Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0
0002 
0003 ====================================================================
0004 Notes on Oxford Semiconductor PCIe (Tornado) 950 serial port devices
0005 ====================================================================
0006 
0007 Oxford Semiconductor PCIe (Tornado) 950 serial port devices are driven
0008 by a fixed 62.5MHz clock input derived from the 100MHz PCI Express clock.
0009 
0010 The baud rate produced by the baud generator is obtained from this input
0011 frequency by dividing it by the clock prescaler, which can be set to any
0012 value from 1 to 63.875 in increments of 0.125, and then the usual 16-bit
0013 divisor is used as with the original 8250, to divide the frequency by a
0014 value from 1 to 65535.  Finally a programmable oversampling rate is used
0015 that can take any value from 4 to 16 to divide the frequency further and
0016 determine the actual baud rate used.  Baud rates from 15625000bps down
0017 to 0.933bps can be obtained this way.
0018 
0019 By default the oversampling rate is set to 16 and the clock prescaler is
0020 set to 33.875, meaning that the frequency to be used as the reference
0021 for the usual 16-bit divisor is 115313.653, which is close enough to the
0022 frequency of 115200 used by the original 8250 for the same values to be
0023 used for the divisor to obtain the requested baud rates by software that
0024 is unaware of the extra clock controls available.
0025 
0026 The oversampling rate is programmed with the TCR register and the clock
0027 prescaler is programmed with the CPR/CPR2 register pair [OX200]_ [OX952]_
0028 [OX954]_ [OX958]_.  To switch away from the default value of 33.875 for
0029 the prescaler the enhanced mode has to be explicitly enabled though, by
0030 setting bit 4 of the EFR.  In that mode setting bit 7 in the MCR enables
0031 the prescaler or otherwise it is bypassed as if the value of 1 was used.
0032 Additionally writing any value to CPR clears CPR2 for compatibility with
0033 old software written for older conventional PCI Oxford Semiconductor
0034 devices that do not have the extra prescaler's 9th bit in CPR2, so the
0035 CPR/CPR2 register pair has to be programmed in the right order.
0036 
0037 By using these parameters rates from 15625000bps down to 1bps can be
0038 obtained, with either exact or highly-accurate actual bit rates for
0039 standard and many non-standard rates.
0040 
0041 Here are the figures for the standard and some non-standard baud rates
0042 (including those quoted in Oxford Semiconductor documentation), giving
0043 the requested rate (r), the actual rate yielded (a) and its deviation
0044 from the requested rate (d), and the values of the oversampling rate
0045 (tcr), the clock prescaler (cpr) and the divisor (div) produced by the
0046 new ``get_divisor`` handler:
0047 
0048 ::
0049 
0050  r: 15625000, a: 15625000.00, d:  0.0000%, tcr:  4, cpr:  1.000, div:     1
0051  r: 12500000, a: 12500000.00, d:  0.0000%, tcr:  5, cpr:  1.000, div:     1
0052  r: 10416666, a: 10416666.67, d:  0.0000%, tcr:  6, cpr:  1.000, div:     1
0053  r:  8928571, a:  8928571.43, d:  0.0000%, tcr:  7, cpr:  1.000, div:     1
0054  r:  7812500, a:  7812500.00, d:  0.0000%, tcr:  8, cpr:  1.000, div:     1
0055  r:  4000000, a:  4000000.00, d:  0.0000%, tcr:  5, cpr:  3.125, div:     1
0056  r:  3686400, a:  3676470.59, d: -0.2694%, tcr:  8, cpr:  2.125, div:     1
0057  r:  3500000, a:  3496503.50, d: -0.0999%, tcr: 13, cpr:  1.375, div:     1
0058  r:  3000000, a:  2976190.48, d: -0.7937%, tcr: 14, cpr:  1.500, div:     1
0059  r:  2500000, a:  2500000.00, d:  0.0000%, tcr: 10, cpr:  2.500, div:     1
0060  r:  2000000, a:  2000000.00, d:  0.0000%, tcr: 10, cpr:  3.125, div:     1
0061  r:  1843200, a:  1838235.29, d: -0.2694%, tcr: 16, cpr:  2.125, div:     1
0062  r:  1500000, a:  1492537.31, d: -0.4975%, tcr:  5, cpr:  8.375, div:     1
0063  r:  1152000, a:  1152073.73, d:  0.0064%, tcr: 14, cpr:  3.875, div:     1
0064  r:   921600, a:   919117.65, d: -0.2694%, tcr: 16, cpr:  2.125, div:     2
0065  r:   576000, a:   576036.87, d:  0.0064%, tcr: 14, cpr:  3.875, div:     2
0066  r:   460800, a:   460829.49, d:  0.0064%, tcr:  7, cpr:  3.875, div:     5
0067  r:   230400, a:   230414.75, d:  0.0064%, tcr: 14, cpr:  3.875, div:     5
0068  r:   115200, a:   115207.37, d:  0.0064%, tcr: 14, cpr:  1.250, div:    31
0069  r:    57600, a:    57603.69, d:  0.0064%, tcr:  8, cpr:  3.875, div:    35
0070  r:    38400, a:    38402.46, d:  0.0064%, tcr: 14, cpr:  3.875, div:    30
0071  r:    19200, a:    19201.23, d:  0.0064%, tcr:  8, cpr:  3.875, div:   105
0072  r:     9600, a:     9600.06, d:  0.0006%, tcr:  9, cpr:  1.125, div:   643
0073  r:     4800, a:     4799.98, d: -0.0004%, tcr:  7, cpr:  2.875, div:   647
0074  r:     2400, a:     2400.02, d:  0.0008%, tcr:  9, cpr:  2.250, div:  1286
0075  r:     1200, a:     1200.00, d:  0.0000%, tcr: 14, cpr:  2.875, div:  1294
0076  r:      300, a:      300.00, d:  0.0000%, tcr: 11, cpr:  2.625, div:  7215
0077  r:      200, a:      200.00, d:  0.0000%, tcr: 16, cpr:  1.250, div: 15625
0078  r:      150, a:      150.00, d:  0.0000%, tcr: 13, cpr:  2.250, div: 14245
0079  r:      134, a:      134.00, d:  0.0000%, tcr: 11, cpr:  2.625, div: 16153
0080  r:      110, a:      110.00, d:  0.0000%, tcr: 12, cpr:  1.000, div: 47348
0081  r:       75, a:       75.00, d:  0.0000%, tcr:  4, cpr:  5.875, div: 35461
0082  r:       50, a:       50.00, d:  0.0000%, tcr: 16, cpr:  1.250, div: 62500
0083  r:       25, a:       25.00, d:  0.0000%, tcr: 16, cpr:  2.500, div: 62500
0084  r:        4, a:        4.00, d:  0.0000%, tcr: 16, cpr: 20.000, div: 48828
0085  r:        2, a:        2.00, d:  0.0000%, tcr: 16, cpr: 40.000, div: 48828
0086  r:        1, a:        1.00, d:  0.0000%, tcr: 16, cpr: 63.875, div: 61154
0087 
0088 With the baud base set to 15625000 and the unsigned 16-bit UART_DIV_MAX
0089 limitation imposed by ``serial8250_get_baud_rate`` standard baud rates
0090 below 300bps become unavailable in the regular way, e.g. the rate of
0091 200bps requires the baud base to be divided by 78125 and that is beyond
0092 the unsigned 16-bit range.  The historic spd_cust feature can still be
0093 used by encoding the values for, the prescaler, the oversampling rate
0094 and the clock divisor (DLM/DLL) as follows to obtain such rates if so
0095 required:
0096 
0097 ::
0098 
0099   31 29 28             20 19   16 15                            0
0100  +-----+-----------------+-------+-------------------------------+
0101  |0 0 0|    CPR2:CPR     |  TCR  |            DLM:DLL            |
0102  +-----+-----------------+-------+-------------------------------+
0103 
0104 Use a value such encoded for the ``custom_divisor`` field along with the
0105 ASYNC_SPD_CUST flag set in the ``flags`` field in ``struct serial_struct``
0106 passed with the TIOCSSERIAL ioctl(2), such as with the setserial(8)
0107 utility and its ``divisor`` and ``spd_cust`` parameters, and then select
0108 the baud rate of 38400bps.  Note that the value of 0 in TCR sets the
0109 oversampling rate to 16 and prescaler values below 1 in CPR2/CPR are
0110 clamped by the driver to 1.
0111 
0112 For example the value of 0x1f4004e2 will set CPR2/CPR, TCR and DLM/DLL
0113 respectively to 0x1f4, 0x0 and 0x04e2, choosing the prescaler value,
0114 the oversampling rate and the clock divisor of 62.500, 16 and 1250
0115 respectively.  These parameters will set the baud rate for the serial
0116 port to 62500000 / 62.500 / 1250 / 16 = 50bps.
0117 
0118 Maciej W. Rozycki  <macro@orcam.me.uk>
0119 
0120 .. [OX200] "OXPCIe200 PCI Express Multi-Port Bridge", Oxford Semiconductor,
0121    Inc., DS-0045, 10 Nov 2008, Section "950 Mode", pp. 64-65
0122 
0123 .. [OX952] "OXPCIe952 PCI Express Bridge to Dual Serial & Parallel Port",
0124    Oxford Semiconductor, Inc., DS-0046, Mar 06 08, Section "950 Mode",
0125    p. 20
0126 
0127 .. [OX954] "OXPCIe954 PCI Express Bridge to Quad Serial Port", Oxford
0128    Semiconductor, Inc., DS-0047, Feb 08, Section "950 Mode", p. 20
0129 
0130 .. [OX958] "OXPCIe958 PCI Express Bridge to Octal Serial Port", Oxford
0131    Semiconductor, Inc., DS-0048, Feb 08, Section "950 Mode", p. 20