This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void spike_prepare_spi_message(void) | |
{ | |
spi_message_init(&spike_ctl.msg); | |
/* put some changing values in tx_buff for testing */ | |
spike_ctl.tx_buff[0] = spike_dev.test_data++; | |
spike_ctl.tx_buff[1] = spike_dev.test_data++; | |
spike_ctl.tx_buff[2] = spike_dev.test_data++; | |
spike_ctl.tx_buff[3] = spike_dev.test_data++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int spike_do_one_message(void) | |
{ | |
int status; | |
if (down_interruptible(&spike_dev.spi_sem)) | |
return -ERESTARTSYS; | |
if (!spike_dev.spi_device) { | |
up(&spike_dev.spi_sem); | |
return -ENODEV; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int __init add_spike_device_to_bus(void) | |
{ | |
struct spi_master *spi_master; | |
struct spi_device *spi_device; | |
struct device *pdev; | |
char buff[64]; | |
int status = 0; | |
spi_master = spi_busnum_to_master(SPI_BUS); | |
if (!spi_master) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void spike_completion_handler(void *arg) | |
{ | |
spike_ctl.spi_callbacks++; | |
spike_ctl.busy = 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct spike_control { | |
struct spi_message msg; | |
struct spi_transfer transfer; | |
u32 busy; | |
u32 spi_callbacks; | |
u32 busy_counter; | |
u8 *tx_buff; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct spike_control { | |
struct spi_message msg; | |
struct spi_transfer transfer; | |
u32 busy; | |
u32 spi_callbacks; | |
u32 busy_counter; | |
u8 *tx_buff; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int spike_queue_spi_write(void) | |
{ | |
int status; | |
unsigned long flags; | |
spi_message_init(&spike_ctl.msg); | |
/* this gets called when the spi_message completes */ | |
spike_ctl.msg.complete = spike_completion_handler; | |
spike_ctl.msg.context = NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct spike_dev { | |
spinlock_t spi_lock; | |
struct semaphore fop_sem; | |
dev_t devt; | |
struct cdev cdev; | |
struct class *class; | |
struct spi_device *spi_device; | |
struct hrtimer timer; | |
u32 timer_period_sec; | |
u32 timer_period_ns; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static enum hrtimer_restart spike_timer_callback(struct hrtimer *timer) | |
{ | |
if (!spike_dev.running) { | |
return HRTIMER_NORESTART; | |
} | |
/* busy means the previous message has not completed */ | |
if (spike_ctl.busy) { | |
spike_ctl.busy_counter++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct spi_board_info { | |
/* the device name and module name are coupled, like platform_bus; | |
* "modalias" is normally the driver name. | |
* | |
* platform_data goes to spi_device.dev.platform_data, | |
* controller_data goes to spi_device.controller_data, | |
* irq is copied too | |
*/ | |
char modalias[SPI_NAME_SIZE]; | |
const void *platform_data; |
OlderNewer