Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013-2015 Freescale Semiconductor |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <fsl-mc/fsl_mc_sys.h> |
| 8 | #include <fsl-mc/fsl_mc_cmd.h> |
| 9 | #include <fsl-mc/fsl_dpio.h> |
| 10 | |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 11 | int dpio_open(struct fsl_mc_io *mc_io, |
| 12 | uint32_t cmd_flags, |
| 13 | int dpio_id, |
| 14 | uint16_t *token) |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 15 | { |
| 16 | struct mc_command cmd = { 0 }; |
| 17 | int err; |
| 18 | |
| 19 | /* prepare command */ |
| 20 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_OPEN, |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 21 | cmd_flags, |
| 22 | 0); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 23 | DPIO_CMD_OPEN(cmd, dpio_id); |
| 24 | |
| 25 | /* send command to mc*/ |
| 26 | err = mc_send_command(mc_io, &cmd); |
| 27 | if (err) |
| 28 | return err; |
| 29 | |
| 30 | /* retrieve response parameters */ |
| 31 | *token = MC_CMD_HDR_READ_TOKEN(cmd.header); |
| 32 | |
| 33 | return 0; |
| 34 | } |
| 35 | |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 36 | int dpio_close(struct fsl_mc_io *mc_io, |
| 37 | uint32_t cmd_flags, |
| 38 | uint16_t token) |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 39 | { |
| 40 | struct mc_command cmd = { 0 }; |
| 41 | |
| 42 | /* prepare command */ |
| 43 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_CLOSE, |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 44 | cmd_flags, |
| 45 | token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 46 | |
| 47 | /* send command to mc*/ |
| 48 | return mc_send_command(mc_io, &cmd); |
| 49 | } |
| 50 | |
Prabhakar Kushwaha | cf0c8cf | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 51 | int dpio_create(struct fsl_mc_io *mc_io, |
| 52 | uint32_t cmd_flags, |
| 53 | const struct dpio_cfg *cfg, |
| 54 | uint16_t *token) |
| 55 | { |
| 56 | struct mc_command cmd = { 0 }; |
| 57 | int err; |
| 58 | |
| 59 | /* prepare command */ |
| 60 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_CREATE, |
| 61 | cmd_flags, |
| 62 | 0); |
| 63 | DPIO_CMD_CREATE(cmd, cfg); |
| 64 | |
| 65 | /* send command to mc*/ |
| 66 | err = mc_send_command(mc_io, &cmd); |
| 67 | if (err) |
| 68 | return err; |
| 69 | |
| 70 | /* retrieve response parameters */ |
| 71 | *token = MC_CMD_HDR_READ_TOKEN(cmd.header); |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | int dpio_destroy(struct fsl_mc_io *mc_io, |
| 77 | uint32_t cmd_flags, |
| 78 | uint16_t token) |
| 79 | { |
| 80 | struct mc_command cmd = { 0 }; |
| 81 | |
| 82 | /* prepare command */ |
| 83 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_DESTROY, |
| 84 | cmd_flags, |
| 85 | token); |
| 86 | |
| 87 | /* send command to mc*/ |
| 88 | return mc_send_command(mc_io, &cmd); |
| 89 | } |
| 90 | |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 91 | int dpio_enable(struct fsl_mc_io *mc_io, |
| 92 | uint32_t cmd_flags, |
| 93 | uint16_t token) |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 94 | { |
| 95 | struct mc_command cmd = { 0 }; |
| 96 | |
| 97 | /* prepare command */ |
| 98 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_ENABLE, |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 99 | cmd_flags, |
| 100 | token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 101 | |
| 102 | /* send command to mc*/ |
| 103 | return mc_send_command(mc_io, &cmd); |
| 104 | } |
| 105 | |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 106 | int dpio_disable(struct fsl_mc_io *mc_io, |
| 107 | uint32_t cmd_flags, |
| 108 | uint16_t token) |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 109 | { |
| 110 | struct mc_command cmd = { 0 }; |
| 111 | |
| 112 | /* prepare command */ |
| 113 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_DISABLE, |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 114 | cmd_flags, |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 115 | token); |
| 116 | |
| 117 | /* send command to mc*/ |
| 118 | return mc_send_command(mc_io, &cmd); |
| 119 | } |
| 120 | |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 121 | int dpio_reset(struct fsl_mc_io *mc_io, |
| 122 | uint32_t cmd_flags, |
| 123 | uint16_t token) |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 124 | { |
| 125 | struct mc_command cmd = { 0 }; |
| 126 | |
| 127 | /* prepare command */ |
| 128 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_RESET, |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 129 | cmd_flags, |
| 130 | token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 131 | |
| 132 | /* send command to mc*/ |
| 133 | return mc_send_command(mc_io, &cmd); |
| 134 | } |
| 135 | |
| 136 | int dpio_get_attributes(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 137 | uint32_t cmd_flags, |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 138 | uint16_t token, |
| 139 | struct dpio_attr *attr) |
| 140 | { |
| 141 | struct mc_command cmd = { 0 }; |
| 142 | int err; |
| 143 | |
| 144 | /* prepare command */ |
| 145 | cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_ATTR, |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 146 | cmd_flags, |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 147 | token); |
| 148 | |
| 149 | /* send command to mc*/ |
| 150 | err = mc_send_command(mc_io, &cmd); |
| 151 | if (err) |
| 152 | return err; |
| 153 | |
| 154 | /* retrieve response parameters */ |
| 155 | DPIO_RSP_GET_ATTR(cmd, attr); |
| 156 | |
| 157 | return 0; |
| 158 | } |