All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/5] sun6i: A31s / CSQ_CS908 board support
@ 2014-11-23 13:43 Hans de Goede
  2014-11-23 13:43 ` [U-Boot] [PATCH v2 1/5] sun6i: Make dram clk and zq value Kconfig options Hans de Goede
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Hans de Goede @ 2014-11-23 13:43 UTC (permalink / raw)
  To: u-boot

Hi,

Here is v2 of my sun6i: A31s / CSQ_CS908 board support series.

Changes since v1:
-"sun6i: Make dram clk and zq value Kconfig options"
 -Mention changing of default zq value in commit message
 -Drop "if EXPERT" usage, as that breaks setting things through defconfig files
-"sun6i: Drop some "unknown magic" from dram init"
 -Mention that the info on what the dropped unknown magic did comes from
  Allwinner
-"sun6i: Add new CSQ_CS908 board"
 -Add setting of LDO for phy, so that network works
 -Correct usb vbus settings

Regards,

Hans

^ permalink raw reply	[flat|nested] 19+ messages in thread
* [U-Boot] [PATCH v2 1/5] sun6i: Make dram clk and zq value Kconfig options
@ 2014-11-23 13:39 Hans de Goede
  0 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2014-11-23 13:39 UTC (permalink / raw)
  To: u-boot

It turns out that there is a too large spread between boards to handle this
with a default value, turn this into Kconfig options, and set the values
the factory images are using for the Colombus and Mele_M9 boards.

Note this changes the ZQ default when not overriden through defconfig from
120 to 123, as that is what most boards seem to actually use.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 arch/arm/cpu/armv7/sunxi/dram_sun6i.c | 12 +++++-------
 board/sunxi/Kconfig                   | 17 +++++++++++++++++
 configs/Colombus_defconfig            |  2 ++
 configs/Mele_M9_defconfig             |  2 ++
 4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/dram_sun6i.c b/arch/arm/cpu/armv7/sunxi/dram_sun6i.c
index 10a6241..30439dc 100644
--- a/arch/arm/cpu/armv7/sunxi/dram_sun6i.c
+++ b/arch/arm/cpu/armv7/sunxi/dram_sun6i.c
@@ -17,9 +17,7 @@
 #include <asm/arch/dram.h>
 #include <asm/arch/prcm.h>
 
-/* DRAM clk & zq defaults, maybe turn these into Kconfig options ? */
-#define DRAM_CLK_DEFAULT 312000000
-#define DRAM_ZQ_DEFAULT 0x78
+#define DRAM_CLK (CONFIG_DRAM_CLK * 1000000)
 
 struct dram_sun6i_para {
 	u8 bus_width;
@@ -48,7 +46,7 @@ static void mctl_sys_init(void)
 		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
 	const int dram_clk_div = 2;
 
-	clock_set_pll5(DRAM_CLK_DEFAULT * dram_clk_div);
+	clock_set_pll5(DRAM_CLK * dram_clk_div);
 
 	clrsetbits_le32(&ccm->dram_clk_cfg, CCM_DRAMCLK_CFG_DIV0_MASK,
 		CCM_DRAMCLK_CFG_DIV0(dram_clk_div) | CCM_DRAMCLK_CFG_RST |
@@ -173,7 +171,7 @@ static void mctl_channel_init(int ch_index, struct dram_sun6i_para *para)
 
 	await_completion(&mctl_phy->pgsr, 0x03, 0x03);
 
-	writel(DRAM_ZQ_DEFAULT, &mctl_phy->zq0cr1);
+	writel(CONFIG_DRAM_ZQ, &mctl_phy->zq0cr1);
 
 	setbits_le32(&mctl_phy->pir, MCTL_PIR_CLEAR_STATUS);
 	writel(MCTL_PIR_STEP1, &mctl_phy->pir);
@@ -219,9 +217,9 @@ static void mctl_channel_init(int ch_index, struct dram_sun6i_para *para)
 	await_completion(&mctl_ctl->sstat, 0x07, 0x01);
 
 	/* Set number of clks per micro-second */
-	writel(DRAM_CLK_DEFAULT / 1000000, &mctl_ctl->togcnt1u);
+	writel(DRAM_CLK / 1000000, &mctl_ctl->togcnt1u);
 	/* Set number of clks per 100 nano-seconds */
-	writel(DRAM_CLK_DEFAULT / 10000000, &mctl_ctl->togcnt100n);
+	writel(DRAM_CLK / 10000000, &mctl_ctl->togcnt100n);
 	/* Set memory timing registers */
 	writel(MCTL_TREFI, &mctl_ctl->trefi);
 	writel(MCTL_TMRD, &mctl_ctl->tmrd);
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 246cd9a..6162227 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -32,6 +32,23 @@ config MACH_SUN8I
 
 endchoice
 
+if MACH_SUN6I
+
+config DRAM_CLK
+	int "sun6i dram clock speed"
+	default 312
+	---help---
+	Set the dram clock speed, valid range 240 - 480, must be a multiple
+	of 24.
+
+config DRAM_ZQ
+	int "sun6i dram zq value"
+	default 123
+	---help---
+	Set the dram zq value.
+
+endif
+
 config SYS_CONFIG_NAME
 	string
 	default "sun4i" if MACH_SUN4I
diff --git a/configs/Colombus_defconfig b/configs/Colombus_defconfig
index de78a01..9b4968f 100644
--- a/configs/Colombus_defconfig
+++ b/configs/Colombus_defconfig
@@ -5,3 +5,5 @@ CONFIG_USB_KEYBOARD=n
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN6I=y
 +S:CONFIG_TARGET_COLOMBUS=y
++S:CONFIG_DRAM_CLK=288
++S:CONFIG_DRAM_ZQ=379
diff --git a/configs/Mele_M9_defconfig b/configs/Mele_M9_defconfig
index 40eabce..740b931 100644
--- a/configs/Mele_M9_defconfig
+++ b/configs/Mele_M9_defconfig
@@ -5,6 +5,8 @@ CONFIG_FDTFILE="sun6i-a31-m9.dtb"
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN6I=y
 +S:CONFIG_TARGET_MELE_M9=y
++S:CONFIG_DRAM_CLK=312
++S:CONFIG_DRAM_ZQ=120
 # Ethernet phy power
 +S:CONFIG_AXP221_DLDO1_VOLT=3300
 # USB hub power
-- 
2.1.0

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

end of thread, other threads:[~2014-12-19 10:02 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-23 13:43 [U-Boot] [PATCH v2 0/5] sun6i: A31s / CSQ_CS908 board support Hans de Goede
2014-11-23 13:43 ` [U-Boot] [PATCH v2 1/5] sun6i: Make dram clk and zq value Kconfig options Hans de Goede
2014-11-25  8:55   ` Ian Campbell
2014-11-25  9:08     ` Hans de Goede
2014-12-12 20:29   ` Siarhei Siamashka
2014-11-23 13:43 ` [U-Boot] [PATCH v2 2/5] sun6i: Add sunxi_get_ss_bonding_id() function Hans de Goede
2014-11-23 13:43 ` [U-Boot] [PATCH v2 3/5] sun6i: dram: Do not try to initialize a second dram chan on A31s Hans de Goede
2014-11-25  8:56   ` Ian Campbell
2014-12-12 20:25   ` Siarhei Siamashka
2014-12-13 11:00     ` Hans de Goede
2014-12-19 10:02       ` Siarhei Siamashka
2014-11-23 13:43 ` [U-Boot] [PATCH v2 4/5] sun6i: Drop some "unknown magic" from dram init Hans de Goede
2014-12-12 20:24   ` Siarhei Siamashka
2014-12-13 10:57     ` Hans de Goede
2014-11-23 13:43 ` [U-Boot] [PATCH v2 5/5] sun6i: Add new CSQ_CS908 board Hans de Goede
2014-12-14 14:57   ` Ian Campbell
2014-12-18 10:39     ` Hans de Goede
2014-12-18 18:56       ` Ian Campbell
  -- strict thread matches above, loose matches on Subject: below --
2014-11-23 13:39 [U-Boot] [PATCH v2 1/5] sun6i: Make dram clk and zq value Kconfig options Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.