arch/arm/src/am335x and boards/arm/am335x/beaglebone-black: Add I2C support for AM335X.
This commit is contained in:
parent
425b1c737c
commit
813902cf87
@ -133,16 +133,8 @@ config AM335X_MMC2
|
||||
bool "MMC/SD/SDIO0 High Speed Host Controller 2"
|
||||
default n
|
||||
|
||||
config AM335X_I2C0
|
||||
bool "Multi-master I2C Controller 0"
|
||||
default n
|
||||
|
||||
config AM335X_I2C1
|
||||
bool "Multi-master I2C Controller 1"
|
||||
default n
|
||||
|
||||
config AM335X_I2C2
|
||||
bool "Multi-master I2C Controller 2"
|
||||
config AM335X_I2C
|
||||
bool
|
||||
default n
|
||||
|
||||
config AM335X_MCASP0
|
||||
@ -360,4 +352,24 @@ config AM335X_LCDC_PIXCLK_INVERT
|
||||
default y
|
||||
|
||||
endmenu # LCD Configuration
|
||||
|
||||
menu "I2C Peripherals"
|
||||
|
||||
menuconfig AM335X_I2C0
|
||||
bool "Multi-master I2C Controller 0"
|
||||
default n
|
||||
select AM335X_I2C
|
||||
|
||||
menuconfig AM335X_I2C1
|
||||
bool "Multi-master I2C Controller 1"
|
||||
default n
|
||||
select AM335X_I2C
|
||||
|
||||
menuconfig AM335X_I2C2
|
||||
bool "Multi-master I2C Controller 2"
|
||||
default n
|
||||
select AM335X_I2C
|
||||
|
||||
endmenu # I2C Peripherals
|
||||
|
||||
endif # ARCH_CHIP_AM335X
|
||||
|
@ -139,3 +139,7 @@ endif
|
||||
ifeq ($(CONFIG_AM335X_LCDC),y)
|
||||
CHIP_CSRCS += am335x_lcdc.c am335x_edid.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_AM335X_I2C),y)
|
||||
CHIP_CSRCS += am335x_i2c.c
|
||||
endif
|
||||
|
@ -313,7 +313,6 @@ static int am335x_gpio_configinput(gpio_pinset_t pinset)
|
||||
|
||||
/* Configure pin pad settings */
|
||||
|
||||
index = ((pinset & GPIO_PADCTL_MASK) >> GPIO_PADCTL_SHIFT);
|
||||
regaddr = AM335X_PADCTL_ADDRESS(index);
|
||||
muxset = (pinmux_pinset_t)((pinset & GPIO_PINMUX_MASK) >> GPIO_PINMUX_SHIFT);
|
||||
return am335x_pinmux_configure(regaddr, muxset);
|
||||
@ -462,3 +461,36 @@ bool am335x_gpio_read(gpio_pinset_t pinset)
|
||||
leave_critical_section(flags);
|
||||
return value;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: am335x_periph_gpio
|
||||
*
|
||||
* Description:
|
||||
* Return GPIO pinset that correspond to provided peripheral pinset.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
gpio_pinset_t am335x_periph_gpio(gpio_pinset_t pinset)
|
||||
{
|
||||
unsigned int index;
|
||||
int port;
|
||||
int pin;
|
||||
|
||||
if ((pinset & GPIO_MODE_MASK) == GPIO_PERIPH)
|
||||
{
|
||||
index = ((pinset & GPIO_PADCTL_MASK) >> GPIO_PADCTL_SHIFT);
|
||||
for (port = 0; port < AM335X_GPIO_NPORTS; port++)
|
||||
{
|
||||
for (pin = 0; pin < AM335X_GPIO_NPINS; pin++)
|
||||
{
|
||||
if (index == g_gpio_padctl[port][pin])
|
||||
{
|
||||
return (GPIO_INPUT | (port << GPIO_PORT_SHIFT) |
|
||||
(pin << GPIO_PIN_SHIFT));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return GPIO_MODE_MASK;
|
||||
}
|
||||
|
@ -300,6 +300,16 @@ int am335x_dump_gpio(uint32_t pinset, const char *msg);
|
||||
# define am335x_dump_gpio(p,m)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Function: am335x_periph_gpio
|
||||
*
|
||||
* Description:
|
||||
* Return GPIO pinset that correspond to provided peripheral pinset.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
gpio_pinset_t am335x_periph_gpio(gpio_pinset_t pinset);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
1726
arch/arm/src/am335x/am335x_i2c.c
Normal file
1726
arch/arm/src/am335x/am335x_i2c.c
Normal file
File diff suppressed because it is too large
Load Diff
86
arch/arm/src/am335x/am335x_i2c.h
Normal file
86
arch/arm/src/am335x/am335x_i2c.h
Normal file
@ -0,0 +1,86 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/am335x/am335x_i2c.h
|
||||
*
|
||||
* Copyright (C) 2019 Petro Karashchenko. All rights reserved.
|
||||
* Author: Petro Karashchenko <petro.karashchenko@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_AM335X_AM335X_I2C_H
|
||||
#define __ARCH_ARM_SRC_AM335X_AM335X_I2C_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: am335x_i2cbus_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the selected I2C port. And return a unique instance of struct
|
||||
* struct i2c_master_s. This function may be called to obtain multiple
|
||||
* instances of the interface, each of which may be set up with a
|
||||
* different frequency and slave address.
|
||||
*
|
||||
* Input Parameters:
|
||||
* Port number (for hardware that has multiple I2C interfaces)
|
||||
*
|
||||
* Returned Value:
|
||||
* Valid I2C device structure reference on success; a NULL on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct i2c_master_s *am335x_i2cbus_initialize(int port);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: am335x_i2cbus_uninitialize
|
||||
*
|
||||
* Description:
|
||||
* De-initialize the selected I2C port, and power down the device.
|
||||
*
|
||||
* Input Parameters:
|
||||
* Device structure as returned by the am335x_i2cbus_initialize()
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success, ERROR when internal reference count mismatch or dev
|
||||
* points to invalid hardware device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int am335x_i2cbus_uninitialize(FAR struct i2c_master_s *dev);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_AM335X_AM335X_I2C_H */
|
@ -118,7 +118,9 @@ void up_irqinitialize(void)
|
||||
/* Wait for the reset to complete */
|
||||
|
||||
while ((getreg32(AM335X_INTC_SYSSTATUS) & INTC_SYSSTATUS_RESETDONE) !=
|
||||
INTC_SYSSTATUS_RESETDONE);
|
||||
INTC_SYSSTATUS_RESETDONE)
|
||||
{
|
||||
}
|
||||
|
||||
/* Enable any interrupt generation by setting priority threshold */
|
||||
|
||||
|
@ -51,15 +51,17 @@
|
||||
#include "up_arch.h"
|
||||
#include "hardware/am335x_timer.h"
|
||||
|
||||
#include "am335x_sysclk.h"
|
||||
|
||||
#define USE_TIMER1MS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Timer clock selects system clock CLK_M_OSC (24MHz) */
|
||||
/* Timer clock selects system clock CLK_M_OSC */
|
||||
|
||||
# define TMR_CLOCK (24000000ll)
|
||||
# define TMR_CLOCK ((int64_t)am335x_get_sysclk())
|
||||
|
||||
/* The desired timer interrupt frequency is provided by the definition
|
||||
* CLK_TCK (see include/time.h). CLK_TCK defines the desired number of
|
||||
@ -136,7 +138,9 @@ void arm_timer_initialize(void)
|
||||
|
||||
putreg32(TMR1MS_TIOCP_SOFT_RESET, AM335X_TMR1MS_TIOCP_CFG);
|
||||
|
||||
while (!(getreg32(AM335X_TMR1MS_TISTAT) & TMR1MS_TISTAT));
|
||||
while (!(getreg32(AM335X_TMR1MS_TISTAT) & TMR1MS_TISTAT))
|
||||
{
|
||||
}
|
||||
|
||||
putreg32(TMR_TPIR, AM335X_TMR1MS_TPIR);
|
||||
putreg32(TMR_TNIR, AM335X_TMR1MS_TNIR);
|
||||
@ -175,7 +179,9 @@ void arm_timer_initialize(void)
|
||||
|
||||
putreg32(TMR_TIOCP_SOFT_RESET, AM335X_TMR2_TIOCP_CFG);
|
||||
|
||||
while ((getreg32(AM335X_TMR2_TIOCP_CFG) & TMR_TIOCP_SOFT_RESET));
|
||||
while ((getreg32(AM335X_TMR2_TIOCP_CFG) & TMR_TIOCP_SOFT_RESET))
|
||||
{
|
||||
}
|
||||
|
||||
putreg32(TMR_TLDR, AM335X_TMR2_TLDR);
|
||||
putreg32(TMR_TCRR, AM335X_TMR2_TCRR);
|
||||
|
@ -59,9 +59,13 @@
|
||||
void am335x_wdog_disable_all(void)
|
||||
{
|
||||
putreg32(WDT_SPR_STOP_FEED_A, AM335X_WDT_SPR);
|
||||
while ((getreg32(AM335X_WDT_WPS) & WDT_WPS_W_PEND_WSPR) != 0);
|
||||
while ((getreg32(AM335X_WDT_WPS) & WDT_WPS_W_PEND_WSPR) != 0)
|
||||
{
|
||||
}
|
||||
|
||||
putreg32(WDT_SPR_STOP_FEED_B, AM335X_WDT_SPR);
|
||||
while ((getreg32(AM335X_WDT_WPS) & WDT_WPS_W_PEND_WSPR) != 0);
|
||||
while ((getreg32(AM335X_WDT_WPS) & WDT_WPS_W_PEND_WSPR) != 0)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Alternate Pin Functions.
|
||||
*
|
||||
* Alternative pin selections are provided with a numeric suffix like _1, _2, etc.
|
||||
@ -56,7 +57,8 @@
|
||||
*
|
||||
* #define GPIO_UART2_RXD GPIO_UART2_RXD_1
|
||||
*
|
||||
* The driver will then automatically configure to use the MMC0_CLK pin for UART2 RXD.*/
|
||||
* The driver will then automatically configure to use the MMC0_CLK pin for UART2 RXD.
|
||||
*/
|
||||
|
||||
/* WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!
|
||||
* Additional effort is required to select specific GPIO options (such as pull-up or
|
||||
@ -670,24 +672,24 @@
|
||||
|
||||
/* I2C */
|
||||
|
||||
#define GPIO_I2C0_SCL (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_I2C0_SCL_INDEX) | PINMUX_MODE0 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C0_SDA (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_I2C0_SDA_INDEX) | PINMUX_MODE0 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C0_SCL (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_I2C0_SCL_INDEX) | PINMUX_MODE0 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C0_SDA (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_I2C0_SDA_INDEX) | PINMUX_MODE0 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
|
||||
#define GPIO_I2C1_SCL_1 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_MII1_RX_ER_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C1_SCL_2 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_SPI0_CS0_INDEX) | PINMUX_MODE2 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C1_SCL_3 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART0_RTSN_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C1_SCL_4 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART1_TXD_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C1_SDA_1 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_MII1_CRS_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C1_SDA_2 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_SPI0_D1_INDEX) | PINMUX_MODE2 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C1_SDA_3 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART0_CTSN_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C1_SDA_4 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART1_RXD_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C1_SCL_1 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_MII1_RX_ER_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C1_SCL_2 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_SPI0_CS0_INDEX) | PINMUX_MODE2 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C1_SCL_3 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART0_RTSN_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C1_SCL_4 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART1_TXD_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C1_SDA_1 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_MII1_CRS_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C1_SDA_2 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_SPI0_D1_INDEX) | PINMUX_MODE2 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C1_SDA_3 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART0_CTSN_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C1_SDA_4 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART1_RXD_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
|
||||
#define GPIO_I2C2_SCL_1 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_SPI0_D0_INDEX) | PINMUX_MODE2 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C2_SCL_2 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART0_TXD_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C2_SCL_3 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART1_RTSN_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C2_SDA_1 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_SPI0_SCLK_INDEX) | PINMUX_MODE2 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C2_SDA_2 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART0_RXD_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C2_SDA_3 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART1_CTSN_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE)
|
||||
#define GPIO_I2C2_SCL_1 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_SPI0_D0_INDEX) | PINMUX_MODE2 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C2_SCL_2 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART0_TXD_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C2_SCL_3 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART1_RTSN_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C2_SDA_1 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_SPI0_SCLK_INDEX) | PINMUX_MODE2 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C2_SDA_2 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART0_RXD_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
#define GPIO_I2C2_SDA_3 (GPIO_PERIPH | GPIO_PADCTL(AM335X_PADCTL_UART1_CTSN_INDEX) | PINMUX_MODE3 | PINMUX_RX_ENABLE | PINMUX_PULL_TYPE_UP | PINMUX_SLEW_SLOW)
|
||||
|
||||
/* McASP */
|
||||
|
||||
|
@ -173,7 +173,7 @@
|
||||
|
||||
/* Register bit field definitions ***************************************************/
|
||||
|
||||
#define I2C_SYSC_AUTOIDLE (1 << 0) /* Bit 0: Autoidle */
|
||||
#define I2C_SYSC_AUTOIDLE (1 << 0) /* Bit 0: Auto-idle */
|
||||
#define I2C_SYSC_SRST (1 << 1) /* Bit 1: SoftReset */
|
||||
#define I2C_SYSC_WAKEUP (1 << 2) /* Bit 2: Enable Wakeup control */
|
||||
#define I2C_SYSC_IDLE_SHIFT (3) /* Bits 3-4: Idle Mode selection */
|
||||
@ -205,6 +205,12 @@
|
||||
#define I2C_IRQ_RDR (1 << 13) /* Bit 13: Receive draining IRQ */
|
||||
#define I2C_IRQ_XDR (1 << 14) /* Bit 14: Transmit draining IRQ */
|
||||
|
||||
#define I2C_IRQ_ERRORMASK (I2C_IRQ_AL | I2C_IRQ_NACK | I2C_IRQ_AERR | I2C_IRQ_XUDF | I2C_IRQ_ROVR | I2C_IRQ_BB)
|
||||
|
||||
#define I2C_ICR_CLEARMASK (I2C_IRQ_AL | I2C_IRQ_NACK | I2C_IRQ_ARDY | I2C_IRQ_RRDY | I2C_IRQ_XRDY \
|
||||
| I2C_IRQ_GC | I2C_IRQ_STC | I2C_IRQ_AERR | I2C_IRQ_BF | I2C_IRQ_AAS \
|
||||
| I2C_IRQ_XUDF | I2C_IRQ_ROVR | I2C_IRQ_BB | I2C_IRQ_RDR | I2C_IRQ_XDR)
|
||||
|
||||
#define I2C_WE_AL (1 << 0) /* Bit 0: Arbitration lost */
|
||||
#define I2C_WE_NACK (1 << 1) /* Bit 1: No acknowledgment */
|
||||
#define I2C_WE_ARDY (1 << 2) /* Bit 2: Register access ready */
|
||||
|
@ -130,6 +130,14 @@
|
||||
* PR1_PRU1_PRU_R31_15/GPIO1_11
|
||||
*/
|
||||
|
||||
/* I2Cs *********************************************************************/
|
||||
|
||||
#define GPIO_I2C1_SCL GPIO_I2C1_SCL_2
|
||||
#define GPIO_I2C1_SCL GPIO_I2C1_SDA_2
|
||||
|
||||
#define GPIO_I2C2_SCL GPIO_I2C2_SCL_1
|
||||
#define GPIO_I2C2_SCL GPIO_I2C2_SDA_1
|
||||
|
||||
/****************************************************************************
|
||||
* Assembly Language Macros
|
||||
****************************************************************************/
|
||||
@ -138,4 +146,5 @@
|
||||
.macro config_sdram
|
||||
.endm
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* __BOARDS_ARM_AM335X_BEAGLEBONE_BLACK_INCLUDE_BOARD_H */
|
||||
|
@ -119,6 +119,6 @@ void board_late_initialize(void)
|
||||
{
|
||||
/* Perform board-specific initialization */
|
||||
|
||||
return am335x_bringup();
|
||||
am335x_bringup();
|
||||
}
|
||||
#endif /* CONFIG_BOARD_LATE_INITIALIZE */
|
||||
|
@ -48,6 +48,36 @@
|
||||
|
||||
#include "beaglebone-black.h"
|
||||
|
||||
#include "am335x_i2c.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_I2C_DRIVER) && (defined(CONFIG_AM335X_I2C0) || \
|
||||
defined(CONFIG_AM335X_I2C1) || defined(CONFIG_AM335X_I2C2))
|
||||
static void am335x_i2c_register(int bus)
|
||||
{
|
||||
FAR struct i2c_master_s *i2c;
|
||||
int ret;
|
||||
|
||||
i2c = am335x_i2cbus_initialize(bus);
|
||||
if (i2c == NULL)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to get I2C%d interface\n", bus);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = i2c_register(i2c, bus);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to register I2C%d driver: %d\n", bus, ret);
|
||||
am335x_i2cbus_uninitialize(i2c);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -90,6 +120,18 @@ int am335x_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_I2C_DRIVER) && defined(CONFIG_AM335X_I2C0)
|
||||
am335x_i2c_register(0);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_I2C_DRIVER) && defined(CONFIG_AM335X_I2C1)
|
||||
am335x_i2c_register(1);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_I2C_DRIVER) && defined(CONFIG_AM335X_I2C2)
|
||||
am335x_i2c_register(2);
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -93,14 +93,10 @@
|
||||
* PR1_MII1_RXD0/MCASP0_ACLKX/GPIO1_24
|
||||
*/
|
||||
|
||||
#define GPIO_LED0 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT1 | GPIO_PIN21 | \
|
||||
GPIO_PADCTL(AM335X_PADCTL_GPMC_A5_INDEX))
|
||||
#define GPIO_LED1 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT1 | GPIO_PIN22 | \
|
||||
GPIO_PADCTL(AM335X_PADCTL_GPMC_A6_INDEX))
|
||||
#define GPIO_LED2 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT1 | GPIO_PIN23 | \
|
||||
GPIO_PADCTL(AM335X_PADCTL_GPMC_A7_INDEX))
|
||||
#define GPIO_LED3 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT1 | GPIO_PIN24 | \
|
||||
GPIO_PADCTL(AM335X_PADCTL_GPMC_A8_INDEX))
|
||||
#define GPIO_LED0 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT1 | GPIO_PIN21)
|
||||
#define GPIO_LED1 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT1 | GPIO_PIN22)
|
||||
#define GPIO_LED2 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT1 | GPIO_PIN23)
|
||||
#define GPIO_LED3 (GPIO_OUTPUT | GPIO_OUTPUT_ZERO | GPIO_PORT1 | GPIO_PIN24)
|
||||
|
||||
/* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
|
||||
* defined. In that case, the usage by the board port is defined in
|
||||
|
Loading…
Reference in New Issue
Block a user