1 // SPDX-License-Identifier: GPL-2.0
6 #include <linux/init.h>
7 #include <linux/mtd/mtd.h>
8 #include <linux/mtd/map.h>
9 #include <linux/mtd/physmap.h>
10 #include <linux/slab.h>
11 #include <linux/platform_device.h>
14 #include <asm/bootinfo.h>
16 #include <asm/reboot.h>
17 #include <asm/setup.h>
18 #include <asm/mach-au1x00/au1000.h>
19 #include <asm/mach-db1x00/bcsr.h>
23 void prom_putchar(char c
)
25 if (alchemy_get_cputype() == ALCHEMY_CPU_AU1300
)
26 alchemy_uart_putchar(AU1300_UART2_PHYS_ADDR
, c
);
28 alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR
, c
);
32 static struct platform_device db1x00_rtc_dev
= {
38 static void db1x_power_off(void)
40 bcsr_write(BCSR_RESETS
, 0);
41 bcsr_write(BCSR_SYSTEM
, BCSR_SYSTEM_PWROFF
| BCSR_SYSTEM_RESET
);
42 while (1) /* sit and spin */
46 static void db1x_reset(char *c
)
48 bcsr_write(BCSR_RESETS
, 0);
49 bcsr_write(BCSR_SYSTEM
, 0);
52 static int __init
db1x_late_setup(void)
55 pm_power_off
= db1x_power_off
;
57 _machine_halt
= db1x_power_off
;
58 if (!_machine_restart
)
59 _machine_restart
= db1x_reset
;
61 platform_device_register(&db1x00_rtc_dev
);
65 device_initcall(db1x_late_setup
);
67 /* register a pcmcia socket */
68 int __init
db1x_register_pcmcia_socket(phys_addr_t pcmcia_attr_start
,
69 phys_addr_t pcmcia_attr_end
,
70 phys_addr_t pcmcia_mem_start
,
71 phys_addr_t pcmcia_mem_end
,
72 phys_addr_t pcmcia_io_start
,
73 phys_addr_t pcmcia_io_end
,
82 struct platform_device
*pd
;
90 sr
= kcalloc(cnt
, sizeof(struct resource
), GFP_KERNEL
);
94 pd
= platform_device_alloc("db1xxx_pcmcia", id
);
100 sr
[0].name
= "pcmcia-attr";
101 sr
[0].flags
= IORESOURCE_MEM
;
102 sr
[0].start
= pcmcia_attr_start
;
103 sr
[0].end
= pcmcia_attr_end
;
105 sr
[1].name
= "pcmcia-mem";
106 sr
[1].flags
= IORESOURCE_MEM
;
107 sr
[1].start
= pcmcia_mem_start
;
108 sr
[1].end
= pcmcia_mem_end
;
110 sr
[2].name
= "pcmcia-io";
111 sr
[2].flags
= IORESOURCE_MEM
;
112 sr
[2].start
= pcmcia_io_start
;
113 sr
[2].end
= pcmcia_io_end
;
115 sr
[3].name
= "insert";
116 sr
[3].flags
= IORESOURCE_IRQ
;
117 sr
[3].start
= sr
[3].end
= cd_irq
;
120 sr
[4].flags
= IORESOURCE_IRQ
;
121 sr
[4].start
= sr
[4].end
= card_irq
;
125 sr
[i
].name
= "stschg";
126 sr
[i
].flags
= IORESOURCE_IRQ
;
127 sr
[i
].start
= sr
[i
].end
= stschg_irq
;
131 sr
[i
].name
= "eject";
132 sr
[i
].flags
= IORESOURCE_IRQ
;
133 sr
[i
].start
= sr
[i
].end
= eject_irq
;
137 pd
->num_resources
= cnt
;
139 ret
= platform_device_add(pd
);
143 platform_device_put(pd
);
149 #define YAMON_SIZE 0x00100000
150 #define YAMON_ENV_SIZE 0x00040000
152 int __init
db1x_register_norflash(unsigned long size
, int width
,
155 struct physmap_flash_data
*pfd
;
156 struct platform_device
*pd
;
157 struct mtd_partition
*parts
;
158 struct resource
*res
;
161 if (size
< (8 * 1024 * 1024))
165 parts
= kcalloc(5, sizeof(struct mtd_partition
), GFP_KERNEL
);
169 res
= kzalloc(sizeof(struct resource
), GFP_KERNEL
);
173 pfd
= kzalloc(sizeof(struct physmap_flash_data
), GFP_KERNEL
);
177 pd
= platform_device_alloc("physmap-flash", 0);
181 /* NOR flash ends at 0x20000000, regardless of size */
182 res
->start
= 0x20000000 - size
;
183 res
->end
= 0x20000000 - 1;
184 res
->flags
= IORESOURCE_MEM
;
186 /* partition setup. Most Develboards have a switch which allows
187 * to swap the physical locations of the 2 NOR flash banks.
193 parts
[i
].name
= "User FS";
194 parts
[i
].size
= size
/ 2;
198 parts
[i
].offset
= MTDPART_OFS_APPEND
;
199 parts
[i
].name
= "User FS 2";
200 parts
[i
].size
= (size
/ 2) - (0x20000000 - 0x1fc00000);
203 parts
[i
].offset
= MTDPART_OFS_APPEND
;
204 parts
[i
].name
= "YAMON";
205 parts
[i
].size
= YAMON_SIZE
;
206 parts
[i
].mask_flags
= MTD_WRITEABLE
;
209 parts
[i
].offset
= MTDPART_OFS_APPEND
;
210 parts
[i
].name
= "raw kernel";
211 parts
[i
].size
= 0x00400000 - YAMON_SIZE
- YAMON_ENV_SIZE
;
214 parts
[i
].offset
= MTDPART_OFS_APPEND
;
215 parts
[i
].name
= "YAMON Env";
216 parts
[i
].size
= YAMON_ENV_SIZE
;
217 parts
[i
].mask_flags
= MTD_WRITEABLE
;
221 parts
[i
].offset
= MTDPART_OFS_APPEND
;
222 parts
[i
].name
= "User FS";
223 parts
[i
].size
= size
/ 2;
231 pd
->dev
.platform_data
= pfd
;
233 pd
->num_resources
= 1;
235 ret
= platform_device_add(pd
);
239 platform_device_put(pd
);