dsp_common.c

来自「omap3 linux 2.6 用nocc去除了冗余代码」· C语言 代码 · 共 164 行

C
164
字号
/* * This file is part of OMAP DSP driver (DSP Gateway version 3.3.1) * * Copyright (C) 2002-2006 Nokia Corporation. All rights reserved. * * Contact: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */#include <linux/module.h>#include <linux/init.h>#include <linux/sched.h>#include <linux/delay.h>#include <linux/mm.h>#include <linux/clk.h>#include <linux/mutex.h>#include <linux/interrupt.h>#include <asm/io.h>#include <asm/tlbflush.h>#include <asm/irq.h>#include "dsp_common.h"#define dsp_boot_config(mode)	writel((mode), DSP_IPI_DSPBOOTCONFIG)struct omap_dsp *omap_dsp;dsp_long_t dspmem_base, dspmem_size,	   daram_base, daram_size,	   saram_base, saram_size;static struct cpustat {	struct mutex lock;	enum cpustat_e stat;	enum cpustat_e req;	u16 icrmask;} cpustat = {	.stat = CPUSTAT_RESET,	.icrmask = 0xffff,};int dsp_set_rstvect(dsp_long_t adr){	unsigned long *dst_adr;	if (adr >= DSPSPACE_SIZE)		return -EINVAL;	dst_adr = dspbyte_to_virt(DSP_BOOT_ADR_DIRECT);	/* word swap */	*dst_adr = ((adr & 0xffff) << 16) | (adr >> 16);	/* fill 8 bytes! */	*(dst_adr + 1) = 0;	/* direct boot */	dsp_boot_config(DSP_BOOT_CONFIG_DIRECT);	return 0;}dsp_long_t dsp_get_rstvect(void){	unsigned long *dst_adr;	dst_adr = dspbyte_to_virt(DSP_BOOT_ADR_DIRECT);	return ((*dst_adr & 0xffff) << 16) | (*dst_adr >> 16);}void dsp_reset_idle_boot_base(void) { }static int init_done;static int omap_dsp_init(void){	mutex_init(&cpustat.lock);	dspmem_size = 0;	/* To be Revisited for 3430 */	if (cpu_is_omap34xx()) {		return -ENODEV;	}	if (dspmem_size == 0) {		printk(KERN_ERR "omapdsp: unsupported omap architecture.\n");		return -ENODEV;	}	init_done = 1;	pr_info("omap_dsp_init() done\n");	return 0;}static void dsp_cpustat_update(void){	if (!init_done)		omap_dsp_init();	if (cpustat.req == CPUSTAT_RUN) {		if (cpustat.stat < CPUSTAT_RUN) {			cpustat.stat = CPUSTAT_RUN;		}		return;	}	/* cpustat.req < CPUSTAT_RUN */	if (cpustat.stat == CPUSTAT_RUN) {	}	/*	 * no user, no request	 */	if (cpustat.stat != CPUSTAT_RESET) {		cpustat.stat = CPUSTAT_RESET;	}}void dsp_cpustat_request(enum cpustat_e req){	mutex_lock(&cpustat.lock);	cpustat.req = req;	dsp_cpustat_update();	mutex_unlock(&cpustat.lock);}enum cpustat_e dsp_cpustat_get_stat(void){	return cpustat.stat;}u16 dsp_cpustat_get_icrmask(void){	return cpustat.icrmask;}void dsp_cpustat_set_icrmask(u16 mask){	mutex_lock(&cpustat.lock);	cpustat.icrmask = mask;	dsp_cpustat_update();	mutex_unlock(&cpustat.lock);}void dsp_register_mem_cb(int (*req_cb)(void), void (*rel_cb)(void)) { }void dsp_unregister_mem_cb(void) { }arch_initcall(omap_dsp_init);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?