summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/uart.c
Commit message (Collapse)AuthorAgeFilesLines
* greybus: gbphy: Remove protocol specific version handlingViresh Kumar2016-05-311-4/+0
| | | | | | | | | | | | | | | | | We should be using the generic version handling at bundle level, instead of at protocol level for bridged PHY devices as well. The bundle version handling is already in place, though it is *not* used today as we haven't bumped the version of control protocol yet. Remove protocol specific handling for bridged PHY devices. Tested on EVT 1.5 with gpbridge-test module. No nuttx changes are required with this. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: wait for credits on shutdownAxel Haslam2016-05-311-0/+31
| | | | | | | | | | | | | We should try to wait until all credits are accounted for before returning from shutdown. For this purpose add a helper function that will wait on completion, and call it form the shutdown. This helper will also be useful when "wait until sent" is implemented. Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Implement flush_bufferAxel Haslam2016-05-311-0/+15
| | | | | | | | | | | | | | Data may be held pening in the hardware because of flow control mechanisms. When the port is closed, we need to flush all data that was not sent. For this, use the greybus message GB_UART_TYPE_FLUSH_FIFOS which will flush all data queued on the module but not yet sent on the data line. Suggested-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Add credits based tracking for transmit pathAxel Haslam2016-05-311-1/+65
| | | | | | | | | | | | | | | | | | | | | To avoid polling the firmware for space, a credit based system is implemented. The host will keep track of how many credits (bytes) it has sent to the firmware, and stop sending data when the quota is filled. The host will be informed that the firmware has more room for data when it handles the receive_credits request message from the firmware, and will continue to write data as credits become available. The firmware and the host may implement an algorithm to aggregate credits, and avoid extra greybus traffic. Suggested-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Use a fifo to send data to the modulesAxel Haslam2016-05-311-18/+105
| | | | | | | | | | | | | | | The firmware now buffers data instead of blocking while the transfer is sent, and the write operation cannot sleep. Instead of using gb_transfer_sync (which sleeps) in the write callback, buffer data in a fifo and send it from from a work queue. The write_room callback will will report 1 byte less that what is really available in the fifo, to leave space for extra characters that may be added by the tty layer. Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Implement dtr_rts callback.Axel Haslam2016-05-311-2/+20
| | | | | | | | | | | | Dtr_dts allows the tty layer to set the flow control lines to the correct state during open and close. Note that locking for newctrl is missing throughout the driver and will be addressed on a separate patch. Suggested-and-reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Handle CRTSCTS flag in termiosAxel Haslam2016-05-311-2/+8
| | | | | | | | | | Handle the CRTSCTS flag in set_termios, so that auto flow control can be turned off. For this, add a new flag in the line coding request specifically for this purpose. Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: gpbridge: rename 'gpbridge' to 'gbphy' everywhereSandeep Patil2016-05-191-24/+24
| | | | | | | | | | | | | | The 'gpbridge' name didn't relaly reflect what the bus is; which is a bus for bridged-phy devices. So, rename all instances of 'gpbridge' to more appropriate 'gbphy' Testing Done: Build and boot tested. 'lsgb' will stop displaying 'GPBridge' devices until I change the library to reflect this change. Signed-off-by: Sandeep Patil <patil_sandeep@projectara.com> Suggested-by: Greg Kroah-Hartman <gregkh@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart fix missing negation on DTR settingAxel Haslam2016-05-181-1/+1
| | | | | | | | The unset the DTR flag is missing "~" Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Create separate moduleViresh Kumar2016-05-141-2/+7
| | | | | | | | | | Create separate module for uart gpbridge driver. Tested on EVT 1.5 by inserting GP test module, all the devices were enumerated correctly. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Kill reference_count hackViresh Kumar2016-05-051-25/+26
| | | | | | | | | | | | | | | This was done long back and was probably the best bet then, but it looks really bad to have it this way now. Kill the hack and implement proper driver init()/exit() routines to do the same thing. Tested using gbsim by hotplugging uart manifest and removing it later. Also tried removing the gb-phy module to test the exit path properly. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: UART: convert to a gpbridge driverGreg Kroah-Hartman2016-05-051-41/+73
| | | | | | | | | | | | | | | This converts the UART driver to be a gpbridge driver, moving it away from the "legacy" interface. Testing Done: Tested on gbsim. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> [vaibhav.hiremath@linaro.org: 1.Changed code to retain init/exit fns of drivers. 2.Exit path fix. 3. Fixed review comments] Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Tested-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Update line coding settings only when neededAxel Haslam2016-04-211-1/+1
| | | | | | | | | | The check for line coding changed should use memcmp and not memcpy. Testing done: trivial Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: convert drivers to use connection->private set/getGreg Kroah-Hartman2016-03-221-6/+6
| | | | | | | | | | This converts all drivers to use the gb_connection_get_data() and gb_connection_set_data() functions to make it a bit more explicit as to what is going on. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: gpbridge.h: move protocol init/exit prototypesGreg Kroah-Hartman2016-03-031-0/+1
| | | | | | | | | Create gpbridge.h for the gpbridge-specific function prototypes, the rest of the greybus drivers don't care about them. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
* greybus: uart: fix incomplete receive-data sanity checksJohan Hovold2016-02-241-9/+24
| | | | | | | | | | | | | | | | | Fix incomplete receive-data sanity checks. The payload size was never verified before parsing the uart header and neither was the uart-header data size verified against the actual payload size, something which could lead to information leaks when passing data beyond the payload buffer to the tty layer. Also remove the incorrect check against the maximum (tx-buffer) payload size. Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: add missing serial-state sanity checkJohan Hovold2016-02-241-4/+22
| | | | | | | | | | Add dedicated serial-state request handler and add the missing sanity check on the incoming request. Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: add max-payload sanity checkJohan Hovold2016-02-241-2/+8
| | | | | | | | | | Let's be well behaved and add a sanity check on the maximum greybus payload size to avoid underflow on the calculated buffer size. Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: properly calculate max buffer sizeGreg Kroah-Hartman2016-02-231-6/+3
| | | | | | | | | | | | | | We forgot to count the size of the uart send data message header when calculating the maximum size of the buffer that the uart driver could send in one chunk. This fixes the math and makes the variable a size_t to match the return value of the call to gb_operation_get_payload_size_max(); Reported-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Tested-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: fix double free of tty portRui Miguel Silva2016-02-051-1/+0
| | | | | | | | | When inserting and removing a module with a UART protocol defined a double free of the tty_port would happen and that would generate a lot of kernel oops in different places related to memory corruption. Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: Prefix hexadecimal values with 0x while printing themViresh Kumar2015-12-041-1/+1
| | | | | | | | | | To clearly specify the base for printed values, prefix hexadecimal values with 0x. Suggested-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: use the bundle struct device instead of the connectorGreg Kroah-Hartman2015-10-151-5/+5
| | | | | | | | | | | | We are removing struct device from the gb_connection structure in the near future. The gb_bundle structure's struct device should be used as a replacement. This patch moves the uart driver to use the bundle pointer instead of the connection pointer. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Reviewed-by: Alex Elder <elder@linaro.org>
* greybus: uart: Drop get_version supportViresh Kumar2015-08-111-13/+3
| | | | | | | This is done from a common place now, no need to replicate it. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Use (already defined) major/minor macrosViresh Kumar2015-08-101-2/+2
| | | | | | | | We already have macros for these, use them instead of writing fixed values. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: fix typo in defintionBryan O'Donoghue2015-07-141-1/+1
| | | | | | | | | | Fixing needless redefinition of operation types in gbsim reveals this typo GB_UART_TYPE_SET_BREAK -> GB_UART_TYPE_SEND_BREAK. This patch should be applied in lock-step to the patch to gbsim 'gbsim/uart: remove unnecessary redefinition of operation types' since gbsim does not contain the typo. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: properly cleanup ida and idr structures when shutting downGreg Kroah-Hartman2015-07-081-0/+1
| | | | | | | | | idr and ida structures have internal memory allocated that needs to be freed when modules are removed. So call the proper idr_destroy() or ida_destroy() functions on the module exit path to free the memory. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Reviewed-by: Alex Elder <elder@linaro.org>
* greybus: Rename gb_gpbridge_protocol_driver() as gb_builtin_protocol_driver()Viresh Kumar2015-07-011-1/+1
| | | | | | | | | | | This macro is also required by core protocols like control and svc, and hence the 'gpbridge' name doesn't fit anymore. Lets call this macro gb_builtin_protocol_driver(). Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Update UART to reflect field size changesBryan O'Donoghue2015-06-301-7/+7
| | | | | | | | | | | The greybus UART protocol specification was updated to reduce the size of the control field in serial-state-request and line-state-request. This patch updates the kernel protocol driver to reflect the specification changes. Once applied gbsim changes will be also be updated automatically since gbsim depends on the header being modified directly. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Add support for UART error signalsBryan O'Donoghue2015-06-301-19/+40
| | | | | | | | | | After reviewing the UART specification for greybus break, parity, framing and over-run errors were moved to the receive-data message. This patch implements that specification change in the UART protocol driver. Matching code in gbsim has been tested with this change. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Latch modem control signals for tciomgetBryan O'Donoghue2015-06-171-1/+1
| | | | | | | | | | Latch signals coming from UART module for - GB_UART_CTRL_DCD - GB_UART_CTRL_DSR - GB_UART_CTRL_RI Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: fix the clean up while uart initiates connection unsucessfullyPhong Tran2015-06-111-6/+12
| | | | | | | | There is lack of unregister and free the tty driver. This patch fixes it. Signed-off-by: Phong Tran <tranmanphong@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: remove the redundant unregister chrdevPhong Tran2015-06-091-4/+0
| | | | | | | | | | | The unregister_chrdev_region() does twice here. The chrdev region was unregistered inside tty_unregister_driver(). Signed-off-by: Phong Tran <tranmanphong@gmail.com> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: properly interpret receive data sizeAlex Elder2015-06-081-4/+6
| | | | | | | | | In gb_uart_request_recv(), the receive data size is in little-endian format. Do the proper byte swapping of that value before using it. Found by "make check". Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Remove magic numbers make struct gb_tty variable names consistentBryan O'Donoghue2015-06-041-6/+7
| | | | | | | | Use defines for the data format command. Tidy up naming of gb_tty variables. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Add gb_uart_request_recv for receiving async UART dataBryan O'Donoghue2015-06-041-1/+42
| | | | | | | | | | gb_uart_request_recv job in life is to process unsolicited greybus mesages from the UART. Hook the incoming UART data and pass to the TTY layer. Line-state changes still TBD. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: kmalloc for send_data once onlyBryan O'Donoghue2015-06-041-11/+22
| | | | | | | | | | | Make kmalloc for the send buffer a one time alloc based on the MTU for a given greybus link. The write_room for an gb_operation_sync then will be the size of the buffer we use for a single operation. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: send_data should return size or errorBryan O'Donoghue2015-06-041-5/+7
| | | | | | | | gb_operation_sync returns 0 on success but the calling function expects the number of bytes written on success or a negative errno Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Update uart.c to register tty portsBryan O'Donoghue2015-06-041-1/+7
| | | | | | | | | | For each new UART connection we need to do a tty_port_init else we'll crash when trying to access the tty mutex later on. Base the TTY major/minor numbers on non-zero values. Supply an empty operations structure for the newly regitered port. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Reduce UART count from 255 to 16Bryan O'Donoghue2015-06-041-1/+1
| | | | | | | | | Arbitrary number 255 is both not aligned and probably too big. Move the UART count down to 16 which is still large but, more realistic. 8 may be too few for future testing setups, 16 should accomodate any. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Tidy naming convention to more closely match specBryan O'Donoghue2015-06-041-9/+15
| | | | | | | | Update tabs and naming of structures to match the naming used in the greybus specification more closely. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Move UART protocol structs/defines to greybus_protocols.hBryan O'Donoghue2015-06-041-66/+0
| | | | | | | | | gbsim depends on the structures and defines in greybus_protocols.h generally in order to simulate firmware. Move UART defines into this header to facilitate. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: Fix the memory leak in connection initPhong Tran2015-06-041-2/+4
| | | | | | | | If alloc minor is error, gb_tty should free. Signed-off-by: Phong Tran <tranmanphong@gmail.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: Use gb_gpbridge_protocol_init()Viresh Kumar2015-05-201-9/+1
| | | | | | | | Start using gb_gpbridge_protocol_init() in gpbridge drivers. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: eliminate extra response flag definitionsAlex Elder2015-05-071-2/+1
| | | | | | | | | | | | | | | | | | | | All protocols use the same value to distinguish between request and response message types. This is a requirement. Use GB_MESSAGE_TYPE_RESPONSE rather than GB_OPERATION_TYPE_RESPONSE for the name of the flag used to distiguish between request and response messages. Get rid of the redundant response flag definitions that are associated with specific protocols. Describe the symbolic values as "operation types" rather than "message types" where they are defined. The message type for a request is the same as the operation type; the message type for a response is the operation type OR'd with GB_MESSAGE_TYPE_RESPONSE. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: uart: remove packed-attribute from line-coding structJohan Hovold2015-03-171-1/+1
| | | | | | | | Remove packed-attribute from line-coding struct, whose members are all naturally aligned. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: remove unused version-response structsViresh Kumar2015-01-221-5/+0
| | | | | | | | These aren't used anymore and so can be removed. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: create get_version() routines with the help of a macroViresh Kumar2015-01-221-27/+2
| | | | | | | | This gets rid of lots of duplication of code. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: uart: s/REQ/TYPEViresh Kumar2015-01-221-13/+13
| | | | | | | | | | | | Request type for all other protocols is defined like: GB_<protocol>_TYPE_<operation>, but for UART is like: GB_<protocol>_REQ_<operation>. Replace REQ with TYPE to make it consistent. It will also be useful in a later patch that creates get_version() routines with the help of a macro. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: Remove "-gb" suffix from .c filesViresh Kumar2015-01-221-0/+787
Some files are prefixed with "gb-" and some are suffixed with "-gb". The rationale behind the first one is that the modules would be named so, i.e. gb-*.ko. But there is no reason to keep the "-gb" suffix in the second case. Remove the unnecessary suffix. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
OpenPOWER on IntegriCloud