aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2013-06-30 21:38:54 +0200
committerPaul Kocialkowski <contact@paulk.fr>2013-06-30 21:38:54 +0200
commit293c8673233ac4c444b43d3d53a8792d66df6564 (patch)
tree4aabe707ff83ef3a0840848ec82cf0bf63ae9326 /samsung-ipc
parenta058b95d4603103cfa9b569756ce2592d9641c3c (diff)
downloadexternal_libsamsung-ipc-293c8673233ac4c444b43d3d53a8792d66df6564.zip
external_libsamsung-ipc-293c8673233ac4c444b43d3d53a8792d66df6564.tar.gz
external_libsamsung-ipc-293c8673233ac4c444b43d3d53a8792d66df6564.tar.bz2
xmm6160: Use device-specific sizes and offsets
Change-Id: Ia9d4736497cd0e5fe240f9474916b29e0343dd3a Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'samsung-ipc')
-rw-r--r--samsung-ipc/device/aries/aries_ipc.c16
-rw-r--r--samsung-ipc/device/aries/aries_ipc.h3
-rw-r--r--samsung-ipc/device/crespo/crespo_ipc.c15
-rw-r--r--samsung-ipc/device/crespo/crespo_ipc.h3
-rw-r--r--samsung-ipc/device/xmm6160/xmm6160.c31
-rw-r--r--samsung-ipc/device/xmm6160/xmm6160.h7
6 files changed, 43 insertions, 32 deletions
diff --git a/samsung-ipc/device/aries/aries_ipc.c b/samsung-ipc/device/aries/aries_ipc.c
index 237aeb1..e62ec0a 100644
--- a/samsung-ipc/device/aries/aries_ipc.c
+++ b/samsung-ipc/device/aries/aries_ipc.c
@@ -56,6 +56,8 @@ int aries_ipc_bootstrap(struct ipc_client *client)
struct timeval timeout;
fd_set fds;
+ unsigned char *p;
+ unsigned char *pp;
int rc;
int i;
@@ -107,13 +109,17 @@ int aries_ipc_bootstrap(struct ipc_client *client)
usleep(100000);
- rc = xmm6160_psi_send(client, serial_fd, modem_image_data, ARIES_MODEM_IMAGE_SIZE);
+ p = (unsigned char *) modem_image_data;
+
+ rc = xmm6160_psi_send(client, serial_fd, (void *) p, ARIES_PSI_SIZE);
if (rc < 0) {
ipc_client_log(client, "Sending XMM6160 PSI failed");
goto error;
}
ipc_client_log(client, "Sent XMM6160 PSI");
+ p += ARIES_PSI_SIZE;
+
onedram_init = 0;
FD_ZERO(&fds);
@@ -150,14 +156,18 @@ int aries_ipc_bootstrap(struct ipc_client *client)
}
ipc_client_log(client, "Mapped onedram to memory");
- rc = xmm6160_modem_image_send(client, -1, onedram_address, modem_image_data, ARIES_MODEM_IMAGE_SIZE, 0);
+ pp = (unsigned char *) onedram_address;
+
+ rc = xmm6160_modem_image_send(client, -1, (void *) pp, (void *) p, ARIES_MODEM_IMAGE_SIZE - ARIES_PSI_SIZE);
if (rc < 0) {
ipc_client_log(client, "Sending XMM6160 modem image failed");
goto error;
}
ipc_client_log(client, "Sent XMM6160 modem image");
- rc = xmm6160_nv_data_send(client, -1, onedram_address, ARIES_NV_DATA_OFFSET);
+ pp = (unsigned char *) onedram_address + ARIES_ONEDRAM_NV_DATA_OFFSET;
+
+ rc = xmm6160_nv_data_send(client, -1, pp);
if (rc < 0) {
ipc_client_log(client, "Sending XMM6160 nv_data failed");
goto error;
diff --git a/samsung-ipc/device/aries/aries_ipc.h b/samsung-ipc/device/aries/aries_ipc.h
index 11a1c4d..abaff03 100644
--- a/samsung-ipc/device/aries/aries_ipc.h
+++ b/samsung-ipc/device/aries/aries_ipc.h
@@ -25,7 +25,8 @@
#define __ARIES_IPC_H__
#define ARIES_MODEM_IMAGE_SIZE 0xA00000
-#define ARIES_NV_DATA_OFFSET 0xD80000
+#define ARIES_PSI_SIZE 0x5000
+#define ARIES_ONEDRAM_NV_DATA_OFFSET 0xD80000
#define ARIES_ONEDRAM_MEMORY_SIZE 0xFFF000
#define ARIES_ONEDRAM_INIT 0x12341234
#define ARIES_ONEDRAM_MAGIC 0x45674567
diff --git a/samsung-ipc/device/crespo/crespo_ipc.c b/samsung-ipc/device/crespo/crespo_ipc.c
index 06ae3be..cd8777f 100644
--- a/samsung-ipc/device/crespo/crespo_ipc.c
+++ b/samsung-ipc/device/crespo/crespo_ipc.c
@@ -44,6 +44,7 @@ int crespo_ipc_bootstrap(struct ipc_client *client)
int modem_ctl_fd = -1;
int serial_fd = -1;
+ unsigned char *p;
int rc;
if (client == NULL)
@@ -81,21 +82,29 @@ int crespo_ipc_bootstrap(struct ipc_client *client)
usleep(100000);
- rc = xmm6160_psi_send(client, serial_fd, modem_image_data, CRESPO_MODEM_IMAGE_SIZE);
+ p = (unsigned char *) modem_image_data;
+
+ rc = xmm6160_psi_send(client, serial_fd, (void *) p, CRESPO_PSI_SIZE);
if (rc < 0) {
ipc_client_log(client, "Sending XMM6160 PSI failed");
goto error;
}
ipc_client_log(client, "Sent XMM6160 PSI");
- rc = xmm6160_modem_image_send(client, modem_ctl_fd, NULL, modem_image_data, CRESPO_MODEM_IMAGE_SIZE, 0);
+ p += CRESPO_PSI_SIZE;
+
+ lseek(modem_ctl_fd, 0, SEEK_SET);
+
+ rc = xmm6160_modem_image_send(client, modem_ctl_fd, NULL, (void *) p, CRESPO_MODEM_IMAGE_SIZE - CRESPO_PSI_SIZE);
if (rc < 0) {
ipc_client_log(client, "Sending XMM6160 modem image failed");
goto error;
}
ipc_client_log(client, "Sent XMM6160 modem image");
- rc = xmm6160_nv_data_send(client, modem_ctl_fd, NULL, CRESPO_NV_DATA_OFFSET);
+ lseek(modem_ctl_fd, CRESPO_MODEM_CTL_NV_DATA_OFFSET, SEEK_SET);
+
+ rc = xmm6160_nv_data_send(client, modem_ctl_fd, NULL);
if (rc < 0) {
ipc_client_log(client, "Sending XMM6160 nv_data failed");
goto error;
diff --git a/samsung-ipc/device/crespo/crespo_ipc.h b/samsung-ipc/device/crespo/crespo_ipc.h
index d1bc785..f06fd5e 100644
--- a/samsung-ipc/device/crespo/crespo_ipc.h
+++ b/samsung-ipc/device/crespo/crespo_ipc.h
@@ -22,7 +22,8 @@
#define __CRESPO_IPC_H__
#define CRESPO_MODEM_IMAGE_SIZE 0xD80000
-#define CRESPO_NV_DATA_OFFSET 0xD80000
+#define CRESPO_PSI_SIZE 0x5000
+#define CRESPO_MODEM_CTL_NV_DATA_OFFSET 0xD80000
#define CRESPO_DATA_SIZE 0x50000
#define CRESPO_MODEM_IMAGE_DEVICE "/dev/mtd/mtd5ro"
diff --git a/samsung-ipc/device/xmm6160/xmm6160.c b/samsung-ipc/device/xmm6160/xmm6160.c
index 22bc050..0a23f32 100644
--- a/samsung-ipc/device/xmm6160/xmm6160.c
+++ b/samsung-ipc/device/xmm6160/xmm6160.c
@@ -31,13 +31,12 @@
#include "xmm6160.h"
int xmm6160_psi_send(struct ipc_client *client, int serial_fd,
- void *modem_image_data, int modem_image_size)
+ void *modem_image_data, unsigned short psi_size)
{
char at[] = XMM6160_AT;
unsigned char version;
unsigned char info;
unsigned char psi_magic;
- unsigned short psi_size;
unsigned char psi_crc;
unsigned char psi_ack;
@@ -50,7 +49,7 @@ int xmm6160_psi_send(struct ipc_client *client, int serial_fd,
int rc;
int i;
- if (client == NULL || serial_fd < 0 || modem_image_data == NULL || modem_image_size < XMM6160_PSI_SIZE)
+ if (client == NULL || serial_fd < 0 || modem_image_data == NULL || psi_size <= 0)
return -1;
tcgetattr(serial_fd, &termios);
@@ -106,8 +105,6 @@ int xmm6160_psi_send(struct ipc_client *client, int serial_fd,
}
ipc_client_log(client, "Wrote PSI magic (0x%x)", psi_magic);
- psi_size = XMM6160_PSI_SIZE;
-
rc = write(serial_fd, &psi_size, sizeof(psi_size));
if (rc < (int) sizeof(psi_size)) {
ipc_client_log(client, "Writing PSI size failed");
@@ -124,7 +121,7 @@ int xmm6160_psi_send(struct ipc_client *client, int serial_fd,
p = (unsigned char *) modem_image_data;
psi_crc = 0;
- for (i=0; i < XMM6160_PSI_SIZE; i++) {
+ for (i=0; i < psi_size; i++) {
rc = select(serial_fd + 1, NULL, &fds, NULL, &timeout);
if (rc <= 0) {
ipc_client_log(client, "Writing PSI failed");
@@ -189,29 +186,25 @@ complete:
}
int xmm6160_modem_image_send(struct ipc_client *client, int device_fd,
- void *device_address, void *modem_image_data, int modem_image_size, int modem_image_offset)
+ void *device_address, void *modem_image_data, int modem_image_size)
{
int wc;
unsigned char *p;
- int length;
int rc;
int i;
- if (client == NULL || (device_fd < 0 && device_address == NULL) || modem_image_data == NULL || modem_image_size <= XMM6160_PSI_SIZE)
+ if (client == NULL || (device_fd < 0 && device_address == NULL) || modem_image_data == NULL || modem_image_size <= 0)
return -1;
- p = (unsigned char *) modem_image_data + XMM6160_PSI_SIZE;
- length = modem_image_size - XMM6160_PSI_SIZE;
+ p = (unsigned char *) modem_image_data;
if (device_address != NULL) {
- memcpy((void *) ((unsigned char *) device_address + modem_image_offset), p, length);
+ memcpy(device_address, (void *) p, modem_image_size);
} else {
- lseek(device_fd, modem_image_offset, SEEK_SET);
-
wc = 0;
- while (wc < length) {
- rc = write(device_fd, p, length - wc);
+ while (wc < modem_image_size) {
+ rc = write(device_fd, (void *) p, modem_image_size - wc);
if (rc < 0) {
ipc_client_log(client, "Writing modem image failed");
goto error;
@@ -234,7 +227,7 @@ complete:
}
int xmm6160_nv_data_send(struct ipc_client *client, int device_fd,
- void *device_address, int modem_image_offset)
+ void *device_address)
{
void *nv_data = NULL;
int wc;
@@ -271,10 +264,8 @@ int xmm6160_nv_data_send(struct ipc_client *client, int device_fd,
length = nv_data_size(client);
if (device_address != NULL) {
- memcpy((void *) ((unsigned char *) device_address + modem_image_offset), p, length);
+ memcpy(device_address, p, length);
} else {
- lseek(device_fd, modem_image_offset, SEEK_SET);
-
wc = 0;
while (wc < length) {
rc = write(device_fd, p, length - wc);
diff --git a/samsung-ipc/device/xmm6160/xmm6160.h b/samsung-ipc/device/xmm6160/xmm6160.h
index 6bd1b2c..412dfdb 100644
--- a/samsung-ipc/device/xmm6160/xmm6160.h
+++ b/samsung-ipc/device/xmm6160/xmm6160.h
@@ -25,17 +25,16 @@
#define XMM6160_AT "AT"
#define XMM6160_AT_COUNT 20
-#define XMM6160_PSI_SIZE 0x5000
#define XMM6160_PSI_MAGIC 0x30
#define XMM6160_PSI_ACK 0x01
#define XMM6160_BOOTCORE_VERSION 0xF0
int xmm6160_psi_send(struct ipc_client *client, int serial_fd,
- void *modem_image_data, int modem_image_size);
+ void *modem_image_data, unsigned short psi_size);
int xmm6160_modem_image_send(struct ipc_client *client, int device_fd,
- void *device_address, void *modem_image_data, int modem_image_size,int modem_image_offset);
+ void *device_address, void *modem_image_data, int modem_image_size);
int xmm6160_nv_data_send(struct ipc_client *client, int device_fd,
- void *device_address, int modem_image_offset);
+ void *device_address);
#endif