mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3] More AM33xx SPI patches
@ 2013-06-18 11:25 Teresa Gámez
  2013-06-18 11:25 ` [PATCH 1/3] ARM: OMAP: AM33xx: Add muxing function for spi0 Teresa Gámez
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Teresa Gámez @ 2013-06-18 11:25 UTC (permalink / raw)
  To: barebox

This patches are based on Jan Lübbes 

arm: omap: am33xx: set up SPI devices

patch which I haven't found in next yet.

Teresa

Teresa Gámez (3):
  ARM: OMAP: AM33xx: Add muxing function for spi0
  omap3_spi: Add CS check for AM33xx
  ARM: OMAP: pcm051: Add spi flash support

 arch/arm/boards/pcm051/board.c               |   41 ++++++++++++++++++++++++++
 arch/arm/boards/pcm051/env/init/mtdparts-nor |   12 +++++++
 arch/arm/configs/pcm051_defconfig            |    3 +-
 arch/arm/mach-omap/am33xx_mux.c              |    5 +++
 arch/arm/mach-omap/include/mach/am33xx-mux.h |    1 +
 drivers/spi/omap3_spi.c                      |   20 +++++++++++--
 6 files changed, 78 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/boards/pcm051/env/init/mtdparts-nor


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] ARM: OMAP: AM33xx: Add muxing function for spi0
  2013-06-18 11:25 [PATCH 0/3] More AM33xx SPI patches Teresa Gámez
@ 2013-06-18 11:25 ` Teresa Gámez
  2013-06-18 11:25 ` [PATCH 2/3] omap3_spi: Add CS check for AM33xx Teresa Gámez
  2013-06-18 11:25 ` [PATCH 3/3] ARM: OMAP: pcm051: Add spi flash support Teresa Gámez
  2 siblings, 0 replies; 5+ messages in thread
From: Teresa Gámez @ 2013-06-18 11:25 UTC (permalink / raw)
  To: barebox

Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
---
 arch/arm/mach-omap/am33xx_mux.c              |    5 +++++
 arch/arm/mach-omap/include/mach/am33xx-mux.h |    1 +
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap/am33xx_mux.c b/arch/arm/mach-omap/am33xx_mux.c
index 424d120..abc8586 100644
--- a/arch/arm/mach-omap/am33xx_mux.c
+++ b/arch/arm/mach-omap/am33xx_mux.c
@@ -314,3 +314,8 @@ void am33xx_enable_mmc0_pin_mux(void)
 {
 	configure_module_pin_mux(mmc0_pin_mux);
 }
+
+void am33xx_enable_spi0_pin_mux(void)
+{
+	configure_module_pin_mux(spi0_pin_mux);
+}
diff --git a/arch/arm/mach-omap/include/mach/am33xx-mux.h b/arch/arm/mach-omap/include/mach/am33xx-mux.h
index 44b93bd..d6b19dd 100644
--- a/arch/arm/mach-omap/include/mach/am33xx-mux.h
+++ b/arch/arm/mach-omap/include/mach/am33xx-mux.h
@@ -256,5 +256,6 @@ extern void am33xx_enable_i2c2_pin_mux(void);
 extern void am33xx_enable_uart0_pin_mux(void);
 extern void am33xx_enable_uart2_pin_mux(void);
 extern void am33xx_enable_mmc0_pin_mux(void);
+extern void am33xx_enable_spi0_pin_mux(void);
 
 #endif /*__AM33XX_MUX_H__ */
-- 
1.7.0.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] omap3_spi: Add CS check for AM33xx
  2013-06-18 11:25 [PATCH 0/3] More AM33xx SPI patches Teresa Gámez
  2013-06-18 11:25 ` [PATCH 1/3] ARM: OMAP: AM33xx: Add muxing function for spi0 Teresa Gámez
@ 2013-06-18 11:25 ` Teresa Gámez
  2013-06-18 11:25 ` [PATCH 3/3] ARM: OMAP: pcm051: Add spi flash support Teresa Gámez
  2 siblings, 0 replies; 5+ messages in thread
From: Teresa Gámez @ 2013-06-18 11:25 UTC (permalink / raw)
  To: barebox

AM33xx has only 2 McSPI busses and 2 CS for each bus.
Added comment and the check.

Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
---
 drivers/spi/omap3_spi.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
index e6581df..1eb0e6a 100644
--- a/drivers/spi/omap3_spi.c
+++ b/drivers/spi/omap3_spi.c
@@ -326,11 +326,17 @@ static int omap3_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
 static int omap3_spi_setup(struct spi_device *spi)
 {
 	struct spi_master *master = spi->master;
+	int is_not_valid;
 
-	if (((master->bus_num == 1) && (spi->chip_select > 3)) ||
+	if (IS_ENABLED(CONFIG_ARCH_OMAP3))
+		is_not_valid = ((master->bus_num == 1) && (spi->chip_select > 3)) ||
 			((master->bus_num == 2) && (spi->chip_select > 1)) ||
 			((master->bus_num == 3) && (spi->chip_select > 1)) ||
-			((master->bus_num == 4) && (spi->chip_select > 0))) {
+			((master->bus_num == 4) && (spi->chip_select > 0));
+	else
+		is_not_valid = (spi->chip_select > 1);
+
+	if (is_not_valid) {
 		printf("SPI error: unsupported chip select %i \
 			on bus %i\n", spi->chip_select, master->bus_num);
 		return -EINVAL;
@@ -368,12 +374,20 @@ static int omap3_spi_probe(struct device_d *dev)
 	 * McSPI3 has 2 CS (bus 3, cs 0 - 1)
 	 * McSPI4 has 1 CS (bus 4, cs 0)
 	 *
+	 * AM335x McSPI has 2 busses with 2 chip selects:
+	 * McSPI0 has 2 CS (bus 0, cs 0 - 1)
+	 * McSPI1 has 2 CS (bus 1, cs 0 - 1)
+	 *
 	 * The board code has to make sure that it does not use
 	 * invalid buses or chip selects.
 	 */
 
 	master->bus_num = dev->id;
-	master->num_chipselect = 4;
+
+	if (IS_ENABLED(CONFIG_ARCH_OMAP3))
+		master->num_chipselect = 4;
+	else
+		master->num_chipselect = 2;
 	master->setup = omap3_spi_setup;
 	master->transfer = omap3_spi_transfer;
 
-- 
1.7.0.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] ARM: OMAP: pcm051: Add spi flash support
  2013-06-18 11:25 [PATCH 0/3] More AM33xx SPI patches Teresa Gámez
  2013-06-18 11:25 ` [PATCH 1/3] ARM: OMAP: AM33xx: Add muxing function for spi0 Teresa Gámez
  2013-06-18 11:25 ` [PATCH 2/3] omap3_spi: Add CS check for AM33xx Teresa Gámez
@ 2013-06-18 11:25 ` Teresa Gámez
  2013-06-18 12:11   ` Alexander Aring
  2 siblings, 1 reply; 5+ messages in thread
From: Teresa Gámez @ 2013-06-18 11:25 UTC (permalink / raw)
  To: barebox

Add support for w25q64 SPI NOR flash.

Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
---
 arch/arm/boards/pcm051/board.c               |   41 ++++++++++++++++++++++++++
 arch/arm/boards/pcm051/env/init/mtdparts-nor |   12 +++++++
 arch/arm/configs/pcm051_defconfig            |    3 +-
 3 files changed, 55 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/boards/pcm051/env/init/mtdparts-nor

diff --git a/arch/arm/boards/pcm051/board.c b/arch/arm/boards/pcm051/board.c
index 8754ba5..c390c45 100644
--- a/arch/arm/boards/pcm051/board.c
+++ b/arch/arm/boards/pcm051/board.c
@@ -26,6 +26,8 @@
 #include <mach/am33xx-devices.h>
 #include <mach/am33xx-mux.h>
 #include <mach/am33xx-silicon.h>
+#include <spi/spi.h>
+#include <spi/flash.h>
 
 #include "mux.h"
 
@@ -52,12 +54,51 @@ static int pcm051_mem_init(void)
 }
 mem_initcall(pcm051_mem_init);
 
+static struct flash_platform_data pcm051_spi_flash = {
+	.name	= "nor",
+	.type	= "w25q64",
+};
+
+/*
+* SPI Flash works at 80Mhz however the SPI controller runs with 48MHz.
+* So setup Max speed to be less than the controller speed.
+*/
+static struct spi_board_info pcm051_spi_board_info[] = {
+	{
+		.name		= "m25p80",
+		.platform_data	= &pcm051_spi_flash,
+		.max_speed_hz	= 24000000,
+		.bus_num	= 0,
+		.chip_select	= 0,
+	},
+};
+
+static void pcm051_spi_init(void)
+{
+	int ret;
+
+	am33xx_enable_spi0_pin_mux();
+
+	ret = spi_register_board_info(pcm051_spi_board_info,
+					ARRAY_SIZE(pcm051_spi_board_info));
+	am33xx_add_spi0();
+}
+
 static int pcm051_devices_init(void)
 {
 	pcm051_enable_mmc0_pin_mux();
 
 	am33xx_add_mmc0(NULL);
 
+	pcm051_spi_init();
+
+	devfs_add_partition("nor0", 0x00000, SZ_128K,
+					DEVFS_PARTITION_FIXED, "xload");
+	devfs_add_partition("nor0", SZ_128K, SZ_256K,
+					DEVFS_PARTITION_FIXED, "self0");
+	devfs_add_partition("nor0", SZ_128K + SZ_256K, SZ_128K,
+					DEVFS_PARTITION_FIXED, "env0");
+
 	armlinux_set_bootparams((void *)(AM33XX_DRAM_ADDR_SPACE_START + 0x100));
 	armlinux_set_architecture(MACH_TYPE_PCM051);
 
diff --git a/arch/arm/boards/pcm051/env/init/mtdparts-nor b/arch/arm/boards/pcm051/env/init/mtdparts-nor
new file mode 100644
index 0000000..91aa847
--- /dev/null
+++ b/arch/arm/boards/pcm051/env/init/mtdparts-nor
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "NOR partitions"
+	exit
+fi
+
+mtdparts="128k(nor0.xload),512k(nor0.barebox),128k(nor0.bareboxenv),4M(nor0.kernel),-(nor0.root)"
+kernelname="spi_flash"
+
+mtdparts-add -d nor0 -k ${kernelname} -p ${mtdparts}
+
diff --git a/arch/arm/configs/pcm051_defconfig b/arch/arm/configs/pcm051_defconfig
index 4da0ed4..90c2b50 100644
--- a/arch/arm/configs/pcm051_defconfig
+++ b/arch/arm/configs/pcm051_defconfig
@@ -44,8 +44,9 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_UNCOMPRESS=y
 CONFIG_DRIVER_SERIAL_NS16550=y
 CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
-# CONFIG_SPI is not set
+CONFIG_DRIVER_SPI_OMAP3=y
 CONFIG_MTD=y
+CONFIG_MTD_M25P80=y
 CONFIG_NAND=y
 CONFIG_USB=y
 CONFIG_MCI=y
-- 
1.7.0.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] ARM: OMAP: pcm051: Add spi flash support
  2013-06-18 11:25 ` [PATCH 3/3] ARM: OMAP: pcm051: Add spi flash support Teresa Gámez
@ 2013-06-18 12:11   ` Alexander Aring
  0 siblings, 0 replies; 5+ messages in thread
From: Alexander Aring @ 2013-06-18 12:11 UTC (permalink / raw)
  To: Teresa Gámez; +Cc: barebox

Hi,

On Tue, Jun 18, 2013 at 01:25:47PM +0200, Teresa Gámez wrote:
> Add support for w25q64 SPI NOR flash.
> 
> Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
> ---
>  arch/arm/boards/pcm051/board.c               |   41 ++++++++++++++++++++++++++
>  arch/arm/boards/pcm051/env/init/mtdparts-nor |   12 +++++++
>  arch/arm/configs/pcm051_defconfig            |    3 +-
>  3 files changed, 55 insertions(+), 1 deletions(-)
>  create mode 100644 arch/arm/boards/pcm051/env/init/mtdparts-nor
> 
> diff --git a/arch/arm/boards/pcm051/board.c b/arch/arm/boards/pcm051/board.c
> index 8754ba5..c390c45 100644
> --- a/arch/arm/boards/pcm051/board.c
> +++ b/arch/arm/boards/pcm051/board.c
> @@ -26,6 +26,8 @@
>  #include <mach/am33xx-devices.h>
>  #include <mach/am33xx-mux.h>
>  #include <mach/am33xx-silicon.h>
> +#include <spi/spi.h>
> +#include <spi/flash.h>
>  
>  #include "mux.h"
>  
> @@ -52,12 +54,51 @@ static int pcm051_mem_init(void)
>  }
>  mem_initcall(pcm051_mem_init);
>  
> +static struct flash_platform_data pcm051_spi_flash = {
> +	.name	= "nor",
> +	.type	= "w25q64",
> +};
> +
> +/*
> +* SPI Flash works at 80Mhz however the SPI controller runs with 48MHz.
> +* So setup Max speed to be less than the controller speed.
> +*/
> +static struct spi_board_info pcm051_spi_board_info[] = {
> +	{
> +		.name		= "m25p80",
> +		.platform_data	= &pcm051_spi_flash,
> +		.max_speed_hz	= 24000000,
> +		.bus_num	= 0,
> +		.chip_select	= 0,
> +	},
> +};
> +
> +static void pcm051_spi_init(void)
> +{
> +	int ret;
> +
> +	am33xx_enable_spi0_pin_mux();
> +
> +	ret = spi_register_board_info(pcm051_spi_board_info,
> +					ARRAY_SIZE(pcm051_spi_board_info));
> +	am33xx_add_spi0();
> +}
> +
>  static int pcm051_devices_init(void)
>  {
>  	pcm051_enable_mmc0_pin_mux();
>  
>  	am33xx_add_mmc0(NULL);
>  
> +	pcm051_spi_init();
> +
> +	devfs_add_partition("nor0", 0x00000, SZ_128K,
> +					DEVFS_PARTITION_FIXED, "xload");
> +	devfs_add_partition("nor0", SZ_128K, SZ_256K,
> +					DEVFS_PARTITION_FIXED, "self0");

I think this size need to be to SZ_512K or...

> +	devfs_add_partition("nor0", SZ_128K + SZ_256K, SZ_128K,
> +					DEVFS_PARTITION_FIXED, "env0");
> +
>  	armlinux_set_bootparams((void *)(AM33XX_DRAM_ADDR_SPACE_START + 0x100));
>  	armlinux_set_architecture(MACH_TYPE_PCM051);
>  
> diff --git a/arch/arm/boards/pcm051/env/init/mtdparts-nor b/arch/arm/boards/pcm051/env/init/mtdparts-nor
> new file mode 100644
> index 0000000..91aa847
> --- /dev/null
> +++ b/arch/arm/boards/pcm051/env/init/mtdparts-nor
> @@ -0,0 +1,12 @@
> +#!/bin/sh
> +
> +if [ "$1" = menu ]; then
> +	init-menu-add-entry "$0" "NOR partitions"
> +	exit
> +fi
> +
> +mtdparts="128k(nor0.xload),512k(nor0.barebox),128k(nor0.bareboxenv),4M(nor0.kernel),-(nor0.root)"

... 512k(nor0.barebox) to 256k(nor0.barebox).

Regards
Alex

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-18 12:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-18 11:25 [PATCH 0/3] More AM33xx SPI patches Teresa Gámez
2013-06-18 11:25 ` [PATCH 1/3] ARM: OMAP: AM33xx: Add muxing function for spi0 Teresa Gámez
2013-06-18 11:25 ` [PATCH 2/3] omap3_spi: Add CS check for AM33xx Teresa Gámez
2013-06-18 11:25 ` [PATCH 3/3] ARM: OMAP: pcm051: Add spi flash support Teresa Gámez
2013-06-18 12:11   ` Alexander Aring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox