A The notation in device tree
Two. Mailbox Framework (DRIVER/MAILBOX/MAILBOX.C)
structMbox_controller {structDevice *Dev; Assign dev = &pdev->dev when specific mailbox drive probeConst structMbox_chan_ops *ops; function functions to be implemented by mailbox channelstructMbox_chan *Chans; Mailbox Channel pointer ArrayintNum_chans; Mailbox Channel numberBOOLTxdone_irq; To determine whether the last transfer was completed by an interruptBOOLTxdone_poll; //Through the poll mechanism to determine whether the last transmission completed unsigned txpoll_period; POLL cycle, in MS MeterstructMbox_chan * (*of_xlate) (structMbox_controller *mbox,Const structOf_phandle_args *sp); Get callback function for a specific channel/*Internal to API*/ structHrtimer Poll_hrt; structlist_head node;};
structMbox_chan {structMbox_controller *mbox; Contronller pointer unsigned txdone_method; structMbox_client *cl; Client Pointersstructcompletion tx_complete; // void*Active_req; unsigned msg_count, msg_free; void*Msg_data[mbox_tx_queue_len]; spinlock_tLock;/*serialise access to the channel*/ void*Con_priv;};
structMbox_chan_ops {int(*send_data) (structMbox_chan *chan,void*data); Send data (requires last data sent)int(*startup) (structMbox_chan *Chan); Specific mailbox Startupvoid(*shutdown) (structMbox_chan *Chan); Specific mailbox offBOOL(*last_tx_done) (structMbox_chan *Chan); If Txdone_by_poll the callback will be usedBOOL(*peek_data) (structMbox_chan *Chan); Detect if there is data};
structmbox_client {structDevice *Dev; Client DevicesBOOLTx_block; Block until last data was all transmitted unsignedLongtx_tout; Max block period for timeoutBOOLKnows_txdone; Txdone callback, if the controller already has txdone, the configuration is invalidvoid(*rx_callback) (structMbox_client *CL,void*MSSG); Receive Datavoid(*tx_prepare) (structMbox_client *CL,void*MSSG); Preparing Datavoid(*tx_done) (structMbox_client *CL,void*MSSG,intR); Detection Txdone};
Three. Mailbox Client process
Apply channel via Mbox_request_channel_byname according to "Mbox-names"
Create an MBOX device
Access controller through the write read function of the MBOX device
Where write by calling Mbox_send_message,
ADD_TO_RBUF copy msg to Chan->msg_data[max = 20]
Msg_submit Read Msg_data[idx], put in Tx_prepare, call the specific driver of the Send message write register
Where read is driven by an IRQ
The IRQ read register gets the message, calls the Mbox_chan_received_data in mailbox.c, and then calls the client's rx_callback to put the resulting data into client->rx_buffer
Four. Mailbox driver process
To configure the controller properties:
Apply for Chan, configure Chan number
Configure the of_xlate callback to get Chan
Configure Chan_ops
Configure Txdone Judging mode
Registering a controller with Mailbox_controller_register
Five. Summary
Driver Register controller via Mbox_controller_register
Client calls Driver->startup via Mbox_request_channel
The client calls Driver->send_data through Mbox_send_message and waits for Txdone
Driver received remote interrupt read data call Mbox_chan_received_data put data into Client->rx_buffer
Linux Mailbox Model