linux/drivers/platform/mellanox/nvsw-sn2201.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Nvidia sn2201 driver
 *
 * Copyright (C) 2022 Nvidia Technologies Ltd.
 */

#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/platform_data/mlxcpld.h>
#include <linux/platform_data/mlxreg.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>

/* SN2201 CPLD register offset. */
#define NVSW_SN2201_CPLD_LPC_I2C_BASE_ADRR
#define NVSW_SN2201_CPLD_LPC_IO_RANGE
#define NVSW_SN2201_HW_VER_ID_OFFSET
#define NVSW_SN2201_BOARD_ID_OFFSET
#define NVSW_SN2201_CPLD_VER_OFFSET
#define NVSW_SN2201_CPLD_MVER_OFFSET
#define NVSW_SN2201_CPLD_ID_OFFSET
#define NVSW_SN2201_CPLD_PN_OFFSET
#define NVSW_SN2201_CPLD_PN1_OFFSET
#define NVSW_SN2201_PSU_CTRL_OFFSET
#define NVSW_SN2201_QSFP28_STATUS_OFFSET
#define NVSW_SN2201_QSFP28_INT_STATUS_OFFSET
#define NVSW_SN2201_QSFP28_LP_STATUS_OFFSET
#define NVSW_SN2201_QSFP28_RST_STATUS_OFFSET
#define NVSW_SN2201_SYS_STATUS_OFFSET
#define NVSW_SN2201_FRONT_SYS_LED_CTRL_OFFSET
#define NVSW_SN2201_FRONT_PSU_LED_CTRL_OFFSET
#define NVSW_SN2201_FRONT_UID_LED_CTRL_OFFSET
#define NVSW_SN2201_QSFP28_LED_TEST_STATUS_OFFSET
#define NVSW_SN2201_SYS_RST_STATUS_OFFSET
#define NVSW_SN2201_SYS_INT_STATUS_OFFSET
#define NVSW_SN2201_SYS_INT_MASK_OFFSET
#define NVSW_SN2201_ASIC_STATUS_OFFSET
#define NVSW_SN2201_ASIC_EVENT_OFFSET
#define NVSW_SN2201_ASIC_MAKS_OFFSET
#define NVSW_SN2201_THML_STATUS_OFFSET
#define NVSW_SN2201_THML_EVENT_OFFSET
#define NVSW_SN2201_THML_MASK_OFFSET
#define NVSW_SN2201_PS_ALT_STATUS_OFFSET
#define NVSW_SN2201_PS_ALT_EVENT_OFFSET
#define NVSW_SN2201_PS_ALT_MASK_OFFSET
#define NVSW_SN2201_PS_PRSNT_STATUS_OFFSET
#define NVSW_SN2201_PS_PRSNT_EVENT_OFFSET
#define NVSW_SN2201_PS_PRSNT_MASK_OFFSET
#define NVSW_SN2201_PS_DC_OK_STATUS_OFFSET
#define NVSW_SN2201_PS_DC_OK_EVENT_OFFSET
#define NVSW_SN2201_PS_DC_OK_MASK_OFFSET
#define NVSW_SN2201_RST_CAUSE1_OFFSET
#define NVSW_SN2201_RST_CAUSE2_OFFSET
#define NVSW_SN2201_RST_SW_CTRL_OFFSET
#define NVSW_SN2201_FAN_PRSNT_STATUS_OFFSET
#define NVSW_SN2201_FAN_PRSNT_EVENT_OFFSET
#define NVSW_SN2201_FAN_PRSNT_MASK_OFFSET
#define NVSW_SN2201_WD_TMR_OFFSET_LSB
#define NVSW_SN2201_WD_TMR_OFFSET_MSB
#define NVSW_SN2201_WD_ACT_OFFSET
#define NVSW_SN2201_FAN_LED1_CTRL_OFFSET
#define NVSW_SN2201_FAN_LED2_CTRL_OFFSET
#define NVSW_SN2201_REG_MAX

/* Number of physical I2C busses. */
#define NVSW_SN2201_PHY_I2C_BUS_NUM
/* Number of main mux channels. */
#define NVSW_SN2201_MAIN_MUX_CHNL_NUM

#define NVSW_SN2201_MAIN_NR
#define NVSW_SN2201_MAIN_MUX_NR
#define NVSW_SN2201_MAIN_MUX_DEFER_NR

#define NVSW_SN2201_MAIN_MUX_CH0_NR
#define NVSW_SN2201_MAIN_MUX_CH1_NR
#define NVSW_SN2201_MAIN_MUX_CH2_NR
#define NVSW_SN2201_MAIN_MUX_CH3_NR
#define NVSW_SN2201_MAIN_MUX_CH5_NR
#define NVSW_SN2201_MAIN_MUX_CH6_NR
#define NVSW_SN2201_MAIN_MUX_CH7_NR
#define NVSW_SN2201_2ND_MUX_CH0_NR
#define NVSW_SN2201_2ND_MUX_CH1_NR
#define NVSW_SN2201_2ND_MUX_CH2_NR
#define NVSW_SN2201_2ND_MUX_CH3_NR

#define NVSW_SN2201_CPLD_NR
#define NVSW_SN2201_NR_NONE

/* Masks for aggregation, PSU presence and power, ASIC events
 * in CPLD related registers.
 */
#define NVSW_SN2201_CPLD_AGGR_ASIC_MASK_DEF
#define NVSW_SN2201_CPLD_AGGR_PSU_MASK_DEF
#define NVSW_SN2201_CPLD_AGGR_PWR_MASK_DEF
#define NVSW_SN2201_CPLD_AGGR_FAN_MASK_DEF
#define NVSW_SN2201_CPLD_AGGR_MASK_DEF

#define NVSW_SN2201_CPLD_ASIC_MASK
#define NVSW_SN2201_CPLD_PSU_MASK
#define NVSW_SN2201_CPLD_PWR_MASK
#define NVSW_SN2201_CPLD_FAN_MASK

#define NVSW_SN2201_CPLD_SYSIRQ
#define NVSW_SN2201_LPC_SYSIRQ
#define NVSW_SN2201_CPLD_I2CADDR

#define NVSW_SN2201_WD_DFLT_TIMEOUT

/* nvsw_sn2201 - device private data
 * @dev: platform device;
 * @io_data: register access platform data;
 * @led_data: LED platform data;
 * @hotplug_data: hotplug platform data;
 * @i2c_data: I2C controller platform data;
 * @led: LED device;
 * @io_regs: register access device;
 * @pdev_hotplug: hotplug device;
 * @sn2201_devs: I2C devices for sn2201 devices;
 * @sn2201_devs_num: number of I2C devices for sn2201 device;
 * @main_mux_devs: I2C devices for main mux;
 * @main_mux_devs_num: number of I2C devices for main mux;
 * @cpld_devs: I2C devices for cpld;
 * @cpld_devs_num: number of I2C devices for cpld;
 * @main_mux_deferred_nr: I2C adapter number must be exist prior creating devices execution;
 */
struct nvsw_sn2201 {};

static bool nvsw_sn2201_writeable_reg(struct device *dev, unsigned int reg)
{}

static bool nvsw_sn2201_readable_reg(struct device *dev, unsigned int reg)
{}

static bool nvsw_sn2201_volatile_reg(struct device *dev, unsigned int reg)
{}

static const struct reg_default nvsw_sn2201_regmap_default[] =;

/* Configuration for the register map of a device with 1 bytes address space. */
static const struct regmap_config nvsw_sn2201_regmap_conf =;

/* Regions for LPC I2C controller and LPC base register space. */
static const struct resource nvsw_sn2201_lpc_io_resources[] =;

static struct resource nvsw_sn2201_cpld_res[] =;

static struct resource nvsw_sn2201_lpc_res[] =;

/* SN2201 I2C platform data. */
static struct mlxreg_core_hotplug_platform_data nvsw_sn2201_i2c_data =;

/* SN2201 CPLD device. */
static struct i2c_board_info nvsw_sn2201_cpld_devices[] =;

/* SN2201 CPLD board info. */
static struct mlxreg_hotplug_device nvsw_sn2201_cpld_brdinfo[] =;

/* SN2201 main mux device. */
static struct i2c_board_info nvsw_sn2201_main_mux_devices[] =;

/* SN2201 main mux board info. */
static struct mlxreg_hotplug_device nvsw_sn2201_main_mux_brdinfo[] =;

/* SN2201 power devices. */
static struct i2c_board_info nvsw_sn2201_pwr_devices[] =;

/* SN2201 fan devices. */
static struct i2c_board_info nvsw_sn2201_fan_devices[] =;

/* SN2201 hotplug default data. */
static struct mlxreg_core_data nvsw_sn2201_psu_items_data[] =;

static struct mlxreg_core_data nvsw_sn2201_pwr_items_data[] =;

static struct mlxreg_core_data nvsw_sn2201_fan_items_data[] =;

static struct mlxreg_core_data nvsw_sn2201_sys_items_data[] =;

static struct mlxreg_core_item nvsw_sn2201_items[] =;

static
struct mlxreg_core_hotplug_platform_data nvsw_sn2201_hotplug =;

/* SN2201 static devices. */
static struct i2c_board_info nvsw_sn2201_static_devices[] =;

/* SN2201 default static board info. */
static struct mlxreg_hotplug_device nvsw_sn2201_static_brdinfo[] =;

/* LED default data. */
static struct mlxreg_core_data nvsw_sn2201_led_data[] =;

static struct mlxreg_core_platform_data nvsw_sn2201_led =;

/* Default register access data. */
static struct mlxreg_core_data nvsw_sn2201_io_data[] =;

static struct mlxreg_core_platform_data nvsw_sn2201_regs_io =;

/* Default watchdog data. */
static struct mlxreg_core_data nvsw_sn2201_wd_data[] =;

static struct mlxreg_core_platform_data nvsw_sn2201_wd =;

static int
nvsw_sn2201_create_static_devices(struct nvsw_sn2201 *nvsw_sn2201,
				  struct mlxreg_hotplug_device *devs,
				  int size)
{}

static void nvsw_sn2201_destroy_static_devices(struct nvsw_sn2201 *nvsw_sn2201,
					       struct mlxreg_hotplug_device *devs, int size)
{}

static int nvsw_sn2201_config_post_init(struct nvsw_sn2201 *nvsw_sn2201)
{}

static int nvsw_sn2201_config_init(struct nvsw_sn2201 *nvsw_sn2201, void *regmap)
{}

static void nvsw_sn2201_config_exit(struct nvsw_sn2201 *nvsw_sn2201)
{}

/*
 * Initialization is divided into two parts:
 * - I2C main bus init.
 * - Mux creation and attaching devices to the mux,
 *   which assumes that the main bus is already created.
 * This separation is required for synchronization between these two parts.
 * Completion notify callback is used to make this flow synchronized.
 */
static int nvsw_sn2201_i2c_completion_notify(void *handle, int id)
{}

static int nvsw_sn2201_config_pre_init(struct nvsw_sn2201 *nvsw_sn2201)
{}

static int nvsw_sn2201_probe(struct platform_device *pdev)
{}

static void nvsw_sn2201_remove(struct platform_device *pdev)
{}

static const struct acpi_device_id nvsw_sn2201_acpi_ids[] =;

MODULE_DEVICE_TABLE(acpi, nvsw_sn2201_acpi_ids);

static struct platform_driver nvsw_sn2201_driver =;

module_platform_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_ALIAS();