ARM: mx5: use config to define boot related addresses
Subsystems (3)
PATCH 1/6 ARM: mx5: use config to define boot related addresses
---
This series of patch support mx50 reference design board. I've tested it using initramfs on the board.
arch/arm/mach-mx5/Makefile.boot | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-mx5/Makefile.boot +3 -3
@@ -1,3 +1,3 @@ - zreladdr-y := 0x90008000 -params_phys-y := 0x90000100 -initrd_phys-y := 0x90800000 + zreladdr-$(CONFIG_SOC_IMX51) := 0x90008000 +params_phys-$(CONFIG_SOC_IMX51) := 0x90000100 +initrd_phys-$(CONFIG_SOC_IMX51) := 0x90800000
Signature · 1 line
1.6.3.3
PATCH 1/6 ARM: mx5: use config to define boot related addresses
Hello,
Quoted 13 lines · Richard Zhao
Signed-off-by Richard Zhao <[email protected]>---
This series of patch support mx50 reference design board. I've tested it using initramfs on the board.arch/arm/mach-mx5/Makefile.boot | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)arch/arm/mach-mx5/Makefile.boot +0
-0
arch/arm/mach-mx5/Makefile.boot line 3
Quoted 6 lines
arch/arm/mach-mx5/Makefile.boot +3
-3@@ -1,3 +1,3 @@ - zreladdr-y := 0x90008000 -params_phys-y := 0x90000100 -initrd_phys-y := 0x90800000 + zreladdr-$(CONFIG_SOC_IMX51) := 0x90008000 +params_phys-$(CONFIG_SOC_IMX51) := 0x90000100 +initrd_phys-$(CONFIG_SOC_IMX51) := 0x90800000
That is one of the places that is not multi-soc capable. You can make it 66% less worse by just removing params_phys and initrd_phys.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/6 ARM: mx5: use config to define boot related addresses
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 11 lines
Hello,
Quoted 8 lines · Richard Zhao
Signed-off-by Richard Zhao <[email protected]>---
This series of patch support mx50 reference design board. I've tested it using initramfs on the board.?arch/arm/mach-mx5/Makefile.boot | ? ?6 +++---
?1 files changed, 3 insertions(+), 3 deletions(-)
Quoted 13 lines
arch/arm/mach-mx5/Makefile.boot line 3
Quoted 11 lines
arch/arm/mach-mx5/Makefile.boot +3
-3@@ -1,3 +1,3 @@ - ? zreladdr-y ? ? ? ?:= 0x90008000 -params_phys-y ? ? ? ?:= 0x90000100 -initrd_phys-y ? ? ? ?:= 0x90800000 + ? zreladdr-$(CONFIG_SOC_IMX51) ? ? ?:= 0x90008000 +params_phys-$(CONFIG_SOC_IMX51) ? ? ?:= 0x90000100 +initrd_phys-$(CONFIG_SOC_IMX51) ? ? ?:= 0x90800000That is one of the places that is not multi-soc capable. ?You can make it 66% less worse by just removing
params_physandinitrd_phys.
Yes. Thanks!
Richard
Quoted 8 lines
Best regards
Uwe--
Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | Uwe Kleine-K?nig ? ? ? ? ? ?| Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
PATCH 1/6 ARM: mx5: use config to define boot related addresses
In reply to Uwe Kleine-KönigQuoted 11 lines · Uwe Kleine-K?nig
Hello,
Quoted 8 lines · Richard Zhao
Signed-off-by Richard Zhao <[email protected]>---
This series of patch support mx50 reference design board. I've tested it using initramfs on the board.arch/arm/mach-mx5/Makefile.boot | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
Quoted 13 lines
arch/arm/mach-mx5/Makefile.boot line 3
Quoted 11 lines
arch/arm/mach-mx5/Makefile.boot +3
-3@@ -1,3 +1,3 @@ - zreladdr-y := 0x90008000 -params_phys-y := 0x90000100 -initrd_phys-y := 0x90800000 + zreladdr-$(CONFIG_SOC_IMX51) := 0x90008000 +params_phys-$(CONFIG_SOC_IMX51) := 0x90000100 +initrd_phys-$(CONFIG_SOC_IMX51) := 0x90800000That is one of the places that is not multi-soc capable. You can make it 66% less worse by just removing
params_physandinitrd_phys.
Which then destroys the ability to use the bootp veneer which combines a kernel and initrd.
PATCH 1/6 ARM: mx5: use config to define boot related addresses
Hell Russell,
Quoted 15 lines · Russell King - ARM Linux
Quoted 5 lines · Uwe Kleine-K?nig
Quoted 5 lines
arch/arm/mach-mx5/Makefile.boot +0
-0@@ -1,3 +1,3 @@Quoted 8 lines
arch/arm/mach-mx5/Makefile.boot line 3
Quoted 6 lines
arch/arm/mach-mx5/Makefile.boot +3
-3- zreladdr-y := 0x90008000 -params_phys-y := 0x90000100 -initrd_phys-y := 0x90800000 + zreladdr-$(CONFIG_SOC_IMX51) := 0x90008000 +params_phys-$(CONFIG_SOC_IMX51) := 0x90000100 +initrd_phys-$(CONFIG_SOC_IMX51) := 0x90800000That is one of the places that is not multi-soc capable. You can make it 66% less worse by just removing
params_physandinitrd_phys.
Quoted 2 lines
Which then destroys the ability to use the bootp veneer which combines a kernel and initrd.
I am aware of that. I think it's OK to add the assignments when they are needed the first time which I don't expect to happen soon if at all.
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/6 ARM: mx5: use config to define boot related addresses
Quoted 18 lines · Uwe Kleine-K?nig
Hell Russell,
Quoted 15 lines · Russell King - ARM Linux
Quoted 13 lines · Uwe Kleine-K?nig
arch/arm/mach-mx5/Makefile.boot line 3
Quoted 11 lines
arch/arm/mach-mx5/Makefile.boot +3
-3@@ -1,3 +1,3 @@ - zreladdr-y := 0x90008000 -params_phys-y := 0x90000100 -initrd_phys-y := 0x90800000 + zreladdr-$(CONFIG_SOC_IMX51) := 0x90008000 +params_phys-$(CONFIG_SOC_IMX51) := 0x90000100 +initrd_phys-$(CONFIG_SOC_IMX51) := 0x90800000That is one of the places that is not multi-soc capable. You can make it 66% less worse by just removing
params_physandinitrd_phys.
Quoted 4 lines
Quoted 2 lines
Which then destroys the ability to use the bootp veneer which combines a kernel and initrd.
I am aware of that. I think it's OK to add the assignments when they are needed the first time which I don't expect to happen soon if at all.
That depends who is trying to use it. If it's someone who isn't the original platform developer, they may give up with it if the definitions aren't provided.
PATCH 1/6 ARM: mx5: use config to define boot related addresses
Quoted 19 lines · Russell King - ARM Linux
Quoted 18 lines · Uwe Kleine-K?nig
Hell Russell,
Quoted 15 lines · Russell King - ARM Linux
Quoted 13 lines · Uwe Kleine-K?nig
arch/arm/mach-mx5/Makefile.boot line 3
Quoted 11 lines
arch/arm/mach-mx5/Makefile.boot +3
-3@@ -1,3 +1,3 @@ - zreladdr-y := 0x90008000 -params_phys-y := 0x90000100 -initrd_phys-y := 0x90800000 + zreladdr-$(CONFIG_SOC_IMX51) := 0x90008000 +params_phys-$(CONFIG_SOC_IMX51) := 0x90000100 +initrd_phys-$(CONFIG_SOC_IMX51) := 0x90800000That is one of the places that is not multi-soc capable. You can make it 66% less worse by just removing
params_physandinitrd_phys.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Which then destroys the ability to use the bootp veneer which combines a kernel and initrd.
I am aware of that. I think it's OK to add the assignments when they are needed the first time which I don't expect to happen soon if at all.
That depends who is trying to use it. If it's someone who isn't the original platform developer, they may give up with it if the definitions aren't provided.
Hi uwe,
IMO, removing params_phys and initrd_phys is just a work around. It's not the final way to fix multi-SoC support. Do you insist on removing it?
Thanks
Richard
PATCH 1/6 ARM: mx5: use config to define boot related addresses
Hello Richard,
Quoted 23 lines · Richard Zhao
Quoted 22 lines · Russell King - ARM Linux
Quoted 20 lines · Uwe Kleine-K?nig
Quoted 15 lines · Russell King - ARM Linux
Quoted 5 lines · Uwe Kleine-K?nig
Quoted 5 lines
arch/arm/mach-mx5/Makefile.boot +0
-0@@ -1,3 +1,3 @@Quoted 8 lines
arch/arm/mach-mx5/Makefile.boot line 3
Quoted 6 lines
arch/arm/mach-mx5/Makefile.boot +3
-3- zreladdr-y := 0x90008000 -params_phys-y := 0x90000100 -initrd_phys-y := 0x90800000 + zreladdr-$(CONFIG_SOC_IMX51) := 0x90008000 +params_phys-$(CONFIG_SOC_IMX51) := 0x90000100 +initrd_phys-$(CONFIG_SOC_IMX51) := 0x90800000That is one of the places that is not multi-soc capable. You can make it 66% less worse by just removing
params_physandinitrd_phys.Quoted 2 lines
Which then destroys the ability to use the bootp veneer which combines a kernel and initrd.
I am aware of that. I think it's OK to add the assignments when they are needed the first time which I don't expect to happen soon if at all.
Quoted 7 lines
Quoted 3 lines
That depends who is trying to use it. If it's someone who isn't the original platform developer, they may give up with it if the definitions aren't provided.
Hi uwe,
IMO, removing
params_physandinitrd_physis just a work around. It's not the final way to fix multi-SoC support. Do you insist on removing it?
no, I don't care much. I think it will never be used, but go ahead, do as you prefer.
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 2/6 arm: plat-mxc: add full parameter macro to define gpio port
In reply to Richard Zhao--- arch/arm/plat-mxc/gpio.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/plat-mxc/gpio.c +4 -1
@@ -350,15 +350,18 @@ int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt)return 0 ; } -#define DEFINE_IMX_GPIO_PORT_IRQ (soc, _id, _hwid, _irq) \ +#define _DEFINE_IMX_GPIO_PORT_IRQ (soc, _id, _hwid, _irq, _irq_high) \ { \ .chip.label = "gpio-" #_id, \ .irq = _irq, \ + .irq_high = _irq_high, \ .base = soc ## _IO_ADDRESS( \ soc ## _GPIO ## _hwid ## _BASE_ADDR), \ .virtual_irq_start = MXC_GPIO_IRQ_START + (_id) * 32, \ } +#define DEFINE_IMX_GPIO_PORT_IRQ (soc, _id, _hwid, _irq) \ + _DEFINE_IMX_GPIO_PORT_IRQ(soc, _id, _hwid, _irq, 0)#define DEFINE_IMX_GPIO_PORT (soc, _id, _hwid) \ DEFINE_IMX_GPIO_PORT_IRQ(soc, _id, _hwid, 0)
Signature · 1 line
1.6.3.3
PATCH 2/6 arm: plat-mxc: add full parameter macro to define gpio port
Quoted 13 lines · Richard Zhao
Signed-off-by Richard Zhao <[email protected]>--- arch/arm/plat-mxc/gpio.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)arch/arm/plat-mxc/gpio.c +0
-0@@ -350,15 +350,18 @@ int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt)return 0 ; }
arch/arm/plat-mxc/gpio.c int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt) · line 361
Quoted 10 lines
arch/arm/plat-mxc/gpio.c +2
-1-#define DEFINE_IMX_GPIO_PORT_IRQ (soc, _id, _hwid, _irq) \ +#define _DEFINE_IMX_GPIO_PORT_IRQ (soc, _id, _hwid, _irq, _irq_high) \ { \ .chip.label = "gpio-" #_id, \ .irq = _irq, \ + .irq_high = _irq_high, \ .base = soc ## _IO_ADDRESS( \ soc ## _GPIO ## _hwid ## _BASE_ADDR), \ .virtual_irq_start = MXC_GPIO_IRQ_START + (_id) * 32, \ }
I don't like the name you chose. IMHO it should contain HIGH.
Uwe
Quoted 11 lines
arch/arm/plat-mxc/gpio.c +2
-0+#define DEFINE_IMX_GPIO_PORT_IRQ (soc, _id, _hwid, _irq) \ + _DEFINE_IMX_GPIO_PORT_IRQ(soc, _id, _hwid, _irq, 0)#define DEFINE_IMX_GPIO_PORT (soc, _id, _hwid) \ DEFINE_IMX_GPIO_PORT_IRQ(soc, _id, _hwid, 0)Signature · 1 line
1.6.3.3
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 3/6 arm: mx51: define mx51's own MXC_GPIO_IRQS
In reply to Richard Zhaomx5 SoCs have different GPIO port count.
--- arch/arm/plat-mxc/include/mach/irqs.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/plat-mxc/include/mach/irqs.h +1 -1
@@ -29,7 +29,7 @@#define MXC_GPIO_IRQS (32 * 4)#elif definedCONFIG_ARCH_MX25 #define MXC_GPIO_IRQS (32 * 4) -#elif definedCONFIG_ARCH_MX5 +#elif definedCONFIG_SOC_IMX51 #define MXC_GPIO_IRQS (32 * 4)#elif definedCONFIG_ARCH_MXC91231 #define MXC_GPIO_IRQS (32 * 4)
Signature · 1 line
1.6.3.3
PATCH 4/6 arm: mx5: always use __mxc_cpu_type to check cpu type
In reply to Richard ZhaoEvery SoC in mach-mx5 calls mxc_set_cpu_type to set cpu type.
--- arch/arm/plat-mxc/include/mach/mxc.h | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
arch/arm/plat-mxc/include/mach/mxc.h +1 -3
@@ -129,10 +129,8 @@ extern unsigned int __mxc_cpu_type;#ifdef CONFIG_ARCH_MX5 # ifdef mxc_cpu_type# undef mxc_cpu_type -# define mxc_cpu_type __mxc_cpu_type -# else -# define mxc_cpu_type MXC_CPU_MX51# endif +# define mxc_cpu_type __mxc_cpu_type# define cpu_is_mx51 () (mxc_cpu_type == MXC_CPU_MX51)# define cpu_is_mx53 () (mxc_cpu_type == MXC_CPU_MX53)#else
Signature · 1 line
1.6.3.3
PATCH 4/6 arm: mx5: always use __mxc_cpu_type to check cpu type
Quoted 1 line · Richard Zhao
Every SoC in mach-mx5 calls
mxc_set_cpu_typeto set cpu type.
I don't like that. Your change makes the usage of cpu_is_mx51() for single-machine builds more expensive.
Quoted 12 lines
Signed-off-by Richard Zhao <[email protected]>--- arch/arm/plat-mxc/include/mach/mxc.h | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)arch/arm/plat-mxc/include/mach/mxc.h +0
-0@@ -129,10 +129,8 @@ extern unsigned int __mxc_cpu_type;#ifdef CONFIG_ARCH_MX5
arch/arm/plat-mxc/include/mach/mxc.h extern unsigned int __mxc_cpu_type; · line 136
Quoted 10 lines
arch/arm/plat-mxc/include/mach/mxc.h +1
-3# ifdef mxc_cpu_type# undef mxc_cpu_type -# define mxc_cpu_type __mxc_cpu_type -# else -# define mxc_cpu_type MXC_CPU_MX51# endif +# define mxc_cpu_type __mxc_cpu_type# define cpu_is_mx51 () (mxc_cpu_type == MXC_CPU_MX51)# define cpu_is_mx53 () (mxc_cpu_type == MXC_CPU_MX53)#else
Here is a bug. cpu_is_mx53 will never be true for a mx5-only build. (That is currently always true for images supporting mx5.)
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 4/6 arm: mx5: always use __mxc_cpu_type to check cpu type
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 4 lines · Richard Zhao
Quoted 1 line
Every SoC in mach-mx5 calls
mxc_set_cpu_typeto set cpu type.I don't like that. ?Your change makes the usage of
cpu_is_mx51()for single-machine builds more expensive.
You're right. I'll add the below like other SoCs:
#ifdef CONFIG_SOC_IMX51
..
#else
# define cpu_is_mx51() (mxc_cpu_type == MXC_CPU_MX51) #endif
can I remove cpu_is_mx53 definition? because CONFIG_SOC_IMX53 is undefined yet. Dinh can add it back when he send out other commits.
Thanks
Richard
Quoted 32 lines
Quoted 18 lines
Signed-off-by Richard Zhao <[email protected]>---
?arch/arm/plat-mxc/include/mach/mxc.h | ? ?4 +---
?1 files changed, 1 insertions(+), 3 deletions(-)arch/arm/plat-mxc/include/mach/mxc.h +0
-0@@ -129,10 +129,8 @@ extern unsigned int __mxc_cpu_type;?#ifdef
CONFIG_ARCH_MX5
?# ifdefmxc_cpu_type
?# ?undefmxc_cpu_typearch/arm/plat-mxc/include/mach/mxc.h +0
-3-# ?define mxc_cpu_type __mxc_cpu_type -# else -# ?define mxc_cpu_type MXC_CPU_MX51Quoted 5 lines
?# endif
+# definemxc_cpu_type__mxc_cpu_type
?# definecpu_is_mx51()? ? ? ? ? ? ? (mxc_cpu_type==MXC_CPU_MX51) ?# definecpu_is_mx53()? ? ? ? ? ? ? (mxc_cpu_type==MXC_CPU_MX53) ?#elseHere is a bug. ?cpu_is_mx53 will never be true for a mx5-only build. (That is currently always true for images supporting mx5.)
Uwe
--
Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | Uwe Kleine-K?nig ? ? ? ? ? ?| Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
PATCH 4/6 arm: mx5: always use __mxc_cpu_type to check cpu type
Hello Richard,
Quoted 9 lines · Richard Zhao
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 4 lines · Richard Zhao
Quoted 1 line
Every SoC in mach-mx5 calls
mxc_set_cpu_typeto set cpu type.I don't like that. ?Your change makes the usage of
cpu_is_mx51()for single-machine builds more expensive.You're right. I'll add the below like other SoCs:
#ifdefCONFIG_SOC_IMX51
..
#else
Quoted 5 lines
# define cpu_is_mx51() (mxc_cpu_type == MXC_CPU_MX51) #endifcan I remove
cpu_is_mx53definition? becauseCONFIG_SOC_IMX53is undefined yet. Dinh can add it back when he send out other commits.
yeap
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 5/6 arm: mx50: add core functions support
In reply to Richard ZhaoAdd core definitions and memory map, clock, gpio, irq, iomux, uart device support.
--- arch/arm/mach-mx5/Kconfig | 8 + arch/arm/mach-mx5/Makefile | 2 + arch/arm/mach-mx5/Makefile.boot | 3 + arch/arm/mach-mx5/clock-mx50.c | 3262 +++++++++++++++++++++++++ arch/arm/mach-mx5/crm_regs-mx50.h | 607 +++++ arch/arm/mach-mx5/devices-mx50.h | 26 + arch/arm/mach-mx5/mm-mx50.c | 60 + arch/arm/plat-mxc/devices/platform-imx-uart.c | 13 + arch/arm/plat-mxc/gpio.c | 14 + arch/arm/plat-mxc/include/mach/common.h | 4 + arch/arm/plat-mxc/include/mach/hardware.h | 1 + arch/arm/plat-mxc/include/mach/iomux-mx50.h | 595 +++++ arch/arm/plat-mxc/include/mach/irqs.h | 2 + arch/arm/plat-mxc/include/mach/memory.h | 3 + arch/arm/plat-mxc/include/mach/mx50.h | 306 +++ arch/arm/plat-mxc/include/mach/mxc.h | 2 + 16 files changed, 4908 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mx5/clock-mx50.c create mode 100644 arch/arm/mach-mx5/crm_regs-mx50.h create mode 100644 arch/arm/mach-mx5/devices-mx50.h create mode 100644 arch/arm/mach-mx5/mm-mx50.c create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx50.h create mode 100644 arch/arm/plat-mxc/include/mach/mx50.h
arch/arm/mach-mx5/Kconfig +8 -0
@@ -12,6 +12,14 @@ config SOC_IMX51 select ARCH_HAS_CPUFREQ select ARCH_MX51 +config SOC_IMX50 + bool + select MXC_TZIC + select ARCH_MXC_IOMUX_V3 + select ARCH_MXC_AUDMUX_V2 + select ARCH_HAS_CPUFREQ + + comment "MX5 platforms:" config MACH_MX51_BABBAGE
arch/arm/mach-mx5/Makefile +2 -0
@@ -13,3 +13,5 @@ obj-$(CONFIG_MACH_EUKREA_MBIMX51_BASEBOARD) += eukrea_mbimx51-baseboard.o obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += board-cpuimx51sd.o obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o + +obj-$(CONFIG_SOC_IMX50) += mm-mx50.o clock-mx50.o
arch/arm/mach-mx5/Makefile.boot +3 -0
@@ -1,3 +1,6 @@ zreladdr-$(CONFIG_SOC_IMX51) := 0x90008000 params_phys-$(CONFIG_SOC_IMX51) := 0x90000100 initrd_phys-$(CONFIG_SOC_IMX51) := 0x90800000 + zreladdr-$(CONFIG_SOC_IMX50) := 0x70008000 +params_phys-$(CONFIG_SOC_IMX50) := 0x70000100 +initrd_phys-$(CONFIG_SOC_IMX50) := 0x70800000
arch/arm/mach-mx5/clock-mx50.c new file +3262 -0
2,975 lines not on this page · raw message
arch/arm/mach-mx5/crm_regs-mx50.h new file +607 -0
607 lines not on this page · raw message
arch/arm/mach-mx5/devices-mx50.h new file +26 -0
Lines of this file are not shown. View the raw message.
arch/arm/mach-mx5/mm-mx50.c new file +60 -0
60 lines not on this page · raw message
arch/arm/plat-mxc/devices/platform-imx-uart.c +13 -0
Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/include/mach/common.h +4 -0
Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/include/mach/hardware.h +1 -0
Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/include/mach/iomux-mx50.h new file +595 -0
595 lines not on this page · raw message
arch/arm/plat-mxc/include/mach/memory.h +3 -0
Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/include/mach/mx50.h new file +306 -0
306 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.3.3
Part of the diff is not shown here. View the raw message.
PATCH 5/6 arm: mx50: add core functions support
Hello Richard,
Quoted 35 lines · Richard Zhao
Add core definitions and memory map, clock, gpio, irq, iomux, uart device support.
Signed-off-by Richard Zhao <[email protected]>--- arch/arm/mach-mx5/Kconfig | 8 + arch/arm/mach-mx5/Makefile | 2 + arch/arm/mach-mx5/Makefile.boot | 3 + arch/arm/mach-mx5/clock-mx50.c | 3262 +++++++++++++++++++++++++ arch/arm/mach-mx5/crm_regs-mx50.h | 607 +++++ arch/arm/mach-mx5/devices-mx50.h | 26 + arch/arm/mach-mx5/mm-mx50.c | 60 + arch/arm/plat-mxc/devices/platform-imx-uart.c | 13 + arch/arm/plat-mxc/gpio.c | 14 + arch/arm/plat-mxc/include/mach/common.h | 4 + arch/arm/plat-mxc/include/mach/hardware.h | 1 + arch/arm/plat-mxc/include/mach/iomux-mx50.h | 595 +++++ arch/arm/plat-mxc/include/mach/irqs.h | 2 + arch/arm/plat-mxc/include/mach/memory.h | 3 + arch/arm/plat-mxc/include/mach/mx50.h | 306 +++ arch/arm/plat-mxc/include/mach/mxc.h | 2 + 16 files changed, 4908 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mx5/clock-mx50.c create mode 100644 arch/arm/mach-mx5/crm_regs-mx50.h create mode 100644 arch/arm/mach-mx5/devices-mx50.h create mode 100644 arch/arm/mach-mx5/mm-mx50.c create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx50.h create mode 100644 arch/arm/plat-mxc/include/mach/mx50.harch/arm/mach-mx5/Kconfig +0
-0@@ -12,6 +12,14 @@ config SOC_IMX51 select ARCH_HAS_CPUFREQ
arch/arm/mach-mx5/Kconfig config SOC_IMX51 · line 22
Quoted 10 lines
arch/arm/mach-mx5/Kconfig +8
-0select ARCH_MX51 +config SOC_IMX50 + bool + select MXC_TZIC + select ARCH_MXC_IOMUX_V3 + select ARCH_MXC_AUDMUX_V2 + select ARCH_HAS_CPUFREQ + +
only a single empty line please
arch/arm/mach-mx5/Makefile obj-$(CONFIG_MACH_EUKREA_MBIMX51_BASEBOARD) += eukrea_mbimx51-baseboard.o · line 17
Quoted 13 lines
arch/arm/mach-mx5/Kconfig +0
-0comment "MX5 platforms:" config MACH_MX51_BABBAGEarch/arm/mach-mx5/Makefile +2
-0@@ -13,3 +13,5 @@ obj-$(CONFIG_MACH_EUKREA_MBIMX51_BASEBOARD) += eukrea_mbimx51-baseboard.o obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += board-cpuimx51sd.o obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o + +obj-$(CONFIG_SOC_IMX50) += mm-mx50.o clock-mx50.o
Please put that over the machine lines
arch/arm/mach-mx5/Makefile.boot line 6
Quoted 11 lines
arch/arm/mach-mx5/Makefile.boot +3
-0@@ -1,3 +1,6 @@ zreladdr-$(CONFIG_SOC_IMX51) := 0x90008000 params_phys-$(CONFIG_SOC_IMX51) := 0x90000100 initrd_phys-$(CONFIG_SOC_IMX51) := 0x90800000 + zreladdr-$(CONFIG_SOC_IMX50) := 0x70008000 +params_phys-$(CONFIG_SOC_IMX50) := 0x70000100 +initrd_phys-$(CONFIG_SOC_IMX50) := 0x70800000
Do you need params_phys and initrd_phys?
Quoted 80 lines
arch/arm/mach-mx5/clock-mx50.c new file +74
-0@@ -0,0 +1,3262 @@ +/* +* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/time.h> +#include <linux/hrtimer.h> +#include <linux/mm.h> +#include <linux/errno.h> +#include <linux/delay.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <asm/clkdev.h> +#include <asm/div64.h> +#include <mach/hardware.h> +#include <mach/common.h> +#include <mach/clock.h> + +#include "crm_regs-mx50.h" + +/* External clock values passed-in by the board code */ +static unsigned long external_high_reference, external_low_reference; +static unsigned long oscillator_reference, ckih2_reference; + +static struct clk pll1_main_clk; +static struct clk pll1_sw_clk; +static struct clk pll2_sw_clk; +static struct clk pll3_sw_clk; +static struct clk apbh_dma_clk; +static struct clk apll_clk; +static struct clk pfd0_clk; +static struct clk pfd1_clk; +static struct clk pfd2_clk; +static struct clk pfd3_clk; +static struct clk pfd4_clk; +static struct clk pfd5_clk; +static struct clk pfd6_clk; +static struct clk pfd7_clk; +static struct clk lp_apm_clk; +static struct clk weim_clk[]; +static struct clk ddr_clk; +static struct clk axi_a_clk; +static struct clk axi_b_clk; +static struct clk gpu2d_clk; + +static void __iomem *pll1_base; +static void __iomem *pll2_base; +static void __iomem *pll3_base; +void __iomem *apll_base; + +void __iomem *databahn; + +#define DDR_SYNC_MODE 0x30000 +#define SPIN_DELAY 1000000/* in nanoseconds */ +#define WAIT (exp, timeout) \ +({ \ + struct timespec nstimeofday; \ + struct timespec curtime; \
arch/arm/mach-mx5/clock-mx50.c line 84
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+int result =1 ; \ +getnstimeofday (&nstimeofday); \ +while (!(exp)) { \ +getnstimeofday (&curtime); \ +if ((curtime.tv_nsec - nstimeofday.tv_nsec) > (timeout)) { \ + result =0 ; \ +break ; \ + } \ + } \ + result; \
this is broken. Consider getnstimeofday(&nstimeofday) returns with nstimeofday = { .ts_sec = 42, .ts_nsec = 999999999, }. If timeout is >0 the break is never taken. And furthermore I'm sure that getnstimeofday isn't the right function for that job.
Quoted 23 lines
arch/arm/mach-mx5/clock-mx50.c new file +23
-0+}) + +#define MAX_AHB_CLK 133000000 + +static struct clk esdhc3_clk[]; + +static void __calc_pre_post_dividers (u32 div,u32 *pre,u32 *post) +{ +u32 min_pre, temp_pre, old_err, err; + +if (div >=512 ) { + *pre =8 ; + *post =64 ; + }else if (div >=8 ) { + min_pre = (div -1 ) /64 +1 ; + old_err =8 ; +for (temp_pre =8 ; temp_pre >= min_pre; temp_pre--) { + err = div % temp_pre; +if (err ==0 ) { + *pre = temp_pre; +break ; + } + err = temp_pre - err;
arch/arm/mach-mx5/clock-mx50.c line 117
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+if (err < old_err) { + old_err = err; + *pre = temp_pre; + } + } + *post = (div + *pre -1 ) / *pre; + }else if (div <8 ) { + *pre = div; + *post =1 ; + }
You seem to have copied an old version of this function. The similarity to arch/arm/mach-mx5/clock-mx51.c makes me wonder if you shouldn't copy the Copyright lines from there, too.
arch/arm/mach-mx5/clock-mx50.c line 128
Quoted 11 lines
arch/arm/mach-mx5/clock-mx50.c new file +11
-0+} + +static int _clk_enable (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg); + reg |= MXC_CCM_CCGRx_CG_MASK << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); + +return 0 ; +}
These functions are refactored in arch/arm/mach-mx5/clock-mx51.c in the meantime, too.
Quoted 59 lines
arch/arm/mach-mx5/clock-mx50.c new file +59
-0+ +static int _clk_enable_inrun (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (clk->enable_reg); + reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); + reg |=1 << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); +return 0 ; +} + +static void _clk_disable (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg); + reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); +__raw_writel (reg, clk->enable_reg); +} + +static void _clk_disable_inwait (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg); + reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); + reg |=1 << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); +} + +static unsigned long _clk_round_rate_div (struct clk *clk, +unsigned long rate, +u32 max_div, +u32 *new_div) +{ +u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div =DIV_ROUND_UP (parent_rate, rate); +if (div > max_div) + div = max_div; +else if (div ==0 ) + div++; +if (new_div !=NULL ) + *new_div = div; + +return parent_rate / div; +} +/* +* For the 4-to-1 muxed input clock +*/ +static inline u32 _get_mux (struct clk *parent,struct clk *m0, +struct clk *m1,struct clk *m2,struct clk *m3) +{ +if (parent == m0) +return 0 ; +else if (parent == m1) +return 1 ; +else if (parent == m2) +return 2 ;
arch/arm/mach-mx5/clock-mx50.c line 197
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+else if (parent == m3) +return 3 ; +else +BUG (); + +return 0 ; +} + +/* +* For the 4-to-1 muxed input clock
8-to-1 ?
Quoted 96 lines
arch/arm/mach-mx5/clock-mx50.c new file +96
-0+*/ +static inline u32 _get_mux8 (struct clk *parent,struct clk *m0,struct clk *m1, +struct clk *m2,struct clk *m3,struct clk *m4, +struct clk *m5,struct clk *m6,struct clk *m7) +{ +if (parent == m0) +return 0 ; +else if (parent == m1) +return 1 ; +else if (parent == m2) +return 2 ; +else if (parent == m3) +return 3 ; +else if (parent == m4) +return 4 ; +else if (parent == m5) +return 5 ; +else if (parent == m6) +return 6 ; +else if (parent == m7) +return 7 ; +else +BUG (); + +return 0 ; +} + +static inline void __iomem *_get_pll_base (struct clk *pll) +{ +if (pll == &pll1_main_clk) +return pll1_base; +else if (pll == &pll2_sw_clk) +return pll2_base; +else if (pll == &pll3_sw_clk) +return pll3_base; +else +BUG (); + +return NULL ; +} + +static unsigned long get_high_reference_clock_rate (struct clk *clk) +{ +return external_high_reference; +} + +static unsigned long get_low_reference_clock_rate (struct clk *clk) +{ +return external_low_reference; +} + +static unsigned long get_oscillator_reference_clock_rate (struct clk *clk) +{ +return oscillator_reference; +} + +static unsigned long get_ckih2_reference_clock_rate (struct clk *clk) +{ +return ckih2_reference; +} + +/* External high frequency clock */ +static struct clk ckih_clk = { + .get_rate = get_high_reference_clock_rate, +}; + +static struct clk ckih2_clk = { + .get_rate = get_ckih2_reference_clock_rate, +}; + +static struct clk osc_clk = { + .get_rate = get_oscillator_reference_clock_rate, +}; + +/* External low frequency (32kHz) clock */ +static struct clk ckil_clk = { + .get_rate = get_low_reference_clock_rate, +}; + +static int apll_enable (struct clk *clk) +{ +__raw_writel (1 , apll_base +MXC_ANADIG_MISC_SET ); +return 0 ; +} + +static void apll_disable (struct clk *clk) +{ +__raw_writel (1 , apll_base +MXC_ANADIG_MISC_CLR ); +} + +static unsigned long apll_get_rate (struct clk *clk) +{ +return 480000000 ; +} + +static struct clk apll_clk = {
arch/arm/mach-mx5/clock-mx50.c line 303
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+ .get_rate = apll_get_rate, + .enable = apll_enable, + .disable = apll_disable, +}; + +static unsigned long pfd_round_rate (struct clk *clk,unsigned long rate) +{ +u32 frac; +u64 tmp; + tmp = (u64 )clk_get_rate (clk->parent) *18 ;
This can overflow e.g. when parent = apll
arch/arm/mach-mx5/clock-mx50.c line 307
Quoted 4 lines
arch/arm/mach-mx5/clock-mx50.c new file +4
-0+do_div (tmp, rate); + frac = tmp; + frac = frac <18 ?18 : frac; + frac = frac >35 ?35 : frac;
I remember having seen something like:
#define CLAMP(x, low, high) ((x) < (low) ? (low) : ((x) > (high) ? (high) : (x)))
Maybe this is something for <linux/kernel.h>, probably with better typing.
arch/arm/mach-mx5/clock-mx50.c line 319
Quoted 12 lines
arch/arm/mach-mx5/clock-mx50.c new file +12
-0+do_div (tmp, frac); +return tmp; +} + +static int pfd_set_rate (struct clk *clk,unsigned long rate) +{ +u32 frac; +u64 tmp; + tmp = (u64 )clk_get_rate (clk->parent) *18 ; + +if (apbh_dma_clk.usecount ==0 ) + apbh_dma_clk.enable (&apbh_dma_clk);
Why not just use clk_enable(apbh_dma)?
arch/arm/mach-mx5/clock-mx50.c line 327
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c new file +7
-0+do_div (tmp, rate); + frac = tmp; + frac = frac <18 ?18 : frac; + frac = frac >35 ?35 : frac; +/* clear clk frac bits */ +__raw_writel (MXC_ANADIG_PFD_FRAC_MASK << clk->enable_shift, + apll_base + (int )clk->enable_reg +8 );
What is 8?
arch/arm/mach-mx5/clock-mx50.c line 330
Quoted 3 lines
arch/arm/mach-mx5/clock-mx50.c new file +3
-0+/* set clk frac bits */ +__raw_writel (frac << clk->enable_shift, + apll_base + (int )clk->enable_reg +4 );
What is 4?
arch/arm/mach-mx5/clock-mx50.c line 331
Quoted 2 lines
arch/arm/mach-mx5/clock-mx50.c new file +2
-0+ + tmp = (u64 )clk_get_rate (clk->parent) *18 ;
overflow?
arch/arm/mach-mx5/clock-mx50.c line 336
Quoted 4 lines
arch/arm/mach-mx5/clock-mx50.c new file +4
-0+do_div (tmp, frac); + +if (apbh_dma_clk.usecount ==0 ) + apbh_dma_clk.disable (&apbh_dma_clk);
... then you can balance here with an clk_disable that just does the right thing.
arch/arm/mach-mx5/clock-mx50.c line 345
Quoted 9 lines
arch/arm/mach-mx5/clock-mx50.c new file +9
-0+return 0 ; +} + +static int pfd_enable (struct clk *clk) +{ +int index; + +if (apbh_dma_clk.usecount ==0 ) + apbh_dma_clk.enable (&apbh_dma_clk);
ditto
arch/arm/mach-mx5/clock-mx50.c line 350
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +5
-0+ index =_get_mux8 (clk, &pfd0_clk, &pfd1_clk, &pfd2_clk, &pfd3_clk, + &pfd4_clk, &pfd5_clk, &pfd6_clk, &pfd7_clk); +__raw_writel (1 << (index +MXC_ANADIG_PFD_DIS_OFFSET ), + apll_base +MXC_ANADIG_PLLCTRL_CLR ); +/* clear clk gate bit */
Having an empty line before comments improves readability.
Quoted 105 lines
arch/arm/mach-mx5/clock-mx50.c new file +105
-0+__raw_writel ((1 << (clk->enable_shift +7 )), + apll_base + (int )clk->enable_reg +8 ); + +/* check lock bit */ +if (!WAIT (__raw_readl (apll_base +MXC_ANADIG_PLLCTRL ) + &MXC_ANADIG_APLL_LOCK ,50000 )) { +__raw_writel (MXC_ANADIG_APLL_FORCE_LOCK , + apll_base +MXC_ANADIG_PLLCTRL_CLR ); +__raw_writel (MXC_ANADIG_APLL_FORCE_LOCK , + apll_base +MXC_ANADIG_PLLCTRL_SET ); +if (!WAIT (__raw_readl (apll_base +MXC_ANADIG_PLLCTRL ) + &MXC_ANADIG_APLL_LOCK ,SPIN_DELAY )) +panic ("pfd_enable failed!\n" ); + } +if (apbh_dma_clk.usecount ==0 ) + apbh_dma_clk.disable (&apbh_dma_clk); +return 0 ; +} + +static void pfd_disable (struct clk *clk) +{ +int index; + +if (apbh_dma_clk.usecount ==0 ) + apbh_dma_clk.enable (&apbh_dma_clk); + index =_get_mux8 (clk, &pfd0_clk, &pfd1_clk, &pfd2_clk, &pfd3_clk, + &pfd4_clk, &pfd5_clk, &pfd6_clk, &pfd7_clk); +/* set clk gate bit */ +__raw_writel ((1 << (clk->enable_shift +7 )), + apll_base + (int )clk->enable_reg +4 ); +__raw_writel (1 << (index +MXC_ANADIG_PFD_DIS_OFFSET ), + apll_base +MXC_ANADIG_PLLCTRL_SET ); +if (apbh_dma_clk.usecount ==0 ) + apbh_dma_clk.disable (&apbh_dma_clk); +} + +static struct clk pfd0_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC0 , + .enable_shift =MXC_ANADIG_PFD0_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd1_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC0 , + .enable_shift =MXC_ANADIG_PFD1_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd2_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC0 , + .enable_shift =MXC_ANADIG_PFD2_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd3_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC0 , + .enable_shift =MXC_ANADIG_PFD3_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd4_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC1 , + .enable_shift =MXC_ANADIG_PFD4_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd5_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC1 , + .enable_shift =MXC_ANADIG_PFD5_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd6_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC1 , + .enable_shift =MXC_ANADIG_PFD6_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +};
arch/arm/mach-mx5/clock-mx50.c line 465
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+ +static struct clk pfd7_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC1 , + .enable_shift =MXC_ANADIG_PFD7_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +};
Maybe define a macro to simplify these 8 definitions?
Quoted 494 lines
arch/arm/mach-mx5/clock-mx50.c new file +494
-0+ +static unsigned long _clk_pll_get_rate (struct clk *clk) +{ +long mfi, mfn, mfd, pdf, ref_clk, mfn_abs; +unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl; +void __iomem *pllbase; +s64 temp; + + pllbase =_get_pll_base (clk); + + dp_ctl =__raw_readl (pllbase +MXC_PLL_DP_CTL ); + pll_hfsm = dp_ctl &MXC_PLL_DP_CTL_HFSM ; + dbl = dp_ctl &MXC_PLL_DP_CTL_DPDCK0_2_EN ; + +if (pll_hfsm ==0 ) { + dp_op =__raw_readl (pllbase +MXC_PLL_DP_OP ); + dp_mfd =__raw_readl (pllbase +MXC_PLL_DP_MFD ); + dp_mfn =__raw_readl (pllbase +MXC_PLL_DP_MFN ); + }else { + dp_op =__raw_readl (pllbase +MXC_PLL_DP_HFS_OP ); + dp_mfd =__raw_readl (pllbase +MXC_PLL_DP_HFS_MFD ); + dp_mfn =__raw_readl (pllbase +MXC_PLL_DP_HFS_MFN ); + } + pdf = dp_op &MXC_PLL_DP_OP_PDF_MASK ; + mfi = (dp_op &MXC_PLL_DP_OP_MFI_MASK ) >>MXC_PLL_DP_OP_MFI_OFFSET ; + mfi = (mfi <=5 ) ?5 : mfi; + mfd = dp_mfd &MXC_PLL_DP_MFD_MASK ; + mfn = mfn_abs = dp_mfn &MXC_PLL_DP_MFN_MASK ; +/* Sign extend to 32-bits */ +if (mfn >=0x04000000 ) { + mfn |=0xFC000000 ; + mfn_abs = -mfn; + } + + ref_clk =2 *clk_get_rate (clk->parent); +if (dbl !=0 ) + ref_clk *=2 ; + + ref_clk /= (pdf +1 ); + temp = (u64 ) ref_clk * mfn_abs; +do_div (temp, mfd +1 ); +if (mfn <0 ) + temp = -temp; + temp = (ref_clk * mfi) + temp; + +return temp; +} + +static int _clk_pll_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, reg1; +void __iomem *pllbase; + +long mfi, pdf, mfn, mfd =999999 ; +s64 temp64; +unsigned long quad_parent_rate; +unsigned long pll_hfsm, dp_ctl; + + pllbase =_get_pll_base (clk); + + quad_parent_rate =4 *clk_get_rate (clk->parent); + pdf = mfi =-1 ; +while (++pdf <16 && mfi <5 ) + mfi = rate * (pdf+1 ) / quad_parent_rate; +if (mfi >15 ) +return -1 ; + pdf--; + + temp64 = rate*(pdf+1 ) - quad_parent_rate*mfi; +do_div (temp64, quad_parent_rate/1000000 ); + mfn = (long )temp64; + + dp_ctl =__raw_readl (pllbase +MXC_PLL_DP_CTL ); +/* use dpdck0_2 */ +__raw_writel (dp_ctl |0x1000L , pllbase +MXC_PLL_DP_CTL ); + pll_hfsm = dp_ctl &MXC_PLL_DP_CTL_HFSM ; +if (pll_hfsm ==0 ) { + reg = mfi<<4 | pdf; +__raw_writel (reg, pllbase +MXC_PLL_DP_OP ); +__raw_writel (mfd, pllbase +MXC_PLL_DP_MFD ); +__raw_writel (mfn, pllbase +MXC_PLL_DP_MFN ); + }else { + reg = mfi<<4 | pdf; +__raw_writel (reg, pllbase +MXC_PLL_DP_HFS_OP ); +__raw_writel (mfd, pllbase +MXC_PLL_DP_HFS_MFD ); +__raw_writel (mfn, pllbase +MXC_PLL_DP_HFS_MFN ); + } +/* If auto restart is disabled, restart the PLL and +* wait for it to lock. +*/ + reg =__raw_readl (pllbase +MXC_PLL_DP_CTL ); +if (reg &MXC_PLL_DP_CTL_UPEN ) { + reg =__raw_readl (pllbase +MXC_PLL_DP_CONFIG ); +if (!(reg &MXC_PLL_DP_CONFIG_AREN )) { + reg1 =__raw_readl (pllbase +MXC_PLL_DP_CTL ); + reg1 |=MXC_PLL_DP_CTL_RST ; +__raw_writel (reg1, pllbase +MXC_PLL_DP_CTL ); + } +/* Wait for lock */ +if (!WAIT (__raw_readl (pllbase +MXC_PLL_DP_CTL ) + &MXC_PLL_DP_CTL_LRF ,SPIN_DELAY )) +panic ("pll_set_rate: pll relock failed\n" ); + } +return 0 ; +} + +static int _clk_pll_enable (struct clk *clk) +{ +u32 reg; +void __iomem *pllbase; + + pllbase =_get_pll_base (clk); + reg =__raw_readl (pllbase +MXC_PLL_DP_CTL ); + +if (reg &MXC_PLL_DP_CTL_UPEN ) +return 0 ; + + reg |=MXC_PLL_DP_CTL_UPEN ; +__raw_writel (reg, pllbase +MXC_PLL_DP_CTL ); + +/* Wait for lock */ +if (!WAIT (__raw_readl (pllbase +MXC_PLL_DP_CTL ) &MXC_PLL_DP_CTL_LRF , +SPIN_DELAY )) +panic ("pll relock failed\n" ); +return 0 ; +} + +static void _clk_pll_disable (struct clk *clk) +{ +u32 reg; +void __iomem *pllbase; + + pllbase =_get_pll_base (clk); + reg =__raw_readl (pllbase +MXC_PLL_DP_CTL ) & ~MXC_PLL_DP_CTL_UPEN ; +__raw_writel (reg, pllbase +MXC_PLL_DP_CTL ); +} + +static struct clk pll1_main_clk = { + .parent = &osc_clk, + .get_rate = _clk_pll_get_rate, + .enable = _clk_pll_enable, + .disable = _clk_pll_disable, +}; + +static int _clk_pll1_sw_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CCSR ); + +if (parent == &pll1_main_clk) { + reg &= ~MXC_CCM_CCSR_PLL1_SW_CLK_SEL ; +__raw_writel (reg,MXC_CCM_CCSR ); +/* Set the step_clk parent to be lp_apm, to save power. */ + mux =_get_mux (&lp_apm_clk, &lp_apm_clk,NULL , &pll2_sw_clk, + &pll3_sw_clk); + reg =__raw_readl (MXC_CCM_CCSR ); + reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK ) | + (mux <<MXC_CCM_CCSR_STEP_SEL_OFFSET ); + }else { +if (parent == &lp_apm_clk) { + mux =_get_mux (parent, &lp_apm_clk,NULL , &pll2_sw_clk, + &pll3_sw_clk); + reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK ) | + (mux <<MXC_CCM_CCSR_STEP_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CCSR ); + reg =__raw_readl (MXC_CCM_CCSR ); + reg |=MXC_CCM_CCSR_PLL1_SW_CLK_SEL ; + }else { + mux =_get_mux (parent, &lp_apm_clk,NULL , &pll2_sw_clk, + &pll3_sw_clk); + reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK ) | + (mux <<MXC_CCM_CCSR_STEP_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CCSR ); + reg =__raw_readl (MXC_CCM_CCSR ); + reg |=MXC_CCM_CCSR_PLL1_SW_CLK_SEL ; + + } + } +__raw_writel (reg,MXC_CCM_CCSR ); + +return 0 ; +} + +static unsigned long _clk_pll1_sw_get_rate (struct clk *clk) +{ +u32 reg, div; + div =1 ; + reg =__raw_readl (MXC_CCM_CCSR ); + +if (clk->parent == &pll2_sw_clk) { + div = ((reg &MXC_CCM_CCSR_PLL2_PODF_MASK ) >> +MXC_CCM_CCSR_PLL2_PODF_OFFSET ) +1 ; + }else if (clk->parent == &pll3_sw_clk) { + div = ((reg &MXC_CCM_CCSR_PLL3_PODF_MASK ) >> +MXC_CCM_CCSR_PLL3_PODF_OFFSET ) +1 ; + } +return clk_get_rate (clk->parent) / div; +} + +/* pll1 switch clock */ +static struct clk pll1_sw_clk = { + .parent = &pll1_main_clk, + .set_parent = _clk_pll1_sw_set_parent, + .get_rate = _clk_pll1_sw_get_rate, +}; + +static int _clk_pll2_sw_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CCSR ); + +if (parent == &pll2_sw_clk) { + reg &= ~MXC_CCM_CCSR_PLL2_SW_CLK_SEL ; + }else { + reg = (reg & ~MXC_CCM_CCSR_PLL2_SW_CLK_SEL ); + reg |=MXC_CCM_CCSR_PLL2_SW_CLK_SEL ; + } +__raw_writel (reg,MXC_CCM_CCSR ); +return 0 ; +} + +/* same as pll2_main_clk. These two clocks should always be the same */ +static struct clk pll2_sw_clk = { + .parent = &osc_clk, + .get_rate = _clk_pll_get_rate, + .enable = _clk_pll_enable, + .disable = _clk_pll_disable, + .set_rate = _clk_pll_set_rate, + .set_parent = _clk_pll2_sw_set_parent, +}; + +/* same as pll3_main_clk. These two clocks should always be the same */ +static struct clk pll3_sw_clk = { + .parent = &osc_clk, + .set_rate = _clk_pll_set_rate, + .get_rate = _clk_pll_get_rate, + .enable = _clk_pll_enable, + .disable = _clk_pll_disable, +}; + +static int _clk_lp_apm_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + +if (parent == &osc_clk) + reg =__raw_readl (MXC_CCM_CCSR ) & ~MXC_CCM_CCSR_LP_APM_SEL ; +else if (parent == &apll_clk) + reg =__raw_readl (MXC_CCM_CCSR ) |MXC_CCM_CCSR_LP_APM_SEL ; +else +return -EINVAL ; + +__raw_writel (reg,MXC_CCM_CCSR ); + +return 0 ; +} + +static struct clk lp_apm_clk = { + .parent = &osc_clk, + .set_parent = _clk_lp_apm_set_parent, +}; + +static unsigned long _clk_arm_get_rate (struct clk *clk) +{ +u32 cacrr, div; + + cacrr =__raw_readl (MXC_CCM_CACRR ); + div = (cacrr &MXC_CCM_CACRR_ARM_PODF_MASK ) +1 ; +return clk_get_rate (clk->parent) / div; +} + +static unsigned long _clk_cpu_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 cpu_podf; +unsigned long parent_rate; + + parent_rate =clk_get_rate (clk->parent); + cpu_podf = parent_rate / rate; + cpu_podf = cpu_podf >8 ?8 : cpu_podf; + cpu_podf = cpu_podf <1 ?1 : cpu_podf; + +return parent_rate / cpu_podf; +} + +static int _clk_cpu_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, cpu_podf; +unsigned long parent_rate; + + rate =_clk_cpu_round_rate (clk, rate); + parent_rate =clk_get_rate (clk->parent); + cpu_podf = parent_rate / rate -1 ; + + reg =__raw_readl (MXC_CCM_CACRR ); + reg &= ~MXC_CCM_CACRR_ARM_PODF_MASK ; + reg |= cpu_podf <<MXC_CCM_CACRR_ARM_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_CACRR ); + +return 0 ; +} + +static struct clk cpu_clk = { + .parent = &pll1_sw_clk, + .get_rate = _clk_arm_get_rate, + .set_rate = _clk_cpu_set_rate, + .round_rate = _clk_cpu_round_rate, +}; + +static int _clk_main_bus_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, + &lp_apm_clk); + reg =__raw_readl (MXC_CCM_CBCDR ) & ~MXC_CCM_CBCDR_PERIPH_CLK_SEL_MASK ; + reg |= (mux <<MXC_CCM_CBCDR_PERIPH_CLK_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CBCDR ); + +return 0 ; +} + +static struct clk main_bus_clk = { + .parent = &pll2_sw_clk, + .set_parent = _clk_main_bus_set_parent, +}; + +static unsigned long _clk_axi_a_get_rate (struct clk *clk) +{ +u32 reg, div; + + reg =__raw_readl (MXC_CCM_CBCDR ); + div = ((reg &MXC_CCM_CBCDR_AXI_A_PODF_MASK ) >> +MXC_CCM_CBCDR_AXI_A_PODF_OFFSET ) +1 ; +return clk_get_rate (clk->parent) / div; +} + +static int _clk_axi_a_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; +if (div ==0 ) + div++; +if (((parent_rate / div) != rate) || (div >8 )) +return -EINVAL ; + + reg =__raw_readl (MXC_CCM_CBCDR ); + reg &= ~MXC_CCM_CBCDR_AXI_A_PODF_MASK ; + reg |= (div -1 ) <<MXC_CCM_CBCDR_AXI_A_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_CBCDR ); + +if (!WAIT (!(__raw_readl (MXC_CCM_CDHIPR ) + &MXC_CCM_CDHIPR_AXI_A_PODF_BUSY ),SPIN_DELAY )) +panic ("pll _clk_axi_a_set_rate failed\n" ); + +return 0 ; +} + +static unsigned long _clk_axi_a_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; + +/* Make sure rate is not greater than the maximum value for the clock. +* Also prevent a div of 0. +*/ + +if (div >8 ) + div =8 ; +else if (div ==0 ) + div++; + +return parent_rate / div; +} + + +static struct clk axi_a_clk = { + .parent = &main_bus_clk, + .get_rate = _clk_axi_a_get_rate, + .set_rate = _clk_axi_a_set_rate, + .round_rate = _clk_axi_a_round_rate, +}; + +static unsigned long _clk_axi_b_get_rate (struct clk *clk) +{ +u32 reg, div; + + reg =__raw_readl (MXC_CCM_CBCDR ); + div = ((reg &MXC_CCM_CBCDR_AXI_B_PODF_MASK ) >> +MXC_CCM_CBCDR_AXI_B_PODF_OFFSET ) +1 ; +return clk_get_rate (clk->parent) / div; +} + +static int _clk_axi_b_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; +if (div ==0 ) + div++; +if (((parent_rate / div) != rate) || (div >8 )) +return -EINVAL ; + + reg =__raw_readl (MXC_CCM_CBCDR ); + reg &= ~MXC_CCM_CBCDR_AXI_B_PODF_MASK ; + reg |= (div -1 ) <<MXC_CCM_CBCDR_AXI_B_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_CBCDR ); + +if (!WAIT (!(__raw_readl (MXC_CCM_CDHIPR ) + &MXC_CCM_CDHIPR_AXI_B_PODF_BUSY ),SPIN_DELAY )) +panic ("_clk_axi_b_set_rate failed\n" ); + +return 0 ; +} + +static unsigned long _clk_axi_b_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; + +/* Make sure rate is not greater than the maximum value for the clock. +* Also prevent a div of 0. +*/ + +if (div >8 ) + div =8 ; +else if (div ==0 ) + div++; + +return parent_rate / div; +} + + +static struct clk axi_b_clk = { + .parent = &main_bus_clk, + .get_rate = _clk_axi_b_get_rate, + .set_rate = _clk_axi_b_set_rate, + .round_rate = _clk_axi_b_round_rate, +}; + +static unsigned long _clk_ahb_get_rate (struct clk *clk) +{ +u32 reg, div; + + reg =__raw_readl (MXC_CCM_CBCDR ); + div = ((reg &MXC_CCM_CBCDR_AHB_PODF_MASK ) >> +MXC_CCM_CBCDR_AHB_PODF_OFFSET ) +1 ; +return clk_get_rate (clk->parent) / div; +} + + +static int _clk_ahb_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; +if (div ==0 ) + div++; +if (((parent_rate / div) != rate) || (div >8 )) +return -EINVAL ; + + reg =__raw_readl (MXC_CCM_CBCDR ); + reg &= ~MXC_CCM_CBCDR_AHB_PODF_MASK ; + reg |= (div -1 ) <<MXC_CCM_CBCDR_AHB_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_CBCDR ); + +if (!WAIT (!(__raw_readl (MXC_CCM_CDHIPR ) &MXC_CCM_CDHIPR_AHB_PODF_BUSY ), +SPIN_DELAY )) +panic ("_clk_ahb_set_rate failed\n" ); + +return 0 ; +} + +static unsigned long _clk_ahb_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; + +/* Make sure rate is not greater than the maximum value for the clock. +* Also prevent a div of 0.
arch/arm/mach-mx5/clock-mx50.c line 969
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+*/ +if (div ==0 ) + div++; +if (parent_rate / div >MAX_AHB_CLK ) + div++; + +if (div >8 ) + div =8 ; + +return parent_rate / div;
This can return something > MAX_AHB_CLK, is this intended?
Quoted 22 lines
arch/arm/mach-mx5/clock-mx50.c new file +22
-0+} + + +static struct clk ahb_clk = { + .parent = &main_bus_clk, + .get_rate = _clk_ahb_get_rate, + .set_rate = _clk_ahb_set_rate, + .round_rate = _clk_ahb_round_rate, +}; + +static int _clk_max_enable (struct clk *clk) +{ +u32 reg; + +_clk_enable (clk); + +/* Handshake with MAX when LPM is entered. */ + reg =__raw_readl (MXC_CCM_CLPCR ); + reg &= ~MXC_CCM_CLPCR_BYPASS_MAX_LPM_HS ; +__raw_writel (reg,MXC_CCM_CLPCR ); + +return 0 ;
arch/arm/mach-mx5/clock-mx50.c line 1001
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+} + + +static void _clk_max_disable (struct clk *clk) +{ +u32 reg; + +_clk_disable_inwait (clk); + +/* No Handshake with MAX when LPM is entered as its disabled. */
s/H/h/
arch/arm/mach-mx5/clock-mx50.c line 1005
Quoted 4 lines
arch/arm/mach-mx5/clock-mx50.c new file +4
-0+ reg =__raw_readl (MXC_CCM_CLPCR ); + reg |=MXC_CCM_CLPCR_BYPASS_MAX_LPM_HS ; +__raw_writel (reg,MXC_CCM_CLPCR ); +}
When enabling you do
enable clk
enable handshake
; when disabling you do
disable clk
disable handshake
. This is not symmetric. Intended?
Quoted 217 lines
arch/arm/mach-mx5/clock-mx50.c new file +217
-0+static struct clk ahb_max_clk = { + .parent = &ahb_clk, + .enable_reg =MXC_CCM_CCGR0 , + .enable_shift = MXC_CCM_CCGRx_CG14_OFFSET, + .enable = _clk_max_enable, + .disable = _clk_max_disable, +}; + +static struct clk ahbmux1_clk = { + .id =0 , + .parent = &ahb_clk, + .secondary = &ahb_max_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR0 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .disable = _clk_disable_inwait, +}; + +static unsigned long _clk_ipg_get_rate (struct clk *clk) +{ +u32 reg, div; + + reg =__raw_readl (MXC_CCM_CBCDR ); + div = ((reg &MXC_CCM_CBCDR_IPG_PODF_MASK ) >> +MXC_CCM_CBCDR_IPG_PODF_OFFSET ) +1 ; +return clk_get_rate (clk->parent) / div; +} + +static struct clk ipg_clk = { + .parent = &ahb_clk, + .get_rate = _clk_ipg_get_rate, +}; + +static unsigned long _clk_ipg_per_get_rate (struct clk *clk) +{ +u32 reg, prediv1, prediv2, podf; + +if (clk->parent == &main_bus_clk || clk->parent == &lp_apm_clk) { +/* the main_bus_clk is the one before the DVFS engine */ + reg =__raw_readl (MXC_CCM_CBCDR ); + prediv1 = ((reg &MXC_CCM_CBCDR_PERCLK_PRED1_MASK ) >> +MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET ) +1 ; + prediv2 = ((reg &MXC_CCM_CBCDR_PERCLK_PRED2_MASK ) >> +MXC_CCM_CBCDR_PERCLK_PRED2_OFFSET ) +1 ; + podf = ((reg &MXC_CCM_CBCDR_PERCLK_PODF_MASK ) >> +MXC_CCM_CBCDR_PERCLK_PODF_OFFSET ) +1 ; +return clk_get_rate (clk->parent) / (prediv1 * prediv2 * podf); + }else if (clk->parent == &ipg_clk) { +return clk_get_rate (&ipg_clk); + } +BUG (); +return 0 ; +} + +static int _clk_ipg_per_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CBCMR ); + mux =_get_mux (parent, &main_bus_clk, &lp_apm_clk, &ipg_clk,NULL ); +if (mux ==2 ) { + reg |=MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL ; + }else { + reg &= ~MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL ; +if (mux ==0 ) + reg &= ~MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL ; +else + reg |=MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL ; + } +__raw_writel (reg,MXC_CCM_CBCMR ); + +return 0 ; +} + +static struct clk ipg_perclk = { + .parent = &lp_apm_clk, + .get_rate = _clk_ipg_per_get_rate, + .set_parent = _clk_ipg_per_set_parent, +}; + +static struct clk ipmux1_clk = { + .enable_reg =MXC_CCM_CCGR5 , + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, +}; + +static struct clk ipmux2_clk = { + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG0_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, +}; + +static int _clk_sys_clk_enable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CLK_SYS ); + reg &= ~(MXC_CCM_CLK_SYS_SYS_XTAL_CLKGATE_MASK | +MXC_CCM_CLK_SYS_SYS_PLL_CLKGATE_MASK ); +if (__raw_readl (MXC_CCM_CLKSEQ_BYPASS ) &0x1 ) + reg |=MXC_CCM_CLK_SYS_SYS_PLL_CLKGATE_MASK ; +else + reg |=MXC_CCM_CLK_SYS_SYS_XTAL_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_CLK_SYS ); +return 0 ; +} + +static void _clk_sys_clk_disable (struct clk *clk) +{ +u32 reg, reg1; + + reg1 = (__raw_readl (databahn +DATABAHN_CTL_REG55 )) + &DDR_SYNC_MODE ; + reg =__raw_readl (MXC_CCM_CLK_SYS ); + reg &= ~(MXC_CCM_CLK_SYS_SYS_XTAL_CLKGATE_MASK | +MXC_CCM_CLK_SYS_SYS_PLL_CLKGATE_MASK ); +if (__raw_readl (MXC_CCM_CLKSEQ_BYPASS ) &0x1 ) + reg |=1 <<MXC_CCM_CLK_SYS_SYS_PLL_CLKGATE_OFFSET ; +else { +/* If DDR is sourced from SYS_CLK (in Sync mode), we cannot +* gate its clock when ARM is in wait if the DDR is not in +* self refresh. +*/ +if (reg1 ==DDR_SYNC_MODE ) + reg |=3 <<MXC_CCM_CLK_SYS_SYS_XTAL_CLKGATE_OFFSET ; +else + reg |=1 <<MXC_CCM_CLK_SYS_SYS_XTAL_CLKGATE_OFFSET ; + } +__raw_writel (reg,MXC_CCM_CLK_SYS ); +} + +static struct clk sys_clk = { + .enable = _clk_sys_clk_enable, + .disable = _clk_sys_clk_disable, +}; + + +static int _clk_weim_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CBCDR ); +if (parent == &ahb_clk) + reg |=MXC_CCM_CBCDR_WEIM_CLK_SEL ; +else if (parent == &main_bus_clk) + reg &= ~MXC_CCM_CBCDR_WEIM_CLK_SEL ; +else +BUG (); +__raw_writel (reg,MXC_CCM_CBCDR ); + +return 0 ; +} + +static int _clk_weim_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; +if (div ==0 ) + div++; +if (((parent_rate / div) != rate) || (div >8 )) +return -EINVAL ; + reg =__raw_readl (MXC_CCM_CBCDR ); + reg &= ~MXC_CCM_CBCDR_WEIM_PODF_MASK ; + reg |= (div -1 ) <<MXC_CCM_CBCDR_WEIM_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_CBCDR ); +if (!WAIT (!(__raw_readl (MXC_CCM_CDHIPR ) &MXC_CCM_CDHIPR_WEIM_PODF_BUSY ) + ,SPIN_DELAY )) +panic ("_clk_emi_slow_set_rate failed\n" ); + +return 0 ; +} + +static unsigned long _clk_weim_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; +if (div >8 ) + div =8 ; +else if (div ==0 ) + div++; +return parent_rate / div; +} + +static struct clk weim_clk[] = { + { + .parent = &main_bus_clk, + .set_parent = _clk_weim_set_parent, + .set_rate = _clk_weim_set_rate, + .round_rate = _clk_weim_round_rate, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR5 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .disable = _clk_disable_inwait, + .secondary = &weim_clk[1 ], + }, + { + .parent = &ipg_clk, + .secondary = &sys_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR5 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, + .disable = _clk_disable_inwait, + } +}; + +static int _clk_ocram_enable (struct clk *clk) +{ +return 0 ; +} +
arch/arm/mach-mx5/clock-mx50.c line 1234
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+static void _clk_ocram_disable (struct clk *clk) +{ +} + +static struct clk ocram_clk = { + .parent = &sys_clk, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG1_OFFSET, + .enable = _clk_ocram_enable, + .disable = _clk_ocram_disable,
This looks fishy. .enable_reg and .enable_shift is unused because _clk_ocram_enable and _clk_ocram_disable are empty.
Quoted 40 lines
arch/arm/mach-mx5/clock-mx50.c new file +40
-0+}; + +static struct clk aips_tz1_clk = { + .parent = &ahb_clk, + .secondary = &ahb_max_clk, + .enable_reg =MXC_CCM_CCGR0 , + .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable_inwait, +}; + +static struct clk aips_tz2_clk = { + .parent = &ahb_clk, + .secondary = &ahb_max_clk, + .enable_reg =MXC_CCM_CCGR0 , + .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable_inwait, +}; + +static struct clk gpc_dvfs_clk = { + .enable_reg =MXC_CCM_CCGR5 , + .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, +}; + +static int _clk_sdma_enable (struct clk *clk) +{ +u32 reg; + +_clk_enable (clk); + +/* Handshake with SDMA when LPM is entered. */ + reg =__raw_readl (MXC_CCM_CLPCR ); + reg &= ~MXC_CCM_CLPCR_BYPASS_SDMA_LPM_HS ; +__raw_writel (reg,MXC_CCM_CLPCR ); + +return 0 ; +}
arch/arm/mach-mx5/clock-mx50.c line 1284
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+ +static void _clk_sdma_disable (struct clk *clk) +{ +u32 reg; + +_clk_disable (clk); +/* No handshake with SDMA as its not enabled. */ + reg =__raw_readl (MXC_CCM_CLPCR ); + reg |=MXC_CCM_CLPCR_BYPASS_SDMA_LPM_HS ; +__raw_writel (reg,MXC_CCM_CLPCR );
ditto
Quoted 149 lines
arch/arm/mach-mx5/clock-mx50.c new file +149
-0+} + + +static struct clk sdma_clk[] = { + { + .parent = &ahb_clk, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG15_OFFSET, + .enable = _clk_sdma_enable, + .disable = _clk_sdma_disable, + }, + { + .parent = &ipg_clk, + .secondary = &ddr_clk, + }, +}; + +static struct clk spba_clk = { + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR5 , + .enable_shift = MXC_CCM_CCGRx_CG0_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, +}; + +static unsigned long _clk_uart_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_CSCDR1 ); + prediv = ((reg &MXC_CCM_CSCDR1_UART_CLK_PRED_MASK ) >> +MXC_CCM_CSCDR1_UART_CLK_PRED_OFFSET ) +1 ; + podf = ((reg &MXC_CCM_CSCDR1_UART_CLK_PODF_MASK ) >> +MXC_CCM_CSCDR1_UART_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent)/(prediv * podf) ; +} + +static int _clk_uart_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, + &lp_apm_clk); + reg =__raw_readl (MXC_CCM_CSCMR1 ) & ~MXC_CCM_CSCMR1_UART_CLK_SEL_MASK ; + reg |= mux <<MXC_CCM_CSCMR1_UART_CLK_SEL_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk uart_main_clk = { + .parent = &pll2_sw_clk, + .get_rate = _clk_uart_get_rate, + .set_parent = _clk_uart_set_parent, +}; + +static struct clk uart1_clk[] = { + { + .id =0 , + .parent = &uart_main_clk, + .secondary = &uart1_clk[1 ], + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG4_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG3_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, +}; + +static struct clk uart2_clk[] = { + { + .id =1 , + .parent = &uart_main_clk, + .secondary = &uart2_clk[1 ], + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =1 , + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, +}; + +static struct clk uart3_clk[] = { + { + .id =2 , + .parent = &uart_main_clk, + .secondary = &uart3_clk[1 ], + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =2 , + .parent = &ipg_clk, + .secondary = &spba_clk, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, +}; + +static struct clk uart4_clk[] = { + { + .id =3 , + .parent = &uart_main_clk, + .secondary = &uart4_clk[1 ], + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =3 , + .parent = &ipg_clk, + .secondary = &spba_clk, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG4_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, +}; + +static struct clk uart5_clk[] = { + { + .id =4 , + .parent = &uart_main_clk, + .secondary = &uart5_clk[1 ], + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + },
arch/arm/mach-mx5/clock-mx50.c line 1443
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+ { + .id = 4, + .parent = &ipg_clk, + .secondary = &spba_clk, + .enable_reg = MXC_CCM_CCGR7, + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, +};
macro to define the uart clocks
Quoted 62 lines
arch/arm/mach-mx5/clock-mx50.c new file +62
-0+ +static struct clk gpt_clk[] = { + { + .parent = &ipg_perclk, + .id =0 , + .secondary = &gpt_clk[1 ], + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG10_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ckil_clk, + }, +}; + +static struct clk pwm1_clk[] = { + { + .parent = &ipg_perclk, + .id =0 , + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + .secondary = &pwm1_clk[1 ], + }, + { + .id =0 , + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, + .enable = _clk_enable_inrun,/*Active only when ARM is running. */ + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ckil_clk, + }, +}; + +static struct clk pwm2_clk[] = { + { + .parent = &ipg_perclk, + .id =1 , + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + .secondary = &pwm2_clk[1 ], + }, + { + .id =1 , + .parent = &ipg_clk,
arch/arm/mach-mx5/clock-mx50.c line 1515
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+ .enable_reg = MXC_CCM_CCGR2, + .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, + .enable = _clk_enable_inrun, /*Active only when ARM is running. */ + .disable = _clk_disable, + }, + { + .id = 1, + .parent = &ckil_clk, + }, +};
macro?
Quoted 744 lines
arch/arm/mach-mx5/clock-mx50.c new file +744
-0+ +static struct clk i2c_clk[] = { + { + .id =0 , + .parent = &ipg_perclk, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =1 , + .parent = &ipg_perclk, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG10_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =2 , + .parent = &ipg_perclk, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG11_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, +}; + +static unsigned long _clk_cspi_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_CSCDR2 ); + prediv = ((reg &MXC_CCM_CSCDR2_CSPI_CLK_PRED_MASK ) >> +MXC_CCM_CSCDR2_CSPI_CLK_PRED_OFFSET ) +1 ; +if (prediv ==1 ) +BUG (); + podf = ((reg &MXC_CCM_CSCDR2_CSPI_CLK_PODF_MASK ) >> +MXC_CCM_CSCDR2_CSPI_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent) / (prediv * podf); +} + +static int _clk_cspi_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, + &lp_apm_clk); + reg =__raw_readl (MXC_CCM_CSCMR1 ) & ~MXC_CCM_CSCMR1_CSPI_CLK_SEL_MASK ; + reg |= mux <<MXC_CCM_CSCMR1_CSPI_CLK_SEL_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk cspi_main_clk = { + .parent = &pll3_sw_clk, + .get_rate = _clk_cspi_get_rate, + .set_parent = _clk_cspi_set_parent, +}; + +static struct clk cspi1_clk[] = { + { + .id =0 , + .parent = &cspi_main_clk, + .secondary = &cspi1_clk[1 ], + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG10_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ipg_clk, + .secondary = &spba_clk, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, + .enable = _clk_enable_inrun,/*Active only when ARM is running. */ + .disable = _clk_disable, + }, +}; + +static struct clk cspi2_clk[] = { + { + .id =1 , + .parent = &cspi_main_clk, + .secondary = &cspi2_clk[1 ], + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =1 , + .parent = &ipg_clk, + .secondary = &aips_tz2_clk, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG11_OFFSET, + .enable = _clk_enable_inrun,/*Active only when ARM is running. */ + .disable = _clk_disable, + }, +}; + +static struct clk cspi3_clk = { + .id =2 , + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + .secondary = &aips_tz2_clk, +}; + +static int _clk_ssi_lp_apm_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CSCMR1 ) & ~MXC_CCM_CSCMR1_SSI_APM_CLK_SEL ; +if (parent == &lp_apm_clk) + reg |=MXC_CCM_CSCMR1_SSI_APM_CLK_SEL ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk ssi_lp_apm_clk = { + .parent = &ckih_clk, + .set_parent = _clk_ssi_lp_apm_set_parent, +}; + +static unsigned long _clk_ssi1_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_CS1CDR ); + prediv = ((reg &MXC_CCM_CS1CDR_SSI1_CLK_PRED_MASK ) >> +MXC_CCM_CS1CDR_SSI1_CLK_PRED_OFFSET ) +1 ; +if (prediv ==1 ) +BUG (); + podf = ((reg &MXC_CCM_CS1CDR_SSI1_CLK_PODF_MASK ) >> +MXC_CCM_CS1CDR_SSI1_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent) / (prediv * podf); +} +static int _clk_ssi1_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, + &pll3_sw_clk, &ssi_lp_apm_clk); + reg =__raw_readl (MXC_CCM_CSCMR1 ) & ~MXC_CCM_CSCMR1_SSI1_CLK_SEL_MASK ; + reg |= mux <<MXC_CCM_CSCMR1_SSI1_CLK_SEL_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk ssi1_clk[] = { + { + .id =0 , + .parent = &pll3_sw_clk, + .set_parent = _clk_ssi1_set_parent, + .secondary = &ssi1_clk[1 ], + .get_rate = _clk_ssi1_get_rate, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ipg_clk, + .secondary = &ssi1_clk[2 ], + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &aips_tz2_clk, + }, +}; + +static unsigned long _clk_ssi2_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_CS2CDR ); + prediv = ((reg &MXC_CCM_CS2CDR_SSI2_CLK_PRED_MASK ) >> +MXC_CCM_CS2CDR_SSI2_CLK_PRED_OFFSET ) +1 ; +if (prediv ==1 ) +BUG (); + podf = ((reg &MXC_CCM_CS2CDR_SSI2_CLK_PODF_MASK ) >> +MXC_CCM_CS2CDR_SSI2_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent) / (prediv * podf); +} + +static int _clk_ssi2_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, + &pll3_sw_clk, &ssi_lp_apm_clk); + reg =__raw_readl (MXC_CCM_CSCMR1 ) & ~MXC_CCM_CSCMR1_SSI2_CLK_SEL_MASK ; + reg |= mux <<MXC_CCM_CSCMR1_SSI2_CLK_SEL_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk ssi2_clk[] = { + { + .id =1 , + .parent = &pll3_sw_clk, + .set_parent = _clk_ssi2_set_parent, + .secondary = &ssi2_clk[1 ], + .get_rate = _clk_ssi2_get_rate, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG11_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =1 , + .parent = &ipg_clk, + .secondary = &ssi2_clk[2 ], + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG10_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =1 , + .parent = &spba_clk, + }, +}; + +static unsigned long _clk_ssi_ext1_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; +u32 div =1 ; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); +if ((reg &MXC_CCM_CSCMR1_SSI_EXT1_COM_CLK_SEL ) ==0 ) { + reg =__raw_readl (MXC_CCM_CS1CDR ); + prediv = ((reg &MXC_CCM_CS1CDR_SSI_EXT1_CLK_PRED_MASK ) >> +MXC_CCM_CS1CDR_SSI_EXT1_CLK_PRED_OFFSET ) +1 ; +if (prediv ==1 ) +BUG (); + podf = ((reg &MXC_CCM_CS1CDR_SSI_EXT1_CLK_PODF_MASK ) >> +MXC_CCM_CS1CDR_SSI_EXT1_CLK_PODF_OFFSET ) +1 ; + div = prediv * podf; + } +return clk_get_rate (clk->parent) / div; +} + +static int _clk_ssi_ext1_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, div, pre, post; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; +if (div ==0 ) + div++; +if (((parent_rate / div) != rate) || div >512 ) +return -EINVAL ; + +__calc_pre_post_dividers (div, &pre, &post); + + reg =__raw_readl (MXC_CCM_CS1CDR ); + reg &= ~(MXC_CCM_CS1CDR_SSI_EXT1_CLK_PRED_MASK | +MXC_CCM_CS1CDR_SSI_EXT1_CLK_PODF_MASK ); + reg |= (post -1 ) <<MXC_CCM_CS1CDR_SSI_EXT1_CLK_PODF_OFFSET ; + reg |= (pre -1 ) <<MXC_CCM_CS1CDR_SSI_EXT1_CLK_PRED_OFFSET ; +__raw_writel (reg,MXC_CCM_CS1CDR ); + +return 0 ; +} + +static int _clk_ssi_ext1_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); +if (parent == &ssi1_clk[0 ]) { + reg |=MXC_CCM_CSCMR1_SSI_EXT1_COM_CLK_SEL ; + }else { + reg &= ~MXC_CCM_CSCMR1_SSI_EXT1_COM_CLK_SEL ; + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, + &ssi_lp_apm_clk); + reg = (reg & ~MXC_CCM_CSCMR1_SSI_EXT1_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CSCMR1_SSI_EXT1_CLK_SEL_OFFSET ); + } + +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static unsigned long _clk_ssi_ext1_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 pre, post; +u32 parent_rate =clk_get_rate (clk->parent); +u32 div = parent_rate / rate; + +if (parent_rate % rate) + div++; + +__calc_pre_post_dividers (div, &pre, &post); + +return parent_rate / (pre * post); +} + +static struct clk ssi_ext1_clk = { + .parent = &pll3_sw_clk, + .set_parent = _clk_ssi_ext1_set_parent, + .set_rate = _clk_ssi_ext1_set_rate, + .round_rate = _clk_ssi_ext1_round_rate, + .get_rate = _clk_ssi_ext1_get_rate, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG14_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, +}; + +static unsigned long _clk_ssi_ext2_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; +u32 div =1 ; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); +if ((reg &MXC_CCM_CSCMR1_SSI_EXT2_COM_CLK_SEL ) ==0 ) { + reg =__raw_readl (MXC_CCM_CS2CDR ); + prediv = ((reg &MXC_CCM_CS2CDR_SSI_EXT2_CLK_PRED_MASK ) >> +MXC_CCM_CS2CDR_SSI_EXT2_CLK_PRED_OFFSET ) +1 ; +if (prediv ==1 ) +BUG (); + podf = ((reg &MXC_CCM_CS2CDR_SSI_EXT2_CLK_PODF_MASK ) >> +MXC_CCM_CS2CDR_SSI_EXT2_CLK_PODF_OFFSET ) +1 ; + div = prediv * podf; + } +return clk_get_rate (clk->parent) / div; +} + +static int _clk_ssi_ext2_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); +if (parent == &ssi2_clk[0 ]) { + reg |=MXC_CCM_CSCMR1_SSI_EXT2_COM_CLK_SEL ; + }else { + reg &= ~MXC_CCM_CSCMR1_SSI_EXT2_COM_CLK_SEL ; + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, + &ssi_lp_apm_clk); + reg = (reg & ~MXC_CCM_CSCMR1_SSI_EXT2_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CSCMR1_SSI_EXT2_CLK_SEL_OFFSET ); + } + +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk ssi_ext2_clk = { + .parent = &pll3_sw_clk, + .set_parent = _clk_ssi_ext2_set_parent, + .get_rate = _clk_ssi_ext2_get_rate, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG15_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, +}; + +static struct clk tmax2_clk = { + .id =0 , + .parent = &ahb_clk, + .secondary = &ahb_max_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG1_OFFSET, + .disable = _clk_disable, +}; + +static struct clk usb_ahb_clk = { + .parent = &ipg_clk, + .secondary = &ddr_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET, + .disable = _clk_disable, +}; + +static struct clk usb_phy_clk[] = { + { + .id =0 , + .parent = &osc_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, + .disable = _clk_disable, + }, + { + .id =1 , + .parent = &osc_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .disable = _clk_disable, + } +}; + +static struct clk esdhc_dep_clks = { + .parent = &spba_clk, + .secondary = &ddr_clk, +}; + +static unsigned long _clk_esdhc1_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_CSCDR1 ); + prediv = ((reg &MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PRED_MASK ) >> +MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PRED_OFFSET ) +1 ; + podf = ((reg &MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PODF_MASK ) >> +MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent) / (prediv * podf); +} + +static int _clk_esdhc1_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, + &lp_apm_clk); + reg = reg & ~MXC_CCM_CSCMR1_ESDHC1_CLK_SEL_MASK ; + reg |= mux <<MXC_CCM_CSCMR1_ESDHC1_CLK_SEL_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + + +static int _clk_esdhc1_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg; +u32 div; +u32 pre, post; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; + +if ((parent_rate / div) != rate) +return -EINVAL ; + +__calc_pre_post_dividers (div, &pre, &post); + +/* Set sdhc1 clock divider */ + reg =__raw_readl (MXC_CCM_CSCDR1 ) & + ~(MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PRED_MASK | +MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PODF_MASK ); + reg |= (post -1 ) <<MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PODF_OFFSET ; + reg |= (pre -1 ) <<MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PRED_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCDR1 ); + +return 0 ; +} + +static struct clk esdhc1_clk[] = { + { + .id =0 , + .parent = &pll2_sw_clk, + .set_parent = _clk_esdhc1_set_parent, + .get_rate = _clk_esdhc1_get_rate, + .set_rate = _clk_esdhc1_set_rate, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG1_OFFSET, + .disable = _clk_disable, + .secondary = &esdhc1_clk[1 ], + }, + { + .id =0 , + .parent = &ipg_clk, + .secondary = &esdhc1_clk[2 ], + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG0_OFFSET, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &tmax2_clk, + .secondary = &esdhc_dep_clks, + }, + +}; + +static int _clk_esdhc2_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); +if (parent == &esdhc1_clk[0 ]) + reg &= ~MXC_CCM_CSCMR1_ESDHC2_CLK_SEL ; +else if (parent == &esdhc3_clk[0 ]) + reg |=MXC_CCM_CSCMR1_ESDHC2_CLK_SEL ; +else +BUG (); +__raw_writel (reg,MXC_CCM_CSCMR1 ); +return 0 ; +} + +static struct clk esdhc2_clk[] = { + { + .id =1 , + .parent = &esdhc1_clk[0 ], + .set_parent = _clk_esdhc2_set_parent, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG3_OFFSET, + .disable = _clk_disable, + .secondary = &esdhc2_clk[1 ], + }, + { + .id =1 , + .parent = &ipg_clk, + .secondary = &esdhc2_clk[2 ], + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG2_OFFSET, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &tmax2_clk, + .secondary = &esdhc_dep_clks, + }, +}; + +static int _clk_esdhc3_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); + mux =_get_mux8 (parent, &pll1_sw_clk, &pll2_sw_clk, + &pll3_sw_clk, &lp_apm_clk, &pfd0_clk, + &pfd1_clk, &pfd4_clk, &osc_clk); + reg = reg & ~MXC_CCM_CSCMR1_ESDHC3_CLK_SEL_MASK ; + reg |= mux <<MXC_CCM_CSCMR1_ESDHC3_CLK_SEL_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static unsigned long _clk_esdhc3_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_CSCDR1 ); + prediv = ((reg &MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PRED_MASK ) >> +MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PRED_OFFSET ) +1 ; + podf = ((reg &MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PODF_MASK ) >> +MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent) / (prediv * podf); +} + +static int _clk_esdhc3_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg; +u32 div; +u32 pre, post; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; + +if ((parent_rate / div) != rate) +return -EINVAL ; + +__calc_pre_post_dividers (div, &pre, &post); + +/* Set sdhc1 clock divider */ + reg =__raw_readl (MXC_CCM_CSCDR1 ) & + ~(MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PRED_MASK | +MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PODF_MASK ); + reg |= (post -1 ) <<MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PODF_OFFSET ; + reg |= (pre -1 ) <<MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PRED_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCDR1 ); + +return 0 ; +} + + +static struct clk esdhc3_clk[] = { + { + .id =2 , + .parent = &pll2_sw_clk, + .set_parent = _clk_esdhc3_set_parent, + .get_rate = _clk_esdhc3_get_rate, + .set_rate = _clk_esdhc3_set_rate, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, + .disable = _clk_disable, + .secondary = &esdhc3_clk[1 ], + }, + { + .id =2 , + .parent = &ipg_clk, + .secondary = &esdhc3_clk[2 ], + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG4_OFFSET, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ahb_max_clk, + .secondary = &esdhc_dep_clks, + }, +}; + +static int _clk_esdhc4_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); +if (parent == &esdhc1_clk[0 ]) + reg &= ~MXC_CCM_CSCMR1_ESDHC4_CLK_SEL ; +else if (parent == &esdhc3_clk[0 ]) + reg |=MXC_CCM_CSCMR1_ESDHC4_CLK_SEL ; +else +BUG (); +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk esdhc4_clk[] = { + { + .id =3 , + .parent = &esdhc1_clk[0 ], + .set_parent = _clk_esdhc4_set_parent, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, + .disable = _clk_disable, + .secondary = &esdhc4_clk[1 ], + }, + { + .id =3 , + .parent = &ipg_clk, + .secondary = &esdhc4_clk[2 ], + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &tmax2_clk, + .secondary = &esdhc_dep_clks, + }, +}; + +static int _clk_ddr_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CLK_DDR ); +if (parent == &pfd0_clk) + reg |=MXC_CCM_CLK_DDR_DDR_PFD_SEL ; +else if (parent == &pll1_sw_clk) + reg &= ~MXC_CCM_CLK_DDR_DDR_PFD_SEL ; +else +return -EINVAL ; +__raw_writel (reg,MXC_CCM_CLK_DDR ); +return 0 ; +} + +static unsigned long _clk_ddr_get_rate (struct clk *clk) +{ +u32 reg, div; + + reg =__raw_readl (MXC_CCM_CLK_DDR ); + div = (reg &MXC_CCM_CLK_DDR_DDR_DIV_PLL_MASK ) >> +MXC_CCM_CLK_DDR_DDR_DIV_PLL_OFFSET ; +if (div) +return clk_get_rate (clk->parent) / div; + +return 0 ; +} + +static int _clk_ddr_enable (struct clk *clk) +{ +u32 reg; + +_clk_enable (clk); + reg = (__raw_readl (databahn +DATABAHN_CTL_REG55 )) & +DDR_SYNC_MODE ; +if (reg !=DDR_SYNC_MODE ) { + reg =__raw_readl (MXC_CCM_CLK_DDR ); + reg |=MXC_CCM_CLK_DDR_DDR_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_CLK_DDR ); + } +return 0 ; +} + +static void _clk_ddr_disable (struct clk *clk) +{ +_clk_disable_inwait (clk); +} + + +static struct clk ddr_clk = { + .parent = &pll1_sw_clk, + .secondary = &sys_clk, + .set_parent = _clk_ddr_set_parent, + .get_rate = _clk_ddr_get_rate, + .enable = _clk_ddr_enable, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG15_OFFSET, + .disable = _clk_ddr_disable, +}; + +static unsigned long _clk_pgc_get_rate (struct clk *clk) +{ +u32 reg, div; + + reg =__raw_readl (MXC_CCM_CSCDR1 ); + div = (reg &MXC_CCM_CSCDR1_PGC_CLK_PODF_MASK ) >> +MXC_CCM_CSCDR1_PGC_CLK_PODF_OFFSET ; + div =1 >> div; +return clk_get_rate (clk->parent) / div; +} + +static struct clk pgc_clk = {
arch/arm/mach-mx5/clock-mx50.c line 2269
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+ .parent = &ipg_clk, + .get_rate = _clk_pgc_get_rate, +}; + +static unsigned long _clk_usb_get_rate (struct clk *clk) +{ +return 60000000 ; +} + +/*usb OTG clock */
space after * please
arch/arm/mach-mx5/crm_regs-mx50.h
Quoted 1,005 lines
arch/arm/mach-mx5/clock-mx50.c new file +993
-0+static struct clk usb_clk = { + .get_rate = _clk_usb_get_rate, +}; + +static struct clk rtc_clk = { + .parent = &ckil_clk, + .secondary = &ipg_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG14_OFFSET, + .disable = _clk_disable, +}; + +struct clk rng_clk = { + .parent = &ipg_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG1_OFFSET, + .disable = _clk_disable, +}; + +static struct clk owire_clk = { + .parent = &ipg_perclk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG11_OFFSET, + .disable = _clk_disable, +}; + +static struct clk fec_clk[] = { + { + .parent = &ipg_clk, + .secondary = &fec_clk[1 ], + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET, + .disable = _clk_disable, + }, + { + .parent = &aips_tz2_clk, + .secondary = &ddr_clk, + }, +}; + +static int gpmi_clk_enable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_GPMI ); + reg |=MXC_CCM_GPMI_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_GPMI ); +_clk_enable (clk); +return 0 ; +} + +static void gpmi_clk_disable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_GPMI ); + reg &= ~MXC_CCM_GPMI_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_GPMI ); +_clk_disable (clk); +} + +static int bch_clk_enable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_BCH ); + reg |=MXC_CCM_BCH_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_BCH ); +_clk_enable (clk); +return 0 ; +} + +static void bch_clk_disable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_BCH ); + reg &= ~MXC_CCM_BCH_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_BCH ); +_clk_disable (clk); +} + +static int gpmi_set_parent (struct clk *clk,struct clk *parent) +{ +/* Setting for ONFI nand which need PLL1(800MHZ) */ +if (parent == &pll1_main_clk) { +u32 reg =__raw_readl (MXC_CCM_CLKSEQ_BYPASS ); + + reg = (reg & ~MXC_CCM_CLKSEQ_BYPASS_BYPASS_GPMI_CLK_SEL_MASK ) | + (0x2 <<MXC_CCM_CLKSEQ_BYPASS_BYPASS_GPMI_CLK_SEL_OFFSET ); + +__raw_writel (reg,MXC_CCM_CLKSEQ_BYPASS ); + +/* change to the new Parent */ + clk->parent = parent; + }else +printk (KERN_WARNING "You should not call the %s\n" , __func__); +return 0 ; +} + +static int gpmi_set_rate (struct clk *clk,unsigned long rate) +{ +/* Setting for ONFI nand which in different mode */ +if (clk->parent == &pll1_main_clk) { +u32 value; +u32 reg; + + value =clk_get_rate (clk->parent); + value /= rate; + value /=2 ;/* HW_GPMI_CTRL1's GPMI_CLK_DIV2_EN will be set */ + + reg =__raw_readl (MXC_CCM_GPMI ); + reg = (reg & ~MXC_CCM_GPMI_CLK_DIV_MASK ) | value; + +__raw_writel (reg,MXC_CCM_GPMI ); + }else +printk (KERN_WARNING "You should not call the %s\n" , __func__); +return 0 ; +} + +static struct clk gpmi_nfc_clk[] = { + {/* gpmi_io_clk */ + .parent = &osc_clk, + .secondary = &gpmi_nfc_clk[1 ], + .set_parent = gpmi_set_parent, + .set_rate = gpmi_set_rate, + .enable = gpmi_clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, + .disable = gpmi_clk_disable, + }, + {/* gpmi_apb_clk */ + .parent = &ahb_clk, + .secondary = &gpmi_nfc_clk[2 ], + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .disable = _clk_disable, + }, + {/* bch_clk */ + .parent = &osc_clk, + .secondary = &gpmi_nfc_clk[3 ], + .enable = bch_clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG0_OFFSET, + .disable = bch_clk_disable, + }, + {/* bch_apb_clk */ + .parent = &ahb_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET, + .disable = _clk_disable, + }, +}; + +static struct clk ocotp_clk = { + .parent = &ahb_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET, + .disable = _clk_disable, +}; + +static int _clk_gpu2d_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CBCMR ); + mux =_get_mux (parent, &axi_a_clk, &axi_b_clk, &weim_clk[0 ], &ahb_clk); + reg = (reg & ~MXC_CCM_CBCMR_GPU2D_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CBCMR_GPU2D_CLK_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CBCMR ); + +return 0 ; +} + +static struct clk gpu2d_clk = { + .parent = &axi_a_clk, + .secondary = &ddr_clk, + .set_parent = _clk_gpu2d_set_parent, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, + .disable = _clk_disable, +}; + +static struct clk apbh_dma_clk = { + .parent = &ahb_clk, + .secondary = &ddr_clk, + .enable = _clk_enable, + .disable = _clk_disable_inwait, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG10_OFFSET, +}; + +struct clk dcp_clk = { + .parent = &ahb_clk, + .secondary = &apbh_dma_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG11_OFFSET, + .disable = _clk_disable, +}; + +static int _clk_display_axi_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CLKSEQ_BYPASS ); + mux =_get_mux (parent, &osc_clk, &pfd2_clk, &pll1_sw_clk,NULL ); + reg = (reg & ~MXC_CCM_CLKSEQ_BYPASS_BYPASS_DISPLAY_AXI_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CLKSEQ_BYPASS_BYPASS_DISPLAY_AXI_CLK_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CLKSEQ_BYPASS ); + +return 0 ; +} + +static unsigned long _clk_display_axi_get_rate (struct clk *clk) +{ +u32 div; + + div =__raw_readl (MXC_CCM_DISPLAY_AXI ); + div &=MXC_CCM_DISPLAY_AXI_DIV_MASK ; +if (div ==0 ) {/* gated off */ +return clk_get_rate (clk->parent); + }else { +return clk_get_rate (clk->parent) / div; + } +} + +static unsigned long _clk_display_axi_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 max_div = (2 <<6 ) -1 ; +return _clk_round_rate_div (clk, rate, max_div,NULL ); +} + +static int _clk_display_axi_set_rate (struct clk *clk,unsigned long rate) +{ +u32 new_div, max_div; +u32 reg; + + max_div = (2 <<6 ) -1 ; +_clk_round_rate_div (clk, rate, max_div, &new_div); + + reg =__raw_readl (MXC_CCM_DISPLAY_AXI ); + reg &= ~MXC_CCM_DISPLAY_AXI_DIV_MASK ; + reg |= new_div <<MXC_CCM_DISPLAY_AXI_DIV_OFFSET ; +__raw_writel (reg,MXC_CCM_DISPLAY_AXI ); + +while (__raw_readl (MXC_CCM_CSR2 ) &MXC_CCM_CSR2_DISPLAY_AXI_BUSY ) + ; +return 0 ; +} + +static struct clk display_axi_clk = { + .parent = &osc_clk, + .secondary = &apbh_dma_clk, + .set_parent = _clk_display_axi_set_parent, + .get_rate = _clk_display_axi_get_rate, + .set_rate = _clk_display_axi_set_rate, + .round_rate = _clk_display_axi_round_rate, + .enable = _clk_enable, + .disable = _clk_disable, + .enable_reg =MXC_CCM_DISPLAY_AXI , + .enable_shift =MXC_CCM_DISPLAY_AXI_CLKGATE_OFFSET , +}; + +/* TODO: check Auto-Slow Mode */ +static struct clk pxp_axi_clk = { + .parent = &display_axi_clk, + .enable = _clk_enable, + .disable = _clk_disable, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, +}; + +static struct clk elcdif_axi_clk = { + .parent = &display_axi_clk, + .enable = _clk_enable, + .disable = _clk_disable, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG10_OFFSET, +}; + +static int _clk_elcdif_pix_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CLKSEQ_BYPASS ); + mux =_get_mux (parent, &osc_clk, &pfd6_clk, &pll1_sw_clk, &ckih_clk); + reg = (reg & ~MXC_CCM_CLKSEQ_BYPASS_BYPASS_ELCDIF_PIX_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CLKSEQ_BYPASS_BYPASS_ELCDIF_PIX_CLK_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CLKSEQ_BYPASS ); + +return 0 ; +} + +static unsigned long _clk_elcdif_pix_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_ELCDIFPIX ); + prediv = ((reg &MXC_CCM_ELCDIFPIX_CLK_PRED_MASK ) >> +MXC_CCM_ELCDIFPIX_CLK_PRED_OFFSET ) +1 ; + podf = ((reg &MXC_CCM_ELCDIFPIX_CLK_PODF_MASK ) >> +MXC_CCM_ELCDIFPIX_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent) / (prediv * podf); +} + +static unsigned long _clk_elcdif_pix_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 max_div = (2 <<12 ) -1 ; +return _clk_round_rate_div (clk, rate, max_div,NULL ); +} + +static int _clk_elcdif_pix_set_rate (struct clk *clk,unsigned long rate) +{ +u32 new_div, max_div; +u32 reg; + + max_div = (2 <<12 ) -1 ; +_clk_round_rate_div (clk, rate, max_div, &new_div); + + reg =__raw_readl (MXC_CCM_ELCDIFPIX ); +/* Pre-divider set to 1 - only use PODF for clk dividing */ + reg &= ~MXC_CCM_ELCDIFPIX_CLK_PRED_MASK ; + reg |=1 <<MXC_CCM_ELCDIFPIX_CLK_PRED_OFFSET ; + reg &= ~MXC_CCM_ELCDIFPIX_CLK_PODF_MASK ; + reg |= new_div <<MXC_CCM_ELCDIFPIX_CLK_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_ELCDIFPIX ); + +return 0 ; +} + +static int _clk_elcdif_pix_enable (struct clk *clk) +{ +u32 reg; + +_clk_enable (clk); + reg =__raw_readl (MXC_CCM_ELCDIFPIX ); + reg |=0x3 <<MXC_CCM_ELCDIFPIX_CLKGATE_OFFSET ; +__raw_writel (reg,MXC_CCM_ELCDIFPIX ); +return 0 ; +} + +static void _clk_elcdif_pix_disable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_ELCDIFPIX ); + reg &= ~MXC_CCM_ELCDIFPIX_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_ELCDIFPIX ); +_clk_disable (clk); +} + +static struct clk elcdif_pix_clk = { + .parent = &osc_clk, + .secondary = &ddr_clk, + .enable = _clk_elcdif_pix_enable, + .disable = _clk_elcdif_pix_disable, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .set_parent = _clk_elcdif_pix_set_parent, + .get_rate = _clk_elcdif_pix_get_rate, + .round_rate = _clk_elcdif_pix_round_rate, + .set_rate = _clk_elcdif_pix_set_rate, +}; + +static int _clk_epdc_axi_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CLKSEQ_BYPASS ); + mux =_get_mux (parent, &osc_clk, &pfd3_clk, &pll1_sw_clk,NULL ); + reg = (reg & ~MXC_CCM_CLKSEQ_BYPASS_BYPASS_EPDC_AXI_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CLKSEQ_BYPASS_BYPASS_EPDC_AXI_CLK_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CLKSEQ_BYPASS ); + +return 0 ; +} + +static unsigned long _clk_epdc_axi_get_rate (struct clk *clk) +{ +u32 div; + + div =__raw_readl (MXC_CCM_EPDC_AXI ); + div &=MXC_CCM_EPDC_AXI_DIV_MASK ; +if (div ==0 ) {/* gated off */ +return clk_get_rate (clk->parent); + }else { +return clk_get_rate (clk->parent) / div; + } +} + +static unsigned long _clk_epdc_axi_round_rate_div (struct clk *clk, +unsigned long rate, +u32 *new_div) +{ +u32 div, max_div; + + max_div = (2 <<6 ) -1 ; + div =DIV_ROUND_UP (clk_get_rate (clk->parent), rate); +if (div > max_div) + div = max_div; +else if (div ==0 ) + div++; +if (new_div !=NULL ) + *new_div = div; +return clk_get_rate (clk->parent) / div; +} + +static unsigned long _clk_epdc_axi_round_rate (struct clk *clk, +unsigned long rate) +{ +return _clk_epdc_axi_round_rate_div (clk, rate,NULL ); +} + +static int _clk_epdc_axi_set_rate (struct clk *clk,unsigned long rate) +{ +u32 new_div; +u32 reg; + +_clk_epdc_axi_round_rate_div (clk, rate, &new_div); + + reg =__raw_readl (MXC_CCM_EPDC_AXI ); + reg &= ~MXC_CCM_EPDC_AXI_DIV_MASK ; + reg |= new_div <<MXC_CCM_EPDC_AXI_DIV_OFFSET ; +__raw_writel (reg,MXC_CCM_EPDC_AXI ); + +while (__raw_readl (MXC_CCM_CSR2 ) &MXC_CCM_CSR2_EPDC_AXI_BUSY ) + ; + +return 0 ; +} + +static int _clk_epdc_axi_enable (struct clk *clk) +{ +u32 reg; + +_clk_enable (clk); + + reg =__raw_readl (MXC_CCM_EPDC_AXI ); + reg |=MXC_CCM_EPDC_AXI_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_EPDC_AXI ); + +return 0 ; +} + +static void _clk_epdc_axi_disable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_EPDC_AXI ); + reg &= ~MXC_CCM_EPDC_AXI_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_EPDC_AXI ); +_clk_disable (clk); +} + +/* TODO: check Auto-Slow Mode */ +static struct clk epdc_axi_clk = { + .parent = &osc_clk, + .secondary = &apbh_dma_clk, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .set_parent = _clk_epdc_axi_set_parent, + .get_rate = _clk_epdc_axi_get_rate, + .set_rate = _clk_epdc_axi_set_rate, + .round_rate = _clk_epdc_axi_round_rate, + .enable = _clk_epdc_axi_enable, + .disable = _clk_epdc_axi_disable, +}; + + +static int _clk_epdc_pix_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CLKSEQ_BYPASS ); + mux =_get_mux (parent, &osc_clk, &pfd5_clk, &pll1_sw_clk, &ckih_clk); + reg = (reg & ~MXC_CCM_CLKSEQ_BYPASS_BYPASS_EPDC_PIX_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CLKSEQ_BYPASS_BYPASS_EPDC_PIX_CLK_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CLKSEQ_BYPASS ); + +return 0 ; +} + +static unsigned long _clk_epdc_pix_get_rate (struct clk *clk) +{ +u32 div; + + div =__raw_readl (MXC_CCM_EPDCPIX ); + div &=MXC_CCM_EPDC_PIX_CLK_PODF_MASK ; +if (div ==0 ) {/* gated off */ +return clk_get_rate (clk->parent); + }else { +return clk_get_rate (clk->parent) / div; + } +} + +static unsigned long _clk_epdc_pix_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 max_div = (2 <<12 ) -1 ; +return _clk_round_rate_div (clk, rate, max_div,NULL ); +} + +static int _clk_epdc_pix_set_rate (struct clk *clk,unsigned long rate) +{ +u32 new_div, max_div; +u32 reg; + + max_div = (2 <<12 ) -1 ; +_clk_round_rate_div (clk, rate, max_div, &new_div); + + reg =__raw_readl (MXC_CCM_EPDCPIX ); +/* Pre-divider set to 1 - only use PODF for clk dividing */ + reg &= ~MXC_CCM_EPDC_PIX_CLK_PRED_MASK ; + reg |=1 <<MXC_CCM_EPDC_PIX_CLK_PRED_OFFSET ; + reg &= ~MXC_CCM_EPDC_PIX_CLK_PODF_MASK ; + reg |= new_div <<MXC_CCM_EPDC_PIX_CLK_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_EPDCPIX ); + +while (__raw_readl (MXC_CCM_CSR2 ) &MXC_CCM_CSR2_EPDC_PIX_BUSY ) + ; + +return 0 ; +} + +static int _clk_epdc_pix_enable (struct clk *clk) +{ +u32 reg; + +_clk_enable (clk); + reg =__raw_readl (MXC_CCM_EPDCPIX ); + reg |=MXC_CCM_EPDC_PIX_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_EPDCPIX ); + +return 0 ; +} + +static void _clk_epdc_pix_disable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_EPDCPIX ); + reg &= ~MXC_CCM_EPDC_PIX_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_EPDCPIX ); +_clk_disable (clk); +} + +/* TODO: check Auto-Slow Mode */ +static struct clk epdc_pix_clk = { + .parent = &osc_clk, + .secondary = &apbh_dma_clk, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, + .set_parent = _clk_epdc_pix_set_parent, + .get_rate = _clk_epdc_pix_get_rate, + .set_rate = _clk_epdc_pix_set_rate, + .round_rate = _clk_epdc_pix_round_rate, + .enable = _clk_epdc_pix_enable, + .disable = _clk_epdc_pix_disable, +}; + +static unsigned long cko1_get_rate (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CCOSR ); + reg &=MXC_CCM_CCOSR_CKO1_DIV_MASK ; + reg = reg >>MXC_CCM_CCOSR_CKO1_DIV_OFFSET ; +return clk_get_rate (clk->parent) / (reg +1 ); +} + +static int cko1_enable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CCOSR ); + reg |=MXC_CCM_CCOSR_CKO1_EN ; +__raw_writel (reg,MXC_CCM_CCOSR ); +return 0 ; +} + +static void cko1_disable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CCOSR ); + reg &= ~MXC_CCM_CCOSR_CKO1_EN ; +__raw_writel (reg,MXC_CCM_CCOSR ); +} + +static int cko1_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = (parent_rate/rate -1 ) &0x7 ; + reg =__raw_readl (MXC_CCM_CCOSR ); + reg &= ~MXC_CCM_CCOSR_CKO1_DIV_MASK ; + reg |= div <<MXC_CCM_CCOSR_CKO1_DIV_OFFSET ; +__raw_writel (reg,MXC_CCM_CCOSR ); +return 0 ; +} + +static unsigned long cko1_round_rate (struct clk *clk,unsigned long rate) +{ +u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; + div = div <1 ?1 : div; + div = div >8 ?8 : div; +return parent_rate / div; +} + +static int cko1_set_parent (struct clk *clk,struct clk *parent) +{ +u32 sel, reg, fast; + +if (parent == &cpu_clk) { + sel =0 ; + fast =1 ; + }else if (parent == &pll1_sw_clk) { + sel =1 ; + fast =1 ; + }else if (parent == &pll2_sw_clk) { + sel =2 ; + fast =1 ; + }else if (parent == &pll3_sw_clk) { + sel =3 ; + fast =1 ; + }else if (parent == &apll_clk) { + sel =0 ; + fast =0 ; + }else if (parent == &pfd0_clk) { + sel =1 ; + fast =0 ; + }else if (parent == &pfd1_clk) { + sel =2 ; + fast =0 ; + }else if (parent == &pfd2_clk) { + sel =3 ; + fast =0 ; + }else if (parent == &pfd3_clk) { + sel =4 ; + fast =0 ; + }else if (parent == &pfd4_clk) { + sel =5 ; + fast =0 ; + }else if (parent == &pfd5_clk) { + sel =6 ; + fast =0 ; + }else if (parent == &pfd6_clk) { + sel =7 ; + fast =0 ; + }else if (parent == &weim_clk[0 ]) { + sel =10 ; + fast =0 ; + }else if (parent == &ahb_clk) { + sel =11 ; + fast =0 ; + }else if (parent == &ipg_clk) { + sel =12 ; + fast =0 ; + }else if (parent == &ipg_perclk) { + sel =13 ; + fast =0 ; + }else if (parent == &pfd7_clk) { + sel =15 ; + fast =0 ; + }else +return -EINVAL ; + + reg =__raw_readl (MXC_CCM_CCOSR ); + reg &= ~MXC_CCM_CCOSR_CKO1_SEL_MASK ; + reg |= sel <<MXC_CCM_CCOSR_CKO1_SEL_OFFSET ; +if (fast) + reg &= ~MXC_CCM_CCOSR_CKO1_SLOW_SEL ; +else + reg |=MXC_CCM_CCOSR_CKO1_SLOW_SEL ; +__raw_writel (reg,MXC_CCM_CCOSR ); +return 0 ; +} + +static struct clk cko1_clk = { + .parent = &pll1_sw_clk, + .get_rate = cko1_get_rate, + .enable = cko1_enable, + .disable = cko1_disable, + .set_rate = cko1_set_rate, + .round_rate = cko1_round_rate, + .set_parent = cko1_set_parent, +}; + +#define _REGISTER_CLOCK (d, n, c) \ + { \ + .dev_id = d, \ + .con_id = n, \ + .clk = &c, \Lines of this file are not shown. View the raw message.
arch/arm/mach-mx5/crm_regs-mx50.h new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Does that mean GPL v1 may be applied or not?
arch/arm/mach-mx5/mm-mx50.c
Quoted 668 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +601
-0Lines of this file are not shown. View the raw message.
arch/arm/mach-mx5/devices-mx50.h new file +26
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Did you verify that the exiting function works for mx50?
arch/arm/mach-mx5/mm-mx50.c
Quoted 27 lines
arch/arm/mach-mx5/mm-mx50.c new file +27
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Is it really necessary for soc code to map the irq controller? If yes that needs to be changed.
arch/arm/plat-mxc/devices/platform-imx-uart.c
Quoted 25 lines
arch/arm/mach-mx5/mm-mx50.c new file +4
-0Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/devices/platform-imx-uart.c +13
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
double empty line
arch/arm/plat-mxc/include/mach/common.h
Quoted 42 lines
arch/arm/plat-mxc/devices/platform-imx-uart.c +0
-0Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/include/mach/common.h +2
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
IMHO sort mx50 between mx35 and mx51.
arch/arm/plat-mxc/include/mach/iomux-mx50.h
Quoted 68 lines
arch/arm/plat-mxc/include/mach/common.h +2
-0Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/include/mach/hardware.h +1
-0Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/include/mach/iomux-mx50.h new file +38
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Shouldn't that go into iomux-v3.h?
arch/arm/plat-mxc/include/mach/irqs.h
Quoted 570 lines
arch/arm/plat-mxc/include/mach/iomux-mx50.h new file +557
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
That is if you have a kernel with support for mx25 and mx50 you end up with MXC_GPIO_IRQS being defined as (32 * 4).
arch/arm/plat-mxc/include/mach/memory.h
Quoted 18 lines
arch/arm/plat-mxc/include/mach/memory.h +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
I think introducing ARCH_MX50 would be nice and using it e.g. here.
arch/arm/plat-mxc/include/mach/mx50.h
Quoted 20 lines
arch/arm/plat-mxc/include/mach/memory.h +0
-0Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/include/mach/mx50.h new file +11
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
can you please use lower case letters for hex constants?
arch/arm/plat-mxc/include/mach/mxc.h
Quoted 315 lines
arch/arm/plat-mxc/include/mach/mx50.h new file +295
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
This has the same problem as cpu_is_mx53 that I pointed out in the review to an earlier patch of this series
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
Part of the diff is not shown here. View the raw message.
PATCH 5/6 arm: mx50: add core functions support
On Thu, Dec 09, 2010 at 09:25:35AM +0100, Uwe Kleine-K?nig wrote:
Hi Uwe,
Thanks, see below comments.
Quoted 40 lines
Hello Richard,
Quoted 37 lines · Richard Zhao
Add core definitions and memory map, clock, gpio, irq, iomux, uart device support.
Signed-off-by Richard Zhao <[email protected]>--- arch/arm/mach-mx5/Kconfig | 8 + arch/arm/mach-mx5/Makefile | 2 + arch/arm/mach-mx5/Makefile.boot | 3 + arch/arm/mach-mx5/clock-mx50.c | 3262 +++++++++++++++++++++++++ arch/arm/mach-mx5/crm_regs-mx50.h | 607 +++++ arch/arm/mach-mx5/devices-mx50.h | 26 + arch/arm/mach-mx5/mm-mx50.c | 60 + arch/arm/plat-mxc/devices/platform-imx-uart.c | 13 + arch/arm/plat-mxc/gpio.c | 14 + arch/arm/plat-mxc/include/mach/common.h | 4 + arch/arm/plat-mxc/include/mach/hardware.h | 1 + arch/arm/plat-mxc/include/mach/iomux-mx50.h | 595 +++++ arch/arm/plat-mxc/include/mach/irqs.h | 2 + arch/arm/plat-mxc/include/mach/memory.h | 3 + arch/arm/plat-mxc/include/mach/mx50.h | 306 +++ arch/arm/plat-mxc/include/mach/mxc.h | 2 + 16 files changed, 4908 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mx5/clock-mx50.c create mode 100644 arch/arm/mach-mx5/crm_regs-mx50.h create mode 100644 arch/arm/mach-mx5/devices-mx50.h create mode 100644 arch/arm/mach-mx5/mm-mx50.c create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx50.h create mode 100644 arch/arm/plat-mxc/include/mach/mx50.harch/arm/mach-mx5/Kconfig +0
-0@@ -12,6 +12,14 @@ config SOC_IMX51 select ARCH_HAS_CPUFREQ select ARCH_MX51
Quoted 9 lines
arch/arm/mach-mx5/Kconfig config SOC_IMX51 · line 22
Quoted 8 lines
arch/arm/mach-mx5/Kconfig +8
-0+config SOC_IMX50 + bool + select MXC_TZIC + select ARCH_MXC_IOMUX_V3 + select ARCH_MXC_AUDMUX_V2 + select ARCH_HAS_CPUFREQ + +only a single empty line please
Yes.
Quoted 15 lines
Quoted 9 lines
arch/arm/mach-mx5/Kconfig +0
-0comment "MX5 platforms:" config MACH_MX51_BABBAGEarch/arm/mach-mx5/Makefile +0
-0arch/arm/mach-mx5/Makefile obj-$(CONFIG_MACH_EUKREA_MBIMX51_BASEBOARD) += eukrea_mbimx51-baseboard.o · line 17
Quoted 5 lines
arch/arm/mach-mx5/Makefile +2
-0@@ -13,3 +13,5 @@ obj-$(CONFIG_MACH_EUKREA_MBIMX51_BASEBOARD) += eukrea_mbimx51-baseboard.o obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += board-cpuimx51sd.o obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o + +obj-$(CONFIG_SOC_IMX50) += mm-mx50.o clock-mx50.oPlease put that over the machine lines
Yes.
Quoted 13 lines
arch/arm/mach-mx5/Makefile.boot line 6
Quoted 12 lines
arch/arm/mach-mx5/Makefile.boot +3
-0@@ -1,3 +1,6 @@ zreladdr-$(CONFIG_SOC_IMX51) := 0x90008000 params_phys-$(CONFIG_SOC_IMX51) := 0x90000100 initrd_phys-$(CONFIG_SOC_IMX51) := 0x90800000 + zreladdr-$(CONFIG_SOC_IMX50) := 0x70008000 +params_phys-$(CONFIG_SOC_IMX50) := 0x70000100 +initrd_phys-$(CONFIG_SOC_IMX50) := 0x70800000Do you need
params_physandinitrd_phys?
If you insist on removing them, I can remove.
Quoted 87 lines
Quoted 87 lines
arch/arm/mach-mx5/clock-mx50.c new file +80
-0@@ -0,0 +1,3262 @@ +/* +* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/time.h> +#include <linux/hrtimer.h> +#include <linux/mm.h> +#include <linux/errno.h> +#include <linux/delay.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <asm/clkdev.h> +#include <asm/div64.h> +#include <mach/hardware.h> +#include <mach/common.h> +#include <mach/clock.h> + +#include "crm_regs-mx50.h" + +/* External clock values passed-in by the board code */ +static unsigned long external_high_reference, external_low_reference; +static unsigned long oscillator_reference, ckih2_reference; + +static struct clk pll1_main_clk; +static struct clk pll1_sw_clk; +static struct clk pll2_sw_clk; +static struct clk pll3_sw_clk; +static struct clk apbh_dma_clk; +static struct clk apll_clk; +static struct clk pfd0_clk; +static struct clk pfd1_clk; +static struct clk pfd2_clk; +static struct clk pfd3_clk; +static struct clk pfd4_clk; +static struct clk pfd5_clk; +static struct clk pfd6_clk; +static struct clk pfd7_clk; +static struct clk lp_apm_clk; +static struct clk weim_clk[]; +static struct clk ddr_clk; +static struct clk axi_a_clk; +static struct clk axi_b_clk; +static struct clk gpu2d_clk; + +static void __iomem *pll1_base; +static void __iomem *pll2_base; +static void __iomem *pll3_base; +void __iomem *apll_base; + +void __iomem *databahn; + +#define DDR_SYNC_MODE 0x30000 +#define SPIN_DELAY 1000000/* in nanoseconds */ +#define WAIT (exp, timeout) \ +({ \ + struct timespec nstimeofday; \ + struct timespec curtime; \ + int result = 1; \ + getnstimeofday(&nstimeofday); \ + while (!(exp)) { \ + getnstimeofday(&curtime); \ + if ((curtime.tv_nsec - nstimeofday.tv_nsec) > (timeout)) { \ + result = 0; \
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 84
Quoted 4 lines
arch/arm/mach-mx5/clock-mx50.c new file +4
-0+break ; \ + } \ + } \ + result; \this is broken. Consider
getnstimeofday(&nstimeofday)returns with nstimeofday = { .ts_sec = 42, .ts_nsec = 999999999, }. If timeout is >0 the break is never taken. And furthermore I'm sure that getnstimeofday isn't the right function for that job.
So, what do I suppose to use? udelay is not accurate here.
Quoted 29 lines
Quoted 29 lines
arch/arm/mach-mx5/clock-mx50.c new file +28
-0+}) + +#define MAX_AHB_CLK 133000000 + +static struct clk esdhc3_clk[]; + +static void __calc_pre_post_dividers (u32 div,u32 *pre,u32 *post) +{ +u32 min_pre, temp_pre, old_err, err; + +if (div >=512 ) { + *pre =8 ; + *post =64 ; + }else if (div >=8 ) { + min_pre = (div -1 ) /64 +1 ; + old_err =8 ; +for (temp_pre =8 ; temp_pre >= min_pre; temp_pre--) { + err = div % temp_pre; +if (err ==0 ) { + *pre = temp_pre; +break ; + } + err = temp_pre - err; +if (err < old_err) { + old_err = err; + *pre = temp_pre; + } + }
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 117
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +5
-0+ *post = (div + *pre -1 ) / *pre; + }else if (div <8 ) { + *pre = div; + *post =1 ; + }You seem to have copied an old version of this function. The similarity to
arch/arm/mach-mx5/clock-mx51.cmakes me wonder if you shouldn't copy the Copyright lines from there, too.
It's freescale code. clock-mx51.c is originally freescale code too.
Quoted 14 lines
arch/arm/mach-mx5/clock-mx50.c line 128
Quoted 12 lines
arch/arm/mach-mx5/clock-mx50.c new file +11
-0+} + +static int _clk_enable (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg); + reg |= MXC_CCM_CCGRx_CG_MASK << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); + +return 0 ; +}These functions are refactored in
arch/arm/mach-mx5/clock-mx51.cin the meantime, too.
Do you mean _clk_ccgr_xxx? Do I need to abstract common file clock.c, or just repeat the function?
Quoted 63 lines
Quoted 63 lines
arch/arm/mach-mx5/clock-mx50.c new file +62
-0+ +static int _clk_enable_inrun (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (clk->enable_reg); + reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); + reg |=1 << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); +return 0 ; +} + +static void _clk_disable (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg); + reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); +__raw_writel (reg, clk->enable_reg); +} + +static void _clk_disable_inwait (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg); + reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); + reg |=1 << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); +} + +static unsigned long _clk_round_rate_div (struct clk *clk, +unsigned long rate, +u32 max_div, +u32 *new_div) +{ +u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div =DIV_ROUND_UP (parent_rate, rate); +if (div > max_div) + div = max_div; +else if (div ==0 ) + div++; +if (new_div !=NULL ) + *new_div = div; + +return parent_rate / div; +} +/* +* For the 4-to-1 muxed input clock +*/ +static inline u32 _get_mux (struct clk *parent,struct clk *m0, +struct clk *m1,struct clk *m2,struct clk *m3) +{ +if (parent == m0) +return 0 ; +else if (parent == m1) +return 1 ; +else if (parent == m2) +return 2 ; +else if (parent == m3) +return 3 ; +else
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 197
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c new file +7
-0+BUG (); + +return 0 ; +} + +/* +* For the 4-to-1 muxed input clock 8-to-1 ?
Yes.
Quoted 100 lines
Quoted 100 lines
arch/arm/mach-mx5/clock-mx50.c new file +99
-0+*/ +static inline u32 _get_mux8 (struct clk *parent,struct clk *m0,struct clk *m1, +struct clk *m2,struct clk *m3,struct clk *m4, +struct clk *m5,struct clk *m6,struct clk *m7) +{ +if (parent == m0) +return 0 ; +else if (parent == m1) +return 1 ; +else if (parent == m2) +return 2 ; +else if (parent == m3) +return 3 ; +else if (parent == m4) +return 4 ; +else if (parent == m5) +return 5 ; +else if (parent == m6) +return 6 ; +else if (parent == m7) +return 7 ; +else +BUG (); + +return 0 ; +} + +static inline void __iomem *_get_pll_base (struct clk *pll) +{ +if (pll == &pll1_main_clk) +return pll1_base; +else if (pll == &pll2_sw_clk) +return pll2_base; +else if (pll == &pll3_sw_clk) +return pll3_base; +else +BUG (); + +return NULL ; +} + +static unsigned long get_high_reference_clock_rate (struct clk *clk) +{ +return external_high_reference; +} + +static unsigned long get_low_reference_clock_rate (struct clk *clk) +{ +return external_low_reference; +} + +static unsigned long get_oscillator_reference_clock_rate (struct clk *clk) +{ +return oscillator_reference; +} + +static unsigned long get_ckih2_reference_clock_rate (struct clk *clk) +{ +return ckih2_reference; +} + +/* External high frequency clock */ +static struct clk ckih_clk = { + .get_rate = get_high_reference_clock_rate, +}; + +static struct clk ckih2_clk = { + .get_rate = get_ckih2_reference_clock_rate, +}; + +static struct clk osc_clk = { + .get_rate = get_oscillator_reference_clock_rate, +}; + +/* External low frequency (32kHz) clock */ +static struct clk ckil_clk = { + .get_rate = get_low_reference_clock_rate, +}; + +static int apll_enable (struct clk *clk) +{ +__raw_writel (1 , apll_base +MXC_ANADIG_MISC_SET ); +return 0 ; +} + +static void apll_disable (struct clk *clk) +{ +__raw_writel (1 , apll_base +MXC_ANADIG_MISC_CLR ); +} + +static unsigned long apll_get_rate (struct clk *clk) +{ +return 480000000 ; +} + +static struct clk apll_clk = { + .get_rate = apll_get_rate, + .enable = apll_enable, + .disable = apll_disable,
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 303
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c new file +7
-0+}; + +static unsigned long pfd_round_rate (struct clk *clk,unsigned long rate) +{ +u32 frac; +u64 tmp; + tmp = (u64 )clk_get_rate (clk->parent) *18 ;This can overflow e.g. when parent = apll
480M * 18 = 0x202FBF000, u64 can not overflow.
Quoted 11 lines
arch/arm/mach-mx5/clock-mx50.c line 307
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +4
-0+do_div (tmp, rate); + frac = tmp; + frac = frac <18 ?18 : frac; + frac = frac >35 ?35 : frac;I remember having seen something like:
#define
CLAMP(x, low, high)((x) < (low) ? (low) : ((x) > (high) ? (high) : (x)))Maybe this is something for <
linux/kernel.h>, probably with better typing.
Yes, thanks. it's clamp(val, min, max).
Quoted 14 lines
arch/arm/mach-mx5/clock-mx50.c line 319
Quoted 13 lines
arch/arm/mach-mx5/clock-mx50.c new file +12
-0+do_div (tmp, frac); +return tmp; +} + +static int pfd_set_rate (struct clk *clk,unsigned long rate) +{ +u32 frac; +u64 tmp; + tmp = (u64 )clk_get_rate (clk->parent) *18 ; + +if (apbh_dma_clk.usecount ==0 ) + apbh_dma_clk.enable (&apbh_dma_clk);Why not just use
clk_enable(apbh_dma)?
Yes, thanks.
Quoted 9 lines
arch/arm/mach-mx5/clock-mx50.c line 327
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c new file +7
-0+do_div (tmp, rate); + frac = tmp; + frac = frac <18 ?18 : frac; + frac = frac >35 ?35 : frac; +/* clear clk frac bits */ +__raw_writel (MXC_ANADIG_PFD_FRAC_MASK << clk->enable_shift, + apll_base + (int )clk->enable_reg +8 );What is 8?
Its read/set/clear reg are three different reg. The ip is from mxs series. I can add a MXC_SET_OFFSET and MXC_CLEAR_OFFSET macro in crm-regs-mx50.h, if you need it.
Quoted 4 lines
arch/arm/mach-mx5/clock-mx50.c line 330
Quoted 3 lines
arch/arm/mach-mx5/clock-mx50.c new file +3
-0+/* set clk frac bits */ +__raw_writel (frac << clk->enable_shift, + apll_base + (int )clk->enable_reg +4 );What is 4?
same as above.
Quoted 4 lines
arch/arm/mach-mx5/clock-mx50.c line 331
Quoted 3 lines
arch/arm/mach-mx5/clock-mx50.c new file +2
-0+ + tmp = (u64 )clk_get_rate (clk->parent) *18 ;overflow?
why?
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c line 336
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +4
-0+do_div (tmp, frac); + +if (apbh_dma_clk.usecount ==0 ) + apbh_dma_clk.disable (&apbh_dma_clk);... then you can balance here with an
clk_disablethat just does the right thing.
correct
Quoted 11 lines
arch/arm/mach-mx5/clock-mx50.c line 345
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +9
-0+return 0 ; +} + +static int pfd_enable (struct clk *clk) +{ +int index; + +if (apbh_dma_clk.usecount ==0 ) + apbh_dma_clk.enable (&apbh_dma_clk);ditto
correct
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c line 350
Quoted 6 lines
arch/arm/mach-mx5/clock-mx50.c new file +5
-0+ index =_get_mux8 (clk, &pfd0_clk, &pfd1_clk, &pfd2_clk, &pfd3_clk, + &pfd4_clk, &pfd5_clk, &pfd6_clk, &pfd7_clk); +__raw_writel (1 << (index +MXC_ANADIG_PFD_DIS_OFFSET ), + apll_base +MXC_ANADIG_PLLCTRL_CLR ); +/* clear clk gate bit */ Having an empty line before comments improves readability.
ok
Quoted 109 lines
Quoted 109 lines
arch/arm/mach-mx5/clock-mx50.c new file +108
-0+__raw_writel ((1 << (clk->enable_shift +7 )), + apll_base + (int )clk->enable_reg +8 ); + +/* check lock bit */ +if (!WAIT (__raw_readl (apll_base +MXC_ANADIG_PLLCTRL ) + &MXC_ANADIG_APLL_LOCK ,50000 )) { +__raw_writel (MXC_ANADIG_APLL_FORCE_LOCK , + apll_base +MXC_ANADIG_PLLCTRL_CLR ); +__raw_writel (MXC_ANADIG_APLL_FORCE_LOCK , + apll_base +MXC_ANADIG_PLLCTRL_SET ); +if (!WAIT (__raw_readl (apll_base +MXC_ANADIG_PLLCTRL ) + &MXC_ANADIG_APLL_LOCK ,SPIN_DELAY )) +panic ("pfd_enable failed!\n" ); + } +if (apbh_dma_clk.usecount ==0 ) + apbh_dma_clk.disable (&apbh_dma_clk); +return 0 ; +} + +static void pfd_disable (struct clk *clk) +{ +int index; + +if (apbh_dma_clk.usecount ==0 ) + apbh_dma_clk.enable (&apbh_dma_clk); + index =_get_mux8 (clk, &pfd0_clk, &pfd1_clk, &pfd2_clk, &pfd3_clk, + &pfd4_clk, &pfd5_clk, &pfd6_clk, &pfd7_clk); +/* set clk gate bit */ +__raw_writel ((1 << (clk->enable_shift +7 )), + apll_base + (int )clk->enable_reg +4 ); +__raw_writel (1 << (index +MXC_ANADIG_PFD_DIS_OFFSET ), + apll_base +MXC_ANADIG_PLLCTRL_SET ); +if (apbh_dma_clk.usecount ==0 ) + apbh_dma_clk.disable (&apbh_dma_clk); +} + +static struct clk pfd0_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC0 , + .enable_shift =MXC_ANADIG_PFD0_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd1_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC0 , + .enable_shift =MXC_ANADIG_PFD1_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd2_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC0 , + .enable_shift =MXC_ANADIG_PFD2_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd3_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC0 , + .enable_shift =MXC_ANADIG_PFD3_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd4_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC1 , + .enable_shift =MXC_ANADIG_PFD4_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd5_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC1 , + .enable_shift =MXC_ANADIG_PFD5_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd6_clk = { + .parent = &apll_clk, + .enable_reg = (void *)MXC_ANADIG_FRAC1 , + .enable_shift =MXC_ANADIG_PFD6_FRAC_OFFSET , + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +}; + +static struct clk pfd7_clk = { + .parent = &apll_clk,
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 465
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c new file +7
-0+ .enable_reg = (void *)MXC_ANADIG_FRAC1, + .enable_shift = MXC_ANADIG_PFD7_FRAC_OFFSET, + .set_rate = pfd_set_rate, + .round_rate = pfd_round_rate, + .enable = pfd_enable, + .disable = pfd_disable, +};Maybe define a macro to simplify these 8 definitions?
ok
Quoted 497 lines
Quoted 497 lines
arch/arm/mach-mx5/clock-mx50.c new file +497
-0+ +static unsigned long _clk_pll_get_rate (struct clk *clk) +{ +long mfi, mfn, mfd, pdf, ref_clk, mfn_abs; +unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl; +void __iomem *pllbase; +s64 temp; + + pllbase =_get_pll_base (clk); + + dp_ctl =__raw_readl (pllbase +MXC_PLL_DP_CTL ); + pll_hfsm = dp_ctl &MXC_PLL_DP_CTL_HFSM ; + dbl = dp_ctl &MXC_PLL_DP_CTL_DPDCK0_2_EN ; + +if (pll_hfsm ==0 ) { + dp_op =__raw_readl (pllbase +MXC_PLL_DP_OP ); + dp_mfd =__raw_readl (pllbase +MXC_PLL_DP_MFD ); + dp_mfn =__raw_readl (pllbase +MXC_PLL_DP_MFN ); + }else { + dp_op =__raw_readl (pllbase +MXC_PLL_DP_HFS_OP ); + dp_mfd =__raw_readl (pllbase +MXC_PLL_DP_HFS_MFD ); + dp_mfn =__raw_readl (pllbase +MXC_PLL_DP_HFS_MFN ); + } + pdf = dp_op &MXC_PLL_DP_OP_PDF_MASK ; + mfi = (dp_op &MXC_PLL_DP_OP_MFI_MASK ) >>MXC_PLL_DP_OP_MFI_OFFSET ; + mfi = (mfi <=5 ) ?5 : mfi; + mfd = dp_mfd &MXC_PLL_DP_MFD_MASK ; + mfn = mfn_abs = dp_mfn &MXC_PLL_DP_MFN_MASK ; +/* Sign extend to 32-bits */ +if (mfn >=0x04000000 ) { + mfn |=0xFC000000 ; + mfn_abs = -mfn; + } + + ref_clk =2 *clk_get_rate (clk->parent); +if (dbl !=0 ) + ref_clk *=2 ; + + ref_clk /= (pdf +1 ); + temp = (u64 ) ref_clk * mfn_abs; +do_div (temp, mfd +1 ); +if (mfn <0 ) + temp = -temp; + temp = (ref_clk * mfi) + temp; + +return temp; +} + +static int _clk_pll_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, reg1; +void __iomem *pllbase; + +long mfi, pdf, mfn, mfd =999999 ; +s64 temp64; +unsigned long quad_parent_rate; +unsigned long pll_hfsm, dp_ctl; + + pllbase =_get_pll_base (clk); + + quad_parent_rate =4 *clk_get_rate (clk->parent); + pdf = mfi =-1 ; +while (++pdf <16 && mfi <5 ) + mfi = rate * (pdf+1 ) / quad_parent_rate; +if (mfi >15 ) +return -1 ; + pdf--; + + temp64 = rate*(pdf+1 ) - quad_parent_rate*mfi; +do_div (temp64, quad_parent_rate/1000000 ); + mfn = (long )temp64; + + dp_ctl =__raw_readl (pllbase +MXC_PLL_DP_CTL ); +/* use dpdck0_2 */ +__raw_writel (dp_ctl |0x1000L , pllbase +MXC_PLL_DP_CTL ); + pll_hfsm = dp_ctl &MXC_PLL_DP_CTL_HFSM ; +if (pll_hfsm ==0 ) { + reg = mfi<<4 | pdf; +__raw_writel (reg, pllbase +MXC_PLL_DP_OP ); +__raw_writel (mfd, pllbase +MXC_PLL_DP_MFD ); +__raw_writel (mfn, pllbase +MXC_PLL_DP_MFN ); + }else { + reg = mfi<<4 | pdf; +__raw_writel (reg, pllbase +MXC_PLL_DP_HFS_OP ); +__raw_writel (mfd, pllbase +MXC_PLL_DP_HFS_MFD ); +__raw_writel (mfn, pllbase +MXC_PLL_DP_HFS_MFN ); + } +/* If auto restart is disabled, restart the PLL and +* wait for it to lock. +*/ + reg =__raw_readl (pllbase +MXC_PLL_DP_CTL ); +if (reg &MXC_PLL_DP_CTL_UPEN ) { + reg =__raw_readl (pllbase +MXC_PLL_DP_CONFIG ); +if (!(reg &MXC_PLL_DP_CONFIG_AREN )) { + reg1 =__raw_readl (pllbase +MXC_PLL_DP_CTL ); + reg1 |=MXC_PLL_DP_CTL_RST ; +__raw_writel (reg1, pllbase +MXC_PLL_DP_CTL ); + } +/* Wait for lock */ +if (!WAIT (__raw_readl (pllbase +MXC_PLL_DP_CTL ) + &MXC_PLL_DP_CTL_LRF ,SPIN_DELAY )) +panic ("pll_set_rate: pll relock failed\n" ); + } +return 0 ; +} + +static int _clk_pll_enable (struct clk *clk) +{ +u32 reg; +void __iomem *pllbase; + + pllbase =_get_pll_base (clk); + reg =__raw_readl (pllbase +MXC_PLL_DP_CTL ); + +if (reg &MXC_PLL_DP_CTL_UPEN ) +return 0 ; + + reg |=MXC_PLL_DP_CTL_UPEN ; +__raw_writel (reg, pllbase +MXC_PLL_DP_CTL ); + +/* Wait for lock */ +if (!WAIT (__raw_readl (pllbase +MXC_PLL_DP_CTL ) &MXC_PLL_DP_CTL_LRF , +SPIN_DELAY )) +panic ("pll relock failed\n" ); +return 0 ; +} + +static void _clk_pll_disable (struct clk *clk) +{ +u32 reg; +void __iomem *pllbase; + + pllbase =_get_pll_base (clk); + reg =__raw_readl (pllbase +MXC_PLL_DP_CTL ) & ~MXC_PLL_DP_CTL_UPEN ; +__raw_writel (reg, pllbase +MXC_PLL_DP_CTL ); +} + +static struct clk pll1_main_clk = { + .parent = &osc_clk, + .get_rate = _clk_pll_get_rate, + .enable = _clk_pll_enable, + .disable = _clk_pll_disable, +}; + +static int _clk_pll1_sw_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CCSR ); + +if (parent == &pll1_main_clk) { + reg &= ~MXC_CCM_CCSR_PLL1_SW_CLK_SEL ; +__raw_writel (reg,MXC_CCM_CCSR ); +/* Set the step_clk parent to be lp_apm, to save power. */ + mux =_get_mux (&lp_apm_clk, &lp_apm_clk,NULL , &pll2_sw_clk, + &pll3_sw_clk); + reg =__raw_readl (MXC_CCM_CCSR ); + reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK ) | + (mux <<MXC_CCM_CCSR_STEP_SEL_OFFSET ); + }else { +if (parent == &lp_apm_clk) { + mux =_get_mux (parent, &lp_apm_clk,NULL , &pll2_sw_clk, + &pll3_sw_clk); + reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK ) | + (mux <<MXC_CCM_CCSR_STEP_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CCSR ); + reg =__raw_readl (MXC_CCM_CCSR ); + reg |=MXC_CCM_CCSR_PLL1_SW_CLK_SEL ; + }else { + mux =_get_mux (parent, &lp_apm_clk,NULL , &pll2_sw_clk, + &pll3_sw_clk); + reg = (reg & ~MXC_CCM_CCSR_STEP_SEL_MASK ) | + (mux <<MXC_CCM_CCSR_STEP_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CCSR ); + reg =__raw_readl (MXC_CCM_CCSR ); + reg |=MXC_CCM_CCSR_PLL1_SW_CLK_SEL ; + + } + } +__raw_writel (reg,MXC_CCM_CCSR ); + +return 0 ; +} + +static unsigned long _clk_pll1_sw_get_rate (struct clk *clk) +{ +u32 reg, div; + div =1 ; + reg =__raw_readl (MXC_CCM_CCSR ); + +if (clk->parent == &pll2_sw_clk) { + div = ((reg &MXC_CCM_CCSR_PLL2_PODF_MASK ) >> +MXC_CCM_CCSR_PLL2_PODF_OFFSET ) +1 ; + }else if (clk->parent == &pll3_sw_clk) { + div = ((reg &MXC_CCM_CCSR_PLL3_PODF_MASK ) >> +MXC_CCM_CCSR_PLL3_PODF_OFFSET ) +1 ; + } +return clk_get_rate (clk->parent) / div; +} + +/* pll1 switch clock */ +static struct clk pll1_sw_clk = { + .parent = &pll1_main_clk, + .set_parent = _clk_pll1_sw_set_parent, + .get_rate = _clk_pll1_sw_get_rate, +}; + +static int _clk_pll2_sw_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CCSR ); + +if (parent == &pll2_sw_clk) { + reg &= ~MXC_CCM_CCSR_PLL2_SW_CLK_SEL ; + }else { + reg = (reg & ~MXC_CCM_CCSR_PLL2_SW_CLK_SEL ); + reg |=MXC_CCM_CCSR_PLL2_SW_CLK_SEL ; + } +__raw_writel (reg,MXC_CCM_CCSR ); +return 0 ; +} + +/* same as pll2_main_clk. These two clocks should always be the same */ +static struct clk pll2_sw_clk = { + .parent = &osc_clk, + .get_rate = _clk_pll_get_rate, + .enable = _clk_pll_enable, + .disable = _clk_pll_disable, + .set_rate = _clk_pll_set_rate, + .set_parent = _clk_pll2_sw_set_parent, +}; + +/* same as pll3_main_clk. These two clocks should always be the same */ +static struct clk pll3_sw_clk = { + .parent = &osc_clk, + .set_rate = _clk_pll_set_rate, + .get_rate = _clk_pll_get_rate, + .enable = _clk_pll_enable, + .disable = _clk_pll_disable, +}; + +static int _clk_lp_apm_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + +if (parent == &osc_clk) + reg =__raw_readl (MXC_CCM_CCSR ) & ~MXC_CCM_CCSR_LP_APM_SEL ; +else if (parent == &apll_clk) + reg =__raw_readl (MXC_CCM_CCSR ) |MXC_CCM_CCSR_LP_APM_SEL ; +else +return -EINVAL ; + +__raw_writel (reg,MXC_CCM_CCSR ); + +return 0 ; +} + +static struct clk lp_apm_clk = { + .parent = &osc_clk, + .set_parent = _clk_lp_apm_set_parent, +}; + +static unsigned long _clk_arm_get_rate (struct clk *clk) +{ +u32 cacrr, div; + + cacrr =__raw_readl (MXC_CCM_CACRR ); + div = (cacrr &MXC_CCM_CACRR_ARM_PODF_MASK ) +1 ; +return clk_get_rate (clk->parent) / div; +} + +static unsigned long _clk_cpu_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 cpu_podf; +unsigned long parent_rate; + + parent_rate =clk_get_rate (clk->parent); + cpu_podf = parent_rate / rate; + cpu_podf = cpu_podf >8 ?8 : cpu_podf; + cpu_podf = cpu_podf <1 ?1 : cpu_podf; + +return parent_rate / cpu_podf; +} + +static int _clk_cpu_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, cpu_podf; +unsigned long parent_rate; + + rate =_clk_cpu_round_rate (clk, rate); + parent_rate =clk_get_rate (clk->parent); + cpu_podf = parent_rate / rate -1 ; + + reg =__raw_readl (MXC_CCM_CACRR ); + reg &= ~MXC_CCM_CACRR_ARM_PODF_MASK ; + reg |= cpu_podf <<MXC_CCM_CACRR_ARM_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_CACRR ); + +return 0 ; +} + +static struct clk cpu_clk = { + .parent = &pll1_sw_clk, + .get_rate = _clk_arm_get_rate, + .set_rate = _clk_cpu_set_rate, + .round_rate = _clk_cpu_round_rate, +}; + +static int _clk_main_bus_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, + &lp_apm_clk); + reg =__raw_readl (MXC_CCM_CBCDR ) & ~MXC_CCM_CBCDR_PERIPH_CLK_SEL_MASK ; + reg |= (mux <<MXC_CCM_CBCDR_PERIPH_CLK_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CBCDR ); + +return 0 ; +} + +static struct clk main_bus_clk = { + .parent = &pll2_sw_clk, + .set_parent = _clk_main_bus_set_parent, +}; + +static unsigned long _clk_axi_a_get_rate (struct clk *clk) +{ +u32 reg, div; + + reg =__raw_readl (MXC_CCM_CBCDR ); + div = ((reg &MXC_CCM_CBCDR_AXI_A_PODF_MASK ) >> +MXC_CCM_CBCDR_AXI_A_PODF_OFFSET ) +1 ; +return clk_get_rate (clk->parent) / div; +} + +static int _clk_axi_a_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; +if (div ==0 ) + div++; +if (((parent_rate / div) != rate) || (div >8 )) +return -EINVAL ; + + reg =__raw_readl (MXC_CCM_CBCDR ); + reg &= ~MXC_CCM_CBCDR_AXI_A_PODF_MASK ; + reg |= (div -1 ) <<MXC_CCM_CBCDR_AXI_A_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_CBCDR ); + +if (!WAIT (!(__raw_readl (MXC_CCM_CDHIPR ) + &MXC_CCM_CDHIPR_AXI_A_PODF_BUSY ),SPIN_DELAY )) +panic ("pll _clk_axi_a_set_rate failed\n" ); + +return 0 ; +} + +static unsigned long _clk_axi_a_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; + +/* Make sure rate is not greater than the maximum value for the clock. +* Also prevent a div of 0. +*/ + +if (div >8 ) + div =8 ; +else if (div ==0 ) + div++; + +return parent_rate / div; +} + + +static struct clk axi_a_clk = { + .parent = &main_bus_clk, + .get_rate = _clk_axi_a_get_rate, + .set_rate = _clk_axi_a_set_rate, + .round_rate = _clk_axi_a_round_rate, +}; + +static unsigned long _clk_axi_b_get_rate (struct clk *clk) +{ +u32 reg, div; + + reg =__raw_readl (MXC_CCM_CBCDR ); + div = ((reg &MXC_CCM_CBCDR_AXI_B_PODF_MASK ) >> +MXC_CCM_CBCDR_AXI_B_PODF_OFFSET ) +1 ; +return clk_get_rate (clk->parent) / div; +} + +static int _clk_axi_b_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; +if (div ==0 ) + div++; +if (((parent_rate / div) != rate) || (div >8 )) +return -EINVAL ; + + reg =__raw_readl (MXC_CCM_CBCDR ); + reg &= ~MXC_CCM_CBCDR_AXI_B_PODF_MASK ; + reg |= (div -1 ) <<MXC_CCM_CBCDR_AXI_B_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_CBCDR ); + +if (!WAIT (!(__raw_readl (MXC_CCM_CDHIPR ) + &MXC_CCM_CDHIPR_AXI_B_PODF_BUSY ),SPIN_DELAY )) +panic ("_clk_axi_b_set_rate failed\n" ); + +return 0 ; +} + +static unsigned long _clk_axi_b_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; + +/* Make sure rate is not greater than the maximum value for the clock. +* Also prevent a div of 0. +*/ + +if (div >8 ) + div =8 ; +else if (div ==0 ) + div++; + +return parent_rate / div; +} + + +static struct clk axi_b_clk = { + .parent = &main_bus_clk, + .get_rate = _clk_axi_b_get_rate, + .set_rate = _clk_axi_b_set_rate, + .round_rate = _clk_axi_b_round_rate, +}; + +static unsigned long _clk_ahb_get_rate (struct clk *clk) +{ +u32 reg, div; + + reg =__raw_readl (MXC_CCM_CBCDR ); + div = ((reg &MXC_CCM_CBCDR_AHB_PODF_MASK ) >> +MXC_CCM_CBCDR_AHB_PODF_OFFSET ) +1 ; +return clk_get_rate (clk->parent) / div; +} + + +static int _clk_ahb_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; +if (div ==0 ) + div++; +if (((parent_rate / div) != rate) || (div >8 )) +return -EINVAL ; + + reg =__raw_readl (MXC_CCM_CBCDR ); + reg &= ~MXC_CCM_CBCDR_AHB_PODF_MASK ; + reg |= (div -1 ) <<MXC_CCM_CBCDR_AHB_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_CBCDR ); + +if (!WAIT (!(__raw_readl (MXC_CCM_CDHIPR ) &MXC_CCM_CDHIPR_AHB_PODF_BUSY ), +SPIN_DELAY )) +panic ("_clk_ahb_set_rate failed\n" ); + +return 0 ; +} + +static unsigned long _clk_ahb_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; + +/* Make sure rate is not greater than the maximum value for the clock. +* Also prevent a div of 0. +*/ +if (div ==0 ) + div++;
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 969
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c new file +7
-0+if (parent_rate / div >MAX_AHB_CLK ) + div++; + +if (div >8 ) + div =8 ; + +return parent_rate / div;This can return something >
MAX_AHB_CLK, is this intended?
No, it's a bug. Thanks.
Quoted 26 lines
Quoted 26 lines
arch/arm/mach-mx5/clock-mx50.c new file +25
-0+} + + +static struct clk ahb_clk = { + .parent = &main_bus_clk, + .get_rate = _clk_ahb_get_rate, + .set_rate = _clk_ahb_set_rate, + .round_rate = _clk_ahb_round_rate, +}; + +static int _clk_max_enable (struct clk *clk) +{ +u32 reg; + +_clk_enable (clk); + +/* Handshake with MAX when LPM is entered. */ + reg =__raw_readl (MXC_CCM_CLPCR ); + reg &= ~MXC_CCM_CLPCR_BYPASS_MAX_LPM_HS ; +__raw_writel (reg,MXC_CCM_CLPCR ); + +return 0 ; +} + +
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 1001
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c new file +7
-0+static void _clk_max_disable (struct clk *clk) +{ +u32 reg; + +_clk_disable_inwait (clk); + +/* No Handshake with MAX when LPM is entered as its disabled. */ s/H/h/
ok
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c line 1005
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +4
-0+ reg =__raw_readl (MXC_CCM_CLPCR ); + reg |=MXC_CCM_CLPCR_BYPASS_MAX_LPM_HS ; +__raw_writel (reg,MXC_CCM_CLPCR ); +}When enabling you do
enable clk
enable handshake
Quoted 6 lines
; when disabling you do
disable clk
disable handshake. This is not symmetric. Intended?
Yes, disable handshake is ahead of disable clk is better.
Quoted 223 lines
Quoted 223 lines
arch/arm/mach-mx5/clock-mx50.c new file +222
-0+static struct clk ahb_max_clk = { + .parent = &ahb_clk, + .enable_reg =MXC_CCM_CCGR0 , + .enable_shift = MXC_CCM_CCGRx_CG14_OFFSET, + .enable = _clk_max_enable, + .disable = _clk_max_disable, +}; + +static struct clk ahbmux1_clk = { + .id =0 , + .parent = &ahb_clk, + .secondary = &ahb_max_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR0 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .disable = _clk_disable_inwait, +}; + +static unsigned long _clk_ipg_get_rate (struct clk *clk) +{ +u32 reg, div; + + reg =__raw_readl (MXC_CCM_CBCDR ); + div = ((reg &MXC_CCM_CBCDR_IPG_PODF_MASK ) >> +MXC_CCM_CBCDR_IPG_PODF_OFFSET ) +1 ; +return clk_get_rate (clk->parent) / div; +} + +static struct clk ipg_clk = { + .parent = &ahb_clk, + .get_rate = _clk_ipg_get_rate, +}; + +static unsigned long _clk_ipg_per_get_rate (struct clk *clk) +{ +u32 reg, prediv1, prediv2, podf; + +if (clk->parent == &main_bus_clk || clk->parent == &lp_apm_clk) { +/* the main_bus_clk is the one before the DVFS engine */ + reg =__raw_readl (MXC_CCM_CBCDR ); + prediv1 = ((reg &MXC_CCM_CBCDR_PERCLK_PRED1_MASK ) >> +MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET ) +1 ; + prediv2 = ((reg &MXC_CCM_CBCDR_PERCLK_PRED2_MASK ) >> +MXC_CCM_CBCDR_PERCLK_PRED2_OFFSET ) +1 ; + podf = ((reg &MXC_CCM_CBCDR_PERCLK_PODF_MASK ) >> +MXC_CCM_CBCDR_PERCLK_PODF_OFFSET ) +1 ; +return clk_get_rate (clk->parent) / (prediv1 * prediv2 * podf); + }else if (clk->parent == &ipg_clk) { +return clk_get_rate (&ipg_clk); + } +BUG (); +return 0 ; +} + +static int _clk_ipg_per_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CBCMR ); + mux =_get_mux (parent, &main_bus_clk, &lp_apm_clk, &ipg_clk,NULL ); +if (mux ==2 ) { + reg |=MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL ; + }else { + reg &= ~MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL ; +if (mux ==0 ) + reg &= ~MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL ; +else + reg |=MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL ; + } +__raw_writel (reg,MXC_CCM_CBCMR ); + +return 0 ; +} + +static struct clk ipg_perclk = { + .parent = &lp_apm_clk, + .get_rate = _clk_ipg_per_get_rate, + .set_parent = _clk_ipg_per_set_parent, +}; + +static struct clk ipmux1_clk = { + .enable_reg =MXC_CCM_CCGR5 , + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, +}; + +static struct clk ipmux2_clk = { + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG0_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, +}; + +static int _clk_sys_clk_enable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CLK_SYS ); + reg &= ~(MXC_CCM_CLK_SYS_SYS_XTAL_CLKGATE_MASK | +MXC_CCM_CLK_SYS_SYS_PLL_CLKGATE_MASK ); +if (__raw_readl (MXC_CCM_CLKSEQ_BYPASS ) &0x1 ) + reg |=MXC_CCM_CLK_SYS_SYS_PLL_CLKGATE_MASK ; +else + reg |=MXC_CCM_CLK_SYS_SYS_XTAL_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_CLK_SYS ); +return 0 ; +} + +static void _clk_sys_clk_disable (struct clk *clk) +{ +u32 reg, reg1; + + reg1 = (__raw_readl (databahn +DATABAHN_CTL_REG55 )) + &DDR_SYNC_MODE ; + reg =__raw_readl (MXC_CCM_CLK_SYS ); + reg &= ~(MXC_CCM_CLK_SYS_SYS_XTAL_CLKGATE_MASK | +MXC_CCM_CLK_SYS_SYS_PLL_CLKGATE_MASK ); +if (__raw_readl (MXC_CCM_CLKSEQ_BYPASS ) &0x1 ) + reg |=1 <<MXC_CCM_CLK_SYS_SYS_PLL_CLKGATE_OFFSET ; +else { +/* If DDR is sourced from SYS_CLK (in Sync mode), we cannot +* gate its clock when ARM is in wait if the DDR is not in +* self refresh. +*/ +if (reg1 ==DDR_SYNC_MODE ) + reg |=3 <<MXC_CCM_CLK_SYS_SYS_XTAL_CLKGATE_OFFSET ; +else + reg |=1 <<MXC_CCM_CLK_SYS_SYS_XTAL_CLKGATE_OFFSET ; + } +__raw_writel (reg,MXC_CCM_CLK_SYS ); +} + +static struct clk sys_clk = { + .enable = _clk_sys_clk_enable, + .disable = _clk_sys_clk_disable, +}; + + +static int _clk_weim_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CBCDR ); +if (parent == &ahb_clk) + reg |=MXC_CCM_CBCDR_WEIM_CLK_SEL ; +else if (parent == &main_bus_clk) + reg &= ~MXC_CCM_CBCDR_WEIM_CLK_SEL ; +else +BUG (); +__raw_writel (reg,MXC_CCM_CBCDR ); + +return 0 ; +} + +static int _clk_weim_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; +if (div ==0 ) + div++; +if (((parent_rate / div) != rate) || (div >8 )) +return -EINVAL ; + reg =__raw_readl (MXC_CCM_CBCDR ); + reg &= ~MXC_CCM_CBCDR_WEIM_PODF_MASK ; + reg |= (div -1 ) <<MXC_CCM_CBCDR_WEIM_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_CBCDR ); +if (!WAIT (!(__raw_readl (MXC_CCM_CDHIPR ) &MXC_CCM_CDHIPR_WEIM_PODF_BUSY ) + ,SPIN_DELAY )) +panic ("_clk_emi_slow_set_rate failed\n" ); + +return 0 ; +} + +static unsigned long _clk_weim_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; +if (div >8 ) + div =8 ; +else if (div ==0 ) + div++; +return parent_rate / div; +} + +static struct clk weim_clk[] = { + { + .parent = &main_bus_clk, + .set_parent = _clk_weim_set_parent, + .set_rate = _clk_weim_set_rate, + .round_rate = _clk_weim_round_rate, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR5 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .disable = _clk_disable_inwait, + .secondary = &weim_clk[1 ], + }, + { + .parent = &ipg_clk, + .secondary = &sys_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR5 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, + .disable = _clk_disable_inwait, + } +}; + +static int _clk_ocram_enable (struct clk *clk) +{ +return 0 ; +} + +static void _clk_ocram_disable (struct clk *clk) +{ +} + +static struct clk ocram_clk = {
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 1234
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +5
-0+ .parent = &sys_clk, + .enable_reg = MXC_CCM_CCGR6, + .enable_shift = MXC_CCM_CCGRx_CG1_OFFSET, + .enable = _clk_ocram_enable, + .disable = _clk_ocram_disable,This looks fishy. .enable_reg and .enable_shift is unused because
_clk_ocram_enableand_clk_ocram_disableare empty.
I'll add implementation.
Quoted 44 lines
Quoted 44 lines
arch/arm/mach-mx5/clock-mx50.c new file +43
-0+}; + +static struct clk aips_tz1_clk = { + .parent = &ahb_clk, + .secondary = &ahb_max_clk, + .enable_reg =MXC_CCM_CCGR0 , + .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable_inwait, +}; + +static struct clk aips_tz2_clk = { + .parent = &ahb_clk, + .secondary = &ahb_max_clk, + .enable_reg =MXC_CCM_CCGR0 , + .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable_inwait, +}; + +static struct clk gpc_dvfs_clk = { + .enable_reg =MXC_CCM_CCGR5 , + .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, +}; + +static int _clk_sdma_enable (struct clk *clk) +{ +u32 reg; + +_clk_enable (clk); + +/* Handshake with SDMA when LPM is entered. */ + reg =__raw_readl (MXC_CCM_CLPCR ); + reg &= ~MXC_CCM_CLPCR_BYPASS_SDMA_LPM_HS ; +__raw_writel (reg,MXC_CCM_CLPCR ); + +return 0 ; +} + +static void _clk_sdma_disable (struct clk *clk) +{
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 1284
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c new file +7
-0+u32 reg; + +_clk_disable (clk); +/* No handshake with SDMA as its not enabled. */ + reg =__raw_readl (MXC_CCM_CLPCR ); + reg |=MXC_CCM_CLPCR_BYPASS_SDMA_LPM_HS ; +__raw_writel (reg,MXC_CCM_CLPCR );ditto
ok
Quoted 153 lines
Quoted 153 lines
arch/arm/mach-mx5/clock-mx50.c new file +152
-0+} + + +static struct clk sdma_clk[] = { + { + .parent = &ahb_clk, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG15_OFFSET, + .enable = _clk_sdma_enable, + .disable = _clk_sdma_disable, + }, + { + .parent = &ipg_clk, + .secondary = &ddr_clk, + }, +}; + +static struct clk spba_clk = { + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR5 , + .enable_shift = MXC_CCM_CCGRx_CG0_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, +}; + +static unsigned long _clk_uart_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_CSCDR1 ); + prediv = ((reg &MXC_CCM_CSCDR1_UART_CLK_PRED_MASK ) >> +MXC_CCM_CSCDR1_UART_CLK_PRED_OFFSET ) +1 ; + podf = ((reg &MXC_CCM_CSCDR1_UART_CLK_PODF_MASK ) >> +MXC_CCM_CSCDR1_UART_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent)/(prediv * podf) ; +} + +static int _clk_uart_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, + &lp_apm_clk); + reg =__raw_readl (MXC_CCM_CSCMR1 ) & ~MXC_CCM_CSCMR1_UART_CLK_SEL_MASK ; + reg |= mux <<MXC_CCM_CSCMR1_UART_CLK_SEL_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk uart_main_clk = { + .parent = &pll2_sw_clk, + .get_rate = _clk_uart_get_rate, + .set_parent = _clk_uart_set_parent, +}; + +static struct clk uart1_clk[] = { + { + .id =0 , + .parent = &uart_main_clk, + .secondary = &uart1_clk[1 ], + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG4_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG3_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, +}; + +static struct clk uart2_clk[] = { + { + .id =1 , + .parent = &uart_main_clk, + .secondary = &uart2_clk[1 ], + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =1 , + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, +}; + +static struct clk uart3_clk[] = { + { + .id =2 , + .parent = &uart_main_clk, + .secondary = &uart3_clk[1 ], + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =2 , + .parent = &ipg_clk, + .secondary = &spba_clk, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, +}; + +static struct clk uart4_clk[] = { + { + .id =3 , + .parent = &uart_main_clk, + .secondary = &uart4_clk[1 ], + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =3 , + .parent = &ipg_clk, + .secondary = &spba_clk, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG4_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, +}; + +static struct clk uart5_clk[] = { + { + .id =4 , + .parent = &uart_main_clk, + .secondary = &uart5_clk[1 ], + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =4 , + .parent = &ipg_clk,
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 1443
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c new file +7
-0+ .secondary = &spba_clk, + .enable_reg = MXC_CCM_CCGR7, + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, +};macro to define the uart clocks
ok
Quoted 66 lines
Quoted 66 lines
arch/arm/mach-mx5/clock-mx50.c new file +65
-0+ +static struct clk gpt_clk[] = { + { + .parent = &ipg_perclk, + .id =0 , + .secondary = &gpt_clk[1 ], + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG10_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ckil_clk, + }, +}; + +static struct clk pwm1_clk[] = { + { + .parent = &ipg_perclk, + .id =0 , + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + .secondary = &pwm1_clk[1 ], + }, + { + .id =0 , + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, + .enable = _clk_enable_inrun,/*Active only when ARM is running. */ + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ckil_clk, + }, +}; + +static struct clk pwm2_clk[] = { + { + .parent = &ipg_perclk, + .id =1 , + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + .secondary = &pwm2_clk[1 ], + }, + { + .id =1 , + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, + .enable = _clk_enable_inrun,/*Active only when ARM is running. */
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 1515
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c new file +7
-0+ .disable = _clk_disable, + }, + { + .id = 1, + .parent = &ckil_clk, + }, +};macro?
ok
Quoted 748 lines
Quoted 748 lines
arch/arm/mach-mx5/clock-mx50.c new file +747
-0+ +static struct clk i2c_clk[] = { + { + .id =0 , + .parent = &ipg_perclk, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =1 , + .parent = &ipg_perclk, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG10_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =2 , + .parent = &ipg_perclk, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG11_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, +}; + +static unsigned long _clk_cspi_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_CSCDR2 ); + prediv = ((reg &MXC_CCM_CSCDR2_CSPI_CLK_PRED_MASK ) >> +MXC_CCM_CSCDR2_CSPI_CLK_PRED_OFFSET ) +1 ; +if (prediv ==1 ) +BUG (); + podf = ((reg &MXC_CCM_CSCDR2_CSPI_CLK_PODF_MASK ) >> +MXC_CCM_CSCDR2_CSPI_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent) / (prediv * podf); +} + +static int _clk_cspi_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, + &lp_apm_clk); + reg =__raw_readl (MXC_CCM_CSCMR1 ) & ~MXC_CCM_CSCMR1_CSPI_CLK_SEL_MASK ; + reg |= mux <<MXC_CCM_CSCMR1_CSPI_CLK_SEL_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk cspi_main_clk = { + .parent = &pll3_sw_clk, + .get_rate = _clk_cspi_get_rate, + .set_parent = _clk_cspi_set_parent, +}; + +static struct clk cspi1_clk[] = { + { + .id =0 , + .parent = &cspi_main_clk, + .secondary = &cspi1_clk[1 ], + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG10_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ipg_clk, + .secondary = &spba_clk, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, + .enable = _clk_enable_inrun,/*Active only when ARM is running. */ + .disable = _clk_disable, + }, +}; + +static struct clk cspi2_clk[] = { + { + .id =1 , + .parent = &cspi_main_clk, + .secondary = &cspi2_clk[1 ], + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =1 , + .parent = &ipg_clk, + .secondary = &aips_tz2_clk, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG11_OFFSET, + .enable = _clk_enable_inrun,/*Active only when ARM is running. */ + .disable = _clk_disable, + }, +}; + +static struct clk cspi3_clk = { + .id =2 , + .parent = &ipg_clk, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + .secondary = &aips_tz2_clk, +}; + +static int _clk_ssi_lp_apm_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CSCMR1 ) & ~MXC_CCM_CSCMR1_SSI_APM_CLK_SEL ; +if (parent == &lp_apm_clk) + reg |=MXC_CCM_CSCMR1_SSI_APM_CLK_SEL ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk ssi_lp_apm_clk = { + .parent = &ckih_clk, + .set_parent = _clk_ssi_lp_apm_set_parent, +}; + +static unsigned long _clk_ssi1_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_CS1CDR ); + prediv = ((reg &MXC_CCM_CS1CDR_SSI1_CLK_PRED_MASK ) >> +MXC_CCM_CS1CDR_SSI1_CLK_PRED_OFFSET ) +1 ; +if (prediv ==1 ) +BUG (); + podf = ((reg &MXC_CCM_CS1CDR_SSI1_CLK_PODF_MASK ) >> +MXC_CCM_CS1CDR_SSI1_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent) / (prediv * podf); +} +static int _clk_ssi1_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, + &pll3_sw_clk, &ssi_lp_apm_clk); + reg =__raw_readl (MXC_CCM_CSCMR1 ) & ~MXC_CCM_CSCMR1_SSI1_CLK_SEL_MASK ; + reg |= mux <<MXC_CCM_CSCMR1_SSI1_CLK_SEL_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk ssi1_clk[] = { + { + .id =0 , + .parent = &pll3_sw_clk, + .set_parent = _clk_ssi1_set_parent, + .secondary = &ssi1_clk[1 ], + .get_rate = _clk_ssi1_get_rate, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ipg_clk, + .secondary = &ssi1_clk[2 ], + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &aips_tz2_clk, + }, +}; + +static unsigned long _clk_ssi2_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_CS2CDR ); + prediv = ((reg &MXC_CCM_CS2CDR_SSI2_CLK_PRED_MASK ) >> +MXC_CCM_CS2CDR_SSI2_CLK_PRED_OFFSET ) +1 ; +if (prediv ==1 ) +BUG (); + podf = ((reg &MXC_CCM_CS2CDR_SSI2_CLK_PODF_MASK ) >> +MXC_CCM_CS2CDR_SSI2_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent) / (prediv * podf); +} + +static int _clk_ssi2_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, + &pll3_sw_clk, &ssi_lp_apm_clk); + reg =__raw_readl (MXC_CCM_CSCMR1 ) & ~MXC_CCM_CSCMR1_SSI2_CLK_SEL_MASK ; + reg |= mux <<MXC_CCM_CSCMR1_SSI2_CLK_SEL_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk ssi2_clk[] = { + { + .id =1 , + .parent = &pll3_sw_clk, + .set_parent = _clk_ssi2_set_parent, + .secondary = &ssi2_clk[1 ], + .get_rate = _clk_ssi2_get_rate, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG11_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =1 , + .parent = &ipg_clk, + .secondary = &ssi2_clk[2 ], + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG10_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, + }, + { + .id =1 , + .parent = &spba_clk, + }, +}; + +static unsigned long _clk_ssi_ext1_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; +u32 div =1 ; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); +if ((reg &MXC_CCM_CSCMR1_SSI_EXT1_COM_CLK_SEL ) ==0 ) { + reg =__raw_readl (MXC_CCM_CS1CDR ); + prediv = ((reg &MXC_CCM_CS1CDR_SSI_EXT1_CLK_PRED_MASK ) >> +MXC_CCM_CS1CDR_SSI_EXT1_CLK_PRED_OFFSET ) +1 ; +if (prediv ==1 ) +BUG (); + podf = ((reg &MXC_CCM_CS1CDR_SSI_EXT1_CLK_PODF_MASK ) >> +MXC_CCM_CS1CDR_SSI_EXT1_CLK_PODF_OFFSET ) +1 ; + div = prediv * podf; + } +return clk_get_rate (clk->parent) / div; +} + +static int _clk_ssi_ext1_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, div, pre, post; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; +if (div ==0 ) + div++; +if (((parent_rate / div) != rate) || div >512 ) +return -EINVAL ; + +__calc_pre_post_dividers (div, &pre, &post); + + reg =__raw_readl (MXC_CCM_CS1CDR ); + reg &= ~(MXC_CCM_CS1CDR_SSI_EXT1_CLK_PRED_MASK | +MXC_CCM_CS1CDR_SSI_EXT1_CLK_PODF_MASK ); + reg |= (post -1 ) <<MXC_CCM_CS1CDR_SSI_EXT1_CLK_PODF_OFFSET ; + reg |= (pre -1 ) <<MXC_CCM_CS1CDR_SSI_EXT1_CLK_PRED_OFFSET ; +__raw_writel (reg,MXC_CCM_CS1CDR ); + +return 0 ; +} + +static int _clk_ssi_ext1_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); +if (parent == &ssi1_clk[0 ]) { + reg |=MXC_CCM_CSCMR1_SSI_EXT1_COM_CLK_SEL ; + }else { + reg &= ~MXC_CCM_CSCMR1_SSI_EXT1_COM_CLK_SEL ; + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, + &ssi_lp_apm_clk); + reg = (reg & ~MXC_CCM_CSCMR1_SSI_EXT1_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CSCMR1_SSI_EXT1_CLK_SEL_OFFSET ); + } + +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static unsigned long _clk_ssi_ext1_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 pre, post; +u32 parent_rate =clk_get_rate (clk->parent); +u32 div = parent_rate / rate; + +if (parent_rate % rate) + div++; + +__calc_pre_post_dividers (div, &pre, &post); + +return parent_rate / (pre * post); +} + +static struct clk ssi_ext1_clk = { + .parent = &pll3_sw_clk, + .set_parent = _clk_ssi_ext1_set_parent, + .set_rate = _clk_ssi_ext1_set_rate, + .round_rate = _clk_ssi_ext1_round_rate, + .get_rate = _clk_ssi_ext1_get_rate, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG14_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, +}; + +static unsigned long _clk_ssi_ext2_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; +u32 div =1 ; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); +if ((reg &MXC_CCM_CSCMR1_SSI_EXT2_COM_CLK_SEL ) ==0 ) { + reg =__raw_readl (MXC_CCM_CS2CDR ); + prediv = ((reg &MXC_CCM_CS2CDR_SSI_EXT2_CLK_PRED_MASK ) >> +MXC_CCM_CS2CDR_SSI_EXT2_CLK_PRED_OFFSET ) +1 ; +if (prediv ==1 ) +BUG (); + podf = ((reg &MXC_CCM_CS2CDR_SSI_EXT2_CLK_PODF_MASK ) >> +MXC_CCM_CS2CDR_SSI_EXT2_CLK_PODF_OFFSET ) +1 ; + div = prediv * podf; + } +return clk_get_rate (clk->parent) / div; +} + +static int _clk_ssi_ext2_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); +if (parent == &ssi2_clk[0 ]) { + reg |=MXC_CCM_CSCMR1_SSI_EXT2_COM_CLK_SEL ; + }else { + reg &= ~MXC_CCM_CSCMR1_SSI_EXT2_COM_CLK_SEL ; + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, + &ssi_lp_apm_clk); + reg = (reg & ~MXC_CCM_CSCMR1_SSI_EXT2_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CSCMR1_SSI_EXT2_CLK_SEL_OFFSET ); + } + +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk ssi_ext2_clk = { + .parent = &pll3_sw_clk, + .set_parent = _clk_ssi_ext2_set_parent, + .get_rate = _clk_ssi_ext2_get_rate, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG15_OFFSET, + .enable = _clk_enable, + .disable = _clk_disable, +}; + +static struct clk tmax2_clk = { + .id =0 , + .parent = &ahb_clk, + .secondary = &ahb_max_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR1 , + .enable_shift = MXC_CCM_CCGRx_CG1_OFFSET, + .disable = _clk_disable, +}; + +static struct clk usb_ahb_clk = { + .parent = &ipg_clk, + .secondary = &ddr_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET, + .disable = _clk_disable, +}; + +static struct clk usb_phy_clk[] = { + { + .id =0 , + .parent = &osc_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, + .disable = _clk_disable, + }, + { + .id =1 , + .parent = &osc_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .disable = _clk_disable, + } +}; + +static struct clk esdhc_dep_clks = { + .parent = &spba_clk, + .secondary = &ddr_clk, +}; + +static unsigned long _clk_esdhc1_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_CSCDR1 ); + prediv = ((reg &MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PRED_MASK ) >> +MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PRED_OFFSET ) +1 ; + podf = ((reg &MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PODF_MASK ) >> +MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent) / (prediv * podf); +} + +static int _clk_esdhc1_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); + mux =_get_mux (parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, + &lp_apm_clk); + reg = reg & ~MXC_CCM_CSCMR1_ESDHC1_CLK_SEL_MASK ; + reg |= mux <<MXC_CCM_CSCMR1_ESDHC1_CLK_SEL_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + + +static int _clk_esdhc1_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg; +u32 div; +u32 pre, post; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; + +if ((parent_rate / div) != rate) +return -EINVAL ; + +__calc_pre_post_dividers (div, &pre, &post); + +/* Set sdhc1 clock divider */ + reg =__raw_readl (MXC_CCM_CSCDR1 ) & + ~(MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PRED_MASK | +MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PODF_MASK ); + reg |= (post -1 ) <<MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PODF_OFFSET ; + reg |= (pre -1 ) <<MXC_CCM_CSCDR1_ESDHC1_MSHC2_CLK_PRED_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCDR1 ); + +return 0 ; +} + +static struct clk esdhc1_clk[] = { + { + .id =0 , + .parent = &pll2_sw_clk, + .set_parent = _clk_esdhc1_set_parent, + .get_rate = _clk_esdhc1_get_rate, + .set_rate = _clk_esdhc1_set_rate, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG1_OFFSET, + .disable = _clk_disable, + .secondary = &esdhc1_clk[1 ], + }, + { + .id =0 , + .parent = &ipg_clk, + .secondary = &esdhc1_clk[2 ], + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG0_OFFSET, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &tmax2_clk, + .secondary = &esdhc_dep_clks, + }, + +}; + +static int _clk_esdhc2_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); +if (parent == &esdhc1_clk[0 ]) + reg &= ~MXC_CCM_CSCMR1_ESDHC2_CLK_SEL ; +else if (parent == &esdhc3_clk[0 ]) + reg |=MXC_CCM_CSCMR1_ESDHC2_CLK_SEL ; +else +BUG (); +__raw_writel (reg,MXC_CCM_CSCMR1 ); +return 0 ; +} + +static struct clk esdhc2_clk[] = { + { + .id =1 , + .parent = &esdhc1_clk[0 ], + .set_parent = _clk_esdhc2_set_parent, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG3_OFFSET, + .disable = _clk_disable, + .secondary = &esdhc2_clk[1 ], + }, + { + .id =1 , + .parent = &ipg_clk, + .secondary = &esdhc2_clk[2 ], + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG2_OFFSET, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &tmax2_clk, + .secondary = &esdhc_dep_clks, + }, +}; + +static int _clk_esdhc3_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); + mux =_get_mux8 (parent, &pll1_sw_clk, &pll2_sw_clk, + &pll3_sw_clk, &lp_apm_clk, &pfd0_clk, + &pfd1_clk, &pfd4_clk, &osc_clk); + reg = reg & ~MXC_CCM_CSCMR1_ESDHC3_CLK_SEL_MASK ; + reg |= mux <<MXC_CCM_CSCMR1_ESDHC3_CLK_SEL_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static unsigned long _clk_esdhc3_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_CSCDR1 ); + prediv = ((reg &MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PRED_MASK ) >> +MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PRED_OFFSET ) +1 ; + podf = ((reg &MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PODF_MASK ) >> +MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent) / (prediv * podf); +} + +static int _clk_esdhc3_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg; +u32 div; +u32 pre, post; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; + +if ((parent_rate / div) != rate) +return -EINVAL ; + +__calc_pre_post_dividers (div, &pre, &post); + +/* Set sdhc1 clock divider */ + reg =__raw_readl (MXC_CCM_CSCDR1 ) & + ~(MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PRED_MASK | +MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PODF_MASK ); + reg |= (post -1 ) <<MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PODF_OFFSET ; + reg |= (pre -1 ) <<MXC_CCM_CSCDR1_ESDHC3_MSHC2_CLK_PRED_OFFSET ; +__raw_writel (reg,MXC_CCM_CSCDR1 ); + +return 0 ; +} + + +static struct clk esdhc3_clk[] = { + { + .id =2 , + .parent = &pll2_sw_clk, + .set_parent = _clk_esdhc3_set_parent, + .get_rate = _clk_esdhc3_get_rate, + .set_rate = _clk_esdhc3_set_rate, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, + .disable = _clk_disable, + .secondary = &esdhc3_clk[1 ], + }, + { + .id =2 , + .parent = &ipg_clk, + .secondary = &esdhc3_clk[2 ], + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG4_OFFSET, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &ahb_max_clk, + .secondary = &esdhc_dep_clks, + }, +}; + +static int _clk_esdhc4_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CSCMR1 ); +if (parent == &esdhc1_clk[0 ]) + reg &= ~MXC_CCM_CSCMR1_ESDHC4_CLK_SEL ; +else if (parent == &esdhc3_clk[0 ]) + reg |=MXC_CCM_CSCMR1_ESDHC4_CLK_SEL ; +else +BUG (); +__raw_writel (reg,MXC_CCM_CSCMR1 ); + +return 0 ; +} + +static struct clk esdhc4_clk[] = { + { + .id =3 , + .parent = &esdhc1_clk[0 ], + .set_parent = _clk_esdhc4_set_parent, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, + .disable = _clk_disable, + .secondary = &esdhc4_clk[1 ], + }, + { + .id =3 , + .parent = &ipg_clk, + .secondary = &esdhc4_clk[2 ], + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR3 , + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .disable = _clk_disable, + }, + { + .id =0 , + .parent = &tmax2_clk, + .secondary = &esdhc_dep_clks, + }, +}; + +static int _clk_ddr_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CLK_DDR ); +if (parent == &pfd0_clk) + reg |=MXC_CCM_CLK_DDR_DDR_PFD_SEL ; +else if (parent == &pll1_sw_clk) + reg &= ~MXC_CCM_CLK_DDR_DDR_PFD_SEL ; +else +return -EINVAL ; +__raw_writel (reg,MXC_CCM_CLK_DDR ); +return 0 ; +} + +static unsigned long _clk_ddr_get_rate (struct clk *clk) +{ +u32 reg, div; + + reg =__raw_readl (MXC_CCM_CLK_DDR ); + div = (reg &MXC_CCM_CLK_DDR_DDR_DIV_PLL_MASK ) >> +MXC_CCM_CLK_DDR_DDR_DIV_PLL_OFFSET ; +if (div) +return clk_get_rate (clk->parent) / div; + +return 0 ; +} + +static int _clk_ddr_enable (struct clk *clk) +{ +u32 reg; + +_clk_enable (clk); + reg = (__raw_readl (databahn +DATABAHN_CTL_REG55 )) & +DDR_SYNC_MODE ; +if (reg !=DDR_SYNC_MODE ) { + reg =__raw_readl (MXC_CCM_CLK_DDR ); + reg |=MXC_CCM_CLK_DDR_DDR_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_CLK_DDR ); + } +return 0 ; +} + +static void _clk_ddr_disable (struct clk *clk) +{ +_clk_disable_inwait (clk); +} + + +static struct clk ddr_clk = { + .parent = &pll1_sw_clk, + .secondary = &sys_clk, + .set_parent = _clk_ddr_set_parent, + .get_rate = _clk_ddr_get_rate, + .enable = _clk_ddr_enable, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG15_OFFSET, + .disable = _clk_ddr_disable, +}; + +static unsigned long _clk_pgc_get_rate (struct clk *clk) +{ +u32 reg, div; + + reg =__raw_readl (MXC_CCM_CSCDR1 ); + div = (reg &MXC_CCM_CSCDR1_PGC_CLK_PODF_MASK ) >> +MXC_CCM_CSCDR1_PGC_CLK_PODF_OFFSET ; + div =1 >> div; +return clk_get_rate (clk->parent) / div; +} + +static struct clk pgc_clk = { + .parent = &ipg_clk, + .get_rate = _clk_pgc_get_rate, +};
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 2269
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c new file +7
-0+ +static unsigned long _clk_usb_get_rate (struct clk *clk) +{ +return 60000000 ; +} + +/*usb OTG clock */ space after * please
ok
Quoted 999 lines
Quoted 999 lines
arch/arm/mach-mx5/clock-mx50.c new file +993
-0+static struct clk usb_clk = { + .get_rate = _clk_usb_get_rate, +}; + +static struct clk rtc_clk = { + .parent = &ckil_clk, + .secondary = &ipg_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR4 , + .enable_shift = MXC_CCM_CCGRx_CG14_OFFSET, + .disable = _clk_disable, +}; + +struct clk rng_clk = { + .parent = &ipg_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG1_OFFSET, + .disable = _clk_disable, +}; + +static struct clk owire_clk = { + .parent = &ipg_perclk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG11_OFFSET, + .disable = _clk_disable, +}; + +static struct clk fec_clk[] = { + { + .parent = &ipg_clk, + .secondary = &fec_clk[1 ], + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR2 , + .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET, + .disable = _clk_disable, + }, + { + .parent = &aips_tz2_clk, + .secondary = &ddr_clk, + }, +}; + +static int gpmi_clk_enable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_GPMI ); + reg |=MXC_CCM_GPMI_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_GPMI ); +_clk_enable (clk); +return 0 ; +} + +static void gpmi_clk_disable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_GPMI ); + reg &= ~MXC_CCM_GPMI_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_GPMI ); +_clk_disable (clk); +} + +static int bch_clk_enable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_BCH ); + reg |=MXC_CCM_BCH_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_BCH ); +_clk_enable (clk); +return 0 ; +} + +static void bch_clk_disable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_BCH ); + reg &= ~MXC_CCM_BCH_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_BCH ); +_clk_disable (clk); +} + +static int gpmi_set_parent (struct clk *clk,struct clk *parent) +{ +/* Setting for ONFI nand which need PLL1(800MHZ) */ +if (parent == &pll1_main_clk) { +u32 reg =__raw_readl (MXC_CCM_CLKSEQ_BYPASS ); + + reg = (reg & ~MXC_CCM_CLKSEQ_BYPASS_BYPASS_GPMI_CLK_SEL_MASK ) | + (0x2 <<MXC_CCM_CLKSEQ_BYPASS_BYPASS_GPMI_CLK_SEL_OFFSET ); + +__raw_writel (reg,MXC_CCM_CLKSEQ_BYPASS ); + +/* change to the new Parent */ + clk->parent = parent; + }else +printk (KERN_WARNING "You should not call the %s\n" , __func__); +return 0 ; +} + +static int gpmi_set_rate (struct clk *clk,unsigned long rate) +{ +/* Setting for ONFI nand which in different mode */ +if (clk->parent == &pll1_main_clk) { +u32 value; +u32 reg; + + value =clk_get_rate (clk->parent); + value /= rate; + value /=2 ;/* HW_GPMI_CTRL1's GPMI_CLK_DIV2_EN will be set */ + + reg =__raw_readl (MXC_CCM_GPMI ); + reg = (reg & ~MXC_CCM_GPMI_CLK_DIV_MASK ) | value; + +__raw_writel (reg,MXC_CCM_GPMI ); + }else +printk (KERN_WARNING "You should not call the %s\n" , __func__); +return 0 ; +} + +static struct clk gpmi_nfc_clk[] = { + {/* gpmi_io_clk */ + .parent = &osc_clk, + .secondary = &gpmi_nfc_clk[1 ], + .set_parent = gpmi_set_parent, + .set_rate = gpmi_set_rate, + .enable = gpmi_clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, + .disable = gpmi_clk_disable, + }, + {/* gpmi_apb_clk */ + .parent = &ahb_clk, + .secondary = &gpmi_nfc_clk[2 ], + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .disable = _clk_disable, + }, + {/* bch_clk */ + .parent = &osc_clk, + .secondary = &gpmi_nfc_clk[3 ], + .enable = bch_clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG0_OFFSET, + .disable = bch_clk_disable, + }, + {/* bch_apb_clk */ + .parent = &ahb_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET, + .disable = _clk_disable, + }, +}; + +static struct clk ocotp_clk = { + .parent = &ahb_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET, + .disable = _clk_disable, +}; + +static int _clk_gpu2d_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CBCMR ); + mux =_get_mux (parent, &axi_a_clk, &axi_b_clk, &weim_clk[0 ], &ahb_clk); + reg = (reg & ~MXC_CCM_CBCMR_GPU2D_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CBCMR_GPU2D_CLK_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CBCMR ); + +return 0 ; +} + +static struct clk gpu2d_clk = { + .parent = &axi_a_clk, + .secondary = &ddr_clk, + .set_parent = _clk_gpu2d_set_parent, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, + .disable = _clk_disable, +}; + +static struct clk apbh_dma_clk = { + .parent = &ahb_clk, + .secondary = &ddr_clk, + .enable = _clk_enable, + .disable = _clk_disable_inwait, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG10_OFFSET, +}; + +struct clk dcp_clk = { + .parent = &ahb_clk, + .secondary = &apbh_dma_clk, + .enable = _clk_enable, + .enable_reg =MXC_CCM_CCGR7 , + .enable_shift = MXC_CCM_CCGRx_CG11_OFFSET, + .disable = _clk_disable, +}; + +static int _clk_display_axi_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CLKSEQ_BYPASS ); + mux =_get_mux (parent, &osc_clk, &pfd2_clk, &pll1_sw_clk,NULL ); + reg = (reg & ~MXC_CCM_CLKSEQ_BYPASS_BYPASS_DISPLAY_AXI_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CLKSEQ_BYPASS_BYPASS_DISPLAY_AXI_CLK_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CLKSEQ_BYPASS ); + +return 0 ; +} + +static unsigned long _clk_display_axi_get_rate (struct clk *clk) +{ +u32 div; + + div =__raw_readl (MXC_CCM_DISPLAY_AXI ); + div &=MXC_CCM_DISPLAY_AXI_DIV_MASK ; +if (div ==0 ) {/* gated off */ +return clk_get_rate (clk->parent); + }else { +return clk_get_rate (clk->parent) / div; + } +} + +static unsigned long _clk_display_axi_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 max_div = (2 <<6 ) -1 ; +return _clk_round_rate_div (clk, rate, max_div,NULL ); +} + +static int _clk_display_axi_set_rate (struct clk *clk,unsigned long rate) +{ +u32 new_div, max_div; +u32 reg; + + max_div = (2 <<6 ) -1 ; +_clk_round_rate_div (clk, rate, max_div, &new_div); + + reg =__raw_readl (MXC_CCM_DISPLAY_AXI ); + reg &= ~MXC_CCM_DISPLAY_AXI_DIV_MASK ; + reg |= new_div <<MXC_CCM_DISPLAY_AXI_DIV_OFFSET ; +__raw_writel (reg,MXC_CCM_DISPLAY_AXI ); + +while (__raw_readl (MXC_CCM_CSR2 ) &MXC_CCM_CSR2_DISPLAY_AXI_BUSY ) + ; +return 0 ; +} + +static struct clk display_axi_clk = { + .parent = &osc_clk, + .secondary = &apbh_dma_clk, + .set_parent = _clk_display_axi_set_parent, + .get_rate = _clk_display_axi_get_rate, + .set_rate = _clk_display_axi_set_rate, + .round_rate = _clk_display_axi_round_rate, + .enable = _clk_enable, + .disable = _clk_disable, + .enable_reg =MXC_CCM_DISPLAY_AXI , + .enable_shift =MXC_CCM_DISPLAY_AXI_CLKGATE_OFFSET , +}; + +/* TODO: check Auto-Slow Mode */ +static struct clk pxp_axi_clk = { + .parent = &display_axi_clk, + .enable = _clk_enable, + .disable = _clk_disable, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG9_OFFSET, +}; + +static struct clk elcdif_axi_clk = { + .parent = &display_axi_clk, + .enable = _clk_enable, + .disable = _clk_disable, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG10_OFFSET, +}; + +static int _clk_elcdif_pix_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CLKSEQ_BYPASS ); + mux =_get_mux (parent, &osc_clk, &pfd6_clk, &pll1_sw_clk, &ckih_clk); + reg = (reg & ~MXC_CCM_CLKSEQ_BYPASS_BYPASS_ELCDIF_PIX_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CLKSEQ_BYPASS_BYPASS_ELCDIF_PIX_CLK_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CLKSEQ_BYPASS ); + +return 0 ; +} + +static unsigned long _clk_elcdif_pix_get_rate (struct clk *clk) +{ +u32 reg, prediv, podf; + + reg =__raw_readl (MXC_CCM_ELCDIFPIX ); + prediv = ((reg &MXC_CCM_ELCDIFPIX_CLK_PRED_MASK ) >> +MXC_CCM_ELCDIFPIX_CLK_PRED_OFFSET ) +1 ; + podf = ((reg &MXC_CCM_ELCDIFPIX_CLK_PODF_MASK ) >> +MXC_CCM_ELCDIFPIX_CLK_PODF_OFFSET ) +1 ; + +return clk_get_rate (clk->parent) / (prediv * podf); +} + +static unsigned long _clk_elcdif_pix_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 max_div = (2 <<12 ) -1 ; +return _clk_round_rate_div (clk, rate, max_div,NULL ); +} + +static int _clk_elcdif_pix_set_rate (struct clk *clk,unsigned long rate) +{ +u32 new_div, max_div; +u32 reg; + + max_div = (2 <<12 ) -1 ; +_clk_round_rate_div (clk, rate, max_div, &new_div); + + reg =__raw_readl (MXC_CCM_ELCDIFPIX ); +/* Pre-divider set to 1 - only use PODF for clk dividing */ + reg &= ~MXC_CCM_ELCDIFPIX_CLK_PRED_MASK ; + reg |=1 <<MXC_CCM_ELCDIFPIX_CLK_PRED_OFFSET ; + reg &= ~MXC_CCM_ELCDIFPIX_CLK_PODF_MASK ; + reg |= new_div <<MXC_CCM_ELCDIFPIX_CLK_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_ELCDIFPIX ); + +return 0 ; +} + +static int _clk_elcdif_pix_enable (struct clk *clk) +{ +u32 reg; + +_clk_enable (clk); + reg =__raw_readl (MXC_CCM_ELCDIFPIX ); + reg |=0x3 <<MXC_CCM_ELCDIFPIX_CLKGATE_OFFSET ; +__raw_writel (reg,MXC_CCM_ELCDIFPIX ); +return 0 ; +} + +static void _clk_elcdif_pix_disable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_ELCDIFPIX ); + reg &= ~MXC_CCM_ELCDIFPIX_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_ELCDIFPIX ); +_clk_disable (clk); +} + +static struct clk elcdif_pix_clk = { + .parent = &osc_clk, + .secondary = &ddr_clk, + .enable = _clk_elcdif_pix_enable, + .disable = _clk_elcdif_pix_disable, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET, + .set_parent = _clk_elcdif_pix_set_parent, + .get_rate = _clk_elcdif_pix_get_rate, + .round_rate = _clk_elcdif_pix_round_rate, + .set_rate = _clk_elcdif_pix_set_rate, +}; + +static int _clk_epdc_axi_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CLKSEQ_BYPASS ); + mux =_get_mux (parent, &osc_clk, &pfd3_clk, &pll1_sw_clk,NULL ); + reg = (reg & ~MXC_CCM_CLKSEQ_BYPASS_BYPASS_EPDC_AXI_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CLKSEQ_BYPASS_BYPASS_EPDC_AXI_CLK_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CLKSEQ_BYPASS ); + +return 0 ; +} + +static unsigned long _clk_epdc_axi_get_rate (struct clk *clk) +{ +u32 div; + + div =__raw_readl (MXC_CCM_EPDC_AXI ); + div &=MXC_CCM_EPDC_AXI_DIV_MASK ; +if (div ==0 ) {/* gated off */ +return clk_get_rate (clk->parent); + }else { +return clk_get_rate (clk->parent) / div; + } +} + +static unsigned long _clk_epdc_axi_round_rate_div (struct clk *clk, +unsigned long rate, +u32 *new_div) +{ +u32 div, max_div; + + max_div = (2 <<6 ) -1 ; + div =DIV_ROUND_UP (clk_get_rate (clk->parent), rate); +if (div > max_div) + div = max_div; +else if (div ==0 ) + div++; +if (new_div !=NULL ) + *new_div = div; +return clk_get_rate (clk->parent) / div; +} + +static unsigned long _clk_epdc_axi_round_rate (struct clk *clk, +unsigned long rate) +{ +return _clk_epdc_axi_round_rate_div (clk, rate,NULL ); +} + +static int _clk_epdc_axi_set_rate (struct clk *clk,unsigned long rate) +{ +u32 new_div; +u32 reg; + +_clk_epdc_axi_round_rate_div (clk, rate, &new_div); + + reg =__raw_readl (MXC_CCM_EPDC_AXI ); + reg &= ~MXC_CCM_EPDC_AXI_DIV_MASK ; + reg |= new_div <<MXC_CCM_EPDC_AXI_DIV_OFFSET ; +__raw_writel (reg,MXC_CCM_EPDC_AXI ); + +while (__raw_readl (MXC_CCM_CSR2 ) &MXC_CCM_CSR2_EPDC_AXI_BUSY ) + ; + +return 0 ; +} + +static int _clk_epdc_axi_enable (struct clk *clk) +{ +u32 reg; + +_clk_enable (clk); + + reg =__raw_readl (MXC_CCM_EPDC_AXI ); + reg |=MXC_CCM_EPDC_AXI_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_EPDC_AXI ); + +return 0 ; +} + +static void _clk_epdc_axi_disable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_EPDC_AXI ); + reg &= ~MXC_CCM_EPDC_AXI_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_EPDC_AXI ); +_clk_disable (clk); +} + +/* TODO: check Auto-Slow Mode */ +static struct clk epdc_axi_clk = { + .parent = &osc_clk, + .secondary = &apbh_dma_clk, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET, + .set_parent = _clk_epdc_axi_set_parent, + .get_rate = _clk_epdc_axi_get_rate, + .set_rate = _clk_epdc_axi_set_rate, + .round_rate = _clk_epdc_axi_round_rate, + .enable = _clk_epdc_axi_enable, + .disable = _clk_epdc_axi_disable, +}; + + +static int _clk_epdc_pix_set_parent (struct clk *clk,struct clk *parent) +{ +u32 reg, mux; + + reg =__raw_readl (MXC_CCM_CLKSEQ_BYPASS ); + mux =_get_mux (parent, &osc_clk, &pfd5_clk, &pll1_sw_clk, &ckih_clk); + reg = (reg & ~MXC_CCM_CLKSEQ_BYPASS_BYPASS_EPDC_PIX_CLK_SEL_MASK ) | + (mux <<MXC_CCM_CLKSEQ_BYPASS_BYPASS_EPDC_PIX_CLK_SEL_OFFSET ); +__raw_writel (reg,MXC_CCM_CLKSEQ_BYPASS ); + +return 0 ; +} + +static unsigned long _clk_epdc_pix_get_rate (struct clk *clk) +{ +u32 div; + + div =__raw_readl (MXC_CCM_EPDCPIX ); + div &=MXC_CCM_EPDC_PIX_CLK_PODF_MASK ; +if (div ==0 ) {/* gated off */ +return clk_get_rate (clk->parent); + }else { +return clk_get_rate (clk->parent) / div; + } +} + +static unsigned long _clk_epdc_pix_round_rate (struct clk *clk, +unsigned long rate) +{ +u32 max_div = (2 <<12 ) -1 ; +return _clk_round_rate_div (clk, rate, max_div,NULL ); +} + +static int _clk_epdc_pix_set_rate (struct clk *clk,unsigned long rate) +{ +u32 new_div, max_div; +u32 reg; + + max_div = (2 <<12 ) -1 ; +_clk_round_rate_div (clk, rate, max_div, &new_div); + + reg =__raw_readl (MXC_CCM_EPDCPIX ); +/* Pre-divider set to 1 - only use PODF for clk dividing */ + reg &= ~MXC_CCM_EPDC_PIX_CLK_PRED_MASK ; + reg |=1 <<MXC_CCM_EPDC_PIX_CLK_PRED_OFFSET ; + reg &= ~MXC_CCM_EPDC_PIX_CLK_PODF_MASK ; + reg |= new_div <<MXC_CCM_EPDC_PIX_CLK_PODF_OFFSET ; +__raw_writel (reg,MXC_CCM_EPDCPIX ); + +while (__raw_readl (MXC_CCM_CSR2 ) &MXC_CCM_CSR2_EPDC_PIX_BUSY ) + ; + +return 0 ; +} + +static int _clk_epdc_pix_enable (struct clk *clk) +{ +u32 reg; + +_clk_enable (clk); + reg =__raw_readl (MXC_CCM_EPDCPIX ); + reg |=MXC_CCM_EPDC_PIX_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_EPDCPIX ); + +return 0 ; +} + +static void _clk_epdc_pix_disable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_EPDCPIX ); + reg &= ~MXC_CCM_EPDC_PIX_CLKGATE_MASK ; +__raw_writel (reg,MXC_CCM_EPDCPIX ); +_clk_disable (clk); +} + +/* TODO: check Auto-Slow Mode */ +static struct clk epdc_pix_clk = { + .parent = &osc_clk, + .secondary = &apbh_dma_clk, + .enable_reg =MXC_CCM_CCGR6 , + .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, + .set_parent = _clk_epdc_pix_set_parent, + .get_rate = _clk_epdc_pix_get_rate, + .set_rate = _clk_epdc_pix_set_rate, + .round_rate = _clk_epdc_pix_round_rate, + .enable = _clk_epdc_pix_enable, + .disable = _clk_epdc_pix_disable, +}; + +static unsigned long cko1_get_rate (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CCOSR ); + reg &=MXC_CCM_CCOSR_CKO1_DIV_MASK ; + reg = reg >>MXC_CCM_CCOSR_CKO1_DIV_OFFSET ; +return clk_get_rate (clk->parent) / (reg +1 ); +} + +static int cko1_enable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CCOSR ); + reg |=MXC_CCM_CCOSR_CKO1_EN ; +__raw_writel (reg,MXC_CCM_CCOSR ); +return 0 ; +} + +static void cko1_disable (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (MXC_CCM_CCOSR ); + reg &= ~MXC_CCM_CCOSR_CKO1_EN ; +__raw_writel (reg,MXC_CCM_CCOSR ); +} + +static int cko1_set_rate (struct clk *clk,unsigned long rate) +{ +u32 reg, div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = (parent_rate/rate -1 ) &0x7 ; + reg =__raw_readl (MXC_CCM_CCOSR ); + reg &= ~MXC_CCM_CCOSR_CKO1_DIV_MASK ; + reg |= div <<MXC_CCM_CCOSR_CKO1_DIV_OFFSET ; +__raw_writel (reg,MXC_CCM_CCOSR ); +return 0 ; +} + +static unsigned long cko1_round_rate (struct clk *clk,unsigned long rate) +{ +u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div = parent_rate / rate; + div = div <1 ?1 : div; + div = div >8 ?8 : div; +return parent_rate / div; +} + +static int cko1_set_parent (struct clk *clk,struct clk *parent) +{ +u32 sel, reg, fast; + +if (parent == &cpu_clk) { + sel =0 ; + fast =1 ; + }else if (parent == &pll1_sw_clk) { + sel =1 ; + fast =1 ; + }else if (parent == &pll2_sw_clk) { + sel =2 ; + fast =1 ; + }else if (parent == &pll3_sw_clk) { + sel =3 ; + fast =1 ; + }else if (parent == &apll_clk) { + sel =0 ; + fast =0 ; + }else if (parent == &pfd0_clk) { + sel =1 ; + fast =0 ; + }else if (parent == &pfd1_clk) { + sel =2 ; + fast =0 ; + }else if (parent == &pfd2_clk) { + sel =3 ; + fast =0 ; + }else if (parent == &pfd3_clk) { + sel =4 ; + fast =0 ; + }else if (parent == &pfd4_clk) { + sel =5 ; + fast =0 ; + }else if (parent == &pfd5_clk) { + sel =6 ; + fast =0 ; + }else if (parent == &pfd6_clk) { + sel =7 ; + fast =0 ; + }else if (parent == &weim_clk[0 ]) { + sel =10 ; + fast =0 ; + }else if (parent == &ahb_clk) { + sel =11 ; + fast =0 ; + }else if (parent == &ipg_clk) { + sel =12 ; + fast =0 ; + }else if (parent == &ipg_perclk) { + sel =13 ; + fast =0 ; + }else if (parent == &pfd7_clk) { + sel =15 ; + fast =0 ; + }else +return -EINVAL ; + + reg =__raw_readl (MXC_CCM_CCOSR ); + reg &= ~MXC_CCM_CCOSR_CKO1_SEL_MASK ; + reg |= sel <<MXC_CCM_CCOSR_CKO1_SEL_OFFSET ; +if (fast) + reg &= ~MXC_CCM_CCOSR_CKO1_SLOW_SEL ; +else + reg |=MXC_CCM_CCOSR_CKO1_SLOW_SEL ; +__raw_writel (reg,MXC_CCM_CCOSR ); +return 0 ; +} + +static struct clk cko1_clk = { + .parent = &pll1_sw_clk, + .get_rate = cko1_get_rate, + .enable = cko1_enable, + .disable = cko1_disable, + .set_rate = cko1_set_rate, + .round_rate = cko1_round_rate, + .set_parent = cko1_set_parent, +}; + +#define _REGISTER_CLOCK (d, n, c) \ + { \ + .dev_id = d, \ + .con_id = n, \ + .clk = &c, \Lines of this file are not shown. View the raw message.
arch/arm/mach-mx5/crm_regs-mx50.h new file +0
-0The rest of this diff is not shown. View the raw message.
Quoted 8 lines
arch/arm/mach-mx5/crm_regs-mx50.h
Quoted 7 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Does that mean GPL v1 may be applied or not?
Does it need to mention all GPL version? I saw other files have such header too.
Quoted 662 lines
Quoted 662 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +601
-0Lines of this file are not shown. View the raw message.
arch/arm/mach-mx5/devices-mx50.h new file +26
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 8 lines
arch/arm/mach-mx5/mm-mx50.c
Quoted 7 lines
arch/arm/mach-mx5/mm-mx50.c new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Did you verify that the exiting function works for mx50?
Yes, I calculated the physical->virtual map, no overlap. And ccm and uart works.
Quoted 22 lines
Quoted 22 lines
arch/arm/mach-mx5/mm-mx50.c new file +21
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 8 lines
arch/arm/mach-mx5/mm-mx50.c
Quoted 6 lines
arch/arm/mach-mx5/mm-mx50.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Is it really necessary for soc code to map the irq controller? If yes that needs to be changed.
TZIC is in on-chip memory section. It's a large memory region. It's hare to use current memory map routines to map it. I mean imx_map_entry.
Quoted 13 lines
Quoted 13 lines
arch/arm/mach-mx5/mm-mx50.c new file +4
-0Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/devices/platform-imx-uart.c +0
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 14 lines
arch/arm/plat-mxc/devices/platform-imx-uart.c
Quoted 13 lines
arch/arm/plat-mxc/devices/platform-imx-uart.c +13
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
double empty line
ok
Quoted 36 lines
Quoted 36 lines
arch/arm/plat-mxc/devices/platform-imx-uart.c +0
-0Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/include/mach/common.h +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 8 lines
arch/arm/plat-mxc/include/mach/common.h
Quoted 7 lines
arch/arm/plat-mxc/include/mach/common.h +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
IMHO sort mx50 between mx35 and mx51.
ok
Quoted 62 lines
Quoted 62 lines
arch/arm/plat-mxc/include/mach/common.h +2
-0Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/include/mach/hardware.h +1
-0Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/include/mach/iomux-mx50.h new file +31
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 8 lines
arch/arm/plat-mxc/include/mach/iomux-mx50.h
Quoted 7 lines
arch/arm/plat-mxc/include/mach/iomux-mx50.h new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Shouldn't that go into
iomux-v3.h?
Yes. I added it here because I saw other file also defined it. I can send out a new patch to move it.
Quoted 565 lines
Quoted 565 lines
arch/arm/plat-mxc/include/mach/iomux-mx50.h new file +557
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 8 lines
arch/arm/plat-mxc/include/mach/irqs.h
Quoted 6 lines
arch/arm/plat-mxc/include/mach/irqs.h +2
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
That is if you have a kernel with support for mx25 and mx50 you end up with
MXC_GPIO_IRQSbeing defined as (32 * 4).
ok, I will move it to the first place. Anyway, I think it's just a work around for mult-SoC support.
Quoted 12 lines
Quoted 12 lines
arch/arm/plat-mxc/include/mach/memory.h +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 8 lines
arch/arm/plat-mxc/include/mach/memory.h
Quoted 7 lines
arch/arm/plat-mxc/include/mach/memory.h +2
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
I think introducing
ARCH_MX50would be nice and using it e.g. here.
Why? Isn't it redundant? They're all soc level macro.
Quoted 14 lines
Quoted 14 lines
arch/arm/plat-mxc/include/mach/memory.h +0
-0Lines of this file are not shown. View the raw message.
arch/arm/plat-mxc/include/mach/mx50.h new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 8 lines
arch/arm/plat-mxc/include/mach/mx50.h
Quoted 7 lines
arch/arm/plat-mxc/include/mach/mx50.h new file +7
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
can you please use lower case letters for hex constants?
ok
Quoted 310 lines
Quoted 310 lines
arch/arm/plat-mxc/include/mach/mx50.h new file +295
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 8 lines
arch/arm/plat-mxc/include/mach/mxc.h
Quoted 6 lines
arch/arm/plat-mxc/include/mach/mxc.h +1
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
This has the same problem as
cpu_is_mx53that I pointed out in the review to an earlier patch of this series
Ok.
Quoted 7 lines
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
Thanks
Richard
Part of the diff is not shown here. View the raw message.
PATCH 5/6 arm: mx50: add core functions support
Hello Richard,
Quoted 20 lines · Richard Zhao
Quoted 11 lines · Uwe Kleine-K?nig
Quoted 10 lines · Richard Zhao
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+#define WAIT (exp, timeout) \ +({ \ + struct timespec nstimeofday; \ + struct timespec curtime; \ + int result = 1; \ + getnstimeofday(&nstimeofday); \ + while (!(exp)) { \ + getnstimeofday(&curtime); \ + if ((curtime.tv_nsec - nstimeofday.tv_nsec) > (timeout)) { \ + result = 0; \Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 84
Quoted 4 lines
arch/arm/mach-mx5/clock-mx50.c new file +4
-0+break ; \ + } \ + } \ + result; \this is broken. Consider
getnstimeofday(&nstimeofday)returns with nstimeofday = { .ts_sec = 42, .ts_nsec = 999999999, }. If timeout is >0 the break is never taken. And furthermore I'm sure that getnstimeofday isn't the right function for that job.
Quoted 1 line
So, what do I suppose to use? udelay is not accurate here.
I'd just busy-loop bounded by a loop count. Do you need exact timing here?
Quoted 30 lines
Quoted 22 lines
Quoted 22 lines
arch/arm/mach-mx5/clock-mx50.c new file +22
-0+static void __calc_pre_post_dividers (u32 div,u32 *pre,u32 *post) +{ +u32 min_pre, temp_pre, old_err, err; + +if (div >=512 ) { + *pre =8 ; + *post =64 ; + }else if (div >=8 ) { + min_pre = (div -1 ) /64 +1 ; + old_err =8 ; +for (temp_pre =8 ; temp_pre >= min_pre; temp_pre--) { + err = div % temp_pre; +if (err ==0 ) { + *pre = temp_pre; +break ; + } + err = temp_pre - err; +if (err < old_err) { + old_err = err; + *pre = temp_pre; + } + }Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 117
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +5
-0+ *post = (div + *pre -1 ) / *pre; + }else if (div <8 ) { + *pre = div; + *post =1 ; + }You seem to have copied an old version of this function. The similarity to
arch/arm/mach-mx5/clock-mx51.cmakes me wonder if you shouldn't copy the Copyright lines from there, too.
Quoted 1 line
It's freescale code.
clock-mx51.cis originally freescale code too.
If you copied from Freescale only that's obviously OK. Still I wonder about the years. clock-mx51 has
* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
* Copyright (C) 2009-2010 Amit Kucheria <[email protected]>
while your suggested clock-mx50.c has
* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +5
-0+} + +static int _clk_enable (struct clk *clk) +{ +u32 reg;Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 128
Quoted 6 lines
arch/arm/mach-mx5/clock-mx50.c new file +6
-0+ reg =__raw_readl (clk->enable_reg); + reg |= MXC_CCM_CCGRx_CG_MASK << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); + +return 0 ; +}These functions are refactored in
arch/arm/mach-mx5/clock-mx51.cin the meantime, too.
Quoted 2 lines
Do you mean
_clk_ccgr_xxx? Do I need to abstract common fileclock.c, or just repeat the function?
See Sascha's comment. I agree that it makes sense to get the common clock stuff in first. With that I have the hope that we can simplify here considerably.
Quoted 7 lines
Quoted 6 lines
arch/arm/mach-mx5/clock-mx50.c line 303
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +5
-0+static unsigned long pfd_round_rate (struct clk *clk,unsigned long rate) +{ +u32 frac; +u64 tmp; + tmp = (u64 )clk_get_rate (clk->parent) *18 ;This can overflow e.g. when parent = apll
480M * 18 =
0x202FBF000, u64 can not overflow.
ah, missed that u64.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +4
-0+do_div (tmp, rate); + frac = tmp; + frac = frac <18 ?18 : frac; + frac = frac >35 ?35 : frac;
Quoted 7 lines
Quoted 6 lines
I remember having seen something like:
#define
CLAMP(x, low, high)((x) < (low) ? (low) : ((x) > (high) ? (high) : (x)))Maybe this is something for <
linux/kernel.h>, probably with better typing.Yes, thanks. it's
clamp(val, min, max).
ah, anticipatory obedience :-)
Quoted 6 lines
Quoted 4 lines
arch/arm/mach-mx5/clock-mx50.c line 327
Quoted 3 lines
arch/arm/mach-mx5/clock-mx50.c new file +3
-0+/* clear clk frac bits */ +__raw_writel (MXC_ANADIG_PFD_FRAC_MASK << clk->enable_shift, + apll_base + (int )clk->enable_reg +8 );What is 8?
Its read/set/clear reg are three different reg. The ip is from mxs series. I can add a
MXC_SET_OFFSETandMXC_CLEAR_OFFSETmacro incrm-regs-mx50.h, if you need it.
ah, ok. The (suggested) mxs barebox port uses 4 and 8, too. I wonder if it makes sense to introduce
#define __raw_setl(val, addr) __raw_writel(val, addr + 4)
and analogous __raw_clearl. That together with a more defensive way to define it. (I.e. cast addr to char* (?) and __iomem (?) and use the usual parenthesis.)
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +0
-0Quoted 8 lines
arch/arm/mach-mx5/crm_regs-mx50.h line 6
Quoted 7 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +6
-0@@ -0,0 +1,607 @@ +/* +* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: Does that mean GPL v1 may be applied or not?
Quoted 1 line
Does it need to mention all GPL version?
I like specifying the exact terms. Some people consider saying "version X or later" OK. So "licensed under the GNU General Public License" without a version might be OK for you. But then saying where to find a copy of the GPL v2 or later seems strange to me.
Quoted 1 line
I saw other files have such header too.
IMHO that's a bad excuse. Feel free to make your work better than the people before you!
Quoted 10 lines
Quoted 8 lines
arch/arm/mach-mx5/crm_regs-mx50.h line 13
Quoted 7 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +7
-0+/* +* Define the MX50 memory map. +*/ +static struct map_desc mx50_io_desc[]__initdata = { +imx_map_entry (MX50 ,AIPS1 ,MT_DEVICE ), +imx_map_entry (MX50 ,SPBA0 ,MT_DEVICE ), +imx_map_entry (MX50 ,AIPS2 ,MT_DEVICE ),Did you verify that the exiting function works for mx50?
Yes, I calculated the
physical->virtualmap, no overlap. And ccm and uart works.
OK, I added mx50 to my script that generates the comment for IMX_IOP2V. (And it confirms your findings :-)
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +4
-0+void __init mx50_init_irq (void ) +{ +unsigned long tzic_addr; +void __iomem *tzic_virt;Quoted 8 lines
arch/arm/mach-mx5/crm_regs-mx50.h line 23
Quoted 6 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +6
-0+ + tzic_addr =MX50_TZIC_BASE_ADDR ; + + tzic_virt =ioremap (tzic_addr,SZ_16K ); +if (!tzic_virt) +panic ("unable to map TZIC interrupt controller\n" );Is it really necessary for soc code to map the irq controller? If yes that needs to be changed.
Quoted 2 lines
TZIC is in on-chip memory section. It's a large memory region. It's hare to use current memory map routines to map it. I mean
imx_map_entry.
Hmm, MX50_TZIC_BASE_ADDR is at 0x0fffc000. If you add it to the statically mapped memory, your map looks as follows:
* TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000
* SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
* AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x100000
* AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x100000
which is OK, isn't it?
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +8
-0+/* +* various IOMUX alternate output functions (1-7) +*/ +enum iomux_config { +IOMUX_CONFIG_ALT0 , +IOMUX_CONFIG_ALT1 , +IOMUX_CONFIG_ALT2 , +IOMUX_CONFIG_ALT3 ,Quoted 8 lines
arch/arm/mach-mx5/crm_regs-mx50.h line 38
Quoted 7 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +7
-0+IOMUX_CONFIG_ALT4 , +IOMUX_CONFIG_ALT5 , +IOMUX_CONFIG_ALT6 , +IOMUX_CONFIG_ALT7 , +IOMUX_CONFIG_GPIO ,/* added to help user use GPIO mode */ + IOMUX_CONFIG_SION = 0x1 << 4, /* LOOPBACK:MUX SION bit */ +};Shouldn't that go into
iomux-v3.h?
Quoted 2 lines
Yes. I added it here because I saw other file also defined it. I can send out a new patch to move it.
Yes, that's a seperate patch at the beginning of the series, please.
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
arch/arm/plat-mxc/include/mach/irqs.h +0
-0@@ -29,6 +29,8 @@#define MXC_GPIO_IRQS (32 * 4)#elif definedCONFIG_ARCH_MX25 Quoted 8 lines
arch/arm/plat-mxc/include/mach/irqs.h line 36
Quoted 6 lines
arch/arm/plat-mxc/include/mach/irqs.h +2
-0#define MXC_GPIO_IRQS (32 * 4) +#elif definedCONFIG_SOC_IMX50 +#define MXC_GPIO_IRQS (32 * 6)#elif definedCONFIG_SOC_IMX51 #define MXC_GPIO_IRQS (32 * 4)#elif definedCONFIG_ARCH_MXC91231 That is if you have a kernel with support for mx25 and mx50 you end up with
MXC_GPIO_IRQSbeing defined as (32 * 4).
Quoted 1 line
ok, I will move it to the first place. Anyway, I think it's just a work around for mult-SoC support.
It's needed as long was we need to specify the number of irqs. Unless when using sparse irq it's good to keep this number low. So this is the strait forward approach.
Quoted 19 lines
Quoted 11 lines
Quoted 11 lines
arch/arm/plat-mxc/include/mach/memory.h +1
-0@@ -16,6 +16,7 @@#define MX25_PHYS_OFFSET UL(0x80000000)#define MX27_PHYS_OFFSET UL(0xa0000000)#define MX3x_PHYS_OFFSET UL(0x80000000) +#define MX50_PHYS_OFFSET UL(0x70000000)#define MX51_PHYS_OFFSET UL(0x90000000)#define MX53_PHYS_OFFSET UL(0x70000000)Quoted 8 lines
arch/arm/plat-mxc/include/mach/memory.h line 38
Quoted 7 lines
arch/arm/plat-mxc/include/mach/memory.h +2
-0#define MXC91231_PHYS_OFFSET UL(0x90000000)@@ -33,6 +34,8 @@# define PHYS_OFFSET MX3x_PHYS_OFFSET# elif definedCONFIG_ARCH_MXC91231 # define PHYS_OFFSET MXC91231_PHYS_OFFSET +# elif definedCONFIG_SOC_IMX50 +# define PHYS_OFFSET MX50_PHYS_OFFSETI think introducing
ARCH_MX50would be nice and using it e.g. here.
Quoted 1 line
Why? Isn't it redundant? They're all soc level macro.
Right from a technical pov. For maintainability they have a different meaning. That is, ARCH_... needs further addressing for multi-SOC. I really like being able to grep for these places.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 5/6 arm: mx50: add core functions support
Hi Uwe,
Quoted 23 lines · Uwe Kleine-K?nig
Hello Richard,
Quoted 20 lines · Richard Zhao
Quoted 19 lines · Uwe Kleine-K?nig
Quoted 4 lines · Richard Zhao
arch/arm/mach-mx5/clock-mx50.c new file +4
-0+#define WAIT (exp, timeout) \ +({ \ + struct timespec nstimeofday; \ + struct timespec curtime; \arch/arm/mach-mx5/clock-mx50.c line 84
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+int result =1 ; \ +getnstimeofday (&nstimeofday); \ +while (!(exp)) { \ +getnstimeofday (&curtime); \ +if ((curtime.tv_nsec - nstimeofday.tv_nsec) > (timeout)) { \ + result =0 ; \ +break ; \ + } \ + } \ + result; \this is broken. Consider
getnstimeofday(&nstimeofday)returns with nstimeofday = { .ts_sec = 42, .ts_nsec = 999999999, }. If timeout is >0 the break is never taken. And furthermore I'm sure that getnstimeofday isn't the right function for that job.
Quoted 3 lines
Quoted 1 line
So, what do I suppose to use? udelay is not accurate here.
I'd just busy-loop bounded by a loop count. Do you need exact timing here?
Yes. If the time is too short, the system may hang.
Quoted 35 lines
Quoted 31 lines
Quoted 23 lines
Quoted 23 lines
arch/arm/mach-mx5/clock-mx50.c new file +22
-0+static void __calc_pre_post_dividers (u32 div,u32 *pre,u32 *post) +{ +u32 min_pre, temp_pre, old_err, err; + +if (div >=512 ) { + *pre =8 ; + *post =64 ; + }else if (div >=8 ) { + min_pre = (div -1 ) /64 +1 ; + old_err =8 ; +for (temp_pre =8 ; temp_pre >= min_pre; temp_pre--) { + err = div % temp_pre; +if (err ==0 ) { + *pre = temp_pre; +break ; + } + err = temp_pre - err; +if (err < old_err) { + old_err = err; + *pre = temp_pre; + } + }Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 117
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +5
-0+ *post = (div + *pre -1 ) / *pre; + }else if (div <8 ) { + *pre = div; + *post =1 ; + }You seem to have copied an old version of this function. The similarity to
arch/arm/mach-mx5/clock-mx51.cmakes me wonder if you shouldn't copy the Copyright lines from there, too.Quoted 1 line
It's freescale code.
clock-mx51.cis originally freescale code too.If you copied from Freescale only that's obviously OK. Still I wonder about the years. clock-mx51 has
Quoted 6 lines
* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
* Copyright (C) 2009-2010 Amit Kucheria <[email protected]>while your suggested
clock-mx50.chas* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
It's because this file was created in 2010.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
arch/arm/mach-mx5/clock-mx50.c line 128
Quoted 12 lines
arch/arm/mach-mx5/clock-mx50.c new file +11
-0+} + +static int _clk_enable (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg); + reg |= MXC_CCM_CCGRx_CG_MASK << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); + +return 0 ; +}These functions are refactored in
arch/arm/mach-mx5/clock-mx51.cin the meantime, too.
Quoted 5 lines
Quoted 2 lines
Do you mean
_clk_ccgr_xxx? Do I need to abstract common fileclock.c, or just repeat the function?See Sascha's comment. I agree that it makes sense to get the common clock stuff in first. With that I have the hope that we can simplify here considerably.
Where should I put the common code? plat-mxc or mach-mx5? Is it ok for you if I only share the code between mx5x?
Quoted 30 lines
Quoted 8 lines
Quoted 7 lines
arch/arm/mach-mx5/clock-mx50.c line 303
Quoted 6 lines
arch/arm/mach-mx5/clock-mx50.c new file +5
-0+static unsigned long pfd_round_rate (struct clk *clk,unsigned long rate) +{ +u32 frac; +u64 tmp; + tmp = (u64 )clk_get_rate (clk->parent) *18 ;This can overflow e.g. when parent = apll
480M * 18 =
0x202FBF000, u64 can not overflow.ah, missed that u64.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +4
-0+do_div (tmp, rate); + frac = tmp; + frac = frac <18 ?18 : frac; + frac = frac >35 ?35 : frac;Quoted 7 lines
Quoted 6 lines
I remember having seen something like:
#define
CLAMP(x, low, high)((x) < (low) ? (low) : ((x) > (high) ? (high) : (x)))Maybe this is something for <
linux/kernel.h>, probably with better typing.Yes, thanks. it's
clamp(val, min, max).ah, anticipatory obedience :-)
Quoted 6 lines
Quoted 4 lines
arch/arm/mach-mx5/clock-mx50.c line 327
Quoted 3 lines
arch/arm/mach-mx5/clock-mx50.c new file +3
-0+/* clear clk frac bits */ +__raw_writel (MXC_ANADIG_PFD_FRAC_MASK << clk->enable_shift, + apll_base + (int )clk->enable_reg +8 );What is 8?
Its read/set/clear reg are three different reg. The ip is from mxs series. I can add a
MXC_SET_OFFSETandMXC_CLEAR_OFFSETmacro incrm-regs-mx50.h, if you need it.
Quoted 8 lines
ah, ok. The (suggested) mxs barebox port uses 4 and 8, too. I wonder if it makes sense to introduce
#define __raw_setl(val, addr) __raw_writel(val, addr + 4)and analogous
__raw_clearl. That together with a more defensive way to define it. (I.e. cast addr to char* (?) and__iomem(?) and use the usual parenthesis.)
Yes, if the offset is alway 4 or 8. I'm not sure yet. I will check with Shawn. And sharing code between mxc and mxs is another problem.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
arch/arm/mach-mx5/crm_regs-mx50.h line 6
Quoted 13 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +6
-0@@ -0,0 +1,607 @@ +/* +* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: Does that mean GPL v1 may be applied or not?
Quoted 5 lines
Quoted 1 line
Does it need to mention all GPL version?
I like specifying the exact terms. Some people consider saying "version X or later" OK. So "licensed under the GNU General Public License" without a version might be OK for you. But then saying where to find a copy of the GPL v2 or later seems strange to me.
/*
* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. *
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
* at the following locations:
*
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
Is above ok?
Quoted 35 lines
Quoted 2 lines
I saw other files have such header too.
IMHO that's a bad excuse. Feel free to make your work better than the people before you!
Quoted 10 lines
Quoted 8 lines
arch/arm/mach-mx5/crm_regs-mx50.h line 13
Quoted 7 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +7
-0+/* +* Define the MX50 memory map. +*/ +static struct map_desc mx50_io_desc[]__initdata = { +imx_map_entry (MX50 ,AIPS1 ,MT_DEVICE ), +imx_map_entry (MX50 ,SPBA0 ,MT_DEVICE ), +imx_map_entry (MX50 ,AIPS2 ,MT_DEVICE ),Did you verify that the exiting function works for mx50?
Yes, I calculated the
physical->virtualmap, no overlap. And ccm and uart works.OK, I added mx50 to my script that generates the comment for
IMX_IOP2V. (And it confirms your findings :-)Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +4
-0+void __init mx50_init_irq (void ) +{ +unsigned long tzic_addr; +void __iomem *tzic_virt;Quoted 8 lines
arch/arm/mach-mx5/crm_regs-mx50.h line 23
Quoted 6 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +6
-0+ + tzic_addr =MX50_TZIC_BASE_ADDR ; + + tzic_virt =ioremap (tzic_addr,SZ_16K ); +if (!tzic_virt) +panic ("unable to map TZIC interrupt controller\n" );Is it really necessary for soc code to map the irq controller? If yes that needs to be changed.
Quoted 2 lines
TZIC is in on-chip memory section. It's a large memory region. It's hare to use current memory map routines to map it. I mean
imx_map_entry.Hmm,
MX50_TZIC_BASE_ADDRis at0x0fffc000. If you add it to the statically mapped memory, your map looks as follows:
Quoted 6 lines
* TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000 * AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x100000 * AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x100000which is OK, isn't it?
Great! I will add a macro MX50_TZIC_SIZE.
Quoted 60 lines
Quoted 17 lines
Quoted 17 lines
Quoted 6 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +5
-0+/* +* various IOMUX alternate output functions (1-7) +*/ +enum iomux_config { +IOMUX_CONFIG_ALT0 ,arch/arm/mach-mx5/crm_regs-mx50.h line 38
Quoted 10 lines
arch/arm/mach-mx5/crm_regs-mx50.h new file +10
-0+IOMUX_CONFIG_ALT1 , +IOMUX_CONFIG_ALT2 , +IOMUX_CONFIG_ALT3 , +IOMUX_CONFIG_ALT4 , +IOMUX_CONFIG_ALT5 , +IOMUX_CONFIG_ALT6 , +IOMUX_CONFIG_ALT7 , +IOMUX_CONFIG_GPIO ,/* added to help user use GPIO mode */ + IOMUX_CONFIG_SION = 0x1 << 4, /* LOOPBACK:MUX SION bit */ +};Shouldn't that go into
iomux-v3.h?Quoted 2 lines
Yes. I added it here because I saw other file also defined it. I can send out a new patch to move it.
Yes, that's a seperate patch at the beginning of the series, please.
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
arch/arm/plat-mxc/include/mach/irqs.h +0
-0@@ -29,6 +29,8 @@#define MXC_GPIO_IRQS (32 * 4)#elif definedCONFIG_ARCH_MX25 Quoted 8 lines
arch/arm/plat-mxc/include/mach/irqs.h line 36
Quoted 6 lines
arch/arm/plat-mxc/include/mach/irqs.h +2
-0#define MXC_GPIO_IRQS (32 * 4) +#elif definedCONFIG_SOC_IMX50 +#define MXC_GPIO_IRQS (32 * 6)#elif definedCONFIG_SOC_IMX51 #define MXC_GPIO_IRQS (32 * 4)#elif definedCONFIG_ARCH_MXC91231 That is if you have a kernel with support for mx25 and mx50 you end up with
MXC_GPIO_IRQSbeing defined as (32 * 4).Quoted 1 line
ok, I will move it to the first place. Anyway, I think it's just a work around for mult-SoC support.
It's needed as long was we need to specify the number of irqs. Unless when using sparse irq it's good to keep this number low. So this is the strait forward approach.
Quoted 19 lines
Quoted 19 lines
Quoted 13 lines
arch/arm/plat-mxc/include/mach/memory.h +1
-0@@ -16,6 +16,7 @@#define MX25_PHYS_OFFSET UL(0x80000000)#define MX27_PHYS_OFFSET UL(0xa0000000)#define MX3x_PHYS_OFFSET UL(0x80000000) +#define MX50_PHYS_OFFSET UL(0x70000000)#define MX51_PHYS_OFFSET UL(0x90000000)#define MX53_PHYS_OFFSET UL(0x70000000)#define MXC91231_PHYS_OFFSET UL(0x90000000)arch/arm/plat-mxc/include/mach/memory.h line 38
Quoted 5 lines
arch/arm/plat-mxc/include/mach/memory.h +2
-0@@ -33,6 +34,8 @@# define PHYS_OFFSET MX3x_PHYS_OFFSET# elif definedCONFIG_ARCH_MXC91231 # define PHYS_OFFSET MXC91231_PHYS_OFFSET +# elif definedCONFIG_SOC_IMX50 +# define PHYS_OFFSET MX50_PHYS_OFFSETI think introducing
ARCH_MX50would be nice and using it e.g. here.
Quoted 4 lines
Quoted 1 line
Why? Isn't it redundant? They're all soc level macro.
Right from a technical pov. For maintainability they have a different meaning. That is,
ARCH_... needs further addressing for multi-SOC. I really like being able to grep for these places.
Is it the only reason that be easy to grep? I really think we only need one of them, either a or b.
Quoted 8 lines
Best regards
Uwe--
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
Thanks
Richard
PATCH 5/6 arm: mx50: add core functions support
Hello Richard,
Quoted 22 lines · Richard Zhao
Quoted 21 lines · Uwe Kleine-K?nig
Quoted 20 lines · Richard Zhao
Quoted 19 lines · Uwe Kleine-K?nig
Quoted 4 lines · Richard Zhao
arch/arm/mach-mx5/clock-mx50.c new file +4
-0+#define WAIT (exp, timeout) \ +({ \ + struct timespec nstimeofday; \ + struct timespec curtime; \arch/arm/mach-mx5/clock-mx50.c line 84
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+int result =1 ; \ +getnstimeofday (&nstimeofday); \ +while (!(exp)) { \ +getnstimeofday (&curtime); \ +if ((curtime.tv_nsec - nstimeofday.tv_nsec) > (timeout)) { \ + result =0 ; \ +break ; \ + } \ + } \ + result; \this is broken. Consider
getnstimeofday(&nstimeofday)returns with nstimeofday = { .ts_sec = 42, .ts_nsec = 999999999, }. If timeout is >0 the break is never taken. And furthermore I'm sure that getnstimeofday isn't the right function for that job.
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
So, what do I suppose to use? udelay is not accurate here.
I'd just busy-loop bounded by a loop count. Do you need exact timing here?
Yes. If the time is too short, the system may hang.
What is the unit of the needed time? If it's clock ticks a busy loop is fine. Why udelay isn't accurate enough?
Quoted 34 lines
Quoted 34 lines
Quoted 30 lines
Quoted 22 lines
Quoted 22 lines
arch/arm/mach-mx5/clock-mx50.c new file +22
-0+static void __calc_pre_post_dividers (u32 div,u32 *pre,u32 *post) +{ +u32 min_pre, temp_pre, old_err, err; + +if (div >=512 ) { + *pre =8 ; + *post =64 ; + }else if (div >=8 ) { + min_pre = (div -1 ) /64 +1 ; + old_err =8 ; +for (temp_pre =8 ; temp_pre >= min_pre; temp_pre--) { + err = div % temp_pre; +if (err ==0 ) { + *pre = temp_pre; +break ; + } + err = temp_pre - err; +if (err < old_err) { + old_err = err; + *pre = temp_pre; + } + }Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 117
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +5
-0+ *post = (div + *pre -1 ) / *pre; + }else if (div <8 ) { + *pre = div; + *post =1 ; + }You seem to have copied an old version of this function. The similarity to
arch/arm/mach-mx5/clock-mx51.cmakes me wonder if you shouldn't copy the Copyright lines from there, too.Quoted 1 line
It's freescale code.
clock-mx51.cis originally freescale code too.If you copied from Freescale only that's obviously OK. Still I wonder about the years. clock-mx51 has
Quoted 7 lines
Quoted 6 lines
* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
* Copyright (C) 2009-2010 Amit Kucheria <[email protected]>while your suggested
clock-mx50.chas* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
It's because this file was created in 2010.
INAL, but I think it's in your (and/or your employer's) interest to have an early date here.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
arch/arm/mach-mx5/clock-mx50.c line 128
Quoted 9 lines
arch/arm/mach-mx5/clock-mx50.c new file +9
-0+static int _clk_enable (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg); + reg |= MXC_CCM_CCGRx_CG_MASK << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); + +return 0 ; +}These functions are refactored in
arch/arm/mach-mx5/clock-mx51.cin the meantime, too.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Do you mean
_clk_ccgr_xxx? Do I need to abstract common fileclock.c, or just repeat the function?See Sascha's comment. I agree that it makes sense to get the common clock stuff in first. With that I have the hope that we can simplify here considerably.
Where should I put the common code? plat-mxc or mach-mx5? Is it ok for you if I only share the code between mx5x?
hmm, don't know yet. This needs a deeper comparison in my opinion.
Quoted 11 lines
/*
* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. *
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
* at the following locations:
*
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
Is above ok?
I think this is something Freescale has to decide. I prefer the statement I wrote e.g. in arch/arm/plat-mxc/devices/platform-imx-dma.c, but as I said, it's up to you.
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
arch/arm/mach-mx5/mm-mx50.c line 56
Quoted 3 lines
arch/arm/mach-mx5/mm-mx50.c new file +3
-0+ tzic_virt =ioremap (tzic_addr,SZ_16K ); +if (!tzic_virt) +panic ("unable to map TZIC interrupt controller\n" );Is it really necessary for soc code to map the irq controller? If yes that needs to be changed.
TZIC is in on-chip memory section. It's a large memory region. It's hare to use current memory map routines to map it. I mean
imx_map_entry.Hmm,
MX50_TZIC_BASE_ADDRis at0x0fffc000. If you add it to the statically mapped memory, your map looks as follows:
Quoted 7 lines
Quoted 6 lines
* TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000 * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000 * AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x100000 * AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x100000which is OK, isn't it?
Great! I will add a macro
MX50_TZIC_SIZE.
And maybe do the same for mx51.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
arch/arm/plat-mxc/include/mach/memory.h line 38
Quoted 5 lines
# define
PHYS_OFFSETMX3x_PHYS_OFFSET# elif defined CONFIG_ARCH_MXC91231 # define PHYS_OFFSET MXC91231_PHYS_OFFSETarch/arm/plat-mxc/include/mach/memory.h +2
-0+# elif definedCONFIG_SOC_IMX50 +# define PHYS_OFFSET MX50_PHYS_OFFSETI think introducing
ARCH_MX50would be nice and using it e.g. here.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Why? Isn't it redundant? They're all soc level macro.
Right from a technical pov. For maintainability they have a different meaning. That is,
ARCH_... needs further addressing for multi-SOC. I really like being able to grep for these places.Is it the only reason that be easy to grep? I really think we only need one of them, either a or b.
IMHO the reason is good enough.
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 5/6 arm: mx50: add core functions support
Hi Uwe,
2010/12/10 Uwe Kleine-K?nig <[email protected]>:
Quoted 25 lines
Hello Richard,
Quoted 22 lines · Richard Zhao
Quoted 21 lines · Uwe Kleine-K?nig
Quoted 20 lines · Richard Zhao
Quoted 19 lines · Uwe Kleine-K?nig
Quoted 4 lines · Richard Zhao
(quoted diff) +4
-0+#define WAIT(exp, timeout) \ +({ \ + ? ? struct timespec nstimeofday; \ + ? ? struct timespec curtime; \Review
Quoted 10 lines
(quoted diff) +10
-0+ ? ? int result = 1; \ + ? ? getnstimeofday(&nstimeofday); \ + ? ? while (!(exp)) { \ + ? ? ? ? ? ? getnstimeofday(&curtime); \ + ? ? ? ? ? ? if ((curtime.tv_nsec - nstimeofday.tv_nsec) > (timeout)) { \ + ? ? ? ? ? ? ? ? ? ? result = 0; \ + ? ? ? ? ? ? ? ? ? ? break; \ + ? ? ? ? ? ? } \ + ? ? } \ + ? ? result; \this is broken. ?Consider
getnstimeofday(&nstimeofday)returns with nstimeofday = { .ts_sec = 42, .ts_nsec = 999999999, }. ?If timeout is >0 the break is never taken. ?And furthermore I'm sure that getnstimeofday isn't the right function for that job.
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
So, what do I suppose to use? udelay is not accurate here.
I'd just busy-loop bounded by a loop count. ?Do you need exact timing here?
Yes. If the time is too short, the system may hang.
What is the unit of the needed time? ?If it's clock ticks a busy loop is fine. ?Why udelay isn't accurate enough?
In most cases, it's some specific clock cycles.
udelay may depend on calibrate_delay(). I first used udelay, but it won't work anyway, so I changed it to getnstimeofday.
I need to add a abs here to avoid overflow.
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 31 lines
Quoted 23 lines
Quoted 23 lines
(quoted diff) +22
-0+static void __calc_pre_post_dividers(u32 div, u32 *pre, u32 *post) +{ + ? ? u32 min_pre, temp_pre, old_err, err; + + ? ? if (div >= 512) { + ? ? ? ? ? ? *pre = 8; + ? ? ? ? ? ? *post = 64; + ? ? } else if (div >= 8) { + ? ? ? ? ? ? min_pre = (div - 1) / 64 + 1; + ? ? ? ? ? ? old_err = 8; + ? ? ? ? ? ? for (temp_pre = 8; temp_pre >= min_pre; temp_pre--) { + ? ? ? ? ? ? ? ? ? ? err = div % temp_pre; + ? ? ? ? ? ? ? ? ? ? if (err == 0) { + ? ? ? ? ? ? ? ? ? ? ? ? ? ? *pre = temp_pre; + ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; + ? ? ? ? ? ? ? ? ? ? } + ? ? ? ? ? ? ? ? ? ? err = temp_pre - err; + ? ? ? ? ? ? ? ? ? ? if (err < old_err) { + ? ? ? ? ? ? ? ? ? ? ? ? ? ? old_err = err; + ? ? ? ? ? ? ? ? ? ? ? ? ? ? *pre = temp_pre; + ? ? ? ? ? ? ? ? ? ? } + ? ? ? ? ? ? }Quoted 8 lines
Quoted 5 lines
+ ? ? ? ? ? ? *post = (div + *pre - 1) / *pre;
+ ? ? } else if (div < 8) {
+ ? ? ? ? ? ? *pre = div;
+ ? ? ? ? ? ? *post = 1;
+ ? ? }You seem to have copied an old version of this function. ?The similarity to
arch/arm/mach-mx5/clock-mx51.cmakes me wonder if you shouldn't copy the Copyright lines from there, too.Quoted 1 line
It's freescale code.
clock-mx51.cis originally freescale code too.If you copied from Freescale only that's obviously OK. ?Still I wonder about the years. ?clock-mx51 has
? ? ? ? ?* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. ? ? ? ? ?* Copyright (C) 2009-2010 Amit Kucheria <[email protected]>
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
while your suggested
clock-mx50.chas? ? ? ? ?* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
It's because this file was created in 2010.
INAL, but I think it's in your (and/or your employer's) interest to have an early date here.
I'll check with professional.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Review
Quoted 10 lines
(quoted diff) +9
-0+static int _clk_enable(struct clk *clk) +{ + ? ? u32 reg; + ? ? reg = __raw_readl(clk->enable_reg); + ? ? reg |= MXC_CCM_CCGRx_CG_MASK << clk->enable_shift; + ? ? __raw_writel(reg, clk->enable_reg); + + ? ? return 0; +}These functions are refactored in
arch/arm/mach-mx5/clock-mx51.cin the meantime, too.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Do you mean
_clk_ccgr_xxx? Do I need to abstract common fileclock.c, or just repeat the function?See Sascha's comment. ?I agree that it makes sense to get the common clock stuff in first. ?With that I have the hope that we can simplify here considerably.
Where should I put the common code? plat-mxc or mach-mx5? Is it ok for you if I only share the code between mx5x?
hmm, don't know yet. ?This needs a deeper comparison in my opinion.
ok. I will look at mx3 and mx5.
Quoted 12 lines
Quoted 12 lines
/*
?* Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. ?*
?* The code contained herein is licensed under the GNU General Public ?* License. You may obtain a copy of the GNU General Public License ?* at the following locations:
?*
?* http://www.opensource.org/licenses/gpl-license.html
?* http://www.gnu.org/copyleft/gpl.html
?*/
Is above ok?
Quoted 3 lines
I think this is something Freescale has to decide. ?I prefer the statement I wrote e.g. in
arch/arm/plat-mxc/devices/platform-imx-dma.c, but as I said, it's up to you.
I will check with professional, and use the official one.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
+ ? ?
tzic_virt=ioremap(tzic_addr, SZ_16K);
+ ? ? if (!tzic_virt)
+ ? ? ? ? ? ?panic("unable to map TZIC interrupt controller\n");Is it really necessary for soc code to map the irq controller? ?If yes that needs to be changed.
TZIC is in on-chip memory section. It's a large memory region. It's hare to use current memory map routines to map it. I mean
imx_map_entry.Hmm,
MX50_TZIC_BASE_ADDRis at0x0fffc000. ?If you add it to the statically mapped memory, your map looks as follows:
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
?* ? ? ?TZIC ? ?0x0fffc000+0x004000 ? ? -> ? ? ?0xf4bfc000+0x004000 ?* ? ? ?SPBA0 ? 0x50000000+0x100000 ? ? -> ? ? ?0xf5400000+0x100000 ?* ? ? ?AIPS1 ? 0x53f00000+0x100000 ? ? -> ? ? ?0xf5700000+0x100000 ?* ? ? ?AIPS2 ? 0x63f00000+0x100000 ? ? -> ? ? ?0xf5300000+0x100000
which is OK, isn't it?
Great! I will add a macro
MX50_TZIC_SIZE.And maybe do the same for mx51.
ok
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 6 lines
?# ?define
PHYS_OFFSET? ? ? ? ? ? ? ?MX3x_PHYS_OFFSET ?# elif definedCONFIG_ARCH_MXC91231
?# ?definePHYS_OFFSET? ? ? ? ? ? ? ?MXC91231_PHYS_OFFSET(quoted diff) +2
-0+# elif defined CONFIG_SOC_IMX50 +# ?define PHYS_OFFSET ? ? ? ? ? ? ? ?MX50_PHYS_OFFSETI think introducing
ARCH_MX50would be nice and using it e.g. here.
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Why? Isn't it redundant? They're all soc level macro.
Right from a technical pov. ?For maintainability they have a different meaning. ?That is,
ARCH_... needs further addressing for multi-SOC. ?I really like being able to grep for these places.Is it the only reason that be easy to grep? I really think we only need one of them, either a or b.
IMHO the reason is good enough.
Both you and Sascha have made your decision? Then, OK.
No other platforms use SOC_XXX, I really can not understand the meaning.
Quoted 6 lines
Uwe
--
Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | Uwe Kleine-K?nig ? ? ? ? ? ?| Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
Thanks
Richard
Quoted 1 line
Sascha Hauer
maintainerPATCH 5/6 arm: mx50: add core functions support
In reply to Richard ZhaoQuoted 130 lines · Richard Zhao
Add core definitions and memory map, clock, gpio, irq, iomux, uart device support.
Signed-off-by Richard Zhao <[email protected]>--- arch/arm/mach-mx5/Kconfig | 8 + arch/arm/mach-mx5/Makefile | 2 + arch/arm/mach-mx5/Makefile.boot | 3 + arch/arm/mach-mx5/clock-mx50.c | 3262 +++++++++++++++++++++++++ arch/arm/mach-mx5/crm_regs-mx50.h | 607 +++++ arch/arm/mach-mx5/devices-mx50.h | 26 + arch/arm/mach-mx5/mm-mx50.c | 60 + arch/arm/plat-mxc/devices/platform-imx-uart.c | 13 + arch/arm/plat-mxc/gpio.c | 14 + arch/arm/plat-mxc/include/mach/common.h | 4 + arch/arm/plat-mxc/include/mach/hardware.h | 1 + arch/arm/plat-mxc/include/mach/iomux-mx50.h | 595 +++++ arch/arm/plat-mxc/include/mach/irqs.h | 2 + arch/arm/plat-mxc/include/mach/memory.h | 3 + arch/arm/plat-mxc/include/mach/mx50.h | 306 +++ arch/arm/plat-mxc/include/mach/mxc.h | 2 + 16 files changed, 4908 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mx5/clock-mx50.c create mode 100644 arch/arm/mach-mx5/crm_regs-mx50.h create mode 100644 arch/arm/mach-mx5/devices-mx50.h create mode 100644 arch/arm/mach-mx5/mm-mx50.c create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx50.h create mode 100644 arch/arm/plat-mxc/include/mach/mx50.harch/arm/mach-mx5/Kconfig +8
-0@@ -12,6 +12,14 @@ config SOC_IMX51 select ARCH_HAS_CPUFREQ select ARCH_MX51 +config SOC_IMX50 + bool + select MXC_TZIC + select ARCH_MXC_IOMUX_V3 + select ARCH_MXC_AUDMUX_V2 + select ARCH_HAS_CPUFREQ + + comment "MX5 platforms:" config MACH_MX51_BABBAGEarch/arm/mach-mx5/Makefile +2
-0@@ -13,3 +13,5 @@ obj-$(CONFIG_MACH_EUKREA_MBIMX51_BASEBOARD) += eukrea_mbimx51-baseboard.o obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += board-cpuimx51sd.o obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o + +obj-$(CONFIG_SOC_IMX50) += mm-mx50.o clock-mx50.oarch/arm/mach-mx5/Makefile.boot +3
-0@@ -1,3 +1,6 @@ zreladdr-$(CONFIG_SOC_IMX51) := 0x90008000 params_phys-$(CONFIG_SOC_IMX51) := 0x90000100 initrd_phys-$(CONFIG_SOC_IMX51) := 0x90800000 + zreladdr-$(CONFIG_SOC_IMX50) := 0x70008000 +params_phys-$(CONFIG_SOC_IMX50) := 0x70000100 +initrd_phys-$(CONFIG_SOC_IMX50) := 0x70800000arch/arm/mach-mx5/clock-mx50.c new file +55
-0@@ -0,0 +1,3262 @@ +/* +* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/time.h> +#include <linux/hrtimer.h> +#include <linux/mm.h> +#include <linux/errno.h> +#include <linux/delay.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <asm/clkdev.h> +#include <asm/div64.h> +#include <mach/hardware.h> +#include <mach/common.h> +#include <mach/clock.h> + +#include "crm_regs-mx50.h" + +/* External clock values passed-in by the board code */ +static unsigned long external_high_reference, external_low_reference; +static unsigned long oscillator_reference, ckih2_reference; + +static struct clk pll1_main_clk; +static struct clk pll1_sw_clk; +static struct clk pll2_sw_clk; +static struct clk pll3_sw_clk; +static struct clk apbh_dma_clk; +static struct clk apll_clk; +static struct clk pfd0_clk; +static struct clk pfd1_clk; +static struct clk pfd2_clk; +static struct clk pfd3_clk; +static struct clk pfd4_clk; +static struct clk pfd5_clk; +static struct clk pfd6_clk; +static struct clk pfd7_clk; +static struct clk lp_apm_clk;
arch/arm/mach-mx5/clock-mx50.c line 65
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+static struct clk weim_clk[]; +static struct clk ddr_clk; +static struct clk axi_a_clk; +static struct clk axi_b_clk; +static struct clk gpu2d_clk; + +static void __iomem *pll1_base; +static void __iomem *pll2_base; +static void __iomem *pll3_base; +void __iomem *apll_base;
static?
arch/arm/mach-mx5/clock-mx50.c line 67
Quoted 2 lines
arch/arm/mach-mx5/clock-mx50.c new file +2
-0+ +void __iomem *databahn;
static?
Quoted 41 lines
arch/arm/mach-mx5/clock-mx50.c new file +41
-0+ +#define DDR_SYNC_MODE 0x30000 +#define SPIN_DELAY 1000000/* in nanoseconds */ +#define WAIT (exp, timeout) \ +({ \ + struct timespec nstimeofday; \ + struct timespec curtime; \ + int result = 1; \ + getnstimeofday(&nstimeofday); \ + while (!(exp)) { \ + getnstimeofday(&curtime); \ + if ((curtime.tv_nsec - nstimeofday.tv_nsec) > (timeout)) { \ + result = 0; \ + break; \ + } \ + } \ + result; \ +}) + +#define MAX_AHB_CLK 133000000 + +static struct clk esdhc3_clk[]; + +static void __calc_pre_post_dividers (u32 div,u32 *pre,u32 *post) +{ +u32 min_pre, temp_pre, old_err, err; + +if (div >=512 ) { + *pre =8 ; + *post =64 ; + }else if (div >=8 ) { + min_pre = (div -1 ) /64 +1 ; + old_err =8 ; +for (temp_pre =8 ; temp_pre >= min_pre; temp_pre--) { + err = div % temp_pre; +if (err ==0 ) { + *pre = temp_pre; +break ; + } + err = temp_pre - err; +if (err < old_err) {
arch/arm/mach-mx5/clock-mx50.c line 118
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+ old_err = err; + *pre = temp_pre; + } + } + *post = (div + *pre -1 ) / *pre; + }else if (div <8 ) { + *pre = div; + *post =1 ; + } +}
We already have this function. It should be made globally available and used here.
Quoted 34 lines
arch/arm/mach-mx5/clock-mx50.c new file +34
-0+ +static int _clk_enable (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg); + reg |= MXC_CCM_CCGRx_CG_MASK << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); + +return 0 ; +} + +static int _clk_enable_inrun (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (clk->enable_reg); + reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); + reg |=1 << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); +return 0 ; +} + +static void _clk_disable (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg); + reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); +__raw_writel (reg, clk->enable_reg); +} + +static void _clk_disable_inwait (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg);
arch/arm/mach-mx5/clock-mx50.c line 162
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+ reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); + reg |=1 << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); +} + +static unsigned long _clk_round_rate_div (struct clk *clk, +unsigned long rate, +u32 max_div, +u32 *new_div) +{
ditto.
BTW I don't know why you insist on these silly leading underscores in function names. Please please remove them.
Quoted 22 lines
arch/arm/mach-mx5/clock-mx50.c new file +22
-0+u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div =DIV_ROUND_UP (parent_rate, rate); +if (div > max_div) + div = max_div; +else if (div ==0 ) + div++; +if (new_div !=NULL ) + *new_div = div; + +return parent_rate / div; +} +/* +* For the 4-to-1 muxed input clock +*/ +static inline u32 _get_mux (struct clk *parent,struct clk *m0, +struct clk *m1,struct clk *m2,struct clk *m3) +{ +if (parent == m0) +return 0 ; +else if (parent == m1)
arch/arm/mach-mx5/clock-mx50.c line 194
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+return 1 ; + else if (parent == m2) + return 2; + else if (parent == m3) + return 3; + else +BUG (); + +return 0 ; +}
Also in i.MX51-53 clock support
Quoted 37 lines
arch/arm/mach-mx5/clock-mx50.c new file +37
-0+ +static unsigned long _clk_pll_get_rate (struct clk *clk) +{ +long mfi, mfn, mfd, pdf, ref_clk, mfn_abs; +unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl; +void __iomem *pllbase; +s64 temp; + + pllbase =_get_pll_base (clk); + + dp_ctl =__raw_readl (pllbase +MXC_PLL_DP_CTL ); + pll_hfsm = dp_ctl &MXC_PLL_DP_CTL_HFSM ; + dbl = dp_ctl &MXC_PLL_DP_CTL_DPDCK0_2_EN ; + +if (pll_hfsm ==0 ) { + dp_op =__raw_readl (pllbase +MXC_PLL_DP_OP ); + dp_mfd =__raw_readl (pllbase +MXC_PLL_DP_MFD ); + dp_mfn =__raw_readl (pllbase +MXC_PLL_DP_MFN ); + }else { + dp_op =__raw_readl (pllbase +MXC_PLL_DP_HFS_OP ); + dp_mfd =__raw_readl (pllbase +MXC_PLL_DP_HFS_MFD ); + dp_mfn =__raw_readl (pllbase +MXC_PLL_DP_HFS_MFN ); + } + pdf = dp_op &MXC_PLL_DP_OP_PDF_MASK ; + mfi = (dp_op &MXC_PLL_DP_OP_MFI_MASK ) >>MXC_PLL_DP_OP_MFI_OFFSET ; + mfi = (mfi <=5 ) ?5 : mfi; + mfd = dp_mfd &MXC_PLL_DP_MFD_MASK ; + mfn = mfn_abs = dp_mfn &MXC_PLL_DP_MFN_MASK ; +/* Sign extend to 32-bits */ +if (mfn >=0x04000000 ) { + mfn |=0xFC000000 ; + mfn_abs = -mfn; + } + + ref_clk =2 *clk_get_rate (clk->parent); +if (dbl !=0 ) + ref_clk *=2 ;
arch/arm/mach-mx5/clock-mx50.c line 512
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+ + ref_clk /= (pdf +1 ); + temp = (u64 ) ref_clk * mfn_abs; +do_div (temp, mfd +1 ); +if (mfn <0 ) + temp = -temp; + temp = (ref_clk * mfi) + temp; + +return temp; +}
I just realized we already have this functions in the tree two times.
I stop looking at the clock code at this point.
Please factor out the common code.
We are heading towards an unmaintainable mess with this clock code. I am tempted to say that I won't take any more clock code until we have a common struct clk and an idea how we can make the clock code more readable and maintainable across different almost-the-same-with-subtle-differences-i.MX-variants.
Honestly this clock code shows the complete failure of not the software but the hardware designers. Why must each and every i.MX SoC look different? Why is there no common register layout for one clock which is then repeated for the other clocks?
Quoted 69 lines
arch/arm/plat-mxc/include/mach/iomux-mx50.h new file +63
-0@@ -0,0 +1,595 @@ +/* +* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __MACH_IOMUX_MX50_H__ +#define __MACH_IOMUX_MX50_H__ + +#include <mach/iomux-v3.h> + +/* +* various IOMUX alternate output functions (1-7) +*/ +enum iomux_config { +IOMUX_CONFIG_ALT0 , +IOMUX_CONFIG_ALT1 , +IOMUX_CONFIG_ALT2 , +IOMUX_CONFIG_ALT3 , +IOMUX_CONFIG_ALT4 , +IOMUX_CONFIG_ALT5 , +IOMUX_CONFIG_ALT6 , +IOMUX_CONFIG_ALT7 , +IOMUX_CONFIG_GPIO ,/* added to help user use GPIO mode */ +IOMUX_CONFIG_SION =0x1 <<4 ,/* LOOPBACK:MUX SION bit */ +}; + +#define NON_MUX_I 0 +#define NON_PAD_I NO_PAD_CTRL + +#define IOMUX_TO_IRQ_V3 (pin) (MXC_GPIO_IRQ_START + pin) + +#define MX50_ELCDIF_PAD_CTRL (PAD_CTL_PKE | \ + PAD_CTL_DSE_HIGH) + +#define MX50_WVGA_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_DSE_HIGH) + +#define MX50_SD_PAD_CTRL (PAD_CTL_DSE_HIGH | \ + PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST) + +#define MX50_SD3_PAD_DAT (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_PUS_47K_UP | PAD_CTL_DSE_HIGH) +#define MX50_SD3_PAD_CMD (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_PUS_100K_UP | PAD_CTL_DSE_HIGH) +#define MX50_SD3_PAD_CLK (PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_PUS_47K_UP | PAD_CTL_DSE_HIGH) +#define MX50_UART_PAD_CTRL (PAD_CTL_DSE_HIGH | PAD_CTL_PKE) +#define MX50_I2C_PAD_CTRL (PAD_CTL_ODE | PAD_CTL_DSE_HIGH | \ + PAD_CTL_PUS_100K_UP | PAD_CTL_HYS) +#define MX50_USB_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_DSE_HIGH | PAD_CTL_PUS_47K_UP)
arch/arm/plat-mxc/include/mach/iomux-mx50.h line 73
Quoted 10 lines
arch/arm/plat-mxc/include/mach/iomux-mx50.h new file +10
-0+ +#define MX50_FEC_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_PUS_22K_UP | PAD_CTL_ODE | \ + PAD_CTL_DSE_HIGH) + +#define MX50_OWIRE_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_PUS_100K_UP | PAD_CTL_ODE | \ + PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST) + +#define MX50_PAD_KEY_COL0__GPIO_4_0 IOMUX_PAD(0x2CC, 0x20, 1, 0x0, 0, NO_PAD_CTRL)
^^^^^
We sort the pins by this column. Also it would be really great if you could generate a complete list of the alternate functions from the excel sheets. I am getting really tired of all the iomux patches. I generated the list from the excel sheets for the i.MX35, and now compare the logs:
sha at octopus:~/octopus/linux/linux-2.6 git lg arch/arm/plat-mxc/include/mach/iomux-mx35.h 401d87d arm/imx: remove "NO_PAD_CTRL" from Copyright statements
66ddfc6 mx35: add a missing comma in a pad definition
218deaa MX35: Add iomux pin defintions
sha at octopus:~/octopus/linux/linux-2.6 git lg arch/arm/plat-mxc/include/mach/iomux-mx25.h 6b63226 mx25: add PWM4 to iomux
b04102b mx25: add iomux defines for UART4 on KPP pins
8402ed3 i.MX25: add AUDMUX and SSI support
49535a9 mx25: add platform code for imx-keypad
9b1489e Merge branch 'mxc-master' of git://git.pengutronix.de/git/imx/linux-2.6 into imx/master e76feb8 arm/imx/iomux-mx25: unify style and comment cleanup
401d87d arm/imx: remove "NO_PAD_CTRL" from Copyright statements
0f547dc mx25pdk: add LCD support
dda71f1 mx25: s/NO_PAD_CTL/NO_PAD_CTRL/
8e5be21 i.MX25 iomux definitions (corrected version)
sha at octopus:~/octopus/linux/linux-2.6 git lg arch/arm/plat-mxc/include/mach/iomux-mx51.h 0dea1c7 imx51: fix gpio_4_24 and gpio_4_25 pad configuration
82df68a imx51: add gpio mode for csi1 {h,v}sync
0a7d487 imx51: enhance iomux configuration for esdhc support
db9d423 imx51: fix iomux configuration
47c5382 ARM: imx: Add gpio-keys to plat-mxc
b545d9e iomux-mx51: fix GPIO_1_xx 's IOMUX configuration
217f580 iomux-mx51: fix SD1 and SD2's iomux configuration
4b5ee7a ARM: iomux-mx51: Add AUD5 pinmux definitions
f781bc8 ARM: mx5/iomux-mx51: Fix input path of some pins in gpio mode
2e35bab ARM: mx5/iomux-mx51: Add aud3 primary function defines
8efd927 ARM: mx5/iomux-mx51: Add SPI controller pads
eaa4fd0 ARM: mx5/iomux-mx51: add iomux definitions for eCSPI2 on the imx51_3ds board 3efee47 ARM: mx5/mx51_babbage: Add FEC support
6937aab iomux-mx51: add 4 pin definitions
b3fb53a mx51/iomux: add UART and GPIO pad definitions for imx51_3ds board 310894b mx51/iomux: Fix mux mode and input path for two pads
68d03da [PATCH] mxc: Fix pad names for imx51
71c2e51 mx5: Add i2c to Freescale MX51 Babbage HW
d6b273b mx5: bring usb phy out of reset on freescale mx51 babbage hw
282f152 mxc: Update GPIO for USB support on Freescale MX51 Babbage HW
a329b48 mxc: Core support for Freescale i.MX5 series
arch/arm/plat-mxc/include/mach/irqs.h line 36
Quoted 13 lines
arch/arm/plat-mxc/include/mach/irqs.h +2
-0@@ -29,6 +29,8 @@#define MXC_GPIO_IRQS (32 * 4)#elif definedCONFIG_ARCH_MX25 #define MXC_GPIO_IRQS (32 * 4) +#elif definedCONFIG_SOC_IMX50 +#define MXC_GPIO_IRQS (32 * 6)#elif definedCONFIG_SOC_IMX51 #define MXC_GPIO_IRQS (32 * 4)#elif definedCONFIG_ARCH_MXC91231
Above this block there is the following comment:
/* these are ordered by size to support multi-SoC kernels */
Quoted 60 lines
arch/arm/plat-mxc/include/mach/memory.h +3
-0@@ -16,6 +16,7 @@#define MX25_PHYS_OFFSET UL(0x80000000)#define MX27_PHYS_OFFSET UL(0xa0000000)#define MX3x_PHYS_OFFSET UL(0x80000000) +#define MX50_PHYS_OFFSET UL(0x70000000)#define MX51_PHYS_OFFSET UL(0x90000000)#define MX53_PHYS_OFFSET UL(0x70000000)#define MXC91231_PHYS_OFFSET UL(0x90000000)@@ -33,6 +34,8 @@# define PHYS_OFFSET MX3x_PHYS_OFFSET# elif definedCONFIG_ARCH_MXC91231 # define PHYS_OFFSET MXC91231_PHYS_OFFSET +# elif definedCONFIG_SOC_IMX50 +# define PHYS_OFFSET MX50_PHYS_OFFSET# elif definedCONFIG_ARCH_MX51 # define PHYS_OFFSET MX51_PHYS_OFFSET# elif definedCONFIG_ARCH_MX53 arch/arm/plat-mxc/include/mach/mx50.h new file +33
-0@@ -0,0 +1,306 @@ +#ifndef __MACH_MX50_H__ +#define __MACH_MX50_H__ + +/* +* IROM +*/ +#define MX50_IROM_BASE_ADDR 0x0 +#define MX50_IROM_SIZE SZ_64K + +/* TZIC */ +#define MX50_TZIC_BASE_ADDR 0x0FFFC000 + + +/* +* IRAM +*/ +#define MX50_IRAM_BASE_ADDR 0xF8000000/* internal ram */ +#define MX50_IRAM_PARTITIONS 16 +#define MX50_IRAM_SIZE (MX50_IRAM_PARTITIONS * SZ_8K)/* 128KB */ + +/* +* Databahn +*/ +#define MX50_DATABAHN_BASE_ADDR 0x14000000 +#define DATABAHN_CTL_REG19 0x4c +#define DATABAHN_CTL_REG20 0x50 +#define DATABAHN_CTL_REG21 0x54 +#define DATABAHN_CTL_REG22 0x58 +#define DATABAHN_CTL_REG23 0x5c +#define DATABAHN_CTL_REG42 0xa8 +#define DATABAHN_CTL_REG43 0xac +#define DATABAHN_CTL_REG55 0xdc +#define DATABAHN_CTL_REG63 0xFC
arch/arm/plat-mxc/include/mach/mx50.h line 43
Quoted 10 lines
arch/arm/plat-mxc/include/mach/mx50.h new file +10
-0+#define LOWPOWER_CONTROL_MASK 0x1F +#define LOWPOWER_AUTOENABLE_MASK 0x1F +#define LOWPOWER_EXTERNAL_CNT_MASK (0xFFFF << 16) +#define LOWPOWER_EXTERNAL_CNT_OFFSET 16 +#define LOWPOWER_INTERNAL_CNT_MASK (0xFFFF << 8) +#define LOWPOWER_INTERNAL_CNT_OFFSET 8 +#define LOWPOWER_REFRESH_ENABLE_MASK (3 << 16) +#define LOWPOWER_REFRESH_ENABLE_OFFSET 16 +#define LOWPOWER_REFRESH_HOLD_MASK 0xFFFF +#define LOWPOWER_REFRESH_HOLD_OFFSET 0
What have we learned about properly prefixing defines?
Also, where are these used besides the clock code? Do we really need these to be globally available?
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH 5/6 arm: mx50: add core functions support
Hi Sascha,
Quoted 135 lines · Sascha Hauer
Quoted 134 lines · Richard Zhao
Add core definitions and memory map, clock, gpio, irq, iomux, uart device support.
Signed-off-by Richard Zhao <[email protected]>--- arch/arm/mach-mx5/Kconfig | 8 + arch/arm/mach-mx5/Makefile | 2 + arch/arm/mach-mx5/Makefile.boot | 3 + arch/arm/mach-mx5/clock-mx50.c | 3262 +++++++++++++++++++++++++ arch/arm/mach-mx5/crm_regs-mx50.h | 607 +++++ arch/arm/mach-mx5/devices-mx50.h | 26 + arch/arm/mach-mx5/mm-mx50.c | 60 + arch/arm/plat-mxc/devices/platform-imx-uart.c | 13 + arch/arm/plat-mxc/gpio.c | 14 + arch/arm/plat-mxc/include/mach/common.h | 4 + arch/arm/plat-mxc/include/mach/hardware.h | 1 + arch/arm/plat-mxc/include/mach/iomux-mx50.h | 595 +++++ arch/arm/plat-mxc/include/mach/irqs.h | 2 + arch/arm/plat-mxc/include/mach/memory.h | 3 + arch/arm/plat-mxc/include/mach/mx50.h | 306 +++ arch/arm/plat-mxc/include/mach/mxc.h | 2 + 16 files changed, 4908 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mx5/clock-mx50.c create mode 100644 arch/arm/mach-mx5/crm_regs-mx50.h create mode 100644 arch/arm/mach-mx5/devices-mx50.h create mode 100644 arch/arm/mach-mx5/mm-mx50.c create mode 100644 arch/arm/plat-mxc/include/mach/iomux-mx50.h create mode 100644 arch/arm/plat-mxc/include/mach/mx50.harch/arm/mach-mx5/Kconfig +8
-0@@ -12,6 +12,14 @@ config SOC_IMX51 select ARCH_HAS_CPUFREQ select ARCH_MX51 +config SOC_IMX50 + bool + select MXC_TZIC + select ARCH_MXC_IOMUX_V3 + select ARCH_MXC_AUDMUX_V2 + select ARCH_HAS_CPUFREQ + + comment "MX5 platforms:" config MACH_MX51_BABBAGEarch/arm/mach-mx5/Makefile +2
-0@@ -13,3 +13,5 @@ obj-$(CONFIG_MACH_EUKREA_MBIMX51_BASEBOARD) += eukrea_mbimx51-baseboard.o obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += board-cpuimx51sd.o obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o + +obj-$(CONFIG_SOC_IMX50) += mm-mx50.o clock-mx50.oarch/arm/mach-mx5/Makefile.boot +3
-0@@ -1,3 +1,6 @@ zreladdr-$(CONFIG_SOC_IMX51) := 0x90008000 params_phys-$(CONFIG_SOC_IMX51) := 0x90000100 initrd_phys-$(CONFIG_SOC_IMX51) := 0x90800000 + zreladdr-$(CONFIG_SOC_IMX50) := 0x70008000 +params_phys-$(CONFIG_SOC_IMX50) := 0x70000100 +initrd_phys-$(CONFIG_SOC_IMX50) := 0x70800000arch/arm/mach-mx5/clock-mx50.c new file +59
-0@@ -0,0 +1,3262 @@ +/* +* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/time.h> +#include <linux/hrtimer.h> +#include <linux/mm.h> +#include <linux/errno.h> +#include <linux/delay.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <asm/clkdev.h> +#include <asm/div64.h> +#include <mach/hardware.h> +#include <mach/common.h> +#include <mach/clock.h> + +#include "crm_regs-mx50.h" + +/* External clock values passed-in by the board code */ +static unsigned long external_high_reference, external_low_reference; +static unsigned long oscillator_reference, ckih2_reference; + +static struct clk pll1_main_clk; +static struct clk pll1_sw_clk; +static struct clk pll2_sw_clk; +static struct clk pll3_sw_clk; +static struct clk apbh_dma_clk; +static struct clk apll_clk; +static struct clk pfd0_clk; +static struct clk pfd1_clk; +static struct clk pfd2_clk; +static struct clk pfd3_clk; +static struct clk pfd4_clk; +static struct clk pfd5_clk; +static struct clk pfd6_clk; +static struct clk pfd7_clk; +static struct clk lp_apm_clk; +static struct clk weim_clk[]; +static struct clk ddr_clk; +static struct clk axi_a_clk; +static struct clk axi_b_clk;
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 65
Quoted 6 lines
arch/arm/mach-mx5/clock-mx50.c new file +6
-0+static struct clk gpu2d_clk; + +static void __iomem *pll1_base; +static void __iomem *pll2_base; +static void __iomem *pll3_base; +void __iomem *apll_base;static?
yes
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c line 67
Quoted 3 lines
arch/arm/mach-mx5/clock-mx50.c new file +2
-0+ +void __iomem *databahn;static?
yes
Quoted 47 lines
Quoted 47 lines
arch/arm/mach-mx5/clock-mx50.c new file +46
-0+ +#define DDR_SYNC_MODE 0x30000 +#define SPIN_DELAY 1000000/* in nanoseconds */ +#define WAIT (exp, timeout) \ +({ \ + struct timespec nstimeofday; \ + struct timespec curtime; \ + int result = 1; \ + getnstimeofday(&nstimeofday); \ + while (!(exp)) { \ + getnstimeofday(&curtime); \ + if ((curtime.tv_nsec - nstimeofday.tv_nsec) > (timeout)) { \ + result = 0; \ + break; \ + } \ + } \ + result; \ +}) + +#define MAX_AHB_CLK 133000000 + +static struct clk esdhc3_clk[]; + +static void __calc_pre_post_dividers (u32 div,u32 *pre,u32 *post) +{ +u32 min_pre, temp_pre, old_err, err; + +if (div >=512 ) { + *pre =8 ; + *post =64 ; + }else if (div >=8 ) { + min_pre = (div -1 ) /64 +1 ; + old_err =8 ; +for (temp_pre =8 ; temp_pre >= min_pre; temp_pre--) { + err = div % temp_pre; +if (err ==0 ) { + *pre = temp_pre; +break ; + } + err = temp_pre - err; +if (err < old_err) { + old_err = err; + *pre = temp_pre; + } + } + *post = (div + *pre -1 ) / *pre;
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 118
Quoted 5 lines
arch/arm/mach-mx5/clock-mx50.c new file +5
-0+ }else if (div <8 ) { + *pre = div; + *post =1 ; + } +}We already have this function. It should be made globally available and used here.
so I need to create a new clock.c?
Quoted 48 lines
Quoted 35 lines
arch/arm/mach-mx5/clock-mx50.c new file +34
-0+ +static int _clk_enable (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg); + reg |= MXC_CCM_CCGRx_CG_MASK << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); + +return 0 ; +} + +static int _clk_enable_inrun (struct clk *clk) +{ +u32 reg; + + reg =__raw_readl (clk->enable_reg); + reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); + reg |=1 << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); +return 0 ; +} + +static void _clk_disable (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg); + reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); +__raw_writel (reg, clk->enable_reg); +} + +static void _clk_disable_inwait (struct clk *clk) +{ +u32 reg; + reg =__raw_readl (clk->enable_reg);arch/arm/mach-mx5/clock-mx50.c line 162
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+ reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift); + reg |=1 << clk->enable_shift; +__raw_writel (reg, clk->enable_reg); +} + +static unsigned long _clk_round_rate_div (struct clk *clk, +unsigned long rate, +u32 max_div, +u32 *new_div) +{ditto.
Quoted 2 lines
BTW I don't know why you insist on these silly leading underscores in function names. Please please remove them.
"_" prefix says it's used internally, and avoid conflicts with global symbol. Move to clock.c too?
Quoted 27 lines
Quoted 27 lines
arch/arm/mach-mx5/clock-mx50.c new file +26
-0+u32 div; +u32 parent_rate =clk_get_rate (clk->parent); + + div =DIV_ROUND_UP (parent_rate, rate); +if (div > max_div) + div = max_div; +else if (div ==0 ) + div++; +if (new_div !=NULL ) + *new_div = div; + +return parent_rate / div; +} +/* +* For the 4-to-1 muxed input clock +*/ +static inline u32 _get_mux (struct clk *parent,struct clk *m0, +struct clk *m1,struct clk *m2,struct clk *m3) +{ +if (parent == m0) +return 0 ; +else if (parent == m1) +return 1 ; +else if (parent == m2) +return 2 ; +else if (parent == m3)
Quoted 8 lines
arch/arm/mach-mx5/clock-mx50.c line 194
Quoted 6 lines
arch/arm/mach-mx5/clock-mx50.c new file +6
-0+return 3 ; + else +BUG (); + +return 0 ; +}Also in i.MX51-53 clock support
move to clock.c too
Quoted 61 lines
Quoted 38 lines
arch/arm/mach-mx5/clock-mx50.c new file +37
-0+ +static unsigned long _clk_pll_get_rate (struct clk *clk) +{ +long mfi, mfn, mfd, pdf, ref_clk, mfn_abs; +unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl; +void __iomem *pllbase; +s64 temp; + + pllbase =_get_pll_base (clk); + + dp_ctl =__raw_readl (pllbase +MXC_PLL_DP_CTL ); + pll_hfsm = dp_ctl &MXC_PLL_DP_CTL_HFSM ; + dbl = dp_ctl &MXC_PLL_DP_CTL_DPDCK0_2_EN ; + +if (pll_hfsm ==0 ) { + dp_op =__raw_readl (pllbase +MXC_PLL_DP_OP ); + dp_mfd =__raw_readl (pllbase +MXC_PLL_DP_MFD ); + dp_mfn =__raw_readl (pllbase +MXC_PLL_DP_MFN ); + }else { + dp_op =__raw_readl (pllbase +MXC_PLL_DP_HFS_OP ); + dp_mfd =__raw_readl (pllbase +MXC_PLL_DP_HFS_MFD ); + dp_mfn =__raw_readl (pllbase +MXC_PLL_DP_HFS_MFN ); + } + pdf = dp_op &MXC_PLL_DP_OP_PDF_MASK ; + mfi = (dp_op &MXC_PLL_DP_OP_MFI_MASK ) >>MXC_PLL_DP_OP_MFI_OFFSET ; + mfi = (mfi <=5 ) ?5 : mfi; + mfd = dp_mfd &MXC_PLL_DP_MFD_MASK ; + mfn = mfn_abs = dp_mfn &MXC_PLL_DP_MFN_MASK ; +/* Sign extend to 32-bits */ +if (mfn >=0x04000000 ) { + mfn |=0xFC000000 ; + mfn_abs = -mfn; + } + + ref_clk =2 *clk_get_rate (clk->parent); +if (dbl !=0 ) + ref_clk *=2 ;arch/arm/mach-mx5/clock-mx50.c line 512
Quoted 10 lines
arch/arm/mach-mx5/clock-mx50.c new file +10
-0+ + ref_clk /= (pdf +1 ); + temp = (u64 ) ref_clk * mfn_abs; +do_div (temp, mfd +1 ); +if (mfn <0 ) + temp = -temp; + temp = (ref_clk * mfi) + temp; + +return temp; +}I just realized we already have this functions in the tree two times.
I stop looking at the clock code at this point.
Please factor out the common code.
We are heading towards an unmaintainable mess with this clock code. I am tempted to say that I won't take any more clock code until we have a common struct clk and an idea how we can make the clock code more readable and maintainable across different almost-the-same-with-subtle-differences-i.MX-variants.
Quoted 4 lines
Honestly this clock code shows the complete failure of not the software but the hardware designers. Why must each and every i.MX SoC look different? Why is there no common register layout for one clock which is then repeated for the other clocks?
Well, the problem is the SoCs have already come out. I'll try to work out a common code. The common code will be restrcited to mx5x temporaly?
Quoted 82 lines
Quoted 70 lines
arch/arm/plat-mxc/include/mach/iomux-mx50.h new file +63
-0@@ -0,0 +1,595 @@ +/* +* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __MACH_IOMUX_MX50_H__ +#define __MACH_IOMUX_MX50_H__ + +#include <mach/iomux-v3.h> + +/* +* various IOMUX alternate output functions (1-7) +*/ +enum iomux_config { +IOMUX_CONFIG_ALT0 , +IOMUX_CONFIG_ALT1 , +IOMUX_CONFIG_ALT2 , +IOMUX_CONFIG_ALT3 , +IOMUX_CONFIG_ALT4 , +IOMUX_CONFIG_ALT5 , +IOMUX_CONFIG_ALT6 , +IOMUX_CONFIG_ALT7 , +IOMUX_CONFIG_GPIO ,/* added to help user use GPIO mode */ +IOMUX_CONFIG_SION =0x1 <<4 ,/* LOOPBACK:MUX SION bit */ +}; + +#define NON_MUX_I 0 +#define NON_PAD_I NO_PAD_CTRL + +#define IOMUX_TO_IRQ_V3 (pin) (MXC_GPIO_IRQ_START + pin) + +#define MX50_ELCDIF_PAD_CTRL (PAD_CTL_PKE | \ + PAD_CTL_DSE_HIGH) + +#define MX50_WVGA_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_DSE_HIGH) + +#define MX50_SD_PAD_CTRL (PAD_CTL_DSE_HIGH | \ + PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST) + +#define MX50_SD3_PAD_DAT (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_PUS_47K_UP | PAD_CTL_DSE_HIGH) +#define MX50_SD3_PAD_CMD (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_PUS_100K_UP | PAD_CTL_DSE_HIGH) +#define MX50_SD3_PAD_CLK (PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_PUS_47K_UP | PAD_CTL_DSE_HIGH) +#define MX50_UART_PAD_CTRL (PAD_CTL_DSE_HIGH | PAD_CTL_PKE) +#define MX50_I2C_PAD_CTRL (PAD_CTL_ODE | PAD_CTL_DSE_HIGH | \ + PAD_CTL_PUS_100K_UP | PAD_CTL_HYS) +#define MX50_USB_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_DSE_HIGH | PAD_CTL_PUS_47K_UP)arch/arm/plat-mxc/include/mach/iomux-mx50.h line 73
Quoted 10 lines
arch/arm/plat-mxc/include/mach/iomux-mx50.h new file +10
-0+ +#define MX50_FEC_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_PUS_22K_UP | PAD_CTL_ODE | \ + PAD_CTL_DSE_HIGH) + +#define MX50_OWIRE_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_PUE | \ + PAD_CTL_PUS_100K_UP | PAD_CTL_ODE | \ + PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST) + +#define MX50_PAD_KEY_COL0__GPIO_4_0 IOMUX_PAD(0x2CC, 0x20, 1, 0x0, 0, NO_PAD_CTRL)^^^^^
Quoted 4 lines
We sort the pins by this column. Also it would be really great if you could generate a complete list of the alternate functions from the excel sheets. I am getting really tired of all the iomux patches. I generated the list from the excel sheets for the i.MX35, and now compare the logs:
ok, I'll generate the full list, and sort by pad.
Quoted 56 lines
sha at octopus:~/octopus/linux/linux-2.6 git lg
arch/arm/plat-mxc/include/mach/iomux-mx35.h401d87d arm/imx: remove "NO_PAD_CTRL" from Copyright statements
66ddfc6 mx35: add a missing comma in a pad definition
218deaa MX35: Add iomux pin defintions
sha at octopus:~/octopus/linux/linux-2.6 git lgarch/arm/plat-mxc/include/mach/iomux-mx25.h6b63226 mx25: add PWM4 to iomux
b04102b mx25: add iomux defines for UART4 on KPP pins
8402ed3 i.MX25: add AUDMUX and SSI support
49535a9 mx25: add platform code for imx-keypad
9b1489e Merge branch 'mxc-master' ofgit://git.pengutronix.de/git/imx/linux-2.6into imx/master e76feb8 arm/imx/iomux-mx25: unify style and comment cleanup
401d87d arm/imx: remove "NO_PAD_CTRL" from Copyright statements
0f547dc mx25pdk: add LCD support
dda71f1 mx25: s/NO_PAD_CTL/NO_PAD_CTRL/
8e5be21 i.MX25 iomux definitions (corrected version)
sha at octopus:~/octopus/linux/linux-2.6 git lgarch/arm/plat-mxc/include/mach/iomux-mx51.h0dea1c7 imx51: fixgpio_4_24andgpio_4_25pad configuration
82df68a imx51: add gpio mode for csi1 {h,v}sync
0a7d487 imx51: enhance iomux configuration for esdhc support
db9d423 imx51: fix iomux configuration
47c5382 ARM: imx: Add gpio-keys to plat-mxc
b545d9e iomux-mx51: fixGPIO_1_xx's IOMUX configuration
217f580 iomux-mx51: fix SD1 and SD2's iomux configuration
4b5ee7a ARM: iomux-mx51: Add AUD5 pinmux definitions
f781bc8 ARM: mx5/iomux-mx51: Fix input path of some pins in gpio mode
2e35bab ARM: mx5/iomux-mx51: Add aud3 primary function defines
8efd927 ARM: mx5/iomux-mx51: Add SPI controller pads
eaa4fd0 ARM: mx5/iomux-mx51: add iomux definitions for eCSPI2 on theimx51_3dsboard 3efee47 ARM: mx5/mx51_babbage: Add FEC support
6937aab iomux-mx51: add 4 pin definitions
b3fb53a mx51/iomux: add UART and GPIO pad definitions forimx51_3dsboard 310894b mx51/iomux: Fix mux mode and input path for two pads
68d03da [PATCH] mxc: Fix pad names for imx51
71c2e51 mx5: Add i2c to Freescale MX51 Babbage HW
d6b273b mx5: bring usb phy out of reset on freescale mx51 babbage hw
282f152 mxc: Update GPIO for USB support on Freescale MX51 Babbage HW
a329b48 mxc: Core support for Freescale i.MX5 seriesarch/arm/plat-mxc/include/mach/irqs.h line 36
Quoted 13 lines
arch/arm/plat-mxc/include/mach/irqs.h +2
-0@@ -29,6 +29,8 @@#define MXC_GPIO_IRQS (32 * 4)#elif definedCONFIG_ARCH_MX25 #define MXC_GPIO_IRQS (32 * 4) +#elif definedCONFIG_SOC_IMX50 +#define MXC_GPIO_IRQS (32 * 6)#elif definedCONFIG_SOC_IMX51 #define MXC_GPIO_IRQS (32 * 4)#elif definedCONFIG_ARCH_MXC91231 Above this block there is the following comment:
Quoted 1 line
/* these are ordered by size to support multi-SoC kernels */
ok, I will move it to the first place. But I still think it's just a work around for multi-SoC.
Quoted 66 lines
Quoted 66 lines
arch/arm/plat-mxc/include/mach/memory.h +3
-0@@ -16,6 +16,7 @@#define MX25_PHYS_OFFSET UL(0x80000000)#define MX27_PHYS_OFFSET UL(0xa0000000)#define MX3x_PHYS_OFFSET UL(0x80000000) +#define MX50_PHYS_OFFSET UL(0x70000000)#define MX51_PHYS_OFFSET UL(0x90000000)#define MX53_PHYS_OFFSET UL(0x70000000)#define MXC91231_PHYS_OFFSET UL(0x90000000)@@ -33,6 +34,8 @@# define PHYS_OFFSET MX3x_PHYS_OFFSET# elif definedCONFIG_ARCH_MXC91231 # define PHYS_OFFSET MXC91231_PHYS_OFFSET +# elif definedCONFIG_SOC_IMX50 +# define PHYS_OFFSET MX50_PHYS_OFFSET# elif definedCONFIG_ARCH_MX51 # define PHYS_OFFSET MX51_PHYS_OFFSET# elif definedCONFIG_ARCH_MX53 arch/arm/plat-mxc/include/mach/mx50.h new file +37
-0@@ -0,0 +1,306 @@ +#ifndef __MACH_MX50_H__ +#define __MACH_MX50_H__ + +/* +* IROM +*/ +#define MX50_IROM_BASE_ADDR 0x0 +#define MX50_IROM_SIZE SZ_64K + +/* TZIC */ +#define MX50_TZIC_BASE_ADDR 0x0FFFC000 + + +/* +* IRAM +*/ +#define MX50_IRAM_BASE_ADDR 0xF8000000/* internal ram */ +#define MX50_IRAM_PARTITIONS 16 +#define MX50_IRAM_SIZE (MX50_IRAM_PARTITIONS * SZ_8K)/* 128KB */ + +/* +* Databahn +*/ +#define MX50_DATABAHN_BASE_ADDR 0x14000000 +#define DATABAHN_CTL_REG19 0x4c +#define DATABAHN_CTL_REG20 0x50 +#define DATABAHN_CTL_REG21 0x54 +#define DATABAHN_CTL_REG22 0x58 +#define DATABAHN_CTL_REG23 0x5c +#define DATABAHN_CTL_REG42 0xa8 +#define DATABAHN_CTL_REG43 0xac +#define DATABAHN_CTL_REG55 0xdc +#define DATABAHN_CTL_REG63 0xFC +#define LOWPOWER_CONTROL_MASK 0x1F +#define LOWPOWER_AUTOENABLE_MASK 0x1F +#define LOWPOWER_EXTERNAL_CNT_MASK (0xFFFF << 16) +#define LOWPOWER_EXTERNAL_CNT_OFFSET 16
Quoted 8 lines
arch/arm/plat-mxc/include/mach/mx50.h line 43
Quoted 6 lines
arch/arm/plat-mxc/include/mach/mx50.h new file +6
-0+#define LOWPOWER_INTERNAL_CNT_MASK (0xFFFF << 8) +#define LOWPOWER_INTERNAL_CNT_OFFSET 8 +#define LOWPOWER_REFRESH_ENABLE_MASK (3 << 16) +#define LOWPOWER_REFRESH_ENABLE_OFFSET 16 +#define LOWPOWER_REFRESH_HOLD_MASK 0xFFFF +#define LOWPOWER_REFRESH_HOLD_OFFSET 0What have we learned about properly prefixing defines?
my fault.
Quoted 3 lines
Also, where are these used besides the clock code? Do we really need these to be globally available?
In freescale code, it's used in:mach-mx5/cpu.c
|/pm.c
|/clock_mx50.cplat-mxc/zq_calib.c
Quoted 7 lines
--
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Thanks
Richard
PATCH 6/6 arm: mx50: add mx50 reference design board support
In reply to Richard ZhaoAdd basic function and uart device support.
--- arch/arm/mach-mx5/Kconfig | 11 ++ arch/arm/mach-mx5/Makefile | 1 + arch/arm/mach-mx5/board-mx50_rdp.c | 232 +++++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/uncompress.h | 4 + 4 files changed, 248 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mx5/board-mx50_rdp.c
arch/arm/mach-mx5/Kconfig +11 -0
@@ -108,4 +108,15 @@ config MACH_MX51_EFIKAMX Include support for Genesi Efika MX nettop. This includes specific configurations for the board and its peripherals. +config MACH_MX50_RDP + bool "Support MX50 reference design board" + select SOC_IMX50 + select IMX_HAVE_PLATFORM_IMX_I2C + select IMX_HAVE_PLATFORM_IMX_UART + select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX + select IMX_HAVE_PLATFORM_SPI_IMX + help + Include support for MX50 reference design board. This includes specific + configurations for the board and its peripherals. + endif
arch/arm/mach-mx5/Makefile +1 -0
@@ -15,3 +15,4 @@ obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o obj-$(CONFIG_SOC_IMX50) += mm-mx50.o clock-mx50.o +obj-$(CONFIG_MACH_MX50_RDP) += board-mx50_rdp.o
arch/arm/mach-mx5/board-mx50_rdp.c new file +232 -0
232 lines not on this page · raw message
arch/arm/plat-mxc/include/mach/uncompress.h +4 -0
@@ -63,6 +63,7 @@ static inline void flush(void)#define MX3X_UART1_BASE_ADDR 0x43F90000#define MX3X_UART2_BASE_ADDR 0x43F94000#define MX51_UART1_BASE_ADDR 0x73fbc000 +#define MX50_UART1_BASE_ADDR 0x53fbc000static __inline__void __arch_decomp_setup (unsigned long arch_id) {
@@ -102,6 +103,9 @@ static __inline__ void __arch_decomp_setup(unsigned long arch_id)case MACH_TYPE_EUKREA_CPUIMX51SD : uart_base =MX51_UART1_BASE_ADDR ;break ; +case MACH_TYPE_MX50_RDP : + uart_base =MX50_UART1_BASE_ADDR ; +break ;default :break ; }
Signature · 1 line
1.6.3.3
PATCH 6/6 arm: mx50: add mx50 reference design board support
Quoted 8 lines · Richard Zhao
Add basic function and uart device support.
Signed-off-by Richard Zhao <[email protected]>--- arch/arm/mach-mx5/Kconfig | 11 ++ arch/arm/mach-mx5/Makefile | 1 + arch/arm/mach-mx5/board-mx50_rdp.c | 232 +++++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/uncompress.h | 4 +
uncompress.h should come earlier in the series
arch/arm/mach-mx5/Kconfig config MACH_MX51_EFIKAMX · line 112
Quoted 13 lines
4 files changed, 248 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mx5/board-mx50_rdp.carch/arm/mach-mx5/Kconfig +2
-0@@ -108,4 +108,15 @@ config MACH_MX51_EFIKAMX Include support for Genesi Efika MX nettop. This includes specific configurations for the board and its peripherals. +config MACH_MX50_RDP + bool "Support MX50 reference design board"
P as in "board"?
Quoted 71 lines
arch/arm/mach-mx5/Kconfig +9
-0+ select SOC_IMX50 + select IMX_HAVE_PLATFORM_IMX_I2C + select IMX_HAVE_PLATFORM_IMX_UART + select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX + select IMX_HAVE_PLATFORM_SPI_IMX + help + Include support for MX50 reference design board. This includes specific + configurations for the board and its peripherals. + endifarch/arm/mach-mx5/Makefile +1
-0@@ -15,3 +15,4 @@ obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o obj-$(CONFIG_SOC_IMX50) += mm-mx50.o clock-mx50.o +obj-$(CONFIG_MACH_MX50_RDP) += board-mx50_rdp.oarch/arm/mach-mx5/board-mx50_rdp.c new file +46
-0@@ -0,0 +1,232 @@ +/* +* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. +*/ + +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/delay.h> +#include <linux/pm.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/init.h> +#include <linux/input.h> +#include <linux/nodemask.h> +#include <linux/clk.h> +#include <linux/platform_device.h> +#include <linux/fsl_devices.h> +#include <linux/spi/spi.h> +#include <linux/i2c.h> +#include <linux/ata.h> +#include <linux/mtd/mtd.h> +#include <linux/mtd/map.h> +#include <linux/mtd/partitions.h> +#include <linux/pwm_backlight.h> +#include <linux/fec.h> + +#include <mach/common.h> +#include <mach/hardware.h> +#include <mach/memory.h> +#include <mach/gpio.h> +#include <mach/mmc.h>
arch/arm/mach-mx5/board-mx50_rdp.c line 56
Quoted 10 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +10
-0+#include <mach/iomux-mx50.h> +#include <mach/i2c.h> +#include <mach/imx-uart.h> + +#include <asm/irq.h> +#include <asm/setup.h> +#include <asm/mach-types.h> +#include <asm/mach/arch.h> +#include <asm/mach/time.h> +#include <asm/mach/flash.h>
are you sure you need all of these?
arch/arm/mach-mx5/board-mx50_rdp.c line 60
Quoted 4 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +4
-0+ +#include "devices-mx50.h" + +static iomux_v3_cfg_t mx50rdp_pads[] = {
const? __initconst?
Quoted 117 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +117
-0+/* SD1 */ +MX50_PAD_ECSPI2_SS0__GPIO_4_19 , +MX50_PAD_EIM_CRE__GPIO_1_27 , +MX50_PAD_SD1_CMD__SD1_CMD , + +MX50_PAD_SD1_CLK__SD1_CLK , +MX50_PAD_SD1_D0__SD1_D0 , +MX50_PAD_SD1_D1__SD1_D1 , +MX50_PAD_SD1_D2__SD1_D2 , +MX50_PAD_SD1_D3__SD1_D3 , + +/* SD2 */ +MX50_PAD_SD2_CD__GPIO_5_17 , +MX50_PAD_SD2_WP__GPIO_5_16 , +MX50_PAD_SD2_CMD__SD2_CMD , +MX50_PAD_SD2_CLK__SD2_CLK , +MX50_PAD_SD2_D0__SD2_D0 , +MX50_PAD_SD2_D1__SD2_D1 , +MX50_PAD_SD2_D2__SD2_D2 , +MX50_PAD_SD2_D3__SD2_D3 , +MX50_PAD_SD2_D4__SD2_D4 , +MX50_PAD_SD2_D5__SD2_D5 , +MX50_PAD_SD2_D6__SD2_D6 , +MX50_PAD_SD2_D7__SD2_D7 , + +/* SD3 */ +MX50_PAD_SD3_CMD__SD3_CMD , +MX50_PAD_SD3_CLK__SD3_CLK , +MX50_PAD_SD3_D0__SD3_D0 , +MX50_PAD_SD3_D1__SD3_D1 , +MX50_PAD_SD3_D2__SD3_D2 , +MX50_PAD_SD3_D3__SD3_D3 , +MX50_PAD_SD3_D4__SD3_D4 , +MX50_PAD_SD3_D5__SD3_D5 , +MX50_PAD_SD3_D6__SD3_D6 , +MX50_PAD_SD3_D7__SD3_D7 , + +/* PWR_INT */ +MX50_PAD_ECSPI2_MISO__GPIO_4_18 , + +/* UART pad setting */ +MX50_PAD_UART1_TXD__UART1_TXD , +MX50_PAD_UART1_RXD__UART1_RXD , +MX50_PAD_UART1_RTS__UART1_RTS , +MX50_PAD_UART2_TXD__UART2_TXD , +MX50_PAD_UART2_RXD__UART2_RXD , +MX50_PAD_UART2_CTS__UART2_CTS , +MX50_PAD_UART2_RTS__UART2_RTS , + +MX50_PAD_I2C1_SCL__I2C1_SCL , +MX50_PAD_I2C1_SDA__I2C1_SDA , +MX50_PAD_I2C2_SCL__I2C2_SCL , +MX50_PAD_I2C2_SDA__I2C2_SDA , + +MX50_PAD_EPITO__USBH1_PWR , +/* Need to comment below line if +* one needs to debug owire. +*/ +MX50_PAD_OWIRE__USBH1_OC , +/* using gpio to control otg pwr */ +MX50_PAD_PWM2__GPIO_6_25 , +MX50_PAD_I2C3_SCL__USBOTG_OC , + +MX50_PAD_SSI_RXC__FEC_MDIO , +MX50_PAD_SSI_RXC__FEC_MDIO , +MX50_PAD_DISP_D0__FEC_TXCLK , +MX50_PAD_DISP_D1__FEC_RX_ER , +MX50_PAD_DISP_D2__FEC_RX_DV , +MX50_PAD_DISP_D3__FEC_RXD1 , +MX50_PAD_DISP_D4__FEC_RXD0 , +MX50_PAD_DISP_D5__FEC_TX_EN , +MX50_PAD_DISP_D6__FEC_TXD1 , +MX50_PAD_DISP_D7__FEC_TXD0 , +MX50_PAD_SSI_RXFS__FEC_MDC , +MX50_PAD_I2C3_SDA__GPIO_6_23 , +MX50_PAD_ECSPI1_SCLK__GPIO_4_12 , + +MX50_PAD_CSPI_SS0__CSPI_SS0 , +MX50_PAD_ECSPI1_MOSI__CSPI_SS1 , +MX50_PAD_CSPI_MOSI__CSPI_MOSI , +MX50_PAD_CSPI_MISO__CSPI_MISO , + +/* SGTL500_OSC_EN */ +MX50_PAD_UART1_CTS__GPIO_6_8 , + +/* SGTL_AMP_SHDN */ +MX50_PAD_UART3_RXD__GPIO_6_15 , + +/* Keypad */ +MX50_PAD_KEY_COL0__KEY_COL0 , +MX50_PAD_KEY_ROW0__KEY_ROW0 , +MX50_PAD_KEY_COL1__KEY_COL1 , +MX50_PAD_KEY_ROW1__KEY_ROW1 , +MX50_PAD_KEY_COL2__KEY_COL2 , +MX50_PAD_KEY_ROW2__KEY_ROW2 , +MX50_PAD_KEY_COL3__KEY_COL3 , +MX50_PAD_KEY_ROW3__KEY_ROW3 , +MX50_PAD_EIM_DA0__KEY_COL4 , +MX50_PAD_EIM_DA1__KEY_ROW4 , +MX50_PAD_EIM_DA2__KEY_COL5 , +MX50_PAD_EIM_DA3__KEY_ROW5 , +MX50_PAD_EIM_DA4__KEY_COL6 , +MX50_PAD_EIM_DA5__KEY_ROW6 , +MX50_PAD_EIM_DA6__KEY_COL7 , +MX50_PAD_EIM_DA7__KEY_ROW7 , +/*EIM pads */ +MX50_PAD_EIM_DA8__GPIO_1_8 , +MX50_PAD_EIM_DA9__GPIO_1_9 , +MX50_PAD_EIM_DA10__GPIO_1_10 , +MX50_PAD_EIM_DA11__GPIO_1_11 , +MX50_PAD_EIM_DA12__GPIO_1_12 , +MX50_PAD_EIM_DA13__GPIO_1_13 , +MX50_PAD_EIM_DA14__GPIO_1_14 , +MX50_PAD_EIM_DA15__GPIO_1_15 , +MX50_PAD_EIM_CS2__GPIO_1_16 , +MX50_PAD_EIM_CS1__GPIO_1_17 , + MX50_PAD_EIM_CS0__GPIO_1_18,
arch/arm/mach-mx5/board-mx50_rdp.c line 187
Quoted 10 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +10
-0+MX50_PAD_EIM_EB0__GPIO_1_19 , +MX50_PAD_EIM_EB1__GPIO_1_20 , +MX50_PAD_EIM_WAIT__GPIO_1_21 , +MX50_PAD_EIM_BCLK__GPIO_1_22 , +MX50_PAD_EIM_RDY__GPIO_1_23 , + MX50_PAD_EIM_OE__GPIO_1_24, +}; + +/* Serial ports */ +#if defined(CONFIG_SERIAL_IMX ) || defined(CONFIG_SERIAL_IMX_MODULE )
please add all devices unconditionally
Quoted 6 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +6
-0+static const struct imxuart_platform_data uart_pdata__initconst = { + .flags =IMXUART_HAVE_RTSCTS , +}; + +static inline void mxc_init_imx_uart (void ) +{
arch/arm/mach-mx5/board-mx50_rdp.c line 203
Quoted 10 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +10
-0+imx50_add_imx_uart (0 , &uart_pdata); + imx50_add_imx_uart(1, &uart_pdata); +} +#else /* !SERIAL_IMX */ +static inline void mxc_init_imx_uart (void ) +{ +} +#endif /* SERIAL_IMX */ + +/*!
s/!//
Quoted 56 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +29
-0+* Board specific initialization. +*/ +static void __init mxc_board_init (void ) +{ +mxc_iomux_v3_setup_multiple_pads (mx50rdp_pads, +ARRAY_SIZE (mx50rdp_pads)); +mxc_init_imx_uart (); + +} + +static void __init mx50_rdp_timer_init (void ) +{ +mx50_clocks_init (32768 ,24000000 ,22579200 ); +} + +static struct sys_timer mxc_timer = { + .init = mx50_rdp_timer_init, +}; + +/* +* The following uses standard kernel macros define in arch.h in order to +* initialize __mach_desc_MX50_RDP data structure. +*/ +MACHINE_START (MX50_RDP ,"Freescale MX50 Reference Design Platform" ) + .map_io = mx50_map_io, + .init_irq = mx50_init_irq, + .init_machine = mxc_board_init, + .timer = &mxc_timer, +MACHINE_END arch/arm/plat-mxc/include/mach/uncompress.h +4
-0@@ -63,6 +63,7 @@ static inline void flush(void)#define MX3X_UART1_BASE_ADDR 0x43F90000#define MX3X_UART2_BASE_ADDR 0x43F94000#define MX51_UART1_BASE_ADDR 0x73fbc000 +#define MX50_UART1_BASE_ADDR 0x53fbc000static __inline__void __arch_decomp_setup (unsigned long arch_id) {@@ -102,6 +103,9 @@ static __inline__ void __arch_decomp_setup(unsigned long arch_id)case MACH_TYPE_EUKREA_CPUIMX51SD : uart_base =MX51_UART1_BASE_ADDR ;break ; +case MACH_TYPE_MX50_RDP : + uart_base =MX50_UART1_BASE_ADDR ; +break ;default :break ; }Signature · 1 line
1.6.3.3
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 6/6 arm: mx50: add mx50 reference design board support
2010/12/9 Uwe Kleine-K?nig <[email protected]>:
Quoted 10 lines · Richard Zhao
Quoted 8 lines
Add basic function and uart device support.
Signed-off-by Richard Zhao <[email protected]>---
?arch/arm/mach-mx5/Kconfig ? ? ? ? ? ? ? ? ? | ? 11 ++ ?arch/arm/mach-mx5/Makefile ? ? ? ? ? ? ? ? ?| ? ?1 + ?arch/arm/mach-mx5/board-mx50_rdp.c ? ? ? ? ?| ?232 +++++++++++++++++++++++++++ ?arch/arm/plat-mxc/include/mach/uncompress.h | ? ?4 +
uncompress.hshould come earlier in the series
uart_base need board level definition.
Quoted 12 lines
Quoted 12 lines
?4 files changed, 248 insertions(+), 0 deletions(-) ?create mode 100644
arch/arm/mach-mx5/board-mx50_rdp.carch/arm/mach-mx5/Kconfig +0
-0@@ -108,4 +108,15 @@ config MACH_MX51_EFIKAMX? ? ? ? Include support for Genesi Efika MX nettop. This includes specific ? ? ? ? configurations for the board and its peripherals.
Quoted 3 lines
Quoted 2 lines
+config
MACH_MX50_RDP
+ ? ? bool "Support MX50 reference design board"P as in "board"?
It's platform. Change it to "Support MX50 reference design platform"
Quoted 75 lines
Quoted 75 lines
+ ? ? select
SOC_IMX50
+ ? ? selectIMX_HAVE_PLATFORM_IMX_I2C
+ ? ? selectIMX_HAVE_PLATFORM_IMX_UART
+ ? ? selectIMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
+ ? ? selectIMX_HAVE_PLATFORM_SPI_IMX
+ ? ? help
+ ? ? ? Include support for MX50 reference design board. This includes specific
+ ? ? ? configurations for the board and its peripherals.
+
?endifarch/arm/mach-mx5/Makefile +0
-0@@ -15,3 +15,4 @@ obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o?obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o
?obj-$(CONFIG_SOC_IMX50) += mm-mx50.o clock-mx50.o
arch/arm/mach-mx5/Makefile +1
-0+obj-$(CONFIG_MACH_MX50_RDP) += board-mx50_rdp.oarch/arm/mach-mx5/board-mx50_rdp.c new file +49
-0@@ -0,0 +1,232 @@ +/* +* Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. +*/ + +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ?See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/delay.h> +#include <linux/pm.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/init.h> +#include <linux/input.h> +#include <linux/nodemask.h> +#include <linux/clk.h> +#include <linux/platform_device.h> +#include <linux/fsl_devices.h> +#include <linux/spi/spi.h> +#include <linux/i2c.h> +#include <linux/ata.h> +#include <linux/mtd/mtd.h> +#include <linux/mtd/map.h> +#include <linux/mtd/partitions.h> +#include <linux/pwm_backlight.h> +#include <linux/fec.h> + +#include <mach/common.h> +#include <mach/hardware.h> +#include <mach/memory.h> +#include <mach/gpio.h> +#include <mach/mmc.h> +#include <mach/iomux-mx50.h> +#include <mach/i2c.h> +#include <mach/imx-uart.h>
Quoted 8 lines
arch/arm/mach-mx5/board-mx50_rdp.c line 56
Quoted 7 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +7
-0+ +#include <asm/irq.h> +#include <asm/setup.h> +#include <asm/mach-types.h> +#include <asm/mach/arch.h> +#include <asm/mach/time.h> +#include <asm/mach/flash.h> are you sure you need all of these?
I'll check it.
Quoted 6 lines
arch/arm/mach-mx5/board-mx50_rdp.c line 60
Quoted 5 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +4
-0+ +#include "devices-mx50.h" + +static iomux_v3_cfg_t mx50rdp_pads[] = {const?
__initconst?
OK
Quoted 121 lines
Quoted 121 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +120
-0+ ? ? /* SD1 */ + ? ? MX50_PAD_ECSPI2_SS0__GPIO_4_19, + ? ? MX50_PAD_EIM_CRE__GPIO_1_27, + ? ? MX50_PAD_SD1_CMD__SD1_CMD, + + ? ? MX50_PAD_SD1_CLK__SD1_CLK, + ? ? MX50_PAD_SD1_D0__SD1_D0, + ? ? MX50_PAD_SD1_D1__SD1_D1, + ? ? MX50_PAD_SD1_D2__SD1_D2, + ? ? MX50_PAD_SD1_D3__SD1_D3, + + ? ? /* SD2 */ + ? ? MX50_PAD_SD2_CD__GPIO_5_17, + ? ? MX50_PAD_SD2_WP__GPIO_5_16, + ? ? MX50_PAD_SD2_CMD__SD2_CMD, + ? ? MX50_PAD_SD2_CLK__SD2_CLK, + ? ? MX50_PAD_SD2_D0__SD2_D0, + ? ? MX50_PAD_SD2_D1__SD2_D1, + ? ? MX50_PAD_SD2_D2__SD2_D2, + ? ? MX50_PAD_SD2_D3__SD2_D3, + ? ? MX50_PAD_SD2_D4__SD2_D4, + ? ? MX50_PAD_SD2_D5__SD2_D5, + ? ? MX50_PAD_SD2_D6__SD2_D6, + ? ? MX50_PAD_SD2_D7__SD2_D7, + + ? ? /* SD3 */ + ? ? MX50_PAD_SD3_CMD__SD3_CMD, + ? ? MX50_PAD_SD3_CLK__SD3_CLK, + ? ? MX50_PAD_SD3_D0__SD3_D0, + ? ? MX50_PAD_SD3_D1__SD3_D1, + ? ? MX50_PAD_SD3_D2__SD3_D2, + ? ? MX50_PAD_SD3_D3__SD3_D3, + ? ? MX50_PAD_SD3_D4__SD3_D4, + ? ? MX50_PAD_SD3_D5__SD3_D5, + ? ? MX50_PAD_SD3_D6__SD3_D6, + ? ? MX50_PAD_SD3_D7__SD3_D7, + + ? ? /* PWR_INT */ + ? ? MX50_PAD_ECSPI2_MISO__GPIO_4_18, + + ? ? /* UART pad setting */ + ? ? MX50_PAD_UART1_TXD__UART1_TXD, + ? ? MX50_PAD_UART1_RXD__UART1_RXD, + ? ? MX50_PAD_UART1_RTS__UART1_RTS, + ? ? MX50_PAD_UART2_TXD__UART2_TXD, + ? ? MX50_PAD_UART2_RXD__UART2_RXD, + ? ? MX50_PAD_UART2_CTS__UART2_CTS, + ? ? MX50_PAD_UART2_RTS__UART2_RTS, + + ? ? MX50_PAD_I2C1_SCL__I2C1_SCL, + ? ? MX50_PAD_I2C1_SDA__I2C1_SDA, + ? ? MX50_PAD_I2C2_SCL__I2C2_SCL, + ? ? MX50_PAD_I2C2_SDA__I2C2_SDA, + + ? ? MX50_PAD_EPITO__USBH1_PWR, + ? ? /* Need to comment below line if +? ? ?* one needs to debug owire. +? ? ?*/ + ? ? MX50_PAD_OWIRE__USBH1_OC, + ? ? /* using gpio to control otg pwr */ + ? ? MX50_PAD_PWM2__GPIO_6_25, + ? ? MX50_PAD_I2C3_SCL__USBOTG_OC, + + ? ? MX50_PAD_SSI_RXC__FEC_MDIO, + ? ? MX50_PAD_SSI_RXC__FEC_MDIO, + ? ? MX50_PAD_DISP_D0__FEC_TXCLK, + ? ? MX50_PAD_DISP_D1__FEC_RX_ER, + ? ? MX50_PAD_DISP_D2__FEC_RX_DV, + ? ? MX50_PAD_DISP_D3__FEC_RXD1, + ? ? MX50_PAD_DISP_D4__FEC_RXD0, + ? ? MX50_PAD_DISP_D5__FEC_TX_EN, + ? ? MX50_PAD_DISP_D6__FEC_TXD1, + ? ? MX50_PAD_DISP_D7__FEC_TXD0, + ? ? MX50_PAD_SSI_RXFS__FEC_MDC, + ? ? MX50_PAD_I2C3_SDA__GPIO_6_23, + ? ? MX50_PAD_ECSPI1_SCLK__GPIO_4_12, + + ? ? MX50_PAD_CSPI_SS0__CSPI_SS0, + ? ? MX50_PAD_ECSPI1_MOSI__CSPI_SS1, + ? ? MX50_PAD_CSPI_MOSI__CSPI_MOSI, + ? ? MX50_PAD_CSPI_MISO__CSPI_MISO, + + ? ? /* SGTL500_OSC_EN */ + ? ? MX50_PAD_UART1_CTS__GPIO_6_8, + + ? ? /* SGTL_AMP_SHDN */ + ? ? MX50_PAD_UART3_RXD__GPIO_6_15, + + ? ? /* Keypad */ + ? ? MX50_PAD_KEY_COL0__KEY_COL0, + ? ? MX50_PAD_KEY_ROW0__KEY_ROW0, + ? ? MX50_PAD_KEY_COL1__KEY_COL1, + ? ? MX50_PAD_KEY_ROW1__KEY_ROW1, + ? ? MX50_PAD_KEY_COL2__KEY_COL2, + ? ? MX50_PAD_KEY_ROW2__KEY_ROW2, + ? ? MX50_PAD_KEY_COL3__KEY_COL3, + ? ? MX50_PAD_KEY_ROW3__KEY_ROW3, + ? ? MX50_PAD_EIM_DA0__KEY_COL4, + ? ? MX50_PAD_EIM_DA1__KEY_ROW4, + ? ? MX50_PAD_EIM_DA2__KEY_COL5, + ? ? MX50_PAD_EIM_DA3__KEY_ROW5, + ? ? MX50_PAD_EIM_DA4__KEY_COL6, + ? ? MX50_PAD_EIM_DA5__KEY_ROW6, + ? ? MX50_PAD_EIM_DA6__KEY_COL7, + ? ? MX50_PAD_EIM_DA7__KEY_ROW7, + ? ? /*EIM pads */ + ? ? MX50_PAD_EIM_DA8__GPIO_1_8, + ? ? MX50_PAD_EIM_DA9__GPIO_1_9, + ? ? MX50_PAD_EIM_DA10__GPIO_1_10, + ? ? MX50_PAD_EIM_DA11__GPIO_1_11, + ? ? MX50_PAD_EIM_DA12__GPIO_1_12, + ? ? MX50_PAD_EIM_DA13__GPIO_1_13, + ? ? MX50_PAD_EIM_DA14__GPIO_1_14, + ? ? MX50_PAD_EIM_DA15__GPIO_1_15, + ? ? MX50_PAD_EIM_CS2__GPIO_1_16, + ? ? MX50_PAD_EIM_CS1__GPIO_1_17, + ? ? MX50_PAD_EIM_CS0__GPIO_1_18, + ? ? MX50_PAD_EIM_EB0__GPIO_1_19, + ? ? MX50_PAD_EIM_EB1__GPIO_1_20, + ? ? MX50_PAD_EIM_WAIT__GPIO_1_21,
Quoted 8 lines
arch/arm/mach-mx5/board-mx50_rdp.c line 187
Quoted 7 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +7
-0+ ? ? MX50_PAD_EIM_BCLK__GPIO_1_22, + ? ? MX50_PAD_EIM_RDY__GPIO_1_23, + ? ? MX50_PAD_EIM_OE__GPIO_1_24, +}; + +/* Serial ports */ +#if defined(CONFIG_SERIAL_IMX ) || defined(CONFIG_SERIAL_IMX_MODULE )please add all devices unconditionally
ok
Quoted 10 lines
Quoted 10 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +9
-0+static const struct imxuart_platform_data uart_pdata__initconst = { + ? ? .flags = IMXUART_HAVE_RTSCTS, +}; + +static inline void mxc_init_imx_uart (void ) +{ + ? ? imx50_add_imx_uart(0, &uart_pdata); + ? ? imx50_add_imx_uart(1, &uart_pdata); +}
Quoted 8 lines
arch/arm/mach-mx5/board-mx50_rdp.c line 203
Quoted 7 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +7
-0+#else /* !SERIAL_IMX */ +static inline void mxc_init_imx_uart (void ) +{ +} +#endif /* SERIAL_IMX */ + +/*! s/!//
Yes
Quoted 59 lines
Quoted 46 lines
arch/arm/mach-mx5/board-mx50_rdp.c new file +29
-0+* Board specific initialization. +*/ +static void __init mxc_board_init (void ) +{ + ? ? mxc_iomux_v3_setup_multiple_pads(mx50rdp_pads, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ARRAY_SIZE(mx50rdp_pads)); + ? ? mxc_init_imx_uart(); + +} + +static void __init mx50_rdp_timer_init (void ) +{ + ? ? mx50_clocks_init(32768, 24000000, 22579200); +} + +static struct sys_timer mxc_timer = { + ? ? .init ? = mx50_rdp_timer_init, +}; + +/* +* The following uses standard kernel macros define in arch.h in order to +* initialize __mach_desc_MX50_RDP data structure. +*/ +MACHINE_START (MX50_RDP ,"Freescale MX50 Reference Design Platform" ) + ? ? .map_io = mx50_map_io, + ? ? .init_irq = mx50_init_irq, + ? ? .init_machine = mxc_board_init, + ? ? .timer = &mxc_timer, +MACHINE_END arch/arm/plat-mxc/include/mach/uncompress.h +0
-0@@ -63,6 +63,7 @@ static inline void flush(void)?#define
MX3X_UART1_BASE_ADDR0x43F90000
?#defineMX3X_UART2_BASE_ADDR0x43F94000
?#defineMX51_UART1_BASE_ADDR0x73fbc000
+#defineMX50_UART1_BASE_ADDR0x53fbc000?static
__inline__void__arch_decomp_setup(unsigned long arch_id)?{arch/arm/plat-mxc/include/mach/uncompress.h +0
-0@@ -102,6 +103,9 @@ static __inline__ void __arch_decomp_setup(unsigned long arch_id)? ? ? case
MACH_TYPE_EUKREA_CPUIMX51SD:
? ? ? ? ? ? ?uart_base=MX51_UART1_BASE_ADDR;
? ? ? ? ? ? ? break;Quoted 11 lines
+ ? ? case
MACH_TYPE_MX50_RDP:
+ ? ? ? ? ? ?uart_base=MX50_UART1_BASE_ADDR;
+ ? ? ? ? ? ? break;
? ? ? default:
? ? ? ? ? ? ? break;
? ? ? }
--
1.6.3.3--
Quoted 3 lines
Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | Uwe Kleine-K?nig ? ? ? ? ? ?| Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
Thanks
Richard