Andy Shevchenko | 15c566f | 2018-08-10 13:26:49 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 2 | /* |
Luis Oliveira | 5b6d721 | 2017-06-22 11:17:33 +0100 | [diff] [blame] | 3 | * Synopsys DesignWare I2C adapter driver. |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 4 | * |
| 5 | * Based on the TI DAVINCI I2C adapter driver. |
| 6 | * |
| 7 | * Copyright (C) 2006 Texas Instruments. |
| 8 | * Copyright (C) 2007 MontaVista Software Inc. |
| 9 | * Copyright (C) 2009 Provigent Ltd. |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 10 | */ |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 11 | #include <linux/acpi.h> |
| 12 | #include <linux/clk-provider.h> |
| 13 | #include <linux/clk.h> |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 14 | #include <linux/delay.h> |
Mika Westerberg | 56d4b8a | 2015-09-24 12:06:54 +0300 | [diff] [blame] | 15 | #include <linux/dmi.h> |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 16 | #include <linux/err.h> |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 17 | #include <linux/errno.h> |
| 18 | #include <linux/i2c.h> |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 19 | #include <linux/interrupt.h> |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 20 | #include <linux/io.h> |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/module.h> |
Christian Ruppert | 9803f86 | 2013-06-26 10:55:06 +0200 | [diff] [blame] | 23 | #include <linux/of.h> |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 24 | #include <linux/platform_data/i2c-designware.h> |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 25 | #include <linux/platform_device.h> |
Deepak Sikri | 3bf3b28 | 2012-02-24 17:01:15 +0530 | [diff] [blame] | 26 | #include <linux/pm.h> |
Mika Westerberg | 7272194 | 2013-01-17 12:31:06 +0200 | [diff] [blame] | 27 | #include <linux/pm_runtime.h> |
Mika Westerberg | 4c5301a | 2015-11-30 17:11:44 +0200 | [diff] [blame] | 28 | #include <linux/property.h> |
Zhangfei Gao | ab809fd | 2016-12-27 22:22:40 +0800 | [diff] [blame] | 29 | #include <linux/reset.h> |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 30 | #include <linux/sched.h> |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 31 | #include <linux/slab.h> |
Rafael J. Wysocki | 02e4564 | 2018-01-03 01:37:34 +0100 | [diff] [blame] | 32 | #include <linux/suspend.h> |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 33 | |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 34 | #include "i2c-designware-core.h" |
| 35 | |
Dirk Brandewie | 1d31b58 | 2011-10-06 11:26:30 -0700 | [diff] [blame] | 36 | static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev) |
| 37 | { |
| 38 | return clk_get_rate(dev->clk)/1000; |
| 39 | } |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 40 | |
Mika Westerberg | b61b141 | 2013-01-17 12:31:07 +0200 | [diff] [blame] | 41 | #ifdef CONFIG_ACPI |
Mika Westerberg | 56d4b8a | 2015-09-24 12:06:54 +0300 | [diff] [blame] | 42 | /* |
| 43 | * The HCNT/LCNT information coming from ACPI should be the most accurate |
| 44 | * for given platform. However, some systems get it wrong. On such systems |
| 45 | * we get better results by calculating those based on the input clock. |
| 46 | */ |
| 47 | static const struct dmi_system_id dw_i2c_no_acpi_params[] = { |
| 48 | { |
| 49 | .ident = "Dell Inspiron 7348", |
| 50 | .matches = { |
| 51 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 52 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7348"), |
| 53 | }, |
| 54 | }, |
| 55 | { } |
| 56 | }; |
| 57 | |
Mika Westerberg | 57cd1e3 | 2013-08-19 15:07:54 +0300 | [diff] [blame] | 58 | static void dw_i2c_acpi_params(struct platform_device *pdev, char method[], |
| 59 | u16 *hcnt, u16 *lcnt, u32 *sda_hold) |
| 60 | { |
| 61 | struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER }; |
| 62 | acpi_handle handle = ACPI_HANDLE(&pdev->dev); |
| 63 | union acpi_object *obj; |
| 64 | |
Mika Westerberg | 56d4b8a | 2015-09-24 12:06:54 +0300 | [diff] [blame] | 65 | if (dmi_check_system(dw_i2c_no_acpi_params)) |
| 66 | return; |
| 67 | |
Mika Westerberg | 57cd1e3 | 2013-08-19 15:07:54 +0300 | [diff] [blame] | 68 | if (ACPI_FAILURE(acpi_evaluate_object(handle, method, NULL, &buf))) |
| 69 | return; |
| 70 | |
| 71 | obj = (union acpi_object *)buf.pointer; |
| 72 | if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 3) { |
| 73 | const union acpi_object *objs = obj->package.elements; |
| 74 | |
| 75 | *hcnt = (u16)objs[0].integer.value; |
| 76 | *lcnt = (u16)objs[1].integer.value; |
chin.yew.tan@intel.com | bd698d2 | 2017-03-28 16:48:02 +0800 | [diff] [blame] | 77 | *sda_hold = (u32)objs[2].integer.value; |
Mika Westerberg | 57cd1e3 | 2013-08-19 15:07:54 +0300 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | kfree(buf.pointer); |
| 81 | } |
| 82 | |
Mika Westerberg | b61b141 | 2013-01-17 12:31:07 +0200 | [diff] [blame] | 83 | static int dw_i2c_acpi_configure(struct platform_device *pdev) |
| 84 | { |
| 85 | struct dw_i2c_dev *dev = platform_get_drvdata(pdev); |
Andy Shevchenko | e3ea52b | 2018-07-25 17:39:26 +0300 | [diff] [blame] | 86 | struct i2c_timings *t = &dev->timings; |
Jan Kiszka | ad258fb | 2017-05-22 07:46:55 +0200 | [diff] [blame] | 87 | u32 ss_ht = 0, fp_ht = 0, hs_ht = 0, fs_ht = 0; |
Mika Westerberg | b61b141 | 2013-01-17 12:31:07 +0200 | [diff] [blame] | 88 | |
Mika Westerberg | b61b141 | 2013-01-17 12:31:07 +0200 | [diff] [blame] | 89 | dev->tx_fifo_depth = 32; |
| 90 | dev->rx_fifo_depth = 32; |
Mika Westerberg | 57cd1e3 | 2013-08-19 15:07:54 +0300 | [diff] [blame] | 91 | |
| 92 | /* |
chin.yew.tan@intel.com | bd698d2 | 2017-03-28 16:48:02 +0800 | [diff] [blame] | 93 | * Try to get SDA hold time and *CNT values from an ACPI method for |
| 94 | * selected speed modes. |
Mika Westerberg | 57cd1e3 | 2013-08-19 15:07:54 +0300 | [diff] [blame] | 95 | */ |
Ard Biesheuvel | 9d64084 | 2017-05-19 09:56:40 +0100 | [diff] [blame] | 96 | dw_i2c_acpi_params(pdev, "SSCN", &dev->ss_hcnt, &dev->ss_lcnt, &ss_ht); |
| 97 | dw_i2c_acpi_params(pdev, "FPCN", &dev->fp_hcnt, &dev->fp_lcnt, &fp_ht); |
| 98 | dw_i2c_acpi_params(pdev, "HSCN", &dev->hs_hcnt, &dev->hs_lcnt, &hs_ht); |
| 99 | dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt, &fs_ht); |
| 100 | |
Andy Shevchenko | e3ea52b | 2018-07-25 17:39:26 +0300 | [diff] [blame] | 101 | switch (t->bus_freq_hz) { |
chin.yew.tan@intel.com | bd698d2 | 2017-03-28 16:48:02 +0800 | [diff] [blame] | 102 | case 100000: |
Ard Biesheuvel | 9d64084 | 2017-05-19 09:56:40 +0100 | [diff] [blame] | 103 | dev->sda_hold_time = ss_ht; |
chin.yew.tan@intel.com | bd698d2 | 2017-03-28 16:48:02 +0800 | [diff] [blame] | 104 | break; |
| 105 | case 1000000: |
Ard Biesheuvel | 9d64084 | 2017-05-19 09:56:40 +0100 | [diff] [blame] | 106 | dev->sda_hold_time = fp_ht; |
chin.yew.tan@intel.com | bd698d2 | 2017-03-28 16:48:02 +0800 | [diff] [blame] | 107 | break; |
| 108 | case 3400000: |
Ard Biesheuvel | 9d64084 | 2017-05-19 09:56:40 +0100 | [diff] [blame] | 109 | dev->sda_hold_time = hs_ht; |
chin.yew.tan@intel.com | bd698d2 | 2017-03-28 16:48:02 +0800 | [diff] [blame] | 110 | break; |
| 111 | case 400000: |
| 112 | default: |
Ard Biesheuvel | 9d64084 | 2017-05-19 09:56:40 +0100 | [diff] [blame] | 113 | dev->sda_hold_time = fs_ht; |
chin.yew.tan@intel.com | bd698d2 | 2017-03-28 16:48:02 +0800 | [diff] [blame] | 114 | break; |
| 115 | } |
Mika Westerberg | 57cd1e3 | 2013-08-19 15:07:54 +0300 | [diff] [blame] | 116 | |
Mika Westerberg | b61b141 | 2013-01-17 12:31:07 +0200 | [diff] [blame] | 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | static const struct acpi_device_id dw_i2c_acpi_match[] = { |
| 121 | { "INT33C2", 0 }, |
| 122 | { "INT33C3", 0 }, |
Mika Westerberg | 25b3dfc | 2013-11-12 11:57:30 +0200 | [diff] [blame] | 123 | { "INT3432", 0 }, |
| 124 | { "INT3433", 0 }, |
Hans de Goede | b30f2f6 | 2018-10-06 10:25:39 +0200 | [diff] [blame] | 125 | { "80860F41", ACCESS_NO_IRQ_SUSPEND }, |
| 126 | { "808622C1", ACCESS_NO_IRQ_SUSPEND | MODEL_CHERRYTRAIL }, |
Xiangliang Yu | 2d244c8 | 2015-12-11 20:02:53 +0800 | [diff] [blame] | 127 | { "AMD0010", ACCESS_INTR_MASK }, |
Xiangliang Yu | e4e666b | 2016-03-10 19:34:52 +0800 | [diff] [blame] | 128 | { "AMDI0010", ACCESS_INTR_MASK }, |
Suravee Suthikulpanit | 90708ce | 2015-12-15 15:55:53 -0600 | [diff] [blame] | 129 | { "AMDI0510", 0 }, |
Loc Ho | 04a407f | 2015-12-10 14:19:17 -0700 | [diff] [blame] | 130 | { "APMC0D0F", 0 }, |
Hanjun Guo | 58dd8ab | 2017-04-22 11:23:44 +0800 | [diff] [blame] | 131 | { "HISI02A1", 0 }, |
| 132 | { "HISI02A2", 0 }, |
Hanjun Guo | dec0a81 | 2020-02-03 09:36:07 +0800 | [diff] [blame^] | 133 | { "HISI02A3", 0 }, |
Mika Westerberg | b61b141 | 2013-01-17 12:31:07 +0200 | [diff] [blame] | 134 | { } |
| 135 | }; |
| 136 | MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match); |
| 137 | #else |
| 138 | static inline int dw_i2c_acpi_configure(struct platform_device *pdev) |
| 139 | { |
| 140 | return -ENODEV; |
| 141 | } |
| 142 | #endif |
| 143 | |
Alexandre Belloni | 9674277 | 2018-08-31 17:11:09 +0200 | [diff] [blame] | 144 | #ifdef CONFIG_OF |
Alexandre Belloni | 1bb3995 | 2018-08-31 17:11:12 +0200 | [diff] [blame] | 145 | #define MSCC_ICPU_CFG_TWI_DELAY 0x0 |
| 146 | #define MSCC_ICPU_CFG_TWI_DELAY_ENABLE BIT(0) |
| 147 | #define MSCC_ICPU_CFG_TWI_SPIKE_FILTER 0x4 |
| 148 | |
| 149 | static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev) |
| 150 | { |
| 151 | writel((dev->sda_hold_time << 1) | MSCC_ICPU_CFG_TWI_DELAY_ENABLE, |
| 152 | dev->ext + MSCC_ICPU_CFG_TWI_DELAY); |
| 153 | |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | static int dw_i2c_of_configure(struct platform_device *pdev) |
| 158 | { |
| 159 | struct dw_i2c_dev *dev = platform_get_drvdata(pdev); |
| 160 | struct resource *mem; |
| 161 | |
| 162 | switch (dev->flags & MODEL_MASK) { |
| 163 | case MODEL_MSCC_OCELOT: |
| 164 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 165 | dev->ext = devm_ioremap_resource(&pdev->dev, mem); |
| 166 | if (!IS_ERR(dev->ext)) |
| 167 | dev->set_sda_hold_time = mscc_twi_set_sda_hold_time; |
| 168 | break; |
| 169 | default: |
| 170 | break; |
| 171 | } |
| 172 | |
| 173 | return 0; |
| 174 | } |
| 175 | |
Alexandre Belloni | 9674277 | 2018-08-31 17:11:09 +0200 | [diff] [blame] | 176 | static const struct of_device_id dw_i2c_of_match[] = { |
| 177 | { .compatible = "snps,designware-i2c", }, |
Alexandre Belloni | 1bb3995 | 2018-08-31 17:11:12 +0200 | [diff] [blame] | 178 | { .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT }, |
Alexandre Belloni | 9674277 | 2018-08-31 17:11:09 +0200 | [diff] [blame] | 179 | {}, |
| 180 | }; |
| 181 | MODULE_DEVICE_TABLE(of, dw_i2c_of_match); |
Alexandre Belloni | 1bb3995 | 2018-08-31 17:11:12 +0200 | [diff] [blame] | 182 | #else |
| 183 | static inline int dw_i2c_of_configure(struct platform_device *pdev) |
| 184 | { |
| 185 | return -ENODEV; |
| 186 | } |
Alexandre Belloni | 9674277 | 2018-08-31 17:11:09 +0200 | [diff] [blame] | 187 | #endif |
| 188 | |
Luis Oliveira | 89a1e1b | 2017-06-14 11:43:22 +0100 | [diff] [blame] | 189 | static void i2c_dw_configure_master(struct dw_i2c_dev *dev) |
| 190 | { |
Andy Shevchenko | e3ea52b | 2018-07-25 17:39:26 +0300 | [diff] [blame] | 191 | struct i2c_timings *t = &dev->timings; |
| 192 | |
Luis Oliveira | 5b6d721 | 2017-06-22 11:17:33 +0100 | [diff] [blame] | 193 | dev->functionality = I2C_FUNC_10BIT_ADDR | DW_IC_DEFAULT_FUNCTIONALITY; |
| 194 | |
Luis Oliveira | 89a1e1b | 2017-06-14 11:43:22 +0100 | [diff] [blame] | 195 | dev->master_cfg = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE | |
| 196 | DW_IC_CON_RESTART_EN; |
| 197 | |
Luis Oliveira | 5b6d721 | 2017-06-22 11:17:33 +0100 | [diff] [blame] | 198 | dev->mode = DW_IC_MASTER; |
| 199 | |
Andy Shevchenko | e3ea52b | 2018-07-25 17:39:26 +0300 | [diff] [blame] | 200 | switch (t->bus_freq_hz) { |
Luis Oliveira | 89a1e1b | 2017-06-14 11:43:22 +0100 | [diff] [blame] | 201 | case 100000: |
| 202 | dev->master_cfg |= DW_IC_CON_SPEED_STD; |
| 203 | break; |
| 204 | case 3400000: |
| 205 | dev->master_cfg |= DW_IC_CON_SPEED_HIGH; |
| 206 | break; |
| 207 | default: |
| 208 | dev->master_cfg |= DW_IC_CON_SPEED_FAST; |
| 209 | } |
| 210 | } |
| 211 | |
Luis Oliveira | 5b6d721 | 2017-06-22 11:17:33 +0100 | [diff] [blame] | 212 | static void i2c_dw_configure_slave(struct dw_i2c_dev *dev) |
| 213 | { |
| 214 | dev->functionality = I2C_FUNC_SLAVE | DW_IC_DEFAULT_FUNCTIONALITY; |
| 215 | |
| 216 | dev->slave_cfg = DW_IC_CON_RX_FIFO_FULL_HLD_CTRL | |
Jarkko Nikula | 4e2d93d | 2017-08-09 15:24:44 +0300 | [diff] [blame] | 217 | DW_IC_CON_RESTART_EN | DW_IC_CON_STOP_DET_IFADDRESSED; |
Luis Oliveira | 5b6d721 | 2017-06-22 11:17:33 +0100 | [diff] [blame] | 218 | |
| 219 | dev->mode = DW_IC_SLAVE; |
Suravee Suthikulpanit | b33af11 | 2016-01-04 09:17:35 -0600 | [diff] [blame] | 220 | } |
| 221 | |
Hans de Goede | 77f3381 | 2019-03-12 15:55:53 +0100 | [diff] [blame] | 222 | static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev) |
Tin Huynh | 8e59876 | 2016-12-14 16:23:58 +0700 | [diff] [blame] | 223 | { |
| 224 | u32 param, tx_fifo_depth, rx_fifo_depth; |
| 225 | |
| 226 | /* |
| 227 | * Try to detect the FIFO depth if not set by interface driver, |
| 228 | * the depth could be from 2 to 256 from HW spec. |
| 229 | */ |
| 230 | param = i2c_dw_read_comp_param(dev); |
| 231 | tx_fifo_depth = ((param >> 16) & 0xff) + 1; |
| 232 | rx_fifo_depth = ((param >> 8) & 0xff) + 1; |
| 233 | if (!dev->tx_fifo_depth) { |
| 234 | dev->tx_fifo_depth = tx_fifo_depth; |
| 235 | dev->rx_fifo_depth = rx_fifo_depth; |
Tin Huynh | 8e59876 | 2016-12-14 16:23:58 +0700 | [diff] [blame] | 236 | } else if (tx_fifo_depth >= 2) { |
| 237 | dev->tx_fifo_depth = min_t(u32, dev->tx_fifo_depth, |
| 238 | tx_fifo_depth); |
| 239 | dev->rx_fifo_depth = min_t(u32, dev->rx_fifo_depth, |
| 240 | rx_fifo_depth); |
| 241 | } |
| 242 | } |
| 243 | |
Rafael J. Wysocki | 126dbc6 | 2017-09-25 23:10:06 +0200 | [diff] [blame] | 244 | static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev) |
| 245 | { |
| 246 | pm_runtime_disable(dev->dev); |
| 247 | |
Hans de Goede | 9cbeeca | 2018-09-05 21:51:31 +0200 | [diff] [blame] | 248 | if (dev->shared_with_punit) |
Rafael J. Wysocki | 126dbc6 | 2017-09-25 23:10:06 +0200 | [diff] [blame] | 249 | pm_runtime_put_noidle(dev->dev); |
| 250 | } |
| 251 | |
Jarkko Nikula | 6ad6fde | 2015-08-31 17:31:32 +0300 | [diff] [blame] | 252 | static int dw_i2c_plat_probe(struct platform_device *pdev) |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 253 | { |
Mika Westerberg | 4c5301a | 2015-11-30 17:11:44 +0200 | [diff] [blame] | 254 | struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev); |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 255 | struct i2c_adapter *adap; |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 256 | struct dw_i2c_dev *dev; |
Andy Shevchenko | e3ea52b | 2018-07-25 17:39:26 +0300 | [diff] [blame] | 257 | struct i2c_timings *t; |
| 258 | u32 acpi_speed; |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 259 | struct resource *mem; |
Hans de Goede | 231d069 | 2017-08-29 14:08:35 +0200 | [diff] [blame] | 260 | int i, irq, ret; |
Colin Ian King | 4ce8e88 | 2017-09-21 23:30:07 +0100 | [diff] [blame] | 261 | static const int supported_speeds[] = { |
| 262 | 0, 100000, 400000, 1000000, 3400000 |
| 263 | }; |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 264 | |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 265 | irq = platform_get_irq(pdev, 0); |
Alexey Brodkin | b20d386 | 2015-03-09 12:03:12 +0300 | [diff] [blame] | 266 | if (irq < 0) |
| 267 | return irq; |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 268 | |
Andy Shevchenko | 1cb715c | 2013-04-10 00:36:36 +0000 | [diff] [blame] | 269 | dev = devm_kzalloc(&pdev->dev, sizeof(struct dw_i2c_dev), GFP_KERNEL); |
| 270 | if (!dev) |
| 271 | return -ENOMEM; |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 272 | |
Wolfram Sang | 3cc2d00 | 2013-05-10 10:16:54 +0200 | [diff] [blame] | 273 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Andy Shevchenko | 1cb715c | 2013-04-10 00:36:36 +0000 | [diff] [blame] | 274 | dev->base = devm_ioremap_resource(&pdev->dev, mem); |
| 275 | if (IS_ERR(dev->base)) |
| 276 | return PTR_ERR(dev->base); |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 277 | |
Andy Shevchenko | 1cb715c | 2013-04-10 00:36:36 +0000 | [diff] [blame] | 278 | dev->dev = &pdev->dev; |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 279 | dev->irq = irq; |
| 280 | platform_set_drvdata(pdev, dev); |
| 281 | |
Zhangfei Gao | ab809fd | 2016-12-27 22:22:40 +0800 | [diff] [blame] | 282 | dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); |
Andy Shevchenko | a6af48e | 2019-08-19 13:31:30 +0300 | [diff] [blame] | 283 | if (IS_ERR(dev->rst)) |
| 284 | return PTR_ERR(dev->rst); |
| 285 | |
| 286 | reset_control_deassert(dev->rst); |
Zhangfei Gao | ab809fd | 2016-12-27 22:22:40 +0800 | [diff] [blame] | 287 | |
Andy Shevchenko | e3ea52b | 2018-07-25 17:39:26 +0300 | [diff] [blame] | 288 | t = &dev->timings; |
| 289 | if (pdata) |
| 290 | t->bus_freq_hz = pdata->i2c_scl_freq; |
| 291 | else |
| 292 | i2c_parse_fw_timings(&pdev->dev, t, false); |
Mika Westerberg | 4c5301a | 2015-11-30 17:11:44 +0200 | [diff] [blame] | 293 | |
Jarkko Nikula | 10f8e7f | 2016-08-12 17:02:54 +0300 | [diff] [blame] | 294 | acpi_speed = i2c_acpi_find_bus_speed(&pdev->dev); |
Hans de Goede | 231d069 | 2017-08-29 14:08:35 +0200 | [diff] [blame] | 295 | /* |
| 296 | * Some DSTDs use a non standard speed, round down to the lowest |
| 297 | * standard speed. |
| 298 | */ |
| 299 | for (i = 1; i < ARRAY_SIZE(supported_speeds); i++) { |
| 300 | if (acpi_speed < supported_speeds[i]) |
| 301 | break; |
| 302 | } |
| 303 | acpi_speed = supported_speeds[i - 1]; |
| 304 | |
Jarkko Nikula | 973652d | 2016-11-10 13:37:20 +0200 | [diff] [blame] | 305 | /* |
| 306 | * Find bus speed from the "clock-frequency" device property, ACPI |
| 307 | * or by using fast mode if neither is set. |
| 308 | */ |
Andy Shevchenko | e3ea52b | 2018-07-25 17:39:26 +0300 | [diff] [blame] | 309 | if (acpi_speed && t->bus_freq_hz) |
| 310 | t->bus_freq_hz = min(t->bus_freq_hz, acpi_speed); |
| 311 | else if (acpi_speed || t->bus_freq_hz) |
| 312 | t->bus_freq_hz = max(t->bus_freq_hz, acpi_speed); |
Jarkko Nikula | 973652d | 2016-11-10 13:37:20 +0200 | [diff] [blame] | 313 | else |
Andy Shevchenko | e3ea52b | 2018-07-25 17:39:26 +0300 | [diff] [blame] | 314 | t->bus_freq_hz = 400000; |
Jarkko Nikula | 10f8e7f | 2016-08-12 17:02:54 +0300 | [diff] [blame] | 315 | |
Alexandre Belloni | 1732c22 | 2018-08-31 17:11:08 +0200 | [diff] [blame] | 316 | dev->flags |= (uintptr_t)device_get_match_data(&pdev->dev); |
| 317 | |
Alexandre Belloni | 1bb3995 | 2018-08-31 17:11:12 +0200 | [diff] [blame] | 318 | if (pdev->dev.of_node) |
| 319 | dw_i2c_of_configure(pdev); |
| 320 | |
Mika Westerberg | 4c5301a | 2015-11-30 17:11:44 +0200 | [diff] [blame] | 321 | if (has_acpi_companion(&pdev->dev)) |
| 322 | dw_i2c_acpi_configure(pdev); |
| 323 | |
| 324 | /* |
Weifeng Voon | d608c3d | 2016-08-12 17:02:49 +0300 | [diff] [blame] | 325 | * Only standard mode at 100kHz, fast mode at 400kHz, |
Weifeng Voon | b6e6714 | 2016-08-12 17:02:51 +0300 | [diff] [blame] | 326 | * fast mode plus at 1MHz and high speed mode at 3.4MHz are supported. |
Mika Westerberg | 4c5301a | 2015-11-30 17:11:44 +0200 | [diff] [blame] | 327 | */ |
Andy Shevchenko | e3ea52b | 2018-07-25 17:39:26 +0300 | [diff] [blame] | 328 | if (t->bus_freq_hz != 100000 && t->bus_freq_hz != 400000 && |
| 329 | t->bus_freq_hz != 1000000 && t->bus_freq_hz != 3400000) { |
Weifeng Voon | d608c3d | 2016-08-12 17:02:49 +0300 | [diff] [blame] | 330 | dev_err(&pdev->dev, |
Hans de Goede | 22acc37 | 2017-07-13 15:45:01 +0200 | [diff] [blame] | 331 | "%d Hz is unsupported, only 100kHz, 400kHz, 1MHz and 3.4MHz are supported\n", |
Andy Shevchenko | e3ea52b | 2018-07-25 17:39:26 +0300 | [diff] [blame] | 332 | t->bus_freq_hz); |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 333 | ret = -EINVAL; |
Zhangfei Gao | ab809fd | 2016-12-27 22:22:40 +0800 | [diff] [blame] | 334 | goto exit_reset; |
Christian Ruppert | 9803f86 | 2013-06-26 10:55:06 +0200 | [diff] [blame] | 335 | } |
| 336 | |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 337 | ret = i2c_dw_probe_lock_support(dev); |
| 338 | if (ret) |
Zhangfei Gao | ab809fd | 2016-12-27 22:22:40 +0800 | [diff] [blame] | 339 | goto exit_reset; |
David Box | 894acb2 | 2015-01-15 01:12:17 -0800 | [diff] [blame] | 340 | |
Luis Oliveira | 5b6d721 | 2017-06-22 11:17:33 +0100 | [diff] [blame] | 341 | if (i2c_detect_slave_mode(&pdev->dev)) |
| 342 | i2c_dw_configure_slave(dev); |
| 343 | else |
| 344 | i2c_dw_configure_master(dev); |
Dirk Brandewie | 2fa8326 | 2011-10-06 11:26:31 -0700 | [diff] [blame] | 345 | |
Phil Edworthy | c62ebb3 | 2019-02-28 13:52:10 +0000 | [diff] [blame] | 346 | /* Optional interface clock */ |
| 347 | dev->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); |
Andy Shevchenko | 71dc297 | 2019-08-19 13:24:23 +0300 | [diff] [blame] | 348 | if (IS_ERR(dev->pclk)) { |
| 349 | ret = PTR_ERR(dev->pclk); |
| 350 | goto exit_reset; |
| 351 | } |
Phil Edworthy | c62ebb3 | 2019-02-28 13:52:10 +0000 | [diff] [blame] | 352 | |
Mika Westerberg | 925ddb2 | 2014-09-30 13:04:54 +0300 | [diff] [blame] | 353 | dev->clk = devm_clk_get(&pdev->dev, NULL); |
Phil Reid | 0326f9f | 2017-11-02 10:40:26 +0800 | [diff] [blame] | 354 | if (!i2c_dw_prepare_clk(dev, true)) { |
Andy Shevchenko | e3ea52b | 2018-07-25 17:39:26 +0300 | [diff] [blame] | 355 | u64 clk_khz; |
Mika Westerberg | 925ddb2 | 2014-09-30 13:04:54 +0300 | [diff] [blame] | 356 | |
Andy Shevchenko | e3ea52b | 2018-07-25 17:39:26 +0300 | [diff] [blame] | 357 | dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; |
| 358 | clk_khz = dev->get_clk_rate_khz(dev); |
| 359 | |
| 360 | if (!dev->sda_hold_time && t->sda_hold_ns) |
| 361 | dev->sda_hold_time = |
| 362 | div_u64(clk_khz * t->sda_hold_ns + 500000, 1000000); |
Mika Westerberg | 925ddb2 | 2014-09-30 13:04:54 +0300 | [diff] [blame] | 363 | } |
| 364 | |
Hans de Goede | 77f3381 | 2019-03-12 15:55:53 +0100 | [diff] [blame] | 365 | dw_i2c_set_fifo_size(dev); |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 366 | |
| 367 | adap = &dev->adapter; |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 368 | adap->owner = THIS_MODULE; |
Wolfram Sang | 70fba83 | 2014-07-10 13:46:26 +0200 | [diff] [blame] | 369 | adap->class = I2C_CLASS_DEPRECATED; |
Dustin Byford | 8eb5c87 | 2015-10-23 12:27:07 -0700 | [diff] [blame] | 370 | ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); |
Rob Herring | af71100 | 2011-11-08 14:43:47 -0600 | [diff] [blame] | 371 | adap->dev.of_node = pdev->dev.of_node; |
Hans de Goede | cd86d14 | 2019-03-12 15:55:54 +0100 | [diff] [blame] | 372 | adap->nr = -1; |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 373 | |
Rafael J. Wysocki | 02e4564 | 2018-01-03 01:37:34 +0100 | [diff] [blame] | 374 | dev_pm_set_driver_flags(&pdev->dev, |
| 375 | DPM_FLAG_SMART_PREPARE | |
| 376 | DPM_FLAG_SMART_SUSPEND | |
| 377 | DPM_FLAG_LEAVE_SUSPENDED); |
Rafael J. Wysocki | 422cb78 | 2018-01-03 01:35:54 +0100 | [diff] [blame] | 378 | |
Rafael J. Wysocki | 126dbc6 | 2017-09-25 23:10:06 +0200 | [diff] [blame] | 379 | /* The code below assumes runtime PM to be disabled. */ |
| 380 | WARN_ON(pm_runtime_enabled(&pdev->dev)); |
| 381 | |
| 382 | pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); |
| 383 | pm_runtime_use_autosuspend(&pdev->dev); |
| 384 | pm_runtime_set_active(&pdev->dev); |
| 385 | |
Hans de Goede | 9cbeeca | 2018-09-05 21:51:31 +0200 | [diff] [blame] | 386 | if (dev->shared_with_punit) |
Rafael J. Wysocki | 126dbc6 | 2017-09-25 23:10:06 +0200 | [diff] [blame] | 387 | pm_runtime_get_noresume(&pdev->dev); |
| 388 | |
| 389 | pm_runtime_enable(&pdev->dev); |
Mika Westerberg | 7272194 | 2013-01-17 12:31:06 +0200 | [diff] [blame] | 390 | |
Luis Oliveira | 5b6d721 | 2017-06-22 11:17:33 +0100 | [diff] [blame] | 391 | if (dev->mode == DW_IC_SLAVE) |
| 392 | ret = i2c_dw_probe_slave(dev); |
| 393 | else |
| 394 | ret = i2c_dw_probe(dev); |
| 395 | |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 396 | if (ret) |
Zhangfei Gao | ab809fd | 2016-12-27 22:22:40 +0800 | [diff] [blame] | 397 | goto exit_probe; |
Wolfram Sang | 36d48fb | 2015-10-09 10:39:24 +0100 | [diff] [blame] | 398 | |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 399 | return ret; |
Zhangfei Gao | ab809fd | 2016-12-27 22:22:40 +0800 | [diff] [blame] | 400 | |
| 401 | exit_probe: |
Rafael J. Wysocki | 126dbc6 | 2017-09-25 23:10:06 +0200 | [diff] [blame] | 402 | dw_i2c_plat_pm_cleanup(dev); |
Zhangfei Gao | ab809fd | 2016-12-27 22:22:40 +0800 | [diff] [blame] | 403 | exit_reset: |
Andy Shevchenko | a6af48e | 2019-08-19 13:31:30 +0300 | [diff] [blame] | 404 | reset_control_assert(dev->rst); |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 405 | return ret; |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 406 | } |
| 407 | |
Jarkko Nikula | 6ad6fde | 2015-08-31 17:31:32 +0300 | [diff] [blame] | 408 | static int dw_i2c_plat_remove(struct platform_device *pdev) |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 409 | { |
| 410 | struct dw_i2c_dev *dev = platform_get_drvdata(pdev); |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 411 | |
Mika Westerberg | 7272194 | 2013-01-17 12:31:06 +0200 | [diff] [blame] | 412 | pm_runtime_get_sync(&pdev->dev); |
| 413 | |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 414 | i2c_del_adapter(&dev->adapter); |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 415 | |
Luis Oliveira | 9031235 | 2017-06-14 11:43:23 +0100 | [diff] [blame] | 416 | dev->disable(dev); |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 417 | |
Mika Westerberg | edfc390 | 2015-06-17 12:08:38 +0300 | [diff] [blame] | 418 | pm_runtime_dont_use_autosuspend(&pdev->dev); |
| 419 | pm_runtime_put_sync(&pdev->dev); |
Rafael J. Wysocki | 126dbc6 | 2017-09-25 23:10:06 +0200 | [diff] [blame] | 420 | dw_i2c_plat_pm_cleanup(dev); |
| 421 | |
Andy Shevchenko | a6af48e | 2019-08-19 13:31:30 +0300 | [diff] [blame] | 422 | reset_control_assert(dev->rst); |
Mika Westerberg | 7272194 | 2013-01-17 12:31:06 +0200 | [diff] [blame] | 423 | |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 424 | return 0; |
| 425 | } |
| 426 | |
Jisheng Zhang | 8503ff1 | 2015-05-20 22:33:13 +0800 | [diff] [blame] | 427 | #ifdef CONFIG_PM_SLEEP |
Jarkko Nikula | 6ad6fde | 2015-08-31 17:31:32 +0300 | [diff] [blame] | 428 | static int dw_i2c_plat_prepare(struct device *dev) |
Jisheng Zhang | 8503ff1 | 2015-05-20 22:33:13 +0800 | [diff] [blame] | 429 | { |
Rafael J. Wysocki | 422cb78 | 2018-01-03 01:35:54 +0100 | [diff] [blame] | 430 | /* |
| 431 | * If the ACPI companion device object is present for this device, it |
| 432 | * may be accessed during suspend and resume of other devices via I2C |
| 433 | * operation regions, so tell the PM core and middle layers to avoid |
| 434 | * skipping system suspend/resume callbacks for it in that case. |
| 435 | */ |
| 436 | return !has_acpi_companion(dev); |
Jisheng Zhang | 8503ff1 | 2015-05-20 22:33:13 +0800 | [diff] [blame] | 437 | } |
| 438 | |
Jarkko Nikula | 6ad6fde | 2015-08-31 17:31:32 +0300 | [diff] [blame] | 439 | static void dw_i2c_plat_complete(struct device *dev) |
Jisheng Zhang | 8503ff1 | 2015-05-20 22:33:13 +0800 | [diff] [blame] | 440 | { |
Rafael J. Wysocki | 02e4564 | 2018-01-03 01:37:34 +0100 | [diff] [blame] | 441 | /* |
| 442 | * The device can only be in runtime suspend at this point if it has not |
| 443 | * been resumed throughout the ending system suspend/resume cycle, so if |
| 444 | * the platform firmware might mess up with it, request the runtime PM |
| 445 | * framework to resume it. |
| 446 | */ |
| 447 | if (pm_runtime_suspended(dev) && pm_resume_via_firmware()) |
Jisheng Zhang | 8503ff1 | 2015-05-20 22:33:13 +0800 | [diff] [blame] | 448 | pm_request_resume(dev); |
| 449 | } |
| 450 | #else |
Jarkko Nikula | 319d7f0 | 2015-10-21 10:09:17 +0300 | [diff] [blame] | 451 | #define dw_i2c_plat_prepare NULL |
| 452 | #define dw_i2c_plat_complete NULL |
Jisheng Zhang | 8503ff1 | 2015-05-20 22:33:13 +0800 | [diff] [blame] | 453 | #endif |
| 454 | |
Mika Westerberg | 1fc2fe2 | 2014-05-15 17:37:23 +0300 | [diff] [blame] | 455 | #ifdef CONFIG_PM |
Rafael J. Wysocki | 5415277 | 2017-09-25 01:30:51 +0200 | [diff] [blame] | 456 | static int dw_i2c_plat_suspend(struct device *dev) |
Deepak Sikri | 3bf3b28 | 2012-02-24 17:01:15 +0530 | [diff] [blame] | 457 | { |
Masahiro Yamada | 9242e72 | 2017-07-28 01:16:24 +0900 | [diff] [blame] | 458 | struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); |
Deepak Sikri | 3bf3b28 | 2012-02-24 17:01:15 +0530 | [diff] [blame] | 459 | |
Hans de Goede | 2751541 | 2019-02-22 14:08:40 +0100 | [diff] [blame] | 460 | i_dev->suspended = true; |
| 461 | |
Hans de Goede | 9cbeeca | 2018-09-05 21:51:31 +0200 | [diff] [blame] | 462 | if (i_dev->shared_with_punit) |
Hans de Goede | 9d9a152 | 2018-08-29 15:06:31 +0200 | [diff] [blame] | 463 | return 0; |
| 464 | |
Luis Oliveira | 9031235 | 2017-06-14 11:43:23 +0100 | [diff] [blame] | 465 | i_dev->disable(i_dev); |
Phil Reid | 0326f9f | 2017-11-02 10:40:26 +0800 | [diff] [blame] | 466 | i2c_dw_prepare_clk(i_dev, false); |
Deepak Sikri | 3bf3b28 | 2012-02-24 17:01:15 +0530 | [diff] [blame] | 467 | |
| 468 | return 0; |
| 469 | } |
| 470 | |
Jarkko Nikula | 6ad6fde | 2015-08-31 17:31:32 +0300 | [diff] [blame] | 471 | static int dw_i2c_plat_resume(struct device *dev) |
Deepak Sikri | 3bf3b28 | 2012-02-24 17:01:15 +0530 | [diff] [blame] | 472 | { |
Masahiro Yamada | 9242e72 | 2017-07-28 01:16:24 +0900 | [diff] [blame] | 473 | struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); |
Deepak Sikri | 3bf3b28 | 2012-02-24 17:01:15 +0530 | [diff] [blame] | 474 | |
Hans de Goede | 9cbeeca | 2018-09-05 21:51:31 +0200 | [diff] [blame] | 475 | if (!i_dev->shared_with_punit) |
Hans de Goede | 9d9a152 | 2018-08-29 15:06:31 +0200 | [diff] [blame] | 476 | i2c_dw_prepare_clk(i_dev, true); |
| 477 | |
Luis Oliveira | 9031235 | 2017-06-14 11:43:23 +0100 | [diff] [blame] | 478 | i_dev->init(i_dev); |
Hans de Goede | 2751541 | 2019-02-22 14:08:40 +0100 | [diff] [blame] | 479 | i_dev->suspended = false; |
Deepak Sikri | 3bf3b28 | 2012-02-24 17:01:15 +0530 | [diff] [blame] | 480 | |
| 481 | return 0; |
| 482 | } |
Deepak Sikri | 3bf3b28 | 2012-02-24 17:01:15 +0530 | [diff] [blame] | 483 | |
Jisheng Zhang | 8503ff1 | 2015-05-20 22:33:13 +0800 | [diff] [blame] | 484 | static const struct dev_pm_ops dw_i2c_dev_pm_ops = { |
Jarkko Nikula | 6ad6fde | 2015-08-31 17:31:32 +0300 | [diff] [blame] | 485 | .prepare = dw_i2c_plat_prepare, |
| 486 | .complete = dw_i2c_plat_complete, |
Rafael J. Wysocki | 5415277 | 2017-09-25 01:30:51 +0200 | [diff] [blame] | 487 | SET_LATE_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume) |
| 488 | SET_RUNTIME_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume, NULL) |
Jisheng Zhang | 8503ff1 | 2015-05-20 22:33:13 +0800 | [diff] [blame] | 489 | }; |
| 490 | |
| 491 | #define DW_I2C_DEV_PMOPS (&dw_i2c_dev_pm_ops) |
| 492 | #else |
| 493 | #define DW_I2C_DEV_PMOPS NULL |
| 494 | #endif |
Mika Westerberg | 1fc2fe2 | 2014-05-15 17:37:23 +0300 | [diff] [blame] | 495 | |
Luis Oliveira | e393f67 | 2017-06-14 11:43:21 +0100 | [diff] [blame] | 496 | /* Work with hotplug and coldplug */ |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 497 | MODULE_ALIAS("platform:i2c_designware"); |
| 498 | |
| 499 | static struct platform_driver dw_i2c_driver = { |
Jarkko Nikula | 6ad6fde | 2015-08-31 17:31:32 +0300 | [diff] [blame] | 500 | .probe = dw_i2c_plat_probe, |
| 501 | .remove = dw_i2c_plat_remove, |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 502 | .driver = { |
| 503 | .name = "i2c_designware", |
Rob Herring | af71100 | 2011-11-08 14:43:47 -0600 | [diff] [blame] | 504 | .of_match_table = of_match_ptr(dw_i2c_of_match), |
Mika Westerberg | b61b141 | 2013-01-17 12:31:07 +0200 | [diff] [blame] | 505 | .acpi_match_table = ACPI_PTR(dw_i2c_acpi_match), |
Jisheng Zhang | 8503ff1 | 2015-05-20 22:33:13 +0800 | [diff] [blame] | 506 | .pm = DW_I2C_DEV_PMOPS, |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 507 | }, |
| 508 | }; |
| 509 | |
| 510 | static int __init dw_i2c_init_driver(void) |
| 511 | { |
Wolfram Sang | cccdcea | 2013-10-08 22:35:33 +0200 | [diff] [blame] | 512 | return platform_driver_register(&dw_i2c_driver); |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 513 | } |
Pratyush Anand | 1045228 | 2012-02-29 12:27:46 +0530 | [diff] [blame] | 514 | subsys_initcall(dw_i2c_init_driver); |
Dirk Brandewie | 2373f6b | 2011-10-29 10:57:23 +0100 | [diff] [blame] | 515 | |
| 516 | static void __exit dw_i2c_exit_driver(void) |
| 517 | { |
| 518 | platform_driver_unregister(&dw_i2c_driver); |
| 519 | } |
| 520 | module_exit(dw_i2c_exit_driver); |
| 521 | |
| 522 | MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>"); |
| 523 | MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter"); |
| 524 | MODULE_LICENSE("GPL"); |