📄 sc520_spunk.c
字号:
u32 isa_map_rom(u32 bus_addr, int size){ u32 par; printf("isa_map_rom asked to map %d bytes at %x\n", size, bus_addr); par = size; if (par < 0x80000) { par = 0x80000; } par >>= 12; par--; par&=0x7f; par <<= 18; par |= (bus_addr>>12); par |= 0x50000000; printf ("setting PAR11 to %x\n", par); /* Map rom 0x10000 with PAR1 */ write_mmcr_long(SC520_PAR11, par); return bus_addr;}/* * this function removed any mapping created * with pci_get_rom_window() */void isa_unmap_rom(u32 addr){ printf("isa_unmap_rom asked to unmap %x", addr); if ((addr>>12) == (read_mmcr_long(SC520_PAR11)&0x3ffff)) { write_mmcr_long(SC520_PAR11, 0); printf(" done\n"); return; } printf(" not ours\n");}#ifdef CONFIG_PCI#define PCI_ROM_TEMP_SPACE 0x10000/* * This function should map a chunk of size bytes * of the system address space to the PCI bus, * suitable to map PCI ROMS (bus address < 16M) * the function will return the host memory address * which should be converted into a bus address * before used to configure the PCI rom address * decoder */u32 pci_get_rom_window(struct pci_controller *hose, int size){ u32 par; par = size; if (par < 0x80000) { par = 0x80000; } par >>= 16; par--; par&=0x7ff; par <<= 14; par |= (PCI_ROM_TEMP_SPACE>>16); par |= 0x72000000; printf ("setting PAR1 to %x\n", par); /* Map rom 0x10000 with PAR1 */ write_mmcr_long(SC520_PAR1, par); return PCI_ROM_TEMP_SPACE;}/* * this function removed any mapping created * with pci_get_rom_window() */void pci_remove_rom_window(struct pci_controller *hose, u32 addr){ printf("pci_remove_rom_window: %x", addr); if (addr == PCI_ROM_TEMP_SPACE) { write_mmcr_long(SC520_PAR1, 0); printf(" done\n"); return; } printf(" not ours\n");}/* * This function is called in order to provide acces to the * legacy video I/O ports on the PCI bus. * After this function accesses to I/O ports 0x3b0-0x3bb and * 0x3c0-0x3df shuld result in transactions on the PCI bus. * */int pci_enable_legacy_video_ports(struct pci_controller *hose){ /* Map video memory to 0xa0000*/ write_mmcr_long(SC520_PAR0, 0x7200400a); /* forward all I/O accesses to PCI */ write_mmcr_byte(SC520_ADDDECCTL, read_mmcr_byte(SC520_ADDDECCTL) | IO_HOLE_DEST_PCI); /* so we map away all io ports to pci (only way to access pci io * below 0x400. But then we have to map back the portions that we dont * use so that the generate cycles on the GPIO bus where the sio and * ISA slots are connected, this requre the use of several PAR registers */ /* bring 0x100 - 0x2f7 back to ISA using PAR5 */ write_mmcr_long(SC520_PAR5, 0x31f70100); /* com2 use 2f8-2ff */ /* bring 0x300 - 0x3af back to ISA using PAR7 */ write_mmcr_long(SC520_PAR7, 0x30af0300); /* vga use 3b0-3bb */ /* bring 0x3bc - 0x3bf back to ISA using PAR8 */ write_mmcr_long(SC520_PAR8, 0x300303bc); /* vga use 3c0-3df */ /* bring 0x3e0 - 0x3f7 back to ISA using PAR9 */ write_mmcr_long(SC520_PAR9, 0x301703e0); /* com1 use 3f8-3ff */ return 0;}#endif/* * Miscelaneous platform dependent initialisations */int board_init(void){ DECLARE_GLOBAL_DATA_PTR; init_sc520(); bus_init(); irq_init(); /* max drive current on SDRAM */ write_mmcr_word(SC520_DSCTL, 0x0100); /* enter debug mode after next reset (only if jumper is also set) */ write_mmcr_byte(SC520_RESCFG, 0x08); /* configure the software timer to 33.000MHz */ write_mmcr_byte(SC520_SWTMRCFG, 1); gd->bus_clk = 33000000; return 0;}int dram_init(void){ init_sc520_dram(); return 0;}void show_boot_progress(int val){ int version = read_mmcr_byte(SC520_SYSINFO); if (version == 0) { /* PIO31-PIO16 Data */ write_mmcr_word(SC520_PIODATA31_16, (read_mmcr_word(SC520_PIODATA31_16) & 0xffc0)| ((val&0x7e)>>1)); /* 0x1f8 >> 3 */ /* PIO0-PIO15 Data */ write_mmcr_word(SC520_PIODATA15_0, (read_mmcr_word(SC520_PIODATA15_0) & 0x1fff)| ((val&0x7)<<13)); } else { /* newer boards use PIO4-PIO12 */ /* PIO0-PIO15 Data */#if 0 val = (val & 0x007) | ((val & 0x038) << 3) | ((val & 0x1c0) >> 3);#else val = (val & 0x007) | ((val & 0x07e) << 2);#endif write_mmcr_word(SC520_PIODATA15_0, (read_mmcr_word(SC520_PIODATA15_0) & 0xe00f) | ((val&0x01ff)<<4)); }}int last_stage_init(void){ int version = read_mmcr_byte(SC520_SYSINFO); printf("Omicron Ceti SC520 Spunk revision %x\n", version);#if 0 if (version) { int x, y; printf("eeprom probe %d\n", spi_eeprom_probe(1)); spi_eeprom_read(1, 0, (u8*)&x, 2); spi_eeprom_read(1, 1, (u8*)&y, 2); printf("eeprom bytes %04x%04x\n", x, y); x ^= 0xffff; y ^= 0xffff; spi_eeprom_write(1, 0, (u8*)&x, 2); spi_eeprom_write(1, 1, (u8*)&y, 2); spi_eeprom_read(1, 0, (u8*)&x, 2); spi_eeprom_read(1, 1, (u8*)&y, 2); printf("eeprom bytes %04x%04x\n", x, y); } else { int x, y; printf("eeprom probe %d\n", mw_eeprom_probe(1)); mw_eeprom_read(1, 0, (u8*)&x, 2); mw_eeprom_read(1, 1, (u8*)&y, 2); printf("eeprom bytes %04x%04x\n", x, y); x ^= 0xffff; y ^= 0xffff; mw_eeprom_write(1, 0, (u8*)&x, 2); mw_eeprom_write(1, 1, (u8*)&y, 2); mw_eeprom_read(1, 0, (u8*)&x, 2); mw_eeprom_read(1, 1, (u8*)&y, 2); printf("eeprom bytes %04x%04x\n", x, y); }#endif ds1722_probe(2); return 0;}void ssi_chip_select(int dev){ int version = read_mmcr_byte(SC520_SYSINFO); if (version) { /* Spunk board: EEPROM and CAN are actove-low, TEMP and AUX are active high */ switch (dev) { case 1: /* EEPROM */ write_mmcr_word(SC520_PIOCLR31_16, 0x0004); break; case 2: /* Temp Probe */ write_mmcr_word(SC520_PIOSET31_16, 0x0002); break; case 3: /* CAN */ write_mmcr_word(SC520_PIOCLR31_16, 0x0008); break; case 4: /* AUX */ write_mmcr_word(SC520_PIOSET31_16, 0x0001); break; case 0: write_mmcr_word(SC520_PIOCLR31_16, 0x0003); write_mmcr_word(SC520_PIOSET31_16, 0x000c); break; default: printf("Illegal SSI device requested: %d\n", dev); } } else { /* Globox board: Both EEPROM and TEMP are active-high */ switch (dev) { case 1: /* EEPROM */ write_mmcr_word(SC520_PIOSET15_0, 0x0100); break; case 2: /* Temp Probe */ write_mmcr_word(SC520_PIOSET15_0, 0x0080); break; case 0: write_mmcr_word(SC520_PIOCLR15_0, 0x0180); break; default: printf("Illegal SSI device requested: %d\n", dev); } }}void spi_init_f(void){ read_mmcr_byte(SC520_SYSINFO) ? spi_eeprom_probe(1) : mw_eeprom_probe(1);}ssize_t spi_read(uchar *addr, int alen, uchar *buffer, int len){ int offset; int i; offset = 0; for (i=0;i<alen;i++) { offset <<= 8; offset |= addr[i]; } return read_mmcr_byte(SC520_SYSINFO) ? spi_eeprom_read(1, offset, buffer, len) : mw_eeprom_read(1, offset, buffer, len);}ssize_t spi_write(uchar *addr, int alen, uchar *buffer, int len){ int offset; int i; offset = 0; for (i=0;i<alen;i++) { offset <<= 8; offset |= addr[i]; } return read_mmcr_byte(SC520_SYSINFO) ? spi_eeprom_write(1, offset, buffer, len) : mw_eeprom_write(1, offset, buffer, len);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -