From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Thu, 24 Dec 2015 12:55:55 +0100 Subject: [U-Boot] [PATCH v3 3/4] mips: ath79: add spi driver In-Reply-To: References: <1450956123-17606-1-git-send-email-wills.wang@live.com> Message-ID: <201512241255.55314.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thursday, December 24, 2015 at 12:22:02 PM, Wills Wang wrote: > Signed-off-by: Wills Wang > --- [...] > diff --git a/drivers/spi/ath79_spi.c b/drivers/spi/ath79_spi.c > new file mode 100644 > index 0000000..ddfc807 > --- /dev/null > +++ b/drivers/spi/ath79_spi.c > @@ -0,0 +1,211 @@ > +/* > + * (C) Copyright 2015 > + * Wills Wang, > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* CLOCK_DIVIDER = 3 (SPI clock = 200 / 8 ~ 25 MHz) */ > +#define SPI_CLK_DIV(x) ((x >> 1) - 1) The x needs parenthesis ... (((x) >> 1) - 1) > + > +struct ath79_spi_platdata { > + void __iomem *regs; > +}; > + > +struct ath79_spi_priv { > + void __iomem *regs; > +}; > + > +static inline u32 ath79_spi_read(struct udevice *bus, u32 offset) > +{ > + struct ath79_spi_priv *priv = dev_get_priv(bus); > + const void __iomem *base = (void __iomem *)KSEG1ADDR(priv->regs); > + return readl(base + offset); Just make this readl(KSEG1ADDR(...)) ? > +} > + > +static inline void ath79_spi_write(struct udevice *bus, u32 val, > + u32 offset) > +{ > + struct ath79_spi_priv *priv = dev_get_priv(bus); > + const void __iomem *base = (void __iomem *)KSEG1ADDR(priv->regs); > + writel(val, base + offset); DTTO here. [...]