2018-08-10 13:26:49 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2011-10-29 10:57:23 +01:00
|
|
|
/*
|
2017-06-22 11:17:33 +01:00
|
|
|
* Synopsys DesignWare I2C adapter driver.
|
2011-10-29 10:57:23 +01:00
|
|
|
*
|
|
|
|
* Based on the TI DAVINCI I2C adapter driver.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Texas Instruments.
|
|
|
|
* Copyright (C) 2007 MontaVista Software Inc.
|
|
|
|
* Copyright (C) 2009 Provigent Ltd.
|
|
|
|
*/
|
2017-06-14 11:43:21 +01:00
|
|
|
#include <linux/clk-provider.h>
|
|
|
|
#include <linux/clk.h>
|
2011-10-29 10:57:23 +01:00
|
|
|
#include <linux/delay.h>
|
2020-07-02 12:33:21 +02:00
|
|
|
#include <linux/dmi.h>
|
2011-10-29 10:57:23 +01:00
|
|
|
#include <linux/err.h>
|
2017-06-14 11:43:21 +01:00
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/i2c.h>
|
2011-10-29 10:57:23 +01:00
|
|
|
#include <linux/interrupt.h>
|
2017-06-14 11:43:21 +01:00
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/kernel.h>
|
2020-05-28 12:33:21 +03:00
|
|
|
#include <linux/mfd/syscon.h>
|
2017-06-14 11:43:21 +01:00
|
|
|
#include <linux/module.h>
|
2011-10-29 10:57:23 +01:00
|
|
|
#include <linux/platform_device.h>
|
2012-02-24 17:01:15 +05:30
|
|
|
#include <linux/pm.h>
|
2013-01-17 12:31:06 +02:00
|
|
|
#include <linux/pm_runtime.h>
|
2015-11-30 17:11:44 +02:00
|
|
|
#include <linux/property.h>
|
2020-05-28 12:33:21 +03:00
|
|
|
#include <linux/regmap.h>
|
2016-12-27 22:22:40 +08:00
|
|
|
#include <linux/reset.h>
|
2017-06-14 11:43:21 +01:00
|
|
|
#include <linux/sched.h>
|
2011-10-29 10:57:23 +01:00
|
|
|
#include <linux/slab.h>
|
2021-07-12 17:20:26 +03:00
|
|
|
#include <linux/units.h>
|
2017-06-14 11:43:21 +01:00
|
|
|
|
2011-10-29 10:57:23 +01:00
|
|
|
#include "i2c-designware-core.h"
|
|
|
|
|
2011-10-06 11:26:30 -07:00
|
|
|
static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev)
|
|
|
|
{
|
2021-07-12 17:20:26 +03:00
|
|
|
return clk_get_rate(dev->clk) / KILO;
|
2011-10-06 11:26:30 -07:00
|
|
|
}
|
2011-10-29 10:57:23 +01:00
|
|
|
|
2018-08-31 17:11:09 +02:00
|
|
|
#ifdef CONFIG_OF
|
2020-05-28 12:33:21 +03:00
|
|
|
#define BT1_I2C_CTL 0x100
|
|
|
|
#define BT1_I2C_CTL_ADDR_MASK GENMASK(7, 0)
|
|
|
|
#define BT1_I2C_CTL_WR BIT(8)
|
|
|
|
#define BT1_I2C_CTL_GO BIT(31)
|
|
|
|
#define BT1_I2C_DI 0x104
|
|
|
|
#define BT1_I2C_DO 0x108
|
|
|
|
|
|
|
|
static int bt1_i2c_read(void *context, unsigned int reg, unsigned int *val)
|
|
|
|
{
|
|
|
|
struct dw_i2c_dev *dev = context;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note these methods shouldn't ever fail because the system controller
|
|
|
|
* registers are memory mapped. We check the return value just in case.
|
|
|
|
*/
|
|
|
|
ret = regmap_write(dev->sysmap, BT1_I2C_CTL,
|
|
|
|
BT1_I2C_CTL_GO | (reg & BT1_I2C_CTL_ADDR_MASK));
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return regmap_read(dev->sysmap, BT1_I2C_DO, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bt1_i2c_write(void *context, unsigned int reg, unsigned int val)
|
|
|
|
{
|
|
|
|
struct dw_i2c_dev *dev = context;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = regmap_write(dev->sysmap, BT1_I2C_DI, val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return regmap_write(dev->sysmap, BT1_I2C_CTL,
|
2024-09-25 15:44:23 +03:00
|
|
|
BT1_I2C_CTL_GO | BT1_I2C_CTL_WR | (reg & BT1_I2C_CTL_ADDR_MASK));
|
2020-05-28 12:33:21 +03:00
|
|
|
}
|
|
|
|
|
2024-07-05 20:06:25 +02:00
|
|
|
static const struct regmap_config bt1_i2c_cfg = {
|
2020-05-28 12:33:21 +03:00
|
|
|
.reg_bits = 32,
|
|
|
|
.val_bits = 32,
|
|
|
|
.reg_stride = 4,
|
|
|
|
.fast_io = true,
|
|
|
|
.reg_read = bt1_i2c_read,
|
|
|
|
.reg_write = bt1_i2c_write,
|
|
|
|
.max_register = DW_IC_COMP_TYPE,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
|
|
|
|
{
|
|
|
|
dev->sysmap = syscon_node_to_regmap(dev->dev->of_node->parent);
|
|
|
|
if (IS_ERR(dev->sysmap))
|
|
|
|
return PTR_ERR(dev->sysmap);
|
|
|
|
|
|
|
|
dev->map = devm_regmap_init(dev->dev, NULL, dev, &bt1_i2c_cfg);
|
|
|
|
return PTR_ERR_OR_ZERO(dev->map);
|
|
|
|
}
|
2018-08-31 17:11:12 +02:00
|
|
|
#else
|
2020-05-28 12:33:21 +03:00
|
|
|
static int bt1_i2c_request_regs(struct dw_i2c_dev *dev)
|
2018-08-31 17:11:12 +02:00
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2018-08-31 17:11:09 +02:00
|
|
|
#endif
|
2016-01-04 09:17:35 -06:00
|
|
|
|
2023-06-05 10:52:04 +08:00
|
|
|
static int txgbe_i2c_request_regs(struct dw_i2c_dev *dev)
|
|
|
|
{
|
|
|
|
dev->map = dev_get_regmap(dev->dev->parent, NULL);
|
|
|
|
if (!dev->map)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-09-25 23:10:06 +02:00
|
|
|
static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev)
|
|
|
|
{
|
|
|
|
pm_runtime_disable(dev->dev);
|
|
|
|
|
2018-09-05 21:51:31 +02:00
|
|
|
if (dev->shared_with_punit)
|
2017-09-25 23:10:06 +02:00
|
|
|
pm_runtime_put_noidle(dev->dev);
|
|
|
|
}
|
|
|
|
|
2020-05-28 12:33:20 +03:00
|
|
|
static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev)
|
|
|
|
{
|
|
|
|
struct platform_device *pdev = to_platform_device(dev->dev);
|
2020-05-28 12:33:21 +03:00
|
|
|
int ret;
|
2020-05-28 12:33:20 +03:00
|
|
|
|
2020-05-28 12:33:21 +03:00
|
|
|
switch (dev->flags & MODEL_MASK) {
|
|
|
|
case MODEL_BAIKAL_BT1:
|
|
|
|
ret = bt1_i2c_request_regs(dev);
|
|
|
|
break;
|
2023-06-05 10:52:04 +08:00
|
|
|
case MODEL_WANGXUN_SP:
|
|
|
|
ret = txgbe_i2c_request_regs(dev);
|
|
|
|
break;
|
2020-05-28 12:33:21 +03:00
|
|
|
default:
|
|
|
|
dev->base = devm_platform_ioremap_resource(pdev, 0);
|
|
|
|
ret = PTR_ERR_OR_ZERO(dev->base);
|
|
|
|
break;
|
|
|
|
}
|
2020-05-28 12:33:20 +03:00
|
|
|
|
2020-05-28 12:33:21 +03:00
|
|
|
return ret;
|
2020-05-28 12:33:20 +03:00
|
|
|
}
|
2020-03-24 14:32:16 +02:00
|
|
|
|
2020-07-02 12:33:21 +02:00
|
|
|
static const struct dmi_system_id dw_i2c_hwmon_class_dmi[] = {
|
|
|
|
{
|
|
|
|
.ident = "Qtechnology QT5222",
|
|
|
|
.matches = {
|
|
|
|
DMI_MATCH(DMI_SYS_VENDOR, "Qtechnology"),
|
|
|
|
DMI_MATCH(DMI_PRODUCT_NAME, "QT5222"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ } /* terminate list */
|
|
|
|
};
|
|
|
|
|
2022-02-08 15:12:18 +01:00
|
|
|
static const struct i2c_dw_semaphore_callbacks i2c_dw_semaphore_cb_table[] = {
|
|
|
|
#ifdef CONFIG_I2C_DESIGNWARE_BAYTRAIL
|
|
|
|
{
|
|
|
|
.probe = i2c_dw_baytrail_probe_lock_support,
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_I2C_DESIGNWARE_AMDPSP
|
|
|
|
{
|
|
|
|
.probe = i2c_dw_amdpsp_probe_lock_support,
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
static int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
|
|
|
|
{
|
|
|
|
const struct i2c_dw_semaphore_callbacks *ptr;
|
|
|
|
int i = 0;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
dev->semaphore_idx = -1;
|
|
|
|
|
2024-08-19 21:45:07 +03:00
|
|
|
for (ptr = i2c_dw_semaphore_cb_table; ptr->probe; ptr++) {
|
2022-02-08 15:12:18 +01:00
|
|
|
ret = ptr->probe(dev);
|
|
|
|
if (ret) {
|
|
|
|
/*
|
|
|
|
* If there is no semaphore device attached to this
|
|
|
|
* controller, we shouldn't abort general i2c_controller
|
|
|
|
* probe.
|
|
|
|
*/
|
|
|
|
if (ret != -ENODEV)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev->semaphore_idx = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void i2c_dw_remove_lock_support(struct dw_i2c_dev *dev)
|
|
|
|
{
|
|
|
|
if (dev->semaphore_idx < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (i2c_dw_semaphore_cb_table[dev->semaphore_idx].remove)
|
|
|
|
i2c_dw_semaphore_cb_table[dev->semaphore_idx].remove(dev);
|
|
|
|
}
|
|
|
|
|
2015-08-31 17:31:32 +03:00
|
|
|
static int dw_i2c_plat_probe(struct platform_device *pdev)
|
2011-10-29 10:57:23 +01:00
|
|
|
{
|
2024-09-25 15:44:19 +03:00
|
|
|
struct device *device = &pdev->dev;
|
2011-10-29 10:57:23 +01:00
|
|
|
struct i2c_adapter *adap;
|
2017-06-14 11:43:21 +01:00
|
|
|
struct dw_i2c_dev *dev;
|
2020-05-19 15:50:41 +03:00
|
|
|
int irq, ret;
|
2011-10-29 10:57:23 +01:00
|
|
|
|
|
|
|
irq = platform_get_irq(pdev, 0);
|
2015-03-09 12:03:12 +03:00
|
|
|
if (irq < 0)
|
|
|
|
return irq;
|
2011-10-29 10:57:23 +01:00
|
|
|
|
2024-09-25 15:44:19 +03:00
|
|
|
dev = devm_kzalloc(device, sizeof(*dev), GFP_KERNEL);
|
2013-04-10 00:36:36 +00:00
|
|
|
if (!dev)
|
|
|
|
return -ENOMEM;
|
2011-10-29 10:57:23 +01:00
|
|
|
|
2024-09-25 15:44:19 +03:00
|
|
|
dev->flags = (uintptr_t)device_get_match_data(device);
|
|
|
|
if (device_property_present(device, "wx,i2c-snps-model"))
|
2024-02-13 14:48:42 +02:00
|
|
|
dev->flags = MODEL_WANGXUN_SP | ACCESS_POLLING;
|
2023-06-05 10:52:04 +08:00
|
|
|
|
2024-09-25 15:44:19 +03:00
|
|
|
dev->dev = device;
|
2011-10-29 10:57:23 +01:00
|
|
|
dev->irq = irq;
|
|
|
|
platform_set_drvdata(pdev, dev);
|
|
|
|
|
2020-05-28 12:33:20 +03:00
|
|
|
ret = dw_i2c_plat_request_regs(dev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2024-09-25 15:44:19 +03:00
|
|
|
dev->rst = devm_reset_control_get_optional_exclusive(device, NULL);
|
2019-08-19 13:31:30 +03:00
|
|
|
if (IS_ERR(dev->rst))
|
|
|
|
return PTR_ERR(dev->rst);
|
|
|
|
|
|
|
|
reset_control_deassert(dev->rst);
|
2016-12-27 22:22:40 +08:00
|
|
|
|
2024-08-22 20:58:38 +03:00
|
|
|
ret = i2c_dw_fw_parse_and_configure(dev);
|
2020-05-19 15:50:39 +03:00
|
|
|
if (ret)
|
2016-12-27 22:22:40 +08:00
|
|
|
goto exit_reset;
|
2013-06-26 10:55:06 +02:00
|
|
|
|
2017-06-14 11:43:21 +01:00
|
|
|
ret = i2c_dw_probe_lock_support(dev);
|
|
|
|
if (ret)
|
2016-12-27 22:22:40 +08:00
|
|
|
goto exit_reset;
|
2015-01-15 01:12:17 -08:00
|
|
|
|
2020-04-25 16:44:45 +03:00
|
|
|
i2c_dw_configure(dev);
|
2011-10-06 11:26:31 -07:00
|
|
|
|
2019-02-28 13:52:10 +00:00
|
|
|
/* Optional interface clock */
|
2024-09-25 15:44:19 +03:00
|
|
|
dev->pclk = devm_clk_get_optional(device, "pclk");
|
2019-08-19 13:24:23 +03:00
|
|
|
if (IS_ERR(dev->pclk)) {
|
|
|
|
ret = PTR_ERR(dev->pclk);
|
|
|
|
goto exit_reset;
|
|
|
|
}
|
2019-02-28 13:52:10 +00:00
|
|
|
|
2024-09-25 15:44:19 +03:00
|
|
|
dev->clk = devm_clk_get_optional(device, NULL);
|
2022-06-10 10:42:33 +03:00
|
|
|
if (IS_ERR(dev->clk)) {
|
|
|
|
ret = PTR_ERR(dev->clk);
|
|
|
|
goto exit_reset;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = i2c_dw_prepare_clk(dev, true);
|
|
|
|
if (ret)
|
|
|
|
goto exit_reset;
|
|
|
|
|
|
|
|
if (dev->clk) {
|
2024-08-22 20:58:38 +03:00
|
|
|
struct i2c_timings *t = &dev->timings;
|
2018-07-25 17:39:26 +03:00
|
|
|
u64 clk_khz;
|
|
|
|
|
2016-01-04 09:17:35 -06:00
|
|
|
dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz;
|
2018-07-25 17:39:26 +03:00
|
|
|
clk_khz = dev->get_clk_rate_khz(dev);
|
2014-09-30 13:04:54 +03:00
|
|
|
|
2018-07-25 17:39:26 +03:00
|
|
|
if (!dev->sda_hold_time && t->sda_hold_ns)
|
|
|
|
dev->sda_hold_time =
|
2021-07-12 17:20:26 +03:00
|
|
|
DIV_S64_ROUND_CLOSEST(clk_khz * t->sda_hold_ns, MICRO);
|
2014-09-30 13:04:54 +03:00
|
|
|
}
|
|
|
|
|
2011-10-29 10:57:23 +01:00
|
|
|
adap = &dev->adapter;
|
|
|
|
adap->owner = THIS_MODULE;
|
2020-07-02 12:33:21 +02:00
|
|
|
adap->class = dmi_check_system(dw_i2c_hwmon_class_dmi) ?
|
2024-09-25 15:44:23 +03:00
|
|
|
I2C_CLASS_HWMON : I2C_CLASS_DEPRECATED;
|
i2c: i2c-designware-platdrv: Always use a dynamic adapter number
Before this commit the i2c-designware-platdrv assumes that if the pdev
has an apci-companion it should use a dynamic adapter-nr and it sets
adapter->nr to -1, otherwise it will use pdev->id as adapter->nr.
There are 3 ways how platform_device-s to which i2c-designware-platdrv
will bind can be instantiated:
1) Through of / devicetree
2) Through ACPI enumeration
3) Explicitly instantiated through platform_device_create + add
1) In case of devicetree-instantiation the drivers/of code always sets
pdev->id to PLATFORM_DEVID_NONE, which is -1 so in this case both paths
to set adapter->nr end up doing the same thing.
2) In case of ACPI instantiation the device will always have an
ACPI-companion, so we are already using dynamic adapter-nrs.
3) There are 2 places manually instantiating a designware_i2c platform_dev:
drivers/mfd/intel_quark_i2c_gpio.c
drivers/mfd/intel-lpss.c
In the intel_quark_i2c_gpio.c case pdev->id is always 0, so switching to
dynamic adapter-nrs here could lead to the bus-number no longer being
stable, but the quark X1000 only has 1 i2c-controller, which will also
be assigned bus-number 0 when using dynamic adapter-nrs.
In the intel-lpss.c case intel_lpss_probe() is called from either
intel-lpss-acpi.c in which case there always is an ACPI-companion, or
from intel-lpss-pci.c. In most cases devices handled by intel-lpss-pci.c
also have an ACPI-companion, so we use a dynamic adapter-nr. But in some
cases the ACPI-companion is missing and we would use pdev->id (allocated
from intel_lpss_devid_ida). Devices which use the intel-lpss-pci.c code
typically have many i2c busses, so using pdev->id in this case may lead
to a bus-number conflict, triggering a WARN(id < 0, "couldn't get idr")
in i2c-core-base.c causing an oops an the adapter registration to fail.
So in this case using non dynamic adapter-nrs is actually undesirable.
One machine on which this oops was triggering is the Apollo Lake based
Acer TravelMate Spin B118.
TL;DR: Switching to always using dynamic adapter-numbers does not make
any difference in most cases and in the one case where it does make a
difference the behavior change is desirable because the old behavior
caused an oops.
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1687065
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2019-03-12 15:55:54 +01:00
|
|
|
adap->nr = -1;
|
2011-10-29 10:57:23 +01:00
|
|
|
|
2024-09-25 15:44:19 +03:00
|
|
|
if (dev->flags & ACCESS_NO_IRQ_SUSPEND)
|
|
|
|
dev_pm_set_driver_flags(device, DPM_FLAG_SMART_PREPARE);
|
|
|
|
else
|
|
|
|
dev_pm_set_driver_flags(device, DPM_FLAG_SMART_PREPARE | DPM_FLAG_SMART_SUSPEND);
|
2018-01-03 01:35:54 +01:00
|
|
|
|
2024-09-25 15:44:19 +03:00
|
|
|
device_enable_async_suspend(device);
|
2021-10-25 14:35:29 -07:00
|
|
|
|
2017-09-25 23:10:06 +02:00
|
|
|
/* The code below assumes runtime PM to be disabled. */
|
2024-09-25 15:44:19 +03:00
|
|
|
WARN_ON(pm_runtime_enabled(device));
|
2017-09-25 23:10:06 +02:00
|
|
|
|
2024-09-25 15:44:19 +03:00
|
|
|
pm_runtime_set_autosuspend_delay(device, 1000);
|
|
|
|
pm_runtime_use_autosuspend(device);
|
|
|
|
pm_runtime_set_active(device);
|
2017-09-25 23:10:06 +02:00
|
|
|
|
2018-09-05 21:51:31 +02:00
|
|
|
if (dev->shared_with_punit)
|
2024-09-25 15:44:19 +03:00
|
|
|
pm_runtime_get_noresume(device);
|
2017-09-25 23:10:06 +02:00
|
|
|
|
2024-09-25 15:44:19 +03:00
|
|
|
pm_runtime_enable(device);
|
2013-01-17 12:31:06 +02:00
|
|
|
|
2020-04-25 16:44:47 +03:00
|
|
|
ret = i2c_dw_probe(dev);
|
2017-06-14 11:43:21 +01:00
|
|
|
if (ret)
|
2016-12-27 22:22:40 +08:00
|
|
|
goto exit_probe;
|
2015-10-09 10:39:24 +01:00
|
|
|
|
2017-06-14 11:43:21 +01:00
|
|
|
return ret;
|
2016-12-27 22:22:40 +08:00
|
|
|
|
|
|
|
exit_probe:
|
2017-09-25 23:10:06 +02:00
|
|
|
dw_i2c_plat_pm_cleanup(dev);
|
2016-12-27 22:22:40 +08:00
|
|
|
exit_reset:
|
2019-08-19 13:31:30 +03:00
|
|
|
reset_control_assert(dev->rst);
|
2017-06-14 11:43:21 +01:00
|
|
|
return ret;
|
2011-10-29 10:57:23 +01:00
|
|
|
}
|
|
|
|
|
2023-05-08 22:51:38 +02:00
|
|
|
static void dw_i2c_plat_remove(struct platform_device *pdev)
|
2011-10-29 10:57:23 +01:00
|
|
|
{
|
|
|
|
struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
|
2024-09-25 15:44:19 +03:00
|
|
|
struct device *device = &pdev->dev;
|
2011-10-29 10:57:23 +01:00
|
|
|
|
2024-09-25 15:44:19 +03:00
|
|
|
pm_runtime_get_sync(device);
|
2013-01-17 12:31:06 +02:00
|
|
|
|
2011-10-29 10:57:23 +01:00
|
|
|
i2c_del_adapter(&dev->adapter);
|
|
|
|
|
2024-08-22 20:58:41 +03:00
|
|
|
i2c_dw_disable(dev);
|
2011-10-29 10:57:23 +01:00
|
|
|
|
2024-09-25 15:44:19 +03:00
|
|
|
pm_runtime_dont_use_autosuspend(device);
|
|
|
|
pm_runtime_put_sync(device);
|
2017-09-25 23:10:06 +02:00
|
|
|
dw_i2c_plat_pm_cleanup(dev);
|
|
|
|
|
2022-02-08 15:12:18 +01:00
|
|
|
i2c_dw_remove_lock_support(dev);
|
|
|
|
|
2019-08-19 13:31:30 +03:00
|
|
|
reset_control_assert(dev->rst);
|
2011-10-29 10:57:23 +01:00
|
|
|
}
|
|
|
|
|
2024-08-19 21:45:11 +03:00
|
|
|
static const struct of_device_id dw_i2c_of_match[] = {
|
|
|
|
{ .compatible = "snps,designware-i2c", },
|
|
|
|
{ .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT },
|
|
|
|
{ .compatible = "baikal,bt1-sys-i2c", .data = (void *)MODEL_BAIKAL_BT1 },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
|
|
|
|
|
|
|
|
static const struct acpi_device_id dw_i2c_acpi_match[] = {
|
|
|
|
{ "80860F41", ACCESS_NO_IRQ_SUSPEND },
|
|
|
|
{ "808622C1", ACCESS_NO_IRQ_SUSPEND },
|
|
|
|
{ "AMD0010", ACCESS_INTR_MASK },
|
|
|
|
{ "AMDI0010", ACCESS_INTR_MASK },
|
|
|
|
{ "AMDI0019", ACCESS_INTR_MASK | ARBITRATION_SEMAPHORE },
|
|
|
|
{ "AMDI0510", 0 },
|
|
|
|
{ "APMC0D0F", 0 },
|
i2c: designware: Add ACPI HID for DWAPB I2C controller on FUJITSU-MONAKA
Enable DWAPB I2C controller support on FUJITSU-MONAKA.
This will be used in the FUJITSU-MONAKA server scheduled
for shipment in 2027.
The DSDT information obtained when verified using an
in-house simulator is presented below.
Device (SMB0)
{
Name (_HID, "FUJI200B") // _HID: Hardware ID
Name (_UID, Zero) // _UID: Unique ID
...
Name (_CRS, ResourceTemplate ()
{
Memory32Fixed (ReadWrite,
0x2A4B0000, // Address Base
0x00010000, // Address Length
)
Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
{
0x00000159,
}
})
...
}
The expression SMB0 is used to indicate SMBus HC#0,
a string of up to four characters.
Created the SMB0 object according to the following
specifications:
ACPI Specification
13.2. Accessing the SMBus from ASL Code
https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/13_ACPI_System_Mgmt_Bus_Interface_Spec/accessing-the-smbus-from-asl-code.html
IPMI Specification
Example 4: SSIF Interface(P574)
https://www.intel.co.jp/content/www/jp/ja/products/docs/servers/ipmi/ipmi-second-gen-interface-spec-v2-rev1-1.html
Signed-off-by: Yoshihiro Furudera <fj5100bi@fujitsu.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
2024-10-24 07:15:53 +00:00
|
|
|
{ "FUJI200B", 0 },
|
2024-08-19 21:45:11 +03:00
|
|
|
{ "HISI02A1", 0 },
|
|
|
|
{ "HISI02A2", 0 },
|
|
|
|
{ "HISI02A3", 0 },
|
2024-09-26 10:40:06 +08:00
|
|
|
{ "HJMC3001", 0 },
|
2024-08-19 21:45:11 +03:00
|
|
|
{ "HYGO0010", ACCESS_INTR_MASK },
|
|
|
|
{ "INT33C2", 0 },
|
|
|
|
{ "INT33C3", 0 },
|
|
|
|
{ "INT3432", 0 },
|
|
|
|
{ "INT3433", 0 },
|
|
|
|
{ "INTC10EF", 0 },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match);
|
|
|
|
|
2024-04-25 14:44:34 -07:00
|
|
|
static const struct platform_device_id dw_i2c_platform_ids[] = {
|
|
|
|
{ "i2c_designware" },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(platform, dw_i2c_platform_ids);
|
2011-10-29 10:57:23 +01:00
|
|
|
|
|
|
|
static struct platform_driver dw_i2c_driver = {
|
2015-08-31 17:31:32 +03:00
|
|
|
.probe = dw_i2c_plat_probe,
|
2024-09-29 09:21:57 +02:00
|
|
|
.remove = dw_i2c_plat_remove,
|
2011-10-29 10:57:23 +01:00
|
|
|
.driver = {
|
|
|
|
.name = "i2c_designware",
|
2024-08-19 21:45:11 +03:00
|
|
|
.of_match_table = dw_i2c_of_match,
|
|
|
|
.acpi_match_table = dw_i2c_acpi_match,
|
2024-08-27 18:00:37 +03:00
|
|
|
.pm = pm_ptr(&i2c_dw_dev_pm_ops),
|
2011-10-29 10:57:23 +01:00
|
|
|
},
|
2024-04-25 14:44:34 -07:00
|
|
|
.id_table = dw_i2c_platform_ids,
|
2011-10-29 10:57:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init dw_i2c_init_driver(void)
|
|
|
|
{
|
2013-10-08 22:35:33 +02:00
|
|
|
return platform_driver_register(&dw_i2c_driver);
|
2011-10-29 10:57:23 +01:00
|
|
|
}
|
2012-02-29 12:27:46 +05:30
|
|
|
subsys_initcall(dw_i2c_init_driver);
|
2011-10-29 10:57:23 +01:00
|
|
|
|
|
|
|
static void __exit dw_i2c_exit_driver(void)
|
|
|
|
{
|
|
|
|
platform_driver_unregister(&dw_i2c_driver);
|
|
|
|
}
|
|
|
|
module_exit(dw_i2c_exit_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>");
|
|
|
|
MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter");
|
|
|
|
MODULE_LICENSE("GPL");
|
module: Convert symbol namespace to string literal
Clean up the existing export namespace code along the same lines of
commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
Scripted using
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-02 15:59:47 +01:00
|
|
|
MODULE_IMPORT_NS("I2C_DW");
|
|
|
|
MODULE_IMPORT_NS("I2C_DW_COMMON");
|