diff options
author | Omar Ramirez Luna <omar.ramirez@ti.com> | 2010-06-23 13:01:58 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-06-23 22:39:07 (GMT) |
commit | 7d55524d3039e3e70756ee0a45f2fe59b7ed3fd2 (patch) | |
tree | e104d6a35c6fbae2743749dff63de14b2dea8778 /drivers/staging/tidspbridge/rmgr/dspdrv.c | |
parent | c4ca3d5a4b02b484fdb1bab59489699b94998fad (diff) | |
download | linux-fsl-qoriq-7d55524d3039e3e70756ee0a45f2fe59b7ed3fd2.tar.xz |
staging: ti dspbridge: add resource manager
Add TI's DSP Bridge resource manager driver sources
Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
Signed-off-by: Kanigeri, Hari <h-kanigeri2@ti.com>
Signed-off-by: Ameya Palande <ameya.palande@nokia.com>
Signed-off-by: Guzman Lugo, Fernando <fernando.lugo@ti.com>
Signed-off-by: Hebbar, Shivananda <x0hebbar@ti.com>
Signed-off-by: Ramos Falcon, Ernesto <ernesto@ti.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Anna, Suman <s-anna@ti.com>
Signed-off-by: Gupta, Ramesh <grgupta@ti.com>
Signed-off-by: Gomez Castellanos, Ivan <ivan.gomez@ti.com>
Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: Armando Uribe De Leon <x0095078@ti.com>
Signed-off-by: Deepak Chitriki <deepak.chitriki@ti.com>
Signed-off-by: Menon, Nishanth <nm@ti.com>
Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/tidspbridge/rmgr/dspdrv.c')
-rw-r--r-- | drivers/staging/tidspbridge/rmgr/dspdrv.c | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/drivers/staging/tidspbridge/rmgr/dspdrv.c b/drivers/staging/tidspbridge/rmgr/dspdrv.c new file mode 100644 index 0000000..ec9ba4f --- /dev/null +++ b/drivers/staging/tidspbridge/rmgr/dspdrv.c @@ -0,0 +1,142 @@ +/* + * dspdrv.c + * + * DSP-BIOS Bridge driver support functions for TI OMAP processors. + * + * Interface to allocate and free bridge resources. + * + * Copyright (C) 2005-2006 Texas Instruments, Inc. + * + * This package 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 PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* ----------------------------------- Host OS */ +#include <dspbridge/host_os.h> + +/* ----------------------------------- DSP/BIOS Bridge */ +#include <dspbridge/std.h> +#include <dspbridge/dbdefs.h> + +/* ----------------------------------- Trace & Debug */ +#include <dspbridge/dbc.h> + +/* ----------------------------------- OS Adaptation Layer */ +#include <dspbridge/cfg.h> + +/* ----------------------------------- Platform Manager */ +#include <dspbridge/drv.h> +#include <dspbridge/dev.h> +#include <dspbridge/dspapi.h> + +/* ----------------------------------- Resource Manager */ +#include <dspbridge/mgr.h> + +/* ----------------------------------- This */ +#include <dspbridge/dspdrv.h> + +/* + * ======== dsp_init ======== + * Allocates bridge resources. Loads a base image onto DSP, if specified. + */ +u32 dsp_init(OUT u32 *init_status) +{ + char dev_node[MAXREGPATHLENGTH] = "TIOMAP1510"; + int status = -EPERM; + struct drv_object *drv_obj = NULL; + u32 device_node; + u32 device_node_string; + + if (!api_init()) + goto func_cont; + + status = drv_create(&drv_obj); + if (DSP_FAILED(status)) { + api_exit(); + goto func_cont; + } + + /* End drv_create */ + /* Request Resources */ + status = drv_request_resources((u32) &dev_node, &device_node_string); + if (DSP_SUCCEEDED(status)) { + /* Attempt to Start the Device */ + status = dev_start_device((struct cfg_devnode *) + device_node_string); + if (DSP_FAILED(status)) + (void)drv_release_resources + ((u32) device_node_string, drv_obj); + } else { + dev_dbg(bridge, "%s: drv_request_resources Failed\n", __func__); + status = -EPERM; + } + + /* Unwind whatever was loaded */ + if (DSP_FAILED(status)) { + /* irrespective of the status of dev_remove_device we conitinue + * unloading. Get the Driver Object iterate through and remove. + * Reset the status to E_FAIL to avoid going through + * api_init_complete2. */ + for (device_node = drv_get_first_dev_extension(); + device_node != 0; + device_node = drv_get_next_dev_extension(device_node)) { + (void)dev_remove_device((struct cfg_devnode *) + device_node); + (void)drv_release_resources((u32) device_node, drv_obj); + } + /* Remove the Driver Object */ + (void)drv_destroy(drv_obj); + drv_obj = NULL; + api_exit(); + dev_dbg(bridge, "%s: Logical device failed init\n", __func__); + } /* Unwinding the loaded drivers */ +func_cont: + /* Attempt to Start the Board */ + if (DSP_SUCCEEDED(status)) { + /* BRD_AutoStart could fail if the dsp execuetable is not the + * correct one. We should not propagate that error + * into the device loader. */ + (void)api_init_complete2(); + } else { + dev_dbg(bridge, "%s: Failed\n", __func__); + } /* End api_init_complete2 */ + DBC_ENSURE((DSP_SUCCEEDED(status) && drv_obj != NULL) || + (DSP_FAILED(status) && drv_obj == NULL)); + *init_status = status; + /* Return the Driver Object */ + return (u32) drv_obj; +} + +/* + * ======== dsp_deinit ======== + * Frees the resources allocated for bridge. + */ +bool dsp_deinit(u32 deviceContext) +{ + bool ret = true; + u32 device_node; + struct mgr_object *mgr_obj = NULL; + + while ((device_node = drv_get_first_dev_extension()) != 0) { + (void)dev_remove_device((struct cfg_devnode *)device_node); + + (void)drv_release_resources((u32) device_node, + (struct drv_object *)deviceContext); + } + + (void)drv_destroy((struct drv_object *)deviceContext); + + /* Get the Manager Object from Registry + * MGR Destroy will unload the DCD dll */ + if (DSP_SUCCEEDED(cfg_get_object((u32 *) &mgr_obj, REG_MGR_OBJECT))) + (void)mgr_destroy(mgr_obj); + + api_exit(); + + return ret; +} |