summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/include/nvrm_owr.h
blob: 8aebb28e4ad06b92e09e0ddd40e4d5c8af5fec74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
 * Copyright (c) 2009 NVIDIA Corporation.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of the NVIDIA Corporation nor the names of its contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */

#ifndef INCLUDED_nvrm_owr_H
#define INCLUDED_nvrm_owr_H


#if defined(__cplusplus)
extern "C"
{
#endif

#include "nvrm_pinmux.h"
#include "nvrm_module.h"
#include "nvrm_init.h"

#include "nvos.h"
#include "nvcommon.h"

/**
 * NvRmOwrHandle is an opaque handle for the RM OWR driver.
 */

typedef struct NvRmOwrRec *NvRmOwrHandle;

/**
 * @brief Open the OWR driver. This function allocates the
 * RM OWR handle.
 *
 * Assert encountered in debug mode if passed parameter is invalid.
 *
 * @param hDevice Handle to the Rm device which is required by Rm to acquire
 * the resources from RM.
 * @param instance Instance of the OWR controller to be opened. Starts from 0.
 * @param phOwr Points to the location where the OWR handle shall be stored.
 *
 * @retval NvSuccess OWR driver opened successfully.
 * @retval NvError_InsufficientMemory Indicates that function fails to allocate
 * the memory.
 */

 NvError NvRmOwrOpen(
    NvRmDeviceHandle hDevice,
    NvU32 instance,
    NvRmOwrHandle * hOwr );

/**
 * @brief Closes the OWR driver. Disables the clock and invalidates the OWR handle.
 * This API never fails.
 *
 * @param hOwr A handle from NvRmOwrOpen().  If hOwr is NULL, this API does
 *     nothing.
 */

 void NvRmOwrClose(
    NvRmOwrHandle hOwr );

/**
 * Defines OWR transaction flags.
 */

typedef enum
{

      /// OWR read the unique address of the device.
          NvRmOwr_ReadAddress = 1,

      /// OWR memory read transaction.
          NvRmOwr_MemRead,

      /// OWR memory write transaction.
          NvRmOwr_MemWrite,

      /// OWR memory readbyte transaction.
          NvRmOwr_ReadByte,

      /// OWR memory writebyte transaction.
          NvRmOwr_WriteByte,

      /// OWR memory Check Presence
          NvRmOwr_CheckPresence,

      /// OWR readbit transaction.
      /// The LSB will be received first.
          NvRmOwr_ReadBit,

      /// OWR writebit transaction.
      /// The LSB will be transmitted first.
          NvRmOwr_WriteBit,

    NvRmOwrTransactionFlags_Num,
    NvRmOwrTransactionFlags_Force32 = 0x7FFFFFFF
} NvRmOwrTransactionFlags;

/**
 * Defines OWR transaction info structure. Contains details of the transaction.
 */

typedef struct NvRmOwrTransactionInfoRec
{

    /// Transaction type flags. See @NvRmOwrTransactionFlags
        NvU32 Flags;

    /// Offset in the OWR device where Memory read/write operations need to be performed.
        NvU32 Offset;

    /// Number of bytes to read/write.
        NvU32 NumBytes;

    /// OWR device ROM Id. This can be zero, if there is a single OWR device on the bus.
        NvU32 Address;
} NvRmOwrTransactionInfo;

/**
 * @brief Does multiple OWR transactions. Each transaction can be a read or write.
 *
 * @param hOwr Handle to the OWR channel.
 * @param OwrPinMap for OWR controllers which are being multiplexed across
 *        multiple pin mux configurations, this specifies which pin mux configuration
 *        should be used for the transaction.  Must be 0 when the ODM pin mux query
 *        specifies a non-multiplexed configuration for the controller.
 * @param Data Pointer to the buffer for all the required read, write transactions.
 * @param DataLength Length of the data buffer.
 * @param Transcations Pointer to the NvRmOwrTransactionInfo structure.
 * See @NvRmOwrTransactionInfo
 * @param NumOfTransactions Number of transcations
 *
 *
 * @retval NvSuccess OWR Transaction succeeded.
 * @retval NvError_NotSupported Indicates assumption on parameter values violated.
 * @retval NvError_InvalidState Indicates that the last read or write call is not
 * completed.
 * @retval NvError_ControllerBusy Indicates controller is presently busy with an
 * OWR transaction.
 */

 NvError NvRmOwrTransaction(
    NvRmOwrHandle hOwr,
    NvU32 OwrPinMap,
    NvU8 * Data,
    NvU32 DataLen,
    NvRmOwrTransactionInfo * Transaction,
    NvU32 NumOfTransactions );

#if defined(__cplusplus)
}
#endif

#endif