static void cetus_sd_plug_change(int state) { if(state == CARD_INSERTED) __gpio_as_irq_rise_edge(MSC0_HOTPLUG_PIN); else __gpio_as_irq_fall_edge(MSC0_HOTPLUG_PIN); }
static int udc_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { int len = 0; if (__gpio_get_pin(GPIO_UDC_HOTPLUG)) { #ifdef CONFIG_JZ_UDC_HOTPLUG /* Cable has connected, wait for disconnection. */ __gpio_as_irq_fall_edge(GPIO_UDC_HOTPLUG); if (jz_udc_active) len += sprintf (page+len, "CONNECT_CABLE\n"); else len += sprintf (page+len, "CONNECT_POWER\n"); #else len += sprintf (page+len, "CONNECT\n"); #endif } else { #ifdef CONFIG_JZ_UDC_HOTPLUG /* Cable has disconnected, wait for connection. */ __gpio_as_irq_rise_edge(GPIO_UDC_HOTPLUG); #endif len += sprintf (page+len, "REMOVE\n"); } return len; }
static void MMCGpioTask(void *arg) { u8 err; cardstate = CARD_OUT; cardexsit = 1 ; while(1) { // __intc_mask_irq(48 + MMC_CD_PIN); printf("Looks like MMC gpio change! \n"); if ( cardstate == CARD_OUT ) //card have inserted! { OSTimeDlyHMSM(0,0,0,500); if ( __gpio_get_pin(MMC_CD_PIN) == 0 ) //card readlly insert! { printf("Card readlly insert! \n"); cardstate = CARD_IN; info_card_in(); MMC_Initialize(); __gpio_as_irq_rise_edge(MMC_CD_PIN); } else __gpio_as_irq_fall_edge(MMC_CD_PIN); } else //card have not inserted! { OSTimeDlyHMSM(0,0,0,500); if ( __gpio_get_pin(MMC_CD_PIN) == 1 ) //card readlly out! { printf("Card readlly out! \n"); cardstate = CARD_OUT; info_card_out(); __gpio_as_irq_fall_edge(MMC_CD_PIN); } else __gpio_as_irq_rise_edge(MMC_CD_PIN); } __gpio_ack_irq(MMC_CD_PIN); __intc_ack_irq(48 + MMC_CD_PIN); __gpio_unmask_irq(MMC_CD_PIN); OSSemPend(MMCGPIOEvent, 0, &err); } }
static void enable_gpio_irqs(struct gpio_keys_platform_data *pdata) { int i; for (i = 0; i < pdata->nbuttons; i++) { struct gpio_keys_button *button = &pdata->buttons[i]; if (button->active_low) __gpio_as_irq_fall_edge(button->gpio); else __gpio_as_irq_rise_edge(button->gpio); } }
static void uh_init_gpio(struct uh_data *uh) { /* get current pin level */ __gpio_disable_pull(uh->gpio_pin); __gpio_as_input(uh->gpio_pin); udelay(1); /* Because of every plug IN/OUT action will casue more than one interrupt, So whether rising trigger or falling trigger method can both start the detection. */ __gpio_as_irq_rise_edge(uh->gpio_pin); return; }
static void udc_timer_routine(unsigned long data) { udc_old_state = jz_udc_active; /* jz_udc_active was updated in the udc driver */ udc_pin_level = __gpio_get_pin(UDC_HOTPLUG_PIN); /* Setup irq for next event */ if (udc_pin_level) { /* Cable has connected, wait for disconnection. */ __gpio_as_irq_fall_edge(UDC_HOTPLUG_PIN); } else { /* update udc state */ jz_udc_active = 0; /* Have no actions */ /* Cable has disconnected, wait for connection. */ __gpio_as_irq_rise_edge(UDC_HOTPLUG_PIN); } wake_up_process(kudcd_task); }
int oem_gpio_set_irq_type(int gpio, unsigned int type) { if(type == IRQ_TYPE_EDGE_BOTH){ if(read_gpio_pin(gpio)){ type = IRQ_TYPE_EDGE_FALLING; }else{ type = IRQ_TYPE_EDGE_RISING; } } if(type == IRQ_TYPE_LEVEL_MASK){ if(read_gpio_pin(gpio)){ type = IRQ_TYPE_LEVEL_LOW; }else{ type = IRQ_TYPE_LEVEL_HIGH; } } switch(type){ case IRQ_TYPE_EDGE_RISING: __gpio_as_irq_rise_edge(gpio); break; case IRQ_TYPE_EDGE_FALLING: __gpio_as_irq_fall_edge(gpio); break; case IRQ_TYPE_LEVEL_HIGH: __gpio_as_irq_high_level(gpio); break; case IRQ_TYPE_LEVEL_LOW: __gpio_as_irq_low_level(gpio); break; default: return -EINVAL; } return 0; }
/* * Module init and exit */ static int __init udc_hotplug_init(void) { int retval; kudcd_task = kthread_run(udc_thread, NULL, "kudcd"); if (IS_ERR(kudcd_task)) { printk(KERN_ERR "jz_udc_hotplug: Failed to create system monitor thread.\n"); return PTR_ERR(kudcd_task); } retval = request_irq(UDC_HOTPLUG_IRQ, udc_hotplug_irq, IRQF_DISABLED, "udc_hotplug", NULL); if (retval) { printk("Could not get udc hotplug irq %d\n", UDC_HOTPLUG_IRQ); return retval; } /* get current pin level */ __gpio_disable_pull(UDC_HOTPLUG_PIN); __gpio_as_input(UDC_HOTPLUG_PIN); udelay(1); udc_pin_level = __gpio_get_pin(UDC_HOTPLUG_PIN); if (udc_pin_level) { /* Cable has connected, wait for disconnection. */ __gpio_as_irq_fall_edge(UDC_HOTPLUG_PIN); } else { /* Cable has disconnected, wait for connection. */ __gpio_as_irq_rise_edge(UDC_HOTPLUG_PIN); } printk("JZ UDC hotplug driver registered\n"); return 0; }
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"); }
void TPanelInit() { int i; unsigned char data1; int retval; /* Disable INT that connected to ATA2508's TINT.*/ __gpio_as_i2c(); __gpio_as_output(TP_KEY_RST); __gpio_set_pin(TP_KEY_RST); mdelay(100); __gpio_clear_pin(TP_KEY_RST); mdelay(800); __gpio_set_pin(TP_KEY_RST); __gpio_mask_irq(TP_KEY_TINT); /* usage : I2C_WRITE( register_address, data);*/ for(i=0; i<13; i++) { data1 = init_data_alpha[i]; write_reg(i, data1); } for(i=13; i<63; i++) { data1 = init_data_burst[i-13]; write_reg(i, data1); } #if 0 for (i = 0; i < 63; i++) { data1 = read_reg(i); printf("REG0x%02x = 0x%02x\n", i, data1); } #endif /*wait for 1 ms*/ mdelay(1); #if 0 while(1) { data1 = read_reg(0x68); printf("REG0x68 = %d\n", data1); data1 = read_reg(0x75); printf("REG0x75 = 0x%02x\n", data1); data1 = read_reg(0x76); printf("REG0x76 = 0x%02x\n", data1); mdelay(2000); } #endif /*to activate all the new settings, give a WARM RESET.*/ write_reg(ADDR_WARM_RESET, 0x00); //ADDR_WARM_RESET=0xFF // printf("the return value of write reg 0xff is %d\n", ret); #if 0 data1 = read_reg(0x68); printf("REG0x68 = %d\n", data1); #endif /*wait for 1 ~ 10 ms.*/ mdelay(10); /*Enable INT that connected to ATA2508's TINT.*/ __gpio_as_irq_rise_edge(TP_KEY_TINT); request_irq(TP_TINT_IRQ, tp_tint_irq, 0); printf("Lyra touch panel register!\n"); // return; // return 0; }
static int jz_pm_do_sleep(void) { unsigned long delta; unsigned long nfcsr = REG_EMC_NFCSR; unsigned long opcr = REG_CPM_OPCR; unsigned long imr = REG_INTC_IMR; unsigned long sadc = REG_SADC_ENA; unsigned long sleep_gpio_save[7*(GPIO_PORT_NUM-1)]; printk("Put CPU into sleep mode.\n"); /* Preserve current time */ delta = xtime.tv_sec - REG_RTC_RSR; /* Disable nand flash */ REG_EMC_NFCSR = ~0xff; /* stop sadc */ REG_SADC_ENA &= ~0x7; while((REG_SADC_ENA & 0x7) != 0); udelay(100); /*stop udc and usb*/ __cpm_suspend_uhcphy(); __cpm_suspend_udcphy(); /* Sleep on-board modules */ jz_board_do_sleep(sleep_gpio_save); /* Mask all interrupts */ REG_INTC_IMSR = 0xffffffff; /* Just allow following interrupts to wakeup the system. * Note: modify this according to your system. */ /* enable RTC alarm */ __intc_unmask_irq(IRQ_RTC); #if 0 /* make system wake up after n seconds by RTC alarm */ unsigned int v, n; n = 10; while (!__rtc_write_ready()); __rtc_enable_alarm(); while (!__rtc_write_ready()); __rtc_enable_alarm_irq(); while (!__rtc_write_ready()); v = __rtc_get_second(); while (!__rtc_write_ready()); __rtc_set_alarm_second(v+n); #endif /* WAKEUP key */ __gpio_as_irq_rise_edge(GPIO_WAKEUP); __gpio_unmask_irq(GPIO_WAKEUP); __intc_unmask_irq(IRQ_GPIO0 - (GPIO_WAKEUP/32)); /* unmask IRQ_GPIOn depends on GPIO_WAKEUP */ /* disable externel clock Oscillator in sleep mode */ __cpm_disable_osc_in_sleep(); /* select 32K crystal as RTC clock in sleep mode */ __cpm_select_rtcclk_rtc(); /* Enter SLEEP mode */ REG_CPM_LCR &= ~CPM_LCR_LPM_MASK; REG_CPM_LCR |= CPM_LCR_LPM_SLEEP; __asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0"); /* Restore to IDLE mode */ REG_CPM_LCR &= ~CPM_LCR_LPM_MASK; REG_CPM_LCR |= CPM_LCR_LPM_IDLE; /* Restore nand flash control register */ REG_EMC_NFCSR = nfcsr; /* Restore interrupts */ REG_INTC_IMSR = imr; REG_INTC_IMCR = ~imr; /* Restore sadc */ REG_SADC_ENA = sadc; /* Resume on-board modules */ jz_board_do_resume(sleep_gpio_save); /* Restore Oscillator and Power Control Register */ REG_CPM_OPCR = opcr; /* Restore current time */ xtime.tv_sec = REG_RTC_RSR + delta; return 0; }