0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #ifndef _LINUX_RICOH_H
0031 #define _LINUX_RICOH_H
0032
0033
0034 #define RF5C_MODE_CTL 0x1f
0035 #define RF5C_PWR_CTL 0x2f
0036 #define RF5C_CHIP_ID 0x3a
0037 #define RF5C_MODE_CTL_3 0x3b
0038
0039
0040 #define RF5C_IO_OFF(w) (0x36+((w)<<1))
0041
0042
0043 #define RF5C_MODE_ATA 0x01
0044 #define RF5C_MODE_LED_ENA 0x02
0045 #define RF5C_MODE_CA21 0x04
0046 #define RF5C_MODE_CA22 0x08
0047 #define RF5C_MODE_CA23 0x10
0048 #define RF5C_MODE_CA24 0x20
0049 #define RF5C_MODE_CA25 0x40
0050 #define RF5C_MODE_3STATE_BIT7 0x80
0051
0052
0053 #define RF5C_PWR_VCC_3V 0x01
0054 #define RF5C_PWR_IREQ_HIGH 0x02
0055 #define RF5C_PWR_INPACK_ENA 0x04
0056 #define RF5C_PWR_5V_DET 0x08
0057 #define RF5C_PWR_TC_SEL 0x10
0058 #define RF5C_PWR_DREQ_LOW 0x20
0059 #define RF5C_PWR_DREQ_OFF 0x00
0060 #define RF5C_PWR_DREQ_INPACK 0x40
0061 #define RF5C_PWR_DREQ_SPKR 0x80
0062 #define RF5C_PWR_DREQ_IOIS16 0xc0
0063
0064
0065 #define RF5C_CHIP_RF5C296 0x32
0066 #define RF5C_CHIP_RF5C396 0xb2
0067
0068
0069 #define RF5C_MCTL3_DISABLE 0x01
0070 #define RF5C_MCTL3_DMA_ENA 0x02
0071
0072
0073
0074
0075 #define RL5C46X_BCR_3E0_ENA 0x0800
0076 #define RL5C46X_BCR_3E2_ENA 0x1000
0077
0078
0079 #define RL5C4XX_CONFIG 0x80
0080 #define RL5C4XX_CONFIG_IO_1_MODE 0x0200
0081 #define RL5C4XX_CONFIG_IO_0_MODE 0x0100
0082 #define RL5C4XX_CONFIG_PREFETCH 0x0001
0083
0084
0085 #define RL5C4XX_MISC 0x0082
0086 #define RL5C4XX_MISC_HW_SUSPEND_ENA 0x0002
0087 #define RL5C4XX_MISC_VCCEN_POL 0x0100
0088 #define RL5C4XX_MISC_VPPEN_POL 0x0200
0089 #define RL5C46X_MISC_SUSPEND 0x0001
0090 #define RL5C46X_MISC_PWR_SAVE_2 0x0004
0091 #define RL5C46X_MISC_IFACE_BUSY 0x0008
0092 #define RL5C46X_MISC_B_LOCK 0x0010
0093 #define RL5C46X_MISC_A_LOCK 0x0020
0094 #define RL5C46X_MISC_PCI_LOCK 0x0040
0095 #define RL5C47X_MISC_IFACE_BUSY 0x0004
0096 #define RL5C47X_MISC_PCI_INT_MASK 0x0018
0097 #define RL5C47X_MISC_PCI_INT_DIS 0x0020
0098 #define RL5C47X_MISC_SUBSYS_WR 0x0040
0099 #define RL5C47X_MISC_SRIRQ_ENA 0x0080
0100 #define RL5C47X_MISC_5V_DISABLE 0x0400
0101 #define RL5C47X_MISC_LED_POL 0x0800
0102
0103
0104 #define RL5C4XX_16BIT_CTL 0x0084
0105 #define RL5C4XX_16CTL_IO_TIMING 0x0100
0106 #define RL5C4XX_16CTL_MEM_TIMING 0x0200
0107 #define RL5C46X_16CTL_LEVEL_1 0x0010
0108 #define RL5C46X_16CTL_LEVEL_2 0x0020
0109
0110
0111 #define RL5C4XX_16BIT_IO_0 0x0088
0112 #define RL5C4XX_16BIT_MEM_0 0x008a
0113 #define RL5C4XX_SETUP_MASK 0x0007
0114 #define RL5C4XX_SETUP_SHIFT 0
0115 #define RL5C4XX_CMD_MASK 0x01f0
0116 #define RL5C4XX_CMD_SHIFT 4
0117 #define RL5C4XX_HOLD_MASK 0x1c00
0118 #define RL5C4XX_HOLD_SHIFT 10
0119 #define RL5C4XX_MISC_CONTROL 0x2F
0120 #define RL5C4XX_ZV_ENABLE 0x08
0121
0122
0123 #define RL5C4XX_MISC3 0x00A2
0124 #define RL5C47X_MISC3_CB_CLKRUN_DIS BIT(1)
0125
0126 #ifdef __YENTA_H
0127
0128 #define rl_misc(socket) ((socket)->private[0])
0129 #define rl_ctl(socket) ((socket)->private[1])
0130 #define rl_io(socket) ((socket)->private[2])
0131 #define rl_mem(socket) ((socket)->private[3])
0132 #define rl_config(socket) ((socket)->private[4])
0133
0134 static void ricoh_zoom_video(struct pcmcia_socket *sock, int onoff)
0135 {
0136 u8 reg;
0137 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
0138
0139 reg = config_readb(socket, RL5C4XX_MISC_CONTROL);
0140 if (onoff)
0141
0142 reg |= RL5C4XX_ZV_ENABLE;
0143 else
0144 reg &= ~RL5C4XX_ZV_ENABLE;
0145
0146 config_writeb(socket, RL5C4XX_MISC_CONTROL, reg);
0147 }
0148
0149 static void ricoh_set_zv(struct yenta_socket *socket)
0150 {
0151 if(socket->dev->vendor == PCI_VENDOR_ID_RICOH)
0152 {
0153 switch(socket->dev->device)
0154 {
0155
0156 case PCI_DEVICE_ID_RICOH_RL5C478:
0157 socket->socket.zoom_video = ricoh_zoom_video;
0158 break;
0159 }
0160 }
0161 }
0162
0163 static void ricoh_set_clkrun(struct yenta_socket *socket, bool quiet)
0164 {
0165 u16 misc3;
0166
0167
0168
0169
0170
0171 if (socket->dev->device != PCI_DEVICE_ID_RICOH_RL5C476 &&
0172 socket->dev->device != PCI_DEVICE_ID_RICOH_RL5C478)
0173 return;
0174
0175 if (socket->dev->revision < 0x80)
0176 return;
0177
0178 misc3 = config_readw(socket, RL5C4XX_MISC3);
0179 if (misc3 & RL5C47X_MISC3_CB_CLKRUN_DIS) {
0180 if (!quiet)
0181 dev_dbg(&socket->dev->dev,
0182 "CLKRUN feature already disabled\n");
0183 } else if (disable_clkrun) {
0184 if (!quiet)
0185 dev_info(&socket->dev->dev,
0186 "Disabling CLKRUN feature\n");
0187 misc3 |= RL5C47X_MISC3_CB_CLKRUN_DIS;
0188 config_writew(socket, RL5C4XX_MISC3, misc3);
0189 }
0190 }
0191
0192 static void ricoh_save_state(struct yenta_socket *socket)
0193 {
0194 rl_misc(socket) = config_readw(socket, RL5C4XX_MISC);
0195 rl_ctl(socket) = config_readw(socket, RL5C4XX_16BIT_CTL);
0196 rl_io(socket) = config_readw(socket, RL5C4XX_16BIT_IO_0);
0197 rl_mem(socket) = config_readw(socket, RL5C4XX_16BIT_MEM_0);
0198 rl_config(socket) = config_readw(socket, RL5C4XX_CONFIG);
0199 }
0200
0201 static void ricoh_restore_state(struct yenta_socket *socket)
0202 {
0203 config_writew(socket, RL5C4XX_MISC, rl_misc(socket));
0204 config_writew(socket, RL5C4XX_16BIT_CTL, rl_ctl(socket));
0205 config_writew(socket, RL5C4XX_16BIT_IO_0, rl_io(socket));
0206 config_writew(socket, RL5C4XX_16BIT_MEM_0, rl_mem(socket));
0207 config_writew(socket, RL5C4XX_CONFIG, rl_config(socket));
0208 ricoh_set_clkrun(socket, true);
0209 }
0210
0211
0212
0213
0214
0215 static int ricoh_override(struct yenta_socket *socket)
0216 {
0217 u16 config, ctl;
0218
0219 config = config_readw(socket, RL5C4XX_CONFIG);
0220
0221
0222 ctl = RL5C4XX_16CTL_IO_TIMING | RL5C4XX_16CTL_MEM_TIMING;
0223
0224 if(socket->dev->device < PCI_DEVICE_ID_RICOH_RL5C475) {
0225 ctl |= RL5C46X_16CTL_LEVEL_1 | RL5C46X_16CTL_LEVEL_2;
0226 } else {
0227 config |= RL5C4XX_CONFIG_PREFETCH;
0228 }
0229
0230 config_writew(socket, RL5C4XX_16BIT_CTL, ctl);
0231 config_writew(socket, RL5C4XX_CONFIG, config);
0232
0233 ricoh_set_zv(socket);
0234 ricoh_set_clkrun(socket, false);
0235
0236 return 0;
0237 }
0238
0239 #endif
0240
0241 #endif