Skip to contentSkip to conversation

orion5x: edminiv2: add libata support

PATCH New Albert Aribaud 4 participants 16 messages Jun 30, 2010 – Jul 1, 2010

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

PATCH 1/1 orion5x: edminiv2: add libata support

---
This patch:
- adds support in libata for the orion5x MVSATAHC controller;
- enables orion5x MVSTAHC port 1 on the edmini board;
- adds IDE and EXT2 commands to the edminiv2 command set.

 arch/arm/include/asm/arch-orion5x/orion5x.h |   20 ++++++++++++++-
 board/LaCie/edminiv2/config.mk              |    6 ++++-
 board/LaCie/edminiv2/edminiv2.c             |   22 +++++++++++++++++
 common/cmd_ide.c                            |   14 +++++++---
 include/configs/edminiv2.h                  |   35 +++++++++++++++++++++++++-
 5 files changed, 88 insertions(+), 9 deletions(-)
arch/arm/include/asm/arch-orion5x/orion5x.h +18 -2
index 4008c84..2724a70 100644
@@ -38,7 +38,7 @@
 #if defined(CONFIG_FEROCEON)
 #include <asm/arch/cpu.h>
 
-/* SOC specific definations */
+/* SOC specific definitions */
 #define ORION5X_REGISTER(x)			(ORION5X_REGS_PHY_BASE + x)
 
 /* Documented registers */
@@ -54,7 +54,23 @@
 #define ORION5X_REG_PCIE_BASE			(ORION5X_REGISTER(0x40000))
 #define ORION5X_USB20_PORT0_BASE		(ORION5X_REGISTER(0x50000))
 #define ORION5X_USB20_PORT1_BASE		(ORION5X_REGISTER(0xA0000))
-#define ORION5X_EGIGA_BASE			(ORION5X_REGISTER(0x72000))
+#define ORION5X_SATA_BASE			(ORION5X_REGISTER(0x80000))
+#define ORION5X_SATA_PORT0_OFFSET		0x2000
+#define ORION5X_SATA_PORT1_OFFSET		0x4000
+
+/*
+ * SATA definitions needed for controller initialization
+ */
+/* SControl register address */
+#define ORION5X_SATA_PORT1_SCONTROL_REG \
+	(ORION5X_SATA_BASE+ORION5X_SATA_PORT1_OFFSET+0x308)
+/* Mask and values for device DETection and link initialization */
+#define ORION5X_SATA_SCONTROL_DET_MASK		0x0000000F
+#define ORION5X_SATA_SCONTROL_DET_NONE		0x00000000
+#define ORION5X_SATA_SCONTROL_DET_INIT		0x00000001
+/* Mask and values for device Interface Power Management */
+#define ORION5X_SATA_SCONTROL_IMP_MASK		0x00000F00
+#define ORION5X_SATA_SCONTROL_IMP_NO_LP_ALLOWED	0x00000300
 
 #define CONFIG_MAX_RAM_BANK_SIZE		(64*1024*1024)
 
board/LaCie/edminiv2/config.mk +5 -1
index 3dec1aa..1606cca 100644
@@ -24,4 +24,8 @@
 # MA 02110-1301 USA
 #
 
-TEXT_BASE = 0x00100000
+# As the Linux  kernel will load from 00008000 up and we cannot tell
+# how big it can be, let U-Boot run in the topmost megabyte of the
+# ED Mini V2 64 megabyte DRAM.
+
+TEXT_BASE = 0x03F00000
board/LaCie/edminiv2/edminiv2.c +22 -0
index 54c0ffe..6b4f0e5 100644
@@ -80,13 +80,35 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
 }
 #endif				/* CONFIG_SYS_FLASH_CFI */
 
+/* ED Mini V2 uses SATA PORT1. Initialize this port and disable
+ * disable low power on it
+ */
+ /* mask for isolating IPM and DET fields in SControl register */
+#define EDMINIV2_SCONTROL_MASK (ORION5X_SATA_SCONTROL_DET_MASK \
+	|| ORION5X_SATA_SCONTROL_IMP_MASK)
+/* IPM and DET values for initializing link */
+#define EDMINIV2_PORT_INIT (ORION5X_SATA_SCONTROL_DET_INIT \
+	|| ORION5X_SATA_SCONTROL_IMP_NO_LP_ALLOWED)
+/* IPM and DET values to use link once initialized */
+#define EDMINIV2_PORT_USE (ORION5X_SATA_SCONTROL_DET_NONE \
+	|| ORION5X_SATA_SCONTROL_IMP_NO_LP_ALLOWED)
+
 int board_init(void)
 {
+	u32 reg;
+
 	/* arch number of board */
 	gd->bd->bi_arch_number = MACH_TYPE_EDMINI_V2;
 
 	/* boot parameter start at 256th byte of RAM base */
 	gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
 
+	/* reset port 1 of SATAHC controller */
+	reg = readl(ORION5X_SATA_PORT1_SCONTROL_REG);
+	reg = (reg & ~EDMINIV2_SCONTROL_MASK) | EDMINIV2_PORT_INIT;
+	writel(reg, ORION5X_SATA_PORT1_SCONTROL_REG);
+	reg = (reg & ~EDMINIV2_SCONTROL_MASK) | EDMINIV2_PORT_USE;
+	writel(reg, ORION5X_SATA_PORT1_SCONTROL_REG);
+
 	return 0;
 }
common/cmd_ide.c +10 -4
index 8bd8920..08ebbf6 100644
@@ -45,6 +45,10 @@
 #include <mpc5xxx.h>
 #endif
 
+#ifdef CONFIG_ORION5X
+#include <asm/arch/orion5x.h>
+#endif
+
 #include <ide.h>
 #include <ata.h>
 
@@ -854,7 +858,8 @@ input_swap_data(int dev, ulong *sect_buf, int words)
 #endif	/* __LITTLE_ENDIAN || CONFIG_AU1X00 */
 
 
-#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH)
+#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH) \
+	|| defined(__ARM__)
 static void
 output_data(int dev, ulong *sect_buf, int words)
 {
@@ -906,7 +911,8 @@ output_data(int dev, ulong *sect_buf, int words)
 }
 #endif	/* __PPC__ */
 
-#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH)
+#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH) \
+	|| defined(__ARM__)
 static void
 input_data(int dev, ulong *sect_buf, int words)
 {
@@ -1580,7 +1586,7 @@ int ide_device_present(int dev)
  * ATAPI Support
  */
 
-#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA)
+#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(__ARM__)
 /* since ATAPI may use commands with not 4 bytes alligned length
  * we have our own transfer functions, 2 bytes alligned */
 static void
@@ -1618,7 +1624,7 @@ output_data_shorts(int dev, ushort *sect_buf, int shorts)
 static void
 input_data_shorts(int dev, ushort *sect_buf, int shorts)
 {
-#if defined(CONFIG_HMI10) || defined(CONFIG_CPC45)
+#if defined(CONFIG_HMI10) || defined(CONFIG_CPC45) || defined(__ARM__)
 	uchar	*dbuf;
 	volatile uchar	*pbuf_even;
 	volatile uchar	*pbuf_odd;
include/configs/edminiv2.h +33 -2
index c3d95a0..923cca9 100644
@@ -52,6 +52,12 @@
 #define CONFIG_SYS_HZ		1000
 
 /*
+ * __io is necessary for cmd_ide to compile
+ */
+
+#define __io
+
+/*
  * Board-specific values for Orion5x MPP low level init:
  * - MPPs 12 to 15 are SATA LEDs (mode 5)
  * - Others are GPIO/unused (mode 3 for MPP0, mode 5 for
@@ -60,7 +66,7 @@
 
 #define ORION5X_MPP0_7		0x00000003
 #define ORION5X_MPP8_15		0x55550000
-#define ORION5X_MPP16_23	0x00000000
+#define ORION5X_MPP16_23	0x00005555
 
 /*
  * Board-specific values for Orion5x GPIO low level init:
@@ -74,7 +80,6 @@
  */
 
 #define ORION5X_GPIO_OUT_ENABLE	0x03fcffff
-#define ORION5X_GPIO_OUT_VALUE	0x03fcffff
 
 /*
  * NS16550 Configuration
@@ -131,6 +136,7 @@
  * Commands configuration - using default command set for now
  */
 #include <config_cmd_default.h>
+
 /*
  * Disabling some default commands for staggered bring-up
  */
@@ -139,6 +145,25 @@
 #undef CONFIG_CMD_NFS	/* no NFS since no net */
 
 /*
+ * ED Mini has a connector for SATA Port 1
+ */
+
+#define CONFIG_CMD_IDE
+#define CONFIG_DOS_PARTITION
+#define CONFIG_CMD_EXT2
+
+#define CONFIG_LIBATA
+#define CONFIG_SYS_IDE_MAXBUS		1
+#define CONFIG_SYS_IDE_MAXDEVICE	1
+#define CONFIG_SYS_ATA_BASE_ADDR	ORION5X_SATA_BASE
+#define CONFIG_SYS_ATA_IDE0_OFFSET	ORION5X_SATA_PORT1_OFFSET
+#define CONFIG_SYS_ATA_DATA_OFFSET	(0x0100)
+#define CONFIG_SYS_ATA_REG_OFFSET	(0x0100)
+#define CONFIG_SYS_ATA_ALT_OFFSET	(0x0100)
+#define CONFIG_SYS_ATA_STRIDE		4
+#define CONFIG_LBA48
+
+/*
  *  Environment variables configurations
  */
 #define CONFIG_ENV_IS_IN_FLASH		1
@@ -169,4 +194,10 @@
 #define CONFIG_SYS_RESET_ADDRESS	0xffff0000
 #define CONFIG_SYS_MAXARGS		16
 
+/* Debugging features */
+
+/* #define the following if u-boot will boot from RAM */
+/* #undef it if u-boot will boot from FLASH */
+#undef CONFIG_SKIP_LOWLEVEL_INIT	/* disable board lowlevel_init */
+
 #endif /* _CONFIG_EDMINIV2_H */
Signature · 1 line
1.6.4.4
#1 lore raw

PATCH 1/1 orion5x: edminiv2: add libata support

Dear Albert Aribaud,

Quoted 7 lines · In message <[email protected]> you wrote:

---
This patch:
- adds support in libata for the orion5x MVSATAHC controller;
- enables orion5x MVSTAHC port 1 on the edmini board;
- adds IDE and EXT2 commands to the edminiv2 command set.

What exactly do you mean by "libata"? Do we have something like this
in U-Boot?

Quoted 4 lines

+/* ED Mini V2 uses SATA PORT1. Initialize this port and disable
+ * disable low power on it
+ */
+ /* mask for isolating IPM and DET fields in SControl register */

Incorrect multiline comment style.

common/cmd_ide.c input_swap_data(int dev, ulong *sect_buf, int words) · line 862

Quoted 3 lines
common/cmd_ide.c +2 -1
-#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH)
+#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH) \
+	|| defined(__ARM__)

Please do not add to this mess of tests, but introduce a single feature-specific #define instead.

common/cmd_ide.c input_swap_data(int dev, ulong *sect_buf, int words) · line 862

Quoted 3 lines
common/cmd_ide.c +2 -1
-#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH)
+#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH) \
+	|| defined(__ARM__)

Ditto here and everywhere else.

include/configs/edminiv2.h line 202

Quoted 6 lines
include/configs/edminiv2.h +6 -0
+/* Debugging features */
+
+/* #define the following if u-boot will boot from RAM */
+/* #undef it if u-boot will boot from FLASH */
+#undef CONFIG_SKIP_LOWLEVEL_INIT	/* disable board lowlevel_init */
+

This seems to be an unrelated change (like someother, smaller ones). Please make sure to split your patches into independent parts.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
An armed society is a polite society.
#2 lore raw

PATCH 1/1 orion5x: edminiv2: add libata support

Hi Wolfgang,

Le 30/06/2010 23:39, Wolfgang Denk a ?crit :

Quoted 11 lines

Dear Albert Aribaud,

Quoted 7 lines · In message<[email protected]> you wrote:

---
This patch:
- adds support in libata for the orion5x MVSATAHC controller;
- enables orion5x MVSTAHC port 1 on the edmini board;
- adds IDE and EXT2 commands to the edminiv2 command set.

Quoted 2 lines

What exactly do you mean by "libata"? Do we have something like this
in U-Boot?

My mistake: I meant ide. I'd started this work looking into the libata.c block driver but realized later that it wasn't what I needed, but the term stuck in my mind. I'll fix references to mention IDE instead.

Quoted 6 lines
Quoted 4 lines

+/* ED Mini V2 uses SATA PORT1. Initialize this port and disable
+ * disable low power on it
+ */
+ /* mask for isolating IPM and DET fields in SControl register */

Incorrect multiline comment style.

Will this be ok?

	/*
	 * ED Mini V2 [...]
	 * disable [...]
	 */

	/* mask for [...] */
Quoted 6 lines

common/cmd_ide.c input_swap_data(int dev, ulong *sect_buf, int words) · line 862

Quoted 3 lines
common/cmd_ide.c +2 -1
-#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH)
+#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH) \
+	|| defined(__ARM__)

Please do not add to this mess of tests, but introduce a single feature-specific #define instead.

Will do. Would CONFIG_IDE_USE_INSW_OUTSW do? Basically, that's what the test is for: either use outsw()/insw() or use outw()/inw() within a loop.

Note that this change does not relate per se to my patch and requires addition of this #define to a lot of config header files. Wouldn't it be better if I submitted it as an independent atomic patch?

Quoted 9 lines

include/configs/edminiv2.h line 202

Quoted 6 lines
include/configs/edminiv2.h +6 -0
+/* Debugging features */
+
+/* #define the following if u-boot will boot from RAM */
+/* #undef it if u-boot will boot from FLASH */
+#undef CONFIG_SKIP_LOWLEVEL_INIT	/* disable board lowlevel_init */
+

This seems to be an unrelated change (like someother, smaller ones). Please make sure to split your patches into independent parts.

I'll put them in two separate patches, one for fixing typos and one for adding the CONFIG_SKIP_LOWLEVEL_INIT comments and line.

Quoted 3 lines

Best regards,

Wolfgang Denk

Thanks for the feedback.

Amicalement,

Signature · 1 line
Albert.
#3 lore raw

PATCH 1/1 orion5x: edminiv2: add libata support

Dear Albert ARIBAUD,

Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 2 lines

Incorrect multiline comment style.

Will this be ok?

Yes.

Quoted 9 lines
Quoted 6 lines

common/cmd_ide.c input_swap_data(int dev, ulong *sect_buf, int words) · line 862

Quoted 3 lines
common/cmd_ide.c +2 -1
-#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH)
+#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH) \
+	|| defined(__ARM__)

Please do not add to this mess of tests, but introduce a single feature-specific #define instead.

Will do. Would CONFIG_IDE_USE_INSW_OUTSW do? Basically, that's what the > test is for: either use outsw()/insw() or use outw()/inw() within a loop.

Or CONFIG_IDE_SWAP_IO or similar?

Quoted 3 lines

Note that this change does not relate per se to my patch and requires addition of this #define to a lot of config header files. Wouldn't it be better if I submitted it as an independent atomic patch?

Indeed this should be then a part 1/N patch in your series.

Quoted 2 lines

I'll put them in two separate patches, one for fixing typos and one for > adding the CONFIG_SKIP_LOWLEVEL_INIT comments and line.

Thanks.

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
They weren't that important. They were merely at the top. The  people
who  really  run organizations are usually found several levels down,
where it's still possible to get things done.
                                      - Terry Pratchett, _Small Gods_
#4 lore raw

PATCH 1/1 orion5x: edminiv2: add libata support

This patch is superseded by a new patch set.

Amicalement,

Signature · 1 line
Albert.
#5 lore raw

PATCH 1/4 ide: add configuration CONFIG_IDE_SWAP_IO

---
 arch/powerpc/include/asm/config.h |    3 +++
 common/cmd_ide.c                  |   22 +++++++++++++---------
 doc/README.PXA_CF                 |    8 ++++++++
 include/configs/ap325rxa.h        |    1 +
 include/configs/ms7720se.h        |    1 +
 include/configs/r2dplus.h         |    1 +
 include/configs/r7780mp.h         |    1 +
 7 files changed, 28 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/config.h +3 -0
index fc3facb..371989d 100644
@@ -76,4 +76,7 @@
 /* Relocation to SDRAM works on all PPC boards */
 #define CONFIG_RELOC_FIXUP_WORKS
 
+/* All PPC boards must swap IDE bytes */
+#define CONFIG_IDE_SWAP_IO
+
 #endif /* _ASM_CONFIG_H_ */
common/cmd_ide.c +13 -9
index 8bd8920..0d7a309 100644
@@ -45,6 +45,10 @@
 #include <mpc5xxx.h>
 #endif
 
+#ifdef CONFIG_ORION5X
+#include <asm/arch/orion5x.h>
+#endif
+
 #include <ide.h>
 #include <ata.h>
 
@@ -854,7 +858,7 @@ input_swap_data(int dev, ulong *sect_buf, int words)
 #endif	/* __LITTLE_ENDIAN || CONFIG_AU1X00 */
 
 
-#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH)
+#if defined(CONFIG_IDE_SWAP_IO)
 static void
 output_data(int dev, ulong *sect_buf, int words)
 {
@@ -898,15 +902,15 @@ output_data(int dev, ulong *sect_buf, int words)
 	}
 #endif
 }
-#else	/* ! __PPC__ */
+#else	/* ! CONFIG_IDE_SWAP_IO */
 static void
 output_data(int dev, ulong *sect_buf, int words)
 {
 	outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words<<1);
 }
-#endif	/* __PPC__ */
+#endif	/* CONFIG_IDE_SWAP_IO */
 
-#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA) || defined(CONFIG_SH)
+#if defined(CONFIG_IDE_SWAP_IO)
 static void
 input_data(int dev, ulong *sect_buf, int words)
 {
@@ -956,14 +960,14 @@ input_data(int dev, ulong *sect_buf, int words)
 	}
 #endif
 }
-#else	/* ! __PPC__ */
+#else	/* ! CONFIG_IDE_SWAP_IO */
 static void
 input_data(int dev, ulong *sect_buf, int words)
 {
 	insw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words << 1);
 }
 
-#endif	/* __PPC__ */
+#endif	/* CONFIG_IDE_SWAP_IO */
 
 /* -------------------------------------------------------------------------
  */
@@ -1580,7 +1584,7 @@ int ide_device_present(int dev)
  * ATAPI Support
  */
 
-#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA)
+#if defined(CONFIG_IDE_SWAP_IO)
 /* since ATAPI may use commands with not 4 bytes alligned length
  * we have our own transfer functions, 2 bytes alligned */
 static void
@@ -1647,7 +1651,7 @@ input_data_shorts(int dev, ushort *sect_buf, int shorts)
 #endif
 }
 
-#else	/* ! __PPC__ */
+#else	/* ! CONFIG_IDE_SWAP_IO */
 static void
 output_data_shorts(int dev, ushort *sect_buf, int shorts)
 {
@@ -1660,7 +1664,7 @@ input_data_shorts(int dev, ushort *sect_buf, int shorts)
 	insw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, shorts);
 }
 
-#endif	/* __PPC__ */
+#endif	/* CONFIG_IDE_SWAP_IO */
 
 /*
  * Wait until (Status & mask) == res, or timeout (in ms)
doc/README.PXA_CF +8 -0
index 6a0f236..1d76b32 100644
@@ -6,6 +6,14 @@ follow the connections of the standard lubbock. Anyway just the block
 marked memory configuration should be touched since the other parameters
 are imposed by the PXA architecture.
 
+EDIT 2010-07-01: in common/cmd_ide.c, having CONFIG_PXA_PCMCIA defined
+would cause looping on inw()/outw() rather than using insw()/outsw(),
+thus making sure IDE / ATA bytes are properly swapped. This behaviour
+is now controlled by CONFIG_IDE_SWAP_IO, therefore PXA boards with
+PCMCIA should #define CONFIG_IDE_SWAP_IO.
+
+#define CONFIG_IDE_SWAP_IO
+
 #define CONFIG_PXA_PCMCIA 1
 #define CONFIG_PXA_IDE 1
 
include/configs/ap325rxa.h +1 -0
index 70dd47e..80a5797 100644
@@ -138,6 +138,7 @@
 #define CONFIG_SYS_ATA_DATA_OFFSET	0x200	/* data reg offset */
 #define CONFIG_SYS_ATA_REG_OFFSET	0x200	/* reg offset */
 #define CONFIG_SYS_ATA_ALT_OFFSET	0x210	/* alternate register offset */
+#define CONFIG_IDE_SWAP_IO
 
 /* if you use all NOR Flash , you change dip-switch. Please see Manual. */
 #define CONFIG_SYS_MAX_FLASH_BANKS	1
include/configs/ms7720se.h +1 -0
index ba0a3f8..0ea3527 100644
@@ -122,5 +122,6 @@
 #define CONFIG_SYS_ATA_DATA_OFFSET	0		/* data reg offset */
 #define CONFIG_SYS_ATA_REG_OFFSET	0		/* reg offset */
 #define CONFIG_SYS_ATA_ALT_OFFSET	0x200		/* alternate register offset */
+#define CONFIG_IDE_SWAP_IO
 
 #endif	/* __MS7720SE_H */
include/configs/r2dplus.h +1 -0
index 8931b97..955f3ff 100644
@@ -96,6 +96,7 @@
 #define CONFIG_SYS_ATA_DATA_OFFSET	0x1000	/* data reg offset */
 #define CONFIG_SYS_ATA_REG_OFFSET	0x1000	/* reg offset */
 #define CONFIG_SYS_ATA_ALT_OFFSET	0x800	/* alternate register offset */
+#define CONFIG_IDE_SWAP_IO
 
 /*
  * SuperH PCI Bridge Configration
include/configs/r7780mp.h +1 -0
index 71c570e..3afe93a 100644
@@ -171,6 +171,7 @@
 #define CONFIG_SYS_ATA_DATA_OFFSET     0x1000          /* data reg offset */
 #define CONFIG_SYS_ATA_REG_OFFSET      0x1000          /* reg offset */
 #define CONFIG_SYS_ATA_ALT_OFFSET      0x800           /* alternate register offset */
+#define CONFIG_IDE_SWAP_IO
 #endif /* CONFIG_CMD_IDE */
 
 #endif /* __R7780RP_H */
Signature · 1 line
1.6.4.4
#6 lore raw

PATCH 2/4 orion5x: edminiv2: add CMD_IDE support

---
 arch/arm/include/asm/arch-orion5x/orion5x.h |   20 ++++++++++++++++++
 board/LaCie/edminiv2/config.mk              |    6 ++++-
 board/LaCie/edminiv2/edminiv2.c             |   26 ++++++++++++++++++++++++
 include/configs/edminiv2.h                  |   29 +++++++++++++++++++++++++-
 4 files changed, 78 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-orion5x/orion5x.h +20 -0
index 4008c84..11de968 100644
@@ -55,6 +55,26 @@
 #define ORION5X_USB20_PORT0_BASE		(ORION5X_REGISTER(0x50000))
 #define ORION5X_USB20_PORT1_BASE		(ORION5X_REGISTER(0xA0000))
 #define ORION5X_EGIGA_BASE			(ORION5X_REGISTER(0x72000))
+#define ORION5X_SATA_BASE			(ORION5X_REGISTER(0x80000))
+#define ORION5X_SATA_PORT0_OFFSET		0x2000
+#define ORION5X_SATA_PORT1_OFFSET		0x4000
+
+/*
+ * SATA definitions needed for controller initialization
+ */
+/* SControl register address */
+#define ORION5X_SATA_PORT1_SCONTROL_REG \
+	(ORION5X_SATA_BASE+ORION5X_SATA_PORT1_OFFSET+0x308)
+/* Mask and values for device DETection and link initialization */
+#define ORION5X_SATA_SCONTROL_DET_MASK		0x0000000F
+#define ORION5X_SATA_SCONTROL_DET_NONE		0x00000000
+#define ORION5X_SATA_SCONTROL_DET_INIT		0x00000001
+/* Mask and values for device Interface Power Management */
+#define ORION5X_SATA_SCONTROL_IMP_MASK		0x00000F00
+#define ORION5X_SATA_SCONTROL_IMP_NO_LP_ALLOWED	0x00000300
+
+/* Orion5x will need byte-swapping if using ATA registers */
+#define CONFIG_IDE_SWAP_IO
 
 #define CONFIG_MAX_RAM_BANK_SIZE		(64*1024*1024)
 
board/LaCie/edminiv2/config.mk +5 -1
index 3dec1aa..1606cca 100644
@@ -24,4 +24,8 @@
 # MA 02110-1301 USA
 #
 
-TEXT_BASE = 0x00100000
+# As the Linux  kernel will load from 00008000 up and we cannot tell
+# how big it can be, let U-Boot run in the topmost megabyte of the
+# ED Mini V2 64 megabyte DRAM.
+
+TEXT_BASE = 0x03F00000
board/LaCie/edminiv2/edminiv2.c +26 -0
index 54c0ffe..84375c2 100644
@@ -80,13 +80,39 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
 }
 #endif				/* CONFIG_SYS_FLASH_CFI */
 
+/*
+ * ED Mini V2 uses SATA PORT1. Initialize this port and
+ * disable low power on it.
+ */
+
+/* mask for isolating IPM and DET fields in SControl register */
+#define EDMINIV2_SCONTROL_MASK (ORION5X_SATA_SCONTROL_DET_MASK \
+	|| ORION5X_SATA_SCONTROL_IMP_MASK)
+
+/* IPM and DET values for initializing link */
+#define EDMINIV2_PORT_INIT (ORION5X_SATA_SCONTROL_DET_INIT \
+	|| ORION5X_SATA_SCONTROL_IMP_NO_LP_ALLOWED)
+
+/* IPM and DET values to use link once initialized */
+#define EDMINIV2_PORT_USE (ORION5X_SATA_SCONTROL_DET_NONE \
+	|| ORION5X_SATA_SCONTROL_IMP_NO_LP_ALLOWED)
+
 int board_init(void)
 {
+	u32 reg;
+
 	/* arch number of board */
 	gd->bd->bi_arch_number = MACH_TYPE_EDMINI_V2;
 
 	/* boot parameter start at 256th byte of RAM base */
 	gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
 
+	/* reset port 1 of SATAHC controller */
+	reg = readl(ORION5X_SATA_PORT1_SCONTROL_REG);
+	reg = (reg & ~EDMINIV2_SCONTROL_MASK) | EDMINIV2_PORT_INIT;
+	writel(reg, ORION5X_SATA_PORT1_SCONTROL_REG);
+	reg = (reg & ~EDMINIV2_SCONTROL_MASK) | EDMINIV2_PORT_USE;
+	writel(reg, ORION5X_SATA_PORT1_SCONTROL_REG);
+
 	return 0;
 }
include/configs/edminiv2.h +27 -2
index c3d95a0..5c328c8 100644
@@ -52,6 +52,12 @@
 #define CONFIG_SYS_HZ		1000
 
 /*
+ * __io is necessary for cmd_ide to compile
+ */
+
+#define __io
+
+/*
  * Board-specific values for Orion5x MPP low level init:
  * - MPPs 12 to 15 are SATA LEDs (mode 5)
  * - Others are GPIO/unused (mode 3 for MPP0, mode 5 for
@@ -60,7 +66,7 @@
 
 #define ORION5X_MPP0_7		0x00000003
 #define ORION5X_MPP8_15		0x55550000
-#define ORION5X_MPP16_23	0x00000000
+#define ORION5X_MPP16_23	0x00005555
 
 /*
  * Board-specific values for Orion5x GPIO low level init:
@@ -74,7 +80,6 @@
  */
 
 #define ORION5X_GPIO_OUT_ENABLE	0x03fcffff
-#define ORION5X_GPIO_OUT_VALUE	0x03fcffff
 
 /*
  * NS16550 Configuration
@@ -131,6 +136,7 @@
  * Commands configuration - using default command set for now
  */
 #include <config_cmd_default.h>
+
 /*
  * Disabling some default commands for staggered bring-up
  */
@@ -139,6 +145,25 @@
 #undef CONFIG_CMD_NFS	/* no NFS since no net */
 
 /*
+ * ED Mini has a connector for SATA Port 1
+ */
+
+#define CONFIG_CMD_IDE
+#define CONFIG_DOS_PARTITION
+#define CONFIG_CMD_EXT2
+
+#define CONFIG_LIBATA
+#define CONFIG_SYS_IDE_MAXBUS		1
+#define CONFIG_SYS_IDE_MAXDEVICE	1
+#define CONFIG_SYS_ATA_BASE_ADDR	ORION5X_SATA_BASE
+#define CONFIG_SYS_ATA_IDE0_OFFSET	ORION5X_SATA_PORT1_OFFSET
+#define CONFIG_SYS_ATA_DATA_OFFSET	(0x0100)
+#define CONFIG_SYS_ATA_REG_OFFSET	(0x0100)
+#define CONFIG_SYS_ATA_ALT_OFFSET	(0x0100)
+#define CONFIG_SYS_ATA_STRIDE		4
+#define CONFIG_LBA48
+
+/*
  *  Environment variables configurations
  */
 #define CONFIG_ENV_IS_IN_FLASH		1
Signature · 1 line
1.6.4.4
#7 lore raw

PATCH 3/4 orion5x: fix typo in comment

---
 arch/arm/include/asm/arch-orion5x/orion5x.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/include/asm/arch-orion5x/orion5x.h +1 -1
index 11de968..2009ac5 100644
@@ -38,7 +38,7 @@
 #if defined(CONFIG_FEROCEON)
 #include <asm/arch/cpu.h>
 
-/* SOC specific definations */
+/* SOC specific definitions */
 #define ORION5X_REGISTER(x)			(ORION5X_REGS_PHY_BASE + x)
 
 /* Documented registers */
Signature · 1 line
1.6.4.4
#8 lore raw

PATCH 4/4 edminiv2: inttroduce CONFIG_SKIP_LOWLEVEL_INIT

---
 include/configs/edminiv2.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
include/configs/edminiv2.h +6 -0
index 5c328c8..923cca9 100644
@@ -194,4 +194,10 @@
 #define CONFIG_SYS_RESET_ADDRESS	0xffff0000
 #define CONFIG_SYS_MAXARGS		16
 
+/* Debugging features */
+
+/* #define the following if u-boot will boot from RAM */
+/* #undef it if u-boot will boot from FLASH */
+#undef CONFIG_SKIP_LOWLEVEL_INIT	/* disable board lowlevel_init */
+
 #endif /* _CONFIG_EDMINIV2_H */
Signature · 1 line
1.6.4.4
#9 lore raw

PATCH 1/1 orion5x: edminiv2: add libata support

In reply to Albert Aribaud

Le 30/06/2010 23:30, Albert Aribaud a ?crit :

Quoted 4 lines

This patch:
- adds support in libata for the orion5x MVSATAHC controller;
- enables orion5x MVSTAHC port 1 on the edmini board;
- adds IDE and EXT2 commands to the edminiv2 command set.

Note: commands "ide", "esxt2ls" and "ext2load" have been successfully tested. Command "diskboot" was not tested but should work as it requires no specific support wrt other disk-related commands.

Amicalement,

Signature · 1 line
Albert.
#10 lore raw

PATCH 1/1 orion5x: edminiv2: add libata support

In reply to Albert Aribaud
Quoted 6 lines · Albert Aribaud

---
This patch:
- adds support in libata for the orion5x MVSATAHC controller;
- enables orion5x MVSTAHC port 1 on the edmini board;
- adds IDE and EXT2 commands to the edminiv2 command set.

Just a heads up. I posted a patch with a sata-driver for kirkwood a while back. (We use this with our board and it seems to work fine)

http://lists.denx.de/pipermail/u-boot/2010-June/073147.html

Which might have some similarities to the sata controller on orion.

/Tor

#11 lore raw

PATCH 1/1 orion5x: edminiv2: add libata support

Quoted 18 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Tor Krill
Sent: Thursday, July 01, 2010 1:07 PM
To: Albert Aribaud
Cc: u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] orion5x: edminiv2: add libata support

Quoted 6 lines · Albert Aribaud

---
This patch:
- adds support in libata for the orion5x MVSATAHC controller;
- enables orion5x MVSTAHC port 1 on the edmini board;
- adds IDE and EXT2 commands to the edminiv2 command set.

Quoted 4 lines

Just a heads up. I posted a patch with a sata-driver for kirkwood a while back. (We use this with our board and it seems to work fine)

http://lists.denx.de/pipermail/u-boot/2010-June/073147.html

I was just trying to test it, May I know relevant board configs?

Quoted 2 lines

Which might have some similarities to the sata controller on orion.

like egiga, we can think of having single sata driver for this.

Regards..
Prafulla . .

Quoted 8 lines

/Tor

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#12 lore raw

PATCH 1/1 orion5x: edminiv2: add libata support

Quoted 17 lines · Prafulla Wadaskar
Quoted 17 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Tor Krill
Sent: Thursday, July 01, 2010 1:07 PM
To: Albert Aribaud
Cc: u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] orion5x: edminiv2: add libata support

Quoted 6 lines · Albert Aribaud

---
This patch:
- adds support in libata for the orion5x MVSATAHC controller;
- enables orion5x MVSTAHC port 1 on the edmini board;
- adds IDE and EXT2 commands to the edminiv2 command set.

Quoted 6 lines
Quoted 4 lines

Just a heads up. I posted a patch with a sata-driver for kirkwood a while back. (We use this with our board and it seems to work fine)

http://lists.denx.de/pipermail/u-boot/2010-June/073147.html

I was just trying to test it, May I know relevant board configs?

On our board we have:

/*
* Disk configuration
*/
#define CONFIG_SATA_MV
#define CONFIG_SYS_SATA_MAX_DEVICE 2

#ifdef CONFIG_SATA_MV
#define CONFIG_LBA48
#define CONFIG_LIBATA
#define CONFIG_CMD_SATA
#define CONFIG_DOS_PARTITION
#define CONFIG_CMD_EXT2
#endif

Hopefully i have not missed anything :)

Quoted 4 lines
Quoted 2 lines

Which might have some similarities to the sata controller on orion.

like egiga, we can think of having single sata driver for this.

My thoughts to.

/Tor

#13 lore raw

PATCH 1/1 orion5x: edminiv2: add libata support

In reply to Prafulla Wadaskar

Le 01/07/2010 10:41, Prafulla Wadaskar a ?crit :

Quoted 21 lines
Quoted 21 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Tor Krill
Sent: Thursday, July 01, 2010 1:07 PM
To: Albert Aribaud
Cc: u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] orion5x: edminiv2: add libata support

Quoted 6 lines · Albert Aribaud

---
This patch:
- adds support in libata for the orion5x MVSATAHC controller;
- enables orion5x MVSTAHC port 1 on the edmini board;
- adds IDE and EXT2 commands to the edminiv2 command set.

Just a heads up. I posted a patch with a sata-driver for kirkwood a while back. (We use this with our board and it seems to work fine)

Quoted 8 lines
Quoted 1 line

http://lists.denx.de/pipermail/u-boot/2010-June/073147.html

I was just trying to test it, May I know relevant board configs?

Quoted 2 lines

Which might have some similarities to the sata controller on orion.

like egiga, we can think of having single sata driver for this.

I'm not against looking into integrating the sata-mv driver for orion5x as a SoC; but I'll retain the IDE approach at least for the ED Mini where NOR Flash space might be scarce and disk DMA at bootloader stage isn't a must IMO.

Regarding egiga sharing between kirkwood and orion5x, I have recently submitted a set of patches to the list with a request for comments.

Quoted 2 lines

Regards..
Prafulla . .

Amicalement,

Signature · 1 line
Albert.
#14 lore raw

PATCH 1/1 orion5x: edminiv2: add libata support

In reply to Tor Krill

Le 01/07/2010 09:36, Tor Krill a ?crit :

Quoted 8 lines · Albert Aribaud
Quoted 6 lines

---
This patch:
- adds support in libata for the orion5x MVSATAHC controller;
- enables orion5x MVSTAHC port 1 on the edmini board;
- adds IDE and EXT2 commands to the edminiv2 command set.

Quoted 8 lines

Just a heads up. I posted a patch with a sata-driver for kirkwood a while back. (We use this with our board and it seems to work fine)

http://lists.denx.de/pipermail/u-boot/2010-June/073147.html

Which might have some similarities to the sata controller on orion.

/Tor

Thanks Tor -- Now we're both informed of each other's dev. :)

First off : the MVSATAHX controller is indeed quite similar between both SoCs, at least from a u-boot perspective, where disk usage is limited to loading a kernel and initrd.

I see your sata_mv driver originates in the Linux kernel driver and makes use of DMA. This might be a real gain when loading big files often ; in my case, I considered that u-boot will only kick in once in a while and load a less-than-2MB kernel and possibly a less-than-3MB initrd, and while relying on the IDE PIO code will certainly make it slower than with sata_mv, the occasional couple of 10th of ms is a fair price for the very small footprint -- ED Mini V2 is short on NOR Flash space.

Amicalement,

Signature · 1 line
Albert.
#15 lore raw

PATCH 1/1 orion5x: edminiv2: add libata support

In reply to Tor Krill

Le 01/07/2010 09:36, Tor Krill a ?crit :

Quoted 8 lines · Albert Aribaud
Quoted 6 lines

---
This patch:
- adds support in libata for the orion5x MVSATAHC controller;
- enables orion5x MVSTAHC port 1 on the edmini board;
- adds IDE and EXT2 commands to the edminiv2 command set.

Quoted 8 lines

Just a heads up. I posted a patch with a sata-driver for kirkwood a while back. (We use this with our board and it seems to work fine)

http://lists.denx.de/pipermail/u-boot/2010-June/073147.html

Which might have some similarities to the sata controller on orion.

/Tor

Thanks Tor -- Now we're both informed of each other's dev. :)

First off : the MVSATAHC controller is indeed quite similar between both SoCs, at least from a u-boot perspective, where disk usage is limited to loading a kernel and initrd. IIRC its code is already shared on the Linux side between orion5x and kirkwood.

I see your sata_mv driver originates in the Linux kernel driver and makes use of DMA. This might be a real gain when loading big files often ; in my case, I considered that u-boot will only kick in once in a while and load a less-than-2MB kernel and possibly a less-than-3MB initrd, and while relying on the IDE PIO code will certainly make it slower than with sata_mv, the occasional couple of 10th of ms is a fair price for the very small footprint -- ED Mini V2 is short on NOR Flash space.

Amicalement,

Signature · 1 line
Albert.