Ejemplo n.º 1
0
int eddy_gpio_ioctl(struct inode *inode, struct file *flip,
		unsigned int command, unsigned long arg)
{
	int ret=0;
	int copy_size =0;

	void __user *argp = (void __user *)arg;

	switch (command) {

		case INIT_PRODUCT:
			/* ready led set mode out */
			at91_set_gpio_output(AT91_PIN_PC4,GPIO_HIGH);
			/* reset swith read */
			at91_set_gpio_input(AT91_PIN_PC16,PULLUP_ENABLE);
			break;

		case GET_PRODUCTID:
			productID = get_productID();	
			return productID;	
			break;
		case RDY_LED_ON:
			/* ready LED on */
			at91_set_gpio_value(AT91_PIN_PC4,GPIO_HIGH);
			break;
		case RDY_LED_OFF:
			/* ready LED off */
			at91_set_gpio_value(AT91_PIN_PC4,GPIO_LOW);
			break;
		case RESET_READ:
			/* reset switch read */	
			ret = at91_get_gpio_value(AT91_PIN_PC16);
			break;

		case SETGPIOINIT:		
			copy_size = sizeof(tmp_gpio_l);
			if (copy_from_user(&tmp_gpio_l, argp, copy_size))
			{
				return -EFAULT;
			}
			memcpy(&eddy_gpio_l,&tmp_gpio_l,copy_size);
			
			set_lowlevel_gpio_info(PIOM,SETGPIOENABLE);
			set_lowlevel_gpio_info(PIOM,SETGPIOMOD);
			set_lowlevel_gpio_info(PIOM,SETGPIOPUL);
			set_lowlevel_gpio_info(PIOM,SETGPIOVAL);

			return ret;

		case SETGPIOMOD_LM	:		

			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_from_user(&tmp_gpio_l.mode[0], argp, copy_size))
			{
				return -EFAULT;
			}
			ret = set_lowlevel_gpio_info(PIOM,SETGPIOMOD);
			return ret;


		case GETGPIOMOD_LM	:	

			ret = get_lowlevel_gpio_info(PIOM, PIO_OSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio_l.mode[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;

		case SETGPIOVAL_LM	:

			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_from_user(&tmp_gpio_l.value[0], argp, copy_size))
			{
				return -EFAULT;
			}
			ret = set_lowlevel_gpio_info(PIOM,SETGPIOVAL);

			return ret;

		case GETGPIOVAL_LM	:	
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOM, PIO_PDSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio_l.value[0],copy_size))
			{
				return -EFAULT;
			}
			return 0;

		case SETGPIOPUL_LM	:
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_from_user(&tmp_gpio_l.pullup[0], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOM,SETGPIOPUL);
			return ret;

		case GETGPIOPUL_LM	:
			ret = get_lowlevel_gpio_info(PIOM, PIO_PUSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio_l.pullup[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;

		case SETGPIOMOD_LA	:
			copy_size = sizeof(unsigned int);
			if (copy_from_user(&tmp_gpio_l.mode[0], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOA,SETGPIOMOD);
			return ret;

		case GETGPIOMOD_LA	:
			ret = get_lowlevel_gpio_info(PIOA, PIO_OSR);
			copy_size = sizeof(unsigned int);
			if (copy_to_user(argp, &tmp_gpio_l.mode[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;

		case SETGPIOVAL_LA	:
			copy_size = sizeof(unsigned int);
			if (copy_from_user(&tmp_gpio_l.value[0], argp, copy_size))
			{
				return -EFAULT;
			}
			eddy_gpio_l.value[0] = tmp_gpio_l.value[0];
			__raw_writel(tmp_gpio_l.value[0], gpio_membase + PIO_SODR);
			tmp_gpio_l.value[0] = ~(tmp_gpio_l.value[0]) & eddy_gpio_l.en_gpio[0];
			__raw_writel(tmp_gpio_l.value[0], gpio_membase + PIO_CODR);

			return 0;
		case GETGPIOVAL_LA	:
			ret = get_lowlevel_gpio_info(PIOA, PIO_PDSR);
			copy_size = sizeof(unsigned int);
			if (copy_to_user(argp, &tmp_gpio_l.value[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOPUL_LA	:
			copy_size = sizeof(unsigned int);
			if (copy_from_user(&tmp_gpio_l.pullup[0], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOA,SETGPIOPUL);
			return ret;
		case GETGPIOPUL_LA	:
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOA, PIO_PUSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio_l.pullup[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOMOD_LB	:
			copy_size = sizeof(unsigned int);
			if (copy_from_user(&tmp_gpio_l.mode[1], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOB,SETGPIOMOD);

			return ret;

		case GETGPIOMOD_LB	:
			ret = get_lowlevel_gpio_info(PIOB, PIO_OSR);
			copy_size = sizeof(unsigned int);
			if (copy_to_user(argp, &tmp_gpio_l.mode[1],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOVAL_LB	:
			copy_size = sizeof(unsigned int);
			if (copy_from_user(&tmp_gpio_l.value[1], argp, copy_size))
			{
				return -EFAULT;
			}

			eddy_gpio_l.value[1] = tmp_gpio_l.value[1];
			__raw_writel(tmp_gpio_l.value[1], gpio_membase + pio[1] + PIO_SODR);
			tmp_gpio_l.value[1] = ~(tmp_gpio_l.value[1]) & eddy_gpio_l.en_gpio[1];
			__raw_writel(tmp_gpio_l.value[1], gpio_membase + pio[1] + PIO_CODR);

			return 0;

		case GETGPIOVAL_LB	:
			ret = get_lowlevel_gpio_info(PIOB, PIO_PDSR);
			copy_size = sizeof(unsigned int);
			if (copy_to_user(argp, &tmp_gpio_l.value[1],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOPUL_LB	:
			copy_size = sizeof(unsigned int);
			if (copy_from_user(&tmp_gpio_l.pullup[1], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOB,SETGPIOPUL);
			return ret;
		case GETGPIOPUL_LB	:
			ret = get_lowlevel_gpio_info(PIOB, PIO_PUSR);
			copy_size = sizeof(unsigned int);
			if (copy_to_user(argp, &tmp_gpio_l.pullup[1],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOMOD_LC	:
			copy_size = sizeof(unsigned int);
			if (copy_from_user(&tmp_gpio_l.mode[2], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOC,SETGPIOMOD);

			return ret;

		case GETGPIOMOD_LC	:
			ret = get_lowlevel_gpio_info(PIOC, PIO_OSR);
			copy_size = sizeof(unsigned int);
			if (copy_to_user(argp, &tmp_gpio_l.mode[2],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOVAL_LC	:
			copy_size = sizeof(unsigned int);
			if (copy_from_user(&tmp_gpio_l.value[2], argp, copy_size))
			{
				return -EFAULT;
			}

			eddy_gpio_l.value[2] = tmp_gpio_l.value[2];
			__raw_writel(tmp_gpio_l.value[2], gpio_membase + pio[2] + PIO_SODR);
			tmp_gpio_l.value[2] = ~(tmp_gpio_l.value[2]) & eddy_gpio_l.en_gpio[2];
			__raw_writel(tmp_gpio_l.value[2], gpio_membase + pio[2] + PIO_CODR);

			return 0;
		case GETGPIOVAL_LC	:
			ret = get_lowlevel_gpio_info(PIOC, PIO_PDSR);
			copy_size = sizeof(unsigned int);
			if (copy_to_user(argp, &tmp_gpio_l.value[2],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOPUL_LC	:
			copy_size = sizeof(unsigned int);
			if (copy_from_user(&tmp_gpio_l.pullup[2], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOC,SETGPIOPUL);
			return ret;
		case GETGPIOPUL_LC	:
			ret = get_lowlevel_gpio_info(PIOC, PIO_PUSR);
			copy_size = sizeof(unsigned int);
			if (copy_to_user(argp, &tmp_gpio_l.pullup[2],copy_size))
			{
				return -EFAULT;
			}
			return ret;

		default : 
			return 0;
	}
	return ret;

}
static int ads7843_pendown_state(void)
{
	return !at91_get_gpio_value(AT91_PIN_PC2);	/* Touchscreen PENIRQ */
}
Ejemplo n.º 3
0
static int __init at91_ide_probe(struct platform_device *pdev)
{
	int ret;
	struct ide_hw hw, *hws[] = { &hw };
	struct ide_host *host;
	struct resource *res;
	unsigned long tf_base = 0, ctl_base = 0;
	struct at91_cf_data *board = pdev->dev.platform_data;

	if (!board)
		return -ENODEV;

	if (board->det_pin && at91_get_gpio_value(board->det_pin) != 0) {
		perr("no device detected\n");
		return -ENODEV;
	}

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res) {
		perr("can't get memory resource\n");
		return -ENODEV;
	}

	if (!devm_request_mem_region(&pdev->dev, res->start + TASK_FILE,
				     REGS_SIZE, "ide") ||
	    !devm_request_mem_region(&pdev->dev, res->start + ALT_MODE,
				     REGS_SIZE, "alt")) {
		perr("memory resources in use\n");
		return -EBUSY;
	}

	pdbg("chipselect %u irq %u res %08lx\n", board->chipselect,
	     board->irq_pin, (unsigned long) res->start);

	tf_base = (unsigned long) devm_ioremap(&pdev->dev, res->start + TASK_FILE,
					       REGS_SIZE);
	ctl_base = (unsigned long) devm_ioremap(&pdev->dev, res->start + ALT_MODE,
						REGS_SIZE);
	if (!tf_base || !ctl_base) {
		perr("can't map memory regions\n");
		return -EBUSY;
	}

	memset(&hw, 0, sizeof(hw));

	if (board->flags & AT91_IDE_SWAP_A0_A2) {
		/* workaround for stupid hardware bug */
		hw.io_ports.data_addr	= tf_base + 0;
		hw.io_ports.error_addr	= tf_base + 4;
		hw.io_ports.nsect_addr	= tf_base + 2;
		hw.io_ports.lbal_addr	= tf_base + 6;
		hw.io_ports.lbam_addr	= tf_base + 1;
		hw.io_ports.lbah_addr	= tf_base + 5;
		hw.io_ports.device_addr = tf_base + 3;
		hw.io_ports.command_addr = tf_base + 7;
		hw.io_ports.ctl_addr	= ctl_base + 3;
	} else
		ide_std_init_ports(&hw, tf_base, ctl_base + 6);

	hw.irq = board->irq_pin;
	hw.dev = &pdev->dev;

	host = ide_host_alloc(&at91_ide_port_info, hws, 1);
	if (!host) {
		perr("failed to allocate ide host\n");
		return -ENOMEM;
	}

	/* setup Static Memory Controller - PIO 0 as default */
	apply_timings(board->chipselect, 0, ide_timing_find_mode(XFER_PIO_0), 0);

	/* with GPIO interrupt we have to do quirks in handler */
	if (board->irq_pin >= PIN_BASE)
		host->irq_handler = at91_irq_handler;

	host->ports[0]->select_data = board->chipselect;

	ret = ide_host_register(host, &at91_ide_port_info, hws);
	if (ret) {
		perr("failed to register ide host\n");
		goto err_free_host;
	}
	platform_set_drvdata(pdev, host);
	return 0;

err_free_host:
	ide_host_free(host);
	return ret;
}
Ejemplo n.º 4
0
int eddy_gpio_ioctl(struct inode *inode, struct file *flip,
		unsigned int command, unsigned long arg)
{
	int ret=0;
	int tmp = 0;
	int copy_size =0;

	void __user *argp = (void __user *)arg;

	switch (command) {
		case INIT_PRODUCT:
			productID = get_productID();	
			/* all common setting */

			/* ready led set mode out */
			at91_set_gpio_output(AT91_PIN_PC4,GPIO_HIGH);
			/* reset swith read */
			at91_set_gpio_input(AT91_PIN_PC16,PULLUP_ENABLE);
			/* hardware reset */
			/* each product dependent setting */ 
			init_product();
			break;
		case GET_PRODUCTID:
			if(productID == 0x00)
			{
				productID = get_productID();	
			}
			return productID;	
			break;
		case COMRXON:
			/* receive enable */
			at91_set_gpio_value(AT91_PIN_PC16,GPIO_HIGH);
			/* transmit disable */
			at91_set_gpio_value(AT91_PIN_PC17,GPIO_HIGH);
			break;
		case COMTXON:
			/* receive disable */
			at91_set_gpio_value(AT91_PIN_PC16,GPIO_LOW);
			/* transmit enable */
			at91_set_gpio_value(AT91_PIN_PC17,GPIO_LOW);
			break;
		case RDY_LED_ON:
			/* ready LED on */
			//	printk("ready led on\n");
			at91_set_gpio_value(AT91_PIN_PC4,GPIO_HIGH);
			break;
		case RDY_LED_OFF:
			//	printk("ready led off\n");
			/* ready LED off */
			at91_set_gpio_value(AT91_PIN_PC4,GPIO_LOW);
			break;
		case RESET_READ:
			/* reset switch read */	
			//	ret = at91_get_gpio_value(AT91_PIN_PC16);
			ret = 1;

			break;
		case HW_RESET:
			/* Hardware reset */
			at91_set_gpio_value(AT91_PIN_PB19,GPIO_HIGH);
			udelay(100);
			at91_set_gpio_value(AT91_PIN_PB19,GPIO_HIGH);
			udelay(100);
			at91_set_gpio_value(AT91_PIN_PB19,GPIO_HIGH);
			udelay(100);
			break;	
		case SETGPIOMODEIN:
			if(copy_from_user(&tmp, (void *) arg, sizeof(int)))
			{
				return -EFAULT;
			}
			else
			{
				if(productID == EDDY_CPU)
				{
					tmp += AT91_PIN_PC16 ;
				}
				if(productID == EDDY_S1_PIN || productID == EDDY_S1_PIN_C || productID == EDDY_S2_M || productID == EDDY_S2_M_C)
				{
					tmp += AT91_PIN_PC28 ;
				}
				if(productID == EDDY_DK_C)
				{
					tmp += AT91_PIN_PC20 ;
				}

			}
			ret = check_gpio_num(tmp);
			//printk("set gpio mode in ret = %d, tmp = %d \n",ret,tmp);
			if(ret < 0)
			{
				break;
			}
			else
			{
				ret = at91_set_gpio_input(tmp,PULLUP_ENABLE);
				break;
			}
		case SETGPIOMODEOUT:
			if(copy_from_user(&tmp, (void *) arg, sizeof(int)))
			{
				return -EFAULT;
			}
			else
			{
				if(productID == EDDY_CPU)
				{
					//printk("set gpio mode out Eddy_CPU\n");
					tmp += AT91_PIN_PC16 ;
				}
				if(productID == EDDY_S1_PIN || productID == EDDY_S1_PIN_C || productID == EDDY_S2_M || productID == EDDY_S2_M_C)
				{
					//printk("set gpio mode out Eddy_S1_PIN\n");
					tmp += AT91_PIN_PC28 ;
				}
				if(productID == EDDY_DK_C)
				{
					tmp += AT91_PIN_PC20 ;
				}

			}
			ret = check_gpio_num(tmp);
			if(ret < 0)
			{
				break;
			}
			else
			{
				ret = at91_set_gpio_output(tmp,GPIO_HIGH);
				break;
			}
		case GETGPIOMODE:
			if(copy_from_user(&tmp, (void *) arg, sizeof(int)))
			{
				return -EFAULT;
			}
			else
			{
				if(productID == EDDY_CPU)
				{
					tmp += AT91_PIN_PC16 ;
				}
				if(productID == EDDY_S1_PIN || productID == EDDY_S1_PIN_C || productID == EDDY_S2_M || productID == EDDY_S2_M_C)
				{
					tmp += AT91_PIN_PC28 ;
				}
				if(productID == EDDY_DK_C)
				{
					tmp += AT91_PIN_PC20 ;
				}

			}
			ret = check_gpio_num(tmp);
			//printk("get gpio mode ret = %d, tmp = %d \n",ret,tmp);
			if(ret < 0)
			{
				break;
			}
			else
			{
				ret = at91_get_gpio_mode(tmp);
				break;
			}
		case SETGPIOVALUEHIGH:
			if(copy_from_user(&tmp, (void *) arg, sizeof(int)))
			{
				return -EFAULT;
			}
			else
			{
				if(productID == EDDY_CPU)
				{
					tmp += AT91_PIN_PC16 ;
				}
				if(productID == EDDY_S1_PIN || productID == EDDY_S1_PIN_C || productID == EDDY_S2_M || productID == EDDY_S2_M_C)
				{
					tmp += AT91_PIN_PC28 ;
				}
				if(productID == EDDY_DK_C)
				{
					tmp += AT91_PIN_PC20 ;
				}

			}
			ret = check_gpio_num(tmp);
			if(ret < 0)
			{
				break;
			}
			else
			{
				ret = at91_set_gpio_value(tmp,GPIO_HIGH);
				//	printk("set gpio value high = %d \n",tmp);
				break;
			}
		case SETGPIOVALUELOW:
			//printk("\n");
			if(copy_from_user(&tmp, (void *) arg, sizeof(int)))

			{
				return -EFAULT;
			}
			else
			{
				//	printk("set gpio value low 1 = %d \n",tmp);
				if(productID == EDDY_CPU)
				{
					tmp += AT91_PIN_PC16 ;
				}
				if(productID == EDDY_S1_PIN || productID == EDDY_S1_PIN_C || productID == EDDY_S2_M || productID == EDDY_S2_M_C)
				{
					tmp += AT91_PIN_PC28 ;
				}
				if(productID == EDDY_DK_C)
				{
					tmp += AT91_PIN_PC20 ;
				}

			}
			ret = check_gpio_num(tmp);
			//	printk("set gpio value low 2 = %d \n",tmp);
			if(ret < 0)
			{
				break;
			}
			else
			{
				ret = at91_set_gpio_value(tmp,GPIO_LOW);
				//		printk("set gpio value low 3 = %d \n",tmp);
				break;
			}
		case GETGPIOVALUE:
			//printk("\n");
			if(copy_from_user(&tmp, (void *) arg, sizeof(int)))
			{
				return -EFAULT;
			}
			else
			{
				if(productID == EDDY_CPU)
				{
					tmp += AT91_PIN_PC16 ;
				}
				if(productID == EDDY_S1_PIN || productID == EDDY_S1_PIN_C || productID == EDDY_S2_M || productID == EDDY_S2_M_C)
				{
					tmp += AT91_PIN_PC28 ;
				}
				if(productID == EDDY_DK_C)
				{
					tmp += AT91_PIN_PC20 ;
				}

			}
			ret = check_gpio_num(tmp);
			if(ret < 0)
			{
				break;
			}
			else
			{
				ret = at91_get_gpio_value(tmp);
				//		printk("get gpio value = %d \n",tmp);
				break;
			}
		case GPIO_CHIP:
			//	printk("gpio chip check\n");
			ret = system_process();
			break;
	}

	switch (tmp)
	{
		case SETGPIOMOD_LM	:		

			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_from_user(&tmp_gpio.mode[0], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOM,PIO_IDR);
			ret = set_lowlevel_gpio_info(PIOM,PIO_PUDR);
			ret = set_lowlevel_gpio_info(PIOM,PIO_OER);
			ret = set_lowlevel_gpio_info(PIOM,PIO_PER);

			return ret;


		case GETGPIOMOD_LM	:	

			ret = get_lowlevel_gpio_info(PIOM, PIO_OSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio.mode[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;

		case SETGPIOVAL_LM	:

			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_from_user(&tmp_gpio.value[0], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOM,PIO_SODR);

			return ret;

		case GETGPIOVAL_LM	:	
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOM, PIO_ODSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio.value[0],copy_size))
			{
				return -EFAULT;
			}
			return 0;

		case SETGPIOPUL_LM	:
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_from_user(&tmp_gpio.pullup[0], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOM,PIO_PUER);
			ret = set_lowlevel_gpio_info(PIOM,PIO_PUER);

			return ret;
		case GETGPIOPUL_LM	:
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOM, PIO_PUSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio.pullup[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;

		case SETGPIOMOD_LA	:
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_from_user(&tmp_gpio.mode[0], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOM,PIO_IDR);
			ret = set_lowlevel_gpio_info(PIOM,PIO_PUDR);
			ret = set_lowlevel_gpio_info(PIOM,PIO_OER);
			ret = set_lowlevel_gpio_info(PIOM,PIO_PER);

			return ret;

		case GETGPIOMOD_LA	:
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOA, PIO_OSR);
			copy_size = sizeof(unsigned int);
			if (copy_to_user(argp, &tmp_gpio.mode[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOVAL_LA	:
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_from_user(&tmp_gpio.value[0], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOM,PIO_SODR);

			return ret;
		case GETGPIOVAL_LA	:
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOA, PIO_ODSR);
			copy_size = sizeof(unsigned int);
			if (copy_to_user(argp, &tmp_gpio.value[0],copy_size))
			{
				return -EFAULT;
			}
			return 0;
		case SETGPIOPUL_LA	:
		case GETGPIOPUL_LA	:
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOA, PIO_PUSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio.pullup[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOMOD_LB	:
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_from_user(&tmp_gpio.mode[0], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOM,PIO_IDR);
			ret = set_lowlevel_gpio_info(PIOM,PIO_PUDR);
			ret = set_lowlevel_gpio_info(PIOM,PIO_OER);
			ret = set_lowlevel_gpio_info(PIOM,PIO_PER);

			return ret;

		case GETGPIOMOD_LB	:
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOB, PIO_OSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio.mode[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOVAL_LB	:
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_from_user(&tmp_gpio.value[0], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOM,PIO_SODR);

			return ret;
		case GETGPIOVAL_LB	:
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOB, PIO_ODSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio.value[0],copy_size))
			{
				return -EFAULT;
			}
			return 0;
		case SETGPIOPUL_LB	:
		case GETGPIOPUL_LB	:
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOB, PIO_PUSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio.pullup[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOMOD_LC	:
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_from_user(&tmp_gpio.mode[0], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOM,PIO_IDR);
			ret = set_lowlevel_gpio_info(PIOM,PIO_PUDR);
			ret = set_lowlevel_gpio_info(PIOM,PIO_OER);
			ret = set_lowlevel_gpio_info(PIOM,PIO_PER);

			return ret;

		case GETGPIOMOD_LC	:
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOC, PIO_OSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio.mode[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOVAL_LC	:
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_from_user(&tmp_gpio.value[0], argp, copy_size))
			{
				return -EFAULT;
			}

			ret = set_lowlevel_gpio_info(PIOM,PIO_SODR);

			return ret;
		case GETGPIOVAL_LC	:
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOC, PIO_ODSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio.value[0],copy_size))
			{
				return -EFAULT;
			}
			return 0;
		case SETGPIOPUL_LC	:
		case GETGPIOPUL_LC	:
			ret = 0;
			ret = get_lowlevel_gpio_info(PIOC, PIO_PUSR);
			copy_size = sizeof(unsigned int);
			copy_size *= 3;
			if (copy_to_user(argp, &tmp_gpio.pullup[0],copy_size))
			{
				return -EFAULT;
			}
			return ret;
		case SETGPIOMOD		:
		case GETGPIOMOD		:
		case SETGPIOVAL		:
		case GETGPIOVAL		:
		case SETGPIOPUL		:	
		case GETGPIOPUL		:
		case SETGPIOMOD_M	:
		case GETGPIOMOD_M	:
		case SETGPIOVAL_M	:
		case GETGPIOVAL_M	:
		case SETGPIOPUL_M	:
		case GETGPIOPUL_M	:
		default : 
			return 0;
	}
	return ret;

}
Ejemplo n.º 5
0
static inline int at91_cf_present(struct at91_cf_socket *cf)
{
	return !at91_get_gpio_value(cf->board->det_pin);
}
Ejemplo n.º 6
0
static int at91sam9260ek_nand_ready(struct mtd_info *mtd)
{
	return at91_get_gpio_value(AT91_PIN_PC13);
}
Ejemplo n.º 7
0
/*
 * Probe for the device
 */
static int __init at91_mci_probe(struct platform_device *pdev)
{
	struct mmc_host *mmc;
	struct at91mci_host *host;
	struct resource *res;
	int ret;

	pr_debug("Probe MCI devices\n");

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res)
		return -ENXIO;

	if (!request_mem_region(res->start, res->end - res->start + 1, DRIVER_NAME))
		return -EBUSY;

	mmc = mmc_alloc_host(sizeof(struct at91mci_host), &pdev->dev);
	if (!mmc) {
		pr_debug("Failed to allocate mmc host\n");
		release_mem_region(res->start, res->end - res->start + 1);
		return -ENOMEM;
	}

	mmc->ops = &at91_mci_ops;
	mmc->f_min = 375000;
	mmc->f_max = 25000000;
	mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
	mmc->caps = MMC_CAP_BYTEBLOCK;

	host = mmc_priv(mmc);
	host->mmc = mmc;
	host->buffer = NULL;
	host->bus_mode = 0;
	host->board = pdev->dev.platform_data;
	if (host->board->wire4) {
#ifdef SUPPORT_4WIRE
		mmc->caps |= MMC_CAP_4_BIT_DATA;
#else
		printk("AT91 MMC: 4 wire bus mode not supported by this driver - using 1 wire\n");
#endif
	}

	/*
	 * Get Clock
	 */
	host->mci_clk = clk_get(&pdev->dev, "mci_clk");
	if (IS_ERR(host->mci_clk)) {
		printk(KERN_ERR "AT91 MMC: no clock defined.\n");
		mmc_free_host(mmc);
		release_mem_region(res->start, res->end - res->start + 1);
		return -ENODEV;
	}

	/*
	 * Map I/O region
	 */
	host->baseaddr = ioremap(res->start, res->end - res->start + 1);
	if (!host->baseaddr) {
		clk_put(host->mci_clk);
		mmc_free_host(mmc);
		release_mem_region(res->start, res->end - res->start + 1);
		return -ENOMEM;
	}

	/*
	 * Reset hardware
	 */
	clk_enable(host->mci_clk);		/* Enable the peripheral clock */
	at91_mci_disable(host);
	at91_mci_enable(host);

	/*
	 * Allocate the MCI interrupt
	 */
	host->irq = platform_get_irq(pdev, 0);
	ret = request_irq(host->irq, at91_mci_irq, IRQF_SHARED, DRIVER_NAME, host);
	if (ret) {
		printk(KERN_ERR "AT91 MMC: Failed to request MCI interrupt\n");
		clk_disable(host->mci_clk);
		clk_put(host->mci_clk);
		mmc_free_host(mmc);
		iounmap(host->baseaddr);
		release_mem_region(res->start, res->end - res->start + 1);
		return ret;
	}

	platform_set_drvdata(pdev, mmc);

	/*
	 * Add host to MMC layer
	 */
	if (host->board->det_pin)
		host->present = !at91_get_gpio_value(host->board->det_pin);
	else
		host->present = -1;

	mmc_add_host(mmc);

	/*
	 * monitor card insertion/removal if we can
	 */
	if (host->board->det_pin) {
		ret = request_irq(host->board->det_pin, at91_mmc_det_irq,
				0, DRIVER_NAME, host);
		if (ret)
			printk(KERN_ERR "AT91 MMC: Couldn't allocate MMC detect irq\n");
	}

	pr_debug("Added MCI driver\n");

	return 0;
}
Ejemplo n.º 8
0
        at91_set_gpio_value(AT91_PIN_PB2, 1);
        mdelay(20); /* something > 13.5 msec */
}


/*******************************************************
 * SYSFS Subsection
 * Routines to manage the directory /sys/class/ipspeaker
 *******************************************************
 */
#define CLASS_NAME "ipspeaker"

static struct class *audio_class=NULL;

ssize_t ipspeaker_sysfs_ac_show(struct class *class, char *buf) {
        return sprintf(buf, "%d\n", at91_get_gpio_value(AT91_PIN_PB31));
}

ssize_t ipspeaker_sysfs_blazecom_show(struct class *class, char *buf) {
        return sprintf(buf, "%d\n", at91_get_gpio_value(AT91_PIN_PB0));
}

ssize_t ipspeaker_sysfs_ip_show(struct class *class, char *buf) {
        return sprintf(buf, "%d\n", at91_get_gpio_value(AT91_PIN_PC12));
}

ssize_t ipspeaker_sysfs_voldown_show(struct class *class, char *buf) {
        return sprintf(buf, "%d\n", at91_get_gpio_value(AT91_PIN_PC8));
}

ssize_t ipspeaker_sysfs_volup_show(struct class *class, char *buf) {
Ejemplo n.º 9
0
/* this is a weak define that we are overriding */
int board_mmc_getcd(struct mmc *mmc)
{
	return !at91_get_gpio_value(CONFIG_SYS_MMC_CD_PIN);
}
Ejemplo n.º 10
0
/*
 * Probe for the device
 */
static int at91rm9200_mci_probe(struct device* dev)
{
	struct mmc_host* mmc;
	struct at91mci_host* host;
	int ret;

	DBG("Probe MCI devices\n");

	mmc = mmc_alloc_host(sizeof(struct at91mci_host), dev);
	if (!mmc) {
		DBG("Failed to allocate mmc host\n");

		ret = -ENOMEM;
		return ret;
	}

	mmc->ops = &at91rm9200_mci_ops;
	mmc->f_min = 400000;
	mmc->f_max = 25000000;
	mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;

	host = mmc_priv(mmc);
	host->mmc = mmc;
	host->buffer = NULL;
	host->board = dev->platform_data;

	/*
	 * Allocate the MCI interrupt
	 */
	ret = request_irq(AT91C_ID_MCI, at91rm9200_mci_irq, SA_SHIRQ, DRIVER_NAME, host);
	if (ret) {
		DBG("Failed to request MCI interrupt\n");
		return ret;
	}

	dev_set_drvdata(dev, mmc);

	/*
	 * Add host to MMC layer
	 */
	if (host->board->det_pin)
		host->present = !at91_get_gpio_value(host->board->det_pin);
	else
		host->present = -1;

	if (host->board->wire4)
		host->mmc->flags |= HOST_CAP_SD_4_BIT;

	mmc_add_host(mmc);

	/*
	 * monitor card insertion/removal if we can
	 */
	if (host->board->det_pin) {
		ret = request_irq(host->board->det_pin, at91rm9200_mmc_det_irq,
				SA_SAMPLE_RANDOM, DRIVER_NAME, host);
		if (ret)
			DBG("couldn't allocate MMC detect irq\n");
	}

	DBG(KERN_INFO "Added MCI driver\n");

	return 0;
}
Ejemplo n.º 11
0
/*
 * Probe for the NAND device.
 */
static int __init at91_nand_probe(struct platform_device *pdev)
{
	struct at91_nand_host *host;
	struct mtd_info *mtd;
	struct nand_chip *nand_chip;
	int res;

#ifdef CONFIG_MTD_PARTITIONS
	struct mtd_partition *partitions = NULL;
	int num_partitions = 0;
#endif

	/* Allocate memory for the device structure (and zero it) */
	host = kzalloc(sizeof(struct at91_nand_host), GFP_KERNEL);
	if (!host) {
		printk(KERN_ERR "at91_nand: failed to allocate device structure.\n");
		return -ENOMEM;
	}

	host->io_base = ioremap(pdev->resource[0].start,
				pdev->resource[0].end - pdev->resource[0].start + 1);
	if (host->io_base == NULL) {
		printk(KERN_ERR "at91_nand: ioremap failed\n");
		kfree(host);
		return -EIO;
	}

	mtd = &host->mtd;
	nand_chip = &host->nand_chip;
	host->board = pdev->dev.platform_data;

	nand_chip->priv = host;		/* link the private data structures */
	mtd->priv = nand_chip;
	mtd->owner = THIS_MODULE;

	/* Set address of NAND IO lines */
	nand_chip->IO_ADDR_R = host->io_base;
	nand_chip->IO_ADDR_W = host->io_base;
	nand_chip->cmd_ctrl = at91_nand_cmd_ctrl;
	nand_chip->dev_ready = at91_nand_device_ready;
	nand_chip->ecc.mode = NAND_ECC_SOFT;	/* enable ECC */
	nand_chip->chip_delay = 20;		/* 20us command delay time */

	if (host->board->bus_width_16)		/* 16-bit bus width */
		nand_chip->options |= NAND_BUSWIDTH_16;

	platform_set_drvdata(pdev, host);
	at91_nand_enable(host);

	if (host->board->det_pin) {
		if (at91_get_gpio_value(host->board->det_pin)) {
			printk ("No SmartMedia card inserted.\n");
			res = ENXIO;
			goto out;
		}
	}

	/* Scan to find existance of the device */
	if (nand_scan(mtd, 1)) {
		res = -ENXIO;
		goto out;
	}

#ifdef CONFIG_MTD_PARTITIONS
	if (host->board->partition_info)
		partitions = host->board->partition_info(mtd->size, &num_partitions);

	if ((!partitions) || (num_partitions == 0)) {
		printk(KERN_ERR "at91_nand: No parititions defined, or unsupported device.\n");
		res = ENXIO;
		goto release;
	}

	res = add_mtd_partitions(mtd, partitions, num_partitions);
#else
	res = add_mtd_device(mtd);
#endif

	if (!res)
		return res;

release:
	nand_release(mtd);
out:
	at91_nand_disable(host);
	platform_set_drvdata(pdev, NULL);
	iounmap(host->io_base);
	kfree(host);
	return res;
}
Ejemplo n.º 12
0
static int at91_nand_ready(struct mtd_info *mtd)
{
	return at91_get_gpio_value(CONFIG_SYS_NAND_READY_PIN);
}
Ejemplo n.º 13
0
static int ads7843_pendown_state(void)
{
	return !at91_get_gpio_value(AT91_PIN_PC2);	
}