From 0662793ca0050e823cd1207cc4689a1cba5068bd Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Thu, 28 Jun 2018 06:24:26 -0400 Subject: [PATCH] Add cleaned-up xDuoo X3 support Cleaned up, rebased, and forward-ported from the xvortex fork. (original credit to vsoftster@gmail.com) Change-Id: Ibcc023a0271ea81e901450a88317708c2683236d Signed-off-by: Solomon Peachy --- apps/SOURCES | 2 + apps/keymaps/keymap-xduoox3.c | 212 + apps/menus/sound_menu.c | 7 + apps/plugins/battery_bench.c | 6 + apps/plugins/blackjack.c | 16 + apps/plugins/brickmania.c | 10 + apps/plugins/calculator.c | 11 + apps/plugins/calendar.c | 10 + apps/plugins/chessbox/chessbox_pgn.h | 14 + apps/plugins/chessclock.c | 10 + apps/plugins/chip8.c | 8 + apps/plugins/chopper.c | 4 + apps/plugins/clix.c | 8 + apps/plugins/cube.c | 10 + apps/plugins/doom/i_video.c | 11 + apps/plugins/fft/fft.c | 9 + apps/plugins/flipit.c | 12 + apps/plugins/fractals/fractal.h | 12 + apps/plugins/goban/goban.h | 12 + apps/plugins/greyscale.c | 8 + apps/plugins/imageviewer/imageviewer_button.h | 15 + apps/plugins/jewels.c | 10 + apps/plugins/lib/keymaps.h | 8 + apps/plugins/lib/pluginlib_actions.c | 15 + apps/plugins/midi/midiplay.c | 8 + apps/plugins/minesweeper.c | 13 + apps/plugins/mp3_encoder.c | 6 + apps/plugins/mpegplayer/mpeg_settings.c | 10 + apps/plugins/mpegplayer/mpegplayer.c | 9 + apps/plugins/oscilloscope.c | 14 + apps/plugins/pegbox.c | 17 + apps/plugins/pictureflow/pictureflow.c | 3 +- apps/plugins/plugin.lds | 10 +- apps/plugins/pong.c | 8 + apps/plugins/reversi/reversi-gui.h | 11 + apps/plugins/rockblox.c | 12 + apps/plugins/rockboy/rockboy.c | 10 + apps/plugins/rockpaint.c | 11 + apps/plugins/sliding_puzzle.c | 9 + apps/plugins/snake.c | 8 + apps/plugins/snake2.c | 9 + apps/plugins/sokoban.c | 16 + apps/plugins/solitaire.c | 19 + apps/plugins/spacerocks.c | 9 + apps/plugins/star.c | 16 + apps/plugins/stopwatch.c | 8 + apps/plugins/sudoku/sudoku.h | 14 + apps/plugins/text_viewer/tv_button.h | 12 + apps/plugins/vu_meter.c | 11 + apps/plugins/wormlet.c | 9 + apps/plugins/xobox.c | 9 + apps/plugins/zxbox/keymaps.h | 8 + apps/plugins/zxbox/zxbox_keyb.c | 9 + apps/settings.h | 4 + bootloader/SOURCES | 3 + bootloader/common.c | 2 +- bootloader/xduoox3.c | 184 + docs/CREDITS | 3 + firmware/SOURCES | 35 +- firmware/drivers/audio/cs4398.c | 41 + firmware/drivers/audio/sdl.c | 4 + firmware/drivers/nand_id.c | 29 +- firmware/drivers/rtc/rtc_jz4760.c | 124 + firmware/export/audiohw.h | 3 +- firmware/export/audiohw_settings.h | 3 + firmware/export/config.h | 23 +- firmware/export/config/ondavx747.h | 2 +- firmware/export/config/ondavx767.h | 2 +- firmware/export/config/ondavx777.h | 2 +- firmware/export/config/xduoox3.h | 195 + firmware/export/cpu.h | 3 + firmware/export/cs4398.h | 116 + firmware/export/jz4760b.h | 9643 +++++++++++++++++ firmware/powermgmt.c | 2 +- firmware/sound.c | 10 + firmware/target/hosted/sdl/sim-ui-defines.h | 7 + firmware/target/mips/ingenic_jz47xx/app.lds | 6 +- .../mips/ingenic_jz47xx/ata-nand-jz4740.c | 2 +- .../mips/ingenic_jz47xx/ata-nand-jz4760.c | 692 ++ .../mips/ingenic_jz47xx/ata-sd-jz4740.c | 2 +- .../mips/ingenic_jz47xx/ata-sd-jz4760.c | 1487 +++ .../mips/ingenic_jz47xx/backlight-target.h | 2 + .../target/mips/ingenic_jz47xx/codec-jz4760.c | 293 + firmware/target/mips/ingenic_jz47xx/crt0.S | 2 + .../target/mips/ingenic_jz47xx/debug-jz4760.c | 146 + .../target/mips/ingenic_jz47xx/dma-target.h | 31 + .../mips/ingenic_jz47xx/dma_acc-jz4760.c | 102 + .../target/mips/ingenic_jz47xx/i2c-jz4760.c | 355 + .../mips/ingenic_jz47xx/kernel-jz4760.c | 53 + .../target/mips/ingenic_jz47xx/lcd-jz4760.c | 28 + .../target/mips/ingenic_jz47xx/pcm-jz4760.c | 240 + .../mips/ingenic_jz47xx/system-jz4760.c | 710 ++ .../mips/ingenic_jz47xx/system-target.h | 14 +- .../target/mips/ingenic_jz47xx/timer-jz4760.c | 101 + .../target/mips/ingenic_jz47xx/usb-jz4760.c | 870 ++ firmware/target/mips/ingenic_jz47xx/xdebug.h | 31 + .../mips/ingenic_jz47xx/xduoo_x3/adc-target.h | 28 + .../ingenic_jz47xx/xduoo_x3/ata-sd-target.h | 48 + .../xduoo_x3/backlight-xduoo_x3.c | 50 + .../ingenic_jz47xx/xduoo_x3/button-target.h | 46 + .../ingenic_jz47xx/xduoo_x3/lcd-xduoo_x3.c | 420 + .../ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c | 46 + .../ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c | 214 + firmware/target/mips/mmu-mips.c | 106 +- firmware/target/mips/mmu-mips.h | 14 +- firmware/usb.c | 3 +- tools/builds.pm | 4 + tools/configure | 24 + tools/release/sims.pl | 1 + tools/rockboxdev.sh | 2 +- tools/scramble.c | 4 +- uisimulator/bitmaps/UI-xduoox3.bmp | Bin 0 -> 263288 bytes uisimulator/buttonmap/SOURCES | 2 + uisimulator/buttonmap/xduoo-x3.c | 82 + 114 files changed, 17348 insertions(+), 101 deletions(-) create mode 100644 apps/keymaps/keymap-xduoox3.c create mode 100644 bootloader/xduoox3.c create mode 100644 firmware/drivers/audio/cs4398.c create mode 100644 firmware/drivers/rtc/rtc_jz4760.c create mode 100644 firmware/export/config/xduoox3.h create mode 100644 firmware/export/cs4398.h create mode 100644 firmware/export/jz4760b.h create mode 100644 firmware/target/mips/ingenic_jz47xx/ata-nand-jz4760.c create mode 100644 firmware/target/mips/ingenic_jz47xx/ata-sd-jz4760.c create mode 100644 firmware/target/mips/ingenic_jz47xx/codec-jz4760.c create mode 100644 firmware/target/mips/ingenic_jz47xx/debug-jz4760.c create mode 100644 firmware/target/mips/ingenic_jz47xx/dma-target.h create mode 100644 firmware/target/mips/ingenic_jz47xx/dma_acc-jz4760.c create mode 100644 firmware/target/mips/ingenic_jz47xx/i2c-jz4760.c create mode 100644 firmware/target/mips/ingenic_jz47xx/kernel-jz4760.c create mode 100644 firmware/target/mips/ingenic_jz47xx/lcd-jz4760.c create mode 100644 firmware/target/mips/ingenic_jz47xx/pcm-jz4760.c create mode 100644 firmware/target/mips/ingenic_jz47xx/system-jz4760.c create mode 100644 firmware/target/mips/ingenic_jz47xx/timer-jz4760.c create mode 100644 firmware/target/mips/ingenic_jz47xx/usb-jz4760.c create mode 100644 firmware/target/mips/ingenic_jz47xx/xdebug.h create mode 100644 firmware/target/mips/ingenic_jz47xx/xduoo_x3/adc-target.h create mode 100644 firmware/target/mips/ingenic_jz47xx/xduoo_x3/ata-sd-target.h create mode 100644 firmware/target/mips/ingenic_jz47xx/xduoo_x3/backlight-xduoo_x3.c create mode 100644 firmware/target/mips/ingenic_jz47xx/xduoo_x3/button-target.h create mode 100644 firmware/target/mips/ingenic_jz47xx/xduoo_x3/lcd-xduoo_x3.c create mode 100644 firmware/target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c create mode 100644 firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c create mode 100644 uisimulator/bitmaps/UI-xduoox3.bmp create mode 100644 uisimulator/buttonmap/xduoo-x3.c diff --git a/apps/SOURCES b/apps/SOURCES index de633880f6..a84c01977f 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -317,4 +317,6 @@ keymaps/keymap-ypr1.c keymaps/keymap-dx50.c #elif CONFIG_KEYPAD == AGPTEK_ROCKER_PAD keymaps/keymap-agptekrocker.c +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +keymaps/keymap-xduoox3.c #endif diff --git a/apps/keymaps/keymap-xduoox3.c b/apps/keymaps/keymap-xduoox3.c new file mode 100644 index 0000000000..abe8507cd8 --- /dev/null +++ b/apps/keymaps/keymap-xduoox3.c @@ -0,0 +1,212 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* Button Code Definitions for xDuoo X3 target */ + +#include "config.h" +#include "action.h" +#include "button.h" +#include "settings.h" + +/* {Action Code, Button code, Prereq button code } */ + +/* + * The format of the list is as follows + * { Action Code, Button code, Prereq button code } + * if there's no need to check the previous button's value, use BUTTON_NONE + * Insert LAST_ITEM_IN_LIST at the end of each mapping + */ +static const struct button_mapping button_context_standard[] = { + { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, + { ACTION_STD_CANCEL, BUTTON_OPTION|BUTTON_REL, BUTTON_OPTION }, + { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, + { ACTION_STD_MENU, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, + + LAST_ITEM_IN_LIST +}; /* button_context_standard */ + +static const struct button_mapping button_context_wps[] = { + { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, + { ACTION_WPS_STOP, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + { ACTION_WPS_SKIPPREV, BUTTON_PREV|BUTTON_REL, BUTTON_PREV }, + { ACTION_WPS_SEEKBACK, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_WPS_STOPSEEK, BUTTON_PREV|BUTTON_REL, BUTTON_PREV|BUTTON_REPEAT }, + { ACTION_WPS_SKIPNEXT, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT }, + { ACTION_WPS_SEEKFWD, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_WPS_STOPSEEK, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT|BUTTON_REPEAT }, + { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_WPS_BROWSE, BUTTON_OPTION|BUTTON_REL, BUTTON_OPTION }, + { ACTION_WPS_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, + { ACTION_WPS_MENU, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, + { ACTION_WPS_QUICKSCREEN, BUTTON_HOME|BUTTON_REPEAT, BUTTON_HOME }, + { ACTION_WPS_HOTKEY, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_OPTION }, + + LAST_ITEM_IN_LIST +}; /* button_context_wps */ + +static const struct button_mapping button_context_list[] = { + { ACTION_LIST_VOLUP, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_LIST_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_list */ + +/** Bookmark Screen **/ +static const struct button_mapping button_context_bmark[] = { + { ACTION_BMS_DELETE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST) +}; /* button_context_bmark */ + +/** Keyboard **/ +static const struct button_mapping button_context_keyboard[] = { + { ACTION_KBD_LEFT, BUTTON_PREV, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_NEXT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_OPTION, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_HOME, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_KBD_SELECT, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, + { ACTION_KBD_DONE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, + { ACTION_KBD_ABORT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard */ + +/** Pitchscreen **/ +static const struct button_mapping button_context_pitchscreen[] = { + { ACTION_PS_INC_SMALL, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_PS_INC_BIG, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_PS_DEC_SMALL, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_PS_DEC_BIG, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_PS_NUDGE_LEFT, BUTTON_PREV, BUTTON_NONE }, + { ACTION_PS_NUDGE_LEFTOFF, BUTTON_PREV|BUTTON_REL, BUTTON_NONE }, + { ACTION_PS_NUDGE_RIGHT, BUTTON_NEXT, BUTTON_NONE }, + { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_NEXT|BUTTON_REL, BUTTON_NONE }, + { ACTION_PS_TOGGLE_MODE, BUTTON_PLAY|BUTTON_REL, BUTTON_NONE }, + { ACTION_PS_RESET, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + { ACTION_PS_EXIT, BUTTON_OPTION|BUTTON_REL, BUTTON_OPTION }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_pitchscreen */ + +/** Quickscreen **/ +static const struct button_mapping button_context_quickscreen[] = { + { ACTION_QS_TOP, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_QS_TOP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_QS_DOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_QS_DOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_QS_LEFT, BUTTON_PREV, BUTTON_NONE }, + { ACTION_QS_LEFT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_QS_RIGHT, BUTTON_NEXT, BUTTON_NONE }, + { ACTION_QS_RIGHT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_quickscreen */ + +/** Settings - General Mappings **/ +static const struct button_mapping button_context_settings[] = { + { ACTION_SETTINGS_RESET, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, + { ACTION_STD_CANCEL, BUTTON_OPTION|BUTTON_REL, BUTTON_OPTION }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_settings */ + +static const struct button_mapping button_context_settings_vol_is_inc[] = { + { ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT,BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT,BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_settings_right_is_inc */ + +/** Tree **/ +static const struct button_mapping button_context_tree[] = { + { ACTION_TREE_WPS, BUTTON_HOME|BUTTON_REL, BUTTON_HOME }, + { ACTION_TREE_STOP, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + { ACTION_TREE_HOTKEY, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_OPTION }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST) +}; /* button_context_tree */ + +/** Yes/No Screen **/ +static const struct button_mapping button_context_yesnoscreen[] = { + { ACTION_YESNO_ACCEPT, BUTTON_PLAY, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_settings_yesnoscreen */ + +/* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */ +const struct button_mapping* get_context_mapping(int context) +{ + switch (context) + { + case CONTEXT_LIST: + return button_context_list; + case CONTEXT_STD: + return button_context_standard; + case CONTEXT_BOOKMARKSCREEN: + return button_context_bmark; + case CONTEXT_KEYBOARD: + return button_context_keyboard; + case CONTEXT_PITCHSCREEN: + return button_context_pitchscreen; + case CONTEXT_QUICKSCREEN: + return button_context_quickscreen; + case CONTEXT_SETTINGS: + return button_context_settings; + case CONTEXT_SETTINGS_TIME: + case CONTEXT_SETTINGS_COLOURCHOOSER: + case CONTEXT_SETTINGS_EQ: + case CONTEXT_SETTINGS_RECTRIGGER: + return button_context_settings_vol_is_inc; + case CONTEXT_TREE: + case CONTEXT_MAINMENU: + return button_context_tree; + case CONTEXT_WPS: + return button_context_wps; + case CONTEXT_YESNOSCREEN: + return button_context_yesnoscreen; + } + return button_context_standard; +} diff --git a/apps/menus/sound_menu.c b/apps/menus/sound_menu.c index 69e8e3676a..489d03bf4d 100644 --- a/apps/menus/sound_menu.c +++ b/apps/menus/sound_menu.c @@ -132,6 +132,10 @@ MENUITEM_SETTING(depth_3d, &global_settings.depth_3d, NULL); MENUITEM_SETTING(roll_off, &global_settings.roll_off, NULL); #endif +#ifdef AUDIOHW_HAVE_FUNCTIONAL_MODE +MENUITEM_SETTING(func_mode, &global_settings.func_mode, NULL); +#endif + #if CONFIG_CODEC == SWCODEC /* Crossfeed Submenu */ MENUITEM_SETTING(crossfeed, &global_settings.crossfeed, lowlatency_callback); @@ -256,6 +260,9 @@ MAKE_MENU(sound_settings, ID2P(LANG_SOUND_SETTINGS), NULL, Icon_Audio, #ifdef AUDIOHW_HAVE_FILTER_ROLL_OFF ,&roll_off #endif +#ifdef AUDIOHW_HAVE_FUNCTIONAL_MODE + ,&func_mode +#endif #if CONFIG_CODEC == SWCODEC ,&crossfeed_menu, &equalizer_menu, &dithering_enabled ,&surround_menu, &pbe_menu, &afr_enabled diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index bb9c3b0e6f..9a48ef2fdb 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c @@ -279,6 +279,12 @@ #define BATTERY_OFF_TXT "Right" #define BATTERY_ON_TXT "Left - start" +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define BATTERY_ON BUTTON_PLAY +#define BATTERY_OFF BUTTON_POWER +#define BATTERY_ON_TXT "PLAY - start" +#define BATTERY_OFF_TXT "POWER" + #else #error No keymap defined! #endif diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c index 411ff3970b..6c3e487bf2 100644 --- a/apps/plugins/blackjack.c +++ b/apps/plugins/blackjack.c @@ -573,6 +573,22 @@ enum { #define BJACK_QUIT_NAME "Volume up" #define BJACK_DOUBLE_NAME "Option+Down" +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define BJACK_SELECT_NAME "PLAY" +#define BJACK_STAY_NAME "NEXT" +#define BJACK_QUIT_NAME "POWER" +#define BJACK_DOUBLE_NAME "PREV" +#define BJACK_SELECT BUTTON_PLAY +#define BJACK_QUIT BUTTON_POWER +#define BJACK_MAX BUTTON_VOL_UP +#define BJACK_MIN BUTTON_VOL_DOWN +#define BJACK_STAY BUTTON_NEXT +#define BJACK_DOUBLEDOWN BUTTON_PREV +#define BJACK_UP BUTTON_HOME +#define BJACK_DOWN BUTTON_OPTION +#define BJACK_RIGHT BUTTON_NEXT +#define BJACK_LEFT BUTTON_PREV + #else #error No keymap defined! #endif diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index 3fc30819b9..24c6fab613 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c @@ -332,6 +332,16 @@ CONFIG_KEYPAD == SANSA_CONNECT_PAD #define UP BUTTON_UP #define DOWN BUTTON_DOWN +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define QUIT BUTTON_POWER +#define LEFT BUTTON_PREV +#define RIGHT BUTTON_NEXT +#define ALTLEFT BUTTON_VOL_DOWN +#define ALTRIGHT BUTTON_VOL_UP +#define SELECT BUTTON_PLAY +#define UP BUTTON_HOME +#define DOWN BUTTON_OPTION + #else #error No keymap defined! #endif diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c index a30ccdc83d..f10bca66ec 100644 --- a/apps/plugins/calculator.c +++ b/apps/plugins/calculator.c @@ -525,6 +525,17 @@ F3: equal to "=" #define CALCULATOR_CALC BUTTON_VOLUP #define CALCULATOR_CLEAR (BUTTON_SELECT|BUTTON_REPEAT) +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define CALCULATOR_LEFT BUTTON_PREV +#define CALCULATOR_RIGHT BUTTON_NEXT +#define CALCULATOR_UP BUTTON_HOME +#define CALCULATOR_DOWN BUTTON_OPTION +#define CALCULATOR_QUIT BUTTON_POWER +#define CALCULATOR_INPUT_CALC_PRE (BUTTON_OPTION|BUTTON_REPEAT) +#define CALCULATOR_INPUT (BUTTON_PLAY|BUTTON_REL) +#define CALCULATOR_CALC (BUTTON_PLAY|BUTTON_REPEAT) +#define CALCULATOR_CLEAR (BUTTON_POWER|BUTTON_REPEAT) + #else #error No keymap defined! #endif diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c index 23446beb40..74ee49904b 100644 --- a/apps/plugins/calendar.c +++ b/apps/plugins/calendar.c @@ -413,6 +413,16 @@ #define CALENDAR_NEXT_MONTH (BUTTON_VOLDOWN) #define CALENDAR_PREV_MONTH (BUTTON_VOLUP) +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define CALENDAR_QUIT BUTTON_POWER +#define CALENDAR_SELECT BUTTON_PLAY +#define CALENDAR_NEXT_WEEK BUTTON_OPTION +#define CALENDAR_PREV_WEEK BUTTON_HOME +#define CALENDAR_NEXT_DAY BUTTON_NEXT +#define CALENDAR_PREV_DAY BUTTON_PREV +#define CALENDAR_NEXT_MONTH BUTTON_VOL_UP +#define CALENDAR_PREV_MONTH BUTTON_VOL_DOWN + #else #error "No keypad setting." #endif diff --git a/apps/plugins/chessbox/chessbox_pgn.h b/apps/plugins/chessbox/chessbox_pgn.h index fe50297732..1f44d1b712 100644 --- a/apps/plugins/chessbox/chessbox_pgn.h +++ b/apps/plugins/chessbox/chessbox_pgn.h @@ -558,6 +558,20 @@ #define CB_SCROLL_LEFT (BUTTON_LEFT|BUTTON_REPEAT) #define CB_SCROLL_RIGHT (BUTTON_RIGHT|BUTTON_REPEAT) +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define CB_SELECT BUTTON_PLAY +#define CB_UP BUTTON_HOME +#define CB_DOWN BUTTON_OPTION +#define CB_LEFT BUTTON_PREV +#define CB_RIGHT BUTTON_NEXT +#define CB_PLAY BUTTON_VOL_UP +#define CB_LEVEL (BUTTON_PLAY|BUTTON_REPEAT) +#define CB_MENU BUTTON_POWER +#define CB_SCROLL_UP (BUTTON_HOME|BUTTON_REPEAT) +#define CB_SCROLL_DOWN (BUTTON_OPTION|BUTTON_REPEAT) +#define CB_SCROLL_LEFT (BUTTON_PREV|BUTTON_REPEAT) +#define CB_SCROLL_RIGHT (BUTTON_NEXT|BUTTON_REPEAT) + #else #error No keymap defined! #endif diff --git a/apps/plugins/chessclock.c b/apps/plugins/chessclock.c index bc907feec3..ae7889ed95 100644 --- a/apps/plugins/chessclock.c +++ b/apps/plugins/chessclock.c @@ -412,6 +412,16 @@ #define CHC_SETTINGS_CANCEL BUTTON_RIGHT #define CHC_SETTINGS_OK (BUTTON_SELECT|BUTTON_REPEAT) +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define CHC_QUIT BUTTON_POWER +#define CHC_STARTSTOP BUTTON_PLAY +#define CHC_RESET BUTTON_OPTION +#define CHC_MENU BUTTON_HOME +#define CHC_SETTINGS_INC BUTTON_NEXT +#define CHC_SETTINGS_DEC BUTTON_PREV +#define CHC_SETTINGS_OK BUTTON_PLAY +#define CHC_SETTINGS_CANCEL BUTTON_POWER + #else #error No keymap defined! #endif diff --git a/apps/plugins/chip8.c b/apps/plugins/chip8.c index 5fb55ae011..153558667e 100644 --- a/apps/plugins/chip8.c +++ b/apps/plugins/chip8.c @@ -1283,6 +1283,14 @@ CONFIG_KEYPAD == MROBE500_PAD #define CHIP8_KEY6 BUTTON_RIGHT #define CHIP8_KEY8 BUTTON_LEFT +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define CHIP8_OFF BUTTON_POWER +#define CHIP8_KEY2 BUTTON_HOME +#define CHIP8_KEY4 BUTTON_PREV +#define CHIP8_KEY5 BUTTON_PLAY +#define CHIP8_KEY6 BUTTON_NEXT +#define CHIP8_KEY8 BUTTON_OPTION + #else #error No keymap defined! #endif diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c index 4a838c44ae..1732a16ecb 100644 --- a/apps/plugins/chopper.c +++ b/apps/plugins/chopper.c @@ -209,6 +209,10 @@ CONFIG_KEYPAD == MROBE500_PAD #define ACTION BUTTON_SELECT #define ACTIONTEXT "Select" +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define QUIT BUTTON_POWER +#define ACTION BUTTON_PLAY +#define ACTIONTEXT "PLAY" #elif !defined(HAVE_TOUCHSCREEN) #error No keymap defined! diff --git a/apps/plugins/clix.c b/apps/plugins/clix.c index b47fe69952..b2580a1630 100644 --- a/apps/plugins/clix.c +++ b/apps/plugins/clix.c @@ -276,6 +276,14 @@ #define CLIX_BUTTON_RIGHT BUTTON_RIGHT #define CLIX_BUTTON_CLICK BUTTON_SELECT +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define CLIX_BUTTON_QUIT BUTTON_POWER +#define CLIX_BUTTON_UP BUTTON_HOME +#define CLIX_BUTTON_DOWN BUTTON_OPTION +#define CLIX_BUTTON_LEFT BUTTON_PREV +#define CLIX_BUTTON_RIGHT BUTTON_NEXT +#define CLIX_BUTTON_CLICK BUTTON_PLAY + #else #error "no keymap" #endif diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c index 04cb013f26..9a67c337d1 100644 --- a/apps/plugins/cube.c +++ b/apps/plugins/cube.c @@ -413,6 +413,16 @@ #define CUBE_HIGHSPEED (BUTTON_SELECT | BUTTON_REPEAT) #define CUBE_PAUSE (BUTTON_LEFT | BUTTON_REPEAT) +#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) +#define CUBE_QUIT BUTTON_POWER +#define CUBE_NEXT BUTTON_NEXT +#define CUBE_PREV BUTTON_PREV +#define CUBE_INC BUTTON_VOL_UP +#define CUBE_DEC BUTTON_VOL_DOWN +#define CUBE_MODE BUTTON_OPTION +#define CUBE_PAUSE BUTTON_HOME +#define CUBE_HIGHSPEED BUTTON_PLAY + #else #error No keymap defined! #endif diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c index 5535f08b6e..d734e1e12b 100644 --- a/apps/plugins/doom/i_video.c +++ b/apps/plugins/doom/i_video.c @@ -555,6 +555,17 @@ void I_ShutdownGraphics(void) #define DOOMBUTTON_WEAPON BUTTON_VOLUP #define DOOMBUTTON_MAP (BUTTON_VOLUP|BUTTON_REPEAT) +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define DOOMBUTTON_UP BUTTON_HOME +#define DOOMBUTTON_DOWN BUTTON_OPTION +#define DOOMBUTTON_LEFT BUTTON_PREV +#define DOOMBUTTON_RIGHT BUTTON_NEXT +#define DOOMBUTTON_SHOOT BUTTON_PLAY +#define DOOMBUTTON_OPEN (BUTTON_HOME | BUTTON_POWER) +#define DOOMBUTTON_ESC BUTTON_POWER +#define DOOMBUTTON_ENTER BUTTON_PLAY +#define DOOMBUTTON_WEAPON BUTTON_VOL_UP + #else #error Keymap not defined! #endif diff --git a/apps/plugins/fft/fft.c b/apps/plugins/fft/fft.c index a83bd36557..e5750c109a 100644 --- a/apps/plugins/fft/fft.c +++ b/apps/plugins/fft/fft.c @@ -334,6 +334,15 @@ GREY_INFO_STRUCT # define FFT_ORIENTATION BUTTON_SELECT # define FFT_WINDOW BUTTON_VOLDOWN +#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) +# define FFT_PREV_GRAPH BUTTON_PREV +# define FFT_NEXT_GRAPH BUTTON_NEXT +# define FFT_ORIENTATION BUTTON_HOME +# define FFT_FREQ_SCALE BUTTON_OPTION +# define FFT_WINDOW (BUTTON_HOME|BUTTON_POWER) +# define FFT_AMP_SCALE BUTTON_PLAY +# define FFT_QUIT BUTTON_POWER + #elif !defined(HAVE_TOUCHSCREEN) #error No keymap defined! #endif diff --git a/apps/plugins/flipit.c b/apps/plugins/flipit.c index fafc1f9c08..b089974aef 100644 --- a/apps/plugins/flipit.c +++ b/apps/plugins/flipit.c @@ -482,6 +482,18 @@ #define FLIPIT_STEP_BY_STEP (BUTTON_LEFT|BUTTON_VOLUP) #define FLIPIT_TOGGLE BUTTON_SELECT +#elif CONFIG_KEYPAD == XDUOO_X3_PAD + +#define FLIPIT_LEFT BUTTON_PREV +#define FLIPIT_RIGHT BUTTON_NEXT +#define FLIPIT_UP BUTTON_HOME +#define FLIPIT_DOWN BUTTON_OPTION +#define FLIPIT_QUIT BUTTON_POWER +#define FLIPIT_SHUFFLE (BUTTON_HOME | BUTTON_PREV) +#define FLIPIT_SOLVE (BUTTON_HOME | BUTTON_NEXT) +#define FLIPIT_STEP_BY_STEP (BUTTON_HOME | BUTTON_PLAY) +#define FLIPIT_TOGGLE BUTTON_PLAY + #else #error No keymap defined! #endif diff --git a/apps/plugins/fractals/fractal.h b/apps/plugins/fractals/fractal.h index aa8c31f093..ed6be31695 100644 --- a/apps/plugins/fractals/fractal.h +++ b/apps/plugins/fractals/fractal.h @@ -484,6 +484,18 @@ #define FRACTAL_PRECISION_DEC (BUTTON_VOLUP|BUTTON_LEFT) #define FRACTAL_RESET BUTTON_SELECT +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define FRACTAL_QUIT BUTTON_POWER +#define FRACTAL_UP BUTTON_HOME +#define FRACTAL_DOWN BUTTON_OPTION +#define FRACTAL_LEFT BUTTON_PREV +#define FRACTAL_RIGHT BUTTON_NEXT +#define FRACTAL_ZOOM_IN BUTTON_VOL_UP +#define FRACTAL_ZOOM_OUT BUTTON_VOL_DOWN +#define FRACTAL_PRECISION_INC (BUTTON_PLAY | BUTTON_NEXT) +#define FRACTAL_PRECISION_DEC (BUTTON_PLAY | BUTTON_PREV) +#define FRACTAL_RESET (BUTTON_HOME | BUTTON_POWER) + #else #error No keymap defined! #endif diff --git a/apps/plugins/goban/goban.h b/apps/plugins/goban/goban.h index 135b9dbe95..d1d66e3535 100644 --- a/apps/plugins/goban/goban.h +++ b/apps/plugins/goban/goban.h @@ -452,6 +452,18 @@ #define GBN_BUTTON_PLAY (BUTTON_SELECT | BUTTON_REL) #define GBN_BUTTON_NAV_MODE BUTTON_VOLUP +#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) +#define GBN_BUTTON_UP BUTTON_HOME +#define GBN_BUTTON_DOWN BUTTON_OPTION +#define GBN_BUTTON_LEFT BUTTON_PREV +#define GBN_BUTTON_RIGHT BUTTON_NEXT +#define GBN_BUTTON_RETREAT BUTTON_VOL_DOWN +#define GBN_BUTTON_ADVANCE BUTTON_VOL_UP +#define GBN_BUTTON_MENU BUTTON_POWER +#define GBN_BUTTON_PLAY BUTTON_PLAY | BUTTON_REL +#define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT +#define GBN_BUTTON_NEXT_VAR BUTTON_HOME | BUTTON_POWER + #else #error Unsupported keypad #endif diff --git a/apps/plugins/greyscale.c b/apps/plugins/greyscale.c index 4dd29cee0b..ae873a06ac 100644 --- a/apps/plugins/greyscale.c +++ b/apps/plugins/greyscale.c @@ -108,6 +108,14 @@ #define GREYSCALE_RIGHT BUTTON_RIGHT #define GREYSCALE_OFF BUTTON_PLAY +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define GREYSCALE_SHIFT BUTTON_PLAY +#define GREYSCALE_UP BUTTON_HOME +#define GREYSCALE_DOWN BUTTON_OPTION +#define GREYSCALE_LEFT BUTTON_PREV +#define GREYSCALE_RIGHT BUTTON_NEXT +#define GREYSCALE_OFF BUTTON_POWER + #endif #define GFX_HEIGHT (LCD_HEIGHT-8) diff --git a/apps/plugins/imageviewer/imageviewer_button.h b/apps/plugins/imageviewer/imageviewer_button.h index abd84f1710..2f349b1a24 100644 --- a/apps/plugins/imageviewer/imageviewer_button.h +++ b/apps/plugins/imageviewer/imageviewer_button.h @@ -495,6 +495,21 @@ #define IMGVIEW_QUIT (BUTTON_POWER|BUTTON_REL) #define IMGVIEW_MENU (BUTTON_SELECT|BUTTON_REL) +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define IMGVIEW_ZOOM_PRE BUTTON_PLAY +#define IMGVIEW_ZOOM_IN (BUTTON_PLAY | BUTTON_REL) +#define IMGVIEW_ZOOM_OUT (BUTTON_PLAY | BUTTON_REPEAT) +#define IMGVIEW_UP BUTTON_HOME +#define IMGVIEW_DOWN BUTTON_OPTION +#define IMGVIEW_LEFT BUTTON_PREV +#define IMGVIEW_RIGHT BUTTON_NEXT +#define IMGVIEW_NEXT BUTTON_VOL_UP +#define IMGVIEW_NEXT_REPEAT (BUTTON_VOL_UP|BUTTON_REPEAT) +#define IMGVIEW_PREVIOUS BUTTON_VOL_DOWN +#define IMGVIEW_PREVIOUS_REPEAT (BUTTON_VOL_DOWN|BUTTON_REPEAT) +#define IMGVIEW_MENU BUTTON_POWER +#define IMGVIEW_SLIDE_SHOW (BUTTON_HOME|BUTTON_POWER) + #else #error No keymap defined! #endif diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c index 97531a001c..e4a22830a1 100644 --- a/apps/plugins/jewels.c +++ b/apps/plugins/jewels.c @@ -377,6 +377,16 @@ CONFIG_KEYPAD == MROBE500_PAD #define JEWELS_CANCEL BUTTON_POWER #define HK_CANCEL "Power" +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define JEWELS_UP BUTTON_HOME +#define JEWELS_DOWN BUTTON_OPTION +#define JEWELS_LEFT BUTTON_PREV +#define JEWELS_RIGHT BUTTON_NEXT +#define JEWELS_SELECT BUTTON_PLAY +#define JEWELS_CANCEL BUTTON_POWER +#define HK_SELECT "PLAY" +#define HK_CANCEL "POWER" + #else #error No keymap defined! #endif diff --git a/apps/plugins/lib/keymaps.h b/apps/plugins/lib/keymaps.h index 64deccf513..5fab361620 100644 --- a/apps/plugins/lib/keymaps.h +++ b/apps/plugins/lib/keymaps.h @@ -215,6 +215,14 @@ #define BTN_FIRE BUTTON_MENU #define BTN_PAUSE BUTTON_POWER +#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) +#define BTN_UP BUTTON_VOL_UP +#define BTN_DOWN BUTTON_VOL_DOWN +#define BTN_LEFT BUTTON_PREV +#define BTN_RIGHT BUTTON_NEXT +#define BTN_FIRE BUTTON_PLAY +#define BTN_PAUSE BUTTON_OPTION + #else #error Unsupported keypad #endif diff --git a/apps/plugins/lib/pluginlib_actions.c b/apps/plugins/lib/pluginlib_actions.c index f9addb32f4..2c5fb773ba 100644 --- a/apps/plugins/lib/pluginlib_actions.c +++ b/apps/plugins/lib/pluginlib_actions.c @@ -228,6 +228,15 @@ const struct button_mapping pla_main_ctx[] = { PLA_DOWN_REPEAT, BUTTON_FF|BUTTON_REPEAT, BUTTON_NONE}, { PLA_LEFT_REPEAT, BUTTON_REW|BUTTON_M|BUTTON_REPEAT, BUTTON_NONE}, { PLA_RIGHT_REPEAT, BUTTON_FF|BUTTON_M|BUTTON_REPEAT, BUTTON_NONE}, +#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) + { PLA_UP, BUTTON_HOME, BUTTON_NONE }, + { PLA_DOWN, BUTTON_OPTION, BUTTON_NONE }, + { PLA_LEFT, BUTTON_PREV, BUTTON_NONE }, + { PLA_RIGHT, BUTTON_NEXT, BUTTON_NONE }, + { PLA_UP_REPEAT, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE }, + { PLA_DOWN_REPEAT, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_NONE }, + { PLA_LEFT_REPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, + { PLA_RIGHT_REPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, #else # ifndef HAVE_TOUCHSCREEN # error pluginlib_actions: No directions defined @@ -447,6 +456,12 @@ const struct button_mapping pla_main_ctx[] = {PLA_SELECT, BUTTON_PLAY, BUTTON_NONE}, {PLA_SELECT_REL, BUTTON_PLAY|BUTTON_REL, BUTTON_NONE}, {PLA_SELECT_REPEAT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE}, +#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) + {PLA_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_POWER}, + {PLA_EXIT, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE}, + {PLA_SELECT, BUTTON_PLAY, BUTTON_NONE}, + {PLA_SELECT_REL, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY}, + {PLA_SELECT_REPEAT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE}, #else # ifndef HAVE_TOUCHSCREEN diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c index 418f72b6a5..de6310dcd8 100644 --- a/apps/plugins/midi/midiplay.c +++ b/apps/plugins/midi/midiplay.c @@ -293,6 +293,14 @@ #define MIDI_VOL_DOWN BUTTON_VOLDOWN #define MIDI_PLAYPAUSE BUTTON_SELECT +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define MIDI_QUIT BUTTON_POWER +#define MIDI_FFWD BUTTON_NEXT +#define MIDI_REWIND BUTTON_PREV +#define MIDI_VOL_UP BUTTON_VOL_UP +#define MIDI_VOL_DOWN BUTTON_VOL_DOWN +#define MIDI_PLAYPAUSE BUTTON_PLAY + #else #error No keymap defined! #endif diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c index 98eb8d9e7a..2a3b5f78e9 100644 --- a/apps/plugins/minesweeper.c +++ b/apps/plugins/minesweeper.c @@ -404,6 +404,19 @@ CONFIG_KEYPAD == MROBE500_PAD #elif CONFIG_KEYPAD == CREATIVE_ZENXFI2_PAD # define MINESWP_QUIT BUTTON_POWER +#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) +# define MINESWP_LEFT BUTTON_PREV +# define MINESWP_RIGHT BUTTON_NEXT +# define MINESWP_UP BUTTON_HOME +# define MINESWP_DOWN BUTTON_OPTION +# define MINESWP_QUIT BUTTON_POWER +# define MINESWP_TOGGLE_PRE BUTTON_PLAY +# define MINESWP_TOGGLE (BUTTON_PLAY | BUTTON_REL) +# define MINESWP_TOGGLE2 BUTTON_VOL_DOWN +# define MINESWP_DISCOVER (BUTTON_PLAY | BUTTON_REPEAT) +# define MINESWP_DISCOVER2 BUTTON_VOL_UP +# define MINESWP_INFO (BUTTON_PLAY | BUTTON_OPTION) + #else #error No keymap defined! #endif diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c index e86e74f408..9e09135385 100644 --- a/apps/plugins/mp3_encoder.c +++ b/apps/plugins/mp3_encoder.c @@ -2556,6 +2556,12 @@ CONFIG_KEYPAD == MROBE500_PAD #define MP3ENC_DONE BUTTON_POWER #define MP3ENC_SELECT BUTTON_SELECT +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define MP3ENC_PREV BUTTON_HOME +#define MP3ENC_NEXT BUTTON_OPTION +#define MP3ENC_DONE BUTTON_POWER +#define MP3ENC_SELECT BUTTON_PLAY + #else #error No keymap defined! #endif diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c index dadfccf291..7976f5f542 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.c +++ b/apps/plugins/mpegplayer/mpeg_settings.c @@ -306,6 +306,16 @@ struct mpeg_settings settings; #define MPEG_START_TIME_DOWN BUTTON_DOWN #define MPEG_START_TIME_EXIT BUTTON_POWER +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define MPEG_START_TIME_SELECT BUTTON_PLAY +#define MPEG_START_TIME_LEFT BUTTON_PREV +#define MPEG_START_TIME_RIGHT BUTTON_NEXT +#define MPEG_START_TIME_UP BUTTON_HOME +#define MPEG_START_TIME_DOWN BUTTON_OPTION +#define MPEG_START_TIME_LEFT2 BUTTON_VOL_UP +#define MPEG_START_TIME_RIGHT2 BUTTON_VOL_DOWN +#define MPEG_START_TIME_EXIT BUTTON_POWER + #else #error No keymap defined! #endif diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index 07cf8ba8e2..fd3e8d8cd5 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c @@ -441,6 +441,15 @@ CONFIG_KEYPAD == SANSA_M200_PAD #define MPEG_RW BUTTON_LEFT #define MPEG_FF BUTTON_RIGHT +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define MPEG_MENU BUTTON_PLAY +#define MPEG_STOP BUTTON_POWER +#define MPEG_PAUSE BUTTON_HOME +#define MPEG_VOLDOWN BUTTON_VOL_DOWN +#define MPEG_VOLUP BUTTON_VOL_UP +#define MPEG_RW BUTTON_PREV +#define MPEG_FF BUTTON_NEXT + #else #error No keymap defined! #endif diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c index 85cbf2bfb2..4534684293 100644 --- a/apps/plugins/oscilloscope.c +++ b/apps/plugins/oscilloscope.c @@ -504,6 +504,20 @@ #define OSCILLOSCOPE_VOL_UP BUTTON_VOLUP #define OSCILLOSCOPE_VOL_DOWN BUTTON_VOLDOWN +#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) +#define OSCILLOSCOPE_QUIT BUTTON_POWER +#define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_PLAY +#define OSCILLOSCOPE_DRAWMODE (BUTTON_PLAY | BUTTON_REL) +#define OSCILLOSCOPE_ORIENTATION_PRE BUTTON_PLAY +#define OSCILLOSCOPE_ORIENTATION (BUTTON_PLAY | BUTTON_REPEAT) +#define OSCILLOSCOPE_ADVMODE BUTTON_HOME +#define OSCILLOSCOPE_PAUSE BUTTON_OPTION +#define OSCILLOSCOPE_SPEED_UP BUTTON_NEXT +#define OSCILLOSCOPE_SPEED_DOWN BUTTON_PREV +#define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP +#define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN +#define NEED_LASTBUTTON + #else #error No keymap defined! #endif diff --git a/apps/plugins/pegbox.c b/apps/plugins/pegbox.c index dcc6176d2b..922359cd32 100644 --- a/apps/plugins/pegbox.c +++ b/apps/plugins/pegbox.c @@ -643,6 +643,23 @@ CONFIG_KEYPAD == MROBE500_PAD #define QUIT_TEXT "POWER" #define SELECT_TEXT "MENU" +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define PEGBOX_SELECT BUTTON_PLAY +#define PEGBOX_QUIT BUTTON_POWER +#define PEGBOX_RESTART (BUTTON_POWER | BUTTON_HOME) +#define PEGBOX_LVL_UP BUTTON_VOL_UP +#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN +#define PEGBOX_UP BUTTON_HOME +#define PEGBOX_DOWN BUTTON_OPTION +#define PEGBOX_RIGHT BUTTON_NEXT +#define PEGBOX_LEFT BUTTON_PREV + +#define SELECT_TEXT "PLAY" +#define QUIT_TEXT "POWER" +#define RESTART_TEXT "HOME" +#define LVL_UP_TEXT "VOL+" +#define LVL_DOWN_TEXT "VOL-" + #else #error Unsupported keymap! #endif diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 6e47418e93..84a4315141 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c @@ -118,7 +118,8 @@ const struct button_mapping pf_context_buttons[] = CONFIG_KEYPAD == GIGABEAT_PAD || CONFIG_KEYPAD == GIGABEAT_S_PAD || \ CONFIG_KEYPAD == MROBE100_PAD || CONFIG_KEYPAD == MROBE500_PAD || \ CONFIG_KEYPAD == PHILIPS_SA9200_PAD || CONFIG_KEYPAD == SANSA_CLIP_PAD || \ - CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD || CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD + CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD || CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD || \ + CONFIG_KEYPAD == XDUOO_X3_PAD {PF_QUIT, BUTTON_POWER, BUTTON_NONE}, #if CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD {PF_MENU, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT}, diff --git a/apps/plugins/plugin.lds b/apps/plugins/plugin.lds index 831cb59b81..aea44e7d40 100644 --- a/apps/plugins/plugin.lds +++ b/apps/plugins/plugin.lds @@ -163,8 +163,14 @@ OUTPUT_FORMAT(elf32-littlemips) #define IRAMORIG (0x00000000 + (56*1024)) #define IRAMSIZE (200*1024) -#elif CONFIG_CPU == JZ4732 -#define DRAMORIG 0x80004000 + STUBOFFSET +#elif CONFIG_CPU == JZ4732 || CONFIG_CPU == JZ4760B +#undef STUBOFFSET +#ifdef DEBUG +#define STUBOFFSET 0x14000 +#else +#define STUBOFFSET 0x4000 +#endif +#define DRAMORIG 0x80000000 + STUBOFFSET #define IRAM DRAM #define IRAMSIZE 0 /* The bit of IRAM that is available is used in the core */ diff --git a/apps/plugins/pong.c b/apps/plugins/pong.c index 016d548675..d65134e5d2 100644 --- a/apps/plugins/pong.c +++ b/apps/plugins/pong.c @@ -309,6 +309,14 @@ CONFIG_KEYPAD == MROBE500_PAD #define PONG_QUIT BUTTON_POWER #define PONG_PAUSE BUTTON_MENU +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define PONG_QUIT BUTTON_POWER +#define PONG_PAUSE BUTTON_PLAY +#define PONG_LEFT_UP BUTTON_PREV +#define PONG_LEFT_DOWN BUTTON_OPTION +#define PONG_RIGHT_UP BUTTON_HOME +#define PONG_RIGHT_DOWN BUTTON_NEXT + #else #error No keymap defined! #endif diff --git a/apps/plugins/reversi/reversi-gui.h b/apps/plugins/reversi/reversi-gui.h index 67897a9772..1dc1dedbed 100644 --- a/apps/plugins/reversi/reversi-gui.h +++ b/apps/plugins/reversi/reversi-gui.h @@ -328,6 +328,17 @@ #define REVERSI_BUTTON_MAKE_MOVE BUTTON_SELECT #define REVERSI_BUTTON_MENU BUTTON_POWER +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define REVERSI_BUTTON_QUIT BUTTON_POWER +#define REVERSI_BUTTON_UP BUTTON_HOME +#define REVERSI_BUTTON_DOWN BUTTON_OPTION +#define REVERSI_BUTTON_LEFT BUTTON_PREV +#define REVERSI_BUTTON_RIGHT BUTTON_NEXT +#define REVERSI_BUTTON_MAKE_MOVE BUTTON_PLAY +#define REVERSI_BUTTON_MAKE_MOVE_SHORTPRESS +#define REVERSI_BUTTON_MENU BUTTON_PLAY +#define REVERSI_BUTTON_MENU_LONGPRESS + #else #error No keymap defined! #endif diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c index a0814beda1..b204ed87da 100644 --- a/apps/plugins/rockblox.c +++ b/apps/plugins/rockblox.c @@ -480,6 +480,18 @@ #define ROCKBLOX_ROTATE_CCW BUTTON_VOLDOWN #define ROCKBLOX_DOWN BUTTON_DOWN +#elif CONFIG_KEYPAD == XDUOO_X3_PAD + +#define ROCKBLOX_OFF BUTTON_POWER +#define ROCKBLOX_ROTATE_CCW BUTTON_HOME +#define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_DOWN +#define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP +#define ROCKBLOX_DOWN BUTTON_OPTION +#define ROCKBLOX_LEFT BUTTON_PREV +#define ROCKBLOX_RIGHT BUTTON_NEXT +#define ROCKBLOX_DROP (BUTTON_PLAY|BUTTON_REL) +#define ROCKBLOX_RESTART (BUTTON_PLAY|BUTTON_REPEAT) + #else #error No keymap defined! #endif diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c index 38536d1375..7425fc2550 100644 --- a/apps/plugins/rockboy/rockboy.c +++ b/apps/plugins/rockboy/rockboy.c @@ -423,6 +423,16 @@ static void setoptions (void) options.A = BUTTON_VOLDOWN; options.B = BUTTON_VOLUP; +#elif CONFIG_KEYPAD == XDUOO_X3_PAD + options.UP = BUTTON_PREV; + options.DOWN = BUTTON_NEXT; + + options.A = BUTTON_HOME; + options.B = BUTTON_OPTION; + options.START = BUTTON_VOL_DOWN; + options.SELECT = BUTTON_VOL_UP; + options.MENU = BUTTON_POWER; + #else #error No Keymap Defined! #endif diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c index d2534f4aa6..d0f9f7235c 100644 --- a/apps/plugins/rockpaint.c +++ b/apps/plugins/rockpaint.c @@ -327,6 +327,17 @@ #define ROCKPAINT_QUIT BUTTON_POWER #define ROCKPAINT_MENU BUTTON_MENU +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define ROCKPAINT_QUIT BUTTON_POWER +#define ROCKPAINT_DRAW BUTTON_PLAY +#define ROCKPAINT_MENU (BUTTON_HOME | BUTTON_POWER) +#define ROCKPAINT_TOOLBAR BUTTON_VOL_UP +#define ROCKPAINT_TOOLBAR2 BUTTON_VOL_DOWN +#define ROCKPAINT_UP BUTTON_HOME +#define ROCKPAINT_DOWN BUTTON_OPTION +#define ROCKPAINT_LEFT BUTTON_PREV +#define ROCKPAINT_RIGHT BUTTON_NEXT + #else #error "Please define keys for this keypad" #endif diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c index d43c3d527f..a3f84e32ae 100644 --- a/apps/plugins/sliding_puzzle.c +++ b/apps/plugins/sliding_puzzle.c @@ -331,6 +331,15 @@ CONFIG_KEYPAD == MROBE500_PAD #define PUZZLE_SHUFFLE BUTTON_POWER #define PUZZLE_PICTURE BUTTON_SELECT +#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) +#define PUZZLE_QUIT BUTTON_POWER +#define PUZZLE_LEFT BUTTON_PREV +#define PUZZLE_RIGHT BUTTON_NEXT +#define PUZZLE_UP BUTTON_HOME +#define PUZZLE_DOWN BUTTON_OPTION +#define PUZZLE_SHUFFLE (BUTTON_HOME | BUTTON_POWER) +#define PUZZLE_PICTURE BUTTON_PLAY + #else #error No keymap defined! #endif diff --git a/apps/plugins/snake.c b/apps/plugins/snake.c index a73e61d9ec..9144edf062 100644 --- a/apps/plugins/snake.c +++ b/apps/plugins/snake.c @@ -289,6 +289,14 @@ dir is the current direction of the snake - 0=up, 1=right, 2=down, 3=left; #define SNAKE_DOWN BUTTON_DOWN #define SNAKE_PLAYPAUSE BUTTON_SELECT +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define SNAKE_QUIT BUTTON_POWER +#define SNAKE_LEFT BUTTON_PREV +#define SNAKE_RIGHT BUTTON_NEXT +#define SNAKE_UP BUTTON_HOME +#define SNAKE_DOWN BUTTON_OPTION +#define SNAKE_PLAYPAUSE BUTTON_PLAY + #else #error No keymap defined! #endif diff --git a/apps/plugins/snake2.c b/apps/plugins/snake2.c index f32012e029..13d2c57b24 100644 --- a/apps/plugins/snake2.c +++ b/apps/plugins/snake2.c @@ -419,6 +419,15 @@ CONFIG_KEYPAD == MROBE500_PAD #define SNAKE2_PLAYPAUSE BUTTON_SELECT #define SNAKE2_PLAYPAUSE_TEXT "Select" +#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) +#define SNAKE2_LEFT BUTTON_PREV +#define SNAKE2_RIGHT BUTTON_NEXT +#define SNAKE2_UP BUTTON_HOME +#define SNAKE2_DOWN BUTTON_OPTION +#define SNAKE2_QUIT BUTTON_POWER +#define SNAKE2_PLAYPAUSE BUTTON_PLAY +#define SNAKE2_PLAYPAUSE_TEXT "PLAY" + #else #error No keymap defined! #endif diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c index af369f82a6..98d295eb1a 100644 --- a/apps/plugins/sokoban.c +++ b/apps/plugins/sokoban.c @@ -651,6 +651,22 @@ #define SOKOBAN_MENU BUTTON_MENU #define SOKOBAN_MENU_NAME "[MENU]" +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define SOKOBAN_LEFT BUTTON_PREV +#define SOKOBAN_RIGHT BUTTON_NEXT +#define SOKOBAN_UP BUTTON_HOME +#define SOKOBAN_DOWN BUTTON_OPTION +#define SOKOBAN_MENU BUTTON_POWER +#define SOKOBAN_UNDO_PRE BUTTON_PLAY +#define SOKOBAN_UNDO (BUTTON_PLAY | BUTTON_REL) +#define SOKOBAN_REDO (BUTTON_POWER | BUTTON_PLAY) +#define SOKOBAN_LEVEL_DOWN BUTTON_VOL_DOWN +#define SOKOBAN_LEVEL_REPEAT (BUTTON_PLAY | BUTTON_NEXT) +#define SOKOBAN_LEVEL_UP BUTTON_VOL_UP +#define SOKOBAN_PAUSE BUTTON_PLAY +#define BUTTON_SAVE BUTTON_PLAY +#define BUTTON_SAVE_NAME "PLAY" + #else #error No keymap defined! #endif diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c index ee3742472b..fe7da2788e 100644 --- a/apps/plugins/solitaire.c +++ b/apps/plugins/solitaire.c @@ -687,6 +687,25 @@ CONFIG_KEYPAD == MROBE500_PAD #elif CONFIG_KEYPAD == CREATIVE_ZENXFI2_PAD # define SOL_QUIT BUTTON_POWER +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +# define SOL_QUIT BUTTON_POWER +# define SOL_UP BUTTON_HOME +# define SOL_DOWN BUTTON_OPTION +# define SOL_LEFT BUTTON_PREV +# define SOL_RIGHT BUTTON_NEXT +# define SOL_MOVE_PRE BUTTON_PLAY +# define SOL_MOVE (BUTTON_PLAY | BUTTON_REL) +# define SOL_DRAW (BUTTON_POWER | BUTTON_REPEAT) +# define SOL_REM2CUR BUTTON_VOL_DOWN +# define SOL_CUR2STACK_PRE BUTTON_PLAY +# define SOL_CUR2STACK (BUTTON_PLAY | BUTTON_REPEAT) +# define SOL_REM2STACK BUTTON_VOL_UP +# define HK_MOVE "PLAY" +# define HK_DRAW "DBL HOME" +# define HK_REM2CUR "PREV" +# define HK_CUR2STACK "DBL PLAY" +# define HK_REM2STACK "NEXT" + #else #error No keymap defined! #endif diff --git a/apps/plugins/spacerocks.c b/apps/plugins/spacerocks.c index 7a22de814b..ad03919861 100644 --- a/apps/plugins/spacerocks.c +++ b/apps/plugins/spacerocks.c @@ -354,6 +354,15 @@ #define AST_RIGHT BUTTON_RIGHT #define AST_FIRE BUTTON_SELECT +#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) +#define AST_PAUSE BUTTON_VOL_UP +#define AST_QUIT BUTTON_POWER +#define AST_THRUST BUTTON_HOME +#define AST_HYPERSPACE BUTTON_OPTION +#define AST_LEFT BUTTON_PREV +#define AST_RIGHT BUTTON_NEXT +#define AST_FIRE BUTTON_PLAY + #else #error No keymap defined! #endif diff --git a/apps/plugins/star.c b/apps/plugins/star.c index 6d0cd65e20..bcddab8f20 100644 --- a/apps/plugins/star.c +++ b/apps/plugins/star.c @@ -623,6 +623,22 @@ #define STAR_TOGGLE_CONTROL_NAME "Play" #define STAR_QUIT_NAME "Back" +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define STAR_QUIT BUTTON_POWER +#define STAR_LEFT BUTTON_PREV +#define STAR_RIGHT BUTTON_NEXT +#define STAR_UP BUTTON_HOME +#define STAR_DOWN BUTTON_OPTION +#define STAR_TOGGLE_CONTROL BUTTON_PLAY +#define STAR_LEVEL_UP (BUTTON_PLAY | BUTTON_NEXT) +#define STAR_LEVEL_DOWN (BUTTON_PLAY | BUTTON_PREV) +#define STAR_LEVEL_REPEAT (BUTTON_PLAY | BUTTON_OPTION) +#define STAR_TOGGLE_CONTROL_NAME "PLAY" +#define STAR_QUIT_NAME "POWER" +#define STAR_LEVEL_UP_NAME "PLAY + NEXT" +#define STAR_LEVEL_DOWN_NAME "PLAY + PREV" +#define STAR_LEVEL_REPEAT_NAME "PLAY + OPTION" + #else #error No keymap defined! #endif diff --git a/apps/plugins/stopwatch.c b/apps/plugins/stopwatch.c index 8d99178e48..69f14a20ef 100644 --- a/apps/plugins/stopwatch.c +++ b/apps/plugins/stopwatch.c @@ -313,6 +313,14 @@ #define STOPWATCH_SCROLL_UP BUTTON_UP #define STOPWATCH_SCROLL_DOWN BUTTON_DOWN +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define STOPWATCH_QUIT BUTTON_POWER +#define STOPWATCH_START_STOP BUTTON_NEXT +#define STOPWATCH_RESET_TIMER BUTTON_PREV +#define STOPWATCH_LAP_TIMER BUTTON_PLAY +#define STOPWATCH_SCROLL_UP BUTTON_HOME +#define STOPWATCH_SCROLL_DOWN BUTTON_OPTION + #else #error No keymap defined! #endif diff --git a/apps/plugins/sudoku/sudoku.h b/apps/plugins/sudoku/sudoku.h index 8d871c7b2d..e26644a2d8 100644 --- a/apps/plugins/sudoku/sudoku.h +++ b/apps/plugins/sudoku/sudoku.h @@ -423,6 +423,20 @@ #define SUDOKU_BUTTON_TOGGLE BUTTON_SELECT #define SUDOKU_BUTTON_POSSIBLE BUTTON_VOLUP +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define SUDOKU_BUTTON_QUIT_PRE BUTTON_POWER +#define SUDOKU_BUTTON_QUIT (BUTTON_POWER | BUTTON_REPEAT) +#define SUDOKU_BUTTON_UP BUTTON_HOME +#define SUDOKU_BUTTON_DOWN BUTTON_OPTION +#define SUDOKU_BUTTON_LEFT BUTTON_PREV +#define SUDOKU_BUTTON_RIGHT BUTTON_NEXT +#define SUDOKU_BUTTON_TOGGLEBACK BUTTON_VOL_DOWN +#define SUDOKU_BUTTON_TOGGLE BUTTON_VOL_UP +#define SUDOKU_BUTTON_ALTTOGGLE BUTTON_PLAY +#define SUDOKU_BUTTON_MENU_PRE BUTTON_POWER +#define SUDOKU_BUTTON_MENU (BUTTON_POWER | BUTTON_REL) +#define SUDOKU_BUTTON_POSSIBLE (BUTTON_HOME | BUTTON_POWER) + #else #error No keymap defined! #endif diff --git a/apps/plugins/text_viewer/tv_button.h b/apps/plugins/text_viewer/tv_button.h index 9d1b5afa88..58bce80eaf 100644 --- a/apps/plugins/text_viewer/tv_button.h +++ b/apps/plugins/text_viewer/tv_button.h @@ -550,6 +550,18 @@ #define TV_AUTOSCROLL BUTTON_VOLDOWN #define TV_BOOKMARK BUTTON_VOLUP +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define TV_QUIT BUTTON_POWER +#define TV_SCROLL_UP BUTTON_VOL_UP +#define TV_SCROLL_DOWN BUTTON_VOL_DOWN +#define TV_SCREEN_LEFT BUTTON_PREV +#define TV_SCREEN_RIGHT BUTTON_NEXT +#define TV_MENU BUTTON_PLAY +#define TV_AUTOSCROLL (BUTTON_POWER | BUTTON_HOME) +#define TV_LINE_UP BUTTON_HOME +#define TV_LINE_DOWN BUTTON_OPTION +#define TV_BOOKMARK (BUTTON_OPTION | BUTTON_PLAY) + #else #error No keymap defined! #endif diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c index 8c80066c67..04876ba198 100644 --- a/apps/plugins/vu_meter.c +++ b/apps/plugins/vu_meter.c @@ -421,6 +421,17 @@ #define LABEL_VOLUME "Vol Up/Down" #define LABEL_MENU "Select" +#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) +#define VUMETER_QUIT BUTTON_POWER +#define VUMETER_HELP BUTTON_HOME +#define VUMETER_MENU BUTTON_PLAY +#define VUMETER_UP BUTTON_VOL_UP +#define VUMETER_DOWN BUTTON_VOL_DOWN +#define LABEL_HELP "HOME" +#define LABEL_QUIT "POWER" +#define LABEL_MENU "PLAY" +#define LABEL_VOLUME "VOL UP/DN" + #else #error No keymap defined! #endif diff --git a/apps/plugins/wormlet.c b/apps/plugins/wormlet.c index f1ccaec782..83cfadc338 100644 --- a/apps/plugins/wormlet.c +++ b/apps/plugins/wormlet.c @@ -393,6 +393,15 @@ CONFIG_KEYPAD == MROBE500_PAD #define BTN_QUIT BUTTON_POWER #define BTN_STOPRESET (BUTTON_SELECT|BUTTON_REPEAT) +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define BTN_DIR_UP BUTTON_HOME +#define BTN_DIR_DOWN BUTTON_OPTION +#define BTN_DIR_LEFT BUTTON_PREV +#define BTN_DIR_RIGHT BUTTON_NEXT +#define BTN_STARTPAUSE BUTTON_PLAY +#define BTN_QUIT BUTTON_POWER +#define BTN_STOPRESET (BUTTON_HOME | BUTTON_POWER) + #else #error No keymap defined! #endif diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c index f5c4a29bdf..9b41e2d1ac 100644 --- a/apps/plugins/xobox.c +++ b/apps/plugins/xobox.c @@ -342,6 +342,15 @@ CONFIG_KEYPAD == MROBE500_PAD #define DOWN BUTTON_DOWN #define PAUSE BUTTON_SELECT +#elif CONFIG_KEYPAD == XDUOO_X3_PAD + +#define QUIT BUTTON_POWER +#define LEFT BUTTON_PREV +#define RIGHT BUTTON_NEXT +#define UP BUTTON_HOME +#define DOWN BUTTON_OPTION +#define PAUSE BUTTON_PLAY + #else #error No keymap defined! #endif diff --git a/apps/plugins/zxbox/keymaps.h b/apps/plugins/zxbox/keymaps.h index d10eeb67e7..ebdd41734e 100644 --- a/apps/plugins/zxbox/keymaps.h +++ b/apps/plugins/zxbox/keymaps.h @@ -282,6 +282,14 @@ #define ZX_RIGHT BUTTON_RIGHT #define ZX_SELECT BUTTON_SELECT +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +#define ZX_SELECT BUTTON_PLAY +#define ZX_MENU BUTTON_POWER +#define ZX_LEFT BUTTON_PREV +#define ZX_RIGHT BUTTON_NEXT +#define ZX_UP BUTTON_HOME +#define ZX_DOWN BUTTON_OPTION + #else #error Keymap not defined! diff --git a/apps/plugins/zxbox/zxbox_keyb.c b/apps/plugins/zxbox/zxbox_keyb.c index 2931c8ea32..f38712d8d1 100644 --- a/apps/plugins/zxbox/zxbox_keyb.c +++ b/apps/plugins/zxbox/zxbox_keyb.c @@ -278,6 +278,15 @@ #define KBD_UP BUTTON_UP #define KBD_DOWN BUTTON_DOWN +#elif CONFIG_KEYPAD == XDUOO_X3_PAD + +#define KBD_SELECT BUTTON_PLAY +#define KBD_ABORT BUTTON_POWER +#define KBD_LEFT BUTTON_PREV +#define KBD_RIGHT BUTTON_NEXT +#define KBD_UP BUTTON_HOME +#define KBD_DOWN BUTTON_OPTION + #endif #ifdef HAVE_TOUCHSCREEN diff --git a/apps/settings.h b/apps/settings.h index 411675153a..8d8c766d45 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -811,6 +811,10 @@ struct user_settings int roll_off; #endif +#ifdef AUDIOHW_HAVE_FUNCTIONAL_MODE + int func_mode; +#endif + #ifdef AUDIOHW_HAVE_EQ /** Hardware EQ tone controls **/ struct hw_eq_band diff --git a/bootloader/SOURCES b/bootloader/SOURCES index 359e2ba700..0b39da153a 100644 --- a/bootloader/SOURCES +++ b/bootloader/SOURCES @@ -53,6 +53,9 @@ samsung_yps3.c #elif defined(ONDA_VX747) || defined(ONDA_VX747P) || defined(ONDA_VX767) || defined(ONDA_VX777) ondavx747.c show_logo.c +#elif defined(XDUOO_X3) +xduoox3.c +show_logo.c #elif defined(CREATIVE_ZVx) creativezvm.c #elif CONFIG_CPU==AS3525 || CONFIG_CPU==AS3525v2 diff --git a/bootloader/common.c b/bootloader/common.c index 4969d92b40..5c5647ac64 100644 --- a/bootloader/common.c +++ b/bootloader/common.c @@ -54,7 +54,7 @@ || defined(SAMSUNG_YH820) || defined(PHILIPS_SA9200) \ || defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) \ || defined(ONDA_VX747) || defined(PBELL_VIBE500) \ - || defined(TOSHIBA_GIGABEAT_S) + || defined(TOSHIBA_GIGABEAT_S) || defined(XDUOO_X3) bool verbose = false; #else bool verbose = true; diff --git a/bootloader/xduoox3.c b/bootloader/xduoox3.c new file mode 100644 index 0000000000..3db87a866d --- /dev/null +++ b/bootloader/xduoox3.c @@ -0,0 +1,184 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "jz4760b.h" +#include "../kernel-internal.h" +#include "backlight.h" +#include "font.h" +#include "lcd.h" +#include "file.h" +#include "usb.h" +#include "system.h" +#include "button.h" +#include "common.h" +#include "rb-loader.h" +#include "loader_strerror.h" +#include "storage.h" +#include "file_internal.h" +#include "disk.h" +#include "string.h" +#include "adc.h" +#include "version.h" + +#include "xdebug.h" + +extern void show_logo(void); +extern void power_off(void); + +static void show_splash(int timeout, const char *msg) +{ + reset_screen(); + lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * strlen(msg))) / 2, + (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg); + lcd_update(); + + sleep(timeout); +} + +static void usb_mode(void) +{ + int button; + + /* Init USB */ + usb_init(); + usb_start_monitoring(); + + /* Wait for threads to connect */ + show_splash(HZ/2, "Waiting for USB"); + + while (1) + { + button = button_get_w_tmo(HZ/2); + + if (button == SYS_USB_CONNECTED) + break; /* Hit */ + } + + if (button == SYS_USB_CONNECTED) + { + /* Got the message - wait for disconnect */ + show_splash(0, "Bootloader USB mode"); + + usb_acknowledge(SYS_USB_CONNECTED_ACK); + + while (1) + { + button = button_get(true); + if (button == SYS_USB_DISCONNECTED) + break; + } + } +} + +static int boot_rockbox(void) +{ + int rc; + void (*kernel_entry)(void); + + printf("Mounting disk...\n"); + rc = disk_mount_all(); + if (rc <= 0) + { + verbose = true; + error(EDISK,rc, true); + } + + printf("Loading firmware...\n"); + rc = load_firmware((unsigned char *)CONFIG_SDRAM_START, BOOTFILE, 0x400000); + if(rc <= EFILE_EMPTY) + return rc; + else + { + printf("Starting Rockbox...\n"); + adc_close(); /* Disable SADC, seems to fix the re-init Rockbox does */ + + disable_interrupt(); + kernel_entry = (void*) CONFIG_SDRAM_START; + kernel_entry(); + + return 0; /* Shouldn't happen */ + } +} + +static void reset_configuration(void) +{ + int rc; + + rc = disk_mount_all(); + if (rc <= 0) + { + verbose = true; + error(EDISK,rc, true); + } + + if(rename(ROCKBOX_DIR "/config.cfg", ROCKBOX_DIR "/config.old") == 0) + show_splash(HZ/2, "Configuration reset successfully!"); + else + show_splash(HZ/2, "Couldn't reset configuration!"); +} + +int main(void) +{ + int rc; + + serial_puts("\n\nSPL Stage 2\n\n"); + + kernel_init(); + lcd_init(); + font_init(); + lcd_setfont(FONT_SYSFIXED); + button_init(); + backlight_init(); + + show_logo(); + + filesystem_init(); + + rc = storage_init(); + if(rc) + { + verbose = true; + error(EATA, rc, true); + } + + /* Don't mount the disks yet, there could be file system/partition errors + which are fixable in USB mode */ + + reset_screen(); + + printf(MODEL_NAME" Rockbox Bootloader\n"); + printf("Version %s\n", rbversion); + + rc = boot_rockbox(); + + if(rc <= EFILE_EMPTY) + { + verbose = true; + printf("Error: %s", loader_strerror(rc)); + } + + /* Halt */ + while (1) + core_idle(); + + return 0; +} diff --git a/docs/CREDITS b/docs/CREDITS index 2ce7a86f4b..7743ba0af8 100644 --- a/docs/CREDITS +++ b/docs/CREDITS @@ -663,6 +663,9 @@ Constantine Mountantonakis Ivan Pesic Jonatan Nyberg Alessandro Stoppani +Alexander Yurenin +Roman Stolyarov +Solomon Peachy The libmad team The wavpack team diff --git a/firmware/SOURCES b/firmware/SOURCES index d2c27b71f0..33d59fa429 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -366,8 +366,10 @@ drivers/rtc/rtc_mr100.c drivers/rtc/rtc_mc13783.c #elif (CONFIG_RTC == RTC_TCC77X) drivers/rtc/rtc_tcc77x.c -#elif (CONFIG_RTC == RTC_JZ47XX) +#elif (CONFIG_RTC == RTC_JZ4740) drivers/rtc/rtc_jz4740.c +#elif (CONFIG_RTC == RTC_JZ4760) +drivers/rtc/rtc_jz4760.c #elif (CONFIG_RTC == RTC_S35390A) drivers/rtc/rtc_s35390a.c #elif (CONFIG_RTC == RTC_S35380A) @@ -477,6 +479,8 @@ drivers/audio/dummy_codec.c drivers/audio/df1704.c #elif defined (HAVE_PCM1792_CODEC) drivers/audio/pcm1792.c +#elif defined (HAVE_CS4398) +drivers/audio/cs4398.c #endif /* defined(HAVE_*) */ #else /* PLATFORM_HOSTED */ #if defined(SAMSUNG_YPR0) && defined(HAVE_AS3514) @@ -739,9 +743,9 @@ target/arm/crt0.S #elif defined(CPU_MIPS) && (CONFIG_PLATFORM & PLATFORM_NATIVE) target/mips/mmu-mips.c -#if CONFIG_CPU==JZ4732 +#if CONFIG_CPU==JZ4732 || CONFIG_CPU==JZ4760B target/mips/ingenic_jz47xx/crt0.S -#endif /* CONFIG_CPU == JZ4732 */ +#endif /* CONFIG_CPU == JZ4732 || JZ4760B */ #else @@ -1725,6 +1729,24 @@ target/mips/ingenic_jz47xx/pcm-jz4740.c drivers/nand_id.c #endif /* CONFIG_CPU == JZ4732 */ +#if CONFIG_CPU == JZ4760B +target/mips/ingenic_jz47xx/dma_acc-jz4760.c +target/mips/ingenic_jz47xx/ata-nand-jz4760.c +target/mips/ingenic_jz47xx/ata-sd-jz4760.c +target/mips/ingenic_jz47xx/debug-jz4760.c +target/mips/ingenic_jz47xx/kernel-jz4760.c +target/mips/ingenic_jz47xx/i2c-jz4760.c +target/mips/ingenic_jz47xx/lcd-jz4760.c +target/mips/ingenic_jz47xx/system-jz4760.c +target/mips/ingenic_jz47xx/usb-jz4760.c +target/mips/ingenic_jz47xx/timer-jz4760.c +#ifndef BOOTLOADER +target/mips/ingenic_jz47xx/codec-jz4760.c +target/mips/ingenic_jz47xx/pcm-jz4760.c +#endif /* BOOTLOADER */ +drivers/nand_id.c +#endif /* CONFIG_CPU == JZ4760B */ + #if defined(ONDA_VX747) || defined(ONDA_VX747P) || defined(ONDA_VX777) target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c @@ -1741,6 +1763,13 @@ target/mips/ingenic_jz47xx/onda_vx767/power-onda_vx767.c target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c #endif /* ONDA_VX767 */ +#if defined(XDUOO_X3) +target/mips/ingenic_jz47xx/xduoo_x3/backlight-xduoo_x3.c +target/mips/ingenic_jz47xx/xduoo_x3/lcd-xduoo_x3.c +target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c +target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c +#endif /* XDUOO_X3 */ + #if defined(LYRE_PROTO1) target/arm/at91sam/lyre_proto1/adc-lyre_proto1.c target/arm/at91sam/lyre_proto1/backlight-lyre_proto1.c diff --git a/firmware/drivers/audio/cs4398.c b/firmware/drivers/audio/cs4398.c new file mode 100644 index 0000000000..35aa99d08c --- /dev/null +++ b/firmware/drivers/audio/cs4398.c @@ -0,0 +1,41 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "system.h" +#include "cs4398.h" +#include "config.h" +#include "audio.h" +#include "audiohw.h" +#include "i2c.h" + +void cs4398_write_reg(uint8_t reg, uint8_t val) +{ + unsigned char buf[2] = {reg, val}; + i2c_write(CS4398_I2C_ADDR, (unsigned char *)&buf, 2); +} + +uint8_t cs4398_read_reg(uint8_t reg) +{ + unsigned char buf[2] = {reg, 0xff}; + i2c_write(CS4398_I2C_ADDR, (unsigned char *)&buf[0], 1); + i2c_read(CS4398_I2C_ADDR, (unsigned char *)&buf[1], 1); + return buf[1]; +} diff --git a/firmware/drivers/audio/sdl.c b/firmware/drivers/audio/sdl.c index ae66380d16..a8fd2ffa07 100644 --- a/firmware/drivers/audio/sdl.c +++ b/firmware/drivers/audio/sdl.c @@ -122,6 +122,10 @@ void audiohw_set_depth_3d(int value) void audiohw_set_lineout_volume(int vol_l, int vol_r) { (void)vol_l; (void)vol_r; } #endif +#if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF) +void audiohw_set_filter_roll_off(int value) + { (void)value; } +#endif void audiohw_close(void) {} diff --git a/firmware/drivers/nand_id.c b/firmware/drivers/nand_id.c index f2b9861c7c..56132ab090 100644 --- a/firmware/drivers/nand_id.c +++ b/firmware/drivers/nand_id.c @@ -34,27 +34,38 @@ static const struct nand_info samsung[] = /* id1, id2 pages/block, blocks, page_size, spare_size, col_cycles, row_cycles, planes -*/ +*/ {0xDC, 0x10, /* K9F4G08UOM */ 64, 4096, 2048, 64, 2, 3, 1 }, - + {0xD3, 0x51, /* K9K8G08UOM */ 64, 8192, 2048, 64, 2, 3, 1 }, - + {0xD5, 0x14, /* K9GAG08UOM */ 128, 4096, 4096, 128, 2, 3, 2 }, - + {0xD5, 0x55, /* K9LAG08UOM, K9HBG08U1M, K9MCG08U5M */ 128, 8192, 2048, 64, 2, 3, 4 }, - + {0xD7, 0x55, /* K9LBG08UOM */ 128, 8192, 4096, 128, 2, 3, 4 }, }; +static const struct nand_info gigadevice[] = +{ +/* + id1, id2 + pages/block, blocks, page_size, spare_size, col_cycles, row_cycles, planes +*/ + {0xB1, 0x80, /* MD5N01G51MSD1B */ + 64, 1024, 2048, 64, 2, 2, 1 }, +}; + #define NI(id, x) {id, (struct nand_info*)x, (sizeof(x)/sizeof(struct nand_info))} static const struct nand_manufacturer all[] = { NI(0xEC, samsung), + NI(0x98, gigadevice), }; // ----------------------------------------------------------------------------- @@ -63,7 +74,7 @@ struct nand_info* nand_identify(unsigned char data[5]) { unsigned int i; int found = -1; - + for(i = 0; i < (sizeof(all)/sizeof(struct nand_manufacturer)); i++) { if(data[0] == all[i].id) @@ -72,16 +83,16 @@ struct nand_info* nand_identify(unsigned char data[5]) break; } } - + if(found < 0) return NULL; - + for(i = 0; i < all[found].total; i++) { if(data[1] == all[found].info[i].dev_id && data[2] == all[found].info[i].dev_id2) return &all[found].info[i]; } - + return NULL; } diff --git a/firmware/drivers/rtc/rtc_jz4760.c b/firmware/drivers/rtc/rtc_jz4760.c new file mode 100644 index 0000000000..cda618d617 --- /dev/null +++ b/firmware/drivers/rtc/rtc_jz4760.c @@ -0,0 +1,124 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* + * Real Time Clock interface for Jz4760. + * + */ + +#include "config.h" +#include "cpu.h" +#include "rtc.h" +#include "timefuncs.h" +#include "logf.h" + +#define RTC_FREQ_DIVIDER (32768 - 1) + +/* Stolen from dietlibc-0.29/libugly/gmtime_r.c (GPLv2) */ +#define SPD (24*60*60) +#define ISLEAP(year) (!(year%4) && ((year%100) || !(year%400))) +static void _localtime(const time_t t, struct tm *r) +{ + time_t i; + register time_t work = t % SPD; + static int m_to_d[12] = /* This could be shared with mktime() */ + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; + + r->tm_sec = work % 60; + work /= 60; + r->tm_min = work % 60; + r->tm_hour = work / 60; + work = t / SPD; + r->tm_wday = (4 + work) % 7; + + for (i=1970; ; ++i) + { + register time_t k = ISLEAP(i) ? 366 : 365; + + if (work >= k) + work -= k; + else + break; + } + + r->tm_year = i - 1900; + r->tm_yday = work; + + r->tm_mday = 1; + if (ISLEAP(i) && (work>58)) + { + if (work==59) + r->tm_mday=2; /* 29.2. */ + + work-=1; + } + + for (i=11; i && (m_to_d[i] > work); --i); + r->tm_mon = i; + r->tm_mday += work - m_to_d[i]; +} + +int rtc_read_datetime(struct tm *tm) +{ + _localtime(rtc_read_reg(RTC_RTCSR), tm); + + return 1; +} + +int rtc_write_datetime(const struct tm *tm) +{ + rtc_write_reg(RTC_RTCSR, mktime((struct tm*)tm)); + + return 0; +} + +void rtc_init(void) +{ + unsigned int cfc,hspr,rgr_1hz; + + __cpm_select_rtcclk_rtc(); + + cfc = HSPR_RTCV; + hspr = rtc_read_reg(RTC_HSPR); + rgr_1hz = rtc_read_reg(RTC_RTCGR) & RTCGR_NC1HZ_MASK; + + if((hspr != cfc) || (rgr_1hz != RTC_FREQ_DIVIDER)) + { + /* We are powered on for the first time !!! */ + + /* Set 32768 rtc clocks per seconds */ + rtc_write_reg(RTC_RTCGR, RTC_FREQ_DIVIDER); + + /* Set minimum wakeup_n pin low-level assertion time for wakeup: 100ms */ + rtc_write_reg(RTC_HWFCR, HWFCR_WAIT_TIME(100)); + rtc_write_reg(RTC_HRCR, HRCR_WAIT_TIME(60)); + + /* Reset to the default time */ + rtc_write_reg(RTC_RTCSR, 946681200); /* 01/01/2000 */ + + /* start rtc */ + rtc_write_reg(RTC_RTCCR, RTCCR_RTCE); + rtc_write_reg(RTC_HSPR, cfc); + } + + /* clear all rtc flags */ + rtc_write_reg(RTC_HWRSR, 0); +} diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h index 26a1a69f95..09001c8045 100644 --- a/firmware/export/audiohw.h +++ b/firmware/export/audiohw.h @@ -209,6 +209,8 @@ struct sound_settings_info #include "pcm1792.h" #elif defined(HAVE_NWZ_LINUX_CODEC) #include "nwzlinux_codec.h" +#elif defined(HAVE_CS4398) +#include "cs4398.h" #elif (CONFIG_PLATFORM & (PLATFORM_ANDROID | PLATFORM_MAEMO\ | PLATFORM_PANDORA | PLATFORM_SDL)) #include "hosted_codec.h" @@ -576,7 +578,6 @@ void audiohw_set_depth_3d(int val); void audiohw_set_filter_roll_off(int val); #endif - void audiohw_set_frequency(int fsel); #ifdef HAVE_RECORDING diff --git a/firmware/export/audiohw_settings.h b/firmware/export/audiohw_settings.h index 675ec59a7b..f9610421e8 100644 --- a/firmware/export/audiohw_settings.h +++ b/firmware/export/audiohw_settings.h @@ -113,6 +113,9 @@ AUDIOHW_SETTINGS( #if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF) AUDIOHW_SETTING_ENT(FILTER_ROLL_OFF, sound_set_filter_roll_off) #endif +#if defined(AUDIOHW_HAVE_FUNCTIONAL_MODE) + AUDIOHW_SETTING_ENT(FUNCTIONAL_MODE, sound_set_functional_mode) +#endif /* Hardware EQ tone controls */ #if defined(AUDIOHW_HAVE_EQ) AUDIOHW_SETTING_ENT(EQ_BAND1_GAIN, sound_set_hw_eq_band1_gain) diff --git a/firmware/export/config.h b/firmware/export/config.h index e362000c18..b7a355ce54 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -82,6 +82,7 @@ #define S5L8701 8701 #define S5L8702 8702 #define JZ4732 4732 +#define JZ4760B 47602 #define AS3525 3525 #define AT91SAM9260 9260 #define AS3525v2 35252 @@ -162,11 +163,12 @@ #define CREATIVE_ZEN_PAD 58 #define SAMSUNG_YPZ5_PAD 59 #define IHIFI_PAD 60 -#define SAMSUNG_YPR1_PAD 61 +#define SAMSUNG_YPR1_PAD 61 #define SAMSUNG_YH92X_PAD 62 #define DX50_PAD 63 #define SONY_NWZA860_PAD 64 /* The NWZ-A860 is too different (touchscreen) */ -#define AGPTEK_ROCKER_PAD 65 +#define AGPTEK_ROCKER_PAD 65 +#define XDUOO_X3_PAD 66 /* CONFIG_POWER_SAVE combinable bit flags*/ #define POWERSV_CPU 0x1 @@ -287,6 +289,7 @@ #define LCD_SAMSUNGYPR1 62 /* as used by Samsung YP-R1 */ #define LCD_NWZ_LINUX 63 /* as used in the Linux-based NWZ series */ #define LCD_INGENIC_LINUX 64 +#define LCD_XDUOOX3 65 /* as used by the xDuoo X3 */ /* LCD_PIXELFORMAT */ #define HORIZONTAL_PACKING 1 @@ -358,12 +361,13 @@ Lyre prototype 1 */ #define RTC_MC13783 13 /* Freescale MC13783 PMIC */ #define RTC_S5L8700 14 #define RTC_S35390A 15 -#define RTC_JZ47XX 16 /* Ingenic Jz47XX */ +#define RTC_JZ4740 16 /* Ingenic Jz4740 */ #define RTC_NANO2G 17 /* This seems to be a PCF5063x */ #define RTC_D2 18 /* Either PCF50606 or PCF50635 */ #define RTC_S35380A 19 #define RTC_IMX233 20 #define RTC_STM41T62 21 /* ST M41T62 */ +#define RTC_JZ4760 22 /* Ingenic Jz4760 */ /* USB On-the-go */ #define USBOTG_M66591 6591 /* M:Robe 500 */ @@ -372,6 +376,7 @@ Lyre prototype 1 */ #define USBOTG_M5636 5636 /* iAudio X5 */ #define USBOTG_ARC 5020 /* PortalPlayer 502x and IMX233 */ #define USBOTG_JZ4740 4740 /* Ingenic Jz4740/Jz4732 */ +#define USBOTG_JZ4760 4760 /* Ingenic Jz4760/Jz4760B */ #define USBOTG_AS3525 3525 /* AMS AS3525 */ #define USBOTG_S3C6400X 6400 /* Samsung S3C6400X, also used in the S5L8701/S5L8702/S5L8720 */ #define USBOTG_DESIGNWARE 6401 /* Synopsys DesignWare OTG, used in S5L8701/S5L8702/S5L8720/AS3252v2 */ @@ -612,6 +617,8 @@ Lyre prototype 1 */ #include "config/sonynwze350.h" #elif defined(AGPTEK_ROCKER) #include "config/agptekrocker.h" +#elif defined(XDUOO_X3) +#include "config/xduoox3.h" #else /* no known platform */ #endif @@ -980,7 +987,7 @@ Lyre prototype 1 */ #endif /* BOOTLOADER */ -#if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) \ +#if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) || (CONFIG_CPU == JZ4760B) \ || (CONFIG_CPU == AS3525) || (CONFIG_CPU == AS3525v2) \ || defined(CPU_S5L870X) || (CONFIG_CPU == S3C2440) \ || defined(APPLICATION) || (CONFIG_CPU == PP5002) \ @@ -1057,14 +1064,14 @@ Lyre prototype 1 */ (CONFIG_CPU == TCC7801) || \ (CONFIG_CPU == IMX233 && !defined(PLUGIN) && !defined(CODEC)) || /* IMX233: core only */ \ defined(CPU_S5L870X)) || /* Samsung S5L8700: core, plugins, codecs */ \ - (CONFIG_CPU == JZ4732 && !defined(PLUGIN) && !defined(CODEC)) /* Jz4740: core only */ + ((CONFIG_CPU == JZ4732 || CONFIG_CPU == JZ4760B) && !defined(PLUGIN) && !defined(CODEC)) /* Jz47XX: core only */ #define ICODE_ATTR __attribute__ ((section(".icode"))) #define ICONST_ATTR __attribute__ ((section(".irodata"))) #define IDATA_ATTR __attribute__ ((section(".idata"))) #define IBSS_ATTR __attribute__ ((section(".ibss"))) #define USE_IRAM #if CONFIG_CPU != SH7034 && (CONFIG_CPU != AS3525 || MEMORYSIZE > 2) \ - && CONFIG_CPU != JZ4732 && CONFIG_CPU != AS3525v2 && CONFIG_CPU != IMX233 + && CONFIG_CPU != JZ4732 && CONFIG_CPU != JZ4760B && CONFIG_CPU != AS3525v2 && CONFIG_CPU != IMX233 #define PLUGIN_USE_IRAM #endif #else @@ -1207,6 +1214,7 @@ Lyre prototype 1 */ #define USB_HAS_BULK #elif (CONFIG_USBOTG == USBOTG_ARC) || \ (CONFIG_USBOTG == USBOTG_JZ4740) || \ + (CONFIG_USBOTG == USBOTG_JZ4760) || \ (CONFIG_USBOTG == USBOTG_M66591) || \ (CONFIG_USBOTG == USBOTG_DESIGNWARE) || \ (CONFIG_USBOTG == USBOTG_AS3525) @@ -1231,7 +1239,8 @@ Lyre prototype 1 */ #if defined(HAVE_BOOTLOADER_USB_MODE) || \ defined(CREATIVE_ZVx) || defined(CPU_TCC77X) || defined(CPU_TCC780X) || \ CONFIG_USBOTG == USBOTG_JZ4740 || CONFIG_USBOTG == USBOTG_AS3525 || \ - CONFIG_USBOTG == USBOTG_S3C6400X || CONFIG_USBOTG == USBOTG_DESIGNWARE + CONFIG_USBOTG == USBOTG_S3C6400X || CONFIG_USBOTG == USBOTG_DESIGNWARE || \ + CONFIG_USBOTG == USBOTG_JZ4760 #define USB_ENABLE_STORAGE #endif diff --git a/firmware/export/config/ondavx747.h b/firmware/export/config/ondavx747.h index d02845808f..bf2c47e05c 100644 --- a/firmware/export/config/ondavx747.h +++ b/firmware/export/config/ondavx747.h @@ -91,7 +91,7 @@ #define CONFIG_CODEC SWCODEC /* define this if you have a real-time clock */ -#define CONFIG_RTC RTC_JZ47XX +#define CONFIG_RTC RTC_JZ4740 /* Tuner config */ #define CONFIG_TUNER TEA5767 diff --git a/firmware/export/config/ondavx767.h b/firmware/export/config/ondavx767.h index 77fce1d1a4..3718d202a2 100644 --- a/firmware/export/config/ondavx767.h +++ b/firmware/export/config/ondavx767.h @@ -80,7 +80,7 @@ #define CONFIG_CODEC SWCODEC /* define this if you have a real-time clock */ -#define CONFIG_RTC RTC_JZ47XX +#define CONFIG_RTC RTC_JZ4740 /* Define this for LCD backlight available */ #define HAVE_BACKLIGHT diff --git a/firmware/export/config/ondavx777.h b/firmware/export/config/ondavx777.h index 404d193d4a..17e3eda165 100644 --- a/firmware/export/config/ondavx777.h +++ b/firmware/export/config/ondavx777.h @@ -85,7 +85,7 @@ #define CONFIG_CODEC SWCODEC /* define this if you have a real-time clock */ -#define CONFIG_RTC RTC_JZ47XX +#define CONFIG_RTC RTC_JZ4740 /* Tuner config */ #define CONFIG_TUNER TEA5767 diff --git a/firmware/export/config/xduoox3.h b/firmware/export/config/xduoox3.h new file mode 100644 index 0000000000..3262917d2c --- /dev/null +++ b/firmware/export/config/xduoox3.h @@ -0,0 +1,195 @@ +/* + * This config file is for xDuoo X3 + */ + +#define MODEL_NAME "xDuoo X3" +#define MODEL_NUMBER 106 + +/* Offset ( in the firmware file's header ) to the file CRC */ +#define FIRMWARE_OFFSET_FILE_CRC 0 + +/* Offset ( in the firmware file's header ) to the real data */ +#define FIRMWARE_OFFSET_FILE_DATA 8 + +/* Support FAT16 for SD cards <= 2GB */ +#define HAVE_FAT16SUPPORT + +/* ChinaChip NAND FTL */ +#define CONFIG_NAND NAND_CC + +/* define this if you have a bitmap LCD display */ +#define HAVE_LCD_BITMAP + +/* define this if you have access to the quickscreen */ +#define HAVE_QUICKSCREEN + +/* define this if you would like tagcache to build on this target */ +#define HAVE_TAGCACHE + +/* define this if the target has volume keys which can be used in the lists */ +#define HAVE_VOLUME_IN_LIST + +/* LCD dimensions */ +#define LCD_WIDTH 128 +#define LCD_HEIGHT 64 +/* sqrt(128^2 + 64^2) / 1.0 = 143.1 */ +#define LCD_DPI 143 +#define LCD_DEPTH 1 + +#define LCD_PIXELFORMAT VERTICAL_PACKING +#define HAVE_NEGATIVE_LCD /* bright on dark */ + +/* Display colours, for screenshots and sim (0xRRGGBB) */ +#define LCD_DARKCOLOR 0x000000 +#define LCD_BRIGHTCOLOR 0x000000 +#define LCD_BL_DARKCOLOR 0x000000 +#define LCD_BL_BRIGHTCOLOR 0x0de2e5 + +/* define this if you have LCD enable function */ +#define HAVE_LCD_ENABLE + +#ifndef BOOTLOADER +/* Define this if your LCD can be put to sleep. + * HAVE_LCD_ENABLE should be defined as well. */ +#define HAVE_LCD_SLEEP +#define HAVE_LCD_SLEEP_SETTING +#endif + +/* define this if you can flip your LCD */ +#define HAVE_LCD_FLIP + +/* define this if you can invert the pixels */ +#define HAVE_LCD_INVERT + +/* Define this for LCD backlight available */ +#define HAVE_BACKLIGHT +#define HAVE_BACKLIGHT_BRIGHTNESS + +/* Which backlight fading type? */ +#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING + +#define IRAM_LCDFRAMEBUFFER IDATA_ATTR /* put the lcd frame buffer in IRAM */ + +/* Define this if you can detect headphones */ +#define HAVE_HEADPHONE_DETECTION + +#define CONFIG_KEYPAD XDUOO_X3_PAD + +/* Define this if a programmable hotkey is mapped */ +#define HAVE_HOTKEY + +/* Define this if you do software codec */ +#define CONFIG_CODEC SWCODEC + +/* Define this for LCD backlight available */ +#define HAVE_BACKLIGHT + +#ifndef BOOTLOADER +/* define this if you have a real-time clock */ +#define CONFIG_RTC RTC_JZ4760 +#endif + +/* Define this if you have a software controlled poweroff */ +#define HAVE_SW_POWEROFF + +/* The number of bytes reserved for loadable codecs */ +#define CODEC_SIZE 0x100000 + +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0x100000 + +#define HAVE_CS4398 +#define CODEC_SLAVE + +/* has no tone controls, so we use the software ones */ +#define HAVE_SW_TONE_CONTROLS + +/* define the bitmask of hardware sample rates */ +#define HW_SAMPR_CAPS SAMPR_CAP_ALL + +#define AB_REPEAT_ENABLE + +#define BATTERY_CAPACITY_DEFAULT 2000 /* default battery capacity */ +#define BATTERY_CAPACITY_MIN 500 /* min. capacity selectable */ +#define BATTERY_CAPACITY_MAX 2000 /* max. capacity selectable */ +#define BATTERY_CAPACITY_INC 100 /* capacity increment */ +#define BATTERY_TYPES_COUNT 1 /* only one type */ + +#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE + +/* Hardware controlled charging with monitoring */ +#define CONFIG_CHARGING CHARGING_MONITOR + +/* There is only USB charging */ +#define HAVE_USB_POWER + +#define CFG_EXTAL 12000000 /* EXT clock: 12 Mhz */ + +/* define this if the flash memory uses the SecureDigital Memory Card protocol */ +#define CONFIG_STORAGE (STORAGE_SD /* | STORAGE_NAND */) + +#define HAVE_MULTIDRIVE +#define NUM_DRIVES 2 + +/* Define this if media can be exchanged on the fly */ +#ifndef BOOTLOADER +#define HAVE_HOTSWAP +#define HAVE_HOTSWAP_STORAGE_AS_MAIN +#endif + +/* define this if you have a flash memory storage */ +#define HAVE_FLASH_STORAGE + +/** Non-simulator section **/ +#ifndef SIMULATOR + +/* Define this if you have a Ingenic JZ4760B */ +#define CONFIG_CPU JZ4760B + +/* Define this to the CPU frequency */ +#define CPU_FREQ 492000000 /* CPU clock: 492 MHz */ + +/* Define this if you want to use the JZ47XX i2c interface */ +#define CONFIG_I2C I2C_JZ47XX + +#define NEED_ADC_CLOSE 1 + +/* define this if the hardware can be powered off while charging */ +/* #define HAVE_POWEROFF_WHILE_CHARGING */ + +/* Type of LCD */ +#define CONFIG_LCD LCD_XDUOOX3 + +/* USB On-the-go */ +#define CONFIG_USBOTG USBOTG_JZ4760 + +/* enable these for the experimental usb stack */ +#define HAVE_USBSTACK + +/* Connect by events, not by tick polling */ +#define USB_STATUS_BY_EVENT + +#define USB_VENDOR_ID 0x0525 +#define USB_PRODUCT_ID 0xA4A5 + +#define USB_NUM_ENDPOINTS 3 +#define USB_DEVBSS_ATTR IBSS_ATTR + +#define BOOTFILE_EXT "x3" +#define BOOTFILE "rockbox." BOOTFILE_EXT +#define BOOTDIR "/.rockbox" + +#define INCLUDE_TIMEOUT_API + +#define ICODE_ATTR_TREMOR_NOT_MDCT + +#endif /* SIMULATOR */ + +/** Port-specific settings **/ + +#define CONFIG_SDRAM_START 0x80004000 + +/* Main LCD backlight brightness range and defaults */ +#define MIN_BRIGHTNESS_SETTING 1 +#define MAX_BRIGHTNESS_SETTING 16 +#define DEFAULT_BRIGHTNESS_SETTING 16 /* "full brightness" */ diff --git a/firmware/export/cpu.h b/firmware/export/cpu.h index 7405319822..201ffba656 100644 --- a/firmware/export/cpu.h +++ b/firmware/export/cpu.h @@ -68,6 +68,9 @@ #if CONFIG_CPU == JZ4732 #include "jz4740.h" #endif +#if CONFIG_CPU == JZ4760B +#include "jz4760b.h" +#endif #if CONFIG_CPU == AS3525 #include "as3525.h" #endif diff --git a/firmware/export/cs4398.h b/firmware/export/cs4398.h new file mode 100644 index 0000000000..99dce6b7fa --- /dev/null +++ b/firmware/export/cs4398.h @@ -0,0 +1,116 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _CS4398_H +#define _CS4398_H + +#define CS4398_VOLUME_MIN -1270 +#define CS4398_VOLUME_MAX 0 + +#define AUDIOHW_CAPS (FILTER_ROLL_OFF_CAP | LINEOUT_CAP) +AUDIOHW_SETTING(VOLUME, "dB", 0, 1, CS4398_VOLUME_MIN/10, CS4398_VOLUME_MAX/10, 0) +AUDIOHW_SETTING(FILTER_ROLL_OFF, "", 0, 1, 0, 1, 0) + +void cs4398_write_reg(uint8_t reg, uint8_t val); +uint8_t cs4398_read_reg(uint8_t reg); + +#define CS4398_I2C_ADDR 0x4f /* 1001111 */ + +#define CS4398_REG_CHIPID 0x01 +#define CS4398_REG_MODECTL 0x02 +#define CS4398_REG_VOLMIX 0x03 +#define CS4398_REG_MUTE 0x04 +#define CS4398_REG_VOL_A 0x05 +#define CS4398_REG_VOL_B 0x06 +#define CS4398_REG_RAMPFILT 0x07 +#define CS4398_REG_MISC 0x08 +#define CS4398_REG_MISC2 0x09 + +/* REG_CHIPID */ +#define CS4398_REV_MASK 0x07 +#define CS4398_PART_MASK 0xf8 +#define CS4398_PART_CS4398 0x70 +/* REG_MODECTL */ +#define CS4398_FM_MASK 0x03 +#define CS4398_FM_SINGLE 0x00 +#define CS4398_FM_DOUBLE 0x01 +#define CS4398_FM_QUAD 0x02 +#define CS4398_FM_DSD 0x03 +#define CS4398_DEM_MASK 0x0c +#define CS4398_DEM_NONE 0x00 +#define CS4398_DEM_44100 0x04 +#define CS4398_DEM_48000 0x08 +#define CS4398_DEM_32000 0x0c +#define CS4398_DIF_MASK 0x70 +#define CS4398_DIF_LJUST 0x00 +#define CS4398_DIF_I2S 0x10 +#define CS4398_DIF_RJUST_16 0x20 +#define CS4398_DIF_RJUST_24 0x30 +#define CS4398_DIF_RJUST_20 0x40 +#define CS4398_DIF_RJUST_18 0x50 +#define CS4398_DSD_SRC 0x80 +/* REG_VOLMIX */ +#define CS4398_ATAPI_MASK 0x1f +#define CS4398_ATAPI_B_MUTE 0x00 +#define CS4398_ATAPI_B_R 0x01 +#define CS4398_ATAPI_B_L 0x02 +#define CS4398_ATAPI_B_LR 0x03 +#define CS4398_ATAPI_A_MUTE 0x00 +#define CS4398_ATAPI_A_R 0x04 +#define CS4398_ATAPI_A_L 0x08 +#define CS4398_ATAPI_A_LR 0x0c +#define CS4398_ATAPI_MIX_LR_VOL 0x10 +#define CS4398_INVERT_B 0x20 +#define CS4398_INVERT_A 0x40 +#define CS4398_VOL_B_EQ_A 0x80 +/* REG_MUTE */ +#define CS4398_MUTEP_MASK 0x03 +#define CS4398_MUTEP_AUTO 0x00 +#define CS4398_MUTEP_LOW 0x02 +#define CS4398_MUTEP_HIGH 0x03 +#define CS4398_MUTE_B 0x08 +#define CS4398_MUTE_A 0x10 +#define CS4398_MUTEC_A_EQ_B 0x20 +#define CS4398_DAMUTE 0x40 +#define CS4398_PAMUTE 0x80 +/* REG_VOL_A */ +#define CS4398_VOL_A_MASK 0xff +/* REG_VOL_B */ +#define CS4398_VOL_B_MASK 0xff +/* REG_RAMPFILT */ +#define CS4398_DIR_DSD 0x01 +#define CS4398_FILT_SEL 0x04 +#define CS4398_RMP_DN 0x10 +#define CS4398_RMP_UP 0x20 +#define CS4398_ZERO_CROSS 0x40 +#define CS4398_SOFT_RAMP 0x80 +/* REG_MISC */ +#define CS4398_MCLKDIV3 0x08 +#define CS4398_MCLKDIV2 0x10 +#define CS4398_FREEZE 0x20 +#define CS4398_CPEN 0x40 +#define CS4398_PDN 0x80 +/* REG_MISC2 */ +#define CS4398_DSD_PM_EN 0x01 +#define CS4398_DSD_PM_MODE 0x02 +#define CS4398_INVALID_DSD 0x04 +#define CS4398_STATIC_DSD 0x08 + +#endif diff --git a/firmware/export/jz4760b.h b/firmware/export/jz4760b.h new file mode 100644 index 0000000000..c523cc64c9 --- /dev/null +++ b/firmware/export/jz4760b.h @@ -0,0 +1,9643 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * Copyright (C) 2008 Ingenic Semiconductor Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* + * jz4760b.h + * + * JZ4760B common definition. + * + * Copyright (C) 2008 Ingenic Semiconductor Inc. + * + * Author: + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __JZ4760B_H__ +#define __JZ4760B_H__ + +#if defined(__ASSEMBLY__) || defined(__LANGUAGE_ASSEMBLY) + #ifndef __MIPS_ASSEMBLER + #define __MIPS_ASSEMBLER + #endif + #define REG8(addr) (addr) + #define REG16(addr) (addr) + #define REG32(addr) (addr) +#else + typedef unsigned char u8; + typedef unsigned short u16; + typedef unsigned int u32; + + #define REG8(addr) *((volatile unsigned char *)(addr)) + #define REG16(addr) *((volatile unsigned short *)(addr)) + #define REG32(addr) *((volatile unsigned int *)(addr)) + + #define INREG8(x) ((unsigned char)(*(volatile unsigned char *)(x))) + #define OUTREG8(x, y) *(volatile unsigned char *)(x) = (y) + #define SETREG8(x, y) OUTREG8(x, INREG8(x)|(y)) + #define CLRREG8(x, y) OUTREG8(x, INREG8(x)&~(y)) + #define CMSREG8(x, y, m) OUTREG8(x, (INREG8(x)&~(m))|(y)) + + #define INREG16(x) ((unsigned short)(*(volatile unsigned short *)(x))) + #define OUTREG16(x, y) *(volatile unsigned short *)(x) = (y) + #define SETREG16(x, y) OUTREG16(x, INREG16(x)|(y)) + #define CLRREG16(x, y) OUTREG16(x, INREG16(x)&~(y)) + #define CMSREG16(x, y, m) OUTREG16(x, (INREG16(x)&~(m))|(y)) + + #define INREG32(x) ((unsigned int)(*(volatile unsigned int *)(x))) + #define OUTREG32(x, y) *(volatile unsigned int *)(x) = (y) + #define SETREG32(x, y) OUTREG32(x, INREG32(x)|(y)) + #define CLRREG32(x, y) OUTREG32(x, INREG32(x)&~(y)) + #define CMSREG32(x, y, m) OUTREG32(x, (INREG32(x)&~(m))|(y)) +#endif + +/* + * Define the bit field macro to avoid the bit mistake + */ +#define BIT0 (1 << 0) +#define BIT1 (1 << 1) +#define BIT2 (1 << 2) +#define BIT3 (1 << 3) +#define BIT4 (1 << 4) +#define BIT5 (1 << 5) +#define BIT6 (1 << 6) +#define BIT7 (1 << 7) +#define BIT8 (1 << 8) +#define BIT9 (1 << 9) +#define BIT10 (1 << 10) +#define BIT11 (1 << 11) +#define BIT12 (1 << 12) +#define BIT13 (1 << 13) +#define BIT14 (1 << 14) +#define BIT15 (1 << 15) +#define BIT16 (1 << 16) +#define BIT17 (1 << 17) +#define BIT18 (1 << 18) +#define BIT19 (1 << 19) +#define BIT20 (1 << 20) +#define BIT21 (1 << 21) +#define BIT22 (1 << 22) +#define BIT23 (1 << 23) +#define BIT24 (1 << 24) +#define BIT25 (1 << 25) +#define BIT26 (1 << 26) +#define BIT27 (1 << 27) +#define BIT28 (1 << 28) +#define BIT29 (1 << 29) +#define BIT30 (1 << 30) +#define BIT31 (1 << 31) + +/* Generate the bit field mask from msb to lsb */ +#define BITS_H2L(msb, lsb) ((0xFFFFFFFF >> (32-((msb)-(lsb)+1))) << (lsb)) + +/* Get the bit field value from the data which is read from the register */ +#define get_bf_value(data, lsb, mask) (((data) & (mask)) >> (lsb)) + +/* + * Define the module base addresses + */ +/* AHB0 BUS Devices Base */ +#define HARB0_BASE 0xB3000000 +/* AHB1 BUS Devices Base */ +#define HARB1_BASE 0xB3200000 +#define DMAGP0_BASE 0xB3210000 +#define DMAGP1_BASE 0xB3220000 +#define DMAGP2_BASE 0xB3230000 +#define DEBLK_BASE 0xB3270000 +#define IDCT_BASE 0xB3280000 +#define CABAC_BASE 0xB3290000 +#define TCSM0_BASE 0xB32B0000 +#define TCSM1_BASE 0xB32C0000 +#define SRAM_BASE 0xB32D0000 +/* AHB2 BUS Devices Base */ +#define HARB2_BASE 0xB3400000 +#define UHC_BASE 0xB3430000 +#define GPS_BASE 0xB3480000 +#define ETHC_BASE 0xB34B0000 +/* APB BUS Devices Base */ +#define PS2_BASE 0xB0060000 + +/* + * General purpose I/O port module(GPIO) address definition + */ +#define GPIO_BASE 0xb0010000 + +/* GPIO group offset */ +#define GPIO_GOS 0x100 + +/* Each group address */ +#define GPIO_BASEA (GPIO_BASE + (0) * GPIO_GOS) +#define GPIO_BASEB (GPIO_BASE + (1) * GPIO_GOS) +#define GPIO_BASEC (GPIO_BASE + (2) * GPIO_GOS) +#define GPIO_BASED (GPIO_BASE + (3) * GPIO_GOS) +#define GPIO_BASEE (GPIO_BASE + (4) * GPIO_GOS) +#define GPIO_BASEF (GPIO_BASE + (5) * GPIO_GOS) + +/* + * GPIO registers offset address definition + */ +#define GPIO_PXPIN_OFFSET (0x00) /* r, 32, 0x00000000 */ +#define GPIO_PXDAT_OFFSET (0x10) /* r, 32, 0x00000000 */ +#define GPIO_PXDATS_OFFSET (0x14) /* w, 32, 0x???????? */ +#define GPIO_PXDATC_OFFSET (0x18) /* w, 32, 0x???????? */ +#define GPIO_PXIM_OFFSET (0x20) /* r, 32, 0xffffffff */ +#define GPIO_PXIMS_OFFSET (0x24) /* w, 32, 0x???????? */ +#define GPIO_PXIMC_OFFSET (0x28) /* w, 32, 0x???????? */ +#define GPIO_PXPE_OFFSET (0x30) /* r, 32, 0x00000000 */ +#define GPIO_PXPES_OFFSET (0x34) /* w, 32, 0x???????? */ +#define GPIO_PXPEC_OFFSET (0x38) /* w, 32, 0x???????? */ +#define GPIO_PXFUN_OFFSET (0x40) /* r, 32, 0x00000000 */ +#define GPIO_PXFUNS_OFFSET (0x44) /* w, 32, 0x???????? */ +#define GPIO_PXFUNC_OFFSET (0x48) /* w, 32, 0x???????? */ +#define GPIO_PXSEL_OFFSET (0x50) /* r, 32, 0x00000000 */ +#define GPIO_PXSELS_OFFSET (0x54) /* w, 32, 0x???????? */ +#define GPIO_PXSELC_OFFSET (0x58) /* w, 32, 0x???????? */ +#define GPIO_PXDIR_OFFSET (0x60) /* r, 32, 0x00000000 */ +#define GPIO_PXDIRS_OFFSET (0x64) /* w, 32, 0x???????? */ +#define GPIO_PXDIRC_OFFSET (0x68) /* w, 32, 0x???????? */ +#define GPIO_PXTRG_OFFSET (0x70) /* r, 32, 0x00000000 */ +#define GPIO_PXTRGS_OFFSET (0x74) /* w, 32, 0x???????? */ +#define GPIO_PXTRGC_OFFSET (0x78) /* w, 32, 0x???????? */ +#define GPIO_PXFLG_OFFSET (0x80) /* r, 32, 0x00000000 */ +#define GPIO_PXFLGC_OFFSET (GPIO_PXDATS_OFFSET) /* w, 32, 0x???????? */ +#define GPIO_PXDS0_OFFSET (0xC0) /* r, 32, 0x00000000 */ +#define GPIO_PXDS0S_OFFSET (0xC4) /* w, 32, 0x00000000 */ +#define GPIO_PXDS0C_OFFSET (0xC8) /* w, 32, 0x00000000 */ +#define GPIO_PXDS1_OFFSET (0xD0) /* r, 32, 0x00000000 */ +#define GPIO_PXDS1S_OFFSET (0xD4) /* w, 32, 0x00000000 */ +#define GPIO_PXDS1C_OFFSET (0xD8) /* w, 32, 0x00000000 */ +#define GPIO_PXDS2_OFFSET (0xE0) /* r, 32, 0x00000000 */ +#define GPIO_PXDS2S_OFFSET (0xE4) /* w, 32, 0x00000000 */ +#define GPIO_PXDS2C_OFFSET (0xE8) /* w, 32, 0x00000000 */ +#define GPIO_PXSL_OFFSET (0xF0) /* r, 32, 0x00000000 */ +#define GPIO_PXSLS_OFFSET (0xF4) /* w, 32, 0x00000000 */ +#define GPIO_PXSLC_OFFSET (0xF8) /* w, 32, 0x00000000 */ + +/* + * GPIO registers address definition + */ +#define GPIO_PXPIN(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXPIN_OFFSET) +#define GPIO_PXDAT(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDAT_OFFSET) +#define GPIO_PXDATS(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDATS_OFFSET) +#define GPIO_PXDATC(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDATC_OFFSET) +#define GPIO_PXIM(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXIM_OFFSET) +#define GPIO_PXIMS(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXIMS_OFFSET) +#define GPIO_PXIMC(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXIMC_OFFSET) +#define GPIO_PXPE(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXPE_OFFSET) +#define GPIO_PXPES(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXPES_OFFSET) +#define GPIO_PXPEC(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXPEC_OFFSET) +#define GPIO_PXFUN(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXFUN_OFFSET) +#define GPIO_PXFUNS(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXFUNS_OFFSET) +#define GPIO_PXFUNC(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXFUNC_OFFSET) +#define GPIO_PXSEL(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXSEL_OFFSET) +#define GPIO_PXSELS(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXSELS_OFFSET) +#define GPIO_PXSELC(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXSELC_OFFSET) +#define GPIO_PXDIR(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDIR_OFFSET) +#define GPIO_PXDIRS(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDIRS_OFFSET) +#define GPIO_PXDIRC(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDIRC_OFFSET) +#define GPIO_PXTRG(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXTRG_OFFSET) +#define GPIO_PXTRGS(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXTRGS_OFFSET) +#define GPIO_PXTRGC(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXTRGC_OFFSET) +#define GPIO_PXFLG(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXFLG_OFFSET) +#define GPIO_PXFLGC(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXFLGC_OFFSET) +#define GPIO_PXDS0(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDS0_OFFSET) +#define GPIO_PXDS0S(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDS0S_OFFSET) +#define GPIO_PXDS0C(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDS0C_OFFSET) +#define GPIO_PXDS1(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDS1_OFFSET) +#define GPIO_PXDS1S(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDS1S_OFFSET) +#define GPIO_PXDS1C(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDS1C_OFFSET) +#define GPIO_PXDS2(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDS2_OFFSET) +#define GPIO_PXDS2S(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDS2S_OFFSET) +#define GPIO_PXDS2C(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXDS2C_OFFSET) +#define GPIO_PXSL(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXSL_OFFSET) +#define GPIO_PXSLS(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXSLS_OFFSET) +#define GPIO_PXSLC(n) (GPIO_BASE + (n)*GPIO_GOS + GPIO_PXSLC_OFFSET) + +/* */ +#define GPIO_PORT_NUM 6 +#define MAX_GPIO_NUM 192 +#define GPIO_WAKEUP (30) + +#ifndef __MIPS_ASSEMBLER + +//n = 0,1,2,3,4,5 (PORTA, PORTB, PORTC, PORTD, PORTE, PORTF) +#define REG_GPIO_PXPIN(n) REG32(GPIO_PXPIN(n)) +#define REG_GPIO_PXDAT(n) REG32(GPIO_PXDAT(n)) +#define REG_GPIO_PXDATS(n) REG32(GPIO_PXDATS(n)) +#define REG_GPIO_PXDATC(n) REG32(GPIO_PXDATC(n)) +#define REG_GPIO_PXIM(n) REG32(GPIO_PXIM(n)) +#define REG_GPIO_PXIMS(n) REG32(GPIO_PXIMS(n)) +#define REG_GPIO_PXIMC(n) REG32(GPIO_PXIMC(n)) +#define REG_GPIO_PXPE(n) REG32(GPIO_PXPE(n)) +#define REG_GPIO_PXPES(n) REG32(GPIO_PXPES(n)) +#define REG_GPIO_PXPEC(n) REG32(GPIO_PXPEC(n)) +#define REG_GPIO_PXFUN(n) REG32(GPIO_PXFUN(n)) +#define REG_GPIO_PXFUNS(n) REG32(GPIO_PXFUNS(n)) +#define REG_GPIO_PXFUNC(n) REG32(GPIO_PXFUNC(n)) +#define REG_GPIO_PXSEL(n) REG32(GPIO_PXSEL(n)) +#define REG_GPIO_PXSELS(n) REG32(GPIO_PXSELS(n)) +#define REG_GPIO_PXSELC(n) REG32(GPIO_PXSELC(n)) +#define REG_GPIO_PXDIR(n) REG32(GPIO_PXDIR(n)) +#define REG_GPIO_PXDIRS(n) REG32(GPIO_PXDIRS(n)) +#define REG_GPIO_PXDIRC(n) REG32(GPIO_PXDIRC(n)) +#define REG_GPIO_PXTRG(n) REG32(GPIO_PXTRG(n)) +#define REG_GPIO_PXTRGS(n) REG32(GPIO_PXTRGS(n)) +#define REG_GPIO_PXTRGC(n) REG32(GPIO_PXTRGC(n)) +#define REG_GPIO_PXFLG(n) REG32(GPIO_PXFLG(n)) +#define REG_GPIO_PXFLGC(n) REG32(GPIO_PXFLGC(n)) +#define REG_GPIO_PXDS0(n) REG32(GPIO_PXDS0(n)) +#define REG_GPIO_PXDS0S(n) REG32(GPIO_PXDS0S(n)) +#define REG_GPIO_PXDS0C(n) REG32(GPIO_PXDS0C(n)) +#define REG_GPIO_PXDS1(n) REG32(GPIO_PXDS1(n)) +#define REG_GPIO_PXDS1S(n) REG32(GPIO_PXDS1S(n)) +#define REG_GPIO_PXDS1C(n) REG32(GPIO_PXDS1C(n)) +#define REG_GPIO_PXDS2(n) REG32(GPIO_PXDS2(n)) +#define REG_GPIO_PXDS2S(n) REG32(GPIO_PXDS2S(n)) +#define REG_GPIO_PXDS2C(n) REG32(GPIO_PXDS2C(n)) +#define REG_GPIO_PXSL(n) REG32(GPIO_PXSL(n)) +#define REG_GPIO_PXSLS(n) REG32(GPIO_PXSLS(n)) +#define REG_GPIO_PXSLC(n) REG32(GPIO_PXSLC(n)) + +/*---------------------------------------------------------------- + * p is the port number (0,1,2,3,4,5) + * o is the pin offset (0-31) inside the port + * n is the absolute number of a pin (0-127), regardless of the port + */ + +//---------------------------------------------------------------- +// Function Pins Mode + +#define __gpio_as_func0(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXFUNS(p) = (1 << o); \ + REG_GPIO_PXTRGC(p) = (1 << o); \ + REG_GPIO_PXSELC(p) = (1 << o); \ +} while (0) + +#define __gpio_as_func1(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXFUNS(p) = (1 << o); \ + REG_GPIO_PXTRGC(p) = (1 << o); \ + REG_GPIO_PXSELS(p) = (1 << o); \ +} while (0) + +#define __gpio_as_func2(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXFUNS(p) = (1 << o); \ + REG_GPIO_PXTRGS(p) = (1 << o); \ + REG_GPIO_PXSELC(p) = (1 << o); \ +} while (0) + +#define __gpio_as_func3(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXFUNS(p) = (1 << o); \ + REG_GPIO_PXTRGS(p) = (1 << o); \ + REG_GPIO_PXSELS(p) = (1 << o); \ +} while (0) + +/* + * UART0_TxD, UART0_RxD + */ +#define __gpio_as_uart0() \ +do { \ + unsigned int bits = BIT3 | BIT0; \ + REG_GPIO_PXFUNS(5) = bits; \ + REG_GPIO_PXTRGC(5) = bits; \ + REG_GPIO_PXSELC(5) = bits; \ + REG_GPIO_PXPES(5) = bits; \ +} while (0) + +/* + * UART0_TxD, UART0_RxD, UART0_CTS, UART0_RTS + */ +#define __gpio_as_uart0_ctsrts() \ +do { \ + unsigned int bits = BITS_H2L(3, 0); \ + REG_GPIO_PXFUNS(5) = bits; \ + REG_GPIO_PXTRGC(5) = bits; \ + REG_GPIO_PXSELC(5) = bits; \ + REG_GPIO_PXPES(5) = bits; \ +} while (0) + +/* + * UART1_TxD, UART1_RxD + */ +#define __gpio_as_uart1() \ +do { \ + unsigned int bits = BIT28 | BIT26; \ + REG_GPIO_PXFUNS(3) = bits; \ + REG_GPIO_PXTRGC(3) = bits; \ + REG_GPIO_PXSELC(3) = bits; \ + REG_GPIO_PXPES(3) = bits; \ +} while (0) + +/* + * UART1_TxD, UART1_RxD, UART1_CTS, UART1_RTS + */ +#define __gpio_as_uart1_ctsrts() \ +do { \ + unsigned int bits = BITS_H2L(29, 26); \ + REG_GPIO_PXFUNS(3) = bits; \ + REG_GPIO_PXTRGC(3) = bits; \ + REG_GPIO_PXSELC(3) = bits; \ + REG_GPIO_PXPES(3) = bits; \ +} while (0) + +/* + * UART2_TxD, UART2_RxD + */ +#define __gpio_as_uart2() \ +do { \ + unsigned int bits = BIT30 | BIT28; \ + REG_GPIO_PXFUNS(2) = bits; \ + REG_GPIO_PXTRGC(2) = bits; \ + REG_GPIO_PXSELC(2) = bits; \ + REG_GPIO_PXPES(2) = bits; \ +} while (0) + +/* + * UART2_TxD, UART2_RxD, UART2_CTS, UART2_RTS + */ +#define __gpio_as_uart2_ctsrts() \ +do { \ + unsigned int bits = BITS_H2L(31, 28); \ + REG_GPIO_PXFUNS(2) = bits; \ + REG_GPIO_PXTRGC(2) = bits; \ + REG_GPIO_PXSELC(2) = bits; \ + REG_GPIO_PXPES(2) = bits; \ +} while (0) + +/* WARNING: the folloing macro do NOT check */ +/* + * UART3_TxD, UART3_RxD + */ +#define __gpio_as_uart3() \ +do { \ + unsigned int bits = BIT12; \ + REG_GPIO_PXFUNS(3) = bits; \ + REG_GPIO_PXTRGC(3) = bits; \ + REG_GPIO_PXSELS(3) = bits; \ + REG_GPIO_PXPES(3) = bits; \ + bits = BIT5; \ + REG_GPIO_PXFUNS(4) = bits; \ + REG_GPIO_PXTRGC(4) = bits; \ + REG_GPIO_PXSELS(4) = bits; \ + REG_GPIO_PXPES(4) = bits; \ +} while (0) +/* + * UART3_TxD, UART3_RxD, UART3_CTS, UART3_RTS + */ +#define __gpio_as_uart3_ctsrts() \ +do { \ + REG_GPIO_PXFUNS(3) = (1 << 12); \ + REG_GPIO_PXTRGC(3) = (1 << 12); \ + REG_GPIO_PXSELC(3) = (1 << 12); \ + REG_GPIO_PXPES(3) = (1 << 12); \ + REG_GPIO_PXFUNS(4) = 0x00000320; \ + REG_GPIO_PXTRGC(4) = 0x00000320; \ + REG_GPIO_PXSELS(4) = 0x00000020; \ + REG_GPIO_PXSELC(4) = 0x00000300; \ + REG_GPIO_PXPES(4) = 0x00000320; \ +} while (0) + +/* + * SD0 ~ SD7, CS1#, CLE, ALE, FRE#, FWE#, FRB# + * @n: chip select number(1 ~ 6) + */ +#define __gpio_as_nand_8bit(n) \ +do { \ + \ + REG_GPIO_PXFUNS(0) = 0x000c00ff; /* SD0 ~ SD7, FRE#, FWE# */ \ + REG_GPIO_PXSELC(0) = 0x000c00ff; \ + REG_GPIO_PXTRGC(0) = 0x000c00ff; \ + REG_GPIO_PXPES(0) = 0x000c00ff; \ + REG_GPIO_PXFUNS(1) = 0x00000003; /* CLE(SA0_CL), ALE(SA1_AL) */ \ + REG_GPIO_PXSELC(1) = 0x00000003; \ + REG_GPIO_PXTRGC(1) = 0x00000003; \ + REG_GPIO_PXPES(1) = 0x00000003; \ + \ + REG_GPIO_PXFUNS(0) = 0x00200000 << ((n)-1); /* CSn */ \ + REG_GPIO_PXSELC(0) = 0x00200000 << ((n)-1); \ + REG_GPIO_PXTRGC(0) = 0x00200000 << ((n)-1); \ + REG_GPIO_PXPES(0) = 0x00200000 << ((n)-1); \ + \ + REG_GPIO_PXFUNC(0) = 0x00100000; /* FRB#(input) */ \ + REG_GPIO_PXSELC(0) = 0x00100000; \ + REG_GPIO_PXDIRC(0) = 0x00100000; \ + REG_GPIO_PXPES(0) = 0x00100000; \ +} while (0) + +#define __gpio_as_nand_16bit(n) \ +do { \ + \ + REG_GPIO_PXFUNS(0) = 0x000cffff; /* SD0 ~ SD15, CS1#, FRE#, FWE# */ \ + REG_GPIO_PXSELC(0) = 0x000cffff; \ + REG_GPIO_PXTRGC(0) = 0x000cffff; \ + REG_GPIO_PXPES(0) = 0x000cffff; \ + REG_GPIO_PXFUNS(1) = 0x00000003; /* CLE(SA2), ALE(SA3) */ \ + REG_GPIO_PXSELC(1) = 0x00000003; \ + REG_GPIO_PXTRGC(1) = 0x00000003; \ + REG_GPIO_PXPES(1) = 0x00000003; \ + \ + REG_GPIO_PXFUNS(0) = 0x00200000 << ((n)-1); /* CSn */ \ + REG_GPIO_PXSELC(0) = 0x00200000 << ((n)-1); \ + REG_GPIO_PXTRGC(0) = 0x00200000 << ((n)-1); \ + REG_GPIO_PXPES(0) = 0x00200000 << ((n)-1); \ + \ + REG_GPIO_PXFUNC(0) = 0x00100000; /* FRB#(input) */ \ + REG_GPIO_PXSELC(0) = 0x00100000; \ + REG_GPIO_PXDIRC(0) = 0x00100000; \ + REG_GPIO_PXPES(0) = 0x00100000; \ +} while (0) + +/* + * SLCD + */ +#define __gpio_as_slcd_16bit() \ +do { \ + REG_GPIO_PXFUNS(2) = 0x03cff0fc; \ + REG_GPIO_PXTRGC(2) = 0x03cff0fc; \ + REG_GPIO_PXSELC(2) = 0x03cff0fc; \ + REG_GPIO_PXPES(2) = 0x03cff0fc; \ +} while (0) + +/* + * LCD_R3~LCD_R7, LCD_G2~LCD_G7, LCD_B3~LCD_B7, + * LCD_PCLK, LCD_HSYNC, LCD_VSYNC, LCD_DE + */ +#define __gpio_as_lcd_16bit() \ +do { \ + REG_GPIO_PXFUNS(2) = 0x0f8ff3f8; \ + REG_GPIO_PXTRGC(2) = 0x0f8ff3f8; \ + REG_GPIO_PXSELC(2) = 0x0f8ff3f8; \ + REG_GPIO_PXPES(2) = 0x0f8ff3f8; \ +} while (0) + +/* + * LCD_R2~LCD_R7, LCD_G2~LCD_G7, LCD_B2~LCD_B7, + * LCD_PCLK, LCD_HSYNC, LCD_VSYNC, LCD_DE + */ +#define __gpio_as_lcd_18bit() \ +do { \ + REG_GPIO_PXFUNS(2) = 0x0fcff3fc; \ + REG_GPIO_PXTRGC(2) = 0x0fcff3fc; \ + REG_GPIO_PXSELC(2) = 0x0fcff3fc; \ + REG_GPIO_PXPES(2) = 0x0fcff3fc; \ +} while (0) + +/* + * LCD_R0~LCD_R7, LCD_G0~LCD_G7, LCD_B0~LCD_B7, + * LCD_PCLK, LCD_HSYNC, LCD_VSYNC, LCD_DE + */ +#define __gpio_as_lcd_24bit() \ +do { \ + REG_GPIO_PXFUNS(2) = 0x0fffffff; \ + REG_GPIO_PXTRGC(2) = 0x0fffffff; \ + REG_GPIO_PXSELC(2) = 0x0fffffff; \ + REG_GPIO_PXPES(2) = 0x0fffffff; \ +} while (0) + +/* + * LCD_R0~LCD_R7, LCD_G0~LCD_G7, LCD_B0~LCD_B7, + * LCD_PCLK, LCD_HSYNC, LCD_VSYNC, LCD_DE + */ +#define __gpio_clear_lcd_24bit() \ +do { \ + REG_GPIO_PXFUNC(2) = 0x0fffffff; \ + REG_GPIO_PXTRGC(2) = 0x0fffffff; \ + REG_GPIO_PXSELC(2) = 0x0fffffff; \ + REG_GPIO_PXDIRS(2) = 0x0fffffff; \ + REG_GPIO_PXDATC(2) = 0x0fffffff; \ + REG_GPIO_PXPES(2) = 0x0fffffff; \ +} while (0) + +/* Set data pin driver strength v: 0~7 */ +#define __gpio_set_lcd_data_driving_strength(v) \ +do { \ + unsigned int d; \ + d = v & 0x1; \ + if(d) REG_GPIO_PXDS0S(2) = 0x0ff3fcff; \ + else REG_GPIO_PXDS0C(2) = 0x0ff3fcff; \ + d = v & 0x2; \ + if(d) REG_GPIO_PXDS1S(2) = 0x0ff3fcff; \ + else REG_GPIO_PXDS1C(2) = 0x0ff3fcff; \ + d = v & 0x4; \ + if(d) REG_GPIO_PXDS2S(2) = 0x0ff3fcff; \ + else REG_GPIO_PXDS2C(2) = 0x0ff3fcff; \ +} while(0) +/* Set HSYNC VSYNC DE driver strength v: 0~7 */ +#define __gpio_set_lcd_sync_driving_strength(v) \ +do { \ + unsigned int d; \ + d = v & 0x1; \ + if(d) REG_GPIO_PXDS0S(2) = 0x000c0200; \ + else REG_GPIO_PXDS0C(2) = 0x000c0200; \ + d = v & 0x2; \ + if(d) REG_GPIO_PXDS1S(2) = 0x000c0200; \ + else REG_GPIO_PXDS1C(2) = 0x000c0200; \ + d = v & 0x4; \ + if(d) REG_GPIO_PXDS2S(2) = 0x000c0200; \ + else REG_GPIO_PXDS2C(2) = 0x000c0200; \ +} while(0) +/* Set PCLK driver strength v: 0~7 */ +#define __gpio_set_lcd_clk_driving_strength(v) \ +do { \ + unsigned int d; \ + d = v & 0x1; \ + if(d) REG_GPIO_PXDS0S(2) = (1 << 8); \ + else REG_GPIO_PXDS0C(2) = (1 << 8); \ + d = v & 0x2; \ + if(d) REG_GPIO_PXDS1S(2) = (1 << 8); \ + else REG_GPIO_PXDS1C(2) = (1 << 8); \ + d = v & 0x4; \ + if(d) REG_GPIO_PXDS2S(2) = (1 << 8); \ + else REG_GPIO_PXDS2C(2) = (1 << 8); \ +} while(0) + +/* Set fast slew rate */ +#define __gpio_set_lcd_data_fslew(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXSLS(p) = 0x0ff3fcff; \ +} while(0) + +/* Set slow slew rate */ +#define __gpio_set_lcd_data_sslew(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXSLC(p) = 0x0ff3fcff; \ +} while(0) + +/* Set fast slew rate */ +#define __gpio_set_lcd_sync_fslew(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXSLS(p) = 0x000c0200; \ +} while(0) + +/* Set slow slew rate */ +#define __gpio_set_lcd_sync_sslew(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXSLC(p) = 0x000c0200; \ +} while(0) + +/* Set fast slew rate */ +#define __gpio_set_lcd_pclk_fslew(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXSLS(p) = (1 << 8); \ +} while(0) + +/* Set slow slew rate */ +#define __gpio_set_lcd_pclk_sslew(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXSLC(p) = (1 << 8); \ +} while(0) + +/* + * LCD_CLS, LCD_SPL, LCD_PS, LCD_REV + */ +#define __gpio_as_lcd_special() \ +do { \ + REG_GPIO_PXFUNS(2) = 0x0fffffff; \ + REG_GPIO_PXTRGC(2) = 0x0fffffff; \ + REG_GPIO_PXSELC(2) = 0x0feffbfc; \ + REG_GPIO_PXSELS(2) = 0x00100403; \ + REG_GPIO_PXPES(2) = 0x0fffffff; \ +} while (0) + +#define __gpio_as_epd() \ +do { \ + REG_GPIO_PXFUNS(1) = 0x00011e00; \ + REG_GPIO_PXTRGS(1) = 0x00011e00; \ + REG_GPIO_PXSELS(1) = 0x00011e00; \ + REG_GPIO_PXPES(1) = 0x00011e00; \ +} while (0) +/* + * CIM_D0~CIM_D7, CIM_MCLK, CIM_PCLK, CIM_VSYNC, CIM_HSYNC + */ +#define __gpio_as_cim() \ +do { \ + REG_GPIO_PXFUNS(1) = 0x0003ffc0; \ + REG_GPIO_PXTRGC(1) = 0x0003ffc0; \ + REG_GPIO_PXSELC(1) = 0x0003ffc0; \ + REG_GPIO_PXPES(1) = 0x0003ffc0; \ +} while (0) + +/* + * SDATO, SDATI, BCLK, SYNC, SCLK_RSTN(gpio sepc) or + * SDATA_OUT, SDATA_IN, BIT_CLK, SYNC, SCLK_RESET(aic spec) + */ +#define __gpio_as_aic() \ +do { \ + REG_GPIO_PXFUNS(3) = 0x00003000; \ + REG_GPIO_PXTRGC(3) = 0x00003000; \ + REG_GPIO_PXSELS(3) = 0x00001000; \ + REG_GPIO_PXSELC(3) = 0x00002000; \ + REG_GPIO_PXPES(3) = 0x00003000; \ + REG_GPIO_PXFUNS(4) = 0x000000e0; \ + REG_GPIO_PXTRGS(4) = 0x00000020; \ + REG_GPIO_PXTRGC(4) = 0x000000c0; \ + REG_GPIO_PXSELC(4) = 0x000000e0; \ + REG_GPIO_PXPES(4) = 0x000000e0; \ +} while (0) + +#define __gpio_as_spdif() \ +do { \ + REG_GPIO_PXFUNS(3) = 0x00003000; \ + REG_GPIO_PXTRGC(3) = 0x00003000; \ + REG_GPIO_PXSELS(3) = 0x00001000; \ + REG_GPIO_PXSELC(3) = 0x00002000; \ + REG_GPIO_PXPES(3) = 0x00003000; \ + REG_GPIO_PXFUNS(4) = 0x000038e0; \ + REG_GPIO_PXTRGC(4) = 0x000038c0; \ + REG_GPIO_PXTRGS(4) = 0x00000020; \ + REG_GPIO_PXSELC(4) = 0x000038e0; \ + REG_GPIO_PXPES(4) = 0x000038e0; \ +} while (0) + +/* + * MSC0_CMD, MSC0_CLK, MSC0_D0 ~ MSC0_D3 + */ +#define __gpio_as_msc0_pa_4bit() \ +do { \ + REG_GPIO_PXFUNS(0) = 0x00fc0000; \ + REG_GPIO_PXTRGC(0) = 0x00fc0000; \ + REG_GPIO_PXSELS(0) = 0x00ec0000; \ + REG_GPIO_PXSELC(0) = 0x00100000; \ + REG_GPIO_PXPES(0) = 0x00fc0000; \ +} while (0) + +/* + * MSC0_CMD, MSC0_CLK, MSC0_D0 ~ MSC0_D7 + */ +#define __gpio_as_msc0_pe_8bit() \ +do { \ + REG_GPIO_PXFUNS(4) = 0x3ff00000; \ + REG_GPIO_PXTRGC(4) = 0x3ff00000; \ + REG_GPIO_PXSELC(4) = 0x3ff00000; \ + REG_GPIO_PXPES(4) = 0x3ff00000; \ + REG_GPIO_PXDS0S(4) = 0x3ff00000; \ +} while (0) +/* + * MSC0_CMD, MSC0_CLK, MSC0_D0 ~ MSC0_D3 + */ +#define __gpio_as_msc0_pe_4bit() \ +do { \ + REG_GPIO_PXFUNS(4) = 0x30f00000; \ + REG_GPIO_PXTRGC(4) = 0x30f00000; \ + REG_GPIO_PXSELC(4) = 0x30f00000; \ + REG_GPIO_PXPES(4) = 0x30f00000; \ + REG_GPIO_PXDS0S(4) = 0x30f00000; \ +} while (0) + +#define __gpio_as_msc0_boot() \ +do { \ + REG_GPIO_PXFUNS(0) = 0x00ec0000; \ + REG_GPIO_PXTRGC(0) = 0x00ec0000; \ + REG_GPIO_PXSELS(0) = 0x00ec0000; \ + REG_GPIO_PXPES(0) = 0x00ec0000; \ + REG_GPIO_PXFUNS(0) = 0x00100000; \ + REG_GPIO_PXTRGC(0) = 0x00100000; \ + REG_GPIO_PXSELC(0) = 0x00100000; \ + REG_GPIO_PXPES(0) = 0x00100000; \ + \ +} while (0) + +/* + * MSC1_CMD, MSC1_CLK, MSC1_D0 ~ MSC1_D7 + */ +#define __gpio_as_msc1_pe_8bit() \ +do { \ + REG_GPIO_PXFUNS(4) = 0x3ff00000; \ + REG_GPIO_PXTRGC(4) = 0x3ff00000; \ + REG_GPIO_PXSELS(4) = 0x3ff00000; \ + REG_GPIO_PXPES(4) = 0x3ff00000; \ + REG_GPIO_PXDS0S(4) = 0x3ff00000; \ +} while (0) +/* + * MSC1_CMD, MSC1_CLK, MSC1_D0 ~ MSC1_D3 + */ +#define __gpio_as_msc1_pe_4bit() \ +do { \ + REG_GPIO_PXFUNS(4) = 0x30f00000; \ + REG_GPIO_PXTRGC(4) = 0x30f00000; \ + REG_GPIO_PXSELS(4) = 0x30f00000; \ + REG_GPIO_PXPES(4) = 0x30f00000; \ + REG_GPIO_PXDS0S(4) = 0x30f00000; \ +} while (0) + +/* + * MSC1_CMD, MSC1_CLK, MSC1_D0 ~ MSC1_D3 + */ +#define __gpio_as_msc1_pd_4bit() \ +do { \ + REG_GPIO_PXFUNS(3) = 0x03f00000; \ + REG_GPIO_PXTRGC(3) = 0x03f00000; \ + REG_GPIO_PXSELC(3) = 0x03f00000; \ + REG_GPIO_PXPES(3) = 0x03f00000; \ + REG_GPIO_PXDS0S(3) = 0x03f00000; \ +} while (0) + +/* Port B + * MSC2_CMD, MSC2_CLK, MSC2_D0 ~ MSC2_D3 + */ +#define __gpio_as_msc2_pb_4bit() \ +do { \ + REG_GPIO_PXFUNS(1) = 0xf0300000; \ + REG_GPIO_PXTRGC(1) = 0xf0300000; \ + REG_GPIO_PXSELC(1) = 0xf0300000; \ + REG_GPIO_PXPES(1) = 0xf0300000; \ + REG_GPIO_PXDS0S(1) = 0xf0300000; \ +} while (0) + +/* + * MSC2_CMD, MSC2_CLK, MSC2_D0 ~ MSC2_D7 + */ +#define __gpio_as_msc2_pe_8bit() \ +do { \ + REG_GPIO_PXFUNS(4) = 0x3ff00000; \ + REG_GPIO_PXTRGS(4) = 0x3ff00000; \ + REG_GPIO_PXSELC(4) = 0x3ff00000; \ + REG_GPIO_PXPES(4) = 0x3ff00000; \ + REG_GPIO_PXDS0S(4) = 0x3ff00000; \ +} while (0) +/* + * MSC2_CMD, MSC2_CLK, MSC2_D0 ~ MSC2_D3 + */ +#define __gpio_as_msc2_pe_4bit() \ +do { \ + REG_GPIO_PXFUNS(4) = 0x30f00000; \ + REG_GPIO_PXTRGS(4) = 0x30f00000; \ + REG_GPIO_PXSELC(4) = 0x30f00000; \ + REG_GPIO_PXPES(4) = 0x30f00000; \ + REG_GPIO_PXDS0S(4)= 0x30f00000; \ +} while (0) +#define __gpio_as_msc0_4bit __gpio_as_msc0_pe_4bit /* default as msc0 4bit */ +#define __gpio_as_msc1_4bit __gpio_as_msc1_pd_4bit /* msc1 only support 4bit */ +#define __gpio_as_msc __gpio_as_msc0_4bit /* default as msc0 4bit */ +#define __gpio_as_msc0 __gpio_as_msc0_4bit /* msc0 default as 4bit */ +#define __gpio_as_msc1 __gpio_as_msc1_4bit /* msc1 only support 4bit */ +#define __gpio_as_msc0_8bit __gpio_as_msc0_pe_8bit /* default as msc0 8bit */ +#define __gpio_as_msc1_8bit __gpio_as_msc1_pd_8bit /* msc1 only support 8bit */ +/* + * TSCLK, TSSTR, TSFRM, TSFAIL, TSDI0~7 + */ +#define __gpio_as_tssi_1() \ +do { \ + REG_GPIO_PXFUNS(1) = 0x0003ffc0; \ + REG_GPIO_PXTRGC(1) = 0x0003ffc0; \ + REG_GPIO_PXSELS(1) = 0x0003ffc0; \ + REG_GPIO_PXPES(1) = 0x0003ffc0; \ +} while (0) + +/* + * TSCLK, TSSTR, TSFRM, TSFAIL, TSDI0~7 + */ +#define __gpio_as_tssi_2() \ +do { \ + REG_GPIO_PXFUNS(1) = 0xfff00000; \ + REG_GPIO_PXTRGC(1) = 0x0fc00000; \ + REG_GPIO_PXTRGS(1) = 0xf0300000; \ + REG_GPIO_PXSELC(1) = 0xfff00000; \ + REG_GPIO_PXPES(1) = 0xfff00000; \ +} while (0) + +/* + * SSI_CE0, SSI_CE1, SSI_GPC, SSI_CLK, SSI_DT, SSI_DR + */ +#define __gpio_as_ssi() \ +do { \ + REG_GPIO_PXFUNS(0) = 0x002c0000; /* SSI0_CE0, SSI0_CLK, SSI0_DT */ \ + REG_GPIO_PXTRGS(0) = 0x002c0000; \ + REG_GPIO_PXSELC(0) = 0x002c0000; \ + REG_GPIO_PXPES(0) = 0x002c0000; \ + \ + REG_GPIO_PXFUNS(0) = 0x00100000; /* SSI0_DR */ \ + REG_GPIO_PXTRGC(0) = 0x00100000; \ + REG_GPIO_PXSELS(0) = 0x00100000; \ + REG_GPIO_PXPES(0) = 0x00100000; \ +} while (0) + +/* + * SSI_CE0, SSI_CE2, SSI_GPC, SSI_CLK, SSI_DT, SSI1_DR + */ +#define __gpio_as_ssi_1() \ +do { \ + REG_GPIO_PXFUNS(5) = 0x0000fc00; \ + REG_GPIO_PXTRGC(5) = 0x0000fc00; \ + REG_GPIO_PXSELC(5) = 0x0000fc00; \ + REG_GPIO_PXPES(5) = 0x0000fc00; \ +} while (0) + +/* Port B + * SSI2_CE0, SSI2_CE2, SSI2_GPC, SSI2_CLK, SSI2_DT, SSI12_DR + */ +#define __gpio_as_ssi2_1() \ +do { \ + REG_GPIO_PXFUNS(5) = 0xf0300000; \ + REG_GPIO_PXTRGC(5) = 0xf0300000; \ + REG_GPIO_PXSELS(5) = 0xf0300000; \ + REG_GPIO_PXPES(5) = 0xf0300000; \ +} while (0) + +#define __gpio_as_pcm0() \ +do { \ + REG_GPIO_PXFUNS(3) = 0xf; \ + REG_GPIO_PXTRGC(3) = 0xf; \ + REG_GPIO_PXSELC(3) = 0xf; \ + REG_GPIO_PXPES(3) = 0xf; \ +} while (0) + +#define __gpio_as_pcm1() \ +do { \ + REG_GPIO_PXFUNS(3) = 0x1000; \ + REG_GPIO_PXTRGS(3) = 0x1000; \ + REG_GPIO_PXSELC(3) = 0x1000; \ + REG_GPIO_PXPES(3) = 0x1000; \ + REG_GPIO_PXFUNS(4) = 0x1000; \ + REG_GPIO_PXTRGC(4) = 0x300; \ + REG_GPIO_PXTRGS(4) = 0x20; \ + REG_GPIO_PXSELS(4) = 0x320; \ + REG_GPIO_PXPES(4) = 0x320; \ +} while (0) +/* + * I2C_SCK, I2C_SDA + */ +#define __gpio_as_i2c(n) \ +do { \ + REG_GPIO_PXFUNS(3+(n)) = 0xc0000000; \ + REG_GPIO_PXTRGC(3+(n)) = 0xc0000000; \ + REG_GPIO_PXSELC(3+(n)) = 0xc0000000; \ + REG_GPIO_PXPES(3+(n)) = 0xc0000000; \ +} while (0) + +/* + * PWM0 + */ +#define __gpio_as_pwm0() \ +do { \ + REG_GPIO_PXFUNS(4) = 0x1; \ + REG_GPIO_PXTRGC(4) = 0x1; \ + REG_GPIO_PXSELC(4) = 0x1; \ + REG_GPIO_PXPES(4) = 0x1; \ +} while (0) + +/* + * PWM1 + */ +#define __gpio_as_pwm1() \ +do { \ + REG_GPIO_PXFUNS(4) = 0x2; \ + REG_GPIO_PXTRGC(4) = 0x2; \ + REG_GPIO_PXSELC(4) = 0x2; \ + REG_GPIO_PXPEC(4) = 0x2; \ +} while (0) + +/* + * PWM2 + */ +#define __gpio_as_pwm2() \ +do { \ + REG_GPIO_PXFUNS(4) = 0x4; \ + REG_GPIO_PXTRGC(4) = 0x4; \ + REG_GPIO_PXSELC(4) = 0x4; \ + REG_GPIO_PXPES(4) = 0x4; \ +} while (0) + +/* + * PWM3 + */ +#define __gpio_as_pwm3() \ +do { \ + REG_GPIO_PXFUNS(4) = 0x8; \ + REG_GPIO_PXTRGC(4) = 0x8; \ + REG_GPIO_PXSELC(4) = 0x8; \ + REG_GPIO_PXPES(4) = 0x8; \ +} while (0) + +/* + * PWM4 + */ +#define __gpio_as_pwm4() \ +do { \ + REG_GPIO_PXFUNS(4) = 0x10; \ + REG_GPIO_PXTRGC(4) = 0x10; \ + REG_GPIO_PXSELC(4) = 0x10; \ + REG_GPIO_PXPES(4) = 0x10; \ +} while (0) + +/* + * PWM5 + */ +#define __gpio_as_pwm5() \ +do { \ + REG_GPIO_PXFUNS(4) = 0x20; \ + REG_GPIO_PXTRGC(4) = 0x20; \ + REG_GPIO_PXSELC(4) = 0x20; \ + REG_GPIO_PXPES(4) = 0x20; \ +} while (0) + +/* + * n = 0 ~ 5 + */ +#define __gpio_as_pwm(n) __gpio_as_pwm##n() + +/* + * OWI - PA29 function 1 + */ +#define __gpio_as_owi() \ +do { \ + REG_GPIO_PXFUNS(0) = 0x20000000; \ + REG_GPIO_PXTRGC(0) = 0x20000000; \ + REG_GPIO_PXSELS(0) = 0x20000000; \ +} while (0) + +/* + * SCC - PD08 function 0 + * PD09 function 0 + */ +#define __gpio_as_scc() \ +do { \ + REG_GPIO_PXFUNS(3) = 0xc0000300; \ + REG_GPIO_PXTRGC(3) = 0xc0000300; \ + REG_GPIO_PXSELC(3) = 0xc0000300; \ +} while (0) + +#define __gpio_as_otg_drvvbus() \ +do { \ + REG_GPIO_PXDATC(4) = (1 << 10); \ + REG_GPIO_PXPEC(4) = (1 << 10); \ + REG_GPIO_PXSELC(4) = (1 << 10); \ + REG_GPIO_PXTRGC(4) = (1 << 10); \ + REG_GPIO_PXFUNS(4) = (1 << 10); \ +} while (0) + +//------------------------------------------- +// GPIO or Interrupt Mode + +#define __gpio_get_port(p) (REG_GPIO_PXPIN(p)) + +#define __gpio_port_as_output(p, o) \ +do { \ + REG_GPIO_PXFUNC(p) = (1 << (o)); \ + REG_GPIO_PXSELC(p) = (1 << (o)); \ + REG_GPIO_PXDIRS(p) = (1 << (o)); \ + REG_GPIO_PXPES(p) = (1 << (o)); \ +} while (0) + +#define __gpio_port_as_input(p, o) \ +do { \ + REG_GPIO_PXFUNC(p) = (1 << (o)); \ + REG_GPIO_PXSELC(p) = (1 << (o)); \ + REG_GPIO_PXDIRC(p) = (1 << (o)); \ +} while (0) + +#define __gpio_as_output(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + __gpio_port_as_output(p, o); \ +} while (0) + +#define __gpio_as_input(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + __gpio_port_as_input(p, o); \ +} while (0) + +#define __gpio_set_pin(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXDATS(p) = (1 << o); \ +} while (0) + +#define __gpio_clear_pin(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXDATC(p) = (1 << o); \ +} while (0) + +#define __gpio_get_pin(n) \ +({ \ + unsigned int p, o, v; \ + p = (n) / 32; \ + o = (n) % 32; \ + if (__gpio_get_port(p) & (1 << o)) \ + v = 1; \ + else \ + v = 0; \ + v; \ +}) + +#define __gpio_as_irq_high_level(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXIMS(p) = (1 << o); \ + REG_GPIO_PXTRGC(p) = (1 << o); \ + REG_GPIO_PXFUNC(p) = (1 << o); \ + REG_GPIO_PXSELS(p) = (1 << o); \ + REG_GPIO_PXDIRS(p) = (1 << o); \ + REG_GPIO_PXFLGC(p) = (1 << o); \ + REG_GPIO_PXIMC(p) = (1 << o); \ +} while (0) + +#define __gpio_as_irq_low_level(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXIMS(p) = (1 << o); \ + REG_GPIO_PXTRGC(p) = (1 << o); \ + REG_GPIO_PXFUNC(p) = (1 << o); \ + REG_GPIO_PXSELS(p) = (1 << o); \ + REG_GPIO_PXDIRC(p) = (1 << o); \ + REG_GPIO_PXFLGC(p) = (1 << o); \ + REG_GPIO_PXIMC(p) = (1 << o); \ +} while (0) + +#define __gpio_as_irq_rise_edge(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXIMS(p) = (1 << o); \ + REG_GPIO_PXTRGS(p) = (1 << o); \ + REG_GPIO_PXFUNC(p) = (1 << o); \ + REG_GPIO_PXSELS(p) = (1 << o); \ + REG_GPIO_PXDIRS(p) = (1 << o); \ + REG_GPIO_PXFLGC(p) = (1 << o); \ + REG_GPIO_PXIMC(p) = (1 << o); \ +} while (0) + +#define __gpio_as_irq_fall_edge(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXIMS(p) = (1 << o); \ + REG_GPIO_PXTRGS(p) = (1 << o); \ + REG_GPIO_PXFUNC(p) = (1 << o); \ + REG_GPIO_PXSELS(p) = (1 << o); \ + REG_GPIO_PXDIRC(p) = (1 << o); \ + REG_GPIO_PXFLGC(p) = (1 << o); \ + REG_GPIO_PXIMC(p) = (1 << o); \ +} while (0) + +#define __gpio_mask_irq(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXIMS(p) = (1 << o); \ +} while (0) + +#define __gpio_unmask_irq(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXIMC(p) = (1 << o); \ +} while (0) + +#define __gpio_ack_irq(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXFLGC(p) = (1 << o); \ +} while (0) + +#define __gpio_get_irq() \ +({ \ + unsigned int tmp, v = 0; \ + for (int p = 5; p >= 0; p--) { \ + tmp = REG_GPIO_PXFLG(p); \ + for (int i = 0; i < 32; i++) \ + if (tmp & (1 << i)) \ + v = (32*p + i); \ + } \ + v; \ +}) + +#define __gpio_group_irq(n) \ +({ \ + register int tmp, i; \ + tmp = REG_GPIO_PXFLG(n) & (~REG_GPIO_PXIM(n)); \ + for (i=31;i>=0;i--) \ + if (tmp & (1 << i)) \ + break; \ + i; \ +}) + +#define __gpio_enable_pull(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXPEC(p) = (1 << o); \ +} while (0) + +#define __gpio_disable_pull(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXPES(p) = (1 << o); \ +} while (0) + +/* Set pin driver strength v: 0~7 */ +#define __gpio_set_driving_strength(n, v) \ +do { \ + unsigned int p, o, d; \ + p = (n) / 32; \ + o = (n) % 32; \ + d = v & 0x1; \ + if(d) REG_GPIO_PXDS0S(p) = (1 << o); \ + else REG_GPIO_PXDS0C(p) = (1 << o); \ + d = v & 0x2; \ + if(d) REG_GPIO_PXDS1S(p) = (1 << o); \ + else REG_GPIO_PXDS1C(p) = (1 << o); \ + d = v & 0x4; \ + if(d) REG_GPIO_PXDS2S(p) = (1 << o); \ + else REG_GPIO_PXDS2C(p) = (1 << o); \ +} while(0) + +/* Set fast slew rate */ +#define __gpio_set_fslew(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXSLS(p) = (1 << o); \ +} while(0) + +/* Set slow slew rate */ +#define __gpio_set_sslew(n) \ +do { \ + unsigned int p, o; \ + p = (n) / 32; \ + o = (n) % 32; \ + REG_GPIO_PXSLC(p) = (1 << o); \ +} while(0) + +#endif /* __MIPS_ASSEMBLER */ + +#define DMAC_BASE 0xB3420000 + +/************************************************************************* + * DMAC (DMA Controller) + *************************************************************************/ + +#define MAX_DMA_NUM 12 /* max 12 channels */ +#define MAX_MDMA_NUM 3 /* max 3 channels */ +#define MAX_BDMA_NUM 3 /* max 3 channels */ +#define HALF_DMA_NUM 6 /* the number of one dma controller's channels */ + +/* m is the DMA controller index (0, 1), n is the DMA channel index (0 - 11) */ + +#define DMAC_DSAR(n) (DMAC_BASE + ((n)/HALF_DMA_NUM*0x100 + 0x00 + ((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM) * 0x20)) /* DMA source address */ +#define DMAC_DTAR(n) (DMAC_BASE + ((n)/HALF_DMA_NUM*0x100 + 0x04 + ((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM) * 0x20)) /* DMA target address */ +#define DMAC_DTCR(n) (DMAC_BASE + ((n)/HALF_DMA_NUM*0x100 + 0x08 + ((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM) * 0x20)) /* DMA transfer count */ +#define DMAC_DRSR(n) (DMAC_BASE + ((n)/HALF_DMA_NUM*0x100 + 0x0c + ((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM) * 0x20)) /* DMA request source */ +#define DMAC_DCCSR(n) (DMAC_BASE + ((n)/HALF_DMA_NUM*0x100 + 0x10 + ((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM) * 0x20)) /* DMA control/status */ +#define DMAC_DCMD(n) (DMAC_BASE + ((n)/HALF_DMA_NUM*0x100 + 0x14 + ((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM) * 0x20)) /* DMA command */ +#define DMAC_DDA(n) (DMAC_BASE + ((n)/HALF_DMA_NUM*0x100 + 0x18 + ((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM) * 0x20)) /* DMA descriptor address */ +#define DMAC_DSD(n) (DMAC_BASE + ((n)/HALF_DMA_NUM*0x100 + 0xc0 + ((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM) * 0x04)) /* DMA Stride Address */ + +#define DMAC_DMACR(m) (DMAC_BASE + 0x0300 + 0x100 * (m)) /* DMA control register */ +#define DMAC_DMAIPR(m) (DMAC_BASE + 0x0304 + 0x100 * (m)) /* DMA interrupt pending */ +#define DMAC_DMADBR(m) (DMAC_BASE + 0x0308 + 0x100 * (m)) /* DMA doorbell */ +#define DMAC_DMADBSR(m) (DMAC_BASE + 0x030C + 0x100 * (m)) /* DMA doorbell set */ +#define DMAC_DMACKE(m) (DMAC_BASE + 0x0310 + 0x100 * (m)) +#define DMAC_DMACKES(m) (DMAC_BASE + 0x0314 + 0x100 * (m)) +#define DMAC_DMACKEC(m) (DMAC_BASE + 0x0318 + 0x100 * (m)) + +#define REG_DMAC_DSAR(n) REG32(DMAC_DSAR((n))) +#define REG_DMAC_DTAR(n) REG32(DMAC_DTAR((n))) +#define REG_DMAC_DTCR(n) REG32(DMAC_DTCR((n))) +#define REG_DMAC_DRSR(n) REG32(DMAC_DRSR((n))) +#define REG_DMAC_DCCSR(n) REG32(DMAC_DCCSR((n))) +#define REG_DMAC_DCMD(n) REG32(DMAC_DCMD((n))) +#define REG_DMAC_DDA(n) REG32(DMAC_DDA((n))) +#define REG_DMAC_DSD(n) REG32(DMAC_DSD(n)) +#define REG_DMAC_DMACR(m) REG32(DMAC_DMACR(m)) +#define REG_DMAC_DMAIPR(m) REG32(DMAC_DMAIPR(m)) +#define REG_DMAC_DMADBR(m) REG32(DMAC_DMADBR(m)) +#define REG_DMAC_DMADBSR(m) REG32(DMAC_DMADBSR(m)) +#define REG_DMAC_DMACKE(m) REG32(DMAC_DMACKE(m)) +#define REG_DMAC_DMACKES(m) REG32(DMAC_DMACKES(m)) +#define REG_DMAC_DMACKEC(m) REG32(DMAC_DMACKEC(m)) + +// DMA request source register +#define DMAC_DRSR_RS_BIT 0 +#define DMAC_DRSR_RS_MASK (0x3f << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_NAND (1 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_BCH_ENC (2 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_BCH_DEC (3 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_AUTO (0x08 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_TSSIIN (0x09 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_EXT (0x0c << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_UART3OUT (0x0e << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_UART3IN (0x0f << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_UART2OUT (0x10 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_UART2IN (0x11 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_UART1OUT (0x12 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_UART1IN (0x13 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_UART0OUT (0x14 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_UART0IN (0x15 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_SSI0OUT (0x16 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_SSI0IN (0x17 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_AICOUT (0x18 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_AICIN (0x19 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_MSC0OUT (0x1a << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_MSC0IN (0x1b << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_TCU (0x1c << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_SADC (0x1d << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_MSC1OUT (0x1e << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_MSC1IN (0x1f << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_SSI1OUT (0x20 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_SSI1IN (0x21 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_PMOUT (0x22 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_PMIN (0x23 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_MSC2OUT (0x24 << DMAC_DRSR_RS_BIT) + #define DMAC_DRSR_RS_MSC2IN (0x25 << DMAC_DRSR_RS_BIT) + +// DMA channel control/status register +#define DMAC_DCCSR_NDES (1 << 31) /* descriptor (0) or not (1) ? */ +#define DMAC_DCCSR_DES8 (1 << 30) /* Descriptor 8 Word */ +#define DMAC_DCCSR_DES4 (0 << 30) /* Descriptor 4 Word */ +#define DMAC_DCCSR_CDOA_BIT 16 /* copy of DMA offset address */ +#define DMAC_DCCSR_CDOA_MASK (0xff << DMAC_DCCSR_CDOA_BIT) + +#define DMAC_DCCSR_AR (1 << 4) /* address error */ +#define DMAC_DCCSR_TT (1 << 3) /* transfer terminated */ +#define DMAC_DCCSR_HLT (1 << 2) /* DMA halted */ +#define DMAC_DCCSR_CT (1 << 1) /* count terminated */ +#define DMAC_DCCSR_EN (1 << 0) /* channel enable bit */ + +// DMA channel command register +#define DMAC_DCMD_EACKS_LOW (1 << 31) /* External DACK Output Level Select, active low */ +#define DMAC_DCMD_EACKS_HIGH (0 << 31) /* External DACK Output Level Select, active high */ +#define DMAC_DCMD_EACKM_WRITE (1 << 30) /* External DACK Output Mode Select, output in write cycle */ +#define DMAC_DCMD_EACKM_READ (0 << 30) /* External DACK Output Mode Select, output in read cycle */ +#define DMAC_DCMD_ERDM_BIT 28 /* External DREQ Detection Mode Select */ +#define DMAC_DCMD_ERDM_MASK (0x03 << DMAC_DCMD_ERDM_BIT) + #define DMAC_DCMD_ERDM_LOW (0 << DMAC_DCMD_ERDM_BIT) + #define DMAC_DCMD_ERDM_FALL (1 << DMAC_DCMD_ERDM_BIT) + #define DMAC_DCMD_ERDM_HIGH (2 << DMAC_DCMD_ERDM_BIT) + #define DMAC_DCMD_ERDM_RISE (3 << DMAC_DCMD_ERDM_BIT) +#define DMAC_DCMD_BLAST (1 << 25) /* BCH last */ +#define DMAC_DCMD_SAI (1 << 23) /* source address increment */ +#define DMAC_DCMD_DAI (1 << 22) /* dest address increment */ +#define DMAC_DCMD_RDIL_BIT 16 /* request detection interval length */ +#define DMAC_DCMD_RDIL_MASK (0x0f << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_IGN (0 << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_2 (0x01 << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_4 (0x02 << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_8 (0x03 << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_12 (0x04 << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_16 (0x05 << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_20 (0x06 << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_24 (0x07 << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_28 (0x08 << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_32 (0x09 << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_48 (0x0a << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_60 (0x0b << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_64 (0x0c << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_124 (0x0d << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_128 (0x0e << DMAC_DCMD_RDIL_BIT) + #define DMAC_DCMD_RDIL_200 (0x0f << DMAC_DCMD_RDIL_BIT) +#define DMAC_DCMD_SWDH_BIT 14 /* source port width */ +#define DMAC_DCMD_SWDH_MASK (0x03 << DMAC_DCMD_SWDH_BIT) + #define DMAC_DCMD_SWDH_32 (0 << DMAC_DCMD_SWDH_BIT) + #define DMAC_DCMD_SWDH_8 (1 << DMAC_DCMD_SWDH_BIT) + #define DMAC_DCMD_SWDH_16 (2 << DMAC_DCMD_SWDH_BIT) +#define DMAC_DCMD_DWDH_BIT 12 /* dest port width */ +#define DMAC_DCMD_DWDH_MASK (0x03 << DMAC_DCMD_DWDH_BIT) + #define DMAC_DCMD_DWDH_32 (0 << DMAC_DCMD_DWDH_BIT) + #define DMAC_DCMD_DWDH_8 (1 << DMAC_DCMD_DWDH_BIT) + #define DMAC_DCMD_DWDH_16 (2 << DMAC_DCMD_DWDH_BIT) +#define DMAC_DCMD_DS_BIT 8 /* transfer data size of a data unit */ +#define DMAC_DCMD_DS_MASK (0x07 << DMAC_DCMD_DS_BIT) + #define DMAC_DCMD_DS_32BIT (0 << DMAC_DCMD_DS_BIT) + #define DMAC_DCMD_DS_8BIT (1 << DMAC_DCMD_DS_BIT) + #define DMAC_DCMD_DS_16BIT (2 << DMAC_DCMD_DS_BIT) + #define DMAC_DCMD_DS_16BYTE (3 << DMAC_DCMD_DS_BIT) + #define DMAC_DCMD_DS_32BYTE (4 << DMAC_DCMD_DS_BIT) + #define DMAC_DCMD_DS_64BYTE (5 << DMAC_DCMD_DS_BIT) + +#define DMAC_DCMD_STDE (1 << 2) /* Stride enable */ +#define DMAC_DCMD_TIE (1 << 1) /* DMA transfer interrupt enable */ +#define DMAC_DCMD_LINK (1 << 0) /* descriptor link enable */ + +// DMA descriptor address register +#define DMAC_DDA_BASE_BIT 12 /* descriptor base address */ +#define DMAC_DDA_BASE_MASK (0x0fffff << DMAC_DDA_BASE_BIT) +#define DMAC_DDA_OFFSET_BIT 4 /* descriptor offset address */ +#define DMAC_DDA_OFFSET_MASK (0x0ff << DMAC_DDA_OFFSET_BIT) + +// DMA stride address register +#define DMAC_DSD_TSD_BIT 16 /* target stride address */ +#define DMAC_DSD_TSD_MASK (0xffff << DMAC_DSD_TSD_BIT) +#define DMAC_DSD_SSD_BIT 0 /* source stride address */ +#define DMAC_DSD_SSD_MASK (0xffff << DMAC_DSD_SSD_BIT) + +// DMA control register +#define DMAC_DMACR_FMSC (1 << 31) /* MSC Fast DMA mode */ +#define DMAC_DMACR_FSSI (1 << 30) /* SSI Fast DMA mode */ +#define DMAC_DMACR_FTSSI (1 << 29) /* TSSI Fast DMA mode */ +#define DMAC_DMACR_FUART (1 << 28) /* UART Fast DMA mode */ +#define DMAC_DMACR_FAIC (1 << 27) /* AIC Fast DMA mode */ +#define DMAC_DMACR_PR_BIT 8 /* channel priority mode */ +#define DMAC_DMACR_PR_MASK (0x03 << DMAC_DMACR_PR_BIT) + #define DMAC_DMACR_PR_012345 (0 << DMAC_DMACR_PR_BIT) + #define DMAC_DMACR_PR_120345 (1 << DMAC_DMACR_PR_BIT) + #define DMAC_DMACR_PR_230145 (2 << DMAC_DMACR_PR_BIT) + #define DMAC_DMACR_PR_340125 (3 << DMAC_DMACR_PR_BIT) +#define DMAC_DMACR_HLT (1 << 3) /* DMA halt flag */ +#define DMAC_DMACR_AR (1 << 2) /* address error flag */ +#define DMAC_DMACR_DMAE (1 << 0) /* DMA enable bit */ + +// DMA doorbell register +#define DMAC_DMADBR_DB5 (1 << 5) /* doorbell for channel 5 */ +#define DMAC_DMADBR_DB4 (1 << 4) /* doorbell for channel 4 */ +#define DMAC_DMADBR_DB3 (1 << 3) /* doorbell for channel 3 */ +#define DMAC_DMADBR_DB2 (1 << 2) /* doorbell for channel 2 */ +#define DMAC_DMADBR_DB1 (1 << 1) /* doorbell for channel 1 */ +#define DMAC_DMADBR_DB0 (1 << 0) /* doorbell for channel 0 */ + +// DMA doorbell set register +#define DMAC_DMADBSR_DBS5 (1 << 5) /* enable doorbell for channel 5 */ +#define DMAC_DMADBSR_DBS4 (1 << 4) /* enable doorbell for channel 4 */ +#define DMAC_DMADBSR_DBS3 (1 << 3) /* enable doorbell for channel 3 */ +#define DMAC_DMADBSR_DBS2 (1 << 2) /* enable doorbell for channel 2 */ +#define DMAC_DMADBSR_DBS1 (1 << 1) /* enable doorbell for channel 1 */ +#define DMAC_DMADBSR_DBS0 (1 << 0) /* enable doorbell for channel 0 */ + +// DMA interrupt pending register +#define DMAC_DMAIPR_CIRQ5 (1 << 5) /* irq pending status for channel 5 */ +#define DMAC_DMAIPR_CIRQ4 (1 << 4) /* irq pending status for channel 4 */ +#define DMAC_DMAIPR_CIRQ3 (1 << 3) /* irq pending status for channel 3 */ +#define DMAC_DMAIPR_CIRQ2 (1 << 2) /* irq pending status for channel 2 */ +#define DMAC_DMAIPR_CIRQ1 (1 << 1) /* irq pending status for channel 1 */ +#define DMAC_DMAIPR_CIRQ0 (1 << 0) /* irq pending status for channel 0 */ + +#ifndef __MIPS_ASSEMBLER + +/*************************************************************************** + * DMAC + ***************************************************************************/ + +/* m is the DMA controller index (0, 1), n is the DMA channel index (0 - 11) */ + +#define __dmac_enable_module(m) \ + ( REG_DMAC_DMACR(m) |= DMAC_DMACR_DMAE | DMAC_DMACR_PR_012345 ) +#define __dmac_disable_module(m) \ + ( REG_DMAC_DMACR(m) &= ~DMAC_DMACR_DMAE ) + +/* p=0,1,2,3 */ +#define __dmac_set_priority(m,p) \ +do { \ + REG_DMAC_DMACR(m) &= ~DMAC_DMACR_PR_MASK; \ + REG_DMAC_DMACR(m) |= ((p) << DMAC_DMACR_PR_BIT); \ +} while (0) + +#define __dmac_test_halt_error(m) ( REG_DMAC_DMACR(m) & DMAC_DMACR_HLT ) +#define __dmac_test_addr_error(m) ( REG_DMAC_DMACR(m) & DMAC_DMACR_AR ) + +#define __dmac_channel_enable_clk(n) \ + REG_DMAC_DMACKES((n)/HALF_DMA_NUM) = 1 << ((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM); + +#define __dmac_channel_disable_clk(n) \ + REG_DMAC_DMACKEC((n)/HALF_DMA_NUM) = 1 << ((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM); + +#define __dmac_enable_descriptor(n) \ + ( REG_DMAC_DCCSR((n)) &= ~DMAC_DCCSR_NDES ) +#define __dmac_disable_descriptor(n) \ + ( REG_DMAC_DCCSR((n)) |= DMAC_DCCSR_NDES ) + +#define __dmac_enable_channel(n) \ +do { \ + REG_DMAC_DCCSR((n)) |= DMAC_DCCSR_EN; \ +} while (0) +#define __dmac_disable_channel(n) \ +do { \ + REG_DMAC_DCCSR((n)) &= ~DMAC_DCCSR_EN; \ +} while (0) +#define __dmac_channel_enabled(n) \ + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_EN ) + +#define __dmac_channel_enable_irq(n) \ + ( REG_DMAC_DCMD((n)) |= DMAC_DCMD_TIE ) +#define __dmac_channel_disable_irq(n) \ + ( REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_TIE ) + +#define __dmac_channel_transmit_halt_detected(n) \ + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_HLT ) +#define __dmac_channel_transmit_end_detected(n) \ + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_TT ) +#define __dmac_channel_address_error_detected(n) \ + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_AR ) + +#define __dmac_channel_count_terminated_detected(n) \ + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_CT ) +#define __dmac_channel_descriptor_invalid_detected(n) \ + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_INV ) + +#define __dmac_channel_clear_transmit_halt(n) \ + do { \ + /* clear both channel halt error and globle halt error */ \ + REG_DMAC_DCCSR(n) &= ~DMAC_DCCSR_HLT; \ + REG_DMAC_DMACR(n/HALF_DMA_NUM) &= ~DMAC_DMACR_HLT; \ + } while (0) +#define __dmac_channel_clear_transmit_end(n) \ + ( REG_DMAC_DCCSR(n) &= ~DMAC_DCCSR_TT ) +#define __dmac_channel_clear_address_error(n) \ + do { \ + REG_DMAC_DDA(n) = 0; /* clear descriptor address register */ \ + REG_DMAC_DSAR(n) = 0; /* clear source address register */ \ + REG_DMAC_DTAR(n) = 0; /* clear target address register */ \ + /* clear both channel addr error and globle address error */ \ + REG_DMAC_DCCSR(n) &= ~DMAC_DCCSR_AR; \ + REG_DMAC_DMACR(n/HALF_DMA_NUM) &= ~DMAC_DMACR_AR; \ + } while (0) + +#define __dmac_channel_clear_count_terminated(n) \ + ( REG_DMAC_DCCSR((n)) &= ~DMAC_DCCSR_CT ) +#define __dmac_channel_clear_descriptor_invalid(n) \ + ( REG_DMAC_DCCSR((n)) &= ~DMAC_DCCSR_INV ) + +#define __dmac_channel_set_transfer_unit_32bit(n) \ +do { \ + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \ + REG_DMAC_DCMD((n)) |= MAC_DCMD_DS_32BIT; \ +} while (0) + +#define __dmac_channel_set_transfer_unit_16bit(n) \ +do { \ + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \ + REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_16BIT; \ +} while (0) + +#define __dmac_channel_set_transfer_unit_8bit(n) \ +do { \ + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \ + REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_8BIT; \ +} while (0) + +#define __dmac_channel_set_transfer_unit_16byte(n) \ +do { \ + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \ + REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_16BYTE; \ +} while (0) + +#define __dmac_channel_set_transfer_unit_32byte(n) \ +do { \ + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \ + REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_32BYTE; \ +} while (0) + +/* w=8,16,32 */ +#define __dmac_channel_set_dest_port_width(n,w) \ +do { \ + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DWDH_MASK; \ + REG_DMAC_DCMD((n)) |= DMAC_DCMD_DWDH_##w; \ +} while (0) + +/* w=8,16,32 */ +#define __dmac_channel_set_src_port_width(n,w) \ +do { \ + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_SWDH_MASK; \ + REG_DMAC_DCMD((n)) |= DMAC_DCMD_SWDH_##w; \ +} while (0) + +/* v=0-15 */ +#define __dmac_channel_set_rdil(n,v) \ +do { \ + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_RDIL_MASK; \ + REG_DMAC_DCMD((n) |= ((v) << DMAC_DCMD_RDIL_BIT); \ +} while (0) + +#define __dmac_channel_dest_addr_fixed(n) \ + ( REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DAI ) +#define __dmac_channel_dest_addr_increment(n) \ + ( REG_DMAC_DCMD((n)) |= DMAC_DCMD_DAI ) + +#define __dmac_channel_src_addr_fixed(n) \ + ( REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_SAI ) +#define __dmac_channel_src_addr_increment(n) \ + ( REG_DMAC_DCMD((n)) |= DMAC_DCMD_SAI ) + +#define __dmac_channel_set_doorbell(n) \ + ( REG_DMAC_DMADBSR((n)/HALF_DMA_NUM) = (1 << ((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM)) ) + +#define __dmac_channel_irq_detected(n) ( REG_DMAC_DMAIPR((n)/HALF_DMA_NUM) & (1 << ((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM)) ) +#define __dmac_channel_ack_irq(n) ( REG_DMAC_DMAIPR((n)/HALF_DMA_NUM) &= ~(1 <<((n)-(n)/HALF_DMA_NUM*HALF_DMA_NUM)) ) + +static __inline__ int __dmac_get_irq(void) +{ + int i; + for (i = 0; i < MAX_DMA_NUM; i++) + if (__dmac_channel_irq_detected(i)) + return i; + return -1; +} + +#endif /* __MIPS_ASSEMBLER */ + +/* + * Interrupt controller module(INTC) address definition + */ +#define INTC_BASE 0xB0001000 + +/* + * INTC registers offset address definition + */ +#define INTC_ICSR_OFFSET (0x00) /* 32, r, 0x00000000 */ +#define INTC_ICMR_OFFSET (0x04) /* 32, rw, 0xffffffff */ +#define INTC_ICMSR_OFFSET (0x08) /* 32, w, 0x???????? */ +#define INTC_ICMCR_OFFSET (0x0c) /* 32, w, 0x???????? */ +#define INTC_ICPR_OFFSET (0x10) /* 32, r, 0x00000000 */ + +/* INTC groups offset */ +#define INTC_GOS 0x20 + +/* + * INTC registers address definition + */ +#define INTC_ICSR(n) (INTC_BASE + (n) * INTC_GOS + INTC_ICSR_OFFSET) +#define INTC_ICMR(n) (INTC_BASE + (n) * INTC_GOS + INTC_ICMR_OFFSET) +#define INTC_ICMSR(n) (INTC_BASE + (n) * INTC_GOS + INTC_ICMSR_OFFSET) +#define INTC_ICMCR(n) (INTC_BASE + (n) * INTC_GOS + INTC_ICMCR_OFFSET) +#define INTC_ICPR(n) (INTC_BASE + (n) * INTC_GOS + INTC_ICPR_OFFSET) + +/* + * INTC registers common define + */ + +/* 1st-level interrupts */ +#define IRQ_I2C1 0 +#define IRQ_I2C0 1 +#define IRQ_UART3 2 +#define IRQ_UART2 3 +#define IRQ_UART1 4 +#define IRQ_UART0 5 +#define IRQ_GPU 6 +#define IRQ_SSI1 7 +#define IRQ_SSI0 8 +#define IRQ_TSSI 9 +#define IRQ_BDMA 10 +#define IRQ_KBC 11 +#define IRQ_GPIO5 12 +#define IRQ_GPIO4 13 +#define IRQ_GPIO3 14 +#define IRQ_GPIO2 15 +#define IRQ_GPIO1 16 +#define IRQ_GPIO0 17 +#define IRQ_SADC 18 +#define IRQ_ETH 19 +#define IRQ_UHC 20 +#define IRQ_OTG 21 +#define IRQ_MDMA 22 +#define IRQ_DMAC1 23 +#define IRQ_DMAC0 24 +#define IRQ_TCU2 25 +#define IRQ_TCU1 26 +#define IRQ_TCU0 27 +#define IRQ_GPS 28 +#define IRQ_IPU 29 +#define IRQ_CIM 30 +#define IRQ_LCD 31 + +#define IRQ_RTC 32 /* 32 + 0 */ +#define IRQ_OWI 33 /* 32 + 1 */ +#define IRQ_AIC 34 /* 32 + 2 */ +#define IRQ_MSC2 35 /* 32 + 3 */ +#define IRQ_MSC1 36 /* 32 + 4 */ +#define IRQ_MSC0 37 /* 32 + 5 */ +#define IRQ_SCC 38 /* 32 + 6 */ +#define IRQ_BCH 39 /* 32 + 7 */ +#define IRQ_PCM 40 /* 32 + 8 */ +#define IRQ_HARB0 41 /* 32 + 9 */ +#define IRQ_HARB2 42 /* 32 + 10 */ +#define IRQ_AOSD 43 /* 32 + 11 */ +#define IRQ_CPM 44 /* 32 + 12 */ + +#define IRQ_INTC_MAX 45 + +/* 2nd-level interrupts */ +#define IRQ_DMA_BASE (IRQ_INTC_MAX) +#define IRQ_DMA_MAX (IRQ_DMA_BASE + NUM_DMA) + +#define IRQ_MDMA_BASE (IRQ_DMA_MAX) +#define IRQ_MDMA_MAX (IRQ_MDMA_BASE + NUM_MDMA) + +#define IRQ_BDMA_BASE (IRQ_MDMA_MAX) +#define IRQ_BDMA_MAX (IRQ_BDMA_BASE + NUM_BDMA) + +/* To be cleanup begin */ +#define IRQ_DMA_0 46 +#define IRQ_DMA_1 (IRQ_DMA_0 + HALF_DMA_NUM) /* 46 + 6 = 52 */ +#define IRQ_MDMA_0 (IRQ_DMA_0 + MAX_DMA_NUM) /* 46 + 12 = 58 */ +#define IRQ_BDMA_0 (IRQ_DMA_0 + MAX_DMA_NUM + MAX_MDMA_NUM) /* 46 + 12 + 2 = 60 */ + +#define IRQ_GPIO_0 64 /* 64 to (64+MAX_GPIO_NUM-1) for GPIO pin 0 to MAX_GPIO_NUM-1 */ + +#define NUM_INTC 45 +#define NUM_DMA MAX_DMA_NUM +#define NUM_MDMA MAX_MDMA_NUM +#define NUM_BDMA MAX_BDMA_NUM +#define NUM_GPIO MAX_GPIO_NUM +/* To be cleanup end */ + +#ifndef __MIPS_ASSEMBLER + +#define REG_INTC_ICMR(n) REG32(INTC_ICMR(n)) +#define REG_INTC_ICMSR(n) REG32(INTC_ICMSR(n)) +#define REG_INTC_ICMCR(n) REG32(INTC_ICMCR(n)) +#define REG_INTC_ICPR(n) REG32(INTC_ICPR(n)) + +#define __intc_unmask_irq(n) (REG_INTC_ICMCR((n)/32) = (1 << ((n)%32))) +#define __intc_mask_irq(n) (REG_INTC_ICMSR((n)/32) = (1 << ((n)%32))) + +#endif /* __MIPS_ASSEMBLER */ + +/* + * AC97 and I2S controller module(AIC) address definition + */ +#define AIC_BASE 0xb0020000 + +/* + * AIC registers offset address definition + */ +#define AIC_FR_OFFSET (0x00) +#define AIC_CR_OFFSET (0x04) +#define AIC_ACCR1_OFFSET (0x08) +#define AIC_ACCR2_OFFSET (0x0c) +#define AIC_I2SCR_OFFSET (0x10) +#define AIC_SR_OFFSET (0x14) +#define AIC_ACSR_OFFSET (0x18) +#define AIC_I2SSR_OFFSET (0x1c) +#define AIC_ACCAR_OFFSET (0x20) +#define AIC_ACCDR_OFFSET (0x24) +#define AIC_ACSAR_OFFSET (0x28) +#define AIC_ACSDR_OFFSET (0x2c) +#define AIC_I2SDIV_OFFSET (0x30) +#define AIC_DR_OFFSET (0x34) + +#define SPDIF_ENA_OFFSET (0x80) +#define SPDIF_CTRL_OFFSET (0x84) +#define SPDIF_STATE_OFFSET (0x88) +#define SPDIF_CFG1_OFFSET (0x8c) +#define SPDIF_CFG2_OFFSET (0x90) +#define SPDIF_FIFO_OFFSET (0x94) + +#define ICDC_RGADW_OFFSET (0xa4) +#define ICDC_RGDATA_OFFSET (0xa8) + +/* + * AIC registers address definition + */ +#define AIC_FR (AIC_BASE + AIC_FR_OFFSET) +#define AIC_CR (AIC_BASE + AIC_CR_OFFSET) +#define AIC_ACCR1 (AIC_BASE + AIC_ACCR1_OFFSET) +#define AIC_ACCR2 (AIC_BASE + AIC_ACCR2_OFFSET) +#define AIC_I2SCR (AIC_BASE + AIC_I2SCR_OFFSET) +#define AIC_SR (AIC_BASE + AIC_SR_OFFSET) +#define AIC_ACSR (AIC_BASE + AIC_ACSR_OFFSET) +#define AIC_I2SSR (AIC_BASE + AIC_I2SSR_OFFSET) +#define AIC_ACCAR (AIC_BASE + AIC_ACCAR_OFFSET) +#define AIC_ACCDR (AIC_BASE + AIC_ACCDR_OFFSET) +#define AIC_ACSAR (AIC_BASE + AIC_ACSAR_OFFSET) +#define AIC_ACSDR (AIC_BASE + AIC_ACSDR_OFFSET) +#define AIC_I2SDIV (AIC_BASE + AIC_I2SDIV_OFFSET) +#define AIC_DR (AIC_BASE + AIC_DR_OFFSET) + +#define SPDIF_ENA (AIC_BASE + SPDIF_ENA_OFFSET) +#define SPDIF_CTRL (AIC_BASE + SPDIF_CTRL_OFFSET) +#define SPDIF_STATE (AIC_BASE + SPDIF_STATE_OFFSET) +#define SPDIF_CFG1 (AIC_BASE + SPDIF_CFG1_OFFSET) +#define SPDIF_CFG2 (AIC_BASE + SPDIF_CFG2_OFFSET) +#define SPDIF_FIFO (AIC_BASE + SPDIF_FIFO_OFFSET) + +#define ICDC_RGADW (AIC_BASE + ICDC_RGADW_OFFSET) +#define ICDC_RGDATA (AIC_BASE + ICDC_RGDATA_OFFSET) + +/* + * AIC registers common define + */ + +/* AIC controller configuration register(AICFR) */ +#define AIC_FR_LSMP BIT6 +#define AIC_FR_ICDC BIT5 +#define AIC_FR_AUSEL BIT4 +#define AIC_FR_RST BIT3 +#define AIC_FR_BCKD BIT2 +#define AIC_FR_SYNCD BIT1 +#define AIC_FR_ENB BIT0 + +#define AIC_FR_RFTH_LSB 24 +#define AIC_FR_RFTH_MASK BITS_H2L(27, AIC_FR_RFTH_LSB) + +#define AIC_FR_TFTH_LSB 16 +#define AIC_FR_TFTH_MASK BITS_H2L(20, AIC_FR_TFTH_LSB) + +/* AIC controller common control register(AICCR) */ +#define AIC_CR_PACK16 BIT28 +#define AIC_CR_RDMS BIT15 +#define AIC_CR_TDMS BIT14 +#define AIC_CR_M2S BIT11 +#define AIC_CR_ENDSW BIT10 +#define AIC_CR_AVSTSU BIT9 +#define AIC_CR_TFLUSH BIT8 +#define AIC_CR_RFLUSH BIT7 +#define AIC_CR_EROR BIT6 +#define AIC_CR_ETUR BIT5 +#define AIC_CR_ERFS BIT4 +#define AIC_CR_ETFS BIT3 +#define AIC_CR_ENLBF BIT2 +#define AIC_CR_ERPL BIT1 +#define AIC_CR_EREC BIT0 + +#define AIC_CR_CHANNEL_LSB 24 +#define AIC_CR_CHANNEL_MASK BITS_H2L(26, AIC_CR_CHANNEL_LSB) + +#define AIC_CR_OSS_LSB 19 +#define AIC_CR_OSS_MASK BITS_H2L(21, AIC_CR_OSS_LSB) + #define AIC_CR_OSS(n) (((n) > 18 ? (n)/6 : (n)/9) << AIC_CR_OSS_LSB) /* n = 8, 16, 18, 20, 24 */ + +#define AIC_CR_ISS_LSB 16 +#define AIC_CR_ISS_MASK BITS_H2L(18, AIC_CR_ISS_LSB) + #define AIC_CR_ISS(n) (((n) > 18 ? (n)/6 : (n)/9) << AIC_CR_ISS_LSB) /* n = 8, 16, 18, 20, 24 */ + +/* AIC controller AC-link control register 1(ACCR1) */ +#define AIC_ACCR1_RS_LSB 16 +#define AIC_ACCR1_RS_MASK BITS_H2L(25, AIC_ACCR1_RS_LSB) + #define AIC_ACCR1_RS_SLOT(n) ((1 << ((n) - 3)) << AIC_ACCR1_RS_LSB) /* n = 3 .. 12 */ + +#define AIC_ACCR1_XS_LSB 0 +#define AIC_ACCR1_XS_MASK BITS_H2L(9, AIC_ACCR1_XS_LSB) + #define AIC_ACCR1_XS_SLOT(n) ((1 << ((n) - 3)) << AIC_ACCR1_XS_LSB) /* n = 3 .. 12 */ + +/* AIC controller AC-link control register 2 (ACCR2) */ +#define AIC_ACCR2_ERSTO BIT18 +#define AIC_ACCR2_ESADR BIT17 +#define AIC_ACCR2_ECADT BIT16 +#define AIC_ACCR2_SO BIT3 +#define AIC_ACCR2_SR BIT2 +#define AIC_ACCR2_SS BIT1 +#define AIC_ACCR2_SA BIT0 + +/* AIC controller i2s/msb-justified control register (I2SCR) */ +#define AIC_I2SCR_RFIRST BIT17 +#define AIC_I2SCR_SWLH BIT16 +#define AIC_I2SCR_STPBK BIT12 +#define AIC_I2SCR_ESCLK BIT4 +#define AIC_I2SCR_AMSL BIT0 + +/* AIC controller FIFO status register (AICSR) */ +#define AIC_SR_ROR BIT6 +#define AIC_SR_TUR BIT5 +#define AIC_SR_RFS BIT4 +#define AIC_SR_TFS BIT3 + +#define AIC_SR_RFL_LSB 24 +#define AIC_SR_RFL_MASK BITS_H2L(29, AIC_SR_RFL_LSB) + +#define AIC_SR_TFL_LSB 8 +#define AIC_SR_TFL_MASK BITS_H2L(13, AIC_SR_TFL_LSB) + +/* AIC controller AC-link status register (ACSR) */ +#define AIC_ACSR_SLTERR BIT21 +#define AIC_ACSR_CRDY BIT20 +#define AIC_ACSR_CLPM BIT19 +#define AIC_ACSR_RSTO BIT18 +#define AIC_ACSR_SADR BIT17 +#define AIC_ACSR_CADT BIT16 + +/* AIC controller I2S/MSB-justified status register (I2SSR) */ +#define AIC_I2SSR_CHBSY BIT5 +#define AIC_I2SSR_TBSY BIT4 +#define AIC_I2SSR_RBSY BIT3 +#define AIC_I2SSR_BSY BIT2 + +/* AIC controller AC97 codec command address register (ACCAR) */ +#define AIC_ACCAR_CAR_LSB 0 +#define AIC_ACCAR_CAR_MASK BITS_H2L(19, AIC_ACCAR_CAR_LSB) + +/* AIC controller AC97 codec command data register (ACCDR) */ +#define AIC_ACCDR_CDR_LSB 0 +#define AIC_ACCDR_CDR_MASK BITS_H2L(19, AIC_ACCDR_CDR_LSB) + +/* AC97 read and write macro based on ACCAR and ACCDR */ +#define AC97_READ_CMD BIT19 +#define AC97_WRITE_CMD (BIT19 & ~BIT19) + +#define AC97_INDEX_LSB 12 +#define AC97_INDEX_MASK BITS_H2L(18, AC97_INDEX_LSB) + +#define AC97_DATA_LSB 4 +#define AC97_DATA_MASK BITS_H2L(19, AC97_DATA_LSB) + +/* AIC controller AC97 codec status address register (ACSAR) */ +#define AIC_ACSAR_SAR_LSB 0 +#define AIC_ACSAR_SAR_MASK BITS_H2L(19, AIC_ACSAR_SAR_LSB) + +/* AIC controller AC97 codec status data register (ACSDR) */ +#define AIC_ACSDR_SDR_LSB 0 +#define AIC_ACSDR_SDR_MASK BITS_H2L(19, AIC_ACSDR_SDR_LSB) + +/* AIC controller I2S/MSB-justified clock divider register (I2SDIV) */ +#define AIC_I2SDIV_DIV_LSB 0 +#define AIC_I2SDIV_DIV_MASK BITS_H2L(3, AIC_I2SDIV_DIV_LSB) + +/* SPDIF enable register (SPDIF_ENA) */ +#define SPDIF_ENA_SPEN BIT0 + +/* SPDIF control register (SPDIF_CTRL) */ +#define SPDIF_CTRL_DMAEN BIT15 +#define SPDIF_CTRL_DTYPE BIT14 +#define SPDIF_CTRL_SIGN BIT13 +#define SPDIF_CTRL_INVALID BIT12 +#define SPDIF_CTRL_RST BIT11 +#define SPDIF_CTRL_SPDIFI2S BIT10 +#define SPDIF_CTRL_MTRIG BIT1 +#define SPDIF_CTRL_MFFUR BIT0 + +/* SPDIF state register (SPDIF_STAT) */ +#define SPDIF_STAT_BUSY BIT7 +#define SPDIF_STAT_FTRIG BIT1 +#define SPDIF_STAT_FUR BIT0 + +#define SPDIF_STAT_FLVL_LSB 8 +#define SPDIF_STAT_FLVL_MASK BITS_H2L(14, SPDIF_STAT_FLVL_LSB) + +/* SPDIF configure 1 register (SPDIF_CFG1) */ +#define SPDIF_CFG1_INITLVL BIT17 +#define SPDIF_CFG1_ZROVLD BIT16 + +#define SPDIF_CFG1_TRIG_LSB 12 +#define SPDIF_CFG1_TRIG_MASK BITS_H2L(13, SPDIF_CFG1_TRIG_LSB) +#define SPDIF_CFG1_TRIG(n) (((n) > 16 ? 3 : (n)/8) << SPDIF_CFG1_TRIG_LSB) /* n = 4, 8, 16, 32 */ + +#define SPDIF_CFG1_SRCNUM_LSB 8 +#define SPDIF_CFG1_SRCNUM_MASK BITS_H2L(11, SPDIF_CFG1_SRCNUM_LSB) + +#define SPDIF_CFG1_CH1NUM_LSB 4 +#define SPDIF_CFG1_CH1NUM_MASK BITS_H2L(7, SPDIF_CFG1_CH1NUM_LSB) + +#define SPDIF_CFG1_CH2NUM_LSB 0 +#define SPDIF_CFG1_CH2NUM_MASK BITS_H2L(3, SPDIF_CFG1_CH2NUM_LSB) + +/* SPDIF configure 2 register (SPDIF_CFG2) */ +#define SPDIF_CFG2_MAXWL BIT18 +#define SPDIF_CFG2_PRE BIT3 +#define SPDIF_CFG2_COPYN BIT2 +#define SPDIF_CFG2_AUDION BIT1 +#define SPDIF_CFG2_CONPRO BIT0 + +#define SPDIF_CFG2_FS_LSB 26 +#define SPDIF_CFG2_FS_MASK BITS_H2L(29, SPDIF_CFG2_FS_LSB) + +#define SPDIF_CFG2_ORGFRQ_LSB 22 +#define SPDIF_CFG2_ORGFRQ_MASK BITS_H2L(25, SPDIF_CFG2_ORGFRQ_LSB) + +#define SPDIF_CFG2_SAMWL_LSB 19 +#define SPDIF_CFG2_SAMWL_MASK BITS_H2L(21, SPDIF_CFG2_SAMWL_LSB) + +#define SPDIF_CFG2_CLKACU_LSB 16 +#define SPDIF_CFG2_CLKACU_MASK BITS_H2L(17, SPDIF_CFG2_CLKACU_LSB) + +#define SPDIF_CFG2_CATCODE_LSB 8 +#define SPDIF_CFG2_CATCODE_MASK BITS_H2L(15, SPDIF_CFG2_CATCODE_LSB) + +#define SPDIF_CFG2_CHMD_LSB 6 +#define SPDIF_CFG2_CHMD_MASK BITS_H2L(7, SPDIF_CFG2_CHMD_LSB) + +/* ICDC internal register access control register(RGADW) */ +#define ICDC_RGADW_RGWR BIT16 + +#define ICDC_RGADW_RGADDR_LSB 8 +#define ICDC_RGADW_RGADDR_MASK BITS_H2L(14, ICDC_RGADW_RGADDR_LSB) + +#define ICDC_RGADW_RGDIN_LSB 0 +#define ICDC_RGADW_RGDIN_MASK BITS_H2L(7, ICDC_RGADW_RGDIN_LSB) + +/* ICDC internal register data output register (RGDATA)*/ +#define ICDC_RGDATA_IRQ BIT8 + +#define ICDC_RGDATA_RGDOUT_LSB 0 +#define ICDC_RGDATA_RGDOUT_MASK BITS_H2L(7, ICDC_RGDATA_RGDOUT_LSB) + +#ifndef __MIPS_ASSEMBLER + +#define REG_AIC_FR REG32(AIC_FR) +#define REG_AIC_CR REG32(AIC_CR) +#define REG_AIC_ACCR1 REG32(AIC_ACCR1) +#define REG_AIC_ACCR2 REG32(AIC_ACCR2) +#define REG_AIC_I2SCR REG32(AIC_I2SCR) +#define REG_AIC_SR REG32(AIC_SR) +#define REG_AIC_ACSR REG32(AIC_ACSR) +#define REG_AIC_I2SSR REG32(AIC_I2SSR) +#define REG_AIC_ACCAR REG32(AIC_ACCAR) +#define REG_AIC_ACCDR REG32(AIC_ACCDR) +#define REG_AIC_ACSAR REG32(AIC_ACSAR) +#define REG_AIC_ACSDR REG32(AIC_ACSDR) +#define REG_AIC_I2SDIV REG32(AIC_I2SDIV) +#define REG_AIC_DR REG32(AIC_DR) + +#define REG_SPDIF_ENA REG32(SPDIF_ENA) +#define REG_SPDIF_CTRL REG32(SPDIF_CTRL) +#define REG_SPDIF_STATE REG32(SPDIF_STATE) +#define REG_SPDIF_CFG1 REG32(SPDIF_CFG1) +#define REG_SPDIF_CFG2 REG32(SPDIF_CFG2) +#define REG_SPDIF_FIFO REG32(SPDIF_FIFO) + +#define REG_ICDC_RGADW REG32(ICDC_RGADW) +#define REG_ICDC_RGDATA REG32(ICDC_RGDATA) + +#define __aic_enable() ( REG_AIC_FR |= AIC_FR_ENB ) +#define __aic_disable() ( REG_AIC_FR &= ~AIC_FR_ENB ) + +#define __aic_select_ac97() ( REG_AIC_FR &= ~AIC_FR_AUSEL ) +#define __aic_select_i2s() ( REG_AIC_FR |= AIC_FR_AUSEL ) + +#define __aic_play_zero() ( REG_AIC_FR &= ~AIC_FR_LSMP ) +#define __aic_play_lastsample() ( REG_AIC_FR |= AIC_FR_LSMP ) + +#define __i2s_as_master() ( REG_AIC_FR |= AIC_FR_BCKD | AIC_FR_SYNCD ) +#define __i2s_as_slave() ( REG_AIC_FR &= ~(AIC_FR_BCKD | AIC_FR_SYNCD) ) +#define __aic_reset_status() ( REG_AIC_FR & AIC_FR_RST ) + +#define __i2s_enable_sclk() ( REG_AIC_I2SCR |= AIC_I2SCR_ESCLK ) +#define __i2s_disable_sclk() ( REG_AIC_I2SCR &= ~AIC_I2SCR_ESCLK ) + +#define __aic_reset() \ +do { \ + REG_AIC_FR |= AIC_FR_RST; \ +} while(0) + +#define __aic_set_transmit_trigger(n) \ +do { \ + REG_AIC_FR &= ~AIC_FR_TFTH_MASK; \ + REG_AIC_FR |= ((n) << AIC_FR_TFTH_LSB); \ +} while(0) + +#define __aic_set_receive_trigger(n) \ +do { \ + REG_AIC_FR &= ~AIC_FR_RFTH_MASK; \ + REG_AIC_FR |= ((n) << AIC_FR_RFTH_LSB); \ +} while(0) + +#define __aic_enable_oldstyle() +#define __aic_enable_newstyle() +#define __aic_enable_pack16() ( REG_AIC_CR |= AIC_CR_PACK16 ) +#define __aic_enable_unpack16() ( REG_AIC_CR &= ~AIC_CR_PACK16) + +/* n = AIC_CR_CHANNEL_MONO,AIC_CR_CHANNEL_STEREO ... */ +#define __aic_out_channel_select(n) \ +do { \ + REG_AIC_CR &= ~AIC_CR_CHANNEL_MASK; \ + REG_AIC_CR |= ((n) << AIC_CR_CHANNEL_LSB ); \ +} while(0) + +#define __aic_enable_record() ( REG_AIC_CR |= AIC_CR_EREC ) +#define __aic_disable_record() ( REG_AIC_CR &= ~AIC_CR_EREC ) +#define __aic_enable_replay() ( REG_AIC_CR |= AIC_CR_ERPL ) +#define __aic_disable_replay() ( REG_AIC_CR &= ~AIC_CR_ERPL ) +#define __aic_enable_loopback() ( REG_AIC_CR |= AIC_CR_ENLBF ) +#define __aic_disable_loopback() ( REG_AIC_CR &= ~AIC_CR_ENLBF ) + +#define __aic_flush_tfifo() ( REG_AIC_CR |= AIC_CR_TFLUSH ) +#define __aic_unflush_tfifo() ( REG_AIC_CR &= ~AIC_CR_TFLUSH ) +#define __aic_flush_rfifo() ( REG_AIC_CR |= AIC_CR_RFLUSH ) +#define __aic_unflush_rfifo() ( REG_AIC_CR &= ~AIC_CR_RFLUSH ) + +#define __aic_enable_transmit_intr() \ + ( REG_AIC_CR |= (AIC_CR_ETFS | AIC_CR_ETUR) ) +#define __aic_disable_transmit_intr() \ + ( REG_AIC_CR &= ~(AIC_CR_ETFS | AIC_CR_ETUR) ) +#define __aic_enable_receive_intr() \ + ( REG_AIC_CR |= (AIC_CR_ERFS | AIC_CR_EROR) ) +#define __aic_disable_receive_intr() \ + ( REG_AIC_CR &= ~(AIC_CR_ERFS | AIC_CR_EROR) ) + +#define __aic_enable_transmit_dma() ( REG_AIC_CR |= AIC_CR_TDMS ) +#define __aic_disable_transmit_dma() ( REG_AIC_CR &= ~AIC_CR_TDMS ) +#define __aic_enable_receive_dma() ( REG_AIC_CR |= AIC_CR_RDMS ) +#define __aic_disable_receive_dma() ( REG_AIC_CR &= ~AIC_CR_RDMS ) + +#define __aic_enable_mono2stereo() ( REG_AIC_CR |= AIC_CR_M2S ) +#define __aic_disable_mono2stereo() ( REG_AIC_CR &= ~AIC_CR_M2S ) +#define __aic_enable_byteswap() ( REG_AIC_CR |= AIC_CR_ENDSW ) +#define __aic_disable_byteswap() ( REG_AIC_CR &= ~AIC_CR_ENDSW ) +#define __aic_enable_unsignadj() ( REG_AIC_CR |= AIC_CR_AVSTSU ) +#define __aic_disable_unsignadj() ( REG_AIC_CR &= ~AIC_CR_AVSTSU ) + +#define AC97_PCM_XS_L_FRONT AIC_ACCR1_XS_SLOT(3) +#define AC97_PCM_XS_R_FRONT AIC_ACCR1_XS_SLOT(4) +#define AC97_PCM_XS_CENTER AIC_ACCR1_XS_SLOT(6) +#define AC97_PCM_XS_L_SURR AIC_ACCR1_XS_SLOT(7) +#define AC97_PCM_XS_R_SURR AIC_ACCR1_XS_SLOT(8) +#define AC97_PCM_XS_LFE AIC_ACCR1_XS_SLOT(9) + +#define AC97_PCM_RS_L_FRONT AIC_ACCR1_RS_SLOT(3) +#define AC97_PCM_RS_R_FRONT AIC_ACCR1_RS_SLOT(4) +#define AC97_PCM_RS_CENTER AIC_ACCR1_RS_SLOT(6) +#define AC97_PCM_RS_L_SURR AIC_ACCR1_RS_SLOT(7) +#define AC97_PCM_RS_R_SURR AIC_ACCR1_RS_SLOT(8) +#define AC97_PCM_RS_LFE AIC_ACCR1_RS_SLOT(9) + +#define __ac97_set_xs_none() ( REG_AIC_ACCR1 &= ~AIC_ACCR1_XS_MASK ) +#define __ac97_set_xs_mono() \ +do { \ + REG_AIC_ACCR1 &= ~AIC_ACCR1_XS_MASK; \ + REG_AIC_ACCR1 |= AC97_PCM_XS_R_FRONT; \ +} while(0) +#define __ac97_set_xs_stereo() \ +do { \ + REG_AIC_ACCR1 &= ~AIC_ACCR1_XS_MASK; \ + REG_AIC_ACCR1 |= AC97_PCM_XS_L_FRONT | AC97_PCM_XS_R_FRONT; \ +} while(0) + +/* In fact, only stereo is support now. */ +#define __ac97_set_rs_none() ( REG_AIC_ACCR1 &= ~AIC_ACCR1_RS_MASK ) +#define __ac97_set_rs_mono() \ +do { \ + REG_AIC_ACCR1 &= ~AIC_ACCR1_RS_MASK; \ + REG_AIC_ACCR1 |= AC97_PCM_RS_R_FRONT; \ +} while(0) +#define __ac97_set_rs_stereo() \ +do { \ + REG_AIC_ACCR1 &= ~AIC_ACCR1_RS_MASK; \ + REG_AIC_ACCR1 |= AC97_PCM_RS_L_FRONT | AC97_PCM_RS_R_FRONT; \ +} while(0) + +#define __ac97_warm_reset_codec() \ + do { \ + REG_AIC_ACCR2 |= AIC_ACCR2_SA; \ + REG_AIC_ACCR2 |= AIC_ACCR2_SS; \ + udelay(2); \ + REG_AIC_ACCR2 &= ~AIC_ACCR2_SS; \ + REG_AIC_ACCR2 &= ~AIC_ACCR2_SA; \ + } while (0) + +#define __ac97_cold_reset_codec() \ + do { \ + REG_AIC_ACCR2 |= AIC_ACCR2_SR; \ + udelay(2); \ + REG_AIC_ACCR2 &= ~AIC_ACCR2_SR; \ + } while (0) + +/* n=8,16,18,20 */ +#define __ac97_set_iass(n) \ + ( REG_AIC_ACCR2 = (REG_AIC_ACCR2 & ~AIC_ACCR2_IASS_MASK) | AIC_ACCR2_IASS_##n##BIT ) +#define __ac97_set_oass(n) \ + ( REG_AIC_ACCR2 = (REG_AIC_ACCR2 & ~AIC_ACCR2_OASS_MASK) | AIC_ACCR2_OASS_##n##BIT ) + +/* This bit should only be set in 2 channels configuration */ +#define __i2s_send_rfirst() ( REG_AIC_I2SCR |= AIC_I2SCR_RFIRST ) /* RL */ +#define __i2s_send_lfirst() ( REG_AIC_I2SCR &= ~AIC_I2SCR_RFIRST ) /* LR */ + +/* This bit should only be set in 2 channels configuration and 16bit-packed mode */ +#define __i2s_switch_lr() ( REG_AIC_I2SCR |= AIC_I2SCR_SWLH ) +#define __i2s_unswitch_lr() ( REG_AIC_I2SCR &= ~AIC_I2SCR_SWLH ) + +#define __i2s_select_i2s() ( REG_AIC_I2SCR &= ~AIC_I2SCR_AMSL ) +#define __i2s_select_msbjustified() ( REG_AIC_I2SCR |= AIC_I2SCR_AMSL ) + +/* n=8,16,18,20,24 */ +/*#define __i2s_set_sample_size(n) \ + ( REG_AIC_I2SCR |= (REG_AIC_I2SCR & ~AIC_I2SCR_WL_MASK) | AIC_I2SCR_WL_##n##BIT )*/ + +#define __i2s_out_channel_select(n) __aic_out_channel_select(n) + +#define __i2s_set_oss_sample_size(n) \ + ( REG_AIC_CR = (REG_AIC_CR & ~AIC_CR_OSS_MASK) | AIC_CR_OSS(n)) +#define __i2s_set_iss_sample_size(n) \ + ( REG_AIC_CR = (REG_AIC_CR & ~AIC_CR_ISS_MASK) | AIC_CR_ISS(n)) + +#define __i2s_stop_bitclk() ( REG_AIC_I2SCR |= AIC_I2SCR_STPBK ) +#define __i2s_start_bitclk() ( REG_AIC_I2SCR &= ~AIC_I2SCR_STPBK ) + +#define __aic_transmit_request() ( REG_AIC_SR & AIC_SR_TFS ) +#define __aic_receive_request() ( REG_AIC_SR & AIC_SR_RFS ) +#define __aic_transmit_underrun() ( REG_AIC_SR & AIC_SR_TUR ) +#define __aic_receive_overrun() ( REG_AIC_SR & AIC_SR_ROR ) + +#define __aic_clear_errors() ( REG_AIC_SR &= ~(AIC_SR_TUR | AIC_SR_ROR) ) + +#define __aic_get_transmit_resident() \ + ( (REG_AIC_SR & AIC_SR_TFL_MASK) >> AIC_SR_TFL_LSB ) +#define __aic_get_receive_count() \ + ( (REG_AIC_SR & AIC_SR_RFL_MASK) >> AIC_SR_RFL_LSB ) + +#define __ac97_command_transmitted() ( REG_AIC_ACSR & AIC_ACSR_CADT ) +#define __ac97_status_received() ( REG_AIC_ACSR & AIC_ACSR_SADR ) +#define __ac97_status_receive_timeout() ( REG_AIC_ACSR & AIC_ACSR_RSTO ) +#define __ac97_codec_is_low_power_mode() ( REG_AIC_ACSR & AIC_ACSR_CLPM ) +#define __ac97_codec_is_ready() ( REG_AIC_ACSR & AIC_ACSR_CRDY ) +#define __ac97_slot_error_detected() ( REG_AIC_ACSR & AIC_ACSR_SLTERR ) +#define __ac97_clear_slot_error() ( REG_AIC_ACSR &= ~AIC_ACSR_SLTERR ) + +#define __i2s_is_busy() ( REG_AIC_I2SSR & AIC_I2SSR_BSY ) + +#define __ac97_out_rcmd_addr(reg) \ +do { \ + REG_AIC_ACCAR = AC97_READ_CMD | ((reg) << AC97_INDEX_LSB); \ +} while (0) + +#define __ac97_out_wcmd_addr(reg) \ +do { \ + REG_AIC_ACCAR = AC97_WRITE_CMD | ((reg) << AC97_INDEX_LSB); \ +} while (0) + +#define __ac97_out_data(value) \ +do { \ + REG_AIC_ACCDR = ((value) << AC97_DATA_LSB); \ +} while (0) + +#define __ac97_in_data() \ + ( (REG_AIC_ACSDR & CODEC_REG_DATA_MASK) >> AC97_DATA_LSB ) + +#define __ac97_in_status_addr() \ + ( (REG_AIC_ACSAR & AC97_INDEX_MASK) >> AC97_INDEX_LSB ) + +#define __i2s_set_sample_rate(i2sclk, sync) \ + ( REG_AIC_I2SDIV = ((i2sclk) / (4*64)) / (sync) ) + +#define __i2s_set_i2sdiv(n) \ + ( REG_AIC_I2SDIV = (n) ) + +#define __aic_write_tfifo(v) ( REG_AIC_DR = (v) ) +#define __aic_read_rfifo() ( REG_AIC_DR ) + +#define __aic_internal_codec() ( REG_AIC_FR |= AIC_FR_ICDC ) +#define __aic_external_codec() ( REG_AIC_FR &= ~AIC_FR_ICDC ) + +// +// Define next ops for AC97 compatible +// + +#define AC97_ACSR AIC_ACSR + +#define __ac97_enable() __aic_enable(); __aic_select_ac97() +#define __ac97_disable() __aic_disable() +#define __ac97_reset() __aic_reset() + +#define __ac97_set_transmit_trigger(n) __aic_set_transmit_trigger(n) +#define __ac97_set_receive_trigger(n) __aic_set_receive_trigger(n) + +#define __ac97_enable_record() __aic_enable_record() +#define __ac97_disable_record() __aic_disable_record() +#define __ac97_enable_replay() __aic_enable_replay() +#define __ac97_disable_replay() __aic_disable_replay() +#define __ac97_enable_loopback() __aic_enable_loopback() +#define __ac97_disable_loopback() __aic_disable_loopback() + +#define __ac97_enable_transmit_dma() __aic_enable_transmit_dma() +#define __ac97_disable_transmit_dma() __aic_disable_transmit_dma() +#define __ac97_enable_receive_dma() __aic_enable_receive_dma() +#define __ac97_disable_receive_dma() __aic_disable_receive_dma() + +#define __ac97_transmit_request() __aic_transmit_request() +#define __ac97_receive_request() __aic_receive_request() +#define __ac97_transmit_underrun() __aic_transmit_underrun() +#define __ac97_receive_overrun() __aic_receive_overrun() + +#define __ac97_clear_errors() __aic_clear_errors() + +#define __ac97_get_transmit_resident() __aic_get_transmit_resident() +#define __ac97_get_receive_count() __aic_get_receive_count() + +#define __ac97_enable_transmit_intr() __aic_enable_transmit_intr() +#define __ac97_disable_transmit_intr() __aic_disable_transmit_intr() +#define __ac97_enable_receive_intr() __aic_enable_receive_intr() +#define __ac97_disable_receive_intr() __aic_disable_receive_intr() + +#define __ac97_write_tfifo(v) __aic_write_tfifo(v) +#define __ac97_read_rfifo() __aic_read_rfifo() + +// +// Define next ops for I2S compatible +// + +#define I2S_ACSR AIC_I2SSR + +#define __i2s_enable() __aic_enable(); __aic_select_i2s() +#define __i2s_disable() __aic_disable() +#define __i2s_reset() __aic_reset() + +#define __i2s_set_transmit_trigger(n) __aic_set_transmit_trigger(n) +#define __i2s_set_receive_trigger(n) __aic_set_receive_trigger(n) + +#define __i2s_enable_record() __aic_enable_record() +#define __i2s_disable_record() __aic_disable_record() +#define __i2s_enable_replay() __aic_enable_replay() +#define __i2s_disable_replay() __aic_disable_replay() +#define __i2s_enable_loopback() __aic_enable_loopback() +#define __i2s_disable_loopback() __aic_disable_loopback() + +#define __i2s_enable_transmit_dma() __aic_enable_transmit_dma() +#define __i2s_disable_transmit_dma() __aic_disable_transmit_dma() +#define __i2s_enable_receive_dma() __aic_enable_receive_dma() +#define __i2s_disable_receive_dma() __aic_disable_receive_dma() + +#define __i2s_transmit_request() __aic_transmit_request() +#define __i2s_receive_request() __aic_receive_request() +#define __i2s_transmit_underrun() __aic_transmit_underrun() +#define __i2s_receive_overrun() __aic_receive_overrun() + +#define __i2s_clear_errors() __aic_clear_errors() + +#define __i2s_get_transmit_resident() __aic_get_transmit_resident() +#define __i2s_get_receive_count() __aic_get_receive_count() + +#define __i2s_enable_transmit_intr() __aic_enable_transmit_intr() +#define __i2s_disable_transmit_intr() __aic_disable_transmit_intr() +#define __i2s_enable_receive_intr() __aic_enable_receive_intr() +#define __i2s_disable_receive_intr() __aic_disable_receive_intr() + +#define __i2s_write_tfifo(v) __aic_write_tfifo(v) +#define __i2s_read_rfifo() __aic_read_rfifo() + +#define __i2s_enable_pack16() __aic_enable_pack16() +#define __i2s_enable_unpack16() __aic_enable_unpack16() + +#define __i2s_reset_codec() \ + do { \ + } while (0) + +/************************************************************************* + * SPDIF INTERFACE in AIC Controller + *************************************************************************/ + +#define __spdif_enable() ( REG_SPDIF_ENA |= SPDIF_ENA_SPEN ) +#define __spdif_disable() ( REG_SPDIF_ENA &= ~SPDIF_ENA_SPEN ) + +#define __spdif_enable_transmit_dma() ( REG_SPDIF_CTRL |= SPDIF_CTRL_DMAEN ) +#define __spdif_disable_transmit_dma() ( REG_SPDIF_CTRL &= ~SPDIF_CTRL_DMAEN ) +#define __spdif_enable_dtype() ( REG_SPDIF_CTRL |= SPDIF_CTRL_DTYPE ) +#define __spdif_disable_dtype() ( REG_SPDIF_CTRL &= ~SPDIF_CTRL_DTYPE ) +#define __spdif_enable_sign() ( REG_SPDIF_CTRL |= SPDIF_CTRL_SIGN ) +#define __spdif_disable_sign() ( REG_SPDIF_CTRL &= ~SPDIF_CTRL_SIGN ) +#define __spdif_enable_invalid() ( REG_SPDIF_CTRL |= SPDIF_CTRL_INVALID ) +#define __spdif_disable_invalid() ( REG_SPDIF_CTRL &= ~SPDIF_CTRL_INVALID ) +#define __spdif_enable_reset() ( REG_SPDIF_CTRL |= SPDIF_CTRL_RST ) +#define __spdif_select_spdif() ( REG_SPDIF_CTRL |= SPDIF_CTRL_SPDIFI2S ) +#define __spdif_select_i2s() ( REG_SPDIF_CTRL &= ~SPDIF_CTRL_SPDIFI2S ) +#define __spdif_enable_MTRIGmask() ( REG_SPDIF_CTRL |= SPDIF_CTRL_MTRIG ) +#define __spdif_disable_MTRIGmask() ( REG_SPDIF_CTRL &= ~SPDIF_CTRL_MTRIG ) +#define __spdif_enable_MFFURmask() ( REG_SPDIF_CTRL |= SPDIF_CTRL_MFFUR ) +#define __spdif_disable_MFFURmask() ( REG_SPDIF_CTRL &= ~SPDIF_CTRL_MFFUR ) + +#define __spdif_enable_initlvl_high() ( REG_SPDIF_CFG1 |= SPDIF_CFG1_INITLVL ) +#define __spdif_enable_initlvl_low() ( REG_SPDIF_CFG1 &= ~SPDIF_CFG1_INITLVL ) +#define __spdif_enable_zrovld_invald() ( REG_SPDIF_CFG1 |= SPDIF_CFG1_ZROVLD ) +#define __spdif_enable_zrovld_vald() ( REG_SPDIF_CFG1 &= ~SPDIF_CFG1_ZROVLD ) + +/* 0, 1, 2, 3 */ +#define __spdif_set_transmit_trigger(n) \ +do { \ + REG_SPDIF_CFG1 &= ~SPDIF_CFG1_TRIG_MASK; \ + REG_SPDIF_CFG1 |= SPDIF_CFG1_TRIG(n); \ +} while(0) + +/* 1 ~ 15 */ +#define __spdif_set_srcnum(n) \ +do { \ + REG_SPDIF_CFG1 &= ~SPDIF_CFG1_SRCNUM_MASK; \ + REG_SPDIF_CFG1 |= ((n) << SPDIF_CFG1_SRCNUM_LSB); \ +} while(0) + +/* 1 ~ 15 */ +#define __spdif_set_ch1num(n) \ +do { \ + REG_SPDIF_CFG1 &= ~SPDIF_CFG1_CH1NUM_MASK; \ + REG_SPDIF_CFG1 |= ((n) << SPDIF_CFG1_CH1NUM_LSB); \ +} while(0) + +/* 1 ~ 15 */ +#define __spdif_set_ch2num(n) \ +do { \ + REG_SPDIF_CFG1 &= ~SPDIF_CFG1_CH2NUM_MASK; \ + REG_SPDIF_CFG1 |= ((n) << SPDIF_CFG1_CH2NUM_LSB); \ +} while(0) + +/* 0x0, 0x2, 0x3, 0xa, 0xe */ +#define __spdif_set_fs(n) \ +do { \ + REG_SPDIF_CFG2 &= ~SPDIF_CFG2_FS_MASK; \ + REG_SPDIF_CFG2 |= ((n) << SPDIF_CFG2_FS_LSB); \ +} while(0) + +/* 0xd, 0xc, 0x5, 0x1 */ +#define __spdif_set_orgfrq(n) \ +do { \ + REG_SPDIF_CFG2 &= ~SPDIF_CFG2_ORGFRQ_MASK; \ + REG_SPDIF_CFG2 |= ((n) << SPDIF_CFG2_ORGFRQ_LSB); \ +} while(0) + +/* 0x1, 0x6, 0x2, 0x4, 0x5 */ +#define __spdif_set_samwl(n) \ +do { \ + REG_SPDIF_CFG2 &= ~SPDIF_CFG2_SAMWL_MASK; \ + REG_SPDIF_CFG2 |= ((n) << SPDIF_CFG2_SAMWL_LSB); \ +} while(0) + +#define __spdif_enable_samwl_24() ( REG_SPDIF_CFG2 |= SPDIF_CFG2_MAXWL ) +#define __spdif_enable_samwl_20() ( REG_SPDIF_CFG1 &= ~SPDIF_CFG2_MAXWL ) + +/* 0x1, 0x1, 0x2, 0x3 */ +#define __spdif_set_clkacu(n) \ +do { \ + REG_SPDIF_CFG2 &= ~SPDIF_CFG2_CLKACU_MASK; \ + REG_SPDIF_CFG2 |= ((n) << SPDIF_CFG2_CLKACU_LSB); \ +} while(0) + +/* see IEC60958-3 */ +#define __spdif_set_catcode(n) \ +do { \ + REG_SPDIF_CFG2 &= ~SPDIF_CFG2_CATCODE_MASK; \ + REG_SPDIF_CFG2 |= ((n) << SPDIF_CFG2_CATCODE_LSB); \ +} while(0) + +/* n = 0x0, */ +#define __spdif_set_chmode(n) \ +do { \ + REG_SPDIF_CFG2 &= ~SPDIF_CFG2_CHMD_MASK; \ + REG_SPDIF_CFG2 |= ((n) << SPDIF_CFG2_CHMD_LSB); \ +} while(0) + +#define __spdif_enable_pre() ( REG_SPDIF_CFG2 |= SPDIF_CFG2_PRE ) +#define __spdif_disable_pre() ( REG_SPDIF_CFG2 &= ~SPDIF_CFG2_PRE ) +#define __spdif_enable_copyn() ( REG_SPDIF_CFG2 |= SPDIF_CFG2_COPYN ) +#define __spdif_disable_copyn() ( REG_SPDIF_CFG2 &= ~SPDIF_CFG2_COPYN ) +/* audio sample word represents linear PCM samples */ +#define __spdif_enable_audion() ( REG_SPDIF_CFG2 &= ~SPDIF_CFG2_AUDION ) +/* udio sample word used for other purpose */ +#define __spdif_disable_audion() ( REG_SPDIF_CFG2 |= SPDIF_CFG2_AUDION ) +#define __spdif_enable_conpro() ( REG_SPDIF_CFG2 &= ~SPDIF_CFG2_CONPRO ) +#define __spdif_disable_conpro() ( REG_SPDIF_CFG2 |= SPDIF_CFG2_CONPRO ) + +/*************************************************************************** + * ICDC + ***************************************************************************/ +#define __i2s_internal_codec() __aic_internal_codec() +#define __i2s_external_codec() __aic_external_codec() + +#define __icdc_clk_ready() ( REG_ICDC_CKCFG & ICDC_CKCFG_CKRDY ) +#define __icdc_sel_adc() ( REG_ICDC_CKCFG |= ICDC_CKCFG_SELAD ) +#define __icdc_sel_dac() ( REG_ICDC_CKCFG &= ~ICDC_CKCFG_SELAD ) + +#define __icdc_set_rgwr() ( REG_ICDC_RGADW |= ICDC_RGADW_RGWR ) +#define __icdc_clear_rgwr() ( REG_ICDC_RGADW &= ~ICDC_RGADW_RGWR ) +#define __icdc_rgwr_ready() ( REG_ICDC_RGADW & ICDC_RGADW_RGWR ) + +#define __icdc_set_addr(n) \ +do { \ + REG_ICDC_RGADW &= ~ICDC_RGADW_RGADDR_MASK; \ + REG_ICDC_RGADW |= (n) << ICDC_RGADW_RGADDR_LSB; \ +} while(0) + +#define __icdc_set_cmd(n) \ +do { \ + REG_ICDC_RGADW &= ~ICDC_RGADW_RGDIN_MASK; \ + REG_ICDC_RGADW |= (n) << ICDC_RGADW_RGDIN_LSB; \ +} while(0) + +#define __icdc_irq_pending() ( REG_ICDC_RGDATA & ICDC_RGDATA_IRQ ) +#define __icdc_get_value() ( REG_ICDC_RGDATA & ICDC_RGDATA_RGDOUT_MASK ) + +#endif /* __MIPS_ASSEMBLER */ + +/* + * Bose-Chaudhuri-Hocquenghem controller module(BCH) address definition + */ +#define BCH_BASE 0xb34d0000 + +/* + * BCH registers offset addresses definition + */ +#define BCH_BHCR_OFFSET (0x00) /* r, 32, 0x00000000 */ +#define BCH_BHCSR_OFFSET (0x04) /* w, 32, 0x???????? */ +#define BCH_BHCCR_OFFSET (0x08) /* w, 32, 0x???????? */ +#define BCH_BHCNT_OFFSET (0x0c) /* rw, 32, 0x00000000 */ +#define BCH_BHDR_OFFSET (0x10) /* w, 8, 0x???????? */ +#define BCH_BHPAR0_OFFSET (0x14) /* rw, 32, 0x00000000 */ +#define BCH_BHPAR1_OFFSET (0x18) /* rw, 32, 0x00000000 */ +#define BCH_BHPAR2_OFFSET (0x1c) /* rw, 32, 0x00000000 */ +#define BCH_BHPAR3_OFFSET (0x20) /* rw, 32, 0x00000000 */ +#define BCH_BHPAR4_OFFSET (0x24) /* rw, 32, 0x00000000 */ +#define BCH_BHPAR5_OFFSET (0x28) /* rw, 32, 0x00000000 */ +#define BCH_BHPAR6_OFFSET (0x2c) /* rw, 32, 0x00000000 */ +#define BCH_BHPAR7_OFFSET (0x30) /* rw, 32, 0x00000000 */ +#define BCH_BHPAR8_OFFSET (0x34) /* rw, 32, 0x00000000 */ +#define BCH_BHPAR9_OFFSET (0x38) /* rw, 32, 0x00000000 */ +#define BCH_BHERR0_OFFSET (0x3c) /* r, 32, 0x00000000 */ +#define BCH_BHERR1_OFFSET (0x40) /* r, 32, 0x00000000 */ +#define BCH_BHERR2_OFFSET (0x44) /* r, 32, 0x00000000 */ +#define BCH_BHERR3_OFFSET (0x48) /* r, 32, 0x00000000 */ +#define BCH_BHERR4_OFFSET (0x4c) /* r, 32, 0x00000000 */ +#define BCH_BHERR5_OFFSET (0x50) /* r, 32, 0x00000000 */ +#define BCH_BHERR6_OFFSET (0x54) /* r, 32, 0x00000000 */ +#define BCH_BHERR7_OFFSET (0x58) /* r, 32, 0x00000000 */ +#define BCH_BHERR8_OFFSET (0x5c) /* r, 32, 0x00000000 */ +#define BCH_BHERR9_OFFSET (0x60) /* r, 32, 0x00000000 */ +#define BCH_BHERR10_OFFSET (0x64) /* r, 32, 0x00000000 */ +#define BCH_BHERR11_OFFSET (0x68) /* r, 32, 0x00000000 */ +#define BCH_BHINT_OFFSET (0x6c) /* r, 32, 0x00000000 */ +#define BCH_BHINTE_OFFSET (0x70) /* rw, 32, 0x00000000 */ +#define BCH_BHINTES_OFFSET (0x74) /* w, 32, 0x???????? */ +#define BCH_BHINTEC_OFFSET (0x78) /* w, 32, 0x???????? */ + +/* + * BCH registers addresses definition + */ +#define BCH_BHCR (BCH_BASE + BCH_BHCR_OFFSET) +#define BCH_BHCSR (BCH_BASE + BCH_BHCSR_OFFSET) +#define BCH_BHCCR (BCH_BASE + BCH_BHCCR_OFFSET) +#define BCH_BHCNT (BCH_BASE + BCH_BHCNT_OFFSET) +#define BCH_BHDR (BCH_BASE + BCH_BHDR_OFFSET) +#define BCH_BHPAR0 (BCH_BASE + BCH_BHPAR0_OFFSET) +#define BCH_BHPAR1 (BCH_BASE + BCH_BHPAR1_OFFSET) +#define BCH_BHPAR2 (BCH_BASE + BCH_BHPAR2_OFFSET) +#define BCH_BHPAR3 (BCH_BASE + BCH_BHPAR3_OFFSET) +#define BCH_BHPAR4 (BCH_BASE + BCH_BHPAR4_OFFSET) +#define BCH_BHPAR5 (BCH_BASE + BCH_BHPAR5_OFFSET) +#define BCH_BHPAR6 (BCH_BASE + BCH_BHPAR6_OFFSET) +#define BCH_BHPAR7 (BCH_BASE + BCH_BHPAR7_OFFSET) +#define BCH_BHPAR8 (BCH_BASE + BCH_BHPAR8_OFFSET) +#define BCH_BHPAR9 (BCH_BASE + BCH_BHPAR9_OFFSET) +#define BCH_BHERR0 (BCH_BASE + BCH_BHERR0_OFFSET) +#define BCH_BHERR1 (BCH_BASE + BCH_BHERR1_OFFSET) +#define BCH_BHERR2 (BCH_BASE + BCH_BHERR2_OFFSET) +#define BCH_BHERR3 (BCH_BASE + BCH_BHERR3_OFFSET) +#define BCH_BHERR4 (BCH_BASE + BCH_BHERR4_OFFSET) +#define BCH_BHERR5 (BCH_BASE + BCH_BHERR5_OFFSET) +#define BCH_BHERR6 (BCH_BASE + BCH_BHERR6_OFFSET) +#define BCH_BHERR7 (BCH_BASE + BCH_BHERR7_OFFSET) +#define BCH_BHERR8 (BCH_BASE + BCH_BHERR8_OFFSET) +#define BCH_BHERR9 (BCH_BASE + BCH_BHERR9_OFFSET) +#define BCH_BHERR10 (BCH_BASE + BCH_BHERR10_OFFSET) +#define BCH_BHERR11 (BCH_BASE + BCH_BHERR11_OFFSET) +#define BCH_BHINT (BCH_BASE + BCH_BHINT_OFFSET) +#define BCH_BHINTES (BCH_BASE + BCH_BHINTES_OFFSET) +#define BCH_BHINTEC (BCH_BASE + BCH_BHINTEC_OFFSET) +#define BCH_BHINTE (BCH_BASE + BCH_BHINTE_OFFSET) + +/* + * BCH registers common define + */ + +/* BCH control register (BHCR) */ +#define BHCR_DMAE BIT7 /* BCH DMA enable */ +#define BHCR_ENCE BIT2 +#define BHCR_BRST BIT1 /* BCH reset */ +#define BHCR_BCHE BIT0 /* BCH enable */ + +#define BHCR_BSEL_LSB 3 +#define BHCR_BSEL_MASK BITS_H2L(5, BHCR_BSEL_LSB) + #define BHCR_BSEL(n) (((n)/4 - 1) << BHCR_BSEL_LSB) /* n = 4, 8, 12, 16, 20, 24 */ + +/* BCH interrupt status register (BHINT) */ +#define BHINT_ALL_F BIT4 +#define BHINT_DECF BIT3 +#define BHINT_ENCF BIT2 +#define BHINT_UNCOR BIT1 +#define BHINT_ERR BIT0 + +#define BHINT_ERRC_LSB 27 +#define BHINT_ERRC_MASK BITS_H2L(31, BHINT_ERRC_LSB) + +/* BCH ENC/DEC count register (BHCNT) */ +#define BHCNT_DEC_LSB 16 +#define BHCNT_DEC_MASK BITS_H2L(26, BHCNT_DEC_LSB) + +#define BHCNT_ENC_LSB 0 +#define BHCNT_ENC_MASK BITS_H2L(10, BHCNT_ENC_LSB) + +/* BCH error report register (BCHERR)*/ +#define BCH_ERR_INDEX_LSB 0 +#define BCH_ERR_INDEX_MASK BITS_H2L(12, BCH_ERR_INDEX_LSB) + +/* BCH common macro define */ +#define BCH_ENCODE 1 +#define BCH_DECODE 0 + +#ifndef __MIPS_ASSEMBLER + +#define REG_BCH_BHCR REG32(BCH_BHCR) +#define REG_BCH_BHCSR REG32(BCH_BHCSR) +#define REG_BCH_BHCCR REG32(BCH_BHCCR) +#define REG_BCH_BHCNT REG32(BCH_BHCNT) +#define REG_BCH_BHDR REG8(BCH_BHDR) +#define REG_BCH_BHPAR0 REG32(BCH_BHPAR0) +#define REG_BCH_BHPAR1 REG32(BCH_BHPAR1) +#define REG_BCH_BHPAR2 REG32(BCH_BHPAR2) +#define REG_BCH_BHPAR3 REG32(BCH_BHPAR3) +#define REG_BCH_BHPAR4 REG32(BCH_BHPAR4) +#define REG_BCH_BHPAR5 REG32(BCH_BHPAR5) +#define REG_BCH_BHPAR6 REG32(BCH_BHPAR6) +#define REG_BCH_BHPAR7 REG32(BCH_BHPAR7) +#define REG_BCH_BHPAR8 REG32(BCH_BHPAR8) +#define REG_BCH_BHPAR9 REG32(BCH_BHPAR9) +#define REG_BCH_BHERR0 REG32(BCH_BHERR0) +#define REG_BCH_BHERR1 REG32(BCH_BHERR1) +#define REG_BCH_BHERR2 REG32(BCH_BHERR2) +#define REG_BCH_BHERR3 REG32(BCH_BHERR3) +#define REG_BCH_BHERR4 REG32(BCH_BHERR4) +#define REG_BCH_BHERR5 REG32(BCH_BHERR5) +#define REG_BCH_BHERR6 REG32(BCH_BHERR6) +#define REG_BCH_BHERR7 REG32(BCH_BHERR7) +#define REG_BCH_BHERR8 REG32(BCH_BHERR8) +#define REG_BCH_BHERR9 REG32(BCH_BHERR9) +#define REG_BCH_BHERR10 REG32(BCH_BHERR10) +#define REG_BCH_BHERR11 REG32(BCH_BHERR11) +#define REG_BCH_BHINT REG32(BCH_BHINT) +#define REG_BCH_BHINTE REG32(BCH_BHINTE) +#define REG_BCH_BHINTEC REG32(BCH_BHINTEC) +#define REG_BCH_BHINTES REG32(BCH_BHINTES) + +#define __ecc_enable(encode, bit) \ +do { \ + unsigned int tmp = BHCR_BRST | BHCR_BCHE; \ + if (encode) \ + tmp |= BHCR_ENCE; \ + tmp |= BHCR_BSEL(bit); \ + REG_BCH_BHCSR = tmp; \ + REG_BCH_BHCCR = ~tmp; \ +} while (0) +#define __ecc_disable() (REG_BCH_BHCCR = BHCR_BCHE) + +#define __ecc_dma_enable() (REG_BCH_BHCSR = BHCR_DMAE) +#define __ecc_dma_disable() (REG_BCH_BHCCR = BHCR_DMAE) + +#define __ecc_cnt_enc(n) CMSREG32(BCH_BHCNT, (n) << BHCNT_ENC_LSB, BHCNT_ENC_MASK) +#define __ecc_cnt_dec(n) CMSREG32(BCH_BHCNT, (n) << BHCNT_DEC_LSB, BHCNT_DEC_MASK) + +#define __ecc_encode_sync() \ +do { \ + unsigned int i = 1; \ + while (!(REG_BCH_BHINT & BHINT_ENCF) && i++); \ +} while (0) + +#define __ecc_decode_sync() \ +do { \ + unsigned int i = 1; \ + while (!(REG_BCH_BHINT & BHINT_DECF) && i++); \ +} while (0) + +#endif /* __MIPS_ASSEMBLER */ + +#define BDMAC_BASE 0xB3450000 + +/************************************************************************* + * BDMAC (BCH & NAND DMA Controller) + *************************************************************************/ + +/* n is the DMA channel index (0 - 2) */ +#define BDMAC_DSAR(n) (BDMAC_BASE + (0x00 + (n) * 0x20)) /* DMA source address */ +#define BDMAC_DTAR(n) (BDMAC_BASE + (0x04 + (n) * 0x20)) /* DMA target address */ +#define BDMAC_DTCR(n) (BDMAC_BASE + (0x08 + (n) * 0x20)) /* DMA transfer count */ +#define BDMAC_DRSR(n) (BDMAC_BASE + (0x0c + (n) * 0x20)) /* DMA request source */ +#define BDMAC_DCCSR(n) (BDMAC_BASE + (0x10 + (n) * 0x20)) /* DMA control/status */ +#define BDMAC_DCMD(n) (BDMAC_BASE + (0x14 + (n) * 0x20)) /* DMA command */ +#define BDMAC_DDA(n) (BDMAC_BASE + (0x18 + (n) * 0x20)) /* DMA descriptor address */ +#define BDMAC_DSD(n) (BDMAC_BASE + (0x1c + (n) * 0x20)) /* DMA Stride Address */ +#define BDMAC_DNT(n) (BDMAC_BASE + (0xc0 + (n) * 0x04)) /* NAND Detect Timer */ + +#define BDMAC_DMACR (BDMAC_BASE + 0x0300) /* DMA control register */ +#define BDMAC_DMAIPR (BDMAC_BASE + 0x0304) /* DMA interrupt pending */ +#define BDMAC_DMADBR (BDMAC_BASE + 0x0308) /* DMA doorbell */ +#define BDMAC_DMADBSR (BDMAC_BASE + 0x030C) /* DMA doorbell set */ +#define BDMAC_DMACKE (BDMAC_BASE + 0x0310) +#define BDMAC_DMACKES (BDMAC_BASE + 0x0314) +#define BDMAC_DMACKEC (BDMAC_BASE + 0x0318) + +#define REG_BDMAC_DSAR(n) REG32(BDMAC_DSAR((n))) +#define REG_BDMAC_DTAR(n) REG32(BDMAC_DTAR((n))) +#define REG_BDMAC_DTCR(n) REG32(BDMAC_DTCR((n))) +#define REG_BDMAC_DRSR(n) REG32(BDMAC_DRSR((n))) +#define REG_BDMAC_DCCSR(n) REG32(BDMAC_DCCSR((n))) +#define REG_BDMAC_DCMD(n) REG32(BDMAC_DCMD((n))) +#define REG_BDMAC_DDA(n) REG32(BDMAC_DDA((n))) +#define REG_BDMAC_DSD(n) REG32(BDMAC_DSD(n)) +#define REG_BDMAC_DNT(n) REG32(BDMAC_DNT(n)) + +#define REG_BDMAC_DMACR REG32(BDMAC_DMACR) +#define REG_BDMAC_DMAIPR REG32(BDMAC_DMAIPR) +#define REG_BDMAC_DMADBR REG32(BDMAC_DMADBR) +#define REG_BDMAC_DMADBSR REG32(BDMAC_DMADBSR) +#define REG_BDMAC_DMACKE REG32(BDMAC_DMACKE) +#define REG_BDMAC_DMACKES REG32(BDMAC_DMACKES) +#define REG_BDMAC_DMACKEC REG32(BDMAC_DMACKEC) + +// BDMA request source register +#define BDMAC_DRSR_RS_BIT 0 + #define BDMAC_DRSR_RS_MASK (0x3f << DMAC_DRSR_RS_BIT) + #define BDMAC_DRSR_RS_BCH_ENC (2 << DMAC_DRSR_RS_BIT) + #define BDMAC_DRSR_RS_BCH_DEC (3 << DMAC_DRSR_RS_BIT) + #define BDMAC_DRSR_RS_NAND0 (6 << DMAC_DRSR_RS_BIT) + #define BDMAC_DRSR_RS_NAND1 (7 << DMAC_DRSR_RS_BIT) + #define BDMAC_DRSR_RS_NAND (BDMAC_DRSR_RS_NAND0) + #define BDMAC_DRSR_RS_AUTO (8 << DMAC_DRSR_RS_BIT) + #define BDMAC_DRSR_RS_EXT (12 << DMAC_DRSR_RS_BIT) + +// BDMA channel control/status register +#define BDMAC_DCCSR_NDES (1 << 31) /* descriptor (0) or not (1) ? */ +#define BDMAC_DCCSR_DES8 (1 << 30) /* Descriptor 8 Word */ +#define BDMAC_DCCSR_DES4 (0 << 30) /* Descriptor 4 Word */ +#define BDMAC_DCCSR_LASTMD_BIT 28 +#define BDMAC_DCCSR_LASTMD_MASK (0x3 << BDMAC_DCCSR_LASTMD_BIT) +#define BDMAC_DCCSR_LASTMD0 (0 << 28) /* BCH Decoding last mode 0, there's one descriptor for decoding blcok*/ +#define BDMAC_DCCSR_LASTMD1 (1 << 28) /* BCH Decoding last mode 1, there's two descriptor for decoding blcok*/ +#define BDMAC_DCCSR_LASTMD2 (2 << 28) /* BCH Decoding last mode 2, there's three descriptor for decoding blcok*/ +#define BDMAC_DCCSR_FRBS(n) ((n) << 24) +#define BDMAC_DCCSR_FRBS_BIT 24 +#define BDMAC_DCCSR_FRBS_MASK (0x7 << BDMAC_DCCSR_FRBS_BIT) +#define BDMAC_DCCSR_CDOA_BIT 16 /* copy of DMA offset address */ +#define BDMAC_DCCSR_CDOA_MASK (0xff << BDMACC_DCCSR_CDOA_BIT) +#define BDMAC_DCCSR_BERR_BIT 7 +#define BDMAC_DCCSR_BERR_MASK (0x1f << BDMAC_DCCSR_BERR_BIT) +#define BDMAC_DCCSR_BUERR (1 << 5) +#define BDMAC_DCCSR_AR (1 << 4) /* address error */ +#define BDMAC_DCCSR_TT (1 << 3) /* transfer terminated */ +#define BDMAC_DCCSR_HLT (1 << 2) /* DMA halted */ +#define BDMAC_DCCSR_BAC (1 << 1) +#define BDMAC_DCCSR_EN (1 << 0) /* channel enable bit */ + +// BDMA channel command register +#define BDMAC_DCMD_EACKS_LOW (1 << 31) /* External DACK Output Level Select, active low */ +#define BDMAC_DCMD_EACKS_HIGH (0 << 31) /* External DACK Output Level Select, active high */ +#define BDMAC_DCMD_EACKM_WRITE (1 << 30) /* External DACK Output Mode Select, output in write cycle */ +#define BDMAC_DCMD_EACKM_READ (0 << 30) /* External DACK Output Mode Select, output in read cycle */ +#define BDMAC_DCMD_ERDM_BIT 28 /* External DREQ Detection Mode Select */ + #define BDMAC_DCMD_ERDM_MASK (0x03 << BDMAC_DCMD_ERDM_BIT) + #define BDMAC_DCMD_ERDM_LOW (0 << BDMAC_DCMD_ERDM_BIT) + #define BDMAC_DCMD_ERDM_FALL (1 << BDMAC_DCMD_ERDM_BIT) + #define BDMAC_DCMD_ERDM_HIGH (2 << BDMAC_DCMD_ERDM_BIT) + #define BDMAC_DCMD_ERDM_RISE (3 << BDMAC_DCMD_ERDM_BIT) +#define BDMAC_DCMD_BLAST (1 << 25) /* BCH last */ +#define BDMAC_DCMD_SAI (1 << 23) /* source address increment */ +#define BDMAC_DCMD_DAI (1 << 22) /* dest address increment */ +#define BDMAC_DCMD_SWDH_BIT 14 /* source port width */ + #define BDMAC_DCMD_SWDH_MASK (0x03 << BDMAC_DCMD_SWDH_BIT) + #define BDMAC_DCMD_SWDH_32 (0 << BDMAC_DCMD_SWDH_BIT) + #define BDMAC_DCMD_SWDH_8 (1 << BDMAC_DCMD_SWDH_BIT) + #define BDMAC_DCMD_SWDH_16 (2 << BDMAC_DCMD_SWDH_BIT) +#define BDMAC_DCMD_DWDH_BIT 12 /* dest port width */ + #define BDMAC_DCMD_DWDH_MASK (0x03 << BDMAC_DCMD_DWDH_BIT) + #define BDMAC_DCMD_DWDH_32 (0 << BDMAC_DCMD_DWDH_BIT) + #define BDMAC_DCMD_DWDH_8 (1 << BDMAC_DCMD_DWDH_BIT) + #define BDMAC_DCMD_DWDH_16 (2 << BDMAC_DCMD_DWDH_BIT) +#define BDMAC_DCMD_DS_BIT 8 /* transfer data size of a data unit */ + #define BDMAC_DCMD_DS_MASK (0x07 << BDMAC_DCMD_DS_BIT) + #define BDMAC_DCMD_DS_32BIT (0 << BDMAC_DCMD_DS_BIT) + #define BDMAC_DCMD_DS_8BIT (1 << BDMAC_DCMD_DS_BIT) + #define BDMAC_DCMD_DS_16BIT (2 << BDMAC_DCMD_DS_BIT) + #define BDMAC_DCMD_DS_16BYTE (3 << BDMAC_DCMD_DS_BIT) + #define BDMAC_DCMD_DS_32BYTE (4 << BDMAC_DCMD_DS_BIT) + #define BDMAC_DCMD_DS_64BYTE (5 << BDMAC_DCMD_DS_BIT) +#define BDMAC_DCMD_NRD (1 << 7) /* NAND direct read */ +#define BDMAC_DCMD_NWR (1 << 6) /* NAND direct write */ +#define BDMAC_DCMD_NAC (1 << 5) /* NAND AL/CL enable */ +#define BDMAC_DCMD_NSTA (1 << 4) +#define BDMAC_DCMD_STDE (1 << 2) /* Stride Disable/Enable */ +#define BDMAC_DCMD_TIE (1 << 1) /* DMA transfer interrupt enable */ +#define BDMAC_DCMD_LINK (1 << 0) /* descriptor link enable */ + +// BDMA descriptor address register +#define BDMAC_DDA_BASE_BIT 12 /* descriptor base address */ + #define BDMAC_DDA_BASE_MASK (0x0fffff << BDMAC_DDA_BASE_BIT) +#define BDMAC_DDA_OFFSET_BIT 4 /* descriptor offset address */ + #define BDMAC_DDA_OFFSET_MASK (0x0ff << BDMAC_DDA_OFFSET_BIT) + +// BDMA stride address register +#define BDMAC_DSD_TSD_BIT 16 /* target stride address */ + #define BDMAC_DSD_TSD_MASK (0xffff << BDMAC_DSD_TSD_BIT) +#define BDMAC_DSD_SSD_BIT 0 /* source stride address */ + #define BDMAC_DSD_SSD_MASK (0xffff << BDMAC_DSD_SSD_BIT) + +// BDMA NAND Detect timer register +#define BDMAC_NDTCTIMER_EN (1 << 15) /* enable detect timer */ +#define BDMAC_TAILCNT_BIT 16 + +// BDMA control register +#define BDMAC_DMACR_PR_BIT 8 /* channel priority mode */ + #define BDMAC_DMACR_PR_MASK (0x03 << DMAC_DMACR_PR_BIT) + #define BDMAC_DMACR_PR_01_2 (0 << BDMAC_DMACR_PR_BIT) + #define BDMAC_DMACR_PR_12_0 (1 << BDMAC_DMACR_PR_BIT) + #define BDMAC_DMACR_PR_20_1 (2 << BDMAC_DMACR_PR_BIT) + #define BDMAC_DMACR_PR_012 (3 << BDMAC_DMACR_PR_BIT) +#define BDMAC_DMACR_HLT (1 << 3) /* DMA halt flag */ +#define BDMAC_DMACR_AR (1 << 2) /* address error flag */ +#define BDMAC_DMACR_DMAE (1 << 0) /* DMA enable bit */ + +// BDMA interrupt pending register +#define BDMAC_DMAIPR_CIRQ2 (1 << 2) /* irq pending status for channel 2 */ +#define BDMAC_DMAIPR_CIRQ1 (1 << 1) /* irq pending status for channel 1 */ +#define BDMAC_DMAIPR_CIRQ0 (1 << 0) /* irq pending status for channel 0 */ + +// BDMA doorbell register +#define BDMAC_DMADBR_DB2 (1 << 2) /* doorbell for channel 2 */ +#define BDMAC_DMADBR_DB1 (1 << 1) /* doorbell for channel 1 */ +#define BDMAC_DMADBR_DB0 (1 << 0) /* doorbell for channel 0 */ + +// BDMA doorbell set register +#define BDMAC_DMADBSR_DBS2 (1 << 2) /* enable doorbell for channel 2 */ +#define BDMAC_DMADBSR_DBS1 (1 << 1) /* enable doorbell for channel 1 */ +#define BDMAC_DMADBSR_DBS0 (1 << 0) /* enable doorbell for channel 0 */ + +#ifndef __MIPS_ASSEMBLER + +/*************************************************************************** + * BCH & NAND DMAC + ***************************************************************************/ + +#define __bdmac_enable_module() \ + ( REG_BDMAC_DMACR |= BDMAC_DMACR_DMAE ) +#define __bdmac_disable_module() \ + ( REG_BDMAC_DMACR &= ~BDMAC_DMACR_DMAE ) + +/* n is the DMA channel index (0 - 2) */ + +#define __bdmac_test_halt_error ( REG_BDMAC_DMACR & BDMAC_DMACR_HLT ) +#define __bdmac_test_addr_error ( REG_BDMAC_DMACR & BDMAC_DMACR_AR ) + +#define __bdmac_channel_enable_clk(n) \ + REG_BDMAC_DMACKES = 1 << (n); + +#define __bdmac_enable_descriptor(n) \ + ( REG_BDMAC_DCCSR((n)) &= ~BDMAC_DCCSR_NDES ) +#define __bdmac_disable_descriptor(n) \ + ( REG_BDMAC_DCCSR((n)) |= BDMAC_DCCSR_NDES ) + +#define __bdmac_enable_channel(n) \ +do { \ + REG_BDMAC_DCCSR((n)) |= BDMAC_DCCSR_EN; \ +} while (0) +#define __bdmac_disable_channel(n) \ +do { \ + REG_BDMAC_DCCSR((n)) &= ~BDMAC_DCCSR_EN; \ +} while (0) + +#define __bdmac_channel_enable_irq(n) \ + ( REG_BDMAC_DCMD((n)) |= BDMAC_DCMD_TIE ) +#define __bdmac_channel_disable_irq(n) \ + ( REG_BDMAC_DCMD((n)) &= ~BDMAC_DCMD_TIE ) + +#define __bdmac_channel_transmit_halt_detected(n) \ + ( REG_BDMAC_DCCSR((n)) & BDMAC_DCCSR_HLT ) +#define __bdmac_channel_transmit_end_detected(n) \ + ( REG_BDMAC_DCCSR((n)) & BDMAC_DCCSR_TT ) +/* Nand ops status error, only for channel 1 */ +#define __bdmac_channel_status_error_detected() \ + ( REG_BDMAC_DCCSR(1) & BDMAC_DCCSR_NSERR ) +#define __bdmac_channel_address_error_detected(n) \ + ( REG_BDMAC_DCCSR((n)) & BDMAC_DCCSR_AR ) +#define __bdmac_channel_count_terminated_detected(n) \ + ( REG_BDMAC_DCCSR((n)) & BDMAC_DCCSR_CT ) +#define __bdmac_channel_descriptor_invalid_detected(n) \ + ( REG_BDMAC_DCCSR((n)) & BDMAC_DCCSR_INV ) +#define __bdmac_BCH_error_detected(n) \ + ( REG_BDMAC_DCCSR((n)) & BDMAC_DCCSR_BERR ) + +#define __bdmac_channel_clear_transmit_halt(n) \ + do { \ + /* clear both channel halt error and globle halt error */ \ + REG_BDMAC_DCCSR(n) &= ~BDMAC_DCCSR_HLT; \ + REG_BDMAC_DMACR &= ~BDMAC_DMACR_HLT; \ + } while (0) +#define __bdmac_channel_clear_transmit_end(n) \ + ( REG_BDMAC_DCCSR(n) &= ~BDMAC_DCCSR_TT ) +/* Nand ops status error, only for channel 1 */ +#define __bdmac_channel_clear_status_error() \ + ( REG_BDMAC_DCCSR(1) &= ~BDMAC_DCCSR_NSERR ) +#define __bdmac_channel_clear_address_error(n) \ + do { \ + REG_BDMAC_DDA(n) = 0; /* clear descriptor address register */ \ + REG_BDMAC_DSAR(n) = 0; /* clear source address register */ \ + REG_BDMAC_DTAR(n) = 0; /* clear target address register */ \ + /* clear both channel addr error and globle address error */ \ + REG_BDMAC_DCCSR(n) &= ~BDMAC_DCCSR_AR; \ + REG_BDMAC_DMACR &= ~BDMAC_DMACR_AR; \ + } while (0) +#define __bdmac_channel_clear_count_terminated(n) \ + ( REG_BDMAC_DCCSR((n)) &= ~BDMAC_DCCSR_CT ) +#define __bdmac_channel_clear_descriptor_invalid(n) \ + ( REG_BDMAC_DCCSR((n)) &= ~BDMAC_DCCSR_INV ) + +#define __bdmac_channel_set_transfer_unit_32bit(n) \ +do { \ + REG_BDMAC_DCMD((n)) &= ~BDMAC_DCMD_DS_MASK; \ + REG_BDMAC_DCMD((n)) |= BDMAC_DCMD_DS_32BIT; \ +} while (0) + +#define __bdmac_channel_set_transfer_unit_16bit(n) \ +do { \ + REG_BDMAC_DCMD((n)) &= ~BDMAC_DCMD_DS_MASK; \ + REG_BDMAC_DCMD((n)) |= BDMAC_DCMD_DS_16BIT; \ +} while (0) + +#define __bdmac_channel_set_transfer_unit_8bit(n) \ +do { \ + REG_BDMAC_DCMD((n)) &= ~BDMAC_DCMD_DS_MASK; \ + REG_BDMAC_DCMD((n)) |= BDMAC_DCMD_DS_8BIT; \ +} while (0) + +#define __bdmac_channel_set_transfer_unit_16byte(n) \ +do { \ + REG_BDMAC_DCMD((n)) &= ~BDMAC_DCMD_DS_MASK; \ + REG_BDMAC_DCMD((n)) |= BDMAC_DCMD_DS_16BYTE; \ +} while (0) + +#define __bdmac_channel_set_transfer_unit_32byte(n) \ +do { \ + REG_BDMAC_DCMD((n)) &= ~BDMAC_DCMD_DS_MASK; \ + REG_BDMAC_DCMD((n)) |= BDMAC_DCMD_DS_32BYTE; \ +} while (0) + +/* w=8,16,32 */ +#define __bdmac_channel_set_dest_port_width(n,w) \ +do { \ + REG_BDMAC_DCMD((n)) &= ~BDMAC_DCMD_DWDH_MASK; \ + REG_BDMAC_DCMD((n)) |= BDMAC_DCMD_DWDH_##w; \ +} while (0) + +/* w=8,16,32 */ +#define __bdmac_channel_set_src_port_width(n,w) \ +do { \ + REG_BDMAC_DCMD((n)) &= ~BDMAC_DCMD_SWDH_MASK; \ + REG_BDMAC_DCMD((n)) |= BDMAC_DCMD_SWDH_##w; \ +} while (0) + +#define __bdmac_channel_dest_addr_fixed(n) \ + (REG_BDMAC_DCMD((n)) &= ~BDMAC_DCMD_DAI) +#define __bdmac_channel_dest_addr_increment(n) \ + (REG_BDMAC_DCMD((n)) |= BDMAC_DCMD_DAI) + +#define __bdmac_channel_src_addr_fixed(n) \ + (REG_BDMAC_DCMD((n)) &= ~BDMAC_DCMD_SAI) +#define __bdmac_channel_src_addr_increment(n) \ + (REG_BDMAC_DCMD((n)) |= BDMAC_DCMD_SAI) + +#define __bdmac_channel_set_doorbell(n) \ + (REG_BDMAC_DMADBSR = (1 << (n))) + +#define __bdmac_channel_irq_detected(n) (REG_BDMAC_DMAIPR & (1 << (n))) +#define __bdmac_channel_ack_irq(n) (REG_BDMAC_DMAIPR &= ~(1 <<(n))) + +static __inline__ int __bdmac_get_irq(void) +{ + int i; + for (i = 0; i < MAX_BDMA_NUM; i++) + if (__bdmac_channel_irq_detected(i)) + return i; + return -1; +} + +#endif /* __MIPS_ASSEMBLER */ + +#define CIM_BASE 0xB3060000 + +/************************************************************************* + * CIM + *************************************************************************/ +#define CIM_CFG (CIM_BASE + 0x0000) +#define CIM_CTRL (CIM_BASE + 0x0004) +#define CIM_STATE (CIM_BASE + 0x0008) +#define CIM_IID (CIM_BASE + 0x000C) +#define CIM_DA (CIM_BASE + 0x0020) +#define CIM_FA (CIM_BASE + 0x0024) +#define CIM_FID (CIM_BASE + 0x0028) +#define CIM_CMD (CIM_BASE + 0x002C) +#define CIM_SIZE (CIM_BASE + 0x0030) +#define CIM_OFFSET (CIM_BASE + 0x0034) +#define CIM_YFA (CIM_BASE + 0x0038) +#define CIM_YCMD (CIM_BASE + 0x003C) +#define CIM_CBFA (CIM_BASE + 0x0040) +#define CIM_CBCMD (CIM_BASE + 0x0044) +#define CIM_CRFA (CIM_BASE + 0x0048) +#define CIM_CRCMD (CIM_BASE + 0x004C) +#define CIM_CTRL2 (CIM_BASE + 0x0050) + +#define CIM_RAM_ADDR (CIM_BASE + 0x1000) + +#define REG_CIM_CFG REG32(CIM_CFG) +#define REG_CIM_CTRL REG32(CIM_CTRL) +#define REG_CIM_STATE REG32(CIM_STATE) +#define REG_CIM_IID REG32(CIM_IID) +#define REG_CIM_DA REG32(CIM_DA) +#define REG_CIM_FA REG32(CIM_FA) +#define REG_CIM_FID REG32(CIM_FID) +#define REG_CIM_CMD REG32(CIM_CMD) +#define REG_CIM_SIZE REG32(CIM_SIZE) +#define REG_CIM_OFFSET REG32(CIM_OFFSET) +#define REG_CIM_YFA REG32(CIM_YFA) +#define REG_CIM_YCMD REG32(CIM_YCMD) +#define REG_CIM_CBFA REG32(CIM_CBFA) +#define REG_CIM_CBCMD REG32(CIM_CBCMD) +#define REG_CIM_CRFA REG32(CIM_CRFA) +#define REG_CIM_CRCMD REG32(CIM_CRCMD) +#define REG_CIM_CTRL2 REG32(CIM_CTRL2) + +#define CIM_CFG_EEOFEN (1 << 31) +#define CIM_CFG_EXP (1 << 30) + +#define CIM_CFG_RXF_TRIG_BIT 24 +#define CIM_CFG_RXF_TRIG_MASK (0x3f << CIM_CFG_RXF_TRIG_BIT) + +#define CIM_CFG_BW_BIT 22 +#define CIM_CFG_BW_MASK (0x3 << CIM_CFG_BW_BIT) + +#define CIM_CFG_SEP (1 << 20) + +#define CIM_CFG_ORDER_BIT 18 +#define CIM_CFG_ORDER_MASK (0x3 << CIM_CFG_ORDER_BIT) +#define CIM_CFG_ORDER_0 (0x0 << CIM_CFG_ORDER_BIT) /* Y0CbY1Cr; YCbCr */ +#define CIM_CFG_ORDER_1 (0x1 << CIM_CFG_ORDER_BIT) /* Y0CrY1Cb; YCrCb */ +#define CIM_CFG_ORDER_2 (0x2 << CIM_CFG_ORDER_BIT) /* CbY0CrY1; CbCrY */ +#define CIM_CFG_ORDER_3 (0x3 << CIM_CFG_ORDER_BIT) /* CrY0CbY1; CrCbY */ + +#define CIM_CFG_DF_BIT 16 +#define CIM_CFG_DF_MASK (0x3 << CIM_CFG_DF_BIT) +#define CIM_CFG_DF_YUV444 (0x1 << CIM_CFG_DF_BIT) /* YCbCr444 */ +#define CIM_CFG_DF_YUV422 (0x2 << CIM_CFG_DF_BIT) /* YCbCr422 */ +#define CIM_CFG_DF_ITU656 (0x3 << CIM_CFG_DF_BIT) /* ITU656 YCbCr422 */ + +#define CIM_CFG_INV_DAT (1 << 15) +#define CIM_CFG_VSP (1 << 14) /* VSYNC Polarity:0-rising edge active,1-falling edge active */ +#define CIM_CFG_HSP (1 << 13) /* HSYNC Polarity:0-rising edge active,1-falling edge active */ +#define CIM_CFG_PCP (1 << 12) /* PCLK working edge: 0-rising, 1-falling */ + +#define CIM_CFG_DMA_BURST_TYPE_BIT 10 +#define CIM_CFG_DMA_BURST_TYPE_MASK (0x3 << CIM_CFG_DMA_BURST_TYPE_BIT) +#define CIM_CFG_DMA_BURST_INCR4 (0 << CIM_CFG_DMA_BURST_TYPE_BIT) +#define CIM_CFG_DMA_BURST_INCR8 (1 << CIM_CFG_DMA_BURST_TYPE_BIT) /* Suggested */ +#define CIM_CFG_DMA_BURST_INCR16 (2 << CIM_CFG_DMA_BURST_TYPE_BIT) /* Suggested High speed AHB*/ +#define CIM_CFG_DMA_BURST_INCR32 (3 << CIM_CFG_DMA_BURST_TYPE_BIT) /* Suggested High speed AHB*/ + +#define CIM_CFG_DUMMY_ZERO (1 << 9) +#define CIM_CFG_EXT_VSYNC (1 << 8) /* Only for ITU656 Progressive mode */ +#define CIM_CFG_LM (1 << 7) /* Only for ITU656 Progressive mode */ +#define CIM_CFG_PACK_BIT 4 +#define CIM_CFG_PACK_MASK (0x7 << CIM_CFG_PACK_BIT) +#define CIM_CFG_PACK_0 (0 << CIM_CFG_PACK_BIT) /* 11 22 33 44 0xY0CbY1Cr */ +#define CIM_CFG_PACK_1 (1 << CIM_CFG_PACK_BIT) /* 22 33 44 11 0xCbY1CrY0 */ +#define CIM_CFG_PACK_2 (2 << CIM_CFG_PACK_BIT) /* 33 44 11 22 0xY1CrY0Cb */ +#define CIM_CFG_PACK_3 (3 << CIM_CFG_PACK_BIT) /* 44 11 22 33 0xCrY0CbY1 */ +#define CIM_CFG_PACK_4 (4 << CIM_CFG_PACK_BIT) /* 44 33 22 11 0xCrY1CbY0 */ +#define CIM_CFG_PACK_5 (5 << CIM_CFG_PACK_BIT) /* 33 22 11 44 0xY1CbY0Cr */ +#define CIM_CFG_PACK_6 (6 << CIM_CFG_PACK_BIT) /* 22 11 44 33 0xCbY0CrY1 */ +#define CIM_CFG_PACK_7 (7 << CIM_CFG_PACK_BIT) /* 11 44 33 22 0xY0CrY1Cb */ +#define CIM_CFG_FP (1 << 3) /* Only for ITU656 Progressive mode */ +#define CIM_CFG_BYPASS_BIT 2 +#define CIM_CFG_BYPASS_MASK (1 << CIM_CFG_BYPASS_BIT) +#define CIM_CFG_BYPASS (1 << CIM_CFG_BYPASS_BIT) +#define CIM_CFG_DSM_BIT 0 +#define CIM_CFG_DSM_MASK (0x3 << CIM_CFG_DSM_BIT) +#define CIM_CFG_DSM_CPM (0 << CIM_CFG_DSM_BIT) /* CCIR656 Progressive Mode */ +#define CIM_CFG_DSM_CIM (1 << CIM_CFG_DSM_BIT) /* CCIR656 Interlace Mode */ +#define CIM_CFG_DSM_GCM (2 << CIM_CFG_DSM_BIT) /* Gated Clock Mode */ + +/* CIM Control Register (CIM_CTRL) */ +#define CIM_CTRL_EEOF_LINE_BIT 20 +#define CIM_CTRL_EEOF_LINE_MASK (0xfff << CIM_CTRL_EEOF_LINE_BIT) + +#define CIM_CTRL_FRC_BIT 16 +#define CIM_CTRL_FRC_MASK (0xf << CIM_CTRL_FRC_BIT) +#define CIM_CTRL_FRC_1 (0x0 << CIM_CTRL_FRC_BIT) /* Sample every frame */ +#define CIM_CTRL_FRC_2 (0x1 << CIM_CTRL_FRC_BIT) /* Sample 1/2 frame */ +#define CIM_CTRL_FRC_3 (0x2 << CIM_CTRL_FRC_BIT) /* Sample 1/3 frame */ +#define CIM_CTRL_FRC_4 (0x3 << CIM_CTRL_FRC_BIT) /* Sample 1/4 frame */ +#define CIM_CTRL_FRC_5 (0x4 << CIM_CTRL_FRC_BIT) /* Sample 1/5 frame */ +#define CIM_CTRL_FRC_6 (0x5 << CIM_CTRL_FRC_BIT) /* Sample 1/6 frame */ +#define CIM_CTRL_FRC_7 (0x6 << CIM_CTRL_FRC_BIT) /* Sample 1/7 frame */ +#define CIM_CTRL_FRC_8 (0x7 << CIM_CTRL_FRC_BIT) /* Sample 1/8 frame */ +#define CIM_CTRL_FRC_9 (0x8 << CIM_CTRL_FRC_BIT) /* Sample 1/9 frame */ +#define CIM_CTRL_FRC_10 (0x9 << CIM_CTRL_FRC_BIT) /* Sample 1/10 frame */ +#define CIM_CTRL_FRC_11 (0xA << CIM_CTRL_FRC_BIT) /* Sample 1/11 frame */ +#define CIM_CTRL_FRC_12 (0xB << CIM_CTRL_FRC_BIT) /* Sample 1/12 frame */ +#define CIM_CTRL_FRC_13 (0xC << CIM_CTRL_FRC_BIT) /* Sample 1/13 frame */ +#define CIM_CTRL_FRC_14 (0xD << CIM_CTRL_FRC_BIT) /* Sample 1/14 frame */ +#define CIM_CTRL_FRC_15 (0xE << CIM_CTRL_FRC_BIT) /* Sample 1/15 frame */ +#define CIM_CTRL_FRC_16 (0xF << CIM_CTRL_FRC_BIT) /* Sample 1/16 frame */ + +#define CIM_CTRL_DMA_EEOF (1 << 15) /* Enable EEOF interrupt */ +#define CIM_CTRL_WIN_EN (1 << 14) +#define CIM_CTRL_VDDM (1 << 13) /* VDD interrupt enable */ +#define CIM_CTRL_DMA_SOFM (1 << 12) +#define CIM_CTRL_DMA_EOFM (1 << 11) +#define CIM_CTRL_DMA_STOPM (1 << 10) +#define CIM_CTRL_RXF_TRIGM (1 << 9) +#define CIM_CTRL_RXF_OFM (1 << 8) +#define CIM_CTRL_DMA_SYNC (1 << 7) /*when change DA, do frame sync */ +#define CIM_CTRL_H_SYNC (1 << 6) /*Enable horizental sync when CIMCFG.SEP is 1*/ + +#define CIM_CTRL_PPW_BIT 3 +#define CIM_CTRL_PPW_MASK (0x3 << CIM_CTRL_PPW_BIT) + +#define CIM_CTRL_DMA_EN (1 << 2) /* Enable DMA */ +#define CIM_CTRL_RXF_RST (1 << 1) /* RxFIFO reset */ +#define CIM_CTRL_ENA (1 << 0) /* Enable CIM */ + +/* cim control2 */ +#define CIM_CTRL2_OPG_BIT 4 +#define CIM_CTRL2_OPG_MASK (0x3 << CIM_CTRL2_OPG_BIT) +#define CIM_CTRL2_OPE (1 << 2) +#define CIM_CTRL2_EME (1 << 1) +#define CIM_CTRL2_APM (1 << 0) + +/* CIM State Register (CIM_STATE) */ +#define CIM_STATE_CR_RF_OF (1 << 27) +#define CIM_STATE_CR_RF_TRIG (1 << 26) +#define CIM_STATE_CR_RF_EMPTY (1 << 25) +#define CIM_STATE_CB_RF_OF (1 << 19) +#define CIM_STATE_CB_RF_TRIG (1 << 18) +#define CIM_STATE_CB_RF_EMPTY (1 << 17) +#define CIM_STATE_Y_RF_OF (1 << 11) +#define CIM_STATE_Y_RF_TRIG (1 << 10) +#define CIM_STATE_Y_RF_EMPTY (1 << 9) +#define CIM_STATE_DMA_EEOF (1 << 7) /* DMA Line EEOf irq */ +#define CIM_STATE_DMA_SOF (1 << 6) /* DMA start irq */ +#define CIM_STATE_DMA_EOF (1 << 5) /* DMA end irq */ +#define CIM_STATE_DMA_STOP (1 << 4) /* DMA stop irq */ +#define CIM_STATE_RXF_OF (1 << 3) /* RXFIFO over flow irq */ +#define CIM_STATE_RXF_TRIG (1 << 2) /* RXFIFO triger meet irq */ +#define CIM_STATE_RXF_EMPTY (1 << 1) /* RXFIFO empty irq */ +#define CIM_STATE_VDD (1 << 0) /* CIM disabled irq */ + +/* CIM DMA Command Register (CIM_CMD) */ + +#define CIM_CMD_SOFINT (1 << 31) /* enable DMA start irq */ +#define CIM_CMD_EOFINT (1 << 30) /* enable DMA end irq */ +#define CIM_CMD_EEOFINT (1 << 29) /* enable DMA EEOF irq */ +#define CIM_CMD_STOP (1 << 28) /* enable DMA stop irq */ +#define CIM_CMD_OFRCV (1 << 27) /* enable recovery when TXFiFo overflow */ +#define CIM_CMD_LEN_BIT 0 +#define CIM_CMD_LEN_MASK (0xffffff << CIM_CMD_LEN_BIT) + +/* CIM Window-Image Size Register (CIM_SIZE) */ +#define CIM_SIZE_LPF_BIT 16 /* Lines per freame for csc output image */ +#define CIM_SIZE_LPF_MASK (0x1fff << CIM_SIZE_LPF_BIT) +#define CIM_SIZE_PPL_BIT 0 /* Pixels per line for csc output image, should be an even number */ +#define CIM_SIZE_PPL_MASK (0x1fff << CIM_SIZE_PPL_BIT) + +/* CIM Image Offset Register (CIM_OFFSET) */ +#define CIM_OFFSET_V_BIT 16 /* Vertical offset */ +#define CIM_OFFSET_V_MASK (0xfff << CIM_OFFSET_V_BIT) +#define CIM_OFFSET_H_BIT 0 /* Horizontal offset, should be an enen number */ +#define CIM_OFFSET_H_MASK (0xfff << CIM_OFFSET_H_BIT) /*OFFSET_H should be even number*/ + +#define CIM_YCMD_SOFINT (1 << 31) /* enable DMA start irq */ +#define CIM_YCMD_EOFINT (1 << 30) /* enable DMA end irq */ +#define CIM_YCMD_EEOFINT (1 << 29) /* enable DMA EEOF irq */ +#define CIM_YCMD_STOP (1 << 28) /* enable DMA stop irq */ +#define CIM_YCMD_OFRCV (1 << 27) /* enable recovery when TXFiFo overflow */ +#define CIM_YCMD_LEN_BIT 0 +#define CIM_YCMD_LEN_MASK (0xffffff << CIM_YCMD_LEN_BIT) + +#define CIM_CBCMD_LEN_BIT 0 +#define CIM_CBCMD_LEN_MASK (0xffffff << CIM_CBCMD_LEN_BIT) + +#define CIM_CRCMD_LEN_BIT 0 +#define CIM_CRCMD_LEN_MASK (0xffffff << CIM_CRCMD_LEN_BIT) + +#ifndef __MIPS_ASSEMBLER + +/*************************************************************************** + * CIM + ***************************************************************************/ + +#define __cim_enable() ( REG_CIM_CTRL |= CIM_CTRL_ENA ) +#define __cim_disable() ( REG_CIM_CTRL &= ~CIM_CTRL_ENA ) + +#define __cim_enable_sep() (REG_CIM_CFG |= CIM_CFG_SEP) +#define __cim_disable_sep() (REG_CIM_CFG &= ~CIM_CFG_SEP) + +/* n = 0, 1, 2, 3 */ +#define __cim_set_input_data_stream_order(n) \ + do { \ + REG_CIM_CFG &= ~CIM_CFG_ORDER_MASK; \ + REG_CIM_CFG |= ((n)<>CIM_SIZE_LPF_BIT) +#define __cim_get_pixel() ((REG_CIM_SIZE&CIM_SIZE_PPL_MASK)>>CIM_SIZE_PPL_BIT) + +#define __cim_set_v_offset(a) ( REG_CIM_OFFSET = (REG_CIM_OFFSET&(~CIM_OFFSET_V_MASK)) | ((a)<>CIM_OFFSET_V_BIT) +#define __cim_get_h_offset() ((REG_CIM_OFFSET&CIM_OFFSET_H_MASK)>>CIM_OFFSET_H_BIT) + +#endif /* __MIPS_ASSEMBLER */ + +/* + * Clock reset and power controller module(CPM) address definition + */ +#define CPM_BASE 0xb0000000 + +/* + * CPM registers offset address definition + */ +#define CPM_CPCCR_OFFSET (0x00) /* rw, 32, 0x01011100 */ +#define CPM_LCR_OFFSET (0x04) /* rw, 32, 0x000000f8 */ +#define CPM_RSR_OFFSET (0x08) /* rw, 32, 0x???????? */ +#define CPM_CPPCR0_OFFSET (0x10) /* rw, 32, 0x28080011 */ +#define CPM_CPPSR_OFFSET (0x14) /* rw, 32, 0x80000000 */ +#define CPM_CLKGR0_OFFSET (0x20) /* rw, 32, 0x3fffffe0 */ +#define CPM_OPCR_OFFSET (0x24) /* rw, 32, 0x00001570 */ +#define CPM_CLKGR1_OFFSET (0x28) /* rw, 32, 0x0000017f */ +#define CPM_CPPCR1_OFFSET (0x30) /* rw, 32, 0x28080002 */ +#define CPM_CPSPR_OFFSET (0x34) /* rw, 32, 0x???????? */ +#define CPM_CPSPPR_OFFSET (0x38) /* rw, 32, 0x0000a5a5 */ +#define CPM_USBPCR_OFFSET (0x3c) /* rw, 32, 0x42992198 */ +#define CPM_USBRDT_OFFSET (0x40) /* rw, 32, 0x00000096 */ +#define CPM_USBVBFIL_OFFSET (0x44) /* rw, 32, 0x00000080 */ +#define CPM_USBCDR_OFFSET (0x50) /* rw, 32, 0x00000000 */ +#define CPM_I2SCDR_OFFSET (0x60) /* rw, 32, 0x00000000 */ +#define CPM_LPCDR_OFFSET (0x64) /* rw, 32, 0x00000000 */ +#define CPM_MSCCDR_OFFSET (0x68) /* rw, 32, 0x00000000 */ +#define CPM_UHCCDR_OFFSET (0x6c) /* rw, 32, 0x00000000 */ +#define CPM_SSICDR_OFFSET (0x74) /* rw, 32, 0x00000000 */ +#define CPM_CIMCDR_OFFSET (0x7c) /* rw, 32, 0x00000000 */ +#define CPM_GPSCDR_OFFSET (0x80) /* rw, 32, 0x00000000 */ +#define CPM_PCMCDR_OFFSET (0x84) /* rw, 32, 0x00000000 */ +#define CPM_GPUCDR_OFFSET (0x88) /* rw, 32, 0x00000000 */ +#define CPM_PSWC0ST_OFFSET (0x90) /* rw, 32, 0x00000000 */ +#define CPM_PSWC1ST_OFFSET (0x94) /* rw, 32, 0x00000000 */ +#define CPM_PSWC2ST_OFFSET (0x98) /* rw, 32, 0x00000000 */ +#define CPM_PSWC3ST_OFFSET (0x9c) /* rw, 32, 0x00000000 */ + +/* + * CPM registers address definition + */ +#define CPM_CPCCR (CPM_BASE + CPM_CPCCR_OFFSET) +#define CPM_LCR (CPM_BASE + CPM_LCR_OFFSET) +#define CPM_RSR (CPM_BASE + CPM_RSR_OFFSET) +#define CPM_CPPCR0 (CPM_BASE + CPM_CPPCR0_OFFSET) +#define CPM_CPPSR (CPM_BASE + CPM_CPPSR_OFFSET) +#define CPM_CLKGR0 (CPM_BASE + CPM_CLKGR0_OFFSET) +#define CPM_OPCR (CPM_BASE + CPM_OPCR_OFFSET) +#define CPM_CLKGR1 (CPM_BASE + CPM_CLKGR1_OFFSET) +#define CPM_CPPCR1 (CPM_BASE + CPM_CPPCR1_OFFSET) +#define CPM_CPSPR (CPM_BASE + CPM_CPSPR_OFFSET) +#define CPM_CPSPPR (CPM_BASE + CPM_CPSPPR_OFFSET) +#define CPM_USBPCR (CPM_BASE + CPM_USBPCR_OFFSET) +#define CPM_USBRDT (CPM_BASE + CPM_USBRDT_OFFSET) +#define CPM_USBVBFIL (CPM_BASE + CPM_USBVBFIL_OFFSET) +#define CPM_USBCDR (CPM_BASE + CPM_USBCDR_OFFSET) +#define CPM_I2SCDR (CPM_BASE + CPM_I2SCDR_OFFSET) +#define CPM_LPCDR (CPM_BASE + CPM_LPCDR_OFFSET) +#define CPM_MSCCDR (CPM_BASE + CPM_MSCCDR_OFFSET) +#define CPM_UHCCDR (CPM_BASE + CPM_UHCCDR_OFFSET) +#define CPM_SSICDR (CPM_BASE + CPM_SSICDR_OFFSET) +#define CPM_CIMCDR (CPM_BASE + CPM_CIMCDR_OFFSET) +#define CPM_GPSCDR (CPM_BASE + CPM_GPSCDR_OFFSET) +#define CPM_PCMCDR (CPM_BASE + CPM_PCMCDR_OFFSET) +#define CPM_GPUCDR (CPM_BASE + CPM_GPUCDR_OFFSET) +#define CPM_PSWC0ST (CPM_BASE + CPM_PSWC0ST_OFFSET) +#define CPM_PSWC1ST (CPM_BASE + CPM_PSWC1ST_OFFSET) +#define CPM_PSWC2ST (CPM_BASE + CPM_PSWC2ST_OFFSET) +#define CPM_PSWC3ST (CPM_BASE + CPM_PSWC3ST_OFFSET) + +/* + * CPM registers common define + */ + +/* Clock control register(CPCCR) */ +#define CPCCR_ECS BIT31 +#define CPCCR_MEM BIT30 +#define CPCCR_CE BIT22 +#define CPCCR_PCS BIT21 + +#define CPCCR_SDIV_LSB 24 +#define CPCCR_SDIV_MASK BITS_H2L(27, CPCCR_SDIV_LSB) + +#define CPCCR_H2DIV_LSB 16 +#define CPCCR_H2DIV_MASK BITS_H2L(19, CPCCR_H2DIV_LSB) + +#define CPCCR_MDIV_LSB 12 +#define CPCCR_MDIV_MASK BITS_H2L(15, CPCCR_MDIV_LSB) + +#define CPCCR_PDIV_LSB 8 +#define CPCCR_PDIV_MASK BITS_H2L(11, CPCCR_PDIV_LSB) + +#define CPCCR_HDIV_LSB 4 +#define CPCCR_HDIV_MASK BITS_H2L(7, CPCCR_HDIV_LSB) + +#define CPCCR_CDIV_LSB 0 +#define CPCCR_CDIV_MASK BITS_H2L(3, CPCCR_CDIV_LSB) + +/* Low power control register(LCR) */ +#define LCR_PDAHB1 BIT30 +#define LCR_PDAHB1S BIT26 +#define LCR_DOZE BIT2 + +#define LCR_PST_LSB 8 +#define LCR_PST_MASK BITS_H2L(19, LCR_PST_LSB) + +#define LCR_DUTY_LSB 3 +#define LCR_DUTY_MASK BITS_H2L(7, LCR_DUTY_LSB) + +#define LCR_LPM_LSB 0 +#define LCR_LPM_MASK BITS_H2L(1, LCR_LPM_LSB) +#define LCR_LPM_IDLE (0x0 << LCR_LPM_LSB) +#define LCR_LPM_SLEEP (0x1 << LCR_LPM_LSB) + +/* Reset status register(RSR) */ +#define RSR_P0R BIT2 +#define RSR_WR BIT1 +#define RSR_PR BIT0 + +/* PLL control register 0(CPPCR0) */ +#define CPPCR0_LOCK BIT15 /* LOCK0 bit */ +#define CPPCR0_PLLS BIT10 +#define CPPCR0_PLLBP BIT9 +#define CPPCR0_PLLEN BIT8 + +#define CPPCR0_PLLM_LSB 24 +#define CPPCR0_PLLM_MASK BITS_H2L(30, CPPCR0_PLLM_LSB) + +#define CPPCR0_PLLN_LSB 18 +#define CPPCR0_PLLN_MASK BITS_H2L(21, CPPCR0_PLLN_LSB) + +#define CPPCR0_PLLOD_LSB 16 +#define CPPCR0_PLLOD_MASK BITS_H2L(17, CPPCR0_PLLOD_LSB) + +#define CPPCR0_PLLST_LSB 0 +#define CPPCR0_PLLST_MASK BITS_H2L(7, CPPCR0_PLLST_LSB) + +/* PLL switch and status register(CPPSR) */ +#define CPPSR_PLLOFF BIT31 +#define CPPSR_PLLBP BIT30 +#define CPPSR_PLLON BIT29 +#define CPPSR_PS BIT28 +#define CPPSR_FS BIT27 +#define CPPSR_CS BIT26 +#define CPPSR_SM BIT2 +#define CPPSR_PM BIT1 +#define CPPSR_FM BIT0 + +/* Clock gate register 0(CGR0) */ +#define CLKGR0_AHB_MON BIT31 +#define CLKGR0_DDR BIT30 +#define CLKGR0_IPU BIT29 +#define CLKGR0_LCD BIT28 +#define CLKGR0_TVE BIT27 +#define CLKGR0_CIM BIT26 +#define CLKGR0_MDMA BIT25 +#define CLKGR0_UHC BIT24 +#define CLKGR0_MAC BIT23 +#define CLKGR0_GPS BIT22 +#define CLKGR0_DMAC BIT21 +#define CLKGR0_SSI2 BIT20 +#define CLKGR0_SSI1 BIT19 +#define CLKGR0_UART3 BIT18 +#define CLKGR0_UART2 BIT17 +#define CLKGR0_UART1 BIT16 +#define CLKGR0_UART0 BIT15 +#define CLKGR0_SADC BIT14 +#define CLKGR0_KBC BIT13 +#define CLKGR0_MSC2 BIT12 +#define CLKGR0_MSC1 BIT11 +#define CLKGR0_OWI BIT10 +#define CLKGR0_TSSI BIT9 +#define CLKGR0_AIC BIT8 +#define CLKGR0_SCC BIT7 +#define CLKGR0_I2C1 BIT6 +#define CLKGR0_I2C0 BIT5 +#define CLKGR0_SSI0 BIT4 +#define CLKGR0_MSC0 BIT3 +#define CLKGR0_OTG BIT2 +#define CLKGR0_BCH BIT1 +#define CLKGR0_NEMC BIT0 + +/* Oscillator and power control register(OPCR) */ +#define OPCR_OTGPHY_ENABLE BIT7 /* SPENDN bit */ +#define OPCR_GPSEN BIT6 +#define OPCR_UHCPHY_DISABLE BIT5 /* SPENDH bit */ +#define OPCR_O1SE BIT4 +#define OPCR_PD BIT3 +#define OPCR_ERCS BIT2 + +#define OPCR_O1ST_LSB 8 +#define OPCR_O1ST_MASK BITS_H2L(15, OPCR_O1ST_LSB) + +/* Clock gate register 1(CGR1) */ +#define CLKGR1_AUX BIT11 +#define CLKGR1_OSD BIT10 +#define CLKGR1_GPU BIT9 +#define CLKGR1_PCM BIT8 +#define CLKGR1_AHB1 BIT7 +#define CLKGR1_CABAC BIT6 +#define CLKGR1_SRAM BIT5 +#define CLKGR1_DCT BIT4 +#define CLKGR1_ME BIT3 +#define CLKGR1_DBLK BIT2 +#define CLKGR1_MC BIT1 +#define CLKGR1_BDMA BIT0 + +/* PLL control register 1(CPPCR1) */ +#define CPPCR1_P1SCS BIT15 +#define CPPCR1_PLL1EN BIT7 +#define CPPCR1_PLL1S BIT6 +#define CPPCR1_LOCK BIT2 /* LOCK1 bit */ +#define CPPCR1_PLL1OFF BIT1 +#define CPPCR1_PLL1ON BIT0 + +#define CPPCR1_PLL1M_LSB 24 +#define CPPCR1_PLL1M_MASK BITS_H2L(30, CPPCR1_PLL1M_LSB) + +#define CPPCR1_PLL1N_LSB 18 +#define CPPCR1_PLL1N_MASK BITS_H2L(21, CPPCR1_PLL1N_LSB) + +#define CPPCR1_PLL1OD_LSB 16 +#define CPPCR1_PLL1OD_MASK BITS_H2L(17, CPPCR1_PLL1OD_LSB) + +#define CPPCR1_P1SDIV_LSB 9 +#define CPPCR1_P1SDIV_MASK BITS_H2L(14, CPPCR1_P1SDIV_LSB) + +/* CPM scratch pad protected register(CPSPPR) */ +#define CPSPPR_CPSPR_WRITABLE (0x00005a5a) + +/* OTG parameter control register(USBPCR) */ +#define USBPCR_USB_MODE BIT31 +#define USBPCR_AVLD_REG BIT30 +#define USBPCR_INCRM BIT27 /* INCR_MASK bit */ +#define USBPCR_CLK12_EN BIT26 +#define USBPCR_COMMONONN BIT25 +#define USBPCR_VBUSVLDEXT BIT24 +#define USBPCR_VBUSVLDEXTSEL BIT23 +#define USBPCR_POR BIT22 +#define USBPCR_SIDDQ BIT21 +#define USBPCR_OTG_DISABLE BIT20 +#define USBPCR_TXPREEMPHTUNE BIT6 + +#define USBPCR_IDPULLUP_LSB 28 /* IDPULLUP_MASK bit */ +#define USBPCR_IDPULLUP_MASK BITS_H2L(29, USBPCR_USBPCR_IDPULLUP_LSB) + +#define USBPCR_COMPDISTUNE_LSB 17 +#define USBPCR_COMPDISTUNE_MASK BITS_H2L(19, USBPCR_COMPDISTUNE_LSB) + +#define USBPCR_OTGTUNE_LSB 14 +#define USBPCR_OTGTUNE_MASK BITS_H2L(16, USBPCR_OTGTUNE_LSB) + +#define USBPCR_SQRXTUNE_LSB 11 +#define USBPCR_SQRXTUNE_MASK BITS_H2L(13, USBPCR_SQRXTUNE_LSB) + +#define USBPCR_TXFSLSTUNE_LSB 7 +#define USBPCR_TXFSLSTUNE_MASK BITS_H2L(10, USBPCR_TXFSLSTUNE_LSB) + +#define USBPCR_TXRISETUNE_LSB 4 +#define USBPCR_TXRISETUNE_MASK BITS_H2L(5, USBPCR_TXRISETUNE_LSB) + +#define USBPCR_TXVREFTUNE_LSB 0 +#define USBPCR_TXVREFTUNE_MASK BITS_H2L(3, USBPCR_TXVREFTUNE_LSB) + +/* OTG reset detect timer register(USBRDT) */ +#define USBRDT_HB_MASK BIT26 +#define USBRDT_VBFIL_LD_EN BIT25 +#define USBRDT_IDDIG_EN BIT24 +#define USBRDT_IDDIG_REG BIT23 + +#define USBRDT_USBRDT_LSB 0 +#define USBRDT_USBRDT_MASK BITS_H2L(22, USBRDT_USBRDT_LSB) + +/* OTG PHY clock divider register(USBCDR) */ +#define USBCDR_UCS BIT31 +#define USBCDR_UPCS BIT30 + +#define USBCDR_OTGDIV_LSB 0 /* USBCDR bit */ +#define USBCDR_OTGDIV_MASK BITS_H2L(5, USBCDR_OTGDIV_LSB) + +/* I2S device clock divider register(I2SCDR) */ +#define I2SCDR_I2CS BIT31 +#define I2SCDR_I2PCS BIT30 + +#define I2SCDR_I2SDIV_LSB 0 /* I2SCDR bit */ +#define I2SCDR_I2SDIV_MASK BITS_H2L(8, I2SCDR_I2SDIV_LSB) + +/* LCD pix clock divider register(LPCDR) */ +//#define LPCDR_LSCS BIT31 +#define LPCDR_LTCS BIT30 +#define LPCDR_LPCS BIT29 + +#define LPCDR_PIXDIV_LSB 0 /* LPCDR bit */ +#define LPCDR_PIXDIV_MASK BITS_H2L(10, LPCDR_PIXDIV_LSB) + +/* MSC clock divider register(MSCCDR) */ +#define MSCCDR_MCS BIT31 + +#define MSCCDR_MSCDIV_LSB 0 /* MSCCDR bit */ +#define MSCCDR_MSCDIV_MASK BITS_H2L(4, MSCCDR_MSCDIV_LSB) + +/* UHC device clock divider register(UHCCDR) */ +#define UHCCDR_UHPCS BIT31 + +#define UHCCDR_UHCDIV_LSB 0 /* UHCCDR bit */ +#define UHCCDR_UHCDIV_MASK BITS_H2L(3, UHCCDR_UHCDIV_LSB) + +/* SSI clock divider register(SSICDR) */ +#define SSICDR_SCS BIT31 + +#define SSICDR_SSIDIV_LSB 0 /* SSICDR bit */ +#define SSICDR_SSIDIV_MASK BITS_H2L(3, SSICDR_SSIDIV_LSB) + +/* CIM mclk clock divider register(CIMCDR) */ +#define CIMCDR_CIMDIV_LSB 0 /* CIMCDR bit */ +#define CIMCDR_CIMDIV_MASK BITS_H2L(7, CIMCDR_CIMDIV_LSB) + +/* GPS clock divider register(GPSCDR) */ +#define GPSCDR_GPCS BIT31 + +#define GPSCDR_GPSDIV_LSB 0 /* GPSCDR bit */ +#define GSPCDR_GPSDIV_MASK BITS_H2L(3, GPSCDR_GPSDIV_LSB) + +/* PCM device clock divider register(PCMCDR) */ +#define PCMCDR_PCMS BIT31 +#define PCMCDR_PCMPCS BIT30 + +#define PCMCDR_PCMDIV_LSB 0 /* PCMCDR bit */ +#define PCMCDR_PCMDIV_MASK BITS_H2L(8, PCMCDR_PCMDIV_LSB) + +/* GPU clock divider register */ +#define GPUCDR_GPCS BIT31 +#define GPUCDR_GPUDIV_LSB 0 /* GPUCDR bit */ +#define GPUCDR_GPUDIV_MASK BITS_H2L(2, GPUCDR_GPUDIV_LSB) + +#ifndef __MIPS_ASSEMBLER + +#define REG_CPM_CPCCR REG32(CPM_CPCCR) +#define REG_CPM_RSR REG32(CPM_RSR) +#define REG_CPM_CPPCR0 REG32(CPM_CPPCR0) +#define REG_CPM_CPPSR REG32(CPM_CPPSR) +#define REG_CPM_CPPCR1 REG32(CPM_CPPCR1) +#define REG_CPM_CPSPR REG32(CPM_CPSPR) +#define REG_CPM_CPSPPR REG32(CPM_CPSPPR) +#define REG_CPM_USBPCR REG32(CPM_USBPCR) +#define REG_CPM_USBRDT REG32(CPM_USBRDT) +#define REG_CPM_USBVBFIL REG32(CPM_USBVBFIL) +#define REG_CPM_USBCDR REG32(CPM_USBCDR) +#define REG_CPM_I2SCDR REG32(CPM_I2SCDR) +#define REG_CPM_LPCDR REG32(CPM_LPCDR) +#define REG_CPM_MSCCDR REG32(CPM_MSCCDR) +#define REG_CPM_UHCCDR REG32(CPM_UHCCDR) +#define REG_CPM_SSICDR REG32(CPM_SSICDR) +#define REG_CPM_CIMCDR REG32(CPM_CIMCDR) +#define REG_CPM_GPSCDR REG32(CPM_GPSCDR) +#define REG_CPM_PCMCDR REG32(CPM_PCMCDR) +#define REG_CPM_GPUCDR REG32(CPM_GPUCDR) + +#define REG_CPM_PSWC0ST REG32(CPM_PSWC0ST) +#define REG_CPM_PSWC1ST REG32(CPM_PSWC1ST) +#define REG_CPM_PSWC2ST REG32(CPM_PSWC2ST) +#define REG_CPM_PSWC3ST REG32(CPM_PSWC3ST) + +#define REG_CPM_LCR REG32(CPM_LCR) +#define REG_CPM_CLKGR0 REG32(CPM_CLKGR0) +#define REG_CPM_OPCR REG32(CPM_OPCR) +#define REG_CPM_CLKGR1 REG32(CPM_CLKGR1) +#define REG_CPM_CLKGR REG32(CPM_CLKGR0) + +#define cpm_get_scrpad() INREG32(CPM_CPSPR) +#define cpm_set_scrpad(data) \ +do { \ + OUTREG32(CPM_CPSPPR, CPSPPR_CPSPR_WRITABLE); \ + OUTREG32(CPM_CPSPR, data); \ + OUTREG32(CPM_CPSPPR, ~CPSPPR_CPSPR_WRITABLE); \ +} while (0) + +#define CPM_POWER_ON 1 +#define CPM_POWER_OFF 0 + +/*************************************************************************** + * CPM * + ***************************************************************************/ +#define __cpm_get_pllm() \ + ((REG_CPM_CPPCR0 & CPPCR0_PLLM_MASK) >> CPPCR0_PLLM_LSB) +#define __cpm_get_plln() \ + ((REG_CPM_CPPCR0 & CPPCR0_PLLN_MASK) >> CPPCR0_PLLN_LSB) +#define __cpm_get_pllod() \ + ((REG_CPM_CPPCR0 & CPPCR0_PLLOD_MASK) >> CPPCR0_PLLOD_LSB) + +#define __cpm_get_pll1m() \ + ((REG_CPM_CPPCR1 & CPPCR1_PLL1M_MASK) >> CPPCR1_PLL1M_LSB) +#define __cpm_get_pll1n() \ + ((REG_CPM_CPPCR1 & CPPCR1_PLL1N_MASK) >> CPPCR1_PLL1N_LSB) +#define __cpm_get_pll1od() \ + ((REG_CPM_CPPCR1 & CPPCR1_PLL1OD_MASK) >> CPPCR1_PLL1OD_LSB) + +#define __cpm_get_cdiv() \ + ((REG_CPM_CPCCR & CPCCR_CDIV_MASK) >> CPCCR_CDIV_LSB) +#define __cpm_get_hdiv() \ + ((REG_CPM_CPCCR & CPCCR_HDIV_MASK) >> CPCCR_HDIV_LSB) +#define __cpm_get_h2div() \ + ((REG_CPM_CPCCR & CPCCR_H2DIV_MASK) >> CPCCR_H2DIV_LSB) +#define __cpm_get_pdiv() \ + ((REG_CPM_CPCCR & CPCCR_PDIV_MASK) >> CPCCR_PDIV_LSB) +#define __cpm_get_mdiv() \ + ((REG_CPM_CPCCR & CPCCR_MDIV_MASK) >> CPCCR_MDIV_LSB) +#define __cpm_get_sdiv() \ + ((REG_CPM_CPCCR & CPCCR_SDIV_MASK) >> CPCCR_SDIV_LSB) +#define __cpm_get_i2sdiv() \ + ((REG_CPM_I2SCDR & I2SCDR_I2SDIV_MASK) >> I2SCDR_I2SDIV_LSB) +#define __cpm_get_pixdiv() \ + ((REG_CPM_LPCDR & LPCDR_PIXDIV_MASK) >> LPCDR_PIXDIV_LSB) +#define __cpm_get_mscdiv() \ + ((REG_CPM_MSCCDR & MSCCDR_MSCDIV_MASK) >> MSCCDR_MSCDIV_LSB) +#define __cpm_get_ssidiv() \ + ((REG_CPM_SSICCDR & SSICDR_SSICDIV_MASK) >> SSICDR_SSIDIV_LSB) +#define __cpm_get_pcmdiv() \ + ((REG_CPM_PCMCDR & PCMCDR_PCMCD_MASK) >> PCMCDR_PCMCD_LSB) +#define __cpm_get_pll1div() \ + ((REG_CPM_CPPCR1 & CPCCR1_P1SDIV_MASK) >> CPCCR1_P1SDIV_LSB) + +#define __cpm_set_cdiv(v) \ + (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPCCR_CDIV_MASK) | ((v) << (CPCCR_CDIV_LSB))) +#define __cpm_set_hdiv(v) \ + (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPCCR_HDIV_MASK) | ((v) << (CPCCR_HDIV_LSB))) +#define __cpm_set_pdiv(v) \ + (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPCCR_PDIV_MASK) | ((v) << (CPCCR_PDIV_LSB))) +#define __cpm_set_mdiv(v) \ + (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPCCR_MDIV_MASK) | ((v) << (CPCCR_MDIV_LSB))) +#define __cpm_set_h1div(v) \ + (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPCCR_H1DIV_MASK) | ((v) << (CPCCR_H1DIV_LSB))) +#define __cpm_set_udiv(v) \ + (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPCCR_UDIV_MASK) | ((v) << (CPCCR_UDIV_LSB))) +#define __cpm_set_i2sdiv(v) \ + (REG_CPM_I2SCDR = (REG_CPM_I2SCDR & ~I2SCDR_I2SDIV_MASK) | ((v) << (I2SCDR_I2SDIV_LSB))) +#define __cpm_set_pixdiv(v) \ + (REG_CPM_LPCDR = (REG_CPM_LPCDR & ~LPCDR_PIXDIV_MASK) | ((v) << (LPCDR_PIXDIV_LSB))) +#define __cpm_set_mscdiv(v) \ + (REG_CPM_MSCCDR = (REG_CPM_MSCCDR & ~MSCCDR_MSCDIV_MASK) | ((v) << (MSCCDR_MSCDIV_LSB))) +#define __cpm_set_ssidiv(v) \ + (REG_CPM_SSICDR = (REG_CPM_SSICDR & ~SSICDR_SSIDIV_MASK) | ((v) << (SSICDR_SSIDIV_LSB))) +#define __cpm_set_pcmdiv(v) \ + (REG_CPM_PCMCDR = (REG_CPM_PCMCDR & ~PCMCDR_PCMCD_MASK) | ((v) << (PCMCDR_PCMCD_LSB))) +#define __cpm_set_pll1div(v) \ + (REG_CPM_CPPCR1 = (REG_CPM_CPPCR1 & ~CPCCR1_P1SDIV_MASK) | ((v) << (CPCCR1_P1SDIV_LSB))) + +#define __cpm_select_i2sclk_pll1() (REG_CPM_I2SCDR |= I2SCDR_I2PCS) +#define __cpm_select_i2sclk_pll0() (REG_CPM_I2SCDR &= ~I2SCDR_I2PCS) +#define __cpm_select_otgclk_pll1() (REG_CPM_USBCDR |= USBCDR_UPCS) +#define __cpm_select_otgclk_pll0() (REG_CPM_USBCDR &= ~USBCDR_UPCS) +#define __cpm_select_lcdpclk_pll1() (REG_CPM_LPCDR |= LPCDR_LPCS) +#define __cpm_select_lcdpclk_pll0() (REG_CPM_LPCDR &= ~LPCDR_LPCS) +#define __cpm_select_uhcclk_pll1() (REG_CPM_UHCCDR |= UHCCDR_UHPCS) +#define __cpm_select_uhcclk_pll0() (REG_CPM_UHCCDR &= ~UHCCDR_UHPCS) +#define __cpm_select_gpsclk_pll1() (REG_CPM_GPSCDR |= GPSCDR_GPCS) +#define __cpm_select_gpsclk_pll0() (REG_CPM_GPSCDR &= ~GPSCDR_GPCS) +#define __cpm_select_pcmclk_pll1() (REG_CPM_PCMCDR |= PCMCDR_PCMPCS) +#define __cpm_select_pcmclk_pll0() (REG_CPM_PCMCDR &= ~PCMCDR_PCMPCS) +#define __cpm_select_gpuclk_pll1() (REG_CPM_GPUCDR |= GPUCDR_GPCS) +#define __cpm_select_gpuclk_pll0() (REG_CPM_GPUCDR &= ~GPUCDR_GPCS) +#define __cpm_select_clk_pll1() (REG_CPM_CDR |= CDR_PCS) +#define __cpm_select_clk_pll0() (REG_CPM_CDR &= ~CDR_PCS) + + +#define __cpm_select_pcmclk_pll() (REG_CPM_PCMCDR |= PCMCDR_PCMS) +#define __cpm_select_pcmclk_exclk() (REG_CPM_PCMCDR &= ~PCMCDR_PCMS) +#define __cpm_select_pixclk_ext() (REG_CPM_LPCDR |= LPCDR_LPCS) +#define __cpm_select_pixclk_pll() (REG_CPM_LPCDR &= ~LPCDR_LPCS) +#define __cpm_select_tveclk_exclk() (REG_CPM_LPCDR |= CPCCR_LSCS) +#define __cpm_select_tveclk_pll() (REG_CPM_LPCDR &= ~LPCDR_LSCS) +#define __cpm_select_pixclk_lcd() (REG_CPM_LPCDR &= ~LPCDR_LTCS) +#define __cpm_select_pixclk_tve() (REG_CPM_LPCDR |= LPCDR_LTCS) +#define __cpm_select_i2sclk_exclk() (REG_CPM_I2SCDR &= ~I2SCDR_I2CS) +#define __cpm_select_i2sclk_pll() (REG_CPM_I2SCDR |= I2SCDR_I2CS) +//#define __cpm_select_usbclk_exclk() (REG_CPM_CPCCR &= ~CPCCR_UCS) +//#define __cpm_select_usbclk_pll() (REG_CPM_CPCCR |= CPCCR_UCS) + +#define __cpm_enable_cko() +#define __cpm_exclk_direct() (REG_CPM_CPCCR &= ~CPCCR_ECS) +#define __cpm_exclk_div2() (REG_CPM_CPCCR |= CPCCR_ECS) +#define __cpm_enable_pll_change() (REG_CPM_CPCCR |= CPCCR_CE) + +#define __cpm_pllout_div2() (REG_CPM_CPCCR &= ~CPCCR_PCS) +#define __cpm_pll_enable() (REG_CPM_CPPCR0 |= CPPCR0_PLLEN) + +#define __cpm_pll1_enable() (REG_CPM_CPPCR1 |= CPPCR1_PLL1EN) + +#define __cpm_pll_is_off() (REG_CPM_CPPSR & CPPSR_PLLOFF) +#define __cpm_pll_is_on() (REG_CPM_CPPSR & CPPSR_PLLON) +#define __cpm_pll_bypass() (REG_CPM_CPPSR |= CPPSR_PLLBP) + +#define __cpm_get_cclk_doze_duty() \ + ((REG_CPM_LCR & LCR_DOZE_DUTY_MASK) >> LCR_DOZE_DUTY_LSB) +#define __cpm_set_cclk_doze_duty(v) \ + (REG_CPM_LCR = (REG_CPM_LCR & ~LCR_DOZE_DUTY_MASK) | ((v) << (LCR_DOZE_DUTY_LSB))) + +#define __cpm_doze_mode() (REG_CPM_LCR |= LCR_DOZE_ON) +#define __cpm_idle_mode() \ + (REG_CPM_LCR = (REG_CPM_LCR & ~LCR_LPM_MASK) | LCR_LPM_IDLE) +#define __cpm_sleep_mode() \ + (REG_CPM_LCR = (REG_CPM_LCR & ~LCR_LPM_MASK) | LCR_LPM_SLEEP) + +#define __cpm_stop_all() \ + do {\ + (REG_CPM_CLKGR0 = 0xffffffff);\ + (REG_CPM_CLKGR1 = 0x3ff);\ + }while(0) +#define __cpm_stop_emc() (REG_CPM_CLKGR0 |= CLKGR0_EMC) +#define __cpm_stop_ddr() (REG_CPM_CLKGR0 |= CLKGR0_DDR) +#define __cpm_stop_ipu() (REG_CPM_CLKGR0 |= CLKGR0_IPU) +#define __cpm_stop_lcd() (REG_CPM_CLKGR0 |= CLKGR0_LCD) +#define __cpm_stop_tve() (REG_CPM_CLKGR0 |= CLKGR0_TVE) +#define __cpm_stop_Cim() (REG_CPM_CLKGR0 |= CLKGR0_CIM) +#define __cpm_stop_mdma() (REG_CPM_CLKGR0 |= CLKGR0_MDMA) +#define __cpm_stop_uhc() (REG_CPM_CLKGR0 |= CLKGR0_UHC) +#define __cpm_stop_mac() (REG_CPM_CLKGR0 |= CLKGR0_MAC) +#define __cpm_stop_gps() (REG_CPM_CLKGR0 |= CLKGR0_GPS) +#define __cpm_stop_dmac() (REG_CPM_CLKGR0 |= CLKGR0_DMAC) +#define __cpm_stop_ssi2() (REG_CPM_CLKGR0 |= CLKGR0_SSI2) +#define __cpm_stop_ssi1() (REG_CPM_CLKGR0 |= CLKGR0_SSI1) +#define __cpm_stop_uart3() (REG_CPM_CLKGR0 |= CLKGR0_UART3) +#define __cpm_stop_uart2() (REG_CPM_CLKGR0 |= CLKGR0_UART2) +#define __cpm_stop_uart1() (REG_CPM_CLKGR0 |= CLKGR0_UART1) +#define __cpm_stop_uart0() (REG_CPM_CLKGR0 |= CLKGR0_UART0) +#define __cpm_stop_sadc() (REG_CPM_CLKGR0 |= CLKGR0_SADC) +#define __cpm_stop_kbc() (REG_CPM_CLKGR0 |= CLKGR0_KBC) +#define __cpm_stop_msc2() (REG_CPM_CLKGR0 |= CLKGR0_MSC2) +#define __cpm_stop_msc1() (REG_CPM_CLKGR0 |= CLKGR0_MSC1) +#define __cpm_stop_owi() (REG_CPM_CLKGR0 |= CLKGR0_OWI) +#define __cpm_stop_tssi() (REG_CPM_CLKGR0 |= CLKGR0_TSSI) +#define __cpm_stop_aic() (REG_CPM_CLKGR0 |= CLKGR0_AIC) +#define __cpm_stop_scc() (REG_CPM_CLKGR0 |= CLKGR0_SCC) +#define __cpm_stop_i2c1() (REG_CPM_CLKGR0 |= CLKGR0_I2C1) +#define __cpm_stop_i2c0() (REG_CPM_CLKGR0 |= CLKGR0_I2C0) +#define __cpm_stop_ssi0() (REG_CPM_CLKGR0 |= CLKGR0_SSI0) +#define __cpm_stop_msc0() (REG_CPM_CLKGR0 |= CLKGR0_MSC0) +#define __cpm_stop_otg() (REG_CPM_CLKGR0 |= CLKGR0_OTG) +#define __cpm_stop_bch() (REG_CPM_CLKGR0 |= CLKGR0_BCH) +#define __cpm_stop_nemc() (REG_CPM_CLKGR0 |= CLKGR0_NEMC) +#define __cpm_stop_gpu() (REG_CPM_CLKGR1 |= CLKGR1_GPU) +#define __cpm_stop_pcm() (REG_CPM_CLKGR1 |= CLKGR1_PCM) +#define __cpm_stop_ahb1() (REG_CPM_CLKGR1 |= CLKGR1_AHB1) +#define __cpm_stop_cabac() (REG_CPM_CLKGR1 |= CLKGR1_CABAC) +#define __cpm_stop_sram() (REG_CPM_CLKGR1 |= CLKGR1_SRAM) +#define __cpm_stop_dct() (REG_CPM_CLKGR1 |= CLKGR1_DCT) +#define __cpm_stop_me() (REG_CPM_CLKGR1 |= CLKGR1_ME) +#define __cpm_stop_dblk() (REG_CPM_CLKGR1 |= CLKGR1_DBLK) +#define __cpm_stop_mc() (REG_CPM_CLKGR1 |= CLKGR1_MC) +#define __cpm_stop_bdma() (REG_CPM_CLKGR1 |= CLKGR1_BDMA) + +#define __cpm_start_all() \ + do {\ + REG_CPM_CLKGR0 = 0x0;\ + REG_CPM_CLKGR1 = 0x0;\ + } while(0) +#define __cpm_start_emc() (REG_CPM_CLKGR0 &= ~CLKGR0_EMC) +#define __cpm_start_ddr() (REG_CPM_CLKGR0 &= ~CLKGR0_DDR) +#define __cpm_start_ipu() (REG_CPM_CLKGR0 &= ~CLKGR0_IPU) +#define __cpm_start_lcd() (REG_CPM_CLKGR0 &= ~CLKGR0_LCD) +#define __cpm_start_tve() (REG_CPM_CLKGR0 &= ~CLKGR0_TVE) +#define __cpm_start_Cim() (REG_CPM_CLKGR0 &= ~CLKGR0_CIM) +#define __cpm_start_mdma() (REG_CPM_CLKGR0 &= ~CLKGR0_MDMA) +#define __cpm_start_uhc() (REG_CPM_CLKGR0 &= ~CLKGR0_UHC) +#define __cpm_start_mac() (REG_CPM_CLKGR0 &= ~CLKGR0_MAC) +#define __cpm_start_gps() (REG_CPM_CLKGR0 &= ~CLKGR0_GPS) +#define __cpm_start_dmac() (REG_CPM_CLKGR0 &= ~CLKGR0_DMAC) +#define __cpm_start_ssi2() (REG_CPM_CLKGR0 &= ~CLKGR0_SSI2) +#define __cpm_start_ssi1() (REG_CPM_CLKGR0 &= ~CLKGR0_SSI1) +#define __cpm_start_uart3() (REG_CPM_CLKGR0 &= ~CLKGR0_UART3) +#define __cpm_start_uart2() (REG_CPM_CLKGR0 &= ~CLKGR0_UART2) +#define __cpm_start_uart1() (REG_CPM_CLKGR0 &= ~CLKGR0_UART1) +#define __cpm_start_uart0() (REG_CPM_CLKGR0 &= ~CLKGR0_UART0) +#define __cpm_start_sadc() (REG_CPM_CLKGR0 &= ~CLKGR0_SADC) +#define __cpm_start_kbc() (REG_CPM_CLKGR0 &= ~CLKGR0_KBC) +#define __cpm_start_msc2() (REG_CPM_CLKGR0 &= ~CLKGR0_MSC2) +#define __cpm_start_msc1() (REG_CPM_CLKGR0 &= ~CLKGR0_MSC1) +#define __cpm_start_owi() (REG_CPM_CLKGR0 &= ~CLKGR0_OWI) +#define __cpm_start_tssi() (REG_CPM_CLKGR0 &= ~CLKGR0_TSSI) +#define __cpm_start_aic() (REG_CPM_CLKGR0 &= ~CLKGR0_AIC) +#define __cpm_start_scc() (REG_CPM_CLKGR0 &= ~CLKGR0_SCC) +#define __cpm_start_i2c1() (REG_CPM_CLKGR0 &= ~CLKGR0_I2C1) +#define __cpm_start_i2c0() (REG_CPM_CLKGR0 &= ~CLKGR0_I2C0) +#define __cpm_start_ssi0() (REG_CPM_CLKGR0 &= ~CLKGR0_SSI0) +#define __cpm_start_msc0() (REG_CPM_CLKGR0 &= ~CLKGR0_MSC0) +#define __cpm_start_otg() (REG_CPM_CLKGR0 &= ~CLKGR0_OTG) +#define __cpm_start_bch() (REG_CPM_CLKGR0 &= ~CLKGR0_BCH) +#define __cpm_start_nemc() (REG_CPM_CLKGR0 &= ~CLKGR0_NEMC) +#define __cpm_start_gpu() (REG_CPM_CLKGR1 &= ~CLKGR1_GPU) +#define __cpm_start_pcm() (REG_CPM_CLKGR1 &= ~CLKGR1_PCM) +#define __cpm_start_ahb1() (REG_CPM_CLKGR1 &= ~CLKGR1_AHB1) +#define __cpm_start_cabac() (REG_CPM_CLKGR1 &= ~CLKGR1_CABAC) +#define __cpm_start_sram() (REG_CPM_CLKGR1 &= ~CLKGR1_SRAM) +#define __cpm_start_dct() (REG_CPM_CLKGR1 &= ~CLKGR1_DCT) +#define __cpm_start_me() (REG_CPM_CLKGR1 &= ~CLKGR1_ME) +#define __cpm_start_dblk() (REG_CPM_CLKGR1 &= ~CLKGR1_DBLK) +#define __cpm_start_mc() (REG_CPM_CLKGR1 &= ~CLKGR1_MC) +#define __cpm_start_bdma() (REG_CPM_CLKGR1 &= ~CLKGR1_BDMA) + +#define __cpm_get_o1st() \ + ((REG_CPM_OPCR & OPCR_O1ST_MASK) >> OPCR_O1ST_LSB) +#define __cpm_set_o1st(v) \ + (REG_CPM_OPCR = (REG_CPM_OPCR & ~OPCR_O1ST_MASK) | ((v) << (OPCR_O1ST_LSB))) +#define __cpm_suspend_otgphy() (REG_CPM_OPCR &= ~OPCR_OTGPHY_ENABLE) +#define __cpm_resume_otgphy() (REG_CPM_OPCR |= OPCR_OTGPHY_ENABLE) +#define __cpm_enable_osc_in_sleep() (REG_CPM_OPCR |= OPCR_OSC_ENABLE) +#define __cpm_select_rtcclk_rtc() (REG_CPM_OPCR |= OPCR_ERCS) +#define __cpm_select_rtcclk_exclk() (REG_CPM_OPCR &= ~OPCR_ERCS) + +#ifdef CFG_EXTAL +#define JZ_EXTAL CFG_EXTAL +#else +#define JZ_EXTAL 12000000 +#endif +#define JZ_EXTAL2 32768 /* RTC clock */ + +/* PLL output frequency */ +static __inline__ unsigned int __cpm_get_pllout(void) +{ + unsigned long m, n, no, pllout; + unsigned long cppcr = REG_CPM_CPPCR0; + unsigned long od[4] = {1, 2, 4, 8}; + if ((cppcr & CPPCR0_PLLEN) && (!(cppcr & CPPCR0_PLLBP))) { + m = __cpm_get_pllm() * 2; + n = __cpm_get_plln(); + no = od[__cpm_get_pllod()]; + pllout = ((JZ_EXTAL) * m / (n * no)); + } else + pllout = JZ_EXTAL; + return pllout; +} + +/* PLL output frequency */ +static __inline__ unsigned int __cpm_get_pll1out(void) +{ + unsigned long m, n, no, pllout; + unsigned long cppcr1 = REG_CPM_CPPCR1; + unsigned long od[4] = {1, 2, 4, 8}; + if (cppcr1 & CPPCR1_PLL1EN) + { + m = __cpm_get_pll1m() * 2; + n = __cpm_get_pll1n(); + no = od[__cpm_get_pll1od()]; + if (cppcr1 & CPPCR1_P1SCS) + pllout = ((__cpm_get_pllout()) * m / (n * no)); + else + pllout = ((JZ_EXTAL) * m / (n * no)); + + } else + pllout = JZ_EXTAL; + return pllout; +} + +/* PLL output frequency for MSC/I2S/LCD/USB */ +static __inline__ unsigned int __cpm_get_pllout2(void) +{ + if (REG_CPM_CPCCR & CPCCR_PCS) + return __cpm_get_pllout(); + else + return __cpm_get_pllout()/2; +} + +/* CPU core clock */ +static __inline__ unsigned int __cpm_get_cclk(void) +{ + int div[] = {1, 2, 3, 4, 6, 8}; + + return __cpm_get_pllout() / div[__cpm_get_cdiv()]; +} + +/* AHB system bus clock */ +static __inline__ unsigned int __cpm_get_hclk(void) +{ + int div[] = {1, 2, 3, 4, 6, 8}; + + return __cpm_get_pllout() / div[__cpm_get_hdiv()]; +} + +/* Memory bus clock */ +static __inline__ unsigned int __cpm_get_mclk(void) +{ + int div[] = {1, 2, 3, 4, 6, 8}; + + return __cpm_get_pllout() / div[__cpm_get_mdiv()]; +} + +/* APB peripheral bus clock */ +static __inline__ unsigned int __cpm_get_pclk(void) +{ + int div[] = {1, 2, 3, 4, 6, 8}; + + return __cpm_get_pllout() / div[__cpm_get_pdiv()]; +} + +/* AHB1 module clock */ +static __inline__ unsigned int __cpm_get_h2clk(void) +{ + int div[] = {1, 2, 3, 4, 6, 8}; + + return __cpm_get_pllout() / div[__cpm_get_h2div()]; +} + +/* LCD pixel clock */ +static __inline__ unsigned int __cpm_get_pixclk(void) +{ + return __cpm_get_pllout2() / (__cpm_get_pixdiv() + 1); +} + +/* I2S clock */ +static __inline__ unsigned int __cpm_get_i2sclk(void) +{ + if (REG_CPM_I2SCDR & I2SCDR_I2CS) { + return __cpm_get_pllout2() / (__cpm_get_i2sdiv() + 1); + } + else { + return JZ_EXTAL; + } +} + +/* USB clock */ +/* +static __inline__ unsigned int __cpm_get_usbclk(void) +{ + if (REG_CPM_CPCCR & CPCCR_UCS) { + return __cpm_get_pllout2() / (__cpm_get_udiv() + 1); + } + else { + return JZ_EXTAL; + } +} +*/ +/* EXTAL clock for UART,I2C,SSI,TCU,USB-PHY */ +static __inline__ unsigned int __cpm_get_extalclk(void) +{ + return JZ_EXTAL; +} + +/* RTC clock for CPM,INTC,RTC,TCU,WDT */ +static __inline__ unsigned int __cpm_get_rtcclk(void) +{ + return JZ_EXTAL2; +} + +/* + * Output 24MHz for SD and 16MHz for MMC. + */ +static inline void __cpm_select_msc_clk(int sd) +{ + unsigned int pllout2 = __cpm_get_pllout2(); + unsigned int div = 0; + + if (sd) { + div = pllout2 / 24000000; + } + else { + div = pllout2 / 16000000; + } + + REG_CPM_MSCCDR = (div - 1)|(1<<31); + REG_CPM_CPCCR |= CPCCR_CE; +} + +#endif /* __MIPS_ASSEMBLER */ + +#define DDRC_BASE 0xB3020000 + +/************************************************************************* + * DDRC (DDR Controller) + *************************************************************************/ +#define DDRC_ST (DDRC_BASE + 0x0) /* DDR Status Register */ +#define DDRC_CFG (DDRC_BASE + 0x4) /* DDR Configure Register */ +#define DDRC_CTRL (DDRC_BASE + 0x8) /* DDR Control Register */ +#define DDRC_LMR (DDRC_BASE + 0xc) /* DDR Load-Mode-Register */ +#define DDRC_TIMING1 (DDRC_BASE + 0x10) /* DDR Timing Config Register 1 */ +#define DDRC_TIMING2 (DDRC_BASE + 0x14) /* DDR Timing Config Register 2 */ +#define DDRC_REFCNT (DDRC_BASE + 0x18) /* DDR Auto-Refresh Counter */ +#define DDRC_DQS (DDRC_BASE + 0x1c) /* DDR DQS Delay Control Register */ +#define DDRC_DQS_ADJ (DDRC_BASE + 0x20) /* DDR DQS Delay Adjust Register */ +#define DDRC_MMAP0 (DDRC_BASE + 0x24) /* DDR Memory Map Config Register */ +#define DDRC_MMAP1 (DDRC_BASE + 0x28) /* DDR Memory Map Config Register */ +#define DDRC_DDELAYCTRL1 (DDRC_BASE + 0x2c) +#define DDRC_DDELAYCTRL2 (DDRC_BASE + 0x30) +#define DDRC_DSTRB (DDRC_BASE + 0x34) +#define DDRC_PMEMBS0 (DDRC_BASE + 0x50) +#define DDRC_PMEMBS1 (DDRC_BASE + 0x54) +#define DDRC_PMEMOSEL (DDRC_BASE + 0x58) +#define DDRC_PMEMOEN (DDRC_BASE + 0x5c) + +/* DDRC Register */ +#define REG_DDRC_ST REG32(DDRC_ST) +#define REG_DDRC_CFG REG32(DDRC_CFG) +#define REG_DDRC_CTRL REG32(DDRC_CTRL) +#define REG_DDRC_LMR REG32(DDRC_LMR) +#define REG_DDRC_TIMING1 REG32(DDRC_TIMING1) +#define REG_DDRC_TIMING2 REG32(DDRC_TIMING2) +#define REG_DDRC_REFCNT REG32(DDRC_REFCNT) +#define REG_DDRC_DQS REG32(DDRC_DQS) +#define REG_DDRC_DQS_ADJ REG32(DDRC_DQS_ADJ) +#define REG_DDRC_MMAP0 REG32(DDRC_MMAP0) +#define REG_DDRC_MMAP1 REG32(DDRC_MMAP1) +#define REG_DDRC_DDELAYCTRL1 REG32(DDRC_DDELAYCTRL1) +#define REG_DDRC_DDELAYCTRL2 REG32(DDRC_DDELAYCTRL2) +#define REG_DDRC_DSTRB REG32(DDRC_DSTRB) +#define REG_DDRC_PMEMBS0 REG32(DDRC_PMEMBS0) +#define REG_DDRC_PMEMBS1 REG32(DDRC_PMEMBS1) +#define REG_DDRC_PMEMOSEL REG32(DDRC_PMEMOSEL) +#define REG_DDRC_PMEMOEN REG32(DDRC_PMEMOEN) + +/* DDRC Status Register */ +#define DDRC_ST_ENDIAN (1 << 7) /* 0 Little data endian + 1 Big data endian */ +#define DDRC_ST_MISS (1 << 6) + +#define DDRC_ST_DPDN (1 << 5) /* 0 DDR memory is NOT in deep-power-down state + 1 DDR memory is in deep-power-down state */ +#define DDRC_ST_PDN (1 << 4) /* 0 DDR memory is NOT in power-down state + 1 DDR memory is in power-down state */ +#define DDRC_ST_AREF (1 << 3) /* 0 DDR memory is NOT in auto-refresh state + 1 DDR memory is in auto-refresh state */ +#define DDRC_ST_SREF (1 << 2) /* 0 DDR memory is NOT in self-refresh state + 1 DDR memory is in self-refresh state */ +#define DDRC_ST_CKE1 (1 << 1) /* 0 CKE1 Pin is low + 1 CKE1 Pin is high */ +#define DDRC_ST_CKE0 (1 << 0) /* 0 CKE0 Pin is low + 1 CKE0 Pin is high */ + +/* DDRC Configure Register */ +#define DDRC_CFG_RDPRI (1 << 29) +#define DDRC_CFG_ROW1_BIT 27 /* Row Address width. */ +#define DDRC_CFG_COL1_BIT 25 /* Row Address width. */ +#define DDRC_CFG_BA1 (1 << 24) +#define DDRC_CFG_IMBA (1 << 23) +#define DDRC_CFG_DQSMD (1 << 22) +#define DDRC_CFG_BTRUN (1 << 21) + +#define DDRC_CFG_MISPE (1 << 15) + +#define DDRC_CFG_TYPE_BIT 12 +#define DDRC_CFG_TYPE_MASK (0x7 << DDRC_CFG_TYPE_BIT) +#define DDRC_CFG_TYPE_DDR1 (2 << DDRC_CFG_TYPE_BIT) +#define DDRC_CFG_TYPE_MDDR (3 << DDRC_CFG_TYPE_BIT) +#define DDRC_CFG_TYPE_DDR2 (4 << DDRC_CFG_TYPE_BIT) + +#define DDRC_CFG_ROW_BIT 10 /* Row Address width. */ +#define DDRC_CFG_ROW_MASK (0x3 << DDRC_CFG_ROW_BIT) +#define DDRC_CFG_ROW_12 (0 << DDRC_CFG_ROW_BIT) /* 12-bit row address is used */ +#define DDRC_CFG_ROW_13 (1 << DDRC_CFG_ROW_BIT) /* 13-bit row address is used */ +#define DDRC_CFG_ROW_14 (2 << DDRC_CFG_ROW_BIT) /* 14-bit row address is used */ + +#define DDRC_CFG_COL_BIT 8 /* Column Address width. + Specify the Column address width of external DDR. */ +#define DDRC_CFG_COL_MASK (0x3 << DDRC_CFG_COL_BIT) +#define DDRC_CFG_COL_8 (0 << DDRC_CFG_COL_BIT) /* 8-bit Column address is used */ +#define DDRC_CFG_COL_9 (1 << DDRC_CFG_COL_BIT) /* 9-bit Column address is used */ +#define DDRC_CFG_COL_10 (2 << DDRC_CFG_COL_BIT) /* 10-bit Column address is used */ +#define DDRC_CFG_COL_11 (3 << DDRC_CFG_COL_BIT) /* 11-bit Column address is used */ + +#define DDRC_CFG_CS1EN (1 << 7) /* 0 DDR Pin CS1 un-used + 1 There're DDR memory connected to CS1 */ +#define DDRC_CFG_CS0EN (1 << 6) /* 0 DDR Pin CS0 un-used + 1 There're DDR memory connected to CS0 */ + +#define DDRC_CFG_CL_BIT 2 /* CAS Latency */ +#define DDRC_CFG_CL_MASK (0xf << DDRC_CFG_CL_BIT) +#define DDRC_CFG_CL_3 (0x0a << DDRC_CFG_CL_BIT) /* CL = 3 tCK */ +#define DDRC_CFG_CL_4 (0x0b << DDRC_CFG_CL_BIT) /* CL = 4 tCK */ +#define DDRC_CFG_CL_5 (0x0c << DDRC_CFG_CL_BIT) /* CL = 5 tCK */ +#define DDRC_CFG_CL_6 (0x0d << DDRC_CFG_CL_BIT) /* CL = 6 tCK */ +#define DDRC_CFG_CL_7 (0x0e << DDRC_CFG_CL_BIT) /* CL = 7 tCK */ + +#define DDRC_CFG_BA (1 << 1) /* 0 4 bank device, Pin ba[1:0] valid, ba[2] un-used + 1 8 bank device, Pin ba[2:0] valid*/ +#define DDRC_CFG_DW (1 << 0) /*0 External memory data width is 16-bit + 1 External memory data width is 32-bit */ + +/* DDRC Control Register */ +#define DDRC_CTRL_ACTPD (1 << 15) /* 0 Precharge all banks before entering power-down + 1 Do not precharge banks before entering power-down */ +#define DDRC_CTRL_PDT_BIT 12 /* Power-Down Timer */ +#define DDRC_CTRL_PDT_MASK (0x7 << DDRC_CTRL_PDT_BIT) +#define DDRC_CTRL_PDT_DIS (0 << DDRC_CTRL_PDT_BIT) /* power-down disabled */ +#define DDRC_CTRL_PDT_8 (1 << DDRC_CTRL_PDT_BIT) /* Enter power-down after 8 tCK idle */ +#define DDRC_CTRL_PDT_16 (2 << DDRC_CTRL_PDT_BIT) /* Enter power-down after 16 tCK idle */ +#define DDRC_CTRL_PDT_32 (3 << DDRC_CTRL_PDT_BIT) /* Enter power-down after 32 tCK idle */ +#define DDRC_CTRL_PDT_64 (4 << DDRC_CTRL_PDT_BIT) /* Enter power-down after 64 tCK idle */ +#define DDRC_CTRL_PDT_128 (5 << DDRC_CTRL_PDT_BIT) /* Enter power-down after 128 tCK idle */ + +#define DDRC_CTRL_PRET_BIT 8 /* Precharge Timer */ +#define DDRC_CTRL_PRET_MASK (0x7 << DDRC_CTRL_PRET_BIT) /* */ + #define DDRC_CTRL_PRET_DIS (0 << DDRC_CTRL_PRET_BIT) /* PRET function Disabled */ + #define DDRC_CTRL_PRET_8 (1 << DDRC_CTRL_PRET_BIT) /* Precharge active bank after 8 tCK idle */ + #define DDRC_CTRL_PRET_16 (2 << DDRC_CTRL_PRET_BIT) /* Precharge active bank after 16 tCK idle */ + #define DDRC_CTRL_PRET_32 (3 << DDRC_CTRL_PRET_BIT) /* Precharge active bank after 32 tCK idle */ + #define DDRC_CTRL_PRET_64 (4 << DDRC_CTRL_PRET_BIT) /* Precharge active bank after 64 tCK idle */ + #define DDRC_CTRL_PRET_128 (5 << DDRC_CTRL_PRET_BIT) /* Precharge active bank after 128 tCK idle */ + +#define DDRC_CTRL_SR (1 << 5) /* 1 Drive external DDR device entering self-refresh mode + 0 Drive external DDR device exiting self-refresh mode */ +#define DDRC_CTRL_UNALIGN (1 << 4) /* 0 Disable unaligned transfer on AXI BUS + 1 Enable unaligned transfer on AXI BUS */ +#define DDRC_CTRL_ALH (1 << 3) /* Advanced Latency Hiding: + 0 Disable ALH + 1 Enable ALH */ +#define DDRC_CTRL_CKE (1 << 1) /* 0 Not set CKE Pin High + 1 Set CKE Pin HIGH */ +#define DDRC_CTRL_RESET (1 << 0) /* 0 End resetting ddrc_controller + 1 Resetting ddrc_controller */ + +/* DDRC Load-Mode-Register */ +#define DDRC_LMR_DDR_ADDR_BIT 16 /* When performing a DDR command, DDRC_ADDR[13:0] + corresponding to external DDR address Pin A[13:0] */ +#define DDRC_LMR_DDR_ADDR_MASK (0x3fff << DDRC_LMR_DDR_ADDR_BIT) + +#define DDRC_LMR_BA_BIT 8 /* When performing a DDR command, BA[2:0] + corresponding to external DDR address Pin BA[2:0]. */ +#define DDRC_LMR_BA_MASK (0x7 << DDRC_LMR_BA_BIT) +/* For DDR2 */ +#define DDRC_LMR_BA_MRS (0 << DDRC_LMR_BA_BIT) /* Mode Register set */ +#define DDRC_LMR_BA_EMRS1 (1 << DDRC_LMR_BA_BIT) /* Extended Mode Register1 set */ +#define DDRC_LMR_BA_EMRS2 (2 << DDRC_LMR_BA_BIT) /* Extended Mode Register2 set */ +#define DDRC_LMR_BA_EMRS3 (3 << DDRC_LMR_BA_BIT) /* Extended Mode Register3 set */ +/* For mobile DDR */ +#define DDRC_LMR_BA_M_MRS (0 << DDRC_LMR_BA_BIT) /* Mode Register set */ +#define DDRC_LMR_BA_M_EMRS (2 << DDRC_LMR_BA_BIT) /* Extended Mode Register set */ +#define DDRC_LMR_BA_M_SR (1 << DDRC_LMR_BA_BIT) /* Status Register set */ + +#define DDRC_LMR_CMD_BIT 4 +#define DDRC_LMR_CMD_MASK (0x3 << DDRC_LMR_CMD_BIT) +#define DDRC_LMR_CMD_PREC (0 << DDRC_LMR_CMD_BIT)/* Precharge one bank/All banks */ +#define DDRC_LMR_CMD_AUREF (1 << DDRC_LMR_CMD_BIT)/* Auto-Refresh */ +#define DDRC_LMR_CMD_LMR (2 << DDRC_LMR_CMD_BIT)/* Load Mode Register */ + +#define DDRC_LMR_START (1 << 0) /* 0 No command is performed + 1 On the posedge of START, perform a command + defined by CMD field */ +/* DDRC Mode Register Set */ +#define DDR_MRS_PD_BIT (1 << 10) /* Active power down exit time */ +#define DDR_MRS_PD_MASK (1 << DDR_MRS_PD_BIT) +#define DDR_MRS_PD_FAST_EXIT (0 << 10) +#define DDR_MRS_PD_SLOW_EXIT (1 << 10) +#define DDR_MRS_WR_BIT (1 << 9) /* Write Recovery for autoprecharge */ +#define DDR_MRS_WR_MASK (7 << DDR_MRS_WR_BIT) +#define DDR_MRS_DLL_RST (1 << 8) /* DLL Reset */ +#define DDR_MRS_TM_BIT 7 /* Operating Mode */ +#define DDR_MRS_TM_MASK (1 << DDR_MRS_OM_BIT) +#define DDR_MRS_TM_NORMAL (0 << DDR_MRS_OM_BIT) +#define DDR_MRS_TM_TEST (1 << DDR_MRS_OM_BIT) +#define DDR_MRS_CAS_BIT 4 /* CAS Latency */ +#define DDR_MRS_CAS_MASK (7 << DDR_MRS_CAS_BIT) +#define DDR_MRS_BT_BIT 3 /* Burst Type */ +#define DDR_MRS_BT_MASK (1 << DDR_MRS_BT_BIT) +#define DDR_MRS_BT_SEQ (0 << DDR_MRS_BT_BIT) /* Sequential */ +#define DDR_MRS_BT_INT (1 << DDR_MRS_BT_BIT) /* Interleave */ +#define DDR_MRS_BL_BIT 0 /* Burst Length */ +#define DDR_MRS_BL_MASK (7 << DDR_MRS_BL_BIT) +#define DDR_MRS_BL_4 (2 << DDR_MRS_BL_BIT) +#define DDR_MRS_BL_8 (3 << DDR_MRS_BL_BIT) + +/* DDRC Extended Mode Register1 Set */ +#define DDR_EMRS1_QOFF (1<<12) /* 0 Output buffer enabled + 1 Output buffer disabled */ +#define DDR_EMRS1_RDQS_EN (1<<11) /* 0 Disable + 1 Enable */ +#define DDR_EMRS1_DQS_DIS (1<<10) /* 0 Enable + 1 Disable */ +#define DDR_EMRS1_OCD_BIT 7 /* Additive Latency 0 -> 6 */ +#define DDR_EMRS1_OCD_MASK (0x7 << DDR_EMRS1_OCD_BIT) +#define DDR_EMRS1_OCD_EXIT (0 << DDR_EMRS1_OCD_BIT) +#define DDR_EMRS1_OCD_D0 (1 << DDR_EMRS1_OCD_BIT) +#define DDR_EMRS1_OCD_D1 (2 << DDR_EMRS1_OCD_BIT) +#define DDR_EMRS1_OCD_ADJ (4 << DDR_EMRS1_OCD_BIT) +#define DDR_EMRS1_OCD_DFLT (7 << DDR_EMRS1_OCD_BIT) +#define DDR_EMRS1_AL_BIT 3 /* Additive Latency 0 -> 6 */ +#define DDR_EMRS1_AL_MASK (7 << DDR_EMRS1_AL_BIT) +#define DDR_EMRS1_RTT_BIT 2 /* */ +#define DDR_EMRS1_RTT_MASK (0x11 << DDR_EMRS1_DIC_BIT) /* Bit 6, Bit 2 */ +#define DDR_EMRS1_DIC_BIT 1 /* Output Driver Impedence Control */ +#define DDR_EMRS1_DIC_MASK (1 << DDR_EMRS1_DIC_BIT) /* 100% */ +#define DDR_EMRS1_DIC_NORMAL (0 << DDR_EMRS1_DIC_BIT) /* 60% */ +#define DDR_EMRS1_DIC_HALF (1 << DDR_EMRS1_DIC_BIT) +#define DDR_EMRS1_DLL_BIT 0 /* DLL Enable */ +#define DDR_EMRS1_DLL_MASK (1 << DDR_EMRS1_DLL_BIT) +#define DDR_EMRS1_DLL_EN (0 << DDR_EMRS1_DLL_BIT) +#define DDR_EMRS1_DLL_DIS (1 << DDR_EMRS1_DLL_BIT) + +/* Mobile SDRAM Extended Mode Register */ +#define DDR_EMRS_DS_BIT 5 /* Driver strength */ +#define DDR_EMRS_DS_MASK (7 << DDR_EMRS_DS_BIT) +#define DDR_EMRS_DS_FULL (0 << DDR_EMRS_DS_BIT) /*Full*/ +#define DDR_EMRS_DS_HALF (1 << DDR_EMRS_DS_BIT) /*1/2 Strength*/ +#define DDR_EMRS_DS_QUTR (2 << DDR_EMRS_DS_BIT) /*1/4 Strength*/ +#define DDR_EMRS_DS_OCTANT (3 << DDR_EMRS_DS_BIT) /*1/8 Strength*/ +#define DDR_EMRS_DS_QUTR3 (4 << DDR_EMRS_DS_BIT) /*3/4 Strength*/ + +#define DDR_EMRS_PRSR_BIT 0 /* Partial Array Self Refresh */ +#define DDR_EMRS_PRSR_MASK (7 << DDR_EMRS_PRSR_BIT) +#define DDR_EMRS_PRSR_ALL (0 << DDR_EMRS_PRSR_BIT) /*All Banks*/ +#define DDR_EMRS_PRSR_HALF_TL (1 << DDR_EMRS_PRSR_BIT) /*Half of Total Bank*/ +#define DDR_EMRS_PRSR_QUTR_TL (2 << DDR_EMRS_PRSR_BIT) /*Quarter of Total Bank*/ +#define DDR_EMRS_PRSR_HALF_B0 (5 << DDR_EMRS_PRSR_BIT) /*Half of Bank0*/ +#define DDR_EMRS_PRSR_QUTR_B0 (6 << DDR_EMRS_PRSR_BIT) /*Quarter of Bank0*/ + +/* DDRC Timing Config Register 1 */ +#define DDRC_TIMING1_TRAS_BIT 28 /* ACTIVE to PRECHARGE command period (2 * tRAS + 1) */ +#define DDRC_TIMING1_TRAS_MASK (0xf << DDRC_TIMING1_TRAS_BIT) + +#define DDRC_TIMING1_TRTP_BIT 24 /* READ to PRECHARGE command period. */ +#define DDRC_TIMING1_TRTP_MASK (0x3 << DDRC_TIMING1_TRTP_BIT) + +#define DDRC_TIMING1_TRP_BIT 20 /* PRECHARGE command period. */ +#define DDRC_TIMING1_TRP_MASK (0x7 << DDRC_TIMING1_TRP_BIT) + +#define DDRC_TIMING1_TRCD_BIT 16 /* ACTIVE to READ or WRITE command period. */ +#define DDRC_TIMING1_TRCD_MASK (0x7 << DDRC_TIMING1_TRCD_BIT) + +#define DDRC_TIMING1_TRC_BIT 12 /* ACTIVE to ACTIVE command period. */ +#define DDRC_TIMING1_TRC_MASK (0xf << DDRC_TIMING1_TRC_BIT) + +#define DDRC_TIMING1_TRRD_BIT 8 /* ACTIVE bank A to ACTIVE bank B command period. */ +#define DDRC_TIMING1_TRRD_MASK (0x3 << DDRC_TIMING1_TRRD_BIT) +#define DDRC_TIMING1_TRRD_DISABLE (0 << DDRC_TIMING1_TRRD_BIT) +#define DDRC_TIMING1_TRRD_2 (1 << DDRC_TIMING1_TRRD_BIT) +#define DDRC_TIMING1_TRRD_3 (2 << DDRC_TIMING1_TRRD_BIT) +#define DDRC_TIMING1_TRRD_4 (3 << DDRC_TIMING1_TRRD_BIT) + +#define DDRC_TIMING1_TWR_BIT 4 /* WRITE Recovery Time defined by register MR of DDR2 memory */ +#define DDRC_TIMING1_TWR_MASK (0x7 << DDRC_TIMING1_TWR_BIT) +#define DDRC_TIMING1_TWR_1 (0 << DDRC_TIMING1_TWR_BIT) +#define DDRC_TIMING1_TWR_2 (1 << DDRC_TIMING1_TWR_BIT) +#define DDRC_TIMING1_TWR_3 (2 << DDRC_TIMING1_TWR_BIT) +#define DDRC_TIMING1_TWR_4 (3 << DDRC_TIMING1_TWR_BIT) +#define DDRC_TIMING1_TWR_5 (4 << DDRC_TIMING1_TWR_BIT) +#define DDRC_TIMING1_TWR_6 (5 << DDRC_TIMING1_TWR_BIT) + +#define DDRC_TIMING1_TWTR_BIT 0 /* WRITE to READ command delay. */ +#define DDRC_TIMING1_TWTR_MASK (0x3 << DDRC_TIMING1_TWTR_BIT) +#define DDRC_TIMING1_TWTR_1 (0 << DDRC_TIMING1_TWTR_BIT) +#define DDRC_TIMING1_TWTR_2 (1 << DDRC_TIMING1_TWTR_BIT) +#define DDRC_TIMING1_TWTR_3 (2 << DDRC_TIMING1_TWTR_BIT) +#define DDRC_TIMING1_TWTR_4 (3 << DDRC_TIMING1_TWTR_BIT) + +/* DDRC Timing Config Register 2 */ +#define DDRC_TIMING2_TRFC_BIT 24 /* AUTO-REFRESH command period. */ +#define DDRC_TIMING2_TRFC_MASK (0xf << DDRC_TIMING2_TRFC_BIT) +#define DDRC_TIMING2_RWCOV_BIT 19 /* Equal to Tsel of MDELAY. */ +#define DDRC_TIMING2_RWCOV_MASK (0x3 << DDRC_TIMING2_RWCOV_BIT) +#define DDRC_TIMING2_TCKE_BIT 16 +#define DDRC_TIMING2_TCKE_MASK (0x7 << DDRC_TIMING2_TCKE_BIT) +#define DDRC_TIMING2_TMINSR_BIT 8 /* Minimum Self-Refresh / Deep-Power-Down time */ +#define DDRC_TIMING2_TMINSR_MASK (0xf << DDRC_TIMING2_TMINSR_BIT) +#define DDRC_TIMING2_TXP_BIT 4 /* EXIT-POWER-DOWN to next valid command period. */ +#define DDRC_TIMING2_TXP_MASK (0x7 << DDRC_TIMING2_TXP_BIT) +#define DDRC_TIMING2_TMRD_BIT 0 /* Load-Mode-Register to next valid command period. */ +#define DDRC_TIMING2_TMRD_MASK (0x3 << DDRC_TIMING2_TMRD_BIT) + +/* DDRC Auto-Refresh Counter */ +#define DDRC_REFCNT_CON_BIT 16 /* Constant value used to compare with CNT value. */ +#define DDRC_REFCNT_CON_MASK (0xff << DDRC_REFCNT_CON_BIT) +#define DDRC_REFCNT_CNT_BIT 8 /* 8-bit counter */ +#define DDRC_REFCNT_CNT_MASK (0xff << DDRC_REFCNT_CNT_BIT) +#define DDRC_REFCNT_CLKDIV_BIT 1 /* Clock Divider for auto-refresh counter. */ +#define DDRC_REFCNT_CLKDIV_MASK (0x7 << DDRC_REFCNT_CLKDIV_BIT) +#define DDRC_REFCNT_REF_EN (1 << 0) /* Enable Refresh Counter */ + +/* DDRC DQS Delay Control Register */ +#define DDRC_DQS_ERROR (1 << 29) /* ahb_clk Delay Detect ERROR, read-only. */ +#define DDRC_DQS_READY (1 << 28) /* ahb_clk Delay Detect READY, read-only. */ +#define DDRC_DQS_SRDET (1 << 25) +#define DDRC_DQS_DET (1 << 24) /* Start delay detecting. */ +#define DDRC_DQS_AUTO (1 << 23) /* Hardware auto-detect & set delay line */ +#define DDRC_DQS_CLKD_BIT 16 /* CLKD is reference value for setting WDQS and RDQS.*/ +#define DDRC_DQS_CLKD_MASK (0x3f << DDRC_DQS_CLKD_BIT) +#define DDRC_DQS_WDQS_BIT 8 /* Set delay element number to write DQS delay-line. */ +#define DDRC_DQS_WDQS_MASK (0x3f << DDRC_DQS_WDQS_BIT) +#define DDRC_DQS_RDQS_BIT 0 /* Set delay element number to read DQS delay-line. */ +#define DDRC_DQS_RDQS_MASK (0x3f << DDRC_DQS_RDQS_BIT) + +/* DDRC DQS Delay Adjust Register */ +#define DDRC_DQS_ADJDQSCON_BIT 16 +#define DDRC_DQS_ADJDQSCON_MASK (0xffff << DDRC_DQS_ADJDQSCON_BIT) +#define DDRC_DQS_ADJWSIGN (1 << 13) +#define DDRC_DQS_ADJWDQS_BIT 8 /* The adjust value for WRITE DQS delay */ +#define DDRC_DQS_ADJWDQS_MASK (0x1f << DDRC_DQS_ADJWDQS_BIT) +#define DDRC_DQS_ADJRSIGN (1 << 5) +#define DDRC_DQS_ADJRDQS_BIT 0 /* The adjust value for READ DQS delay */ +#define DDRC_DQS_ADJRDQS_MASK (0x1f << DDRC_DQS_ADJRDQS_BIT) + +/* DDRC Memory Map Config Register */ +#define DDRC_MMAP_BASE_BIT 8 /* base address */ +#define DDRC_MMAP_BASE_MASK (0xff << DDRC_MMAP_BASE_BIT) +#define DDRC_MMAP_MASK_BIT 0 /* address mask */ +#define DDRC_MMAP_MASK_MASK (0xff << DDRC_MMAP_MASK_BIT) + +#define DDRC_MMAP0_BASE (0x20 << DDRC_MMAP_BASE_BIT) +#define DDRC_MMAP1_BASE_64M (0x24 << DDRC_MMAP_BASE_BIT) /*when bank0 is 128M*/ +#define DDRC_MMAP1_BASE_128M (0x28 << DDRC_MMAP_BASE_BIT) /*when bank0 is 128M*/ +#define DDRC_MMAP1_BASE_256M (0x30 << DDRC_MMAP_BASE_BIT) /*when bank0 is 128M*/ + +#define DDRC_MMAP_MASK_64_64 (0xfc << DDRC_MMAP_MASK_BIT) /*mask for two 128M SDRAM*/ +#define DDRC_MMAP_MASK_128_128 (0xf8 << DDRC_MMAP_MASK_BIT) /*mask for two 128M SDRAM*/ +#define DDRC_MMAP_MASK_256_256 (0xf0 << DDRC_MMAP_MASK_BIT) /*mask for two 128M SDRAM*/ + +/* DDRC Timing Configure Register 1 */ +#define DDRC_DDELAYCTRL1_TSEL_BIT 18 +#define DDRC_DDELAYCTRL1_TSEL_MASK (0x3 << DDRC_DDELAYCTRL1_TSEL_BIT) +#define DDRC_DDELAYCTRL1_MSEL_BIT 16 +#define DDRC_DDELAYCTRL1_MSEL_MASK (0x3 << DDRC_DDELAYCTRL1_MSEL_BIT) +#define DDRC_DDELAYCTRL1_HL (1 << 15) +#define DDRC_DDELAYCTRL1_QUAR (1 << 14) +#define DDRC_DDELAYCTRL1_MAUTO (1 << 6) +#define DDRC_DDELAYCTRL1_MSIGN (1 << 5) +#define DDRC_DDELAYCTRL1_MASK_DELAY_SEL_ADJ_BIT 0 +#define DDRC_DDELAYCTRL1_MASK_DELAY_SEL_ADJ_MASK (0x1f << DDRC_DDELAYCTRL1_MASK_DELAY_SEL_ADJ_BIT) + +/* DDRC Timing Configure Register 2 */ +#define DDRC_DDELAYCTRL2_MASK_DELAY_SEL_BIT 0 +#define DDRC_DDELAYCTRL2_MASK_DELAY_SEL_MASK (0x3f << DDRC_DDELAYCTRL2_MASK_DELAY_SEL_BIT) + +/* DDRC Multi-media stride Register */ +#define DDRC_DSTRB_STRB0_BIT 16 +#define DDRC_DSTRB_STRB0_MASK (0x1fff << DDRC_DSTRB_STRB0_BIT) +#define DDRC_DSTRB_STRB1_BIT 0 +#define DDRC_DSTRB_STRB1_MASK (0x1fff << DDRC_DSTRB_STRB1_BIT) +/* DDRC IO pad control Register */ +#define DDRC_PMEMBS0_PDDQS3 (1 << 31) +#define DDRC_PMEMBS0_PDDQS2 (1 << 30) +#define DDRC_PMEMBS0_PDDQS1 (1 << 29) +#define DDRC_PMEMBS0_PDDQS0 (1 << 28) +#define DDRC_PMEMBS0_PDDQ3 (1 << 27) +#define DDRC_PMEMBS0_PDDQ2 (1 << 26) +#define DDRC_PMEMBS0_PDDQ1 (1 << 25) +#define DDRC_PMEMBS0_PDDQ0 (1 << 24) +#define DDRC_PMEMBS0_STDQS3 (1 << 23) +#define DDRC_PMEMBS0_STDQS2 (1 << 22) +#define DDRC_PMEMBS0_STDQS1 (1 << 21) +#define DDRC_PMEMBS0_STDQS0 (1 << 20) +#define DDRC_PMEMBS0_STDQ3 (1 << 19) +#define DDRC_PMEMBS0_STDQ2 (1 << 18) +#define DDRC_PMEMBS0_STDQ1 (1 << 17) +#define DDRC_PMEMBS0_STDQ0 (1 << 16) +#define DDRC_PMEMBS0_PEDQS3 (1 << 15) +#define DDRC_PMEMBS0_PEDQS2 (1 << 14) +#define DDRC_PMEMBS0_PEDQS1 (1 << 13) +#define DDRC_PMEMBS0_PEDQS0 (1 << 12) +#define DDRC_PMEMBS0_PEDQ3 (1 << 11) +#define DDRC_PMEMBS0_PEDQ2 (1 << 10) +#define DDRC_PMEMBS0_PEDQ1 (1 << 9) +#define DDRC_PMEMBS0_PEDQ0 (1 << 8) +#define DDRC_PMEMBS0_PSDQS3 (1 << 7) +#define DDRC_PMEMBS0_PSDQS2 (1 << 6) +#define DDRC_PMEMBS0_PSDQS1 (1 << 5) +#define DDRC_PMEMBS0_PSDQS0 (1 << 4) +#define DDRC_PMEMBS0_PSDQ3 (1 << 3) +#define DDRC_PMEMBS0_PSDQ2 (1 << 2) +#define DDRC_PMEMBS0_PSDQ1 (1 << 1) +#define DDRC_PMEMBS0_PSDQ0 (1 << 0) +/* DDRC IO pad control Register */ +#define DDRC_PMEMBS1_IENDQS3 (1 << 31) +#define DDRC_PMEMBS1_IENDQS2 (1 << 30) +#define DDRC_PMEMBS1_IENDQS1 (1 << 29) +#define DDRC_PMEMBS1_IENDQS0 (1 << 28) +#define DDRC_PMEMBS1_IENDQ3 (1 << 27) +#define DDRC_PMEMBS1_IENDQ2 (1 << 26) +#define DDRC_PMEMBS1_IENDQ1 (1 << 25) +#define DDRC_PMEMBS1_IENDQ0 (1 << 24) +#define DDRC_PMEMBS1_SSTL (1 << 16) + +#define DDRC_PMEMBS1_SSELDQS3_BIT 14 +#define DDRC_PMEMBS1_SSELDQS3_MASK (0x3 << DDRC_PMEMBS1_SSELDQS3_BIT) + +#define DDRC_PMEMBS1_SSELDQS2_BIT 12 +#define DDRC_PMEMBS1_SSELDQS2_MASK (0x3 << DDRC_PMEMBS1_SSELDQS2_BIT) + +#define DDRC_PMEMBS1_SSELDQS1_BIT 10 +#define DDRC_PMEMBS1_SSELDQS1_MASK (0x3 << DDRC_PMEMBS1_SSELDQS1_BIT) + +#define DDRC_PMEMBS1_SSELDQS0_BIT 8 +#define DDRC_PMEMBS1_SSELDQS0_MASK (0x3 << DDRC_PMEMBS1_SSELDQS0_BIT) + +#define DDRC_PMEMBS1_SSELDQ3_BIT 6 +#define DDRC_PMEMBS1_SSELDQ3_MASK (0x3 << DDRC_PMEMBS1_SSELDQ3_BIT) + +#define DDRC_PMEMBS1_SSELDQ2_BIT 4 +#define DDRC_PMEMBS1_SSELDQ2_MASK (0x3 << DDRC_PMEMBS1_SSELDQ2_BIT) + +#define DDRC_PMEMBS1_SSELDQ1_BIT 2 +#define DDRC_PMEMBS1_SSELDQ1_MASK (0x3 << DDRC_PMEMBS1_SSELDQ1_BIT) + +#define DDRC_PMEMBS1_SSELDQ0_BIT 0 +#define DDRC_PMEMBS1_SSELDQ0_MASK (0x3 << DDRC_PMEMBS1_SSELDQ0_BIT) + +/* DDRC IO pad control Register */ +#define DDRC_PMEMOSEL_CKSSEL_BIT 18 +#define DDRC_PMEMOSEL_CKSSEL_MASK (0x3 << DDRC_PMEMOSEL_CKSSEL_BIT) + +#define DDRC_PMEMOSEL_CKESSEL_BIT 16 +#define DDRC_PMEMOSEL_CKESSEL_MASK (0x3 << DDRC_PMEMOSEL_CKESSEL_BIT) + +#define DDRC_PMEMOSEL_ADDRSSEL_BIT 14 +#define DDRC_PMEMOSEL_ADDRSSEL_MASK (0x3 << DDRC_PMEMOSEL_ADDRSSEL_BIT) + +#define DDRC_PMEMOSEL_DMSSEL3_BIT 12 +#define DDRC_PMEMOSEL_DMSSEL3_MASK (0x3 << DDRC_PMEMOSEL_DMSSEL3_BIT) + +#define DDRC_PMEMOSEL_DMSSEL2_BIT 10 +#define DDRC_PMEMOSEL_DMSSEL2_MASK (0x3 << DDRC_PMEMOSEL_DMSSEL2_BIT) + +#define DDRC_PMEMOSEL_DMSSEL1_BIT 8 +#define DDRC_PMEMOSEL_DMSSEL1_MASK (0x3 << DDRC_PMEMOSEL_DMSSEL1_BIT) + +#define DDRC_PMEMOSEL_DMSSEL0_BIT 6 +#define DDRC_PMEMOSEL_DMSSEL0_MASK (0x3 << DDRC_PMEMOSEL_DMSSEL0_BIT) + +#define DDRC_PMEMOSEL_CMDSSEL_BIT 4 +#define DDRC_PMEMOSEL_CMDSSEL_MASK (0x3 << DDRC_PMEMOSEL_CMDSSEL_BIT) + +#define DDRC_PMEMOSEL_CSSSEL1_BIT 2 +#define DDRC_PMEMOSEL_CSSSEL1_MASK (0x3 << DDRC_PMEMOSEL_CSSSEL1_BIT) + +#define DDRC_PMEMOSEL_CSSSEL0_BIT 0 +#define DDRC_PMEMOSEL_CSSSEL0_MASK (0x3 << DDRC_PMEMOSEL_CSSSEL0_BIT) + +/* DDRC IO pad control Register */ +#define DDRC_PMEMOEN_CKOEN (1 << 14) +#define DDRC_PMEMOEN_BAOEN2 (1 << 13) +#define DDRC_PMEMOEN_BAOEN1 (1 << 12) +#define DDRC_PMEMOEN_BAOEN0 (1 << 11) +#define DDRC_PMEMOEN_AOEN13 (1 << 10) +#define DDRC_PMEMOEN_AOEN12 (1 << 9) +#define DDRC_PMEMOEN_AOEN11_0 (1 << 8) +#define DDRC_PMEMOEN_DMOEN3 (1 << 7) +#define DDRC_PMEMOEN_DMOEN2 (1 << 6) +#define DDRC_PMEMOEN_DMOEN1 (1 << 5) +#define DDRC_PMEMOEN_DMOEN0 (1 << 4) +#define DDRC_PMEMOEN_CMDOEN (1 << 3) +#define DDRC_PMEMOEN_CSOEN1 (1 << 2) +#define DDRC_PMEMOEN_CSOEN0 (1 << 1) +#define DDRC_PMEMOEN_CKEOEN (1 << 0) + +#ifndef __MIPS_ASSEMBLER + +#define DDR_GET_VALUE(x, y) \ +({ \ + unsigned long value, tmp; \ + tmp = x * 1000; \ + value = (tmp % y == 0) ? (tmp / y) : (tmp / y + 1); \ + value; \ +}) + +#endif /* __MIPS_ASSEMBLER */ + +#define EMC_BASE 0xB3410000 + +/************************************************************************* + * EMC (External Memory Controller) + *************************************************************************/ +#define EMC_BCR (EMC_BASE + 0x00) /* Bus Control Register */ +#define EMC_PMEMBS1 (EMC_BASE + 0x6004) +#define EMC_PMEMBS0 (EMC_BASE + 0x6008) +#define EMC_SMCR0 (EMC_BASE + 0x10) /* Static Memory Control Register 0 ??? */ +#define EMC_SMCR1 (EMC_BASE + 0x14) /* Static Memory Control Register 1 */ +#define EMC_SMCR2 (EMC_BASE + 0x18) /* Static Memory Control Register 2 */ +#define EMC_SMCR3 (EMC_BASE + 0x1c) /* Static Memory Control Register 3 */ +#define EMC_SMCR4 (EMC_BASE + 0x20) /* Static Memory Control Register 4 */ +#define EMC_SMCR5 (EMC_BASE + 0x24) /* Static Memory Control Register 5 */ +#define EMC_SMCR6 (EMC_BASE + 0x28) /* Static Memory Control Register 6 */ +#define EMC_SACR0 (EMC_BASE + 0x30) /* Static Memory Bank 0 Addr Config Reg */ +#define EMC_SACR1 (EMC_BASE + 0x34) /* Static Memory Bank 1 Addr Config Reg */ +#define EMC_SACR2 (EMC_BASE + 0x38) /* Static Memory Bank 2 Addr Config Reg */ +#define EMC_SACR3 (EMC_BASE + 0x3c) /* Static Memory Bank 3 Addr Config Reg */ +#define EMC_SACR4 (EMC_BASE + 0x40) /* Static Memory Bank 4 Addr Config Reg */ +#define EMC_SACR5 (EMC_BASE + 0x44) /* Static Memory Bank 5 Addr Config Reg */ +#define EMC_SACR6 (EMC_BASE + 0x48) /* Static Memory Bank 6 Addr Config Reg */ +#define EMC_NFCSR (EMC_BASE + 0x50) /* NAND Flash Control/Status Register */ +#define EMC_DMCR (EMC_BASE + 0x80) /* DRAM Control Register */ +#define EMC_RTCSR (EMC_BASE + 0x84) /* Refresh Time Control/Status Register */ +#define EMC_RTCNT (EMC_BASE + 0x88) /* Refresh Timer Counter */ +#define EMC_RTCOR (EMC_BASE + 0x8c) /* Refresh Time Constant Register */ +#define EMC_DMAR0 (EMC_BASE + 0x90) /* SDRAM Bank 0 Addr Config Register */ +#define EMC_DMAR1 (EMC_BASE + 0x94) /* SDRAM Bank 1 Addr Config Register */ +#define EMC_SDMR0 (EMC_BASE + 0xa000) /* Mode Register of SDRAM bank 0 */ + +#define REG_EMC_BCR REG32(EMC_BCR) +#define REG_EMC_PMEMBS1 REG32(EMC_PMEMBS1) +#define REG_EMC_PMEMBS0 REG32(EMC_PMEMBS0) +#define REG_EMC_SMCR0 REG32(EMC_SMCR0) // ??? +#define REG_EMC_SMCR1 REG32(EMC_SMCR1) +#define REG_EMC_SMCR2 REG32(EMC_SMCR2) +#define REG_EMC_SMCR3 REG32(EMC_SMCR3) +#define REG_EMC_SMCR4 REG32(EMC_SMCR4) +#define REG_EMC_SMCR5 REG32(EMC_SMCR5) +#define REG_EMC_SMCR6 REG32(EMC_SMCR6) +#define REG_EMC_SACR0 REG32(EMC_SACR0) +#define REG_EMC_SACR1 REG32(EMC_SACR1) +#define REG_EMC_SACR2 REG32(EMC_SACR2) +#define REG_EMC_SACR3 REG32(EMC_SACR3) +#define REG_EMC_SACR4 REG32(EMC_SACR4) + +#define REG_EMC_NFCSR REG32(EMC_NFCSR) + +#define REG_EMC_DMCR REG32(EMC_DMCR) +#define REG_EMC_RTCSR REG16(EMC_RTCSR) +#define REG_EMC_RTCNT REG16(EMC_RTCNT) +#define REG_EMC_RTCOR REG16(EMC_RTCOR) +#define REG_EMC_DMAR0 REG32(EMC_DMAR0) +#define REG_EMC_DMAR1 REG32(EMC_DMAR1) + +/* Bus Control Register */ +#define EMC_BCR_BT_SEL_BIT 30 +#define EMC_BCR_BT_SEL_MASK (0x3 << EMC_BCR_BT_SEL_BIT) +#define EMC_BCR_PK_SEL (1 << 24) +#define EMC_BCR_BSR_MASK (1 << 2) /* Nand and SDRAM Bus Share Select: 0, share; 1, unshare */ + #define EMC_BCR_BSR_SHARE (0 << 2) + #define EMC_BCR_BSR_UNSHARE (1 << 2) +#define EMC_BCR_BRE (1 << 1) +#define EMC_BCR_ENDIAN (1 << 0) + +/* Static Memory Control Register */ +#define EMC_SMCR_STRV_BIT 24 +#define EMC_SMCR_STRV_MASK (0x1f << EMC_SMCR_STRV_BIT) +#define EMC_SMCR_TAW_BIT 20 +#define EMC_SMCR_TAW_MASK (0x0f << EMC_SMCR_TAW_BIT) +#define EMC_SMCR_TBP_BIT 16 +#define EMC_SMCR_TBP_MASK (0x0f << EMC_SMCR_TBP_BIT) +#define EMC_SMCR_TAH_BIT 12 +#define EMC_SMCR_TAH_MASK (0x07 << EMC_SMCR_TAH_BIT) +#define EMC_SMCR_TAS_BIT 8 +#define EMC_SMCR_TAS_MASK (0x07 << EMC_SMCR_TAS_BIT) +#define EMC_SMCR_BW_BIT 6 +#define EMC_SMCR_BW_MASK (0x03 << EMC_SMCR_BW_BIT) + #define EMC_SMCR_BW_8BIT (0 << EMC_SMCR_BW_BIT) + #define EMC_SMCR_BW_16BIT (1 << EMC_SMCR_BW_BIT) + #define EMC_SMCR_BW_32BIT (2 << EMC_SMCR_BW_BIT) +#define EMC_SMCR_BCM (1 << 3) +#define EMC_SMCR_BL_BIT 1 +#define EMC_SMCR_BL_MASK (0x03 << EMC_SMCR_BL_BIT) + #define EMC_SMCR_BL_4 (0 << EMC_SMCR_BL_BIT) + #define EMC_SMCR_BL_8 (1 << EMC_SMCR_BL_BIT) + #define EMC_SMCR_BL_16 (2 << EMC_SMCR_BL_BIT) + #define EMC_SMCR_BL_32 (3 << EMC_SMCR_BL_BIT) +#define EMC_SMCR_SMT (1 << 0) + +/* Static Memory Bank Addr Config Reg */ +#define EMC_SACR_BASE_BIT 8 +#define EMC_SACR_BASE_MASK (0xff << EMC_SACR_BASE_BIT) +#define EMC_SACR_MASK_BIT 0 +#define EMC_SACR_MASK_MASK (0xff << EMC_SACR_MASK_BIT) + +/* NAND Flash Control/Status Register */ +#define EMC_NFCSR_NFCE4 (1 << 7) /* NAND Flash Enable */ +#define EMC_NFCSR_NFE4 (1 << 6) /* NAND Flash FCE# Assertion Enable */ +#define EMC_NFCSR_NFCE3 (1 << 5) +#define EMC_NFCSR_NFE3 (1 << 4) +#define EMC_NFCSR_NFCE2 (1 << 3) +#define EMC_NFCSR_NFE2 (1 << 2) +#define EMC_NFCSR_NFCE1 (1 << 1) +#define EMC_NFCSR_NFE1 (1 << 0) +#define EMC_NFCSR_NFE(n) (1 << (((n)-1)*2)) +#define EMC_NFCSR_NFCE(n) (1 << (((n)*2)-1)) + +/* DRAM Control Register */ +#define EMC_DMCR_BW_BIT 31 +#define EMC_DMCR_BW (1 << EMC_DMCR_BW_BIT) +#define EMC_DMCR_CA_BIT 26 +#define EMC_DMCR_CA_MASK (0x07 << EMC_DMCR_CA_BIT) + #define EMC_DMCR_CA_8 (0 << EMC_DMCR_CA_BIT) + #define EMC_DMCR_CA_9 (1 << EMC_DMCR_CA_BIT) + #define EMC_DMCR_CA_10 (2 << EMC_DMCR_CA_BIT) + #define EMC_DMCR_CA_11 (3 << EMC_DMCR_CA_BIT) + #define EMC_DMCR_CA_12 (4 << EMC_DMCR_CA_BIT) +#define EMC_DMCR_RMODE (1 << 25) +#define EMC_DMCR_RFSH (1 << 24) +#define EMC_DMCR_MRSET (1 << 23) +#define EMC_DMCR_RA_BIT 20 +#define EMC_DMCR_RA_MASK (0x03 << EMC_DMCR_RA_BIT) + #define EMC_DMCR_RA_11 (0 << EMC_DMCR_RA_BIT) + #define EMC_DMCR_RA_12 (1 << EMC_DMCR_RA_BIT) + #define EMC_DMCR_RA_13 (2 << EMC_DMCR_RA_BIT) +#define EMC_DMCR_BA_BIT 19 +#define EMC_DMCR_BA (1 << EMC_DMCR_BA_BIT) +#define EMC_DMCR_PDM (1 << 18) +#define EMC_DMCR_EPIN (1 << 17) +#define EMC_DMCR_MBSEL (1 << 16) +#define EMC_DMCR_TRAS_BIT 13 +#define EMC_DMCR_TRAS_MASK (0x07 << EMC_DMCR_TRAS_BIT) +#define EMC_DMCR_RCD_BIT 11 +#define EMC_DMCR_RCD_MASK (0x03 << EMC_DMCR_RCD_BIT) +#define EMC_DMCR_TPC_BIT 8 +#define EMC_DMCR_TPC_MASK (0x07 << EMC_DMCR_TPC_BIT) +#define EMC_DMCR_TRWL_BIT 5 +#define EMC_DMCR_TRWL_MASK (0x03 << EMC_DMCR_TRWL_BIT) +#define EMC_DMCR_TRC_BIT 2 +#define EMC_DMCR_TRC_MASK (0x07 << EMC_DMCR_TRC_BIT) +#define EMC_DMCR_TCL_BIT 0 +#define EMC_DMCR_TCL_MASK (0x03 << EMC_DMCR_TCL_BIT) + +/* Refresh Time Control/Status Register */ +#define EMC_RTCSR_SFR (1 << 8) /* self refresh flag */ +#define EMC_RTCSR_CMF (1 << 7) +#define EMC_RTCSR_CKS_BIT 0 +#define EMC_RTCSR_CKS_MASK (0x07 << EMC_RTCSR_CKS_BIT) + #define EMC_RTCSR_CKS_DISABLE (0 << EMC_RTCSR_CKS_BIT) + #define EMC_RTCSR_CKS_4 (1 << EMC_RTCSR_CKS_BIT) + #define EMC_RTCSR_CKS_16 (2 << EMC_RTCSR_CKS_BIT) + #define EMC_RTCSR_CKS_64 (3 << EMC_RTCSR_CKS_BIT) + #define EMC_RTCSR_CKS_256 (4 << EMC_RTCSR_CKS_BIT) + #define EMC_RTCSR_CKS_1024 (5 << EMC_RTCSR_CKS_BIT) + #define EMC_RTCSR_CKS_2048 (6 << EMC_RTCSR_CKS_BIT) + #define EMC_RTCSR_CKS_4096 (7 << EMC_RTCSR_CKS_BIT) + +/* SDRAM Bank Address Configuration Register */ +#define EMC_DMAR_BASE_BIT 8 +#define EMC_DMAR_BASE_MASK (0xff << EMC_DMAR_BASE_BIT) +#define EMC_DMAR_MASK_BIT 0 +#define EMC_DMAR_MASK_MASK (0xff << EMC_DMAR_MASK_BIT) + +/* Mode Register of SDRAM bank 0 */ +#define EMC_SDMR_BM (1 << 9) /* Write Burst Mode */ +#define EMC_SDMR_OM_BIT 7 /* Operating Mode */ +#define EMC_SDMR_OM_MASK (3 << EMC_SDMR_OM_BIT) + #define EMC_SDMR_OM_NORMAL (0 << EMC_SDMR_OM_BIT) +#define EMC_SDMR_CAS_BIT 4 /* CAS Latency */ +#define EMC_SDMR_CAS_MASK (7 << EMC_SDMR_CAS_BIT) + #define EMC_SDMR_CAS_1 (1 << EMC_SDMR_CAS_BIT) + #define EMC_SDMR_CAS_2 (2 << EMC_SDMR_CAS_BIT) + #define EMC_SDMR_CAS_3 (3 << EMC_SDMR_CAS_BIT) +#define EMC_SDMR_BT_BIT 3 /* Burst Type */ +#define EMC_SDMR_BT_MASK (1 << EMC_SDMR_BT_BIT) + #define EMC_SDMR_BT_SEQ (0 << EMC_SDMR_BT_BIT) /* Sequential */ + #define EMC_SDMR_BT_INT (1 << EMC_SDMR_BT_BIT) /* Interleave */ +#define EMC_SDMR_BL_BIT 0 /* Burst Length */ +#define EMC_SDMR_BL_MASK (7 << EMC_SDMR_BL_BIT) + #define EMC_SDMR_BL_1 (0 << EMC_SDMR_BL_BIT) + #define EMC_SDMR_BL_2 (1 << EMC_SDMR_BL_BIT) + #define EMC_SDMR_BL_4 (2 << EMC_SDMR_BL_BIT) + #define EMC_SDMR_BL_8 (3 << EMC_SDMR_BL_BIT) + +#define EMC_SDMR_CAS2_16BIT \ + (EMC_SDMR_CAS_2 | EMC_SDMR_BT_SEQ | EMC_SDMR_BL_2) +#define EMC_SDMR_CAS2_32BIT \ + (EMC_SDMR_CAS_2 | EMC_SDMR_BT_SEQ | EMC_SDMR_BL_4) +#define EMC_SDMR_CAS3_16BIT \ + (EMC_SDMR_CAS_3 | EMC_SDMR_BT_SEQ | EMC_SDMR_BL_2) +#define EMC_SDMR_CAS3_32BIT \ + (EMC_SDMR_CAS_3 | EMC_SDMR_BT_SEQ | EMC_SDMR_BL_4) + +#define I2C0_BASE 0xB0050000 +#define I2C1_BASE 0xB0051000 + +/************************************************************************* + * I2C + *************************************************************************/ +#define I2C_CTRL(n) (I2C0_BASE + (n)*0x1000 + 0x00) +#define I2C_TAR(n) (I2C0_BASE + (n)*0x1000 + 0x04) +#define I2C_SAR(n) (I2C0_BASE + (n)*0x1000 + 0x08) +#define I2C_DC(n) (I2C0_BASE + (n)*0x1000 + 0x10) +#define I2C_SHCNT(n) (I2C0_BASE + (n)*0x1000 + 0x14) +#define I2C_SLCNT(n) (I2C0_BASE + (n)*0x1000 + 0x18) +#define I2C_FHCNT(n) (I2C0_BASE + (n)*0x1000 + 0x1C) +#define I2C_FLCNT(n) (I2C0_BASE + (n)*0x1000 + 0x20) +#define I2C_INTST(n) (I2C0_BASE + (n)*0x1000 + 0x2C) +#define I2C_INTM(n) (I2C0_BASE + (n)*0x1000 + 0x30) +#define I2C_RXTL(n) (I2C0_BASE + (n)*0x1000 + 0x38) +#define I2C_TXTL(n) (I2C0_BASE + (n)*0x1000 + 0x3c) +#define I2C_CINTR(n) (I2C0_BASE + (n)*0x1000 + 0x40) +#define I2C_CRXUF(n) (I2C0_BASE + (n)*0x1000 + 0x44) +#define I2C_CRXOF(n) (I2C0_BASE + (n)*0x1000 + 0x48) +#define I2C_CTXOF(n) (I2C0_BASE + (n)*0x1000 + 0x4C) +#define I2C_CRXREQ(n) (I2C0_BASE + (n)*0x1000 + 0x50) +#define I2C_CTXABRT(n) (I2C0_BASE + (n)*0x1000 + 0x54) +#define I2C_CRXDONE(n) (I2C0_BASE + (n)*0x1000 + 0x58) +#define I2C_CACT(n) (I2C0_BASE + (n)*0x1000 + 0x5C) +#define I2C_CSTP(n) (I2C0_BASE + (n)*0x1000 + 0x60) +#define I2C_CSTT(n) (I2C0_BASE + (n)*0x1000 + 0x64) +#define I2C_CGC(n) (I2C0_BASE + (n)*0x1000 + 0x68) +#define I2C_ENB(n) (I2C0_BASE + (n)*0x1000 + 0x6C) +#define I2C_STA(n) (I2C0_BASE + (n)*0x1000 + 0x70) +#define I2C_TXABRT(n) (I2C0_BASE + (n)*0x1000 + 0x80) +#define I2C_DMACR(n) (I2C0_BASE + (n)*0x1000 + 0x88) +#define I2C_DMATDLR(n) (I2C0_BASE + (n)*0x1000 + 0x8c) +#define I2C_DMARDLR(n) (I2C0_BASE + (n)*0x1000 + 0x90) +#define I2C_SDASU(n) (I2C0_BASE + (n)*0x1000 + 0x94) +#define I2C_ACKGC(n) (I2C0_BASE + (n)*0x1000 + 0x98) +#define I2C_ENSTA(n) (I2C0_BASE + (n)*0x1000 + 0x9C) + +#define REG_I2C_CTRL(n) REG8(I2C_CTRL(n)) /* I2C Control Register (I2C_CTRL) */ +#define REG_I2C_TAR(n) REG16(I2C_TAR(n)) /* I2C target address (I2C_TAR) */ +#define REG_I2C_SAR(n) REG16(I2C_SAR(n)) +#define REG_I2C_DC(n) REG16(I2C_DC(n)) +#define REG_I2C_SHCNT(n) REG16(I2C_SHCNT(n)) +#define REG_I2C_SLCNT(n) REG16(I2C_SLCNT(n)) +#define REG_I2C_FHCNT(n) REG16(I2C_FHCNT(n)) +#define REG_I2C_FLCNT(n) REG16(I2C_FLCNT(n)) +#define REG_I2C_INTST(n) REG16(I2C_INTST(n)) /* i2c interrupt status (I2C_INTST) */ +#define REG_I2C_INTM(n) REG16(I2C_INTM(n)) /* i2c interrupt mask status (I2C_INTM) */ +#define REG_I2C_RXTL(n) REG8(I2C_RXTL(n)) +#define REG_I2C_TXTL(n) REG8(I2C_TXTL(n)) +#define REG_I2C_CINTR(n) REG8(I2C_CINTR(n)) +#define REG_I2C_CRXUF(n) REG8(I2C_CRXUF(n)) +#define REG_I2C_CRXOF(n) REG8(I2C_CRXOF(n)) +#define REG_I2C_CTXOF(n) REG8(I2C_CTXOF(n)) +#define REG_I2C_CRXREQ(n) REG8(I2C_CRXREQ(n)) +#define REG_I2C_CTXABRT(n) REG8(I2C_CTXABRT(n)) +#define REG_I2C_CRXDONE(n) REG8(I2C_CRXDONE(n)) +#define REG_I2C_CACT(n) REG8(I2C_CACT(n)) +#define REG_I2C_CSTP(n) REG8(I2C_CSTP(n)) +#define REG_I2C_CSTT(n) REG16(I2C_CSTT(n)) +#define REG_I2C_CGC(n) REG8(I2C_CGC(n)) +#define REG_I2C_ENB(n) REG8(I2C_ENB(n)) +#define REG_I2C_STA(n) REG8(I2C_STA(n)) +#define REG_I2C_TXABRT(n) REG16(I2C_TXABRT(n)) +#define REG_I2C_DMACR(n) REG8(I2C_DMACR(n)) +#define REG_I2C_DMATDLR(n) REG8(I2C_DMATDLR(n)) +#define REG_I2C_DMARDLR(n) REG8(I2C_DMARDLR(n)) +#define REG_I2C_SDASU(n) REG8(I2C_SDASU(n)) +#define REG_I2C_ACKGC(n) REG8(I2C_ACKGC(n)) +#define REG_I2C_ENSTA(n) REG8(I2C_ENSTA(n)) + +/* I2C Control Register (I2C_CTRL) */ + +#define I2C_CTRL_STPHLD (1 << 7) /* Stop Hold Enable bit: when tx fifo empty, 0: send stop 1: never send stop*/ +#define I2C_CTRL_SLVDIS (1 << 6) /* after reset slave is disabled*/ +#define I2C_CTRL_REST (1 << 5) +#define I2C_CTRL_MATP (1 << 4) /* 1: 10bit address 0: 7bit addressing*/ +#define I2C_CTRL_SATP (1 << 3) /* 1: 10bit address 0: 7bit address*/ +#define I2C_CTRL_SPDF (2 << 1) /* fast mode 400kbps */ +#define I2C_CTRL_SPDS (1 << 1) /* standard mode 100kbps */ +#define I2C_CTRL_MD (1 << 0) /* master enabled*/ + +/* I2C target address (I2C_TAR) */ + +#define I2C_TAR_MATP (1 << 12) +#define I2C_TAR_SPECIAL (1 << 11) +#define I2C_TAR_GC_OR_START (1 << 10) +#define I2C_TAR_I2CTAR_BIT 0 +#define I2C_TAR_I2CTAR_MASK (0x3ff << I2C_TAR_I2CTAR_BIT) + +/* I2C slave address */ +#define I2C_SAR_I2CSAR_BIT 0 +#define I2C_SAR_I2CSAR_MASK (0x3ff << I2C_SAR_I2CSAR_BIT) + +/* I2C data buffer and command (I2C_DC) */ + +#define I2C_DC_CMD (1 << 8) /* 1 read 0 write*/ +#define I2C_DC_DAT_BIT 0 +#define I2C_DC_DAT_MASK (0xff << I2C_DC_DAT_BIT) /* 1 read 0 write*/ + +/* i2c interrupt status (I2C_INTST) */ + +#define I2C_INTST_IGC (1 << 11) /* */ +#define I2C_INTST_ISTT (1 << 10) +#define I2C_INTST_ISTP (1 << 9) +#define I2C_INTST_IACT (1 << 8) +#define I2C_INTST_RXDN (1 << 7) +#define I2C_INTST_TXABT (1 << 6) +#define I2C_INTST_RDREQ (1 << 5) +#define I2C_INTST_TXEMP (1 << 4) +#define I2C_INTST_TXOF (1 << 3) +#define I2C_INTST_RXFL (1 << 2) +#define I2C_INTST_RXOF (1 << 1) +#define I2C_INTST_RXUF (1 << 0) + +/* i2c interrupt mask status (I2C_INTM) */ + +#define I2C_INTM_MIGC (1 << 11) /* */ +#define I2C_INTM_MISTT (1 << 10) +#define I2C_INTM_MISTP (1 << 9) +#define I2C_INTM_MIACT (1 << 8) +#define I2C_INTM_MRXDN (1 << 7) +#define I2C_INTM_MTXABT (1 << 6) +#define I2C_INTM_MRDREQ (1 << 5) +#define I2C_INTM_MTXEMP (1 << 4) +#define I2C_INTM_MTXOF (1 << 3) +#define I2C_INTM_MRXFL (1 << 2) +#define I2C_INTM_MRXOF (1 << 1) +#define I2C_INTM_MRXUF (1 << 0) + +/* I2C Clear Combined and Individual Interrupts (I2C_CINTR) */ + +#define I2C_CINTR_CINT (1 << 0) + +/* I2C Clear TX_OVER Interrupt */ +/* I2C Clear RDREQ Interrupt */ +/* I2C Clear TX_ABRT Interrupt */ +/* I2C Clear RX_DONE Interrupt */ +/* I2C Clear ACTIVITY Interrupt */ +/* I2C Clear STOP Interrupts */ +/* I2C Clear START Interrupts */ +/* I2C Clear GEN_CALL Interrupts */ + +/* I2C Enable (I2C_ENB) */ + +#define I2C_ENB_I2CENB (1 << 0) /* Enable the i2c */ + +/* I2C Status Register (I2C_STA) */ + +#define I2C_STA_SLVACT (1 << 6) /* Slave FSM is not in IDLE state */ +#define I2C_STA_MSTACT (1 << 5) /* Master FSM is not in IDLE state */ +#define I2C_STA_RFF (1 << 4) /* RFIFO if full */ +#define I2C_STA_RFNE (1 << 3) /* RFIFO is not empty */ +#define I2C_STA_TFE (1 << 2) /* TFIFO is empty */ +#define I2C_STA_TFNF (1 << 1) /* TFIFO is not full */ +#define I2C_STA_ACT (1 << 0) /* I2C Activity Status */ + +/* I2C Transmit Abort Status Register (I2C_TXABRT) */ + +#define I2C_TXABRT_SLVRD_INTX (1 << 15) +#define I2C_TXABRT_SLV_ARBLOST (1 << 14) +#define I2C_TXABRT_SLVFLUSH_TXFIFO (1 << 13) +#define I2C_TXABRT_ARB_LOST (1 << 12) +#define I2C_TXABRT_ABRT_MASTER_DIS (1 << 11) +#define I2C_TXABRT_ABRT_10B_RD_NORSTRT (1 << 10) +#define I2C_TXABRT_SBYTE_NORSTRT (1 << 9) +#define I2C_TXABRT_ABRT_HS_NORSTRT (1 << 8) +#define I2C_TXABRT_SBYTE_ACKDET (1 << 7) +#define I2C_TXABRT_ABRT_HS_ACKD (1 << 6) +#define I2C_TXABRT_ABRT_GCALL_READ (1 << 5) +#define I2C_TXABRT_ABRT_GCALL_NOACK (1 << 4) +#define I2C_TXABRT_ABRT_XDATA_NOACK (1 << 3) +#define I2C_TXABRT_ABRT_10ADDR2_NOACK (1 << 2) +#define I2C_TXABRT_ABRT_10ADDR1_NOACK (1 << 1) +#define I2C_TXABRT_ABRT_7B_ADDR_NOACK (1 << 0) + +/* */ +#define I2C_DMACR_TDEN (1 << 1) +#define I2C_DMACR_RDEN (1 << 0) + +/* */ +#define I2C_DMATDLR_TDLR_BIT 0 +#define I2C_DMATDLR_TDLR_MASK (0x1f << I2C_DMATDLR_TDLR_BIT) + +/* */ +#define I2C_DMARDLR_RDLR_BIT 0 +#define I2C_DMARDLR_RDLR_MASK (0x1f << I2C_DMARDLR_RDLR_BIT) + +/* I2C Enable Status Register (I2C_ENSTA) */ + +#define I2C_ENSTA_SLVRDLST (1 << 2) +#define I2C_ENSTA_SLVDISB (1 << 1) +#define I2C_ENSTA_I2CEN (1 << 0) /* when read as 1, i2c is deemed to be in an enabled state + when read as 0, i2c is deemed completely inactive. The cpu can + safely read this bit anytime .When this bit is read as 0 ,the cpu can + safely read SLVRDLST and SLVDISB */ + +/* I2C standard mode high count register(I2CSHCNT) */ +#define I2CSHCNT_ADJUST(n) (((n) - 8) < 6 ? 6 : ((n) - 8)) + +/* I2C standard mode low count register(I2CSLCNT) */ +#define I2CSLCNT_ADJUST(n) (((n) - 1) < 8 ? 8 : ((n) - 1)) + +/* I2C fast mode high count register(I2CFHCNT) */ +#define I2CFHCNT_ADJUST(n) (((n) - 8) < 6 ? 6 : ((n) - 8)) + +/* I2C fast mode low count register(I2CFLCNT) */ +#define I2CFLCNT_ADJUST(n) (((n) - 1) < 8 ? 8 : ((n) - 1)) + +#ifndef __MIPS_ASSEMBLER + +/*************************************************************************** + * I2C + ***************************************************************************/ + +#define __i2c_enable(n) ( REG_I2C_ENB(n) = 1 ) +#define __i2c_disable(n) ( REG_I2C_ENB(n) = 0 ) + +#define __i2c_is_enable(n) ( REG_I2C_ENSTA(n) & I2C_ENB_I2CENB ) +#define __i2c_is_disable(n) ( !(REG_I2C_ENSTA(n) & I2C_ENB_I2CENB) ) + +#define __i2c_abrt(n) ( REG_I2C_TXABRT(n) != 0 ) +#define __i2c_abrt_intr(n) (REG_I2C_INTST(n) & I2C_INTST_TXABT) +#define __i2c_master_active(n) ( REG_I2C_STA(n) & I2C_STA_MSTACT ) +#define __i2c_abrt_7b_addr_nack(n) ( REG_I2C_TXABRT(n) & I2C_TXABRT_ABRT_7B_ADDR_NOACK ) +#define __i2c_txfifo_is_empty(n) ( REG_I2C_STA(n) & I2C_STA_TFE ) +#define __i2c_clear_interrupts(ret,n) ( ret = REG_I2C_CINTR(n) ) + +#define __i2c_dma_rd_enable(n) SETREG8(I2C_DMACR(n),1 << 0) +#define __i2c_dma_rd_disable(n) CLRREG8(I2C_DMACR(n),1 << 0) +#define __i2c_dma_td_enable(n) SETREG8(I2C_DMACR(n),1 << 1) +#define __i2c_dma_td_disable(n) CLRREG8(I2C_DMACR(n),1 << 1) + +#define __i2c_send_stop(n) CLRREG8(I2C_CTRL(n), I2C_CTRL_STPHLD) +#define __i2c_nsend_stop(n) SETREG8(I2C_CTRL(n), I2C_CTRL_STPHLD) + +#define __i2c_set_dma_td_level(n,data) OUTREG8(I2C_DMATDLR(n),data) +#define __i2c_set_dma_rd_level(n,data) OUTREG8(I2C_DMARDLR(n),data) + +/* +#define __i2c_set_clk(dev_clk, i2c_clk) \ + ( REG_I2C_GR = (dev_clk) / (16*(i2c_clk)) - 1 ) +*/ + +#define __i2c_read(n) ( REG_I2C_DC(n) & 0xff ) +#define __i2c_write(val,n) ( REG_I2C_DC(n) = (val) ) + +#endif /* __MIPS_ASSEMBLER */ + +#define IPU_BASE 0xB3080000 + +/************************************************************************* + * IPU (Image Processing Unit) + *************************************************************************/ +#define IPU_V_BASE 0xB3080000 +#define IPU_P_BASE 0x13080000 + +/* Register offset */ +#define REG_CTRL 0x0 /* IPU Control Register */ +#define REG_STATUS 0x4 /* IPU Status Register */ +#define REG_D_FMT 0x8 /* Data Format Register */ +#define REG_Y_ADDR 0xc /* Input Y or YUV422 Packaged Data Address Register */ +#define REG_U_ADDR 0x10 /* Input U Data Address Register */ +#define REG_V_ADDR 0x14 /* Input V Data Address Register */ +#define REG_IN_FM_GS 0x18 /* Input Geometric Size Register */ +#define REG_Y_STRIDE 0x1c /* Input Y Data Line Stride Register */ +#define REG_UV_STRIDE 0x20 /* Input UV Data Line Stride Register */ +#define REG_OUT_ADDR 0x24 /* Output Frame Start Address Register */ +#define REG_OUT_GS 0x28 /* Output Geometric Size Register */ +#define REG_OUT_STRIDE 0x2c /* Output Data Line Stride Register */ +#define REG_RSZ_COEF_INDEX 0x30 /* Resize Coefficients Table Index Register */ +#define REG_CSC_CO_COEF 0x34 /* CSC C0 Coefficient Register */ +#define REG_CSC_C1_COEF 0x38 /* CSC C1 Coefficient Register */ +#define REG_CSC_C2_COEF 0x3c /* CSC C2 Coefficient Register */ +#define REG_CSC_C3_COEF 0x40 /* CSC C3 Coefficient Register */ +#define REG_CSC_C4_COEF 0x44 /* CSC C4 Coefficient Register */ +#define HRSZ_LUT_BASE 0x48 /* Horizontal Resize Coefficients Look Up Table Register group */ +#define VRSZ_LUT_BASE 0x4c /* Virtical Resize Coefficients Look Up Table Register group */ +#define REG_CSC_OFSET_PARA 0x50 /* CSC Offset Parameter Register */ +#define REG_Y_PHY_T_ADDR 0x54 /* Input Y Physical Table Address Register */ +#define REG_U_PHY_T_ADDR 0x58 /* Input U Physical Table Address Register */ +#define REG_V_PHY_T_ADDR 0x5c /* Input V Physical Table Address Register */ +#define REG_OUT_PHY_T_ADDR 0x60 /* Output Physical Table Address Register */ + +/* REG_CTRL: IPU Control Register */ +#define IPU_CE_SFT 0x0 +#define IPU_CE_MSK 0x1 +#define IPU_RUN_SFT 0x1 +#define IPU_RUN_MSK 0x1 +#define HRSZ_EN_SFT 0x2 +#define HRSZ_EN_MSK 0x1 +#define VRSZ_EN_SFT 0x3 +#define VRSZ_EN_MSK 0x1 +#define CSC_EN_SFT 0x4 +#define CSC_EN_MSK 0x1 +#define FM_IRQ_EN_SFT 0x5 +#define FM_IRQ_EN_MSK 0x1 +#define IPU_RST_SFT 0x6 +#define IPU_RST_MSK 0x1 +#define H_SCALE_SFT 0x8 +#define H_SCALE_MSK 0x1 +#define V_SCALE_SFT 0x9 +#define V_SCALE_MSK 0x1 +#define PKG_SEL_SFT 0xA +#define PKG_SEL_MSK 0x1 +#define LCDC_SEL_SFT 0xB +#define LCDC_SEL_MSK 0x1 +#define SPAGE_MAP_SFT 0xC +#define SPAGE_MAP_MSK 0x1 +#define DPAGE_SEL_SFT 0xD +#define DPAGE_SEL_MSK 0x1 +#define DISP_SEL_SFT 0xE +#define DISP_SEL_MSK 0x1 +#define FIELD_CONF_EN_SFT 15 +#define FIELD_CONF_EN_MSK 1 +#define FIELD_SEL_SFT 16 +#define FIELD_SEL_MSK 1 +#define DFIX_SEL_SFT 17 +#define DFIX_SEL_MSK 1 + +/* REG_STATUS: IPU Status Register */ +#define OUT_END_SFT 0x0 +#define OUT_END_MSK 0x1 +#define FMT_ERR_SFT 0x1 +#define FMT_ERR_MSK 0x1 +#define SIZE_ERR_SFT 0x2 +#define SIZE_ERR_MSK 0x1 + +/* D_FMT: Data Format Register */ +#define IN_FMT_SFT 0x0 +#define IN_FMT_MSK 0x3 +#define IN_OFT_SFT 0x2 +#define IN_OFT_MSK 0x3 +#define YUV_PKG_OUT_SFT 0x10 +#define YUV_PKG_OUT_MSK 0x7 +#define OUT_FMT_SFT 0x13 +#define OUT_FMT_MSK 0x3 +#define RGB_OUT_OFT_SFT 0x15 +#define RGB_OUT_OFT_MSK 0x7 +#define RGB888_FMT_SFT 0x18 +#define RGB888_FMT_MSK 0x1 + +/* IN_FM_GS: Input Geometric Size Register */ +#define IN_FM_H_SFT 0x0 +#define IN_FM_H_MSK 0xFFF +#define IN_FM_W_SFT 0x10 +#define IN_FM_W_MSK 0xFFF + +/* Y_STRIDE: Input Y Data Line Stride Register */ +#define Y_S_SFT 0x0 +#define Y_S_MSK 0x3FFF + +/* UV_STRIDE: Input UV Data Line Stride Register */ +#define V_S_SFT 0x0 +#define V_S_MSK 0x1FFF +#define U_S_SFT 0x10 +#define U_S_MSK 0x1FFF + +/* OUT_GS: Output Geometric Size Register */ +#define OUT_FM_H_SFT 0x0 +#define OUT_FM_H_MSK 0x1FFF +#define OUT_FM_W_SFT 0x10 +#define OUT_FM_W_MSK 0x7FFF + +/* OUT_STRIDE: Output Data Line Stride Register */ +#define OUT_S_SFT 0x0 +#define OUT_S_MSK 0xFFFF + +/* RSZ_COEF_INDEX: Resize Coefficients Table Index Register */ +#define VE_IDX_SFT 0x0 +#define VE_IDX_MSK 0x1F +#define HE_IDX_SFT 0x10 +#define HE_IDX_MSK 0x1F + +/* CSC_CX_COEF: CSC CX Coefficient Register */ +#define CX_COEF_SFT 0x0 +#define CX_COEF_MSK 0xFFF + +/* HRSZ_LUT_BASE, VRSZ_LUT_BASE: Resize Coefficients Look Up Table Register group */ +#define LUT_LEN 20 + +#define OUT_N_SFT 0x0 +#define OUT_N_MSK 0x1 +#define IN_N_SFT 0x1 +#define IN_N_MSK 0x1 +#define W_COEF_SFT 0x2 +#define W_COEF_MSK 0x3FF + +/* CSC_OFSET_PARA: CSC Offset Parameter Register */ +#define CHROM_OF_SFT 0x10 +#define CHROM_OF_MSK 0xFF +#define LUMA_OF_SFT 0x00 +#define LUMA_OF_MSK 0xFF + +#ifndef __MIPS_ASSEMBLER + +#if 0 +/************************************************************************* + * IPU (Image Processing Unit) + *************************************************************************/ +#define u32 volatile unsigned long + +#define write_reg(reg, val) \ +do { \ + *(u32 *)(reg) = (val); \ +} while(0) + +#define read_reg(reg, off) (*(u32 *)((reg)+(off))) + +#define set_ipu_fmt(rgb_888_out_fmt, rgb_out_oft, out_fmt, yuv_pkg_out, in_oft, in_fmt ) \ +({ write_reg( (IPU_V_BASE + REG_D_FMT), ((in_fmt) & IN_FMT_MSK)<> LCD_VSYNC_VPS_BIT ) + +#define __lcd_vsync_get_vpe() \ + ( (REG_LCD_VSYNC & LCD_VSYNC_VPE_MASK) >> LCD_VSYNC_VPE_BIT ) +#define __lcd_vsync_set_vpe(n) \ +do { \ + REG_LCD_VSYNC &= ~LCD_VSYNC_VPE_MASK; \ + REG_LCD_VSYNC |= (n) << LCD_VSYNC_VPE_BIT; \ +} while (0) + +#define __lcd_hsync_get_hps() \ + ( (REG_LCD_HSYNC & LCD_HSYNC_HPS_MASK) >> LCD_HSYNC_HPS_BIT ) +#define __lcd_hsync_set_hps(n) \ +do { \ + REG_LCD_HSYNC &= ~LCD_HSYNC_HPS_MASK; \ + REG_LCD_HSYNC |= (n) << LCD_HSYNC_HPS_BIT; \ +} while (0) + +#define __lcd_hsync_get_hpe() \ + ( (REG_LCD_HSYNC & LCD_HSYNC_HPE_MASK) >> LCD_VSYNC_HPE_BIT ) +#define __lcd_hsync_set_hpe(n) \ +do { \ + REG_LCD_HSYNC &= ~LCD_HSYNC_HPE_MASK; \ + REG_LCD_HSYNC |= (n) << LCD_HSYNC_HPE_BIT; \ +} while (0) + +#define __lcd_vat_get_ht() \ + ( (REG_LCD_VAT & LCD_VAT_HT_MASK) >> LCD_VAT_HT_BIT ) +#define __lcd_vat_set_ht(n) \ +do { \ + REG_LCD_VAT &= ~LCD_VAT_HT_MASK; \ + REG_LCD_VAT |= (n) << LCD_VAT_HT_BIT; \ +} while (0) + +#define __lcd_vat_get_vt() \ + ( (REG_LCD_VAT & LCD_VAT_VT_MASK) >> LCD_VAT_VT_BIT ) +#define __lcd_vat_set_vt(n) \ +do { \ + REG_LCD_VAT &= ~LCD_VAT_VT_MASK; \ + REG_LCD_VAT |= (n) << LCD_VAT_VT_BIT; \ +} while (0) + +#define __lcd_dah_get_hds() \ + ( (REG_LCD_DAH & LCD_DAH_HDS_MASK) >> LCD_DAH_HDS_BIT ) +#define __lcd_dah_set_hds(n) \ +do { \ + REG_LCD_DAH &= ~LCD_DAH_HDS_MASK; \ + REG_LCD_DAH |= (n) << LCD_DAH_HDS_BIT; \ +} while (0) + +#define __lcd_dah_get_hde() \ + ( (REG_LCD_DAH & LCD_DAH_HDE_MASK) >> LCD_DAH_HDE_BIT ) +#define __lcd_dah_set_hde(n) \ +do { \ + REG_LCD_DAH &= ~LCD_DAH_HDE_MASK; \ + REG_LCD_DAH |= (n) << LCD_DAH_HDE_BIT; \ +} while (0) + +#define __lcd_dav_get_vds() \ + ( (REG_LCD_DAV & LCD_DAV_VDS_MASK) >> LCD_DAV_VDS_BIT ) +#define __lcd_dav_set_vds(n) \ +do { \ + REG_LCD_DAV &= ~LCD_DAV_VDS_MASK; \ + REG_LCD_DAV |= (n) << LCD_DAV_VDS_BIT; \ +} while (0) + +#define __lcd_dav_get_vde() \ + ( (REG_LCD_DAV & LCD_DAV_VDE_MASK) >> LCD_DAV_VDE_BIT ) +#define __lcd_dav_set_vde(n) \ +do { \ + REG_LCD_DAV &= ~LCD_DAV_VDE_MASK; \ + REG_LCD_DAV |= (n) << LCD_DAV_VDE_BIT; \ +} while (0) + +/* DMA Command Register */ +#define __lcd_cmd0_set_sofint() ( REG_LCD_CMD0 |= LCD_CMD_SOFINT ) +#define __lcd_cmd0_clr_sofint() ( REG_LCD_CMD0 &= ~LCD_CMD_SOFINT ) +#define __lcd_cmd1_set_sofint() ( REG_LCD_CMD1 |= LCD_CMD_SOFINT ) +#define __lcd_cmd1_clr_sofint() ( REG_LCD_CMD1 &= ~LCD_CMD_SOFINT ) + +#define __lcd_cmd0_set_eofint() ( REG_LCD_CMD0 |= LCD_CMD_EOFINT ) +#define __lcd_cmd0_clr_eofint() ( REG_LCD_CMD0 &= ~LCD_CMD_EOFINT ) +#define __lcd_cmd1_set_eofint() ( REG_LCD_CMD1 |= LCD_CMD_EOFINT ) +#define __lcd_cmd1_clr_eofint() ( REG_LCD_CMD1 &= ~LCD_CMD_EOFINT ) + +#define __lcd_cmd0_set_pal() ( REG_LCD_CMD0 |= LCD_CMD_PAL ) +#define __lcd_cmd0_clr_pal() ( REG_LCD_CMD0 &= ~LCD_CMD_PAL ) + +#define __lcd_cmd0_get_len() \ + ( (REG_LCD_CMD0 & LCD_CMD_LEN_MASK) >> LCD_CMD_LEN_BIT ) +#define __lcd_cmd1_get_len() \ + ( (REG_LCD_CMD1 & LCD_CMD_LEN_MASK) >> LCD_CMD_LEN_BIT ) + +#endif /* __MIPS_ASSEMBLER */ + +/* + * Motion compensation module(MC) address definition + */ +#define MC_BASE 0xb3250000 + +/* + * MC registers offset address definition + */ +#define MC_MCCR_OFFSET (0x00) /* rw, 32, 0x???????? */ +#define MC_MCSR_OFFSET (0x04) /* rw, 32, 0x???????? */ +#define MC_MCRBAR_OFFSET (0x08) /* rw, 32, 0x???????? */ +#define MC_MCT1LFCR_OFFSET (0x0c) /* rw, 32, 0x???????? */ +#define MC_MCT2LFCR_OFFSET (0x10) /* rw, 32, 0x???????? */ +#define MC_MCCBAR_OFFSET (0x14) /* rw, 32, 0x???????? */ +#define MC_MCIIR_OFFSET (0x18) /* rw, 32, 0x???????? */ +#define MC_MCSIR_OFFSET (0x1c) /* rw, 32, 0x???????? */ +#define MC_MCT1MFCR_OFFSET (0x20) /* rw, 32, 0x???????? */ +#define MC_MCT2MFCR_OFFSET (0x24) /* rw, 32, 0x???????? */ +#define MC_MCFGIR_OFFSET (0x28) /* rw, 32, 0x???????? */ +#define MC_MCFCIR_OFFSET (0x2c) /* rw, 32, 0x???????? */ +#define MC_MCRNDTR_OFFSET (0x40) /* rw, 32, 0x???????? */ + +#define MC_MC2CR_OFFSET (0x8000) /* rw, 32, 0x???????? */ +#define MC_MC2SR_OFFSET (0x8004) /* rw, 32, 0x???????? */ +#define MC_MC2RBAR_OFFSET (0x8008) /* rw, 32, 0x???????? */ +#define MC_MC2CBAR_OFFSET (0x800c) /* rw, 32, 0x???????? */ +#define MC_MC2IIR_OFFSET (0x8010) /* rw, 32, 0x???????? */ +#define MC_MC2TFCR_OFFSET (0x8014) /* rw, 32, 0x???????? */ +#define MC_MC2SIR_OFFSET (0x8018) /* rw, 32, 0x???????? */ +#define MC_MC2FCIR_OFFSET (0x801c) /* rw, 32, 0x???????? */ +#define MC_MC2RNDTR_OFFSET (0x8040) /* rw, 32, 0x???????? */ + +/* + * MC registers address definition + */ +#define MC_MCCR (MC_BASE + MC_MCCR_OFFSET) +#define MC_MCSR (MC_BASE + MC_MCSR_OFFSET) +#define MC_MCRBAR (MC_BASE + MC_MCRBAR_OFFSET) +#define MC_MCT1LFCR (MC_BASE + MC_MCT1LFCR_OFFSET) +#define MC_MCT2LFCR (MC_BASE + MC_MCT2LFCR_OFFSET) +#define MC_MCCBAR (MC_BASE + MC_MCCBAR_OFFSET) +#define MC_MCIIR (MC_BASE + MC_MCIIR_OFFSET) +#define MC_MCSIR (MC_BASE + MC_MCSIR_OFFSET) +#define MC_MCT1MFCR (MC_BASE + MC_MCT1MFCR_OFFSET) +#define MC_MCT2MFCR (MC_BASE + MC_MCT2MFCR_OFFSET) +#define MC_MCFGIR (MC_BASE + MC_MCFGIR_OFFSET) +#define MC_MCFCIR (MC_BASE + MC_MCFCIR_OFFSET) +#define MC_MCRNDTR (MC_BASE + MC_MCRNDTR_OFFSET) + +#define MC_MC2CR (MC_BASE + MC_MC2CR_OFFSET) +#define MC_MC2SR (MC_BASE + MC_MC2SR_OFFSET) +#define MC_MC2RBAR (MC_BASE + MC_MC2RBAR_OFFSET) +#define MC_MC2CBAR (MC_BASE + MC_MC2CBAR_OFFSET) +#define MC_MC2IIR (MC_BASE + MC_MC2IIR_OFFSET) +#define MC_MC2TFCR (MC_BASE + MC_MC2TFCR_OFFSET) +#define MC_MC2SIR (MC_BASE + MC_MC2SIR_OFFSET) +#define MC_MC2FCIR (MC_BASE + MC_MC2FCIR_OFFSET) +#define MC_MC2RNDTR (MC_BASE + MC_MC2RNDTR_OFFSET) + +/* + * MC registers common define + */ + +/* MC Control Register(MCCR) */ +#define MCCR_RETE BIT16 +#define MCCR_DIPE BIT7 +#define MCCR_CKGEN BIT6 +#define MCCR_FDDEN BIT5 +#define MCCR_DINSE BIT3 +#define MCCR_FAE BIT2 +#define MCCR_RST BIT1 +#define MCCR_CHEN BIT0 + +#define MCCR_FDDPGN_LSB 8 +#define MCCR_FDDPGN_MASK BITS_H2L(15, MCCR_FDDPGN_LSB) + +/* MC Status Register(MCSR) */ +#define MCSR_DLEND BIT1 +#define MCSR_BKLEND BIT0 + +#ifndef __MIPS_ASSEMBLER + +#define REG_MC_MCCR REG32(REG_MC_MCCR) +#define REG_MC_MCSR REG32(REG_MC_MCSR) +#define REG_MC_MCRBAR REG32(REG_MC_MCRBAR) +#define REG_MC_MCT1LFCR REG32(REG_MC_MCT1LFCR) +#define REG_MC_MCT2LFCR REG32(REG_MC_MCT2LFCR) +#define REG_MC_MCCBAR REG32(REG_MC_MCCBAR) +#define REG_MC_MCIIR REG32(REG_MC_MCIIR) +#define REG_MC_MCSIR REG32(REG_MC_MCSIR) +#define REG_MC_MCT1MFCR REG32(REG_MC_MCT1MFCR) +#define REG_MC_MCT2MFCR REG32(REG_MC_MCT2MFCR) +#define REG_MC_MCFGIR REG32(REG_MC_MCFGIR) +#define REG_MC_MCFCIR REG32(REG_MC_MCFCIR) +#define REG_MC_MCRNDTR REG32(REG_MC_MCRNDTR) + +#define REG_MC_MC2CR REG32(REG_MC_MC2CR) +#define REG_MC_MC2SR REG32(REG_MC_MC2SR) +#define REG_MC_MC2RBAR REG32(REG_MC_MC2RBAR) +#define REG_MC_MC2CBAR REG32(REG_MC_MC2CBAR) +#define REG_MC_MC2IIR REG32(REG_MC_MC2IIR) +#define REG_MC_MC2TFCR REG32(REG_MC_MC2TFCR) +#define REG_MC_MC2SIR REG32(REG_MC_MC2SIR) +#define REG_MC_MC2FCIR REG32(REG_MC_MC2FCIR) +#define REG_MC_MC2RNDTR REG32(REG_MC_MC2RNDTR) + +#endif /* __MIPS_ASSEMBLER */ + +#define MDMAC_BASE 0xB3030000 /* Memory Copy DMAC */ + +/************************************************************************* + * MDMAC (MEM Copy DMA Controller) + *************************************************************************/ + +/* m is the DMA controller index (0, 1), n is the DMA channel index (0 - 11) */ + +#define MDMAC_DSAR(n) (MDMAC_BASE + (0x00 + (n) * 0x20)) /* DMA source address */ +#define MDMAC_DTAR(n) (MDMAC_BASE + (0x04 + (n) * 0x20)) /* DMA target address */ +#define MDMAC_DTCR(n) (MDMAC_BASE + (0x08 + (n) * 0x20)) /* DMA transfer count */ +#define MDMAC_DRSR(n) (MDMAC_BASE + (0x0c + (n) * 0x20)) /* DMA request source */ +#define MDMAC_DCCSR(n) (MDMAC_BASE + (0x10 + (n) * 0x20)) /* DMA control/status */ +#define MDMAC_DCMD(n) (MDMAC_BASE + (0x14 + (n) * 0x20)) /* DMA command */ +#define MDMAC_DDA(n) (MDMAC_BASE + (0x18 + (n) * 0x20)) /* DMA descriptor address */ +#define MDMAC_DSD(n) (MDMAC_BASE + (0x1c + (n) * 0x20)) /* DMA Stride Address */ + +#define MDMAC_DMACR (MDMAC_BASE + 0x0300) /* DMA control register */ +#define MDMAC_DMAIPR (MDMAC_BASE + 0x0304) /* DMA interrupt pending */ +#define MDMAC_DMADBR (MDMAC_BASE + 0x0308) /* DMA doorbell */ +#define MDMAC_DMADBSR (MDMAC_BASE + 0x030C) /* DMA doorbell set */ +#define MDMAC_DMACKE (MDMAC_BASE + 0x0310) +#define MDMAC_DMACKES (MDMAC_BASE + 0x0314) +#define MDMAC_DMACKEC (MDMAC_BASE + 0x0318) + +#define REG_MDMAC_DSAR(n) REG32(MDMAC_DSAR((n))) +#define REG_MDMAC_DTAR(n) REG32(MDMAC_DTAR((n))) +#define REG_MDMAC_DTCR(n) REG32(MDMAC_DTCR((n))) +#define REG_MDMAC_DRSR(n) REG32(MDMAC_DRSR((n))) +#define REG_MDMAC_DCCSR(n) REG32(MDMAC_DCCSR((n))) +#define REG_MDMAC_DCMD(n) REG32(MDMAC_DCMD((n))) +#define REG_MDMAC_DDA(n) REG32(MDMAC_DDA((n))) +#define REG_MDMAC_DSD(n) REG32(MDMAC_DSD(n)) +#define REG_MDMAC_DMACR REG32(MDMAC_DMACR) +#define REG_MDMAC_DMAIPR REG32(MDMAC_DMAIPR) +#define REG_MDMAC_DMADBR REG32(MDMAC_DMADBR) +#define REG_MDMAC_DMADBSR REG32(MDMAC_DMADBSR) +#define REG_MDMAC_DMACKE REG32(MDMAC_DMACKE) +#define REG_MDMAC_DMACKES REG32(MDMAC_DMACKES) +#define REG_MDMAC_DMACKEC REG32(MDMAC_DMACKEC) + +// DMA control register +#define DMAC_MDMACR_HLT (1 << 3) /* DMA halt flag */ +#define DMAC_MDMACR_AR (1 << 2) /* address error flag */ +#define DMAC_MDMACR_DMAE (1 << 0) /* DMA enable bit */ + +#ifndef __MIPS_ASSEMBLER + +/*************************************************************************** + * Mem Copy DMAC + ***************************************************************************/ + +#define __mdmac_enable_module() \ + ( REG_MDMAC_DMACR |= DMAC_MDMACR_DMAE ) +#define __mdmac_disable_module() \ + ( REG_MDMAC_DMACR &= ~DMAC_MDMACR_DMAE ) + +#define __mdmac_test_halt_error ( REG_MDMAC_DMACR & DMAC_MDMACR_HLT ) +#define __mdmac_test_addr_error ( REG_MDMAC_DMACR & DMAC_MDMACR_AR ) + +#define __mdmac_channel_enable_clk \ + REG_MDMAC_DMACKES = 1 << (n); + +#define __mdmac_channel_disable_clk \ + REG_MDMAC_DMACKEC = 1 << (n); + +#define __mdmac_enable_descriptor(n) \ + ( REG_MDMAC_DCCSR((n)) &= ~DMAC_DCCSR_NDES ) +#define __mdmac_disable_descriptor(n) \ + ( REG_MDMAC_DCCSR((n)) |= DMAC_DCCSR_NDES ) + +#define __mdmac_enable_channel(n) \ +do { \ + REG_MDMAC_DCCSR((n)) |= DMAC_DCCSR_EN; \ +} while (0) +#define __mdmac_disable_channel(n) \ +do { \ + REG_MDMAC_DCCSR((n)) &= ~DMAC_DCCSR_EN; \ +} while (0) +#define __mdmac_channel_enabled(n) \ + ( REG_MDMAC_DCCSR((n)) & DMAC_DCCSR_EN ) + +#define __mdmac_channel_enable_irq(n) \ + ( REG_MDMAC_DCMD((n)) |= DMAC_DCMD_TIE ) +#define __mdmac_channel_disable_irq(n) \ + ( REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_TIE ) + +#define __mdmac_channel_transmit_halt_detected(n) \ + ( REG_MDMAC_DCCSR((n)) & DMAC_DCCSR_HLT ) +#define __mdmac_channel_transmit_end_detected(n) \ + ( REG_MDMAC_DCCSR((n)) & DMAC_DCCSR_TT ) +#define __mdmac_channel_address_error_detected(n) \ + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_AR ) +#define __mdmac_channel_count_terminated_detected(n) \ + ( REG_MDMAC_DCCSR((n)) & DMAC_DCCSR_CT ) +#define __mdmac_channel_descriptor_invalid_detected(n) \ + ( REG_MDMAC_DCCSR((n)) & DMAC_DCCSR_INV ) + +#define __mdmac_channel_clear_transmit_halt(n) \ + do { \ + /* clear both channel halt error and globle halt error */ \ + REG_MDMAC_DCCSR(n) &= ~DMAC_DCCSR_HLT; \ + REG_MDMAC_DMACR &= ~DMAC_DMACR_HLT; \ + } while (0) +#define __mdmac_channel_clear_transmit_end(n) \ + ( REG_MDMAC_DCCSR(n) &= ~DMAC_DCCSR_TT ) +#define __mdmac_channel_clear_address_error(n) \ + do { \ + REG_MDMAC_DDA(n) = 0; /* clear descriptor address register */ \ + REG_MDMAC_DSAR(n) = 0; /* clear source address register */ \ + REG_MDMAC_DTAR(n) = 0; /* clear target address register */ \ + /* clear both channel addr error and globle address error */ \ + REG_MDMAC_DCCSR(n) &= ~DMAC_DCCSR_AR; \ + REG_MDMAC_DMACR &= ~DMAC_DMACR_AR; \ + } while (0) +#define __mdmac_channel_clear_count_terminated(n) \ + ( REG_MDMAC_DCCSR((n)) &= ~DMAC_DCCSR_CT ) +#define __mdmac_channel_clear_descriptor_invalid(n) \ + ( REG_MDMAC_DCCSR((n)) &= ~DMAC_DCCSR_INV ) + +#define __mdmac_channel_set_transfer_unit_32bit(n) \ +do { \ + REG_MDMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \ + REG_MDMAC_DCMD((n)) |= DMAC_DCMD_DS_32BIT; \ +} while (0) + +#define __mdmac_channel_set_transfer_unit_16bit(n) \ +do { \ + REG_MDMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \ + REG_MDMAC_DCMD((n)) |= DMAC_DCMD_DS_16BIT; \ +} while (0) + +#define __mdmac_channel_set_transfer_unit_8bit(n) \ +do { \ + REG_MDMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \ + REG_MDMAC_DCMD((n)) |= DMAC_DCMD_DS_8BIT; \ +} while (0) + +#define __mdmac_channel_set_transfer_unit_16byte(n) \ +do { \ + REG_MDMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \ + REG_MDMAC_DCMD((n)) |= DMAC_DCMD_DS_16BYTE; \ +} while (0) + +#define __mdmac_channel_set_transfer_unit_32byte(n) \ +do { \ + REG_MDMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \ + REG_MDMAC_DCMD((n)) |= DMAC_DCMD_DS_32BYTE; \ +} while (0) + +/* w=8,16,32 */ +#define __mdmac_channel_set_dest_port_width(n,w) \ +do { \ + REG_MDMAC_DCMD((n)) &= ~DMAC_DCMD_DWDH_MASK; \ + REG_MDMAC_DCMD((n)) |= DMAC_DCMD_DWDH_##w; \ +} while (0) + +/* w=8,16,32 */ +#define __mdmac_channel_set_src_port_width(n,w) \ +do { \ + REG_MDMAC_DCMD((n)) &= ~DMAC_DCMD_SWDH_MASK; \ + REG_MDMAC_DCMD((n)) |= DMAC_DCMD_SWDH_##w; \ +} while (0) + +/* v=0-15 */ +#define __mdmac_channel_set_rdil(n,v) \ +do { \ + REG_MDMAC_DCMD((n)) &= ~DMAC_DCMD_RDIL_MASK; \ + REG_MDMAC_DCMD((n) |= ((v) << DMAC_DCMD_RDIL_BIT); \ +} while (0) + +#define __mdmac_channel_dest_addr_fixed(n) \ + (REG_MDMAC_DCMD((n)) &= ~DMAC_DCMD_DAI) +#define __mdmac_channel_dest_addr_increment(n) \ + (REG_MDMAC_DCMD((n)) |= DMAC_DCMD_DAI) + +#define __mdmac_channel_src_addr_fixed(n) \ + (REG_MDMAC_DCMD((n)) &= ~DMAC_DCMD_SAI) +#define __mdmac_channel_src_addr_increment(n) \ + (REG_MDMAC_DCMD((n)) |= DMAC_DCMD_SAI) + +#define __mdmac_channel_set_doorbell(n) \ + (REG_MDMAC_DMADBSR = (1 << (n))) + +#define __mdmac_channel_irq_detected(n) (REG_MDMAC_DMAIPR & (1 << (n))) +#define __mdmac_channel_ack_irq(n) (REG_MDMAC_DMAIPR &= ~(1 <<(n))) + +static __inline__ int __mdmac_get_irq(void) +{ + int i; + for (i = 0; i < MAX_MDMA_NUM; i++) + if (__mdmac_channel_irq_detected(i)) + return i; + return -1; +} + +#endif /* __MIPS_ASSEMBLER */ + +/* + * Motion estimation module(ME) address definition + */ +#define ME_BASE 0xb3260000 + +/* + * ME registers offset address definition + */ +#define ME_MECR_OFFSET (0x00) /* rw, 32, 0x???????0 */ +#define ME_MERBAR_OFFSET (0x04) /* rw, 32, 0x???????? */ +#define ME_MECBAR_OFFSET (0x08) /* rw, 32, 0x???????? */ +#define ME_MEDAR_OFFSET (0x0c) /* rw, 32, 0x???????? */ +#define ME_MERFSR_OFFSET (0x10) /* rw, 32, 0x???????? */ +#define ME_MECFSR_OFFSET (0x14) /* rw, 32, 0x???????? */ +#define ME_MEDFSR_OFFSET (0x18) /* rw, 32, 0x???????? */ +#define ME_MESR_OFFSET (0x1c) /* rw, 32, 0x???????? */ +#define ME_MEMR_OFFSET (0x20) /* rw, 32, 0x???????? */ +#define ME_MEFR_OFFSET (0x24) /* rw, 32, 0x???????? */ + +/* + * ME registers address definition + */ +#define ME_MECR (ME_BASE + ME_MECR_OFFSET) +#define ME_MERBAR (ME_BASE + ME_MERBAR_OFFSET) +#define ME_MECBAR (ME_BASE + ME_MECBAR_OFFSET) +#define ME_MEDAR (ME_BASE + ME_MEDAR_OFFSET) +#define ME_MERFSR (ME_BASE + ME_MERFSR_OFFSET) +#define ME_MECFSR (ME_BASE + ME_MECFSR_OFFSET) +#define ME_MEDFSR (ME_BASE + ME_MEDFSR_OFFSET) +#define ME_MESR (ME_BASE + ME_MESR_OFFSET) +#define ME_MEMR (ME_BASE + ME_MEMR_OFFSET) +#define ME_MEFR (ME_BASE + ME_MEFR_OFFSET) + +/* + * ME registers common define + */ + +/* ME control register(MECR) */ +#define MECR_FLUSH BIT2 +#define MECR_RESET BIT1 +#define MECR_ENABLE BIT0 + +/* ME settings register(MESR) */ +#define MESR_GATE_LSB 16 +#define MESR_GATE_MASK BITS_H2L(31, MESR_GATE_LSB) + +#define MESR_NUM_LSB 0 +#define MESR_NUM_MASK BITS_H2L(5, MESR_NUM_LSB) + +/* ME MVD register(MEMR) */ +#define MEMR_MVDY_LSB 16 +#define MESR_MVDY_MASK BITS_H2L(31, MEMR_MVDY_LSB) + +#define MEMR_MVDX_LSB 0 +#define MESR_MVDX_MASK BITS_H2L(15, MEMR_MVDX_LSB) + +/* ME flag register(MEFR) */ +#define MEFR_INTRA BIT1 +#define MEFR_COMPLETED BIT0 + +#ifndef __MIPS_ASSEMBLER + +#define REG_ME_MECR REG32(ME_MECR) +#define REG_ME_MERBAR REG32(ME_MERBAR) +#define REG_ME_MECBAR REG32(ME_MECBAR) +#define REG_ME_MEDAR REG32(ME_MEDAR) +#define REG_ME_MERFSR REG32(ME_MERFSR) +#define REG_ME_MECFSR REG32(ME_MECFSR) +#define REG_ME_MEDFSR REG32(ME_MEDFSR) +#define REG_ME_MESR REG32(ME_MESR) +#define REG_ME_MEMR REG32(ME_MEMR) +#define REG_ME_MEFR REG32(ME_MEFR) + +#endif /* __MIPS_ASSEMBLER */ + +#define MSC0_BASE 0xB0021000 +#define MSC1_BASE 0xB0022000 +#define MSC2_BASE 0xB0023000 + +/************************************************************************* + * MSC + ************************************************************************/ +/* n = 0, 1 (MSC0, MSC1) */ +#define MSC_STRPCL(n) (MSC0_BASE + (n)*0x1000 + 0x000) +#define MSC_STAT(n) (MSC0_BASE + (n)*0x1000 + 0x004) +#define MSC_CLKRT(n) (MSC0_BASE + (n)*0x1000 + 0x008) +#define MSC_CMDAT(n) (MSC0_BASE + (n)*0x1000 + 0x00C) +#define MSC_RESTO(n) (MSC0_BASE + (n)*0x1000 + 0x010) +#define MSC_RDTO(n) (MSC0_BASE + (n)*0x1000 + 0x014) +#define MSC_BLKLEN(n) (MSC0_BASE + (n)*0x1000 + 0x018) +#define MSC_NOB(n) (MSC0_BASE + (n)*0x1000 + 0x01C) +#define MSC_SNOB(n) (MSC0_BASE + (n)*0x1000 + 0x020) +#define MSC_IMASK(n) (MSC0_BASE + (n)*0x1000 + 0x024) +#define MSC_IREG(n) (MSC0_BASE + (n)*0x1000 + 0x028) +#define MSC_CMD(n) (MSC0_BASE + (n)*0x1000 + 0x02C) +#define MSC_ARG(n) (MSC0_BASE + (n)*0x1000 + 0x030) +#define MSC_RES(n) (MSC0_BASE + (n)*0x1000 + 0x034) +#define MSC_RXFIFO(n) (MSC0_BASE + (n)*0x1000 + 0x038) +#define MSC_TXFIFO(n) (MSC0_BASE + (n)*0x1000 + 0x03C) +#define MSC_LPM(n) (MSC0_BASE + (n)*0x1000 + 0x040) + +#define REG_MSC_STRPCL(n) REG16(MSC_STRPCL(n)) +#define REG_MSC_STAT(n) REG32(MSC_STAT(n)) +#define REG_MSC_CLKRT(n) REG16(MSC_CLKRT(n)) +#define REG_MSC_CMDAT(n) REG32(MSC_CMDAT(n)) +#define REG_MSC_RESTO(n) REG16(MSC_RESTO(n)) +#define REG_MSC_RDTO(n) REG32(MSC_RDTO(n)) +#define REG_MSC_BLKLEN(n) REG16(MSC_BLKLEN(n)) +#define REG_MSC_NOB(n) REG16(MSC_NOB(n)) +#define REG_MSC_SNOB(n) REG16(MSC_SNOB(n)) +#define REG_MSC_IMASK(n) REG32(MSC_IMASK(n)) +#define REG_MSC_IREG(n) REG16(MSC_IREG(n)) +#define REG_MSC_CMD(n) REG8(MSC_CMD(n)) +#define REG_MSC_ARG(n) REG32(MSC_ARG(n)) +#define REG_MSC_RES(n) REG16(MSC_RES(n)) +#define REG_MSC_RXFIFO(n) REG32(MSC_RXFIFO(n)) +#define REG_MSC_TXFIFO(n) REG32(MSC_TXFIFO(n)) +#define REG_MSC_LPM(n) REG32(MSC_LPM(n)) + +/* MSC Clock and Control Register (MSC_STRPCL) */ +#define MSC_STRPCL_SEND_CCSD (1 << 15) /*send command completion signal disable to ceata */ +#define MSC_STRPCL_SEND_AS_CCSD (1 << 14) /*send internally generated stop after sending ccsd */ +#define MSC_STRPCL_EXIT_MULTIPLE (1 << 7) +#define MSC_STRPCL_EXIT_TRANSFER (1 << 6) +#define MSC_STRPCL_START_READWAIT (1 << 5) +#define MSC_STRPCL_STOP_READWAIT (1 << 4) +#define MSC_STRPCL_RESET (1 << 3) +#define MSC_STRPCL_START_OP (1 << 2) +#define MSC_STRPCL_CLOCK_CONTROL_BIT 0 +#define MSC_STRPCL_CLOCK_CONTROL_MASK (0x3 << MSC_STRPCL_CLOCK_CONTROL_BIT) + #define MSC_STRPCL_CLOCK_CONTROL_STOP (0x1 << MSC_STRPCL_CLOCK_CONTROL_BIT) /* Stop MMC/SD clock */ + #define MSC_STRPCL_CLOCK_CONTROL_START (0x2 << MSC_STRPCL_CLOCK_CONTROL_BIT) /* Start MMC/SD clock */ + +/* MSC Status Register (MSC_STAT) */ +#define MSC_STAT_AUTO_CMD_DONE (1 << 31) /*12 is internally generated by controller has finished */ +#define MSC_STAT_IS_RESETTING (1 << 15) +#define MSC_STAT_SDIO_INT_ACTIVE (1 << 14) +#define MSC_STAT_PRG_DONE (1 << 13) +#define MSC_STAT_DATA_TRAN_DONE (1 << 12) +#define MSC_STAT_END_CMD_RES (1 << 11) +#define MSC_STAT_DATA_FIFO_AFULL (1 << 10) +#define MSC_STAT_IS_READWAIT (1 << 9) +#define MSC_STAT_CLK_EN (1 << 8) +#define MSC_STAT_DATA_FIFO_FULL (1 << 7) +#define MSC_STAT_DATA_FIFO_EMPTY (1 << 6) +#define MSC_STAT_CRC_RES_ERR (1 << 5) +#define MSC_STAT_CRC_READ_ERROR (1 << 4) +#define MSC_STAT_CRC_WRITE_ERROR_BIT 2 +#define MSC_STAT_CRC_WRITE_ERROR_MASK (0x3 << MSC_STAT_CRC_WRITE_ERROR_BIT) + #define MSC_STAT_CRC_WRITE_ERROR_NO (0 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* No error on transmission of data */ + #define MSC_STAT_CRC_WRITE_ERROR (1 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* Card observed erroneous transmission of data */ + #define MSC_STAT_CRC_WRITE_ERROR_NOSTS (2 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* No CRC status is sent back */ +#define MSC_STAT_TIME_OUT_RES (1 << 1) +#define MSC_STAT_TIME_OUT_READ (1 << 0) + +/* MSC Bus Clock Control Register (MSC_CLKRT) */ +#define MSC_CLKRT_CLK_DIV_BIT 14 +#define MSC_CLKRT_CLK_DIV_MASK (0x3 << MSC_CLKRT_CLK_DIV_BIT) +#define MSC_CLKRT_CLK_SRC_DIV_1 (0x0 << MSC_CLKRT_CLK_DIV_BIT) /* CLK_SRC */ +#define MSC_CLKRT_CLK_SRC_DIV_2 (0x1 << MSC_CLKRT_CLK_DIV_BIT) /* 1/2 of CLK_SRC */ +#define MSC_CLKRT_CLK_SRC_DIV_3 (0x2 << MSC_CLKRT_CLK_DIV_BIT) /* 1/3 of CLK_SRC */ +#define MSC_CLKRT_CLK_SRC_DIV_4 (0x3 << MSC_CLKRT_CLK_DIV_BIT) /* 1/4 of CLK_SRC */ + +#define MSC_CLKRT_CLK_RATE_BIT 0 +#define MSC_CLKRT_CLK_RATE_MASK (0x7 << MSC_CLKRT_CLK_RATE_BIT) +#define MSC_CLKRT_CLK_RATE_DIV_1 (0x0 << MSC_CLKRT_CLK_RATE_BIT) /* CLK_SRC */ +#define MSC_CLKRT_CLK_RATE_DIV_2 (0x1 << MSC_CLKRT_CLK_RATE_BIT) /* 1/2 of CLK_SRC */ +#define MSC_CLKRT_CLK_RATE_DIV_4 (0x2 << MSC_CLKRT_CLK_RATE_BIT) /* 1/4 of CLK_SRC */ +#define MSC_CLKRT_CLK_RATE_DIV_8 (0x3 << MSC_CLKRT_CLK_RATE_BIT) /* 1/8 of CLK_SRC */ +#define MSC_CLKRT_CLK_RATE_DIV_16 (0x4 << MSC_CLKRT_CLK_RATE_BIT) /* 1/16 of CLK_SRC */ +#define MSC_CLKRT_CLK_RATE_DIV_32 (0x5 << MSC_CLKRT_CLK_RATE_BIT) /* 1/32 of CLK_SRC */ +#define MSC_CLKRT_CLK_RATE_DIV_64 (0x6 << MSC_CLKRT_CLK_RATE_BIT) /* 1/64 of CLK_SRC */ +#define MSC_CLKRT_CLK_RATE_DIV_128 (0x7 << MSC_CLKRT_CLK_RATE_BIT) /* 1/128 of CLK_SRC */ + +/* MSC Command Sequence Control Register (MSC_CMDAT) */ +#define MSC_CMDAT_CCS_EXPECTED (1 << 31) /* interrupts are enabled in ce-ata */ +#define MSC_CMDAT_READ_CEATA (1 << 30) +#define MSC_CMDAT_SDIO_PRDT (1 << 17) /* exact 2 cycle */ +#define MSC_CMDAT_SEND_AS_STOP (1 << 16) +#define MSC_CMDAT_RTRG_BIT 14 +#define MSC_CMDAT_RTRG_EQUALT_8 (0x0 << MSC_CMDAT_RTRG_BIT) /*reset value*/ + #define MSC_CMDAT_RTRG_EQUALT_16 (0x1 << MSC_CMDAT_RTRG_BIT) + #define MSC_CMDAT_RTRG_EQUALT_24 (0x2 << MSC_CMDAT_RTRG_BIT) + +#define MSC_CMDAT_TTRG_BIT 12 +#define MSC_CMDAT_TTRG_LESS_8 (0x0 << MSC_CMDAT_TTRG_BIT) /*reset value*/ + #define MSC_CMDAT_TTRG_LESS_16 (0x1 << MSC_CMDAT_TTRG_BIT) + #define MSC_CMDAT_TTRG_LESS_24 (0x2 << MSC_CMDAT_TTRG_BIT) +#define MSC_CMDAT_STOP_ABORT (1 << 11) +#define MSC_CMDAT_BUS_WIDTH_BIT 9 +#define MSC_CMDAT_BUS_WIDTH_MASK (0x3 << MSC_CMDAT_BUS_WIDTH_BIT) + #define MSC_CMDAT_BUS_WIDTH_1BIT (0x0 << MSC_CMDAT_BUS_WIDTH_BIT) /* 1-bit data bus */ + #define MSC_CMDAT_BUS_WIDTH_4BIT (0x2 << MSC_CMDAT_BUS_WIDTH_BIT) /* 4-bit data bus */ + #define MSC_CMDAT_BUS_WIDTH_8BIT (0x3 << MSC_CMDAT_BUS_WIDTH_BIT) /* 8-bit data bus */ +#define MSC_CMDAT_DMA_EN (1 << 8) +#define MSC_CMDAT_INIT (1 << 7) +#define MSC_CMDAT_BUSY (1 << 6) +#define MSC_CMDAT_STREAM_BLOCK (1 << 5) +#define MSC_CMDAT_WRITE (1 << 4) +#define MSC_CMDAT_READ (0 << 4) +#define MSC_CMDAT_DATA_EN (1 << 3) +#define MSC_CMDAT_RESPONSE_BIT 0 +#define MSC_CMDAT_RESPONSE_MASK (0x7 << MSC_CMDAT_RESPONSE_BIT) + #define MSC_CMDAT_RESPONSE_NONE (0x0 << MSC_CMDAT_RESPONSE_BIT) /* No response */ + #define MSC_CMDAT_RESPONSE_R1 (0x1 << MSC_CMDAT_RESPONSE_BIT) /* Format R1 and R1b */ + #define MSC_CMDAT_RESPONSE_R2 (0x2 << MSC_CMDAT_RESPONSE_BIT) /* Format R2 */ + #define MSC_CMDAT_RESPONSE_R3 (0x3 << MSC_CMDAT_RESPONSE_BIT) /* Format R3 */ + #define MSC_CMDAT_RESPONSE_R4 (0x4 << MSC_CMDAT_RESPONSE_BIT) /* Format R4 */ + #define MSC_CMDAT_RESPONSE_R5 (0x5 << MSC_CMDAT_RESPONSE_BIT) /* Format R5 */ + #define MSC_CMDAT_RESPONSE_R6 (0x6 << MSC_CMDAT_RESPONSE_BIT) /* Format R6 */ + #define MSC_CMDAT_RESRONSE_R7 (0x7 << MSC_CMDAT_RESPONSE_BIT) /* Format R7 */ + +#define CMDAT_DMA_EN (1 << 8) +#define CMDAT_INIT (1 << 7) +#define CMDAT_BUSY (1 << 6) +#define CMDAT_STREAM (1 << 5) +#define CMDAT_WRITE (1 << 4) +#define CMDAT_DATA_EN (1 << 3) + +/* MSC Interrupts Mask Register (MSC_IMASK) */ +#define MSC_IMASK_AUTO_CMD_DONE (1 << 15) +#define MSC_IMASK_DATA_FIFO_FULL (1 << 14) +#define MSC_IMASK_DATA_FIFO_EMP (1 << 13) +#define MSC_IMASK_CRC_RES_ERR (1 << 12) +#define MSC_IMASK_CRC_READ_ERR (1 << 11) +#define MSC_IMASK_CRC_WRITE_ERR (1 << 10) +#define MSC_IMASK_TIME_OUT_RES (1 << 9) +#define MSC_IMASK_TIME_OUT_READ (1 << 8) +#define MSC_IMASK_SDIO (1 << 7) +#define MSC_IMASK_TXFIFO_WR_REQ (1 << 6) +#define MSC_IMASK_RXFIFO_RD_REQ (1 << 5) +#define MSC_IMASK_END_CMD_RES (1 << 2) +#define MSC_IMASK_PRG_DONE (1 << 1) +#define MSC_IMASK_DATA_TRAN_DONE (1 << 0) + +/* MSC Interrupts Status Register (MSC_IREG) */ +#define MSC_IREG_AUTO_CMD_DONE (1 << 15) +#define MSC_IREG_DATA_FIFO_FULL (1 << 14) +#define MSC_IREG_DATA_FIFO_EMP (1 << 13) +#define MSC_IREG_CRC_RES_ERR (1 << 12) +#define MSC_IREG_CRC_READ_ERR (1 << 11) +#define MSC_IREG_CRC_WRITE_ERR (1 << 10) +#define MSC_IREG_TIMEOUT_RES (1 << 9) +#define MSC_IREG_TIMEOUT_READ (1 << 8) +#define MSC_IREG_SDIO (1 << 7) +#define MSC_IREG_TXFIFO_WR_REQ (1 << 6) +#define MSC_IREG_RXFIFO_RD_REQ (1 << 5) +#define MSC_IREG_END_CMD_RES (1 << 2) +#define MSC_IREG_PRG_DONE (1 << 1) +#define MSC_IREG_DATA_TRAN_DONE (1 << 0) + +/* MSC Low Power Mode Register (MSC_LPM) */ +#define MSC_SET_HISPD (1 << 31) +#define MSC_SET_LPM (1 << 0) + +#ifndef __MIPS_ASSEMBLER + +/*************************************************************************** + * MSC + ***************************************************************************/ +/* n = 0, 1 (MSC0, MSC1) */ + +#define __msc_start_op(n) \ + ( REG_MSC_STRPCL(n) = MSC_STRPCL_START_OP | MSC_STRPCL_CLOCK_CONTROL_START ) + +#define __msc_set_resto(n, to) ( REG_MSC_RESTO(n) = to ) +#define __msc_set_rdto(n, to) ( REG_MSC_RDTO(n) = to ) +#define __msc_set_cmd(n, cmd) ( REG_MSC_CMD(n) = cmd ) +#define __msc_set_arg(n, arg) ( REG_MSC_ARG(n) = arg ) +#define __msc_set_nob(n, nob) ( REG_MSC_NOB(n) = nob ) +#define __msc_get_nob(n) ( REG_MSC_NOB(n) ) +#define __msc_set_blklen(n, len) ( REG_MSC_BLKLEN(n) = len ) +#define __msc_set_cmdat(n, cmdat) ( REG_MSC_CMDAT(n) = cmdat ) + +#define __msc_set_cmdat_bus_width1(n) \ +do { \ + REG_MSC_CMDAT(n) &= ~MSC_CMDAT_BUS_WIDTH_MASK; \ + REG_MSC_CMDAT(n) |= MSC_CMDAT_BUS_WIDTH_1BIT; \ +} while(0) + +#define __msc_set_cmdat_bus_width4(n) \ +do { \ + REG_MSC_CMDAT(n) &= ~MSC_CMDAT_BUS_WIDTH_MASK; \ + REG_MSC_CMDAT(n) |= MSC_CMDAT_BUS_WIDTH_4BIT; \ +} while(0) + +#define __msc_set_cmdat_dma_en(n) ( REG_MSC_CMDAT(n) |= MSC_CMDAT_DMA_EN ) +#define __msc_set_cmdat_init(n) ( REG_MSC_CMDAT(n) |= MSC_CMDAT_INIT ) +#define __msc_set_cmdat_busy(n) ( REG_MSC_CMDAT(n) |= MSC_CMDAT_BUSY ) +#define __msc_set_cmdat_stream(n) ( REG_MSC_CMDAT(n) |= MSC_CMDAT_STREAM_BLOCK ) +#define __msc_set_cmdat_block(n) ( REG_MSC_CMDAT(n) &= ~MSC_CMDAT_STREAM_BLOCK ) +#define __msc_set_cmdat_read(n) ( REG_MSC_CMDAT(n) &= ~MSC_CMDAT_WRITE ) +#define __msc_set_cmdat_write(n) ( REG_MSC_CMDAT(n) |= MSC_CMDAT_WRITE ) +#define __msc_set_cmdat_data_en(n) ( REG_MSC_CMDAT(n) |= MSC_CMDAT_DATA_EN ) + +/* r is MSC_CMDAT_RESPONSE_FORMAT_Rx or MSC_CMDAT_RESPONSE_FORMAT_NONE */ +#define __msc_set_cmdat_res_format(n, r) \ +do { \ + REG_MSC_CMDAT(n) &= ~MSC_CMDAT_RESPONSE_MASK; \ + REG_MSC_CMDAT(n) |= (r); \ +} while(0) + +#define __msc_clear_cmdat(n) \ + REG_MSC_CMDAT(n) &= ~( MSC_CMDAT_STOP_ABORT | MSC_CMDAT_DMA_EN | MSC_CMDAT_INIT| \ + MSC_CMDAT_BUSY | MSC_CMDAT_STREAM_BLOCK | MSC_CMDAT_WRITE | \ + MSC_CMDAT_DATA_EN | MSC_CMDAT_RESPONSE_MASK ) + +#define __msc_get_imask(n) ( REG_MSC_IMASK(n) ) +#define __msc_mask_all_intrs(n) ( REG_MSC_IMASK(n) = 0xff ) +#define __msc_unmask_all_intrs(n) ( REG_MSC_IMASK(n) = 0x00 ) +#define __msc_mask_rd(n) ( REG_MSC_IMASK(n) |= MSC_IMASK_RXFIFO_RD_REQ ) +#define __msc_unmask_rd(n) ( REG_MSC_IMASK(n) &= ~MSC_IMASK_RXFIFO_RD_REQ ) +#define __msc_mask_wr(n) ( REG_MSC_IMASK(n) |= MSC_IMASK_TXFIFO_WR_REQ ) +#define __msc_unmask_wr(n) ( REG_MSC_IMASK(n) &= ~MSC_IMASK_TXFIFO_WR_REQ ) +#define __msc_mask_endcmdres(n) ( REG_MSC_IMASK(n) |= MSC_IMASK_END_CMD_RES ) +#define __msc_unmask_endcmdres(n) ( REG_MSC_IMASK(n) &= ~MSC_IMASK_END_CMD_RES ) +#define __msc_mask_datatrandone(n) ( REG_MSC_IMASK(n) |= MSC_IMASK_DATA_TRAN_DONE ) +#define __msc_unmask_datatrandone(n) ( REG_MSC_IMASK(n) &= ~MSC_IMASK_DATA_TRAN_DONE ) +#define __msc_mask_prgdone(n) ( REG_MSC_IMASK(n) |= MSC_IMASK_PRG_DONE ) +#define __msc_unmask_prgdone(n) ( REG_MSC_IMASK(n) &= ~MSC_IMASK_PRG_DONE ) + +/* m=0,1,2,3,4,5,6,7 */ +#define __msc_set_clkrt(n, m) \ +do { \ + REG_MSC_CLKRT(n) = m; \ +} while(0) + +#define __msc_get_ireg(n) ( REG_MSC_IREG(n) ) +#define __msc_ireg_rd(n) ( REG_MSC_IREG(n) & MSC_IREG_RXFIFO_RD_REQ ) +#define __msc_ireg_wr(n) ( REG_MSC_IREG(n) & MSC_IREG_TXFIFO_WR_REQ ) +#define __msc_ireg_end_cmd_res(n) ( REG_MSC_IREG(n) & MSC_IREG_END_CMD_RES ) +#define __msc_ireg_data_tran_done(n) ( REG_MSC_IREG(n) & MSC_IREG_DATA_TRAN_DONE ) +#define __msc_ireg_prg_done(n) ( REG_MSC_IREG(n) & MSC_IREG_PRG_DONE ) +#define __msc_ireg_clear_end_cmd_res(n) ( REG_MSC_IREG(n) = MSC_IREG_END_CMD_RES ) +#define __msc_ireg_clear_data_tran_done(n) ( REG_MSC_IREG(n) = MSC_IREG_DATA_TRAN_DONE ) +#define __msc_ireg_clear_prg_done(n) ( REG_MSC_IREG(n) = MSC_IREG_PRG_DONE ) + +#define __msc_get_stat(n) ( REG_MSC_STAT(n) ) +#define __msc_stat_not_end_cmd_res(n) ( (REG_MSC_STAT(n) & MSC_STAT_END_CMD_RES) == 0) +#define __msc_stat_crc_err(n) \ + ( REG_MSC_STAT(n) & (MSC_STAT_CRC_RES_ERR | MSC_STAT_CRC_READ_ERROR | MSC_STAT_CRC_WRITE_ERROR_YES) ) +#define __msc_stat_res_crc_err(n) ( REG_MSC_STAT(n) & MSC_STAT_CRC_RES_ERR ) +#define __msc_stat_rd_crc_err(n) ( REG_MSC_STAT(n) & MSC_STAT_CRC_READ_ERROR ) +#define __msc_stat_wr_crc_err(n) ( REG_MSC_STAT(n) & MSC_STAT_CRC_WRITE_ERROR_YES ) +#define __msc_stat_resto_err(n) ( REG_MSC_STAT(n) & MSC_STAT_TIME_OUT_RES ) +#define __msc_stat_rdto_err(n) ( REG_MSC_STAT(n) & MSC_STAT_TIME_OUT_READ ) + +#define __msc_rd_resfifo(n) ( REG_MSC_RES(n) ) +#define __msc_rd_rxfifo(n) ( REG_MSC_RXFIFO(n) ) +#define __msc_wr_txfifo(n, v) ( REG_MSC_TXFIFO(n) = v ) + +#define __msc_reset(n) \ +do { \ + REG_MSC_STRPCL(n) = MSC_STRPCL_RESET; \ + while (REG_MSC_STAT(n) & MSC_STAT_IS_RESETTING); \ +} while (0) + +#define __msc_start_clk(n) \ +do { \ + REG_MSC_STRPCL(n) = MSC_STRPCL_CLOCK_CONTROL_START; \ +} while (0) + +#define __msc_stop_clk(n) \ +do { \ + REG_MSC_STRPCL(n) = MSC_STRPCL_CLOCK_CONTROL_STOP; \ +} while (0) + +#define MMC_CLK 19169200 +#define SD_CLK 24576000 + +/* msc_clk should little than pclk and little than clk retrieve from card */ +#define __msc_calc_clk_divisor(type,dev_clk,msc_clk,lv) \ +do { \ + unsigned int rate, pclk, i; \ + pclk = dev_clk; \ + rate = type?SD_CLK:MMC_CLK; \ + if (msc_clk && msc_clk < pclk) \ + pclk = msc_clk; \ + i = 0; \ + while (pclk < rate) \ + { \ + i ++; \ + rate >>= 1; \ + } \ + lv = i; \ +} while(0) + +/* divide rate to little than or equal to 400kHz */ +#define __msc_calc_slow_clk_divisor(type, lv) \ +do { \ + unsigned int rate, i; \ + rate = (type?SD_CLK:MMC_CLK)/1000/400; \ + i = 0; \ + while (rate > 0) \ + { \ + rate >>= 1; \ + i ++; \ + } \ + lv = i; \ +} while(0) + +#endif /* __MIPS_ASSEMBLER */ + +#define NEMC_BASE 0xB3410000 + +/************************************************************************* + * NEMC (External Memory Controller for NAND) + *************************************************************************/ + +#define NEMC_NFCSR (NEMC_BASE + 0x50) /* NAND Flash Control/Status Register */ +#define NEMC_SMCR (NEMC_BASE + 0x14) /* Static Memory Control Register 1 */ +#define NEMC_PNCR (NEMC_BASE + 0x100) +#define NEMC_PNDR (NEMC_BASE + 0x104) +#define NEMC_BITCNT (NEMC_BASE + 0x108) + +#define REG_NEMC_NFCSR REG32(NEMC_NFCSR) +#define REG_NEMC_SMCR1 REG32(NEMC_SMCR) +#define REG_NEMC_PNCR REG32(NEMC_PNCR) +#define REG_NEMC_PNDR REG32(NEMC_PNDR) +#define REG_NEMC_BITCNT REG32(NEMC_BITCNT) + +/* NAND Flash Control/Status Register */ +#define NEMC_NFCSR_NFCE4 (1 << 7) /* NAND Flash Enable */ +#define NEMC_NFCSR_NFE4 (1 << 6) /* NAND Flash FCE# Assertion Enable */ +#define NEMC_NFCSR_NFCE3 (1 << 5) +#define NEMC_NFCSR_NFE3 (1 << 4) +#define NEMC_NFCSR_NFCE2 (1 << 3) +#define NEMC_NFCSR_NFE2 (1 << 2) +#define NEMC_NFCSR_NFCE1 (1 << 1) +#define NEMC_NFCSR_NFE1 (1 << 0) + +#define UDC_BASE 0xB3440000 + +/************************************************************************* + * USB Device + *************************************************************************/ +#define USB_BASE UDC_BASE + +#define USB_FADDR (USB_BASE + 0x00) /* Function Address 8-bit */ +#define USB_POWER (USB_BASE + 0x01) /* Power Managemetn 8-bit */ +#define USB_INTRIN (USB_BASE + 0x02) /* Interrupt IN 16-bit */ +#define USB_INTROUT (USB_BASE + 0x04) /* Interrupt OUT 16-bit */ +#define USB_INTRINE (USB_BASE + 0x06) /* Intr IN enable 16-bit */ +#define USB_INTROUTE (USB_BASE + 0x08) /* Intr OUT enable 16-bit */ +#define USB_INTRUSB (USB_BASE + 0x0a) /* Interrupt USB 8-bit */ +#define USB_INTRUSBE (USB_BASE + 0x0b) /* Interrupt USB Enable 8-bit */ +#define USB_FRAME (USB_BASE + 0x0c) /* Frame number 16-bit */ +#define USB_INDEX (USB_BASE + 0x0e) /* Index register 8-bit */ +#define USB_TESTMODE (USB_BASE + 0x0f) /* USB test mode 8-bit */ + +#define USB_CSR0 (USB_BASE + 0x12) /* EP0 CSR 16-bit */ +#define USB_COUNT0 (USB_BASE + 0x18) /* EP0 OUT FIFO count 8-bit */ + +#define USB_INMAXP (USB_BASE + 0x10) /* EP1-15 IN Max Pkt Size 16-bit */ +#define USB_INCSR (USB_BASE + 0x12) /* EP1-15 IN CSR LSB 8/16bit */ +#define USB_INCSRH (USB_BASE + 0x13) /* EP1-15 IN CSR MSB 8-bit */ +#define USB_OUTMAXP (USB_BASE + 0x14) /* EP1-15 OUT Max Pkt Size 16-bit */ +#define USB_OUTCSR (USB_BASE + 0x16) /* EP1-15 OUT CSR LSB 8/16bit */ +#define USB_OUTCSRH (USB_BASE + 0x17) /* EP1-15 OUT CSR MSB 8-bit */ +#define USB_OUTCOUNT (USB_BASE + 0x18) /* EP1-15 OUT FIFO count 16-bit */ + +#define USB_FIFO_EP(n) (USB_BASE + (n)*4 + 0x20) + +#define USB_EPINFO (USB_BASE + 0x78) /* Endpoint information */ +#define USB_RAMINFO (USB_BASE + 0x79) /* RAM information */ + +#define USB_INTR (USB_BASE + 0x200) /* DMA pending interrupts */ +#define USB_CNTL(n) (USB_BASE + (n)*0x10 + 0x204) /* DMA channel n control */ +#define USB_ADDR(n) (USB_BASE + (n)*0x10 + 0x208) /* DMA channel n AHB memory addr */ +#define USB_COUNT(n) (USB_BASE + (n)*0x10 + 0x20c) /* DMA channel n byte count */ + +/* Power register bit masks */ +#define USB_POWER_SUSPENDM 0x01 +#define USB_POWER_RESUME 0x04 +#define USB_POWER_HSMODE 0x10 +#define USB_POWER_HSENAB 0x20 +#define USB_POWER_SOFTCONN 0x40 + +/* Interrupt register bit masks */ +#define USB_INTR_SUSPEND 0x01 +#define USB_INTR_RESUME 0x02 +#define USB_INTR_RESET 0x04 + +#define USB_INTR_EP(n) (1 << (n)) + +/* CSR0 bit masks */ +#define USB_CSR0_OUTPKTRDY 0x01 +#define USB_CSR0_INPKTRDY 0x02 +#define USB_CSR0_SENTSTALL 0x04 +#define USB_CSR0_DATAEND 0x08 +#define USB_CSR0_SETUPEND 0x10 +#define USB_CSR0_SENDSTALL 0x20 +#define USB_CSR0_SVDOUTPKTRDY 0x40 +#define USB_CSR0_SVDSETUPEND 0x80 +#define USB_CSR0_FLUSHFIFO 0x100 + +/* Endpoint CSR register bits */ +#define USB_INCSRH_AUTOSET 0x80 +#define USB_INCSRH_ISO 0x40 +#define USB_INCSRH_MODE 0x20 +#define USB_INCSRH_DMAREQENAB 0x10 +#define USB_INCSRH_FRCDATATOG 0x08 +#define USB_INCSRH_DMAREQMODE 0x04 +#define USB_INCSR_CDT 0x40 +#define USB_INCSR_SENTSTALL 0x20 +#define USB_INCSR_SENDSTALL 0x10 +#define USB_INCSR_FF 0x08 +#define USB_INCSR_UNDERRUN 0x04 +#define USB_INCSR_FFNOTEMPT 0x02 +#define USB_INCSR_INPKTRDY 0x01 +#define USB_OUTCSRH_AUTOCLR 0x80 +#define USB_OUTCSRH_ISO 0x40 +#define USB_OUTCSRH_DMAREQENAB 0x20 +#define USB_OUTCSRH_DNYT 0x10 +#define USB_OUTCSRH_DMAREQMODE 0x08 +#define USB_OUTCSR_CDT 0x80 +#define USB_OUTCSR_SENTSTALL 0x40 +#define USB_OUTCSR_SENDSTALL 0x20 +#define USB_OUTCSR_FF 0x10 +#define USB_OUTCSR_DATAERR 0x08 +#define USB_OUTCSR_OVERRUN 0x04 +#define USB_OUTCSR_FFFULL 0x02 +#define USB_OUTCSR_OUTPKTRDY 0x01 + +/* Testmode register bits */ +#define USB_TEST_SE0NAK 0x01 +#define USB_TEST_J 0x02 +#define USB_TEST_K 0x04 +#define USB_TEST_PACKET 0x08 +#define USB_TEST_FORCE_HS 0x10 +#define USB_TEST_FORCE_FS 0x20 +#define USB_TEST_ALL ( USB_TEST_SE0NAK | USB_TEST_J \ + | USB_TEST_K | USB_TEST_PACKET \ + | USB_TEST_FORCE_HS | USB_TEST_FORCE_FS) + +/* DMA control bits */ +#define USB_CNTL_ENA 0x01 +#define USB_CNTL_DIR_IN 0x02 +#define USB_CNTL_MODE_1 0x04 +#define USB_CNTL_INTR_EN 0x08 +#define USB_CNTL_EP(n) ((n) << 4) +#define USB_CNTL_BURST_0 (0 << 9) +#define USB_CNTL_BURST_4 (1 << 9) +#define USB_CNTL_BURST_8 (2 << 9) +#define USB_CNTL_BURST_16 (3 << 9) + +/* DMA interrupt bits */ +#define USB_INTR_DMA_BULKIN 1 +#define USB_INTR_DMA_BULKOUT 2 + +#define REG_USB_FADDR REG8(USB_FADDR) +#define REG_USB_POWER REG8(USB_POWER) +#define REG_USB_INTRIN REG16(USB_INTRIN) +#define REG_USB_INTROUT REG16(USB_INTROUT) +#define REG_USB_INTRINE REG16(USB_INTRINE) +#define REG_USB_INTROUTE REG16(USB_INTROUTE) +#define REG_USB_INTRUSB REG8(USB_INTRUSB) +#define REG_USB_INTRUSBE REG8(USB_INTRUSBE) +#define REG_USB_FRAME REG16(USB_FRAME) +#define REG_USB_INDEX REG8(USB_INDEX) +#define REG_USB_TESTMODE REG8(USB_TESTMODE) + +#define REG_USB_CSR0 REG16(USB_CSR0) +#define REG_USB_COUNT0 REG8(USB_COUNT0) + +#define REG_USB_INMAXP REG16(USB_INMAXP) +#define REG_USB_INCSR REG16(USB_INCSR) +#define REG_USB_INCSRH REG8(USB_INCSRH) +#define REG_USB_OUTMAXP REG16(USB_OUTMAXP) +#define REG_USB_OUTCSR REG16(USB_OUTCSR) +#define REG_USB_OUTCSRH REG8(USB_OUTCSRH) +#define REG_USB_OUTCOUNT REG16(USB_OUTCOUNT) + +#define REG_USB_FIFO_EP(n) REG32(USB_FIFO_EP(n)) + +#define REG_USB_INTR REG8(USB_INTR) +#define REG_USB_CNTL(n) REG16(USB_CNTL(n)) +#define REG_USB_ADDR(n) REG32(USB_ADDR(n)) +#define REG_USB_COUNT(n) REG32(USB_COUNT(n)) + +#define REG_USB_EPINFO REG8(USB_EPINFO) +#define REG_USB_RAMINFO REG8(USB_RAMINFO) + +/* + * One wire bus interface(OWI) address definition + */ +#define OWI_BASE 0xb0072000 + +/* + * OWI registers offset address definition + */ +#define OWI_OWICFG_OFFSET (0x00) /* rw, 8, 0x00 */ +#define OWI_OWICTL_OFFSET (0x04) /* rw, 8, 0x00 */ +#define OWI_OWISTS_OFFSET (0x08) /* rw, 8, 0x00 */ +#define OWI_OWIDAT_OFFSET (0x0c) /* rw, 8, 0x00 */ +#define OWI_OWIDIV_OFFSET (0x10) /* rw, 8, 0x00 */ + +/* + * OWI registers address definition + */ +#define OWI_OWICFG (OWI_BASE + OWI_OWICFG_OFFSET) +#define OWI_OWICTL (OWI_BASE + OWI_OWICTL_OFFSET) +#define OWI_OWISTS (OWI_BASE + OWI_OWISTS_OFFSET) +#define OWI_OWIDAT (OWI_BASE + OWI_OWIDAT_OFFSET) +#define OWI_OWIDIV (OWI_BASE + OWI_OWIDIV_OFFSET) + +/* + * OWI registers common define + */ + +/* OWI configure register(OWICFG) */ +#define OWICFG_MODE BIT7 +#define OWICFG_RDDATA BIT6 +#define OWICFG_WRDATA BIT5 +#define OWICFG_RDST BIT4 +#define OWICFG_WR1RD BIT3 +#define OWICFG_WR0 BIT2 +#define OWICFG_RST BIT1 +#define OWICFG_ENA BIT0 + +/* OWI control register(OWICTL) */ +#define OWICTL_EBYTE BIT2 +#define OWICTL_EBIT BIT1 +#define OWICTL_ERST BIT0 + +/* OWI status register(OWISTS) */ +#define OWISTS_PST BIT7 +#define OWISTS_BYTE_RDY BIT2 +#define OWISTS_BIT_RDY BIT1 +#define OWISTS_PST_RDY BIT0 + +/* OWI clock divide register(OWIDIV) */ +#define OWIDIV_CLKDIV_LSB 0 +#define OWIDIV_CLKDIV_MASK BITS_H2L(5, OWIDIV_CLKDIV_LSB) + +#ifndef __MIPS_ASSEMBLER + +/* Basic ops */ +#define REG_OWI_OWICFG REG8(OWI_OWICFG) +#define REG_OWI_OWICTL REG8(OWI_OWICTL) +#define REG_OWI_OWISTS REG8(OWI_OWISTS) +#define REG_OWI_OWIDAT REG8(OWI_OWIDAT) +#define REG_OWI_OWIDIV REG8(OWI_OWIDIV) + +#endif /* __MIPS_ASSEMBLER */ + +/* + * Pulse-code modulation module(PCM) address definition + */ +#define PCM_BASE 0xb0071000 + +/* + * pcm number, jz4760x has only PCM0 + */ + +#define PCM0 0 +#define PCM1 1 + +/* PCM groups offset */ +#define PCM_GOS 0x3000 + +/* + * PCM registers offset address definition + */ +#define PCM_PCTL_OFFSET (0x00) /* rw, 32, 0x00000000 */ +#define PCM_PCFG_OFFSET (0x04) /* rw, 32, 0x00000110 */ +#define PCM_PDP_OFFSET (0x08) /* rw, 32, 0x00000000 */ +#define PCM_PINTC_OFFSET (0x0c) /* rw, 32, 0x00000000 */ +#define PCM_PINTS_OFFSET (0x10) /* rw, 32, 0x00000100 */ +#define PCM_PDIV_OFFSET (0x14) /* rw, 32, 0x00000001 */ + +/* + * PCM registers address definition + */ +#define PCM_PCTL(n) (PCM_BASE + (n) * PCM_GOS + PCM_PCTL_OFFSET) +#define PCM_PCFG(n) (PCM_BASE + (n) * PCM_GOS + PCM_PCFG_OFFSET) +#define PCM_PDP(n) (PCM_BASE + (n) * PCM_GOS + PCM_PDP_OFFSET) +#define PCM_PINTC(n) (PCM_BASE + (n) * PCM_GOS + PCM_PINTC_OFFSET) +#define PCM_PINTS(n) (PCM_BASE + (n) * PCM_GOS + PCM_PINTS_OFFSET) +#define PCM_PDIV(n) (PCM_BASE + (n) * PCM_GOS + PCM_PDIV_OFFSET) + +/* + * CPM registers common define + */ + +/* PCM controller control register (PCTL) */ +#define PCTL_ERDMA BIT9 +#define PCTL_ETDMA BIT8 +#define PCTL_LSMP BIT7 +#define PCTL_ERPL BIT6 +#define PCTL_EREC BIT5 +#define PCTL_FLUSH BIT4 +#define PCTL_RST BIT3 +#define PCTL_CLKEN BIT1 +#define PCTL_PCMEN BIT0 + +/* PCM controller configure register (PCFG) */ +#define PCFG_ISS_16BIT BIT12 +#define PCFG_OSS_16BIT BIT11 +#define PCFG_IMSBPOS BIT10 +#define PCFG_OMSBPOS BIT9 +#define PCFG_MODE_SLAVE BIT0 + +#define PCFG_SLOT_LSB 13 +#define PCFG_SLOT_MASK BITS_H2L(14, PCFG_SLOT_LSB) +#define PCFG_SLOT(val) ((val) << PCFG_SLOT_LSB) + +#define PCFG_RFTH_LSB 5 +#define PCFG_RFTH_MASK BITS_H2L(8, PCFG_RFTH_LSB) + +#define PCFG_TFTH_LSB 1 +#define PCFG_TFTH_MASK BITS_H2L(4, PCFG_TFTH_LSB) + +/* PCM controller interrupt control register(PINTC) */ +#define PINTC_ETFS BIT3 +#define PINTC_ETUR BIT2 +#define PINTC_ERFS BIT1 +#define PINTC_EROR BIT0 + +/* PCM controller interrupt status register(PINTS) */ +#define PINTS_RSTS BIT14 +#define PINTS_TFS BIT8 +#define PINTS_TUR BIT7 +#define PINTS_RFS BIT1 +#define PINTS_ROR BIT0 + +#define PINTS_TFL_LSB 9 +#define PINTS_TFL_MASK BITS_H2L(13, PINTS_TFL_LSB) + +#define PINTS_RFL_LSB 2 +#define PINTS_RFL_MASK BITS_H2L(6, PINTS_RFL_LSB) + +/* PCM controller clock division register(PDIV) */ +#define PDIV_SYNL_LSB 11 +#define PDIV_SYNL_MASK BITS_H2L(16, PDIV_SYNL_LSB) + +#define PDIV_SYNDIV_LSB 6 +#define PDIV_SYNDIV_MASK BITS_H2L(10, PDIV_SYNDIV_LSB) + +#define PDIV_CLKDIV_LSB 0 +#define PDIV_CLKDIV_MASK BITS_H2L(5, PDIV_CLKDIV_LSB) + +#ifndef __MIPS_ASSEMBLER + +#define REG_PCM_PCTL(n) REG32(PCM_PCTL(n)) +#define REG_PCM_PCFG(n) REG32(PCM_PCFG(n)) +#define REG_PCM_PDP(n) REG32(PCM_PDP(n)) +#define REG_PCM_PINTC(n) REG32(PCM_PINTC(n)) +#define REG_PCM_PINTS(n) REG32(PCM_PINTS(n)) +#define REG_PCM_PDIV(n) REG32(PCM_PDIV(n)) + +/* + * PCM_DIN, PCM_DOUT, PCM_CLK, PCM_SYN + */ +#define __gpio_as_pcm(n) \ +do { \ + switch(n) { \ + case PCM0: __gpio_as_pcm0();break; \ + case PCM1: __gpio_as_pcm1();break; \ + } \ + \ +} while (0) + +#define __pcm_enable(n) (REG_PCM_PCTL(n) |= PCTL_PCMEN) +#define __pcm_disable(n) (REG_PCM_PCTL(n) &= ~PCTL_PCMEN) + +#define __pcm_clk_enable(n) (REG_PCM_PCTL(n) |= PCTL_CLKEN) +#define __pcm_clk_disable(n) (REG_PCM_PCTL(n) &= ~PCTL_CLKEN) + +#define __pcm_reset(n) (REG_PCM_PCTL(n) |= PCTL_RST) +#define __pcm_flush_fifo(n) (REG_PCM_PCTL(n) |= PCTL_FLUSH) + +#define __pcm_enable_record(n) (REG_PCM_PCTL(n) |= PCTL_EREC) +#define __pcm_disable_record(n) (REG_PCM_PCTL(n) &= ~PCTL_EREC) +#define __pcm_enable_playback(n) (REG_PCM_PCTL(n) |= PCTL_ERPL) +#define __pcm_disable_playback(n) (REG_PCM_PCTL(n) &= ~PCTL_ERPL) + +#define __pcm_enable_rxfifo(n) __pcm_enable_record(n) +#define __pcm_disable_rxfifo(n) __pcm_disable_record(n) +#define __pcm_enable_txfifo(n) __pcm_enable_playback(n) +#define __pcm_disable_txfifo(n) __pcm_disable_playback(n) + +#define __pcm_last_sample(n) (REG_PCM_PCTL(n) |= PCTL_LSMP) +#define __pcm_zero_sample(n) (REG_PCM_PCTL(n) &= ~PCTL_LSMP) + +#define __pcm_enable_transmit_dma(n) (REG_PCM_PCTL(n) |= PCTL_ETDMA) +#define __pcm_disable_transmit_dma(n) (REG_PCM_PCTL(n) &= ~PCTL_ETDMA) +#define __pcm_enable_receive_dma(n) (REG_PCM_PCTL(n) |= PCTL_ERDMA) +#define __pcm_disable_receive_dma(n) (REG_PCM_PCTL(n) &= ~PCTL_ERDMA) + +#define __pcm_as_master(n) (REG_PCM_PCFG(n) &= ~PCFG_MODE_SLAVE) +#define __pcm_as_slave(n) (REG_PCM_PCFG(n) |= PCFG_MODE_SLAVE) + +#define __pcm_set_transmit_trigger(n, val) \ +do { \ + REG_PCM_PCFG(n) &= ~PCFG_TFTH_MASK; \ + REG_PCM_PCFG(n) |= ((val) << PCFG_TFTH_LSB); \ + \ +} while(0) + +#define __pcm_set_receive_trigger(n, val) \ +do { \ + REG_PCM_PCFG(n) &= ~PCFG_RFTH_MASK; \ + REG_PCM_PCFG(n) |= ((val) << PCFG_RFTH_LSB); \ + \ +} while(0) + +#define __pcm_omsb_same_sync(n) (REG_PCM_PCFG(n) &= ~PCFG_OMSBPOS) +#define __pcm_omsb_next_sync(n) (REG_PCM_PCFG(n) |= PCFG_OMSBPOS) + +#define __pcm_imsb_same_sync(n) (REG_PCM_PCFG(n) &= ~PCFG_IMSBPOS) +#define __pcm_imsb_next_sync(n) (REG_PCM_PCFG(n) |= PCFG_IMSBPOS) + +#define __pcm_set_iss(n, val) \ +do { \ + if ((val) == 16) \ + REG_PCM_PCFG(n) |= PCFG_ISS_16BIT; \ + else \ + REG_PCM_PCFG(n) &= ~PCFG_ISS_16BIT; \ + \ +} while (0) + +#define __pcm_set_oss(n, val) \ +do { \ + if ((val) == 16) \ + REG_PCM_PCFG(n) |= PCFG_OSS_16BIT; \ + else \ + REG_PCM_PCFG(n) &= ~PCFG_OSS_16BIT; \ + \ +} while (0) \ + +#define __pcm_set_valid_slot(n, val) \ + (REG_PCM_PCFG(n) = (REG_PCM_PCFG(n) & ~PCFG_SLOT_MASK) | PCFG_SLOT(val)) + +#define __pcm_write_data(n, val) (REG_PCM_PDP(n) = (val)) +#define __pcm_read_data(n) (REG_PCM_PDP(n)) + +#define __pcm_enable_tfs_intr(n) (REG_PCM_PINTC(n) |= PINTC_ETFS) +#define __pcm_disable_tfs_intr(n) (REG_PCM_PINTC(n) &= ~PINTC_ETFS) + +#define __pcm_enable_tur_intr(n) (REG_PCM_PINTC(n) |= PINTC_ETUR) +#define __pcm_disable_tur_intr(n) (REG_PCM_PINTC(n) &= ~PINTC_ETUR) + +#define __pcm_enable_rfs_intr(n) (REG_PCM_PINTC(n) |= PINTC_ERFS) +#define __pcm_disable_rfs_intr(n) (REG_PCM_PINTC(n) &= ~PINTC_ERFS) + +#define __pcm_enable_ror_intr(n) (REG_PCM_PINTC(n) |= PINTC_EROR) +#define __pcm_disable_ror_intr(n) (REG_PCM_PINTC(n) &= ~PINTC_EROR) + +#define __pcm_ints_valid_tx(n) (((REG_PCM_PINTS(n) & PINTS_TFL_MASK) >> PINTS_TFL_LSB)) +#define __pcm_ints_valid_rx(n) (((REG_PCM_PINTS(n) & PINTS_RFL_MASK) >> PINTS_RFL_LSB)) + +#define __pcm_set_clk_div(n, val) \ + (REG_PCM_PDIV(n) = (REG_PCM_PDIV(n) & ~PDIV_CLKDIV_MASK) | ((val) << PDIV_CLKDIV_LSB)) + +#define __pcm_set_clk_rate(n, sysclk, pcmclk) \ + __pcm_set_clk_div((n), ((sysclk) / (pcmclk) - 1)) + +#define __pcm_set_sync_div(n, val) \ + (REG_PCM_PDIV(n) = (REG_PCM_PDIV(n) & ~PDIV_SYNDIV_MASK) | ((val) << PDIV_SYNDIV_LSB)) + +#define __pcm_set_sync_rate(n, pcmclk, sync) \ + __pcm_set_sync_div((n), ((pcmclk) / (8 * (sync)) - 1)) + +#define __pcm_set_sync_len(n, val) \ + (REG_PCM_PDIV(n) = (REG_PCM_PDIV(n) & ~PDIV_SYNL_MASK) | ((val) << PDIV_SYNL_LSB)) + +#endif /* __MIPS_ASSEMBLER */ + +/* + * Real time clock module(RTC) address definition + */ +#define RTC_BASE 0xb0003000 + +/* + * RTC registers offset address definition + */ +#define RTC_RTCCR_OFFSET (0x00) /* rw, 32, 0x00000081 */ +#define RTC_RTCSR_OFFSET (0x04) /* rw, 32, 0x???????? */ +#define RTC_RTCSAR_OFFSET (0x08) /* rw, 32, 0x???????? */ +#define RTC_RTCGR_OFFSET (0x0c) /* rw, 32, 0x0??????? */ + +#define RTC_HCR_OFFSET (0x20) /* rw, 32, 0x00000000 */ +#define RTC_HWFCR_OFFSET (0x24) /* rw, 32, 0x0000???0 */ +#define RTC_HRCR_OFFSET (0x28) /* rw, 32, 0x00000??0 */ +#define RTC_HWCR_OFFSET (0x2c) /* rw, 32, 0x00000008 */ +#define RTC_HWRSR_OFFSET (0x30) /* rw, 32, 0x00000000 */ +#define RTC_HSPR_OFFSET (0x34) /* rw, 32, 0x???????? */ +#define RTC_WENR_OFFSET (0x3c) /* rw, 32, 0x00000000 */ + +/* + * RTC registers address definition + */ +#define RTC_RTCCR (RTC_BASE + RTC_RTCCR_OFFSET) +#define RTC_RTCSR (RTC_BASE + RTC_RTCSR_OFFSET) +#define RTC_RTCSAR (RTC_BASE + RTC_RTCSAR_OFFSET) +#define RTC_RTCGR (RTC_BASE + RTC_RTCGR_OFFSET) + +#define RTC_HCR (RTC_BASE + RTC_HCR_OFFSET) +#define RTC_HWFCR (RTC_BASE + RTC_HWFCR_OFFSET) +#define RTC_HRCR (RTC_BASE + RTC_HRCR_OFFSET) +#define RTC_HWCR (RTC_BASE + RTC_HWCR_OFFSET) +#define RTC_HWRSR (RTC_BASE + RTC_HWRSR_OFFSET) +#define RTC_HSPR (RTC_BASE + RTC_HSPR_OFFSET) +#define RTC_WENR (RTC_BASE + RTC_WENR_OFFSET) + +/* + * RTC registers common define + */ + +/* RTC control register(RTCCR) */ +#define RTCCR_WRDY BIT7 +#define RTCCR_1HZ BIT6 +#define RTCCR_1HZIE BIT5 +#define RTCCR_AF BIT4 +#define RTCCR_AIE BIT3 +#define RTCCR_AE BIT2 +#define RTCCR_SELEXC BIT1 +#define RTCCR_RTCE BIT0 + +/* RTC regulator register(RTCGR) */ +#define RTCGR_LOCK BIT31 + +#define RTCGR_ADJC_LSB 16 +#define RTCGR_ADJC_MASK BITS_H2L(25, RTCGR_ADJC_LSB) + +#define RTCGR_NC1HZ_LSB 0 +#define RTCGR_NC1HZ_MASK BITS_H2L(15, RTCGR_NC1HZ_LSB) + +/* Hibernate control register(HCR) */ +#define HCR_PD BIT0 + +/* Hibernate wakeup filter counter register(HWFCR) */ +#define HWFCR_LSB 5 +#define HWFCR_MASK BITS_H2L(15, HWFCR_LSB) +#define HWFCR_WAIT_TIME(ms) (((ms) << HWFCR_LSB) > HWFCR_MASK ? HWFCR_MASK : ((ms) << HWFCR_LSB)) + +/* Hibernate reset counter register(HRCR) */ +#define HRCR_LSB 5 +#define HRCR_MASK BITS_H2L(11, HRCR_LSB) +#define HRCR_WAIT_TIME(ms) (((ms) << HRCR_LSB) > HRCR_MASK ? HRCR_MASK : ((ms) << HRCR_LSB)) + +/* Hibernate wakeup control register(HWCR) */ +#define HWCR_EPDET BIT3 +#define HWCR_WKUPVL BIT2 +#define HWCR_EALM BIT0 + +/* Hibernate wakeup status register(HWRSR) */ +#define HWRSR_APD BIT8 +#define HWRSR_HR BIT5 +#define HWRSR_PPR BIT4 +#define HWRSR_PIN BIT1 +#define HWRSR_ALM BIT0 + +/* write enable pattern register(WENR) */ +#define WENR_WEN BIT31 + +#define WENR_WENPAT_LSB 0 +#define WENR_WENPAT_MASK BITS_H2L(15, WENR_WENPAT_LSB) +#define WENR_WENPAT_WRITABLE (0xa55a) + +/* Hibernate scratch pattern register(HSPR) */ +#define HSPR_RTCV 0x52544356 /* The value is 'RTCV', means rtc is valid */ + +#ifndef __MIPS_ASSEMBLER + +/* Waiting for the RTC register writing finish */ +#define __wait_write_ready() \ +do { \ + int timeout = 0x1000; \ + while (!(rtc_read_reg(RTC_RTCCR) & RTCCR_WRDY) && timeout--); \ +}while(0); + +/* Waiting for the RTC register writable */ +#define __wait_writable() \ +do { \ + int timeout = 0x1000; \ + __wait_write_ready(); \ + OUTREG32(RTC_WENR, WENR_WENPAT_WRITABLE); \ + __wait_write_ready(); \ + while (!(rtc_read_reg(RTC_WENR) & WENR_WEN) && timeout--); \ +}while(0); + +/* Basic RTC ops */ +#define rtc_read_reg(reg) \ +({ \ + unsigned int data, timeout = 0x10000; \ + do { \ + data = INREG32(reg); \ + } while (INREG32(reg) != data && timeout--); \ + data; \ +}) + +#define rtc_write_reg(reg, data) \ +do { \ + __wait_writable(); \ + OUTREG32(reg, data); \ + __wait_write_ready(); \ +}while(0); + +#define rtc_set_reg(reg, data) rtc_write_reg(reg, rtc_read_reg(reg) | (data)) +#define rtc_clr_reg(reg, data) rtc_write_reg(reg, rtc_read_reg(reg) & ~(data)) + +#endif /* __MIPS_ASSEMBLER */ + +/* + * SAR A/D Controller(SADC) address definition + */ +#define SADC_BASE 0xb0070000 + +/* + * SADC registers offset definition + */ +#define SADC_ADENA_OFFSET (0x00) /* rw, 8, 0x00 */ +#define SADC_ADCFG_OFFSET (0x04) /* rw, 32, 0x0002000c */ +#define SADC_ADCTRL_OFFSET (0x08) /* rw, 8, 0x3f */ +#define SADC_ADSTATE_OFFSET (0x0c) /* rw, 8, 0x00 */ +#define SADC_ADSAME_OFFSET (0x10) /* rw, 16, 0x0000 */ +#define SADC_ADWAIT_OFFSET (0x14) /* rw, 16, 0x0000 */ +#define SADC_ADTCH_OFFSET (0x18) /* rw, 32, 0x00000000 */ +#define SADC_ADVDAT_OFFSET (0x1c) /* rw, 16, 0x0000 */ +#define SADC_ADADAT_OFFSET (0x20) /* rw, 16, 0x0000 */ +#define SADC_ADFLT_OFFSET (0x24) /* rw, 16, 0x0000 */ +#define SADC_ADCLK_OFFSET (0x28) /* rw, 32, 0x00000000 */ + +/* + * SADC registers address definition + */ +#define SADC_ADENA (SADC_BASE + SADC_ADENA_OFFSET) /* ADC Enable Register */ +#define SADC_ADCFG (SADC_BASE + SADC_ADCFG_OFFSET) /* ADC Configure Register */ +#define SADC_ADCTRL (SADC_BASE + SADC_ADCTRL_OFFSET) /* ADC Control Register */ +#define SADC_ADSTATE (SADC_BASE + SADC_ADSTATE_OFFSET)/* ADC Status Register*/ +#define SADC_ADSAME (SADC_BASE + SADC_ADSAME_OFFSET) /* ADC Same Point Time Register */ +#define SADC_ADWAIT (SADC_BASE + SADC_ADWAIT_OFFSET) /* ADC Wait Time Register */ +#define SADC_ADTCH (SADC_BASE + SADC_ADTCH_OFFSET) /* ADC Touch Screen Data Register */ +#define SADC_ADVDAT (SADC_BASE + SADC_ADVDAT_OFFSET) /* ADC VBAT Data Register */ +#define SADC_ADADAT (SADC_BASE + SADC_ADADAT_OFFSET) /* ADC AUX Data Register */ +#define SADC_ADFLT (SADC_BASE + SADC_ADFLT_OFFSET) /* ADC Filter Register */ +#define SADC_ADCLK (SADC_BASE + SADC_ADCLK_OFFSET) /* ADC Clock Divide Register */ + +/* + * SADC registers common define + */ + +/* ADC Enable Register (ADENA) */ +#define ADENA_POWER BIT7 +#define ADENA_SLP_MD BIT6 +#define ADENA_PENDEN BIT3 +#define ADENA_TCHEN BIT2 +#define ADENA_VBATEN BIT1 +#define ADENA_AUXEN BIT0 + +/* ADC Configure Register (ADCFG) */ +#define ADCFG_SPZZ BIT31 +#define ADCFG_VBAT_SEL BIT30 +#define ADCFG_DMA_EN BIT15 + +#define ADCFG_XYZ_LSB 13 +#define ADCFG_XYZ_MASK BITS_H2L(14, ADCFG_XYZ_LSB) + #define ADCFG_XYZ_XYS (0x0 << ADCFG_XYZ_LSB) + #define ADCFG_XYZ_XYD (0x1 << ADCFG_XYZ_LSB) + #define ADCFG_XYZ_XYZ1Z2 (0x2 << ADCFG_XYZ_LSB) + +#define ADCFG_SNUM_LSB 10 +#define ADCFG_SNUM_MASK BITS_H2L(12, ADCFG_SNUM_LSB) + #define ADCFG_SNUM(n) (((n) <= 6 ? ((n)-1) : ((n)-2)) << ADCFG_SNUM_LSB) + +#define ADCFG_CMD_LSB 0 +#define ADCFG_CMD_MASK BITS_H2L(1, ADCFG_CMD_LSB) + #define ADCFG_CMD_AUX(n) ((n) << ADCFG_CMD_LSB) + +/* ADC Control Register (ADCCTRL) */ +#define ADCTRL_SLPENDM BIT5 +#define ADCTRL_PENDM BIT4 +#define ADCTRL_PENUM BIT3 +#define ADCTRL_DTCHM BIT2 +#define ADCTRL_VRDYM BIT1 +#define ADCTRL_ARDYM BIT0 +#define ADCTRL_MASK_ALL (ADCTRL_SLPENDM | ADCTRL_PENDM | ADCTRL_PENUM \ + | ADCTRL_DTCHM | ADCTRL_VRDYM | ADCTRL_ARDYM) + +/* ADC Status Register (ADSTATE) */ +#define ADSTATE_SLP_RDY BIT7 +#define ADSTATE_SLPEND BIT5 +#define ADSTATE_PEND BIT4 +#define ADSTATE_PENU BIT3 +#define ADSTATE_DTCH BIT2 +#define ADSTATE_VRDY BIT1 +#define ADSTATE_ARDY BIT0 + +/* ADC Same Point Time Register (ADSAME) */ +#define ADSAME_SCNT_LSB 0 +#define ADSAME_SCNT_MASK BITS_H2L(15, ADSAME_SCNT_LSB) + +/* ADC Wait Pen Down Time Register (ADWAIT) */ +#define ADWAIT_WCNT_LSB 0 +#define ADWAIT_WCNT_MASK BITS_H2L(15, ADWAIT_WCNT_LSB) + +/* ADC Touch Screen Data Register (ADTCH) */ +#define ADTCH_TYPE1 BIT31 +#define ADTCH_TYPE0 BIT15 + +#define ADTCH_DATA1_LSB 16 +#define ADTCH_DATA1_MASK BITS_H2L(27, ADTCH_DATA1_LSB) + +#define ADTCH_DATA0_LSB 0 +#define ADTCH_DATA0_MASK BITS_H2L(11, ADTCH_DATA0_LSB) + +/* ADC VBAT Date Register (ADVDAT) */ +#define ADVDAT_VDATA_LSB 0 +#define ADVDAT_VDATA_MASK BITS_H2L(11, ADVDAT_VDATA_LSB) + +/* ADC AUX Data Register (ADADAT) */ +#define ADADAT_ADATA_LSB 0 +#define ADADAT_ADATA_MASK BITS_H2L(11, ADADAT_ADATA_LSB) + +/* ADC Clock Divide Register (ADCLK) */ +#define ADCLK_CLKDIV_MS_LSB 16 +#define ADCLK_CLKDIV_MS_MASK BITS_H2L(31, ADCLK_CLKDIV_MS_LSB) + +#define ADCLK_CLKDIV_US_LSB 8 +#define ADCLK_CLKDIV_US_MASK BITS_H2L(15, ADCLK_CLKDIV_US_LSB) + +#define ADCLK_CLKDIV_LSB 0 +#define ADCLK_CLKDIV_MASK BITS_H2L(7, ADCLK_CLKDIV_LSB) + +/* ADC Filter Register (ADFLT) */ +#define ADFLT_FLT_EN BIT15 + +#define ADFLT_FLT_D_LSB 0 +#define ADFLT_FLT_D_MASK BITS_H2L(11, ADFLT_FLT_D_LSB) + +#ifndef __MIPS_ASSEMBLER + +#define REG_SADC_ADENA REG8(SADC_ADENA) +#define REG_SADC_ADCFG REG32(SADC_ADCFG) +#define REG_SADC_ADCTRL REG8(SADC_ADCTRL) +#define REG_SADC_ADSTATE REG8(SADC_ADSTATE) +#define REG_SADC_ADSAME REG16(SADC_ADSAME) +#define REG_SADC_ADWAIT REG16(SADC_ADWAIT) +#define REG_SADC_ADTCH REG32(SADC_ADTCH) +#define REG_SADC_ADVDAT REG16(SADC_ADVDAT) +#define REG_SADC_ADADAT REG16(SADC_ADADAT) +#define REG_SADC_ADFLT REG16(SADC_ADFLT) +#define REG_SADC_ADCLK REG32(SADC_ADCLK) + +#endif /* __MIPS_ASSEMBLER */ + +#define SCC_BASE 0xB0040000 + +/************************************************************************* + * SCC + *************************************************************************/ +#define SCC_DR (SCC_BASE + 0x000) +#define SCC_FDR (SCC_BASE + 0x004) +#define SCC_CR (SCC_BASE + 0x008) +#define SCC_SR (SCC_BASE + 0x00C) +#define SCC_TFR (SCC_BASE + 0x010) +#define SCC_EGTR (SCC_BASE + 0x014) +#define SCC_ECR (SCC_BASE + 0x018) +#define SCC_RTOR (SCC_BASE + 0x01C) + +#define REG_SCC_DR REG8(SCC_DR) +#define REG_SCC_FDR REG8(SCC_FDR) +#define REG_SCC_CR REG32(SCC_CR) +#define REG_SCC_SR REG16(SCC_SR) +#define REG_SCC_TFR REG16(SCC_TFR) +#define REG_SCC_EGTR REG8(SCC_EGTR) +#define REG_SCC_ECR REG32(SCC_ECR) +#define REG_SCC_RTOR REG8(SCC_RTOR) + +/* SCC FIFO Data Count Register (SCC_FDR) */ + +#define SCC_FDR_EMPTY 0x00 +#define SCC_FDR_FULL 0x10 + +/* SCC Control Register (SCC_CR) */ + +#define SCC_CR_SCCE (1 << 31) +#define SCC_CR_TRS (1 << 30) +#define SCC_CR_T2R (1 << 29) +#define SCC_CR_FDIV_BIT 24 +#define SCC_CR_FDIV_MASK (0x3 << SCC_CR_FDIV_BIT) + #define SCC_CR_FDIV_1 (0 << SCC_CR_FDIV_BIT) /* SCC_CLK frequency is the same as device clock */ + #define SCC_CR_FDIV_2 (1 << SCC_CR_FDIV_BIT) /* SCC_CLK frequency is half of device clock */ +#define SCC_CR_FLUSH (1 << 23) +#define SCC_CR_TRIG_BIT 16 +#define SCC_CR_TRIG_MASK (0x3 << SCC_CR_TRIG_BIT) + #define SCC_CR_TRIG_1 (0 << SCC_CR_TRIG_BIT) /* Receive/Transmit-FIFO Trigger is 1 */ + #define SCC_CR_TRIG_4 (1 << SCC_CR_TRIG_BIT) /* Receive/Transmit-FIFO Trigger is 4 */ + #define SCC_CR_TRIG_8 (2 << SCC_CR_TRIG_BIT) /* Receive/Transmit-FIFO Trigger is 8 */ + #define SCC_CR_TRIG_14 (3 << SCC_CR_TRIG_BIT) /* Receive/Transmit-FIFO Trigger is 14 */ +#define SCC_CR_TP (1 << 15) +#define SCC_CR_CONV (1 << 14) +#define SCC_CR_TXIE (1 << 13) +#define SCC_CR_RXIE (1 << 12) +#define SCC_CR_TENDIE (1 << 11) +#define SCC_CR_RTOIE (1 << 10) +#define SCC_CR_ECIE (1 << 9) +#define SCC_CR_EPIE (1 << 8) +#define SCC_CR_RETIE (1 << 7) +#define SCC_CR_EOIE (1 << 6) +#define SCC_CR_TSEND (1 << 3) +#define SCC_CR_PX_BIT 1 +#define SCC_CR_PX_MASK (0x3 << SCC_CR_PX_BIT) + #define SCC_CR_PX_NOT_SUPPORT (0 << SCC_CR_PX_BIT) /* SCC does not support clock stop */ + #define SCC_CR_PX_STOP_LOW (1 << SCC_CR_PX_BIT) /* SCC_CLK stops at state low */ + #define SCC_CR_PX_STOP_HIGH (2 << SCC_CR_PX_BIT) /* SCC_CLK stops at state high */ +#define SCC_CR_CLKSTP (1 << 0) + +/* SCC Status Register (SCC_SR) */ + +#define SCC_SR_TRANS (1 << 15) +#define SCC_SR_ORER (1 << 12) +#define SCC_SR_RTO (1 << 11) +#define SCC_SR_PER (1 << 10) +#define SCC_SR_TFTG (1 << 9) +#define SCC_SR_RFTG (1 << 8) +#define SCC_SR_TEND (1 << 7) +#define SCC_SR_RETR_3 (1 << 4) +#define SCC_SR_ECNTO (1 << 0) + +#ifndef __MIPS_ASSEMBLER + +/*************************************************************************** + * SCC + ***************************************************************************/ + +#define __scc_enable() ( REG_SCC_CR |= SCC_CR_SCCE ) +#define __scc_disable() ( REG_SCC_CR &= ~SCC_CR_SCCE ) + +#define __scc_set_tx_mode() ( REG_SCC_CR |= SCC_CR_TRS ) +#define __scc_set_rx_mode() ( REG_SCC_CR &= ~SCC_CR_TRS ) + +#define __scc_enable_t2r() ( REG_SCC_CR |= SCC_CR_T2R ) +#define __scc_disable_t2r() ( REG_SCC_CR &= ~SCC_CR_T2R ) + +#define __scc_clk_as_devclk() \ +do { \ + REG_SCC_CR &= ~SCC_CR_FDIV_MASK; \ + REG_SCC_CR |= SCC_CR_FDIV_1; \ +} while (0) + +#define __scc_clk_as_half_devclk() \ +do { \ + REG_SCC_CR &= ~SCC_CR_FDIV_MASK; \ + REG_SCC_CR |= SCC_CR_FDIV_2; \ +} while (0) + +/* n=1,4,8,14 */ +#define __scc_set_fifo_trigger(n) \ +do { \ + REG_SCC_CR &= ~SCC_CR_TRIG_MASK; \ + REG_SCC_CR |= SCC_CR_TRIG_##n; \ +} while (0) + +#define __scc_set_protocol(p) \ +do { \ + if (p) \ + REG_SCC_CR |= SCC_CR_TP; \ + else \ + REG_SCC_CR &= ~SCC_CR_TP; \ +} while (0) + +#define __scc_flush_fifo() ( REG_SCC_CR |= SCC_CR_FLUSH ) + +#define __scc_set_invert_mode() ( REG_SCC_CR |= SCC_CR_CONV ) +#define __scc_set_direct_mode() ( REG_SCC_CR &= ~SCC_CR_CONV ) + +#define SCC_ERR_INTRS \ + ( SCC_CR_ECIE | SCC_CR_EPIE | SCC_CR_RETIE | SCC_CR_EOIE ) +#define SCC_ALL_INTRS \ + ( SCC_CR_TXIE | SCC_CR_RXIE | SCC_CR_TENDIE | SCC_CR_RTOIE | \ + SCC_CR_ECIE | SCC_CR_EPIE | SCC_CR_RETIE | SCC_CR_EOIE ) + +#define __scc_enable_err_intrs() ( REG_SCC_CR |= SCC_ERR_INTRS ) +#define __scc_disable_err_intrs() ( REG_SCC_CR &= ~SCC_ERR_INTRS ) + +#define SCC_ALL_ERRORS \ + ( SCC_SR_ORER | SCC_SR_RTO | SCC_SR_PER | SCC_SR_RETR_3 | SCC_SR_ECNTO) + +#define __scc_clear_errors() ( REG_SCC_SR &= ~SCC_ALL_ERRORS ) + +#define __scc_enable_all_intrs() ( REG_SCC_CR |= SCC_ALL_INTRS ) +#define __scc_disable_all_intrs() ( REG_SCC_CR &= ~SCC_ALL_INTRS ) + +#define __scc_enable_tx_intr() ( REG_SCC_CR |= SCC_CR_TXIE | SCC_CR_TENDIE ) +#define __scc_disable_tx_intr() ( REG_SCC_CR &= ~(SCC_CR_TXIE | SCC_CR_TENDIE) ) + +#define __scc_enable_rx_intr() ( REG_SCC_CR |= SCC_CR_RXIE) +#define __scc_disable_rx_intr() ( REG_SCC_CR &= ~SCC_CR_RXIE) + +#define __scc_set_tsend() ( REG_SCC_CR |= SCC_CR_TSEND ) +#define __scc_clear_tsend() ( REG_SCC_CR &= ~SCC_CR_TSEND ) + +#define __scc_set_clockstop() ( REG_SCC_CR |= SCC_CR_CLKSTP ) +#define __scc_clear_clockstop() ( REG_SCC_CR &= ~SCC_CR_CLKSTP ) + +#define __scc_clockstop_low() \ +do { \ + REG_SCC_CR &= ~SCC_CR_PX_MASK; \ + REG_SCC_CR |= SCC_CR_PX_STOP_LOW; \ +} while (0) + +#define __scc_clockstop_high() \ +do { \ + REG_SCC_CR &= ~SCC_CR_PX_MASK; \ + REG_SCC_CR |= SCC_CR_PX_STOP_HIGH; \ +} while (0) + +/* SCC status checking */ +#define __scc_check_transfer_status() ( REG_SCC_SR & SCC_SR_TRANS ) +#define __scc_check_rx_overrun_error() ( REG_SCC_SR & SCC_SR_ORER ) +#define __scc_check_rx_timeout() ( REG_SCC_SR & SCC_SR_RTO ) +#define __scc_check_parity_error() ( REG_SCC_SR & SCC_SR_PER ) +#define __scc_check_txfifo_trigger() ( REG_SCC_SR & SCC_SR_TFTG ) +#define __scc_check_rxfifo_trigger() ( REG_SCC_SR & SCC_SR_RFTG ) +#define __scc_check_tx_end() ( REG_SCC_SR & SCC_SR_TEND ) +#define __scc_check_retx_3() ( REG_SCC_SR & SCC_SR_RETR_3 ) +#define __scc_check_ecnt_overflow() ( REG_SCC_SR & SCC_SR_ECNTO ) + +#endif /* __MIPS_ASSEMBLER */ + +#define SSI0_BASE 0xB0043000 +#define SSI1_BASE 0xB0044000 +#define SSI2_BASE 0xB0045000 + +/************************************************************************* + * SSI (Synchronous Serial Interface) + *************************************************************************/ +/* n = 0, 1 (SSI0, SSI1) */ +#define SSI_DR(n) (SSI0_BASE + 0x000 + (n)*0x1000) +#define SSI_CR0(n) (SSI0_BASE + 0x004 + (n)*0x1000) +#define SSI_CR1(n) (SSI0_BASE + 0x008 + (n)*0x1000) +#define SSI_SR(n) (SSI0_BASE + 0x00C + (n)*0x1000) +#define SSI_ITR(n) (SSI0_BASE + 0x010 + (n)*0x1000) +#define SSI_ICR(n) (SSI0_BASE + 0x014 + (n)*0x1000) +#define SSI_GR(n) (SSI0_BASE + 0x018 + (n)*0x1000) + +#define REG_SSI_DR(n) REG32(SSI_DR(n)) +#define REG_SSI_CR0(n) REG16(SSI_CR0(n)) +#define REG_SSI_CR1(n) REG32(SSI_CR1(n)) +#define REG_SSI_SR(n) REG32(SSI_SR(n)) +#define REG_SSI_ITR(n) REG16(SSI_ITR(n)) +#define REG_SSI_ICR(n) REG8(SSI_ICR(n)) +#define REG_SSI_GR(n) REG16(SSI_GR(n)) + +/* SSI Data Register (SSI_DR) */ + +#define SSI_DR_GPC_BIT 0 +#define SSI_DR_GPC_MASK (0x1ff << SSI_DR_GPC_BIT) + +#define SSI_MAX_FIFO_ENTRIES 128 /* 128 txfifo and 128 rxfifo */ + +/* SSI Control Register 0 (SSI_CR0) */ + +#define SSI_CR0_SSIE (1 << 15) +#define SSI_CR0_TIE (1 << 14) +#define SSI_CR0_RIE (1 << 13) +#define SSI_CR0_TEIE (1 << 12) +#define SSI_CR0_REIE (1 << 11) +#define SSI_CR0_LOOP (1 << 10) +#define SSI_CR0_RFINE (1 << 9) +#define SSI_CR0_RFINC (1 << 8) +#define SSI_CR0_EACLRUN (1 << 7) /* hardware auto clear underrun when TxFifo no empty */ +#define SSI_CR0_FSEL (1 << 6) +#define SSI_CR0_TFLUSH (1 << 2) +#define SSI_CR0_RFLUSH (1 << 1) +#define SSI_CR0_DISREV (1 << 0) + +/* SSI Control Register 1 (SSI_CR1) */ + +#define SSI_CR1_FRMHL_BIT 30 +#define SSI_CR1_FRMHL_MASK (0x3 << SSI_CR1_FRMHL_BIT) + #define SSI_CR1_FRMHL_CELOW_CE2LOW (0 << SSI_CR1_FRMHL_BIT) /* SSI_CE_ is low valid and SSI_CE2_ is low valid */ + #define SSI_CR1_FRMHL_CEHIGH_CE2LOW (1 << SSI_CR1_FRMHL_BIT) /* SSI_CE_ is high valid and SSI_CE2_ is low valid */ + #define SSI_CR1_FRMHL_CELOW_CE2HIGH (2 << SSI_CR1_FRMHL_BIT) /* SSI_CE_ is low valid and SSI_CE2_ is high valid */ + #define SSI_CR1_FRMHL_CEHIGH_CE2HIGH (3 << SSI_CR1_FRMHL_BIT) /* SSI_CE_ is high valid and SSI_CE2_ is high valid */ +#define SSI_CR1_TFVCK_BIT 28 +#define SSI_CR1_TFVCK_MASK (0x3 << SSI_CR1_TFVCK_BIT) + #define SSI_CR1_TFVCK_0 (0 << SSI_CR1_TFVCK_BIT) + #define SSI_CR1_TFVCK_1 (1 << SSI_CR1_TFVCK_BIT) + #define SSI_CR1_TFVCK_2 (2 << SSI_CR1_TFVCK_BIT) + #define SSI_CR1_TFVCK_3 (3 << SSI_CR1_TFVCK_BIT) +#define SSI_CR1_TCKFI_BIT 26 +#define SSI_CR1_TCKFI_MASK (0x3 << SSI_CR1_TCKFI_BIT) + #define SSI_CR1_TCKFI_0 (0 << SSI_CR1_TCKFI_BIT) + #define SSI_CR1_TCKFI_1 (1 << SSI_CR1_TCKFI_BIT) + #define SSI_CR1_TCKFI_2 (2 << SSI_CR1_TCKFI_BIT) + #define SSI_CR1_TCKFI_3 (3 << SSI_CR1_TCKFI_BIT) +#define SSI_CR1_LFST (1 << 25) +#define SSI_CR1_ITFRM (1 << 24) +#define SSI_CR1_UNFIN (1 << 23) +#define SSI_CR1_MULTS (1 << 22) +#define SSI_CR1_FMAT_BIT 20 +#define SSI_CR1_FMAT_MASK (0x3 << SSI_CR1_FMAT_BIT) + #define SSI_CR1_FMAT_SPI (0 << SSI_CR1_FMAT_BIT) /* Motorola¡¯s SPI format */ + #define SSI_CR1_FMAT_SSP (1 << SSI_CR1_FMAT_BIT) /* TI's SSP format */ + #define SSI_CR1_FMAT_MW1 (2 << SSI_CR1_FMAT_BIT) /* National Microwire 1 format */ + #define SSI_CR1_FMAT_MW2 (3 << SSI_CR1_FMAT_BIT) /* National Microwire 2 format */ +#define SSI_CR1_TTRG_BIT 16 /* SSI1 TX trigger */ +#define SSI_CR1_TTRG_MASK (0xf << SSI_CR1_TTRG_BIT) +#define SSI_CR1_MCOM_BIT 12 +#define SSI_CR1_MCOM_MASK (0xf << SSI_CR1_MCOM_BIT) + #define SSI_CR1_MCOM_1BIT (0x0 << SSI_CR1_MCOM_BIT) /* 1-bit command selected */ + #define SSI_CR1_MCOM_2BIT (0x1 << SSI_CR1_MCOM_BIT) /* 2-bit command selected */ + #define SSI_CR1_MCOM_3BIT (0x2 << SSI_CR1_MCOM_BIT) /* 3-bit command selected */ + #define SSI_CR1_MCOM_4BIT (0x3 << SSI_CR1_MCOM_BIT) /* 4-bit command selected */ + #define SSI_CR1_MCOM_5BIT (0x4 << SSI_CR1_MCOM_BIT) /* 5-bit command selected */ + #define SSI_CR1_MCOM_6BIT (0x5 << SSI_CR1_MCOM_BIT) /* 6-bit command selected */ + #define SSI_CR1_MCOM_7BIT (0x6 << SSI_CR1_MCOM_BIT) /* 7-bit command selected */ + #define SSI_CR1_MCOM_8BIT (0x7 << SSI_CR1_MCOM_BIT) /* 8-bit command selected */ + #define SSI_CR1_MCOM_9BIT (0x8 << SSI_CR1_MCOM_BIT) /* 9-bit command selected */ + #define SSI_CR1_MCOM_10BIT (0x9 << SSI_CR1_MCOM_BIT) /* 10-bit command selected */ + #define SSI_CR1_MCOM_11BIT (0xA << SSI_CR1_MCOM_BIT) /* 11-bit command selected */ + #define SSI_CR1_MCOM_12BIT (0xB << SSI_CR1_MCOM_BIT) /* 12-bit command selected */ + #define SSI_CR1_MCOM_13BIT (0xC << SSI_CR1_MCOM_BIT) /* 13-bit command selected */ + #define SSI_CR1_MCOM_14BIT (0xD << SSI_CR1_MCOM_BIT) /* 14-bit command selected */ + #define SSI_CR1_MCOM_15BIT (0xE << SSI_CR1_MCOM_BIT) /* 15-bit command selected */ + #define SSI_CR1_MCOM_16BIT (0xF << SSI_CR1_MCOM_BIT) /* 16-bit command selected */ +#define SSI_CR1_RTRG_BIT 8 /* SSI RX trigger */ +#define SSI_CR1_RTRG_MASK (0xf << SSI_CR1_RTRG_BIT) +#define SSI_CR1_FLEN_BIT 4 +#define SSI_CR1_FLEN_MASK (0xf << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_2BIT (0x0 << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_3BIT (0x1 << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_4BIT (0x2 << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_5BIT (0x3 << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_6BIT (0x4 << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_7BIT (0x5 << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_8BIT (0x6 << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_9BIT (0x7 << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_10BIT (0x8 << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_11BIT (0x9 << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_12BIT (0xA << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_13BIT (0xB << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_14BIT (0xC << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_15BIT (0xD << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_16BIT (0xE << SSI_CR1_FLEN_BIT) + #define SSI_CR1_FLEN_17BIT (0xF << SSI_CR1_FLEN_BIT) +#define SSI_CR1_PHA (1 << 1) +#define SSI_CR1_POL (1 << 0) + +/* SSI Status Register (SSI_SR) */ + +#define SSI_SR_TFIFONUM_BIT 16 +#define SSI_SR_TFIFONUM_MASK (0xff << SSI_SR_TFIFONUM_BIT) +#define SSI_SR_RFIFONUM_BIT 8 +#define SSI_SR_RFIFONUM_MASK (0xff << SSI_SR_RFIFONUM_BIT) +#define SSI_SR_END (1 << 7) +#define SSI_SR_BUSY (1 << 6) +#define SSI_SR_TFF (1 << 5) +#define SSI_SR_RFE (1 << 4) +#define SSI_SR_TFHE (1 << 3) +#define SSI_SR_RFHF (1 << 2) +#define SSI_SR_UNDR (1 << 1) +#define SSI_SR_OVER (1 << 0) + +/* SSI Interval Time Control Register (SSI_ITR) */ + +#define SSI_ITR_CNTCLK (1 << 15) +#define SSI_ITR_IVLTM_BIT 0 +#define SSI_ITR_IVLTM_MASK (0x7fff << SSI_ITR_IVLTM_BIT) + +/* + * SSI Character-per-frame Control Register (SSI_ICR) + * SSI_ICR is ignored for SSI_ICR1.FMT != 00b +*/ + +#ifndef __MIPS_ASSEMBLER + +/*************************************************************************** + * SSI (Synchronous Serial Interface) + ***************************************************************************/ +/* n = 0, 1 (SSI0, SSI1) */ +#define __ssi_enable(n) ( REG_SSI_CR0(n) |= SSI_CR0_SSIE ) +#define __ssi_disable(n) ( REG_SSI_CR0(n) &= ~SSI_CR0_SSIE ) +#define __ssi_select_ce(n) ( REG_SSI_CR0(n) &= ~SSI_CR0_FSEL ) + +#define __ssi_normal_mode(n) ( REG_SSI_ITR(n) &= ~SSI_ITR_IVLTM_MASK ) + +#define __ssi_select_ce2(n) \ +do { \ + REG_SSI_CR0(n) |= SSI_CR0_FSEL; \ + REG_SSI_CR1(n) &= ~SSI_CR1_MULTS; \ +} while (0) + +#define __ssi_select_gpc(n) \ +do { \ + REG_SSI_CR0(n) &= ~SSI_CR0_FSEL; \ + REG_SSI_CR1(n) |= SSI_CR1_MULTS; \ +} while (0) + +#define __ssi_underrun_auto_clear(n) \ +do { \ + REG_SSI_CR0(n) |= SSI_CR0_EACLRUN; \ +} while (0) + +#define __ssi_underrun_clear_manually(n) \ +do { \ + REG_SSI_CR0(n) &= ~SSI_CR0_EACLRUN; \ +} while (0) + +#define __ssi_enable_tx_intr(n) \ + ( REG_SSI_CR0(n) |= SSI_CR0_TIE | SSI_CR0_TEIE ) + +#define __ssi_disable_tx_intr(n) \ + ( REG_SSI_CR0(n) &= ~(SSI_CR0_TIE | SSI_CR0_TEIE) ) + +#define __ssi_enable_rx_intr(n) \ + ( REG_SSI_CR0(n) |= SSI_CR0_RIE | SSI_CR0_REIE ) + +#define __ssi_disable_rx_intr(n) \ + ( REG_SSI_CR0(n) &= ~(SSI_CR0_RIE | SSI_CR0_REIE) ) + +#define __ssi_enable_txfifo_half_empty_intr(n) \ + ( REG_SSI_CR0(n) |= SSI_CR0_TIE ) +#define __ssi_disable_txfifo_half_empty_intr(n) \ + ( REG_SSI_CR0(n) &= ~SSI_CR0_TIE ) +#define __ssi_enable_tx_error_intr(n) \ + ( REG_SSI_CR0(n) |= SSI_CR0_TEIE ) +#define __ssi_disable_tx_error_intr(n) \ + ( REG_SSI_CR0(n) &= ~SSI_CR0_TEIE ) +#define __ssi_enable_rxfifo_half_full_intr(n) \ + ( REG_SSI_CR0(n) |= SSI_CR0_RIE ) +#define __ssi_disable_rxfifo_half_full_intr(n) \ + ( REG_SSI_CR0(n) &= ~SSI_CR0_RIE ) +#define __ssi_enable_rx_error_intr(n) \ + ( REG_SSI_CR0(n) |= SSI_CR0_REIE ) +#define __ssi_disable_rx_error_intr(n) \ + ( REG_SSI_CR0(n) &= ~SSI_CR0_REIE ) + +#define __ssi_enable_loopback(n) ( REG_SSI_CR0(n) |= SSI_CR0_LOOP ) +#define __ssi_disable_loopback(n) ( REG_SSI_CR0(n) &= ~SSI_CR0_LOOP ) + +#define __ssi_enable_receive(n) ( REG_SSI_CR0(n) &= ~SSI_CR0_DISREV ) +#define __ssi_disable_receive(n) ( REG_SSI_CR0(n) |= SSI_CR0_DISREV ) + +#define __ssi_finish_receive(n) \ + ( REG_SSI_CR0(n) |= (SSI_CR0_RFINE | SSI_CR0_RFINC) ) + +#define __ssi_disable_recvfinish(n) \ + ( REG_SSI_CR0(n) &= ~(SSI_CR0_RFINE | SSI_CR0_RFINC) ) + +#define __ssi_flush_txfifo(n) ( REG_SSI_CR0(n) |= SSI_CR0_TFLUSH ) +#define __ssi_flush_rxfifo(n) ( REG_SSI_CR0(n) |= SSI_CR0_RFLUSH ) + +#define __ssi_flush_fifo(n) \ + ( REG_SSI_CR0(n) |= SSI_CR0_TFLUSH | SSI_CR0_RFLUSH ) + +#define __ssi_finish_transmit(n) ( REG_SSI_CR1(n) &= ~SSI_CR1_UNFIN ) +#define __ssi_wait_transmit(n) ( REG_SSI_CR1(n) |= SSI_CR1_UNFIN ) +#define __ssi_use_busy_wait_mode(n) __ssi_wait_transmit(n) +#define __ssi_unset_busy_wait_mode(n) __ssi_finish_transmit(n) + +#define __ssi_spi_format(n) \ + do { \ + REG_SSI_CR1(n) &= ~SSI_CR1_FMAT_MASK; \ + REG_SSI_CR1(n) |= SSI_CR1_FMAT_SPI; \ + REG_SSI_CR1(n) &= ~(SSI_CR1_TFVCK_MASK|SSI_CR1_TCKFI_MASK); \ + REG_SSI_CR1(n) |= (SSI_CR1_TFVCK_1 | SSI_CR1_TCKFI_1); \ + } while (0) + +/* TI's SSP format, must clear SSI_CR1.UNFIN */ +#define __ssi_ssp_format(n) \ + do { \ + REG_SSI_CR1(n) &= ~(SSI_CR1_FMAT_MASK | SSI_CR1_UNFIN); \ + REG_SSI_CR1(n) |= SSI_CR1_FMAT_SSP; \ + } while (0) + +/* National's Microwire format, must clear SSI_CR0.RFINE, and set max delay */ +#define __ssi_microwire_format(n) \ + do { \ + REG_SSI_CR1(n) &= ~SSI_CR1_FMAT_MASK; \ + REG_SSI_CR1(n) |= SSI_CR1_FMAT_MW1; \ + REG_SSI_CR1(n) &= ~(SSI_CR1_TFVCK_MASK|SSI_CR1_TCKFI_MASK); \ + REG_SSI_CR1(n) |= (SSI_CR1_TFVCK_3 | SSI_CR1_TCKFI_3); \ + REG_SSI_CR0(n) &= ~SSI_CR0_RFINE; \ + } while (0) + +/* CE# level (FRMHL), CE# in interval time (ITFRM), + clock phase and polarity (PHA POL), + interval time (SSIITR), interval characters/frame (SSIICR) */ + +/* frmhl,endian,mcom,flen,pha,pol MASK */ +#define SSICR1_MISC_MASK \ + ( SSI_CR1_FRMHL_MASK | SSI_CR1_LFST | SSI_CR1_MCOM_MASK \ + | SSI_CR1_FLEN_MASK | SSI_CR1_PHA | SSI_CR1_POL ) + +#define __ssi_spi_set_misc(n,frmhl,endian,flen,mcom,pha,pol) \ + do { \ + REG_SSI_CR1(n) &= ~SSICR1_MISC_MASK; \ + REG_SSI_CR1(n) |= ((frmhl) << 30) | ((endian) << 25) | \ + (((mcom) - 1) << 12) | (((flen) - 2) << 4) | \ + ((pha) << 1) | (pol); \ + } while(0) + +/* Transfer with MSB or LSB first */ +#define __ssi_set_msb(n) ( REG_SSI_CR1(n) &= ~SSI_CR1_LFST ) +#define __ssi_set_lsb(n) ( REG_SSI_CR1(n) |= SSI_CR1_LFST ) + +#define __ssi_set_frame_length(n, m) \ + REG_SSI_CR1(n) = (REG_SSI_CR1(n) & ~SSI_CR1_FLEN_MASK) | (((m) - 2) << 4) + +/* m = 1 - 16 */ +#define __ssi_set_microwire_command_length(n,m) \ + ( REG_SSI_CR1(n) = ((REG_SSI_CR1(n) & ~SSI_CR1_MCOM_MASK) | SSI_CR1_MCOM_##m##BIT) ) + +/* Set the clock phase for SPI */ +#define __ssi_set_spi_clock_phase(n, m) \ + ( REG_SSI_CR1(n) = ((REG_SSI_CR1(n) & ~SSI_CR1_PHA) | (((m)&0x1)<< 1))) + +/* Set the clock polarity for SPI */ +#define __ssi_set_spi_clock_polarity(n, p) \ + ( REG_SSI_CR1(n) = ((REG_SSI_CR1(n) & ~SSI_CR1_POL) | ((p)&0x1)) ) + +/* SSI tx trigger, m = i x 8 */ +#define __ssi_set_tx_trigger(n, m) \ + do { \ + REG_SSI_CR1(n) &= ~SSI_CR1_TTRG_MASK; \ + REG_SSI_CR1(n) |= ((m)/8)<> SSI_SR_TFIFONUM_BIT ) + +#define __ssi_get_rxfifo_count(n) \ + ( (REG_SSI_SR(n) & SSI_SR_RFIFONUM_MASK) >> SSI_SR_RFIFONUM_BIT ) + +#define __ssi_transfer_end(n) ( REG_SSI_SR(n) & SSI_SR_END ) +#define __ssi_is_busy(n) ( REG_SSI_SR(n) & SSI_SR_BUSY ) + +#define __ssi_txfifo_full(n) ( REG_SSI_SR(n) & SSI_SR_TFF ) +#define __ssi_rxfifo_empty(n) ( REG_SSI_SR(n) & SSI_SR_RFE ) +#define __ssi_rxfifo_half_full(n) ( REG_SSI_SR(n) & SSI_SR_RFHF ) +#define __ssi_txfifo_half_empty(n) ( REG_SSI_SR(n) & SSI_SR_TFHE ) +#define __ssi_underrun(n) ( REG_SSI_SR(n) & SSI_SR_UNDR ) +#define __ssi_overrun(n) ( REG_SSI_SR(n) & SSI_SR_OVER ) +#define __ssi_clear_underrun(n) ( REG_SSI_SR(n) = ~SSI_SR_UNDR ) +#define __ssi_clear_overrun(n) ( REG_SSI_SR(n) = ~SSI_SR_OVER ) +#define __ssi_clear_errors(n) ( REG_SSI_SR(n) &= ~(SSI_SR_UNDR | SSI_SR_OVER) ) + +#define __ssi_set_clk(n, dev_clk, ssi_clk) \ + ( REG_SSI_GR(n) = (dev_clk) / (2*(ssi_clk)) - 1 ) + +#define __ssi_receive_data(n) REG_SSI_DR(n) +#define __ssi_transmit_data(n, v) (REG_SSI_DR(n) = (v)) + +#endif /* __MIPS_ASSEMBLER */ + +/* + * Timer and counter unit module(TCU) address definition + */ +#define TCU_BASE 0xb0002000 + +/* TCU group offset */ +#define TCU_GOS 0x10 + +/* TCU total channel number */ +#define TCU_CHANNEL_NUM 8 + +/* + * TCU registers offset definition + */ +#define TCU_TER_OFFSET (0x10) /* r, 16, 0x0000 */ +#define TCU_TESR_OFFSET (0x14) /* w, 16, 0x???? */ +#define TCU_TECR_OFFSET (0x18) /* w, 16, 0x???? */ + +#define TCU_TSR_OFFSET (0x1c) /* r, 32, 0x00000000 */ +#define TCU_TSSR_OFFSET (0x2c) /* w, 32, 0x00000000 */ +#define TCU_TSCR_OFFSET (0x3c) /* w, 32, 0x0000 */ + +#define TCU_TFR_OFFSET (0x20) /* r, 32, 0x003F003F */ +#define TCU_TFSR_OFFSET (0x24) /* w, 32, 0x???????? */ +#define TCU_TFCR_OFFSET (0x28) /* w, 32, 0x???????? */ + +#define TCU_TMR_OFFSET (0x30) /* r, 32, 0x00000000 */ +#define TCU_TMSR_OFFSET (0x34) /* w, 32, 0x???????? */ +#define TCU_TMCR_OFFSET (0x38) /* w, 32, 0x???????? */ + +#define TCU_TSTR_OFFSET (0xf0) /* r, 32, 0x00000000 */ +#define TCU_TSTSR_OFFSET (0xf4) /* w, 32, 0x???????? */ +#define TCU_TSTCR_OFFSET (0xf8) /* w, 32, 0x???????? */ + +#define TCU_TDFR_OFFSET (0x40) /* rw,16, 0x???? */ +#define TCU_TDHR_OFFSET (0x44) /* rw,16, 0x???? */ +#define TCU_TCNT_OFFSET (0x48) /* rw,16, 0x???? */ +#define TCU_TCSR_OFFSET (0x4c) /* rw,16, 0x0000 */ + +/* + * TCU registers address definition + */ +#define TCU_TER (TCU_BASE + TCU_TER_OFFSET) +#define TCU_TESR (TCU_BASE + TCU_TESR_OFFSET) +#define TCU_TECR (TCU_BASE + TCU_TECR_OFFSET) +#define TCU_TSR (TCU_BASE + TCU_TSR_OFFSET) +#define TCU_TFR (TCU_BASE + TCU_TFR_OFFSET) +#define TCU_TFSR (TCU_BASE + TCU_TFSR_OFFSET) +#define TCU_TFCR (TCU_BASE + TCU_TFCR_OFFSET) +#define TCU_TSSR (TCU_BASE + TCU_TSSR_OFFSET) +#define TCU_TMR (TCU_BASE + TCU_TMR_OFFSET) +#define TCU_TMSR (TCU_BASE + TCU_TMSR_OFFSET) +#define TCU_TMCR (TCU_BASE + TCU_TMCR_OFFSET) +#define TCU_TSCR (TCU_BASE + TCU_TSCR_OFFSET) +#define TCU_TSTR (TCU_BASE + TCU_TSTR_OFFSET) +#define TCU_TSTSR (TCU_BASE + TCU_TSTSR_OFFSET) +#define TCU_TSTCR (TCU_BASE + TCU_TSTCR_OFFSET) + +/* n is the TCU channel index (0 - 7) */ +#define TCU_TDFR(n) (TCU_BASE + (n) * TCU_GOS + TCU_TDFR_OFFSET) +#define TCU_TDHR(n) (TCU_BASE + (n) * TCU_GOS + TCU_TDHR_OFFSET) +#define TCU_TCNT(n) (TCU_BASE + (n) * TCU_GOS + TCU_TCNT_OFFSET) +#define TCU_TCSR(n) (TCU_BASE + (n) * TCU_GOS + TCU_TCSR_OFFSET) + +/* + * TCU registers bit field common define + */ + +/* When n is NOT less than TCU_CHANNEL_NUM, change to TCU_CHANNEL_NUM - 1 */ +#define __TIMER(n) (1 << ((n) < TCU_CHANNEL_NUM ? (n) : (TCU_CHANNEL_NUM - 1)) + +/* Timer counter enable register(TER) */ +#define TER_OSTEN BIT15 +#define TER_TCEN(n) __TIMER(n) + +/* Timer counter enable set register(TESR) */ +#define TESR_OST BIT15 +#define TESR_TIMER(n) __TIMER(n) + +/* Timer counter enable clear register(TECR) */ +#define TECR_OST BIT15 +#define TECR_TIMER(n) __TIMER(n) + +/* Timer stop register(TSR) */ +#define TSR_WDT_STOP BIT16 +#define TSR_OST_STOP BIT15 +#define TSR_TIMER_STOP(n) __TIMER(n) + +/* Timer stop set register(TSSR) */ +#define TSSR_WDT BIT16 +#define TSSR_OST BIT15 +#define TSSR_TIMER(n) __TIMER(n) + +/* Timer stop clear register(TSCR) */ +#define TSCR_WDT BIT16 +#define TSCR_OST BIT15 +#define TSSR_TIMER(n) __TIMER(n) + +/* Timer flag register(TFR) */ +#define TFR_HFLAG(n) (__TIMER(n) << 16) +#define TFR_OSTFLAG BIT15 +#define TFR_FFLAG(n) __TIMER(n) + +/* Timer flag set register(TFSR) */ +#define TFSR_HFLAG(n) (__TIMER(n) << 16) +#define TFSR_OSTFLAG BIT15 +#define TFSR_FFLAG(n) __TIMER(n) + +/* Timer flag clear register(TFCR) */ +#define TFCR_HFLAG(n) (__TIMER(n) << 16) +#define TFCR_OSTFLAG BIT15 +#define TFCR_FFLAG(n) (__TIMER(n)) + +/* Timer mast register(TMR) */ +#define TMR_HMASK(n) (__TIMER(n) << 16) +#define TMR_OSTMASK BIT15 +#define TMR_FMASK(n) (__TIMER(n)) + +/* Timer mask set register(TMSR) */ +#define TMSR_HMASK(n) (__TIMER(n) << 16) +#define TMSR_OSTMASK BIT15 +#define TMSR_FMASK(n) (__TIMER(n)) + +/* Timer mask clear register(TMCR) */ +#define TMCR_HMASK(n) (__TIMER(n) << 16) +#define TMCR_OSTMASK BIT15 +#define TMCR_FMASK(n) (__TIMER(n)) + +/* Timer control register(TCSR) */ +#define TCSR_BYPASS BIT11 +#define TCSR_CLRZ BIT10 +#define TCSR_SD_ABRUPT BIT9 +#define TCSR_INITL_HIGH BIT8 +#define TCSR_PWM_EN BIT7 +#define TCSR_PWM_IN_EN BIT6 +#define TCSR_EXT_EN BIT2 +#define TCSR_RTC_EN BIT1 +#define TCSR_PCK_EN BIT0 + +#define TCSR_PRESCALE_LSB 3 +#define TCSR_PRESCALE_MASK BITS_H2L(5, TCSR_PRESCALE_LSB) +#define TCSR_PRESCALE1 (0x0 << TCSR_PRESCALE_LSB) +#define TCSR_PRESCALE4 (0x1 << TCSR_PRESCALE_LSB) +#define TCSR_PRESCALE16 (0x2 << TCSR_PRESCALE_LSB) +#define TCSR_PRESCALE64 (0x3 << TCSR_PRESCALE_LSB) +#define TCSR_PRESCALE256 (0x4 << TCSR_PRESCALE_LSB) +#define TCSR_PRESCALE1024 (0x5 << TCSR_PRESCALE_LSB) + +/* Timer data full register(TDFR) */ +#define TDFR_TDFR_LSB 0 +#define TDFR_TDFR_MASK BITS_H2L(15, TDFR_TDFR_LSB) + +/* Timer data half register(TDHR) */ +#define TDHR_TDHR_LSB 0 +#define TDHR_TDHR_MASK BITS_H2L(15, TDHR_TDHR_LSB) + +/* Timer counter register(TCNT) */ +#define TCNT_TCNT_LSB 0 +#define TCNT_TCNT_MASK BITS_H2L(15, TCNT_TCNT_LSB) + +/* Timer status register(TSTR) */ +#define TSTR_REAL2 BIT18 +#define TSTR_REAL1 BIT17 +#define TSTR_BUSY2 BIT2 +#define TSTR_BUSY1 BIT1 + +/* Timer status set register(TSTSR) */ +#define TSTSR_REALS2 BIT18 +#define TSTSR_REALS1 BIT17 +#define TSTSR_BUSYS2 BIT2 +#define TSTSR_BUSYS1 BIT1 + +/* Timer status clear register(TSTCR) */ +#define TSTCR_REALC2 BIT18 +#define TSTCR_REALC1 BIT17 +#define TSTCR_BUSYC2 BIT2 +#define TSTCR_BUSYC1 BIT1 + +#ifndef __MIPS_ASSEMBLER + +#define REG_TCU_TER REG16(TCU_TER) +#define REG_TCU_TESR REG16(TCU_TESR) +#define REG_TCU_TECR REG16(TCU_TECR) +#define REG_TCU_TSR REG32(TCU_TSR) +#define REG_TCU_TFR REG32(TCU_TFR) +#define REG_TCU_TFSR REG32(TCU_TFSR) +#define REG_TCU_TFCR REG32(TCU_TFCR) +#define REG_TCU_TSSR REG32(TCU_TSSR) +#define REG_TCU_TMR REG32(TCU_TMR) +#define REG_TCU_TMSR REG32(TCU_TMSR) +#define REG_TCU_TMCR REG32(TCU_TMCR) +#define REG_TCU_TSCR REG32(TCU_TSCR) +#define REG_TCU_TSTR REG32(TCU_TSTR) +#define REG_TCU_TSTSR REG32(TCU_TSTSR) +#define REG_TCU_TSTCR REG32(TCU_TSTCR) + +#define REG_TCU_TDFR(n) REG16(TCU_TDFR(n)) +#define REG_TCU_TDHR(n) REG16(TCU_TDHR(n)) +#define REG_TCU_TCNT(n) REG16(TCU_TCNT(n)) +#define REG_TCU_TCSR(n) REG16(TCU_TCSR(n)) + +// where 'n' is the TCU channel +#define __tcu_select_extalclk(n) \ + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~(TCSR_EXT_EN | TCSR_RTC_EN | TCSR_PCK_EN)) | TCSR_EXT_EN) +#define __tcu_select_rtcclk(n) \ + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~(TCSR_EXT_EN | TCSR_RTC_EN | TCSR_PCK_EN)) | TCSR_RTC_EN) +#define __tcu_select_pclk(n) \ + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~(TCSR_EXT_EN | TCSR_RTC_EN | TCSR_PCK_EN)) | TCSR_PCK_EN) +#define __tcu_disable_pclk(n) \ + REG_TCU_TCSR(n) = (REG_TCU_TCSR((n)) & ~TCSR_PCK_EN); +#define __tcu_select_clk_div1(n) \ + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCSR_PRESCALE_MASK) | TCSR_PRESCALE1) +#define __tcu_select_clk_div4(n) \ + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCSR_PRESCALE_MASK) | TCSR_PRESCALE4) +#define __tcu_select_clk_div16(n) \ + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCSR_PRESCALE_MASK) | TCSR_PRESCALE16) +#define __tcu_select_clk_div64(n) \ + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCSR_PRESCALE_MASK) | TCSR_PRESCALE64) +#define __tcu_select_clk_div256(n) \ + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCSR_PRESCALE_MASK) | TCSR_PRESCALE256) +#define __tcu_select_clk_div1024(n) \ + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCSR_PRESCALE_MASK) | TCSR_PRESCALE1024) + +#define __tcu_enable_pwm_output(n) (REG_TCU_TCSR((n)) |= TCSR_PWM_EN) +#define __tcu_disable_pwm_output(n) (REG_TCU_TCSR((n)) &= ~TCSR_PWM_EN) + +#define __tcu_init_pwm_output_high(n) (REG_TCU_TCSR((n)) |= TCSR_INITL_HIGH) +#define __tcu_init_pwm_output_low(n) (REG_TCU_TCSR((n)) &= ~TCSR_INITL_HIGH) + +#define __tcu_set_pwm_output_shutdown_graceful(n) (REG_TCU_TCSR((n)) &= ~TCSR_SD_ABRUPT) +#define __tcu_set_pwm_output_shutdown_abrupt(n) (REG_TCU_TCSR((n)) |= TCSR_SD_ABRUPT) + +#define __tcu_clear_counter_to_zero(n) (REG_TCU_TCSR((n)) |= TCSR_CLRZ) + +#define __tcu_ost_enabled() (REG_TCU_TER & TER_OSTEN) +#define __tcu_enable_ost() (REG_TCU_TESR = TESR_OST) +#define __tcu_disable_ost() (REG_TCU_TECR = TECR_OST) + +#define __tcu_counter_enabled(n) (REG_TCU_TER & (1 << (n))) +#define __tcu_start_counter(n) (REG_TCU_TESR |= (1 << (n))) +#define __tcu_stop_counter(n) (REG_TCU_TECR |= (1 << (n))) + +#define __tcu_half_match_flag(n) (REG_TCU_TFR & (1 << ((n) + 16))) +#define __tcu_full_match_flag(n) (REG_TCU_TFR & (1 << (n))) +#define __tcu_set_half_match_flag(n) (REG_TCU_TFSR = (1 << ((n) + 16))) +#define __tcu_set_full_match_flag(n) (REG_TCU_TFSR = (1 << (n))) +#define __tcu_clear_half_match_flag(n) (REG_TCU_TFCR = (1 << ((n) + 16))) +#define __tcu_clear_full_match_flag(n) (REG_TCU_TFCR = (1 << (n))) +#define __tcu_mask_half_match_irq(n) (REG_TCU_TMSR = (1 << ((n) + 16))) +#define __tcu_mask_full_match_irq(n) (REG_TCU_TMSR = (1 << (n))) +#define __tcu_unmask_half_match_irq(n) (REG_TCU_TMCR = (1 << ((n) + 16))) +#define __tcu_unmask_full_match_irq(n) (REG_TCU_TMCR = (1 << (n))) + +#define __tcu_ost_match_flag() (REG_TCU_TFR & TFR_OSTFLAG) +#define __tcu_set_ost_match_flag() (REG_TCU_TFSR = TFSR_OSTFLAG) +#define __tcu_clear_ost_match_flag() (REG_TCU_TFCR = TFCR_OSTFLAG) +#define __tcu_ost_match_irq_masked() (REG_TCU_TMR & TMR_OSTMASK) +#define __tcu_mask_ost_match_irq() (REG_TCU_TMSR = TMSR_OSTMASK) +#define __tcu_unmask_ost_match_irq() (REG_TCU_TMCR = TMCR_OSTMASK) + +#define __tcu_wdt_clock_stopped() (REG_TCU_TSR & TSR_WDT_STOP) +#define __tcu_ost_clock_stopped() (REG_TCU_TSR & TSR_OST_STOP) +#define __tcu_timer_clock_stopped(n) (REG_TCU_TSR & (1 << (n))) + +#define __tcu_start_wdt_clock() (REG_TCU_TSCR = TSCR_WDT) +#define __tcu_start_ost_clock() (REG_TCU_TSCR = TSCR_OST) +#define __tcu_start_timer_clock(n) (REG_TCU_TSCR = (1 << (n))) + +#define __tcu_stop_wdt_clock() (REG_TCU_TSSR = TSSR_WDT) +#define __tcu_stop_ost_clock() (REG_TCU_TSSR = TSSR_OST) +#define __tcu_stop_timer_clock(n) (REG_TCU_TSSR = (1 << (n))) + +#define __tcu_get_count(n) (REG_TCU_TCNT((n))) +#define __tcu_set_count(n,v) (REG_TCU_TCNT((n)) = (v)) +#define __tcu_set_full_data(n,v) (REG_TCU_TDFR((n)) = (v)) +#define __tcu_set_half_data(n,v) (REG_TCU_TDHR((n)) = (v)) + +/* TCU2, counter 1, 2*/ +#define __tcu_read_real_value(n) (REG_TCU_TSTR & (1 << ((n) + 16))) +#define __tcu_read_false_value(n) (REG_TCU_TSTR & (1 << ((n) + 16))) +#define __tcu_counter_busy(n) (REG_TCU_TSTR & (1 << (n))) +#define __tcu_counter_ready(n) (REG_TCU_TSTR & (1 << (n))) + +#define __tcu_set_read_real_value(n) (REG_TCU_TSTSR = (1 << ((n) + 16))) +#define __tcu_set_read_false_value(n) (REG_TCU_TSTCR = (1 << ((n) + 16))) +#define __tcu_set_counter_busy(n) (REG_TCU_TSTSR = (1 << (n))) +#define __tcu_set_counter_ready(n) (REG_TCU_TSTCR = (1 << (n))) + +#endif /* __MIPS_ASSEMBLER */ + +#define TSSI0_BASE 0xB0073000 + +/************************************************************************* + * TSSI MPEG 2-TS slave interface + *************************************************************************/ +#define TSSI_ENA ( TSSI0_BASE + 0x00 ) /* TSSI enable register */ +#define TSSI_CFG ( TSSI0_BASE + 0x04 ) /* TSSI configure register */ +#define TSSI_CTRL ( TSSI0_BASE + 0x08 ) /* TSSI control register */ +#define TSSI_STAT ( TSSI0_BASE + 0x0c ) /* TSSI state register */ +#define TSSI_FIFO ( TSSI0_BASE + 0x10 ) /* TSSI FIFO register */ +#define TSSI_PEN ( TSSI0_BASE + 0x14 ) /* TSSI PID enable register */ +#define TSSI_NUM ( TSSI0_BASE + 0x18 ) +#define TSSI_DTR ( TSSI0_BASE + 0x1c ) +#define TSSI_PID(n) ( TSSI0_BASE + 0x20 + 4*(n) ) /* TSSI PID filter register */ +#define TSSI_PID0 ( TSSI0_BASE + 0x20 ) +#define TSSI_PID1 ( TSSI0_BASE + 0x24 ) +#define TSSI_PID2 ( TSSI0_BASE + 0x28 ) +#define TSSI_PID3 ( TSSI0_BASE + 0x2c ) +#define TSSI_PID4 ( TSSI0_BASE + 0x30 ) +#define TSSI_PID5 ( TSSI0_BASE + 0x34 ) +#define TSSI_PID6 ( TSSI0_BASE + 0x38 ) +#define TSSI_PID7 ( TSSI0_BASE + 0x3c ) +#define TSSI_PID8 ( TSSI0_BASE + 0x40 ) +#define TSSI_PID9 ( TSSI0_BASE + 0x44 ) +#define TSSI_PID10 ( TSSI0_BASE + 0x48 ) +#define TSSI_PID11 ( TSSI0_BASE + 0x4c ) +#define TSSI_PID12 ( TSSI0_BASE + 0x50 ) +#define TSSI_PID13 ( TSSI0_BASE + 0x54 ) +#define TSSI_PID14 ( TSSI0_BASE + 0x58 ) +#define TSSI_PID15 ( TSSI0_BASE + 0x5c ) +#define TSSI_PID_MAX 16 /* max PID: 15 */ + +#define TSSI_DDA ( TSSI0_BASE + 0x60 ) +#define TSSI_DTA ( TSSI0_BASE + 0x64 ) +#define TSSI_DID ( TSSI0_BASE + 0x68 ) +#define TSSI_DCMD ( TSSI0_BASE + 0x6c ) +#define TSSI_DST ( TSSI0_BASE + 0x70 ) +#define TSSI_TC ( TSSI0_BASE + 0x74 ) + +#define REG_TSSI_ENA REG8( TSSI_ENA ) +#define REG_TSSI_CFG REG16( TSSI_CFG ) +#define REG_TSSI_CTRL REG8( TSSI_CTRL ) +#define REG_TSSI_STAT REG8( TSSI_STAT ) +#define REG_TSSI_FIFO REG32( TSSI_FIFO ) +#define REG_TSSI_PEN REG32( TSSI_PEN ) +#define REG_TSSI_NUM REG32( TSSI_NUM ) +#define REG_TSSI_DTR REG32( TSSI_DTR ) +#define REG_TSSI_PID(n) REG32( TSSI_PID(n) ) +#define REG_TSSI_PID0 REG32( TSSI_PID0 ) +#define REG_TSSI_PID1 REG32( TSSI_PID1 ) +#define REG_TSSI_PID2 REG32( TSSI_PID2 ) +#define REG_TSSI_PID3 REG32( TSSI_PID3 ) +#define REG_TSSI_PID4 REG32( TSSI_PID4 ) +#define REG_TSSI_PID5 REG32( TSSI_PID5 ) +#define REG_TSSI_PID6 REG32( TSSI_PID6 ) +#define REG_TSSI_PID7 REG32( TSSI_PID7 ) +#define REG_TSSI_PID8 REG32( TSSI_PID8 ) +#define REG_TSSI_PID9 REG32( TSSI_PID9 ) +#define REG_TSSI_PID10 REG32( TSSI_PID10 ) +#define REG_TSSI_PID11 REG32( TSSI_PID11 ) +#define REG_TSSI_PID12 REG32( TSSI_PID12 ) +#define REG_TSSI_PID13 REG32( TSSI_PID13 ) +#define REG_TSSI_PID14 REG32( TSSI_PID14 ) +#define REG_TSSI_PID15 REG32( TSSI_PID15 ) + +/* TSSI enable register */ +#define TSSI_ENA_SFT_RST ( 1 << 7 ) /* soft reset bit */ +#define TSSI_ENA_PID_EN ( 1 << 2 ) /* soft filtering function enable bit */ +#define TSSI_ENA_FAIL ( 1 << 4 ) /* fail signal bit */ +#define TSSI_ENA_PEN_0 ( 1 << 3 ) /* PID filter enable bit for PID */ +#define TSSI_ENA_DMA_EN ( 1 << 1 ) /* DMA enable bit */ +#define TSSI_ENA_ENA ( 1 << 0 ) /* TSSI enable bit */ + +/* TSSI configure register */ +#define TSSI_CFG_TRIG_BIT 14 /* fifo trig number */ +#define TSSI_CFG_TRIG_MASK ( 0x7 << TSSI_CFG_TRIG_BIT) +#define TSSI_CFG_TRIG_4 ( 0 << TSSI_CFG_TRIG_BIT) +#define TSSI_CFG_TRIG_8 ( 1 << TSSI_CFG_TRIG_BIT) +#define TSSI_CFG_TRIG_16 ( 2 << TSSI_CFG_TRIG_BIT) +#define TSSI_CFG_TRIG_32 ( 3 << TSSI_CFG_TRIG_BIT) +#define TSSI_CFG_TRIG_48 ( 4 << TSSI_CFG_TRIG_BIT) +#define TSSI_CFG_TRIG_64 ( 5 << TSSI_CFG_TRIG_BIT) +#define TSSI_CFG_TRIG_80 ( 6 << TSSI_CFG_TRIG_BIT) +#define TSSI_CFG_TRIG_96 ( 7 << TSSI_CFG_TRIG_BIT) + +/* mode of adding data 0 select bit */ +#define TSSI_CFG_TRANS_MD_BIT 10 +#define TSSI_CFG_TRANS_MD_MASK ( 0x3 << TSSI_CFG_TRANS_MD_BIT) +#define TSSI_CFG_TRANS_MD_0 (0 << TSSI_CFG_TRANS_MD_BIT) +#define TSSI_CFG_TRANS_MD_1 (1 << TSSI_CFG_TRANS_MD_BIT) +#define TSSI_CFG_TRANS_MD_2 (2 << TSSI_CFG_TRANS_MD_BIT) + +#define TSSI_CFG_END_WD ( 1 << 9 ) /* order of data in word */ +#define TSSI_CFG_END_BT ( 1 << 8 ) /* order of data in byte */ + +#define TSSI_CFG_TSDI_H ( 1 << 7 ) /* data pin polarity */ +#define TSSI_CFG_USE_0 ( 1 << 6 ) /* serial mode data pin select */ +#define TSSI_CFG_USE_TSDI0 ( 1 << 6 ) /* TSDI0 as serial mode data pin */ +#define TSSI_CFG_USE_TSDI7 ( 0 << 6 ) /* TSDI7 as serial mode data pin */ +#define TSSI_CFG_TSCLK_CH ( 1 << 5 ) /* clk channel select */ +#define TSSI_CFG_PARAL ( 1 << 4 ) /* mode select */ +#define TSSI_CFG_PARAL_MODE ( 1 << 4 ) /* parallel select */ +#define TSSI_CFG_SERIAL_MODE ( 0 << 4 ) /* serial select */ +#define TSSI_CFG_TSCLK_P ( 1 << 3 ) /* clk edge select */ +#define TSSI_CFG_TSFRM_H ( 1 << 2 ) /* TSFRM polarity select */ +#define TSSI_CFG_TSSTR_H ( 1 << 1 ) /* TSSTR polarity select */ +#define TSSI_CFG_TSFAIL_H ( 1 << 0 ) /* TSFAIL polarity select */ + +/* TSSI control register */ +#define TSSI_CTRL_DTRM ( 1 << 2 ) /* FIFO data trigger interrupt mask bit */ +#define TSSI_CTRL_OVRNM ( 1 << 1 ) /* FIFO overrun interrupt mask bit */ +#define TSSI_CTRL_TRIGM ( 1 << 0 ) /* FIFO trigger interrupt mask bit */ + +/* TSSI state register */ +#define TSSI_STAT_DTR ( 1 << 2 ) /* FIFO data trigger interrupt flag bit */ +#define TSSI_STAT_OVRN ( 1 << 1 ) /* FIFO overrun interrupt flag bit */ +#define TSSI_STAT_TRIG ( 1 << 0 ) /* FIFO trigger interrupt flag bit */ + +/* TSSI PID enable register */ +#define TSSI_PEN_EN00 ( 1 << 0 ) /* enable PID n */ +#define TSSI_PEN_EN10 ( 1 << 1 ) +#define TSSI_PEN_EN20 ( 1 << 2 ) +#define TSSI_PEN_EN30 ( 1 << 3 ) +#define TSSI_PEN_EN40 ( 1 << 4 ) +#define TSSI_PEN_EN50 ( 1 << 5 ) +#define TSSI_PEN_EN60 ( 1 << 6 ) +#define TSSI_PEN_EN70 ( 1 << 7 ) +#define TSSI_PEN_EN80 ( 1 << 8 ) +#define TSSI_PEN_EN90 ( 1 << 9 ) +#define TSSI_PEN_EN100 ( 1 << 10 ) +#define TSSI_PEN_EN110 ( 1 << 11 ) +#define TSSI_PEN_EN120 ( 1 << 12 ) +#define TSSI_PEN_EN130 ( 1 << 13 ) +#define TSSI_PEN_EN140 ( 1 << 14 ) +#define TSSI_PEN_EN150 ( 1 << 15 ) +#define TSSI_PEN_EN01 ( 1 << 16 ) +#define TSSI_PEN_EN11 ( 1 << 17 ) +#define TSSI_PEN_EN21 ( 1 << 18 ) +#define TSSI_PEN_EN31 ( 1 << 19 ) +#define TSSI_PEN_EN41 ( 1 << 20 ) +#define TSSI_PEN_EN51 ( 1 << 21 ) +#define TSSI_PEN_EN61 ( 1 << 22 ) +#define TSSI_PEN_EN71 ( 1 << 23 ) +#define TSSI_PEN_EN81 ( 1 << 24 ) +#define TSSI_PEN_EN91 ( 1 << 25 ) +#define TSSI_PEN_EN101 ( 1 << 26 ) +#define TSSI_PEN_EN111 ( 1 << 27 ) +#define TSSI_PEN_EN121 ( 1 << 28 ) +#define TSSI_PEN_EN131 ( 1 << 29 ) +#define TSSI_PEN_EN141 ( 1 << 30 ) +#define TSSI_PEN_EN151 ( 1 << 31 ) +//#define TSSI_PEN_PID0 ( 1 << 31 ) /* PID filter enable PID0 */ + +/* TSSI Data Number Registers */ +#define TSSI_DNUM_BIT 0 +#define TSSI_DNUM_MASK (0x7f << TSSI_DNUM_BIT) + +/* TSSI Data Trigger Register */ +#define TSSI_DTRG_BIT 0 +#define TSSI_DTRG_MASK (0x7f << TSSI_DTRG_BIT) + +/* TSSI PID Filter Registers */ +#define TSSI_PID_PID1_BIT 16 +#define TSSI_PID_PID1_MASK (0x1fff<=0 && n <(TSSI_PID_MAX*2) ) { \ + REG_TSSI_PEN |= ( 1 << n ); \ + } \ + } while (0) + +/* m = 0, ..., 31 */ +#define __tssi_disable_pid_filter(m) \ + do { \ + int n = (m); \ + if ( n>=0 && n <(TSSI_PID_MAX*2) ) { \ + REG_TSSI_PEN &= ~( 1 << n ); \ + } \ + } while (0) + +/* n = 0, ..., 15 */ +#define __tssi_set_pid0(n, pid0) \ + do { \ + REG_TSSI_PID(n) &= ~TSSI_PID_PID0_MASK; \ + REG_TSSI_PID(n) |= ((pid0)<=0 && n < TSSI_PID_MAX*2) { \ + if ( n < TSSI_PID_MAX ) \ + __tssi_set_pid0(n, pid); \ + else \ + __tssi_set_pid1(n-TSSI_PID_MAX, pid); \ + } \ + }while (0) + +#endif /* __MIPS_ASSEMBLER */ + +#define TVE_BASE 0xB3050100 + +/************************************************************************* + * TVE (TV Encoder Controller) + *************************************************************************/ +#define TVE_CTRL (TVE_BASE + 0x40) /* TV Encoder Control register */ +#define TVE_FRCFG (TVE_BASE + 0x44) /* Frame configure register */ +#define TVE_SLCFG1 (TVE_BASE + 0x50) /* TV signal level configure register 1 */ +#define TVE_SLCFG2 (TVE_BASE + 0x54) /* TV signal level configure register 2*/ +#define TVE_SLCFG3 (TVE_BASE + 0x58) /* TV signal level configure register 3*/ +#define TVE_LTCFG1 (TVE_BASE + 0x60) /* Line timing configure register 1 */ +#define TVE_LTCFG2 (TVE_BASE + 0x64) /* Line timing configure register 2 */ +#define TVE_CFREQ (TVE_BASE + 0x70) /* Chrominance sub-carrier frequency configure register */ +#define TVE_CPHASE (TVE_BASE + 0x74) /* Chrominance sub-carrier phase configure register */ +#define TVE_CBCRCFG (TVE_BASE + 0x78) /* Chrominance filter configure register */ +#define TVE_WSSCR (TVE_BASE + 0x80) /* Wide screen signal control register */ +#define TVE_WSSCFG1 (TVE_BASE + 0x84) /* Wide screen signal configure register 1 */ +#define TVE_WSSCFG2 (TVE_BASE + 0x88) /* Wide screen signal configure register 2 */ +#define TVE_WSSCFG3 (TVE_BASE + 0x8c) /* Wide screen signal configure register 3 */ + +#define REG_TVE_CTRL REG32(TVE_CTRL) +#define REG_TVE_FRCFG REG32(TVE_FRCFG) +#define REG_TVE_SLCFG1 REG32(TVE_SLCFG1) +#define REG_TVE_SLCFG2 REG32(TVE_SLCFG2) +#define REG_TVE_SLCFG3 REG32(TVE_SLCFG3) +#define REG_TVE_LTCFG1 REG32(TVE_LTCFG1) +#define REG_TVE_LTCFG2 REG32(TVE_LTCFG2) +#define REG_TVE_CFREQ REG32(TVE_CFREQ) +#define REG_TVE_CPHASE REG32(TVE_CPHASE) +#define REG_TVE_CBCRCFG REG32(TVE_CBCRCFG) +#define REG_TVE_WSSCR REG32(TVE_WSSCR) +#define REG_TVE_WSSCFG1 REG32(TVE_WSSCFG1) +#define REG_TVE_WSSCFG2 REG32(TVE_WSSCFG2) +#define REG_TVE_WSSCFG3 REG32(TVE_WSSCFG3) + +/* TV Encoder Control register */ +#define TVE_CTRL_EYCBCR (1 << 25) /* YCbCr_enable */ +#define TVE_CTRL_ECVBS (1 << 24) /* 1: cvbs_enable 0: s-video*/ +#define TVE_CTRL_DAPD3 (1 << 23) /* DAC 3 power down */ +#define TVE_CTRL_DAPD2 (1 << 22) /* DAC 2 power down */ +#define TVE_CTRL_DAPD1 (1 << 21) /* DAC 1 power down */ +#define TVE_CTRL_DAPD (1 << 20) /* power down all DACs */ +#define TVE_CTRL_YCDLY_BIT 16 +#define TVE_CTRL_YCDLY_MASK (0x7 << TVE_CTRL_YCDLY_BIT) +#define TVE_CTRL_CGAIN_BIT 14 +#define TVE_CTRL_CGAIN_MASK (0x3 << TVE_CTRL_CGAIN_BIT) + #define TVE_CTRL_CGAIN_FULL (0 << TVE_CTRL_CGAIN_BIT) /* gain = 1 */ + #define TVE_CTRL_CGAIN_QUTR (1 << TVE_CTRL_CGAIN_BIT) /* gain = 1/4 */ + #define TVE_CTRL_CGAIN_HALF (2 << TVE_CTRL_CGAIN_BIT) /* gain = 1/2 */ + #define TVE_CTRL_CGAIN_THREE_QURT (3 << TVE_CTRL_CGAIN_BIT) /* gain = 3/4 */ +#define TVE_CTRL_CBW_BIT 12 +#define TVE_CTRL_CBW_MASK (0x3 << TVE_CTRL_CBW_BIT) + #define TVE_CTRL_CBW_NARROW (0 << TVE_CTRL_CBW_BIT) /* Narrow band */ + #define TVE_CTRL_CBW_WIDE (1 << TVE_CTRL_CBW_BIT) /* Wide band */ + #define TVE_CTRL_CBW_EXTRA (2 << TVE_CTRL_CBW_BIT) /* Extra wide band */ + #define TVE_CTRL_CBW_ULTRA (3 << TVE_CTRL_CBW_BIT) /* Ultra wide band */ +#define TVE_CTRL_SYNCT (1 << 9) +#define TVE_CTRL_PAL (1 << 8) /* 1: PAL, 0: NTSC */ +#define TVE_CTRL_FINV (1 << 7) /* invert_top:1-invert top and bottom fields. */ +#define TVE_CTRL_ZBLACK (1 << 6) /* bypass_yclamp:1-Black of luminance (Y) input is 0.*/ +#define TVE_CTRL_CR1ST (1 << 5) /* uv_order:0-Cb before Cr,1-Cr before Cb */ +#define TVE_CTRL_CLBAR (1 << 4) /* Color bar mode:0-Output input video to TV,1-Output color bar to TV */ +#define TVE_CTRL_SWRST (1 << 0) /* Software reset:1-TVE is reset */ + +/* Signal level configure register 1 */ +#define TVE_SLCFG1_BLACKL_BIT 0 +#define TVE_SLCFG1_BLACKL_MASK (0x3ff << TVE_SLCFG1_BLACKL_BIT) +#define TVE_SLCFG1_WHITEL_BIT 16 +#define TVE_SLCFG1_WHITEL_MASK (0x3ff << TVE_SLCFG1_WHITEL_BIT) + +/* Signal level configure register 2 */ +#define TVE_SLCFG2_BLANKL_BIT 0 +#define TVE_SLCFG2_BLANKL_MASK (0x3ff << TVE_SLCFG2_BLANKL_BIT) +#define TVE_SLCFG2_VBLANKL_BIT 16 +#define TVE_SLCFG2_VBLANKL_MASK (0x3ff << TVE_SLCFG2_VBLANKL_BIT) + +/* Signal level configure register 3 */ +#define TVE_SLCFG3_SYNCL_BIT 0 +#define TVE_SLCFG3_SYNCL_MASK (0xff << TVE_SLCFG3_SYNCL_BIT) + +/* Line timing configure register 1 */ +#define TVE_LTCFG1_BACKP_BIT 0 +#define TVE_LTCFG1_BACKP_MASK (0x7f << TVE_LTCFG1_BACKP_BIT) +#define TVE_LTCFG1_HSYNCW_BIT 8 +#define TVE_LTCFG1_HSYNCW_MASK (0x7f << TVE_LTCFG1_HSYNCW_BIT) +#define TVE_LTCFG1_FRONTP_BIT 16 +#define TVE_LTCFG1_FRONTP_MASK (0x1f << TVE_LTCFG1_FRONTP_BIT) + +/* Line timing configure register 2 */ +#define TVE_LTCFG2_BURSTW_BIT 0 +#define TVE_LTCFG2_BURSTW_MASK (0x3f << TVE_LTCFG2_BURSTW_BIT) +#define TVE_LTCFG2_PREBW_BIT 8 +#define TVE_LTCFG2_PREBW_MASK (0x1f << TVE_LTCFG2_PREBW_BIT) +#define TVE_LTCFG2_ACTLIN_BIT 16 +#define TVE_LTCFG2_ACTLIN_MASK (0x7ff << TVE_LTCFG2_ACTLIN_BIT) + +/* Chrominance sub-carrier phase configure register */ +#define TVE_CPHASE_CCRSTP_BIT 0 +#define TVE_CPHASE_CCRSTP_MASK (0x3 << TVE_CPHASE_CCRSTP_BIT) + #define TVE_CPHASE_CCRSTP_8 (0 << TVE_CPHASE_CCRSTP_BIT) /* Every 8 field */ + #define TVE_CPHASE_CCRSTP_4 (1 << TVE_CPHASE_CCRSTP_BIT) /* Every 4 field */ + #define TVE_CPHASE_CCRSTP_2 (2 << TVE_CPHASE_CCRSTP_BIT) /* Every 2 lines */ + #define TVE_CPHASE_CCRSTP_0 (3 << TVE_CPHASE_CCRSTP_BIT) /* Never */ +#define TVE_CPHASE_ACTPH_BIT 16 +#define TVE_CPHASE_ACTPH_MASK (0xff << TVE_CPHASE_ACTPH_BIT) +#define TVE_CPHASE_INITPH_BIT 24 +#define TVE_CPHASE_INITPH_MASK (0xff << TVE_CPHASE_INITPH_BIT) + +/* Chrominance filter configure register */ +#define TVE_CBCRCFG_CRGAIN_BIT 0 +#define TVE_CBCRCFG_CRGAIN_MASK (0xff << TVE_CBCRCFG_CRGAIN_BIT) +#define TVE_CBCRCFG_CBGAIN_BIT 8 +#define TVE_CBCRCFG_CBGAIN_MASK (0xff << TVE_CBCRCFG_CBGAIN_BIT) +#define TVE_CBCRCFG_CRBA_BIT 16 +#define TVE_CBCRCFG_CRBA_MASK (0xff << TVE_CBCRCFG_CRBA_BIT) +#define TVE_CBCRCFG_CBBA_BIT 24 +#define TVE_CBCRCFG_CBBA_MASK (0xff << TVE_CBCRCFG_CBBA_BIT) + +/* Frame configure register */ +#define TVE_FRCFG_NLINE_BIT 0 +#define TVE_FRCFG_NLINE_MASK (0x3ff << TVE_FRCFG_NLINE_BIT) +#define TVE_FRCFG_L1ST_BIT 16 +#define TVE_FRCFG_L1ST_MASK (0xff << TVE_FRCFG_L1ST_BIT) + +/* Wide screen signal control register */ +#define TVE_WSSCR_EWSS0_BIT 0 +#define TVE_WSSCR_EWSS1_BIT 1 +#define TVE_WSSCR_WSSTP_BIT 2 +#define TVE_WSSCR_WSSCKBP_BIT 3 +#define TVE_WSSCR_WSSEDGE_BIT 4 +#define TVE_WSSCR_WSSEDGE_MASK (0x7 << TVE_WSSCR_WSSEDGE_BIT) +#define TVE_WSSCR_ENCH_BIT 8 +#define TVE_WSSCR_NCHW_BIT 9 +#define TVE_WSSCR_NCHFREQ_BIT 12 +#define TVE_WSSCR_NCHFREQ_MASK (0x7 << TVE_WSSCR_NCHFREQ_BIT) + +#ifndef __MIPS_ASSEMBLER + +/************************************************************************* + * TVE (TV Encoder Controller) ops + *************************************************************************/ +/* TV Encoder Control register ops */ +#define __tve_soft_reset() (REG_TVE_CTRL |= TVE_CTRL_SWRST) + +#define __tve_output_colorbar() (REG_TVE_CTRL |= TVE_CTRL_CLBAR) +#define __tve_output_video() (REG_TVE_CTRL &= ~TVE_CTRL_CLBAR) + +#define __tve_input_cr_first() (REG_TVE_CTRL |= TVE_CTRL_CR1ST) +#define __tve_input_cb_first() (REG_TVE_CTRL &= ~TVE_CTRL_CR1ST) + +#define __tve_set_0_as_black() (REG_TVE_CTRL |= TVE_CTRL_ZBLACK) +#define __tve_set_16_as_black() (REG_TVE_CTRL &= ~TVE_CTRL_ZBLACK) + +#define __tve_ena_invert_top_bottom() (REG_TVE_CTRL |= TVE_CTRL_FINV) +#define __tve_dis_invert_top_bottom() (REG_TVE_CTRL &= ~TVE_CTRL_FINV) + +#define __tve_set_pal_mode() (REG_TVE_CTRL |= TVE_CTRL_PAL) +#define __tve_set_ntsc_mode() (REG_TVE_CTRL &= ~TVE_CTRL_PAL) + +#define __tve_set_pal_dura() (REG_TVE_CTRL |= TVE_CTRL_SYNCT) +#define __tve_set_ntsc_dura() (REG_TVE_CTRL &= ~TVE_CTRL_SYNCT) + +/* n = 0 ~ 3 */ +#define __tve_set_c_bandwidth(n) \ +do {\ + REG_TVE_CTRL &= ~TVE_CTRL_CBW_MASK;\ + REG_TVE_CTRL |= (n) << TVE_CTRL_CBW_BIT; \ +}while(0) + +/* n = 0 ~ 3 */ +#define __tve_set_c_gain(n) \ +do {\ + REG_TVE_CTRL &= ~TVE_CTRL_CGAIN_MASK;\ + (REG_TVE_CTRL |= (n) << TVE_CTRL_CGAIN_BIT; \ +}while(0) + +/* n = 0 ~ 7 */ +#define __tve_set_yc_delay(n) \ +do { \ + REG_TVE_CTRL &= ~TVE_CTRL_YCDLY_MASK \ + REG_TVE_CTRL |= ((n) << TVE_CTRL_YCDLY_BIT); \ +} while(0) + +#define __tve_disable_all_dacs() (REG_TVE_CTRL |= TVE_CTRL_DAPD) +#define __tve_disable_dac1() (REG_TVE_CTRL |= TVE_CTRL_DAPD1) +#define __tve_enable_dac1() (REG_TVE_CTRL &= ~TVE_CTRL_DAPD1) +#define __tve_disable_dac2() (REG_TVE_CTRL |= TVE_CTRL_DAPD2) +#define __tve_enable_dac2() (REG_TVE_CTRL &= ~TVE_CTRL_DAPD2) +#define __tve_disable_dac3() (REG_TVE_CTRL |= TVE_CTRL_DAPD3) +#define __tve_enable_dac3() (REG_TVE_CTRL &= ~TVE_CTRL_DAPD3) + +#define __tve_enable_svideo_fmt() (REG_TVE_CTRL |= TVE_CTRL_ECVBS) +#define __tve_enable_cvbs_fmt() (REG_TVE_CTRL &= ~TVE_CTRL_ECVBS) + +/* TV Encoder Frame Configure register ops */ +/* n = 0 ~ 255 */ +#define __tve_set_first_video_line(n) \ +do {\ + REG_TVE_FRCFG &= ~TVE_FRCFG_L1ST_MASK;\ + REG_TVE_FRCFG |= (n) << TVE_FRCFG_L1ST_BIT;\ +} while(0) +/* n = 0 ~ 1023 */ +#define __tve_set_line_num_per_frm(n) \ +do {\ + REG_TVE_FRCFG &= ~TVE_FRCFG_NLINE_MASK;\ + REG_TVE_CFG |= (n) << TVE_FRCFG_NLINE_BIT;\ +} while(0) +#define __tve_get_video_line_num()\ + (((REG_TVE_FRCFG & TVE_FRCFG_NLINE_MASK) >> TVE_FRCFG_NLINE_BIT) - 1 - 2 * ((REG_TVE_FRCFG & TVE_FRCFG_L1ST_MASK) >> TVE_FRCFG_L1ST_BIT)) + +/* TV Encoder Signal Level Configure register ops */ +/* n = 0 ~ 1023 */ +#define __tve_set_white_level(n) \ +do {\ + REG_TVE_SLCFG1 &= ~TVE_SLCFG1_WHITEL_MASK;\ + REG_TVE_SLCFG1 |= (n) << TVE_SLCFG1_WHITEL_BIT;\ +} while(0) +/* n = 0 ~ 1023 */ +#define __tve_set_black_level(n) \ +do {\ + REG_TVE_SLCFG1 &= ~TVE_SLCFG1_BLACKL_MASK;\ + REG_TVE_SLCFG1 |= (n) << TVE_SLCFG1_BLACKL_BIT;\ +} while(0) +/* n = 0 ~ 1023 */ +#define __tve_set_blank_level(n) \ +do {\ + REG_TVE_SLCFG2 &= ~TVE_SLCFG2_BLANKL_MASK;\ + REG_TVE_SLCFG2 |= (n) << TVE_SLCFG2_BLANKL_BIT;\ +} while(0) +/* n = 0 ~ 1023 */ +#define __tve_set_vbi_blank_level(n) \ +do {\ + REG_TVE_SLCFG2 &= ~TVE_SLCFG2_VBLANKL_MASK;\ + REG_TVE_SLCFG2 |= (n) << TVE_SLCFG2_VBLANKL_BIT;\ +} while(0) +/* n = 0 ~ 1023 */ +#define __tve_set_sync_level(n) \ +do {\ + REG_TVE_SLCFG3 &= ~TVE_SLCFG3_SYNCL_MASK;\ + REG_TVE_SLCFG3 |= (n) << TVE_SLCFG3_SYNCL_BIT;\ +} while(0) + +/* TV Encoder Signal Level Configure register ops */ +/* n = 0 ~ 31 */ +#define __tve_set_front_porch(n) \ +do {\ + REG_TVE_LTCFG1 &= ~TVE_LTCFG1_FRONTP_MASK;\ + REG_TVE_LTCFG1 |= (n) << TVE_LTCFG1_FRONTP_BIT; \ +} while(0) +/* n = 0 ~ 127 */ +#define __tve_set_hsync_width(n) \ +do {\ + REG_TVE_LTCFG1 &= ~TVE_LTCFG1_HSYNCW_MASK;\ + REG_TVE_LTCFG1 |= (n) << TVE_LTCFG1_HSYNCW_BIT; \ +} while(0) +/* n = 0 ~ 127 */ +#define __tve_set_back_porch(n) \ +do {\ + REG_TVE_LTCFG1 &= ~TVE_LTCFG1_BACKP_MASK;\ + REG_TVE_LTCFG1 |= (n) << TVE_LTCFG1_BACKP_BIT; \ +} while(0) +/* n = 0 ~ 2047 */ +#define __tve_set_active_linec(n) \ +do {\ + REG_TVE_LTCFG2 &= ~TVE_LTCFG2_ACTLIN_MASK;\ + REG_TVE_LTCFG2 |= (n) << TVE_LTCFG2_ACTLIN_BIT; \ +} while(0) +/* n = 0 ~ 31 */ +#define __tve_set_breezy_way(n) \ +do {\ + REG_TVE_LTCFG2 &= ~TVE_LTCFG2_PREBW_MASK;\ + REG_TVE_LTCFG2 |= (n) << TVE_LTCFG2_PREBW_BIT; \ +} while(0) + +/* n = 0 ~ 127 */ +#define __tve_set_burst_width(n) \ +do {\ + REG_TVE_LTCFG2 &= ~TVE_LTCFG2_BURSTW_MASK;\ + REG_TVE_LTCFG2 |= (n) << TVE_LTCFG2_BURSTW_BIT; \ +} while(0) + +/* TV Encoder Chrominance filter and Modulation register ops */ +/* n = 0 ~ (2^32-1) */ +#define __tve_set_c_sub_carrier_freq(n) REG_TVE_CFREQ = (n) +/* n = 0 ~ 255 */ +#define __tve_set_c_sub_carrier_init_phase(n) \ +do { \ + REG_TVE_CPHASE &= ~TVE_CPHASE_INITPH_MASK; \ + REG_TVE_CPHASE |= (n) << TVE_CPHASE_INITPH_BIT; \ +} while(0) +/* n = 0 ~ 255 */ +#define __tve_set_c_sub_carrier_act_phase(n) \ +do { \ + REG_TVE_CPHASE &= ~TVE_CPHASE_ACTPH_MASK; \ + REG_TVE_CPHASE |= (n) << TVE_CPHASE_ACTPH_BIT; \ +} while(0) +/* n = 0 ~ 255 */ +#define __tve_set_c_phase_rst_period(n) \ +do { \ + REG_TVE_CPHASE &= ~TVE_CPHASE_CCRSTP_MASK; \ + REG_TVE_CPHASE |= (n) << TVE_CPHASE_CCRSTP_BIT; \ +} while(0) +/* n = 0 ~ 255 */ +#define __tve_set_cb_burst_amp(n) \ +do { \ + REG_TVE_CBCRCFG &= ~TVE_CBCRCFG_CBBA_MASK; \ + REG_TVE_CBCRCFG |= (n) << TVE_CBCRCFG_CBBA_BIT; \ +} while(0) +/* n = 0 ~ 255 */ +#define __tve_set_cr_burst_amp(n) \ +do { \ + REG_TVE_CBCRCFG &= ~TVE_CBCRCFG_CRBA_MASK; \ + REG_TVE_CBCRCFG |= (n) << TVE_CBCRCFG_CRBA_BIT; \ +} while(0) +/* n = 0 ~ 255 */ +#define __tve_set_cb_gain_amp(n) \ +do { \ + REG_TVE_CBCRCFG &= ~TVE_CBCRCFG_CBGAIN_MASK; \ + REG_TVE_CBCRCFG |= (n) << TVE_CBCRCFG_CBGAIN_BIT; \ +} while(0) +/* n = 0 ~ 255 */ +#define __tve_set_cr_gain_amp(n) \ +do { \ + REG_TVE_CBCRCFG &= ~TVE_CBCRCFG_CRGAIN_MASK; \ + REG_TVE_CBCRCFG |= (n) << TVE_CBCRCFG_CRGAIN_BIT; \ +} while(0) + +/* TV Encoder Wide Screen Signal Control register ops */ +/* n = 0 ~ 7 */ +#define __tve_set_notch_freq(n) \ +do { \ + REG_TVE_WSSCR &= ~TVE_WSSCR_NCHFREQ_MASK; \ + REG_TVE_WSSCR |= (n) << TVE_WSSCR_NCHFREQ_BIT; \ +} while(0) +/* n = 0 ~ 7 */ +#define __tve_set_notch_width() (REG_TVE_WSSCR |= TVE_WSSCR_NCHW_BIT) +#define __tve_clear_notch_width() (REG_TVE_WSSCR &= ~TVE_WSSCR_NCHW_BIT) +#define __tve_enable_notch() (REG_TVE_WSSCR |= TVE_WSSCR_ENCH_BIT) +#define __tve_disable_notch() (REG_TVE_WSSCR &= ~TVE_WSSCR_ENCH_BIT) +/* n = 0 ~ 7 */ +#define __tve_set_wss_edge(n) \ +do { \ + REG_TVE_WSSCR &= ~TVE_WSSCR_WSSEDGE_MASK; \ + REG_TVE_WSSCR |= (n) << TVE_WSSCR_WSSEDGE_BIT; \ +} while(0) +#define __tve_set_wss_clkbyp() (REG_TVE_WSSCR |= TVE_WSSCR_WSSCKBP_BIT) +#define __tve_set_wss_type() (REG_TVE_WSSCR |= TVE_WSSCR_WSSTP_BIT) +#define __tve_enable_wssf1() (REG_TVE_WSSCR |= TVE_WSSCR_EWSS1_BIT) +#define __tve_enable_wssf0() (REG_TVE_WSSCR |= TVE_WSSCR_EWSS0_BIT) + +/* TV Encoder Wide Screen Signal Configure register 1, 2 and 3 ops */ +/* n = 0 ~ 1023 */ +#define __tve_set_wss_level(n) \ +do { \ + REG_TVE_WSSCFG1 &= ~TVE_WSSCFG1_WSSL_MASK; \ + REG_TVE_WSSCFG1 |= (n) << TVE_WSSCFG1_WSSL_BIT; \ +} while(0) +/* n = 0 ~ 4095 */ +#define __tve_set_wss_freq(n) \ +do { \ + REG_TVE_WSSCFG1 &= ~TVE_WSSCFG1_WSSFREQ_MASK; \ + REG_TVE_WSSCFG1 |= (n) << TVE_WSSCFG1_WSSFREQ_BIT; \ +} while(0) +/* n = 0, 1; l = 0 ~ 255 */ +#define __tve_set_wss_line(n,v) \ +do { \ + REG_TVE_WSSCFG##n &= ~TVE_WSSCFG_WSSLINE_MASK; \ + REG_TVE_WSSCFG##n |= (v) << TVE_WSSCFG_WSSLINE_BIT; \ +} while(0) +/* n = 0, 1; d = 0 ~ (2^20-1) */ +#define __tve_set_wss_data(n, v) \ +do { \ + REG_TVE_WSSCFG##n &= ~TVE_WSSCFG_WSSLINE_MASK; \ + REG_TVE_WSSCFG##n |= (v) << TVE_WSSCFG_WSSLINE_BIT; \ +} while(0) + +#endif /* __MIPS_ASSEMBLER */ + +#define UART0_BASE 0xB0030000 +#define UART1_BASE 0xB0031000 +#define UART2_BASE 0xB0032000 +#define UART3_BASE 0xB0033000 + +/************************************************************************* + * UART + *************************************************************************/ + +#define IRDA_BASE UART0_BASE +#define UART_BASE UART0_BASE +#define UART_OFF 0x1000 + +/* Register Offset */ +#define OFF_RDR (0x00) /* R 8b H'xx */ +#define OFF_TDR (0x00) /* W 8b H'xx */ +#define OFF_DLLR (0x00) /* RW 8b H'00 */ +#define OFF_DLHR (0x04) /* RW 8b H'00 */ +#define OFF_IER (0x04) /* RW 8b H'00 */ +#define OFF_ISR (0x08) /* R 8b H'01 */ +#define OFF_FCR (0x08) /* W 8b H'00 */ +#define OFF_LCR (0x0C) /* RW 8b H'00 */ +#define OFF_MCR (0x10) /* RW 8b H'00 */ +#define OFF_LSR (0x14) /* R 8b H'00 */ +#define OFF_MSR (0x18) /* R 8b H'00 */ +#define OFF_SPR (0x1C) /* RW 8b H'00 */ +#define OFF_SIRCR (0x20) /* RW 8b H'00, UART0 */ +#define OFF_UMR (0x24) /* RW 8b H'00, UART M Register */ +#define OFF_UACR (0x28) /* RW 8b H'00, UART Add Cycle Register */ + +/* Register Address */ +#define UART0_RDR (UART0_BASE + OFF_RDR) +#define UART0_TDR (UART0_BASE + OFF_TDR) +#define UART0_DLLR (UART0_BASE + OFF_DLLR) +#define UART0_DLHR (UART0_BASE + OFF_DLHR) +#define UART0_IER (UART0_BASE + OFF_IER) +#define UART0_ISR (UART0_BASE + OFF_ISR) +#define UART0_FCR (UART0_BASE + OFF_FCR) +#define UART0_LCR (UART0_BASE + OFF_LCR) +#define UART0_MCR (UART0_BASE + OFF_MCR) +#define UART0_LSR (UART0_BASE + OFF_LSR) +#define UART0_MSR (UART0_BASE + OFF_MSR) +#define UART0_SPR (UART0_BASE + OFF_SPR) +#define UART0_SIRCR (UART0_BASE + OFF_SIRCR) +#define UART0_UMR (UART0_BASE + OFF_UMR) +#define UART0_UACR (UART0_BASE + OFF_UACR) + +#define UART1_RDR (UART1_BASE + OFF_RDR) +#define UART1_TDR (UART1_BASE + OFF_TDR) +#define UART1_DLLR (UART1_BASE + OFF_DLLR) +#define UART1_DLHR (UART1_BASE + OFF_DLHR) +#define UART1_IER (UART1_BASE + OFF_IER) +#define UART1_ISR (UART1_BASE + OFF_ISR) +#define UART1_FCR (UART1_BASE + OFF_FCR) +#define UART1_LCR (UART1_BASE + OFF_LCR) +#define UART1_MCR (UART1_BASE + OFF_MCR) +#define UART1_LSR (UART1_BASE + OFF_LSR) +#define UART1_MSR (UART1_BASE + OFF_MSR) +#define UART1_SPR (UART1_BASE + OFF_SPR) +#define UART1_SIRCR (UART1_BASE + OFF_SIRCR) + +#define UART2_RDR (UART2_BASE + OFF_RDR) +#define UART2_TDR (UART2_BASE + OFF_TDR) +#define UART2_DLLR (UART2_BASE + OFF_DLLR) +#define UART2_DLHR (UART2_BASE + OFF_DLHR) +#define UART2_IER (UART2_BASE + OFF_IER) +#define UART2_ISR (UART2_BASE + OFF_ISR) +#define UART2_FCR (UART2_BASE + OFF_FCR) +#define UART2_LCR (UART2_BASE + OFF_LCR) +#define UART2_MCR (UART2_BASE + OFF_MCR) +#define UART2_LSR (UART2_BASE + OFF_LSR) +#define UART2_MSR (UART2_BASE + OFF_MSR) +#define UART2_SPR (UART2_BASE + OFF_SPR) +#define UART2_SIRCR (UART2_BASE + OFF_SIRCR) + +#define UART3_RDR (UART3_BASE + OFF_RDR) +#define UART3_TDR (UART3_BASE + OFF_TDR) +#define UART3_DLLR (UART3_BASE + OFF_DLLR) +#define UART3_DLHR (UART3_BASE + OFF_DLHR) +#define UART3_IER (UART3_BASE + OFF_IER) +#define UART3_ISR (UART3_BASE + OFF_ISR) +#define UART3_FCR (UART3_BASE + OFF_FCR) +#define UART3_LCR (UART3_BASE + OFF_LCR) +#define UART3_MCR (UART3_BASE + OFF_MCR) +#define UART3_LSR (UART3_BASE + OFF_LSR) +#define UART3_MSR (UART3_BASE + OFF_MSR) +#define UART3_SPR (UART3_BASE + OFF_SPR) +#define UART3_SIRCR (UART3_BASE + OFF_SIRCR) + +/* + * Define macros for UARTIER + * UART Interrupt Enable Register + */ +#define UARTIER_RIE (1 << 0) /* 0: receive fifo full interrupt disable */ +#define UARTIER_TIE (1 << 1) /* 0: transmit fifo empty interrupt disable */ +#define UARTIER_RLIE (1 << 2) /* 0: receive line status interrupt disable */ +#define UARTIER_MIE (1 << 3) /* 0: modem status interrupt disable */ +#define UARTIER_RTIE (1 << 4) /* 0: receive timeout interrupt disable */ + +/* + * Define macros for UARTISR + * UART Interrupt Status Register + */ +#define UARTISR_IP (1 << 0) /* 0: interrupt is pending 1: no interrupt */ +#define UARTISR_IID (7 << 1) /* Source of Interrupt */ +#define UARTISR_IID_MSI (0 << 1) /* Modem status interrupt */ +#define UARTISR_IID_THRI (1 << 1) /* Transmitter holding register empty */ +#define UARTISR_IID_RDI (2 << 1) /* Receiver data interrupt */ +#define UARTISR_IID_RLSI (3 << 1) /* Receiver line status interrupt */ +#define UARTISR_IID_RTO (6 << 1) /* Receive timeout */ +#define UARTISR_FFMS (3 << 6) /* FIFO mode select, set when UARTFCR.FE is set to 1 */ +#define UARTISR_FFMS_NO_FIFO (0 << 6) +#define UARTISR_FFMS_FIFO_MODE (3 << 6) + +/* + * Define macros for UARTFCR + * UART FIFO Control Register + */ +#define UARTFCR_FE (1 << 0) /* 0: non-FIFO mode 1: FIFO mode */ +#define UARTFCR_RFLS (1 << 1) /* write 1 to flush receive FIFO */ +#define UARTFCR_TFLS (1 << 2) /* write 1 to flush transmit FIFO */ +#define UARTFCR_DMS (1 << 3) /* 0: disable DMA mode */ +#define UARTFCR_UUE (1 << 4) /* 0: disable UART */ +#define UARTFCR_RTRG (3 << 6) /* Receive FIFO Data Trigger */ +#define UARTFCR_RTRG_1 (0 << 6) +#define UARTFCR_RTRG_4 (1 << 6) +#define UARTFCR_RTRG_8 (2 << 6) +#define UARTFCR_RTRG_15 (3 << 6) + +/* + * Define macros for UARTLCR + * UART Line Control Register + */ +#define UARTLCR_WLEN (3 << 0) /* word length */ +#define UARTLCR_WLEN_5 (0 << 0) +#define UARTLCR_WLEN_6 (1 << 0) +#define UARTLCR_WLEN_7 (2 << 0) +#define UARTLCR_WLEN_8 (3 << 0) +#define UARTLCR_STOP (1 << 2) /* 0: 1 stop bit when word length is 5,6,7,8 + 1: 1.5 stop bits when 5; 2 stop bits when 6,7,8 */ +#define UARTLCR_STOP1 (0 << 2) +#define UARTLCR_STOP2 (1 << 2) +#define UARTLCR_PE (1 << 3) /* 0: parity disable */ +#define UARTLCR_PROE (1 << 4) /* 0: even parity 1: odd parity */ +#define UARTLCR_SPAR (1 << 5) /* 0: sticky parity disable */ +#define UARTLCR_SBRK (1 << 6) /* write 0 normal, write 1 send break */ +#define UARTLCR_DLAB (1 << 7) /* 0: access UARTRDR/TDR/IER 1: access UARTDLLR/DLHR */ + +/* + * Define macros for UARTLSR + * UART Line Status Register + */ +#define UARTLSR_DR (1 << 0) /* 0: receive FIFO is empty 1: receive data is ready */ +#define UARTLSR_ORER (1 << 1) /* 0: no overrun error */ +#define UARTLSR_PER (1 << 2) /* 0: no parity error */ +#define UARTLSR_FER (1 << 3) /* 0; no framing error */ +#define UARTLSR_BRK (1 << 4) /* 0: no break detected 1: receive a break signal */ +#define UARTLSR_TDRQ (1 << 5) /* 1: transmit FIFO half "empty" */ +#define UARTLSR_TEMT (1 << 6) /* 1: transmit FIFO and shift registers empty */ +#define UARTLSR_RFER (1 << 7) /* 0: no receive error 1: receive error in FIFO mode */ + +/* + * Define macros for UARTMCR + * UART Modem Control Register + */ +#define UARTMCR_RTS (1 << 1) /* 0: RTS_ output high, 1: RTS_ output low */ +#define UARTMCR_LOOP (1 << 4) /* 0: normal 1: loopback mode */ +#define UARTMCR_FCM (1 << 6) /* 0: software 1: hardware */ +#define UARTMCR_MCE (1 << 7) /* 0: modem function is disable */ + +/* + * Define macros for UARTMSR + * UART Modem Status Register + */ +#define UARTMSR_CCTS (1 << 0) /* 1: a change on CTS_ pin */ +#define UARTMSR_CTS (1 << 4) /* 0: CTS_ pin is high */ + +/* + * Define macros for SIRCR + * Slow IrDA Control Register + */ +#define SIRCR_TSIRE (1 << 0) /* 0: transmitter is in UART mode 1: SIR mode */ +#define SIRCR_RSIRE (1 << 1) /* 0: receiver is in UART mode 1: SIR mode */ +#define SIRCR_TPWS (1 << 2) /* 0: transmit 0 pulse width is 3/16 of bit length + 1: 0 pulse width is 1.6us for 115.2Kbps */ +#define SIRCR_TDPL (1 << 3) /* 0: encoder generates a positive pulse for 0 */ +#define SIRCR_RDPL (1 << 4) /* 0: decoder interprets positive pulse as 0 */ + +#ifndef __MIPS_ASSEMBLER + +/*************************************************************************** + * UART + ***************************************************************************/ +#define __jtag_as_uart3() \ +do { \ + REG_GPIO_PXSELC(0) = 0x40000000; \ + REG_GPIO_PXSELS(0) = 0x80000000; \ +} while(0) + +#define __uart_enable(n) \ + ( REG8(UART_BASE + UART_OFF*(n) + OFF_FCR) |= UARTFCR_UUE | UARTFCR_FE ) +#define __uart_disable(n) \ + ( REG8(UART_BASE + UART_OFF*(n) + OFF_FCR) = ~UARTFCR_UUE ) + +#define __uart_enable_transmit_irq(n) \ + ( REG8(UART_BASE + UART_OFF*(n) + OFF_IER) |= UARTIER_TIE ) +#define __uart_disable_transmit_irq(n) \ + ( REG8(UART_BASE + UART_OFF*(n) + OFF_IER) &= ~UARTIER_TIE ) + +#define __uart_enable_receive_irq(n) \ + ( REG8(UART_BASE + UART_OFF*(n) + OFF_IER) |= UARTIER_RIE | UARTIER_RLIE | UARTIER_RTIE ) +#define __uart_disable_receive_irq(n) \ + ( REG8(UART_BASE + UART_OFF*(n) + OFF_IER) &= ~(UARTIER_RIE | UARTIER_RLIE | UARTIER_RTIE) ) + +#define __uart_enable_loopback(n) \ + ( REG8(UART_BASE + UART_OFF*(n) + OFF_MCR) |= UARTMCR_LOOP ) +#define __uart_disable_loopback(n) \ + ( REG8(UART_BASE + UART_OFF*(n) + OFF_MCR) &= ~UARTMCR_LOOP ) + +#define __uart_set_8n1(n) \ + ( REG8(UART_BASE + UART_OFF*(n) + OFF_LCR) = UARTLCR_WLEN_8 ) + +#define __uart_set_baud(n, devclk, baud) \ + do { \ + REG8(UART_BASE + UART_OFF*(n) + OFF_LCR) |= UARTLCR_DLAB; \ + REG8(UART_BASE + UART_OFF*(n) + OFF_DLLR) = (devclk / 16 / baud) & 0xff; \ + REG8(UART_BASE + UART_OFF*(n) + OFF_DLHR) = ((devclk / 16 / baud) >> 8) & 0xff; \ + REG8(UART_BASE + UART_OFF*(n) + OFF_LCR) &= ~UARTLCR_DLAB; \ + } while (0) + +#define __uart_parity_error(n) \ + ( (REG8(UART_BASE + UART_OFF*(n) + OFF_LSR) & UARTLSR_PER) != 0 ) + +#define __uart_clear_errors(n) \ + ( REG8(UART_BASE + UART_OFF*(n) + OFF_LSR) &= ~(UARTLSR_ORER | UARTLSR_BRK | UARTLSR_FER | UARTLSR_PER | UARTLSR_RFER) ) + +#define __uart_transmit_fifo_empty(n) \ + ( (REG8(UART_BASE + UART_OFF*(n) + OFF_LSR) & UARTLSR_TDRQ) != 0 ) + +#define __uart_transmit_end(n) \ + ( (REG8(UART_BASE + UART_OFF*(n) + OFF_LSR) & UARTLSR_TEMT) != 0 ) + +#define __uart_transmit_char(n, ch) \ + REG8(UART_BASE + UART_OFF*(n) + OFF_TDR) = (ch) + +#define __uart_receive_fifo_full(n) \ + ( (REG8(UART_BASE + UART_OFF*(n) + OFF_LSR) & UARTLSR_DR) != 0 ) + +#define __uart_receive_ready(n) \ + ( (REG8(UART_BASE + UART_OFF*(n) + OFF_LSR) & UARTLSR_DR) != 0 ) + +#define __uart_receive_char(n) \ + REG8(UART_BASE + UART_OFF*(n) + OFF_RDR) + +#define __uart_disable_irda() \ + ( REG8(IRDA_BASE + OFF_SIRCR) &= ~(SIRCR_TSIRE | SIRCR_RSIRE) ) +#define __uart_enable_irda() \ + /* Tx high pulse as 0, Rx low pulse as 0 */ \ + ( REG8(IRDA_BASE + OFF_SIRCR) = SIRCR_TSIRE | SIRCR_RSIRE | SIRCR_RXPL | SIRCR_TPWS ) + +#endif /* __MIPS_ASSEMBLER */ + +/* + * Watchdog timer module(WDT) address definition + */ +#define WDT_BASE 0xb0002000 + +/* + * WDT registers offset address definition + */ +#define WDT_WDR_OFFSET (0x00) /* rw, 16, 0x???? */ +#define WDT_WCER_OFFSET (0x04) /* rw, 8, 0x00 */ +#define WDT_WCNT_OFFSET (0x08) /* rw, 16, 0x???? */ +#define WDT_WCSR_OFFSET (0x0c) /* rw, 16, 0x0000 */ + +/* + * WDT registers address definition + */ +#define WDT_WDR (WDT_BASE + WDT_WDR_OFFSET) +#define WDT_WCER (WDT_BASE + WDT_WCER_OFFSET) +#define WDT_WCNT (WDT_BASE + WDT_WCNT_OFFSET) +#define WDT_WCSR (WDT_BASE + WDT_WCSR_OFFSET) + +/* + * WDT registers common define + */ + +/* Watchdog counter enable register(WCER) */ +#define WCER_TCEN BIT0 + +/* Watchdog control register(WCSR) */ +#define WCSR_PRESCALE_LSB 3 +#define WCSR_PRESCALE_MASK BITS_H2L(5, WCSR_PRESCALE_LSB) +#define WCSR_PRESCALE1 (0x0 << WCSR_PRESCALE_LSB) +#define WCSR_PRESCALE4 (0x1 << WCSR_PRESCALE_LSB) +#define WCSR_PRESCALE16 (0x2 << WCSR_PRESCALE_LSB) +#define WCSR_PRESCALE64 (0x3 << WCSR_PRESCALE_LSB) +#define WCSR_PRESCALE256 (0x4 << WCSR_PRESCALE_LSB) +#define WCSR_PRESCALE1024 (0x5 << WCSR_PRESCALE_LSB) + +#define WCSR_CLKIN_LSB 0 +#define WCSR_CLKIN_MASK BITS_H2L(2, WCSR_CLKIN_LSB) +#define WCSR_CLKIN_PCK (0x1 << WCSR_CLKIN_LSB) +#define WCSR_CLKIN_RTC (0x2 << WCSR_CLKIN_LSB) +#define WCSR_CLKIN_EXT (0x4 << WCSR_CLKIN_LSB) + +#ifndef __MIPS_ASSEMBLER + +#define REG_WDT_WDR REG16(WDT_WDR) +#define REG_WDT_WCER REG8(WDT_WCER) +#define REG_WDT_WCNT REG16(WDT_WCNT) +#define REG_WDT_WCSR REG16(WDT_WCSR) + +#endif /* __MIPS_ASSEMBLER */ + +/* + * Operating system timer module(OST) address definition + */ +#define OST_BASE 0xb0002000 + +/* + * OST registers offset address definition + */ +#define OST_OSTDR_OFFSET (0xe0) /* rw, 32, 0x???????? */ +#define OST_OSTCNT_OFFSET (0xe4) /* rw, 32, 0x???????? */ +#define OST_OSTCNTL_OFFSET (0xe4) /* rw, 32, 0x???????? */ +#define OST_OSTCNTH_OFFSET (0xe8) /* rw, 32, 0x???????? */ +#define OST_OSTCSR_OFFSET (0xec) /* rw, 16, 0x0000 */ +#define OST_OSTCNTHBUF_OFFSET (0xfc) /* r, 32, 0x???????? */ + +/* + * OST registers address definition + */ +#define OST_OSTDR (OST_BASE + OST_OSTDR_OFFSET) +#define OST_OSTCNT (OST_BASE + OST_OSTCNT_OFFSET) +#define OST_OSTCNTL (OST_BASE + OST_OSTCNTL_OFFSET) +#define OST_OSTCNTH (OST_BASE + OST_OSTCNTH_OFFSET) +#define OST_OSTCSR (OST_BASE + OST_OSTCSR_OFFSET) +#define OST_OSTCNTHBUF (OST_BASE + OST_OSTCNTHBUF_OFFSET) + +/* + * OST registers common define + */ + +/* Operating system control register(OSTCSR) */ +#define OSTCSR_CNT_MD BIT15 +#define OSTCSR_SD BIT9 +#define OSTCSR_EXT_EN BIT2 +#define OSTCSR_RTC_EN BIT1 +#define OSTCSR_PCK_EN BIT0 + +#define OSTCSR_PRESCALE_LSB 3 +#define OSTCSR_PRESCALE_MASK BITS_H2L(5, OSTCSR_PRESCALE_LSB) +#define OSTCSR_PRESCALE1 (0x0 << OSTCSR_PRESCALE_LSB) +#define OSTCSR_PRESCALE4 (0x1 << OSTCSR_PRESCALE_LSB) +#define OSTCSR_PRESCALE16 (0x2 << OSTCSR_PRESCALE_LSB) +#define OSTCSR_PRESCALE64 (0x3 << OSTCSR_PRESCALE_LSB) +#define OSTCSR_PRESCALE256 (0x4 << OSTCSR_PRESCALE_LSB) +#define OSTCSR_PRESCALE1024 (0x5 << OSTCSR_PRESCALE_LSB) + +#ifndef __MIPS_ASSEMBLER + +#define REG_OST_OSTDR REG32(OST_OSTDR) +#define REG_OST_OSTCNT REG32(OST_OSTCNT) +#define REG_OST_OSTCNTL REG32(OST_OSTCNTL) +#define REG_OST_OSTCNTH REG32(OST_OSTCNTH) +#define REG_OST_OSTCSR REG16(OST_OSTCSR) +#define REG_OST_OSTCNTHBUF REG32(OST_OSTCNTHBUF) + +#endif /* __MIPS_ASSEMBLER */ + +#define AOSD_BASE 0xB3070000 + +/************************************************************************* + * OSD (On Screen Display) + *************************************************************************/ +#define AOSD_ADDR0 (AOSD_BASE + 0x00) +#define AOSD_ADDR1 (AOSD_BASE + 0x04) +#define AOSD_ADDR2 (AOSD_BASE + 0x08) +#define AOSD_ADDR3 (AOSD_BASE + 0x0C) +#define AOSD_WADDR (AOSD_BASE + 0x10) +#define AOSD_ADDRLEN (AOSD_BASE + 0x14) +#define AOSD_ALPHA_VALUE (AOSD_BASE + 0x18) +#define AOSD_CTRL (AOSD_BASE + 0x1C) +#define AOSD_INT (AOSD_BASE + 0x20) + +#define REG_AOSD_ADDR0 REG32(AOSD_ADDR0) +#define REG_AOSD_ADDR1 REG32(AOSD_ADDR1) +#define REG_AOSD_ADDR2 REG32(AOSD_ADDR2) +#define REG_AOSD_ADDR3 REG32(AOSD_ADDR3) +#define REG_AOSD_WADDR REG32(AOSD_WADDR) +#define REG_AOSD_ADDRLEN REG32(AOSD_ADDRLEN) +#define REG_AOSD_ALPHA_VALUE REG32(AOSD_ALPHA_VALUE) +#define REG_AOSD_CTRL REG32(AOSD_CTRL) +#define REG_AOSD_INT REG32(AOSD_INT) + +#define AOSD_CTRL_FRMLV_MASK (0x3 << 18) +#define AOSD_CTRL_FRMLV_2 (0x1 << 18) +#define AOSD_CTRL_FRMLV_3 (0x2 << 18) +#define AOSD_CTRL_FRMLV_4 (0x3 << 18) + +#define AOSD_CTRL_FRM_END (1 << 17) +#define AOSD_CTRL_ALPHA_START (1 << 16) +#define AOSD_CTRL_INT_MAKS (1 << 15) +#define AOSD_CTRL_CHANNEL_LEVEL_BIT 7 +#define AOSD_CTRL_CHANNEL_LEVEL_MASK (0xff << AOSD_CTRL_CHANNEL_LEVEL_BIT) +#define AOSD_CTRL_ALPHA_MODE_BIT 3 +#define AOSD_CTRL_ALPHA_MODE_MASK (0xf << AOSD_CTRL_ALPHA_MODE_BIT) +#define AOSD_CTRL_ALPHA_PIXEL_MODE 0 +#define AOSD_CTRL_ALPHA_FRAME_MODE 1 + +#define AOSD_CTRL_FORMAT_MODE_BIT 1 +#define AOSD_CTRL_FORMAT_MODE_MASK (0x3 << 1) +#define AOSD_CTRL_RGB565_FORMAT_MODE (0 << AOSD_CTRL_FORMAT_MODE_BIT) +#define AOSD_CTRL_RGB555_FORMAT_MODE (1 << AOSD_CTRL_FORMAT_MODE_BIT) +#define AOSD_CTRL_RGB8888_FORMAT_MODE (2 << AOSD_CTRL_FORMAT_MODE_BIT) + +#define AOSD_ALPHA_ENABLE (1 << 0) + +#define AOSD_INT_COMPRESS_END (1 << 1) +#define AOSD_INT_AOSD_END (1 << 0) + +#define __osd_enable_alpha() (REG_AOSD_CTRL |= AOSD_ALPHA_ENABLE) +#define __osd_alpha_start() (REG_AOSD_CTRL |= AOSD_CTRL_ALPHA_START) + +/************************************************************************* + * COMPRESS + *************************************************************************/ +#define COMPRESS_SCR_ADDR (AOSD_BASE + 0x00) +#define COMPRESS_DES_ADDR (AOSD_BASE + 0x10) +#define COMPRESS_DST_OFFSET (AOSD_BASE + 0x34) +#define COMPRESS_FRAME_SIZE (AOSD_BASE + 0x38) +#define COMPRESS_CTRL (AOSD_BASE + 0x3C) +#define COMPRESS_RATIO (AOSD_BASE + 0x40) +#define COMPRESS_SRC_OFFSET (AOSD_BASE + 0x44) + +#define REG_COMPRESS_SCR_ADDR REG32(COMPRESS_SCR_ADDR) +#define REG_COMPRESS_DES_ADDR REG32(COMPRESS_DES_ADDR) +#define REG_COMPRESS_DST_OFFSET REG32(COMPRESS_DST_OFFSET) +#define REG_COMPRESS_FRAME_SIZE REG32(COMPRESS_FRAME_SIZE) +#define REG_COMPRESS_CTRL REG32(COMPRESS_CTRL) +#define REG_COMPRESS_RATIO REG32(COMPRESS_RATIO) +#define REG_COMPRESS_SRC_OFFSET REG32(COMPRESS_SRC_OFFSET) + +#define COMPRESS_CTRL_WITHOUT_ALPHA (1 << 4) +#define COMPRESS_CTRL_WITH_ALPHA (0 << 4) +#define COMPRESS_CTRL_COMP_START (1 << 3) +#define COMPRESS_CTRL_COMP_END (1 << 2) +#define COMPRESS_CTRL_INT_MASK (1 << 1) +#define COMPRESS_CTRL_COMP_ENABLE (1 << 0) + +#define COMPRESS_RATIO_FRM_BYPASS (1 << 31) +#define COMPRESS_BYPASS_ROW (1 << 12) +#define COMPRESS_ROW_QUARTER (1 << 0) + +#define COMPRESS_CTRL_ALIGNED_MODE_BIT (31) +#define COMPRESS_CTRL_ALIGNED_16_WORD (0 << COMPRESS_CTRL_ALIGNED_MODE_BIT) +#define COMPRESS_CTRL_ALIGNED_64_WORD (1 << COMPRESS_CTRL_ALIGNED_MODE_BIT) + +#define __compress_enable() (REG_COMPRESS_CTRL |= COMPRESS_INT_AOSD_END) +#define __compress_start() (REG_COMPRESS_CTRL |= COMPRESS_CTRL_COMP_START) +#define __compress_with_alpha() (REG_COMPRESS_CTRL |= COMPRESS_CTRL_ALPHA_EN) + +/* Rockbox defines */ + +/* Timer frequency */ +#define TIMER_FREQ (CFG_EXTAL) /* For full precision! */ + +/* Serial */ +#define CFG_UART_BASE UART1_BASE /* Base of the UART channel */ +#define CFG_BAUDRATE 57600 + +#endif /* __JZ4760B_H__ */ diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 4cfcbbd56d..60565b1573 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -129,7 +129,7 @@ static int battery_type = 0; /* Power history: power_history[0] is the newest sample */ unsigned short power_history[POWER_HISTORY_LEN] = {0}; -#if CONFIG_CPU == JZ4732 /* FIXME! */ || (CONFIG_PLATFORM & PLATFORM_HOSTED) +#if (CONFIG_CPU == JZ4732) || (CONFIG_CPU == JZ4760B) || (CONFIG_PLATFORM & PLATFORM_HOSTED) static char power_stack[DEFAULT_STACK_SIZE + POWERMGMT_DEBUG_STACK]; #else static char power_stack[DEFAULT_STACK_SIZE/2 + POWERMGMT_DEBUG_STACK]; diff --git a/firmware/sound.c b/firmware/sound.c index a19cc15c41..eb66f34c5d 100644 --- a/firmware/sound.c +++ b/firmware/sound.c @@ -324,6 +324,16 @@ void sound_set_filter_roll_off(int value) } #endif +#if defined(AUDIOHW_HAVE_FUNCTIONAL_MODE) +void sound_set_functional_mode(int value) +{ + if (!audio_is_initialized) + return; + + audiohw_set_functional_mode(value); +} +#endif + #if defined(AUDIOHW_HAVE_EQ) int sound_enum_hw_eq_band_setting(unsigned int band, unsigned int band_setting) diff --git a/firmware/target/hosted/sdl/sim-ui-defines.h b/firmware/target/hosted/sdl/sim-ui-defines.h index 1ac124c881..b237842711 100644 --- a/firmware/target/hosted/sdl/sim-ui-defines.h +++ b/firmware/target/hosted/sdl/sim-ui-defines.h @@ -508,6 +508,7 @@ #define UI_LCD_POSX 46 #define UI_LCD_POSY 40 +<<<<<<< HEAD #elif defined(SONY_NWZA860) #define UI_TITLE "Sony NWZ-A860 Series" #define UI_WIDTH 390 /* width of GUI window */ @@ -521,6 +522,12 @@ #define UI_HEIGHT 380 #define UI_LCD_POSX 29 #define UI_LCD_POSY 25 +#elif defined(XDUOO_X3) +#define UI_TITLE "xDuoo X3" +#define UI_WIDTH 192 /* width of GUI window */ +#define UI_HEIGHT 457 /* height of GUI window */ +#define UI_LCD_POSX 34 +#define UI_LCD_POSY 73 #elif defined(SIMULATOR) #error no UI defines #endif diff --git a/firmware/target/mips/ingenic_jz47xx/app.lds b/firmware/target/mips/ingenic_jz47xx/app.lds index a8ac6ff0bf..85c332b182 100644 --- a/firmware/target/mips/ingenic_jz47xx/app.lds +++ b/firmware/target/mips/ingenic_jz47xx/app.lds @@ -5,8 +5,10 @@ OUTPUT_ARCH(MIPS) ENTRY(_start) STARTUP(target/mips/ingenic_jz47xx/crt0.o) -#define DRAMORIG 0x80004000 -#define DRAMSIZE (MEMORYSIZE * 0x100000) +#define STUBOFFSET 0x4000 + +#define DRAMORIG (0x80000000 + STUBOFFSET) +#define DRAMSIZE (MEMORYSIZE * 0x100000 - STUBOFFSET) #define IRAMORIG 0x80000000 #define IRAMSIZE 16K diff --git a/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c index ac4092f043..0ce0ed1e19 100644 --- a/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c @@ -20,7 +20,7 @@ ****************************************************************************/ #include "config.h" -#include "jz4740.h" +#include "cpu.h" #include "nand.h" #include "nand_id.h" #include "system.h" diff --git a/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4760.c b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4760.c new file mode 100644 index 0000000000..b3cc589528 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4760.c @@ -0,0 +1,692 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include "nand.h" +#include "nand_id.h" +#include "system.h" +#include "panic.h" +#include "kernel.h" +#include "storage.h" +#include "string.h" +/*#define LOGF_ENABLE*/ +#include "logf.h" + +//#define USE_DMA +//#define USE_ECC + +/* + * Standard NAND flash commands + */ +#define NAND_CMD_READ0 0 +#define NAND_CMD_READ1 1 +#define NAND_CMD_RNDOUT 5 +#define NAND_CMD_PAGEPROG 0x10 +#define NAND_CMD_READOOB 0x50 +#define NAND_CMD_ERASE1 0x60 +#define NAND_CMD_STATUS 0x70 +#define NAND_CMD_STATUS_MULTI 0x71 +#define NAND_CMD_SEQIN 0x80 +#define NAND_CMD_RNDIN 0x85 +#define NAND_CMD_READID 0x90 +#define NAND_CMD_ERASE2 0xd0 +#define NAND_CMD_RESET 0xff + +/* Extended commands for large page devices */ +#define NAND_CMD_READSTART 0x30 +#define NAND_CMD_RNDOUTSTART 0xE0 +#define NAND_CMD_CACHEDPROG 0x15 + +/* Status bits */ +#define NAND_STATUS_FAIL 0x01 +#define NAND_STATUS_FAIL_N1 0x02 +#define NAND_STATUS_TRUE_READY 0x20 +#define NAND_STATUS_READY 0x40 +#define NAND_STATUS_WP 0x80 + +/* + * NAND parameter struct + */ +struct nand_param { + unsigned int bus_width; /* data bus width: 8-bit/16-bit */ + unsigned int row_cycle; /* row address cycles: 2/3 */ + unsigned int page_size; /* page size in bytes: 512/2048/4096 */ + unsigned int oob_size; /* oob size in bytes: 16/64/128 */ + unsigned int page_per_block; /* pages per block: 32/64/128 */ + unsigned int bad_block_pos; /* bad block pos in oob: 0/5 */ +}; + +/* + * jz4760_nand.c + * + * NAND read routine for JZ4760 + * + * Copyright (c) 2005-2008 Ingenic Semiconductor Inc. + * + */ + +#define CFG_NAND_BASE 0xBA000000 +#define NAND_ADDR_OFFSET 0x00800000 +#define NAND_CMD_OFFSET 0x00400000 + +#define CFG_NAND_SMCR1 0x0d444400 + +#define NAND_DATAPORT CFG_NAND_BASE +#define NAND_ADDRPORT (CFG_NAND_BASE | NAND_ADDR_OFFSET) +#define NAND_COMMPORT (CFG_NAND_BASE | NAND_CMD_OFFSET) + +#define ECC_BLOCK 512 +#define ECC_POS 24 +#define PAR_SIZE 13 + +#define __nand_cmd(n) (REG8(NAND_COMMPORT) = (n)) +#define __nand_addr(n) (REG8(NAND_ADDRPORT) = (n)) +#define __nand_data8() (REG8(NAND_DATAPORT)) +#define __nand_data16() (REG16(NAND_DATAPORT)) + +#define __nand_select() (REG_NEMC_NFCSR |= NEMC_NFCSR_NFE1 | NEMC_NFCSR_NFCE1) +#define __nand_deselect() (REG_NEMC_NFCSR &= ~(NEMC_NFCSR_NFE1 | NEMC_NFCSR_NFCE1)) + +/*--------------------------------------------------------------*/ + +static struct nand_info* chip_info = NULL; +static struct nand_info* bank; +static unsigned long nand_size; +static struct nand_param internal_param; +static struct mutex nand_mtx; +#ifdef USE_DMA +static struct mutex nand_dma_mtx; +static struct semaphore nand_dma_complete; +#endif +static unsigned char temp_page[2048]; /* Max page size */ + +static inline void jz_nand_wait_ready(void) +{ + unsigned int timeout = 1000; + while ((REG_GPIO_PXPIN(0) & 0x00100000) && timeout--); + while (!(REG_GPIO_PXPIN(0) & 0x00100000)); +} + +#ifndef USE_DMA +static inline void jz_nand_read_buf16(void *buf, int count) +{ + register int i; + register unsigned short *p = (unsigned short *)buf; + + for (i = 0; i < count; i += 2) + *p++ = __nand_data16(); +} + +static inline void jz_nand_read_buf8(void *buf, int count) +{ + register int i; + register unsigned char *p = (unsigned char *)buf; + + for (i = 0; i < count; i++) + *p++ = __nand_data8(); +} +#else +static void jz_nand_write_dma(void *source, unsigned int len, int bw) +{ + mutex_lock(&nand_dma_mtx); + + if(((unsigned int)source < 0xa0000000) && len) + dma_cache_wback_inv((unsigned long)source, len); + + dma_enable(); + + REG_DMAC_DCCSR(DMA_NAND_CHANNEL) = DMAC_DCCSR_NDES; + REG_DMAC_DSAR(DMA_NAND_CHANNEL) = PHYSADDR((unsigned long)source); + REG_DMAC_DTAR(DMA_NAND_CHANNEL) = PHYSADDR((unsigned long)NAND_DATAPORT); + REG_DMAC_DTCR(DMA_NAND_CHANNEL) = len / 16; + REG_DMAC_DRSR(DMA_NAND_CHANNEL) = DMAC_DRSR_RS_AUTO; + REG_DMAC_DCMD(DMA_NAND_CHANNEL) = (DMAC_DCMD_SAI| DMAC_DCMD_DAI | DMAC_DCMD_SWDH_32 | DMAC_DCMD_DS_16BYTE | + (bw == 8 ? DMAC_DCMD_DWDH_8 : DMAC_DCMD_DWDH_16)); + + REG_DMAC_DCCSR(DMA_NAND_CHANNEL) |= DMAC_DCCSR_EN; /* Enable DMA channel */ +#if 1 + while( REG_DMAC_DTCR(DMA_NAND_CHANNEL) ) + yield(); +#else + REG_DMAC_DCMD(DMA_NAND_CHANNEL) |= DMAC_DCMD_TIE; /* Enable DMA interrupt */ + semaphore_wait(&nand_dma_complete, TIMEOUT_BLOCK); +#endif + + REG_DMAC_DCCSR(DMA_NAND_CHANNEL) &= ~DMAC_DCCSR_EN; /* Disable DMA channel */ + + dma_disable(); + + mutex_unlock(&nand_dma_mtx); +} + +static void jz_nand_read_dma(void *target, unsigned int len, int bw) +{ + mutex_lock(&nand_dma_mtx); + + if(((unsigned int)target < 0xa0000000) && len) + dma_cache_wback_inv((unsigned long)target, len); + + dma_enable(); + + REG_DMAC_DCCSR(DMA_NAND_CHANNEL) = DMAC_DCCSR_NDES ; + REG_DMAC_DSAR(DMA_NAND_CHANNEL) = PHYSADDR((unsigned long)NAND_DATAPORT); + REG_DMAC_DTAR(DMA_NAND_CHANNEL) = PHYSADDR((unsigned long)target); + REG_DMAC_DTCR(DMA_NAND_CHANNEL) = len / 4; + REG_DMAC_DRSR(DMA_NAND_CHANNEL) = DMAC_DRSR_RS_AUTO; + REG_DMAC_DCMD(DMA_NAND_CHANNEL) = (DMAC_DCMD_SAI| DMAC_DCMD_DAI | DMAC_DCMD_DWDH_32 | DMAC_DCMD_DS_32BIT | + (bw == 8 ? DMAC_DCMD_SWDH_8 : DMAC_DCMD_SWDH_16)); + REG_DMAC_DCCSR(DMA_NAND_CHANNEL) |= DMAC_DCCSR_EN; /* Enable DMA channel */ +#if 1 + while( REG_DMAC_DTCR(DMA_NAND_CHANNEL) ) + yield(); +#else + REG_DMAC_DCMD(DMA_NAND_CHANNEL) |= DMAC_DCMD_TIE; /* Enable DMA interrupt */ + semaphore_wait(&nand_dma_complete, TIMEOUT_BLOCK); +#endif + + //REG_DMAC_DCCSR(DMA_NAND_CHANNEL) &= ~DMAC_DCCSR_EN; /* Disable DMA channel */ + + dma_disable(); + + mutex_unlock(&nand_dma_mtx); +} + +void DMA_CALLBACK(DMA_NAND_CHANNEL)(void) +{ + if (REG_DMAC_DCCSR(DMA_NAND_CHANNEL) & DMAC_DCCSR_HLT) + REG_DMAC_DCCSR(DMA_NAND_CHANNEL) &= ~DMAC_DCCSR_HLT; + + if (REG_DMAC_DCCSR(DMA_NAND_CHANNEL) & DMAC_DCCSR_AR) + REG_DMAC_DCCSR(DMA_NAND_CHANNEL) &= ~DMAC_DCCSR_AR; + + if (REG_DMAC_DCCSR(DMA_NAND_CHANNEL) & DMAC_DCCSR_CT) + REG_DMAC_DCCSR(DMA_NAND_CHANNEL) &= ~DMAC_DCCSR_CT; + + if (REG_DMAC_DCCSR(DMA_NAND_CHANNEL) & DMAC_DCCSR_TT) + REG_DMAC_DCCSR(DMA_NAND_CHANNEL) &= ~DMAC_DCCSR_TT; + + semaphore_release(&nand_dma_complete); +} +#endif /* USE_DMA */ + +static inline void jz_nand_read_buf(void *buf, int count, int bw) +{ +#ifdef USE_DMA + if (bw == 8) + jz_nand_read_dma(buf, count, 8); + else + jz_nand_read_dma(buf, count, 16); +#else + if (bw == 8) + jz_nand_read_buf8(buf, count); + else + jz_nand_read_buf16(buf, count); +#endif +} + +#ifdef USE_ECC +/* + * Correct 1~9-bit errors in 512-bytes data + */ +static void jz_rs_correct(unsigned char *dat, int idx, int mask) +{ + int i, j; + unsigned short d, d1, dm; + + i = (idx * 9) >> 3; + j = (idx * 9) & 0x7; + + i = (j == 0) ? (i - 1) : i; + j = (j == 0) ? 7 : (j - 1); + + if (i > 512) + return; + + if (i == 512) + d = dat[i - 1]; + else + d = (dat[i] << 8) | dat[i - 1]; + + d1 = (d >> j) & 0x1ff; + d1 ^= mask; + + dm = ~(0x1ff << j); + d = (d & dm) | (d1 << j); + + dat[i - 1] = d & 0xff; + if (i < 512) + dat[i] = (d >> 8) & 0xff; +} +#endif + +/* + * Read oob + */ +static int jz_nand_read_oob(unsigned long page_addr, unsigned char *buf, int size) +{ + struct nand_param *nandp = &internal_param; + int page_size, row_cycle, bus_width; + int col_addr; + + page_size = nandp->page_size; + row_cycle = nandp->row_cycle; + bus_width = nandp->bus_width; + + if (page_size >= 2048) + col_addr = page_size; + else + col_addr = 0; + + if (page_size >= 2048) + /* Send READ0 command */ + __nand_cmd(NAND_CMD_READ0); + else + /* Send READOOB command */ + __nand_cmd(NAND_CMD_READOOB); + + /* Send column address */ + __nand_addr(col_addr & 0xff); + if (page_size >= 2048) + __nand_addr((col_addr >> 8) & 0xff); + + /* Send page address */ + __nand_addr(page_addr & 0xff); + __nand_addr((page_addr >> 8) & 0xff); + if (row_cycle == 3) + __nand_addr((page_addr >> 16) & 0xff); + + /* Send READSTART command for 2048 ps NAND */ + if (page_size >= 2048) + __nand_cmd(NAND_CMD_READSTART); + + /* Wait for device ready */ + jz_nand_wait_ready(); + + /* Read oob data */ + jz_nand_read_buf(buf, size, bus_width); + + return 0; +} + + +/* + * nand_read_page() + * + * Input: + * + * block - block number: 0, 1, 2, ... + * page - page number within a block: 0, 1, 2, ... + * dst - pointer to target buffer + */ +static int jz_nand_read_page(unsigned long page_addr, unsigned char *dst) +{ + struct nand_param *nandp = &internal_param; + int page_size, oob_size, page_per_block; + int row_cycle, bus_width, ecc_count; + int i; +#ifdef USE_ECC + int j; +#endif + unsigned char *data_buf; + unsigned char oob_buf[nandp->oob_size]; + + page_size = nandp->page_size; + oob_size = nandp->oob_size; + page_per_block = nandp->page_per_block; + row_cycle = nandp->row_cycle; + bus_width = nandp->bus_width; + + /* + * Read oob data + */ + jz_nand_read_oob(page_addr, oob_buf, oob_size); + + /* + * Read page data + */ + + /* Send READ0 command */ + __nand_cmd(NAND_CMD_READ0); + + /* Send column address */ + __nand_addr(0); + if (page_size >= 2048) + __nand_addr(0); + + /* Send page address */ + __nand_addr(page_addr & 0xff); + __nand_addr((page_addr >> 8) & 0xff); + if (row_cycle >= 3) + __nand_addr((page_addr >> 16) & 0xff); + + /* Send READSTART command for 2048 ps NAND */ + if (page_size >= 2048) + __nand_cmd(NAND_CMD_READSTART); + + /* Wait for device ready */ + jz_nand_wait_ready(); + + /* Read page data */ + data_buf = dst; + + ecc_count = page_size / ECC_BLOCK; + + for (i = 0; i < ecc_count; i++) + { +#ifdef USE_ECC + volatile unsigned char *paraddr = (volatile unsigned char *)EMC_NFPAR0; + unsigned int stat; + + /* Enable RS decoding */ + REG_EMC_NFINTS = 0x0; + __ecc_decoding_4bit(); +#endif + + /* Read data */ + jz_nand_read_buf((void *)data_buf, ECC_BLOCK, bus_width); + +#ifdef USE_ECC + /* Set PAR values */ + for (j = 0; j < PAR_SIZE; j++) + *paraddr++ = oob_buf[ECC_POS + i*PAR_SIZE + j]; + + /* Set PRDY */ + REG_EMC_NFECR |= EMC_NFECR_PRDY; + + /* Wait for completion */ + __ecc_decode_sync(); + + /* Disable decoding */ + __ecc_disable(); + + /* Check result of decoding */ + stat = REG_EMC_NFINTS; + if (stat & EMC_NFINTS_ERR) + { + /* Error occurred */ + if (stat & EMC_NFINTS_UNCOR) + { + /* Uncorrectable error occurred */ + logf("Uncorrectable ECC error at NAND page address 0x%lx", page_addr); + return -1; + } + else + { + unsigned int errcnt, index, mask; + + errcnt = (stat & EMC_NFINTS_ERRCNT_MASK) >> EMC_NFINTS_ERRCNT_BIT; + switch (errcnt) + { + case 4: + index = (REG_EMC_NFERR3 & EMC_NFERR_INDEX_MASK) >> EMC_NFERR_INDEX_BIT; + mask = (REG_EMC_NFERR3 & EMC_NFERR_MASK_MASK) >> EMC_NFERR_MASK_BIT; + jz_rs_correct(data_buf, index, mask); + case 3: + index = (REG_EMC_NFERR2 & EMC_NFERR_INDEX_MASK) >> EMC_NFERR_INDEX_BIT; + mask = (REG_EMC_NFERR2 & EMC_NFERR_MASK_MASK) >> EMC_NFERR_MASK_BIT; + jz_rs_correct(data_buf, index, mask); + case 2: + index = (REG_EMC_NFERR1 & EMC_NFERR_INDEX_MASK) >> EMC_NFERR_INDEX_BIT; + mask = (REG_EMC_NFERR1 & EMC_NFERR_MASK_MASK) >> EMC_NFERR_MASK_BIT; + jz_rs_correct(data_buf, index, mask); + case 1: + index = (REG_EMC_NFERR0 & EMC_NFERR_INDEX_MASK) >> EMC_NFERR_INDEX_BIT; + mask = (REG_EMC_NFERR0 & EMC_NFERR_MASK_MASK) >> EMC_NFERR_MASK_BIT; + jz_rs_correct(data_buf, index, mask); + break; + default: + break; + } + } + } +#endif + + data_buf += ECC_BLOCK; + } + + return 0; +} + +static int jz_nand_init(void) +{ + unsigned char cData[5]; + + __gpio_as_nand_16bit(1); + + REG_NEMC_SMCR1 = CFG_NAND_SMCR1 | 0x40; + + __nand_select(); + + __nand_cmd(NAND_CMD_READID); + __nand_addr(NAND_CMD_READ0); + cData[0] = __nand_data8(); + cData[1] = __nand_data8(); + cData[2] = __nand_data8(); + cData[3] = __nand_data8(); + cData[4] = __nand_data8(); + + __nand_deselect(); + + logf("NAND chip %d: 0x%x 0x%x 0x%x 0x%x 0x%x", i+1, cData[0], cData[1], + cData[2], cData[3], cData[4]); + + bank = nand_identify(cData); + + if(bank == NULL) + { + panicf("Unknown NAND flash chip: 0x%x 0x%x 0x%x 0x%x 0x%x", cData[0], + cData[1], cData[2], cData[3], cData[4]); + return -1; /* panicf() doesn't return though */ + } + + chip_info = bank; + + internal_param.bus_width = 16; + internal_param.row_cycle = chip_info->row_cycles; + internal_param.page_size = chip_info->page_size; + internal_param.oob_size = chip_info->spare_size; + internal_param.page_per_block = chip_info->pages_per_block; + internal_param.bad_block_pos = 0; + + nand_size = ((chip_info->page_size * chip_info->blocks_per_bank * chip_info->pages_per_block) - 0x200000) / 512; + + return 0; +} + +int nand_init(void) +{ + int res = 0; + static bool inited = false; + + if(!inited) + { + res = jz_nand_init(); + mutex_init(&nand_mtx); +#ifdef USE_DMA + mutex_init(&nand_dma_mtx); + semaphore_init(&nand_dma_complete, 1, 0); + system_enable_irq(DMA_IRQ(DMA_NAND_CHANNEL)); +#endif + + inited = true; + } + + return res; +} + +static inline int read_sector(unsigned long start, unsigned int count, + void* buf, unsigned int chip_size) +{ + register int ret; + + if(UNLIKELY(start % chip_size == 0 && count == chip_size)) + ret = jz_nand_read_page(start / chip_size, buf); + else + { + ret = jz_nand_read_page(start / chip_size, temp_page); + memcpy(buf, temp_page + (start % chip_size), count); + } + + return ret; +} + +static inline int write_sector(unsigned long start, unsigned int count, + const void* buf, unsigned int chip_size) +{ + int ret = 0; + + (void)start; + (void)count; + (void)buf; + (void)chip_size; + + /* TODO */ + + return ret; +} + +int nand_read_sectors(IF_MV(int drive,) unsigned long start, int count, void* buf) +{ +#ifdef HAVE_MULTIVOLUME + (void)drive; +#endif + int ret = 0; + unsigned int _count, chip_size = chip_info->page_size; + unsigned long _start; + + logf("start"); + mutex_lock(&nand_mtx); + + _start = start << 9; + _start += 0x200000; /* skip BL */ + _count = count << 9; + + __nand_select(); + ret = read_sector(_start, _count, buf, chip_size); + __nand_deselect(); + + mutex_unlock(&nand_mtx); + + logf("nand_read_sectors(%ld, %d, 0x%x): %d", start, count, (int)buf, ret); + + return ret; +} + +int nand_write_sectors(IF_MV(int drive,) unsigned long start, int count, const void* buf) +{ +#ifdef HAVE_MULTIVOLUME + (void)drive; +#endif + int ret = 0; + unsigned int _count, chip_size = chip_info->page_size; + unsigned long _start; + + logf("start"); + mutex_lock(&nand_mtx); + + _start = start << 9; + _start += chip_info->page_size * chip_info->pages_per_block; /* skip BL */ + _count = count << 9; + + __nand_select(); + ret = write_sector(_start, _count, buf, chip_size); + __nand_deselect(); + + mutex_unlock(&nand_mtx); + + logf("nand_write_sectors(%ld, %d, 0x%x): %d", start, count, (int)buf, ret); + + return ret; +} + +#ifdef HAVE_STORAGE_FLUSH +int nand_flush(void) +{ + return 0; +} +#endif + +void nand_spindown(int seconds) +{ + /* null */ + (void)seconds; +} + +void nand_sleep(void) +{ + /* null */ +} + +void nand_spin(void) +{ + /* null */ +} + +void nand_enable(bool on) +{ + /* null - flash controller is enabled/disabled as needed. */ + (void)on; +} + +/* TODO */ +long nand_last_disk_activity(void) +{ + return 0; +} + +int nand_spinup_time(void) +{ + return 0; +} + +void nand_sleepnow(void) +{ +} + +#ifdef STORAGE_GET_INFO +void nand_get_info(IF_MV(int drive,) struct storage_info *info) +{ +#ifdef HAVE_MULTIVOLUME + (void)drive; +#endif + + /* firmware version */ + info->revision="0.00"; + + info->vendor="Rockbox"; + info->product="NAND Storage"; + + /* blocks count */ + info->num_sectors = nand_size; + info->sector_size = 512; +} +#endif + +#ifdef CONFIG_STORAGE_MULTI +int nand_num_drives(int first_drive) +{ + /* We don't care which logical drive number(s) we have been assigned */ + (void)first_drive; + + return 1; +} +#endif diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c index 9565551df6..9215d7d08a 100644 --- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c @@ -21,7 +21,7 @@ #include "config.h" #include "gcc_extensions.h" -#include "jz4740.h" +#include "cpu.h" #include "ata-sd-target.h" #include "led.h" #include "sdmmc.h" diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4760.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4760.c new file mode 100644 index 0000000000..c34f74a202 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4760.c @@ -0,0 +1,1487 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "gcc_extensions.h" +#include "cpu.h" +#include "ata-sd-target.h" +#include "dma-target.h" +#include "led.h" +#include "sdmmc.h" +#include "logf.h" +#include "storage.h" +#include "string.h" + +static long last_disk_activity = -1; +static tCardInfo card[NUM_DRIVES]; + +static struct mutex sd_mtx; +static struct semaphore sd_wakeup; + +static int use_4bit[NUM_DRIVES]; +static int num_6[NUM_DRIVES]; +static int sd2_0[NUM_DRIVES]; + +#define SD_DMA_ENABLE 1 + +//#define DEBUG(x...) logf(x) +#define DEBUG(x, ...) + +/* volumes */ +#define SD_SLOT_1 0 /* SD card 1 */ +#define SD_SLOT_2 1 /* SD card 2 */ + +#define MSC_CHN(n) (2-n) + +#define SD_IRQ_MASK(n) \ +do { \ + REG_MSC_IMASK(n) = 0xffff; \ + REG_MSC_IREG(n) = 0xffff; \ +} while (0) + +/* Error codes */ +enum sd_result_t +{ + SD_NO_RESPONSE = -1, + SD_NO_ERROR = 0, + SD_ERROR_OUT_OF_RANGE, + SD_ERROR_ADDRESS, + SD_ERROR_BLOCK_LEN, + SD_ERROR_ERASE_SEQ, + SD_ERROR_ERASE_PARAM, + SD_ERROR_WP_VIOLATION, + SD_ERROR_CARD_IS_LOCKED, + SD_ERROR_LOCK_UNLOCK_FAILED, + SD_ERROR_COM_CRC, + SD_ERROR_ILLEGAL_COMMAND, + SD_ERROR_CARD_ECC_FAILED, + SD_ERROR_CC, + SD_ERROR_GENERAL, + SD_ERROR_UNDERRUN, + SD_ERROR_OVERRUN, + SD_ERROR_CID_CSD_OVERWRITE, + SD_ERROR_STATE_MISMATCH, + SD_ERROR_HEADER_MISMATCH, + SD_ERROR_TIMEOUT, + SD_ERROR_CRC, + SD_ERROR_DRIVER_FAILURE, +}; + +/* Standard MMC/SD clock speeds */ +#define MMC_CLOCK_SLOW 400000 /* 400 kHz for initial setup */ +#define SD_CLOCK_FAST 24000000 /* 24 MHz for SD Cards */ +#define SD_CLOCK_HIGH 48000000 /* 48 MHz for SD Cards */ + +/* Extra commands for state control */ +/* Use negative numbers to disambiguate */ +#define SD_CIM_RESET -1 + +/* Proprietary commands, illegal/reserved according to SD Specification 2.00 */ + /* class 1 */ +#define SD_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */ + + /* class 3 */ +#define SD_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */ + + /* class 4 */ +#define SD_PROGRAM_CID 26 /* adtc R1 */ +#define SD_PROGRAM_CSD 27 /* adtc R1 */ + + /* class 9 */ +#define SD_GO_IRQ_STATE 40 /* bcr R5 */ + +/* Don't change the order of these; they are used in dispatch tables */ +enum sd_rsp_t +{ + RESPONSE_NONE = 0, + RESPONSE_R1 = 1, + RESPONSE_R1B = 2, + RESPONSE_R2_CID = 3, + RESPONSE_R2_CSD = 4, + RESPONSE_R3 = 5, + RESPONSE_R4 = 6, + RESPONSE_R5 = 7, + RESPONSE_R6 = 8, + RESPONSE_R7 = 9, +}; + +/* + MMC status in R1 + Type + e : error bit + s : status bit + r : detected and set for the actual command response + x : detected and set during command execution. the host must poll + the card by sending status command in order to read these bits. + Clear condition + a : according to the card state + b : always related to the previous command. Reception of + a valid command will clear it (with a delay of one command) + c : clear by read + */ + +#define R1_OUT_OF_RANGE (1 << 31) /* er, c */ +#define R1_ADDRESS_ERROR (1 << 30) /* erx, c */ +#define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */ +#define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */ +#define R1_ERASE_PARAM (1 << 27) /* ex, c */ +#define R1_WP_VIOLATION (1 << 26) /* erx, c */ +#define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */ +#define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */ +#define R1_COM_CRC_ERROR (1 << 23) /* er, b */ +#define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */ +#define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */ +#define R1_CC_ERROR (1 << 20) /* erx, c */ +#define R1_ERROR (1 << 19) /* erx, c */ +#define R1_UNDERRUN (1 << 18) /* ex, c */ +#define R1_OVERRUN (1 << 17) /* ex, c */ +#define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */ +#define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */ +#define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */ +#define R1_ERASE_RESET (1 << 13) /* sr, c */ +#define R1_STATUS(x) (x & 0xFFFFE000) +#define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */ +#define R1_READY_FOR_DATA (1 << 8) /* sx, a */ +#define R1_APP_CMD (1 << 7) /* sr, c */ + +/* These are unpacked versions of the actual responses */ +struct sd_response_r1 +{ + unsigned char cmd; + unsigned int status; +}; + +struct sd_response_r3 +{ + unsigned int ocr; +}; + +#define SD_CARD_BUSY 0x80000000 /* Card Power up status bit */ + +struct sd_request +{ + int index; /* Slot index - used for CS lines */ + int cmd; /* Command to send */ + unsigned int arg; /* Argument to send */ + enum sd_rsp_t rtype; /* Response type expected */ + + /* Data transfer (these may be modified at the low level) */ + unsigned short nob; /* Number of blocks to transfer*/ + unsigned short block_len; /* Block length */ + unsigned char *buffer; /* Data buffer */ + unsigned int cnt; /* Data length, for PIO */ + + /* Results */ + unsigned char response[18]; /* Buffer to store response - CRC is optional */ + enum sd_result_t result; +}; + +#define SD_OCR_ARG 0x00ff8000 /* Argument of OCR */ + +/*********************************************************************** + * SD Events + */ +#define SD_EVENT_NONE 0x00 /* No events */ +#define SD_EVENT_RX_DATA_DONE 0x01 /* Rx data done */ +#define SD_EVENT_TX_DATA_DONE 0x02 /* Tx data done */ +#define SD_EVENT_PROG_DONE 0x04 /* Programming is done */ + +/************************************************************************** + * Utility functions + **************************************************************************/ + +#define PARSE_U32(_buf,_index) \ + (((unsigned int)_buf[_index]) << 24) | (((unsigned int)_buf[_index+1]) << 16) | \ + (((unsigned int)_buf[_index+2]) << 8) | ((unsigned int)_buf[_index+3]); + +#define PARSE_U16(_buf,_index) \ + (((unsigned short)_buf[_index]) << 8) | ((unsigned short)_buf[_index+1]); + +static int sd_unpack_r1(struct sd_request *request, struct sd_response_r1 *r1) +{ + unsigned char *buf = request->response; + + if (request->result) + return request->result; + + r1->cmd = buf[0]; + r1->status = PARSE_U32(buf,1); + + DEBUG("sd_unpack_r1: cmd=%d status=%08x", r1->cmd, r1->status); + + if (R1_STATUS(r1->status)) { + if (r1->status & R1_OUT_OF_RANGE) return SD_ERROR_OUT_OF_RANGE; + if (r1->status & R1_ADDRESS_ERROR) return SD_ERROR_ADDRESS; + if (r1->status & R1_BLOCK_LEN_ERROR) return SD_ERROR_BLOCK_LEN; + if (r1->status & R1_ERASE_SEQ_ERROR) return SD_ERROR_ERASE_SEQ; + if (r1->status & R1_ERASE_PARAM) return SD_ERROR_ERASE_PARAM; + if (r1->status & R1_WP_VIOLATION) return SD_ERROR_WP_VIOLATION; + //if (r1->status & R1_CARD_IS_LOCKED) return SD_ERROR_CARD_IS_LOCKED; + if (r1->status & R1_LOCK_UNLOCK_FAILED) return SD_ERROR_LOCK_UNLOCK_FAILED; + if (r1->status & R1_COM_CRC_ERROR) return SD_ERROR_COM_CRC; + if (r1->status & R1_ILLEGAL_COMMAND) return SD_ERROR_ILLEGAL_COMMAND; + if (r1->status & R1_CARD_ECC_FAILED) return SD_ERROR_CARD_ECC_FAILED; + if (r1->status & R1_CC_ERROR) return SD_ERROR_CC; + if (r1->status & R1_ERROR) return SD_ERROR_GENERAL; + if (r1->status & R1_UNDERRUN) return SD_ERROR_UNDERRUN; + if (r1->status & R1_OVERRUN) return SD_ERROR_OVERRUN; + if (r1->status & R1_CID_CSD_OVERWRITE) return SD_ERROR_CID_CSD_OVERWRITE; + } + + if (buf[0] != request->cmd) + return SD_ERROR_HEADER_MISMATCH; + + /* This should be last - it's the least dangerous error */ + + return 0; +} + +static int sd_unpack_r6(struct sd_request *request, struct sd_response_r1 *r1, unsigned long *rca) +{ + unsigned char *buf = request->response; + + if (request->result) + return request->result; + + *rca = PARSE_U16(buf,1); /* Save RCA returned by the SD Card */ + + *(buf+1) = 0; + *(buf+2) = 0; + + return sd_unpack_r1(request, r1); +} + +static int sd_unpack_r3(struct sd_request *request, struct sd_response_r3 *r3) +{ + unsigned char *buf = request->response; + + if (request->result) return request->result; + + r3->ocr = PARSE_U32(buf,1); + DEBUG("sd_unpack_r3: ocr=%08x", r3->ocr); + + if (buf[0] != 0x3f) + return SD_ERROR_HEADER_MISMATCH; + + return 0; +} + +/* Stop the MMC clock and wait while it happens */ +static inline int jz_sd_stop_clock(const int drive) +{ + register int timeout = 1000; + + //DEBUG("stop MMC clock"); + REG_MSC_STRPCL(MSC_CHN(drive)) = MSC_STRPCL_CLOCK_CONTROL_STOP; + + while (timeout && (REG_MSC_STAT(MSC_CHN(drive)) & MSC_STAT_CLK_EN)) + { + timeout--; + if (timeout == 0) + { + DEBUG("Timeout on stop clock waiting"); + return SD_ERROR_TIMEOUT; + } + udelay(1); + } + //DEBUG("clock off time is %d microsec", timeout); + return SD_NO_ERROR; +} + +/* Start the MMC clock and operation */ +static inline int jz_sd_start_clock(const int drive) +{ + REG_MSC_STRPCL(MSC_CHN(drive)) = MSC_STRPCL_CLOCK_CONTROL_START | MSC_STRPCL_START_OP; + return SD_NO_ERROR; +} + +static int jz_sd_check_status(const int drive, struct sd_request *request) +{ + (void)request; + unsigned int status = REG_MSC_STAT(MSC_CHN(drive)); + + /* Checking for response or data timeout */ + if (status & (MSC_STAT_TIME_OUT_RES | MSC_STAT_TIME_OUT_READ)) + { + DEBUG("SD timeout, MSC_STAT 0x%x CMD %d", status, + request->cmd); + return SD_ERROR_TIMEOUT; + } + + /* Checking for CRC error */ + if (status & + (MSC_STAT_CRC_READ_ERROR | MSC_STAT_CRC_WRITE_ERROR | + MSC_STAT_CRC_RES_ERR)) + { + DEBUG("SD CRC error, MSC_STAT 0x%x", status); + return SD_ERROR_CRC; + + } + + + /* Checking for FIFO empty */ + /*if(status & MSC_STAT_DATA_FIFO_EMPTY && request->rtype != RESPONSE_NONE) + { + DEBUG("SD FIFO empty, MSC_STAT 0x%x", status); + return SD_ERROR_UNDERRUN; + }*/ + + return SD_NO_ERROR; +} + +/* Obtain response to the command and store it to response buffer */ +static void jz_sd_get_response(const int drive, struct sd_request *request) +{ + int i; + unsigned char *buf; + unsigned int data; + + DEBUG("fetch response for request %d, cmd %d", request->rtype, + request->cmd); + buf = request->response; + request->result = SD_NO_ERROR; + + switch (request->rtype) + { + case RESPONSE_R1: + case RESPONSE_R1B: + case RESPONSE_R7: + case RESPONSE_R6: + case RESPONSE_R3: + case RESPONSE_R4: + case RESPONSE_R5: + { + data = REG_MSC_RES(MSC_CHN(drive)); + buf[0] = (data >> 8) & 0xff; + buf[1] = data & 0xff; + data = REG_MSC_RES(MSC_CHN(drive)); + buf[2] = (data >> 8) & 0xff; + buf[3] = data & 0xff; + data = REG_MSC_RES(MSC_CHN(drive)); + buf[4] = data & 0xff; + + DEBUG("request %d, response [%02x %02x %02x %02x %02x]", + request->rtype, buf[0], buf[1], buf[2], + buf[3], buf[4]); + break; + } + case RESPONSE_R2_CID: + case RESPONSE_R2_CSD: + { + for (i = 0; i < 16; i += 2) + { + data = REG_MSC_RES(MSC_CHN(drive)); + buf[i] = (data >> 8) & 0xff; + buf[i + 1] = data & 0xff; + } + DEBUG("request %d, response []", request->rtype); + break; + } + case RESPONSE_NONE: + DEBUG("No response"); + break; + + default: + DEBUG("unhandled response type for request %d", + request->rtype); + break; + } +} + +static int jz_sd_receive_data(const int drive, struct sd_request *req) +{ + unsigned int nob = req->nob; + unsigned int wblocklen = (unsigned int) (req->block_len + 3) >> 2; /* length in word */ + unsigned char *buf = req->buffer; + unsigned int *wbuf = (unsigned int *) buf; + unsigned int waligned = (((unsigned int) buf & 0x3) == 0); /* word aligned ? */ + unsigned int stat, timeout, data, cnt; + + for (; nob >= 1; nob--) + { + timeout = 0x3FFFFFF; + + while (timeout) + { + timeout--; + stat = REG_MSC_STAT(MSC_CHN(drive)); + + if (stat & MSC_STAT_TIME_OUT_READ) + return SD_ERROR_TIMEOUT; + else if (stat & MSC_STAT_CRC_READ_ERROR) + return SD_ERROR_CRC; + else if (!(stat & MSC_STAT_DATA_FIFO_EMPTY) + || (stat & MSC_STAT_DATA_FIFO_AFULL)) + /* Ready to read data */ + break; + + udelay(1); + } + + if (!timeout) + return SD_ERROR_TIMEOUT; + + /* Read data from RXFIFO. It could be FULL or PARTIAL FULL */ + DEBUG("Receive Data = %d", wblocklen); + cnt = wblocklen; + while (cnt) + { + data = REG_MSC_RXFIFO(MSC_CHN(drive)); + if (waligned) + *wbuf++ = data; + else + { + *buf++ = (unsigned char) (data >> 0); + *buf++ = (unsigned char) (data >> 8); + *buf++ = (unsigned char) (data >> 16); + *buf++ = (unsigned char) (data >> 24); + } + cnt--; + while (cnt + && (REG_MSC_STAT(MSC_CHN(drive)) & + MSC_STAT_DATA_FIFO_EMPTY)); + } + } + + return SD_NO_ERROR; +} + +static int jz_sd_transmit_data(const int drive, struct sd_request *req) +{ + unsigned int nob = req->nob; + unsigned int wblocklen = (unsigned int) (req->block_len + 3) >> 2; /* length in word */ + unsigned char *buf = req->buffer; + unsigned int *wbuf = (unsigned int *) buf; + unsigned int waligned = (((unsigned int) buf & 0x3) == 0); /* word aligned ? */ + unsigned int stat, timeout, data, cnt; + + for (; nob >= 1; nob--) + { + timeout = 0x3FFFFFF; + + while (timeout) + { + timeout--; + stat = REG_MSC_STAT(MSC_CHN(drive)); + + if (stat & + (MSC_STAT_CRC_WRITE_ERROR | + MSC_STAT_CRC_WRITE_ERROR_NOSTS)) + return SD_ERROR_CRC; + else if (!(stat & MSC_STAT_DATA_FIFO_FULL)) + /* Ready to write data */ + break; + + udelay(1); + } + + if (!timeout) + return SD_ERROR_TIMEOUT; + + /* Write data to TXFIFO */ + cnt = wblocklen; + while (cnt) + { + while (REG_MSC_STAT(MSC_CHN(drive)) & MSC_STAT_DATA_FIFO_FULL); + + if (waligned) + REG_MSC_TXFIFO(MSC_CHN(drive)) = *wbuf++; + else + { + data = *buf++; + data |= *buf++ << 8; + data |= *buf++ << 16; + data |= *buf++ << 24; + REG_MSC_TXFIFO(MSC_CHN(drive)) = data; + } + + cnt--; + } + } + + return SD_NO_ERROR; +} + +#if SD_DMA_ENABLE +static void jz_sd_receive_data_dma(const int drive, struct sd_request *req) +{ + unsigned int waligned = (((unsigned int)req->buffer & 0x3) == 0); /* word aligned ? */ + unsigned int size = req->block_len * req->nob; + + if (!waligned) + { + jz_sd_receive_data(drive, req); + return; + } + + /* flush dcache */ + dma_cache_wback_inv((unsigned long) req->buffer, size); + + /* setup dma channel */ + REG_DMAC_DCCSR(DMA_SD_RX_CHANNEL) = 0; + REG_DMAC_DSAR(DMA_SD_RX_CHANNEL) = PHYSADDR(MSC_RXFIFO(MSC_CHN(drive))); /* DMA source addr */ + REG_DMAC_DTAR(DMA_SD_RX_CHANNEL) = PHYSADDR((unsigned long)req->buffer); /* DMA dest addr */ + REG_DMAC_DTCR(DMA_SD_RX_CHANNEL) = (size + 3) >> 2; /* DMA transfer count */ + REG_DMAC_DRSR(DMA_SD_RX_CHANNEL) = (drive == SD_SLOT_1) ? DMAC_DRSR_RS_MSC2IN : DMAC_DRSR_RS_MSC1IN; /* DMA request type */ + + REG_DMAC_DCMD(DMA_SD_RX_CHANNEL) = + DMAC_DCMD_DAI | DMAC_DCMD_SWDH_32 | DMAC_DCMD_DWDH_32 | + DMAC_DCMD_DS_32BIT; + REG_DMAC_DCCSR(DMA_SD_RX_CHANNEL) = DMAC_DCCSR_EN | DMAC_DCCSR_NDES; + + /* wait for dma completion */ + while (REG_DMAC_DTCR(DMA_SD_RX_CHANNEL)); + + /* clear status and disable channel */ + REG_DMAC_DCCSR(DMA_SD_RX_CHANNEL) = 0; +} + +static void jz_sd_transmit_data_dma(const int drive, struct sd_request *req) +{ + unsigned int waligned = (((unsigned int)req->buffer & 0x3) == 0); /* word aligned ? */ + unsigned int size = req->block_len * req->nob; + + if (!waligned) + { + jz_sd_transmit_data(drive, req); + return; + } + + /* flush dcache */ + dma_cache_wback_inv((unsigned long) req->buffer, size); + + /* setup dma channel */ + REG_DMAC_DCCSR(DMA_SD_RX_CHANNEL) = 0; + REG_DMAC_DSAR(DMA_SD_TX_CHANNEL) = PHYSADDR((unsigned long) req->buffer); /* DMA source addr */ + REG_DMAC_DTAR(DMA_SD_TX_CHANNEL) = PHYSADDR(MSC_TXFIFO(MSC_CHN(drive))); /* DMA dest addr */ + REG_DMAC_DTCR(DMA_SD_TX_CHANNEL) = (size + 3) >> 2; /* DMA transfer count */ + REG_DMAC_DRSR(DMA_SD_TX_CHANNEL) = (drive == SD_SLOT_1) ? DMAC_DRSR_RS_MSC2OUT : DMAC_DRSR_RS_MSC1OUT; /* DMA request type */ + + REG_DMAC_DCMD(DMA_SD_TX_CHANNEL) = + DMAC_DCMD_SAI | DMAC_DCMD_SWDH_32 | DMAC_DCMD_DWDH_32 | + DMAC_DCMD_DS_32BIT; + REG_DMAC_DCCSR(DMA_SD_TX_CHANNEL) = DMAC_DCCSR_EN | DMAC_DCCSR_NDES; + + /* wait for dma completion */ + while (REG_DMAC_DTCR(DMA_SD_TX_CHANNEL)); + + /* clear status and disable channel */ + REG_DMAC_DCCSR(DMA_SD_TX_CHANNEL) = 0; +} + +void DMA_CALLBACK(DMA_SD_RX_CHANNEL)(void) +{ + if (REG_DMAC_DCCSR(DMA_SD_RX_CHANNEL) & DMAC_DCCSR_AR) + { + logf("SD RX DMA address error"); + REG_DMAC_DCCSR(DMA_SD_RX_CHANNEL) &= ~DMAC_DCCSR_AR; + } + + if (REG_DMAC_DCCSR(DMA_SD_RX_CHANNEL) & DMAC_DCCSR_HLT) + { + logf("SD RX DMA halt"); + REG_DMAC_DCCSR(DMA_SD_RX_CHANNEL) &= ~DMAC_DCCSR_HLT; + } + + if (REG_DMAC_DCCSR(DMA_SD_RX_CHANNEL) & DMAC_DCCSR_TT) + { + REG_DMAC_DCCSR(DMA_SD_RX_CHANNEL) &= ~DMAC_DCCSR_TT; + //sd_rx_dma_callback(); + } +} + +void DMA_CALLBACK(DMA_SD_TX_CHANNEL)(void) +{ + if (REG_DMAC_DCCSR(DMA_SD_TX_CHANNEL) & DMAC_DCCSR_AR) + { + logf("SD TX DMA address error: %x, %x, %x", var1, var2, var3); + REG_DMAC_DCCSR(DMA_SD_TX_CHANNEL) &= ~DMAC_DCCSR_AR; + } + + if (REG_DMAC_DCCSR(DMA_SD_TX_CHANNEL) & DMAC_DCCSR_HLT) + { + logf("SD TX DMA halt"); + REG_DMAC_DCCSR(DMA_SD_TX_CHANNEL) &= ~DMAC_DCCSR_HLT; + } + + if (REG_DMAC_DCCSR(DMA_SD_TX_CHANNEL) & DMAC_DCCSR_TT) + { + REG_DMAC_DCCSR(DMA_SD_TX_CHANNEL) &= ~DMAC_DCCSR_TT; + //sd_tx_dma_callback(); + } +} +#endif /* SD_DMA_ENABLE */ + +static inline unsigned int jz_sd_calc_clkrt(const int drive, unsigned int rate) +{ + unsigned int clkrt; + unsigned int clk_src = sd2_0[drive] ? SD_CLOCK_HIGH : SD_CLOCK_FAST; + + clkrt = 0; + while (rate < clk_src) + { + clkrt++; + clk_src >>= 1; + } + return clkrt; +} + +static inline void cpm_select_msc_clk(unsigned int rate) +{ + unsigned int div = __cpm_get_pllout2() / rate; + + REG_CPM_MSCCDR = div - 1; +} + +/* Set the MMC clock frequency */ +static void jz_sd_set_clock(const int drive, unsigned int rate) +{ + int clkrt; + + jz_sd_stop_clock(drive); + + /* select clock source from CPM */ + cpm_select_msc_clk(rate); + + __cpm_enable_pll_change(); + clkrt = jz_sd_calc_clkrt(drive, rate); + REG_MSC_CLKRT(MSC_CHN(drive)) = clkrt; + + DEBUG("set clock to %u Hz clkrt=%d", rate, clkrt); +} + +/******************************************************************************************************************** +** Name: int jz_sd_exec_cmd() +** Function: send command to the card, and get a response +** Input: struct sd_request *req: SD request +** Output: 0: right >0: error code +********************************************************************************************************************/ +static int jz_sd_exec_cmd(const int drive, struct sd_request *request) +{ + unsigned int cmdat = 0, events = 0; + int retval, timeout = 0x3fffff; + + /* Indicate we have no result yet */ + request->result = SD_NO_RESPONSE; + + if (request->cmd == SD_CIM_RESET) { + /* On reset, 1-bit bus width */ + use_4bit[drive] = 0; + + /* Reset MMC/SD controller */ + __msc_reset(MSC_CHN(drive)); + + /* On reset, drop SD clock down */ + jz_sd_set_clock(drive, MMC_CLOCK_SLOW); + + /* On reset, stop SD clock */ + jz_sd_stop_clock(drive); + } + if (request->cmd == SD_SET_BUS_WIDTH) + { + if (request->arg == 0x2) + { + DEBUG("Use 4-bit bus width"); + use_4bit[drive] = 1; + } + else + { + DEBUG("Use 1-bit bus width"); + use_4bit[drive] = 0; + } + } + + /* stop clock */ + jz_sd_stop_clock(drive); + + /* mask all interrupts */ + //REG_MSC_IMASK(MSC_CHN(drive)) = 0xffff; + /* clear status */ + REG_MSC_IREG(MSC_CHN(drive)) = 0xffff; + /*open interrupt */ + REG_MSC_IMASK(MSC_CHN(drive)) = (~7); + /* use 4-bit bus width when possible */ + if (use_4bit[drive]) + cmdat |= MSC_CMDAT_BUS_WIDTH_4BIT; + + /* Set command type and events */ + switch (request->cmd) + { + /* SD core extra command */ + case SD_CIM_RESET: + cmdat |= MSC_CMDAT_INIT; /* Initialization sequence sent prior to command */ + break; + /* bc - broadcast - no response */ + case SD_GO_IDLE_STATE: + case SD_SET_DSR: + break; + + /* bcr - broadcast with response */ + case SD_APP_OP_COND: + case SD_ALL_SEND_CID: + case SD_GO_IRQ_STATE: + break; + + /* adtc - addressed with data transfer */ + case SD_READ_DAT_UNTIL_STOP: + case SD_READ_SINGLE_BLOCK: + case SD_READ_MULTIPLE_BLOCK: + case SD_SEND_SCR: +#if SD_DMA_ENABLE + cmdat |= + MSC_CMDAT_DATA_EN | MSC_CMDAT_READ | MSC_CMDAT_DMA_EN; +#else + cmdat |= MSC_CMDAT_DATA_EN | MSC_CMDAT_READ; +#endif + events = SD_EVENT_RX_DATA_DONE; + break; + + case 6: + if (num_6[drive] < 2) + { +#if SD_DMA_ENABLE + cmdat |= + MSC_CMDAT_DATA_EN | MSC_CMDAT_READ | + MSC_CMDAT_DMA_EN; +#else + cmdat |= MSC_CMDAT_DATA_EN | MSC_CMDAT_READ; +#endif + events = SD_EVENT_RX_DATA_DONE; + } + break; + + case SD_WRITE_DAT_UNTIL_STOP: + case SD_WRITE_BLOCK: + case SD_WRITE_MULTIPLE_BLOCK: + case SD_PROGRAM_CID: + case SD_PROGRAM_CSD: + case SD_LOCK_UNLOCK: +#if SD_DMA_ENABLE + cmdat |= + MSC_CMDAT_DATA_EN | MSC_CMDAT_WRITE | MSC_CMDAT_DMA_EN; +#else + cmdat |= MSC_CMDAT_DATA_EN | MSC_CMDAT_WRITE; +#endif + events = SD_EVENT_TX_DATA_DONE | SD_EVENT_PROG_DONE; + break; + + case SD_STOP_TRANSMISSION: + events = SD_EVENT_PROG_DONE; + break; + + /* ac - no data transfer */ + default: + break; + } + + /* Set response type */ + switch (request->rtype) + { + case RESPONSE_NONE: + break; + case RESPONSE_R1B: + cmdat |= MSC_CMDAT_BUSY; + /* FALLTHRU */ + case RESPONSE_R1: + case RESPONSE_R7: + cmdat |= MSC_CMDAT_RESPONSE_R1; + break; + case RESPONSE_R2_CID: + case RESPONSE_R2_CSD: + cmdat |= MSC_CMDAT_RESPONSE_R2; + break; + case RESPONSE_R3: + cmdat |= MSC_CMDAT_RESPONSE_R3; + break; + case RESPONSE_R4: + cmdat |= MSC_CMDAT_RESPONSE_R4; + break; + case RESPONSE_R5: + cmdat |= MSC_CMDAT_RESPONSE_R5; + break; + case RESPONSE_R6: + cmdat |= MSC_CMDAT_RESPONSE_R6; + break; + default: + break; + } + + /* Set command index */ + if (request->cmd == SD_CIM_RESET) + REG_MSC_CMD(MSC_CHN(drive)) = SD_GO_IDLE_STATE; + else + REG_MSC_CMD(MSC_CHN(drive)) = request->cmd; + + /* Set argument */ + REG_MSC_ARG(MSC_CHN(drive)) = request->arg; + + /* Set block length and nob */ + if (request->cmd == SD_SEND_SCR) + { /* get SCR from DataFIFO */ + REG_MSC_BLKLEN(MSC_CHN(drive)) = 8; + REG_MSC_NOB(MSC_CHN(drive)) = 1; + } + else + { + REG_MSC_BLKLEN(MSC_CHN(drive)) = request->block_len; + REG_MSC_NOB(MSC_CHN(drive)) = request->nob; + } + + /* Set command */ + REG_MSC_CMDAT(MSC_CHN(drive)) = cmdat; + + DEBUG("Send cmd %d cmdat: %x arg: %x resp %d", request->cmd, + cmdat, request->arg, request->rtype); + + /* Start SD clock and send command to card */ + jz_sd_start_clock(drive); + + /* Wait for command completion */ + //__intc_unmask_irq(IRQ_MSC); + //semaphore_wait(&sd_wakeup, 100); + while (timeout-- && !(REG_MSC_STAT(MSC_CHN(drive)) & MSC_STAT_END_CMD_RES)); + + + if (timeout == 0) + return SD_ERROR_TIMEOUT; + + REG_MSC_IREG(MSC_CHN(drive)) = MSC_IREG_END_CMD_RES; /* clear flag */ + + /* Check for status */ + retval = jz_sd_check_status(drive, request); + if (retval) + return retval; + + /* Complete command with no response */ + if (request->rtype == RESPONSE_NONE) + return SD_NO_ERROR; + + /* Get response */ + jz_sd_get_response(drive, request); + + /* Start data operation */ + if (events & (SD_EVENT_RX_DATA_DONE | SD_EVENT_TX_DATA_DONE)) + { + if (events & SD_EVENT_RX_DATA_DONE) + { + if (request->cmd == SD_SEND_SCR) + { + /* SD card returns SCR register as data. + SD core expect it in the response buffer, + after normal response. */ + request->buffer = + (unsigned char *) ((unsigned int) request->response + 5); + } +#if SD_DMA_ENABLE + jz_sd_receive_data_dma(drive, request); +#else + jz_sd_receive_data(drive, request); +#endif + } + + if (events & SD_EVENT_TX_DATA_DONE) + { +#if SD_DMA_ENABLE + jz_sd_transmit_data_dma(drive, request); +#else + jz_sd_transmit_data(drive, request); +#endif + } + //__intc_unmask_irq(IRQ_MSC); + //semaphore_wait(&sd_wakeup, 100); + /* Wait for Data Done */ + while (!(REG_MSC_IREG(MSC_CHN(drive)) & MSC_IREG_DATA_TRAN_DONE)); + REG_MSC_IREG(MSC_CHN(drive)) = MSC_IREG_DATA_TRAN_DONE; /* clear status */ + } + + /* Wait for Prog Done event */ + if (events & SD_EVENT_PROG_DONE) + { + //__intc_unmask_irq(IRQ_MSC); + //semaphore_wait(&sd_wakeup, 100); + while (!(REG_MSC_IREG(MSC_CHN(drive)) & MSC_IREG_PRG_DONE)); + REG_MSC_IREG(MSC_CHN(drive)) = MSC_IREG_PRG_DONE; /* clear status */ + } + + /* Command completed */ + + return SD_NO_ERROR; /* return successfully */ +} + +/******************************************************************************************************************* +** Name: int sd_chkcard() +** Function: check whether card is insert entirely +** Input: NULL +** Output: 1: insert entirely 0: not insert entirely +********************************************************************************************************************/ +static int jz_sd_chkcard(const int drive) +{ + return (__gpio_get_pin((drive == SD_SLOT_1) ? PIN_SD1_CD : PIN_SD2_CD) == 0 ? 1 : 0); +} + +/* MSC interrupt handler */ +void MSC(void) +{ + //semaphore_release(&sd_wakeup); + logf("MSC interrupt"); +} + +#ifdef HAVE_HOTSWAP +static void sd_gpio_setup_irq(const int drive, bool inserted) +{ + int pin = (drive == SD_SLOT_1) ? PIN_SD1_CD : PIN_SD2_CD; + int irq = (drive == SD_SLOT_1) ? IRQ_SD1_CD : IRQ_SD2_CD; + if(inserted) + __gpio_as_irq_rise_edge(pin); + else + __gpio_as_irq_fall_edge(pin); + system_enable_irq(irq); +} +#endif + +/******************************************************************************************************************* +** Name: void sd_hardware_init() +** Function: initialize the hardware condiction that access sd card +** Input: NULL +** Output: NULL +********************************************************************************************************************/ +static void jz_sd_hardware_init(const int drive) +{ + if (drive == SD_SLOT_1) + __cpm_start_msc2(); /* enable mmc2 clock */ + else + __cpm_start_msc1(); /* enable mmc1 clock */ +#ifdef HAVE_HOTSWAP + sd_gpio_setup_irq(drive, jz_sd_chkcard(drive)); +#endif + __msc_reset(MSC_CHN(drive)); /* reset mmc/sd controller */ + SD_IRQ_MASK(MSC_CHN(drive)); /* mask all IRQs */ + jz_sd_stop_clock(drive); /* stop SD clock */ +} + +static int sd_send_cmd(const int drive, struct sd_request *request, int cmd, unsigned int arg, + unsigned short nob, unsigned short block_len, + enum sd_rsp_t rtype, unsigned char* buffer) +{ + request->cmd = cmd; + request->arg = arg; + request->rtype = rtype; + request->nob = nob; + request->block_len = block_len; + request->buffer = buffer; + request->cnt = nob * block_len; + + return jz_sd_exec_cmd(drive, request); +} + +static void sd_simple_cmd(const int drive, struct sd_request *request, int cmd, unsigned int arg, + enum sd_rsp_t rtype) +{ + sd_send_cmd(drive, request, cmd, arg, 0, 0, rtype, NULL); +} + +#define SD_INIT_DOING 0 +#define SD_INIT_PASSED 1 +#define SD_INIT_FAILED 2 +static int sd_init_card_state(const int drive, struct sd_request *request) +{ + struct sd_response_r1 r1; + struct sd_response_r3 r3; + int retval, i, ocr = 0x40300000, limit_41 = 0; + + switch (request->cmd) + { + case SD_GO_IDLE_STATE: /* No response to parse */ + sd_simple_cmd(drive, request, SD_SEND_IF_COND, 0x1AA, RESPONSE_R1); + break; + + case SD_SEND_IF_COND: + retval = sd_unpack_r1(request, &r1); + sd_simple_cmd(drive, request, SD_APP_CMD, 0, RESPONSE_R1); + break; + + case SD_APP_CMD: + retval = sd_unpack_r1(request, &r1); + if (retval & (limit_41 < 100)) + { + DEBUG("sd_init_card_state: unable to SD_APP_CMD error=%d", + retval); + limit_41++; + sd_simple_cmd(drive, request, SD_APP_OP_COND, ocr, RESPONSE_R3); + } + else if (limit_41 < 100) + { + limit_41++; + sd_simple_cmd(drive, request, SD_APP_OP_COND, ocr, RESPONSE_R3); + } + else + /* reset the card to idle*/ + sd_simple_cmd(drive, request, SD_GO_IDLE_STATE, 0, RESPONSE_NONE); + break; + + case SD_APP_OP_COND: + retval = sd_unpack_r3(request, &r3); + if (retval) + break; + + DEBUG("sd_init_card_state: read ocr value = 0x%08x", r3.ocr); + card[drive].ocr = r3.ocr; + + if(!(r3.ocr & SD_CARD_BUSY || ocr == 0)) + { + sleep(HZ / 100); + sd_simple_cmd(drive, request, SD_APP_CMD, 0, RESPONSE_R1); + } + else + { + /* Set the data bus width to 4 bits */ + use_4bit[drive] = 1; + sd_simple_cmd(drive, request, SD_ALL_SEND_CID, 0, RESPONSE_R2_CID); + } + break; + + case SD_ALL_SEND_CID: + for(i=0; i<4; i++) + card[drive].cid[i] = ((request->response[1+i*4]<<24) | (request->response[2+i*4]<<16) | + (request->response[3+i*4]<< 8) | request->response[4+i*4]); + + logf("CID: %08lx%08lx%08lx%08lx", card[drive].cid[0], card[drive].cid[1], card[drive].cid[2], card[drive].cid[3]); + sd_simple_cmd(drive, request, SD_SEND_RELATIVE_ADDR, 0, RESPONSE_R6); + break; + case SD_SEND_RELATIVE_ADDR: + retval = sd_unpack_r6(request, &r1, &card[drive].rca); + card[drive].rca = card[drive].rca << 16; + DEBUG("sd_init_card_state: Get RCA from SD: 0x%04lx Status: %x", card[drive].rca, r1.status); + if (retval) + { + DEBUG("sd_init_card_state: unable to SET_RELATIVE_ADDR error=%d", + retval); + return SD_INIT_FAILED; + } + + sd_simple_cmd(drive, request, SD_SEND_CSD, card[drive].rca, RESPONSE_R2_CSD); + break; + + case SD_SEND_CSD: + for(i=0; i<4; i++) + card[drive].csd[i] = ((request->response[1+i*4]<<24) | (request->response[2+i*4]<<16) | + (request->response[3+i*4]<< 8) | request->response[4+i*4]); + + sd_parse_csd(&card[drive]); + sd2_0[drive] = (card_extract_bits(card[drive].csd, 127, 2) == 1); + + logf("CSD: %08lx%08lx%08lx%08lx", card[drive].csd[0], card[drive].csd[1], card[drive].csd[2], card[drive].csd[3]); + DEBUG("SD card is ready"); + jz_sd_set_clock(drive, SD_CLOCK_FAST); + return SD_INIT_PASSED; + + default: + DEBUG("sd_init_card_state: error! Illegal last cmd %d", request->cmd); + return SD_INIT_FAILED; + } + + return SD_INIT_DOING; +} + +static int sd_switch(const int drive, struct sd_request *request, int mode, int group, + unsigned char value, unsigned char * resp) +{ + unsigned int arg; + + mode = !!mode; + value &= 0xF; + arg = (mode << 31 | 0x00FFFFFF); + arg &= ~(0xF << (group * 4)); + arg |= value << (group * 4); + sd_send_cmd(drive, request, 6, arg, 1, 64, RESPONSE_R1, resp); + + return 0; +} + +/* + * Fetches and decodes switch information + */ +static int sd_read_switch(const int drive, struct sd_request *request) +{ + unsigned int status[64 / 4]; + + memset((unsigned char *)status, 0, 64); + sd_switch(drive, request, 0, 0, 1, (unsigned char*) status); + + if (((unsigned char *)status)[13] & 0x02) + return 0; + else + return 1; +} + +/* + * Test if the card supports high-speed mode and, if so, switch to it. + */ +static int sd_switch_hs(const int drive, struct sd_request *request) +{ + unsigned int status[64 / 4]; + + sd_switch(drive, request, 1, 0, 1, (unsigned char*) status); + return 0; +} + +static int sd_select_card(const int drive) +{ + struct sd_request request; + struct sd_response_r1 r1; + int retval; + + sd_simple_cmd(drive, &request, SD_SELECT_CARD, card[drive].rca, + RESPONSE_R1B); + retval = sd_unpack_r1(&request, &r1); + if (retval) + return retval; + + if (sd2_0[drive]) + { + retval = sd_read_switch(drive, &request); + if (!retval) + { + sd_switch_hs(drive, &request); + jz_sd_set_clock(drive, SD_CLOCK_HIGH); + } + } + num_6[drive] = 3; + sd_simple_cmd(drive, &request, SD_APP_CMD, card[drive].rca, + RESPONSE_R1); + retval = sd_unpack_r1(&request, &r1); + if (retval) + return retval; + sd_simple_cmd(drive, &request, SD_SET_BUS_WIDTH, 2, RESPONSE_R1); + retval = sd_unpack_r1(&request, &r1); + if (retval) + return retval; + + card[drive].initialized = 1; + + return 0; +} + +static int sd_init_device(const int drive) +{ + int retval = 0; + struct sd_request init_req; + register int timeout = 1000; + + mutex_lock(&sd_mtx); + + /* Initialise card data as blank */ + memset(&card[drive], 0, sizeof(tCardInfo)); + + sd2_0[drive] = 0; + num_6[drive] = 0; + use_4bit[drive] = 0; + + /* reset mmc/sd controller */ + jz_sd_hardware_init(drive); + + sd_simple_cmd(drive, &init_req, SD_CIM_RESET, 0, RESPONSE_NONE); + sd_simple_cmd(drive, &init_req, SD_GO_IDLE_STATE, 0, RESPONSE_NONE); + + sleep(HZ/2); /* Give the card/controller some rest */ + + while(timeout-- && ((retval = sd_init_card_state(drive, &init_req)) == SD_INIT_DOING)); + retval = (retval == SD_INIT_PASSED ? sd_select_card(drive) : -1); + + if (drive == SD_SLOT_1) + __cpm_stop_msc2(); /* disable SD1 clock */ + else + __cpm_stop_msc1(); /* disable SD2 clock */ + + mutex_unlock(&sd_mtx); + + return retval; +} + +int sd_init(void) +{ + static bool inited = false; + + sd_init_gpio(); /* init GPIO */ + +#if SD_DMA_ENABLE + __dmac_channel_enable_clk(DMA_SD_RX_CHANNEL); + __dmac_channel_enable_clk(DMA_SD_TX_CHANNEL); +#endif + + if(!inited) + { + semaphore_init(&sd_wakeup, 1, 0); + mutex_init(&sd_mtx); + inited = true; + } + + for (int drive = 0; drive < NUM_DRIVES; drive++) + sd_init_device(drive); + + return 0; +} + +static inline bool card_detect_target(const int drive) +{ + return (jz_sd_chkcard(drive) == 1); +} + +tCardInfo* card_get_info_target(const int drive) +{ + return &card[drive]; +} + +static inline void sd_start_transfer(const int drive) +{ + mutex_lock(&sd_mtx); + if (drive == SD_SLOT_1) + __cpm_start_msc2(); + else + __cpm_start_msc1(); + led(true); +} + +static inline void sd_stop_transfer(const int drive) +{ + led(false); + if (drive == SD_SLOT_1) + __cpm_stop_msc2(); + else + __cpm_stop_msc1(); + mutex_unlock(&sd_mtx); +} + +int sd_read_sectors(const int drive, unsigned long start, int count, void* buf) +{ + sd_start_transfer(drive); + + struct sd_request request; + struct sd_response_r1 r1; + int retval = -1; + + if (!card_detect_target(drive) || count == 0 || start > card[drive].numblocks) + goto err; + + if(card[drive].initialized == 0 && !sd_init_device(drive)) + goto err; + + sd_simple_cmd(drive, &request, SD_SEND_STATUS, card[drive].rca, RESPONSE_R1); + retval = sd_unpack_r1(&request, &r1); + if (retval && (retval != SD_ERROR_STATE_MISMATCH)) + goto err; + + sd_simple_cmd(drive, &request, SD_SET_BLOCKLEN, SD_BLOCK_SIZE, RESPONSE_R1); + if ((retval = sd_unpack_r1(&request, &r1))) + goto err; + + if (sd2_0[drive]) + { + sd_send_cmd(drive, &request, SD_READ_MULTIPLE_BLOCK, start, + count, SD_BLOCK_SIZE, RESPONSE_R1, buf); + if ((retval = sd_unpack_r1(&request, &r1))) + goto err; + } + else + { + sd_send_cmd(drive, &request, SD_READ_MULTIPLE_BLOCK, + start * SD_BLOCK_SIZE, count, + SD_BLOCK_SIZE, RESPONSE_R1, buf); + if ((retval = sd_unpack_r1(&request, &r1))) + goto err; + } + + last_disk_activity = current_tick; + + sd_simple_cmd(drive, &request, SD_STOP_TRANSMISSION, 0, RESPONSE_R1B); + if ((retval = sd_unpack_r1(&request, &r1))) + goto err; + +err: + sd_stop_transfer(drive); + + return retval; +} + +int sd_write_sectors(const int drive, unsigned long start, int count, const void* buf) +{ + sd_start_transfer(drive); + + struct sd_request request; + struct sd_response_r1 r1; + int retval = -1; + + if (!card_detect_target(drive) || count == 0 || start > card[drive].numblocks) + goto err; + + if(card[drive].initialized == 0 && !sd_init_device(drive)) + goto err; + + sd_simple_cmd(drive, &request, SD_SEND_STATUS, card[drive].rca, RESPONSE_R1); + retval = sd_unpack_r1(&request, &r1); + if (retval && (retval != SD_ERROR_STATE_MISMATCH)) + goto err; + + sd_simple_cmd(drive, &request, SD_SET_BLOCKLEN, SD_BLOCK_SIZE, RESPONSE_R1); + if ((retval = sd_unpack_r1(&request, &r1))) + goto err; + + if (sd2_0[drive]) + { + sd_send_cmd(drive, &request, SD_WRITE_MULTIPLE_BLOCK, start, + count, SD_BLOCK_SIZE, RESPONSE_R1, + (void*)buf); + if ((retval = sd_unpack_r1(&request, &r1))) + goto err; + } + else + { + sd_send_cmd(drive, &request, SD_WRITE_MULTIPLE_BLOCK, + start * SD_BLOCK_SIZE, count, + SD_BLOCK_SIZE, RESPONSE_R1, (void*)buf); + if ((retval = sd_unpack_r1(&request, &r1))) + goto err; + } + + last_disk_activity = current_tick; + + sd_simple_cmd(drive, &request, SD_STOP_TRANSMISSION, 0, RESPONSE_R1B); + if ((retval = sd_unpack_r1(&request, &r1))) + goto err; + +err: + sd_stop_transfer(drive); + + return retval; +} + +long sd_last_disk_activity(void) +{ + return last_disk_activity; +} + +int sd_spinup_time(void) +{ + return 0; +} + +void sd_enable(bool on) +{ + (void)on; +} + +bool sd_disk_is_active(void) +{ + return false; +} + +int sd_soft_reset(void) +{ + return 0; +} + +#ifdef HAVE_HOTSWAP +bool sd_removable(const int drive) +{ + (void)drive; + return true; +} + +static int sd1_oneshot_callback(struct timeout *tmo) +{ + int state = card_detect_target(SD_SLOT_1); + + /* This is called only if the state was stable for 300ms - check state + * and post appropriate event. */ + queue_broadcast(state ? SYS_HOTSWAP_INSERTED : SYS_HOTSWAP_EXTRACTED, + 0); + + sd_gpio_setup_irq(SD_SLOT_1, state); + + return 0; + (void)tmo; +} + +static int sd2_oneshot_callback(struct timeout *tmo) +{ + int state = card_detect_target(SD_SLOT_2); + + /* This is called only if the state was stable for 300ms - check state + * and post appropriate event. */ + queue_broadcast(state ? SYS_HOTSWAP_INSERTED : SYS_HOTSWAP_EXTRACTED, + 1); + + sd_gpio_setup_irq(SD_SLOT_2, state); + + return 0; + (void)tmo; +} + +/* called on insertion/removal interrupt */ +void GPIO_SD1_CD(void) +{ + static struct timeout sd1_oneshot; + timeout_register(&sd1_oneshot, sd1_oneshot_callback, (3*HZ/10), 0); +} + +void GPIO_SD2_CD(void) +{ + static struct timeout sd2_oneshot; + timeout_register(&sd2_oneshot, sd2_oneshot_callback, (3*HZ/10), 0); +} +#endif + +bool sd_present(const int drive) +{ + return card_detect_target(drive); +} + +#ifdef CONFIG_STORAGE_MULTI +int sd_num_drives(int first_drive) +{ + return NUM_DRIVES; +} +#endif /* CONFIG_STORAGE_MULTI */ + +int sd_event(long id, intptr_t data) +{ + int rc = 0; + + switch (id) + { +#ifdef HAVE_HOTSWAP + case SYS_HOTSWAP_INSERTED: + case SYS_HOTSWAP_EXTRACTED: + /* Force card init for new card, re-init for re-inserted one or + * clear if the last attempt to init failed with an error. */ + mutex_lock(&sd_mtx); /* lock-out card activity */ + card[data].initialized = 0; + mutex_unlock(&sd_mtx); + break; +#endif /* HAVE_HOTSWAP */ + default: + rc = storage_event_default_handler(id, data, last_disk_activity, + STORAGE_SD); + break; + } + + return rc; +} diff --git a/firmware/target/mips/ingenic_jz47xx/backlight-target.h b/firmware/target/mips/ingenic_jz47xx/backlight-target.h index 0dc7ce387a..1b61d13e4c 100644 --- a/firmware/target/mips/ingenic_jz47xx/backlight-target.h +++ b/firmware/target/mips/ingenic_jz47xx/backlight-target.h @@ -26,6 +26,8 @@ bool backlight_hw_init(void); void backlight_hw_on(void); void backlight_hw_off(void); +#ifdef HAVE_BACKLIGHT_BRIGHTNESS void backlight_hw_brightness(int brightness); +#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ #endif /* BACKLIGHT_TARGET_H */ diff --git a/firmware/target/mips/ingenic_jz47xx/codec-jz4760.c b/firmware/target/mips/ingenic_jz47xx/codec-jz4760.c new file mode 100644 index 0000000000..f25dc70eb4 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/codec-jz4760.c @@ -0,0 +1,293 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "audio.h" +#include "sound.h" +#include "cpu.h" +#include "system.h" +#include "pcm_sw_volume.h" +#include "cs4398.h" +#include "kernel.h" + +#define PIN_CS_RST (32*1+10) +#define PIN_CODEC_PWRON (32*1+13) +#define PIN_AP_MUTE (32*1+14) +#define PIN_JD_CON (32*1+16) + +static void pop_ctrl(const int val) +{ + if(val) + __gpio_clear_pin(PIN_JD_CON); + else + __gpio_set_pin(PIN_JD_CON); +} + +static void amp_enable(const int val) +{ + if(val) + __gpio_set_pin(PIN_CODEC_PWRON); + else + __gpio_clear_pin(PIN_CODEC_PWRON); +} + +static void dac_enable(const int val) +{ + if(val) + __gpio_set_pin(PIN_CS_RST); + else + __gpio_clear_pin(PIN_CS_RST); +} + +static void ap_mute(bool mute) +{ + if(mute) + __gpio_clear_pin(PIN_AP_MUTE); + else + __gpio_set_pin(PIN_AP_MUTE); +} + +static void audiohw_mute(bool mute) +{ + if(mute) + cs4398_write_reg(CS4398_REG_MUTE, cs4398_read_reg(CS4398_REG_MUTE) | CS4398_MUTE_A | CS4398_MUTE_B); + else + cs4398_write_reg(CS4398_REG_MUTE, cs4398_read_reg(CS4398_REG_MUTE) & ~(CS4398_MUTE_A | CS4398_MUTE_B)); +} + +void audiohw_preinit(void) +{ + cs4398_write_reg(CS4398_REG_MISC, CS4398_CPEN | CS4398_PDN); + cs4398_write_reg(CS4398_REG_MODECTL, CS4398_FM_SINGLE | CS4398_DEM_NONE | CS4398_DIF_LJUST); + cs4398_write_reg(CS4398_REG_VOLMIX, CS4398_ATAPI_A_L | CS4398_ATAPI_B_R); + cs4398_write_reg(CS4398_REG_MUTE, CS4398_MUTEP_LOW); + cs4398_write_reg(CS4398_REG_VOL_A, 0xff); + cs4398_write_reg(CS4398_REG_VOL_B, 0xff); + cs4398_write_reg(CS4398_REG_RAMPFILT, CS4398_ZERO_CROSS | CS4398_SOFT_RAMP); + cs4398_write_reg(CS4398_REG_MISC, CS4398_CPEN); +} + +void audiohw_init(void) +{ + __gpio_as_func1(3*32+12); // BCK + __gpio_as_func0(3*32+13); // LRCK + __gpio_as_func2(4*32+5); // MCLK + __gpio_as_func0(4*32+7); // DO + + pop_ctrl(0); + ap_mute(true); + amp_enable(0); + dac_enable(0); + + __gpio_as_output(PIN_JD_CON); + __gpio_as_output(PIN_AP_MUTE); + __gpio_as_output(PIN_CODEC_PWRON); + __gpio_as_output(PIN_CS_RST); + + mdelay(100); + amp_enable(1); + + /* set AIC clk PLL1 */ + __cpm_select_i2sclk_pll(); + __cpm_select_i2sclk_pll1(); + + __cpm_enable_pll_change(); + __cpm_set_i2sdiv(43-1); + + __cpm_start_aic(); + + /* Init AIC */ + __i2s_enable_sclk(); + __i2s_external_codec(); + __i2s_select_msbjustified(); + __i2s_as_master(); + __i2s_enable_transmit_dma(); + __i2s_set_transmit_trigger(24); + __i2s_set_oss_sample_size(16); + __i2s_enable(); + + /* Init DAC */ + dac_enable(1); + udelay(1); + audiohw_preinit(); +} + +static int vol_tenthdb2hw(const int tdb) +{ + if (tdb < CS4398_VOLUME_MIN) { + return 0xff; + } else if (tdb > CS4398_VOLUME_MAX) { + return 0x00; + } else { + return (-tdb/5); + } +} + +void audiohw_set_volume(int vol_l, int vol_r) +{ + cs4398_write_reg(CS4398_REG_VOL_A, vol_tenthdb2hw(vol_l)); + cs4398_write_reg(CS4398_REG_VOL_B, vol_tenthdb2hw(vol_r)); +} + +void audiohw_set_lineout_volume(int vol_l, int vol_r) +{ +#if 0 /* unused */ + cs4398_write_reg(CS4398_REG_VOL_A, vol_tenthdb2hw(vol_l)); + cs4398_write_reg(CS4398_REG_VOL_B, vol_tenthdb2hw(vol_r)); +#else + (void)vol_l; + (void)vol_r; +#endif +} + +void audiohw_set_filter_roll_off(int value) +{ + /* 0 = fast (sharp); + 1 = slow */ + if (value == 0) { + cs4398_write_reg(CS4398_REG_RAMPFILT, cs4398_read_reg(CS4398_REG_RAMPFILT) & ~CS4398_FILT_SEL); + } else { + cs4398_write_reg(CS4398_REG_RAMPFILT, cs4398_read_reg(CS4398_REG_RAMPFILT) | CS4398_FILT_SEL); + } +} + +void pll1_init(unsigned int freq); +void audiohw_set_frequency(int fsel) +{ + unsigned int pll1_speed; + unsigned char mclk_div, bclk_div, func_mode; + + switch(fsel) + { + case HW_FREQ_8: + pll1_speed = 426000000; + mclk_div = 52; + bclk_div = 16; + func_mode = 0; + break; + case HW_FREQ_11: + pll1_speed = 508000000; + mclk_div = 45; + bclk_div = 16; + func_mode = 0; + break; + case HW_FREQ_12: + pll1_speed = 516000000; + mclk_div = 42; + bclk_div = 16; + func_mode = 0; + break; + case HW_FREQ_16: + pll1_speed = 426000000; + mclk_div = 52; + bclk_div = 8; + func_mode = 0; + break; + case HW_FREQ_22: + pll1_speed = 508000000; + mclk_div = 45; + bclk_div = 8; + func_mode = 0; + break; + case HW_FREQ_24: + pll1_speed = 516000000; + mclk_div = 42; + bclk_div = 8; + func_mode = 0; + break; + case HW_FREQ_32: + pll1_speed = 426000000; + mclk_div = 52; + bclk_div = 4; + func_mode = 0; + break; + case HW_FREQ_44: + pll1_speed = 508000000; + mclk_div = 45; + bclk_div = 4; + func_mode = 0; + break; + case HW_FREQ_48: + pll1_speed = 516000000; + mclk_div = 42; + bclk_div = 4; + func_mode = 0; + break; + case HW_FREQ_64: + pll1_speed = 426000000; + mclk_div = 52; + bclk_div = 2; + func_mode = 1; + break; + case HW_FREQ_88: + pll1_speed = 508000000; + mclk_div = 45; + bclk_div = 2; + func_mode = 1; + break; + case HW_FREQ_96: + pll1_speed = 516000000; + mclk_div = 42; + bclk_div = 2; + func_mode = 1; + break; + default: + return; + } + + __i2s_stop_bitclk(); + + /* 0 = Single-Speed Mode (<50KHz); + 1 = Double-Speed Mode (50-100KHz); + 2 = Quad-Speed Mode; (100-200KHz) */ + cs4398_write_reg(CS4398_REG_MODECTL, (cs4398_read_reg(CS4398_REG_MODECTL) & ~CS4398_FM_MASK) | func_mode); + if (func_mode == 2) + cs4398_write_reg(CS4398_REG_MISC, cs4398_read_reg(CS4398_REG_MISC) | CS4398_MCLKDIV2); + else + cs4398_write_reg(CS4398_REG_MISC, cs4398_read_reg(CS4398_REG_MISC) & ~CS4398_MCLKDIV2); + + pll1_init(pll1_speed); + __cpm_enable_pll_change(); + __cpm_set_i2sdiv(mclk_div-1); + __i2s_set_i2sdiv(bclk_div-1); + __i2s_start_bitclk(); +} + +void audiohw_postinit(void) +{ + sleep(HZ); + audiohw_mute(false); + ap_mute(false); + pop_ctrl(1); +} + +void audiohw_close(void) +{ + pop_ctrl(0); + sleep(HZ/10); + ap_mute(true); + audiohw_mute(true); + amp_enable(0); + dac_enable(0); + __i2s_disable(); + __cpm_stop_aic(); + sleep(HZ); + pop_ctrl(1); +} diff --git a/firmware/target/mips/ingenic_jz47xx/crt0.S b/firmware/target/mips/ingenic_jz47xx/crt0.S index 0ae365022a..49de3e6a01 100644 --- a/firmware/target/mips/ingenic_jz47xx/crt0.S +++ b/firmware/target/mips/ingenic_jz47xx/crt0.S @@ -50,6 +50,7 @@ .set noat #ifdef BOOTLOADER +#ifndef XDUOO_X3 /* These will get filled in by scramble */ .word 0 /* Empty */ .word 0 /* Filesize */ @@ -65,6 +66,7 @@ _relocate_loop: bne t1, t2, _relocate_loop sw t3, -4(t1) #endif +#endif _start: la ra, _start diff --git a/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c new file mode 100644 index 0000000000..88fc351946 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c @@ -0,0 +1,146 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "system.h" +#include "cpu.h" +#include +#include +#include "lcd.h" +#include "kernel.h" +#include "font.h" +#include "button.h" +#include "timefuncs.h" + +#define CFG_UART_BASE UART1_BASE /* Base of the UART channel */ + +void serial_putc (const char c) +{ + volatile u8 *uart_lsr = (volatile u8 *)(CFG_UART_BASE + OFF_LSR); + volatile u8 *uart_tdr = (volatile u8 *)(CFG_UART_BASE + OFF_TDR); + + if (c == '\n') serial_putc ('\r'); + + /* Wait for fifo to shift out some bytes */ + while ( !((*uart_lsr & (UARTLSR_TDRQ | UARTLSR_TEMT)) == 0x60) ); + + *uart_tdr = (u8)c; +} + +void serial_puts (const char *s) +{ + while (*s) { + serial_putc (*s++); + } +} + +void serial_putsf(const char *format, ...) +{ + static char printfbuf[256]; + int len; + unsigned char *ptr; + va_list ap; + va_start(ap, format); + + ptr = printfbuf; + len = vsnprintf(ptr, sizeof(printfbuf), format, ap); + va_end(ap); + + serial_puts(ptr); + serial_putc('\n'); +} + +void serial_put_hex(unsigned int d) +{ + char c[12]; + int i; + for(i = 0; i < 8;i++) + { + c[i] = (d >> ((7 - i) * 4)) & 0xf; + if(c[i] < 10) + c[i] += 0x30; + else + c[i] += (0x41 - 10); + } + c[8] = '\n'; + c[9] = 0; + serial_puts(c); + +} + +void serial_put_dec(unsigned int d) +{ + char c[16]; + int i; + int j = 0; + int x = d; + + while (x /= 10) + j++; + + for (i = j; i >= 0; i--) { + c[i] = d % 10; + c[i] += 0x30; + d /= 10; + } + c[j + 1] = '\n'; + c[j + 2] = 0; + serial_puts(c); +} + +void serial_dump_data(unsigned char* data, int len) +{ + int i; + for(i=0; i>4) & 0xf; + if(a < 10) + a += 0x30; + else + a += (0x41 - 10); + serial_putc( a ); + + a = (*data) & 0xf; + if(a < 10) + a += 0x30; + else + a += (0x41 - 10); + serial_putc( a ); + + serial_putc( ' ' ); + + data++; + } + + serial_putc( '\n' ); +} + +bool dbg_ports(void) +{ + serial_puts("dbg_ports\n"); + return false; +} + +bool dbg_hw_info(void) +{ + serial_puts("dbg_hw_info\n"); + return false; +} diff --git a/firmware/target/mips/ingenic_jz47xx/dma-target.h b/firmware/target/mips/ingenic_jz47xx/dma-target.h new file mode 100644 index 0000000000..792d8fe87c --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/dma-target.h @@ -0,0 +1,31 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef __DMA_TARGET_H_ +#define __DMA_TARGET_H_ + +#include "system.h" +#include + +void memset_dma(void *target, int c, size_t len, unsigned int bits); +void memcpy_dma(void *target, const void *source, size_t len, unsigned int bits); + +#endif /* __DMA_TARGET_H_ */ diff --git a/firmware/target/mips/ingenic_jz47xx/dma_acc-jz4760.c b/firmware/target/mips/ingenic_jz47xx/dma_acc-jz4760.c new file mode 100644 index 0000000000..4cdea2ad08 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/dma_acc-jz4760.c @@ -0,0 +1,102 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "dma-target.h" + +#define MDMA_CHANNEL 0 + +void memset_dma(void *target, int c, size_t len, unsigned int bits) +{ + unsigned int d; + unsigned char *dp; + + if(((unsigned int)target < 0xa0000000) && len) + dma_cache_wback_inv((unsigned long)target, len); + + dp = (unsigned char *)((unsigned int)(&d) | 0xa0000000); + *(dp + 0) = c; + *(dp + 1) = c; + *(dp + 2) = c; + *(dp + 3) = c; + + REG_MDMAC_DCCSR(MDMA_CHANNEL) = 0; + REG_MDMAC_DSAR(MDMA_CHANNEL) = PHYSADDR((unsigned long)dp); + REG_MDMAC_DTAR(MDMA_CHANNEL) = PHYSADDR((unsigned long)target); + REG_MDMAC_DRSR(MDMA_CHANNEL) = DMAC_DRSR_RS_AUTO; + switch (bits) + { + case 8: + REG_MDMAC_DTCR(MDMA_CHANNEL) = len; + REG_MDMAC_DCMD(MDMA_CHANNEL) = DMAC_DCMD_DAI | DMAC_DCMD_SWDH_8 | DMAC_DCMD_DWDH_8 | DMAC_DCMD_DS_8BIT; + break; + case 16: + REG_MDMAC_DTCR(MDMA_CHANNEL) = len / 2; + REG_MDMAC_DCMD(MDMA_CHANNEL) = DMAC_DCMD_DAI | DMAC_DCMD_SWDH_16 | DMAC_DCMD_DWDH_16 | DMAC_DCMD_DS_16BIT; + break; + case 32: + REG_MDMAC_DTCR(MDMA_CHANNEL) = len / 4; + REG_MDMAC_DCMD(MDMA_CHANNEL) = DMAC_DCMD_DAI | DMAC_DCMD_SWDH_32 | DMAC_DCMD_DWDH_32 | DMAC_DCMD_DS_32BIT; + break; + default: + return; + } + REG_MDMAC_DCCSR(MDMA_CHANNEL) = DMAC_DCCSR_EN | DMAC_DCCSR_NDES; + + while (REG_MDMAC_DTCR(MDMA_CHANNEL)); + + REG_MDMAC_DCCSR(MDMA_CHANNEL) = 0; +} + +void memcpy_dma(void *target, const void *source, size_t len, unsigned int bits) +{ + if(((unsigned int)source < 0xa0000000) && len) + dma_cache_wback_inv((unsigned long)source, len); + + if(((unsigned int)target < 0xa0000000) && len) + dma_cache_wback_inv((unsigned long)target, len); + + REG_MDMAC_DCCSR(MDMA_CHANNEL) = 0; + REG_MDMAC_DSAR(MDMA_CHANNEL) = PHYSADDR((unsigned long)source); + REG_MDMAC_DTAR(MDMA_CHANNEL) = PHYSADDR((unsigned long)target); + REG_MDMAC_DRSR(MDMA_CHANNEL) = DMAC_DRSR_RS_AUTO; + switch (bits) + { + case 8: + REG_MDMAC_DTCR(MDMA_CHANNEL) = len; + REG_MDMAC_DCMD(MDMA_CHANNEL) = DMAC_DCMD_SAI | DMAC_DCMD_DAI | DMAC_DCMD_SWDH_8 | DMAC_DCMD_DWDH_8 | DMAC_DCMD_DS_8BIT; + break; + case 16: + REG_MDMAC_DTCR(MDMA_CHANNEL) = len / 2; + REG_MDMAC_DCMD(MDMA_CHANNEL) = DMAC_DCMD_SAI | DMAC_DCMD_DAI | DMAC_DCMD_SWDH_16 | DMAC_DCMD_DWDH_16 | DMAC_DCMD_DS_16BIT; + break; + case 32: + REG_MDMAC_DTCR(MDMA_CHANNEL) = len / 4; + REG_MDMAC_DCMD(MDMA_CHANNEL) = DMAC_DCMD_SAI | DMAC_DCMD_DAI | DMAC_DCMD_SWDH_32 | DMAC_DCMD_DWDH_32 | DMAC_DCMD_DS_32BIT; + break; + default: + return; + } + REG_MDMAC_DCCSR(MDMA_CHANNEL) = DMAC_DCCSR_EN | DMAC_DCCSR_NDES; + + while (REG_MDMAC_DTCR(MDMA_CHANNEL)); + + REG_MDMAC_DCCSR(MDMA_CHANNEL) = 0; +} diff --git a/firmware/target/mips/ingenic_jz47xx/i2c-jz4760.c b/firmware/target/mips/ingenic_jz47xx/i2c-jz4760.c new file mode 100644 index 0000000000..e35fe7a091 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/i2c-jz4760.c @@ -0,0 +1,355 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" +#include "system.h" +#include "cpu.h" +#include "logf.h" +#include "i2c.h" + +#define I2C_CHN 1 +#define I2C_CLK 100000 + +#define I2C_READ 1 +#define I2C_WRITE 0 + +#define I2C_M_RD 1 +#define I2C_M_WR 2 + +#define TIMEOUT 100000 + +static char i2c_rwflags; +static int i2c_ctrl_rest = 0; +static unsigned char *msg_buf; +static int cmd_cnt; +static volatile int cmd_flag; +static int r_cnt; +static unsigned char i2c_subaddr = 0; + +/* + * I2C bus protocol basic routines + */ + +/* Interrupt handler */ +void I2C1(void) +{ + int timeout = TIMEOUT; + + if (__i2c_abrt_7b_addr_nack(I2C_CHN)) { + int ret; + cmd_flag = -1; + __i2c_clear_interrupts(ret,I2C_CHN); + REG_I2C_INTM(I2C_CHN) = 0x0; + return; + } + + /* first byte,when length > 1 */ + if (cmd_flag == 0 && cmd_cnt > 1) { + cmd_flag = 1; + if (i2c_rwflags == I2C_M_RD) { + REG_I2C_DC(I2C_CHN) = I2C_READ << 8; + } else { + REG_I2C_DC(I2C_CHN) = (I2C_WRITE << 8) | *msg_buf++; + } + cmd_cnt--; + } + + if (i2c_rwflags == I2C_M_RD) { + if (REG_I2C_STA(I2C_CHN) & I2C_STA_RFNE) { + *msg_buf++ = REG_I2C_DC(I2C_CHN) & 0xff; + r_cnt--; + } + + REG_I2C_DC(I2C_CHN) = I2C_READ << 8; + } else { + REG_I2C_DC(I2C_CHN) = (I2C_WRITE << 8) | *msg_buf++; + } + + cmd_cnt--; + + if (!(cmd_cnt)) { + REG_I2C_INTM(I2C_CHN) = 0x0; + cmd_flag = 2; + if (i2c_rwflags == I2C_M_RD){ + while (r_cnt > 2) { + if ((REG_I2C_STA(I2C_CHN) & I2C_STA_RFNE) && timeout) { + *msg_buf++ = REG_I2C_DC(I2C_CHN) & 0xff; + r_cnt--; + } + if (!(timeout--)) { + cmd_flag = -1; + return; + } + } + } + } + + return; +} + +static int i2c_set_clk(int i2c_clk) +{ + int dev_clk = __cpm_get_pclk(); + int count = 0; + + if (i2c_clk < 0 || i2c_clk > 400000) + goto Set_clk_err; + + count = dev_clk/i2c_clk - 23; + if (count < 0) + goto Set_clk_err; + + if (i2c_clk <= 100000) { + REG_I2C_CTRL(I2C_CHN) = 0x43 | i2c_ctrl_rest; /* standard speed mode*/ + if (count%2 == 0) { + REG_I2C_SHCNT(I2C_CHN) = count/2 + 6 - 5; + REG_I2C_SLCNT(I2C_CHN) = count/2 + 8 + 5; + } else { + REG_I2C_SHCNT(I2C_CHN) = count/2 + 6 -5; + REG_I2C_SLCNT(I2C_CHN) = count/2 + 8 +5 + 1; + } + } else { + REG_I2C_CTRL(I2C_CHN) = 0x45 | i2c_ctrl_rest; /* high speed mode*/ + if (count%2 == 0) { + REG_I2C_FHCNT(I2C_CHN) = count/2 + 6; + REG_I2C_FLCNT(I2C_CHN) = count/2 + 8; + } else { + REG_I2C_FHCNT(I2C_CHN) = count/2 + 6; + REG_I2C_FLCNT(I2C_CHN) = count/2 + 8 + 1; + } + } + return 0; + +Set_clk_err: + + logf("i2c set sclk faild,i2c_clk=%d,dev_clk=%d.\n",i2c_clk,dev_clk); + return -1; +} + +static int i2c_disable(void) +{ + int timeout = TIMEOUT; + + __i2c_disable(I2C_CHN); + while(__i2c_is_enable(I2C_CHN) && (timeout > 0)) { + udelay(1); + timeout--; + } + if(timeout) + return 0; + else + return 1; +} + +static int i2c_enable(void) +{ + int timeout = TIMEOUT; + + __i2c_enable(I2C_CHN); + while(__i2c_is_disable(I2C_CHN) && (timeout > 0)) { + udelay(1); + timeout--; + } + if(timeout) + return 0; + else + return 1; +} + +static void i2c_init_as_master(unsigned char address) +{ + if(i2c_disable()) + logf("i2c not disable\n"); + + i2c_set_clk(I2C_CLK); + + REG_I2C_TAR(I2C_CHN) = address; /* slave id needed write only once */ + REG_I2C_INTM(I2C_CHN) = 0x0; /* unmask all interrupts */ + REG_I2C_TXTL(I2C_CHN) = 0x1; + + if(i2c_enable()) + logf("i2c not enable\n"); +} + +int xfer_read_subaddr(unsigned char subaddr, unsigned char device, unsigned char *buf, int length) +{ + int timeout,r_i = 0; + + cmd_cnt = length; + r_cnt = length; + msg_buf = buf; + i2c_rwflags = I2C_M_RD; + i2c_ctrl_rest = I2C_CTRL_REST; + i2c_init_as_master(device); + + REG_I2C_DC(I2C_CHN) = (I2C_WRITE << 8) | subaddr; + + cmd_flag = 0; + REG_I2C_INTM(I2C_CHN) = 0x10; + timeout = TIMEOUT; + while (cmd_flag != 2 && --timeout) { + if (cmd_flag == -1) { + r_i = 1; + goto R_dev_err; + } + udelay(10); + } + if (!timeout) { + r_i = 4; + goto R_timeout; + } + + while (r_cnt) { + while (!(REG_I2C_STA(I2C_CHN) & I2C_STA_RFNE)) { + if ((cmd_flag == -1) || + (REG_I2C_INTST(I2C_CHN) & I2C_INTST_TXABT) || + REG_I2C_TXABRT(I2C_CHN)) { + int ret; + r_i = 2; + __i2c_clear_interrupts(ret,I2C_CHN); + goto R_dev_err; + } + } + *msg_buf++ = REG_I2C_DC(I2C_CHN) & 0xff; + r_cnt--; + } + + timeout = TIMEOUT; + while ((REG_I2C_STA(I2C_CHN) & I2C_STA_MSTACT) && --timeout) + udelay(10); + if (!timeout){ + r_i = 3; + goto R_timeout; + } + + return 0; + +R_dev_err: +R_timeout: + + i2c_init_as_master(device); + if (r_i == 1) { + logf("Read i2c device 0x%2x failed in r_i = %d :device no ack.\n",device,r_i); + } else if (r_i == 2) { + logf("Read i2c device 0x%2x failed in r_i = %d :i2c abort.\n",device,r_i); + } else if (r_i == 3) { + logf("Read i2c device 0x%2x failed in r_i = %d :waite master inactive timeout.\n",device,r_i); + } else if (r_i == 4) { + logf("Read i2c device 0x%2x failed in r_i = %d.\n",device,r_i); + } else { + logf("Read i2c device 0x%2x failed in r_i = %d.\n",device,r_i); + } + return -1; +} + +int xfer_write_subaddr(unsigned char subaddr, unsigned char device, const unsigned char *buf, int length) +{ + int timeout,w_i = 0; + + cmd_cnt = length; + r_cnt = length; + msg_buf = (unsigned char *)buf; + i2c_rwflags = I2C_M_WR; + i2c_ctrl_rest = I2C_CTRL_REST; + i2c_init_as_master(device); + + REG_I2C_DC(I2C_CHN) = (I2C_WRITE << 8) | subaddr; + + cmd_flag = 0; + REG_I2C_INTM(I2C_CHN) = 0x10; + + timeout = TIMEOUT; + while ((cmd_flag != 2) && (--timeout)) + { + if (cmd_flag == -1){ + w_i = 1; + goto W_dev_err; + } + udelay(10); + } + + timeout = TIMEOUT; + while((!(REG_I2C_STA(I2C_CHN) & I2C_STA_TFE)) && --timeout){ + udelay(10); + } + if (!timeout){ + w_i = 2; + goto W_timeout; + } + + timeout = TIMEOUT; + while (__i2c_master_active(I2C_CHN) && --timeout); + if (!timeout){ + w_i = 3; + goto W_timeout; + } + + if ((length == 1)&& + ((cmd_flag == -1) || + (REG_I2C_INTST(I2C_CHN) & I2C_INTST_TXABT) || + REG_I2C_TXABRT(I2C_CHN))) { + int ret; + w_i = 5; + __i2c_clear_interrupts(ret,I2C_CHN); + goto W_dev_err; + } + + return 0; + +W_dev_err: +W_timeout: + + i2c_init_as_master(device); + if (w_i == 1) { + logf("Write i2c device 0x%2x failed in w_i=%d:device no ack. I2C_CHN:[%d]sxyzhang\n",device,w_i,I2C_CHN); + } else if (w_i == 2) { + logf("Write i2c device 0x%2x failed in w_i=%d:waite TF buff empty timeout.\n",device,w_i); + } else if (w_i == 3) { + logf("Write i2c device 0x%2x failed in w_i=%d:waite master inactive timeout.\n",device,w_i); + } else if (w_i == 5) { + logf("Write i2c device 0x%2x failed in w_i=%d:device no ack or abort.I2C_CHN:[%d]sxyzhang \n",device,w_i,I2C_CHN); + } else { + logf("Write i2c device 0x%2x failed in w_i=%d.\n",device,w_i); + } + + return -1; +} + +int i2c_read(int device, unsigned char* buf, int count) +{ + return xfer_read_subaddr(i2c_subaddr, device, &buf[0], count); +} + +int i2c_write(int device, const unsigned char* buf, int count) +{ + if (count < 2) + { + i2c_subaddr = buf[0]; + return 0; + } + return xfer_write_subaddr(buf[0], device, &buf[1], count-1); +} + +void i2c_init(void) +{ + __gpio_as_i2c(I2C_CHN); + __cpm_start_i2c1(); + system_enable_irq(IRQ_I2C1); +} diff --git a/firmware/target/mips/ingenic_jz47xx/kernel-jz4760.c b/firmware/target/mips/ingenic_jz47xx/kernel-jz4760.c new file mode 100644 index 0000000000..ab0f152669 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/kernel-jz4760.c @@ -0,0 +1,53 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "system.h" +#include "kernel.h" +#include "cpu.h" + +void tick_start(unsigned int interval_in_ms) +{ + unsigned int latch; + + /* 12Mhz / 4 = 3Mhz */ + latch = interval_in_ms*1000 * 3; + + REG_OST_OSTCSR = OSTCSR_PRESCALE4 | OSTCSR_EXT_EN; + REG_OST_OSTDR = latch; + REG_OST_OSTCNTL = 0; + REG_OST_OSTCNTH = 0; + + system_enable_irq(IRQ_TCU0); + + REG_TCU_TMCR = TMCR_OSTMASK; /* unmask match irq */ + REG_TCU_TSCR = TSCR_OST; /* enable timer clock */ + REG_TCU_TESR = TESR_OST; /* start counting up */ +} + +/* Interrupt handler */ +void TCU0(void) +{ + REG_TCU_TFCR = TFCR_OSTFLAG; /* ACK timer */ + + /* Run through the list of tick tasks */ + call_tick_tasks(); +} diff --git a/firmware/target/mips/ingenic_jz47xx/lcd-jz4760.c b/firmware/target/mips/ingenic_jz47xx/lcd-jz4760.c new file mode 100644 index 0000000000..03fb937d0a --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/lcd-jz4760.c @@ -0,0 +1,28 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include /* off_t */ + +#include "config.h" +#include "cpu.h" +#include "lcd.h" +#include "lcd-target.h" +#include "system.h" +#include "kernel.h" diff --git a/firmware/target/mips/ingenic_jz47xx/pcm-jz4760.c b/firmware/target/mips/ingenic_jz47xx/pcm-jz4760.c new file mode 100644 index 0000000000..39df037f76 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/pcm-jz4760.c @@ -0,0 +1,240 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "system.h" +#include "kernel.h" +#include "logf.h" +#include "audio.h" +#include "sound.h" +#include "pcm.h" +#include "pcm-internal.h" +#include "cpu.h" + + +/**************************************************************************** + ** Playback DMA transfer + **/ + +void pcm_play_dma_postinit(void) +{ + audiohw_postinit(); + + /* Flush FIFO */ + __aic_flush_tfifo(); +} + +void pcm_play_dma_init(void) +{ + system_enable_irq(DMA_IRQ(DMA_AIC_TX_CHANNEL)); + + /* Initialize default register values. */ + audiohw_init(); +} + +void pcm_dma_apply_settings(void) +{ + audiohw_set_frequency(pcm_fsel); +} + +static const void* playback_address; +static inline void set_dma(const void *addr, size_t size) +{ + int burst_size; + logf("%x %d %x", (unsigned int)addr, size, REG_AIC_SR); + + dma_cache_wback_inv((unsigned long)addr, size); + + if(size % 16) + { + if(size % 4) + { + size /= 2; + burst_size = DMAC_DCMD_DS_16BIT; + } + else + { + size /= 4; + burst_size = DMAC_DCMD_DS_32BIT; + } + } + else + { + size /= 16; + burst_size = DMAC_DCMD_DS_16BYTE; + } + + REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) = 0; + REG_DMAC_DSAR(DMA_AIC_TX_CHANNEL) = PHYSADDR((unsigned long)addr); + REG_DMAC_DTAR(DMA_AIC_TX_CHANNEL) = PHYSADDR((unsigned long)AIC_DR); + REG_DMAC_DTCR(DMA_AIC_TX_CHANNEL) = size; + REG_DMAC_DRSR(DMA_AIC_TX_CHANNEL) = DMAC_DRSR_RS_AICOUT; + REG_DMAC_DCMD(DMA_AIC_TX_CHANNEL) = (DMAC_DCMD_SAI | DMAC_DCMD_SWDH_32 | burst_size | DMAC_DCMD_DWDH_16 | DMAC_DCMD_TIE); + REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) = DMAC_DCCSR_NDES | DMAC_DCCSR_EN; + + playback_address = addr; +} + +static inline void play_dma_callback(void) +{ + const void *start; + size_t size; + + if (pcm_play_dma_complete_callback(PCM_DMAST_OK, &start, &size)) + { + set_dma(start, size); + REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) |= DMAC_DCCSR_EN; + pcm_play_dma_status_callback(PCM_DMAST_STARTED); + } +} + +void DMA_CALLBACK(DMA_AIC_TX_CHANNEL)(void) __attribute__ ((section(".icode"))); +void DMA_CALLBACK(DMA_AIC_TX_CHANNEL)(void) +{ + if (REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) & DMAC_DCCSR_AR) + { + logf("PCM DMA address error"); + REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) &= ~DMAC_DCCSR_AR; + } + + if (REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) & DMAC_DCCSR_HLT) + { + logf("PCM DMA halt"); + REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) &= ~DMAC_DCCSR_HLT; + } + + if (REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) & DMAC_DCCSR_TT) + { + REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) &= ~DMAC_DCCSR_TT; + play_dma_callback(); + } +} + +void pcm_play_dma_start(const void *addr, size_t size) +{ + __dmac_channel_enable_clk(DMA_AIC_TX_CHANNEL); + + set_dma(addr, size); + + __aic_enable_replay(); + + __dmac_channel_enable_irq(DMA_AIC_TX_CHANNEL); +} + +void pcm_play_dma_stop(void) +{ + int flags = disable_irq_save(); + + REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) = (REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) | DMAC_DCCSR_HLT) & ~DMAC_DCCSR_EN; + + __dmac_channel_disable_clk(DMA_AIC_TX_CHANNEL); + + __aic_disable_replay(); + + restore_irq(flags); +} + +static unsigned int play_lock = 0; +void pcm_play_lock(void) +{ + int flags = disable_irq_save(); + + if (++play_lock == 1) + __dmac_channel_disable_irq(DMA_AIC_TX_CHANNEL); + + restore_irq(flags); +} + +void pcm_play_unlock(void) +{ + int flags = disable_irq_save(); + + if (--play_lock == 0) + __dmac_channel_enable_irq(DMA_AIC_TX_CHANNEL); + + restore_irq(flags); +} + +void pcm_play_dma_pause(bool pause) +{ + int flags = disable_irq_save(); + + if(pause) + REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) &= ~DMAC_DCCSR_EN; + else + REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) |= DMAC_DCCSR_EN; + + restore_irq(flags); +} + +static int get_dma_count(void) +{ + int count = REG_DMAC_DTCR(DMA_AIC_TX_CHANNEL); + switch(REG_DMAC_DCMD(DMA_AIC_TX_CHANNEL) & DMAC_DCMD_DS_MASK) + { + case DMAC_DCMD_DS_16BIT: + count *= 2; + break; + case DMAC_DCMD_DS_32BIT: + count *= 4; + break; + case DMAC_DCMD_DS_16BYTE: + count *= 16; + break; + } + + return count; +} + +size_t pcm_get_bytes_waiting(void) +{ + int bytes, flags = disable_irq_save(); + + if(REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) & DMAC_DCCSR_EN) + bytes = get_dma_count() & ~3; + else + bytes = 0; + + restore_irq(flags); + + return bytes; +} + +const void * pcm_play_dma_get_peak_buffer(int *count) +{ + int flags = disable_irq_save(); + + const void* addr; + if(REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) & DMAC_DCCSR_EN) + { + int bytes = get_dma_count(); + *count = bytes >> 2; + addr = (const void*)((int)(playback_address + bytes + 2) & ~3); + } + else + { + *count = 0; + addr = NULL; + } + + restore_irq(flags); + + return addr; +} diff --git a/firmware/target/mips/ingenic_jz47xx/system-jz4760.c b/firmware/target/mips/ingenic_jz47xx/system-jz4760.c new file mode 100644 index 0000000000..8472a7378f --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/system-jz4760.c @@ -0,0 +1,710 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include "mips.h" +#include "mmu-mips.h" +#include "panic.h" +#include "system.h" +#include "kernel.h" +#include "power.h" + +static int irq; +static void UIRQ(void) +{ + panicf("Unhandled interrupt occurred: %d", irq); +} + +#define intr(name) extern __attribute__((weak,alias("UIRQ"))) void name (void) + +intr(I2C1);intr(I2C0);intr(UART3);intr(UART2);intr(UART1);intr(UART0);intr(GPU); +intr(SSI1);intr(SSI0);intr(TSSI);intr(KBC);intr(SADC);intr(ETH);intr(UHC); +intr(OTG);intr(TCU2);intr(TCU1);intr(TCU0);intr(GPS);intr(IPU);intr(CIM); +intr(LCD);intr(RTC);intr(OWI);intr(AIC);intr(MSC2);intr(MSC1);intr(MSC0); +intr(SCC);intr(BCH);intr(PCM);intr(HARB0);intr(HARB2);intr(AOSD);intr(CPM); + +intr(DMA0);intr(DMA1);intr(DMA2);intr(DMA3);intr(DMA4);intr(DMA5); +intr(DMA6);intr(DMA7);intr(DMA8);intr(DMA9);intr(DMA10);intr(DMA11); +intr(MDMA0);intr(MDMA1);intr(MDMA2); +intr(BDMA0);intr(BDMA1);intr(BDMA2); + +intr(GPIO0);intr(GPIO1);intr(GPIO2);intr(GPIO3);intr(GPIO4);intr(GPIO5); +intr(GPIO6);intr(GPIO7);intr(GPIO8);intr(GPIO9);intr(GPIO10);intr(GPIO11); +intr(GPIO12);intr(GPIO13);intr(GPIO14);intr(GPIO15);intr(GPIO16);intr(GPIO17); +intr(GPIO18);intr(GPIO19);intr(GPIO20);intr(GPIO21);intr(GPIO22);intr(GPIO23); +intr(GPIO24);intr(GPIO25);intr(GPIO26);intr(GPIO27);intr(GPIO28);intr(GPIO29); +intr(GPIO30);intr(GPIO31);intr(GPIO32);intr(GPIO33);intr(GPIO34);intr(GPIO35); +intr(GPIO36);intr(GPIO37);intr(GPIO38);intr(GPIO39);intr(GPIO40);intr(GPIO41); +intr(GPIO42);intr(GPIO43);intr(GPIO44);intr(GPIO45);intr(GPIO46);intr(GPIO47); +intr(GPIO48);intr(GPIO49);intr(GPIO50);intr(GPIO51);intr(GPIO52);intr(GPIO53); +intr(GPIO54);intr(GPIO55);intr(GPIO56);intr(GPIO57);intr(GPIO58);intr(GPIO59); +intr(GPIO60);intr(GPIO61);intr(GPIO62);intr(GPIO63);intr(GPIO64);intr(GPIO65); +intr(GPIO66);intr(GPIO67);intr(GPIO68);intr(GPIO69);intr(GPIO70);intr(GPIO71); +intr(GPIO72);intr(GPIO73);intr(GPIO74);intr(GPIO75);intr(GPIO76);intr(GPIO77); +intr(GPIO78);intr(GPIO79);intr(GPIO80);intr(GPIO81);intr(GPIO82);intr(GPIO83); +intr(GPIO84);intr(GPIO85);intr(GPIO86);intr(GPIO87);intr(GPIO88);intr(GPIO89); +intr(GPIO90);intr(GPIO91);intr(GPIO92);intr(GPIO93);intr(GPIO94);intr(GPIO95); +intr(GPIO96);intr(GPIO97);intr(GPIO98);intr(GPIO99);intr(GPIO100);intr(GPIO101); +intr(GPIO102);intr(GPIO103);intr(GPIO104);intr(GPIO105);intr(GPIO106); +intr(GPIO107);intr(GPIO108);intr(GPIO109);intr(GPIO110);intr(GPIO111); +intr(GPIO112);intr(GPIO113);intr(GPIO114);intr(GPIO115);intr(GPIO116); +intr(GPIO117);intr(GPIO118);intr(GPIO119);intr(GPIO120);intr(GPIO121); +intr(GPIO122);intr(GPIO123);intr(GPIO124);intr(GPIO125);intr(GPIO126); +intr(GPIO127);intr(GPIO128);intr(GPIO129);intr(GPIO130);intr(GPIO131); +intr(GPIO132);intr(GPIO133);intr(GPIO134);intr(GPIO135);intr(GPIO136); +intr(GPIO137);intr(GPIO138);intr(GPIO139);intr(GPIO140);intr(GPIO141); +intr(GPIO142);intr(GPIO143);intr(GPIO144);intr(GPIO145);intr(GPIO146); +intr(GPIO147);intr(GPIO148);intr(GPIO149);intr(GPIO150);intr(GPIO151); +intr(GPIO152);intr(GPIO153);intr(GPIO154);intr(GPIO155);intr(GPIO156); +intr(GPIO157);intr(GPIO158);intr(GPIO159);intr(GPIO160);intr(GPIO161); +intr(GPIO162);intr(GPIO163);intr(GPIO164);intr(GPIO165);intr(GPIO166); +intr(GPIO167);intr(GPIO168);intr(GPIO169);intr(GPIO170);intr(GPIO171); +intr(GPIO172);intr(GPIO173);intr(GPIO174);intr(GPIO175);intr(GPIO176); +intr(GPIO177);intr(GPIO178);intr(GPIO179);intr(GPIO180);intr(GPIO181); +intr(GPIO182);intr(GPIO183);intr(GPIO184);intr(GPIO185);intr(GPIO186); +intr(GPIO187);intr(GPIO188);intr(GPIO189);intr(GPIO190);intr(GPIO191); + +static void (* const irqvector[])(void) = +{ + I2C1,I2C0,UART3,UART2,UART1,UART0,GPU,SSI1, + SSI0,TSSI,UIRQ,KBC,UIRQ,UIRQ,UIRQ,UIRQ, + UIRQ,UIRQ,SADC,ETH,UHC,OTG,UIRQ,UIRQ, + UIRQ,TCU2,TCU1,TCU0,GPS,IPU,CIM,LCD, + + RTC,OWI,AIC,MSC2,MSC1,MSC0,SCC,BCH, // 32 + PCM,HARB0,HARB2,AOSD,CPM,UIRQ, + + DMA0,DMA1,DMA2,DMA3,DMA4,DMA5,DMA6,DMA7, // 46 + DMA8,DMA9,DMA10,DMA11,MDMA0,MDMA1,MDMA2,BDMA0, + BDMA1,BDMA2, + + GPIO0,GPIO1,GPIO2,GPIO3,GPIO4,GPIO5,GPIO6,GPIO7, // 64 + GPIO8,GPIO9,GPIO10,GPIO11,GPIO12,GPIO13,GPIO14,GPIO15, + GPIO16,GPIO17,GPIO18,GPIO19,GPIO20,GPIO21,GPIO22,GPIO23, + GPIO24,GPIO25,GPIO26,GPIO27,GPIO28,GPIO29,GPIO30,GPIO31, + GPIO32,GPIO33,GPIO34,GPIO35,GPIO36,GPIO37,GPIO38,GPIO39, + GPIO40,GPIO41,GPIO42,GPIO43,GPIO44,GPIO45,GPIO46,GPIO47, + GPIO48,GPIO49,GPIO50,GPIO51,GPIO52,GPIO53,GPIO54,GPIO55, + GPIO56,GPIO57,GPIO58,GPIO59,GPIO60,GPIO61,GPIO62,GPIO63, + GPIO64,GPIO65,GPIO66,GPIO67,GPIO68,GPIO69,GPIO70,GPIO71, + GPIO72,GPIO73,GPIO74,GPIO75,GPIO76,GPIO77,GPIO78,GPIO79, + GPIO80,GPIO81,GPIO82,GPIO83,GPIO84,GPIO85,GPIO86,GPIO87, + GPIO88,GPIO89,GPIO90,GPIO91,GPIO92,GPIO93,GPIO94,GPIO95, + GPIO96,GPIO97,GPIO98,GPIO99,GPIO100,GPIO101,GPIO102,GPIO103, + GPIO104,GPIO105,GPIO106,GPIO107,GPIO108,GPIO109,GPIO110,GPIO111, + GPIO112,GPIO113,GPIO114,GPIO115,GPIO116,GPIO117,GPIO118,GPIO119, + GPIO120,GPIO121,GPIO122,GPIO123,GPIO124,GPIO125,GPIO126,GPIO127, + GPIO128,GPIO129,GPIO130,GPIO131,GPIO132,GPIO133,GPIO134,GPIO135, + GPIO136,GPIO137,GPIO138,GPIO139,GPIO140,GPIO141,GPIO142,GPIO143, + GPIO144,GPIO145,GPIO146,GPIO147,GPIO148,GPIO149,GPIO150,GPIO151, + GPIO152,GPIO153,GPIO154,GPIO155,GPIO156,GPIO157,GPIO158,GPIO159, + GPIO160,GPIO161,GPIO162,GPIO163,GPIO164,GPIO165,GPIO166,GPIO167, + GPIO168,GPIO169,GPIO170,GPIO171,GPIO172,GPIO173,GPIO174,GPIO175, + GPIO176,GPIO177,GPIO178,GPIO179,GPIO180,GPIO181,GPIO182,GPIO183, + GPIO184,GPIO185,GPIO186,GPIO187,GPIO188,GPIO189,GPIO190,GPIO191 +}; + +static unsigned int dma_irq_mask = 0; +static unsigned char mdma_irq_mask = 0; +static unsigned char bdma_irq_mask = 0; +static unsigned int gpio_irq_mask[6] = {0}; + +void system_enable_irq(unsigned int irq) +{ + register unsigned int t; + if ((irq >= IRQ_GPIO_0) && (irq <= IRQ_GPIO_0 + NUM_GPIO)) + { + __gpio_unmask_irq(irq - IRQ_GPIO_0); + t = (irq - IRQ_GPIO_0) >> 5; + gpio_irq_mask[t] |= (1 << ((irq - IRQ_GPIO_0) & 0x1f)); + __intc_unmask_irq(IRQ_GPIO0 - t); + } + else if ((irq >= IRQ_DMA_0) && (irq <= IRQ_DMA_0 + NUM_DMA)) + { + __dmac_channel_enable_irq(irq - IRQ_DMA_0); + t = (irq - IRQ_DMA_0) / HALF_DMA_NUM; + dma_irq_mask |= (1 << (irq - IRQ_DMA_0)); + __intc_unmask_irq(IRQ_DMAC0 - t); + } + else if ((irq >= IRQ_MDMA_0) && (irq <= IRQ_MDMA_0 + NUM_MDMA)) + { + __mdmac_channel_enable_irq(irq - IRQ_MDMA_0); + mdma_irq_mask |= (1 << (irq - IRQ_MDMA_0)); + __intc_unmask_irq(IRQ_MDMA); + } + else if ((irq >= IRQ_BDMA_0) && (irq <= IRQ_BDMA_0 + NUM_BDMA)) + { + __bdmac_channel_enable_irq(irq - IRQ_BDMA_0); + bdma_irq_mask |= (1 << (irq - IRQ_BDMA_0)); + __intc_unmask_irq(IRQ_BDMA); + } + else if (irq < IRQ_INTC_MAX) + __intc_unmask_irq(irq); +} + +static void dis_irq(unsigned int irq) +{ + register unsigned int t; + if ((irq >= IRQ_GPIO_0) && (irq <= IRQ_GPIO_0 + NUM_GPIO)) + { + __gpio_mask_irq(irq - IRQ_GPIO_0); + t = (irq - IRQ_GPIO_0) >> 5; + gpio_irq_mask[t] &= ~(1 << ((irq - IRQ_GPIO_0) & 0x1f)); + if (!gpio_irq_mask[t]) + __intc_mask_irq(IRQ_GPIO0 - t); + } + else if ((irq >= IRQ_DMA_0) && (irq < IRQ_DMA_0 + NUM_DMA)) + { + __dmac_channel_disable_irq(irq - IRQ_DMA_0); + dma_irq_mask &= ~(1 << (irq - IRQ_DMA_0)); + if (!(dma_irq_mask & 0x003F)) + __intc_mask_irq(IRQ_DMAC0); + if (!(dma_irq_mask & 0x0FC0)) + __intc_mask_irq(IRQ_DMAC1); + } + else if ((irq >= IRQ_MDMA_0) && (irq < IRQ_MDMA_0 + NUM_MDMA)) + { + __mdmac_channel_disable_irq(irq - IRQ_MDMA_0); + mdma_irq_mask &= ~(1 << (irq - IRQ_MDMA_0)); + if (!mdma_irq_mask) + __intc_mask_irq(IRQ_MDMA); + } + else if ((irq >= IRQ_BDMA_0) && (irq < IRQ_BDMA_0 + NUM_BDMA)) + { + __bdmac_channel_disable_irq(irq - IRQ_BDMA_0); + bdma_irq_mask &= ~(1 << (irq - IRQ_BDMA_0)); + if (!bdma_irq_mask) + __intc_mask_irq(IRQ_BDMA); + } + else if (irq < IRQ_INTC_MAX) + __intc_mask_irq(irq); +} + +static void ack_irq(unsigned int irq) +{ + if ((irq >= IRQ_GPIO_0) && (irq <= IRQ_GPIO_0 + NUM_GPIO)) + { + __gpio_ack_irq(irq - IRQ_GPIO_0); + } +} + +static int get_irq_number(void) +{ + static unsigned long ipl0, ipl1; + register int irq0, irq1; + + ipl0 |= REG_INTC_ICPR(0); + ipl1 |= REG_INTC_ICPR(1); + + if (!(ipl0 || ipl1)) + return -1; + + __asm__ __volatile__("negu $8, %0 \n" + "and $8, %0, $8 \n" + "clz %0, %1 \n" + "li $8, 31 \n" + "subu %0, $8, %0 \n" + : "=r" (irq0) + : "r" (ipl0) + : "t0" + ); + + __asm__ __volatile__("negu $8, %0 \n" + "and $8, %0, $8 \n" + "clz %0, %1 \n" + "li $8, 31 \n" + "subu %0, $8, %0 \n" + : "=r" (irq1) + : "r" (ipl1) + : "t0" + ); + + if (UNLIKELY(irq0 < 0) && UNLIKELY(irq1 < 0)) + return -1; + + if (!(ipl0 & 3)) { + if (ipl0) { + irq = irq0; + ipl0 &= ~(1<= 0)) + irqvector[irq](); +} + +#define EXC(x,y) case (x): return (y); +static char* parse_exception(unsigned int cause) +{ + switch(cause & M_CauseExcCode) + { + EXC(EXC_INT, "Interrupt"); + EXC(EXC_MOD, "TLB Modified"); + EXC(EXC_TLBL, "TLB Exception (Load or Ifetch)"); + EXC(EXC_ADEL, "Address Error (Load or Ifetch)"); + EXC(EXC_ADES, "Address Error (Store)"); + EXC(EXC_TLBS, "TLB Exception (Store)"); + EXC(EXC_IBE, "Instruction Bus Error"); + EXC(EXC_DBE, "Data Bus Error"); + EXC(EXC_SYS, "Syscall"); + EXC(EXC_BP, "Breakpoint"); + EXC(EXC_RI, "Reserved Instruction"); + EXC(EXC_CPU, "Coprocessor Unusable"); + EXC(EXC_OV, "Overflow"); + EXC(EXC_TR, "Trap Instruction"); + EXC(EXC_FPE, "Floating Point Exception"); + EXC(EXC_C2E, "COP2 Exception"); + EXC(EXC_MDMX, "MDMX Exception"); + EXC(EXC_WATCH, "Watch Exception"); + EXC(EXC_MCHECK, "Machine Check Exception"); + EXC(EXC_CacheErr, "Cache error caused re-entry to Debug Mode"); + default: + return NULL; + } +} + +void exception_handler(void* stack_ptr, unsigned int cause, unsigned int epc) +{ + panicf("Exception occurred: %s [0x%08x] at 0x%08x (stack at 0x%08x)", parse_exception(cause), read_c0_badvaddr(), epc, (unsigned int)stack_ptr); +} + +void tlb_refill_handler(void) +{ + panicf("TLB refill handler at 0x%08lx! [0x%x]", read_c0_epc(), read_c0_badvaddr()); +} + +void udelay(unsigned int usec) +{ + unsigned int i = usec * (__cpm_get_cclk() / 2000000); + __asm__ __volatile__ ( + ".set noreorder \n" + "1: \n" + "bne %0, $0, 1b \n" + "addi %0, %0, -1 \n" + ".set reorder \n" + : "=r" (i) + : "0" (i) + ); +} + +void mdelay(unsigned int msec) +{ + unsigned int i; + for(i=0; i 1500 * MHZ) + continue; + for (k = pll_n_min; k <= pll_n_max; k++) { + n = k; + + /* Limit: 1MHZ <= XIN/N <= 50MHZ */ + if ((xtal / n) < (1 * MHZ)) + break; + if ((xtal / n) > (15 * MHZ)) + continue; + + for (j = pll_m_min; j <= pll_m_max; j++) { + m = j*2; + + raw = xtal * m / n; + tmp = raw / od[i]; + + tmp = (tmp > speed) ? (tmp - speed) : (speed - tmp); + + if (tmp < distance) { + distance = tmp; + + plcr_m_n_od = (j << CPPCR0_PLLM_LSB) + | (k << CPPCR0_PLLN_LSB) + | (i << CPPCR0_PLLOD_LSB); + + if (!distance) { /* Match. */ + return plcr_m_n_od; + } + } + } + } + } + return plcr_m_n_od; +} + +/* PLL output clock = EXTAL * NF / (NR * NO) + * + * NF = FD + 2, NR = RD + 2 + * NO = 1 (if OD = 0), NO = 2 (if OD = 1 or 2), NO = 4 (if OD = 3) + */ +static void pll0_init(unsigned int freq) +{ + register unsigned int cfcr, plcr1; + int n2FR[9] = { + 0, 0, 1, 2, 3, 0, 4, 0, 5 + }; + + /** divisors, + * for jz4760b,I:H:H2:P:M:S. + * DIV should be one of [1, 2, 3, 4, 6, 8] + */ + int div[6] = {1, 4, 4, 4, 4, 4}; + int usbdiv; + + /* set ahb **/ + REG32(HARB0_BASE) = 0x00300000; + REG32(0xb3070048) = 0x00000000; + REG32(HARB2_BASE) = 0x00FFFFFF; + + cfcr = CPCCR_PCS | + (n2FR[div[0]] << CPCCR_CDIV_LSB) | + (n2FR[div[1]] << CPCCR_HDIV_LSB) | + (n2FR[div[2]] << CPCCR_H2DIV_LSB) | + (n2FR[div[3]] << CPCCR_PDIV_LSB) | + (n2FR[div[4]] << CPCCR_MDIV_LSB) | + (n2FR[div[5]] << CPCCR_SDIV_LSB); + + // write REG_DDRC_CTRL 8 times to clear ddr fifo + REG_DDRC_CTRL = 0; + REG_DDRC_CTRL = 0; + REG_DDRC_CTRL = 0; + REG_DDRC_CTRL = 0; + REG_DDRC_CTRL = 0; + REG_DDRC_CTRL = 0; + REG_DDRC_CTRL = 0; + REG_DDRC_CTRL = 0; + + if (CFG_EXTAL > 16000000) + cfcr |= CPCCR_ECS; + else + cfcr &= ~CPCCR_ECS; + + cfcr &= ~CPCCR_MEM; /* mddr */ + cfcr |= CPCCR_CE; + + plcr1 = pll_calc_m_n_od(freq, CFG_EXTAL); + plcr1 |= (0x20 << CPPCR0_PLLST_LSB) /* PLL stable time */ + | CPPCR0_PLLEN; /* enable PLL */ + + /* + * Init USB Host clock, pllout2 must be n*48MHz + * For JZ4760b UHC - River. + */ + usbdiv = (cfcr & CPCCR_PCS) ? CPU_FREQ : (CPU_FREQ / 2); + REG_CPM_UHCCDR = usbdiv / 48000000 - 1; + + /* init PLL */ + REG_CPM_CPCCR = cfcr; + REG_CPM_CPPCR0 = plcr1; + + __cpm_enable_pll_change(); + + /*wait for pll output stable ...*/ + while (!(REG_CPM_CPPCR0 & CPPCR0_PLLS)); + + REG_CPM_CPPCR0 &= ~CPPCR0_LOCK; +} + +void pll1_init(unsigned int freq) +{ + register unsigned int plcr2; + + /* set CPM_CPCCR_MEM only for ddr1 or ddr2 */ + plcr2 = pll_calc_m_n_od(freq, CFG_EXTAL) + | CPPCR1_PLL1EN; /* enable PLL1 */ + + /* init PLL_1 , source clock is extal clock */ + REG_CPM_CPPCR1 = plcr2; + + __cpm_enable_pll_change(); + + /*wait for pll_1 output stable ...*/ + while (!(REG_CPM_CPPCR1 & CPPCR1_PLL1S)); + + REG_CPM_CPPCR1 &= ~CPPCR1_LOCK; +} + +static void serial_setbrg(void) +{ + volatile u8 *uart_lcr = (volatile u8 *)(CFG_UART_BASE + OFF_LCR); + volatile u8 *uart_dlhr = (volatile u8 *)(CFG_UART_BASE + OFF_DLHR); + volatile u8 *uart_dllr = (volatile u8 *)(CFG_UART_BASE + OFF_DLLR); + volatile u8 *uart_umr = (volatile u8 *)(CFG_UART_BASE + OFF_UMR); + volatile u8 *uart_uacr = (volatile u8 *)(CFG_UART_BASE + OFF_UACR); + u16 baud_div, tmp; + + *uart_umr = 16; + *uart_uacr = 0; + baud_div = 13; /* 57600 */ + + tmp = *uart_lcr; + tmp |= UARTLCR_DLAB; + *uart_lcr = tmp; + + *uart_dlhr = (baud_div >> 8) & 0xff; + *uart_dllr = baud_div & 0xff; + + tmp &= ~UARTLCR_DLAB; + *uart_lcr = tmp; +} + +int serial_preinit(void) +{ + volatile u8 *uart_fcr = (volatile u8 *)(CFG_UART_BASE + OFF_FCR); + volatile u8 *uart_lcr = (volatile u8 *)(CFG_UART_BASE + OFF_LCR); + volatile u8 *uart_ier = (volatile u8 *)(CFG_UART_BASE + OFF_IER); + volatile u8 *uart_sircr = (volatile u8 *)(CFG_UART_BASE + OFF_SIRCR); + + __gpio_as_uart1(); + __cpm_start_uart1(); + + /* Disable port interrupts while changing hardware */ + *uart_ier = 0; + + /* Disable UART unit function */ + *uart_fcr = ~UARTFCR_UUE; + + /* Set both receiver and transmitter in UART mode (not SIR) */ + *uart_sircr = ~(SIRCR_RSIRE | SIRCR_TSIRE); + + /* Set databits, stopbits and parity. (8-bit data, 1 stopbit, no parity) */ + *uart_lcr = UARTLCR_WLEN_8 | UARTLCR_STOP1; + + /* Set baud rate */ + serial_setbrg(); + + /* Enable UART unit, enable and clear FIFO */ + *uart_fcr = UARTFCR_UUE | UARTFCR_FE | UARTFCR_TFLS | UARTFCR_RFLS; + + return 0; +} + +void usb_preinit(void) +{ + /* Clear ECS bit of CPCCR, 0:clock source is EXCLK, 1:clock source is EXCLK/2 */ + REG_CPM_CPCCR &= ~CPCCR_ECS; + + /* Clear all bits of USBCDR, 0:OTG clock source is pin EXCLK, PLL0 output, divider = 1:12MHZ */ + REG_CPM_USBCDR = 0; + + /* Set CE bit of CPCCR, it means frequence is changed immediately */ + REG_CPM_CPCCR |= CPCCR_CE; + + udelay(3); + + /* Clear OTG bit of CLKGR0, 0:device can be accessed */ + REG_CPM_CLKGR0 &= ~CLKGR0_OTG; + + /* fil */ + REG_CPM_USBVBFIL = 0x80; + + /* rdt */ + REG_CPM_USBRDT = (600 * (CPU_FREQ / 1000000)) / 1000; + + /* rdt - filload_en */ + REG_CPM_USBRDT |= (1 << 25); + + /* TXRISETUNE & TXVREFTUNE. */ + REG_CPM_USBPCR &= ~0x3f; + REG_CPM_USBPCR |= 0x35; + + /* enable tx pre-emphasis */ + REG_CPM_USBPCR |= 0x40; + + /* most DC leave of tx */ + REG_CPM_USBPCR |= 0xf; + + /* Device Mode. */ + REG_CPM_USBPCR &= ~(1 << 31); + REG_CPM_USBPCR |= USBPCR_VBUSVLDEXT; + + /* phy reset */ + REG_CPM_USBPCR |= USBPCR_POR; + udelay(30); + REG_CPM_USBPCR &= ~USBPCR_POR; + udelay(300); + + /* Enable the USB PHY */ + REG_CPM_OPCR |= OPCR_OTGPHY_ENABLE; + + /* Wait PHY Clock Stable. */ + udelay(300); +} + +void dma_preinit(void) +{ + __cpm_start_mdma(); + __cpm_start_dmac(); + + REG_MDMAC_DMACKES = 0x1; + + REG_DMAC_DMACR(DMA_AIC_TX_CHANNEL) = DMAC_DMACR_DMAE | DMAC_DMACR_FAIC; + REG_DMAC_DMACR(DMA_SD_RX_CHANNEL) = DMAC_DMACR_DMAE | DMAC_DMACR_FMSC; + REG_DMAC_DMACR(DMA_SD_TX_CHANNEL) = DMAC_DMACR_DMAE | DMAC_DMACR_FMSC; +} + +/* Gets called *before* main */ +void ICODE_ATTR system_main(void) +{ + int i; + + __dcache_writeback_all(); + __icache_invalidate_all(); + + write_c0_status(1 << 28 | 1 << 10 ); /* Enable CP | Mask interrupt 2 */ + + /* Disable all interrupts */ + for(i=0; i 60ms */ + rtc_write_reg(RTC_HRCR, HRCR_WAIT_TIME(60)); + + /* clear wakeup status register */ + rtc_write_reg(RTC_HWRSR, 0x0); + + /* set wake up valid level as low */ + rtc_write_reg(RTC_HWCR,0x8); + + /* Put CPU to hibernate mode */ + rtc_write_reg(RTC_HCR, HCR_PD); + + while (1); +} + +void system_init(void) +{ +} + +int system_memory_guard(int newmode) +{ + (void)newmode; + return 0; +} + +#ifdef HAVE_ADJUSTABLE_CPU_FREQ +void set_cpu_frequency(long frequency) +{ + serial_putsf("set_cpu_frequency: %d\n", frequency); +} +#endif diff --git a/firmware/target/mips/ingenic_jz47xx/system-target.h b/firmware/target/mips/ingenic_jz47xx/system-target.h index 1c2e7d7173..9720d3a80c 100644 --- a/firmware/target/mips/ingenic_jz47xx/system-target.h +++ b/firmware/target/mips/ingenic_jz47xx/system-target.h @@ -25,7 +25,7 @@ #include #include "config.h" -#include "jz4740.h" +#include "cpu.h" #include "mipsregs.h" #define CACHE_SIZE 16*1024 @@ -35,6 +35,8 @@ /* no optimized byteswap functions implemented for mips, yet */ #define NEED_GENERIC_BYTESWAPS +#define STORAGE_WANTS_ALIGN + /* This one returns the old status */ static inline int set_interrupt_status(int status, int mask) { @@ -86,10 +88,18 @@ void mdelay(unsigned int msec); void dma_enable(void); void dma_disable(void); +#if CONFIG_CPU == JZ4732 #define DMA_AIC_TX_CHANNEL 0 #define DMA_NAND_CHANNEL 1 #define DMA_USB_CHANNEL 2 #define DMA_LCD_CHANNEL 3 +#elif CONFIG_CPU == JZ4760B +#define DMA_AIC_TX_CHANNEL 0 +#define DMA_NAND_CHANNEL 1 +#define DMA_USB_CHANNEL 2 +#define DMA_SD_RX_CHANNEL 3 +#define DMA_SD_TX_CHANNEL 4 +#endif #define XDMA_CALLBACK(n) DMA ## n #define DMA_CALLBACK(n) XDMA_CALLBACK(n) @@ -103,7 +113,7 @@ void dma_disable(void); */ static inline void core_sleep(void) { -#if CONFIG_CPU == JZ4732 +#if CONFIG_CPU == JZ4732 || CONFIG_CPU == JZ4760B __cpm_idle_mode(); #endif asm volatile(".set mips32r2 \n" diff --git a/firmware/target/mips/ingenic_jz47xx/timer-jz4760.c b/firmware/target/mips/ingenic_jz47xx/timer-jz4760.c new file mode 100644 index 0000000000..0f16825b34 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/timer-jz4760.c @@ -0,0 +1,101 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "timer.h" + +/* Interrupt handler */ +void TCU1(void) +{ + __tcu_clear_full_match_flag(5); + + if (pfn_timer != NULL) + pfn_timer(); +} + +bool timer_set(long cycles, bool start) +{ + unsigned int divider = cycles, prescaler_bit = 0, prescaler = 1, old_irq; + + if(cycles < 1) + return false; + + if(start && pfn_unregister != NULL) + { + pfn_unregister(); + pfn_unregister = NULL; + } + + /* Increase prescale values starting from 0 to make the cycle count fit */ + while(divider > 65535 && prescaler <= 1024) + { + prescaler <<= 2; /* 1, 4, 16, 64, 256, 1024 */ + prescaler_bit++; + divider = cycles / prescaler; + } + + old_irq = disable_irq_save(); + + __tcu_stop_counter(5); + if(start) + { + __tcu_disable_pwm_output(5); + + __tcu_mask_half_match_irq(5); + __tcu_unmask_full_match_irq(5); + + /* EXTAL clock = CFG_EXTAL (12Mhz in most targets) */ + __tcu_select_extalclk(5); + } + + REG_TCU_TCSR(5) = (REG_TCU_TCSR(5) & ~TCSR_PRESCALE_MASK) | (prescaler_bit << TCSR_PRESCALE_LSB); + REG_TCU_TCNT(5) = 0; + REG_TCU_TDHR(5) = 0; + REG_TCU_TDFR(5) = divider; + + __tcu_clear_full_match_flag(5); + + if(start) + { + system_enable_irq(IRQ_TCU1); + __tcu_start_counter(5); + } + + restore_irq(old_irq); + + return true; +} + +bool timer_start(void) +{ + __tcu_start_counter(5); + + return true; +} + +void timer_stop(void) +{ + unsigned int old_irq = disable_irq_save(); + __tcu_stop_counter(5); + restore_irq(old_irq); +} diff --git a/firmware/target/mips/ingenic_jz47xx/usb-jz4760.c b/firmware/target/mips/ingenic_jz47xx/usb-jz4760.c new file mode 100644 index 0000000000..bc2158fb6f --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/usb-jz4760.c @@ -0,0 +1,870 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +/*#define LOGF_ENABLE*/ +#include "logf.h" +#include "system.h" +#include "usb_ch9.h" +#include "usb_drv.h" +#include "usb_core.h" +#include "cpu.h" +#include "thread.h" + +#define PIN_USB_DET (32*4+19) +#define IRQ_USB_DET GPIO_IRQ(PIN_USB_DET) +#define GPIO_USB_DET GPIO147 + +#define PIN_USB_DRVVBUS (32*4+10) +#define PIN_USB_OTG_ID (32*3+7) + +#define EP_BUF_LEFT(ep) ((ep)->length - (ep)->sent) +#define EP_PTR(ep) ((void*)((unsigned int)(ep)->buf + (ep)->sent)) +#define EP_NUMBER(ep) (((int)(ep) - (int)&endpoints[0])/sizeof(struct usb_endpoint)) +#define EP_NUMBER2(ep) (EP_NUMBER((ep))/2) +#define TOTAL_EP() (sizeof(endpoints)/sizeof(struct usb_endpoint)) +#define EP_IS_IN(ep) (EP_NUMBER((ep))%2) + +enum ep_type +{ + ep_control, + ep_bulk, + ep_interrupt, + ep_isochronous +}; + +struct usb_endpoint +{ + void *buf; + size_t length; + union + { + size_t sent; + size_t received; + }; + bool busy; + + const enum ep_type type; + const bool use_dma; + + const long fifo_addr; + unsigned short fifo_size; + + bool wait; + struct semaphore complete; +}; + +#define EP_INIT(_type, _fifo_addr, _fifo_size, _buf, _use_dma) \ + { .type = (_type), .fifo_addr = (_fifo_addr), .fifo_size = (_fifo_size), \ + .buf = (_buf), .use_dma = (_use_dma), .length = 0, .busy = false, .wait = false } + +static unsigned char ep0_rx_buf[64]; +static struct usb_endpoint endpoints[] = +{ + EP_INIT(ep_control, USB_FIFO_EP(0), 64, NULL, false), + EP_INIT(ep_control, USB_FIFO_EP(0), 64, &ep0_rx_buf, false), + EP_INIT(ep_bulk, USB_FIFO_EP(1), 512, NULL, false), + EP_INIT(ep_bulk, USB_FIFO_EP(1), 512, NULL, false), + EP_INIT(ep_interrupt, USB_FIFO_EP(2), 64, NULL, false), + EP_INIT(ep_interrupt, USB_FIFO_EP(2), 64, NULL, false), +}; + +static inline void select_endpoint(int ep) +{ + REG_USB_INDEX = ep; +} + +static void readFIFO(struct usb_endpoint *ep, unsigned int size) +{ + logf("%s(EP%d, %d)", __func__, EP_NUMBER2(ep), size); + + register unsigned char *ptr = (unsigned char*)EP_PTR(ep); + register unsigned int *ptr32 = (unsigned int*)ptr; + register unsigned int s = size >> 2; + register unsigned int x; + + if(size > 0) + { + if( ((unsigned int)ptr & 3) == 0 ) + { + while(s--) + *ptr32++ = REG32(ep->fifo_addr); + + ptr = (unsigned char*)ptr32; + } + else + { + while(s--) + { + x = REG32(ep->fifo_addr); + *ptr++ = x & 0xFF; x >>= 8; + *ptr++ = x & 0xFF; x >>= 8; + *ptr++ = x & 0xFF; x >>= 8; + *ptr++ = x; + } + } + + s = size & 3; + while(s--) + *ptr++ = REG8(ep->fifo_addr); + } +} + +static void writeFIFO(struct usb_endpoint *ep, size_t size) +{ + logf("%s(EP%d, %d)", __func__, EP_NUMBER2(ep), size); + + register unsigned int *d32 = (unsigned int *)EP_PTR(ep); + register size_t s = size >> 2; + + if(size > 0) + { + while (s--) + REG32(ep->fifo_addr) = *d32++; + + if( (s = size & 3) ) + { + register unsigned char *d8 = (unsigned char *)d32; + while (s--) + REG8(ep->fifo_addr) = *d8++; + } + } +} + +static void flushFIFO(struct usb_endpoint *ep) +{ + logf("%s(%d)", __func__, EP_NUMBER(ep)); + + switch (ep->type) + { + case ep_control: + break; + + case ep_bulk: + case ep_interrupt: + case ep_isochronous: + if(EP_IS_IN(ep)) + REG_USB_INCSR |= (USB_INCSR_FF | USB_INCSR_CDT); + else + REG_USB_OUTCSR |= (USB_OUTCSR_FF | USB_OUTCSR_CDT); + break; + } +} + +static inline void ep_transfer_completed(struct usb_endpoint* ep) +{ + ep->sent = 0; + ep->length = 0; + ep->buf = NULL; + ep->busy = false; + if(ep->wait) + semaphore_release(&ep->complete); +} + +static void EP0_send(void) +{ + struct usb_endpoint* ep = &endpoints[0]; + unsigned int length; + unsigned char csr0; + + select_endpoint(0); + csr0 = REG_USB_CSR0; + + if(ep->sent == 0) + length = MIN(ep->length, ep->fifo_size); + else + length = MIN(EP_BUF_LEFT(ep), ep->fifo_size); + + writeFIFO(ep, length); + ep->sent += length; + + if(ep->sent >= ep->length) + { + REG_USB_CSR0 = (csr0 | USB_CSR0_INPKTRDY | USB_CSR0_DATAEND); /* Set data end! */ + usb_core_transfer_complete(0, USB_DIR_IN, 0, ep->sent); + ep_transfer_completed(ep); + } + else + REG_USB_CSR0 = (csr0 | USB_CSR0_INPKTRDY); +} + +static void EP0_handler(void) +{ + logf("%s()", __func__); + + unsigned char csr0; + struct usb_endpoint *ep_send = &endpoints[0]; + struct usb_endpoint *ep_recv = &endpoints[1]; + + /* Read CSR0 */ + select_endpoint(0); + csr0 = REG_USB_CSR0; + + /* Check for SentStall: + This bit is set when a STALL handshake is transmitted. The CPU should clear this bit. + */ + if(csr0 & USB_CSR0_SENTSTALL) + { + REG_USB_CSR0 = csr0 & ~USB_CSR0_SENTSTALL; + return; + } + + /* Check for SetupEnd: + This bit will be set when a control transaction ends before the DataEnd bit has been set. + An interrupt will be generated and the FIFO flushed at this time. + The bit is cleared by the CPU writing a 1 to the ServicedSetupEnd bit. + */ + if(csr0 & USB_CSR0_SETUPEND) + { + REG_USB_CSR0 = csr0 | USB_CSR0_SVDSETUPEND; + return; + } + + /* Call relevant routines for endpoint 0 state */ + if(ep_send->busy) + EP0_send(); + else if(csr0 & USB_CSR0_OUTPKTRDY) /* There is a packet in the fifo */ + { + readFIFO(ep_recv, REG_USB_COUNT0); + REG_USB_CSR0 = csr0 | USB_CSR0_SVDOUTPKTRDY; /* clear OUTPKTRDY bit */ + usb_core_control_request((struct usb_ctrlrequest*)ep_recv->buf); + } +} + +static void EPIN_handler(unsigned int endpoint) +{ + struct usb_endpoint* ep = &endpoints[endpoint*2]; + unsigned int length, csr; + + select_endpoint(endpoint); + csr = REG_USB_INCSR; + logf("%s(%d): 0x%x", __func__, endpoint, csr); + + if(!ep->busy) + { + logf("Entered EPIN handler without work!"); + return; + } + + if(csr & USB_INCSR_SENTSTALL) + { + REG_USB_INCSR = csr & ~USB_INCSR_SENTSTALL; + return; + } + + if(ep->use_dma) + return; + + if(csr & USB_INCSR_FFNOTEMPT) + { + logf("FIFO is not empty! 0x%x", csr); + return; + } + + logf("EP%d: %d -> %d", endpoint, ep->sent, ep->length); + + if(ep->sent == 0) + length = MIN(ep->length, ep->fifo_size); + else + length = MIN(EP_BUF_LEFT(ep), ep->fifo_size); + + writeFIFO(ep, length); + REG_USB_INCSR = csr | USB_INCSR_INPKTRDY; + ep->sent += length; + + if(ep->sent >= ep->length) + { + usb_core_transfer_complete(endpoint, USB_DIR_IN, 0, ep->sent); + ep_transfer_completed(ep); + logf("sent complete"); + } +} + +static void EPOUT_handler(unsigned int endpoint) +{ + struct usb_endpoint* ep = &endpoints[endpoint*2+1]; + unsigned int size, csr; + + if(!ep->busy) + { + logf("Entered EPOUT handler without work!"); + return; + } + + select_endpoint(endpoint); + while((csr = REG_USB_OUTCSR) & (USB_OUTCSR_SENTSTALL|USB_OUTCSR_OUTPKTRDY)) + { + logf("%s(%d): 0x%x", __func__, endpoint, csr); + if(csr & USB_OUTCSR_SENTSTALL) + { + logf("stall sent, flushing fifo.."); + flushFIFO(ep); + REG_USB_OUTCSR = csr & ~USB_OUTCSR_SENTSTALL; + return; + } + + if(ep->use_dma) + return; + + if(csr & USB_OUTCSR_OUTPKTRDY) /* There is a packet in the fifo */ + { + size = REG_USB_OUTCOUNT; + + readFIFO(ep, size); + ep->received += size; + + /*if(csr & USB_OUTCSR_FFFULL) + csr &= ~USB_OUTCSR_FFFULL;*/ + + REG_USB_OUTCSR = csr & ~USB_OUTCSR_OUTPKTRDY; + + logf("received: %d max length: %d", ep->received, ep->length); + + if(size < ep->fifo_size || ep->received >= ep->length) + { + usb_core_transfer_complete(endpoint, USB_DIR_OUT, 0, ep->received); + ep_transfer_completed(ep); + logf("receive transfer_complete"); + } + } + } +} + +static void EPDMA_handler(int number) +{ + int endpoint = -1; + unsigned int size = 0; + + if(number == USB_INTR_DMA_BULKIN) + endpoint = (REG_USB_CNTL(0) >> 4) & 0xF; + else if(number == USB_INTR_DMA_BULKOUT) + endpoint = (REG_USB_CNTL(1) >> 4) & 0xF; + + struct usb_endpoint* ep = &endpoints[endpoint]; + logf("DMA_BULK%d %d", number, endpoint); + + if(number == USB_INTR_DMA_BULKIN) + size = (unsigned int)ep->buf - REG_USB_ADDR(0); + else if(number == USB_INTR_DMA_BULKOUT) + size = (unsigned int)ep->buf - REG_USB_ADDR(1); + + if(number == USB_INTR_DMA_BULKOUT) + { + /* Disable DMA */ + REG_USB_CNTL(1) = 0; + + __dcache_invalidate_all(); + + select_endpoint(endpoint); + /* Read out last packet manually */ + unsigned int lpack_size = REG_USB_OUTCOUNT; + if(lpack_size > 0) + { + ep->buf += ep->length - lpack_size; + readFIFO(ep, lpack_size); + REG_USB_OUTCSR &= ~USB_OUTCSR_OUTPKTRDY; + } + } + else if(number == USB_INTR_DMA_BULKIN && size % ep->fifo_size) + { + /* If the last packet is less than MAXP, set INPKTRDY manually */ + REG_USB_INCSR |= USB_INCSR_INPKTRDY; + } + + usb_core_transfer_complete(endpoint, EP_IS_IN(ep) ? USB_DIR_IN : USB_DIR_OUT, + 0, ep->length); + ep_transfer_completed(ep); +} + +static void setup_endpoint(struct usb_endpoint *ep) +{ + int csr, csrh; + + select_endpoint(EP_NUMBER2(ep)); + + ep->busy = false; + ep->wait = false; + ep->sent = 0; + ep->length = 0; + + if(ep->type == ep_bulk) + { + if(REG_USB_POWER & USB_POWER_HSMODE) + ep->fifo_size = 512; + else + ep->fifo_size = 64; + } + + if(EP_IS_IN(ep)) + { + csr = (USB_INCSR_FF | USB_INCSR_CDT); + csrh = USB_INCSRH_MODE; + + if(ep->use_dma) + csrh |= (USB_INCSRH_DMAREQENAB | USB_INCSRH_AUTOSET | USB_INCSRH_DMAREQMODE); + + if(ep->type == ep_interrupt) + csrh |= USB_INCSRH_FRCDATATOG; + + REG_USB_INMAXP = ep->fifo_size; + REG_USB_INCSR = csr; + REG_USB_INCSRH = csrh; + REG_USB_INTRINE |= USB_INTR_EP(EP_NUMBER2(ep)); + } + else + { + csr = (USB_OUTCSR_FF | USB_OUTCSR_CDT); + csrh = 0; + + if(ep->type == ep_interrupt) + csrh |= USB_OUTCSRH_DNYT; + + if(ep->use_dma) + csrh |= (USB_OUTCSRH_DMAREQENAB | USB_OUTCSRH_AUTOCLR | USB_OUTCSRH_DMAREQMODE); + + REG_USB_OUTMAXP = ep->fifo_size; + REG_USB_OUTCSR = csr; + REG_USB_OUTCSRH = csrh; + REG_USB_INTROUTE |= USB_INTR_EP(EP_NUMBER2(ep)); + } +} + +static void udc_reset(void) +{ + /* From the datasheet: + + When a reset condition is detected on the USB, the controller performs the following actions: + * Sets FAddr to 0. + * Sets Index to 0. + * Flushes all endpoint FIFOs. + * Clears all control/status registers. + * Enables all endpoint interrupts. + * Generates a Reset interrupt. + */ + + logf("%s()", __func__); + + unsigned int i; + + REG_USB_FADDR = 0; + REG_USB_INDEX = 0; + + /* Disable interrupts */ + REG_USB_INTRINE = 0; + REG_USB_INTROUTE = 0; + REG_USB_INTRUSBE = 0; + + /* Disable DMA */ + REG_USB_CNTL(0) = 0; + REG_USB_CNTL(1) = 0; + + /* High speed, softconnect */ + REG_USB_POWER = (USB_POWER_SOFTCONN | USB_POWER_HSENAB); + + /* Reset EP0 */ + select_endpoint(0); + REG_USB_CSR0 = (USB_CSR0_SVDOUTPKTRDY | USB_CSR0_SVDSETUPEND | USB_CSR0_FLUSHFIFO); + + /* Reset other endpoints */ + for(i=2; itype == ep_control && ptr == NULL && length == 0) + return; /* ACK request, handled in the ISR */ + + int flags = disable_irq_save(); + + ep->buf = ptr; + ep->sent = 0; + ep->length = length; + ep->busy = true; + if(blocking) + ep->wait = true; + + if(ep->type == ep_control) + { + EP0_send(); + } + else + { + if(ep->use_dma) + { + //dma_cache_wback_inv((unsigned long)ptr, length); + __dcache_writeback_all(); + REG_USB_ADDR(0) = PHYSADDR((unsigned long)ptr); + REG_USB_COUNT(0) = length; + REG_USB_CNTL(0) = (USB_CNTL_INTR_EN | USB_CNTL_MODE_1 | + USB_CNTL_DIR_IN | USB_CNTL_ENA | + USB_CNTL_EP(EP_NUMBER2(ep)) | USB_CNTL_BURST_16); + } + else + EPIN_handler(EP_NUMBER2(ep)); + } + + restore_irq(flags); + + if(blocking) + { + semaphore_wait(&ep->complete, TIMEOUT_BLOCK); + ep->wait = false; + } +} + +int usb_drv_send_nonblocking(int endpoint, void* ptr, int length) +{ + logf("%s(%d, 0x%x, %d)", __func__, endpoint, (int)ptr, length); + + usb_drv_send_internal(&endpoints[(endpoint & 0x7F)*2], ptr, length, false); + + return 0; +} + +int usb_drv_send(int endpoint, void* ptr, int length) +{ + logf("%s(%d, 0x%x, %d)", __func__, endpoint, (int)ptr, length); + + usb_drv_send_internal(&endpoints[(endpoint & 0x7F)*2], ptr, length, true); + + return 0; +} + +int usb_drv_recv(int endpoint, void* ptr, int length) +{ + int flags; + struct usb_endpoint *ep; + endpoint &= 0x7F; + + logf("%s(%d, 0x%x, %d)", __func__, endpoint, (int)ptr, length); + + if(endpoint == EP_CONTROL) + return 0; /* all EP0 OUT transactions are handled within the ISR */ + else + { + flags = disable_irq_save(); + ep = &endpoints[endpoint*2+1]; + + ep->buf = ptr; + ep->received = 0; + ep->length = length; + ep->busy = true; + if(ep->use_dma) + { + //dma_cache_wback_inv((unsigned long)ptr, length); + __dcache_writeback_all(); + REG_USB_ADDR(1) = PHYSADDR((unsigned long)ptr); + REG_USB_COUNT(1) = length; + REG_USB_CNTL(1) = (USB_CNTL_INTR_EN | USB_CNTL_MODE_1 | + USB_CNTL_ENA | USB_CNTL_EP(endpoint) | + USB_CNTL_BURST_16); + } + else + EPOUT_handler(endpoint); + + restore_irq(flags); + return 0; + } +} + +void usb_drv_set_test_mode(int mode) +{ + logf("%s(%d)", __func__, mode); + + switch(mode) + { + case 0: + REG_USB_TESTMODE &= ~USB_TEST_ALL; + break; + case 1: + REG_USB_TESTMODE |= USB_TEST_J; + break; + case 2: + REG_USB_TESTMODE |= USB_TEST_K; + break; + case 3: + REG_USB_TESTMODE |= USB_TEST_SE0NAK; + break; + case 4: + REG_USB_TESTMODE |= USB_TEST_PACKET; + break; + } +} + +int usb_drv_port_speed(void) +{ + return (REG_USB_POWER & USB_POWER_HSMODE) ? 1 : 0; +} + +void usb_drv_cancel_all_transfers(void) +{ + logf("%s()", __func__); + + unsigned int i, flags; + flags = disable_irq_save(); + + for(i=0; i> 7) ? "IN" : "OUT"); +} + +int usb_drv_request_endpoint(int type, int dir) +{ + logf("%s(%d, %s)", __func__, type, (dir == USB_DIR_IN) ? "IN" : "OUT"); + + dir &= USB_ENDPOINT_DIR_MASK; + type &= USB_ENDPOINT_XFERTYPE_MASK; + + /* There are only 3+2 endpoints, so hardcode this ... */ + switch(type) + { + case USB_ENDPOINT_XFER_BULK: + if(dir == USB_DIR_IN) + return (1 | USB_DIR_IN); + else + return (1 | USB_DIR_OUT); + + case USB_ENDPOINT_XFER_INT: + if(dir == USB_DIR_IN) + return (2 | USB_DIR_IN); + else + return (2 | USB_DIR_OUT); + + default: + return -1; + } +} diff --git a/firmware/target/mips/ingenic_jz47xx/xdebug.h b/firmware/target/mips/ingenic_jz47xx/xdebug.h new file mode 100644 index 0000000000..2f348e266b --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/xdebug.h @@ -0,0 +1,31 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef __XDEBUG_H_ +#define __XDEBUG_H_ + +void serial_puts(const char *s); +void serial_putsf(const char *format, ...); +void serial_put_hex(unsigned int d); +void serial_put_dec(unsigned int d); +void serial_dump_data(unsigned char* data, int len); + +#endif /* __XDEBUG_H_ */ diff --git a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/adc-target.h b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/adc-target.h new file mode 100644 index 0000000000..c47406ca21 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/adc-target.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef _ADC_TARGET_H_ +#define _ADC_TARGET_H_ + +#define NUM_ADC_CHANNELS 4 + +#define ADC_BUTTONS 0 + +#endif /* _ADC_TARGET_H_ */ diff --git a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/ata-sd-target.h b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/ata-sd-target.h new file mode 100644 index 0000000000..bb2cced15b --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/ata-sd-target.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef ATA_SD_TARGET_H +#define ATA_SD_TARGET_H + +#include "cpu.h" +#include "system.h" + +#define PIN_SD1_CD (32*0+29) /* Pin to check card insertion */ +#define IRQ_SD1_CD GPIO_IRQ(PIN_SD1_CD) +#define GPIO_SD1_CD GPIO29 + +#define PIN_SD2_CD (32*0+28) /* Pin to check card insertion */ +#define IRQ_SD2_CD GPIO_IRQ(PIN_SD2_CD) +#define GPIO_SD2_CD GPIO28 + +static inline void sd_init_gpio(void) +{ + __gpio_as_msc1_pd_4bit(); + __gpio_as_msc2_pb_4bit(); + + __gpio_as_input(PIN_SD1_CD); + __gpio_as_input(PIN_SD2_CD); + + __gpio_disable_pull(PIN_SD1_CD); + __gpio_disable_pull(PIN_SD2_CD); +} + +#endif diff --git a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/backlight-xduoo_x3.c b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/backlight-xduoo_x3.c new file mode 100644 index 0000000000..3f00b0b67d --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/backlight-xduoo_x3.c @@ -0,0 +1,50 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include "backlight-target.h" +#include "lcd.h" + +bool backlight_hw_init(void) +{ + return true; +} + +void backlight_hw_on(void) +{ + lcd_enable(true); +} + +void backlight_hw_off(void) +{ + lcd_enable(false); +} + +void backlight_hw_brightness(int brightness) +{ + lcd_set_contrast(brightness*16-1); +} + +void lcd_sleep(void) +{ + backlight_hw_off(); +} diff --git a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/button-target.h b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/button-target.h new file mode 100644 index 0000000000..2dd94b14bc --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/button-target.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef BUTTON_TARGET_H +#define BUTTON_TARGET_H + +#define HAS_BUTTON_HOLD + +/* Main unit's buttons */ +#define BUTTON_POWER 0x00000001 +#define BUTTON_HOME 0x00000002 +#define BUTTON_OPTION 0x00000004 +#define BUTTON_PREV 0x00000008 +#define BUTTON_NEXT 0x00000010 +#define BUTTON_PLAY 0x00000020 +#define BUTTON_VOL_UP 0x00000040 +#define BUTTON_VOL_DOWN 0x00000080 + +#define BUTTON_LEFT 0 +#define BUTTON_RIGHT 0 + +#define BUTTON_MAIN (BUTTON_POWER | BUTTON_HOME | BUTTON_OPTION | BUTTON_PREV | \ + BUTTON_NEXT | BUTTON_PLAY | BUTTON_VOL_UP | BUTTON_VOL_DOWN) + +/* Software power-off */ +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 10 + +#endif /* BUTTON_TARGET_H */ diff --git a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/lcd-xduoo_x3.c b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/lcd-xduoo_x3.c new file mode 100644 index 0000000000..89251b727d --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/lcd-xduoo_x3.c @@ -0,0 +1,420 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" + +#include "lcd.h" +#include "system.h" +#include "cpu.h" +#include "string.h" + +/* LCD pins */ +#define PIN_BL_EN (32*4+0) + +#define PIN_LCD_D0 (32*2+2) +#define PIN_LCD_D1 (32*2+3) +#define PIN_LCD_D2 (32*2+4) +#define PIN_LCD_D3 (32*2+5) +#define PIN_LCD_D4 (32*2+6) +#define PIN_LCD_D5 (32*2+7) +#define PIN_LCD_D6 (32*2+12) +#define PIN_LCD_D7 (32*2+13) + +#define PIN_LCD_RD (32*2+8) +#define PIN_LCD_DC (32*2+9) +#define PIN_LCD_CS (32*2+14) +#define PIN_LCD_RES (32*2+18) +#define PIN_LCD_WR (32*2+19) + +/* LCD setup codes */ +#define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00) +#define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10) +#define LCD_SET_DISPLAY_START_LINE ((char)0x40) +#define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81) +#define LCD_SET_CHARGE_PUMP ((char)0x8D) +#define LCD_SET_SEGMENT_REMAP ((char)0xA0) +#define LCD_SET_SEGMENT_REMAP_INV ((char)0xA1) +#define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4) +#define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5) +#define LCD_SET_NORMAL_DISPLAY ((char)0xA6) +#define LCD_SET_REVERSE_DISPLAY ((char)0xA7) +#define LCD_SET_MULTIPLEX_RATIO ((char)0xA8) +#define LCD_SET_DC_DC ((char)0xAD) +#define LCD_SET_DISPLAY_OFF ((char)0xAE) +#define LCD_SET_DISPLAY_ON ((char)0xAF) +#define LCD_SET_PAGE_ADDRESS ((char)0xB0) +#define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0) +#define LCD_SET_COM_OUTPUT_SCAN_DIRECTION_INV ((char)0xC8) +#define LCD_SET_DISPLAY_OFFSET ((char)0xD3) +#define LCD_SET_DISPLAY_CLOCK_AND_OSC_FREQ ((char)0xD5) +#define LCD_SET_VCOM_HW_CONFIGURATION ((char)0xDA) +#define LCD_SET_VCOM_DESELECT_LEVEL ((char)0xDB) +#define LCD_SET_PRECHARGE_PERIOD ((char)0xD9) +#define LCD_NOP ((char)0xE3) + +/* LCD command codes */ +#define LCD_CNTL_CONTRAST 0x81 /* Contrast */ +#define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */ +#define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */ +#define LCD_CNTL_DISPON 0xaf /* Display on */ + +#define LCD_CNTL_PAGE 0xb0 /* Page address */ +#define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */ +#define LCD_CNTL_LOWCOL 0x00 /* Lower column address */ + +#define LCD_COL_OFFSET 2 /* column offset */ + +static inline void bitdelay(void) +{ + unsigned int i = 15; + __asm__ __volatile__ ( + ".set noreorder \n" + "1: \n" + "bne %0, $0, 1b \n" + "addi %0, %0, -1 \n" + ".set reorder \n" + : "=r" (i) + : "0" (i) + ); +} + +void lcd_hw_init(void) +{ + REG_GPIO_PXFUNC(2) = 0x000C73FC; /* D0-D7 RD DC CS RES WR */ + REG_GPIO_PXSELC(2) = 0x000C73FC; + REG_GPIO_PXDIRS(2) = 0x000C73FC; + REG_GPIO_PXDATS(2) = 0x000C73FC; + __gpio_clear_pin(PIN_BL_EN); + __gpio_as_output(PIN_BL_EN); + __gpio_clear_pin(PIN_LCD_RES); + udelay(1); + __gpio_set_pin(PIN_LCD_RES); + __gpio_clear_pin(PIN_LCD_CS); +} + +void lcd_write_command(int byte) +{ + __gpio_clear_pin(PIN_LCD_DC); + REG_GPIO_PXDATC(2) = 0x000030FC; + REG_GPIO_PXDATS(2) = ((byte & 0xC0) << 6) | ((byte & 0x3F) << 2); + __gpio_clear_pin(PIN_LCD_WR); + bitdelay(); + __gpio_set_pin(PIN_LCD_WR); + bitdelay(); +} + +void lcd_write_data(const fb_data* p_bytes, int count) +{ + __gpio_set_pin(PIN_LCD_DC); + while (count--) + { + REG_GPIO_PXDATC(2) = 0x000030FC; + REG_GPIO_PXDATS(2) = ((*p_bytes & 0xC0) << 6) | ((*p_bytes & 0x3F) << 2); + p_bytes++; + __gpio_clear_pin(PIN_LCD_WR); + bitdelay(); + __gpio_set_pin(PIN_LCD_WR); + bitdelay(); + } +} + +void lcd_enable_power(bool onoff) +{ + if (onoff) + __gpio_set_pin(PIN_BL_EN); + else + __gpio_clear_pin(PIN_BL_EN); +} + +/** globals **/ + +static bool display_on = false; /* used by lcd_enable */ + +/*** hardware configuration ***/ + +void lcd_set_contrast(int val) +{ + lcd_write_command(LCD_CNTL_CONTRAST); + lcd_write_command(val); +} + +void lcd_set_invert_display(bool yesno) +{ + if (yesno) + lcd_write_command(LCD_SET_REVERSE_DISPLAY); + else + lcd_write_command(LCD_SET_NORMAL_DISPLAY); +} + +/* turn the display upside down (call lcd_update() afterwards) */ +void lcd_set_flip(bool yesno) +{ + if (yesno) + { + lcd_write_command(LCD_SET_SEGMENT_REMAP); + lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION); + } + else + { + lcd_write_command(LCD_SET_SEGMENT_REMAP_INV); + lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION_INV); + } +} + +#ifdef HAVE_LCD_ENABLE +void lcd_enable(bool enable) +{ + if(display_on == enable) + return; + + if( (display_on = enable) ) /* simple '=' is not a typo ! */ + { + lcd_enable_power(enable); + lcd_write_command(LCD_SET_DISPLAY_ON); + send_event(LCD_EVENT_ACTIVATION, NULL); + } + else + { + lcd_write_command(LCD_SET_DISPLAY_OFF); + lcd_enable_power(enable); + } +} + +bool lcd_active(void) +{ + return display_on; +} +#endif + +/* LCD init, largely based on what OF does */ +void lcd_init_device(void) +{ + int i; + + lcd_hw_init(); + + /* Set display off */ + lcd_write_command(LCD_SET_DISPLAY_OFF); + + /* Set display clock and oscillator frequency */ + lcd_write_command(LCD_SET_DISPLAY_CLOCK_AND_OSC_FREQ); + lcd_write_command(0x80); + + /* Set multiplex ratio*/ + lcd_write_command(LCD_SET_MULTIPLEX_RATIO); + lcd_write_command(0x3F); + + /* Set display offset */ + lcd_write_command(LCD_SET_DISPLAY_OFFSET); + lcd_write_command(0x00); + + /* Set starting line as 0 */ + lcd_write_command(LCD_SET_DISPLAY_START_LINE); + + /* Set charge pump */ + lcd_write_command(LCD_SET_CHARGE_PUMP); + lcd_write_command(0x14); /* VCC Generated by Internal DC/DC Circuit */ + + /* Column 131 is remapped to SEG0 */ + lcd_write_command(LCD_SET_SEGMENT_REMAP_INV); + + /* Invert COM scan direction (N-1 to 0) */ + lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION_INV); + + /* Set COM hardware configuration */ + lcd_write_command(LCD_SET_VCOM_HW_CONFIGURATION); + lcd_write_command(0x12); + + /* Set contrast control */ + lcd_write_command(LCD_SET_CONTRAST_CONTROL_REGISTER); + lcd_write_command(0xCF); /* VCC Generated by Internal DC/DC Circuit */ + + /* Set pre-charge period */ + lcd_write_command(LCD_SET_PRECHARGE_PERIOD); + lcd_write_command(0xF1); /* VCC Generated by Internal DC/DC Circuit */ + + /* Set VCOM deselect level */ + lcd_write_command(LCD_SET_VCOM_DESELECT_LEVEL); + lcd_write_command(0x40); + + /* Set normal display mode (not every pixel ON) */ + lcd_write_command(LCD_SET_ENTIRE_DISPLAY_OFF); + + /* Set normal display mode (not inverted) */ + lcd_write_command(LCD_SET_NORMAL_DISPLAY); + + fb_data p_bytes[LCD_WIDTH + 2 * LCD_COL_OFFSET]; + memset(p_bytes, 0, sizeof(p_bytes)); /* fills with 0 : pixel off */ + for(i = 0; i < 8; i++) + { + lcd_write_command (LCD_SET_PAGE_ADDRESS | (i /*& 0xf*/)); + lcd_write_data(p_bytes, LCD_WIDTH + 2 * LCD_COL_OFFSET); + } + + lcd_enable(true); + + lcd_update(); +} + +/*** Update functions ***/ + +/* Performance function that works with an external buffer + note that by and bheight are in 8-pixel units! */ +void lcd_blit_mono(const unsigned char *data, int x, int by, int width, + int bheight, int stride) +{ + if(!display_on) + return; + + /* Copy display bitmap to hardware */ + while (bheight--) + { + lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); + lcd_write_command (LCD_CNTL_HIGHCOL | (((x+LCD_COL_OFFSET)>>4) & 0xf)); + lcd_write_command (LCD_CNTL_LOWCOL | ((x+LCD_COL_OFFSET) & 0xf)); + + lcd_write_data(data, width); + data += stride; + } +} + + +#ifndef BOOTLOADER +/* Helper function for lcd_grey_phase_blit(). */ +void lcd_grey_data(unsigned char *values, unsigned char *phases, int count) ICODE_ATTR; +void lcd_grey_data(unsigned char *values, unsigned char *phases, int count) +{ + unsigned char a, b, c, d; + + __gpio_set_pin(PIN_LCD_DC); + while(count--) + { + c = 0; + d = 8; + while(d--) + { + a = *phases; + b = *values++; + b += a & ~0x80; + *phases++ = b; + c <<= 1; + c |= a >> 7; + } + REG_GPIO_PXDATC(2) = 0x000030FC; + REG_GPIO_PXDATS(2) = ((c & 0xC0) << 6) | ((c & 0x3F) << 2); + __gpio_clear_pin(PIN_LCD_WR); + bitdelay(); + __gpio_set_pin(PIN_LCD_WR); + bitdelay(); + } +} + +/* Performance function that works with an external buffer + note that by and bheight are in 8-pixel units! */ +void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases, + int x, int by, int width, int bheight, int stride) +{ + if(!display_on) + return; + + stride <<= 3; /* 8 pixels per block */ + /* Copy display bitmap to hardware */ + while (bheight--) + { + lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); + lcd_write_command (LCD_CNTL_HIGHCOL | (((x+LCD_COL_OFFSET)>>4) & 0xf)); + lcd_write_command (LCD_CNTL_LOWCOL | ((x+LCD_COL_OFFSET) & 0xf)); + + lcd_grey_data(values, phases, width); + + values += stride; + phases += stride; + } +} +#endif + +/* Update the display. + This must be called after all other LCD functions that change the display. */ +void lcd_update(void) ICODE_ATTR; +void lcd_update(void) +{ + int y; + + if(!display_on) + return; + + /* Copy display bitmap to hardware */ + for (y = 0; y < LCD_FBHEIGHT; y++) + { + lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); + lcd_write_command (LCD_CNTL_HIGHCOL | ((LCD_COL_OFFSET >> 4) & 0xf)); + lcd_write_command (LCD_CNTL_LOWCOL | (LCD_COL_OFFSET & 0xf)); + + lcd_write_data (FBADDR(0, y), LCD_WIDTH); + } +} + +/* Update a fraction of the display. */ +void lcd_update_rect(int, int, int, int) ICODE_ATTR; +void lcd_update_rect(int x, int y, int width, int height) +{ + int ymax; + + if(!display_on) + return; + + /* The Y coordinates have to work on even 8 pixel rows */ + if (x < 0) + { + width += x; + x = 0; + } + + if (x + width > LCD_WIDTH) + width = LCD_WIDTH - x; + + if (width <= 0) + return; /* nothing left to do, 0 is harmful to lcd_write_data() */ + + if (y < 0) + { + height += y; + y = 0; + } + + if (y + height > LCD_HEIGHT) + height = LCD_HEIGHT - y; + + if (height <= 0) + return; /* nothing left to do */ + + ymax = (y + height-1) >> 3; + y >>= 3; + + /* Copy specified rectange bitmap to hardware */ + for (; y <= ymax; y++) + { + lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); + lcd_write_command (LCD_CNTL_HIGHCOL | (((x+LCD_COL_OFFSET) >> 4) & 0xf)); + lcd_write_command (LCD_CNTL_LOWCOL | ((x+LCD_COL_OFFSET) & 0xf)); + + lcd_write_data (FBADDR(x,y), width); + } +} diff --git a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c new file mode 100644 index 0000000000..9ae602ba56 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/power-xduoo_x3.c @@ -0,0 +1,46 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "power.h" +#include "cpu.h" + +#define CHARGE_STAT_GPIO (32*1+6) /* STAT port */ + +/* Detect which power sources are present. */ +unsigned int power_input_status(void) +{ + if(!__gpio_get_pin(CHARGE_STAT_GPIO)) + return POWER_INPUT_USB_CHARGER; + + return POWER_INPUT_NONE; +} + +void power_init(void) +{ + __gpio_as_input(CHARGE_STAT_GPIO); + __gpio_disable_pull(CHARGE_STAT_GPIO); +} + +bool charging_state(void) +{ + return (power_input_status() == POWER_INPUT_USB_CHARGER); +} diff --git a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c new file mode 100644 index 0000000000..d4a3548305 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c @@ -0,0 +1,214 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "system.h" +#include "cpu.h" +#include "button.h" +#include "button-target.h" +#include "powermgmt.h" +#include "kernel.h" +#include "backlight.h" +#include "logf.h" +#include "adc.h" + +#define PIN_BTN_POWER (32*0+30) +#define PIN_BTN_HOLD (32*1+15) + +#define PIN_KEY_INT (32*4+13) +#define KEY_INT_IRQ GPIO141 + +#define PIN_CHARGE_CON (32*1+7) + +#define PIN_PH_DECT (32*1+11) +#define IRQ_PH_DECT GPIO_IRQ(PIN_PH_DECT) +#define GPIO_PH_DECT GPIO43 + +#define PIN_LO_DECT (32*1+12) +#define IRQ_LO_DECT GPIO_IRQ(PIN_LO_DECT) +#define GPIO_LO_DECT GPIO44 + +static volatile unsigned short bat_val,key_val; + +bool headphones_inserted(void) +{ + return (__gpio_get_pin(PIN_PH_DECT) != 0); +} + +void button_init_device(void) +{ + key_val = 0xfff; + + __gpio_as_input(PIN_BTN_POWER); + __gpio_as_input(PIN_BTN_HOLD); + + __gpio_disable_pull(PIN_BTN_POWER); + __gpio_disable_pull(PIN_BTN_HOLD); + + __gpio_as_irq_fall_edge(PIN_KEY_INT); + system_enable_irq(GPIO_IRQ(PIN_KEY_INT)); + + __gpio_set_pin(PIN_CHARGE_CON); /* 0.7 A */ + __gpio_as_output(PIN_CHARGE_CON); + + __gpio_as_input(PIN_LO_DECT); + __gpio_as_input(PIN_PH_DECT); + + __gpio_disable_pull(PIN_LO_DECT); + __gpio_disable_pull(PIN_PH_DECT); +} + +bool button_hold(void) +{ + return (__gpio_get_pin(PIN_BTN_HOLD) ? true : false); +} + +int button_read_device(void) +{ + static bool hold_button = false; + bool hold_button_old; + + hold_button_old = hold_button; + hold_button = (__gpio_get_pin(PIN_BTN_HOLD) ? true : false); + + int btn = BUTTON_NONE; + bool gpio_btn = (__gpio_get_pin(PIN_BTN_POWER) ? false : true); + + REG_SADC_ADCFG = ADCFG_VBAT_SEL + ADCFG_CMD_AUX(1); + REG_SADC_ADENA = ADENA_VBATEN + ADENA_AUXEN; + +#ifndef BOOTLOADER + if (hold_button != hold_button_old) { + backlight_hold_changed(hold_button); + } + if (hold_button) { + return BUTTON_NONE; + } +#endif + + if (gpio_btn) + btn |= BUTTON_POWER; + + if (key_val < 261) + btn |= BUTTON_VOL_UP; + else + if (key_val < 653) + btn |= BUTTON_VOL_DOWN; + else + if (key_val < 1101) + btn |= BUTTON_PREV; + else + if (key_val < 1498) + btn |= BUTTON_NEXT; + else + if (key_val < 1839) + btn |= BUTTON_PLAY; + else + if (key_val < 2213) + btn |= BUTTON_OPTION; + else + if (key_val < 2600) + btn |= BUTTON_HOME; + + return btn; +} + +/* called on button press interrupt */ +void KEY_INT_IRQ(void) +{ +} + +const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = +{ + /* 5% */ + 3634 +}; + +const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = +{ + /* 0% */ + 3300 +}; + + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ +const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = +{ + { 3300, 3652, 3704, 3730, 3753, 3786, 3836, 3906, 3973, 4061, 4160 } +}; + +#if CONFIG_CHARGING +/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ +const unsigned short percent_to_volt_charge[11] = + { 3300, 3652, 3704, 3730, 3753, 3786, 3836, 3906, 3973, 4061, 4160 }; +#endif /* CONFIG_CHARGING */ + +/* VBAT = (BDATA/1024) * 2.5V */ +#define BATTERY_SCALE_FACTOR 2460 + +/* Returns battery voltage from ADC [millivolts] */ +int _battery_voltage(void) +{ + return (bat_val*BATTERY_SCALE_FACTOR)>>10; +} + +void adc_init(void) +{ + bat_val = 0xfff; + + __cpm_start_sadc(); + mdelay(10); + REG_SADC_ADENA = 0; /* Power Up */ + mdelay(70); + REG_SADC_ADSTATE = 0; + REG_SADC_ADCTRL = ADCTRL_MASK_ALL - ADCTRL_ARDYM - ADCTRL_VRDYM; + REG_SADC_ADCFG = ADCFG_VBAT_SEL + ADCFG_CMD_AUX(1); + REG_SADC_ADCLK = (4 << 16) | (1 << 8) | 59; /* 200KHz */ + system_enable_irq(IRQ_SADC); +} + +void adc_close(void) +{ + REG_SADC_ADENA = ADENA_POWER; /* Power Down */ + __intc_mask_irq(IRQ_SADC); + mdelay(20); + __cpm_stop_sadc(); +} + +/* Interrupt handler */ +void SADC(void) +{ + unsigned char state; + unsigned char sadcstate; + + sadcstate = REG_SADC_ADSTATE; + state = REG_SADC_ADSTATE & (~REG_SADC_ADCTRL); + REG_SADC_ADSTATE &= sadcstate; + + if(state & ADCTRL_ARDYM) + { + key_val = REG_SADC_ADADAT; + } + if(state & ADCTRL_VRDYM) + { + bat_val = REG_SADC_ADVDAT; + } +} diff --git a/firmware/target/mips/mmu-mips.c b/firmware/target/mips/mmu-mips.c index 9dcec43321..b519bf9331 100644 --- a/firmware/target/mips/mmu-mips.c +++ b/firmware/target/mips/mmu-mips.c @@ -127,86 +127,76 @@ void mmu_init(void) #define SYNC_WB() __asm__ __volatile__ ("sync") -#define __CACHE_OP(op, addr) \ - __asm__ __volatile__( \ - " .set noreorder \n" \ - " .set mips32\n\t \n" \ - " cache %0, %1 \n" \ - " .set mips0 \n" \ - " .set reorder \n" \ - : \ - : "i" (op), "m" (*(unsigned char *)(addr))) - -void __flush_dcache_line(unsigned long addr) -{ - __CACHE_OP(DCHitWBInv, addr); - SYNC_WB(); -} +#define cache_op(base,op) \ + __asm__ __volatile__(" \ + .set noreorder; \ + .set mips3; \ + cache %1, (%0); \ + .set mips0; \ + .set reorder" \ + : \ + : "r" (base), \ + "i" (op)); void __icache_invalidate_all(void) { - unsigned int i; + unsigned long start; + unsigned long end; - asm volatile (".set noreorder \n" - ".set mips32 \n" - "mtc0 $0, $28 \n" /* TagLo */ - "mtc0 $0, $29 \n" /* TagHi */ - ".set mips0 \n" - ".set reorder \n" - ); - for(i=A_K0BASE; i= CACHE_SIZE) + if (size >= CACHE_SIZE*2) { __dcache_writeback_all(); - else - { + } + else { unsigned long dc_lsize = CACHE_LINE_SIZE; - + a = addr & ~(dc_lsize - 1); end = (addr + size - 1) & ~(dc_lsize - 1); - for(; a < end; a += dc_lsize) - __flush_dcache_line(a); + while (1) { + cache_op(a,DCHitWBInv); + if (a == end) + break; + a += dc_lsize; + } } + SYNC_WB(); } diff --git a/firmware/target/mips/mmu-mips.h b/firmware/target/mips/mmu-mips.h index 47aea807cc..7e1e36d3f4 100644 --- a/firmware/target/mips/mmu-mips.h +++ b/firmware/target/mips/mmu-mips.h @@ -31,14 +31,16 @@ void mmu_init(void); #define HAVE_CPUCACHE_INVALIDATE //#define HAVE_CPUCACHE_FLUSH -void __dcache_writeback_all(void); -void __dcache_invalidate_all(void); +void __idcache_invalidate_all(void); void __icache_invalidate_all(void); -void __flush_dcache_line(unsigned long addr); +void __dcache_invalidate_all(void); +void __dcache_writeback_all(void); + void dma_cache_wback_inv(unsigned long addr, unsigned long size); -#define commit_discard_idcache __icache_invalidate_all -#define commit_discard_dcache __dcache_invalidate_all -#define commit_dcache __dcache_writeback_all +#define commit_discard_idcache __idcache_invalidate_all +#define commit_discard_icache __icache_invalidate_all +#define commit_discard_dcache __dcache_invalidate_all +#define commit_dcache __dcache_writeback_all #endif /* __MMU_MIPS_INCLUDE_H */ diff --git a/firmware/usb.c b/firmware/usb.c index 562734c84a..375bb6d768 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -49,7 +49,8 @@ (defined(HAVE_USBSTACK) && (defined(CREATIVE_ZVx))) || \ (defined(HAVE_USBSTACK) && (defined(OLYMPUS_MROBE_500))) || \ defined(CPU_TCC77X) || defined(CPU_TCC780X) || \ - (CONFIG_USBOTG == USBOTG_JZ4740) + (CONFIG_USBOTG == USBOTG_JZ4740) || \ + (CONFIG_USBOTG == USBOTG_JZ4760) /* TODO: condition should be reset to be only the original (defined(HAVE_USBSTACK) && defined(HAVE_BOOTLOADER_USB_MODE)) */ #define USB_FULL_INIT diff --git a/tools/builds.pm b/tools/builds.pm index 1dfe937426..e002bfca7b 100644 --- a/tools/builds.pm +++ b/tools/builds.pm @@ -418,6 +418,10 @@ $releasenotes="/wiki/ReleaseNotes314"; name => 'Agptek Rocker', status => 2 } + 'xduoox3' => { + name => 'xDuoo X3', + status => 2, + }, ); sub manualname { diff --git a/tools/configure b/tools/configure index 76a62a6364..330c6640fe 100755 --- a/tools/configure +++ b/tools/configure @@ -1535,6 +1535,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/buttonmap/SOURCES @@ -85,5 +85,7 @@ creative-zen.c sony-nwza860.c #elif CONFIG_KEYPAD == AGPTEK_ROCKER_PAD agptek-rocker.c +#elif CONFIG_KEYPAD == XDUOO_X3_PAD +xduoo-x3.c #endif #endif /* SIMULATOR */ diff --git a/uisimulator/buttonmap/xduoo-x3.c b/uisimulator/buttonmap/xduoo-x3.c new file mode 100644 index 0000000000..e0b5a476c3 --- /dev/null +++ b/uisimulator/buttonmap/xduoo-x3.c @@ -0,0 +1,82 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2016 by Roman Stolyarov + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + + +#include +#include "button.h" +#include "buttonmap.h" + +int key_to_button(int keyboard_button) +{ + int new_btn = BUTTON_NONE; + switch (keyboard_button) + { + case SDLK_KP4: + case SDLK_UP: + new_btn = BUTTON_PREV; + break; + case SDLK_KP1: + case SDLK_DOWN: + new_btn = BUTTON_NEXT; + break; + case SDLK_KP3: + case SDLK_KP_ENTER: + case SDLK_SPACE: + case SDLK_RETURN: + new_btn = BUTTON_PLAY; + break; + case SDLK_KP5: + case SDLK_END: + case SDLK_BACKSPACE: + new_btn = BUTTON_OPTION; + break; + case SDLK_KP7: + case SDLK_ESCAPE: + new_btn = BUTTON_POWER; + break; + case SDLK_KP9: + case SDLK_HOME: + new_btn = BUTTON_HOME; + break; + case SDLK_KP_MINUS: + case SDLK_PAGEUP: + new_btn = BUTTON_VOL_UP; + break; + case SDLK_KP_PLUS: + case SDLK_PAGEDOWN: + new_btn = BUTTON_VOL_DOWN; + break; + } + return new_btn; +} + +struct button_map bm[] = { + { SDLK_KP4, 68, 342, 17, "Prev" }, + { SDLK_KP1, 72, 404, 17, "Next" }, + { SDLK_KP3, 142, 374, 28, "Play" }, + { SDLK_KP5, 106, 288, 17, "Option" }, + { SDLK_KP7, 38, 244, 17, "Power" }, + { SDLK_KP9, 155, 244, 17, "Home" }, + { SDLK_KP_MINUS, 192, 74, 17, "Vol Up" }, + { SDLK_KP_PLUS, 192, 132, 17, "Vol Dn" }, + { SDLK_h, 0, 66, 17, "Hold" }, + { 0, 0, 0, 0, "None" } +};