···11+/*22+ * Toshiba rbtx4938 pci routines33+ * Copyright (C) 2000-2001 Toshiba Corporation44+ *55+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the66+ * terms of the GNU General Public License version 2. This program is77+ * licensed "as is" without any warranty of any kind, whether express88+ * or implied.99+ *1010+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1111+ */1212+#include <linux/types.h>1313+#include <linux/pci.h>1414+#include <linux/kernel.h>1515+#include <linux/init.h>1616+1717+#include <asm/tx4938/rbtx4938.h>1818+1919+extern struct pci_controller tx4938_pci_controller[];2020+2121+int pci_get_irq(struct pci_dev *dev, int pin)2222+{2323+ int irq = pin;2424+ u8 slot = PCI_SLOT(dev->devfn);2525+ struct pci_controller *controller = (struct pci_controller *)dev->sysdata;2626+2727+ if (controller == &tx4938_pci_controller[1]) {2828+ /* TX4938 PCIC1 */2929+ switch (slot) {3030+ case TX4938_PCIC_IDSEL_AD_TO_SLOT(31):3131+ if (tx4938_ccfgptr->pcfg & TX4938_PCFG_ETH0_SEL)3232+ return RBTX4938_IRQ_IRC + TX4938_IR_ETH0;3333+ break;3434+ case TX4938_PCIC_IDSEL_AD_TO_SLOT(30):3535+ if (tx4938_ccfgptr->pcfg & TX4938_PCFG_ETH1_SEL)3636+ return RBTX4938_IRQ_IRC + TX4938_IR_ETH1;3737+ break;3838+ }3939+ return 0;4040+ }4141+4242+ /* IRQ rotation */4343+ irq--; /* 0-3 */4444+ if (dev->bus->parent == NULL &&4545+ (slot == TX4938_PCIC_IDSEL_AD_TO_SLOT(23))) {4646+ /* PCI CardSlot (IDSEL=A23) */4747+ /* PCIA => PCIA (IDSEL=A23) */4848+ irq = (irq + 0 + slot) % 4;4949+ } else {5050+ /* PCI Backplane */5151+ irq = (irq + 33 - slot) % 4;5252+ }5353+ irq++; /* 1-4 */5454+5555+ switch (irq) {5656+ case 1:5757+ irq = RBTX4938_IRQ_IOC_PCIA;5858+ break;5959+ case 2:6060+ irq = RBTX4938_IRQ_IOC_PCIB;6161+ break;6262+ case 3:6363+ irq = RBTX4938_IRQ_IOC_PCIC;6464+ break;6565+ case 4:6666+ irq = RBTX4938_IRQ_IOC_PCID;6767+ break;6868+ }6969+ return irq;7070+}7171+7272+int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)7373+{7474+ unsigned char irq = 0;7575+7676+ irq = pci_get_irq(dev, pin);7777+7878+ printk(KERN_INFO "PCI: 0x%02x:0x%02x(0x%02x,0x%02x) IRQ=%d\n",7979+ dev->bus->number, dev->devfn, PCI_SLOT(dev->devfn),8080+ PCI_FUNC(dev->devfn), irq);8181+8282+ return irq;8383+}8484+8585+/*8686+ * Do platform specific device initialization at pci_enable_device() time8787+ */8888+int pcibios_plat_dev_init(struct pci_dev *dev)8989+{9090+ return 0;9191+}9292+
+198
arch/mips/pci/ops-tx4938.c
···11+/*22+ * Define the pci_ops for the Toshiba rbtx493833+ * Copyright (C) 2000-2001 Toshiba Corporation44+ *55+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the66+ * terms of the GNU General Public License version 2. This program is77+ * licensed "as is" without any warranty of any kind, whether express88+ * or implied.99+ *1010+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1111+ */1212+#include <linux/types.h>1313+#include <linux/pci.h>1414+#include <linux/kernel.h>1515+#include <linux/init.h>1616+1717+#include <asm/addrspace.h>1818+#include <asm/tx4938/rbtx4938.h>1919+2020+/* initialize in setup */2121+struct resource pci_io_resource = {2222+ .name = "pci IO space",2323+ .start = 0,2424+ .end = 0,2525+ .flags = IORESOURCE_IO2626+};2727+2828+/* initialize in setup */2929+struct resource pci_mem_resource = {3030+ .name = "pci memory space",3131+ .start = 0,3232+ .end = 0,3333+ .flags = IORESOURCE_MEM3434+};3535+3636+struct resource tx4938_pcic1_pci_io_resource = {3737+ .name = "PCI1 IO",3838+ .start = 0,3939+ .end = 0,4040+ .flags = IORESOURCE_IO4141+};4242+struct resource tx4938_pcic1_pci_mem_resource = {4343+ .name = "PCI1 mem",4444+ .start = 0,4545+ .end = 0,4646+ .flags = IORESOURCE_MEM4747+};4848+4949+static int mkaddr(int bus, int dev_fn, int where, int *flagsp)5050+{5151+ if (bus > 0) {5252+ /* Type 1 configuration */5353+ tx4938_pcicptr->g2pcfgadrs = ((bus & 0xff) << 0x10) |5454+ ((dev_fn & 0xff) << 0x08) | (where & 0xfc) | 1;5555+ } else {5656+ if (dev_fn >= PCI_DEVFN(TX4938_PCIC_MAX_DEVNU, 0))5757+ return -1;5858+5959+ /* Type 0 configuration */6060+ tx4938_pcicptr->g2pcfgadrs = ((bus & 0xff) << 0x10) |6161+ ((dev_fn & 0xff) << 0x08) | (where & 0xfc);6262+ }6363+ /* clear M_ABORT and Disable M_ABORT Int. */6464+ tx4938_pcicptr->pcistatus =6565+ (tx4938_pcicptr->pcistatus & 0x0000ffff) |6666+ (PCI_STATUS_REC_MASTER_ABORT << 16);6767+ tx4938_pcicptr->pcimask &= ~PCI_STATUS_REC_MASTER_ABORT;6868+6969+ return 0;7070+}7171+7272+static int check_abort(int flags)7373+{7474+ int code = PCIBIOS_SUCCESSFUL;7575+ /* wait write cycle completion before checking error status */7676+ while (tx4938_pcicptr->pcicstatus & TX4938_PCIC_PCICSTATUS_IWB)7777+ ;7878+ if (tx4938_pcicptr->pcistatus & (PCI_STATUS_REC_MASTER_ABORT << 16)) {7979+ tx4938_pcicptr->pcistatus =8080+ (tx4938_pcicptr->8181+ pcistatus & 0x0000ffff) | (PCI_STATUS_REC_MASTER_ABORT8282+ << 16);8383+ tx4938_pcicptr->pcimask |= PCI_STATUS_REC_MASTER_ABORT;8484+ code = PCIBIOS_DEVICE_NOT_FOUND;8585+ }8686+ return code;8787+}8888+8989+static int tx4938_pcibios_read_config(struct pci_bus *bus, unsigned int devfn,9090+ int where, int size, u32 * val)9191+{9292+ int flags, retval, dev, busno, func;9393+9494+ dev = PCI_SLOT(devfn);9595+ func = PCI_FUNC(devfn);9696+9797+ /* check if the bus is top-level */9898+ if (bus->parent != NULL)9999+ busno = bus->number;100100+ else {101101+ busno = 0;102102+ }103103+104104+ if (mkaddr(busno, devfn, where, &flags))105105+ return -1;106106+107107+ switch (size) {108108+ case 1:109109+ *val = *(volatile u8 *) ((ulong) & tx4938_pcicptr->g2pcfgdata |110110+#ifdef __BIG_ENDIAN111111+ ((where & 3) ^ 3));112112+#else113113+ (where & 3));114114+#endif115115+ break;116116+ case 2:117117+ *val = *(volatile u16 *) ((ulong) & tx4938_pcicptr->g2pcfgdata |118118+#ifdef __BIG_ENDIAN119119+ ((where & 3) ^ 2));120120+#else121121+ (where & 3));122122+#endif123123+ break;124124+ case 4:125125+ *val = tx4938_pcicptr->g2pcfgdata;126126+ break;127127+ }128128+129129+ retval = check_abort(flags);130130+ if (retval == PCIBIOS_DEVICE_NOT_FOUND)131131+ *val = 0xffffffff;132132+133133+ return retval;134134+}135135+136136+static int tx4938_pcibios_write_config(struct pci_bus *bus, unsigned int devfn, int where,137137+ int size, u32 val)138138+{139139+ int flags, dev, busno, func;140140+141141+ busno = bus->number;142142+ dev = PCI_SLOT(devfn);143143+ func = PCI_FUNC(devfn);144144+145145+ /* check if the bus is top-level */146146+ if (bus->parent != NULL) {147147+ busno = bus->number;148148+ } else {149149+ busno = 0;150150+ }151151+152152+ if (mkaddr(busno, devfn, where, &flags))153153+ return -1;154154+155155+ switch (size) {156156+ case 1:157157+ *(volatile u8 *) ((ulong) & tx4938_pcicptr->g2pcfgdata |158158+#ifdef __BIG_ENDIAN159159+ ((where & 3) ^ 3)) = val;160160+#else161161+ (where & 3)) = val;162162+#endif163163+ break;164164+ case 2:165165+ *(volatile u16 *) ((ulong) & tx4938_pcicptr->g2pcfgdata |166166+#ifdef __BIG_ENDIAN167167+ ((where & 0x3) ^ 0x2)) = val;168168+#else169169+ (where & 3)) = val;170170+#endif171171+ break;172172+ case 4:173173+ tx4938_pcicptr->g2pcfgdata = val;174174+ break;175175+ }176176+177177+ return check_abort(flags);178178+}179179+180180+struct pci_ops tx4938_pci_ops = {181181+ tx4938_pcibios_read_config,182182+ tx4938_pcibios_write_config183183+};184184+185185+struct pci_controller tx4938_pci_controller[] = {186186+ /* h/w only supports devices 0x00 to 0x14 */187187+ {188188+ .pci_ops = &tx4938_pci_ops,189189+ .io_resource = &pci_io_resource,190190+ .mem_resource = &pci_mem_resource,191191+ },192192+ /* h/w only supports devices 0x00 to 0x14 */193193+ {194194+ .pci_ops = &tx4938_pci_ops,195195+ .io_resource = &tx4938_pcic1_pci_io_resource,196196+ .mem_resource = &tx4938_pcic1_pci_mem_resource,197197+ }198198+};
+24
arch/mips/tx4938/Kconfig
···11+if TOSHIBA_RBTX493822+33+comment "Multiplex Pin Select"44+choice55+ prompt "PIO[58:61]"66+ default TOSHIBA_RBTX4938_MPLEX_PIO58_6177+88+config TOSHIBA_RBTX4938_MPLEX_PIO58_6199+ bool "PIO"1010+config TOSHIBA_RBTX4938_MPLEX_NAND1111+ bool "NAND"1212+config TOSHIBA_RBTX4938_MPLEX_ATA1313+ bool "ATA"1414+1515+endchoice1616+1717+config TX4938_NAND_BOOT1818+ depends on EXPERIMENTAL && TOSHIBA_RBTX4938_MPLEX_NAND1919+ bool "NAND Boot Support (EXPERIMENTAL)"2020+ help2121+ This is only for Toshiba RBTX4938 reference board, which has NAND IPL.2222+ Select this option if you need to use NAND boot.2323+2424+endif
+11
arch/mips/tx4938/common/Makefile
···11+#22+# Makefile for common code for Toshiba TX4927 based systems33+#44+# Note! Dependencies are done automagically by 'make dep', which also55+# removes any old dependencies. DON'T put your own dependencies here66+# unless it's something special (ie not a .c file).77+#88+99+obj-y += prom.o setup.o irq.o irq_handler.o rtc_rx5c348.o1010+obj-$(CONFIG_KGDB) += dbgio.o1111+
+50
arch/mips/tx4938/common/dbgio.c
···11+/*22+ * linux/arch/mips/tx4938/common/dbgio.c33+ *44+ * kgdb interface for gdb55+ *66+ * Author: MontaVista Software, Inc.77+ * source@mvista.com88+ *99+ * Copyright 2005 MontaVista Software Inc.1010+ *1111+ * This program is free software; you can redistribute it and/or modify it1212+ * under the terms of the GNU General Public License as published by the1313+ * Free Software Foundation; either version 2 of the License, or (at your1414+ * option) any later version.1515+ *1616+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED1717+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF1818+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.1919+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,2020+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,2121+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS2222+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND2323+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR2424+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE2525+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2626+ *2727+ * You should have received a copy of the GNU General Public License along2828+ * with this program; if not, write to the Free Software Foundation, Inc.,2929+ * 675 Mass Ave, Cambridge, MA 02139, USA.3030+ *3131+ * Support for TX4938 in 2.6 - Hiroshi DOYU <Hiroshi_DOYU@montavista.co.jp>3232+ */3333+3434+#include <asm/mipsregs.h>3535+#include <asm/system.h>3636+#include <asm/tx4938/tx4938_mips.h>3737+3838+extern u8 txx9_sio_kdbg_rd(void);3939+extern int txx9_sio_kdbg_wr( u8 ch );4040+4141+u8 getDebugChar(void)4242+{4343+ return (txx9_sio_kdbg_rd());4444+}4545+4646+int putDebugChar(u8 byte)4747+{4848+ return (txx9_sio_kdbg_wr(byte));4949+}5050+
+424
arch/mips/tx4938/common/irq.c
···11+/*22+ * linux/arch/mps/tx4938/common/irq.c33+ *44+ * Common tx4938 irq handler55+ * Copyright (C) 2000-2001 Toshiba Corporation66+ *77+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the88+ * terms of the GNU General Public License version 2. This program is99+ * licensed "as is" without any warranty of any kind, whether express1010+ * or implied.1111+ *1212+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1313+ */1414+#include <linux/errno.h>1515+#include <linux/init.h>1616+#include <linux/kernel_stat.h>1717+#include <linux/module.h>1818+#include <linux/signal.h>1919+#include <linux/sched.h>2020+#include <linux/types.h>2121+#include <linux/interrupt.h>2222+#include <linux/ioport.h>2323+#include <linux/timex.h>2424+#include <linux/slab.h>2525+#include <linux/random.h>2626+#include <linux/irq.h>2727+#include <asm/bitops.h>2828+#include <asm/bootinfo.h>2929+#include <asm/io.h>3030+#include <asm/irq.h>3131+#include <asm/mipsregs.h>3232+#include <asm/system.h>3333+#include <asm/tx4938/rbtx4938.h>3434+3535+/**********************************************************************************/3636+/* Forwad definitions for all pic's */3737+/**********************************************************************************/3838+3939+static unsigned int tx4938_irq_cp0_startup(unsigned int irq);4040+static void tx4938_irq_cp0_shutdown(unsigned int irq);4141+static void tx4938_irq_cp0_enable(unsigned int irq);4242+static void tx4938_irq_cp0_disable(unsigned int irq);4343+static void tx4938_irq_cp0_mask_and_ack(unsigned int irq);4444+static void tx4938_irq_cp0_end(unsigned int irq);4545+4646+static unsigned int tx4938_irq_pic_startup(unsigned int irq);4747+static void tx4938_irq_pic_shutdown(unsigned int irq);4848+static void tx4938_irq_pic_enable(unsigned int irq);4949+static void tx4938_irq_pic_disable(unsigned int irq);5050+static void tx4938_irq_pic_mask_and_ack(unsigned int irq);5151+static void tx4938_irq_pic_end(unsigned int irq);5252+5353+/**********************************************************************************/5454+/* Kernel structs for all pic's */5555+/**********************************************************************************/5656+DEFINE_SPINLOCK(tx4938_cp0_lock);5757+DEFINE_SPINLOCK(tx4938_pic_lock);5858+5959+#define TX4938_CP0_NAME "TX4938-CP0"6060+static struct hw_interrupt_type tx4938_irq_cp0_type = {6161+ .typename = TX4938_CP0_NAME,6262+ .startup = tx4938_irq_cp0_startup,6363+ .shutdown = tx4938_irq_cp0_shutdown,6464+ .enable = tx4938_irq_cp0_enable,6565+ .disable = tx4938_irq_cp0_disable,6666+ .ack = tx4938_irq_cp0_mask_and_ack,6767+ .end = tx4938_irq_cp0_end,6868+ .set_affinity = NULL6969+};7070+7171+#define TX4938_PIC_NAME "TX4938-PIC"7272+static struct hw_interrupt_type tx4938_irq_pic_type = {7373+ .typename = TX4938_PIC_NAME,7474+ .startup = tx4938_irq_pic_startup,7575+ .shutdown = tx4938_irq_pic_shutdown,7676+ .enable = tx4938_irq_pic_enable,7777+ .disable = tx4938_irq_pic_disable,7878+ .ack = tx4938_irq_pic_mask_and_ack,7979+ .end = tx4938_irq_pic_end,8080+ .set_affinity = NULL8181+};8282+8383+static struct irqaction tx4938_irq_pic_action = {8484+ .handler = no_action,8585+ .flags = 0,8686+ .mask = CPU_MASK_NONE,8787+ .name = TX4938_PIC_NAME8888+};8989+9090+/**********************************************************************************/9191+/* Functions for cp0 */9292+/**********************************************************************************/9393+9494+#define tx4938_irq_cp0_mask(irq) ( 1 << ( irq-TX4938_IRQ_CP0_BEG+8 ) )9595+9696+static void __init9797+tx4938_irq_cp0_init(void)9898+{9999+ int i;100100+101101+ for (i = TX4938_IRQ_CP0_BEG; i <= TX4938_IRQ_CP0_END; i++) {102102+ irq_desc[i].status = IRQ_DISABLED;103103+ irq_desc[i].action = 0;104104+ irq_desc[i].depth = 1;105105+ irq_desc[i].handler = &tx4938_irq_cp0_type;106106+ }107107+108108+ return;109109+}110110+111111+static unsigned int112112+tx4938_irq_cp0_startup(unsigned int irq)113113+{114114+ tx4938_irq_cp0_enable(irq);115115+116116+ return (0);117117+}118118+119119+static void120120+tx4938_irq_cp0_shutdown(unsigned int irq)121121+{122122+ tx4938_irq_cp0_disable(irq);123123+}124124+125125+static void126126+tx4938_irq_cp0_enable(unsigned int irq)127127+{128128+ unsigned long flags;129129+130130+ spin_lock_irqsave(&tx4938_cp0_lock, flags);131131+132132+ set_c0_status(tx4938_irq_cp0_mask(irq));133133+134134+ spin_unlock_irqrestore(&tx4938_cp0_lock, flags);135135+}136136+137137+static void138138+tx4938_irq_cp0_disable(unsigned int irq)139139+{140140+ unsigned long flags;141141+142142+ spin_lock_irqsave(&tx4938_cp0_lock, flags);143143+144144+ clear_c0_status(tx4938_irq_cp0_mask(irq));145145+146146+ spin_unlock_irqrestore(&tx4938_cp0_lock, flags);147147+148148+ return;149149+}150150+151151+static void152152+tx4938_irq_cp0_mask_and_ack(unsigned int irq)153153+{154154+ tx4938_irq_cp0_disable(irq);155155+156156+ return;157157+}158158+159159+static void160160+tx4938_irq_cp0_end(unsigned int irq)161161+{162162+ if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {163163+ tx4938_irq_cp0_enable(irq);164164+ }165165+166166+ return;167167+}168168+169169+/**********************************************************************************/170170+/* Functions for pic */171171+/**********************************************************************************/172172+173173+u32174174+tx4938_irq_pic_addr(int irq)175175+{176176+ /* MVMCP -- need to formulize this */177177+ irq -= TX4938_IRQ_PIC_BEG;178178+179179+ switch (irq) {180180+ case 17:181181+ case 16:182182+ case 1:183183+ case 0:{184184+ return (TX4938_MKA(TX4938_IRC_IRLVL0));185185+ }186186+ case 19:187187+ case 18:188188+ case 3:189189+ case 2:{190190+ return (TX4938_MKA(TX4938_IRC_IRLVL1));191191+ }192192+ case 21:193193+ case 20:194194+ case 5:195195+ case 4:{196196+ return (TX4938_MKA(TX4938_IRC_IRLVL2));197197+ }198198+ case 23:199199+ case 22:200200+ case 7:201201+ case 6:{202202+ return (TX4938_MKA(TX4938_IRC_IRLVL3));203203+ }204204+ case 25:205205+ case 24:206206+ case 9:207207+ case 8:{208208+ return (TX4938_MKA(TX4938_IRC_IRLVL4));209209+ }210210+ case 27:211211+ case 26:212212+ case 11:213213+ case 10:{214214+ return (TX4938_MKA(TX4938_IRC_IRLVL5));215215+ }216216+ case 29:217217+ case 28:218218+ case 13:219219+ case 12:{220220+ return (TX4938_MKA(TX4938_IRC_IRLVL6));221221+ }222222+ case 31:223223+ case 30:224224+ case 15:225225+ case 14:{226226+ return (TX4938_MKA(TX4938_IRC_IRLVL7));227227+ }228228+ }229229+230230+ return (0);231231+}232232+233233+u32234234+tx4938_irq_pic_mask(int irq)235235+{236236+ /* MVMCP -- need to formulize this */237237+ irq -= TX4938_IRQ_PIC_BEG;238238+239239+ switch (irq) {240240+ case 31:241241+ case 29:242242+ case 27:243243+ case 25:244244+ case 23:245245+ case 21:246246+ case 19:247247+ case 17:{248248+ return (0x07000000);249249+ }250250+ case 30:251251+ case 28:252252+ case 26:253253+ case 24:254254+ case 22:255255+ case 20:256256+ case 18:257257+ case 16:{258258+ return (0x00070000);259259+ }260260+ case 15:261261+ case 13:262262+ case 11:263263+ case 9:264264+ case 7:265265+ case 5:266266+ case 3:267267+ case 1:{268268+ return (0x00000700);269269+ }270270+ case 14:271271+ case 12:272272+ case 10:273273+ case 8:274274+ case 6:275275+ case 4:276276+ case 2:277277+ case 0:{278278+ return (0x00000007);279279+ }280280+ }281281+ return (0x00000000);282282+}283283+284284+static void285285+tx4938_irq_pic_modify(unsigned pic_reg, unsigned clr_bits, unsigned set_bits)286286+{287287+ unsigned long val = 0;288288+289289+ val = TX4938_RD(pic_reg);290290+ val &= (~clr_bits);291291+ val |= (set_bits);292292+ TX4938_WR(pic_reg, val);293293+ mmiowb();294294+ TX4938_RD(pic_reg);295295+296296+ return;297297+}298298+299299+static void __init300300+tx4938_irq_pic_init(void)301301+{302302+ unsigned long flags;303303+ int i;304304+305305+ for (i = TX4938_IRQ_PIC_BEG; i <= TX4938_IRQ_PIC_END; i++) {306306+ irq_desc[i].status = IRQ_DISABLED;307307+ irq_desc[i].action = 0;308308+ irq_desc[i].depth = 2;309309+ irq_desc[i].handler = &tx4938_irq_pic_type;310310+ }311311+312312+ setup_irq(TX4938_IRQ_NEST_PIC_ON_CP0, &tx4938_irq_pic_action);313313+314314+ spin_lock_irqsave(&tx4938_pic_lock, flags);315315+316316+ TX4938_WR(0xff1ff640, 0x6); /* irq level mask -- only accept hightest */317317+ TX4938_WR(0xff1ff600, TX4938_RD(0xff1ff600) | 0x1); /* irq enable */318318+319319+ spin_unlock_irqrestore(&tx4938_pic_lock, flags);320320+321321+ return;322322+}323323+324324+static unsigned int325325+tx4938_irq_pic_startup(unsigned int irq)326326+{327327+ tx4938_irq_pic_enable(irq);328328+329329+ return (0);330330+}331331+332332+static void333333+tx4938_irq_pic_shutdown(unsigned int irq)334334+{335335+ tx4938_irq_pic_disable(irq);336336+337337+ return;338338+}339339+340340+static void341341+tx4938_irq_pic_enable(unsigned int irq)342342+{343343+ unsigned long flags;344344+345345+ spin_lock_irqsave(&tx4938_pic_lock, flags);346346+347347+ tx4938_irq_pic_modify(tx4938_irq_pic_addr(irq), 0,348348+ tx4938_irq_pic_mask(irq));349349+350350+ spin_unlock_irqrestore(&tx4938_pic_lock, flags);351351+352352+ return;353353+}354354+355355+static void356356+tx4938_irq_pic_disable(unsigned int irq)357357+{358358+ unsigned long flags;359359+360360+ spin_lock_irqsave(&tx4938_pic_lock, flags);361361+362362+ tx4938_irq_pic_modify(tx4938_irq_pic_addr(irq),363363+ tx4938_irq_pic_mask(irq), 0);364364+365365+ spin_unlock_irqrestore(&tx4938_pic_lock, flags);366366+367367+ return;368368+}369369+370370+static void371371+tx4938_irq_pic_mask_and_ack(unsigned int irq)372372+{373373+ tx4938_irq_pic_disable(irq);374374+375375+ return;376376+}377377+378378+static void379379+tx4938_irq_pic_end(unsigned int irq)380380+{381381+ if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {382382+ tx4938_irq_pic_enable(irq);383383+ }384384+385385+ return;386386+}387387+388388+/**********************************************************************************/389389+/* Main init functions */390390+/**********************************************************************************/391391+392392+void __init393393+tx4938_irq_init(void)394394+{395395+ extern asmlinkage void tx4938_irq_handler(void);396396+397397+ tx4938_irq_cp0_init();398398+ tx4938_irq_pic_init();399399+ set_except_vector(0, tx4938_irq_handler);400400+401401+ return;402402+}403403+404404+int405405+tx4938_irq_nested(void)406406+{407407+ int sw_irq = 0;408408+ u32 level2;409409+410410+ level2 = TX4938_RD(0xff1ff6a0);411411+ if ((level2 & 0x10000) == 0) {412412+ level2 &= 0x1f;413413+ sw_irq = TX4938_IRQ_PIC_BEG + level2;414414+ if (sw_irq == 26) {415415+ {416416+ extern int toshiba_rbtx4938_irq_nested(int sw_irq);417417+ sw_irq = toshiba_rbtx4938_irq_nested(sw_irq);418418+ }419419+ }420420+ }421421+422422+ wbflush();423423+ return (sw_irq);424424+}
+84
arch/mips/tx4938/common/irq_handler.S
···11+/*22+ * linux/arch/mips/tx4938/common/handler.S33+ *44+ * Primary interrupt handler for tx4938 based systems55+ * Copyright (C) 2000-2001 Toshiba Corporation66+ *77+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the88+ * terms of the GNU General Public License version 2. This program is99+ * licensed "as is" without any warranty of any kind, whether express1010+ * or implied.1111+ *1212+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1313+ */1414+#include <asm/asm.h>1515+#include <asm/mipsregs.h>1616+#include <asm/addrspace.h>1717+#include <asm/regdef.h>1818+#include <asm/stackframe.h>1919+#include <asm/tx4938/rbtx4938.h>2020+2121+2222+ .align 52323+ NESTED(tx4938_irq_handler, PT_SIZE, sp)2424+ SAVE_ALL2525+ CLI2626+ .set at2727+2828+ mfc0 t0, CP0_CAUSE2929+ mfc0 t1, CP0_STATUS3030+ and t0, t13131+3232+ andi t1, t0, STATUSF_IP7 /* cpu timer */3333+ bnez t1, ll_ip73434+3535+ /* IP6..IP3 multiplexed -- do not use */3636+3737+ andi t1, t0, STATUSF_IP2 /* tx4938 pic */3838+ bnez t1, ll_ip23939+4040+ andi t1, t0, STATUSF_IP1 /* user line 1 */4141+ bnez t1, ll_ip14242+4343+ andi t1, t0, STATUSF_IP0 /* user line 0 */4444+ bnez t1, ll_ip04545+4646+ .set reorder4747+4848+ nop4949+ END(tx4938_irq_handler)5050+5151+ .align 55252+5353+5454+ll_ip7:5555+ li a0, TX4938_IRQ_CPU_TIMER5656+ move a1, sp5757+ jal do_IRQ5858+ j ret_from_irq5959+6060+6161+ll_ip2:6262+ jal tx4938_irq_nested6363+ nop6464+ beqz v0, goto_spurious_interrupt6565+ nop6666+ move a0, v06767+ move a1, sp6868+ jal do_IRQ6969+ j ret_from_irq7070+7171+goto_spurious_interrupt:7272+ j ret_from_irq7373+7474+ll_ip1:7575+ li a0, TX4938_IRQ_USER17676+ move a1, sp7777+ jal do_IRQ7878+ j ret_from_irq7979+8080+ll_ip0:8181+ li a0, TX4938_IRQ_USER08282+ move a1, sp8383+ jal do_IRQ8484+ j ret_from_irq
+129
arch/mips/tx4938/common/prom.c
···11+/*22+ * linux/arch/mips/tx4938/common/prom.c33+ *44+ * common tx4938 memory interface55+ * Copyright (C) 2000-2001 Toshiba Corporation66+ *77+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the88+ * terms of the GNU General Public License version 2. This program is99+ * licensed "as is" without any warranty of any kind, whether express1010+ * or implied.1111+ *1212+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1313+ */1414+1515+#include <linux/init.h>1616+#include <linux/mm.h>1717+#include <linux/sched.h>1818+#include <linux/bootmem.h>1919+2020+#include <asm/addrspace.h>2121+#include <asm/bootinfo.h>2222+#include <asm/tx4938/tx4938.h>2323+2424+static unsigned int __init2525+tx4938_process_sdccr(u64 * addr)2626+{2727+ u64 val;2828+ unsigned int sdccr_ce;2929+ unsigned int sdccr_rs;3030+ unsigned int sdccr_cs;3131+ unsigned int sdccr_mw;3232+ unsigned int rs = 0;3333+ unsigned int cs = 0;3434+ unsigned int mw = 0;3535+ unsigned int bc = 4;3636+ unsigned int msize = 0;3737+3838+ val = (*((vu64 *) (addr)));3939+4040+ /* MVMCP -- need #defs for these bits masks */4141+ sdccr_ce = ((val & (1 << 10)) >> 10);4242+ sdccr_rs = ((val & (3 << 5)) >> 5);4343+ sdccr_cs = ((val & (7 << 2)) >> 2);4444+ sdccr_mw = ((val & (1 << 0)) >> 0);4545+4646+ if (sdccr_ce) {4747+ switch (sdccr_rs) {4848+ case 0:{4949+ rs = 2048;5050+ break;5151+ }5252+ case 1:{5353+ rs = 4096;5454+ break;5555+ }5656+ case 2:{5757+ rs = 8192;5858+ break;5959+ }6060+ default:{6161+ rs = 0;6262+ break;6363+ }6464+ }6565+ switch (sdccr_cs) {6666+ case 0:{6767+ cs = 256;6868+ break;6969+ }7070+ case 1:{7171+ cs = 512;7272+ break;7373+ }7474+ case 2:{7575+ cs = 1024;7676+ break;7777+ }7878+ case 3:{7979+ cs = 2048;8080+ break;8181+ }8282+ case 4:{8383+ cs = 4096;8484+ break;8585+ }8686+ default:{8787+ cs = 0;8888+ break;8989+ }9090+ }9191+ switch (sdccr_mw) {9292+ case 0:{9393+ mw = 8;9494+ break;9595+ } /* 8 bytes = 64 bits */9696+ case 1:{9797+ mw = 4;9898+ break;9999+ } /* 4 bytes = 32 bits */100100+ }101101+ }102102+103103+ /* bytes per chip MB per chip bank count */104104+ msize = (((rs * cs * mw) / (1024 * 1024)) * (bc));105105+106106+ /* MVMCP -- bc hard coded to 4 from table 9.3.1 */107107+ /* boad supports bc=2 but no way to detect */108108+109109+ return (msize);110110+}111111+112112+unsigned int __init113113+tx4938_get_mem_size(void)114114+{115115+ unsigned int c0;116116+ unsigned int c1;117117+ unsigned int c2;118118+ unsigned int c3;119119+ unsigned int total;120120+121121+ /* MVMCP -- need #defs for these registers */122122+ c0 = tx4938_process_sdccr((u64 *) 0xff1f8000);123123+ c1 = tx4938_process_sdccr((u64 *) 0xff1f8008);124124+ c2 = tx4938_process_sdccr((u64 *) 0xff1f8010);125125+ c3 = tx4938_process_sdccr((u64 *) 0xff1f8018);126126+ total = c0 + c1 + c2 + c3;127127+128128+ return (total);129129+}
+202
arch/mips/tx4938/common/rtc_rx5c348.c
···11+/*22+ * RTC routines for RICOH Rx5C348 SPI chip.33+ * Copyright (C) 2000-2001 Toshiba Corporation44+ *55+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the66+ * terms of the GNU General Public License version 2. This program is77+ * licensed "as is" without any warranty of any kind, whether express88+ * or implied.99+ *1010+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1111+ */1212+#include <linux/init.h>1313+#include <linux/kernel.h>1414+#include <linux/string.h>1515+#include <linux/rtc.h>1616+#include <linux/time.h>1717+#include <asm/time.h>1818+#include <asm/tx4938/spi.h>1919+2020+#define EPOCH 20002121+2222+/* registers */2323+#define Rx5C348_REG_SECOND 02424+#define Rx5C348_REG_MINUTE 12525+#define Rx5C348_REG_HOUR 22626+#define Rx5C348_REG_WEEK 32727+#define Rx5C348_REG_DAY 42828+#define Rx5C348_REG_MONTH 52929+#define Rx5C348_REG_YEAR 63030+#define Rx5C348_REG_ADJUST 73131+#define Rx5C348_REG_ALARM_W_MIN 83232+#define Rx5C348_REG_ALARM_W_HOUR 93333+#define Rx5C348_REG_ALARM_W_WEEK 103434+#define Rx5C348_REG_ALARM_D_MIN 113535+#define Rx5C348_REG_ALARM_D_HOUR 123636+#define Rx5C348_REG_CTL1 143737+#define Rx5C348_REG_CTL2 153838+3939+/* register bits */4040+#define Rx5C348_BIT_PM 0x20 /* REG_HOUR */4141+#define Rx5C348_BIT_Y2K 0x80 /* REG_MONTH */4242+#define Rx5C348_BIT_24H 0x20 /* REG_CTL1 */4343+#define Rx5C348_BIT_XSTP 0x10 /* REG_CTL2 */4444+4545+/* commands */4646+#define Rx5C348_CMD_W(addr) (((addr) << 4) | 0x08) /* single write */4747+#define Rx5C348_CMD_R(addr) (((addr) << 4) | 0x0c) /* single read */4848+#define Rx5C348_CMD_MW(addr) (((addr) << 4) | 0x00) /* burst write */4949+#define Rx5C348_CMD_MR(addr) (((addr) << 4) | 0x04) /* burst read */5050+5151+static struct spi_dev_desc srtc_dev_desc = {5252+ .baud = 1000000, /* 1.0Mbps @ Vdd 2.0V */5353+ .tcss = 31,5454+ .tcsh = 1,5555+ .tcsr = 62,5656+ /* 31us for Tcss (62us for Tcsr) is required for carry operation) */5757+ .byteorder = 1, /* MSB-First */5858+ .polarity = 0, /* High-Active */5959+ .phase = 1, /* Shift-Then-Sample */6060+6161+};6262+static int srtc_chipid;6363+static int srtc_24h;6464+6565+static inline int6666+spi_rtc_io(unsigned char *inbuf, unsigned char *outbuf, unsigned int count)6767+{6868+ unsigned char *inbufs[1], *outbufs[1];6969+ unsigned int incounts[2], outcounts[2];7070+ inbufs[0] = inbuf;7171+ incounts[0] = count;7272+ incounts[1] = 0;7373+ outbufs[0] = outbuf;7474+ outcounts[0] = count;7575+ outcounts[1] = 0;7676+ return txx9_spi_io(srtc_chipid, &srtc_dev_desc,7777+ inbufs, incounts, outbufs, outcounts, 0);7878+}7979+8080+/*8181+ * Conversion between binary and BCD.8282+ */8383+#ifndef BCD_TO_BIN8484+#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)8585+#endif8686+8787+#ifndef BIN_TO_BCD8888+#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)8989+#endif9090+9191+/* RTC-dependent code for time.c */9292+9393+static int9494+rtc_rx5c348_set_time(unsigned long t)9595+{9696+ unsigned char inbuf[8];9797+ struct rtc_time tm;9898+ u8 year, month, day, hour, minute, second, century;9999+100100+ /* convert */101101+ to_tm(t, &tm);102102+103103+ year = tm.tm_year % 100;104104+ month = tm.tm_mon+1; /* tm_mon starts from 0 to 11 */105105+ day = tm.tm_mday;106106+ hour = tm.tm_hour;107107+ minute = tm.tm_min;108108+ second = tm.tm_sec;109109+ century = tm.tm_year / 100;110110+111111+ inbuf[0] = Rx5C348_CMD_MW(Rx5C348_REG_SECOND);112112+ BIN_TO_BCD(second);113113+ inbuf[1] = second;114114+ BIN_TO_BCD(minute);115115+ inbuf[2] = minute;116116+117117+ if (srtc_24h) {118118+ BIN_TO_BCD(hour);119119+ inbuf[3] = hour;120120+ } else {121121+ /* hour 0 is AM12, noon is PM12 */122122+ inbuf[3] = 0;123123+ if (hour >= 12)124124+ inbuf[3] = Rx5C348_BIT_PM;125125+ hour = (hour + 11) % 12 + 1;126126+ BIN_TO_BCD(hour);127127+ inbuf[3] |= hour;128128+ }129129+ inbuf[4] = 0; /* ignore week */130130+ BIN_TO_BCD(day);131131+ inbuf[5] = day;132132+ BIN_TO_BCD(month);133133+ inbuf[6] = month;134134+ if (century >= 20)135135+ inbuf[6] |= Rx5C348_BIT_Y2K;136136+ BIN_TO_BCD(year);137137+ inbuf[7] = year;138138+ /* write in one transfer to avoid data inconsistency */139139+ return spi_rtc_io(inbuf, NULL, 8);140140+}141141+142142+static unsigned long143143+rtc_rx5c348_get_time(void)144144+{145145+ unsigned char inbuf[8], outbuf[8];146146+ unsigned int year, month, day, hour, minute, second;147147+148148+ inbuf[0] = Rx5C348_CMD_MR(Rx5C348_REG_SECOND);149149+ memset(inbuf + 1, 0, 7);150150+ /* read in one transfer to avoid data inconsistency */151151+ if (spi_rtc_io(inbuf, outbuf, 8))152152+ return 0;153153+ second = outbuf[1];154154+ BCD_TO_BIN(second);155155+ minute = outbuf[2];156156+ BCD_TO_BIN(minute);157157+ if (srtc_24h) {158158+ hour = outbuf[3];159159+ BCD_TO_BIN(hour);160160+ } else {161161+ hour = outbuf[3] & ~Rx5C348_BIT_PM;162162+ BCD_TO_BIN(hour);163163+ hour %= 12;164164+ if (outbuf[3] & Rx5C348_BIT_PM)165165+ hour += 12;166166+ }167167+ day = outbuf[5];168168+ BCD_TO_BIN(day);169169+ month = outbuf[6] & ~Rx5C348_BIT_Y2K;170170+ BCD_TO_BIN(month);171171+ year = outbuf[7];172172+ BCD_TO_BIN(year);173173+ year += EPOCH;174174+175175+ return mktime(year, month, day, hour, minute, second);176176+}177177+178178+void __init179179+rtc_rx5c348_init(int chipid)180180+{181181+ unsigned char inbuf[2], outbuf[2];182182+ srtc_chipid = chipid;183183+ /* turn on RTC if it is not on */184184+ inbuf[0] = Rx5C348_CMD_R(Rx5C348_REG_CTL2);185185+ inbuf[1] = 0;186186+ spi_rtc_io(inbuf, outbuf, 2);187187+ if (outbuf[1] & Rx5C348_BIT_XSTP) {188188+ inbuf[0] = Rx5C348_CMD_W(Rx5C348_REG_CTL2);189189+ inbuf[1] = 0;190190+ spi_rtc_io(inbuf, NULL, 2);191191+ }192192+193193+ inbuf[0] = Rx5C348_CMD_R(Rx5C348_REG_CTL1);194194+ inbuf[1] = 0;195195+ spi_rtc_io(inbuf, outbuf, 2);196196+ if (outbuf[1] & Rx5C348_BIT_24H)197197+ srtc_24h = 1;198198+199199+ /* set the function pointers */200200+ rtc_get_time = rtc_rx5c348_get_time;201201+ rtc_set_time = rtc_rx5c348_set_time;202202+}
+91
arch/mips/tx4938/common/setup.c
···11+/*22+ * linux/arch/mips/tx4938/common/setup.c33+ *44+ * common tx4938 setup routines55+ *66+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the77+ * terms of the GNU General Public License version 2. This program is88+ * licensed "as is" without any warranty of any kind, whether express99+ * or implied.1010+ *1111+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1212+ */1313+1414+#include <linux/errno.h>1515+#include <linux/init.h>1616+#include <linux/kernel_stat.h>1717+#include <linux/module.h>1818+#include <linux/signal.h>1919+#include <linux/sched.h>2020+#include <linux/types.h>2121+#include <linux/interrupt.h>2222+#include <linux/ioport.h>2323+#include <linux/timex.h>2424+#include <linux/slab.h>2525+#include <linux/random.h>2626+#include <linux/irq.h>2727+#include <asm/bitops.h>2828+#include <asm/bootinfo.h>2929+#include <asm/io.h>3030+#include <asm/irq.h>3131+#include <asm/mipsregs.h>3232+#include <asm/system.h>3333+#include <asm/time.h>3434+#include <asm/time.h>3535+#include <asm/tx4938/rbtx4938.h>3636+3737+extern void toshiba_rbtx4938_setup(void);3838+extern void rbtx4938_time_init(void);3939+4040+void __init tx4938_setup(void);4141+void __init tx4938_time_init(void);4242+void __init tx4938_timer_setup(struct irqaction *irq);4343+void dump_cp0(char *key);4444+4545+void (*__wbflush) (void);4646+4747+static void4848+tx4938_write_buffer_flush(void)4949+{5050+ mmiowb();5151+5252+ __asm__ __volatile__(5353+ ".set push\n\t"5454+ ".set noreorder\n\t"5555+ "lw $0,%0\n\t"5656+ "nop\n\t"5757+ ".set pop"5858+ : /* no output */5959+ : "m" (*(int *)KSEG1)6060+ : "memory");6161+}6262+6363+void __init6464+plat_setup(void)6565+{6666+ board_time_init = tx4938_time_init;6767+ board_timer_setup = tx4938_timer_setup;6868+ __wbflush = tx4938_write_buffer_flush;6969+ toshiba_rbtx4938_setup();7070+}7171+7272+void __init7373+tx4938_time_init(void)7474+{7575+ rbtx4938_time_init();7676+}7777+7878+void __init7979+tx4938_timer_setup(struct irqaction *irq)8080+{8181+ u32 count;8282+ u32 c1;8383+ u32 c2;8484+8585+ setup_irq(TX4938_IRQ_CPU_TIMER, irq);8686+8787+ c1 = read_c0_count();8888+ count = c1 + (mips_hpt_frequency / HZ);8989+ write_c0_compare(count);9090+ c2 = read_c0_count();9191+}
+9
arch/mips/tx4938/toshiba_rbtx4938/Makefile
···11+#22+# Makefile for common code for Toshiba TX4927 based systems33+#44+# Note! Dependencies are done automagically by 'make dep', which also55+# removes any old dependencies. DON'T put your own dependencies here66+# unless it's something special (ie not a .c file).77+#88+99+obj-y += prom.o setup.o irq.o spi_eeprom.o spi_txx9.o
+244
arch/mips/tx4938/toshiba_rbtx4938/irq.c
···11+/*22+ * linux/arch/mips/tx4938/toshiba_rbtx4938/irq.c33+ *44+ * Toshiba RBTX4938 specific interrupt handlers55+ * Copyright (C) 2000-2001 Toshiba Corporation66+ *77+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the88+ * terms of the GNU General Public License version 2. This program is99+ * licensed "as is" without any warranty of any kind, whether express1010+ * or implied.1111+ *1212+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1313+ */1414+1515+/*1616+IRQ Device1717+1818+16 TX4938-CP0/00 Software 01919+17 TX4938-CP0/01 Software 12020+18 TX4938-CP0/02 Cascade TX4938-CP02121+19 TX4938-CP0/03 Multiplexed -- do not use2222+20 TX4938-CP0/04 Multiplexed -- do not use2323+21 TX4938-CP0/05 Multiplexed -- do not use2424+22 TX4938-CP0/06 Multiplexed -- do not use2525+23 TX4938-CP0/07 CPU TIMER2626+2727+24 TX4938-PIC/002828+25 TX4938-PIC/012929+26 TX4938-PIC/02 Cascade RBTX4938-IOC3030+27 TX4938-PIC/03 RBTX4938 RTL-8019AS Ethernet3131+28 TX4938-PIC/043232+29 TX4938-PIC/05 TX4938 ETH13333+30 TX4938-PIC/06 TX4938 ETH03434+31 TX4938-PIC/073535+32 TX4938-PIC/08 TX4938 SIO 03636+33 TX4938-PIC/09 TX4938 SIO 13737+34 TX4938-PIC/10 TX4938 DMA03838+35 TX4938-PIC/11 TX4938 DMA13939+36 TX4938-PIC/12 TX4938 DMA24040+37 TX4938-PIC/13 TX4938 DMA34141+38 TX4938-PIC/144242+39 TX4938-PIC/154343+40 TX4938-PIC/16 TX4938 PCIC4444+41 TX4938-PIC/17 TX4938 TMR04545+42 TX4938-PIC/18 TX4938 TMR14646+43 TX4938-PIC/19 TX4938 TMR24747+44 TX4938-PIC/204848+45 TX4938-PIC/214949+46 TX4938-PIC/22 TX4938 PCIERR5050+47 TX4938-PIC/235151+48 TX4938-PIC/245252+49 TX4938-PIC/255353+50 TX4938-PIC/265454+51 TX4938-PIC/275555+52 TX4938-PIC/285656+53 TX4938-PIC/295757+54 TX4938-PIC/305858+55 TX4938-PIC/31 TX4938 SPI5959+6060+56 RBTX4938-IOC/00 PCI-D6161+57 RBTX4938-IOC/01 PCI-C6262+58 RBTX4938-IOC/02 PCI-B6363+59 RBTX4938-IOC/03 PCI-A6464+60 RBTX4938-IOC/04 RTC6565+61 RBTX4938-IOC/05 ATA6666+62 RBTX4938-IOC/06 MODEM6767+63 RBTX4938-IOC/07 SWINT6868+*/6969+#include <linux/init.h>7070+#include <linux/kernel.h>7171+#include <linux/types.h>7272+#include <linux/mm.h>7373+#include <linux/swap.h>7474+#include <linux/ioport.h>7575+#include <linux/sched.h>7676+#include <linux/interrupt.h>7777+#include <linux/pci.h>7878+#include <linux/timex.h>7979+#include <asm/bootinfo.h>8080+#include <asm/page.h>8181+#include <asm/io.h>8282+#include <asm/irq.h>8383+#include <asm/processor.h>8484+#include <asm/ptrace.h>8585+#include <asm/reboot.h>8686+#include <asm/time.h>8787+#include <linux/version.h>8888+#include <linux/bootmem.h>8989+#include <asm/tx4938/rbtx4938.h>9090+9191+static unsigned int toshiba_rbtx4938_irq_ioc_startup(unsigned int irq);9292+static void toshiba_rbtx4938_irq_ioc_shutdown(unsigned int irq);9393+static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq);9494+static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq);9595+static void toshiba_rbtx4938_irq_ioc_mask_and_ack(unsigned int irq);9696+static void toshiba_rbtx4938_irq_ioc_end(unsigned int irq);9797+9898+DEFINE_SPINLOCK(toshiba_rbtx4938_ioc_lock);9999+100100+#define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC"101101+static struct hw_interrupt_type toshiba_rbtx4938_irq_ioc_type = {102102+ .typename = TOSHIBA_RBTX4938_IOC_NAME,103103+ .startup = toshiba_rbtx4938_irq_ioc_startup,104104+ .shutdown = toshiba_rbtx4938_irq_ioc_shutdown,105105+ .enable = toshiba_rbtx4938_irq_ioc_enable,106106+ .disable = toshiba_rbtx4938_irq_ioc_disable,107107+ .ack = toshiba_rbtx4938_irq_ioc_mask_and_ack,108108+ .end = toshiba_rbtx4938_irq_ioc_end,109109+ .set_affinity = NULL110110+};111111+112112+#define TOSHIBA_RBTX4938_IOC_INTR_ENAB 0xb7f02000113113+#define TOSHIBA_RBTX4938_IOC_INTR_STAT 0xb7f0200a114114+115115+int116116+toshiba_rbtx4938_irq_nested(int sw_irq)117117+{118118+ u8 level3;119119+120120+ level3 = reg_rd08(TOSHIBA_RBTX4938_IOC_INTR_STAT) & 0xff;121121+ if (level3) {122122+ /* must use fls so onboard ATA has priority */123123+ sw_irq = TOSHIBA_RBTX4938_IRQ_IOC_BEG + fls(level3) - 1;124124+ }125125+126126+ wbflush();127127+ return sw_irq;128128+}129129+130130+static struct irqaction toshiba_rbtx4938_irq_ioc_action = {131131+ .handler = no_action,132132+ .flags = 0,133133+ .mask = CPU_MASK_NONE,134134+ .name = TOSHIBA_RBTX4938_IOC_NAME,135135+};136136+137137+/**********************************************************************************/138138+/* Functions for ioc */139139+/**********************************************************************************/140140+static void __init141141+toshiba_rbtx4938_irq_ioc_init(void)142142+{143143+ int i;144144+145145+ for (i = TOSHIBA_RBTX4938_IRQ_IOC_BEG;146146+ i <= TOSHIBA_RBTX4938_IRQ_IOC_END; i++) {147147+ irq_desc[i].status = IRQ_DISABLED;148148+ irq_desc[i].action = 0;149149+ irq_desc[i].depth = 3;150150+ irq_desc[i].handler = &toshiba_rbtx4938_irq_ioc_type;151151+ }152152+153153+ setup_irq(RBTX4938_IRQ_IOCINT,154154+ &toshiba_rbtx4938_irq_ioc_action);155155+}156156+157157+static unsigned int158158+toshiba_rbtx4938_irq_ioc_startup(unsigned int irq)159159+{160160+ toshiba_rbtx4938_irq_ioc_enable(irq);161161+162162+ return 0;163163+}164164+165165+static void166166+toshiba_rbtx4938_irq_ioc_shutdown(unsigned int irq)167167+{168168+ toshiba_rbtx4938_irq_ioc_disable(irq);169169+}170170+171171+static void172172+toshiba_rbtx4938_irq_ioc_enable(unsigned int irq)173173+{174174+ unsigned long flags;175175+ volatile unsigned char v;176176+177177+ spin_lock_irqsave(&toshiba_rbtx4938_ioc_lock, flags);178178+179179+ v = TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);180180+ v |= (1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG));181181+ TX4938_WR08(TOSHIBA_RBTX4938_IOC_INTR_ENAB, v);182182+ mmiowb();183183+ TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);184184+185185+ spin_unlock_irqrestore(&toshiba_rbtx4938_ioc_lock, flags);186186+}187187+188188+static void189189+toshiba_rbtx4938_irq_ioc_disable(unsigned int irq)190190+{191191+ unsigned long flags;192192+ volatile unsigned char v;193193+194194+ spin_lock_irqsave(&toshiba_rbtx4938_ioc_lock, flags);195195+196196+ v = TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);197197+ v &= ~(1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG));198198+ TX4938_WR08(TOSHIBA_RBTX4938_IOC_INTR_ENAB, v);199199+ mmiowb();200200+ TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);201201+202202+ spin_unlock_irqrestore(&toshiba_rbtx4938_ioc_lock, flags);203203+}204204+205205+static void206206+toshiba_rbtx4938_irq_ioc_mask_and_ack(unsigned int irq)207207+{208208+ toshiba_rbtx4938_irq_ioc_disable(irq);209209+}210210+211211+static void212212+toshiba_rbtx4938_irq_ioc_end(unsigned int irq)213213+{214214+ if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {215215+ toshiba_rbtx4938_irq_ioc_enable(irq);216216+ }217217+}218218+219219+extern void __init txx9_spi_irqinit(int irc_irq);220220+221221+void __init arch_init_irq(void)222222+{223223+ extern void tx4938_irq_init(void);224224+225225+ /* Now, interrupt control disabled, */226226+ /* all IRC interrupts are masked, */227227+ /* all IRC interrupt mode are Low Active. */228228+229229+ /* mask all IOC interrupts */230230+ *rbtx4938_imask_ptr = 0;231231+232232+ /* clear SoftInt interrupts */233233+ *rbtx4938_softint_ptr = 0;234234+ tx4938_irq_init();235235+ toshiba_rbtx4938_irq_ioc_init();236236+ /* Onboard 10M Ether: High Active */237237+ TX4938_WR(TX4938_MKA(TX4938_IRC_IRDM0), 0x00000040);238238+239239+ if (tx4938_ccfgptr->pcfg & TX4938_PCFG_SPI_SEL) {240240+ txx9_spi_irqinit(RBTX4938_IRQ_IRC_SPI);241241+ }242242+243243+ wbflush();244244+}
+78
arch/mips/tx4938/toshiba_rbtx4938/prom.c
···11+/*22+ * linux/arch/mips/tx4938/toshiba_rbtx4938/prom.c33+ *44+ * rbtx4938 specific prom routines55+ * Copyright (C) 2000-2001 Toshiba Corporation66+ *77+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the88+ * terms of the GNU General Public License version 2. This program is99+ * licensed "as is" without any warranty of any kind, whether express1010+ * or implied.1111+ *1212+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1313+ */1414+1515+#include <linux/config.h>1616+#include <linux/init.h>1717+#include <linux/mm.h>1818+#include <linux/sched.h>1919+#include <linux/bootmem.h>2020+2121+#include <asm/addrspace.h>2222+#include <asm/bootinfo.h>2323+#include <asm/tx4938/tx4938.h>2424+2525+void __init prom_init_cmdline(void)2626+{2727+ int argc = (int) fw_arg0;2828+ char **argv = (char **) fw_arg1;2929+ int i;3030+3131+ /* ignore all built-in args if any f/w args given */3232+ if (argc > 1) {3333+ *arcs_cmdline = '\0';3434+ }3535+3636+ for (i = 1; i < argc; i++) {3737+ if (i != 1) {3838+ strcat(arcs_cmdline, " ");3939+ }4040+ strcat(arcs_cmdline, argv[i]);4141+ }4242+}4343+4444+void __init prom_init(void)4545+{4646+ extern int tx4938_get_mem_size(void);4747+ int msize;4848+#ifndef CONFIG_TX4938_NAND_BOOT4949+ prom_init_cmdline();5050+#endif5151+ mips_machgroup = MACH_GROUP_TOSHIBA;5252+ mips_machtype = MACH_TOSHIBA_RBTX4938;5353+5454+ msize = tx4938_get_mem_size();5555+ add_memory_region(0, msize << 20, BOOT_MEM_RAM);5656+5757+ return;5858+}5959+6060+unsigned long __init prom_free_prom_memory(void)6161+{6262+ return 0;6363+}6464+6565+void __init prom_fixup_mem_map(unsigned long start, unsigned long end)6666+{6767+ return;6868+}6969+7070+const char *get_system_type(void)7171+{7272+ return "Toshiba RBTX4938";7373+}7474+7575+char * __init prom_getcmdline(void)7676+{7777+ return &(arcs_cmdline[0]);7878+}
+1035
arch/mips/tx4938/toshiba_rbtx4938/setup.c
···11+/*22+ * linux/arch/mips/tx4938/toshiba_rbtx4938/setup.c33+ *44+ * Setup pointers to hardware-dependent routines.55+ * Copyright (C) 2000-2001 Toshiba Corporation66+ *77+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the88+ * terms of the GNU General Public License version 2. This program is99+ * licensed "as is" without any warranty of any kind, whether express1010+ * or implied.1111+ *1212+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1313+ */1414+#include <linux/config.h>1515+#include <linux/init.h>1616+#include <linux/types.h>1717+#include <linux/ioport.h>1818+#include <linux/proc_fs.h>1919+#include <linux/delay.h>2020+#include <linux/interrupt.h>2121+#include <linux/console.h>2222+#include <linux/pci.h>2323+#include <asm/wbflush.h>2424+#include <asm/reboot.h>2525+#include <asm/irq.h>2626+#include <asm/time.h>2727+#include <asm/uaccess.h>2828+#include <asm/io.h>2929+#include <asm/bootinfo.h>3030+#include <asm/tx4938/rbtx4938.h>3131+#ifdef CONFIG_SERIAL_TXX93232+#include <linux/tty.h>3333+#include <linux/serial.h>3434+#include <linux/serial_core.h>3535+#endif3636+3737+extern void rbtx4938_time_init(void) __init;3838+extern char * __init prom_getcmdline(void);3939+static inline void tx4938_report_pcic_status1(struct tx4938_pcic_reg *pcicptr);4040+4141+/* These functions are used for rebooting or halting the machine*/4242+extern void rbtx4938_machine_restart(char *command);4343+extern void rbtx4938_machine_halt(void);4444+extern void rbtx4938_machine_power_off(void);4545+4646+/* clocks */4747+unsigned int txx9_master_clock;4848+unsigned int txx9_cpu_clock;4949+unsigned int txx9_gbus_clock;5050+5151+unsigned long rbtx4938_ce_base[8];5252+unsigned long rbtx4938_ce_size[8];5353+int txboard_pci66_mode;5454+static int tx4938_pcic_trdyto; /* default: disabled */5555+static int tx4938_pcic_retryto; /* default: disabled */5656+static int tx4938_ccfg_toeon = 1;5757+5858+struct tx4938_pcic_reg *pcicptrs[4] = {5959+ tx4938_pcicptr /* default setting for TX4938 */6060+};6161+6262+static struct {6363+ unsigned long base;6464+ unsigned long size;6565+} phys_regions[16] __initdata;6666+static int num_phys_regions __initdata;6767+6868+#define PHYS_REGION_MINSIZE 0x100006969+7070+void rbtx4938_machine_halt(void)7171+{7272+ printk(KERN_NOTICE "System Halted\n");7373+ local_irq_disable();7474+7575+ while (1)7676+ __asm__(".set\tmips3\n\t"7777+ "wait\n\t"7878+ ".set\tmips0");7979+}8080+8181+void rbtx4938_machine_power_off(void)8282+{8383+ rbtx4938_machine_halt();8484+ /* no return */8585+}8686+8787+void rbtx4938_machine_restart(char *command)8888+{8989+ local_irq_disable();9090+9191+ printk("Rebooting...");9292+ *rbtx4938_softresetlock_ptr = 1;9393+ *rbtx4938_sfvol_ptr = 1;9494+ *rbtx4938_softreset_ptr = 1;9595+ wbflush();9696+9797+ while(1);9898+}9999+100100+void __init101101+txboard_add_phys_region(unsigned long base, unsigned long size)102102+{103103+ if (num_phys_regions >= ARRAY_SIZE(phys_regions)) {104104+ printk("phys_region overflow\n");105105+ return;106106+ }107107+ phys_regions[num_phys_regions].base = base;108108+ phys_regions[num_phys_regions].size = size;109109+ num_phys_regions++;110110+}111111+unsigned long __init112112+txboard_find_free_phys_region(unsigned long begin, unsigned long end,113113+ unsigned long size)114114+{115115+ unsigned long base;116116+ int i;117117+118118+ for (base = begin / size * size; base < end; base += size) {119119+ for (i = 0; i < num_phys_regions; i++) {120120+ if (phys_regions[i].size &&121121+ base <= phys_regions[i].base + (phys_regions[i].size - 1) &&122122+ base + (size - 1) >= phys_regions[i].base)123123+ break;124124+ }125125+ if (i == num_phys_regions)126126+ return base;127127+ }128128+ return 0;129129+}130130+unsigned long __init131131+txboard_find_free_phys_region_shrink(unsigned long begin, unsigned long end,132132+ unsigned long *size)133133+{134134+ unsigned long sz, base;135135+ for (sz = *size; sz >= PHYS_REGION_MINSIZE; sz /= 2) {136136+ base = txboard_find_free_phys_region(begin, end, sz);137137+ if (base) {138138+ *size = sz;139139+ return base;140140+ }141141+ }142142+ return 0;143143+}144144+unsigned long __init145145+txboard_request_phys_region_range(unsigned long begin, unsigned long end,146146+ unsigned long size)147147+{148148+ unsigned long base;149149+ base = txboard_find_free_phys_region(begin, end, size);150150+ if (base)151151+ txboard_add_phys_region(base, size);152152+ return base;153153+}154154+unsigned long __init155155+txboard_request_phys_region(unsigned long size)156156+{157157+ unsigned long base;158158+ unsigned long begin = 0, end = 0x20000000; /* search low 512MB */159159+ base = txboard_find_free_phys_region(begin, end, size);160160+ if (base)161161+ txboard_add_phys_region(base, size);162162+ return base;163163+}164164+unsigned long __init165165+txboard_request_phys_region_shrink(unsigned long *size)166166+{167167+ unsigned long base;168168+ unsigned long begin = 0, end = 0x20000000; /* search low 512MB */169169+ base = txboard_find_free_phys_region_shrink(begin, end, size);170170+ if (base)171171+ txboard_add_phys_region(base, *size);172172+ return base;173173+}174174+175175+#ifdef CONFIG_PCI176176+void __init177177+tx4938_pcic_setup(struct tx4938_pcic_reg *pcicptr,178178+ struct pci_controller *channel,179179+ unsigned long pci_io_base,180180+ int extarb)181181+{182182+ int i;183183+184184+ /* Disable All Initiator Space */185185+ pcicptr->pciccfg &= ~(TX4938_PCIC_PCICCFG_G2PMEN(0)|186186+ TX4938_PCIC_PCICCFG_G2PMEN(1)|187187+ TX4938_PCIC_PCICCFG_G2PMEN(2)|188188+ TX4938_PCIC_PCICCFG_G2PIOEN);189189+190190+ /* GB->PCI mappings */191191+ pcicptr->g2piomask = (channel->io_resource->end - channel->io_resource->start) >> 4;192192+ pcicptr->g2piogbase = pci_io_base |193193+#ifdef __BIG_ENDIAN194194+ TX4938_PCIC_G2PIOGBASE_ECHG195195+#else196196+ TX4938_PCIC_G2PIOGBASE_BSDIS197197+#endif198198+ ;199199+ pcicptr->g2piopbase = 0;200200+ for (i = 0; i < 3; i++) {201201+ pcicptr->g2pmmask[i] = 0;202202+ pcicptr->g2pmgbase[i] = 0;203203+ pcicptr->g2pmpbase[i] = 0;204204+ }205205+ if (channel->mem_resource->end) {206206+ pcicptr->g2pmmask[0] = (channel->mem_resource->end - channel->mem_resource->start) >> 4;207207+ pcicptr->g2pmgbase[0] = channel->mem_resource->start |208208+#ifdef __BIG_ENDIAN209209+ TX4938_PCIC_G2PMnGBASE_ECHG210210+#else211211+ TX4938_PCIC_G2PMnGBASE_BSDIS212212+#endif213213+ ;214214+ pcicptr->g2pmpbase[0] = channel->mem_resource->start;215215+ }216216+ /* PCI->GB mappings (I/O 256B) */217217+ pcicptr->p2giopbase = 0; /* 256B */218218+ pcicptr->p2giogbase = 0;219219+ /* PCI->GB mappings (MEM 512MB (64MB on R1.x)) */220220+ pcicptr->p2gm0plbase = 0;221221+ pcicptr->p2gm0pubase = 0;222222+ pcicptr->p2gmgbase[0] = 0 |223223+ TX4938_PCIC_P2GMnGBASE_TMEMEN |224224+#ifdef __BIG_ENDIAN225225+ TX4938_PCIC_P2GMnGBASE_TECHG226226+#else227227+ TX4938_PCIC_P2GMnGBASE_TBSDIS228228+#endif229229+ ;230230+ /* PCI->GB mappings (MEM 16MB) */231231+ pcicptr->p2gm1plbase = 0xffffffff;232232+ pcicptr->p2gm1pubase = 0xffffffff;233233+ pcicptr->p2gmgbase[1] = 0;234234+ /* PCI->GB mappings (MEM 1MB) */235235+ pcicptr->p2gm2pbase = 0xffffffff; /* 1MB */236236+ pcicptr->p2gmgbase[2] = 0;237237+238238+ pcicptr->pciccfg &= TX4938_PCIC_PCICCFG_GBWC_MASK;239239+ /* Enable Initiator Memory Space */240240+ if (channel->mem_resource->end)241241+ pcicptr->pciccfg |= TX4938_PCIC_PCICCFG_G2PMEN(0);242242+ /* Enable Initiator I/O Space */243243+ if (channel->io_resource->end)244244+ pcicptr->pciccfg |= TX4938_PCIC_PCICCFG_G2PIOEN;245245+ /* Enable Initiator Config */246246+ pcicptr->pciccfg |=247247+ TX4938_PCIC_PCICCFG_ICAEN |248248+ TX4938_PCIC_PCICCFG_TCAR;249249+250250+ /* Do not use MEMMUL, MEMINF: YMFPCI card causes M_ABORT. */251251+ pcicptr->pcicfg1 = 0;252252+253253+ pcicptr->g2ptocnt &= ~0xffff;254254+255255+ if (tx4938_pcic_trdyto >= 0) {256256+ pcicptr->g2ptocnt &= ~0xff;257257+ pcicptr->g2ptocnt |= (tx4938_pcic_trdyto & 0xff);258258+ }259259+260260+ if (tx4938_pcic_retryto >= 0) {261261+ pcicptr->g2ptocnt &= ~0xff00;262262+ pcicptr->g2ptocnt |= ((tx4938_pcic_retryto<<8) & 0xff00);263263+ }264264+265265+ /* Clear All Local Bus Status */266266+ pcicptr->pcicstatus = TX4938_PCIC_PCICSTATUS_ALL;267267+ /* Enable All Local Bus Interrupts */268268+ pcicptr->pcicmask = TX4938_PCIC_PCICSTATUS_ALL;269269+ /* Clear All Initiator Status */270270+ pcicptr->g2pstatus = TX4938_PCIC_G2PSTATUS_ALL;271271+ /* Enable All Initiator Interrupts */272272+ pcicptr->g2pmask = TX4938_PCIC_G2PSTATUS_ALL;273273+ /* Clear All PCI Status Error */274274+ pcicptr->pcistatus =275275+ (pcicptr->pcistatus & 0x0000ffff) |276276+ (TX4938_PCIC_PCISTATUS_ALL << 16);277277+ /* Enable All PCI Status Error Interrupts */278278+ pcicptr->pcimask = TX4938_PCIC_PCISTATUS_ALL;279279+280280+ if (!extarb) {281281+ /* Reset Bus Arbiter */282282+ pcicptr->pbacfg = TX4938_PCIC_PBACFG_RPBA;283283+ pcicptr->pbabm = 0;284284+ /* Enable Bus Arbiter */285285+ pcicptr->pbacfg = TX4938_PCIC_PBACFG_PBAEN;286286+ }287287+288288+ /* PCIC Int => IRC IRQ16 */289289+ pcicptr->pcicfg2 =290290+ (pcicptr->pcicfg2 & 0xffffff00) | TX4938_IR_PCIC;291291+292292+ pcicptr->pcistatus = PCI_COMMAND_MASTER |293293+ PCI_COMMAND_MEMORY |294294+ PCI_COMMAND_PARITY | PCI_COMMAND_SERR;295295+}296296+297297+int __init298298+tx4938_report_pciclk(void)299299+{300300+ unsigned long pcode = TX4938_REV_PCODE();301301+ int pciclk = 0;302302+ printk("TX%lx PCIC --%s PCICLK:",303303+ pcode,304304+ (tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI66) ? " PCI66" : "");305305+ if (tx4938_ccfgptr->pcfg & TX4938_PCFG_PCICLKEN_ALL) {306306+307307+ switch ((unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_PCIDIVMODE_MASK) {308308+ case TX4938_CCFG_PCIDIVMODE_4:309309+ pciclk = txx9_cpu_clock / 4; break;310310+ case TX4938_CCFG_PCIDIVMODE_4_5:311311+ pciclk = txx9_cpu_clock * 2 / 9; break;312312+ case TX4938_CCFG_PCIDIVMODE_5:313313+ pciclk = txx9_cpu_clock / 5; break;314314+ case TX4938_CCFG_PCIDIVMODE_5_5:315315+ pciclk = txx9_cpu_clock * 2 / 11; break;316316+ case TX4938_CCFG_PCIDIVMODE_8:317317+ pciclk = txx9_cpu_clock / 8; break;318318+ case TX4938_CCFG_PCIDIVMODE_9:319319+ pciclk = txx9_cpu_clock / 9; break;320320+ case TX4938_CCFG_PCIDIVMODE_10:321321+ pciclk = txx9_cpu_clock / 10; break;322322+ case TX4938_CCFG_PCIDIVMODE_11:323323+ pciclk = txx9_cpu_clock / 11; break;324324+ }325325+ printk("Internal(%dMHz)", pciclk / 1000000);326326+ } else {327327+ printk("External");328328+ pciclk = -1;329329+ }330330+ printk("\n");331331+ return pciclk;332332+}333333+334334+void __init set_tx4938_pcicptr(int ch, struct tx4938_pcic_reg *pcicptr)335335+{336336+ pcicptrs[ch] = pcicptr;337337+}338338+339339+struct tx4938_pcic_reg *get_tx4938_pcicptr(int ch)340340+{341341+ return pcicptrs[ch];342342+}343343+344344+static struct pci_dev *fake_pci_dev(struct pci_controller *hose,345345+ int top_bus, int busnr, int devfn)346346+{347347+ static struct pci_dev dev;348348+ static struct pci_bus bus;349349+350350+ dev.sysdata = (void *)hose;351351+ dev.devfn = devfn;352352+ bus.number = busnr;353353+ bus.ops = hose->pci_ops;354354+ bus.parent = NULL;355355+ dev.bus = &bus;356356+357357+ return &dev;358358+}359359+360360+#define EARLY_PCI_OP(rw, size, type) \361361+static int early_##rw##_config_##size(struct pci_controller *hose, \362362+ int top_bus, int bus, int devfn, int offset, type value) \363363+{ \364364+ return pci_##rw##_config_##size( \365365+ fake_pci_dev(hose, top_bus, bus, devfn), \366366+ offset, value); \367367+}368368+369369+EARLY_PCI_OP(read, word, u16 *)370370+371371+int txboard_pci66_check(struct pci_controller *hose, int top_bus, int current_bus)372372+{373373+ u32 pci_devfn;374374+ unsigned short vid;375375+ int devfn_start = 0;376376+ int devfn_stop = 0xff;377377+ int cap66 = -1;378378+ u16 stat;379379+380380+ printk("PCI: Checking 66MHz capabilities...\n");381381+382382+ for (pci_devfn=devfn_start; pci_devfn<devfn_stop; pci_devfn++) {383383+ early_read_config_word(hose, top_bus, current_bus, pci_devfn,384384+ PCI_VENDOR_ID, &vid);385385+386386+ if (vid == 0xffff) continue;387387+388388+ /* check 66MHz capability */389389+ if (cap66 < 0)390390+ cap66 = 1;391391+ if (cap66) {392392+ early_read_config_word(hose, top_bus, current_bus, pci_devfn,393393+ PCI_STATUS, &stat);394394+ if (!(stat & PCI_STATUS_66MHZ)) {395395+ printk(KERN_DEBUG "PCI: %02x:%02x not 66MHz capable.\n",396396+ current_bus, pci_devfn);397397+ cap66 = 0;398398+ break;399399+ }400400+ }401401+ }402402+ return cap66 > 0;403403+}404404+405405+int __init406406+tx4938_pciclk66_setup(void)407407+{408408+ int pciclk;409409+410410+ /* Assert M66EN */411411+ tx4938_ccfgptr->ccfg |= TX4938_CCFG_PCI66;412412+ /* Double PCICLK (if possible) */413413+ if (tx4938_ccfgptr->pcfg & TX4938_PCFG_PCICLKEN_ALL) {414414+ unsigned int pcidivmode =415415+ tx4938_ccfgptr->ccfg & TX4938_CCFG_PCIDIVMODE_MASK;416416+ switch (pcidivmode) {417417+ case TX4938_CCFG_PCIDIVMODE_8:418418+ case TX4938_CCFG_PCIDIVMODE_4:419419+ pcidivmode = TX4938_CCFG_PCIDIVMODE_4;420420+ pciclk = txx9_cpu_clock / 4;421421+ break;422422+ case TX4938_CCFG_PCIDIVMODE_9:423423+ case TX4938_CCFG_PCIDIVMODE_4_5:424424+ pcidivmode = TX4938_CCFG_PCIDIVMODE_4_5;425425+ pciclk = txx9_cpu_clock * 2 / 9;426426+ break;427427+ case TX4938_CCFG_PCIDIVMODE_10:428428+ case TX4938_CCFG_PCIDIVMODE_5:429429+ pcidivmode = TX4938_CCFG_PCIDIVMODE_5;430430+ pciclk = txx9_cpu_clock / 5;431431+ break;432432+ case TX4938_CCFG_PCIDIVMODE_11:433433+ case TX4938_CCFG_PCIDIVMODE_5_5:434434+ default:435435+ pcidivmode = TX4938_CCFG_PCIDIVMODE_5_5;436436+ pciclk = txx9_cpu_clock * 2 / 11;437437+ break;438438+ }439439+ tx4938_ccfgptr->ccfg =440440+ (tx4938_ccfgptr->ccfg & ~TX4938_CCFG_PCIDIVMODE_MASK)441441+ | pcidivmode;442442+ printk(KERN_DEBUG "PCICLK: ccfg:%08lx\n",443443+ (unsigned long)tx4938_ccfgptr->ccfg);444444+ } else {445445+ pciclk = -1;446446+ }447447+ return pciclk;448448+}449449+450450+extern struct pci_controller tx4938_pci_controller[];451451+static int __init tx4938_pcibios_init(void)452452+{453453+ unsigned long mem_base[2];454454+ unsigned long mem_size[2] = {TX4938_PCIMEM_SIZE_0,TX4938_PCIMEM_SIZE_1}; /* MAX 128M,64K */455455+ unsigned long io_base[2];456456+ unsigned long io_size[2] = {TX4938_PCIIO_SIZE_0,TX4938_PCIIO_SIZE_1}; /* MAX 16M,64K */457457+ /* TX4938 PCIC1: 64K MEM/IO is enough for ETH0,ETH1 */458458+ int extarb = !(tx4938_ccfgptr->ccfg & TX4938_CCFG_PCIXARB);459459+460460+ PCIBIOS_MIN_IO = 0x00001000UL;461461+ PCIBIOS_MIN_MEM = 0x01000000UL;462462+463463+ mem_base[0] = txboard_request_phys_region_shrink(&mem_size[0]);464464+ io_base[0] = txboard_request_phys_region_shrink(&io_size[0]);465465+466466+ printk("TX4938 PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:%s\n",467467+ (unsigned short)(tx4938_pcicptr->pciid >> 16),468468+ (unsigned short)(tx4938_pcicptr->pciid & 0xffff),469469+ (unsigned short)(tx4938_pcicptr->pciccrev & 0xff),470470+ extarb ? "External" : "Internal");471471+472472+ /* setup PCI area */473473+ tx4938_pci_controller[0].io_resource->start = io_base[0];474474+ tx4938_pci_controller[0].io_resource->end = (io_base[0] + io_size[0]) - 1;475475+ tx4938_pci_controller[0].mem_resource->start = mem_base[0];476476+ tx4938_pci_controller[0].mem_resource->end = mem_base[0] + mem_size[0] - 1;477477+478478+ set_tx4938_pcicptr(0, tx4938_pcicptr);479479+480480+ register_pci_controller(&tx4938_pci_controller[0]);481481+482482+ if (tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI66) {483483+ printk("TX4938_CCFG_PCI66 already configured\n");484484+ txboard_pci66_mode = -1; /* already configured */485485+ }486486+487487+ /* Reset PCI Bus */488488+ *rbtx4938_pcireset_ptr = 0;489489+ /* Reset PCIC */490490+ tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIRST;491491+ if (txboard_pci66_mode > 0)492492+ tx4938_pciclk66_setup();493493+ mdelay(10);494494+ /* clear PCIC reset */495495+ tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIRST;496496+ *rbtx4938_pcireset_ptr = 1;497497+ wbflush();498498+ tx4938_report_pcic_status1(tx4938_pcicptr);499499+500500+ tx4938_report_pciclk();501501+ tx4938_pcic_setup(tx4938_pcicptr, &tx4938_pci_controller[0], io_base[0], extarb);502502+ if (txboard_pci66_mode == 0 &&503503+ txboard_pci66_check(&tx4938_pci_controller[0], 0, 0)) {504504+ /* Reset PCI Bus */505505+ *rbtx4938_pcireset_ptr = 0;506506+ /* Reset PCIC */507507+ tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIRST;508508+ tx4938_pciclk66_setup();509509+ mdelay(10);510510+ /* clear PCIC reset */511511+ tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIRST;512512+ *rbtx4938_pcireset_ptr = 1;513513+ wbflush();514514+ /* Reinitialize PCIC */515515+ tx4938_report_pciclk();516516+ tx4938_pcic_setup(tx4938_pcicptr, &tx4938_pci_controller[0], io_base[0], extarb);517517+ }518518+519519+ mem_base[1] = txboard_request_phys_region_shrink(&mem_size[1]);520520+ io_base[1] = txboard_request_phys_region_shrink(&io_size[1]);521521+ /* Reset PCIC1 */522522+ tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIC1RST;523523+ /* PCI1DMD==0 => PCI1CLK==GBUSCLK/2 => PCI66 */524524+ if (!(tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI1DMD))525525+ tx4938_ccfgptr->ccfg |= TX4938_CCFG_PCI1_66;526526+ else527527+ tx4938_ccfgptr->ccfg &= ~TX4938_CCFG_PCI1_66;528528+ mdelay(10);529529+ /* clear PCIC1 reset */530530+ tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIC1RST;531531+ tx4938_report_pcic_status1(tx4938_pcic1ptr);532532+533533+ printk("TX4938 PCIC1 -- DID:%04x VID:%04x RID:%02x",534534+ (unsigned short)(tx4938_pcic1ptr->pciid >> 16),535535+ (unsigned short)(tx4938_pcic1ptr->pciid & 0xffff),536536+ (unsigned short)(tx4938_pcic1ptr->pciccrev & 0xff));537537+ printk("%s PCICLK:%dMHz\n",538538+ (tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI1_66) ? " PCI66" : "",539539+ txx9_gbus_clock /540540+ ((tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI1DMD) ? 4 : 2) /541541+ 1000000);542542+543543+ /* assumption: CPHYSADDR(mips_io_port_base) == io_base[0] */544544+ tx4938_pci_controller[1].io_resource->start =545545+ io_base[1] - io_base[0];546546+ tx4938_pci_controller[1].io_resource->end =547547+ io_base[1] - io_base[0] + io_size[1] - 1;548548+ tx4938_pci_controller[1].mem_resource->start = mem_base[1];549549+ tx4938_pci_controller[1].mem_resource->end =550550+ mem_base[1] + mem_size[1] - 1;551551+ set_tx4938_pcicptr(1, tx4938_pcic1ptr);552552+553553+ register_pci_controller(&tx4938_pci_controller[1]);554554+555555+ tx4938_pcic_setup(tx4938_pcic1ptr, &tx4938_pci_controller[1], io_base[1], extarb);556556+557557+ /* map ioport 0 to PCI I/O space address 0 */558558+ set_io_port_base(KSEG1 + io_base[0]);559559+560560+ return 0;561561+}562562+563563+arch_initcall(tx4938_pcibios_init);564564+565565+#endif /* CONFIG_PCI */566566+567567+/* SPI support */568568+569569+/* chip select for SPI devices */570570+#define SEEPROM1_CS 7 /* PIO7 */571571+#define SEEPROM2_CS 0 /* IOC */572572+#define SEEPROM3_CS 1 /* IOC */573573+#define SRTC_CS 2 /* IOC */574574+575575+static int rbtx4938_spi_cs_func(int chipid, int on)576576+{577577+ unsigned char bit;578578+ switch (chipid) {579579+ case RBTX4938_SEEPROM1_CHIPID:580580+ if (on)581581+ tx4938_pioptr->dout &= ~(1 << SEEPROM1_CS);582582+ else583583+ tx4938_pioptr->dout |= (1 << SEEPROM1_CS);584584+ return 0;585585+ break;586586+ case RBTX4938_SEEPROM2_CHIPID:587587+ bit = (1 << SEEPROM2_CS);588588+ break;589589+ case RBTX4938_SEEPROM3_CHIPID:590590+ bit = (1 << SEEPROM3_CS);591591+ break;592592+ case RBTX4938_SRTC_CHIPID:593593+ bit = (1 << SRTC_CS);594594+ break;595595+ default:596596+ return -ENODEV;597597+ }598598+ /* bit1,2,4 are low active, bit3 is high active */599599+ *rbtx4938_spics_ptr =600600+ (*rbtx4938_spics_ptr & ~bit) |601601+ ((on ? (bit ^ 0x0b) : ~(bit ^ 0x0b)) & bit);602602+ return 0;603603+}604604+605605+#ifdef CONFIG_PCI606606+extern int spi_eeprom_read(int chipid, int address, unsigned char *buf, int len);607607+608608+int rbtx4938_get_tx4938_ethaddr(struct pci_dev *dev, unsigned char *addr)609609+{610610+ struct pci_controller *channel = (struct pci_controller *)dev->bus->sysdata;611611+ static unsigned char dat[17];612612+ static int read_dat = 0;613613+ int ch = 0;614614+615615+ if (channel != &tx4938_pci_controller[1])616616+ return -ENODEV;617617+ /* TX4938 PCIC1 */618618+ switch (PCI_SLOT(dev->devfn)) {619619+ case TX4938_PCIC_IDSEL_AD_TO_SLOT(31):620620+ ch = 0;621621+ break;622622+ case TX4938_PCIC_IDSEL_AD_TO_SLOT(30):623623+ ch = 1;624624+ break;625625+ default:626626+ return -ENODEV;627627+ }628628+ if (!read_dat) {629629+ unsigned char sum;630630+ int i;631631+ read_dat = 1;632632+ /* 0-3: "MAC\0", 4-9:eth0, 10-15:eth1, 16:sum */633633+ if (spi_eeprom_read(RBTX4938_SEEPROM1_CHIPID,634634+ 0, dat, sizeof(dat))) {635635+ printk(KERN_ERR "seeprom: read error.\n");636636+ } else {637637+ if (strcmp(dat, "MAC") != 0)638638+ printk(KERN_WARNING "seeprom: bad signature.\n");639639+ for (i = 0, sum = 0; i < sizeof(dat); i++)640640+ sum += dat[i];641641+ if (sum)642642+ printk(KERN_WARNING "seeprom: bad checksum.\n");643643+ }644644+ }645645+ memcpy(addr, &dat[4 + 6 * ch], 6);646646+ return 0;647647+}648648+#endif /* CONFIG_PCI */649649+650650+extern void __init txx9_spi_init(unsigned long base, int (*cs_func)(int chipid, int on));651651+static void __init rbtx4938_spi_setup(void)652652+{653653+ /* set SPI_SEL */654654+ tx4938_ccfgptr->pcfg |= TX4938_PCFG_SPI_SEL;655655+ /* chip selects for SPI devices */656656+ tx4938_pioptr->dout |= (1 << SEEPROM1_CS);657657+ tx4938_pioptr->dir |= (1 << SEEPROM1_CS);658658+ txx9_spi_init(TX4938_SPI_REG, rbtx4938_spi_cs_func);659659+}660660+661661+static struct resource rbtx4938_fpga_resource;662662+663663+static char pcode_str[8];664664+static struct resource tx4938_reg_resource = {665665+ pcode_str, TX4938_REG_BASE, TX4938_REG_BASE+TX4938_REG_SIZE, IORESOURCE_MEM666666+};667667+668668+void __init tx4938_board_setup(void)669669+{670670+ int i;671671+ unsigned long divmode;672672+ int cpuclk = 0;673673+ unsigned long pcode = TX4938_REV_PCODE();674674+675675+ ioport_resource.start = 0x1000;676676+ ioport_resource.end = 0xffffffff;677677+ iomem_resource.start = 0x1000;678678+ iomem_resource.end = 0xffffffff; /* expand to 4GB */679679+680680+ sprintf(pcode_str, "TX%lx", pcode);681681+ /* SDRAMC,EBUSC are configured by PROM */682682+ for (i = 0; i < 8; i++) {683683+ if (!(tx4938_ebuscptr->cr[i] & 0x8))684684+ continue; /* disabled */685685+ rbtx4938_ce_base[i] = (unsigned long)TX4938_EBUSC_BA(i);686686+ txboard_add_phys_region(rbtx4938_ce_base[i], TX4938_EBUSC_SIZE(i));687687+ }688688+689689+ /* clocks */690690+ if (txx9_master_clock) {691691+ /* calculate gbus_clock and cpu_clock from master_clock */692692+ divmode = (unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_DIVMODE_MASK;693693+ switch (divmode) {694694+ case TX4938_CCFG_DIVMODE_8:695695+ case TX4938_CCFG_DIVMODE_10:696696+ case TX4938_CCFG_DIVMODE_12:697697+ case TX4938_CCFG_DIVMODE_16:698698+ case TX4938_CCFG_DIVMODE_18:699699+ txx9_gbus_clock = txx9_master_clock * 4; break;700700+ default:701701+ txx9_gbus_clock = txx9_master_clock;702702+ }703703+ switch (divmode) {704704+ case TX4938_CCFG_DIVMODE_2:705705+ case TX4938_CCFG_DIVMODE_8:706706+ cpuclk = txx9_gbus_clock * 2; break;707707+ case TX4938_CCFG_DIVMODE_2_5:708708+ case TX4938_CCFG_DIVMODE_10:709709+ cpuclk = txx9_gbus_clock * 5 / 2; break;710710+ case TX4938_CCFG_DIVMODE_3:711711+ case TX4938_CCFG_DIVMODE_12:712712+ cpuclk = txx9_gbus_clock * 3; break;713713+ case TX4938_CCFG_DIVMODE_4:714714+ case TX4938_CCFG_DIVMODE_16:715715+ cpuclk = txx9_gbus_clock * 4; break;716716+ case TX4938_CCFG_DIVMODE_4_5:717717+ case TX4938_CCFG_DIVMODE_18:718718+ cpuclk = txx9_gbus_clock * 9 / 2; break;719719+ }720720+ txx9_cpu_clock = cpuclk;721721+ } else {722722+ if (txx9_cpu_clock == 0) {723723+ txx9_cpu_clock = 300000000; /* 300MHz */724724+ }725725+ /* calculate gbus_clock and master_clock from cpu_clock */726726+ cpuclk = txx9_cpu_clock;727727+ divmode = (unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_DIVMODE_MASK;728728+ switch (divmode) {729729+ case TX4938_CCFG_DIVMODE_2:730730+ case TX4938_CCFG_DIVMODE_8:731731+ txx9_gbus_clock = cpuclk / 2; break;732732+ case TX4938_CCFG_DIVMODE_2_5:733733+ case TX4938_CCFG_DIVMODE_10:734734+ txx9_gbus_clock = cpuclk * 2 / 5; break;735735+ case TX4938_CCFG_DIVMODE_3:736736+ case TX4938_CCFG_DIVMODE_12:737737+ txx9_gbus_clock = cpuclk / 3; break;738738+ case TX4938_CCFG_DIVMODE_4:739739+ case TX4938_CCFG_DIVMODE_16:740740+ txx9_gbus_clock = cpuclk / 4; break;741741+ case TX4938_CCFG_DIVMODE_4_5:742742+ case TX4938_CCFG_DIVMODE_18:743743+ txx9_gbus_clock = cpuclk * 2 / 9; break;744744+ }745745+ switch (divmode) {746746+ case TX4938_CCFG_DIVMODE_8:747747+ case TX4938_CCFG_DIVMODE_10:748748+ case TX4938_CCFG_DIVMODE_12:749749+ case TX4938_CCFG_DIVMODE_16:750750+ case TX4938_CCFG_DIVMODE_18:751751+ txx9_master_clock = txx9_gbus_clock / 4; break;752752+ default:753753+ txx9_master_clock = txx9_gbus_clock;754754+ }755755+ }756756+ /* change default value to udelay/mdelay take reasonable time */757757+ loops_per_jiffy = txx9_cpu_clock / HZ / 2;758758+759759+ /* CCFG */760760+ /* clear WatchDogReset,BusErrorOnWrite flag (W1C) */761761+ tx4938_ccfgptr->ccfg |= TX4938_CCFG_WDRST | TX4938_CCFG_BEOW;762762+ /* clear PCIC1 reset */763763+ if (tx4938_ccfgptr->clkctr & TX4938_CLKCTR_PCIC1RST)764764+ tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIC1RST;765765+766766+ /* enable Timeout BusError */767767+ if (tx4938_ccfg_toeon)768768+ tx4938_ccfgptr->ccfg |= TX4938_CCFG_TOE;769769+770770+ /* DMA selection */771771+ tx4938_ccfgptr->pcfg &= ~TX4938_PCFG_DMASEL_ALL;772772+773773+ /* Use external clock for external arbiter */774774+ if (!(tx4938_ccfgptr->ccfg & TX4938_CCFG_PCIXARB))775775+ tx4938_ccfgptr->pcfg &= ~TX4938_PCFG_PCICLKEN_ALL;776776+777777+ printk("%s -- %dMHz(M%dMHz) CRIR:%08lx CCFG:%Lx PCFG:%Lx\n",778778+ pcode_str,779779+ cpuclk / 1000000, txx9_master_clock / 1000000,780780+ (unsigned long)tx4938_ccfgptr->crir,781781+ tx4938_ccfgptr->ccfg,782782+ tx4938_ccfgptr->pcfg);783783+784784+ printk("%s SDRAMC --", pcode_str);785785+ for (i = 0; i < 4; i++) {786786+ unsigned long long cr = tx4938_sdramcptr->cr[i];787787+ unsigned long ram_base, ram_size;788788+ if (!((unsigned long)cr & 0x00000400))789789+ continue; /* disabled */790790+ ram_base = (unsigned long)(cr >> 49) << 21;791791+ ram_size = ((unsigned long)(cr >> 33) + 1) << 21;792792+ if (ram_base >= 0x20000000)793793+ continue; /* high memory (ignore) */794794+ printk(" CR%d:%016Lx", i, cr);795795+ txboard_add_phys_region(ram_base, ram_size);796796+ }797797+ printk(" TR:%09Lx\n", tx4938_sdramcptr->tr);798798+799799+ /* SRAM */800800+ if (pcode == 0x4938 && tx4938_sramcptr->cr & 1) {801801+ unsigned int size = 0x800;802802+ unsigned long base =803803+ (tx4938_sramcptr->cr >> (39-11)) & ~(size - 1);804804+ txboard_add_phys_region(base, size);805805+ }806806+807807+ /* IRC */808808+ /* disable interrupt control */809809+ tx4938_ircptr->cer = 0;810810+811811+ /* TMR */812812+ /* disable all timers */813813+ for (i = 0; i < TX4938_NR_TMR; i++) {814814+ tx4938_tmrptr(i)->tcr = 0x00000020;815815+ tx4938_tmrptr(i)->tisr = 0;816816+ tx4938_tmrptr(i)->cpra = 0xffffffff;817817+ tx4938_tmrptr(i)->itmr = 0;818818+ tx4938_tmrptr(i)->ccdr = 0;819819+ tx4938_tmrptr(i)->pgmr = 0;820820+ }821821+822822+ /* enable DMA */823823+ TX4938_WR64(0xff1fb150, TX4938_DMA_MCR_MSTEN);824824+ TX4938_WR64(0xff1fb950, TX4938_DMA_MCR_MSTEN);825825+826826+ /* PIO */827827+ tx4938_pioptr->maskcpu = 0;828828+ tx4938_pioptr->maskext = 0;829829+830830+ /* TX4938 internal registers */831831+ if (request_resource(&iomem_resource, &tx4938_reg_resource))832832+ printk("request resource for internal registers failed\n");833833+}834834+835835+#ifdef CONFIG_PCI836836+static inline void tx4938_report_pcic_status1(struct tx4938_pcic_reg *pcicptr)837837+{838838+ unsigned short pcistatus = (unsigned short)(pcicptr->pcistatus >> 16);839839+ unsigned long g2pstatus = pcicptr->g2pstatus;840840+ unsigned long pcicstatus = pcicptr->pcicstatus;841841+ static struct {842842+ unsigned long flag;843843+ const char *str;844844+ } pcistat_tbl[] = {845845+ { PCI_STATUS_DETECTED_PARITY, "DetectedParityError" },846846+ { PCI_STATUS_SIG_SYSTEM_ERROR, "SignaledSystemError" },847847+ { PCI_STATUS_REC_MASTER_ABORT, "ReceivedMasterAbort" },848848+ { PCI_STATUS_REC_TARGET_ABORT, "ReceivedTargetAbort" },849849+ { PCI_STATUS_SIG_TARGET_ABORT, "SignaledTargetAbort" },850850+ { PCI_STATUS_PARITY, "MasterParityError" },851851+ }, g2pstat_tbl[] = {852852+ { TX4938_PCIC_G2PSTATUS_TTOE, "TIOE" },853853+ { TX4938_PCIC_G2PSTATUS_RTOE, "RTOE" },854854+ }, pcicstat_tbl[] = {855855+ { TX4938_PCIC_PCICSTATUS_PME, "PME" },856856+ { TX4938_PCIC_PCICSTATUS_TLB, "TLB" },857857+ { TX4938_PCIC_PCICSTATUS_NIB, "NIB" },858858+ { TX4938_PCIC_PCICSTATUS_ZIB, "ZIB" },859859+ { TX4938_PCIC_PCICSTATUS_PERR, "PERR" },860860+ { TX4938_PCIC_PCICSTATUS_SERR, "SERR" },861861+ { TX4938_PCIC_PCICSTATUS_GBE, "GBE" },862862+ { TX4938_PCIC_PCICSTATUS_IWB, "IWB" },863863+ };864864+ int i;865865+866866+ printk("pcistat:%04x(", pcistatus);867867+ for (i = 0; i < ARRAY_SIZE(pcistat_tbl); i++)868868+ if (pcistatus & pcistat_tbl[i].flag)869869+ printk("%s ", pcistat_tbl[i].str);870870+ printk("), g2pstatus:%08lx(", g2pstatus);871871+ for (i = 0; i < ARRAY_SIZE(g2pstat_tbl); i++)872872+ if (g2pstatus & g2pstat_tbl[i].flag)873873+ printk("%s ", g2pstat_tbl[i].str);874874+ printk("), pcicstatus:%08lx(", pcicstatus);875875+ for (i = 0; i < ARRAY_SIZE(pcicstat_tbl); i++)876876+ if (pcicstatus & pcicstat_tbl[i].flag)877877+ printk("%s ", pcicstat_tbl[i].str);878878+ printk(")\n");879879+}880880+881881+void tx4938_report_pcic_status(void)882882+{883883+ int i;884884+ struct tx4938_pcic_reg *pcicptr;885885+ for (i = 0; (pcicptr = get_tx4938_pcicptr(i)) != NULL; i++)886886+ tx4938_report_pcic_status1(pcicptr);887887+}888888+889889+#endif /* CONFIG_PCI */890890+891891+/* We use onchip r4k counter or TMR timer as our system wide timer892892+ * interrupt running at 100HZ. */893893+894894+extern void __init rtc_rx5c348_init(int chipid);895895+void __init rbtx4938_time_init(void)896896+{897897+ rtc_rx5c348_init(RBTX4938_SRTC_CHIPID);898898+ mips_hpt_frequency = txx9_cpu_clock / 2;899899+}900900+901901+void __init toshiba_rbtx4938_setup(void)902902+{903903+ unsigned long long pcfg;904904+ char *argptr;905905+906906+ iomem_resource.end = 0xffffffff; /* 4GB */907907+908908+ if (txx9_master_clock == 0)909909+ txx9_master_clock = 25000000; /* 25MHz */910910+ tx4938_board_setup();911911+ /* setup irq stuff */912912+ TX4938_WR(TX4938_MKA(TX4938_IRC_IRDM0), 0x00000000); /* irq trigger */913913+ TX4938_WR(TX4938_MKA(TX4938_IRC_IRDM1), 0x00000000); /* irq trigger */914914+ /* setup serial stuff */915915+ TX4938_WR(0xff1ff314, 0x00000000); /* h/w flow control off */916916+ TX4938_WR(0xff1ff414, 0x00000000); /* h/w flow control off */917917+918918+#ifndef CONFIG_PCI919919+ set_io_port_base(RBTX4938_ETHER_BASE);920920+#endif921921+922922+#ifdef CONFIG_SERIAL_TXX9923923+ {924924+ extern int early_serial_txx9_setup(struct uart_port *port);925925+ int i;926926+ struct uart_port req;927927+ for(i = 0; i < 2; i++) {928928+ memset(&req, 0, sizeof(req));929929+ req.line = i;930930+ req.iotype = UPIO_MEM;931931+ req.membase = (char *)(0xff1ff300 + i * 0x100);932932+ req.mapbase = 0xff1ff300 + i * 0x100;933933+ req.irq = 32 + i;934934+ req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;935935+ req.uartclk = 50000000;936936+ early_serial_txx9_setup(&req);937937+ }938938+ }939939+#ifdef CONFIG_SERIAL_TXX9_CONSOLE940940+ argptr = prom_getcmdline();941941+ if (strstr(argptr, "console=") == NULL) {942942+ strcat(argptr, " console=ttyS0,38400");943943+ }944944+#endif945945+#endif946946+947947+#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61948948+ printk("PIOSEL: disabling both ata and nand selection\n");949949+ local_irq_disable();950950+ tx4938_ccfgptr->pcfg &= ~(TX4938_PCFG_NDF_SEL | TX4938_PCFG_ATA_SEL);951951+#endif952952+953953+#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_NAND954954+ printk("PIOSEL: enabling nand selection\n");955955+ tx4938_ccfgptr->pcfg |= TX4938_PCFG_NDF_SEL;956956+ tx4938_ccfgptr->pcfg &= ~TX4938_PCFG_ATA_SEL;957957+#endif958958+959959+#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_ATA960960+ printk("PIOSEL: enabling ata selection\n");961961+ tx4938_ccfgptr->pcfg |= TX4938_PCFG_ATA_SEL;962962+ tx4938_ccfgptr->pcfg &= ~TX4938_PCFG_NDF_SEL;963963+#endif964964+965965+#ifdef CONFIG_IP_PNP966966+ argptr = prom_getcmdline();967967+ if (strstr(argptr, "ip=") == NULL) {968968+ strcat(argptr, " ip=any");969969+ }970970+#endif971971+972972+973973+#ifdef CONFIG_FB974974+ {975975+ conswitchp = &dummy_con;976976+ }977977+#endif978978+979979+ rbtx4938_spi_setup();980980+ pcfg = tx4938_ccfgptr->pcfg; /* updated */981981+ /* fixup piosel */982982+ if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) ==983983+ TX4938_PCFG_ATA_SEL) {984984+ *rbtx4938_piosel_ptr = (*rbtx4938_piosel_ptr & 0x03) | 0x04;985985+ }986986+ else if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) ==987987+ TX4938_PCFG_NDF_SEL) {988988+ *rbtx4938_piosel_ptr = (*rbtx4938_piosel_ptr & 0x03) | 0x08;989989+ }990990+ else {991991+ *rbtx4938_piosel_ptr &= ~(0x08 | 0x04);992992+ }993993+994994+ rbtx4938_fpga_resource.name = "FPGA Registers";995995+ rbtx4938_fpga_resource.start = CPHYSADDR(RBTX4938_FPGA_REG_ADDR);996996+ rbtx4938_fpga_resource.end = CPHYSADDR(RBTX4938_FPGA_REG_ADDR) + 0xffff;997997+ rbtx4938_fpga_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY;998998+ if (request_resource(&iomem_resource, &rbtx4938_fpga_resource))999999+ printk("request resource for fpga failed\n");10001000+10011001+ /* disable all OnBoard I/O interrupts */10021002+ *rbtx4938_imask_ptr = 0;10031003+10041004+ _machine_restart = rbtx4938_machine_restart;10051005+ _machine_halt = rbtx4938_machine_halt;10061006+ _machine_power_off = rbtx4938_machine_power_off;10071007+10081008+ *rbtx4938_led_ptr = 0xff;10091009+ printk("RBTX4938 --- FPGA(Rev %02x)", *rbtx4938_fpga_rev_ptr);10101010+ printk(" DIPSW:%02x,%02x\n",10111011+ *rbtx4938_dipsw_ptr, *rbtx4938_bdipsw_ptr);10121012+}10131013+10141014+#ifdef CONFIG_PROC_FS10151015+extern void spi_eeprom_proc_create(struct proc_dir_entry *dir, int chipid);10161016+static int __init tx4938_spi_proc_setup(void)10171017+{10181018+ struct proc_dir_entry *tx4938_spi_eeprom_dir;10191019+10201020+ tx4938_spi_eeprom_dir = proc_mkdir("spi_eeprom", 0);10211021+10221022+ if (!tx4938_spi_eeprom_dir)10231023+ return -ENOMEM;10241024+10251025+ /* don't allow user access to RBTX4938_SEEPROM1_CHIPID10261026+ * as it contains eth0 and eth1 MAC addresses10271027+ */10281028+ spi_eeprom_proc_create(tx4938_spi_eeprom_dir, RBTX4938_SEEPROM2_CHIPID);10291029+ spi_eeprom_proc_create(tx4938_spi_eeprom_dir, RBTX4938_SEEPROM3_CHIPID);10301030+10311031+ return 0;10321032+}10331033+10341034+__initcall(tx4938_spi_proc_setup);10351035+#endif
+219
arch/mips/tx4938/toshiba_rbtx4938/spi_eeprom.c
···11+/*22+ * linux/arch/mips/tx4938/toshiba_rbtx4938/spi_eeprom.c33+ * Copyright (C) 2000-2001 Toshiba Corporation44+ *55+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the66+ * terms of the GNU General Public License version 2. This program is77+ * licensed "as is" without any warranty of any kind, whether express88+ * or implied.99+ *1010+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1111+ */1212+#include <linux/config.h>1313+#include <linux/init.h>1414+#include <linux/delay.h>1515+#include <linux/proc_fs.h>1616+#include <linux/spinlock.h>1717+#include <asm/tx4938/spi.h>1818+#include <asm/tx4938/tx4938.h>1919+2020+/* ATMEL 250x0 instructions */2121+#define ATMEL_WREN 0x062222+#define ATMEL_WRDI 0x042323+#define ATMEL_RDSR 0x052424+#define ATMEL_WRSR 0x012525+#define ATMEL_READ 0x032626+#define ATMEL_WRITE 0x022727+2828+#define ATMEL_SR_BSY 0x012929+#define ATMEL_SR_WEN 0x023030+#define ATMEL_SR_BP0 0x043131+#define ATMEL_SR_BP1 0x083232+3333+DEFINE_SPINLOCK(spi_eeprom_lock);3434+3535+static struct spi_dev_desc seeprom_dev_desc = {3636+ .baud = 1500000, /* 1.5Mbps */3737+ .tcss = 1,3838+ .tcsh = 1,3939+ .tcsr = 1,4040+ .byteorder = 1, /* MSB-First */4141+ .polarity = 0, /* High-Active */4242+ .phase = 0, /* Sample-Then-Shift */4343+4444+};4545+static inline int4646+spi_eeprom_io(int chipid,4747+ unsigned char **inbufs, unsigned int *incounts,4848+ unsigned char **outbufs, unsigned int *outcounts)4949+{5050+ return txx9_spi_io(chipid, &seeprom_dev_desc,5151+ inbufs, incounts, outbufs, outcounts, 0);5252+}5353+5454+int spi_eeprom_write_enable(int chipid, int enable)5555+{5656+ unsigned char inbuf[1];5757+ unsigned char *inbufs[1];5858+ unsigned int incounts[2];5959+ unsigned long flags;6060+ int stat;6161+ inbuf[0] = enable ? ATMEL_WREN : ATMEL_WRDI;6262+ inbufs[0] = inbuf;6363+ incounts[0] = sizeof(inbuf);6464+ incounts[1] = 0;6565+ spin_lock_irqsave(&spi_eeprom_lock, flags);6666+ stat = spi_eeprom_io(chipid, inbufs, incounts, NULL, NULL);6767+ spin_unlock_irqrestore(&spi_eeprom_lock, flags);6868+ return stat;6969+}7070+7171+static int spi_eeprom_read_status_nolock(int chipid)7272+{7373+ unsigned char inbuf[2], outbuf[2];7474+ unsigned char *inbufs[1], *outbufs[1];7575+ unsigned int incounts[2], outcounts[2];7676+ int stat;7777+ inbuf[0] = ATMEL_RDSR;7878+ inbuf[1] = 0;7979+ inbufs[0] = inbuf;8080+ incounts[0] = sizeof(inbuf);8181+ incounts[1] = 0;8282+ outbufs[0] = outbuf;8383+ outcounts[0] = sizeof(outbuf);8484+ outcounts[1] = 0;8585+ stat = spi_eeprom_io(chipid, inbufs, incounts, outbufs, outcounts);8686+ if (stat < 0)8787+ return stat;8888+ return outbuf[1];8989+}9090+9191+int spi_eeprom_read_status(int chipid)9292+{9393+ unsigned long flags;9494+ int stat;9595+ spin_lock_irqsave(&spi_eeprom_lock, flags);9696+ stat = spi_eeprom_read_status_nolock(chipid);9797+ spin_unlock_irqrestore(&spi_eeprom_lock, flags);9898+ return stat;9999+}100100+101101+int spi_eeprom_read(int chipid, int address, unsigned char *buf, int len)102102+{103103+ unsigned char inbuf[2];104104+ unsigned char *inbufs[2], *outbufs[2];105105+ unsigned int incounts[2], outcounts[3];106106+ unsigned long flags;107107+ int stat;108108+ inbuf[0] = ATMEL_READ;109109+ inbuf[1] = address;110110+ inbufs[0] = inbuf;111111+ inbufs[1] = NULL;112112+ incounts[0] = sizeof(inbuf);113113+ incounts[1] = 0;114114+ outbufs[0] = NULL;115115+ outbufs[1] = buf;116116+ outcounts[0] = 2;117117+ outcounts[1] = len;118118+ outcounts[2] = 0;119119+ spin_lock_irqsave(&spi_eeprom_lock, flags);120120+ stat = spi_eeprom_io(chipid, inbufs, incounts, outbufs, outcounts);121121+ spin_unlock_irqrestore(&spi_eeprom_lock, flags);122122+ return stat;123123+}124124+125125+int spi_eeprom_write(int chipid, int address, unsigned char *buf, int len)126126+{127127+ unsigned char inbuf[2];128128+ unsigned char *inbufs[2];129129+ unsigned int incounts[3];130130+ unsigned long flags;131131+ int i, stat;132132+133133+ if (address / 8 != (address + len - 1) / 8)134134+ return -EINVAL;135135+ stat = spi_eeprom_write_enable(chipid, 1);136136+ if (stat < 0)137137+ return stat;138138+ stat = spi_eeprom_read_status(chipid);139139+ if (stat < 0)140140+ return stat;141141+ if (!(stat & ATMEL_SR_WEN))142142+ return -EPERM;143143+144144+ inbuf[0] = ATMEL_WRITE;145145+ inbuf[1] = address;146146+ inbufs[0] = inbuf;147147+ inbufs[1] = buf;148148+ incounts[0] = sizeof(inbuf);149149+ incounts[1] = len;150150+ incounts[2] = 0;151151+ spin_lock_irqsave(&spi_eeprom_lock, flags);152152+ stat = spi_eeprom_io(chipid, inbufs, incounts, NULL, NULL);153153+ if (stat < 0)154154+ goto unlock_return;155155+156156+ /* write start. max 10ms */157157+ for (i = 10; i > 0; i--) {158158+ int stat = spi_eeprom_read_status_nolock(chipid);159159+ if (stat < 0)160160+ goto unlock_return;161161+ if (!(stat & ATMEL_SR_BSY))162162+ break;163163+ mdelay(1);164164+ }165165+ spin_unlock_irqrestore(&spi_eeprom_lock, flags);166166+ if (i == 0)167167+ return -EIO;168168+ return len;169169+ unlock_return:170170+ spin_unlock_irqrestore(&spi_eeprom_lock, flags);171171+ return stat;172172+}173173+174174+#ifdef CONFIG_PROC_FS175175+#define MAX_SIZE 0x80 /* for ATMEL 25010 */176176+static int spi_eeprom_read_proc(char *page, char **start, off_t off,177177+ int count, int *eof, void *data)178178+{179179+ unsigned int size = MAX_SIZE;180180+ if (spi_eeprom_read((int)data, 0, (unsigned char *)page, size) < 0)181181+ size = 0;182182+ return size;183183+}184184+185185+static int spi_eeprom_write_proc(struct file *file, const char *buffer,186186+ unsigned long count, void *data)187187+{188188+ unsigned int size = MAX_SIZE;189189+ int i;190190+ if (file->f_pos >= size)191191+ return -EIO;192192+ if (file->f_pos + count > size)193193+ count = size - file->f_pos;194194+ for (i = 0; i < count; i += 8) {195195+ int len = count - i < 8 ? count - i : 8;196196+ if (spi_eeprom_write((int)data, file->f_pos,197197+ (unsigned char *)buffer, len) < 0) {198198+ count = -EIO;199199+ break;200200+ }201201+ buffer += len;202202+ file->f_pos += len;203203+ }204204+ return count;205205+}206206+207207+__init void spi_eeprom_proc_create(struct proc_dir_entry *dir, int chipid)208208+{209209+ struct proc_dir_entry *entry;210210+ char name[128];211211+ sprintf(name, "seeprom-%d", chipid);212212+ entry = create_proc_entry(name, 0600, dir);213213+ if (entry) {214214+ entry->read_proc = spi_eeprom_read_proc;215215+ entry->write_proc = spi_eeprom_write_proc;216216+ entry->data = (void *)chipid;217217+ }218218+}219219+#endif /* CONFIG_PROC_FS */
+159
arch/mips/tx4938/toshiba_rbtx4938/spi_txx9.c
···11+/*22+ * linux/arch/mips/tx4938/toshiba_rbtx4938/spi_txx9.c33+ * Copyright (C) 2000-2001 Toshiba Corporation44+ *55+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the66+ * terms of the GNU General Public License version 2. This program is77+ * licensed "as is" without any warranty of any kind, whether express88+ * or implied.99+ *1010+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1111+ */1212+#include <linux/init.h>1313+#include <linux/delay.h>1414+#include <linux/errno.h>1515+#include <linux/interrupt.h>1616+#include <linux/module.h>1717+#include <linux/sched.h>1818+#include <linux/spinlock.h>1919+#include <linux/wait.h>2020+#include <asm/tx4938/spi.h>2121+#include <asm/tx4938/tx4938.h>2222+2323+static int (*txx9_spi_cs_func)(int chipid, int on);2424+static DEFINE_SPINLOCK(txx9_spi_lock);2525+2626+extern unsigned int txx9_gbus_clock;2727+2828+#define SPI_FIFO_SIZE 42929+3030+void __init txx9_spi_init(unsigned long base, int (*cs_func)(int chipid, int on))3131+{3232+ txx9_spi_cs_func = cs_func;3333+ /* enter config mode */3434+ tx4938_spiptr->mcr = TXx9_SPMCR_CONFIG | TXx9_SPMCR_BCLR;3535+}3636+3737+static DECLARE_WAIT_QUEUE_HEAD(txx9_spi_wait);3838+static void txx9_spi_interrupt(int irq, void *dev_id, struct pt_regs *regs)3939+{4040+ /* disable rx intr */4141+ tx4938_spiptr->cr0 &= ~TXx9_SPCR0_RBSIE;4242+ wake_up(&txx9_spi_wait);4343+}4444+static struct irqaction txx9_spi_action = {4545+ txx9_spi_interrupt, 0, 0, "spi", NULL, NULL,4646+};4747+4848+void __init txx9_spi_irqinit(int irc_irq)4949+{5050+ setup_irq(irc_irq, &txx9_spi_action);5151+}5252+5353+int txx9_spi_io(int chipid, struct spi_dev_desc *desc,5454+ unsigned char **inbufs, unsigned int *incounts,5555+ unsigned char **outbufs, unsigned int *outcounts,5656+ int cansleep)5757+{5858+ unsigned int incount, outcount;5959+ unsigned char *inp, *outp;6060+ int ret;6161+ unsigned long flags;6262+6363+ spin_lock_irqsave(&txx9_spi_lock, flags);6464+ if ((tx4938_spiptr->mcr & TXx9_SPMCR_OPMODE) == TXx9_SPMCR_ACTIVE) {6565+ spin_unlock_irqrestore(&txx9_spi_lock, flags);6666+ return -EBUSY;6767+ }6868+ /* enter config mode */6969+ tx4938_spiptr->mcr = TXx9_SPMCR_CONFIG | TXx9_SPMCR_BCLR;7070+ tx4938_spiptr->cr0 =7171+ (desc->byteorder ? TXx9_SPCR0_SBOS : 0) |7272+ (desc->polarity ? TXx9_SPCR0_SPOL : 0) |7373+ (desc->phase ? TXx9_SPCR0_SPHA : 0) |7474+ 0x08;7575+ tx4938_spiptr->cr1 =7676+ (((TXX9_IMCLK + desc->baud) / (2 * desc->baud) - 1) << 8) |7777+ 0x08 /* 8 bit only */;7878+ /* enter active mode */7979+ tx4938_spiptr->mcr = TXx9_SPMCR_ACTIVE;8080+ spin_unlock_irqrestore(&txx9_spi_lock, flags);8181+8282+ /* CS ON */8383+ if ((ret = txx9_spi_cs_func(chipid, 1)) < 0) {8484+ spin_unlock_irqrestore(&txx9_spi_lock, flags);8585+ return ret;8686+ }8787+ udelay(desc->tcss);8888+8989+ /* do scatter IO */9090+ inp = inbufs ? *inbufs : NULL;9191+ outp = outbufs ? *outbufs : NULL;9292+ incount = 0;9393+ outcount = 0;9494+ while (1) {9595+ unsigned char data;9696+ unsigned int count;9797+ int i;9898+ if (!incount) {9999+ incount = incounts ? *incounts++ : 0;100100+ inp = (incount && inbufs) ? *inbufs++ : NULL;101101+ }102102+ if (!outcount) {103103+ outcount = outcounts ? *outcounts++ : 0;104104+ outp = (outcount && outbufs) ? *outbufs++ : NULL;105105+ }106106+ if (!inp && !outp)107107+ break;108108+ count = SPI_FIFO_SIZE;109109+ if (incount)110110+ count = min(count, incount);111111+ if (outcount)112112+ count = min(count, outcount);113113+114114+ /* now tx must be idle... */115115+ while (!(tx4938_spiptr->sr & TXx9_SPSR_SIDLE))116116+ ;117117+118118+ tx4938_spiptr->cr0 =119119+ (tx4938_spiptr->cr0 & ~TXx9_SPCR0_RXIFL_MASK) |120120+ ((count - 1) << 12);121121+ if (cansleep) {122122+ /* enable rx intr */123123+ tx4938_spiptr->cr0 |= TXx9_SPCR0_RBSIE;124124+ }125125+ /* send */126126+ for (i = 0; i < count; i++)127127+ tx4938_spiptr->dr = inp ? *inp++ : 0;128128+ /* wait all rx data */129129+ if (cansleep) {130130+ wait_event(txx9_spi_wait,131131+ tx4938_spiptr->sr & TXx9_SPSR_SRRDY);132132+ } else {133133+ while (!(tx4938_spiptr->sr & TXx9_SPSR_RBSI))134134+ ;135135+ }136136+ /* receive */137137+ for (i = 0; i < count; i++) {138138+ data = tx4938_spiptr->dr;139139+ if (outp)140140+ *outp++ = data;141141+ }142142+ if (incount)143143+ incount -= count;144144+ if (outcount)145145+ outcount -= count;146146+ }147147+148148+ /* CS OFF */149149+ udelay(desc->tcsh);150150+ txx9_spi_cs_func(chipid, 0);151151+ udelay(desc->tcsr);152152+153153+ spin_lock_irqsave(&txx9_spi_lock, flags);154154+ /* enter config mode */155155+ tx4938_spiptr->mcr = TXx9_SPMCR_CONFIG | TXx9_SPMCR_BCLR;156156+ spin_unlock_irqrestore(&txx9_spi_lock, flags);157157+158158+ return 0;159159+}
···11+/*22+ * linux/include/asm-mips/tx4938/spi.h33+ * Definitions for TX4937/TX4938 SPI44+ *55+ * Copyright (C) 2000-2001 Toshiba Corporation66+ *77+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the88+ * terms of the GNU General Public License version 2. This program is99+ * licensed "as is" without any warranty of any kind, whether express1010+ * or implied.1111+ *1212+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1313+ */1414+#ifndef __ASM_TX_BOARDS_TX4938_SPI_H1515+#define __ASM_TX_BOARDS_TX4938_SPI_H1616+1717+/* SPI */1818+struct spi_dev_desc {1919+ unsigned int baud;2020+ unsigned short tcss, tcsh, tcsr; /* CS setup/hold/recovery time */2121+ unsigned int byteorder:1; /* 0:LSB-First, 1:MSB-First */2222+ unsigned int polarity:1; /* 0:High-Active */2323+ unsigned int phase:1; /* 0:Sample-Then-Shift */2424+};2525+2626+extern void txx9_spi_init(unsigned long base, int (*cs_func)(int chipid, int on)) __init;2727+extern void txx9_spi_irqinit(int irc_irq) __init;2828+extern int txx9_spi_io(int chipid, struct spi_dev_desc *desc,2929+ unsigned char **inbufs, unsigned int *incounts,3030+ unsigned char **outbufs, unsigned int *outcounts,3131+ int cansleep);3232+extern int spi_eeprom_write_enable(int chipid, int enable);3333+extern int spi_eeprom_read_status(int chipid);3434+extern int spi_eeprom_read(int chipid, int address, unsigned char *buf, int len);3535+extern int spi_eeprom_write(int chipid, int address, unsigned char *buf, int len);3636+extern void spi_eeprom_proc_create(struct proc_dir_entry *dir, int chipid) __init;3737+3838+#define TXX9_IMCLK (txx9_gbus_clock / 2)3939+4040+/*4141+* SPI4242+*/4343+4444+/* SPMCR : SPI Master Control */4545+#define TXx9_SPMCR_OPMODE 0xc04646+#define TXx9_SPMCR_CONFIG 0x404747+#define TXx9_SPMCR_ACTIVE 0x804848+#define TXx9_SPMCR_SPSTP 0x024949+#define TXx9_SPMCR_BCLR 0x015050+5151+/* SPCR0 : SPI Status */5252+#define TXx9_SPCR0_TXIFL_MASK 0xc0005353+#define TXx9_SPCR0_RXIFL_MASK 0x30005454+#define TXx9_SPCR0_SIDIE 0x08005555+#define TXx9_SPCR0_SOEIE 0x04005656+#define TXx9_SPCR0_RBSIE 0x02005757+#define TXx9_SPCR0_TBSIE 0x01005858+#define TXx9_SPCR0_IFSPSE 0x00105959+#define TXx9_SPCR0_SBOS 0x00046060+#define TXx9_SPCR0_SPHA 0x00026161+#define TXx9_SPCR0_SPOL 0x00016262+6363+/* SPSR : SPI Status */6464+#define TXx9_SPSR_TBSI 0x80006565+#define TXx9_SPSR_RBSI 0x40006666+#define TXx9_SPSR_TBS_MASK 0x38006767+#define TXx9_SPSR_RBS_MASK 0x07006868+#define TXx9_SPSR_SPOE 0x00806969+#define TXx9_SPSR_IFSD 0x00087070+#define TXx9_SPSR_SIDLE 0x00047171+#define TXx9_SPSR_STRDY 0x00027272+#define TXx9_SPSR_SRRDY 0x00017373+7474+#endif /* __ASM_TX_BOARDS_TX4938_SPI_H */
+706
include/asm-mips/tx4938/tx4938.h
···11+/*22+ * linux/include/asm-mips/tx4938/tx4938.h33+ * Definitions for TX4937/TX493844+ * Copyright (C) 2000-2001 Toshiba Corporation55+ *66+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the77+ * terms of the GNU General Public License version 2. This program is88+ * licensed "as is" without any warranty of any kind, whether express99+ * or implied.1010+ *1111+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1212+ */1313+#ifndef __ASM_TX_BOARDS_TX4938_H1414+#define __ASM_TX_BOARDS_TX4938_H1515+1616+#include <asm/tx4938/tx4938_mips.h>1717+1818+#define tx4938_read_nfmc(addr) (*(volatile unsigned int *)(addr))1919+#define tx4938_write_nfmc(b,addr) (*(volatile unsigned int *)(addr)) = (b)2020+2121+#define TX4938_NR_IRQ_LOCAL TX4938_IRQ_PIC_BEG2222+2323+#define TX4938_IRQ_IRC_PCIC (TX4938_NR_IRQ_LOCAL + TX4938_IR_PCIC)2424+#define TX4938_IRQ_IRC_PCIERR (TX4938_NR_IRQ_LOCAL + TX4938_IR_PCIERR)2525+2626+#define TX4938_PCIIO_0 0x100000002727+#define TX4938_PCIIO_1 0x010100002828+#define TX4938_PCIMEM_0 0x080000002929+#define TX4938_PCIMEM_1 0x110000003030+3131+#define TX4938_PCIIO_SIZE_0 0x010000003232+#define TX4938_PCIIO_SIZE_1 0x000100003333+#define TX4938_PCIMEM_SIZE_0 0x080000003434+#define TX4938_PCIMEM_SIZE_1 0x000100003535+3636+#define TX4938_REG_BASE 0xff1f0000 /* == TX4937_REG_BASE */3737+#define TX4938_REG_SIZE 0x00010000 /* == TX4937_REG_SIZE */3838+3939+/* NDFMC, SRAMC, PCIC1, SPIC: TX4938 only */4040+#define TX4938_NDFMC_REG (TX4938_REG_BASE + 0x5000)4141+#define TX4938_SRAMC_REG (TX4938_REG_BASE + 0x6000)4242+#define TX4938_PCIC1_REG (TX4938_REG_BASE + 0x7000)4343+#define TX4938_SDRAMC_REG (TX4938_REG_BASE + 0x8000)4444+#define TX4938_EBUSC_REG (TX4938_REG_BASE + 0x9000)4545+#define TX4938_DMA_REG(ch) (TX4938_REG_BASE + 0xb000 + (ch) * 0x800)4646+#define TX4938_PCIC_REG (TX4938_REG_BASE + 0xd000)4747+#define TX4938_CCFG_REG (TX4938_REG_BASE + 0xe000)4848+#define TX4938_NR_TMR 34949+#define TX4938_TMR_REG(ch) ((TX4938_REG_BASE + 0xf000) + (ch) * 0x100)5050+#define TX4938_NR_SIO 25151+#define TX4938_SIO_REG(ch) ((TX4938_REG_BASE + 0xf300) + (ch) * 0x100)5252+#define TX4938_PIO_REG (TX4938_REG_BASE + 0xf500)5353+#define TX4938_IRC_REG (TX4938_REG_BASE + 0xf600)5454+#define TX4938_ACLC_REG (TX4938_REG_BASE + 0xf700)5555+#define TX4938_SPI_REG (TX4938_REG_BASE + 0xf800)5656+5757+#ifndef _LANGUAGE_ASSEMBLY5858+#include <asm/byteorder.h>5959+6060+#define TX4938_MKA(x) ((u32)( ((u32)(TX4938_REG_BASE)) | ((u32)(x)) ))6161+6262+#define TX4938_RD08( reg ) (*(vu08*)(reg))6363+#define TX4938_WR08( reg, val ) ((*(vu08*)(reg))=(val))6464+6565+#define TX4938_RD16( reg ) (*(vu16*)(reg))6666+#define TX4938_WR16( reg, val ) ((*(vu16*)(reg))=(val))6767+6868+#define TX4938_RD32( reg ) (*(vu32*)(reg))6969+#define TX4938_WR32( reg, val ) ((*(vu32*)(reg))=(val))7070+7171+#define TX4938_RD64( reg ) (*(vu64*)(reg))7272+#define TX4938_WR64( reg, val ) ((*(vu64*)(reg))=(val))7373+7474+#define TX4938_RD( reg ) TX4938_RD32( reg )7575+#define TX4938_WR( reg, val ) TX4938_WR32( reg, val )7676+7777+#endif /* !__ASSEMBLY__ */7878+7979+#ifdef __ASSEMBLY__8080+#define _CONST64(c) c8181+#else8282+#define _CONST64(c) c##ull8383+8484+#include <asm/byteorder.h>8585+8686+#ifdef __BIG_ENDIAN8787+#define endian_def_l2(e1,e2) \8888+ volatile unsigned long e1,e28989+#define endian_def_s2(e1,e2) \9090+ volatile unsigned short e1,e29191+#define endian_def_sb2(e1,e2,e3) \9292+ volatile unsigned short e1;volatile unsigned char e2,e39393+#define endian_def_b2s(e1,e2,e3) \9494+ volatile unsigned char e1,e2;volatile unsigned short e39595+#define endian_def_b4(e1,e2,e3,e4) \9696+ volatile unsigned char e1,e2,e3,e49797+#else9898+#define endian_def_l2(e1,e2) \9999+ volatile unsigned long e2,e1100100+#define endian_def_s2(e1,e2) \101101+ volatile unsigned short e2,e1102102+#define endian_def_sb2(e1,e2,e3) \103103+ volatile unsigned char e3,e2;volatile unsigned short e1104104+#define endian_def_b2s(e1,e2,e3) \105105+ volatile unsigned short e3;volatile unsigned char e2,e1106106+#define endian_def_b4(e1,e2,e3,e4) \107107+ volatile unsigned char e4,e3,e2,e1108108+#endif109109+110110+111111+struct tx4938_sdramc_reg {112112+ volatile unsigned long long cr[4];113113+ volatile unsigned long long unused0[4];114114+ volatile unsigned long long tr;115115+ volatile unsigned long long unused1[2];116116+ volatile unsigned long long cmd;117117+ volatile unsigned long long sfcmd;118118+};119119+120120+struct tx4938_ebusc_reg {121121+ volatile unsigned long long cr[8];122122+};123123+124124+struct tx4938_dma_reg {125125+ struct tx4938_dma_ch_reg {126126+ volatile unsigned long long cha;127127+ volatile unsigned long long sar;128128+ volatile unsigned long long dar;129129+ endian_def_l2(unused0, cntr);130130+ endian_def_l2(unused1, sair);131131+ endian_def_l2(unused2, dair);132132+ endian_def_l2(unused3, ccr);133133+ endian_def_l2(unused4, csr);134134+ } ch[4];135135+ volatile unsigned long long dbr[8];136136+ volatile unsigned long long tdhr;137137+ volatile unsigned long long midr;138138+ endian_def_l2(unused0, mcr);139139+};140140+141141+struct tx4938_pcic_reg {142142+ volatile unsigned long pciid;143143+ volatile unsigned long pcistatus;144144+ volatile unsigned long pciccrev;145145+ volatile unsigned long pcicfg1;146146+ volatile unsigned long p2gm0plbase; /* +10 */147147+ volatile unsigned long p2gm0pubase;148148+ volatile unsigned long p2gm1plbase;149149+ volatile unsigned long p2gm1pubase;150150+ volatile unsigned long p2gm2pbase; /* +20 */151151+ volatile unsigned long p2giopbase;152152+ volatile unsigned long unused0;153153+ volatile unsigned long pcisid;154154+ volatile unsigned long unused1; /* +30 */155155+ volatile unsigned long pcicapptr;156156+ volatile unsigned long unused2;157157+ volatile unsigned long pcicfg2;158158+ volatile unsigned long g2ptocnt; /* +40 */159159+ volatile unsigned long unused3[15];160160+ volatile unsigned long g2pstatus; /* +80 */161161+ volatile unsigned long g2pmask;162162+ volatile unsigned long pcisstatus;163163+ volatile unsigned long pcimask;164164+ volatile unsigned long p2gcfg; /* +90 */165165+ volatile unsigned long p2gstatus;166166+ volatile unsigned long p2gmask;167167+ volatile unsigned long p2gccmd;168168+ volatile unsigned long unused4[24]; /* +a0 */169169+ volatile unsigned long pbareqport; /* +100 */170170+ volatile unsigned long pbacfg;171171+ volatile unsigned long pbastatus;172172+ volatile unsigned long pbamask;173173+ volatile unsigned long pbabm; /* +110 */174174+ volatile unsigned long pbacreq;175175+ volatile unsigned long pbacgnt;176176+ volatile unsigned long pbacstate;177177+ volatile unsigned long long g2pmgbase[3]; /* +120 */178178+ volatile unsigned long long g2piogbase;179179+ volatile unsigned long g2pmmask[3]; /* +140 */180180+ volatile unsigned long g2piomask;181181+ volatile unsigned long long g2pmpbase[3]; /* +150 */182182+ volatile unsigned long long g2piopbase;183183+ volatile unsigned long pciccfg; /* +170 */184184+ volatile unsigned long pcicstatus;185185+ volatile unsigned long pcicmask;186186+ volatile unsigned long unused5;187187+ volatile unsigned long long p2gmgbase[3]; /* +180 */188188+ volatile unsigned long long p2giogbase;189189+ volatile unsigned long g2pcfgadrs; /* +1a0 */190190+ volatile unsigned long g2pcfgdata;191191+ volatile unsigned long unused6[8];192192+ volatile unsigned long g2pintack;193193+ volatile unsigned long g2pspc;194194+ volatile unsigned long unused7[12]; /* +1d0 */195195+ volatile unsigned long long pdmca; /* +200 */196196+ volatile unsigned long long pdmga;197197+ volatile unsigned long long pdmpa;198198+ volatile unsigned long long pdmctr;199199+ volatile unsigned long long pdmcfg; /* +220 */200200+ volatile unsigned long long pdmsts;201201+};202202+203203+struct tx4938_aclc_reg {204204+ volatile unsigned long acctlen;205205+ volatile unsigned long acctldis;206206+ volatile unsigned long acregacc;207207+ volatile unsigned long unused0;208208+ volatile unsigned long acintsts;209209+ volatile unsigned long acintmsts;210210+ volatile unsigned long acinten;211211+ volatile unsigned long acintdis;212212+ volatile unsigned long acsemaph;213213+ volatile unsigned long unused1[7];214214+ volatile unsigned long acgpidat;215215+ volatile unsigned long acgpodat;216216+ volatile unsigned long acslten;217217+ volatile unsigned long acsltdis;218218+ volatile unsigned long acfifosts;219219+ volatile unsigned long unused2[11];220220+ volatile unsigned long acdmasts;221221+ volatile unsigned long acdmasel;222222+ volatile unsigned long unused3[6];223223+ volatile unsigned long acaudodat;224224+ volatile unsigned long acsurrdat;225225+ volatile unsigned long accentdat;226226+ volatile unsigned long aclfedat;227227+ volatile unsigned long acaudiat;228228+ volatile unsigned long unused4;229229+ volatile unsigned long acmodoat;230230+ volatile unsigned long acmodidat;231231+ volatile unsigned long unused5[15];232232+ volatile unsigned long acrevid;233233+};234234+235235+236236+struct tx4938_tmr_reg {237237+ volatile unsigned long tcr;238238+ volatile unsigned long tisr;239239+ volatile unsigned long cpra;240240+ volatile unsigned long cprb;241241+ volatile unsigned long itmr;242242+ volatile unsigned long unused0[3];243243+ volatile unsigned long ccdr;244244+ volatile unsigned long unused1[3];245245+ volatile unsigned long pgmr;246246+ volatile unsigned long unused2[3];247247+ volatile unsigned long wtmr;248248+ volatile unsigned long unused3[43];249249+ volatile unsigned long trr;250250+};251251+252252+struct tx4938_sio_reg {253253+ volatile unsigned long lcr;254254+ volatile unsigned long dicr;255255+ volatile unsigned long disr;256256+ volatile unsigned long cisr;257257+ volatile unsigned long fcr;258258+ volatile unsigned long flcr;259259+ volatile unsigned long bgr;260260+ volatile unsigned long tfifo;261261+ volatile unsigned long rfifo;262262+};263263+264264+struct tx4938_pio_reg {265265+ volatile unsigned long dout;266266+ volatile unsigned long din;267267+ volatile unsigned long dir;268268+ volatile unsigned long od;269269+ volatile unsigned long flag[2];270270+ volatile unsigned long pol;271271+ volatile unsigned long intc;272272+ volatile unsigned long maskcpu;273273+ volatile unsigned long maskext;274274+};275275+struct tx4938_irc_reg {276276+ volatile unsigned long cer;277277+ volatile unsigned long cr[2];278278+ volatile unsigned long unused0;279279+ volatile unsigned long ilr[8];280280+ volatile unsigned long unused1[4];281281+ volatile unsigned long imr;282282+ volatile unsigned long unused2[7];283283+ volatile unsigned long scr;284284+ volatile unsigned long unused3[7];285285+ volatile unsigned long ssr;286286+ volatile unsigned long unused4[7];287287+ volatile unsigned long csr;288288+};289289+290290+struct tx4938_ndfmc_reg {291291+ endian_def_l2(unused0, dtr);292292+ endian_def_l2(unused1, mcr);293293+ endian_def_l2(unused2, sr);294294+ endian_def_l2(unused3, isr);295295+ endian_def_l2(unused4, imr);296296+ endian_def_l2(unused5, spr);297297+ endian_def_l2(unused6, rstr);298298+};299299+300300+struct tx4938_spi_reg {301301+ volatile unsigned long mcr;302302+ volatile unsigned long cr0;303303+ volatile unsigned long cr1;304304+ volatile unsigned long fs;305305+ volatile unsigned long unused1;306306+ volatile unsigned long sr;307307+ volatile unsigned long dr;308308+ volatile unsigned long unused2;309309+};310310+311311+struct tx4938_sramc_reg {312312+ volatile unsigned long long cr;313313+};314314+315315+struct tx4938_ccfg_reg {316316+ volatile unsigned long long ccfg;317317+ volatile unsigned long long crir;318318+ volatile unsigned long long pcfg;319319+ volatile unsigned long long tear;320320+ volatile unsigned long long clkctr;321321+ volatile unsigned long long unused0;322322+ volatile unsigned long long garbc;323323+ volatile unsigned long long unused1;324324+ volatile unsigned long long unused2;325325+ volatile unsigned long long ramp;326326+ volatile unsigned long long unused3;327327+ volatile unsigned long long jmpadr;328328+};329329+330330+#undef endian_def_l2331331+#undef endian_def_s2332332+#undef endian_def_sb2333333+#undef endian_def_b2s334334+#undef endian_def_b4335335+336336+#endif /* __ASSEMBLY__ */337337+338338+/*339339+ * NDFMC340340+ */341341+342342+/* NDFMCR : NDFMC Mode Control */343343+#define TX4938_NDFMCR_WE 0x80344344+#define TX4938_NDFMCR_ECC_ALL 0x60345345+#define TX4938_NDFMCR_ECC_RESET 0x60346346+#define TX4938_NDFMCR_ECC_READ 0x40347347+#define TX4938_NDFMCR_ECC_ON 0x20348348+#define TX4938_NDFMCR_ECC_OFF 0x00349349+#define TX4938_NDFMCR_CE 0x10350350+#define TX4938_NDFMCR_BSPRT 0x04351351+#define TX4938_NDFMCR_ALE 0x02352352+#define TX4938_NDFMCR_CLE 0x01353353+354354+/* NDFMCR : NDFMC Status */355355+#define TX4938_NDFSR_BUSY 0x80356356+357357+/* NDFMCR : NDFMC Reset */358358+#define TX4938_NDFRSTR_RST 0x01359359+360360+/*361361+ * IRC362362+ */363363+364364+#define TX4938_IR_ECCERR 0365365+#define TX4938_IR_WTOERR 1366366+#define TX4938_NUM_IR_INT 6367367+#define TX4938_IR_INT(n) (2 + (n))368368+#define TX4938_NUM_IR_SIO 2369369+#define TX4938_IR_SIO(n) (8 + (n))370370+#define TX4938_NUM_IR_DMA 4371371+#define TX4938_IR_DMA(ch,n) ((ch ? 27 : 10) + (n)) /* 10-13,27-30 */372372+#define TX4938_IR_PIO 14373373+#define TX4938_IR_PDMAC 15374374+#define TX4938_IR_PCIC 16375375+#define TX4938_NUM_IR_TMR 3376376+#define TX4938_IR_TMR(n) (17 + (n))377377+#define TX4938_IR_NDFMC 21378378+#define TX4938_IR_PCIERR 22379379+#define TX4938_IR_PCIPME 23380380+#define TX4938_IR_ACLC 24381381+#define TX4938_IR_ACLCPME 25382382+#define TX4938_IR_PCIC1 26383383+#define TX4938_IR_SPI 31384384+#define TX4938_NUM_IR 32385385+/* multiplex */386386+#define TX4938_IR_ETH0 TX4938_IR_INT(4)387387+#define TX4938_IR_ETH1 TX4938_IR_INT(3)388388+389389+/*390390+ * CCFG391391+ */392392+/* CCFG : Chip Configuration */393393+#define TX4938_CCFG_WDRST _CONST64(0x0000020000000000)394394+#define TX4938_CCFG_WDREXEN _CONST64(0x0000010000000000)395395+#define TX4938_CCFG_BCFG_MASK _CONST64(0x000000ff00000000)396396+#define TX4938_CCFG_TINTDIS 0x01000000397397+#define TX4938_CCFG_PCI66 0x00800000398398+#define TX4938_CCFG_PCIMODE 0x00400000399399+#define TX4938_CCFG_PCI1_66 0x00200000400400+#define TX4938_CCFG_DIVMODE_MASK 0x001e0000401401+#define TX4938_CCFG_DIVMODE_2 (0x4 << 17)402402+#define TX4938_CCFG_DIVMODE_2_5 (0xf << 17)403403+#define TX4938_CCFG_DIVMODE_3 (0x5 << 17)404404+#define TX4938_CCFG_DIVMODE_4 (0x6 << 17)405405+#define TX4938_CCFG_DIVMODE_4_5 (0xd << 17)406406+#define TX4938_CCFG_DIVMODE_8 (0x0 << 17)407407+#define TX4938_CCFG_DIVMODE_10 (0xb << 17)408408+#define TX4938_CCFG_DIVMODE_12 (0x1 << 17)409409+#define TX4938_CCFG_DIVMODE_16 (0x2 << 17)410410+#define TX4938_CCFG_DIVMODE_18 (0x9 << 17)411411+#define TX4938_CCFG_BEOW 0x00010000412412+#define TX4938_CCFG_WR 0x00008000413413+#define TX4938_CCFG_TOE 0x00004000414414+#define TX4938_CCFG_PCIXARB 0x00002000415415+#define TX4938_CCFG_PCIDIVMODE_MASK 0x00001c00416416+#define TX4938_CCFG_PCIDIVMODE_4 (0x1 << 10)417417+#define TX4938_CCFG_PCIDIVMODE_4_5 (0x3 << 10)418418+#define TX4938_CCFG_PCIDIVMODE_5 (0x5 << 10)419419+#define TX4938_CCFG_PCIDIVMODE_5_5 (0x7 << 10)420420+#define TX4938_CCFG_PCIDIVMODE_8 (0x0 << 10)421421+#define TX4938_CCFG_PCIDIVMODE_9 (0x2 << 10)422422+#define TX4938_CCFG_PCIDIVMODE_10 (0x4 << 10)423423+#define TX4938_CCFG_PCIDIVMODE_11 (0x6 << 10)424424+#define TX4938_CCFG_PCI1DMD 0x00000100425425+#define TX4938_CCFG_SYSSP_MASK 0x000000c0426426+#define TX4938_CCFG_ENDIAN 0x00000004427427+#define TX4938_CCFG_HALT 0x00000002428428+#define TX4938_CCFG_ACEHOLD 0x00000001429429+430430+/* PCFG : Pin Configuration */431431+#define TX4938_PCFG_ETH0_SEL _CONST64(0x8000000000000000)432432+#define TX4938_PCFG_ETH1_SEL _CONST64(0x4000000000000000)433433+#define TX4938_PCFG_ATA_SEL _CONST64(0x2000000000000000)434434+#define TX4938_PCFG_ISA_SEL _CONST64(0x1000000000000000)435435+#define TX4938_PCFG_SPI_SEL _CONST64(0x0800000000000000)436436+#define TX4938_PCFG_NDF_SEL _CONST64(0x0400000000000000)437437+#define TX4938_PCFG_SDCLKDLY_MASK 0x30000000438438+#define TX4938_PCFG_SDCLKDLY(d) ((d)<<28)439439+#define TX4938_PCFG_SYSCLKEN 0x08000000440440+#define TX4938_PCFG_SDCLKEN_ALL 0x07800000441441+#define TX4938_PCFG_SDCLKEN(ch) (0x00800000<<(ch))442442+#define TX4938_PCFG_PCICLKEN_ALL 0x003f0000443443+#define TX4938_PCFG_PCICLKEN(ch) (0x00010000<<(ch))444444+#define TX4938_PCFG_SEL2 0x00000200445445+#define TX4938_PCFG_SEL1 0x00000100446446+#define TX4938_PCFG_DMASEL_ALL 0x0000000f447447+#define TX4938_PCFG_DMASEL0_DRQ0 0x00000000448448+#define TX4938_PCFG_DMASEL0_SIO1 0x00000001449449+#define TX4938_PCFG_DMASEL1_DRQ1 0x00000000450450+#define TX4938_PCFG_DMASEL1_SIO1 0x00000002451451+#define TX4938_PCFG_DMASEL2_DRQ2 0x00000000452452+#define TX4938_PCFG_DMASEL2_SIO0 0x00000004453453+#define TX4938_PCFG_DMASEL3_DRQ3 0x00000000454454+#define TX4938_PCFG_DMASEL3_SIO0 0x00000008455455+456456+/* CLKCTR : Clock Control */457457+#define TX4938_CLKCTR_NDFCKD _CONST64(0x0001000000000000)458458+#define TX4938_CLKCTR_NDFRST _CONST64(0x0000000100000000)459459+#define TX4938_CLKCTR_ETH1CKD 0x80000000460460+#define TX4938_CLKCTR_ETH0CKD 0x40000000461461+#define TX4938_CLKCTR_SPICKD 0x20000000462462+#define TX4938_CLKCTR_SRAMCKD 0x10000000463463+#define TX4938_CLKCTR_PCIC1CKD 0x08000000464464+#define TX4938_CLKCTR_DMA1CKD 0x04000000465465+#define TX4938_CLKCTR_ACLCKD 0x02000000466466+#define TX4938_CLKCTR_PIOCKD 0x01000000467467+#define TX4938_CLKCTR_DMACKD 0x00800000468468+#define TX4938_CLKCTR_PCICKD 0x00400000469469+#define TX4938_CLKCTR_TM0CKD 0x00100000470470+#define TX4938_CLKCTR_TM1CKD 0x00080000471471+#define TX4938_CLKCTR_TM2CKD 0x00040000472472+#define TX4938_CLKCTR_SIO0CKD 0x00020000473473+#define TX4938_CLKCTR_SIO1CKD 0x00010000474474+#define TX4938_CLKCTR_ETH1RST 0x00008000475475+#define TX4938_CLKCTR_ETH0RST 0x00004000476476+#define TX4938_CLKCTR_SPIRST 0x00002000477477+#define TX4938_CLKCTR_SRAMRST 0x00001000478478+#define TX4938_CLKCTR_PCIC1RST 0x00000800479479+#define TX4938_CLKCTR_DMA1RST 0x00000400480480+#define TX4938_CLKCTR_ACLRST 0x00000200481481+#define TX4938_CLKCTR_PIORST 0x00000100482482+#define TX4938_CLKCTR_DMARST 0x00000080483483+#define TX4938_CLKCTR_PCIRST 0x00000040484484+#define TX4938_CLKCTR_TM0RST 0x00000010485485+#define TX4938_CLKCTR_TM1RST 0x00000008486486+#define TX4938_CLKCTR_TM2RST 0x00000004487487+#define TX4938_CLKCTR_SIO0RST 0x00000002488488+#define TX4938_CLKCTR_SIO1RST 0x00000001489489+490490+/* bits for G2PSTATUS/G2PMASK */491491+#define TX4938_PCIC_G2PSTATUS_ALL 0x00000003492492+#define TX4938_PCIC_G2PSTATUS_TTOE 0x00000002493493+#define TX4938_PCIC_G2PSTATUS_RTOE 0x00000001494494+495495+/* bits for PCIMASK (see also PCI_STATUS_XXX in linux/pci.h */496496+#define TX4938_PCIC_PCISTATUS_ALL 0x0000f900497497+498498+/* bits for PBACFG */499499+#define TX4938_PCIC_PBACFG_FIXPA 0x00000008500500+#define TX4938_PCIC_PBACFG_RPBA 0x00000004501501+#define TX4938_PCIC_PBACFG_PBAEN 0x00000002502502+#define TX4938_PCIC_PBACFG_BMCEN 0x00000001503503+504504+/* bits for G2PMnGBASE */505505+#define TX4938_PCIC_G2PMnGBASE_BSDIS _CONST64(0x0000002000000000)506506+#define TX4938_PCIC_G2PMnGBASE_ECHG _CONST64(0x0000001000000000)507507+508508+/* bits for G2PIOGBASE */509509+#define TX4938_PCIC_G2PIOGBASE_BSDIS _CONST64(0x0000002000000000)510510+#define TX4938_PCIC_G2PIOGBASE_ECHG _CONST64(0x0000001000000000)511511+512512+/* bits for PCICSTATUS/PCICMASK */513513+#define TX4938_PCIC_PCICSTATUS_ALL 0x000007b8514514+#define TX4938_PCIC_PCICSTATUS_PME 0x00000400515515+#define TX4938_PCIC_PCICSTATUS_TLB 0x00000200516516+#define TX4938_PCIC_PCICSTATUS_NIB 0x00000100517517+#define TX4938_PCIC_PCICSTATUS_ZIB 0x00000080518518+#define TX4938_PCIC_PCICSTATUS_PERR 0x00000020519519+#define TX4938_PCIC_PCICSTATUS_SERR 0x00000010520520+#define TX4938_PCIC_PCICSTATUS_GBE 0x00000008521521+#define TX4938_PCIC_PCICSTATUS_IWB 0x00000002522522+#define TX4938_PCIC_PCICSTATUS_E2PDONE 0x00000001523523+524524+/* bits for PCICCFG */525525+#define TX4938_PCIC_PCICCFG_GBWC_MASK 0x0fff0000526526+#define TX4938_PCIC_PCICCFG_HRST 0x00000800527527+#define TX4938_PCIC_PCICCFG_SRST 0x00000400528528+#define TX4938_PCIC_PCICCFG_IRBER 0x00000200529529+#define TX4938_PCIC_PCICCFG_G2PMEN(ch) (0x00000100>>(ch))530530+#define TX4938_PCIC_PCICCFG_G2PM0EN 0x00000100531531+#define TX4938_PCIC_PCICCFG_G2PM1EN 0x00000080532532+#define TX4938_PCIC_PCICCFG_G2PM2EN 0x00000040533533+#define TX4938_PCIC_PCICCFG_G2PIOEN 0x00000020534534+#define TX4938_PCIC_PCICCFG_TCAR 0x00000010535535+#define TX4938_PCIC_PCICCFG_ICAEN 0x00000008536536+537537+/* bits for P2GMnGBASE */538538+#define TX4938_PCIC_P2GMnGBASE_TMEMEN _CONST64(0x0000004000000000)539539+#define TX4938_PCIC_P2GMnGBASE_TBSDIS _CONST64(0x0000002000000000)540540+#define TX4938_PCIC_P2GMnGBASE_TECHG _CONST64(0x0000001000000000)541541+542542+/* bits for P2GIOGBASE */543543+#define TX4938_PCIC_P2GIOGBASE_TIOEN _CONST64(0x0000004000000000)544544+#define TX4938_PCIC_P2GIOGBASE_TBSDIS _CONST64(0x0000002000000000)545545+#define TX4938_PCIC_P2GIOGBASE_TECHG _CONST64(0x0000001000000000)546546+547547+#define TX4938_PCIC_IDSEL_AD_TO_SLOT(ad) ((ad) - 11)548548+#define TX4938_PCIC_MAX_DEVNU TX4938_PCIC_IDSEL_AD_TO_SLOT(32)549549+550550+/* bits for PDMCFG */551551+#define TX4938_PCIC_PDMCFG_RSTFIFO 0x00200000552552+#define TX4938_PCIC_PDMCFG_EXFER 0x00100000553553+#define TX4938_PCIC_PDMCFG_REQDLY_MASK 0x00003800554554+#define TX4938_PCIC_PDMCFG_REQDLY_NONE (0 << 11)555555+#define TX4938_PCIC_PDMCFG_REQDLY_16 (1 << 11)556556+#define TX4938_PCIC_PDMCFG_REQDLY_32 (2 << 11)557557+#define TX4938_PCIC_PDMCFG_REQDLY_64 (3 << 11)558558+#define TX4938_PCIC_PDMCFG_REQDLY_128 (4 << 11)559559+#define TX4938_PCIC_PDMCFG_REQDLY_256 (5 << 11)560560+#define TX4938_PCIC_PDMCFG_REQDLY_512 (6 << 11)561561+#define TX4938_PCIC_PDMCFG_REQDLY_1024 (7 << 11)562562+#define TX4938_PCIC_PDMCFG_ERRIE 0x00000400563563+#define TX4938_PCIC_PDMCFG_NCCMPIE 0x00000200564564+#define TX4938_PCIC_PDMCFG_NTCMPIE 0x00000100565565+#define TX4938_PCIC_PDMCFG_CHNEN 0x00000080566566+#define TX4938_PCIC_PDMCFG_XFRACT 0x00000040567567+#define TX4938_PCIC_PDMCFG_BSWAP 0x00000020568568+#define TX4938_PCIC_PDMCFG_XFRSIZE_MASK 0x0000000c569569+#define TX4938_PCIC_PDMCFG_XFRSIZE_1DW 0x00000000570570+#define TX4938_PCIC_PDMCFG_XFRSIZE_1QW 0x00000004571571+#define TX4938_PCIC_PDMCFG_XFRSIZE_4QW 0x00000008572572+#define TX4938_PCIC_PDMCFG_XFRDIRC 0x00000002573573+#define TX4938_PCIC_PDMCFG_CHRST 0x00000001574574+575575+/* bits for PDMSTS */576576+#define TX4938_PCIC_PDMSTS_REQCNT_MASK 0x3f000000577577+#define TX4938_PCIC_PDMSTS_FIFOCNT_MASK 0x00f00000578578+#define TX4938_PCIC_PDMSTS_FIFOWP_MASK 0x000c0000579579+#define TX4938_PCIC_PDMSTS_FIFORP_MASK 0x00030000580580+#define TX4938_PCIC_PDMSTS_ERRINT 0x00000800581581+#define TX4938_PCIC_PDMSTS_DONEINT 0x00000400582582+#define TX4938_PCIC_PDMSTS_CHNEN 0x00000200583583+#define TX4938_PCIC_PDMSTS_XFRACT 0x00000100584584+#define TX4938_PCIC_PDMSTS_ACCMP 0x00000080585585+#define TX4938_PCIC_PDMSTS_NCCMP 0x00000040586586+#define TX4938_PCIC_PDMSTS_NTCMP 0x00000020587587+#define TX4938_PCIC_PDMSTS_CFGERR 0x00000008588588+#define TX4938_PCIC_PDMSTS_PCIERR 0x00000004589589+#define TX4938_PCIC_PDMSTS_CHNERR 0x00000002590590+#define TX4938_PCIC_PDMSTS_DATAERR 0x00000001591591+#define TX4938_PCIC_PDMSTS_ALL_CMP 0x000000e0592592+#define TX4938_PCIC_PDMSTS_ALL_ERR 0x0000000f593593+594594+/*595595+ * DMA596596+ */597597+/* bits for MCR */598598+#define TX4938_DMA_MCR_EIS(ch) (0x10000000<<(ch))599599+#define TX4938_DMA_MCR_DIS(ch) (0x01000000<<(ch))600600+#define TX4938_DMA_MCR_RSFIF 0x00000080601601+#define TX4938_DMA_MCR_FIFUM(ch) (0x00000008<<(ch))602602+#define TX4938_DMA_MCR_RPRT 0x00000002603603+#define TX4938_DMA_MCR_MSTEN 0x00000001604604+605605+/* bits for CCRn */606606+#define TX4938_DMA_CCR_IMMCHN 0x20000000607607+#define TX4938_DMA_CCR_USEXFSZ 0x10000000608608+#define TX4938_DMA_CCR_LE 0x08000000609609+#define TX4938_DMA_CCR_DBINH 0x04000000610610+#define TX4938_DMA_CCR_SBINH 0x02000000611611+#define TX4938_DMA_CCR_CHRST 0x01000000612612+#define TX4938_DMA_CCR_RVBYTE 0x00800000613613+#define TX4938_DMA_CCR_ACKPOL 0x00400000614614+#define TX4938_DMA_CCR_REQPL 0x00200000615615+#define TX4938_DMA_CCR_EGREQ 0x00100000616616+#define TX4938_DMA_CCR_CHDN 0x00080000617617+#define TX4938_DMA_CCR_DNCTL 0x00060000618618+#define TX4938_DMA_CCR_EXTRQ 0x00010000619619+#define TX4938_DMA_CCR_INTRQD 0x0000e000620620+#define TX4938_DMA_CCR_INTENE 0x00001000621621+#define TX4938_DMA_CCR_INTENC 0x00000800622622+#define TX4938_DMA_CCR_INTENT 0x00000400623623+#define TX4938_DMA_CCR_CHNEN 0x00000200624624+#define TX4938_DMA_CCR_XFACT 0x00000100625625+#define TX4938_DMA_CCR_SMPCHN 0x00000020626626+#define TX4938_DMA_CCR_XFSZ(order) (((order) << 2) & 0x0000001c)627627+#define TX4938_DMA_CCR_XFSZ_1W TX4938_DMA_CCR_XFSZ(2)628628+#define TX4938_DMA_CCR_XFSZ_2W TX4938_DMA_CCR_XFSZ(3)629629+#define TX4938_DMA_CCR_XFSZ_4W TX4938_DMA_CCR_XFSZ(4)630630+#define TX4938_DMA_CCR_XFSZ_8W TX4938_DMA_CCR_XFSZ(5)631631+#define TX4938_DMA_CCR_XFSZ_16W TX4938_DMA_CCR_XFSZ(6)632632+#define TX4938_DMA_CCR_XFSZ_32W TX4938_DMA_CCR_XFSZ(7)633633+#define TX4938_DMA_CCR_MEMIO 0x00000002634634+#define TX4938_DMA_CCR_SNGAD 0x00000001635635+636636+/* bits for CSRn */637637+#define TX4938_DMA_CSR_CHNEN 0x00000400638638+#define TX4938_DMA_CSR_STLXFER 0x00000200639639+#define TX4938_DMA_CSR_CHNACT 0x00000100640640+#define TX4938_DMA_CSR_ABCHC 0x00000080641641+#define TX4938_DMA_CSR_NCHNC 0x00000040642642+#define TX4938_DMA_CSR_NTRNFC 0x00000020643643+#define TX4938_DMA_CSR_EXTDN 0x00000010644644+#define TX4938_DMA_CSR_CFERR 0x00000008645645+#define TX4938_DMA_CSR_CHERR 0x00000004646646+#define TX4938_DMA_CSR_DESERR 0x00000002647647+#define TX4938_DMA_CSR_SORERR 0x00000001648648+649649+/* TX4938 Interrupt Controller (32-bit registers) */650650+#define TX4938_IRC_BASE 0xf510651651+#define TX4938_IRC_IRFLAG0 0xf510652652+#define TX4938_IRC_IRFLAG1 0xf514653653+#define TX4938_IRC_IRPOL 0xf518654654+#define TX4938_IRC_IRRCNT 0xf51c655655+#define TX4938_IRC_IRMASKINT 0xf520656656+#define TX4938_IRC_IRMASKEXT 0xf524657657+#define TX4938_IRC_IRDEN 0xf600658658+#define TX4938_IRC_IRDM0 0xf604659659+#define TX4938_IRC_IRDM1 0xf608660660+#define TX4938_IRC_IRLVL0 0xf610661661+#define TX4938_IRC_IRLVL1 0xf614662662+#define TX4938_IRC_IRLVL2 0xf618663663+#define TX4938_IRC_IRLVL3 0xf61c664664+#define TX4938_IRC_IRLVL4 0xf620665665+#define TX4938_IRC_IRLVL5 0xf624666666+#define TX4938_IRC_IRLVL6 0xf628667667+#define TX4938_IRC_IRLVL7 0xf62c668668+#define TX4938_IRC_IRMSK 0xf640669669+#define TX4938_IRC_IREDC 0xf660670670+#define TX4938_IRC_IRPND 0xf680671671+#define TX4938_IRC_IRCS 0xf6a0672672+#define TX4938_IRC_LIMIT 0xf6ff673673+674674+675675+#ifndef __ASSEMBLY__676676+677677+#define tx4938_sdramcptr ((struct tx4938_sdramc_reg *)TX4938_SDRAMC_REG)678678+#define tx4938_ebuscptr ((struct tx4938_ebusc_reg *)TX4938_EBUSC_REG)679679+#define tx4938_dmaptr(ch) ((struct tx4938_dma_reg *)TX4938_DMA_REG(ch))680680+#define tx4938_ndfmcptr ((struct tx4938_ndfmc_reg *)TX4938_NDFMC_REG)681681+#define tx4938_ircptr ((struct tx4938_irc_reg *)TX4938_IRC_REG)682682+#define tx4938_pcicptr ((struct tx4938_pcic_reg *)TX4938_PCIC_REG)683683+#define tx4938_pcic1ptr ((struct tx4938_pcic_reg *)TX4938_PCIC1_REG)684684+#define tx4938_ccfgptr ((struct tx4938_ccfg_reg *)TX4938_CCFG_REG)685685+#define tx4938_tmrptr(ch) ((struct tx4938_tmr_reg *)TX4938_TMR_REG(ch))686686+#define tx4938_sioptr(ch) ((struct tx4938_sio_reg *)TX4938_SIO_REG(ch))687687+#define tx4938_pioptr ((struct tx4938_pio_reg *)TX4938_PIO_REG)688688+#define tx4938_aclcptr ((struct tx4938_aclc_reg *)TX4938_ACLC_REG)689689+#define tx4938_spiptr ((struct tx4938_spi_reg *)TX4938_SPI_REG)690690+#define tx4938_sramcptr ((struct tx4938_sramc_reg *)TX4938_SRAMC_REG)691691+692692+693693+#define TX4938_REV_MAJ_MIN() ((unsigned long)tx4938_ccfgptr->crir & 0x00ff)694694+#define TX4938_REV_PCODE() ((unsigned long)tx4938_ccfgptr->crir >> 16)695695+696696+#define TX4938_SDRAMC_BA(ch) ((tx4938_sdramcptr->cr[ch] >> 49) << 21)697697+#define TX4938_SDRAMC_SIZE(ch) (((tx4938_sdramcptr->cr[ch] >> 33) + 1) << 21)698698+699699+#define TX4938_EBUSC_BA(ch) ((tx4938_ebuscptr->cr[ch] >> 48) << 20)700700+#define TX4938_EBUSC_SIZE(ch) \701701+ (0x00100000 << ((unsigned long)(tx4938_ebuscptr->cr[ch] >> 8) & 0xf))702702+703703+704704+#endif /* !__ASSEMBLY__ */705705+706706+#endif
+54
include/asm-mips/tx4938/tx4938_mips.h
···11+/*22+ * linux/include/asm-mips/tx4938/tx4938_bitmask.h33+ * Generic bitmask definitions44+ *55+ * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the66+ * terms of the GNU General Public License version 2. This program is77+ * licensed "as is" without any warranty of any kind, whether express88+ * or implied.99+ *1010+ * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)1111+ */1212+1313+#ifndef TX4938_TX4938_MIPS_H1414+#define TX4938_TX4938_MIPS_H1515+#ifndef __ASSEMBLY__1616+1717+#define reg_rd08(r) ((u8 )(*((vu8 *)(r))))1818+#define reg_rd16(r) ((u16)(*((vu16*)(r))))1919+#define reg_rd32(r) ((u32)(*((vu32*)(r))))2020+#define reg_rd64(r) ((u64)(*((vu64*)(r))))2121+2222+#define reg_wr08(r,v) ((*((vu8 *)(r)))=((u8 )(v)))2323+#define reg_wr16(r,v) ((*((vu16*)(r)))=((u16)(v)))2424+#define reg_wr32(r,v) ((*((vu32*)(r)))=((u32)(v)))2525+#define reg_wr64(r,v) ((*((vu64*)(r)))=((u64)(v)))2626+2727+typedef volatile __signed char vs8;2828+typedef volatile unsigned char vu8;2929+3030+typedef volatile __signed short vs16;3131+typedef volatile unsigned short vu16;3232+3333+typedef volatile __signed int vs32;3434+typedef volatile unsigned int vu32;3535+3636+typedef s8 s08;3737+typedef vs8 vs08;3838+3939+typedef u8 u08;4040+typedef vu8 vu08;4141+4242+#if (_MIPS_SZLONG == 64)4343+4444+typedef volatile __signed__ long vs64;4545+typedef volatile unsigned long vu64;4646+4747+#else4848+4949+typedef volatile __signed__ long long vs64;5050+typedef volatile unsigned long long vu64;5151+5252+#endif5353+#endif5454+#endif