本文整理汇总了C++中readl函数的典型用法代码示例。如果您正苦于以下问题:C++ readl函数的具体用法?C++ readl怎么用?C++ readl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: micveth_clientpoll
static void
micveth_clientpoll(struct work_struct *work)
{
micveth_info_t *veth_info;
uint32_t transRingHi;
uint32_t transRingLo;
uint32_t scratch14 = 0;
uint32_t scratch15 = 0;
int bd;
static int enter = 0;
if (enter == 0)
{
printk("micveth is polling\n");
enter = 1;
}
mutex_lock(&micveth.lv_state_mutex);
if (micveth.lv_pollstate == CLIENT_POLL_STOPPING) {
micveth.lv_pollstate = CLIENT_POLL_STOPPED;
mutex_unlock(&micveth.lv_state_mutex);
wake_up(&micveth.lv_wq);
return;
}
// Check for state changes for each board in the system
for (bd = 0; bd < micveth.lv_num_clients; bd++) {
veth_info = &micveth.lv_info[bd];
// Do not poll boards that have not had the interface started.
if (veth_info->vi_state == VETH_STATE_INITIALIZED) {
break;
}
#ifdef NO_SRATCHREGREAD_AFTER_CONNECT
if(veth_info->vi_state != VETH_STATE_LINKUP) {
#endif
scratch14 = readl(veth_info->vi_scratch14);
scratch15 = readl(veth_info->vi_scratch15);
#ifdef NO_SRATCHREGREAD_AFTER_CONNECT
}
#endif
if (veth_info->vi_state == VETH_STATE_LINKUP) {
if (scratch14 == MICVETH_LINK_DOWN_MAGIC) {
veth_info->vi_state = VETH_STATE_LINKDOWN;
}
} else if (veth_info->vi_state == VETH_STATE_LINKDOWN) {
if (scratch14 == MICVETH_LINK_UP_MAGIC) {
// Write the transfer ring address.
transRingHi = (uint32_t)(veth_info->vi_ring.phys >> 32);
transRingLo = (uint32_t)(veth_info->vi_ring.phys & 0xffffffff);
writel(transRingLo, veth_info->vi_scratch14);
writel(transRingHi, veth_info->vi_scratch15);
veth_info->vi_state = VETH_STATE_LINKUP;
printk("MIC virtual ethernet up for board %d\n", bd);
#ifdef MIC_IS_EMULATION
printk("Card wrote Magic: It must be UP!\n");
#endif
if (mic_vnet_mode == VNET_MODE_POLL) {
schedule_delayed_work(&veth_info->vi_poll,
msecs_to_jiffies(MICVETH_POLL_TIMER_DELAY));
}
micveth.lv_num_links_remaining--;
}
#ifdef MIC_IS_EMULATION
else if (scratch14) {
printk("---> 0x%x \n", scratch14);
writel(0x0, veth_info->vi_scratch14);
}
#endif
}
示例2: balong_get_rtc_value
/*
* adapt v9r1
*/
u32 balong_get_rtc_value (void)
{
u32 rtc_value = 0;
rtc_value = readl(g_rtc_ctrl.rtc_base_addr + HI_RTC_CCVR_OFFSET);
return rtc_value;
}
示例3: mxs_auart_probe
static int __devinit mxs_auart_probe(struct platform_device *pdev)
{
struct mxs_auart_port *s;
u32 version;
int ret = 0;
struct resource *r;
s = kzalloc(sizeof(struct mxs_auart_port), GFP_KERNEL);
if (!s) {
ret = -ENOMEM;
goto out;
}
s->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(s->clk)) {
ret = PTR_ERR(s->clk);
goto out_free;
}
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) {
ret = -ENXIO;
goto out_free_clk;
}
s->port.mapbase = r->start;
s->port.membase = ioremap(r->start, resource_size(r));
s->port.ops = &mxs_auart_ops;
s->port.iotype = UPIO_MEM;
s->port.line = pdev->id < 0 ? 0 : pdev->id;
s->port.fifosize = 16;
s->port.uartclk = clk_get_rate(s->clk);
s->port.type = PORT_IMX;
s->port.dev = s->dev = get_device(&pdev->dev);
s->flags = 0;
s->ctrl = 0;
s->irq = platform_get_irq(pdev, 0);
s->port.irq = s->irq;
ret = request_irq(s->irq, mxs_auart_irq_handle, 0, dev_name(&pdev->dev), s);
if (ret)
goto out_free_clk;
platform_set_drvdata(pdev, s);
auart_port[pdev->id] = s;
mxs_auart_reset(&s->port);
ret = uart_add_one_port(&auart_driver, &s->port);
if (ret)
goto out_free_irq;
version = readl(s->port.membase + AUART_VERSION);
dev_info(&pdev->dev, "Found APPUART %d.%d.%d\n",
(version >> 24) & 0xff,
(version >> 16) & 0xff, version & 0xffff);
return 0;
out_free_irq:
auart_port[pdev->id] = NULL;
free_irq(s->irq, s);
out_free_clk:
clk_put(s->clk);
out_free:
kfree(s);
out:
return ret;
}
示例4: get_key
inline int get_key(void)
{
return (readl(P_AO_GPIO_I) & (1 << 3)) ? 0 : 1;
}
示例5: i2s_init
static int i2s_init(Exynos5I2s *bus)
{
Exynos5I2sRegs *regs = bus->regs;
uint32_t mode = readl(®s->mode);
// Set transmit only mode.
mode &= ~MOD_MASK;
mode &= ~(MOD_SDF_MASK | MOD_LR_RLOW | MOD_SLAVE);
mode |= MOD_SDF_IIS;
// Sets the frame size for I2S LR clock.
mode &= ~MOD_MULTI_RCLK_MASK;
switch (bus->lr_frame_size) {
case 768:
mode |= MOD_MULTI_RCLK_768FS;
break;
case 512:
mode |= MOD_MULTI_RCLK_512FS;
break;
case 384:
mode |= MOD_MULTI_RCLK_384FS;
break;
case 256:
mode |= MOD_MULTI_RCLK_256FS;
break;
default:
printf("%s: Unrecognized frame size %d.\n", __func__,
bus->lr_frame_size);
return 1;
}
mode &= ~MOD_BLC_MASK;
switch (bus->bits_per_sample) {
case 8:
mode |= MOD_BLC_8BIT;
break;
case 16:
mode |= MOD_BLC_16BIT;
break;
case 24:
mode |= MOD_BLC_24BIT;
break;
default:
printf("%s: Invalid sample size input %d\n",
__func__, bus->bits_per_sample);
return 1;
}
// Set the bit clock frame size (in multiples of LRCLK)
mode &= ~MOD_BCLK_MASK;
switch (bus->bits_per_sample * bus->channels) {
case 48:
mode |= MOD_BCLK_48FS;
break;
case 32:
mode |= MOD_BCLK_32FS;
break;
case 24:
mode |= MOD_BCLK_24FS;
break;
case 16:
mode |= MOD_BCLK_16FS;
break;
default:
printf("%s: Unrecognignized clock frame size %d.\n",
__func__, bus->bits_per_sample * bus->channels);
return 1;
}
writel(mode, ®s->mode);
i2s_transmit_enable(®s->control, 0);
i2s_flush_tx_fifo(®s->fifo_control);
return 0;
}
示例6: isl_upload_firmware
static int
isl_upload_firmware(islpci_private *priv)
{
u32 reg, rc;
void __iomem *device_base = priv->device_base;
/* clear the RAMBoot and the Reset bit */
reg = readl(device_base + ISL38XX_CTRL_STAT_REG);
reg &= ~ISL38XX_CTRL_STAT_RESET;
reg &= ~ISL38XX_CTRL_STAT_RAMBOOT;
writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
wmb();
udelay(ISL38XX_WRITEIO_DELAY);
/* set the Reset bit without reading the register ! */
reg |= ISL38XX_CTRL_STAT_RESET;
writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
wmb();
udelay(ISL38XX_WRITEIO_DELAY);
/* clear the Reset bit */
reg &= ~ISL38XX_CTRL_STAT_RESET;
writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
wmb();
/* wait a while for the device to reboot */
mdelay(50);
{
const struct firmware *fw_entry = NULL;
long fw_len;
const u32 *fw_ptr;
rc = request_firmware(&fw_entry, priv->firmware, PRISM_FW_PDEV);
if (rc) {
printk(KERN_ERR
"%s: request_firmware() failed for '%s'\n",
"prism54", priv->firmware);
return rc;
}
/* prepare the Direct Memory Base register */
reg = ISL38XX_DEV_FIRMWARE_ADDRES;
fw_ptr = (u32 *) fw_entry->data;
fw_len = fw_entry->size;
if (fw_len % 4) {
printk(KERN_ERR
"%s: firmware '%s' size is not multiple of 32bit, aborting!\n",
"prism54", priv->firmware);
release_firmware(fw_entry);
return -EILSEQ; /* Illegal byte sequence */;
}
while (fw_len > 0) {
long _fw_len =
(fw_len >
ISL38XX_MEMORY_WINDOW_SIZE) ?
ISL38XX_MEMORY_WINDOW_SIZE : fw_len;
u32 __iomem *dev_fw_ptr = device_base + ISL38XX_DIRECT_MEM_WIN;
/* set the card's base address for writing the data */
isl38xx_w32_flush(device_base, reg,
ISL38XX_DIR_MEM_BASE_REG);
wmb(); /* be paranoid */
/* increment the write address for next iteration */
reg += _fw_len;
fw_len -= _fw_len;
/* write the data to the Direct Memory Window 32bit-wise */
/* memcpy_toio() doesn't guarantee 32bit writes :-| */
while (_fw_len > 0) {
/* use non-swapping writel() */
__raw_writel(*fw_ptr, dev_fw_ptr);
fw_ptr++, dev_fw_ptr++;
_fw_len -= 4;
}
/* flush PCI posting */
(void) readl(device_base + ISL38XX_PCI_POSTING_FLUSH);
wmb(); /* be paranoid again */
BUG_ON(_fw_len != 0);
}
BUG_ON(fw_len != 0);
/* Firmware version is at offset 40 (also for "newmac") */
printk(KERN_DEBUG "%s: firmware version: %.8s\n",
priv->ndev->name, fw_entry->data + 40);
release_firmware(fw_entry);
}
/* now reset the device
* clear the Reset & ClkRun bit, set the RAMBoot bit */
reg = readl(device_base + ISL38XX_CTRL_STAT_REG);
reg &= ~ISL38XX_CTRL_STAT_CLKRUN;
reg &= ~ISL38XX_CTRL_STAT_RESET;
//.........这里部分代码省略.........
示例7: fec_open
/**
* Start the FEC engine
* @param[in] dev Our device to handle
*/
static int fec_open(struct eth_device *edev)
{
struct fec_priv *fec = (struct fec_priv *)edev->priv;
int speed;
uint32_t addr, size;
int i;
debug("fec_open: fec_open(dev)\n");
/* full-duplex, heartbeat disabled */
writel(1 << 2, &fec->eth->x_cntrl);
fec->rbd_index = 0;
/* Invalidate all descriptors */
for (i = 0; i < FEC_RBD_NUM - 1; i++)
fec_rbd_clean(0, &fec->rbd_base[i]);
fec_rbd_clean(1, &fec->rbd_base[i]);
/* Flush the descriptors into RAM */
size = roundup(FEC_RBD_NUM * sizeof(struct fec_bd),
ARCH_DMA_MINALIGN);
addr = (uint32_t)fec->rbd_base;
flush_dcache_range(addr, addr + size);
#ifdef FEC_QUIRK_ENET_MAC
/* Enable ENET HW endian SWAP */
writel(readl(&fec->eth->ecntrl) | FEC_ECNTRL_DBSWAP,
&fec->eth->ecntrl);
/* Enable ENET store and forward mode */
writel(readl(&fec->eth->x_wmrk) | FEC_X_WMRK_STRFWD,
&fec->eth->x_wmrk);
#endif
/*
* Enable FEC-Lite controller
*/
writel(readl(&fec->eth->ecntrl) | FEC_ECNTRL_ETHER_EN,
&fec->eth->ecntrl);
#if defined(CONFIG_MX25) || defined(CONFIG_MX53) || defined(CONFIG_MX6SL)
udelay(100);
/*
* setup the MII gasket for RMII mode
*/
/* disable the gasket */
writew(0, &fec->eth->miigsk_enr);
/* wait for the gasket to be disabled */
while (readw(&fec->eth->miigsk_enr) & MIIGSK_ENR_READY)
udelay(2);
/* configure gasket for RMII, 50 MHz, no loopback, and no echo */
writew(MIIGSK_CFGR_IF_MODE_RMII, &fec->eth->miigsk_cfgr);
/* re-enable the gasket */
writew(MIIGSK_ENR_EN, &fec->eth->miigsk_enr);
/* wait until MII gasket is ready */
int max_loops = 10;
while ((readw(&fec->eth->miigsk_enr) & MIIGSK_ENR_READY) == 0) {
if (--max_loops <= 0) {
printf("WAIT for MII Gasket ready timed out\n");
break;
}
}
#endif
#ifdef CONFIG_PHYLIB
{
/* Start up the PHY */
int ret = phy_startup(fec->phydev);
if (ret) {
printf("Could not initialize PHY %s\n",
fec->phydev->dev->name);
return ret;
}
speed = fec->phydev->speed;
}
#else
miiphy_wait_aneg(edev);
speed = miiphy_speed(edev->name, fec->phy_id);
miiphy_duplex(edev->name, fec->phy_id);
#endif
#ifdef FEC_QUIRK_ENET_MAC
{
u32 ecr = readl(&fec->eth->ecntrl) & ~FEC_ECNTRL_SPEED;
u32 rcr = readl(&fec->eth->r_cntrl) & ~FEC_RCNTRL_RMII_10T;
if (speed == _1000BASET)
ecr |= FEC_ECNTRL_SPEED;
else if (speed != _100BASET)
rcr |= FEC_RCNTRL_RMII_10T;
writel(ecr, &fec->eth->ecntrl);
writel(rcr, &fec->eth->r_cntrl);
}
#endif
debug("%s:Speed=%i\n", __func__, speed);
//.........这里部分代码省略.........
示例8: fec_send
/**
* Transmit one frame
* @param[in] dev Our ethernet device to handle
* @param[in] packet Pointer to the data to be transmitted
* @param[in] length Data count in bytes
* @return 0 on success
*/
static int fec_send(struct eth_device *dev, void *packet, int length)
{
unsigned int status;
uint32_t size, end;
uint32_t addr;
int timeout = FEC_XFER_TIMEOUT;
int ret = 0;
/*
* This routine transmits one frame. This routine only accepts
* 6-byte Ethernet addresses.
*/
struct fec_priv *fec = (struct fec_priv *)dev->priv;
/*
* Check for valid length of data.
*/
if ((length > 1500) || (length <= 0)) {
printf("Payload (%d) too large\n", length);
return -1;
}
/*
* Setup the transmit buffer. We are always using the first buffer for
* transmission, the second will be empty and only used to stop the DMA
* engine. We also flush the packet to RAM here to avoid cache trouble.
*/
#ifdef CONFIG_FEC_MXC_SWAP_PACKET
swap_packet((uint32_t *)packet, length);
#endif
addr = (uint32_t)packet;
end = roundup(addr + length, ARCH_DMA_MINALIGN);
addr &= ~(ARCH_DMA_MINALIGN - 1);
flush_dcache_range(addr, end);
writew(length, &fec->tbd_base[fec->tbd_index].data_length);
writel(addr, &fec->tbd_base[fec->tbd_index].data_pointer);
/*
* update BD's status now
* This block:
* - is always the last in a chain (means no chain)
* - should transmitt the CRC
* - might be the last BD in the list, so the address counter should
* wrap (-> keep the WRAP flag)
*/
status = readw(&fec->tbd_base[fec->tbd_index].status) & FEC_TBD_WRAP;
status |= FEC_TBD_LAST | FEC_TBD_TC | FEC_TBD_READY;
writew(status, &fec->tbd_base[fec->tbd_index].status);
/*
* Flush data cache. This code flushes both TX descriptors to RAM.
* After this code, the descriptors will be safely in RAM and we
* can start DMA.
*/
size = roundup(2 * sizeof(struct fec_bd), ARCH_DMA_MINALIGN);
addr = (uint32_t)fec->tbd_base;
flush_dcache_range(addr, addr + size);
/*
* Below we read the DMA descriptor's last four bytes back from the
* DRAM. This is important in order to make sure that all WRITE
* operations on the bus that were triggered by previous cache FLUSH
* have completed.
*
* Otherwise, on MX28, it is possible to observe a corruption of the
* DMA descriptors. Please refer to schematic "Figure 1-2" in MX28RM
* for the bus structure of MX28. The scenario is as follows:
*
* 1) ARM core triggers a series of WRITEs on the AHB_ARB2 bus going
* to DRAM due to flush_dcache_range()
* 2) ARM core writes the FEC registers via AHB_ARB2
* 3) FEC DMA starts reading/writing from/to DRAM via AHB_ARB3
*
* Note that 2) does sometimes finish before 1) due to reordering of
* WRITE accesses on the AHB bus, therefore triggering 3) before the
* DMA descriptor is fully written into DRAM. This results in occasional
* corruption of the DMA descriptor.
*/
readl(addr + size - 4);
/*
* Enable SmartDMA transmit task
*/
fec_tx_task_enable(fec);
/*
* Wait until frame is sent. On each turn of the wait cycle, we must
* invalidate data cache to see what's really in RAM. Also, we need
* barrier here.
*/
while (--timeout) {
//.........这里部分代码省略.........
示例9: tpam_irq
/*
* IRQ handler.
*
* If a message comes from the board we read it, construct a sk_buff containing
* the message and we queue the sk_buff on the board's receive queue, and we
* trigger the execution of the board's receive task queue.
*
* If a message ack comes from the board we can go on and send a new message,
* so we trigger the execution of the board's send task queue.
*
* irq: the irq number
* dev_id: the registered board to the irq
* regs: not used.
*/
void tpam_irq(int irq, void *dev_id, struct pt_regs *regs) {
tpam_card *card = (tpam_card *)dev_id;
u32 ackupload, uploadptr;
u32 waiting_too_long;
u32 hpic;
struct sk_buff *skb;
pci_mpb mpb;
skb_header *skbh;
dprintk("TurboPAM(tpam_irq): IRQ received, card=%d\n", card->id);
/* grab the board lock */
spin_lock(&card->lock);
/* get the message type */
ackupload = copy_from_pam_dword(card, (void *)TPAM_ACKUPLOAD_REGISTER);
/* acknowledge the interrupt */
copy_to_pam_dword(card, (void *)TPAM_INTERRUPTACK_REGISTER, 0);
readl(card->bar0 + TPAM_HINTACK_REGISTER);
if (!ackupload) {
/* it is a new message from the board */
dprintk("TurboPAM(tpam_irq): message received, card=%d\n",
card->id);
/* get the upload pointer */
uploadptr = copy_from_pam_dword(card,
(void *)TPAM_UPLOADPTR_REGISTER);
/* get the beginning of the message (pci_mpb part) */
copy_from_pam(card, &mpb, (void *)uploadptr, sizeof(pci_mpb));
/* allocate the sk_buff */
if (!(skb = alloc_skb(sizeof(skb_header) + sizeof(pci_mpb) +
mpb.actualBlockTLVSize +
mpb.actualDataSize, GFP_ATOMIC))) {
printk(KERN_ERR "TurboPAM(tpam_irq): "
"alloc_skb failed\n");
spin_unlock(&card->lock);
return;
}
/* build the skb_header */
skbh = (skb_header *)skb_put(skb, sizeof(skb_header));
skbh->size = sizeof(pci_mpb) + mpb.actualBlockTLVSize;
skbh->data_size = mpb.actualDataSize;
skbh->ack = 0;
skbh->ack_size = 0;
/* copy the pci_mpb into the sk_buff */
memcpy(skb_put(skb, sizeof(pci_mpb)), &mpb, sizeof(pci_mpb));
/* copy the TLV block into the sk_buff */
copy_from_pam(card, skb_put(skb, mpb.actualBlockTLVSize),
(void *)uploadptr + sizeof(pci_mpb),
mpb.actualBlockTLVSize);
/* if existent, copy the data block into the sk_buff */
if (mpb.actualDataSize)
copy_from_pam(card, skb_put(skb, mpb.actualDataSize),
(void *)uploadptr + sizeof(pci_mpb) + 4096,
mpb.actualDataSize);
/* wait for the board to become ready */
waiting_too_long = 0;
do {
hpic = readl(card->bar0 + TPAM_HPIC_REGISTER);
if (waiting_too_long++ > 0xfffffff) {
spin_unlock(&card->lock);
printk(KERN_ERR "TurboPAM(tpam_irq): "
"waiting too long...\n");
return;
}
} while (hpic & 0x00000002);
/* acknowledge the message */
copy_to_pam_dword(card, (void *)TPAM_ACKDOWNLOAD_REGISTER,
0xffffffff);
readl(card->bar0 + TPAM_DSPINT_REGISTER);
/* release the board lock */
spin_unlock(&card->lock);
if (mpb.messageID == ID_U3ReadyToReceiveInd) {
//.........这里部分代码省略.........
示例10: board_eth_init
int board_eth_init(bd_t *bis)
{
int rv, n = 0;
uint8_t mac_addr[6];
uint32_t mac_hi, mac_lo;
__maybe_unused struct am335x_baseboard_id header;
puts("board_eth_init \n");
/* try reading mac address from efuse */
mac_lo = readl(&cdev->macid0l);
mac_hi = readl(&cdev->macid0h);
mac_addr[0] = mac_hi & 0xFF;
mac_addr[1] = (mac_hi & 0xFF00) >> 8;
mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
mac_addr[4] = mac_lo & 0xFF;
mac_addr[5] = (mac_lo & 0xFF00) >> 8;
#if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
(defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
if (!getenv("ethaddr")) {
printf("<ethaddr> not set. Validating first E-fuse MAC\n");
if (is_valid_ether_addr(mac_addr))
eth_setenv_enetaddr("ethaddr", mac_addr);
}
#ifdef CONFIG_DRIVER_TI_CPSW
mac_lo = readl(&cdev->macid1l);
mac_hi = readl(&cdev->macid1h);
mac_addr[0] = mac_hi & 0xFF;
mac_addr[1] = (mac_hi & 0xFF00) >> 8;
mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
mac_addr[4] = mac_lo & 0xFF;
mac_addr[5] = (mac_lo & 0xFF00) >> 8;
if (!getenv("eth1addr")) {
if (is_valid_ether_addr(mac_addr))
eth_setenv_enetaddr("eth1addr", mac_addr);
}
if (read_eeprom(&header) < 0)
puts("Could not get board ID.\n");
if (board_is_bone(&header) || board_is_bone_lt(&header) ||
board_is_idk(&header)) {
writel(MII_MODE_ENABLE, &cdev->miisel);
cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
PHY_INTERFACE_MODE_MII;
} else {
writel((RGMII_MODE_ENABLE | RGMII_INT_DELAY), &cdev->miisel);
cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
PHY_INTERFACE_MODE_RGMII;
}
rv = cpsw_register(&cpsw_data);
if (rv < 0)
printf("Error %d registering CPSW switch\n", rv);
else
n += rv;
#endif
/*
*
* CPSW RGMII Internal Delay Mode is not supported in all PVT
* operating points. So we must set the TX clock delay feature
* in the AR8051 PHY. Since we only support a single ethernet
* device in U-Boot, we only do this for the first instance.
*/
#define AR8051_PHY_DEBUG_ADDR_REG 0x1d
#define AR8051_PHY_DEBUG_DATA_REG 0x1e
#define AR8051_DEBUG_RGMII_CLK_DLY_REG 0x5
#define AR8051_RGMII_TX_CLK_DLY 0x100
if (board_is_evm_sk(&header) || board_is_gp_evm(&header)) {
const char *devname;
devname = miiphy_get_current_dev();
miiphy_write(devname, 0x0, AR8051_PHY_DEBUG_ADDR_REG,
AR8051_DEBUG_RGMII_CLK_DLY_REG);
miiphy_write(devname, 0x0, AR8051_PHY_DEBUG_DATA_REG,
AR8051_RGMII_TX_CLK_DLY);
}
#endif
#if defined(CONFIG_USB_ETHER) && \
(!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
if (is_valid_ether_addr(mac_addr))
eth_setenv_enetaddr("usbnet_devaddr", mac_addr);
rv = usb_eth_initialize(bis);
if (rv < 0)
printf("Error %d registering USB_ETHER\n", rv);
else
n += rv;
#endif
return n;
}
示例11: tpam_sendpacket
/*
* Try to send a packet from the board's send queue or from the channel's
* send queue.
*
* card: the board.
* channel: the channel (if NULL, the packet will be taken from the
* board's send queue. If not, it will be taken from the
* channel's send queue.
*
* Return: 0 if tpam_send_tq must try another card/channel combination
* (meaning that no packet has been send), 1 if no more packets
* can be send at that time (a packet has been send or the card is
* still busy from a previous send).
*/
static int tpam_sendpacket(tpam_card *card, tpam_channel *channel) {
struct sk_buff *skb;
u32 hpic;
u32 downloadptr;
skb_header *skbh;
u32 waiting_too_long;
dprintk("TurboPAM(tpam_sendpacket), card=%d, channel=%d\n",
card->id, channel ? channel->num : -1);
if (channel) {
/* dequeue a packet from the channel's send queue */
if (!(skb = skb_dequeue(&channel->sendq))) {
dprintk("TurboPAM(tpam_sendpacket): "
"card=%d, channel=%d, no packet\n",
card->id, channel->num);
return 0;
}
/* if the channel is not ready to receive, requeue the packet
* and return 0 to give a chance to another channel */
if (!channel->readytoreceive) {
dprintk("TurboPAM(tpam_sendpacket): "
"card=%d, channel=%d, channel not ready\n",
card->id, channel->num);
skb_queue_head(&channel->sendq, skb);
return 0;
}
/* grab the board lock */
spin_lock_irq(&card->lock);
/* if the board is busy, requeue the packet and return 1 since
* there is no need to try another channel */
if (card->busy) {
dprintk("TurboPAM(tpam_sendpacket): "
"card=%d, channel=%d, card busy\n",
card->id, channel->num);
skb_queue_head(&channel->sendq, skb);
spin_unlock_irq(&card->lock);
return 1;
}
}
else {
/* dequeue a packet from the board's send queue */
if (!(skb = skb_dequeue(&card->sendq))) {
dprintk("TurboPAM(tpam_sendpacket): "
"card=%d, no packet\n", card->id);
return 0;
}
/* grab the board lock */
spin_lock_irq(&card->lock);
/* if the board is busy, requeue the packet and return 1 since
* there is no need to try another channel */
if (card->busy) {
dprintk("TurboPAM(tpam_sendpacket): "
"card=%d, card busy\n", card->id);
skb_queue_head(&card->sendq, skb);
spin_unlock_irq(&card->lock);
return 1;
}
}
/* wait for the board to become ready */
waiting_too_long = 0;
do {
hpic = readl(card->bar0 + TPAM_HPIC_REGISTER);
if (waiting_too_long++ > 0xfffffff) {
spin_unlock_irq(&card->lock);
printk(KERN_ERR "TurboPAM(tpam_sendpacket): "
"waiting too long...\n");
return 1;
}
} while (hpic & 0x00000002);
skbh = (skb_header *)skb->data;
dprintk("TurboPAM(tpam_sendpacket): "
"card=%d, card ready, sending %d/%d bytes\n",
card->id, skbh->size, skbh->data_size);
/* get the board's download pointer */
downloadptr = copy_from_pam_dword(card,
(void *)TPAM_DOWNLOADPTR_REGISTER);
//.........这里部分代码省略.........
示例12: ethoc_read
static inline u32 ethoc_read(struct ethoc *dev, loff_t offset)
{
return readl(dev->iobase + offset);
}
示例13: spdif_readl
static inline u32 spdif_readl(unsigned long base, u32 reg)
{
u32 val = readl(base + reg);
SPDIF_DEBUG_PRINT("Spdif Read 0x%lx : %08x\n",base + reg, val);
return val;
}
示例14: check_ide_device
static int check_ide_device(int slot, int ide_base_bus)
{
volatile char *ident = NULL;
volatile char *feature_p[MAX_FEATURES];
volatile char *p, *start;
int n_features = 0;
uchar func_id = ~0;
uchar code, len;
ushort config_base = 0;
int found = 0;
int i;
u32 socket_status;
debug ("PCMCIA MEM: %08X\n", pcmcia_cis_ptr);
socket_status = readl(socket_base+8);
if ((socket_status & 6) != 0 || (socket_status & 0x20) != 0) {
printf("no card or CardBus card\n");
return 1;
}
start = p = (volatile char *) pcmcia_cis_ptr;
while ((p - start) < MAX_TUPEL_SZ) {
code = *p; p += 2;
if (code == 0xFF) { /* End of chain */
break;
}
len = *p; p += 2;
#if defined(DEBUG) && (DEBUG > 1)
{
volatile uchar *q = p;
printf ("\nTuple code %02x length %d\n\tData:",
code, len);
for (i = 0; i < len; ++i) {
printf (" %02x", *q);
q+= 2;
}
}
#endif /* DEBUG */
switch (code) {
case CISTPL_VERS_1:
ident = p + 4;
break;
case CISTPL_FUNCID:
/* Fix for broken SanDisk which may have 0x80 bit set */
func_id = *p & 0x7F;
break;
case CISTPL_FUNCE:
if (n_features < MAX_FEATURES)
feature_p[n_features++] = p;
break;
case CISTPL_CONFIG:
config_base = (*(p+6) << 8) + (*(p+4));
debug ("\n## Config_base = %04x ###\n", config_base);
default:
break;
}
p += 2 * len;
}
found = identify(ident);
if (func_id != ((uchar)~0)) {
print_funcid (func_id);
if (func_id == CISTPL_FUNCID_FIXED)
found = 1;
else
return 1; /* no disk drive */
}
for (i=0; i<n_features; ++i) {
print_fixed(feature_p[i]);
}
if (!found) {
printf("unknown card type\n");
return 1;
}
/* select config index 1 */
writeb(1, pcmcia_cis_ptr + config_base);
#if 0
printf("Confiuration Option Register: %02x\n", readb(pcmcia_cis_ptr + config_base));
printf("Card Confiuration and Status Register: %02x\n", readb(pcmcia_cis_ptr + config_base + 2));
printf("Pin Replacement Register Register: %02x\n", readb(pcmcia_cis_ptr + config_base + 4));
printf("Socket and Copy Register: %02x\n", readb(pcmcia_cis_ptr + config_base + 6));
#endif
ide_devices_found |= (1 << (slot+ide_base_bus));
return 0;
}
示例15: fec_recv
/**
* Pull one frame from the card
* @param[in] dev Our ethernet device to handle
* @return Length of packet read
*/
static int fec_recv(struct eth_device *dev)
{
struct fec_priv *fec = (struct fec_priv *)dev->priv;
struct fec_bd *rbd = &fec->rbd_base[fec->rbd_index];
unsigned long ievent;
int frame_length, len = 0;
struct nbuf *frame;
uint16_t bd_status;
uint32_t addr, size, end;
int i;
ALLOC_CACHE_ALIGN_BUFFER(uchar, buff, FEC_MAX_PKT_SIZE);
/*
* Check if any critical events have happened
*/
ievent = readl(&fec->eth->ievent);
writel(ievent, &fec->eth->ievent);
debug("fec_recv: ievent 0x%lx\n", ievent);
if (ievent & FEC_IEVENT_BABR) {
fec_halt(dev);
fec_init(dev, fec->bd);
printf("some error: 0x%08lx\n", ievent);
return 0;
}
if (ievent & FEC_IEVENT_HBERR) {
/* Heartbeat error */
writel(0x00000001 | readl(&fec->eth->x_cntrl),
&fec->eth->x_cntrl);
}
if (ievent & FEC_IEVENT_GRA) {
/* Graceful stop complete */
if (readl(&fec->eth->x_cntrl) & 0x00000001) {
fec_halt(dev);
writel(~0x00000001 & readl(&fec->eth->x_cntrl),
&fec->eth->x_cntrl);
fec_init(dev, fec->bd);
}
}
/*
* Read the buffer status. Before the status can be read, the data cache
* must be invalidated, because the data in RAM might have been changed
* by DMA. The descriptors are properly aligned to cachelines so there's
* no need to worry they'd overlap.
*
* WARNING: By invalidating the descriptor here, we also invalidate
* the descriptors surrounding this one. Therefore we can NOT change the
* contents of this descriptor nor the surrounding ones. The problem is
* that in order to mark the descriptor as processed, we need to change
* the descriptor. The solution is to mark the whole cache line when all
* descriptors in the cache line are processed.
*/
addr = (uint32_t)rbd;
addr &= ~(ARCH_DMA_MINALIGN - 1);
size = roundup(sizeof(struct fec_bd), ARCH_DMA_MINALIGN);
invalidate_dcache_range(addr, addr + size);
bd_status = readw(&rbd->status);
debug("fec_recv: status 0x%x\n", bd_status);
if (!(bd_status & FEC_RBD_EMPTY)) {
if ((bd_status & FEC_RBD_LAST) && !(bd_status & FEC_RBD_ERR) &&
((readw(&rbd->data_length) - 4) > 14)) {
/*
* Get buffer address and size
*/
frame = (struct nbuf *)readl(&rbd->data_pointer);
frame_length = readw(&rbd->data_length) - 4;
/*
* Invalidate data cache over the buffer
*/
addr = (uint32_t)frame;
end = roundup(addr + frame_length, ARCH_DMA_MINALIGN);
addr &= ~(ARCH_DMA_MINALIGN - 1);
invalidate_dcache_range(addr, end);
/*
* Fill the buffer and pass it to upper layers
*/
#ifdef CONFIG_FEC_MXC_SWAP_PACKET
swap_packet((uint32_t *)frame->data, frame_length);
#endif
memcpy(buff, frame->data, frame_length);
NetReceive(buff, frame_length);
len = frame_length;
} else {
if (bd_status & FEC_RBD_ERR)
printf("error frame: 0x%08lx 0x%08x\n",
(ulong)rbd->data_pointer,
bd_status);
}
/*
* Free the current buffer, restart the engine and move forward
* to the next buffer. Here we check if the whole cacheline of
//.........这里部分代码省略.........