Exemplo n.º 1
0
/* Detect which power sources are present. */
unsigned int power_input_status(void)
{
    unsigned int status = POWER_INPUT_NONE;

    if (__gpio_get_pin(USB_CHARGER_GPIO))
        status |= POWER_INPUT_USB_CHARGER;

    if(!__gpio_get_pin(CHARGE_STAT_GPIO))
        status |= POWER_INPUT_USB;

    return status;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
static unsigned int cetus_sd_get_wp(struct device *dev)
{
	unsigned int status;

	status = (unsigned int) __gpio_get_pin(GPIO_SD0_WP);
	return (status);
}
Exemplo n.º 4
0
static unsigned int cetus_sd_status(struct device *dev)
{
	unsigned int status;

	status = (unsigned int) __gpio_get_pin(GPIO_SD0_CD_N);
	return (!status);
}
Exemplo n.º 5
0
static int mmc_read_proc (char *page, char **start, off_t off,
                          int count, int *eof, void *data)
{
        int len = 0;

#if defined(CONFIG_JZ4750_LYRA)
        if (!(__gpio_get_pin(MSC_HOTPLUG_PIN)))
#else
        if (__gpio_get_pin(MSC_HOTPLUG_PIN))
#endif
                len += sprintf (page+len, "REMOVE\n");
        else
                len += sprintf (page+len, "INSERT\n");

        return len;
}
Exemplo n.º 6
0
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);
	}
}
Exemplo n.º 7
0
////////////////////////////////////////////////////
// 功能: 
// 输入: 
// 输出:
// 返回: 
// 说明: 
////////////////////////////////////////////////////
int DacIsHeadphoneIn(void)
{
#if defined(CONFIG_ERAPHONE_IO)
	if(__gpio_get_pin(CONFIG_ERAPHONE_IO) == CONFIG_ERAPHONE_INERT)
		return 1;
	return 0;
#else
	return 0;
#endif	
}
Exemplo n.º 8
0
static int mmc_read_proc (char *page, char **start, off_t off,
                          int count, int *eof, void *data)
{
        int len = 0;

        if (__gpio_get_pin(MSC_HOTPLUG_PIN))
                len += sprintf (page+len, "REMOVE\n");
        else
                len += sprintf (page+len, "INSERT\n");

        return len;
}
Exemplo n.º 9
0
/* Do cable detection */
static void cable_detect(struct uh_data *uh)
{	
	if (__gpio_get_pin(uh->gpio_pin)) {
		D("Cable online.\n");
		
		uh->cable_detect_state = UH_CABLE_STATE_POWER;
		
	}else {
		D("Cable offline.\n");

		clear_bit(BIT_KEEP_ALIVE, &uh->flags);
		
		uh->cable_detect_state = UH_CABLE_STATE_OFFLINE;
	}

	return;
}
Exemplo n.º 10
0
static void button_timer_callback(unsigned long data)
{
	int gpio;
	int code;
	int active_low;
	struct platform_device *pdev = (struct platform_device *)data;
	struct input_dev *input = platform_get_drvdata(pdev);
	int state, i;
	static int button_pressed[KEY_NUM] = { 0, 0, 0, 0, 0 };

	down(&sem);

	for (i = 0; i < KEY_NUM; i++) {
		if (1 == current_key[i]) {
			gpio = board_buttons[i].gpio;
			code = board_buttons[i].code;
			active_low = board_buttons[i].active_low;

			state = __gpio_get_pin(gpio);

			if (active_low ^ state) {
				/* button pressed */
				button_pressed[i] = 1;
				input_report_key(input, code, 1);
				//input_sync(input);
				mod_timer(&kbd_timer[i],
					  jiffies + SCAN_INTERVAL);
				dprintk("gpio %d down, code:%d \n",
							gpio, code);
			} else {
				/* button released */
				if (1 == button_pressed[i]) {
					input_report_key(input, code, 0);
					//input_sync(input);
					button_pressed[i] = 0;
					current_key[i] = 0;
					dprintk("gpio %d up, code:%d \n",
								gpio, code);
				}
			}
		}
	}
	up(&sem);

}
Exemplo n.º 11
0
/* Called from kernel thread */
static void do_detect(struct uh_data *uh)
{
	D("Called.\n");
	
	if (!test_and_clear_bit(BIT_DO_DETECT, &uh->flags))
		return;

	D("Do detect.\n");

	if(__gpio_get_pin(uh->gpio_pin)) {
		cable_detect(uh);
		usb_detect(uh);
		
		set_cable_state(uh, uh->cable_detect_state);
	}else{
		set_cable_state(uh, UH_CABLE_STATE_OFFLINE);
	}
	
	return;
}
Exemplo n.º 12
0
int read_gpio_pin(int pin)
{
	int t, v;
	int i;

	i = GPIO_DEBOUNCE;

	v = t = 0;

	while (i--) {
		t = __gpio_get_pin(pin);
		if (v != t)
			i = GPIO_DEBOUNCE;

		v = t;
		ndelay(100);
	}

	return v;
}
Exemplo n.º 13
0
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);
}
Exemplo n.º 14
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;
}
Exemplo n.º 15
0
static void gpio_init(void)
{
	/*
	 * Initialize NAND Flash Pins
	 */
	__gpio_as_nand();

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

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

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

	/*
	 * Initialize Other pins
	 */
	unsigned int i;
	for (i = 0; i < 7; i++){
		__gpio_as_input(GPIO_KEYIN_BASE + i);
		__gpio_enable_pull(GPIO_KEYIN_BASE + i);
	}

	for (i = 0; i < 8; i++) {
		__gpio_as_output(GPIO_KEYOUT_BASE + i);
		__gpio_clear_pin(GPIO_KEYOUT_BASE + i);
	}

	/* enable the TP4, TP5 as UART0 */
	__gpio_jtag_to_uart0();

	/*
	 * Initialize UART0 pins, in Ben NanoNote uart0 and keyin8 use the
	 * same gpio, init the gpio as uart0 cause a keyboard bug. so for
	 * end user we disable the uart0
	 */
	if (__gpio_get_pin(GPIO_KEYIN_BASE + 2) == 0){
		/* if pressed [S] */
		printf("[S] pressed, enable UART0\n");
		gd->boot_option |= BOOT_WITH_ENABLE_UART;
		__gpio_as_uart0();
	} else {
		__gpio_as_input(GPIO_KEYIN_8);
		__gpio_enable_pull(GPIO_KEYIN_8);
	}

	__gpio_as_output(GPIO_AUDIO_POP);
	__gpio_set_pin(GPIO_AUDIO_POP);

	__gpio_as_output(GPIO_LCD_CS);
	__gpio_clear_pin(GPIO_LCD_CS);

	__gpio_as_output(GPIO_AMP_EN);
	__gpio_clear_pin(GPIO_AMP_EN);

	__gpio_as_output(GPIO_SDPW_EN);
	__gpio_disable_pull(GPIO_SDPW_EN);
	__gpio_clear_pin(GPIO_SDPW_EN);

	__gpio_as_input(GPIO_SD_DETECT);
	__gpio_disable_pull(GPIO_SD_DETECT);

	__gpio_as_input(GPIO_USB_DETECT);
	__gpio_enable_pull(GPIO_USB_DETECT);

	if (__gpio_get_pin(GPIO_KEYIN_BASE + 3) == 0) {
		printf("[M] pressed, boot from sd card\n");
		gd->boot_option |= BOOT_FROM_SDCARD;
	}
}
Exemplo n.º 16
0
BOOL GPIOGetLevel(BYTE IOPIN)
{
	return __gpio_get_pin(IO_DOOR_SENSOR-(IOPIN&0x0f));
}
Exemplo n.º 17
0
/* return 1 means battery is full; return 0 means battery is empty */
int GetBatteryStatus(void)
{
	return __gpio_get_pin(GPIO_BATTERY);
}
Exemplo n.º 18
0
BOOL GPIOGetLevel(BYTE IOPIN)
{
        return __gpio_get_pin(GPIOCvtTbl[IOPIN]);
}
Exemplo n.º 19
0
static int GetEscPin(void)
{
    __gpio_as_input(GP_KEYESC);
    return __gpio_get_pin(GP_KEYESC);
}
Exemplo n.º 20
0
static int Get164Input(void)
{
    __gpio_as_input(GP_KEYSCAN);
    return __gpio_get_pin(GP_KEYSCAN);
}