diff options
author | Simon Shields <simon@lineageos.org> | 2018-03-26 22:43:36 +0000 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2019-09-12 20:41:57 +0200 |
commit | 8bb344580de2e9b842cc068e29fd3fe80e3f50ef (patch) | |
tree | 5c5011c5de7e55e67e9b0721afd79ff29781b69e | |
parent | 7384be1d7ba087f7cc10e0e2ed84a1f78a46204c (diff) | |
download | hardware_replicant_libsamsung-ipc-8bb344580de2e9b842cc068e29fd3fe80e3f50ef.tar.gz hardware_replicant_libsamsung-ipc-8bb344580de2e9b842cc068e29fd3fe80e3f50ef.tar.bz2 hardware_replicant_libsamsung-ipc-8bb344580de2e9b842cc068e29fd3fe80e3f50ef.zip |
xmm626: modify to work on mainline
GNUtoo@cyberdimension.org: [rebase, fixes and cleanups]
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r-- | samsung-ipc/modems/generic/xmm626_hsic.c | 16 | ||||
-rw-r--r-- | samsung-ipc/modems/generic/xmm626_sec_modem.c | 133 | ||||
-rw-r--r-- | samsung-ipc/modems/generic/xmm626_sec_modem.h | 16 |
3 files changed, 90 insertions, 75 deletions
diff --git a/samsung-ipc/modems/generic/xmm626_hsic.c b/samsung-ipc/modems/generic/xmm626_hsic.c index 30ade46..3916b9e 100644 --- a/samsung-ipc/modems/generic/xmm626_hsic.c +++ b/samsung-ipc/modems/generic/xmm626_hsic.c @@ -357,19 +357,27 @@ int xmm626_hsic_command_send(int device_fd, unsigned short code, goto error; rc = read(device_fd, &header, sizeof(header)); - if (rc < (int) sizeof(header)) + if (rc < (int) sizeof(header)) { + printf("got no header\n"); goto error; + } rc = select(device_fd + 1, &fds, NULL, NULL, &timeout); - if (rc <= 0) + if (rc <= 0) { + printf("select failed\n"); goto error; + } rc = read(device_fd, buffer, command_data_size); - if (rc < (int) command_data_size) + if (rc < (int) command_data_size) { + printf("not enough read\n"); goto error; + } - if (header.code != code) + if (header.code != code) { + printf("header code mismatch"); goto error; + } rc = 0; goto complete; diff --git a/samsung-ipc/modems/generic/xmm626_sec_modem.c b/samsung-ipc/modems/generic/xmm626_sec_modem.c index faeacb9..5d358dc 100644 --- a/samsung-ipc/modems/generic/xmm626_sec_modem.c +++ b/samsung-ipc/modems/generic/xmm626_sec_modem.c @@ -19,6 +19,7 @@ */ #define _GNU_SOURCE +#include <errno.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> @@ -37,14 +38,11 @@ #include "xmm626.h" #include "xmm626_sec_modem.h" -int xmm626_sec_modem_power(int device_fd, int power) +int xmm626_sec_modem_power(__attribute__((unused)) int device_fd, int power) { int rc; - if (device_fd < 0) - return -1; - - rc = ioctl(device_fd, power ? IOCTL_MODEM_ON : IOCTL_MODEM_OFF, 0); + rc = sysfs_value_write(XMM626_SEC_MODEM_POWER_PATH, !!power); if (rc < 0) return -1; @@ -58,14 +56,14 @@ int xmm626_sec_modem_boot_power(int device_fd, int power) if (device_fd < 0) return -1; - rc = ioctl(device_fd, power ? IOCTL_MODEM_BOOT_ON : IOCTL_MODEM_BOOT_OFF, 0); + rc = sysfs_value_write(XMM626_SEC_MODEM_POWER_PATH, !!power); if (rc < 0) return -1; return 0; } -int xmm626_sec_modem_status_online_wait(int device_fd) +int xmm626_sec_modem_status_online_wait(__attribute__((unused)) int device_fd) { int status; int i; @@ -87,82 +85,89 @@ int xmm626_sec_modem_status_online_wait(int device_fd) int xmm626_sec_modem_hci_power(int power) { - int ehci_rc, ohci_rc; - - ehci_rc = sysfs_value_write(XMM626_SEC_MODEM_EHCI_POWER_SYSFS, !!power); - if (ehci_rc >= 0) - usleep(50000); + int ehci_rc, ohci_rc = -1; - ohci_rc = sysfs_value_write(XMM626_SEC_MODEM_OHCI_POWER_SYSFS, !!power); + + /*ohci_rc = sysfs_value_write(XMM626_SEC_MODEM_OHCI_POWER_SYSFS, !!power); if (ohci_rc >= 0) usleep(50000); +*/ + + if (!!power) { + ohci_rc = sysfs_value_write(XMM626_SEC_MODEM_PDA_ACTIVE_SYSFS, 1); + if (sysfs_value_read(XMM626_SEC_HOSTWAKE_PATH)) { + ohci_rc |= sysfs_value_write(XMM626_SEC_MODEM_SLAVEWAKE_SYSFS, 0); + usleep(10000); + ohci_rc |= sysfs_value_write(XMM626_SEC_MODEM_SLAVEWAKE_SYSFS, 1); + } + ehci_rc = sysfs_value_write(XMM626_SEC_MODEM_EHCI_POWER_SYSFS, !!power); + if (ehci_rc >= 0) + usleep(50000); + + ohci_rc |= sysfs_value_write(XMM626_SEC_LINK_ACTIVE_PATH, 1); + } else { + ehci_rc = sysfs_value_write(XMM626_SEC_MODEM_EHCI_POWER_SYSFS, !!power); + if (ehci_rc >= 0) + usleep(50000); + + //ohci_rc = sysfs_value_write(XMM626_SEC_MODEM_PDA_ACTIVE_SYSFS, 0); + ohci_rc = sysfs_value_write(XMM626_SEC_LINK_ACTIVE_PATH, 0); + } + + if (ohci_rc < 0) { + printf("ohci_rc < 0\n"); + } if (ehci_rc < 0 && ohci_rc < 0) return -1; return 0; } -int xmm626_sec_modem_link_control_enable(int device_fd, int enable) +int xmm626_sec_modem_link_control_enable(__attribute__((unused)) int device_fd, + int enable) { - int rc; - - if (device_fd < 0) - return -1; - - rc = ioctl(device_fd, IOCTL_LINK_CONTROL_ENABLE, &enable); - if (rc < 0) - return -1; - + if (enable) { + } return 0; } -int xmm626_sec_modem_link_control_active(int device_fd, int active) +int xmm626_sec_modem_link_control_active(__attribute__((unused)) int device_fd, + int active) { int rc; - if (device_fd < 0) - return -1; - - rc = ioctl(device_fd, IOCTL_LINK_CONTROL_ACTIVE, &active); + rc = sysfs_value_write(XMM626_SEC_LINK_ACTIVE_PATH, !!active); if (rc < 0) return -1; return 0; } -int xmm626_sec_modem_link_connected_wait(int device_fd) +int xmm626_sec_modem_link_connected_wait(__attribute__((unused)) int device_fd) { - int status; int i; - if (device_fd < 0) - return -1; - i = 0; - for (i = 0; i < 100; i++) { - status = ioctl(device_fd, IOCTL_LINK_CONNECTED, 0); - if (status) - return 0; + for (i = 0; i < 10; i++) { usleep(50000); } - return -1; + return 0; } -int xmm626_sec_modem_link_get_hostwake_wait(int device_fd) +int xmm626_sec_modem_link_get_hostwake_wait( + __attribute__((unused)) int device_fd) { int status; int i; - if (device_fd < 0) - return -1; - i = 0; for (i = 0; i < 10; i++) { - status = ioctl(device_fd, IOCTL_LINK_GET_HOSTWAKE, 0); - if (status) + /* !gpio_get_value (hostwake) */ + status = sysfs_value_read(XMM626_SEC_HOSTWAKE_PATH); + if (status == 0) /* invert: return true when hostwake is low */ return 0; usleep(50000); @@ -409,17 +414,25 @@ complete: int xmm626_sec_modem_open(int type) { - int fd; - - switch (type) { - case IPC_CLIENT_TYPE_FMT: - fd = open(XMM626_SEC_MODEM_IPC0_DEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK); - break; - case IPC_CLIENT_TYPE_RFS: - fd = open(XMM626_SEC_MODEM_RFS0_DEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK); - break; - default: - return -1; + int fd = -1; + int i = 0; + + while (fd < 0 && i < 30) { + i++; + usleep(30000); + switch (type) { + case IPC_CLIENT_TYPE_FMT: + printf("%s: %d %d\n", XMM626_SEC_MODEM_IPC0_DEVICE, fd, errno); + fd = open(XMM626_SEC_MODEM_IPC0_DEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK); + break; + case IPC_CLIENT_TYPE_RFS: + fd = open(XMM626_SEC_MODEM_RFS0_DEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK); + printf("%s: %d %d\n", XMM626_SEC_MODEM_RFS0_DEVICE, fd, errno); + break; + default: + printf("unknown type\n"); + return -1; + } } return fd; @@ -437,16 +450,11 @@ int xmm626_sec_modem_close(int fd) int xmm626_sec_modem_read(int fd, void *buffer, size_t length) { - int status; int rc; if (fd < 0 || buffer == NULL || length <= 0) return -1; - status = ioctl(fd, IOCTL_MODEM_STATUS, 0); - if (status != STATE_ONLINE && status != STATE_BOOTING) - return -1; - rc = read(fd, buffer, length); return rc; @@ -454,16 +462,11 @@ int xmm626_sec_modem_read(int fd, void *buffer, size_t length) int xmm626_sec_modem_write(int fd, const void *buffer, size_t length) { - int status; int rc; if (fd < 0 || buffer == NULL || length <= 0) return -1; - status = ioctl(fd, IOCTL_MODEM_STATUS, 0); - if (status != STATE_ONLINE && status != STATE_BOOTING) - return -1; - rc = write(fd, buffer, length); return rc; diff --git a/samsung-ipc/modems/generic/xmm626_sec_modem.h b/samsung-ipc/modems/generic/xmm626_sec_modem.h index 9599a84..3012b04 100644 --- a/samsung-ipc/modems/generic/xmm626_sec_modem.h +++ b/samsung-ipc/modems/generic/xmm626_sec_modem.h @@ -20,14 +20,18 @@ #ifndef __XMM626_SEC_MODEM_H__ #define __XMM626_SEC_MODEM_H__ -#define XMM626_SEC_MODEM_BOOT0_DEVICE "/dev/umts_boot0" +#define XMM626_SEC_MODEM_BOOT0_DEVICE "/dev/xmm6262_boot0" #define XMM626_SEC_MODEM_BOOT1_DEVICE "/dev/umts_boot1" -#define XMM626_SEC_MODEM_IPC0_DEVICE "/dev/umts_ipc0" -#define XMM626_SEC_MODEM_RFS0_DEVICE "/dev/umts_rfs0" +#define XMM626_SEC_MODEM_IPC0_DEVICE "/dev/umts_ipc" +#define XMM626_SEC_MODEM_RFS0_DEVICE "/dev/umts_rfs" #define XMM626_SEC_MODEM_LINK_PM_DEVICE "/dev/link_pm" -#define XMM626_SEC_MODEM_EHCI_POWER_SYSFS "/sys/devices/platform/s5p-ehci/ehci_power" -#define XMM626_SEC_MODEM_OHCI_POWER_SYSFS "/sys/devices/platform/s5p-ohci/ohci_power" - +#define XMM626_SEC_MODEM_EHCI_POWER_SYSFS "/sys/devices/platform/soc/12580000.ehci/ehci_power" +#define XMM626_SEC_HOSTWAKE_PATH "/sys/devices/platform/xmm6262/hostwake" +#define XMM626_SEC_LINK_ACTIVE_PATH "/sys/devices/platform/xmm6262/link_active" +#define XMM626_SEC_MODEM_POWER_PATH "/sys/devices/platform/xmm6262/modem_power" +#define XMM626_SEC_MODEM_PDA_ACTIVE_SYSFS "/sys/devices/platform/xmm6262/pda_active" +#define XMM626_SEC_MODEM_SLAVEWAKE_SYSFS "/sys/devices/platform/xmm6262/slavewake" +//#define XMM626_SEC_MODEM_OHCI_POWER_SYSFS "/sys/devices/platform/s5p-ohci/ohci_power" #define XMM626_SEC_MODEM_GPRS_IFACE_PREFIX "rmnet" #define XMM626_SEC_MODEM_GPRS_IFACE_COUNT 3 |