linux/drivers/gpio/gpio-mlxbf2.c

// SPDX-License-Identifier: GPL-2.0

/*
 * Copyright (C) 2020-2021 NVIDIA CORPORATION & AFFILIATES
 */

#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/gpio/driver.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/resource.h>
#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/types.h>

/*
 * There are 3 YU GPIO blocks:
 * gpio[0]: HOST_GPIO0->HOST_GPIO31
 * gpio[1]: HOST_GPIO32->HOST_GPIO63
 * gpio[2]: HOST_GPIO64->HOST_GPIO69
 */
#define MLXBF2_GPIO_MAX_PINS_PER_BLOCK

/*
 * arm_gpio_lock register:
 * bit[31]	lock status: active if set
 * bit[15:0]	set lock
 * The lock is enabled only if 0xd42f is written to this field
 */
#define YU_ARM_GPIO_LOCK_ADDR
#define YU_ARM_GPIO_LOCK_SIZE
#define YU_LOCK_ACTIVE_BIT(val)
#define YU_ARM_GPIO_LOCK_ACQUIRE
#define YU_ARM_GPIO_LOCK_RELEASE

/*
 * gpio[x] block registers and their offset
 */
#define YU_GPIO_DATAIN
#define YU_GPIO_MODE1
#define YU_GPIO_MODE0
#define YU_GPIO_DATASET
#define YU_GPIO_DATACLEAR
#define YU_GPIO_CAUSE_RISE_EN
#define YU_GPIO_CAUSE_FALL_EN
#define YU_GPIO_MODE1_CLEAR
#define YU_GPIO_MODE0_SET
#define YU_GPIO_MODE0_CLEAR
#define YU_GPIO_CAUSE_OR_CAUSE_EVTEN0
#define YU_GPIO_CAUSE_OR_EVTEN0
#define YU_GPIO_CAUSE_OR_CLRCAUSE

struct mlxbf2_gpio_context_save_regs {};

/* BlueField-2 gpio block context structure. */
struct mlxbf2_gpio_context {};

/* BlueField-2 gpio shared structure. */
struct mlxbf2_gpio_param {};

static struct resource yu_arm_gpio_lock_res =;

static DEFINE_MUTEX(yu_arm_gpio_lock_mutex);

static struct mlxbf2_gpio_param yu_arm_gpio_lock_param =;

/* Request memory region and map yu_arm_gpio_lock resource */
static int mlxbf2_gpio_get_lock_res(struct platform_device *pdev)
{}

/*
 * Acquire the YU arm_gpio_lock to be able to change the direction
 * mode. If the lock_active bit is already set, return an error.
 */
static int mlxbf2_gpio_lock_acquire(struct mlxbf2_gpio_context *gs)
{}

/*
 * Release the YU arm_gpio_lock after changing the direction mode.
 */
static void mlxbf2_gpio_lock_release(struct mlxbf2_gpio_context *gs)
	__releases(&gs->gc.bgpio_lock)
	__releases(yu_arm_gpio_lock_param.lock)
{}

/*
 * mode0 and mode1 are both locked by the gpio_lock field.
 *
 * Together, mode0 and mode1 define the gpio Mode dependeing also
 * on Reg_DataOut.
 *
 * {mode1,mode0}:{Reg_DataOut=0,Reg_DataOut=1}->{DataOut=0,DataOut=1}
 *
 * {0,0}:Reg_DataOut{0,1}->{Z,Z} Input PAD
 * {0,1}:Reg_DataOut{0,1}->{0,1} Full drive Output PAD
 * {1,0}:Reg_DataOut{0,1}->{0,Z} 0-set PAD to low, 1-float
 * {1,1}:Reg_DataOut{0,1}->{Z,1} 0-float, 1-set PAD to high
 */

/*
 * Set input direction:
 * {mode1,mode0} = {0,0}
 */
static int mlxbf2_gpio_direction_input(struct gpio_chip *chip,
				       unsigned int offset)
{}

/*
 * Set output direction:
 * {mode1,mode0} = {0,1}
 */
static int mlxbf2_gpio_direction_output(struct gpio_chip *chip,
					unsigned int offset,
					int value)
{}

static void mlxbf2_gpio_irq_enable(struct irq_data *irqd)
{}

static void mlxbf2_gpio_irq_disable(struct irq_data *irqd)
{}

static irqreturn_t mlxbf2_gpio_irq_handler(int irq, void *ptr)
{}

static int
mlxbf2_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)
{}

static void mlxbf2_gpio_irq_print_chip(struct irq_data *irqd,
				       struct seq_file *p)
{}

static const struct irq_chip mlxbf2_gpio_irq_chip =;

/* BlueField-2 GPIO driver initialization routine. */
static int
mlxbf2_gpio_probe(struct platform_device *pdev)
{}

static int __maybe_unused mlxbf2_gpio_suspend(struct device *dev)
{}

static int __maybe_unused mlxbf2_gpio_resume(struct device *dev)
{}
static SIMPLE_DEV_PM_OPS(mlxbf2_pm_ops, mlxbf2_gpio_suspend, mlxbf2_gpio_resume);

static const struct acpi_device_id __maybe_unused mlxbf2_gpio_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, mlxbf2_gpio_acpi_match);

static struct platform_driver mlxbf2_gpio_driver =;

module_platform_driver();

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