linux/include/linux/ssb/ssb_driver_extif.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Hardware-specific External Interface I/O core definitions
 * for the BCM47xx family of SiliconBackplane-based chips.
 *
 * The External Interface core supports a total of three external chip selects
 * supporting external interfaces. One of the external chip selects is
 * used for Flash, one is used for PCMCIA, and the other may be
 * programmed to support either a synchronous interface or an
 * asynchronous interface. The asynchronous interface can be used to
 * support external devices such as UARTs and the BCM2019 Bluetooth
 * baseband processor.
 * The external interface core also contains 2 on-chip 16550 UARTs, clock
 * frequency control, a watchdog interrupt timer, and a GPIO interface.
 *
 * Copyright 2005, Broadcom Corporation
 * Copyright 2006, Michael Buesch
 */
#ifndef LINUX_SSB_EXTIFCORE_H_
#define LINUX_SSB_EXTIFCORE_H_

/* external interface address space */
#define SSB_EXTIF_PCMCIA_MEMBASE(x)
#define SSB_EXTIF_PCMCIA_IOBASE(x)
#define SSB_EXTIF_PCMCIA_CFGBASE(x)
#define SSB_EXTIF_CFGIF_BASE(x)
#define SSB_EXTIF_FLASH_BASE(x)

#define SSB_EXTIF_NR_GPIOOUT
/* GPIO NOTE:
 * The multiple instances of output and output enable registers
 * are present to allow driver software for multiple cores to control
 * gpio outputs without needing to share a single register pair.
 * Use the following helper macro to get a register offset value.
 */
#define SSB_EXTIF_GPIO_OUT(index)
#define SSB_EXTIF_GPIO_OUTEN(index)

/** EXTIF core registers **/

#define SSB_EXTIF_CTL
#define SSB_EXTIF_CTL_UARTEN
#define SSB_EXTIF_EXTSTAT
#define SSB_EXTIF_EXTSTAT_EMODE
#define SSB_EXTIF_EXTSTAT_EIRQPIN
#define SSB_EXTIF_EXTSTAT_GPIOIRQPIN
#define SSB_EXTIF_PCMCIA_CFG
#define SSB_EXTIF_PCMCIA_MEMWAIT
#define SSB_EXTIF_PCMCIA_ATTRWAIT
#define SSB_EXTIF_PCMCIA_IOWAIT
#define SSB_EXTIF_PROG_CFG
#define SSB_EXTIF_PROG_WAITCNT
#define SSB_EXTIF_FLASH_CFG
#define SSB_EXTIF_FLASH_WAITCNT
#define SSB_EXTIF_WATCHDOG
#define SSB_EXTIF_CLOCK_N
#define SSB_EXTIF_CLOCK_SB
#define SSB_EXTIF_CLOCK_PCI
#define SSB_EXTIF_CLOCK_MII
#define SSB_EXTIF_GPIO_IN
#define SSB_EXTIF_GPIO_OUT_BASE
#define SSB_EXTIF_GPIO_OUTEN_BASE
#define SSB_EXTIF_EJTAG_OUTEN
#define SSB_EXTIF_GPIO_INTPOL
#define SSB_EXTIF_GPIO_INTMASK
#define SSB_EXTIF_UART_DATA
#define SSB_EXTIF_UART_TIMER
#define SSB_EXTIF_UART_FCR
#define SSB_EXTIF_UART_LCR
#define SSB_EXTIF_UART_MCR
#define SSB_EXTIF_UART_LSR
#define SSB_EXTIF_UART_MSR
#define SSB_EXTIF_UART_SCRATCH




/* pcmcia/prog/flash_config */
#define SSB_EXTCFG_EN
#define SSB_EXTCFG_MODE
#define SSB_EXTCFG_MODE_SHIFT
#define SSB_EXTCFG_MODE_FLASH
#define SSB_EXTCFG_MODE_SYNC
#define SSB_EXTCFG_MODE_PCMCIA
#define SSB_EXTCFG_DS16
#define SSB_EXTCFG_BSWAP
#define SSB_EXTCFG_CLKDIV
#define SSB_EXTCFG_CLKDIV_SHIFT
#define SSB_EXTCFG_CLKDIV_2
#define SSB_EXTCFG_CLKDIV_3
#define SSB_EXTCFG_CLKDIV_4
#define SSB_EXTCFG_CLKEN
#define SSB_EXTCFG_STROBE

/* pcmcia_memwait */
#define SSB_PCMCIA_MEMW_0
#define SSB_PCMCIA_MEMW_1
#define SSB_PCMCIA_MEMW_1_SHIFT
#define SSB_PCMCIA_MEMW_2
#define SSB_PCMCIA_MEMW_2_SHIFT
#define SSB_PCMCIA_MEMW_3
#define SSB_PCMCIA_MEMW_3_SHIFT

/* pcmcia_attrwait */
#define SSB_PCMCIA_ATTW_0
#define SSB_PCMCIA_ATTW_1
#define SSB_PCMCIA_ATTW_1_SHIFT
#define SSB_PCMCIA_ATTW_2
#define SSB_PCMCIA_ATTW_2_SHIFT
#define SSB_PCMCIA_ATTW_3
#define SSB_PCMCIA_ATTW_3_SHIFT

/* pcmcia_iowait */
#define SSB_PCMCIA_IOW_0
#define SSB_PCMCIA_IOW_1
#define SSB_PCMCIA_IOW_1_SHIFT
#define SSB_PCMCIA_IOW_2
#define SSB_PCMCIA_IOW_2_SHIFT
#define SSB_PCMCIA_IOW_3
#define SSB_PCMCIA_IOW_3_SHIFT

/* prog_waitcount */
#define SSB_PROG_WCNT_0
#define SSB_PROG_WCNT_1
#define SSB_PROG_WCNT_1_SHIFT
#define SSB_PROG_WCNT_2
#define SSB_PROG_WCNT_2_SHIFT
#define SSB_PROG_WCNT_3
#define SSB_PROG_WCNT_3_SHIFT

#define SSB_PROG_W0
#define SSB_PROG_W1
#define SSB_PROG_W2
#define SSB_PROG_W3

/* flash_waitcount */
#define SSB_FLASH_WCNT_0
#define SSB_FLASH_WCNT_1
#define SSB_FLASH_WCNT_1_SHIFT
#define SSB_FLASH_WCNT_2
#define SSB_FLASH_WCNT_2_SHIFT
#define SSB_FLASH_WCNT_3
#define SSB_FLASH_WCNT_3_SHIFT

/* watchdog */
#define SSB_EXTIF_WATCHDOG_CLK

#define SSB_EXTIF_WATCHDOG_MAX_TIMER
#define SSB_EXTIF_WATCHDOG_MAX_TIMER_MS


#ifdef CONFIG_SSB_DRIVER_EXTIF

struct ssb_extif {
	struct ssb_device *dev;
	spinlock_t gpio_lock;
};

static inline bool ssb_extif_available(struct ssb_extif *extif)
{
	return (extif->dev != NULL);
}

extern void ssb_extif_get_clockcontrol(struct ssb_extif *extif,
			               u32 *plltype, u32 *n, u32 *m);

extern void ssb_extif_timing_init(struct ssb_extif *extif,
				  unsigned long ns);

extern u32 ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks);

/* Extif GPIO pin access */
u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask);
u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask, u32 value);
u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask, u32 value);
u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask, u32 value);
u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask, u32 value);

#ifdef CONFIG_SSB_SERIAL
extern int ssb_extif_serial_init(struct ssb_extif *extif,
				 struct ssb_serial_port *ports);
#endif /* CONFIG_SSB_SERIAL */


#else /* CONFIG_SSB_DRIVER_EXTIF */
/* extif disabled */

struct ssb_extif {};

static inline bool ssb_extif_available(struct ssb_extif *extif)
{}

static inline
void ssb_extif_get_clockcontrol(struct ssb_extif *extif,
			        u32 *plltype, u32 *n, u32 *m)
{}

static inline
void ssb_extif_timing_init(struct ssb_extif *extif, unsigned long ns)
{}

static inline
u32 ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks)
{}

static inline u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask)
{}

static inline u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask,
				     u32 value)
{}

static inline u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask,
				       u32 value)
{}

static inline u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask,
					  u32 value)
{}

static inline u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask,
					 u32 value)
{}

#ifdef CONFIG_SSB_SERIAL
static inline int ssb_extif_serial_init(struct ssb_extif *extif,
					struct ssb_serial_port *ports)
{
	return 0;
}
#endif /* CONFIG_SSB_SERIAL */

#endif /* CONFIG_SSB_DRIVER_EXTIF */
#endif /* LINUX_SSB_EXTIFCORE_H_ */