18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * o2micro.h 1.13 1999/10/25 20:03:34
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * The contents of this file are subject to the Mozilla Public License
58c2ecf20Sopenharmony_ci * Version 1.1 (the "License"); you may not use this file except in
68c2ecf20Sopenharmony_ci * compliance with the License. You may obtain a copy of the License
78c2ecf20Sopenharmony_ci * at http://www.mozilla.org/MPL/
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * Software distributed under the License is distributed on an "AS IS"
108c2ecf20Sopenharmony_ci * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
118c2ecf20Sopenharmony_ci * the License for the specific language governing rights and
128c2ecf20Sopenharmony_ci * limitations under the License.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * The initial developer of the original code is David A. Hinds
158c2ecf20Sopenharmony_ci * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
168c2ecf20Sopenharmony_ci * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci * Alternatively, the contents of this file may be used under the
198c2ecf20Sopenharmony_ci * terms of the GNU General Public License version 2 (the "GPL"), in which
208c2ecf20Sopenharmony_ci * case the provisions of the GPL are applicable instead of the
218c2ecf20Sopenharmony_ci * above.  If you wish to allow the use of your version of this file
228c2ecf20Sopenharmony_ci * only under the terms of the GPL and not to allow others to use
238c2ecf20Sopenharmony_ci * your version of this file under the MPL, indicate your decision by
248c2ecf20Sopenharmony_ci * deleting the provisions above and replace them with the notice and
258c2ecf20Sopenharmony_ci * other provisions required by the GPL.  If you do not delete the
268c2ecf20Sopenharmony_ci * provisions above, a recipient may use your version of this file
278c2ecf20Sopenharmony_ci * under either the MPL or the GPL.
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#ifndef _LINUX_O2MICRO_H
318c2ecf20Sopenharmony_ci#define _LINUX_O2MICRO_H
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/* Additional PCI configuration registers */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define O2_MUX_CONTROL		0x90	/* 32 bit */
368c2ecf20Sopenharmony_ci#define  O2_MUX_RING_OUT	0x0000000f
378c2ecf20Sopenharmony_ci#define  O2_MUX_SKTB_ACTV	0x000000f0
388c2ecf20Sopenharmony_ci#define  O2_MUX_SCTA_ACTV_ENA	0x00000100
398c2ecf20Sopenharmony_ci#define  O2_MUX_SCTB_ACTV_ENA	0x00000200
408c2ecf20Sopenharmony_ci#define  O2_MUX_SER_IRQ_ROUTE	0x0000e000
418c2ecf20Sopenharmony_ci#define  O2_MUX_SER_PCI		0x00010000
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define  O2_MUX_SKTA_TURBO	0x000c0000	/* for 6833, 6860 */
448c2ecf20Sopenharmony_ci#define  O2_MUX_SKTB_TURBO	0x00300000
458c2ecf20Sopenharmony_ci#define  O2_MUX_AUX_VCC_3V	0x00400000
468c2ecf20Sopenharmony_ci#define  O2_MUX_PCI_VCC_5V	0x00800000
478c2ecf20Sopenharmony_ci#define  O2_MUX_PME_MUX		0x0f000000
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/* Additional ExCA registers */
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define O2_MODE_A		0x38
528c2ecf20Sopenharmony_ci#define O2_MODE_A_2		0x26	/* for 6833B, 6860C */
538c2ecf20Sopenharmony_ci#define  O2_MODE_A_CD_PULSE	0x04
548c2ecf20Sopenharmony_ci#define  O2_MODE_A_SUSP_EDGE	0x08
558c2ecf20Sopenharmony_ci#define  O2_MODE_A_HOST_SUSP	0x10
568c2ecf20Sopenharmony_ci#define  O2_MODE_A_PWR_MASK	0x60
578c2ecf20Sopenharmony_ci#define  O2_MODE_A_QUIET	0x80
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define O2_MODE_B		0x39
608c2ecf20Sopenharmony_ci#define O2_MODE_B_2		0x2e	/* for 6833B, 6860C */
618c2ecf20Sopenharmony_ci#define  O2_MODE_B_IDENT	0x03
628c2ecf20Sopenharmony_ci#define  O2_MODE_B_ID_BSTEP	0x00
638c2ecf20Sopenharmony_ci#define  O2_MODE_B_ID_CSTEP	0x01
648c2ecf20Sopenharmony_ci#define  O2_MODE_B_ID_O2	0x02
658c2ecf20Sopenharmony_ci#define  O2_MODE_B_VS1		0x04
668c2ecf20Sopenharmony_ci#define  O2_MODE_B_VS2		0x08
678c2ecf20Sopenharmony_ci#define  O2_MODE_B_IRQ15_RI	0x80
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#define O2_MODE_C		0x3a
708c2ecf20Sopenharmony_ci#define  O2_MODE_C_DREQ_MASK	0x03
718c2ecf20Sopenharmony_ci#define  O2_MODE_C_DREQ_INPACK	0x01
728c2ecf20Sopenharmony_ci#define  O2_MODE_C_DREQ_WP	0x02
738c2ecf20Sopenharmony_ci#define  O2_MODE_C_DREQ_BVD2	0x03
748c2ecf20Sopenharmony_ci#define  O2_MODE_C_ZVIDEO	0x08
758c2ecf20Sopenharmony_ci#define  O2_MODE_C_IREQ_SEL	0x30
768c2ecf20Sopenharmony_ci#define  O2_MODE_C_MGMT_SEL	0xc0
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#define O2_MODE_D		0x3b
798c2ecf20Sopenharmony_ci#define  O2_MODE_D_IRQ_MODE	0x03
808c2ecf20Sopenharmony_ci#define  O2_MODE_D_PCI_CLKRUN	0x04
818c2ecf20Sopenharmony_ci#define  O2_MODE_D_CB_CLKRUN	0x08
828c2ecf20Sopenharmony_ci#define  O2_MODE_D_SKT_ACTV	0x20
838c2ecf20Sopenharmony_ci#define  O2_MODE_D_PCI_FIFO	0x40	/* for OZ6729, OZ6730 */
848c2ecf20Sopenharmony_ci#define  O2_MODE_D_W97_IRQ	0x40
858c2ecf20Sopenharmony_ci#define  O2_MODE_D_ISA_IRQ	0x80
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#define O2_MHPG_DMA		0x3c
888c2ecf20Sopenharmony_ci#define  O2_MHPG_CHANNEL	0x07
898c2ecf20Sopenharmony_ci#define  O2_MHPG_CINT_ENA	0x08
908c2ecf20Sopenharmony_ci#define  O2_MHPG_CSC_ENA	0x10
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#define O2_FIFO_ENA		0x3d
938c2ecf20Sopenharmony_ci#define  O2_FIFO_ZVIDEO_3	0x08
948c2ecf20Sopenharmony_ci#define  O2_FIFO_PCI_FIFO	0x10
958c2ecf20Sopenharmony_ci#define  O2_FIFO_POSTWR		0x40
968c2ecf20Sopenharmony_ci#define  O2_FIFO_BUFFER		0x80
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define O2_MODE_E		0x3e
998c2ecf20Sopenharmony_ci#define  O2_MODE_E_MHPG_DMA	0x01
1008c2ecf20Sopenharmony_ci#define  O2_MODE_E_SPKR_OUT	0x02
1018c2ecf20Sopenharmony_ci#define  O2_MODE_E_LED_OUT	0x08
1028c2ecf20Sopenharmony_ci#define  O2_MODE_E_SKTA_ACTV	0x10
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#define O2_RESERVED1		0x94
1058c2ecf20Sopenharmony_ci#define O2_RESERVED2		0xD4
1068c2ecf20Sopenharmony_ci#define O2_RES_READ_PREFETCH	0x02
1078c2ecf20Sopenharmony_ci#define O2_RES_WRITE_BURST	0x08
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_cistatic int o2micro_override(struct yenta_socket *socket)
1108c2ecf20Sopenharmony_ci{
1118c2ecf20Sopenharmony_ci	/*
1128c2ecf20Sopenharmony_ci	 * 'reserved' register at 0x94/D4. allows setting read prefetch and write
1138c2ecf20Sopenharmony_ci	 * bursting. read prefetching for example makes the RME Hammerfall DSP
1148c2ecf20Sopenharmony_ci	 * working. for some bridges it is at 0x94, for others at 0xD4. it's
1158c2ecf20Sopenharmony_ci	 * ok to write to both registers on all O2 bridges.
1168c2ecf20Sopenharmony_ci	 * from Eric Still, 02Micro.
1178c2ecf20Sopenharmony_ci	 */
1188c2ecf20Sopenharmony_ci	u8 a, b;
1198c2ecf20Sopenharmony_ci	bool use_speedup;
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci	if (PCI_FUNC(socket->dev->devfn) == 0) {
1228c2ecf20Sopenharmony_ci		a = config_readb(socket, O2_RESERVED1);
1238c2ecf20Sopenharmony_ci		b = config_readb(socket, O2_RESERVED2);
1248c2ecf20Sopenharmony_ci		dev_dbg(&socket->dev->dev, "O2: 0x94/0xD4: %02x/%02x\n", a, b);
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci		switch (socket->dev->device) {
1278c2ecf20Sopenharmony_ci		/*
1288c2ecf20Sopenharmony_ci		 * older bridges have problems with both read prefetch and write
1298c2ecf20Sopenharmony_ci		 * bursting depending on the combination of the chipset, bridge
1308c2ecf20Sopenharmony_ci		 * and the cardbus card. so disable them to be on the safe side.
1318c2ecf20Sopenharmony_ci		 */
1328c2ecf20Sopenharmony_ci		case PCI_DEVICE_ID_O2_6729:
1338c2ecf20Sopenharmony_ci		case PCI_DEVICE_ID_O2_6730:
1348c2ecf20Sopenharmony_ci		case PCI_DEVICE_ID_O2_6812:
1358c2ecf20Sopenharmony_ci		case PCI_DEVICE_ID_O2_6832:
1368c2ecf20Sopenharmony_ci		case PCI_DEVICE_ID_O2_6836:
1378c2ecf20Sopenharmony_ci		case PCI_DEVICE_ID_O2_6933:
1388c2ecf20Sopenharmony_ci			use_speedup = false;
1398c2ecf20Sopenharmony_ci			break;
1408c2ecf20Sopenharmony_ci		default:
1418c2ecf20Sopenharmony_ci			use_speedup = true;
1428c2ecf20Sopenharmony_ci			break;
1438c2ecf20Sopenharmony_ci		}
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci		/* the user may override our decision */
1468c2ecf20Sopenharmony_ci		if (strcasecmp(o2_speedup, "on") == 0)
1478c2ecf20Sopenharmony_ci			use_speedup = true;
1488c2ecf20Sopenharmony_ci		else if (strcasecmp(o2_speedup, "off") == 0)
1498c2ecf20Sopenharmony_ci			use_speedup = false;
1508c2ecf20Sopenharmony_ci		else if (strcasecmp(o2_speedup, "default") != 0)
1518c2ecf20Sopenharmony_ci			dev_warn(&socket->dev->dev,
1528c2ecf20Sopenharmony_ci				"O2: Unknown parameter, using 'default'");
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci		if (use_speedup) {
1558c2ecf20Sopenharmony_ci			dev_info(&socket->dev->dev,
1568c2ecf20Sopenharmony_ci				"O2: enabling read prefetch/write burst. If you experience problems or performance issues, use the yenta_socket parameter 'o2_speedup=off'\n");
1578c2ecf20Sopenharmony_ci			config_writeb(socket, O2_RESERVED1,
1588c2ecf20Sopenharmony_ci				      a | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST);
1598c2ecf20Sopenharmony_ci			config_writeb(socket, O2_RESERVED2,
1608c2ecf20Sopenharmony_ci				      b | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST);
1618c2ecf20Sopenharmony_ci		} else {
1628c2ecf20Sopenharmony_ci			dev_info(&socket->dev->dev,
1638c2ecf20Sopenharmony_ci				"O2: disabling read prefetch/write burst. If you experience problems or performance issues, use the yenta_socket parameter 'o2_speedup=on'\n");
1648c2ecf20Sopenharmony_ci			config_writeb(socket, O2_RESERVED1,
1658c2ecf20Sopenharmony_ci				      a & ~(O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST));
1668c2ecf20Sopenharmony_ci			config_writeb(socket, O2_RESERVED2,
1678c2ecf20Sopenharmony_ci				      b & ~(O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST));
1688c2ecf20Sopenharmony_ci		}
1698c2ecf20Sopenharmony_ci	}
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci	return 0;
1728c2ecf20Sopenharmony_ci}
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_cistatic void o2micro_restore_state(struct yenta_socket *socket)
1758c2ecf20Sopenharmony_ci{
1768c2ecf20Sopenharmony_ci	/*
1778c2ecf20Sopenharmony_ci	 * as long as read prefetch is the only thing in
1788c2ecf20Sopenharmony_ci	 * o2micro_override, it's safe to call it from here
1798c2ecf20Sopenharmony_ci	 */
1808c2ecf20Sopenharmony_ci	o2micro_override(socket);
1818c2ecf20Sopenharmony_ci}
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci#endif /* _LINUX_O2MICRO_H */
184