162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * ti113x.h 1.16 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_TI113X_H 3162306a36Sopenharmony_ci#define _LINUX_TI113X_H 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci/* Register definitions for TI 113X PCI-to-CardBus bridges */ 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci/* System Control Register */ 3762306a36Sopenharmony_ci#define TI113X_SYSTEM_CONTROL 0x0080 /* 32 bit */ 3862306a36Sopenharmony_ci#define TI113X_SCR_SMIROUTE 0x04000000 3962306a36Sopenharmony_ci#define TI113X_SCR_SMISTATUS 0x02000000 4062306a36Sopenharmony_ci#define TI113X_SCR_SMIENB 0x01000000 4162306a36Sopenharmony_ci#define TI113X_SCR_VCCPROT 0x00200000 4262306a36Sopenharmony_ci#define TI113X_SCR_REDUCEZV 0x00100000 4362306a36Sopenharmony_ci#define TI113X_SCR_CDREQEN 0x00080000 4462306a36Sopenharmony_ci#define TI113X_SCR_CDMACHAN 0x00070000 4562306a36Sopenharmony_ci#define TI113X_SCR_SOCACTIVE 0x00002000 4662306a36Sopenharmony_ci#define TI113X_SCR_PWRSTREAM 0x00000800 4762306a36Sopenharmony_ci#define TI113X_SCR_DELAYUP 0x00000400 4862306a36Sopenharmony_ci#define TI113X_SCR_DELAYDOWN 0x00000200 4962306a36Sopenharmony_ci#define TI113X_SCR_INTERROGATE 0x00000100 5062306a36Sopenharmony_ci#define TI113X_SCR_CLKRUN_SEL 0x00000080 5162306a36Sopenharmony_ci#define TI113X_SCR_PWRSAVINGS 0x00000040 5262306a36Sopenharmony_ci#define TI113X_SCR_SUBSYSRW 0x00000020 5362306a36Sopenharmony_ci#define TI113X_SCR_CB_DPAR 0x00000010 5462306a36Sopenharmony_ci#define TI113X_SCR_CDMA_EN 0x00000008 5562306a36Sopenharmony_ci#define TI113X_SCR_ASYNC_IRQ 0x00000004 5662306a36Sopenharmony_ci#define TI113X_SCR_KEEPCLK 0x00000002 5762306a36Sopenharmony_ci#define TI113X_SCR_CLKRUN_ENA 0x00000001 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci#define TI122X_SCR_SER_STEP 0xc0000000 6062306a36Sopenharmony_ci#define TI122X_SCR_INTRTIE 0x20000000 6162306a36Sopenharmony_ci#define TIXX21_SCR_TIEALL 0x10000000 6262306a36Sopenharmony_ci#define TI122X_SCR_CBRSVD 0x00400000 6362306a36Sopenharmony_ci#define TI122X_SCR_MRBURSTDN 0x00008000 6462306a36Sopenharmony_ci#define TI122X_SCR_MRBURSTUP 0x00004000 6562306a36Sopenharmony_ci#define TI122X_SCR_RIMUX 0x00000001 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci/* Multimedia Control Register */ 6862306a36Sopenharmony_ci#define TI1250_MULTIMEDIA_CTL 0x0084 /* 8 bit */ 6962306a36Sopenharmony_ci#define TI1250_MMC_ZVOUTEN 0x80 7062306a36Sopenharmony_ci#define TI1250_MMC_PORTSEL 0x40 7162306a36Sopenharmony_ci#define TI1250_MMC_ZVEN1 0x02 7262306a36Sopenharmony_ci#define TI1250_MMC_ZVEN0 0x01 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci#define TI1250_GENERAL_STATUS 0x0085 /* 8 bit */ 7562306a36Sopenharmony_ci#define TI1250_GPIO0_CONTROL 0x0088 /* 8 bit */ 7662306a36Sopenharmony_ci#define TI1250_GPIO1_CONTROL 0x0089 /* 8 bit */ 7762306a36Sopenharmony_ci#define TI1250_GPIO2_CONTROL 0x008a /* 8 bit */ 7862306a36Sopenharmony_ci#define TI1250_GPIO3_CONTROL 0x008b /* 8 bit */ 7962306a36Sopenharmony_ci#define TI1250_GPIO_MODE_MASK 0xc0 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci/* IRQMUX/MFUNC Register */ 8262306a36Sopenharmony_ci#define TI122X_MFUNC 0x008c /* 32 bit */ 8362306a36Sopenharmony_ci#define TI122X_MFUNC0_MASK 0x0000000f 8462306a36Sopenharmony_ci#define TI122X_MFUNC1_MASK 0x000000f0 8562306a36Sopenharmony_ci#define TI122X_MFUNC2_MASK 0x00000f00 8662306a36Sopenharmony_ci#define TI122X_MFUNC3_MASK 0x0000f000 8762306a36Sopenharmony_ci#define TI122X_MFUNC4_MASK 0x000f0000 8862306a36Sopenharmony_ci#define TI122X_MFUNC5_MASK 0x00f00000 8962306a36Sopenharmony_ci#define TI122X_MFUNC6_MASK 0x0f000000 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci#define TI122X_MFUNC0_INTA 0x00000002 9262306a36Sopenharmony_ci#define TI125X_MFUNC0_INTB 0x00000001 9362306a36Sopenharmony_ci#define TI122X_MFUNC1_INTB 0x00000020 9462306a36Sopenharmony_ci#define TI122X_MFUNC3_IRQSER 0x00001000 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci/* Retry Status Register */ 9862306a36Sopenharmony_ci#define TI113X_RETRY_STATUS 0x0090 /* 8 bit */ 9962306a36Sopenharmony_ci#define TI113X_RSR_PCIRETRY 0x80 10062306a36Sopenharmony_ci#define TI113X_RSR_CBRETRY 0x40 10162306a36Sopenharmony_ci#define TI113X_RSR_TEXP_CBB 0x20 10262306a36Sopenharmony_ci#define TI113X_RSR_MEXP_CBB 0x10 10362306a36Sopenharmony_ci#define TI113X_RSR_TEXP_CBA 0x08 10462306a36Sopenharmony_ci#define TI113X_RSR_MEXP_CBA 0x04 10562306a36Sopenharmony_ci#define TI113X_RSR_TEXP_PCI 0x02 10662306a36Sopenharmony_ci#define TI113X_RSR_MEXP_PCI 0x01 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci/* Card Control Register */ 10962306a36Sopenharmony_ci#define TI113X_CARD_CONTROL 0x0091 /* 8 bit */ 11062306a36Sopenharmony_ci#define TI113X_CCR_RIENB 0x80 11162306a36Sopenharmony_ci#define TI113X_CCR_ZVENABLE 0x40 11262306a36Sopenharmony_ci#define TI113X_CCR_PCI_IRQ_ENA 0x20 11362306a36Sopenharmony_ci#define TI113X_CCR_PCI_IREQ 0x10 11462306a36Sopenharmony_ci#define TI113X_CCR_PCI_CSC 0x08 11562306a36Sopenharmony_ci#define TI113X_CCR_SPKROUTEN 0x02 11662306a36Sopenharmony_ci#define TI113X_CCR_IFG 0x01 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci#define TI1220_CCR_PORT_SEL 0x20 11962306a36Sopenharmony_ci#define TI122X_CCR_AUD2MUX 0x04 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci/* Device Control Register */ 12262306a36Sopenharmony_ci#define TI113X_DEVICE_CONTROL 0x0092 /* 8 bit */ 12362306a36Sopenharmony_ci#define TI113X_DCR_5V_FORCE 0x40 12462306a36Sopenharmony_ci#define TI113X_DCR_3V_FORCE 0x20 12562306a36Sopenharmony_ci#define TI113X_DCR_IMODE_MASK 0x06 12662306a36Sopenharmony_ci#define TI113X_DCR_IMODE_ISA 0x02 12762306a36Sopenharmony_ci#define TI113X_DCR_IMODE_SERIAL 0x04 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci#define TI12XX_DCR_IMODE_PCI_ONLY 0x00 13062306a36Sopenharmony_ci#define TI12XX_DCR_IMODE_ALL_SERIAL 0x06 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci/* Buffer Control Register */ 13362306a36Sopenharmony_ci#define TI113X_BUFFER_CONTROL 0x0093 /* 8 bit */ 13462306a36Sopenharmony_ci#define TI113X_BCR_CB_READ_DEPTH 0x08 13562306a36Sopenharmony_ci#define TI113X_BCR_CB_WRITE_DEPTH 0x04 13662306a36Sopenharmony_ci#define TI113X_BCR_PCI_READ_DEPTH 0x02 13762306a36Sopenharmony_ci#define TI113X_BCR_PCI_WRITE_DEPTH 0x01 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci/* Diagnostic Register */ 14062306a36Sopenharmony_ci#define TI1250_DIAGNOSTIC 0x0093 /* 8 bit */ 14162306a36Sopenharmony_ci#define TI1250_DIAG_TRUE_VALUE 0x80 14262306a36Sopenharmony_ci#define TI1250_DIAG_PCI_IREQ 0x40 14362306a36Sopenharmony_ci#define TI1250_DIAG_PCI_CSC 0x20 14462306a36Sopenharmony_ci#define TI1250_DIAG_ASYNC_CSC 0x01 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci/* DMA Registers */ 14762306a36Sopenharmony_ci#define TI113X_DMA_0 0x0094 /* 32 bit */ 14862306a36Sopenharmony_ci#define TI113X_DMA_1 0x0098 /* 32 bit */ 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci/* ExCA IO offset registers */ 15162306a36Sopenharmony_ci#define TI113X_IO_OFFSET(map) (0x36+((map)<<1)) 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci/* EnE test register */ 15462306a36Sopenharmony_ci#define ENE_TEST_C9 0xc9 /* 8bit */ 15562306a36Sopenharmony_ci#define ENE_TEST_C9_TLTENABLE 0x02 15662306a36Sopenharmony_ci#define ENE_TEST_C9_PFENABLE_F0 0x04 15762306a36Sopenharmony_ci#define ENE_TEST_C9_PFENABLE_F1 0x08 15862306a36Sopenharmony_ci#define ENE_TEST_C9_PFENABLE (ENE_TEST_C9_PFENABLE_F0 | ENE_TEST_C9_PFENABLE_F1) 15962306a36Sopenharmony_ci#define ENE_TEST_C9_WPDISALBLE_F0 0x40 16062306a36Sopenharmony_ci#define ENE_TEST_C9_WPDISALBLE_F1 0x80 16162306a36Sopenharmony_ci#define ENE_TEST_C9_WPDISALBLE (ENE_TEST_C9_WPDISALBLE_F0 | ENE_TEST_C9_WPDISALBLE_F1) 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci/* 16462306a36Sopenharmony_ci * Texas Instruments CardBus controller overrides. 16562306a36Sopenharmony_ci */ 16662306a36Sopenharmony_ci#define ti_sysctl(socket) ((socket)->private[0]) 16762306a36Sopenharmony_ci#define ti_cardctl(socket) ((socket)->private[1]) 16862306a36Sopenharmony_ci#define ti_devctl(socket) ((socket)->private[2]) 16962306a36Sopenharmony_ci#define ti_diag(socket) ((socket)->private[3]) 17062306a36Sopenharmony_ci#define ti_mfunc(socket) ((socket)->private[4]) 17162306a36Sopenharmony_ci#define ene_test_c9(socket) ((socket)->private[5]) 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci/* 17462306a36Sopenharmony_ci * These are the TI specific power management handlers. 17562306a36Sopenharmony_ci */ 17662306a36Sopenharmony_cistatic void ti_save_state(struct yenta_socket *socket) 17762306a36Sopenharmony_ci{ 17862306a36Sopenharmony_ci ti_sysctl(socket) = config_readl(socket, TI113X_SYSTEM_CONTROL); 17962306a36Sopenharmony_ci ti_mfunc(socket) = config_readl(socket, TI122X_MFUNC); 18062306a36Sopenharmony_ci ti_cardctl(socket) = config_readb(socket, TI113X_CARD_CONTROL); 18162306a36Sopenharmony_ci ti_devctl(socket) = config_readb(socket, TI113X_DEVICE_CONTROL); 18262306a36Sopenharmony_ci ti_diag(socket) = config_readb(socket, TI1250_DIAGNOSTIC); 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci if (socket->dev->vendor == PCI_VENDOR_ID_ENE) 18562306a36Sopenharmony_ci ene_test_c9(socket) = config_readb(socket, ENE_TEST_C9); 18662306a36Sopenharmony_ci} 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_cistatic void ti_restore_state(struct yenta_socket *socket) 18962306a36Sopenharmony_ci{ 19062306a36Sopenharmony_ci config_writel(socket, TI113X_SYSTEM_CONTROL, ti_sysctl(socket)); 19162306a36Sopenharmony_ci config_writel(socket, TI122X_MFUNC, ti_mfunc(socket)); 19262306a36Sopenharmony_ci config_writeb(socket, TI113X_CARD_CONTROL, ti_cardctl(socket)); 19362306a36Sopenharmony_ci config_writeb(socket, TI113X_DEVICE_CONTROL, ti_devctl(socket)); 19462306a36Sopenharmony_ci config_writeb(socket, TI1250_DIAGNOSTIC, ti_diag(socket)); 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci if (socket->dev->vendor == PCI_VENDOR_ID_ENE) 19762306a36Sopenharmony_ci config_writeb(socket, ENE_TEST_C9, ene_test_c9(socket)); 19862306a36Sopenharmony_ci} 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ci/* 20162306a36Sopenharmony_ci * Zoom video control for TI122x/113x chips 20262306a36Sopenharmony_ci */ 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_cistatic void ti_zoom_video(struct pcmcia_socket *sock, int onoff) 20562306a36Sopenharmony_ci{ 20662306a36Sopenharmony_ci u8 reg; 20762306a36Sopenharmony_ci struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_ci /* If we don't have a Zoom Video switch this is harmless, 21062306a36Sopenharmony_ci we just tristate the unused (ZV) lines */ 21162306a36Sopenharmony_ci reg = config_readb(socket, TI113X_CARD_CONTROL); 21262306a36Sopenharmony_ci if (onoff) 21362306a36Sopenharmony_ci /* Zoom zoom, we will all go together, zoom zoom, zoom zoom */ 21462306a36Sopenharmony_ci reg |= TI113X_CCR_ZVENABLE; 21562306a36Sopenharmony_ci else 21662306a36Sopenharmony_ci reg &= ~TI113X_CCR_ZVENABLE; 21762306a36Sopenharmony_ci config_writeb(socket, TI113X_CARD_CONTROL, reg); 21862306a36Sopenharmony_ci} 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_ci/* 22162306a36Sopenharmony_ci * The 145x series can also use this. They have an additional 22262306a36Sopenharmony_ci * ZV autodetect mode we don't use but don't actually need. 22362306a36Sopenharmony_ci * FIXME: manual says its in func0 and func1 but disagrees with 22462306a36Sopenharmony_ci * itself about this - do we need to force func0, if so we need 22562306a36Sopenharmony_ci * to know a lot more about socket pairings in pcmcia_socket than 22662306a36Sopenharmony_ci * we do now.. uggh. 22762306a36Sopenharmony_ci */ 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_cistatic void ti1250_zoom_video(struct pcmcia_socket *sock, int onoff) 23062306a36Sopenharmony_ci{ 23162306a36Sopenharmony_ci struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); 23262306a36Sopenharmony_ci int shift = 0; 23362306a36Sopenharmony_ci u8 reg; 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci ti_zoom_video(sock, onoff); 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ci reg = config_readb(socket, TI1250_MULTIMEDIA_CTL); 23862306a36Sopenharmony_ci reg |= TI1250_MMC_ZVOUTEN; /* ZV bus enable */ 23962306a36Sopenharmony_ci 24062306a36Sopenharmony_ci if(PCI_FUNC(socket->dev->devfn)==1) 24162306a36Sopenharmony_ci shift = 1; 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_ci if(onoff) 24462306a36Sopenharmony_ci { 24562306a36Sopenharmony_ci reg &= ~(1<<6); /* Clear select bit */ 24662306a36Sopenharmony_ci reg |= shift<<6; /* Favour our socket */ 24762306a36Sopenharmony_ci reg |= 1<<shift; /* Socket zoom video on */ 24862306a36Sopenharmony_ci } 24962306a36Sopenharmony_ci else 25062306a36Sopenharmony_ci { 25162306a36Sopenharmony_ci reg &= ~(1<<6); /* Clear select bit */ 25262306a36Sopenharmony_ci reg |= (1^shift)<<6; /* Favour other socket */ 25362306a36Sopenharmony_ci reg &= ~(1<<shift); /* Socket zoon video off */ 25462306a36Sopenharmony_ci } 25562306a36Sopenharmony_ci 25662306a36Sopenharmony_ci config_writeb(socket, TI1250_MULTIMEDIA_CTL, reg); 25762306a36Sopenharmony_ci} 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_cistatic void ti_set_zv(struct yenta_socket *socket) 26062306a36Sopenharmony_ci{ 26162306a36Sopenharmony_ci if(socket->dev->vendor == PCI_VENDOR_ID_TI) 26262306a36Sopenharmony_ci { 26362306a36Sopenharmony_ci switch(socket->dev->device) 26462306a36Sopenharmony_ci { 26562306a36Sopenharmony_ci /* There may be more .. */ 26662306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1220: 26762306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1221: 26862306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1225: 26962306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_4510: 27062306a36Sopenharmony_ci socket->socket.zoom_video = ti_zoom_video; 27162306a36Sopenharmony_ci break; 27262306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1250: 27362306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251A: 27462306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251B: 27562306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1450: 27662306a36Sopenharmony_ci socket->socket.zoom_video = ti1250_zoom_video; 27762306a36Sopenharmony_ci } 27862306a36Sopenharmony_ci } 27962306a36Sopenharmony_ci} 28062306a36Sopenharmony_ci 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_ci/* 28362306a36Sopenharmony_ci * Generic TI init - TI has an extension for the 28462306a36Sopenharmony_ci * INTCTL register that sets the PCI CSC interrupt. 28562306a36Sopenharmony_ci * Make sure we set it correctly at open and init 28662306a36Sopenharmony_ci * time 28762306a36Sopenharmony_ci * - override: disable the PCI CSC interrupt. This makes 28862306a36Sopenharmony_ci * it possible to use the CSC interrupt to probe the 28962306a36Sopenharmony_ci * ISA interrupts. 29062306a36Sopenharmony_ci * - init: set the interrupt to match our PCI state. 29162306a36Sopenharmony_ci * This makes us correctly get PCI CSC interrupt 29262306a36Sopenharmony_ci * events. 29362306a36Sopenharmony_ci */ 29462306a36Sopenharmony_cistatic int ti_init(struct yenta_socket *socket) 29562306a36Sopenharmony_ci{ 29662306a36Sopenharmony_ci u8 new, reg = exca_readb(socket, I365_INTCTL); 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ci new = reg & ~I365_INTR_ENA; 29962306a36Sopenharmony_ci if (socket->dev->irq) 30062306a36Sopenharmony_ci new |= I365_INTR_ENA; 30162306a36Sopenharmony_ci if (new != reg) 30262306a36Sopenharmony_ci exca_writeb(socket, I365_INTCTL, new); 30362306a36Sopenharmony_ci return 0; 30462306a36Sopenharmony_ci} 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_cistatic int ti_override(struct yenta_socket *socket) 30762306a36Sopenharmony_ci{ 30862306a36Sopenharmony_ci u8 new, reg = exca_readb(socket, I365_INTCTL); 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_ci new = reg & ~I365_INTR_ENA; 31162306a36Sopenharmony_ci if (new != reg) 31262306a36Sopenharmony_ci exca_writeb(socket, I365_INTCTL, new); 31362306a36Sopenharmony_ci 31462306a36Sopenharmony_ci ti_set_zv(socket); 31562306a36Sopenharmony_ci 31662306a36Sopenharmony_ci return 0; 31762306a36Sopenharmony_ci} 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_cistatic void ti113x_use_isa_irq(struct yenta_socket *socket) 32062306a36Sopenharmony_ci{ 32162306a36Sopenharmony_ci int isa_irq = -1; 32262306a36Sopenharmony_ci u8 intctl; 32362306a36Sopenharmony_ci u32 isa_irq_mask = 0; 32462306a36Sopenharmony_ci 32562306a36Sopenharmony_ci if (!isa_probe) 32662306a36Sopenharmony_ci return; 32762306a36Sopenharmony_ci 32862306a36Sopenharmony_ci /* get a free isa int */ 32962306a36Sopenharmony_ci isa_irq_mask = yenta_probe_irq(socket, isa_interrupts); 33062306a36Sopenharmony_ci if (!isa_irq_mask) 33162306a36Sopenharmony_ci return; /* no useable isa irq found */ 33262306a36Sopenharmony_ci 33362306a36Sopenharmony_ci /* choose highest available */ 33462306a36Sopenharmony_ci for (; isa_irq_mask; isa_irq++) 33562306a36Sopenharmony_ci isa_irq_mask >>= 1; 33662306a36Sopenharmony_ci socket->cb_irq = isa_irq; 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_ci exca_writeb(socket, I365_CSCINT, (isa_irq << 4)); 33962306a36Sopenharmony_ci 34062306a36Sopenharmony_ci intctl = exca_readb(socket, I365_INTCTL); 34162306a36Sopenharmony_ci intctl &= ~(I365_INTR_ENA | I365_IRQ_MASK); /* CSC Enable */ 34262306a36Sopenharmony_ci exca_writeb(socket, I365_INTCTL, intctl); 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_ci dev_info(&socket->dev->dev, 34562306a36Sopenharmony_ci "Yenta TI113x: using isa irq %d for CardBus\n", isa_irq); 34662306a36Sopenharmony_ci} 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_cistatic int ti113x_override(struct yenta_socket *socket) 35062306a36Sopenharmony_ci{ 35162306a36Sopenharmony_ci u8 cardctl; 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_ci cardctl = config_readb(socket, TI113X_CARD_CONTROL); 35462306a36Sopenharmony_ci cardctl &= ~(TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_IREQ | TI113X_CCR_PCI_CSC); 35562306a36Sopenharmony_ci if (socket->dev->irq) 35662306a36Sopenharmony_ci cardctl |= TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_CSC | TI113X_CCR_PCI_IREQ; 35762306a36Sopenharmony_ci else 35862306a36Sopenharmony_ci ti113x_use_isa_irq(socket); 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_ci config_writeb(socket, TI113X_CARD_CONTROL, cardctl); 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_ci return ti_override(socket); 36362306a36Sopenharmony_ci} 36462306a36Sopenharmony_ci 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_ci/* irqrouting for func0, probes PCI interrupt and ISA interrupts */ 36762306a36Sopenharmony_cistatic void ti12xx_irqroute_func0(struct yenta_socket *socket) 36862306a36Sopenharmony_ci{ 36962306a36Sopenharmony_ci u32 mfunc, mfunc_old, devctl; 37062306a36Sopenharmony_ci u8 gpio3, gpio3_old; 37162306a36Sopenharmony_ci int pci_irq_status; 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ci mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC); 37462306a36Sopenharmony_ci devctl = config_readb(socket, TI113X_DEVICE_CONTROL); 37562306a36Sopenharmony_ci dev_info(&socket->dev->dev, "TI: mfunc 0x%08x, devctl 0x%02x\n", 37662306a36Sopenharmony_ci mfunc, devctl); 37762306a36Sopenharmony_ci 37862306a36Sopenharmony_ci /* make sure PCI interrupts are enabled before probing */ 37962306a36Sopenharmony_ci ti_init(socket); 38062306a36Sopenharmony_ci 38162306a36Sopenharmony_ci /* test PCI interrupts first. only try fixing if return value is 0! */ 38262306a36Sopenharmony_ci pci_irq_status = yenta_probe_cb_irq(socket); 38362306a36Sopenharmony_ci if (pci_irq_status) 38462306a36Sopenharmony_ci goto out; 38562306a36Sopenharmony_ci 38662306a36Sopenharmony_ci /* 38762306a36Sopenharmony_ci * We're here which means PCI interrupts are _not_ delivered. try to 38862306a36Sopenharmony_ci * find the right setting (all serial or parallel) 38962306a36Sopenharmony_ci */ 39062306a36Sopenharmony_ci dev_info(&socket->dev->dev, 39162306a36Sopenharmony_ci "TI: probing PCI interrupt failed, trying to fix\n"); 39262306a36Sopenharmony_ci 39362306a36Sopenharmony_ci /* for serial PCI make sure MFUNC3 is set to IRQSER */ 39462306a36Sopenharmony_ci if ((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) { 39562306a36Sopenharmony_ci switch (socket->dev->device) { 39662306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1250: 39762306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251A: 39862306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251B: 39962306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1450: 40062306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1451A: 40162306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_4450: 40262306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_4451: 40362306a36Sopenharmony_ci /* these chips have no IRQSER setting in MFUNC3 */ 40462306a36Sopenharmony_ci break; 40562306a36Sopenharmony_ci 40662306a36Sopenharmony_ci default: 40762306a36Sopenharmony_ci mfunc = (mfunc & ~TI122X_MFUNC3_MASK) | TI122X_MFUNC3_IRQSER; 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_ci /* write down if changed, probe */ 41062306a36Sopenharmony_ci if (mfunc != mfunc_old) { 41162306a36Sopenharmony_ci config_writel(socket, TI122X_MFUNC, mfunc); 41262306a36Sopenharmony_ci 41362306a36Sopenharmony_ci pci_irq_status = yenta_probe_cb_irq(socket); 41462306a36Sopenharmony_ci if (pci_irq_status == 1) { 41562306a36Sopenharmony_ci dev_info(&socket->dev->dev, 41662306a36Sopenharmony_ci "TI: all-serial interrupts ok\n"); 41762306a36Sopenharmony_ci mfunc_old = mfunc; 41862306a36Sopenharmony_ci goto out; 41962306a36Sopenharmony_ci } 42062306a36Sopenharmony_ci 42162306a36Sopenharmony_ci /* not working, back to old value */ 42262306a36Sopenharmony_ci mfunc = mfunc_old; 42362306a36Sopenharmony_ci config_writel(socket, TI122X_MFUNC, mfunc); 42462306a36Sopenharmony_ci 42562306a36Sopenharmony_ci if (pci_irq_status == -1) 42662306a36Sopenharmony_ci goto out; 42762306a36Sopenharmony_ci } 42862306a36Sopenharmony_ci } 42962306a36Sopenharmony_ci 43062306a36Sopenharmony_ci /* serial PCI interrupts not working fall back to parallel */ 43162306a36Sopenharmony_ci dev_info(&socket->dev->dev, 43262306a36Sopenharmony_ci "TI: falling back to parallel PCI interrupts\n"); 43362306a36Sopenharmony_ci devctl &= ~TI113X_DCR_IMODE_MASK; 43462306a36Sopenharmony_ci devctl |= TI113X_DCR_IMODE_SERIAL; /* serial ISA could be right */ 43562306a36Sopenharmony_ci config_writeb(socket, TI113X_DEVICE_CONTROL, devctl); 43662306a36Sopenharmony_ci } 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_ci /* parallel PCI interrupts: route INTA */ 43962306a36Sopenharmony_ci switch (socket->dev->device) { 44062306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1250: 44162306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251A: 44262306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251B: 44362306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1450: 44462306a36Sopenharmony_ci /* make sure GPIO3 is set to INTA */ 44562306a36Sopenharmony_ci gpio3 = gpio3_old = config_readb(socket, TI1250_GPIO3_CONTROL); 44662306a36Sopenharmony_ci gpio3 &= ~TI1250_GPIO_MODE_MASK; 44762306a36Sopenharmony_ci if (gpio3 != gpio3_old) 44862306a36Sopenharmony_ci config_writeb(socket, TI1250_GPIO3_CONTROL, gpio3); 44962306a36Sopenharmony_ci break; 45062306a36Sopenharmony_ci 45162306a36Sopenharmony_ci default: 45262306a36Sopenharmony_ci gpio3 = gpio3_old = 0; 45362306a36Sopenharmony_ci 45462306a36Sopenharmony_ci mfunc = (mfunc & ~TI122X_MFUNC0_MASK) | TI122X_MFUNC0_INTA; 45562306a36Sopenharmony_ci if (mfunc != mfunc_old) 45662306a36Sopenharmony_ci config_writel(socket, TI122X_MFUNC, mfunc); 45762306a36Sopenharmony_ci } 45862306a36Sopenharmony_ci 45962306a36Sopenharmony_ci /* time to probe again */ 46062306a36Sopenharmony_ci pci_irq_status = yenta_probe_cb_irq(socket); 46162306a36Sopenharmony_ci if (pci_irq_status == 1) { 46262306a36Sopenharmony_ci mfunc_old = mfunc; 46362306a36Sopenharmony_ci dev_info(&socket->dev->dev, "TI: parallel PCI interrupts ok\n"); 46462306a36Sopenharmony_ci } else { 46562306a36Sopenharmony_ci /* not working, back to old value */ 46662306a36Sopenharmony_ci mfunc = mfunc_old; 46762306a36Sopenharmony_ci config_writel(socket, TI122X_MFUNC, mfunc); 46862306a36Sopenharmony_ci if (gpio3 != gpio3_old) 46962306a36Sopenharmony_ci config_writeb(socket, TI1250_GPIO3_CONTROL, gpio3_old); 47062306a36Sopenharmony_ci } 47162306a36Sopenharmony_ci 47262306a36Sopenharmony_ciout: 47362306a36Sopenharmony_ci if (pci_irq_status < 1) { 47462306a36Sopenharmony_ci socket->cb_irq = 0; 47562306a36Sopenharmony_ci dev_info(&socket->dev->dev, 47662306a36Sopenharmony_ci "Yenta TI: no PCI interrupts. Fish. Please report.\n"); 47762306a36Sopenharmony_ci } 47862306a36Sopenharmony_ci} 47962306a36Sopenharmony_ci 48062306a36Sopenharmony_ci 48162306a36Sopenharmony_ci/* changes the irq of func1 to match that of func0 */ 48262306a36Sopenharmony_cistatic int ti12xx_align_irqs(struct yenta_socket *socket, int *old_irq) 48362306a36Sopenharmony_ci{ 48462306a36Sopenharmony_ci struct pci_dev *func0; 48562306a36Sopenharmony_ci 48662306a36Sopenharmony_ci /* find func0 device */ 48762306a36Sopenharmony_ci func0 = pci_get_slot(socket->dev->bus, socket->dev->devfn & ~0x07); 48862306a36Sopenharmony_ci if (!func0) 48962306a36Sopenharmony_ci return 0; 49062306a36Sopenharmony_ci 49162306a36Sopenharmony_ci if (old_irq) 49262306a36Sopenharmony_ci *old_irq = socket->cb_irq; 49362306a36Sopenharmony_ci socket->cb_irq = socket->dev->irq = func0->irq; 49462306a36Sopenharmony_ci 49562306a36Sopenharmony_ci pci_dev_put(func0); 49662306a36Sopenharmony_ci 49762306a36Sopenharmony_ci return 1; 49862306a36Sopenharmony_ci} 49962306a36Sopenharmony_ci 50062306a36Sopenharmony_ci/* 50162306a36Sopenharmony_ci * ties INTA and INTB together. also changes the devices irq to that of 50262306a36Sopenharmony_ci * the function 0 device. call from func1 only. 50362306a36Sopenharmony_ci * returns 1 if INTRTIE changed, 0 otherwise. 50462306a36Sopenharmony_ci */ 50562306a36Sopenharmony_cistatic int ti12xx_tie_interrupts(struct yenta_socket *socket, int *old_irq) 50662306a36Sopenharmony_ci{ 50762306a36Sopenharmony_ci u32 sysctl; 50862306a36Sopenharmony_ci int ret; 50962306a36Sopenharmony_ci 51062306a36Sopenharmony_ci sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL); 51162306a36Sopenharmony_ci if (sysctl & TI122X_SCR_INTRTIE) 51262306a36Sopenharmony_ci return 0; 51362306a36Sopenharmony_ci 51462306a36Sopenharmony_ci /* align */ 51562306a36Sopenharmony_ci ret = ti12xx_align_irqs(socket, old_irq); 51662306a36Sopenharmony_ci if (!ret) 51762306a36Sopenharmony_ci return 0; 51862306a36Sopenharmony_ci 51962306a36Sopenharmony_ci /* tie */ 52062306a36Sopenharmony_ci sysctl |= TI122X_SCR_INTRTIE; 52162306a36Sopenharmony_ci config_writel(socket, TI113X_SYSTEM_CONTROL, sysctl); 52262306a36Sopenharmony_ci 52362306a36Sopenharmony_ci return 1; 52462306a36Sopenharmony_ci} 52562306a36Sopenharmony_ci 52662306a36Sopenharmony_ci/* undo what ti12xx_tie_interrupts() did */ 52762306a36Sopenharmony_cistatic void ti12xx_untie_interrupts(struct yenta_socket *socket, int old_irq) 52862306a36Sopenharmony_ci{ 52962306a36Sopenharmony_ci u32 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL); 53062306a36Sopenharmony_ci sysctl &= ~TI122X_SCR_INTRTIE; 53162306a36Sopenharmony_ci config_writel(socket, TI113X_SYSTEM_CONTROL, sysctl); 53262306a36Sopenharmony_ci 53362306a36Sopenharmony_ci socket->cb_irq = socket->dev->irq = old_irq; 53462306a36Sopenharmony_ci} 53562306a36Sopenharmony_ci 53662306a36Sopenharmony_ci/* 53762306a36Sopenharmony_ci * irqrouting for func1, plays with INTB routing 53862306a36Sopenharmony_ci * only touches MFUNC for INTB routing. all other bits are taken 53962306a36Sopenharmony_ci * care of in func0 already. 54062306a36Sopenharmony_ci */ 54162306a36Sopenharmony_cistatic void ti12xx_irqroute_func1(struct yenta_socket *socket) 54262306a36Sopenharmony_ci{ 54362306a36Sopenharmony_ci u32 mfunc, mfunc_old, devctl, sysctl; 54462306a36Sopenharmony_ci int pci_irq_status; 54562306a36Sopenharmony_ci 54662306a36Sopenharmony_ci mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC); 54762306a36Sopenharmony_ci devctl = config_readb(socket, TI113X_DEVICE_CONTROL); 54862306a36Sopenharmony_ci dev_info(&socket->dev->dev, "TI: mfunc 0x%08x, devctl 0x%02x\n", 54962306a36Sopenharmony_ci mfunc, devctl); 55062306a36Sopenharmony_ci 55162306a36Sopenharmony_ci /* if IRQs are configured as tied, align irq of func1 with func0 */ 55262306a36Sopenharmony_ci sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL); 55362306a36Sopenharmony_ci if (sysctl & TI122X_SCR_INTRTIE) 55462306a36Sopenharmony_ci ti12xx_align_irqs(socket, NULL); 55562306a36Sopenharmony_ci 55662306a36Sopenharmony_ci /* make sure PCI interrupts are enabled before probing */ 55762306a36Sopenharmony_ci ti_init(socket); 55862306a36Sopenharmony_ci 55962306a36Sopenharmony_ci /* test PCI interrupts first. only try fixing if return value is 0! */ 56062306a36Sopenharmony_ci pci_irq_status = yenta_probe_cb_irq(socket); 56162306a36Sopenharmony_ci if (pci_irq_status) 56262306a36Sopenharmony_ci goto out; 56362306a36Sopenharmony_ci 56462306a36Sopenharmony_ci /* 56562306a36Sopenharmony_ci * We're here which means PCI interrupts are _not_ delivered. try to 56662306a36Sopenharmony_ci * find the right setting 56762306a36Sopenharmony_ci */ 56862306a36Sopenharmony_ci dev_info(&socket->dev->dev, 56962306a36Sopenharmony_ci "TI: probing PCI interrupt failed, trying to fix\n"); 57062306a36Sopenharmony_ci 57162306a36Sopenharmony_ci /* if all serial: set INTRTIE, probe again */ 57262306a36Sopenharmony_ci if ((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) { 57362306a36Sopenharmony_ci int old_irq; 57462306a36Sopenharmony_ci 57562306a36Sopenharmony_ci if (ti12xx_tie_interrupts(socket, &old_irq)) { 57662306a36Sopenharmony_ci pci_irq_status = yenta_probe_cb_irq(socket); 57762306a36Sopenharmony_ci if (pci_irq_status == 1) { 57862306a36Sopenharmony_ci dev_info(&socket->dev->dev, 57962306a36Sopenharmony_ci "TI: all-serial interrupts, tied ok\n"); 58062306a36Sopenharmony_ci goto out; 58162306a36Sopenharmony_ci } 58262306a36Sopenharmony_ci 58362306a36Sopenharmony_ci ti12xx_untie_interrupts(socket, old_irq); 58462306a36Sopenharmony_ci } 58562306a36Sopenharmony_ci } 58662306a36Sopenharmony_ci /* parallel PCI: route INTB, probe again */ 58762306a36Sopenharmony_ci else { 58862306a36Sopenharmony_ci int old_irq; 58962306a36Sopenharmony_ci 59062306a36Sopenharmony_ci switch (socket->dev->device) { 59162306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1250: 59262306a36Sopenharmony_ci /* the 1250 has one pin for IRQSER/INTB depending on devctl */ 59362306a36Sopenharmony_ci break; 59462306a36Sopenharmony_ci 59562306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251A: 59662306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251B: 59762306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1450: 59862306a36Sopenharmony_ci /* 59962306a36Sopenharmony_ci * those have a pin for IRQSER/INTB plus INTB in MFUNC0 60062306a36Sopenharmony_ci * we alread probed the shared pin, now go for MFUNC0 60162306a36Sopenharmony_ci */ 60262306a36Sopenharmony_ci mfunc = (mfunc & ~TI122X_MFUNC0_MASK) | TI125X_MFUNC0_INTB; 60362306a36Sopenharmony_ci break; 60462306a36Sopenharmony_ci 60562306a36Sopenharmony_ci default: 60662306a36Sopenharmony_ci mfunc = (mfunc & ~TI122X_MFUNC1_MASK) | TI122X_MFUNC1_INTB; 60762306a36Sopenharmony_ci break; 60862306a36Sopenharmony_ci } 60962306a36Sopenharmony_ci 61062306a36Sopenharmony_ci /* write, probe */ 61162306a36Sopenharmony_ci if (mfunc != mfunc_old) { 61262306a36Sopenharmony_ci config_writel(socket, TI122X_MFUNC, mfunc); 61362306a36Sopenharmony_ci 61462306a36Sopenharmony_ci pci_irq_status = yenta_probe_cb_irq(socket); 61562306a36Sopenharmony_ci if (pci_irq_status == 1) { 61662306a36Sopenharmony_ci dev_info(&socket->dev->dev, 61762306a36Sopenharmony_ci "TI: parallel PCI interrupts ok\n"); 61862306a36Sopenharmony_ci goto out; 61962306a36Sopenharmony_ci } 62062306a36Sopenharmony_ci 62162306a36Sopenharmony_ci mfunc = mfunc_old; 62262306a36Sopenharmony_ci config_writel(socket, TI122X_MFUNC, mfunc); 62362306a36Sopenharmony_ci 62462306a36Sopenharmony_ci if (pci_irq_status == -1) 62562306a36Sopenharmony_ci goto out; 62662306a36Sopenharmony_ci } 62762306a36Sopenharmony_ci 62862306a36Sopenharmony_ci /* still nothing: set INTRTIE */ 62962306a36Sopenharmony_ci if (ti12xx_tie_interrupts(socket, &old_irq)) { 63062306a36Sopenharmony_ci pci_irq_status = yenta_probe_cb_irq(socket); 63162306a36Sopenharmony_ci if (pci_irq_status == 1) { 63262306a36Sopenharmony_ci dev_info(&socket->dev->dev, 63362306a36Sopenharmony_ci "TI: parallel PCI interrupts, tied ok\n"); 63462306a36Sopenharmony_ci goto out; 63562306a36Sopenharmony_ci } 63662306a36Sopenharmony_ci 63762306a36Sopenharmony_ci ti12xx_untie_interrupts(socket, old_irq); 63862306a36Sopenharmony_ci } 63962306a36Sopenharmony_ci } 64062306a36Sopenharmony_ci 64162306a36Sopenharmony_ciout: 64262306a36Sopenharmony_ci if (pci_irq_status < 1) { 64362306a36Sopenharmony_ci socket->cb_irq = 0; 64462306a36Sopenharmony_ci dev_info(&socket->dev->dev, 64562306a36Sopenharmony_ci "TI: no PCI interrupts. Fish. Please report.\n"); 64662306a36Sopenharmony_ci } 64762306a36Sopenharmony_ci} 64862306a36Sopenharmony_ci 64962306a36Sopenharmony_ci 65062306a36Sopenharmony_ci/* Returns true value if the second slot of a two-slot controller is empty */ 65162306a36Sopenharmony_cistatic int ti12xx_2nd_slot_empty(struct yenta_socket *socket) 65262306a36Sopenharmony_ci{ 65362306a36Sopenharmony_ci struct pci_dev *func; 65462306a36Sopenharmony_ci struct yenta_socket *slot2; 65562306a36Sopenharmony_ci int devfn; 65662306a36Sopenharmony_ci unsigned int state; 65762306a36Sopenharmony_ci int ret = 1; 65862306a36Sopenharmony_ci u32 sysctl; 65962306a36Sopenharmony_ci 66062306a36Sopenharmony_ci /* catch the two-slot controllers */ 66162306a36Sopenharmony_ci switch (socket->dev->device) { 66262306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1220: 66362306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1221: 66462306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1225: 66562306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251A: 66662306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251B: 66762306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1420: 66862306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1450: 66962306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1451A: 67062306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1520: 67162306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1620: 67262306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_4520: 67362306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_4450: 67462306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_4451: 67562306a36Sopenharmony_ci /* 67662306a36Sopenharmony_ci * there are way more, but they need to be added in yenta_socket.c 67762306a36Sopenharmony_ci * and pci_ids.h first anyway. 67862306a36Sopenharmony_ci */ 67962306a36Sopenharmony_ci break; 68062306a36Sopenharmony_ci 68162306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_XX12: 68262306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_X515: 68362306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_X420: 68462306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_X620: 68562306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_XX21_XX11: 68662306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_7410: 68762306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_7610: 68862306a36Sopenharmony_ci /* 68962306a36Sopenharmony_ci * those are either single or dual slot CB with additional functions 69062306a36Sopenharmony_ci * like 1394, smartcard reader, etc. check the TIEALL flag for them 69162306a36Sopenharmony_ci * the TIEALL flag binds the IRQ of all functions together. 69262306a36Sopenharmony_ci * we catch the single slot variants later. 69362306a36Sopenharmony_ci */ 69462306a36Sopenharmony_ci sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL); 69562306a36Sopenharmony_ci if (sysctl & TIXX21_SCR_TIEALL) 69662306a36Sopenharmony_ci return 0; 69762306a36Sopenharmony_ci 69862306a36Sopenharmony_ci break; 69962306a36Sopenharmony_ci 70062306a36Sopenharmony_ci /* single-slot controllers have the 2nd slot empty always :) */ 70162306a36Sopenharmony_ci default: 70262306a36Sopenharmony_ci return 1; 70362306a36Sopenharmony_ci } 70462306a36Sopenharmony_ci 70562306a36Sopenharmony_ci /* get other slot */ 70662306a36Sopenharmony_ci devfn = socket->dev->devfn & ~0x07; 70762306a36Sopenharmony_ci func = pci_get_slot(socket->dev->bus, 70862306a36Sopenharmony_ci (socket->dev->devfn & 0x07) ? devfn : devfn | 0x01); 70962306a36Sopenharmony_ci if (!func) 71062306a36Sopenharmony_ci return 1; 71162306a36Sopenharmony_ci 71262306a36Sopenharmony_ci /* 71362306a36Sopenharmony_ci * check that the device id of both slots match. this is needed for the 71462306a36Sopenharmony_ci * XX21 and the XX11 controller that share the same device id for single 71562306a36Sopenharmony_ci * and dual slot controllers. return '2nd slot empty'. we already checked 71662306a36Sopenharmony_ci * if the interrupt is tied to another function. 71762306a36Sopenharmony_ci */ 71862306a36Sopenharmony_ci if (socket->dev->device != func->device) 71962306a36Sopenharmony_ci goto out; 72062306a36Sopenharmony_ci 72162306a36Sopenharmony_ci slot2 = pci_get_drvdata(func); 72262306a36Sopenharmony_ci if (!slot2) 72362306a36Sopenharmony_ci goto out; 72462306a36Sopenharmony_ci 72562306a36Sopenharmony_ci /* check state */ 72662306a36Sopenharmony_ci yenta_get_status(&slot2->socket, &state); 72762306a36Sopenharmony_ci if (state & SS_DETECT) { 72862306a36Sopenharmony_ci ret = 0; 72962306a36Sopenharmony_ci goto out; 73062306a36Sopenharmony_ci } 73162306a36Sopenharmony_ci 73262306a36Sopenharmony_ciout: 73362306a36Sopenharmony_ci pci_dev_put(func); 73462306a36Sopenharmony_ci return ret; 73562306a36Sopenharmony_ci} 73662306a36Sopenharmony_ci 73762306a36Sopenharmony_ci/* 73862306a36Sopenharmony_ci * TI specifiy parts for the power hook. 73962306a36Sopenharmony_ci * 74062306a36Sopenharmony_ci * some TI's with some CB's produces interrupt storm on power on. it has been 74162306a36Sopenharmony_ci * seen with atheros wlan cards on TI1225 and TI1410. solution is simply to 74262306a36Sopenharmony_ci * disable any CB interrupts during this time. 74362306a36Sopenharmony_ci */ 74462306a36Sopenharmony_cistatic int ti12xx_power_hook(struct pcmcia_socket *sock, int operation) 74562306a36Sopenharmony_ci{ 74662306a36Sopenharmony_ci struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); 74762306a36Sopenharmony_ci u32 mfunc, devctl, sysctl; 74862306a36Sopenharmony_ci u8 gpio3; 74962306a36Sopenharmony_ci 75062306a36Sopenharmony_ci /* only POWER_PRE and POWER_POST are interesting */ 75162306a36Sopenharmony_ci if ((operation != HOOK_POWER_PRE) && (operation != HOOK_POWER_POST)) 75262306a36Sopenharmony_ci return 0; 75362306a36Sopenharmony_ci 75462306a36Sopenharmony_ci devctl = config_readb(socket, TI113X_DEVICE_CONTROL); 75562306a36Sopenharmony_ci sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL); 75662306a36Sopenharmony_ci mfunc = config_readl(socket, TI122X_MFUNC); 75762306a36Sopenharmony_ci 75862306a36Sopenharmony_ci /* 75962306a36Sopenharmony_ci * all serial/tied: only disable when modparm set. always doing it 76062306a36Sopenharmony_ci * would mean a regression for working setups 'cos it disables the 76162306a36Sopenharmony_ci * interrupts for both both slots on 2-slot controllers 76262306a36Sopenharmony_ci * (and users of single slot controllers where it's save have to 76362306a36Sopenharmony_ci * live with setting the modparm, most don't have to anyway) 76462306a36Sopenharmony_ci */ 76562306a36Sopenharmony_ci if (((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) && 76662306a36Sopenharmony_ci (pwr_irqs_off || ti12xx_2nd_slot_empty(socket))) { 76762306a36Sopenharmony_ci switch (socket->dev->device) { 76862306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1250: 76962306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251A: 77062306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251B: 77162306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1450: 77262306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1451A: 77362306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_4450: 77462306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_4451: 77562306a36Sopenharmony_ci /* these chips have no IRQSER setting in MFUNC3 */ 77662306a36Sopenharmony_ci break; 77762306a36Sopenharmony_ci 77862306a36Sopenharmony_ci default: 77962306a36Sopenharmony_ci if (operation == HOOK_POWER_PRE) 78062306a36Sopenharmony_ci mfunc = (mfunc & ~TI122X_MFUNC3_MASK); 78162306a36Sopenharmony_ci else 78262306a36Sopenharmony_ci mfunc = (mfunc & ~TI122X_MFUNC3_MASK) | TI122X_MFUNC3_IRQSER; 78362306a36Sopenharmony_ci } 78462306a36Sopenharmony_ci 78562306a36Sopenharmony_ci return 0; 78662306a36Sopenharmony_ci } 78762306a36Sopenharmony_ci 78862306a36Sopenharmony_ci /* do the job differently for func0/1 */ 78962306a36Sopenharmony_ci if ((PCI_FUNC(socket->dev->devfn) == 0) || 79062306a36Sopenharmony_ci ((sysctl & TI122X_SCR_INTRTIE) && 79162306a36Sopenharmony_ci (pwr_irqs_off || ti12xx_2nd_slot_empty(socket)))) { 79262306a36Sopenharmony_ci /* some bridges are different */ 79362306a36Sopenharmony_ci switch (socket->dev->device) { 79462306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1250: 79562306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251A: 79662306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251B: 79762306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1450: 79862306a36Sopenharmony_ci /* those oldies use gpio3 for INTA */ 79962306a36Sopenharmony_ci gpio3 = config_readb(socket, TI1250_GPIO3_CONTROL); 80062306a36Sopenharmony_ci if (operation == HOOK_POWER_PRE) 80162306a36Sopenharmony_ci gpio3 = (gpio3 & ~TI1250_GPIO_MODE_MASK) | 0x40; 80262306a36Sopenharmony_ci else 80362306a36Sopenharmony_ci gpio3 &= ~TI1250_GPIO_MODE_MASK; 80462306a36Sopenharmony_ci config_writeb(socket, TI1250_GPIO3_CONTROL, gpio3); 80562306a36Sopenharmony_ci break; 80662306a36Sopenharmony_ci 80762306a36Sopenharmony_ci default: 80862306a36Sopenharmony_ci /* all new bridges are the same */ 80962306a36Sopenharmony_ci if (operation == HOOK_POWER_PRE) 81062306a36Sopenharmony_ci mfunc &= ~TI122X_MFUNC0_MASK; 81162306a36Sopenharmony_ci else 81262306a36Sopenharmony_ci mfunc |= TI122X_MFUNC0_INTA; 81362306a36Sopenharmony_ci config_writel(socket, TI122X_MFUNC, mfunc); 81462306a36Sopenharmony_ci } 81562306a36Sopenharmony_ci } else { 81662306a36Sopenharmony_ci switch (socket->dev->device) { 81762306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251A: 81862306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1251B: 81962306a36Sopenharmony_ci case PCI_DEVICE_ID_TI_1450: 82062306a36Sopenharmony_ci /* those have INTA elsewhere and INTB in MFUNC0 */ 82162306a36Sopenharmony_ci if (operation == HOOK_POWER_PRE) 82262306a36Sopenharmony_ci mfunc &= ~TI122X_MFUNC0_MASK; 82362306a36Sopenharmony_ci else 82462306a36Sopenharmony_ci mfunc |= TI125X_MFUNC0_INTB; 82562306a36Sopenharmony_ci config_writel(socket, TI122X_MFUNC, mfunc); 82662306a36Sopenharmony_ci 82762306a36Sopenharmony_ci break; 82862306a36Sopenharmony_ci 82962306a36Sopenharmony_ci default: 83062306a36Sopenharmony_ci /* all new bridges are the same */ 83162306a36Sopenharmony_ci if (operation == HOOK_POWER_PRE) 83262306a36Sopenharmony_ci mfunc &= ~TI122X_MFUNC1_MASK; 83362306a36Sopenharmony_ci else 83462306a36Sopenharmony_ci mfunc |= TI122X_MFUNC1_INTB; 83562306a36Sopenharmony_ci config_writel(socket, TI122X_MFUNC, mfunc); 83662306a36Sopenharmony_ci } 83762306a36Sopenharmony_ci } 83862306a36Sopenharmony_ci 83962306a36Sopenharmony_ci return 0; 84062306a36Sopenharmony_ci} 84162306a36Sopenharmony_ci 84262306a36Sopenharmony_cistatic int ti12xx_override(struct yenta_socket *socket) 84362306a36Sopenharmony_ci{ 84462306a36Sopenharmony_ci u32 val, val_orig; 84562306a36Sopenharmony_ci 84662306a36Sopenharmony_ci /* make sure that memory burst is active */ 84762306a36Sopenharmony_ci val_orig = val = config_readl(socket, TI113X_SYSTEM_CONTROL); 84862306a36Sopenharmony_ci if (disable_clkrun && PCI_FUNC(socket->dev->devfn) == 0) { 84962306a36Sopenharmony_ci dev_info(&socket->dev->dev, "Disabling CLKRUN feature\n"); 85062306a36Sopenharmony_ci val |= TI113X_SCR_KEEPCLK; 85162306a36Sopenharmony_ci } 85262306a36Sopenharmony_ci if (!(val & TI122X_SCR_MRBURSTUP)) { 85362306a36Sopenharmony_ci dev_info(&socket->dev->dev, 85462306a36Sopenharmony_ci "Enabling burst memory read transactions\n"); 85562306a36Sopenharmony_ci val |= TI122X_SCR_MRBURSTUP; 85662306a36Sopenharmony_ci } 85762306a36Sopenharmony_ci if (val_orig != val) 85862306a36Sopenharmony_ci config_writel(socket, TI113X_SYSTEM_CONTROL, val); 85962306a36Sopenharmony_ci 86062306a36Sopenharmony_ci /* 86162306a36Sopenharmony_ci * Yenta expects controllers to use CSCINT to route 86262306a36Sopenharmony_ci * CSC interrupts to PCI rather than INTVAL. 86362306a36Sopenharmony_ci */ 86462306a36Sopenharmony_ci val = config_readb(socket, TI1250_DIAGNOSTIC); 86562306a36Sopenharmony_ci dev_info(&socket->dev->dev, "Using %s to route CSC interrupts to PCI\n", 86662306a36Sopenharmony_ci (val & TI1250_DIAG_PCI_CSC) ? "CSCINT" : "INTVAL"); 86762306a36Sopenharmony_ci dev_info(&socket->dev->dev, "Routing CardBus interrupts to %s\n", 86862306a36Sopenharmony_ci (val & TI1250_DIAG_PCI_IREQ) ? "PCI" : "ISA"); 86962306a36Sopenharmony_ci 87062306a36Sopenharmony_ci /* do irqrouting, depending on function */ 87162306a36Sopenharmony_ci if (PCI_FUNC(socket->dev->devfn) == 0) 87262306a36Sopenharmony_ci ti12xx_irqroute_func0(socket); 87362306a36Sopenharmony_ci else 87462306a36Sopenharmony_ci ti12xx_irqroute_func1(socket); 87562306a36Sopenharmony_ci 87662306a36Sopenharmony_ci /* install power hook */ 87762306a36Sopenharmony_ci socket->socket.power_hook = ti12xx_power_hook; 87862306a36Sopenharmony_ci 87962306a36Sopenharmony_ci return ti_override(socket); 88062306a36Sopenharmony_ci} 88162306a36Sopenharmony_ci 88262306a36Sopenharmony_ci 88362306a36Sopenharmony_cistatic int ti1250_override(struct yenta_socket *socket) 88462306a36Sopenharmony_ci{ 88562306a36Sopenharmony_ci u8 old, diag; 88662306a36Sopenharmony_ci 88762306a36Sopenharmony_ci old = config_readb(socket, TI1250_DIAGNOSTIC); 88862306a36Sopenharmony_ci diag = old & ~(TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ); 88962306a36Sopenharmony_ci if (socket->cb_irq) 89062306a36Sopenharmony_ci diag |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ; 89162306a36Sopenharmony_ci 89262306a36Sopenharmony_ci if (diag != old) { 89362306a36Sopenharmony_ci dev_info(&socket->dev->dev, 89462306a36Sopenharmony_ci "adjusting diagnostic: %02x -> %02x\n", 89562306a36Sopenharmony_ci old, diag); 89662306a36Sopenharmony_ci config_writeb(socket, TI1250_DIAGNOSTIC, diag); 89762306a36Sopenharmony_ci } 89862306a36Sopenharmony_ci 89962306a36Sopenharmony_ci return ti12xx_override(socket); 90062306a36Sopenharmony_ci} 90162306a36Sopenharmony_ci 90262306a36Sopenharmony_ci 90362306a36Sopenharmony_ci/** 90462306a36Sopenharmony_ci * EnE specific part. EnE bridges are register compatible with TI bridges but 90562306a36Sopenharmony_ci * have their own test registers and more important their own little problems. 90662306a36Sopenharmony_ci * Some fixup code to make everybody happy (TM). 90762306a36Sopenharmony_ci */ 90862306a36Sopenharmony_ci 90962306a36Sopenharmony_ci#ifdef CONFIG_YENTA_ENE_TUNE 91062306a36Sopenharmony_ci/* 91162306a36Sopenharmony_ci * set/clear various test bits: 91262306a36Sopenharmony_ci * Defaults to clear the bit. 91362306a36Sopenharmony_ci * - mask (u8) defines what bits to change 91462306a36Sopenharmony_ci * - bits (u8) is the values to change them to 91562306a36Sopenharmony_ci * -> it's 91662306a36Sopenharmony_ci * current = (current & ~mask) | bits 91762306a36Sopenharmony_ci */ 91862306a36Sopenharmony_ci/* pci ids of devices that wants to have the bit set */ 91962306a36Sopenharmony_ci#define DEVID(_vend,_dev,_subvend,_subdev,mask,bits) { \ 92062306a36Sopenharmony_ci .vendor = _vend, \ 92162306a36Sopenharmony_ci .device = _dev, \ 92262306a36Sopenharmony_ci .subvendor = _subvend, \ 92362306a36Sopenharmony_ci .subdevice = _subdev, \ 92462306a36Sopenharmony_ci .driver_data = ((mask) << 8 | (bits)), \ 92562306a36Sopenharmony_ci } 92662306a36Sopenharmony_cistatic struct pci_device_id ene_tune_tbl[] = { 92762306a36Sopenharmony_ci /* Echo Audio products based on motorola DSP56301 and DSP56361 */ 92862306a36Sopenharmony_ci DEVID(PCI_VENDOR_ID_MOTOROLA, 0x1801, 0xECC0, PCI_ANY_ID, 92962306a36Sopenharmony_ci ENE_TEST_C9_TLTENABLE | ENE_TEST_C9_PFENABLE, ENE_TEST_C9_TLTENABLE), 93062306a36Sopenharmony_ci DEVID(PCI_VENDOR_ID_MOTOROLA, 0x3410, 0xECC0, PCI_ANY_ID, 93162306a36Sopenharmony_ci ENE_TEST_C9_TLTENABLE | ENE_TEST_C9_PFENABLE, ENE_TEST_C9_TLTENABLE), 93262306a36Sopenharmony_ci 93362306a36Sopenharmony_ci {} 93462306a36Sopenharmony_ci}; 93562306a36Sopenharmony_ci 93662306a36Sopenharmony_cistatic void ene_tune_bridge(struct pcmcia_socket *sock, struct pci_bus *bus) 93762306a36Sopenharmony_ci{ 93862306a36Sopenharmony_ci struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); 93962306a36Sopenharmony_ci struct pci_dev *dev; 94062306a36Sopenharmony_ci struct pci_device_id *id = NULL; 94162306a36Sopenharmony_ci u8 test_c9, old_c9, mask, bits; 94262306a36Sopenharmony_ci 94362306a36Sopenharmony_ci list_for_each_entry(dev, &bus->devices, bus_list) { 94462306a36Sopenharmony_ci id = (struct pci_device_id *) pci_match_id(ene_tune_tbl, dev); 94562306a36Sopenharmony_ci if (id) 94662306a36Sopenharmony_ci break; 94762306a36Sopenharmony_ci } 94862306a36Sopenharmony_ci 94962306a36Sopenharmony_ci test_c9 = old_c9 = config_readb(socket, ENE_TEST_C9); 95062306a36Sopenharmony_ci if (id) { 95162306a36Sopenharmony_ci mask = (id->driver_data >> 8) & 0xFF; 95262306a36Sopenharmony_ci bits = id->driver_data & 0xFF; 95362306a36Sopenharmony_ci 95462306a36Sopenharmony_ci test_c9 = (test_c9 & ~mask) | bits; 95562306a36Sopenharmony_ci } 95662306a36Sopenharmony_ci else 95762306a36Sopenharmony_ci /* default to clear TLTEnable bit, old behaviour */ 95862306a36Sopenharmony_ci test_c9 &= ~ENE_TEST_C9_TLTENABLE; 95962306a36Sopenharmony_ci 96062306a36Sopenharmony_ci dev_info(&socket->dev->dev, 96162306a36Sopenharmony_ci "EnE: changing testregister 0xC9, %02x -> %02x\n", 96262306a36Sopenharmony_ci old_c9, test_c9); 96362306a36Sopenharmony_ci config_writeb(socket, ENE_TEST_C9, test_c9); 96462306a36Sopenharmony_ci} 96562306a36Sopenharmony_ci 96662306a36Sopenharmony_cistatic int ene_override(struct yenta_socket *socket) 96762306a36Sopenharmony_ci{ 96862306a36Sopenharmony_ci /* install tune_bridge() function */ 96962306a36Sopenharmony_ci socket->socket.tune_bridge = ene_tune_bridge; 97062306a36Sopenharmony_ci 97162306a36Sopenharmony_ci return ti1250_override(socket); 97262306a36Sopenharmony_ci} 97362306a36Sopenharmony_ci#else 97462306a36Sopenharmony_ci# define ene_override ti1250_override 97562306a36Sopenharmony_ci#endif /* !CONFIG_YENTA_ENE_TUNE */ 97662306a36Sopenharmony_ci 97762306a36Sopenharmony_ci#endif /* _LINUX_TI113X_H */ 97862306a36Sopenharmony_ci 979