On Wed, Jan 18, 2017 at 11:35:57AM +1300, Michael Clark wrote:
> On 18 Jan 2017, at 6:35 AM, ron minnich <
rmin...@gmail.com> wrote:
>
> Maybe I can divine this stuff but I'm not sure how :-)
>
> I think we need a hz entry for the rtc and each core.
>
> The rtc should be pretty obvious; it would be nice to just
> know the clock rate of the rtc, rather than try to divine
> it with timing loops. Actually, I don't even know how one
> could figure it out absent some fixed reference source, and
> I don't know what that is. Just counting on 10 mhz. to
> always be the rate seems dicy.
Hello,
I assume "rtc" here means the machine timer register (mtime)?
I ask because in software engineering an "rtc" usually means
a (battery-backed) hardware real-time-clock that provides
persistent time-of-day and date registers.
> harts would be
> core {0{0{hz 0xwhatever; ...};};};
>
> hz in general might be useful for many things; the uart comes to mind. For
> 16550 uart emulations it’s good to know what the source clock is.
>
>
> The question for the UART would be which clock? It may be the system clock in
> some systems (FPGA) or it could be separate 1MHz reference clock.
> The UART section probably could have its own clock frequency.
>
> Also should the default UART settings be in the config string e.g. “115200,8N1”
> so that the firmware can program the UART, or is this reasonable to hard code
> as a “documented” start up value for early console.
[...]
> The loader might need the model too, as some models have 32-bit register layout
> instead of 8-bit register layout (Xilinx AXI UART16550 comes to mind) and
> various other quirks (although looking at of_serial.c this might be handled
> with a “reg-shift” property).
>
> e.g. an MMIO UART with a 1MHz clock that is set to 115200,8N1 at POST/BIST.
>
> uart {
> model “meta8250”;
> addr 0x40003000;
> clock-frequency 1000000;
> settings “115200,8N1”;
> }
According to chapter 8 of the privileged spec v1.9.1,
config-string uses the device-tree data model (which includes
the existing bindings, i.e. structures and property names).
Extensions to the existing bindings can be introduced if
necessary, but where bindings already exist, they must be used.
Therefore please don't invent incompatible bindings for stuff
that is already there like the binding definition for
8250/16550-style UARTs; please cf.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/serial/8250.txt
What you want to define as "model" is already defined as the
"compatible" property.
Your "addr" is already defined as the "reg" property (which lists
the MMIO register base adddress(es) and -range(s)). Real-world
SoCs often have multiple logically-connected register blocks
interspaced with registers belonging to other IP blocks in the
same SoC, so it is important that it is possible to specifiy
multiple base addresses and ranges for one IP block.
The clock supply to the UART is handled by either the
"clock-frequency" property for a fixed-frequency clock or by a
phandle reference to a separate clock definition in case of a
variable clock supply.
In real-world SoCs, the UART clocks are usually not
fixed-frequency clocks, but instead the UART clock is derived
from a (choice of) PLL clock(s) with multiple programmable
pre-dividers, which themselves are driven by one or multiple
(sometimes programmable) oscillators. As multiple devices can
depend on the same parent clocks and can need runtime adjustments
of their clock supply, it can be necessary to do coordinated
modifications of the parent clock settings of multiple devices at
runtime. In case of an UART it can for example be necessary to
modify the UART input clock frequency for achieving specific
baudrates. To be able to do properly coordinated clock tree
changes, the device-tree (and thereby config string) must provide
a proper representation of the clock hardware to the operating
system. Therefore complex clock setups are represented by a
separate clock definition that gets referenced by the devices
that use the corresponding clock instead of just supplying a
fixed "clock-frequency" property. A fixed clock-frequency property
can only be used if the UART is really driven by a fixed-frequency
clock.
In real-world SoCs these interdependencies in the clock tree
commonly exist for many of the on-chip peripherals (MMC
controllers, SPI controllers, PWM controllers, audio controllers,
infraread controllers, etc).
To get back from a visit to the complexities of the clock
subsystem to the 16550 UART bindings:
For UART models that only accept 32bit register access we have
the "reg-io-width" property.
The interrupt line that the UART is connected to is specified by
the "interrupts" property.
So a UART definition could look like (in the simple case of a
16550a-compatible UART implementation driven by a single
fixed-frequency clock and triggering interrupt 25 on a
directly-connected master interrupt-controller):
uart@12340000 {
compatible = "ns16550a";
reg = <0x12340000> <0x100>;
clock-frequency = "1000000";
interrupts = <25>;
}
Regarding the "settings" property from your example above: please
don't intermix hardware description and system configuration
with each other. A node describing a piece of hardware or an IP
block like the UART shall contain the description of how the
hardware works and how is interconnected, but not how is gets
configured in a particular system. For passing configuration
information, device-tree has the "chosen" node, in which
information like the amount of available system memory or the
device to use as the system console can be provided. The
configuration entries in the "chosen" node can contain a
reference to the hardware node they configure. A real-world
example from an ARM-SoC device-tree:
chosen {
stdout-path = "serial0:115200n8";
};
where serial0 is a phandle reference to the corresponding UART
node.
Regards,
Karsten
--
Gem. Par. 28 Abs. 4 Bundesdatenschutzgesetz widerspreche ich der Nutzung
sowie der Weitergabe meiner personenbezogenen Daten für Zwecke der
Werbung sowie der Markt- oder Meinungsforschung.