All of lore.kernel.org
 help / color / mirror / Atom feed
From: Praveen Talari <quic_ptalari@quicinc.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	<linux-arm-msm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-serial@vger.kernel.org>, <devicetree@vger.kernel.org>,
	"Bryan O'Donoghue" <bryan.odonoghue@linaro.org>
Cc: <psodagud@quicinc.com>, <djaggi@quicinc.com>,
	<quic_msavaliy@quicinc.com>, <quic_vtanuku@quicinc.com>,
	<quic_arandive@quicinc.com>, <quic_mnaresh@quicinc.com>,
	<quic_shazhuss@quicinc.com>
Subject: Re: [PATCH v6 6/8] serial: qcom-geni: move clock-rate logic to separate function
Date: Mon, 16 Jun 2025 21:34:27 +0530	[thread overview]
Message-ID: <509c94bb-cf31-43bb-a92d-db006efd43aa@quicinc.com> (raw)
In-Reply-To: <20250606172114.6618-7-quic_ptalari@quicinc.com>

Hi Bryan,

Gentle reminder!!

Thanks,
Praveen Talari

On 6/6/2025 10:51 PM, Praveen Talari wrote:
> Facilitates future modifications within the new function,
> leading to better readability and maintainability of the code.
> 
> Move the code that handles the actual logic of clock-rate
> calculations to a separate function geni_serial_set_rate()
> which enhances code readability.
> 
> Signed-off-by: Praveen Talari <quic_ptalari@quicinc.com>
> ---
> v5 -> v6
> - used "unsigned int" instead of "unsigned long" in newly
>    added API function params to avoid the format specifier
>    warnings.
> 
> v3 -> v4
> - added version log after ---
> 
> v1 -> v2
> - resolved build warnings for datatype format specifiers
> - removed double spaces in log
> ---
>   drivers/tty/serial/qcom_geni_serial.c | 56 +++++++++++++++++----------
>   1 file changed, 36 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
> index 715db35bab2f..b6fa7dc9b1fb 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
> @@ -1283,27 +1283,14 @@ static unsigned long get_clk_div_rate(struct clk *clk, unsigned int baud,
>   	return ser_clk;
>   }
>   
> -static void qcom_geni_serial_set_termios(struct uart_port *uport,
> -					 struct ktermios *termios,
> -					 const struct ktermios *old)
> +static int geni_serial_set_rate(struct uart_port *uport, unsigned int baud)
>   {
> -	unsigned int baud;
> -	u32 bits_per_char;
> -	u32 tx_trans_cfg;
> -	u32 tx_parity_cfg;
> -	u32 rx_trans_cfg;
> -	u32 rx_parity_cfg;
> -	u32 stop_bit_len;
> -	unsigned int clk_div;
> -	u32 ser_clk_cfg;
>   	struct qcom_geni_serial_port *port = to_dev_port(uport);
>   	unsigned long clk_rate;
> -	u32 ver, sampling_rate;
>   	unsigned int avg_bw_core;
> -	unsigned long timeout;
> -
> -	/* baud rate */
> -	baud = uart_get_baud_rate(uport, termios, old, 300, 4000000);
> +	unsigned int clk_div;
> +	u32 ver, sampling_rate;
> +	u32 ser_clk_cfg;
>   
>   	sampling_rate = UART_OVERSAMPLING;
>   	/* Sampling rate is halved for IP versions >= 2.5 */
> @@ -1317,7 +1304,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
>   		dev_err(port->se.dev,
>   			"Couldn't find suitable clock rate for %u\n",
>   			baud * sampling_rate);
> -		return;
> +		return -EINVAL;
>   	}
>   
>   	dev_dbg(port->se.dev, "desired_rate = %u, clk_rate = %lu, clk_div = %u\n",
> @@ -1339,6 +1326,37 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
>   	port->se.icc_paths[CPU_TO_GENI].avg_bw = Bps_to_icc(baud);
>   	geni_icc_set_bw(&port->se);
>   
> +	writel(ser_clk_cfg, uport->membase + GENI_SER_M_CLK_CFG);
> +	writel(ser_clk_cfg, uport->membase + GENI_SER_S_CLK_CFG);
> +	return 0;
> +}
> +
> +static void qcom_geni_serial_set_termios(struct uart_port *uport,
> +					 struct ktermios *termios,
> +					 const struct ktermios *old)
> +{
> +	struct qcom_geni_serial_port *port = to_dev_port(uport);
> +	unsigned int baud;
> +	unsigned long timeout;
> +	u32 bits_per_char;
> +	u32 tx_trans_cfg;
> +	u32 tx_parity_cfg;
> +	u32 rx_trans_cfg;
> +	u32 rx_parity_cfg;
> +	u32 stop_bit_len;
> +	int ret = 0;
> +
> +	/* baud rate */
> +	baud = uart_get_baud_rate(uport, termios, old, 300, 4000000);
> +
> +	ret = geni_serial_set_rate(uport, baud);
> +	if (ret) {
> +		dev_err(port->se.dev,
> +			"%s: Failed to set baud:%u ret:%d\n",
> +			__func__, baud, ret);
> +		return;
> +	}
> +
>   	/* parity */
>   	tx_trans_cfg = readl(uport->membase + SE_UART_TX_TRANS_CFG);
>   	tx_parity_cfg = readl(uport->membase + SE_UART_TX_PARITY_CFG);
> @@ -1406,8 +1424,6 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
>   	writel(bits_per_char, uport->membase + SE_UART_TX_WORD_LEN);
>   	writel(bits_per_char, uport->membase + SE_UART_RX_WORD_LEN);
>   	writel(stop_bit_len, uport->membase + SE_UART_TX_STOP_BIT_LEN);
> -	writel(ser_clk_cfg, uport->membase + GENI_SER_M_CLK_CFG);
> -	writel(ser_clk_cfg, uport->membase + GENI_SER_S_CLK_CFG);
>   }
>   
>   #ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE

  reply	other threads:[~2025-06-16 16:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-06 17:21 [PATCH v6 0/8] Enable QUPs and Serial on SA8255p Qualcomm platforms Praveen Talari
2025-06-06 17:21 ` [PATCH v6 1/8] dt-bindings: serial: describe SA8255p Praveen Talari
2025-06-10  7:04   ` Krzysztof Kozlowski
2025-06-10  8:10     ` Praveen Talari
2025-06-11  7:17       ` Krzysztof Kozlowski
2025-06-11 14:12         ` Praveen Talari
2025-06-06 17:21 ` [PATCH v6 2/8] dt-bindings: qcom: geni-se: " Praveen Talari
2025-06-06 17:21 ` [PATCH v6 3/8] soc: qcom: geni-se: Enable QUPs on SA8255p Qualcomm platforms Praveen Talari
2025-06-16  8:40   ` Praveen Talari
2025-06-16 18:36     ` Bryan O'Donoghue
2025-06-17  1:52       ` Praveen Talari
2025-06-16 18:53   ` Bryan O'Donoghue
2025-06-20 10:59     ` Praveen Talari
2025-06-17 14:24   ` Bjorn Andersson
2025-06-06 17:21 ` [PATCH v6 4/8] serial: qcom-geni: move resource initialization to separate function Praveen Talari
2025-06-06 17:21 ` [PATCH v6 5/8] serial: qcom-geni: move resource control logic to separate functions Praveen Talari
2025-06-06 17:21 ` [PATCH v6 6/8] serial: qcom-geni: move clock-rate logic to separate function Praveen Talari
2025-06-16 16:04   ` Praveen Talari [this message]
2025-06-16 16:25     ` Krzysztof Kozlowski
2025-06-17 16:07     ` Bjorn Andersson
2025-06-26 15:57       ` Praveen Talari
2025-06-06 17:21 ` [PATCH v6 7/8] serial: qcom-geni: Enable PM runtime for serial driver Praveen Talari
2025-06-17 15:53   ` Bjorn Andersson
2025-06-20  9:34     ` Praveen Talari
2025-06-30  5:10     ` Praveen Talari
2025-06-30 11:32       ` Krzysztof Kozlowski
2025-07-01 11:12       ` Dmitry Baryshkov
2025-07-14 16:21         ` Praveen Talari
2025-07-15 12:30           ` Dmitry Baryshkov
2025-06-06 17:21 ` [PATCH v6 8/8] serial: qcom-geni: Enable Serial on SA8255p Qualcomm platforms Praveen Talari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=509c94bb-cf31-43bb-a92d-db006efd43aa@quicinc.com \
    --to=quic_ptalari@quicinc.com \
    --cc=andersson@kernel.org \
    --cc=bryan.odonoghue@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=djaggi@quicinc.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=psodagud@quicinc.com \
    --cc=quic_arandive@quicinc.com \
    --cc=quic_mnaresh@quicinc.com \
    --cc=quic_msavaliy@quicinc.com \
    --cc=quic_shazhuss@quicinc.com \
    --cc=quic_vtanuku@quicinc.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.