/* * linux/arch/mips/jz4750/board-apus.c * * JZ4750 APUS board setup routines. * * Copyright (c) 2006-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. */ #include #include #include #include #include #include #include #include #include #include #include //#define DEBUG /********************************************************************************* * Power management routines ********************************************************************************/ /* * __gpio_as_sleep set all pins to pull-disable, and set all pins as input * except sdram and the pins which can be used as CS1_N to CS4_N for chip select. */ #define __gpio_as_sleep() \ do { \ REG_GPIO_PXFUNC(1) = ~0x03ff7fff; \ REG_GPIO_PXSELC(1) = ~0x03ff7fff; \ REG_GPIO_PXDIRC(1) = ~0x03ff7fff; \ REG_GPIO_PXPES(1) = ~0x03ff7fff; \ REG_GPIO_PXFUNC(2) = ~0x01e00000; \ REG_GPIO_PXSELC(2) = ~0x01e00000; \ REG_GPIO_PXDIRC(2) = ~0x01e00000; \ REG_GPIO_PXPES(2) = ~0x01e00000; \ REG_GPIO_PXFUNC(3) = 0xffffffff; \ REG_GPIO_PXSELC(3) = 0xffffffff; \ REG_GPIO_PXDIRC(3) = 0xffffffff; \ REG_GPIO_PXPES(3) = 0xffffffff; \ REG_GPIO_PXFUNC(4) = 0xffffffff; \ REG_GPIO_PXSELC(4) = 0xffffffff; \ REG_GPIO_PXDIRC(4) = 0xffffffff; \ REG_GPIO_PXPES(4) = 0xffffffff; \ REG_GPIO_PXFUNC(5) = 0xffffffff; \ REG_GPIO_PXSELC(5) = 0xffffffff; \ REG_GPIO_PXDIRC(5) = 0xffffffff; \ REG_GPIO_PXPES(5) = 0xffffffff; \ } while (0) extern void (*jz_timer_callback)(void); struct wakeup_key_s { int gpio; /* gpio pin number */ int active_low; /* the key interrupt pin is low voltage or fall edge acitve */ }; /* add wakeup keys here */ static struct wakeup_key_s wakeup_key[] = { { .gpio = GPIO_CALL, .active_low = ACTIVE_LOW_CALL, }, { .gpio = GPIO_HOME, .active_low = ACTIVE_LOW_HOME, }, { .gpio = GPIO_BACK, .active_low = ACTIVE_LOW_BACK, }, { .gpio = GPIO_MENU, .active_low = ACTIVE_LOW_MENU, }, { .gpio = GPIO_ENDCALL, .active_low = ACTIVE_LOW_ENDCALL, }, { .gpio = GPIO_ADKEY_INT, .active_low = ACTIVE_LOW_ADKEY, }, }; static void wakeup_key_setup(void) { int i; int num = sizeof(wakeup_key) / sizeof(wakeup_key[0]); for(i = 0; i < num; i++) { #if 0 if(wakeup_key[i].active_low) __gpio_as_irq_fall_edge(wakeup_key[i].gpio); else __gpio_as_irq_rise_edge(wakeup_key[i].gpio); #endif __gpio_ack_irq(wakeup_key[i].gpio); __gpio_unmask_irq(wakeup_key[i].gpio); __intc_unmask_irq(IRQ_GPIO0 - (wakeup_key[i].gpio/32)); /* unmask IRQ_GPIOn */ } } /* NOTES: * 1: Pins that are floated (NC) should be set as input and pull-enable. * 2: Pins that are pull-up or pull-down by outside should be set as input * and pull-disable. * 3: Pins that are connected to a chip except sdram and nand flash * should be set as input and pull-disable, too. */ void jz_board_do_sleep(unsigned long *ptr) { unsigned char i; #ifdef DEBUG __intc_unmask_irq(IRQ_UART3); /* Print messages of GPIO registers for debug */ for(i=0;i