Commit aa74c44b authored by Wells Lu's avatar Wells Lu Committed by Linus Walleij

pinctrl: Add driver for Sunplus SP7021

Add driver for Sunplus SP7021 SoC.
Signed-off-by: default avatarWells Lu <wellslutw@gmail.com>
Link: https://lore.kernel.org/r/1642344734-27229-3-git-send-email-wellslutw@gmail.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 340407d2
...@@ -15317,6 +15317,7 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) ...@@ -15317,6 +15317,7 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
S: Maintained S: Maintained
W: https://sunplus.atlassian.net/wiki/spaces/doc/overview W: https://sunplus.atlassian.net/wiki/spaces/doc/overview
F: Documentation/devicetree/bindings/pinctrl/sunplus,* F: Documentation/devicetree/bindings/pinctrl/sunplus,*
F: drivers/pinctrl/sunplus/
F: include/dt-bindings/pinctrl/sppctl*.h F: include/dt-bindings/pinctrl/sppctl*.h
PKTCDVD DRIVER PKTCDVD DRIVER
......
...@@ -527,6 +527,7 @@ source "drivers/pinctrl/samsung/Kconfig" ...@@ -527,6 +527,7 @@ source "drivers/pinctrl/samsung/Kconfig"
source "drivers/pinctrl/spear/Kconfig" source "drivers/pinctrl/spear/Kconfig"
source "drivers/pinctrl/sprd/Kconfig" source "drivers/pinctrl/sprd/Kconfig"
source "drivers/pinctrl/stm32/Kconfig" source "drivers/pinctrl/stm32/Kconfig"
source "drivers/pinctrl/sunplus/Kconfig"
source "drivers/pinctrl/sunxi/Kconfig" source "drivers/pinctrl/sunxi/Kconfig"
source "drivers/pinctrl/tegra/Kconfig" source "drivers/pinctrl/tegra/Kconfig"
source "drivers/pinctrl/ti/Kconfig" source "drivers/pinctrl/ti/Kconfig"
......
...@@ -71,6 +71,7 @@ obj-$(CONFIG_PINCTRL_SAMSUNG) += samsung/ ...@@ -71,6 +71,7 @@ obj-$(CONFIG_PINCTRL_SAMSUNG) += samsung/
obj-$(CONFIG_PINCTRL_SPEAR) += spear/ obj-$(CONFIG_PINCTRL_SPEAR) += spear/
obj-y += sprd/ obj-y += sprd/
obj-$(CONFIG_PINCTRL_STM32) += stm32/ obj-$(CONFIG_PINCTRL_STM32) += stm32/
obj-y += sunplus/
obj-$(CONFIG_PINCTRL_SUNXI) += sunxi/ obj-$(CONFIG_PINCTRL_SUNXI) += sunxi/
obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-$(CONFIG_ARCH_TEGRA) += tegra/
obj-y += ti/ obj-y += ti/
......
# SPDX-License-Identifier: GPL-2.0
#
# Sunplus Pin control driver configuration
#
config PINCTRL_SPPCTL
tristate "Sunplus SP7021 PinMux and GPIO driver"
depends on SOC_SP7021
depends on OF && HAS_IOMEM
select GENERIC_PINCTRL_GROUPS
select GENERIC_PINMUX_FUNCTIONS
select GENERIC_PINCONF
select PINCONF
select PINMUX
select GPIOLIB
select OF_GPIO
help
Say Y here to support Sunplus SP7021 pinmux controller.
This driver requires the pinctrl framework.
GPIO is provided by the same driver.
To compile this driver as a module, choose M here.
The module will be called sppinctrl.
# SPDX-License-Identifier: GPL-2.0
#
# Makefile for the Sunplus Pin control drivers.
#
obj-$(CONFIG_PINCTRL_SPPCTL) += sppinctrl.o
sppinctrl-objs := sppctl.o sppctl_sp7021.o
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/*
* SP7021 Pin Controller Driver.
* Copyright (C) Sunplus Tech / Tibbo Tech.
*/
#ifndef __SPPCTL_H__
#define __SPPCTL_H__
#include <linux/bits.h>
#include <linux/gpio/driver.h>
#include <linux/kernel.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#define SPPCTL_MODULE_NAME "sppctl_sp7021"
#define SPPCTL_GPIO_OFF_FIRST 0x00
#define SPPCTL_GPIO_OFF_MASTER 0x00
#define SPPCTL_GPIO_OFF_OE 0x20
#define SPPCTL_GPIO_OFF_OUT 0x40
#define SPPCTL_GPIO_OFF_IN 0x60
#define SPPCTL_GPIO_OFF_IINV 0x80
#define SPPCTL_GPIO_OFF_OINV 0xa0
#define SPPCTL_GPIO_OFF_OD 0xc0
#define SPPCTL_FULLY_PINMUX_MASK_MASK GENMASK(22, 16)
#define SPPCTL_FULLY_PINMUX_SEL_MASK GENMASK(6, 0)
#define SPPCTL_FULLY_PINMUX_UPPER_SHIFT 8
/*
* Mask-fields and control-fields of MOON registers of SP7021 are
* arranged as shown below:
*
* register | mask-fields | control-fields
* ----------+--------------+----------------
* base[0] | (31 : 16) | (15 : 0)
* base[1] | (31 : 24) | (15 : 0)
* base[2] | (31 : 24) | (15 : 0)
* : | : | :
*
* where mask-fields are used to protect control-fields from write-in
* accidentally. Set the corresponding bits in the mask-field before
* you write a value into a control-field.
*/
#define SPPCTL_MOON_REG_MASK_SHIFT 16
#define SPPCTL_SET_MOON_REG_BIT(bit) (BIT((bit) + SPPCTL_MOON_REG_MASK_SHIFT) | BIT(bit))
#define SPPCTL_CLR_MOON_REG_BIT(bit) BIT((bit) + SPPCTL_MOON_REG_MASK_SHIFT)
#define SPPCTL_IOP_CONFIGS 0xff
#define FNCE(n, r, o, bo, bl, g) { \
.name = n, \
.type = r, \
.roff = o, \
.boff = bo, \
.blen = bl, \
.grps = (g), \
.gnum = ARRAY_SIZE(g), \
}
#define FNCN(n, r, o, bo, bl) { \
.name = n, \
.type = r, \
.roff = o, \
.boff = bo, \
.blen = bl, \
.grps = NULL, \
.gnum = 0, \
}
#define EGRP(n, v, p) { \
.name = n, \
.gval = (v), \
.pins = (p), \
.pnum = ARRAY_SIZE(p), \
}
/**
* enum mux_first_reg - Define modes of access of FIRST register
* @mux_f_mux: Set the corresponding pin to a fully-pinmux pin
* @mux_f_gpio: Set the corresponding pin to a GPIO or IOP pin
* @mux_f_keep: Don't change (keep intact)
*/
enum mux_first_reg {
mux_f_mux = 0,
mux_f_gpio = 1,
mux_f_keep = 2,
};
/**
* enum mux_master_reg - Define modes of access of MASTER register
* @mux_m_iop: Set the corresponding pin to an IO processor (IOP) pin
* @mux_m_gpio: Set the corresponding pin to a digital GPIO pin
* @mux_m_keep: Don't change (keep intact)
*/
enum mux_master_reg {
mux_m_iop = 0,
mux_m_gpio = 1,
mux_m_keep = 2,
};
/**
* enum pinmux_type - Define types of pinmux pins
* @pinmux_type_fpmx: A fully-pinmux pin
* @pinmux_type_grp: A group-pinmux pin
*/
enum pinmux_type {
pinmux_type_fpmx,
pinmux_type_grp,
};
/**
* struct grp2fp_map - A map storing indexes
* @f_idx: an index to function table
* @g_idx: an index to group table
*/
struct grp2fp_map {
u16 f_idx;
u16 g_idx;
};
struct sppctl_gpio_chip;
struct sppctl_pdata {
void __iomem *moon2_base; /* MOON2 */
void __iomem *gpioxt_base; /* MASTER, OE, OUT, IN, I_INV, O_INV, OD */
void __iomem *first_base; /* FIRST */
void __iomem *moon1_base; /* MOON1 */
struct pinctrl_desc pctl_desc;
struct pinctrl_dev *pctl_dev;
struct pinctrl_gpio_range pctl_grange;
struct sppctl_gpio_chip *spp_gchip;
char const **unq_grps;
size_t unq_grps_sz;
struct grp2fp_map *g2fp_maps;
};
struct sppctl_grp {
const char * const name;
const u8 gval; /* group number */
const unsigned * const pins; /* list of pins */
const unsigned int pnum; /* number of pins */
};
struct sppctl_func {
const char * const name;
const enum pinmux_type type; /* function type */
const u8 roff; /* register offset */
const u8 boff; /* bit offset */
const u8 blen; /* bit length */
const struct sppctl_grp * const grps; /* list of groups */
const unsigned int gnum; /* number of groups */
};
extern const struct sppctl_func sppctl_list_funcs[];
extern const char * const sppctl_pmux_list_s[];
extern const char * const sppctl_gpio_list_s[];
extern const struct pinctrl_pin_desc sppctl_pins_all[];
extern const unsigned int sppctl_pins_gpio[];
extern const size_t sppctl_list_funcs_sz;
extern const size_t sppctl_pmux_list_sz;
extern const size_t sppctl_gpio_list_sz;
extern const size_t sppctl_pins_all_sz;
#endif
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment