Beispiel #1
0
static void get_gpio_settings(void)
{
	unsigned long pmc_ctrl;
	int i;
	int j;

	pmc_ctrl = readl(IO_ADDRESS(TEGRA_PMC_BASE));	
	printk(KERN_INFO "pICS_%s: pmc_ctrl = 0x%lX...\n",__func__,pmc_ctrl);
	
	for (i = 0; i < 7; i++) {
		for (j = 0; j < 4; j++) {
			int gpio = tegra_gpio_compose(i, j, 0);
			printk(KERN_INFO "pICS_%s: %d:%d %02x %02x %02x %02x %02x %02x %06x\n",__func__,
			       i, j,
			       __raw_readl(GPIO_CNF(gpio)),
			       __raw_readl(GPIO_OE(gpio)),
			       __raw_readl(GPIO_OUT(gpio)),
			       __raw_readl(GPIO_IN(gpio)),
			       __raw_readl(GPIO_INT_STA(gpio)),
			       __raw_readl(GPIO_INT_ENB(gpio)),
			       __raw_readl(GPIO_INT_LVL(gpio)));
		}
	}
}
Beispiel #2
0
static int xway_gpio_get(struct gpio_chip *chip, unsigned int pin)
{
	struct ltq_pinmux_info *info = dev_get_drvdata(chip->dev);

	return gpio_getbit(info->membase[0], GPIO_IN(pin), PORT_PIN(pin));
}
Beispiel #3
0
 */

GPIO_SignalType gpio_sleep_changes[] =
{
  /* GPIO 0-4 (keypad usage) configure to output low, but their functions
   * remain the same, so no change.
   */
  /* GPIO 5 through 9, (key sense usage), its function unchange, no change */
  /* GPIO10 (backlight usage)configure to output low, its function unchange */
  /* GPIO 11 (Headset det usage), no change */
  /* GPIO 12,14,15 (UIM usage) configure to input low, it can be featurized */
  /* GPIO 13 uses to enable bluetooth, and BT takes care it, in the case of
   * no BT, it configure to input, tlmm init function already take care it.
  */
  /* GPIO 20,21,22,23(AUX PCM usage) configure to input, pull down */
  GPIO_IN(20,GROUP_GPIO_0,GPIO_PULL_DOWN), // AUX_PCM_CLK
  GPIO_IN(21,GROUP_GPIO_0,GPIO_PULL_DOWN), // AUX_PCM_SYNC
  GPIO_IN(22,GROUP_GPIO_0,GPIO_PULL_DOWN), // AUX_PCM_DIN
  GPIO_IN(23,GROUP_GPIO_0,GPIO_PULL_DOWN), // AUX_PCM_OUT

#ifdef FEATURE_DRV_SDCC
  /* GPIO 24-29 (SDCC usage), card is not in */
#if 0
  GPIO_IN(24,GROUP_GPIO_0,GPIO_PULL_DOWN), // SDCC_CLK
  GPIO_IN(25,GROUP_GPIO_0,GPIO_PULL_DOWN), // SDCC_DATA[0]
  GPIO_IN(26,GROUP_GPIO_0,GPIO_PULL_DOWN), // SDCC_DATA[1]
  GPIO_IN(27,GROUP_GPIO_0,GPIO_PULL_DOWN), // SDCC_DATA[2]
  GPIO_IN(28,GROUP_GPIO_0,GPIO_PULL_DOWN), // SDCC_DATA[3]
  GPIO_IN(29,GROUP_GPIO_0,GPIO_PULL_DOWN), // SDCC_CMD
#endif										   // 
#endif
Beispiel #4
0
void trans_process(void)
{   // copy data from comm-port RX buffer to RF packet handler TX buffer, and from RF packet handler RX buffer to comm-port TX buffer

    // ********************
    // decide which comm-port we are using (usart or usb)

    bool usb_comms = false;						// TRUE if we are using the usb port for comms.
    uint32_t comm_port = PIOS_COM_SERIAL;		// default to using the usart comm-port

    #if defined(PIOS_INCLUDE_USB)
        if (PIOS_USB_CheckAvailable(0))
        {	// USB comms is up, use the USB comm-port instead of the USART comm-port
            usb_comms = true;
            comm_port = PIOS_COM_TELEM_USB;
        }
    #endif

    // ********************
    // check to see if the local communication port has changed (usart/usb)

    if (trans_previous_com_port == 0 && trans_previous_com_port != comm_port)
    {	// the local communications port has changed .. remove any data in the buffers
        trans_temp_buffer2_wr = 0;
    }
    else
	if (usb_comms)
	{	// we're using the USB for comms - keep the USART rx buffer empty
		uint8_t c;
		while (PIOS_COM_ReceiveBuffer(PIOS_COM_SERIAL, &c, 1, 0) > 0);
	}

	trans_previous_com_port = comm_port;			// remember the current comm-port we are using

	// ********************

	uint16_t connection_index = 0;					// the RF connection we are using

	// ********************
	// send the data received down the comm-port to the RF packet handler TX buffer

	if (saved_settings.mode == MODE_NORMAL || saved_settings.mode == MODE_STREAM_TX)
	{
		// free space size in the RF packet handler tx buffer
		uint16_t ph_num = ph_putData_free(connection_index);

		// set the USART RTS handshaking line
		if (!usb_comms)
		{
			if (ph_num < 32 || !ph_connected(connection_index))
				SERIAL_RTS_CLEAR;						// lower the USART RTS line - we don't have space in the buffer for anymore bytes
			else
				SERIAL_RTS_SET;							// release the USART RTS line - we have space in the buffer for now bytes
		}
		else
			SERIAL_RTS_SET;								// release the USART RTS line

		// limit number of bytes we will get to the size of the temp buffer
		if (ph_num > sizeof(trans_temp_buffer1))
			ph_num = sizeof(trans_temp_buffer1);

		// copy data received down the comm-port into our temp buffer
		register uint16_t bytes_saved = 0;
		bytes_saved = PIOS_COM_ReceiveBuffer(comm_port, trans_temp_buffer1, ph_num, 0);

		// put the received comm-port data bytes into the RF packet handler TX buffer
		if (bytes_saved > 0)
		{
			trans_rx_timer = 0;
			ph_putData(connection_index, trans_temp_buffer1, bytes_saved);
		}
	}
	else
	{	// empty the comm-ports rx buffer
		uint8_t c;
		while (PIOS_COM_ReceiveBuffer(comm_port, &c, 1, 0) > 0);
	}

	// ********************
	// send the data received via the RF link out the comm-port

	if (saved_settings.mode == MODE_NORMAL || saved_settings.mode == MODE_STREAM_RX)
	{
		if (trans_temp_buffer2_wr < sizeof(trans_temp_buffer2))
		{
			// get number of data bytes received via the RF link
			uint16_t ph_num = ph_getData_used(connection_index);

			// limit to how much space we have in the temp buffer
			if (ph_num > sizeof(trans_temp_buffer2) - trans_temp_buffer2_wr)
				ph_num = sizeof(trans_temp_buffer2) - trans_temp_buffer2_wr;

			if (ph_num > 0)
			{	// fetch the data bytes received via the RF link and save into our temp buffer
				ph_num = ph_getData(connection_index, trans_temp_buffer2 + trans_temp_buffer2_wr, ph_num);
				trans_temp_buffer2_wr += ph_num;
			}
		}

		#if (defined(PIOS_COM_DEBUG) && (PIOS_COM_DEBUG == PIOS_COM_SERIAL))
			if (!usb_comms)
			{	// the serial-port is being used for debugging - don't send data down it
				trans_temp_buffer2_wr = 0;
				trans_tx_timer = 0;
				return;
			}
		#endif

		if (trans_temp_buffer2_wr > 0)
		{	// we have data in our temp buffer that needs sending out the comm-port

			if (usb_comms || (!usb_comms && GPIO_IN(SERIAL_CTS_PIN)))
			{	// we are OK to send the data out the comm-port

				// send the data out the comm-port
				int32_t res = PIOS_COM_SendBufferNonBlocking(comm_port, trans_temp_buffer2, trans_temp_buffer2_wr);	// this one doesn't work properly with USB :(
				if (res >= 0)
				{	// data was sent out the comm-port OK .. remove the sent data from the temp buffer
					trans_temp_buffer2_wr = 0;
					trans_tx_timer = 0;
				}
				else
				{	// failed to send the data out the comm-port
					#if defined(TRANS_DEBUG)
						DEBUG_PRINTF("PIOS_COM_SendBuffer %d %d\r\n", trans_temp_buffer2_wr, res);
					#endif

					if (trans_tx_timer >= 5000)
						trans_temp_buffer2_wr = 0;	// seems we can't send our data for at least the last 5 seconds - delete it
				}
			}
		}
	}
	else
	{	// empty the buffer
		trans_temp_buffer2_wr = 0;
		trans_tx_timer = 0;
	}

	// ********************
}