Example #1
0
bool
trk::
DemuxAddress::set(int sw_num, SW_DIRECTION& sw_direc)
{
    if ( sw_num < 0 || sw_num > 4|| sw_direc == NOVAL) return false;

    int line_index = sw_num * 2 + sw_direc;
    std::bitset<8 * sizeof(int)> b = line_index;
    gpios_[4]->value(HIGH);
    gpios_[0]->value( GPIO_VALUE( (int)b[0] ));
    gpios_[1]->value( GPIO_VALUE( (int)b[1] ));
    gpios_[2]->value( GPIO_VALUE( (int)b[2] ));
    gpios_[3]->value( GPIO_VALUE( (int)b[3] ));
    gpios_[4]->value(LOW);

    usleep(50000);
    gpios_[4]->value(HIGH);
    return true;
}
Example #2
0
bool mmc_present (void)
{
  uint8_t present = 0;
  int i;
  mmc_cd_gpio (true);
  for (i = 0; i < 8; ++i)
    present = (present << 1) | (GPIO_VALUE (PIN_SDHC1_CD) ? 0 : 1);

  mmc_cd_gpio (false);

  return present == (uint8_t) ~0;
}
Example #3
0
	LCD_VSYNC | STRENGTH(S12MA), /* PIN21/LCD_HSYNC/I2C_SDA- GPIO PIN 10*/
	LCD_HSYNC | STRENGTH(S12MA),     /* PIN20/LCD_VSYNC    - GPIO PIN  8*/
	LCD_DOTCLOCK | STRENGTH(S12MA),  /* PIN19/LCD_DOTCLK   - GPIO PIN  6*/


	/* SD card interface */
	SSP1_DATA0 | PULLUP(1),
	SSP1_DATA1 | PULLUP(1),
	SSP1_DATA2 | PULLUP(1),
	SSP1_DATA3 | PULLUP(1),
	SSP1_SCK,
	SSP1_CMD | PULLUP(1),
	SSP1_DETECT | PULLUP(1),

	/* led */
	SSP1_DETECT_GPIO | GPIO_OUT | GPIO_VALUE(1),

	/* gpio - USB hub LAN9512-JZX*/
	GPMI_ALE_GPIO | GPIO_OUT | GPIO_VALUE(1),
};

static int imx23_olinuxino_mem_init(void)
{
	arm_add_mem_device("ram0", IMX_MEMORY_BASE, 64 * 1024 * 1024);

	return 0;
}
mem_initcall(imx23_olinuxino_mem_init);

static void olinuxino_init_usb(void)
{
Example #4
0
	GPMI_CLE | VE_3_3V | PULLUP(1),
	GPMI_RESETN | VE_3_3V | PULLUP(0),	/* external PU */

	/* Network interface */

	/*
	 * Note: To setup the external phy in a manner the baseboard
	 * supports, its configuration is divided into a small part here in
	 * the CPU card setup and the remaining configuration in the baseboard
	 * file.
	 * Here: Switch on the power supply to the external phy, but keep its
	 * reset line low.
	 */

	/* send a "good morning" to the ext. phy 0 = reset */
	ENET0_RX_CLK_GPIO | VE_3_3V | PULLUP(0) | GPIO_OUT | GPIO_VALUE(0),

	/* phy power control 1 = on */
	PWM4_GPIO | VE_3_3V | GPIO_OUT | PULLUP(0) | GPIO_VALUE(1),

	ENET_CLK | VE_3_3V | BITKEEPER(0),
	ENET0_MDC | VE_3_3V | PULLUP(0),
	ENET0_MDIO | VE_3_3V | PULLUP(0),
	ENET0_TXD0 | VE_3_3V | PULLUP(0),
	ENET0_TXD1 | VE_3_3V | PULLUP(0),
	ENET0_TX_EN | VE_3_3V | PULLUP(0),
	ENET0_TX_CLK | VE_3_3V | BITKEEPER(0),

};

extern void base_board_init(void);
Example #5
0
	FUNC(2) | PORTF(3, 3) | VE_3_3V,

	/* mmc0 */
	SSP0_D0 | VE_3_3V | PULLUP(1),
	SSP0_D1 | VE_3_3V | PULLUP(1),
	SSP0_D2 | VE_3_3V | PULLUP(1),
	SSP0_D3 | VE_3_3V | PULLUP(1),
	SSP0_D4 | VE_3_3V | PULLUP(1),
	SSP0_D5 | VE_3_3V | PULLUP(1),
	SSP0_D6 | VE_3_3V | PULLUP(1),
	SSP0_D7 | VE_3_3V | PULLUP(1),
	SSP0_CMD | VE_3_3V | PULLUP(1),
	SSP0_CD | VE_3_3V | PULLUP(1),
	SSP0_SCK | VE_3_3V | BITKEEPER(0),
	/* MCI slot power control 1 = off */
	PWM3_GPIO | VE_3_3V | GPIO_OUT | GPIO_VALUE(0),
};

static struct mxs_mci_platform_data mci_pdata = {
	.caps = MMC_MODE_8BIT,
	.voltages = MMC_VDD_32_33 | MMC_VDD_33_34,	/* fixed to 3.3 V */
	.f_min = 400 * 1000,
	.f_max = 25000000,
};

static int cfa10036_mem_init(void)
{
	arm_add_mem_device("ram0", IMX_MEMORY_BASE, 128 * 1024 * 1024);

	return 0;
}
Example #6
0
	PWM0_DUART_RX | VE_3_3V,
	PWM1_DUART_TX | VE_3_3V,

	/* fec0 */
	ENET_CLK | VE_3_3V | BITKEEPER(0),
	ENET0_MDC | VE_3_3V | PULLUP(1),
	ENET0_MDIO | VE_3_3V | PULLUP(1),
	ENET0_TXD0 | VE_3_3V | PULLUP(1),
	ENET0_TXD1 | VE_3_3V | PULLUP(1),
	ENET0_TX_EN | VE_3_3V | PULLUP(1),
	ENET0_TX_CLK | VE_3_3V | BITKEEPER(0),
	ENET0_RXD0 | VE_3_3V | PULLUP(1),
	ENET0_RXD1 | VE_3_3V | PULLUP(1),
	ENET0_RX_EN | VE_3_3V | PULLUP(1),
	/* send a "good morning" to the ext. phy 0 = reset */
	ENET0_RX_CLK_GPIO | VE_3_3V | PULLUP(0) | GPIO_OUT | GPIO_VALUE(0),
	/* phy power control 1 = on */
	SSP1_D3_GPIO | VE_3_3V | PULLUP(0) | GPIO_OUT | GPIO_VALUE(0),

	/* mmc0 */
	SSP0_D0 | VE_3_3V | PULLUP(1),
	SSP0_D1 | VE_3_3V | PULLUP(1),
	SSP0_D2 | VE_3_3V | PULLUP(1),
	SSP0_D3 | VE_3_3V | PULLUP(1),
	SSP0_D4 | VE_3_3V | PULLUP(1),
	SSP0_D5 | VE_3_3V | PULLUP(1),
	SSP0_D6 | VE_3_3V | PULLUP(1),
	SSP0_D7 | VE_3_3V | PULLUP(1),
	SSP0_CMD | VE_3_3V | PULLUP(1),
	SSP0_CD | VE_3_3V | PULLUP(1),
	SSP0_SCK | VE_3_3V | BITKEEPER(0),
Example #7
0
int
main ( int argc, char **argv )
{
    int                 result;
    int                 period, half_period, half_period2;
    uint32_t volatile * gpio_base = 0;

    /* Retreive the mapped GPIO memory. */
    result = setup_gpio_mmap ( &gpio_base );

    if ( result < 0 ) {
        printf ( "-- error: cannot setup mapped GPIO.\n" );
        exit ( 1 );
    }

    period = 1000; /* default = 1Hz */
    if ( argc > 1 ) {
        period = atoi ( argv[1] );
    }
    half_period = set_frequency(1000);
    half_period2 = set_frequency(500);

    /* Setup GPIO of LED0 to output. */
    GPIO_CONF_AS_OUTPUT ( gpio_base, GPIO_LED0 );
    GPIO_CONF_AS_OUTPUT ( gpio_base, GPIO_LED1 );

	 GPIO_CONF_AS_INPUT ( gpio_base, GPIO_BTN0 );

    printf ( "-- info: start blinking.\n" );

    /* Blink led at frequency of 1Hz. */

    while (1) {
        /*GPIO_SET ( gpio_base, GPIO_LED0 );
	GPIO_SET ( gpio_base, GPIO_LED1 );
 	delay ( half_period );
	 
	GPIO_CLR ( gpio_base, GPIO_LED0 );
	delay ( half_period2 );
	GPIO_CLR ( gpio_base, GPIO_LED1 );
       	delay ( half_period2 );*/


	if(GPIO_VALUE( gpio_base, GPIO_BTN0 )==0)
	{

		GPIO_SET ( gpio_base, GPIO_LED0 );
		GPIO_SET ( gpio_base, GPIO_LED1 );
	 	delay ( half_period );
		 
		GPIO_CLR ( gpio_base, GPIO_LED0 );
		delay ( half_period2 );
		GPIO_CLR ( gpio_base, GPIO_LED1 );
	       	delay ( half_period2 );

	}


    }
    return 0;
}
Example #8
0
static int
GPIO_init(GPIO *self, PyObject *args, PyObject *kwds)
{
	int fd = -1;
	int gpio = -1;
	
	PyObject * direction = NULL;
	PyObject * trigger = NULL;
	PyObject * tmp = NULL;

	static char *kwlist[] = { "gpio", "direction", "trigger", NULL };

	if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|OO:__init__",
			kwlist, &gpio, &direction, &trigger ) )
		return -1;

	if (gpio < 0)
		return -1;

	self->gpio = gpio;

	GPIO_VALUE( gpio, self->v_path );
	if ( ( fd = open( self->v_path, O_RDWR, 0 ) ) == -1 ) {
		// try to get gpio exported:
		if ( exportGpio( gpio ) == 0 ) {
			// check if export was (really) successful
			
			if ( ( fd = open( self->v_path, O_RDWR ) ) == -1) {
				// export failed
				PyErr_SetFromErrno( PyExc_IOError );
				return -1;
			}
		} else {
			PyErr_SetString( PyExc_StandardError,
				"Export failed." );
			return -1;
		}
	}

	GPIO_EDGE(gpio, self->e_path);
	GPIO_DIREC(gpio, self->d_path);

	self->fd_val = fd;
	if ( ( self->fd_dir = open( self->d_path, O_RDWR ) ) == -1 ) {
		return -1;
	}

	if ( ( self->fd_edge = open( self->e_path, O_RDWR ) ) == -1 ) {
		return -1;
	}

	if (direction) {
		setDirection( self, direction );
		tmp = self->direction;
		Py_INCREF(direction);
		self->direction = direction;
		Py_XDECREF(tmp);
	} else {
		// no direction requested, use current
		Py_XDECREF(self->direction);
		self->direction = getDirection( self );
		Py_INCREF(self->direction);
	}

	if (trigger) {
		setTrigger( self, trigger );
		tmp = self->trigger;
		Py_INCREF(trigger);
		self->trigger = trigger;
		Py_XDECREF(tmp);
	} else {
		// no trigger requested, use current
		Py_XDECREF(self->trigger);
		self->trigger = getTrigger( self );
		Py_INCREF(self->trigger);
	}

	return 0;
}
Example #9
0
	.enable = tx28_fb_enable,
};

static const uint32_t tx28_starterkit_pad_setup[] = {
	/*
	 * Part II of phy's initialization
	 * Setup phy's mode to '111'
	 */

	/*
	 * force the mod pins to a specific level
	 * '111' means: "All capable. Auto-negotiation enabled".
	 * For other values refer LAN8710's datasheet,
	 * chapter "Mode Bus - MODE[2:0]"
	 */
	ENET0_RXD0_GPIO | VE_3_3V | GPIO_OUT | GPIO_VALUE(1), /* MOD0 */
	ENET0_RXD1_GPIO | VE_3_3V | GPIO_OUT | GPIO_VALUE(1), /* MOD1 */
	ENET0_RX_EN_GPIO | VE_3_3V | GPIO_OUT | GPIO_VALUE(1), /* MOD2 */

	/* release the reset ('mod' pins get latched) */
	ENET0_RX_CLK_GPIO | VE_3_3V | BITKEEPER(0) | GPIO_OUT | GPIO_VALUE(1),

	/* right now the 'mod' pins are in their native mode */
	ENET0_RXD0 | VE_3_3V | PULLUP(0),
	ENET0_RXD1 | VE_3_3V | PULLUP(0),
	ENET0_RX_EN | VE_3_3V | PULLUP(0),

	/* Debug UART, available at card connector UART1 */
	AUART0_CTS_DUART_RX | VE_3_3V | STRENGTH(S8MA),
	AUART0_RTS_DUART_TX | VE_3_3V | STRENGTH(S8MA),
	AUART0_RX_DUART_CTS | VE_3_3V | STRENGTH(S8MA),
Example #10
0
uint32 exModeMDIORead(uint32 reg){
	uint32 data = 0;
	uint8 i;
	uint8 Addr[32]={0};
	uint8 Data[32]={0};
	uint8 temp1[32]={0};
	//uint8 temp2[32]={0};
	uint8 mdio_signal_real[116*2] ={0};

	uint8 mdio_signal[116]={
		1,1,1,1,0,1,1,0,	//PRE  ST  OP
		1,1,				//ADDR 2bit
		1,0,1,1,1,1,1,1,
		1,0,1,1,0,1,0,1,
		0,0,0,0,1,0,0,0,
		0,0,0,0,0,0,0,0,	//ADDR  32bit  //0xbfb50800  //0xbfb50a00
		1,0, 				//TA
		0,0,0,0,0,0,0,1, 	//byte-enable  DATA 8bit

		0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,

		0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,
		0,0,0,0,0,0,0,0,
		1,0,1,1,0,1,0,0,	//byte-enable  DATA 64bit
	};

	uint8 mdc_signal[116*2+16]={
		1,0,1,0,1,0,1,0, 	//PRE  ST  OP
		1,0,				//ADDR 2bit
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,	//ADDR  32bit
		1,0, 				//TA
		1,0,1,0,1,0,1,0,	//byte-enable  DATA 8bit
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,	//byte-enable  DATA 64bit

		1,0,1,0,1,0,1,0, 	//PRE  ST  OP
		1,0,				//ADDR 2bit
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,	//ADDR  32bit
		1,0, 				//TA
		1,0,1,0,1,0,1,0,	//byte-enable  DATA 8bit
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,	//byte-enable  DATA 64bit

		1,0,1,0,1,0,1,0,
		1,0,1,0,1,0,1,0,
	};
#ifdef DBG
	printk("%s(%d)Entry \n",__func__,__LINE__);
#endif

	if((reg>=0x7)&&(reg<=0xff))//contril register space
	{
		mdio_signal[8]=0;
		mdio_signal[9]=0;
	}
	else if(((reg&0xf)==0x0)||((reg&0xf)==0x8))  //high 32bit  addr bit[33:32] = 0x10
	{
		mdio_signal[8]=1;
		mdio_signal[9]=0;
		reg=reg-0xa0000000;//for 0xb4000000 ->0x14000000
	}
	else if(((reg&0xf)==0x4)||((reg&0xf)==0xc))//low 32bit  addr bit[33:32] = 0x01
	{
		mdio_signal[8]=0;
		mdio_signal[9]=1;
		reg=reg-0xa0000000;//for 0xb4000000 ->0x14000000
	}


	word2Bit(reg,temp1);


	for(i=0;i<32;i++)
	{
		Addr[i]=temp1[31-i];
	//	Data[i]=temp2[31-i];
		//printf("reg[%d]  = %d\r\n", i, Addr[i]);
		//printf("data[%d]  = %d\r\n", i, Data[i]);
	}

	for(i=10;i<42;i++)
	{
		mdio_signal[i]=Addr[i-10];

	}

	for (i=0;i<42;i++)
	{
		mdio_signal_real[i*2]=mdio_signal[i];
		mdio_signal_real[i*2+1]=mdio_signal[i];
		//printf("mdio_signal0[%d]  = %d\r\n", i, mdio_signal[i]);
	}

	HwGpioSetMode(MDIO_WRITE);//write
	//GPIO_HIGH(mdio_gpio);//let MDIO can be push by MDC
	//delayDmtSymbols(1);

	for (i=0;i<116*2+16;i++)
	{
		//printk("mdiod:%d ",mdio_signal_real[i]);
		//if(i % 10 == 0)
		//	printk("\n");
		if(i<42*2)
		{
			if (mdc_signal[i] ==0)
			{
				GPIO_LOW(mdc_gpio);
				//delayDmtSymbols(1);
			}
			else if (mdc_signal[i] ==1)
			{
				GPIO_HIGH(mdc_gpio);
				//delayDmtSymbols(1);
			}

			if (mdio_signal_real[i] ==0)
			{
				GPIO_LOW(mdio_gpio);
				//delayDmtSymbols(1);
			}
			else if (mdio_signal_real[i] ==1)
			{
				GPIO_HIGH(mdio_gpio);
				//delayDmtSymbols(1);
			}
		}
		else if (i==42*2)
		{
			if (mdc_signal[i] ==0)
			{
				GPIO_LOW(mdc_gpio);
				//delayDmtSymbols(1);
			}
			else if (mdc_signal[i] ==1)
			{
				GPIO_HIGH(mdc_gpio);
				//delayDmtSymbols(1);
			}

			//delayDmtSymbols(2);
			HwGpioSetMode(MDIO_READ);//read
		}
		else
		{
			//delayDmtSymbols(1);
			if (mdc_signal[i] ==0)
			{
				GPIO_LOW(mdc_gpio);
				//delayDmtSymbols(1);
			}
			else if (mdc_signal[i] ==1)
			{
				GPIO_HIGH(mdc_gpio);
				//delayDmtSymbols(1);
				if((i>42*2)&&(i<116*2+2))
				{
					mdio_signal_real[i-2] = GPIO_VALUE(mdio_gpio);
				}
			}

		}
	}

	for (i=0;i<116;i++)
	{
		mdio_signal[i]=mdio_signal_real[i*2];
		//printf("mdio_signal1[%d]  = %d\r\n", i, mdio_signal[i]);
	}
// get data from mdio_signal
	for(i=0;i<32;i++)
	{
		if((reg>=0x7)&&(reg<=0xff))//contril register space //data low 32bit
		{
			Data[i]=mdio_signal[i+84];
		}
		else if(((reg&0xf)==0x0)||((reg&0xf)==0x8))  //high 32bit  addr bit[33:32] = 0x10
		{
			Data[i]=mdio_signal[i+52];
		}
		else if(((reg&0xf)==0x4)||((reg&0xf)==0xc))//low 32bit  addr bit[33:32] = 0x01
		{
			Data[i]=mdio_signal[i+84];
		}
		//printf("Data[%d]  = %d\r\n", i, Data[i]);
	}
	data=bit2Word(Data);
#ifdef DBG
	printk("%s(%d)Exit \n",__func__,__LINE__);
#endif
	return data;

}
Example #11
0
	LCD_D9 | STRENGTH(S12MA),
	LCD_D8 | STRENGTH(S12MA),
	LCD_D7 | STRENGTH(S12MA),
	LCD_D6 | STRENGTH(S12MA),
	LCD_D5 | STRENGTH(S12MA),
	LCD_D4 | STRENGTH(S12MA),
	LCD_D3 | STRENGTH(S12MA),
	LCD_D2 | STRENGTH(S12MA),
	LCD_D1 | STRENGTH(S12MA),
	LCD_D0 | STRENGTH(S12MA),

	/* LCD usage currently unknown */
	LCD_CS,	/* used as SPI SS */
	LCD_RS,	/* used as SPI CLK */
	/* keep the display in reset state */
	LCD_RESET_GPIO | STRENGTH(S4MA) | GPIO_OUT | GPIO_VALUE(0),
	LCD_WR,	/* used as SPI MOSI */

	/* I2C to the MMA7455L, KXTE9, AT24C08 (DCID), AT24C128B (ID EEPROM) and QN8005B */
	I2C_SDA,
	I2C_CLK,

	/* Rotary decoder (external pull ups) */
	ROTARYA,
	ROTARYB,

	/* the chumby bend (external pull up) */
	PWM4_GPIO | GPIO_IN,

	/* backlight control, to be controled by PWM, here we only want to disable it */
	PWM2_GPIO | GPIO_OUT | GPIO_VALUE(0),	/* 1 enables, 0 disables the backlight */