Confusion in Pad Configuration and GPIO Muxing


I am learning few linux system level conepts and working on some
hardware related things.I want to understand

How GPIO Muxing works?

What is pad configuration?

What is "bank" and its base for any pin?

When we change in u-boot MUX_VAL() what exactly we are chaning?

How GPIO and PAD conf is related?



You always work with CPU registers. Read TRM for omap3530 or similar

Thanks for replying.
It means PAD conf. includes configuration of those registers,but what
is muxing?
if i have some register banks ,how this register values are reflected
to a io pin?
To which bank a gpio belongs?For configuring gpio which register to
read/write?Where to check?
Can you help me in understanding below code?

#define SUCCESS 0

#define GPIO5_OE (*((volatile unsigned long
*)0x49056034)) // Output Data Enable Register (Table 24-27)
#define GPIO5_DATAOUT (*((volatile unsigned long
*)0x4905603C)) // Data Out register (Table 24-31)
#define LED1 0x00200000 // Bit 21
#define LED0 0x00400000 // Bit 22
#define CM_FCLKEN_PER (*((volatile unsigned long
*)0x48005000)) // Controls the modules functional clock activity.
(Table 4-237)
#define CM_ICLKEN_PER (*((volatile unsigned long
*)0x48005010)) // Controls the modules interface clock activity
(Table 4-239)
// SCM
#define CONTROL_PADCONF_UART1_TX (*((volatile unsigned long
*)0x4800217C)) // Pad configuration for GPIO_149 [31:16] (Tables 7-4
& 7-74)
#define CONTROL_PADCONF_UART1_CTS (*((volatile unsigned long
*)0x48002180)) // Pad configuration for GPIO_150 [15:0] (Tables 7-4
& 7-74)
#define SZ_4K 0x00001000

long int i;
  long int j;
   printk("LED Driver Initialized\n");

   (*gpio_149) &= 0x0000FFFF;
   (*gpio_149) |= 0x00040000;
   (*gpio_150) &= 0xFFFF0000;
   (*gpio_150) |= 0x00000004;

  // Switch on the Interface and functional clocks to the GPIO5 module
*fclken |= 0x20; // Enable GPIO5 F clock
*iclken |= 0x20; // Enable GPIO5 I clock

  // Configure the GPIO signals
  *output_enable &= ~(LED1+LED0); // Set GPIO_149 & GPIO_150
(GPIO 4 bit 2) to output
  *dataout |= LED0; // Set GPIO_150 high
  *dataout &= ~LED1; // Set GPIO_149 low

  // Hello world!
printk("Before DATAOUT------------------\n");
   for (i=0; i<0x10000000; i++) {
    printk("...............In delay.................\n");
  printk(".................Toggling led ............\n");
      *dataout ^= LED0; // Toggle GPIO_150
      *dataout ^= LED1; // Toggle GPIO_149