linux/include/linux/gpio/gpio-nomadik.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __LINUX_GPIO_NOMADIK_H
#define __LINUX_GPIO_NOMADIK_H

struct fwnode_handle;

/* Package definitions */
#define PINCTRL_NMK_STN8815
#define PINCTRL_NMK_DB8500

#define GPIO_BLOCK_SHIFT
#define NMK_GPIO_PER_CHIP
#define NMK_MAX_BANKS

/* Register in the logic block */
#define NMK_GPIO_DAT
#define NMK_GPIO_DATS
#define NMK_GPIO_DATC
#define NMK_GPIO_PDIS
#define NMK_GPIO_DIR
#define NMK_GPIO_DIRS
#define NMK_GPIO_DIRC
#define NMK_GPIO_SLPC
#define NMK_GPIO_AFSLA
#define NMK_GPIO_AFSLB
#define NMK_GPIO_LOWEMI

#define NMK_GPIO_RIMSC
#define NMK_GPIO_FIMSC
#define NMK_GPIO_IS
#define NMK_GPIO_IC
#define NMK_GPIO_RWIMSC
#define NMK_GPIO_FWIMSC
#define NMK_GPIO_WKS
/* These appear in DB8540 and later ASICs */
#define NMK_GPIO_EDGELEVEL
#define NMK_GPIO_LEVEL

/* Pull up/down values */
enum nmk_gpio_pull {};

/* Sleep mode */
enum nmk_gpio_slpm {};

struct nmk_gpio_chip {};

/* Alternate functions: function C is set in hw by setting both A and B */
#define NMK_GPIO_ALT_GPIO
#define NMK_GPIO_ALT_A
#define NMK_GPIO_ALT_B
#define NMK_GPIO_ALT_C

#define NMK_GPIO_ALT_CX_SHIFT
#define NMK_GPIO_ALT_C1
#define NMK_GPIO_ALT_C2
#define NMK_GPIO_ALT_C3
#define NMK_GPIO_ALT_C4

#define PRCM_GPIOCR_ALTCX(pin_num,\
	altc1_used, altc1_ri, altc1_cb,\
	altc2_used, altc2_ri, altc2_cb,\
	altc3_used, altc3_ri, altc3_cb,\
	altc4_used, altc4_ri, altc4_cb)

/**
 * enum prcm_gpiocr_reg_index
 * Used to reference an PRCM GPIOCR register address.
 */
enum prcm_gpiocr_reg_index {};
/**
 * enum prcm_gpiocr_altcx_index
 * Used to reference an Other alternate-C function.
 */
enum prcm_gpiocr_altcx_index {};

/**
 * struct prcm_gpio_altcx - Other alternate-C function
 * @used: other alternate-C function availability
 * @reg_index: PRCM GPIOCR register index used to control the function
 * @control_bit: PRCM GPIOCR bit used to control the function
 */
struct prcm_gpiocr_altcx {} __packed;

/**
 * struct prcm_gpio_altcx_pin_desc - Other alternate-C pin
 * @pin: The pin number
 * @altcx: array of other alternate-C[1-4] functions
 */
struct prcm_gpiocr_altcx_pin_desc {};

/**
 * struct nmk_function - Nomadik pinctrl mux function
 * @name: The name of the function, exported to pinctrl core.
 * @groups: An array of pin groups that may select this function.
 * @ngroups: The number of entries in @groups.
 */
struct nmk_function {};

/**
 * struct nmk_pingroup - describes a Nomadik pin group
 * @grp: Generic data of the pin group (name and pins)
 * @altsetting: the altsetting to apply to all pins in this group to
 *	configure them to be used by a function
 */
struct nmk_pingroup {};

#define NMK_PIN_GROUP(a, b)

/**
 * struct nmk_pinctrl_soc_data - Nomadik pin controller per-SoC configuration
 * @pins:	An array describing all pins the pin controller affects.
 *		All pins which are also GPIOs must be listed first within the
 *		array, and be numbered identically to the GPIO controller's
 *		numbering.
 * @npins:	The number of entries in @pins.
 * @functions:	The functions supported on this SoC.
 * @nfunction:	The number of entries in @functions.
 * @groups:	An array describing all pin groups the pin SoC supports.
 * @ngroups:	The number of entries in @groups.
 * @altcx_pins:	The pins that support Other alternate-C function on this SoC
 * @npins_altcx: The number of Other alternate-C pins
 * @prcm_gpiocr_registers: The array of PRCM GPIOCR registers on this SoC
 */
struct nmk_pinctrl_soc_data {};

#ifdef CONFIG_PINCTRL_STN8815

void nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc);

#else

static inline void
nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc)
{}

#endif

#ifdef CONFIG_PINCTRL_DB8500

void nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc);

#else

static inline void
nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc)
{}

#endif

#ifdef CONFIG_PINCTRL_DB8540

void nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc);

#else

static inline void
nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc)
{}

#endif

struct platform_device;

#ifdef CONFIG_DEBUG_FS

/*
 * Symbols declared in gpio-nomadik used by pinctrl-nomadik. If pinctrl-nomadik
 * is enabled, then gpio-nomadik is enabled as well; the reverse if not always
 * true.
 */
void nmk_gpio_dbg_show_one(struct seq_file *s, struct pinctrl_dev *pctldev,
			   struct gpio_chip *chip, unsigned int offset,
			   unsigned int gpio);

#else

static inline void nmk_gpio_dbg_show_one(struct seq_file *s,
					 struct pinctrl_dev *pctldev,
					 struct gpio_chip *chip,
					 unsigned int offset,
					 unsigned int gpio)
{
}

#endif

void __nmk_gpio_make_output(struct nmk_gpio_chip *nmk_chip,
			    unsigned int offset, int val);
void __nmk_gpio_set_slpm(struct nmk_gpio_chip *nmk_chip, unsigned int offset,
			 enum nmk_gpio_slpm mode);
struct nmk_gpio_chip *nmk_gpio_populate_chip(struct fwnode_handle *fwnode,
					     struct platform_device *pdev);

/* Symbols declared in pinctrl-nomadik used by gpio-nomadik. */
#ifdef CONFIG_PINCTRL_NOMADIK
extern struct nmk_gpio_chip *nmk_gpio_chips[NMK_MAX_BANKS];
extern spinlock_t nmk_gpio_slpm_lock;
int __maybe_unused nmk_prcm_gpiocr_get_mode(struct pinctrl_dev *pctldev,
					    int gpio);
#endif

#endif /* __LINUX_GPIO_NOMADIK_H */