aboutsummaryrefslogtreecommitdiffstats
path: root/main/linux-octeon/ubnt-e200-sdio-underclock.patch
blob: 423917ac52e7cb65add25fef3a4457dae7c88e17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Underclock the SDIO bus on E200 devices.

Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
Upstream-status: Not yet submitted

--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -760,6 +760,28 @@
 	}
 }
 
+int __init alpine_prune_device_tree(void)
+{
+	if (fdt_check_header(initial_boot_params))
+		panic("Corrupt Device Tree.");
+
+	/* UBNT underclocks the SDIO bus on E200.  We do the same here. */
+	if (octeon_bootinfo->board_type == CVMX_BOARD_TYPE_UBNT_E200 || octeon_bootinfo->board_type == CVMX_BOARD_TYPE_UBNT_E220) {
+		int mmc_slot0;
+		u32 freq = 26000000;
+
+		pr_info("UBNT E200 board detected, underclocking SDIO bus.\n");
+
+		mmc_slot0 = fdt_path_offset(initial_boot_params, "/soc/mmc/mmc-slot@0");
+		if (mmc_slot0 > 0) {
+			fdt_setprop_inplace_cell(initial_boot_params, mmc_slot0,
+				"spi-max-frequency", freq);
+		}
+	}
+
+	return 0;
+}
+
 int __init octeon_prune_device_tree(void)
 {
 	int i, max_port, uart_mask;
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -1184,6 +1184,7 @@
 }
 
 void __init octeon_fill_mac_addresses(void);
+int alpine_prune_device_tree(void);
 
 void __init device_tree_init(void)
 {
@@ -1219,6 +1220,9 @@
 		octeon_prune_device_tree();
 		pr_info("Using internal Device Tree.\n");
 	}
+
+	alpine_prune_device_tree();
+
 	if (fill_mac)
 		octeon_fill_mac_addresses();
 	unflatten_and_copy_device_tree();
--- a/arch/mips/include/asm/octeon/cvmx-bootinfo.h
+++ b/arch/mips/include/asm/octeon/cvmx-bootinfo.h
@@ -295,6 +295,9 @@
 	 */
 	CVMX_BOARD_TYPE_CUST_PRIVATE_MIN = 20001,
 	CVMX_BOARD_TYPE_UBNT_E100 = 20002,
+	CVMX_BOARD_TYPE_UBNT_E200 = 20003,
+	CVMX_BOARD_TYPE_UBNT_E120 = 20004,
+	CVMX_BOARD_TYPE_UBNT_E220 = 20005,
 	CVMX_BOARD_TYPE_CUST_DSR1000N = 20006,
 	CVMX_BOARD_TYPE_KONTRON_S1901 = 21901,
 	CVMX_BOARD_TYPE_CUST_PRIVATE_MAX = 30000,
@@ -396,6 +399,9 @@
 		    /* Customer private range */
 		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MIN)
 		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_UBNT_E100)
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_UBNT_E200)
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_UBNT_E120)
+		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_UBNT_E220)
 		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DSR1000N)
 		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_KONTRON_S1901)
 		ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MAX)