forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/arch/powerpc/platforms/pasemi/setup.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2006-2007 PA Semi, Inc
34 *
....@@ -7,19 +8,6 @@
78 * Maintained by: Olof Johansson <olof@lixom.net>
89 *
910 * Based on arch/powerpc/platforms/maple/setup.c
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License version 2 as
13
- * published by the Free Software Foundation.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License
21
- * along with this program; if not, write to the Free Software
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2311 */
2412
2513 #include <linux/errno.h>
....@@ -34,6 +22,7 @@
3422 #include <asm/prom.h>
3523 #include <asm/iommu.h>
3624 #include <asm/machdep.h>
25
+#include <asm/i8259.h>
3726 #include <asm/mpic.h>
3827 #include <asm/smp.h>
3928 #include <asm/time.h>
....@@ -71,6 +60,40 @@
7160 while (1)
7261 out_le32(reset_reg, 0x6000000);
7362 }
63
+
64
+#ifdef CONFIG_PPC_PASEMI_NEMO
65
+void pas_shutdown(void)
66
+{
67
+ /* Set the PLD bit that makes the SB600 think the power button is being pressed */
68
+ void __iomem *pld_map = ioremap(0xf5000000,4096);
69
+ while (1)
70
+ out_8(pld_map+7,0x01);
71
+}
72
+
73
+/* RTC platform device structure as is not in device tree */
74
+static struct resource rtc_resource[] = {{
75
+ .name = "rtc",
76
+ .start = 0x70,
77
+ .end = 0x71,
78
+ .flags = IORESOURCE_IO,
79
+}, {
80
+ .name = "rtc",
81
+ .start = 8,
82
+ .end = 8,
83
+ .flags = IORESOURCE_IRQ,
84
+}};
85
+
86
+static inline void nemo_init_rtc(void)
87
+{
88
+ platform_device_register_simple("rtc_cmos", -1, rtc_resource, 2);
89
+}
90
+
91
+#else
92
+
93
+static inline void nemo_init_rtc(void)
94
+{
95
+}
96
+#endif
7497
7598 #ifdef CONFIG_SMP
7699 static arch_spinlock_t timebase_lock;
....@@ -123,10 +146,6 @@
123146 #endif
124147 /* Lookup PCI hosts */
125148 pas_pci_init();
126
-
127
-#ifdef CONFIG_DUMMY_CONSOLE
128
- conswitchp = &dummy_con;
129
-#endif
130149
131150 /* Remap SDC register for doing reset */
132151 /* XXXOJN This should maybe come out of the device tree */
....@@ -182,6 +201,42 @@
182201 return 0;
183202 }
184203 machine_device_initcall(pasemi, pas_setup_mce_regs);
204
+
205
+#ifdef CONFIG_PPC_PASEMI_NEMO
206
+static void sb600_8259_cascade(struct irq_desc *desc)
207
+{
208
+ struct irq_chip *chip = irq_desc_get_chip(desc);
209
+ unsigned int cascade_irq = i8259_irq();
210
+
211
+ if (cascade_irq)
212
+ generic_handle_irq(cascade_irq);
213
+
214
+ chip->irq_eoi(&desc->irq_data);
215
+}
216
+
217
+static void nemo_init_IRQ(struct mpic *mpic)
218
+{
219
+ struct device_node *np;
220
+ int gpio_virq;
221
+ /* Connect the SB600's legacy i8259 controller */
222
+ np = of_find_node_by_path("/pxp@0,e0000000");
223
+ i8259_init(np, 0);
224
+ of_node_put(np);
225
+
226
+ gpio_virq = irq_create_mapping(NULL, 3);
227
+ irq_set_irq_type(gpio_virq, IRQ_TYPE_LEVEL_HIGH);
228
+ irq_set_chained_handler(gpio_virq, sb600_8259_cascade);
229
+ mpic_unmask_irq(irq_get_irq_data(gpio_virq));
230
+
231
+ irq_set_default_host(mpic->irqhost);
232
+}
233
+
234
+#else
235
+
236
+static inline void nemo_init_IRQ(struct mpic *mpic)
237
+{
238
+}
239
+#endif
185240
186241 static __init void pas_init_IRQ(void)
187242 {
....@@ -242,6 +297,8 @@
242297 irq_set_irq_type(nmi_virq, IRQ_TYPE_EDGE_RISING);
243298 mpic_unmask_irq(irq_get_irq_data(nmi_virq));
244299 }
300
+
301
+ nemo_init_IRQ(mpic);
245302
246303 of_node_put(mpic_node);
247304 of_node_put(root);
....@@ -338,55 +395,6 @@
338395 return !!(srr1 & 0x2);
339396 }
340397
341
-#ifdef CONFIG_PCMCIA
342
-static int pcmcia_notify(struct notifier_block *nb, unsigned long action,
343
- void *data)
344
-{
345
- struct device *dev = data;
346
- struct device *parent;
347
- struct pcmcia_device *pdev = to_pcmcia_dev(dev);
348
-
349
- /* We are only intereted in device addition */
350
- if (action != BUS_NOTIFY_ADD_DEVICE)
351
- return 0;
352
-
353
- parent = pdev->socket->dev.parent;
354
-
355
- /* We know electra_cf devices will always have of_node set, since
356
- * electra_cf is an of_platform driver.
357
- */
358
- if (!parent->of_node)
359
- return 0;
360
-
361
- if (!of_device_is_compatible(parent->of_node, "electra-cf"))
362
- return 0;
363
-
364
- /* We use the direct ops for localbus */
365
- dev->dma_ops = &dma_nommu_ops;
366
-
367
- return 0;
368
-}
369
-
370
-static struct notifier_block pcmcia_notifier = {
371
- .notifier_call = pcmcia_notify,
372
-};
373
-
374
-static inline void pasemi_pcmcia_init(void)
375
-{
376
- extern struct bus_type pcmcia_bus_type;
377
-
378
- bus_register_notifier(&pcmcia_bus_type, &pcmcia_notifier);
379
-}
380
-
381
-#else
382
-
383
-static inline void pasemi_pcmcia_init(void)
384
-{
385
-}
386
-
387
-#endif
388
-
389
-
390398 static const struct of_device_id pasemi_bus_ids[] = {
391399 /* Unfortunately needed for legacy firmwares */
392400 { .type = "localbus", },
....@@ -399,10 +407,10 @@
399407
400408 static int __init pasemi_publish_devices(void)
401409 {
402
- pasemi_pcmcia_init();
403
-
404410 /* Publish OF platform devices for SDC and other non-PCI devices */
405411 of_platform_bus_probe(NULL, pasemi_bus_ids, NULL);
412
+
413
+ nemo_init_rtc();
406414
407415 return 0;
408416 }
....@@ -418,6 +426,17 @@
418426 !of_machine_is_compatible("pasemi,pwrficient"))
419427 return 0;
420428
429
+#ifdef CONFIG_PPC_PASEMI_NEMO
430
+ /*
431
+ * Check for the Nemo motherboard here, if we are running on one
432
+ * change the machine definition to fit
433
+ */
434
+ if (of_machine_is_compatible("pasemi,nemo")) {
435
+ pm_power_off = pas_shutdown;
436
+ ppc_md.name = "A-EON Amigaone X1000";
437
+ }
438
+#endif
439
+
421440 iommu_init_early_pasemi();
422441
423442 return 1;