[U-Boot] [PATCH] arm: rmobile: Add supoprt for KMC KZM-A9-GT board

Nobuhiro Iwamatsu nobuhiro.iwamatsu.yj at renesas.com
Thu Jun 28 08:56:18 CEST 2012


Hi, Wolfgang.

2012/6/27 Wolfgang Denk <wd at denx.de>:
> Dear Nobuhiro Iwamatsu,
>
> In message <CABMQnV+RAOvBXAgnMv9Vo2HYjqZ7uZ2-TOx91qAYNrWX4PQM_Q at mail.gmail.com> you wrote:
>>
> ...
>> >> --- /dev/null
>> >> +++ b/board/kmc/kzm/lowlevel_init.S
> ...
>> >> +     and_write32     LIFEC_SEC_SRC, 0xFFFFFFE7
>> >> +
>> >> +     and_write32     SRCR3, 0xFFFF7FFF
>> >> +     and_write32     SMSTPCR2,0xFFFBFFFF
>> >> +     and_write32     SRCR2, 0xFFFBFFFF
>> >> +     write32         PLLECR, 0x00000000
>> >> +
>> >> +     cmp_loop        PLLECR, 0x00000F00, 0x00000000
>> >> +     cmp_loop        FRQCRB, 0x80000000, 0x00000000
>> >> +
>> >> +     write32         PLL0CR, 0x2D000000
>> >> +     write32         PLL1CR, 0x17100000
>> >> +     write32         FRQCRB, 0x96235880
>> >> +     cmp_loop        FRQCRB, 0x80000000, 0x00000000
>> >> +
>> >> +     write32         FLCKCR, 0x0000000B
>> >> +     and_write32     SMSTPCR0, 0xFFFFFFFD
>> >> +
>> >> +     and_write32     SRCR0, 0xFFFFFFFD
>> >> +     write32         SMGPIOTIME, 0x00000514
>> >> +     write32         SMCMT2TIME, 0x00000514
>> >> +     write32         SMCPGTIME, 0x00000514
>> >> +     write32         SMSYSCTIME, 0x00000514
>> >> +
>> >> +     write32         DVFSCR4, 0x00092000
>> >> +     write32         DVFSCR5, 0x000000DC
>> >> +     write32         PLLECR, 0x00000000
>> >> +     cmp_loop        PLLECR, 0x00000F00, 0x00000000
>> >> +
>> >> +     write32         FRQCRA, 0x0012453C
>> >> +     write32         FRQCRB, 0x80331350
>> >> +     cmp_loop        FRQCRB, 0x80000000, 0x00000000
>> >> +     write32         FRQCRD, 0x00000B0B
>> >> +     cmp_loop        FRQCRD, 0x80000000, 0x00000000
>> >> +
>> >> +     write32         PCLKCR, 0x00000003
>> >> +     write32         VCLKCR1, 0x0000012F
>> >> +     write32         VCLKCR2, 0x00000119
>> >> +     write32         VCLKCR3, 0x00000119
>> >> +     write32         ZBCKCR, 0x00000002
>> >> +     write32         FLCKCR, 0x00000005
>> >> +     write32         SD0CKCR, 0x00000080
>> >> +     write32         SD1CKCR, 0x00000080
>> >> +     write32         SD2CKCR, 0x00000080
>> >> +     write32         FSIACKCR, 0x0000003F
>> >> +     write32         FSIBCKCR, 0x0000003F
>> >> +     write32         SUBCKCR, 0x00000080
>> >> +     write32         SPUACKCR, 0x0000000B
>> >> +     write32         SPUVCKCR, 0x0000000B
>> >> +     write32         MSUCKCR, 0x0000013F
>> >> +     write32         HSICKCR, 0x00000080
>> >> +     write32         MFCK1CR, 0x0000003F
>> >> +     write32         MFCK2CR, 0x0000003F
>> >> +     write32         DSITCKCR, 0x00000107
>> >> +     write32         DSI0PCKCR, 0x00000313
>> >> +     write32         DSI1PCKCR, 0x0000130D
>> >> +     write32         DSI0PHYCR, 0x2A800E0E
>> >> +     write32         PLL0CR, 0x1E000000
>> >> +     write32         PLL0CR, 0x2D000000
>> >> +     write32         PLL1CR, 0x17100000
>> >> +     write32         PLL2CR, 0x27000080
>> >> +     write32         PLL3CR, 0x1D000000
>> >> +     write32         PLL0STPCR, 0x00080000
>> >> +     write32         PLL1STPCR, 0x000120C0
>> >> +     write32         PLL2STPCR, 0x00012000
>> >> +     write32         PLL3STPCR, 0x00000030
>> >> +     write32         PLLECR, 0x0000000B
>> >> +     cmp_loop        PLLECR, 0x00000B00, 0x00000B00
>> >> +
>> >> +     write32         DVFSCR3, 0x000120F0
>> >> +     write32         MPMODE, 0x00000020
>> >> +     write32         VREFCR, 0x0000028A
>> >> +     write32         RMSTPCR0, 0xE4628087
>> >> +     write32         RMSTPCR1, 0xFFFFFFFF
>> >> +     write32         RMSTPCR2, 0x53FFFFFF
>> >> +     write32         RMSTPCR3, 0xFFFFFFFF
>> >> +     write32         RMSTPCR4, 0x00800D3D
>> >> +     write32         RMSTPCR5, 0xFFFFF3FF
>> >> +     write32         SMSTPCR2, 0x00000000
>> >> +     write32         SRCR2,  0x00040000
>> >> +     and_write32     PLLECR, 0xFFFFFFF7
>> >> +     cmp_loop        PLLECR, 0x00000800, 0x00000000
>> >> +
>> >> +     write32         HPBCTRL6, 0x00000001
>> >> +     cmp_loop        HPBCTRL6, 0x00000001, 0x00000001
>> >> +
>> >> +     write32         FRQCRD, 0x00001414
>> >> +     cmp_loop        FRQCRD, 0x80000000, 0x00000000
>> >> +
>> >> +     write32         PLL3CR, 0x1D000000
>> >> +     or_write32      PLLECR, 0x00000008
>> >> +     cmp_loop        PLLECR, 0x00000800, 0x00000800
>> >> +
>> >> +     or_write32      DLLCNT0A, 0x00000002
>> >> +     write32         SDGENCNTA, 0x00000005
>> >> +     cmp_loop        SDGENCNTA, 0xFFFFFFFF, 0x00000000
>> >> +
>> >> +     write32         SDCR0A, 0xACC90159
>> >> +     write32         SDCR1A, 0x00010059
>> >> +     write32         SDWCRC0A, 0x50874114
>> >> +     write32         SDWCRC1A, 0x33199B37
>> >> +     write32         SDWCRC2A, 0x008F2313
>> >> +     write32         SDWCR00A, 0x31020707
>> >> +     write32         SDWCR01A, 0x0017040A
>> >> +     write32         SDWCR10A, 0x31020707
>> >> +     write32         SDWCR11A, 0x0017040A
>> >> +     write32         SDDRVCR0A, 0x05555555
>> >> +     write32         SDWCR2A, 0x30000000
>> >> +     or_write32      SDPCRA, 0x00000080
>> >> +     cmp_loop        SDPCRA, 0x00000080, 0x00000080
>> >> +     write32         SDGENCNTA, 0x00002710
>> >> +     cmp_loop        SDGENCNTA, 0xFFFFFFFF, 0x00000000
>> >> +     write32         SDMRACR0A, 0x0000003F
>> >> +     write32         SDMRA1, 0x00000000
>> >> +     write32         SDGENCNTA, 0x000001F4
>> >> +     cmp_loop        SDGENCNTA, 0xFFFFFFFF, 0x00000000
>> >> +     write32         SDMRACR0A, 0x0000FF0A
>> >> +     write32         SDMRA3, 0x00000000
>> >> +     write32         SDGENCNTA, 0x00000032
>> >> +     cmp_loop        SDGENCNTA, 0xFFFFFFFF, 0x00000000
>> >> +     write32         SDMRACR0A, 0x00002201
>> >> +     write32         SDMRA1, 0x00000000
>> >> +     write32         SDMRACR0A, 0x00000402
>> >> +     write32         SDMRA1, 0x00000000
>> >> +     write32         SDMRACR0A, 0x00000403
>> >> +     write32         SDMRA1, 0x00000000
>> >> +     write32         SDMRA2, 0x00000000
>> >> +     write32         SDMRTMPCRA, 0x88800004
>> >> +     write32         SDMRTMPMSKA,0x00000004
>> >> +     write32         RTCORA, 0xA55A0032
>> >> +     write32         RTCORHA, 0xA55A000C
>> >> +     write32         RTCSRA, 0xA55A2048
>> >> +     or_write32      SDCR0A, 0x00000800
>> >> +     or_write32      SDCR1A, 0x00000400
>> >> +     write32         ZQCCRA, 0xFFF20000
>> >> +
>> >> +     or_write32      DLLCNT0B, 0x00000002
>> >> +     write32         SDGENCNTB, 0x00000005
>> >> +     cmp_loop        SDGENCNTB, 0xFFFFFFFF, 0x00000000
>> >> +
>> >> +     write32         SDCR0B, 0xACC90159
>> >> +     write32         SDCR1B, 0x00010059
>> >> +     write32         SDWCRC0B, 0x50874114
>> >> +     write32         SDWCRC1B, 0x33199B37
>> >> +     write32         SDWCRC2B, 0x008F2313
>> >> +     write32         SDWCR00B, 0x31020707
>> >> +     write32         SDWCR01B, 0x0017040A
>> >> +     write32         SDWCR10B, 0x31020707
>> >> +     write32         SDWCR11B, 0x0017040A
>> >> +     write32         SDDRVCR0B, 0x05555555
>> >> +     write32         SDWCR2B, 0x30000000
>> >> +     or_write32      SDPCRB, 0x00000080
>> >> +     cmp_loop        SDPCRB, 0x00000080, 0x00000080
>> >> +
>> >> +     write32         SDGENCNTB, 0x00002710
>> >> +     cmp_loop                SDGENCNTB, 0xFFFFFFFF,>  0x00000000
>> >> +     write32         SDMRACR0B, 0x0000003F
>> >> +     write32         SDMRB1, 0x00000000
>> >> +     write32         SDGENCNTB, 0x000001F4
>> >> +     cmp_loop        SDGENCNTB, 0xFFFFFFFF, 0x00000000
>> >> +
>> >> +     write32         SDMRACR0B, 0x0000FF0A
>> >> +     write32         SDMRB3, 0x00000000
>> >> +     write32         SDGENCNTB, 0x00000032
>> >> +     cmp_loop        SDGENCNTB, 0xFFFFFFFF, 0x00000000
>> >> +
>> >> +     write32         SDMRACR0B, 0x00002201
>> >> +     write32         SDMRB1, 0x00000000
>> >> +     write32         SDMRACR0B, 0x00000402
>> >> +     write32         SDMRB1, 0x00000000
>> >> +     write32         SDMRACR0B, 0x00000403
>> >> +     write32         SDMRB1, 0x00000000
>> >> +     write32         SDMRB2, 0x00000000
>> >> +     write32         SDMRTMPCRB, 0x88800004
>> >> +     write32         SDMRTMPMSKB, 0x00000004
>> >> +     write32         RTCORB,  0xA55A0032
>> >> +     write32         RTCORHB, 0xA55A000C
>> >> +     write32         RTCSRB,  0xA55A2048
>> >> +     or_write32      SDCR0B, 0x00000800
>> >> +     or_write32      SDCR1B, 0x00000400
>> >> +     write32         ZQCCRB, 0xFFF20000
>> >> +     or_write32      SDPDCR0B, 0x00030000
>> >> +     write32         DPHYCNT1B, 0xA5390000
>> >> +     write32         DPHYCNT0B, 0x00001200
>> >> +     write32         DPHYCNT1B, 0x07CE0000
>> >> +     write32         DPHYCNT0B, 0x00001247
>> >> +     cmp_loop        DPHYCNT2B, 0xFFFFFFFF, 0x07CE0000
>> >> +
>> >> +     and_write32     SDPDCR0B, 0xFFFCFFFF
>> >> +
>> >> +     write32         FRQCRD, 0x00000B0B
>> >> +     cmp_loop        FRQCRD, 0x80000000, 0x00000000
>> >
>> > Can't all this be simplified by using tables?
>>
>> I like this style. Because  the information of the register is because it
>> can be formed from a data sheet automatically.
>> It is very painful to make a table from a data sheet separately.
>> However, I obey it if a policy of ARM is to use the table.
>
> I disagree.  You cannot really like this style.
>
> Such a list of completely hard-coded magic numbers, without any
> comments, is not readable and not maintainable.  No programmer can
> like such code. It is a horrible mess.

I agree.

>
> I wonder why this is written in assembly at all?  Why don't you write
> all this in C?  I cannot see any strong reason that would prevent an
> implementation in C.
>

In my case, the portion of initialization of a board is mounted based on
a hardware designer's information, and the manual of CPU.
Since these are templates in many cases, a transplant is easy.
However, it also knows that there are various problems so that you may point out

OK,  I will change coding style for sh port and rmobile port.

Best regards,
  Nobuhiro

-- 
Nobuhiro Iwamatsu


More information about the U-Boot mailing list