coreb.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Load firmware into Core B on a BF561
  2. *
  3. * Copyright 2004-2009 Analog Devices Inc.
  4. * Licensed under the GPL-2 or later.
  5. */
  6. /* The Core B reset func requires code in the application that is loaded into
  7. * Core B. In order to reset, the application needs to install an interrupt
  8. * handler for Supplemental Interrupt 0, that sets RETI to 0xff600000 and
  9. * writes bit 11 of SICB_SYSCR when bit 5 of SICA_SYSCR is 0. This causes Core
  10. * B to stall when Supplemental Interrupt 0 is set, and will reset PC to
  11. * 0xff600000 when COREB_SRAM_INIT is cleared.
  12. */
  13. #include <linux/device.h>
  14. #include <linux/fs.h>
  15. #include <linux/kernel.h>
  16. #include <linux/miscdevice.h>
  17. #include <linux/module.h>
  18. #define CMD_COREB_START _IO('b', 0)
  19. #define CMD_COREB_STOP _IO('b', 1)
  20. #define CMD_COREB_RESET _IO('b', 2)
  21. static long
  22. coreb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  23. {
  24. int ret = 0;
  25. switch (cmd) {
  26. case CMD_COREB_START:
  27. bfin_write_SYSCR(bfin_read_SYSCR() & ~0x0020);
  28. break;
  29. case CMD_COREB_STOP:
  30. bfin_write_SYSCR(bfin_read_SYSCR() | 0x0020);
  31. bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | 0x0080);
  32. break;
  33. case CMD_COREB_RESET:
  34. bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | 0x0080);
  35. break;
  36. default:
  37. ret = -EINVAL;
  38. break;
  39. }
  40. CSYNC();
  41. return ret;
  42. }
  43. static const struct file_operations coreb_fops = {
  44. .owner = THIS_MODULE,
  45. .unlocked_ioctl = coreb_ioctl,
  46. .llseek = noop_llseek,
  47. };
  48. static struct miscdevice coreb_dev = {
  49. .minor = MISC_DYNAMIC_MINOR,
  50. .name = "coreb",
  51. .fops = &coreb_fops,
  52. };
  53. static int __init bf561_coreb_init(void)
  54. {
  55. return misc_register(&coreb_dev);
  56. }
  57. module_init(bf561_coreb_init);
  58. static void __exit bf561_coreb_exit(void)
  59. {
  60. misc_deregister(&coreb_dev);
  61. }
  62. module_exit(bf561_coreb_exit);
  63. MODULE_AUTHOR("Bas Vermeulen <bvermeul@blackstar.xs4all.nl>");
  64. MODULE_DESCRIPTION("BF561 Core B Support");
  65. MODULE_LICENSE("GPL");