This repository has been archived by the owner on Jan 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIXME: - split up into n patches - describe Signed-off-by: Stephen Warren <[email protected]>
- Loading branch information
Showing
18 changed files
with
297 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* (C) Copyright 2016 Stephen Warren <[email protected]> | ||
* | ||
* SPDX-License-Identifier: GPL-2.0+ | ||
*/ | ||
|
||
#ifndef _BCM2835_AUX_H_ | ||
#define _BCM2835_AUX_H_ | ||
|
||
#ifndef CONFIG_BCM2835 | ||
#define BCM2835_AUX_BASE 0x3f215000 | ||
#else | ||
#define BCM2835_AUX_BASE 0x20215000 | ||
#endif | ||
|
||
#define BCM2835_AUX_ENABLES_SPI2 BIT(0) | ||
#define BCM2835_AUX_ENABLES_SPI1 BIT(0) | ||
#define BCM2835_AUX_ENABLES_MINI_UART BIT(0) | ||
|
||
struct bcm2835_aux_regs { | ||
u32 irq; | ||
u32 enables; | ||
}; | ||
|
||
#endif /* _BCM2835_AXU_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
RPI_3_32B BOARD | ||
M: Stephen Warren <[email protected]> | ||
S: Maintained | ||
F: board/raspberrypi/rpi_3_32b/ | ||
F: include/configs/rpi_3_32b.h | ||
F: configs/rpi_3_32b_defconfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# | ||
# (C) Copyright 2012,2015 Stephen Warren <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# | ||
|
||
obj-y := ../rpi/rpi.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CONFIG_ARM=y | ||
CONFIG_ARCH_BCM283X=y | ||
CONFIG_TARGET_RPI_3_32B=y | ||
CONFIG_SYS_PROMPT="U-Boot> " | ||
# CONFIG_CMD_IMLS is not set | ||
# CONFIG_CMD_FLASH is not set | ||
# CONFIG_CMD_FPGA is not set | ||
CONFIG_CMD_GPIO=y | ||
CONFIG_PHYS_TO_BUS=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* (C) Copyright 2016 Stephen Warren <[email protected]> | ||
* | ||
* Derived from pl01x code: | ||
* | ||
* (C) Copyright 2000 | ||
* Rob Taylor, Flying Pig Systems. [email protected]. | ||
* | ||
* (C) Copyright 2004 | ||
* ARM Ltd. | ||
* Philippe Robin, <[email protected]> | ||
* | ||
* SPDX-License-Identifier: GPL-2.0+ | ||
*/ | ||
|
||
/* Simple U-Boot driver for the BCM283x mini UART */ | ||
|
||
#include <common.h> | ||
#include <dm.h> | ||
#include <errno.h> | ||
#include <watchdog.h> | ||
#include <asm/io.h> | ||
#include <serial.h> | ||
#include <dm/platform_data/serial_bcm283x_mu.h> | ||
#include <linux/compiler.h> | ||
#include <fdtdec.h> | ||
|
||
struct bcm283x_mu_regs { | ||
u32 io; | ||
u32 iir; | ||
u32 ier; | ||
u32 lcr; | ||
u32 mcr; | ||
u32 lsr; | ||
u32 msr; | ||
u32 scratch; | ||
u32 cntl; | ||
u32 stat; | ||
u32 baud; | ||
}; | ||
|
||
#define BCM283X_MU_LCR_DATA_SIZE_8 3 | ||
|
||
#define BCM283X_MU_LSR_TX_IDLE BIT(6) | ||
/* This actually means not full, but is named not empty in the docs */ | ||
#define BCM283X_MU_LSR_TX_EMPTY BIT(5) | ||
#define BCM283X_MU_LSR_RX_READY BIT(0) | ||
|
||
struct bcm283x_mu_priv { | ||
struct bcm283x_mu_regs *regs; | ||
}; | ||
|
||
static int bcm283x_mu_serial_setbrg(struct udevice *dev, int baudrate) | ||
{ | ||
struct bcm283x_mu_priv *priv = dev_get_priv(dev); | ||
struct bcm283x_mu_regs *regs = priv->regs; | ||
/* FIXME: Get this from plat data later */ | ||
u32 clock_rate = 250000000; | ||
u32 divider; | ||
|
||
divider = clock_rate / (baudrate * 8); | ||
|
||
writel(BCM283X_MU_LCR_DATA_SIZE_8, ®s->lcr); | ||
writel(divider - 1, ®s->baud); | ||
|
||
return 0; | ||
} | ||
|
||
static int bcm283x_mu_serial_probe(struct udevice *dev) | ||
{ | ||
struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev); | ||
struct bcm283x_mu_priv *priv = dev_get_priv(dev); | ||
|
||
priv->regs = (struct bcm283x_mu_regs *)plat->base; | ||
|
||
return 0; | ||
} | ||
|
||
static int bcm283x_mu_serial_getc(struct udevice *dev) | ||
{ | ||
struct bcm283x_mu_priv *priv = dev_get_priv(dev); | ||
struct bcm283x_mu_regs *regs = priv->regs; | ||
u32 data; | ||
|
||
/* Wait until there is data in the FIFO */ | ||
if (!(readl(®s->lsr) & BCM283X_MU_LSR_RX_READY)) | ||
return -EAGAIN; | ||
|
||
data = readl(®s->io); | ||
|
||
return (int)data; | ||
} | ||
|
||
static int bcm283x_mu_serial_putc(struct udevice *dev, const char data) | ||
{ | ||
struct bcm283x_mu_priv *priv = dev_get_priv(dev); | ||
struct bcm283x_mu_regs *regs = priv->regs; | ||
|
||
/* Wait until there is space in the FIFO */ | ||
if (!(readl(®s->lsr) & BCM283X_MU_LSR_TX_EMPTY)) | ||
return -EAGAIN; | ||
|
||
/* Send the character */ | ||
writel(data, ®s->io); | ||
|
||
return 0; | ||
} | ||
|
||
static int bcm283x_mu_serial_pending(struct udevice *dev, bool input) | ||
{ | ||
struct bcm283x_mu_priv *priv = dev_get_priv(dev); | ||
struct bcm283x_mu_regs *regs = priv->regs; | ||
unsigned int lsr = readl(®s->lsr); | ||
|
||
if (input) { | ||
WATCHDOG_RESET(); | ||
return lsr & BCM283X_MU_LSR_RX_READY; | ||
} else { | ||
return !(lsr & BCM283X_MU_LSR_TX_IDLE); | ||
} | ||
} | ||
|
||
static const struct dm_serial_ops bcm283x_mu_serial_ops = { | ||
.putc = bcm283x_mu_serial_putc, | ||
.pending = bcm283x_mu_serial_pending, | ||
.getc = bcm283x_mu_serial_getc, | ||
.setbrg = bcm283x_mu_serial_setbrg, | ||
}; | ||
|
||
U_BOOT_DRIVER(serial_bcm283x_mu) = { | ||
.name = "serial_bcm283x_mu", | ||
.id = UCLASS_SERIAL, | ||
.platdata_auto_alloc_size = sizeof(struct bcm283x_mu_serial_platdata), | ||
.probe = bcm283x_mu_serial_probe, | ||
.ops = &bcm283x_mu_serial_ops, | ||
.flags = DM_FLAG_PRE_RELOC, | ||
.priv_auto_alloc_size = sizeof(struct bcm283x_mu_priv), | ||
}; |
Oops, something went wrong.
202d830
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just continue to use the PL011 implementation (remapping the pins to the correct ALT)?
The big advantage is that this way we are always sure about the clock - the firmware can not easily change the clock behind the scenes impacting the serial console...
So we only would need: board_early_init_f.
Just some ideas...
202d830
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PL011 is to be used by Bluetooth, so we have to use the mini UART for the console now. See pelwell's comment at RPi-Distro/repo#22 (search for "bluetooth") for background. Hopefully the FW will soon replace the board_early_init_f() function; see raspberrypi/firmware#553.
202d830
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there are several such tickets - I opened one just today as well for the downstream kernel...
But still - people may want to run their terminal with ttyAMA - especially when you run on a Compute Module, where you have access to both ttys - and they promise a CM with the bcm2837...
Note that the CM has an ID of 0x20 - you may want to add that to u-boot as well:
202d830
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect the default configuration in U-Boot to be coded to match the RPi Foundation's decisions regarding how they expect the HW to be used by default. People can certainly adjust the code locally if they want to assign the UARTs differently, or we could add some more U-Boot defconfigs (and/or perhaps request additional VC FW config.txt options?) to support people who want to use non-default configurations.
I suggest sending a patch for the new CM board ID; the CM I have has either ID 0x11 or 0x14. Do you have a board yourself that has 0x20 ID? If not, where do you get that information? FWIW, the data sources used to construct the existing table in U-Boot are:
202d830
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - i got that board myself - I just rebooted it that way to get that output...