mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Teresa Gámez" <t.gamez@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/3] ARM: OMAP: pcm051: Add spi flash support
Date: Tue, 18 Jun 2013 13:25:47 +0200	[thread overview]
Message-ID: <1371554747-9052-4-git-send-email-t.gamez@phytec.de> (raw)
In-Reply-To: <1371554747-9052-1-git-send-email-t.gamez@phytec.de>

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

  parent reply	other threads:[~2013-06-18 11:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2013-06-18 12:11   ` [PATCH 3/3] ARM: OMAP: pcm051: Add spi flash support Alexander Aring

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=1371554747-9052-4-git-send-email-t.gamez@phytec.de \
    --to=t.gamez@phytec.de \
    --cc=barebox@lists.infradead.org \
    /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