Guest User

nsa3x0.patch v5.2

a guest
Feb 25th, 2012
622
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff -Nur a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
  2. --- a/arch/arm/mach-kirkwood/Kconfig 2012-02-09 04:21:53.000000000 +0100
  3. +++ b/arch/arm/mach-kirkwood/Kconfig 2012-02-25 23:08:39.180034382 +0100
  4. @@ -130,6 +130,18 @@
  5. Say 'Y' here if you want your kernel to support the
  6. HP t5325 Thin Client.
  7.  
  8. +config MACH_NSA310
  9. + bool "Zyxel NSA-310"
  10. + help
  11. + Say 'Y' here if you want your kernel to support the
  12. + Zyxel NSA-310 NAS.
  13. +
  14. +config MACH_NSA320
  15. + bool "Zyxel NSA-320"
  16. + help
  17. + Say 'Y' here if you want your kernel to support the
  18. + Zyxel NSA-320 NAS.
  19. +
  20. endmenu
  21.  
  22. endif
  23. diff -Nur a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile
  24. --- a/arch/arm/mach-kirkwood/Makefile 2012-02-09 04:21:53.000000000 +0100
  25. +++ b/arch/arm/mach-kirkwood/Makefile 2012-02-25 23:08:39.184034382 +0100
  26. @@ -18,5 +18,7 @@
  27. obj-$(CONFIG_MACH_NET2BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
  28. obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
  29. obj-$(CONFIG_MACH_T5325) += t5325-setup.o
  30. +obj-$(CONFIG_MACH_NSA310) += nsa310-setup.o
  31. +obj-$(CONFIG_MACH_NSA320) += nsa320-setup.o mcu.o
  32.  
  33. obj-$(CONFIG_CPU_IDLE) += cpuidle.o
  34. diff -Nur a/arch/arm/mach-kirkwood/mcu.c b/arch/arm/mach-kirkwood/mcu.c
  35. --- a/arch/arm/mach-kirkwood/mcu.c 1970-01-01 01:00:00.000000000 +0100
  36. +++ b/arch/arm/mach-kirkwood/mcu.c 2012-02-25 23:08:39.564034385 +0100
  37. @@ -0,0 +1,125 @@
  38. +#include <linux/module.h>
  39. +#include <linux/init.h>
  40. +#include <asm/irq.h>
  41. +#include <asm/delay.h>
  42. +#include <linux/delay.h>
  43. +#include <linux/interrupt.h>
  44. +#include <linux/workqueue.h>
  45. +#include <linux/timer.h>
  46. +#include <linux/syscalls.h>
  47. +#include <linux/kmod.h>
  48. +#include <linux/syscalls.h>
  49. +#include <linux/fs.h>
  50. +#include <asm/fcntl.h>
  51. +#include <asm/hardirq.h>
  52. +#include <linux/ioctl.h>
  53. +#include <linux/cdev.h>
  54. +#include <linux/sched.h>
  55. +#include <linux/mm.h>
  56. +#include <asm/io.h>
  57. +#include <linux/spinlock.h>
  58. +#include <mach/hardware.h>
  59. +#include <asm/uaccess.h>
  60. +#include <linux/syscalls.h>
  61. +#include <asm/atomic.h>
  62. +#include <linux/proc_fs.h>
  63. +#include <asm/uaccess.h>
  64. +#include <linux/kernel.h>
  65. +
  66. +#include <mach/kirkwood.h>
  67. +#include <plat/gpio.h>
  68. +#include <linux/gpio.h>
  69. +#include "common.h"
  70. +#include "mpp.h"
  71. +
  72. +
  73. +
  74. +#define MCU_DATA_PIN 14
  75. +#define MCU_CLK_PIN 16
  76. +#define MCU_ACT_PIN 17
  77. +
  78. +MODULE_LICENSE("GPL v2");
  79. +#define MODULE_NAME "mcu"
  80. +
  81. +unsigned long mcu_data = 0;
  82. +unsigned long mcu_counter = 0;
  83. +
  84. +static struct proc_dir_entry *mcu_proc;
  85. +
  86. +static int mcu_status_read_fn(char *buf, char **start, off_t offset,
  87. + int count, int *eof, void *data)
  88. +{
  89. + unsigned long len, i;
  90. +
  91. + mcu_data = 0;
  92. +
  93. + gpio_request(14, "MCU_DATA");
  94. + gpio_request(16, "MCU_CLK");
  95. + gpio_request(17, "MCU_ACT");
  96. +
  97. + gpio_direction_output(MCU_ACT_PIN, 0);
  98. + msleep(100);
  99. + gpio_direction_input(MCU_DATA_PIN);
  100. + gpio_direction_output(MCU_CLK_PIN, 0);
  101. + udelay(100);
  102. +
  103. + for(i = 0 ; i < 32 ; i++)
  104. + {
  105. + mcu_data <<= 1;
  106. + gpio_set_value(MCU_CLK_PIN,1);
  107. +
  108. + mcu_data |= gpio_get_value(MCU_DATA_PIN)?0x1:0;
  109. +
  110. + udelay(100);
  111. +
  112. + gpio_set_value(MCU_CLK_PIN,0);
  113. +
  114. + udelay(100);
  115. + }
  116. +
  117. +
  118. + gpio_set_value(MCU_CLK_PIN,1);
  119. + gpio_set_value(MCU_ACT_PIN,1);
  120. +
  121. +
  122. + gpio_free(14);
  123. + gpio_free(16);
  124. + gpio_free(17);
  125. +
  126. + len = sprintf(buf, "MagicNum:%u\nRpss:%u\nTemperature:%u\n",(unsigned int)((mcu_data & 0xff000000) >> 24),
  127. + (unsigned int)((mcu_data & 0xff0000) >> 16),
  128. + (unsigned int)((mcu_data & 0xffff)));
  129. + *eof = 1;
  130. +
  131. + return len;
  132. +}
  133. +
  134. +static int mcu_status_write_fn(struct file *file, const char __user *buffer,
  135. + unsigned long count, void *data)
  136. +{
  137. + return 0;
  138. +}
  139. +
  140. +
  141. +static int __init mcu_init(void)
  142. +{
  143. +
  144. + mcu_proc = create_proc_entry("mcu", 0644, NULL);
  145. + if(mcu_proc != NULL)
  146. + {
  147. + mcu_proc->read_proc = mcu_status_read_fn;
  148. + mcu_proc->write_proc = mcu_status_write_fn;
  149. + }
  150. +
  151. + return 0;
  152. +}
  153. +
  154. +static void __exit mcu_exit(void)
  155. +{
  156. + remove_proc_entry("mcu", NULL);
  157. +
  158. +}
  159. +
  160. +module_init(mcu_init);
  161. +module_exit(mcu_exit);
  162. +
  163. diff -Nur a/arch/arm/mach-kirkwood/nsa310-setup.c b/arch/arm/mach-kirkwood/nsa310-setup.c
  164. --- a/arch/arm/mach-kirkwood/nsa310-setup.c 1970-01-01 01:00:00.000000000 +0100
  165. +++ b/arch/arm/mach-kirkwood/nsa310-setup.c 2012-02-25 23:08:39.564034385 +0100
  166. @@ -0,0 +1,351 @@
  167. +/*
  168. + * arch/arm/mach-kirkwood/nsa310-setup.c
  169. + *
  170. + * Zyxel NSA-310 Setup, by AA666, Peeter123 and Piotr Gozdur
  171. + *
  172. + * This file is licensed under the terms of the GNU General Public
  173. + * License version 2. This program is licensed "as is" without any
  174. + * warranty of any kind, whether express or implied.
  175. + */
  176. +
  177. +#include <linux/kernel.h>
  178. +#include <linux/init.h>
  179. +#include <linux/input.h>
  180. +#include <linux/delay.h>
  181. +#include <linux/platform_device.h>
  182. +#include <linux/i2c.h>
  183. +#include <linux/irq.h>
  184. +#include <linux/mtd/partitions.h>
  185. +#include <mtd/mtd-abi.h>
  186. +#include <linux/ata_platform.h>
  187. +#include <linux/ethtool.h>
  188. +#include <linux/gpio.h>
  189. +#include <linux/gpio_keys.h>
  190. +#include <linux/leds.h>
  191. +#include <asm/mach-types.h>
  192. +#include <asm/mach/arch.h>
  193. +#include <mach/kirkwood.h>
  194. +#include <plat/mvsdio.h>
  195. +#include "common.h"
  196. +#include "mpp.h"
  197. +#include <linux/timer.h>
  198. +#include <linux/jiffies.h>
  199. +
  200. +static void nsa310_timerfunc(unsigned long data);
  201. +static DEFINE_TIMER(timer, nsa310_timerfunc, 0, 0);
  202. +
  203. +static struct mtd_partition nsa310_nand_parts[] = {
  204. + {
  205. + .name = "uboot",
  206. + .offset = 0,
  207. + .size = 0x100000,
  208. + .mask_flags = MTD_WRITEABLE
  209. + }, {
  210. + .name = "uboot_env",
  211. + .offset = MTDPART_OFS_NXTBLK,
  212. + .size = 0x80000
  213. + }, {
  214. + .name = "key_store",
  215. + .offset = MTDPART_OFS_NXTBLK,
  216. + .size = 0x80000
  217. + }, {
  218. + .name = "info",
  219. + .offset = MTDPART_OFS_NXTBLK,
  220. + .size = 0x80000
  221. + }, {
  222. + .name = "etc",
  223. + .offset = MTDPART_OFS_NXTBLK,
  224. + .size = 0xA00000
  225. + }, {
  226. + .name = "kernel_1",
  227. + .offset = MTDPART_OFS_NXTBLK,
  228. + .size = 0xA00000
  229. + }, {
  230. + .name = "rootfs1",
  231. + .offset = MTDPART_OFS_NXTBLK,
  232. + .size = 0x2FC0000
  233. + }, {
  234. + .name = "kernel_2",
  235. + .offset = MTDPART_OFS_NXTBLK,
  236. + .size = 0xA00000
  237. + }, {
  238. + .name = "rootfs2",
  239. + .offset = MTDPART_OFS_NXTBLK,
  240. + .size = 0x2FC0000
  241. + },
  242. +};
  243. +
  244. +static struct i2c_board_info __initdata nsa310_i2c = {
  245. + I2C_BOARD_INFO("lm85", 0x2E),
  246. +};
  247. +
  248. +static struct mv_sata_platform_data nsa310_sata_data = {
  249. + .n_ports = 2,
  250. +};
  251. +
  252. +static unsigned int nsa310_mpp_config[] __initdata = {
  253. + MPP36_GPIO, // Reset button
  254. + MPP37_GPIO, // Copy button
  255. + MPP46_GPIO, // Power button
  256. +
  257. + MPP48_GPIO, // Power Off
  258. + MPP21_GPIO, // USB Power Off
  259. +
  260. + MPP28_GPIO, // Sys LED Green
  261. + MPP29_GPIO, // Sys LED Yellow
  262. + MPP41_GPIO, // SATA1 LED Green
  263. + MPP42_GPIO, // SATA1 LED Red
  264. + MPP12_GPO, // SATA2 LED Green
  265. + MPP13_GPIO, // SATA2 LED Red
  266. + MPP39_GPIO, // Copy LED Green
  267. + MPP40_GPIO, // Copy LED Red
  268. + MPP15_GPIO, // USB LED Green
  269. + MPP16_GPIO, // USB LED Red
  270. +
  271. + MPP38_GPIO, // VID B0
  272. + MPP45_GPIO, // VID B1
  273. +
  274. + MPP44_GPIO, // Buzzer
  275. + MPP43_GPIO, // HTP
  276. +
  277. + MPP47_GPIO, // Power Resume Data
  278. + MPP49_GPIO, // Power Resume Clock
  279. +
  280. + 0
  281. +};
  282. +
  283. +static struct gpio_led nsa310_gpio_led[] = {
  284. + {
  285. + .name = "nsa310:green:System",
  286. + .default_trigger = "timer",
  287. + .gpio = 28,
  288. + .active_low = 0,
  289. +
  290. + },
  291. + {
  292. + .name = "nsa310:red:System",
  293. + .default_trigger = "none",
  294. + .gpio = 29,
  295. + .active_low = 0,
  296. + },
  297. + {
  298. + .name = "nsa310:green:SATA1",
  299. + .default_trigger = "sata1r-disk",
  300. + .gpio = 41,
  301. + .active_low = 0,
  302. + },
  303. + {
  304. + .name = "nsa310:red:SATA1",
  305. + .default_trigger = "sata1w-disk",
  306. + .gpio = 42,
  307. + .active_low = 0,
  308. + },
  309. + {
  310. + .name = "nsa310:green:SATA2",
  311. + .default_trigger = "sata2r-disk",
  312. + .gpio = 12,
  313. + .active_low = 0,
  314. + },
  315. + {
  316. + .name = "nsa310:red:SATA2",
  317. + .default_trigger = "sata2w-disk",
  318. + .gpio = 13,
  319. + .active_low = 0,
  320. + },
  321. + {
  322. + .name = "nsa310:green:USB",
  323. + .default_trigger = "usbr-disk",
  324. + .gpio = 15,
  325. + .active_low = 0,
  326. + },
  327. + {
  328. + .name = "nsa310:red:USB",
  329. + .default_trigger = "usbw-disk",
  330. + .gpio = 16,
  331. + .active_low = 0,
  332. + },
  333. + {
  334. + .name = "nsa310:green:Copy",
  335. + .default_trigger = "none",
  336. + .gpio = 39,
  337. + .active_low = 0,
  338. + },
  339. + {
  340. + .name = "nsa310:red:Copy",
  341. + .default_trigger = "none",
  342. + .gpio = 40,
  343. + .active_low = 0,
  344. + },
  345. +};
  346. +
  347. +
  348. +static int nsa310_gpio_blink_set(unsigned gpio, int state,
  349. + unsigned long *delay_on, unsigned long *delay_off)
  350. +{
  351. +
  352. +// Use hardware acceleration
  353. +// if (delay_on && delay_off && !*delay_on && !*delay_off)
  354. +// *delay_on = *delay_off = 100;
  355. +
  356. + switch(state) {
  357. + case GPIO_LED_NO_BLINK_LOW:
  358. + case GPIO_LED_NO_BLINK_HIGH:
  359. + orion_gpio_set_blink(gpio, 0);
  360. + gpio_set_value(gpio, state);
  361. + break;
  362. + case GPIO_LED_BLINK:
  363. + orion_gpio_set_blink(gpio, 1);
  364. + break;
  365. + }
  366. + return 0;
  367. +}
  368. +
  369. +
  370. +static struct gpio_led_platform_data nsa310_led_data = {
  371. + .leds = nsa310_gpio_led,
  372. + .num_leds = ARRAY_SIZE(nsa310_gpio_led),
  373. + .gpio_blink_set = nsa310_gpio_blink_set,
  374. +};
  375. +
  376. +static struct platform_device nsa310_leds = {
  377. + .name = "leds-gpio",
  378. + .id = -1,
  379. + .dev = { .platform_data = &nsa310_led_data, }
  380. +};
  381. +
  382. +static struct gpio_keys_button nsa310_gpio_keys_button[] = {
  383. + {
  384. + .code = KEY_POWER,
  385. + .type = EV_KEY,
  386. + .gpio = 46,
  387. + .desc = "Power Button",
  388. + .active_low = 0,
  389. + .debounce_interval = 1000,
  390. + },
  391. + {
  392. + .code = KEY_COPY,
  393. + .type = EV_KEY,
  394. + .gpio = 37,
  395. + .desc = "USB Copy",
  396. + .active_low = 1,
  397. + .debounce_interval = 1000,
  398. + },
  399. + {
  400. + .code = KEY_OPTION,
  401. + .type = EV_KEY,
  402. + .gpio = 36,
  403. + .desc = "Reset",
  404. + .active_low = 1,
  405. + .debounce_interval = 1000,
  406. + },
  407. +};
  408. +
  409. +static struct gpio_keys_platform_data nsa310_keys_data = {
  410. + .buttons = nsa310_gpio_keys_button,
  411. + .nbuttons = ARRAY_SIZE(nsa310_gpio_keys_button),
  412. +};
  413. +
  414. +
  415. +static struct platform_device nsa310_buttons = {
  416. + .name = "gpio-keys",
  417. + .id = -1,
  418. + .dev = { .platform_data = &nsa310_keys_data, }
  419. +};
  420. +
  421. +static void nsa310_power_off(void)
  422. +{
  423. +//
  424. +//don't work with sysfs
  425. + printk(KERN_INFO "Activating power off GPIO pin...\n");
  426. + gpio_set_value(48, 1);
  427. +
  428. +// If machine goes to restart, uncomment next lines for infinite loop
  429. +/* printk(KERN_INFO "System halted, please turn off power manually\n");
  430. + gpio_set_value(28, 0);
  431. + do {
  432. + mdelay(1000);
  433. + } while(1);
  434. +*/
  435. +}
  436. +
  437. +static void nsa310_timerfunc(unsigned long data)
  438. +{
  439. +// Activate USB Power
  440. + if (gpio_request(21, "USB Power") != 0 || gpio_direction_output(21, 1) != 0)
  441. + printk(KERN_ERR "failed to setup USB power GPIO\n");
  442. + else
  443. + printk(KERN_INFO "USB power enabled\n");
  444. + gpio_free(21);
  445. +}
  446. +
  447. +static void __init nsa310_init(void)
  448. +{
  449. + u32 dev, rev;
  450. +
  451. + kirkwood_init();
  452. +
  453. + kirkwood_mpp_conf(nsa310_mpp_config);
  454. + kirkwood_nand_init(ARRAY_AND_SIZE(nsa310_nand_parts), 40);
  455. + kirkwood_pcie_id(&dev, &rev);
  456. +
  457. + kirkwood_sata_init(&nsa310_sata_data);
  458. + kirkwood_uart0_init();
  459. + kirkwood_i2c_init();
  460. + i2c_register_board_info(0, &nsa310_i2c, 1);
  461. +
  462. + platform_device_register(&nsa310_leds);
  463. + platform_device_register(&nsa310_buttons);
  464. +
  465. + kirkwood_ehci_init();
  466. +// USB Power delay for 20 sec
  467. + timer.function = nsa310_timerfunc;
  468. + timer.data = 0;
  469. + timer.expires = jiffies + msecs_to_jiffies(20000);
  470. + add_timer(&timer);
  471. +
  472. +
  473. +/* Power resume control */
  474. + gpio_request(49, "Power-clk");
  475. + gpio_direction_output(49, 1);
  476. + gpio_request(47, "Power-data");
  477. +// Clear power resume
  478. +// gpio_direction_output(47, 0);
  479. +// Set power resume
  480. + gpio_direction_output(47, 1);
  481. + udelay(1000);
  482. +// gpio_direction_output(49, 0);
  483. + gpio_set_value(49, 0);
  484. +// release GPIO?
  485. +//test
  486. + gpio_free(47);
  487. + gpio_free(49);
  488. + printk(KERN_INFO "Power resume enabled\n");
  489. +
  490. +
  491. +// Activate Power-off GPIO
  492. + if (gpio_request(48, "Power-off") == 0 && gpio_direction_output(48, 0) == 0) {
  493. +// gpio_free(48);
  494. + pm_power_off = nsa310_power_off;
  495. + printk(KERN_INFO "Power-off GPIO enabled\n");
  496. + } else
  497. + printk(KERN_ERR "failed to configure Power-off GPIO\n");
  498. +
  499. +};
  500. +
  501. +static int __init nsa310_pci_init(void)
  502. +{
  503. + if (machine_is_nsa310())
  504. + kirkwood_pcie_init(KW_PCIE0);
  505. + return 0;
  506. +}
  507. +
  508. +subsys_initcall(nsa310_pci_init);
  509. +
  510. +MACHINE_START(NSA310, "Zyxel NSA-310")
  511. + .atag_offset = 0x100,
  512. + .init_machine = nsa310_init,
  513. + .map_io = kirkwood_map_io,
  514. + .init_early = kirkwood_init_early,
  515. + .init_irq = kirkwood_init_irq,
  516. + .timer = &kirkwood_timer,
  517. +MACHINE_END
  518. diff -Nur a/arch/arm/mach-kirkwood/nsa320-setup.c b/arch/arm/mach-kirkwood/nsa320-setup.c
  519. --- a/arch/arm/mach-kirkwood/nsa320-setup.c 1970-01-01 01:00:00.000000000 +0100
  520. +++ b/arch/arm/mach-kirkwood/nsa320-setup.c 2012-02-25 23:08:39.568034385 +0100
  521. @@ -0,0 +1,356 @@
  522. +/*
  523. + * arch/arm/mach-kirkwood/nsa320-setup.c
  524. + *
  525. + * Zyxel NSA-320 Setup, by AA666 and Piotr Gozdur
  526. + *
  527. + * This file is licensed under the terms of the GNU General Public
  528. + * License version 2. This program is licensed "as is" without any
  529. + * warranty of any kind, whether express or implied.
  530. + */
  531. +
  532. +#include <linux/kernel.h>
  533. +#include <linux/init.h>
  534. +#include <linux/input.h>
  535. +#include <linux/delay.h>
  536. +#include <linux/platform_device.h>
  537. +#include <linux/i2c.h>
  538. +#include <linux/irq.h>
  539. +#include <linux/mtd/partitions.h>
  540. +#include <mtd/mtd-abi.h>
  541. +#include <linux/ata_platform.h>
  542. +#include <linux/mv643xx_eth.h>
  543. +#include <linux/mv643xx_i2c.h>
  544. +#include <linux/ethtool.h>
  545. +#include <linux/gpio.h>
  546. +#include <linux/gpio_keys.h>
  547. +#include <linux/leds.h>
  548. +#include <asm/mach-types.h>
  549. +#include <asm/mach/arch.h>
  550. +#include <mach/kirkwood.h>
  551. +#include <plat/mvsdio.h>
  552. +#include "common.h"
  553. +#include "mpp.h"
  554. +#include <linux/timer.h>
  555. +#include <linux/jiffies.h>
  556. +
  557. +static void nsa320_timerfunc(unsigned long data);
  558. +static DEFINE_TIMER(timer, nsa320_timerfunc, 0, 0);
  559. +
  560. +static struct mtd_partition nsa320_nand_parts[] = {
  561. + {
  562. + .name = "uboot",
  563. + .offset = 0,
  564. + .size = 0x100000,
  565. + .mask_flags = MTD_WRITEABLE
  566. + }, {
  567. + .name = "uboot_env",
  568. + .offset = MTDPART_OFS_NXTBLK,
  569. + .size = 0x80000
  570. + }, {
  571. + .name = "key_store",
  572. + .offset = MTDPART_OFS_NXTBLK,
  573. + .size = 0x80000
  574. + }, {
  575. + .name = "info",
  576. + .offset = MTDPART_OFS_NXTBLK,
  577. + .size = 0x80000
  578. + }, {
  579. + .name = "etc",
  580. + .offset = MTDPART_OFS_NXTBLK,
  581. + .size = 0xA00000
  582. + }, {
  583. + .name = "kernel_1",
  584. + .offset = MTDPART_OFS_NXTBLK,
  585. + .size = 0xA00000
  586. + }, {
  587. + .name = "rootfs1",
  588. + .offset = MTDPART_OFS_NXTBLK,
  589. + .size = 0x2FC0000
  590. + }, {
  591. + .name = "kernel_2",
  592. + .offset = MTDPART_OFS_NXTBLK,
  593. + .size = 0xA00000
  594. + }, {
  595. + .name = "rootfs2",
  596. + .offset = MTDPART_OFS_NXTBLK,
  597. + .size = 0x2FC0000
  598. + },
  599. +};
  600. +
  601. +static struct i2c_board_info __initdata nsa320_i2c_rtc = {
  602. + I2C_BOARD_INFO("pcf8563", 0x51),
  603. +};
  604. +
  605. +static struct mv643xx_eth_platform_data nsa320_ge00_data = {
  606. + .phy_addr = MV643XX_ETH_PHY_ADDR(0),
  607. + .speed = SPEED_1000,
  608. + .duplex = DUPLEX_FULL,
  609. +};
  610. +
  611. +static struct mv_sata_platform_data nsa320_sata_data = {
  612. + .n_ports = 2,
  613. +};
  614. +
  615. +static unsigned int nsa320_mpp_config[] __initdata = {
  616. + MPP36_GPIO, // Reset button
  617. + MPP37_GPIO, // Copy button
  618. + MPP46_GPIO, // Power button
  619. +
  620. + MPP48_GPIO, // Power Off
  621. + MPP21_GPIO, // USB Power Off
  622. +
  623. + MPP28_GPIO, // Sys LED Green
  624. + MPP29_GPIO, // Sys LED Yellow
  625. + MPP41_GPIO, // SATA1 LED Green
  626. + MPP42_GPIO, // SATA1 LED Red
  627. + MPP12_GPO, // SATA2 LED Green
  628. + MPP13_GPIO, // SATA2 LED Red
  629. + MPP39_GPIO, // Copy LED Green
  630. + MPP40_GPIO, // Copy LED Red
  631. + MPP15_GPIO, // USB LED Green
  632. +
  633. + MPP14_GPIO, // MCU Data
  634. + MPP16_GPIO, // MCU Clk
  635. + MPP17_GPIO, // MCU Act
  636. +
  637. + MPP38_GPIO, // VID B0
  638. + MPP45_GPIO, // VID B1
  639. +
  640. + MPP44_GPIO, // Buzzer
  641. + MPP43_GPIO, // HTP
  642. +
  643. + MPP47_GPIO, // Power Resume Data
  644. + MPP49_GPIO, // Power Resume Clock
  645. +
  646. + 0
  647. +};
  648. +
  649. +static struct gpio_led nsa320_gpio_led[] = {
  650. + {
  651. + .name = "nsa320:green:System",
  652. + .default_trigger = "timer",
  653. + .gpio = 28,
  654. + .active_low = 0,
  655. +
  656. + },
  657. + {
  658. + .name = "nsa320:red:System",
  659. + .default_trigger = "none",
  660. + .gpio = 29,
  661. + .active_low = 0,
  662. + },
  663. + {
  664. + .name = "nsa320:green:SATA1",
  665. + .default_trigger = "sata1r-disk",
  666. + .gpio = 41,
  667. + .active_low = 0,
  668. + },
  669. + {
  670. + .name = "nsa320:red:SATA1",
  671. + .default_trigger = "sata1w-disk",
  672. + .gpio = 42,
  673. + .active_low = 0,
  674. + },
  675. + {
  676. + .name = "nsa320:green:SATA2",
  677. + .default_trigger = "sata2r-disk",
  678. + .gpio = 12,
  679. + .active_low = 0,
  680. + },
  681. + {
  682. + .name = "nsa320:red:SATA2",
  683. + .default_trigger = "sata2w-disk",
  684. + .gpio = 13,
  685. + .active_low = 0,
  686. + },
  687. + {
  688. + .name = "nsa320:green:USB",
  689. + .default_trigger = "usb-disk",
  690. + .gpio = 15,
  691. + .active_low = 0,
  692. + },
  693. + {
  694. + .name = "nsa320:green:Copy",
  695. + .default_trigger = "none",
  696. + .gpio = 39,
  697. + .active_low = 0,
  698. + },
  699. + {
  700. + .name = "nsa320:red:Copy",
  701. + .default_trigger = "none",
  702. + .gpio = 40,
  703. + .active_low = 0,
  704. + },
  705. +};
  706. +
  707. +
  708. +static int nsa320_gpio_blink_set(unsigned gpio, int state,
  709. + unsigned long *delay_on, unsigned long *delay_off)
  710. +{
  711. +
  712. +// Use hardware acceleration
  713. +// if (delay_on && delay_off && !*delay_on && !*delay_off)
  714. +// *delay_on = *delay_off = 100;
  715. +
  716. + switch(state) {
  717. + case GPIO_LED_NO_BLINK_LOW:
  718. + case GPIO_LED_NO_BLINK_HIGH:
  719. + orion_gpio_set_blink(gpio, 0);
  720. + gpio_set_value(gpio, state);
  721. + break;
  722. + case GPIO_LED_BLINK:
  723. + orion_gpio_set_blink(gpio, 1);
  724. + break;
  725. + }
  726. + return 0;
  727. +}
  728. +
  729. +
  730. +static struct gpio_led_platform_data nsa320_led_data = {
  731. + .leds = nsa320_gpio_led,
  732. + .num_leds = ARRAY_SIZE(nsa320_gpio_led),
  733. + .gpio_blink_set = nsa320_gpio_blink_set,
  734. +};
  735. +
  736. +static struct platform_device nsa320_leds = {
  737. + .name = "leds-gpio",
  738. + .id = -1,
  739. + .dev = { .platform_data = &nsa320_led_data, }
  740. +};
  741. +
  742. +static struct gpio_keys_button nsa320_gpio_keys_button[] = {
  743. + {
  744. + .code = KEY_POWER,
  745. + .type = EV_KEY,
  746. + .gpio = 46,
  747. + .desc = "Power Button",
  748. + .active_low = 0,
  749. + .debounce_interval = 1000,
  750. + },
  751. + {
  752. + .code = KEY_COPY,
  753. + .type = EV_KEY,
  754. + .gpio = 37,
  755. + .desc = "USB Copy",
  756. + .active_low = 1,
  757. + .debounce_interval = 1000,
  758. + },
  759. + {
  760. + .code = KEY_OPTION,
  761. + .type = EV_KEY,
  762. + .gpio = 36,
  763. + .desc = "Reset",
  764. + .active_low = 1,
  765. + .debounce_interval = 1000,
  766. + },
  767. +};
  768. +
  769. +static struct gpio_keys_platform_data nsa320_keys_data = {
  770. + .buttons = nsa320_gpio_keys_button,
  771. + .nbuttons = ARRAY_SIZE(nsa320_gpio_keys_button),
  772. +};
  773. +
  774. +static struct platform_device nsa320_buttons = {
  775. + .name = "gpio-keys",
  776. + .id = -1,
  777. + .dev = { .platform_data = &nsa320_keys_data, }
  778. +};
  779. +
  780. +static void nsa320_power_off(void)
  781. +{
  782. +//
  783. +//don't work with sysfs
  784. + printk(KERN_INFO "Activating power off GPIO pin...\n");
  785. + gpio_set_value(48, 1);
  786. +
  787. +// If machine goes to restart, uncomment next lines for infinite loop
  788. +/* printk(KERN_INFO "System halted, please turn off power manually\n");
  789. + gpio_set_value(28, 0);
  790. + do {
  791. + mdelay(1000);
  792. + } while(1);
  793. +*/
  794. +}
  795. +
  796. +static void nsa320_timerfunc(unsigned long data)
  797. +{
  798. +// Activate USB Power
  799. + if (gpio_request(21, "USB Power") != 0 || gpio_direction_output(21, 1) != 0)
  800. + printk(KERN_ERR "failed to setup USB power GPIO\n");
  801. + else
  802. + printk(KERN_INFO "USB power enabled\n");
  803. + gpio_free(21);
  804. +}
  805. +
  806. +static void __init nsa320_init(void)
  807. +{
  808. + u32 dev, rev;
  809. +
  810. + kirkwood_init();
  811. +
  812. + kirkwood_mpp_conf(nsa320_mpp_config);
  813. + kirkwood_nand_init(ARRAY_AND_SIZE(nsa320_nand_parts), 25);
  814. + kirkwood_ge00_init(&nsa320_ge00_data);
  815. + kirkwood_pcie_id(&dev, &rev);
  816. +
  817. + kirkwood_sata_init(&nsa320_sata_data);
  818. + kirkwood_uart0_init();
  819. + kirkwood_i2c_init();
  820. + i2c_register_board_info(0, &nsa320_i2c_rtc, 1);
  821. +
  822. + platform_device_register(&nsa320_leds);
  823. + platform_device_register(&nsa320_buttons);
  824. +
  825. + kirkwood_ehci_init();
  826. +// USB Power delay for 20 sec
  827. + timer.function = nsa320_timerfunc;
  828. + timer.data = 0;
  829. + timer.expires = jiffies + msecs_to_jiffies(20000);
  830. + add_timer(&timer);
  831. +
  832. +
  833. +/* Power resume control */
  834. + gpio_request(49, "Power-clk");
  835. + gpio_direction_output(49, 1);
  836. + gpio_request(47, "Power-data");
  837. +// Clear power resume
  838. +// gpio_direction_output(47, 0);
  839. +// Set power resume
  840. + gpio_direction_output(47, 1);
  841. + udelay(1000);
  842. +// gpio_direction_output(49, 0);
  843. + gpio_set_value(49, 0);
  844. +// release GPIO?
  845. +//test
  846. + gpio_free(47);
  847. + gpio_free(49);
  848. + printk(KERN_INFO "Power resume enabled\n");
  849. +
  850. +
  851. +// Activate Power-off GPIO
  852. + if (gpio_request(48, "Power-off") == 0 && gpio_direction_output(48, 0) == 0) {
  853. +// gpio_free(48);
  854. + pm_power_off = nsa320_power_off;
  855. + printk(KERN_INFO "Power-off GPIO enabled\n");
  856. + } else
  857. + printk(KERN_ERR "failed to configure Power-off GPIO\n");
  858. +
  859. +};
  860. +
  861. +static int __init nsa320_pci_init(void)
  862. +{
  863. + if (machine_is_nsa320())
  864. + kirkwood_pcie_init(KW_PCIE0);
  865. + return 0;
  866. +}
  867. +
  868. +subsys_initcall(nsa320_pci_init);
  869. +
  870. +MACHINE_START(NSA320, "Zyxel NSA-320")
  871. + .atag_offset = 0x100,
  872. + .init_machine = nsa320_init,
  873. + .map_io = kirkwood_map_io,
  874. + .init_early = kirkwood_init_early,
  875. + .init_irq = kirkwood_init_irq,
  876. + .timer = &kirkwood_timer,
  877. +MACHINE_END
  878. diff -Nur a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
  879. --- a/arch/arm/tools/mach-types 2012-02-09 04:21:53.000000000 +0100
  880. +++ b/arch/arm/tools/mach-types 2012-02-25 23:08:39.568034385 +0100
  881. @@ -1169,3 +1169,5 @@
  882. pov2 MACH_POV2 POV2 3889
  883. ipod_touch_2g MACH_IPOD_TOUCH_2G IPOD_TOUCH_2G 3890
  884. da850_pqab MACH_DA850_PQAB DA850_PQAB 3891
  885. +nsa320 MACH_NSA320 NSA320 3956
  886. +nsa310 MACH_NSA310 NSA310 4022
  887. diff -Nur a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
  888. --- a/drivers/ata/sata_mv.c 2012-02-09 04:21:53.000000000 +0100
  889. +++ b/drivers/ata/sata_mv.c 2012-02-25 23:08:39.572034386 +0100
  890. @@ -69,6 +69,7 @@
  891. #include <scsi/scsi_cmnd.h>
  892. #include <scsi/scsi_device.h>
  893. #include <linux/libata.h>
  894. +#include <linux/leds.h>
  895.  
  896. #define DRV_NAME "sata_mv"
  897. #define DRV_VERSION "1.28"
  898. @@ -2306,6 +2307,7 @@
  899. struct mv_port_priv *pp = ap->private_data;
  900. u32 in_index;
  901. unsigned int port_irqs;
  902. + struct ata_taskfile *tf = &qc->tf;
  903.  
  904. pp->pp_flags &= ~MV_PP_FLAG_FAKE_ATA_BUSY; /* paranoia */
  905.  
  906. @@ -2318,6 +2320,8 @@
  907. }
  908. /* fall thru */
  909. case ATA_PROT_NCQ:
  910. + ledtrig_sata_activity(ap->port_no, tf->flags & ATA_TFLAG_WRITE);
  911. +
  912. mv_start_edma(ap, port_mmio, pp, qc->tf.protocol);
  913. pp->req_idx = (pp->req_idx + 1) & MV_MAX_Q_DEPTH_MASK;
  914. in_index = pp->req_idx << EDMA_REQ_Q_PTR_SHIFT;
  915. diff -Nur a/drivers/leds/Kconfig b/drivers/leds/Kconfig
  916. --- a/drivers/leds/Kconfig 2012-02-09 04:21:53.000000000 +0100
  917. +++ b/drivers/leds/Kconfig 2012-02-25 23:08:43.652034419 +0100
  918. @@ -439,6 +439,22 @@
  919. This allows LEDs to be controlled by IDE disk activity.
  920. If unsure, say Y.
  921.  
  922. +config LEDS_TRIGGER_SATA_DISK
  923. + bool "LED SATA Disk Trigger"
  924. + depends on ATA
  925. + depends on LEDS_TRIGGERS
  926. + help
  927. + This allows LEDs to be controlled by SATA disk activity.
  928. + If unsure, say Y.
  929. +
  930. +config LEDS_TRIGGER_USB_DISK
  931. + bool "LED USB Disk Trigger"
  932. + depends on USB_STORAGE
  933. + depends on LEDS_TRIGGERS
  934. + help
  935. + This allows LEDs to be controlled by USB disk activity.
  936. + If unsure, say Y.
  937. +
  938. config LEDS_TRIGGER_HEARTBEAT
  939. tristate "LED Heartbeat Trigger"
  940. depends on LEDS_TRIGGERS
  941. diff -Nur a/drivers/leds/ledtrig-sata-disk.c b/drivers/leds/ledtrig-sata-disk.c
  942. --- a/drivers/leds/ledtrig-sata-disk.c 1970-01-01 01:00:00.000000000 +0100
  943. +++ b/drivers/leds/ledtrig-sata-disk.c 2012-02-25 23:08:39.608034386 +0100
  944. @@ -0,0 +1,109 @@
  945. +/*
  946. + * LED SATA-Disk Activity Trigger
  947. + *
  948. + * Author: Piotr Gozdur
  949. + *
  950. + * Based on "LED IDE-Disk Activity Trigger"
  951. + * by Richard Purdie <rpurdie@openedhand.com>
  952. + *
  953. + * This program is free software; you can redistribute it and/or modify
  954. + * it under the terms of the GNU General Public License version 2 as
  955. + * published by the Free Software Foundation.
  956. + *
  957. + */
  958. +
  959. +#include <linux/module.h>
  960. +#include <linux/jiffies.h>
  961. +#include <linux/kernel.h>
  962. +#include <linux/init.h>
  963. +#include <linux/timer.h>
  964. +#include <linux/leds.h>
  965. +
  966. +DEFINE_LED_TRIGGER(ledtrig1r_sata);
  967. +DEFINE_LED_TRIGGER(ledtrig1w_sata);
  968. +DEFINE_LED_TRIGGER(ledtrig2r_sata);
  969. +DEFINE_LED_TRIGGER(ledtrig2w_sata);
  970. +
  971. +static void ledtrig_sata_timerfunc(unsigned long data);
  972. +static DEFINE_TIMER(ledtrig_sata_timer, ledtrig_sata_timerfunc, 0, 0);
  973. +
  974. +static int sata_activity=0;
  975. +static int sata_lastactivity=0;
  976. +static unsigned char sata1_rd=0, sata2_rd=0, sata1_wr=0, sata2_wr=0;
  977. +
  978. +void ledtrig_sata_activity(int port, int wr)
  979. +{
  980. + if(port == 0){
  981. + if(wr) sata1_wr = 1;
  982. + else sata1_rd = 1;
  983. + }
  984. + if(port == 1){
  985. + if(wr) sata2_wr = 1;
  986. + else sata2_rd = 1;
  987. + }
  988. +
  989. + sata_activity++;
  990. + if (!timer_pending(&ledtrig_sata_timer))
  991. + mod_timer(&ledtrig_sata_timer, jiffies + msecs_to_jiffies(10));
  992. +}
  993. +EXPORT_SYMBOL(ledtrig_sata_activity);
  994. +
  995. +static void ledtrig_sata_timerfunc(unsigned long data)
  996. +{
  997. + if (sata_lastactivity != sata_activity) {
  998. + sata_lastactivity = sata_activity;
  999. +
  1000. + if(sata1_rd){
  1001. + sata1_rd = 0;
  1002. + led_trigger_event(ledtrig1r_sata, INT_MAX);
  1003. + }
  1004. + else led_trigger_event(ledtrig1r_sata, LED_OFF);
  1005. + if(sata1_wr){
  1006. + sata1_wr = 0;
  1007. + led_trigger_event(ledtrig1w_sata, INT_MAX);
  1008. + }
  1009. + else led_trigger_event(ledtrig1w_sata, LED_OFF);
  1010. +
  1011. + if(sata2_rd){
  1012. + sata2_rd = 0;
  1013. + led_trigger_event(ledtrig2r_sata, INT_MAX);
  1014. + }
  1015. + else led_trigger_event(ledtrig2r_sata, LED_OFF);
  1016. + if(sata2_wr){
  1017. + sata2_wr = 0;
  1018. + led_trigger_event(ledtrig2w_sata, INT_MAX);
  1019. + }
  1020. + else led_trigger_event(ledtrig2w_sata, LED_OFF);
  1021. +
  1022. + mod_timer(&ledtrig_sata_timer, jiffies + msecs_to_jiffies(10));
  1023. + } else {
  1024. + led_trigger_event(ledtrig1r_sata, LED_OFF);
  1025. + led_trigger_event(ledtrig1w_sata, LED_OFF);
  1026. + led_trigger_event(ledtrig2r_sata, LED_OFF);
  1027. + led_trigger_event(ledtrig2w_sata, LED_OFF);
  1028. + }
  1029. +}
  1030. +
  1031. +static int __init ledtrig_sata_init(void)
  1032. +{
  1033. + led_trigger_register_simple("sata1r-disk", &ledtrig1r_sata);
  1034. + led_trigger_register_simple("sata1w-disk", &ledtrig1w_sata);
  1035. + led_trigger_register_simple("sata2r-disk", &ledtrig2r_sata);
  1036. + led_trigger_register_simple("sata2w-disk", &ledtrig2w_sata);
  1037. + return 0;
  1038. +}
  1039. +
  1040. +static void __exit ledtrig_sata_exit(void)
  1041. +{
  1042. + led_trigger_unregister_simple(ledtrig1r_sata);
  1043. + led_trigger_unregister_simple(ledtrig1w_sata);
  1044. + led_trigger_unregister_simple(ledtrig2r_sata);
  1045. + led_trigger_unregister_simple(ledtrig2w_sata);
  1046. +}
  1047. +
  1048. +module_init(ledtrig_sata_init);
  1049. +module_exit(ledtrig_sata_exit);
  1050. +
  1051. +MODULE_AUTHOR("Piotr Gozdur");
  1052. +MODULE_DESCRIPTION("LED SATA Disk Activity Trigger");
  1053. +MODULE_LICENSE("GPL");
  1054. diff -Nur a/drivers/leds/ledtrig-usb-disk.c b/drivers/leds/ledtrig-usb-disk.c
  1055. --- a/drivers/leds/ledtrig-usb-disk.c 1970-01-01 01:00:00.000000000 +0100
  1056. +++ b/drivers/leds/ledtrig-usb-disk.c 2012-02-25 23:08:43.652034419 +0100
  1057. @@ -0,0 +1,131 @@
  1058. +/*
  1059. + * LED USB-Disk Activity Trigger
  1060. + *
  1061. + * Author: Piotr Gozdur
  1062. + *
  1063. + * Based on "LED IDE-Disk Activity Trigger"
  1064. + * by Richard Purdie <rpurdie@openedhand.com>
  1065. + *
  1066. + * This program is free software; you can redistribute it and/or modify
  1067. + * it under the terms of the GNU General Public License version 2 as
  1068. + * published by the Free Software Foundation.
  1069. + *
  1070. + */
  1071. +
  1072. +#include <linux/module.h>
  1073. +#include <linux/jiffies.h>
  1074. +#include <linux/kernel.h>
  1075. +#include <linux/init.h>
  1076. +#include <linux/timer.h>
  1077. +#include <linux/leds.h>
  1078. +
  1079. +
  1080. +#ifdef CONFIG_MACH_NSA310
  1081. +
  1082. +DEFINE_LED_TRIGGER(ledtrigr_usb);
  1083. +DEFINE_LED_TRIGGER(ledtrigw_usb);
  1084. +
  1085. +static void ledtrig_usb_timerfunc(unsigned long data);
  1086. +static DEFINE_TIMER(ledtrig_usb_timer, ledtrig_usb_timerfunc, 0, 0);
  1087. +
  1088. +static int usb_activity=0;
  1089. +static int usb_lastactivity=0;
  1090. +static unsigned char usb_rd=0, usb_wr=0;
  1091. +
  1092. +void ledtrig_usb_activity(int wr)
  1093. +{
  1094. + if(wr) usb_wr = 1;
  1095. + else usb_rd = 1;
  1096. +
  1097. + usb_activity++;
  1098. + if (!timer_pending(&ledtrig_usb_timer))
  1099. + mod_timer(&ledtrig_usb_timer, jiffies + msecs_to_jiffies(10));
  1100. +}
  1101. +EXPORT_SYMBOL(ledtrig_usb_activity);
  1102. +
  1103. +static void ledtrig_usb_timerfunc(unsigned long data)
  1104. +{
  1105. + if (usb_lastactivity != usb_activity) {
  1106. + usb_lastactivity = usb_activity;
  1107. +
  1108. + if(usb_rd){
  1109. + usb_rd = 0;
  1110. + led_trigger_event(ledtrigr_usb, INT_MAX);
  1111. + }
  1112. + else led_trigger_event(ledtrigr_usb, LED_OFF);
  1113. + if(usb_wr){
  1114. + usb_wr = 0;
  1115. + led_trigger_event(ledtrigw_usb, INT_MAX);
  1116. + }
  1117. + else led_trigger_event(ledtrigw_usb, LED_OFF);
  1118. +
  1119. + mod_timer(&ledtrig_usb_timer, jiffies + msecs_to_jiffies(10));
  1120. + } else {
  1121. + led_trigger_event(ledtrigr_usb, LED_OFF);
  1122. + led_trigger_event(ledtrigw_usb, LED_OFF);
  1123. + }
  1124. +}
  1125. +
  1126. +static int __init ledtrig_usb_init(void)
  1127. +{
  1128. + led_trigger_register_simple("usbr-disk", &ledtrigr_usb);
  1129. + led_trigger_register_simple("usbw-disk", &ledtrigw_usb);
  1130. + return 0;
  1131. +}
  1132. +
  1133. +static void __exit ledtrig_usb_exit(void)
  1134. +{
  1135. + led_trigger_unregister_simple(ledtrigr_usb);
  1136. + led_trigger_unregister_simple(ledtrigw_usb);
  1137. +}
  1138. +
  1139. +#else
  1140. +
  1141. +DEFINE_LED_TRIGGER(ledtrig_usb);
  1142. +
  1143. +static void ledtrig_usb_timerfunc(unsigned long data);
  1144. +static DEFINE_TIMER(ledtrig_usb_timer, ledtrig_usb_timerfunc, 0, 0);
  1145. +
  1146. +static int usb_activity=0;
  1147. +static int usb_lastactivity=0;
  1148. +
  1149. +void ledtrig_usb_activity(int wr)
  1150. +{
  1151. + usb_activity++;
  1152. + if (!timer_pending(&ledtrig_usb_timer))
  1153. + mod_timer(&ledtrig_usb_timer, jiffies + msecs_to_jiffies(10));
  1154. +}
  1155. +EXPORT_SYMBOL(ledtrig_usb_activity);
  1156. +
  1157. +static void ledtrig_usb_timerfunc(unsigned long data)
  1158. +{
  1159. + if (usb_lastactivity != usb_activity) {
  1160. + usb_lastactivity = usb_activity;
  1161. +
  1162. + led_trigger_event(ledtrig_usb, INT_MAX);
  1163. +
  1164. + mod_timer(&ledtrig_usb_timer, jiffies + msecs_to_jiffies(10));
  1165. + } else {
  1166. + led_trigger_event(ledtrig_usb, LED_OFF);
  1167. + }
  1168. +}
  1169. +
  1170. +static int __init ledtrig_usb_init(void)
  1171. +{
  1172. + led_trigger_register_simple("usb-disk", &ledtrig_usb);
  1173. + return 0;
  1174. +}
  1175. +
  1176. +static void __exit ledtrig_usb_exit(void)
  1177. +{
  1178. + led_trigger_unregister_simple(ledtrig_usb);
  1179. +}
  1180. +
  1181. +#endif
  1182. +
  1183. +module_init(ledtrig_usb_init);
  1184. +module_exit(ledtrig_usb_exit);
  1185. +
  1186. +MODULE_AUTHOR("Piotr Gozdur");
  1187. +MODULE_DESCRIPTION("LED USB Disk Activity Trigger");
  1188. +MODULE_LICENSE("GPL");
  1189. diff -Nur a/drivers/leds/Makefile b/drivers/leds/Makefile
  1190. --- a/drivers/leds/Makefile 2012-02-09 04:21:53.000000000 +0100
  1191. +++ b/drivers/leds/Makefile 2012-02-25 23:08:43.652034419 +0100
  1192. @@ -57,3 +57,5 @@
  1193. obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o
  1194. obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o
  1195. obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o
  1196. +obj-$(CONFIG_LEDS_TRIGGER_SATA_DISK) += ledtrig-sata-disk.o
  1197. +obj-$(CONFIG_LEDS_TRIGGER_USB_DISK) += ledtrig-usb-disk.o
  1198. diff -Nur a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
  1199. --- a/drivers/usb/storage/transport.c 2012-02-09 04:21:53.000000000 +0100
  1200. +++ b/drivers/usb/storage/transport.c 2012-02-25 23:08:43.656034419 +0100
  1201. @@ -63,6 +63,8 @@
  1202. #include <linux/blkdev.h>
  1203. #include "../../scsi/sd.h"
  1204.  
  1205. +#include <linux/leds.h>
  1206. +
  1207.  
  1208. /***********************************************************************
  1209. * Data transfer routines
  1210. @@ -628,6 +630,9 @@
  1211. return;
  1212. }
  1213.  
  1214. + if (srb->cmnd[0] == READ_10) ledtrig_usb_activity(0); // patch by Slawomir Gajzner
  1215. + if (srb->cmnd[0] == WRITE_10) ledtrig_usb_activity(1);
  1216. +
  1217. srb->result = SAM_STAT_GOOD;
  1218.  
  1219. /* Determine if we need to auto-sense
  1220. diff -Nur a/include/linux/leds.h b/include/linux/leds.h
  1221. --- a/include/linux/leds.h 2012-02-09 04:21:53.000000000 +0100
  1222. +++ b/include/linux/leds.h 2012-02-25 23:08:43.656034419 +0100
  1223. @@ -167,6 +167,18 @@
  1224. #define ledtrig_ide_activity() do {} while(0)
  1225. #endif
  1226.  
  1227. +#ifdef CONFIG_LEDS_TRIGGER_SATA_DISK
  1228. +extern void ledtrig_sata_activity(int port, int wr);
  1229. +#else
  1230. +#define ledtrig_sata_activity() do {} while(0)
  1231. +#endif
  1232. +
  1233. +#ifdef CONFIG_LEDS_TRIGGER_USB_DISK
  1234. +extern void ledtrig_usb_activity(int wr);
  1235. +#else
  1236. +#define ledtrig_usb_activity() do {} while(0)
  1237. +#endif
  1238. +
  1239. /*
  1240. * Generic LED platform data for describing LED names and default triggers.
  1241. */
RAW Paste Data