1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * topic.h 1.8 1999/08/28 04:01:47
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * The contents of this file are subject to the Mozilla Public License
5*4882a593Smuzhiyun * Version 1.1 (the "License"); you may not use this file except in
6*4882a593Smuzhiyun * compliance with the License. You may obtain a copy of the License
7*4882a593Smuzhiyun * at http://www.mozilla.org/MPL/
8*4882a593Smuzhiyun *
9*4882a593Smuzhiyun * Software distributed under the License is distributed on an "AS IS"
10*4882a593Smuzhiyun * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11*4882a593Smuzhiyun * the License for the specific language governing rights and
12*4882a593Smuzhiyun * limitations under the License.
13*4882a593Smuzhiyun *
14*4882a593Smuzhiyun * The initial developer of the original code is David A. Hinds
15*4882a593Smuzhiyun * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
16*4882a593Smuzhiyun * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
17*4882a593Smuzhiyun *
18*4882a593Smuzhiyun * Alternatively, the contents of this file may be used under the
19*4882a593Smuzhiyun * terms of the GNU General Public License version 2 (the "GPL"), in which
20*4882a593Smuzhiyun * case the provisions of the GPL are applicable instead of the
21*4882a593Smuzhiyun * above. If you wish to allow the use of your version of this file
22*4882a593Smuzhiyun * only under the terms of the GPL and not to allow others to use
23*4882a593Smuzhiyun * your version of this file under the MPL, indicate your decision by
24*4882a593Smuzhiyun * deleting the provisions above and replace them with the notice and
25*4882a593Smuzhiyun * other provisions required by the GPL. If you do not delete the
26*4882a593Smuzhiyun * provisions above, a recipient may use your version of this file
27*4882a593Smuzhiyun * under either the MPL or the GPL.
28*4882a593Smuzhiyun * topic.h $Release$ 1999/08/28 04:01:47
29*4882a593Smuzhiyun */
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun #ifndef _LINUX_TOPIC_H
32*4882a593Smuzhiyun #define _LINUX_TOPIC_H
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun /* Register definitions for Toshiba ToPIC95/97/100 controllers */
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun #define TOPIC_SOCKET_CONTROL 0x0090 /* 32 bit */
37*4882a593Smuzhiyun #define TOPIC_SCR_IRQSEL 0x00000001
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun #define TOPIC_SLOT_CONTROL 0x00a0 /* 8 bit */
40*4882a593Smuzhiyun #define TOPIC_SLOT_SLOTON 0x80
41*4882a593Smuzhiyun #define TOPIC_SLOT_SLOTEN 0x40
42*4882a593Smuzhiyun #define TOPIC_SLOT_ID_LOCK 0x20
43*4882a593Smuzhiyun #define TOPIC_SLOT_ID_WP 0x10
44*4882a593Smuzhiyun #define TOPIC_SLOT_PORT_MASK 0x0c
45*4882a593Smuzhiyun #define TOPIC_SLOT_PORT_SHIFT 2
46*4882a593Smuzhiyun #define TOPIC_SLOT_OFS_MASK 0x03
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun #define TOPIC_CARD_CONTROL 0x00a1 /* 8 bit */
49*4882a593Smuzhiyun #define TOPIC_CCR_INTB 0x20
50*4882a593Smuzhiyun #define TOPIC_CCR_INTA 0x10
51*4882a593Smuzhiyun #define TOPIC_CCR_CLOCK 0x0c
52*4882a593Smuzhiyun #define TOPIC_CCR_PCICLK 0x0c
53*4882a593Smuzhiyun #define TOPIC_CCR_PCICLK_2 0x08
54*4882a593Smuzhiyun #define TOPIC_CCR_CCLK 0x04
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun #define TOPIC97_INT_CONTROL 0x00a1 /* 8 bit */
57*4882a593Smuzhiyun #define TOPIC97_ICR_INTB 0x20
58*4882a593Smuzhiyun #define TOPIC97_ICR_INTA 0x10
59*4882a593Smuzhiyun #define TOPIC97_ICR_STSIRQNP 0x04
60*4882a593Smuzhiyun #define TOPIC97_ICR_IRQNP 0x02
61*4882a593Smuzhiyun #define TOPIC97_ICR_IRQSEL 0x01
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun #define TOPIC_CARD_DETECT 0x00a3 /* 8 bit */
64*4882a593Smuzhiyun #define TOPIC_CDR_MODE_PC32 0x80
65*4882a593Smuzhiyun #define TOPIC_CDR_VS1 0x04
66*4882a593Smuzhiyun #define TOPIC_CDR_VS2 0x02
67*4882a593Smuzhiyun #define TOPIC_CDR_SW_DETECT 0x01
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun #define TOPIC_REGISTER_CONTROL 0x00a4 /* 32 bit */
70*4882a593Smuzhiyun #define TOPIC_RCR_RESUME_RESET 0x80000000
71*4882a593Smuzhiyun #define TOPIC_RCR_REMOVE_RESET 0x40000000
72*4882a593Smuzhiyun #define TOPIC97_RCR_CLKRUN_ENA 0x20000000
73*4882a593Smuzhiyun #define TOPIC97_RCR_TESTMODE 0x10000000
74*4882a593Smuzhiyun #define TOPIC97_RCR_IOPLUP 0x08000000
75*4882a593Smuzhiyun #define TOPIC_RCR_BUFOFF_PWROFF 0x02000000
76*4882a593Smuzhiyun #define TOPIC_RCR_BUFOFF_SIGOFF 0x01000000
77*4882a593Smuzhiyun #define TOPIC97_RCR_CB_DEV_MASK 0x0000f800
78*4882a593Smuzhiyun #define TOPIC97_RCR_CB_DEV_SHIFT 11
79*4882a593Smuzhiyun #define TOPIC97_RCR_RI_DISABLE 0x00000004
80*4882a593Smuzhiyun #define TOPIC97_RCR_CAUDIO_OFF 0x00000002
81*4882a593Smuzhiyun #define TOPIC_RCR_CAUDIO_INVERT 0x00000001
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun #define TOPIC97_MISC1 0x00ad /* 8bit */
84*4882a593Smuzhiyun #define TOPIC97_MISC1_CLOCKRUN_ENABLE 0x80
85*4882a593Smuzhiyun #define TOPIC97_MISC1_CLOCKRUN_MODE 0x40
86*4882a593Smuzhiyun #define TOPIC97_MISC1_DETECT_REQ_ENA 0x10
87*4882a593Smuzhiyun #define TOPIC97_MISC1_SCK_CLEAR_DIS 0x04
88*4882a593Smuzhiyun #define TOPIC97_MISC1_R2_LOW_ENABLE 0x10
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun #define TOPIC97_MISC2 0x00ae /* 8 bit */
91*4882a593Smuzhiyun #define TOPIC97_MISC2_SPWRCLK_MASK 0x70
92*4882a593Smuzhiyun #define TOPIC97_MISC2_SPWRMOD 0x08
93*4882a593Smuzhiyun #define TOPIC97_MISC2_SPWR_ENABLE 0x04
94*4882a593Smuzhiyun #define TOPIC97_MISC2_ZV_MODE 0x02
95*4882a593Smuzhiyun #define TOPIC97_MISC2_ZV_ENABLE 0x01
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun #define TOPIC97_ZOOM_VIDEO_CONTROL 0x009c /* 8 bit */
98*4882a593Smuzhiyun #define TOPIC97_ZV_CONTROL_ENABLE 0x01
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun #define TOPIC97_AUDIO_VIDEO_SWITCH 0x003c /* 8 bit */
101*4882a593Smuzhiyun #define TOPIC97_AVS_AUDIO_CONTROL 0x02
102*4882a593Smuzhiyun #define TOPIC97_AVS_VIDEO_CONTROL 0x01
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun #define TOPIC_EXCA_IF_CONTROL 0x3e /* 8 bit */
105*4882a593Smuzhiyun #define TOPIC_EXCA_IFC_33V_ENA 0x01
106*4882a593Smuzhiyun
107*4882a593Smuzhiyun #define TOPIC_PCI_CFG_PPBCN 0x3e /* 16-bit */
108*4882a593Smuzhiyun #define TOPIC_PCI_CFG_PPBCN_WBEN 0x0400
109*4882a593Smuzhiyun
topic97_zoom_video(struct pcmcia_socket * sock,int onoff)110*4882a593Smuzhiyun static void topic97_zoom_video(struct pcmcia_socket *sock, int onoff)
111*4882a593Smuzhiyun {
112*4882a593Smuzhiyun struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
113*4882a593Smuzhiyun u8 reg_zv, reg;
114*4882a593Smuzhiyun
115*4882a593Smuzhiyun reg_zv = config_readb(socket, TOPIC97_ZOOM_VIDEO_CONTROL);
116*4882a593Smuzhiyun if (onoff) {
117*4882a593Smuzhiyun reg_zv |= TOPIC97_ZV_CONTROL_ENABLE;
118*4882a593Smuzhiyun config_writeb(socket, TOPIC97_ZOOM_VIDEO_CONTROL, reg_zv);
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun reg = config_readb(socket, TOPIC97_AUDIO_VIDEO_SWITCH);
121*4882a593Smuzhiyun reg |= TOPIC97_AVS_AUDIO_CONTROL | TOPIC97_AVS_VIDEO_CONTROL;
122*4882a593Smuzhiyun config_writeb(socket, TOPIC97_AUDIO_VIDEO_SWITCH, reg);
123*4882a593Smuzhiyun } else {
124*4882a593Smuzhiyun reg_zv &= ~TOPIC97_ZV_CONTROL_ENABLE;
125*4882a593Smuzhiyun config_writeb(socket, TOPIC97_ZOOM_VIDEO_CONTROL, reg_zv);
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun reg = config_readb(socket, TOPIC97_AUDIO_VIDEO_SWITCH);
128*4882a593Smuzhiyun reg &= ~(TOPIC97_AVS_AUDIO_CONTROL | TOPIC97_AVS_VIDEO_CONTROL);
129*4882a593Smuzhiyun config_writeb(socket, TOPIC97_AUDIO_VIDEO_SWITCH, reg);
130*4882a593Smuzhiyun }
131*4882a593Smuzhiyun }
132*4882a593Smuzhiyun
topic97_override(struct yenta_socket * socket)133*4882a593Smuzhiyun static int topic97_override(struct yenta_socket *socket)
134*4882a593Smuzhiyun {
135*4882a593Smuzhiyun /* ToPIC97/100 support ZV */
136*4882a593Smuzhiyun socket->socket.zoom_video = topic97_zoom_video;
137*4882a593Smuzhiyun return 0;
138*4882a593Smuzhiyun }
139*4882a593Smuzhiyun
140*4882a593Smuzhiyun
topic95_override(struct yenta_socket * socket)141*4882a593Smuzhiyun static int topic95_override(struct yenta_socket *socket)
142*4882a593Smuzhiyun {
143*4882a593Smuzhiyun u8 fctrl;
144*4882a593Smuzhiyun u16 ppbcn;
145*4882a593Smuzhiyun
146*4882a593Smuzhiyun /* enable 3.3V support for 16bit cards */
147*4882a593Smuzhiyun fctrl = exca_readb(socket, TOPIC_EXCA_IF_CONTROL);
148*4882a593Smuzhiyun exca_writeb(socket, TOPIC_EXCA_IF_CONTROL, fctrl | TOPIC_EXCA_IFC_33V_ENA);
149*4882a593Smuzhiyun
150*4882a593Smuzhiyun /* tell yenta to use exca registers to power 16bit cards */
151*4882a593Smuzhiyun socket->flags |= YENTA_16BIT_POWER_EXCA | YENTA_16BIT_POWER_DF;
152*4882a593Smuzhiyun
153*4882a593Smuzhiyun /* Disable write buffers to prevent lockups under load with numerous
154*4882a593Smuzhiyun Cardbus cards, observed on Tecra 500CDT and reported elsewhere on the
155*4882a593Smuzhiyun net. This is not a power-on default according to the datasheet
156*4882a593Smuzhiyun but some BIOSes seem to set it. */
157*4882a593Smuzhiyun if (pci_read_config_word(socket->dev, TOPIC_PCI_CFG_PPBCN, &ppbcn) == 0
158*4882a593Smuzhiyun && socket->dev->revision <= 7
159*4882a593Smuzhiyun && (ppbcn & TOPIC_PCI_CFG_PPBCN_WBEN)) {
160*4882a593Smuzhiyun ppbcn &= ~TOPIC_PCI_CFG_PPBCN_WBEN;
161*4882a593Smuzhiyun pci_write_config_word(socket->dev, TOPIC_PCI_CFG_PPBCN, ppbcn);
162*4882a593Smuzhiyun dev_info(&socket->dev->dev, "Disabled ToPIC95 Cardbus write buffers.\n");
163*4882a593Smuzhiyun }
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun return 0;
166*4882a593Smuzhiyun }
167*4882a593Smuzhiyun
168*4882a593Smuzhiyun #endif /* _LINUX_TOPIC_H */
169