diff options
-rw-r--r-- | arch/arm/boot/dts/Makefile | 9 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/Kconfig | 19 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/include/mach/bridge-regs.h | 85 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/include/mach/kirkwood.h | 142 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/kirkwood-pm.c | 76 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/kirkwood-pm.h | 26 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/kirkwood.c | 209 |
8 files changed, 563 insertions, 4 deletions
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index b9d6a8b485e0..e135182992b2 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile | |||
@@ -81,8 +81,8 @@ dtb-$(CONFIG_ARCH_HIGHBANK) += highbank.dtb \ | |||
81 | ecx-2000.dtb | 81 | ecx-2000.dtb |
82 | dtb-$(CONFIG_ARCH_INTEGRATOR) += integratorap.dtb \ | 82 | dtb-$(CONFIG_ARCH_INTEGRATOR) += integratorap.dtb \ |
83 | integratorcp.dtb | 83 | integratorcp.dtb |
84 | dtb-$(CONFIG_ARCH_LPC32XX) += ea3250.dtb phy3250.dtb | 84 | kirkwood := \ |
85 | dtb-$(CONFIG_ARCH_KIRKWOOD) += kirkwood-cloudbox.dtb \ | 85 | kirkwood-cloudbox.dtb \ |
86 | kirkwood-db-88f6281.dtb \ | 86 | kirkwood-db-88f6281.dtb \ |
87 | kirkwood-db-88f6282.dtb \ | 87 | kirkwood-db-88f6282.dtb \ |
88 | kirkwood-dns320.dtb \ | 88 | kirkwood-dns320.dtb \ |
@@ -116,6 +116,8 @@ dtb-$(CONFIG_ARCH_KIRKWOOD) += kirkwood-cloudbox.dtb \ | |||
116 | kirkwood-topkick.dtb \ | 116 | kirkwood-topkick.dtb \ |
117 | kirkwood-ts219-6281.dtb \ | 117 | kirkwood-ts219-6281.dtb \ |
118 | kirkwood-ts219-6282.dtb | 118 | kirkwood-ts219-6282.dtb |
119 | dtb-$(CONFIG_ARCH_KIRKWOOD) += $(kirkwood) | ||
120 | dtb-$(CONFIG_ARCH_LPC32XX) += ea3250.dtb phy3250.dtb | ||
119 | dtb-$(CONFIG_ARCH_MARCO) += marco-evb.dtb | 121 | dtb-$(CONFIG_ARCH_MARCO) += marco-evb.dtb |
120 | dtb-$(CONFIG_ARCH_MOXART) += moxart-uc7112lx.dtb | 122 | dtb-$(CONFIG_ARCH_MOXART) += moxart-uc7112lx.dtb |
121 | dtb-$(CONFIG_ARCH_MSM) += qcom-msm8660-surf.dtb \ | 123 | dtb-$(CONFIG_ARCH_MSM) += qcom-msm8660-surf.dtb \ |
@@ -131,7 +133,8 @@ dtb-$(CONFIG_ARCH_MVEBU) += armada-370-db.dtb \ | |||
131 | armada-xp-gp.dtb \ | 133 | armada-xp-gp.dtb \ |
132 | armada-xp-netgear-rn2120.dtb \ | 134 | armada-xp-netgear-rn2120.dtb \ |
133 | armada-xp-matrix.dtb \ | 135 | armada-xp-matrix.dtb \ |
134 | armada-xp-openblocks-ax3-4.dtb | 136 | armada-xp-openblocks-ax3-4.dtb \ |
137 | $(kirkwood) | ||
135 | dtb-$(CONFIG_ARCH_MXC) += \ | 138 | dtb-$(CONFIG_ARCH_MXC) += \ |
136 | imx25-karo-tx25.dtb \ | 139 | imx25-karo-tx25.dtb \ |
137 | imx25-pdk.dtb \ | 140 | imx25-pdk.dtb \ |
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index 6c0824ef6d03..2d7af55e9f75 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig | |||
@@ -1,5 +1,5 @@ | |||
1 | config ARCH_MVEBU | 1 | config ARCH_MVEBU |
2 | bool "Marvell Engineering Business Unit (MVEBU) SoCs" if ARCH_MULTI_V7 | 2 | bool "Marvell Engineering Business Unit (MVEBU) SoCs" if (ARCH_MULTI_V7 || ARCH_MULTI_V5) |
3 | select ARCH_SUPPORTS_BIG_ENDIAN | 3 | select ARCH_SUPPORTS_BIG_ENDIAN |
4 | select CLKSRC_MMIO | 4 | select CLKSRC_MMIO |
5 | select COMMON_CLK | 5 | select COMMON_CLK |
@@ -46,6 +46,23 @@ config MACH_ARMADA_XP | |||
46 | Say 'Y' here if you want your kernel to support boards based | 46 | Say 'Y' here if you want your kernel to support boards based |
47 | on the Marvell Armada XP SoC with device tree. | 47 | on the Marvell Armada XP SoC with device tree. |
48 | 48 | ||
49 | config MACH_KIRKWOOD | ||
50 | bool "Marvell Kirkwood boards" if ARCH_MULTI_V5 | ||
51 | select ARCH_HAS_CPUFREQ | ||
52 | select ARCH_REQUIRE_GPIOLIB | ||
53 | select CPU_FEROCEON | ||
54 | select KIRKWOOD_CLK | ||
55 | select OF_IRQ | ||
56 | select ORION_IRQCHIP | ||
57 | select ORION_TIMER | ||
58 | select PCI | ||
59 | select PCI_QUIRKS | ||
60 | select PINCTRL_KIRKWOOD | ||
61 | select USE_OF | ||
62 | help | ||
63 | Say 'Y' here if you want your kernel to support boards based | ||
64 | on the Marvell Kirkwood device tree. | ||
65 | |||
49 | endmenu | 66 | endmenu |
50 | 67 | ||
51 | endif | 68 | endif |
diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile index d99846103bbb..6809ec769dd6 100644 --- a/arch/arm/mach-mvebu/Makefile +++ b/arch/arm/mach-mvebu/Makefile | |||
@@ -7,3 +7,4 @@ obj-y += coherency.o coherency_ll.o pmsu.o system-controller.o mvebu-soc-id. | |||
7 | obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o | 7 | obj-$(CONFIG_MACH_ARMADA_370_XP) += armada-370-xp.o |
8 | obj-$(CONFIG_SMP) += platsmp.o headsmp.o | 8 | obj-$(CONFIG_SMP) += platsmp.o headsmp.o |
9 | obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o | 9 | obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o |
10 | obj-$(CONFIG_MACH_KIRKWOOD) += kirkwood.o kirkwood-pm.o | ||
diff --git a/arch/arm/mach-mvebu/include/mach/bridge-regs.h b/arch/arm/mach-mvebu/include/mach/bridge-regs.h new file mode 100644 index 000000000000..6eb8fea1f76f --- /dev/null +++ b/arch/arm/mach-mvebu/include/mach/bridge-regs.h | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-mvebu/include/mach/bridge-regs.h | ||
3 | * | ||
4 | * Mbus-L to Mbus Bridge Registers | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #ifndef __ASM_ARCH_BRIDGE_REGS_H | ||
12 | #define __ASM_ARCH_BRIDGE_REGS_H | ||
13 | |||
14 | #include <mach/kirkwood.h> | ||
15 | |||
16 | #define CPU_CONFIG (BRIDGE_VIRT_BASE + 0x0100) | ||
17 | #define CPU_CONFIG_PHYS (BRIDGE_PHYS_BASE + 0x0100) | ||
18 | #define CPU_CONFIG_ERROR_PROP 0x00000004 | ||
19 | |||
20 | #define CPU_CONTROL (BRIDGE_VIRT_BASE + 0x0104) | ||
21 | #define CPU_CONTROL_PHYS (BRIDGE_PHYS_BASE + 0x0104) | ||
22 | #define CPU_RESET 0x00000002 | ||
23 | |||
24 | #define RSTOUTn_MASK (BRIDGE_VIRT_BASE + 0x0108) | ||
25 | #define SOFT_RESET_OUT_EN 0x00000004 | ||
26 | |||
27 | #define SYSTEM_SOFT_RESET (BRIDGE_VIRT_BASE + 0x010c) | ||
28 | #define SOFT_RESET 0x00000001 | ||
29 | |||
30 | #define BRIDGE_CAUSE (BRIDGE_VIRT_BASE + 0x0110) | ||
31 | |||
32 | #define BRIDGE_INT_TIMER1_CLR (~0x0004) | ||
33 | |||
34 | #define IRQ_VIRT_BASE (BRIDGE_VIRT_BASE + 0x0200) | ||
35 | #define IRQ_CAUSE_LOW_OFF 0x0000 | ||
36 | #define IRQ_MASK_LOW_OFF 0x0004 | ||
37 | #define IRQ_CAUSE_HIGH_OFF 0x0010 | ||
38 | #define IRQ_MASK_HIGH_OFF 0x0014 | ||
39 | |||
40 | #define TIMER_VIRT_BASE (BRIDGE_VIRT_BASE + 0x0300) | ||
41 | #define TIMER_PHYS_BASE (BRIDGE_PHYS_BASE + 0x0300) | ||
42 | |||
43 | #define L2_CONFIG_REG (BRIDGE_VIRT_BASE + 0x0128) | ||
44 | #define L2_WRITETHROUGH 0x00000010 | ||
45 | |||
46 | #define CLOCK_GATING_CTRL (BRIDGE_VIRT_BASE + 0x11c) | ||
47 | #define CGC_BIT_GE0 (0) | ||
48 | #define CGC_BIT_PEX0 (2) | ||
49 | #define CGC_BIT_USB0 (3) | ||
50 | #define CGC_BIT_SDIO (4) | ||
51 | #define CGC_BIT_TSU (5) | ||
52 | #define CGC_BIT_DUNIT (6) | ||
53 | #define CGC_BIT_RUNIT (7) | ||
54 | #define CGC_BIT_XOR0 (8) | ||
55 | #define CGC_BIT_AUDIO (9) | ||
56 | #define CGC_BIT_SATA0 (14) | ||
57 | #define CGC_BIT_SATA1 (15) | ||
58 | #define CGC_BIT_XOR1 (16) | ||
59 | #define CGC_BIT_CRYPTO (17) | ||
60 | #define CGC_BIT_PEX1 (18) | ||
61 | #define CGC_BIT_GE1 (19) | ||
62 | #define CGC_BIT_TDM (20) | ||
63 | #define CGC_GE0 (1 << 0) | ||
64 | #define CGC_PEX0 (1 << 2) | ||
65 | #define CGC_USB0 (1 << 3) | ||
66 | #define CGC_SDIO (1 << 4) | ||
67 | #define CGC_TSU (1 << 5) | ||
68 | #define CGC_DUNIT (1 << 6) | ||
69 | #define CGC_RUNIT (1 << 7) | ||
70 | #define CGC_XOR0 (1 << 8) | ||
71 | #define CGC_AUDIO (1 << 9) | ||
72 | #define CGC_POWERSAVE (1 << 11) | ||
73 | #define CGC_SATA0 (1 << 14) | ||
74 | #define CGC_SATA1 (1 << 15) | ||
75 | #define CGC_XOR1 (1 << 16) | ||
76 | #define CGC_CRYPTO (1 << 17) | ||
77 | #define CGC_PEX1 (1 << 18) | ||
78 | #define CGC_GE1 (1 << 19) | ||
79 | #define CGC_TDM (1 << 20) | ||
80 | #define CGC_RESERVED (0x6 << 21) | ||
81 | |||
82 | #define MEMORY_PM_CTRL (BRIDGE_VIRT_BASE + 0x118) | ||
83 | #define MEMORY_PM_CTRL_PHYS (BRIDGE_PHYS_BASE + 0x118) | ||
84 | |||
85 | #endif | ||
diff --git a/arch/arm/mach-mvebu/include/mach/kirkwood.h b/arch/arm/mach-mvebu/include/mach/kirkwood.h new file mode 100644 index 000000000000..9d966dc78d67 --- /dev/null +++ b/arch/arm/mach-mvebu/include/mach/kirkwood.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-mvebu/include/mach/kirkwood.h | ||
3 | * | ||
4 | * Generic definitions for Marvell Kirkwood SoC flavors: | ||
5 | * 88F6180, 88F6192 and 88F6281. | ||
6 | * | ||
7 | * This file is licensed under the terms of the GNU General Public | ||
8 | * License version 2. This program is licensed "as is" without any | ||
9 | * warranty of any kind, whether express or implied. | ||
10 | */ | ||
11 | |||
12 | #ifndef __ASM_ARCH_KIRKWOOD_H | ||
13 | #define __ASM_ARCH_KIRKWOOD_H | ||
14 | |||
15 | /* | ||
16 | * Marvell Kirkwood address maps. | ||
17 | * | ||
18 | * phys | ||
19 | * e0000000 PCIe #0 Memory space | ||
20 | * e8000000 PCIe #1 Memory space | ||
21 | * f1000000 on-chip peripheral registers | ||
22 | * f2000000 PCIe #0 I/O space | ||
23 | * f3000000 PCIe #1 I/O space | ||
24 | * f4000000 NAND controller address window | ||
25 | * f5000000 Security Accelerator SRAM | ||
26 | * | ||
27 | * virt phys size | ||
28 | * fed00000 f1000000 1M on-chip peripheral registers | ||
29 | * fee00000 f2000000 1M PCIe #0 I/O space | ||
30 | * fef00000 f3000000 1M PCIe #1 I/O space | ||
31 | */ | ||
32 | |||
33 | #define KIRKWOOD_SRAM_PHYS_BASE 0xf5000000 | ||
34 | #define KIRKWOOD_SRAM_SIZE SZ_2K | ||
35 | |||
36 | #define KIRKWOOD_NAND_MEM_PHYS_BASE 0xf4000000 | ||
37 | #define KIRKWOOD_NAND_MEM_SIZE SZ_1K | ||
38 | |||
39 | #define KIRKWOOD_PCIE1_IO_PHYS_BASE 0xf3000000 | ||
40 | #define KIRKWOOD_PCIE1_IO_BUS_BASE 0x00010000 | ||
41 | #define KIRKWOOD_PCIE1_IO_SIZE SZ_64K | ||
42 | |||
43 | #define KIRKWOOD_PCIE_IO_PHYS_BASE 0xf2000000 | ||
44 | #define KIRKWOOD_PCIE_IO_BUS_BASE 0x00000000 | ||
45 | #define KIRKWOOD_PCIE_IO_SIZE SZ_64K | ||
46 | |||
47 | #define KIRKWOOD_REGS_PHYS_BASE 0xf1000000 | ||
48 | #define KIRKWOOD_REGS_VIRT_BASE IOMEM(0xfed00000) | ||
49 | #define KIRKWOOD_REGS_SIZE SZ_1M | ||
50 | |||
51 | #define KIRKWOOD_PCIE_MEM_PHYS_BASE 0xe0000000 | ||
52 | #define KIRKWOOD_PCIE_MEM_BUS_BASE 0xe0000000 | ||
53 | #define KIRKWOOD_PCIE_MEM_SIZE SZ_128M | ||
54 | |||
55 | #define KIRKWOOD_PCIE1_MEM_PHYS_BASE 0xe8000000 | ||
56 | #define KIRKWOOD_PCIE1_MEM_BUS_BASE 0xe8000000 | ||
57 | #define KIRKWOOD_PCIE1_MEM_SIZE SZ_128M | ||
58 | |||
59 | /* | ||
60 | * Register Map | ||
61 | */ | ||
62 | #define DDR_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE + 0x00000) | ||
63 | #define DDR_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x00000) | ||
64 | #define DDR_WINDOW_CPU_BASE (DDR_PHYS_BASE + 0x1500) | ||
65 | #define DDR_WINDOW_CPU_SZ (0x20) | ||
66 | #define DDR_OPERATION_BASE (DDR_PHYS_BASE + 0x1418) | ||
67 | |||
68 | #define DEV_BUS_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x10000) | ||
69 | #define DEV_BUS_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE + 0x10000) | ||
70 | #define SAMPLE_AT_RESET (DEV_BUS_VIRT_BASE + 0x0030) | ||
71 | #define DEVICE_ID (DEV_BUS_VIRT_BASE + 0x0034) | ||
72 | #define GPIO_LOW_VIRT_BASE (DEV_BUS_VIRT_BASE + 0x0100) | ||
73 | #define GPIO_HIGH_VIRT_BASE (DEV_BUS_VIRT_BASE + 0x0140) | ||
74 | #define RTC_PHYS_BASE (DEV_BUS_PHYS_BASE + 0x0300) | ||
75 | #define SPI_PHYS_BASE (DEV_BUS_PHYS_BASE + 0x0600) | ||
76 | #define I2C_PHYS_BASE (DEV_BUS_PHYS_BASE + 0x1000) | ||
77 | #define UART0_PHYS_BASE (DEV_BUS_PHYS_BASE + 0x2000) | ||
78 | #define UART0_VIRT_BASE (DEV_BUS_VIRT_BASE + 0x2000) | ||
79 | #define UART1_PHYS_BASE (DEV_BUS_PHYS_BASE + 0x2100) | ||
80 | #define UART1_VIRT_BASE (DEV_BUS_VIRT_BASE + 0x2100) | ||
81 | |||
82 | #define BRIDGE_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE + 0x20000) | ||
83 | #define BRIDGE_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x20000) | ||
84 | #define BRIDGE_WINS_BASE (BRIDGE_PHYS_BASE) | ||
85 | #define BRIDGE_WINS_SZ (0x80) | ||
86 | |||
87 | #define CRYPTO_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x30000) | ||
88 | |||
89 | #define PCIE_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE + 0x40000) | ||
90 | #define PCIE_LINK_CTRL (PCIE_VIRT_BASE + 0x70) | ||
91 | #define PCIE_STATUS (PCIE_VIRT_BASE + 0x1a04) | ||
92 | #define PCIE1_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE + 0x44000) | ||
93 | #define PCIE1_LINK_CTRL (PCIE1_VIRT_BASE + 0x70) | ||
94 | #define PCIE1_STATUS (PCIE1_VIRT_BASE + 0x1a04) | ||
95 | |||
96 | #define USB_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x50000) | ||
97 | |||
98 | #define XOR0_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x60800) | ||
99 | #define XOR0_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE + 0x60800) | ||
100 | #define XOR1_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x60900) | ||
101 | #define XOR1_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE + 0x60900) | ||
102 | #define XOR0_HIGH_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x60A00) | ||
103 | #define XOR0_HIGH_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE + 0x60A00) | ||
104 | #define XOR1_HIGH_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x60B00) | ||
105 | #define XOR1_HIGH_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE + 0x60B00) | ||
106 | |||
107 | #define GE00_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x70000) | ||
108 | #define GE01_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x74000) | ||
109 | |||
110 | #define SATA_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x80000) | ||
111 | #define SATA_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE + 0x80000) | ||
112 | #define SATA0_IF_CTRL (SATA_VIRT_BASE + 0x2050) | ||
113 | #define SATA0_PHY_MODE_2 (SATA_VIRT_BASE + 0x2330) | ||
114 | #define SATA1_IF_CTRL (SATA_VIRT_BASE + 0x4050) | ||
115 | #define SATA1_PHY_MODE_2 (SATA_VIRT_BASE + 0x4330) | ||
116 | |||
117 | #define SDIO_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0x90000) | ||
118 | |||
119 | #define AUDIO_PHYS_BASE (KIRKWOOD_REGS_PHYS_BASE + 0xA0000) | ||
120 | #define AUDIO_VIRT_BASE (KIRKWOOD_REGS_VIRT_BASE + 0xA0000) | ||
121 | |||
122 | /* | ||
123 | * Supported devices and revisions. | ||
124 | */ | ||
125 | #define MV88F6281_DEV_ID 0x6281 | ||
126 | #define MV88F6281_REV_Z0 0 | ||
127 | #define MV88F6281_REV_A0 2 | ||
128 | #define MV88F6281_REV_A1 3 | ||
129 | |||
130 | #define MV88F6192_DEV_ID 0x6192 | ||
131 | #define MV88F6192_REV_Z0 0 | ||
132 | #define MV88F6192_REV_A0 2 | ||
133 | #define MV88F6192_REV_A1 3 | ||
134 | |||
135 | #define MV88F6180_DEV_ID 0x6180 | ||
136 | #define MV88F6180_REV_A0 2 | ||
137 | #define MV88F6180_REV_A1 3 | ||
138 | |||
139 | #define MV88F6282_DEV_ID 0x6282 | ||
140 | #define MV88F6282_REV_A0 0 | ||
141 | #define MV88F6282_REV_A1 1 | ||
142 | #endif | ||
diff --git a/arch/arm/mach-mvebu/kirkwood-pm.c b/arch/arm/mach-mvebu/kirkwood-pm.c new file mode 100644 index 000000000000..b8c8365b84d8 --- /dev/null +++ b/arch/arm/mach-mvebu/kirkwood-pm.c | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * Power Management driver for Marvell Kirkwood SoCs | ||
3 | * | ||
4 | * Copyright (C) 2013 Ezequiel Garcia <ezequiel@free-electrons.com> | ||
5 | * Copyright (C) 2010 Simon Guinot <sguinot@lacie.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License, | ||
9 | * version 2 of the License. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | */ | ||
16 | |||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/suspend.h> | ||
19 | #include <linux/io.h> | ||
20 | #include <mach/bridge-regs.h> | ||
21 | |||
22 | static void __iomem *ddr_operation_base; | ||
23 | static void __iomem *memory_pm_ctrl; | ||
24 | |||
25 | static void kirkwood_low_power(void) | ||
26 | { | ||
27 | u32 mem_pm_ctrl; | ||
28 | |||
29 | mem_pm_ctrl = readl(memory_pm_ctrl); | ||
30 | |||
31 | /* Set peripherals to low-power mode */ | ||
32 | writel_relaxed(~0, memory_pm_ctrl); | ||
33 | |||
34 | /* Set DDR in self-refresh */ | ||
35 | writel_relaxed(0x7, ddr_operation_base); | ||
36 | |||
37 | /* | ||
38 | * Set CPU in wait-for-interrupt state. | ||
39 | * This disables the CPU core clocks, | ||
40 | * the array clocks, and also the L2 controller. | ||
41 | */ | ||
42 | cpu_do_idle(); | ||
43 | |||
44 | writel_relaxed(mem_pm_ctrl, memory_pm_ctrl); | ||
45 | } | ||
46 | |||
47 | static int kirkwood_suspend_enter(suspend_state_t state) | ||
48 | { | ||
49 | switch (state) { | ||
50 | case PM_SUSPEND_STANDBY: | ||
51 | kirkwood_low_power(); | ||
52 | break; | ||
53 | default: | ||
54 | return -EINVAL; | ||
55 | } | ||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static int kirkwood_pm_valid_standby(suspend_state_t state) | ||
60 | { | ||
61 | return state == PM_SUSPEND_STANDBY; | ||
62 | } | ||
63 | |||
64 | static const struct platform_suspend_ops kirkwood_suspend_ops = { | ||
65 | .enter = kirkwood_suspend_enter, | ||
66 | .valid = kirkwood_pm_valid_standby, | ||
67 | }; | ||
68 | |||
69 | int __init kirkwood_pm_init(void) | ||
70 | { | ||
71 | ddr_operation_base = ioremap(DDR_OPERATION_BASE, 4); | ||
72 | memory_pm_ctrl = ioremap(MEMORY_PM_CTRL_PHYS, 4); | ||
73 | |||
74 | suspend_set_ops(&kirkwood_suspend_ops); | ||
75 | return 0; | ||
76 | } | ||
diff --git a/arch/arm/mach-mvebu/kirkwood-pm.h b/arch/arm/mach-mvebu/kirkwood-pm.h new file mode 100644 index 000000000000..21e7530f368b --- /dev/null +++ b/arch/arm/mach-mvebu/kirkwood-pm.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * Power Management driver for Marvell Kirkwood SoCs | ||
3 | * | ||
4 | * Copyright (C) 2013 Ezequiel Garcia <ezequiel@free-electrons.com> | ||
5 | * Copyright (C) 2010 Simon Guinot <sguinot@lacie.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License, | ||
9 | * version 2 of the License. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | */ | ||
16 | |||
17 | #ifndef __ARCH_KIRKWOOD_PM_H | ||
18 | #define __ARCH_KIRKWOOD_PM_H | ||
19 | |||
20 | #ifdef CONFIG_PM | ||
21 | void kirkwood_pm_init(void); | ||
22 | #else | ||
23 | static inline void kirkwood_pm_init(void) {}; | ||
24 | #endif | ||
25 | |||
26 | #endif | ||
diff --git a/arch/arm/mach-mvebu/kirkwood.c b/arch/arm/mach-mvebu/kirkwood.c new file mode 100644 index 000000000000..6e754a38f418 --- /dev/null +++ b/arch/arm/mach-mvebu/kirkwood.c | |||
@@ -0,0 +1,209 @@ | |||
1 | /* | ||
2 | * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net> | ||
3 | * | ||
4 | * arch/arm/mach-mvebu/kirkwood.c | ||
5 | * | ||
6 | * Flattened Device Tree board initialization | ||
7 | * | ||
8 | * This file is licensed under the terms of the GNU General Public | ||
9 | * License version 2. This program is licensed "as is" without any | ||
10 | * warranty of any kind, whether express or implied. | ||
11 | */ | ||
12 | |||
13 | #include <linux/clk.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/of.h> | ||
17 | #include <linux/of_address.h> | ||
18 | #include <linux/of_net.h> | ||
19 | #include <linux/of_platform.h> | ||
20 | #include <linux/dma-mapping.h> | ||
21 | #include <linux/irqchip.h> | ||
22 | #include <linux/kexec.h> | ||
23 | #include <asm/hardware/cache-feroceon-l2.h> | ||
24 | #include <asm/mach/arch.h> | ||
25 | #include <asm/mach/map.h> | ||
26 | #include <mach/bridge-regs.h> | ||
27 | #include <plat/common.h> | ||
28 | #include <plat/pcie.h> | ||
29 | #include "kirkwood-pm.h" | ||
30 | |||
31 | static struct resource kirkwood_cpufreq_resources[] = { | ||
32 | [0] = { | ||
33 | .start = CPU_CONTROL_PHYS, | ||
34 | .end = CPU_CONTROL_PHYS + 3, | ||
35 | .flags = IORESOURCE_MEM, | ||
36 | }, | ||
37 | }; | ||
38 | |||
39 | static struct platform_device kirkwood_cpufreq_device = { | ||
40 | .name = "kirkwood-cpufreq", | ||
41 | .id = -1, | ||
42 | .num_resources = ARRAY_SIZE(kirkwood_cpufreq_resources), | ||
43 | .resource = kirkwood_cpufreq_resources, | ||
44 | }; | ||
45 | |||
46 | static void __init kirkwood_cpufreq_init(void) | ||
47 | { | ||
48 | platform_device_register(&kirkwood_cpufreq_device); | ||
49 | } | ||
50 | |||
51 | static struct resource kirkwood_cpuidle_resource[] = { | ||
52 | { | ||
53 | .flags = IORESOURCE_MEM, | ||
54 | .start = DDR_OPERATION_BASE, | ||
55 | .end = DDR_OPERATION_BASE + 3, | ||
56 | }, | ||
57 | }; | ||
58 | |||
59 | static struct platform_device kirkwood_cpuidle = { | ||
60 | .name = "kirkwood_cpuidle", | ||
61 | .id = -1, | ||
62 | .resource = kirkwood_cpuidle_resource, | ||
63 | .num_resources = 1, | ||
64 | }; | ||
65 | |||
66 | static void __init kirkwood_cpuidle_init(void) | ||
67 | { | ||
68 | platform_device_register(&kirkwood_cpuidle); | ||
69 | } | ||
70 | |||
71 | /* Temporary here since mach-mvebu has a function we can use */ | ||
72 | static void kirkwood_restart(enum reboot_mode mode, const char *cmd) | ||
73 | { | ||
74 | /* | ||
75 | * Enable soft reset to assert RSTOUTn. | ||
76 | */ | ||
77 | writel(SOFT_RESET_OUT_EN, RSTOUTn_MASK); | ||
78 | |||
79 | /* | ||
80 | * Assert soft reset. | ||
81 | */ | ||
82 | writel(SOFT_RESET, SYSTEM_SOFT_RESET); | ||
83 | |||
84 | while (1) | ||
85 | ; | ||
86 | } | ||
87 | |||
88 | #define MV643XX_ETH_MAC_ADDR_LOW 0x0414 | ||
89 | #define MV643XX_ETH_MAC_ADDR_HIGH 0x0418 | ||
90 | |||
91 | static void __init kirkwood_dt_eth_fixup(void) | ||
92 | { | ||
93 | struct device_node *np; | ||
94 | |||
95 | /* | ||
96 | * The ethernet interfaces forget the MAC address assigned by u-boot | ||
97 | * if the clocks are turned off. Usually, u-boot on kirkwood boards | ||
98 | * has no DT support to properly set local-mac-address property. | ||
99 | * As a workaround, we get the MAC address from mv643xx_eth registers | ||
100 | * and update the port device node if no valid MAC address is set. | ||
101 | */ | ||
102 | for_each_compatible_node(np, NULL, "marvell,kirkwood-eth-port") { | ||
103 | struct device_node *pnp = of_get_parent(np); | ||
104 | struct clk *clk; | ||
105 | struct property *pmac; | ||
106 | void __iomem *io; | ||
107 | u8 *macaddr; | ||
108 | u32 reg; | ||
109 | |||
110 | if (!pnp) | ||
111 | continue; | ||
112 | |||
113 | /* skip disabled nodes or nodes with valid MAC address*/ | ||
114 | if (!of_device_is_available(pnp) || of_get_mac_address(np)) | ||
115 | goto eth_fixup_skip; | ||
116 | |||
117 | clk = of_clk_get(pnp, 0); | ||
118 | if (IS_ERR(clk)) | ||
119 | goto eth_fixup_skip; | ||
120 | |||
121 | io = of_iomap(pnp, 0); | ||
122 | if (!io) | ||
123 | goto eth_fixup_no_map; | ||
124 | |||
125 | /* ensure port clock is not gated to not hang CPU */ | ||
126 | clk_prepare_enable(clk); | ||
127 | |||
128 | /* store MAC address register contents in local-mac-address */ | ||
129 | pr_err(FW_INFO "%s: local-mac-address is not set\n", | ||
130 | np->full_name); | ||
131 | |||
132 | pmac = kzalloc(sizeof(*pmac) + 6, GFP_KERNEL); | ||
133 | if (!pmac) | ||
134 | goto eth_fixup_no_mem; | ||
135 | |||
136 | pmac->value = pmac + 1; | ||
137 | pmac->length = 6; | ||
138 | pmac->name = kstrdup("local-mac-address", GFP_KERNEL); | ||
139 | if (!pmac->name) { | ||
140 | kfree(pmac); | ||
141 | goto eth_fixup_no_mem; | ||
142 | } | ||
143 | |||
144 | macaddr = pmac->value; | ||
145 | reg = readl(io + MV643XX_ETH_MAC_ADDR_HIGH); | ||
146 | macaddr[0] = (reg >> 24) & 0xff; | ||
147 | macaddr[1] = (reg >> 16) & 0xff; | ||
148 | macaddr[2] = (reg >> 8) & 0xff; | ||
149 | macaddr[3] = reg & 0xff; | ||
150 | |||
151 | reg = readl(io + MV643XX_ETH_MAC_ADDR_LOW); | ||
152 | macaddr[4] = (reg >> 8) & 0xff; | ||
153 | macaddr[5] = reg & 0xff; | ||
154 | |||
155 | of_update_property(np, pmac); | ||
156 | |||
157 | eth_fixup_no_mem: | ||
158 | iounmap(io); | ||
159 | clk_disable_unprepare(clk); | ||
160 | eth_fixup_no_map: | ||
161 | clk_put(clk); | ||
162 | eth_fixup_skip: | ||
163 | of_node_put(pnp); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | /* | ||
168 | * Disable propagation of mbus errors to the CPU local bus, as this | ||
169 | * causes mbus errors (which can occur for example for PCI aborts) to | ||
170 | * throw CPU aborts, which we're not set up to deal with. | ||
171 | */ | ||
172 | void kirkwood_disable_mbus_error_propagation(void) | ||
173 | { | ||
174 | void __iomem *cpu_config; | ||
175 | |||
176 | cpu_config = ioremap(CPU_CONFIG_PHYS, 4); | ||
177 | writel(readl(cpu_config) & ~CPU_CONFIG_ERROR_PROP, cpu_config); | ||
178 | } | ||
179 | |||
180 | |||
181 | static void __init kirkwood_dt_init(void) | ||
182 | { | ||
183 | kirkwood_disable_mbus_error_propagation(); | ||
184 | |||
185 | BUG_ON(mvebu_mbus_dt_init()); | ||
186 | |||
187 | #ifdef CONFIG_CACHE_FEROCEON_L2 | ||
188 | feroceon_of_init(); | ||
189 | #endif | ||
190 | kirkwood_cpufreq_init(); | ||
191 | kirkwood_cpuidle_init(); | ||
192 | |||
193 | kirkwood_pm_init(); | ||
194 | kirkwood_dt_eth_fixup(); | ||
195 | |||
196 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); | ||
197 | } | ||
198 | |||
199 | static const char * const kirkwood_dt_board_compat[] = { | ||
200 | "marvell,kirkwood", | ||
201 | NULL | ||
202 | }; | ||
203 | |||
204 | DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)") | ||
205 | /* Maintainer: Jason Cooper <jason@lakedaemon.net> */ | ||
206 | .init_machine = kirkwood_dt_init, | ||
207 | .restart = kirkwood_restart, | ||
208 | .dt_compat = kirkwood_dt_board_compat, | ||
209 | MACHINE_END | ||