Ignore:
Timestamp:
2018-02-12T20:16:44Z (7 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
448e093
Parents:
8192d8a
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-12 20:16:44)
git-committer:
GitHub <noreply@…> (2018-02-12 20:16:44)
Message:

Generalize ns16550 driver to work with more chips. (#20)

Some UART controllers are compatible with 16550A, but have more spacing
between registers. In particular, ARMADA 385, which is the basis of
Turris Omnia router, has a compatible UART with 32b registers instead of 8b
(with the top three bytes unused).

Note: The device tree file hints that some UARTs may need register reads/writes
that are wider than 8 bits, and this commit does not address that possibility.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/include/genarch/drivers/ns16550/ns16550.h

    r8192d8a r38b0ae2  
    5050
    5151/** NS16550 registers. */
    52 typedef struct {
    53         union {
    54                 ioport8_t rbr;      /**< Receiver Buffer Register (read). */
    55                 ioport8_t thr;      /**< Transmitter Holder Register (write). */
    56         } __attribute__ ((packed));
    57         ioport8_t ier;      /**< Interrupt Enable Register. */
    58         union {
    59                 ioport8_t iir;  /**< Interrupt Ident Register (read). */
    60                 ioport8_t fcr;  /**< FIFO control register (write). */
    61         } __attribute__ ((packed));
    62         ioport8_t lcr;      /**< Line Control register. */
    63         ioport8_t mcr;      /**< Modem Control Register. */
    64         ioport8_t lsr;      /**< Line Status Register. */
    65 } __attribute__ ((packed)) ns16550_t;
     52enum {
     53        NS16550_REG_RBR = 0,  /**< Receiver Buffer Register (read). */
     54        NS16550_REG_THR = 0,  /**< Transmitter Holder Register (write). */
     55        NS16550_REG_IER = 1,  /**< Interrupt Enable Register. */
     56        NS16550_REG_IIR = 2,  /**< Interrupt Ident Register (read). */
     57        NS16550_REG_FCR = 2,  /**< FIFO control register (write). */
     58        NS16550_REG_LCR = 3,  /**< Line Control register. */
     59        NS16550_REG_MCR = 4,  /**< Modem Control Register. */
     60        NS16550_REG_LSR = 5,  /**< Line Status Register. */
     61};
    6662
    6763/** Structure representing the ns16550 device. */
    6864typedef struct {
    6965        irq_t irq;
    70         ns16550_t *ns16550;
     66        volatile ioport8_t *ns16550;
    7167        indev_t *input;
    7268        outdev_t *output;
    7369        parea_t parea;
     70        int reg_shift;
    7471} ns16550_instance_t;
    7572
    76 extern ns16550_instance_t *ns16550_init(ns16550_t *, inr_t, cir_t, void *,
     73extern ns16550_instance_t *ns16550_init(ioport8_t *, int, inr_t, cir_t, void *,
    7774    outdev_t **);
    7875extern void ns16550_wire(ns16550_instance_t *, indev_t *);
Note: See TracChangeset for help on using the changeset viewer.