Root/package/uboot-xburst/files/board/xburst/nanonote/nanonote.c

1/*
2 * Authors: Xiangfu Liu <xiangfu.z@gmail.com>
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 <command.h>
12#include <asm/mipsregs.h>
13#include <asm/jz4740.h>
14
15DECLARE_GLOBAL_DATA_PTR;
16
17static void gpio_init(void)
18{
19    /*
20     * Initialize NAND Flash Pins
21     */
22    __gpio_as_nand();
23
24    /*
25     * Initialize SDRAM pins
26     */
27    __gpio_as_sdram_16bit_4720();
28
29    /*
30     * Initialize LCD pins
31     */
32    __gpio_as_lcd_18bit();
33
34    /*
35     * Initialize MSC pins
36     */
37    __gpio_as_msc();
38
39    /*
40     * Initialize Other pins
41     */
42    unsigned int i;
43    for (i = 0; i < 7; i++){
44        __gpio_as_input(GPIO_KEYIN_BASE + i);
45        __gpio_enable_pull(GPIO_KEYIN_BASE + i);
46    }
47
48    for (i = 0; i < 8; i++) {
49        __gpio_as_output(GPIO_KEYOUT_BASE + i);
50        __gpio_clear_pin(GPIO_KEYOUT_BASE + i);
51    }
52
53    /* enable the TP4, TP5 as UART0 */
54    __gpio_jtag_to_uart0();
55
56    /*
57     * Initialize UART0 pins, in Ben NanoNote uart0 and keyin8 use the
58     * same gpio, init the gpio as uart0 cause a keyboard bug. so for
59     * end user we disable the uart0
60     */
61    if (__gpio_get_pin(GPIO_KEYIN_BASE + 2) == 0){
62        /* if pressed [S] */
63        printf("[S] pressed, enable UART0\n");
64        gd->boot_option |= BOOT_WITH_ENABLE_UART;
65        __gpio_as_uart0();
66    } else {
67        __gpio_as_input(GPIO_KEYIN_8);
68        __gpio_enable_pull(GPIO_KEYIN_8);
69    }
70
71    __gpio_as_output(GPIO_AUDIO_POP);
72    __gpio_set_pin(GPIO_AUDIO_POP);
73
74    __gpio_as_output(GPIO_LCD_CS);
75    __gpio_clear_pin(GPIO_LCD_CS);
76
77    __gpio_as_output(GPIO_AMP_EN);
78    __gpio_clear_pin(GPIO_AMP_EN);
79
80    __gpio_as_output(GPIO_SDPW_EN);
81    __gpio_disable_pull(GPIO_SDPW_EN);
82    __gpio_clear_pin(GPIO_SDPW_EN);
83
84    __gpio_as_input(GPIO_SD_DETECT);
85    __gpio_disable_pull(GPIO_SD_DETECT);
86
87    __gpio_as_input(GPIO_USB_DETECT);
88    __gpio_enable_pull(GPIO_USB_DETECT);
89
90    if (__gpio_get_pin(GPIO_KEYIN_BASE + 3) == 0) {
91        printf("[M] pressed, boot from sd card\n");
92        gd->boot_option |= BOOT_FROM_SDCARD;
93    }
94}
95
96static void cpm_init(void)
97{
98    __cpm_stop_ipu();
99    __cpm_stop_cim();
100    __cpm_stop_i2c();
101    __cpm_stop_ssi();
102    __cpm_stop_uart1();
103    __cpm_stop_sadc();
104    __cpm_stop_uhc();
105    __cpm_stop_udc();
106    __cpm_stop_aic1();
107/* __cpm_stop_aic2();*/
108}
109
110void board_early_init(void)
111{
112    gpio_init();
113    cpm_init();
114}
115
116/* U-Boot common routines */
117
118int checkboard (void)
119{
120    printf("Board: Qi LB60 (Ingenic XBurst Jz4740 SoC, Speed %d MHz)\n",
121           gd->cpu_clk / 1000000);
122
123    return 0; /* success */
124}
125

Archive Download this file



interactive