diff options
author | Simon Shields <simon@lineageos.org> | 2018-03-26 22:43:36 +0000 |
---|---|---|
committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2019-07-02 15:25:56 +0200 |
commit | bc8935d18733a5cef5d1f4a87607c58a20414efd (patch) | |
tree | 4fa572245d0821da16de736f15871e093c0d9a29 | |
parent | e188cad25b290ae74f99d574bfbdade9601fa19b (diff) | |
download | hardware_replicant_libsamsung-ipc-bc8935d18733a5cef5d1f4a87607c58a20414efd.tar.gz hardware_replicant_libsamsung-ipc-bc8935d18733a5cef5d1f4a87607c58a20414efd.tar.bz2 hardware_replicant_libsamsung-ipc-bc8935d18733a5cef5d1f4a87607c58a20414efd.zip |
n7100/xmm626: modify to work on mainline
this will also work on i9300.
-rw-r--r-- | samsung-ipc/devices/n7100/n7100.c | 39 | ||||
-rw-r--r-- | samsung-ipc/devices/n7100/n7100.h | 2 | ||||
-rw-r--r-- | samsung-ipc/devices/xmm626/xmm626_hsic.c | 16 | ||||
-rw-r--r-- | samsung-ipc/devices/xmm626/xmm626_sec_modem.c | 76 | ||||
-rw-r--r-- | samsung-ipc/devices/xmm626/xmm626_sec_modem.h | 12 |
5 files changed, 85 insertions, 60 deletions
diff --git a/samsung-ipc/devices/n7100/n7100.c b/samsung-ipc/devices/n7100/n7100.c index eb2005b..7226462 100644 --- a/samsung-ipc/devices/n7100/n7100.c +++ b/samsung-ipc/devices/n7100/n7100.c @@ -59,20 +59,14 @@ int n7100_boot(struct ipc_client *client) } ipc_client_log(client, "Mapped modem image data to memory"); - modem_boot_fd = open(XMM626_SEC_MODEM_BOOT0_DEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK); - if (modem_boot_fd < 0) { - ipc_client_log(client, "Opening modem boot device failed"); - goto error; - } - ipc_client_log(client, "Opened modem boot device"); - - modem_link_fd = open(XMM626_SEC_MODEM_LINK_PM_DEVICE, O_RDWR); + /* modem_link_fd = open(XMM626_SEC_MODEM_LINK_PM_DEVICE, O_RDWR); if (modem_link_fd < 0) { ipc_client_log(client, "Opening modem link device failed"); goto error; } ipc_client_log(client, "Opened modem link device"); - +*/ + rc = xmm626_sec_modem_power(modem_boot_fd, 0); rc = xmm626_sec_modem_hci_power(0); if (rc < 0) { ipc_client_log(client, "Turning the modem off failed"); @@ -81,7 +75,9 @@ int n7100_boot(struct ipc_client *client) ipc_client_log(client, "Turned the modem off"); rc = xmm626_sec_modem_power(modem_boot_fd, 1); + printf("%d\n", rc); rc |= xmm626_sec_modem_hci_power(1); + printf("%d\n", rc); if (rc < 0) { ipc_client_log(client, "Turning the modem on failed"); @@ -89,13 +85,29 @@ int n7100_boot(struct ipc_client *client) } ipc_client_log(client, "Turned the modem on"); - rc = xmm626_sec_modem_link_connected_wait(modem_link_fd); + rc = 0; + do { + modem_boot_fd = open(XMM626_SEC_MODEM_BOOT0_DEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK); + if (modem_boot_fd >= 0) { + break; + } + usleep(5000); + rc++; + } while (rc < 10000); + if (modem_boot_fd < 0) { + ipc_client_log(client, "Failed to open boot device"); + goto error; + } + ipc_client_log(client, "Opened modem boot device"); + + + /* rc = xmm626_sec_modem_link_connected_wait(modem_link_fd); if (rc < 0) { ipc_client_log(client, "Waiting for link connected failed"); goto error; } ipc_client_log(client, "Waited for link connected"); - +*/ p = (unsigned char *) modem_image_data + N7100_PSI_OFFSET; rc = xmm626_hsic_psi_send(client, modem_boot_fd, (void *) p, N7100_PSI_SIZE); @@ -179,7 +191,6 @@ int n7100_boot(struct ipc_client *client) rc = xmm626_sec_modem_link_get_hostwake_wait(modem_link_fd); if (rc < 0) { ipc_client_log(client, "Waiting for host wake failed"); - goto error; } ipc_client_log(client, "Waited for host wake"); @@ -192,11 +203,11 @@ int n7100_boot(struct ipc_client *client) goto error; } - rc = xmm626_sec_modem_link_connected_wait(modem_link_fd); + /* rc = xmm626_sec_modem_link_connected_wait(modem_link_fd); if (rc < 0) { ipc_client_log(client, "Waiting for link connected failed"); goto error; - } + }*/ ipc_client_log(client, "Waited for link connected"); usleep(300000); diff --git a/samsung-ipc/devices/n7100/n7100.h b/samsung-ipc/devices/n7100/n7100.h index 47088e1..7c475f3 100644 --- a/samsung-ipc/devices/n7100/n7100.h +++ b/samsung-ipc/devices/n7100/n7100.h @@ -32,7 +32,7 @@ #define N7100_NV_DATA_OFFSET 0xA00000 #define N7100_NV_DATA_SIZE 0x200000 -#define N7100_MODEM_IMAGE_DEVICE "/dev/block/mmcblk0p10" +#define N7100_MODEM_IMAGE_DEVICE "/dev/disk/by-partlabel/RADIO" struct n7100_transport_data { int fd; diff --git a/samsung-ipc/devices/xmm626/xmm626_hsic.c b/samsung-ipc/devices/xmm626/xmm626_hsic.c index 30ade46..3916b9e 100644 --- a/samsung-ipc/devices/xmm626/xmm626_hsic.c +++ b/samsung-ipc/devices/xmm626/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/devices/xmm626/xmm626_sec_modem.c b/samsung-ipc/devices/xmm626/xmm626_sec_modem.c index faeacb9..2fa6bbf 100644 --- a/samsung-ipc/devices/xmm626/xmm626_sec_modem.c +++ b/samsung-ipc/devices/xmm626/xmm626_sec_modem.c @@ -41,10 +41,7 @@ int xmm626_sec_modem_power(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,7 +55,7 @@ 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; @@ -87,16 +84,39 @@ 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; @@ -105,15 +125,8 @@ int xmm626_sec_modem_hci_power(int power) int xmm626_sec_modem_link_control_enable(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; } @@ -121,10 +134,7 @@ int xmm626_sec_modem_link_control_active(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; @@ -136,19 +146,13 @@ int xmm626_sec_modem_link_connected_wait(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) @@ -156,13 +160,11 @@ int xmm626_sec_modem_link_get_hostwake_wait(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); diff --git a/samsung-ipc/devices/xmm626/xmm626_sec_modem.h b/samsung-ipc/devices/xmm626/xmm626_sec_modem.h index 9599a84..b1e82c6 100644 --- a/samsung-ipc/devices/xmm626/xmm626_sec_modem.h +++ b/samsung-ipc/devices/xmm626/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_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 |