[PATCH V6] serial: qcom_geni_serial: To correct QUP Version detection logic

2020-09-30 Thread Paras Sharma
For QUP IP versions 2.5 and above the oversampling rate is
halved from 32 to 16.

Commit ce734600545f ("tty: serial: qcom_geni_serial: Update
the oversampling rate") is pushed to handle this scenario.
But the existing logic is failing to classify QUP Version 3.0
into the correct group ( 2.5 and above).

As result Serial Engine clocks are not configured properly for
baud rate and garbage data is sampled to FIFOs from the line.

So, fix the logic to detect QUP with versions 2.5 and above.

Fixes: ce734600545f ("tty: serial: qcom_geni_serial: Update the oversampling 
rate")
Signed-off-by: Paras Sharma 
---
Changes in V6:
Removed newline unneeded change

Changes in V5:
Moved QUP_SE_VERSION_2_5 to common header file qcom-geni-se.h

Changes in V4:
Created a new #define QUP_SE_VERSION_2_5 for Qup serial engine having version 
2.5

Changes in V3:
Replaced the condition for detecting Qup version(2.5 or greater) with value 
0x2005

Changes in V2:
Changed subject line and logic for checking Qup version

 drivers/tty/serial/qcom_geni_serial.c | 2 +-
 include/linux/qcom-geni-se.h  | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/qcom_geni_serial.c 
b/drivers/tty/serial/qcom_geni_serial.c
index f0b1b47..464ffc9 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -1000,7 +1000,7 @@ static void qcom_geni_serial_set_termios(struct uart_port 
*uport,
sampling_rate = UART_OVERSAMPLING;
/* Sampling rate is halved for IP versions >= 2.5 */
ver = geni_se_get_qup_hw_version(>se);
-   if (GENI_SE_VERSION_MAJOR(ver) >= 2 && GENI_SE_VERSION_MINOR(ver) >= 5)
+   if (ver >= QUP_SE_VERSION_2_5)
sampling_rate /= 2;
 
clk_rate = get_clk_div_rate(baud, sampling_rate, _div);
diff --git a/include/linux/qcom-geni-se.h b/include/linux/qcom-geni-se.h
index 8f385fb..1c31f26 100644
--- a/include/linux/qcom-geni-se.h
+++ b/include/linux/qcom-geni-se.h
@@ -248,6 +248,9 @@ struct geni_se {
 #define GENI_SE_VERSION_MINOR(ver) ((ver & HW_VER_MINOR_MASK) >> 
HW_VER_MINOR_SHFT)
 #define GENI_SE_VERSION_STEP(ver) (ver & HW_VER_STEP_MASK)
 
+/* QUP SE VERSION value for major number 2 and minor number 5 */
+#define QUP_SE_VERSION_2_5  0x2005
+
 /*
  * Define bandwidth thresholds that cause the underlying Core 2X interconnect
  * clock to run at the named frequency. These baseline values are recommended
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH V5] serial: qcom_geni_serial: To correct QUP Version detection logic

2020-09-28 Thread Paras Sharma
For QUP IP versions 2.5 and above the oversampling rate is
halved from 32 to 16.
Commit ce734600545f ("tty: serial: qcom_geni_serial: Update
the oversampling rate") is pushed to handle this scenario.But
the existing logic is failing to classify QUP Version 3.0 into
the correct group ( 2.5 and above).

As result Serial Engine clocks are not configured properly for
baud rate and garbage data is sampled to FIFOs from the line.

So, fix the logic to detect QUP with versions 2.5 and above.

Fixes: ce734600545f ("tty: serial: qcom_geni_serial: Update the oversampling 
rate")
Signed-off-by: Paras Sharma 
---
Changes in V5:
Moved QUP_SE_VERSION_2_5 to common header file qcom-geni-se.h

Changes in V4:
Created a new #define QUP_SE_VERSION_2_5 for Qup serial engine having version 
2.5

Changes in V3:
Replaced the condition for detecting Qup version(2.5 or greater) with value 
0x2005

Changes in V2:
Changed subject line and logic for checking Qup version

 drivers/tty/serial/qcom_geni_serial.c | 3 ++-
 include/linux/qcom-geni-se.h  | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/qcom_geni_serial.c 
b/drivers/tty/serial/qcom_geni_serial.c
index f0b1b47..198ecdd7 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -106,6 +106,7 @@
 /* We always configure 4 bytes per FIFO word */
 #define BYTES_PER_FIFO_WORD4
 
+
 struct qcom_geni_private_data {
/* NOTE: earlycon port will have NULL here */
struct uart_driver *drv;
@@ -1000,7 +1001,7 @@ static void qcom_geni_serial_set_termios(struct uart_port 
*uport,
sampling_rate = UART_OVERSAMPLING;
/* Sampling rate is halved for IP versions >= 2.5 */
ver = geni_se_get_qup_hw_version(>se);
-   if (GENI_SE_VERSION_MAJOR(ver) >= 2 && GENI_SE_VERSION_MINOR(ver) >= 5)
+   if (ver >= QUP_SE_VERSION_2_5)
sampling_rate /= 2;
 
clk_rate = get_clk_div_rate(baud, sampling_rate, _div);
diff --git a/include/linux/qcom-geni-se.h b/include/linux/qcom-geni-se.h
index 8f385fb..1c31f26 100644
--- a/include/linux/qcom-geni-se.h
+++ b/include/linux/qcom-geni-se.h
@@ -248,6 +248,9 @@ struct geni_se {
 #define GENI_SE_VERSION_MINOR(ver) ((ver & HW_VER_MINOR_MASK) >> 
HW_VER_MINOR_SHFT)
 #define GENI_SE_VERSION_STEP(ver) (ver & HW_VER_STEP_MASK)
 
+/* QUP SE VERSION value for major number 2 and minor number 5 */
+#define QUP_SE_VERSION_2_5  0x2005
+
 /*
  * Define bandwidth thresholds that cause the underlying Core 2X interconnect
  * clock to run at the named frequency. These baseline values are recommended
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH V4] serial: qcom_geni_serial: To correct QUP Version detection logic

2020-09-14 Thread Paras Sharma
The current implementation reduces the sampling rate by half
if qup HW version is  greater is than 2.5 by checking if the
geni SE major version is greater than 2 and geni SE minor version
is greater than 5.This implementation fails when the version is
greater than or equal to 3.

Hence, a new macro QUP_SE_VERSION_2_5 is defined having value
for major number 2 and minor number 5 as 0x2005.Hence,if 
ver is greater than this value,sampling rate is halved. 
This logic would work for any future qup version.

Fixes: ce734600545f ("tty: serial: qcom_geni_serial: Update the oversampling 
rate")
Signed-off-by: Paras Sharma 
---
Changes in V4:
Created a new macro QUP_SE_VERSION_2_5 for Qup se version 2.5

 drivers/tty/serial/qcom_geni_serial.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/qcom_geni_serial.c 
b/drivers/tty/serial/qcom_geni_serial.c
index f0b1b47..9b74b1e 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -106,6 +106,9 @@
 /* We always configure 4 bytes per FIFO word */
 #define BYTES_PER_FIFO_WORD4
 
+/* QUP SE VERSION value for major number 2 and minor number 5 */
+#define QUP_SE_VERSION_2_5  0x2005
+
 struct qcom_geni_private_data {
/* NOTE: earlycon port will have NULL here */
struct uart_driver *drv;
@@ -1000,7 +1003,7 @@ static void qcom_geni_serial_set_termios(struct uart_port 
*uport,
sampling_rate = UART_OVERSAMPLING;
/* Sampling rate is halved for IP versions >= 2.5 */
ver = geni_se_get_qup_hw_version(>se);
-   if (GENI_SE_VERSION_MAJOR(ver) >= 2 && GENI_SE_VERSION_MINOR(ver) >= 5)
+   if (ver >= QUP_SE_VERSION_2_5)
sampling_rate /= 2;
 
clk_rate = get_clk_div_rate(baud, sampling_rate, _div);
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH] serial: qcom_geni_serial: To correct QUP Version detection logic

2020-09-01 Thread Paras Sharma
The current implementation reduces the sampling rate by half
if qup HW version is  greater is than 2.5 by checking if the
geni SE major version is greater than 2 and geni SE minor version
is greater than 5.

This implementation fails when the version is 3 or greater.

Hence new implementation checks if version is greater than or equal
to 0x2005 which would work for any future version.

Signed-off-by: Paras Sharma 
---
 drivers/tty/serial/qcom_geni_serial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/qcom_geni_serial.c 
b/drivers/tty/serial/qcom_geni_serial.c
index f0b1b47..e18b431 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -1000,7 +1000,7 @@ static void qcom_geni_serial_set_termios(struct uart_port 
*uport,
sampling_rate = UART_OVERSAMPLING;
/* Sampling rate is halved for IP versions >= 2.5 */
ver = geni_se_get_qup_hw_version(>se);
-   if (GENI_SE_VERSION_MAJOR(ver) >= 2 && GENI_SE_VERSION_MINOR(ver) >= 5)
+   if (ver >= 0x2005)
sampling_rate /= 2;
 
clk_rate = get_clk_div_rate(baud, sampling_rate, _div);
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH V2] serial: qcom_geni_serial: To correct QUP Version detection logic

2020-08-11 Thread Paras Sharma
The current implementation reduces the sampling rate by half
if qup HW version greater is than 2.5 by checking if the geni
SE major version is greater than 2 and geni SE minor version
is greater than 5.

This implementation fails when the version is 3 or greater.

Hence by adding the another check for geni SE major version,
this problem can be solved.

Signed-off-by: Paras Sharma 
---
 drivers/tty/serial/qcom_geni_serial.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/qcom_geni_serial.c 
b/drivers/tty/serial/qcom_geni_serial.c
index 3aa29d2..a9f92d8 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -995,7 +995,8 @@ static void qcom_geni_serial_set_termios(struct uart_port 
*uport,
sampling_rate = UART_OVERSAMPLING;
/* Sampling rate is halved for IP versions >= 2.5 */
ver = geni_se_get_qup_hw_version(>se);
-   if (GENI_SE_VERSION_MAJOR(ver) >= 2 && GENI_SE_VERSION_MINOR(ver) >= 5)
+   if ((GENI_SE_VERSION_MAJOR(ver) >= 2 && GENI_SE_VERSION_MINOR(ver) >= 5)
+   || GENI_SE_VERSION_MAJOR(ver) >= 3)
sampling_rate /= 2;
 
clk_rate = get_clk_div_rate(baud, sampling_rate, _div);
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation



[PATCH] tty: serial: qcom_geni_serial: To correct logic for QUP HW version

2020-07-24 Thread Paras Sharma
To correct the logic to detect whether the QUP HW version is greater
 than 2.5.

Signed-off-by: Paras Sharma 
---
 drivers/tty/serial/qcom_geni_serial.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/qcom_geni_serial.c 
b/drivers/tty/serial/qcom_geni_serial.c
index 1ed3d35..5b0efb49 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -954,7 +954,8 @@ static void qcom_geni_serial_set_termios(struct uart_port 
*uport,
sampling_rate = UART_OVERSAMPLING;
/* Sampling rate is halved for IP versions >= 2.5 */
ver = geni_se_get_qup_hw_version(>se);
-   if (GENI_SE_VERSION_MAJOR(ver) >= 2 && GENI_SE_VERSION_MINOR(ver) >= 5)
+   if ((GENI_SE_VERSION_MAJOR(ver) >= 2 && GENI_SE_VERSION_MINOR(ver) >= 5)
+   || GENI_SE_VERSION_MAJOR(ver) >= 3)
sampling_rate /= 2;
 
clk_rate = get_clk_div_rate(baud, sampling_rate, _div);
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation