Module Name:    src
Committed By:   marty
Date:           Fri Dec 11 04:12:21 UTC 2015

Modified Files:
        src/sys/arch/evbarm/exynos: exynos_machdep.c

Log Message:
EXYNOS rewrite step 3 of N: Add aliases for gpio pins

This adds the GPIO aliases that will be used for board-independent driver
lookup until we have FDT.

The idea here is that each pin used by any driver is given a name that
the driver knows that is independent of the gpio bank name.  The mapping
from the alias to the actual gpio bank + pin number is done in this file
and a lookup function is added to exynos_gpio.c that allows a driver to
ask for a gpio pin by the alias name, blisssfully unaware that there is
an underlying GPIO bank name.

Once set up with all the drivers, it should then be possible to move to a
different vendor's board simply by modifying exynos_machdep.c


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/exynos/exynos_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/evbarm/exynos/exynos_machdep.c
diff -u src/sys/arch/evbarm/exynos/exynos_machdep.c:1.1 src/sys/arch/evbarm/exynos/exynos_machdep.c:1.2
--- src/sys/arch/evbarm/exynos/exynos_machdep.c:1.1	Sun Dec  6 00:33:44 2015
+++ src/sys/arch/evbarm/exynos/exynos_machdep.c	Fri Dec 11 04:12:21 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: exynos_machdep.c,v 1.1 2015/12/06 00:33:44 marty Exp $ */
+/*	$NetBSD: exynos_machdep.c,v 1.2 2015/12/11 04:12:21 marty Exp $ */
 
 /*
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exynos_machdep.c,v 1.1 2015/12/06 00:33:44 marty Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exynos_machdep.c,v 1.2 2015/12/11 04:12:21 marty Exp $");
 
 #include "opt_evbarm_boardtype.h"
 #include "opt_exynos.h"
@@ -135,6 +135,9 @@ char *boot_file = NULL;				/* MI bootfil
 uint8_t uboot_enaddr[ETHER_ADDR_LEN] = {};
 
 
+void
+odroid_device_register(device_t self, void *aux);
+
 /*
  * kernel start and end from the linker
  */
@@ -201,6 +204,40 @@ static struct boot_physmem bp_highgig = 
 };
 #endif
 
+static struct gpio_pin_entry {
+	const char *pin_name;
+	const char *pin_user;
+} gpio_pin_entries[] = {
+	/* mux@13400000 (muxa) */
+	{ "gpx3-7", "hdmi-hpd-irq"},
+	{ "gpx3-6", "hdmi_cec" },
+	{ "gpx0-7", "dp_hpd_gpio" },
+	{ "gpx0-4", "pmic-irq" },
+	{ "gpx3-2", "audio-irq" },
+	{ "gpx3-4", "b-sess1-irq" },
+	{ "gpx3-5", "b-sess0-irq" },
+	{ "gpx1-1", "id2-irq" },
+	/* mux@134100000 (muxb) */
+	{ "gpc0-0", "sd0-clk" },
+	{ "gpc0-1", "sd0-cmd" },
+	{ "gpc0-7", "sd0-rdqs" },
+	{ "gpd1-3", "sd0-qrdy" },
+	{ "gpc0-3", "sd0-bus-width1" },
+	{ "gpc0-3", "sd0-bus-width4-bit1" },
+	{ "gpc0-4", "sd0-bus-width4-bit2" },
+	{ "gpc0-5", "sd0-bus-width4-bit3" },
+	{ "gpc0-6", "sd0-bus-width4-bit4" },
+	{ "gpc1-0", "sd1-clk" },
+	{ "gpc1-1", "sd1-cmd" },
+	{ "gpc1-3", "sd1-bus-width1" },
+	{ "gpc1-3", "sd1-bus-width4-bit1" },
+	{ "gpc1-4", "sd1-bus-width4-bit2" },
+	{ "gpc1-5", "sd1-bus-width4-bit3" },
+	{ "gpc1-6", "sd1-bus-width4-bit4" },
+	/* TODO: muxc and muxd as needed */
+	{ 0, 0}
+};
+	
 #ifdef VERBOSE_INIT_ARM
 extern void exynos_putchar(int);
 
@@ -238,6 +275,20 @@ exynos_printn(u_int n, int base)
 extern void cortex_mpstart(void);
 
 /*
+ * void init_gpio_dictionary(...)
+ *
+ * Setup the dictionary of gpio pin names for the drivers to use
+ */
+static void init_gpio_dictionary(struct gpio_pin_entry *pins,
+				 prop_dictionary_t dict)
+{
+	while (pins->pin_name) {
+		prop_dictionary_set_cstring(dict, pins->pin_user,
+					    pins->pin_name);
+		pins++;
+	}
+}
+/*
  * u_int initarm(...)
  *
  * Our entry point from the assembly before main() is called.
@@ -351,9 +402,8 @@ initarm(void *arg)
 	    mapallmem_p);
 
 	/* we've a specific device_register routine */
-	evbarm_device_register = exynos_device_register;
-	evbarm_device_register_post_config = exynos_device_register_post_config;
-
+	evbarm_device_register = odroid_device_register;
+//	evbarm_device_register_post_config = exynos_device_register_post_config;
 	/*
 	 * If we couldn't map all of memory via TTBR1, limit the memory the
 	 * kernel can allocate from to be from the highest available 1GB.
@@ -458,6 +508,16 @@ exynos_extract_mac_adress(void)
 #undef EXPECT_COLON
 }
 
+void
+odroid_device_register(device_t self, void *aux)
+{
+	prop_dictionary_t dict = device_properties(self);
+	exynos_device_register(self, aux);
+	if (device_is_a(self, "exyogpio")) {
+		init_gpio_dictionary(gpio_pin_entries, dict);
+	}
+}
+
 /*
  * Exynos specific tweaks
  */

Reply via email to