Beispiel #1
0
static int pxa250_irda_startup(struct net_device *dev)
{
   

   __ECHO_IN;

   /*
    * Ensure that the ports for this device are setup correctly.
    */


   set_GPIO_mode (GPIO46_STRXD_MD);
   set_GPIO_mode (GPIO47_STTXD_MD);

   STMCR = MCR_OUT2;
   STLCR = LCR_WLS1 | LCR_WLS0;

   SET_SIR_MODE;
   CKEN |= CKEN5_STUART;
   /* enable irq from stuart */
   ICMR |= ( 1 << 20 );
	
   /*reset FIFO*/
		
/*	STFCR = FCR_TRFIFOE |  FCR_RESETTF | FCR_RESETRF;// | FCR_ITL_16;

	STIER = IER_UUE | IER_RAVIE | IER_RTOIE;
*/	
   __ECHO_OUT;

   return 0;
	
}
Beispiel #2
0
void ezx_i2c_pm_resume(void)
{
        /* enable clocks */
        CKEN |= CKEN14_I2C;
        set_GPIO_mode(117 | GPIO_ALT_FN_1_IN);
        set_GPIO_mode(118 | GPIO_ALT_FN_1_IN);
        /* enable irqs */
        enable_irq(i2c_pxa_data.irq);
        /* disable unit */
        _ICR(adap) &= ~ICR_IUE;
        /* reset the unit */
        _ICR(adap) |= ICR_UR;
        udelay(100);
        _ICR(adap) |= ICR_FM;
        /* disable unit */
        _ICR(adap) &= ~ICR_IUE;
        /* XXX: I2C_PXA_SLAVE_ADDR == I2C_PXA_PWR_SLAVE_ADDR ??? */
        /* set our slave address */
        _ISAR(adap) = I2C_PXA_SLAVE_ADDR;
        /* set control register values */
        _ICR(adap) = I2C_ICR_INIT;
        /* set clear interrupt bits */
        _ISR(adap) = I2C_ISR_INIT;
        /* enable unit */
        _ICR(adap) |= ICR_IUE;
        udelay(100);					
}
Beispiel #3
0
static void i2c_pxa_reset(struct i2c_algo_pxa_data *adap)
{
        /* set the global I2C clocks on */
        CKEN |= CKEN14_I2C;

	set_GPIO_mode(117 | GPIO_ALT_FN_1_IN);
	set_GPIO_mode(118 | GPIO_ALT_FN_1_IN);

#ifdef CONFIG_POWER_I2C
        /* set the global PWR_I2C clock on */
        CKEN |= CKEN15_PWRI2C;

	/* Enable PI2C controller PWR_SCL and PWR_SDA */
	PCFR |= PCFR_PI2CEN;

	/* Setup GPIO3 and GPIO4 to ALT_FN1_IN (PWR_SCL and PWR_SDA) */
	set_GPIO_mode(3 | GPIO_ALT_FN_1_IN);
	set_GPIO_mode(4 | GPIO_ALT_FN_1_IN);

#endif

        /* disable unit */
	_ICR(adap) &= ~ICR_IUE;

        /* reset the unit */
	_ICR(adap) |= ICR_UR;
        udelay(100);
	_ICR(adap) |= ICR_FM;
	
        /* disable unit */
	_ICR(adap) &= ~ICR_IUE;

	/* XXX: I2C_PXA_SLAVE_ADDR == I2C_PXA_PWR_SLAVE_ADDR ??? */
        /* set our slave address */
	_ISAR(adap) = I2C_PXA_SLAVE_ADDR;

        /* set control register values */
	_ICR(adap) = I2C_ICR_INIT;

        /* set clear interrupt bits */
	_ISR(adap) = I2C_ISR_INIT;

        /* enable unit */
	_ICR(adap) |= ICR_IUE;
        udelay(100);

}
Beispiel #4
0
void turn_off_gpio(int gpio) {
	set_GPIO_mode(gpio | GPIO_OUT);
	GPCR(gpio) = GPIO_bit(gpio);
	if (GPLR(gpio) & GPIO_bit(gpio)) {
		PDEBUG("LED gpio %d on\n", gpio);
	} else {
		PDEBUG("LED gpio %d off\n", gpio);
	}
}
Beispiel #5
0
ssize_t gpio_write(struct file *file, const char *ubuf, size_t count,
		   loff_t *offp)
{
	unsigned int domode=0, inout=0, i, j;
	char buf[16];
	char *p;

	if (count > 15) count = 15;
	if (copy_from_user(buf, ubuf, count))
		return -EFAULT;
	buf[count] = '\0';

	p = buf;
	/* skip blanks: it may be all blanks, then accept it */
	while (*p && isspace(*p))
		p++;
	if (!*p)
		return count;

	/* mode: accept M and I or O */
	if (*p == 'm' || *p == 'M') {
		domode++, p++;
		if (*p == 'i' || *p == 'I')
			inout= 0;
		else if (*p == 'o' || *p == 'O')
			inout = GPIO_MD_MASK_DIR;
		else return -EINVAL;
		p++;
	}

	/* get numbers */
	if (sscanf(p, "%i=%i", &i, &j) != 2)
		return -EINVAL;
	if (!i || i > 80 || j > 3)
		return -EINVAL;
	if (!domode && j > 1)
		return -EINVAL;

	/* act */
	if (domode) {
		if (!j)     domode =                0;
		if (j == 1) domode = GPIO_ALT_FN_1_IN;
		if (j == 2) domode = GPIO_ALT_FN_2_IN;
		if (j == 3) domode = GPIO_ALT_FN_3_IN;
		domode |= inout;
		set_GPIO_mode( i | domode);
	} else {
		if (j)
			GPSR(i) = GPIO_bit(i);
		else
			GPCR(i) = GPIO_bit(i);
	}
	*offp += count;
	return count;
}
Beispiel #6
0
static void pxa250_do_fir_GPIO_config(void)
{
   /*
    * Modify GPIO 46 and 47 Alternate Function 
    */

   __ECHO_IN;

   /*Switch AF*/
   set_GPIO_mode (GPIO46_ICPRXD_MD);
   set_GPIO_mode (GPIO47_ICPTXD_MD);

   if (machine_is_lubbock())
      LUB_MISC_WR |= 1 << 4;

   /*init clock*/
   CKEN |= CKEN13_FICP;

   __ECHO_OUT;
}
Beispiel #7
0
/* Connect the USB device to the bus */
void udc_connect(void)
{
	usbdbg("UDC connect");

#ifdef CONFIG_USB_DEV_PULLUP_GPIO
	/* Turn on the USB connection by enabling the pullup resistor */
	set_GPIO_mode(CONFIG_USB_DEV_PULLUP_GPIO | GPIO_OUT);
	writel(GPIO_bit(CONFIG_USB_DEV_PULLUP_GPIO), GPSR(CONFIG_USB_DEV_PULLUP_GPIO));
#else
	/* Host port 2 transceiver D+ pull up enable */
	writel(readl(UP2OCR) | UP2OCR_DPPUE, UP2OCR);
#endif
}
Beispiel #8
0
static void cerf_pcmcia_reset( void)
{
	int i;

	// Make sure SKTSEL is 0 (single slot)
	set_GPIO_mode(54 | GPIO_OUT);
	GPCR1 = GPIO_bit(54);
	set_GPIO_mode(GPIO54_pSKTSEL_MD);

	PCMCIA_GPCR = PCMCIA_GPIO_CF_RESET_MASK;
	mdelay(300);

	PCMCIA_GPSR = PCMCIA_GPIO_CF_RESET_MASK;
	udelay(20);

	PCMCIA_GPCR = PCMCIA_GPIO_CF_RESET_MASK;
	mdelay(50);

	for( i=0; i<10; i++)
	{
		if( cerf_pcmcia_level_ready()) break;
		mdelay(100);
	}
}
static void __init csb226_map_io(void)
{
	pxa_map_io();
	iotable_init(csb226_io_desc);

	/* This enables the BTUART */
	CKEN |= CKEN7_BTUART;
	set_GPIO_mode(GPIO42_BTRXD_MD);
	set_GPIO_mode(GPIO43_BTTXD_MD);
	set_GPIO_mode(GPIO44_BTCTS_MD);
	set_GPIO_mode(GPIO45_BTRTS_MD);

	/* This is for the CS8900 chip select */
	set_GPIO_mode(GPIO78_nCS_2_MD);

	/* setup sleep mode values */
	PWER  = 0x00000002;
	PFER  = 0x00000000;
	PRER  = 0x00000002;
	PGSR0 = 0x00008000;
	PGSR1 = 0x003F0202;
	PGSR2 = 0x0001C000;
	PCFR |= PCFR_OPDE;
}
Beispiel #10
0
static int pxa250_irda_set_speed(struct net_device *dev, int speed)
{
   struct pxa250_irda *si = dev->priv;
   int brd, ret = -EINVAL;
   static int last_fir_speed=0;

   __ECHO_IN;
   


   switch (speed) {
      case 9600:	case 19200:	case 38400:
      case 57600:	case 115200:
	   
	 /* Baud rate fixed - Clo */

	 /*
	  * FIXME
	  */
	 if (last_fir_speed) 
	 {

	    pxa250_stop_fir(dev);
	    set_GPIO_mode (GPIO46_STRXD_MD);
	    set_GPIO_mode (GPIO47_STTXD_MD);
   
	    enable_irq(dev->irq);
	    netif_wake_queue(dev);
	    last_fir_speed=0;
	 }
	 

	 LUB_MISC_WR &= ~(1 << 4);

	 brd = 14745600 / (16 * speed); 

	 STLCR |= LCR_DLAB;

	 STDLH = brd >> 8; /* Clo: set Divisor Latch High */
	 STDLL = brd & 0xFF; /* Clo: set Devisor Latch Low */
		
	 STLCR &= ~LCR_DLAB; /* Clo: clear DLAB bit */ 

	 STMCR = MCR_OUT2;

	 CKEN |= CKEN5_STUART;

	 ICMR |= ( 1 << 20 );
		
	 STLCR = LCR_WLS1 | LCR_WLS0;

	 SET_SIR_MODE;
		
	 STFCR = FCR_TRFIFOE |  FCR_RESETTF | FCR_RESETRF | FCR_ITL_1 ;// | FCR_ITL_16;

	 STIER = IER_UUE | IER_RAVIE | IER_RTIOE;

	 si->speed = speed;

	 ret = 0;
	 break;

      case 4000000:

	 if (last_fir_speed)
	    goto speed_out;
	 
	 disable_irq(dev->irq);

	 pxa250_sir_irda_shutdown(si);
	 pxa250_fir_irda_startup(si);
	 pxa250_irda_rx_alloc(si);
	 ICCR0=0;
	 pxa250_start_rx_dma(dev);
	 pxa250_ficp_rx_start();
	 
	 enable_irq(si->fir_irq);
	 DBG("enable FIR \n");
	 si->speed = speed;

	 netif_wake_queue(dev);
	 last_fir_speed=1;
speed_out:
	 
	 ret=0;
	 
	 break;

      default:
	 break;
   }
   __ECHO_OUT;

   return ret;
}
Beispiel #11
0
int sg_ssp_init(void)
{
  int result;
  
  /* Set up owner pointers.*/
  SET_MODULE_OWNER(&sg_ssp_fops);
  
  /* Get our needed resources. */
  result = check_mem_region(SG_SSP_PHYSBASE, SG_SSP_SIZE);
  if (result) {
    printk(KERN_INFO "sg_ssp: can't get I/O mem address 0x%lx\n",
	   SG_SSP_PHYSBASE);
    return result;
  }
  request_mem_region(SG_SSP_PHYSBASE, SG_SSP_SIZE, "SSP");
  
  result = check_mem_region(SG_GPIOCNTL_PHYSBASE, SG_GPIOCNTL_SIZE);
  if (result) {
    printk(KERN_INFO "sg_ssp: can't get GPIO I/O mem address 0x%lx\n",
	   SG_GPIOCNTL_PHYSBASE);
    return result;
  }
  request_mem_region(SG_GPIOCNTL_PHYSBASE, SG_GPIOCNTL_SIZE, "SSPGPIO");

  /* also, ioremap it */
  sg_ssp_vbase = (unsigned long)sg_ssp_remap(SG_SSP_PHYSBASE,SG_SSP_SIZE);
  /* Hmm... we should check the return value */
  
  result = register_chrdev(major, "ssp", &sg_ssp_fops);
  if (result < 0) {
    printk(KERN_INFO "sg_ssp: can't get major number\n");
    sg_ssp_unmap((void *)sg_ssp_vbase);
    release_mem_region(SG_SSP_PHYSBASE,SG_SSP_SIZE);
    return result;
  }
  if (major == 0) major = result; /* dynamic */
  
  result = request_irq(IRQ_SSP, sg_ssp_interrupt,
		       SA_INTERRUPT, "ssp", NULL);
  if (result) {
    printk(KERN_INFO "sg_ssp: can't get assigned irq %i\n",
	   IRQ_SSP);
    sg_ssp_unmap((void *)sg_ssp_vbase);
    release_mem_region(SG_SSP_PHYSBASE,SG_SSP_SIZE);
    return result;
  }

  SSSR = SSPS_ROR;
  SSCR1 = 0;

  // Enable the SSP alternate functions
  set_GPIO_mode(GPIO23_SCLK_md);
  set_GPIO_mode(GPIO25_STXD_MD); // Enable the SSP TX/RX lines
  set_GPIO_mode(GPIO26_SRXD_MD);

  set_GPIO_mode((GPIO27_SEXTCLK | GPIO_IN));    // Avoid driving the RED LED
  set_GPIO_mode((22 | GPIO_OUT));		// MUX Selector
  set_GPIO_mode((77 | GPIO_OUT));		// RSTN 

  /* Set the state of the reset pin */
  GPSR(77) = GPIO_bit(77);  // RSTN -> 1
 
  return 0;
}
Beispiel #12
0
int
/****************************************************/
mmc_init(int verbose)
/****************************************************/
{
 	int retries, rc = -ENODEV;
	uchar *resp;

#ifdef CONFIG_LUBBOCK
	set_GPIO_mode( GPIO6_MMCCLK_MD );
	set_GPIO_mode( GPIO8_MMCCS0_MD );
#endif
	CKEN |= CKEN12_MMC; /* enable MMC unit clock */

	mmc_csd.c_size = 0;

	MMC_CLKRT  = MMC_CLKRT_0_3125MHZ;
	MMC_RESTO  = MMC_RES_TO_MAX;
	MMC_SPI    = MMC_SPI_DISABLE;

	/* reset */
	retries = 10;
	resp = mmc_cmd(0, 0, 0, 0);
	resp = mmc_cmd(1, 0x00ff, 0xc000, MMC_CMDAT_INIT|MMC_CMDAT_BUSY|MMC_CMDAT_R3);
	while (retries-- && resp && !(resp[4] & 0x80))
	{
		debug("resp %x %x\n", resp[0], resp[1]);
		udelay(50);
		resp = mmc_cmd(1, 0x00ff, 0xff00, MMC_CMDAT_BUSY|MMC_CMDAT_R3);
	}

	/* try to get card id */
	resp = mmc_cmd(2, 0, 0, MMC_CMDAT_R2);
	if (resp)
	{
		/* TODO configure mmc driver depending on card attributes */
		mmc_cid_t *cid = (mmc_cid_t *)resp;
		if (verbose)
		{
			printf("MMC found. Card desciption is:\n");
			printf("Manufacturer ID = %02x%02x%02x\n",
							cid->id[0], cid->id[1], cid->id[2]);
			printf("HW/FW Revision = %x %x\n",cid->hwrev, cid->fwrev);
			cid->hwrev = cid->fwrev = 0;	/* null terminate string */
			printf("Product Name = %s\n",cid->name);
			printf("Serial Number = %02x%02x%02x\n",
							cid->sn[0], cid->sn[1], cid->sn[2]);
			printf("Month = %d\n",cid->month);
			printf("Year = %d\n",1997 + cid->year);
		}
		/* fill in device description */
		mmc_dev.if_type = IF_TYPE_MMC;
		mmc_dev.dev = 0;
		mmc_dev.lun = 0;
		mmc_dev.type = 0;
		/* FIXME fill in the correct size (is set to 32MByte) */
		mmc_dev.blksz = 512;
		mmc_dev.lba = 0x10000;
		sprintf(mmc_dev.vendor,"Man %02x%02x%02x Snr %02x%02x%02x",
				cid->id[0], cid->id[1], cid->id[2],
				cid->sn[0], cid->sn[1], cid->sn[2]);
		sprintf(mmc_dev.product,"%s",cid->name);
		sprintf(mmc_dev.revision,"%x %x",cid->hwrev, cid->fwrev);
		mmc_dev.removable = 0;
		mmc_dev.block_read = mmc_bread;

		/* MMC exists, get CSD too */
		resp = mmc_cmd(MMC_CMD_SET_RCA, MMC_DEFAULT_RCA, 0, MMC_CMDAT_R1);
		resp = mmc_cmd(MMC_CMD_SEND_CSD, MMC_DEFAULT_RCA, 0, MMC_CMDAT_R2);
		if (resp)
		{
			mmc_csd_t *csd = (mmc_csd_t *)resp;
			memcpy(&mmc_csd, csd, sizeof(csd));
			rc = 0;
			mmc_ready = 1;
			/* FIXME add verbose printout for csd */
		}
	}

	MMC_CLKRT = 0;	/* 20 MHz */
	resp = mmc_cmd(7, MMC_DEFAULT_RCA, 0, MMC_CMDAT_R1);

	fat_register_device(&mmc_dev,1); /* partitions start counting with 1 */

	return rc;
}
Beispiel #13
0
static int ezx_i2c_pm_callback(struct pm_dev *pm_dev, pm_request_t req, void *data)
{
	switch(req)
	{
	case PM_SUSPEND:
		/* disable IRQs */
		if (i2c_pxa_data.irq) 
		          disable_irq(i2c_pxa_data.irq);
		/* disable PI2C Controller */
		PCFR &= ~PCFR_PI2CEN;
		
		/* disable clocks */
		CKEN &= ~CKEN14_I2C;

#ifdef CONFIG_POWER_I2C
		if (i2c_pxa_pwr_data.irq)
		          disable_irq(i2c_pxa_pwr_data.irq);
		/* disable PI2C Controller */
		PCFR &= ~PCFR_PI2CEN;
		CKEN &= ~CKEN15_PWRI2C;
#endif		
		break;
	case PM_RESUME:
        /* enable clocks */
        CKEN |= CKEN14_I2C;

        set_GPIO_mode(117 | GPIO_ALT_FN_1_IN);
        set_GPIO_mode(118 | GPIO_ALT_FN_1_IN);
        /* enable irqs */
        enable_irq(i2c_pxa_data.irq);
#ifdef CONFIG_POWER_I2C
      	/* set the global PWR_I2C clock on */
        CKEN |= CKEN15_PWRI2C;

		/* Enable PI2C controller PWR_SCL and PWR_SDA */
		PCFR |= PCFR_PI2CEN;
        set_GPIO_mode(3 | GPIO_ALT_FN_1_IN);
        set_GPIO_mode(4 | GPIO_ALT_FN_1_IN);
		enable_irq(i2c_pxa_pwr_data.irq);
#endif	
	
 	    /* disable unit */
		_ICR(adap) &= ~ICR_IUE;

	    /* reset the unit */
		_ICR(adap) |= ICR_UR;
	    udelay(100);
		_ICR(adap) |= ICR_FM;
        /* disable unit */
		_ICR(adap) &= ~ICR_IUE;

		/* XXX: I2C_PXA_SLAVE_ADDR == I2C_PXA_PWR_SLAVE_ADDR ??? */
	    /* set our slave address */
		_ISAR(adap) = I2C_PXA_SLAVE_ADDR;

	    /* set control register values */
		_ICR(adap) = I2C_ICR_INIT;

    	/* set clear interrupt bits */
		_ISR(adap) = I2C_ISR_INIT;

        /* enable unit */
		_ICR(adap) |= ICR_IUE;
        udelay(100);	
		break;
	}
	return 0;
}
Beispiel #14
0
static int __init s3c2410_ts_init(void)
{
	int ret;

	tsEvent = tsEvent_dummy;

	ret = register_chrdev(0, DEVICE_NAME, &s3c2410_fops);
	if (ret < 0) {
	  printk(DEVICE_NAME " can't get major number\n");
	  return ret;
	}
	tsMajor = ret;

	/* set gpio to XP, YM, YP and  YM */
#if 0
	set_GPIO_mode(GPIO106_nYPON_MD);
	set_GPIO_mode(GPIO105_YMON_MD);
	set_GPIO_mode(GPIO104_nXPON_MD);
	set_GPIO_mode(GPIO103_XMON_MD);

	GPUP(GPIO106_nYPON) |= GPIO_bit(GPIO106_nYPON);
	GPUP(GPIO105_YMON) &= GPIO_bit(GPIO105_YMON);
	GPUP(GPIO104_nXPON) |= GPIO_bit(GPIO104_nXPON);
	GPUP(GPIO103_XMON) &= GPIO_bit(GPIO103_XMON);
#else
	set_gpio_ctrl(GPIO_YPON); 
	set_gpio_ctrl(GPIO_YMON);
	set_gpio_ctrl(GPIO_XPON);
	set_gpio_ctrl(GPIO_XMON);
#endif

	/* Enable touch interrupt */
	ret = request_irq(IRQ_ADC_DONE, s3c2410_isr_adc, SA_INTERRUPT, 
			  DEVICE_NAME, s3c2410_isr_adc);
	if (ret) goto adc_failed;
	ret = request_irq(IRQ_TC, s3c2410_isr_tc, SA_INTERRUPT, 
			  DEVICE_NAME, s3c2410_isr_tc);
	if (ret) goto tc_failed;

	/* Wait for touch screen interrupts */
	wait_down_int();

#ifdef CONFIG_DEVFS_FS
	devfs_ts_dir = devfs_mk_dir(NULL, "touchscreen", NULL);
	devfs_tsraw = devfs_register(devfs_ts_dir, "0raw", DEVFS_FL_DEFAULT,
			tsMajor, TSRAW_MINOR, S_IFCHR | S_IRUSR | S_IWUSR,
			&s3c2410_fops, NULL);
#endif

#ifdef CONFIG_PM
#if 0
	tsdev.pm_dev = pm_register(PM_GP_DEV, PM_USER_INPUT,
				   s3c2410_ts_pm_callback);
#endif
	tsdev.pm_dev = pm_register(PM_DEBUG_DEV, PM_USER_INPUT,
				   s3c2410_ts_pm_callback);
#endif
	printk(DEVICE_NAME " initialized\n");

	return 0;
 tc_failed:
	free_irq(IRQ_ADC_DONE, s3c2410_isr_adc);
 adc_failed:
	return ret;
}
Beispiel #15
0
static int do_ioctl(struct inode * inode, struct file *filp,
		    u_int cmd, u_long arg)
{
	struct apm_user *	as;
	struct pm_dev *		pm;
	struct ipm_config	conf;

	as = filp->private_data;
	if (check_apm_user(as, "ioctl"))
		return -EIO;

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

	switch (cmd) {
        case APM_IOC_SUSPEND:
		pm_do_suspend(CPUMODE_SLEEP);
		break;
        case APM_IOC_SET_WAKEUP:
		if ((pm = pm_find((pm_dev_t)arg,NULL)) == NULL)
			return -EINVAL;
		pm_send(pm,PM_SET_WAKEUP,NULL);
		break;
	case APM_IOC_SLEEP:
		pm_go_sleep(arg);
		break;
	case APM_IOC_SET_SPROF_WIN:
		sleep_to = arg * HZ;
		APM_DPRINTK("do_ioctl: sleep timeout %ld\n", arg);
		break;
	case APM_IOC_WAKEUP_ENABLE:
		PWER |= arg;
		APM_DPRINTK("do_ioctl: enable wakeup source:PWER=0x%x\n", PWER);
		break;
	case APM_IOC_WAKEUP_DISABLE:
		PWER &= ~arg;
		APM_DPRINTK("do_ioctl: disable wakeup source:PWER=0x%x\n", PWER);
		break;
	case APM_IOC_POWEROFF:
		APM_DPRINTK("do_ioctl: do power off\n");
		/* here all device should response ok */
		pm_send_all(PM_SUSPEND, (void *)3);
		pm_do_poweroff();
		pm_send_all(PM_RESUME, (void *)0);
		break;
	case APM_IOC_RESET_BP:
		APM_DPRINTK("do_ioctl: reset bp\n");
		GPCR(GPIO_BB_RESET) = GPIO_bit(GPIO_BB_RESET);
		mdelay(1);
		GPSR(GPIO_BB_RESET) = GPIO_bit(GPIO_BB_RESET);
		break;
	case APM_IOC_USEROFF_ENABLE:
		APM_DPRINTK("do_ioctl: useroff support enable\n");
		user_off_available = (int)arg;
		break;
	case APM_IOC_NOTIFY_BP:
                break;
        case APM_IOC_REFLASH:
                cpu_proc_fin();
                *(unsigned long *)(phys_to_virt(FLAG_ADDR)) = REFLASH_FLAG;

//		power_ic_periph_set_usb_pull_up(0);
//LIN           mdelay(1000);
//LIN let GPIO control the connectivity
#include <linux/power_ic.h>
		set_GPIO_mode(GPIO_USB_READY|GPIO_OUT);
		clr_GPIO(GPIO_USB_READY);
		power_ic_periph_set_usb_pull_up(0);
		mdelay(10);
		power_ic_set_reg_bit(POWER_IC_REG_EOC_CONN_CONTROL,19,1);//LIN set USB_CNTRL(bit19) to disable emu control
		mdelay(1000);
//LIN		power_ic_periph_set_usb_pull_up(1);

                /* Initialize the watchdog and let it fire */
                OWER = OWER_WME;
                OSSR = OSSR_M3;
		OSMR3 = OSCR + CLOCK_TICK_RATE/100;	/* ... in 10 ms */
                MDREFR |= MDREFR_SLFRSH;
		while(1);
                break;
        case APM_IOC_PASSTHRU:
                cpu_proc_fin();
                *(unsigned long *)(phys_to_virt(FLAG_ADDR)) = PASS_THRU_FLAG;

		power_ic_periph_set_usb_pull_up(0);
                mdelay(1000);
		power_ic_periph_set_usb_pull_up(1);

                /* Initialize the watchdog and let it fire */
                OWER = OWER_WME;
                OSSR = OSSR_M3;
		OSMR3 = OSCR + CLOCK_TICK_RATE/100;	/* ... in 10 ms */
                MDREFR |= MDREFR_SLFRSH;
		while(1);
                break;
	case APM_IOC_SET_IPROF_WIN:
		/* set profile window size */
		break;
	case APM_IOC_STARTPMU:
		if( pipm_start_pmu !=NULL )
			pipm_start_pmu();
		break;
	case APM_IOC_GET_IPM_CONFIG:
		get_ipm_config(&conf);
		return (copy_to_user((void *)arg, &conf,sizeof(conf)))? -EFAULT:0;
		break;
	case APM_IOC_SET_IPM_CONFIG:
		if(copy_from_user(&conf,(void *)arg,sizeof(conf)))
			return -EFAULT;
		
		return set_ipm_config(&conf);
		break;
	default:
		return -EINVAL;
	}
	return 0;
}
Beispiel #16
0
static void usb_hub_port_connect_change(struct usb_hub *hubstate, int port,
					u16 portstatus, u16 portchange)
{
	struct usb_device *hub = hubstate->dev;
	struct usb_device *dev;
	unsigned int delay = HUB_SHORT_RESET_TIME;
	int i;

	dbg("port %d, portstatus %x, change %x, %s",
		port + 1, portstatus, portchange, portspeed (portstatus));

	/* Clear the connection change status */
	usb_clear_port_feature(hub, port + 1, USB_PORT_FEAT_C_CONNECTION);

	/* Disconnect any existing devices under this port */
	if (hub->children[port])
		usb_disconnect(&hub->children[port]);

	/* Return now if nothing is connected */
	if (!(portstatus & USB_PORT_STAT_CONNECTION)) {
		if (portstatus & USB_PORT_STAT_ENABLE)
			usb_hub_port_disable(hub, port);

		return;
	}

	if (usb_hub_port_debounce(hub, port)) {
		err("connect-debounce failed, port %d disabled", port+1);
		usb_hub_port_disable(hub, port);
		return;
	}

	down(&usb_address0_sem);

	for (i = 0; i < HUB_PROBE_TRIES; i++) {
		struct usb_device *pdev;
		int len;

		/* Allocate a new device struct */
		dev = usb_alloc_dev(hub, hub->bus);
		if (!dev) {
			err("couldn't allocate usb_device");
			break;
		}

		hub->children[port] = dev;
		
		/* add by Levis for wakeup BP */
		int begin = 0;
#ifdef CONFIG_ARCH_EZXBASE
			set_GPIO_mode(GPIO_IN | GPIO_BP_RDY);
			if(!GPIO_is_high(GPIO_BP_RDY))
			{
				if(GPIO_is_high(GPIO_AP_RDY ))
				{
					GPCR(GPIO_AP_RDY ) = GPIO_bit(GPIO_AP_RDY );
					udelay(WAKE_UP_BP_UDELAY);
					GPSR(GPIO_AP_RDY ) = GPIO_bit(GPIO_AP_RDY );
				}else {
					GPSR(GPIO_AP_RDY ) = GPIO_bit(GPIO_AP_RDY );
					udelay(WAKE_UP_BP_UDELAY);
					GPCR(GPIO_AP_RDY ) = GPIO_bit(GPIO_AP_RDY );
				}
				begin = jiffies;
				while(!GPIO_is_high(GPIO_BP_RDY) && (jiffies < (begin+HZ)))					;
				if(!GPIO_is_high(GPIO_BP_RDY))
				{
					printk("%s: Wakeup BP timeout! BP is still in sleep state!\n", __FUNCTION__);		
				}				
			}
#else  
		set_GPIO_mode(GPIO_IN | 41);
		if(GPIO_is_high(41))
		{
			if(GPIO_is_high(GPIO_MCU_INT_SW))
				GPCR(GPIO_MCU_INT_SW) = GPIO_bit(GPIO_MCU_INT_SW);		
			else {
				GPSR(GPIO_MCU_INT_SW) = GPIO_bit(GPIO_MCU_INT_SW);		
			}	
			begin = jiffies;
			while(GPIO_is_high(41) && (jiffies < (begin+HZ))) printk("%s: waitting for BP active!\n", __FUNCTION__);
			if(GPIO_is_high(GPIO_MCU_INT_SW))
				GPCR(GPIO_MCU_INT_SW) = GPIO_bit(GPIO_MCU_INT_SW);		
			else {
				GPSR(GPIO_MCU_INT_SW) = GPIO_bit(GPIO_MCU_INT_SW);		
			}	
		}
#endif	
		/* end Levis */

		/* Reset the device */
		if (usb_hub_port_reset(hub, port, dev, delay)) {
			usb_free_dev(dev);
			break;
		}

		/* Find a new device ID for it */
		usb_connect(dev);

		/* Set up TT records, if needed  */
		if (hub->tt) {
			dev->tt = hub->tt;
			dev->ttport = hub->ttport;
		} else if (dev->speed != USB_SPEED_HIGH
				&& hub->speed == USB_SPEED_HIGH) {
			dev->tt = &hubstate->tt;
			dev->ttport = port + 1;
		}

		/* Save readable and stable topology id, distinguishing
		 * devices by location for diagnostics, tools, etc.  The
		 * string is a path along hub ports, from the root.  Each
		 * device's id will be stable until USB is re-cabled, and
		 * hubs are often labeled with these port numbers.
		 *
		 * Initial size: ".NN" times five hubs + NUL = 16 bytes max
		 * (quite rare, since most hubs have 4-6 ports).
		 */
		pdev = dev->parent;
		if (pdev->devpath [0] != '0')	/* parent not root? */
			len = snprintf (dev->devpath, sizeof dev->devpath,
				"%s.%d", pdev->devpath, port + 1);
		/* root == "0", root port 2 == "2", port 3 that hub "2.3" */
		else
			len = snprintf (dev->devpath, sizeof dev->devpath,
				"%d", port + 1);
		if (len == sizeof dev->devpath)
			warn ("devpath size! usb/%03d/%03d path %s",
				dev->bus->busnum, dev->devnum, dev->devpath);
		info("new USB device %s-%s, assigned address %d",
			dev->bus->bus_name, dev->devpath, dev->devnum);

		/* Run it through the hoops (find a driver, etc) */
		if (!usb_new_device(dev))
			goto done;

		/* Free the configuration if there was an error */
		usb_free_dev(dev);

		/* Switch to a long reset time */
		delay = HUB_LONG_RESET_TIME;
	}

	hub->children[port] = NULL;
	usb_hub_port_disable(hub, port);
done:
	up(&usb_address0_sem);
}
Beispiel #17
0
static void ipcusb_xmit_data(void)
{	
	int c, count = IPC_URB_SIZE;
	int result = 0;
	int buf_flag = 0;
	int buf_num = 0;

	if( !(UHCRHPS3 & 0x2))
       	{
                printk("\n ipcusb_xmit_data:port has been disabled.\n");
                return;
        }		
	//printk("%s: sumbit_times=%d, callback_times=%d\n", __FUNCTION__, sumbit_times, callback_times);
	if(bvd_ipc->write_finished_flag == 0)
	{
		//printk("%s: write_finished_flag=%d, return!\n", __FUNCTION__, bvd_ipc->write_finished_flag); 
		return;
	}
 
	while (1) 
	{
		c = CIRC_CNT_TO_END(bvd_ipc->xmit.head, bvd_ipc->xmit.tail, IPC_USB_XMIT_SIZE);
		if (count < c)
		  c = count;
		if (c <= 0) {		  
		  break;
		}
		memcpy(bvd_ipc->obuf+buf_num, bvd_ipc->xmit.buf + bvd_ipc->xmit.tail, c);
		buf_flag = 1;	
		bvd_ipc->xmit.tail = ((bvd_ipc->xmit.tail + c) & (IPC_USB_XMIT_SIZE-1));
		count -= c;
		buf_num += c;
	}    
#ifdef CONFIG_NO_USB_SUSPEND_RESUME
		
#else	 
	if(buf_num == 0)
	{
		bvd_dbg("ipcusb_xmit_data: buf_num=%d, add suspend_timer", buf_num);
		bvd_ipc->suspend_flag = 0;
		mod_timer(&suspend_timer, jiffies+(IPC_USB_SUSPEND_INTERVAL*HZ/1000));
	}
#endif
	bvd_dbg("ipcusb_xmit_data: buf_num=%d", buf_num);
	bvd_dbg("ipcusb_xmit_data: bvd_ipc->obuf: ");

#ifdef BVD_DEBUG	
	bvd_dbg_hex((bvd_ipc->obuf)-buf_num, buf_num);
#endif

	if( buf_flag )
	{
		
		bvd_ipc->writeurb_mux.transfer_buffer_length = buf_num;
		bvd_dbg("ipcusb_xmit_data: copy data to write urb finished! ");
#ifdef CONFIG_NO_USB_SUSPEND_RESUME 

#else		
		if((UHCRHPS3 & 0x4) == 0x4)
		{
			static int ret;
			int time = 0;	

#ifdef CONFIG_ARCH_EZXBASE
			/**if BP sleep, wake up BP first**/
			set_GPIO_mode(GPIO_IN | GPIO_BP_RDY);
			if(!GPIO_is_high(GPIO_BP_RDY))
			{
				if(GPIO_is_high(GPIO_AP_RDY ))
				{
					GPCR(GPIO_AP_RDY ) = GPIO_bit(GPIO_AP_RDY );
					udelay(WAKE_UP_BP_UDELAY);
					GPSR(GPIO_AP_RDY ) = GPIO_bit(GPIO_AP_RDY );
				}else {
					GPSR(GPIO_AP_RDY ) = GPIO_bit(GPIO_AP_RDY );
					udelay(WAKE_UP_BP_UDELAY);
					GPCR(GPIO_AP_RDY ) = GPIO_bit(GPIO_AP_RDY );
				}
				time = jiffies;
				while(!GPIO_is_high(GPIO_BP_RDY) && (jiffies < (time+HZ)))					;

				if(!GPIO_is_high(GPIO_BP_RDY))
				{
					printk("%s: Wakeup BP timeout! BP is still in sleep state!\n", __FUNCTION__);		
				}				
			}
#else 
			/**if BP sleep, wake up BP first**/
			set_GPIO_mode(GPIO_IN | 41);
			if(GPIO_is_high(41))
			{
				if(GPIO_is_high(GPIO_MCU_INT_SW))
					GPCR(GPIO_MCU_INT_SW) = GPIO_bit(GPIO_MCU_INT_SW);
				else{
					GPSR(GPIO_MCU_INT_SW) = GPIO_bit(GPIO_MCU_INT_SW);
				}
				time = jiffies;
				while(GPIO_is_high(41) && (jiffies < (time+HZ)))					;
				if(GPIO_is_high(41))
				{
					printk("%s: Wakeup BP timeout! BP state is %d\n", __FUNCTION__, GPIO_is_high(41));		
				}
				if(GPIO_is_high(GPIO_MCU_INT_SW))
					GPCR(GPIO_MCU_INT_SW) = GPIO_bit(GPIO_MCU_INT_SW);
				else{
					GPSR(GPIO_MCU_INT_SW) = GPIO_bit(GPIO_MCU_INT_SW);
				}
			}
#endif
			/** Resume BP**/ 
//			ipc_traffic = 1;
	
			UHCRHPS3 = 0x8;
			while(!(UHCRHPS3 & (1<<18))) mdelay(1);
			UHCRHPS3 = 1<<18; // Write 1 to clear
			bvd_dbg("ipc-resume[0x%x]\n",UHCRHPS3);
			bvd_dbg("ipcusb_xmit_data: Send RESUME signal! UHCRHPS3=0x%x\n", UHCRHPS3);
			host_port_suspended = 0;
			mdelay(3);
			set_BLE();
			/*send IN token*/
			bvd_ipc->readurb_mux.actual_length = 0;
			bvd_ipc->readurb_mux.dev = bvd_ipc->ipc_dev;
			if((ret = usb_submit_urb(&bvd_ipc->readurb_mux)) < 0)
			{
				warn("\nerr:[out]submit_readurb failed [%d]\n", ret);
			}
			bvd_dbg("\n[out]IN token sent-----\n");
		}
#endif
		sumbit_times++;
		bvd_ipc->write_finished_flag = 0;
		bvd_dbg("%s: clear write_finished_flag:%d\n", __FUNCTION__, bvd_ipc->write_finished_flag);
		bvd_ipc->writeurb_mux.dev = bvd_ipc->ipc_dev;
		if((result = usb_submit_urb(&bvd_ipc->writeurb_mux)) < 0)
		{
			warn("\n[out]submit_urb_ret[%d]\n", result);
		}
		
		bvd_dbg("\n[out]usb_submit_urb[%d]\n", result);

	}		
}
Beispiel #18
0
/* pxa_pcmcia_driver_init()
 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 *
 * This routine performs a basic sanity check to ensure that this
 * kernel has been built with the appropriate board-specific low-level
 * PCMCIA support, performs low-level PCMCIA initialization, registers
 * this socket driver with Card Services, and then spawns the daemon
 * thread which is the real workhorse of the socket driver.
 *
 * Please see linux/Documentation/arm/SA1100/PCMCIA for more information
 * on the low-level kernel interface.
 *
 * Returns: 0 on success, -1 on error
 */
static int __init pxa_pcmcia_driver_init(void){
  servinfo_t info;
  struct pcmcia_init pcmcia_init;
  struct pcmcia_state state[PXA_PCMCIA_MAX_SOCK];
  struct pcmcia_state_array state_array;
  unsigned int i, clock;
  unsigned long mecr;

  printk(KERN_INFO "Intel PXA250/210 PCMCIA (CS release %s)\n", CS_RELEASE);

  CardServices(GetCardServicesInfo, &info);

  if(info.Revision!=CS_RELEASE_CODE){
    printk(KERN_ERR "Card Services release codes do not match\n");
    return -1;
  }

  /* Setup GPIOs for PCMCIA/CF alternate function mode.
   *
   * It would be nice if set_GPIO_mode included support
   * for driving GPIO outputs to default high/low state
   * before programming GPIOs as outputs. Setting GPIO
   * outputs to default high/low state via GPSR/GPCR
   * before defining them as outputs should reduce
   * the possibility of glitching outputs during GPIO
   * setup. This of course assumes external terminators
   * are present to hold GPIOs in a defined state.
   *
   * In the meantime, setup default state of GPIO
   * outputs before we enable them as outputs.
   */

  GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
                      GPIO_bit(GPIO49_nPWE) |
                      GPIO_bit(GPIO50_nPIOR) |
                      GPIO_bit(GPIO51_nPIOW) |
                      GPIO_bit(GPIO52_nPCE_1) |
                      GPIO_bit(GPIO53_nPCE_2);

  set_GPIO_mode(GPIO48_nPOE_MD);
  set_GPIO_mode(GPIO49_nPWE_MD);
  set_GPIO_mode(GPIO50_nPIOR_MD);
  set_GPIO_mode(GPIO51_nPIOW_MD);
  set_GPIO_mode(GPIO52_nPCE_1_MD);
  set_GPIO_mode(GPIO53_nPCE_2_MD);
  set_GPIO_mode(GPIO54_pSKTSEL_MD); /* REVISIT: s/b dependent on num sockets */
  set_GPIO_mode(GPIO55_nPREG_MD);
  set_GPIO_mode(GPIO56_nPWAIT_MD);
  set_GPIO_mode(GPIO57_nIOIS16_MD);


  if(machine_is_lubbock()){
#ifdef CONFIG_ARCH_LUBBOCK
    pcmcia_low_level=&lubbock_pcmcia_ops;
#endif
  } else if (machine_is_pxa_idp()) {
    pcmcia_low_level=&pxa_idp_pcmcia_ops;
  } else if( machine_is_pxa_cerf()){
    pcmcia_low_level=&cerf_pcmcia_ops;
  }

  if (!pcmcia_low_level) {
    printk(KERN_ERR "This hardware is not supported by the PXA250/210 Card Service driver\n");
    return -ENODEV;
  }

  pcmcia_init.handler=pxa_pcmcia_interrupt;

  if((pxa_pcmcia_socket_count=pcmcia_low_level->init(&pcmcia_init))<0){
    printk(KERN_ERR "Unable to initialize kernel PCMCIA service.\n");
    return -EIO;
  }

  state_array.size=pxa_pcmcia_socket_count;
  state_array.state=state;

  /* Configure MECR based on the number of sockets present. */
  if (pxa_pcmcia_socket_count == 2) {
    MECR |= GPIO_bit(0);
  } else {
    MECR &= ~GPIO_bit(0);
  }

  if(pcmcia_low_level->socket_state(&state_array)<0){
    printk(KERN_ERR "Unable to get PCMCIA status from kernel.\n");
    return -EIO;
  }

  /* Well, it looks good to go. So we can now enable the PCMCIA
   * controller.
   */
  MECR |= GPIO_bit(1);

  /* We need to initialize the MCXX registers to default values
   * here because we're not guaranteed to see a SetIOMap operation
   * at runtime.
   */

  clock = get_lclk_frequency_10khz();

  for(i=0; i<pxa_pcmcia_socket_count; ++i){
    pxa_pcmcia_socket[i].k_state=state[i];

    /* This is an interim fix. Apparently, SetSocket is no longer
     * called to initialize each socket (prior to the first detect
     * event). For now, we'll just manually set up the mask.
     */
    pxa_pcmcia_socket[i].cs_state.csc_mask=SS_DETECT;

    pxa_pcmcia_socket[i].virt_io=(i==0)?PCMCIA_IO_0_BASE:PCMCIA_IO_1_BASE;
    pxa_pcmcia_socket[i].phys_attr=_PCMCIAAttr(i);
    pxa_pcmcia_socket[i].phys_mem=_PCMCIAMem(i);

    /* REVISIT: cleanup these macros */
    //MCIO_SET(i, PXA_PCMCIA_IO_ACCESS, clock);
    //MCATTR_SET(i, PXA_PCMCIA_5V_MEM_ACCESS, clock);
    //MCMEM_SET(i, PXA_PCMCIA_5V_MEM_ACCESS, clock);

    pxa_pcmcia_socket[i].speed_io=PXA_PCMCIA_IO_ACCESS;
    pxa_pcmcia_socket[i].speed_attr=PXA_PCMCIA_5V_MEM_ACCESS;
    pxa_pcmcia_socket[i].speed_mem=PXA_PCMCIA_5V_MEM_ACCESS;
  }

/* REVISIT: cleanup these macros */
MCMEM0 = ((pxa_mcxx_setup(PXA_PCMCIA_5V_MEM_ACCESS, clock)
		& MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT)
       | ((pxa_mcxx_asst(PXA_PCMCIA_5V_MEM_ACCESS, clock)
		& MCXX_ASST_MASK) << MCXX_ASST_SHIFT)
       | ((pxa_mcxx_hold(PXA_PCMCIA_5V_MEM_ACCESS, clock)
		& MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT);
MCMEM1 = ((pxa_mcxx_setup(PXA_PCMCIA_5V_MEM_ACCESS, clock)
		& MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT)
       | ((pxa_mcxx_asst(PXA_PCMCIA_5V_MEM_ACCESS, clock)
		& MCXX_ASST_MASK) << MCXX_ASST_SHIFT)
       | ((pxa_mcxx_hold(PXA_PCMCIA_5V_MEM_ACCESS, clock)
		& MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT);
MCATT0 = ((pxa_mcxx_setup(PXA_PCMCIA_5V_MEM_ACCESS, clock)
		& MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT)
       | ((pxa_mcxx_asst(PXA_PCMCIA_5V_MEM_ACCESS, clock)
		& MCXX_ASST_MASK) << MCXX_ASST_SHIFT)
       | ((pxa_mcxx_hold(PXA_PCMCIA_5V_MEM_ACCESS, clock)
		& MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT);
MCATT1 = ((pxa_mcxx_setup(PXA_PCMCIA_5V_MEM_ACCESS, clock)
		& MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT)
       | ((pxa_mcxx_asst(PXA_PCMCIA_5V_MEM_ACCESS, clock)
		& MCXX_ASST_MASK) << MCXX_ASST_SHIFT)
       | ((pxa_mcxx_hold(PXA_PCMCIA_5V_MEM_ACCESS, clock)
		& MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT);
MCIO0 = ((pxa_mcxx_setup(PXA_PCMCIA_IO_ACCESS, clock)
		& MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT)
       | ((pxa_mcxx_asst(PXA_PCMCIA_IO_ACCESS, clock)
		& MCXX_ASST_MASK) << MCXX_ASST_SHIFT)
       | ((pxa_mcxx_hold(PXA_PCMCIA_IO_ACCESS, clock)
		& MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT);
MCIO1 = ((pxa_mcxx_setup(PXA_PCMCIA_IO_ACCESS, clock)
		& MCXX_SETUP_MASK) << MCXX_SETUP_SHIFT)
       | ((pxa_mcxx_asst(PXA_PCMCIA_IO_ACCESS, clock)
		& MCXX_ASST_MASK) << MCXX_ASST_SHIFT)
       | ((pxa_mcxx_hold(PXA_PCMCIA_IO_ACCESS, clock)
		& MCXX_HOLD_MASK) << MCXX_HOLD_SHIFT);

#ifdef CONFIG_CPU_FREQ
  if(cpufreq_register_notifier(&pxa_pcmcia_notifier_block) < 0){
    printk(KERN_ERR "Unable to register CPU frequency change notifier\n");
    return -ENXIO;
  }
#endif

  /* Only advertise as many sockets as we can detect: */
  if(register_ss_entry(pxa_pcmcia_socket_count, 
		       &pxa_pcmcia_operations)<0){
    printk(KERN_ERR "Unable to register socket service routine\n");
    return -ENXIO;
  }

  /* Start the event poll timer.  It will reschedule by itself afterwards. */
  pxa_pcmcia_poll_event(0);

  DEBUG(1, "pxa_cs: initialization complete\n");

  return 0;

}  /* pxa_pcmcia_driver_init() */
Beispiel #19
0
/*----------------------------------------------------------------------------*/
static void
initTrig (void)
{
    set_GPIO_mode(GPIO40_FFDTR | GPIO_OUT);
    clearTrig();
}/* end of initTrig() */