summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuodong Xu <guodong.xu@linaro.org>2012-08-09 12:53:50 +0800
committerRyan Harkin <ryan.harkin@linaro.org>2012-08-10 11:44:49 +0100
commit66f4e5e7b2233e3823bbe2f2c053c0c3bdd0c182 (patch)
treee75bb57bd4e699f7c664e6d5deb7d510603e2584
parent697bdbf8b3994d1142ceb4675211a8080850707f (diff)
drivers/stm: Merge updates in stm framework and ti drivers into stm_dummy
-rw-r--r--drivers/stm/stm_dummy.c394
1 files changed, 182 insertions, 212 deletions
diff --git a/drivers/stm/stm_dummy.c b/drivers/stm/stm_dummy.c
index 796481d1ac4..3b3847f626c 100644
--- a/drivers/stm/stm_dummy.c
+++ b/drivers/stm/stm_dummy.c
@@ -48,6 +48,7 @@
#include <linux/mutex.h>
#include <linux/io.h>
#include <linux/err.h>
+#include <linux/version.h>
#include "stm_fw.h"
#include "stm_msg.h"
@@ -64,7 +65,11 @@ static void build_ost_header(uint32_t protocol_id, uint32_t size,
static int32_t stm_put_msg(void *phdr_buf, int32_t hdr_size, void *pmsg_buf,
uint32_t msg_size, int32_t chn, bool timestamp);
-static struct chn_alloc *find_chn_object(int chn);
+static int32_t stm_put_bin(void *phdr_buf, int32_t hdr_size, void *pmsg_buf,
+ enum msg_data_t element_type, uint32_t num_bytes,
+ int32_t stm_chn, bool timestamp);
+
+static struct chn_alloc *construct_chn_obj(int chn, int chn_num);
static bool stm_app_ownership(void);
@@ -83,35 +88,22 @@ static bool stm_test_clock(void);
#define STM_MAX_HW_MASTERS 4 /* Maximum number of hw masters active at
* any one time */
#define HW_MASTER_MASK 0x80 /* All HW masters have bit 7 set */
-#define STM_CONTROL_BASE
#define ATTRIBUTE_BUF_SIZE 256
-
static char attribute_buf[ATTRIBUTE_BUF_SIZE];
-//RMH static const uint32_t stm_base_address = L4_EMU_44XX_BASE;
static const uint32_t stm_resolution = 0x1000;
-//RMH static uint32_t stm_iobase;
-#define STM_ADDRESS_SPACE (stm_resolution * STM_CHANNEL_TOTAL)
-
-//RMH static const uint32_t stm_control_base = L4_EMU_44XX_BASE + 0x161000;
-//RMH static const uint32_t stm_control_size = 4096;
-//RMH static uint32_t stm_cntl_iobase;
/* These are offsets from stm_control_base */
-/* non ARM STM spec v1.0 */
#define STM_SWMCTRL0_OFFSET 0x024
#define STM_SWMCTRL1_OFFSET 0x028
#define STM_SWMCTRL2_OFFSET 0x02c
#define STM_SWMCTRL3_OFFSET 0x030
#define STM_SWMCTRL4_OFFSET 0x034
#define STM_HWMCTRL_OFFSET 0x038
-
-/* ARM STM spec v1.0 */
-#define STM_LOCK_OFFSET 0xFB0 /* STMLAR */
-#define STM_LOCK_STATUS_OFFSET 0xFB4 /* STMLSR */
+#define STM_LOCK_OFFSET 0xFB0
+#define STM_LOCK_STATUS_OFFSET 0xFB4
/* STM_SWMCTRL0 bit definitions */
-/* non ARM STM spec v1.0 */
#define STM_OWNERSHIP_MASK 0xC0000000
#define STM_OWNERSHIP_AVAILABLE 0x00000000
#define STM_OWNERSHIP_CLAIMED 0x40000000
@@ -121,8 +113,6 @@ static const uint32_t stm_resolution = 0x1000;
#define STM_CURRENT_OWNER_APP 0x10000000
#define STM_MODULE_ENABLE 0x80010000
#define STM_MODULE_DISABLE 0x00000000
-
-/* ARM STM spec v1.0 */
/* STM Lock Access Register value */
#define STM_MODULE_UNLOCK 0xC5ACCE55
/* STM Lock Status bits */
@@ -163,8 +153,10 @@ static struct stm_dummy_device dev;
struct chn_alloc {
u8 chn;
+ int chn_num; /* Number of consecutive channels allocated */
int xmit_byte_count;
- enum msg_formats chn_msg_format;
+ enum msg_format_t msg_format;
+ enum msg_data_t msg_data_type;
struct mutex chn_lock;
struct list_head chn_list_link;
};
@@ -218,7 +210,7 @@ int get_global_info(struct stm_global_info *info)
}
/* Write buf to STM port */
-int stm_write(int chn, char *buf, int cnt, bool uspace, bool timestamp)
+int stm_write(void *chn_id, char *buf, int cnt, bool uspace, bool timestamp)
{
/*
@@ -229,12 +221,10 @@ int stm_write(int chn, char *buf, int cnt, bool uspace, bool timestamp)
*/
int ret = 0;
const char *local_buf = NULL;
- struct chn_alloc *chn_obj = find_chn_object(chn);
+ struct chn_alloc *chn_obj = chn_id;
int hdr_size = 0;
uint32_t ost_header[2] = { 0 };
-
- if (IS_ERR(chn_obj))
- return PTR_ERR(chn_obj);
+ uint32_t ost_protocol;
if (!buf || cnt < 1 || !chn_obj)
return -EINVAL;
@@ -246,7 +236,7 @@ int stm_write(int chn, char *buf, int cnt, bool uspace, bool timestamp)
if (mutex_lock_interruptible(&chn_obj->chn_lock))
return -ERESTARTSYS;
- switch (chn_obj->chn_msg_format) {
+ switch (chn_obj->msg_format) {
case VENDOR:
if (uspace) {
@@ -264,16 +254,32 @@ int stm_write(int chn, char *buf, int cnt, bool uspace, bool timestamp)
ret = -EFAULT;
goto stm_write_exit;
}
+ } else {
+ local_buf = buf;
}
/* Send message over STM channel */
- build_ost_header((uint32_t)OST_PROTOCOL_BYTESTREAM, cnt,
- (uint32_t *)ost_header, &hdr_size);
- ret = stm_put_msg((void *)ost_header, hdr_size,
- (void *)local_buf, cnt, chn, timestamp);
+ ost_protocol = (STRING == chn_obj->msg_data_type)
+ ? OST_PROTOCOL_CHARSTREAM
+ : OST_PROTOCOL_BINSTREAM;
+
+ build_ost_header(ost_protocol, cnt,
+ (uint32_t *)ost_header, &hdr_size);
+
+ if (STRING == chn_obj->msg_data_type)
+ ret = stm_put_msg((void *)ost_header, hdr_size,
+ (void *)local_buf, cnt,
+ chn_obj->chn, timestamp);
+ else
+ ret = stm_put_bin((void *)ost_header, hdr_size,
+ (void *)local_buf, chn_obj->msg_data_type,
+ cnt, chn_obj->chn, timestamp);
if (!ret)
ret = cnt;
+ if (!uspace)
+ local_buf = NULL;
+
break;
case USER:
@@ -281,7 +287,14 @@ int stm_write(int chn, char *buf, int cnt, bool uspace, bool timestamp)
* No need to worry about exceeding STM_MAX_XFER_BYTES because
* stm_fw driver takes care of this check.
*/
- ret = stm_put_msg(NULL, 0, (void *)buf, cnt, chn, timestamp);
+ if (STRING == chn_obj->msg_data_type) {
+ ret = stm_put_msg(NULL, 0, (void *)buf, cnt,
+ chn_obj->chn, timestamp);
+ } else {
+ ret = stm_put_bin(NULL, 0, (void *)buf,
+ chn_obj->msg_data_type,
+ cnt, chn_obj->chn, timestamp);
+ }
if (!ret)
ret = cnt;
@@ -304,45 +317,53 @@ stm_write_exit:
return ret;
}
-enum usecase_id {
- USECASE_USER,
- USECASE_PRINTK,
- USECASE_LAST
-};
+int stm_write_mark(void *chn_id, char *pbuf, int cnt, bool uspace,
+ bool timestamp)
+{
+ int ret = 0;
+ const int pid_msg_max = 64;
+ char pid_msg[pid_msg_max];
+ uint msg_cnt;
+ struct chn_alloc *chn_obj = chn_id;
+ enum msg_format_t orig_msg_format = chn_obj->msg_format;
+ enum msg_data_t orig_msg_data_type = chn_obj->msg_data_type;
-static char *usecase_cmds[] = {
- [USECASE_USER] = "user",
- [USECASE_PRINTK] = "printk"
-};
+ msg_cnt = snprintf(pid_msg, pid_msg_max, "PID %d using STM Channel %d",
+ *(pid_t *)pbuf, chn_obj->chn);
+
+ chn_obj->msg_format = VENDOR;
+ chn_obj->msg_data_type = STRING;
+
+ ret = stm_write(chn_id, pid_msg, msg_cnt, uspace, timestamp);
+
+ chn_obj->msg_format = orig_msg_format;
+ chn_obj->msg_data_type = orig_msg_data_type;
+
+ return ret;
+}
-int stm_allocate_channel(char *usecase)
+int stm_allocate_channel(enum stm_usecase uc_id, void **chn_id)
{
int chn;
int ret = 0;
int chn_offset;
int chn_num;
int chn_last;
- enum usecase_id uc_id;
struct chn_alloc *chn_obj;
+ *chn_id = NULL;
+
if (mutex_lock_interruptible(&dev.lock))
return -ERESTARTSYS;
- /* Search for the supported usecase id */
- for (uc_id = USECASE_USER; uc_id < USECASE_LAST; uc_id++)
- if (!strncmp(usecase, usecase_cmds[uc_id],
- strlen(usecase_cmds[uc_id])))
- break;
-
switch (uc_id) {
-
- case USECASE_USER:
+ case USER_CHANNEL_REQUEST:
chn_num = STM_CHANNEL_TOTAL - STM_CHANNEL_RESERVED;
chn_offset = STM_START_ALLOC;
chn_last = chn_num;
break;
- case USECASE_PRINTK:
+ case PRINTK_CHANNEL_REQUEST:
chn_num = STM_CHANNEL_RESERVED;
chn_offset = STM_CHANNEL_TOTAL - STM_CHANNEL_RESERVED;
chn_last = STM_CHANNEL_TOTAL;
@@ -353,6 +374,8 @@ int stm_allocate_channel(char *usecase)
goto stm_allocate_channel_exit;
}
+/*TODO: Can simplify since using a mutex to protect */
+
/* Look for a free channel from channel map - note thread safe test */
do {
chn = find_next_zero_bit(dev.chn_map, chn_num, chn_offset);
@@ -363,20 +386,13 @@ int stm_allocate_channel(char *usecase)
goto stm_allocate_channel_exit;
}
- chn_obj = kmalloc(sizeof(struct chn_alloc), GFP_KERNEL);
- if (!chn_obj) {
- ret = -ENOMEM;
+ chn_obj = construct_chn_obj(chn, 1);
+ if (IS_ERR(chn_obj)) {
+ ret = PTR_ERR(chn_obj);
goto stm_allocate_channel_exit;
}
- mutex_init(&chn_obj->chn_lock);
- chn_obj->chn = chn;
- chn_obj->chn_msg_format = VENDOR;
- chn_obj->xmit_byte_count = 0;
-
- list_add(&chn_obj->chn_list_link, &dev.chn_list_head);
- dev.user_allocated_chn_cnt++;
- ret = chn;
+ *chn_id = chn_obj;
stm_allocate_channel_exit:
@@ -385,35 +401,34 @@ stm_allocate_channel_exit:
}
-int stm_free_channel(int chn)
+int stm_free_channel(void *chn_id)
{
- struct list_head *ptr;
- struct chn_alloc *chn_obj = NULL;
+ int i;
+ struct chn_alloc *chn_obj = chn_id;
if (mutex_lock_interruptible(&dev.lock))
return -ERESTARTSYS;
- list_for_each(ptr, &dev.chn_list_head) {
- chn_obj = list_entry(ptr, struct chn_alloc, chn_list_link);
- if (!chn_obj || chn != chn_obj->chn)
- continue;
+ /* Make sure nobody else is using the channel. */
+ if (mutex_lock_interruptible(&chn_obj->chn_lock)) {
+ mutex_unlock(&dev.lock);
+ return -ERESTARTSYS;
+ }
- /* Make sure nobody else is using the channel. */
- if (mutex_lock_interruptible(&chn_obj->chn_lock)) {
- mutex_unlock(&dev.lock);
- return -ERESTARTSYS;
- }
- /* Remove the channel from the link list. */
- list_del(ptr);
- /* Safe to unlock. */
- mutex_unlock(&chn_obj->chn_lock);
+ /* Remove the channel from the link list. */
+ list_del(&chn_obj->chn_list_link);
+
+ /* Safe to unlock. */
+ mutex_unlock(&chn_obj->chn_lock);
- clear_bit(chn, dev.chn_map);
+ /* Free channels */
+ for (i = chn_obj->chn; i < chn_obj->chn + chn_obj->chn_num; i++) {
+ clear_bit(i, dev.chn_map);
dev.user_allocated_chn_cnt--;
- kfree(chn_obj);
- break;
}
+ kfree(chn_obj);
+
mutex_unlock(&dev.lock);
return 0;
@@ -423,13 +438,17 @@ enum config_id {
CFGID_FMT_USER,
CFGID_FMT_VENDOR,
CFGID_FMT_RAW,
+ CFGID_STRING,
+ CFGID_BIN8,
+ CFGID_BIN16,
+ CFGID_BIN32,
+ CFGID_GUARANTEED_TIMING,
CFGID_ROUTE_TO_PTI,
CFGID_ROUTE_TO_ETB,
CFGID_SET_MASTER,
CFGID_CLR_MASTER,
CFGID_STM_ENABLE,
CFGID_STM_DISABLE,
- CFGID_GUARANTEED_TIMING,
CFGID_LAST
};
@@ -437,17 +456,22 @@ static char *config_cmds[] = {
[CFGID_FMT_USER] = "fmt_user",
[CFGID_FMT_VENDOR] = "fmt_vendor",
[CFGID_FMT_RAW] = "fmt_raw",
+ [CFGID_STRING] = "string",
+ [CFGID_BIN8] = "binary8",
+ [CFGID_BIN16] = "binary16",
+ [CFGID_BIN32] = "binary32",
+ [CFGID_GUARANTEED_TIMING] = "guaranteed",
[CFGID_ROUTE_TO_PTI] = "route_stm_to_pti",
[CFGID_ROUTE_TO_ETB] = "route_stm_to_etb",
[CFGID_SET_MASTER] = "set_master",
[CFGID_CLR_MASTER] = "clr_master",
[CFGID_STM_ENABLE] = "stm_enable",
[CFGID_STM_DISABLE] = "stm_disable",
- [CFGID_GUARANTEED_TIMING] = "guaranteed"
+
};
-int stm_config_write(int chn, char *config_buf, int count)
+int stm_config_write(void *chn_id, char *config_buf)
{
int ret = 0;
struct chn_alloc *chn_obj;
@@ -463,19 +487,17 @@ int stm_config_write(int chn, char *config_buf, int count)
char delims[] = " ";
uint32_t control;
- chn_obj = (chn > -1) ? find_chn_object(chn) : NULL;
- if (chn_obj < 0)
- return (int)chn_obj;
-
- if (!config_buf || count < 1 || (!chn_obj && chn > -1))
+ if (!config_buf || !chn_id)
return -EINVAL;
+ chn_obj = ((int)chn_id != -1) ? chn_id : NULL;
+
if (chn_obj)
if (mutex_lock_interruptible(&chn_obj->chn_lock))
return -ERESTARTSYS;
/* check buf against list of supported features */
- for (cfg_id = CFGID_FMT_USER; cfg_id < CFGID_LAST; cfg_id++)
+ for (cfg_id = 0; cfg_id < CFGID_LAST; cfg_id++)
if (!strncmp(config_buf, config_cmds[cfg_id],
strlen(config_cmds[cfg_id])))
break;
@@ -489,18 +511,29 @@ int stm_config_write(int chn, char *config_buf, int count)
switch (cfg_id) {
case CFGID_FMT_USER:
- chn_obj->chn_msg_format = USER;
+ chn_obj->msg_format = USER;
break;
case CFGID_FMT_VENDOR:
- chn_obj->chn_msg_format = VENDOR;
+ chn_obj->msg_format = VENDOR;
break;
case CFGID_FMT_RAW:
- chn_obj->chn_msg_format = RAW;
+ chn_obj->msg_format = RAW;
ret = -EINVAL;
goto stm_config_write_exit;
-
+ case CFGID_STRING:
+ chn_obj->msg_data_type = STRING;
+ break;
+ case CFGID_BIN8:
+ chn_obj->msg_data_type = BIN8;
+ break;
+ case CFGID_BIN16:
+ chn_obj->msg_data_type = BIN16;
+ break;
+ case CFGID_BIN32:
+ chn_obj->msg_data_type = BIN32;
+ break;
case CFGID_ROUTE_TO_ETB:
/* Note: call stm_app_ownership first*/
/* Note: need to set rate at which masters are generated
@@ -546,27 +579,15 @@ int stm_config_write(int chn, char *config_buf, int count)
if (data[0] & HW_MASTER_MASK) {
/* set hw master select value */
-//RMH master_select = ioread32((void *)(stm_cntl_iobase +
-//RMH STM_HWMCTRL_OFFSET));
- master_select = 0; //RMH
+ master_select = 0; /* fake reading */
master_select |= data[0] << (i * 8);
-//RMH iowrite32(master_select, (void *)(stm_cntl_iobase +
-//RMH STM_HWMCTRL_OFFSET));
} else {
/* set sw master select value */
-//RMH master_select = ioread32((void *)(stm_cntl_iobase +
-//RMH STM_SWMCTRL1_OFFSET));
- master_select = 0; //RMH
+ master_select = 0;
master_select |= data[0] << (i * 8);
-//RMH iowrite32(master_select, (void *)(stm_cntl_iobase +
-//RMH STM_SWMCTRL1_OFFSET));
/* set master mask value */
-//RMH master_mask = ioread32((void *)stm_cntl_iobase +
-//RMH STM_SWMCTRL2_OFFSET);
- master_mask = 0; //RMH
+ master_mask = 0;
master_mask |= data[1] << (i * 8);
-//RMH iowrite32(master_mask, (void *)(stm_cntl_iobase +
-//RMH STM_SWMCTRL2_OFFSET));
/* TODO:: Add fixed values for other domain master selection registers. */
/* These may not actually need to be set. */
@@ -583,15 +604,12 @@ int stm_config_write(int chn, char *config_buf, int count)
goto stm_config_write_exit;
}
-//RMH iowrite32(STM_MODULE_ENABLE, (void *)(stm_cntl_iobase
-//RMH + STM_SWMCTRL0_OFFSET));
+ control = 0;
-//RMH control = ioread32((void *)(stm_cntl_iobase
-//RMH + STM_SWMCTRL0_OFFSET));
- control = 0; //RMH
-
- if ((control & STM_OWNERSHIP_MASK) != STM_OWNERSHIP_ENABLED)
- return -EFAULT;
+ if ((control & STM_OWNERSHIP_MASK) != STM_OWNERSHIP_ENABLED) {
+ ret = -EFAULT;
+ goto stm_config_write_exit;
+ }
break;
@@ -606,15 +624,12 @@ int stm_config_write(int chn, char *config_buf, int count)
goto stm_config_write_exit;
}
-//RMH iowrite32(STM_MODULE_DISABLE, (void *)(stm_cntl_iobase
-//RMH + STM_SWMCTRL0_OFFSET));
+ control = 0;
-//RMH control = ioread32((void *)(stm_cntl_iobase
-//RMH + STM_SWMCTRL0_OFFSET));
- control = 0; //RMH
-
- if ((control & STM_OWNERSHIP_MASK) != STM_OWNERSHIP_AVAILABLE)
- return -EFAULT;
+ if ((control & STM_OWNERSHIP_MASK) != STM_OWNERSHIP_AVAILABLE) {
+ ret = -EFAULT;
+ goto stm_config_write_exit;
+ }
break;
@@ -623,11 +638,9 @@ int stm_config_write(int chn, char *config_buf, int count)
break;
default:
/* If the config request not supported */
- count = -EINVAL;
+ ret = -EINVAL;
}
- ret = count;
-
stm_config_write_exit:
if (chn_obj)
@@ -638,16 +651,13 @@ stm_config_write_exit:
}
/* Provide comma seperated list of configuration and channel state info. */
-int stm_config_read(int chn, char *config_string, int count)
+int stm_config_read(void *chn_id, char *config_string, int count)
{
- struct chn_alloc *chn_obj = find_chn_object(chn);
+ struct chn_alloc *chn_obj = chn_id;
int buf_cnt = 0;
char *chn_format = NULL;
- if (IS_ERR(chn_obj))
- return PTR_ERR(chn_obj);
-
if (!config_string || count < 1 || !chn_obj)
return -EINVAL;
@@ -657,7 +667,7 @@ int stm_config_read(int chn, char *config_string, int count)
buf_cnt = snprintf(config_string, count, "STM channel %d\n,",
chn_obj->chn);
- switch (chn_obj->chn_msg_format) {
+ switch (chn_obj->msg_format) {
case VENDOR:
chn_format = config_cmds[CFGID_FMT_VENDOR];
break;
@@ -683,61 +693,32 @@ int stm_config_read(int chn, char *config_string, int count)
return buf_cnt;
}
-
static struct stm_operations stm_dummy_ops = {
.name = "stm_dummy",
.get_global_info = get_global_info,
.write = stm_write,
+ .write_mark = stm_write_mark,
.allocate_channel = stm_allocate_channel,
.free_channel = stm_free_channel,
.config_write = stm_config_write,
.config_read = stm_config_read
};
-
void stm_dummy_clean(void)
{
- struct list_head *ptr;
+ struct list_head *ptr, *tmp;
struct chn_alloc *chn_obj = NULL;
- list_for_each(ptr, &dev.chn_list_head) {
+ list_for_each_safe(ptr, tmp, &dev.chn_list_head) {
chn_obj = list_entry(ptr, struct chn_alloc, chn_list_link);
kfree(chn_obj);
}
}
-
int __init stm_dummy_init(void)
{
int ret = 0;
-//RMH char *mod_name = "STM ARM Module";
-
-//RMH if (!request_mem_region(stm_base_address, STM_ADDRESS_SPACE,
-//RMH mod_name)) {
-//RMH ret = -ENODEV;
-//RMH goto init_err;
-//RMH }
-
-//RMH stm_iobase = (unsigned long)ioremap_nocache(stm_base_address,
-//RMH STM_ADDRESS_SPACE);
-//RMH if (!stm_iobase) {
-//RMH ret = -ENODEV;
-//RMH goto init_err;
-//RMH }
-
-//RMH if (!request_mem_region(stm_control_base, STM_ADDRESS_SPACE,
-//RMH mod_name)) {
-//RMH ret = -ENODEV;
-//RMH goto init_err;
-//RMH }
-
-//RMH stm_cntl_iobase = (unsigned long)ioremap_nocache(stm_control_base,
-//RMH stm_control_size);
-//RMH if (!stm_cntl_iobase) {
-//RMH ret = -ENODEV;
-//RMH goto init_err;
-//RMH }
/* Register with the STM Framework Drvier */
ret = stm_register(&stm_dummy_ops);
@@ -754,13 +735,13 @@ init_err:
stm_dummy_clean();
pr_err("stm_dummy: driver registration error %d\n", ret);
return ret;
-
}
void __exit stm_dummy_exit(void)
{
- pr_info("stm_dummy: driver exit\n");
+ stm_unregister();
stm_dummy_clean();
+ pr_info("stm_dummy: driver exit\n");
}
module_init(stm_dummy_init);
@@ -772,25 +753,26 @@ MODULE_LICENSE("Dual BSD/GPL");
/*****************************************************************************
* Support functions
*****************************************************************************/
-static struct chn_alloc *find_chn_object(int chn)
+/* Assumpti0on this function called with dev.lock mutex already locked */
+static struct chn_alloc *construct_chn_obj(int chn, int chn_num)
{
- struct list_head *ptr;
- struct chn_alloc *chn_obj = NULL;
- struct chn_alloc *chn_obj_ret = NULL;
+ struct chn_alloc *chn_obj;
- if (mutex_lock_interruptible(&dev.lock))
- return ERR_PTR(-ERESTARTSYS);
+ chn_obj = kmalloc(sizeof(struct chn_alloc), GFP_KERNEL);
+ if (!chn_obj)
+ return (struct chn_alloc *)-ENOMEM;
- list_for_each(ptr, &dev.chn_list_head) {
- chn_obj = list_entry(ptr, struct chn_alloc, chn_list_link);
- if (chn == chn_obj->chn) {
- chn_obj_ret = chn_obj;
- break;
- }
- }
+ mutex_init(&chn_obj->chn_lock);
+ chn_obj->chn = chn;
+ chn_obj->chn_num = chn_num;
+ chn_obj->msg_format = VENDOR;
+ chn_obj->msg_data_type = STRING;
+ chn_obj->xmit_byte_count = 0;
- mutex_unlock(&dev.lock);
- return chn_obj_ret;
+ list_add(&chn_obj->chn_list_link, &dev.chn_list_head);
+ dev.user_allocated_chn_cnt += chn_num;
+
+ return chn_obj;
}
static int parse_ulongs_from_string(int num_longs, int max_ulong, long *data,
@@ -798,7 +780,7 @@ static int parse_ulongs_from_string(int num_longs, int max_ulong, long *data,
{
/* Parse the set header command */
int i;
- int ret;
+ int ret = 0;
char **item = &kbuf;
/* Get command - throw it away */
char *param = strsep(item, delims);
@@ -808,27 +790,20 @@ static int parse_ulongs_from_string(int num_longs, int max_ulong, long *data,
param = strsep(item, delims);
if (!param)
return -EINVAL;
-
+#if (LINUX_VERSION_CODE == 132643) /*2.6.35*/
+ ret = strict_strtol(param, 0, &data[i]);
+#else
ret = kstrtol(param, 10, &data[i]);
+#endif
if (ret)
return ret;
+
if (data[i] < 0 || data[i] > max_ulong)
return -EINVAL;
}
- return 0;
-}
-
-static inline uint32_t compose_address(uint32_t addr_type, int32_t stm_chn)
-{
- uint32_t offset;
-
- offset = (addr_type == STM_TIMESTAMP) ? stm_resolution / 2 : 0;
-
- return (uint32_t)(/*RMH stm_iobase + */
- (stm_resolution * (uint32_t)stm_chn) +
- offset);
+ return ret;
}
static void build_ost_header(uint32_t protocol_id, uint32_t size,
@@ -845,13 +820,19 @@ static void build_ost_header(uint32_t protocol_id, uint32_t size,
}
}
-
static int32_t stm_put_msg(void *phdr_buf, int32_t hdr_size, void *pmsg_buf,
uint32_t msg_size, int32_t stm_chn, bool timestamp)
{
return 0;
}
+static int32_t stm_put_bin(void *phdr_buf, int32_t hdr_size, void *pmsg_buf,
+ enum msg_data_t element_type, uint32_t num_bytes,
+ int32_t stm_chn, bool timestamp)
+{
+ return 0;
+}
+
static bool stm_app_ownership(void)
{
uint32_t control;
@@ -859,7 +840,7 @@ static bool stm_app_ownership(void)
int retry = 100;
bool ret = true;
- control = 0; //RMH ioread32((void *)stm_cntl_iobase + STM_SWMCTRL0_OFFSET);
+ control = 0;
/* If driver already owns the STM module then exit*/
if ((control & STM_CURRENT_OWNER_MASK) == STM_CURRENT_OWNER_APP) {
@@ -874,11 +855,7 @@ static bool stm_app_ownership(void)
}
/* Since it's avaiable can attempt to claim - so unlock the module*/
-//RMH iowrite32(STM_MODULE_UNLOCK, (void *)stm_cntl_iobase + STM_LOCK_OFFSET);
-
/* Test that it unlocked properly */
-//RMH lock_status = ioread32((void *)stm_cntl_iobase +
-//RMH STM_LOCK_STATUS_OFFSET);
lock_status = 0;
/*
@@ -893,7 +870,6 @@ static bool stm_app_ownership(void)
/* claim */
control = STM_OWNERSHIP_CLAIMED;
-//RMH iowrite32(control, (void *)stm_cntl_iobase + STM_SWMCTRL0_OFFSET);
/* Test for claim and app owns */
do {
@@ -904,9 +880,7 @@ static bool stm_app_ownership(void)
const uint32_t enabled = STM_OWNERSHIP_ENABLED |
STM_CURRENT_OWNER_APP;
-//RMH control = ioread32((void *)stm_cntl_iobase +
-//RMH STM_SWMCTRL0_OFFSET);
- control = 0; //RMH
+ control = 0;
if ((control & mask) == claimed || (control & mask) == enabled)
break;
@@ -923,8 +897,7 @@ static bool stm_test_enable()
{
uint32_t control;
-//RMH control = ioread32((void *)stm_cntl_iobase + STM_SWMCTRL0_OFFSET);
- control = 0; // RMH
+ control = 0;
if ((control & STM_MODULE_ENABLE) == STM_MODULE_ENABLE)
return true;
@@ -937,8 +910,7 @@ static bool stm_test_clock()
bool app_owns = false;
uint32_t control;
-//RMH control = ioread32((void *)stm_cntl_iobase + STM_SWMCTRL0_OFFSET);
- control = 0; //RMH
+ control = 0;
/* If driver already owns the STM module then it must be
* powered up and clock enabled.
@@ -955,8 +927,6 @@ static bool stm_test_clock()
/* If ownership is avaialbe test driver (app) can own*/
app_owns = stm_app_ownership();
if (app_owns) {
-//RMH iowrite32(STM_MODULE_DISABLE, (void *)(stm_cntl_iobase
-//RMH + STM_SWMCTRL0_OFFSET));
return true;
}