📄 ev64260.c
字号:
/* * arch/ppc/platforms/ev64260.c * * Board setup routines for the Marvell/Galileo EV-64260-BP Evaluation Board. * * Author: Mark A. Greer <mgreer@mvista.com> * * 2001-2003 (c) MontaVista, Software, Inc. This file is licensed under * the terms of the GNU General Public License version 2. This program * is licensed "as is" without any warranty of any kind, whether express * or implied. *//* * The EV-64260-BP port is the result of hard work from many people from * many companies. In particular, employees of Marvell/Galileo, Mission * Critical Linux, Xyterra, and MontaVista Software were heavily involved. * * Note: I have not been able to get *all* PCI slots to work reliably * at 66 MHz. I recommend setting jumpers J15 & J16 to short pins 1&2 * so that 33 MHz is used. --MAG * Note: The 750CXe and 7450 are not stable with a 125MHz or 133MHz TCLK/SYSCLK. * At 100MHz, they are solid. */#include <linux/config.h>#include <linux/delay.h>#include <linux/pci.h>#include <linux/ide.h>#include <linux/irq.h>#include <linux/fs.h>#include <linux/seq_file.h>#include <linux/console.h>#include <linux/initrd.h>#include <linux/root_dev.h>#include <linux/platform_device.h>#if !defined(CONFIG_SERIAL_MPSC_CONSOLE)#include <linux/serial.h>#include <linux/tty.h>#include <linux/serial_core.h>#else#include <linux/mv643xx.h>#endif#include <asm/bootinfo.h>#include <asm/machdep.h>#include <asm/mv64x60.h>#include <asm/todc.h>#include <asm/time.h>#include <platforms/ev64260.h>#define BOARD_VENDOR "Marvell/Galileo"#define BOARD_MACHINE "EV-64260-BP"static struct mv64x60_handle bh;#if !defined(CONFIG_SERIAL_MPSC_CONSOLE)extern void gen550_progress(char *, unsigned short);extern void gen550_init(int, struct uart_port *);#endifstatic const unsigned int cpu_7xx[16] = { /* 7xx & 74xx (but not 745x) */ 18, 15, 14, 2, 4, 13, 5, 9, 6, 11, 8, 10, 16, 12, 7, 0};static const unsigned int cpu_745x[2][16] = { /* PLL_EXT 0 & 1 */ { 1, 15, 14, 2, 4, 13, 5, 9, 6, 11, 8, 10, 16, 12, 7, 0 }, { 0, 30, 0, 2, 0, 26, 0, 18, 0, 22, 20, 24, 28, 32, 0, 0 }};TODC_ALLOC();static intev64260_get_bus_speed(void){ return 100000000;}static intev64260_get_cpu_speed(void){ unsigned long pvr, hid1, pll_ext; pvr = PVR_VER(mfspr(SPRN_PVR)); if (pvr != PVR_VER(PVR_7450)) { hid1 = mfspr(SPRN_HID1) >> 28; return ev64260_get_bus_speed() * cpu_7xx[hid1]/2; } else { hid1 = (mfspr(SPRN_HID1) & 0x0001e000) >> 13; pll_ext = 0; /* No way to read; must get from schematic */ return ev64260_get_bus_speed() * cpu_745x[pll_ext][hid1]/2; }}unsigned long __initev64260_find_end_of_memory(void){ return mv64x60_get_mem_size(CONFIG_MV64X60_NEW_BASE, MV64x60_TYPE_GT64260A);}/* * Marvell/Galileo EV-64260-BP Evaluation Board PCI interrupt routing. * Note: By playing with J8 and JP1-4, you can get 2 IRQ's from the first * PCI bus (in which cast, INTPIN B would be EV64260_PCI_1_IRQ). * This is the most IRQs you can get from one bus with this board, though. */static int __initev64260_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin){ struct pci_controller *hose = pci_bus_to_hose(dev->bus->number); if (hose->index == 0) { static char pci_irq_table[][4] = /* * PCI IDSEL/INTPIN->INTLINE * A B C D */ { {EV64260_PCI_0_IRQ,0,0,0}, /* IDSEL 7 - PCI bus 0 */ {EV64260_PCI_0_IRQ,0,0,0}, /* IDSEL 8 - PCI bus 0 */ }; const long min_idsel = 7, max_idsel = 8, irqs_per_slot = 4; return PCI_IRQ_TABLE_LOOKUP; } else { static char pci_irq_table[][4] = /* * PCI IDSEL/INTPIN->INTLINE * A B C D */ { { EV64260_PCI_1_IRQ,0,0,0}, /* IDSEL 7 - PCI bus 1 */ { EV64260_PCI_1_IRQ,0,0,0}, /* IDSEL 8 - PCI bus 1 */ }; const long min_idsel = 7, max_idsel = 8, irqs_per_slot = 4; return PCI_IRQ_TABLE_LOOKUP; }}static void __initev64260_setup_peripherals(void){ mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN, EV64260_EMB_FLASH_BASE, EV64260_EMB_FLASH_SIZE, 0); bh.ci->enable_window_32bit(&bh, MV64x60_CPU2BOOT_WIN); mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN, EV64260_EXT_SRAM_BASE, EV64260_EXT_SRAM_SIZE, 0); bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_0_WIN); mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN, EV64260_TODC_BASE, EV64260_TODC_SIZE, 0); bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_1_WIN); mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_2_WIN, EV64260_UART_BASE, EV64260_UART_SIZE, 0); bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_2_WIN); mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_3_WIN, EV64260_EXT_FLASH_BASE, EV64260_EXT_FLASH_SIZE, 0); bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_3_WIN); TODC_INIT(TODC_TYPE_DS1501, 0, 0, ioremap(EV64260_TODC_BASE, EV64260_TODC_SIZE), 8); mv64x60_clr_bits(&bh, MV64x60_CPU_CONFIG,((1<<12) | (1<<28) | (1<<29))); mv64x60_set_bits(&bh, MV64x60_CPU_CONFIG, (1<<27)); if (ev64260_get_bus_speed() > 100000000) mv64x60_set_bits(&bh, MV64x60_CPU_CONFIG, (1<<23)); mv64x60_set_bits(&bh, MV64x60_PCI0_PCI_DECODE_CNTL, ((1<<0) | (1<<3))); mv64x60_set_bits(&bh, MV64x60_PCI1_PCI_DECODE_CNTL, ((1<<0) | (1<<3))); /* * Enabling of PCI internal-vs-external arbitration * is a platform- and errata-dependent decision. */ if (bh.type == MV64x60_TYPE_GT64260A ) { mv64x60_set_bits(&bh, MV64x60_PCI0_ARBITER_CNTL, (1<<31)); mv64x60_set_bits(&bh, MV64x60_PCI1_ARBITER_CNTL, (1<<31)); } mv64x60_set_bits(&bh, MV64x60_CPU_MASTER_CNTL, (1<<9)); /* Only 1 cpu */ /* * Turn off timer/counters. Not turning off watchdog timer because * can't read its reg on the 64260A so don't know if we'll be enabling * or disabling. */ mv64x60_clr_bits(&bh, MV64x60_TIMR_CNTR_0_3_CNTL, ((1<<0) | (1<<8) | (1<<16) | (1<<24))); mv64x60_clr_bits(&bh, GT64260_TIMR_CNTR_4_7_CNTL, ((1<<0) | (1<<8) | (1<<16) | (1<<24))); /* * Set MPSC Multiplex RMII * NOTE: ethernet driver modifies bit 0 and 1 */ mv64x60_write(&bh, GT64260_MPP_SERIAL_PORTS_MULTIPLEX, 0x00001102); /* * The EV-64260-BP uses several Multi-Purpose Pins (MPP) on the 64260 * bridge as interrupt inputs (via the General Purpose Ports (GPP) * register). Need to route the MPP inputs to the GPP and set the * polarity correctly. * * In MPP Control 2 Register * MPP 21 -> GPP 21 (DUART channel A intr) bits 20-23 -> 0 * MPP 22 -> GPP 22 (DUART channel B intr) bits 24-27 -> 0 */ mv64x60_clr_bits(&bh, MV64x60_MPP_CNTL_2, (0xf<<20) | (0xf<<24) ); /* * In MPP Control 3 Register * MPP 26 -> GPP 26 (RTC INT) bits 8-11 -> 0 * MPP 27 -> GPP 27 (PCI 0 INTA) bits 12-15 -> 0 * MPP 29 -> GPP 29 (PCI 1 INTA) bits 20-23 -> 0 */ mv64x60_clr_bits(&bh, MV64x60_MPP_CNTL_3, (0xf<<8)|(0xf<<12)|(0xf<<20));#define GPP_EXTERNAL_INTERRUPTS \ ((1<<21) | (1<<22) | (1<<26) | (1<<27) | (1<<29)) /* DUART & PCI interrupts are inputs */ mv64x60_clr_bits(&bh, MV64x60_GPP_IO_CNTL, GPP_EXTERNAL_INTERRUPTS); /* DUART & PCI interrupts are active low */ mv64x60_set_bits(&bh, MV64x60_GPP_LEVEL_CNTL, GPP_EXTERNAL_INTERRUPTS); /* Clear any pending interrupts for these inputs and enable them. */ mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, ~GPP_EXTERNAL_INTERRUPTS); mv64x60_set_bits(&bh, MV64x60_GPP_INTR_MASK, GPP_EXTERNAL_INTERRUPTS); return;}static void __initev64260_setup_bridge(void){ struct mv64x60_setup_info si; int i; memset(&si, 0, sizeof(si)); si.phys_reg_base = CONFIG_MV64X60_NEW_BASE; si.pci_0.enable_bus = 1; si.pci_0.pci_io.cpu_base = EV64260_PCI0_IO_CPU_BASE; si.pci_0.pci_io.pci_base_hi = 0; si.pci_0.pci_io.pci_base_lo = EV64260_PCI0_IO_PCI_BASE; si.pci_0.pci_io.size = EV64260_PCI0_IO_SIZE; si.pci_0.pci_io.swap = MV64x60_CPU2PCI_SWAP_NONE; si.pci_0.pci_mem[0].cpu_base = EV64260_PCI0_MEM_CPU_BASE; si.pci_0.pci_mem[0].pci_base_hi = 0; si.pci_0.pci_mem[0].pci_base_lo = EV64260_PCI0_MEM_PCI_BASE; si.pci_0.pci_mem[0].size = EV64260_PCI0_MEM_SIZE; si.pci_0.pci_mem[0].swap = MV64x60_CPU2PCI_SWAP_NONE; si.pci_0.pci_cmd_bits = 0; si.pci_0.latency_timer = 0x8; si.pci_1.enable_bus = 1; si.pci_1.pci_io.cpu_base = EV64260_PCI1_IO_CPU_BASE; si.pci_1.pci_io.pci_base_hi = 0; si.pci_1.pci_io.pci_base_lo = EV64260_PCI1_IO_PCI_BASE; si.pci_1.pci_io.size = EV64260_PCI1_IO_SIZE; si.pci_1.pci_io.swap = MV64x60_CPU2PCI_SWAP_NONE; si.pci_1.pci_mem[0].cpu_base = EV64260_PCI1_MEM_CPU_BASE; si.pci_1.pci_mem[0].pci_base_hi = 0; si.pci_1.pci_mem[0].pci_base_lo = EV64260_PCI1_MEM_PCI_BASE; si.pci_1.pci_mem[0].size = EV64260_PCI1_MEM_SIZE; si.pci_1.pci_mem[0].swap = MV64x60_CPU2PCI_SWAP_NONE; si.pci_1.pci_cmd_bits = 0; si.pci_1.latency_timer = 0x8; for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) { si.cpu_prot_options[i] = 0; si.cpu_snoop_options[i] = GT64260_CPU_SNOOP_WB; si.pci_0.acc_cntl_options[i] = GT64260_PCI_ACC_CNTL_DREADEN | GT64260_PCI_ACC_CNTL_RDPREFETCH | GT64260_PCI_ACC_CNTL_RDLINEPREFETCH | GT64260_PCI_ACC_CNTL_RDMULPREFETCH | GT64260_PCI_ACC_CNTL_SWAP_NONE | GT64260_PCI_ACC_CNTL_MBURST_32_BTYES; si.pci_0.snoop_options[i] = GT64260_PCI_SNOOP_WB; si.pci_1.acc_cntl_options[i] = GT64260_PCI_ACC_CNTL_DREADEN | GT64260_PCI_ACC_CNTL_RDPREFETCH | GT64260_PCI_ACC_CNTL_RDLINEPREFETCH | GT64260_PCI_ACC_CNTL_RDMULPREFETCH | GT64260_PCI_ACC_CNTL_SWAP_NONE | GT64260_PCI_ACC_CNTL_MBURST_32_BTYES; si.pci_1.snoop_options[i] = GT64260_PCI_SNOOP_WB; } /* Lookup PCI host bridges */ if (mv64x60_init(&bh, &si)) printk(KERN_ERR "Bridge initialization failed.\n"); pci_dram_offset = 0; /* System mem at same addr on PCI & cpu bus */ ppc_md.pci_swizzle = common_swizzle; ppc_md.pci_map_irq = ev64260_map_irq; ppc_md.pci_exclude_device = mv64x60_pci_exclude_device; mv64x60_set_bus(&bh, 0, 0); bh.hose_a->first_busno = 0; bh.hose_a->last_busno = 0xff; bh.hose_a->last_busno = pciauto_bus_scan(bh.hose_a, 0); bh.hose_b->first_busno = bh.hose_a->last_busno + 1; mv64x60_set_bus(&bh, 1, bh.hose_b->first_busno); bh.hose_b->last_busno = 0xff; bh.hose_b->last_busno = pciauto_bus_scan(bh.hose_b, bh.hose_b->first_busno); return;}#if defined(CONFIG_SERIAL_8250) && !defined(CONFIG_SERIAL_MPSC_CONSOLE)static void __initev64260_early_serial_map(void){ struct uart_port port; static char first_time = 1; if (first_time) { memset(&port, 0, sizeof(port));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -