mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-01 00:49:43 +00:00
a2a55e518f
Freescale's Layerscape Management Complex (MC) provide support various objects like DPRC, DPNI, DPBP and DPIO. Where: DPRC: Place holdes for other MC objectes like DPNI, DPBP, DPIO DPBP: Management of buffer pool DPIO: Used for used to QBMan portal DPNI: Represents standard network interface These objects are used for DPAA ethernet drivers. Signed-off-by: J. German Rivera <German.Rivera@freescale.com> Signed-off-by: Lijun Pan <Lijun.Pan@freescale.com> Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com> Signed-off-by: Geoff Thorpe <Geoff.Thorpe@freescale.com> Signed-off-by: Haiying Wang <Haiying.Wang@freescale.com> Signed-off-by: Cristian Sovaiala <cristian.sovaiala@freescale.com> Signed-off-by: pankaj chauhan <pankaj.chauhan@freescale.com> Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com> Reviewed-by: York Sun <yorksun@freescale.com>
63 lines
1.7 KiB
C
63 lines
1.7 KiB
C
/*
|
|
* Freescale Layerscape MC I/O wrapper
|
|
*
|
|
* Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
|
|
* Author: German Rivera <German.Rivera@freescale.com>
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
|
|
#include <fsl-mc/fsl_mc_sys.h>
|
|
#include <fsl-mc/fsl_mc_cmd.h>
|
|
#include <common.h>
|
|
#include <errno.h>
|
|
#include <asm/io.h>
|
|
|
|
#define MC_CMD_HDR_READ_CMDID(_hdr) \
|
|
((uint16_t)u64_dec((_hdr), MC_CMD_HDR_CMDID_O, MC_CMD_HDR_CMDID_S))
|
|
|
|
/**
|
|
* mc_send_command - Send MC command and wait for response
|
|
*
|
|
* @mc_io: Pointer to MC I/O object to be used
|
|
* @cmd: MC command buffer. On input, it contains the command to send to the MC.
|
|
* On output, it contains the response from the MC if any.
|
|
*
|
|
* Depending on the sharing option specified when creating the MC portal
|
|
* wrapper, this function will use a spinlock or mutex to ensure exclusive
|
|
* access to the MC portal from the point when the command is sent until a
|
|
* response is received from the MC.
|
|
*/
|
|
int mc_send_command(struct fsl_mc_io *mc_io,
|
|
struct mc_command *cmd)
|
|
{
|
|
enum mc_cmd_status status;
|
|
int timeout = 6000;
|
|
|
|
mc_write_command(mc_io->mmio_regs, cmd);
|
|
|
|
for ( ; ; ) {
|
|
status = mc_read_response(mc_io->mmio_regs, cmd);
|
|
if (status != MC_CMD_STATUS_READY)
|
|
break;
|
|
|
|
if (--timeout == 0) {
|
|
printf("Error: Timeout waiting for MC response\n");
|
|
return -ETIMEDOUT;
|
|
}
|
|
|
|
udelay(500);
|
|
}
|
|
|
|
if (status != MC_CMD_STATUS_OK) {
|
|
printf("Error: MC command failed (portal: %p, obj handle: %#x, command: %#x, status: %#x)\n",
|
|
mc_io->mmio_regs,
|
|
(unsigned int)MC_CMD_HDR_READ_TOKEN(cmd->header),
|
|
(unsigned int)MC_CMD_HDR_READ_CMDID(cmd->header),
|
|
(unsigned int)status);
|
|
|
|
return -EIO;
|
|
}
|
|
|
|
return 0;
|
|
}
|