* [PATCH 2/3 for next] PCM051: Clean up lowlevel code
2013-08-23 7:00 [PATCH 1/3 for next] AM33xx: Cleanup of lowlevel code Teresa Gámez
@ 2013-08-23 7:00 ` Teresa Gámez
2013-08-23 7:00 ` [PATCH 3/3 for next] beaglebone: " Teresa Gámez
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Teresa Gámez @ 2013-08-23 7:00 UTC (permalink / raw)
To: barebox
Use now the initialisation functions from am33xx_generic.
Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
---
arch/arm/boards/pcm051/lowlevel.c | 206 +++++++------------------------------
1 files changed, 36 insertions(+), 170 deletions(-)
diff --git a/arch/arm/boards/pcm051/lowlevel.c b/arch/arm/boards/pcm051/lowlevel.c
index dd06c6a..faf23fc 100644
--- a/arch/arm/boards/pcm051/lowlevel.c
+++ b/arch/arm/boards/pcm051/lowlevel.c
@@ -13,171 +13,36 @@
#include <mach/am33xx-mux.h>
#include <mach/wdt.h>
-/* UART Defines */
-#define UART_SYSCFG_OFFSET (0x54)
-#define UART_SYSSTS_OFFSET (0x58)
-
-#define UART_RESET (0x1 << 1)
-#define UART_CLK_RUNNING_MASK 0x1
-#define UART_SMART_IDLE_EN (0x1 << 0x3)
-
-/* AM335X EMIF Register values */
-#define VTP_CTRL_READY (0x1 << 5)
-#define VTP_CTRL_ENABLE (0x1 << 6)
-#define VTP_CTRL_START_EN (0x1)
-#define CMD_FORCE 0x00 /* common #def */
-#define CMD_DELAY 0x00
-
-#define EMIF_READ_LATENCY 0x06
-#define EMIF_SDCFG 0x61C04832 /* CL 5, CWL 5 */
-#define EMIF_SDREF 0x0000093B
-
-#define EMIF_TIM1 0x0668A39B
-#define EMIF_TIM2 0x26337FDA
-#define EMIF_TIM3 0x501F830F
-
-#define DLL_LOCK_DIFF 0x0
-#define PHY_WR_DATA 0xC1
-#define RD_DQS 0x3B
-#define WR_DQS 0x85
-#define PHY_FIFO_WE 0x100
-#define INVERT_CLKOUT 0x1
-#define PHY_RANK0_DELAY 0x01
-#define DDR_IOCTRL_VALUE 0x18B
-#define CTRL_SLAVE_RATIO 0x40
-#define PHY_LVL_MODE 0x1
-#define DDR_ZQ_CFG 0x50074BE4
-
-static void Cmd_Macro_Config(void)
-{
- writel(CTRL_SLAVE_RATIO, AM33XX_CMD0_CTRL_SLAVE_RATIO_0);
- writel(CMD_FORCE, AM33XX_CMD0_CTRL_SLAVE_FORCE_0);
- writel(CMD_DELAY, AM33XX_CMD0_CTRL_SLAVE_DELAY_0);
- writel(DLL_LOCK_DIFF, AM33XX_CMD0_DLL_LOCK_DIFF_0);
- writel(INVERT_CLKOUT, AM33XX_CMD0_INVERT_CLKOUT_0);
-
- writel(CTRL_SLAVE_RATIO, AM33XX_CMD1_CTRL_SLAVE_RATIO_0);
- writel(CMD_FORCE, AM33XX_CMD1_CTRL_SLAVE_FORCE_0);
- writel(CMD_DELAY, AM33XX_CMD1_CTRL_SLAVE_DELAY_0);
- writel(DLL_LOCK_DIFF, AM33XX_CMD1_DLL_LOCK_DIFF_0);
- writel(INVERT_CLKOUT, AM33XX_CMD1_INVERT_CLKOUT_0);
-
- writel(CTRL_SLAVE_RATIO, AM33XX_CMD2_CTRL_SLAVE_RATIO_0);
- writel(CMD_FORCE, AM33XX_CMD2_CTRL_SLAVE_FORCE_0);
- writel(CMD_DELAY, AM33XX_CMD2_CTRL_SLAVE_DELAY_0);
- writel(DLL_LOCK_DIFF, AM33XX_CMD2_DLL_LOCK_DIFF_0);
- writel(INVERT_CLKOUT, AM33XX_CMD2_INVERT_CLKOUT_0);
-}
-
-static void config_vtp(void)
-{
- writel(readl(AM33XX_VTP0_CTRL_REG) | VTP_CTRL_ENABLE,
- AM33XX_VTP0_CTRL_REG);
- writel(readl(AM33XX_VTP0_CTRL_REG) & (~VTP_CTRL_START_EN),
- AM33XX_VTP0_CTRL_REG);
- writel(readl(AM33XX_VTP0_CTRL_REG) | VTP_CTRL_START_EN,
- AM33XX_VTP0_CTRL_REG);
-
- /* Poll for READY */
- while ((readl(AM33XX_VTP0_CTRL_REG) &
- VTP_CTRL_READY) != VTP_CTRL_READY);
-}
-
-static void phy_config_data(void)
-{
- writel(RD_DQS, AM33XX_DATA0_RD_DQS_SLAVE_RATIO_0);
- writel(WR_DQS, AM33XX_DATA0_WR_DQS_SLAVE_RATIO_0);
- writel(PHY_FIFO_WE, AM33XX_DATA0_FIFO_WE_SLAVE_RATIO_0);
- writel(PHY_WR_DATA, AM33XX_DATA0_WR_DATA_SLAVE_RATIO_0);
-
- writel(RD_DQS, AM33XX_DATA1_RD_DQS_SLAVE_RATIO_0);
- writel(WR_DQS, AM33XX_DATA1_WR_DQS_SLAVE_RATIO_0);
- writel(PHY_FIFO_WE, AM33XX_DATA1_FIFO_WE_SLAVE_RATIO_0);
- writel(PHY_WR_DATA, AM33XX_DATA1_WR_DATA_SLAVE_RATIO_0);
-}
-
-static void config_emif(void)
-{
- /*Program EMIF0 CFG Registers*/
- writel(EMIF_READ_LATENCY, AM33XX_EMIF4_0_REG(DDR_PHY_CTRL_1));
- writel(EMIF_READ_LATENCY,
- AM33XX_EMIF4_0_REG(DDR_PHY_CTRL_1_SHADOW));
- writel(EMIF_READ_LATENCY, AM33XX_EMIF4_0_REG(DDR_PHY_CTRL_2));
- writel(EMIF_TIM1, AM33XX_EMIF4_0_REG(SDRAM_TIM_1));
- writel(EMIF_TIM1, AM33XX_EMIF4_0_REG(SDRAM_TIM_1_SHADOW));
- writel(EMIF_TIM2, AM33XX_EMIF4_0_REG(SDRAM_TIM_2));
- writel(EMIF_TIM2, AM33XX_EMIF4_0_REG(SDRAM_TIM_2_SHADOW));
- writel(EMIF_TIM3, AM33XX_EMIF4_0_REG(SDRAM_TIM_3));
- writel(EMIF_TIM3, AM33XX_EMIF4_0_REG(SDRAM_TIM_3_SHADOW));
-
- writel(EMIF_SDREF, AM33XX_EMIF4_0_REG(SDRAM_REF_CTRL));
- writel(EMIF_SDREF, AM33XX_EMIF4_0_REG(SDRAM_REF_CTRL_SHADOW));
-
- writel(EMIF_SDCFG, AM33XX_EMIF4_0_REG(SDRAM_CONFIG));
- writel(DDR_ZQ_CFG, AM33XX_EMIF4_0_REG(ZQ_CONFIG));
-
- while ((readl(AM33XX_EMIF4_0_REG(SDRAM_STATUS)) & 0x4) != 0x4);
-}
-
-static void pcm051_config_ddr(void)
-{
- enable_ddr_clocks();
-
- config_vtp();
-
- /* init mode */
- writel(PHY_LVL_MODE, AM33XX_DATA0_WRLVL_INIT_MODE_0);
- writel(PHY_LVL_MODE, AM33XX_DATA0_GATELVL_INIT_MODE_0);
- writel(PHY_LVL_MODE, AM33XX_DATA1_WRLVL_INIT_MODE_0);
- writel(PHY_LVL_MODE, AM33XX_DATA1_GATELVL_INIT_MODE_0);
-
- Cmd_Macro_Config();
- phy_config_data();
-
- writel(PHY_RANK0_DELAY, AM33XX_DATA0_RANK0_DELAYS_0);
- writel(PHY_RANK0_DELAY, AM33XX_DATA1_RANK0_DELAYS_0);
-
- writel(DDR_IOCTRL_VALUE, AM33XX_DDR_CMD0_IOCTRL);
- writel(DDR_IOCTRL_VALUE, AM33XX_DDR_CMD1_IOCTRL);
- writel(DDR_IOCTRL_VALUE, AM33XX_DDR_CMD2_IOCTRL);
- writel(DDR_IOCTRL_VALUE, AM33XX_DDR_DATA0_IOCTRL);
- writel(DDR_IOCTRL_VALUE, AM33XX_DDR_DATA1_IOCTRL);
-
- writel(readl(AM33XX_DDR_IO_CTRL) &
- 0xefffffff, AM33XX_DDR_IO_CTRL);
- writel(readl(AM33XX_DDR_CKE_CTRL) |
- 0x00000001, AM33XX_DDR_CKE_CTRL);
-
- config_emif();
-}
-
-/*
- * early system init of muxing and clocks.
- */
-void pcm051_sram_init(void)
-{
- u32 regVal, uart_base;
-
- /* Setup the PLLs and the clocks for the peripherals */
- pll_init(MPUPLL_M_600, 25);
-
- pcm051_config_ddr();
-
- /* UART softreset */
- am33xx_enable_uart0_pin_mux();
- uart_base = AM33XX_UART0_BASE;
-
- regVal = readl(uart_base + UART_SYSCFG_OFFSET);
- regVal |= UART_RESET;
- writel(regVal, (uart_base + UART_SYSCFG_OFFSET));
- while ((readl(uart_base + UART_SYSSTS_OFFSET) &
- UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK);
-
- /* Disable smart idle */
- regVal = readl((uart_base + UART_SYSCFG_OFFSET));
- regVal |= UART_SMART_IDLE_EN;
- writel(regVal, (uart_base + UART_SYSCFG_OFFSET));
-}
+static const struct am33xx_cmd_control MT41J256M8HX15E_2x256M8_cmd = {
+ .slave_ratio0 = 0x40,
+ .dll_lock_diff0 = 0x0,
+ .invert_clkout0 = 0x1,
+ .slave_ratio1 = 0x40,
+ .dll_lock_diff1 = 0x0,
+ .invert_clkout1 = 0x1,
+ .slave_ratio2 = 0x40,
+ .dll_lock_diff2 = 0x0,
+ .invert_clkout2 = 0x1,
+};
+
+static const struct am33xx_emif_regs MT41J256M8HX15E_2x256M8_regs = {
+ .emif_read_latency = 0x6,
+ .emif_tim1 = 0x0668A39B,
+ .emif_tim2 = 0x26337FDA,
+ .emif_tim3 = 0x501F830F,
+ .sdram_config = 0x61C04832,
+ .zq_config = 0x50074BE4,
+ .sdram_ref_ctrl = 0x0000093B,
+};
+
+static const struct am33xx_ddr_data MT41J256M8HX15E_2x256M8_data = {
+ .rd_slave_ratio0 = 0x3B,
+ .wr_dqs_slave_ratio0 = 0x85,
+ .fifo_we_slave_ratio0 = 0x100,
+ .wr_slave_ratio0 = 0xC1,
+ .use_rank0_delay = 0x01,
+ .dll_lock_diff0 = 0x0,
+};
/**
* @brief The basic entry point for board initialization.
@@ -190,8 +55,6 @@ void pcm051_sram_init(void)
*/
static int pcm051_board_init(void)
{
- int in_sdram = running_in_sdram();
-
/* WDT1 is already running when the bootloader gets control
* Disable it to avoid "random" resets
*/
@@ -201,9 +64,12 @@ static int pcm051_board_init(void)
writel(WDT_DISABLE_CODE2, AM33XX_WDT_REG(WSPR));
while (readl(AM33XX_WDT_REG(WWPS)) != 0x0);
- /* Dont reconfigure SDRAM while running in SDRAM! */
- if (!in_sdram)
- pcm051_sram_init();
+ am335x_sdram_init(MPUPLL_M_600, 25, 0x18B,
+ &MT41J256M8HX15E_2x256M8_cmd,
+ &MT41J256M8HX15E_2x256M8_regs,
+ &MT41J256M8HX15E_2x256M8_data);
+
+ am33xx_enable_uart0_pin_mux();
return 0;
}
--
1.7.0.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3 for next] beaglebone: Clean up lowlevel code
2013-08-23 7:00 [PATCH 1/3 for next] AM33xx: Cleanup of lowlevel code Teresa Gámez
2013-08-23 7:00 ` [PATCH 2/3 for next] PCM051: Clean up " Teresa Gámez
@ 2013-08-23 7:00 ` Teresa Gámez
2013-08-26 6:49 ` [PATCH 1/3 for next] AM33xx: Cleanup of " Sascha Hauer
2013-09-02 8:23 ` Jan Lübbe
3 siblings, 0 replies; 6+ messages in thread
From: Teresa Gámez @ 2013-08-23 7:00 UTC (permalink / raw)
To: barebox
Using here now the initialisiation functions in
am33xx_generic.
Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
---
I'm not able to test this as I do not have a beaglebone.
But I do have oritened on the u-boot code which does
not seem to differ between ddr2 and ddr3 initalisation
functions.
How bad this colidates now with Saschas and Jans bbb patches.
Maybe someone could test this anyway? And we'll find a solution
for a cleaner lowlevel code..
arch/arm/boards/beaglebone/lowlevel.c | 252 ++++++--------------------------
1 files changed, 48 insertions(+), 204 deletions(-)
diff --git a/arch/arm/boards/beaglebone/lowlevel.c b/arch/arm/boards/beaglebone/lowlevel.c
index 2f3b3df..368188a 100644
--- a/arch/arm/boards/beaglebone/lowlevel.c
+++ b/arch/arm/boards/beaglebone/lowlevel.c
@@ -12,211 +12,59 @@
#include <mach/am33xx-mux.h>
#include <mach/wdt.h>
-/* UART Defines */
-#define UART_SYSCFG_OFFSET (0x54)
-#define UART_SYSSTS_OFFSET (0x58)
-
-#define UART_RESET (0x1 << 1)
-#define UART_CLK_RUNNING_MASK 0x1
-#define UART_SMART_IDLE_EN (0x1 << 0x3)
-
-/* AM335X EMIF Register values */
-#define EMIF_SDMGT 0x80000000
-#define EMIF_SDRAM 0x00004650
-#define EMIF_PHYCFG 0x2
-#define DDR_PHY_RESET (0x1 << 10)
-#define DDR_FUNCTIONAL_MODE_EN 0x1
-#define DDR_PHY_READY (0x1 << 2)
-#define VTP_CTRL_READY (0x1 << 5)
-#define VTP_CTRL_ENABLE (0x1 << 6)
-#define VTP_CTRL_LOCK_EN (0x1 << 4)
-#define VTP_CTRL_START_EN (0x1)
-#define DDR2_RATIO 0x80 /* for mDDR */
-#define CMD_FORCE 0x00 /* common #def */
-#define CMD_DELAY 0x00
-
-#define EMIF_READ_LATENCY 0x05
-#define EMIF_TIM1 0x0666B3D6
-#define EMIF_TIM2 0x143731DA
-#define EMIF_TIM3 0x00000347
-#define EMIF_SDCFG 0x43805332
-#define EMIF_SDREF 0x0000081a
-#define DDR2_DLL_LOCK_DIFF 0x0
#define DDR2_RD_DQS 0x12
#define DDR2_PHY_FIFO_WE 0x80
-
-#define DDR2_INVERT_CLKOUT 0x00
#define DDR2_WR_DQS 0x00
#define DDR2_PHY_WRLVL 0x00
#define DDR2_PHY_GATELVL 0x00
#define DDR2_PHY_WR_DATA 0x40
-#define PHY_RANK0_DELAY 0x01
-#define PHY_DLL_LOCK_DIFF 0x0
-#define DDR_IOCTRL_VALUE 0x18B
-
-static void beaglebone_data_macro_config(int dataMacroNum)
-{
- u32 BaseAddrOffset = 0x00;
-
- if (dataMacroNum == 1)
- BaseAddrOffset = 0xA4;
-
- __raw_writel(((DDR2_RD_DQS<<30)|(DDR2_RD_DQS<<20)
- |(DDR2_RD_DQS<<10)|(DDR2_RD_DQS<<0)),
- (AM33XX_DATA0_RD_DQS_SLAVE_RATIO_0 + BaseAddrOffset));
- __raw_writel(DDR2_RD_DQS>>2,
- (AM33XX_DATA0_RD_DQS_SLAVE_RATIO_1 + BaseAddrOffset));
- __raw_writel(((DDR2_WR_DQS<<30)|(DDR2_WR_DQS<<20)
- |(DDR2_WR_DQS<<10)|(DDR2_WR_DQS<<0)),
- (AM33XX_DATA0_WR_DQS_SLAVE_RATIO_0 + BaseAddrOffset));
- __raw_writel(DDR2_WR_DQS>>2,
- (AM33XX_DATA0_WR_DQS_SLAVE_RATIO_1 + BaseAddrOffset));
- __raw_writel(((DDR2_PHY_WRLVL<<30)|(DDR2_PHY_WRLVL<<20)
- |(DDR2_PHY_WRLVL<<10)|(DDR2_PHY_WRLVL<<0)),
- (AM33XX_DATA0_WRLVL_INIT_RATIO_0 + BaseAddrOffset));
- __raw_writel(DDR2_PHY_WRLVL>>2,
- (AM33XX_DATA0_WRLVL_INIT_RATIO_1 + BaseAddrOffset));
- __raw_writel(((DDR2_PHY_GATELVL<<30)|(DDR2_PHY_GATELVL<<20)
- |(DDR2_PHY_GATELVL<<10)|(DDR2_PHY_GATELVL<<0)),
- (AM33XX_DATA0_GATELVL_INIT_RATIO_0 + BaseAddrOffset));
- __raw_writel(DDR2_PHY_GATELVL>>2,
- (AM33XX_DATA0_GATELVL_INIT_RATIO_1 + BaseAddrOffset));
- __raw_writel(((DDR2_PHY_FIFO_WE<<30)|(DDR2_PHY_FIFO_WE<<20)
- |(DDR2_PHY_FIFO_WE<<10)|(DDR2_PHY_FIFO_WE<<0)),
- (AM33XX_DATA0_FIFO_WE_SLAVE_RATIO_0 + BaseAddrOffset));
- __raw_writel(DDR2_PHY_FIFO_WE>>2,
- (AM33XX_DATA0_FIFO_WE_SLAVE_RATIO_1 + BaseAddrOffset));
- __raw_writel(((DDR2_PHY_WR_DATA<<30)|(DDR2_PHY_WR_DATA<<20)
- |(DDR2_PHY_WR_DATA<<10)|(DDR2_PHY_WR_DATA<<0)),
- (AM33XX_DATA0_WR_DATA_SLAVE_RATIO_0 + BaseAddrOffset));
- __raw_writel(DDR2_PHY_WR_DATA>>2,
- (AM33XX_DATA0_WR_DATA_SLAVE_RATIO_1 + BaseAddrOffset));
- __raw_writel(PHY_DLL_LOCK_DIFF,
- (AM33XX_DATA0_DLL_LOCK_DIFF_0 + BaseAddrOffset));
-}
-
-static void beaglebone_cmd_macro_config(void)
-{
- __raw_writel(DDR2_RATIO, AM33XX_CMD0_CTRL_SLAVE_RATIO_0);
- __raw_writel(CMD_FORCE, AM33XX_CMD0_CTRL_SLAVE_FORCE_0);
- __raw_writel(CMD_DELAY, AM33XX_CMD0_CTRL_SLAVE_DELAY_0);
- __raw_writel(DDR2_DLL_LOCK_DIFF, AM33XX_CMD0_DLL_LOCK_DIFF_0);
- __raw_writel(DDR2_INVERT_CLKOUT, AM33XX_CMD0_INVERT_CLKOUT_0);
-
- __raw_writel(DDR2_RATIO, AM33XX_CMD1_CTRL_SLAVE_RATIO_0);
- __raw_writel(CMD_FORCE, AM33XX_CMD1_CTRL_SLAVE_FORCE_0);
- __raw_writel(CMD_DELAY, AM33XX_CMD1_CTRL_SLAVE_DELAY_0);
- __raw_writel(DDR2_DLL_LOCK_DIFF, AM33XX_CMD1_DLL_LOCK_DIFF_0);
- __raw_writel(DDR2_INVERT_CLKOUT, AM33XX_CMD1_INVERT_CLKOUT_0);
-
- __raw_writel(DDR2_RATIO, AM33XX_CMD2_CTRL_SLAVE_RATIO_0);
- __raw_writel(CMD_FORCE, AM33XX_CMD2_CTRL_SLAVE_FORCE_0);
- __raw_writel(CMD_DELAY, AM33XX_CMD2_CTRL_SLAVE_DELAY_0);
- __raw_writel(DDR2_DLL_LOCK_DIFF, AM33XX_CMD2_DLL_LOCK_DIFF_0);
- __raw_writel(DDR2_INVERT_CLKOUT, AM33XX_CMD2_INVERT_CLKOUT_0);
-}
-
-static void beaglebone_config_vtp(void)
-{
- __raw_writel(__raw_readl(AM33XX_VTP0_CTRL_REG) | VTP_CTRL_ENABLE,
- AM33XX_VTP0_CTRL_REG);
- __raw_writel(__raw_readl(AM33XX_VTP0_CTRL_REG) & (~VTP_CTRL_START_EN),
- AM33XX_VTP0_CTRL_REG);
- __raw_writel(__raw_readl(AM33XX_VTP0_CTRL_REG) | VTP_CTRL_START_EN,
- AM33XX_VTP0_CTRL_REG);
-
- /* Poll for READY */
- while ((__raw_readl(AM33XX_VTP0_CTRL_REG) & VTP_CTRL_READY) != VTP_CTRL_READY);
-}
-
-static void beaglebone_config_emif_ddr2(void)
-{
- u32 i;
-
- /*Program EMIF0 CFG Registers*/
- __raw_writel(EMIF_READ_LATENCY, AM33XX_EMIF4_0_REG(DDR_PHY_CTRL_1));
- __raw_writel(EMIF_READ_LATENCY, AM33XX_EMIF4_0_REG(DDR_PHY_CTRL_1_SHADOW));
- __raw_writel(EMIF_READ_LATENCY, AM33XX_EMIF4_0_REG(DDR_PHY_CTRL_2));
- __raw_writel(EMIF_TIM1, AM33XX_EMIF4_0_REG(SDRAM_TIM_1));
- __raw_writel(EMIF_TIM1, AM33XX_EMIF4_0_REG(SDRAM_TIM_1_SHADOW));
- __raw_writel(EMIF_TIM2, AM33XX_EMIF4_0_REG(SDRAM_TIM_2));
- __raw_writel(EMIF_TIM2, AM33XX_EMIF4_0_REG(SDRAM_TIM_2_SHADOW));
- __raw_writel(EMIF_TIM3, AM33XX_EMIF4_0_REG(SDRAM_TIM_3));
- __raw_writel(EMIF_TIM3, AM33XX_EMIF4_0_REG(SDRAM_TIM_3_SHADOW));
-
- __raw_writel(EMIF_SDCFG, AM33XX_EMIF4_0_REG(SDRAM_CONFIG));
- __raw_writel(EMIF_SDCFG, AM33XX_EMIF4_0_REG(SDRAM_CONFIG2));
-
- /* __raw_writel(EMIF_SDMGT, EMIF0_0_SDRAM_MGMT_CTRL);
- __raw_writel(EMIF_SDMGT, EMIF0_0_SDRAM_MGMT_CTRL_SHD); */
- __raw_writel(0x00004650, AM33XX_EMIF4_0_REG(SDRAM_REF_CTRL));
- __raw_writel(0x00004650, AM33XX_EMIF4_0_REG(SDRAM_REF_CTRL_SHADOW));
-
- for (i = 0; i < 5000; i++) {
-
- }
-
- /* __raw_writel(EMIF_SDMGT, EMIF0_0_SDRAM_MGMT_CTRL);
- __raw_writel(EMIF_SDMGT, EMIF0_0_SDRAM_MGMT_CTRL_SHD); */
- __raw_writel(EMIF_SDREF, AM33XX_EMIF4_0_REG(SDRAM_REF_CTRL));
- __raw_writel(EMIF_SDREF, AM33XX_EMIF4_0_REG(SDRAM_REF_CTRL_SHADOW));
-
- __raw_writel(EMIF_SDCFG, AM33XX_EMIF4_0_REG(SDRAM_CONFIG));
- __raw_writel(EMIF_SDCFG, AM33XX_EMIF4_0_REG(SDRAM_CONFIG2));
-}
-
-static void beaglebone_config_ddr(void)
-{
- enable_ddr_clocks();
-
- beaglebone_config_vtp();
-
- beaglebone_cmd_macro_config();
- beaglebone_data_macro_config(0);
- beaglebone_data_macro_config(1);
-
- __raw_writel(PHY_RANK0_DELAY, AM33XX_DATA0_RANK0_DELAYS_0);
- __raw_writel(PHY_RANK0_DELAY, AM33XX_DATA1_RANK0_DELAYS_0);
-
- __raw_writel(DDR_IOCTRL_VALUE, AM33XX_DDR_CMD0_IOCTRL);
- __raw_writel(DDR_IOCTRL_VALUE, AM33XX_DDR_CMD1_IOCTRL);
- __raw_writel(DDR_IOCTRL_VALUE, AM33XX_DDR_CMD2_IOCTRL);
- __raw_writel(DDR_IOCTRL_VALUE, AM33XX_DDR_DATA0_IOCTRL);
- __raw_writel(DDR_IOCTRL_VALUE, AM33XX_DDR_DATA1_IOCTRL);
-
- __raw_writel(__raw_readl(AM33XX_DDR_IO_CTRL) & 0xefffffff, AM33XX_DDR_IO_CTRL);
- __raw_writel(__raw_readl(AM33XX_DDR_CKE_CTRL) | 0x00000001, AM33XX_DDR_CKE_CTRL);
-
- beaglebone_config_emif_ddr2();
-}
-
-/*
- * early system init of muxing and clocks.
- */
-void beaglebone_sram_init(void)
-{
- u32 regVal, uart_base;
-
- /* Setup the PLLs and the clocks for the peripherals */
- pll_init(MPUPLL_M_500, 24);
-
- beaglebone_config_ddr();
-
- /* UART softreset */
- uart_base = AM33XX_UART0_BASE;
-
- regVal = __raw_readl(uart_base + UART_SYSCFG_OFFSET);
- regVal |= UART_RESET;
- __raw_writel(regVal, (uart_base + UART_SYSCFG_OFFSET) );
- while ((__raw_readl(uart_base + UART_SYSSTS_OFFSET) &
- UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK);
-
- /* Disable smart idle */
- regVal = __raw_readl((uart_base + UART_SYSCFG_OFFSET));
- regVal |= UART_SMART_IDLE_EN;
- __raw_writel(regVal, (uart_base + UART_SYSCFG_OFFSET));
-}
+static const struct am33xx_cmd_control ddr2_cmd_ctrl = {
+ .slave_ratio0 = 0x80,
+ .dll_lock_diff0 = 0x0,
+ .invert_clkout0 = 0x0,
+ .slave_ratio1 = 0x80,
+ .dll_lock_diff1 = 0x0,
+ .invert_clkout1 = 0x0,
+ .slave_ratio2 = 0x80,
+ .dll_lock_diff2 = 0x0,
+ .invert_clkout2 = 0x0,
+};
+
+static const struct am33xx_emif_regs ddr2_regs = {
+ .emif_read_latency = 0x5,
+ .emif_tim1 = 0x0666B3D6,
+ .emif_tim2 = 0x143731DA,
+ .emif_tim3 = 0x00000347,
+ .sdram_config = 0x43805332,
+ .sdram_config2 = 0x43805332,
+ .sdram_ref_ctrl = 0x0000081a,
+};
+
+static const struct am33xx_ddr_data ddr2_data = {
+ .rd_slave_ratio0 = (DDR2_RD_DQS << 30) | (DDR2_RD_DQS << 20) |
+ (DDR2_RD_DQS << 10) | (DDR2_RD_DQS << 0),
+ .wr_dqs_slave_ratio0 = (DDR2_WR_DQS << 30) | (DDR2_WR_DQS << 20) |
+ (DDR2_WR_DQS << 10) | (DDR2_WR_DQS << 0),
+ .wrlvl_init_ratio0 = (DDR2_PHY_WRLVL << 30) |
+ (DDR2_PHY_WRLVL << 20) |
+ (DDR2_PHY_WRLVL << 10) |
+ (DDR2_PHY_WRLVL << 0),
+ .gatelvl_init_ratio0 = (DDR2_PHY_GATELVL << 30) |
+ (DDR2_PHY_GATELVL << 20) |
+ (DDR2_PHY_GATELVL << 10) |
+ (DDR2_PHY_GATELVL << 0),
+ .fifo_we_slave_ratio0 = (DDR2_PHY_FIFO_WE << 30) |
+ (DDR2_PHY_FIFO_WE << 20) |
+ (DDR2_PHY_FIFO_WE << 10) |
+ (DDR2_PHY_FIFO_WE << 0),
+ .wr_slave_ratio0 = (DDR2_PHY_WR_DATA << 30) |
+ (DDR2_PHY_WR_DATA << 20) |
+ (DDR2_PHY_WR_DATA << 10) |
+ (DDR2_PHY_WR_DATA << 0),
+ .use_rank0_delay = 0x01,
+ .dll_lock_diff0 = 0x0,
+};
/**
* @brief The basic entry point for board initialization.
@@ -229,8 +77,6 @@ void beaglebone_sram_init(void)
*/
static int beaglebone_board_init(void)
{
- int in_sdram = running_in_sdram();
-
/* WDT1 is already running when the bootloader gets control
* Disable it to avoid "random" resets
*/
@@ -239,11 +85,9 @@ static int beaglebone_board_init(void)
__raw_writel(WDT_DISABLE_CODE2, AM33XX_WDT_REG(WSPR));
while(__raw_readl(AM33XX_WDT_REG(WWPS)) != 0x0);
- /* Dont reconfigure SDRAM while running in SDRAM! */
- if (!in_sdram)
- beaglebone_sram_init();
+ am335x_sdram_init(MPUPLL_M_500, 24, 0x18B,
+ &ddr2_cmd_ctrl, &ddr2_regs, &ddr2_data);
- /* Enable pin mux */
am33xx_enable_uart0_pin_mux();
return 0;
--
1.7.0.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3 for next] AM33xx: Cleanup of lowlevel code
2013-08-23 7:00 [PATCH 1/3 for next] AM33xx: Cleanup of lowlevel code Teresa Gámez
2013-08-23 7:00 ` [PATCH 2/3 for next] PCM051: Clean up " Teresa Gámez
2013-08-23 7:00 ` [PATCH 3/3 for next] beaglebone: " Teresa Gámez
@ 2013-08-26 6:49 ` Sascha Hauer
2013-08-26 12:19 ` Teresa Gamez
2013-09-02 8:23 ` Jan Lübbe
3 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2013-08-26 6:49 UTC (permalink / raw)
To: Teresa Gámez; +Cc: barebox
Hi Teresa,
On Fri, Aug 23, 2013 at 09:00:20AM +0200, Teresa Gámez wrote:
> There is a lot of duplicate lowlevel code between the
> am33xx boards. Move this code to am33xx_generic and
> create structs for sdram settings.
I'm mostly fine with this series. I made some small changes to it and
rebased my beaglebone black series ontop of it. I'm about to repost the
my series which includes your changed patches. It would be good if you
could have a look.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3 for next] AM33xx: Cleanup of lowlevel code
2013-08-26 6:49 ` [PATCH 1/3 for next] AM33xx: Cleanup of " Sascha Hauer
@ 2013-08-26 12:19 ` Teresa Gamez
0 siblings, 0 replies; 6+ messages in thread
From: Teresa Gamez @ 2013-08-26 12:19 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Am 26.08.2013 08:49, schrieb Sascha Hauer:
> Hi Teresa,
>
> On Fri, Aug 23, 2013 at 09:00:20AM +0200, Teresa Gámez wrote:
>> There is a lot of duplicate lowlevel code between the
>> am33xx boards. Move this code to am33xx_generic and
>> create structs for sdram settings.
> I'm mostly fine with this series. I made some small changes to it and
> rebased my beaglebone black series ontop of it. I'm about to repost the
> my series which includes your changed patches. It would be good if you
> could have a look.
Beside of the missing inlcude everything looks fine.
Thanks.
Teresa
>
> Sascha
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3 for next] AM33xx: Cleanup of lowlevel code
2013-08-23 7:00 [PATCH 1/3 for next] AM33xx: Cleanup of lowlevel code Teresa Gámez
` (2 preceding siblings ...)
2013-08-26 6:49 ` [PATCH 1/3 for next] AM33xx: Cleanup of " Sascha Hauer
@ 2013-09-02 8:23 ` Jan Lübbe
3 siblings, 0 replies; 6+ messages in thread
From: Jan Lübbe @ 2013-09-02 8:23 UTC (permalink / raw)
To: Teresa Gámez; +Cc: barebox
On Fri, 2013-08-23 at 09:00 +0200, Teresa Gámez wrote:
> There is a lot of duplicate lowlevel code between the
> am33xx boards. Move this code to am33xx_generic and
> create structs for sdram settings.
>
> Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
Just for comparison, the current u-boot mainline does something similar:
http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/include/asm/arch-am33xx/ddr_defs.h;hb=HEAD
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread