2019-05-27 14:55:22 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2008-11-13 05:25:38 +08:00
|
|
|
/*
|
2013-06-03 20:31:17 +08:00
|
|
|
* Xilinx gpio driver for xps/axi_gpio IP.
|
2008-11-13 05:25:38 +08:00
|
|
|
*
|
2013-06-03 20:31:17 +08:00
|
|
|
* Copyright 2008 - 2013 Xilinx, Inc.
|
2008-11-13 05:25:38 +08:00
|
|
|
*/
|
|
|
|
|
2013-06-03 20:31:17 +08:00
|
|
|
#include <linux/bitops.h>
|
2020-11-13 01:12:22 +08:00
|
|
|
#include <linux/clk.h>
|
2008-11-13 05:25:38 +08:00
|
|
|
#include <linux/errno.h>
|
2020-11-13 01:12:20 +08:00
|
|
|
#include <linux/gpio/driver.h>
|
|
|
|
#include <linux/init.h>
|
2021-01-29 22:26:48 +08:00
|
|
|
#include <linux/interrupt.h>
|
2020-11-13 01:12:20 +08:00
|
|
|
#include <linux/io.h>
|
2021-01-29 22:26:48 +08:00
|
|
|
#include <linux/irq.h>
|
2011-07-04 01:38:09 +08:00
|
|
|
#include <linux/module.h>
|
2008-11-13 05:25:38 +08:00
|
|
|
#include <linux/of_device.h>
|
|
|
|
#include <linux/of_platform.h>
|
2021-01-29 22:26:49 +08:00
|
|
|
#include <linux/pm_runtime.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2008-11-13 05:25:38 +08:00
|
|
|
|
|
|
|
/* Register Offset Definitions */
|
|
|
|
#define XGPIO_DATA_OFFSET (0x0) /* Data register */
|
|
|
|
#define XGPIO_TRI_OFFSET (0x4) /* I/O direction register */
|
|
|
|
|
2013-06-03 20:31:17 +08:00
|
|
|
#define XGPIO_CHANNEL_OFFSET 0x8
|
|
|
|
|
2021-01-29 22:26:48 +08:00
|
|
|
#define XGPIO_GIER_OFFSET 0x11c /* Global Interrupt Enable */
|
|
|
|
#define XGPIO_GIER_IE BIT(31)
|
|
|
|
#define XGPIO_IPISR_OFFSET 0x120 /* IP Interrupt Status */
|
|
|
|
#define XGPIO_IPIER_OFFSET 0x128 /* IP Interrupt Enable */
|
|
|
|
|
2013-06-03 20:31:17 +08:00
|
|
|
/* Read/Write access to the GPIO registers */
|
2014-12-17 23:51:10 +08:00
|
|
|
#if defined(CONFIG_ARCH_ZYNQ) || defined(CONFIG_X86)
|
2013-06-03 20:31:18 +08:00
|
|
|
# define xgpio_readreg(offset) readl(offset)
|
|
|
|
# define xgpio_writereg(offset, val) writel(val, offset)
|
|
|
|
#else
|
|
|
|
# define xgpio_readreg(offset) __raw_readl(offset)
|
|
|
|
# define xgpio_writereg(offset, val) __raw_writel(val, offset)
|
|
|
|
#endif
|
2013-06-03 20:31:17 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct xgpio_instance - Stores information about GPIO device
|
2019-06-08 01:04:16 +08:00
|
|
|
* @gc: GPIO chip
|
|
|
|
* @regs: register block
|
2015-05-04 22:37:16 +08:00
|
|
|
* @gpio_width: GPIO width for every channel
|
2021-01-29 22:26:48 +08:00
|
|
|
* @gpio_state: GPIO write state shadow register
|
|
|
|
* @gpio_last_irq_read: GPIO read state register from last interrupt
|
2014-12-17 23:51:11 +08:00
|
|
|
* @gpio_dir: GPIO direction shadow register
|
|
|
|
* @gpio_lock: Lock used for synchronization
|
2021-01-29 22:26:48 +08:00
|
|
|
* @irq: IRQ used by GPIO device
|
|
|
|
* @irqchip: IRQ chip
|
|
|
|
* @irq_enable: GPIO IRQ enable/disable bitfield
|
|
|
|
* @irq_rising_edge: GPIO IRQ rising edge enable/disable bitfield
|
|
|
|
* @irq_falling_edge: GPIO IRQ falling edge enable/disable bitfield
|
2020-11-13 01:12:22 +08:00
|
|
|
* @clk: clock resource for this driver
|
2013-06-03 20:31:17 +08:00
|
|
|
*/
|
2008-11-13 05:25:38 +08:00
|
|
|
struct xgpio_instance {
|
2019-06-08 01:04:16 +08:00
|
|
|
struct gpio_chip gc;
|
|
|
|
void __iomem *regs;
|
2014-12-17 23:51:12 +08:00
|
|
|
unsigned int gpio_width[2];
|
|
|
|
u32 gpio_state[2];
|
2021-01-29 22:26:48 +08:00
|
|
|
u32 gpio_last_irq_read[2];
|
2014-12-17 23:51:12 +08:00
|
|
|
u32 gpio_dir[2];
|
2021-01-29 22:26:47 +08:00
|
|
|
spinlock_t gpio_lock; /* For serializing operations */
|
2021-01-29 22:26:48 +08:00
|
|
|
int irq;
|
|
|
|
struct irq_chip irqchip;
|
|
|
|
u32 irq_enable[2];
|
|
|
|
u32 irq_rising_edge[2];
|
|
|
|
u32 irq_falling_edge[2];
|
2020-11-13 01:12:22 +08:00
|
|
|
struct clk *clk;
|
2014-12-17 23:51:09 +08:00
|
|
|
};
|
|
|
|
|
2014-12-17 23:51:12 +08:00
|
|
|
static inline int xgpio_index(struct xgpio_instance *chip, int gpio)
|
|
|
|
{
|
|
|
|
if (gpio >= chip->gpio_width[0])
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int xgpio_regoffset(struct xgpio_instance *chip, int gpio)
|
|
|
|
{
|
|
|
|
if (xgpio_index(chip, gpio))
|
|
|
|
return XGPIO_CHANNEL_OFFSET;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int xgpio_offset(struct xgpio_instance *chip, int gpio)
|
|
|
|
{
|
|
|
|
if (xgpio_index(chip, gpio))
|
|
|
|
return gpio - chip->gpio_width[0];
|
|
|
|
|
|
|
|
return gpio;
|
|
|
|
}
|
2008-11-13 05:25:38 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* xgpio_get - Read the specified signal of the GPIO device.
|
|
|
|
* @gc: Pointer to gpio_chip device structure.
|
|
|
|
* @gpio: GPIO signal number.
|
|
|
|
*
|
2014-12-17 23:51:11 +08:00
|
|
|
* This function reads the specified signal of the GPIO device.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* 0 if direction of GPIO signals is set as input otherwise it
|
|
|
|
* returns negative error value.
|
2008-11-13 05:25:38 +08:00
|
|
|
*/
|
|
|
|
static int xgpio_get(struct gpio_chip *gc, unsigned int gpio)
|
|
|
|
{
|
2015-12-07 22:20:17 +08:00
|
|
|
struct xgpio_instance *chip = gpiochip_get_data(gc);
|
2014-12-17 23:51:12 +08:00
|
|
|
u32 val;
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2019-06-08 01:04:16 +08:00
|
|
|
val = xgpio_readreg(chip->regs + XGPIO_DATA_OFFSET +
|
2014-12-17 23:51:12 +08:00
|
|
|
xgpio_regoffset(chip, gpio));
|
|
|
|
|
|
|
|
return !!(val & BIT(xgpio_offset(chip, gpio)));
|
2008-11-13 05:25:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xgpio_set - Write the specified signal of the GPIO device.
|
|
|
|
* @gc: Pointer to gpio_chip device structure.
|
|
|
|
* @gpio: GPIO signal number.
|
|
|
|
* @val: Value to be written to specified signal.
|
|
|
|
*
|
|
|
|
* This function writes the specified value in to the specified signal of the
|
|
|
|
* GPIO device.
|
|
|
|
*/
|
|
|
|
static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
2015-12-07 22:20:17 +08:00
|
|
|
struct xgpio_instance *chip = gpiochip_get_data(gc);
|
2014-12-17 23:51:12 +08:00
|
|
|
int index = xgpio_index(chip, gpio);
|
|
|
|
int offset = xgpio_offset(chip, gpio);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2021-01-29 22:26:47 +08:00
|
|
|
spin_lock_irqsave(&chip->gpio_lock, flags);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
|
|
|
/* Write to GPIO signal and set its direction to output */
|
|
|
|
if (val)
|
2014-12-17 23:51:12 +08:00
|
|
|
chip->gpio_state[index] |= BIT(offset);
|
2008-11-13 05:25:38 +08:00
|
|
|
else
|
2014-12-17 23:51:12 +08:00
|
|
|
chip->gpio_state[index] &= ~BIT(offset);
|
2013-06-03 20:31:17 +08:00
|
|
|
|
2019-06-08 01:04:16 +08:00
|
|
|
xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET +
|
2014-12-17 23:51:12 +08:00
|
|
|
xgpio_regoffset(chip, gpio), chip->gpio_state[index]);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2021-01-29 22:26:47 +08:00
|
|
|
spin_unlock_irqrestore(&chip->gpio_lock, flags);
|
2008-11-13 05:25:38 +08:00
|
|
|
}
|
|
|
|
|
2016-06-03 20:54:41 +08:00
|
|
|
/**
|
|
|
|
* xgpio_set_multiple - Write the specified signals of the GPIO device.
|
|
|
|
* @gc: Pointer to gpio_chip device structure.
|
|
|
|
* @mask: Mask of the GPIOS to modify.
|
|
|
|
* @bits: Value to be wrote on each GPIO
|
|
|
|
*
|
|
|
|
* This function writes the specified values into the specified signals of the
|
|
|
|
* GPIO devices.
|
|
|
|
*/
|
|
|
|
static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
|
|
|
|
unsigned long *bits)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct xgpio_instance *chip = gpiochip_get_data(gc);
|
|
|
|
int index = xgpio_index(chip, 0);
|
|
|
|
int offset, i;
|
|
|
|
|
2021-01-29 22:26:47 +08:00
|
|
|
spin_lock_irqsave(&chip->gpio_lock, flags);
|
2016-06-03 20:54:41 +08:00
|
|
|
|
|
|
|
/* Write to GPIO signals */
|
|
|
|
for (i = 0; i < gc->ngpio; i++) {
|
|
|
|
if (*mask == 0)
|
|
|
|
break;
|
2020-01-26 06:14:10 +08:00
|
|
|
/* Once finished with an index write it out to the register */
|
2016-06-03 20:54:41 +08:00
|
|
|
if (index != xgpio_index(chip, i)) {
|
2019-06-08 01:04:16 +08:00
|
|
|
xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET +
|
2020-01-26 06:14:10 +08:00
|
|
|
index * XGPIO_CHANNEL_OFFSET,
|
2016-06-03 20:54:41 +08:00
|
|
|
chip->gpio_state[index]);
|
2021-01-29 22:26:47 +08:00
|
|
|
spin_unlock_irqrestore(&chip->gpio_lock, flags);
|
2016-06-03 20:54:41 +08:00
|
|
|
index = xgpio_index(chip, i);
|
2021-01-29 22:26:47 +08:00
|
|
|
spin_lock_irqsave(&chip->gpio_lock, flags);
|
2016-06-03 20:54:41 +08:00
|
|
|
}
|
|
|
|
if (__test_and_clear_bit(i, mask)) {
|
|
|
|
offset = xgpio_offset(chip, i);
|
|
|
|
if (test_bit(i, bits))
|
|
|
|
chip->gpio_state[index] |= BIT(offset);
|
|
|
|
else
|
|
|
|
chip->gpio_state[index] &= ~BIT(offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-08 01:04:16 +08:00
|
|
|
xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET +
|
2020-01-26 06:14:10 +08:00
|
|
|
index * XGPIO_CHANNEL_OFFSET, chip->gpio_state[index]);
|
2016-06-03 20:54:41 +08:00
|
|
|
|
2021-01-29 22:26:47 +08:00
|
|
|
spin_unlock_irqrestore(&chip->gpio_lock, flags);
|
2016-06-03 20:54:41 +08:00
|
|
|
}
|
|
|
|
|
2008-11-13 05:25:38 +08:00
|
|
|
/**
|
|
|
|
* xgpio_dir_in - Set the direction of the specified GPIO signal as input.
|
|
|
|
* @gc: Pointer to gpio_chip device structure.
|
|
|
|
* @gpio: GPIO signal number.
|
|
|
|
*
|
2014-12-17 23:51:11 +08:00
|
|
|
* Return:
|
|
|
|
* 0 - if direction of GPIO signals is set as input
|
|
|
|
* otherwise it returns negative error value.
|
2008-11-13 05:25:38 +08:00
|
|
|
*/
|
|
|
|
static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
2015-12-07 22:20:17 +08:00
|
|
|
struct xgpio_instance *chip = gpiochip_get_data(gc);
|
2014-12-17 23:51:12 +08:00
|
|
|
int index = xgpio_index(chip, gpio);
|
|
|
|
int offset = xgpio_offset(chip, gpio);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2021-01-29 22:26:47 +08:00
|
|
|
spin_lock_irqsave(&chip->gpio_lock, flags);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
|
|
|
/* Set the GPIO bit in shadow register and set direction as input */
|
2014-12-17 23:51:12 +08:00
|
|
|
chip->gpio_dir[index] |= BIT(offset);
|
2019-06-08 01:04:16 +08:00
|
|
|
xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET +
|
2014-12-17 23:51:12 +08:00
|
|
|
xgpio_regoffset(chip, gpio), chip->gpio_dir[index]);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2021-01-29 22:26:47 +08:00
|
|
|
spin_unlock_irqrestore(&chip->gpio_lock, flags);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xgpio_dir_out - Set the direction of the specified GPIO signal as output.
|
|
|
|
* @gc: Pointer to gpio_chip device structure.
|
|
|
|
* @gpio: GPIO signal number.
|
|
|
|
* @val: Value to be written to specified signal.
|
|
|
|
*
|
2014-12-17 23:51:11 +08:00
|
|
|
* This function sets the direction of specified GPIO signal as output.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* If all GPIO signals of GPIO chip is configured as input then it returns
|
2008-11-13 05:25:38 +08:00
|
|
|
* error otherwise it returns 0.
|
|
|
|
*/
|
|
|
|
static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
2015-12-07 22:20:17 +08:00
|
|
|
struct xgpio_instance *chip = gpiochip_get_data(gc);
|
2014-12-17 23:51:12 +08:00
|
|
|
int index = xgpio_index(chip, gpio);
|
|
|
|
int offset = xgpio_offset(chip, gpio);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2021-01-29 22:26:47 +08:00
|
|
|
spin_lock_irqsave(&chip->gpio_lock, flags);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
|
|
|
/* Write state of GPIO signal */
|
|
|
|
if (val)
|
2014-12-17 23:51:12 +08:00
|
|
|
chip->gpio_state[index] |= BIT(offset);
|
2008-11-13 05:25:38 +08:00
|
|
|
else
|
2014-12-17 23:51:12 +08:00
|
|
|
chip->gpio_state[index] &= ~BIT(offset);
|
2019-06-08 01:04:16 +08:00
|
|
|
xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET +
|
2014-12-17 23:51:12 +08:00
|
|
|
xgpio_regoffset(chip, gpio), chip->gpio_state[index]);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
|
|
|
/* Clear the GPIO bit in shadow register and set direction as output */
|
2014-12-17 23:51:12 +08:00
|
|
|
chip->gpio_dir[index] &= ~BIT(offset);
|
2019-06-08 01:04:16 +08:00
|
|
|
xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET +
|
2014-12-17 23:51:12 +08:00
|
|
|
xgpio_regoffset(chip, gpio), chip->gpio_dir[index]);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2021-01-29 22:26:47 +08:00
|
|
|
spin_unlock_irqrestore(&chip->gpio_lock, flags);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xgpio_save_regs - Set initial values of GPIO pins
|
2019-06-08 01:04:16 +08:00
|
|
|
* @chip: Pointer to GPIO instance
|
2008-11-13 05:25:38 +08:00
|
|
|
*/
|
2019-06-08 01:04:16 +08:00
|
|
|
static void xgpio_save_regs(struct xgpio_instance *chip)
|
2008-11-13 05:25:38 +08:00
|
|
|
{
|
2019-06-08 01:04:16 +08:00
|
|
|
xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET, chip->gpio_state[0]);
|
|
|
|
xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET, chip->gpio_dir[0]);
|
2014-12-17 23:51:12 +08:00
|
|
|
|
|
|
|
if (!chip->gpio_width[1])
|
|
|
|
return;
|
|
|
|
|
2019-06-08 01:04:16 +08:00
|
|
|
xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + XGPIO_CHANNEL_OFFSET,
|
2014-12-17 23:51:12 +08:00
|
|
|
chip->gpio_state[1]);
|
2019-06-08 01:04:16 +08:00
|
|
|
xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET + XGPIO_CHANNEL_OFFSET,
|
2014-12-17 23:51:12 +08:00
|
|
|
chip->gpio_dir[1]);
|
2008-11-13 05:25:38 +08:00
|
|
|
}
|
|
|
|
|
2021-01-29 22:26:49 +08:00
|
|
|
static int xgpio_request(struct gpio_chip *chip, unsigned int offset)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = pm_runtime_get_sync(chip->parent);
|
|
|
|
/*
|
|
|
|
* If the device is already active pm_runtime_get() will return 1 on
|
|
|
|
* success, but gpio_request still needs to return 0.
|
|
|
|
*/
|
|
|
|
return ret < 0 ? ret : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xgpio_free(struct gpio_chip *chip, unsigned int offset)
|
|
|
|
{
|
|
|
|
pm_runtime_put(chip->parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __maybe_unused xgpio_suspend(struct device *dev)
|
|
|
|
{
|
|
|
|
struct xgpio_instance *gpio = dev_get_drvdata(dev);
|
|
|
|
struct irq_data *data = irq_get_irq_data(gpio->irq);
|
|
|
|
|
|
|
|
if (!data) {
|
|
|
|
dev_err(dev, "irq_get_irq_data() failed\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!irqd_is_wakeup_set(data))
|
|
|
|
return pm_runtime_force_suspend(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-13 01:12:25 +08:00
|
|
|
/**
|
|
|
|
* xgpio_remove - Remove method for the GPIO device.
|
|
|
|
* @pdev: pointer to the platform device
|
|
|
|
*
|
|
|
|
* This function remove gpiochips and frees all the allocated resources.
|
|
|
|
*
|
|
|
|
* Return: 0 always
|
|
|
|
*/
|
|
|
|
static int xgpio_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct xgpio_instance *gpio = platform_get_drvdata(pdev);
|
|
|
|
|
2021-01-29 22:26:49 +08:00
|
|
|
pm_runtime_get_sync(&pdev->dev);
|
|
|
|
pm_runtime_put_noidle(&pdev->dev);
|
|
|
|
pm_runtime_disable(&pdev->dev);
|
2020-11-13 01:12:25 +08:00
|
|
|
clk_disable_unprepare(gpio->clk);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-01-29 22:26:48 +08:00
|
|
|
/**
|
|
|
|
* xgpio_irq_ack - Acknowledge a child GPIO interrupt.
|
|
|
|
* @irq_data: per IRQ and chip data passed down to chip functions
|
|
|
|
* This currently does nothing, but irq_ack is unconditionally called by
|
|
|
|
* handle_edge_irq and therefore must be defined.
|
|
|
|
*/
|
|
|
|
static void xgpio_irq_ack(struct irq_data *irq_data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-29 22:26:49 +08:00
|
|
|
static int __maybe_unused xgpio_resume(struct device *dev)
|
|
|
|
{
|
|
|
|
struct xgpio_instance *gpio = dev_get_drvdata(dev);
|
|
|
|
struct irq_data *data = irq_get_irq_data(gpio->irq);
|
|
|
|
|
|
|
|
if (!data) {
|
|
|
|
dev_err(dev, "irq_get_irq_data() failed\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!irqd_is_wakeup_set(data))
|
|
|
|
return pm_runtime_force_resume(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __maybe_unused xgpio_runtime_suspend(struct device *dev)
|
|
|
|
{
|
|
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
|
|
struct xgpio_instance *gpio = platform_get_drvdata(pdev);
|
|
|
|
|
|
|
|
clk_disable(gpio->clk);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __maybe_unused xgpio_runtime_resume(struct device *dev)
|
|
|
|
{
|
|
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
|
|
struct xgpio_instance *gpio = platform_get_drvdata(pdev);
|
|
|
|
|
|
|
|
return clk_enable(gpio->clk);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct dev_pm_ops xgpio_dev_pm_ops = {
|
|
|
|
SET_SYSTEM_SLEEP_PM_OPS(xgpio_suspend, xgpio_resume)
|
|
|
|
SET_RUNTIME_PM_OPS(xgpio_runtime_suspend,
|
|
|
|
xgpio_runtime_resume, NULL)
|
|
|
|
};
|
|
|
|
|
2021-01-29 22:26:48 +08:00
|
|
|
/**
|
|
|
|
* xgpio_irq_mask - Write the specified signal of the GPIO device.
|
|
|
|
* @irq_data: per IRQ and chip data passed down to chip functions
|
|
|
|
*/
|
|
|
|
static void xgpio_irq_mask(struct irq_data *irq_data)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct xgpio_instance *chip = irq_data_get_irq_chip_data(irq_data);
|
|
|
|
int irq_offset = irqd_to_hwirq(irq_data);
|
|
|
|
int index = xgpio_index(chip, irq_offset);
|
|
|
|
int offset = xgpio_offset(chip, irq_offset);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&chip->gpio_lock, flags);
|
|
|
|
|
|
|
|
chip->irq_enable[index] &= ~BIT(offset);
|
|
|
|
|
|
|
|
if (!chip->irq_enable[index]) {
|
|
|
|
/* Disable per channel interrupt */
|
|
|
|
u32 temp = xgpio_readreg(chip->regs + XGPIO_IPIER_OFFSET);
|
|
|
|
|
|
|
|
temp &= ~BIT(index);
|
|
|
|
xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, temp);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&chip->gpio_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xgpio_irq_unmask - Write the specified signal of the GPIO device.
|
|
|
|
* @irq_data: per IRQ and chip data passed down to chip functions
|
|
|
|
*/
|
|
|
|
static void xgpio_irq_unmask(struct irq_data *irq_data)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct xgpio_instance *chip = irq_data_get_irq_chip_data(irq_data);
|
|
|
|
int irq_offset = irqd_to_hwirq(irq_data);
|
|
|
|
int index = xgpio_index(chip, irq_offset);
|
|
|
|
int offset = xgpio_offset(chip, irq_offset);
|
|
|
|
u32 old_enable = chip->irq_enable[index];
|
|
|
|
|
|
|
|
spin_lock_irqsave(&chip->gpio_lock, flags);
|
|
|
|
|
|
|
|
chip->irq_enable[index] |= BIT(offset);
|
|
|
|
|
|
|
|
if (!old_enable) {
|
|
|
|
/* Clear any existing per-channel interrupts */
|
|
|
|
u32 val = xgpio_readreg(chip->regs + XGPIO_IPISR_OFFSET) &
|
|
|
|
BIT(index);
|
|
|
|
|
|
|
|
if (val)
|
|
|
|
xgpio_writereg(chip->regs + XGPIO_IPISR_OFFSET, val);
|
|
|
|
|
|
|
|
/* Update GPIO IRQ read data before enabling interrupt*/
|
|
|
|
val = xgpio_readreg(chip->regs + XGPIO_DATA_OFFSET +
|
|
|
|
index * XGPIO_CHANNEL_OFFSET);
|
|
|
|
chip->gpio_last_irq_read[index] = val;
|
|
|
|
|
|
|
|
/* Enable per channel interrupt */
|
|
|
|
val = xgpio_readreg(chip->regs + XGPIO_IPIER_OFFSET);
|
|
|
|
val |= BIT(index);
|
|
|
|
xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&chip->gpio_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xgpio_set_irq_type - Write the specified signal of the GPIO device.
|
|
|
|
* @irq_data: Per IRQ and chip data passed down to chip functions
|
|
|
|
* @type: Interrupt type that is to be set for the gpio pin
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* 0 if interrupt type is supported otherwise -EINVAL
|
|
|
|
*/
|
|
|
|
static int xgpio_set_irq_type(struct irq_data *irq_data, unsigned int type)
|
|
|
|
{
|
|
|
|
struct xgpio_instance *chip = irq_data_get_irq_chip_data(irq_data);
|
|
|
|
int irq_offset = irqd_to_hwirq(irq_data);
|
|
|
|
int index = xgpio_index(chip, irq_offset);
|
|
|
|
int offset = xgpio_offset(chip, irq_offset);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The Xilinx GPIO hardware provides a single interrupt status
|
|
|
|
* indication for any state change in a given GPIO channel (bank).
|
|
|
|
* Therefore, only rising edge or falling edge triggers are
|
|
|
|
* supported.
|
|
|
|
*/
|
|
|
|
switch (type & IRQ_TYPE_SENSE_MASK) {
|
|
|
|
case IRQ_TYPE_EDGE_BOTH:
|
|
|
|
chip->irq_rising_edge[index] |= BIT(offset);
|
|
|
|
chip->irq_falling_edge[index] |= BIT(offset);
|
|
|
|
break;
|
|
|
|
case IRQ_TYPE_EDGE_RISING:
|
|
|
|
chip->irq_rising_edge[index] |= BIT(offset);
|
|
|
|
chip->irq_falling_edge[index] &= ~BIT(offset);
|
|
|
|
break;
|
|
|
|
case IRQ_TYPE_EDGE_FALLING:
|
|
|
|
chip->irq_rising_edge[index] &= ~BIT(offset);
|
|
|
|
chip->irq_falling_edge[index] |= BIT(offset);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
irq_set_handler_locked(irq_data, handle_edge_irq);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xgpio_irqhandler - Gpio interrupt service routine
|
|
|
|
* @desc: Pointer to interrupt description
|
|
|
|
*/
|
|
|
|
static void xgpio_irqhandler(struct irq_desc *desc)
|
|
|
|
{
|
|
|
|
struct xgpio_instance *chip = irq_desc_get_handler_data(desc);
|
|
|
|
struct irq_chip *irqchip = irq_desc_get_chip(desc);
|
|
|
|
u32 num_channels = chip->gpio_width[1] ? 2 : 1;
|
|
|
|
u32 offset = 0, index;
|
|
|
|
u32 status = xgpio_readreg(chip->regs + XGPIO_IPISR_OFFSET);
|
|
|
|
|
|
|
|
xgpio_writereg(chip->regs + XGPIO_IPISR_OFFSET, status);
|
|
|
|
|
|
|
|
chained_irq_enter(irqchip, desc);
|
|
|
|
for (index = 0; index < num_channels; index++) {
|
|
|
|
if ((status & BIT(index))) {
|
|
|
|
unsigned long rising_events, falling_events, all_events;
|
|
|
|
unsigned long flags;
|
|
|
|
u32 data, bit;
|
|
|
|
unsigned int irq;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&chip->gpio_lock, flags);
|
|
|
|
data = xgpio_readreg(chip->regs + XGPIO_DATA_OFFSET +
|
|
|
|
index * XGPIO_CHANNEL_OFFSET);
|
|
|
|
rising_events = data &
|
|
|
|
~chip->gpio_last_irq_read[index] &
|
|
|
|
chip->irq_enable[index] &
|
|
|
|
chip->irq_rising_edge[index];
|
|
|
|
falling_events = ~data &
|
|
|
|
chip->gpio_last_irq_read[index] &
|
|
|
|
chip->irq_enable[index] &
|
|
|
|
chip->irq_falling_edge[index];
|
|
|
|
dev_dbg(chip->gc.parent,
|
|
|
|
"IRQ chan %u rising 0x%lx falling 0x%lx\n",
|
|
|
|
index, rising_events, falling_events);
|
|
|
|
all_events = rising_events | falling_events;
|
|
|
|
chip->gpio_last_irq_read[index] = data;
|
|
|
|
spin_unlock_irqrestore(&chip->gpio_lock, flags);
|
|
|
|
|
|
|
|
for_each_set_bit(bit, &all_events, 32) {
|
|
|
|
irq = irq_find_mapping(chip->gc.irq.domain,
|
|
|
|
offset + bit);
|
|
|
|
generic_handle_irq(irq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
offset += chip->gpio_width[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
chained_irq_exit(irqchip, desc);
|
|
|
|
}
|
|
|
|
|
2008-11-13 05:25:38 +08:00
|
|
|
/**
|
|
|
|
* xgpio_of_probe - Probe method for the GPIO device.
|
2014-12-17 23:51:09 +08:00
|
|
|
* @pdev: pointer to the platform device
|
2008-11-13 05:25:38 +08:00
|
|
|
*
|
2014-12-17 23:51:11 +08:00
|
|
|
* Return:
|
|
|
|
* It returns 0, if the driver is bound to the GPIO device, or
|
|
|
|
* a negative value if there is an error.
|
2008-11-13 05:25:38 +08:00
|
|
|
*/
|
2014-12-17 23:51:09 +08:00
|
|
|
static int xgpio_probe(struct platform_device *pdev)
|
2008-11-13 05:25:38 +08:00
|
|
|
{
|
|
|
|
struct xgpio_instance *chip;
|
|
|
|
int status = 0;
|
2014-12-17 23:51:09 +08:00
|
|
|
struct device_node *np = pdev->dev.of_node;
|
2021-01-29 22:26:48 +08:00
|
|
|
u32 is_dual = 0;
|
|
|
|
u32 cells = 2;
|
|
|
|
struct gpio_irq_chip *girq;
|
|
|
|
u32 temp;
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2014-12-17 23:51:12 +08:00
|
|
|
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
|
|
|
|
if (!chip)
|
2008-11-13 05:25:38 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2014-12-17 23:51:12 +08:00
|
|
|
platform_set_drvdata(pdev, chip);
|
2014-12-17 23:51:09 +08:00
|
|
|
|
2008-11-13 05:25:38 +08:00
|
|
|
/* Update GPIO state shadow register with default value */
|
2020-11-13 01:12:27 +08:00
|
|
|
if (of_property_read_u32(np, "xlnx,dout-default", &chip->gpio_state[0]))
|
|
|
|
chip->gpio_state[0] = 0x0;
|
2008-11-13 05:25:38 +08:00
|
|
|
|
|
|
|
/* Update GPIO direction shadow register with default value */
|
2014-12-17 23:51:12 +08:00
|
|
|
if (of_property_read_u32(np, "xlnx,tri-default", &chip->gpio_dir[0]))
|
|
|
|
chip->gpio_dir[0] = 0xFFFFFFFF;
|
2013-06-03 20:31:16 +08:00
|
|
|
|
2021-01-29 22:26:48 +08:00
|
|
|
/* Update cells with gpio-cells value */
|
|
|
|
if (of_property_read_u32(np, "#gpio-cells", &cells))
|
|
|
|
dev_dbg(&pdev->dev, "Missing gpio-cells property\n");
|
|
|
|
|
|
|
|
if (cells != 2) {
|
|
|
|
dev_err(&pdev->dev, "#gpio-cells mismatch\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-09-24 06:58:45 +08:00
|
|
|
/*
|
|
|
|
* Check device node and parent device node for device width
|
|
|
|
* and assume default width of 32
|
|
|
|
*/
|
2014-12-17 23:51:12 +08:00
|
|
|
if (of_property_read_u32(np, "xlnx,gpio-width", &chip->gpio_width[0]))
|
|
|
|
chip->gpio_width[0] = 32;
|
|
|
|
|
2021-01-29 22:26:47 +08:00
|
|
|
spin_lock_init(&chip->gpio_lock);
|
2014-12-17 23:51:12 +08:00
|
|
|
|
|
|
|
if (of_property_read_u32(np, "xlnx,is-dual", &is_dual))
|
|
|
|
is_dual = 0;
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2014-12-17 23:51:12 +08:00
|
|
|
if (is_dual) {
|
|
|
|
/* Update GPIO state shadow register with default value */
|
2020-11-13 01:12:27 +08:00
|
|
|
if (of_property_read_u32(np, "xlnx,dout-default-2",
|
|
|
|
&chip->gpio_state[1]))
|
|
|
|
chip->gpio_state[1] = 0x0;
|
2014-12-17 23:51:12 +08:00
|
|
|
|
|
|
|
/* Update GPIO direction shadow register with default value */
|
|
|
|
if (of_property_read_u32(np, "xlnx,tri-default-2",
|
|
|
|
&chip->gpio_dir[1]))
|
|
|
|
chip->gpio_dir[1] = 0xFFFFFFFF;
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2014-12-17 23:51:12 +08:00
|
|
|
/*
|
|
|
|
* Check device node and parent device node for device width
|
|
|
|
* and assume default width of 32
|
|
|
|
*/
|
|
|
|
if (of_property_read_u32(np, "xlnx,gpio2-width",
|
|
|
|
&chip->gpio_width[1]))
|
|
|
|
chip->gpio_width[1] = 32;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-06-08 01:04:16 +08:00
|
|
|
chip->gc.base = -1;
|
|
|
|
chip->gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1];
|
|
|
|
chip->gc.parent = &pdev->dev;
|
|
|
|
chip->gc.direction_input = xgpio_dir_in;
|
|
|
|
chip->gc.direction_output = xgpio_dir_out;
|
2021-01-29 22:26:48 +08:00
|
|
|
chip->gc.of_gpio_n_cells = cells;
|
2019-06-08 01:04:16 +08:00
|
|
|
chip->gc.get = xgpio_get;
|
|
|
|
chip->gc.set = xgpio_set;
|
2021-01-29 22:26:49 +08:00
|
|
|
chip->gc.request = xgpio_request;
|
|
|
|
chip->gc.free = xgpio_free;
|
2019-06-08 01:04:16 +08:00
|
|
|
chip->gc.set_multiple = xgpio_set_multiple;
|
|
|
|
|
|
|
|
chip->gc.label = dev_name(&pdev->dev);
|
|
|
|
|
|
|
|
chip->regs = devm_platform_ioremap_resource(pdev, 0);
|
|
|
|
if (IS_ERR(chip->regs)) {
|
|
|
|
dev_err(&pdev->dev, "failed to ioremap memory resource\n");
|
|
|
|
return PTR_ERR(chip->regs);
|
|
|
|
}
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2020-11-13 01:12:22 +08:00
|
|
|
chip->clk = devm_clk_get_optional(&pdev->dev, NULL);
|
2021-01-29 22:26:46 +08:00
|
|
|
if (IS_ERR(chip->clk))
|
|
|
|
return dev_err_probe(&pdev->dev, PTR_ERR(chip->clk), "input clock not found.\n");
|
2020-11-13 01:12:22 +08:00
|
|
|
|
|
|
|
status = clk_prepare_enable(chip->clk);
|
|
|
|
if (status < 0) {
|
|
|
|
dev_err(&pdev->dev, "Failed to prepare clk\n");
|
|
|
|
return status;
|
|
|
|
}
|
2021-01-29 22:26:49 +08:00
|
|
|
pm_runtime_get_noresume(&pdev->dev);
|
|
|
|
pm_runtime_set_active(&pdev->dev);
|
|
|
|
pm_runtime_enable(&pdev->dev);
|
2020-11-13 01:12:22 +08:00
|
|
|
|
2019-06-08 01:04:16 +08:00
|
|
|
xgpio_save_regs(chip);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2021-01-29 22:26:48 +08:00
|
|
|
chip->irq = platform_get_irq_optional(pdev, 0);
|
|
|
|
if (chip->irq <= 0)
|
|
|
|
goto skip_irq;
|
|
|
|
|
|
|
|
chip->irqchip.name = "gpio-xilinx";
|
|
|
|
chip->irqchip.irq_ack = xgpio_irq_ack;
|
|
|
|
chip->irqchip.irq_mask = xgpio_irq_mask;
|
|
|
|
chip->irqchip.irq_unmask = xgpio_irq_unmask;
|
|
|
|
chip->irqchip.irq_set_type = xgpio_set_irq_type;
|
|
|
|
|
|
|
|
/* Disable per-channel interrupts */
|
|
|
|
xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, 0);
|
|
|
|
/* Clear any existing per-channel interrupts */
|
|
|
|
temp = xgpio_readreg(chip->regs + XGPIO_IPISR_OFFSET);
|
|
|
|
xgpio_writereg(chip->regs + XGPIO_IPISR_OFFSET, temp);
|
|
|
|
/* Enable global interrupts */
|
|
|
|
xgpio_writereg(chip->regs + XGPIO_GIER_OFFSET, XGPIO_GIER_IE);
|
|
|
|
|
|
|
|
girq = &chip->gc.irq;
|
|
|
|
girq->chip = &chip->irqchip;
|
|
|
|
girq->parent_handler = xgpio_irqhandler;
|
|
|
|
girq->num_parents = 1;
|
|
|
|
girq->parents = devm_kcalloc(&pdev->dev, 1,
|
|
|
|
sizeof(*girq->parents),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!girq->parents) {
|
|
|
|
status = -ENOMEM;
|
2021-01-29 22:26:49 +08:00
|
|
|
goto err_pm_put;
|
2021-01-29 22:26:48 +08:00
|
|
|
}
|
|
|
|
girq->parents[0] = chip->irq;
|
|
|
|
girq->default_type = IRQ_TYPE_NONE;
|
|
|
|
girq->handler = handle_bad_irq;
|
|
|
|
|
|
|
|
skip_irq:
|
2019-06-08 01:04:16 +08:00
|
|
|
status = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
|
2008-11-13 05:25:38 +08:00
|
|
|
if (status) {
|
2019-06-08 01:04:16 +08:00
|
|
|
dev_err(&pdev->dev, "failed to add GPIO chip\n");
|
2021-01-29 22:26:49 +08:00
|
|
|
goto err_pm_put;
|
2008-11-13 05:25:38 +08:00
|
|
|
}
|
2013-06-03 20:31:17 +08:00
|
|
|
|
2021-01-29 22:26:49 +08:00
|
|
|
pm_runtime_put(&pdev->dev);
|
2008-11-13 05:25:38 +08:00
|
|
|
return 0;
|
2021-01-29 22:26:48 +08:00
|
|
|
|
2021-01-29 22:26:49 +08:00
|
|
|
err_pm_put:
|
|
|
|
pm_runtime_disable(&pdev->dev);
|
|
|
|
pm_runtime_put_noidle(&pdev->dev);
|
2021-01-29 22:26:48 +08:00
|
|
|
clk_disable_unprepare(chip->clk);
|
|
|
|
return status;
|
2008-11-13 05:25:38 +08:00
|
|
|
}
|
|
|
|
|
2014-05-07 17:08:20 +08:00
|
|
|
static const struct of_device_id xgpio_of_match[] = {
|
2008-11-13 05:25:38 +08:00
|
|
|
{ .compatible = "xlnx,xps-gpio-1.00.a", },
|
|
|
|
{ /* end of list */ },
|
|
|
|
};
|
|
|
|
|
2014-12-17 23:51:09 +08:00
|
|
|
MODULE_DEVICE_TABLE(of, xgpio_of_match);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2014-12-17 23:51:09 +08:00
|
|
|
static struct platform_driver xgpio_plat_driver = {
|
|
|
|
.probe = xgpio_probe,
|
2020-11-13 01:12:25 +08:00
|
|
|
.remove = xgpio_remove,
|
2014-12-17 23:51:09 +08:00
|
|
|
.driver = {
|
|
|
|
.name = "gpio-xilinx",
|
|
|
|
.of_match_table = xgpio_of_match,
|
2021-01-29 22:26:49 +08:00
|
|
|
.pm = &xgpio_dev_pm_ops,
|
2014-12-17 23:51:09 +08:00
|
|
|
},
|
|
|
|
};
|
2008-11-13 05:25:38 +08:00
|
|
|
|
2014-12-17 23:51:09 +08:00
|
|
|
static int __init xgpio_init(void)
|
|
|
|
{
|
|
|
|
return platform_driver_register(&xgpio_plat_driver);
|
2008-11-13 05:25:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
subsys_initcall(xgpio_init);
|
2014-12-17 23:51:09 +08:00
|
|
|
|
|
|
|
static void __exit xgpio_exit(void)
|
|
|
|
{
|
|
|
|
platform_driver_unregister(&xgpio_plat_driver);
|
|
|
|
}
|
|
|
|
module_exit(xgpio_exit);
|
2008-11-13 05:25:38 +08:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Xilinx, Inc.");
|
|
|
|
MODULE_DESCRIPTION("Xilinx GPIO driver");
|
|
|
|
MODULE_LICENSE("GPL");
|