OK335xS U-boot GPIO control hacking

简介: /**************************************************************************************** * OK335xS U-boot GPIO control hacking * 声明: * 本文主要是跟踪U-boot中如何设置GPIO口电平。
/****************************************************************************************
 *                           OK335xS U-boot GPIO control hacking
 * 声明:
 *     本文主要是跟踪U-boot中如何设置GPIO口电平。
 *
 *                                                  2015-9-26 晴 深圳 南山平山村 曾剑锋
 ***************************************************************************************/

cat board/forlinx/ok335x/evm.c                                                                      
int board_init(void)                                                                                
{                                                                                                   
    int c = 100;                                                                                    
    /* Configure the i2c0 pin mux */                                                                
    enable_i2c0_pin_mux();                                                                          
                                                                                                    
    i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);                                           
                                                                                                    
    board_id = GP_BOARD;                                                                            
    profile = 1;    /* profile 0 is internally considered as 1 */                                   
    daughter_board_connected = 1;                                                                   
                                                                                                    
    configure_evm_pin_mux(board_id, header.version, profile, daughter_board_connected); --+         
                                                                                          |         
    /**                                                                                   |         
      * 1. 参考资料:                                                                     |
      *   AM335x ARM Cortex-A8 Microprocessors (MPUs) Technical Reference Manual (Rev. H) |
      *                                                                                   |
      * 2. ARM Cortex-A8 Memory Map                                                       |
      *             Table 2-2. L4_WKUP Peripheral Memory Map (continued)                  |
      * +-------------+---------------------+-------------------+------+----------------+ |         
      * | Region Name | Start Address (hex) | End Address (hex) | Size | Description    | |         
      * +-------------+---------------------+-------------------+------+----------------+ |         
      * | GPIO0       | 0x44E0_7000         | 0x44E0_7FFF       | 4KB  | GPIO Registers | |         
      * +-------------+---------------------+-------------------+------+----------------+ |         
      *                                                                                   |         
      * 3. GPIO Registers(4068 页)                                                      |
      *                 Table 25-5. GPIO REGISTERS                                        |
      * +--------+-------------------+---------------+-------------------+                |         
      * | Offset | Acronym           | Register Name | Section           |                |         
      * +--------+-------------------+---------------+-------------------+                |         
      * | 134h   | GPIO_OE           |               | Section 25.4.1.16 |<-+             |         
      * +--------+-------------------+---------------+-------------------+  |             |         
      * | 190h   | GPIO_CLEARDATAOUT |               | Section 25.4.1.25 |  |<-+          |         
      * +--------+-------------------+---------------+-------------------+  |  |          |         
      * | 194h   | GPIO_SETDATAOUT   |               | Section 25.4.1.26 |  |  |<-+       |         
      * +--------+-------------------+---------------+-------------------+  |  |  |       |         
      */                                                                    |  |  |       |         
    /* set gpio0_7 gpio0_12 gpio0_22 gpio0_23 output mode */                |  |  |       |         
    __raw_writel(~((1<<7) | (1<<12) | (1<<22) |(1<<23)), 0x44E07134);-------+  |  |       |         
    /* set gpio0_7 12 19 23 low */                                             |  |       |         
    __raw_writel((1<<7) | (1<<19) | (1<<23), 0x44E07190);            ----------+  |       |         
    /* set gpio0_22 high to height */                                             |       |         
    __raw_writel( (1<<12) | (1<<22), 0x44E07194);                    -------------+       |         
                                                                                          |         
                                                                                          |         
#ifndef CONFIG_SPL_BUILD                                                                  |         
    board_evm_init();                                                                     |         
#endif                                                                                    |         
    gpmc_init();                                                                          |         
                                                                                          |         
    return 0;                                                                             |         
}               +-------------------------------------------------------------------------+         
                V                                                                                   
void configure_evm_pin_mux(unsigned char dghtr_brd_id, char version[4], unsigned short              
        profile, unsigned int daughter_board_flag)                                                  
{                                                                                                   
    if (dghtr_brd_id > BASE_BOARD)                                                                  
        return;                                                                                     
                                                                                                    
    set_evm_pin_mux(am335x_evm_pin_mux[0], profile,daughter_board_flag);                            
}                                 |                                                                 
                                  V                                                                 
static struct evm_pin_mux *am335x_evm_pin_mux[] = {                                                 
    general_purpose_evm_pin_mux,                      ----------------------+                       
};                                                                          |                       
                                                                            |                       
/*                                                                          |                       
 * Update the structure with the modules present in the general purpose     |                       
 * board and the profiles in which the modules are present.                 |                       
 * If the module is physically present but if it is not available           |                       
 * in any of the profile, then do not update it.                            |                       
 * For eg, nand is avialable only in the profiles 0 and 1, whereas          |                       
 * UART0  is available in all the profiles.                                 |                       
 */                                                                         |                       
static struct evm_pin_mux general_purpose_evm_pin_mux[] = {      <----------+                       
    {i2c1_pin_mux, PROFILE_ALL & ~PROFILE_2 & ~PROFILE_4, DEV_ON_BASEBOARD},                        
                                                                                                    
#ifdef CONFIG_NAND                                                                                  
    {nand_pin_mux, PROFILE_ALL & ~PROFILE_2 & ~PROFILE_3, DEV_ON_DGHTR_BRD},                        
#endif                                                                                              
                                                                                                    
#ifndef CONFIG_NO_ETH                                                                               
    {mii1_pin_mux, PROFILE_ALL, DEV_ON_BASEBOARD},                                                  
#endif                                                                                              
                                                                                                    
#ifdef CONFIG_MMC                                                                                   
    {mmc0_pin_mux, PROFILE_ALL, DEV_ON_BASEBOARD},                                                  
#endif                                                                                              
    {backlight_pin_mux, PROFILE_ALL, DEV_ON_BASEBOARD},           -----+                            
    {maxttl_model_pin_mux, PROFILE_ALL, DEV_ON_BASEBOARD},             |                            
    {lcd_pin_mux, PROFILE_ALL, DEV_ON_BASEBOARD},                      |                            
    {uart0_pin_mux, PROFILE_ALL, DEV_ON_BASEBOARD},                    |                            
    {0},                                                               |                            
};                                                                     |                            
                                                                       |                            
static struct module_pin_mux backlight_pin_mux[] = {              <----+                            
    {OFFSET(ecap0_in_pwm0_out), MODE(7) | PULLUP_EN | RXACTIVE}, /* GPIO0_7 */                      
    {OFFSET(uart1_ctsn), MODE(7) | PULLUDDIS | RXACTIVE},        /* GPIO0_ 12 */                    
    {-1},                                                                                           
};                                                                                                  

 

目录
相关文章
|
移动开发 Android开发
I.MX6 天嵌 E9 U-boot menu hacking
/************************************************************************************ * I.MX6 天嵌 E9 U-boot menu hacking * 说明: * 天嵌在U-boot中添加了自己的选择menu,想看一下怎么实现的。
954 0
|
Android开发
OK335xS dhcpcd porting
/********************************************************************** * OK335xS dhcpcd porting * 说明: * 之前在看Android源码的时候看到dhcpcd,但是busybox一直用的dhcpc, * 一般来说加了d都是后台运行的程序,也就意味着可能是可以做到动态获取 * DHCP IP了,当然目前没有测试,仅仅是先编译看一下效果,看是否会出问题。
1104 0
|
网络协议 缓存 索引
OK335xS Qt network hacking
/********************************************************************** * OK335xS Qt network hacking * 说明: * 应该半年前尝试过来解读这个程序,但是那时候对有些东西不是很理解, * 最后不了了之了,这次因为需要,所以重新对network的mainwindow.cpp进行 * 一下解读。
709 0
|
Linux Android开发
I.MX6 gpio-keys driver hacking
/**************************************************************************** * I.MX6 gpio-keys driver hacking * 说明: * 1. 本文解读gpio-keys驱动是如何注册,最终处理函数在哪里。
1144 0
I.MX6 U-boot PWM hacking
/******************************************************************************* * I.MX6 U-boot PWM hacking * 说明: * 本文主要记录I.MX6 U-boot是如何配置PWM,发现文中的pwm0对应的引脚和真正的 * 电路板的pwm0不是一个,也就意味着其实是引脚连接错了,另外之前一直有一个 * 疑问:为什么双屏显示的时候,有一个屏在U-boot阶段和Kernel阶段总是不亮。
1315 0
|
Linux
I.MX6 U-boot GPIO hacking
/******************************************************************************* * I.MX6 U-boot GPIO hacking * 说明: * 本文主要记录I.MX6 U-boot是如何设置GPIO口输入输出的,主要是考虑到这个阶段 * 并没有像Linux内核中的gpio_request一系列函数使用。
1081 0
|
Linux
OK335xS LAN8710 phy driver hacking
/******************************************************************** * OK335xS LAN8710 phy driver hacking * 说明: * 本文主要是对OK335xS中的phy的驱动进行代码跟踪,并解决当前遇到 * LAN8710上电后插入网线,会导致LAN8710无法自动握手,Link灯不亮,内核 * 也检测不到LAN8710有状态发生了改变,最终问题定位于LAN8710的驱动初 * 始化部分,本文解决办法选择注释掉对应的内容就行了。
1121 0
OK335xS davinci mdio driver hacking
/******************************************************************************* * OK335xS davinci mdio driver hacking * 说明: * 以前一直也想对网卡驱动的工作原理进行跟踪,这次正好有机会,先跟mdio接口部分 * 的代码。
824 0
|
Android开发 SoC
I.MX6 Power off register hacking
/*********************************************************************** * I.MX6 Power off register hacking * 声明: * 本文主要记录I.MX6DL中的Power off按键的注册过程。
690 0
|
Linux
OK335xS knob driver hacking
/************************************************************************* * OK335xS knob driver hacking * 说明: * 本文主要是为了分析knob设备的创建,驱动层如何注册,发送信息。
705 0