Skip to contentSkip to conversation

Freescale STMP spi driver

PATCH In review dmitry pervushin 3 participants 8 messages Jun 2, 2009 – Jul 7, 2009 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Freescale STMP spi driver

Hello David,

Here is the patch for SSP/SPI on STMP3xxx boards; could you please apply it? Any comments are appreciated.
=========================================================================

The patch adds support of SSP ports in SPI mode on Freescale STMP3xxx platforms.

drivers/spi/Kconfig +6 -0
Index: linux-2.6-arm/drivers/spi/Kconfig
===================================================================
@@ -204,6 +204,12 @@ config SPI_SH_SCI
 	help
 	  SPI driver for SuperH SCI blocks.
 
+config SPI_STMP3XXX
+	tristate "Freescale STMP37xx/378x SPI/SSP controller"
+	depends on ARCH_STMP3XXX && SPI_MASTER
+	help
+	  SPI driver for Freescale STMP37xx/378x SoC SSP interface
+
 config SPI_TXX9
 	tristate "Toshiba TXx9 SPI controller"
 	depends on GENERIC_GPIO && CPU_TX49XX
drivers/spi/Makefile +1 -0
Index: linux-2.6-arm/drivers/spi/Makefile
===================================================================
@@ -30,6 +30,7 @@ obj-$(CONFIG_SPI_S3C24XX)		+= spi_s3c24x
 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_STMP3XXX)		+= spi_stmp.o
 # 	... add above this line ...
 
 # SPI protocol drivers (device/link on bus)
drivers/spi/spi_stmp.c new file +655 -0

655 lines not on this page · raw message

drivers/spi/spi_stmp.h new file +45 -0

45 lines not on this page · raw message

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hi dmitry,

Quoted 15 lines · dmitry pervushin

Hello David,

Here is the patch for SSP/SPI on STMP3xxx boards; could you please apply it? Any comments are appreciated.
=========================================================================

...

drivers/spi/spi_stmp.c new file +7 -0
+/* the spi->mode bits understood by this driver: */
+#define MODEBITS (SPI_CPOL | SPI_CPHA)
+static int stmp_spi_setup(struct spi_device *spi)
+{
+	struct stmp_spi *ss;
+
+	ss = spi_master_get_devdata(spi->master);

drivers/spi/spi_stmp.c line 169

Quoted 10 lines
drivers/spi/spi_stmp.c new file +10 -0
+	if (!spi->bits_per_word)
+		spi->bits_per_word = 8;
+	if (spi->mode & ~MODEBITS) {
+		dev_err(&spi->dev, "%s: unsupported mode bits %x\n",
+			__func__, spi->mode & ~MODEBITS);
+		return -EINVAL;
+	}
+	dev_dbg(&spi->dev, "%s, mode %d, %u bits/w\n",
+		__func__, spi->mode & MODEBITS, spi->bits_per_word);
+	return stmp_spi_setup_transfer(spi, NULL);

This might trash running SPI transfers. The setup() method must not touch hardware registers.

drivers/spi/spi_stmp.h

Quoted 6 lines

...

Index: linux-2.6-arm/drivers/spi/spi_stmp.h
===================================================================

drivers/spi/spi_stmp.h new file +0 -0

No need for a separate .h file here, IMO. The stmp_spi struct should go into stmp_spi.c.

Quoted 36 lines
drivers/spi/spi_stmp.h new file +35 -0
@@ -0,0 +1,45 @@
+/*
+ * Freescale STMP378X SPI master driver
+ *
+ * Author: dmitry pervushin <dimka-L1vi/lXTdtvkgf6YlCu6wwC/[email protected]>
+ *
+ * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
+ */
+
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+#ifndef __SPI_STMP_H
+#define __SPI_STMP_H
+
+struct stmp_spi {
+	int		id;
+
+	void *  __iomem regs;	/* vaddr of the control registers */
+
+	u32		irq;
+	u32		dma;
+	struct stmp3xxx_dma_descriptor d;
+
+	u32		speed_khz;
+	u32		saved_timings;
+	u32		divider;
+
+	struct clk	*clk;
+	struct device	*master_dev;

drivers/spi/spi_stmp.h line 45

Quoted 10 lines
drivers/spi/spi_stmp.h new file +10 -0
+
+	struct work_struct work;
+	struct workqueue_struct *workqueue;
+	spinlock_t lock;
+	struct list_head queue;
+
+	struct completion done;
+};
+
+#endif /* __SPI_STMP_H */

baruch

Signature · 10 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
#3 lore raw

PATCH 1/1 Freescale STMP spi driver, revised

Thanks Baruch for reviewing the patch, here is the updated one:

Add the SPI driver for Freescale STMP 3xxx-based boards

drivers/spi/Kconfig +6 -0
Index: linux-2.6-arm/drivers/spi/Kconfig
===================================================================
@@ -204,6 +204,12 @@ config SPI_SH_SCI
 	help
 	  SPI driver for SuperH SCI blocks.
 
+config SPI_STMP3XXX
+	tristate "Freescale STMP37xx/378x SPI/SSP controller"
+	depends on ARCH_STMP3XXX && SPI_MASTER
+	help
+	  SPI driver for Freescale STMP37xx/378x SoC SSP interface
+
 config SPI_TXX9
 	tristate "Toshiba TXx9 SPI controller"
 	depends on GENERIC_GPIO && CPU_TX49XX
drivers/spi/Makefile +1 -0
Index: linux-2.6-arm/drivers/spi/Makefile
===================================================================
@@ -30,6 +30,7 @@ obj-$(CONFIG_SPI_S3C24XX)		+= spi_s3c24x
 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_STMP3XXX)		+= spi_stmp.o
 # 	... add above this line ...
 
 # SPI protocol drivers (device/link on bus)
drivers/spi/spi_stmp.c new file +676 -0

676 lines not on this page · raw message

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Re: [PATCH] Freescale STMP spi driver, revised

Quoted 3 lines · dmitry pervushin

Add the SPI driver for Freescale STMP 3xxx-based boards

Needs the appended fixups for current kernels ...
technical comments in a bit.

- Dave

drivers/spi/spi_stmp.c +8 -12
@@ -171,22 +171,16 @@ static int stmp_spi_setup_transfer(struc
 	return 0;
 }
 
-/* the spi->mode bits understood by this driver: */
-#define MODEBITS (SPI_CPOL | SPI_CPHA)
 static int stmp_spi_setup(struct spi_device *spi)
 {
-	struct stmp_spi *ss;
-
-	ss = spi_master_get_devdata(spi->master);
-	if (!spi->bits_per_word)
-		spi->bits_per_word = 8;
-	if (spi->mode & ~MODEBITS) {
-		dev_err(&spi->dev, "%s: unsupported mode bits %x\n",
-			__func__, spi->mode & ~MODEBITS);
+	/* spi_setup() does basic checks,
+	 * stmp_spi_setup_transfer() does more later
+	 */
+	if (spi->bits_per_word != 8) {
+		dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
+			__func__, bits_per_word);
 		return -EINVAL;
 	}
-	dev_dbg(&spi->dev, "%s, mode %d, %u bits/w\n",
-		__func__, spi->mode & MODEBITS, spi->bits_per_word);
 	return 0;
 }
 
@@ -497,6 +491,8 @@ static int __devinit stmp_spi_probe(stru
 	master->transfer = stmp_spi_transfer;
 	master->setup = stmp_spi_setup;
 
+	/* the spi->mode bits understood by this driver: */
+	master->mode_bits = SPI_CPOL | SPI_CPHA;
 
 	ss->irq = platform_get_irq(dev, 0);
 	if (ss->irq < 0) {

------------------------------------------------------------------------------

A message that is not in the archive (sent off-list or not yet received): 200907022147.44892.david-b-yBeKhBN/[email protected]

#7 lore raw

Re: [PATCH] Freescale STMP spi driver, revised

Thanks for your attention; I tested the change on the board and the updated patch is in the following message.

Quoted 44 lines · David Brownell
Quoted 3 lines · dmitry pervushin

Add the SPI driver for Freescale STMP 3xxx-based boards

Needs the appended fixups for current kernels ...
technical comments in a bit.

- Dave

drivers/spi/spi_stmp.c +6 -12
@@ -171,22 +171,16 @@ static int stmp_spi_setup_transfer(struc
 	return 0;
 }
 
-/* the spi->mode bits understood by this driver: */
-#define MODEBITS (SPI_CPOL | SPI_CPHA)
 static int stmp_spi_setup(struct spi_device *spi)
 {
-	struct stmp_spi *ss;
-
-	ss = spi_master_get_devdata(spi->master);
-	if (!spi->bits_per_word)
-		spi->bits_per_word = 8;
-	if (spi->mode & ~MODEBITS) {
-		dev_err(&spi->dev, "%s: unsupported mode bits %x\n",
-			__func__, spi->mode & ~MODEBITS);
+	/* spi_setup() does basic checks,
+	 * stmp_spi_setup_transfer() does more later
+	 */
+	if (spi->bits_per_word != 8) {
+		dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
+			__func__, bits_per_word);
 		return -EINVAL;
 	}
-	dev_dbg(&spi->dev, "%s, mode %d, %u bits/w\n",
-		__func__, spi->mode & MODEBITS, spi->bits_per_word);
 	return 0;
 }
 

drivers/spi/spi_stmp.c static int __devinit stmp_spi_probe(stru · line 498

Quoted 8 lines
drivers/spi/spi_stmp.c +2 -0
@@ -497,6 +491,8 @@ static int __devinit stmp_spi_probe(stru
 	master->transfer = stmp_spi_transfer;
 	master->setup = stmp_spi_setup;
 
+	/* the spi->mode bits understood by this driver: */
+	master->mode_bits = SPI_CPOL | SPI_CPHA;
 
 	ss->irq = platform_get_irq(dev, 0);
 	if (ss->irq < 0) {

------------------------------------------------------------------------------

#8 lore raw

Re: [PATCH] Freescale STMP spi driver - take 3

In reply to a message not in the archive

Add the SPI driver for Freescale STMP 3xxx-based boards

---
 drivers/spi/Kconfig    |    6 
 drivers/spi/Makefile   |    1 
 drivers/spi/spi_stmp.c |  672 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 679 insertions(+)
drivers/spi/Kconfig +6 -0
Index: linux-2.6-arm/drivers/spi/Kconfig
===================================================================
@@ -213,6 +213,12 @@ config SPI_SH_SCI
 	help
 	  SPI driver for SuperH SCI blocks.
 
+config SPI_STMP3XXX
+	tristate "Freescale STMP37xx/378x SPI/SSP controller"
+	depends on ARCH_STMP3XXX && SPI_MASTER
+	help
+	  SPI driver for Freescale STMP37xx/378x SoC SSP interface
+
 config SPI_TXX9
 	tristate "Toshiba TXx9 SPI controller"
 	depends on GENERIC_GPIO && CPU_TX49XX
drivers/spi/Makefile +1 -0
Index: linux-2.6-arm/drivers/spi/Makefile
===================================================================
@@ -31,6 +31,7 @@ obj-$(CONFIG_SPI_S3C24XX)		+= spi_s3c24x
 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_STMP3XXX)		+= spi_stmp.o
 # 	... add above this line ...
 
 # SPI protocol drivers (device/link on bus)
drivers/spi/spi_stmp.c new file +672 -0

672 lines not on this page · raw message

------------------------------------------------------------------------------

#9 lore raw

Re: [PATCH] Freescale STMP spi driver, revised

In reply to a message not in the archive

drivers/spi/spi_stmp.c line 66

Quoted 4 lines · dmitry pervushin
drivers/spi/spi_stmp.c new file +4 -0
+#define busy_wait(cond)						\
+	({							\
+	  int count;						\
+	  for (count = 1000; (cond) && count > 0; count--)	\

Where does the "1000" come from?

Quoted 52 lines
drivers/spi/spi_stmp.c new file +50 -0
+		  cpu_relax();					\
+	  (count);						\
+	})
 
 
+static int stmp_spi_setup_transfer(struct spi_device *spi,
+		struct spi_transfer *t)
+{
+	u8 bits_per_word;
+	u32 hz;
+	struct stmp_spi *ss = spi_master_get_devdata(spi->master);
+	u16 rate;
+
+	bits_per_word = spi->bits_per_word;
+	if (t && t->bits_per_word)
+		bits_per_word = t->bits_per_word;
+
+	/*
+	  Calculate speed:
+		- by default, use maximum speed from ssp clk
+		- if device overrides it, use it
+		- if transfer specifies other speed, use transfer's one
+	 */
+	hz = 1000 * ss->speed_khz / ss->divider;
+	if (spi->max_speed_hz)
+		hz = min(hz, spi->max_speed_hz);
+	if (t && t->speed_hz)
+		hz = min(hz, t->speed_hz);
+
+	if (hz == 0) {
+		dev_err(&spi->dev, "Cannot continue with zero clock\n");
+		return -EINVAL;
+	}
+
+	if (bits_per_word != 8) {
+		dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
+			__func__, bits_per_word);
+		return -EINVAL;
+	}
+
+	dev_dbg(&spi->dev, "Requested clk rate = %uHz, max = %uHz/%d = %uHz\n",
+		hz, ss->speed_khz, ss->divider,
+		ss->speed_khz * 1000 / ss->divider);
+
+	if (ss->speed_khz * 1000 / ss->divider < hz) {
+		dev_err(&spi->dev, "%s, unsupported clock rate %uHz\n",
+			__func__, hz);
+		return -EINVAL;
+	}
+
+	rate = 1000 * ss->speed_khz/ss->divider/hz;
+

drivers/spi/spi_stmp.c line 169

Quoted 10 lines
drivers/spi/spi_stmp.c new file +10 -0
+	writel(BF(ss->divider, SSP_TIMING_CLOCK_DIVIDE)		|
+	       BF(rate - 1, SSP_TIMING_CLOCK_RATE),
+	       HW_SSP_TIMING + ss->regs);
+
+	writel(BF(1 /* mode SPI */, SSP_CTRL1_SSP_MODE)		|
+	       BF(4 /* 8 bits   */, SSP_CTRL1_WORD_LENGTH)	|
+	       ((spi->mode & SPI_CPOL) ? BM_SSP_CTRL1_POLARITY : 0) |
+	       ((spi->mode & SPI_CPHA) ? BM_SSP_CTRL1_PHASE : 0) |
+	       (pio ? 0 : BM_SSP_CTRL1_DMA_ENABLE),
+	       ss->regs + HW_SSP_CTRL1);

That's kind of long to be doing before each spi_transfer.

You might make your main loop only call that when it knows the current settings are wrong ... e.g. on the first pass through the handle_message() loop, and when there are some per-transfer-overrides to apply/remove.

(That's *only* a performance issue, not a correctness one.) It will be pretty visible with small transfers.)

Quoted 18 lines
drivers/spi/spi_stmp.c new file +15 -0
+
+	return 0;
+}
 
 
 
+static int stmp_spi_handle_message(struct stmp_spi *ss, struct spi_message *m)
+{
+	int first, last;
+	struct spi_transfer *t, *tmp_t;
+	int status = 0;
+	int cs;
+
+	first = last = 0;
+
+	cs = m->spi->chip_select;
+
+	list_for_each_entry_safe(t, tmp_t, &m->transfers, transfer_list) {

drivers/spi/spi_stmp.c line 338

Quoted 10 lines
drivers/spi/spi_stmp.c new file +10 -0
+
+		stmp_spi_setup_transfer(m->spi, t);
+
+		if (&t->transfer_list == m->transfers.next)
+			first = !0;
+		if (&t->transfer_list == m->transfers.prev)
+			last = !0;
+		if (t->rx_buf && t->tx_buf) {
+			pr_debug("%s: cannot send and receive simultaneously\n",
+				__func__);

In that case add SPI_MASTER_HALF_DUPLEX to spi_master.flags in your probe() routine. Given a patch I sent out earlier today, you will be able to remove this test from this critical path.

drivers/spi/spi_stmp.c line 344

Quoted 6 lines
drivers/spi/spi_stmp.c new file +6 -0
+			return -EINVAL;
+		}
+
+		/*
+		  REVISIT:
+		  here driver completely ignores setting of t->cs_change

Yeah, please fix that. Minimally, by rejecting submission of messages where it's set anywhere except in the final transfer.

drivers/spi/spi_stmp.c line 351

Quoted 7 lines
drivers/spi/spi_stmp.c new file +7 -0
+		 */
+		if (t->tx_buf) {
+			status = pio ?
+			   stmp_spi_txrx_pio(ss, cs, (void *)t->tx_buf,
+				   t->len, &first, &last, 1) :
+			   stmp_spi_txrx_dma(ss, cs, (void *)t->tx_buf,
+				   t->tx_dma, t->len, &first, &last, 1);

Rather than "1", or "0" below, please change to "bool" param and use "true" and "false". It's still a bit ugly though.

Review

Quoted 1 line
(quoted diff) +1 -0
+			if (debug) {

This debug stuff really ought to be compiled out of the driver if DEBUG is not set.

Quoted 10 lines
drivers/spi/spi_stmp.c new file +8 -0
+				if (t->len < 0x10)
+					print_hex_dump_bytes("Tx ",
+						DUMP_PREFIX_OFFSET,
+						t->tx_buf, t->len);
+				else
+					pr_debug("Tx: %d bytes\n", t->len);
+			}
+		}
 
 

drivers/spi/spi_stmp.c line 395

Quoted 10 lines
drivers/spi/spi_stmp.c new file +10 -0
+/**
+ * stmp_spi_handle - handle messages from the queue
+ */
+static void stmp_spi_handle(struct work_struct *w)
+{
+	struct stmp_spi *ss = container_of(w, struct stmp_spi, work);
+	unsigned long flags;
+	struct spi_message *m;
+
+	BUG_ON(w == NULL);

Strike this BUG_ON(can't happen) ...

drivers/spi/spi_stmp.c line 404

Quoted 9 lines
drivers/spi/spi_stmp.c new file +9 -0
+
+	spin_lock_irqsave(&ss->lock, flags);
+	while (!list_empty(&ss->queue)) {
+		m = list_entry(ss->queue.next, struct spi_message, queue);
+		list_del_init(&m->queue);
+		spin_unlock_irqrestore(&ss->lock, flags);
+
+		m->status = stmp_spi_handle_message(ss, m);
+		if (m->complete)

And don't bother checking m->complete either; it's required.

Quoted 7 lines
drivers/spi/spi_stmp.c new file +7 -0
+			m->complete(m->context);
+
+		spin_lock_irqsave(&ss->lock, flags);
+	}
+	spin_unlock_irqrestore(&ss->lock, flags);
+
+	return;

drivers/spi/spi_stmp.c line 450

Quoted 10 lines
drivers/spi/spi_stmp.c new file +9 -0
+}
 
+static irqreturn_t stmp_spi_irq_err(int irq, void *dev_id)
+{
+	struct stmp_spi *ss = dev_id;
+	u32 c1, st;
+
+	c1 = readl(ss->regs + HW_SSP_CTRL1);
+	st = readl(ss->regs + HW_SSP_STATUS);
+	printk(KERN_ERR"IRQ - ERROR!, status = 0x%08X, c1 = 0x%08X\n", st, c1);

Make it a dev_err().

drivers/spi/spi_stmp.c line 463

Quoted 13 lines
drivers/spi/spi_stmp.c new file +13 -0
+	stmp3xxx_clearl(c1 & 0xCCCC0000, ss->regs + HW_SSP_CTRL1);
+
+	return IRQ_HANDLED;
+}
+
+static int __devinit stmp_spi_probe(struct platform_device *dev)
+{
+	int err = 0;
+	struct spi_master *master;
+	struct stmp_spi *ss;
+	struct resource *r;
+
+	/* Get resources(memory, IRQ) associated with the device */

That's not what spi_alloc_master() does ... this comment needs to be re-located. :)

Quoted 77 lines
drivers/spi/spi_stmp.c new file +77 -0
+	master = spi_alloc_master(&dev->dev, sizeof(struct stmp_spi));
+
+	if (master == NULL) {
+		err = -ENOMEM;
+		goto out0;
+	}
+
+	ss = spi_master_get_devdata(master);
+	platform_set_drvdata(dev, master);
+
+	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
+	if (r == NULL) {
+		err = -ENODEV;
+		goto out_put_master;
+	}
+	ss->regs = ioremap(r->start, resource_size(r));
+	if (!ss->regs) {
+		err = -EINVAL;
+		goto out_put_master;
+	}
+
+	ss->master_dev = &dev->dev;
+	ss->id = dev->id;
+
+	INIT_WORK(&ss->work, stmp_spi_handle);
+	INIT_LIST_HEAD(&ss->queue);
+	spin_lock_init(&ss->lock);
+
+	ss->workqueue = create_singlethread_workqueue(dev_name(&dev->dev));
+	if (!ss->workqueue) {
+		err = -ENXIO;
+		goto out_put_master;
+	}
+	master->transfer = stmp_spi_transfer;
+	master->setup = stmp_spi_setup;
+
+
+	ss->irq = platform_get_irq(dev, 0);
+	if (ss->irq < 0) {
+		err = -ENXIO;
+		goto out_put_master;
+	}
+
+	r = platform_get_resource(dev, IORESOURCE_DMA, 0);
+	if (r == NULL) {
+		err = -ENODEV;
+		goto out_put_master;
+	}
+
+	ss->dma = r->start;
+	err = stmp3xxx_dma_request(ss->dma, &dev->dev, dev_name(&dev->dev));
+	if (err)
+		goto out_put_master;
+
+	err = stmp3xxx_dma_allocate_command(ss->dma, &ss->d);
+	if (err)
+		goto out_free_dma;
+
+	master->bus_num = dev->id;
+	master->num_chipselect = 1;
+
+	/* SPI controller initializations */
+	err = stmp_spi_init_hw(ss);
+	if (err) {
+		dev_dbg(&dev->dev, "cannot initialize hardware\n");
+		goto out_free_dma_desc;
+	}
+
+	if (clock) {
+		dev_info(&dev->dev, "clock rate forced to %d\n", clock);
+		clk_set_rate(ss->clk, clock);
+	}
+	ss->speed_khz = clk_get_rate(ss->clk);
+	ss->divider = 2;
+	dev_info(&dev->dev, "max possible speed %d = %ld/%d kHz\n",
+		ss->speed_khz, clk_get_rate(ss->clk), ss->divider);
+

drivers/spi/spi_stmp.c line 550

Quoted 10 lines
drivers/spi/spi_stmp.c new file +10 -0
+	/* Register for SPI interrupt */
+	err = request_irq(ss->irq, stmp_spi_irq, 0,
+			  dev_name(&dev->dev), ss);
+	if (err) {
+		dev_dbg(&dev->dev, "request_irq failed, %d\n", err);
+		goto out_release_hw;
+	}
+
+	/* ..and shared interrupt for all SSP controllers */
+	err = request_irq(IRQ_SSP_ERROR, stmp_spi_irq_err, IRQF_SHARED,

This should use a value from the platform resources, not a constant IRQ_SSP_ERROR (which might change on other silicon).

drivers/spi/spi_stmp.c line 555

Quoted 5 lines
drivers/spi/spi_stmp.c new file +5 -0
+			  dev_name(&dev->dev), ss);
+	if (err) {
+		dev_dbg(&dev->dev, "request_irq(error) failed, %d\n", err);
+		goto out_free_irq;
+	}

------------------------------------------------------------------------------

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 200907031849.53761.david-b-yBeKhBN/[email protected]

#12 lore raw

Re: [PATCH] Freescale STMP spi driver, revised

Crossposted to mailing list

Quoted 3 lines · David Brownell

Your updated patch only addressed the minor fixup I sent, not the technical feedback I sent (included below) ... I'll wait for an update on those points too.

Thanks for your review; the updated patch is inlined below.

Add the SPI driver for Freescale STMP 3xxx-based boards

                                                                      > 
---
 drivers/spi/Kconfig    |    6 
 drivers/spi/Makefile   |    1 
 drivers/spi/spi_stmp.c |  677 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 684 insertions(+)
drivers/spi/Kconfig +6 -0
Index: linux-2.6/drivers/spi/Kconfig
===================================================================
@@ -211,6 +211,12 @@ config SPI_SH_SCI
 	help
 	  SPI driver for SuperH SCI blocks.
 
+config SPI_STMP3XXX
+	tristate "Freescale STMP37xx/378x SPI/SSP controller"
+	depends on ARCH_STMP3XXX && SPI_MASTER
+	help
+	  SPI driver for Freescale STMP37xx/378x SoC SSP interface
+
 config SPI_TXX9
 	tristate "Toshiba TXx9 SPI controller"
 	depends on GENERIC_GPIO && CPU_TX49XX
drivers/spi/Makefile +1 -0
Index: linux-2.6/drivers/spi/Makefile
===================================================================
@@ -31,6 +31,7 @@ obj-$(CONFIG_SPI_S3C24XX)		+= spi_s3c24x
 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_STMP3XXX)		+= spi_stmp.o
 # 	... add above this line ...
 
 # SPI protocol drivers (device/link on bus)
drivers/spi/spi_stmp.c new file +677 -0

677 lines not on this page · raw message

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/blackberry