[U-Boot] [PATCH] orion5x: edminiv2: add libata support

Signed-off-by: Albert Aribaud albert.aribaud@free.fr --- 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(-)
diff --git a/arch/arm/include/asm/arch-orion5x/orion5x.h b/arch/arm/include/asm/arch-orion5x/orion5x.h index 4008c84..2724a70 100644 --- a/arch/arm/include/asm/arch-orion5x/orion5x.h +++ b/arch/arm/include/asm/arch-orion5x/orion5x.h @@ -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)
diff --git a/board/LaCie/edminiv2/config.mk b/board/LaCie/edminiv2/config.mk index 3dec1aa..1606cca 100644 --- a/board/LaCie/edminiv2/config.mk +++ b/board/LaCie/edminiv2/config.mk @@ -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 diff --git a/board/LaCie/edminiv2/edminiv2.c b/board/LaCie/edminiv2/edminiv2.c index 54c0ffe..6b4f0e5 100644 --- a/board/LaCie/edminiv2/edminiv2.c +++ b/board/LaCie/edminiv2/edminiv2.c @@ -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; } diff --git a/common/cmd_ide.c b/common/cmd_ide.c index 8bd8920..08ebbf6 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -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; diff --git a/include/configs/edminiv2.h b/include/configs/edminiv2.h index c3d95a0..923cca9 100644 --- a/include/configs/edminiv2.h +++ b/include/configs/edminiv2.h @@ -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 */

Dear Albert Aribaud,
In message 1277933418-682-1-git-send-email-albert.aribaud@free.fr you wrote:
Signed-off-by: Albert Aribaud albert.aribaud@free.fr
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?
+/* 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.
-#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.
-#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.
+/* 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

Hi Wolfgang,
Le 30/06/2010 23:39, Wolfgang Denk a écrit :
Dear Albert Aribaud,
In message1277933418-682-1-git-send-email-albert.aribaud@free.fr you wrote:
Signed-off-by: Albert Aribaudalbert.aribaud@free.fr
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?
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.
+/* 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 [...] */
-#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?
+/* 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.
Best regards,
Wolfgang Denk
Thanks for the feedback.
Amicalement,

Dear Albert ARIBAUD,
In message 4C2BC6CB.1070802@free.fr you wrote:
Incorrect multiline comment style.
Will this be ok?
Yes.
-#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?
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.
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

Signed-off-by: Albert Aribaud albert.aribaud@free.fr --- 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(-)
diff --git a/arch/powerpc/include/asm/config.h b/arch/powerpc/include/asm/config.h index fc3facb..371989d 100644 --- a/arch/powerpc/include/asm/config.h +++ b/arch/powerpc/include/asm/config.h @@ -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_ */ diff --git a/common/cmd_ide.c b/common/cmd_ide.c index 8bd8920..0d7a309 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -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) diff --git a/doc/README.PXA_CF b/doc/README.PXA_CF index 6a0f236..1d76b32 100644 --- a/doc/README.PXA_CF +++ b/doc/README.PXA_CF @@ -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
diff --git a/include/configs/ap325rxa.h b/include/configs/ap325rxa.h index 70dd47e..80a5797 100644 --- a/include/configs/ap325rxa.h +++ b/include/configs/ap325rxa.h @@ -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 diff --git a/include/configs/ms7720se.h b/include/configs/ms7720se.h index ba0a3f8..0ea3527 100644 --- a/include/configs/ms7720se.h +++ b/include/configs/ms7720se.h @@ -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 */ diff --git a/include/configs/r2dplus.h b/include/configs/r2dplus.h index 8931b97..955f3ff 100644 --- a/include/configs/r2dplus.h +++ b/include/configs/r2dplus.h @@ -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 diff --git a/include/configs/r7780mp.h b/include/configs/r7780mp.h index 71c570e..3afe93a 100644 --- a/include/configs/r7780mp.h +++ b/include/configs/r7780mp.h @@ -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 */

Signed-off-by: Albert Aribaud albert.aribaud@free.fr --- 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(-)
diff --git a/arch/arm/include/asm/arch-orion5x/orion5x.h b/arch/arm/include/asm/arch-orion5x/orion5x.h index 4008c84..11de968 100644 --- a/arch/arm/include/asm/arch-orion5x/orion5x.h +++ b/arch/arm/include/asm/arch-orion5x/orion5x.h @@ -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)
diff --git a/board/LaCie/edminiv2/config.mk b/board/LaCie/edminiv2/config.mk index 3dec1aa..1606cca 100644 --- a/board/LaCie/edminiv2/config.mk +++ b/board/LaCie/edminiv2/config.mk @@ -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 diff --git a/board/LaCie/edminiv2/edminiv2.c b/board/LaCie/edminiv2/edminiv2.c index 54c0ffe..84375c2 100644 --- a/board/LaCie/edminiv2/edminiv2.c +++ b/board/LaCie/edminiv2/edminiv2.c @@ -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; } diff --git a/include/configs/edminiv2.h b/include/configs/edminiv2.h index c3d95a0..5c328c8 100644 --- a/include/configs/edminiv2.h +++ b/include/configs/edminiv2.h @@ -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

Signed-off-by: Albert Aribaud albert.aribaud@free.fr --- arch/arm/include/asm/arch-orion5x/orion5x.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/arm/include/asm/arch-orion5x/orion5x.h b/arch/arm/include/asm/arch-orion5x/orion5x.h index 11de968..2009ac5 100644 --- a/arch/arm/include/asm/arch-orion5x/orion5x.h +++ b/arch/arm/include/asm/arch-orion5x/orion5x.h @@ -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 */

Signed-off-by: Albert Aribaud albert.aribaud@free.fr --- include/configs/edminiv2.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/include/configs/edminiv2.h b/include/configs/edminiv2.h index 5c328c8..923cca9 100644 --- a/include/configs/edminiv2.h +++ b/include/configs/edminiv2.h @@ -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 */

Le 30/06/2010 23:30, Albert Aribaud a écrit :
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,

On Wed, 2010-06-30 at 23:30 +0200, Albert Aribaud wrote:
Signed-off-by: Albert Aribaud albert.aribaud@free.fr
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

-----Original Message----- From: u-boot-bounces@lists.denx.de [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Tor Krill Sent: Thursday, July 01, 2010 1:07 PM To: Albert Aribaud Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] [PATCH] orion5x: edminiv2: add libata support
On Wed, 2010-06-30 at 23:30 +0200, Albert Aribaud wrote:
Signed-off-by: Albert Aribaud albert.aribaud@free.fr
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)
I was just trying to test it, May I know relevant board configs?
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 . .
/Tor
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

On Thu, 2010-07-01 at 10:41 +0200, Prafulla Wadaskar wrote:
-----Original Message----- From: u-boot-bounces@lists.denx.de [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Tor Krill Sent: Thursday, July 01, 2010 1:07 PM To: Albert Aribaud Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] [PATCH] orion5x: edminiv2: add libata support
On Wed, 2010-06-30 at 23:30 +0200, Albert Aribaud wrote:
Signed-off-by: Albert Aribaud albert.aribaud@free.fr
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)
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 :)
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

Le 01/07/2010 10:41, Prafulla Wadaskar a écrit :
-----Original Message----- From: u-boot-bounces@lists.denx.de [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Tor Krill Sent: Thursday, July 01, 2010 1:07 PM To: Albert Aribaud Cc: u-boot@lists.denx.de Subject: Re: [U-Boot] [PATCH] orion5x: edminiv2: add libata support
On Wed, 2010-06-30 at 23:30 +0200, Albert Aribaud wrote:
Signed-off-by: Albert Aribaudalbert.aribaud@free.fr
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)
I was just trying to test it, May I know relevant board configs?
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.
Regards.. Prafulla . .
Amicalement,

Le 01/07/2010 09:36, Tor Krill a écrit :
On Wed, 2010-06-30 at 23:30 +0200, Albert Aribaud wrote:
Signed-off-by: Albert Aribaudalbert.aribaud@free.fr
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
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,

Le 01/07/2010 09:36, Tor Krill a écrit :
On Wed, 2010-06-30 at 23:30 +0200, Albert Aribaud wrote:
Signed-off-by: Albert Aribaudalbert.aribaud@free.fr
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
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,
participants (5)
-
Albert ARIBAUD
-
Albert Aribaud
-
Prafulla Wadaskar
-
Tor Krill
-
Wolfgang Denk