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 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 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 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"); }