/* * early init callback, read nvram data from flash and checksum it */ void __init board_prom_init(void) { unsigned int check_len, i; u8 *boot_addr, *cfe, *p; char cfe_version[32]; u32 val; /* read base address of boot chip select (0) * 6345 does not have MPI but boots from standard * MIPS Flash address */ if (BCMCPU_IS_6345()) val = 0x1fc00000; else { val = bcm_mpi_readl(MPI_CSBASE_REG(0)); val &= MPI_CSBASE_BASE_MASK; } boot_addr = (u8 *)KSEG1ADDR(val); /* dump cfe version */ cfe = boot_addr + BCM963XX_CFE_VERSION_OFFSET; if (!memcmp(cfe, "cfe-v", 5)) snprintf(cfe_version, sizeof(cfe_version), "%u.%u.%u-%u.%u", cfe[5], cfe[6], cfe[7], cfe[8], cfe[9]); else strcpy(cfe_version, "unknown"); printk(KERN_INFO PFX "CFE version: %s\n", cfe_version); /* extract nvram data */ memcpy(&nvram, boot_addr + BCM963XX_NVRAM_OFFSET, sizeof(nvram)); /* check checksum before using data */ if (nvram.version <= 4) check_len = offsetof(struct bcm963xx_nvram, checksum_old); else
/* * third stage init callback, register all board devices. */ int __init board_register_devices(void) { u32 val; bcm63xx_uart_register(); bcm63xx_wdt_register(); if (board.has_pccard) bcm63xx_pcmcia_register(); if (board.has_enet0 && !board_get_mac_address(board.enet0.mac_addr)) bcm63xx_enet_register(0, &board.enet0); if (board.has_enet1 && !board_get_mac_address(board.enet1.mac_addr)) bcm63xx_enet_register(1, &board.enet1); if (board.has_ohci0) bcm63xx_ohci_register(); if (board.has_ehci0) bcm63xx_ehci_register(); /* read base address of boot chip select (0) */ val = bcm_mpi_readl(MPI_CSBASE_REG(0)); val &= MPI_CSBASE_BASE_MASK; mtd_resources[0].start = val; mtd_resources[0].end = 0x1FFFFFFF; platform_device_register(&mtd_dev); return 0; }
int __init bcm63xx_flash_register(void) { int flash_type; u32 val; flash_type = bcm63xx_detect_flash_type(); switch (flash_type) { case BCM63XX_FLASH_TYPE_PARALLEL: /* read base address of boot chip select (0) */ val = bcm_mpi_readl(MPI_CSBASE_REG(0)); val &= MPI_CSBASE_BASE_MASK; mtd_resources[0].start = val; mtd_resources[0].end = 0x1FFFFFFF; return platform_device_register(&mtd_dev); case BCM63XX_FLASH_TYPE_SERIAL: pr_warn("unsupported serial flash detected\n"); return -ENODEV; case BCM63XX_FLASH_TYPE_NAND: pr_warn("unsupported NAND flash detected\n"); return -ENODEV; default: pr_err("flash detection failed for BCM%x: %d\n", bcm63xx_get_cpu_id(), flash_type); return -ENODEV; } }
static u32 bcm63xx_int_cfg_readl(u32 reg) { u32 tmp; tmp = reg & MPI_PCICFGCTL_CFGADDR_MASK; tmp |= MPI_PCICFGCTL_WRITEEN_MASK; bcm_mpi_writel(tmp, MPI_PCICFGCTL_REG); iob(); return bcm_mpi_readl(MPI_PCICFGDATA_REG); }
int __init bcm63xx_dsp_register(const struct bcm63xx_dsp_platform_data *pd) { struct bcm63xx_dsp_platform_data *dpd; u32 val; /* Get the memory window */ val = bcm_mpi_readl(MPI_CSBASE_REG(pd->cs - 1)); val &= MPI_CSBASE_BASE_MASK; voip_dsp_resources[0].start = val; voip_dsp_resources[0].end = val + 0xFFFFFFF; voip_dsp_resources[1].start = pd->ext_irq; /* copy given platform data */ dpd = bcm63xx_voip_dsp_device.dev.platform_data; memcpy(dpd, pd, sizeof (*pd)); return platform_device_register(&bcm63xx_voip_dsp_device); }
/* * early init callback */ void __init board_prom_init(void) { u32 val; /* read base address of boot chip select (0) */ val = bcm_mpi_readl(MPI_CSBASE_REG(0)); val &= MPI_CSBASE_BASE_MASK; /* assume board is a Livebox */ memcpy(&board, bcm963xx_boards[0], sizeof(board)); /* setup pin multiplexing depending on board enabled device, * this has to be done this early since PCI init is done * inside arch_initcall */ val = 0; if (board.has_pci) { bcm63xx_pci_enabled = 1; if (BCMCPU_IS_6348()) val |= GPIO_MODE_6348_G2_PCI; } if (board.has_pccard) { if (BCMCPU_IS_6348()) val |= GPIO_MODE_6348_G1_MII_PCCARD; } if (board.has_enet0 && !board.enet0.use_internal_phy) { if (BCMCPU_IS_6348()) val |= GPIO_MODE_6348_G3_EXT_MII | GPIO_MODE_6348_G0_EXT_MII; } if (board.has_enet1 && !board.enet1.use_internal_phy) { if (BCMCPU_IS_6348()) val |= GPIO_MODE_6348_G3_EXT_MII | GPIO_MODE_6348_G0_EXT_MII; } bcm_gpio_writel(val, GPIO_MODE_REG); }
static int __init bcm63xx_pci_init(void) { unsigned int mem_size; u32 val; if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358() && !BCMCPU_IS_6368()) return -ENODEV; if (!bcm63xx_pci_enabled) return -ENODEV; pci_iospace_start = ioremap_nocache(BCM_PCI_IO_BASE_PA, 4); if (!pci_iospace_start) return -ENOMEM; val = BCM_PCI_MEM_BASE_PA & MPI_L2P_BASE_MASK; bcm_mpi_writel(val, MPI_L2PMEMBASE1_REG); bcm_mpi_writel(~(BCM_PCI_MEM_SIZE - 1), MPI_L2PMEMRANGE1_REG); bcm_mpi_writel(val | MPI_L2PREMAP_ENABLED_MASK, MPI_L2PMEMREMAP1_REG); val = bcm_pcmcia_readl(PCMCIA_C1_REG); val &= ~PCMCIA_C1_CBIDSEL_MASK; val |= (CARDBUS_PCI_IDSEL << PCMCIA_C1_CBIDSEL_SHIFT); bcm_pcmcia_writel(val, PCMCIA_C1_REG); #ifdef CONFIG_CARDBUS val = BCM_CB_MEM_BASE_PA & MPI_L2P_BASE_MASK; bcm_mpi_writel(val, MPI_L2PMEMBASE2_REG); bcm_mpi_writel(~(BCM_CB_MEM_SIZE - 1), MPI_L2PMEMRANGE2_REG); val |= MPI_L2PREMAP_ENABLED_MASK | MPI_L2PREMAP_IS_CARDBUS_MASK; bcm_mpi_writel(val, MPI_L2PMEMREMAP2_REG); #else bcm_mpi_writel(0, MPI_L2PMEMREMAP2_REG); #endif val = BCM_PCI_IO_BASE_PA & MPI_L2P_BASE_MASK; bcm_mpi_writel(val, MPI_L2PIOBASE_REG); bcm_mpi_writel(~(BCM_PCI_IO_SIZE - 1), MPI_L2PIORANGE_REG); bcm_mpi_writel(val | MPI_L2PREMAP_ENABLED_MASK, MPI_L2PIOREMAP_REG); bcm_mpi_writel(MPI_LOCBUSCTL_EN_PCI_GPIO_MASK, MPI_LOCBUSCTL_REG); bcm63xx_int_cfg_writel(0, PCI_BASE_ADDRESS_3); if (BCMCPU_IS_6358() || BCMCPU_IS_6368()) val = MPI_SP0_REMAP_ENABLE_MASK; else val = 0; bcm_mpi_writel(val, MPI_SP0_REMAP_REG); bcm63xx_int_cfg_writel(0x0, PCI_BASE_ADDRESS_4); bcm_mpi_writel(0, MPI_SP1_REMAP_REG); mem_size = bcm63xx_get_memory_size(); if (BCMCPU_IS_6348() && (bcm63xx_get_cpu_rev() & 0xf0) == 0xa0) { if (mem_size > (16 * 1024 * 1024)) printk(KERN_WARNING "bcm63xx: this CPU " "revision cannot handle more than 16MB " "of RAM for PCI bus mastering\n"); } else { bcm_mpi_writel(~(mem_size - 1), MPI_SP0_RANGE_REG); bcm_mpi_writel(0, MPI_SP1_RANGE_REG); } val = bcm63xx_int_cfg_readl(BCMPCI_REG_TIMERS); val &= ~REG_TIMER_RETRY_MASK; bcm63xx_int_cfg_writel(val, BCMPCI_REG_TIMERS); val = bcm63xx_int_cfg_readl(PCI_COMMAND); val |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); bcm63xx_int_cfg_writel(val, PCI_COMMAND); val = bcm_mpi_readl(MPI_PCIMODESEL_REG); val &= ~MPI_PCIMODESEL_BAR1_NOSWAP_MASK; val &= ~MPI_PCIMODESEL_BAR2_NOSWAP_MASK; val &= ~MPI_PCIMODESEL_PREFETCH_MASK; val |= (8 << MPI_PCIMODESEL_PREFETCH_SHIFT); bcm_mpi_writel(val, MPI_PCIMODESEL_REG); val = bcm_mpi_readl(MPI_LOCINT_REG); val |= MPI_LOCINT_MASK(MPI_LOCINT_EXT_PCI_INT); bcm_mpi_writel(val, MPI_LOCINT_REG); register_pci_controller(&bcm63xx_controller); #ifdef CONFIG_CARDBUS register_pci_controller(&bcm63xx_cb_controller); #endif request_mem_region(BCM_PCI_IO_BASE_PA, BCM_PCI_IO_SIZE, "bcm63xx PCI IO space"); return 0; }
static int __init bcm63xx_pci_init(void) { unsigned int mem_size; u32 val; if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358()) return -ENODEV; if (!bcm63xx_pci_enabled) return -ENODEV; /* * configuration access are done through IO space, remap 4 * first bytes to access it from CPU. * * this means that no io access from CPU should happen while * we do a configuration cycle, but there's no way we can add * a spinlock for each io access, so this is currently kind of * broken on SMP. */ pci_iospace_start = ioremap_nocache(BCM_PCI_IO_BASE_PA, 4); if (!pci_iospace_start) return -ENOMEM; /* setup local bus to PCI access (PCI memory) */ val = BCM_PCI_MEM_BASE_PA & MPI_L2P_BASE_MASK; bcm_mpi_writel(val, MPI_L2PMEMBASE1_REG); bcm_mpi_writel(~(BCM_PCI_MEM_SIZE - 1), MPI_L2PMEMRANGE1_REG); bcm_mpi_writel(val | MPI_L2PREMAP_ENABLED_MASK, MPI_L2PMEMREMAP1_REG); /* set Cardbus IDSEL (type 0 cfg access on primary bus for * this IDSEL will be done on Cardbus instead) */ val = bcm_pcmcia_readl(PCMCIA_C1_REG); val &= ~PCMCIA_C1_CBIDSEL_MASK; val |= (CARDBUS_PCI_IDSEL << PCMCIA_C1_CBIDSEL_SHIFT); bcm_pcmcia_writel(val, PCMCIA_C1_REG); #ifdef CONFIG_CARDBUS /* setup local bus to PCI access (Cardbus memory) */ val = BCM_CB_MEM_BASE_PA & MPI_L2P_BASE_MASK; bcm_mpi_writel(val, MPI_L2PMEMBASE2_REG); bcm_mpi_writel(~(BCM_CB_MEM_SIZE - 1), MPI_L2PMEMRANGE2_REG); val |= MPI_L2PREMAP_ENABLED_MASK | MPI_L2PREMAP_IS_CARDBUS_MASK; bcm_mpi_writel(val, MPI_L2PMEMREMAP2_REG); #else /* disable second access windows */ bcm_mpi_writel(0, MPI_L2PMEMREMAP2_REG); #endif /* setup local bus to PCI access (IO memory), we have only 1 * IO window for both PCI and cardbus, but it cannot handle * both at the same time, assume standard PCI for now, if * cardbus card has IO zone, PCI fixup will change window to * cardbus */ val = BCM_PCI_IO_BASE_PA & MPI_L2P_BASE_MASK; bcm_mpi_writel(val, MPI_L2PIOBASE_REG); bcm_mpi_writel(~(BCM_PCI_IO_SIZE - 1), MPI_L2PIORANGE_REG); bcm_mpi_writel(val | MPI_L2PREMAP_ENABLED_MASK, MPI_L2PIOREMAP_REG); /* enable PCI related GPIO pins */ bcm_mpi_writel(MPI_LOCBUSCTL_EN_PCI_GPIO_MASK, MPI_LOCBUSCTL_REG); /* setup PCI to local bus access, used by PCI device to target * local RAM while bus mastering */ bcm63xx_int_cfg_writel(0, PCI_BASE_ADDRESS_3); if (BCMCPU_IS_6358()) val = MPI_SP0_REMAP_ENABLE_MASK; else val = 0; bcm_mpi_writel(val, MPI_SP0_REMAP_REG); bcm63xx_int_cfg_writel(0x0, PCI_BASE_ADDRESS_4); bcm_mpi_writel(0, MPI_SP1_REMAP_REG); mem_size = bcm63xx_get_memory_size(); /* 6348 before rev b0 exposes only 16 MB of RAM memory through * PCI, throw a warning if we have more memory */ if (BCMCPU_IS_6348() && (bcm63xx_get_cpu_rev() & 0xf0) == 0xa0) { if (mem_size > (16 * 1024 * 1024)) printk(KERN_WARNING "bcm63xx: this CPU " "revision cannot handle more than 16MB " "of RAM for PCI bus mastering\n"); } else { /* setup sp0 range to local RAM size */ bcm_mpi_writel(~(mem_size - 1), MPI_SP0_RANGE_REG); bcm_mpi_writel(0, MPI_SP1_RANGE_REG); } /* change host bridge retry counter to infinite number of * retry, needed for some broadcom wifi cards with Silicon * Backplane bus where access to srom seems very slow */ val = bcm63xx_int_cfg_readl(BCMPCI_REG_TIMERS); val &= ~REG_TIMER_RETRY_MASK; bcm63xx_int_cfg_writel(val, BCMPCI_REG_TIMERS); /* enable memory decoder and bus mastering */ val = bcm63xx_int_cfg_readl(PCI_COMMAND); val |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); bcm63xx_int_cfg_writel(val, PCI_COMMAND); /* enable read prefetching & disable byte swapping for bus * mastering transfers */ val = bcm_mpi_readl(MPI_PCIMODESEL_REG); val &= ~MPI_PCIMODESEL_BAR1_NOSWAP_MASK; val &= ~MPI_PCIMODESEL_BAR2_NOSWAP_MASK; val &= ~MPI_PCIMODESEL_PREFETCH_MASK; val |= (8 << MPI_PCIMODESEL_PREFETCH_SHIFT); bcm_mpi_writel(val, MPI_PCIMODESEL_REG); /* enable pci interrupt */ val = bcm_mpi_readl(MPI_LOCINT_REG); val |= MPI_LOCINT_MASK(MPI_LOCINT_EXT_PCI_INT); bcm_mpi_writel(val, MPI_LOCINT_REG); register_pci_controller(&bcm63xx_controller); #ifdef CONFIG_CARDBUS register_pci_controller(&bcm63xx_cb_controller); #endif /* mark memory space used for IO mapping as reserved */ request_mem_region(BCM_PCI_IO_BASE_PA, BCM_PCI_IO_SIZE, "bcm63xx PCI IO space"); return 0; }
/* * early init callback, read nvram data from flash and checksum it */ void __init board_prom_init(void) { unsigned int i; u8 *boot_addr, *cfe; char cfe_version[32]; char *board_name; u32 val; /* read base address of boot chip select (0) * 6328 does not have MPI but boots from a fixed address */ if (BCMCPU_IS_6328()) val = 0x18000000; else { val = bcm_mpi_readl(MPI_CSBASE_REG(0)); val &= MPI_CSBASE_BASE_MASK; } boot_addr = (u8 *)KSEG1ADDR(val); /* dump cfe version */ cfe = boot_addr + BCM963XX_CFE_VERSION_OFFSET; if (!memcmp(cfe, "cfe-v", 5)) snprintf(cfe_version, sizeof(cfe_version), "%u.%u.%u-%u.%u", cfe[5], cfe[6], cfe[7], cfe[8], cfe[9]); else strcpy(cfe_version, "unknown"); printk(KERN_INFO PFX "CFE version: %s\n", cfe_version); bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET); board_name = bcm63xx_nvram_get_name(); /* find board by name */ for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) { if (strncmp(board_name, bcm963xx_boards[i]->name, 16)) continue; /* copy, board desc array is marked initdata */ memcpy(&board, bcm963xx_boards[i], sizeof(board)); break; } /* bail out if board is not found, will complain later */ if (!board.name[0]) { char name[17]; memcpy(name, board_name, 16); name[16] = 0; printk(KERN_ERR PFX "unknown bcm963xx board: %s\n", name); return; } /* setup pin multiplexing depending on board enabled device, * this has to be done this early since PCI init is done * inside arch_initcall */ val = 0; #ifdef CONFIG_PCI if (board.has_pci) { bcm63xx_pci_enabled = 1; if (BCMCPU_IS_6348()) val |= GPIO_MODE_6348_G2_PCI; } #endif if (board.has_pccard) { if (BCMCPU_IS_6348()) val |= GPIO_MODE_6348_G1_MII_PCCARD; } if (board.has_enet0 && !board.enet0.use_internal_phy) { if (BCMCPU_IS_6348()) val |= GPIO_MODE_6348_G3_EXT_MII | GPIO_MODE_6348_G0_EXT_MII; } if (board.has_enet1 && !board.enet1.use_internal_phy) { if (BCMCPU_IS_6348()) val |= GPIO_MODE_6348_G3_EXT_MII | GPIO_MODE_6348_G0_EXT_MII; } bcm_gpio_writel(val, GPIO_MODE_REG); }