Commit c4ca3d5a authored by Omar Ramirez Luna's avatar Omar Ramirez Luna Committed by Greg Kroah-Hartman

staging: ti dspbridge: add platform manager code

Add TI's DSP Bridge platform manager driver sources
Signed-off-by: default avatarOmar Ramirez Luna <omar.ramirez@ti.com>
Signed-off-by: default avatarKanigeri, Hari <h-kanigeri2@ti.com>
Signed-off-by: default avatarAmeya Palande <ameya.palande@nokia.com>
Signed-off-by: default avatarGuzman Lugo, Fernando <fernando.lugo@ti.com>
Signed-off-by: default avatarHebbar, Shivananda <x0hebbar@ti.com>
Signed-off-by: default avatarRamos Falcon, Ernesto <ernesto@ti.com>
Signed-off-by: default avatarFelipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: default avatarAnna, Suman <s-anna@ti.com>
Signed-off-by: default avatarGupta, Ramesh <grgupta@ti.com>
Signed-off-by: default avatarGomez Castellanos, Ivan <ivan.gomez@ti.com>
Signed-off-by: default avatarAndy Shevchenko <ext-andriy.shevchenko@nokia.com>
Signed-off-by: default avatarArmando Uribe De Leon <x0095078@ti.com>
Signed-off-by: default avatarDeepak Chitriki <deepak.chitriki@ti.com>
Signed-off-by: default avatarMenon, Nishanth <nm@ti.com>
Signed-off-by: default avatarPhil Carmody <ext-phil.2.carmody@nokia.com>
Signed-off-by: default avatarOhad Ben-Cohen <ohad@wizery.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 999e07d6
/*
* chnl.c
*
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
*
* DSP API channel interface: multiplexes data streams through the single
* physical link managed by a Bridge Bridge driver.
*
* 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>
#include <dspbridge/sync.h>
/* ----------------------------------- Platform Manager */
#include <dspbridge/proc.h>
#include <dspbridge/dev.h>
/* ----------------------------------- Others */
#include <dspbridge/chnlpriv.h>
#include <chnlobj.h>
/* ----------------------------------- This */
#include <dspbridge/chnl.h>
/* ----------------------------------- Globals */
static u32 refs;
/*
* ======== chnl_create ========
* Purpose:
* Create a channel manager object, responsible for opening new channels
* and closing old ones for a given 'Bridge board.
*/
int chnl_create(OUT struct chnl_mgr **phChnlMgr,
struct dev_object *hdev_obj,
IN CONST struct chnl_mgrattrs *pMgrAttrs)
{
int status;
struct chnl_mgr *hchnl_mgr;
struct chnl_mgr_ *chnl_mgr_obj = NULL;
DBC_REQUIRE(refs > 0);
DBC_REQUIRE(phChnlMgr != NULL);
DBC_REQUIRE(pMgrAttrs != NULL);
*phChnlMgr = NULL;
/* Validate args: */
if ((0 < pMgrAttrs->max_channels) &&
(pMgrAttrs->max_channels <= CHNL_MAXCHANNELS))
status = 0;
else if (pMgrAttrs->max_channels == 0)
status = -EINVAL;
else
status = -ECHRNG;
if (pMgrAttrs->word_size == 0)
status = -EINVAL;
if (DSP_SUCCEEDED(status)) {
status = dev_get_chnl_mgr(hdev_obj, &hchnl_mgr);
if (DSP_SUCCEEDED(status) && hchnl_mgr != NULL)
status = -EEXIST;
}
if (DSP_SUCCEEDED(status)) {
struct bridge_drv_interface *intf_fxns;
dev_get_intf_fxns(hdev_obj, &intf_fxns);
/* Let Bridge channel module finish the create: */
status = (*intf_fxns->pfn_chnl_create) (&hchnl_mgr, hdev_obj,
pMgrAttrs);
if (DSP_SUCCEEDED(status)) {
/* Fill in DSP API channel module's fields of the
* chnl_mgr structure */
chnl_mgr_obj = (struct chnl_mgr_ *)hchnl_mgr;
chnl_mgr_obj->intf_fxns = intf_fxns;
/* Finally, return the new channel manager handle: */
*phChnlMgr = hchnl_mgr;
}
}
DBC_ENSURE(DSP_FAILED(status) || chnl_mgr_obj);
return status;
}
/*
* ======== chnl_destroy ========
* Purpose:
* Close all open channels, and destroy the channel manager.
*/
int chnl_destroy(struct chnl_mgr *hchnl_mgr)
{
struct chnl_mgr_ *chnl_mgr_obj = (struct chnl_mgr_ *)hchnl_mgr;
struct bridge_drv_interface *intf_fxns;
int status;
DBC_REQUIRE(refs > 0);
if (chnl_mgr_obj) {
intf_fxns = chnl_mgr_obj->intf_fxns;
/* Let Bridge channel module destroy the chnl_mgr: */
status = (*intf_fxns->pfn_chnl_destroy) (hchnl_mgr);
} else {
status = -EFAULT;
}
return status;
}
/*
* ======== chnl_exit ========
* Purpose:
* Discontinue usage of the CHNL module.
*/
void chnl_exit(void)
{
DBC_REQUIRE(refs > 0);
refs--;
DBC_ENSURE(refs >= 0);
}
/*
* ======== chnl_init ========
* Purpose:
* Initialize the CHNL module's private state.
*/
bool chnl_init(void)
{
bool ret = true;
DBC_REQUIRE(refs >= 0);
if (ret)
refs++;
DBC_ENSURE((ret && (refs > 0)) || (!ret && (refs >= 0)));
return ret;
}
/*
* chnlobj.h
*
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
*
* Structure subcomponents of channel class library channel objects which
* are exposed to DSP API from Bridge driver.
*
* 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.
*/
#ifndef CHNLOBJ_
#define CHNLOBJ_
#include <dspbridge/chnldefs.h>
#include <dspbridge/dspdefs.h>
/*
* This struct is the first field in a chnl_mgr struct. Other. implementation
* specific fields follow this structure in memory.
*/
struct chnl_mgr_ {
/* These must be the first fields in a chnl_mgr struct: */
/* Function interface to Bridge driver. */
struct bridge_drv_interface *intf_fxns;
};
/*
* This struct is the first field in a chnl_object struct. Other,
* implementation specific fields follow this structure in memory.
*/
struct chnl_object_ {
/* These must be the first fields in a chnl_object struct: */
struct chnl_mgr_ *chnl_mgr_obj; /* Pointer back to channel manager. */
};
#endif /* CHNLOBJ_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* io.c
*
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
*
* IO manager interface: Manages IO between CHNL and msg_ctrl.
*
* 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/dev.h>
/* ----------------------------------- This */
#include <ioobj.h>
#include <dspbridge/iodefs.h>
#include <dspbridge/io.h>
/* ----------------------------------- Globals */
static u32 refs;
/*
* ======== io_create ========
* Purpose:
* Create an IO manager object, responsible for managing IO between
* CHNL and msg_ctrl
*/
int io_create(OUT struct io_mgr **phIOMgr, struct dev_object *hdev_obj,
IN CONST struct io_attrs *pMgrAttrs)
{
struct bridge_drv_interface *intf_fxns;
struct io_mgr *hio_mgr = NULL;
struct io_mgr_ *pio_mgr = NULL;
int status = 0;
DBC_REQUIRE(refs > 0);
DBC_REQUIRE(phIOMgr != NULL);
DBC_REQUIRE(pMgrAttrs != NULL);
*phIOMgr = NULL;
/* A memory base of 0 implies no memory base: */
if ((pMgrAttrs->shm_base != 0) && (pMgrAttrs->usm_length == 0))
status = -EINVAL;
if (pMgrAttrs->word_size == 0)
status = -EINVAL;
if (DSP_SUCCEEDED(status)) {
dev_get_intf_fxns(hdev_obj, &intf_fxns);
/* Let Bridge channel module finish the create: */
status = (*intf_fxns->pfn_io_create) (&hio_mgr, hdev_obj,
pMgrAttrs);
if (DSP_SUCCEEDED(status)) {
pio_mgr = (struct io_mgr_ *)hio_mgr;
pio_mgr->intf_fxns = intf_fxns;
pio_mgr->hdev_obj = hdev_obj;
/* Return the new channel manager handle: */
*phIOMgr = hio_mgr;
}
}
return status;
}
/*
* ======== io_destroy ========
* Purpose:
* Delete IO manager.
*/
int io_destroy(struct io_mgr *hio_mgr)
{
struct bridge_drv_interface *intf_fxns;
struct io_mgr_ *pio_mgr = (struct io_mgr_ *)hio_mgr;
int status;
DBC_REQUIRE(refs > 0);
intf_fxns = pio_mgr->intf_fxns;
/* Let Bridge channel module destroy the io_mgr: */
status = (*intf_fxns->pfn_io_destroy) (hio_mgr);
return status;
}
/*
* ======== io_exit ========
* Purpose:
* Discontinue usage of the IO module.
*/
void io_exit(void)
{
DBC_REQUIRE(refs > 0);
refs--;
DBC_ENSURE(refs >= 0);
}
/*
* ======== io_init ========
* Purpose:
* Initialize the IO module's private state.
*/
bool io_init(void)
{
bool ret = true;
DBC_REQUIRE(refs >= 0);
if (ret)
refs++;
DBC_ENSURE((ret && (refs > 0)) || (!ret && (refs >= 0)));
return ret;
}
/*
* ioobj.h
*
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
*
* Structure subcomponents of channel class library IO objects which
* are exposed to DSP API from Bridge driver.
*
* 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.
*/
#ifndef IOOBJ_
#define IOOBJ_
#include <dspbridge/devdefs.h>
#include <dspbridge/dspdefs.h>
/*
* This struct is the first field in a io_mgr struct. Other, implementation
* specific fields follow this structure in memory.
*/
struct io_mgr_ {
/* These must be the first fields in a io_mgr struct: */
struct bridge_dev_context *hbridge_context; /* Bridge context. */
/* Function interface to Bridge driver. */
struct bridge_drv_interface *intf_fxns;
struct dev_object *hdev_obj; /* Device this board represents. */
};
#endif /* IOOBJ_ */
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment