summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/zii-imx6q-rdu2/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/boards/zii-imx6q-rdu2/board.c')
-rw-r--r--arch/arm/boards/zii-imx6q-rdu2/board.c283
1 files changed, 265 insertions, 18 deletions
diff --git a/arch/arm/boards/zii-imx6q-rdu2/board.c b/arch/arm/boards/zii-imx6q-rdu2/board.c
index 6352f49c5a..6adb0b1c6f 100644
--- a/arch/arm/boards/zii-imx6q-rdu2/board.c
+++ b/arch/arm/boards/zii-imx6q-rdu2/board.c
@@ -23,6 +23,30 @@
#include <mach/imx6.h>
#include <net.h>
#include <linux/nvmem-consumer.h>
+#include "../zii-common/pn-fixup.h"
+
+enum rdu2_lcd_interface_type {
+ IT_SINGLE_LVDS,
+ IT_DUAL_LVDS,
+ IT_EDP
+};
+
+enum rdu2_lvds_busformat {
+ BF_NONE,
+ BF_JEIDA,
+ BF_SPWG
+};
+
+#define RDU2_LRU_FLAG_EGALAX BIT(0)
+#define RDU2_LRU_FLAG_NO_FEC BIT(1)
+
+struct rdu2_lru_fixup {
+ struct zii_pn_fixup fixup;
+ unsigned int flags;
+ enum rdu2_lcd_interface_type type;
+ enum rdu2_lvds_busformat bus_format;
+ const char *compatible;
+};
#define RDU2_DAC1_RESET IMX_GPIO_NR(1, 0)
#define RDU2_DAC2_RESET IMX_GPIO_NR(1, 2)
@@ -190,31 +214,254 @@ static int rdu2_ethernet_init(void)
}
late_initcall(rdu2_ethernet_init);
-#define I210_CFGWORD_PCIID_157B 0x157b1a11
-static int rdu2_i210_invm(void)
+static int rdu2_fixup_egalax_ts(struct device_node *root, void *context)
{
- int fd;
- u32 val;
+ struct device_node *np;
- if (!of_machine_is_compatible("zii,imx6q-zii-rdu2") &&
- !of_machine_is_compatible("zii,imx6qp-zii-rdu2"))
- return 0;
+ /*
+ * The 32" unit has a EETI eGalax touchscreen instead of the
+ * Synaptics RMI4 found on other units.
+ */
+ pr_info("Enabling eGalax touchscreen instead of RMI4\n");
- fd = open("/dev/e1000-invm0", O_RDWR);
- if (fd < 0) {
- pr_err("could not open e1000 iNVM device!\n");
- return fd;
+ np = of_find_compatible_node(root, NULL, "syna,rmi4-i2c");
+ if (!np)
+ return -ENODEV;
+
+ of_device_disable(np);
+
+ np = of_find_compatible_node(root, NULL, "eeti,exc3000");
+ if (!np)
+ return -ENODEV;
+
+ of_device_enable(np);
+ of_property_write_u32(np->parent, "clock-frequency", 200000);
+
+
+ return 0;
+}
+
+static int rdu2_fixup_dsa(struct device_node *root, void *context)
+{
+ struct device_node *switch_np, *np;
+ phandle i210_handle;
+
+ /*
+ * The 12.1" unit has no FEC connection, so we need to rewrite
+ * the i210 port into the CPU port and delete the FEC port,
+ * which is part of the common setup.
+ */
+ pr_info("Rewriting i210 switch port into CPU port\n");
+
+ switch_np = of_find_compatible_node(root, NULL, "marvell,mv88e6085");
+ if (!switch_np)
+ return -ENODEV;
+
+ np = of_find_node_by_name(switch_np, "port@2");
+ if (!np)
+ return -ENODEV;
+
+ of_delete_node(np);
+
+ np = of_find_node_by_name(root, "i210@0");
+ if (!np)
+ return -ENODEV;
+
+ i210_handle = of_node_create_phandle(np);
+
+ np = of_find_node_by_name(switch_np, "port@0");
+ if (!np)
+ return -ENODEV;
+
+ of_property_write_u32(np, "ethernet", i210_handle);
+ of_property_write_string(np, "label", "cpu");
+
+ return 0;
+}
+
+static int rdu2_fixup_edp(struct device_node *root)
+{
+ const bool kernel_fixup = root != NULL;
+ struct device_node *np;
+
+ if (kernel_fixup) {
+ /*
+ * Kernel DT fixup needs this additional step
+ */
+ pr_info("Found eDP display, enabling parallel output "
+ "and eDP bridge.\n");
+ np = of_find_compatible_node(root, NULL,
+ "fsl,imx-parallel-display");
+ if (!np)
+ return -ENODEV;
+
+ of_device_enable(np);
}
- pread(fd, &val, sizeof(val), 0);
- if (val == I210_CFGWORD_PCIID_157B) {
- pr_debug("i210 already programmed correctly\n");
- return 0;
+ np = of_find_compatible_node(root, NULL, "toshiba,tc358767");
+ if (!np)
+ return -ENODEV;
+
+ of_device_enable(np);
+
+ return 0;
+}
+
+static int rdu2_fixup_lvds(struct device_node *root,
+ const struct rdu2_lru_fixup *fixup)
+{
+ const bool kernel_fixup = root != NULL;
+ struct device_node *np;
+
+ /*
+ * LVDS panels need the correct compatible
+ */
+ pr_info("Found LVDS display, enabling %s channel LDB and "
+ "panel with compatible \"%s\".\n",
+ fixup->type == IT_DUAL_LVDS ? "dual" : "single",
+ fixup->compatible);
+ /*
+ * LVDS panels need the correct timings
+ */
+ np = of_find_node_by_name(root, "panel");
+ if (!np)
+ return -ENODEV;
+
+ if (kernel_fixup) {
+ of_device_enable(np);
+ of_property_write_string(np, "compatible", fixup->compatible);
+ } else {
+ struct device_node *child, *tmp;
+
+ of_device_enable_and_register(np);
+ /*
+ * Delete all mode entries, which aren't suited for the
+ * current display
+ */
+ np = of_find_node_by_name(np, "display-timings");
+ if (!np)
+ return -ENODEV;
+
+ for_each_child_of_node_safe(np, tmp, child) {
+ if (!of_device_is_compatible(child,
+ fixup->compatible))
+ of_delete_node(child);
+ }
}
+ /*
+ * enable LDB channel 0 and set correct interface mode
+ */
+ np = of_find_compatible_node(root, NULL, "fsl,imx6q-ldb");
+ if (!np)
+ return -ENODEV;
+
+ if (kernel_fixup)
+ of_device_enable(np);
+ else
+ of_device_enable_and_register(np);
+
+ if (fixup->type == IT_DUAL_LVDS)
+ of_set_property(np, "fsl,dual-channel", NULL, 0, 1);
+
+ np = of_find_node_by_name(np, "lvds-channel@0");
+ if (!np)
+ return -ENODEV;
+
+ of_device_enable(np);
+
+ if (!kernel_fixup) {
+ of_property_write_string(np, "fsl,data-mapping",
+ fixup->bus_format == BF_SPWG ?
+ "spwg" : "jeida");
+ }
+
+ return 0;
+}
+
+static int rdu2_fixup_display(struct device_node *root, void *context)
+{
+ const struct rdu2_lru_fixup *fixup = context;
+ /*
+ * If the panel is eDP, just enable the parallel output and
+ * eDP bridge
+ */
+ if (fixup->type == IT_EDP)
+ return rdu2_fixup_edp(root);
+
+ return rdu2_fixup_lvds(root, context);
+}
+
+static void rdu2_lru_fixup(const struct zii_pn_fixup *context)
+{
+ const struct rdu2_lru_fixup *fixup =
+ container_of(context, struct rdu2_lru_fixup, fixup);
+
+ WARN_ON(rdu2_fixup_display(NULL, (void *)context));
+ of_register_fixup(rdu2_fixup_display, (void *)context);
+
+ if (fixup->flags & RDU2_LRU_FLAG_EGALAX)
+ of_register_fixup(rdu2_fixup_egalax_ts, NULL);
+
+ if (fixup->flags & RDU2_LRU_FLAG_NO_FEC)
+ of_register_fixup(rdu2_fixup_dsa, NULL);
+}
+
+#define RDU2_LRU_FIXUP(__pn, __flags, __panel) \
+ { \
+ { __pn, rdu2_lru_fixup }, \
+ __flags, \
+ __panel \
+ }
+
+#define RDU2_PANEL_10P1 IT_SINGLE_LVDS, BF_SPWG, "innolux,g121i1-l01"
+#define RDU2_PANEL_11P6 IT_EDP, BF_NONE, NULL
+#define RDU2_PANEL_12P1 IT_SINGLE_LVDS, BF_SPWG, "nec,nl12880bc20-05"
+#define RDU2_PANEL_13P3 IT_DUAL_LVDS, BF_JEIDA, "auo,g133han01"
+#define RDU2_PANEL_15P6 IT_DUAL_LVDS, BF_SPWG, "nlt,nl192108ac18-02d"
+#define RDU2_PANEL_18P5 IT_DUAL_LVDS, BF_SPWG, "auo,g185han01"
+#define RDU2_PANEL_32P0 IT_DUAL_LVDS, BF_SPWG, "auo,p320hvn03"
+
+static const struct rdu2_lru_fixup rdu2_lru_fixups[] = {
+ RDU2_LRU_FIXUP("00-5122-01", RDU2_LRU_FLAG_NO_FEC, RDU2_PANEL_12P1),
+ RDU2_LRU_FIXUP("00-5122-02", RDU2_LRU_FLAG_NO_FEC, RDU2_PANEL_12P1),
+ RDU2_LRU_FIXUP("00-5120-01", 0, RDU2_PANEL_10P1),
+ RDU2_LRU_FIXUP("00-5120-02", 0, RDU2_PANEL_10P1),
+ RDU2_LRU_FIXUP("00-5120-51", 0, RDU2_PANEL_10P1),
+ RDU2_LRU_FIXUP("00-5120-52", 0, RDU2_PANEL_10P1),
+ RDU2_LRU_FIXUP("00-5123-01", 0, RDU2_PANEL_11P6),
+ RDU2_LRU_FIXUP("00-5123-02", 0, RDU2_PANEL_11P6),
+ RDU2_LRU_FIXUP("00-5123-03", 0, RDU2_PANEL_11P6),
+ RDU2_LRU_FIXUP("00-5123-51", 0, RDU2_PANEL_11P6),
+ RDU2_LRU_FIXUP("00-5123-52", 0, RDU2_PANEL_11P6),
+ RDU2_LRU_FIXUP("00-5123-53", 0, RDU2_PANEL_11P6),
+ RDU2_LRU_FIXUP("00-5124-01", 0, RDU2_PANEL_13P3),
+ RDU2_LRU_FIXUP("00-5124-02", 0, RDU2_PANEL_13P3),
+ RDU2_LRU_FIXUP("00-5124-03", 0, RDU2_PANEL_13P3),
+ RDU2_LRU_FIXUP("00-5124-53", 0, RDU2_PANEL_13P3),
+ RDU2_LRU_FIXUP("00-5127-01", 0, RDU2_PANEL_15P6),
+ RDU2_LRU_FIXUP("00-5127-02", 0, RDU2_PANEL_15P6),
+ RDU2_LRU_FIXUP("00-5127-03", 0, RDU2_PANEL_15P6),
+ RDU2_LRU_FIXUP("00-5127-53", 0, RDU2_PANEL_15P6),
+ RDU2_LRU_FIXUP("00-5125-01", 0, RDU2_PANEL_18P5),
+ RDU2_LRU_FIXUP("00-5125-02", 0, RDU2_PANEL_18P5),
+ RDU2_LRU_FIXUP("00-5125-03", 0, RDU2_PANEL_18P5),
+ RDU2_LRU_FIXUP("00-5125-53", 0, RDU2_PANEL_18P5),
+ RDU2_LRU_FIXUP("00-5132-01", RDU2_LRU_FLAG_EGALAX, RDU2_PANEL_32P0),
+ RDU2_LRU_FIXUP("00-5132-02", RDU2_LRU_FLAG_EGALAX, RDU2_PANEL_32P0),
+};
+
+/*
+ * This initcall needs to be executed before coredevices, so we have a chance
+ * to fix up the internal DT with the correct display information.
+ */
+static int rdu2_process_fixups(void)
+{
+ if (!of_machine_is_compatible("zii,imx6q-zii-rdu2") &&
+ !of_machine_is_compatible("zii,imx6qp-zii-rdu2"))
+ return 0;
- val = I210_CFGWORD_PCIID_157B;
- pwrite(fd, &val, sizeof(val), 0);
+ zii_process_lru_fixups(rdu2_lru_fixups);
return 0;
}
-late_initcall(rdu2_i210_invm);
+postmmu_initcall(rdu2_process_fixups);