162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * o2micro.h 1.13 1999/10/25 20:03:34 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 */ 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#ifndef _LINUX_O2MICRO_H 3162306a36Sopenharmony_ci#define _LINUX_O2MICRO_H 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci/* Additional PCI configuration registers */ 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define O2_MUX_CONTROL 0x90 /* 32 bit */ 3662306a36Sopenharmony_ci#define O2_MUX_RING_OUT 0x0000000f 3762306a36Sopenharmony_ci#define O2_MUX_SKTB_ACTV 0x000000f0 3862306a36Sopenharmony_ci#define O2_MUX_SCTA_ACTV_ENA 0x00000100 3962306a36Sopenharmony_ci#define O2_MUX_SCTB_ACTV_ENA 0x00000200 4062306a36Sopenharmony_ci#define O2_MUX_SER_IRQ_ROUTE 0x0000e000 4162306a36Sopenharmony_ci#define O2_MUX_SER_PCI 0x00010000 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define O2_MUX_SKTA_TURBO 0x000c0000 /* for 6833, 6860 */ 4462306a36Sopenharmony_ci#define O2_MUX_SKTB_TURBO 0x00300000 4562306a36Sopenharmony_ci#define O2_MUX_AUX_VCC_3V 0x00400000 4662306a36Sopenharmony_ci#define O2_MUX_PCI_VCC_5V 0x00800000 4762306a36Sopenharmony_ci#define O2_MUX_PME_MUX 0x0f000000 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* Additional ExCA registers */ 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#define O2_MODE_A 0x38 5262306a36Sopenharmony_ci#define O2_MODE_A_2 0x26 /* for 6833B, 6860C */ 5362306a36Sopenharmony_ci#define O2_MODE_A_CD_PULSE 0x04 5462306a36Sopenharmony_ci#define O2_MODE_A_SUSP_EDGE 0x08 5562306a36Sopenharmony_ci#define O2_MODE_A_HOST_SUSP 0x10 5662306a36Sopenharmony_ci#define O2_MODE_A_PWR_MASK 0x60 5762306a36Sopenharmony_ci#define O2_MODE_A_QUIET 0x80 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci#define O2_MODE_B 0x39 6062306a36Sopenharmony_ci#define O2_MODE_B_2 0x2e /* for 6833B, 6860C */ 6162306a36Sopenharmony_ci#define O2_MODE_B_IDENT 0x03 6262306a36Sopenharmony_ci#define O2_MODE_B_ID_BSTEP 0x00 6362306a36Sopenharmony_ci#define O2_MODE_B_ID_CSTEP 0x01 6462306a36Sopenharmony_ci#define O2_MODE_B_ID_O2 0x02 6562306a36Sopenharmony_ci#define O2_MODE_B_VS1 0x04 6662306a36Sopenharmony_ci#define O2_MODE_B_VS2 0x08 6762306a36Sopenharmony_ci#define O2_MODE_B_IRQ15_RI 0x80 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#define O2_MODE_C 0x3a 7062306a36Sopenharmony_ci#define O2_MODE_C_DREQ_MASK 0x03 7162306a36Sopenharmony_ci#define O2_MODE_C_DREQ_INPACK 0x01 7262306a36Sopenharmony_ci#define O2_MODE_C_DREQ_WP 0x02 7362306a36Sopenharmony_ci#define O2_MODE_C_DREQ_BVD2 0x03 7462306a36Sopenharmony_ci#define O2_MODE_C_ZVIDEO 0x08 7562306a36Sopenharmony_ci#define O2_MODE_C_IREQ_SEL 0x30 7662306a36Sopenharmony_ci#define O2_MODE_C_MGMT_SEL 0xc0 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci#define O2_MODE_D 0x3b 7962306a36Sopenharmony_ci#define O2_MODE_D_IRQ_MODE 0x03 8062306a36Sopenharmony_ci#define O2_MODE_D_PCI_CLKRUN 0x04 8162306a36Sopenharmony_ci#define O2_MODE_D_CB_CLKRUN 0x08 8262306a36Sopenharmony_ci#define O2_MODE_D_SKT_ACTV 0x20 8362306a36Sopenharmony_ci#define O2_MODE_D_PCI_FIFO 0x40 /* for OZ6729, OZ6730 */ 8462306a36Sopenharmony_ci#define O2_MODE_D_W97_IRQ 0x40 8562306a36Sopenharmony_ci#define O2_MODE_D_ISA_IRQ 0x80 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci#define O2_MHPG_DMA 0x3c 8862306a36Sopenharmony_ci#define O2_MHPG_CHANNEL 0x07 8962306a36Sopenharmony_ci#define O2_MHPG_CINT_ENA 0x08 9062306a36Sopenharmony_ci#define O2_MHPG_CSC_ENA 0x10 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci#define O2_FIFO_ENA 0x3d 9362306a36Sopenharmony_ci#define O2_FIFO_ZVIDEO_3 0x08 9462306a36Sopenharmony_ci#define O2_FIFO_PCI_FIFO 0x10 9562306a36Sopenharmony_ci#define O2_FIFO_POSTWR 0x40 9662306a36Sopenharmony_ci#define O2_FIFO_BUFFER 0x80 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci#define O2_MODE_E 0x3e 9962306a36Sopenharmony_ci#define O2_MODE_E_MHPG_DMA 0x01 10062306a36Sopenharmony_ci#define O2_MODE_E_SPKR_OUT 0x02 10162306a36Sopenharmony_ci#define O2_MODE_E_LED_OUT 0x08 10262306a36Sopenharmony_ci#define O2_MODE_E_SKTA_ACTV 0x10 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci#define O2_RESERVED1 0x94 10562306a36Sopenharmony_ci#define O2_RESERVED2 0xD4 10662306a36Sopenharmony_ci#define O2_RES_READ_PREFETCH 0x02 10762306a36Sopenharmony_ci#define O2_RES_WRITE_BURST 0x08 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_cistatic int o2micro_override(struct yenta_socket *socket) 11062306a36Sopenharmony_ci{ 11162306a36Sopenharmony_ci /* 11262306a36Sopenharmony_ci * 'reserved' register at 0x94/D4. allows setting read prefetch and write 11362306a36Sopenharmony_ci * bursting. read prefetching for example makes the RME Hammerfall DSP 11462306a36Sopenharmony_ci * working. for some bridges it is at 0x94, for others at 0xD4. it's 11562306a36Sopenharmony_ci * ok to write to both registers on all O2 bridges. 11662306a36Sopenharmony_ci * from Eric Still, 02Micro. 11762306a36Sopenharmony_ci */ 11862306a36Sopenharmony_ci u8 a, b; 11962306a36Sopenharmony_ci bool use_speedup; 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci if (PCI_FUNC(socket->dev->devfn) == 0) { 12262306a36Sopenharmony_ci a = config_readb(socket, O2_RESERVED1); 12362306a36Sopenharmony_ci b = config_readb(socket, O2_RESERVED2); 12462306a36Sopenharmony_ci dev_dbg(&socket->dev->dev, "O2: 0x94/0xD4: %02x/%02x\n", a, b); 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci switch (socket->dev->device) { 12762306a36Sopenharmony_ci /* 12862306a36Sopenharmony_ci * older bridges have problems with both read prefetch and write 12962306a36Sopenharmony_ci * bursting depending on the combination of the chipset, bridge 13062306a36Sopenharmony_ci * and the cardbus card. so disable them to be on the safe side. 13162306a36Sopenharmony_ci */ 13262306a36Sopenharmony_ci case PCI_DEVICE_ID_O2_6729: 13362306a36Sopenharmony_ci case PCI_DEVICE_ID_O2_6730: 13462306a36Sopenharmony_ci case PCI_DEVICE_ID_O2_6812: 13562306a36Sopenharmony_ci case PCI_DEVICE_ID_O2_6832: 13662306a36Sopenharmony_ci case PCI_DEVICE_ID_O2_6836: 13762306a36Sopenharmony_ci case PCI_DEVICE_ID_O2_6933: 13862306a36Sopenharmony_ci use_speedup = false; 13962306a36Sopenharmony_ci break; 14062306a36Sopenharmony_ci default: 14162306a36Sopenharmony_ci use_speedup = true; 14262306a36Sopenharmony_ci break; 14362306a36Sopenharmony_ci } 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci /* the user may override our decision */ 14662306a36Sopenharmony_ci if (strcasecmp(o2_speedup, "on") == 0) 14762306a36Sopenharmony_ci use_speedup = true; 14862306a36Sopenharmony_ci else if (strcasecmp(o2_speedup, "off") == 0) 14962306a36Sopenharmony_ci use_speedup = false; 15062306a36Sopenharmony_ci else if (strcasecmp(o2_speedup, "default") != 0) 15162306a36Sopenharmony_ci dev_warn(&socket->dev->dev, 15262306a36Sopenharmony_ci "O2: Unknown parameter, using 'default'"); 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci if (use_speedup) { 15562306a36Sopenharmony_ci dev_info(&socket->dev->dev, 15662306a36Sopenharmony_ci "O2: enabling read prefetch/write burst. If you experience problems or performance issues, use the yenta_socket parameter 'o2_speedup=off'\n"); 15762306a36Sopenharmony_ci config_writeb(socket, O2_RESERVED1, 15862306a36Sopenharmony_ci a | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST); 15962306a36Sopenharmony_ci config_writeb(socket, O2_RESERVED2, 16062306a36Sopenharmony_ci b | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST); 16162306a36Sopenharmony_ci } else { 16262306a36Sopenharmony_ci dev_info(&socket->dev->dev, 16362306a36Sopenharmony_ci "O2: disabling read prefetch/write burst. If you experience problems or performance issues, use the yenta_socket parameter 'o2_speedup=on'\n"); 16462306a36Sopenharmony_ci config_writeb(socket, O2_RESERVED1, 16562306a36Sopenharmony_ci a & ~(O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST)); 16662306a36Sopenharmony_ci config_writeb(socket, O2_RESERVED2, 16762306a36Sopenharmony_ci b & ~(O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST)); 16862306a36Sopenharmony_ci } 16962306a36Sopenharmony_ci } 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci return 0; 17262306a36Sopenharmony_ci} 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_cistatic void o2micro_restore_state(struct yenta_socket *socket) 17562306a36Sopenharmony_ci{ 17662306a36Sopenharmony_ci /* 17762306a36Sopenharmony_ci * as long as read prefetch is the only thing in 17862306a36Sopenharmony_ci * o2micro_override, it's safe to call it from here 17962306a36Sopenharmony_ci */ 18062306a36Sopenharmony_ci o2micro_override(socket); 18162306a36Sopenharmony_ci} 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci#endif /* _LINUX_O2MICRO_H */ 184