From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 3/8] mips: add base support for atheros ath79 based SOCs
Date: Sat, 26 Dec 2015 18:01:36 +0100 [thread overview]
Message-ID: <567EC7F0.4030909@gmail.com> (raw)
In-Reply-To: <BLU436-SMTP2450837C8090FB04266C09FFFF90@phx.gbl>
Am 26.12.2015 um 17:17 schrieb Wills Wang:
>
>
> On 12/26/2015 03:28 PM, Marek Vasut wrote:
>> On Friday, December 25, 2015 at 07:56:23 PM, Wills Wang wrote:
>>> This patch enable work for ar933x SOC, tested on ar9331 board.
>>>
>>> Signed-off-by: Wills Wang <wills.wang@live.com>
>>> ---
>> [...]
>>
>>> +int arch_cpu_init(void)
>>> +{
>>> + u32 val;
>>> +
>>> + /*
>>> + * Set GPIO10 (UART_SO) as output and enable UART,
>>> + * BIT(15) in GPIO_FUNCTION_1 register must be written with 1
>>> + */
>>> + val = readl(KSEG1ADDR(AR71XX_GPIO_BASE + AR71XX_GPIO_REG_OE));
>>> + val |= BIT(10);
>>> + writel(val, KSEG1ADDR(AR71XX_GPIO_BASE + AR71XX_GPIO_REG_OE));
>>> +
>>> + val = readl(KSEG1ADDR(AR71XX_GPIO_BASE + AR71XX_GPIO_REG_FUNC));
>>> + val |= (AR933X_GPIO_FUNC_UART_EN | BIT(15));
>>> + writel(val, KSEG1ADDR(AR71XX_GPIO_BASE + AR71XX_GPIO_REG_FUNC));
>>> + return 0;
>>> +}
>> Pinmux should be done on a per-board basis, not per-CPU. Also, please use
>> setbits_le32().
> I don't find other more fit entry for pinctrl initialization.
> We must set these IO pin before serial initialization.
> Put it into board directory?
you could use the board_early_init_f hook, implemented in
board/ath79/ap121/ap121.c. If possible you should add a real pinctrl
driver in a later step
>>> diff --git a/arch/mips/mach-ath79/ar933x/ddr_tap.S
>>> b/arch/mips/mach-ath79/ar933x/ddr_tap.S new file mode 100644
>>> index 0000000..18c57de
>>> --- /dev/null
>>> +++ b/arch/mips/mach-ath79/ar933x/ddr_tap.S
>>> @@ -0,0 +1,268 @@
>>> +/*
>>> + * (C) Copyright 2015
>>> + * Wills Wang, <wills.wang@live.com>
>>> + *
>>> + * SPDX-License-Identifier: GPL-2.0+
>>> + */
>>> +
>>> +#include <config.h>
>>> +#include <asm/asm.h>
>>> +#include <asm/regdef.h>
>>> +#include <asm/mipsregs.h>
>>> +#include <asm/addrspace.h>
>>> +#include <asm/arch/ar71xx_regs.h>
>>> +
>>> +#define DRAM_K0(x) KSEG0ADDR(x)
>>> +#define DRAM_K1(x) KSEG1ADDR(x)
>>> +
>>> + .text
>>> + .set noreorder
>>> +
>>> +LEAF(ddr_tap_init)
>>> + /* Tap settings for the DDR */
>>> + li t0, 0xffffffff
>>> + li t1, DRAM_K0(0x500000)
>>> + sw t0, 0x0(t1)
>>> + sw t0, 0x4(t1)
>>> + sw t0, 0x8(t1)
>>> + sw t0, 0xc(t1)
>>> + nop
>>> + nop
>> This should be C code, pretty please.
> Must this be change to c code?
> I think there should be no problem.
this function is only called from init_dram() which already runs in a
full C environment. The conversion to C should be simple. But I would
accept the current patch for the initial merge if you do the conversion
later.
>>
>> [...]
>>
>>> diff --git a/arch/mips/mach-ath79/ar933x/lowlevel_init.S
>>> b/arch/mips/mach-ath79/ar933x/lowlevel_init.S new file mode 100644
>>> index 0000000..72509ca
>>> --- /dev/null
>>> +++ b/arch/mips/mach-ath79/ar933x/lowlevel_init.S
>> lowlevel_init.S should be C code too, I don't see anything which would
>> require this to be ASM .
> I don't find SRAM in this chip, we need DDR memory to handle C runtime
> statck.
currently lowlevel_init() must be coded in assembly because it runs
before RAM and caches are initialized. This function only exists to do
that initialization. MIPS did this from the beginning. Maybe I will send
some patches to use locked cache lines, but that should not be a hard
requirement for adding new SoC's. Actually all modern MIPS based SoC's
have some type of SRAM or first-stage bootloaders, thus adding the cache
line lock feature was not really necessary. I would accept the current
patch for the initial merge.
>> [...]
>>
>>> diff --git a/arch/mips/mach-ath79/cpu.c b/arch/mips/mach-ath79/cpu.c
>>> new file mode 100644
>>> index 0000000..681127c
>>> --- /dev/null
>>> +++ b/arch/mips/mach-ath79/cpu.c
>>> @@ -0,0 +1,171 @@
>>> +/*
>>> + * (C) Copyright 2015
>>> + * Wills Wang, <wills.wang@live.com>
>>> + *
>>> + * SPDX-License-Identifier: GPL-2.0+
>>> + */
>>> +
>>> +#include <common.h>
>>> +#include <asm/io.h>
>>> +#include <asm/addrspace.h>
>>> +#include <asm/types.h>
>>> +#include <asm/arch/ath79.h>
>>> +#include <asm/arch/ar71xx_regs.h>
>>> +
>>> +int print_cpuinfo(void)
>>> +{
>>> + enum ath79_soc_type soc = ATH79_SOC_UNKNOWN;
>>> + char *chip = "????";
const char *chip
>>> + u32 id, major, minor;
>>> + u32 rev = 0;
>>> + u32 ver = 1;
>>> +
>>> + id = readl(KSEG1ADDR(AR71XX_RESET_BASE + AR71XX_RESET_REG_REV_ID));
>>> + major = id & REV_ID_MAJOR_MASK;
>>> +
>>> + switch (major) {
>>> + case REV_ID_MAJOR_AR71XX:
>>> + minor = id & AR71XX_REV_ID_MINOR_MASK;
>>> + rev = id >> AR71XX_REV_ID_REVISION_SHIFT;
>>> + rev &= AR71XX_REV_ID_REVISION_MASK;
>>> + switch (minor) {
>> I did review this already and my suggestions were ignored :-( I stop
>> here ...
> Sorry, I forget this.
> This code inherit from kernel, to change would maintain it much more
> difficult.
>>
I agree with Marek that a lookup table would be better. But why do you
want to add all possible QCA based SoC's? Until there is no supported
board for other SoC's than yours, this would be dead code.
--
- Daniel
next prev parent reply other threads:[~2015-12-26 17:01 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1451069788-6786-1-git-send-email-wills.wang@live.com>
2015-12-25 18:56 ` [U-Boot] [PATCH v4 1/8] include: Add support for "do_div" macro Wills Wang
2015-12-26 7:24 ` Marek Vasut
2015-12-26 15:48 ` Wills Wang
2015-12-26 13:09 ` Daniel Schwierzeck
2015-12-26 16:54 ` Wills Wang
2015-12-25 18:56 ` [U-Boot] [PATCH v4 2/8] mips: implement to access the KSEG0/1 memory range in map_physmem Wills Wang
2015-12-26 7:25 ` Marek Vasut
2015-12-25 18:56 ` [U-Boot] [PATCH v4 3/8] mips: add base support for atheros ath79 based SOCs Wills Wang
2015-12-26 7:28 ` Marek Vasut
2015-12-26 16:17 ` Wills Wang
2015-12-26 17:01 ` Daniel Schwierzeck [this message]
2015-12-26 17:06 ` Marek Vasut
2015-12-27 9:37 ` Wills Wang
2015-12-25 18:56 ` [U-Boot] [PATCH v4 4/8] mips: ath79: add serial driver for ar933x SOC Wills Wang
2015-12-26 13:20 ` Daniel Schwierzeck
2015-12-26 16:54 ` Wills Wang
2015-12-26 17:19 ` Daniel Schwierzeck
2015-12-27 6:28 ` Wills Wang
2015-12-27 8:21 ` Thomas Chou
2015-12-27 13:07 ` Thomas Chou
2015-12-27 8:31 ` Thomas Chou
2015-12-25 18:56 ` [U-Boot] [PATCH v4 5/8] mips: ath79: add spi driver Wills Wang
2015-12-26 13:23 ` Daniel Schwierzeck
2015-12-26 16:56 ` Wills Wang
2015-12-25 18:56 ` [U-Boot] [PATCH v4 6/8] mips: ath79: add AP121 reference board Wills Wang
2015-12-26 13:52 ` Daniel Schwierzeck
2015-12-26 16:59 ` Wills Wang
2015-12-26 17:07 ` Daniel Schwierzeck
2015-12-27 6:36 ` Wills Wang
2015-12-27 6:41 ` Marek Vasut
2015-12-27 7:03 ` Wills Wang
2015-12-27 7:10 ` Marek Vasut
2015-12-25 18:56 ` [U-Boot] [PATCH v4 7/8] mips: support optimize tuning for same common processor cores Wills Wang
2015-12-26 7:30 ` Marek Vasut
2015-12-26 18:58 ` Daniel Schwierzeck
2015-12-27 3:03 ` Wills Wang
2015-12-25 18:56 ` [U-Boot] [PATCH v4 8/8] mips: move optimize tuning option from deprecated config.mk to Kconfig Wills Wang
2015-12-26 7:30 ` Marek Vasut
2015-12-26 17:33 ` Wills Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=567EC7F0.4030909@gmail.com \
--to=daniel.schwierzeck@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox