Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'soc' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc

Pull "ARM: SoC specific updates" from Arnd Bergmann:
"These changes are all specific to an soc family or the code for one
soc. Lots of work for Tegra3 this time, but also a lot of other
platforms. There will be another (smaller) set of soc patches later
in the merge window for stuff that has dependencies on external trees
or that was sent just before the merge window opened.

The asoc tree added a few devices to the i.mx platform, which conflict
with other devices added in the same place here.

The tegra Makefile conflicts between a number of branches, mostly
because of changes regarding localtimer.c, which was removed in the
end.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>"

Fix up some trivial conflicts, including the mentioned Tegra Makefile.

* tag 'soc' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (51 commits)
ARM: EXYNOS: fix cycle count for periodic mode of clock event timers
ARM: EXYNOS: add support JPEG
ARM: EXYNOS: Add DMC1, allow PPMU access for DMC
ARM: SAMSUNG: Correct MIPI-CSIS io memory resource definition
ARM: SAMSUNG: fix __init attribute on regarding s3c_set_platdata()
ARM: SAMSUNG: Add __init attribute to samsung_bl_set()
ARM: S5PV210: Add usb otg phy control
ARM: S3C64XX: Add usb otg phy control
ARM: EXYNOS: Enable l2 configuration through device tree
ARM: EXYNOS: remove useless code to save/restore L2
ARM: EXYNOS: save L2 settings during bootup
ARM: S5P: add L2 early resume code
ARM: EXYNOS: Add support AFTR mode on EXYNOS4210
ARM: mx35: Setup the AIPS registers
ARM: mx5: Use common function for configuring AIPS
ARM: mx3: Setup AIPS registers
ARM: mx3: Let mx31 and mx35 enter in LPM mode in WFI
ARM: defconfig: imx_v6_v7: build in REGULATOR_FIXED_VOLTAGE
ARM: imx: update imx_v6_v7_defconfig
ARM: tegra: Demote EMC clock inconsistency BUG to WARN
...

+5351 -346
+1
arch/arm/Kconfig
··· 1131 1131 config ARM_TIMER_SP804 1132 1132 bool 1133 1133 select CLKSRC_MMIO 1134 + select HAVE_SCHED_CLOCK 1134 1135 1135 1136 source arch/arm/mm/Kconfig 1136 1137
+37
arch/arm/boot/dts/at91sam9g25ek.dts
··· 1 + /* 2 + * at91sam9g25ek.dts - Device Tree file for AT91SAM9G25-EK board 3 + * 4 + * Copyright (C) 2012 Atmel, 5 + * 2012 Nicolas Ferre <nicolas.ferre@atmel.com> 6 + * 7 + * Licensed under GPLv2 or later. 8 + */ 9 + /dts-v1/; 10 + /include/ "at91sam9x5.dtsi" 11 + /include/ "at91sam9x5cm.dtsi" 12 + 13 + / { 14 + model = "Atmel AT91SAM9G25-EK"; 15 + compatible = "atmel,at91sam9g25ek", "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9"; 16 + 17 + chosen { 18 + bootargs = "128M console=ttyS0,115200 mtdparts=atmel_nand:8M(bootstrap/uboot/kernel)ro,-(rootfs) root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs"; 19 + }; 20 + 21 + ahb { 22 + apb { 23 + dbgu: serial@fffff200 { 24 + status = "okay"; 25 + }; 26 + 27 + usart0: serial@f801c000 { 28 + status = "okay"; 29 + }; 30 + 31 + macb0: ethernet@f802c000 { 32 + phy-mode = "rmii"; 33 + status = "okay"; 34 + }; 35 + }; 36 + }; 37 + };
+172
arch/arm/boot/dts/at91sam9x5.dtsi
··· 1 + /* 2 + * at91sam9x5.dtsi - Device Tree Include file for AT91SAM9x5 family SoC 3 + * applies to AT91SAM9G15, AT91SAM9G25, AT91SAM9G35, 4 + * AT91SAM9X25, AT91SAM9X35 SoC 5 + * 6 + * Copyright (C) 2012 Atmel, 7 + * 2012 Nicolas Ferre <nicolas.ferre@atmel.com> 8 + * 9 + * Licensed under GPLv2 or later. 10 + */ 11 + 12 + /include/ "skeleton.dtsi" 13 + 14 + / { 15 + model = "Atmel AT91SAM9x5 family SoC"; 16 + compatible = "atmel,at91sam9x5"; 17 + interrupt-parent = <&aic>; 18 + 19 + aliases { 20 + serial0 = &dbgu; 21 + serial1 = &usart0; 22 + serial2 = &usart1; 23 + serial3 = &usart2; 24 + gpio0 = &pioA; 25 + gpio1 = &pioB; 26 + gpio2 = &pioC; 27 + gpio3 = &pioD; 28 + tcb0 = &tcb0; 29 + tcb1 = &tcb1; 30 + }; 31 + cpus { 32 + cpu@0 { 33 + compatible = "arm,arm926ejs"; 34 + }; 35 + }; 36 + 37 + memory@20000000 { 38 + reg = <0x20000000 0x10000000>; 39 + }; 40 + 41 + ahb { 42 + compatible = "simple-bus"; 43 + #address-cells = <1>; 44 + #size-cells = <1>; 45 + ranges; 46 + 47 + apb { 48 + compatible = "simple-bus"; 49 + #address-cells = <1>; 50 + #size-cells = <1>; 51 + ranges; 52 + 53 + aic: interrupt-controller@fffff000 { 54 + #interrupt-cells = <2>; 55 + compatible = "atmel,at91rm9200-aic"; 56 + interrupt-controller; 57 + interrupt-parent; 58 + reg = <0xfffff000 0x200>; 59 + }; 60 + 61 + pit: timer@fffffe30 { 62 + compatible = "atmel,at91sam9260-pit"; 63 + reg = <0xfffffe30 0xf>; 64 + interrupts = <1 4>; 65 + }; 66 + 67 + tcb0: timer@f8008000 { 68 + compatible = "atmel,at91sam9x5-tcb"; 69 + reg = <0xf8008000 0x100>; 70 + interrupts = <17 4>; 71 + }; 72 + 73 + tcb1: timer@f800c000 { 74 + compatible = "atmel,at91sam9x5-tcb"; 75 + reg = <0xf800c000 0x100>; 76 + interrupts = <17 4>; 77 + }; 78 + 79 + dma0: dma-controller@ffffec00 { 80 + compatible = "atmel,at91sam9g45-dma"; 81 + reg = <0xffffec00 0x200>; 82 + interrupts = <20 4>; 83 + }; 84 + 85 + dma1: dma-controller@ffffee00 { 86 + compatible = "atmel,at91sam9g45-dma"; 87 + reg = <0xffffee00 0x200>; 88 + interrupts = <21 4>; 89 + }; 90 + 91 + pioA: gpio@fffff400 { 92 + compatible = "atmel,at91rm9200-gpio"; 93 + reg = <0xfffff400 0x100>; 94 + interrupts = <2 4>; 95 + #gpio-cells = <2>; 96 + gpio-controller; 97 + }; 98 + 99 + pioB: gpio@fffff600 { 100 + compatible = "atmel,at91rm9200-gpio"; 101 + reg = <0xfffff600 0x100>; 102 + interrupts = <2 4>; 103 + #gpio-cells = <2>; 104 + gpio-controller; 105 + }; 106 + 107 + pioC: gpio@fffff800 { 108 + compatible = "atmel,at91rm9200-gpio"; 109 + reg = <0xfffff800 0x100>; 110 + interrupts = <3 4>; 111 + #gpio-cells = <2>; 112 + gpio-controller; 113 + }; 114 + 115 + pioD: gpio@fffffa00 { 116 + compatible = "atmel,at91rm9200-gpio"; 117 + reg = <0xfffffa00 0x100>; 118 + interrupts = <3 4>; 119 + #gpio-cells = <2>; 120 + gpio-controller; 121 + }; 122 + 123 + dbgu: serial@fffff200 { 124 + compatible = "atmel,at91sam9260-usart"; 125 + reg = <0xfffff200 0x200>; 126 + interrupts = <1 4>; 127 + status = "disabled"; 128 + }; 129 + 130 + usart0: serial@f801c000 { 131 + compatible = "atmel,at91sam9260-usart"; 132 + reg = <0xf801c000 0x200>; 133 + interrupts = <5 4>; 134 + atmel,use-dma-rx; 135 + atmel,use-dma-tx; 136 + status = "disabled"; 137 + }; 138 + 139 + usart1: serial@f8020000 { 140 + compatible = "atmel,at91sam9260-usart"; 141 + reg = <0xf8020000 0x200>; 142 + interrupts = <6 4>; 143 + atmel,use-dma-rx; 144 + atmel,use-dma-tx; 145 + status = "disabled"; 146 + }; 147 + 148 + usart2: serial@f8024000 { 149 + compatible = "atmel,at91sam9260-usart"; 150 + reg = <0xf8024000 0x200>; 151 + interrupts = <7 4>; 152 + atmel,use-dma-rx; 153 + atmel,use-dma-tx; 154 + status = "disabled"; 155 + }; 156 + 157 + macb0: ethernet@f802c000 { 158 + compatible = "cdns,at32ap7000-macb", "cdns,macb"; 159 + reg = <0xf802c000 0x100>; 160 + interrupts = <24 4>; 161 + status = "disabled"; 162 + }; 163 + 164 + macb1: ethernet@f8030000 { 165 + compatible = "cdns,at32ap7000-macb", "cdns,macb"; 166 + reg = <0xf8030000 0x100>; 167 + interrupts = <27 4>; 168 + status = "disabled"; 169 + }; 170 + }; 171 + }; 172 + };
+14
arch/arm/boot/dts/at91sam9x5cm.dtsi
··· 1 + /* 2 + * at91sam9x5cm.dtsi - Device Tree Include file for AT91SAM9x5 CPU Module 3 + * 4 + * Copyright (C) 2012 Atmel, 5 + * 2012 Nicolas Ferre <nicolas.ferre@atmel.com> 6 + * 7 + * Licensed under GPLv2 or later. 8 + */ 9 + 10 + / { 11 + memory@20000000 { 12 + reg = <0x20000000 0x8000000>; 13 + }; 14 + };
+16 -1
arch/arm/common/timer-sp.c
··· 26 26 #include <linux/irq.h> 27 27 #include <linux/io.h> 28 28 29 + #include <asm/sched_clock.h> 29 30 #include <asm/hardware/arm_timer.h> 30 31 31 32 static long __init sp804_get_clock_rate(const char *name) ··· 68 67 return rate; 69 68 } 70 69 71 - void __init sp804_clocksource_init(void __iomem *base, const char *name) 70 + static void __iomem *sched_clock_base; 71 + 72 + static u32 sp804_read(void) 73 + { 74 + return ~readl_relaxed(sched_clock_base + TIMER_VALUE); 75 + } 76 + 77 + void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base, 78 + const char *name, 79 + int use_sched_clock) 72 80 { 73 81 long rate = sp804_get_clock_rate(name); 74 82 ··· 93 83 94 84 clocksource_mmio_init(base + TIMER_VALUE, name, 95 85 rate, 200, 32, clocksource_mmio_readl_down); 86 + 87 + if (use_sched_clock) { 88 + sched_clock_base = base; 89 + setup_sched_clock(sp804_read, 32, rate); 90 + } 96 91 } 97 92 98 93
+2 -3
arch/arm/configs/imx_v6_v7_defconfig
··· 5 5 CONFIG_LOG_BUF_SHIFT=18 6 6 CONFIG_CGROUPS=y 7 7 CONFIG_RELAY=y 8 + CONFIG_BLK_DEV_INITRD=y 8 9 CONFIG_EXPERT=y 9 10 # CONFIG_SLUB_DEBUG is not set 10 11 # CONFIG_COMPAT_BRK is not set ··· 13 12 CONFIG_MODULE_UNLOAD=y 14 13 CONFIG_MODVERSIONS=y 15 14 CONFIG_MODULE_SRCVERSION_ALL=y 16 - # CONFIG_LBDAF is not set 17 15 # CONFIG_BLK_DEV_BSG is not set 18 16 CONFIG_ARCH_MXC=y 19 17 CONFIG_MACH_MX31LILLY=y ··· 26 26 CONFIG_MACH_KZM_ARM11_01=y 27 27 CONFIG_MACH_PCM043=y 28 28 CONFIG_MACH_MX35_3DS=y 29 - CONFIG_MACH_EUKREA_CPUIMX35=y 30 29 CONFIG_MACH_VPR200=y 31 30 CONFIG_MACH_IMX51_DT=y 32 31 CONFIG_MACH_MX51_3DS=y ··· 82 83 # CONFIG_NET_VENDOR_BROADCOM is not set 83 84 # CONFIG_NET_VENDOR_CHELSIO is not set 84 85 # CONFIG_NET_VENDOR_FARADAY is not set 85 - CONFIG_FEC=y 86 86 # CONFIG_NET_VENDOR_INTEL is not set 87 87 # CONFIG_NET_VENDOR_MARVELL is not set 88 88 # CONFIG_NET_VENDOR_MICREL is not set ··· 124 126 CONFIG_IMX2_WDT=y 125 127 CONFIG_MFD_MC13XXX=y 126 128 CONFIG_REGULATOR=y 129 + CONFIG_REGULATOR_FIXED_VOLTAGE=y 127 130 CONFIG_REGULATOR_MC13892=y 128 131 CONFIG_USB=y 129 132 CONFIG_USB_EHCI_HCD=y
+17 -3
arch/arm/configs/mxs_defconfig
··· 77 77 CONFIG_SERIAL_AMBA_PL011=y 78 78 CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 79 79 # CONFIG_HW_RANDOM is not set 80 - CONFIG_I2C=m 80 + CONFIG_I2C=y 81 81 # CONFIG_I2C_COMPAT is not set 82 - CONFIG_I2C_CHARDEV=m 83 - CONFIG_I2C_MXS=m 82 + CONFIG_I2C_CHARDEV=y 83 + CONFIG_I2C_MXS=y 84 84 CONFIG_SPI=y 85 85 CONFIG_SPI_GPIO=m 86 86 CONFIG_DEBUG_GPIO=y ··· 90 90 CONFIG_DISPLAY_SUPPORT=m 91 91 # CONFIG_HID_SUPPORT is not set 92 92 # CONFIG_USB_SUPPORT is not set 93 + CONFIG_SOUND=y 94 + CONFIG_SND=y 95 + CONFIG_SND_TIMER=y 96 + CONFIG_SND_PCM=y 97 + CONFIG_SND_JACK=y 98 + CONFIG_SND_DRIVERS=y 99 + CONFIG_SND_ARM=y 100 + CONFIG_SND_SOC=y 101 + CONFIG_SND_MXS_SOC=y 102 + CONFIG_SND_SOC_MXS_SGTL5000=y 103 + CONFIG_SND_SOC_I2C_AND_SPI=y 104 + CONFIG_SND_SOC_SGTL5000=y 105 + CONFIG_REGULATOR=y 106 + CONFIG_REGULATOR_FIXED_VOLTAGE=y 93 107 CONFIG_MMC=y 94 108 CONFIG_MMC_MXS=y 95 109 CONFIG_RTC_CLASS=y
+14 -1
arch/arm/include/asm/hardware/timer-sp.h
··· 1 - void sp804_clocksource_init(void __iomem *, const char *); 1 + void __sp804_clocksource_and_sched_clock_init(void __iomem *, 2 + const char *, int); 3 + 4 + static inline void sp804_clocksource_init(void __iomem *base, const char *name) 5 + { 6 + __sp804_clocksource_and_sched_clock_init(base, name, 0); 7 + } 8 + 9 + static inline void sp804_clocksource_and_sched_clock_init(void __iomem *base, 10 + const char *name) 11 + { 12 + __sp804_clocksource_and_sched_clock_init(base, name, 1); 13 + } 14 + 2 15 void sp804_clockevents_init(void __iomem *, unsigned int, const char *);
+9
arch/arm/mach-at91/Kconfig
··· 102 102 select HAVE_AT91_DBGU1 103 103 select AT91_SAM9G45_RESET 104 104 105 + config ARCH_AT91SAM9X5 106 + bool "AT91SAM9x5 family" 107 + select CPU_ARM926T 108 + select GENERIC_CLOCKEVENTS 109 + select HAVE_FB_ATMEL 110 + select HAVE_NET_MACB 111 + select HAVE_AT91_DBGU0 112 + select AT91_SAM9G45_RESET 113 + 105 114 config ARCH_AT91X40 106 115 bool "AT91x40" 107 116 select ARCH_USES_GETTIMEOFFSET
+1
arch/arm/mach-at91/Makefile
··· 20 20 obj-$(CONFIG_ARCH_AT91SAM9RL) += at91sam9rl.o at91sam926x_time.o at91sam9rl_devices.o sam9_smc.o 21 21 obj-$(CONFIG_ARCH_AT91SAM9G20) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.o 22 22 obj-$(CONFIG_ARCH_AT91SAM9G45) += at91sam9g45.o at91sam926x_time.o at91sam9g45_devices.o sam9_smc.o 23 + obj-$(CONFIG_ARCH_AT91SAM9X5) += at91sam9x5.o at91sam926x_time.o 23 24 obj-$(CONFIG_ARCH_AT91X40) += at91x40.o at91x40_time.o 24 25 25 26 # AT91RM9200 board-specific support
+373
arch/arm/mach-at91/at91sam9x5.c
··· 1 + /* 2 + * Chip-specific setup code for the AT91SAM9x5 family 3 + * 4 + * Copyright (C) 2010-2012 Atmel Corporation. 5 + * 6 + * Licensed under GPLv2 or later. 7 + */ 8 + 9 + #include <linux/module.h> 10 + #include <linux/dma-mapping.h> 11 + 12 + #include <asm/irq.h> 13 + #include <asm/mach/arch.h> 14 + #include <asm/mach/map.h> 15 + #include <mach/at91sam9x5.h> 16 + #include <mach/at91_pmc.h> 17 + #include <mach/cpu.h> 18 + #include <mach/board.h> 19 + 20 + #include "soc.h" 21 + #include "generic.h" 22 + #include "clock.h" 23 + #include "sam9_smc.h" 24 + 25 + /* -------------------------------------------------------------------- 26 + * Clocks 27 + * -------------------------------------------------------------------- */ 28 + 29 + /* 30 + * The peripheral clocks. 31 + */ 32 + static struct clk pioAB_clk = { 33 + .name = "pioAB_clk", 34 + .pmc_mask = 1 << AT91SAM9X5_ID_PIOAB, 35 + .type = CLK_TYPE_PERIPHERAL, 36 + }; 37 + static struct clk pioCD_clk = { 38 + .name = "pioCD_clk", 39 + .pmc_mask = 1 << AT91SAM9X5_ID_PIOCD, 40 + .type = CLK_TYPE_PERIPHERAL, 41 + }; 42 + static struct clk smd_clk = { 43 + .name = "smd_clk", 44 + .pmc_mask = 1 << AT91SAM9X5_ID_SMD, 45 + .type = CLK_TYPE_PERIPHERAL, 46 + }; 47 + static struct clk usart0_clk = { 48 + .name = "usart0_clk", 49 + .pmc_mask = 1 << AT91SAM9X5_ID_USART0, 50 + .type = CLK_TYPE_PERIPHERAL, 51 + }; 52 + static struct clk usart1_clk = { 53 + .name = "usart1_clk", 54 + .pmc_mask = 1 << AT91SAM9X5_ID_USART1, 55 + .type = CLK_TYPE_PERIPHERAL, 56 + }; 57 + static struct clk usart2_clk = { 58 + .name = "usart2_clk", 59 + .pmc_mask = 1 << AT91SAM9X5_ID_USART2, 60 + .type = CLK_TYPE_PERIPHERAL, 61 + }; 62 + /* USART3 clock - Only for sam9g25/sam9x25 */ 63 + static struct clk usart3_clk = { 64 + .name = "usart3_clk", 65 + .pmc_mask = 1 << AT91SAM9X5_ID_USART3, 66 + .type = CLK_TYPE_PERIPHERAL, 67 + }; 68 + static struct clk twi0_clk = { 69 + .name = "twi0_clk", 70 + .pmc_mask = 1 << AT91SAM9X5_ID_TWI0, 71 + .type = CLK_TYPE_PERIPHERAL, 72 + }; 73 + static struct clk twi1_clk = { 74 + .name = "twi1_clk", 75 + .pmc_mask = 1 << AT91SAM9X5_ID_TWI1, 76 + .type = CLK_TYPE_PERIPHERAL, 77 + }; 78 + static struct clk twi2_clk = { 79 + .name = "twi2_clk", 80 + .pmc_mask = 1 << AT91SAM9X5_ID_TWI2, 81 + .type = CLK_TYPE_PERIPHERAL, 82 + }; 83 + static struct clk mmc0_clk = { 84 + .name = "mci0_clk", 85 + .pmc_mask = 1 << AT91SAM9X5_ID_MCI0, 86 + .type = CLK_TYPE_PERIPHERAL, 87 + }; 88 + static struct clk spi0_clk = { 89 + .name = "spi0_clk", 90 + .pmc_mask = 1 << AT91SAM9X5_ID_SPI0, 91 + .type = CLK_TYPE_PERIPHERAL, 92 + }; 93 + static struct clk spi1_clk = { 94 + .name = "spi1_clk", 95 + .pmc_mask = 1 << AT91SAM9X5_ID_SPI1, 96 + .type = CLK_TYPE_PERIPHERAL, 97 + }; 98 + static struct clk uart0_clk = { 99 + .name = "uart0_clk", 100 + .pmc_mask = 1 << AT91SAM9X5_ID_UART0, 101 + .type = CLK_TYPE_PERIPHERAL, 102 + }; 103 + static struct clk uart1_clk = { 104 + .name = "uart1_clk", 105 + .pmc_mask = 1 << AT91SAM9X5_ID_UART1, 106 + .type = CLK_TYPE_PERIPHERAL, 107 + }; 108 + static struct clk tcb0_clk = { 109 + .name = "tcb0_clk", 110 + .pmc_mask = 1 << AT91SAM9X5_ID_TCB, 111 + .type = CLK_TYPE_PERIPHERAL, 112 + }; 113 + static struct clk pwm_clk = { 114 + .name = "pwm_clk", 115 + .pmc_mask = 1 << AT91SAM9X5_ID_PWM, 116 + .type = CLK_TYPE_PERIPHERAL, 117 + }; 118 + static struct clk adc_clk = { 119 + .name = "adc_clk", 120 + .pmc_mask = 1 << AT91SAM9X5_ID_ADC, 121 + .type = CLK_TYPE_PERIPHERAL, 122 + }; 123 + static struct clk dma0_clk = { 124 + .name = "dma0_clk", 125 + .pmc_mask = 1 << AT91SAM9X5_ID_DMA0, 126 + .type = CLK_TYPE_PERIPHERAL, 127 + }; 128 + static struct clk dma1_clk = { 129 + .name = "dma1_clk", 130 + .pmc_mask = 1 << AT91SAM9X5_ID_DMA1, 131 + .type = CLK_TYPE_PERIPHERAL, 132 + }; 133 + static struct clk uhphs_clk = { 134 + .name = "uhphs_clk", 135 + .pmc_mask = 1 << AT91SAM9X5_ID_UHPHS, 136 + .type = CLK_TYPE_PERIPHERAL, 137 + }; 138 + static struct clk udphs_clk = { 139 + .name = "udphs_clk", 140 + .pmc_mask = 1 << AT91SAM9X5_ID_UDPHS, 141 + .type = CLK_TYPE_PERIPHERAL, 142 + }; 143 + /* emac0 clock - Only for sam9g25/sam9x25/sam9g35/sam9x35 */ 144 + static struct clk macb0_clk = { 145 + .name = "pclk", 146 + .pmc_mask = 1 << AT91SAM9X5_ID_EMAC0, 147 + .type = CLK_TYPE_PERIPHERAL, 148 + }; 149 + /* lcd clock - Only for sam9g15/sam9g35/sam9x35 */ 150 + static struct clk lcdc_clk = { 151 + .name = "lcdc_clk", 152 + .pmc_mask = 1 << AT91SAM9X5_ID_LCDC, 153 + .type = CLK_TYPE_PERIPHERAL, 154 + }; 155 + /* isi clock - Only for sam9g25 */ 156 + static struct clk isi_clk = { 157 + .name = "isi_clk", 158 + .pmc_mask = 1 << AT91SAM9X5_ID_ISI, 159 + .type = CLK_TYPE_PERIPHERAL, 160 + }; 161 + static struct clk mmc1_clk = { 162 + .name = "mci1_clk", 163 + .pmc_mask = 1 << AT91SAM9X5_ID_MCI1, 164 + .type = CLK_TYPE_PERIPHERAL, 165 + }; 166 + /* emac1 clock - Only for sam9x25 */ 167 + static struct clk macb1_clk = { 168 + .name = "pclk", 169 + .pmc_mask = 1 << AT91SAM9X5_ID_EMAC1, 170 + .type = CLK_TYPE_PERIPHERAL, 171 + }; 172 + static struct clk ssc_clk = { 173 + .name = "ssc_clk", 174 + .pmc_mask = 1 << AT91SAM9X5_ID_SSC, 175 + .type = CLK_TYPE_PERIPHERAL, 176 + }; 177 + /* can0 clock - Only for sam9x35 */ 178 + static struct clk can0_clk = { 179 + .name = "can0_clk", 180 + .pmc_mask = 1 << AT91SAM9X5_ID_CAN0, 181 + .type = CLK_TYPE_PERIPHERAL, 182 + }; 183 + /* can1 clock - Only for sam9x35 */ 184 + static struct clk can1_clk = { 185 + .name = "can1_clk", 186 + .pmc_mask = 1 << AT91SAM9X5_ID_CAN1, 187 + .type = CLK_TYPE_PERIPHERAL, 188 + }; 189 + 190 + static struct clk *periph_clocks[] __initdata = { 191 + &pioAB_clk, 192 + &pioCD_clk, 193 + &smd_clk, 194 + &usart0_clk, 195 + &usart1_clk, 196 + &usart2_clk, 197 + &twi0_clk, 198 + &twi1_clk, 199 + &twi2_clk, 200 + &mmc0_clk, 201 + &spi0_clk, 202 + &spi1_clk, 203 + &uart0_clk, 204 + &uart1_clk, 205 + &tcb0_clk, 206 + &pwm_clk, 207 + &adc_clk, 208 + &dma0_clk, 209 + &dma1_clk, 210 + &uhphs_clk, 211 + &udphs_clk, 212 + &mmc1_clk, 213 + &ssc_clk, 214 + // irq0 215 + }; 216 + 217 + static struct clk_lookup periph_clocks_lookups[] = { 218 + /* lookup table for DT entries */ 219 + CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck), 220 + CLKDEV_CON_DEV_ID("usart", "f801c000.serial", &usart0_clk), 221 + CLKDEV_CON_DEV_ID("usart", "f8020000.serial", &usart1_clk), 222 + CLKDEV_CON_DEV_ID("usart", "f8024000.serial", &usart2_clk), 223 + CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk), 224 + CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb0_clk), 225 + CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk), 226 + CLKDEV_CON_ID("pioA", &pioAB_clk), 227 + CLKDEV_CON_ID("pioB", &pioAB_clk), 228 + CLKDEV_CON_ID("pioC", &pioCD_clk), 229 + CLKDEV_CON_ID("pioD", &pioCD_clk), 230 + /* additional fake clock for macb_hclk */ 231 + CLKDEV_CON_DEV_ID("hclk", "f802c000.ethernet", &macb0_clk), 232 + CLKDEV_CON_DEV_ID("hclk", "f8030000.ethernet", &macb1_clk), 233 + }; 234 + 235 + /* 236 + * The two programmable clocks. 237 + * You must configure pin multiplexing to bring these signals out. 238 + */ 239 + static struct clk pck0 = { 240 + .name = "pck0", 241 + .pmc_mask = AT91_PMC_PCK0, 242 + .type = CLK_TYPE_PROGRAMMABLE, 243 + .id = 0, 244 + }; 245 + static struct clk pck1 = { 246 + .name = "pck1", 247 + .pmc_mask = AT91_PMC_PCK1, 248 + .type = CLK_TYPE_PROGRAMMABLE, 249 + .id = 1, 250 + }; 251 + 252 + static void __init at91sam9x5_register_clocks(void) 253 + { 254 + int i; 255 + 256 + for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) 257 + clk_register(periph_clocks[i]); 258 + 259 + clkdev_add_table(periph_clocks_lookups, 260 + ARRAY_SIZE(periph_clocks_lookups)); 261 + 262 + if (cpu_is_at91sam9g25() 263 + || cpu_is_at91sam9x25()) 264 + clk_register(&usart3_clk); 265 + 266 + if (cpu_is_at91sam9g25() 267 + || cpu_is_at91sam9x25() 268 + || cpu_is_at91sam9g35() 269 + || cpu_is_at91sam9x35()) 270 + clk_register(&macb0_clk); 271 + 272 + if (cpu_is_at91sam9g15() 273 + || cpu_is_at91sam9g35() 274 + || cpu_is_at91sam9x35()) 275 + clk_register(&lcdc_clk); 276 + 277 + if (cpu_is_at91sam9g25()) 278 + clk_register(&isi_clk); 279 + 280 + if (cpu_is_at91sam9x25()) 281 + clk_register(&macb1_clk); 282 + 283 + if (cpu_is_at91sam9x25() 284 + || cpu_is_at91sam9x35()) { 285 + clk_register(&can0_clk); 286 + clk_register(&can1_clk); 287 + } 288 + 289 + clk_register(&pck0); 290 + clk_register(&pck1); 291 + } 292 + 293 + /* -------------------------------------------------------------------- 294 + * AT91SAM9x5 processor initialization 295 + * -------------------------------------------------------------------- */ 296 + 297 + static void __init at91sam9x5_map_io(void) 298 + { 299 + at91_init_sram(0, AT91SAM9X5_SRAM_BASE, AT91SAM9X5_SRAM_SIZE); 300 + } 301 + 302 + static void __init at91sam9x5_ioremap_registers(void) 303 + { 304 + if (of_at91sam926x_pit_init() < 0) 305 + panic("Impossible to find PIT\n"); 306 + } 307 + 308 + void __init at91sam9x5_initialize(void) 309 + { 310 + arm_pm_restart = at91sam9g45_restart; 311 + at91_extern_irq = (1 << AT91SAM9X5_ID_IRQ0); 312 + 313 + /* Register GPIO subsystem (using DT) */ 314 + at91_gpio_init(NULL, 0); 315 + } 316 + 317 + /* -------------------------------------------------------------------- 318 + * AT91SAM9x5 devices (temporary before modification of code) 319 + * -------------------------------------------------------------------- */ 320 + void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 321 + void __init at91_set_serial_console(unsigned portnr) {} 322 + struct platform_device *atmel_default_console_device = NULL; 323 + 324 + void __init at91_add_device_nand(struct atmel_nand_data *data) {} 325 + 326 + /* -------------------------------------------------------------------- 327 + * Interrupt initialization 328 + * -------------------------------------------------------------------- */ 329 + /* 330 + * The default interrupt priority levels (0 = lowest, 7 = highest). 331 + */ 332 + static unsigned int at91sam9x5_default_irq_priority[NR_AIC_IRQS] __initdata = { 333 + 7, /* Advanced Interrupt Controller (FIQ) */ 334 + 7, /* System Peripherals */ 335 + 1, /* Parallel IO Controller A and B */ 336 + 1, /* Parallel IO Controller C and D */ 337 + 4, /* Soft Modem */ 338 + 5, /* USART 0 */ 339 + 5, /* USART 1 */ 340 + 5, /* USART 2 */ 341 + 5, /* USART 3 */ 342 + 6, /* Two-Wire Interface 0 */ 343 + 6, /* Two-Wire Interface 1 */ 344 + 6, /* Two-Wire Interface 2 */ 345 + 0, /* Multimedia Card Interface 0 */ 346 + 5, /* Serial Peripheral Interface 0 */ 347 + 5, /* Serial Peripheral Interface 1 */ 348 + 5, /* UART 0 */ 349 + 5, /* UART 1 */ 350 + 0, /* Timer Counter 0, 1, 2, 3, 4 and 5 */ 351 + 0, /* Pulse Width Modulation Controller */ 352 + 0, /* ADC Controller */ 353 + 0, /* DMA Controller 0 */ 354 + 0, /* DMA Controller 1 */ 355 + 2, /* USB Host High Speed port */ 356 + 2, /* USB Device High speed port */ 357 + 3, /* Ethernet MAC 0 */ 358 + 3, /* LDC Controller or Image Sensor Interface */ 359 + 0, /* Multimedia Card Interface 1 */ 360 + 3, /* Ethernet MAC 1 */ 361 + 4, /* Synchronous Serial Interface */ 362 + 4, /* CAN Controller 0 */ 363 + 4, /* CAN Controller 1 */ 364 + 0, /* Advanced Interrupt Controller (IRQ0) */ 365 + }; 366 + 367 + struct at91_init_soc __initdata at91sam9x5_soc = { 368 + .map_io = at91sam9x5_map_io, 369 + .default_irq_priority = at91sam9x5_default_irq_priority, 370 + .ioremap_registers = at91sam9x5_ioremap_registers, 371 + .register_clocks = at91sam9x5_register_clocks, 372 + .init = at91sam9x5_initialize, 373 + };
+1
arch/arm/mach-at91/board-dt.c
··· 109 109 110 110 static const char *at91_dt_board_compat[] __initdata = { 111 111 "atmel,at91sam9m10g45ek", 112 + "atmel,at91sam9x5ek", 112 113 "calao,usb-a9g20", 113 114 NULL 114 115 };
+64 -19
arch/arm/mach-at91/clock.c
··· 48 48 * Chips have some kind of clocks : group them by functionality 49 49 */ 50 50 #define cpu_has_utmi() ( cpu_is_at91sam9rl() \ 51 - || cpu_is_at91sam9g45()) 51 + || cpu_is_at91sam9g45() \ 52 + || cpu_is_at91sam9x5()) 52 53 53 54 #define cpu_has_800M_plla() ( cpu_is_at91sam9g20() \ 54 - || cpu_is_at91sam9g45()) 55 + || cpu_is_at91sam9g45() \ 56 + || cpu_is_at91sam9x5()) 55 57 56 58 #define cpu_has_300M_plla() (cpu_is_at91sam9g10()) 57 59 58 60 #define cpu_has_pllb() (!(cpu_is_at91sam9rl() \ 59 - || cpu_is_at91sam9g45())) 61 + || cpu_is_at91sam9g45() \ 62 + || cpu_is_at91sam9x5())) 60 63 61 - #define cpu_has_upll() (cpu_is_at91sam9g45()) 64 + #define cpu_has_upll() (cpu_is_at91sam9g45() \ 65 + || cpu_is_at91sam9x5()) 62 66 63 67 /* USB host HS & FS */ 64 68 #define cpu_has_uhp() (!cpu_is_at91sam9rl()) 65 69 66 70 /* USB device FS only */ 67 71 #define cpu_has_udpfs() (!(cpu_is_at91sam9rl() \ 68 - || cpu_is_at91sam9g45())) 72 + || cpu_is_at91sam9g45() \ 73 + || cpu_is_at91sam9x5())) 74 + 75 + #define cpu_has_plladiv2() (cpu_is_at91sam9g45() \ 76 + || cpu_is_at91sam9x5()) 77 + 78 + #define cpu_has_mdiv3() (cpu_is_at91sam9g45() \ 79 + || cpu_is_at91sam9x5()) 80 + 81 + #define cpu_has_alt_prescaler() (cpu_is_at91sam9x5()) 69 82 70 83 static LIST_HEAD(clocks); 71 84 static DEFINE_SPINLOCK(clk_lock); ··· 151 138 { 152 139 unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR); 153 140 154 - if (cpu_is_at91sam9g45()) { 155 - if (is_on) 156 - uckr |= AT91_PMC_BIASEN; 157 - else 158 - uckr &= ~AT91_PMC_BIASEN; 159 - } 160 - 161 141 if (is_on) { 162 142 is_on = AT91_PMC_LOCKU; 163 143 at91_sys_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask); ··· 215 209 return &utmi_clk; 216 210 else if (cpu_has_pllb()) 217 211 return &pllb; 212 + break; 213 + /* alternate PMC: can use master clock */ 214 + case AT91_PMC_CSS_MASTER: 215 + return &mck; 218 216 } 219 217 220 218 return NULL; 219 + } 220 + 221 + static int pmc_prescaler_divider(u32 reg) 222 + { 223 + if (cpu_has_alt_prescaler()) { 224 + return 1 << ((reg & AT91_PMC_ALT_PRES) >> PMC_ALT_PRES_OFFSET); 225 + } else { 226 + return 1 << ((reg & AT91_PMC_PRES) >> PMC_PRES_OFFSET); 227 + } 221 228 } 222 229 223 230 static void __clk_enable(struct clk *clk) ··· 334 315 { 335 316 unsigned long flags; 336 317 unsigned prescale; 318 + unsigned long prescale_offset, css_mask; 337 319 unsigned long actual; 338 320 339 321 if (!clk_is_programmable(clk)) 340 322 return -EINVAL; 341 323 if (clk->users) 342 324 return -EBUSY; 325 + 326 + if (cpu_has_alt_prescaler()) { 327 + prescale_offset = PMC_ALT_PRES_OFFSET; 328 + css_mask = AT91_PMC_ALT_PCKR_CSS; 329 + } else { 330 + prescale_offset = PMC_PRES_OFFSET; 331 + css_mask = AT91_PMC_CSS; 332 + } 333 + 343 334 spin_lock_irqsave(&clk_lock, flags); 344 335 345 336 actual = clk->parent->rate_hz; ··· 358 329 u32 pckr; 359 330 360 331 pckr = at91_sys_read(AT91_PMC_PCKR(clk->id)); 361 - pckr &= AT91_PMC_CSS; /* clock selection */ 362 - pckr |= prescale << 2; 332 + pckr &= css_mask; /* keep clock selection */ 333 + pckr |= prescale << prescale_offset; 363 334 at91_sys_write(AT91_PMC_PCKR(clk->id), pckr); 364 335 clk->rate_hz = actual; 365 336 break; ··· 406 377 { 407 378 struct clk *parent; 408 379 u32 pckr; 380 + unsigned int css_mask; 381 + 382 + if (cpu_has_alt_prescaler()) 383 + css_mask = AT91_PMC_ALT_PCKR_CSS; 384 + else 385 + css_mask = AT91_PMC_CSS; 409 386 410 387 pckr = at91_sys_read(AT91_PMC_PCKR(clk->id)); 411 - parent = at91_css_to_clk(pckr & AT91_PMC_CSS); 388 + parent = at91_css_to_clk(pckr & css_mask); 412 389 clk->parent = parent; 413 - clk->rate_hz = parent->rate_hz / (1 << ((pckr & AT91_PMC_PRES) >> 2)); 390 + clk->rate_hz = parent->rate_hz / pmc_prescaler_divider(pckr); 414 391 } 415 392 416 393 #endif /* CONFIG_AT91_PROGRAMMABLE_CLOCKS */ ··· 698 663 if (pll_overclock) 699 664 pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000); 700 665 701 - if (cpu_is_at91sam9g45()) { 666 + if (cpu_has_plladiv2()) { 702 667 mckr = at91_sys_read(AT91_PMC_MCKR); 703 668 plla.rate_hz /= (1 << ((mckr & AT91_PMC_PLLADIV2) >> 12)); /* plla divisor by 2 */ 704 669 } ··· 720 685 * (obtain the USB High Speed 480 MHz when input is 12 MHz) 721 686 */ 722 687 utmi_clk.rate_hz = 40 * utmi_clk.parent->rate_hz; 688 + 689 + /* UTMI bias and PLL are managed at the same time */ 690 + if (cpu_has_upll()) 691 + utmi_clk.pmc_mask |= AT91_PMC_BIASEN; 723 692 } 724 693 725 694 /* ··· 742 703 mckr = at91_sys_read(AT91_PMC_MCKR); 743 704 mck.parent = at91_css_to_clk(mckr & AT91_PMC_CSS); 744 705 freq = mck.parent->rate_hz; 745 - freq /= (1 << ((mckr & AT91_PMC_PRES) >> 2)); /* prescale */ 706 + freq /= pmc_prescaler_divider(mckr); /* prescale */ 746 707 if (cpu_is_at91rm9200()) { 747 708 mck.rate_hz = freq / (1 + ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ 748 709 } else if (cpu_is_at91sam9g20()) { ··· 750 711 freq / ((mckr & AT91_PMC_MDIV) >> 7) : freq; /* mdiv ; (x >> 7) = ((x >> 8) * 2) */ 751 712 if (mckr & AT91_PMC_PDIV) 752 713 freq /= 2; /* processor clock division */ 753 - } else if (cpu_is_at91sam9g45()) { 714 + } else if (cpu_has_mdiv3()) { 754 715 mck.rate_hz = (mckr & AT91_PMC_MDIV) == AT91SAM9_PMC_MDIV_3 ? 755 716 freq / 3 : freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ 756 717 } else { 757 718 mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ 719 + } 720 + 721 + if (cpu_has_alt_prescaler()) { 722 + /* Programmable clocks can use MCK */ 723 + mck.type |= CLK_TYPE_PRIMARY; 724 + mck.id = 4; 758 725 } 759 726 760 727 /* Register the PMC's standard clocks */
+48 -12
arch/arm/mach-at91/include/mach/at91_pmc.h
··· 45 45 #define AT91_PMC_BIASCOUNT (0xf << 28) /* UTMI BIAS Start-up Time */ 46 46 47 47 #define AT91_CKGR_MOR (AT91_PMC + 0x20) /* Main Oscillator Register [not on SAM9RL] */ 48 - #define AT91_PMC_MOSCEN (1 << 0) /* Main Oscillator Enable */ 49 - #define AT91_PMC_OSCBYPASS (1 << 1) /* Oscillator Bypass [SAM9x] */ 50 - #define AT91_PMC_OSCOUNT (0xff << 8) /* Main Oscillator Start-up Time */ 48 + #define AT91_PMC_MOSCEN (1 << 0) /* Main Oscillator Enable */ 49 + #define AT91_PMC_OSCBYPASS (1 << 1) /* Oscillator Bypass */ 50 + #define AT91_PMC_MOSCRCEN (1 << 3) /* Main On-Chip RC Oscillator Enable [some SAM9] */ 51 + #define AT91_PMC_OSCOUNT (0xff << 8) /* Main Oscillator Start-up Time */ 52 + #define AT91_PMC_KEY (0x37 << 16) /* MOR Writing Key */ 53 + #define AT91_PMC_MOSCSEL (1 << 24) /* Main Oscillator Selection [some SAM9] */ 54 + #define AT91_PMC_CFDEN (1 << 25) /* Clock Failure Detector Enable [some SAM9] */ 51 55 52 56 #define AT91_CKGR_MCFR (AT91_PMC + 0x24) /* Main Clock Frequency Register */ 53 57 #define AT91_PMC_MAINF (0xffff << 0) /* Main Clock Frequency */ ··· 76 72 #define AT91_PMC_CSS_PLLA (2 << 0) 77 73 #define AT91_PMC_CSS_PLLB (3 << 0) 78 74 #define AT91_PMC_CSS_UPLL (3 << 0) /* [some SAM9 only] */ 79 - #define AT91_PMC_PRES (7 << 2) /* Master Clock Prescaler */ 80 - #define AT91_PMC_PRES_1 (0 << 2) 81 - #define AT91_PMC_PRES_2 (1 << 2) 82 - #define AT91_PMC_PRES_4 (2 << 2) 83 - #define AT91_PMC_PRES_8 (3 << 2) 84 - #define AT91_PMC_PRES_16 (4 << 2) 85 - #define AT91_PMC_PRES_32 (5 << 2) 86 - #define AT91_PMC_PRES_64 (6 << 2) 75 + #define PMC_PRES_OFFSET 2 76 + #define AT91_PMC_PRES (7 << PMC_PRES_OFFSET) /* Master Clock Prescaler */ 77 + #define AT91_PMC_PRES_1 (0 << PMC_PRES_OFFSET) 78 + #define AT91_PMC_PRES_2 (1 << PMC_PRES_OFFSET) 79 + #define AT91_PMC_PRES_4 (2 << PMC_PRES_OFFSET) 80 + #define AT91_PMC_PRES_8 (3 << PMC_PRES_OFFSET) 81 + #define AT91_PMC_PRES_16 (4 << PMC_PRES_OFFSET) 82 + #define AT91_PMC_PRES_32 (5 << PMC_PRES_OFFSET) 83 + #define AT91_PMC_PRES_64 (6 << PMC_PRES_OFFSET) 84 + #define PMC_ALT_PRES_OFFSET 4 85 + #define AT91_PMC_ALT_PRES (7 << PMC_ALT_PRES_OFFSET) /* Master Clock Prescaler [alternate location] */ 86 + #define AT91_PMC_ALT_PRES_1 (0 << PMC_ALT_PRES_OFFSET) 87 + #define AT91_PMC_ALT_PRES_2 (1 << PMC_ALT_PRES_OFFSET) 88 + #define AT91_PMC_ALT_PRES_4 (2 << PMC_ALT_PRES_OFFSET) 89 + #define AT91_PMC_ALT_PRES_8 (3 << PMC_ALT_PRES_OFFSET) 90 + #define AT91_PMC_ALT_PRES_16 (4 << PMC_ALT_PRES_OFFSET) 91 + #define AT91_PMC_ALT_PRES_32 (5 << PMC_ALT_PRES_OFFSET) 92 + #define AT91_PMC_ALT_PRES_64 (6 << PMC_ALT_PRES_OFFSET) 87 93 #define AT91_PMC_MDIV (3 << 8) /* Master Clock Division */ 88 94 #define AT91RM9200_PMC_MDIV_1 (0 << 8) /* [AT91RM9200 only] */ 89 95 #define AT91RM9200_PMC_MDIV_2 (1 << 8) ··· 117 103 #define AT91_PMC_USBS_UPLL (1 << 0) 118 104 #define AT91_PMC_OHCIUSBDIV (0xF << 8) /* Divider for USB OHCI Clock */ 119 105 106 + #define AT91_PMC_SMD (AT91_PMC + 0x3c) /* Soft Modem Clock Register [some SAM9 only] */ 107 + #define AT91_PMC_SMDS (0x1 << 0) /* SMD input clock selection */ 108 + #define AT91_PMC_SMD_DIV (0x1f << 8) /* SMD input clock divider */ 109 + #define AT91_PMC_SMDDIV(n) (((n) << 8) & AT91_PMC_SMD_DIV) 110 + 120 111 #define AT91_PMC_PCKR(n) (AT91_PMC + 0x40 + ((n) * 4)) /* Programmable Clock 0-N Registers */ 112 + #define AT91_PMC_ALT_PCKR_CSS (0x7 << 0) /* Programmable Clock Source Selection [alternate length] */ 113 + #define AT91_PMC_CSS_MASTER (4 << 0) /* [some SAM9 only] */ 121 114 #define AT91_PMC_CSSMCK (0x1 << 8) /* CSS or Master Clock Selection */ 122 115 #define AT91_PMC_CSSMCK_CSS (0 << 8) 123 116 #define AT91_PMC_CSSMCK_MCK (1 << 8) ··· 141 120 #define AT91_PMC_PCK1RDY (1 << 9) /* Programmable Clock 1 */ 142 121 #define AT91_PMC_PCK2RDY (1 << 10) /* Programmable Clock 2 */ 143 122 #define AT91_PMC_PCK3RDY (1 << 11) /* Programmable Clock 3 */ 123 + #define AT91_PMC_MOSCSELS (1 << 16) /* Main Oscillator Selection [some SAM9] */ 124 + #define AT91_PMC_MOSCRCS (1 << 17) /* Main On-Chip RC [some SAM9] */ 125 + #define AT91_PMC_CFDEV (1 << 18) /* Clock Failure Detector Event [some SAM9] */ 144 126 #define AT91_PMC_IMR (AT91_PMC + 0x6c) /* Interrupt Mask Register */ 145 127 146 128 #define AT91_PMC_PROT (AT91_PMC + 0xe4) /* Write Protect Mode Register [some SAM9] */ 147 - #define AT91_PMC_PROTKEY 0x504d4301 /* Activation Code */ 129 + #define AT91_PMC_WPEN (0x1 << 0) /* Write Protect Enable */ 130 + #define AT91_PMC_WPKEY (0xffffff << 8) /* Write Protect Key */ 131 + #define AT91_PMC_PROTKEY (0x504d43 << 8) /* Activation Code */ 148 132 133 + #define AT91_PMC_WPSR (AT91_PMC + 0xe8) /* Write Protect Status Register [some SAM9] */ 134 + #define AT91_PMC_WPVS (0x1 << 0) /* Write Protect Violation Status */ 135 + #define AT91_PMC_WPVSRC (0xffff << 8) /* Write Protect Violation Source */ 136 + 137 + #define AT91_PMC_PCR (AT91_PMC + 0x10c) /* Peripheral Control Register [some SAM9] */ 138 + #define AT91_PMC_PCR_PID (0x3f << 0) /* Peripheral ID */ 139 + #define AT91_PMC_PCR_CMD (0x1 << 12) /* Command */ 140 + #define AT91_PMC_PCR_DIV (0x3 << 16) /* Divisor Value */ 141 + #define AT91_PMC_PCRDIV(n) (((n) << 16) & AT91_PMC_PCR_DIV) 142 + #define AT91_PMC_PCR_EN (0x1 << 28) /* Enable */ 149 143 150 144 #endif
+80
arch/arm/mach-at91/include/mach/at91sam9x5.h
··· 1 + /* 2 + * Chip-specific header file for the AT91SAM9x5 family 3 + * 4 + * Copyright (C) 2009-2012 Atmel Corporation. 5 + * 6 + * Common definitions. 7 + * Based on AT91SAM9x5 datasheet. 8 + * 9 + * Licensed under GPLv2 or later. 10 + */ 11 + 12 + #ifndef AT91SAM9X5_H 13 + #define AT91SAM9X5_H 14 + 15 + /* 16 + * Peripheral identifiers/interrupts. 17 + */ 18 + #define AT91SAM9X5_ID_PIOAB 2 /* Parallel I/O Controller A and B */ 19 + #define AT91SAM9X5_ID_PIOCD 3 /* Parallel I/O Controller C and D */ 20 + #define AT91SAM9X5_ID_SMD 4 /* SMD Soft Modem (SMD) */ 21 + #define AT91SAM9X5_ID_USART0 5 /* USART 0 */ 22 + #define AT91SAM9X5_ID_USART1 6 /* USART 1 */ 23 + #define AT91SAM9X5_ID_USART2 7 /* USART 2 */ 24 + #define AT91SAM9X5_ID_USART3 8 /* USART 3 */ 25 + #define AT91SAM9X5_ID_TWI0 9 /* Two-Wire Interface 0 */ 26 + #define AT91SAM9X5_ID_TWI1 10 /* Two-Wire Interface 1 */ 27 + #define AT91SAM9X5_ID_TWI2 11 /* Two-Wire Interface 2 */ 28 + #define AT91SAM9X5_ID_MCI0 12 /* High Speed Multimedia Card Interface 0 */ 29 + #define AT91SAM9X5_ID_SPI0 13 /* Serial Peripheral Interface 0 */ 30 + #define AT91SAM9X5_ID_SPI1 14 /* Serial Peripheral Interface 1 */ 31 + #define AT91SAM9X5_ID_UART0 15 /* UART 0 */ 32 + #define AT91SAM9X5_ID_UART1 16 /* UART 1 */ 33 + #define AT91SAM9X5_ID_TCB 17 /* Timer Counter 0, 1, 2, 3, 4 and 5 */ 34 + #define AT91SAM9X5_ID_PWM 18 /* Pulse Width Modulation Controller */ 35 + #define AT91SAM9X5_ID_ADC 19 /* ADC Controller */ 36 + #define AT91SAM9X5_ID_DMA0 20 /* DMA Controller 0 */ 37 + #define AT91SAM9X5_ID_DMA1 21 /* DMA Controller 1 */ 38 + #define AT91SAM9X5_ID_UHPHS 22 /* USB Host High Speed */ 39 + #define AT91SAM9X5_ID_UDPHS 23 /* USB Device High Speed */ 40 + #define AT91SAM9X5_ID_EMAC0 24 /* Ethernet MAC0 */ 41 + #define AT91SAM9X5_ID_LCDC 25 /* LCD Controller */ 42 + #define AT91SAM9X5_ID_ISI 25 /* Image Sensor Interface */ 43 + #define AT91SAM9X5_ID_MCI1 26 /* High Speed Multimedia Card Interface 1 */ 44 + #define AT91SAM9X5_ID_EMAC1 27 /* Ethernet MAC1 */ 45 + #define AT91SAM9X5_ID_SSC 28 /* Synchronous Serial Controller */ 46 + #define AT91SAM9X5_ID_CAN0 29 /* CAN Controller 0 */ 47 + #define AT91SAM9X5_ID_CAN1 30 /* CAN Controller 1 */ 48 + #define AT91SAM9X5_ID_IRQ0 31 /* Advanced Interrupt Controller */ 49 + 50 + /* 51 + * User Peripheral physical base addresses. 52 + */ 53 + #define AT91SAM9X5_BASE_USART0 0xf801c000 54 + #define AT91SAM9X5_BASE_USART1 0xf8020000 55 + #define AT91SAM9X5_BASE_USART2 0xf8024000 56 + 57 + /* 58 + * System Peripherals (offset from AT91_BASE_SYS) 59 + */ 60 + #define AT91_DDRSDRC0 (0xffffe800 - AT91_BASE_SYS) 61 + #define AT91_PMC (0xfffffc00 - AT91_BASE_SYS) 62 + 63 + /* 64 + * Base addresses for early serial code (uncompress.h) 65 + */ 66 + #define AT91_DBGU AT91_BASE_DBGU0 67 + #define AT91_USART0 AT91SAM9X5_BASE_USART0 68 + #define AT91_USART1 AT91SAM9X5_BASE_USART1 69 + #define AT91_USART2 AT91SAM9X5_BASE_USART2 70 + 71 + /* 72 + * Internal Memory. 73 + */ 74 + #define AT91SAM9X5_SRAM_BASE 0x00300000 /* Internal SRAM base address */ 75 + #define AT91SAM9X5_SRAM_SIZE SZ_32K /* Internal SRAM size (32Kb) */ 76 + 77 + #define AT91SAM9X5_ROM_BASE 0x00400000 /* Internal ROM base address */ 78 + #define AT91SAM9X5_ROM_SIZE SZ_64K /* Internal ROM size (64Kb) */ 79 + 80 + #endif
+53
arch/arm/mach-at91/include/mach/at91sam9x5_matrix.h
··· 1 + /* 2 + * Matrix-centric header file for the AT91SAM9x5 family 3 + * 4 + * Copyright (C) 2009-2012 Atmel Corporation. 5 + * 6 + * Only EBI related registers. 7 + * Write Protect register definitions may be useful. 8 + * 9 + * Licensed under GPLv2 or later. 10 + */ 11 + 12 + #ifndef AT91SAM9X5_MATRIX_H 13 + #define AT91SAM9X5_MATRIX_H 14 + 15 + #define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x120) /* EBI Chip Select Assignment Register */ 16 + #define AT91_MATRIX_EBI_CS1A (1 << 1) /* Chip Select 1 Assignment */ 17 + #define AT91_MATRIX_EBI_CS1A_SMC (0 << 1) 18 + #define AT91_MATRIX_EBI_CS1A_SDRAMC (1 << 1) 19 + #define AT91_MATRIX_EBI_CS3A (1 << 3) /* Chip Select 3 Assignment */ 20 + #define AT91_MATRIX_EBI_CS3A_SMC (0 << 3) 21 + #define AT91_MATRIX_EBI_CS3A_SMC_NANDFLASH (1 << 3) 22 + #define AT91_MATRIX_EBI_DBPUC (1 << 8) /* Data Bus Pull-up Configuration */ 23 + #define AT91_MATRIX_EBI_DBPU_ON (0 << 8) 24 + #define AT91_MATRIX_EBI_DBPU_OFF (1 << 8) 25 + #define AT91_MATRIX_EBI_VDDIOMSEL (1 << 16) /* Memory voltage selection */ 26 + #define AT91_MATRIX_EBI_VDDIOMSEL_1_8V (0 << 16) 27 + #define AT91_MATRIX_EBI_VDDIOMSEL_3_3V (1 << 16) 28 + #define AT91_MATRIX_EBI_EBI_IOSR (1 << 17) /* EBI I/O slew rate selection */ 29 + #define AT91_MATRIX_EBI_EBI_IOSR_REDUCED (0 << 17) 30 + #define AT91_MATRIX_EBI_EBI_IOSR_NORMAL (1 << 17) 31 + #define AT91_MATRIX_EBI_DDR_IOSR (1 << 18) /* DDR2 dedicated port I/O slew rate selection */ 32 + #define AT91_MATRIX_EBI_DDR_IOSR_REDUCED (0 << 18) 33 + #define AT91_MATRIX_EBI_DDR_IOSR_NORMAL (1 << 18) 34 + #define AT91_MATRIX_NFD0_SELECT (1 << 24) /* NAND Flash Data Bus Selection */ 35 + #define AT91_MATRIX_NFD0_ON_D0 (0 << 24) 36 + #define AT91_MATRIX_NFD0_ON_D16 (1 << 24) 37 + #define AT91_MATRIX_DDR_MP_EN (1 << 25) /* DDR Multi-port Enable */ 38 + #define AT91_MATRIX_MP_OFF (0 << 25) 39 + #define AT91_MATRIX_MP_ON (1 << 25) 40 + 41 + #define AT91_MATRIX_WPMR (AT91_MATRIX + 0x1E4) /* Write Protect Mode Register */ 42 + #define AT91_MATRIX_WPMR_WPEN (1 << 0) /* Write Protect ENable */ 43 + #define AT91_MATRIX_WPMR_WP_WPDIS (0 << 0) 44 + #define AT91_MATRIX_WPMR_WP_WPEN (1 << 0) 45 + #define AT91_MATRIX_WPMR_WPKEY (0xFFFFFF << 8) /* Write Protect KEY */ 46 + 47 + #define AT91_MATRIX_WPSR (AT91_MATRIX + 0x1E8) /* Write Protect Status Register */ 48 + #define AT91_MATRIX_WPSR_WPVS (1 << 0) /* Write Protect Violation Status */ 49 + #define AT91_MATRIX_WPSR_NO_WPV (0 << 0) 50 + #define AT91_MATRIX_WPSR_WPV (1 << 0) 51 + #define AT91_MATRIX_WPSR_WPVSRC (0xFFFF << 8) /* Write Protect Violation Source */ 52 + 53 + #endif
+2
arch/arm/mach-at91/include/mach/hardware.h
··· 34 34 #include <mach/at91sam9rl.h> 35 35 #elif defined(CONFIG_ARCH_AT91SAM9G45) 36 36 #include <mach/at91sam9g45.h> 37 + #elif defined(CONFIG_ARCH_AT91SAM9X5) 38 + #include <mach/at91sam9x5.h> 37 39 #elif defined(CONFIG_ARCH_AT91X40) 38 40 #include <mach/at91x40.h> 39 41 #else
+5
arch/arm/mach-exynos/clock-exynos4.c
··· 471 471 .enable = exynos4_clk_ip_cam_ctrl, 472 472 .ctrlbit = (1 << 5), 473 473 }, { 474 + .name = "jpeg", 475 + .id = 0, 476 + .enable = exynos4_clk_ip_cam_ctrl, 477 + .ctrlbit = (1 << 6), 478 + }, { 474 479 .name = "fimc", 475 480 .devname = "exynos4-fimc.0", 476 481 .enable = exynos4_clk_ip_cam_ctrl,
+47 -13
arch/arm/mach-exynos/common.c
··· 26 26 #include <asm/hardware/gic.h> 27 27 #include <asm/mach/map.h> 28 28 #include <asm/mach/irq.h> 29 + #include <asm/cacheflush.h> 29 30 30 31 #include <mach/regs-irq.h> 31 32 #include <mach/regs-pmu.h> 32 33 #include <mach/regs-gpio.h> 34 + #include <mach/pmu.h> 33 35 34 36 #include <plat/cpu.h> 35 37 #include <plat/clock.h> ··· 47 45 #include <plat/regs-serial.h> 48 46 49 47 #include "common.h" 48 + #define L2_AUX_VAL 0x7C470001 49 + #define L2_AUX_MASK 0xC200ffff 50 50 51 51 static const char name_exynos4210[] = "EXYNOS4210"; 52 52 static const char name_exynos4212[] = "EXYNOS4212"; ··· 177 173 }, { 178 174 .virtual = (unsigned long)S5P_VA_DMC0, 179 175 .pfn = __phys_to_pfn(EXYNOS4_PA_DMC0), 180 - .length = SZ_4K, 176 + .length = SZ_64K, 177 + .type = MT_DEVICE, 178 + }, { 179 + .virtual = (unsigned long)S5P_VA_DMC1, 180 + .pfn = __phys_to_pfn(EXYNOS4_PA_DMC1), 181 + .length = SZ_64K, 181 182 .type = MT_DEVICE, 182 183 }, { 183 184 .virtual = (unsigned long)S3C_VA_USB_HSPHY, ··· 442 433 #ifdef CONFIG_CACHE_L2X0 443 434 static int __init exynos4_l2x0_cache_init(void) 444 435 { 445 - /* TAG, Data Latency Control: 2cycle */ 446 - __raw_writel(0x110, S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL); 436 + int ret; 437 + ret = l2x0_of_init(L2_AUX_VAL, L2_AUX_MASK); 438 + if (!ret) { 439 + l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs); 440 + clean_dcache_area(&l2x0_regs_phys, sizeof(unsigned long)); 441 + return 0; 442 + } 447 443 448 - if (soc_is_exynos4210()) 449 - __raw_writel(0x110, S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL); 450 - else if (soc_is_exynos4212() || soc_is_exynos4412()) 451 - __raw_writel(0x120, S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL); 444 + if (!(__raw_readl(S5P_VA_L2CC + L2X0_CTRL) & 0x1)) { 445 + l2x0_saved_regs.phy_base = EXYNOS4_PA_L2CC; 446 + /* TAG, Data Latency Control: 2 cycles */ 447 + l2x0_saved_regs.tag_latency = 0x110; 452 448 453 - /* L2X0 Prefetch Control */ 454 - __raw_writel(0x30000007, S5P_VA_L2CC + L2X0_PREFETCH_CTRL); 449 + if (soc_is_exynos4212() || soc_is_exynos4412()) 450 + l2x0_saved_regs.data_latency = 0x120; 451 + else 452 + l2x0_saved_regs.data_latency = 0x110; 455 453 456 - /* L2X0 Power Control */ 457 - __raw_writel(L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN, 458 - S5P_VA_L2CC + L2X0_POWER_CTRL); 454 + l2x0_saved_regs.prefetch_ctrl = 0x30000007; 455 + l2x0_saved_regs.pwr_ctrl = 456 + (L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN); 459 457 460 - l2x0_init(S5P_VA_L2CC, 0x7C470001, 0xC200ffff); 458 + l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs); 461 459 460 + __raw_writel(l2x0_saved_regs.tag_latency, 461 + S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL); 462 + __raw_writel(l2x0_saved_regs.data_latency, 463 + S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL); 464 + 465 + /* L2X0 Prefetch Control */ 466 + __raw_writel(l2x0_saved_regs.prefetch_ctrl, 467 + S5P_VA_L2CC + L2X0_PREFETCH_CTRL); 468 + 469 + /* L2X0 Power Control */ 470 + __raw_writel(l2x0_saved_regs.pwr_ctrl, 471 + S5P_VA_L2CC + L2X0_POWER_CTRL); 472 + 473 + clean_dcache_area(&l2x0_regs_phys, sizeof(unsigned long)); 474 + clean_dcache_area(&l2x0_saved_regs, sizeof(struct l2x0_regs)); 475 + } 476 + 477 + l2x0_init(S5P_VA_L2CC, L2_AUX_VAL, L2_AUX_MASK); 462 478 return 0; 463 479 } 464 480
+147 -4
arch/arm/mach-exynos/cpuidle.c
··· 11 11 #include <linux/kernel.h> 12 12 #include <linux/init.h> 13 13 #include <linux/cpuidle.h> 14 + #include <linux/cpu_pm.h> 14 15 #include <linux/io.h> 15 16 #include <linux/export.h> 16 17 #include <linux/time.h> 17 18 18 19 #include <asm/proc-fns.h> 20 + #include <asm/smp_scu.h> 21 + #include <asm/suspend.h> 22 + #include <asm/unified.h> 23 + #include <mach/regs-pmu.h> 24 + #include <mach/pmu.h> 25 + 26 + #include <plat/cpu.h> 27 + 28 + #define REG_DIRECTGO_ADDR (samsung_rev() == EXYNOS4210_REV_1_1 ? \ 29 + S5P_INFORM7 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \ 30 + (S5P_VA_SYSRAM + 0x24) : S5P_INFORM0)) 31 + #define REG_DIRECTGO_FLAG (samsung_rev() == EXYNOS4210_REV_1_1 ? \ 32 + S5P_INFORM6 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \ 33 + (S5P_VA_SYSRAM + 0x20) : S5P_INFORM1)) 34 + 35 + #define S5P_CHECK_AFTR 0xFCBA0D10 19 36 20 37 static int exynos4_enter_idle(struct cpuidle_device *dev, 21 38 struct cpuidle_driver *drv, 22 39 int index); 40 + static int exynos4_enter_lowpower(struct cpuidle_device *dev, 41 + struct cpuidle_driver *drv, 42 + int index); 23 43 24 - static struct cpuidle_state exynos4_cpuidle_set[] = { 44 + static struct cpuidle_state exynos4_cpuidle_set[] __initdata = { 25 45 [0] = { 26 46 .enter = exynos4_enter_idle, 27 47 .exit_latency = 1, 28 48 .target_residency = 100000, 29 49 .flags = CPUIDLE_FLAG_TIME_VALID, 30 - .name = "IDLE", 50 + .name = "C0", 31 51 .desc = "ARM clock gating(WFI)", 52 + }, 53 + [1] = { 54 + .enter = exynos4_enter_lowpower, 55 + .exit_latency = 300, 56 + .target_residency = 100000, 57 + .flags = CPUIDLE_FLAG_TIME_VALID, 58 + .name = "C1", 59 + .desc = "ARM power down", 32 60 }, 33 61 }; 34 62 ··· 67 39 .owner = THIS_MODULE, 68 40 }; 69 41 42 + /* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */ 43 + static void exynos4_set_wakeupmask(void) 44 + { 45 + __raw_writel(0x0000ff3e, S5P_WAKEUP_MASK); 46 + } 47 + 48 + static unsigned int g_pwr_ctrl, g_diag_reg; 49 + 50 + static void save_cpu_arch_register(void) 51 + { 52 + /*read power control register*/ 53 + asm("mrc p15, 0, %0, c15, c0, 0" : "=r"(g_pwr_ctrl) : : "cc"); 54 + /*read diagnostic register*/ 55 + asm("mrc p15, 0, %0, c15, c0, 1" : "=r"(g_diag_reg) : : "cc"); 56 + return; 57 + } 58 + 59 + static void restore_cpu_arch_register(void) 60 + { 61 + /*write power control register*/ 62 + asm("mcr p15, 0, %0, c15, c0, 0" : : "r"(g_pwr_ctrl) : "cc"); 63 + /*write diagnostic register*/ 64 + asm("mcr p15, 0, %0, c15, c0, 1" : : "r"(g_diag_reg) : "cc"); 65 + return; 66 + } 67 + 68 + static int idle_finisher(unsigned long flags) 69 + { 70 + cpu_do_idle(); 71 + return 1; 72 + } 73 + 74 + static int exynos4_enter_core0_aftr(struct cpuidle_device *dev, 75 + struct cpuidle_driver *drv, 76 + int index) 77 + { 78 + struct timeval before, after; 79 + int idle_time; 80 + unsigned long tmp; 81 + 82 + local_irq_disable(); 83 + do_gettimeofday(&before); 84 + 85 + exynos4_set_wakeupmask(); 86 + 87 + /* Set value of power down register for aftr mode */ 88 + exynos4_sys_powerdown_conf(SYS_AFTR); 89 + 90 + __raw_writel(virt_to_phys(s3c_cpu_resume), REG_DIRECTGO_ADDR); 91 + __raw_writel(S5P_CHECK_AFTR, REG_DIRECTGO_FLAG); 92 + 93 + save_cpu_arch_register(); 94 + 95 + /* Setting Central Sequence Register for power down mode */ 96 + tmp = __raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION); 97 + tmp &= ~S5P_CENTRAL_LOWPWR_CFG; 98 + __raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION); 99 + 100 + cpu_pm_enter(); 101 + cpu_suspend(0, idle_finisher); 102 + 103 + #ifdef CONFIG_SMP 104 + scu_enable(S5P_VA_SCU); 105 + #endif 106 + cpu_pm_exit(); 107 + 108 + restore_cpu_arch_register(); 109 + 110 + /* 111 + * If PMU failed while entering sleep mode, WFI will be 112 + * ignored by PMU and then exiting cpu_do_idle(). 113 + * S5P_CENTRAL_LOWPWR_CFG bit will not be set automatically 114 + * in this situation. 115 + */ 116 + tmp = __raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION); 117 + if (!(tmp & S5P_CENTRAL_LOWPWR_CFG)) { 118 + tmp |= S5P_CENTRAL_LOWPWR_CFG; 119 + __raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION); 120 + } 121 + 122 + /* Clear wakeup state register */ 123 + __raw_writel(0x0, S5P_WAKEUP_STAT); 124 + 125 + do_gettimeofday(&after); 126 + 127 + local_irq_enable(); 128 + idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + 129 + (after.tv_usec - before.tv_usec); 130 + 131 + dev->last_residency = idle_time; 132 + return index; 133 + } 134 + 70 135 static int exynos4_enter_idle(struct cpuidle_device *dev, 71 136 struct cpuidle_driver *drv, 72 - int index) 137 + int index) 73 138 { 74 139 struct timeval before, after; 75 140 int idle_time; ··· 181 60 return index; 182 61 } 183 62 63 + static int exynos4_enter_lowpower(struct cpuidle_device *dev, 64 + struct cpuidle_driver *drv, 65 + int index) 66 + { 67 + int new_index = index; 68 + 69 + /* This mode only can be entered when other core's are offline */ 70 + if (num_online_cpus() > 1) 71 + new_index = drv->safe_state_index; 72 + 73 + if (new_index == 0) 74 + return exynos4_enter_idle(dev, drv, new_index); 75 + else 76 + return exynos4_enter_core0_aftr(dev, drv, new_index); 77 + } 78 + 184 79 static int __init exynos4_init_cpuidle(void) 185 80 { 186 81 int i, max_cpuidle_state, cpu_id; ··· 211 74 memcpy(&drv->states[i], &exynos4_cpuidle_set[i], 212 75 sizeof(struct cpuidle_state)); 213 76 } 77 + drv->safe_state_index = 0; 214 78 cpuidle_register_driver(&exynos4_idle_driver); 215 79 216 80 for_each_cpu(cpu_id, cpu_online_mask) { 217 81 device = &per_cpu(exynos4_cpuidle_device, cpu_id); 218 82 device->cpu = cpu_id; 219 83 220 - device->state_count = drv->state_count; 84 + if (cpu_id == 0) 85 + device->state_count = (sizeof(exynos4_cpuidle_set) / 86 + sizeof(struct cpuidle_state)); 87 + else 88 + device->state_count = 1; /* Support IDLE only */ 221 89 222 90 if (cpuidle_register_device(device)) { 223 91 printk(KERN_ERR "CPUidle register device failed\n,"); 224 92 return -EIO; 225 93 } 226 94 } 95 + 227 96 return 0; 228 97 } 229 98 device_initcall(exynos4_init_cpuidle);
+7
arch/arm/mach-exynos/include/mach/map.h
··· 31 31 #define EXYNOS4_PA_FIMC2 0x11820000 32 32 #define EXYNOS4_PA_FIMC3 0x11830000 33 33 34 + #define EXYNOS4_PA_JPEG 0x11840000 35 + 36 + #define EXYNOS4_PA_G2D 0x12800000 37 + 34 38 #define EXYNOS4_PA_I2S0 0x03830000 35 39 #define EXYNOS4_PA_I2S1 0xE3100000 36 40 #define EXYNOS4_PA_I2S2 0xE2A00000 ··· 61 57 #define EXYNOS4_PA_KEYPAD 0x100A0000 62 58 63 59 #define EXYNOS4_PA_DMC0 0x10400000 60 + #define EXYNOS4_PA_DMC1 0x10410000 64 61 65 62 #define EXYNOS4_PA_COMBINER 0x10440000 66 63 ··· 167 162 #define S5P_PA_FIMC1 EXYNOS4_PA_FIMC1 168 163 #define S5P_PA_FIMC2 EXYNOS4_PA_FIMC2 169 164 #define S5P_PA_FIMC3 EXYNOS4_PA_FIMC3 165 + #define S5P_PA_JPEG EXYNOS4_PA_JPEG 166 + #define S5P_PA_G2D EXYNOS4_PA_G2D 170 167 #define S5P_PA_FIMD0 EXYNOS4_PA_FIMD0 171 168 #define S5P_PA_HDMI EXYNOS4_PA_HDMI 172 169 #define S5P_PA_IIC_HDMIPHY EXYNOS4_PA_IIC_HDMIPHY
+2
arch/arm/mach-exynos/include/mach/pmu.h
··· 22 22 NUM_SYS_POWERDOWN, 23 23 }; 24 24 25 + extern unsigned long l2x0_regs_phys; 25 26 struct exynos4_pmu_conf { 26 27 void __iomem *reg; 27 28 unsigned int val[NUM_SYS_POWERDOWN]; 28 29 }; 29 30 30 31 extern void exynos4_sys_powerdown_conf(enum sys_powerdown mode); 32 + extern void s3c_cpu_resume(void); 31 33 32 34 #endif /* __ASM_ARCH_PMU_H */
+13 -8
arch/arm/mach-exynos/mct.c
··· 30 30 #include <mach/regs-mct.h> 31 31 #include <asm/mach/time.h> 32 32 33 + #define TICK_BASE_CNT 1 34 + 33 35 enum { 34 36 MCT_INT_SPI, 35 37 MCT_INT_PPI 36 38 }; 37 39 38 - static unsigned long clk_cnt_per_tick; 39 40 static unsigned long clk_rate; 40 41 static unsigned int mct_int_type; 41 42 ··· 207 206 static void exynos4_comp_set_mode(enum clock_event_mode mode, 208 207 struct clock_event_device *evt) 209 208 { 209 + unsigned long cycles_per_jiffy; 210 210 exynos4_mct_comp0_stop(); 211 211 212 212 switch (mode) { 213 213 case CLOCK_EVT_MODE_PERIODIC: 214 - exynos4_mct_comp0_start(mode, clk_cnt_per_tick); 214 + cycles_per_jiffy = 215 + (((unsigned long long) NSEC_PER_SEC / HZ * evt->mult) >> evt->shift); 216 + exynos4_mct_comp0_start(mode, cycles_per_jiffy); 215 217 break; 216 218 217 219 case CLOCK_EVT_MODE_ONESHOT: ··· 253 249 254 250 static void exynos4_clockevent_init(void) 255 251 { 256 - clk_cnt_per_tick = clk_rate / 2 / HZ; 257 - 258 - clockevents_calc_mult_shift(&mct_comp_device, clk_rate / 2, 5); 252 + clockevents_calc_mult_shift(&mct_comp_device, clk_rate, 5); 259 253 mct_comp_device.max_delta_ns = 260 254 clockevent_delta2ns(0xffffffff, &mct_comp_device); 261 255 mct_comp_device.min_delta_ns = ··· 317 315 struct clock_event_device *evt) 318 316 { 319 317 struct mct_clock_event_device *mevt = this_cpu_ptr(&percpu_mct_tick); 318 + unsigned long cycles_per_jiffy; 320 319 321 320 exynos4_mct_tick_stop(mevt); 322 321 323 322 switch (mode) { 324 323 case CLOCK_EVT_MODE_PERIODIC: 325 - exynos4_mct_tick_start(clk_cnt_per_tick, mevt); 324 + cycles_per_jiffy = 325 + (((unsigned long long) NSEC_PER_SEC / HZ * evt->mult) >> evt->shift); 326 + exynos4_mct_tick_start(cycles_per_jiffy, mevt); 326 327 break; 327 328 328 329 case CLOCK_EVT_MODE_ONESHOT: ··· 399 394 evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; 400 395 evt->rating = 450; 401 396 402 - clockevents_calc_mult_shift(evt, clk_rate / 2, 5); 397 + clockevents_calc_mult_shift(evt, clk_rate / (TICK_BASE_CNT + 1), 5); 403 398 evt->max_delta_ns = 404 399 clockevent_delta2ns(0x7fffffff, evt); 405 400 evt->min_delta_ns = ··· 407 402 408 403 clockevents_register_device(evt); 409 404 410 - exynos4_mct_write(0x1, mevt->base + MCT_L_TCNTB_OFFSET); 405 + exynos4_mct_write(TICK_BASE_CNT, mevt->base + MCT_L_TCNTB_OFFSET); 411 406 412 407 if (mct_int_type == MCT_INT_SPI) { 413 408 if (cpu == 0) {
-15
arch/arm/mach-exynos/pm.c
··· 155 155 SAVE_ITEM(S5P_SROM_BC3), 156 156 }; 157 157 158 - static struct sleep_save exynos4_l2cc_save[] = { 159 - SAVE_ITEM(S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL), 160 - SAVE_ITEM(S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL), 161 - SAVE_ITEM(S5P_VA_L2CC + L2X0_PREFETCH_CTRL), 162 - SAVE_ITEM(S5P_VA_L2CC + L2X0_POWER_CTRL), 163 - SAVE_ITEM(S5P_VA_L2CC + L2X0_AUX_CTRL), 164 - }; 165 158 166 159 /* For Cortex-A9 Diagnostic and Power control register */ 167 160 static unsigned int save_arm_register[2]; ··· 175 182 u32 tmp; 176 183 177 184 s3c_pm_do_save(exynos4_core_save, ARRAY_SIZE(exynos4_core_save)); 178 - s3c_pm_do_save(exynos4_l2cc_save, ARRAY_SIZE(exynos4_l2cc_save)); 179 185 s3c_pm_do_save(exynos4_epll_save, ARRAY_SIZE(exynos4_epll_save)); 180 186 s3c_pm_do_save(exynos4_vpll_save, ARRAY_SIZE(exynos4_vpll_save)); 181 187 ··· 378 386 379 387 #ifdef CONFIG_SMP 380 388 scu_enable(S5P_VA_SCU); 381 - #endif 382 - 383 - #ifdef CONFIG_CACHE_L2X0 384 - s3c_pm_do_restore_core(exynos4_l2cc_save, ARRAY_SIZE(exynos4_l2cc_save)); 385 - outer_inv_all(); 386 - /* enable L2X0*/ 387 - writel_relaxed(1, S5P_VA_L2CC + L2X0_CTRL); 388 389 #endif 389 390 390 391 early_wakeup:
+1 -1
arch/arm/mach-highbank/highbank.c
··· 110 110 111 111 highbank_clocks_init(); 112 112 113 - sp804_clocksource_init(timer_base + 0x20, "timer1"); 113 + sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1"); 114 114 sp804_clockevents_init(timer_base, irq, "timer0"); 115 115 116 116 twd_local_timer_of_register();
-1
arch/arm/mach-highbank/include/mach/memory.h
··· 1 - /* empty */
+2 -2
arch/arm/mach-imx/Makefile
··· 8 8 obj-$(CONFIG_SOC_IMX27) += cpu-imx27.o pm-imx27.o 9 9 obj-$(CONFIG_SOC_IMX27) += clock-imx27.o mm-imx27.o ehci-imx27.o 10 10 11 - obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clock-imx31.o iomux-imx31.o ehci-imx31.o 12 - obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clock-imx35.o ehci-imx35.o 11 + obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clock-imx31.o iomux-imx31.o ehci-imx31.o pm-imx3.o 12 + obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clock-imx35.o ehci-imx35.o pm-imx3.o 13 13 14 14 obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clock-mx51-mx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o 15 15
-36
arch/arm/mach-imx/cpu-imx5.c
··· 149 149 return mx5_cpu_rev; 150 150 } 151 151 EXPORT_SYMBOL(mx50_revision); 152 - 153 - static int __init post_cpu_init(void) 154 - { 155 - unsigned int reg; 156 - void __iomem *base; 157 - 158 - if (cpu_is_mx51() || cpu_is_mx53()) { 159 - if (cpu_is_mx51()) 160 - base = MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR); 161 - else 162 - base = MX53_IO_ADDRESS(MX53_AIPS1_BASE_ADDR); 163 - 164 - __raw_writel(0x0, base + 0x40); 165 - __raw_writel(0x0, base + 0x44); 166 - __raw_writel(0x0, base + 0x48); 167 - __raw_writel(0x0, base + 0x4C); 168 - reg = __raw_readl(base + 0x50) & 0x00FFFFFF; 169 - __raw_writel(reg, base + 0x50); 170 - 171 - if (cpu_is_mx51()) 172 - base = MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR); 173 - else 174 - base = MX53_IO_ADDRESS(MX53_AIPS2_BASE_ADDR); 175 - 176 - __raw_writel(0x0, base + 0x40); 177 - __raw_writel(0x0, base + 0x44); 178 - __raw_writel(0x0, base + 0x48); 179 - __raw_writel(0x0, base + 0x4C); 180 - reg = __raw_readl(base + 0x50) & 0x00FFFFFF; 181 - __raw_writel(reg, base + 0x50); 182 - } 183 - 184 - return 0; 185 - } 186 - 187 - postcore_initcall(post_cpu_init);
+1
arch/arm/mach-imx/crmregs-imx3.h
··· 77 77 #define MXC_CCM_CCMR_SSI2S_MASK (0x3 << 21) 78 78 #define MXC_CCM_CCMR_LPM_OFFSET 14 79 79 #define MXC_CCM_CCMR_LPM_MASK (0x3 << 14) 80 + #define MXC_CCM_CCMR_LPM_WAIT_MX35 (0x1 << 14) 80 81 #define MXC_CCM_CCMR_FIRS_OFFSET 11 81 82 #define MXC_CCM_CCMR_FIRS_MASK (0x3 << 11) 82 83 #define MXC_CCM_CCMR_UPE (1 << 9)
+11
arch/arm/mach-imx/mm-imx3.c
··· 34 34 { 35 35 unsigned long reg = 0; 36 36 37 + mx3_cpu_lp_set(MX3_WAIT); 38 + 37 39 __asm__ __volatile__( 38 40 /* disable I and D cache */ 39 41 "mrc p15, 0, %0, c1, c0, 0\n" ··· 179 177 } 180 178 181 179 imx_add_imx_sdma("imx31-sdma", MX31_SDMA_BASE_ADDR, MX31_INT_SDMA, &imx31_sdma_pdata); 180 + 181 + imx_set_aips(MX31_IO_ADDRESS(MX31_AIPS1_BASE_ADDR)); 182 + imx_set_aips(MX31_IO_ADDRESS(MX31_AIPS2_BASE_ADDR)); 183 + 182 184 platform_device_register_simple("imx31-audmux", 0, imx31_audmux_res, 183 185 ARRAY_SIZE(imx31_audmux_res)); 184 186 } ··· 273 267 } 274 268 275 269 imx_add_imx_sdma("imx35-sdma", MX35_SDMA_BASE_ADDR, MX35_INT_SDMA, &imx35_sdma_pdata); 270 + 271 + /* Setup AIPS registers */ 272 + imx_set_aips(MX35_IO_ADDRESS(MX35_AIPS1_BASE_ADDR)); 273 + imx_set_aips(MX35_IO_ADDRESS(MX35_AIPS2_BASE_ADDR)); 274 + 276 275 /* i.mx35 has the i.mx31 type audmux */ 277 276 platform_device_register_simple("imx31-audmux", 0, imx35_audmux_res, 278 277 ARRAY_SIZE(imx35_audmux_res));
+10
arch/arm/mach-imx/mm-imx5.c
··· 201 201 202 202 /* i.mx51 has the i.mx35 type sdma */ 203 203 imx_add_imx_sdma("imx35-sdma", MX51_SDMA_BASE_ADDR, MX51_INT_SDMA, &imx51_sdma_pdata); 204 + 205 + /* Setup AIPS registers */ 206 + imx_set_aips(MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR)); 207 + imx_set_aips(MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR)); 208 + 204 209 /* i.mx51 has the i.mx31 type audmux */ 205 210 platform_device_register_simple("imx31-audmux", 0, imx51_audmux_res, 206 211 ARRAY_SIZE(imx51_audmux_res)); ··· 224 219 225 220 /* i.mx53 has the i.mx35 type sdma */ 226 221 imx_add_imx_sdma("imx35-sdma", MX53_SDMA_BASE_ADDR, MX53_INT_SDMA, &imx53_sdma_pdata); 222 + 223 + /* Setup AIPS registers */ 224 + imx_set_aips(MX53_IO_ADDRESS(MX53_AIPS1_BASE_ADDR)); 225 + imx_set_aips(MX53_IO_ADDRESS(MX53_AIPS2_BASE_ADDR)); 226 + 227 227 /* i.mx53 has the i.mx31 type audmux */ 228 228 platform_device_register_simple("imx31-audmux", 0, imx53_audmux_res, 229 229 ARRAY_SIZE(imx53_audmux_res));
+37
arch/arm/mach-imx/pm-imx3.c
··· 1 + /* 2 + * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved. 3 + * 4 + * The code contained herein is licensed under the GNU General Public 5 + * License. You may obtain a copy of the GNU General Public License 6 + * Version 2 or later at the following locations: 7 + * 8 + * http://www.opensource.org/licenses/gpl-license.html 9 + * http://www.gnu.org/copyleft/gpl.html 10 + */ 11 + #include <linux/io.h> 12 + #include <mach/common.h> 13 + #include <mach/hardware.h> 14 + #include <mach/devices-common.h> 15 + #include "crmregs-imx3.h" 16 + 17 + /* 18 + * Set cpu low power mode before WFI instruction. This function is called 19 + * mx3 because it can be used for mx31 and mx35. 20 + * Currently only WAIT_MODE is supported. 21 + */ 22 + void mx3_cpu_lp_set(enum mx3_cpu_pwr_mode mode) 23 + { 24 + int reg = __raw_readl(MXC_CCM_CCMR); 25 + reg &= ~MXC_CCM_CCMR_LPM_MASK; 26 + 27 + switch (mode) { 28 + case MX3_WAIT: 29 + if (cpu_is_mx35()) 30 + reg |= MXC_CCM_CCMR_LPM_WAIT_MX35; 31 + __raw_writel(reg, MXC_CCM_CCMR); 32 + break; 33 + default: 34 + pr_err("Unknown cpu power mode: %d\n", mode); 35 + return; 36 + } 37 + }
+5 -29
arch/arm/mach-mxs/clock-mx23.c
··· 223 223 { 224 224 u32 reg, bm_busy, div_max, d, f, div, frac; 225 225 unsigned long diff, parent_rate, calc_rate; 226 - int i; 227 226 228 227 parent_rate = clk_get_rate(clk->parent); 229 228 ··· 274 275 reg |= div << BP_CLKCTRL_CPU_DIV_CPU; 275 276 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU); 276 277 277 - for (i = 10000; i; i--) 278 - if (!(__raw_readl(CLKCTRL_BASE_ADDR + 279 - HW_CLKCTRL_CPU) & bm_busy)) 280 - break; 281 - if (!i) { 282 - pr_err("%s: divider writing timeout\n", __func__); 283 - return -ETIMEDOUT; 284 - } 278 + mxs_clkctrl_timeout(HW_CLKCTRL_CPU, bm_busy); 285 279 286 280 return 0; 287 281 } ··· 284 292 { \ 285 293 u32 reg, div_max, div; \ 286 294 unsigned long parent_rate; \ 287 - int i; \ 288 295 \ 289 296 parent_rate = clk_get_rate(clk->parent); \ 290 297 div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \ ··· 301 310 } \ 302 311 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \ 303 312 \ 304 - for (i = 10000; i; i--) \ 305 - if (!(__raw_readl(CLKCTRL_BASE_ADDR + \ 306 - HW_CLKCTRL_##dr) & BM_CLKCTRL_##dr##_BUSY)) \ 307 - break; \ 308 - if (!i) { \ 309 - pr_err("%s: divider writing timeout\n", __func__); \ 310 - return -ETIMEDOUT; \ 311 - } \ 312 - \ 313 + mxs_clkctrl_timeout(HW_CLKCTRL_##dr, BM_CLKCTRL_##dr##_BUSY); \ 313 314 return 0; \ 314 315 } 315 316 ··· 444 461 static int clk_misc_init(void) 445 462 { 446 463 u32 reg; 447 - int i; 464 + int ret; 448 465 449 466 /* Fix up parent per register setting */ 450 467 reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ); ··· 493 510 reg |= 3 << BP_CLKCTRL_HBUS_DIV; 494 511 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS); 495 512 496 - for (i = 10000; i; i--) 497 - if (!(__raw_readl(CLKCTRL_BASE_ADDR + 498 - HW_CLKCTRL_HBUS) & BM_CLKCTRL_HBUS_BUSY)) 499 - break; 500 - if (!i) { 501 - pr_err("%s: divider writing timeout\n", __func__); 502 - return -ETIMEDOUT; 503 - } 513 + ret = mxs_clkctrl_timeout(HW_CLKCTRL_HBUS, BM_CLKCTRL_HBUS_BUSY); 504 514 505 515 /* Gate off cpu clock in WFI for power saving */ 506 516 __raw_writel(BM_CLKCTRL_CPU_INTERRUPT_WAIT, ··· 508 532 reg |= 30 << BP_CLKCTRL_FRAC_IOFRAC; 509 533 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC); 510 534 511 - return 0; 535 + return ret; 512 536 } 513 537 514 538 int __init mx23_clocks_init(void)
+14 -43
arch/arm/mach-mxs/clock-mx28.c
··· 322 322 { \ 323 323 u32 reg, bm_busy, div_max, d, f, div, frac; \ 324 324 unsigned long diff, parent_rate, calc_rate; \ 325 - int i; \ 326 325 \ 327 326 div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \ 328 327 bm_busy = BM_CLKCTRL_##dr##_BUSY; \ ··· 395 396 } \ 396 397 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \ 397 398 \ 398 - for (i = 10000; i; i--) \ 399 - if (!(__raw_readl(CLKCTRL_BASE_ADDR + \ 400 - HW_CLKCTRL_##dr) & bm_busy)) \ 401 - break; \ 402 - if (!i) { \ 403 - pr_err("%s: divider writing timeout\n", __func__); \ 404 - return -ETIMEDOUT; \ 405 - } \ 406 - \ 407 - return 0; \ 399 + return mxs_clkctrl_timeout(HW_CLKCTRL_##dr, bm_busy); \ 408 400 } 409 401 410 402 _CLK_SET_RATE(cpu_clk, CPU, FRAC0, CPU) ··· 411 421 { \ 412 422 u32 reg, div_max, div; \ 413 423 unsigned long parent_rate; \ 414 - int i; \ 415 424 \ 416 425 parent_rate = clk_get_rate(clk->parent); \ 417 426 div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \ ··· 428 439 } \ 429 440 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \ 430 441 \ 431 - for (i = 10000; i; i--) \ 432 - if (!(__raw_readl(CLKCTRL_BASE_ADDR + \ 433 - HW_CLKCTRL_##dr) & BM_CLKCTRL_##dr##_BUSY)) \ 434 - break; \ 435 - if (!i) { \ 436 - pr_err("%s: divider writing timeout\n", __func__); \ 437 - return -ETIMEDOUT; \ 438 - } \ 439 - \ 440 - return 0; \ 442 + return mxs_clkctrl_timeout(HW_CLKCTRL_##dr, BM_CLKCTRL_##dr##_BUSY);\ 441 443 } 442 444 443 445 _CLK_SET_RATE1(xbus_clk, XBUS) ··· 441 461 u32 reg; \ 442 462 u64 lrate; \ 443 463 unsigned long parent_rate; \ 444 - int i; \ 445 464 \ 446 465 parent_rate = clk_get_rate(clk->parent); \ 447 466 if (rate > parent_rate) \ ··· 456 477 reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs); \ 457 478 reg &= ~BM_CLKCTRL_##rs##_DIV; \ 458 479 reg |= div << BP_CLKCTRL_##rs##_DIV; \ 480 + if (reg & (1 << clk->enable_shift)) { \ 481 + pr_err("%s: clock is gated\n", __func__); \ 482 + return -EINVAL; \ 483 + } \ 459 484 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs); \ 460 485 \ 461 - for (i = 10000; i; i--) \ 462 - if (!(__raw_readl(CLKCTRL_BASE_ADDR + \ 463 - HW_CLKCTRL_##rs) & BM_CLKCTRL_##rs##_BUSY)) \ 464 - break; \ 465 - if (!i) { \ 466 - pr_err("%s: divider writing timeout\n", __func__); \ 467 - return -ETIMEDOUT; \ 468 - } \ 469 - \ 470 - return 0; \ 486 + return mxs_clkctrl_timeout(HW_CLKCTRL_##rs, BM_CLKCTRL_##rs##_BUSY);\ 471 487 } 472 488 473 489 _CLK_SET_RATE_SAIF(saif0_clk, SAIF0) ··· 628 654 _REGISTER_CLOCK("mxs-dma-apbx", NULL, xbus_clk) 629 655 _REGISTER_CLOCK("mxs-mmc.0", NULL, ssp0_clk) 630 656 _REGISTER_CLOCK("mxs-mmc.1", NULL, ssp1_clk) 657 + _REGISTER_CLOCK("mxs-mmc.2", NULL, ssp2_clk) 658 + _REGISTER_CLOCK("mxs-mmc.3", NULL, ssp3_clk) 631 659 _REGISTER_CLOCK("flexcan.0", NULL, can0_clk) 632 660 _REGISTER_CLOCK("flexcan.1", NULL, can1_clk) 633 661 _REGISTER_CLOCK(NULL, "usb0", usb0_clk) ··· 652 676 static int clk_misc_init(void) 653 677 { 654 678 u32 reg; 655 - int i; 679 + int ret; 656 680 657 681 /* Fix up parent per register setting */ 658 682 reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ); ··· 732 756 reg |= 3 << BP_CLKCTRL_HBUS_DIV; 733 757 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS); 734 758 735 - for (i = 10000; i; i--) 736 - if (!(__raw_readl(CLKCTRL_BASE_ADDR + 737 - HW_CLKCTRL_HBUS) & BM_CLKCTRL_HBUS_ASM_BUSY)) 738 - break; 739 - if (!i) { 740 - pr_err("%s: divider writing timeout\n", __func__); 741 - return -ETIMEDOUT; 742 - } 759 + ret = mxs_clkctrl_timeout(HW_CLKCTRL_HBUS, BM_CLKCTRL_HBUS_ASM_BUSY); 743 760 744 761 /* Gate off cpu clock in WFI for power saving */ 745 762 __raw_writel(BM_CLKCTRL_CPU_INTERRUPT_WAIT, ··· 759 790 reg |= 30 << BP_CLKCTRL_FRAC0_IO0FRAC; 760 791 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC0); 761 792 762 - return 0; 793 + return ret; 763 794 } 764 795 765 796 int __init mx28_clocks_init(void) ··· 772 803 */ 773 804 clk_set_parent(&ssp0_clk, &ref_io0_clk); 774 805 clk_set_parent(&ssp1_clk, &ref_io0_clk); 806 + clk_set_parent(&ssp2_clk, &ref_io1_clk); 807 + clk_set_parent(&ssp3_clk, &ref_io1_clk); 775 808 776 809 clk_prepare_enable(&cpu_clk); 777 810 clk_prepare_enable(&hbus_clk);
+2
arch/arm/mach-mxs/devices/platform-mxs-mmc.c
··· 41 41 const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst = { 42 42 mxs_mxs_mmc_data_entry(MX28, 0, 0), 43 43 mxs_mxs_mmc_data_entry(MX28, 1, 1), 44 + mxs_mxs_mmc_data_entry(MX28, 2, 2), 45 + mxs_mxs_mmc_data_entry(MX28, 3, 3), 44 46 }; 45 47 #endif 46 48
+2
arch/arm/mach-mxs/include/mach/common.h
··· 31 31 32 32 extern void icoll_init_irq(void); 33 33 34 + extern int mxs_clkctrl_timeout(unsigned int reg_offset, unsigned int mask); 35 + 34 36 #endif /* __MACH_MXS_COMMON_H__ */
+16
arch/arm/mach-mxs/system.c
··· 37 37 #define MXS_MODULE_CLKGATE (1 << 30) 38 38 #define MXS_MODULE_SFTRST (1 << 31) 39 39 40 + #define CLKCTRL_TIMEOUT 10 /* 10 ms */ 41 + 40 42 static void __iomem *mxs_clkctrl_reset_addr; 41 43 42 44 /* ··· 139 137 return -ETIMEDOUT; 140 138 } 141 139 EXPORT_SYMBOL(mxs_reset_block); 140 + 141 + int mxs_clkctrl_timeout(unsigned int reg_offset, unsigned int mask) 142 + { 143 + unsigned long timeout = jiffies + msecs_to_jiffies(CLKCTRL_TIMEOUT); 144 + while (readl_relaxed(MXS_IO_ADDRESS(MXS_CLKCTRL_BASE_ADDR) 145 + + reg_offset) & mask) { 146 + if (time_after(jiffies, timeout)) { 147 + pr_err("Timeout at CLKCTRL + 0x%x\n", reg_offset); 148 + return -ETIMEDOUT; 149 + } 150 + } 151 + 152 + return 0; 153 + }
+78 -108
arch/arm/mach-omap2/id.c
··· 29 29 #include "control.h" 30 30 31 31 static unsigned int omap_revision; 32 - 32 + static const char *cpu_rev; 33 33 u32 omap_features; 34 34 35 35 unsigned int omap_rev(void) ··· 114 114 odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_3); 115 115 } 116 116 117 - static void __init omap24xx_check_revision(void) 117 + void __init omap2xxx_check_revision(void) 118 118 { 119 119 int i, j; 120 120 u32 idcode, prod_id; ··· 168 168 pr_info("\n"); 169 169 } 170 170 171 + #define OMAP3_SHOW_FEATURE(feat) \ 172 + if (omap3_has_ ##feat()) \ 173 + printk(#feat" "); 174 + 175 + static void __init omap3_cpuinfo(void) 176 + { 177 + const char *cpu_name; 178 + 179 + /* 180 + * OMAP3430 and OMAP3530 are assumed to be same. 181 + * 182 + * OMAP3525, OMAP3515 and OMAP3503 can be detected only based 183 + * on available features. Upon detection, update the CPU id 184 + * and CPU class bits. 185 + */ 186 + if (cpu_is_omap3630()) { 187 + cpu_name = "OMAP3630"; 188 + } else if (cpu_is_omap3517()) { 189 + /* AM35xx devices */ 190 + cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; 191 + } else if (cpu_is_ti816x()) { 192 + cpu_name = "TI816X"; 193 + } else if (cpu_is_am335x()) { 194 + cpu_name = "AM335X"; 195 + } else if (cpu_is_ti814x()) { 196 + cpu_name = "TI814X"; 197 + } else if (omap3_has_iva() && omap3_has_sgx()) { 198 + /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */ 199 + cpu_name = "OMAP3430/3530"; 200 + } else if (omap3_has_iva()) { 201 + cpu_name = "OMAP3525"; 202 + } else if (omap3_has_sgx()) { 203 + cpu_name = "OMAP3515"; 204 + } else { 205 + cpu_name = "OMAP3503"; 206 + } 207 + 208 + /* Print verbose information */ 209 + pr_info("%s ES%s (", cpu_name, cpu_rev); 210 + 211 + OMAP3_SHOW_FEATURE(l2cache); 212 + OMAP3_SHOW_FEATURE(iva); 213 + OMAP3_SHOW_FEATURE(sgx); 214 + OMAP3_SHOW_FEATURE(neon); 215 + OMAP3_SHOW_FEATURE(isp); 216 + OMAP3_SHOW_FEATURE(192mhz_clk); 217 + 218 + printk(")\n"); 219 + } 220 + 171 221 #define OMAP3_CHECK_FEATURE(status,feat) \ 172 222 if (((status & OMAP3_ ##feat## _MASK) \ 173 223 >> OMAP3_ ##feat## _SHIFT) != FEAT_ ##feat## _NONE) { \ 174 224 omap_features |= OMAP3_HAS_ ##feat; \ 175 225 } 176 226 177 - static void __init omap3_check_features(void) 227 + void __init omap3xxx_check_features(void) 178 228 { 179 229 u32 status; 180 230 ··· 251 201 * TODO: Get additional info (where applicable) 252 202 * e.g. Size of L2 cache. 253 203 */ 204 + 205 + omap3_cpuinfo(); 254 206 } 255 207 256 - static void __init omap4_check_features(void) 208 + void __init omap4xxx_check_features(void) 257 209 { 258 210 u32 si_type; 259 211 ··· 280 228 } 281 229 } 282 230 283 - static void __init ti81xx_check_features(void) 231 + void __init ti81xx_check_features(void) 284 232 { 285 233 omap_features = OMAP3_HAS_NEON; 234 + omap3_cpuinfo(); 286 235 } 287 236 288 - static void __init omap3_check_revision(const char **cpu_rev) 237 + void __init omap3xxx_check_revision(void) 289 238 { 290 239 u32 cpuid, idcode; 291 240 u16 hawkeye; ··· 300 247 cpuid = read_cpuid(CPUID_ID); 301 248 if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) { 302 249 omap_revision = OMAP3430_REV_ES1_0; 303 - *cpu_rev = "1.0"; 250 + cpu_rev = "1.0"; 304 251 return; 305 252 } 306 253 ··· 321 268 case 0: /* Take care of early samples */ 322 269 case 1: 323 270 omap_revision = OMAP3430_REV_ES2_0; 324 - *cpu_rev = "2.0"; 271 + cpu_rev = "2.0"; 325 272 break; 326 273 case 2: 327 274 omap_revision = OMAP3430_REV_ES2_1; 328 - *cpu_rev = "2.1"; 275 + cpu_rev = "2.1"; 329 276 break; 330 277 case 3: 331 278 omap_revision = OMAP3430_REV_ES3_0; 332 - *cpu_rev = "3.0"; 279 + cpu_rev = "3.0"; 333 280 break; 334 281 case 4: 335 282 omap_revision = OMAP3430_REV_ES3_1; 336 - *cpu_rev = "3.1"; 283 + cpu_rev = "3.1"; 337 284 break; 338 285 case 7: 339 286 /* FALLTHROUGH */ 340 287 default: 341 288 /* Use the latest known revision as default */ 342 289 omap_revision = OMAP3430_REV_ES3_1_2; 343 - *cpu_rev = "3.1.2"; 290 + cpu_rev = "3.1.2"; 344 291 } 345 292 break; 346 293 case 0xb868: ··· 353 300 switch (rev) { 354 301 case 0: 355 302 omap_revision = OMAP3517_REV_ES1_0; 356 - *cpu_rev = "1.0"; 303 + cpu_rev = "1.0"; 357 304 break; 358 305 case 1: 359 306 /* FALLTHROUGH */ 360 307 default: 361 308 omap_revision = OMAP3517_REV_ES1_1; 362 - *cpu_rev = "1.1"; 309 + cpu_rev = "1.1"; 363 310 } 364 311 break; 365 312 case 0xb891: ··· 368 315 switch(rev) { 369 316 case 0: /* Take care of early samples */ 370 317 omap_revision = OMAP3630_REV_ES1_0; 371 - *cpu_rev = "1.0"; 318 + cpu_rev = "1.0"; 372 319 break; 373 320 case 1: 374 321 omap_revision = OMAP3630_REV_ES1_1; 375 - *cpu_rev = "1.1"; 322 + cpu_rev = "1.1"; 376 323 break; 377 324 case 2: 378 325 /* FALLTHROUGH */ 379 326 default: 380 327 omap_revision = OMAP3630_REV_ES1_2; 381 - *cpu_rev = "1.2"; 328 + cpu_rev = "1.2"; 382 329 } 383 330 break; 384 331 case 0xb81e: 385 332 switch (rev) { 386 333 case 0: 387 334 omap_revision = TI8168_REV_ES1_0; 388 - *cpu_rev = "1.0"; 335 + cpu_rev = "1.0"; 389 336 break; 390 337 case 1: 391 338 /* FALLTHROUGH */ 392 339 default: 393 340 omap_revision = TI8168_REV_ES1_1; 394 - *cpu_rev = "1.1"; 341 + cpu_rev = "1.1"; 395 342 break; 396 343 } 397 344 break; 398 345 case 0xb944: 399 346 omap_revision = AM335X_REV_ES1_0; 400 - *cpu_rev = "1.0"; 347 + cpu_rev = "1.0"; 401 348 break; 402 349 case 0xb8f2: 403 350 switch (rev) { ··· 405 352 /* FALLTHROUGH */ 406 353 case 1: 407 354 omap_revision = TI8148_REV_ES1_0; 408 - *cpu_rev = "1.0"; 355 + cpu_rev = "1.0"; 409 356 break; 410 357 case 2: 411 358 omap_revision = TI8148_REV_ES2_0; 412 - *cpu_rev = "2.0"; 359 + cpu_rev = "2.0"; 413 360 break; 414 361 case 3: 415 362 /* FALLTHROUGH */ 416 363 default: 417 364 omap_revision = TI8148_REV_ES2_1; 418 - *cpu_rev = "2.1"; 365 + cpu_rev = "2.1"; 419 366 break; 420 367 } 421 368 break; 422 369 default: 423 370 /* Unknown default to latest silicon rev as default */ 424 371 omap_revision = OMAP3630_REV_ES1_2; 425 - *cpu_rev = "1.2"; 372 + cpu_rev = "1.2"; 426 373 pr_warn("Warning: unknown chip type; assuming OMAP3630ES1.2\n"); 427 374 } 428 375 } 429 376 430 - static void __init omap4_check_revision(void) 377 + void __init omap4xxx_check_revision(void) 431 378 { 432 379 u32 idcode; 433 380 u16 hawkeye; ··· 498 445 499 446 pr_info("OMAP%04x ES%d.%d\n", omap_rev() >> 16, 500 447 ((omap_rev() >> 12) & 0xf), ((omap_rev() >> 8) & 0xf)); 501 - } 502 - 503 - #define OMAP3_SHOW_FEATURE(feat) \ 504 - if (omap3_has_ ##feat()) \ 505 - printk(#feat" "); 506 - 507 - static void __init omap3_cpuinfo(const char *cpu_rev) 508 - { 509 - const char *cpu_name; 510 - 511 - /* 512 - * OMAP3430 and OMAP3530 are assumed to be same. 513 - * 514 - * OMAP3525, OMAP3515 and OMAP3503 can be detected only based 515 - * on available features. Upon detection, update the CPU id 516 - * and CPU class bits. 517 - */ 518 - if (cpu_is_omap3630()) { 519 - cpu_name = "OMAP3630"; 520 - } else if (cpu_is_omap3517()) { 521 - /* AM35xx devices */ 522 - cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505"; 523 - } else if (cpu_is_ti816x()) { 524 - cpu_name = "TI816X"; 525 - } else if (cpu_is_am335x()) { 526 - cpu_name = "AM335X"; 527 - } else if (cpu_is_ti814x()) { 528 - cpu_name = "TI814X"; 529 - } else if (omap3_has_iva() && omap3_has_sgx()) { 530 - /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */ 531 - cpu_name = "OMAP3430/3530"; 532 - } else if (omap3_has_iva()) { 533 - cpu_name = "OMAP3525"; 534 - } else if (omap3_has_sgx()) { 535 - cpu_name = "OMAP3515"; 536 - } else { 537 - cpu_name = "OMAP3503"; 538 - } 539 - 540 - /* Print verbose information */ 541 - pr_info("%s ES%s (", cpu_name, cpu_rev); 542 - 543 - OMAP3_SHOW_FEATURE(l2cache); 544 - OMAP3_SHOW_FEATURE(iva); 545 - OMAP3_SHOW_FEATURE(sgx); 546 - OMAP3_SHOW_FEATURE(neon); 547 - OMAP3_SHOW_FEATURE(isp); 548 - OMAP3_SHOW_FEATURE(192mhz_clk); 549 - 550 - printk(")\n"); 551 - } 552 - 553 - /* 554 - * Try to detect the exact revision of the omap we're running on 555 - */ 556 - void __init omap2_check_revision(void) 557 - { 558 - const char *cpu_rev; 559 - 560 - /* 561 - * At this point we have an idea about the processor revision set 562 - * earlier with omap2_set_globals_tap(). 563 - */ 564 - if (cpu_is_omap24xx()) { 565 - omap24xx_check_revision(); 566 - } else if (cpu_is_omap34xx()) { 567 - omap3_check_revision(&cpu_rev); 568 - 569 - /* TI81XX doesn't have feature register */ 570 - if (!cpu_is_ti81xx()) 571 - omap3_check_features(); 572 - else 573 - ti81xx_check_features(); 574 - 575 - omap3_cpuinfo(cpu_rev); 576 - return; 577 - } else if (cpu_is_omap44xx()) { 578 - omap4_check_revision(); 579 - omap4_check_features(); 580 - return; 581 - } else { 582 - pr_err("OMAP revision unknown, please fix!\n"); 583 - } 584 448 } 585 449 586 450 /*
+8 -1
arch/arm/mach-omap2/io.c
··· 348 348 349 349 static void __init omap_common_init_early(void) 350 350 { 351 - omap2_check_revision(); 352 351 omap_init_consistent_dma_size(); 353 352 } 354 353 ··· 388 389 void __init omap2420_init_early(void) 389 390 { 390 391 omap2_set_globals_242x(); 392 + omap2xxx_check_revision(); 391 393 omap_common_init_early(); 392 394 omap2xxx_voltagedomains_init(); 393 395 omap242x_powerdomains_init(); ··· 403 403 void __init omap2430_init_early(void) 404 404 { 405 405 omap2_set_globals_243x(); 406 + omap2xxx_check_revision(); 406 407 omap_common_init_early(); 407 408 omap2xxx_voltagedomains_init(); 408 409 omap243x_powerdomains_init(); ··· 422 421 void __init omap3_init_early(void) 423 422 { 424 423 omap2_set_globals_3xxx(); 424 + omap3xxx_check_revision(); 425 + omap3xxx_check_features(); 425 426 omap_common_init_early(); 426 427 omap3xxx_voltagedomains_init(); 427 428 omap3xxx_powerdomains_init(); ··· 456 453 void __init ti81xx_init_early(void) 457 454 { 458 455 omap2_set_globals_ti81xx(); 456 + omap3xxx_check_revision(); 457 + ti81xx_check_features(); 459 458 omap_common_init_early(); 460 459 omap3xxx_voltagedomains_init(); 461 460 omap3xxx_powerdomains_init(); ··· 472 467 void __init omap4430_init_early(void) 473 468 { 474 469 omap2_set_globals_443x(); 470 + omap4xxx_check_revision(); 471 + omap4xxx_check_features(); 475 472 omap_common_init_early(); 476 473 omap44xx_voltagedomains_init(); 477 474 omap44xx_powerdomains_init();
+8
arch/arm/mach-s3c64xx/Kconfig
··· 83 83 help 84 84 Common setup code for SPI GPIO configurations 85 85 86 + config S3C64XX_SETUP_USB_PHY 87 + bool 88 + help 89 + Common setup code for USB PHY controller 90 + 86 91 # S36400 Macchine support 87 92 88 93 config MACH_SMDK6400 ··· 162 157 select S3C64XX_SETUP_IDE 163 158 select S3C64XX_SETUP_FB_24BPP 164 159 select S3C64XX_SETUP_KEYPAD 160 + select S3C64XX_SETUP_USB_PHY 165 161 help 166 162 Machine support for the Samsung SMDK6410 167 163 ··· 262 256 select S3C_DEV_USB_HOST 263 257 select S3C64XX_SETUP_SDHCI 264 258 select S3C64XX_SETUP_FB_24BPP 259 + select S3C64XX_SETUP_USB_PHY 265 260 select SAMSUNG_DEV_ADC 266 261 select SAMSUNG_DEV_PWM 267 262 select SAMSUNG_DEV_TS ··· 290 283 select S3C64XX_SETUP_FB_24BPP 291 284 select S3C64XX_SETUP_KEYPAD 292 285 select S3C64XX_SETUP_SPI 286 + select S3C64XX_SETUP_USB_PHY 293 287 select SAMSUNG_DEV_ADC 294 288 select SAMSUNG_DEV_KEYPAD 295 289 select S3C_DEV_USB_HOST
+2
arch/arm/mach-s3c64xx/Makefile
··· 22 22 # PM 23 23 24 24 obj-$(CONFIG_PM) += pm.o irq-pm.o sleep.o 25 + obj-$(CONFIG_CPU_IDLE) += cpuidle.o 25 26 26 27 # DMA support 27 28 ··· 43 42 obj-$(CONFIG_S3C64XX_SETUP_KEYPAD) += setup-keypad.o 44 43 obj-$(CONFIG_S3C64XX_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o 45 44 obj-$(CONFIG_S3C64XX_SETUP_SPI) += setup-spi.o 45 + obj-$(CONFIG_S3C64XX_SETUP_USB_PHY) += setup-usb-phy.o 46 46 47 47 # Machine support 48 48
+111 -10
arch/arm/mach-s3c64xx/clock.c
··· 207 207 .enable = s3c64xx_sclk_ctrl, 208 208 .ctrlbit = S3C_CLKCON_SCLK_MMC2_48, 209 209 }, { 210 + .name = "ac97", 211 + .parent = &clk_p, 212 + .ctrlbit = S3C_CLKCON_PCLK_AC97, 213 + }, { 214 + .name = "cfcon", 215 + .parent = &clk_h, 216 + .enable = s3c64xx_hclk_ctrl, 217 + .ctrlbit = S3C_CLKCON_HCLK_IHOST, 218 + }, { 210 219 .name = "dma0", 211 220 .parent = &clk_h, 212 221 .enable = s3c64xx_hclk_ctrl, ··· 225 216 .parent = &clk_h, 226 217 .enable = s3c64xx_hclk_ctrl, 227 218 .ctrlbit = S3C_CLKCON_HCLK_DMA1, 219 + }, { 220 + .name = "3dse", 221 + .parent = &clk_h, 222 + .enable = s3c64xx_hclk_ctrl, 223 + .ctrlbit = S3C_CLKCON_HCLK_3DSE, 224 + }, { 225 + .name = "hclk_secur", 226 + .parent = &clk_h, 227 + .enable = s3c64xx_hclk_ctrl, 228 + .ctrlbit = S3C_CLKCON_HCLK_SECUR, 229 + }, { 230 + .name = "sdma1", 231 + .parent = &clk_h, 232 + .enable = s3c64xx_hclk_ctrl, 233 + .ctrlbit = S3C_CLKCON_HCLK_SDMA1, 234 + }, { 235 + .name = "sdma0", 236 + .parent = &clk_h, 237 + .enable = s3c64xx_hclk_ctrl, 238 + .ctrlbit = S3C_CLKCON_HCLK_SDMA0, 239 + }, { 240 + .name = "hclk_jpeg", 241 + .parent = &clk_h, 242 + .enable = s3c64xx_hclk_ctrl, 243 + .ctrlbit = S3C_CLKCON_HCLK_JPEG, 244 + }, { 245 + .name = "camif", 246 + .parent = &clk_h, 247 + .enable = s3c64xx_hclk_ctrl, 248 + .ctrlbit = S3C_CLKCON_HCLK_CAMIF, 249 + }, { 250 + .name = "hclk_scaler", 251 + .parent = &clk_h, 252 + .enable = s3c64xx_hclk_ctrl, 253 + .ctrlbit = S3C_CLKCON_HCLK_SCALER, 254 + }, { 255 + .name = "2d", 256 + .parent = &clk_h, 257 + .enable = s3c64xx_hclk_ctrl, 258 + .ctrlbit = S3C_CLKCON_HCLK_2D, 259 + }, { 260 + .name = "tv", 261 + .parent = &clk_h, 262 + .enable = s3c64xx_hclk_ctrl, 263 + .ctrlbit = S3C_CLKCON_HCLK_TV, 264 + }, { 265 + .name = "post0", 266 + .parent = &clk_h, 267 + .enable = s3c64xx_hclk_ctrl, 268 + .ctrlbit = S3C_CLKCON_HCLK_POST0, 269 + }, { 270 + .name = "rot", 271 + .parent = &clk_h, 272 + .enable = s3c64xx_hclk_ctrl, 273 + .ctrlbit = S3C_CLKCON_HCLK_ROT, 274 + }, { 275 + .name = "hclk_mfc", 276 + .parent = &clk_h, 277 + .enable = s3c64xx_hclk_ctrl, 278 + .ctrlbit = S3C_CLKCON_HCLK_MFC, 279 + }, { 280 + .name = "pclk_mfc", 281 + .parent = &clk_p, 282 + .enable = s3c64xx_pclk_ctrl, 283 + .ctrlbit = S3C_CLKCON_PCLK_MFC, 284 + }, { 285 + .name = "dac27", 286 + .enable = s3c64xx_sclk_ctrl, 287 + .ctrlbit = S3C_CLKCON_SCLK_DAC27, 288 + }, { 289 + .name = "tv27", 290 + .enable = s3c64xx_sclk_ctrl, 291 + .ctrlbit = S3C_CLKCON_SCLK_TV27, 292 + }, { 293 + .name = "scaler27", 294 + .enable = s3c64xx_sclk_ctrl, 295 + .ctrlbit = S3C_CLKCON_SCLK_SCALER27, 296 + }, { 297 + .name = "sclk_scaler", 298 + .enable = s3c64xx_sclk_ctrl, 299 + .ctrlbit = S3C_CLKCON_SCLK_SCALER, 300 + }, { 301 + .name = "post0_27", 302 + .enable = s3c64xx_sclk_ctrl, 303 + .ctrlbit = S3C_CLKCON_SCLK_POST0_27, 304 + }, { 305 + .name = "secur", 306 + .enable = s3c64xx_sclk_ctrl, 307 + .ctrlbit = S3C_CLKCON_SCLK_SECUR, 308 + }, { 309 + .name = "sclk_mfc", 310 + .enable = s3c64xx_sclk_ctrl, 311 + .ctrlbit = S3C_CLKCON_SCLK_MFC, 312 + }, { 313 + .name = "cam", 314 + .enable = s3c64xx_sclk_ctrl, 315 + .ctrlbit = S3C_CLKCON_SCLK_CAM, 316 + }, { 317 + .name = "sclk_jpeg", 318 + .enable = s3c64xx_sclk_ctrl, 319 + .ctrlbit = S3C_CLKCON_SCLK_JPEG, 228 320 }, 229 321 }; 230 322 ··· 399 289 .name = "watchdog", 400 290 .parent = &clk_p, 401 291 .ctrlbit = S3C_CLKCON_PCLK_WDT, 402 - }, { 403 - .name = "ac97", 404 - .parent = &clk_p, 405 - .ctrlbit = S3C_CLKCON_PCLK_AC97, 406 - }, { 407 - .name = "cfcon", 408 - .parent = &clk_h, 409 - .enable = s3c64xx_hclk_ctrl, 410 - .ctrlbit = S3C_CLKCON_HCLK_IHOST, 411 - } 292 + }, 412 293 }; 413 294 414 295 static struct clk clk_hsmmc0 = {
+91
arch/arm/mach-s3c64xx/cpuidle.c
··· 1 + /* linux/arch/arm/mach-s3c64xx/cpuidle.c 2 + * 3 + * Copyright (c) 2011 Wolfson Microelectronics, plc 4 + * Copyright (c) 2011 Samsung Electronics Co., Ltd. 5 + * http://www.samsung.com 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License version 2 as 9 + * published by the Free Software Foundation. 10 + */ 11 + 12 + #include <linux/kernel.h> 13 + #include <linux/init.h> 14 + #include <linux/cpuidle.h> 15 + #include <linux/io.h> 16 + #include <linux/export.h> 17 + #include <linux/time.h> 18 + 19 + #include <asm/proc-fns.h> 20 + 21 + #include <mach/map.h> 22 + 23 + #include <mach/regs-sys.h> 24 + #include <mach/regs-syscon-power.h> 25 + 26 + static int s3c64xx_enter_idle(struct cpuidle_device *dev, 27 + struct cpuidle_driver *drv, 28 + int index) 29 + { 30 + struct timeval before, after; 31 + unsigned long tmp; 32 + int idle_time; 33 + 34 + local_irq_disable(); 35 + do_gettimeofday(&before); 36 + 37 + /* Setup PWRCFG to enter idle mode */ 38 + tmp = __raw_readl(S3C64XX_PWR_CFG); 39 + tmp &= ~S3C64XX_PWRCFG_CFG_WFI_MASK; 40 + tmp |= S3C64XX_PWRCFG_CFG_WFI_IDLE; 41 + __raw_writel(tmp, S3C64XX_PWR_CFG); 42 + 43 + cpu_do_idle(); 44 + 45 + do_gettimeofday(&after); 46 + local_irq_enable(); 47 + idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + 48 + (after.tv_usec - before.tv_usec); 49 + 50 + dev->last_residency = idle_time; 51 + return index; 52 + } 53 + 54 + static struct cpuidle_state s3c64xx_cpuidle_set[] = { 55 + [0] = { 56 + .enter = s3c64xx_enter_idle, 57 + .exit_latency = 1, 58 + .target_residency = 1, 59 + .flags = CPUIDLE_FLAG_TIME_VALID, 60 + .name = "IDLE", 61 + .desc = "System active, ARM gated", 62 + }, 63 + }; 64 + 65 + static struct cpuidle_driver s3c64xx_cpuidle_driver = { 66 + .name = "s3c64xx_cpuidle", 67 + .owner = THIS_MODULE, 68 + .state_count = ARRAY_SIZE(s3c64xx_cpuidle_set), 69 + }; 70 + 71 + static struct cpuidle_device s3c64xx_cpuidle_device = { 72 + .state_count = ARRAY_SIZE(s3c64xx_cpuidle_set), 73 + }; 74 + 75 + static int __init s3c64xx_init_cpuidle(void) 76 + { 77 + int ret; 78 + 79 + memcpy(s3c64xx_cpuidle_driver.states, s3c64xx_cpuidle_set, 80 + sizeof(s3c64xx_cpuidle_set)); 81 + cpuidle_register_driver(&s3c64xx_cpuidle_driver); 82 + 83 + ret = cpuidle_register_device(&s3c64xx_cpuidle_device); 84 + if (ret) { 85 + pr_err("Failed to register cpuidle device: %d\n", ret); 86 + return ret; 87 + } 88 + 89 + return 0; 90 + } 91 + device_initcall(s3c64xx_init_cpuidle);
+4
arch/arm/mach-s3c64xx/mach-crag6410.c
··· 59 59 #include <plat/sdhci.h> 60 60 #include <plat/gpio-cfg.h> 61 61 #include <plat/s3c64xx-spi.h> 62 + #include <plat/udc-hs.h> 62 63 63 64 #include <plat/keypad.h> 64 65 #include <plat/clock.h> ··· 699 698 .cfg_gpio = crag6410_cfg_sdhci0, 700 699 }; 701 700 701 + static struct s3c_hsotg_plat crag6410_hsotg_pdata; 702 + 702 703 static void __init crag6410_machine_init(void) 703 704 { 704 705 /* Open drain IRQs need pullups */ ··· 725 722 s3c_i2c0_set_platdata(&i2c0_pdata); 726 723 s3c_i2c1_set_platdata(&i2c1_pdata); 727 724 s3c_fb_set_platdata(&crag6410_lcd_pdata); 725 + s3c_hsotg_set_platdata(&crag6410_hsotg_pdata); 728 726 729 727 i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0)); 730 728 i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
+3
arch/arm/mach-s3c64xx/mach-smartq.c
··· 187 187 }, 188 188 }; 189 189 190 + static struct s3c_hsotg_plat smartq_hsotg_pdata; 191 + 190 192 static int __init smartq_lcd_setup_gpio(void) 191 193 { 192 194 int ret; ··· 385 383 void __init smartq_machine_init(void) 386 384 { 387 385 s3c_i2c0_set_platdata(NULL); 386 + s3c_hsotg_set_platdata(&smartq_hsotg_pdata); 388 387 s3c_hwmon_set_platdata(&smartq_hwmon_pdata); 389 388 s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata); 390 389 s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
+4
arch/arm/mach-s3c64xx/mach-smdk6410.c
··· 72 72 #include <plat/keypad.h> 73 73 #include <plat/backlight.h> 74 74 #include <plat/regs-fb-v4.h> 75 + #include <plat/udc-hs.h> 75 76 76 77 #include "common.h" 77 78 ··· 632 631 .pwm_id = 1, 633 632 }; 634 633 634 + static struct s3c_hsotg_plat smdk6410_hsotg_pdata; 635 + 635 636 static void __init smdk6410_map_io(void) 636 637 { 637 638 u32 tmp; ··· 662 659 s3c_i2c0_set_platdata(NULL); 663 660 s3c_i2c1_set_platdata(NULL); 664 661 s3c_fb_set_platdata(&smdk6410_lcd_pdata); 662 + s3c_hsotg_set_platdata(&smdk6410_hsotg_pdata); 665 663 666 664 samsung_keypad_set_platdata(&smdk6410_keypad_data); 667 665
+90
arch/arm/mach-s3c64xx/setup-usb-phy.c
··· 1 + /* 2 + * Copyright (C) 2011 Samsung Electronics Co.Ltd 3 + * Author: Joonyoung Shim <jy0922.shim@samsung.com> 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms of the GNU General Public License as published by the 7 + * Free Software Foundation; either version 2 of the License, or (at your 8 + * option) any later version. 9 + * 10 + */ 11 + 12 + #include <linux/clk.h> 13 + #include <linux/delay.h> 14 + #include <linux/err.h> 15 + #include <linux/io.h> 16 + #include <linux/platform_device.h> 17 + #include <mach/map.h> 18 + #include <mach/regs-sys.h> 19 + #include <plat/cpu.h> 20 + #include <plat/regs-usb-hsotg-phy.h> 21 + #include <plat/usb-phy.h> 22 + 23 + static int s3c_usb_otgphy_init(struct platform_device *pdev) 24 + { 25 + struct clk *xusbxti; 26 + u32 phyclk; 27 + 28 + writel(readl(S3C64XX_OTHERS) | S3C64XX_OTHERS_USBMASK, S3C64XX_OTHERS); 29 + 30 + /* set clock frequency for PLL */ 31 + phyclk = readl(S3C_PHYCLK) & ~S3C_PHYCLK_CLKSEL_MASK; 32 + 33 + xusbxti = clk_get(&pdev->dev, "xusbxti"); 34 + if (xusbxti && !IS_ERR(xusbxti)) { 35 + switch (clk_get_rate(xusbxti)) { 36 + case 12 * MHZ: 37 + phyclk |= S3C_PHYCLK_CLKSEL_12M; 38 + break; 39 + case 24 * MHZ: 40 + phyclk |= S3C_PHYCLK_CLKSEL_24M; 41 + break; 42 + default: 43 + case 48 * MHZ: 44 + /* default reference clock */ 45 + break; 46 + } 47 + clk_put(xusbxti); 48 + } 49 + 50 + /* TODO: select external clock/oscillator */ 51 + writel(phyclk | S3C_PHYCLK_CLK_FORCE, S3C_PHYCLK); 52 + 53 + /* set to normal OTG PHY */ 54 + writel((readl(S3C_PHYPWR) & ~S3C_PHYPWR_NORMAL_MASK), S3C_PHYPWR); 55 + mdelay(1); 56 + 57 + /* reset OTG PHY and Link */ 58 + writel(S3C_RSTCON_PHY | S3C_RSTCON_HCLK | S3C_RSTCON_PHYCLK, 59 + S3C_RSTCON); 60 + udelay(20); /* at-least 10uS */ 61 + writel(0, S3C_RSTCON); 62 + 63 + return 0; 64 + } 65 + 66 + static int s3c_usb_otgphy_exit(struct platform_device *pdev) 67 + { 68 + writel((readl(S3C_PHYPWR) | S3C_PHYPWR_ANALOG_POWERDOWN | 69 + S3C_PHYPWR_OTG_DISABLE), S3C_PHYPWR); 70 + 71 + writel(readl(S3C64XX_OTHERS) & ~S3C64XX_OTHERS_USBMASK, S3C64XX_OTHERS); 72 + 73 + return 0; 74 + } 75 + 76 + int s5p_usb_phy_init(struct platform_device *pdev, int type) 77 + { 78 + if (type == S5P_USB_PHY_DEVICE) 79 + return s3c_usb_otgphy_init(pdev); 80 + 81 + return -EINVAL; 82 + } 83 + 84 + int s5p_usb_phy_exit(struct platform_device *pdev, int type) 85 + { 86 + if (type == S5P_USB_PHY_DEVICE) 87 + return s3c_usb_otgphy_exit(pdev); 88 + 89 + return -EINVAL; 90 + }
+6
arch/arm/mach-s5pv210/Kconfig
··· 65 65 help 66 66 Common setup code for SPI GPIO configurations. 67 67 68 + config S5PV210_SETUP_USB_PHY 69 + bool 70 + help 71 + Common setup code for USB PHY controller 72 + 68 73 menu "S5PC110 Machines" 69 74 70 75 config MACH_AQUILA ··· 112 107 select S5PV210_SETUP_KEYPAD 113 108 select S5PV210_SETUP_SDHCI 114 109 select S5PV210_SETUP_FIMC 110 + select S5PV210_SETUP_USB_PHY 115 111 help 116 112 Machine support for Samsung GONI board 117 113 S5PC110(MCP) is one of package option of S5PV210
+1
arch/arm/mach-s5pv210/Makefile
··· 39 39 obj-$(CONFIG_S5PV210_SETUP_KEYPAD) += setup-keypad.o 40 40 obj-$(CONFIG_S5PV210_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o 41 41 obj-$(CONFIG_S5PV210_SETUP_SPI) += setup-spi.o 42 + obj-$(CONFIG_S5PV210_SETUP_USB_PHY) += setup-usb-phy.o
-4
arch/arm/mach-s5pv210/include/mach/regs-sys.h
··· 13 13 #define S5PV210_USB_PHY_CON (S3C_VA_SYS + 0xE80C) 14 14 #define S5PV210_USB_PHY0_EN (1 << 0) 15 15 #define S5PV210_USB_PHY1_EN (1 << 1) 16 - 17 - /* compatibility defines for s3c-hsotg driver */ 18 - #define S3C64XX_OTHERS S5PV210_USB_PHY_CON 19 - #define S3C64XX_OTHERS_USBMASK S5PV210_USB_PHY0_EN
+90
arch/arm/mach-s5pv210/setup-usb-phy.c
··· 1 + /* 2 + * Copyright (C) 2012 Samsung Electronics Co.Ltd 3 + * Author: Joonyoung Shim <jy0922.shim@samsung.com> 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License version 2 as 7 + * published by the Free Software Foundationr 8 + */ 9 + 10 + #include <linux/clk.h> 11 + #include <linux/delay.h> 12 + #include <linux/err.h> 13 + #include <linux/io.h> 14 + #include <linux/platform_device.h> 15 + #include <mach/map.h> 16 + #include <mach/regs-sys.h> 17 + #include <plat/cpu.h> 18 + #include <plat/regs-usb-hsotg-phy.h> 19 + #include <plat/usb-phy.h> 20 + 21 + static int s5pv210_usb_otgphy_init(struct platform_device *pdev) 22 + { 23 + struct clk *xusbxti; 24 + u32 phyclk; 25 + 26 + writel(readl(S5PV210_USB_PHY_CON) | S5PV210_USB_PHY0_EN, 27 + S5PV210_USB_PHY_CON); 28 + 29 + /* set clock frequency for PLL */ 30 + phyclk = readl(S3C_PHYCLK) & ~S3C_PHYCLK_CLKSEL_MASK; 31 + 32 + xusbxti = clk_get(&pdev->dev, "xusbxti"); 33 + if (xusbxti && !IS_ERR(xusbxti)) { 34 + switch (clk_get_rate(xusbxti)) { 35 + case 12 * MHZ: 36 + phyclk |= S3C_PHYCLK_CLKSEL_12M; 37 + break; 38 + case 24 * MHZ: 39 + phyclk |= S3C_PHYCLK_CLKSEL_24M; 40 + break; 41 + default: 42 + case 48 * MHZ: 43 + /* default reference clock */ 44 + break; 45 + } 46 + clk_put(xusbxti); 47 + } 48 + 49 + /* TODO: select external clock/oscillator */ 50 + writel(phyclk | S3C_PHYCLK_CLK_FORCE, S3C_PHYCLK); 51 + 52 + /* set to normal OTG PHY */ 53 + writel((readl(S3C_PHYPWR) & ~S3C_PHYPWR_NORMAL_MASK), S3C_PHYPWR); 54 + mdelay(1); 55 + 56 + /* reset OTG PHY and Link */ 57 + writel(S3C_RSTCON_PHY | S3C_RSTCON_HCLK | S3C_RSTCON_PHYCLK, 58 + S3C_RSTCON); 59 + udelay(20); /* at-least 10uS */ 60 + writel(0, S3C_RSTCON); 61 + 62 + return 0; 63 + } 64 + 65 + static int s5pv210_usb_otgphy_exit(struct platform_device *pdev) 66 + { 67 + writel((readl(S3C_PHYPWR) | S3C_PHYPWR_ANALOG_POWERDOWN | 68 + S3C_PHYPWR_OTG_DISABLE), S3C_PHYPWR); 69 + 70 + writel(readl(S5PV210_USB_PHY_CON) & ~S5PV210_USB_PHY0_EN, 71 + S5PV210_USB_PHY_CON); 72 + 73 + return 0; 74 + } 75 + 76 + int s5p_usb_phy_init(struct platform_device *pdev, int type) 77 + { 78 + if (type == S5P_USB_PHY_DEVICE) 79 + return s5pv210_usb_otgphy_init(pdev); 80 + 81 + return -EINVAL; 82 + } 83 + 84 + int s5p_usb_phy_exit(struct platform_device *pdev, int type) 85 + { 86 + if (type == S5P_USB_PHY_DEVICE) 87 + return s5pv210_usb_otgphy_exit(pdev); 88 + 89 + return -EINVAL; 90 + }
+3
arch/arm/mach-tegra/Makefile
··· 7 7 obj-y += timer.o 8 8 obj-y += pinmux.o 9 9 obj-y += fuse.o 10 + obj-$(CONFIG_CPU_IDLE) += cpuidle.o 11 + obj-$(CONFIG_CPU_IDLE) += sleep.o 10 12 obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += powergate.o 11 13 obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_clocks.o 12 14 obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_emc.o 13 15 obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += pinmux-tegra20-tables.o 14 16 obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += pinmux-tegra30-tables.o 15 17 obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += board-dt-tegra30.o 18 + obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += tegra30_clocks.o 16 19 obj-$(CONFIG_SMP) += platsmp.o headsmp.o 17 20 obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 18 21 obj-$(CONFIG_TEGRA_SYSTEM_DMA) += dma.o
+23 -1
arch/arm/mach-tegra/board-dt-tegra30.c
··· 34 34 #include <asm/hardware/gic.h> 35 35 36 36 #include "board.h" 37 + #include "clock.h" 37 38 38 39 static struct of_device_id tegra_dt_match_table[] __initdata = { 39 40 { .compatible = "simple-bus", }, 40 41 {} 41 42 }; 42 43 44 + struct of_dev_auxdata tegra30_auxdata_lookup[] __initdata = { 45 + OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000000, "sdhci-tegra.0", NULL), 46 + OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000200, "sdhci-tegra.1", NULL), 47 + OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000400, "sdhci-tegra.2", NULL), 48 + OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000600, "sdhci-tegra.3", NULL), 49 + OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000C000, "tegra-i2c.0", NULL), 50 + OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000C400, "tegra-i2c.1", NULL), 51 + OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000C500, "tegra-i2c.2", NULL), 52 + OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000C700, "tegra-i2c.3", NULL), 53 + OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000D000, "tegra-i2c.4", NULL), 54 + {} 55 + }; 56 + 57 + static __initdata struct tegra_clk_init_table tegra_dt_clk_init_table[] = { 58 + /* name parent rate enabled */ 59 + { "uartd", "pll_p", 408000000, true }, 60 + { NULL, NULL, 0, 0}, 61 + }; 62 + 43 63 static void __init tegra30_dt_init(void) 44 64 { 65 + tegra_clk_init_from_table(tegra_dt_clk_init_table); 66 + 45 67 of_platform_populate(NULL, tegra_dt_match_table, 46 - NULL, NULL); 68 + tegra30_auxdata_lookup, NULL); 47 69 } 48 70 49 71 static const char *tegra30_dt_board_compat[] = {
+22
arch/arm/mach-tegra/clock.c
··· 399 399 } 400 400 EXPORT_SYMBOL(tegra_periph_reset_assert); 401 401 402 + /* Several extended clock configuration bits (e.g., clock routing, clock 403 + * phase control) are included in PLL and peripheral clock source 404 + * registers. */ 405 + int tegra_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting) 406 + { 407 + int ret = 0; 408 + unsigned long flags; 409 + 410 + spin_lock_irqsave(&c->spinlock, flags); 411 + 412 + if (!c->ops || !c->ops->clk_cfg_ex) { 413 + ret = -ENOSYS; 414 + goto out; 415 + } 416 + ret = c->ops->clk_cfg_ex(c, p, setting); 417 + 418 + out: 419 + spin_unlock_irqrestore(&c->spinlock, flags); 420 + 421 + return ret; 422 + } 423 + 402 424 #ifdef CONFIG_DEBUG_FS 403 425 404 426 static int __clk_lock_all_spinlocks(void)
+15
arch/arm/mach-tegra/clock.h
··· 24 24 #include <linux/list.h> 25 25 #include <linux/spinlock.h> 26 26 27 + #include <mach/clk.h> 28 + 27 29 #define DIV_BUS (1 << 0) 28 30 #define DIV_U71 (1 << 1) 29 31 #define DIV_U71_FIXED (1 << 2) ··· 41 39 #define PERIPH_MANUAL_RESET (1 << 12) 42 40 #define PLL_ALT_MISC_REG (1 << 13) 43 41 #define PLLU (1 << 14) 42 + #define PLLX (1 << 15) 43 + #define MUX_PWM (1 << 16) 44 + #define MUX8 (1 << 17) 45 + #define DIV_U71_UART (1 << 18) 46 + #define MUX_CLK_OUT (1 << 19) 47 + #define PLLM (1 << 20) 48 + #define DIV_U71_INT (1 << 21) 49 + #define DIV_U71_IDLE (1 << 22) 44 50 #define ENABLE_ON_INIT (1 << 28) 51 + #define PERIPH_ON_APB (1 << 29) 45 52 46 53 struct clk; 47 54 ··· 76 65 int (*set_rate)(struct clk *, unsigned long); 77 66 long (*round_rate)(struct clk *, unsigned long); 78 67 void (*reset)(struct clk *, bool); 68 + int (*clk_cfg_ex)(struct clk *, 69 + enum tegra_clk_ex_param, u32); 79 70 }; 80 71 81 72 enum clk_state { ··· 127 114 unsigned long vco_max; 128 115 const struct clk_pll_freq_table *freq_table; 129 116 int lock_delay; 117 + unsigned long fixed_rate; 130 118 } pll; 131 119 struct { 132 120 u32 sel; ··· 160 146 }; 161 147 162 148 void tegra2_init_clocks(void); 149 + void tegra30_init_clocks(void); 163 150 void clk_init(struct clk *clk); 164 151 struct clk *tegra_get_clock_by_name(const char *name); 165 152 int clk_reparent(struct clk *c, struct clk *parent);
+1
arch/arm/mach-tegra/common.c
··· 104 104 #ifdef CONFIG_ARCH_TEGRA_3x_SOC 105 105 void __init tegra30_init_early(void) 106 106 { 107 + tegra30_init_clocks(); 107 108 tegra_init_cache(0x441, 0x551); 108 109 } 109 110 #endif
+107
arch/arm/mach-tegra/cpuidle.c
··· 1 + /* 2 + * arch/arm/mach-tegra/cpuidle.c 3 + * 4 + * CPU idle driver for Tegra CPUs 5 + * 6 + * Copyright (c) 2010-2012, NVIDIA Corporation. 7 + * Copyright (c) 2011 Google, Inc. 8 + * Author: Colin Cross <ccross@android.com> 9 + * Gary King <gking@nvidia.com> 10 + * 11 + * Rework for 3.3 by Peter De Schrijver <pdeschrijver@nvidia.com> 12 + * 13 + * This program is free software; you can redistribute it and/or modify 14 + * it under the terms of the GNU General Public License as published by 15 + * the Free Software Foundation; either version 2 of the License, or 16 + * (at your option) any later version. 17 + * 18 + * This program is distributed in the hope that it will be useful, but WITHOUT 19 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 21 + * more details. 22 + */ 23 + 24 + #include <linux/kernel.h> 25 + #include <linux/module.h> 26 + #include <linux/cpu.h> 27 + #include <linux/cpuidle.h> 28 + #include <linux/hrtimer.h> 29 + 30 + #include <mach/iomap.h> 31 + 32 + extern void tegra_cpu_wfi(void); 33 + 34 + static int tegra_idle_enter_lp3(struct cpuidle_device *dev, 35 + struct cpuidle_driver *drv, int index); 36 + 37 + struct cpuidle_driver tegra_idle_driver = { 38 + .name = "tegra_idle", 39 + .owner = THIS_MODULE, 40 + .state_count = 1, 41 + .states = { 42 + [0] = { 43 + .enter = tegra_idle_enter_lp3, 44 + .exit_latency = 10, 45 + .target_residency = 10, 46 + .power_usage = 600, 47 + .flags = CPUIDLE_FLAG_TIME_VALID, 48 + .name = "LP3", 49 + .desc = "CPU flow-controlled", 50 + }, 51 + }, 52 + }; 53 + 54 + static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device); 55 + 56 + static int tegra_idle_enter_lp3(struct cpuidle_device *dev, 57 + struct cpuidle_driver *drv, int index) 58 + { 59 + ktime_t enter, exit; 60 + s64 us; 61 + 62 + local_irq_disable(); 63 + local_fiq_disable(); 64 + 65 + enter = ktime_get(); 66 + 67 + tegra_cpu_wfi(); 68 + 69 + exit = ktime_sub(ktime_get(), enter); 70 + us = ktime_to_us(exit); 71 + 72 + local_fiq_enable(); 73 + local_irq_enable(); 74 + 75 + dev->last_residency = us; 76 + 77 + return index; 78 + } 79 + 80 + static int __init tegra_cpuidle_init(void) 81 + { 82 + int ret; 83 + unsigned int cpu; 84 + struct cpuidle_device *dev; 85 + struct cpuidle_driver *drv = &tegra_idle_driver; 86 + 87 + ret = cpuidle_register_driver(&tegra_idle_driver); 88 + if (ret) { 89 + pr_err("CPUidle driver registration failed\n"); 90 + return ret; 91 + } 92 + 93 + for_each_possible_cpu(cpu) { 94 + dev = &per_cpu(tegra_idle_device, cpu); 95 + dev->cpu = cpu; 96 + 97 + dev->state_count = drv->state_count; 98 + ret = cpuidle_register_device(dev); 99 + if (ret) { 100 + pr_err("CPU%u: CPUidle device registration failed\n", 101 + cpu); 102 + return ret; 103 + } 104 + } 105 + return 0; 106 + } 107 + device_initcall(tegra_cpuidle_init);
+37
arch/arm/mach-tegra/flowctrl.h
··· 1 + /* 2 + * arch/arm/mach-tegra/flowctrl.h 3 + * 4 + * functions and macros to control the flowcontroller 5 + * 6 + * Copyright (c) 2010-2012, NVIDIA Corporation. All rights reserved. 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms and conditions of the GNU General Public License, 10 + * version 2, as published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope that it will be useful, but WITHOUT 13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 + * more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 + */ 20 + 21 + #ifndef __MACH_TEGRA_FLOWCTRL_H 22 + #define __MACH_TEGRA_FLOWCTRL_H 23 + 24 + #define FLOW_CTRL_HALT_CPU0_EVENTS 0x0 25 + #define FLOW_CTRL_WAITEVENT (2 << 29) 26 + #define FLOW_CTRL_WAIT_FOR_INTERRUPT (4 << 29) 27 + #define FLOW_CTRL_JTAG_RESUME (1 << 28) 28 + #define FLOW_CTRL_HALT_CPU_IRQ (1 << 10) 29 + #define FLOW_CTRL_HALT_CPU_FIQ (1 << 8) 30 + #define FLOW_CTRL_CPU0_CSR 0x8 31 + #define FLOW_CTRL_CSR_INTR_FLAG (1 << 15) 32 + #define FLOW_CTRL_CSR_EVENT_FLAG (1 << 14) 33 + #define FLOW_CTRL_CSR_ENABLE (1 << 0) 34 + #define FLOW_CTRL_HALT_CPU1_EVENTS 0x14 35 + #define FLOW_CTRL_CPU1_CSR 0x18 36 + 37 + #endif
+10
arch/arm/mach-tegra/include/mach/clk.h
··· 22 22 23 23 struct clk; 24 24 25 + enum tegra_clk_ex_param { 26 + TEGRA_CLK_VI_INP_SEL, 27 + TEGRA_CLK_DTV_INVERT, 28 + TEGRA_CLK_NAND_PAD_DIV2_ENB, 29 + TEGRA_CLK_PLLD_CSI_OUT_ENB, 30 + TEGRA_CLK_PLLD_DSI_OUT_ENB, 31 + TEGRA_CLK_PLLD_MIPI_MUX_SEL, 32 + }; 33 + 25 34 void tegra_periph_reset_deassert(struct clk *c); 26 35 void tegra_periph_reset_assert(struct clk *c); 27 36 28 37 unsigned long clk_get_rate_all_locked(struct clk *c); 29 38 void tegra2_sdmmc_tap_delay(struct clk *c, int delay); 39 + int tegra_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting); 30 40 31 41 #endif
+3
arch/arm/mach-tegra/include/mach/iomap.h
··· 74 74 #define TEGRA_QUATERNARY_ICTLR_BASE 0x60004300 75 75 #define TEGRA_QUATERNARY_ICTLR_SIZE SZ_64 76 76 77 + #define TEGRA_QUINARY_ICTLR_BASE 0x60004400 78 + #define TEGRA_QUINARY_ICTLR_SIZE SZ_64 79 + 77 80 #define TEGRA_TMR1_BASE 0x60005000 78 81 #define TEGRA_TMR1_SIZE SZ_8 79 82
+4 -3
arch/arm/mach-tegra/include/mach/irqs.h
··· 165 165 #define INT_QUAD_RES_30 (INT_QUAD_BASE + 30) 166 166 #define INT_QUAD_RES_31 (INT_QUAD_BASE + 31) 167 167 168 - #define INT_MAIN_NR (INT_QUAD_BASE + 32 - INT_PRI_BASE) 169 - 168 + /* Tegra30 has 5 banks of 32 IRQs */ 169 + #define INT_MAIN_NR (32 * 5) 170 170 #define INT_GPIO_BASE (INT_PRI_BASE + INT_MAIN_NR) 171 171 172 - #define INT_GPIO_NR (28 * 8) 172 + /* Tegra30 has 8 banks of 32 GPIOs */ 173 + #define INT_GPIO_NR (32 * 8) 173 174 174 175 #define TEGRA_NR_IRQS (INT_GPIO_BASE + INT_GPIO_NR) 175 176
+16 -4
arch/arm/mach-tegra/irq.c
··· 44 44 #define ICTLR_COP_IER_CLR 0x38 45 45 #define ICTLR_COP_IEP_CLASS 0x3c 46 46 47 - #define NUM_ICTLRS 4 48 47 #define FIRST_LEGACY_IRQ 32 48 + 49 + static int num_ictlrs; 49 50 50 51 static void __iomem *ictlr_reg_base[] = { 51 52 IO_ADDRESS(TEGRA_PRIMARY_ICTLR_BASE), 52 53 IO_ADDRESS(TEGRA_SECONDARY_ICTLR_BASE), 53 54 IO_ADDRESS(TEGRA_TERTIARY_ICTLR_BASE), 54 55 IO_ADDRESS(TEGRA_QUATERNARY_ICTLR_BASE), 56 + IO_ADDRESS(TEGRA_QUINARY_ICTLR_BASE), 55 57 }; 56 58 57 59 static inline void tegra_irq_write_mask(unsigned int irq, unsigned long reg) ··· 62 60 u32 mask; 63 61 64 62 BUG_ON(irq < FIRST_LEGACY_IRQ || 65 - irq >= FIRST_LEGACY_IRQ + NUM_ICTLRS * 32); 63 + irq >= FIRST_LEGACY_IRQ + num_ictlrs * 32); 66 64 67 65 base = ictlr_reg_base[(irq - FIRST_LEGACY_IRQ) / 32]; 68 66 mask = BIT((irq - FIRST_LEGACY_IRQ) % 32); ··· 115 113 void __init tegra_init_irq(void) 116 114 { 117 115 int i; 116 + void __iomem *distbase; 118 117 119 - for (i = 0; i < NUM_ICTLRS; i++) { 118 + distbase = IO_ADDRESS(TEGRA_ARM_INT_DIST_BASE); 119 + num_ictlrs = readl_relaxed(distbase + GIC_DIST_CTR) & 0x1f; 120 + 121 + if (num_ictlrs > ARRAY_SIZE(ictlr_reg_base)) { 122 + WARN(1, "Too many (%d) interrupt controllers found. Maximum is %d.", 123 + num_ictlrs, ARRAY_SIZE(ictlr_reg_base)); 124 + num_ictlrs = ARRAY_SIZE(ictlr_reg_base); 125 + } 126 + 127 + for (i = 0; i < num_ictlrs; i++) { 120 128 void __iomem *ictlr = ictlr_reg_base[i]; 121 129 writel(~0, ictlr + ICTLR_CPU_IER_CLR); 122 130 writel(0, ictlr + ICTLR_CPU_IEP_CLASS); ··· 143 131 * initialized elsewhere under DT. 144 132 */ 145 133 if (!of_have_populated_dt()) 146 - gic_init(0, 29, IO_ADDRESS(TEGRA_ARM_INT_DIST_BASE), 134 + gic_init(0, 29, distbase, 147 135 IO_ADDRESS(TEGRA_ARM_PERIF_BASE + 0x100)); 148 136 }
+91
arch/arm/mach-tegra/sleep.S
··· 1 + /* 2 + * arch/arm/mach-tegra/sleep.S 3 + * 4 + * Copyright (c) 2010-2011, NVIDIA Corporation. 5 + * Copyright (c) 2011, Google, Inc. 6 + * 7 + * Author: Colin Cross <ccross@android.com> 8 + * Gary King <gking@nvidia.com> 9 + * 10 + * This program is free software; you can redistribute it and/or modify 11 + * it under the terms of the GNU General Public License as published by 12 + * the Free Software Foundation; either version 2 of the License, or 13 + * (at your option) any later version. 14 + * 15 + * This program is distributed in the hope that it will be useful, but WITHOUT 16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 18 + * more details. 19 + * 20 + * You should have received a copy of the GNU General Public License along 21 + * with this program; if not, write to the Free Software Foundation, Inc., 22 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 23 + */ 24 + 25 + #include <linux/linkage.h> 26 + #include <mach/io.h> 27 + #include <mach/iomap.h> 28 + 29 + #include "flowctrl.h" 30 + 31 + #define TEGRA_FLOW_CTRL_VIRT (TEGRA_FLOW_CTRL_BASE - IO_PPSB_PHYS \ 32 + + IO_PPSB_VIRT) 33 + 34 + /* returns the offset of the flow controller halt register for a cpu */ 35 + .macro cpu_to_halt_reg rd, rcpu 36 + cmp \rcpu, #0 37 + subne \rd, \rcpu, #1 38 + movne \rd, \rd, lsl #3 39 + addne \rd, \rd, #0x14 40 + moveq \rd, #0 41 + .endm 42 + 43 + /* returns the offset of the flow controller csr register for a cpu */ 44 + .macro cpu_to_csr_reg rd, rcpu 45 + cmp \rcpu, #0 46 + subne \rd, \rcpu, #1 47 + movne \rd, \rd, lsl #3 48 + addne \rd, \rd, #0x18 49 + moveq \rd, #8 50 + .endm 51 + 52 + /* returns the ID of the current processor */ 53 + .macro cpu_id, rd 54 + mrc p15, 0, \rd, c0, c0, 5 55 + and \rd, \rd, #0xF 56 + .endm 57 + 58 + /* loads a 32-bit value into a register without a data access */ 59 + .macro mov32, reg, val 60 + movw \reg, #:lower16:\val 61 + movt \reg, #:upper16:\val 62 + .endm 63 + 64 + /* 65 + * tegra_cpu_wfi 66 + * 67 + * puts current CPU in clock-gated wfi using the flow controller 68 + * 69 + * corrupts r0-r3 70 + * must be called with MMU on 71 + */ 72 + 73 + ENTRY(tegra_cpu_wfi) 74 + cpu_id r0 75 + cpu_to_halt_reg r1, r0 76 + cpu_to_csr_reg r2, r0 77 + mov32 r0, TEGRA_FLOW_CTRL_VIRT 78 + mov r3, #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG 79 + str r3, [r0, r2] @ clear event & interrupt status 80 + mov r3, #FLOW_CTRL_WAIT_FOR_INTERRUPT | FLOW_CTRL_JTAG_RESUME 81 + str r3, [r0, r1] @ put flow controller in wait irq mode 82 + dsb 83 + wfi 84 + mov r3, #0 85 + str r3, [r0, r1] @ clear flow controller halt status 86 + mov r3, #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG 87 + str r3, [r0, r2] @ clear event & interrupt status 88 + dsb 89 + mov pc, lr 90 + ENDPROC(tegra_cpu_wfi) 91 +
+25 -5
arch/arm/mach-tegra/tegra2_clocks.c
··· 1143 1143 1144 1144 static long tegra2_emc_clk_round_rate(struct clk *c, unsigned long rate) 1145 1145 { 1146 - long new_rate = rate; 1146 + long emc_rate; 1147 + long clk_rate; 1147 1148 1148 - new_rate = tegra_emc_round_rate(new_rate); 1149 - if (new_rate < 0) 1149 + /* 1150 + * The slowest entry in the EMC clock table that is at least as 1151 + * fast as rate. 1152 + */ 1153 + emc_rate = tegra_emc_round_rate(rate); 1154 + if (emc_rate < 0) 1150 1155 return c->max_rate; 1151 1156 1152 - BUG_ON(new_rate != tegra2_periph_clk_round_rate(c, new_rate)); 1157 + /* 1158 + * The fastest rate the PLL will generate that is at most the 1159 + * requested rate. 1160 + */ 1161 + clk_rate = tegra2_periph_clk_round_rate(c, emc_rate); 1153 1162 1154 - return new_rate; 1163 + /* 1164 + * If this fails, and emc_rate > clk_rate, it's because the maximum 1165 + * rate in the EMC tables is larger than the maximum rate of the EMC 1166 + * clock. The EMC clock's max rate is the rate it was running when the 1167 + * kernel booted. Such a mismatch is probably due to using the wrong 1168 + * BCT, i.e. using a Tegra20 BCT with an EMC table written for Tegra25. 1169 + */ 1170 + WARN_ONCE(emc_rate != clk_rate, 1171 + "emc_rate %ld != clk_rate %ld", 1172 + emc_rate, clk_rate); 1173 + 1174 + return emc_rate; 1155 1175 } 1156 1176 1157 1177 static int tegra2_emc_clk_set_rate(struct clk *c, unsigned long rate)
+3099
arch/arm/mach-tegra/tegra30_clocks.c
··· 1 + /* 2 + * arch/arm/mach-tegra/tegra30_clocks.c 3 + * 4 + * Copyright (c) 2010-2011 NVIDIA CORPORATION. All rights reserved. 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License as published by 8 + * the Free Software Foundation; version 2 of the License. 9 + * 10 + * This program is distributed in the hope that it will be useful, but WITHOUT 11 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 + * more details. 14 + * 15 + * You should have received a copy of the GNU General Public License along 16 + * with this program; if not, write to the Free Software Foundation, Inc., 17 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 + * 19 + */ 20 + 21 + #include <linux/kernel.h> 22 + #include <linux/module.h> 23 + #include <linux/list.h> 24 + #include <linux/spinlock.h> 25 + #include <linux/delay.h> 26 + #include <linux/err.h> 27 + #include <linux/io.h> 28 + #include <linux/clk.h> 29 + #include <linux/cpufreq.h> 30 + #include <linux/syscore_ops.h> 31 + 32 + #include <asm/clkdev.h> 33 + 34 + #include <mach/iomap.h> 35 + 36 + #include "clock.h" 37 + #include "fuse.h" 38 + 39 + #define USE_PLL_LOCK_BITS 0 40 + 41 + #define RST_DEVICES_L 0x004 42 + #define RST_DEVICES_H 0x008 43 + #define RST_DEVICES_U 0x00C 44 + #define RST_DEVICES_V 0x358 45 + #define RST_DEVICES_W 0x35C 46 + #define RST_DEVICES_SET_L 0x300 47 + #define RST_DEVICES_CLR_L 0x304 48 + #define RST_DEVICES_SET_V 0x430 49 + #define RST_DEVICES_CLR_V 0x434 50 + #define RST_DEVICES_NUM 5 51 + 52 + #define CLK_OUT_ENB_L 0x010 53 + #define CLK_OUT_ENB_H 0x014 54 + #define CLK_OUT_ENB_U 0x018 55 + #define CLK_OUT_ENB_V 0x360 56 + #define CLK_OUT_ENB_W 0x364 57 + #define CLK_OUT_ENB_SET_L 0x320 58 + #define CLK_OUT_ENB_CLR_L 0x324 59 + #define CLK_OUT_ENB_SET_V 0x440 60 + #define CLK_OUT_ENB_CLR_V 0x444 61 + #define CLK_OUT_ENB_NUM 5 62 + 63 + #define RST_DEVICES_V_SWR_CPULP_RST_DIS (0x1 << 1) 64 + #define CLK_OUT_ENB_V_CLK_ENB_CPULP_EN (0x1 << 1) 65 + 66 + #define PERIPH_CLK_TO_BIT(c) (1 << (c->u.periph.clk_num % 32)) 67 + #define PERIPH_CLK_TO_RST_REG(c) \ 68 + periph_clk_to_reg((c), RST_DEVICES_L, RST_DEVICES_V, 4) 69 + #define PERIPH_CLK_TO_RST_SET_REG(c) \ 70 + periph_clk_to_reg((c), RST_DEVICES_SET_L, RST_DEVICES_SET_V, 8) 71 + #define PERIPH_CLK_TO_RST_CLR_REG(c) \ 72 + periph_clk_to_reg((c), RST_DEVICES_CLR_L, RST_DEVICES_CLR_V, 8) 73 + 74 + #define PERIPH_CLK_TO_ENB_REG(c) \ 75 + periph_clk_to_reg((c), CLK_OUT_ENB_L, CLK_OUT_ENB_V, 4) 76 + #define PERIPH_CLK_TO_ENB_SET_REG(c) \ 77 + periph_clk_to_reg((c), CLK_OUT_ENB_SET_L, CLK_OUT_ENB_SET_V, 8) 78 + #define PERIPH_CLK_TO_ENB_CLR_REG(c) \ 79 + periph_clk_to_reg((c), CLK_OUT_ENB_CLR_L, CLK_OUT_ENB_CLR_V, 8) 80 + 81 + #define CLK_MASK_ARM 0x44 82 + #define MISC_CLK_ENB 0x48 83 + 84 + #define OSC_CTRL 0x50 85 + #define OSC_CTRL_OSC_FREQ_MASK (0xF<<28) 86 + #define OSC_CTRL_OSC_FREQ_13MHZ (0x0<<28) 87 + #define OSC_CTRL_OSC_FREQ_19_2MHZ (0x4<<28) 88 + #define OSC_CTRL_OSC_FREQ_12MHZ (0x8<<28) 89 + #define OSC_CTRL_OSC_FREQ_26MHZ (0xC<<28) 90 + #define OSC_CTRL_OSC_FREQ_16_8MHZ (0x1<<28) 91 + #define OSC_CTRL_OSC_FREQ_38_4MHZ (0x5<<28) 92 + #define OSC_CTRL_OSC_FREQ_48MHZ (0x9<<28) 93 + #define OSC_CTRL_MASK (0x3f2 | OSC_CTRL_OSC_FREQ_MASK) 94 + 95 + #define OSC_CTRL_PLL_REF_DIV_MASK (3<<26) 96 + #define OSC_CTRL_PLL_REF_DIV_1 (0<<26) 97 + #define OSC_CTRL_PLL_REF_DIV_2 (1<<26) 98 + #define OSC_CTRL_PLL_REF_DIV_4 (2<<26) 99 + 100 + #define OSC_FREQ_DET 0x58 101 + #define OSC_FREQ_DET_TRIG (1<<31) 102 + 103 + #define OSC_FREQ_DET_STATUS 0x5C 104 + #define OSC_FREQ_DET_BUSY (1<<31) 105 + #define OSC_FREQ_DET_CNT_MASK 0xFFFF 106 + 107 + #define PERIPH_CLK_SOURCE_I2S1 0x100 108 + #define PERIPH_CLK_SOURCE_EMC 0x19c 109 + #define PERIPH_CLK_SOURCE_OSC 0x1fc 110 + #define PERIPH_CLK_SOURCE_NUM1 \ 111 + ((PERIPH_CLK_SOURCE_OSC - PERIPH_CLK_SOURCE_I2S1) / 4) 112 + 113 + #define PERIPH_CLK_SOURCE_G3D2 0x3b0 114 + #define PERIPH_CLK_SOURCE_SE 0x42c 115 + #define PERIPH_CLK_SOURCE_NUM2 \ 116 + ((PERIPH_CLK_SOURCE_SE - PERIPH_CLK_SOURCE_G3D2) / 4 + 1) 117 + 118 + #define AUDIO_DLY_CLK 0x49c 119 + #define AUDIO_SYNC_CLK_SPDIF 0x4b4 120 + #define PERIPH_CLK_SOURCE_NUM3 \ 121 + ((AUDIO_SYNC_CLK_SPDIF - AUDIO_DLY_CLK) / 4 + 1) 122 + 123 + #define PERIPH_CLK_SOURCE_NUM (PERIPH_CLK_SOURCE_NUM1 + \ 124 + PERIPH_CLK_SOURCE_NUM2 + \ 125 + PERIPH_CLK_SOURCE_NUM3) 126 + 127 + #define CPU_SOFTRST_CTRL 0x380 128 + 129 + #define PERIPH_CLK_SOURCE_DIVU71_MASK 0xFF 130 + #define PERIPH_CLK_SOURCE_DIVU16_MASK 0xFFFF 131 + #define PERIPH_CLK_SOURCE_DIV_SHIFT 0 132 + #define PERIPH_CLK_SOURCE_DIVIDLE_SHIFT 8 133 + #define PERIPH_CLK_SOURCE_DIVIDLE_VAL 50 134 + #define PERIPH_CLK_UART_DIV_ENB (1<<24) 135 + #define PERIPH_CLK_VI_SEL_EX_SHIFT 24 136 + #define PERIPH_CLK_VI_SEL_EX_MASK (0x3<<PERIPH_CLK_VI_SEL_EX_SHIFT) 137 + #define PERIPH_CLK_NAND_DIV_EX_ENB (1<<8) 138 + #define PERIPH_CLK_DTV_POLARITY_INV (1<<25) 139 + 140 + #define AUDIO_SYNC_SOURCE_MASK 0x0F 141 + #define AUDIO_SYNC_DISABLE_BIT 0x10 142 + #define AUDIO_SYNC_TAP_NIBBLE_SHIFT(c) ((c->reg_shift - 24) * 4) 143 + 144 + #define PLL_BASE 0x0 145 + #define PLL_BASE_BYPASS (1<<31) 146 + #define PLL_BASE_ENABLE (1<<30) 147 + #define PLL_BASE_REF_ENABLE (1<<29) 148 + #define PLL_BASE_OVERRIDE (1<<28) 149 + #define PLL_BASE_LOCK (1<<27) 150 + #define PLL_BASE_DIVP_MASK (0x7<<20) 151 + #define PLL_BASE_DIVP_SHIFT 20 152 + #define PLL_BASE_DIVN_MASK (0x3FF<<8) 153 + #define PLL_BASE_DIVN_SHIFT 8 154 + #define PLL_BASE_DIVM_MASK (0x1F) 155 + #define PLL_BASE_DIVM_SHIFT 0 156 + 157 + #define PLL_OUT_RATIO_MASK (0xFF<<8) 158 + #define PLL_OUT_RATIO_SHIFT 8 159 + #define PLL_OUT_OVERRIDE (1<<2) 160 + #define PLL_OUT_CLKEN (1<<1) 161 + #define PLL_OUT_RESET_DISABLE (1<<0) 162 + 163 + #define PLL_MISC(c) \ 164 + (((c)->flags & PLL_ALT_MISC_REG) ? 0x4 : 0xc) 165 + #define PLL_MISC_LOCK_ENABLE(c) \ 166 + (((c)->flags & (PLLU | PLLD)) ? (1<<22) : (1<<18)) 167 + 168 + #define PLL_MISC_DCCON_SHIFT 20 169 + #define PLL_MISC_CPCON_SHIFT 8 170 + #define PLL_MISC_CPCON_MASK (0xF<<PLL_MISC_CPCON_SHIFT) 171 + #define PLL_MISC_LFCON_SHIFT 4 172 + #define PLL_MISC_LFCON_MASK (0xF<<PLL_MISC_LFCON_SHIFT) 173 + #define PLL_MISC_VCOCON_SHIFT 0 174 + #define PLL_MISC_VCOCON_MASK (0xF<<PLL_MISC_VCOCON_SHIFT) 175 + #define PLLD_MISC_CLKENABLE (1<<30) 176 + 177 + #define PLLU_BASE_POST_DIV (1<<20) 178 + 179 + #define PLLD_BASE_DSIB_MUX_SHIFT 25 180 + #define PLLD_BASE_DSIB_MUX_MASK (1<<PLLD_BASE_DSIB_MUX_SHIFT) 181 + #define PLLD_BASE_CSI_CLKENABLE (1<<26) 182 + #define PLLD_MISC_DSI_CLKENABLE (1<<30) 183 + #define PLLD_MISC_DIV_RST (1<<23) 184 + #define PLLD_MISC_DCCON_SHIFT 12 185 + 186 + #define PLLDU_LFCON_SET_DIVN 600 187 + 188 + /* FIXME: OUT_OF_TABLE_CPCON per pll */ 189 + #define OUT_OF_TABLE_CPCON 0x8 190 + 191 + #define SUPER_CLK_MUX 0x00 192 + #define SUPER_STATE_SHIFT 28 193 + #define SUPER_STATE_MASK (0xF << SUPER_STATE_SHIFT) 194 + #define SUPER_STATE_STANDBY (0x0 << SUPER_STATE_SHIFT) 195 + #define SUPER_STATE_IDLE (0x1 << SUPER_STATE_SHIFT) 196 + #define SUPER_STATE_RUN (0x2 << SUPER_STATE_SHIFT) 197 + #define SUPER_STATE_IRQ (0x3 << SUPER_STATE_SHIFT) 198 + #define SUPER_STATE_FIQ (0x4 << SUPER_STATE_SHIFT) 199 + #define SUPER_LP_DIV2_BYPASS (0x1 << 16) 200 + #define SUPER_SOURCE_MASK 0xF 201 + #define SUPER_FIQ_SOURCE_SHIFT 12 202 + #define SUPER_IRQ_SOURCE_SHIFT 8 203 + #define SUPER_RUN_SOURCE_SHIFT 4 204 + #define SUPER_IDLE_SOURCE_SHIFT 0 205 + 206 + #define SUPER_CLK_DIVIDER 0x04 207 + #define SUPER_CLOCK_DIV_U71_SHIFT 16 208 + #define SUPER_CLOCK_DIV_U71_MASK (0xff << SUPER_CLOCK_DIV_U71_SHIFT) 209 + /* guarantees safe cpu backup */ 210 + #define SUPER_CLOCK_DIV_U71_MIN 0x2 211 + 212 + #define BUS_CLK_DISABLE (1<<3) 213 + #define BUS_CLK_DIV_MASK 0x3 214 + 215 + #define PMC_CTRL 0x0 216 + #define PMC_CTRL_BLINK_ENB (1 << 7) 217 + 218 + #define PMC_DPD_PADS_ORIDE 0x1c 219 + #define PMC_DPD_PADS_ORIDE_BLINK_ENB (1 << 20) 220 + 221 + #define PMC_BLINK_TIMER_DATA_ON_SHIFT 0 222 + #define PMC_BLINK_TIMER_DATA_ON_MASK 0x7fff 223 + #define PMC_BLINK_TIMER_ENB (1 << 15) 224 + #define PMC_BLINK_TIMER_DATA_OFF_SHIFT 16 225 + #define PMC_BLINK_TIMER_DATA_OFF_MASK 0xffff 226 + 227 + #define PMC_PLLP_WB0_OVERRIDE 0xf8 228 + #define PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE (1 << 12) 229 + 230 + #define UTMIP_PLL_CFG2 0x488 231 + #define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xfff) << 6) 232 + #define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18) 233 + #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN (1 << 0) 234 + #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN (1 << 2) 235 + #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN (1 << 4) 236 + 237 + #define UTMIP_PLL_CFG1 0x484 238 + #define UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 27) 239 + #define UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0) 240 + #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN (1 << 14) 241 + #define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN (1 << 12) 242 + #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN (1 << 16) 243 + 244 + #define PLLE_BASE_CML_ENABLE (1<<31) 245 + #define PLLE_BASE_ENABLE (1<<30) 246 + #define PLLE_BASE_DIVCML_SHIFT 24 247 + #define PLLE_BASE_DIVCML_MASK (0xf<<PLLE_BASE_DIVCML_SHIFT) 248 + #define PLLE_BASE_DIVP_SHIFT 16 249 + #define PLLE_BASE_DIVP_MASK (0x3f<<PLLE_BASE_DIVP_SHIFT) 250 + #define PLLE_BASE_DIVN_SHIFT 8 251 + #define PLLE_BASE_DIVN_MASK (0xFF<<PLLE_BASE_DIVN_SHIFT) 252 + #define PLLE_BASE_DIVM_SHIFT 0 253 + #define PLLE_BASE_DIVM_MASK (0xFF<<PLLE_BASE_DIVM_SHIFT) 254 + #define PLLE_BASE_DIV_MASK \ 255 + (PLLE_BASE_DIVCML_MASK | PLLE_BASE_DIVP_MASK | \ 256 + PLLE_BASE_DIVN_MASK | PLLE_BASE_DIVM_MASK) 257 + #define PLLE_BASE_DIV(m, n, p, cml) \ 258 + (((cml)<<PLLE_BASE_DIVCML_SHIFT) | ((p)<<PLLE_BASE_DIVP_SHIFT) | \ 259 + ((n)<<PLLE_BASE_DIVN_SHIFT) | ((m)<<PLLE_BASE_DIVM_SHIFT)) 260 + 261 + #define PLLE_MISC_SETUP_BASE_SHIFT 16 262 + #define PLLE_MISC_SETUP_BASE_MASK (0xFFFF<<PLLE_MISC_SETUP_BASE_SHIFT) 263 + #define PLLE_MISC_READY (1<<15) 264 + #define PLLE_MISC_LOCK (1<<11) 265 + #define PLLE_MISC_LOCK_ENABLE (1<<9) 266 + #define PLLE_MISC_SETUP_EX_SHIFT 2 267 + #define PLLE_MISC_SETUP_EX_MASK (0x3<<PLLE_MISC_SETUP_EX_SHIFT) 268 + #define PLLE_MISC_SETUP_MASK \ 269 + (PLLE_MISC_SETUP_BASE_MASK | PLLE_MISC_SETUP_EX_MASK) 270 + #define PLLE_MISC_SETUP_VALUE \ 271 + ((0x7<<PLLE_MISC_SETUP_BASE_SHIFT) | (0x0<<PLLE_MISC_SETUP_EX_SHIFT)) 272 + 273 + #define PLLE_SS_CTRL 0x68 274 + #define PLLE_SS_INCINTRV_SHIFT 24 275 + #define PLLE_SS_INCINTRV_MASK (0x3f<<PLLE_SS_INCINTRV_SHIFT) 276 + #define PLLE_SS_INC_SHIFT 16 277 + #define PLLE_SS_INC_MASK (0xff<<PLLE_SS_INC_SHIFT) 278 + #define PLLE_SS_MAX_SHIFT 0 279 + #define PLLE_SS_MAX_MASK (0x1ff<<PLLE_SS_MAX_SHIFT) 280 + #define PLLE_SS_COEFFICIENTS_MASK \ 281 + (PLLE_SS_INCINTRV_MASK | PLLE_SS_INC_MASK | PLLE_SS_MAX_MASK) 282 + #define PLLE_SS_COEFFICIENTS_12MHZ \ 283 + ((0x18<<PLLE_SS_INCINTRV_SHIFT) | (0x1<<PLLE_SS_INC_SHIFT) | \ 284 + (0x24<<PLLE_SS_MAX_SHIFT)) 285 + #define PLLE_SS_DISABLE ((1<<12) | (1<<11) | (1<<10)) 286 + 287 + #define PLLE_AUX 0x48c 288 + #define PLLE_AUX_PLLP_SEL (1<<2) 289 + #define PLLE_AUX_CML_SATA_ENABLE (1<<1) 290 + #define PLLE_AUX_CML_PCIE_ENABLE (1<<0) 291 + 292 + #define PMC_SATA_PWRGT 0x1ac 293 + #define PMC_SATA_PWRGT_PLLE_IDDQ_VALUE (1<<5) 294 + #define PMC_SATA_PWRGT_PLLE_IDDQ_SWCTL (1<<4) 295 + 296 + #define ROUND_DIVIDER_UP 0 297 + #define ROUND_DIVIDER_DOWN 1 298 + 299 + /* FIXME: recommended safety delay after lock is detected */ 300 + #define PLL_POST_LOCK_DELAY 100 301 + 302 + /** 303 + * Structure defining the fields for USB UTMI clocks Parameters. 304 + */ 305 + struct utmi_clk_param { 306 + /* Oscillator Frequency in KHz */ 307 + u32 osc_frequency; 308 + /* UTMIP PLL Enable Delay Count */ 309 + u8 enable_delay_count; 310 + /* UTMIP PLL Stable count */ 311 + u8 stable_count; 312 + /* UTMIP PLL Active delay count */ 313 + u8 active_delay_count; 314 + /* UTMIP PLL Xtal frequency count */ 315 + u8 xtal_freq_count; 316 + }; 317 + 318 + static const struct utmi_clk_param utmi_parameters[] = { 319 + { 320 + .osc_frequency = 13000000, 321 + .enable_delay_count = 0x02, 322 + .stable_count = 0x33, 323 + .active_delay_count = 0x05, 324 + .xtal_freq_count = 0x7F 325 + }, 326 + { 327 + .osc_frequency = 19200000, 328 + .enable_delay_count = 0x03, 329 + .stable_count = 0x4B, 330 + .active_delay_count = 0x06, 331 + .xtal_freq_count = 0xBB}, 332 + { 333 + .osc_frequency = 12000000, 334 + .enable_delay_count = 0x02, 335 + .stable_count = 0x2F, 336 + .active_delay_count = 0x04, 337 + .xtal_freq_count = 0x76 338 + }, 339 + { 340 + .osc_frequency = 26000000, 341 + .enable_delay_count = 0x04, 342 + .stable_count = 0x66, 343 + .active_delay_count = 0x09, 344 + .xtal_freq_count = 0xFE 345 + }, 346 + { 347 + .osc_frequency = 16800000, 348 + .enable_delay_count = 0x03, 349 + .stable_count = 0x41, 350 + .active_delay_count = 0x0A, 351 + .xtal_freq_count = 0xA4 352 + }, 353 + }; 354 + 355 + static void __iomem *reg_clk_base = IO_ADDRESS(TEGRA_CLK_RESET_BASE); 356 + static void __iomem *reg_pmc_base = IO_ADDRESS(TEGRA_PMC_BASE); 357 + static void __iomem *misc_gp_hidrev_base = IO_ADDRESS(TEGRA_APB_MISC_BASE); 358 + 359 + #define MISC_GP_HIDREV 0x804 360 + 361 + /* 362 + * Some peripheral clocks share an enable bit, so refcount the enable bits 363 + * in registers CLK_ENABLE_L, ... CLK_ENABLE_W 364 + */ 365 + static int tegra_periph_clk_enable_refcount[CLK_OUT_ENB_NUM * 32]; 366 + 367 + #define clk_writel(value, reg) \ 368 + __raw_writel(value, (u32)reg_clk_base + (reg)) 369 + #define clk_readl(reg) \ 370 + __raw_readl((u32)reg_clk_base + (reg)) 371 + #define pmc_writel(value, reg) \ 372 + __raw_writel(value, (u32)reg_pmc_base + (reg)) 373 + #define pmc_readl(reg) \ 374 + __raw_readl((u32)reg_pmc_base + (reg)) 375 + #define chipid_readl() \ 376 + __raw_readl((u32)misc_gp_hidrev_base + MISC_GP_HIDREV) 377 + 378 + #define clk_writel_delay(value, reg) \ 379 + do { \ 380 + __raw_writel((value), (u32)reg_clk_base + (reg)); \ 381 + udelay(2); \ 382 + } while (0) 383 + 384 + 385 + static inline int clk_set_div(struct clk *c, u32 n) 386 + { 387 + return clk_set_rate(c, (clk_get_rate(c->parent) + n-1) / n); 388 + } 389 + 390 + static inline u32 periph_clk_to_reg( 391 + struct clk *c, u32 reg_L, u32 reg_V, int offs) 392 + { 393 + u32 reg = c->u.periph.clk_num / 32; 394 + BUG_ON(reg >= RST_DEVICES_NUM); 395 + if (reg < 3) 396 + reg = reg_L + (reg * offs); 397 + else 398 + reg = reg_V + ((reg - 3) * offs); 399 + return reg; 400 + } 401 + 402 + static unsigned long clk_measure_input_freq(void) 403 + { 404 + u32 clock_autodetect; 405 + clk_writel(OSC_FREQ_DET_TRIG | 1, OSC_FREQ_DET); 406 + do {} while (clk_readl(OSC_FREQ_DET_STATUS) & OSC_FREQ_DET_BUSY); 407 + clock_autodetect = clk_readl(OSC_FREQ_DET_STATUS); 408 + if (clock_autodetect >= 732 - 3 && clock_autodetect <= 732 + 3) { 409 + return 12000000; 410 + } else if (clock_autodetect >= 794 - 3 && clock_autodetect <= 794 + 3) { 411 + return 13000000; 412 + } else if (clock_autodetect >= 1172 - 3 && clock_autodetect <= 1172 + 3) { 413 + return 19200000; 414 + } else if (clock_autodetect >= 1587 - 3 && clock_autodetect <= 1587 + 3) { 415 + return 26000000; 416 + } else if (clock_autodetect >= 1025 - 3 && clock_autodetect <= 1025 + 3) { 417 + return 16800000; 418 + } else if (clock_autodetect >= 2344 - 3 && clock_autodetect <= 2344 + 3) { 419 + return 38400000; 420 + } else if (clock_autodetect >= 2928 - 3 && clock_autodetect <= 2928 + 3) { 421 + return 48000000; 422 + } else { 423 + pr_err("%s: Unexpected clock autodetect value %d", __func__, 424 + clock_autodetect); 425 + BUG(); 426 + return 0; 427 + } 428 + } 429 + 430 + static int clk_div71_get_divider(unsigned long parent_rate, unsigned long rate, 431 + u32 flags, u32 round_mode) 432 + { 433 + s64 divider_u71 = parent_rate; 434 + if (!rate) 435 + return -EINVAL; 436 + 437 + if (!(flags & DIV_U71_INT)) 438 + divider_u71 *= 2; 439 + if (round_mode == ROUND_DIVIDER_UP) 440 + divider_u71 += rate - 1; 441 + do_div(divider_u71, rate); 442 + if (flags & DIV_U71_INT) 443 + divider_u71 *= 2; 444 + 445 + if (divider_u71 - 2 < 0) 446 + return 0; 447 + 448 + if (divider_u71 - 2 > 255) 449 + return -EINVAL; 450 + 451 + return divider_u71 - 2; 452 + } 453 + 454 + static int clk_div16_get_divider(unsigned long parent_rate, unsigned long rate) 455 + { 456 + s64 divider_u16; 457 + 458 + divider_u16 = parent_rate; 459 + if (!rate) 460 + return -EINVAL; 461 + divider_u16 += rate - 1; 462 + do_div(divider_u16, rate); 463 + 464 + if (divider_u16 - 1 < 0) 465 + return 0; 466 + 467 + if (divider_u16 - 1 > 0xFFFF) 468 + return -EINVAL; 469 + 470 + return divider_u16 - 1; 471 + } 472 + 473 + /* clk_m functions */ 474 + static unsigned long tegra30_clk_m_autodetect_rate(struct clk *c) 475 + { 476 + u32 osc_ctrl = clk_readl(OSC_CTRL); 477 + u32 auto_clock_control = osc_ctrl & ~OSC_CTRL_OSC_FREQ_MASK; 478 + u32 pll_ref_div = osc_ctrl & OSC_CTRL_PLL_REF_DIV_MASK; 479 + 480 + c->rate = clk_measure_input_freq(); 481 + switch (c->rate) { 482 + case 12000000: 483 + auto_clock_control |= OSC_CTRL_OSC_FREQ_12MHZ; 484 + BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1); 485 + break; 486 + case 13000000: 487 + auto_clock_control |= OSC_CTRL_OSC_FREQ_13MHZ; 488 + BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1); 489 + break; 490 + case 19200000: 491 + auto_clock_control |= OSC_CTRL_OSC_FREQ_19_2MHZ; 492 + BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1); 493 + break; 494 + case 26000000: 495 + auto_clock_control |= OSC_CTRL_OSC_FREQ_26MHZ; 496 + BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1); 497 + break; 498 + case 16800000: 499 + auto_clock_control |= OSC_CTRL_OSC_FREQ_16_8MHZ; 500 + BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1); 501 + break; 502 + case 38400000: 503 + auto_clock_control |= OSC_CTRL_OSC_FREQ_38_4MHZ; 504 + BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_2); 505 + break; 506 + case 48000000: 507 + auto_clock_control |= OSC_CTRL_OSC_FREQ_48MHZ; 508 + BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_4); 509 + break; 510 + default: 511 + pr_err("%s: Unexpected clock rate %ld", __func__, c->rate); 512 + BUG(); 513 + } 514 + clk_writel(auto_clock_control, OSC_CTRL); 515 + return c->rate; 516 + } 517 + 518 + static void tegra30_clk_m_init(struct clk *c) 519 + { 520 + pr_debug("%s on clock %s\n", __func__, c->name); 521 + tegra30_clk_m_autodetect_rate(c); 522 + } 523 + 524 + static int tegra30_clk_m_enable(struct clk *c) 525 + { 526 + pr_debug("%s on clock %s\n", __func__, c->name); 527 + return 0; 528 + } 529 + 530 + static void tegra30_clk_m_disable(struct clk *c) 531 + { 532 + pr_debug("%s on clock %s\n", __func__, c->name); 533 + WARN(1, "Attempting to disable main SoC clock\n"); 534 + } 535 + 536 + static struct clk_ops tegra_clk_m_ops = { 537 + .init = tegra30_clk_m_init, 538 + .enable = tegra30_clk_m_enable, 539 + .disable = tegra30_clk_m_disable, 540 + }; 541 + 542 + static struct clk_ops tegra_clk_m_div_ops = { 543 + .enable = tegra30_clk_m_enable, 544 + }; 545 + 546 + /* PLL reference divider functions */ 547 + static void tegra30_pll_ref_init(struct clk *c) 548 + { 549 + u32 pll_ref_div = clk_readl(OSC_CTRL) & OSC_CTRL_PLL_REF_DIV_MASK; 550 + pr_debug("%s on clock %s\n", __func__, c->name); 551 + 552 + switch (pll_ref_div) { 553 + case OSC_CTRL_PLL_REF_DIV_1: 554 + c->div = 1; 555 + break; 556 + case OSC_CTRL_PLL_REF_DIV_2: 557 + c->div = 2; 558 + break; 559 + case OSC_CTRL_PLL_REF_DIV_4: 560 + c->div = 4; 561 + break; 562 + default: 563 + pr_err("%s: Invalid pll ref divider %d", __func__, pll_ref_div); 564 + BUG(); 565 + } 566 + c->mul = 1; 567 + c->state = ON; 568 + } 569 + 570 + static struct clk_ops tegra_pll_ref_ops = { 571 + .init = tegra30_pll_ref_init, 572 + .enable = tegra30_clk_m_enable, 573 + .disable = tegra30_clk_m_disable, 574 + }; 575 + 576 + /* super clock functions */ 577 + /* "super clocks" on tegra30 have two-stage muxes, fractional 7.1 divider and 578 + * clock skipping super divider. We will ignore the clock skipping divider, 579 + * since we can't lower the voltage when using the clock skip, but we can if 580 + * we lower the PLL frequency. We will use 7.1 divider for CPU super-clock 581 + * only when its parent is a fixed rate PLL, since we can't change PLL rate 582 + * in this case. 583 + */ 584 + static void tegra30_super_clk_init(struct clk *c) 585 + { 586 + u32 val; 587 + int source; 588 + int shift; 589 + const struct clk_mux_sel *sel; 590 + val = clk_readl(c->reg + SUPER_CLK_MUX); 591 + c->state = ON; 592 + BUG_ON(((val & SUPER_STATE_MASK) != SUPER_STATE_RUN) && 593 + ((val & SUPER_STATE_MASK) != SUPER_STATE_IDLE)); 594 + shift = ((val & SUPER_STATE_MASK) == SUPER_STATE_IDLE) ? 595 + SUPER_IDLE_SOURCE_SHIFT : SUPER_RUN_SOURCE_SHIFT; 596 + source = (val >> shift) & SUPER_SOURCE_MASK; 597 + if (c->flags & DIV_2) 598 + source |= val & SUPER_LP_DIV2_BYPASS; 599 + for (sel = c->inputs; sel->input != NULL; sel++) { 600 + if (sel->value == source) 601 + break; 602 + } 603 + BUG_ON(sel->input == NULL); 604 + c->parent = sel->input; 605 + 606 + if (c->flags & DIV_U71) { 607 + /* Init safe 7.1 divider value (does not affect PLLX path) */ 608 + clk_writel(SUPER_CLOCK_DIV_U71_MIN << SUPER_CLOCK_DIV_U71_SHIFT, 609 + c->reg + SUPER_CLK_DIVIDER); 610 + c->mul = 2; 611 + c->div = 2; 612 + if (!(c->parent->flags & PLLX)) 613 + c->div += SUPER_CLOCK_DIV_U71_MIN; 614 + } else 615 + clk_writel(0, c->reg + SUPER_CLK_DIVIDER); 616 + } 617 + 618 + static int tegra30_super_clk_enable(struct clk *c) 619 + { 620 + return 0; 621 + } 622 + 623 + static void tegra30_super_clk_disable(struct clk *c) 624 + { 625 + /* since tegra 3 has 2 CPU super clocks - low power lp-mode clock and 626 + geared up g-mode super clock - mode switch may request to disable 627 + either of them; accept request with no affect on h/w */ 628 + } 629 + 630 + static int tegra30_super_clk_set_parent(struct clk *c, struct clk *p) 631 + { 632 + u32 val; 633 + const struct clk_mux_sel *sel; 634 + int shift; 635 + 636 + val = clk_readl(c->reg + SUPER_CLK_MUX); 637 + BUG_ON(((val & SUPER_STATE_MASK) != SUPER_STATE_RUN) && 638 + ((val & SUPER_STATE_MASK) != SUPER_STATE_IDLE)); 639 + shift = ((val & SUPER_STATE_MASK) == SUPER_STATE_IDLE) ? 640 + SUPER_IDLE_SOURCE_SHIFT : SUPER_RUN_SOURCE_SHIFT; 641 + for (sel = c->inputs; sel->input != NULL; sel++) { 642 + if (sel->input == p) { 643 + /* For LP mode super-clock switch between PLLX direct 644 + and divided-by-2 outputs is allowed only when other 645 + than PLLX clock source is current parent */ 646 + if ((c->flags & DIV_2) && (p->flags & PLLX) && 647 + ((sel->value ^ val) & SUPER_LP_DIV2_BYPASS)) { 648 + if (c->parent->flags & PLLX) 649 + return -EINVAL; 650 + val ^= SUPER_LP_DIV2_BYPASS; 651 + clk_writel_delay(val, c->reg); 652 + } 653 + val &= ~(SUPER_SOURCE_MASK << shift); 654 + val |= (sel->value & SUPER_SOURCE_MASK) << shift; 655 + 656 + /* 7.1 divider for CPU super-clock does not affect 657 + PLLX path */ 658 + if (c->flags & DIV_U71) { 659 + u32 div = 0; 660 + if (!(p->flags & PLLX)) { 661 + div = clk_readl(c->reg + 662 + SUPER_CLK_DIVIDER); 663 + div &= SUPER_CLOCK_DIV_U71_MASK; 664 + div >>= SUPER_CLOCK_DIV_U71_SHIFT; 665 + } 666 + c->div = div + 2; 667 + c->mul = 2; 668 + } 669 + 670 + if (c->refcnt) 671 + clk_enable(p); 672 + 673 + clk_writel_delay(val, c->reg); 674 + 675 + if (c->refcnt && c->parent) 676 + clk_disable(c->parent); 677 + 678 + clk_reparent(c, p); 679 + return 0; 680 + } 681 + } 682 + return -EINVAL; 683 + } 684 + 685 + /* 686 + * Do not use super clocks "skippers", since dividing using a clock skipper 687 + * does not allow the voltage to be scaled down. Instead adjust the rate of 688 + * the parent clock. This requires that the parent of a super clock have no 689 + * other children, otherwise the rate will change underneath the other 690 + * children. Special case: if fixed rate PLL is CPU super clock parent the 691 + * rate of this PLL can't be changed, and it has many other children. In 692 + * this case use 7.1 fractional divider to adjust the super clock rate. 693 + */ 694 + static int tegra30_super_clk_set_rate(struct clk *c, unsigned long rate) 695 + { 696 + if ((c->flags & DIV_U71) && (c->parent->flags & PLL_FIXED)) { 697 + int div = clk_div71_get_divider(c->parent->u.pll.fixed_rate, 698 + rate, c->flags, ROUND_DIVIDER_DOWN); 699 + div = max(div, SUPER_CLOCK_DIV_U71_MIN); 700 + 701 + clk_writel(div << SUPER_CLOCK_DIV_U71_SHIFT, 702 + c->reg + SUPER_CLK_DIVIDER); 703 + c->div = div + 2; 704 + c->mul = 2; 705 + return 0; 706 + } 707 + return clk_set_rate(c->parent, rate); 708 + } 709 + 710 + static struct clk_ops tegra_super_ops = { 711 + .init = tegra30_super_clk_init, 712 + .enable = tegra30_super_clk_enable, 713 + .disable = tegra30_super_clk_disable, 714 + .set_parent = tegra30_super_clk_set_parent, 715 + .set_rate = tegra30_super_clk_set_rate, 716 + }; 717 + 718 + static int tegra30_twd_clk_set_rate(struct clk *c, unsigned long rate) 719 + { 720 + /* The input value 'rate' is the clock rate of the CPU complex. */ 721 + c->rate = (rate * c->mul) / c->div; 722 + return 0; 723 + } 724 + 725 + static struct clk_ops tegra30_twd_ops = { 726 + .set_rate = tegra30_twd_clk_set_rate, 727 + }; 728 + 729 + /* Blink output functions */ 730 + 731 + static void tegra30_blink_clk_init(struct clk *c) 732 + { 733 + u32 val; 734 + 735 + val = pmc_readl(PMC_CTRL); 736 + c->state = (val & PMC_CTRL_BLINK_ENB) ? ON : OFF; 737 + c->mul = 1; 738 + val = pmc_readl(c->reg); 739 + 740 + if (val & PMC_BLINK_TIMER_ENB) { 741 + unsigned int on_off; 742 + 743 + on_off = (val >> PMC_BLINK_TIMER_DATA_ON_SHIFT) & 744 + PMC_BLINK_TIMER_DATA_ON_MASK; 745 + val >>= PMC_BLINK_TIMER_DATA_OFF_SHIFT; 746 + val &= PMC_BLINK_TIMER_DATA_OFF_MASK; 747 + on_off += val; 748 + /* each tick in the blink timer is 4 32KHz clocks */ 749 + c->div = on_off * 4; 750 + } else { 751 + c->div = 1; 752 + } 753 + } 754 + 755 + static int tegra30_blink_clk_enable(struct clk *c) 756 + { 757 + u32 val; 758 + 759 + val = pmc_readl(PMC_DPD_PADS_ORIDE); 760 + pmc_writel(val | PMC_DPD_PADS_ORIDE_BLINK_ENB, PMC_DPD_PADS_ORIDE); 761 + 762 + val = pmc_readl(PMC_CTRL); 763 + pmc_writel(val | PMC_CTRL_BLINK_ENB, PMC_CTRL); 764 + 765 + return 0; 766 + } 767 + 768 + static void tegra30_blink_clk_disable(struct clk *c) 769 + { 770 + u32 val; 771 + 772 + val = pmc_readl(PMC_CTRL); 773 + pmc_writel(val & ~PMC_CTRL_BLINK_ENB, PMC_CTRL); 774 + 775 + val = pmc_readl(PMC_DPD_PADS_ORIDE); 776 + pmc_writel(val & ~PMC_DPD_PADS_ORIDE_BLINK_ENB, PMC_DPD_PADS_ORIDE); 777 + } 778 + 779 + static int tegra30_blink_clk_set_rate(struct clk *c, unsigned long rate) 780 + { 781 + unsigned long parent_rate = clk_get_rate(c->parent); 782 + if (rate >= parent_rate) { 783 + c->div = 1; 784 + pmc_writel(0, c->reg); 785 + } else { 786 + unsigned int on_off; 787 + u32 val; 788 + 789 + on_off = DIV_ROUND_UP(parent_rate / 8, rate); 790 + c->div = on_off * 8; 791 + 792 + val = (on_off & PMC_BLINK_TIMER_DATA_ON_MASK) << 793 + PMC_BLINK_TIMER_DATA_ON_SHIFT; 794 + on_off &= PMC_BLINK_TIMER_DATA_OFF_MASK; 795 + on_off <<= PMC_BLINK_TIMER_DATA_OFF_SHIFT; 796 + val |= on_off; 797 + val |= PMC_BLINK_TIMER_ENB; 798 + pmc_writel(val, c->reg); 799 + } 800 + 801 + return 0; 802 + } 803 + 804 + static struct clk_ops tegra_blink_clk_ops = { 805 + .init = &tegra30_blink_clk_init, 806 + .enable = &tegra30_blink_clk_enable, 807 + .disable = &tegra30_blink_clk_disable, 808 + .set_rate = &tegra30_blink_clk_set_rate, 809 + }; 810 + 811 + /* PLL Functions */ 812 + static int tegra30_pll_clk_wait_for_lock(struct clk *c, u32 lock_reg, 813 + u32 lock_bit) 814 + { 815 + #if USE_PLL_LOCK_BITS 816 + int i; 817 + for (i = 0; i < c->u.pll.lock_delay; i++) { 818 + if (clk_readl(lock_reg) & lock_bit) { 819 + udelay(PLL_POST_LOCK_DELAY); 820 + return 0; 821 + } 822 + udelay(2); /* timeout = 2 * lock time */ 823 + } 824 + pr_err("Timed out waiting for lock bit on pll %s", c->name); 825 + return -1; 826 + #endif 827 + udelay(c->u.pll.lock_delay); 828 + 829 + return 0; 830 + } 831 + 832 + 833 + static void tegra30_utmi_param_configure(struct clk *c) 834 + { 835 + u32 reg; 836 + int i; 837 + unsigned long main_rate = 838 + clk_get_rate(c->parent->parent); 839 + 840 + for (i = 0; i < ARRAY_SIZE(utmi_parameters); i++) { 841 + if (main_rate == utmi_parameters[i].osc_frequency) 842 + break; 843 + } 844 + 845 + if (i >= ARRAY_SIZE(utmi_parameters)) { 846 + pr_err("%s: Unexpected main rate %lu\n", __func__, main_rate); 847 + return; 848 + } 849 + 850 + reg = clk_readl(UTMIP_PLL_CFG2); 851 + 852 + /* Program UTMIP PLL stable and active counts */ 853 + /* [FIXME] arclk_rst.h says WRONG! This should be 1ms -> 0x50 Check! */ 854 + reg &= ~UTMIP_PLL_CFG2_STABLE_COUNT(~0); 855 + reg |= UTMIP_PLL_CFG2_STABLE_COUNT( 856 + utmi_parameters[i].stable_count); 857 + 858 + reg &= ~UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(~0); 859 + 860 + reg |= UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT( 861 + utmi_parameters[i].active_delay_count); 862 + 863 + /* Remove power downs from UTMIP PLL control bits */ 864 + reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN; 865 + reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN; 866 + reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN; 867 + 868 + clk_writel(reg, UTMIP_PLL_CFG2); 869 + 870 + /* Program UTMIP PLL delay and oscillator frequency counts */ 871 + reg = clk_readl(UTMIP_PLL_CFG1); 872 + reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0); 873 + 874 + reg |= UTMIP_PLL_CFG1_ENABLE_DLY_COUNT( 875 + utmi_parameters[i].enable_delay_count); 876 + 877 + reg &= ~UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(~0); 878 + reg |= UTMIP_PLL_CFG1_XTAL_FREQ_COUNT( 879 + utmi_parameters[i].xtal_freq_count); 880 + 881 + /* Remove power downs from UTMIP PLL control bits */ 882 + reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN; 883 + reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN; 884 + reg &= ~UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN; 885 + 886 + clk_writel(reg, UTMIP_PLL_CFG1); 887 + } 888 + 889 + static void tegra30_pll_clk_init(struct clk *c) 890 + { 891 + u32 val = clk_readl(c->reg + PLL_BASE); 892 + 893 + c->state = (val & PLL_BASE_ENABLE) ? ON : OFF; 894 + 895 + if (c->flags & PLL_FIXED && !(val & PLL_BASE_OVERRIDE)) { 896 + const struct clk_pll_freq_table *sel; 897 + unsigned long input_rate = clk_get_rate(c->parent); 898 + for (sel = c->u.pll.freq_table; sel->input_rate != 0; sel++) { 899 + if (sel->input_rate == input_rate && 900 + sel->output_rate == c->u.pll.fixed_rate) { 901 + c->mul = sel->n; 902 + c->div = sel->m * sel->p; 903 + return; 904 + } 905 + } 906 + pr_err("Clock %s has unknown fixed frequency\n", c->name); 907 + BUG(); 908 + } else if (val & PLL_BASE_BYPASS) { 909 + c->mul = 1; 910 + c->div = 1; 911 + } else { 912 + c->mul = (val & PLL_BASE_DIVN_MASK) >> PLL_BASE_DIVN_SHIFT; 913 + c->div = (val & PLL_BASE_DIVM_MASK) >> PLL_BASE_DIVM_SHIFT; 914 + if (c->flags & PLLU) 915 + c->div *= (val & PLLU_BASE_POST_DIV) ? 1 : 2; 916 + else 917 + c->div *= (0x1 << ((val & PLL_BASE_DIVP_MASK) >> 918 + PLL_BASE_DIVP_SHIFT)); 919 + if (c->flags & PLL_FIXED) { 920 + unsigned long rate = clk_get_rate_locked(c); 921 + BUG_ON(rate != c->u.pll.fixed_rate); 922 + } 923 + } 924 + 925 + if (c->flags & PLLU) 926 + tegra30_utmi_param_configure(c); 927 + } 928 + 929 + static int tegra30_pll_clk_enable(struct clk *c) 930 + { 931 + u32 val; 932 + pr_debug("%s on clock %s\n", __func__, c->name); 933 + 934 + #if USE_PLL_LOCK_BITS 935 + val = clk_readl(c->reg + PLL_MISC(c)); 936 + val |= PLL_MISC_LOCK_ENABLE(c); 937 + clk_writel(val, c->reg + PLL_MISC(c)); 938 + #endif 939 + val = clk_readl(c->reg + PLL_BASE); 940 + val &= ~PLL_BASE_BYPASS; 941 + val |= PLL_BASE_ENABLE; 942 + clk_writel(val, c->reg + PLL_BASE); 943 + 944 + if (c->flags & PLLM) { 945 + val = pmc_readl(PMC_PLLP_WB0_OVERRIDE); 946 + val |= PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE; 947 + pmc_writel(val, PMC_PLLP_WB0_OVERRIDE); 948 + } 949 + 950 + tegra30_pll_clk_wait_for_lock(c, c->reg + PLL_BASE, PLL_BASE_LOCK); 951 + 952 + return 0; 953 + } 954 + 955 + static void tegra30_pll_clk_disable(struct clk *c) 956 + { 957 + u32 val; 958 + pr_debug("%s on clock %s\n", __func__, c->name); 959 + 960 + val = clk_readl(c->reg); 961 + val &= ~(PLL_BASE_BYPASS | PLL_BASE_ENABLE); 962 + clk_writel(val, c->reg); 963 + 964 + if (c->flags & PLLM) { 965 + val = pmc_readl(PMC_PLLP_WB0_OVERRIDE); 966 + val &= ~PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE; 967 + pmc_writel(val, PMC_PLLP_WB0_OVERRIDE); 968 + } 969 + } 970 + 971 + static int tegra30_pll_clk_set_rate(struct clk *c, unsigned long rate) 972 + { 973 + u32 val, p_div, old_base; 974 + unsigned long input_rate; 975 + const struct clk_pll_freq_table *sel; 976 + struct clk_pll_freq_table cfg; 977 + 978 + pr_debug("%s: %s %lu\n", __func__, c->name, rate); 979 + 980 + if (c->flags & PLL_FIXED) { 981 + int ret = 0; 982 + if (rate != c->u.pll.fixed_rate) { 983 + pr_err("%s: Can not change %s fixed rate %lu to %lu\n", 984 + __func__, c->name, c->u.pll.fixed_rate, rate); 985 + ret = -EINVAL; 986 + } 987 + return ret; 988 + } 989 + 990 + if (c->flags & PLLM) { 991 + if (rate != clk_get_rate_locked(c)) { 992 + pr_err("%s: Can not change memory %s rate in flight\n", 993 + __func__, c->name); 994 + return -EINVAL; 995 + } 996 + return 0; 997 + } 998 + 999 + p_div = 0; 1000 + input_rate = clk_get_rate(c->parent); 1001 + 1002 + /* Check if the target rate is tabulated */ 1003 + for (sel = c->u.pll.freq_table; sel->input_rate != 0; sel++) { 1004 + if (sel->input_rate == input_rate && sel->output_rate == rate) { 1005 + if (c->flags & PLLU) { 1006 + BUG_ON(sel->p < 1 || sel->p > 2); 1007 + if (sel->p == 1) 1008 + p_div = PLLU_BASE_POST_DIV; 1009 + } else { 1010 + BUG_ON(sel->p < 1); 1011 + for (val = sel->p; val > 1; val >>= 1) 1012 + p_div++; 1013 + p_div <<= PLL_BASE_DIVP_SHIFT; 1014 + } 1015 + break; 1016 + } 1017 + } 1018 + 1019 + /* Configure out-of-table rate */ 1020 + if (sel->input_rate == 0) { 1021 + unsigned long cfreq; 1022 + BUG_ON(c->flags & PLLU); 1023 + sel = &cfg; 1024 + 1025 + switch (input_rate) { 1026 + case 12000000: 1027 + case 26000000: 1028 + cfreq = (rate <= 1000000 * 1000) ? 1000000 : 2000000; 1029 + break; 1030 + case 13000000: 1031 + cfreq = (rate <= 1000000 * 1000) ? 1000000 : 2600000; 1032 + break; 1033 + case 16800000: 1034 + case 19200000: 1035 + cfreq = (rate <= 1200000 * 1000) ? 1200000 : 2400000; 1036 + break; 1037 + default: 1038 + pr_err("%s: Unexpected reference rate %lu\n", 1039 + __func__, input_rate); 1040 + BUG(); 1041 + } 1042 + 1043 + /* Raise VCO to guarantee 0.5% accuracy */ 1044 + for (cfg.output_rate = rate; cfg.output_rate < 200 * cfreq; 1045 + cfg.output_rate <<= 1) 1046 + p_div++; 1047 + 1048 + cfg.p = 0x1 << p_div; 1049 + cfg.m = input_rate / cfreq; 1050 + cfg.n = cfg.output_rate / cfreq; 1051 + cfg.cpcon = OUT_OF_TABLE_CPCON; 1052 + 1053 + if ((cfg.m > (PLL_BASE_DIVM_MASK >> PLL_BASE_DIVM_SHIFT)) || 1054 + (cfg.n > (PLL_BASE_DIVN_MASK >> PLL_BASE_DIVN_SHIFT)) || 1055 + (p_div > (PLL_BASE_DIVP_MASK >> PLL_BASE_DIVP_SHIFT)) || 1056 + (cfg.output_rate > c->u.pll.vco_max)) { 1057 + pr_err("%s: Failed to set %s out-of-table rate %lu\n", 1058 + __func__, c->name, rate); 1059 + return -EINVAL; 1060 + } 1061 + p_div <<= PLL_BASE_DIVP_SHIFT; 1062 + } 1063 + 1064 + c->mul = sel->n; 1065 + c->div = sel->m * sel->p; 1066 + 1067 + old_base = val = clk_readl(c->reg + PLL_BASE); 1068 + val &= ~(PLL_BASE_DIVM_MASK | PLL_BASE_DIVN_MASK | 1069 + ((c->flags & PLLU) ? PLLU_BASE_POST_DIV : PLL_BASE_DIVP_MASK)); 1070 + val |= (sel->m << PLL_BASE_DIVM_SHIFT) | 1071 + (sel->n << PLL_BASE_DIVN_SHIFT) | p_div; 1072 + if (val == old_base) 1073 + return 0; 1074 + 1075 + if (c->state == ON) { 1076 + tegra30_pll_clk_disable(c); 1077 + val &= ~(PLL_BASE_BYPASS | PLL_BASE_ENABLE); 1078 + } 1079 + clk_writel(val, c->reg + PLL_BASE); 1080 + 1081 + if (c->flags & PLL_HAS_CPCON) { 1082 + val = clk_readl(c->reg + PLL_MISC(c)); 1083 + val &= ~PLL_MISC_CPCON_MASK; 1084 + val |= sel->cpcon << PLL_MISC_CPCON_SHIFT; 1085 + if (c->flags & (PLLU | PLLD)) { 1086 + val &= ~PLL_MISC_LFCON_MASK; 1087 + if (sel->n >= PLLDU_LFCON_SET_DIVN) 1088 + val |= 0x1 << PLL_MISC_LFCON_SHIFT; 1089 + } else if (c->flags & (PLLX | PLLM)) { 1090 + val &= ~(0x1 << PLL_MISC_DCCON_SHIFT); 1091 + if (rate >= (c->u.pll.vco_max >> 1)) 1092 + val |= 0x1 << PLL_MISC_DCCON_SHIFT; 1093 + } 1094 + clk_writel(val, c->reg + PLL_MISC(c)); 1095 + } 1096 + 1097 + if (c->state == ON) 1098 + tegra30_pll_clk_enable(c); 1099 + 1100 + return 0; 1101 + } 1102 + 1103 + static struct clk_ops tegra_pll_ops = { 1104 + .init = tegra30_pll_clk_init, 1105 + .enable = tegra30_pll_clk_enable, 1106 + .disable = tegra30_pll_clk_disable, 1107 + .set_rate = tegra30_pll_clk_set_rate, 1108 + }; 1109 + 1110 + static int 1111 + tegra30_plld_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting) 1112 + { 1113 + u32 val, mask, reg; 1114 + 1115 + switch (p) { 1116 + case TEGRA_CLK_PLLD_CSI_OUT_ENB: 1117 + mask = PLLD_BASE_CSI_CLKENABLE; 1118 + reg = c->reg + PLL_BASE; 1119 + break; 1120 + case TEGRA_CLK_PLLD_DSI_OUT_ENB: 1121 + mask = PLLD_MISC_DSI_CLKENABLE; 1122 + reg = c->reg + PLL_MISC(c); 1123 + break; 1124 + case TEGRA_CLK_PLLD_MIPI_MUX_SEL: 1125 + if (!(c->flags & PLL_ALT_MISC_REG)) { 1126 + mask = PLLD_BASE_DSIB_MUX_MASK; 1127 + reg = c->reg + PLL_BASE; 1128 + break; 1129 + } 1130 + /* fall through - error since PLLD2 does not have MUX_SEL control */ 1131 + default: 1132 + return -EINVAL; 1133 + } 1134 + 1135 + val = clk_readl(reg); 1136 + if (setting) 1137 + val |= mask; 1138 + else 1139 + val &= ~mask; 1140 + clk_writel(val, reg); 1141 + return 0; 1142 + } 1143 + 1144 + static struct clk_ops tegra_plld_ops = { 1145 + .init = tegra30_pll_clk_init, 1146 + .enable = tegra30_pll_clk_enable, 1147 + .disable = tegra30_pll_clk_disable, 1148 + .set_rate = tegra30_pll_clk_set_rate, 1149 + .clk_cfg_ex = tegra30_plld_clk_cfg_ex, 1150 + }; 1151 + 1152 + static void tegra30_plle_clk_init(struct clk *c) 1153 + { 1154 + u32 val; 1155 + 1156 + val = clk_readl(PLLE_AUX); 1157 + c->parent = (val & PLLE_AUX_PLLP_SEL) ? 1158 + tegra_get_clock_by_name("pll_p") : 1159 + tegra_get_clock_by_name("pll_ref"); 1160 + 1161 + val = clk_readl(c->reg + PLL_BASE); 1162 + c->state = (val & PLLE_BASE_ENABLE) ? ON : OFF; 1163 + c->mul = (val & PLLE_BASE_DIVN_MASK) >> PLLE_BASE_DIVN_SHIFT; 1164 + c->div = (val & PLLE_BASE_DIVM_MASK) >> PLLE_BASE_DIVM_SHIFT; 1165 + c->div *= (val & PLLE_BASE_DIVP_MASK) >> PLLE_BASE_DIVP_SHIFT; 1166 + } 1167 + 1168 + static void tegra30_plle_clk_disable(struct clk *c) 1169 + { 1170 + u32 val; 1171 + pr_debug("%s on clock %s\n", __func__, c->name); 1172 + 1173 + val = clk_readl(c->reg + PLL_BASE); 1174 + val &= ~(PLLE_BASE_CML_ENABLE | PLLE_BASE_ENABLE); 1175 + clk_writel(val, c->reg + PLL_BASE); 1176 + } 1177 + 1178 + static void tegra30_plle_training(struct clk *c) 1179 + { 1180 + u32 val; 1181 + 1182 + /* PLLE is already disabled, and setup cleared; 1183 + * create falling edge on PLLE IDDQ input */ 1184 + val = pmc_readl(PMC_SATA_PWRGT); 1185 + val |= PMC_SATA_PWRGT_PLLE_IDDQ_VALUE; 1186 + pmc_writel(val, PMC_SATA_PWRGT); 1187 + 1188 + val = pmc_readl(PMC_SATA_PWRGT); 1189 + val |= PMC_SATA_PWRGT_PLLE_IDDQ_SWCTL; 1190 + pmc_writel(val, PMC_SATA_PWRGT); 1191 + 1192 + val = pmc_readl(PMC_SATA_PWRGT); 1193 + val &= ~PMC_SATA_PWRGT_PLLE_IDDQ_VALUE; 1194 + pmc_writel(val, PMC_SATA_PWRGT); 1195 + 1196 + do { 1197 + val = clk_readl(c->reg + PLL_MISC(c)); 1198 + } while (!(val & PLLE_MISC_READY)); 1199 + } 1200 + 1201 + static int tegra30_plle_configure(struct clk *c, bool force_training) 1202 + { 1203 + u32 val; 1204 + const struct clk_pll_freq_table *sel; 1205 + unsigned long rate = c->u.pll.fixed_rate; 1206 + unsigned long input_rate = clk_get_rate(c->parent); 1207 + 1208 + for (sel = c->u.pll.freq_table; sel->input_rate != 0; sel++) { 1209 + if (sel->input_rate == input_rate && sel->output_rate == rate) 1210 + break; 1211 + } 1212 + 1213 + if (sel->input_rate == 0) 1214 + return -ENOSYS; 1215 + 1216 + /* disable PLLE, clear setup fiels */ 1217 + tegra30_plle_clk_disable(c); 1218 + 1219 + val = clk_readl(c->reg + PLL_MISC(c)); 1220 + val &= ~(PLLE_MISC_LOCK_ENABLE | PLLE_MISC_SETUP_MASK); 1221 + clk_writel(val, c->reg + PLL_MISC(c)); 1222 + 1223 + /* training */ 1224 + val = clk_readl(c->reg + PLL_MISC(c)); 1225 + if (force_training || (!(val & PLLE_MISC_READY))) 1226 + tegra30_plle_training(c); 1227 + 1228 + /* configure dividers, setup, disable SS */ 1229 + val = clk_readl(c->reg + PLL_BASE); 1230 + val &= ~PLLE_BASE_DIV_MASK; 1231 + val |= PLLE_BASE_DIV(sel->m, sel->n, sel->p, sel->cpcon); 1232 + clk_writel(val, c->reg + PLL_BASE); 1233 + c->mul = sel->n; 1234 + c->div = sel->m * sel->p; 1235 + 1236 + val = clk_readl(c->reg + PLL_MISC(c)); 1237 + val |= PLLE_MISC_SETUP_VALUE; 1238 + val |= PLLE_MISC_LOCK_ENABLE; 1239 + clk_writel(val, c->reg + PLL_MISC(c)); 1240 + 1241 + val = clk_readl(PLLE_SS_CTRL); 1242 + val |= PLLE_SS_DISABLE; 1243 + clk_writel(val, PLLE_SS_CTRL); 1244 + 1245 + /* enable and lock PLLE*/ 1246 + val = clk_readl(c->reg + PLL_BASE); 1247 + val |= (PLLE_BASE_CML_ENABLE | PLLE_BASE_ENABLE); 1248 + clk_writel(val, c->reg + PLL_BASE); 1249 + 1250 + tegra30_pll_clk_wait_for_lock(c, c->reg + PLL_MISC(c), PLLE_MISC_LOCK); 1251 + 1252 + return 0; 1253 + } 1254 + 1255 + static int tegra30_plle_clk_enable(struct clk *c) 1256 + { 1257 + pr_debug("%s on clock %s\n", __func__, c->name); 1258 + return tegra30_plle_configure(c, !c->set); 1259 + } 1260 + 1261 + static struct clk_ops tegra_plle_ops = { 1262 + .init = tegra30_plle_clk_init, 1263 + .enable = tegra30_plle_clk_enable, 1264 + .disable = tegra30_plle_clk_disable, 1265 + }; 1266 + 1267 + /* Clock divider ops */ 1268 + static void tegra30_pll_div_clk_init(struct clk *c) 1269 + { 1270 + if (c->flags & DIV_U71) { 1271 + u32 divu71; 1272 + u32 val = clk_readl(c->reg); 1273 + val >>= c->reg_shift; 1274 + c->state = (val & PLL_OUT_CLKEN) ? ON : OFF; 1275 + if (!(val & PLL_OUT_RESET_DISABLE)) 1276 + c->state = OFF; 1277 + 1278 + divu71 = (val & PLL_OUT_RATIO_MASK) >> PLL_OUT_RATIO_SHIFT; 1279 + c->div = (divu71 + 2); 1280 + c->mul = 2; 1281 + } else if (c->flags & DIV_2) { 1282 + c->state = ON; 1283 + if (c->flags & (PLLD | PLLX)) { 1284 + c->div = 2; 1285 + c->mul = 1; 1286 + } else 1287 + BUG(); 1288 + } else { 1289 + c->state = ON; 1290 + c->div = 1; 1291 + c->mul = 1; 1292 + } 1293 + } 1294 + 1295 + static int tegra30_pll_div_clk_enable(struct clk *c) 1296 + { 1297 + u32 val; 1298 + u32 new_val; 1299 + 1300 + pr_debug("%s: %s\n", __func__, c->name); 1301 + if (c->flags & DIV_U71) { 1302 + val = clk_readl(c->reg); 1303 + new_val = val >> c->reg_shift; 1304 + new_val &= 0xFFFF; 1305 + 1306 + new_val |= PLL_OUT_CLKEN | PLL_OUT_RESET_DISABLE; 1307 + 1308 + val &= ~(0xFFFF << c->reg_shift); 1309 + val |= new_val << c->reg_shift; 1310 + clk_writel_delay(val, c->reg); 1311 + return 0; 1312 + } else if (c->flags & DIV_2) { 1313 + return 0; 1314 + } 1315 + return -EINVAL; 1316 + } 1317 + 1318 + static void tegra30_pll_div_clk_disable(struct clk *c) 1319 + { 1320 + u32 val; 1321 + u32 new_val; 1322 + 1323 + pr_debug("%s: %s\n", __func__, c->name); 1324 + if (c->flags & DIV_U71) { 1325 + val = clk_readl(c->reg); 1326 + new_val = val >> c->reg_shift; 1327 + new_val &= 0xFFFF; 1328 + 1329 + new_val &= ~(PLL_OUT_CLKEN | PLL_OUT_RESET_DISABLE); 1330 + 1331 + val &= ~(0xFFFF << c->reg_shift); 1332 + val |= new_val << c->reg_shift; 1333 + clk_writel_delay(val, c->reg); 1334 + } 1335 + } 1336 + 1337 + static int tegra30_pll_div_clk_set_rate(struct clk *c, unsigned long rate) 1338 + { 1339 + u32 val; 1340 + u32 new_val; 1341 + int divider_u71; 1342 + unsigned long parent_rate = clk_get_rate(c->parent); 1343 + 1344 + pr_debug("%s: %s %lu\n", __func__, c->name, rate); 1345 + if (c->flags & DIV_U71) { 1346 + divider_u71 = clk_div71_get_divider( 1347 + parent_rate, rate, c->flags, ROUND_DIVIDER_UP); 1348 + if (divider_u71 >= 0) { 1349 + val = clk_readl(c->reg); 1350 + new_val = val >> c->reg_shift; 1351 + new_val &= 0xFFFF; 1352 + if (c->flags & DIV_U71_FIXED) 1353 + new_val |= PLL_OUT_OVERRIDE; 1354 + new_val &= ~PLL_OUT_RATIO_MASK; 1355 + new_val |= divider_u71 << PLL_OUT_RATIO_SHIFT; 1356 + 1357 + val &= ~(0xFFFF << c->reg_shift); 1358 + val |= new_val << c->reg_shift; 1359 + clk_writel_delay(val, c->reg); 1360 + c->div = divider_u71 + 2; 1361 + c->mul = 2; 1362 + return 0; 1363 + } 1364 + } else if (c->flags & DIV_2) 1365 + return clk_set_rate(c->parent, rate * 2); 1366 + 1367 + return -EINVAL; 1368 + } 1369 + 1370 + static long tegra30_pll_div_clk_round_rate(struct clk *c, unsigned long rate) 1371 + { 1372 + int divider; 1373 + unsigned long parent_rate = clk_get_rate(c->parent); 1374 + pr_debug("%s: %s %lu\n", __func__, c->name, rate); 1375 + 1376 + if (c->flags & DIV_U71) { 1377 + divider = clk_div71_get_divider( 1378 + parent_rate, rate, c->flags, ROUND_DIVIDER_UP); 1379 + if (divider < 0) 1380 + return divider; 1381 + return DIV_ROUND_UP(parent_rate * 2, divider + 2); 1382 + } else if (c->flags & DIV_2) 1383 + /* no rounding - fixed DIV_2 dividers pass rate to parent PLL */ 1384 + return rate; 1385 + 1386 + return -EINVAL; 1387 + } 1388 + 1389 + static struct clk_ops tegra_pll_div_ops = { 1390 + .init = tegra30_pll_div_clk_init, 1391 + .enable = tegra30_pll_div_clk_enable, 1392 + .disable = tegra30_pll_div_clk_disable, 1393 + .set_rate = tegra30_pll_div_clk_set_rate, 1394 + .round_rate = tegra30_pll_div_clk_round_rate, 1395 + }; 1396 + 1397 + /* Periph clk ops */ 1398 + static inline u32 periph_clk_source_mask(struct clk *c) 1399 + { 1400 + if (c->flags & MUX8) 1401 + return 7 << 29; 1402 + else if (c->flags & MUX_PWM) 1403 + return 3 << 28; 1404 + else if (c->flags & MUX_CLK_OUT) 1405 + return 3 << (c->u.periph.clk_num + 4); 1406 + else if (c->flags & PLLD) 1407 + return PLLD_BASE_DSIB_MUX_MASK; 1408 + else 1409 + return 3 << 30; 1410 + } 1411 + 1412 + static inline u32 periph_clk_source_shift(struct clk *c) 1413 + { 1414 + if (c->flags & MUX8) 1415 + return 29; 1416 + else if (c->flags & MUX_PWM) 1417 + return 28; 1418 + else if (c->flags & MUX_CLK_OUT) 1419 + return c->u.periph.clk_num + 4; 1420 + else if (c->flags & PLLD) 1421 + return PLLD_BASE_DSIB_MUX_SHIFT; 1422 + else 1423 + return 30; 1424 + } 1425 + 1426 + static void tegra30_periph_clk_init(struct clk *c) 1427 + { 1428 + u32 val = clk_readl(c->reg); 1429 + const struct clk_mux_sel *mux = 0; 1430 + const struct clk_mux_sel *sel; 1431 + if (c->flags & MUX) { 1432 + for (sel = c->inputs; sel->input != NULL; sel++) { 1433 + if (((val & periph_clk_source_mask(c)) >> 1434 + periph_clk_source_shift(c)) == sel->value) 1435 + mux = sel; 1436 + } 1437 + BUG_ON(!mux); 1438 + 1439 + c->parent = mux->input; 1440 + } else { 1441 + c->parent = c->inputs[0].input; 1442 + } 1443 + 1444 + if (c->flags & DIV_U71) { 1445 + u32 divu71 = val & PERIPH_CLK_SOURCE_DIVU71_MASK; 1446 + if ((c->flags & DIV_U71_UART) && 1447 + (!(val & PERIPH_CLK_UART_DIV_ENB))) { 1448 + divu71 = 0; 1449 + } 1450 + if (c->flags & DIV_U71_IDLE) { 1451 + val &= ~(PERIPH_CLK_SOURCE_DIVU71_MASK << 1452 + PERIPH_CLK_SOURCE_DIVIDLE_SHIFT); 1453 + val |= (PERIPH_CLK_SOURCE_DIVIDLE_VAL << 1454 + PERIPH_CLK_SOURCE_DIVIDLE_SHIFT); 1455 + clk_writel(val, c->reg); 1456 + } 1457 + c->div = divu71 + 2; 1458 + c->mul = 2; 1459 + } else if (c->flags & DIV_U16) { 1460 + u32 divu16 = val & PERIPH_CLK_SOURCE_DIVU16_MASK; 1461 + c->div = divu16 + 1; 1462 + c->mul = 1; 1463 + } else { 1464 + c->div = 1; 1465 + c->mul = 1; 1466 + } 1467 + 1468 + c->state = ON; 1469 + if (!(clk_readl(PERIPH_CLK_TO_ENB_REG(c)) & PERIPH_CLK_TO_BIT(c))) 1470 + c->state = OFF; 1471 + if (!(c->flags & PERIPH_NO_RESET)) 1472 + if (clk_readl(PERIPH_CLK_TO_RST_REG(c)) & PERIPH_CLK_TO_BIT(c)) 1473 + c->state = OFF; 1474 + } 1475 + 1476 + static int tegra30_periph_clk_enable(struct clk *c) 1477 + { 1478 + pr_debug("%s on clock %s\n", __func__, c->name); 1479 + 1480 + tegra_periph_clk_enable_refcount[c->u.periph.clk_num]++; 1481 + if (tegra_periph_clk_enable_refcount[c->u.periph.clk_num] > 1) 1482 + return 0; 1483 + 1484 + clk_writel_delay(PERIPH_CLK_TO_BIT(c), PERIPH_CLK_TO_ENB_SET_REG(c)); 1485 + if (!(c->flags & PERIPH_NO_RESET) && 1486 + !(c->flags & PERIPH_MANUAL_RESET)) { 1487 + if (clk_readl(PERIPH_CLK_TO_RST_REG(c)) & 1488 + PERIPH_CLK_TO_BIT(c)) { 1489 + udelay(5); /* reset propagation delay */ 1490 + clk_writel(PERIPH_CLK_TO_BIT(c), 1491 + PERIPH_CLK_TO_RST_CLR_REG(c)); 1492 + } 1493 + } 1494 + return 0; 1495 + } 1496 + 1497 + static void tegra30_periph_clk_disable(struct clk *c) 1498 + { 1499 + unsigned long val; 1500 + pr_debug("%s on clock %s\n", __func__, c->name); 1501 + 1502 + if (c->refcnt) 1503 + tegra_periph_clk_enable_refcount[c->u.periph.clk_num]--; 1504 + 1505 + if (tegra_periph_clk_enable_refcount[c->u.periph.clk_num] == 0) { 1506 + /* If peripheral is in the APB bus then read the APB bus to 1507 + * flush the write operation in apb bus. This will avoid the 1508 + * peripheral access after disabling clock*/ 1509 + if (c->flags & PERIPH_ON_APB) 1510 + val = chipid_readl(); 1511 + 1512 + clk_writel_delay( 1513 + PERIPH_CLK_TO_BIT(c), PERIPH_CLK_TO_ENB_CLR_REG(c)); 1514 + } 1515 + } 1516 + 1517 + static void tegra30_periph_clk_reset(struct clk *c, bool assert) 1518 + { 1519 + unsigned long val; 1520 + pr_debug("%s %s on clock %s\n", __func__, 1521 + assert ? "assert" : "deassert", c->name); 1522 + 1523 + if (!(c->flags & PERIPH_NO_RESET)) { 1524 + if (assert) { 1525 + /* If peripheral is in the APB bus then read the APB 1526 + * bus to flush the write operation in apb bus. This 1527 + * will avoid the peripheral access after disabling 1528 + * clock */ 1529 + if (c->flags & PERIPH_ON_APB) 1530 + val = chipid_readl(); 1531 + 1532 + clk_writel(PERIPH_CLK_TO_BIT(c), 1533 + PERIPH_CLK_TO_RST_SET_REG(c)); 1534 + } else 1535 + clk_writel(PERIPH_CLK_TO_BIT(c), 1536 + PERIPH_CLK_TO_RST_CLR_REG(c)); 1537 + } 1538 + } 1539 + 1540 + static int tegra30_periph_clk_set_parent(struct clk *c, struct clk *p) 1541 + { 1542 + u32 val; 1543 + const struct clk_mux_sel *sel; 1544 + pr_debug("%s: %s %s\n", __func__, c->name, p->name); 1545 + 1546 + if (!(c->flags & MUX)) 1547 + return (p == c->parent) ? 0 : (-EINVAL); 1548 + 1549 + for (sel = c->inputs; sel->input != NULL; sel++) { 1550 + if (sel->input == p) { 1551 + val = clk_readl(c->reg); 1552 + val &= ~periph_clk_source_mask(c); 1553 + val |= (sel->value << periph_clk_source_shift(c)); 1554 + 1555 + if (c->refcnt) 1556 + clk_enable(p); 1557 + 1558 + clk_writel_delay(val, c->reg); 1559 + 1560 + if (c->refcnt && c->parent) 1561 + clk_disable(c->parent); 1562 + 1563 + clk_reparent(c, p); 1564 + return 0; 1565 + } 1566 + } 1567 + 1568 + return -EINVAL; 1569 + } 1570 + 1571 + static int tegra30_periph_clk_set_rate(struct clk *c, unsigned long rate) 1572 + { 1573 + u32 val; 1574 + int divider; 1575 + unsigned long parent_rate = clk_get_rate(c->parent); 1576 + 1577 + if (c->flags & DIV_U71) { 1578 + divider = clk_div71_get_divider( 1579 + parent_rate, rate, c->flags, ROUND_DIVIDER_UP); 1580 + if (divider >= 0) { 1581 + val = clk_readl(c->reg); 1582 + val &= ~PERIPH_CLK_SOURCE_DIVU71_MASK; 1583 + val |= divider; 1584 + if (c->flags & DIV_U71_UART) { 1585 + if (divider) 1586 + val |= PERIPH_CLK_UART_DIV_ENB; 1587 + else 1588 + val &= ~PERIPH_CLK_UART_DIV_ENB; 1589 + } 1590 + clk_writel_delay(val, c->reg); 1591 + c->div = divider + 2; 1592 + c->mul = 2; 1593 + return 0; 1594 + } 1595 + } else if (c->flags & DIV_U16) { 1596 + divider = clk_div16_get_divider(parent_rate, rate); 1597 + if (divider >= 0) { 1598 + val = clk_readl(c->reg); 1599 + val &= ~PERIPH_CLK_SOURCE_DIVU16_MASK; 1600 + val |= divider; 1601 + clk_writel_delay(val, c->reg); 1602 + c->div = divider + 1; 1603 + c->mul = 1; 1604 + return 0; 1605 + } 1606 + } else if (parent_rate <= rate) { 1607 + c->div = 1; 1608 + c->mul = 1; 1609 + return 0; 1610 + } 1611 + return -EINVAL; 1612 + } 1613 + 1614 + static long tegra30_periph_clk_round_rate(struct clk *c, 1615 + unsigned long rate) 1616 + { 1617 + int divider; 1618 + unsigned long parent_rate = clk_get_rate(c->parent); 1619 + pr_debug("%s: %s %lu\n", __func__, c->name, rate); 1620 + 1621 + if (c->flags & DIV_U71) { 1622 + divider = clk_div71_get_divider( 1623 + parent_rate, rate, c->flags, ROUND_DIVIDER_UP); 1624 + if (divider < 0) 1625 + return divider; 1626 + 1627 + return DIV_ROUND_UP(parent_rate * 2, divider + 2); 1628 + } else if (c->flags & DIV_U16) { 1629 + divider = clk_div16_get_divider(parent_rate, rate); 1630 + if (divider < 0) 1631 + return divider; 1632 + return DIV_ROUND_UP(parent_rate, divider + 1); 1633 + } 1634 + return -EINVAL; 1635 + } 1636 + 1637 + static struct clk_ops tegra_periph_clk_ops = { 1638 + .init = &tegra30_periph_clk_init, 1639 + .enable = &tegra30_periph_clk_enable, 1640 + .disable = &tegra30_periph_clk_disable, 1641 + .set_parent = &tegra30_periph_clk_set_parent, 1642 + .set_rate = &tegra30_periph_clk_set_rate, 1643 + .round_rate = &tegra30_periph_clk_round_rate, 1644 + .reset = &tegra30_periph_clk_reset, 1645 + }; 1646 + 1647 + 1648 + /* Periph extended clock configuration ops */ 1649 + static int 1650 + tegra30_vi_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting) 1651 + { 1652 + if (p == TEGRA_CLK_VI_INP_SEL) { 1653 + u32 val = clk_readl(c->reg); 1654 + val &= ~PERIPH_CLK_VI_SEL_EX_MASK; 1655 + val |= (setting << PERIPH_CLK_VI_SEL_EX_SHIFT) & 1656 + PERIPH_CLK_VI_SEL_EX_MASK; 1657 + clk_writel(val, c->reg); 1658 + return 0; 1659 + } 1660 + return -EINVAL; 1661 + } 1662 + 1663 + static struct clk_ops tegra_vi_clk_ops = { 1664 + .init = &tegra30_periph_clk_init, 1665 + .enable = &tegra30_periph_clk_enable, 1666 + .disable = &tegra30_periph_clk_disable, 1667 + .set_parent = &tegra30_periph_clk_set_parent, 1668 + .set_rate = &tegra30_periph_clk_set_rate, 1669 + .round_rate = &tegra30_periph_clk_round_rate, 1670 + .clk_cfg_ex = &tegra30_vi_clk_cfg_ex, 1671 + .reset = &tegra30_periph_clk_reset, 1672 + }; 1673 + 1674 + static int 1675 + tegra30_nand_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting) 1676 + { 1677 + if (p == TEGRA_CLK_NAND_PAD_DIV2_ENB) { 1678 + u32 val = clk_readl(c->reg); 1679 + if (setting) 1680 + val |= PERIPH_CLK_NAND_DIV_EX_ENB; 1681 + else 1682 + val &= ~PERIPH_CLK_NAND_DIV_EX_ENB; 1683 + clk_writel(val, c->reg); 1684 + return 0; 1685 + } 1686 + return -EINVAL; 1687 + } 1688 + 1689 + static struct clk_ops tegra_nand_clk_ops = { 1690 + .init = &tegra30_periph_clk_init, 1691 + .enable = &tegra30_periph_clk_enable, 1692 + .disable = &tegra30_periph_clk_disable, 1693 + .set_parent = &tegra30_periph_clk_set_parent, 1694 + .set_rate = &tegra30_periph_clk_set_rate, 1695 + .round_rate = &tegra30_periph_clk_round_rate, 1696 + .clk_cfg_ex = &tegra30_nand_clk_cfg_ex, 1697 + .reset = &tegra30_periph_clk_reset, 1698 + }; 1699 + 1700 + 1701 + static int 1702 + tegra30_dtv_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting) 1703 + { 1704 + if (p == TEGRA_CLK_DTV_INVERT) { 1705 + u32 val = clk_readl(c->reg); 1706 + if (setting) 1707 + val |= PERIPH_CLK_DTV_POLARITY_INV; 1708 + else 1709 + val &= ~PERIPH_CLK_DTV_POLARITY_INV; 1710 + clk_writel(val, c->reg); 1711 + return 0; 1712 + } 1713 + return -EINVAL; 1714 + } 1715 + 1716 + static struct clk_ops tegra_dtv_clk_ops = { 1717 + .init = &tegra30_periph_clk_init, 1718 + .enable = &tegra30_periph_clk_enable, 1719 + .disable = &tegra30_periph_clk_disable, 1720 + .set_parent = &tegra30_periph_clk_set_parent, 1721 + .set_rate = &tegra30_periph_clk_set_rate, 1722 + .round_rate = &tegra30_periph_clk_round_rate, 1723 + .clk_cfg_ex = &tegra30_dtv_clk_cfg_ex, 1724 + .reset = &tegra30_periph_clk_reset, 1725 + }; 1726 + 1727 + static int tegra30_dsib_clk_set_parent(struct clk *c, struct clk *p) 1728 + { 1729 + const struct clk_mux_sel *sel; 1730 + struct clk *d = tegra_get_clock_by_name("pll_d"); 1731 + 1732 + pr_debug("%s: %s %s\n", __func__, c->name, p->name); 1733 + 1734 + for (sel = c->inputs; sel->input != NULL; sel++) { 1735 + if (sel->input == p) { 1736 + if (c->refcnt) 1737 + clk_enable(p); 1738 + 1739 + /* The DSIB parent selection bit is in PLLD base 1740 + register - can not do direct r-m-w, must be 1741 + protected by PLLD lock */ 1742 + tegra_clk_cfg_ex( 1743 + d, TEGRA_CLK_PLLD_MIPI_MUX_SEL, sel->value); 1744 + 1745 + if (c->refcnt && c->parent) 1746 + clk_disable(c->parent); 1747 + 1748 + clk_reparent(c, p); 1749 + return 0; 1750 + } 1751 + } 1752 + 1753 + return -EINVAL; 1754 + } 1755 + 1756 + static struct clk_ops tegra_dsib_clk_ops = { 1757 + .init = &tegra30_periph_clk_init, 1758 + .enable = &tegra30_periph_clk_enable, 1759 + .disable = &tegra30_periph_clk_disable, 1760 + .set_parent = &tegra30_dsib_clk_set_parent, 1761 + .set_rate = &tegra30_periph_clk_set_rate, 1762 + .round_rate = &tegra30_periph_clk_round_rate, 1763 + .reset = &tegra30_periph_clk_reset, 1764 + }; 1765 + 1766 + /* pciex clock support only reset function */ 1767 + static struct clk_ops tegra_pciex_clk_ops = { 1768 + .reset = tegra30_periph_clk_reset, 1769 + }; 1770 + 1771 + /* Output clock ops */ 1772 + 1773 + static DEFINE_SPINLOCK(clk_out_lock); 1774 + 1775 + static void tegra30_clk_out_init(struct clk *c) 1776 + { 1777 + const struct clk_mux_sel *mux = 0; 1778 + const struct clk_mux_sel *sel; 1779 + u32 val = pmc_readl(c->reg); 1780 + 1781 + c->state = (val & (0x1 << c->u.periph.clk_num)) ? ON : OFF; 1782 + c->mul = 1; 1783 + c->div = 1; 1784 + 1785 + for (sel = c->inputs; sel->input != NULL; sel++) { 1786 + if (((val & periph_clk_source_mask(c)) >> 1787 + periph_clk_source_shift(c)) == sel->value) 1788 + mux = sel; 1789 + } 1790 + BUG_ON(!mux); 1791 + c->parent = mux->input; 1792 + } 1793 + 1794 + static int tegra30_clk_out_enable(struct clk *c) 1795 + { 1796 + u32 val; 1797 + unsigned long flags; 1798 + 1799 + pr_debug("%s on clock %s\n", __func__, c->name); 1800 + 1801 + spin_lock_irqsave(&clk_out_lock, flags); 1802 + val = pmc_readl(c->reg); 1803 + val |= (0x1 << c->u.periph.clk_num); 1804 + pmc_writel(val, c->reg); 1805 + spin_unlock_irqrestore(&clk_out_lock, flags); 1806 + 1807 + return 0; 1808 + } 1809 + 1810 + static void tegra30_clk_out_disable(struct clk *c) 1811 + { 1812 + u32 val; 1813 + unsigned long flags; 1814 + 1815 + pr_debug("%s on clock %s\n", __func__, c->name); 1816 + 1817 + spin_lock_irqsave(&clk_out_lock, flags); 1818 + val = pmc_readl(c->reg); 1819 + val &= ~(0x1 << c->u.periph.clk_num); 1820 + pmc_writel(val, c->reg); 1821 + spin_unlock_irqrestore(&clk_out_lock, flags); 1822 + } 1823 + 1824 + static int tegra30_clk_out_set_parent(struct clk *c, struct clk *p) 1825 + { 1826 + u32 val; 1827 + unsigned long flags; 1828 + const struct clk_mux_sel *sel; 1829 + 1830 + pr_debug("%s: %s %s\n", __func__, c->name, p->name); 1831 + 1832 + for (sel = c->inputs; sel->input != NULL; sel++) { 1833 + if (sel->input == p) { 1834 + if (c->refcnt) 1835 + clk_enable(p); 1836 + 1837 + spin_lock_irqsave(&clk_out_lock, flags); 1838 + val = pmc_readl(c->reg); 1839 + val &= ~periph_clk_source_mask(c); 1840 + val |= (sel->value << periph_clk_source_shift(c)); 1841 + pmc_writel(val, c->reg); 1842 + spin_unlock_irqrestore(&clk_out_lock, flags); 1843 + 1844 + if (c->refcnt && c->parent) 1845 + clk_disable(c->parent); 1846 + 1847 + clk_reparent(c, p); 1848 + return 0; 1849 + } 1850 + } 1851 + return -EINVAL; 1852 + } 1853 + 1854 + static struct clk_ops tegra_clk_out_ops = { 1855 + .init = &tegra30_clk_out_init, 1856 + .enable = &tegra30_clk_out_enable, 1857 + .disable = &tegra30_clk_out_disable, 1858 + .set_parent = &tegra30_clk_out_set_parent, 1859 + }; 1860 + 1861 + 1862 + /* Clock doubler ops */ 1863 + static void tegra30_clk_double_init(struct clk *c) 1864 + { 1865 + u32 val = clk_readl(c->reg); 1866 + c->mul = val & (0x1 << c->reg_shift) ? 1 : 2; 1867 + c->div = 1; 1868 + c->state = ON; 1869 + if (!(clk_readl(PERIPH_CLK_TO_ENB_REG(c)) & PERIPH_CLK_TO_BIT(c))) 1870 + c->state = OFF; 1871 + }; 1872 + 1873 + static int tegra30_clk_double_set_rate(struct clk *c, unsigned long rate) 1874 + { 1875 + u32 val; 1876 + unsigned long parent_rate = clk_get_rate(c->parent); 1877 + if (rate == parent_rate) { 1878 + val = clk_readl(c->reg) | (0x1 << c->reg_shift); 1879 + clk_writel(val, c->reg); 1880 + c->mul = 1; 1881 + c->div = 1; 1882 + return 0; 1883 + } else if (rate == 2 * parent_rate) { 1884 + val = clk_readl(c->reg) & (~(0x1 << c->reg_shift)); 1885 + clk_writel(val, c->reg); 1886 + c->mul = 2; 1887 + c->div = 1; 1888 + return 0; 1889 + } 1890 + return -EINVAL; 1891 + } 1892 + 1893 + static struct clk_ops tegra_clk_double_ops = { 1894 + .init = &tegra30_clk_double_init, 1895 + .enable = &tegra30_periph_clk_enable, 1896 + .disable = &tegra30_periph_clk_disable, 1897 + .set_rate = &tegra30_clk_double_set_rate, 1898 + }; 1899 + 1900 + /* Audio sync clock ops */ 1901 + static int tegra30_sync_source_set_rate(struct clk *c, unsigned long rate) 1902 + { 1903 + c->rate = rate; 1904 + return 0; 1905 + } 1906 + 1907 + static struct clk_ops tegra_sync_source_ops = { 1908 + .set_rate = &tegra30_sync_source_set_rate, 1909 + }; 1910 + 1911 + static void tegra30_audio_sync_clk_init(struct clk *c) 1912 + { 1913 + int source; 1914 + const struct clk_mux_sel *sel; 1915 + u32 val = clk_readl(c->reg); 1916 + c->state = (val & AUDIO_SYNC_DISABLE_BIT) ? OFF : ON; 1917 + source = val & AUDIO_SYNC_SOURCE_MASK; 1918 + for (sel = c->inputs; sel->input != NULL; sel++) 1919 + if (sel->value == source) 1920 + break; 1921 + BUG_ON(sel->input == NULL); 1922 + c->parent = sel->input; 1923 + } 1924 + 1925 + static int tegra30_audio_sync_clk_enable(struct clk *c) 1926 + { 1927 + u32 val = clk_readl(c->reg); 1928 + clk_writel((val & (~AUDIO_SYNC_DISABLE_BIT)), c->reg); 1929 + return 0; 1930 + } 1931 + 1932 + static void tegra30_audio_sync_clk_disable(struct clk *c) 1933 + { 1934 + u32 val = clk_readl(c->reg); 1935 + clk_writel((val | AUDIO_SYNC_DISABLE_BIT), c->reg); 1936 + } 1937 + 1938 + static int tegra30_audio_sync_clk_set_parent(struct clk *c, struct clk *p) 1939 + { 1940 + u32 val; 1941 + const struct clk_mux_sel *sel; 1942 + for (sel = c->inputs; sel->input != NULL; sel++) { 1943 + if (sel->input == p) { 1944 + val = clk_readl(c->reg); 1945 + val &= ~AUDIO_SYNC_SOURCE_MASK; 1946 + val |= sel->value; 1947 + 1948 + if (c->refcnt) 1949 + clk_enable(p); 1950 + 1951 + clk_writel(val, c->reg); 1952 + 1953 + if (c->refcnt && c->parent) 1954 + clk_disable(c->parent); 1955 + 1956 + clk_reparent(c, p); 1957 + return 0; 1958 + } 1959 + } 1960 + 1961 + return -EINVAL; 1962 + } 1963 + 1964 + static struct clk_ops tegra_audio_sync_clk_ops = { 1965 + .init = tegra30_audio_sync_clk_init, 1966 + .enable = tegra30_audio_sync_clk_enable, 1967 + .disable = tegra30_audio_sync_clk_disable, 1968 + .set_parent = tegra30_audio_sync_clk_set_parent, 1969 + }; 1970 + 1971 + /* cml0 (pcie), and cml1 (sata) clock ops */ 1972 + static void tegra30_cml_clk_init(struct clk *c) 1973 + { 1974 + u32 val = clk_readl(c->reg); 1975 + c->state = val & (0x1 << c->u.periph.clk_num) ? ON : OFF; 1976 + } 1977 + 1978 + static int tegra30_cml_clk_enable(struct clk *c) 1979 + { 1980 + u32 val = clk_readl(c->reg); 1981 + val |= (0x1 << c->u.periph.clk_num); 1982 + clk_writel(val, c->reg); 1983 + return 0; 1984 + } 1985 + 1986 + static void tegra30_cml_clk_disable(struct clk *c) 1987 + { 1988 + u32 val = clk_readl(c->reg); 1989 + val &= ~(0x1 << c->u.periph.clk_num); 1990 + clk_writel(val, c->reg); 1991 + } 1992 + 1993 + static struct clk_ops tegra_cml_clk_ops = { 1994 + .init = &tegra30_cml_clk_init, 1995 + .enable = &tegra30_cml_clk_enable, 1996 + .disable = &tegra30_cml_clk_disable, 1997 + }; 1998 + 1999 + /* Clock definitions */ 2000 + static struct clk tegra_clk_32k = { 2001 + .name = "clk_32k", 2002 + .rate = 32768, 2003 + .ops = NULL, 2004 + .max_rate = 32768, 2005 + }; 2006 + 2007 + static struct clk tegra_clk_m = { 2008 + .name = "clk_m", 2009 + .flags = ENABLE_ON_INIT, 2010 + .ops = &tegra_clk_m_ops, 2011 + .reg = 0x1fc, 2012 + .reg_shift = 28, 2013 + .max_rate = 48000000, 2014 + }; 2015 + 2016 + static struct clk tegra_clk_m_div2 = { 2017 + .name = "clk_m_div2", 2018 + .ops = &tegra_clk_m_div_ops, 2019 + .parent = &tegra_clk_m, 2020 + .mul = 1, 2021 + .div = 2, 2022 + .state = ON, 2023 + .max_rate = 24000000, 2024 + }; 2025 + 2026 + static struct clk tegra_clk_m_div4 = { 2027 + .name = "clk_m_div4", 2028 + .ops = &tegra_clk_m_div_ops, 2029 + .parent = &tegra_clk_m, 2030 + .mul = 1, 2031 + .div = 4, 2032 + .state = ON, 2033 + .max_rate = 12000000, 2034 + }; 2035 + 2036 + static struct clk tegra_pll_ref = { 2037 + .name = "pll_ref", 2038 + .flags = ENABLE_ON_INIT, 2039 + .ops = &tegra_pll_ref_ops, 2040 + .parent = &tegra_clk_m, 2041 + .max_rate = 26000000, 2042 + }; 2043 + 2044 + static struct clk_pll_freq_table tegra_pll_c_freq_table[] = { 2045 + { 12000000, 1040000000, 520, 6, 1, 8}, 2046 + { 13000000, 1040000000, 480, 6, 1, 8}, 2047 + { 16800000, 1040000000, 495, 8, 1, 8}, /* actual: 1039.5 MHz */ 2048 + { 19200000, 1040000000, 325, 6, 1, 6}, 2049 + { 26000000, 1040000000, 520, 13, 1, 8}, 2050 + 2051 + { 12000000, 832000000, 416, 6, 1, 8}, 2052 + { 13000000, 832000000, 832, 13, 1, 8}, 2053 + { 16800000, 832000000, 396, 8, 1, 8}, /* actual: 831.6 MHz */ 2054 + { 19200000, 832000000, 260, 6, 1, 8}, 2055 + { 26000000, 832000000, 416, 13, 1, 8}, 2056 + 2057 + { 12000000, 624000000, 624, 12, 1, 8}, 2058 + { 13000000, 624000000, 624, 13, 1, 8}, 2059 + { 16800000, 600000000, 520, 14, 1, 8}, 2060 + { 19200000, 624000000, 520, 16, 1, 8}, 2061 + { 26000000, 624000000, 624, 26, 1, 8}, 2062 + 2063 + { 12000000, 600000000, 600, 12, 1, 8}, 2064 + { 13000000, 600000000, 600, 13, 1, 8}, 2065 + { 16800000, 600000000, 500, 14, 1, 8}, 2066 + { 19200000, 600000000, 375, 12, 1, 6}, 2067 + { 26000000, 600000000, 600, 26, 1, 8}, 2068 + 2069 + { 12000000, 520000000, 520, 12, 1, 8}, 2070 + { 13000000, 520000000, 520, 13, 1, 8}, 2071 + { 16800000, 520000000, 495, 16, 1, 8}, /* actual: 519.75 MHz */ 2072 + { 19200000, 520000000, 325, 12, 1, 6}, 2073 + { 26000000, 520000000, 520, 26, 1, 8}, 2074 + 2075 + { 12000000, 416000000, 416, 12, 1, 8}, 2076 + { 13000000, 416000000, 416, 13, 1, 8}, 2077 + { 16800000, 416000000, 396, 16, 1, 8}, /* actual: 415.8 MHz */ 2078 + { 19200000, 416000000, 260, 12, 1, 6}, 2079 + { 26000000, 416000000, 416, 26, 1, 8}, 2080 + { 0, 0, 0, 0, 0, 0 }, 2081 + }; 2082 + 2083 + static struct clk tegra_pll_c = { 2084 + .name = "pll_c", 2085 + .flags = PLL_HAS_CPCON, 2086 + .ops = &tegra_pll_ops, 2087 + .reg = 0x80, 2088 + .parent = &tegra_pll_ref, 2089 + .max_rate = 1400000000, 2090 + .u.pll = { 2091 + .input_min = 2000000, 2092 + .input_max = 31000000, 2093 + .cf_min = 1000000, 2094 + .cf_max = 6000000, 2095 + .vco_min = 20000000, 2096 + .vco_max = 1400000000, 2097 + .freq_table = tegra_pll_c_freq_table, 2098 + .lock_delay = 300, 2099 + }, 2100 + }; 2101 + 2102 + static struct clk tegra_pll_c_out1 = { 2103 + .name = "pll_c_out1", 2104 + .ops = &tegra_pll_div_ops, 2105 + .flags = DIV_U71, 2106 + .parent = &tegra_pll_c, 2107 + .reg = 0x84, 2108 + .reg_shift = 0, 2109 + .max_rate = 700000000, 2110 + }; 2111 + 2112 + static struct clk_pll_freq_table tegra_pll_m_freq_table[] = { 2113 + { 12000000, 666000000, 666, 12, 1, 8}, 2114 + { 13000000, 666000000, 666, 13, 1, 8}, 2115 + { 16800000, 666000000, 555, 14, 1, 8}, 2116 + { 19200000, 666000000, 555, 16, 1, 8}, 2117 + { 26000000, 666000000, 666, 26, 1, 8}, 2118 + { 12000000, 600000000, 600, 12, 1, 8}, 2119 + { 13000000, 600000000, 600, 13, 1, 8}, 2120 + { 16800000, 600000000, 500, 14, 1, 8}, 2121 + { 19200000, 600000000, 375, 12, 1, 6}, 2122 + { 26000000, 600000000, 600, 26, 1, 8}, 2123 + { 0, 0, 0, 0, 0, 0 }, 2124 + }; 2125 + 2126 + static struct clk tegra_pll_m = { 2127 + .name = "pll_m", 2128 + .flags = PLL_HAS_CPCON | PLLM, 2129 + .ops = &tegra_pll_ops, 2130 + .reg = 0x90, 2131 + .parent = &tegra_pll_ref, 2132 + .max_rate = 800000000, 2133 + .u.pll = { 2134 + .input_min = 2000000, 2135 + .input_max = 31000000, 2136 + .cf_min = 1000000, 2137 + .cf_max = 6000000, 2138 + .vco_min = 20000000, 2139 + .vco_max = 1200000000, 2140 + .freq_table = tegra_pll_m_freq_table, 2141 + .lock_delay = 300, 2142 + }, 2143 + }; 2144 + 2145 + static struct clk tegra_pll_m_out1 = { 2146 + .name = "pll_m_out1", 2147 + .ops = &tegra_pll_div_ops, 2148 + .flags = DIV_U71, 2149 + .parent = &tegra_pll_m, 2150 + .reg = 0x94, 2151 + .reg_shift = 0, 2152 + .max_rate = 600000000, 2153 + }; 2154 + 2155 + static struct clk_pll_freq_table tegra_pll_p_freq_table[] = { 2156 + { 12000000, 216000000, 432, 12, 2, 8}, 2157 + { 13000000, 216000000, 432, 13, 2, 8}, 2158 + { 16800000, 216000000, 360, 14, 2, 8}, 2159 + { 19200000, 216000000, 360, 16, 2, 8}, 2160 + { 26000000, 216000000, 432, 26, 2, 8}, 2161 + { 0, 0, 0, 0, 0, 0 }, 2162 + }; 2163 + 2164 + static struct clk tegra_pll_p = { 2165 + .name = "pll_p", 2166 + .flags = ENABLE_ON_INIT | PLL_FIXED | PLL_HAS_CPCON, 2167 + .ops = &tegra_pll_ops, 2168 + .reg = 0xa0, 2169 + .parent = &tegra_pll_ref, 2170 + .max_rate = 432000000, 2171 + .u.pll = { 2172 + .input_min = 2000000, 2173 + .input_max = 31000000, 2174 + .cf_min = 1000000, 2175 + .cf_max = 6000000, 2176 + .vco_min = 20000000, 2177 + .vco_max = 1400000000, 2178 + .freq_table = tegra_pll_p_freq_table, 2179 + .lock_delay = 300, 2180 + .fixed_rate = 408000000, 2181 + }, 2182 + }; 2183 + 2184 + static struct clk tegra_pll_p_out1 = { 2185 + .name = "pll_p_out1", 2186 + .ops = &tegra_pll_div_ops, 2187 + .flags = ENABLE_ON_INIT | DIV_U71 | DIV_U71_FIXED, 2188 + .parent = &tegra_pll_p, 2189 + .reg = 0xa4, 2190 + .reg_shift = 0, 2191 + .max_rate = 432000000, 2192 + }; 2193 + 2194 + static struct clk tegra_pll_p_out2 = { 2195 + .name = "pll_p_out2", 2196 + .ops = &tegra_pll_div_ops, 2197 + .flags = ENABLE_ON_INIT | DIV_U71 | DIV_U71_FIXED, 2198 + .parent = &tegra_pll_p, 2199 + .reg = 0xa4, 2200 + .reg_shift = 16, 2201 + .max_rate = 432000000, 2202 + }; 2203 + 2204 + static struct clk tegra_pll_p_out3 = { 2205 + .name = "pll_p_out3", 2206 + .ops = &tegra_pll_div_ops, 2207 + .flags = ENABLE_ON_INIT | DIV_U71 | DIV_U71_FIXED, 2208 + .parent = &tegra_pll_p, 2209 + .reg = 0xa8, 2210 + .reg_shift = 0, 2211 + .max_rate = 432000000, 2212 + }; 2213 + 2214 + static struct clk tegra_pll_p_out4 = { 2215 + .name = "pll_p_out4", 2216 + .ops = &tegra_pll_div_ops, 2217 + .flags = ENABLE_ON_INIT | DIV_U71 | DIV_U71_FIXED, 2218 + .parent = &tegra_pll_p, 2219 + .reg = 0xa8, 2220 + .reg_shift = 16, 2221 + .max_rate = 432000000, 2222 + }; 2223 + 2224 + static struct clk_pll_freq_table tegra_pll_a_freq_table[] = { 2225 + { 9600000, 564480000, 294, 5, 1, 4}, 2226 + { 9600000, 552960000, 288, 5, 1, 4}, 2227 + { 9600000, 24000000, 5, 2, 1, 1}, 2228 + 2229 + { 28800000, 56448000, 49, 25, 1, 1}, 2230 + { 28800000, 73728000, 64, 25, 1, 1}, 2231 + { 28800000, 24000000, 5, 6, 1, 1}, 2232 + { 0, 0, 0, 0, 0, 0 }, 2233 + }; 2234 + 2235 + static struct clk tegra_pll_a = { 2236 + .name = "pll_a", 2237 + .flags = PLL_HAS_CPCON, 2238 + .ops = &tegra_pll_ops, 2239 + .reg = 0xb0, 2240 + .parent = &tegra_pll_p_out1, 2241 + .max_rate = 700000000, 2242 + .u.pll = { 2243 + .input_min = 2000000, 2244 + .input_max = 31000000, 2245 + .cf_min = 1000000, 2246 + .cf_max = 6000000, 2247 + .vco_min = 20000000, 2248 + .vco_max = 1400000000, 2249 + .freq_table = tegra_pll_a_freq_table, 2250 + .lock_delay = 300, 2251 + }, 2252 + }; 2253 + 2254 + static struct clk tegra_pll_a_out0 = { 2255 + .name = "pll_a_out0", 2256 + .ops = &tegra_pll_div_ops, 2257 + .flags = DIV_U71, 2258 + .parent = &tegra_pll_a, 2259 + .reg = 0xb4, 2260 + .reg_shift = 0, 2261 + .max_rate = 100000000, 2262 + }; 2263 + 2264 + static struct clk_pll_freq_table tegra_pll_d_freq_table[] = { 2265 + { 12000000, 216000000, 216, 12, 1, 4}, 2266 + { 13000000, 216000000, 216, 13, 1, 4}, 2267 + { 16800000, 216000000, 180, 14, 1, 4}, 2268 + { 19200000, 216000000, 180, 16, 1, 4}, 2269 + { 26000000, 216000000, 216, 26, 1, 4}, 2270 + 2271 + { 12000000, 594000000, 594, 12, 1, 8}, 2272 + { 13000000, 594000000, 594, 13, 1, 8}, 2273 + { 16800000, 594000000, 495, 14, 1, 8}, 2274 + { 19200000, 594000000, 495, 16, 1, 8}, 2275 + { 26000000, 594000000, 594, 26, 1, 8}, 2276 + 2277 + { 12000000, 1000000000, 1000, 12, 1, 12}, 2278 + { 13000000, 1000000000, 1000, 13, 1, 12}, 2279 + { 19200000, 1000000000, 625, 12, 1, 8}, 2280 + { 26000000, 1000000000, 1000, 26, 1, 12}, 2281 + 2282 + { 0, 0, 0, 0, 0, 0 }, 2283 + }; 2284 + 2285 + static struct clk tegra_pll_d = { 2286 + .name = "pll_d", 2287 + .flags = PLL_HAS_CPCON | PLLD, 2288 + .ops = &tegra_plld_ops, 2289 + .reg = 0xd0, 2290 + .parent = &tegra_pll_ref, 2291 + .max_rate = 1000000000, 2292 + .u.pll = { 2293 + .input_min = 2000000, 2294 + .input_max = 40000000, 2295 + .cf_min = 1000000, 2296 + .cf_max = 6000000, 2297 + .vco_min = 40000000, 2298 + .vco_max = 1000000000, 2299 + .freq_table = tegra_pll_d_freq_table, 2300 + .lock_delay = 1000, 2301 + }, 2302 + }; 2303 + 2304 + static struct clk tegra_pll_d_out0 = { 2305 + .name = "pll_d_out0", 2306 + .ops = &tegra_pll_div_ops, 2307 + .flags = DIV_2 | PLLD, 2308 + .parent = &tegra_pll_d, 2309 + .max_rate = 500000000, 2310 + }; 2311 + 2312 + static struct clk tegra_pll_d2 = { 2313 + .name = "pll_d2", 2314 + .flags = PLL_HAS_CPCON | PLL_ALT_MISC_REG | PLLD, 2315 + .ops = &tegra_plld_ops, 2316 + .reg = 0x4b8, 2317 + .parent = &tegra_pll_ref, 2318 + .max_rate = 1000000000, 2319 + .u.pll = { 2320 + .input_min = 2000000, 2321 + .input_max = 40000000, 2322 + .cf_min = 1000000, 2323 + .cf_max = 6000000, 2324 + .vco_min = 40000000, 2325 + .vco_max = 1000000000, 2326 + .freq_table = tegra_pll_d_freq_table, 2327 + .lock_delay = 1000, 2328 + }, 2329 + }; 2330 + 2331 + static struct clk tegra_pll_d2_out0 = { 2332 + .name = "pll_d2_out0", 2333 + .ops = &tegra_pll_div_ops, 2334 + .flags = DIV_2 | PLLD, 2335 + .parent = &tegra_pll_d2, 2336 + .max_rate = 500000000, 2337 + }; 2338 + 2339 + static struct clk_pll_freq_table tegra_pll_u_freq_table[] = { 2340 + { 12000000, 480000000, 960, 12, 2, 12}, 2341 + { 13000000, 480000000, 960, 13, 2, 12}, 2342 + { 16800000, 480000000, 400, 7, 2, 5}, 2343 + { 19200000, 480000000, 200, 4, 2, 3}, 2344 + { 26000000, 480000000, 960, 26, 2, 12}, 2345 + { 0, 0, 0, 0, 0, 0 }, 2346 + }; 2347 + 2348 + static struct clk tegra_pll_u = { 2349 + .name = "pll_u", 2350 + .flags = PLL_HAS_CPCON | PLLU, 2351 + .ops = &tegra_pll_ops, 2352 + .reg = 0xc0, 2353 + .parent = &tegra_pll_ref, 2354 + .max_rate = 480000000, 2355 + .u.pll = { 2356 + .input_min = 2000000, 2357 + .input_max = 40000000, 2358 + .cf_min = 1000000, 2359 + .cf_max = 6000000, 2360 + .vco_min = 480000000, 2361 + .vco_max = 960000000, 2362 + .freq_table = tegra_pll_u_freq_table, 2363 + .lock_delay = 1000, 2364 + }, 2365 + }; 2366 + 2367 + static struct clk_pll_freq_table tegra_pll_x_freq_table[] = { 2368 + /* 1.7 GHz */ 2369 + { 12000000, 1700000000, 850, 6, 1, 8}, 2370 + { 13000000, 1700000000, 915, 7, 1, 8}, /* actual: 1699.2 MHz */ 2371 + { 16800000, 1700000000, 708, 7, 1, 8}, /* actual: 1699.2 MHz */ 2372 + { 19200000, 1700000000, 885, 10, 1, 8}, /* actual: 1699.2 MHz */ 2373 + { 26000000, 1700000000, 850, 13, 1, 8}, 2374 + 2375 + /* 1.6 GHz */ 2376 + { 12000000, 1600000000, 800, 6, 1, 8}, 2377 + { 13000000, 1600000000, 738, 6, 1, 8}, /* actual: 1599.0 MHz */ 2378 + { 16800000, 1600000000, 857, 9, 1, 8}, /* actual: 1599.7 MHz */ 2379 + { 19200000, 1600000000, 500, 6, 1, 8}, 2380 + { 26000000, 1600000000, 800, 13, 1, 8}, 2381 + 2382 + /* 1.5 GHz */ 2383 + { 12000000, 1500000000, 750, 6, 1, 8}, 2384 + { 13000000, 1500000000, 923, 8, 1, 8}, /* actual: 1499.8 MHz */ 2385 + { 16800000, 1500000000, 625, 7, 1, 8}, 2386 + { 19200000, 1500000000, 625, 8, 1, 8}, 2387 + { 26000000, 1500000000, 750, 13, 1, 8}, 2388 + 2389 + /* 1.4 GHz */ 2390 + { 12000000, 1400000000, 700, 6, 1, 8}, 2391 + { 13000000, 1400000000, 969, 9, 1, 8}, /* actual: 1399.7 MHz */ 2392 + { 16800000, 1400000000, 1000, 12, 1, 8}, 2393 + { 19200000, 1400000000, 875, 12, 1, 8}, 2394 + { 26000000, 1400000000, 700, 13, 1, 8}, 2395 + 2396 + /* 1.3 GHz */ 2397 + { 12000000, 1300000000, 975, 9, 1, 8}, 2398 + { 13000000, 1300000000, 1000, 10, 1, 8}, 2399 + { 16800000, 1300000000, 928, 12, 1, 8}, /* actual: 1299.2 MHz */ 2400 + { 19200000, 1300000000, 812, 12, 1, 8}, /* actual: 1299.2 MHz */ 2401 + { 26000000, 1300000000, 650, 13, 1, 8}, 2402 + 2403 + /* 1.2 GHz */ 2404 + { 12000000, 1200000000, 1000, 10, 1, 8}, 2405 + { 13000000, 1200000000, 923, 10, 1, 8}, /* actual: 1199.9 MHz */ 2406 + { 16800000, 1200000000, 1000, 14, 1, 8}, 2407 + { 19200000, 1200000000, 1000, 16, 1, 8}, 2408 + { 26000000, 1200000000, 600, 13, 1, 8}, 2409 + 2410 + /* 1.1 GHz */ 2411 + { 12000000, 1100000000, 825, 9, 1, 8}, 2412 + { 13000000, 1100000000, 846, 10, 1, 8}, /* actual: 1099.8 MHz */ 2413 + { 16800000, 1100000000, 982, 15, 1, 8}, /* actual: 1099.8 MHz */ 2414 + { 19200000, 1100000000, 859, 15, 1, 8}, /* actual: 1099.5 MHz */ 2415 + { 26000000, 1100000000, 550, 13, 1, 8}, 2416 + 2417 + /* 1 GHz */ 2418 + { 12000000, 1000000000, 1000, 12, 1, 8}, 2419 + { 13000000, 1000000000, 1000, 13, 1, 8}, 2420 + { 16800000, 1000000000, 833, 14, 1, 8}, /* actual: 999.6 MHz */ 2421 + { 19200000, 1000000000, 625, 12, 1, 8}, 2422 + { 26000000, 1000000000, 1000, 26, 1, 8}, 2423 + 2424 + { 0, 0, 0, 0, 0, 0 }, 2425 + }; 2426 + 2427 + static struct clk tegra_pll_x = { 2428 + .name = "pll_x", 2429 + .flags = PLL_HAS_CPCON | PLL_ALT_MISC_REG | PLLX, 2430 + .ops = &tegra_pll_ops, 2431 + .reg = 0xe0, 2432 + .parent = &tegra_pll_ref, 2433 + .max_rate = 1700000000, 2434 + .u.pll = { 2435 + .input_min = 2000000, 2436 + .input_max = 31000000, 2437 + .cf_min = 1000000, 2438 + .cf_max = 6000000, 2439 + .vco_min = 20000000, 2440 + .vco_max = 1700000000, 2441 + .freq_table = tegra_pll_x_freq_table, 2442 + .lock_delay = 300, 2443 + }, 2444 + }; 2445 + 2446 + static struct clk tegra_pll_x_out0 = { 2447 + .name = "pll_x_out0", 2448 + .ops = &tegra_pll_div_ops, 2449 + .flags = DIV_2 | PLLX, 2450 + .parent = &tegra_pll_x, 2451 + .max_rate = 850000000, 2452 + }; 2453 + 2454 + 2455 + static struct clk_pll_freq_table tegra_pll_e_freq_table[] = { 2456 + /* PLLE special case: use cpcon field to store cml divider value */ 2457 + { 12000000, 100000000, 150, 1, 18, 11}, 2458 + { 216000000, 100000000, 200, 18, 24, 13}, 2459 + { 0, 0, 0, 0, 0, 0 }, 2460 + }; 2461 + 2462 + static struct clk tegra_pll_e = { 2463 + .name = "pll_e", 2464 + .flags = PLL_ALT_MISC_REG, 2465 + .ops = &tegra_plle_ops, 2466 + .reg = 0xe8, 2467 + .max_rate = 100000000, 2468 + .u.pll = { 2469 + .input_min = 12000000, 2470 + .input_max = 216000000, 2471 + .cf_min = 12000000, 2472 + .cf_max = 12000000, 2473 + .vco_min = 1200000000, 2474 + .vco_max = 2400000000U, 2475 + .freq_table = tegra_pll_e_freq_table, 2476 + .lock_delay = 300, 2477 + .fixed_rate = 100000000, 2478 + }, 2479 + }; 2480 + 2481 + static struct clk tegra_cml0_clk = { 2482 + .name = "cml0", 2483 + .parent = &tegra_pll_e, 2484 + .ops = &tegra_cml_clk_ops, 2485 + .reg = PLLE_AUX, 2486 + .max_rate = 100000000, 2487 + .u.periph = { 2488 + .clk_num = 0, 2489 + }, 2490 + }; 2491 + 2492 + static struct clk tegra_cml1_clk = { 2493 + .name = "cml1", 2494 + .parent = &tegra_pll_e, 2495 + .ops = &tegra_cml_clk_ops, 2496 + .reg = PLLE_AUX, 2497 + .max_rate = 100000000, 2498 + .u.periph = { 2499 + .clk_num = 1, 2500 + }, 2501 + }; 2502 + 2503 + static struct clk tegra_pciex_clk = { 2504 + .name = "pciex", 2505 + .parent = &tegra_pll_e, 2506 + .ops = &tegra_pciex_clk_ops, 2507 + .max_rate = 100000000, 2508 + .u.periph = { 2509 + .clk_num = 74, 2510 + }, 2511 + }; 2512 + 2513 + /* Audio sync clocks */ 2514 + #define SYNC_SOURCE(_id) \ 2515 + { \ 2516 + .name = #_id "_sync", \ 2517 + .rate = 24000000, \ 2518 + .max_rate = 24000000, \ 2519 + .ops = &tegra_sync_source_ops \ 2520 + } 2521 + static struct clk tegra_sync_source_list[] = { 2522 + SYNC_SOURCE(spdif_in), 2523 + SYNC_SOURCE(i2s0), 2524 + SYNC_SOURCE(i2s1), 2525 + SYNC_SOURCE(i2s2), 2526 + SYNC_SOURCE(i2s3), 2527 + SYNC_SOURCE(i2s4), 2528 + SYNC_SOURCE(vimclk), 2529 + }; 2530 + 2531 + static struct clk_mux_sel mux_audio_sync_clk[] = { 2532 + { .input = &tegra_sync_source_list[0], .value = 0}, 2533 + { .input = &tegra_sync_source_list[1], .value = 1}, 2534 + { .input = &tegra_sync_source_list[2], .value = 2}, 2535 + { .input = &tegra_sync_source_list[3], .value = 3}, 2536 + { .input = &tegra_sync_source_list[4], .value = 4}, 2537 + { .input = &tegra_sync_source_list[5], .value = 5}, 2538 + { .input = &tegra_pll_a_out0, .value = 6}, 2539 + { .input = &tegra_sync_source_list[6], .value = 7}, 2540 + { 0, 0 } 2541 + }; 2542 + 2543 + #define AUDIO_SYNC_CLK(_id, _index) \ 2544 + { \ 2545 + .name = #_id, \ 2546 + .inputs = mux_audio_sync_clk, \ 2547 + .reg = 0x4A0 + (_index) * 4, \ 2548 + .max_rate = 24000000, \ 2549 + .ops = &tegra_audio_sync_clk_ops \ 2550 + } 2551 + static struct clk tegra_clk_audio_list[] = { 2552 + AUDIO_SYNC_CLK(audio0, 0), 2553 + AUDIO_SYNC_CLK(audio1, 1), 2554 + AUDIO_SYNC_CLK(audio2, 2), 2555 + AUDIO_SYNC_CLK(audio3, 3), 2556 + AUDIO_SYNC_CLK(audio4, 4), 2557 + AUDIO_SYNC_CLK(audio, 5), /* SPDIF */ 2558 + }; 2559 + 2560 + #define AUDIO_SYNC_2X_CLK(_id, _index) \ 2561 + { \ 2562 + .name = #_id "_2x", \ 2563 + .flags = PERIPH_NO_RESET, \ 2564 + .max_rate = 48000000, \ 2565 + .ops = &tegra_clk_double_ops, \ 2566 + .reg = 0x49C, \ 2567 + .reg_shift = 24 + (_index), \ 2568 + .parent = &tegra_clk_audio_list[(_index)], \ 2569 + .u.periph = { \ 2570 + .clk_num = 113 + (_index), \ 2571 + }, \ 2572 + } 2573 + static struct clk tegra_clk_audio_2x_list[] = { 2574 + AUDIO_SYNC_2X_CLK(audio0, 0), 2575 + AUDIO_SYNC_2X_CLK(audio1, 1), 2576 + AUDIO_SYNC_2X_CLK(audio2, 2), 2577 + AUDIO_SYNC_2X_CLK(audio3, 3), 2578 + AUDIO_SYNC_2X_CLK(audio4, 4), 2579 + AUDIO_SYNC_2X_CLK(audio, 5), /* SPDIF */ 2580 + }; 2581 + 2582 + #define MUX_I2S_SPDIF(_id, _index) \ 2583 + static struct clk_mux_sel mux_pllaout0_##_id##_2x_pllp_clkm[] = { \ 2584 + {.input = &tegra_pll_a_out0, .value = 0}, \ 2585 + {.input = &tegra_clk_audio_2x_list[(_index)], .value = 1}, \ 2586 + {.input = &tegra_pll_p, .value = 2}, \ 2587 + {.input = &tegra_clk_m, .value = 3}, \ 2588 + { 0, 0}, \ 2589 + } 2590 + MUX_I2S_SPDIF(audio0, 0); 2591 + MUX_I2S_SPDIF(audio1, 1); 2592 + MUX_I2S_SPDIF(audio2, 2); 2593 + MUX_I2S_SPDIF(audio3, 3); 2594 + MUX_I2S_SPDIF(audio4, 4); 2595 + MUX_I2S_SPDIF(audio, 5); /* SPDIF */ 2596 + 2597 + /* External clock outputs (through PMC) */ 2598 + #define MUX_EXTERN_OUT(_id) \ 2599 + static struct clk_mux_sel mux_clkm_clkm2_clkm4_extern##_id[] = { \ 2600 + {.input = &tegra_clk_m, .value = 0}, \ 2601 + {.input = &tegra_clk_m_div2, .value = 1}, \ 2602 + {.input = &tegra_clk_m_div4, .value = 2}, \ 2603 + {.input = NULL, .value = 3}, /* placeholder */ \ 2604 + { 0, 0}, \ 2605 + } 2606 + MUX_EXTERN_OUT(1); 2607 + MUX_EXTERN_OUT(2); 2608 + MUX_EXTERN_OUT(3); 2609 + 2610 + static struct clk_mux_sel *mux_extern_out_list[] = { 2611 + mux_clkm_clkm2_clkm4_extern1, 2612 + mux_clkm_clkm2_clkm4_extern2, 2613 + mux_clkm_clkm2_clkm4_extern3, 2614 + }; 2615 + 2616 + #define CLK_OUT_CLK(_id) \ 2617 + { \ 2618 + .name = "clk_out_" #_id, \ 2619 + .lookup = { \ 2620 + .dev_id = "clk_out_" #_id, \ 2621 + .con_id = "extern" #_id, \ 2622 + }, \ 2623 + .ops = &tegra_clk_out_ops, \ 2624 + .reg = 0x1a8, \ 2625 + .inputs = mux_clkm_clkm2_clkm4_extern##_id, \ 2626 + .flags = MUX_CLK_OUT, \ 2627 + .max_rate = 216000000, \ 2628 + .u.periph = { \ 2629 + .clk_num = (_id - 1) * 8 + 2, \ 2630 + }, \ 2631 + } 2632 + static struct clk tegra_clk_out_list[] = { 2633 + CLK_OUT_CLK(1), 2634 + CLK_OUT_CLK(2), 2635 + CLK_OUT_CLK(3), 2636 + }; 2637 + 2638 + /* called after peripheral external clocks are initialized */ 2639 + static void init_clk_out_mux(void) 2640 + { 2641 + int i; 2642 + struct clk *c; 2643 + 2644 + /* output clock con_id is the name of peripheral 2645 + external clock connected to input 3 of the output mux */ 2646 + for (i = 0; i < ARRAY_SIZE(tegra_clk_out_list); i++) { 2647 + c = tegra_get_clock_by_name( 2648 + tegra_clk_out_list[i].lookup.con_id); 2649 + if (!c) 2650 + pr_err("%s: could not find clk %s\n", __func__, 2651 + tegra_clk_out_list[i].lookup.con_id); 2652 + mux_extern_out_list[i][3].input = c; 2653 + } 2654 + } 2655 + 2656 + /* Peripheral muxes */ 2657 + static struct clk_mux_sel mux_sclk[] = { 2658 + { .input = &tegra_clk_m, .value = 0}, 2659 + { .input = &tegra_pll_c_out1, .value = 1}, 2660 + { .input = &tegra_pll_p_out4, .value = 2}, 2661 + { .input = &tegra_pll_p_out3, .value = 3}, 2662 + { .input = &tegra_pll_p_out2, .value = 4}, 2663 + /* { .input = &tegra_clk_d, .value = 5}, - no use on tegra30 */ 2664 + { .input = &tegra_clk_32k, .value = 6}, 2665 + { .input = &tegra_pll_m_out1, .value = 7}, 2666 + { 0, 0}, 2667 + }; 2668 + 2669 + static struct clk tegra_clk_sclk = { 2670 + .name = "sclk", 2671 + .inputs = mux_sclk, 2672 + .reg = 0x28, 2673 + .ops = &tegra_super_ops, 2674 + .max_rate = 334000000, 2675 + .min_rate = 40000000, 2676 + }; 2677 + 2678 + static struct clk tegra_clk_blink = { 2679 + .name = "blink", 2680 + .parent = &tegra_clk_32k, 2681 + .reg = 0x40, 2682 + .ops = &tegra_blink_clk_ops, 2683 + .max_rate = 32768, 2684 + }; 2685 + 2686 + static struct clk_mux_sel mux_pllm_pllc_pllp_plla[] = { 2687 + { .input = &tegra_pll_m, .value = 0}, 2688 + { .input = &tegra_pll_c, .value = 1}, 2689 + { .input = &tegra_pll_p, .value = 2}, 2690 + { .input = &tegra_pll_a_out0, .value = 3}, 2691 + { 0, 0}, 2692 + }; 2693 + 2694 + static struct clk_mux_sel mux_pllp_pllc_pllm_clkm[] = { 2695 + { .input = &tegra_pll_p, .value = 0}, 2696 + { .input = &tegra_pll_c, .value = 1}, 2697 + { .input = &tegra_pll_m, .value = 2}, 2698 + { .input = &tegra_clk_m, .value = 3}, 2699 + { 0, 0}, 2700 + }; 2701 + 2702 + static struct clk_mux_sel mux_pllp_clkm[] = { 2703 + { .input = &tegra_pll_p, .value = 0}, 2704 + { .input = &tegra_clk_m, .value = 3}, 2705 + { 0, 0}, 2706 + }; 2707 + 2708 + static struct clk_mux_sel mux_pllp_plld_pllc_clkm[] = { 2709 + {.input = &tegra_pll_p, .value = 0}, 2710 + {.input = &tegra_pll_d_out0, .value = 1}, 2711 + {.input = &tegra_pll_c, .value = 2}, 2712 + {.input = &tegra_clk_m, .value = 3}, 2713 + { 0, 0}, 2714 + }; 2715 + 2716 + static struct clk_mux_sel mux_pllp_pllm_plld_plla_pllc_plld2_clkm[] = { 2717 + {.input = &tegra_pll_p, .value = 0}, 2718 + {.input = &tegra_pll_m, .value = 1}, 2719 + {.input = &tegra_pll_d_out0, .value = 2}, 2720 + {.input = &tegra_pll_a_out0, .value = 3}, 2721 + {.input = &tegra_pll_c, .value = 4}, 2722 + {.input = &tegra_pll_d2_out0, .value = 5}, 2723 + {.input = &tegra_clk_m, .value = 6}, 2724 + { 0, 0}, 2725 + }; 2726 + 2727 + static struct clk_mux_sel mux_plla_pllc_pllp_clkm[] = { 2728 + { .input = &tegra_pll_a_out0, .value = 0}, 2729 + /* { .input = &tegra_pll_c, .value = 1}, no use on tegra30 */ 2730 + { .input = &tegra_pll_p, .value = 2}, 2731 + { .input = &tegra_clk_m, .value = 3}, 2732 + { 0, 0}, 2733 + }; 2734 + 2735 + static struct clk_mux_sel mux_pllp_pllc_clk32_clkm[] = { 2736 + {.input = &tegra_pll_p, .value = 0}, 2737 + {.input = &tegra_pll_c, .value = 1}, 2738 + {.input = &tegra_clk_32k, .value = 2}, 2739 + {.input = &tegra_clk_m, .value = 3}, 2740 + { 0, 0}, 2741 + }; 2742 + 2743 + static struct clk_mux_sel mux_pllp_pllc_clkm_clk32[] = { 2744 + {.input = &tegra_pll_p, .value = 0}, 2745 + {.input = &tegra_pll_c, .value = 1}, 2746 + {.input = &tegra_clk_m, .value = 2}, 2747 + {.input = &tegra_clk_32k, .value = 3}, 2748 + { 0, 0}, 2749 + }; 2750 + 2751 + static struct clk_mux_sel mux_pllp_pllc_pllm[] = { 2752 + {.input = &tegra_pll_p, .value = 0}, 2753 + {.input = &tegra_pll_c, .value = 1}, 2754 + {.input = &tegra_pll_m, .value = 2}, 2755 + { 0, 0}, 2756 + }; 2757 + 2758 + static struct clk_mux_sel mux_clk_m[] = { 2759 + { .input = &tegra_clk_m, .value = 0}, 2760 + { 0, 0}, 2761 + }; 2762 + 2763 + static struct clk_mux_sel mux_pllp_out3[] = { 2764 + { .input = &tegra_pll_p_out3, .value = 0}, 2765 + { 0, 0}, 2766 + }; 2767 + 2768 + static struct clk_mux_sel mux_plld_out0[] = { 2769 + { .input = &tegra_pll_d_out0, .value = 0}, 2770 + { 0, 0}, 2771 + }; 2772 + 2773 + static struct clk_mux_sel mux_plld_out0_plld2_out0[] = { 2774 + { .input = &tegra_pll_d_out0, .value = 0}, 2775 + { .input = &tegra_pll_d2_out0, .value = 1}, 2776 + { 0, 0}, 2777 + }; 2778 + 2779 + static struct clk_mux_sel mux_clk_32k[] = { 2780 + { .input = &tegra_clk_32k, .value = 0}, 2781 + { 0, 0}, 2782 + }; 2783 + 2784 + static struct clk_mux_sel mux_plla_clk32_pllp_clkm_plle[] = { 2785 + { .input = &tegra_pll_a_out0, .value = 0}, 2786 + { .input = &tegra_clk_32k, .value = 1}, 2787 + { .input = &tegra_pll_p, .value = 2}, 2788 + { .input = &tegra_clk_m, .value = 3}, 2789 + { .input = &tegra_pll_e, .value = 4}, 2790 + { 0, 0}, 2791 + }; 2792 + 2793 + static struct clk_mux_sel mux_cclk_g[] = { 2794 + { .input = &tegra_clk_m, .value = 0}, 2795 + { .input = &tegra_pll_c, .value = 1}, 2796 + { .input = &tegra_clk_32k, .value = 2}, 2797 + { .input = &tegra_pll_m, .value = 3}, 2798 + { .input = &tegra_pll_p, .value = 4}, 2799 + { .input = &tegra_pll_p_out4, .value = 5}, 2800 + { .input = &tegra_pll_p_out3, .value = 6}, 2801 + { .input = &tegra_pll_x, .value = 8}, 2802 + { 0, 0}, 2803 + }; 2804 + 2805 + static struct clk tegra_clk_cclk_g = { 2806 + .name = "cclk_g", 2807 + .flags = DIV_U71 | DIV_U71_INT, 2808 + .inputs = mux_cclk_g, 2809 + .reg = 0x368, 2810 + .ops = &tegra_super_ops, 2811 + .max_rate = 1700000000, 2812 + }; 2813 + 2814 + static struct clk tegra30_clk_twd = { 2815 + .parent = &tegra_clk_cclk_g, 2816 + .name = "twd", 2817 + .ops = &tegra30_twd_ops, 2818 + .max_rate = 1400000000, /* Same as tegra_clk_cpu_cmplx.max_rate */ 2819 + .mul = 1, 2820 + .div = 2, 2821 + }; 2822 + 2823 + #define PERIPH_CLK(_name, _dev, _con, _clk_num, _reg, _max, _inputs, _flags) \ 2824 + { \ 2825 + .name = _name, \ 2826 + .lookup = { \ 2827 + .dev_id = _dev, \ 2828 + .con_id = _con, \ 2829 + }, \ 2830 + .ops = &tegra_periph_clk_ops, \ 2831 + .reg = _reg, \ 2832 + .inputs = _inputs, \ 2833 + .flags = _flags, \ 2834 + .max_rate = _max, \ 2835 + .u.periph = { \ 2836 + .clk_num = _clk_num, \ 2837 + }, \ 2838 + } 2839 + 2840 + #define PERIPH_CLK_EX(_name, _dev, _con, _clk_num, _reg, _max, _inputs, \ 2841 + _flags, _ops) \ 2842 + { \ 2843 + .name = _name, \ 2844 + .lookup = { \ 2845 + .dev_id = _dev, \ 2846 + .con_id = _con, \ 2847 + }, \ 2848 + .ops = _ops, \ 2849 + .reg = _reg, \ 2850 + .inputs = _inputs, \ 2851 + .flags = _flags, \ 2852 + .max_rate = _max, \ 2853 + .u.periph = { \ 2854 + .clk_num = _clk_num, \ 2855 + }, \ 2856 + } 2857 + 2858 + #define SHARED_CLK(_name, _dev, _con, _parent, _id, _div, _mode)\ 2859 + { \ 2860 + .name = _name, \ 2861 + .lookup = { \ 2862 + .dev_id = _dev, \ 2863 + .con_id = _con, \ 2864 + }, \ 2865 + .ops = &tegra_clk_shared_bus_ops, \ 2866 + .parent = _parent, \ 2867 + .u.shared_bus_user = { \ 2868 + .client_id = _id, \ 2869 + .client_div = _div, \ 2870 + .mode = _mode, \ 2871 + }, \ 2872 + } 2873 + struct clk tegra_list_clks[] = { 2874 + PERIPH_CLK("apbdma", "tegra-dma", NULL, 34, 0, 26000000, mux_clk_m, 0), 2875 + PERIPH_CLK("rtc", "rtc-tegra", NULL, 4, 0, 32768, mux_clk_32k, PERIPH_NO_RESET | PERIPH_ON_APB), 2876 + PERIPH_CLK("kbc", "tegra-kbc", NULL, 36, 0, 32768, mux_clk_32k, PERIPH_NO_RESET | PERIPH_ON_APB), 2877 + PERIPH_CLK("timer", "timer", NULL, 5, 0, 26000000, mux_clk_m, 0), 2878 + PERIPH_CLK("kfuse", "kfuse-tegra", NULL, 40, 0, 26000000, mux_clk_m, 0), 2879 + PERIPH_CLK("fuse", "fuse-tegra", "fuse", 39, 0, 26000000, mux_clk_m, PERIPH_ON_APB), 2880 + PERIPH_CLK("fuse_burn", "fuse-tegra", "fuse_burn", 39, 0, 26000000, mux_clk_m, PERIPH_ON_APB), 2881 + PERIPH_CLK("apbif", "tegra30-ahub", "apbif", 107, 0, 26000000, mux_clk_m, 0), 2882 + PERIPH_CLK("i2s0", "tegra30-i2s.0", NULL, 30, 0x1d8, 26000000, mux_pllaout0_audio0_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2883 + PERIPH_CLK("i2s1", "tegra30-i2s.1", NULL, 11, 0x100, 26000000, mux_pllaout0_audio1_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2884 + PERIPH_CLK("i2s2", "tegra30-i2s.2", NULL, 18, 0x104, 26000000, mux_pllaout0_audio2_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2885 + PERIPH_CLK("i2s3", "tegra30-i2s.3", NULL, 101, 0x3bc, 26000000, mux_pllaout0_audio3_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2886 + PERIPH_CLK("i2s4", "tegra30-i2s.4", NULL, 102, 0x3c0, 26000000, mux_pllaout0_audio4_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2887 + PERIPH_CLK("spdif_out", "tegra30-spdif", "spdif_out", 10, 0x108, 100000000, mux_pllaout0_audio_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2888 + PERIPH_CLK("spdif_in", "tegra30-spdif", "spdif_in", 10, 0x10c, 100000000, mux_pllp_pllc_pllm, MUX | DIV_U71 | PERIPH_ON_APB), 2889 + PERIPH_CLK("pwm", "pwm", NULL, 17, 0x110, 432000000, mux_pllp_pllc_clk32_clkm, MUX | MUX_PWM | DIV_U71 | PERIPH_ON_APB), 2890 + PERIPH_CLK("d_audio", "tegra30-ahub", "d_audio", 106, 0x3d0, 48000000, mux_plla_pllc_pllp_clkm, MUX | DIV_U71), 2891 + PERIPH_CLK("dam0", "tegra30-dam.0", NULL, 108, 0x3d8, 48000000, mux_plla_pllc_pllp_clkm, MUX | DIV_U71), 2892 + PERIPH_CLK("dam1", "tegra30-dam.1", NULL, 109, 0x3dc, 48000000, mux_plla_pllc_pllp_clkm, MUX | DIV_U71), 2893 + PERIPH_CLK("dam2", "tegra30-dam.2", NULL, 110, 0x3e0, 48000000, mux_plla_pllc_pllp_clkm, MUX | DIV_U71), 2894 + PERIPH_CLK("hda", "tegra30-hda", "hda", 125, 0x428, 108000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 2895 + PERIPH_CLK("hda2codec_2x", "tegra30-hda", "hda2codec", 111, 0x3e4, 48000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 2896 + PERIPH_CLK("hda2hdmi", "tegra30-hda", "hda2hdmi", 128, 0, 48000000, mux_clk_m, 0), 2897 + PERIPH_CLK("sbc1", "spi_tegra.0", NULL, 41, 0x134, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2898 + PERIPH_CLK("sbc2", "spi_tegra.1", NULL, 44, 0x118, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2899 + PERIPH_CLK("sbc3", "spi_tegra.2", NULL, 46, 0x11c, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2900 + PERIPH_CLK("sbc4", "spi_tegra.3", NULL, 68, 0x1b4, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2901 + PERIPH_CLK("sbc5", "spi_tegra.4", NULL, 104, 0x3c8, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2902 + PERIPH_CLK("sbc6", "spi_tegra.5", NULL, 105, 0x3cc, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2903 + PERIPH_CLK("sata_oob", "tegra_sata_oob", NULL, 123, 0x420, 216000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 2904 + PERIPH_CLK("sata", "tegra_sata", NULL, 124, 0x424, 216000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 2905 + PERIPH_CLK("sata_cold", "tegra_sata_cold", NULL, 129, 0, 48000000, mux_clk_m, 0), 2906 + PERIPH_CLK_EX("ndflash", "tegra_nand", NULL, 13, 0x160, 240000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71, &tegra_nand_clk_ops), 2907 + PERIPH_CLK("ndspeed", "tegra_nand_speed", NULL, 80, 0x3f8, 240000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 2908 + PERIPH_CLK("vfir", "vfir", NULL, 7, 0x168, 72000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2909 + PERIPH_CLK("sdmmc1", "sdhci-tegra.0", NULL, 14, 0x150, 208000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */ 2910 + PERIPH_CLK("sdmmc2", "sdhci-tegra.1", NULL, 9, 0x154, 104000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */ 2911 + PERIPH_CLK("sdmmc3", "sdhci-tegra.2", NULL, 69, 0x1bc, 208000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */ 2912 + PERIPH_CLK("sdmmc4", "sdhci-tegra.3", NULL, 15, 0x164, 104000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */ 2913 + PERIPH_CLK("vcp", "tegra-avp", "vcp", 29, 0, 250000000, mux_clk_m, 0), 2914 + PERIPH_CLK("bsea", "tegra-avp", "bsea", 62, 0, 250000000, mux_clk_m, 0), 2915 + PERIPH_CLK("bsev", "tegra-aes", "bsev", 63, 0, 250000000, mux_clk_m, 0), 2916 + PERIPH_CLK("vde", "vde", NULL, 61, 0x1c8, 520000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_INT), 2917 + PERIPH_CLK("csite", "csite", NULL, 73, 0x1d4, 144000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* max rate ??? */ 2918 + PERIPH_CLK("la", "la", NULL, 76, 0x1f8, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 2919 + PERIPH_CLK("owr", "tegra_w1", NULL, 71, 0x1cc, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2920 + PERIPH_CLK("nor", "nor", NULL, 42, 0x1d0, 127000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* requires min voltage */ 2921 + PERIPH_CLK("mipi", "mipi", NULL, 50, 0x174, 60000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB), /* scales with voltage */ 2922 + PERIPH_CLK("i2c1", "tegra-i2c.0", NULL, 12, 0x124, 26000000, mux_pllp_clkm, MUX | DIV_U16 | PERIPH_ON_APB), 2923 + PERIPH_CLK("i2c2", "tegra-i2c.1", NULL, 54, 0x198, 26000000, mux_pllp_clkm, MUX | DIV_U16 | PERIPH_ON_APB), 2924 + PERIPH_CLK("i2c3", "tegra-i2c.2", NULL, 67, 0x1b8, 26000000, mux_pllp_clkm, MUX | DIV_U16 | PERIPH_ON_APB), 2925 + PERIPH_CLK("i2c4", "tegra-i2c.3", NULL, 103, 0x3c4, 26000000, mux_pllp_clkm, MUX | DIV_U16 | PERIPH_ON_APB), 2926 + PERIPH_CLK("i2c5", "tegra-i2c.4", NULL, 47, 0x128, 26000000, mux_pllp_clkm, MUX | DIV_U16 | PERIPH_ON_APB), 2927 + PERIPH_CLK("uarta", "tegra_uart.0", NULL, 6, 0x178, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2928 + PERIPH_CLK("uartb", "tegra_uart.1", NULL, 7, 0x17c, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2929 + PERIPH_CLK("uartc", "tegra_uart.2", NULL, 55, 0x1a0, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2930 + PERIPH_CLK("uartd", "tegra_uart.3", NULL, 65, 0x1c0, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2931 + PERIPH_CLK("uarte", "tegra_uart.4", NULL, 66, 0x1c4, 800000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2932 + PERIPH_CLK("uarta_dbg", "serial8250.0", "uarta", 6, 0x178, 800000000, mux_pllp_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2933 + PERIPH_CLK("uartb_dbg", "serial8250.0", "uartb", 7, 0x17c, 800000000, mux_pllp_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2934 + PERIPH_CLK("uartc_dbg", "serial8250.0", "uartc", 55, 0x1a0, 800000000, mux_pllp_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2935 + PERIPH_CLK("uartd_dbg", "serial8250.0", "uartd", 65, 0x1c0, 800000000, mux_pllp_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2936 + PERIPH_CLK("uarte_dbg", "serial8250.0", "uarte", 66, 0x1c4, 800000000, mux_pllp_clkm, MUX | DIV_U71 | DIV_U71_UART | PERIPH_ON_APB), 2937 + PERIPH_CLK_EX("vi", "tegra_camera", "vi", 20, 0x148, 425000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT, &tegra_vi_clk_ops), 2938 + PERIPH_CLK("3d", "3d", NULL, 24, 0x158, 520000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT | DIV_U71_IDLE | PERIPH_MANUAL_RESET), 2939 + PERIPH_CLK("3d2", "3d2", NULL, 98, 0x3b0, 520000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT | DIV_U71_IDLE | PERIPH_MANUAL_RESET), 2940 + PERIPH_CLK("2d", "2d", NULL, 21, 0x15c, 520000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT | DIV_U71_IDLE), 2941 + PERIPH_CLK("vi_sensor", "tegra_camera", "vi_sensor", 20, 0x1a8, 150000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | PERIPH_NO_RESET), 2942 + PERIPH_CLK("epp", "epp", NULL, 19, 0x16c, 520000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT), 2943 + PERIPH_CLK("mpe", "mpe", NULL, 60, 0x170, 520000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT), 2944 + PERIPH_CLK("host1x", "host1x", NULL, 28, 0x180, 260000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT), 2945 + PERIPH_CLK("cve", "cve", NULL, 49, 0x140, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), /* requires min voltage */ 2946 + PERIPH_CLK("tvo", "tvo", NULL, 49, 0x188, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), /* requires min voltage */ 2947 + PERIPH_CLK_EX("dtv", "dtv", NULL, 79, 0x1dc, 250000000, mux_clk_m, 0, &tegra_dtv_clk_ops), 2948 + PERIPH_CLK("hdmi", "hdmi", NULL, 51, 0x18c, 148500000, mux_pllp_pllm_plld_plla_pllc_plld2_clkm, MUX | MUX8 | DIV_U71), 2949 + PERIPH_CLK("tvdac", "tvdac", NULL, 53, 0x194, 220000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), /* requires min voltage */ 2950 + PERIPH_CLK("disp1", "tegradc.0", NULL, 27, 0x138, 600000000, mux_pllp_pllm_plld_plla_pllc_plld2_clkm, MUX | MUX8), 2951 + PERIPH_CLK("disp2", "tegradc.1", NULL, 26, 0x13c, 600000000, mux_pllp_pllm_plld_plla_pllc_plld2_clkm, MUX | MUX8), 2952 + PERIPH_CLK("usbd", "fsl-tegra-udc", NULL, 22, 0, 480000000, mux_clk_m, 0), /* requires min voltage */ 2953 + PERIPH_CLK("usb2", "tegra-ehci.1", NULL, 58, 0, 480000000, mux_clk_m, 0), /* requires min voltage */ 2954 + PERIPH_CLK("usb3", "tegra-ehci.2", NULL, 59, 0, 480000000, mux_clk_m, 0), /* requires min voltage */ 2955 + PERIPH_CLK("dsia", "tegradc.0", "dsia", 48, 0, 500000000, mux_plld_out0, 0), 2956 + PERIPH_CLK_EX("dsib", "tegradc.1", "dsib", 82, 0xd0, 500000000, mux_plld_out0_plld2_out0, MUX | PLLD, &tegra_dsib_clk_ops), 2957 + PERIPH_CLK("csi", "tegra_camera", "csi", 52, 0, 102000000, mux_pllp_out3, 0), 2958 + PERIPH_CLK("isp", "tegra_camera", "isp", 23, 0, 150000000, mux_clk_m, 0), /* same frequency as VI */ 2959 + PERIPH_CLK("csus", "tegra_camera", "csus", 92, 0, 150000000, mux_clk_m, PERIPH_NO_RESET), 2960 + 2961 + PERIPH_CLK("tsensor", "tegra-tsensor", NULL, 100, 0x3b8, 216000000, mux_pllp_pllc_clkm_clk32, MUX | DIV_U71), 2962 + PERIPH_CLK("actmon", "actmon", NULL, 119, 0x3e8, 216000000, mux_pllp_pllc_clk32_clkm, MUX | DIV_U71), 2963 + PERIPH_CLK("extern1", "extern1", NULL, 120, 0x3ec, 216000000, mux_plla_clk32_pllp_clkm_plle, MUX | MUX8 | DIV_U71), 2964 + PERIPH_CLK("extern2", "extern2", NULL, 121, 0x3f0, 216000000, mux_plla_clk32_pllp_clkm_plle, MUX | MUX8 | DIV_U71), 2965 + PERIPH_CLK("extern3", "extern3", NULL, 122, 0x3f4, 216000000, mux_plla_clk32_pllp_clkm_plle, MUX | MUX8 | DIV_U71), 2966 + PERIPH_CLK("i2cslow", "i2cslow", NULL, 81, 0x3fc, 26000000, mux_pllp_pllc_clk32_clkm, MUX | DIV_U71 | PERIPH_ON_APB), 2967 + PERIPH_CLK("pcie", "tegra-pcie", "pcie", 70, 0, 250000000, mux_clk_m, 0), 2968 + PERIPH_CLK("afi", "tegra-pcie", "afi", 72, 0, 250000000, mux_clk_m, 0), 2969 + PERIPH_CLK("se", "se", NULL, 127, 0x42c, 520000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_INT), 2970 + }; 2971 + 2972 + #define CLK_DUPLICATE(_name, _dev, _con) \ 2973 + { \ 2974 + .name = _name, \ 2975 + .lookup = { \ 2976 + .dev_id = _dev, \ 2977 + .con_id = _con, \ 2978 + }, \ 2979 + } 2980 + 2981 + /* Some clocks may be used by different drivers depending on the board 2982 + * configuration. List those here to register them twice in the clock lookup 2983 + * table under two names. 2984 + */ 2985 + struct clk_duplicate tegra_clk_duplicates[] = { 2986 + CLK_DUPLICATE("usbd", "utmip-pad", NULL), 2987 + CLK_DUPLICATE("usbd", "tegra-ehci.0", NULL), 2988 + CLK_DUPLICATE("usbd", "tegra-otg", NULL), 2989 + CLK_DUPLICATE("hdmi", "tegradc.0", "hdmi"), 2990 + CLK_DUPLICATE("hdmi", "tegradc.1", "hdmi"), 2991 + CLK_DUPLICATE("dsib", "tegradc.0", "dsib"), 2992 + CLK_DUPLICATE("dsia", "tegradc.1", "dsia"), 2993 + CLK_DUPLICATE("pwm", "tegra_pwm.0", NULL), 2994 + CLK_DUPLICATE("pwm", "tegra_pwm.1", NULL), 2995 + CLK_DUPLICATE("pwm", "tegra_pwm.2", NULL), 2996 + CLK_DUPLICATE("pwm", "tegra_pwm.3", NULL), 2997 + CLK_DUPLICATE("bsev", "tegra-avp", "bsev"), 2998 + CLK_DUPLICATE("bsev", "nvavp", "bsev"), 2999 + CLK_DUPLICATE("vde", "tegra-aes", "vde"), 3000 + CLK_DUPLICATE("bsea", "tegra-aes", "bsea"), 3001 + CLK_DUPLICATE("bsea", "nvavp", "bsea"), 3002 + CLK_DUPLICATE("cml1", "tegra_sata_cml", NULL), 3003 + CLK_DUPLICATE("cml0", "tegra_pcie", "cml"), 3004 + CLK_DUPLICATE("pciex", "tegra_pcie", "pciex"), 3005 + CLK_DUPLICATE("i2c1", "tegra-i2c-slave.0", NULL), 3006 + CLK_DUPLICATE("i2c2", "tegra-i2c-slave.1", NULL), 3007 + CLK_DUPLICATE("i2c3", "tegra-i2c-slave.2", NULL), 3008 + CLK_DUPLICATE("i2c4", "tegra-i2c-slave.3", NULL), 3009 + CLK_DUPLICATE("i2c5", "tegra-i2c-slave.4", NULL), 3010 + CLK_DUPLICATE("sbc1", "spi_slave_tegra.0", NULL), 3011 + CLK_DUPLICATE("sbc2", "spi_slave_tegra.1", NULL), 3012 + CLK_DUPLICATE("sbc3", "spi_slave_tegra.2", NULL), 3013 + CLK_DUPLICATE("sbc4", "spi_slave_tegra.3", NULL), 3014 + CLK_DUPLICATE("sbc5", "spi_slave_tegra.4", NULL), 3015 + CLK_DUPLICATE("sbc6", "spi_slave_tegra.5", NULL), 3016 + CLK_DUPLICATE("twd", "smp_twd", NULL), 3017 + CLK_DUPLICATE("vcp", "nvavp", "vcp"), 3018 + }; 3019 + 3020 + struct clk *tegra_ptr_clks[] = { 3021 + &tegra_clk_32k, 3022 + &tegra_clk_m, 3023 + &tegra_clk_m_div2, 3024 + &tegra_clk_m_div4, 3025 + &tegra_pll_ref, 3026 + &tegra_pll_m, 3027 + &tegra_pll_m_out1, 3028 + &tegra_pll_c, 3029 + &tegra_pll_c_out1, 3030 + &tegra_pll_p, 3031 + &tegra_pll_p_out1, 3032 + &tegra_pll_p_out2, 3033 + &tegra_pll_p_out3, 3034 + &tegra_pll_p_out4, 3035 + &tegra_pll_a, 3036 + &tegra_pll_a_out0, 3037 + &tegra_pll_d, 3038 + &tegra_pll_d_out0, 3039 + &tegra_pll_d2, 3040 + &tegra_pll_d2_out0, 3041 + &tegra_pll_u, 3042 + &tegra_pll_x, 3043 + &tegra_pll_x_out0, 3044 + &tegra_pll_e, 3045 + &tegra_clk_cclk_g, 3046 + &tegra_cml0_clk, 3047 + &tegra_cml1_clk, 3048 + &tegra_pciex_clk, 3049 + &tegra_clk_sclk, 3050 + &tegra_clk_blink, 3051 + &tegra30_clk_twd, 3052 + }; 3053 + 3054 + 3055 + static void tegra30_init_one_clock(struct clk *c) 3056 + { 3057 + clk_init(c); 3058 + INIT_LIST_HEAD(&c->shared_bus_list); 3059 + if (!c->lookup.dev_id && !c->lookup.con_id) 3060 + c->lookup.con_id = c->name; 3061 + c->lookup.clk = c; 3062 + clkdev_add(&c->lookup); 3063 + } 3064 + 3065 + void __init tegra30_init_clocks(void) 3066 + { 3067 + int i; 3068 + struct clk *c; 3069 + 3070 + for (i = 0; i < ARRAY_SIZE(tegra_ptr_clks); i++) 3071 + tegra30_init_one_clock(tegra_ptr_clks[i]); 3072 + 3073 + for (i = 0; i < ARRAY_SIZE(tegra_list_clks); i++) 3074 + tegra30_init_one_clock(&tegra_list_clks[i]); 3075 + 3076 + for (i = 0; i < ARRAY_SIZE(tegra_clk_duplicates); i++) { 3077 + c = tegra_get_clock_by_name(tegra_clk_duplicates[i].name); 3078 + if (!c) { 3079 + pr_err("%s: Unknown duplicate clock %s\n", __func__, 3080 + tegra_clk_duplicates[i].name); 3081 + continue; 3082 + } 3083 + 3084 + tegra_clk_duplicates[i].lookup.clk = c; 3085 + clkdev_add(&tegra_clk_duplicates[i].lookup); 3086 + } 3087 + 3088 + for (i = 0; i < ARRAY_SIZE(tegra_sync_source_list); i++) 3089 + tegra30_init_one_clock(&tegra_sync_source_list[i]); 3090 + for (i = 0; i < ARRAY_SIZE(tegra_clk_audio_list); i++) 3091 + tegra30_init_one_clock(&tegra_clk_audio_list[i]); 3092 + for (i = 0; i < ARRAY_SIZE(tegra_clk_audio_2x_list); i++) 3093 + tegra30_init_one_clock(&tegra_clk_audio_2x_list[i]); 3094 + 3095 + init_clk_out_mux(); 3096 + for (i = 0; i < ARRAY_SIZE(tegra_clk_out_list); i++) 3097 + tegra30_init_one_clock(&tegra_clk_out_list[i]); 3098 + 3099 + }
+24
arch/arm/plat-mxc/cpu.c
··· 1 1 2 2 #include <linux/module.h> 3 + #include <linux/io.h> 3 4 #include <mach/hardware.h> 4 5 5 6 unsigned int __mxc_cpu_type; ··· 18 17 else 19 18 pr_info("CPU identified as %s, silicon rev %d.%d\n", 20 19 cpu, (srev >> 4) & 0xf, srev & 0xf); 20 + } 21 + 22 + void __init imx_set_aips(void __iomem *base) 23 + { 24 + unsigned int reg; 25 + /* 26 + * Set all MPROTx to be non-bufferable, trusted for R/W, 27 + * not forced to user-mode. 28 + */ 29 + __raw_writel(0x77777777, base + 0x0); 30 + __raw_writel(0x77777777, base + 0x4); 31 + 32 + /* 33 + * Set all OPACRx to be non-bufferable, to not require 34 + * supervisor privilege level for access, allow for 35 + * write access and untrusted master access. 36 + */ 37 + __raw_writel(0x0, base + 0x40); 38 + __raw_writel(0x0, base + 0x44); 39 + __raw_writel(0x0, base + 0x48); 40 + __raw_writel(0x0, base + 0x4C); 41 + reg = __raw_readl(base + 0x50) & 0x00FFFFFF; 42 + __raw_writel(reg, base + 0x50); 21 43 }
+9
arch/arm/plat-mxc/include/mach/common.h
··· 75 75 extern void mxc_arch_reset_init(void __iomem *); 76 76 extern int mx53_revision(void); 77 77 extern int mx53_display_revision(void); 78 + extern void imx_set_aips(void __iomem *); 78 79 79 80 enum mxc_cpu_pwr_mode { 80 81 WAIT_CLOCKED, /* wfi only */ ··· 85 84 STOP_POWER_OFF, /* STOP + SRPG */ 86 85 }; 87 86 87 + enum mx3_cpu_pwr_mode { 88 + MX3_RUN, 89 + MX3_WAIT, 90 + MX3_DOZE, 91 + MX3_SLEEP, 92 + }; 93 + 94 + extern void mx3_cpu_lp_set(enum mx3_cpu_pwr_mode mode); 88 95 extern void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode); 89 96 extern void imx_print_silicon_rev(const char *cpu, int srev); 90 97
+6 -1
arch/arm/plat-omap/include/plat/cpu.h
··· 449 449 #define OMAP447X_CLASS 0x44700044 450 450 #define OMAP4470_REV_ES1_0 (OMAP447X_CLASS | (0x10 << 8)) 451 451 452 - void omap2_check_revision(void); 452 + void omap2xxx_check_revision(void); 453 + void omap3xxx_check_revision(void); 454 + void omap4xxx_check_revision(void); 455 + void omap3xxx_check_features(void); 456 + void ti81xx_check_features(void); 457 + void omap4xxx_check_features(void); 453 458 454 459 /* 455 460 * Runtime detection of OMAP3 features
+10
arch/arm/plat-s5p/Kconfig
··· 80 80 help 81 81 Compile in platform device definitions for FIMC controller 3 82 82 83 + config S5P_DEV_JPEG 84 + bool 85 + help 86 + Compile in platform device definitions for JPEG codec 87 + 88 + config S5P_DEV_G2D 89 + bool 90 + help 91 + Compile in platform device definitions for G2D device 92 + 83 93 config S5P_DEV_FIMD0 84 94 bool 85 95 help
+38 -6
arch/arm/plat-s5p/sleep.S
··· 23 23 */ 24 24 25 25 #include <linux/linkage.h> 26 - #include <asm/assembler.h> 26 + #include <asm/asm-offsets.h> 27 + #include <asm/hardware/cache-l2x0.h> 27 28 28 - .text 29 + /* 30 + * The following code is located into the .data section. This is to 31 + * allow l2x0_regs_phys to be accessed with a relative load while we 32 + * can't rely on any MMU translation. We could have put l2x0_regs_phys 33 + * in the .text section as well, but some setups might insist on it to 34 + * be truly read-only. (Reference from: arch/arm/kernel/sleep.S) 35 + */ 36 + .data 37 + .align 29 38 30 39 /* 31 40 * sleep magic, to allow the bootloader to check for an valid ··· 48 39 * s3c_cpu_resume 49 40 * 50 41 * resume code entry for bootloader to call 51 - * 52 - * we must put this code here in the data segment as we have no 53 - * other way of restoring the stack pointer after sleep, and we 54 - * must not write to the code segment (code is read-only) 55 42 */ 56 43 57 44 ENTRY(s3c_cpu_resume) 45 + #ifdef CONFIG_CACHE_L2X0 46 + adr r0, l2x0_regs_phys 47 + ldr r0, [r0] 48 + ldr r1, [r0, #L2X0_R_PHY_BASE] 49 + ldr r2, [r1, #L2X0_CTRL] 50 + tst r2, #0x1 51 + bne resume_l2on 52 + ldr r2, [r0, #L2X0_R_AUX_CTRL] 53 + str r2, [r1, #L2X0_AUX_CTRL] 54 + ldr r2, [r0, #L2X0_R_TAG_LATENCY] 55 + str r2, [r1, #L2X0_TAG_LATENCY_CTRL] 56 + ldr r2, [r0, #L2X0_R_DATA_LATENCY] 57 + str r2, [r1, #L2X0_DATA_LATENCY_CTRL] 58 + ldr r2, [r0, #L2X0_R_PREFETCH_CTRL] 59 + str r2, [r1, #L2X0_PREFETCH_CTRL] 60 + ldr r2, [r0, #L2X0_R_PWR_CTRL] 61 + str r2, [r1, #L2X0_POWER_CTRL] 62 + mov r2, #1 63 + str r2, [r1, #L2X0_CTRL] 64 + resume_l2on: 65 + #endif 58 66 b cpu_resume 67 + ENDPROC(s3c_cpu_resume) 68 + #ifdef CONFIG_CACHE_L2X0 69 + .globl l2x0_regs_phys 70 + l2x0_regs_phys: 71 + .long 0 72 + #endif
+8 -4
arch/arm/plat-samsung/clock.c
··· 84 84 85 85 int clk_enable(struct clk *clk) 86 86 { 87 + unsigned long flags; 88 + 87 89 if (IS_ERR(clk) || clk == NULL) 88 90 return -EINVAL; 89 91 90 92 clk_enable(clk->parent); 91 93 92 - spin_lock(&clocks_lock); 94 + spin_lock_irqsave(&clocks_lock, flags); 93 95 94 96 if ((clk->usage++) == 0) 95 97 (clk->enable)(clk, 1); 96 98 97 - spin_unlock(&clocks_lock); 99 + spin_unlock_irqrestore(&clocks_lock, flags); 98 100 return 0; 99 101 } 100 102 101 103 void clk_disable(struct clk *clk) 102 104 { 105 + unsigned long flags; 106 + 103 107 if (IS_ERR(clk) || clk == NULL) 104 108 return; 105 109 106 - spin_lock(&clocks_lock); 110 + spin_lock_irqsave(&clocks_lock, flags); 107 111 108 112 if ((--clk->usage) == 0) 109 113 (clk->enable)(clk, 0); 110 114 111 - spin_unlock(&clocks_lock); 115 + spin_unlock_irqrestore(&clocks_lock, flags); 112 116 clk_disable(clk->parent); 113 117 } 114 118
+3 -1
arch/arm/plat-samsung/dev-backlight.c
··· 77 77 * @gpio_info: structure containing GPIO info for PWM timer 78 78 * @bl_data: structure containing Backlight control data 79 79 */ 80 - void samsung_bl_set(struct samsung_bl_gpio_info *gpio_info, 80 + void __init samsung_bl_set(struct samsung_bl_gpio_info *gpio_info, 81 81 struct platform_pwm_backlight_data *bl_data) 82 82 { 83 83 int ret = 0; ··· 115 115 samsung_bl_data->init = bl_data->init; 116 116 if (bl_data->notify) 117 117 samsung_bl_data->notify = bl_data->notify; 118 + if (bl_data->notify_after) 119 + samsung_bl_data->notify_after = bl_data->notify_after; 118 120 if (bl_data->exit) 119 121 samsung_bl_data->exit = bl_data->exit; 120 122 if (bl_data->check_fb)
+64 -4
arch/arm/plat-samsung/devs.c
··· 57 57 #include <plat/sdhci.h> 58 58 #include <plat/ts.h> 59 59 #include <plat/udc.h> 60 + #include <plat/udc-hs.h> 60 61 #include <plat/usb-control.h> 61 62 #include <plat/usb-phy.h> 62 63 #include <plat/regs-iic.h> ··· 267 266 }, 268 267 }; 269 268 #endif /* CONFIG_S5P_DEV_FIMC3 */ 269 + 270 + /* G2D */ 271 + 272 + #ifdef CONFIG_S5P_DEV_G2D 273 + static struct resource s5p_g2d_resource[] = { 274 + [0] = { 275 + .start = S5P_PA_G2D, 276 + .end = S5P_PA_G2D + SZ_4K - 1, 277 + .flags = IORESOURCE_MEM, 278 + }, 279 + [1] = { 280 + .start = IRQ_2D, 281 + .end = IRQ_2D, 282 + .flags = IORESOURCE_IRQ, 283 + }, 284 + }; 285 + 286 + struct platform_device s5p_device_g2d = { 287 + .name = "s5p-g2d", 288 + .id = 0, 289 + .num_resources = ARRAY_SIZE(s5p_g2d_resource), 290 + .resource = s5p_g2d_resource, 291 + .dev = { 292 + .dma_mask = &samsung_device_dma_mask, 293 + .coherent_dma_mask = DMA_BIT_MASK(32), 294 + }, 295 + }; 296 + #endif /* CONFIG_S5P_DEV_G2D */ 297 + 298 + #ifdef CONFIG_S5P_DEV_JPEG 299 + static struct resource s5p_jpeg_resource[] = { 300 + [0] = DEFINE_RES_MEM(S5P_PA_JPEG, SZ_4K), 301 + [1] = DEFINE_RES_IRQ(IRQ_JPEG), 302 + }; 303 + 304 + struct platform_device s5p_device_jpeg = { 305 + .name = "s5p-jpeg", 306 + .id = 0, 307 + .num_resources = ARRAY_SIZE(s5p_jpeg_resource), 308 + .resource = s5p_jpeg_resource, 309 + .dev = { 310 + .dma_mask = &samsung_device_dma_mask, 311 + .coherent_dma_mask = DMA_BIT_MASK(32), 312 + }, 313 + }; 314 + #endif /* CONFIG_S5P_DEV_JPEG */ 270 315 271 316 /* FIMD0 */ 272 317 ··· 805 758 .resource = s3c_cfcon_resource, 806 759 }; 807 760 808 - void s3c_ide_set_platdata(struct s3c_ide_platdata *pdata) 761 + void __init s3c_ide_set_platdata(struct s3c_ide_platdata *pdata) 809 762 { 810 763 s3c_set_platdata(pdata, sizeof(struct s3c_ide_platdata), 811 764 &s3c_device_cfcon); ··· 923 876 924 877 #ifdef CONFIG_S5P_DEV_CSIS0 925 878 static struct resource s5p_mipi_csis0_resource[] = { 926 - [0] = DEFINE_RES_MEM(S5P_PA_MIPI_CSIS0, SZ_4K), 879 + [0] = DEFINE_RES_MEM(S5P_PA_MIPI_CSIS0, SZ_16K), 927 880 [1] = DEFINE_RES_IRQ(IRQ_MIPI_CSIS0), 928 881 }; 929 882 ··· 937 890 938 891 #ifdef CONFIG_S5P_DEV_CSIS1 939 892 static struct resource s5p_mipi_csis1_resource[] = { 940 - [0] = DEFINE_RES_MEM(S5P_PA_MIPI_CSIS1, SZ_4K), 893 + [0] = DEFINE_RES_MEM(S5P_PA_MIPI_CSIS1, SZ_16K), 941 894 [1] = DEFINE_RES_IRQ(IRQ_MIPI_CSIS1), 942 895 }; 943 896 ··· 1085 1038 .resource = s3c64xx_onenand1_resources, 1086 1039 }; 1087 1040 1088 - void s3c64xx_onenand1_set_platdata(struct onenand_platform_data *pdata) 1041 + void __init s3c64xx_onenand1_set_platdata(struct onenand_platform_data *pdata) 1089 1042 { 1090 1043 s3c_set_platdata(pdata, sizeof(struct onenand_platform_data), 1091 1044 &s3c64xx_device_onenand1); ··· 1459 1412 .coherent_dma_mask = DMA_BIT_MASK(32), 1460 1413 }, 1461 1414 }; 1415 + 1416 + void __init s3c_hsotg_set_platdata(struct s3c_hsotg_plat *pd) 1417 + { 1418 + struct s3c_hsotg_plat *npd; 1419 + 1420 + npd = s3c_set_platdata(pd, sizeof(struct s3c_hsotg_plat), 1421 + &s3c_device_usb_hsotg); 1422 + 1423 + if (!npd->phy_init) 1424 + npd->phy_init = s5p_usb_phy_init; 1425 + if (!npd->phy_exit) 1426 + npd->phy_exit = s5p_usb_phy_exit; 1427 + } 1462 1428 #endif /* CONFIG_S3C_DEV_USB_HSOTG */ 1463 1429 1464 1430 /* USB High Spped 2.0 Device (Gadget) */
+2
arch/arm/plat-samsung/include/plat/devs.h
··· 79 79 extern struct platform_device s5p_device_fimc2; 80 80 extern struct platform_device s5p_device_fimc3; 81 81 extern struct platform_device s5p_device_fimc_md; 82 + extern struct platform_device s5p_device_jpeg; 83 + extern struct platform_device s5p_device_g2d; 82 84 extern struct platform_device s5p_device_fimd0; 83 85 extern struct platform_device s5p_device_hdmi; 84 86 extern struct platform_device s5p_device_i2c_hdmiphy;
+4 -3
arch/arm/plat-samsung/include/plat/regs-usb-hsotg-phy.h
··· 25 25 #define S3C_HSOTG_PHYREG(x) ((x) + S3C_VA_USB_HSPHY) 26 26 27 27 #define S3C_PHYPWR S3C_HSOTG_PHYREG(0x00) 28 - #define SRC_PHYPWR_OTG_DISABLE (1 << 4) 29 - #define SRC_PHYPWR_ANALOG_POWERDOWN (1 << 3) 28 + #define S3C_PHYPWR_NORMAL_MASK (0x19 << 0) 29 + #define S3C_PHYPWR_OTG_DISABLE (1 << 4) 30 + #define S3C_PHYPWR_ANALOG_POWERDOWN (1 << 3) 30 31 #define SRC_PHYPWR_FORCE_SUSPEND (1 << 1) 31 32 32 33 #define S3C_PHYCLK S3C_HSOTG_PHYREG(0x04) ··· 43 42 44 43 #define S3C_RSTCON S3C_HSOTG_PHYREG(0x08) 45 44 #define S3C_RSTCON_PHYCLK (1 << 2) 46 - #define S3C_RSTCON_HCLK (1 << 2) 45 + #define S3C_RSTCON_HCLK (1 << 1) 47 46 #define S3C_RSTCON_PHY (1 << 0) 48 47 49 48 #define S3C_PHYTUNE S3C_HSOTG_PHYREG(0x20)
+5
arch/arm/plat-samsung/include/plat/udc-hs.h
··· 26 26 struct s3c_hsotg_plat { 27 27 enum s3c_hsotg_dmamode dma; 28 28 unsigned int is_osc : 1; 29 + 30 + int (*phy_init)(struct platform_device *pdev, int type); 31 + int (*phy_exit)(struct platform_device *pdev, int type); 29 32 }; 33 + 34 + extern void s3c_hsotg_set_platdata(struct s3c_hsotg_plat *pd);