Merge pull request #2978 from Liufeilong66/master

龙芯1c部分问题
This commit is contained in:
Bernard Xiong 2019-08-21 17:16:54 +08:00 committed by GitHub
commit 863c549497
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 139 additions and 112 deletions

View File

@ -73,8 +73,24 @@ rt_err_t ls1c_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
{
unsigned int gpio = pin;
char irq_name[10];
rt_uint32_t type;
switch (mode)
{
case PIN_IRQ_MODE_RISING:
type=IRQ_TYPE_EDGE_RISING;
break;
case PIN_IRQ_MODE_FALLING:
type=IRQ_TYPE_EDGE_FALLING;
break;
case PIN_IRQ_MODE_HIGH_LEVEL:
type=IRQ_TYPE_LEVEL_HIGH;
break;
case PIN_IRQ_MODE_LOW_LEVEL:
type=IRQ_TYPE_LEVEL_LOW;
break;
}
gpio_set_irq_type(gpio, type);
gpio_set_irq_type(gpio, mode);
rt_sprintf(irq_name, "PIN_%d", gpio);
rt_hw_interrupt_install(LS1C_GPIO_TO_IRQ(gpio), (rt_isr_handler_t)hdr, args, irq_name);

View File

@ -25,13 +25,14 @@
#include <rtthread.h>
#include <drivers/spi.h>
#include <rthw.h>
#include "drv_spi.h"
#include "ls1c_public.h"
#include "spi_msd.h"
#include "dfs_fs.h"
#include "../libraries/ls1c_pin.h"
#ifdef RT_USING_SPI
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINTF(...) rt_kprintf(__VA_ARGS__)
#else
@ -268,10 +269,11 @@ int ls1c_hw_spi_init(void)
static struct rt_spi_device spi_device0;
static struct rt_spi_device spi_device1;
static struct rt_spi_device spi_device2;
static struct rt_spi_device spi_device3;
static struct ls1c_spi_cs spi_cs0;
static struct ls1c_spi_cs spi_cs1;
static struct ls1c_spi_cs spi_cs2;
static struct ls1c_spi_cs spi_cs3;
/* spi02: CS2 SD Card*/
spi_cs2.cs = LS1C_SPI_CS_2;
rt_spi_bus_attach_device(&spi_device2, "spi02", "spi0", (void *)&spi_cs2);
@ -279,6 +281,9 @@ int ls1c_hw_spi_init(void)
rt_spi_bus_attach_device(&spi_device1, "spi01", "spi0", (void *)&spi_cs1);
spi_cs0.cs = LS1C_SPI_CS_0;
rt_spi_bus_attach_device(&spi_device0, "spi00", "spi0", (void *)&spi_cs0);
spi_cs3.cs = LS1C_SPI_CS_3;
rt_spi_bus_attach_device(&spi_device3, "spi03", "spi0", (void*)&spi_cs3);
msd_init("sd0", "spi02");
}
#endif
#ifdef RT_USING_SPI1
@ -296,5 +301,21 @@ int ls1c_hw_spi_init(void)
INIT_BOARD_EXPORT(ls1c_hw_spi_init);
static int board_sd_init(void)
{
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
/* mount sd card fat partition 1 as root directory */
if( dfs_mount("sd0", "/", "elm", 0, 0) == 0)
{
rt_kprintf("File System initialized!\n");
}
else
{
rt_kprintf("File System initialzation failed!\n");
}
#endif /* RT_USING_DFS && RT_USING_DFS_ELMFAT */
}
INIT_APP_EXPORT(board_sd_init);
#endif

View File

@ -572,22 +572,16 @@ struct pbuf *rt_eth_rx(rt_device_t device)
}
/*Handle the Receive Descriptors*/
do
{
desc_index = synopGMAC_get_rx_qptr(gmacdev, &status, &dma_addr1, NULL, &data1, &dma_addr2, NULL, &data2);
if (desc_index >= 0 && data1 != 0)
{
DEBUG_MES("Received Data at Rx Descriptor %d for skb 0x%08x whose status is %08x\n", desc_index, dma_addr1, status);
if (synopGMAC_is_rx_desc_valid(status) || SYNOP_PHY_LOOPBACK)
{
pbuf = pbuf_alloc(PBUF_LINK, MAX_ETHERNET_PAYLOAD, PBUF_RAM);
if (pbuf == 0) rt_kprintf("===error in pbuf_alloc\n");
dma_addr1 = plat_dma_map_single(gmacdev, (void *)data1, RX_BUF_SIZE);
len = synopGMAC_get_rx_desc_frame_length(status); //Not interested in Ethernet CRC bytes
len = synopGMAC_get_rx_desc_frame_length(status)-4; //Not interested in Ethernet CRC bytes
pbuf = pbuf_alloc(PBUF_LINK, len, PBUF_RAM);
if (pbuf == 0) rt_kprintf("===error in pbuf_alloc\n");
rt_memcpy(pbuf->payload, (char *)data1, len);
DEBUG_MES("==get pkg len: %d\n", len);
}
@ -600,19 +594,15 @@ struct pbuf *rt_eth_rx(rt_device_t device)
adapter->synopGMACNetStats.rx_frame_errors += synopGMAC_is_frame_dribbling_errors(status);
adapter->synopGMACNetStats.rx_length_errors += synopGMAC_is_rx_frame_length_errors(status);
}
desc_index = synopGMAC_set_rx_qptr(gmacdev, dma_addr1, RX_BUF_SIZE, (u32)data1, 0, 0, 0);
if (desc_index < 0)
{
#if SYNOP_RX_DEBUG
#if SYNOP_RX_DEBUG
rt_kprintf("Cannot set Rx Descriptor for data1 %08x\n", (u32)data1);
#endif
#endif
plat_free_memory((void *)data1);
}
}
}while(desc_index >= 0);
rt_sem_release(&sem_lock);
DEBUG_MES("%s : before return \n", __FUNCTION__);
return pbuf;

View File

@ -145,8 +145,8 @@ struct ls1c_cop_regs
/* Watch Dog registers */
#define WDT_EN __REG32(WDT_BASE + 0x00)
#define WDT_SET __REG32(WDT_BASE + 0x04)
#define WDT_TIMER __REG32(WDT_BASE + 0x08)
#define WDT_SET __REG32(WDT_BASE + 0x08)
#define WDT_TIMER __REG32(WDT_BASE + 0x04)
#define PLL_FREQ __REG32(0xbfe78030)
#define PLL_DIV_PARAM __REG32(0xbfe78034)