-
Notifications
You must be signed in to change notification settings - Fork 9
/
patch-3.2-nsa310.diff
1511 lines (1501 loc) · 40.2 KB
/
patch-3.2-nsa310.diff
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff -uNr linux-3.2/arch/arm/mach-kirkwood/Kconfig linux-3.2-my/arch/arm/mach-kirkwood/Kconfig
--- linux-3.2/arch/arm/mach-kirkwood/Kconfig 2012-01-05 00:55:44.000000000 +0100
+++ linux-3.2-my/arch/arm/mach-kirkwood/Kconfig 2012-01-07 15:50:31.232388937 +0100
@@ -130,6 +130,18 @@
Say 'Y' here if you want your kernel to support the
HP t5325 Thin Client.
+config MACH_NSA310
+ bool "Zyxel NSA-310"
+ help
+ Say 'Y' here if you want your kernel to support the
+ Zyxel NSA-310 NAS.
+
+config MACH_NSA320
+ bool "Zyxel NSA-320"
+ help
+ Say 'Y' here if you want your kernel to support the
+ Zyxel NSA-320 NAS.
+
endmenu
endif
diff -uNr linux-3.2/arch/arm/mach-kirkwood/Makefile linux-3.2-my/arch/arm/mach-kirkwood/Makefile
--- linux-3.2/arch/arm/mach-kirkwood/Makefile 2012-01-05 00:55:44.000000000 +0100
+++ linux-3.2-my/arch/arm/mach-kirkwood/Makefile 2012-01-07 15:49:31.820389507 +0100
@@ -18,5 +18,7 @@
obj-$(CONFIG_MACH_NET2BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
obj-$(CONFIG_MACH_T5325) += t5325-setup.o
+obj-$(CONFIG_MACH_NSA320) += nsa320-setup.o mcu.o
+obj-$(CONFIG_MACH_NSA310) += nsa310-setup.o mcu.o
obj-$(CONFIG_CPU_IDLE) += cpuidle.o
diff -uNr linux-3.2/arch/arm/mach-kirkwood/mcu.c linux-3.2-my/arch/arm/mach-kirkwood/mcu.c
--- linux-3.2/arch/arm/mach-kirkwood/mcu.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.2-my/arch/arm/mach-kirkwood/mcu.c 2012-01-06 22:03:46.608896063 +0100
@@ -0,0 +1,125 @@
+#include <linux/module.h>
+#include <linux/init.h>
+#include <asm/irq.h>
+#include <asm/delay.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/workqueue.h>
+#include <linux/timer.h>
+#include <linux/syscalls.h>
+#include <linux/kmod.h>
+#include <linux/syscalls.h>
+#include <linux/fs.h>
+#include <asm/fcntl.h>
+#include <asm/hardirq.h>
+#include <linux/ioctl.h>
+#include <linux/cdev.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <asm/io.h>
+#include <linux/spinlock.h>
+#include <mach/hardware.h>
+#include <asm/uaccess.h>
+#include <linux/syscalls.h>
+#include <asm/atomic.h>
+#include <linux/proc_fs.h>
+#include <asm/uaccess.h>
+#include <linux/kernel.h>
+
+#include <mach/kirkwood.h>
+#include <plat/gpio.h>
+#include <linux/gpio.h>
+#include "common.h"
+#include "mpp.h"
+
+
+
+#define MCU_DATA_PIN 14
+#define MCU_CLK_PIN 16
+#define MCU_ACT_PIN 17
+
+MODULE_LICENSE("GPL v2");
+#define MODULE_NAME "mcu"
+
+unsigned long mcu_data = 0;
+unsigned long mcu_counter = 0;
+
+static struct proc_dir_entry *mcu_proc;
+
+static int mcu_status_read_fn(char *buf, char **start, off_t offset,
+ int count, int *eof, void *data)
+{
+ unsigned long len, i;
+
+ mcu_data = 0;
+
+ gpio_request(14, "MCU_DATA");
+ gpio_request(16, "MCU_CLK");
+ gpio_request(17, "MCU_ACT");
+
+ gpio_direction_output(MCU_ACT_PIN, 0);
+ msleep(100);
+ gpio_direction_input(MCU_DATA_PIN);
+ gpio_direction_output(MCU_CLK_PIN, 0);
+ udelay(100);
+
+ for(i = 0 ; i < 32 ; i++)
+ {
+ mcu_data <<= 1;
+ gpio_set_value(MCU_CLK_PIN,1);
+
+ mcu_data |= gpio_get_value(MCU_DATA_PIN)?0x1:0;
+
+ udelay(100);
+
+ gpio_set_value(MCU_CLK_PIN,0);
+
+ udelay(100);
+ }
+
+
+ gpio_set_value(MCU_CLK_PIN,1);
+ gpio_set_value(MCU_ACT_PIN,1);
+
+
+ gpio_free(14);
+ gpio_free(16);
+ gpio_free(17);
+
+ len = sprintf(buf, "MagicNum:%u\nRpss:%u\nTemperature:%u\n",(unsigned int)((mcu_data & 0xff000000) >> 24),
+ (unsigned int)((mcu_data & 0xff0000) >> 16),
+ (unsigned int)((mcu_data & 0xffff)));
+ *eof = 1;
+
+ return len;
+}
+
+static int mcu_status_write_fn(struct file *file, const char __user *buffer,
+ unsigned long count, void *data)
+{
+ return 0;
+}
+
+
+static int __init mcu_init(void)
+{
+
+ mcu_proc = create_proc_entry("mcu", 0644, NULL);
+ if(mcu_proc != NULL)
+ {
+ mcu_proc->read_proc = mcu_status_read_fn;
+ mcu_proc->write_proc = mcu_status_write_fn;
+ }
+
+ return 0;
+}
+
+static void __exit mcu_exit(void)
+{
+ remove_proc_entry("mcu", NULL);
+
+}
+
+module_init(mcu_init);
+module_exit(mcu_exit);
+
diff -uNr linux-3.2/arch/arm/mach-kirkwood/nsa310-setup.c linux-3.2-my/arch/arm/mach-kirkwood/nsa310-setup.c
--- linux-3.2/arch/arm/mach-kirkwood/nsa310-setup.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.2-my/arch/arm/mach-kirkwood/nsa310-setup.c 2012-05-17 13:48:24.225461188 +0200
@@ -0,0 +1,343 @@
+ /*
+ * Zyxel NSA-310 Setup, by AA666 and Peeter123
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/i2c.h>
+#include <linux/irq.h>
+#include <linux/mtd/partitions.h>
+#include <mtd/mtd-abi.h>
+#include <linux/ata_platform.h>
+#include <linux/mv643xx_i2c.h>
+#include <linux/ethtool.h>
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
+#include <linux/leds.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <mach/kirkwood.h>
+#include <plat/mvsdio.h>
+#include "common.h"
+#include "mpp.h"
+#include <linux/timer.h>
+#include <linux/jiffies.h>
+
+static void nsa310_timerfunc(unsigned long data);
+static DEFINE_TIMER(timer, nsa310_timerfunc, 0, 0);
+
+static struct mtd_partition nsa310_nand_parts[] = {
+ {
+ .name = "uboot",
+ .offset = 0,
+ .size = 0x100000,
+ .mask_flags = MTD_WRITEABLE
+ }, {
+ .name = "uboot_env",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0x80000
+ }, {
+ .name = "key_store",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0x80000
+ }, {
+ .name = "info",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0x80000
+ }, {
+ .name = "etc",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0xA00000
+ }, {
+ .name = "kernel_1",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0xA00000
+ }, {
+ .name = "rootfs1",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0x2FC0000
+ }, {
+ .name = "kernel_2",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0xA00000
+ }, {
+ .name = "rootfs2",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0x2FC0000
+ },
+};
+
+static struct mv_sata_platform_data nsa310_sata_data = {
+ .n_ports = 2,
+};
+
+static unsigned int nsa310_mpp_config[] __initdata = {
+ MPP36_GPIO, // Reset button
+ MPP37_GPIO, // Copy button
+ MPP46_GPIO, // Power button
+
+ MPP48_GPIO, // Power Off
+ MPP21_GPIO, // USB Power Off
+
+ MPP28_GPIO, // Sys LED Green
+ MPP29_GPIO, // Sys LED Yellow
+ MPP41_GPIO, // SATA1 LED Green
+ MPP42_GPIO, // SATA1 LED Red
+ MPP12_GPO, // SATA2 LED Green
+ MPP13_GPIO, // SATA2 LED Red
+ MPP39_GPIO, // Copy LED Green
+ MPP40_GPIO, // Copy LED Red
+ MPP15_GPIO, // USB LED Green
+
+ MPP14_GPIO, // MCU Data
+ MPP16_GPIO, // MCU Clk
+ MPP17_GPIO, // MCU Act
+
+ MPP38_GPIO, // VID B0
+ MPP45_GPIO, // VID B1
+
+ MPP44_GPIO, // Buzzer
+ MPP43_GPIO, // HTP
+
+ MPP47_GPIO, // Power Resume Data
+ MPP49_GPIO, // Power Resume Clock
+
+ 0
+};
+
+static struct gpio_led nsa310_gpio_led[] = {
+ {
+ .name = "nsa310:green:System",
+ .default_trigger = "timer",
+ .gpio = 28,
+ .active_low = 0,
+
+ },
+ {
+ .name = "nsa310:red:System",
+ .default_trigger = "none",
+ .gpio = 29,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa310:green:SATA1",
+ .default_trigger = "none",
+ .gpio = 41,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa310:red:SATA1",
+ .default_trigger = "sata-disk",
+ .gpio = 42,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa310:green:SATA2",
+ .default_trigger = "none",
+ .gpio = 12,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa310:red:SATA2",
+ .default_trigger = "none",
+ .gpio = 13,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa310:green:USB",
+ .default_trigger = "none",
+ .gpio = 15,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa310:green:Copy",
+ .default_trigger = "none",
+ .gpio = 39,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa310:red:Copy",
+ .default_trigger = "none",
+ .gpio = 40,
+ .active_low = 0,
+ },
+};
+
+
+static int nsa310_gpio_blink_set(unsigned gpio, int state,
+ unsigned long *delay_on, unsigned long *delay_off)
+{
+
+// Use hardware acceleration
+// if (delay_on && delay_off && !*delay_on && !*delay_off)
+// *delay_on = *delay_off = 100;
+
+ switch(state) {
+ case GPIO_LED_NO_BLINK_LOW:
+ case GPIO_LED_NO_BLINK_HIGH:
+ orion_gpio_set_blink(gpio, 0);
+ gpio_set_value(gpio, state);
+ break;
+ case GPIO_LED_BLINK:
+ orion_gpio_set_blink(gpio, 1);
+ break;
+ }
+ return 0;
+}
+
+
+static struct gpio_led_platform_data nsa310_led_data = {
+ .leds = nsa310_gpio_led,
+ .num_leds = ARRAY_SIZE(nsa310_gpio_led),
+ .gpio_blink_set = nsa310_gpio_blink_set,
+};
+
+static struct platform_device nsa310_leds = {
+ .name = "leds-gpio",
+ .id = -1,
+ .dev = { .platform_data = &nsa310_led_data, }
+};
+
+static struct gpio_keys_button nsa310_gpio_keys_button[] = {
+ {
+ .code = KEY_POWER,
+ .type = EV_KEY,
+ .gpio = 46,
+ .desc = "Power Button",
+ .active_low = 0,
+ .debounce_interval = 1000,
+ },
+ {
+ .code = KEY_COPY,
+ .type = EV_KEY,
+ .gpio = 37,
+ .desc = "USB Copy",
+ .active_low = 1,
+ .debounce_interval = 1000,
+ },
+ {
+ .code = KEY_OPTION,
+ .type = EV_KEY,
+ .gpio = 36,
+ .desc = "Reset",
+ .active_low = 1,
+ .debounce_interval = 1000,
+ },
+};
+
+static struct gpio_keys_platform_data nsa310_keys_data = {
+ .buttons = nsa310_gpio_keys_button,
+ .nbuttons = ARRAY_SIZE(nsa310_gpio_keys_button),
+};
+
+
+static struct platform_device nsa310_buttons = {
+ .name = "gpio-keys",
+ .id = -1,
+ .dev = { .platform_data = &nsa310_keys_data, }
+};
+
+static void nsa310_power_off(void)
+{
+//
+//don't work with sysfs
+ printk(KERN_INFO "NSA310: Activating power off GPIO pin...\n");
+ gpio_set_value(48, 1);
+
+// If machine goes to restart, uncomment next lines for infinite loop
+/* printk(KERN_INFO "System halted, please turn off power manually\n");
+ gpio_set_value(28, 0);
+ do {
+ mdelay(1000);
+ } while(1);
+*/
+}
+
+static void nsa310_timerfunc(unsigned long data)
+{
+// Activate USB Power
+ if (gpio_request(21, "USB Power") != 0 || gpio_direction_output(21, 1) != 0)
+ printk(KERN_ERR "NSA310: Failed to setup USB power GPIO\n");
+ else
+ printk(KERN_INFO "NSA310: USB power enabled\n");
+ gpio_free(21);
+}
+
+static void __init nsa310_init(void)
+{
+ u32 dev, rev;
+
+ kirkwood_init();
+
+ kirkwood_mpp_conf(nsa310_mpp_config);
+ kirkwood_nand_init(ARRAY_AND_SIZE(nsa310_nand_parts), 40);
+ kirkwood_pcie_id(&dev, &rev);
+
+ kirkwood_sata_init(&nsa310_sata_data);
+ kirkwood_uart0_init();
+ kirkwood_i2c_init();
+
+ platform_device_register(&nsa310_leds);
+ platform_device_register(&nsa310_buttons);
+
+ kirkwood_ehci_init();
+// USB Power delay for 20 sec
+ timer.function = nsa310_timerfunc;
+ timer.data = 0;
+ timer.expires = jiffies + msecs_to_jiffies(20000);
+ add_timer(&timer);
+
+
+/* Power resume control */
+ gpio_request(49, "Power-clk");
+ gpio_direction_output(49, 1);
+ gpio_request(47, "Power-data");
+// Clear power resume
+// gpio_direction_output(47, 0);
+// Set power resume
+ gpio_direction_output(47, 1);
+ udelay(1000);
+// gpio_direction_output(49, 0);
+ gpio_set_value(49, 0);
+// release GPIO?
+//test
+ gpio_free(47);
+ gpio_free(49);
+ printk(KERN_INFO "NSA310: Power resume enabled\n");
+
+
+// Activate Power-off GPIO
+ if (gpio_request(48, "Power-off") == 0 && gpio_direction_output(48, 0) == 0) {
+// gpio_free(48);
+ pm_power_off = nsa310_power_off;
+ printk(KERN_INFO "NSA310: Power-off GPIO enabled\n");
+ } else
+ printk(KERN_ERR "NSA310: Failed to configure Power-off GPIO\n");
+
+};
+
+static int __init nsa310_pci_init(void)
+{
+ if (machine_is_nsa310())
+ kirkwood_pcie_init(KW_PCIE0);
+ return 0;
+}
+
+subsys_initcall(nsa310_pci_init);
+
+MACHINE_START(NSA310, "Zyxel NSA-310")
+ .atag_offset = 0x100,
+ .init_machine = nsa310_init,
+ .map_io = kirkwood_map_io,
+ .init_early = kirkwood_init_early,
+ .init_irq = kirkwood_init_irq,
+ .timer = &kirkwood_timer,
+MACHINE_END
+
diff -uNr linux-3.2/arch/arm/mach-kirkwood/nsa320-setup.c linux-3.2-my/arch/arm/mach-kirkwood/nsa320-setup.c
--- linux-3.2/arch/arm/mach-kirkwood/nsa320-setup.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.2-my/arch/arm/mach-kirkwood/nsa320-setup.c 2012-05-17 13:49:54.645637825 +0200
@@ -0,0 +1,356 @@
+/*
+ * arch/arm/mach-kirkwood/nsa320-setup.c
+ *
+ * Zyxel NSA-320 Setup, by AA666
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/i2c.h>
+#include <linux/irq.h>
+#include <linux/mtd/partitions.h>
+#include <mtd/mtd-abi.h>
+#include <linux/ata_platform.h>
+#include <linux/mv643xx_eth.h>
+#include <linux/mv643xx_i2c.h>
+#include <linux/ethtool.h>
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
+#include <linux/leds.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <mach/kirkwood.h>
+#include <plat/mvsdio.h>
+#include "common.h"
+#include "mpp.h"
+#include <linux/timer.h>
+#include <linux/jiffies.h>
+
+static void nsa320_timerfunc(unsigned long data);
+static DEFINE_TIMER(timer, nsa320_timerfunc, 0, 0);
+
+static struct mtd_partition nsa320_nand_parts[] = {
+ {
+ .name = "uboot",
+ .offset = 0,
+ .size = 0x100000,
+ .mask_flags = MTD_WRITEABLE
+ }, {
+ .name = "uboot_env",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0x80000
+ }, {
+ .name = "key_store",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0x80000
+ }, {
+ .name = "info",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0x80000
+ }, {
+ .name = "etc",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0xA00000
+ }, {
+ .name = "kernel_1",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0xA00000
+ }, {
+ .name = "rootfs1",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0x2FC0000
+ }, {
+ .name = "kernel_2",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0xA00000
+ }, {
+ .name = "rootfs2",
+ .offset = MTDPART_OFS_NXTBLK,
+ .size = 0x2FC0000
+ },
+};
+
+static struct i2c_board_info __initdata nsa320_i2c_rtc = {
+ I2C_BOARD_INFO("pcf8563", 0x51),
+};
+
+static struct mv643xx_eth_platform_data nsa320_ge00_data = {
+ .phy_addr = MV643XX_ETH_PHY_ADDR(0),
+ .speed = SPEED_1000,
+ .duplex = DUPLEX_FULL,
+};
+
+static struct mv_sata_platform_data nsa320_sata_data = {
+ .n_ports = 2,
+};
+
+static unsigned int nsa320_mpp_config[] __initdata = {
+ MPP36_GPIO, // Reset button
+ MPP37_GPIO, // Copy button
+ MPP46_GPIO, // Power button
+
+ MPP48_GPIO, // Power Off
+ MPP21_GPIO, // USB Power Off
+
+ MPP28_GPIO, // Sys LED Green
+ MPP29_GPIO, // Sys LED Yellow
+ MPP41_GPIO, // SATA1 LED Green
+ MPP42_GPIO, // SATA1 LED Red
+ MPP12_GPO, // SATA2 LED Green
+ MPP13_GPIO, // SATA2 LED Red
+ MPP39_GPIO, // Copy LED Green
+ MPP40_GPIO, // Copy LED Red
+ MPP15_GPIO, // USB LED Green
+
+ MPP14_GPIO, // MCU Data
+ MPP16_GPIO, // MCU Clk
+ MPP17_GPIO, // MCU Act
+
+ MPP38_GPIO, // VID B0
+ MPP45_GPIO, // VID B1
+
+ MPP44_GPIO, // Buzzer
+ MPP43_GPIO, // HTP
+
+ MPP47_GPIO, // Power Resume Data
+ MPP49_GPIO, // Power Resume Clock
+
+ 0
+};
+
+static struct gpio_led nsa320_gpio_led[] = {
+ {
+ .name = "nsa320:green:System",
+ .default_trigger = "timer",
+ .gpio = 28,
+ .active_low = 0,
+
+ },
+ {
+ .name = "nsa320:red:System",
+ .default_trigger = "none",
+ .gpio = 29,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa320:green:SATA1",
+ .default_trigger = "none",
+ .gpio = 41,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa320:red:SATA1",
+ .default_trigger = "sata-disk",
+ .gpio = 42,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa320:green:SATA2",
+ .default_trigger = "none",
+ .gpio = 12,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa320:red:SATA2",
+ .default_trigger = "none",
+ .gpio = 13,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa320:green:USB",
+ .default_trigger = "none",
+ .gpio = 15,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa320:green:Copy",
+ .default_trigger = "none",
+ .gpio = 39,
+ .active_low = 0,
+ },
+ {
+ .name = "nsa320:red:Copy",
+ .default_trigger = "none",
+ .gpio = 40,
+ .active_low = 0,
+ },
+};
+
+
+static int nsa320_gpio_blink_set(unsigned gpio, int state,
+ unsigned long *delay_on, unsigned long *delay_off)
+{
+
+// Use hardware acceleration
+// if (delay_on && delay_off && !*delay_on && !*delay_off)
+// *delay_on = *delay_off = 100;
+
+ switch(state) {
+ case GPIO_LED_NO_BLINK_LOW:
+ case GPIO_LED_NO_BLINK_HIGH:
+ orion_gpio_set_blink(gpio, 0);
+ gpio_set_value(gpio, state);
+ break;
+ case GPIO_LED_BLINK:
+ orion_gpio_set_blink(gpio, 1);
+ break;
+ }
+ return 0;
+}
+
+
+static struct gpio_led_platform_data nsa320_led_data = {
+ .leds = nsa320_gpio_led,
+ .num_leds = ARRAY_SIZE(nsa320_gpio_led),
+ .gpio_blink_set = nsa320_gpio_blink_set,
+};
+
+static struct platform_device nsa320_leds = {
+ .name = "leds-gpio",
+ .id = -1,
+ .dev = { .platform_data = &nsa320_led_data, }
+};
+
+static struct gpio_keys_button nsa320_gpio_keys_button[] = {
+ {
+ .code = KEY_POWER,
+ .type = EV_KEY,
+ .gpio = 46,
+ .desc = "Power Button",
+ .active_low = 0,
+ .debounce_interval = 1000,
+ },
+ {
+ .code = KEY_COPY,
+ .type = EV_KEY,
+ .gpio = 37,
+ .desc = "USB Copy",
+ .active_low = 1,
+ .debounce_interval = 1000,
+ },
+ {
+ .code = KEY_OPTION,
+ .type = EV_KEY,
+ .gpio = 36,
+ .desc = "Reset",
+ .active_low = 1,
+ .debounce_interval = 1000,
+ },
+};
+
+static struct gpio_keys_platform_data nsa320_keys_data = {
+ .buttons = nsa320_gpio_keys_button,
+ .nbuttons = ARRAY_SIZE(nsa320_gpio_keys_button),
+};
+
+static struct platform_device nsa320_buttons = {
+ .name = "gpio-keys",
+ .id = -1,
+ .dev = { .platform_data = &nsa320_keys_data, }
+};
+
+static void nsa320_power_off(void)
+{
+//
+//don't work with sysfs
+ printk(KERN_INFO "NSA320: Activating power off GPIO pin...\n");
+ gpio_set_value(48, 1);
+
+// If machine goes to restart, uncomment next lines for infinite loop
+/* printk(KERN_INFO "System halted, please turn off power manually\n");
+ gpio_set_value(28, 0);
+ do {
+ mdelay(1000);
+ } while(1);
+*/
+}
+
+static void nsa320_timerfunc(unsigned long data)
+{
+// Activate USB Power
+ if (gpio_request(21, "USB Power") != 0 || gpio_direction_output(21, 1) != 0)
+ printk(KERN_ERR "NSA320: Failed to setup USB power GPIO\n");
+ else
+ printk(KERN_INFO "NSA320: USB power enabled\n");
+ gpio_free(21);
+}
+
+static void __init nsa320_init(void)
+{
+ u32 dev, rev;
+
+ kirkwood_init();
+
+ kirkwood_mpp_conf(nsa320_mpp_config);
+ kirkwood_nand_init(ARRAY_AND_SIZE(nsa320_nand_parts), 40);
+ kirkwood_ge00_init(&nsa320_ge00_data);
+ kirkwood_pcie_id(&dev, &rev);
+
+ kirkwood_sata_init(&nsa320_sata_data);
+ kirkwood_uart0_init();
+ kirkwood_i2c_init();
+ i2c_register_board_info(0, &nsa320_i2c_rtc, 1);
+
+ platform_device_register(&nsa320_leds);
+ platform_device_register(&nsa320_buttons);
+
+ kirkwood_ehci_init();
+// USB Power delay for 20 sec
+ timer.function = nsa320_timerfunc;
+ timer.data = 0;
+ timer.expires = jiffies + msecs_to_jiffies(20000);
+ add_timer(&timer);
+
+
+/* Power resume control */
+ gpio_request(49, "Power-clk");
+ gpio_direction_output(49, 1);
+ gpio_request(47, "Power-data");
+// Clear power resume
+// gpio_direction_output(47, 0);
+// Set power resume
+ gpio_direction_output(47, 1);
+ udelay(1000);
+// gpio_direction_output(49, 0);
+ gpio_set_value(49, 0);
+// release GPIO?
+//test
+ gpio_free(47);
+ gpio_free(49);
+ printk(KERN_INFO "NSA320: Power resume enabled\n");
+
+
+// Activate Power-off GPIO
+ if (gpio_request(48, "Power-off") == 0 && gpio_direction_output(48, 0) == 0) {
+// gpio_free(48);
+ pm_power_off = nsa320_power_off;
+ printk(KERN_INFO "NSA320: Power-off GPIO enabled\n");
+ } else
+ printk(KERN_ERR "failed to configure Power-off GPIO\n");
+
+};
+
+static int __init nsa320_pci_init(void)
+{
+ if (machine_is_nsa320())
+ kirkwood_pcie_init(KW_PCIE0);
+ return 0;
+}
+
+subsys_initcall(nsa320_pci_init);
+
+MACHINE_START(NSA320, "Zyxel NSA-320")
+ .atag_offset = 0x100,
+ .init_machine = nsa320_init,
+ .map_io = kirkwood_map_io,
+ .init_early = kirkwood_init_early,
+ .init_irq = kirkwood_init_irq,
+ .timer = &kirkwood_timer,
+MACHINE_END
diff -uNr linux-3.2/drivers/ata/sata_mv.c linux-3.2-my/drivers/ata/sata_mv.c
--- linux-3.2/drivers/ata/sata_mv.c 2012-01-05 00:55:44.000000000 +0100
+++ linux-3.2-my/drivers/ata/sata_mv.c 2012-01-07 00:23:33.616815976 +0100
@@ -69,6 +69,7 @@
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include <linux/libata.h>
+#include <linux/leds.h>
#define DRV_NAME "sata_mv"
#define DRV_VERSION "1.28"
@@ -1152,6 +1153,8 @@
{
int want_ncq = (protocol == ATA_PROT_NCQ);
+ ledtrig_sata_activity();
+
if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) {
int using_ncq = ((pp->pp_flags & MV_PP_FLAG_NCQ_EN) != 0);
if (want_ncq != using_ncq)
diff -uNr linux-3.2/drivers/leds/Kconfig linux-3.2-my/drivers/leds/Kconfig
--- linux-3.2/drivers/leds/Kconfig 2012-01-05 00:55:44.000000000 +0100
+++ linux-3.2-my/drivers/leds/Kconfig 2012-01-07 14:10:16.951694575 +0100
@@ -413,6 +413,14 @@
depends on IDE_GD_ATA
depends on LEDS_TRIGGERS
help
+ This allows LEDs to be controlled by SATA disk activity.
+ If unsure, say Y.
+
+config LEDS_TRIGGER_SATA_DISK
+ bool "LED SATA Disk Trigger"
+ depends on ATA
+ depends on LEDS_TRIGGERS
+ help
This allows LEDs to be controlled by IDE disk activity.
If unsure, say Y.
@@ -454,6 +462,13 @@
This allows LEDs to be initialised in the ON state.
If unsure, say Y.
+config LEDS_TRIGGER_NETDEV
+ tristate "LED Netdev Trigger"
+ depends on LEDS_TRIGGERS
+ help
+ This allows LEDs to be controlled by network device activity.
+ If unsure, say Y.
+
comment "iptables trigger is under Netfilter config (LED target)"
depends on LEDS_TRIGGERS
diff -uNr linux-3.2/drivers/leds/ledtrig-netdev.c linux-3.2-my/drivers/leds/ledtrig-netdev.c
--- linux-3.2/drivers/leds/ledtrig-netdev.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-3.2-my/drivers/leds/ledtrig-netdev.c 2012-01-07 14:18:29.203689950 +0100
@@ -0,0 +1,463 @@
+/*
+ * LED Kernel Netdev Trigger
+ *
+ * Toggles the LED to reflect the link and traffic state of a named net device
+ *
+ * Copyright 2007 Oliver Jowett <[email protected]>
+ *
+ * Derived from ledtrig-timer.c which is:
+ * Copyright 2005-2006 Openedhand Ltd.
+ * Author: Richard Purdie <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/jiffies.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/device.h>
+#include <linux/sysdev.h>
+#include <linux/netdevice.h>
+#include <linux/timer.h>
+#include <linux/ctype.h>
+#include <linux/leds.h>
+#include <linux/version.h>
+#include <net/net_namespace.h>
+
+#include "leds.h"
+
+/*
+ * Configurable sysfs attributes:
+ *
+ * device_name - network device name to monitor
+ *
+ * interval - duration of LED blink, in milliseconds
+ *
+ * mode - either "none" (LED is off) or a space separated list
+ * of one or more of:
+ * link: LED's normal state reflects whether the link is up (has carrier)
+ * or not
+ * tx: LED blinks on transmitted data
+ * rx: LED blinks on receive data
+ *
+ * Some suggestions:
+ *
+ * Simple link status LED:
+ * $ echo netdev >someled/trigger
+ * $ echo eth0 >someled/device_name
+ * $ echo link >someled/mode
+ *
+ * Ethernet-style link/activity LED:
+ * $ echo netdev >someled/trigger
+ * $ echo eth0 >someled/device_name
+ * $ echo "link tx rx" >someled/mode
+ *
+ * Modem-style tx/rx LEDs:
+ * $ echo netdev >led1/trigger
+ * $ echo ppp0 >led1/device_name
+ * $ echo tx >led1/mode
+ * $ echo netdev >led2/trigger
+ * $ echo ppp0 >led2/device_name
+ * $ echo rx >led2/mode
+ *
+ */
+
+#define MODE_LINK 1
+#define MODE_TX 2
+#define MODE_RX 4
+