platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
/*
|
2018-01-18 02:21:53 +08:00
|
|
|
* Copyright (c) 2016-2018 Mellanox Technologies. All rights reserved.
|
|
|
|
* Copyright (c) 2016-2018 Vadim Pasternak <vadimp@mellanox.com>
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the names of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/hwmon.h>
|
|
|
|
#include <linux/hwmon-sysfs.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/module.h>
|
2018-01-23 11:55:11 +08:00
|
|
|
#include <linux/of_device.h>
|
2018-01-18 02:21:53 +08:00
|
|
|
#include <linux/platform_data/mlxreg.h>
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/spinlock.h>
|
2018-01-23 11:55:11 +08:00
|
|
|
#include <linux/regmap.h>
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
#include <linux/workqueue.h>
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
/* Offset of event and mask registers from status register. */
|
2018-01-18 02:21:53 +08:00
|
|
|
#define MLXREG_HOTPLUG_EVENT_OFF 1
|
2018-01-23 11:55:11 +08:00
|
|
|
#define MLXREG_HOTPLUG_MASK_OFF 2
|
2018-01-18 02:21:53 +08:00
|
|
|
#define MLXREG_HOTPLUG_AGGR_MASK_OFF 1
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
2018-07-27 06:40:58 +08:00
|
|
|
/* ASIC good health mask. */
|
|
|
|
#define MLXREG_HOTPLUG_GOOD_HEALTH_MASK 0x02
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
#define MLXREG_HOTPLUG_ATTRS_MAX 24
|
2018-05-07 14:48:51 +08:00
|
|
|
#define MLXREG_HOTPLUG_NOT_ASSERT 3
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
|
|
|
/**
|
2018-01-18 02:21:53 +08:00
|
|
|
* struct mlxreg_hotplug_priv_data - platform private data:
|
2018-01-23 11:55:11 +08:00
|
|
|
* @irq: platform device interrupt number;
|
2018-03-27 18:02:02 +08:00
|
|
|
* @dev: basic device;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
* @pdev: platform device;
|
|
|
|
* @plat: platform data;
|
2018-03-27 18:02:02 +08:00
|
|
|
* @regmap: register map handle;
|
|
|
|
* @dwork_irq: delayed work template;
|
2018-01-23 11:55:11 +08:00
|
|
|
* @lock: spin lock;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
* @hwmon: hwmon device;
|
2018-01-18 02:21:53 +08:00
|
|
|
* @mlxreg_hotplug_attr: sysfs attributes array;
|
|
|
|
* @mlxreg_hotplug_dev_attr: sysfs sensor device attribute array;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
* @group: sysfs attribute group;
|
|
|
|
* @groups: list of sysfs attribute group for hwmon registration;
|
2018-01-23 11:55:11 +08:00
|
|
|
* @cell: location of top aggregation interrupt register;
|
|
|
|
* @mask: top aggregation interrupt common mask;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
* @aggr_cache: last value of aggregation register status;
|
2018-03-27 18:02:02 +08:00
|
|
|
* @after_probe: flag indication probing completion;
|
2018-05-07 14:48:51 +08:00
|
|
|
* @not_asserted: number of entries in workqueue with no signal assertion;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
*/
|
2018-01-18 02:21:53 +08:00
|
|
|
struct mlxreg_hotplug_priv_data {
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
int irq;
|
2018-01-23 11:55:11 +08:00
|
|
|
struct device *dev;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
struct platform_device *pdev;
|
2018-01-18 02:21:53 +08:00
|
|
|
struct mlxreg_hotplug_platform_data *plat;
|
2018-01-23 11:55:11 +08:00
|
|
|
struct regmap *regmap;
|
|
|
|
struct delayed_work dwork_irq;
|
|
|
|
spinlock_t lock; /* sync with interrupt */
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
struct device *hwmon;
|
2018-01-23 11:55:11 +08:00
|
|
|
struct attribute *mlxreg_hotplug_attr[MLXREG_HOTPLUG_ATTRS_MAX + 1];
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
struct sensor_device_attribute_2
|
2018-01-23 11:55:11 +08:00
|
|
|
mlxreg_hotplug_dev_attr[MLXREG_HOTPLUG_ATTRS_MAX];
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
struct attribute_group group;
|
|
|
|
const struct attribute_group *groups[2];
|
2018-01-23 11:55:11 +08:00
|
|
|
u32 cell;
|
|
|
|
u32 mask;
|
|
|
|
u32 aggr_cache;
|
|
|
|
bool after_probe;
|
2018-05-07 14:48:51 +08:00
|
|
|
u8 not_asserted;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
};
|
|
|
|
|
2018-02-14 06:09:35 +08:00
|
|
|
static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_priv_data *priv,
|
2018-01-23 11:55:11 +08:00
|
|
|
struct mlxreg_core_data *data)
|
2018-01-23 10:50:20 +08:00
|
|
|
{
|
2018-02-14 06:09:36 +08:00
|
|
|
struct mlxreg_core_hotplug_platform_data *pdata;
|
|
|
|
|
2018-07-27 06:40:59 +08:00
|
|
|
/* Notify user by sending hwmon uevent. */
|
|
|
|
kobject_uevent(&priv->hwmon->kobj, KOBJ_CHANGE);
|
|
|
|
|
2018-01-27 03:03:45 +08:00
|
|
|
/*
|
|
|
|
* Return if adapter number is negative. It could be in case hotplug
|
|
|
|
* event is not associated with hotplug device.
|
|
|
|
*/
|
|
|
|
if (data->hpdev.nr < 0)
|
|
|
|
return 0;
|
|
|
|
|
2018-02-14 06:09:36 +08:00
|
|
|
pdata = dev_get_platdata(&priv->pdev->dev);
|
|
|
|
data->hpdev.adapter = i2c_get_adapter(data->hpdev.nr +
|
|
|
|
pdata->shift_nr);
|
2018-01-23 11:55:11 +08:00
|
|
|
if (!data->hpdev.adapter) {
|
2018-02-14 06:09:35 +08:00
|
|
|
dev_err(priv->dev, "Failed to get adapter for bus %d\n",
|
2018-02-14 06:09:36 +08:00
|
|
|
data->hpdev.nr + pdata->shift_nr);
|
2018-01-23 10:50:20 +08:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
data->hpdev.client = i2c_new_device(data->hpdev.adapter,
|
|
|
|
data->hpdev.brdinfo);
|
|
|
|
if (!data->hpdev.client) {
|
2018-02-14 06:09:35 +08:00
|
|
|
dev_err(priv->dev, "Failed to create client %s at bus %d at addr 0x%02x\n",
|
2018-02-14 06:09:36 +08:00
|
|
|
data->hpdev.brdinfo->type, data->hpdev.nr +
|
|
|
|
pdata->shift_nr, data->hpdev.brdinfo->addr);
|
2018-01-23 11:55:11 +08:00
|
|
|
|
|
|
|
i2c_put_adapter(data->hpdev.adapter);
|
|
|
|
data->hpdev.adapter = NULL;
|
2018-01-23 10:50:20 +08:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-07-27 06:40:59 +08:00
|
|
|
static void
|
|
|
|
mlxreg_hotplug_device_destroy(struct mlxreg_hotplug_priv_data *priv,
|
|
|
|
struct mlxreg_core_data *data)
|
2018-01-23 10:50:20 +08:00
|
|
|
{
|
2018-07-27 06:40:59 +08:00
|
|
|
/* Notify user by sending hwmon uevent. */
|
|
|
|
kobject_uevent(&priv->hwmon->kobj, KOBJ_CHANGE);
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
if (data->hpdev.client) {
|
|
|
|
i2c_unregister_device(data->hpdev.client);
|
|
|
|
data->hpdev.client = NULL;
|
2018-01-23 10:50:20 +08:00
|
|
|
}
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
if (data->hpdev.adapter) {
|
|
|
|
i2c_put_adapter(data->hpdev.adapter);
|
|
|
|
data->hpdev.adapter = NULL;
|
2018-01-23 10:50:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-18 02:21:53 +08:00
|
|
|
static ssize_t mlxreg_hotplug_attr_show(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
{
|
2018-01-23 11:55:11 +08:00
|
|
|
struct mlxreg_hotplug_priv_data *priv = dev_get_drvdata(dev);
|
|
|
|
struct mlxreg_core_hotplug_platform_data *pdata;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
int index = to_sensor_dev_attr_2(attr)->index;
|
|
|
|
int nr = to_sensor_dev_attr_2(attr)->nr;
|
2018-01-23 11:55:11 +08:00
|
|
|
struct mlxreg_core_item *item;
|
|
|
|
struct mlxreg_core_data *data;
|
|
|
|
u32 regval;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
pdata = dev_get_platdata(&priv->pdev->dev);
|
|
|
|
item = pdata->items + nr;
|
|
|
|
data = item->data + index;
|
|
|
|
|
|
|
|
ret = regmap_read(priv->regmap, data->reg, ®val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (item->health) {
|
|
|
|
regval &= data->mask;
|
|
|
|
} else {
|
|
|
|
/* Bit = 0 : functional if item->inversed is true. */
|
|
|
|
if (item->inversed)
|
|
|
|
regval = !(regval & data->mask);
|
|
|
|
else
|
|
|
|
regval = !!(regval & data->mask);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
}
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
return sprintf(buf, "%u\n", regval);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
}
|
|
|
|
|
2018-01-18 02:21:53 +08:00
|
|
|
#define PRIV_ATTR(i) priv->mlxreg_hotplug_attr[i]
|
|
|
|
#define PRIV_DEV_ATTR(i) priv->mlxreg_hotplug_dev_attr[i]
|
2018-01-23 11:55:11 +08:00
|
|
|
|
2018-01-18 02:21:53 +08:00
|
|
|
static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
{
|
2018-01-23 11:55:11 +08:00
|
|
|
struct mlxreg_core_hotplug_platform_data *pdata;
|
|
|
|
struct mlxreg_core_item *item;
|
|
|
|
struct mlxreg_core_data *data;
|
|
|
|
int num_attrs = 0, id = 0, i, j;
|
|
|
|
|
|
|
|
pdata = dev_get_platdata(&priv->pdev->dev);
|
|
|
|
item = pdata->items;
|
|
|
|
|
|
|
|
/* Go over all kinds of items - psu, pwr, fan. */
|
|
|
|
for (i = 0; i < pdata->counter; i++, item++) {
|
|
|
|
num_attrs += item->count;
|
|
|
|
data = item->data;
|
|
|
|
/* Go over all units within the item. */
|
|
|
|
for (j = 0; j < item->count; j++, data++, id++) {
|
|
|
|
PRIV_ATTR(id) = &PRIV_DEV_ATTR(id).dev_attr.attr;
|
|
|
|
PRIV_ATTR(id)->name = devm_kasprintf(&priv->pdev->dev,
|
|
|
|
GFP_KERNEL,
|
|
|
|
data->label);
|
|
|
|
|
|
|
|
if (!PRIV_ATTR(id)->name) {
|
|
|
|
dev_err(priv->dev, "Memory allocation failed for attr %d.\n",
|
|
|
|
id);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIV_DEV_ATTR(id).dev_attr.attr.name =
|
|
|
|
PRIV_ATTR(id)->name;
|
|
|
|
PRIV_DEV_ATTR(id).dev_attr.attr.mode = 0444;
|
|
|
|
PRIV_DEV_ATTR(id).dev_attr.show =
|
|
|
|
mlxreg_hotplug_attr_show;
|
|
|
|
PRIV_DEV_ATTR(id).nr = i;
|
|
|
|
PRIV_DEV_ATTR(id).index = j;
|
|
|
|
sysfs_attr_init(&PRIV_DEV_ATTR(id).dev_attr.attr);
|
|
|
|
}
|
|
|
|
}
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
treewide: devm_kzalloc() -> devm_kcalloc()
The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc().
This patch replaces cases of:
devm_kzalloc(handle, a * b, gfp)
with:
devm_kcalloc(handle, a * b, gfp)
as well as handling cases of:
devm_kzalloc(handle, a * b * c, gfp)
with:
devm_kzalloc(handle, array3_size(a, b, c), gfp)
as it's slightly less ugly than:
devm_kcalloc(handle, array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
devm_kzalloc(handle, 4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
Some manual whitespace fixes were needed in this patch, as Coccinelle
really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...".
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
expression HANDLE;
type TYPE;
expression THING, E;
@@
(
devm_kzalloc(HANDLE,
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
devm_kzalloc(HANDLE,
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression HANDLE;
expression COUNT;
typedef u8;
typedef __u8;
@@
(
devm_kzalloc(HANDLE,
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(char) * COUNT
+ COUNT
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
expression HANDLE;
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
expression HANDLE;
identifier SIZE, COUNT;
@@
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression HANDLE;
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
devm_kzalloc(HANDLE,
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression HANDLE;
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
devm_kzalloc(HANDLE,
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
expression HANDLE;
identifier STRIDE, SIZE, COUNT;
@@
(
devm_kzalloc(HANDLE,
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
devm_kzalloc(HANDLE,
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression HANDLE;
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
devm_kzalloc(HANDLE,
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
devm_kzalloc(HANDLE,
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
devm_kzalloc(HANDLE,
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
devm_kzalloc(HANDLE,
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression HANDLE;
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
devm_kzalloc(HANDLE, sizeof(THING) * C2, ...)
|
devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...)
|
devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
devm_kzalloc(HANDLE, C1 * C2, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- (E1) * E2
+ E1, E2
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- (E1) * (E2)
+ E1, E2
, ...)
|
- devm_kzalloc
+ devm_kcalloc
(HANDLE,
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-13 05:07:58 +08:00
|
|
|
priv->group.attrs = devm_kcalloc(&priv->pdev->dev,
|
|
|
|
num_attrs,
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
sizeof(struct attribute *),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!priv->group.attrs)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2018-01-18 02:21:53 +08:00
|
|
|
priv->group.attrs = priv->mlxreg_hotplug_attr;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
priv->groups[0] = &priv->group;
|
|
|
|
priv->groups[1] = NULL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
static void
|
|
|
|
mlxreg_hotplug_work_helper(struct mlxreg_hotplug_priv_data *priv,
|
|
|
|
struct mlxreg_core_item *item)
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
{
|
2018-01-23 11:55:11 +08:00
|
|
|
struct mlxreg_core_data *data;
|
2019-02-18 02:15:30 +08:00
|
|
|
unsigned long asserted;
|
|
|
|
u32 regval, bit;
|
2018-01-23 11:55:11 +08:00
|
|
|
int ret;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Validate if item related to received signal type is valid.
|
|
|
|
* It should never happen, excepted the situation when some
|
|
|
|
* piece of hardware is broken. In such situation just produce
|
|
|
|
* error message and return. Caller must continue to handle the
|
|
|
|
* signals from other devices if any.
|
|
|
|
*/
|
|
|
|
if (unlikely(!item)) {
|
2018-01-23 11:55:11 +08:00
|
|
|
dev_err(priv->dev, "False signal: at offset:mask 0x%02x:0x%02x.\n",
|
|
|
|
item->reg, item->mask);
|
|
|
|
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
/* Mask event. */
|
|
|
|
ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_MASK_OFF,
|
|
|
|
0);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Read status. */
|
|
|
|
ret = regmap_read(priv->regmap, item->reg, ®val);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Set asserted bits and save last status. */
|
|
|
|
regval &= item->mask;
|
|
|
|
asserted = item->cache ^ regval;
|
|
|
|
item->cache = regval;
|
|
|
|
|
2019-02-18 02:15:30 +08:00
|
|
|
for_each_set_bit(bit, &asserted, 8) {
|
2018-01-23 11:55:11 +08:00
|
|
|
data = item->data + bit;
|
|
|
|
if (regval & BIT(bit)) {
|
|
|
|
if (item->inversed)
|
2018-07-27 06:40:59 +08:00
|
|
|
mlxreg_hotplug_device_destroy(priv, data);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
else
|
2018-02-14 06:09:35 +08:00
|
|
|
mlxreg_hotplug_device_create(priv, data);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
} else {
|
2018-01-23 11:55:11 +08:00
|
|
|
if (item->inversed)
|
2018-02-14 06:09:35 +08:00
|
|
|
mlxreg_hotplug_device_create(priv, data);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
else
|
2018-07-27 06:40:59 +08:00
|
|
|
mlxreg_hotplug_device_destroy(priv, data);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Acknowledge event. */
|
2018-01-23 11:55:11 +08:00
|
|
|
ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_EVENT_OFF,
|
|
|
|
0);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
/* Unmask event. */
|
2018-01-23 11:55:11 +08:00
|
|
|
ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_MASK_OFF,
|
|
|
|
item->mask);
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (ret)
|
|
|
|
dev_err(priv->dev, "Failed to complete workqueue.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mlxreg_hotplug_health_work_helper(struct mlxreg_hotplug_priv_data *priv,
|
|
|
|
struct mlxreg_core_item *item)
|
|
|
|
{
|
|
|
|
struct mlxreg_core_data *data = item->data;
|
|
|
|
u32 regval;
|
2018-02-07 17:12:04 +08:00
|
|
|
int i, ret = 0;
|
2018-01-23 11:55:11 +08:00
|
|
|
|
|
|
|
for (i = 0; i < item->count; i++, data++) {
|
|
|
|
/* Mask event. */
|
|
|
|
ret = regmap_write(priv->regmap, data->reg +
|
|
|
|
MLXREG_HOTPLUG_MASK_OFF, 0);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Read status. */
|
|
|
|
ret = regmap_read(priv->regmap, data->reg, ®val);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
regval &= data->mask;
|
2018-07-27 06:40:58 +08:00
|
|
|
|
|
|
|
if (item->cache == regval)
|
|
|
|
goto ack_event;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ASIC health indication is provided through two bits. Bits
|
|
|
|
* value 0x2 indicates that ASIC reached the good health, value
|
|
|
|
* 0x0 indicates ASIC the bad health or dormant state and value
|
|
|
|
* 0x3 indicates the booting state. During ASIC reset it should
|
|
|
|
* pass the following states: dormant -> booting -> good.
|
|
|
|
*/
|
|
|
|
if (regval == MLXREG_HOTPLUG_GOOD_HEALTH_MASK) {
|
|
|
|
if (!data->attached) {
|
|
|
|
/*
|
|
|
|
* ASIC is in steady state. Connect associated
|
|
|
|
* device, if configured.
|
|
|
|
*/
|
2018-02-14 06:09:35 +08:00
|
|
|
mlxreg_hotplug_device_create(priv, data);
|
2018-01-23 11:55:11 +08:00
|
|
|
data->attached = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (data->attached) {
|
2018-07-27 06:40:58 +08:00
|
|
|
/*
|
|
|
|
* ASIC health is failed after ASIC has been
|
|
|
|
* in steady state. Disconnect associated
|
|
|
|
* device, if it has been connected.
|
|
|
|
*/
|
2018-07-27 06:40:59 +08:00
|
|
|
mlxreg_hotplug_device_destroy(priv, data);
|
2018-01-23 11:55:11 +08:00
|
|
|
data->attached = false;
|
|
|
|
data->health_cntr = 0;
|
|
|
|
}
|
|
|
|
}
|
2018-07-27 06:40:58 +08:00
|
|
|
item->cache = regval;
|
|
|
|
ack_event:
|
2018-01-23 11:55:11 +08:00
|
|
|
/* Acknowledge event. */
|
|
|
|
ret = regmap_write(priv->regmap, data->reg +
|
|
|
|
MLXREG_HOTPLUG_EVENT_OFF, 0);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Unmask event. */
|
|
|
|
ret = regmap_write(priv->regmap, data->reg +
|
|
|
|
MLXREG_HOTPLUG_MASK_OFF, data->mask);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (ret)
|
|
|
|
dev_err(priv->dev, "Failed to complete workqueue.\n");
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2018-01-23 11:55:11 +08:00
|
|
|
* mlxreg_hotplug_work_handler - performs traversing of device interrupt
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
* registers according to the below hierarchy schema:
|
|
|
|
*
|
2018-01-23 11:55:11 +08:00
|
|
|
* Aggregation registers (status/mask)
|
|
|
|
* PSU registers: *---*
|
|
|
|
* *-----------------* | |
|
|
|
|
* |status/event/mask|-----> | * |
|
|
|
|
* *-----------------* | |
|
|
|
|
* Power registers: | |
|
|
|
|
* *-----------------* | |
|
|
|
|
* |status/event/mask|-----> | * |
|
|
|
|
* *-----------------* | |
|
|
|
|
* FAN registers: | |--> CPU
|
|
|
|
* *-----------------* | |
|
|
|
|
* |status/event/mask|-----> | * |
|
|
|
|
* *-----------------* | |
|
|
|
|
* ASIC registers: | |
|
|
|
|
* *-----------------* | |
|
|
|
|
* |status/event/mask|-----> | * |
|
|
|
|
* *-----------------* | |
|
|
|
|
* *---*
|
|
|
|
*
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
* In case some system changed are detected: FAN in/out, PSU in/out, power
|
2018-01-23 11:55:11 +08:00
|
|
|
* cable attached/detached, ASIC health good/bad, relevant device is created
|
|
|
|
* or destroyed.
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
*/
|
2018-01-18 02:21:53 +08:00
|
|
|
static void mlxreg_hotplug_work_handler(struct work_struct *work)
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
{
|
2018-01-23 11:55:11 +08:00
|
|
|
struct mlxreg_core_hotplug_platform_data *pdata;
|
|
|
|
struct mlxreg_hotplug_priv_data *priv;
|
|
|
|
struct mlxreg_core_item *item;
|
|
|
|
u32 regval, aggr_asserted;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
unsigned long flags;
|
2018-01-23 11:55:11 +08:00
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
priv = container_of(work, struct mlxreg_hotplug_priv_data,
|
|
|
|
dwork_irq.work);
|
|
|
|
pdata = dev_get_platdata(&priv->pdev->dev);
|
|
|
|
item = pdata->items;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
|
|
|
/* Mask aggregation event. */
|
2018-01-23 11:55:11 +08:00
|
|
|
ret = regmap_write(priv->regmap, pdata->cell +
|
|
|
|
MLXREG_HOTPLUG_AGGR_MASK_OFF, 0);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out;
|
|
|
|
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
/* Read aggregation status. */
|
2018-01-23 11:55:11 +08:00
|
|
|
ret = regmap_read(priv->regmap, pdata->cell, ®val);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
regval &= pdata->mask;
|
|
|
|
aggr_asserted = priv->aggr_cache ^ regval;
|
|
|
|
priv->aggr_cache = regval;
|
|
|
|
|
2018-05-07 14:48:51 +08:00
|
|
|
/*
|
|
|
|
* Handler is invoked, but no assertion is detected at top aggregation
|
|
|
|
* status level. Set aggr_asserted to mask value to allow handler extra
|
|
|
|
* run over all relevant signals to recover any missed signal.
|
|
|
|
*/
|
|
|
|
if (priv->not_asserted == MLXREG_HOTPLUG_NOT_ASSERT) {
|
|
|
|
priv->not_asserted = 0;
|
|
|
|
aggr_asserted = pdata->mask;
|
|
|
|
}
|
|
|
|
if (!aggr_asserted)
|
|
|
|
goto unmask_event;
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
/* Handle topology and health configuration changes. */
|
|
|
|
for (i = 0; i < pdata->counter; i++, item++) {
|
|
|
|
if (aggr_asserted & item->aggr_mask) {
|
|
|
|
if (item->health)
|
|
|
|
mlxreg_hotplug_health_work_helper(priv, item);
|
|
|
|
else
|
|
|
|
mlxreg_hotplug_work_helper(priv, item);
|
|
|
|
}
|
|
|
|
}
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
2018-05-07 14:48:51 +08:00
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
2018-05-07 14:48:51 +08:00
|
|
|
/*
|
|
|
|
* It is possible, that some signals have been inserted, while
|
|
|
|
* interrupt has been masked by mlxreg_hotplug_work_handler. In this
|
|
|
|
* case such signals will be missed. In order to handle these signals
|
|
|
|
* delayed work is canceled and work task re-scheduled for immediate
|
|
|
|
* execution. It allows to handle missed signals, if any. In other case
|
|
|
|
* work handler just validates that no new signals have been received
|
|
|
|
* during masking.
|
|
|
|
*/
|
|
|
|
cancel_delayed_work(&priv->dwork_irq);
|
|
|
|
schedule_delayed_work(&priv->dwork_irq, 0);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
2018-05-07 14:48:51 +08:00
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
2018-05-07 14:48:51 +08:00
|
|
|
return;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
2018-05-07 14:48:51 +08:00
|
|
|
unmask_event:
|
|
|
|
priv->not_asserted++;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
/* Unmask aggregation event (no need acknowledge). */
|
2018-01-23 11:55:11 +08:00
|
|
|
ret = regmap_write(priv->regmap, pdata->cell +
|
|
|
|
MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask);
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (ret)
|
|
|
|
dev_err(priv->dev, "Failed to complete workqueue.\n");
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
}
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv)
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
{
|
2018-01-23 11:55:11 +08:00
|
|
|
struct mlxreg_core_hotplug_platform_data *pdata;
|
|
|
|
struct mlxreg_core_item *item;
|
2018-12-13 07:59:15 +08:00
|
|
|
struct mlxreg_core_data *data;
|
|
|
|
u32 regval;
|
|
|
|
int i, j, ret;
|
2018-01-23 11:55:11 +08:00
|
|
|
|
|
|
|
pdata = dev_get_platdata(&priv->pdev->dev);
|
|
|
|
item = pdata->items;
|
|
|
|
|
|
|
|
for (i = 0; i < pdata->counter; i++, item++) {
|
|
|
|
/* Clear group presense event. */
|
|
|
|
ret = regmap_write(priv->regmap, item->reg +
|
|
|
|
MLXREG_HOTPLUG_EVENT_OFF, 0);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
2018-12-13 07:59:15 +08:00
|
|
|
/*
|
|
|
|
* Verify if hardware configuration requires to disable
|
|
|
|
* interrupt capability for some of components.
|
|
|
|
*/
|
|
|
|
data = item->data;
|
|
|
|
for (j = 0; j < item->count; j++, data++) {
|
|
|
|
/* Verify if the attribute has capability register. */
|
|
|
|
if (data->capability) {
|
|
|
|
/* Read capability register. */
|
|
|
|
ret = regmap_read(priv->regmap,
|
|
|
|
data->capability, ®val);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (!(regval & data->bit))
|
|
|
|
item->mask &= ~BIT(j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
/* Set group initial status as mask and unmask group event. */
|
|
|
|
if (item->inversed) {
|
|
|
|
item->cache = item->mask;
|
|
|
|
ret = regmap_write(priv->regmap, item->reg +
|
|
|
|
MLXREG_HOTPLUG_MASK_OFF,
|
|
|
|
item->mask);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
|
|
|
/* Keep aggregation initial status as zero and unmask events. */
|
2018-01-23 11:55:11 +08:00
|
|
|
ret = regmap_write(priv->regmap, pdata->cell +
|
|
|
|
MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Keep low aggregation initial status as zero and unmask events. */
|
|
|
|
if (pdata->cell_low) {
|
|
|
|
ret = regmap_write(priv->regmap, pdata->cell_low +
|
|
|
|
MLXREG_HOTPLUG_AGGR_MASK_OFF,
|
|
|
|
pdata->mask_low);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
}
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
|
|
|
/* Invoke work handler for initializing hot plug devices setting. */
|
2018-01-23 11:55:11 +08:00
|
|
|
mlxreg_hotplug_work_handler(&priv->dwork_irq.work);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
out:
|
|
|
|
if (ret)
|
|
|
|
dev_err(priv->dev, "Failed to set interrupts.\n");
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
enable_irq(priv->irq);
|
2018-01-23 11:55:11 +08:00
|
|
|
return ret;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
}
|
|
|
|
|
2018-01-18 02:21:53 +08:00
|
|
|
static void mlxreg_hotplug_unset_irq(struct mlxreg_hotplug_priv_data *priv)
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
{
|
2018-01-23 11:55:11 +08:00
|
|
|
struct mlxreg_core_hotplug_platform_data *pdata;
|
|
|
|
struct mlxreg_core_item *item;
|
|
|
|
struct mlxreg_core_data *data;
|
|
|
|
int count, i, j;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
pdata = dev_get_platdata(&priv->pdev->dev);
|
|
|
|
item = pdata->items;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
disable_irq(priv->irq);
|
2018-01-23 11:55:11 +08:00
|
|
|
cancel_delayed_work_sync(&priv->dwork_irq);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
/* Mask low aggregation event, if defined. */
|
|
|
|
if (pdata->cell_low)
|
|
|
|
regmap_write(priv->regmap, pdata->cell_low +
|
|
|
|
MLXREG_HOTPLUG_AGGR_MASK_OFF, 0);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
/* Mask aggregation event. */
|
|
|
|
regmap_write(priv->regmap, pdata->cell + MLXREG_HOTPLUG_AGGR_MASK_OFF,
|
|
|
|
0);
|
|
|
|
|
|
|
|
/* Clear topology configurations. */
|
|
|
|
for (i = 0; i < pdata->counter; i++, item++) {
|
|
|
|
data = item->data;
|
|
|
|
/* Mask group presense event. */
|
|
|
|
regmap_write(priv->regmap, data->reg + MLXREG_HOTPLUG_MASK_OFF,
|
|
|
|
0);
|
|
|
|
/* Clear group presense event. */
|
|
|
|
regmap_write(priv->regmap, data->reg +
|
|
|
|
MLXREG_HOTPLUG_EVENT_OFF, 0);
|
|
|
|
|
|
|
|
/* Remove all the attached devices in group. */
|
|
|
|
count = item->count;
|
|
|
|
for (j = 0; j < count; j++, data++)
|
2018-07-27 06:40:59 +08:00
|
|
|
mlxreg_hotplug_device_destroy(priv, data);
|
2018-01-23 11:55:11 +08:00
|
|
|
}
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
}
|
|
|
|
|
2018-01-18 02:21:53 +08:00
|
|
|
static irqreturn_t mlxreg_hotplug_irq_handler(int irq, void *dev)
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
{
|
2018-01-23 11:55:11 +08:00
|
|
|
struct mlxreg_hotplug_priv_data *priv;
|
|
|
|
|
|
|
|
priv = (struct mlxreg_hotplug_priv_data *)dev;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
|
|
|
/* Schedule work task for immediate execution.*/
|
2018-01-23 11:55:11 +08:00
|
|
|
schedule_delayed_work(&priv->dwork_irq, 0);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2018-01-18 02:21:53 +08:00
|
|
|
static int mlxreg_hotplug_probe(struct platform_device *pdev)
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
{
|
2018-01-23 11:55:11 +08:00
|
|
|
struct mlxreg_core_hotplug_platform_data *pdata;
|
2018-01-18 02:21:53 +08:00
|
|
|
struct mlxreg_hotplug_priv_data *priv;
|
2018-02-14 06:09:34 +08:00
|
|
|
struct i2c_adapter *deferred_adap;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
int err;
|
|
|
|
|
|
|
|
pdata = dev_get_platdata(&pdev->dev);
|
|
|
|
if (!pdata) {
|
|
|
|
dev_err(&pdev->dev, "Failed to get platform data.\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2018-02-14 06:09:34 +08:00
|
|
|
/* Defer probing if the necessary adapter is not configured yet. */
|
|
|
|
deferred_adap = i2c_get_adapter(pdata->deferred_nr);
|
|
|
|
if (!deferred_adap)
|
|
|
|
return -EPROBE_DEFER;
|
|
|
|
i2c_put_adapter(deferred_adap);
|
|
|
|
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
|
|
|
|
if (!priv)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
if (pdata->irq) {
|
|
|
|
priv->irq = pdata->irq;
|
|
|
|
} else {
|
|
|
|
priv->irq = platform_get_irq(pdev, 0);
|
2019-07-31 02:15:53 +08:00
|
|
|
if (priv->irq < 0)
|
2018-01-23 11:55:11 +08:00
|
|
|
return priv->irq;
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
}
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
priv->regmap = pdata->regmap;
|
|
|
|
priv->dev = pdev->dev.parent;
|
|
|
|
priv->pdev = pdev;
|
|
|
|
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
err = devm_request_irq(&pdev->dev, priv->irq,
|
2018-01-23 11:55:11 +08:00
|
|
|
mlxreg_hotplug_irq_handler, IRQF_TRIGGER_FALLING
|
|
|
|
| IRQF_SHARED, "mlxreg-hotplug", priv);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
if (err) {
|
|
|
|
dev_err(&pdev->dev, "Failed to request irq: %d\n", err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2018-01-23 11:55:11 +08:00
|
|
|
disable_irq(priv->irq);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
spin_lock_init(&priv->lock);
|
2018-01-23 11:55:11 +08:00
|
|
|
INIT_DELAYED_WORK(&priv->dwork_irq, mlxreg_hotplug_work_handler);
|
|
|
|
dev_set_drvdata(&pdev->dev, priv);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
2018-01-18 02:21:53 +08:00
|
|
|
err = mlxreg_hotplug_attr_init(priv);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
if (err) {
|
2018-01-23 11:55:11 +08:00
|
|
|
dev_err(&pdev->dev, "Failed to allocate attributes: %d\n",
|
|
|
|
err);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->hwmon = devm_hwmon_device_register_with_groups(&pdev->dev,
|
2018-01-18 02:21:53 +08:00
|
|
|
"mlxreg_hotplug", priv, priv->groups);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
if (IS_ERR(priv->hwmon)) {
|
|
|
|
dev_err(&pdev->dev, "Failed to register hwmon device %ld\n",
|
|
|
|
PTR_ERR(priv->hwmon));
|
|
|
|
return PTR_ERR(priv->hwmon);
|
|
|
|
}
|
|
|
|
|
2018-07-27 06:40:59 +08:00
|
|
|
/* Perform initial interrupts setup. */
|
|
|
|
mlxreg_hotplug_set_irq(priv);
|
|
|
|
priv->after_probe = true;
|
|
|
|
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-18 02:21:53 +08:00
|
|
|
static int mlxreg_hotplug_remove(struct platform_device *pdev)
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
{
|
2018-01-23 11:55:11 +08:00
|
|
|
struct mlxreg_hotplug_priv_data *priv = dev_get_drvdata(&pdev->dev);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
|
|
|
/* Clean interrupts setup. */
|
2018-01-18 02:21:53 +08:00
|
|
|
mlxreg_hotplug_unset_irq(priv);
|
2019-05-24 00:41:52 +08:00
|
|
|
devm_free_irq(&pdev->dev, priv->irq, priv);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-18 02:21:53 +08:00
|
|
|
static struct platform_driver mlxreg_hotplug_driver = {
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
.driver = {
|
2018-01-18 02:21:53 +08:00
|
|
|
.name = "mlxreg-hotplug",
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
},
|
2018-01-18 02:21:53 +08:00
|
|
|
.probe = mlxreg_hotplug_probe,
|
|
|
|
.remove = mlxreg_hotplug_remove,
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
};
|
|
|
|
|
2018-01-18 02:21:53 +08:00
|
|
|
module_platform_driver(mlxreg_hotplug_driver);
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Vadim Pasternak <vadimp@mellanox.com>");
|
2018-01-18 02:21:53 +08:00
|
|
|
MODULE_DESCRIPTION("Mellanox regmap hotplug platform driver");
|
platform/x86: Introduce support for Mellanox hotplug driver
Enable system support for the Mellanox Technologies hotplug platform
driver, which provides support for the next Mellanox basic systems:
"msx6710", "msx6720", "msb7700", "msn2700", "msx1410", "msn2410",
"msb7800", "msn2740", "msn2100" and also various number of derivative
systems from the above basic types.
This driver handles hot-plug events for the power suppliers, power
cables and fans for the above systems.
The Kconfig currently controlling compilation of this code is:
driver/platform/x86:config MLX_CPLD_PLATFORM
tristate "Mellanox platform hotplug driver support"
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-10-21 00:28:01 +08:00
|
|
|
MODULE_LICENSE("Dual BSD/GPL");
|
2018-01-18 02:21:53 +08:00
|
|
|
MODULE_ALIAS("platform:mlxreg-hotplug");
|