Pull i2c updates from Wolfram Sang: - 'remove' callback converted to return void. Big change with trivial fixes all over the tree. Other subsystems depending on this change have been asked to pull an immutable topic branch for this. - new driver for Microchip PCI1xxxx switch - heavy refactoring of the Mellanox BlueField driver - we prefer async probe in the i801 driver now - the rest is usual driver updates (support for more SoCs, some refactoring, some feature additions) * tag 'i2c-for-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (37 commits) i2c: pci1xxxx: prevent signed integer overflow i2c: acpi: Replace zero-length array with DECLARE_FLEX_ARRAY() helper i2c: i801: Prefer async probe i2c: designware-pci: Use standard pattern for memory allocation i2c: designware-pci: Group AMD NAVI quirk parts together i2c: microchip: pci1xxxx: Add driver for I2C host controller in multifunction endpoint of pci1xxxx switch docs: i2c: slave-interface: return errno when handle I2C_SLAVE_WRITE_REQUESTED i2c: mlxbf: remove device tree support i2c: mlxbf: support BlueField-3 SoC i2c: cadence: Add standard bus recovery support i2c: mlxbf: add multi slave functionality i2c: mlxbf: support lock mechanism macintosh/ams: Adapt declaration of ams_i2c_remove() to earlier change i2c: riic: Use devm_platform_ioremap_resource() i2c: mlxbf: remove IRQF_ONESHOT dt-bindings: i2c: rockchip: add rockchip,rk3128-i2c dt-bindings: i2c: renesas,rcar-i2c: Add r8a779g0 support i2c: tegra: Add GPCDMA support i2c: scmi: Convert to be a platform driver i2c: rk3x: Add rv1126 support ...
134 lines
2.8 KiB
C
134 lines
2.8 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Microchip KSZ9477 series register access through I2C
|
|
*
|
|
* Copyright (C) 2018-2019 Microchip Technology Inc.
|
|
*/
|
|
|
|
#include <linux/i2c.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/regmap.h>
|
|
|
|
#include "ksz_common.h"
|
|
|
|
KSZ_REGMAP_TABLE(ksz9477, not_used, 16, 0, 0);
|
|
|
|
static int ksz9477_i2c_probe(struct i2c_client *i2c,
|
|
const struct i2c_device_id *i2c_id)
|
|
{
|
|
struct regmap_config rc;
|
|
struct ksz_device *dev;
|
|
int i, ret;
|
|
|
|
dev = ksz_switch_alloc(&i2c->dev, i2c);
|
|
if (!dev)
|
|
return -ENOMEM;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(ksz9477_regmap_config); i++) {
|
|
rc = ksz9477_regmap_config[i];
|
|
rc.lock_arg = &dev->regmap_mutex;
|
|
dev->regmap[i] = devm_regmap_init_i2c(i2c, &rc);
|
|
if (IS_ERR(dev->regmap[i])) {
|
|
ret = PTR_ERR(dev->regmap[i]);
|
|
dev_err(&i2c->dev,
|
|
"Failed to initialize regmap%i: %d\n",
|
|
ksz9477_regmap_config[i].val_bits, ret);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
if (i2c->dev.platform_data)
|
|
dev->pdata = i2c->dev.platform_data;
|
|
|
|
ret = ksz_switch_register(dev);
|
|
|
|
/* Main DSA driver may not be started yet. */
|
|
if (ret)
|
|
return ret;
|
|
|
|
i2c_set_clientdata(i2c, dev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void ksz9477_i2c_remove(struct i2c_client *i2c)
|
|
{
|
|
struct ksz_device *dev = i2c_get_clientdata(i2c);
|
|
|
|
if (dev)
|
|
ksz_switch_remove(dev);
|
|
}
|
|
|
|
static void ksz9477_i2c_shutdown(struct i2c_client *i2c)
|
|
{
|
|
struct ksz_device *dev = i2c_get_clientdata(i2c);
|
|
|
|
if (!dev)
|
|
return;
|
|
|
|
if (dev->dev_ops->reset)
|
|
dev->dev_ops->reset(dev);
|
|
|
|
dsa_switch_shutdown(dev->ds);
|
|
|
|
i2c_set_clientdata(i2c, NULL);
|
|
}
|
|
|
|
static const struct i2c_device_id ksz9477_i2c_id[] = {
|
|
{ "ksz9477-switch", 0 },
|
|
{},
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(i2c, ksz9477_i2c_id);
|
|
|
|
static const struct of_device_id ksz9477_dt_ids[] = {
|
|
{
|
|
.compatible = "microchip,ksz9477",
|
|
.data = &ksz_switch_chips[KSZ9477]
|
|
},
|
|
{
|
|
.compatible = "microchip,ksz9896",
|
|
.data = &ksz_switch_chips[KSZ9896]
|
|
},
|
|
{
|
|
.compatible = "microchip,ksz9897",
|
|
.data = &ksz_switch_chips[KSZ9897]
|
|
},
|
|
{
|
|
.compatible = "microchip,ksz9893",
|
|
.data = &ksz_switch_chips[KSZ9893]
|
|
},
|
|
{
|
|
.compatible = "microchip,ksz9563",
|
|
.data = &ksz_switch_chips[KSZ9893]
|
|
},
|
|
{
|
|
.compatible = "microchip,ksz8563",
|
|
.data = &ksz_switch_chips[KSZ9893]
|
|
},
|
|
{
|
|
.compatible = "microchip,ksz9567",
|
|
.data = &ksz_switch_chips[KSZ9567]
|
|
},
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(of, ksz9477_dt_ids);
|
|
|
|
static struct i2c_driver ksz9477_i2c_driver = {
|
|
.driver = {
|
|
.name = "ksz9477-switch",
|
|
.of_match_table = of_match_ptr(ksz9477_dt_ids),
|
|
},
|
|
.probe = ksz9477_i2c_probe,
|
|
.remove = ksz9477_i2c_remove,
|
|
.shutdown = ksz9477_i2c_shutdown,
|
|
.id_table = ksz9477_i2c_id,
|
|
};
|
|
|
|
module_i2c_driver(ksz9477_i2c_driver);
|
|
|
|
MODULE_AUTHOR("Tristram Ha <Tristram.Ha@microchip.com>");
|
|
MODULE_DESCRIPTION("Microchip KSZ9477 Series Switch I2C access Driver");
|
|
MODULE_LICENSE("GPL v2");
|