-
Notifications
You must be signed in to change notification settings - Fork 5
/
emac.patch
142 lines (126 loc) · 3.52 KB
/
emac.patch
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
Index: a10_gpio.c
===================================================================
--- a10_gpio.c (revision 261702)
+++ a10_gpio.c (working copy)
@@ -52,6 +52,7 @@
#include <dev/ofw/ofw_bus_subr.h>
#include "gpio_if.h"
+#include "a10_gpio.h"
/*
* A10 have 9 banks of gpio.
@@ -102,6 +103,8 @@
#define A10_GPIO_GP_INT_STA 0x214
#define A10_GPIO_GP_INT_DEB 0x218
+static struct a10_gpio_softc *a10_gpio_sc;
+
#define A10_GPIO_WRITE(_sc, _off, _val) \
bus_space_write_4(_sc->sc_bst, _sc->sc_bsh, _off, _val)
#define A10_GPIO_READ(_sc, _off) \
@@ -473,6 +476,9 @@
device_add_child(dev, "gpioc", device_get_unit(dev));
device_add_child(dev, "gpiobus", device_get_unit(dev));
+
+ a10_gpio_sc = sc;
+
return (bus_generic_attach(dev));
fail:
@@ -518,3 +524,19 @@
};
DRIVER_MODULE(a10_gpio, simplebus, a10_gpio_driver, a10_gpio_devclass, 0, 0);
+
+int
+a10_emac_gpio_config(uint32_t pin)
+{
+ struct a10_gpio_softc *sc = a10_gpio_sc;
+
+ if (sc == NULL)
+ return (ENXIO);
+
+ /* Configure pin mux settings for MII. */
+ A10_GPIO_LOCK(sc);
+ a10_gpio_set_function(sc, pin, A10_GPIO_PULLDOWN);
+ A10_GPIO_UNLOCK(sc);
+
+ return (0);
+}
Index: a20/files.a20
===================================================================
--- a20/files.a20 (revision 261702)
+++ a20/files.a20 (working copy)
@@ -12,8 +12,10 @@
arm/allwinner/a20/a20_cpu_cfg.c standard
arm/allwinner/a10_clk.c standard
+arm/allwinner/a10_sramc.c standard
arm/allwinner/a10_gpio.c optional gpio
arm/allwinner/a10_ehci.c optional ehci
+arm/allwinner/if_emac.c optional emac
arm/allwinner/a10_wdog.c standard
arm/allwinner/timer.c standard
arm/arm/bus_space-v6.c standard
Index: files.a10
===================================================================
--- files.a10 (revision 261702)
+++ files.a10 (working copy)
@@ -11,8 +11,10 @@
arm/allwinner/a20/a20_cpu_cfg.c standard
arm/allwinner/a10_clk.c standard
+arm/allwinner/a10_sramc.c standard
arm/allwinner/a10_gpio.c optional gpio
arm/allwinner/a10_ehci.c optional ehci
+arm/allwinner/if_emac.c optional emac
arm/allwinner/a10_wdog.c standard
arm/allwinner/timer.c standard
arm/allwinner/aintc.c standard
Index: a10_clk.c
===================================================================
--- a10_clk.c (revision 261702)
+++ a10_clk.c (working copy)
@@ -127,7 +127,7 @@
uint32_t reg_value;
if (sc == NULL)
- return ENXIO;
+ return (ENXIO);
/* Gating AHB clock for USB */
reg_value = ccm_read_4(sc, CCM_AHB_GATING0);
@@ -154,7 +154,7 @@
uint32_t reg_value;
if (sc == NULL)
- return ENXIO;
+ return (ENXIO);
/* Disable clock for USB */
reg_value = ccm_read_4(sc, CCM_USB_CLK);
@@ -173,3 +173,19 @@
return (0);
}
+int
+a10_clk_emac_activate(void) {
+ struct a10_ccm_softc *sc = a10_ccm_sc;
+ uint32_t reg_value;
+
+ if (sc == NULL)
+ return (ENXIO);
+
+ /* Gating AHB clock for EMAC */
+ reg_value = ccm_read_4(sc, CCM_AHB_GATING0);
+ reg_value |= CCM_AHB_GATING_EMAC;
+ ccm_write_4(sc, CCM_AHB_GATING0, reg_value);
+
+ return (0);
+}
+
Index: a10_clk.h
===================================================================
--- a10_clk.h (revision 261702)
+++ a10_clk.h (working copy)
@@ -103,6 +103,7 @@
#define CCM_AHB_GATING_USB0 (1 << 0)
#define CCM_AHB_GATING_EHCI0 (1 << 1)
#define CCM_AHB_GATING_EHCI1 (1 << 3)
+#define CCM_AHB_GATING_EMAC (1 << 17)
#define CCM_USB_PHY (1 << 8)
#define CCM_USB0_RESET (1 << 0)
@@ -111,5 +112,6 @@
int a10_clk_usb_activate(void);
int a10_clk_usb_deactivate(void);
+int a10_clk_emac_activate(void);
#endif /* _A10_CLK_H_ */