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-20 16:28:01 +00:00
/*
2018-01-17 18:21:53 +00: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-20 16:28:01 +00: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/io.h>
# include <linux/module.h>
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
# include <linux/platform_device.h>
# include <linux/spinlock.h>
# include <linux/wait.h>
# include <linux/workqueue.h>
/* Offset of event and mask registers from status register */
2018-01-17 18:21:53 +00:00
# define MLXREG_HOTPLUG_EVENT_OFF 1
# define MLXREG_HOTPLUG_MASK_OFF 2
# 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-20 16:28:01 +00:00
2018-01-17 18:21:53 +00:00
# define MLXREG_HOTPLUG_ATTRS_NUM 8
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-20 16:28:01 +00:00
/**
2018-01-17 18:21:53 +00:00
* enum mlxreg_hotplug_attr_type - sysfs attributes for hotplug events :
* @ MLXREG_HOTPLUG_ATTR_TYPE_PSU : power supply unit attribute ;
* @ MLXREG_HOTPLUG_ATTR_TYPE_PWR : power cable attribute ;
* @ MLXREG_HOTPLUG_ATTR_TYPE_FAN : FAN drawer attribute ;
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-20 16:28:01 +00:00
*/
2018-01-17 18:21:53 +00:00
enum mlxreg_hotplug_attr_type {
MLXREG_HOTPLUG_ATTR_TYPE_PSU ,
MLXREG_HOTPLUG_ATTR_TYPE_PWR ,
MLXREG_HOTPLUG_ATTR_TYPE_FAN ,
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-20 16:28:01 +00:00
} ;
/**
2018-01-17 18:21:53 +00:00
* struct mlxreg_hotplug_priv_data - platform private 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-20 16:28:01 +00:00
* @ irq : platform interrupt number ;
* @ pdev : platform device ;
* @ plat : platform data ;
* @ hwmon : hwmon device ;
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
* @ group : sysfs attribute group ;
* @ groups : list of sysfs attribute group for hwmon registration ;
* @ dwork : delayed work template ;
* @ lock : spin lock ;
* @ aggr_cache : last value of aggregation register status ;
* @ psu_cache : last value of PSU register status ;
* @ pwr_cache : last value of power register status ;
* @ fan_cache : last value of FAN register status ;
*/
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
int irq ;
struct platform_device * pdev ;
2018-01-17 18:21:53 +00:00
struct mlxreg_hotplug_platform_data * plat ;
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-20 16:28:01 +00:00
struct device * hwmon ;
2018-01-17 18:21:53 +00:00
struct attribute * mlxreg_hotplug_attr [ MLXREG_HOTPLUG_ATTRS_NUM + 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-20 16:28:01 +00:00
struct sensor_device_attribute_2
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_dev_attr [ MLXREG_HOTPLUG_ATTRS_NUM ] ;
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-20 16:28:01 +00:00
struct attribute_group group ;
const struct attribute_group * groups [ 2 ] ;
struct delayed_work dwork ;
spinlock_t lock ;
u8 aggr_cache ;
u8 psu_cache ;
u8 pwr_cache ;
u8 fan_cache ;
} ;
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
{
struct platform_device * pdev = to_platform_device ( dev ) ;
2018-01-17 18:21:53 +00:00
struct mlxreg_hotplug_priv_data * priv = platform_get_drvdata ( 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-20 16:28:01 +00:00
int index = to_sensor_dev_attr_2 ( attr ) - > index ;
int nr = to_sensor_dev_attr_2 ( attr ) - > nr ;
u8 reg_val = 0 ;
switch ( nr ) {
2018-01-17 18:21:53 +00:00
case MLXREG_HOTPLUG_ATTR_TYPE_PSU :
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-20 16:28:01 +00:00
/* Bit = 0 : PSU is present. */
reg_val = ! ! ! ( inb ( priv - > plat - > psu_reg_offset ) & BIT ( index ) ) ;
break ;
2018-01-17 18:21:53 +00:00
case MLXREG_HOTPLUG_ATTR_TYPE_PWR :
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-20 16:28:01 +00:00
/* Bit = 1 : power cable is attached. */
reg_val = ! ! ( inb ( priv - > plat - > pwr_reg_offset ) & BIT ( index %
priv - > plat - > pwr_count ) ) ;
break ;
2018-01-17 18:21:53 +00:00
case MLXREG_HOTPLUG_ATTR_TYPE_FAN :
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-20 16:28:01 +00:00
/* Bit = 0 : FAN is present. */
reg_val = ! ! ! ( inb ( priv - > plat - > fan_reg_offset ) & BIT ( index %
priv - > plat - > fan_count ) ) ;
break ;
}
return sprintf ( buf , " %u \n " , reg_val ) ;
}
2018-01-17 18:21:53 +00:00
# define PRIV_ATTR(i) priv->mlxreg_hotplug_attr[i]
# define PRIV_DEV_ATTR(i) priv->mlxreg_hotplug_dev_attr[i]
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-20 16:28:01 +00:00
{
int num_attrs = priv - > plat - > psu_count + priv - > plat - > pwr_count +
priv - > plat - > fan_count ;
int i ;
priv - > group . attrs = devm_kzalloc ( & priv - > pdev - > dev , num_attrs *
sizeof ( struct attribute * ) ,
GFP_KERNEL ) ;
if ( ! priv - > group . attrs )
return - ENOMEM ;
for ( i = 0 ; i < num_attrs ; i + + ) {
PRIV_ATTR ( i ) = & PRIV_DEV_ATTR ( i ) . dev_attr . attr ;
if ( i < priv - > plat - > psu_count ) {
PRIV_ATTR ( i ) - > name = devm_kasprintf ( & priv - > pdev - > dev ,
GFP_KERNEL , " psu%u " , i + 1 ) ;
2018-01-17 18:21:53 +00:00
PRIV_DEV_ATTR ( i ) . nr = MLXREG_HOTPLUG_ATTR_TYPE_PSU ;
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-20 16:28:01 +00:00
} else if ( i < priv - > plat - > psu_count + priv - > plat - > pwr_count ) {
PRIV_ATTR ( i ) - > name = devm_kasprintf ( & priv - > pdev - > dev ,
GFP_KERNEL , " pwr%u " , i %
priv - > plat - > pwr_count + 1 ) ;
2018-01-17 18:21:53 +00:00
PRIV_DEV_ATTR ( i ) . nr = MLXREG_HOTPLUG_ATTR_TYPE_PWR ;
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-20 16:28:01 +00:00
} else {
PRIV_ATTR ( i ) - > name = devm_kasprintf ( & priv - > pdev - > dev ,
GFP_KERNEL , " fan%u " , i %
priv - > plat - > fan_count + 1 ) ;
2018-01-17 18:21:53 +00:00
PRIV_DEV_ATTR ( i ) . nr = MLXREG_HOTPLUG_ATTR_TYPE_FAN ;
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-20 16:28:01 +00:00
}
if ( ! PRIV_ATTR ( i ) - > name ) {
dev_err ( & priv - > pdev - > dev , " Memory allocation failed for sysfs attribute %d. \n " ,
i + 1 ) ;
return - ENOMEM ;
}
PRIV_DEV_ATTR ( i ) . dev_attr . attr . name = PRIV_ATTR ( i ) - > name ;
PRIV_DEV_ATTR ( i ) . dev_attr . attr . mode = S_IRUGO ;
2018-01-17 18:21:53 +00:00
PRIV_DEV_ATTR ( i ) . dev_attr . show = mlxreg_hotplug_attr_show ;
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-20 16:28:01 +00:00
PRIV_DEV_ATTR ( i ) . index = i ;
sysfs_attr_init ( & PRIV_DEV_ATTR ( i ) . dev_attr . attr ) ;
}
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
priv - > groups [ 0 ] = & priv - > group ;
priv - > groups [ 1 ] = NULL ;
return 0 ;
}
2018-01-17 18:21:53 +00:00
static int mlxreg_hotplug_device_create ( struct device * dev ,
struct mlxreg_hotplug_device * 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-20 16:28:01 +00:00
{
item - > adapter = i2c_get_adapter ( item - > bus ) ;
if ( ! item - > adapter ) {
dev_err ( dev , " Failed to get adapter for bus %d \n " ,
item - > bus ) ;
return - EFAULT ;
}
item - > client = i2c_new_device ( item - > adapter , & item - > brdinfo ) ;
if ( ! item - > client ) {
dev_err ( dev , " Failed to create client %s at bus %d at addr 0x%02x \n " ,
item - > brdinfo . type , item - > bus , item - > brdinfo . addr ) ;
i2c_put_adapter ( item - > adapter ) ;
item - > adapter = NULL ;
return - EFAULT ;
}
return 0 ;
}
2018-01-17 18:21:53 +00:00
static void mlxreg_hotplug_device_destroy ( struct mlxreg_hotplug_device * 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-20 16:28:01 +00:00
{
if ( item - > client ) {
i2c_unregister_device ( item - > client ) ;
item - > client = NULL ;
}
if ( item - > adapter ) {
i2c_put_adapter ( item - > adapter ) ;
item - > adapter = NULL ;
}
}
static inline void
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_work_helper ( struct device * dev ,
struct mlxreg_hotplug_device * item , u8 is_inverse ,
u16 offset , u8 mask , u8 * cache )
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-20 16:28:01 +00:00
{
u8 val , asserted ;
int bit ;
/* Mask event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , offset + MLXREG_HOTPLUG_MASK_OFF ) ;
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-20 16:28:01 +00:00
/* Read status. */
val = inb ( offset ) & mask ;
asserted = * cache ^ val ;
* cache = val ;
/*
* 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 ) ) {
dev_err ( dev , " False signal is received: register at offset 0x%02x, mask 0x%02x. \n " ,
offset , mask ) ;
return ;
}
for_each_set_bit ( bit , ( unsigned long * ) & asserted , 8 ) {
if ( val & BIT ( bit ) ) {
if ( is_inverse )
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_device_destroy ( item + bit ) ;
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-20 16:28:01 +00:00
else
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_device_create ( dev , item + bit ) ;
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-20 16:28:01 +00:00
} else {
if ( is_inverse )
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_device_create ( dev , item + bit ) ;
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-20 16:28:01 +00:00
else
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_device_destroy ( item + bit ) ;
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-20 16:28:01 +00:00
}
}
/* Acknowledge event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , offset + MLXREG_HOTPLUG_EVENT_OFF ) ;
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-20 16:28:01 +00:00
/* Unmask event. */
2018-01-17 18:21:53 +00:00
outb ( mask , offset + MLXREG_HOTPLUG_MASK_OFF ) ;
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-20 16:28:01 +00:00
}
/*
2018-01-17 18:21:53 +00:00
* mlxreg_hotplug_work_handler - performs traversing of CPLD 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-20 16:28:01 +00:00
* registers according to the below hierarchy schema :
*
* Aggregation registers ( status / mask )
* PSU registers : * - - - *
* * - - - - - - - - - - - - - - - - - * | |
* | status / event / mask | - - - - - > | * |
* * - - - - - - - - - - - - - - - - - * | |
* Power registers : | |
* * - - - - - - - - - - - - - - - - - * | |
* | status / event / mask | - - - - - > | * | - - - > CPU
* * - - - - - - - - - - - - - - - - - * | |
* FAN registers :
* * - - - - - - - - - - - - - - - - - * | |
* | status / event / mask | - - - - - > | * |
* * - - - - - - - - - - - - - - - - - * | |
* * - - - *
* In case some system changed are detected : FAN in / out , PSU in / out , power
* cable attached / detached , relevant device is created or destroyed .
*/
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
{
2018-01-17 18:21:53 +00:00
struct mlxreg_hotplug_priv_data * priv = container_of ( work ,
struct mlxreg_hotplug_priv_data , dwork . 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-20 16:28:01 +00:00
u8 val , aggr_asserted ;
unsigned long flags ;
/* Mask aggregation event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , priv - > plat - > top_aggr_offset + MLXREG_HOTPLUG_AGGR_MASK_OFF ) ;
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-20 16:28:01 +00:00
/* Read aggregation status. */
val = inb ( priv - > plat - > top_aggr_offset ) & priv - > plat - > top_aggr_mask ;
aggr_asserted = priv - > aggr_cache ^ val ;
priv - > aggr_cache = val ;
/* Handle PSU configuration changes. */
if ( aggr_asserted & priv - > plat - > top_aggr_psu_mask )
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_work_helper ( & priv - > pdev - > dev , priv - > plat - > psu ,
1 , priv - > plat - > psu_reg_offset ,
priv - > plat - > psu_mask ,
& priv - > psu_cache ) ;
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-20 16:28:01 +00:00
/* Handle power cable configuration changes. */
if ( aggr_asserted & priv - > plat - > top_aggr_pwr_mask )
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_work_helper ( & priv - > pdev - > dev , priv - > plat - > pwr ,
0 , priv - > plat - > pwr_reg_offset ,
priv - > plat - > pwr_mask ,
& priv - > pwr_cache ) ;
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-20 16:28:01 +00:00
/* Handle FAN configuration changes. */
if ( aggr_asserted & priv - > plat - > top_aggr_fan_mask )
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_work_helper ( & priv - > pdev - > dev , priv - > plat - > fan ,
1 , priv - > plat - > fan_reg_offset ,
priv - > plat - > fan_mask ,
& priv - > fan_cache ) ;
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-20 16:28:01 +00:00
if ( aggr_asserted ) {
spin_lock_irqsave ( & priv - > lock , flags ) ;
/*
* It is possible , that some signals have been inserted , while
2018-01-17 18:21:53 +00:00
* interrupt has been masked by mlxreg_hotplug_work_handler .
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-20 16:28:01 +00:00
* 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 ) ;
schedule_delayed_work ( & priv - > dwork , 0 ) ;
spin_unlock_irqrestore ( & priv - > lock , flags ) ;
return ;
}
/* Unmask aggregation event (no need acknowledge). */
outb ( priv - > plat - > top_aggr_mask , priv - > plat - > top_aggr_offset +
2018-01-17 18:21:53 +00:00
MLXREG_HOTPLUG_AGGR_MASK_OFF ) ;
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-20 16:28:01 +00:00
}
2018-01-17 18:21:53 +00:00
static void 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-20 16:28:01 +00:00
{
/* Clear psu presense event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , priv - > plat - > psu_reg_offset + MLXREG_HOTPLUG_EVENT_OFF ) ;
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-20 16:28:01 +00:00
/* Set psu initial status as mask and unmask psu event. */
priv - > psu_cache = priv - > plat - > psu_mask ;
outb ( priv - > plat - > psu_mask , priv - > plat - > psu_reg_offset +
2018-01-17 18:21:53 +00:00
MLXREG_HOTPLUG_MASK_OFF ) ;
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-20 16:28:01 +00:00
/* Clear power cable event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , priv - > plat - > pwr_reg_offset + MLXREG_HOTPLUG_EVENT_OFF ) ;
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-20 16:28:01 +00:00
/* Keep power initial status as zero and unmask power event. */
outb ( priv - > plat - > pwr_mask , priv - > plat - > pwr_reg_offset +
2018-01-17 18:21:53 +00:00
MLXREG_HOTPLUG_MASK_OFF ) ;
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-20 16:28:01 +00:00
/* Clear fan presense event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , priv - > plat - > fan_reg_offset + MLXREG_HOTPLUG_EVENT_OFF ) ;
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-20 16:28:01 +00:00
/* Set fan initial status as mask and unmask fan event. */
priv - > fan_cache = priv - > plat - > fan_mask ;
outb ( priv - > plat - > fan_mask , priv - > plat - > fan_reg_offset +
2018-01-17 18:21:53 +00:00
MLXREG_HOTPLUG_MASK_OFF ) ;
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-20 16:28:01 +00:00
/* Keep aggregation initial status as zero and unmask events. */
outb ( priv - > plat - > top_aggr_mask , priv - > plat - > top_aggr_offset +
2018-01-17 18:21:53 +00:00
MLXREG_HOTPLUG_AGGR_MASK_OFF ) ;
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-20 16:28:01 +00:00
/* Invoke work handler for initializing hot plug devices setting. */
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_work_handler ( & priv - > dwork . 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-20 16:28:01 +00:00
enable_irq ( priv - > irq ) ;
}
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
{
int i ;
disable_irq ( priv - > irq ) ;
cancel_delayed_work_sync ( & priv - > dwork ) ;
/* Mask aggregation event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , priv - > plat - > top_aggr_offset + MLXREG_HOTPLUG_AGGR_MASK_OFF ) ;
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-20 16:28:01 +00:00
/* Mask psu presense event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , priv - > plat - > psu_reg_offset + MLXREG_HOTPLUG_MASK_OFF ) ;
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-20 16:28:01 +00:00
/* Clear psu presense event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , priv - > plat - > psu_reg_offset + MLXREG_HOTPLUG_EVENT_OFF ) ;
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-20 16:28:01 +00:00
/* Mask power cable event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , priv - > plat - > pwr_reg_offset + MLXREG_HOTPLUG_MASK_OFF ) ;
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-20 16:28:01 +00:00
/* Clear power cable event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , priv - > plat - > pwr_reg_offset + MLXREG_HOTPLUG_EVENT_OFF ) ;
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-20 16:28:01 +00:00
/* Mask fan presense event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , priv - > plat - > fan_reg_offset + MLXREG_HOTPLUG_MASK_OFF ) ;
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-20 16:28:01 +00:00
/* Clear fan presense event. */
2018-01-17 18:21:53 +00:00
outb ( 0 , priv - > plat - > fan_reg_offset + MLXREG_HOTPLUG_EVENT_OFF ) ;
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-20 16:28:01 +00:00
/* Remove all the attached devices. */
for ( i = 0 ; i < priv - > plat - > psu_count ; i + + )
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_device_destroy ( priv - > plat - > psu + i ) ;
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-20 16:28:01 +00:00
for ( i = 0 ; i < priv - > plat - > pwr_count ; i + + )
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_device_destroy ( priv - > plat - > pwr + i ) ;
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-20 16:28:01 +00:00
for ( i = 0 ; i < priv - > plat - > fan_count ; i + + )
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_device_destroy ( priv - > plat - > fan + i ) ;
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-20 16:28:01 +00:00
}
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
{
2018-01-17 18:21:53 +00:00
struct mlxreg_hotplug_priv_data * 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-20 16:28:01 +00:00
/* Schedule work task for immediate execution.*/
schedule_delayed_work ( & priv - > dwork , 0 ) ;
return IRQ_HANDLED ;
}
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
{
2018-01-17 18:21:53 +00:00
struct mlxreg_hotplug_platform_data * pdata ;
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-20 16:28:01 +00:00
int err ;
pdata = dev_get_platdata ( & pdev - > dev ) ;
if ( ! pdata ) {
dev_err ( & pdev - > dev , " Failed to get platform data. \n " ) ;
return - EINVAL ;
}
priv = devm_kzalloc ( & pdev - > dev , sizeof ( * priv ) , GFP_KERNEL ) ;
if ( ! priv )
return - ENOMEM ;
priv - > pdev = pdev ;
priv - > plat = pdata ;
priv - > irq = platform_get_irq ( pdev , 0 ) ;
if ( priv - > irq < 0 ) {
dev_err ( & pdev - > dev , " Failed to get platform irq: %d \n " ,
priv - > irq ) ;
return priv - > irq ;
}
err = devm_request_irq ( & pdev - > dev , priv - > irq ,
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_irq_handler , 0 , pdev - > name ,
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-20 16:28:01 +00:00
if ( err ) {
dev_err ( & pdev - > dev , " Failed to request irq: %d \n " , err ) ;
return err ;
}
disable_irq ( priv - > irq ) ;
2018-01-17 18:21:53 +00:00
INIT_DELAYED_WORK ( & priv - > dwork , mlxreg_hotplug_work_handler ) ;
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-20 16:28:01 +00:00
spin_lock_init ( & priv - > lock ) ;
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
if ( err ) {
dev_err ( & pdev - > dev , " Failed to allocate attributes: %d \n " , err ) ;
return err ;
}
priv - > hwmon = devm_hwmon_device_register_with_groups ( & pdev - > dev ,
2018-01-17 18:21:53 +00: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-20 16:28:01 +00: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 ) ;
}
platform_set_drvdata ( pdev , priv ) ;
/* Perform initial interrupts setup. */
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_set_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-20 16:28:01 +00:00
return 0 ;
}
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
{
2018-01-17 18:21:53 +00:00
struct mlxreg_hotplug_priv_data * priv = platform_get_drvdata ( 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-20 16:28:01 +00:00
/* Clean interrupts setup. */
2018-01-17 18:21:53 +00:00
mlxreg_hotplug_unset_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-20 16:28:01 +00:00
return 0 ;
}
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
. driver = {
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
} ,
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
} ;
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
MODULE_AUTHOR ( " Vadim Pasternak <vadimp@mellanox.com> " ) ;
2018-01-17 18:21:53 +00: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-20 16:28:01 +00:00
MODULE_LICENSE ( " Dual BSD/GPL " ) ;
2018-01-17 18:21:53 +00:00
MODULE_ALIAS ( " platform:mlxreg-hotplug " ) ;