From: Pavel Machek <pavel@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/6] spi: Add designware master SPI DM driver used on SoCFPGA
Date: Wed, 12 Nov 2014 18:51:42 +0100 [thread overview]
Message-ID: <20141112175142.GC30963@amd> (raw)
In-Reply-To: <1415364634-8290-4-git-send-email-sr@denx.de>
Hi!
You tripped my spell-checker, sorry.
> This patch adds the driver for the Designware master SPI controller. This
> IP core is integrated on the Altera SoCFPGA. This implementation is a
> driver model (DM) implementation. So multiple SPI drivers can be used.
> Thats necessary, since SoCFPGA also integrates the Cadence QSPI controller
> used to connect the SPI NOR flashes. Without DM, using multiple SPI
> driver is not possible.
drivers.
> This driver is very loosly based on the Linux driver. Most of the
loosely?
> driver is removed. Only the polling loop for the transfer is really used
> from this driver. As we don't support interrupts and DMA right now.
, as
> + * Very loosly based on the Linux driver version which is:
loosely. (And citing filename here might be useful.)
> +
> +/* Register offsets */
> +#define DW_SPI_CTRL0 0x00
> +#define DW_SPI_CTRL1 0x04
> +#define DW_SPI_SSIENR 0x08
> +#define DW_SPI_MWCR 0x0c
> +#define DW_SPI_SER 0x10
> +#define DW_SPI_BAUDR 0x14
> +#define DW_SPI_TXFLTR 0x18
> +#define DW_SPI_RXFLTR 0x1c
> +#define DW_SPI_TXFLR 0x20
> +#define DW_SPI_RXFLR 0x24
> +#define DW_SPI_SR 0x28
> +#define DW_SPI_IMR 0x2c
> +#define DW_SPI_ISR 0x30
> +#define DW_SPI_RISR 0x34
> +#define DW_SPI_TXOICR 0x38
> +#define DW_SPI_RXOICR 0x3c
> +#define DW_SPI_RXUICR 0x40
> +#define DW_SPI_MSTICR 0x44
> +#define DW_SPI_ICR 0x48
> +#define DW_SPI_DMACR 0x4c
> +#define DW_SPI_DMATDLR 0x50
> +#define DW_SPI_DMARDLR 0x54
> +#define DW_SPI_IDR 0x58
> +#define DW_SPI_VERSION 0x5c
> +#define DW_SPI_DR 0x60
Any chance to convert this to structure?
> +#define RX_TIMEOUT 1000
comment with units would be welcome.
> +
> +struct dw_spi_platdata {
> + s32 frequency; /* Default clock frequency, -1 for none */
> + void __iomem *regs;
> +};
> +
> +struct dw_spi_priv {
> + void __iomem *regs;
> + unsigned int freq; /* Default frequency */
> + unsigned int mode;
> +
> + int bits_per_word;
> + u8 cs; /* chip select pin */
> + u8 n_bytes; /* current is a 1/2/4 byte op */
> + u8 tmode; /* TR/TO/RO/EEPROM */
> + u8 type; /* SPI/SSP/MicroWire */
> + int len;
Having both n_bytes and len is "interesting". Turn n_bytes into
"word_size"?
> +static int dw_spi_probe(struct udevice *bus)
> +{
> + struct dw_spi_platdata *plat = dev_get_platdata(bus);
> + struct dw_spi_priv *priv = dev_get_priv(bus);
> +
> + priv->regs = plat->regs;
> + priv->freq = plat->frequency;
> +
> + /* Currently only bits_per_word == 8 supported */
> + priv->bits_per_word = 8;
> + priv->n_bytes = 1;
n_bytes -> bytes_per_word? Why we have two variables for same
information?
> + /*
> + * Another concern is about the tx/rx mismatch, we
> + * though to use (priv->fifo_len - rxflr - txflr) as
"thought about using"?
> + while (max--) {
> + rxw = dw_readw(priv, DW_SPI_DR);
> + debug("%s: rx=0x%02x\n", __func__, rxw);
> + /* Care rx only if the transfer's original "rx" is not null */
"Care about"?
> +
> + /* spi core configured to do 8 bit transfers */
"core is"?
Thanks,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
next prev parent reply other threads:[~2014-11-12 17:51 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-07 12:50 [U-Boot] [PATCH 0/6] arm: socfpga: Add Designware SPI support Stefan Roese
2014-11-07 12:50 ` [U-Boot] [PATCH 1/6] arm: socfpga: Add DW master SPI clock to clock_manager.c Stefan Roese
2014-11-07 15:08 ` Marek Vasut
2014-11-12 17:41 ` Pavel Machek
2014-11-07 12:50 ` [U-Boot] [PATCH 2/6] arm: socfpga: Add socfpga_spim_enable() to reset_manager.c Stefan Roese
2014-11-12 17:42 ` Pavel Machek
2014-11-16 10:47 ` Stefan Roese
2014-11-07 12:50 ` [U-Boot] [PATCH 3/6] spi: Add designware master SPI DM driver used on SoCFPGA Stefan Roese
2014-11-07 15:12 ` Marek Vasut
2014-11-07 18:01 ` Simon Glass
2014-11-12 17:51 ` Pavel Machek [this message]
2014-11-14 20:16 ` Marek Vasut
2014-11-15 13:33 ` Stefan Roese
2014-11-15 14:40 ` Marek Vasut
2014-11-07 12:50 ` [U-Boot] [PATCH 4/6] arm: socfpga: dts: Add spi0/1 dts nodes for the Designware master SPI devices Stefan Roese
2014-11-12 17:52 ` Pavel Machek
2014-11-07 12:50 ` [U-Boot] [PATCH 5/6] arm: socfpga: dts: socrates: Add spi1/2 aliases needed DM SPI probing Stefan Roese
2014-11-12 17:52 ` Pavel Machek
2014-11-07 12:50 ` [U-Boot] [PATCH 6/6] arm: socfpga: Add Designware (DW) SPI support to config header Stefan Roese
2014-11-12 17:53 ` Pavel Machek
2014-11-14 20:18 ` Marek Vasut
2014-11-15 13:35 ` Stefan Roese
2014-11-15 14:40 ` Marek Vasut
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=20141112175142.GC30963@amd \
--to=pavel@denx.de \
--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