blob: d9752096c18d55f33d2237ef196d347ea9b27bc6 [file] [log] [blame]
Xiangfu Liu7306ccb2011-10-12 12:24:06 +08001/*
2 * Authors: Xiangfu Liu <xiangfu@sharism.cc>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 3 of the License, or (at your option) any later version.
8 */
9
10#include <common.h>
11#include <asm/io.h>
12#include <asm/jz4740.h>
13
14DECLARE_GLOBAL_DATA_PTR;
15
16static void gpio_init(void)
17{
18 unsigned int i;
19
20 /* Initialize NAND Flash Pins */
21 __gpio_as_nand();
22
23 /* Initialize SDRAM pins */
24 __gpio_as_sdram_16bit_4720();
25
26 /* Initialize LCD pins */
27 __gpio_as_lcd_18bit();
28
29 /* Initialize MSC pins */
30 __gpio_as_msc();
31
32 /* Initialize Other pins */
33 for (i = 0; i < 7; i++) {
34 __gpio_as_input(GPIO_KEYIN_BASE + i);
35 __gpio_enable_pull(GPIO_KEYIN_BASE + i);
36 }
37
38 for (i = 0; i < 8; i++) {
39 __gpio_as_output(GPIO_KEYOUT_BASE + i);
40 __gpio_clear_pin(GPIO_KEYOUT_BASE + i);
41 }
42
43 __gpio_as_input(GPIO_KEYIN_8);
44 __gpio_enable_pull(GPIO_KEYIN_8);
45
46 /* enable the TP4, TP5 as UART0 */
47 __gpio_jtag_to_uart0();
48
49 __gpio_as_output(GPIO_AUDIO_POP);
50 __gpio_set_pin(GPIO_AUDIO_POP);
51
52 __gpio_as_output(GPIO_LCD_CS);
53 __gpio_clear_pin(GPIO_LCD_CS);
54
55 __gpio_as_output(GPIO_AMP_EN);
56 __gpio_clear_pin(GPIO_AMP_EN);
57
58 __gpio_as_output(GPIO_SDPW_EN);
59 __gpio_disable_pull(GPIO_SDPW_EN);
60 __gpio_clear_pin(GPIO_SDPW_EN);
61
62 __gpio_as_input(GPIO_SD_DETECT);
63 __gpio_disable_pull(GPIO_SD_DETECT);
64
65 __gpio_as_input(GPIO_USB_DETECT);
66 __gpio_enable_pull(GPIO_USB_DETECT);
67}
68
69static void cpm_init(void)
70{
71 struct jz4740_cpm *cpm = (struct jz4740_cpm *)JZ4740_CPM_BASE;
Marek Vasut837affb2012-08-12 16:53:35 +020072 uint32_t reg = readl(&cpm->clkgr);
Xiangfu Liu7306ccb2011-10-12 12:24:06 +080073
74 reg |= CPM_CLKGR_IPU |
75 CPM_CLKGR_CIM |
76 CPM_CLKGR_I2C |
77 CPM_CLKGR_SSI |
78 CPM_CLKGR_UART1 |
79 CPM_CLKGR_SADC |
80 CPM_CLKGR_UHC |
81 CPM_CLKGR_UDC |
82 CPM_CLKGR_AIC1;
83
Marek Vasut837affb2012-08-12 16:53:35 +020084 writel(reg, &cpm->clkgr);
Xiangfu Liu7306ccb2011-10-12 12:24:06 +080085}
86
87int board_early_init_f(void)
88{
89 gpio_init();
90 cpm_init();
91 calc_clocks(); /* calc the clocks */
92 rtc_init(); /* init rtc on any reset */
93
94 return 0;
95}
96
97/* U-Boot common routines */
98int checkboard(void)
99{
100 printf("Board: Qi LB60 (Ingenic XBurst Jz4740 SoC, Speed %ld MHz)\n",
101 gd->cpu_clk / 1000000);
102
103 return 0;
104}