public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/4] mips: add base support for atheros ath79 based SOCs
Date: Mon, 28 Dec 2015 18:33:31 +0100	[thread overview]
Message-ID: <201512281833.32031.marex@denx.de> (raw)
In-Reply-To: <56816CA4.6070506@gmail.com>

On Monday, December 28, 2015 at 06:08:52 PM, Daniel Schwierzeck wrote:
> Am 28.12.2015 um 16:52 schrieb Marek Vasut:
> > On Monday, December 28, 2015 at 04:48:41 PM, Wills Wang wrote:
> >> On 12/28/2015 09:47 PM, Marek Vasut wrote:
> >>> On Monday, December 28, 2015 at 12:17:41 PM, Wills Wang wrote:
> >>> [...]
> >>> 
> >>>>>> "lowlevel_init.S" can't be dropped.
> >>>>> 
> >>>>> Thank you very much for all the effort you put into investigating and
> >>>>> explaining why this SRAM area cannot be used ... not. From my side,
> >>>>> consider this patch to be NAKed.
> >>>>> 
> >>>>> Best regards,
> >>>>> Marek Vasut
> >>>> 
> >>>> "lowlevel_init.S" can't be entirely dropped, there are three main
> >>>> reasons for this.
> >>> 
> >>> Right, so I checked how these are performed and whether these can or
> >>> cannot be done from C code.
> >>> 
> >>>> 1. Chip has an original issue, need reset "WLAN"  three times to avoid
> >>>> it when power up.
> >>>> 
> >>>   26 /* These three wlan reset will avoid original issue,
> >>>   27 so full chip reset isn't needed here. */
> >>>   28     set_reg(0xb806001c, 0x00c06b30)
> >>>   29     nop
> >>>   30     set_reg(0xb806001c, 0x00c06330)
> >>>   31     nop
> >>>   32     set_reg(0xb806001c, 0x00c06b30)
> >>>   33     nop
> >>>   34     set_reg(0xb806001c, 0x00c06330)
> >>>   35     nop
> >>>   36 reset_wlan:
> >>>   37     set_reg(0xb806001c, 0x00c06b30)
> >>>   38     nop
> >>>   39     set_reg(0xb806001c, 0x00c06330)
> >>>   40     nop
> >>> 
> >>> Yes, these can be done from C code.
> >>> 
> >>>> 2. Need reset RTC and force to wake MAC, or chip can't work .
> >>>> 
> >>>   73 /* RTC reset */
> >>>   74     set_reg(0x1810704c, 0x00000003)
> >>>   75     nop
> >>>   76     nop
> >>>   77     set_reg(0x18107040, 0x00000000)
> >>>   78     nop
> >>>   79     nop
> >>>   80     set_reg(0x18107040, 0x00000001)
> >>>   81     nop
> >>> 
> >>> DTTO.
> >>> 
> >>>> 3. Need initialise PLL clock for CPU/DDR/AHB, the default clock is
> >>>> 25MHz, the interval from
> >>>> power-up to printout is about 5s.
> >>> 
> >>> The PLL configuration is again a set of writes to some random
> >>> registers. This can again be done from the C code.
> >>> 
> >>>> So, assembler code could not be avoided even using SRAM for c stack.
> >>> 
> >>> I am not convinced, see above. Please show me where exactly is the
> >>> assembly code imperative. I simply do not see it.
> >>> 
> >>>> Now that chipmaker don't open SRAM of this chip and recommend DDR for
> >>>> initial stack, i think
> >>>> that using DDR should be more consolidated.
> >>> 
> >>> I do not care what the chip maker says unless there is an explicit
> >>> explanation why they require that. Most often, these sorts of
> >>> "limitations" are in place only because the chipmaker has incompetent
> >>> software engineers.
> >>> 
> >>> So I would like to see either the SRAM or locked cacheline used for
> >>> stack and then lowlevel init converted into proper C code unless there
> >>> is an explicit explanation why this can not be done. And by explicit I
> >>> mean for example a snippet of code which cannot be converted into C
> >>> code. Note that asm volatile can still be used to contain such small
> >>> bits of assembler code if needed be.
> >>> 
> >>> Best regards,
> >>> Marek Vasut
> >> 
> >> I made a series of tries in this, i configure initial stack in SRAM and
> >> convert
> >> these code to c, and put them in arch_cpu_init(the first available c
> >> entry), but
> >> hardware don't work. if i keep the above three points(RESET/RTC/PLL) in
> >> lowlevel_init, put other code in arch_cpu_init, board work fine.
> > 
> > So let me ask the question again -- why does the C code not work ? Did
> > you investigate the reason why does the C code not work ?
> > 
> > Can you share the change you did to convert things to C code ? There
> > might be a bug in that too ...
> 
> it is not a matter of C or assembly, but of the init sequence currently
> implemented on MIPS. The main purpose of lowlevel_init() is to
> initialize memory controllers and DRAM. This has to be done in assembly
> because we have no C runtime environment available at that point.

We do this in C on ARM, so I see no problem with this.

> Also compiling U-Boot as PIC requires to enable MIPS ABI function calls
> in gcc (-mabicalls). This always creates function prologues and
> epilogues which are utilizing the stack pointer. Thus we cannot simply
> convert all lowlevel_init functions to C.

I am not saying all, but a list of register writes should be easy to convert.

> Moving code from lowlevel_init to arch_cpu_init or elsewhere will not
> work because that code runs too late then. Simply moving the stack to
> SRAM will also not help because lowlevel_init runs before the stack is
> available.

We have SRAM to place stack in, so stack is available.

> Before Wills can convert his code to C, we need to rework the init
> sequence in start.S. But that is out of the scope of this patch series.
> I will try to prepare some patches in the next days. The SRAM part
> should be easy. But the cache line lock need some more work and testing.
> 
> In the meantime Wills could send a new patch series, which addresses all
> other issues except lowlevel_init. The function ddr_tap_init can be
> already converted to C because it is called from init_dram where a C
> runtime environment is available. So we could have at least a working
> patch series and could finalize the review of the other patches. After I
> have updated u-boot-mips/next branch, Wills can rebase and convert
> lowlevel_init to C.

  reply	other threads:[~2015-12-28 17:33 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1450956123-17606-1-git-send-email-wills.wang@live.com>
2015-12-24 11:22 ` [U-Boot] [PATCH v3 1/4] mips: add base support for atheros ath79 based SOCs Wills Wang
2015-12-24 11:52   ` Marek Vasut
2015-12-24 13:51     ` Wills Wang
2015-12-24 15:12       ` Marek Vasut
2015-12-25 11:38         ` Wills Wang
2015-12-26  6:02           ` Marek Vasut
2015-12-26 15:48             ` Wills Wang
2015-12-26 17:35               ` Marek Vasut
2015-12-26 18:17                 ` Marek Vasut
2015-12-26 18:29                   ` Wills Wang
2015-12-26 18:37                     ` Marek Vasut
2015-12-27  7:33                       ` Wills Wang
2015-12-27  7:38                         ` Marek Vasut
2015-12-27  8:07                           ` Wills Wang
2015-12-27 10:09                             ` Marek Vasut
2015-12-27 10:18                               ` Wills Wang
2015-12-27 11:04                                 ` Marek Vasut
2015-12-27 11:37                                   ` Wills Wang
2015-12-27 12:27                                     ` Marek Vasut
2015-12-28 11:17                                       ` Wills Wang
2015-12-28 13:47                                         ` Marek Vasut
2015-12-28 15:36                                           ` Wills Wang
2015-12-28 15:48                                           ` Wills Wang
2015-12-28 15:52                                             ` Marek Vasut
2015-12-28 17:08                                               ` Daniel Schwierzeck
2015-12-28 17:33                                                 ` Marek Vasut [this message]
2015-12-27 11:37                                   ` Daniel Schwierzeck
2015-12-27 12:25                                     ` Marek Vasut
2015-12-27 13:17                                     ` Wills Wang
2015-12-24 11:22 ` [U-Boot] [PATCH v3 2/4] mips: ath79: add serial driver for ar933x SOC Wills Wang
2015-12-25  2:39   ` Thomas Chou
2015-12-25  6:05     ` Wills Wang
2015-12-25  6:48       ` Thomas Chou
2015-12-25  2:49   ` Thomas Chou
2016-01-06  0:25   ` Simon Glass
2016-01-06  2:58     ` Wills Wang
2015-12-24 11:22 ` [U-Boot] [PATCH v3 3/4] mips: ath79: add spi driver Wills Wang
2015-12-24 11:55   ` Marek Vasut
2015-12-24 11:22 ` [U-Boot] [PATCH v3 4/4] mips: ath79: add AP121 reference board 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=201512281833.32031.marex@denx.de \
    --to=marex@denx.de \
    --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