Commit graph

1015360 commits

Author SHA1 Message Date
Jiri Slaby
57faa7d614 mxser: move board init into mxser_initbrd
What's done in ->probe for board is actually its initialization. So move
it to mxser_initbrd where it belongs.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-44-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:01 +02:00
Jiri Slaby
b441eb0f69 mxser: clean up the rest of MUST helpers
Clean up the rest of MUST helpers. They all can use the newly added
mxser_must_set_EFR. And passing a bool instead of having two functions
(_enable+_disable) simplifies the code a lot too.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-43-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:01 +02:00
Jiri Slaby
b286484b3b mxser: introduce mxser_must_select_bank and use it
Again, selecting a bank in the EFR register is duplicated many times.
Extract it to a separate function (mxser_must_select_bank) and use it on
all the places.

This cleans up most of the helpers. And mxser_get_must_hardware_id now
returns the HW ID directly, not via a by-reference parameter.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-42-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:01 +02:00
Jiri Slaby
edb7d27cd1 mxser: dedup mxser_must_set_enhance_mode
There are multiple copies of setting the EFR register. Separate it to a
new universal function called __mxser_must_set_EFR. And use it in the
code by introducing mxser_must_set_enhance_mode instead of
mxser_disable_must_enchance_mode and mxser_enable_must_enchance_mode.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-41-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:01 +02:00
Jiri Slaby
238d117d17 mxser: simplify mxser_ioctl_op_mode
* ModeMask local array is just inverted OP_MODE_MASK shifted by shiftbit.
  Drop this array and use the value directly.
* return from the if's true branch and drop 'else' branch by moving the
  code completely outside the if.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-40-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:01 +02:00
Jiri Slaby
9fae5f857e mxser: extract mxser_ioctl_op_mode
This ioctl code sets RS232, RS422 or RS485 mode. Move the code to a
separate function (mxser_ioctl_op_mode) with a note that these
mxser-special ioctls should be likely replaced eventually by TIOCGRS485
and TIOCSRS485.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-39-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:01 +02:00
Jiri Slaby
2c21832b55 mxser: cleanup mxser_change_speed
* use UART macros instead of magic constants
* let the default case reuse already existing code (CS5 case)

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-38-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:01 +02:00
Jiri Slaby
d811b26ba3 mxser: drop mxser_port::custom_divisor
It's an once-set constant, so define a macro for the constant
(MXSER_CUSTOM_DIVISOR) and use it in the code instead.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-37-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:01 +02:00
Jiri Slaby
a6970c39c3 mxser: drop mxser_port::baud_base
It's an once-set constant, so define a macro for the constant
(MXSER_BAUD_BASE) and use it in the code instead.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-36-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
01c3de9a10 mxser: remove unused mxser_port::stop_rx
It's been a long time since mxser_port::stop_rx was abandoned. Remove it.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-35-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
cc67399029 mxser: drop unused mxser_port::normal_termios
After the previous patches, mxser_port::normal_termios is unused, so
time to wave bye-bye.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-34-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
389fc82e47 mxser: don't allocate MXSER_PORTS + 1
The MXSER_PORTS's tty_device is never registered and neither its
tty_port instance exists. Hence, it's quite pointless to allocate it.

It used to be used for global information fetches via ioctls. We have
just removed these as non-existent tty_device+tty_port was exactly the
reason to remove the ioctls.

It would be peculiar to add this "virtual" port as we require a backing
tty_port since commit ecbbfd44a0 (TTY: move tty buffers to tty_port)
in 2012.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-33-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
95b3ea4c6f mxser: remove cnt from mxser_receive_chars
After the previous ioctls removal, cnt is needed only in
mxser_receive_chars_old now. So remove it from mxser_receive_chars and
mxser_receive_chars_new and account only in mxser_receive_chars_old.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-32-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
47f8276918 mxser: remove MOXA_HighSpeedOn ioctl
1) The semantics are defined exactly nowhere.
2) The ioctl definition was never exposed to userspace, so noone should
   actually be reliably using this.
3) It's not even mentioned in any of the mxser utilities.

Provided the above, remove this mxser-special ioctl.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-31-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
a7574ca74a mxser: remove MOXA_ASPP_OQUEUE ioctl
1) The semantics are defined exactly nowhere.
2) The ioctl definition was never exposed to userspace, so noone should
   actually be reliably using this.
3) It's not even mentioned in any of the mxser utilities.

Provided the above, remove this mxser-special ioctl.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-30-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
c94deae5b7 mxser: remove MOXA_GETMSTATUS ioctl
1) MOXA_GETMSTATUS is broken at least since commit ecbbfd44a0 (TTY:
   move tty buffers to tty_port) in 2012.
   Even though it's mentioned in the mon_pa moxa utility, obviously
   noone ever tried that in that timeframe.
2) The ioctl definition was never exposed to userspace, so noone
   should actually be reliably using this.

Provided the above, remove this mxser-special ioctl.

And remove the whole concept of mxser_ioctl_special as this was the last
ioctl in there.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-29-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
476c351db8 mxser: remove MOXA_GETDATACOUNT ioctl
1) MOXA_GETDATACOUNT is broken at least since commit ecbbfd44a0 (TTY:
   move tty buffers to tty_port) in 2012.
   Even though it's mentioned in the mon_p moxa utility, obviously noone
   ever tried that in that timeframe.
2) The ioctl definition was never exposed to userspace, so noone should
   actually be reliably using this.

Provided the above, remove this mxser-special ioctl.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-28-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
a1ebc3794e mxser: remove MOXA_CHKPORTENABLE ioctl
1) MOXA_CHKPORTENABLE is broken at least since commit ecbbfd44a0 (TTY:
   move tty buffers to tty_port) in 2012.
2) The ioctl definition was never exposed to userspace, so noone should
   actually be reliably using this.
3) It's not even mentioned in any of the mxser utilities.

Provided the above, remove this mxser-special ioctl.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-27-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
489435e4ab mxser: remove MOXA_ASPP_LSTATUS ioctl
1) The semantics are defined exactly nowhere.
2) The ioctl definition was never exposed to userspace, so noone should
   actually be reliably using this.
3) It's not even mentioned in any of the mxser utilities.

Provided the above, remove this mxser-special ioctl.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-26-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
644c55d229 mxser: remove MOXA_ASPP_MON and friends
1) MOXA_ASPP_MON_EXT is broken at least since commit ecbbfd44a0 (TTY:
   move tty buffers to tty_port) in 2012.
2) The ioctl definitions were never exposed to userspace, so noone should
   actually be reliably using them.
3) They're not even mentioned in any of the mxser utilities.

So remove all these mxser-special ioctls: MOXA_ASPP_MON,
MOXA_ASPP_MON_EXT, and MOXA_SDS_RSTICOUNTER.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-25-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
ef3dff8a0a mxser: remove MOXA_SET_BAUD_METHOD ioctl
1) The semantics are defined exactly nowhere.
2) The ioctl definition was never exposed to userspace, so noone should
   actually be reliably using this.
3) It's not even mentioned in any of the mxser utilities.

Provided the above, remove this mxser-special ioctl.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-24-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:10:00 +02:00
Jiri Slaby
413d555e12 mxser: remove MOXA_GET_MAJOR deprecated ioctl
MOXA_GET_MAJOR was deprecated in commit 41aee9a121 (Char: mxser, ioctl
cleanup) in 2008. Remove this ioctl finally.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-23-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:59 +02:00
Jiri Slaby
a7f8f2c9dc mxser: drop unused MOXA_DIAGNOSE macro
It's unused.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-22-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:59 +02:00
Jiri Slaby
7064005232 mxser: drop UART_MCR_AFE and UART_LSR_SPECIAL defines
* UART_MCR_AFE is a redefinition of serial_reg.h's one.
* UART_LSR_SPECIAL is a redefinition of serial_reg.h's
  UART_LSR_BRK_ERROR_BITS.

So remove both and replace the latter uses by already defined
UART_LSR_BRK_ERROR_BITS.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-21-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:59 +02:00
Jiri Slaby
02e431444b mxser: make xmit ring buffer variables unsigned
Make the xmit ring buffer pointers and counter (xmit_head, xmit_tail,
xmit_cnt) unsigned. Now, the assumptions for the compiler are clear --
they cannot be negative.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-20-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:59 +02:00
Jiri Slaby
a93963e41f mxser: correct types for uart variables
In struct mxser_port, all the UART registers and masks, and the xon/xoff
character are stored into int. Let's re-type all these as UART registers
are 8bit (u8) and xon/xoff character is an unsigned char (cc_t in
ktermios).

This save some bytes in memory, but more importantly the change makes it
what it really is.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-19-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:59 +02:00
Jiri Slaby
6de6e5c4be mxser: remove else from LSR bits checks
UART_LSR_SPECIAL is composed of UART_LSR_BI, UART_LSR_PE, UART_LSR_FE,
UART_LSR_OE. So status cannot be anything else. Remove the unused else
branch.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-18-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:59 +02:00
Jiri Slaby
0c4194218c mxser: extract mxser_receive_chars_old
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-17-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:59 +02:00
Jiri Slaby
e5ce1bceda mxser: extract mxser_receive_chars_new
Extract the new handling of receive chars (using the MUST chip
enhancements) into a separate function. This eliminates the need for the
intr_old label and makes the code of mxser_receive_chars more compact.
In the next step, we will extract the old handling too.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-16-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:59 +02:00
Jiri Slaby
9cb5c9c322 mxser: simplify mxser_interrupt and drop mxser_board::vector_mask
mxser_board::vector_mask is just a bitfield with bits set for all
available ports.  We can obtain this value simply by
"BIT(brd->info->nports) - 1" directly in the ISR. So remove vector_mask
and simplify the code a bit.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-15-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:59 +02:00
Jiri Slaby
9e40ea1f78 mxser: extract port ISR
The ISR is terrible mix of letters. Let's extract the proper per-port
handling to a separate function called mxser_port_isr. This way, we can
actually see what both mxser_interrupt and mxser_port_isr do now.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-14-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:59 +02:00
Jiri Slaby
1551780603 mxser: cleanup LSR handling in mxser_receive_chars
mxser_interrupt is a bit confusing as it passes a pointer to LSR
variable ("status") to mxser_receive_chars. That function can indeed
update the LCR variable. Make this clear by not passing a variable by
reference, instead, return updated status. And change its type
accordingly -- to u8.

Note that the next patches will rework ISR so that even the definition
of status will be u8 soon too.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-13-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:59 +02:00
Jiri Slaby
cef222cbff mxser: remove nonsense from ISR
request_irq was passed a board. There is no need to check dev_id and/or
find the appropriate board in the ISR. Neither check if board is NULL.
Remove this nonsense.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-12-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:59 +02:00
Jiri Slaby
928f946426 mxser: move max_baud from port to board
mxser_port::max_baud is actually a board property, not port's. So move
it to mxser_board.

While at it, drop the printk informing about max baud rate during probe.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-11-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:58 +02:00
Jiri Slaby
58a2ddb3aa mxser: drop constant board::uart_type
board::uart_type is always set to PORT_16550A. So, use this constant in
the code instead. And drop the mxser_board member.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-10-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:58 +02:00
Jiri Slaby
e45583668e mxser: introduce enum mxser_must_hwid
Provided the MUST HW ID is an enumeration, define one (enum
mxser_must_hwid) and use it in the code.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-9-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:58 +02:00
Jiri Slaby
292955a7c0 mxser: rename mxser_board::chip_flag to must_hwid
It is named IsMoxaMustChipFlag in the original Moxa's driver. Over the
time, it was reduced to chip_flag which doesn't make much sense. So dub
it again by what it is: must_hwid (mxser_must_get_hwid assigns to it).

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-8-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:58 +02:00
Jiri Slaby
3b6618299a mxser: rename CheckIsMoxaMust to mxser_get_must_hwid
CheckIsMoxaMust actually finds out what the card is. So rename it to
mxser_must_get_hwid, so that the name conforms to the semantics of the
function.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-7-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:58 +02:00
Jiri Slaby
dc33f644f1 mxser: cleanup Gpci_uart_info struct
The Gpci_uart_info structure contains up to tripled information and
chose weird types for the members. Deduplicate the members and choose
proper types for the data -- everything can be u8 except baud rate.
There, we use speed_t, which is used in this context.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-6-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:58 +02:00
Jiri Slaby
4463cc5b8c mxser: integrate mxser.h into .c
As mxser.h serves only mxser.c, integrate the definitions into .c and
drop .h. There are some "semi-public" ioctl definitions, but they are
mostly go away in the next patches. If something, they would need to
live in an uapi header anyway.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-5-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:58 +02:00
Jiri Slaby
cede216a05 mxser: remove info printout from init
There is no reason/desire to print module information upon module load.
Drop this printk (and a version define).

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-4-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:58 +02:00
Jiri Slaby
1525490269 mxser: renumber mxser_cards
After the ISA cards removal in the previous patch, the mxser_cards array
has holes in it. So renumber the array while updating PCI device's
driver_data.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-3-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:58 +02:00
Jiri Slaby
291343676e mxser: drop ISA support
While mxser PCI cards are still around and produced (Moxa provided me
with two recently), ISA cards are obsolete for a long time. I haven't
seen anyone using the cards and the ISA code paths are barely tested.

Hence, remove ISA support from mxser driver so that we can clean the
driver up.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210618061516.662-2-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-18 13:09:58 +02:00
Ondrej Zary
d495dd743d serial_cs: Add Option International GSM-Ready 56K/ISDN modem
Add support for Option International GSM-Ready 56K/ISDN PCMCIA modem
card.

Signed-off-by: Ondrej Zary <linux@zary.sk>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210611201940.23898-2-linux@zary.sk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-16 09:20:29 +02:00
Ondrej Zary
11b1d881a9 serial_cs: remove wrong GLOBETROTTER.cis entry
The GLOBETROTTER.cis entry in serial_cs matches more devices than
intended and breaks them. Remove it.

Example: # pccardctl info
PRODID_1="Option International
"
PRODID_2="GSM-Ready 56K/ISDN
"
PRODID_3="021
"
PRODID_4="A
"
MANFID=0013,0000
FUNCID=0

result:
pcmcia 0.0: Direct firmware load for cis/GLOBETROTTER.cis failed with error -2

The GLOBETROTTER.cis is nowhere to be found. There's GLOBETROTTER.cis.ihex at
https://netdev.vger.kernel.narkive.com/h4inqdxM/patch-axnet-cs-fix-phy-id-detection-for-bogus-asix-chip#post41
It's from completely diffetent card:
vers_1 4.1, "Option International", "GSM/GPRS GlobeTrotter", "001", "A"

Signed-off-by: Ondrej Zary <linux@zary.sk>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210611201940.23898-1-linux@zary.sk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-16 09:20:29 +02:00
Maciej W. Rozycki
7888478398 MIPS: Malta: Enable magic multipliers for Super I/O UARTs
The SMSC FDC37M817 Super I/O chip has a configuration feature that lets
it support special UART divisor values of 32770 and 32769 for bit rates
of 230400 and 460800 bits per second respectively.  Our 8250 driver core
provides support for these special divisors via the UPF_MAGIC_MULTIPLIER
flag, and YAMON firmware unconditionally configures the Super I/O chip
with these divisors enabled as well, so all we need to do in platform
setup for these bit rates to work is to set the flag.

Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Link: https://lore.kernel.org/r/alpine.DEB.2.21.2105182249380.3032@angie.orcam.me.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-16 09:20:29 +02:00
Maciej W. Rozycki
f7adc73878 serial: 8250: Handle custom baud rates in UPF_MAGIC_MULTIPLIER range
Handle custom baud rates requested in the UPF_MAGIC_MULTIPLIER range
with BOTHER.  Currently matching is exact, that is if a baud rate that
is not either of clk/4 or clk/8 is requested, then we fall through to
the default case, which will just divide the clock rate by 16 times the
rate requested, round it to closest integer, and possibly yield even
worse results then if clamping to the extra baud rates was chosen.

So for example if we have the usual base rate of 115200 and request a
rate of 230399, then the fall-through divisor calculation will yield 1,
and consequently the baud rate of 115200 will be programmed even though
obviously the magic rate of 230400 would be more appropriate.

Make the selection of the magic rates range-qualified then and use clk/4
for rates from clk/6 up (assuming `serial8250_get_baud_rate' has already
rejected any rates too far beyond clk/4), and otherwise use clk/8 for
rates from clk/12 up, and finally fall through to the standard divisor
calculation.  Explicitly void using the undocumented rate of 153600bps
and stick to documented divisor values only.

Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Link: https://lore.kernel.org/r/alpine.DEB.2.21.2105200232090.29169@angie.orcam.me.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-16 09:20:29 +02:00
Maciej W. Rozycki
78bcae8616 serial: 8250: Actually allow UPF_MAGIC_MULTIPLIER baud rates
Support for magic baud rate divisors of 32770 and 32769 used with SMSC
Super I/O chips for extra baud rates of 230400 and 460800 respectively
where base rate is 115200[1] has been added around Linux 2.5.64, which
predates our repo history, but the origin could be identified as commit
2a717aad772f ("Merge with Linux 2.5.64.") with the old MIPS/Linux repo
also at: <git://git.kernel.org/pub/scm/linux/kernel/git/ralf/linux.git>.

Code that is now in `serial8250_do_get_divisor' was added back then to
`serial8250_get_divisor', but that code would only ever trigger if one
of the higher baud rates was actually requested, and that cannot ever
happen, because the earlier call to `serial8250_get_baud_rate' never
returns them.  This is because it calls `uart_get_baud_rate' with the
maximum requested being the base rate, that is clk/16 or 115200 for SMSC
chips at their nominal clock rate.

Fix it then and allow UPF_MAGIC_MULTIPLIER baud rates to be selected, by
requesting the maximum baud rate of clk/4 rather than clk/16 if the flag
has been set.  Also correct the minimum baud rate, observing that these
ports only support actual (non-magic) divisors of up to 32767 only.

References:

[1] "FDC37M81x, PC98/99 Compliant Enhanced Super I/O Controller with
    Keyboard/Mouse Wake-Up", Standard Microsystems Corporation, Rev.
    03/27/2000, Table 31 - "Baud Rates", p. 77

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Link: https://lore.kernel.org/r/alpine.DEB.2.21.2105190412280.29169@angie.orcam.me.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-16 09:20:29 +02:00
Maciej W. Rozycki
b1691bd049 serial: 8250: Document SMSC Super I/O UART peculiarities
Contrary to what SMSC documentation says and unlike NS16C550A UARTs the
SMSC Super I/O IC claims compatibility with the SMSC UART implementation
does not support dividing the internal PLL clock by any divisor from 1
to 65535[1], with the exception of two magic divisors of 32769 and 32770
used respectively to select the high-speed data rates of 460800bps and
230400bps[2] if enabled on a port-by-port basis in with the Serial Port
Mode Register in the Device Configuration Space[3][4].

Instead empirical evidence indicates that the divisor, as stored in the
DLL and DLM register pair, has the range of 1 to 32767 only, and bit 7
of the DLM register (bit 15 of the divisor) effectively serves as a
selection bit for the prescaler from the base frequency of 7.3728MHz,
either 4 if the bit is 0, or 1 if the bit is 1 and high-speed operation
has been enabled with the Serial Port Mode Register.

So if high-speed operation has not been enabled, then say the values of
1 and 32769 (0x8001) written into the combined DLL and DLM register pair
both select the divisor of 1 and the baud rate of 115200bps.

[1] "FDC37M81x, PC98/99 Compliant Enhanced Super I/O Controller with
    Keyboard/Mouse Wake-Up", Standard Microsystems Corporation, Rev.
    03/27/2000, Section "Programmable Baud Rate Generator (and Divisor
    Latches DLH, DLL)", p. 75

[2] same, Table 31 - "Baud Rates", p. 77

[3] same, Table 60 - "Serial Port 1, Logical Device 4 [Logical Device
    Number = 0x04]", p. 153

[4] same, Table 61 - "Serial Port 2, Logical Device 5 [Logical Device
    Number = 0x05]", p. 153

Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Link: https://lore.kernel.org/r/alpine.DEB.2.21.2106092330530.5469@angie.orcam.me.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-16 09:20:29 +02:00
Vignesh Raghavendra
1882441cd7 dt-bindings: serial: Move omap-serial.txt to YAML schema
Convert serial-omap.txt to YAML schema for better checks and documentation.

Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Link: https://lore.kernel.org/r/20210610182227.2480-1-vigneshr@ti.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-16 09:20:29 +02:00