Beispiel #1
0
void firetux_set_led_VEGA_BASESTATION_IIIA(int led, int brightness)
{
	switch (led) {
	case 1:	/* GPIO A9 */
		if (brightness)
			clear_gpioa(9);
		else
			set_gpioa(9);
		break;
	case 2:	/* GPIO A31 */
		if (brightness)
			clear_gpioa(31);
		else
			set_gpioa(31);
		break;
	case 3:	/* GPIO A16 */
		if (brightness)
			clear_gpioa(16);
		else
			set_gpioa(16);
		break;
	case 4: /* GPIO A3 */
		if (brightness)
			clear_gpioa(3);
		else
			set_gpioa(3);
		break;
	default:
		break;
	}
}
Beispiel #2
0
void firetux_set_led_VEGA_BASESTATION_IIIB(int led, int brightness)
{
	switch (led) {
	case 1:	/* GPIO A9 */
		if (brightness)
			clear_gpioa(9);
		else
			set_gpioa(9);
		break;
	case 2:	/* GPIO A0 */
		if (brightness)
			clear_gpioa(0);
		else
			set_gpioa(0);
		break;
	default:
		break;
	}
}
Beispiel #3
0
static int pin_ioctl(struct inode *inode, struct file *filp,
                     unsigned int cmd, unsigned long arg)
{
	int ret = 0;
	ST_GPIO stGPIO;

	if ((DSPG_GPIOA_WRITE == cmd) || (DSPG_GPIOB_WRITE == cmd) || (DSPG_GPIOC_WRITE == cmd)
	                || (DSPG_GPIOA_SYSMUX == cmd) || (DSPG_GPIOB_SYSMUX == cmd) || (DSPG_GPIOC_SYSMUX == cmd)
	                || (DSPG_GPIOA_SYSPAD == cmd) || (DSPG_GPIOB_SYSPAD == cmd) || (DSPG_GPIOC_SYSPAD == cmd)
	                || (DSPG_GPIOA_READ == cmd) || (DSPG_GPIOB_READ == cmd) || (DSPG_GPIOC_READ == cmd))
	{
		ret = copy_from_user(&stGPIO, arg, sizeof(stGPIO));
	}

	switch (cmd)
	{
	case DSPG_GPIOA_WRITE:
		printk(KERN_INFO"DSPG_GPIOA_WRITE: write %d %d\n", stGPIO.iPin, stGPIO.iVal);
		set_direction_gpioa(stGPIO.iPin, 1);
		if (stGPIO.iVal)
			set_gpioa(stGPIO.iPin);
		else
			clear_gpioa(stGPIO.iPin);
		break;

	case DSPG_GPIOB_WRITE:
		printk(KERN_INFO"DSPG_GPIOB_WRITE: write %d %d\n", stGPIO.iPin, stGPIO.iVal);
		set_direction_gpiob(stGPIO.iPin, 1);
		if (stGPIO.iVal)
			set_gpiob(stGPIO.iPin);
		else
			clear_gpiob(stGPIO.iPin);
		break;

	case DSPG_GPIOC_WRITE:
		printk(KERN_INFO"DSPG_GPIOC_WRITE: write %d %d\n", stGPIO.iPin, stGPIO.iVal);
		set_direction_gpioc(stGPIO.iPin, 1);
		if (stGPIO.iVal)
			set_gpioc(stGPIO.iPin);
		else
			clear_gpioc(stGPIO.iPin);
		break;

	case DSPG_GPIOA_SYSMUX:
		printk(KERN_INFO"DSPG_GPIOA_SYSMUX: sysmux %d %d\n", stGPIO.iPin, stGPIO.iVal);
		set_sysmux_gpioa(stGPIO.iPin, stGPIO.iVal);
		break;

	case DSPG_GPIOB_SYSMUX:
		printk(KERN_INFO"DSPG_GPIOB_SYSMUX: sysmux %d %d\n", stGPIO.iPin, stGPIO.iVal);
		set_sysmux_gpiob(stGPIO.iPin, stGPIO.iVal);
		break;

	case DSPG_GPIOC_SYSMUX:
		printk(KERN_INFO"DSPG_GPIOC_SYSMUX: sysmux %d %d\n", stGPIO.iPin, stGPIO.iVal);
		set_sysmux_gpioc(stGPIO.iPin, stGPIO.iVal);
		break;

	case DSPG_GPIOA_SYSPAD:
		printk(KERN_INFO"DSPG_GPIOA_SYSPAD: syspad %d %d\n", stGPIO.iPin, stGPIO.iVal);
		set_syspad_gpioa(stGPIO.iPin, stGPIO.iVal);
		break;

	case DSPG_GPIOB_SYSPAD:
		printk(KERN_INFO"DSPG_GPIOB_SYSPAD: syspad %d %d\n", stGPIO.iPin, stGPIO.iVal);
		set_syspad_gpiob(stGPIO.iPin, stGPIO.iVal);
		break;

	case DSPG_GPIOC_SYSPAD:
		printk(KERN_INFO"DSPG_GPIOC_SYSPAD: syspad %d %d\n", stGPIO.iPin, stGPIO.iVal);
		set_syspad_gpioc(stGPIO.iPin, stGPIO.iVal);
		break;

		/* it's OK, and the syspad register is needed.
		set_sysmux_gpiob(stGPIO.iPin, 1);
		set_direction_gpiob(stGPIO.iPin, 0);
		set_syspad_gpiob(stGPIO.iPin, 0);
		*/
		/*
		set_direction_gpioa(stGPIO.iPin, 0);
		stGPIO.iVal = get_gpioa(stGPIO.iPin);

		ret = copy_to_user((void __user *)arg, &stGPIO, sizeof(stGPIO));
		if (ret == 0)
			printk(KERN_INFO"DSPG_GPIOA_READ: read %d = %d\n", stGPIO.iPin, stGPIO.iVal);
		else
			printk(KERN_INFO"DSPG_GPIOA_READ: error\n");
		*/

	case DSPG_GPIOA_READ:
		config_gpioa(stGPIO.iPin, SYSMUX_GPIOA, GPIOA_DIR_INPUT, SYSPAD_PULL_UP, -1);
		stGPIO.iVal = get_gpioa(stGPIO.iPin);

		ret = copy_to_user((void __user *)arg, &stGPIO, sizeof(stGPIO));
		if (ret == 0)
			printk(KERN_INFO"DSPG_GPIOA_READ: read %d = %d\n", stGPIO.iPin, stGPIO.iVal);
		else
			printk(KERN_INFO"DSPG_GPIOA_READ: error\n");
			
		break;

	case DSPG_GPIOB_READ:
		config_gpiob(stGPIO.iPin, SYSMUX_GPIOB, GPIOB_DIR_INPUT, SYSPAD_PULL_UP, -1);
		stGPIO.iVal = get_gpiob(stGPIO.iPin);

		ret = copy_to_user((void __user *)arg, &stGPIO, sizeof(stGPIO));
		if (ret == 0)
			printk(KERN_INFO"DSPG_GPIOB_READ: read %d = %d\n", stGPIO.iPin, stGPIO.iVal);
		else
			printk(KERN_INFO"DSPG_GPIOB_READ: error\n");

		break;

	case DSPG_GPIOC_READ:
		config_gpioc(stGPIO.iPin, SYSMUX_GPIOC, GPIOC_DIR_INPUT, SYSPAD_PULL_UP, -1);
		stGPIO.iVal = get_gpioc(stGPIO.iPin);

		ret = copy_to_user((void __user *)arg, &stGPIO, sizeof(stGPIO));
		if (ret == 0)
			printk(KERN_INFO"DSPG_GPIOC_READ: read %d = %d\n", stGPIO.iPin, stGPIO.iVal);
		else
			printk(KERN_INFO"DSPG_GPIOC_READ: error\n");
			
		break;

	default:
		ret = -EINVAL;
	}

	return ret;
}