blob: cf27554e76bf932f5a2e3d31d7fbc10969d369fa [file] [log] [blame]
Mike Frysingerc8f36dc2009-05-14 14:55:50 +00001/* Load firmware into Core B on a BF561
Bryan Wu1394f032007-05-06 14:50:22 -07002 *
Paul Gortmaker2d4d3b52016-10-29 16:38:42 -04003 * Author: Bas Vermeulen <bvermeul@blackstar.xs4all.nl>
4 *
Mike Frysingerc8f36dc2009-05-14 14:55:50 +00005 * Copyright 2004-2009 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
Bryan Wu1394f032007-05-06 14:50:22 -07007 */
8
Mike Frysingerc8f36dc2009-05-14 14:55:50 +00009/* The Core B reset func requires code in the application that is loaded into
10 * Core B. In order to reset, the application needs to install an interrupt
11 * handler for Supplemental Interrupt 0, that sets RETI to 0xff600000 and
12 * writes bit 11 of SICB_SYSCR when bit 5 of SICA_SYSCR is 0. This causes Core
13 * B to stall when Supplemental Interrupt 0 is set, and will reset PC to
14 * 0xff600000 when COREB_SRAM_INIT is cleared.
15 */
16
Bryan Wu1394f032007-05-06 14:50:22 -070017#include <linux/device.h>
Enrik Berkhan76a7f402007-12-24 19:51:31 +080018#include <linux/fs.h>
Paul Gortmaker2d4d3b52016-10-29 16:38:42 -040019#include <linux/init.h>
Mike Frysingerc8f36dc2009-05-14 14:55:50 +000020#include <linux/kernel.h>
21#include <linux/miscdevice.h>
Bryan Wu1394f032007-05-06 14:50:22 -070022
Mike Frysinger7696eec2010-10-06 06:33:08 +000023#define CMD_COREB_START _IO('b', 0)
24#define CMD_COREB_STOP _IO('b', 1)
25#define CMD_COREB_RESET _IO('b', 2)
Bryan Wu1394f032007-05-06 14:50:22 -070026
Mike Frysinger17a1b5e2009-10-13 12:50:05 +000027static long
28coreb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
Bryan Wu1394f032007-05-06 14:50:22 -070029{
Mike Frysingerc8f36dc2009-05-14 14:55:50 +000030 int ret = 0;
Bryan Wu1394f032007-05-06 14:50:22 -070031
Mike Frysingerc8f36dc2009-05-14 14:55:50 +000032 switch (cmd) {
33 case CMD_COREB_START:
Mike Frysinger39c99962010-10-19 18:44:23 +000034 bfin_write_SYSCR(bfin_read_SYSCR() & ~0x0020);
Bryan Wu1394f032007-05-06 14:50:22 -070035 break;
Mike Frysingerc8f36dc2009-05-14 14:55:50 +000036 case CMD_COREB_STOP:
Mike Frysinger39c99962010-10-19 18:44:23 +000037 bfin_write_SYSCR(bfin_read_SYSCR() | 0x0020);
Mike Frysingerc8f36dc2009-05-14 14:55:50 +000038 bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | 0x0080);
39 break;
40 case CMD_COREB_RESET:
41 bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | 0x0080);
42 break;
Bryan Wu1394f032007-05-06 14:50:22 -070043 default:
44 ret = -EINVAL;
Mike Frysingerc8f36dc2009-05-14 14:55:50 +000045 break;
Bryan Wu1394f032007-05-06 14:50:22 -070046 }
Mike Frysingerc8f36dc2009-05-14 14:55:50 +000047
48 CSYNC();
49
Bryan Wu1394f032007-05-06 14:50:22 -070050 return ret;
51}
52
Alexey Dobriyan828c0952009-10-01 15:43:56 -070053static const struct file_operations coreb_fops = {
Mike Frysinger17a1b5e2009-10-13 12:50:05 +000054 .owner = THIS_MODULE,
55 .unlocked_ioctl = coreb_ioctl,
Arnd Bergmann6038f372010-08-15 18:52:59 +020056 .llseek = noop_llseek,
Bryan Wu1394f032007-05-06 14:50:22 -070057};
58
59static struct miscdevice coreb_dev = {
Mike Frysingerc8f36dc2009-05-14 14:55:50 +000060 .minor = MISC_DYNAMIC_MINOR,
61 .name = "coreb",
62 .fops = &coreb_fops,
Bryan Wu1394f032007-05-06 14:50:22 -070063};
Paul Gortmaker2d4d3b52016-10-29 16:38:42 -040064builtin_misc_device(coreb_dev);