/* * SHA transform algorithm, originally taken from code written by * Peter Gutmann, and placed in the public domain. */ static uint32_t rol32(uint32_t word, int shift) { return (word << shift) | (word >> (32 - shift)); } /* The SHA f()-functions. */ #define f1(x,y,z) (z ^ (x & (y ^ z))) /* x ? y : z */ #define f2(x,y,z) (x ^ y ^ z) /* XOR */ #define f3(x,y,z) ((x & y) + (z & (x ^ y))) /* majority */ /* The SHA Mysterious Constants */ #define K1 0x5A827999L /* Rounds 0-19: sqrt(2) * 2^30 */ #define K2 0x6ED9EBA1L /* Rounds 20-39: sqrt(3) * 2^30 */ #define K3 0x8F1BBCDCL /* Rounds 40-59: sqrt(5) * 2^30 */ #define K4 0xCA62C1D6L /* Rounds 60-79: sqrt(10) * 2^30 */ /** * sha_transform - single block SHA1 transform * * @digest: 160 bit digest to update * @data: 512 bits of data to hash * @W: 80 words of workspace (see note) * * This function generates a SHA1 digest for a single 512-bit block. * Be warned, it does not handle padding and message digest, do not * confuse it with the full FIPS 180-1 digest algorithm for variable * length messages. * * Note: If the hash is security sensitive, the caller should be sure * to clear the workspace. This is left to the caller to avoid * unnecessary clears between chained hashing operations. */ static void sha_transform(uint32_t *digest, const unsigned char *in, uint32_t *W) { uint32_t a, b, c, d, e, t, i; for (i = 0; i < 16; i++) { int ofs = 4 * i; /* word load/store may be unaligned here, so use bytes instead */ W[i] = (in[ofs+0] << 24) | (in[ofs+1] << 16) | (in[ofs+2] << 8) | in[ofs+3]; } for (i = 0; i < 64; i++) W[i+16] = rol32(W[i+13] ^ W[i+8] ^ W[i+2] ^ W[i], 1); a = digest[0]; b = digest[1]; c = digest[2]; d = digest[3]; e = digest[4]; for (i = 0; i < 20; i++) { t = f1(b, c, d) + K1 + rol32(a, 5) + e + W[i]; e = d; d = c; c = rol32(b, 30); b = a; a = t; } for (; i < 40; i ++) { t = f2(b, c, d) + K2 + rol32(a, 5) + e + W[i]; e = d; d = c; c = rol32(b, 30); b = a; a = t; } for (; i < 60; i ++) { t = f3(b, c, d) + K3 + rol32(a, 5) + e + W[i]; e = d; d = c; c = rol32(b, 30); b = a; a = t; } for (; i < 80; i ++) { t = f2(b, c, d) + K4 + rol32(a, 5) + e + W[i]; e = d; d = c; c = rol32(b, 30); b = a; a = t; } digest[0] += a; digest[1] += b; digest[2] += c; digest[3] += d; digest[4] += e; } /** * sha_init - initialize the vectors for a SHA1 digest * @buf: vector to initialize */ static void sha_init(uint32_t *buf) { buf[0] = 0x67452301; buf[1] = 0xefcdab89; buf[2] = 0x98badcfe; buf[3] = 0x10325476; buf[4] = 0xc3d2e1f0; } am/log/target/linux/ramips/dts/HLKRM04.dts'>
path: root/target/linux/ramips/dts/HLKRM04.dts
blob: fb72b6bd70d76339d94fbdcef3424b031c8a60ae (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
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
/dts-v1/;

#include "rt5350.dtsi"

/ {
	compatible = "HLKRM04", "ralink,rt5350-soc";
	model = "HILINK HLK-RM04";

	memory@0 {
		device_type = "memory";
		reg = <0x0 0x1000000>;
	};

	chosen {
		bootargs = "console=ttyS1,57600";
	};

	gpio-export {
		compatible = "gpio-export";
		#size-cells = <0>;

		/* I2C */
		gpio1 {
			/* I2C_I2C_SD */
			gpio-export,name = "hlk-rm04:gpio0";
			gpio-export,direction_may_change = <1>;
			gpios = <&gpio0 1 0>;
		};
		gpio2 {
			/* I2C_I2C_SCLK */
			gpio-export,name = "hlk-rm04:gpio1";
			gpio-export,direction_may_change = <1>;
			gpios = <&gpio0 2 0>;
		};
	};

	gpio-keys-polled {
		compatible = "gpio-keys-polled";
		#address-cells = <1>;
		#size-cells = <0>;
		poll-interval = <20>;
		reset {
			label = "reset";
			gpios = <&gpio0 0 1>;
			linux,code = <0x198>;
		};
		wps {
			label = "wps";
			gpios = <&gpio0 14 1>;
			linux,code = <0x211>;
		};
	};
};

&uart {
	status = "okay";
};

&spi0 {
	status = "okay";

	m25p80@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "jedec,spi-nor";
		reg = <0 0>;
		linux,modalias = "m25p80", "s25fl064k";
		spi-max-frequency = <10000000>;

		partition@0 {
			label = "u-boot";
			reg = <0x0 0x30000>;
			read-only;
		};

		partition@30000 {
			label = "u-boot-env";
			reg = <0x30000 0x10000>;
			read-only;
		};

		factory: partition@40000 {
			label = "factory";
			reg = <0x40000 0x10000>;
			read-only;
		};

		partition@50000 {
			label = "firmware";
			reg = <0x50000 0x3b0000>;
		};
	};
};

&pinctrl {
	state_default: pinctrl0 {
		gpio {
			ralink,group = "i2c", "jtag";
			ralink,function = "gpio";
		};

		uartf_gpio {
			ralink,group = "uartf";
			ralink,function = "gpio uartf";
		};
	};
};

&ethernet {
	mtd-mac-address = <&factory 0x4>;
};

&wmac {
	ralink,mtd-eeprom = <&factory 0>;
};

&ehci {
	status = "okay";
};

&ohci {
	status = "okay";
};