1 From c1383a7a5b47035bf08809bf973536af16047640 Mon Sep 17 00:00:00 2001
2 From: Terry Lv <r65388@freescale.com>
3 Date: Sun, 30 Aug 2009 22:04:05 +0800
4 Subject: [PATCH] ENGR00116083: Recovery mode support for Android on mx51.
6 Recovery mode support for Android on mx51.
8 Signed-off-by: Terry Lv <r65388@freescale.com>
11 board/freescale/imx51/imx51.c | 98 +++++
12 board/freescale/mx51_3stack/mx51_3stack.c | 108 +++++-
13 drivers/input/Makefile | 1 +
14 drivers/input/mxc_keyb.c | 598 +++++++++++++++++++++++++++++
15 drivers/mtd/nand/mxc_nand.c | 2 +-
16 include/asm-arm/arch-mx51/keypad.h | 65 ++++
17 include/configs/imx51.h | 6 +-
18 include/configs/imx51_android.h | 297 ++++++++++++++
19 include/configs/mx25_3stack.h | 4 +-
20 include/configs/mx35_3stack.h | 2 +-
21 include/configs/mx51_3stack.h | 35 ++-
22 include/configs/mx51_3stack_android.h | 289 ++++++++++++++
23 include/mxc_keyb.h | 201 ++++++++++
24 14 files changed, 1695 insertions(+), 13 deletions(-)
26 diff --git a/Makefile b/Makefile
27 index 840bfe7..b131cc7 100644
30 @@ -3242,9 +3242,11 @@ mx35_3stack_config \
31 mx35_3stack_mmc_config: unconfig
32 @$(MKCONFIG) $(@:_config=) arm arm1136 mx35_3stack freescale mx35
34 +imx51_android_config \
35 imx51_config : unconfig
36 @$(MKCONFIG) $(@:_config=) arm arm_cortexa8 imx51 freescale mx51
38 +mx51_3stack_android_config \
39 mx51_3stack_config : unconfig
40 @$(MKCONFIG) $(@:_config=) arm arm_cortexa8 mx51_3stack freescale mx51
42 diff --git a/board/freescale/imx51/imx51.c b/board/freescale/imx51/imx51.c
43 index c8efa0f..364f224 100644
44 --- a/board/freescale/imx51/imx51.c
45 +++ b/board/freescale/imx51/imx51.c
47 #include <asm/arch/iomux.h>
48 #include <asm/errno.h>
50 +#include <mxc_keyb.h>
51 +#include <asm/arch/keypad.h>
52 #include "board-imx51.h"
53 #include <asm/arch/imx_spi.h>
54 #include <asm/arch/imx_spi_pmic.h>
55 @@ -457,6 +459,24 @@ int sdhc_init(void)
59 +#if defined(CONFIG_MXC_KPD)
62 + mxc_request_iomux(MX51_PIN_KEY_COL0, IOMUX_CONFIG_ALT0);
63 + mxc_request_iomux(MX51_PIN_KEY_COL1, IOMUX_CONFIG_ALT0);
64 + mxc_request_iomux(MX51_PIN_KEY_COL2, IOMUX_CONFIG_ALT0);
65 + mxc_request_iomux(MX51_PIN_KEY_COL3, IOMUX_CONFIG_ALT0);
66 + mxc_request_iomux(MX51_PIN_KEY_COL4, IOMUX_CONFIG_ALT0);
67 + mxc_request_iomux(MX51_PIN_KEY_COL5, IOMUX_CONFIG_ALT0);
68 + mxc_request_iomux(MX51_PIN_KEY_ROW0, IOMUX_CONFIG_ALT0);
69 + mxc_request_iomux(MX51_PIN_KEY_ROW1, IOMUX_CONFIG_ALT0);
70 + mxc_request_iomux(MX51_PIN_KEY_ROW2, IOMUX_CONFIG_ALT0);
71 + mxc_request_iomux(MX51_PIN_KEY_ROW3, IOMUX_CONFIG_ALT0);
80 @@ -474,7 +494,85 @@ int board_init(void)
81 #ifdef BOARD_LATE_INIT
82 int board_late_init(void)
84 +#if defined(CONFIG_FSL_ANDROID) && defined(CONFIG_MXC_KPD)
85 + struct kpp_key_info key_info = {0, 0};
86 + int switch_delay = CONFIG_ANDROID_BOOTMOD_DELAY;
87 + int state = 0, boot_mode_switch = 0;
92 +#if defined(CONFIG_FSL_ANDROID) && defined(CONFIG_MXC_KPD)
95 + puts("Press home + power to enter recovery mode ...\n");
97 + while ((switch_delay > 0) && (!boot_mode_switch)) {
101 + /* delay 100 * 10ms */
102 + for (i = 0; !boot_mode_switch && i < 100; ++i) {
103 + /* A state machine to scan home + power key */
104 + /* Check for home + power */
105 + if (mxc_kpp_getc(&key_info)) {
109 + if (TEST_HOME_KEY_DEPRESS(key_info.val, key_info.evt)) {
112 + } else if (TEST_POWER_KEY_DEPRESS(key_info.val, key_info.evt)) {
119 + /* Home is already pressed, try to detect Power */
120 + if (TEST_POWER_KEY_DEPRESS(key_info.val,
122 + boot_mode_switch = 1;
124 + if (TEST_HOME_KEY_DEPRESS(key_info.val,
132 + /* Power is already pressed, try to detect Home */
133 + if (TEST_HOME_KEY_DEPRESS(key_info.val,
135 + boot_mode_switch = 1;
137 + if (TEST_POWER_KEY_DEPRESS(key_info.val,
148 + if (1 == boot_mode_switch) {
149 + printf("Boot mode switched to recovery mode!\n");
150 + /* Set env to recovery mode */
151 + setenv("bootargs_android", CONFIG_ANDROID_RECOVERY_BOOTARGS);
152 + setenv("bootcmd_android", CONFIG_ANDROID_RECOVERY_BOOTCMD);
153 + setenv("bootcmd", "run bootcmd_android");
158 + for (i = 0; i < 100; ++i)
166 diff --git a/board/freescale/mx51_3stack/mx51_3stack.c b/board/freescale/mx51_3stack/mx51_3stack.c
167 index 9ddee40..3d8756e 100644
168 --- a/board/freescale/mx51_3stack/mx51_3stack.c
169 +++ b/board/freescale/mx51_3stack/mx51_3stack.c
171 #include <asm/arch/mx51_pins.h>
172 #include <asm/arch/iomux.h>
174 +#include <mxc_keyb.h>
175 +#include <asm/arch/keypad.h>
176 #include "board-mx51_3stack.h"
178 DECLARE_GLOBAL_DATA_PTR;
179 @@ -175,6 +177,84 @@ int board_init(void)
180 #ifdef BOARD_LATE_INIT
181 int board_late_init(void)
183 +#if defined(CONFIG_FSL_ANDROID) && defined(CONFIG_MXC_KPD)
184 + struct kpp_key_info key_info = {0, 0};
185 + int switch_delay = CONFIG_ANDROID_BOOTMOD_DELAY;
186 + int state = 0, boot_mode_switch = 0;
190 +#if defined(CONFIG_FSL_ANDROID) && defined(CONFIG_MXC_KPD)
193 + puts("Press home + power to enter recovery mode ...\n");
195 + while ((switch_delay > 0) && (!boot_mode_switch)) {
199 + /* delay 100 * 10ms */
200 + for (i = 0; !boot_mode_switch && i < 100; ++i) {
201 + /* A state machine to scan home + power key */
202 + /* Check for home + power */
203 + if (mxc_kpp_getc(&key_info)) {
207 + if (TEST_HOME_KEY_DEPRESS(key_info.val, key_info.evt)) {
210 + } else if (TEST_POWER_KEY_DEPRESS(key_info.val, key_info.evt)) {
217 + /* Home is already pressed, try to detect Power */
218 + if (TEST_POWER_KEY_DEPRESS(key_info.val,
220 + boot_mode_switch = 1;
222 + if (TEST_HOME_KEY_DEPRESS(key_info.val,
230 + /* Power is already pressed, try to detect Home */
231 + if (TEST_HOME_KEY_DEPRESS(key_info.val,
233 + boot_mode_switch = 1;
235 + if (TEST_POWER_KEY_DEPRESS(key_info.val,
246 + if (1 == boot_mode_switch) {
247 + printf("Boot mode switched to recovery mode!\n");
248 + /* Set env to recovery mode */
249 + setenv("bootargs_android", CONFIG_ANDROID_RECOVERY_BOOTARGS);
250 + setenv("bootcmd_android", CONFIG_ANDROID_RECOVERY_BOOTCMD);
251 + setenv("bootcmd", "run bootcmd_android");
256 + for (i = 0; i < 100; ++i)
264 @@ -182,6 +262,15 @@ int board_late_init(void)
267 printf("Board: MX51 3STACK [");
269 + if (system_rev & CHIP_REV_2_0) {
271 + } else if (system_rev & CHIP_REV_1_1) {
277 switch (__REG(SRC_BASE_ADDR + 0x8)) {
280 @@ -216,7 +305,6 @@ int board_eth_init(bd_t *bis)
283 u32 interface_esdhc = 0;
287 interface_esdhc = (readl(SRC_BASE_ADDR + 0x4) & (0x00180000)) >> 19;
288 @@ -288,3 +376,21 @@ int sdhc_init(void)
293 +#if defined(CONFIG_MXC_KPD)
296 + mxc_request_iomux(MX51_PIN_KEY_COL0, IOMUX_CONFIG_ALT0);
297 + mxc_request_iomux(MX51_PIN_KEY_COL1, IOMUX_CONFIG_ALT0);
298 + mxc_request_iomux(MX51_PIN_KEY_COL2, IOMUX_CONFIG_ALT0);
299 + mxc_request_iomux(MX51_PIN_KEY_COL3, IOMUX_CONFIG_ALT0);
300 + mxc_request_iomux(MX51_PIN_KEY_COL4, IOMUX_CONFIG_ALT0);
301 + mxc_request_iomux(MX51_PIN_KEY_COL5, IOMUX_CONFIG_ALT0);
302 + mxc_request_iomux(MX51_PIN_KEY_ROW0, IOMUX_CONFIG_ALT0);
303 + mxc_request_iomux(MX51_PIN_KEY_ROW1, IOMUX_CONFIG_ALT0);
304 + mxc_request_iomux(MX51_PIN_KEY_ROW2, IOMUX_CONFIG_ALT0);
305 + mxc_request_iomux(MX51_PIN_KEY_ROW3, IOMUX_CONFIG_ALT0);
310 diff --git a/drivers/input/Makefile b/drivers/input/Makefile
311 index 9a14407..fcf9643 100644
312 --- a/drivers/input/Makefile
313 +++ b/drivers/input/Makefile
314 @@ -30,6 +30,7 @@ ifdef CONFIG_PS2KBD
315 COBJS-y += keyboard.o pc_keyb.o
316 COBJS-$(CONFIG_PS2MULT) += ps2mult.o ps2ser.o
318 +COBJS-${CONFIG_MXC_KPD} += mxc_keyb.o
321 SRCS := $(COBJS:.o=.c)
322 diff --git a/drivers/input/mxc_keyb.c b/drivers/input/mxc_keyb.c
324 index 0000000..8682b79
326 +++ b/drivers/input/mxc_keyb.c
329 + * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
333 + * The code contained herein is licensed under the GNU General Public
334 + * License. You may obtain a copy of the GNU General Public License
335 + * Version 2 or later at the following locations:
337 + * http://www.opensource.org/licenses/gpl-license.html
338 + * http://www.gnu.org/copyleft/gpl.html
344 + * @brief Driver for the Freescale Semiconductor MXC keypad port.
346 + * The keypad driver is designed as a standard Input driver which interacts
347 + * with low level keypad port hardware. Upon opening, the Keypad driver
348 + * initializes the keypad port. When the keypad interrupt happens the driver
349 + * calles keypad polling timer and scans the keypad matrix for key
350 + * press/release. If all key press/release happened it comes out of timer and
351 + * waits for key press interrupt. The scancode for key press and release events
352 + * are passed to Input subsytem.
359 +#include <asm/errno.h>
360 +#include <asm/arch/keypad.h>
361 +#include <linux/types.h>
365 + * * Module header file
367 +#include <mxc_keyb.h>
370 + * Comment KPP_DEBUG to disable debug messages
376 +#define KPP_PRINTF(fmt, args...) printf(fmt , ##args)
378 +static void mxc_kpp_dump_regs()
380 + unsigned short t1, t2, t3;
382 + t1 = __raw_readw(KPCR);
383 + t2 = __raw_readw(KPSR);
384 + t3 = __raw_readw(KDDR);
386 + KPP_PRINTF("KPCR=0x%04x, KPSR=0x%04x, KDDR=0x%04x\n",
391 +#define KPP_PRINTF(fmt, args...)
394 +static u16 mxc_key_mapping[] = CONFIG_MXC_KEYMAPPING;
397 + * This structure holds the keypad private data structure.
399 +static struct keypad_priv kpp_dev;
401 +/*! Indicates if the key pad device is enabled. */
403 +/*! This static variable indicates whether a key event is pressed/released. */
404 +static unsigned short KPress;
406 +/*! cur_rcmap and prev_rcmap array is used to detect key press and release. */
407 +static unsigned short *cur_rcmap; /* max 64 bits (8x8 matrix) */
408 +static unsigned short *prev_rcmap;
411 + * Debounce polling period(10ms) in system ticks.
413 +static unsigned short KScanRate = (10 * CONFIG_SYS_HZ) / 1000;
416 + * These arrays are used to store press and release scancodes.
418 +static short **press_scancode;
419 +static short **release_scancode;
421 +static const unsigned short *mxckpd_keycodes;
422 +static unsigned short mxckpd_keycodes_size;
425 + * These functions are used to configure and the GPIO pins for keypad to
426 + * activate and deactivate it.
428 +extern void setup_mxc_kpd(void);
431 + * This function is called to scan the keypad matrix to find out the key press
432 + * and key release events. Make scancode and break scancode are generated for
433 + * key press and key release events.
435 + * The following scanning sequence are done for
436 + * keypad row and column scanning,
437 + * -# Write 1's to KPDR[15:8], setting column data to 1's
438 + * -# Configure columns as totem pole outputs(for quick discharging of keypad
440 + * -# Configure columns as open-drain
441 + * -# Write a single column to 0, others to 1.
442 + * -# Sample row inputs and save data. Multiple key presses can be detected on
444 + * -# Repeat steps the above steps for remaining columns.
445 + * -# Return all columns to 0 in preparation for standby mode.
446 + * -# Clear KPKD and KPKR status bit(s) by writing to a 1,
447 + * Set the KPKR synchronizer chain by writing "1" to KRSS register,
448 + * Clear the KPKD synchronizer chain by writing "1" to KDSC register
450 + * @result Number of key pressed/released.
452 +static int mxc_kpp_scan_matrix()
454 + unsigned short reg_val;
456 + short scancode = 0;
457 + int keycnt = 0; /* How many keys are still pressed */
460 + * wmb() linux kernel function which guarantees orderings in write
465 + /* save cur keypad matrix to prev */
466 + memcpy(prev_rcmap, cur_rcmap, kpp_dev.kpp_rows * sizeof(prev_rcmap[0]));
467 + memset(cur_rcmap, 0, kpp_dev.kpp_rows * sizeof(cur_rcmap[0]));
469 + for (col = 0; col < kpp_dev.kpp_cols; col++) { /* Col */
470 + /* 2. Write 1.s to KPDR[15:8] setting column data to 1.s */
471 + reg_val = __raw_readw(KPDR);
473 + __raw_writew(reg_val, KPDR);
476 + * 3. Configure columns as totem pole outputs(for quick
477 + * discharging of keypad capacitance)
479 + reg_val = __raw_readw(KPCR);
481 + __raw_writew(reg_val, KPCR);
486 + mxc_kpp_dump_regs();
490 + * 4. Configure columns as open-drain
492 + reg_val = __raw_readw(KPCR);
493 + reg_val |= ((1 << kpp_dev.kpp_cols) - 1) << 8;
494 + __raw_writew(reg_val, KPCR);
497 + * 5. Write a single column to 0, others to 1.
498 + * 6. Sample row inputs and save data. Multiple key presses
499 + * can be detected on a single column.
500 + * 7. Repeat steps 2 - 6 for remaining columns.
503 + /* Col bit starts at 8th bit in KPDR */
504 + reg_val = __raw_readw(KPDR);
505 + reg_val &= ~(1 << (8 + col));
506 + __raw_writew(reg_val, KPDR);
508 + /* Delay added to avoid propagating the 0 from column to row
509 + * when scanning. */
514 + mxc_kpp_dump_regs();
517 + /* Read row input */
518 + reg_val = __raw_readw(KPDR);
519 + for (row = 0; row < kpp_dev.kpp_rows; row++) { /* sample row */
520 + if (TEST_BIT(reg_val, row) == 0) {
521 + cur_rcmap[row] = BITSET(cur_rcmap[row], col);
528 + * 8. Return all columns to 0 in preparation for standby mode.
529 + * 9. Clear KPKD and KPKR status bit(s) by writing to a .1.,
530 + * set the KPKR synchronizer chain by writing "1" to KRSS register,
531 + * clear the KPKD synchronizer chain by writing "1" to KDSC register
534 + __raw_writew(reg_val, KPDR);
535 + reg_val = __raw_readw(KPDR);
536 + reg_val = __raw_readw(KPSR);
537 + reg_val |= KBD_STAT_KPKD | KBD_STAT_KPKR | KBD_STAT_KRSS |
539 + __raw_writew(reg_val, KPSR);
542 + mxc_kpp_dump_regs();
545 + /* Check key press status change */
548 + * prev_rcmap array will contain the previous status of the keypad
549 + * matrix. cur_rcmap array will contains the present status of the
550 + * keypad matrix. If a bit is set in the array, that (row, col) bit is
551 + * pressed, else it is not pressed.
553 + * XORing these two variables will give us the change in bit for
554 + * particular row and column. If a bit is set in XOR output, then that
555 + * (row, col) has a change of status from the previous state. From
556 + * the diff variable the key press and key release of row and column
559 + * If the key press is determined then scancode for key pressed
560 + * can be generated using the following statement:
561 + * scancode = ((row * 8) + col);
563 + * If the key release is determined then scancode for key release
564 + * can be generated using the following statement:
565 + * scancode = ((row * 8) + col) + MXC_KEYRELEASE;
567 + for (row = 0; row < kpp_dev.kpp_rows; row++) {
568 + unsigned char diff;
571 + * Calculate the change in the keypad row status
573 + diff = prev_rcmap[row] ^ cur_rcmap[row];
575 + for (col = 0; col < kpp_dev.kpp_cols; col++) {
576 + if ((diff >> col) & 0x1) {
577 + /* There is a status change on col */
578 + if ((prev_rcmap[row] & BITSET(0, col)) == 0) {
580 + * Previous state is 0, so now
584 + ((row * kpp_dev.kpp_cols) +
587 + kpp_dev.iKeyState = KStateUp;
589 + KPP_PRINTF("Press (%d, %d) scan=%d "
591 + row, col, scancode, KPress);
592 + press_scancode[row][col] =
596 + * Previous state is not 0, so
597 + * now a key is released
600 + (row * kpp_dev.kpp_cols) +
601 + col + MXC_KEYRELEASE;
603 + kpp_dev.iKeyState = KStateDown;
606 + ("Release (%d, %d) scan=%d Kpress=%d\n",
607 + row, col, scancode, KPress);
608 + release_scancode[row][col] =
619 +static int mxc_kpp_reset()
621 + unsigned short reg_val;
625 + * Stop scanning and wait for interrupt.
626 + * Enable press interrupt and disable release interrupt.
628 + __raw_writew(0x00FF, KPDR);
629 + reg_val = __raw_readw(KPSR);
630 + reg_val |= (KBD_STAT_KPKR | KBD_STAT_KPKD);
631 + reg_val |= KBD_STAT_KRSS | KBD_STAT_KDSC;
632 + __raw_writew(reg_val, KPSR);
633 + reg_val |= KBD_STAT_KDIE;
634 + reg_val &= ~KBD_STAT_KRIE;
635 + __raw_writew(reg_val, KPSR);
638 + mxc_kpp_dump_regs();
642 + * No more keys pressed... make sure unwanted key codes are
643 + * not given upstairs
645 + for (i = 0; i < kpp_dev.kpp_rows; i++) {
646 + memset(press_scancode[i], -1,
647 + sizeof(press_scancode[0][0]) * kpp_dev.kpp_cols);
648 + memset(release_scancode[i], -1,
649 + sizeof(release_scancode[0][0]) *
656 +int mxc_kpp_getc(struct kpp_key_info *key_info)
659 + static int key_cnt;
660 + unsigned short reg_val;
661 + short scancode = 0;
663 + reg_val = __raw_readw(KPSR);
666 + if (reg_val & KBD_STAT_KPKD) {
668 + * Disable key press(KDIE status bit) interrupt
670 + reg_val &= ~KBD_STAT_KDIE;
671 + __raw_writew(reg_val, KPSR);
674 + mxc_kpp_dump_regs();
677 + key_cnt = mxc_kpp_scan_matrix();
684 + * This switch case statement is the
685 + * implementation of state machine of debounc
686 + * logic for key press/release.
687 + * The explaination of state machine is as
691 + * This is in intial state of the state machine
692 + * this state it checks for any key presses.
693 + * The key press can be checked using the
694 + * variable KPress. If KPress is set, then key
695 + * press is identified and switches the to
696 + * KStateFirstDown state for key press to
700 + * After debounce delay(10ms), if the KPress is
701 + * still set then pass scancode generated to
702 + * input device and change the state to
703 + * KStateDown, else key press debounce is not
704 + * satisfied so change the state to KStateUp.
707 + * In this state it checks for any key release.
708 + * If KPress variable is cleared, then key
709 + * release is indicated and so, switch the
710 + * state to KStateFirstUp else to state
714 + * After debounce delay(10ms), if the KPress is
715 + * still reset then pass the key release
716 + * scancode to input device and change
717 + * the state to KStateUp else key release is
718 + * not satisfied so change the state to
722 + for (row = 0; row < kpp_dev.kpp_rows; row++) {
723 + for (col = 0; col < kpp_dev.kpp_cols; col++) {
724 + if ((press_scancode[row][col] != -1)) {
725 + /* Still Down, so add scancode */
727 + press_scancode[row][col];
729 + key_info->val = mxckpd_keycodes[scancode];
730 + key_info->evt = KDepress;
732 + KPP_PRINTF("KStateFirstDown: scan=%d val=%d\n",
733 + scancode, mxckpd_keycodes[scancode]);
734 + kpp_dev.iKeyState = KStateDown;
735 + press_scancode[row][col] = -1;
742 + for (row = 0; row < kpp_dev.kpp_rows; row++) {
743 + for (col = 0; col < kpp_dev.kpp_cols; col++) {
744 + if ((release_scancode[row][col] != -1)) {
746 + release_scancode[row][col];
748 + scancode - MXC_KEYRELEASE;
750 + key_info->val = mxckpd_keycodes[scancode];
751 + key_info->evt = KRelease;
753 + KPP_PRINTF("KStateFirstUp: scan=%d val=%d\n",
754 + scancode, mxckpd_keycodes[scancode]);
756 + kpp_dev.iKeyState = KStateUp;
757 + release_scancode[row][col] = -1;
767 + /* udelay(KScanRate); */
768 + key_cnt = mxc_kpp_scan_matrix();
776 + * This function is called to free the allocated memory for local arrays
778 +static void mxc_kpp_free_allocated(void)
782 + if (press_scancode) {
783 + for (i = 0; i < kpp_dev.kpp_rows; i++) {
784 + if (press_scancode[i])
785 + free(press_scancode[i]);
787 + free(press_scancode);
790 + if (release_scancode) {
791 + for (i = 0; i < kpp_dev.kpp_rows; i++) {
792 + if (release_scancode[i])
793 + free(release_scancode[i]);
795 + free(release_scancode);
806 + * This function is called during the driver binding process.
808 + * @param pdev the device structure used to store device specific
809 + * information that is used by the suspend, resume and remove
812 + * @return The function returns 0 on successful registration. Otherwise returns
813 + * specific error code.
819 + unsigned int reg_val;
821 + kpp_dev.kpp_cols = CONFIG_MXC_KPD_COLMAX;
822 + kpp_dev.kpp_rows = CONFIG_MXC_KPD_ROWMAX;
824 + /* clock and IOMUX configuration for keypad */
827 + /* Configure keypad */
829 + /* Enable number of rows in keypad (KPCR[7:0])
830 + * Configure keypad columns as open-drain (KPCR[15:8])
832 + * Configure the rows/cols in KPP
833 + * LSB nibble in KPP is for 8 rows
834 + * MSB nibble in KPP is for 8 cols
836 + reg_val = __raw_readw(KPCR);
837 + reg_val |= (1 << kpp_dev.kpp_rows) - 1; /* LSB */
838 + reg_val |= ((1 << kpp_dev.kpp_cols) - 1) << 8; /* MSB */
839 + __raw_writew(reg_val, KPCR);
841 + /* Write 0's to KPDR[15:8] */
842 + reg_val = __raw_readw(KPDR);
844 + __raw_writew(reg_val, KPDR);
846 + /* Configure columns as output,
847 + * rows as input (KDDR[15:0]) */
848 + reg_val = __raw_readw(KDDR);
851 + __raw_writew(reg_val, KDDR);
853 + /* Clear the KPKD Status Flag
854 + * and Synchronizer chain. */
855 + reg_val = __raw_readw(KPSR);
856 + reg_val &= ~(KBD_STAT_KPKR | KBD_STAT_KPKD);
857 + reg_val |= KBD_STAT_KPKD;
858 + reg_val |= KBD_STAT_KRSS | KBD_STAT_KDSC;
859 + __raw_writew(reg_val, KPSR);
860 + /* Set the KDIE control bit, and clear the KRIE
861 + * control bit (avoid false release events). */
862 + reg_val |= KBD_STAT_KDIE;
863 + reg_val &= ~KBD_STAT_KRIE;
864 + __raw_writew(reg_val, KPSR);
867 + mxc_kpp_dump_regs();
870 + mxckpd_keycodes = mxc_key_mapping;
871 + mxckpd_keycodes_size = kpp_dev.kpp_cols * kpp_dev.kpp_rows;
873 + if ((mxckpd_keycodes == (void *)0)
874 + || (mxckpd_keycodes_size == 0)) {
879 + /* allocate required memory */
880 + press_scancode = (short **)malloc(kpp_dev.kpp_rows * sizeof(press_scancode[0]));
881 + release_scancode = (short **)malloc(kpp_dev.kpp_rows * sizeof(release_scancode[0]));
883 + if (!press_scancode || !release_scancode) {
888 + for (i = 0; i < kpp_dev.kpp_rows; i++) {
889 + press_scancode[i] = (short *)malloc(kpp_dev.kpp_cols
890 + * sizeof(press_scancode[0][0]));
891 + release_scancode[i] =
892 + (short *)malloc(kpp_dev.kpp_cols * sizeof(release_scancode[0][0]));
894 + if (!press_scancode[i] || !release_scancode[i]) {
901 + (unsigned short *)malloc(kpp_dev.kpp_rows * sizeof(cur_rcmap[0]));
903 + (unsigned short *)malloc(kpp_dev.kpp_rows * sizeof(prev_rcmap[0]));
905 + if (!cur_rcmap || !prev_rcmap) {
910 + for (i = 0; i < kpp_dev.kpp_rows; i++) {
911 + memset(press_scancode[i], -1,
912 + sizeof(press_scancode[0][0]) * kpp_dev.kpp_cols);
913 + memset(release_scancode[i], -1,
914 + sizeof(release_scancode[0][0]) * kpp_dev.kpp_cols);
916 + memset(cur_rcmap, 0, kpp_dev.kpp_rows * sizeof(cur_rcmap[0]));
917 + memset(prev_rcmap, 0, kpp_dev.kpp_rows * sizeof(prev_rcmap[0]));
922 + mxc_kpp_free_allocated();
926 diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
927 index f6dd23b..cf27c66 100644
928 --- a/drivers/mtd/nand/mxc_nand.c
929 +++ b/drivers/mtd/nand/mxc_nand.c
930 @@ -547,7 +547,7 @@ static u16 mxc_do_status_auto(struct mtd_info *mtd)
933 raw_write(NFC_AUTO_STATE, REG_NFC_OPS);
935 + #if defined(CONFIG_MX51_3DS) || defined(CONFIG_MX51_BBG)
936 /* mx51to2 NFC need wait the op done */
937 if (is_soc_rev(CHIP_REV_2_0) == 0)
938 wait_op_done(TROP_US_DELAY);
939 diff --git a/include/asm-arm/arch-mx51/keypad.h b/include/asm-arm/arch-mx51/keypad.h
941 index 0000000..23ae4fe
943 +++ b/include/asm-arm/arch-mx51/keypad.h
946 + * (C) Copyright 2009 Freescale Semiconductor, Inc.
948 + * Configuration settings for the MX51-3Stack Freescale board.
950 + * This program is free software; you can redistribute it and/or
951 + * modify it under the terms of the GNU General Public License as
952 + * published by the Free Software Foundation; either version 2 of
953 + * the License, or (at your option) any later version.
955 + * This program is distributed in the hope that it will be useful,
956 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
957 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
958 + * GNU General Public License for more details.
960 + * You should have received a copy of the GNU General Public License
961 + * along with this program; if not, write to the Free Software
962 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
963 + * MA 02111-1307 USA
966 +#ifndef _MXC_KEYPAD_H_
967 +#define _MXC_KEYPAD_H_
981 +#define KEY_LEFT 105
982 +#define KEY_SELECT 0x161
983 +#define KEY_RIGHT 106
989 +#define KEY_DOWN 108
993 +#define KEY_OK 0x160
995 +#define KEY_ENTER 28
996 +#define KEY_MENU 139 /* Menu (show menu) */
997 +#define KEY_BACK 158 /* AC Back */
999 +#if defined(CONFIG_MX51_BBG)
1000 +#define TEST_HOME_KEY_DEPRESS(k, e) (((k) == (KEY_F1)) && (((e) == (KDepress))))
1001 +#define TEST_POWER_KEY_DEPRESS(k, e) (((k) == (KEY_RIGHT)) && (((e) == (KDepress))))
1002 +#elif defined(CONFIG_MX51_3DS)
1003 +#define TEST_HOME_KEY_DEPRESS(k, e) (((k) == (KEY_MENU)) && (((e) == (KDepress))))
1004 +#define TEST_POWER_KEY_DEPRESS(k, e) (((k) == (KEY_F2)) && (((e) == (KDepress))))
1006 +# error Undefined board type!
1010 diff --git a/include/configs/imx51.h b/include/configs/imx51.h
1011 index 8d81fff..23347d1 100644
1012 --- a/include/configs/imx51.h
1013 +++ b/include/configs/imx51.h
1015 #define CONFIG_L2_OFF
1017 #define CONFIG_MXC 1
1018 -#define CONFIG_MX51 1 /* in a mx51 */
1019 +#define CONFIG_MX51_BBG 1 /* in a mx51 */
1020 #define CONFIG_FLASH_HEADER 1
1021 #define CONFIG_FLASH_HEADER_OFFSET 0x400
1022 #define CONFIG_FLASH_HEADER_BARKER 0xB1
1023 @@ -244,11 +244,11 @@
1024 #define CONFIG_ENV_OFFSET 0x100000
1025 #elif defined(CONFIG_FSL_ENV_IN_MMC)
1026 #define CONFIG_ENV_IS_IN_MMC 1
1027 - #define CONFIG_ENV_OFFSET (1024 * 1024)
1028 + #define CONFIG_ENV_OFFSET (768 * 1024)
1029 #elif defined(CONFIG_FSL_ENV_IN_SF)
1030 #define CONFIG_ENV_IS_IN_SPI_FLASH 1
1031 #define CONFIG_ENV_SPI_CS 1
1032 - #define CONFIG_ENV_OFFSET (1024 * 1024)
1033 + #define CONFIG_ENV_OFFSET (768 * 1024)
1035 #define CONFIG_ENV_IS_NOWHERE 1
1037 diff --git a/include/configs/imx51_android.h b/include/configs/imx51_android.h
1038 new file mode 100644
1039 index 0000000..55bcfbf
1041 +++ b/include/configs/imx51_android.h
1044 + * Copyright (C) 2007, Guennadi Liakhovetski <lg@denx.de>
1046 + * (C) Copyright 2009 Freescale Semiconductor, Inc.
1048 + * Configuration settings for the MX51-3Stack Freescale board.
1050 + * This program is free software; you can redistribute it and/or
1051 + * modify it under the terms of the GNU General Public License as
1052 + * published by the Free Software Foundation; either version 2 of
1053 + * the License, or (at your option) any later version.
1055 + * This program is distributed in the hope that it will be useful,
1056 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1057 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1058 + * GNU General Public License for more details.
1060 + * You should have received a copy of the GNU General Public License
1061 + * along with this program; if not, write to the Free Software
1062 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1063 + * MA 02111-1307 USA
1069 +#include <asm/arch/mx51.h>
1071 + /* High Level Configuration Options */
1072 +#define CONFIG_ARMV7 1 /* This is armv7 Cortex-A8 CPU core */
1073 +#define CONFIG_SYS_APCS_GNU
1074 +#define CONFIG_L2_OFF
1076 +#define CONFIG_MXC 1
1077 +#define CONFIG_MX51_BBG 1 /* in a mx51 */
1078 +#define CONFIG_FLASH_HEADER 1
1079 +#define CONFIG_FLASH_HEADER_OFFSET 0x400
1080 +#define CONFIG_FLASH_HEADER_BARKER 0xB1
1082 +#define CONFIG_SKIP_RELOCATE_UBOOT
1084 +#define CONFIG_MX51_HCLK_FREQ 24000000 /* RedBoot says 26MHz */
1085 +#define CONFIG_MX51_CLK32 32768
1086 +#define CONFIG_DISPLAY_CPUINFO
1087 +#define CONFIG_DISPLAY_BOARDINFO
1089 +#define BOARD_LATE_INIT
1091 + * Disabled for now due to build problems under Debian and a significant
1092 + * increase in the final file size: 144260 vs. 109536 Bytes.
1095 +#define CONFIG_CMDLINE_TAG 1 /* enable passing of ATAGs */
1096 +#define CONFIG_REVISION_TAG 1
1097 +#define CONFIG_SETUP_MEMORY_TAGS 1
1098 +#define CONFIG_INITRD_TAG 1
1101 + * Size of malloc() pool
1103 +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 2 * 1024 * 1024)
1104 +/* size in bytes reserved for initial data */
1105 +#define CONFIG_SYS_GBL_DATA_SIZE 128
1108 + * Hardware drivers
1110 +#define CONFIG_MX51_UART 1
1111 +#define CONFIG_MX51_UART1 1
1116 +#define CONFIG_FSL_SF 1
1117 +#define CONFIG_CMD_SPI
1118 +#define CONFIG_CMD_SF
1119 +#define CONFIG_SPI_FLASH_IMX_ATMEL 1
1120 +#define CONFIG_SPI_FLASH_CS 1
1121 +#define CONFIG_IMX_SPI
1122 +#define CONFIG_IMX_SPI_PMIC
1123 +#define CONFIG_IMX_SPI_PMIC_CS 0
1125 +#define MAX_SPI_BYTES (64 * 4)
1130 +#define CONFIG_FSL_MMC 1
1132 +#define CONFIG_MMC 1
1133 +#define CONFIG_CMD_MMC
1134 +#define CONFIG_DOS_PARTITION 1
1135 +#define CONFIG_CMD_FAT 1
1136 +#define CONFIG_MMC_BASE 0x0
1141 +#define CONFIG_HAS_ETH1
1142 +#define CONFIG_NET_MULTI 1
1143 +#define CONFIG_MXC_FEC
1145 +#define CONFIG_DISCOVER_PHY
1147 +#define CONFIG_FEC0_IOBASE FEC_BASE_ADDR
1148 +#define CONFIG_FEC0_PINMUX -1
1149 +#define CONFIG_FEC0_PHY_ADDR 0x1F
1150 +#define CONFIG_FEC0_MIIBASE -1
1152 +#define CONFIG_CMD_PING
1153 +#define CONFIG_CMD_DHCP
1154 +#define CONFIG_CMD_MII
1155 +#define CONFIG_CMD_NET
1158 + * Android support Configs
1160 +#include <asm/arch/keypad.h>
1162 +#define CONFIG_FSL_ANDROID
1164 +#define CONFIG_MXC_KPD
1165 +#define CONFIG_MXC_KEYMAPPING \
1167 + KEY_1, KEY_2, KEY_3, KEY_F1, KEY_UP, KEY_F2, \
1168 + KEY_4, KEY_5, KEY_6, KEY_LEFT, KEY_SELECT, KEY_RIGHT, \
1169 + KEY_7, KEY_8, KEY_9, KEY_F3, KEY_DOWN, KEY_F4, \
1170 + KEY_0, KEY_OK, KEY_ESC, KEY_ENTER, KEY_MENU, KEY_BACK, \
1174 + KEY_3, KEY_2, KEY_0, KEY_OK, KEY_ESC, KEY_ENTER,
1175 + KEY_F1, KEY_4, KEY_6, KEY_5,
1176 + KEY_LEFT, KEY_1, KEY_ , KEY_8, KEY_9, KEY_RIGHT,
1179 +#define CONFIG_MXC_KPD_COLMAX 4
1180 +#define CONFIG_MXC_KPD_ROWMAX 4
1181 +#define CONFIG_ANDROID_NORMAL_BOOTARGS "ip=dhcp mem=480M init=/init wvga calibration"
1182 +#define CONFIG_ANDROID_RECOVERY_BOOTARGS "setenv bootargs ${bootargs} root=/dev/mmcblk0p4 ip=dhcp init=/init rootfstype=ext3 wvga"
1183 +#define CONFIG_ANDROID_RECOVERY_BOOTCMD "run bootargs_base bootargs_android;mmcinit;cp.b 0x100000 ${loadaddr} 0x250000;bootm"
1184 +#define CONFIG_ANDROID_BOOTMOD_DELAY 3
1186 +/* allow to overwrite serial and ethaddr */
1187 +#define CONFIG_ENV_OVERWRITE
1188 +#define CONFIG_CONS_INDEX 1
1189 +#define CONFIG_BAUDRATE 115200
1190 +#define CONFIG_SYS_BAUDRATE_TABLE {9600, 19200, 38400, 57600, 115200}
1192 +/***********************************************************
1193 + * Command definition
1194 + ***********************************************************/
1196 +#include <config_cmd_default.h>
1198 +#define CONFIG_CMD_PING
1199 +#define CONFIG_CMD_DHCP
1200 +/* Enable below configure when supporting nand */
1201 +/* #define CONFIG_CMD_NAND */
1202 +#define CONFIG_CMD_ENV
1204 +#undef CONFIG_CMD_IMLS
1206 +#define CONFIG_BOOTDELAY 3
1208 +#define CONFIG_PRIME "FEC0"
1210 +#define CONFIG_LOADADDR 0x90800000 /* loadaddr env var */
1211 +#define CONFIG_RD_LOADADDR (CONFIG_LOADADDR + 0x300000)
1213 +#define CONFIG_EXTRA_ENV_SETTINGS \
1215 + "ethprime=FEC0\0" \
1216 + "uboot_addr=0xa0000000\0" \
1217 + "uboot=u-boot.bin\0" \
1218 + "kernel=uImage\0" \
1219 + "rd_loadaddr=0x90B00000\0" \
1220 + "nfsroot=/opt/eldk/arm\0" \
1221 + "bootargs_base=setenv bootargs console=ttymxc0,115200\0"\
1222 + "bootargs_nfs=setenv bootargs ${bootargs} root=/dev/nfs "\
1223 + "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0"\
1224 + "bootargs_android=setenv bootargs ${bootargs} ip=dhcp mem=480M init=/init wvga calibration\0" \
1225 + "bootcmd=run bootcmd_android\0" \
1226 + "bootcmd_net=run bootargs_base bootargs_nfs; " \
1227 + "tftpboot ${loadaddr} ${kernel}; bootm\0" \
1228 + "bootcmd_android=run bootargs_base bootargs_android; " \
1229 + "mmcinit;cp.b 0x100000 ${loadaddr} 0x250000; " \
1230 + "cp.b 0x400000 ${rd_loadaddr} 0x4B000; " \
1231 + "bootm ${loadaddr} ${rd_loadaddr}\0" \
1232 + "prg_uboot=tftpboot ${loadaddr} ${uboot}; " \
1233 + "protect off ${uboot_addr} 0xa003ffff; " \
1234 + "erase ${uboot_addr} 0xa003ffff; " \
1235 + "cp.b ${loadaddr} ${uboot_addr} ${filesize}; " \
1236 + "setenv filesize; saveenv\0"
1238 +/*Support LAN9217*/
1240 +#define CONFIG_DRIVER_SMC911X 1
1241 +#define CONFIG_DRIVER_SMC911X_16_BIT 1
1242 +#define CONFIG_DRIVER_SMC911X_BASE_VARIABLE mx51_io_base_addr
1246 + * The MX51 3stack board seems to have a hardware "peculiarity" confirmed under
1247 + * U-Boot, RedBoot and Linux: the ethernet Rx signal is reaching the CS8900A
1248 + * controller inverted. The controller is capable of detecting and correcting
1249 + * this, but it needs 4 network packets for that. Which means, at startup, you
1250 + * will not receive answers to the first 4 packest, unless there have been some
1251 + * broadcasts on the network, or your board is on a hub. Reducing the ARP
1252 + * timeout from default 5 seconds to 200ms we speed up the initial TFTP
1253 + * transfer, should the user wish one, significantly.
1255 +#define CONFIG_ARP_TIMEOUT 200UL
1258 + * Miscellaneous configurable options
1260 +#define CONFIG_SYS_LONGHELP /* undef to save memory */
1261 +#define CONFIG_SYS_PROMPT "BBG U-Boot > "
1262 +#define CONFIG_AUTO_COMPLETE
1263 +#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
1264 +/* Print Buffer Size */
1265 +#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
1266 +#define CONFIG_SYS_MAXARGS 16 /* max number of command args */
1267 +#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE /* Boot Argument Buffer Size */
1269 +#define CONFIG_SYS_MEMTEST_START 0 /* memtest works on */
1270 +#define CONFIG_SYS_MEMTEST_END 0x10000
1272 +#undef CONFIG_SYS_CLKS_IN_HZ /* everything, incl board info, in Hz */
1274 +#define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR
1276 +#define CONFIG_SYS_HZ CONFIG_MX51_CLK32/* use 32kHz clock as source */
1278 +#define CONFIG_CMDLINE_EDITING 1
1280 +/*-----------------------------------------------------------------------
1283 + * The stack sizes are set up in start.S using the settings below
1285 +#define CONFIG_STACKSIZE (128 * 1024) /* regular stack */
1287 +/*-----------------------------------------------------------------------
1288 + * Physical Memory Map
1290 +#define CONFIG_NR_DRAM_BANKS 1
1291 +#define PHYS_SDRAM_1 CSD0_BASE_ADDR
1293 +/* #define PHYS_SDRAM_1_SIZE (128 * 1024 * 1024) */
1294 +#define PHYS_SDRAM_1_SIZE (512 * 1024 * 1024)
1296 +/*-----------------------------------------------------------------------
1297 + * FLASH and environment organization
1299 +#define CONFIG_SYS_NO_FLASH
1301 +/*-----------------------------------------------------------------------
1302 + * NAND FLASH driver setup
1304 +#define NAND_MAX_CHIPS 8
1305 +#define CONFIG_SYS_MAX_NAND_DEVICE 1
1306 +#define CONFIG_SYS_NAND_BASE 0x40000000
1308 +/* Monitor at beginning of flash */
1309 +#if defined(CONFIG_FSL_SF)
1310 + #define CONFIG_FSL_ENV_IN_SF
1311 +#elif defined(CONFIG_FSL_MMC)
1312 + #define CONFIG_FSL_ENV_IN_MMC
1313 +#elif defined(CONFIG_CMD_NAND)
1314 + #define CONFIG_FSL_ENV_IN_NAND
1317 +#define CONFIG_ENV_SECT_SIZE (128 * 1024)
1318 +#define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE
1320 +#if defined(CONFIG_FSL_ENV_IN_NAND)
1321 + #define CONFIG_ENV_IS_IN_NAND 1
1322 + #define CONFIG_ENV_OFFSET 0x100000
1323 +#elif defined(CONFIG_FSL_ENV_IN_MMC)
1324 + #define CONFIG_ENV_IS_IN_MMC 1
1325 + #define CONFIG_ENV_OFFSET (768 * 1024)
1326 +#elif defined(CONFIG_FSL_ENV_IN_SF)
1327 + #define CONFIG_ENV_IS_IN_SPI_FLASH 1
1328 + #define CONFIG_ENV_SPI_CS 1
1329 + #define CONFIG_ENV_OFFSET (768 * 1024)
1331 + #define CONFIG_ENV_IS_NOWHERE 1
1334 + * JFFS2 partitions
1336 +#undef CONFIG_JFFS2_CMDLINE
1337 +#define CONFIG_JFFS2_DEV "nand0"
1339 +#endif /* __CONFIG_H */
1340 diff --git a/include/configs/mx25_3stack.h b/include/configs/mx25_3stack.h
1341 index 5e343ea..93e4b9a 100644
1342 --- a/include/configs/mx25_3stack.h
1343 +++ b/include/configs/mx25_3stack.h
1344 @@ -205,11 +205,11 @@
1345 #define CONFIG_ENV_OFFSET 0x80000
1346 #elif defined(CONFIG_FSL_ENV_IN_MMC)
1347 #define CONFIG_ENV_IS_IN_MMC 1
1348 - #define CONFIG_ENV_OFFSET 0x100000
1349 + #define CONFIG_ENV_OFFSET (768 * 1024)
1350 #elif defined(CONFIG_FSL_ENV_IN_SF)
1351 #define CONFIG_ENV_IS_IN_SPI_FLASH 1
1352 #define CONFIG_ENV_SPI_CS 1
1353 - #define CONFIG_ENV_OFFSET 0x100000
1354 + #define CONFIG_ENV_OFFSET (768 * 1024)
1356 #define CONFIG_ENV_IS_NOWHERE 1
1358 diff --git a/include/configs/mx35_3stack.h b/include/configs/mx35_3stack.h
1359 index 9939964..b78f48e 100644
1360 --- a/include/configs/mx35_3stack.h
1361 +++ b/include/configs/mx35_3stack.h
1364 #if defined(CONFIG_FSL_ENV_IN_NAND)
1365 #define CONFIG_ENV_IS_IN_NAND 1
1366 - #define CONFIG_ENV_OFFSET 0x100000
1367 + #define CONFIG_ENV_OFFSET (768 * 1024)
1368 #elif defined(CONFIG_FSL_ENV_IS_IN_FLASH)
1369 #define CONFIG_ENV_IS_IN_FLASH 1
1371 diff --git a/include/configs/mx51_3stack.h b/include/configs/mx51_3stack.h
1372 index 9cb463d..2cee9d6 100644
1373 --- a/include/configs/mx51_3stack.h
1374 +++ b/include/configs/mx51_3stack.h
1377 * (C) Copyright 2009 Freescale Semiconductor, Inc.
1379 - * Configuration settings for the MX31ADS Freescale board.
1380 + * Configuration settings for the MX51-3Stack Freescale board.
1382 * This program is free software; you can redistribute it and/or
1383 * modify it under the terms of the GNU General Public License as
1385 #define CONFIG_L2_OFF
1387 #define CONFIG_MXC 1
1388 -#define CONFIG_MX51 1 /* in a mx51 */
1389 +#define CONFIG_MX51_3DS 1 /* in a mx51 */
1390 #define CONFIG_FLASH_HEADER 1
1391 #define CONFIG_FLASH_HEADER_OFFSET 0x400
1392 #define CONFIG_FLASH_HEADER_BARKER 0xB1
1394 #define CONFIG_MX51_UART 1
1395 #define CONFIG_MX51_UART1 1
1401 +#define CONFIG_FSL_MMC 1
1403 +#define CONFIG_MMC 1
1404 +#define CONFIG_CMD_MMC
1405 +#define CONFIG_DOS_PARTITION 1
1406 +#define CONFIG_CMD_FAT 1
1407 +#define CONFIG_MMC_BASE 0x0
1409 +#define CONFIG_CMD_PING
1410 +#define CONFIG_CMD_DHCP
1411 +#define CONFIG_CMD_MII
1412 +#define CONFIG_CMD_NET
1414 /* allow to overwrite serial and ethaddr */
1415 #define CONFIG_ENV_OVERWRITE
1416 #define CONFIG_CONS_INDEX 1
1417 @@ -179,10 +196,18 @@
1418 #define CONFIG_SYS_NAND_BASE 0x40000000
1420 /* Monitor at beginning of flash */
1421 -#define CONFIG_ENV_IS_IN_NAND 1
1422 -#define CONFIG_ENV_SECT_SIZE (1024 * 1024)
1423 +#define CONFIG_FSL_ENV_IN_NAND
1424 +#define CONFIG_ENV_SECT_SIZE (128 * 1024)
1425 #define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE
1426 -#define CONFIG_ENV_OFFSET 0x100000
1427 +#if defined(CONFIG_FSL_ENV_IN_NAND)
1428 + #define CONFIG_ENV_IS_IN_NAND 1
1429 + #define CONFIG_ENV_OFFSET 0x100000
1430 +#elif defined(CONFIG_FSL_ENV_IN_MMC)
1431 + #define CONFIG_ENV_IS_IN_MMC 1
1432 + #define CONFIG_ENV_OFFSET (768 * 1024)
1434 + #define CONFIG_ENV_IS_NOWHERE 1
1439 diff --git a/include/configs/mx51_3stack_android.h b/include/configs/mx51_3stack_android.h
1440 new file mode 100644
1441 index 0000000..c4958c0
1443 +++ b/include/configs/mx51_3stack_android.h
1446 + * Copyright (C) 2007, Guennadi Liakhovetski <lg@denx.de>
1448 + * (C) Copyright 2009 Freescale Semiconductor, Inc.
1450 + * Configuration settings for the MX51-3Stack Freescale board.
1452 + * This program is free software; you can redistribute it and/or
1453 + * modify it under the terms of the GNU General Public License as
1454 + * published by the Free Software Foundation; either version 2 of
1455 + * the License, or (at your option) any later version.
1457 + * This program is distributed in the hope that it will be useful,
1458 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1459 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1460 + * GNU General Public License for more details.
1462 + * You should have received a copy of the GNU General Public License
1463 + * along with this program; if not, write to the Free Software
1464 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1465 + * MA 02111-1307 USA
1471 +#include <asm/arch/mx51.h>
1472 +#include <asm/arch/keypad.h>
1474 + /* High Level Configuration Options */
1475 +#define CONFIG_ARMV7 1 /* This is armv7 Cortex-A8 CPU core */
1476 +#define CONFIG_SYS_APCS_GNU
1477 +#define CONFIG_L2_OFF
1479 +#define CONFIG_MXC 1
1480 +#define CONFIG_MX51_3DS 1 /* in a mx51 */
1481 +#define CONFIG_FLASH_HEADER 1
1482 +#define CONFIG_FLASH_HEADER_OFFSET 0x400
1483 +#define CONFIG_FLASH_HEADER_BARKER 0xB1
1485 +#define CONFIG_SKIP_RELOCATE_UBOOT
1487 +#define CONFIG_MX51_HCLK_FREQ 24000000 /* RedBoot says 26MHz */
1488 +#define CONFIG_MX51_CLK32 32768
1489 +#define CONFIG_DISPLAY_CPUINFO
1490 +#define CONFIG_DISPLAY_BOARDINFO
1492 +#define BOARD_LATE_INIT
1494 + * Disabled for now due to build problems under Debian and a significant
1495 + * increase in the final file size: 144260 vs. 109536 Bytes.
1498 +#define CONFIG_CMDLINE_TAG 1 /* enable passing of ATAGs */
1499 +#define CONFIG_REVISION_TAG 1
1500 +#define CONFIG_SETUP_MEMORY_TAGS 1
1501 +#define CONFIG_INITRD_TAG 1
1504 + * Size of malloc() pool
1506 +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 2 * 1024 * 1024)
1507 +/* size in bytes reserved for initial data */
1508 +#define CONFIG_SYS_GBL_DATA_SIZE 128
1511 + * Hardware drivers
1513 +#define CONFIG_MX51_UART 1
1514 +#define CONFIG_MX51_UART1 1
1519 +#define CONFIG_FSL_SF 1
1520 +#define CONFIG_CMD_SPI
1521 +#define CONFIG_CMD_SF
1522 +#define CONFIG_SPI_FLASH_IMX_ATMEL 1
1523 +#define CONFIG_SPI_FLASH_CS 1
1524 +#define CONFIG_IMX_SPI
1525 +#define CONFIG_IMX_SPI_PMIC
1526 +#define CONFIG_IMX_SPI_PMIC_CS 0
1528 +#define MAX_SPI_BYTES (64 * 4)
1533 +#define CONFIG_FSL_MMC 1
1535 +#define CONFIG_MMC 1
1536 +#define CONFIG_CMD_MMC
1537 +#define CONFIG_DOS_PARTITION 1
1538 +#define CONFIG_CMD_FAT 1
1539 +#define CONFIG_MMC_BASE 0x0
1544 +#define CONFIG_HAS_ETH1
1545 +#define CONFIG_NET_MULTI 1
1546 +#define CONFIG_MXC_FEC
1548 +#define CONFIG_DISCOVER_PHY
1550 +#define CONFIG_FEC0_IOBASE FEC_BASE_ADDR
1551 +#define CONFIG_FEC0_PINMUX -1
1552 +#define CONFIG_FEC0_PHY_ADDR 0x1F
1553 +#define CONFIG_FEC0_MIIBASE -1
1555 +#define CONFIG_CMD_PING
1556 +#define CONFIG_CMD_DHCP
1557 +#define CONFIG_CMD_MII
1558 +#define CONFIG_CMD_NET
1561 + * Android support Configs
1563 +#include <asm/arch/keypad.h>
1565 +#define CONFIG_FSL_ANDROID
1567 +#define CONFIG_MXC_KPD
1568 +#define CONFIG_MXC_KEYMAPPING \
1570 + KEY_1, KEY_2, KEY_3, KEY_F1, KEY_UP, KEY_F2, \
1571 + KEY_4, KEY_5, KEY_6, KEY_LEFT, KEY_SELECT, KEY_RIGHT, \
1572 + KEY_7, KEY_8, KEY_9, KEY_F3, KEY_DOWN, KEY_F4, \
1573 + KEY_0, KEY_OK, KEY_ESC, KEY_ENTER, KEY_MENU, KEY_BACK, \
1575 +#define CONFIG_MXC_KPD_COLMAX 6
1576 +#define CONFIG_MXC_KPD_ROWMAX 4
1577 +#define CONFIG_ANDROID_NORMAL_BOOTARGS "ip=dhcp mem=480M init=/init wvga calibration"
1578 +#define CONFIG_ANDROID_RECOVERY_BOOTARGS "setenv bootargs ${bootargs} root=/dev/mmcblk0p4 ip=dhcp init=/init rootfstype=ext3 wvga"
1579 +#define CONFIG_ANDROID_RECOVERY_BOOTCMD "run bootargs_base bootargs_android;mmcinit;cp.b 0x100000 ${loadaddr} 0x250000;bootm"
1580 +#define CONFIG_ANDROID_BOOTMOD_DELAY 3
1582 +/* allow to overwrite serial and ethaddr */
1583 +#define CONFIG_ENV_OVERWRITE
1584 +#define CONFIG_CONS_INDEX 1
1585 +#define CONFIG_BAUDRATE 115200
1586 +#define CONFIG_SYS_BAUDRATE_TABLE {9600, 19200, 38400, 57600, 115200}
1588 +/***********************************************************
1589 + * Command definition
1590 + ***********************************************************/
1592 +#include <config_cmd_default.h>
1594 +#define CONFIG_CMD_PING
1595 +#define CONFIG_CMD_DHCP
1596 +/* Enable below configure when supporting nand */
1597 +#define CONFIG_CMD_NAND
1598 +#define CONFIG_CMD_ENV
1600 +#undef CONFIG_CMD_IMLS
1602 +#define CONFIG_BOOTDELAY 3
1604 +#define CONFIG_PRIME "FEC0"
1606 +#define CONFIG_LOADADDR 0x90800000 /* loadaddr env var */
1607 +#define CONFIG_RD_LOADADDR (CONFIG_LOADADDR + 0x300000)
1609 +#define CONFIG_EXTRA_ENV_SETTINGS \
1611 + "ethprime=smc911x\0" \
1612 + "uboot_addr=0xa0000000\0" \
1613 + "uboot=u-boot.bin\0" \
1614 + "kernel=uImage\0" \
1615 + "rd_loadaddr=0x90B00000\0"
1616 + "nfsroot=/opt/eldk/arm\0" \
1617 + "bootargs_base=setenv bootargs console=ttymxc0,115200\0"\
1618 + "bootargs_nfs=setenv bootargs ${bootargs} root=/dev/nfs "\
1619 + "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0"\
1620 + "bootargs_android=setenv bootargs ${bootargs} ip=dhcp mem=480M init=/init wvga calibration\0" \
1621 + "bootcmd=run bootcmd_android\0" \
1622 + "bootcmd_net=run bootargs_base bootargs_nfs; " \
1623 + "tftpboot ${loadaddr} ${kernel}; bootm\0" \
1624 + "bootcmd_android=run bootargs_base bootargs_android; " \
1625 + "mmcinit;cp.b 0x100000 ${loadaddr} 0x250000; " \
1626 + "cp.b 0x400000 ${rd_loadaddr} 0x4B000; " \
1627 + "bootm ${loadaddr} ${rd_loadaddr}\0" \
1628 + "prg_uboot=tftpboot ${loadaddr} ${uboot}; " \
1629 + "protect off ${uboot_addr} 0xa003ffff; " \
1630 + "erase ${uboot_addr} 0xa003ffff; " \
1631 + "cp.b ${loadaddr} ${uboot_addr} ${filesize}; " \
1632 + "setenv filesize; saveenv\0"
1634 +/*Support LAN9217*/
1635 +#define CONFIG_DRIVER_SMC911X 1
1636 +#define CONFIG_DRIVER_SMC911X_16_BIT 1
1637 +#define CONFIG_DRIVER_SMC911X_BASE_VARIABLE mx51_io_base_addr
1640 + * The MX51 3stack board seems to have a hardware "peculiarity" confirmed under
1641 + * U-Boot, RedBoot and Linux: the ethernet Rx signal is reaching the CS8900A
1642 + * controller inverted. The controller is capable of detecting and correcting
1643 + * this, but it needs 4 network packets for that. Which means, at startup, you
1644 + * will not receive answers to the first 4 packest, unless there have been some
1645 + * broadcasts on the network, or your board is on a hub. Reducing the ARP
1646 + * timeout from default 5 seconds to 200ms we speed up the initial TFTP
1647 + * transfer, should the user wish one, significantly.
1649 +#define CONFIG_ARP_TIMEOUT 200UL
1652 + * Miscellaneous configurable options
1654 +#define CONFIG_SYS_LONGHELP /* undef to save memory */
1655 +#define CONFIG_SYS_PROMPT "MX51 U-Boot > "
1656 +#define CONFIG_AUTO_COMPLETE
1657 +#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
1658 +/* Print Buffer Size */
1659 +#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
1660 +#define CONFIG_SYS_MAXARGS 16 /* max number of command args */
1661 +#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE /* Boot Argument Buffer Size */
1663 +#define CONFIG_SYS_MEMTEST_START 0 /* memtest works on */
1664 +#define CONFIG_SYS_MEMTEST_END 0x10000
1666 +#undef CONFIG_SYS_CLKS_IN_HZ /* everything, incl board info, in Hz */
1668 +#define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR
1670 +#define CONFIG_SYS_HZ CONFIG_MX51_CLK32/* use 32kHz clock as source */
1672 +#define CONFIG_CMDLINE_EDITING 1
1674 +/*-----------------------------------------------------------------------
1677 + * The stack sizes are set up in start.S using the settings below
1679 +#define CONFIG_STACKSIZE (128 * 1024) /* regular stack */
1681 +/*-----------------------------------------------------------------------
1682 + * Physical Memory Map
1684 +#define CONFIG_NR_DRAM_BANKS 1
1685 +#define PHYS_SDRAM_1 CSD0_BASE_ADDR
1687 +/* #define PHYS_SDRAM_1_SIZE (128 * 1024 * 1024) */
1688 +#define PHYS_SDRAM_1_SIZE (512 * 1024 * 1024)
1690 +/*-----------------------------------------------------------------------
1691 + * FLASH and environment organization
1693 +#define CONFIG_SYS_NO_FLASH
1695 +/*-----------------------------------------------------------------------
1696 + * NAND FLASH driver setup
1698 +#define NAND_MAX_CHIPS 8
1699 +#define CONFIG_SYS_MAX_NAND_DEVICE 1
1700 +#define CONFIG_SYS_NAND_BASE 0x40000000
1702 +/* Monitor at beginning of flash */
1703 +#if defined(CONFIG_FSL_SF)
1704 + #define CONFIG_FSL_ENV_IN_SF
1705 +#elif defined(CONFIG_FSL_MMC)
1706 + #define CONFIG_FSL_ENV_IN_MMC
1707 +#elif defined(CONFIG_CMD_NAND)
1708 + #define CONFIG_FSL_ENV_IN_NAND
1711 +#define CONFIG_ENV_SECT_SIZE (128 * 1024)
1712 +#define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE
1714 +#if defined(CONFIG_FSL_ENV_IN_NAND)
1715 + #define CONFIG_ENV_IS_IN_NAND 1
1716 + #define CONFIG_ENV_OFFSET 0x100000
1717 +#elif defined(CONFIG_FSL_ENV_IN_MMC)
1718 + #define CONFIG_ENV_IS_IN_MMC 1
1719 + #define CONFIG_ENV_OFFSET (768 * 1024)
1720 +#elif defined(CONFIG_FSL_ENV_IN_SF)
1721 + #define CONFIG_ENV_IS_IN_SPI_FLASH 1
1722 + #define CONFIG_ENV_SPI_CS 1
1723 + #define CONFIG_ENV_OFFSET (768 * 1024)
1725 + #define CONFIG_ENV_IS_NOWHERE 1
1728 + * JFFS2 partitions
1730 +#undef CONFIG_JFFS2_CMDLINE
1731 +#define CONFIG_JFFS2_DEV "nand0"
1733 +#endif /* __CONFIG_H */
1734 diff --git a/include/mxc_keyb.h b/include/mxc_keyb.h
1735 new file mode 100644
1736 index 0000000..50c6a20
1738 +++ b/include/mxc_keyb.h
1741 + * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
1745 + * The code contained herein is licensed under the GNU General Public
1746 + * License. You may obtain a copy of the GNU General Public License
1747 + * Version 2 or later at the following locations:
1749 + * http://www.opensource.org/licenses/gpl-license.html
1750 + * http://www.gnu.org/copyleft/gpl.html
1754 + * @defgroup keypad Keypad Driver
1758 + * @file mxc_keyb.h
1760 + * @brief MXC keypad header file.
1764 +#ifndef __MXC_KEYB_H__
1765 +#define __MXC_KEYB_H__
1768 + * Keypad Module Name
1770 +#define MOD_NAME "mxckpd"
1773 + * Keypad irq number
1775 +#define KPP_IRQ MXC_INT_KPP
1778 + * XLATE mode selection
1780 +#define KEYPAD_XLATE 0
1783 + * RAW mode selection
1785 +#define KEYPAD_RAW 1
1788 + * Maximum number of keys.
1792 +#define MXC_MAXKEY (MAXROW * MAXCOL)
1795 + * This define indicates break scancode for every key release. A constant
1796 + * of 128 is added to the key press scancode.
1798 +#define MXC_KEYRELEASE 128
1801 + * _reg_KPP_KPCR _reg_KPP_KPSR _reg_KPP_KDDR _reg_KPP_KPDR
1802 + * Keypad Control Register Address
1804 +#define KPCR (KPP_BASE_ADDR + 0x00)
1807 + * Keypad Status Register Address
1809 +#define KPSR (KPP_BASE_ADDR + 0x02)
1812 + * Keypad Data Direction Address
1814 +#define KDDR (KPP_BASE_ADDR + 0x04)
1817 + * Keypad Data Register
1819 +#define KPDR (KPP_BASE_ADDR + 0x06)
1822 + * Key Press Interrupt Status bit
1824 +#define KBD_STAT_KPKD 0x01
1827 + * Key Release Interrupt Status bit
1829 +#define KBD_STAT_KPKR 0x02
1832 + * Key Depress Synchronizer Chain Status bit
1834 +#define KBD_STAT_KDSC 0x04
1837 + * Key Release Synchronizer Status bit
1839 +#define KBD_STAT_KRSS 0x08
1842 + * Key Depress Interrupt Enable Status bit
1844 +#define KBD_STAT_KDIE 0x100
1847 + * Key Release Interrupt Enable
1849 +#define KBD_STAT_KRIE 0x200
1852 + * Keypad Clock Enable
1854 +#define KBD_STAT_KPPEN 0x400
1857 + * Buffer size of keypad queue. Should be a power of 2.
1859 +#define KPP_BUF_SIZE 128
1862 + * Test whether bit is set for integer c
1864 +#define TEST_BIT(c, n) ((c) & (0x1 << (n)))
1867 + * Set nth bit in the integer c
1869 +#define BITSET(c, n) ((c) | (1 << (n)))
1872 + * Reset nth bit in the integer c
1874 +#define BITRESET(c, n) ((c) & ~(1 << (n)))
1882 + * This enum represents the keypad state machine to maintain debounce logic
1883 + * for key press/release.
1888 + * Key press state.
1893 + * Key press debounce state.
1898 + * Key release state.
1903 + * Key release debounce state.
1909 + * Keypad Private Data Structure
1911 +typedef struct keypad_priv {
1914 + * Keypad state machine.
1916 + enum KeyState iKeyState;
1919 + * Number of rows configured in the keypad matrix
1921 + unsigned long kpp_rows;
1924 + * Number of Columns configured in the keypad matrix
1926 + unsigned long kpp_cols;
1930 + * Keypad Data Structure
1932 +struct kpp_key_info {
1933 + enum KeyEvent evt;
1934 + unsigned short val;
1937 +int mxc_kpp_init();
1938 +int mxc_kpp_getc(struct kpp_key_info *);
1940 +#endif /* __MXC_KEYB_H__ */