1 /* 2 * Freescale Layerscape MC I/O wrapper 3 * 4 * Copyright (C) 2013-2015 Freescale Semiconductor, Inc. 5 * Author: German Rivera <German.Rivera@freescale.com> 6 * 7 * SPDX-License-Identifier: GPL-2.0+ 8 */ 9 #include <fsl-mc/fsl_mc_sys.h> 10 #include <fsl-mc/fsl_mc_cmd.h> 11 #include <fsl-mc/fsl_dpbp.h> 12 13 int dpbp_open(struct fsl_mc_io *mc_io, int dpbp_id, uint16_t *token) 14 { 15 struct mc_command cmd = { 0 }; 16 int err; 17 18 /* prepare command */ 19 cmd.header = mc_encode_cmd_header(DPBP_CMDID_OPEN, 20 MC_CMD_PRI_LOW, 0); 21 DPBP_CMD_OPEN(cmd, dpbp_id); 22 23 /* send command to mc*/ 24 err = mc_send_command(mc_io, &cmd); 25 if (err) 26 return err; 27 28 /* retrieve response parameters */ 29 *token = MC_CMD_HDR_READ_TOKEN(cmd.header); 30 31 return err; 32 } 33 34 int dpbp_close(struct fsl_mc_io *mc_io, uint16_t token) 35 { 36 struct mc_command cmd = { 0 }; 37 38 /* prepare command */ 39 cmd.header = mc_encode_cmd_header(DPBP_CMDID_CLOSE, MC_CMD_PRI_HIGH, 40 token); 41 42 /* send command to mc*/ 43 return mc_send_command(mc_io, &cmd); 44 } 45 46 int dpbp_enable(struct fsl_mc_io *mc_io, uint16_t token) 47 { 48 struct mc_command cmd = { 0 }; 49 50 /* prepare command */ 51 cmd.header = mc_encode_cmd_header(DPBP_CMDID_ENABLE, MC_CMD_PRI_LOW, 52 token); 53 54 /* send command to mc*/ 55 return mc_send_command(mc_io, &cmd); 56 } 57 58 int dpbp_disable(struct fsl_mc_io *mc_io, uint16_t token) 59 { 60 struct mc_command cmd = { 0 }; 61 62 /* prepare command */ 63 cmd.header = mc_encode_cmd_header(DPBP_CMDID_DISABLE, 64 MC_CMD_PRI_LOW, token); 65 66 /* send command to mc*/ 67 return mc_send_command(mc_io, &cmd); 68 } 69 70 int dpbp_reset(struct fsl_mc_io *mc_io, uint16_t token) 71 { 72 struct mc_command cmd = { 0 }; 73 74 /* prepare command */ 75 cmd.header = mc_encode_cmd_header(DPBP_CMDID_RESET, 76 MC_CMD_PRI_LOW, token); 77 78 /* send command to mc*/ 79 return mc_send_command(mc_io, &cmd); 80 } 81 82 int dpbp_get_attributes(struct fsl_mc_io *mc_io, 83 uint16_t token, 84 struct dpbp_attr *attr) 85 { 86 struct mc_command cmd = { 0 }; 87 int err; 88 89 /* prepare command */ 90 cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_ATTR, 91 MC_CMD_PRI_LOW, token); 92 93 /* send command to mc*/ 94 err = mc_send_command(mc_io, &cmd); 95 if (err) 96 return err; 97 98 /* retrieve response parameters */ 99 DPBP_RSP_GET_ATTRIBUTES(cmd, attr); 100 101 return 0; 102 } 103