Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L9PBQ-0001cv-Oh for qemu-devel@nongnu.org; Sun, 07 Dec 2008 14:20:48 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L9PBP-0001cj-T8 for qemu-devel@nongnu.org; Sun, 07 Dec 2008 14:20:48 -0500 Received: from [199.232.76.173] (port=54983 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9PBP-0001cg-Pc for qemu-devel@nongnu.org; Sun, 07 Dec 2008 14:20:47 -0500 Received: from savannah.gnu.org ([199.232.41.3]:52395 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L9PBP-0001CP-G3 for qemu-devel@nongnu.org; Sun, 07 Dec 2008 14:20:47 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1L9PBO-0001Y6-EI for qemu-devel@nongnu.org; Sun, 07 Dec 2008 19:20:46 +0000 Received: from balrog by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1L9PBN-0001Xv-Es for qemu-devel@nongnu.org; Sun, 07 Dec 2008 19:20:45 +0000 MIME-Version: 1.0 Errors-To: balrog Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Andrzej Zaborowski Message-Id: Date: Sun, 07 Dec 2008 19:20:45 +0000 Subject: [Qemu-devel] [5932] SH: r2d pci support (Takashi YOSHII). Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5932 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5932 Author: balrog Date: 2008-12-07 19:20:43 +0000 (Sun, 07 Dec 2008) Log Message: ----------- SH: r2d pci support (Takashi YOSHII). This patch adds pci support to sh/r2d board. This is the first user of PCIC support I formerly sent. PCIC actually is inside of chip with CPU core on SH7751. But, this code is written as if SH7750 and PCIC are on board. I care little about physical device boundary, but fitting with qemu's design. This patch also adds some BSC (Bus State Controller) registers, because PCI device driver software have to accesses them. Signed-off-by: Takashi YOSHII Signed-off-by: Andrzej Zaborowski Modified Paths: -------------- trunk/hw/r2d.c trunk/hw/sh7750.c Modified: trunk/hw/r2d.c =================================================================== --- trunk/hw/r2d.c 2008-12-07 19:16:27 UTC (rev 5931) +++ trunk/hw/r2d.c 2008-12-07 19:20:43 UTC (rev 5932) @@ -28,6 +28,9 @@ #include "devices.h" #include "sysemu.h" #include "boards.h" +#include "pci.h" +#include "net.h" +#include "sh7750_regs.h" #define SDRAM_BASE 0x0c000000 /* Physical location of SDRAM: Area 3 */ #define SDRAM_SIZE 0x04000000 @@ -178,6 +181,17 @@ return qemu_allocate_irqs(r2d_fpga_irq_set, s, NR_IRQS); } +static void r2d_pci_set_irq(qemu_irq *p, int n, int l) +{ + qemu_set_irq(p[n], l); +} + +static int r2d_pci_map_irq(PCIDevice *d, int irq_num) +{ + const int intx[] = { PCI_INTA, PCI_INTB, PCI_INTC, PCI_INTD }; + return intx[d->devfn >> 3]; +} + static void r2d_init(ram_addr_t ram_size, int vga_ram_size, const char *boot_device, DisplayState * ds, const char *kernel_filename, const char *kernel_cmdline, @@ -187,6 +201,8 @@ struct SH7750State *s; ram_addr_t sdram_addr, sm501_vga_ram_addr; qemu_irq *irq; + PCIBus *pci; + int i; if (!cpu_model) cpu_model = "SH7751R"; @@ -203,6 +219,7 @@ /* Register peripherals */ s = sh7750_init(env); irq = r2d_fpga_init(0x04000000, sh7750_irl(s)); + pci = sh_pci_register_bus(r2d_pci_set_irq, r2d_pci_map_irq, irq, 0, 4); sm501_vga_ram_addr = qemu_ram_alloc(SM501_VRAM_SIZE); sm501_init(ds, 0x10000000, sm501_vga_ram_addr, SM501_VRAM_SIZE, @@ -212,9 +229,19 @@ mmio_ide_init(0x14001000, 0x1400080c, irq[CF_IDE], 1, drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL); + /* NIC: rtl8139 on-board, and 2 slots. */ + pci_rtl8139_init(pci, &nd_table[0], 2 << 3); + for (i = 1; i < nb_nics; i++) + pci_nic_init(pci, &nd_table[i], -1); + /* Todo: register on board registers */ { int kernel_size; + /* initialization which should be done by firmware */ + uint32_t bcr1 = 1 << 3; /* cs3 SDRAM */ + uint16_t bcr2 = 3 << (3 * 2); /* cs3 32-bit */ + cpu_physical_memory_write(SH7750_BCR1_A7, &bcr1, 4); + cpu_physical_memory_write(SH7750_BCR2_A7, &bcr2, 2); kernel_size = load_image(kernel_filename, phys_ram_base); Modified: trunk/hw/sh7750.c =================================================================== --- trunk/hw/sh7750.c 2008-12-07 19:16:27 UTC (rev 5931) +++ trunk/hw/sh7750.c 2008-12-07 19:20:43 UTC (rev 5932) @@ -41,6 +41,8 @@ /* Peripheral frequency in Hz */ uint32_t periph_freq; /* SDRAM controller */ + uint32_t bcr1; + uint32_t bcr2; uint16_t rfcr; /* IO ports */ uint16_t gpioic; @@ -208,6 +210,8 @@ SH7750State *s = opaque; switch (addr) { + case SH7750_BCR2_A7: + return s->bcr2; case SH7750_FRQCR_A7: return 0; case SH7750_RFCR_A7: @@ -231,6 +235,15 @@ SH7750State *s = opaque; switch (addr) { + case SH7750_BCR1_A7: + return s->bcr1; + case SH7750_BCR4_A7: + case SH7750_WCR1_A7: + case SH7750_WCR2_A7: + case SH7750_WCR3_A7: + case SH7750_MCR_A7: + ignore_access("long read", addr); + return 0; case SH7750_MMUCR_A7: return s->cpu->mmucr; case SH7750_PTEH_A7: @@ -285,6 +298,8 @@ switch (addr) { /* SDRAM controller */ case SH7750_BCR2_A7: + s->bcr2 = mem_value; + return; case SH7750_BCR3_A7: case SH7750_RTCOR_A7: case SH7750_RTCNT_A7: @@ -331,6 +346,8 @@ switch (addr) { /* SDRAM controller */ case SH7750_BCR1_A7: + s->bcr1 = mem_value; + return; case SH7750_BCR4_A7: case SH7750_WCR1_A7: case SH7750_WCR2_A7: