at v6.19 78 lines 1.4 kB view raw
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * EcoNet setup code 4 * 5 * Copyright (C) 2025 Caleb James DeLisle <cjd@cjdns.fr> 6 */ 7 8#include <linux/init.h> 9#include <linux/of_clk.h> 10#include <linux/irqchip.h> 11 12#include <asm/addrspace.h> 13#include <asm/io.h> 14#include <asm/bootinfo.h> 15#include <asm/time.h> 16#include <asm/prom.h> 17#include <asm/smp-ops.h> 18#include <asm/reboot.h> 19 20#define CR_AHB_RSTCR ((void __iomem *)CKSEG1ADDR(0x1fb00040)) 21#define RESET BIT(31) 22 23#define UART_BASE CKSEG1ADDR(0x1fbf0003) 24#define UART_REG_SHIFT 2 25 26static void hw_reset(char *command) 27{ 28 iowrite32(RESET, CR_AHB_RSTCR); 29} 30 31/* 1. Bring up early printk. */ 32void __init prom_init(void) 33{ 34 setup_8250_early_printk_port(UART_BASE, UART_REG_SHIFT, 0); 35 _machine_restart = hw_reset; 36} 37 38/* 2. Parse the DT and find memory */ 39void __init plat_mem_setup(void) 40{ 41 void *dtb; 42 43 set_io_port_base(KSEG1); 44 45 dtb = get_fdt(); 46 if (!dtb) 47 panic("no dtb found"); 48 49 __dt_setup_arch(dtb); 50 51 early_init_dt_scan_memory(); 52} 53 54/* 3. Overload __weak device_tree_init(), add SMP_UP ops */ 55void __init device_tree_init(void) 56{ 57 unflatten_and_copy_device_tree(); 58 59 register_up_smp_ops(); 60} 61 62const char *get_system_type(void) 63{ 64 return "EcoNet-EN75xx"; 65} 66 67/* 4. Initialize the IRQ subsystem */ 68void __init arch_init_irq(void) 69{ 70 irqchip_init(); 71} 72 73/* 5. Timers */ 74void __init plat_time_init(void) 75{ 76 of_clk_init(NULL); 77 timer_probe(); 78}