85xx: Use common LSDMR defines from asm/fsl_lbc.h
[oweals/u-boot.git] / board / sbc8548 / sbc8548.c
index 21f82f2837a8b273aa887de6bbd6459578bbafdb..088f8045daa2d769c20f10748b14ca0060c39624 100644 (file)
 #include <libfdt.h>
 #include <fdt_support.h>
 
-#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
-extern void ddr_enable_ecc(unsigned int dram_size);
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 void local_bus_init(void);
@@ -65,13 +61,6 @@ int checkboard (void)
         */
        local_bus_init ();
 
-       /*
-        * Fix CPU2 errata: A core hang possible while executing a
-        * msync instruction and a snoopable transaction from an I/O
-        * master tagged to make quick forward progress is present.
-        */
-       ecm->eebpcr |= (1 << 16);
-
        /*
         * Hack TSEC 3 and 4 IO voltages.
         */
@@ -114,12 +103,6 @@ initdram(int board_type)
        dram_size = fixed_sdram ();
 #endif
 
-#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
-       /*
-        * Initialize and enable DDR ECC.
-        */
-       ddr_enable_ecc(dram_size);
-#endif
        /*
         * SDRAM Initialization
         */
@@ -143,7 +126,7 @@ local_bus_init(void)
        sys_info_t sysinfo;
 
        get_sys_info(&sysinfo);
-       clkdiv = (lbc->lcrr & 0x0f) * 2;
+       clkdiv = (lbc->lcrr & LCRR_CLKDIV) * 2;
        lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
 
        gur->lbiuiplldcr1 = 0x00078080;
@@ -201,12 +184,12 @@ sdram_init(void)
         * MPC8548 uses "new" 15-16 style addressing.
         */
        lsdmr_common = CONFIG_SYS_LBC_LSDMR_COMMON;
-       lsdmr_common |= CONFIG_SYS_LBC_LSDMR_BSMA1516;
+       lsdmr_common |= LSDMR_BSMA1516;
 
        /*
         * Issue PRECHARGE ALL command.
         */
-       lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_PCHALL;
+       lbc->lsdmr = lsdmr_common | LSDMR_OP_PCHALL;
        asm("sync;msync");
        *sdram_addr = 0xff;
        ppcDcbf((unsigned long) sdram_addr);
@@ -216,7 +199,7 @@ sdram_init(void)
         * Issue 8 AUTO REFRESH commands.
         */
        for (idx = 0; idx < 8; idx++) {
-               lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_ARFRSH;
+               lbc->lsdmr = lsdmr_common | LSDMR_OP_ARFRSH;
                asm("sync;msync");
                *sdram_addr = 0xff;
                ppcDcbf((unsigned long) sdram_addr);
@@ -226,7 +209,7 @@ sdram_init(void)
        /*
         * Issue 8 MODE-set command.
         */
-       lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_MRW;
+       lbc->lsdmr = lsdmr_common | LSDMR_OP_MRW;
        asm("sync;msync");
        *sdram_addr = 0xff;
        ppcDcbf((unsigned long) sdram_addr);
@@ -235,7 +218,7 @@ sdram_init(void)
        /*
         * Issue NORMAL OP command.
         */
-       lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_NORMAL;
+       lbc->lsdmr = lsdmr_common | LSDMR_OP_NORMAL;
        asm("sync;msync");
        *sdram_addr = 0xff;
        ppcDcbf((unsigned long) sdram_addr);
@@ -364,6 +347,9 @@ static struct pci_controller pcie1_hose;
 
 int first_free_busno=0;
 
+extern int fsl_pci_setup_inbound_windows(struct pci_region *r);
+extern void fsl_pci_init(struct pci_controller *hose);
+
 void
 pci_init_board(void)
 {
@@ -372,9 +358,9 @@ pci_init_board(void)
 #ifdef CONFIG_PCI1
 {
        volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI1_ADDR;
-       extern void fsl_pci_init(struct pci_controller *hose);
        struct pci_controller *hose = &pci1_hose;
        struct pci_config_table *table;
+       struct pci_region *r = hose->regions;
 
        uint pci_32 = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_PCI32;      /* PORDEVSR[15] */
        uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB;       /* PORDEVSR[14] */
@@ -396,27 +382,22 @@ pci_init_board(void)
 
 
                /* inbound */
-               pci_set_region(hose->regions + 0,
-                              CONFIG_SYS_PCI_MEMORY_BUS,
-                              CONFIG_SYS_PCI_MEMORY_PHYS,
-                              CONFIG_SYS_PCI_MEMORY_SIZE,
-                              PCI_REGION_MEM | PCI_REGION_MEMORY);
-
+               r += fsl_pci_setup_inbound_windows(r);
 
                /* outbound memory */
-               pci_set_region(hose->regions + 1,
+               pci_set_region(r++,
                               CONFIG_SYS_PCI1_MEM_BASE,
                               CONFIG_SYS_PCI1_MEM_PHYS,
                               CONFIG_SYS_PCI1_MEM_SIZE,
                               PCI_REGION_MEM);
 
                /* outbound io */
-               pci_set_region(hose->regions + 2,
+               pci_set_region(r++,
                               CONFIG_SYS_PCI1_IO_BASE,
                               CONFIG_SYS_PCI1_IO_PHYS,
                               CONFIG_SYS_PCI1_IO_SIZE,
                               PCI_REGION_IO);
-               hose->region_count = 3;
+               hose->region_count = r - hose->regions;
 
                /* relocate config table pointers */
                hose->config_table = \
@@ -431,7 +412,7 @@ pci_init_board(void)
                first_free_busno=hose->last_busno+1;
                printf ("PCI on bus %02x - %02x\n",hose->first_busno,hose->last_busno);
 #ifdef CONFIG_PCIX_CHECK
-               if (!(gur->pordevsr & PORDEVSR_PCI)) {
+               if (!(gur->pordevsr & MPC85xx_PORDEVSR_PCI1)) {
                        /* PCI-X init */
                        if (CONFIG_SYS_CLK_FREQ < 66000000)
                                printf("PCI-X will only work at 66 MHz\n");
@@ -467,9 +448,9 @@ pci_init_board(void)
 #ifdef CONFIG_PCIE1
 {
        volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE1_ADDR;
-       extern void fsl_pci_init(struct pci_controller *hose);
        struct pci_controller *hose = &pcie1_hose;
        int pcie_ep =  (host_agent == 0) || (host_agent == 2 ) || (host_agent == 3);
+       struct pci_region *r = hose->regions;
 
        int pcie_configured  = io_sel >= 1;
 
@@ -485,27 +466,27 @@ pci_init_board(void)
                printf ("\n");
 
                /* inbound */
-               pci_set_region(hose->regions + 0,
+               pci_set_region(r++,
                               CONFIG_SYS_PCI_MEMORY_BUS,
                               CONFIG_SYS_PCI_MEMORY_PHYS,
                               CONFIG_SYS_PCI_MEMORY_SIZE,
-                              PCI_REGION_MEM | PCI_REGION_MEMORY);
+                              PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
 
                /* outbound memory */
-               pci_set_region(hose->regions + 1,
+               pci_set_region(r++,
                               CONFIG_SYS_PCIE1_MEM_BASE,
                               CONFIG_SYS_PCIE1_MEM_PHYS,
                               CONFIG_SYS_PCIE1_MEM_SIZE,
                               PCI_REGION_MEM);
 
                /* outbound io */
-               pci_set_region(hose->regions + 2,
+               pci_set_region(r++,
                               CONFIG_SYS_PCIE1_IO_BASE,
                               CONFIG_SYS_PCIE1_IO_PHYS,
                               CONFIG_SYS_PCIE1_IO_SIZE,
                               PCI_REGION_IO);
 
-               hose->region_count = 3;
+               hose->region_count = r - hose->regions;
 
                hose->first_busno=first_free_busno;
                pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
@@ -531,41 +512,17 @@ int last_stage_init(void)
 }
 
 #if defined(CONFIG_OF_BOARD_SETUP)
-void
-ft_pci_setup(void *blob, bd_t *bd)
-{
-       int node, tmp[2];
+extern void ft_fsl_pci_setup(void *blob, const char *pci_alias,
+                       struct pci_controller *hose);
 
-       node = fdt_path_offset(blob, "/aliases");
-       tmp[0] = 0;
-       if (node >= 0) {
+void ft_board_setup(void *blob, bd_t *bd)
+{
+       ft_cpu_setup(blob, bd);
 #ifdef CONFIG_PCI1
-               const char *path;
-               path = fdt_getprop(blob, node, "pci0", NULL);
-               if (path) {
-                       tmp[1] = pci1_hose.last_busno - pci1_hose.first_busno;
-                       do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
-               }
+       ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
 #endif
 #ifdef CONFIG_PCIE1
-               const char *path;
-               path = fdt_getprop(blob, node, "pci1", NULL);
-               if (path) {
-                       tmp[1] = pcie1_hose.last_busno - pcie1_hose.first_busno;
-                       do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
-               }
-#endif
-       }
-}
-#endif
-
-#if defined(CONFIG_OF_BOARD_SETUP)
-void
-ft_board_setup(void *blob, bd_t *bd)
-{
-       ft_cpu_setup(blob, bd);
-#ifdef CONFIG_PCI
-       ft_pci_setup(blob, bd);
+       ft_fsl_pci_setup(blob, "pci1", &pcie1_hose);
 #endif
 }
 #endif