From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 1/3] serial: sh-sci: Add OF support
Date: Mon, 04 Mar 2013 17:20:49 +0100 [thread overview]
Message-ID: <5345836.ZO7uU35cQD@wuerfel> (raw)
In-Reply-To: <1362414054-23092-1-git-send-email-hechtb+renesas@gmail.com>
On Monday 04 March 2013 17:20:52 Bastian Hecht wrote:
> diff --git a/Documentation/devicetree/bindings/tty/serial/renesas,sci-serial.txt b/Documentation/devicetree/bindings/tty/serial/renesas,sci-serial.txt
> new file mode 100644
> index 0000000..6ad1adf
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/tty/serial/renesas,sci-serial.txt
> @@ -0,0 +1,53 @@
> +* Renesas SH-Mobile Serial Communication Interface
> +
> +Required properties:
> +- compatible : Should be "renesas,sci-<port type>-uart", where <port type> may be
> + SCI, SCIF, IRDA, SCIFA or SCIFB.
Why capital letters here? Maybe just list
"renesas,sci-uart", "renesas,scif-uart", ...
> +- reg : Address and length of the register set for the device
> +- interrupts : Should contain the following IRQs: ERI, RXI, TXI and BRI.
You probably want to require the "interrupt-names" property as well
then.
> +- cell-index : The device id.
> +- renesas,scscr : Should contain a bitfield used by the Serial Control Register.
> + b7 = SCSCR_TIE
> + b6 = SCSCR_RIE
> + b5 = SCSCR_TE
> + b4 = SCSCR_RE
> + b3 = SCSCR_REIE
> + b2 = SCSCR_TOIE
> + b1 = SCSCR_CKE1
> + b0 = SCSCR_CKE0
> +- renesas,scbrr-algo-id : Algorithm ID for the Bit Rate Register
> + 1 = SCBRR_ALGO_1 ((clk + 16 * bps) / (16 * bps) - 1)
> + 2 = SCBRR_ALGO_2 ((clk + 16 * bps) / (32 * bps) - 1)
> + 3 = SCBRR_ALGO_3 (((clk * 2) + 16 * bps) / (16 * bps) - 1)
> + 4 = SCBRR_ALGO_4 (((clk * 2) + 16 * bps) / (32 * bps) - 1)
> + 5 = SCBRR_ALGO_5 (((clk * 1000 / 32) / bps) - 1)
Maybe replace this with a "clock-frequency" property? This may
be what the registers contain, but it is not very readable.
> +Optional properties:
> +- renesas,autoconf : Set if device is capable of auto configuration
> +- renesas,regtype : Overwrite the register layout. In most cases you can rely
> + on auto-probing (omit this property or set to 0) but some legacy devices
> + use a non-default register layout. Possible layouts are
> + 0 = SCIx_PROBE_REGTYPE (default)
> + 1 = SCIx_SCI_REGTYPE
> + 2 = SCIx_IRDA_REGTYPE
> + 3 = SCIx_SCIFA_REGTYPE
> + 4 = SCIx_SCIFB_REGTYPE
> + 5 = SCIx_SH2_SCIF_FIFODATA_REGTYPE
> + 6 = SCIx_SH3_SCIF_REGTYPE
> + 7 = SCIx_SH4_SCIF_REGTYPE
> + 8 = SCIx_SH4_SCIF_NO_SCSPTR_REGTYPE
> + 9 = SCIx_SH4_SCIF_FIFODATA_REGTYPE
> + 10 = SCIx_SH7705_SCIF_REGTYPE
Why do you keep these separate from the "compatible" property?
By definition, the register layout is already determined by
"compatible".
> +#ifdef CONFIG_OF
> +static const struct of_device_id of_sci_match[] = {
> + { .compatible = "renesas,sci-SCI-uart",
> + .data = (void *)PORT_SCI },
> + { .compatible = "renesas,sci-SCIF-uart",
> + .data = (void *)PORT_SCIF },
> + { .compatible = "renesas,sci-IRDA-uart",
> + .data = (void *)PORT_IRDA },
> + { .compatible = "renesas,sci-SCIFA-uart",
> + .data = (void *)PORT_SCIFA },
> + { .compatible = "renesas,sci-SCIFB-uart",
> + .data = (void *)PORT_SCIFB },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, of_sci_match);
> +
> +static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev,
> + int *dev_id)
> +{
> + struct plat_sci_port *p;
> + struct device_node *np = pdev->dev.of_node;
> + const struct of_device_id *match;
> + struct resource *res;
> + const __be32 *prop;
> + int i, irq, val;
> +
You can remove the #ifdef by replacing it with
if (!IS_ENABLED(CONFIG_OF) || !np)
return NULL;
here. This gives better compile time coverage and more readable code.
Otherwise looks very nice!
Arnd
next prev parent reply other threads:[~2013-03-04 16:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-04 16:20 [PATCH v4 1/3] serial: sh-sci: Add OF support Bastian Hecht
2013-03-04 16:20 ` Arnd Bergmann [this message]
2013-03-05 12:58 ` Bastian Hecht
2013-03-05 19:26 ` Arnd Bergmann
2013-03-06 0:50 ` Paul Mundt
2013-03-06 10:19 ` Bastian Hecht
2013-03-06 10:28 ` Arnd Bergmann
2013-03-04 16:20 ` [PATCH v4 2/3] ARM: mach-shmobile: r8a7740: Add DT names to clock list Bastian Hecht
2013-03-04 16:20 ` [PATCH v4 3/3] ARM: mach-shmobile: r8a7740: Setup the serial devices using DT Bastian Hecht
2013-03-04 16:22 ` Arnd Bergmann
2013-03-05 13:00 ` Bastian Hecht
2013-03-05 13:42 ` Sergei Shtylyov
2013-03-05 13:47 ` Bastian Hecht
2013-03-05 19:22 ` Arnd Bergmann
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=5345836.ZO7uU35cQD@wuerfel \
--to=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox