GPIO Interface on u-boot

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

GPIO Interface on u-boot

9,512 次查看
divyardharan
Contributor III

Hi,

We have configured the GPIO in kernel to read switch status and light LED.Kindly help me with suggestions to configure the same in u boot.We are using sabresd imx6q board.

Thanks in advance,

Divya

0 项奖励
回复
3 回复数

3,276 次查看
KursadOney
NXP Employee
NXP Employee

1. Set iomuxing for your gpio. Your board.c file should already have some iomux examples.

2. Use the u-boot gpio api: http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/gpio/mxc_gpio.c;h=815407bb03eecac7c4e8c300a1355d87...

3,276 次查看
divyardharan
Contributor III

Hi Kursad,

Thank you for your reply. We are using the u-boot gpio api . I need to configure the gpio163 as out and need to set value for it. Kindly let me know what modifications are needed in u-boot source code. Please find the beagle.c file.

board/beagle.c


#include <common.h>
#include <twl4030.h>
#include <asm/io.h>
#include <asm/arch/mux.h>
#include <asm/arch/sys_proto.h>
#include <asm/arch/gpio.h>
#include <asm/mach-types.h>
#include "beagle.h"

static int beagle_revision_c;

/*
* Routine: board_init
* Description: Early hardware init.
*/
int board_init(void)
{
DECLARE_GLOBAL_DATA_PTR;

gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
/* board id for Linux */
gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
/* boot param addr */
gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);

return 0;
}

/*
* Routine: beagle_get_revision
* Description: Return the revision of the BeagleBoard this code is running on.
*              If it is a revision Ax/Bx board, this function returns 0,
*              on a revision C board you will get a 1.
*/
int beagle_get_revision(void)
{
return beagle_revision_c;
}

/*
* Routine: beagle_identify
* Description: Detect if we are running on a Beagle revision Ax/Bx or
*              Cx. This can be done by GPIO_171. If this is low, we are
*              running on a revision C board.
*/
void beagle_identify(void)
{
beagle_revision_c = 0;
if (!omap_request_gpio(171)) {
  unsigned int val;

  omap_set_gpio_direction(171, 1);
  val = omap_get_gpio_datain(171);
  omap_free_gpio(171);

  if (val)
   beagle_revision_c = 0;
  else
   beagle_revision_c = 1;
}

printf("Board revision ");
if (beagle_revision_c)
  printf("C\n");
else
  printf("Ax/Bx\n");
}

/*
* Routine: misc_init_r
* Description: Configure board specific parts
*/
int misc_init_r(void)
{
struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;

twl4030_power_init();
twl4030_led_init();

/* Configure GPIOs to output */
writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
  GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);

/* Set GPIOs */
writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
  &gpio6_base->setdataout);
writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
  GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);

beagle_identify();

dieid_num_r();

return 0;
}

/*
* Routine: set_muxconf_regs
* Description: Setting up the configuration Mux registers specific to the
*  hardware. Many pins need to be moved from protect to primary
*  mode.
*/
void set_muxconf_regs(void)
{
MUX_BEAGLE();

if (beagle_revision_c) {
  MUX_BEAGLE_C();
}
}

Thanks,

Divya

0 项奖励
回复

3,276 次查看
saurabh206
Senior Contributor III

Hi Divya,

Please refer

board\freescale\mx6qsabresd\mx6qsabresd.c

Make modification for your GPIO according to setup_iomux_enet().

I hope this will help.

Saurabh

0 项奖励
回复