[spi-devel-general] [RFT PATCH] SuperH HSPI controller driver.

2008-07-21 Thread Manuel Lauss
Hello,

Here is a very simple driver for the HSPI block on many SuperH processors.
I could only subject it to limited testings, as my sole SPI device here is
a write-only 8bit digital poti.  It seems to do the right thing as far as
I could see on an oscilloscope.

The driver doesn't do DMA and pushes/pops bytes one-at-a-time from/to fifos
(I'm going to fix that at a later time).

Please test and comment!

Thanks,
Manuel Lauss

---

A simple driver for the HSPI block found on many SuperH processors.

Signed-off-by: Manuel Lauss [EMAIL PROTECTED]
---
 drivers/spi/Kconfig   |8 +
 drivers/spi/Makefile  |1 +
 drivers/spi/spi_hspi.c|  431 +
 include/asm-sh/spi_hspi.h |   13 ++
 4 files changed, 453 insertions(+), 0 deletions(-)
 create mode 100644 drivers/spi/spi_hspi.c
 create mode 100644 include/asm-sh/spi_hspi.h

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 66ec5d8..1154271 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -100,6 +100,14 @@ config SPI_BUTTERFLY
  inexpensive battery powered microcontroller evaluation board.
  This same cable can be used to flash new firmware.
 
+config SPI_HSPI
+   tristate SuperH on-chip HSPI controller
+   depends on SPI_MASTER  SUPERH
+   select SPI_BITBANG
+   help
+ Driver for the Hitachi HSPI controller core found on various
+ SuperH processors.
+
 config SPI_IMX
tristate Freescale iMX SPI controller
depends on SPI_MASTER  ARCH_IMX  EXPERIMENTAL
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 7fca043..3443855 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o
 obj-$(CONFIG_SPI_TXX9) += spi_txx9.o
 obj-$(CONFIG_SPI_XILINX)   += xilinx_spi.o
 obj-$(CONFIG_SPI_SH_SCI)   += spi_sh_sci.o
+obj-$(CONFIG_SPI_HSPI) += spi_hspi.o
 #  ... add above this line ...
 
 # SPI protocol drivers (device/link on bus)
diff --git a/drivers/spi/spi_hspi.c b/drivers/spi/spi_hspi.c
new file mode 100644
index 000..eb8f173
--- /dev/null
+++ b/drivers/spi/spi_hspi.c
@@ -0,0 +1,431 @@
+/*
+ * SuperH on-chip SPI (HSPI) controller driver.
+ *
+ * (c) 2008 Manuel Lauss [EMAIL PROTECTED]
+ *
+ * largely based on spi_s3c24xx.
+ *
+ * This program is licensed under the terms outlined in the file COPYING
+ * in the root of this archive.
+ */
+
+#include linux/init.h
+#include linux/io.h
+#include linux/spinlock.h
+#include linux/workqueue.h
+#include linux/interrupt.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/err.h
+#include linux/platform_device.h
+#include linux/spi/spi.h
+#include linux/spi/spi_bitbang.h
+
+#include asm/clock.h
+#include asm/spi_hspi.h
+
+#define SPCR   0x00/* control */
+#define SPSR   0x04/* status */
+#define SPSCR  0x08/* sys control */
+#define SPTBR  0x0c/* tx fifo port */
+#define SPRBR  0x10/* rx fifo port */
+
+#define SPCR_FBS   (1  7)/* CPHA */
+#define SPCR_CLKP  (1  6)/* CPOL */
+#define SPCR_IDIV  (1  5)/* clock prescaler: 4, 32*/
+#define SPCR_CLKMASK   0x1f
+
+#define SPSR_TXFU  (1  10)   /* tx fifo full */
+#define SPSR_TXHA  (1  9)/* tx fifo half */
+#define SPSR_TXEM  (1  8)/* tx fifo empty */
+#define SPSR_RXFU  (1  7)/* rx fifo full */
+#define SPSR_RXHA  (1  6)/* rx fifo half */
+#define SPSR_RXEM  (1  5)/* rx fifo empty */
+#define SPSR_RXOO  (1  4)/* rx overrun */
+#define SPSR_RXOW  (1  3)/* rx overrun warning */
+#define SPSR_RXFL  (1  2)/* new rx byte */
+#define SPSR_TXFN  (1  1)/* tx complete */
+#define SPSR_TXFL  (1  0)/* tx buffer not empty */
+
+#define SPSCR_TEIE (1  13)   /* tx fifo empty */
+#define SPSCR_THIE (1  12)   /* tx fifo half full */
+#define SPSCR_RNIE (1  11)   /* rx fifo not-empty */
+#define SPSCR_RHIE (1  10)   /* rx fifo half full */
+#define SPSCR_RFIE (1  9)/* rx fifo full */
+#define SPSCR_FFEN (1  8)/* fifo enable */
+#define SPSCR_LMSB (1  7)/* MSB/LSB first */
+#define SPSCR_CSV  (1  6)/* CS pin polarity */
+#define SPSCR_CSA  (1  5)/* auto CS control enable */
+#define SPSCR_TFIE (1  4)/* 1-byte-tx'ed int */
+#define SPSCR_ROIE (1  3)/* rx overflow ints */
+#define SPSCR_RXDE (1  2)/* rx dma enable */
+#define SPSCR_TXDE (1  1)/* tx dma enable */
+#define SPSCR_MASL (1  0)/* master(1) / slave(0) select */
+
+#define SPSCR_IMASK (SPSCR_TEIE | SPSCR_THIE | SPSCR_RNIE | SPSCR_RHIE | \
+SPSCR_RFIE | SPSCR_TFIE | SPSCR_ROIE)
+
+#define MODEBITS (SPI_CPOL | 

Re: [spi-devel-general] 5088/3: the SPI dependency

2008-07-21 Thread Guennadi Liakhovetski
David, what are your plans wrt SPI changes? I think the required patches 
(max7301) are already in -mm, can we merge them, please? It is a new 
driver, so should not make any damage.

Thanks
Guennadi

On Mon, 21 Jul 2008, Russell King - ARM Linux wrote:

 Since we are over a week into the merge window, and I see no sign of
 the SPI tree merging, it's time to make a decision on what to do about
 the outstanding changes in my tree which depend on the SPI tree having
 been merged first (iow, the presence of linux/spi/max7301.h.)
 
 One solution is to continue twiddling my thumbs waiting for the SPI
 tree to merge, which frankly is utterly boring and is just a waste of
 my time.
 
 Another solution is to back out the change, but that's extremely
 painful to do because soo much other stuff relies on that commit.
 
 Or we could commit a change on top of everything backing out the changes
 to pcm027.c which require the SPI tree to merge first, and have the bits
 which rely on max7301.h submitted later (which is, imho, what should've
 happened.)
 
 Or we could ignore the issue entirely and just merge the remaining
 changes.
 
 Unless I hear otherwise, I shall be intending to back out the troublesome
 changes to pcm027.c and merge that.
 
 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [spi-devel-general] [RFT PATCH] SuperH HSPI controller driver.

2008-07-21 Thread Paul Mundt
On Mon, Jul 21, 2008 at 11:07:44AM +0200, Manuel Lauss wrote:
 +out2:
 + release_resource(priv-ioarea);
 + kfree(priv-ioarea);

What is this kfree() for?

 +static int __devexit hspi_remove(struct platform_device *pdev)
 +{
 + struct hspi_priv *priv = platform_get_drvdata(pdev);
 +
 + spi_bitbang_stop(priv-bitbang);
 + iowrite32(0, priv-io + SPCR);
 + iowrite32(0, priv-io + SPSCR);
 + iowrite32(0, priv-io + SPSR);
 + free_irq(priv-irq, priv);
 + iounmap(priv-io);
 + release_resource(priv-ioarea);
 + kfree(priv-ioarea);

Likewise here.

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [spi-devel-general] [RFT PATCH] SuperH HSPI controller driver.

2008-07-21 Thread Manuel Lauss
On Mon, Jul 21, 2008 at 09:39:25PM +0900, Paul Mundt wrote:
 On Mon, Jul 21, 2008 at 11:07:44AM +0200, Manuel Lauss wrote:
  +out2:
  +   release_resource(priv-ioarea);
  +   kfree(priv-ioarea);
 
 What is this kfree() for?
 
  +static int __devexit hspi_remove(struct platform_device *pdev)
  +{
  +   struct hspi_priv *priv = platform_get_drvdata(pdev);
  +
  +   spi_bitbang_stop(priv-bitbang);
  +   iowrite32(0, priv-io + SPCR);
  +   iowrite32(0, priv-io + SPSCR);
  +   iowrite32(0, priv-io + SPSR);
  +   free_irq(priv-irq, priv);
  +   iounmap(priv-io);
  +   release_resource(priv-ioarea);
  +   kfree(priv-ioarea);
 
 Likewise here.

__request_region() kzalloc's a new struct resource and returns it;
release_resource doesn't free it.

Manuel Lauss

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general