Ejemplo n.º 1
0
static void jz_board_do_resume(unsigned long *ptr)
{
	unsigned char i;

	/* Restore GPIO registers */
	for(i = 1; i < GPIO_PORT_NUM; i++) {
		 REG_GPIO_PXFUNS(i) = *ptr;
		 REG_GPIO_PXFUNC(i) = ~(*ptr++);

		 REG_GPIO_PXSELS(i) = *ptr;
		 REG_GPIO_PXSELC(i) = ~(*ptr++);

		 REG_GPIO_PXDIRS(i) = *ptr;
		 REG_GPIO_PXDIRC(i) = ~(*ptr++);

		 REG_GPIO_PXPES(i) = *ptr;
		 REG_GPIO_PXPEC(i) = ~(*ptr++);

		 REG_GPIO_PXIMS(i)=*ptr;
		 REG_GPIO_PXIMC(i)=~(*ptr++);
	
		 REG_GPIO_PXDATS(i)=*ptr;
		 REG_GPIO_PXDATC(i)=~(*ptr++);
	
		 REG_GPIO_PXTRGS(i)=*ptr;
		 REG_GPIO_PXTRGC(i)=~(*ptr++);
	}

        /* Print messages of GPIO registers for debug */
	for(i=0;i<GPIO_PORT_NUM;i++) {
		dprintk("resume dat:%x pin:%x fun:%x sel:%x dir:%x pull:%x msk:%x trg:%x\n",     \
			REG_GPIO_PXDAT(i),REG_GPIO_PXPIN(i),REG_GPIO_PXFUN(i),REG_GPIO_PXSEL(i), \
			REG_GPIO_PXDIR(i),REG_GPIO_PXPE(i),REG_GPIO_PXIM(i),REG_GPIO_PXTRG(i));
	}
}
void board_do_sleep(void)
{
	int no_change;
	int data = ~0;
	/* set SLEEP mode */
	CMSREG32(CPM_LCR, 0x1, 0x3);

	board_powerdown_device();
	board_save_gpio(gpio_save);

	/* GPIO - A */
	no_change = 1 << 16 | 1 << 17 | 1 << 26 | 1 << 27;
	REG_GPIO_PXFUNC(0) =  data & ~no_change;
	REG_GPIO_PXSELC(0) =  data & ~no_change;
	REG_GPIO_PXDIRC(0) =  data & ~no_change;
	REG_GPIO_PXPES(0) = data & ~no_change; /* disable pull */

	/* GPIO - B */
	no_change = 1 << 5 | 1 << 20 | 1 << 23 | 1 << 25 | 1 << 30;
	REG_GPIO_PXFUNC(1) =  data & ~no_change;
	REG_GPIO_PXSELC(1) =  data & ~no_change;
	REG_GPIO_PXDIRC(1) =  data & ~no_change;
	REG_GPIO_PXPES(1) = data & ~no_change; /* disable pull */

	/* GPIO - C */
	no_change = 0x0;
	REG_GPIO_PXFUNC(2) =  data & ~no_change;
	REG_GPIO_PXSELC(2) =  data & ~no_change;
	REG_GPIO_PXDIRC(2) =  data & ~no_change;
	REG_GPIO_PXPES(2) = data & ~no_change; /* disable pull */

	/* GPIO - D */
	no_change = 1 << 17 | 1 << 18 | 1 << 19 | 1 << 27;
	REG_GPIO_PXFUNC(3) =  data & ~no_change;
	REG_GPIO_PXSELC(3) =  data & ~no_change;
	REG_GPIO_PXDIRC(3) =  data & ~no_change;
	REG_GPIO_PXPES(3) = data & ~no_change; /* disable pull */

	/* GPIO - E */
	no_change = 1 << 0 | 1 << 4 | 1 << 10 | 1 << 11 | 1 << 26 | 1 << 8 | 1 << 3;
	REG_GPIO_PXFUNC(4) =  data & ~no_change;
	REG_GPIO_PXSELC(4) =  data & ~no_change;
	REG_GPIO_PXDIRC(4) =  data & ~no_change;
	REG_GPIO_PXPES(4) = data & ~no_change; /* disable pull */
	__gpio_clear_pin(32 * 4 + 0);/* close lcd and bl*/
	__gpio_set_pin(32 * 4 + 3);
	__gpio_as_output(32 * 4 + 0);
	__gpio_as_output(32 * 4 + 3);

	/* GPIO - F */
	no_change = 1 << 10 | 1 << 11 | 1 << 5 | 1 << 7;
	REG_GPIO_PXFUNC(5) =  data & ~no_change;
	REG_GPIO_PXSELC(5) =  data & ~no_change;
	REG_GPIO_PXDIRC(5) =  data & ~no_change;
	REG_GPIO_PXPES(5) = data & ~no_change; /* disable pull */

	__gpio_as_irq_fall_edge(PWR_WAKE);
	__gpio_unmask_irq(PWR_WAKE);
	__intc_unmask_irq(17);  /* unmask IRQ_GPIOn depends on GPIO_WAKEUP */

	__gpio_as_irq_rise_edge(32*1+5);
	__gpio_unmask_irq(32*1+5);
	__intc_unmask_irq(16);  /* unmask IRQ_GPIOn depends on GPIO_WAKEUP */
#if 0 /*here we do not need other pin to wake up.*/	
	__gpio_as_irq_fall_edge(VOL_ADD);
	__gpio_as_irq_rise_edge(VOL_SUB);
	__gpio_unmask_irq(VOL_ADD);
	__gpio_unmask_irq(VOL_SUB);
	__intc_unmask_irq(14);  /* unmask IRQ_GPIOn depends on VOL_ADD */
	__intc_unmask_irq(12);  /* unmask IRQ_GPIOn depends on VOL_SUB */
#endif	

	/* disable externel clock Oscillator in sleep mode */
	CLRREG32(CPM_OPCR, 1 << 4);

	/* select 32K crystal as RTC clock in sleep mode */
	SETREG32(CPM_OPCR, 1 << 2);

	/* Clear previous reset status */
	CLRREG32(CPM_RSR, 0x7);

	mdelay(50);

	__asm__(".set\tmips3\n\t"
			"sync\n\t"
			"wait\n\t"
			"nop\n\t"
			"nop\n\t"
			"nop\n\t"
			"nop\n\t"
			".set\tmips0");
}
Ejemplo n.º 3
0
static void gpio_init(void)
{
	REG_GPIO_PXPES(0) = 0xffffffff;
	REG_GPIO_PXPES(1) = 0xffffffff;
	REG_GPIO_PXPES(2) = 0xffffffff;
	REG_GPIO_PXPES(3) = 0xffffffff;

	/*
	 * Initialize NAND Flash Pins
	 */
	__gpio_as_nand();

	/*
	 * Initialize SDRAM pins
	 */
	__gpio_as_sdram_32bit();

	/*
	 * Initialize UART0 pins
	 */
	__gpio_as_uart0();

	/*
	 * Initialize MSC pins
	 */
	__gpio_as_msc();

	/*
	 * Initialize LCD pins
	 */
	__gpio_as_lcd_16bit();

	/*
	 * Initialize I2C pins
	 */
	__gpio_as_i2c();

	/*
	 * Initialize Other pins
	 */
	__gpio_as_output(GPIO_SD_VCC_EN_N);
	__gpio_clear_pin(GPIO_SD_VCC_EN_N);

	__gpio_as_input(GPIO_SD_CD_N);
	__gpio_disable_pull(GPIO_SD_CD_N);

	__gpio_as_input(GPIO_CHARG_STAT_N);
	__gpio_as_input(GPIO_USB_DETE);

	__gpio_as_output(GPIO_LED_EN);
	__gpio_set_pin(GPIO_LED_EN);

	__gpio_as_input(GPIO_HP_DETECT);
	__gpio_disable_pull(GPIO_HP_DETECT);

	__gpio_as_output(GPIO_DISP_OFF_N);

	__gpio_as_output(GPIO_LED_EN);
	__gpio_set_pin(GPIO_LED_EN);
	__gpio_as_input(127);

	/* Make sure the external cs8900a won't touch the bus */
	__gpio_enable_pull(GPIO_ETH_CS);
}
void board_restore_gpio(unsigned int *ptr){
	int i = 0;
	for(i = 0; i < GPIO_PORT_NUM; i++) {
		REG_GPIO_PXFUNS(i) = *ptr;
		REG_GPIO_PXFUNC(i) = ~(*ptr++);

		REG_GPIO_PXSELS(i) = *ptr;
		REG_GPIO_PXSELC(i) = ~(*ptr++);

		REG_GPIO_PXDIRS(i) = *ptr;
		REG_GPIO_PXDIRC(i) = ~(*ptr++);

		REG_GPIO_PXPES(i) = *ptr;
		REG_GPIO_PXPEC(i) = ~(*ptr++);

		REG_GPIO_PXIMS(i)=*ptr;
		REG_GPIO_PXIMC(i)=~(*ptr++);

		REG_GPIO_PXDATS(i)=*ptr;
		REG_GPIO_PXDATC(i)=~(*ptr++);

		REG_GPIO_PXTRGS(i)=*ptr;
		REG_GPIO_PXTRGC(i)=~(*ptr++);
	}
	return;

}