^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * License. See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/memblock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/pm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/bootinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <asm/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/reboot.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/cacheflush.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <bcm63xx_board.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <bcm63xx_cpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <bcm63xx_regs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <bcm63xx_io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <bcm63xx_gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) void bcm63xx_machine_halt(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) pr_info("System halted\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) while (1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static void bcm6348_a1_reboot(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) u32 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /* soft reset all blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) pr_info("soft-resetting all blocks ...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) reg = bcm_perf_readl(PERF_SOFTRESET_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) reg &= ~SOFTRESET_6348_ALL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) bcm_perf_writel(reg, PERF_SOFTRESET_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) mdelay(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) reg = bcm_perf_readl(PERF_SOFTRESET_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) reg |= SOFTRESET_6348_ALL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) bcm_perf_writel(reg, PERF_SOFTRESET_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) mdelay(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* Jump to the power on address. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) pr_info("jumping to reset vector.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /* set high vectors (base at 0xbfc00000 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) set_c0_status(ST0_BEV | ST0_ERL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* run uncached in kseg0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) __flush_cache_all();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /* remove all wired TLB entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) write_c0_wired(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) __asm__ __volatile__(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) "jr\t%0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) : "r" (0xbfc00000));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) while (1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) void bcm63xx_machine_reboot(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u32 reg, perf_regs[2] = { 0, 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /* mask and clear all external irq */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) switch (bcm63xx_get_cpu_id()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) case BCM3368_CPU_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) perf_regs[0] = PERF_EXTIRQ_CFG_REG_3368;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) case BCM6328_CPU_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) perf_regs[0] = PERF_EXTIRQ_CFG_REG_6328;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) case BCM6338_CPU_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) perf_regs[0] = PERF_EXTIRQ_CFG_REG_6338;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) case BCM6345_CPU_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) perf_regs[0] = PERF_EXTIRQ_CFG_REG_6345;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) case BCM6348_CPU_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) perf_regs[0] = PERF_EXTIRQ_CFG_REG_6348;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) case BCM6358_CPU_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) perf_regs[0] = PERF_EXTIRQ_CFG_REG_6358;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) case BCM6362_CPU_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) perf_regs[0] = PERF_EXTIRQ_CFG_REG_6362;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) for (i = 0; i < 2; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) if (!perf_regs[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) reg = bcm_perf_readl(perf_regs[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) if (BCMCPU_IS_6348()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) reg &= ~EXTIRQ_CFG_MASK_ALL_6348;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) reg |= EXTIRQ_CFG_CLEAR_ALL_6348;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) reg &= ~EXTIRQ_CFG_MASK_ALL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) reg |= EXTIRQ_CFG_CLEAR_ALL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) bcm_perf_writel(reg, perf_regs[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (BCMCPU_IS_6348() && (bcm63xx_get_cpu_rev() == 0xa1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) bcm6348_a1_reboot();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) pr_info("triggering watchdog soft-reset...\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) if (BCMCPU_IS_6328()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) bcm_wdt_writel(1, WDT_SOFTRESET_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) reg = bcm_perf_readl(PERF_SYS_PLL_CTL_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) reg |= SYS_PLL_SOFT_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) bcm_perf_writel(reg, PERF_SYS_PLL_CTL_REG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) while (1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static void __bcm63xx_machine_reboot(char *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) bcm63xx_machine_reboot();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * return system type in /proc/cpuinfo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) const char *get_system_type(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static char buf[128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) snprintf(buf, sizeof(buf), "bcm63xx/%s (0x%04x/0x%02X)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) board_get_name(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) bcm63xx_get_cpu_id(), bcm63xx_get_cpu_rev());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) void __init plat_time_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) mips_hpt_frequency = bcm63xx_get_cpu_freq() / 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) void __init plat_mem_setup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) memblock_add(0, bcm63xx_get_memory_size());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) _machine_halt = bcm63xx_machine_halt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) _machine_restart = __bcm63xx_machine_reboot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) pm_power_off = bcm63xx_machine_halt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) set_io_port_base(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) ioport_resource.start = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) ioport_resource.end = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) board_setup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) int __init bcm63xx_register_devices(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /* register gpiochip */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) bcm63xx_gpio_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) return board_register_devices();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) arch_initcall(bcm63xx_register_devices);