162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * topic.h 1.8 1999/08/28 04:01:47
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * The contents of this file are subject to the Mozilla Public License
562306a36Sopenharmony_ci * Version 1.1 (the "License"); you may not use this file except in
662306a36Sopenharmony_ci * compliance with the License. You may obtain a copy of the License
762306a36Sopenharmony_ci * at http://www.mozilla.org/MPL/
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * Software distributed under the License is distributed on an "AS IS"
1062306a36Sopenharmony_ci * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
1162306a36Sopenharmony_ci * the License for the specific language governing rights and
1262306a36Sopenharmony_ci * limitations under the License.
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci * The initial developer of the original code is David A. Hinds
1562306a36Sopenharmony_ci * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
1662306a36Sopenharmony_ci * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
1762306a36Sopenharmony_ci *
1862306a36Sopenharmony_ci * Alternatively, the contents of this file may be used under the
1962306a36Sopenharmony_ci * terms of the GNU General Public License version 2 (the "GPL"), in which
2062306a36Sopenharmony_ci * case the provisions of the GPL are applicable instead of the
2162306a36Sopenharmony_ci * above.  If you wish to allow the use of your version of this file
2262306a36Sopenharmony_ci * only under the terms of the GPL and not to allow others to use
2362306a36Sopenharmony_ci * your version of this file under the MPL, indicate your decision by
2462306a36Sopenharmony_ci * deleting the provisions above and replace them with the notice and
2562306a36Sopenharmony_ci * other provisions required by the GPL.  If you do not delete the
2662306a36Sopenharmony_ci * provisions above, a recipient may use your version of this file
2762306a36Sopenharmony_ci * under either the MPL or the GPL.
2862306a36Sopenharmony_ci * topic.h $Release$ 1999/08/28 04:01:47
2962306a36Sopenharmony_ci */
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#ifndef _LINUX_TOPIC_H
3262306a36Sopenharmony_ci#define _LINUX_TOPIC_H
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci/* Register definitions for Toshiba ToPIC95/97/100 controllers */
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#define TOPIC_SOCKET_CONTROL		0x0090	/* 32 bit */
3762306a36Sopenharmony_ci#define  TOPIC_SCR_IRQSEL		0x00000001
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#define TOPIC_SLOT_CONTROL		0x00a0	/* 8 bit */
4062306a36Sopenharmony_ci#define  TOPIC_SLOT_SLOTON		0x80
4162306a36Sopenharmony_ci#define  TOPIC_SLOT_SLOTEN		0x40
4262306a36Sopenharmony_ci#define  TOPIC_SLOT_ID_LOCK		0x20
4362306a36Sopenharmony_ci#define  TOPIC_SLOT_ID_WP		0x10
4462306a36Sopenharmony_ci#define  TOPIC_SLOT_PORT_MASK		0x0c
4562306a36Sopenharmony_ci#define  TOPIC_SLOT_PORT_SHIFT		2
4662306a36Sopenharmony_ci#define  TOPIC_SLOT_OFS_MASK		0x03
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#define TOPIC_CARD_CONTROL		0x00a1	/* 8 bit */
4962306a36Sopenharmony_ci#define  TOPIC_CCR_INTB			0x20
5062306a36Sopenharmony_ci#define  TOPIC_CCR_INTA			0x10
5162306a36Sopenharmony_ci#define  TOPIC_CCR_CLOCK		0x0c
5262306a36Sopenharmony_ci#define  TOPIC_CCR_PCICLK		0x0c
5362306a36Sopenharmony_ci#define  TOPIC_CCR_PCICLK_2		0x08
5462306a36Sopenharmony_ci#define  TOPIC_CCR_CCLK			0x04
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci#define TOPIC97_INT_CONTROL		0x00a1	/* 8 bit */
5762306a36Sopenharmony_ci#define  TOPIC97_ICR_INTB		0x20
5862306a36Sopenharmony_ci#define  TOPIC97_ICR_INTA		0x10
5962306a36Sopenharmony_ci#define  TOPIC97_ICR_STSIRQNP		0x04
6062306a36Sopenharmony_ci#define  TOPIC97_ICR_IRQNP		0x02
6162306a36Sopenharmony_ci#define  TOPIC97_ICR_IRQSEL		0x01
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define TOPIC_CARD_DETECT		0x00a3	/* 8 bit */
6462306a36Sopenharmony_ci#define  TOPIC_CDR_MODE_PC32		0x80
6562306a36Sopenharmony_ci#define  TOPIC_CDR_VS1			0x04
6662306a36Sopenharmony_ci#define  TOPIC_CDR_VS2			0x02
6762306a36Sopenharmony_ci#define  TOPIC_CDR_SW_DETECT		0x01
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci#define TOPIC_REGISTER_CONTROL		0x00a4	/* 32 bit */
7062306a36Sopenharmony_ci#define  TOPIC_RCR_RESUME_RESET		0x80000000
7162306a36Sopenharmony_ci#define  TOPIC_RCR_REMOVE_RESET		0x40000000
7262306a36Sopenharmony_ci#define  TOPIC97_RCR_CLKRUN_ENA		0x20000000
7362306a36Sopenharmony_ci#define  TOPIC97_RCR_TESTMODE		0x10000000
7462306a36Sopenharmony_ci#define  TOPIC97_RCR_IOPLUP		0x08000000
7562306a36Sopenharmony_ci#define  TOPIC_RCR_BUFOFF_PWROFF	0x02000000
7662306a36Sopenharmony_ci#define  TOPIC_RCR_BUFOFF_SIGOFF	0x01000000
7762306a36Sopenharmony_ci#define  TOPIC97_RCR_CB_DEV_MASK	0x0000f800
7862306a36Sopenharmony_ci#define  TOPIC97_RCR_CB_DEV_SHIFT	11
7962306a36Sopenharmony_ci#define  TOPIC97_RCR_RI_DISABLE		0x00000004
8062306a36Sopenharmony_ci#define  TOPIC97_RCR_CAUDIO_OFF		0x00000002
8162306a36Sopenharmony_ci#define  TOPIC_RCR_CAUDIO_INVERT	0x00000001
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci#define TOPIC97_MISC1			0x00ad  /* 8bit */
8462306a36Sopenharmony_ci#define  TOPIC97_MISC1_CLOCKRUN_ENABLE	0x80
8562306a36Sopenharmony_ci#define  TOPIC97_MISC1_CLOCKRUN_MODE	0x40
8662306a36Sopenharmony_ci#define  TOPIC97_MISC1_DETECT_REQ_ENA	0x10
8762306a36Sopenharmony_ci#define  TOPIC97_MISC1_SCK_CLEAR_DIS	0x04
8862306a36Sopenharmony_ci#define  TOPIC97_MISC1_R2_LOW_ENABLE	0x10
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci#define TOPIC97_MISC2			0x00ae  /* 8 bit */
9162306a36Sopenharmony_ci#define  TOPIC97_MISC2_SPWRCLK_MASK	0x70
9262306a36Sopenharmony_ci#define  TOPIC97_MISC2_SPWRMOD		0x08
9362306a36Sopenharmony_ci#define  TOPIC97_MISC2_SPWR_ENABLE	0x04
9462306a36Sopenharmony_ci#define  TOPIC97_MISC2_ZV_MODE		0x02
9562306a36Sopenharmony_ci#define  TOPIC97_MISC2_ZV_ENABLE	0x01
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci#define TOPIC97_ZOOM_VIDEO_CONTROL	0x009c  /* 8 bit */
9862306a36Sopenharmony_ci#define  TOPIC97_ZV_CONTROL_ENABLE	0x01
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci#define TOPIC97_AUDIO_VIDEO_SWITCH	0x003c  /* 8 bit */
10162306a36Sopenharmony_ci#define  TOPIC97_AVS_AUDIO_CONTROL	0x02
10262306a36Sopenharmony_ci#define  TOPIC97_AVS_VIDEO_CONTROL	0x01
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci#define TOPIC_EXCA_IF_CONTROL		0x3e	/* 8 bit */
10562306a36Sopenharmony_ci#define TOPIC_EXCA_IFC_33V_ENA		0x01
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci#define TOPIC_PCI_CFG_PPBCN		0x3e	/* 16-bit */
10862306a36Sopenharmony_ci#define TOPIC_PCI_CFG_PPBCN_WBEN	0x0400
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_cistatic void topic97_zoom_video(struct pcmcia_socket *sock, int onoff)
11162306a36Sopenharmony_ci{
11262306a36Sopenharmony_ci	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
11362306a36Sopenharmony_ci	u8 reg_zv, reg;
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci	reg_zv = config_readb(socket, TOPIC97_ZOOM_VIDEO_CONTROL);
11662306a36Sopenharmony_ci	if (onoff) {
11762306a36Sopenharmony_ci		reg_zv |= TOPIC97_ZV_CONTROL_ENABLE;
11862306a36Sopenharmony_ci		config_writeb(socket, TOPIC97_ZOOM_VIDEO_CONTROL, reg_zv);
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci		reg = config_readb(socket, TOPIC97_AUDIO_VIDEO_SWITCH);
12162306a36Sopenharmony_ci		reg |= TOPIC97_AVS_AUDIO_CONTROL | TOPIC97_AVS_VIDEO_CONTROL;
12262306a36Sopenharmony_ci		config_writeb(socket, TOPIC97_AUDIO_VIDEO_SWITCH, reg);
12362306a36Sopenharmony_ci	} else {
12462306a36Sopenharmony_ci		reg_zv &= ~TOPIC97_ZV_CONTROL_ENABLE;
12562306a36Sopenharmony_ci		config_writeb(socket, TOPIC97_ZOOM_VIDEO_CONTROL, reg_zv);
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci		reg = config_readb(socket, TOPIC97_AUDIO_VIDEO_SWITCH);
12862306a36Sopenharmony_ci		reg &= ~(TOPIC97_AVS_AUDIO_CONTROL | TOPIC97_AVS_VIDEO_CONTROL);
12962306a36Sopenharmony_ci		config_writeb(socket, TOPIC97_AUDIO_VIDEO_SWITCH, reg);
13062306a36Sopenharmony_ci	}
13162306a36Sopenharmony_ci}
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_cistatic int topic97_override(struct yenta_socket *socket)
13462306a36Sopenharmony_ci{
13562306a36Sopenharmony_ci	/* ToPIC97/100 support ZV */
13662306a36Sopenharmony_ci	socket->socket.zoom_video = topic97_zoom_video;
13762306a36Sopenharmony_ci	return 0;
13862306a36Sopenharmony_ci}
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_cistatic int topic95_override(struct yenta_socket *socket)
14262306a36Sopenharmony_ci{
14362306a36Sopenharmony_ci	u8 fctrl;
14462306a36Sopenharmony_ci	u16 ppbcn;
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci	/* enable 3.3V support for 16bit cards */
14762306a36Sopenharmony_ci	fctrl = exca_readb(socket, TOPIC_EXCA_IF_CONTROL);
14862306a36Sopenharmony_ci	exca_writeb(socket, TOPIC_EXCA_IF_CONTROL, fctrl | TOPIC_EXCA_IFC_33V_ENA);
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci	/* tell yenta to use exca registers to power 16bit cards */
15162306a36Sopenharmony_ci	socket->flags |= YENTA_16BIT_POWER_EXCA | YENTA_16BIT_POWER_DF;
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci	/* Disable write buffers to prevent lockups under load with numerous
15462306a36Sopenharmony_ci	   Cardbus cards, observed on Tecra 500CDT and reported elsewhere on the
15562306a36Sopenharmony_ci	   net.  This is not a power-on default according to the datasheet
15662306a36Sopenharmony_ci	   but some BIOSes seem to set it. */
15762306a36Sopenharmony_ci	if (pci_read_config_word(socket->dev, TOPIC_PCI_CFG_PPBCN, &ppbcn) == 0
15862306a36Sopenharmony_ci	    && socket->dev->revision <= 7
15962306a36Sopenharmony_ci	    && (ppbcn & TOPIC_PCI_CFG_PPBCN_WBEN)) {
16062306a36Sopenharmony_ci		ppbcn &= ~TOPIC_PCI_CFG_PPBCN_WBEN;
16162306a36Sopenharmony_ci		pci_write_config_word(socket->dev, TOPIC_PCI_CFG_PPBCN, ppbcn);
16262306a36Sopenharmony_ci		dev_info(&socket->dev->dev, "Disabled ToPIC95 Cardbus write buffers.\n");
16362306a36Sopenharmony_ci	}
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci	return 0;
16662306a36Sopenharmony_ci}
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ci#endif /* _LINUX_TOPIC_H */
169