Skip to contentSkip to conversation

spi: add spi controller master driver for Blackfin 6xx processor

PATCH Superseded Scott Jiang 3 participants 8 messages Jun 18, 2013 – Jul 19, 2013 6 messages not in the archive SPI

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 spi: add spi controller master driver for Blackfin 6xx processor

New spi controller is integrated into Blackfin 6xx processor. Comparing to bf5xx spi controller, we support 32 bits word size and independent receive and transmit DMA channels now. Also mode 0 and 2 (CPHA = 0) can get fully supported becasue cs line may be controlled by the software.

---
 drivers/spi/Kconfig       |    8 +-
 drivers/spi/Makefile      |    1 +
 drivers/spi/spi-bfin6xx.c |  996 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1004 insertions(+), 1 deletions(-)
 create mode 100644 drivers/spi/spi-bfin6xx.c
drivers/spi/Kconfig +7 -1
index 864d87f..d64bbeb 100644
@@ -87,10 +87,16 @@ config SPI_BCM2835
 
 config SPI_BFIN5XX
 	tristate "SPI controller driver for ADI Blackfin5xx"
-	depends on BLACKFIN
+	depends on BLACKFIN && !BF60x
 	help
 	  This is the SPI controller master driver for Blackfin 5xx processor.
 
+config SPI_BFIN6XX
+	tristate "SPI controller driver for ADI Blackfin6xx"
+	depends on BF60x
+	help
+	  This is the SPI controller master driver for Blackfin 6xx processor.
+
 config SPI_BFIN_SPORT
 	tristate "SPI bus via Blackfin SPORT"
 	depends on BLACKFIN
drivers/spi/Makefile +1 -0
index 33f9c09..0114a26 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_SPI_AU1550)		+= spi-au1550.o
 obj-$(CONFIG_SPI_BCM2835)		+= spi-bcm2835.o
 obj-$(CONFIG_SPI_BCM63XX)		+= spi-bcm63xx.o
 obj-$(CONFIG_SPI_BFIN5XX)		+= spi-bfin5xx.o
+obj-$(CONFIG_SPI_BFIN6XX)               += spi-bfin6xx.o
 obj-$(CONFIG_SPI_BFIN_SPORT)		+= spi-bfin-sport.o
 obj-$(CONFIG_SPI_BITBANG)		+= spi-bitbang.o
 obj-$(CONFIG_SPI_BUTTERFLY)		+= spi-butterfly.o
drivers/spi/spi-bfin6xx.c new file +996 -0

996 lines not on this page · raw message

Signature · 10 lines
1.7.0.4



------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

A message that is not in the archive (sent off-list or not yet received): 1371583828-23788-1-git-send-email-scott.jiang.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 5 lines · Scott Jiang

New spi controller is integrated into Blackfin 6xx processor. Comparing to bf5xx spi controller, we support 32 bits word size and independent receive and transmit DMA channels now. Also mode 0 and 2 (CPHA = 0) can get fully supported becasue cs line may be controlled by the software.

A few nits here but mostly looking good.

drivers/spi/spi-bfin6xx.c line 649

Quoted 10 lines
drivers/spi/spi-bfin6xx.c new file +10 -0
+	switch (spi->bits_per_word) {
+	case 8:
+	case 16:
+	case 32:
+		break;
+	default:
+		dev_err(&spi->dev, "%d bits_per_word is not supported\n",
+				spi->bits_per_word);
+		return -EINVAL;
+	}

Just set bits_per_word_mask in the master struct and let the core do this for you.

drivers/spi/spi-bfin6xx.c line 732

Quoted 6 lines
drivers/spi/spi-bfin6xx.c new file +6 -0
+	if (chip->cs < MAX_CTRL_CS) {
+		peripheral_free(ssel[spi->master->bus_num]
+					[chip->cs-1]);
+		bfin_spi_cs_disable(drv_data, chip);
+	} else
+		gpio_free(chip->cs_gpio);

Braces on both sides of the if.

drivers/spi/spi-bfin6xx.c line 855

Quoted 6 lines
drivers/spi/spi-bfin6xx.c new file +6 -0
+	drv_data->regs = devm_ioremap_resource(dev, mem);
+	if (IS_ERR(drv_data->regs)) {
+		dev_err(dev, "can not map register memory\n");
+		ret = PTR_ERR(drv_data->regs);
+		goto err_put_master;
+	}

devm_ioremap_resource() will display an error message for you so you don't need to bother, though in any case the return code should generally be displayed.

drivers/spi/spi-bfin6xx.c line 977

Quoted 3 lines
drivers/spi/spi-bfin6xx.c new file +3 -0
+#ifdef CONFIG_PM
+		.pm     = &bfin_spi_pm_ops,
+#endif

Use SET_SYSTEM_SLEEP_PM_OPS().

drivers/spi/spi-bfin6xx.c line 986

Quoted 5 lines
drivers/spi/spi-bfin6xx.c new file +5 -0
+static int __init bfin_spi_init(void)
+{
+	return platform_driver_probe(&bfin_spi_driver, bfin_spi_probe);
+}
+subsys_initcall(bfin_spi_init);

Should really use module_platform_driver() on modern systems, the deferred probe infrastructure should remove the need for faffing around with init order.

Quoted 1 line

+MODULE_DESCRIPTION("Analog Devices SPI3 controller driver");

Why not call the driver something like bfin_spi3 then?

_______________________________________________
Uclinux-dist-devel mailing list Uclinux-dist-devel-ZG0+EudsQA8dtHy/[email protected]
https://blackfin.uclinux.org/mailman/listinfo/uclinux-dist-devel

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

#4 lore raw

Hi Mark,

Quoted 4 lines
Quoted 2 lines

+MODULE_DESCRIPTION("Analog Devices SPI3 controller driver");

Why not call the driver something like bfin_spi3 then?

Do you mean the driver name or file name? It's the same with spi-bfin5xx driver. The test script may use the same name for 5xx and 6xx boards.

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

A message that is not in the archive (sent off-list or not yet received): CAHG8p1C0DjPt_vNiqYtkVUWYy4M-doj50K1MAEocPs+AkXdhPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw
Quoted 7 lines · Scott Jiang

Hi Mark,

Quoted 3 lines
Quoted 1 line

+MODULE_DESCRIPTION("Analog Devices SPI3 controller driver");

Why not call the driver something like bfin_spi3 then?

Do you mean the driver name or file name? It's the same with spi-bfin5xx driver.

Both. What happens when someone use the IP in a different device, say bf7xx.

Quoted 1 line

The test script may use the same name for 5xx and 6xx boards.

That sounds like something it's not impossible to fix...

_______________________________________________
Uclinux-dist-devel mailing list Uclinux-dist-devel-ZG0+EudsQA8dtHy/[email protected]
https://blackfin.uclinux.org/mailman/listinfo/uclinux-dist-devel

#7 lore raw
In reply to a message not in the archive

Hi Mark,

Quoted 12 lines

drivers/spi/spi-bfin6xx.c line 649

Quoted 11 lines
drivers/spi/spi-bfin6xx.c new file +10 -0
+     switch (spi->bits_per_word) {
+     case 8:
+     case 16:
+     case 32:
+             break;
+     default:
+             dev_err(&spi->dev, "%d bits_per_word is not supported\n",
+                             spi->bits_per_word);
+             return -EINVAL;
+     }
Quoted 3 lines

Just set bits_per_word_mask in the master struct and let the core do this for you.

This check is in spi_setup, but master->bits_per_word_mask check is delayed to each transfer. Don't you think master->bits_per_word_mask also should be tested in spi_setup?

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

A message that is not in the archive (sent off-list or not yet received): CAHG8p1Dz=PwYQ8Q2ERcAQhpUwjmXfQ5HX6M_wvTezybQ4AB4eQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#10 lore raw
In reply to a message not in the archive

Hi Mark,

Quoted 11 lines

drivers/spi/spi-bfin6xx.c line 986

Quoted 6 lines
drivers/spi/spi-bfin6xx.c new file +5 -0
+static int __init bfin_spi_init(void)
+{
+     return platform_driver_probe(&bfin_spi_driver, bfin_spi_probe);
+}
+subsys_initcall(bfin_spi_init);

Should really use module_platform_driver() on modern systems, the deferred probe infrastructure should remove the need for faffing around with init order.

When I convert to use module_platform_driver(), I found some driver depend on SPI_MASTER start up before spi master probe driver. So how can I control this init order?

Thanks,
Scott

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk

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): [email protected]

#13 lore raw

Hi Mark,

Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

Should really use module_platform_driver() on modern systems, the deferred probe infrastructure should remove the need for faffing around with init order.

When I convert to use module_platform_driver(), I found some driver depend on SPI_MASTER start up before spi master probe driver. So how can I control this init order?

Could you be more explicit about the dependencies here? Are these other drivers using -EPROBE_DEFER as they should?

No, it returns ENODEV if spi_busnum_to_master(0) fail. It's a fb driver and /drivers/video
is before /drivers/spi in link order. So I should do more work on this fb driver instead of
spi master driver to make probe deferral mechanism work, right?

Scott

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk