msm: board: DT and non-DT based board file for MSM Copper
Add board file for device tree based device with callouts
to support a mix of DT and non-DT based devices for the
initial phase.
Change-Id: I948df1c1272483f2584fdd9b873f126600e4ccc7
Signed-off-by: Sathish Ambley <sambley@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-copper.c b/arch/arm/mach-msm/board-copper.c
new file mode 100644
index 0000000..496e1f4
--- /dev/null
+++ b/arch/arm/mach-msm/board-copper.c
@@ -0,0 +1,95 @@
+/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/irqdomain.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <asm/mach/map.h>
+#include <asm/hardware/gic.h>
+#include <mach/board.h>
+#include <mach/gpio.h>
+#include <mach/gpiomux.h>
+#include <mach/msm_iomap.h>
+#include "clock.h"
+
+static int __init gpiomux_init(void)
+{
+ int rc;
+
+ rc = msm_gpiomux_init(NR_GPIO_IRQS);
+ if (rc) {
+ pr_err("%s: msm_gpiomux_init failed %d\n", __func__, rc);
+ return rc;
+ }
+
+ return 0;
+}
+
+void __init msm_copper_add_devices(void)
+{
+}
+
+static struct of_device_id msm_copper_gic_match[] __initdata = {
+ { .compatible = "qcom,msm-qgic2", },
+ {}
+};
+
+void __init msm_copper_init_irq(void)
+{
+ unsigned int i;
+
+ gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
+ (void *)MSM_QGIC_CPU_BASE);
+
+ /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
+ writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
+
+ writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
+ mb();
+
+ /* FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
+ * as they are configured as level, which does not play nice with
+ * handle_percpu_irq.
+ */
+ for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
+ if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
+ irq_set_handler(i, handle_percpu_irq);
+ }
+ irq_domain_generate_simple(msm_copper_gic_match,
+ COPPER_QGIC_DIST_PHYS, GIC_SPI_START);
+}
+
+static struct clk_lookup msm_clocks_dummy[] = {
+};
+
+struct clock_init_data msm_dummy_clock_init_data __initdata = {
+ .table = msm_clocks_dummy,
+ .size = ARRAY_SIZE(msm_clocks_dummy),
+};
+
+static struct of_dev_auxdata msm_copper_auxdata_lookup[] __initdata = {
+ {}
+};
+
+void __init msm_copper_init(struct of_dev_auxdata **adata)
+{
+ if (gpiomux_init())
+ pr_err("%s: gpiomux_init() failed\n", __func__);
+ msm_clock_init(&msm_dummy_clock_init_data);
+
+ *adata = msm_copper_auxdata_lookup;
+}
diff --git a/arch/arm/mach-msm/board-dt.c b/arch/arm/mach-msm/board-dt.c
new file mode 100644
index 0000000..1ede17b
--- /dev/null
+++ b/arch/arm/mach-msm/board-dt.c
@@ -0,0 +1,66 @@
+/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/of_fdt.h>
+#include <asm/mach/arch.h>
+#include <mach/socinfo.h>
+#include <mach/board.h>
+#include "timer.h"
+
+#define early_machine_is_copper() \
+ of_flat_dt_is_compatible(of_get_flat_dt_root(), "qcom,msmcopper")
+#define machine_is_copper() \
+ of_machine_is_compatible("qcom,msmcopper")
+
+static void __init msm_dt_init_irq(void)
+{
+ if (machine_is_copper())
+ msm_copper_init_irq();
+}
+
+static void __init msm_dt_map_io(void)
+{
+ if (early_machine_is_copper())
+ msm_map_copper_io();
+ if (socinfo_init() < 0)
+ pr_err("%s: socinfo_init() failed\n", __func__);
+}
+
+static void __init msm_dt_init(void)
+{
+ struct of_dev_auxdata *adata = NULL;
+
+ if (machine_is_copper())
+ msm_copper_init(&adata);
+
+ of_platform_populate(NULL, of_default_bus_match_table, adata, NULL);
+ if (machine_is_copper())
+ msm_copper_add_devices();
+}
+
+static const char *msm_dt_match[] __initdata = {
+ "qcom,msmcopper",
+ NULL
+};
+
+DT_MACHINE_START(MSM_DT, "Qualcomm MSM (Flattened Device Tree)")
+ .map_io = msm_dt_map_io,
+ .init_irq = msm_dt_init_irq,
+ .init_machine = msm_dt_init,
+ .timer = &msm_timer,
+ .dt_compat = msm_dt_match,
+MACHINE_END
diff --git a/arch/arm/mach-msm/include/mach/board.h b/arch/arm/mach-msm/include/mach/board.h
index 5a30df5..2b9343e 100644
--- a/arch/arm/mach-msm/include/mach/board.h
+++ b/arch/arm/mach-msm/include/mach/board.h
@@ -23,6 +23,7 @@
#include <linux/usb.h>
#include <linux/leds-pmic8058.h>
#include <linux/clkdev.h>
+#include <linux/of_platform.h>
#include <linux/msm_ssbi.h>
#include <mach/msm_bus.h>
@@ -410,7 +411,11 @@
#endif
/* common init routines for use by arch/arm/mach-msm/board-*.c */
+#ifdef CONFIG_OF_DEVICE
+void msm_copper_init(struct of_dev_auxdata **);
+#endif
void msm_add_devices(void);
+void msm_copper_add_devices(void);
void msm_map_common_io(void);
void msm_map_qsd8x50_io(void);
void msm_map_msm8x60_io(void);
@@ -419,7 +424,9 @@
void msm_map_apq8064_io(void);
void msm_map_msm7x30_io(void);
void msm_map_fsm9xxx_io(void);
+void msm_map_copper_io(void);
void msm_init_irq(void);
+void msm_copper_init_irq(void);
void vic_handle_irq(struct pt_regs *regs);
struct mmc_platform_data;