0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef LINUX_SSB_EXTIFCORE_H_
0020 #define LINUX_SSB_EXTIFCORE_H_
0021
0022
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
0031
0032
0033
0034
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
0046
0047 #define SSB_EXTIF_CTL 0x0000
0048 #define SSB_EXTIF_CTL_UARTEN (1 << 0)
0049 #define SSB_EXTIF_EXTSTAT 0x0004
0050 #define SSB_EXTIF_EXTSTAT_EMODE (1 << 0)
0051 #define SSB_EXTIF_EXTSTAT_EIRQPIN (1 << 1)
0052 #define SSB_EXTIF_EXTSTAT_GPIOIRQPIN (1 << 2)
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
0085 #define SSB_EXTCFG_EN (1 << 0)
0086 #define SSB_EXTCFG_MODE 0xE
0087 #define SSB_EXTCFG_MODE_SHIFT 1
0088 #define SSB_EXTCFG_MODE_FLASH 0x0
0089 #define SSB_EXTCFG_MODE_SYNC 0x2
0090 #define SSB_EXTCFG_MODE_PCMCIA 0x4
0091 #define SSB_EXTCFG_DS16 (1 << 4)
0092 #define SSB_EXTCFG_BSWAP (1 << 5)
0093 #define SSB_EXTCFG_CLKDIV 0xC0
0094 #define SSB_EXTCFG_CLKDIV_SHIFT 6
0095 #define SSB_EXTCFG_CLKDIV_2 0x0
0096 #define SSB_EXTCFG_CLKDIV_3 0x40
0097 #define SSB_EXTCFG_CLKDIV_4 0x80
0098 #define SSB_EXTCFG_CLKEN (1 << 8)
0099 #define SSB_EXTCFG_STROBE (1 << 9)
0100
0101
0102 #define SSB_PCMCIA_MEMW_0 0x0000003F
0103 #define SSB_PCMCIA_MEMW_1 0x00001F00
0104 #define SSB_PCMCIA_MEMW_1_SHIFT 8
0105 #define SSB_PCMCIA_MEMW_2 0x001F0000
0106 #define SSB_PCMCIA_MEMW_2_SHIFT 16
0107 #define SSB_PCMCIA_MEMW_3 0x1F000000
0108 #define SSB_PCMCIA_MEMW_3_SHIFT 24
0109
0110
0111 #define SSB_PCMCIA_ATTW_0 0x0000003F
0112 #define SSB_PCMCIA_ATTW_1 0x00001F00
0113 #define SSB_PCMCIA_ATTW_1_SHIFT 8
0114 #define SSB_PCMCIA_ATTW_2 0x001F0000
0115 #define SSB_PCMCIA_ATTW_2_SHIFT 16
0116 #define SSB_PCMCIA_ATTW_3 0x1F000000
0117 #define SSB_PCMCIA_ATTW_3_SHIFT 24
0118
0119
0120 #define SSB_PCMCIA_IOW_0 0x0000003F
0121 #define SSB_PCMCIA_IOW_1 0x00001F00
0122 #define SSB_PCMCIA_IOW_1_SHIFT 8
0123 #define SSB_PCMCIA_IOW_2 0x001F0000
0124 #define SSB_PCMCIA_IOW_2_SHIFT 16
0125 #define SSB_PCMCIA_IOW_3 0x1F000000
0126 #define SSB_PCMCIA_IOW_3_SHIFT 24
0127
0128
0129 #define SSB_PROG_WCNT_0 0x0000001F
0130 #define SSB_PROG_WCNT_1 0x00001F00
0131 #define SSB_PROG_WCNT_1_SHIFT 8
0132 #define SSB_PROG_WCNT_2 0x001F0000
0133 #define SSB_PROG_WCNT_2_SHIFT 16
0134 #define SSB_PROG_WCNT_3 0x1F000000
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
0143 #define SSB_FLASH_WCNT_0 0x0000001F
0144 #define SSB_FLASH_WCNT_1 0x00001F00
0145 #define SSB_FLASH_WCNT_1_SHIFT 8
0146 #define SSB_FLASH_WCNT_2 0x001F0000
0147 #define SSB_FLASH_WCNT_2_SHIFT 16
0148 #define SSB_FLASH_WCNT_3 0x1F000000
0149 #define SSB_FLASH_WCNT_3_SHIFT 24
0150
0151
0152 #define SSB_EXTIF_WATCHDOG_CLK 48000000
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
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
0190
0191
0192 #else
0193
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
0256
0257 #endif
0258 #endif