| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2006-2007 PA Semi, Inc |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 7 | 8 | * Maintained by: Olof Johansson <olof@lixom.net> |
|---|
| 8 | 9 | * |
|---|
| 9 | 10 | * 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 |
|---|
| 23 | 11 | */ |
|---|
| 24 | 12 | |
|---|
| 25 | 13 | #include <linux/errno.h> |
|---|
| .. | .. |
|---|
| 34 | 22 | #include <asm/prom.h> |
|---|
| 35 | 23 | #include <asm/iommu.h> |
|---|
| 36 | 24 | #include <asm/machdep.h> |
|---|
| 25 | +#include <asm/i8259.h> |
|---|
| 37 | 26 | #include <asm/mpic.h> |
|---|
| 38 | 27 | #include <asm/smp.h> |
|---|
| 39 | 28 | #include <asm/time.h> |
|---|
| .. | .. |
|---|
| 71 | 60 | while (1) |
|---|
| 72 | 61 | out_le32(reset_reg, 0x6000000); |
|---|
| 73 | 62 | } |
|---|
| 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 |
|---|
| 74 | 97 | |
|---|
| 75 | 98 | #ifdef CONFIG_SMP |
|---|
| 76 | 99 | static arch_spinlock_t timebase_lock; |
|---|
| .. | .. |
|---|
| 123 | 146 | #endif |
|---|
| 124 | 147 | /* Lookup PCI hosts */ |
|---|
| 125 | 148 | pas_pci_init(); |
|---|
| 126 | | - |
|---|
| 127 | | -#ifdef CONFIG_DUMMY_CONSOLE |
|---|
| 128 | | - conswitchp = &dummy_con; |
|---|
| 129 | | -#endif |
|---|
| 130 | 149 | |
|---|
| 131 | 150 | /* Remap SDC register for doing reset */ |
|---|
| 132 | 151 | /* XXXOJN This should maybe come out of the device tree */ |
|---|
| .. | .. |
|---|
| 182 | 201 | return 0; |
|---|
| 183 | 202 | } |
|---|
| 184 | 203 | 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 |
|---|
| 185 | 240 | |
|---|
| 186 | 241 | static __init void pas_init_IRQ(void) |
|---|
| 187 | 242 | { |
|---|
| .. | .. |
|---|
| 242 | 297 | irq_set_irq_type(nmi_virq, IRQ_TYPE_EDGE_RISING); |
|---|
| 243 | 298 | mpic_unmask_irq(irq_get_irq_data(nmi_virq)); |
|---|
| 244 | 299 | } |
|---|
| 300 | + |
|---|
| 301 | + nemo_init_IRQ(mpic); |
|---|
| 245 | 302 | |
|---|
| 246 | 303 | of_node_put(mpic_node); |
|---|
| 247 | 304 | of_node_put(root); |
|---|
| .. | .. |
|---|
| 338 | 395 | return !!(srr1 & 0x2); |
|---|
| 339 | 396 | } |
|---|
| 340 | 397 | |
|---|
| 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 | | - |
|---|
| 390 | 398 | static const struct of_device_id pasemi_bus_ids[] = { |
|---|
| 391 | 399 | /* Unfortunately needed for legacy firmwares */ |
|---|
| 392 | 400 | { .type = "localbus", }, |
|---|
| .. | .. |
|---|
| 399 | 407 | |
|---|
| 400 | 408 | static int __init pasemi_publish_devices(void) |
|---|
| 401 | 409 | { |
|---|
| 402 | | - pasemi_pcmcia_init(); |
|---|
| 403 | | - |
|---|
| 404 | 410 | /* Publish OF platform devices for SDC and other non-PCI devices */ |
|---|
| 405 | 411 | of_platform_bus_probe(NULL, pasemi_bus_ids, NULL); |
|---|
| 412 | + |
|---|
| 413 | + nemo_init_rtc(); |
|---|
| 406 | 414 | |
|---|
| 407 | 415 | return 0; |
|---|
| 408 | 416 | } |
|---|
| .. | .. |
|---|
| 418 | 426 | !of_machine_is_compatible("pasemi,pwrficient")) |
|---|
| 419 | 427 | return 0; |
|---|
| 420 | 428 | |
|---|
| 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 | + |
|---|
| 421 | 440 | iommu_init_early_pasemi(); |
|---|
| 422 | 441 | |
|---|
| 423 | 442 | return 1; |
|---|