Linux Audio

Check our new training course

Loading...
v6.8
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3 * RapidIO configuration space access support
  4 *
  5 * Copyright 2005 MontaVista Software, Inc.
  6 * Matt Porter <mporter@kernel.crashing.org>
 
 
 
 
 
  7 */
  8
  9#include <linux/rio.h>
 10#include <linux/module.h>
 11
 12#include <linux/rio_drv.h>
 13
 14/*
 15 *  Wrappers for all RIO configuration access functions.  They just check
 16 *  alignment and call the low-level functions pointed to by rio_mport->ops.
 17 */
 18
 19#define RIO_8_BAD 0
 20#define RIO_16_BAD (offset & 1)
 21#define RIO_32_BAD (offset & 3)
 22
 23/**
 24 * RIO_LOP_READ - Generate rio_local_read_config_* functions
 25 * @size: Size of configuration space read (8, 16, 32 bits)
 26 * @type: C type of value argument
 27 * @len: Length of configuration space read (1, 2, 4 bytes)
 28 *
 29 * Generates rio_local_read_config_* functions used to access
 30 * configuration space registers on the local device.
 31 */
 32#define RIO_LOP_READ(size,type,len) \
 33int __rio_local_read_config_##size \
 34	(struct rio_mport *mport, u32 offset, type *value)		\
 35{									\
 36	int res;							\
 37	u32 data = 0;							\
 38	if (RIO_##size##_BAD) return RIO_BAD_SIZE;			\
 39	res = mport->ops->lcread(mport, mport->id, offset, len, &data);	\
 40	*value = (type)data;						\
 41	return res;							\
 42}
 43
 44/**
 45 * RIO_LOP_WRITE - Generate rio_local_write_config_* functions
 46 * @size: Size of configuration space write (8, 16, 32 bits)
 47 * @type: C type of value argument
 48 * @len: Length of configuration space write (1, 2, 4 bytes)
 49 *
 50 * Generates rio_local_write_config_* functions used to access
 51 * configuration space registers on the local device.
 52 */
 53#define RIO_LOP_WRITE(size,type,len) \
 54int __rio_local_write_config_##size \
 55	(struct rio_mport *mport, u32 offset, type value)		\
 56{									\
 57	if (RIO_##size##_BAD) return RIO_BAD_SIZE;			\
 58	return mport->ops->lcwrite(mport, mport->id, offset, len, value);\
 59}
 60
 61RIO_LOP_READ(8, u8, 1)
 62RIO_LOP_READ(16, u16, 2)
 63RIO_LOP_READ(32, u32, 4)
 64RIO_LOP_WRITE(8, u8, 1)
 65RIO_LOP_WRITE(16, u16, 2)
 66RIO_LOP_WRITE(32, u32, 4)
 67
 68EXPORT_SYMBOL_GPL(__rio_local_read_config_8);
 69EXPORT_SYMBOL_GPL(__rio_local_read_config_16);
 70EXPORT_SYMBOL_GPL(__rio_local_read_config_32);
 71EXPORT_SYMBOL_GPL(__rio_local_write_config_8);
 72EXPORT_SYMBOL_GPL(__rio_local_write_config_16);
 73EXPORT_SYMBOL_GPL(__rio_local_write_config_32);
 74
 75/**
 76 * RIO_OP_READ - Generate rio_mport_read_config_* functions
 77 * @size: Size of configuration space read (8, 16, 32 bits)
 78 * @type: C type of value argument
 79 * @len: Length of configuration space read (1, 2, 4 bytes)
 80 *
 81 * Generates rio_mport_read_config_* functions used to access
 82 * configuration space registers on the local device.
 83 */
 84#define RIO_OP_READ(size,type,len) \
 85int rio_mport_read_config_##size \
 86	(struct rio_mport *mport, u16 destid, u8 hopcount, u32 offset, type *value)	\
 87{									\
 88	int res;							\
 89	u32 data = 0;							\
 90	if (RIO_##size##_BAD) return RIO_BAD_SIZE;			\
 91	res = mport->ops->cread(mport, mport->id, destid, hopcount, offset, len, &data); \
 92	*value = (type)data;						\
 93	return res;							\
 94}
 95
 96/**
 97 * RIO_OP_WRITE - Generate rio_mport_write_config_* functions
 98 * @size: Size of configuration space write (8, 16, 32 bits)
 99 * @type: C type of value argument
100 * @len: Length of configuration space write (1, 2, 4 bytes)
101 *
102 * Generates rio_mport_write_config_* functions used to access
103 * configuration space registers on the local device.
104 */
105#define RIO_OP_WRITE(size,type,len) \
106int rio_mport_write_config_##size \
107	(struct rio_mport *mport, u16 destid, u8 hopcount, u32 offset, type value)	\
108{									\
109	if (RIO_##size##_BAD) return RIO_BAD_SIZE;			\
110	return mport->ops->cwrite(mport, mport->id, destid, hopcount,	\
111			offset, len, value);				\
112}
113
114RIO_OP_READ(8, u8, 1)
115RIO_OP_READ(16, u16, 2)
116RIO_OP_READ(32, u32, 4)
117RIO_OP_WRITE(8, u8, 1)
118RIO_OP_WRITE(16, u16, 2)
119RIO_OP_WRITE(32, u32, 4)
120
121EXPORT_SYMBOL_GPL(rio_mport_read_config_8);
122EXPORT_SYMBOL_GPL(rio_mport_read_config_16);
123EXPORT_SYMBOL_GPL(rio_mport_read_config_32);
124EXPORT_SYMBOL_GPL(rio_mport_write_config_8);
125EXPORT_SYMBOL_GPL(rio_mport_write_config_16);
126EXPORT_SYMBOL_GPL(rio_mport_write_config_32);
127
128/**
129 * rio_mport_send_doorbell - Send a doorbell message
130 *
131 * @mport: RIO master port
132 * @destid: RIO device destination ID
133 * @data: Doorbell message data
134 *
135 * Send a doorbell message to a RIO device. The doorbell message
136 * has a 16-bit info field provided by the data argument.
137 */
138int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid, u16 data)
139{
140	return mport->ops->dsend(mport, mport->id, destid, data);
141}
142
143EXPORT_SYMBOL_GPL(rio_mport_send_doorbell);
v4.17
 
  1/*
  2 * RapidIO configuration space access support
  3 *
  4 * Copyright 2005 MontaVista Software, Inc.
  5 * Matt Porter <mporter@kernel.crashing.org>
  6 *
  7 * This program is free software; you can redistribute  it and/or modify it
  8 * under  the terms of  the GNU General  Public License as published by the
  9 * Free Software Foundation;  either version 2 of the  License, or (at your
 10 * option) any later version.
 11 */
 12
 13#include <linux/rio.h>
 14#include <linux/module.h>
 
 
 15
 16/*
 17 *  Wrappers for all RIO configuration access functions.  They just check
 18 *  alignment and call the low-level functions pointed to by rio_mport->ops.
 19 */
 20
 21#define RIO_8_BAD 0
 22#define RIO_16_BAD (offset & 1)
 23#define RIO_32_BAD (offset & 3)
 24
 25/**
 26 * RIO_LOP_READ - Generate rio_local_read_config_* functions
 27 * @size: Size of configuration space read (8, 16, 32 bits)
 28 * @type: C type of value argument
 29 * @len: Length of configuration space read (1, 2, 4 bytes)
 30 *
 31 * Generates rio_local_read_config_* functions used to access
 32 * configuration space registers on the local device.
 33 */
 34#define RIO_LOP_READ(size,type,len) \
 35int __rio_local_read_config_##size \
 36	(struct rio_mport *mport, u32 offset, type *value)		\
 37{									\
 38	int res;							\
 39	u32 data = 0;							\
 40	if (RIO_##size##_BAD) return RIO_BAD_SIZE;			\
 41	res = mport->ops->lcread(mport, mport->id, offset, len, &data);	\
 42	*value = (type)data;						\
 43	return res;							\
 44}
 45
 46/**
 47 * RIO_LOP_WRITE - Generate rio_local_write_config_* functions
 48 * @size: Size of configuration space write (8, 16, 32 bits)
 49 * @type: C type of value argument
 50 * @len: Length of configuration space write (1, 2, 4 bytes)
 51 *
 52 * Generates rio_local_write_config_* functions used to access
 53 * configuration space registers on the local device.
 54 */
 55#define RIO_LOP_WRITE(size,type,len) \
 56int __rio_local_write_config_##size \
 57	(struct rio_mport *mport, u32 offset, type value)		\
 58{									\
 59	if (RIO_##size##_BAD) return RIO_BAD_SIZE;			\
 60	return mport->ops->lcwrite(mport, mport->id, offset, len, value);\
 61}
 62
 63RIO_LOP_READ(8, u8, 1)
 64RIO_LOP_READ(16, u16, 2)
 65RIO_LOP_READ(32, u32, 4)
 66RIO_LOP_WRITE(8, u8, 1)
 67RIO_LOP_WRITE(16, u16, 2)
 68RIO_LOP_WRITE(32, u32, 4)
 69
 70EXPORT_SYMBOL_GPL(__rio_local_read_config_8);
 71EXPORT_SYMBOL_GPL(__rio_local_read_config_16);
 72EXPORT_SYMBOL_GPL(__rio_local_read_config_32);
 73EXPORT_SYMBOL_GPL(__rio_local_write_config_8);
 74EXPORT_SYMBOL_GPL(__rio_local_write_config_16);
 75EXPORT_SYMBOL_GPL(__rio_local_write_config_32);
 76
 77/**
 78 * RIO_OP_READ - Generate rio_mport_read_config_* functions
 79 * @size: Size of configuration space read (8, 16, 32 bits)
 80 * @type: C type of value argument
 81 * @len: Length of configuration space read (1, 2, 4 bytes)
 82 *
 83 * Generates rio_mport_read_config_* functions used to access
 84 * configuration space registers on the local device.
 85 */
 86#define RIO_OP_READ(size,type,len) \
 87int rio_mport_read_config_##size \
 88	(struct rio_mport *mport, u16 destid, u8 hopcount, u32 offset, type *value)	\
 89{									\
 90	int res;							\
 91	u32 data = 0;							\
 92	if (RIO_##size##_BAD) return RIO_BAD_SIZE;			\
 93	res = mport->ops->cread(mport, mport->id, destid, hopcount, offset, len, &data); \
 94	*value = (type)data;						\
 95	return res;							\
 96}
 97
 98/**
 99 * RIO_OP_WRITE - Generate rio_mport_write_config_* functions
100 * @size: Size of configuration space write (8, 16, 32 bits)
101 * @type: C type of value argument
102 * @len: Length of configuration space write (1, 2, 4 bytes)
103 *
104 * Generates rio_mport_write_config_* functions used to access
105 * configuration space registers on the local device.
106 */
107#define RIO_OP_WRITE(size,type,len) \
108int rio_mport_write_config_##size \
109	(struct rio_mport *mport, u16 destid, u8 hopcount, u32 offset, type value)	\
110{									\
111	if (RIO_##size##_BAD) return RIO_BAD_SIZE;			\
112	return mport->ops->cwrite(mport, mport->id, destid, hopcount,	\
113			offset, len, value);				\
114}
115
116RIO_OP_READ(8, u8, 1)
117RIO_OP_READ(16, u16, 2)
118RIO_OP_READ(32, u32, 4)
119RIO_OP_WRITE(8, u8, 1)
120RIO_OP_WRITE(16, u16, 2)
121RIO_OP_WRITE(32, u32, 4)
122
123EXPORT_SYMBOL_GPL(rio_mport_read_config_8);
124EXPORT_SYMBOL_GPL(rio_mport_read_config_16);
125EXPORT_SYMBOL_GPL(rio_mport_read_config_32);
126EXPORT_SYMBOL_GPL(rio_mport_write_config_8);
127EXPORT_SYMBOL_GPL(rio_mport_write_config_16);
128EXPORT_SYMBOL_GPL(rio_mport_write_config_32);
129
130/**
131 * rio_mport_send_doorbell - Send a doorbell message
132 *
133 * @mport: RIO master port
134 * @destid: RIO device destination ID
135 * @data: Doorbell message data
136 *
137 * Send a doorbell message to a RIO device. The doorbell message
138 * has a 16-bit info field provided by the data argument.
139 */
140int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid, u16 data)
141{
142	return mport->ops->dsend(mport, mport->id, destid, data);
143}
144
145EXPORT_SYMBOL_GPL(rio_mport_send_doorbell);