coreb.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 2
  19. #define CMD_COREB_STOP 3
  20. #define CMD_COREB_RESET 4
  21. static int
  22. coreb_ioctl(struct inode *inode, 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_SICA_SYSCR(bfin_read_SICA_SYSCR() & ~0x0020);
  28. break;
  29. case CMD_COREB_STOP:
  30. bfin_write_SICA_SYSCR(bfin_read_SICA_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. .ioctl = coreb_ioctl,
  46. };
  47. static struct miscdevice coreb_dev = {
  48. .minor = MISC_DYNAMIC_MINOR,
  49. .name = "coreb",
  50. .fops = &coreb_fops,
  51. };
  52. static int __init bf561_coreb_init(void)
  53. {
  54. return misc_register(&coreb_dev);
  55. }
  56. module_init(bf561_coreb_init);
  57. static void __exit bf561_coreb_exit(void)
  58. {
  59. misc_deregister(&coreb_dev);
  60. }
  61. module_exit(bf561_coreb_exit);
  62. MODULE_AUTHOR("Bas Vermeulen <bvermeul@blackstar.xs4all.nl>");
  63. MODULE_DESCRIPTION("BF561 Core B Support");