xref: /OK3568_Linux_fs/kernel/drivers/slimbus/messaging.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (c) 2011-2017, The Linux Foundation
4*4882a593Smuzhiyun  */
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun #include <linux/slab.h>
7*4882a593Smuzhiyun #include <linux/pm_runtime.h>
8*4882a593Smuzhiyun #include "slimbus.h"
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun /**
11*4882a593Smuzhiyun  * slim_msg_response() - Deliver Message response received from a device to the
12*4882a593Smuzhiyun  *			framework.
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  * @ctrl: Controller handle
15*4882a593Smuzhiyun  * @reply: Reply received from the device
16*4882a593Smuzhiyun  * @len: Length of the reply
17*4882a593Smuzhiyun  * @tid: Transaction ID received with which framework can associate reply.
18*4882a593Smuzhiyun  *
19*4882a593Smuzhiyun  * Called by controller to inform framework about the response received.
20*4882a593Smuzhiyun  * This helps in making the API asynchronous, and controller-driver doesn't need
21*4882a593Smuzhiyun  * to manage 1 more table other than the one managed by framework mapping TID
22*4882a593Smuzhiyun  * with buffers
23*4882a593Smuzhiyun  */
slim_msg_response(struct slim_controller * ctrl,u8 * reply,u8 tid,u8 len)24*4882a593Smuzhiyun void slim_msg_response(struct slim_controller *ctrl, u8 *reply, u8 tid, u8 len)
25*4882a593Smuzhiyun {
26*4882a593Smuzhiyun 	struct slim_msg_txn *txn;
27*4882a593Smuzhiyun 	struct slim_val_inf *msg;
28*4882a593Smuzhiyun 	unsigned long flags;
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun 	spin_lock_irqsave(&ctrl->txn_lock, flags);
31*4882a593Smuzhiyun 	txn = idr_find(&ctrl->tid_idr, tid);
32*4882a593Smuzhiyun 	spin_unlock_irqrestore(&ctrl->txn_lock, flags);
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun 	if (txn == NULL)
35*4882a593Smuzhiyun 		return;
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun 	msg = txn->msg;
38*4882a593Smuzhiyun 	if (msg == NULL || msg->rbuf == NULL) {
39*4882a593Smuzhiyun 		dev_err(ctrl->dev, "Got response to invalid TID:%d, len:%d\n",
40*4882a593Smuzhiyun 				tid, len);
41*4882a593Smuzhiyun 		return;
42*4882a593Smuzhiyun 	}
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun 	slim_free_txn_tid(ctrl, txn);
45*4882a593Smuzhiyun 	memcpy(msg->rbuf, reply, len);
46*4882a593Smuzhiyun 	if (txn->comp)
47*4882a593Smuzhiyun 		complete(txn->comp);
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun 	/* Remove runtime-pm vote now that response was received for TID txn */
50*4882a593Smuzhiyun 	pm_runtime_mark_last_busy(ctrl->dev);
51*4882a593Smuzhiyun 	pm_runtime_put_autosuspend(ctrl->dev);
52*4882a593Smuzhiyun }
53*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(slim_msg_response);
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun /**
56*4882a593Smuzhiyun  * slim_alloc_txn_tid() - Allocate a tid to txn
57*4882a593Smuzhiyun  *
58*4882a593Smuzhiyun  * @ctrl: Controller handle
59*4882a593Smuzhiyun  * @txn: transaction to be allocated with tid.
60*4882a593Smuzhiyun  *
61*4882a593Smuzhiyun  * Return: zero on success with valid txn->tid and error code on failures.
62*4882a593Smuzhiyun  */
slim_alloc_txn_tid(struct slim_controller * ctrl,struct slim_msg_txn * txn)63*4882a593Smuzhiyun int slim_alloc_txn_tid(struct slim_controller *ctrl, struct slim_msg_txn *txn)
64*4882a593Smuzhiyun {
65*4882a593Smuzhiyun 	unsigned long flags;
66*4882a593Smuzhiyun 	int ret = 0;
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun 	spin_lock_irqsave(&ctrl->txn_lock, flags);
69*4882a593Smuzhiyun 	ret = idr_alloc_cyclic(&ctrl->tid_idr, txn, 1,
70*4882a593Smuzhiyun 				SLIM_MAX_TIDS, GFP_ATOMIC);
71*4882a593Smuzhiyun 	if (ret < 0) {
72*4882a593Smuzhiyun 		spin_unlock_irqrestore(&ctrl->txn_lock, flags);
73*4882a593Smuzhiyun 		return ret;
74*4882a593Smuzhiyun 	}
75*4882a593Smuzhiyun 	txn->tid = ret;
76*4882a593Smuzhiyun 	spin_unlock_irqrestore(&ctrl->txn_lock, flags);
77*4882a593Smuzhiyun 	return 0;
78*4882a593Smuzhiyun }
79*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(slim_alloc_txn_tid);
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun /**
82*4882a593Smuzhiyun  * slim_free_txn_tid() - Freee tid of txn
83*4882a593Smuzhiyun  *
84*4882a593Smuzhiyun  * @ctrl: Controller handle
85*4882a593Smuzhiyun  * @txn: transaction whose tid should be freed
86*4882a593Smuzhiyun  */
slim_free_txn_tid(struct slim_controller * ctrl,struct slim_msg_txn * txn)87*4882a593Smuzhiyun void slim_free_txn_tid(struct slim_controller *ctrl, struct slim_msg_txn *txn)
88*4882a593Smuzhiyun {
89*4882a593Smuzhiyun 	unsigned long flags;
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun 	spin_lock_irqsave(&ctrl->txn_lock, flags);
92*4882a593Smuzhiyun 	idr_remove(&ctrl->tid_idr, txn->tid);
93*4882a593Smuzhiyun 	spin_unlock_irqrestore(&ctrl->txn_lock, flags);
94*4882a593Smuzhiyun }
95*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(slim_free_txn_tid);
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun /**
98*4882a593Smuzhiyun  * slim_do_transfer() - Process a SLIMbus-messaging transaction
99*4882a593Smuzhiyun  *
100*4882a593Smuzhiyun  * @ctrl: Controller handle
101*4882a593Smuzhiyun  * @txn: Transaction to be sent over SLIMbus
102*4882a593Smuzhiyun  *
103*4882a593Smuzhiyun  * Called by controller to transmit messaging transactions not dealing with
104*4882a593Smuzhiyun  * Interface/Value elements. (e.g. transmittting a message to assign logical
105*4882a593Smuzhiyun  * address to a slave device
106*4882a593Smuzhiyun  *
107*4882a593Smuzhiyun  * Return: -ETIMEDOUT: If transmission of this message timed out
108*4882a593Smuzhiyun  *	(e.g. due to bus lines not being clocked or driven by controller)
109*4882a593Smuzhiyun  */
slim_do_transfer(struct slim_controller * ctrl,struct slim_msg_txn * txn)110*4882a593Smuzhiyun int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn)
111*4882a593Smuzhiyun {
112*4882a593Smuzhiyun 	DECLARE_COMPLETION_ONSTACK(done);
113*4882a593Smuzhiyun 	bool need_tid = false, clk_pause_msg = false;
114*4882a593Smuzhiyun 	int ret, timeout;
115*4882a593Smuzhiyun 
116*4882a593Smuzhiyun 	/*
117*4882a593Smuzhiyun 	 * do not vote for runtime-PM if the transactions are part of clock
118*4882a593Smuzhiyun 	 * pause sequence
119*4882a593Smuzhiyun 	 */
120*4882a593Smuzhiyun 	if (ctrl->sched.clk_state == SLIM_CLK_ENTERING_PAUSE &&
121*4882a593Smuzhiyun 		(txn->mt == SLIM_MSG_MT_CORE &&
122*4882a593Smuzhiyun 		 txn->mc >= SLIM_MSG_MC_BEGIN_RECONFIGURATION &&
123*4882a593Smuzhiyun 		 txn->mc <= SLIM_MSG_MC_RECONFIGURE_NOW))
124*4882a593Smuzhiyun 		clk_pause_msg = true;
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun 	if (!clk_pause_msg) {
127*4882a593Smuzhiyun 		ret = pm_runtime_get_sync(ctrl->dev);
128*4882a593Smuzhiyun 		if (ctrl->sched.clk_state != SLIM_CLK_ACTIVE) {
129*4882a593Smuzhiyun 			dev_err(ctrl->dev, "ctrl wrong state:%d, ret:%d\n",
130*4882a593Smuzhiyun 				ctrl->sched.clk_state, ret);
131*4882a593Smuzhiyun 			goto slim_xfer_err;
132*4882a593Smuzhiyun 		}
133*4882a593Smuzhiyun 	}
134*4882a593Smuzhiyun 	/* Initialize tid to invalid value */
135*4882a593Smuzhiyun 	txn->tid = 0;
136*4882a593Smuzhiyun 	need_tid = slim_tid_txn(txn->mt, txn->mc);
137*4882a593Smuzhiyun 
138*4882a593Smuzhiyun 	if (need_tid) {
139*4882a593Smuzhiyun 		ret = slim_alloc_txn_tid(ctrl, txn);
140*4882a593Smuzhiyun 		if (ret)
141*4882a593Smuzhiyun 			return ret;
142*4882a593Smuzhiyun 
143*4882a593Smuzhiyun 		if (!txn->msg->comp)
144*4882a593Smuzhiyun 			txn->comp = &done;
145*4882a593Smuzhiyun 		else
146*4882a593Smuzhiyun 			txn->comp = txn->comp;
147*4882a593Smuzhiyun 	}
148*4882a593Smuzhiyun 
149*4882a593Smuzhiyun 	ret = ctrl->xfer_msg(ctrl, txn);
150*4882a593Smuzhiyun 
151*4882a593Smuzhiyun 	if (!ret && need_tid && !txn->msg->comp) {
152*4882a593Smuzhiyun 		unsigned long ms = txn->rl + HZ;
153*4882a593Smuzhiyun 
154*4882a593Smuzhiyun 		timeout = wait_for_completion_timeout(txn->comp,
155*4882a593Smuzhiyun 						      msecs_to_jiffies(ms));
156*4882a593Smuzhiyun 		if (!timeout) {
157*4882a593Smuzhiyun 			ret = -ETIMEDOUT;
158*4882a593Smuzhiyun 			slim_free_txn_tid(ctrl, txn);
159*4882a593Smuzhiyun 		}
160*4882a593Smuzhiyun 	}
161*4882a593Smuzhiyun 
162*4882a593Smuzhiyun 	if (ret)
163*4882a593Smuzhiyun 		dev_err(ctrl->dev, "Tx:MT:0x%x, MC:0x%x, LA:0x%x failed:%d\n",
164*4882a593Smuzhiyun 			txn->mt, txn->mc, txn->la, ret);
165*4882a593Smuzhiyun 
166*4882a593Smuzhiyun slim_xfer_err:
167*4882a593Smuzhiyun 	if (!clk_pause_msg && (txn->tid == 0  || ret == -ETIMEDOUT)) {
168*4882a593Smuzhiyun 		/*
169*4882a593Smuzhiyun 		 * remove runtime-pm vote if this was TX only, or
170*4882a593Smuzhiyun 		 * if there was error during this transaction
171*4882a593Smuzhiyun 		 */
172*4882a593Smuzhiyun 		pm_runtime_mark_last_busy(ctrl->dev);
173*4882a593Smuzhiyun 		pm_runtime_put_autosuspend(ctrl->dev);
174*4882a593Smuzhiyun 	}
175*4882a593Smuzhiyun 	return ret;
176*4882a593Smuzhiyun }
177*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(slim_do_transfer);
178*4882a593Smuzhiyun 
slim_val_inf_sanity(struct slim_controller * ctrl,struct slim_val_inf * msg,u8 mc)179*4882a593Smuzhiyun static int slim_val_inf_sanity(struct slim_controller *ctrl,
180*4882a593Smuzhiyun 			       struct slim_val_inf *msg, u8 mc)
181*4882a593Smuzhiyun {
182*4882a593Smuzhiyun 	if (!msg || msg->num_bytes > 16 ||
183*4882a593Smuzhiyun 	    (msg->start_offset + msg->num_bytes) > 0xC00)
184*4882a593Smuzhiyun 		goto reterr;
185*4882a593Smuzhiyun 	switch (mc) {
186*4882a593Smuzhiyun 	case SLIM_MSG_MC_REQUEST_VALUE:
187*4882a593Smuzhiyun 	case SLIM_MSG_MC_REQUEST_INFORMATION:
188*4882a593Smuzhiyun 		if (msg->rbuf != NULL)
189*4882a593Smuzhiyun 			return 0;
190*4882a593Smuzhiyun 		break;
191*4882a593Smuzhiyun 
192*4882a593Smuzhiyun 	case SLIM_MSG_MC_CHANGE_VALUE:
193*4882a593Smuzhiyun 	case SLIM_MSG_MC_CLEAR_INFORMATION:
194*4882a593Smuzhiyun 		if (msg->wbuf != NULL)
195*4882a593Smuzhiyun 			return 0;
196*4882a593Smuzhiyun 		break;
197*4882a593Smuzhiyun 
198*4882a593Smuzhiyun 	case SLIM_MSG_MC_REQUEST_CHANGE_VALUE:
199*4882a593Smuzhiyun 	case SLIM_MSG_MC_REQUEST_CLEAR_INFORMATION:
200*4882a593Smuzhiyun 		if (msg->rbuf != NULL && msg->wbuf != NULL)
201*4882a593Smuzhiyun 			return 0;
202*4882a593Smuzhiyun 		break;
203*4882a593Smuzhiyun 	}
204*4882a593Smuzhiyun reterr:
205*4882a593Smuzhiyun 	if (msg)
206*4882a593Smuzhiyun 		dev_err(ctrl->dev, "Sanity check failed:msg:offset:0x%x, mc:%d\n",
207*4882a593Smuzhiyun 			msg->start_offset, mc);
208*4882a593Smuzhiyun 	return -EINVAL;
209*4882a593Smuzhiyun }
210*4882a593Smuzhiyun 
slim_slicesize(int code)211*4882a593Smuzhiyun static u16 slim_slicesize(int code)
212*4882a593Smuzhiyun {
213*4882a593Smuzhiyun 	static const u8 sizetocode[16] = {
214*4882a593Smuzhiyun 		0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7
215*4882a593Smuzhiyun 	};
216*4882a593Smuzhiyun 
217*4882a593Smuzhiyun 	code = clamp(code, 1, (int)ARRAY_SIZE(sizetocode));
218*4882a593Smuzhiyun 
219*4882a593Smuzhiyun 	return sizetocode[code - 1];
220*4882a593Smuzhiyun }
221*4882a593Smuzhiyun 
222*4882a593Smuzhiyun /**
223*4882a593Smuzhiyun  * slim_xfer_msg() - Transfer a value info message on slim device
224*4882a593Smuzhiyun  *
225*4882a593Smuzhiyun  * @sbdev: slim device to which this msg has to be transfered
226*4882a593Smuzhiyun  * @msg: value info message pointer
227*4882a593Smuzhiyun  * @mc: message code of the message
228*4882a593Smuzhiyun  *
229*4882a593Smuzhiyun  * Called by drivers which want to transfer a vlaue or info elements.
230*4882a593Smuzhiyun  *
231*4882a593Smuzhiyun  * Return: -ETIMEDOUT: If transmission of this message timed out
232*4882a593Smuzhiyun  */
slim_xfer_msg(struct slim_device * sbdev,struct slim_val_inf * msg,u8 mc)233*4882a593Smuzhiyun int slim_xfer_msg(struct slim_device *sbdev, struct slim_val_inf *msg,
234*4882a593Smuzhiyun 		  u8 mc)
235*4882a593Smuzhiyun {
236*4882a593Smuzhiyun 	DEFINE_SLIM_LDEST_TXN(txn_stack, mc, 6, sbdev->laddr, msg);
237*4882a593Smuzhiyun 	struct slim_msg_txn *txn = &txn_stack;
238*4882a593Smuzhiyun 	struct slim_controller *ctrl = sbdev->ctrl;
239*4882a593Smuzhiyun 	int ret;
240*4882a593Smuzhiyun 	u16 sl;
241*4882a593Smuzhiyun 
242*4882a593Smuzhiyun 	if (!ctrl)
243*4882a593Smuzhiyun 		return -EINVAL;
244*4882a593Smuzhiyun 
245*4882a593Smuzhiyun 	ret = slim_val_inf_sanity(ctrl, msg, mc);
246*4882a593Smuzhiyun 	if (ret)
247*4882a593Smuzhiyun 		return ret;
248*4882a593Smuzhiyun 
249*4882a593Smuzhiyun 	sl = slim_slicesize(msg->num_bytes);
250*4882a593Smuzhiyun 
251*4882a593Smuzhiyun 	dev_dbg(ctrl->dev, "SB xfer msg:os:%x, len:%d, MC:%x, sl:%x\n",
252*4882a593Smuzhiyun 		msg->start_offset, msg->num_bytes, mc, sl);
253*4882a593Smuzhiyun 
254*4882a593Smuzhiyun 	txn->ec = ((sl | (1 << 3)) | ((msg->start_offset & 0xFFF) << 4));
255*4882a593Smuzhiyun 
256*4882a593Smuzhiyun 	switch (mc) {
257*4882a593Smuzhiyun 	case SLIM_MSG_MC_REQUEST_CHANGE_VALUE:
258*4882a593Smuzhiyun 	case SLIM_MSG_MC_CHANGE_VALUE:
259*4882a593Smuzhiyun 	case SLIM_MSG_MC_REQUEST_CLEAR_INFORMATION:
260*4882a593Smuzhiyun 	case SLIM_MSG_MC_CLEAR_INFORMATION:
261*4882a593Smuzhiyun 		txn->rl += msg->num_bytes;
262*4882a593Smuzhiyun 	default:
263*4882a593Smuzhiyun 		break;
264*4882a593Smuzhiyun 	}
265*4882a593Smuzhiyun 
266*4882a593Smuzhiyun 	if (slim_tid_txn(txn->mt, txn->mc))
267*4882a593Smuzhiyun 		txn->rl++;
268*4882a593Smuzhiyun 
269*4882a593Smuzhiyun 	return slim_do_transfer(ctrl, txn);
270*4882a593Smuzhiyun }
271*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(slim_xfer_msg);
272*4882a593Smuzhiyun 
slim_fill_msg(struct slim_val_inf * msg,u32 addr,size_t count,u8 * rbuf,u8 * wbuf)273*4882a593Smuzhiyun static void slim_fill_msg(struct slim_val_inf *msg, u32 addr,
274*4882a593Smuzhiyun 			 size_t count, u8 *rbuf, u8 *wbuf)
275*4882a593Smuzhiyun {
276*4882a593Smuzhiyun 	msg->start_offset = addr;
277*4882a593Smuzhiyun 	msg->num_bytes = count;
278*4882a593Smuzhiyun 	msg->rbuf = rbuf;
279*4882a593Smuzhiyun 	msg->wbuf = wbuf;
280*4882a593Smuzhiyun 	msg->comp = NULL;
281*4882a593Smuzhiyun }
282*4882a593Smuzhiyun 
283*4882a593Smuzhiyun /**
284*4882a593Smuzhiyun  * slim_read() - Read SLIMbus value element
285*4882a593Smuzhiyun  *
286*4882a593Smuzhiyun  * @sdev: client handle.
287*4882a593Smuzhiyun  * @addr:  address of value element to read.
288*4882a593Smuzhiyun  * @count: number of bytes to read. Maximum bytes allowed are 16.
289*4882a593Smuzhiyun  * @val: will return what the value element value was
290*4882a593Smuzhiyun  *
291*4882a593Smuzhiyun  * Return: -EINVAL for Invalid parameters, -ETIMEDOUT If transmission of
292*4882a593Smuzhiyun  * this message timed out (e.g. due to bus lines not being clocked
293*4882a593Smuzhiyun  * or driven by controller)
294*4882a593Smuzhiyun  */
slim_read(struct slim_device * sdev,u32 addr,size_t count,u8 * val)295*4882a593Smuzhiyun int slim_read(struct slim_device *sdev, u32 addr, size_t count, u8 *val)
296*4882a593Smuzhiyun {
297*4882a593Smuzhiyun 	struct slim_val_inf msg;
298*4882a593Smuzhiyun 
299*4882a593Smuzhiyun 	slim_fill_msg(&msg, addr, count, val, NULL);
300*4882a593Smuzhiyun 
301*4882a593Smuzhiyun 	return slim_xfer_msg(sdev, &msg, SLIM_MSG_MC_REQUEST_VALUE);
302*4882a593Smuzhiyun }
303*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(slim_read);
304*4882a593Smuzhiyun 
305*4882a593Smuzhiyun /**
306*4882a593Smuzhiyun  * slim_readb() - Read byte from SLIMbus value element
307*4882a593Smuzhiyun  *
308*4882a593Smuzhiyun  * @sdev: client handle.
309*4882a593Smuzhiyun  * @addr:  address in the value element to read.
310*4882a593Smuzhiyun  *
311*4882a593Smuzhiyun  * Return: byte value of value element.
312*4882a593Smuzhiyun  */
slim_readb(struct slim_device * sdev,u32 addr)313*4882a593Smuzhiyun int slim_readb(struct slim_device *sdev, u32 addr)
314*4882a593Smuzhiyun {
315*4882a593Smuzhiyun 	int ret;
316*4882a593Smuzhiyun 	u8 buf;
317*4882a593Smuzhiyun 
318*4882a593Smuzhiyun 	ret = slim_read(sdev, addr, 1, &buf);
319*4882a593Smuzhiyun 	if (ret < 0)
320*4882a593Smuzhiyun 		return ret;
321*4882a593Smuzhiyun 	else
322*4882a593Smuzhiyun 		return buf;
323*4882a593Smuzhiyun }
324*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(slim_readb);
325*4882a593Smuzhiyun 
326*4882a593Smuzhiyun /**
327*4882a593Smuzhiyun  * slim_write() - Write SLIMbus value element
328*4882a593Smuzhiyun  *
329*4882a593Smuzhiyun  * @sdev: client handle.
330*4882a593Smuzhiyun  * @addr:  address in the value element to write.
331*4882a593Smuzhiyun  * @count: number of bytes to write. Maximum bytes allowed are 16.
332*4882a593Smuzhiyun  * @val: value to write to value element
333*4882a593Smuzhiyun  *
334*4882a593Smuzhiyun  * Return: -EINVAL for Invalid parameters, -ETIMEDOUT If transmission of
335*4882a593Smuzhiyun  * this message timed out (e.g. due to bus lines not being clocked
336*4882a593Smuzhiyun  * or driven by controller)
337*4882a593Smuzhiyun  */
slim_write(struct slim_device * sdev,u32 addr,size_t count,u8 * val)338*4882a593Smuzhiyun int slim_write(struct slim_device *sdev, u32 addr, size_t count, u8 *val)
339*4882a593Smuzhiyun {
340*4882a593Smuzhiyun 	struct slim_val_inf msg;
341*4882a593Smuzhiyun 
342*4882a593Smuzhiyun 	slim_fill_msg(&msg, addr, count,  NULL, val);
343*4882a593Smuzhiyun 
344*4882a593Smuzhiyun 	return slim_xfer_msg(sdev, &msg, SLIM_MSG_MC_CHANGE_VALUE);
345*4882a593Smuzhiyun }
346*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(slim_write);
347*4882a593Smuzhiyun 
348*4882a593Smuzhiyun /**
349*4882a593Smuzhiyun  * slim_writeb() - Write byte to SLIMbus value element
350*4882a593Smuzhiyun  *
351*4882a593Smuzhiyun  * @sdev: client handle.
352*4882a593Smuzhiyun  * @addr:  address of value element to write.
353*4882a593Smuzhiyun  * @value: value to write to value element
354*4882a593Smuzhiyun  *
355*4882a593Smuzhiyun  * Return: -EINVAL for Invalid parameters, -ETIMEDOUT If transmission of
356*4882a593Smuzhiyun  * this message timed out (e.g. due to bus lines not being clocked
357*4882a593Smuzhiyun  * or driven by controller)
358*4882a593Smuzhiyun  *
359*4882a593Smuzhiyun  */
slim_writeb(struct slim_device * sdev,u32 addr,u8 value)360*4882a593Smuzhiyun int slim_writeb(struct slim_device *sdev, u32 addr, u8 value)
361*4882a593Smuzhiyun {
362*4882a593Smuzhiyun 	return slim_write(sdev, addr, 1, &value);
363*4882a593Smuzhiyun }
364*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(slim_writeb);
365