coreb.c 1.6 KB

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