arm64: dts: qcom: Add Lenovo Yoga C630
[sfrench/cifs-2.6.git] / arch / arm / mach-ks8695 / board-sg.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * board-sg.c -- support for the SnapGear KS8695 based boards
4  */
5
6 #include <linux/kernel.h>
7 #include <linux/types.h>
8 #include <linux/init.h>
9 #include <linux/platform_device.h>
10 #include <linux/mtd/mtd.h>
11 #include <linux/mtd/map.h>
12 #include <linux/mtd/physmap.h>
13 #include <linux/mtd/partitions.h>
14 #include <asm/mach-types.h>
15 #include <asm/mach/arch.h>
16 #include "devices.h"
17 #include "generic.h"
18
19 /*
20  * The SG310 machine type is fitted with a conventional 8MB Strataflash
21  * device. Define its partitioning.
22  */
23 #define FL_BASE         0x02000000
24 #define FL_SIZE         SZ_8M
25
26 static struct mtd_partition sg_mtd_partitions[] = {
27         [0] = {
28                 .name   = "SnapGear Boot Loader",
29                 .size   = SZ_128K,
30         },
31         [1] = {
32                 .name   = "SnapGear non-volatile configuration",
33                 .size   = SZ_512K,
34                 .offset = SZ_256K,
35         },
36         [2] = {
37                 .name   = "SnapGear image",
38                 .offset = SZ_512K + SZ_256K,
39         },
40         [3] = {
41                 .name   = "SnapGear StrataFlash",
42         },
43         [4] = {
44                 .name   = "SnapGear Boot Tags",
45                 .size   = SZ_128K,
46                 .offset = SZ_128K,
47         },
48 };
49
50 static struct physmap_flash_data sg_mtd_pdata = {
51         .width          = 1,
52         .nr_parts       = ARRAY_SIZE(sg_mtd_partitions),
53         .parts          = sg_mtd_partitions,
54 };
55
56
57 static struct resource sg_mtd_resource[] = {
58         [0] = {
59                 .start = FL_BASE,
60                 .end   = FL_BASE + FL_SIZE - 1,
61                 .flags = IORESOURCE_MEM,
62         },
63 };
64
65 static struct platform_device sg_mtd_device = {
66         .name           = "physmap-flash",
67         .id             = 0,
68         .num_resources  = ARRAY_SIZE(sg_mtd_resource),
69         .resource       = sg_mtd_resource,
70         .dev            = {
71                 .platform_data = &sg_mtd_pdata,
72         },
73 };
74
75 static void __init sg_init(void)
76 {
77         ks8695_add_device_lan();
78         ks8695_add_device_wan();
79
80         if (machine_is_sg310())
81                 platform_device_register(&sg_mtd_device);
82 }
83
84 #ifdef CONFIG_MACH_LITE300
85 MACHINE_START(LITE300, "SecureComputing/SG300")
86         /* SnapGear */
87         .atag_offset    = 0x100,
88         .map_io         = ks8695_map_io,
89         .init_irq       = ks8695_init_irq,
90         .init_machine   = sg_init,
91         .init_time      = ks8695_timer_init,
92         .restart        = ks8695_restart,
93 MACHINE_END
94 #endif
95
96 #ifdef CONFIG_MACH_SG310
97 MACHINE_START(SG310, "McAfee/SG310")
98         /* SnapGear */
99         .atag_offset    = 0x100,
100         .map_io         = ks8695_map_io,
101         .init_irq       = ks8695_init_irq,
102         .init_machine   = sg_init,
103         .init_time      = ks8695_timer_init,
104         .restart        = ks8695_restart,
105 MACHINE_END
106 #endif
107
108 #ifdef CONFIG_MACH_SE4200
109 MACHINE_START(SE4200, "SecureComputing/SE4200")
110         /* SnapGear */
111         .atag_offset    = 0x100,
112         .map_io         = ks8695_map_io,
113         .init_irq       = ks8695_init_irq,
114         .init_machine   = sg_init,
115         .init_time      = ks8695_timer_init,
116         .restart        = ks8695_restart,
117 MACHINE_END
118 #endif