mirror of
https://github.com/smaeul/u-boot.git
synced 2025-10-14 12:56:00 +01:00
serial: bcm283x_mu: support disabling after initialization
For the Raspberry Pi 3 it needs to be possible to disable the serial device after initialization happens, as only after the GPIO device is available it is known whether the mini uart is usable. Signed-off-by: Fabian Vogt <fvogt@suse.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
ff5d7ae713
commit
cb97ad47bf
@ -59,7 +59,7 @@ static int bcm283x_mu_serial_setbrg(struct udevice *dev, int baudrate)
|
|||||||
struct bcm283x_mu_regs *regs = priv->regs;
|
struct bcm283x_mu_regs *regs = priv->regs;
|
||||||
u32 divider;
|
u32 divider;
|
||||||
|
|
||||||
if (plat->skip_init)
|
if (plat->disabled || plat->skip_init)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
divider = plat->clock / (baudrate * 8);
|
divider = plat->clock / (baudrate * 8);
|
||||||
@ -85,10 +85,14 @@ static int bcm283x_mu_serial_probe(struct udevice *dev)
|
|||||||
|
|
||||||
static int bcm283x_mu_serial_getc(struct udevice *dev)
|
static int bcm283x_mu_serial_getc(struct udevice *dev)
|
||||||
{
|
{
|
||||||
|
struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev);
|
||||||
struct bcm283x_mu_priv *priv = dev_get_priv(dev);
|
struct bcm283x_mu_priv *priv = dev_get_priv(dev);
|
||||||
struct bcm283x_mu_regs *regs = priv->regs;
|
struct bcm283x_mu_regs *regs = priv->regs;
|
||||||
u32 data;
|
u32 data;
|
||||||
|
|
||||||
|
if (plat->disabled)
|
||||||
|
return -EAGAIN;
|
||||||
|
|
||||||
/* Wait until there is data in the FIFO */
|
/* Wait until there is data in the FIFO */
|
||||||
if (!(readl(®s->lsr) & BCM283X_MU_LSR_RX_READY))
|
if (!(readl(®s->lsr) & BCM283X_MU_LSR_RX_READY))
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
@ -100,9 +104,13 @@ static int bcm283x_mu_serial_getc(struct udevice *dev)
|
|||||||
|
|
||||||
static int bcm283x_mu_serial_putc(struct udevice *dev, const char data)
|
static int bcm283x_mu_serial_putc(struct udevice *dev, const char data)
|
||||||
{
|
{
|
||||||
|
struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev);
|
||||||
struct bcm283x_mu_priv *priv = dev_get_priv(dev);
|
struct bcm283x_mu_priv *priv = dev_get_priv(dev);
|
||||||
struct bcm283x_mu_regs *regs = priv->regs;
|
struct bcm283x_mu_regs *regs = priv->regs;
|
||||||
|
|
||||||
|
if (plat->disabled)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* Wait until there is space in the FIFO */
|
/* Wait until there is space in the FIFO */
|
||||||
if (!(readl(®s->lsr) & BCM283X_MU_LSR_TX_EMPTY))
|
if (!(readl(®s->lsr) & BCM283X_MU_LSR_TX_EMPTY))
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
@ -115,9 +123,15 @@ static int bcm283x_mu_serial_putc(struct udevice *dev, const char data)
|
|||||||
|
|
||||||
static int bcm283x_mu_serial_pending(struct udevice *dev, bool input)
|
static int bcm283x_mu_serial_pending(struct udevice *dev, bool input)
|
||||||
{
|
{
|
||||||
|
struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev);
|
||||||
struct bcm283x_mu_priv *priv = dev_get_priv(dev);
|
struct bcm283x_mu_priv *priv = dev_get_priv(dev);
|
||||||
struct bcm283x_mu_regs *regs = priv->regs;
|
struct bcm283x_mu_regs *regs = priv->regs;
|
||||||
unsigned int lsr = readl(®s->lsr);
|
unsigned int lsr;
|
||||||
|
|
||||||
|
if (plat->disabled)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
lsr = readl(®s->lsr);
|
||||||
|
|
||||||
if (input) {
|
if (input) {
|
||||||
WATCHDOG_RESET();
|
WATCHDOG_RESET();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user