Loading...
Note: File does not exist in v6.2.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
4 * Copyright (C) 2011, Maarten ter Huurne <maarten@treewalker.org>
5 * JZ4740 setup code
6 */
7
8#include <linux/clocksource.h>
9#include <linux/init.h>
10#include <linux/io.h>
11#include <linux/irqchip.h>
12#include <linux/kernel.h>
13#include <linux/libfdt.h>
14#include <linux/of_clk.h>
15#include <linux/of_fdt.h>
16#include <linux/pm.h>
17#include <linux/sizes.h>
18#include <linux/suspend.h>
19
20#include <asm/bootinfo.h>
21#include <asm/fw/fw.h>
22#include <asm/prom.h>
23#include <asm/reboot.h>
24#include <asm/time.h>
25
26static unsigned long __init get_board_mach_type(const void *fdt)
27{
28 if (!fdt_node_check_compatible(fdt, 0, "ingenic,x2000"))
29 return MACH_INGENIC_X2000;
30 if (!fdt_node_check_compatible(fdt, 0, "ingenic,x1830"))
31 return MACH_INGENIC_X1830;
32 if (!fdt_node_check_compatible(fdt, 0, "ingenic,x1000"))
33 return MACH_INGENIC_X1000;
34 if (!fdt_node_check_compatible(fdt, 0, "ingenic,jz4780"))
35 return MACH_INGENIC_JZ4780;
36 if (!fdt_node_check_compatible(fdt, 0, "ingenic,jz4770"))
37 return MACH_INGENIC_JZ4770;
38 if (!fdt_node_check_compatible(fdt, 0, "ingenic,jz4725b"))
39 return MACH_INGENIC_JZ4725B;
40
41 return MACH_INGENIC_JZ4740;
42}
43
44void __init plat_mem_setup(void)
45{
46 void *dtb = (void *)fw_passed_dtb;
47
48 __dt_setup_arch(dtb);
49
50 /*
51 * Old devicetree files for the qi,lb60 board did not have a /memory
52 * node. Hardcode the memory info here.
53 */
54 if (!fdt_node_check_compatible(dtb, 0, "qi,lb60") &&
55 fdt_path_offset(dtb, "/memory") < 0)
56 early_init_dt_add_memory_arch(0, SZ_32M);
57
58 mips_machtype = get_board_mach_type(dtb);
59}
60
61void __init device_tree_init(void)
62{
63 if (!initial_boot_params)
64 return;
65
66 unflatten_and_copy_device_tree();
67}
68
69const char *get_system_type(void)
70{
71 switch (mips_machtype) {
72 case MACH_INGENIC_X2000:
73 return "X2000";
74 case MACH_INGENIC_X1830:
75 return "X1830";
76 case MACH_INGENIC_X1000:
77 return "X1000";
78 case MACH_INGENIC_JZ4780:
79 return "JZ4780";
80 case MACH_INGENIC_JZ4770:
81 return "JZ4770";
82 case MACH_INGENIC_JZ4725B:
83 return "JZ4725B";
84 default:
85 return "JZ4740";
86 }
87}
88
89void __init arch_init_irq(void)
90{
91 irqchip_init();
92}
93
94void __init plat_time_init(void)
95{
96 of_clk_init(NULL);
97 timer_probe();
98}
99
100void __init prom_init(void)
101{
102 fw_init_cmdline();
103}
104
105void __init prom_free_prom_memory(void)
106{
107}
108
109static void jz4740_wait_instr(void)
110{
111 __asm__(".set push;\n"
112 ".set mips3;\n"
113 "wait;\n"
114 ".set pop;\n"
115 );
116}
117
118static void jz4740_halt(void)
119{
120 for (;;)
121 jz4740_wait_instr();
122}
123
124static int __maybe_unused jz4740_pm_enter(suspend_state_t state)
125{
126 jz4740_wait_instr();
127
128 return 0;
129}
130
131static const struct platform_suspend_ops jz4740_pm_ops __maybe_unused = {
132 .valid = suspend_valid_only_mem,
133 .enter = jz4740_pm_enter,
134};
135
136static int __init jz4740_pm_init(void)
137{
138 if (IS_ENABLED(CONFIG_PM_SLEEP))
139 suspend_set_ops(&jz4740_pm_ops);
140 _machine_halt = jz4740_halt;
141
142 return 0;
143
144}
145late_initcall(jz4740_pm_init);