Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Hardware-specific External Interface I/O core definitions
0004  * for the BCM47xx family of SiliconBackplane-based chips.
0005  *
0006  * The External Interface core supports a total of three external chip selects
0007  * supporting external interfaces. One of the external chip selects is
0008  * used for Flash, one is used for PCMCIA, and the other may be
0009  * programmed to support either a synchronous interface or an
0010  * asynchronous interface. The asynchronous interface can be used to
0011  * support external devices such as UARTs and the BCM2019 Bluetooth
0012  * baseband processor.
0013  * The external interface core also contains 2 on-chip 16550 UARTs, clock
0014  * frequency control, a watchdog interrupt timer, and a GPIO interface.
0015  *
0016  * Copyright 2005, Broadcom Corporation
0017  * Copyright 2006, Michael Buesch
0018  */
0019 #ifndef LINUX_SSB_EXTIFCORE_H_
0020 #define LINUX_SSB_EXTIFCORE_H_
0021 
0022 /* external interface address space */
0023 #define SSB_EXTIF_PCMCIA_MEMBASE(x) (x)
0024 #define SSB_EXTIF_PCMCIA_IOBASE(x)  ((x) + 0x100000)
0025 #define SSB_EXTIF_PCMCIA_CFGBASE(x) ((x) + 0x200000)
0026 #define SSB_EXTIF_CFGIF_BASE(x)     ((x) + 0x800000)
0027 #define SSB_EXTIF_FLASH_BASE(x)     ((x) + 0xc00000)
0028 
0029 #define SSB_EXTIF_NR_GPIOOUT        5
0030 /* GPIO NOTE:
0031  * The multiple instances of output and output enable registers
0032  * are present to allow driver software for multiple cores to control
0033  * gpio outputs without needing to share a single register pair.
0034  * Use the following helper macro to get a register offset value.
0035  */
0036 #define SSB_EXTIF_GPIO_OUT(index)   ({      \
0037     BUILD_BUG_ON(index >= SSB_EXTIF_NR_GPIOOUT);    \
0038     SSB_EXTIF_GPIO_OUT_BASE + ((index) * 8);    \
0039                     })
0040 #define SSB_EXTIF_GPIO_OUTEN(index) ({      \
0041     BUILD_BUG_ON(index >= SSB_EXTIF_NR_GPIOOUT);    \
0042     SSB_EXTIF_GPIO_OUTEN_BASE + ((index) * 8);  \
0043                     })
0044 
0045 /** EXTIF core registers **/
0046 
0047 #define SSB_EXTIF_CTL           0x0000
0048 #define  SSB_EXTIF_CTL_UARTEN       (1 << 0) /* UART enable */
0049 #define SSB_EXTIF_EXTSTAT       0x0004
0050 #define  SSB_EXTIF_EXTSTAT_EMODE    (1 << 0) /* Endian mode (ro) */
0051 #define  SSB_EXTIF_EXTSTAT_EIRQPIN  (1 << 1) /* External interrupt pin (ro) */
0052 #define  SSB_EXTIF_EXTSTAT_GPIOIRQPIN   (1 << 2) /* GPIO interrupt pin (ro) */
0053 #define SSB_EXTIF_PCMCIA_CFG        0x0010
0054 #define SSB_EXTIF_PCMCIA_MEMWAIT    0x0014
0055 #define SSB_EXTIF_PCMCIA_ATTRWAIT   0x0018
0056 #define SSB_EXTIF_PCMCIA_IOWAIT     0x001C
0057 #define SSB_EXTIF_PROG_CFG      0x0020
0058 #define SSB_EXTIF_PROG_WAITCNT      0x0024
0059 #define SSB_EXTIF_FLASH_CFG     0x0028
0060 #define SSB_EXTIF_FLASH_WAITCNT     0x002C
0061 #define SSB_EXTIF_WATCHDOG      0x0040
0062 #define SSB_EXTIF_CLOCK_N       0x0044
0063 #define SSB_EXTIF_CLOCK_SB      0x0048
0064 #define SSB_EXTIF_CLOCK_PCI     0x004C
0065 #define SSB_EXTIF_CLOCK_MII     0x0050
0066 #define SSB_EXTIF_GPIO_IN       0x0060
0067 #define SSB_EXTIF_GPIO_OUT_BASE     0x0064
0068 #define SSB_EXTIF_GPIO_OUTEN_BASE   0x0068
0069 #define SSB_EXTIF_EJTAG_OUTEN       0x0090
0070 #define SSB_EXTIF_GPIO_INTPOL       0x0094
0071 #define SSB_EXTIF_GPIO_INTMASK      0x0098
0072 #define SSB_EXTIF_UART_DATA     0x0300
0073 #define SSB_EXTIF_UART_TIMER        0x0310
0074 #define SSB_EXTIF_UART_FCR      0x0320
0075 #define SSB_EXTIF_UART_LCR      0x0330
0076 #define SSB_EXTIF_UART_MCR      0x0340
0077 #define SSB_EXTIF_UART_LSR      0x0350
0078 #define SSB_EXTIF_UART_MSR      0x0360
0079 #define SSB_EXTIF_UART_SCRATCH      0x0370
0080 
0081 
0082 
0083 
0084 /* pcmcia/prog/flash_config */
0085 #define SSB_EXTCFG_EN           (1 << 0)    /* enable */
0086 #define SSB_EXTCFG_MODE         0xE     /* mode */
0087 #define SSB_EXTCFG_MODE_SHIFT       1
0088 #define  SSB_EXTCFG_MODE_FLASH      0x0     /* flash/asynchronous mode */
0089 #define  SSB_EXTCFG_MODE_SYNC       0x2     /* synchronous mode */
0090 #define  SSB_EXTCFG_MODE_PCMCIA     0x4     /* pcmcia mode */
0091 #define SSB_EXTCFG_DS16         (1 << 4)    /* destsize:  0=8bit, 1=16bit */
0092 #define SSB_EXTCFG_BSWAP        (1 << 5)    /* byteswap */
0093 #define SSB_EXTCFG_CLKDIV       0xC0        /* clock divider */
0094 #define SSB_EXTCFG_CLKDIV_SHIFT     6
0095 #define  SSB_EXTCFG_CLKDIV_2        0x0     /* backplane/2 */
0096 #define  SSB_EXTCFG_CLKDIV_3        0x40        /* backplane/3 */
0097 #define  SSB_EXTCFG_CLKDIV_4        0x80        /* backplane/4 */
0098 #define SSB_EXTCFG_CLKEN        (1 << 8)    /* clock enable */
0099 #define SSB_EXTCFG_STROBE       (1 << 9)    /* size/bytestrobe (synch only) */
0100 
0101 /* pcmcia_memwait */
0102 #define SSB_PCMCIA_MEMW_0       0x0000003F  /* waitcount0 */
0103 #define SSB_PCMCIA_MEMW_1       0x00001F00  /* waitcount1 */
0104 #define SSB_PCMCIA_MEMW_1_SHIFT     8
0105 #define SSB_PCMCIA_MEMW_2       0x001F0000  /* waitcount2 */
0106 #define SSB_PCMCIA_MEMW_2_SHIFT     16
0107 #define SSB_PCMCIA_MEMW_3       0x1F000000  /* waitcount3 */
0108 #define SSB_PCMCIA_MEMW_3_SHIFT     24
0109 
0110 /* pcmcia_attrwait */
0111 #define SSB_PCMCIA_ATTW_0       0x0000003F  /* waitcount0 */
0112 #define SSB_PCMCIA_ATTW_1       0x00001F00  /* waitcount1 */
0113 #define SSB_PCMCIA_ATTW_1_SHIFT     8
0114 #define SSB_PCMCIA_ATTW_2       0x001F0000  /* waitcount2 */
0115 #define SSB_PCMCIA_ATTW_2_SHIFT     16
0116 #define SSB_PCMCIA_ATTW_3       0x1F000000  /* waitcount3 */
0117 #define SSB_PCMCIA_ATTW_3_SHIFT     24
0118 
0119 /* pcmcia_iowait */
0120 #define SSB_PCMCIA_IOW_0        0x0000003F  /* waitcount0 */
0121 #define SSB_PCMCIA_IOW_1        0x00001F00  /* waitcount1 */
0122 #define SSB_PCMCIA_IOW_1_SHIFT      8
0123 #define SSB_PCMCIA_IOW_2        0x001F0000  /* waitcount2 */
0124 #define SSB_PCMCIA_IOW_2_SHIFT      16
0125 #define SSB_PCMCIA_IOW_3        0x1F000000  /* waitcount3 */
0126 #define SSB_PCMCIA_IOW_3_SHIFT      24
0127 
0128 /* prog_waitcount */
0129 #define SSB_PROG_WCNT_0         0x0000001F  /* waitcount0 */
0130 #define SSB_PROG_WCNT_1         0x00001F00  /* waitcount1 */
0131 #define SSB_PROG_WCNT_1_SHIFT       8
0132 #define SSB_PROG_WCNT_2         0x001F0000  /* waitcount2 */
0133 #define SSB_PROG_WCNT_2_SHIFT       16
0134 #define SSB_PROG_WCNT_3         0x1F000000  /* waitcount3 */
0135 #define SSB_PROG_WCNT_3_SHIFT       24
0136 
0137 #define SSB_PROG_W0         0x0000000C
0138 #define SSB_PROG_W1         0x00000A00
0139 #define SSB_PROG_W2         0x00020000
0140 #define SSB_PROG_W3         0x01000000
0141 
0142 /* flash_waitcount */
0143 #define SSB_FLASH_WCNT_0        0x0000001F  /* waitcount0 */
0144 #define SSB_FLASH_WCNT_1        0x00001F00  /* waitcount1 */
0145 #define SSB_FLASH_WCNT_1_SHIFT      8
0146 #define SSB_FLASH_WCNT_2        0x001F0000  /* waitcount2 */
0147 #define SSB_FLASH_WCNT_2_SHIFT      16
0148 #define SSB_FLASH_WCNT_3        0x1F000000  /* waitcount3 */
0149 #define SSB_FLASH_WCNT_3_SHIFT      24
0150 
0151 /* watchdog */
0152 #define SSB_EXTIF_WATCHDOG_CLK      48000000    /* Hz */
0153 
0154 #define SSB_EXTIF_WATCHDOG_MAX_TIMER    ((1 << 28) - 1)
0155 #define SSB_EXTIF_WATCHDOG_MAX_TIMER_MS (SSB_EXTIF_WATCHDOG_MAX_TIMER \
0156                      / (SSB_EXTIF_WATCHDOG_CLK / 1000))
0157 
0158 
0159 #ifdef CONFIG_SSB_DRIVER_EXTIF
0160 
0161 struct ssb_extif {
0162     struct ssb_device *dev;
0163     spinlock_t gpio_lock;
0164 };
0165 
0166 static inline bool ssb_extif_available(struct ssb_extif *extif)
0167 {
0168     return (extif->dev != NULL);
0169 }
0170 
0171 extern void ssb_extif_get_clockcontrol(struct ssb_extif *extif,
0172                            u32 *plltype, u32 *n, u32 *m);
0173 
0174 extern void ssb_extif_timing_init(struct ssb_extif *extif,
0175                   unsigned long ns);
0176 
0177 extern u32 ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks);
0178 
0179 /* Extif GPIO pin access */
0180 u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask);
0181 u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask, u32 value);
0182 u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask, u32 value);
0183 u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask, u32 value);
0184 u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask, u32 value);
0185 
0186 #ifdef CONFIG_SSB_SERIAL
0187 extern int ssb_extif_serial_init(struct ssb_extif *extif,
0188                  struct ssb_serial_port *ports);
0189 #endif /* CONFIG_SSB_SERIAL */
0190 
0191 
0192 #else /* CONFIG_SSB_DRIVER_EXTIF */
0193 /* extif disabled */
0194 
0195 struct ssb_extif {
0196 };
0197 
0198 static inline bool ssb_extif_available(struct ssb_extif *extif)
0199 {
0200     return false;
0201 }
0202 
0203 static inline
0204 void ssb_extif_get_clockcontrol(struct ssb_extif *extif,
0205                     u32 *plltype, u32 *n, u32 *m)
0206 {
0207 }
0208 
0209 static inline
0210 void ssb_extif_timing_init(struct ssb_extif *extif, unsigned long ns)
0211 {
0212 }
0213 
0214 static inline
0215 u32 ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks)
0216 {
0217     return 0;
0218 }
0219 
0220 static inline u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask)
0221 {
0222     return 0;
0223 }
0224 
0225 static inline u32 ssb_extif_gpio_out(struct ssb_extif *extif, u32 mask,
0226                      u32 value)
0227 {
0228     return 0;
0229 }
0230 
0231 static inline u32 ssb_extif_gpio_outen(struct ssb_extif *extif, u32 mask,
0232                        u32 value)
0233 {
0234     return 0;
0235 }
0236 
0237 static inline u32 ssb_extif_gpio_polarity(struct ssb_extif *extif, u32 mask,
0238                       u32 value)
0239 {
0240     return 0;
0241 }
0242 
0243 static inline u32 ssb_extif_gpio_intmask(struct ssb_extif *extif, u32 mask,
0244                      u32 value)
0245 {
0246     return 0;
0247 }
0248 
0249 #ifdef CONFIG_SSB_SERIAL
0250 static inline int ssb_extif_serial_init(struct ssb_extif *extif,
0251                     struct ssb_serial_port *ports)
0252 {
0253     return 0;
0254 }
0255 #endif /* CONFIG_SSB_SERIAL */
0256 
0257 #endif /* CONFIG_SSB_DRIVER_EXTIF */
0258 #endif /* LINUX_SSB_EXTIFCORE_H_ */