From: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH 01/11] serial: Add support for Qualcomm serial port
Date: Wed, 16 Dec 2015 23:19:44 +0100 [thread overview]
Message-ID: <5671E380.4010707@gmail.com> (raw)
In-Reply-To: <CAPnjgZ3o7FGJnJb3sFWsqwyfT8jcoigMpNzKtdsYSp7UgQ6pTA@mail.gmail.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi Simon,
Thank you for awesome review!
I fully agree with most of the suggestions (for this and following patches),
so to keep it short will reply only to questions (or where I disagree)
On 15.12.2015 19:58, Simon Glass wrote:
> Hi Mateusz,
>
> On 10 December 2015 at 14:41, Mateusz Kulikowski
> <mateusz.kulikowski@gmail.com> wrote:
[...]
>> +static int msm_serial_getc(struct udevice *dev)
>> +{
>> + struct msm_serial_data *p = dev_get_priv(dev);
>> + unsigned sr;
>> + char c;
>> +
>> + /* There was something buffered */
>> + if (p->chars_cnt) {
>> + c = p->chars_buf & 0xFF;
>> + p->chars_buf >>= 8;
>> + p->chars_cnt--;
>> + return c;
>> + }
>> +
>> + /* Clear error in case of buffer overrun */
>> + if (readl(p->base + UARTDM_SR) & UARTDM_SR_UART_OVERRUN)
>> + writel(UARTDM_CR_CMD_RESET_ERR, p->base + UARTDM_CR);
>> +
>> + /* We need to fetch new character */
>> + sr = readl(p->base + UARTDM_SR);
>> +
>> + /* There are at least 4 bytes in fifo */
>> + if (sr & UARTDM_SR_RX_READY) {
>> + p->chars_buf = readl(p->base + UARTDM_RF);
>> + c = p->chars_buf & 0xFF;
>> + p->chars_cnt = 3; /* 4 - one read */
>> + p->chars_buf >>= 8;
>> + return c;
>> + }
>> +
>> + /* Check if there is anything in fifo */
>> + p->chars_cnt = readl(p->base + UARTDM_RXFS);
>> + /* Extract number of characters in UART packing buffer */
>> + p->chars_cnt = (p->chars_cnt >> UARTDM_RXFS_BUF_SHIFT) &
>> + UARTDM_RXFS_BUF_MASK;
>> + if (!p->chars_cnt)
>> + return -EAGAIN;
>> +
>> + /* There is at least one charcter, move it to fifo */
>> + writel(UARTDM_CR_CMD_FORCE_STALE, p->base + UARTDM_CR);
>> +
>> + p->chars_buf = readl(p->base + UARTDM_RF);
>> + writel(UARTDM_CR_CMD_RESET_STALE_INT, p->base + UARTDM_CR);
>> + writel(0xFFFFFF, p->base + UARTDM_DMRX);
>> +
>> + c = p->chars_buf & 0xFF;
>> + p->chars_buf >>= 8;
>> + p->chars_cnt--;
>
> Can you not rationalise this code a bit? E.g.
>
> if (no chars in fifo) {
> try to get some
> }
> if (no chars in fifo)
> return -EAGAIN
> extract char from fifo
> return ch;
>
> You seem to have three copies of the same code.
That is good idea.
Just be warned that "try to get some" will have most of the current code inside.
Reason: Characters from FIFO are packed into 32-bit register.
There are different ways for extracting >=4 chars, and <4 chars.
>
>> + uclass_get_device_by_of_offset(UCLASS_CLK, clkd[0], &clk);
>
> Check return value. -ENODEV means there is no clk. Is it OK to have no clock?
>
>> + if (clk)
>> + clk_set_periph_rate(clk, clkd[1], clk_rate);
>
> If is OK to
Of course will check ret value;
For now (at least when it comes to default UART) it's OK not to have clock,
as U-Boot is chain-loaded from fastboot, but this will change once I get rid
of fastboot dependency.
[...]
>> + .ofdata_to_platdata = msm_serial_ofdata_to_platdata,
>> + .priv_auto_alloc_size = sizeof(struct msm_serial_data),
>> + .probe = msm_serial_probe,
>> + .ops = &msm_serial_ops,
>> + .flags = DM_FLAG_PRE_RELOC,
>
> Do you need this? You can specify this with u-boot,dm-pre-reloc in the
> device tree.
Probably not, as I do it in dts :)
Regards,
Mateusz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQEcBAEBCAAGBQJWceN5AAoJELvtohmVtQzBvvkH/21bJ573Y+MwKoFeezuupO9p
/kmLNmJ3hNYFjoLv837wW2zNqrbyu5SLnM/Udm8ttbqBcbXWZUIjLhdHZLxGhXiR
X0Zu/yXncb4MRua8QvTpsuuPlEHWqFsLc0XCYzgelwllbkhmC4430HDXuyEdY8+F
iHhuDRTnRdvfUmby4VGwGCoAmpcn30TEcbyffjSnGjXTd+SQ3Vi/sHY+0qTIpSVS
QRWwnQX3WqC0hK6nleLaNXymVzarZANzhMgP6G/aAiPk7GKvExZYJ5Ilko+Iewns
z/bF0FX8bUXU/Yq4opgaTNQlcifQqjr8QIUqbEnSQNHVynoP3FAZj0dsZUVrJ28=
=Nj9Z
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2015-12-16 22:19 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-10 21:41 [U-Boot] [RFC PATCH 00/11] Add support for 96boards Dragonboard410C board Mateusz Kulikowski
2015-12-10 21:41 ` [U-Boot] [RFC PATCH 01/11] serial: Add support for Qualcomm serial port Mateusz Kulikowski
2015-12-15 18:58 ` Simon Glass
2015-12-16 22:19 ` Mateusz Kulikowski [this message]
2015-12-21 6:50 ` Masahiro Yamada
2015-12-22 20:23 ` Simon Glass
2015-12-23 3:52 ` Masahiro Yamada
2015-12-27 16:51 ` Mateusz Kulikowski
2015-12-28 17:09 ` Masahiro Yamada
2015-12-28 4:29 ` Simon Glass
2015-12-28 17:13 ` Masahiro Yamada
2015-12-10 21:41 ` [U-Boot] [RFC PATCH 02/11] gpio: Add support for Qualcomm gpio controller Mateusz Kulikowski
2015-12-15 18:58 ` Simon Glass
2015-12-10 21:41 ` [U-Boot] [RFC PATCH 03/11] mmc: Add support for Qualcomm SDHCI controller Mateusz Kulikowski
2015-12-15 18:58 ` Simon Glass
2015-12-16 22:46 ` Mateusz Kulikowski
2015-12-18 22:41 ` Simon Glass
2015-12-19 11:21 ` Mateusz Kulikowski
2015-12-10 21:41 ` [U-Boot] [RFC PATCH 04/11] ehci-hcd: Add init_after_reset Mateusz Kulikowski
2015-12-10 23:14 ` Marek Vasut
2015-12-16 22:30 ` Tom Rini
2015-12-10 21:41 ` [U-Boot] [RFC PATCH 05/11] ehci: Add support for Qualcomm EHCI Mateusz Kulikowski
2015-12-10 23:22 ` Marek Vasut
2015-12-13 12:38 ` Mateusz Kulikowski
2015-12-13 15:48 ` Marek Vasut
2015-12-16 22:51 ` Mateusz Kulikowski
2015-12-10 21:41 ` [U-Boot] [RFC PATCH 06/11] drivers: Add SPMI bus uclass Mateusz Kulikowski
2015-12-15 18:58 ` Simon Glass
2015-12-16 23:09 ` Mateusz Kulikowski
2015-12-10 21:41 ` [U-Boot] [RFC PATCH 07/11] drivers: spmi: Add support for Qualcomm SPMI bus driver Mateusz Kulikowski
2015-12-10 21:41 ` [U-Boot] [RFC PATCH 08/11] pmic: Add support for Qualcomm PM8916 PMIC Mateusz Kulikowski
2015-12-15 18:58 ` Simon Glass
2015-12-10 21:41 ` [U-Boot] [RFC PATCH 09/11] gpio: Add support for Qualcomm PM8916 gpios Mateusz Kulikowski
2015-12-15 18:58 ` Simon Glass
2015-12-10 21:41 ` [U-Boot] [RFC PATCH 10/11] arm: Add support for Qualcomm Snapdragon family Mateusz Kulikowski
2015-12-16 22:29 ` Simon Glass
2015-12-19 12:12 ` Mateusz Kulikowski
2015-12-10 21:41 ` [U-Boot] [RFC PATCH 11/11] board: Add Qualcomm Dragonboard 410C support Mateusz Kulikowski
2015-12-16 22:29 ` Simon Glass
2015-12-19 12:24 ` Mateusz Kulikowski
2015-12-19 20:29 ` Simon Glass
2015-12-15 18:57 ` [U-Boot] [RFC PATCH 00/11] Add support for 96boards Dragonboard410C board sk.syed2
2015-12-15 21:25 ` Mateusz Kulikowski
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=5671E380.4010707@gmail.com \
--to=mateusz.kulikowski@gmail.com \
--cc=u-boot@lists.denx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox