spi: Generalize SPI "master" to "controller"
Now struct spi_master is used for both SPI master and slave controllers, it makes sense to rename it to struct spi_controller, and replace "master" by "controller" where appropriate. For now this conversion is done for SPI core infrastructure only. Wrappers are provided for backwards compatibility, until all SPI drivers have been converted. Noteworthy details: - SPI_MASTER_GPIO_SS is retained, as it only makes sense for SPI master controllers, - spi_busnum_to_master() is retained, as it looks up masters only, - A new field spi_device.controller is added, but spi_device.master is retained for compatibility (both are always initialized by spi_alloc_device()), - spi_flash_read() is used by SPI masters only. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
c94085f587
commit
8caab75fd2
1079
drivers/spi/spi.c
1079
drivers/spi/spi.c
File diff suppressed because it is too large
Load Diff
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
struct dma_chan;
|
struct dma_chan;
|
||||||
struct property_entry;
|
struct property_entry;
|
||||||
struct spi_master;
|
struct spi_controller;
|
||||||
struct spi_transfer;
|
struct spi_transfer;
|
||||||
struct spi_flash_read_message;
|
struct spi_flash_read_message;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ struct spi_statistics {
|
||||||
|
|
||||||
void spi_statistics_add_transfer_stats(struct spi_statistics *stats,
|
void spi_statistics_add_transfer_stats(struct spi_statistics *stats,
|
||||||
struct spi_transfer *xfer,
|
struct spi_transfer *xfer,
|
||||||
struct spi_master *master);
|
struct spi_controller *ctlr);
|
||||||
|
|
||||||
#define SPI_STATISTICS_ADD_TO_FIELD(stats, field, count) \
|
#define SPI_STATISTICS_ADD_TO_FIELD(stats, field, count) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -98,13 +98,14 @@ void spi_statistics_add_transfer_stats(struct spi_statistics *stats,
|
||||||
SPI_STATISTICS_ADD_TO_FIELD(stats, field, 1)
|
SPI_STATISTICS_ADD_TO_FIELD(stats, field, 1)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct spi_device - Master side proxy for an SPI slave device
|
* struct spi_device - Controller side proxy for an SPI slave device
|
||||||
* @dev: Driver model representation of the device.
|
* @dev: Driver model representation of the device.
|
||||||
* @master: SPI controller used with the device.
|
* @controller: SPI controller used with the device.
|
||||||
|
* @master: Copy of controller, for backwards compatibility.
|
||||||
* @max_speed_hz: Maximum clock rate to be used with this chip
|
* @max_speed_hz: Maximum clock rate to be used with this chip
|
||||||
* (on this board); may be changed by the device's driver.
|
* (on this board); may be changed by the device's driver.
|
||||||
* The spi_transfer.speed_hz can override this for each transfer.
|
* The spi_transfer.speed_hz can override this for each transfer.
|
||||||
* @chip_select: Chipselect, distinguishing chips handled by @master.
|
* @chip_select: Chipselect, distinguishing chips handled by @controller.
|
||||||
* @mode: The spi mode defines how data is clocked out and in.
|
* @mode: The spi mode defines how data is clocked out and in.
|
||||||
* This may be changed by the device's driver.
|
* This may be changed by the device's driver.
|
||||||
* The "active low" default for chipselect mode can be overridden
|
* The "active low" default for chipselect mode can be overridden
|
||||||
|
@ -140,7 +141,8 @@ void spi_statistics_add_transfer_stats(struct spi_statistics *stats,
|
||||||
*/
|
*/
|
||||||
struct spi_device {
|
struct spi_device {
|
||||||
struct device dev;
|
struct device dev;
|
||||||
struct spi_master *master;
|
struct spi_controller *controller;
|
||||||
|
struct spi_controller *master; /* compatibility layer */
|
||||||
u32 max_speed_hz;
|
u32 max_speed_hz;
|
||||||
u8 chip_select;
|
u8 chip_select;
|
||||||
u8 bits_per_word;
|
u8 bits_per_word;
|
||||||
|
@ -198,7 +200,7 @@ static inline void spi_dev_put(struct spi_device *spi)
|
||||||
put_device(&spi->dev);
|
put_device(&spi->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ctldata is for the bus_master driver's runtime state */
|
/* ctldata is for the bus_controller driver's runtime state */
|
||||||
static inline void *spi_get_ctldata(struct spi_device *spi)
|
static inline void *spi_get_ctldata(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
return spi->controller_state;
|
return spi->controller_state;
|
||||||
|
@ -292,9 +294,9 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
|
||||||
spi_unregister_driver)
|
spi_unregister_driver)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct spi_master - interface to SPI master controller
|
* struct spi_controller - interface to SPI master or slave controller
|
||||||
* @dev: device interface to this driver
|
* @dev: device interface to this driver
|
||||||
* @list: link with the global spi_master list
|
* @list: link with the global spi_controller list
|
||||||
* @bus_num: board-specific (and often SOC-specific) identifier for a
|
* @bus_num: board-specific (and often SOC-specific) identifier for a
|
||||||
* given SPI controller.
|
* given SPI controller.
|
||||||
* @num_chipselect: chipselects are used to distinguish individual
|
* @num_chipselect: chipselects are used to distinguish individual
|
||||||
|
@ -327,8 +329,8 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
|
||||||
* the device whose settings are being modified.
|
* the device whose settings are being modified.
|
||||||
* @transfer: adds a message to the controller's transfer queue.
|
* @transfer: adds a message to the controller's transfer queue.
|
||||||
* @cleanup: frees controller-specific state
|
* @cleanup: frees controller-specific state
|
||||||
* @can_dma: determine whether this master supports DMA
|
* @can_dma: determine whether this controller supports DMA
|
||||||
* @queued: whether this master is providing an internal message queue
|
* @queued: whether this controller is providing an internal message queue
|
||||||
* @kworker: thread struct for message pump
|
* @kworker: thread struct for message pump
|
||||||
* @kworker_task: pointer to task for message pump kworker thread
|
* @kworker_task: pointer to task for message pump kworker thread
|
||||||
* @pump_messages: work struct for scheduling work to the message pump
|
* @pump_messages: work struct for scheduling work to the message pump
|
||||||
|
@ -384,7 +386,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
|
||||||
* @cs_gpios: Array of GPIOs to use as chip select lines; one per CS
|
* @cs_gpios: Array of GPIOs to use as chip select lines; one per CS
|
||||||
* number. Any individual value may be -ENOENT for CS lines that
|
* number. Any individual value may be -ENOENT for CS lines that
|
||||||
* are not GPIOs (driven by the SPI controller itself).
|
* are not GPIOs (driven by the SPI controller itself).
|
||||||
* @statistics: statistics for the spi_master
|
* @statistics: statistics for the spi_controller
|
||||||
* @dma_tx: DMA transmit channel
|
* @dma_tx: DMA transmit channel
|
||||||
* @dma_rx: DMA receive channel
|
* @dma_rx: DMA receive channel
|
||||||
* @dummy_rx: dummy receive buffer for full-duplex devices
|
* @dummy_rx: dummy receive buffer for full-duplex devices
|
||||||
|
@ -393,7 +395,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
|
||||||
* what Linux expects, this optional hook can be used to translate
|
* what Linux expects, this optional hook can be used to translate
|
||||||
* between the two.
|
* between the two.
|
||||||
*
|
*
|
||||||
* Each SPI master controller can communicate with one or more @spi_device
|
* Each SPI controller can communicate with one or more @spi_device
|
||||||
* children. These make a small bus, sharing MOSI, MISO and SCK signals
|
* children. These make a small bus, sharing MOSI, MISO and SCK signals
|
||||||
* but not chip select signals. Each device may be configured to use a
|
* but not chip select signals. Each device may be configured to use a
|
||||||
* different clock rate, since those shared signals are ignored unless
|
* different clock rate, since those shared signals are ignored unless
|
||||||
|
@ -404,7 +406,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
|
||||||
* an SPI slave device. For each such message it queues, it calls the
|
* an SPI slave device. For each such message it queues, it calls the
|
||||||
* message's completion function when the transaction completes.
|
* message's completion function when the transaction completes.
|
||||||
*/
|
*/
|
||||||
struct spi_master {
|
struct spi_controller {
|
||||||
struct device dev;
|
struct device dev;
|
||||||
|
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
|
@ -442,12 +444,13 @@ struct spi_master {
|
||||||
|
|
||||||
/* other constraints relevant to this driver */
|
/* other constraints relevant to this driver */
|
||||||
u16 flags;
|
u16 flags;
|
||||||
#define SPI_MASTER_HALF_DUPLEX BIT(0) /* can't do full duplex */
|
#define SPI_CONTROLLER_HALF_DUPLEX BIT(0) /* can't do full duplex */
|
||||||
#define SPI_MASTER_NO_RX BIT(1) /* can't do buffer read */
|
#define SPI_CONTROLLER_NO_RX BIT(1) /* can't do buffer read */
|
||||||
#define SPI_MASTER_NO_TX BIT(2) /* can't do buffer write */
|
#define SPI_CONTROLLER_NO_TX BIT(2) /* can't do buffer write */
|
||||||
#define SPI_MASTER_MUST_RX BIT(3) /* requires rx */
|
#define SPI_CONTROLLER_MUST_RX BIT(3) /* requires rx */
|
||||||
#define SPI_MASTER_MUST_TX BIT(4) /* requires tx */
|
#define SPI_CONTROLLER_MUST_TX BIT(4) /* requires tx */
|
||||||
#define SPI_MASTER_GPIO_SS BIT(5) /* GPIO CS must select slave */
|
|
||||||
|
#define SPI_MASTER_GPIO_SS BIT(5) /* GPIO CS must select slave */
|
||||||
|
|
||||||
/* flag indicating this is an SPI slave controller */
|
/* flag indicating this is an SPI slave controller */
|
||||||
bool slave;
|
bool slave;
|
||||||
|
@ -485,8 +488,8 @@ struct spi_master {
|
||||||
* any other request management
|
* any other request management
|
||||||
* + To a given spi_device, message queueing is pure fifo
|
* + To a given spi_device, message queueing is pure fifo
|
||||||
*
|
*
|
||||||
* + The master's main job is to process its message queue,
|
* + The controller's main job is to process its message queue,
|
||||||
* selecting a chip then transferring data
|
* selecting a chip (for masters), then transferring data
|
||||||
* + If there are multiple spi_device children, the i/o queue
|
* + If there are multiple spi_device children, the i/o queue
|
||||||
* arbitration algorithm is unspecified (round robin, fifo,
|
* arbitration algorithm is unspecified (round robin, fifo,
|
||||||
* priority, reservations, preemption, etc)
|
* priority, reservations, preemption, etc)
|
||||||
|
@ -499,7 +502,7 @@ struct spi_master {
|
||||||
int (*transfer)(struct spi_device *spi,
|
int (*transfer)(struct spi_device *spi,
|
||||||
struct spi_message *mesg);
|
struct spi_message *mesg);
|
||||||
|
|
||||||
/* called on release() to free memory provided by spi_master */
|
/* called on release() to free memory provided by spi_controller */
|
||||||
void (*cleanup)(struct spi_device *spi);
|
void (*cleanup)(struct spi_device *spi);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -509,13 +512,13 @@ struct spi_master {
|
||||||
* not modify or store xfer and dma_tx and dma_rx must be set
|
* not modify or store xfer and dma_tx and dma_rx must be set
|
||||||
* while the device is prepared.
|
* while the device is prepared.
|
||||||
*/
|
*/
|
||||||
bool (*can_dma)(struct spi_master *master,
|
bool (*can_dma)(struct spi_controller *ctlr,
|
||||||
struct spi_device *spi,
|
struct spi_device *spi,
|
||||||
struct spi_transfer *xfer);
|
struct spi_transfer *xfer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These hooks are for drivers that want to use the generic
|
* These hooks are for drivers that want to use the generic
|
||||||
* master transfer queueing mechanism. If these are used, the
|
* controller transfer queueing mechanism. If these are used, the
|
||||||
* transfer() function above must NOT be specified by the driver.
|
* transfer() function above must NOT be specified by the driver.
|
||||||
* Over time we expect SPI drivers to be phased over to this API.
|
* Over time we expect SPI drivers to be phased over to this API.
|
||||||
*/
|
*/
|
||||||
|
@ -536,15 +539,15 @@ struct spi_master {
|
||||||
struct completion xfer_completion;
|
struct completion xfer_completion;
|
||||||
size_t max_dma_len;
|
size_t max_dma_len;
|
||||||
|
|
||||||
int (*prepare_transfer_hardware)(struct spi_master *master);
|
int (*prepare_transfer_hardware)(struct spi_controller *ctlr);
|
||||||
int (*transfer_one_message)(struct spi_master *master,
|
int (*transfer_one_message)(struct spi_controller *ctlr,
|
||||||
struct spi_message *mesg);
|
struct spi_message *mesg);
|
||||||
int (*unprepare_transfer_hardware)(struct spi_master *master);
|
int (*unprepare_transfer_hardware)(struct spi_controller *ctlr);
|
||||||
int (*prepare_message)(struct spi_master *master,
|
int (*prepare_message)(struct spi_controller *ctlr,
|
||||||
struct spi_message *message);
|
struct spi_message *message);
|
||||||
int (*unprepare_message)(struct spi_master *master,
|
int (*unprepare_message)(struct spi_controller *ctlr,
|
||||||
struct spi_message *message);
|
struct spi_message *message);
|
||||||
int (*slave_abort)(struct spi_master *spi);
|
int (*slave_abort)(struct spi_controller *ctlr);
|
||||||
int (*spi_flash_read)(struct spi_device *spi,
|
int (*spi_flash_read)(struct spi_device *spi,
|
||||||
struct spi_flash_read_message *msg);
|
struct spi_flash_read_message *msg);
|
||||||
bool (*spi_flash_can_dma)(struct spi_device *spi,
|
bool (*spi_flash_can_dma)(struct spi_device *spi,
|
||||||
|
@ -556,9 +559,9 @@ struct spi_master {
|
||||||
* of transfer_one_message() provied by the core.
|
* of transfer_one_message() provied by the core.
|
||||||
*/
|
*/
|
||||||
void (*set_cs)(struct spi_device *spi, bool enable);
|
void (*set_cs)(struct spi_device *spi, bool enable);
|
||||||
int (*transfer_one)(struct spi_master *master, struct spi_device *spi,
|
int (*transfer_one)(struct spi_controller *ctlr, struct spi_device *spi,
|
||||||
struct spi_transfer *transfer);
|
struct spi_transfer *transfer);
|
||||||
void (*handle_err)(struct spi_master *master,
|
void (*handle_err)(struct spi_controller *ctlr,
|
||||||
struct spi_message *message);
|
struct spi_message *message);
|
||||||
|
|
||||||
/* gpio chip select */
|
/* gpio chip select */
|
||||||
|
@ -575,58 +578,59 @@ struct spi_master {
|
||||||
void *dummy_rx;
|
void *dummy_rx;
|
||||||
void *dummy_tx;
|
void *dummy_tx;
|
||||||
|
|
||||||
int (*fw_translate_cs)(struct spi_master *master, unsigned cs);
|
int (*fw_translate_cs)(struct spi_controller *ctlr, unsigned cs);
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void *spi_master_get_devdata(struct spi_master *master)
|
static inline void *spi_controller_get_devdata(struct spi_controller *ctlr)
|
||||||
{
|
{
|
||||||
return dev_get_drvdata(&master->dev);
|
return dev_get_drvdata(&ctlr->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void spi_master_set_devdata(struct spi_master *master, void *data)
|
static inline void spi_controller_set_devdata(struct spi_controller *ctlr,
|
||||||
|
void *data)
|
||||||
{
|
{
|
||||||
dev_set_drvdata(&master->dev, data);
|
dev_set_drvdata(&ctlr->dev, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct spi_master *spi_master_get(struct spi_master *master)
|
static inline struct spi_controller *spi_controller_get(struct spi_controller *ctlr)
|
||||||
{
|
{
|
||||||
if (!master || !get_device(&master->dev))
|
if (!ctlr || !get_device(&ctlr->dev))
|
||||||
return NULL;
|
return NULL;
|
||||||
return master;
|
return ctlr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void spi_master_put(struct spi_master *master)
|
static inline void spi_controller_put(struct spi_controller *ctlr)
|
||||||
{
|
{
|
||||||
if (master)
|
if (ctlr)
|
||||||
put_device(&master->dev);
|
put_device(&ctlr->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool spi_controller_is_slave(struct spi_master *ctlr)
|
static inline bool spi_controller_is_slave(struct spi_controller *ctlr)
|
||||||
{
|
{
|
||||||
return IS_ENABLED(CONFIG_SPI_SLAVE) && ctlr->slave;
|
return IS_ENABLED(CONFIG_SPI_SLAVE) && ctlr->slave;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PM calls that need to be issued by the driver */
|
/* PM calls that need to be issued by the driver */
|
||||||
extern int spi_master_suspend(struct spi_master *master);
|
extern int spi_controller_suspend(struct spi_controller *ctlr);
|
||||||
extern int spi_master_resume(struct spi_master *master);
|
extern int spi_controller_resume(struct spi_controller *ctlr);
|
||||||
|
|
||||||
/* Calls the driver make to interact with the message queue */
|
/* Calls the driver make to interact with the message queue */
|
||||||
extern struct spi_message *spi_get_next_queued_message(struct spi_master *master);
|
extern struct spi_message *spi_get_next_queued_message(struct spi_controller *ctlr);
|
||||||
extern void spi_finalize_current_message(struct spi_master *master);
|
extern void spi_finalize_current_message(struct spi_controller *ctlr);
|
||||||
extern void spi_finalize_current_transfer(struct spi_master *master);
|
extern void spi_finalize_current_transfer(struct spi_controller *ctlr);
|
||||||
|
|
||||||
/* the spi driver core manages memory for the spi_master classdev */
|
/* the spi driver core manages memory for the spi_controller classdev */
|
||||||
extern struct spi_master *__spi_alloc_controller(struct device *host,
|
extern struct spi_controller *__spi_alloc_controller(struct device *host,
|
||||||
unsigned int size, bool slave);
|
unsigned int size, bool slave);
|
||||||
|
|
||||||
static inline struct spi_master *spi_alloc_master(struct device *host,
|
static inline struct spi_controller *spi_alloc_master(struct device *host,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
return __spi_alloc_controller(host, size, false);
|
return __spi_alloc_controller(host, size, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct spi_master *spi_alloc_slave(struct device *host,
|
static inline struct spi_controller *spi_alloc_slave(struct device *host,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
if (!IS_ENABLED(CONFIG_SPI_SLAVE))
|
if (!IS_ENABLED(CONFIG_SPI_SLAVE))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -634,18 +638,18 @@ static inline struct spi_master *spi_alloc_slave(struct device *host,
|
||||||
return __spi_alloc_controller(host, size, true);
|
return __spi_alloc_controller(host, size, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int spi_register_master(struct spi_master *master);
|
extern int spi_register_controller(struct spi_controller *ctlr);
|
||||||
extern int devm_spi_register_master(struct device *dev,
|
extern int devm_spi_register_controller(struct device *dev,
|
||||||
struct spi_master *master);
|
struct spi_controller *ctlr);
|
||||||
extern void spi_unregister_master(struct spi_master *master);
|
extern void spi_unregister_controller(struct spi_controller *ctlr);
|
||||||
|
|
||||||
extern struct spi_master *spi_busnum_to_master(u16 busnum);
|
extern struct spi_controller *spi_busnum_to_master(u16 busnum);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SPI resource management while processing a SPI message
|
* SPI resource management while processing a SPI message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef void (*spi_res_release_t)(struct spi_master *master,
|
typedef void (*spi_res_release_t)(struct spi_controller *ctlr,
|
||||||
struct spi_message *msg,
|
struct spi_message *msg,
|
||||||
void *res);
|
void *res);
|
||||||
|
|
||||||
|
@ -670,7 +674,7 @@ extern void *spi_res_alloc(struct spi_device *spi,
|
||||||
extern void spi_res_add(struct spi_message *message, void *res);
|
extern void spi_res_add(struct spi_message *message, void *res);
|
||||||
extern void spi_res_free(void *res);
|
extern void spi_res_free(void *res);
|
||||||
|
|
||||||
extern void spi_res_release(struct spi_master *master,
|
extern void spi_res_release(struct spi_controller *ctlr,
|
||||||
struct spi_message *message);
|
struct spi_message *message);
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -854,7 +858,7 @@ struct spi_message {
|
||||||
|
|
||||||
/* for optional use by whatever driver currently owns the
|
/* for optional use by whatever driver currently owns the
|
||||||
* spi_message ... between calls to spi_async and then later
|
* spi_message ... between calls to spi_async and then later
|
||||||
* complete(), that's the spi_master controller driver.
|
* complete(), that's the spi_controller controller driver.
|
||||||
*/
|
*/
|
||||||
struct list_head queue;
|
struct list_head queue;
|
||||||
void *state;
|
void *state;
|
||||||
|
@ -943,21 +947,22 @@ extern int spi_slave_abort(struct spi_device *spi);
|
||||||
static inline size_t
|
static inline size_t
|
||||||
spi_max_message_size(struct spi_device *spi)
|
spi_max_message_size(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct spi_master *master = spi->master;
|
struct spi_controller *ctlr = spi->controller;
|
||||||
if (!master->max_message_size)
|
|
||||||
|
if (!ctlr->max_message_size)
|
||||||
return SIZE_MAX;
|
return SIZE_MAX;
|
||||||
return master->max_message_size(spi);
|
return ctlr->max_message_size(spi);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t
|
static inline size_t
|
||||||
spi_max_transfer_size(struct spi_device *spi)
|
spi_max_transfer_size(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct spi_master *master = spi->master;
|
struct spi_controller *ctlr = spi->controller;
|
||||||
size_t tr_max = SIZE_MAX;
|
size_t tr_max = SIZE_MAX;
|
||||||
size_t msg_max = spi_max_message_size(spi);
|
size_t msg_max = spi_max_message_size(spi);
|
||||||
|
|
||||||
if (master->max_transfer_size)
|
if (ctlr->max_transfer_size)
|
||||||
tr_max = master->max_transfer_size(spi);
|
tr_max = ctlr->max_transfer_size(spi);
|
||||||
|
|
||||||
/* transfer size limit must not be greater than messsage size limit */
|
/* transfer size limit must not be greater than messsage size limit */
|
||||||
return min(tr_max, msg_max);
|
return min(tr_max, msg_max);
|
||||||
|
@ -968,7 +973,7 @@ spi_max_transfer_size(struct spi_device *spi)
|
||||||
/* SPI transfer replacement methods which make use of spi_res */
|
/* SPI transfer replacement methods which make use of spi_res */
|
||||||
|
|
||||||
struct spi_replaced_transfers;
|
struct spi_replaced_transfers;
|
||||||
typedef void (*spi_replaced_release_t)(struct spi_master *master,
|
typedef void (*spi_replaced_release_t)(struct spi_controller *ctlr,
|
||||||
struct spi_message *msg,
|
struct spi_message *msg,
|
||||||
struct spi_replaced_transfers *res);
|
struct spi_replaced_transfers *res);
|
||||||
/**
|
/**
|
||||||
|
@ -1012,7 +1017,7 @@ extern struct spi_replaced_transfers *spi_replace_transfers(
|
||||||
|
|
||||||
/* SPI transfer transformation methods */
|
/* SPI transfer transformation methods */
|
||||||
|
|
||||||
extern int spi_split_transfers_maxsize(struct spi_master *master,
|
extern int spi_split_transfers_maxsize(struct spi_controller *ctlr,
|
||||||
struct spi_message *msg,
|
struct spi_message *msg,
|
||||||
size_t maxsize,
|
size_t maxsize,
|
||||||
gfp_t gfp);
|
gfp_t gfp);
|
||||||
|
@ -1026,8 +1031,8 @@ extern int spi_split_transfers_maxsize(struct spi_master *master,
|
||||||
|
|
||||||
extern int spi_sync(struct spi_device *spi, struct spi_message *message);
|
extern int spi_sync(struct spi_device *spi, struct spi_message *message);
|
||||||
extern int spi_sync_locked(struct spi_device *spi, struct spi_message *message);
|
extern int spi_sync_locked(struct spi_device *spi, struct spi_message *message);
|
||||||
extern int spi_bus_lock(struct spi_master *master);
|
extern int spi_bus_lock(struct spi_controller *ctlr);
|
||||||
extern int spi_bus_unlock(struct spi_master *master);
|
extern int spi_bus_unlock(struct spi_controller *ctlr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spi_sync_transfer - synchronous SPI data transfer
|
* spi_sync_transfer - synchronous SPI data transfer
|
||||||
|
@ -1212,9 +1217,9 @@ struct spi_flash_read_message {
|
||||||
/* SPI core interface for flash read support */
|
/* SPI core interface for flash read support */
|
||||||
static inline bool spi_flash_read_supported(struct spi_device *spi)
|
static inline bool spi_flash_read_supported(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
return spi->master->spi_flash_read &&
|
return spi->controller->spi_flash_read &&
|
||||||
(!spi->master->flash_read_supported ||
|
(!spi->controller->flash_read_supported ||
|
||||||
spi->master->flash_read_supported(spi));
|
spi->controller->flash_read_supported(spi));
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_flash_read(struct spi_device *spi,
|
int spi_flash_read(struct spi_device *spi,
|
||||||
|
@ -1247,7 +1252,7 @@ int spi_flash_read(struct spi_device *spi,
|
||||||
* @irq: Initializes spi_device.irq; depends on how the board is wired.
|
* @irq: Initializes spi_device.irq; depends on how the board is wired.
|
||||||
* @max_speed_hz: Initializes spi_device.max_speed_hz; based on limits
|
* @max_speed_hz: Initializes spi_device.max_speed_hz; based on limits
|
||||||
* from the chip datasheet and board-specific signal quality issues.
|
* from the chip datasheet and board-specific signal quality issues.
|
||||||
* @bus_num: Identifies which spi_master parents the spi_device; unused
|
* @bus_num: Identifies which spi_controller parents the spi_device; unused
|
||||||
* by spi_new_device(), and otherwise depends on board wiring.
|
* by spi_new_device(), and otherwise depends on board wiring.
|
||||||
* @chip_select: Initializes spi_device.chip_select; depends on how
|
* @chip_select: Initializes spi_device.chip_select; depends on how
|
||||||
* the board is wired.
|
* the board is wired.
|
||||||
|
@ -1288,7 +1293,7 @@ struct spi_board_info {
|
||||||
|
|
||||||
|
|
||||||
/* bus_num is board specific and matches the bus_num of some
|
/* bus_num is board specific and matches the bus_num of some
|
||||||
* spi_master that will probably be registered later.
|
* spi_controller that will probably be registered later.
|
||||||
*
|
*
|
||||||
* chip_select reflects how this chip is wired to that master;
|
* chip_select reflects how this chip is wired to that master;
|
||||||
* it's less than num_chipselect.
|
* it's less than num_chipselect.
|
||||||
|
@ -1322,7 +1327,7 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
|
||||||
/* If you're hotplugging an adapter with devices (parport, usb, etc)
|
/* If you're hotplugging an adapter with devices (parport, usb, etc)
|
||||||
* use spi_new_device() to describe each device. You can also call
|
* use spi_new_device() to describe each device. You can also call
|
||||||
* spi_unregister_device() to start making that device vanish, but
|
* spi_unregister_device() to start making that device vanish, but
|
||||||
* normally that would be handled by spi_unregister_master().
|
* normally that would be handled by spi_unregister_controller().
|
||||||
*
|
*
|
||||||
* You can also use spi_alloc_device() and spi_add_device() to use a two
|
* You can also use spi_alloc_device() and spi_add_device() to use a two
|
||||||
* stage registration sequence for each spi_device. This gives the caller
|
* stage registration sequence for each spi_device. This gives the caller
|
||||||
|
@ -1331,13 +1336,13 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
|
||||||
* be defined using the board info.
|
* be defined using the board info.
|
||||||
*/
|
*/
|
||||||
extern struct spi_device *
|
extern struct spi_device *
|
||||||
spi_alloc_device(struct spi_master *master);
|
spi_alloc_device(struct spi_controller *ctlr);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
spi_add_device(struct spi_device *spi);
|
spi_add_device(struct spi_device *spi);
|
||||||
|
|
||||||
extern struct spi_device *
|
extern struct spi_device *
|
||||||
spi_new_device(struct spi_master *, struct spi_board_info *);
|
spi_new_device(struct spi_controller *, struct spi_board_info *);
|
||||||
|
|
||||||
extern void spi_unregister_device(struct spi_device *spi);
|
extern void spi_unregister_device(struct spi_device *spi);
|
||||||
|
|
||||||
|
@ -1345,9 +1350,32 @@ extern const struct spi_device_id *
|
||||||
spi_get_device_id(const struct spi_device *sdev);
|
spi_get_device_id(const struct spi_device *sdev);
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
spi_transfer_is_last(struct spi_master *master, struct spi_transfer *xfer)
|
spi_transfer_is_last(struct spi_controller *ctlr, struct spi_transfer *xfer)
|
||||||
{
|
{
|
||||||
return list_is_last(&xfer->transfer_list, &master->cur_msg->transfers);
|
return list_is_last(&xfer->transfer_list, &ctlr->cur_msg->transfers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Compatibility layer */
|
||||||
|
#define spi_master spi_controller
|
||||||
|
|
||||||
|
#define SPI_MASTER_HALF_DUPLEX SPI_CONTROLLER_HALF_DUPLEX
|
||||||
|
#define SPI_MASTER_NO_RX SPI_CONTROLLER_NO_RX
|
||||||
|
#define SPI_MASTER_NO_TX SPI_CONTROLLER_NO_TX
|
||||||
|
#define SPI_MASTER_MUST_RX SPI_CONTROLLER_MUST_RX
|
||||||
|
#define SPI_MASTER_MUST_TX SPI_CONTROLLER_MUST_TX
|
||||||
|
|
||||||
|
#define spi_master_get_devdata(_ctlr) spi_controller_get_devdata(_ctlr)
|
||||||
|
#define spi_master_set_devdata(_ctlr, _data) \
|
||||||
|
spi_controller_set_devdata(_ctlr, _data)
|
||||||
|
#define spi_master_get(_ctlr) spi_controller_get(_ctlr)
|
||||||
|
#define spi_master_put(_ctlr) spi_controller_put(_ctlr)
|
||||||
|
#define spi_master_suspend(_ctlr) spi_controller_suspend(_ctlr)
|
||||||
|
#define spi_master_resume(_ctlr) spi_controller_resume(_ctlr)
|
||||||
|
|
||||||
|
#define spi_register_master(_ctlr) spi_register_controller(_ctlr)
|
||||||
|
#define devm_spi_register_master(_dev, _ctlr) \
|
||||||
|
devm_spi_register_controller(_dev, _ctlr)
|
||||||
|
#define spi_unregister_master(_ctlr) spi_unregister_controller(_ctlr)
|
||||||
|
|
||||||
#endif /* __LINUX_SPI_H */
|
#endif /* __LINUX_SPI_H */
|
||||||
|
|
|
@ -7,37 +7,37 @@
|
||||||
#include <linux/ktime.h>
|
#include <linux/ktime.h>
|
||||||
#include <linux/tracepoint.h>
|
#include <linux/tracepoint.h>
|
||||||
|
|
||||||
DECLARE_EVENT_CLASS(spi_master,
|
DECLARE_EVENT_CLASS(spi_controller,
|
||||||
|
|
||||||
TP_PROTO(struct spi_master *master),
|
TP_PROTO(struct spi_controller *controller),
|
||||||
|
|
||||||
TP_ARGS(master),
|
TP_ARGS(controller),
|
||||||
|
|
||||||
TP_STRUCT__entry(
|
TP_STRUCT__entry(
|
||||||
__field( int, bus_num )
|
__field( int, bus_num )
|
||||||
),
|
),
|
||||||
|
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
__entry->bus_num = master->bus_num;
|
__entry->bus_num = controller->bus_num;
|
||||||
),
|
),
|
||||||
|
|
||||||
TP_printk("spi%d", (int)__entry->bus_num)
|
TP_printk("spi%d", (int)__entry->bus_num)
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
DEFINE_EVENT(spi_master, spi_master_idle,
|
DEFINE_EVENT(spi_controller, spi_controller_idle,
|
||||||
|
|
||||||
TP_PROTO(struct spi_master *master),
|
TP_PROTO(struct spi_controller *controller),
|
||||||
|
|
||||||
TP_ARGS(master)
|
TP_ARGS(controller)
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
DEFINE_EVENT(spi_master, spi_master_busy,
|
DEFINE_EVENT(spi_controller, spi_controller_busy,
|
||||||
|
|
||||||
TP_PROTO(struct spi_master *master),
|
TP_PROTO(struct spi_controller *controller),
|
||||||
|
|
||||||
TP_ARGS(master)
|
TP_ARGS(controller)
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ DECLARE_EVENT_CLASS(spi_message,
|
||||||
),
|
),
|
||||||
|
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
__entry->bus_num = msg->spi->master->bus_num;
|
__entry->bus_num = msg->spi->controller->bus_num;
|
||||||
__entry->chip_select = msg->spi->chip_select;
|
__entry->chip_select = msg->spi->chip_select;
|
||||||
__entry->msg = msg;
|
__entry->msg = msg;
|
||||||
),
|
),
|
||||||
|
@ -95,7 +95,7 @@ TRACE_EVENT(spi_message_done,
|
||||||
),
|
),
|
||||||
|
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
__entry->bus_num = msg->spi->master->bus_num;
|
__entry->bus_num = msg->spi->controller->bus_num;
|
||||||
__entry->chip_select = msg->spi->chip_select;
|
__entry->chip_select = msg->spi->chip_select;
|
||||||
__entry->msg = msg;
|
__entry->msg = msg;
|
||||||
__entry->frame = msg->frame_length;
|
__entry->frame = msg->frame_length;
|
||||||
|
@ -122,7 +122,7 @@ DECLARE_EVENT_CLASS(spi_transfer,
|
||||||
),
|
),
|
||||||
|
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
__entry->bus_num = msg->spi->master->bus_num;
|
__entry->bus_num = msg->spi->controller->bus_num;
|
||||||
__entry->chip_select = msg->spi->chip_select;
|
__entry->chip_select = msg->spi->chip_select;
|
||||||
__entry->xfer = xfer;
|
__entry->xfer = xfer;
|
||||||
__entry->len = xfer->len;
|
__entry->len = xfer->len;
|
||||||
|
|
Loading…
Reference in New Issue