0001
0002
0003
0004
0005 #include <linux/clk.h>
0006 #include <linux/clkdev.h>
0007 #include <linux/clocksource.h>
0008 #include <linux/dma-map-ops.h>
0009 #include <linux/input.h>
0010 #include <linux/io.h>
0011 #include <linux/irqchip.h>
0012 #include <linux/pl320-ipc.h>
0013 #include <linux/of.h>
0014 #include <linux/of_irq.h>
0015 #include <linux/of_address.h>
0016 #include <linux/reboot.h>
0017 #include <linux/amba/bus.h>
0018 #include <linux/platform_device.h>
0019 #include <linux/psci.h>
0020
0021 #include <asm/hardware/cache-l2x0.h>
0022 #include <asm/mach/arch.h>
0023 #include <asm/mach/map.h>
0024
0025 #include "core.h"
0026 #include "sysregs.h"
0027
0028 void __iomem *sregs_base;
0029 void __iomem *scu_base_addr;
0030
0031 static void __init highbank_scu_map_io(void)
0032 {
0033 unsigned long base;
0034
0035
0036 asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (base));
0037
0038 scu_base_addr = ioremap(base, SZ_4K);
0039 }
0040
0041
0042 static void highbank_l2c310_write_sec(unsigned long val, unsigned reg)
0043 {
0044 if (reg == L2X0_CTRL)
0045 highbank_smc1(0x102, val);
0046 else
0047 WARN_ONCE(1, "Highbank L2C310: ignoring write to reg 0x%x\n",
0048 reg);
0049 }
0050
0051 static void __init highbank_init_irq(void)
0052 {
0053 irqchip_init();
0054
0055 if (of_find_compatible_node(NULL, NULL, "arm,cortex-a9"))
0056 highbank_scu_map_io();
0057 }
0058
0059 static void highbank_power_off(void)
0060 {
0061 highbank_set_pwr_shutdown();
0062
0063 while (1)
0064 cpu_do_idle();
0065 }
0066
0067 static int highbank_platform_notifier(struct notifier_block *nb,
0068 unsigned long event, void *__dev)
0069 {
0070 struct resource *res;
0071 int reg = -1;
0072 u32 val;
0073 struct device *dev = __dev;
0074
0075 if (event != BUS_NOTIFY_ADD_DEVICE)
0076 return NOTIFY_DONE;
0077
0078 if (of_device_is_compatible(dev->of_node, "calxeda,hb-ahci"))
0079 reg = 0xc;
0080 else if (of_device_is_compatible(dev->of_node, "calxeda,hb-sdhci"))
0081 reg = 0x18;
0082 else if (of_device_is_compatible(dev->of_node, "arm,pl330"))
0083 reg = 0x20;
0084 else if (of_device_is_compatible(dev->of_node, "calxeda,hb-xgmac")) {
0085 res = platform_get_resource(to_platform_device(dev),
0086 IORESOURCE_MEM, 0);
0087 if (res) {
0088 if (res->start == 0xfff50000)
0089 reg = 0;
0090 else if (res->start == 0xfff51000)
0091 reg = 4;
0092 }
0093 }
0094
0095 if (reg < 0)
0096 return NOTIFY_DONE;
0097
0098 if (of_property_read_bool(dev->of_node, "dma-coherent")) {
0099 val = readl(sregs_base + reg);
0100 writel(val | 0xff01, sregs_base + reg);
0101 dev->dma_coherent = true;
0102 }
0103
0104 return NOTIFY_OK;
0105 }
0106
0107 static struct notifier_block highbank_amba_nb = {
0108 .notifier_call = highbank_platform_notifier,
0109 };
0110
0111 static struct notifier_block highbank_platform_nb = {
0112 .notifier_call = highbank_platform_notifier,
0113 };
0114
0115 static struct platform_device highbank_cpuidle_device = {
0116 .name = "cpuidle-calxeda",
0117 };
0118
0119 static int hb_keys_notifier(struct notifier_block *nb, unsigned long event, void *data)
0120 {
0121 u32 key = *(u32 *)data;
0122
0123 if (event != 0x1000)
0124 return 0;
0125
0126 if (key == KEY_POWER)
0127 orderly_poweroff(false);
0128 else if (key == 0xffff)
0129 ctrl_alt_del();
0130
0131 return 0;
0132 }
0133 static struct notifier_block hb_keys_nb = {
0134 .notifier_call = hb_keys_notifier,
0135 };
0136
0137 static void __init highbank_init(void)
0138 {
0139 struct device_node *np;
0140
0141
0142 np = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
0143 sregs_base = of_iomap(np, 0);
0144 WARN_ON(!sregs_base);
0145
0146 pm_power_off = highbank_power_off;
0147 highbank_pm_init();
0148
0149 bus_register_notifier(&platform_bus_type, &highbank_platform_nb);
0150 bus_register_notifier(&amba_bustype, &highbank_amba_nb);
0151
0152 pl320_ipc_register_notifier(&hb_keys_nb);
0153
0154 if (psci_ops.cpu_suspend)
0155 platform_device_register(&highbank_cpuidle_device);
0156 }
0157
0158 static const char *const highbank_match[] __initconst = {
0159 "calxeda,highbank",
0160 "calxeda,ecx-2000",
0161 NULL,
0162 };
0163
0164 DT_MACHINE_START(HIGHBANK, "Highbank")
0165 #if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE)
0166 .dma_zone_size = (4ULL * SZ_1G),
0167 #endif
0168 .l2c_aux_val = 0,
0169 .l2c_aux_mask = ~0,
0170 .l2c_write_sec = highbank_l2c310_write_sec,
0171 .init_irq = highbank_init_irq,
0172 .init_machine = highbank_init,
0173 .dt_compat = highbank_match,
0174 .restart = highbank_restart,
0175 MACHINE_END