]> git.sur5r.net Git - u-boot/commitdiff
sunxi: nand: Add pinmux and clock settings for NAND support
authorKarol Gugala <kgugala@antmicro.com>
Thu, 23 Jul 2015 12:33:01 +0000 (14:33 +0200)
committerHans de Goede <hdegoede@redhat.com>
Sat, 8 Aug 2015 14:26:19 +0000 (16:26 +0200)
To enable NAND flash in sunxi SPL,
pins 0-6, 8-22 and 24 on port C are configured.

Signed-off-by: Karol Gugala <kgugala@antmicro.com>
Signed-off-by: Piotr Zierhoffer <pzierhoffer@antmicro.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
arch/arm/include/asm/arch-sunxi/clock_sun4i.h
arch/arm/include/asm/arch-sunxi/gpio.h
board/sunxi/board.c

index 58aff1687af357eca4439d1c55243def8cc8dc56..01d3e28274fce0cc680acd574f4926a76d680fb9 100644 (file)
@@ -267,6 +267,8 @@ struct sunxi_ccm_reg {
 #define CCM_MBUS_CTRL_CLK_SRC_PLL5 0x2
 #define CCM_MBUS_CTRL_GATE (0x1 << 31)
 
+#define CCM_NAND_CTRL_ENABLE           (0x1 << 31)
+
 #define CCM_MMC_CTRL_M(x)              ((x) - 1)
 #define CCM_MMC_CTRL_OCLK_DLY(x)       ((x) << 8)
 #define CCM_MMC_CTRL_N(x)              ((x) << 16)
index 8e67b3bcb87d0fe411fb95588fe85e1fbcd22f27..8382101558c8ddaffabdff1e0d602d6e5eaba00d 100644 (file)
@@ -158,6 +158,7 @@ enum sunxi_gpio_number {
 #define SUN8I_GPB_UART2                2
 #define SUN8I_A33_GPB_UART0    3
 
+#define SUNXI_GPC_NAND         2
 #define SUNXI_GPC_SDC2         3
 #define SUN6I_GPC_SDC3         4
 
index afed6a31cab6732f334d8dba2272730ee8306ac4..f85e825891bc0dbf8009d8f77c37281917f699a9 100644 (file)
@@ -107,6 +107,28 @@ int dram_init(void)
        return 0;
 }
 
+#if defined(CONFIG_SPL_NAND_SUNXI) && defined(CONFIG_SPL_BUILD)
+static void nand_pinmux_setup(void)
+{
+       unsigned int pin;
+       for (pin = SUNXI_GPC(0); pin <= SUNXI_GPC(6); pin++)
+               sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_NAND);
+
+       for (pin = SUNXI_GPC(8); pin <= SUNXI_GPC(22); pin++)
+               sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_NAND);
+
+       sunxi_gpio_set_cfgpin(SUNXI_GPC(24), SUNXI_GPC_NAND);
+}
+
+static void nand_clock_setup(void)
+{
+       struct sunxi_ccm_reg *const ccm =
+               (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+       setbits_le32(&ccm->ahb_gate0, (CLK_GATE_OPEN << AHB_GATE_OFFSET_NAND0));
+       setbits_le32(&ccm->nand0_clk_cfg, CCM_NAND_CTRL_ENABLE | AHB_DIV_1);
+}
+#endif
+
 #ifdef CONFIG_GENERIC_MMC
 static void mmc_pinmux_setup(int sdc)
 {
@@ -431,6 +453,11 @@ void sunxi_board_init(void)
        power_failed |= axp221_set_eldo(3, CONFIG_AXP221_ELDO3_VOLT);
 #endif
 
+#ifdef CONFIG_SPL_NAND_SUNXI
+       nand_pinmux_setup();
+       nand_clock_setup();
+#endif
+
        printf("DRAM:");
        ramsize = sunxi_dram_init();
        printf(" %lu MiB\n", ramsize >> 20);