Skip to contentSkip to conversation

Bring up rk3036 uboot

PATCH New Lin Huang 3 participants 42 messages Oct 21, 2015 – Oct 27, 2015

Subsystems (7)
lore
Share & tools
lore

Lin Huang

author
#0 lore raw

cover Bring up rk3036 uboot

This series patch bring up rk3036 uboot, since rk3036 only 8K size SRAM, not enough space to add ddr driver, so you should use rockchip bootmerge script to merge ddr.bin and u-boot-dtb.bin.

Lin Huang (12):
rockchip: define SUPPORT_SPL and SPL config in RK3288 config
rockchip: implement rockchip timer init function
rockchip: serial driver support rk3036
rockchip: Bring in RK3036 device tree file includes and bindings
rockchip: rk3036: Add clock driver
rockchip: rk3036: Add header files for GRF
rockchip: rk3036: Add Soc reset driver
rockchip: rk3036: Add a simple syscon driver
rockchip: rk3036: Add pinctrl driver
rockchip: Add an rk3036 MMC driver
rockchip: rk3036: Add core Soc start-up code
rockchip: Add basic support for evb-rk3036 board

 arch/arm/Kconfig                                |   2 -
 arch/arm/dts/Makefile                           |   3 +-
 arch/arm/dts/rk3036-sdk.dts                     |  46 +++
 arch/arm/dts/rk3036.dtsi                        | 427 +++++++++++++++++++
 arch/arm/include/asm/arch-rockchip/cru_rk3036.h |  53 +++
 arch/arm/include/asm/arch-rockchip/grf_rk3036.h | 491 ++++++++++++++++++++++
 arch/arm/include/asm/arch-rockchip/hardware.h   |   2 +-
 arch/arm/include/asm/arch-rockchip/timer.h      |  18 +
 arch/arm/mach-rockchip/Kconfig                  |  12 +-
 arch/arm/mach-rockchip/Makefile                 |   1 +
 arch/arm/mach-rockchip/board.c                  |  19 +-
 arch/arm/mach-rockchip/common.c                 |  11 +
 arch/arm/mach-rockchip/rk3036/Kconfig           |  11 +
 arch/arm/mach-rockchip/rk3036/Makefile          |   8 +
 arch/arm/mach-rockchip/rk3036/reset_rk3036.c    |  45 ++
 arch/arm/mach-rockchip/rk3036/syscon_rk3036.c   |  21 +
 board/evb_rk3036/evb_rk3036/Kconfig             |  15 +
 board/evb_rk3036/evb_rk3036/MAINTAINERS         |   0
 board/evb_rk3036/evb_rk3036/Makefile            |   7 +
 board/evb_rk3036/evb_rk3036/evb_rk3036.c        |   7 +
 configs/evb-rk3036_defconfig                    |  41 ++
 drivers/clk/Makefile                            |   1 +
 drivers/clk/clk_rk3036.c                        | 522 ++++++++++++++++++++++++
 drivers/mmc/Kconfig                             |   9 +
 drivers/mmc/Makefile                            |   1 +
 drivers/mmc/rockchip_3036_dw_mmc.c              | 479 ++++++++++++++++++++++
 drivers/pinctrl/Kconfig                         |  18 +
 drivers/pinctrl/rockchip/Makefile               |   1 +
 drivers/pinctrl/rockchip/pinctrl_rk3036.c       | 276 +++++++++++++
 drivers/serial/serial_rockchip.c                |   2 +-
 include/configs/evb_rk3036.h                    |  12 +
 include/configs/rk3036_common.h                 | 116 ++++++
 include/configs/rk3288_common.h                 |   3 +-
 include/dt-bindings/clock/rk3036-cru.h          | 186 +++++++++
 34 files changed, 2858 insertions(+), 8 deletions(-)
 create mode 100644 arch/arm/dts/rk3036-sdk.dts
 create mode 100644 arch/arm/dts/rk3036.dtsi
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3036.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/grf_rk3036.h
 create mode 100644 arch/arm/include/asm/arch-rockchip/timer.h
 create mode 100644 arch/arm/mach-rockchip/rk3036/Kconfig
 create mode 100644 arch/arm/mach-rockchip/rk3036/Makefile
 create mode 100644 arch/arm/mach-rockchip/rk3036/reset_rk3036.c
 create mode 100644 arch/arm/mach-rockchip/rk3036/syscon_rk3036.c
 create mode 100644 board/evb_rk3036/evb_rk3036/Kconfig
 create mode 100644 board/evb_rk3036/evb_rk3036/MAINTAINERS
 create mode 100644 board/evb_rk3036/evb_rk3036/Makefile
 create mode 100644 board/evb_rk3036/evb_rk3036/evb_rk3036.c
 create mode 100644 configs/evb-rk3036_defconfig
 create mode 100644 drivers/clk/clk_rk3036.c
 create mode 100644 drivers/mmc/rockchip_3036_dw_mmc.c
 create mode 100644 drivers/pinctrl/rockchip/pinctrl_rk3036.c
 create mode 100644 include/configs/evb_rk3036.h
 create mode 100644 include/configs/rk3036_common.h
 create mode 100644 include/dt-bindings/clock/rk3036-cru.h
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/12 rockchip: define SUPPORT_SPL and SPL config in RK3288 config

it may not use SPL in other rockchip SOC, so move SUPPORT_SPL and SPL config to rk3288 configuration.

---
Changes in v1: None

 arch/arm/Kconfig               | 2 --
 arch/arm/mach-rockchip/Kconfig | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +0 -2
index 194fb7b..40fa741 100644
@@ -831,8 +831,6 @@ config TARGET_STM32F429_DISCOVERY
 
 config ARCH_ROCKCHIP
 	bool "Support Rockchip SoCs"
-	select SUPPORT_SPL
-	select SPL
 	select OF_CONTROL
 	select CPU_V7
 	select DM
arch/arm/mach-rockchip/Kconfig +2 -0
index ab50f4e..15cd380 100644
@@ -2,6 +2,8 @@ if ARCH_ROCKCHIP
 
 config ROCKCHIP_RK3288
 	bool "Support Rockchip RK3288"
+	select SUPPORT_SPL
+	select SPL
 	help
 	  The Rockchip RK3288 is a ARM-based SoC with a quad-core Cortex-A17
 	  including NEON and GPU, 1MB L2 cache, Mali-T7 graphics, two
Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/12 rockchip: define SUPPORT_SPL and SPL config in RK3288 config

Hi Lin,

Quoted 38 lines · Lin Huang

it may not use SPL in other rockchip SOC, so move SUPPORT_SPL and SPL config to rk3288 configuration.

---
Changes in v1: None

 arch/arm/Kconfig               | 2 --
 arch/arm/mach-rockchip/Kconfig | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +0 -2
index 194fb7b..40fa741 100644
@@ -831,8 +831,6 @@ config TARGET_STM32F429_DISCOVERY
 
 config ARCH_ROCKCHIP
        bool "Support Rockchip SoCs"
-       select SUPPORT_SPL
-       select SPL
        select OF_CONTROL
        select CPU_V7
        select DM
arch/arm/mach-rockchip/Kconfig +2 -1
index ab50f4e..15cd380 100644
@@ -2,6 +2,8 @@ if ARCH_ROCKCHIP
 
 config ROCKCHIP_RK3288
        bool "Support Rockchip RK3288"
+       select SUPPORT_SPL
+       select SPL
        help
          The Rockchip RK3288 is a ARM-based SoC with a quad-core Cortex-A17
          including NEON and GPU, 1MB L2 cache, Mali-T7 graphics, two
--
Quoted 2 lines

1.9.1

We should avoid little binary blobs for booting the chip. I think we can live with this as a stepping stone to having a proper SPL, but what is the plan for a proper SPL in U-Boot?

Regards,
Simon

#3 lore raw

PATCH 1/12 rockchip: define SUPPORT_SPL and SPL config in RK3288 config

Hi Simon

2015-10-22 22:07 GMT+08:00 Simon Glass <[email protected]>:

Quoted 41 lines

Hi Lin,

Review

Quoted 25 lines · Lin Huang

it may not use SPL in other rockchip SOC, so move SUPPORT_SPL and SPL config to rk3288 configuration.

---
Changes in v1: None

 arch/arm/Kconfig               | 2 --
 arch/arm/mach-rockchip/Kconfig | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +0 -2
index 194fb7b..40fa741 100644
@@ -831,8 +831,6 @@ config TARGET_STM32F429_DISCOVERY
 
 config ARCH_ROCKCHIP
        bool "Support Rockchip SoCs"
-       select SUPPORT_SPL
-       select SPL
        select OF_CONTROL
        select CPU_V7
        select DM
(quoted diff) +0 -0

b/arch/arm/mach-rockchip/Kconfig

arch/arm/mach-rockchip/Kconfig if ARCH_ROCKCHIP · line 8

Quoted 11 lines

index ab50f4e..15cd380 100644

arch/arm/mach-rockchip/Kconfig +2 -0
@@ -2,6 +2,8 @@ if ARCH_ROCKCHIP
 
 config ROCKCHIP_RK3288
        bool "Support Rockchip RK3288"
+       select SUPPORT_SPL
+       select SPL
        help
          The Rockchip RK3288 is a ARM-based SoC with a quad-core

Cortex-A17

Quoted 9 lines
Quoted 4 lines
arch/arm/mach-rockchip/Kconfig +0 -1
          including NEON and GPU, 1MB L2 cache, Mali-T7 graphics, two
--

1.9.1

We should avoid little binary blobs for booting the chip. I think we can live with this as a stepping stone to having a proper SPL, but what is the plan for a proper SPL in U-Boot?

RK3036 have only 8k sram. 4k used by boot rom. The ddr initialize code is almost 4k. So i don't think we can do SPL.

Quoted 6 lines

Regards,
Simon

Signature · 1 line
Eddie
#4 lore raw

PATCH 1/12 rockchip: define SUPPORT_SPL and SPL config in RK3288 config

Hi Eddie,

Quoted 54 lines · Eddie Cai

Hi Simon

2015-10-22 22:07 GMT+08:00 Simon Glass <[email protected]>:

Quoted 35 lines

Hi Lin,

Quoted 31 lines · Lin Huang

it may not use SPL in other rockchip SOC, so move SUPPORT_SPL and SPL config to rk3288 configuration.

---
Changes in v1: None

 arch/arm/Kconfig               | 2 --
 arch/arm/mach-rockchip/Kconfig | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +0 -2
index 194fb7b..40fa741 100644
@@ -831,8 +831,6 @@ config TARGET_STM32F429_DISCOVERY
 
 config ARCH_ROCKCHIP
        bool "Support Rockchip SoCs"
-       select SUPPORT_SPL
-       select SPL
        select OF_CONTROL
        select CPU_V7
        select DM
arch/arm/mach-rockchip/Kconfig +0 -0
index ab50f4e..15cd380 100644
@@ -2,6 +2,8 @@ if ARCH_ROCKCHIP
 
Quoted 15 lines
Quoted 11 lines
arch/arm/mach-rockchip/Kconfig +2 -0
 config ROCKCHIP_RK3288
        bool "Support Rockchip RK3288"
+       select SUPPORT_SPL
+       select SPL
        help
          The Rockchip RK3288 is a ARM-based SoC with a quad-core

Cortex-A17
including NEON and GPU, 1MB L2 cache, Mali-T7 graphics, two
--
1.9.1

We should avoid little binary blobs for booting the chip. I think we can live with this as a stepping stone to having a proper SPL, but what is the plan for a proper SPL in U-Boot?

Quoted 2 lines

RK3036 have only 8k sram. 4k used by boot rom. The ddr initialize code is almost 4k. So i don't think we can do SPL.

How does U-Boot get loaded in this case? Does it use ROM code? If so then I think we should create an SPL that handles the DDR init and then returns to the ROM code for loading U-Boot. Also we should document how this works in the README.

Regards,
Simon

#5 lore raw

PATCH 1/12 rockchip: define SUPPORT_SPL and SPL config in RK3288 config

Hi Simon

2015-10-23 0:30 GMT+08:00 Simon Glass <[email protected]>:

Quoted 57 lines

Hi Eddie,

Quoted 54 lines · Eddie Cai

Hi Simon

2015-10-22 22:07 GMT+08:00 Simon Glass <[email protected]>:

Quoted 50 lines

Hi Lin,

Quoted 37 lines · Lin Huang

it may not use SPL in other rockchip SOC, so move SUPPORT_SPL and SPL config to rk3288 configuration.

---
Changes in v1: None

 arch/arm/Kconfig               | 2 --
 arch/arm/mach-rockchip/Kconfig | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +0 -2
index 194fb7b..40fa741 100644
@@ -831,8 +831,6 @@ config TARGET_STM32F429_DISCOVERY
 
 config ARCH_ROCKCHIP
        bool "Support Rockchip SoCs"
-       select SUPPORT_SPL
-       select SPL
        select OF_CONTROL
        select CPU_V7
        select DM
arch/arm/mach-rockchip/Kconfig +2 -0
index ab50f4e..15cd380 100644
@@ -2,6 +2,8 @@ if ARCH_ROCKCHIP
 
 config ROCKCHIP_RK3288
        bool "Support Rockchip RK3288"
+       select SUPPORT_SPL
+       select SPL
        help
          The Rockchip RK3288 is a ARM-based SoC with a quad-core
Quoted 5 lines

Cortex-A17
including NEON and GPU, 1MB L2 cache, Mali-T7 graphics, two
--
1.9.1

We should avoid little binary blobs for booting the chip. I think we can live with this as a stepping stone to having a proper SPL, but what is the plan for a proper SPL in U-Boot?

Quoted 5 lines
Quoted 2 lines

RK3036 have only 8k sram. 4k used by boot rom. The ddr initialize code is almost 4k. So i don't think we can do SPL.

How does U-Boot get loaded in this case? Does it use ROM code? If so

Yes, it use boot rom code to load U-Boot

Quoted 4 lines

then I think we should create an SPL that handles the DDR init and then returns to the ROM code for loading U-Boot. Also we should document how this works in the README.

It is a good news you agree we can return to boot rom from SPL. Do you know what size of sram a smallest SPL need?

Quoted 6 lines

Regards,
Simon

Signature · 1 line
Eddie
#6 lore raw

PATCH 1/12 rockchip: define SUPPORT_SPL and SPL config in RK3288 config

Hi Eddie,

Quoted 67 lines · Eddie Cai

Hi Simon

2015-10-23 0:30 GMT+08:00 Simon Glass <[email protected]>:

Quoted 58 lines

Hi Eddie,

Quoted 54 lines · Eddie Cai

Hi Simon

2015-10-22 22:07 GMT+08:00 Simon Glass <[email protected]>:

Quoted 50 lines

Hi Lin,

Quoted 37 lines · Lin Huang

it may not use SPL in other rockchip SOC, so move SUPPORT_SPL and SPL config to rk3288 configuration.

---
Changes in v1: None

 arch/arm/Kconfig               | 2 --
 arch/arm/mach-rockchip/Kconfig | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +0 -2
index 194fb7b..40fa741 100644
@@ -831,8 +831,6 @@ config TARGET_STM32F429_DISCOVERY
 
 config ARCH_ROCKCHIP
        bool "Support Rockchip SoCs"
-       select SUPPORT_SPL
-       select SPL
        select OF_CONTROL
        select CPU_V7
        select DM
arch/arm/mach-rockchip/Kconfig +2 -0
index ab50f4e..15cd380 100644
@@ -2,6 +2,8 @@ if ARCH_ROCKCHIP
 
 config ROCKCHIP_RK3288
        bool "Support Rockchip RK3288"
+       select SUPPORT_SPL
+       select SPL
        help
          The Rockchip RK3288 is a ARM-based SoC with a quad-core
Quoted 5 lines

Cortex-A17
including NEON and GPU, 1MB L2 cache, Mali-T7 graphics, two
--
1.9.1

We should avoid little binary blobs for booting the chip. I think we can live with this as a stepping stone to having a proper SPL, but what is the plan for a proper SPL in U-Boot?

Quoted 5 lines
Quoted 3 lines

RK3036 have only 8k sram. 4k used by boot rom. The ddr initialize code is
almost 4k. So i don't think we can do SPL.

How does U-Boot get loaded in this case? Does it use ROM code? If so

Quoted 8 lines

Yes, it use boot rom code to load U-Boot

Quoted 4 lines

then I think we should create an SPL that handles the DDR init and then returns to the ROM code for loading U-Boot. Also we should document how this works in the README.

It is a good news you agree we can return to boot rom from SPL. Do you know what size of sram a smallest SPL need?

Exynos does something a little similar - it has a jump table of ROM routines that SPL can call.

You can essentially write your own code for SPL. I very much hope you can use start.S and cro0.S, but these add up to a tiny amount of code so should not cause problems. You should be able to put all of your code into your implementation of board_init_f(), using most of the 4KB available. U-Boot's SPL framework does add some overhead, but if you leave out the board_init_r() implementation this is very small.

If you do get stuck and find the size if over 4KB we should discuss it and see what can be done.

Regards,
Simon

author
#7 lore raw

PATCH 1/12 rockchip: define SUPPORT_SPL and SPL config in RK3288 config

Hi Simon,

Quoted 80 lines · Simon Glass

Hi Eddie,

Quoted 60 lines · Eddie Cai

Hi Simon

2015-10-23 0:30 GMT+08:00 Simon Glass <[email protected]>:

Quoted 57 lines

Hi Eddie,

Quoted 54 lines · Eddie Cai

Hi Simon

2015-10-22 22:07 GMT+08:00 Simon Glass <[email protected]>:

Quoted 34 lines

Hi Lin,

Quoted 31 lines · Lin Huang

it may not use SPL in other rockchip SOC, so move SUPPORT_SPL and SPL config to rk3288 configuration.

---
Changes in v1: None

  arch/arm/Kconfig               | 2 --
  arch/arm/mach-rockchip/Kconfig | 2 ++
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +0 -2
index 194fb7b..40fa741 100644
@@ -831,8 +831,6 @@ config TARGET_STM32F429_DISCOVERY
 
  config ARCH_ROCKCHIP
         bool "Support Rockchip SoCs"
-       select SUPPORT_SPL
-       select SPL
         select OF_CONTROL
         select CPU_V7
         select DM
arch/arm/mach-rockchip/Kconfig +0 -0
index ab50f4e..15cd380 100644
@@ -2,6 +2,8 @@ if ARCH_ROCKCHIP
 
Quoted 14 lines
Quoted 11 lines
arch/arm/mach-rockchip/Kconfig +2 -0
  config ROCKCHIP_RK3288
         bool "Support Rockchip RK3288"
+       select SUPPORT_SPL
+       select SPL
         help
           The Rockchip RK3288 is a ARM-based SoC with a quad-core

Cortex-A17
including NEON and GPU, 1MB L2 cache, Mali-T7 graphics, two
--
1.9.1

We should avoid little binary blobs for booting the chip. I think we can live with this as a stepping stone to having a proper SPL, but what is the plan for a proper SPL in U-Boot?

RK3036 have only 8k sram. 4k used by boot rom. The ddr initialize code is
almost 4k. So i don't think we can do SPL.

Quoted 7 lines
Quoted 1 line

How does U-Boot get loaded in this case? Does it use ROM code? If so

Yes, it use boot rom code to load U-Boot

Quoted 3 lines

then I think we should create an SPL that handles the DDR init and then returns to the ROM code for loading U-Boot. Also we should document how this works in the README.

It is a good news you agree we can return to boot rom from SPL. Do you know what size of sram a smallest SPL need?

Exynos does something a little similar - it has a jump table of ROM routines that SPL can call.

You can essentially write your own code for SPL. I very much hope you can use start.S and cro0.S, but these add up to a tiny amount of code so should not cause problems. You should be able to put all of your code into your implementation of board_init_f(), using most of the 4KB available. U-Boot's SPL framework does add some overhead, but if you leave out the board_init_r() implementation this is very small.

Quoted 2 lines

If you do get stuck and find the size if over 4KB we should discuss it and see what can be done.

Okay, i will reference exynos to see how to do, thank you.

Quoted 6 lines

Regards,
Simon

Signature · 1 line
Lin Huang
#8 lore raw

PATCH 1/12 rockchip: define SUPPORT_SPL and SPL config in RK3288 config

Hi,

Quoted 17 lines · hl

Hi Simon,

Quoted 12 lines · Simon Glass

Hi Eddie,

Quoted 8 lines · Eddie Cai

Hi Simon

2015-10-23 0:30 GMT+08:00 Simon Glass <[email protected]>:

Quoted 4 lines

Hi Eddie,

On 22 October 2015 at 10:01, Eddie Cai <[email protected]>

Quoted 40 lines · wrote:
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines

Hi Simon

2015-10-22 22:07 GMT+08:00 Simon Glass <[email protected]>:

Quoted 36 lines

Hi Lin,

Quoted 32 lines · Lin Huang

it may not use SPL in other rockchip SOC, so move SUPPORT_SPL and SPL config to rk3288 configuration.

---
Changes in v1: None

  arch/arm/Kconfig               | 2 --
  arch/arm/mach-rockchip/Kconfig | 2 ++
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +0 -2
index 194fb7b..40fa741 100644
@@ -831,8 +831,6 @@ config TARGET_STM32F429_DISCOVERY
 
  config ARCH_ROCKCHIP
         bool "Support Rockchip SoCs"
-       select SUPPORT_SPL
-       select SPL
         select OF_CONTROL
         select CPU_V7
         select DM
arch/arm/mach-rockchip/Kconfig +0 -0
index ab50f4e..15cd380 100644
@@ -2,6 +2,8 @@ if ARCH_ROCKCHIP
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-rockchip/Kconfig +2 -0
  config ROCKCHIP_RK3288
         bool "Support Rockchip RK3288"
+       select SUPPORT_SPL
+       select SPL
         help
           The Rockchip RK3288 is a ARM-based SoC with a quad-core

Cortex-A17
including NEON and GPU, 1MB L2 cache, Mali-T7 graphics,

two

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

--
1.9.1

We should avoid little binary blobs for booting the chip. I think we can live with this as a stepping stone to having a proper SPL, but what is the plan for a proper SPL in U-Boot?

RK3036 have only 8k sram. 4k used by boot rom. The ddr initialize code is
almost 4k. So i don't think we can do SPL.

How does U-Boot get loaded in this case? Does it use ROM code? If so

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Yes, it use boot rom code to load U-Boot

Quoted 4 lines

then I think we should create an SPL that handles the DDR init and then returns to the ROM code for loading U-Boot. Also we should document how this works in the README.

It is a good news you agree we can return to boot rom from SPL. Do you

know

Quoted 12 lines
Quoted 12 lines
Quoted 1 line

what size of sram a smallest SPL need?

Exynos does something a little similar - it has a jump table of ROM routines that SPL can call.

You can essentially write your own code for SPL. I very much hope you can use start.S and cro0.S, but these add up to a tiny amount of code so should not cause problems. You should be able to put all of your code into your implementation of board_init_f(), using most of the 4KB available. U-Boot's SPL framework does add some overhead, but if you leave out the board_init_r() implementation this is very small.

Quoted 6 lines
Quoted 2 lines

If you do get stuck and find the size if over 4KB we should discuss it and see what can be done.

Okay, i will reference exynos to see how to do, thank you.

One last point... U-Boot is written in C so as much as possible of this should be C, rather than assembler.

Regards,
Simon

author
#9 lore raw

PATCH 1/12 rockchip: define SUPPORT_SPL and SPL config in RK3288 config

Hi Simon,

Quoted 116 lines · Simon Glass

Hi,

Quoted 9 lines · On Oct 22, 2015 7:22 PM, "hl" <[email protected] <mailto:[email protected]>>…

Hi Simon,

Quoted 4 lines · Simon Glass

Hi Eddie,

On 22 October 2015 at 18:54, Eddie Cai <[email protected]

Quoted 4 lines · <mailto:[email protected]>> wrote:
Quoted 4 lines
Quoted 4 lines

Hi Simon

2015-10-23 0:30 GMT+08:00 Simon Glass <[email protected]

<mailto:[email protected]>>:

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Eddie,

On 22 October 2015 at 10:01, Eddie Cai <[email protected]

Quoted 4 lines · <mailto:[email protected]>> wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Simon

2015-10-22 22:07 GMT+08:00 Simon Glass <[email protected]

<mailto:[email protected]>>:

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Lin,

On 20 October 2015 at 20:37, Lin Huang <[email protected]

Quoted 5 lines · <mailto:[email protected]>> wrote:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

it may not use SPL in other rockchip SOC, so move SUPPORT_SPL and SPL config to rk3288 configuration.

<mailto:[email protected]>>

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines

---
Changes in v1: None

  arch/arm/Kconfig               | 2 --
  arch/arm/mach-rockchip/Kconfig | 2 ++
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +0 -2
index 194fb7b..40fa741 100644
@@ -831,8 +831,6 @@ config TARGET_STM32F429_DISCOVERY
 
  config ARCH_ROCKCHIP
         bool "Support Rockchip SoCs"
-       select SUPPORT_SPL
-       select SPL
         select OF_CONTROL
         select CPU_V7
         select DM
arch/arm/mach-rockchip/Kconfig +0 -0
index ab50f4e..15cd380 100644
@@ -2,6 +2,8 @@ if ARCH_ROCKCHIP
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-rockchip/Kconfig +2 -0
  config ROCKCHIP_RK3288
         bool "Support Rockchip RK3288"
+       select SUPPORT_SPL
+       select SPL
         help
           The Rockchip RK3288 is a ARM-based SoC with a quad-core

Cortex-A17
including NEON and GPU, 1MB L2 cache, Mali-T7

graphics, two

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

--
1.9.1

We should avoid little binary blobs for booting the chip. I

think we

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

can live with this as a stepping stone to having a proper SPL, but what is the plan for a proper SPL in U-Boot?

RK3036 have only 8k sram. 4k used by boot rom. The ddr

initialize code

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

is
almost 4k. So i don't think we can do SPL.

How does U-Boot get loaded in this case? Does it use ROM code? If so

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Yes, it use boot rom code to load U-Boot

Quoted 4 lines

then I think we should create an SPL that handles the DDR init and then returns to the ROM code for loading U-Boot. Also we should document how this works in the README.

It is a good news you agree we can return to boot rom from SPL. Do

you know

Quoted 16 lines
Quoted 14 lines
Quoted 1 line

what size of sram a smallest SPL need?

Exynos does something a little similar - it has a jump table of ROM routines that SPL can call.

You can essentially write your own code for SPL. I very much hope you can use start.S and cro0.S, but these add up to a tiny amount of code so should not cause problems. You should be able to put all of your code into your implementation of board_init_f(), using most of the 4KB available. U-Boot's SPL framework does add some overhead, but if you leave out the board_init_r() implementation this is very small.

If you do get stuck and find the size if over 4KB we should discuss it and see what can be done.

Quoted 6 lines
Quoted 2 lines

Okay, i will reference exynos to see how to do, thank you.

One last point... U-Boot is written in C so as much as possible of this should be C, rather than assembler.

Thank you for pointing that. I try to get a clean SPL(only
timer and uart driver), and it can work now,
it take about 600 bytes, i will start to port ddr driver.

Quoted 4 lines

Regards,
Simon

Signature · 1 line
Lin Huang
#10 lore raw

PATCH 1/12 rockchip: define SUPPORT_SPL and SPL config in RK3288 config

Hi Lin,

Quoted 115 lines · hl

Hi Simon,

On 26/10/15 12:12, Simon Glass wrote:

Hi,

Quoted 100 lines · hl

Hi Simon,

Quoted 95 lines · Simon Glass

Hi Eddie,

Quoted 73 lines · Eddie Cai

Hi Simon

2015-10-23 0:30 GMT+08:00 Simon Glass <[email protected]>:

Quoted 61 lines

Hi Eddie,

Quoted 56 lines · Eddie Cai

Hi Simon

2015-10-22 22:07 GMT+08:00 Simon Glass <[email protected]>:

Quoted 51 lines

Hi Lin,

Quoted 38 lines · Lin Huang

it may not use SPL in other rockchip SOC, so move SUPPORT_SPL and SPL config to rk3288 configuration.

---
Changes in v1: None

  arch/arm/Kconfig               | 2 --
  arch/arm/mach-rockchip/Kconfig | 2 ++
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +0 -2
index 194fb7b..40fa741 100644
@@ -831,8 +831,6 @@ config TARGET_STM32F429_DISCOVERY
 
  config ARCH_ROCKCHIP
         bool "Support Rockchip SoCs"
-       select SUPPORT_SPL
-       select SPL
         select OF_CONTROL
         select CPU_V7
         select DM
arch/arm/mach-rockchip/Kconfig +2 -0
index ab50f4e..15cd380 100644
@@ -2,6 +2,8 @@ if ARCH_ROCKCHIP
 
  config ROCKCHIP_RK3288
         bool "Support Rockchip RK3288"
+       select SUPPORT_SPL
+       select SPL
         help
           The Rockchip RK3288 is a ARM-based SoC with a quad-core
Quoted 6 lines

Cortex-A17
including NEON and GPU, 1MB L2 cache, Mali-T7 graphics,
two
--
1.9.1

We should avoid little binary blobs for booting the chip. I think we can live with this as a stepping stone to having a proper SPL, but what is the plan for a proper SPL in U-Boot?

Quoted 5 lines
Quoted 3 lines

RK3036 have only 8k sram. 4k used by boot rom. The ddr initialize code is
almost 4k. So i don't think we can do SPL.

How does U-Boot get loaded in this case? Does it use ROM code? If so

Yes, it use boot rom code to load U-Boot

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

then I think we should create an SPL that handles the DDR init and then returns to the ROM code for loading U-Boot. Also we should document how this works in the README.

It is a good news you agree we can return to boot rom from SPL. Do you know
what size of sram a smallest SPL need?

Exynos does something a little similar - it has a jump table of ROM routines that SPL can call.

You can essentially write your own code for SPL. I very much hope you can use start.S and cro0.S, but these add up to a tiny amount of code so should not cause problems. You should be able to put all of your code into your implementation of board_init_f(), using most of the 4KB available. U-Boot's SPL framework does add some overhead, but if you leave out the board_init_r() implementation this is very small.

Quoted 6 lines
Quoted 2 lines

If you do get stuck and find the size if over 4KB we should discuss it and see what can be done.

Okay, i will reference exynos to see how to do, thank you.

Quoted 7 lines

One last point... U-Boot is written in C so as much as possible of this should be C, rather than assembler.

Thank you for pointing that. I try to get a clean SPL(only timer and
uart driver), and it can work now,
it take about 600 bytes, i will start to port ddr driver.

Sounds good!

Thanks,
Simon

author
#11 lore raw

PATCH 1/12 rockchip: define SUPPORT_SPL and SPL config in RK3288 config

In reply to Simon Glass

Hi Simon,

Quoted 33 lines · Simon Glass

Hi Lin,

Quoted 30 lines · Lin Huang

it may not use SPL in other rockchip SOC, so move SUPPORT_SPL and SPL config to rk3288 configuration.

---
Changes in v1: None

  arch/arm/Kconfig               | 2 --
  arch/arm/mach-rockchip/Kconfig | 2 ++
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +0 -2
index 194fb7b..40fa741 100644
@@ -831,8 +831,6 @@ config TARGET_STM32F429_DISCOVERY
 
  config ARCH_ROCKCHIP
         bool "Support Rockchip SoCs"
-       select SUPPORT_SPL
-       select SPL
         select OF_CONTROL
         select CPU_V7
         select DM
arch/arm/mach-rockchip/Kconfig +0 -0
index ab50f4e..15cd380 100644
@@ -2,6 +2,8 @@ if ARCH_ROCKCHIP
 
Quoted 13 lines
Quoted 10 lines
arch/arm/mach-rockchip/Kconfig +2 -1
  config ROCKCHIP_RK3288
         bool "Support Rockchip RK3288"
+       select SUPPORT_SPL
+       select SPL
         help
           The Rockchip RK3288 is a ARM-based SoC with a quad-core Cortex-A17
           including NEON and GPU, 1MB L2 cache, Mali-T7 graphics, two
--

1.9.1

We should avoid little binary blobs for booting the chip. I think we can live with this as a stepping stone to having a proper SPL, but what is the plan for a proper SPL in U-Boot?

Since rk3036 only 8K SRAM space, so there is not enough space to use SPL to boot up Soc(i try to reduce spl space before, but it
still too large for 8K),
so i think rk3036 will use little binary blobs booting the soc, not
use SUPPORT_SPL and
SPL config, this is why i move these two config to sepcific Soc config.

Quoted 6 lines

Regards,
Simon

Signature · 1 line
Lin Huang
#12 lore raw

PATCH 1/12 rockchip: define SUPPORT_SPL and SPL config in RK3288 config

Hi Lin,

Quoted 55 lines · hl

Hi Simon,

Quoted 35 lines · Simon Glass

Hi Lin,

Quoted 31 lines · Lin Huang

it may not use SPL in other rockchip SOC, so move SUPPORT_SPL and SPL config to rk3288 configuration.

---
Changes in v1: None

  arch/arm/Kconfig               | 2 --
  arch/arm/mach-rockchip/Kconfig | 2 ++
  2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/Kconfig +0 -2
index 194fb7b..40fa741 100644
@@ -831,8 +831,6 @@ config TARGET_STM32F429_DISCOVERY
 
  config ARCH_ROCKCHIP
         bool "Support Rockchip SoCs"
-       select SUPPORT_SPL
-       select SPL
         select OF_CONTROL
         select CPU_V7
         select DM
arch/arm/mach-rockchip/Kconfig +0 -0
index ab50f4e..15cd380 100644
@@ -2,6 +2,8 @@ if ARCH_ROCKCHIP
 
Quoted 13 lines
Quoted 10 lines
arch/arm/mach-rockchip/Kconfig +2 -1
  config ROCKCHIP_RK3288
         bool "Support Rockchip RK3288"
+       select SUPPORT_SPL
+       select SPL
         help
           The Rockchip RK3288 is a ARM-based SoC with a quad-core Cortex-A17
           including NEON and GPU, 1MB L2 cache, Mali-T7 graphics, two
--

1.9.1

We should avoid little binary blobs for booting the chip. I think we can live with this as a stepping stone to having a proper SPL, but what is the plan for a proper SPL in U-Boot?

Quoted 4 lines

Since rk3036 only 8K SRAM space, so there is not enough space to
use SPL to boot up Soc(i try to reduce spl space before, but it still too large for 8K), so i think rk3036 will use little binary blobs booting the soc, not use SUPPORT_SPL and SPL config, this is why i move these two config to sepcific Soc config.

I'd like to push on this a bit. It would be fine to have SPL just be any program that works - it does not need to load U-Boot, or enable SUPPORT_SPL, etc. Any source file implementation is going to be better than a binary blob. The U-Boot build system allows you to create any SPL image you like.

Regards,
Simon

author
#13 lore raw

PATCH 2/12 rockchip: implement rockchip timer init function

In reply to Lin Huang

now the timer init function implement in board-spl.c, but it may not use SPL in other board or other rockchip SOC, so implement timer init in common.c, we can call it if we need.

---
Changes in v1: None

 arch/arm/include/asm/arch-rockchip/hardware.h |  2 +-
 arch/arm/include/asm/arch-rockchip/timer.h    | 18 ++++++++++++++++++
 arch/arm/mach-rockchip/board.c                |  8 +++++++-
 arch/arm/mach-rockchip/common.c               | 11 +++++++++++
 include/configs/rk3288_common.h               |  3 ++-
 5 files changed, 39 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-rockchip/timer.h
arch/arm/include/asm/arch-rockchip/hardware.h +1 -1
index d5af5b8..44bd67a 100644
@@ -11,7 +11,7 @@
 #define RK_SETBITS(set)			RK_CLRSETBITS(0, set)
 #define RK_CLRBITS(clr)			RK_CLRSETBITS(clr, 0)
 
-#define TIMER7_BASE		0xff810020
+#define TIMER_BASE			CONFIG_SYS_TIMER_BASE
 
 #define rk_clrsetreg(addr, clr, set)	writel((clr) << 16 | (set), addr)
 #define rk_clrreg(addr, clr)		writel((clr) << 16, addr)
arch/arm/include/asm/arch-rockchip/timer.h new file +18 -0
new file mode 100644
index 0000000..57269e9
@@ -0,0 +1,18 @@
+#ifndef __ASM_ARCH_TIMER_H
+#define __ASM_ARCH_TIMER_H
+
+struct rk_timer {
+	unsigned int timer_load_count0;
+	unsigned int timer_load_count1;
+	unsigned int timer_curr_value0;
+	unsigned int timer_curr_value1;
+	unsigned int timer_ctrl_reg;
+	unsigned int timer_int_status;
+};
+
+/**
+ * timer_init() - rockchip timer init
+ */
+void rockchip_timer_init(void);
+
+#endif
arch/arm/mach-rockchip/board.c +7 -1
index 688bc0f..789a801 100644
@@ -3,7 +3,7 @@
  *
  * SPDX-License-Identifier:     GPL-2.0+
  */
-
+#include <asm/arch/timer.h>
 #include <common.h>
 #include <dm.h>
 #include <ram.h>
@@ -12,6 +12,12 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int board_init(void)
 {
+#ifdef CONFIG_SPL_BUILD
+
+	/* have been init in spl board */
+#else
+	rockchip_timer_init();
+#endif
 	return 0;
 }
 
arch/arm/mach-rockchip/common.c +11 -0
index fc7ac72..eaf8bc1 100644
@@ -4,6 +4,8 @@
  * SPDX-License-Identifier:     GPL-2.0+
  */
 
+#include <asm/io.h>
+#include <asm/arch/timer.h>
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
@@ -26,3 +28,12 @@ void *rockchip_get_cru(void)
 
 	return (void *)addr;
 }
+
+void rockchip_timer_init(void)
+{
+	struct rk_timer * const timer_ptr = (void *)TIMER_BASE;
+
+	writel(0xffffffff, &timer_ptr->timer_load_count0);
+	writel(0xffffffff, &timer_ptr->timer_load_count1);
+	writel(1, &timer_ptr->timer_ctrl_reg);
+}
include/configs/rk3288_common.h +2 -1
index e8aec28..b4d040e 100644
@@ -24,7 +24,8 @@
 #define CONFIG_DISPLAY_BOARDINFO
 
 #define CONFIG_SYS_TIMER_RATE		(24 * 1000 * 1000)
-#define CONFIG_SYS_TIMER_COUNTER	(TIMER7_BASE + 8)
+#define CONFIG_SYS_TIMER_BASE		0xff810020 /* TIMER7 */
+#define CONFIG_SYS_TIMER_COUNTER	(CONFIG_SYS_TIMER_BASE + 8)
 
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
Signature · 1 line
1.9.1
#14 lore raw

PATCH 2/12 rockchip: implement rockchip timer init function

Quoted 8 lines · Lin Huang

now the timer init function implement in board-spl.c, but it may not use SPL in other board or other rockchip SOC, so implement timer init in common.c, we can call it if we need.

---
Changes in v1: None

Quoted 7 lines
 arch/arm/include/asm/arch-rockchip/hardware.h |  2 +-
 arch/arm/include/asm/arch-rockchip/timer.h    | 18 ++++++++++++++++++
 arch/arm/mach-rockchip/board.c                |  8 +++++++-
 arch/arm/mach-rockchip/common.c               | 11 +++++++++++
 include/configs/rk3288_common.h               |  3 ++-
 5 files changed, 39 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-rockchip/timer.h
author
#15 lore raw

PATCH 3/12 rockchip: serial driver support rk3036

In reply to Lin Huang

---
Changes in v1: None

 drivers/serial/serial_rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/serial/serial_rockchip.c +1 -1
index 0e7bbfc..1b64ea0 100644
@@ -12,7 +12,7 @@
 
 static const struct udevice_id rockchip_serial_ids[] = {
 	{ .compatible = "rockchip,rk3288-uart" },
-	{ }
+	{ .compatible = "rockchip,rk3036-uart" },
 };
 
 static int rockchip_serial_ofdata_to_platdata(struct udevice *dev)
Signature · 1 line
1.9.1
#16 lore raw

PATCH 3/12 rockchip: serial driver support rk3036

Hi Lin,

Quoted 12 lines · Lin Huang

---
Changes in v1: None

 drivers/serial/serial_rockchip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/serial/serial_rockchip.c +0 -0
index 0e7bbfc..1b64ea0 100644

drivers/serial/serial_rockchip.c line 15

Quoted 5 lines
drivers/serial/serial_rockchip.c +1 -1
@@ -12,7 +12,7 @@
 
 static const struct udevice_id rockchip_serial_ids[] = {
        { .compatible = "rockchip,rk3288-uart" },
-       { }
+       { .compatible = "rockchip,rk3036-uart" },

You should keep the {} at the end as a terminator.

Quoted 6 lines
drivers/serial/serial_rockchip.c +0 -1
 };
 
 static int rockchip_serial_ofdata_to_platdata(struct udevice *dev)
--

1.9.1

Regards,
Simon

author
#17 lore raw

PATCH 3/12 rockchip: serial driver support rk3036

Hi Simon,

Quoted 16 lines · Simon Glass

Hi Lin,

Quoted 13 lines · Lin Huang

---
Changes in v1: None

  drivers/serial/serial_rockchip.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/serial/serial_rockchip.c +0 -0
index 0e7bbfc..1b64ea0 100644
@@ -12,7 +12,7 @@
 
Quoted 5 lines

drivers/serial/serial_rockchip.c line 15

Quoted 4 lines
drivers/serial/serial_rockchip.c +1 -1
  static const struct udevice_id rockchip_serial_ids[] = {
         { .compatible = "rockchip,rk3288-uart" },
-       { }
+       { .compatible = "rockchip,rk3036-uart" },

You should keep the {} at the end as a terminator.

Oh, right, thank you, i will correct it in next version.

Quoted 12 lines
Quoted 7 lines
drivers/serial/serial_rockchip.c +0 -1
  };
 
  static int rockchip_serial_ofdata_to_platdata(struct udevice *dev)
--

1.9.1

Regards,
Simon

Signature · 1 line
Lin Huang
author
#18 lore raw

PATCH 4/12 rockchip: Bring in RK3036 device tree file includes and bindings

In reply to Lin Huang

Since rk3036 device tree file still in reviewing, bring it from
https://patchwork.kernel.org/patch/7203371/ and add some aliases we need in uboot

---
Changes in v1:
- clean copyright announcement

 arch/arm/dts/rk3036.dtsi               | 427 +++++++++++++++++++++++++++++++++
 include/dt-bindings/clock/rk3036-cru.h | 186 ++++++++++++++
 2 files changed, 613 insertions(+)
 create mode 100644 arch/arm/dts/rk3036.dtsi
 create mode 100644 include/dt-bindings/clock/rk3036-cru.h
arch/arm/dts/rk3036.dtsi new file +427 -0
new file mode 100644
index 0000000..e2f3ba9
@@ -0,0 +1,427 @@
+/*
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/pinctrl/rockchip.h>
+#include <dt-bindings/clock/rk3036-cru.h>
+#include "skeleton.dtsi"
+
+/ {
+	compatible = "rockchip,rk3036";
+
+	interrupt-parent = <&gic>;
+
+	aliases {
+		gpio0 = &gpio0;
+		gpio1 = &gpio1;
+		gpio2 = &gpio2;
+		i2c1 = &i2c1;
+		serial0 = &uart0;
+		serial1 = &uart1;
+		serial2 = &uart2;
+		mmc0 = &emmc;	
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x60000000 0x40000000>;
+	};
+
+        arm-pmu {
+                compatible = "arm,cortex-a7-pmu";
+                interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>,
+                             <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>;
+                interrupt-affinity = <&cpu0>, <&cpu1>;
+        };
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		enable-method = "rockchip,rk3036-smp";
+
+		cpu0: cpu at f00 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			reg = <0xf00>;
+			operating-points = <
+				/* KHz    uV */
+				 816000 1000000
+			>;
+			#cooling-cells = <2>; /* min followed by max */
+			clock-latency = <40000>;
+			clocks = <&cru ARMCLK>;
+			resets = <&cru SRST_CORE0>;
+		};
+		cpu1: cpu at f01 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			reg = <0xf01>;
+			resets = <&cru SRST_CORE1>;
+		};
+	};
+
+	amba {
+		compatible = "arm,amba-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+                pdma: pdma at 20078000 {
+                        compatible = "arm,pl330", "arm,primecell";
+                        reg = <0x20078000 0x4000>;
+                        arm,pl330-broken-no-flushp;
+                        interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>,
+                                     <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>;
+                        #dma-cells = <1>;
+                        clocks = <&cru ACLK_DMAC2>;
+                        clock-names = "apb_pclk";
+                };
+	};
+
+	xin24m: oscillator {
+		compatible = "fixed-clock";
+		clock-frequency = <24000000>;
+		clock-output-names = "xin24m";
+		#clock-cells = <0>;
+	};
+
+	timer {
+		compatible = "arm,armv7-timer";
+		arm,cpu-registers-not-fw-configured;
+		interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
+			     <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
+			     <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
+			     <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
+		clock-frequency = <24000000>;
+	};
+
+	cru: clock-controller at 20000000 {
+		compatible = "rockchip,rk3036-cru";
+		reg = <0x20000000 0x1000>;
+		rockchip,grf = <&grf>;
+		#clock-cells = <1>;
+		#reset-cells = <1>;
+		assigned-clocks = <&cru PLL_GPLL>;
+		assigned-clock-rates = <594000000>;
+	};
+
+	uart0: serial at 20060000 {
+		compatible = "rockchip,rk3036-uart", "snps,dw-apb-uart";
+		reg = <0x20060000 0x100>;
+		interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>;
+		reg-shift = <2>;
+		reg-io-width = <4>;
+		clock-frequency = <24000000>;
+		clocks = <&cru SCLK_UART0>, <&cru PCLK_UART0>;
+		clock-names = "baudclk", "apb_pclk";
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart0_xfer &uart0_cts &uart0_rts>;
+	};
+
+	uart1: serial at 20064000 {
+		compatible = "rockchip,rk3036-uart", "snps,dw-apb-uart";
+		reg = <0x20064000 0x100>;
+		interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
+		reg-shift = <2>;
+		reg-io-width = <4>;
+		clock-frequency = <24000000>;
+		clocks = <&cru SCLK_UART1>, <&cru PCLK_UART1>;
+		clock-names = "baudclk", "apb_pclk";
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart1_xfer>;
+	};
+
+	uart2: serial at 20068000 {
+		compatible = "rockchip,rk3036-uart", "snps,dw-apb-uart";
+		reg = <0x20068000 0x100>;
+		interrupts = <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>;
+		reg-shift = <2>;
+		reg-io-width = <4>;
+		clock-frequency = <24000000>;
+		clocks = <&cru SCLK_UART2>, <&cru PCLK_UART2>;
+		clock-names = "baudclk", "apb_pclk";
+		pinctrl-names = "default";
+		pinctrl-0 = <&uart2_xfer>;
+	};
+
+	pwm0: pwm at 20050000 {
+		compatible = "rockchip,rk2928-pwm";
+		reg = <0x20050000 0x10>;
+		#pwm-cells = <3>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pwm0_pin>;
+		clocks = <&cru PCLK_PWM>;
+		clock-names = "pwm";
+		status = "disabled";
+	};
+
+	pwm1: pwm at 20050010 {
+		compatible = "rockchip,rk2928-pwm";
+		reg = <0x20050010 0x10>;
+		#pwm-cells = <3>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pwm1_pin>;
+		clocks = <&cru PCLK_PWM>;
+		clock-names = "pwm";
+		status = "disabled";
+	};
+
+	pwm2: pwm at 20050020 {
+		compatible = "rockchip,rk2928-pwm";
+		reg = <0x20050020 0x10>;
+		#pwm-cells = <3>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pwm2_pin>;
+		clocks = <&cru PCLK_PWM>;
+		clock-names = "pwm";
+		status = "disabled";
+	};
+
+	pwm3: pwm at 20050030 {
+		compatible = "rockchip,rk2928-pwm";
+		reg = <0x20050030 0x10>;
+		#pwm-cells = <2>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pwm3_pin>;
+		clocks = <&cru PCLK_PWM>;
+		clock-names = "pwm";
+		status = "disabled";
+	};
+
+	sram: sram at 10080000 {
+		compatible = "rockchip,rk3036-smp-sram", "mmio-sram";
+		reg = <0x10080000 0x2000>;
+	};
+
+	gic: interrupt-controller at 10139000 {
+		compatible = "arm,gic-400";
+		interrupt-controller;
+		#interrupt-cells = <3>;
+		#address-cells = <0>;
+
+		reg = <0x10139000 0x1000>,
+		      <0x1013a000 0x1000>,
+		      <0x1013c000 0x2000>,
+		      <0x1013e000 0x2000>;
+		interrupts = <GIC_PPI 9 0xf04>;
+	};
+
+	grf: syscon at 20008000 {
+		compatible = "rockchip,rk3036-grf", "syscon";
+		reg = <0x20008000 0x1000>;
+	};
+
+	usb_otg: usb at 10180000 {
+		compatible = "rockchip,rk3288-usb", "rockchip,rk3066-usb",
+				"snps,dwc2";
+		reg = <0x10180000 0x40000>;
+		interrupts = <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cru HCLK_OTG0>;
+		clock-names = "otg";
+		dr_mode = "otg";
+		g-np-tx-fifo-size = <16>;
+		g-rx-fifo-size = <275>;
+		g-tx-fifo-size = <256 128 128 64 64 32>;
+		g-use-dma;
+		status = "disabled";
+	};
+
+	usb_host: usb at 101c0000 {
+		compatible = "rockchip,rk3288-usb", "rockchip,rk3066-usb",
+				"snps,dwc2";
+		reg = <0x101c0000 0x40000>;
+		interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cru HCLK_OTG1>;
+		clock-names = "otg";
+		dr_mode = "host";
+		status = "disabled";
+	};
+
+	emmc: dwmmc at 1021c000 {
+		compatible = "rockchip,rk3288-dw-mshc";
+		clock-frequency = <37500000>;
+		clock-freq-min-max = <400000 37500000>;
+		clocks = <&cru HCLK_EMMC>, <&cru SCLK_EMMC>,
+		<&cru SCLK_EMMC_DRV>, <&cru SCLK_EMMC_SAMPLE>;
+		clock-names = "biu", "ciu", "ciu_drv", "ciu_sample";
+		dmas = <&pdma 12>;
+		dma-names = "rx-tx";
+		fifo-depth = <0x100>;
+		interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
+		reg = <0x1021c000 0x4000>;
+		broken-cd;
+		bus-width = <8>;
+		cap-mmc-highspeed;
+		mmc-ddr-1_8v;
+		disable-wp;
+		non-removable;
+		num-slots = <1>;
+		default-sample-phase = <158>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&emmc_clk &emmc_cmd &emmc_bus8>;
+	};
+
+	pinctrl: pinctrl {
+		compatible = "rockchip,rk3036-pinctrl";
+		rockchip,grf = <&grf>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		gpio0: gpio0 at 2007c000 {
+			compatible = "rockchip,gpio-bank";
+			reg = <0x2007c000 0x100>;
+			interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cru PCLK_GPIO0>;
+
+			gpio-controller;
+			#gpio-cells = <2>;
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+		};
+
+		gpio1: gpio1 at 20080000 {
+			compatible = "rockchip,gpio-bank";
+			reg = <0x20080000 0x100>;
+			interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cru PCLK_GPIO1>;
+
+			gpio-controller;
+			#gpio-cells = <2>;
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+		};
+
+		gpio2: gpio2 at 20084000 {
+			compatible = "rockchip,gpio-bank";
+			reg = <0x20084000 0x100>;
+			interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cru PCLK_GPIO2>;
+
+			gpio-controller;
+			#gpio-cells = <2>;
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+		};
+
+		pcfg_pull_up: pcfg-pull-up {
+			bias-pull-up;
+		};
+
+		pcfg_pull_down: pcfg-pull-down {
+			bias-pull-down;
+		};
+
+		pcfg_pull_none: pcfg-pull-none {
+			bias-disable;
+		};
+
+		emmc {
+			/*
+			 * We run eMMC at max speed; bump up drive strength.
+			 * We also have external pulls, so disable the internal ones.
+			 */
+			emmc_clk: emmc-clk {
+				rockchip,pins = <2 4 RK_FUNC_2 &pcfg_pull_none>;
+			};
+
+			emmc_cmd: emmc-cmd {
+				rockchip,pins = <2 1 RK_FUNC_2 &pcfg_pull_none>;
+		 	};
+
+		 	emmc_bus8: emmc-bus8 {
+				rockchip,pins = <1 24 RK_FUNC_2 &pcfg_pull_none>,
+						<1 25 RK_FUNC_2 &pcfg_pull_none>,
+						<1 26 RK_FUNC_2 &pcfg_pull_none>,
+						<1 27 RK_FUNC_2 &pcfg_pull_none>;
+				/*
+						<1 28 RK_FUNC_2 &pcfg_pull_up>,
+						<1 29 RK_FUNC_2 &pcfg_pull_up>,
+						<1 30 RK_FUNC_2 &pcfg_pull_up>,
+						<1 31 RK_FUNC_2 &pcfg_pull_up>;
+						*/
+ 			};
+		};
+
+		uart0 {
+			uart0_xfer: uart0-xfer {
+				rockchip,pins = <0 16 RK_FUNC_1 &pcfg_pull_none>,
+						<0 17 RK_FUNC_1 &pcfg_pull_none>;
+			};
+
+			uart0_cts: uart0-cts {
+				rockchip,pins = <0 18 RK_FUNC_1 &pcfg_pull_none>;
+			};
+
+			uart0_rts: uart0-rts {
+				rockchip,pins = <0 19 RK_FUNC_1 &pcfg_pull_none>;
+			};
+		};
+
+		uart1 {
+			uart1_xfer: uart1-xfer {
+				rockchip,pins = <2 22 RK_FUNC_1 &pcfg_pull_none>,
+						<2 23 RK_FUNC_1 &pcfg_pull_none>;
+			};
+			/* no rts / cts for uart1 */
+		};
+
+                uart2 {
+                        uart2_xfer: uart2-xfer {
+                                rockchip,pins = <1 18 RK_FUNC_2 &pcfg_pull_none>,
+                                                <1 19 RK_FUNC_2 &pcfg_pull_none>;
+                        };
+                        /* no rts / cts for uart2 */
+                };
+
+		pwm0 {
+			pwm0_pin: pwm0-pin {
+				rockchip,pins = <0 0 RK_FUNC_2 &pcfg_pull_none>;
+			};
+		};
+
+		pwm1 {
+			pwm1_pin: pwm1-pin {
+				rockchip,pins = <0 1 RK_FUNC_2 &pcfg_pull_none>;
+			};
+		};
+
+		pwm2 {
+			pwm2_pin: pwm2-pin {
+				rockchip,pins = <0 1 2 &pcfg_pull_none>;
+			};
+		};
+
+		pwm3 {
+			pwm3_pin: pwm3-pin {
+				rockchip,pins = <0 27 1 &pcfg_pull_none>;
+			};
+		};
+
+		i2c1 {
+			i2c1_xfer: i2c1-xfer {
+				rockchip,pins = <0 2 RK_FUNC_1 &pcfg_pull_none>,
+						<0 3 RK_FUNC_1 &pcfg_pull_none>;
+			};
+		};
+	};
+
+	i2c1: i2c at 20056000 {
+		compatible = "rockchip,rk3288-i2c";
+		reg = <0x20056000 0x1000>;
+		interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		clock-names = "i2c";
+		clocks = <&cru PCLK_I2C1>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&i2c1_xfer>;
+		status = "disabled";
+	};
+};
include/dt-bindings/clock/rk3036-cru.h new file +186 -0

186 lines not on this page · raw message

Signature · 1 line
1.9.1
#19 lore raw

PATCH 4/12 rockchip: Bring in RK3036 device tree file includes and bindings

Quoted 9 lines · Lin Huang

Since rk3036 device tree file still in reviewing, bring it from
https://patchwork.kernel.org/patch/7203371/ and add some aliases we need in uboot

---
Changes in v1:
- clean copyright announcement

Quoted 5 lines
 arch/arm/dts/rk3036.dtsi               | 427 +++++++++++++++++++++++++++++++++
 include/dt-bindings/clock/rk3036-cru.h | 186 ++++++++++++++
 2 files changed, 613 insertions(+)
 create mode 100644 arch/arm/dts/rk3036.dtsi
 create mode 100644 include/dt-bindings/clock/rk3036-cru.h
author
#20 lore raw

PATCH 5/12 rockchip: rk3036: Add clock driver

In reply to Lin Huang

Add a driver for setting up and modifying the various PLLs, peripheral clocks and mmc clocks on RK3036

---
Changes in v1:
- clean copyright announcement

 arch/arm/include/asm/arch-rockchip/cru_rk3036.h |  53 +++
 drivers/clk/Makefile                            |   1 +
 drivers/clk/clk_rk3036.c                        | 522 ++++++++++++++++++++++++
 3 files changed, 576 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3036.h
 create mode 100644 drivers/clk/clk_rk3036.c
arch/arm/include/asm/arch-rockchip/cru_rk3036.h new file +53 -0
new file mode 100644
index 0000000..565491b
@@ -0,0 +1,53 @@
+/*
+ * (C) Copyright 2015 Rockchip Electronics Co., Ltd
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+#ifndef _ASM_ARCH_CRU_RK3036_H
+#define _ASM_ARCH_CRU_RK3036_H
+
+#define OSC_HZ		(24 * 1000 * 1000)
+
+#define APLL_HZ		(600 * 1000000)
+#define GPLL_HZ		(594 * 1000000)
+
+#define CORE_PERI_HZ	150000000
+#define CORE_ACLK_HZ	300000000
+
+#define CPU_ACLK_HZ	150000000
+#define CPU_HCLK_HZ	300000000
+#define CPU_PCLK_HZ	300000000
+
+#define PERI_ACLK_HZ	148500000
+#define PERI_HCLK_HZ	148500000
+#define PERI_PCLK_HZ	74250000
+
+struct rk3036_cru {
+	struct rk3036_pll {
+		u32 con0;
+		u32 con1;
+		u32 con2;
+		u32 con3;
+	} pll[4];
+	u32 cru_mode_con;
+	u32 cru_clksel_con[35];
+	u32 cru_clkgate_con[11];
+	u32 reserved;
+	u32 cru_glb_srst_fst_value;
+	u32 cru_glb_srst_snd_value;
+	u32 reserved1[2];
+	u32 cru_softrst_con[9];
+	u32 cru_misc_con;
+	u32 reserved2[2];
+	u32 cru_glb_cnt_th;
+	u32 cru_sdmmc_con[2];
+	u32 cru_sdio_con[2];
+	u32 cru_emmc_con[2];
+	u32 reserved3;
+	u32 cru_rst_st;
+	u32 reserved4[0x23];
+	u32 cru_pll_mask_con;
+};
+check_member(rk3036_cru, cru_pll_mask_con, 0x01f0);
+
+#endif
drivers/clk/Makefile +1 -0
index 008ec10..4a6a4a8 100644
@@ -6,5 +6,6 @@
 #
 
 obj-$(CONFIG_CLK) += clk-uclass.o
+obj-$(CONFIG_ROCKCHIP_RK3036) += clk_rk3036.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += clk_rk3288.o
 obj-$(CONFIG_SANDBOX) += clk_sandbox.o
drivers/clk/clk_rk3036.c new file +522 -0

522 lines not on this page · raw message

Signature · 1 line
1.9.1
#21 lore raw

PATCH 5/12 rockchip: rk3036: Add clock driver

Hi Lin,

Quoted 8 lines · Lin Huang

Add a driver for setting up and modifying the various PLLs, peripheral clocks and mmc clocks on RK3036

---
Changes in v1:
- clean copyright announcement

Quoted 7 lines
 arch/arm/include/asm/arch-rockchip/cru_rk3036.h |  53 +++
 drivers/clk/Makefile                            |   1 +
 drivers/clk/clk_rk3036.c                        | 522 ++++++++++++++++++++++++
 3 files changed, 576 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3036.h
 create mode 100644 drivers/clk/clk_rk3036.c

Please see nit below.

Quoted 8 lines
drivers/clk/clk_rk3036.c new file +8 -0
+static int rkclk_set_pll(struct rk3036_cru *cru, enum rk_clk_id clk_id,
+                        const struct pll_div *div)
+{
+       int pll_id = rk_pll_id(clk_id);
+       struct rk3036_pll *pll = &cru->pll[pll_id];
+
+       /* All PLLs have same VCO and output frequency range restrictions. */
+       uint vco_hz = OSC_HZ / 1000 * div->fbdiv / div->refdiv * 1000;

drivers/clk/clk_rk3036.c line 185

Quoted 10 lines
drivers/clk/clk_rk3036.c new file +10 -0
+       uint output_hz = vco_hz / div->postdiv1 / div->postdiv2;
+
+       debug("PLL at %p: fbdiv=%d, refdiv=%d, postdiv1=%d, postdiv2=%d,\
+                vco=%u Hz, output=%u Hz\n",
+                       pll, div->fbdiv, div->refdiv, div->postdiv1,
+                       div->postdiv2, vco_hz, output_hz);
+       assert(vco_hz >= VCO_MIN_HZ && vco_hz <= VCO_MAX_HZ &&
+              output_hz >= OUTPUT_MIN_HZ && output_hz <= OUTPUT_MAX_HZ);
+
+       /* use interger mode */

Should that be integer? What does it mean?

author
#22 lore raw

PATCH 5/12 rockchip: rk3036: Add clock driver

Hi Simon,

Quoted 33 lines · Simon Glass

Hi Lin,

Quoted 8 lines · Lin Huang

Add a driver for setting up and modifying the various PLLs, peripheral clocks and mmc clocks on RK3036

---
Changes in v1:
- clean copyright announcement

Quoted 7 lines
  arch/arm/include/asm/arch-rockchip/cru_rk3036.h |  53 +++
  drivers/clk/Makefile                            |   1 +
  drivers/clk/clk_rk3036.c                        | 522 ++++++++++++++++++++++++
  3 files changed, 576 insertions(+)

create mode 100644 arch/arm/include/asm/arch-rockchip/cru_rk3036.h create mode 100644 drivers/clk/clk_rk3036.c

Please see nit below.

Quoted 11 lines
drivers/clk/clk_rk3036.c new file +11 -0
+static int rkclk_set_pll(struct rk3036_cru *cru, enum rk_clk_id clk_id,
+                        const struct pll_div *div)
+{
+       int pll_id = rk_pll_id(clk_id);
+       struct rk3036_pll *pll = &cru->pll[pll_id];
+
+       /* All PLLs have same VCO and output frequency range restrictions. */
+       uint vco_hz = OSC_HZ / 1000 * div->fbdiv / div->refdiv * 1000;
+       uint output_hz = vco_hz / div->postdiv1 / div->postdiv2;
+
+       debug("PLL at %p: fbdiv=%d, refdiv=%d, postdiv1=%d, postdiv2=%d,\
Quoted 8 lines

drivers/clk/clk_rk3036.c line 185

Quoted 7 lines
drivers/clk/clk_rk3036.c new file +7 -0
+                vco=%u Hz, output=%u Hz\n",
+                       pll, div->fbdiv, div->refdiv, div->postdiv1,
+                       div->postdiv2, vco_hz, output_hz);
+       assert(vco_hz >= VCO_MIN_HZ && vco_hz <= VCO_MAX_HZ &&
+              output_hz >= OUTPUT_MIN_HZ && output_hz <= OUTPUT_MAX_HZ);
+
+       /* use interger mode */

Should that be integer? What does it mean?

In the rk3036 TRM, you can see:

Quoted 3 lines
Signature · 9 lines
Lin Huang

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cfdecfjf.png
Type: image/png
Size: 64226 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151023/8ec85220/attachment.png>
author
#23 lore raw

PATCH 6/12 rockchip: rk3036: Add header files for GRF

In reply to Lin Huang

GRF is the gereral register file. Add header files with register definitions.

---
Changes in v1:
- clean copyright announcement

 arch/arm/include/asm/arch-rockchip/grf_rk3036.h | 491 ++++++++++++++++++++++++
 1 file changed, 491 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/grf_rk3036.h
arch/arm/include/asm/arch-rockchip/grf_rk3036.h new file +491 -0
new file mode 100644
index 0000000..c25345e
@@ -0,0 +1,491 @@
+/*
+ * (C) Copyright 2015 Rockchip Electronics Co., Ltd
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+#ifndef _ASM_ARCH_GRF_RK3036_H
+#define _ASM_ARCH_GRF_RK3036_H
+
+struct rk3036_grf {
+	u32 reserved[0x2a];
+	u32 gpio0a_iomux;
+	u32 gpio0b_iomux;
+	u32 gpio0c_iomux;
+	u32 gpio0d_iomux;
+
+	u32 gpio1a_iomux;
+	u32 gpio1b_iomux;
+	u32 gpio1c_iomux;
+	u32 gpio1d_iomux;
+
+	u32 gpio2a_iomux;
+	u32 gpio2b_iomux;
+	u32 gpio2c_iomux;
+	u32 gpio2d_iomux;
+
+	u32 reserved2[0x0a];
+	u32 gpiods;
+	u32 reserved3[0x05];
+	u32 gpio0l_pull;
+	u32 gpio0h_pull;
+	u32 gpio1l_pull;
+	u32 gpio1h_pull;
+	u32 gpio2l_pull;
+	u32 gpio2h_pull;
+	u32 reserved4[4];
+	u32 soc_con0;
+	u32 soc_con1;
+	u32 soc_con2;
+	u32 soc_status0;
+	u32 reserved5;
+	u32 soc_con3;
+	u32 reserved6;
+	u32 dmac_con0;
+	u32 dmac_con1;
+	u32 dmac_con2;
+	u32 reserved7[5];
+	u32 uoc0_con5;
+	u32 reserved8[4];
+	u32 uoc1_con4;
+	u32 uoc1_con5;
+	u32 reserved9;
+	u32 ddrc_stat;
+	u32 uoc_con6;
+	u32 soc_status1;
+	u32 cpu_con0;
+	u32 cpu_con1;
+	u32 cpu_con2;
+	u32 cpu_con3;
+	u32 reserved10;
+	u32 reserved11;
+	u32 cpu_status0;
+	u32 cpu_status1;
+	u32 os_reg[8];
+	u32 reserved12[6];
+	u32 dll_con[4];
+	u32 dll_status[4];
+	u32 dfi_wrnum;
+	u32 dfi_rdnum;
+	u32 dfi_actnum;
+	u32 dfi_timerval;
+	u32 nfi_fifo[4];
+	u32 reserved13[0x10];
+	u32 usbphy0_con[8];
+	u32 usbphy1_con[8];
+	u32 reserved14[0x10];
+	u32 chip_tag;
+	u32 sdmmc_det_cnt;
+};
+check_member(rk3036_grf, sdmmc_det_cnt, 0x304);
+
+/* GRF_GPIO0A_IOMUX */
+enum {
+	GPIO0A3_SHIFT		= 6,
+	GPIO0A3_MASK		= 1,
+	GPIO0A3_GPIO		= 0,
+	GPIO0A3_I2C1_SDA,
+
+	GPIO0A2_SHIFT		= 4,
+	GPIO0A2_MASK		= 1,
+	GPIO0A2_GPIO		= 0,
+	GPIO0A2_I2C1_SCL,
+
+	GPIO0A1_SHIFT		= 2,
+	GPIO0A1_MASK		= 3,
+	GPIO0A1_GPIO		= 0,
+	GPIO0A1_I2C0_SDA,
+	GPIO0A1_PWM2,
+
+	GPIO0A0_SHIFT		= 0,
+	GPIO0A0_MASK		= 3,
+	GPIO0A0_GPIO		= 0,
+	GPIO0A0_I2C0_SCL,
+	GPIO0A0_PWM1,
+
+};
+
+/* GRF_GPIO0B_IOMUX */
+enum {
+	GPIO0B6_SHIFT		= 12,
+	GPIO0B6_MASK		= 3,
+	GPIO0B6_GPIO		= 0,
+	GPIO0B6_MMC1_D3,
+	GPIO0B6_I2S1_SCLK,
+
+	GPIO0B5_SHIFT		= 10,
+	GPIO0B5_MASK		= 3,
+	GPIO0B5_GPIO		= 0,
+	GPIO0B5_MMC1_D2,
+	GPIO0B5_I2S1_SDI,
+
+	GPIO0B4_SHIFT		= 8,
+	GPIO0B4_MASK		= 3,
+	GPIO0B4_GPIO		= 0,
+	GPIO0B4_MMC1_D1,
+	GPIO0B4_I2S1_LRCKTX,
+
+	GPIO0B3_SHIFT		= 6,
+	GPIO0B3_MASK		= 3,
+	GPIO0B3_GPIO		= 0,
+	GPIO0B3_MMC1_D0,
+	GPIO0B3_I2S1_LRCKRX,
+
+	GPIO0B1_SHIFT		= 2,
+	GPIO0B1_MASK		= 3,
+	GPIO0B1_GPIO		= 0,
+	GPIO0B1_MMC1_CLKOUT,
+	GPIO0B1_I2S1_MCLK,
+
+	GPIO0B0_SHIFT		= 0,
+	GPIO0B0_MASK		= 3,
+	GPIO0B0_GPIO		= 0,
+	GPIO0B0_MMC1_CMD,
+	GPIO0B0_I2S1_SDO,
+};
+
+/* GRF_GPIO0C_IOMUX */
+enum {
+	GPIO0C4_SHIFT		= 8,
+	GPIO0C4_MASK		= 1,
+	GPIO0C4_GPIO		= 0,
+	GPIO0C4_DRIVE_VBUS,
+
+	GPIO0C3_SHIFT		= 6,
+	GPIO0C3_MASK		= 1,
+	GPIO0C3_GPIO		= 0,
+	GPIO0C3_UART0_CTSN,
+
+	GPIO0C2_SHIFT		= 4,
+	GPIO0C2_MASK		= 1,
+	GPIO0C2_GPIO		= 0,
+	GPIO0C2_UART0_RTSN,
+
+	GPIO0C1_SHIFT		= 2,
+	GPIO0C1_MASK		= 1,
+	GPIO0C1_GPIO		= 0,
+	GPIO0C1_UART0_SIN,
+
+
+	GPIO0C0_SHIFT		= 0,
+	GPIO0C0_MASK		= 1,
+	GPIO0C0_GPIO		= 0,
+	GPIO0C0_UART0_SOUT,
+};
+
+/* GRF_GPIO0D_IOMUX */
+enum {
+	GPIO0D4_SHIFT		= 8,
+	GPIO0D4_MASK		= 1,
+	GPIO0D4_GPIO		= 0,
+	GPIO0D4_SPDIF,
+
+	GPIO0D3_SHIFT		= 6,
+	GPIO0D3_MASK		= 1,
+	GPIO0D3_GPIO		= 0,
+	GPIO0D3_PWM3,
+
+	GPIO0D2_SHIFT		= 4,
+	GPIO0D2_MASK		= 1,
+	GPIO0D2_GPIO		= 0,
+	GPIO0D2_PWM0,
+};
+
+/* GRF_GPIO1A_IOMUX */
+enum {
+	GPIO1A5_SHIFT		= 10,
+	GPIO1A5_MASK		= 1,
+	GPIO1A5_GPIO		= 0,
+	GPIO1A5_I2S_SDI,
+
+	GPIO1A4_SHIFT		= 8,
+	GPIO1A4_MASK		= 1,
+	GPIO1A4_GPIO		= 0,
+	GPIO1A4_I2S_SD0,
+
+	GPIO1A3_SHIFT		= 6,
+	GPIO1A3_MASK		= 1,
+	GPIO1A3_GPIO		= 0,
+	GPIO1A3_I2S_LRCKTX,
+
+	GPIO1A2_SHIFT		= 4,
+	GPIO1A2_MASK		= 6,
+	GPIO1A2_GPIO		= 0,
+	GPIO1A2_I2S_LRCKRX,
+	GPIO1A2_I2S_PWM1_0,
+
+	GPIO1A1_SHIFT		= 2,
+	GPIO1A1_MASK		= 1,
+	GPIO1A1_GPIO		= 0,
+	GPIO1A1_I2S_SCLK,
+
+	GPIO1A0_SHIFT		= 0,
+	GPIO1A0_MASK		= 1,
+	GPIO1A0_GPIO		= 0,
+	GPIO1A0_I2S_MCLK,
+
+};
+
+/* GRF_GPIO1B_IOMUX */
+enum {
+	GPIO1B7_SHIFT		= 14,
+	GPIO1B7_MASK		= 1,
+	GPIO1B7_GPIO		= 0,
+	GPIO1B7_MMC0_CMD,
+
+	GPIO1B3_SHIFT		= 6,
+	GPIO1B3_MASK		= 1,
+	GPIO1B3_GPIO		= 0,
+	GPIO1B3_HDMI_HPD,
+
+	GPIO1B2_SHIFT		= 4,
+	GPIO1B2_MASK		= 1,
+	GPIO1B2_GPIO		= 0,
+	GPIO1B2_HDMI_SCL,
+
+	GPIO1B1_SHIFT		= 2,
+	GPIO1B1_MASK		= 1,
+	GPIO1B1_GPIO		= 0,
+	GPIO1B1_HDMI_SDA,
+
+	GPIO1B0_SHIFT		= 0,
+	GPIO1B0_MASK		= 1,
+	GPIO1B0_GPIO		= 0,
+	GPIO1B0_HDMI_CEC,
+};
+
+/* GRF_GPIO1C_IOMUX */
+enum {
+	GPIO1C5_SHIFT		= 10,
+	GPIO1C5_MASK		= 3,
+	GPIO1C5_GPIO		= 0,
+	GPIO1C5_MMC0_D3,
+	GPIO1C5_JTAG_TMS,
+
+	GPIO1C4_SHIFT		= 8,
+	GPIO1C4_MASK		= 3,
+	GPIO1C4_GPIO		= 0,
+	GPIO1C4_MMC0_D2,
+	GPIO1C4_JTAG_TCK,
+
+	GPIO1C3_SHIFT		= 6,
+	GPIO1C3_MASK		= 3,
+	GPIO1C3_GPIO		= 0,
+	GPIO1C3_MMC0_D1,
+	GPIO1C3_UART2_SOUT,
+
+	GPIO1C2_SHIFT		= 4,
+	GPIO1C2_MASK		= 3,
+	GPIO1C2_GPIO		= 0,
+	GPIO1C2_MMC0_D0,
+	GPIO1C2_UART2_SIN,
+
+	GPIO1C1_SHIFT		= 2,
+	GPIO1C1_MASK		= 1,
+	GPIO1C1_GPIO		= 0,
+	GPIO1C1_MMC0_DETN,
+
+	GPIO1C0_SHIFT		= 0,
+	GPIO1C0_MASK		= 1,
+	GPIO1C0_GPIO		= 0,
+	GPIO1C0_MMC0_CLKOUT,
+};
+
+/* GRF_GPIO1D_IOMUX */
+enum {
+	GPIO1D7_SHIFT		= 14,
+	GPIO1D7_MASK		= 3,
+	GPIO1D7_GPIO		= 0,
+	GPIO1D7_NAND_D7,
+	GPIO1D7_EMMC_D7,
+	GPIO1D7_SPI_CSN1,
+
+	GPIO1D6_SHIFT		= 12,
+	GPIO1D6_MASK		= 3,
+	GPIO1D6_GPIO		= 0,
+	GPIO1D6_NAND_D6,
+	GPIO1D6_EMMC_D6,
+	GPIO1D6_SPI_CSN0,
+
+	GPIO1D5_SHIFT		= 10,
+	GPIO1D5_MASK		= 3,
+	GPIO1D5_GPIO		= 0,
+	GPIO1D5_NAND_D5,
+	GPIO1D5_EMMC_D5,
+	GPIO1D5_SPI_TXD,
+
+	GPIO1D4_SHIFT		= 8,
+	GPIO1D4_MASK		= 3,
+	GPIO1D4_GPIO		= 0,
+	GPIO1D4_NAND_D4,
+	GPIO1D4_EMMC_D4,
+	GPIO1D4_SPI_RXD,
+
+	GPIO1D3_SHIFT		= 6,
+	GPIO1D3_MASK		= 3,
+	GPIO1D3_GPIO		= 0,
+	GPIO1D3_NAND_D3,
+	GPIO1D3_EMMC_D3,
+	GPIO1D3_SFC_SIO3,
+
+	GPIO1D2_SHIFT		= 4,
+	GPIO1D2_MASK		= 3,
+	GPIO1D2_GPIO		= 0,
+	GPIO1D2_NAND_D2,
+	GPIO1D2_EMMC_D2,
+	GPIO1D2_SFC_SIO2,
+
+	GPIO1D1_SHIFT		= 2,
+	GPIO1D1_MASK		= 3,
+	GPIO1D1_GPIO		= 0,
+	GPIO1D1_NAND_D1,
+	GPIO1D1_EMMC_D1,
+	GPIO1D1_SFC_SIO1,
+
+	GPIO1D0_SHIFT		= 0,
+	GPIO1D0_MASK		= 3,
+	GPIO1D0_GPIO		= 0,
+	GPIO1D0_NAND_D0,
+	GPIO1D0_EMMC_D0,
+	GPIO1D0_SFC_SIO0,
+};
+
+/* GRF_GPIO2A_IOMUX */
+enum {
+	GPIO2A7_SHIFT		= 14,
+	GPIO2A7_MASK		= 1,
+	GPIO2A7_GPIO		= 0,
+	GPIO2A7_TESTCLK_OUT,
+
+	GPIO2A6_SHIFT		= 12,
+	GPIO2A6_MASK		= 1,
+	GPIO2A6_GPIO		= 0,
+	GPIO2A6_NAND_CS0,
+
+	GPIO2A4_SHIFT		= 8,
+	GPIO2A4_MASK		= 3,
+	GPIO2A4_GPIO		= 0,
+	GPIO2A4_NAND_RDY,
+	GPIO2A4_EMMC_CMD,
+	GPIO2A3_SFC_CLK,
+
+	GPIO2A3_SHIFT		= 6,
+	GPIO2A3_MASK		= 3,
+	GPIO2A3_GPIO		= 0,
+	GPIO2A3_NAND_RDN,
+	GPIO2A4_SFC_CSN1,
+
+	GPIO2A2_SHIFT		= 4,
+	GPIO2A2_MASK		= 3,
+	GPIO2A2_GPIO		= 0,
+	GPIO2A2_NAND_WRN,
+	GPIO2A4_SFC_CSN0,
+
+	GPIO2A1_SHIFT		= 2,
+	GPIO2A1_MASK		= 3,
+	GPIO2A1_GPIO		= 0,
+	GPIO2A1_NAND_CLE,
+	GPIO2A1_EMMC_CLKOUT,
+
+	GPIO2A0_SHIFT		= 0,
+	GPIO2A0_MASK		= 3,
+	GPIO2A0_GPIO		= 0,
+	GPIO2A0_NAND_ALE,
+	GPIO2A0_SPI_CLK,
+};
+
+/* GRF_GPIO2B_IOMUX */
+enum {
+	GPIO2B7_SHIFT		= 14,
+	GPIO2B7_MASK		= 1,
+	GPIO2B7_GPIO		= 0,
+	GPIO2B7_MAC_RXER,
+
+	GPIO2B6_SHIFT		= 12,
+	GPIO2B6_MASK		= 3,
+	GPIO2B6_GPIO		= 0,
+	GPIO2B6_MAC_CLKOUT,
+	GPIO2B6_MAC_CLKIN,
+
+	GPIO2B5_SHIFT		= 10,
+	GPIO2B5_MASK		= 1,
+	GPIO2B5_GPIO		= 0,
+	GPIO2B5_MAC_TXEN,
+
+	GPIO2B4_SHIFT		= 8,
+	GPIO2B4_MASK		= 1,
+	GPIO2B4_GPIO		= 0,
+	GPIO2B4_MAC_MDIO,
+
+	GPIO2B2_SHIFT		= 4,
+	GPIO2B2_MASK		= 1,
+	GPIO2B2_GPIO		= 0,
+	GPIO2B2_MAC_CRS,
+};
+
+/* GRF_GPIO2C_IOMUX */
+enum {
+	GPIO2C7_SHIFT		= 14,
+	GPIO2C7_MASK		= 3,
+	GPIO2C7_GPIO		= 0,
+	GPIO2C7_UART1_SOUT,
+	GPIO2C7_TESTCLK_OUT1,
+
+	GPIO2C6_SHIFT		= 12,
+	GPIO2C6_MASK		= 1,
+	GPIO2C6_GPIO		= 0,
+	GPIO2C6_UART1_SIN,
+
+	GPIO2C5_SHIFT		= 10,
+	GPIO2C5_MASK		= 1,
+	GPIO2C5_GPIO		= 0,
+	GPIO2C5_I2C2_SCL,
+
+	GPIO2C4_SHIFT		= 8,
+	GPIO2C4_MASK		= 1,
+	GPIO2C4_GPIO		= 0,
+	GPIO2C4_I2C2_SDA,
+
+	GPIO2C3_SHIFT		= 6,
+	GPIO2C3_MASK		= 1,
+	GPIO2C3_GPIO		= 0,
+	GPIO2C3_MAC_TXD0,
+
+	GPIO2C2_SHIFT		= 4,
+	GPIO2C2_MASK		= 1,
+	GPIO2C2_GPIO		= 0,
+	GPIO2C2_MAC_TXD1,
+
+	GPIO2C1_SHIFT		= 2,
+	GPIO2C1_MASK		= 1,
+	GPIO2C1_GPIO		= 0,
+	GPIO2C1_MAC_RXD0,
+
+	GPIO2C0_SHIFT		= 0,
+	GPIO2C0_MASK		= 1,
+	GPIO2C0_GPIO		= 0,
+	GPIO2C0_MAC_RXD1,
+};
+
+/* GRF_GPIO2D_IOMUX */
+enum {
+	GPIO2D6_SHIFT		= 12,
+	GPIO2D6_MASK		= 1,
+	GPIO2D6_GPIO		= 0,
+	GPIO2D6_I2S_SDO1,
+
+	GPIO2D5_SHIFT		= 10,
+	GPIO2D5_MASK		= 1,
+	GPIO2D5_GPIO		= 0,
+	GPIO2D5_I2S_SDO2,
+
+	GPIO2D4_SHIFT		= 8,
+	GPIO2D4_MASK		= 1,
+	GPIO2D4_GPIO		= 0,
+	GPIO2D4_I2S_SDO3,
+
+	GPIO2D1_SHIFT		= 2,
+	GPIO2D1_MASK		= 1,
+	GPIO2D1_GPIO		= 0,
+	GPIO2D1_MAC_MDC,
+};
+#endif
Signature · 1 line
1.9.1
#24 lore raw

PATCH 6/12 rockchip: rk3036: Add header files for GRF

Quoted 10 lines · Lin Huang

GRF is the gereral register file. Add header files with register definitions.

---
Changes in v1:
- clean copyright announcement

 arch/arm/include/asm/arch-rockchip/grf_rk3036.h | 491 ++++++++++++++++++++++++
 1 file changed, 491 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-rockchip/grf_rk3036.h
author
#25 lore raw

PATCH 7/12 rockchip: rk3036: Add Soc reset driver

In reply to Lin Huang

We can reset the Soc using some CRU (clock/reset unit) register. Add support for this.

---
Chnages in v1:
- clean copyright announcement

 arch/arm/mach-rockchip/rk3036/Makefile       |  8 +++++
 arch/arm/mach-rockchip/rk3036/reset_rk3036.c | 45 ++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/rk3036/Makefile
 create mode 100644 arch/arm/mach-rockchip/rk3036/reset_rk3036.c
arch/arm/mach-rockchip/rk3036/Makefile new file +8 -0
new file mode 100644
index 0000000..643c8d1
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2015 Rockchip Electronics Co., Ltd
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y += reset_rk3036.o
+
arch/arm/mach-rockchip/rk3036/reset_rk3036.c new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
1.9.1
#26 lore raw

PATCH 7/12 rockchip: rk3036: Add Soc reset driver

Quoted 8 lines · Lin Huang

We can reset the Soc using some CRU (clock/reset unit) register. Add support for this.

---
Chnages in v1:
- clean copyright announcement

Quoted 5 lines
 arch/arm/mach-rockchip/rk3036/Makefile       |  8 +++++
 arch/arm/mach-rockchip/rk3036/reset_rk3036.c | 45 ++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/rk3036/Makefile
 create mode 100644 arch/arm/mach-rockchip/rk3036/reset_rk3036.c
author
#27 lore raw

PATCH 8/12 rockchip: rk3036: Add a simple syscon driver

In reply to Lin Huang

Add a driver that provides access to system controllers

---
Changes in v1:
-clean copyright announcement

 arch/arm/mach-rockchip/rk3036/Makefile        |  2 +-
 arch/arm/mach-rockchip/rk3036/syscon_rk3036.c | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-rockchip/rk3036/syscon_rk3036.c
arch/arm/mach-rockchip/rk3036/Makefile +1 -1
index 643c8d1..5071551 100644
@@ -5,4 +5,4 @@
 #
 
 obj-y += reset_rk3036.o
-
+obj-y += syscon_rk3036.o
arch/arm/mach-rockchip/rk3036/syscon_rk3036.c new file +21 -0
new file mode 100644
index 0000000..965afde
@@ -0,0 +1,21 @@
+/*
+ * (C) Copyright 2015 Rockchip Electronics Co., Ltd
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <syscon.h>
+#include <asm/arch/clock.h>
+
+static const struct udevice_id rk3036_syscon_ids[] = {
+	{ .compatible = "rockchip,rk3036-grf", .data = ROCKCHIP_SYSCON_GRF },
+	{ }
+};
+
+U_BOOT_DRIVER(syscon_rk3036) = {
+	.name = "rk3036_syscon",
+	.id = UCLASS_SYSCON,
+	.of_match = rk3036_syscon_ids,
+};
Signature · 1 line
1.9.1
#28 lore raw

PATCH 8/12 rockchip: rk3036: Add a simple syscon driver

Quoted 12 lines · Lin Huang

Add a driver that provides access to system controllers

---
Changes in v1:
-clean copyright announcement

 arch/arm/mach-rockchip/rk3036/Makefile        |  2 +-
 arch/arm/mach-rockchip/rk3036/syscon_rk3036.c | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-rockchip/rk3036/syscon_rk3036.c
author
#29 lore raw

PATCH 9/12 rockchip: rk3036: Add pinctrl driver

In reply to Lin Huang

Add a driver which support pin multiplexing setup for rk3036

---
Changes in v1:
- clean copyright announcement

 drivers/pinctrl/Kconfig                   |  18 ++
 drivers/pinctrl/rockchip/Makefile         |   1 +
 drivers/pinctrl/rockchip/pinctrl_rk3036.c | 276 ++++++++++++++++++++++++++++++
 3 files changed, 295 insertions(+)
 create mode 100644 drivers/pinctrl/rockchip/pinctrl_rk3036.c
drivers/pinctrl/Kconfig +18 -0
index b8146df..8e414cd 100644
@@ -114,6 +114,24 @@ config ROCKCHIP_PINCTRL
 	  definitions and pin control functions for each available multiplex
 	  function.
 
+config ROCKCHIP_3036_PINCTRL
+	bool "Rockchip rk3036 pin control driver"
+	depends on DM
+	help
+	  Support pin multiplexing control on Rockchip rk3036 SoCs. The driver is
+	  controlled by a device tree node which contains both the GPIO
+	  definitions and pin control functions for each available multiplex
+	  function.
+
+config ROCKCHIP_PINCTRL
+	bool "Rockchip pin control driver"
+	depends on DM
+	help
+	  Support pin multiplexing control on Rockchip SoCs. The driver is
+	  controlled by a device tree node which contains both the GPIO
+	  definitions and pin control functions for each available multiplex
+	  function.
+
 config PINCTRL_SANDBOX
 	bool "Sandbox pinctrl driver"
 	depends on SANDBOX
drivers/pinctrl/rockchip/Makefile +1 -0
index 251bace..6fa7d00 100644
@@ -6,3 +6,4 @@
 #
 
 obj-$(CONFIG_ROCKCHIP_PINCTRL) += pinctrl_rk3288.o
+obj-$(CONFIG_ROCKCHIP_3036_PINCTRL) += pinctrl_rk3036.o
drivers/pinctrl/rockchip/pinctrl_rk3036.c new file +276 -0

276 lines not on this page · raw message

Signature · 1 line
1.9.1
#30 lore raw

PATCH 9/12 rockchip: rk3036: Add pinctrl driver

Quoted 7 lines · Lin Huang

Add a driver which support pin multiplexing setup for rk3036

---
Changes in v1:
- clean copyright announcement

Quoted 6 lines
 drivers/pinctrl/Kconfig                   |  18 ++
 drivers/pinctrl/rockchip/Makefile         |   1 +
 drivers/pinctrl/rockchip/pinctrl_rk3036.c | 276 ++++++++++++++++++++++++++++++
 3 files changed, 295 insertions(+)
 create mode 100644 drivers/pinctrl/rockchip/pinctrl_rk3036.c
author
#31 lore raw

PATCH 10/12 rockchip: Add an rk3036 MMC driver

In reply to Lin Huang

rk3036 mmc driver is similar to dw_mmc, but use external dma, this patch implment fifo mode, need to do dma mode in future.

---
Changes in v1:
- clean copyright announcement

 drivers/mmc/Kconfig                |   9 +
 drivers/mmc/Makefile               |   1 +
 drivers/mmc/rockchip_3036_dw_mmc.c | 479 +++++++++++++++++++++++++++++++++++++
 3 files changed, 489 insertions(+)
 create mode 100644 drivers/mmc/rockchip_3036_dw_mmc.c
drivers/mmc/Kconfig +9 -0
index 6277f92..38bfb9c 100644
@@ -19,6 +19,15 @@ config ROCKCHIP_DWMMC
 	  SD 3.0, SDIO 3.0 and MMC 4.5 and supports common eMMC chips as well
 	  as removeable SD and micro-SD cards.
 
+config ROCKCHIP_3036_DWMMC
+	bool "Rockchip 3036 SD/MMC controller support"
+	depends on DM_MMC && OF_CONTROL
+	help
+	  This enables support for the Rockchip 3036 SD/MMM controller, which is
+	  based on Designware IP. The device is compatible with at least
+	  SD 3.0, SDIO 3.0 and MMC 4.5 and supports common eMMC chips as well
+	  as removeable SD and micro-SD cards.
+
 config SH_SDHI
 	bool "SuperH/Renesas ARM SoCs on-chip SDHI host controller support"
 	depends on RMOBILE
drivers/mmc/Makefile +1 -0
index 99d0295..ff3920a 100644
@@ -30,6 +30,7 @@ obj-$(CONFIG_OMAP_HSMMC) += omap_hsmmc.o
 obj-$(CONFIG_X86) += pci_mmc.o
 obj-$(CONFIG_PXA_MMC_GENERIC) += pxa_mmc_gen.o
 obj-$(CONFIG_ROCKCHIP_DWMMC) += rockchip_dw_mmc.o
+obj-$(CONFIG_ROCKCHIP_3036_DWMMC) += rockchip_3036_dw_mmc.o
 obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o
 obj-$(CONFIG_S3C_SDI) += s3c_sdi.o
 obj-$(CONFIG_S5P_SDHCI) += s5p_sdhci.o
drivers/mmc/rockchip_3036_dw_mmc.c new file +479 -0

479 lines not on this page · raw message

Signature · 1 line
1.9.1
#32 lore raw

PATCH 10/12 rockchip: Add an rk3036 MMC driver

Hi Lin,

Quoted 70 lines · Lin Huang

rk3036 mmc driver is similar to dw_mmc, but use external dma, this patch implment fifo mode, need to do dma mode in future.

---
Changes in v1:
- clean copyright announcement

 drivers/mmc/Kconfig                |   9 +
 drivers/mmc/Makefile               |   1 +
 drivers/mmc/rockchip_3036_dw_mmc.c | 479 +++++++++++++++++++++++++++++++++++++
 3 files changed, 489 insertions(+)
 create mode 100644 drivers/mmc/rockchip_3036_dw_mmc.c
drivers/mmc/Kconfig +9 -0
index 6277f92..38bfb9c 100644
@@ -19,6 +19,15 @@ config ROCKCHIP_DWMMC
          SD 3.0, SDIO 3.0 and MMC 4.5 and supports common eMMC chips as well
          as removeable SD and micro-SD cards.
 
+config ROCKCHIP_3036_DWMMC
+       bool "Rockchip 3036 SD/MMC controller support"
+       depends on DM_MMC && OF_CONTROL
+       help
+         This enables support for the Rockchip 3036 SD/MMM controller, which is
+         based on Designware IP. The device is compatible with at least
+         SD 3.0, SDIO 3.0 and MMC 4.5 and supports common eMMC chips as well
+         as removeable SD and micro-SD cards.
+
 config SH_SDHI
        bool "SuperH/Renesas ARM SoCs on-chip SDHI host controller support"
        depends on RMOBILE
drivers/mmc/Makefile +1 -0
index 99d0295..ff3920a 100644
@@ -30,6 +30,7 @@ obj-$(CONFIG_OMAP_HSMMC) += omap_hsmmc.o
 obj-$(CONFIG_X86) += pci_mmc.o
 obj-$(CONFIG_PXA_MMC_GENERIC) += pxa_mmc_gen.o
 obj-$(CONFIG_ROCKCHIP_DWMMC) += rockchip_dw_mmc.o
+obj-$(CONFIG_ROCKCHIP_3036_DWMMC) += rockchip_3036_dw_mmc.o
 obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o
 obj-$(CONFIG_S3C_SDI) += s3c_sdi.o
 obj-$(CONFIG_S5P_SDHCI) += s5p_sdhci.o
drivers/mmc/rockchip_3036_dw_mmc.c new file +18 -0
new file mode 100644
index 0000000..2a2df52
@@ -0,0 +1,479 @@
+/*
+ * (C) Copyright 2015 Rockchip Electronics Co., Ltd
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <dwmmc.h>
+#include <errno.h>
+#include <syscon.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/periph.h>
+#include <linux/err.h>
+#include <bouncebuf.h>
+#include <common.h>
+#include <errno.h>

drivers/mmc/rockchip_3036_dw_mmc.c line 28

Quoted 10 lines
drivers/mmc/rockchip_3036_dw_mmc.c new file +10 -0
+#include <malloc.h>
+#include <memalign.h>
+#include <mmc.h>
+#include <dwmmc.h>
+#include <asm-generic/errno.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define PAGE_SIZE 4096
+#define MMC_GET_FCNT(x)                (((x)>>17) & 0x1FF)

Can we use the SHIFT and MASK enums instead (as for clocks)? I'd like to avoid these sort of macro accessors.

Quoted 7 lines
drivers/mmc/rockchip_3036_dw_mmc.c new file +7 -0
+
+struct rockchip_dwmmc_priv {
+       struct udevice *clk;
+       struct dwmci_host host;
+};
+
+static int dwmci_wait_reset(struct dwmci_host *host, u32 value)

drivers/mmc/rockchip_3036_dw_mmc.c line 45

Quoted 10 lines
drivers/mmc/rockchip_3036_dw_mmc.c new file +10 -0
+{
+       unsigned long timeout = 1000;
+       u32 ctrl;
+
+       dwmci_writel(host, DWMCI_CTRL, value);
+
+       while (timeout--) {
+               ctrl = dwmci_readl(host, DWMCI_CTRL);
+               if (!(ctrl & DWMCI_RESET_ALL))
+                       return 1;

The timeout here is somewhat indeterminate, since it does not reference the timer. Unless there is a special reason to do this (in which case we should have a comment here) we should use something like:

unsigned long start;

start = get_timer(0);
do {
} while (get_timer(start) < 1000);

Quoted 216 lines
drivers/mmc/rockchip_3036_dw_mmc.c new file +216 -0
+       }
+       return 0;
+}
+
+static int dwmci_set_transfer_mode(struct dwmci_host *host,
+               struct mmc_data *data)
+{
+       unsigned long mode;
+
+       mode = DWMCI_CMD_DATA_EXP;
+       if (data->flags & MMC_DATA_WRITE)
+               mode |= DWMCI_CMD_RW;
+
+       return mode;
+}
+
+static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
+               struct mmc_data *data)
+{
+       struct dwmci_host *host = mmc->priv;
+       int ret = 0, flags = 0, i;
+       unsigned int timeout = 100000;
+       u32 retry = 10000;
+       u32 mask;
+       ulong start = get_timer(0);
+       int size;
+       unsigned int fifo_len;
+       unsigned int *buf = 0;
+
+       while (dwmci_readl(host, DWMCI_STATUS) & DWMCI_BUSY) {
+               if (get_timer(start) > timeout) {
+                       debug("%s: Timeout on data busy\n", __func__);
+                       return TIMEOUT;
+               }
+       }
+
+       dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_ALL);
+
+       if (data) {
+               /*
+                * TODO: rk3036 use external DMA,
+                * need to support DMA mode in future
+                */
+               if (data->flags == MMC_DATA_READ)
+                       buf = (unsigned int *)data->dest;
+               else
+                       buf = (unsigned int *)data->src;
+               dwmci_writel(host, DWMCI_BLKSIZ, data->blocksize);
+               dwmci_writel(host, DWMCI_BYTCNT, data->blocksize * data->blocks);
+               dwmci_wait_reset(host, DWMCI_CTRL_FIFO_RESET);
+       }
+
+       dwmci_writel(host, DWMCI_CMDARG, cmd->cmdarg);
+
+       if (data)
+               flags = dwmci_set_transfer_mode(host, data);
+
+       if ((cmd->resp_type & MMC_RSP_136) && (cmd->resp_type & MMC_RSP_BUSY))
+               return -1;
+
+       if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
+               flags |= DWMCI_CMD_ABORT_STOP;
+       else
+               flags |= DWMCI_CMD_PRV_DAT_WAIT;
+
+       if (cmd->resp_type & MMC_RSP_PRESENT) {
+               flags |= DWMCI_CMD_RESP_EXP;
+               if (cmd->resp_type & MMC_RSP_136)
+                       flags |= DWMCI_CMD_RESP_LENGTH;
+       }
+
+       if (cmd->resp_type & MMC_RSP_CRC)
+               flags |= DWMCI_CMD_CHECK_CRC;
+
+       flags |= (cmd->cmdidx | DWMCI_CMD_START | DWMCI_CMD_USE_HOLD_REG);
+
+       debug("Sending CMD%d\n", cmd->cmdidx);
+
+       dwmci_writel(host, DWMCI_CMD, flags);
+
+       for (i = 0; i < retry; i++) {
+               mask = dwmci_readl(host, DWMCI_RINTSTS);
+               if (mask & DWMCI_INTMSK_CDONE) {
+                       if (!data)
+                               dwmci_writel(host, DWMCI_RINTSTS, mask);
+                       break;
+               }
+       }
+
+       if (i == retry) {
+               debug("%s: Timeout.\n", __func__);
+               return TIMEOUT;
+       }
+
+       if (mask & DWMCI_INTMSK_RTO) {
+               /*
+                * Timeout here is not necessarily fatal. (e)MMC cards
+                * will splat here when they receive CMD55 as they do
+                * not support this command and that is exactly the way
+                * to tell them apart from SD cards. Thus, this output
+                * below shall be debug(). eMMC cards also do not favor
+                * CMD8, please keep that in mind.
+                */
+               debug("%s: Response Timeout.\n", __func__);
+               return TIMEOUT;
+       } else if (mask & DWMCI_INTMSK_RE) {
+               debug("%s: Response Error.\n", __func__);
+               return -EIO;
+       }
+
+       if (cmd->resp_type & MMC_RSP_PRESENT) {
+               if (cmd->resp_type & MMC_RSP_136) {
+                       cmd->response[0] = dwmci_readl(host, DWMCI_RESP3);
+                       cmd->response[1] = dwmci_readl(host, DWMCI_RESP2);
+                       cmd->response[2] = dwmci_readl(host, DWMCI_RESP1);
+                       cmd->response[3] = dwmci_readl(host, DWMCI_RESP0);
+               } else {
+                       cmd->response[0] = dwmci_readl(host, DWMCI_RESP0);
+               }
+       }
+
+       if (data) {
+               size = data->blocksize * data->blocks / 4;
+               start = get_timer(0);
+               timeout = 1000;
+               for (;;) {
+                       mask = dwmci_readl(host, DWMCI_RINTSTS);
+                       /* Error during data transfer. */
+                       if (mask & (DWMCI_DATA_ERR | DWMCI_DATA_TOUT)) {
+                               debug("%s: DATA ERROR!\n", __func__);
+                               ret = -EINVAL;
+                               break;
+                       }
+
+                       /*
+                        * TODO: rk3036 use external DMA,
+                        * need to support DMA mode in future
+                        */
+                       if (data->flags == MMC_DATA_READ) {
+                               if ((dwmci_readl(host, DWMCI_RINTSTS) &&
+                                               DWMCI_INTMSK_RXDR) && size) {
+                                       fifo_len = dwmci_readl(host,
+                                                               DWMCI_STATUS);
+                                       fifo_len = MMC_GET_FCNT(fifo_len);
+                                       for (i = 0; i < fifo_len; i++)
+                                               *buf++ = dwmci_readl(host,
+                                                               DWMCI_DATA);
+                                       dwmci_writel(host, DWMCI_RINTSTS,
+                                                       DWMCI_INTMSK_RXDR);
+                                       size = size > fifo_len ?
+                                                       (size - fifo_len) : 0;
+                               }
+                       } else {
+                               if ((dwmci_readl(host, DWMCI_RINTSTS) &&
+                                               DWMCI_INTMSK_TXDR) && size) {
+                                       fifo_len = dwmci_readl(host,
+                                                       DWMCI_STATUS);
+                                       fifo_len = MMC_GET_FCNT(fifo_len);
+                                       for (i = 0; i < fifo_len; i++)
+                                               dwmci_writel(host, DWMCI_DATA,
+                                                               *buf++);
+                                       dwmci_writel(host, DWMCI_RINTSTS,
+                                                       DWMCI_INTMSK_TXDR);
+                                       size = size > fifo_len ?
+                                                       (size - fifo_len) : 0;
+                               }
+                       }
+
+                       /* Data arrived correctly. */
+                       if (mask & DWMCI_INTMSK_DTO) {
+                               ret = 0;
+                               break;
+                       }
+
+                       /* Check for timeout. */
+                       if (get_timer(start) > timeout) {
+                               debug("%s: Timeout waiting for data!\n",
+                                      __func__);
+                               ret = TIMEOUT;
+                               break;
+                       }
+               }
+               dwmci_writel(host, DWMCI_RINTSTS, mask);
+       }
+
+       udelay(100);
+
+       return ret;
+}
+
+static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
+{
+       u32 div, status;
+       int timeout = 10000;
+       unsigned long sclk;
+
+       if ((freq == host->clock) || (freq == 0))
+               return 0;
+       /*
+        * If host->get_mmc_clk isn't defined,
+        * then assume that host->bus_hz is source clock value.
+        * host->bus_hz should be set by user.
+        */
+       if (host->get_mmc_clk)
+               sclk = host->get_mmc_clk(host, freq);
+       else if (host->bus_hz)
+               sclk = host->bus_hz;
+       else {
+               debug("%s: Didn't get source clock value.\n", __func__);
+               return -EINVAL;
+       }
+
+       if (sclk == freq)
+               div = 0;        /* bypass mode */
+       else
+               div = DIV_ROUND_UP(sclk, 2 * freq);

drivers/mmc/rockchip_3036_dw_mmc.c line 271

Quoted 10 lines
drivers/mmc/rockchip_3036_dw_mmc.c new file +10 -0
+
+       dwmci_writel(host, DWMCI_CLKENA, 0);
+       dwmci_writel(host, DWMCI_CLKSRC, 0);
+
+       dwmci_writel(host, DWMCI_CLKDIV, div);
+       dwmci_writel(host, DWMCI_CMD, DWMCI_CMD_PRV_DAT_WAIT |
+                       DWMCI_CMD_UPD_CLK | DWMCI_CMD_START);
+
+       do {
+               status = dwmci_readl(host, DWMCI_CMD);

Similar here.

Quoted 209 lines
drivers/mmc/rockchip_3036_dw_mmc.c new file +208 -1
+               if (timeout-- < 0) {
+                       debug("%s: Timeout!\n", __func__);
+                       return -ETIMEDOUT;
+               }
+       } while (status & DWMCI_CMD_START);
+
+       dwmci_writel(host, DWMCI_CLKENA, DWMCI_CLKEN_ENABLE |
+                       DWMCI_CLKEN_LOW_PWR);
+
+       dwmci_writel(host, DWMCI_CMD, DWMCI_CMD_PRV_DAT_WAIT |
+                       DWMCI_CMD_UPD_CLK | DWMCI_CMD_START);
+
+       timeout = 10000;
+       do {
+               status = dwmci_readl(host, DWMCI_CMD);
+               if (timeout-- < 0) {
+                       debug("%s: Timeout!\n", __func__);
+                       return -ETIMEDOUT;
+               }
+       } while (status & DWMCI_CMD_START);
+
+       host->clock = freq;
+
+       return 0;
+}
+
+static void dwmci_set_ios(struct mmc *mmc)
+{
+       struct dwmci_host *host = (struct dwmci_host *)mmc->priv;
+       u32 ctype, regs;
+
+       debug("Buswidth = %d, clock: %d\n", mmc->bus_width, mmc->clock);
+
+       dwmci_setup_bus(host, mmc->clock);
+       switch (mmc->bus_width) {
+       case 8:
+               ctype = DWMCI_CTYPE_8BIT;
+               break;
+       case 4:
+               ctype = DWMCI_CTYPE_4BIT;
+               break;
+       default:
+               ctype = DWMCI_CTYPE_1BIT;
+               break;
+       }
+
+       dwmci_writel(host, DWMCI_CTYPE, ctype);
+
+       regs = dwmci_readl(host, DWMCI_UHS_REG);
+       if (mmc->ddr_mode)
+               regs |= DWMCI_DDR_MODE;
+       else
+               regs &= ~DWMCI_DDR_MODE;
+
+       dwmci_writel(host, DWMCI_UHS_REG, regs);
+
+       if (host->clksel)
+               host->clksel(host);
+}
+
+static int dwmci_init(struct mmc *mmc)
+{
+       struct dwmci_host *host = mmc->priv;
+
+       if (host->board_init)
+               host->board_init(host);
+
+       dwmci_writel(host, DWMCI_PWREN, 1);
+
+       if (!dwmci_wait_reset(host, DWMCI_RESET_ALL)) {
+               debug("%s[%d] Fail-reset!!\n", __func__, __LINE__);
+               return -EIO;
+       }
+
+       /* Enumerate at 400KHz */
+       dwmci_setup_bus(host, mmc->cfg->f_min);
+
+       dwmci_writel(host, DWMCI_RINTSTS, 0xFFFFFFFF);
+       dwmci_writel(host, DWMCI_INTMASK, 0);
+
+       dwmci_writel(host, DWMCI_TMOUT, 0xFFFFFFFF);
+
+       dwmci_writel(host, DWMCI_IDINTEN, 0);
+       dwmci_writel(host, DWMCI_BMOD, 1);
+
+       if (!host->fifoth_val) {
+               uint32_t fifo_size;
+               fifo_size = dwmci_readl(host, DWMCI_FIFOTH);
+               fifo_size = ((fifo_size & RX_WMARK_MASK) >> RX_WMARK_SHIFT) + 1;
+               host->fifoth_val = MSIZE(0x2) | RX_WMARK(fifo_size / 2 - 1) |
+                               TX_WMARK(fifo_size / 2);
+       }
+       dwmci_writel(host, DWMCI_FIFOTH, host->fifoth_val);
+
+       dwmci_writel(host, DWMCI_CLKENA, 0);
+       dwmci_writel(host, DWMCI_CLKSRC, 0);
+
+       return 0;
+}
+
+static const struct mmc_ops dwmci_ops = {
+       .send_cmd       = dwmci_send_cmd,
+       .set_ios        = dwmci_set_ios,
+       .init           = dwmci_init,
+};
+
+int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk)
+{
+       host->cfg.name = host->name;
+       host->cfg.ops = &dwmci_ops;
+       host->cfg.f_min = min_clk;
+       host->cfg.f_max = max_clk;
+
+       host->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
+
+       host->cfg.host_caps = host->caps;
+
+       if (host->buswidth == 8) {
+               host->cfg.host_caps |= MMC_MODE_8BIT;
+               host->cfg.host_caps &= ~MMC_MODE_4BIT;
+       } else {
+               host->cfg.host_caps |= MMC_MODE_4BIT;
+               host->cfg.host_caps &= ~MMC_MODE_8BIT;
+       }
+       host->cfg.host_caps |= MMC_MODE_HS | MMC_MODE_HS_52MHz;
+
+       host->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
+
+       host->mmc = mmc_create(&host->cfg, host);
+       if (host->mmc == NULL)
+               return -1;
+
+       return 0;
+}
+
+static uint rockchip_dwmmc_get_mmc_clk(struct dwmci_host *host, uint freq)
+{
+       struct udevice *dev = host->priv;
+       struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
+       int ret;
+
+       ret = clk_set_periph_rate(priv->clk, PERIPH_ID_SDMMC0 + host->dev_index,
+                                 freq);
+       if (ret < 0) {
+               debug("%s: err=%d\n", __func__, ret);
+               return ret;
+       }
+
+       return freq;
+}
+
+static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev)
+{
+       struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
+       struct dwmci_host *host = &priv->host;
+
+       host->name = dev->name;
+       host->ioaddr = (void *)dev_get_addr(dev);
+       host->buswidth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+                                       "bus-width", 4);
+       host->get_mmc_clk = rockchip_dwmmc_get_mmc_clk;
+       host->priv = dev;
+
+       /* use non-removeable as sdcard and emmc as judgement */
+       if (fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, "non-removable")
+                                       == -FDT_ERR_NOTFOUND)
+               host->dev_index = (ulong)host->ioaddr == 1;
+
+       return 0;
+}
+
+static int rockchip_dwmmc_probe(struct udevice *dev)
+{
+       struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+       struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
+       struct dwmci_host *host = &priv->host;
+       u32 minmax[2];
+       int ret;
+
+       ret = uclass_get_device(UCLASS_CLK, CLK_GENERAL, &priv->clk);
+       if (ret)
+               return ret;
+
+       ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+                                  "clock-freq-min-max", minmax, 2);
+       if (!ret)
+               ret = add_dwmci(host, minmax[1], minmax[0]);
+       if (ret)
+               return ret;
+
+       upriv->mmc = host->mmc;
+
+       return 0;
+}
+
+static const struct udevice_id rockchip_dwmmc_ids[] = {
+       { .compatible = "rockchip,rk3288-dw-mshc" },
+       { }
+};
+
+U_BOOT_DRIVER(rockchip_dwmmc_drv) = {
+       .name           = "rockchip_3036_dwmmc",
+       .id             = UCLASS_MMC,
+       .of_match       = rockchip_dwmmc_ids,
+       .ofdata_to_platdata = rockchip_dwmmc_ofdata_to_platdata,
+       .probe          = rockchip_dwmmc_probe,
+       .priv_auto_alloc_size = sizeof(struct rockchip_dwmmc_priv),
+};
--
Quoted 2 lines

1.9.1

Regards,
Simon

author
#33 lore raw

PATCH 10/12 rockchip: Add an rk3036 MMC driver

Hi Simon,

Quoted 77 lines · Simon Glass

Hi Lin,

Quoted 74 lines · Lin Huang

rk3036 mmc driver is similar to dw_mmc, but use external dma, this patch implment fifo mode, need to do dma mode in future.

---
Changes in v1:
- clean copyright announcement

  drivers/mmc/Kconfig                |   9 +
  drivers/mmc/Makefile               |   1 +
  drivers/mmc/rockchip_3036_dw_mmc.c | 479 +++++++++++++++++++++++++++++++++++++
  3 files changed, 489 insertions(+)

create mode 100644 drivers/mmc/rockchip_3036_dw_mmc.c

drivers/mmc/Kconfig +9 -0
index 6277f92..38bfb9c 100644
@@ -19,6 +19,15 @@ config ROCKCHIP_DWMMC
           SD 3.0, SDIO 3.0 and MMC 4.5 and supports common eMMC chips as well
           as removeable SD and micro-SD cards.
 
+config ROCKCHIP_3036_DWMMC
+       bool "Rockchip 3036 SD/MMC controller support"
+       depends on DM_MMC && OF_CONTROL
+       help
+         This enables support for the Rockchip 3036 SD/MMM controller, which is
+         based on Designware IP. The device is compatible with at least
+         SD 3.0, SDIO 3.0 and MMC 4.5 and supports common eMMC chips as well
+         as removeable SD and micro-SD cards.
+
  config SH_SDHI
         bool "SuperH/Renesas ARM SoCs on-chip SDHI host controller support"
         depends on RMOBILE
drivers/mmc/Makefile +1 -0
index 99d0295..ff3920a 100644
@@ -30,6 +30,7 @@ obj-$(CONFIG_OMAP_HSMMC) += omap_hsmmc.o
  obj-$(CONFIG_X86) += pci_mmc.o
  obj-$(CONFIG_PXA_MMC_GENERIC) += pxa_mmc_gen.o
  obj-$(CONFIG_ROCKCHIP_DWMMC) += rockchip_dw_mmc.o
+obj-$(CONFIG_ROCKCHIP_3036_DWMMC) += rockchip_3036_dw_mmc.o
  obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o
  obj-$(CONFIG_S3C_SDI) += s3c_sdi.o
  obj-$(CONFIG_S5P_SDHCI) += s5p_sdhci.o
drivers/mmc/rockchip_3036_dw_mmc.c new file +22 -0
new file mode 100644
index 0000000..2a2df52
@@ -0,0 +1,479 @@
+/*
+ * (C) Copyright 2015 Rockchip Electronics Co., Ltd
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <dwmmc.h>
+#include <errno.h>
+#include <syscon.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/periph.h>
+#include <linux/err.h>
+#include <bouncebuf.h>
+#include <common.h>
+#include <errno.h>
+#include <malloc.h>
+#include <memalign.h>
+#include <mmc.h>
+#include <dwmmc.h>
Quoted 8 lines

drivers/mmc/rockchip_3036_dw_mmc.c line 28

Quoted 6 lines
drivers/mmc/rockchip_3036_dw_mmc.c new file +6 -0
+#include <asm-generic/errno.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define PAGE_SIZE 4096
+#define MMC_GET_FCNT(x)                (((x)>>17) & 0x1FF)

Can we use the SHIFT and MASK enums instead (as for clocks)? I'd like to avoid these sort of macro accessors.

Okay, got it.

Quoted 23 lines
Quoted 8 lines
drivers/mmc/rockchip_3036_dw_mmc.c new file +7 -0
+
+struct rockchip_dwmmc_priv {
+       struct udevice *clk;
+       struct dwmci_host host;
+};
+
+static int dwmci_wait_reset(struct dwmci_host *host, u32 value)

drivers/mmc/rockchip_3036_dw_mmc.c line 45

Quoted 10 lines
drivers/mmc/rockchip_3036_dw_mmc.c new file +10 -0
+{
+       unsigned long timeout = 1000;
+       u32 ctrl;
+
+       dwmci_writel(host, DWMCI_CTRL, value);
+
+       while (timeout--) {
+               ctrl = dwmci_readl(host, DWMCI_CTRL);
+               if (!(ctrl & DWMCI_RESET_ALL))
+                       return 1;

The timeout here is somewhat indeterminate, since it does not reference the timer. Unless there is a special reason to do this (in which case we should have a comment here) we should use something like:

Quoted 5 lines

unsigned long start;

start = get_timer(0);
do {
} while (get_timer(start) < 1000);

Thanks to point it, i will modify it next version.

Quoted 220 lines
Quoted 220 lines
drivers/mmc/rockchip_3036_dw_mmc.c new file +219 -0
+       }
+       return 0;
+}
+
+static int dwmci_set_transfer_mode(struct dwmci_host *host,
+               struct mmc_data *data)
+{
+       unsigned long mode;
+
+       mode = DWMCI_CMD_DATA_EXP;
+       if (data->flags & MMC_DATA_WRITE)
+               mode |= DWMCI_CMD_RW;
+
+       return mode;
+}
+
+static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
+               struct mmc_data *data)
+{
+       struct dwmci_host *host = mmc->priv;
+       int ret = 0, flags = 0, i;
+       unsigned int timeout = 100000;
+       u32 retry = 10000;
+       u32 mask;
+       ulong start = get_timer(0);
+       int size;
+       unsigned int fifo_len;
+       unsigned int *buf = 0;
+
+       while (dwmci_readl(host, DWMCI_STATUS) & DWMCI_BUSY) {
+               if (get_timer(start) > timeout) {
+                       debug("%s: Timeout on data busy\n", __func__);
+                       return TIMEOUT;
+               }
+       }
+
+       dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_ALL);
+
+       if (data) {
+               /*
+                * TODO: rk3036 use external DMA,
+                * need to support DMA mode in future
+                */
+               if (data->flags == MMC_DATA_READ)
+                       buf = (unsigned int *)data->dest;
+               else
+                       buf = (unsigned int *)data->src;
+               dwmci_writel(host, DWMCI_BLKSIZ, data->blocksize);
+               dwmci_writel(host, DWMCI_BYTCNT, data->blocksize * data->blocks);
+               dwmci_wait_reset(host, DWMCI_CTRL_FIFO_RESET);
+       }
+
+       dwmci_writel(host, DWMCI_CMDARG, cmd->cmdarg);
+
+       if (data)
+               flags = dwmci_set_transfer_mode(host, data);
+
+       if ((cmd->resp_type & MMC_RSP_136) && (cmd->resp_type & MMC_RSP_BUSY))
+               return -1;
+
+       if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
+               flags |= DWMCI_CMD_ABORT_STOP;
+       else
+               flags |= DWMCI_CMD_PRV_DAT_WAIT;
+
+       if (cmd->resp_type & MMC_RSP_PRESENT) {
+               flags |= DWMCI_CMD_RESP_EXP;
+               if (cmd->resp_type & MMC_RSP_136)
+                       flags |= DWMCI_CMD_RESP_LENGTH;
+       }
+
+       if (cmd->resp_type & MMC_RSP_CRC)
+               flags |= DWMCI_CMD_CHECK_CRC;
+
+       flags |= (cmd->cmdidx | DWMCI_CMD_START | DWMCI_CMD_USE_HOLD_REG);
+
+       debug("Sending CMD%d\n", cmd->cmdidx);
+
+       dwmci_writel(host, DWMCI_CMD, flags);
+
+       for (i = 0; i < retry; i++) {
+               mask = dwmci_readl(host, DWMCI_RINTSTS);
+               if (mask & DWMCI_INTMSK_CDONE) {
+                       if (!data)
+                               dwmci_writel(host, DWMCI_RINTSTS, mask);
+                       break;
+               }
+       }
+
+       if (i == retry) {
+               debug("%s: Timeout.\n", __func__);
+               return TIMEOUT;
+       }
+
+       if (mask & DWMCI_INTMSK_RTO) {
+               /*
+                * Timeout here is not necessarily fatal. (e)MMC cards
+                * will splat here when they receive CMD55 as they do
+                * not support this command and that is exactly the way
+                * to tell them apart from SD cards. Thus, this output
+                * below shall be debug(). eMMC cards also do not favor
+                * CMD8, please keep that in mind.
+                */
+               debug("%s: Response Timeout.\n", __func__);
+               return TIMEOUT;
+       } else if (mask & DWMCI_INTMSK_RE) {
+               debug("%s: Response Error.\n", __func__);
+               return -EIO;
+       }
+
+       if (cmd->resp_type & MMC_RSP_PRESENT) {
+               if (cmd->resp_type & MMC_RSP_136) {
+                       cmd->response[0] = dwmci_readl(host, DWMCI_RESP3);
+                       cmd->response[1] = dwmci_readl(host, DWMCI_RESP2);
+                       cmd->response[2] = dwmci_readl(host, DWMCI_RESP1);
+                       cmd->response[3] = dwmci_readl(host, DWMCI_RESP0);
+               } else {
+                       cmd->response[0] = dwmci_readl(host, DWMCI_RESP0);
+               }
+       }
+
+       if (data) {
+               size = data->blocksize * data->blocks / 4;
+               start = get_timer(0);
+               timeout = 1000;
+               for (;;) {
+                       mask = dwmci_readl(host, DWMCI_RINTSTS);
+                       /* Error during data transfer. */
+                       if (mask & (DWMCI_DATA_ERR | DWMCI_DATA_TOUT)) {
+                               debug("%s: DATA ERROR!\n", __func__);
+                               ret = -EINVAL;
+                               break;
+                       }
+
+                       /*
+                        * TODO: rk3036 use external DMA,
+                        * need to support DMA mode in future
+                        */
+                       if (data->flags == MMC_DATA_READ) {
+                               if ((dwmci_readl(host, DWMCI_RINTSTS) &&
+                                               DWMCI_INTMSK_RXDR) && size) {
+                                       fifo_len = dwmci_readl(host,
+                                                               DWMCI_STATUS);
+                                       fifo_len = MMC_GET_FCNT(fifo_len);
+                                       for (i = 0; i < fifo_len; i++)
+                                               *buf++ = dwmci_readl(host,
+                                                               DWMCI_DATA);
+                                       dwmci_writel(host, DWMCI_RINTSTS,
+                                                       DWMCI_INTMSK_RXDR);
+                                       size = size > fifo_len ?
+                                                       (size - fifo_len) : 0;
+                               }
+                       } else {
+                               if ((dwmci_readl(host, DWMCI_RINTSTS) &&
+                                               DWMCI_INTMSK_TXDR) && size) {
+                                       fifo_len = dwmci_readl(host,
+                                                       DWMCI_STATUS);
+                                       fifo_len = MMC_GET_FCNT(fifo_len);
+                                       for (i = 0; i < fifo_len; i++)
+                                               dwmci_writel(host, DWMCI_DATA,
+                                                               *buf++);
+                                       dwmci_writel(host, DWMCI_RINTSTS,
+                                                       DWMCI_INTMSK_TXDR);
+                                       size = size > fifo_len ?
+                                                       (size - fifo_len) : 0;
+                               }
+                       }
+
+                       /* Data arrived correctly. */
+                       if (mask & DWMCI_INTMSK_DTO) {
+                               ret = 0;
+                               break;
+                       }
+
+                       /* Check for timeout. */
+                       if (get_timer(start) > timeout) {
+                               debug("%s: Timeout waiting for data!\n",
+                                      __func__);
+                               ret = TIMEOUT;
+                               break;
+                       }
+               }
+               dwmci_writel(host, DWMCI_RINTSTS, mask);
+       }
+
+       udelay(100);
+
+       return ret;
+}
+
+static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)
+{
+       u32 div, status;
+       int timeout = 10000;
+       unsigned long sclk;
+
+       if ((freq == host->clock) || (freq == 0))
+               return 0;
+       /*
+        * If host->get_mmc_clk isn't defined,
+        * then assume that host->bus_hz is source clock value.
+        * host->bus_hz should be set by user.
+        */
+       if (host->get_mmc_clk)
+               sclk = host->get_mmc_clk(host, freq);
+       else if (host->bus_hz)
+               sclk = host->bus_hz;
+       else {
+               debug("%s: Didn't get source clock value.\n", __func__);
+               return -EINVAL;
+       }
+
+       if (sclk == freq)
+               div = 0;        /* bypass mode */
+       else
+               div = DIV_ROUND_UP(sclk, 2 * freq);
+
+       dwmci_writel(host, DWMCI_CLKENA, 0);
+       dwmci_writel(host, DWMCI_CLKSRC, 0);
Quoted 8 lines

drivers/mmc/rockchip_3036_dw_mmc.c line 271

Quoted 7 lines
drivers/mmc/rockchip_3036_dw_mmc.c new file +7 -0
+
+       dwmci_writel(host, DWMCI_CLKDIV, div);
+       dwmci_writel(host, DWMCI_CMD, DWMCI_CMD_PRV_DAT_WAIT |
+                       DWMCI_CMD_UPD_CLK | DWMCI_CMD_START);
+
+       do {
+               status = dwmci_readl(host, DWMCI_CMD);

Similar here.

Got it.

Quoted 217 lines
Quoted 210 lines
drivers/mmc/rockchip_3036_dw_mmc.c new file +208 -1
+               if (timeout-- < 0) {
+                       debug("%s: Timeout!\n", __func__);
+                       return -ETIMEDOUT;
+               }
+       } while (status & DWMCI_CMD_START);
+
+       dwmci_writel(host, DWMCI_CLKENA, DWMCI_CLKEN_ENABLE |
+                       DWMCI_CLKEN_LOW_PWR);
+
+       dwmci_writel(host, DWMCI_CMD, DWMCI_CMD_PRV_DAT_WAIT |
+                       DWMCI_CMD_UPD_CLK | DWMCI_CMD_START);
+
+       timeout = 10000;
+       do {
+               status = dwmci_readl(host, DWMCI_CMD);
+               if (timeout-- < 0) {
+                       debug("%s: Timeout!\n", __func__);
+                       return -ETIMEDOUT;
+               }
+       } while (status & DWMCI_CMD_START);
+
+       host->clock = freq;
+
+       return 0;
+}
+
+static void dwmci_set_ios(struct mmc *mmc)
+{
+       struct dwmci_host *host = (struct dwmci_host *)mmc->priv;
+       u32 ctype, regs;
+
+       debug("Buswidth = %d, clock: %d\n", mmc->bus_width, mmc->clock);
+
+       dwmci_setup_bus(host, mmc->clock);
+       switch (mmc->bus_width) {
+       case 8:
+               ctype = DWMCI_CTYPE_8BIT;
+               break;
+       case 4:
+               ctype = DWMCI_CTYPE_4BIT;
+               break;
+       default:
+               ctype = DWMCI_CTYPE_1BIT;
+               break;
+       }
+
+       dwmci_writel(host, DWMCI_CTYPE, ctype);
+
+       regs = dwmci_readl(host, DWMCI_UHS_REG);
+       if (mmc->ddr_mode)
+               regs |= DWMCI_DDR_MODE;
+       else
+               regs &= ~DWMCI_DDR_MODE;
+
+       dwmci_writel(host, DWMCI_UHS_REG, regs);
+
+       if (host->clksel)
+               host->clksel(host);
+}
+
+static int dwmci_init(struct mmc *mmc)
+{
+       struct dwmci_host *host = mmc->priv;
+
+       if (host->board_init)
+               host->board_init(host);
+
+       dwmci_writel(host, DWMCI_PWREN, 1);
+
+       if (!dwmci_wait_reset(host, DWMCI_RESET_ALL)) {
+               debug("%s[%d] Fail-reset!!\n", __func__, __LINE__);
+               return -EIO;
+       }
+
+       /* Enumerate at 400KHz */
+       dwmci_setup_bus(host, mmc->cfg->f_min);
+
+       dwmci_writel(host, DWMCI_RINTSTS, 0xFFFFFFFF);
+       dwmci_writel(host, DWMCI_INTMASK, 0);
+
+       dwmci_writel(host, DWMCI_TMOUT, 0xFFFFFFFF);
+
+       dwmci_writel(host, DWMCI_IDINTEN, 0);
+       dwmci_writel(host, DWMCI_BMOD, 1);
+
+       if (!host->fifoth_val) {
+               uint32_t fifo_size;
+               fifo_size = dwmci_readl(host, DWMCI_FIFOTH);
+               fifo_size = ((fifo_size & RX_WMARK_MASK) >> RX_WMARK_SHIFT) + 1;
+               host->fifoth_val = MSIZE(0x2) | RX_WMARK(fifo_size / 2 - 1) |
+                               TX_WMARK(fifo_size / 2);
+       }
+       dwmci_writel(host, DWMCI_FIFOTH, host->fifoth_val);
+
+       dwmci_writel(host, DWMCI_CLKENA, 0);
+       dwmci_writel(host, DWMCI_CLKSRC, 0);
+
+       return 0;
+}
+
+static const struct mmc_ops dwmci_ops = {
+       .send_cmd       = dwmci_send_cmd,
+       .set_ios        = dwmci_set_ios,
+       .init           = dwmci_init,
+};
+
+int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk)
+{
+       host->cfg.name = host->name;
+       host->cfg.ops = &dwmci_ops;
+       host->cfg.f_min = min_clk;
+       host->cfg.f_max = max_clk;
+
+       host->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
+
+       host->cfg.host_caps = host->caps;
+
+       if (host->buswidth == 8) {
+               host->cfg.host_caps |= MMC_MODE_8BIT;
+               host->cfg.host_caps &= ~MMC_MODE_4BIT;
+       } else {
+               host->cfg.host_caps |= MMC_MODE_4BIT;
+               host->cfg.host_caps &= ~MMC_MODE_8BIT;
+       }
+       host->cfg.host_caps |= MMC_MODE_HS | MMC_MODE_HS_52MHz;
+
+       host->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
+
+       host->mmc = mmc_create(&host->cfg, host);
+       if (host->mmc == NULL)
+               return -1;
+
+       return 0;
+}
+
+static uint rockchip_dwmmc_get_mmc_clk(struct dwmci_host *host, uint freq)
+{
+       struct udevice *dev = host->priv;
+       struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
+       int ret;
+
+       ret = clk_set_periph_rate(priv->clk, PERIPH_ID_SDMMC0 + host->dev_index,
+                                 freq);
+       if (ret < 0) {
+               debug("%s: err=%d\n", __func__, ret);
+               return ret;
+       }
+
+       return freq;
+}
+
+static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev)
+{
+       struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
+       struct dwmci_host *host = &priv->host;
+
+       host->name = dev->name;
+       host->ioaddr = (void *)dev_get_addr(dev);
+       host->buswidth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+                                       "bus-width", 4);
+       host->get_mmc_clk = rockchip_dwmmc_get_mmc_clk;
+       host->priv = dev;
+
+       /* use non-removeable as sdcard and emmc as judgement */
+       if (fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, "non-removable")
+                                       == -FDT_ERR_NOTFOUND)
+               host->dev_index = (ulong)host->ioaddr == 1;
+
+       return 0;
+}
+
+static int rockchip_dwmmc_probe(struct udevice *dev)
+{
+       struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+       struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
+       struct dwmci_host *host = &priv->host;
+       u32 minmax[2];
+       int ret;
+
+       ret = uclass_get_device(UCLASS_CLK, CLK_GENERAL, &priv->clk);
+       if (ret)
+               return ret;
+
+       ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+                                  "clock-freq-min-max", minmax, 2);
+       if (!ret)
+               ret = add_dwmci(host, minmax[1], minmax[0]);
+       if (ret)
+               return ret;
+
+       upriv->mmc = host->mmc;
+
+       return 0;
+}
+
+static const struct udevice_id rockchip_dwmmc_ids[] = {
+       { .compatible = "rockchip,rk3288-dw-mshc" },
+       { }
+};
+
+U_BOOT_DRIVER(rockchip_dwmmc_drv) = {
+       .name           = "rockchip_3036_dwmmc",
+       .id             = UCLASS_MMC,
+       .of_match       = rockchip_dwmmc_ids,
+       .ofdata_to_platdata = rockchip_dwmmc_ofdata_to_platdata,
+       .probe          = rockchip_dwmmc_probe,
+       .priv_auto_alloc_size = sizeof(struct rockchip_dwmmc_priv),
+};
--
Quoted 2 lines

1.9.1

Regards,
Simon

Signature · 1 line
Lin Huang
author
#34 lore raw

PATCH 11/12 rockchip: rk3036: Add core Soc start-up code

In reply to Lin Huang

---
Changes in v1:
- clean copyright announcement

 arch/arm/mach-rockchip/Kconfig        |  10 ++-
 arch/arm/mach-rockchip/Makefile       |   1 +
 arch/arm/mach-rockchip/board.c        |  13 +++-
 arch/arm/mach-rockchip/rk3036/Kconfig |  11 ++++
 include/configs/rk3036_common.h       | 116 ++++++++++++++++++++++++++++++++++
 5 files changed, 149 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-rockchip/rk3036/Kconfig
 create mode 100644 include/configs/rk3036_common.h
arch/arm/mach-rockchip/Kconfig +9 -1
index 15cd380..72d61d1 100644
@@ -11,6 +11,14 @@ config ROCKCHIP_RK3288
 	  and video codec support. Peripherals include Gigabit Ethernet,
 	  USB2 host and OTG, SDIO, I2S, UART,s, SPI, I2C and PWMs.
 
+config ROCKCHIP_RK3036
+	bool "Support Rockchip RK3036"
+	help
+	  The Rockchip RK3036 is a ARM-based SoC with a dual-core Cortex-A7
+	  including NEON and GPU, Mali-400 graphics, several DDR3 options
+	  and video codec support. Peripherals include Gigabit Ethernet,
+	  USB2 host and OTG, SDIO, I2S, UART, SPI, I2C and PWMs.
+
 config SYS_MALLOC_F
 	default y
 
@@ -39,5 +47,5 @@ config ROCKCHIP_SERIAL
 	default y
 
 source "arch/arm/mach-rockchip/rk3288/Kconfig"
-
+source "arch/arm/mach-rockchip/rk3036/Kconfig"
 endif
arch/arm/mach-rockchip/Makefile +1 -0
index 5a4e383..1cdbc34 100644
@@ -11,3 +11,4 @@ obj-y += board.o
 endif
 obj-y += common.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288/
+obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036/
arch/arm/mach-rockchip/board.c +12 -1
index 789a801..d1d8856 100644
@@ -3,6 +3,8 @@
  *
  * SPDX-License-Identifier:     GPL-2.0+
  */
+
+#include <asm/io.h>
 #include <asm/arch/timer.h>
 #include <common.h>
 #include <dm.h>
@@ -23,6 +25,7 @@ int board_init(void)
 
 int dram_init(void)
 {
+#ifdef CONFIG_SPL_BUILD
 	struct ram_info ram;
 	struct udevice *dev;
 	int ret;
@@ -37,8 +40,16 @@ int dram_init(void)
 		debug("Cannot get DRAM size: %d\n", ret);
 		return ret;
 	}
-	debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
 	gd->ram_size = ram.size;
+#else
+	int i;
+	unsigned int addr;
+
+	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+		addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
+		gd->ram_size += get_ram_size((long *)addr, SDRAM_BANK_SIZE);
+	}
+#endif
 
 	return 0;
 }
arch/arm/mach-rockchip/rk3036/Kconfig new file +11 -0
new file mode 100644
index 0000000..6198ad6
@@ -0,0 +1,11 @@
+if ROCKCHIP_RK3036
+
+config TARGET_EVB_RK3036
+	bool "EVB_RK3036"
+
+config SYS_SOC
+	default "rockchip"
+
+source "board/evb_rk3036/evb_rk3036/Kconfig"
+
+endif
include/configs/rk3036_common.h new file +116 -0

116 lines not on this page · raw message

Signature · 1 line
1.9.1
#35 lore raw

PATCH 11/12 rockchip: rk3036: Add core Soc start-up code

Hi Lin,

Quoted 1 line · Lin Huang

Please add a commit message.

Quoted 73 lines

---
Changes in v1:
- clean copyright announcement

 arch/arm/mach-rockchip/Kconfig        |  10 ++-
 arch/arm/mach-rockchip/Makefile       |   1 +
 arch/arm/mach-rockchip/board.c        |  13 +++-
 arch/arm/mach-rockchip/rk3036/Kconfig |  11 ++++
 include/configs/rk3036_common.h       | 116 ++++++++++++++++++++++++++++++++++
 5 files changed, 149 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-rockchip/rk3036/Kconfig
 create mode 100644 include/configs/rk3036_common.h
arch/arm/mach-rockchip/Kconfig +9 -1
index 15cd380..72d61d1 100644
@@ -11,6 +11,14 @@ config ROCKCHIP_RK3288
          and video codec support. Peripherals include Gigabit Ethernet,
          USB2 host and OTG, SDIO, I2S, UART,s, SPI, I2C and PWMs.
 
+config ROCKCHIP_RK3036
+       bool "Support Rockchip RK3036"
+       help
+         The Rockchip RK3036 is a ARM-based SoC with a dual-core Cortex-A7
+         including NEON and GPU, Mali-400 graphics, several DDR3 options
+         and video codec support. Peripherals include Gigabit Ethernet,
+         USB2 host and OTG, SDIO, I2S, UART, SPI, I2C and PWMs.
+
 config SYS_MALLOC_F
        default y
 
@@ -39,5 +47,5 @@ config ROCKCHIP_SERIAL
        default y
 
 source "arch/arm/mach-rockchip/rk3288/Kconfig"
-
+source "arch/arm/mach-rockchip/rk3036/Kconfig"
 endif
arch/arm/mach-rockchip/Makefile +1 -0
index 5a4e383..1cdbc34 100644
@@ -11,3 +11,4 @@ obj-y += board.o
 endif
 obj-y += common.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288/
+obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036/
arch/arm/mach-rockchip/board.c +3 -0
index 789a801..d1d8856 100644
@@ -3,6 +3,8 @@
  *
  * SPDX-License-Identifier:     GPL-2.0+
  */
+
+#include <asm/io.h>
 #include <asm/arch/timer.h>
 #include <common.h>
 #include <dm.h>
@@ -23,6 +25,7 @@ int board_init(void)
 
 int dram_init(void)
 {
+#ifdef CONFIG_SPL_BUILD
        struct ram_info ram;
        struct udevice *dev;
        int ret;
@@ -37,8 +40,16 @@ int dram_init(void)
                debug("Cannot get DRAM size: %d\n", ret);
                return ret;
        }

arch/arm/mach-rockchip/board.c int dram_init(void) · line 51

Quoted 10 lines
arch/arm/mach-rockchip/board.c +8 -1
-       debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
        gd->ram_size = ram.size;
+#else
+       int i;
+       unsigned int addr;
+
+       for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+               addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
+               gd->ram_size += get_ram_size((long *)addr, SDRAM_BANK_SIZE);
+       }

I think this code should go in a new RAM driver - see the RK3288 version. All it needs to do is to implement the get_info() method.

Of course we need to figure out the proper RAM init too in SPL, but it sounds like that would not use driver model due to the 8KB space constraint.

arch/arm/mach-rockchip/board.c int dram_init(void) · line 54

Quoted 3 lines
arch/arm/mach-rockchip/board.c +3 -0
+config TARGET_EVB_RK3036
+       bool "EVB_RK3036"
+

Please add some help for this, describing the board.

Regards,
Simon

author
#36 lore raw

PATCH 12/12 rockchip: Add basic support for evb-rk3036 board

In reply to Lin Huang

This add some basic files required to allow the board to dispaly serial message and can run command(mmc info etc)

---
Changes in v1:
- clean copyright announcement

 arch/arm/dts/Makefile                    |  3 ++-
 arch/arm/dts/rk3036-sdk.dts              | 46 ++++++++++++++++++++++++++++++++
 board/evb_rk3036/evb_rk3036/Kconfig      | 15 +++++++++++
 board/evb_rk3036/evb_rk3036/MAINTAINERS  |  0
 board/evb_rk3036/evb_rk3036/Makefile     |  7 +++++
 board/evb_rk3036/evb_rk3036/evb_rk3036.c |  7 +++++
 configs/evb-rk3036_defconfig             | 41 ++++++++++++++++++++++++++++
 include/configs/evb_rk3036.h             | 12 +++++++++
 8 files changed, 130 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/rk3036-sdk.dts
 create mode 100644 board/evb_rk3036/evb_rk3036/Kconfig
 create mode 100644 board/evb_rk3036/evb_rk3036/MAINTAINERS
 create mode 100644 board/evb_rk3036/evb_rk3036/Makefile
 create mode 100644 board/evb_rk3036/evb_rk3036/evb_rk3036.c
 create mode 100644 configs/evb-rk3036_defconfig
 create mode 100644 include/configs/evb_rk3036.h
arch/arm/dts/Makefile +2 -1
index 3babe65..d007199 100644
@@ -17,7 +17,8 @@ dtb-$(CONFIG_EXYNOS5) += exynos5250-arndale.dtb \
 	exynos5422-odroidxu3.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += \
 	rk3288-firefly.dtb \
-	rk3288-jerry.dtb
+	rk3288-jerry.dtb \
+	rk3036-sdk.dtb
 dtb-$(CONFIG_TEGRA) += tegra20-harmony.dtb \
 	tegra20-medcom-wide.dtb \
 	tegra20-paz00.dtb \
arch/arm/dts/rk3036-sdk.dts new file +46 -0

46 lines not on this page · raw message

board/evb_rk3036/evb_rk3036/Kconfig new file +15 -0
new file mode 100644
index 0000000..ae2a9eb
@@ -0,0 +1,15 @@
+if TARGET_EVB_RK3036
+
+config SYS_BOARD
+	default "evb_rk3036"
+
+config SYS_VENDOR
+	default "evb_rk3036"
+
+config SYS_CONFIG_NAME
+	default "evb_rk3036"
+
+config BOARD_SPECIFIC_OPTIONS # dummy
+	def_bool y
+
+endif
board/evb_rk3036/evb_rk3036/MAINTAINERS new file +0 -0
new file mode 100644
index 0000000..e69de29
board/evb_rk3036/evb_rk3036/Makefile new file +7 -0
new file mode 100644
index 0000000..0403836
@@ -0,0 +1,7 @@
+#
+# (C) Copyright 2015 Google, Inc
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y	+= evb_rk3036.o
board/evb_rk3036/evb_rk3036/evb_rk3036.c new file +7 -0
new file mode 100644
index 0000000..19850ff
@@ -0,0 +1,7 @@
+/*
+ * (C) Copyright 2015 Rockchip Electronics Co., Ltd
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
configs/evb-rk3036_defconfig new file +41 -0

41 lines not on this page · raw message

include/configs/evb_rk3036.h new file +12 -0
new file mode 100644
index 0000000..aa07889
@@ -0,0 +1,12 @@
+/*
+ * (C) Copyright 2015 Rockchip Electronics Co., Ltd
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#include <configs/rk3036_common.h>
+
+#endif
Signature · 1 line
1.9.1
#37 lore raw

PATCH 12/12 rockchip: Add basic support for evb-rk3036 board

Quoted 8 lines · Lin Huang

This add some basic files required to allow the board to dispaly serial message and can run command(mmc info etc)

---
Changes in v1:
- clean copyright announcement

Quoted 17 lines
 arch/arm/dts/Makefile                    |  3 ++-
 arch/arm/dts/rk3036-sdk.dts              | 46 ++++++++++++++++++++++++++++++++
 board/evb_rk3036/evb_rk3036/Kconfig      | 15 +++++++++++
 board/evb_rk3036/evb_rk3036/MAINTAINERS  |  0
 board/evb_rk3036/evb_rk3036/Makefile     |  7 +++++
 board/evb_rk3036/evb_rk3036/evb_rk3036.c |  7 +++++
 configs/evb-rk3036_defconfig             | 41 ++++++++++++++++++++++++++++
 include/configs/evb_rk3036.h             | 12 +++++++++
 8 files changed, 130 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/rk3036-sdk.dts
 create mode 100644 board/evb_rk3036/evb_rk3036/Kconfig
 create mode 100644 board/evb_rk3036/evb_rk3036/MAINTAINERS
 create mode 100644 board/evb_rk3036/evb_rk3036/Makefile
 create mode 100644 board/evb_rk3036/evb_rk3036/evb_rk3036.c
 create mode 100644 configs/evb-rk3036_defconfig
 create mode 100644 include/configs/evb_rk3036.h

Can you also please update doc/README.rockchip with build instructions and how to get an image onto this board?

Regards,
Simon

author
#38 lore raw

PATCH 12/12 rockchip: Add basic support for evb-rk3036 board

Hi Simon,

Quoted 26 lines · Simon Glass
Quoted 17 lines · Lin Huang

This add some basic files required to allow the board to dispaly serial message and can run command(mmc info etc)

---
Changes in v1:
- clean copyright announcement

  arch/arm/dts/Makefile                    |  3 ++-
  arch/arm/dts/rk3036-sdk.dts              | 46 ++++++++++++++++++++++++++++++++
  board/evb_rk3036/evb_rk3036/Kconfig      | 15 +++++++++++
  board/evb_rk3036/evb_rk3036/MAINTAINERS  |  0
  board/evb_rk3036/evb_rk3036/Makefile     |  7 +++++
  board/evb_rk3036/evb_rk3036/evb_rk3036.c |  7 +++++
  configs/evb-rk3036_defconfig             | 41 ++++++++++++++++++++++++++++
  include/configs/evb_rk3036.h             | 12 +++++++++
  8 files changed, 130 insertions(+), 1 deletion(-)
Quoted 8 lines

create mode 100644 arch/arm/dts/rk3036-sdk.dts create mode 100644 board/evb_rk3036/evb_rk3036/Kconfig create mode 100644 board/evb_rk3036/evb_rk3036/MAINTAINERS create mode 100644 board/evb_rk3036/evb_rk3036/Makefile create mode 100644 board/evb_rk3036/evb_rk3036/evb_rk3036.c create mode 100644 configs/evb-rk3036_defconfig create mode 100644 include/configs/evb_rk3036.h

Quoted 2 lines

Can you also please update doc/README.rockchip with build instructions and how to get an image onto this board?

I try to figure out how to merge binary blob and u-boot-dtb.bin use
mkimage,
i will update doc/README ASAP when i finish it. And where should
the binary blob store?

Quoted 5 lines

Regards,
Simon

Signature · 1 line
Lin Huang
#39 lore raw

PATCH 12/12 rockchip: Add basic support for evb-rk3036 board

Hi,

Quoted 34 lines · hl

Hi Simon,

Quoted 30 lines · Simon Glass
Quoted 28 lines · Lin Huang

This add some basic files required to allow the board to dispaly serial message and can run command(mmc info etc)

---
Changes in v1:
- clean copyright announcement

  arch/arm/dts/Makefile                    |  3 ++-
  arch/arm/dts/rk3036-sdk.dts              | 46
++++++++++++++++++++++++++++++++
  board/evb_rk3036/evb_rk3036/Kconfig      | 15 +++++++++++
  board/evb_rk3036/evb_rk3036/MAINTAINERS  |  0
  board/evb_rk3036/evb_rk3036/Makefile     |  7 +++++
  board/evb_rk3036/evb_rk3036/evb_rk3036.c |  7 +++++
  configs/evb-rk3036_defconfig             | 41
++++++++++++++++++++++++++++
  include/configs/evb_rk3036.h             | 12 +++++++++
  8 files changed, 130 insertions(+), 1 deletion(-)

create mode 100644 arch/arm/dts/rk3036-sdk.dts create mode 100644 board/evb_rk3036/evb_rk3036/Kconfig create mode 100644 board/evb_rk3036/evb_rk3036/MAINTAINERS create mode 100644 board/evb_rk3036/evb_rk3036/Makefile create mode 100644 board/evb_rk3036/evb_rk3036/evb_rk3036.c create mode 100644 configs/evb-rk3036_defconfig create mode 100644 include/configs/evb_rk3036.h

Quoted 7 lines
Quoted 2 lines

Can you also please update doc/README.rockchip with build instructions and how to get an image onto this board?

I try to figure out how to merge binary blob and u-boot-dtb.bin use
mkimage,
i will update doc/README ASAP when i finish it. And where should the
binary blob store?

Hopefully we don't need the binary block, and u-boot-spl.bin will contain all the code needed. There are boards already with tiny SPL images.

Then you can just provide instructions on how to build the image, perhaps with the 'dd' tool. You don't need to build an entire image in the build system - just provide instructions on how someone might put the SPL and U-Boot onto an SD card and get it to boot.

Regards,
Simon

author
#40 lore raw

PATCH 12/12 rockchip: Add basic support for evb-rk3036 board

Hi Simon,

Quoted 41 lines · Simon Glass

Hi,

Quoted 32 lines · hl

Hi Simon,

Quoted 28 lines · Simon Glass
Quoted 27 lines · Lin Huang

This add some basic files required to allow the board to dispaly serial message and can run command(mmc info etc)

---
Changes in v1:
- clean copyright announcement

   arch/arm/dts/Makefile                    |  3 ++-
   arch/arm/dts/rk3036-sdk.dts              | 46
++++++++++++++++++++++++++++++++
   board/evb_rk3036/evb_rk3036/Kconfig      | 15 +++++++++++
   board/evb_rk3036/evb_rk3036/MAINTAINERS  |  0
   board/evb_rk3036/evb_rk3036/Makefile     |  7 +++++
   board/evb_rk3036/evb_rk3036/evb_rk3036.c |  7 +++++
   configs/evb-rk3036_defconfig             | 41
++++++++++++++++++++++++++++
   include/configs/evb_rk3036.h             | 12 +++++++++
   8 files changed, 130 insertions(+), 1 deletion(-)

create mode 100644 arch/arm/dts/rk3036-sdk.dts create mode 100644 board/evb_rk3036/evb_rk3036/Kconfig create mode 100644 board/evb_rk3036/evb_rk3036/MAINTAINERS create mode 100644 board/evb_rk3036/evb_rk3036/Makefile create mode 100644 board/evb_rk3036/evb_rk3036/evb_rk3036.c create mode 100644 configs/evb-rk3036_defconfig create mode 100644 include/configs/evb_rk3036.h

Quoted 6 lines
Quoted 2 lines

Can you also please update doc/README.rockchip with build instructions and how to get an image onto this board?

I try to figure out how to merge binary blob and u-boot-dtb.bin use
mkimage,
i will update doc/README ASAP when i finish it. And where should the
binary blob store?

Quoted 8 lines

Hopefully we don't need the binary block, and u-boot-spl.bin will contain all the code needed. There are boards already with tiny SPL images.

Then you can just provide instructions on how to build the image, perhaps with the 'dd' tool. You don't need to build an entire image in the build system - just provide instructions on how someone might put the SPL and U-Boot onto an SD card and get it to boot.

Okay, i will implement rk3036 sdram driver first, and try to run it
in SPL,
it may take some times.

Quoted 5 lines

Regards,
Simon

Signature · 1 line
Lin Huang
#41 lore raw

PATCH 12/12 rockchip: Add basic support for evb-rk3036 board

Hi,

Quoted 62 lines · hl

Hi Simon,

Quoted 48 lines · Simon Glass

Hi,

Quoted 35 lines · hl

Hi Simon,

Quoted 30 lines · Simon Glass
Quoted 28 lines · Lin Huang

This add some basic files required to allow the board to dispaly serial message and can run command(mmc info etc)

---
Changes in v1:
- clean copyright announcement

   arch/arm/dts/Makefile                    |  3 ++-
   arch/arm/dts/rk3036-sdk.dts              | 46
++++++++++++++++++++++++++++++++
   board/evb_rk3036/evb_rk3036/Kconfig      | 15 +++++++++++
   board/evb_rk3036/evb_rk3036/MAINTAINERS  |  0
   board/evb_rk3036/evb_rk3036/Makefile     |  7 +++++
   board/evb_rk3036/evb_rk3036/evb_rk3036.c |  7 +++++
   configs/evb-rk3036_defconfig             | 41
++++++++++++++++++++++++++++
   include/configs/evb_rk3036.h             | 12 +++++++++
   8 files changed, 130 insertions(+), 1 deletion(-)

create mode 100644 arch/arm/dts/rk3036-sdk.dts create mode 100644 board/evb_rk3036/evb_rk3036/Kconfig create mode 100644 board/evb_rk3036/evb_rk3036/MAINTAINERS create mode 100644 board/evb_rk3036/evb_rk3036/Makefile create mode 100644 board/evb_rk3036/evb_rk3036/evb_rk3036.c create mode 100644 configs/evb-rk3036_defconfig create mode 100644 include/configs/evb_rk3036.h

Quoted 8 lines
Quoted 2 lines

Can you also please update doc/README.rockchip with build instructions and how to get an image onto this board?

I try to figure out how to merge binary blob and u-boot-dtb.bin use
mkimage,
i will update doc/README ASAP when i finish it. And where should
the
binary blob store?

Quoted 8 lines

Hopefully we don't need the binary block, and u-boot-spl.bin will contain all the code needed. There are boards already with tiny SPL images.

Then you can just provide instructions on how to build the image, perhaps with the 'dd' tool. You don't need to build an entire image in the build system - just provide instructions on how someone might put the SPL and U-Boot onto an SD card and get it to boot.

Quoted 3 lines

Okay, i will implement rk3036 sdram driver first, and try to run it in
SPL,
it may take some times.

Sounds good, thanks. Perhaps the rk3288 driver might be a starting point? I'm not sure how similar they are.

Regards,
Simon