From: Jiri Slaby <jslaby@suse.cz>
To: Kevin Cernekee <cernekee@gmail.com>,
gregkh@linuxfoundation.org, robh@kernel.org
Cc: tushar.behera@linaro.org, daniel@zonque.org,
haojian.zhuang@gmail.com, robert.jarzmik@free.fr,
grant.likely@linaro.org, f.fainelli@gmail.com, mbizon@freebox.fr,
jogo@openwrt.org, linux-mips@linux-mips.org,
linux-serial@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH/RFC 3/8] of: Add helper function to check MMIO register endianness
Date: Wed, 12 Nov 2014 09:50:44 +0100 [thread overview]
Message-ID: <54631F64.8080009@suse.cz> (raw)
In-Reply-To: <1415781993-7755-4-git-send-email-cernekee@gmail.com>
On 11/12/2014, 09:46 AM, Kevin Cernekee wrote:
> SoC peripherals can come in several different flavors:
>
> - little-endian: registers always need to be accessed in LE mode (so the
> kernel should perform a swap if the CPU is running BE)
>
> - big-endian: registers always need to be accessed in BE mode (so the
> kernel should perform a swap if the CPU is running LE)
>
> - native-endian: the bus will automatically swap accesses, so the kernel
> should never swap
>
> Introduce a function that checks an OF device node to see whether it
> contains a "big-endian" or "native-endian" property. For the former case,
> always return 1. For the latter case, return 1 iff the kernel was built
> for BE (implying that the BE MMIO accessors do not perform a swap).
> Otherwise return 0, assuming LE registers.
>
> LE registers are assumed by default because most existing drivers (libahci,
> serial8250, usb) always use readl/writel in the absence of instructions
> to the contrary, so that will be our fallback.
>
> Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
> ---
> drivers/of/base.c | 23 +++++++++++++++++++++++
> include/linux/of.h | 6 ++++++
> 2 files changed, 29 insertions(+)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 3823edf..9dd494a 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -552,6 +552,29 @@ int of_device_is_available(const struct device_node *device)
> EXPORT_SYMBOL(of_device_is_available);
>
> /**
> + * of_device_is_big_endian - check if a device has BE registers
> + *
> + * @device: Node to check for availability
> + *
> + * Returns 1 if the device has a "big-endian" property, or if the kernel
> + * was compiled for BE *and* the device has a "native-endian" property.
> + * Returns 0 otherwise.
> + *
> + * Callers would nominally use ioread32be/iowrite32be if
> + * of_device_is_big_endian() == 1, or readl/writel otherwise.
> + */
> +int of_device_is_big_endian(const struct device_node *device)
> +{
> + if (of_property_read_bool(device, "big-endian"))
> + return 1;
> + if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
> + of_property_read_bool(device, "native-endian"))
> + return 1;
> + return 0;
> +}
This should actually return bool and use true/false.
--
js
suse labs
next prev parent reply other threads:[~2014-11-12 8:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-12 8:46 [PATCH/RFC 0/8] UART driver support for BMIPS multiplatform kernels Kevin Cernekee
2014-11-12 8:46 ` [PATCH/RFC 1/8] tty: Fallback to use dynamic major number Kevin Cernekee
2014-11-12 8:46 ` [PATCH/RFC 2/8] serial: core: Add big_endian flag Kevin Cernekee
2014-11-12 8:46 ` [PATCH/RFC 3/8] of: Add helper function to check MMIO register endianness Kevin Cernekee
2014-11-12 8:50 ` Jiri Slaby [this message]
2014-11-12 9:04 ` Kevin Cernekee
2014-11-12 9:23 ` Jiri Slaby
2014-11-12 8:46 ` [PATCH/RFC 4/8] serial: pxa: Add fifo-size and {big,native}-endian properties Kevin Cernekee
2014-11-12 9:02 ` Arnd Bergmann
2014-11-12 9:03 ` Jiri Slaby
2014-11-12 9:08 ` Arnd Bergmann
2014-11-12 8:46 ` [PATCH/RFC 5/8] serial: pxa: Make the driver buildable for BCM7xxx set-top platforms Kevin Cernekee
2014-11-12 9:04 ` Arnd Bergmann
2014-11-12 9:19 ` Kevin Cernekee
2014-11-13 9:42 ` Arnd Bergmann
2014-11-13 19:08 ` Kevin Cernekee
2014-11-13 22:34 ` Arnd Bergmann
2014-11-14 21:07 ` Robert Jarzmik
2014-11-14 21:07 ` Robert Jarzmik
2014-11-12 8:46 ` [PATCH/RFC 6/8] serial: pxa: Update DT binding documentation Kevin Cernekee
2014-11-12 8:46 ` [PATCH/RFC 7/8] serial: earlycon: Set uart_port->big_endian based on DT properties Kevin Cernekee
2014-11-12 8:46 ` [PATCH/RFC 8/8] serial: pxa: Add OF_EARLYCON support Kevin Cernekee
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=54631F64.8080009@suse.cz \
--to=jslaby@suse.cz \
--cc=cernekee@gmail.com \
--cc=daniel@zonque.org \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=grant.likely@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=haojian.zhuang@gmail.com \
--cc=jogo@openwrt.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-serial@vger.kernel.org \
--cc=mbizon@freebox.fr \
--cc=robert.jarzmik@free.fr \
--cc=robh@kernel.org \
--cc=tushar.behera@linaro.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.