Re: [PATCH 3/3] Serial: Separate out earlycon support

2020-12-07 Thread Greg KH
On Mon, Dec 07, 2020 at 05:52:32PM +0530, Akash Asthana wrote:
> Hi Greg,
> 
> On 12/7/2020 2:41 PM, Greg KH wrote:
> > On Mon, Dec 07, 2020 at 02:17:27PM +0530, Akash Asthana wrote:
> > > Separate out earlycon support from serial driver and remove it's
> > > dependency on QUP wrapper driver.
> > > 
> > > This enable us to manage earlycon independently and we can re-use the
> > > same earlycon driver for android project which currently uses
> > > downstream version of QUP drivers.
> > What do you mean by "downstream" here?
> > 
> > > Signed-off-by: Akash Asthana 
> > > ---
> > >   drivers/tty/serial/Kconfig  |   9 +
> > >   drivers/tty/serial/Makefile |   1 +
> > >   drivers/tty/serial/qcom_geni_earlycon.c | 649 
> > > 
> > >   drivers/tty/serial/qcom_geni_serial.c   |  97 -
> > So you are replacing 97 lines of code with 649 lines?  How is this
> > benefiting anyone?
> > 
> > confused,
> 
> We have 2 versions of QUP driver, upstream version(Present in linus tree,
> mostly used for chromium project) and downstream version(belong to vendor
> part of code in GKI design, used for all the other project).

Why do you have 2 different versions?  Why not merge them both into the
kernel tree?  That seems like madness to try to support 2.  And why
would we care about any out-of-tree code?  This is increasing our
complexity for code that isn't even being merged here, not anything you
would do if you were the maintainer of it, right?

> There is need to enable geni earlycon in Google provided boot image for GKI
> to facilitate the debug until real console(belong to vendor code) is up.

Then submit the code for that here please.

> Currently it won't be possible because geni earlycon cannot be enabled
> independently, it depends on upstream QUP wrapper driver
> (soc/qcom/qcom-geni-se.c) and upstream serial
> driver(serial/qcom_geni_serial.c).
> 
> With this patch I am trying to break any dependency btw earlycon hook and
> QUP kernel drivers, so it can be managed independently.

Please submit the code that depends on this change, and we will be glad
to review it.

thanks,

greg k-h


Re: [PATCH 3/3] Serial: Separate out earlycon support

2020-12-07 Thread Akash Asthana

Hi Greg,

On 12/7/2020 3:13 PM, Greg KH wrote:

On Mon, Dec 07, 2020 at 02:17:27PM +0530, Akash Asthana wrote:

Separate out earlycon support from serial driver and remove it's
dependency on QUP wrapper driver.

This enable us to manage earlycon independently and we can re-use the
same earlycon driver for android project which currently uses
downstream version of QUP drivers.

Signed-off-by: Akash Asthana 
---
  drivers/tty/serial/Kconfig  |   9 +
  drivers/tty/serial/Makefile |   1 +
  drivers/tty/serial/qcom_geni_earlycon.c | 649 
  drivers/tty/serial/qcom_geni_serial.c   |  97 -
  4 files changed, 659 insertions(+), 97 deletions(-)
  create mode 100644 drivers/tty/serial/qcom_geni_earlycon.c

Nit, your subject line shoudl say somewhere that this is the qcom
earlycon driver/support, not "earlycon in general".

Thanks for feedback, I will take care of it in next post.


thanks,

greg k-h


--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na 
Linux Foundation Collaborative Project



Re: [PATCH 3/3] Serial: Separate out earlycon support

2020-12-07 Thread Akash Asthana

Hi Greg,

On 12/7/2020 2:41 PM, Greg KH wrote:

On Mon, Dec 07, 2020 at 02:17:27PM +0530, Akash Asthana wrote:

Separate out earlycon support from serial driver and remove it's
dependency on QUP wrapper driver.

This enable us to manage earlycon independently and we can re-use the
same earlycon driver for android project which currently uses
downstream version of QUP drivers.

What do you mean by "downstream" here?


Signed-off-by: Akash Asthana 
---
  drivers/tty/serial/Kconfig  |   9 +
  drivers/tty/serial/Makefile |   1 +
  drivers/tty/serial/qcom_geni_earlycon.c | 649 
  drivers/tty/serial/qcom_geni_serial.c   |  97 -

So you are replacing 97 lines of code with 649 lines?  How is this
benefiting anyone?

confused,


We have 2 versions of QUP driver, upstream version(Present in linus 
tree, mostly used for chromium project) and downstream version(belong to 
vendor part of code in GKI design, used for all the other project).


There is need to enable geni earlycon in Google provided boot image for 
GKI to facilitate the debug until real console(belong to vendor code) is up.


Currently it won't be possible because geni earlycon cannot be enabled 
independently, it depends on upstream QUP wrapper driver 
(soc/qcom/qcom-geni-se.c) and upstream serial 
driver(serial/qcom_geni_serial.c).


With this patch I am trying to break any dependency btw earlycon hook 
and QUP kernel drivers, so it can be managed independently.


Regards,

Akash


--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na 
Linux Foundation Collaborative Project



Re: [PATCH 3/3] Serial: Separate out earlycon support

2020-12-07 Thread Greg KH
On Mon, Dec 07, 2020 at 02:17:27PM +0530, Akash Asthana wrote:
> Separate out earlycon support from serial driver and remove it's
> dependency on QUP wrapper driver.
> 
> This enable us to manage earlycon independently and we can re-use the
> same earlycon driver for android project which currently uses
> downstream version of QUP drivers.
> 
> Signed-off-by: Akash Asthana 
> ---
>  drivers/tty/serial/Kconfig  |   9 +
>  drivers/tty/serial/Makefile |   1 +
>  drivers/tty/serial/qcom_geni_earlycon.c | 649 
> 
>  drivers/tty/serial/qcom_geni_serial.c   |  97 -
>  4 files changed, 659 insertions(+), 97 deletions(-)
>  create mode 100644 drivers/tty/serial/qcom_geni_earlycon.c

Nit, your subject line shoudl say somewhere that this is the qcom
earlycon driver/support, not "earlycon in general".

thanks,

greg k-h


Re: [PATCH 3/3] Serial: Separate out earlycon support

2020-12-07 Thread Greg KH
On Mon, Dec 07, 2020 at 02:17:27PM +0530, Akash Asthana wrote:
> Separate out earlycon support from serial driver and remove it's
> dependency on QUP wrapper driver.
> 
> This enable us to manage earlycon independently and we can re-use the
> same earlycon driver for android project which currently uses
> downstream version of QUP drivers.

What do you mean by "downstream" here?

> 
> Signed-off-by: Akash Asthana 
> ---
>  drivers/tty/serial/Kconfig  |   9 +
>  drivers/tty/serial/Makefile |   1 +
>  drivers/tty/serial/qcom_geni_earlycon.c | 649 
> 
>  drivers/tty/serial/qcom_geni_serial.c   |  97 -

So you are replacing 97 lines of code with 649 lines?  How is this
benefiting anyone?

confused,

greg k-h


[PATCH 3/3] Serial: Separate out earlycon support

2020-12-07 Thread Akash Asthana
Separate out earlycon support from serial driver and remove it's
dependency on QUP wrapper driver.

This enable us to manage earlycon independently and we can re-use the
same earlycon driver for android project which currently uses
downstream version of QUP drivers.

Signed-off-by: Akash Asthana 
---
 drivers/tty/serial/Kconfig  |   9 +
 drivers/tty/serial/Makefile |   1 +
 drivers/tty/serial/qcom_geni_earlycon.c | 649 
 drivers/tty/serial/qcom_geni_serial.c   |  97 -
 4 files changed, 659 insertions(+), 97 deletions(-)
 create mode 100644 drivers/tty/serial/qcom_geni_earlycon.c

diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 3409e0b..393a017 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -957,6 +957,15 @@ config SERIAL_QCOM_GENI
depends on QCOM_GENI_SE
select SERIAL_CORE
 
+config SERIAL_QCOM_GENI_EARLYCON
+   bool "QCOM GENI Early Console support"
+   select SERIAL_CORE
+   select SERIAL_CORE_CONSOLE
+   select SERIAL_EARLYCON
+   help
+ Serial early console driver for Qualcomm Technologies Inc's GENI
+ based QUP hardware.
+
 config SERIAL_QCOM_GENI_CONSOLE
bool "QCOM GENI Serial Console support"
depends on SERIAL_QCOM_GENI
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index b85d53f..4f9c318 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o
 obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o
 obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o
 obj-$(CONFIG_SERIAL_MSM) += msm_serial.o
+obj-$(CONFIG_SERIAL_QCOM_GENI_EARLYCON) += qcom_geni_earlycon.o
 obj-$(CONFIG_SERIAL_QCOM_GENI) += qcom_geni_serial.o
 obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
 obj-$(CONFIG_SERIAL_ALTERA_UART) += altera_uart.o
diff --git a/drivers/tty/serial/qcom_geni_earlycon.c 
b/drivers/tty/serial/qcom_geni_earlycon.c
new file mode 100644
index 000..847cc7b
--- /dev/null
+++ b/drivers/tty/serial/qcom_geni_earlycon.c
@@ -0,0 +1,649 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2020, The Linux foundation. All rights reserved.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Common SE registers */
+#define GENI_FORCE_DEFAULT_REG 0x20
+#define GENI_FW_REVISION_RO0x68
+#define SE_GENI_DMA_MODE_EN0x258
+#define SE_GENI_M_CMD0 0x600
+#define SE_GENI_M_CMD_CTRL_REG 0x604
+#define SE_GENI_M_IRQ_STATUS   0x610
+#define SE_GENI_M_IRQ_EN   0x614
+#define SE_GENI_M_IRQ_CLEAR0x618
+#define SE_GENI_S_CMD0 0x630
+#define SE_GENI_S_CMD_CTRL_REG 0x634
+#define SE_GENI_S_IRQ_STATUS   0x640
+#define SE_GENI_S_IRQ_EN   0x644
+#define SE_GENI_S_IRQ_CLEAR0x648
+#define SE_GENI_TX_FIFOn   0x700
+#define SE_GENI_RX_FIFOn   0x780
+#define SE_GENI_TX_FIFO_STATUS 0x800
+#define SE_GENI_RX_FIFO_STATUS 0x804
+#define SE_GENI_TX_WATERMARK_REG   0x80c
+#define SE_GENI_RX_WATERMARK_REG   0x810
+#define SE_GENI_RX_RFR_WATERMARK_REG   0x814
+#define SE_DMA_TX_IRQ_CLR  0xc44
+#define SE_DMA_RX_IRQ_CLR  0xd44
+
+/* GENI_FORCE_DEFAULT_REG fields */
+#define FORCE_DEFAULT  BIT(0)
+
+/* GENI_FW_REVISION_RO fields */
+#define FW_REV_PROTOCOL_MSKGENMASK(15, 8)
+#define FW_REV_PROTOCOL_SHFT   8
+
+/* SE_GENI_DMA_MODE_EN */
+#define GENI_DMA_MODE_EN   BIT(0)
+
+/* GENI_M_CMD0 fields */
+#define M_OPCODE_MSK   GENMASK(31, 27)
+#define M_OPCODE_SHFT  27
+#define M_PARAMS_MSK   GENMASK(26, 0)
+
+/* GENI_M_CMD_CTRL_REG */
+#define M_GENI_CMD_CANCEL  BIT(2)
+#define M_GENI_CMD_ABORT   BIT(1)
+#define M_GENI_DISABLE BIT(0)
+
+/* GENI_S_CMD0 fields */
+#define S_OPCODE_MSK   GENMASK(31, 27)
+#define S_OPCODE_SHFT  27
+#define S_PARAMS_MSK   GENMASK(26, 0)
+
+/* GENI_S_CMD_CTRL_REG */
+#define S_GENI_CMD_CANCEL  BIT(2)
+#define S_GENI_CMD_ABORT   BIT(1)
+#define S_GENI_DISABLE BIT(0)
+
+/* GENI_M_IRQ_EN fields */
+#define M_CMD_DONE_EN  BIT(0)
+#define M_CMD_OVERRUN_EN   BIT(1)
+#define M_ILLEGAL_CMD_EN   BIT(2)
+#define M_CMD_FAILURE_EN   BIT(3)
+#define M_CMD_CANCEL_ENBIT(4)
+#define M_CMD_ABORT_EN BIT(5)
+#define M_TIMESTAMP_EN BIT(6)
+#define M_RX_IRQ_ENBIT(7)
+#define M_GP_SYNC_IRQ_0_EN BIT(8)
+#define M_GP_IRQ_0_EN  BIT(9)
+#define M_GP_IRQ_1_EN  BIT(10)
+#define M_GP_IRQ_2_EN  BIT(11)
+#define