xref: /linux/arch/arm/mach-orion5x/board-mss2.c (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2fbf04d81SThomas Petazzoni /*
3fbf04d81SThomas Petazzoni  * Maxtor Shared Storage II Board Setup
4fbf04d81SThomas Petazzoni  *
5fbf04d81SThomas Petazzoni  * Maintainer: Sylver Bruneau <sylver.bruneau@googlemail.com>
6fbf04d81SThomas Petazzoni  */
7fbf04d81SThomas Petazzoni 
8fbf04d81SThomas Petazzoni #include <linux/kernel.h>
9fbf04d81SThomas Petazzoni #include <linux/init.h>
10fbf04d81SThomas Petazzoni #include <linux/platform_device.h>
11fbf04d81SThomas Petazzoni #include <linux/pci.h>
12fbf04d81SThomas Petazzoni #include <linux/irq.h>
13fbf04d81SThomas Petazzoni #include <asm/mach-types.h>
14fbf04d81SThomas Petazzoni #include <asm/mach/arch.h>
15fbf04d81SThomas Petazzoni #include <asm/mach/pci.h>
16c22c2c60SArnd Bergmann #include "orion5x.h"
17c22c2c60SArnd Bergmann #include "bridge-regs.h"
18fbf04d81SThomas Petazzoni #include "common.h"
19fbf04d81SThomas Petazzoni 
20fbf04d81SThomas Petazzoni /*****************************************************************************
21fbf04d81SThomas Petazzoni  * Maxtor Shared Storage II Info
22fbf04d81SThomas Petazzoni  ****************************************************************************/
23fbf04d81SThomas Petazzoni 
24fbf04d81SThomas Petazzoni /****************************************************************************
25fbf04d81SThomas Petazzoni  * PCI setup
26fbf04d81SThomas Petazzoni  ****************************************************************************/
mss2_pci_map_irq(const struct pci_dev * dev,u8 slot,u8 pin)27fbf04d81SThomas Petazzoni static int __init mss2_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
28fbf04d81SThomas Petazzoni {
29fbf04d81SThomas Petazzoni 	int irq;
30fbf04d81SThomas Petazzoni 
31fbf04d81SThomas Petazzoni 	/*
32fbf04d81SThomas Petazzoni 	 * Check for devices with hard-wired IRQs.
33fbf04d81SThomas Petazzoni 	 */
34fbf04d81SThomas Petazzoni 	irq = orion5x_pci_map_irq(dev, slot, pin);
35fbf04d81SThomas Petazzoni 	if (irq != -1)
36fbf04d81SThomas Petazzoni 		return irq;
37fbf04d81SThomas Petazzoni 
38fbf04d81SThomas Petazzoni 	return -1;
39fbf04d81SThomas Petazzoni }
40fbf04d81SThomas Petazzoni 
41fbf04d81SThomas Petazzoni static struct hw_pci mss2_pci __initdata = {
42fbf04d81SThomas Petazzoni 	.nr_controllers = 2,
43fbf04d81SThomas Petazzoni 	.setup		= orion5x_pci_sys_setup,
44fbf04d81SThomas Petazzoni 	.scan		= orion5x_pci_sys_scan_bus,
45fbf04d81SThomas Petazzoni 	.map_irq	= mss2_pci_map_irq,
46fbf04d81SThomas Petazzoni };
47fbf04d81SThomas Petazzoni 
mss2_pci_init(void)48fbf04d81SThomas Petazzoni static int __init mss2_pci_init(void)
49fbf04d81SThomas Petazzoni {
50fbf04d81SThomas Petazzoni 	if (machine_is_mss2())
51fbf04d81SThomas Petazzoni 		pci_common_init(&mss2_pci);
52fbf04d81SThomas Petazzoni 
53fbf04d81SThomas Petazzoni 	return 0;
54fbf04d81SThomas Petazzoni }
55fbf04d81SThomas Petazzoni subsys_initcall(mss2_pci_init);
56fbf04d81SThomas Petazzoni 
57fbf04d81SThomas Petazzoni /*****************************************************************************
58fbf04d81SThomas Petazzoni  * MSS2 power off method
59fbf04d81SThomas Petazzoni  ****************************************************************************/
60fbf04d81SThomas Petazzoni /*
61fbf04d81SThomas Petazzoni  * On the Maxtor Shared Storage II, the shutdown process is the following :
62fbf04d81SThomas Petazzoni  * - Userland modifies U-boot env to tell U-boot to go idle at next boot
63fbf04d81SThomas Petazzoni  * - The board reboots
64fbf04d81SThomas Petazzoni  * - U-boot starts and go into an idle mode until the user press "power"
65fbf04d81SThomas Petazzoni  */
mss2_power_off(void)66fbf04d81SThomas Petazzoni static void mss2_power_off(void)
67fbf04d81SThomas Petazzoni {
68fbf04d81SThomas Petazzoni 	u32 reg;
69fbf04d81SThomas Petazzoni 
70fbf04d81SThomas Petazzoni 	/*
71fbf04d81SThomas Petazzoni 	 * Enable and issue soft reset
72fbf04d81SThomas Petazzoni 	 */
73fbf04d81SThomas Petazzoni 	reg = readl(RSTOUTn_MASK);
74fbf04d81SThomas Petazzoni 	reg |= 1 << 2;
75fbf04d81SThomas Petazzoni 	writel(reg, RSTOUTn_MASK);
76fbf04d81SThomas Petazzoni 
77fbf04d81SThomas Petazzoni 	reg = readl(CPU_SOFT_RESET);
78fbf04d81SThomas Petazzoni 	reg |= 1;
79fbf04d81SThomas Petazzoni 	writel(reg, CPU_SOFT_RESET);
80fbf04d81SThomas Petazzoni }
81fbf04d81SThomas Petazzoni 
mss2_init(void)82fbf04d81SThomas Petazzoni void __init mss2_init(void)
83fbf04d81SThomas Petazzoni {
84fbf04d81SThomas Petazzoni 	/* register mss2 specific power-off method */
85*4bf23b96SAndrew Davis 	register_platform_power_off(mss2_power_off);
86fbf04d81SThomas Petazzoni }
87