OK335xS U-boot GPIO control hacking

/****************************************************************************************
 *                           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},
};                                                                                                  

 

时间: 2024-10-11 16:32:13

OK335xS U-boot GPIO control hacking的相关文章

OK335xS GPMC nand device register hacking

/********************************************************************************* * OK335xS GPMC nand device register hacking * 说明: * 由于最近遇到No NAND device found这个内核错误,在网络上也没找到很好的 * 解决办法,于是只能自己去跟踪整个设备.驱动的注册流程,试着去理解整个系统 * 的运作流程. * * 2015-9-2 雨 深圳 南山平山

OK335xS pwm buzzer Linux driver hacking

/**************************************************************************** * OK335xS pwm buzzer Linux driver hacking * 声明: * 本文仅仅是为了知道如何使用pwm来控制buzzer,已达到控制不同声音的频率. * * 2015-10-7 雨 深圳 南山平山村 曾剑锋 *****************************************************

OK335xS 网络连接打印信息 hacking

/*********************************************************************** * OK335xS 网络连接打印信息 hacking * 说明: * 当我们插入网线的时候,经常会看到对应的网卡已连接,当前属于10M. * 100M网卡工作状态等等信息,那么这些信息是如何被输出的,工作机制是什么, * 网卡的速度是由phy决定的还是由mac决定的,是不是在phy对应的中断里处理, * 等等,这些内容都需要去确认. * * 2016-

hacking a friend&amp;#39;s Linux buzzer driver in OK335xS

1 /**************************************************************************** 2 * hacking a friend's Linux buzzer driver in OK335xS 3 * 说明: 4 * 解读朋友的Linux buzzer驱动,作为后续相关编码的参考. 5 * 6 * 2015-8-25 晴 深圳 南山平山村 曾剑锋 7 ************************************

OK335xS knob driver hacking

/************************************************************************* * OK335xS knob driver hacking * 说明: * 本文主要是为了分析knob设备的创建,驱动层如何注册,发送信息. * * 2015-11-18 晴 深圳 南山平山村 曾剑锋 ************************************************************************/

OK335xS mac address hacking

/*********************************************************************** * OK335xS mac address hacking * 声明: * 在一般的嵌入式产品中,一般mac地址都是存在于CPU芯片中,不过有时候 * 我们也许会表示怀疑,因为我们可能更希望知道那些东西到底存在哪里,以一 * 种什么样的形式存在. * * 2016-2-1 深圳 南山平山村 曾剑锋 ***************************

OK335xS UART device registe hacking

/************************************************************************* * OK335xS UART device registe hacking * 声明: * 1. 本文是对OK335xS Linux内核中UART设备注册代码进行跟踪: * 2. 本人在文中采用函数调用线路图进行标记,方便阅读: * 3. 代码跟踪的用的是vim+ctags: * * 2015-6-30 晴 深圳 南山平山村 曾剑锋 *******

OK335xS LAN8710 phy driver hacking

/******************************************************************** * OK335xS LAN8710 phy driver hacking * 说明: * 本文主要是对OK335xS中的phy的驱动进行代码跟踪,并解决当前遇到 * LAN8710上电后插入网线,会导致LAN8710无法自动握手,Link灯不亮,内核 * 也检测不到LAN8710有状态发生了改变,最终问题定位于LAN8710的驱动初 * 始化部分,本文解决办

OK335xS 256M 512M nand flash make ubifs hacking

/********************************************************************************* * OK335xs 256M 512M nand flash make ubifs hacking * 声明: * 本文主要是记录分析如何生成ubifs文件系统. * * 2015-11-14 晴 深圳 南山平山村 曾剑锋 *******************************************************