// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) /* * Copyright 2013-2016 Freescale Semiconductor Inc. * * I/O services to send MC commands to the MC hardware * */ #include <linux/delay.h> #include <linux/slab.h> #include <linux/ioport.h> #include <linux/device.h> #include <linux/io.h> #include <linux/io-64-nonatomic-hi-lo.h> #include <linux/fsl/mc.h> #include "fsl-mc-private.h" /* * Timeout in milliseconds to wait for the completion of an MC command */ #define MC_CMD_COMPLETION_TIMEOUT_MS … /* * usleep_range() min and max values used to throttle down polling * iterations while waiting for MC command completion */ #define MC_CMD_COMPLETION_POLLING_MIN_SLEEP_USECS … #define MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS … static enum mc_cmd_status mc_cmd_hdr_read_status(struct fsl_mc_command *cmd) { … } u16 mc_cmd_hdr_read_cmdid(struct fsl_mc_command *cmd) { … } static int mc_status_to_error(enum mc_cmd_status status) { … } static const char *mc_status_to_string(enum mc_cmd_status status) { … } /** * mc_write_command - writes a command to a Management Complex (MC) portal * * @portal: pointer to an MC portal * @cmd: pointer to a filled command */ static inline void mc_write_command(struct fsl_mc_command __iomem *portal, struct fsl_mc_command *cmd) { … } /** * mc_read_response - reads the response for the last MC command from a * Management Complex (MC) portal * * @portal: pointer to an MC portal * @resp: pointer to command response buffer * * Returns MC_CMD_STATUS_OK on Success; Error code otherwise. */ static inline enum mc_cmd_status mc_read_response(struct fsl_mc_command __iomem *portal, struct fsl_mc_command *resp) { … } /** * mc_polling_wait_preemptible() - Waits for the completion of an MC * command doing preemptible polling. * uslepp_range() is called between * polling iterations. * @mc_io: MC I/O object to be used * @cmd: command buffer to receive MC response * @mc_status: MC command completion status */ static int mc_polling_wait_preemptible(struct fsl_mc_io *mc_io, struct fsl_mc_command *cmd, enum mc_cmd_status *mc_status) { … } /** * mc_polling_wait_atomic() - Waits for the completion of an MC command * doing atomic polling. udelay() is called * between polling iterations. * @mc_io: MC I/O object to be used * @cmd: command buffer to receive MC response * @mc_status: MC command completion status */ static int mc_polling_wait_atomic(struct fsl_mc_io *mc_io, struct fsl_mc_command *cmd, enum mc_cmd_status *mc_status) { … } /** * mc_send_command() - Sends a command to the MC device using the given * MC I/O object * @mc_io: MC I/O object to be used * @cmd: command to be sent * * Returns '0' on Success; Error code otherwise. */ int mc_send_command(struct fsl_mc_io *mc_io, struct fsl_mc_command *cmd) { … } EXPORT_SYMBOL_GPL(…);