Updating SPEAr Support
Subsystems (4)
PATCH v4 62/62 ST SPEAr: Updating defconfigs
In reply to Viresh Kumar--- arch/arm/configs/spear13xx_defconfig | 78 ++++++++++++++++++++++++++++++--- arch/arm/configs/spear3xx_defconfig | 80 +++++++++++++++++++++++++++++++--- arch/arm/configs/spear6xx_defconfig | 72 ++++++++++++++++++++++++++++--- 3 files changed, 211 insertions(+), 19 deletions(-)
arch/arm/configs/spear13xx_defconfig +72 -6
@@ -10,31 +10,94 @@ CONFIG_PLAT_SPEAR=y CONFIG_ARCH_SPEAR13XX=y CONFIG_BOARD_SPEAR1300_EVB=y CONFIG_BOARD_SPEAR1310_EVB=y +CONFIG_PCI=y +CONFIG_PCI_MSI=y +CONFIG_PCIEPORTBUS=y +# CONFIG_PCIEAER is not set CONFIG_SMP=y CONFIG_NR_CPUS=2 CONFIG_AEABI=y +CONFIG_CPU_FREQ=y +CONFIG_CPU_FREQ_STAT_DETAILS=y +CONFIG_CPU_FREQ_GOV_POWERSAVE=y +CONFIG_CPU_FREQ_GOV_USERSPACE=y +CONFIG_CPU_FREQ_GOV_ONDEMAND=y +CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y +CONFIG_VFP=y CONFIG_BINFMT_MISC=y +CONFIG_PM=y +CONFIG_NET=y +CONFIG_PACKET=y +CONFIG_UNIX=y +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +CONFIG_IP_PNP_BOOTP=y +CONFIG_NET_IPIP=y +CONFIG_ARPD=y +# CONFIG_IPV6 is not set +# CONFIG_WIRELESS is not set CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y CONFIG_MTD=y CONFIG_MTD_CONCAT=y CONFIG_MTD_PARTITIONS=y CONFIG_MTD_CMDLINE_PARTS=y CONFIG_MTD_CHAR=y CONFIG_MTD_BLOCK=y +CONFIG_MTD_CFI=y +CONFIG_MTD_CFI_INTELEXT=y +CONFIG_MTD_CFI_STAA=y +CONFIG_MTD_PHYSMAP=y +CONFIG_MTD_M25P80=y +# CONFIG_M25PXX_USE_FAST_READ is not set +CONFIG_MTD_NAND=y +CONFIG_MTD_NAND_FSMC=y CONFIG_BLK_DEV_RAM=y CONFIG_BLK_DEV_RAM_SIZE=16384 +CONFIG_SCSI=y +CONFIG_BLK_DEV_SD=y +CONFIG_CHR_DEV_ST=y +CONFIG_CHR_DEV_OSST=y +CONFIG_BLK_DEV_SR=y +CONFIG_CHR_DEV_SG=y +CONFIG_CHR_DEV_SCH=y +CONFIG_NETDEVICES=y +# CONFIG_WLAN is not set CONFIG_INPUT_FF_MEMLESS=y # CONFIG_INPUT_MOUSEDEV_PSAUX is not set -# CONFIG_INPUT_KEYBOARD is not set +CONFIG_INPUT_EVDEV=y +CONFIG_INPUT_EVBUG=y +# CONFIG_KEYBOARD_ATKBD is not set +CONFIG_KEYBOARD_SPEAR=y # CONFIG_INPUT_MOUSE is not set CONFIG_SERIAL_AMBA_PL011=y CONFIG_SERIAL_AMBA_PL011_CONSOLE=y # CONFIG_LEGACY_PTYS is not set CONFIG_RAW_DRIVER=y CONFIG_MAX_RAW_DEVS=8192 +CONFIG_I2C=y +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_DESIGNWARE=y +CONFIG_SPI=y +CONFIG_SPI_PL022=y +CONFIG_SPI_SPIDEV=y +CONFIG_GPIO_SYSFS=y +CONFIG_GPIO_PL061=y # CONFIG_HWMON is not set # CONFIG_HID_SUPPORT is not set -# CONFIG_USB_SUPPORT is not set +CONFIG_USB=y +CONFIG_USB_EHCI_HCD=y +# CONFIG_USB_EHCI_TT_NEWSCHED is not set +CONFIG_USB_OHCI_HCD=y +CONFIG_USB_STORAGE=y +CONFIG_USB_TEST=y +CONFIG_MMC=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_SPEAR=y +CONFIG_RTC_CLASS=y CONFIG_EXT2_FS=y CONFIG_EXT2_FS_XATTR=y CONFIG_EXT2_FS_SECURITY=y
@@ -42,16 +105,18 @@ CONFIG_EXT3_FS=y # CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set CONFIG_EXT3_FS_SECURITY=y CONFIG_AUTOFS4_FS=m -CONFIG_MSDOS_FS=m -CONFIG_VFAT_FS=m +CONFIG_MSDOS_FS=y +CONFIG_VFAT_FS=y CONFIG_FAT_DEFAULT_IOCHARSET="ascii" CONFIG_TMPFS=y CONFIG_JFFS2_FS=y +CONFIG_NFS_FS=y +CONFIG_ROOT_NFS=y +# CONFIG_RPCSEC_GSS_KRB5 is not set CONFIG_PARTITION_ADVANCED=y -CONFIG_NLS=y CONFIG_NLS_DEFAULT="utf8" CONFIG_NLS_CODEPAGE_437=y -CONFIG_NLS_ASCII=m +CONFIG_NLS_ASCII=y CONFIG_MAGIC_SYSRQ=y CONFIG_DEBUG_FS=y CONFIG_DEBUG_KERNEL=y
@@ -59,3 +124,4 @@ CONFIG_DETECT_HUNG_TASK=y CONFIG_DEBUG_SPINLOCK=y CONFIG_DEBUG_SPINLOCK_SLEEP=y CONFIG_DEBUG_INFO=y +# CONFIG_ARM_UNWIND is not set
arch/arm/configs/spear3xx_defconfig +73 -7
116 lines not on this page · raw message
arch/arm/configs/spear6xx_defconfig +66 -6
106 lines not on this page · raw message
Signature · 1 line
1.7.2.2
v4 cover Updating SPEAr Support
In reply to Viresh KumarQuoted 14 lines · Viresh Kumar
Changes since V3:
- SPEAr13xx: gic init, smp and hotplug code updated w.r.t. latest linus/master
- Appending UL toVMALLOC_ENDMacros
- readl & writle_relaxedused instread_rawinuncompress.h
- infinite loop removed fromarch_reset()inmach-spear13xx/include/mach/system.h
- patch: ST-SPEAr13xx-Modified-static-mappings is broken into two patches. Now, static mapping for SPEAr1310 RAS will be present only on 1310 machine.
- Updated commit message of: SPEAr Power Management: Added the support for Standby mode
- Default ssp freq changed to 25MHz.
- patch: ST-SPEAr-13xx-Adding-support-for-SPEAr1310 is splitted into two patches. Separate patch for 320 CAN is added.
- Wrapper routinespi_init()in spear*evb.c files is removed.
Quoted 8 lines
- routine
i2c_register_board_devices()is renamed toi2c_register_default_devices()inarch/arm/plat-spear/i2c_eval_board.cfile
- Following patches are removed from this patchset, they will be added separately:
ST-SPEAr-FSMC-Flexible-Static-Memory-Controller-NOR-.patch
- Following patches are already present in linus-next or already Acked, so they are also removed from this patchset:
Newly-erased-page-read-workaround.patch
Does this mean I can get rid of the entire set of spear patches in the patch system now?
PATCH v4 4/62 ST SPEAr: Making clock functions more generic
In reply to Viresh KumarQuoted 8 lines · Viresh Kumar
/* pll1 configuration structure */
static structpll_clk_configpll1_config= {arch/arm/mach-spear3xx/clock.c +1
-0.mode_reg = PLL1_CTR, .cfg_reg = PLL1_FRQ, + .masks = &pll1_masks, };/* PLL1 clock */
...
Quoted 5 lines
arch/arm/plat-spear/clock.c +2
-2- mode = (readl (config->mode_reg) >>PLL_MODE_SHIFT ) & -PLL_MODE_MASK ; + mode = (readl (config->mode_reg) >> config->masks->mode_shift) & + config->masks->mode_mask;
...
arch/arm/plat-spear/include/plat/clock.h struct clk { · line 116
Quoted 7 lines
struct
pll_clk_config{arch/arm/plat-spear/include/plat/clock.h +3
-2-unsigned int *mode_reg; -unsigned int *cfg_reg; +u32 *mode_reg; +u32 *cfg_reg; +struct pll_clk_masks *masks; };
Registers should have an __iomem attribute on them. Preferably, but not absolutely necessary, should be void to prevent any direct dereferencing.
PATCH v4 6/62 ST SPEAr13XX: Adding machine specific header files
In reply to Viresh Kumararch/arm/mach-spear13xx/include/mach/misc_regs.h line 23
Quoted 5 lines · Viresh Kumar
arch/arm/mach-spear13xx/include/mach/misc_regs.h new file +5
-0+#define MISC_BASE VA_SPEAR13XX_MISC_BASE + +/* General Configuration */ +#define SOC_CFG ((unsigned int *)(MISC_BASE + 0x000)) +#define BOOTSTRAP_CFG ((unsigned int *)(MISC_BASE + 0x004))
You could really do with an IOMEM() macro, thus:
#ifndef __ASSEMBLY__
#define IOMEM(x) ((void __iomem __force *)(x))
#else
#define IOMEM(x) (x)
#endif
You can then use that for stuff like VA_SPEAR13XX_MISC_BASE, and all these definitions then become:
#define SOC_CFG (MISC_BASE + 0x000)
because GCC allows void pointer arithmetic (treats it as char).
PATCH v4 7/62 ST SPEAr13XX: Adding machine specific src files
In reply to Viresh KumarQuoted 12 lines · Viresh Kumar
arch/arm/mach-spear13xx/headsmp.S new file +6
-0@@ -0,0 +1,96 @@ +/* + * arch/arm/mach-spear13XX/headsmp.S + * + * Picked from realview + * Copyright (c) 2010 ST Microelectronics Limited + * Shiraz Hashim <[email protected]>
arch/arm/mach-spear13xx/headsmp.S line 16
Quoted 10 lines
arch/arm/mach-spear13xx/headsmp.S new file +10
-0+ * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/linkage.h> +#include <linux/init.h> + + __INIT
Is this ever called after the kernel text is thrown away? What if we add support in the generic code to start with secondary CPUs offline as a power saving or boot time feature?
Quoted 34 lines
arch/arm/mach-spear13xx/headsmp.S new file +34
-0+ +/* + * This one is picked from Tegra :- + * + * The secondary kernel init calls v7_flush_dcache_all before it enables + * the L1; however, the L1 comes out of reset in an undefined state, so + * the clean + invalidate performed by v7_flush_dcache_all causes a bunch + * of cache lines with uninitialized data and uninitialized tags to get + * written out to memory, which does really unpleasant things to the ain + * processor. We fix this by performing an invalidate, rather than a + * clean + invalidate, before jumping into the kernel. + */ +ENTRY(v7_invalidate_l1) + mov r0, #0 + mcr p15, 2, r0, c0, c0, 0 + mrc p15, 1, r0, c0, c0, 0 + + ldr r1, =0x7fff + and r2, r1, r0, lsr #13 + + ldr r1, =0x3ff + + and r3, r1, r0, lsr #3 @ NumWays - 1 + add r2, r2, #1 @ NumSets + + and r0, r0, #0x7 + add r0, r0, #4 @ SetShift + + clz r1, r3 @ WayShift + add r4, r3, #1 @ NumWays +1: sub r2, r2, #1 @ NumSets-- + mov r3, r4 @ Temp = NumWays +2: subs r3, r3, #1 @ Temp-- + mov r5, r3, lsl r1
arch/arm/mach-spear13xx/headsmp.S line 60
Quoted 10 lines
arch/arm/mach-spear13xx/headsmp.S new file +10
-0+ mov r6, r2, lsl r0 + orr r5, r5, r6 @ Reg = Temp<<WayShift)|(NumSets<<SetShift) + mcr p15, 0, r5, c7, c6, 2 + bgt 2b + cmp r2, #0 + bgt 1b + dsb + isb + mov pc, lr +ENDPROC(v7_invalidate_l1)
This code appears to have its only caller commented out. Should it be removed?
Quoted 36 lines
arch/arm/mach-spear13xx/headsmp.S new file +36
-0+ +/* + * spear13xx specific entry point for secondary CPUs. This provides + * a "holding pen" into which all secondary cores are held until we're + * ready for them to initialise. + */ +ENTRY(spear13xx_secondary_startup) + /* If we don't do this then we have a crash */ + + /* + * Since now this is being called from xloader so removing it + * here + */ +#if 0 + bl v7_invalidate_l1 +#endif + + mrc p15, 0, r0, c0, c0, 5 + and r0, r0, #15 + adr r4, 1f + ldmia r4, {r5, r6} + sub r4, r4, r5 + add r6, r6, r4 +pen: ldr r7, [r6] + cmp r7, r0 + bne pen + + /* + * we've been released from the holding pen: secondary_stack + * should now contain the SVC stack for this core + */ + b secondary_startup + + .align +1: .long . + .long pen_release
...
Quoted 90 lines
arch/arm/mach-spear13xx/headsmp.S new file +90
-0+volatile int __cpuinitdata pen_release = -1; +static DEFINE_SPINLOCK(boot_lock); + +/* + * Write pen_release in a way that is guaranteed to be visible to all + * observers, irrespective of whether they're taking part in coherency + * or not. This is necessary for the hotplug code to work reliably. + */ +static void write_pen_release(int val) +{ + pen_release = val; + smp_wmb(); + __cpuc_flush_dcache_area((void *)&pen_release, sizeof(pen_release)); + outer_clean_range(__pa(&pen_release), __pa(&pen_release + 1)); +} + +static void __iomem *scu_base_addr(void) +{ + return __io_address(SPEAR13XX_SCU_BASE); +} + +void __cpuinit platform_secondary_init(unsigned int cpu) +{ + /* + * if any interrupts are already enabled for the primary + * core (e.g. timer irq), then they will not have been enabled + * for us: do so + */ + gic_secondary_init(0); + + /* + * let the primary processor know we're out of the + * pen, then head off into the C entry point + */ + write_pen_release(-1); + + /* + * Synchronise with the boot thread. + */ + spin_lock(&boot_lock); + spin_unlock(&boot_lock); +} + +int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) +{ + unsigned long timeout; + + /* + * set synchronisation state between this boot processor + * and the secondary one + */ + spin_lock(&boot_lock); + + /* + * The secondary processor is waiting to be released from + * the holding pen - release it, then wait for it to flag + * that it has been released by resetting pen_release. + * + * Note that "pen_release" is the hardware CPU ID, whereas + * "cpu" is Linux's internal ID. + */ + write_pen_release(cpu); + + timeout = jiffies + (1 * HZ); + while (time_before(jiffies, timeout)) { + smp_rmb(); + if (pen_release == -1) + break; + + udelay(10); + } + + /* + * now the secondary core is starting up let it run its + * calibrations, then wait for it to finish + */ + spin_unlock(&boot_lock); + + return pen_release != -1 ? -ENOSYS : 0; +} + +/* + * Initialise the CPU possible map early - this describes the CPUs + * which may be present or become present in the system. + */ +void __init smp_init_cpus(void) +{ + void __iomem *scu_base = scu_base_addr(); + unsigned int i, ncores; +
arch/arm/mach-spear13xx/headsmp.S
Quoted 10 lines
arch/arm/mach-spear13xx/headsmp.S new file +10
-0+ ncores = scu_base ? scu_get_core_count(scu_base) : 1; + + for (i = 0; i < ncores; i++) + set_cpu_possible(i, true); +} + +static void __init wakeup_secondary(void) +{ + /* nobody is to be released from the pen yet */ + pen_release = -1;
But pen_release starts off as -1, so is this really needed?
arch/arm/mach-spear13xx/headsmp.S
Quoted 11 lines
arch/arm/mach-spear13xx/headsmp.S new file +11
-0+ + /* + * Write the address of secondary startup into the system-wide + * location (presently it is in SRAM). The BootMonitor waits + * for this register to become non-zero. + * We must also send an sev to wake it up + */ + __raw_writel(BSYM(virt_to_phys(spear13xx_secondary_startup)), + __io_address(SPEAR13XX_SYS_LOCATION)); + + mb();
Do you really need to sync back to L2, or will a dsb() do here - and as the spinlock code uses dsb() + sev() together, would it make sense to combine the two? (dsb() is required to ensure all previous writes are visible prior to the sev() executing.)
PATCH v4 26/62 ST SPEAr: Adding support for SSP PL022
In reply to Viresh Kumararch/arm/mach-spear13xx/spear1300_evb.c line 15
Quoted 9 lines · Viresh Kumar
arch/arm/mach-spear13xx/spear1300_evb.c +1
-0@@ -12,7 +12,10 @@*/ #include <linux/types.h> +#include <linux/gpio.h>
:-)
arch/arm/mach-spear3xx/spear300_evb.c line 21
Quoted 12 lines
arch/arm/mach-spear3xx/spear300_evb.c +3
-0@@ -15,10 +15,14 @@#include <linux/mtd/fsmc.h> #include <asm/mach/arch.h> #include <asm/mach-types.h> +#include <linux/spi/flash.h> +#include <linux/spi/spi.h> #include <mach/generic.h> +#include <mach/gpio.h>
:-(
arch/arm/mach-spear3xx/spear310_evb.c line 21
Quoted 12 lines
arch/arm/mach-spear3xx/spear310_evb.c +3
-0@@ -15,9 +15,13 @@#include <linux/mtd/fsmc.h> #include <asm/mach/arch.h> #include <asm/mach-types.h> +#include <linux/spi/flash.h> +#include <linux/spi/spi.h> #include <mach/generic.h> +#include <mach/gpio.h>
:-(
arch/arm/mach-spear3xx/spear320_evb.c line 21
Quoted 12 lines
arch/arm/mach-spear3xx/spear320_evb.c +3
-0@@ -15,9 +15,13 @@#include <linux/mtd/fsmc.h> #include <asm/mach/arch.h> #include <asm/mach-types.h> +#include <linux/spi/flash.h> +#include <linux/spi/spi.h> #include <mach/generic.h> +#include <mach/gpio.h>
:-(
arch/arm/mach-spear6xx/spear600_evb.c line 22
Quoted 13 lines
arch/arm/mach-spear6xx/spear600_evb.c +4
-0@@ -15,15 +15,23 @@#include <linux/mtd/fsmc.h> #include <asm/mach/arch.h> #include <asm/mach-types.h> +#include <linux/gpio.h> +#include <linux/spi/flash.h> +#include <linux/spi/spi.h> #include <mach/generic.h> +#include <mach/gpio.h>
:-(
Quoted 15 lines
arch/arm/plat-spear/include/plat/spi.h new file +9
-0@@ -0,0 +1,74 @@ +/* +* arch/arm/plat-spear/include/plat/spi.h +* +* SPI board specific definitions common to multiple boards on multiple +* machines. +* +* Copyright (C) 2010 ST Microelectronics +* Viresh Kumar<[email protected]> +*
arch/arm/plat-spear/include/plat/spi.h line 19
Quoted 10 lines
arch/arm/plat-spear/include/plat/spi.h new file +10
-0+* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#ifndef __PLAT_SPI_H +#define __PLAT_SPI_H + +#include <linux/amba/pl022.h> +#include <linux/gpio.h>
:-)
PATCH v4 5/62 ST SPEAr: Formalized timer support
In reply to Viresh KumarHi,
Quoted 18 lines · Viresh Kumar
arch/arm/mach-spear3xx/spear3xx.c +10
-1@@ -523,5 +523,35 @@ struct pmx_dev pmx_plgpio_45_46_49_50 = { .mode_count = ARRAY_SIZE(pmx_plgpio_45_46_49_50_modes), .enb_on_reset = 1, }; +#endif /* CONFIG_MACH_SPEAR310 || CONFIG_MACH_SPEAR320 */ -#endif +static void __init spear3xx_timer_init (void ) +{ +char pclk_name[] ="pll3_48m_clk" ; +struct clk *gpt_clk, *pclk; + +/* get the system timer clock */ + gpt_clk =clk_get_sys ("gpt0" ,NULL ); +if (!gpt_clk) { +pr_err ("%s:couldn't get clk for gpt\n" , __func__);
arch/arm/mach-spear3xx/spear3xx.c struct pmx_dev pmx_plgpio_45_46_49_50 = { · line 546
Quoted 10 lines
arch/arm/mach-spear3xx/spear3xx.c +10
-0+BUG (); + } + +/* get the suitable parent clock for timer*/ + pclk =clk_get (NULL , pclk_name); +if (!pclk) { +pr_err ("%s:couldn't get %s as parent for gpt\n" , + __func__, pclk_name); +BUG (); + }
These should probably be using IS_ERR() rather than checking against NULL to be consistent with the API.
[...]
arch/arm/mach-spear6xx/spear600_evb.c static void __init spear600_evb_init(void) · line 45
Quoted 9 lines
arch/arm/mach-spear6xx/spear600_evb.c +1
-0@@ -42,10 +42,11 @@ static void __init spear600_evb_init(void)amba_device_register (amba_devs[i], &iomem_resource); } +
Nitpick, why the extra newline?
Quoted 26 lines
arch/arm/mach-spear6xx/spear600_evb.c +1
-1MACHINE_START (SPEAR600 ,"ST-SPEAR600-EVB" ) .boot_params = 0x00000100, .map_io = spear6xx_map_io, .init_irq = spear6xx_init_irq, - .timer = &spear_sys_timer, + .timer = &spear6xx_timer, .init_machine = spear600_evb_init,MACHINE_END arch/arm/mach-spear6xx/spear6xx.c +10
-0@@ -155,3 +155,34 @@ void __init spear6xx_map_io(void)/* This will initialize clock framework */ clk_init (); } + +static void __init spear6xx_timer_init (void ) +{ +char pclk_name[] ="pll3_48m_clk" ; +struct clk *gpt_clk, *pclk; + +/* get the system timer clock */ + gpt_clk =clk_get_sys ("gpt0" ,NULL ); +if (!gpt_clk) { +pr_err ("%s:couldn't get clk for gpt\n" , __func__);
arch/arm/mach-spear6xx/spear6xx.c void __init spear6xx_map_io(void) · line 177
Quoted 10 lines
arch/arm/mach-spear6xx/spear6xx.c +10
-0+BUG (); + } + +/* get the suitable parent clock for timer*/ + pclk =clk_get (NULL , pclk_name); +if (!pclk) { +pr_err ("%s:couldn't get %s as parent for gpt\n" , + __func__, pclk_name); +BUG (); + }
As above, IS_ERR() would be better here.
Jamie
PATCH v4 25/62 ST SPEAr: Added PCIE host controller base driver support.
In reply to Viresh KumarReview
Quoted 2 lines · Viresh Kumar
(quoted diff) +2
-0+ clk = clk_get_sys("pcie1", NULL); + if (!clk) {
IS_ERR(clk)
Quoted 5 lines
arch/arm/mach-spear13xx/pcie.c new file +5
-0+pr_err ("%s:couldn't get clk for pcie1\n" , + __func__); +continue ; + } +if (clk_enable (clk)) {
arch/arm/mach-spear13xx/pcie.c line 576
Quoted 10 lines
arch/arm/mach-spear13xx/pcie.c new file +10
-0+pr_err ("%s:couldn't enable clk for pcie1\n" , + __func__); +continue ; + } + }else if (port ==2 ) { +/* Ideally CFG Clock should have been also enabled +* here. But it is done currently during board +* init routne*/ + clk =clk_get_sys ("pcie2" ,NULL ); +if (!clk) {
IS_ERR(clk)
Quoted 15 lines
arch/arm/mach-spear13xx/pcie.c new file +15
-0+pr_err ("%s:couldn't get clk for pcie2\n" , + __func__); +continue ; + } +if (clk_enable (clk)) { +pr_err ("%s:couldn't enable clk for pcie2\n" , + __func__); +continue ; + } + } + +if ((*pcie_port_is_host)(port)) +add_pcie_port (port, spr_pcie_base[port], + spr_pcie_app_base[port]); + }
...
Quoted 6 lines
arch/arm/mach-spear13xx/spear13xx.c +6
-0+#ifdef CONFIG_PCIEPORTBUS +/* PCIE0 clock always needs to be enabled if any of the three PCIE port +* have to be used. So call this function from the board initilization +* file. Ideally , all controller should have been independent from +* others with respect to clock. +*/
arch/arm/mach-spear13xx/spear13xx.c struct platform_device spear13xx_rtc_device = { · line 317
Quoted 10 lines
arch/arm/mach-spear13xx/spear13xx.c +10
-0+int enable_pcie0_clk (void ) +{ +struct clk *clk; +/*Enable all CLK in CFG registers here only. Idealy only PCIE0 +* should have been enabled. But Controler does not work +* properly if PCIE1 and PCIE2's CFG CLK is enabled in stages. +*/ +writel (PCIE0_CFG_VAL |PCIE1_CFG_VAL |PCIE2_CFG_VAL ,PCIE_CFG ); + clk =clk_get_sys ("pcie0" ,NULL ); +if (!clk) {
IS_ERR(clk)
PATCH v4 32/62 ST SPEAr 13xx : Adding support for SPEAr1310
In reply to Viresh KumarHi,
Quoted 8 lines · Viresh Kumar
From: Bhupesh Sharma <[email protected]>
This patch adds support for SPEAr1310 Machine and evaluation board
Signed-off-by Bhupesh Sharma <[email protected]>Signed-off-by shiraz hashim <[email protected]>Signed-off-by Viresh Kumar <[email protected]>---
[...]
Quoted 64 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +57
-0@@ -0,0 +1,133 @@ +/* +* arch/arm/mach-spear13xx/spear1310_evb.c +* +* SPEAr1310 evaluation board source file +* +* Copyright (C) 2010 ST Microelectronics +* Bhupesh Sharma <[email protected]> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#include <linux/types.h> +#include <linux/gpio.h> +#include <linux/mtd/nand.h> +#include <linux/mtd/fsmc.h> +#include <linux/spi/flash.h> +#include <linux/spi/spi.h> +#include <asm/mach/arch.h> +#include <asm/mach-types.h> +#include <plat/fsmc.h> +#include <plat/keyboard.h> +#include <plat/spi.h> +#include <mach/generic.h> +#include <mach/spear.h> +#include <mach/pcie.h> + +static struct amba_device *amba_devs[]__initdata = { +/* spear13xx specific devices */ + &spear13xx_gpio_device[0 ], + &spear13xx_gpio_device[1 ], + &spear13xx_ssp_device, + &spear13xx_uart_device, +}; + +static struct platform_device *plat_devs[]__initdata = { +/* spear13xx specific devices */ + &spear13xx_ehci0_device, + &spear13xx_ehci1_device, + &spear13xx_i2c_device, + &spear13xx_kbd_device, + &spear13xx_nand_device, + &spear13xx_ohci0_device, + &spear13xx_ohci1_device, + &spear13xx_rtc_device, + &spear13xx_sdhci_device, + +/* spear1310 specific devices */ + &spear1310_can0_device, + &spear1310_can1_device, +}; + +/* keyboard specific platform data */ +static DECLARE_KEYMAP (keymap); +static struct matrix_keymap_data keymap_data = { + .keymap = keymap,
arch/arm/mach-spear13xx/spear1310_evb.c line 67
Quoted 10 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +10
-0+ .keymap_size = ARRAY_SIZE(keymap), +}; + +static struct kbd_platform_data kbd_data = { + .keymap = &keymap_data, + .rep =1 , +}; + +static struct spi_board_info __initdata spi_board_info[] = { +};
AFAICT spi_register_board_info() doesn't do anything when passed this empty array so both the array and call could be removed.
Quoted 14 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +14
-0+ +#ifdef CONFIG_PCIEPORTBUS +/* this function is needed for PCIE host and device driver. Same +* controller can not be programmed as host as well as device. So host +* driver must call this function and if this function returns 1 then +* only host should add that particular port as RC. +* A port to be added as device, one must also add device's information +* in plat_devs array defined in this file. +* it is the responsibility of calling function to not send port number +* greter than max no of controller(3) +*/ +int spear1310_pcie_port_is_host (int port) +{ +switch (port) {
arch/arm/mach-spear13xx/spear1310_evb.c line 91
Quoted 10 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +10
-0+case 0 : +return 0 ; +case 1 : +return 1 ; +case 2 : + return 1; + } +return -EINVAL ; +} +#endif
It looks like this can be made static. Also, given the comment, is it worth adding a BUG_ON(port > 3)?
Quoted 12 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +12
-0+static void __init spear1310_evb_init (void ) +{ +unsigned int i; + +/* set keyboard plat data */ +kbd_set_plat_data (&spear13xx_kbd_device, &kbd_data); + +/* set nand device's plat data */ +fsmc_nand_set_plat_data (&spear13xx_nand_device,NULL ,0 , +NAND_SKIP_BBTSCAN ,FSMC_NAND_BW8 ); +nand_mach_init (FSMC_NAND_BW8 ); +
arch/arm/mach-spear13xx/spear1310_evb.c line 114
Quoted 10 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +10
-0+/* call spear1310 machine init function */ +spear1310_init (); + +/* Register slave devices on the I2C buses */ +i2c_register_default_devices (); + +#ifdef CONFIG_PCIEPORTBUS +/* Enable PCIE0 clk */ +enable_pcie0_clk (); +pcie_init (&spear1310_pcie_port_is_host);
No '&' needed before function name.
Jamie
PATCH v4 38/62 SPEAr CPU freq: Adding support for CPU Freq framework
In reply to Viresh KumarHi,
Quoted 7 lines · Viresh Kumar
From: Deepak Sikri <[email protected]>
Signed-off-by Deepak Sikri <[email protected]>Signed-off-by Rajeev Kumar <[email protected]>Signed-off-by shiraz hashim <[email protected]>Signed-off-by Viresh Kumar <[email protected]>---
[...]
Quoted 65 lines
arch/arm/plat-spear/cpufreq.c new file +59
-0@@ -0,0 +1,159 @@ +/* +* arch/arm/plat-spear/cpufreq.c +* +* CPU Frequency Scaling for SPEAr platform +* +* Copyright (C) 2010 ST Microelectronics +* Deepak Sikri<[email protected]> +* +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/cpufreq.h> +#include <linux/delay.h> +#include <linux/init.h> +#include <linux/err.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <asm/system.h> +#include <mach/hardware.h> + +#define CPU_CLK "cpu_clk" + +#ifdef CONFIG_ARCH_SPEAR13XX +#define MIN_CPU_FREQ 200000 +#define MAX_CPU_FREQ 500000 + +static u32 spear_cpu_freq[] = { +200000 ,/* 200 MHZ */ +250000 ,/* 250 MHZ */ +332000 ,/* 332 MHZ */ +400000 ,/* 400 MHZ */ +500000 ,/* 500 MHZ */ +}; +#elif defined(CONFIG_ARCH_SPEAR6XX ) || defined(CONFIG_ARCH_SPEAR3XX ) +#define MIN_CPU_FREQ 166000 +#define MAX_CPU_FREQ 332000 + +static u32 spear_cpu_freq[] = { +166000 ,/* 166 MHZ */ +266000 ,/* 266 MHZ */ +332000 ,/* 333 MHZ */ +}; +#endif + +static struct +cpufreq_frequency_table spear_freq_tbl[ARRAY_SIZE (spear_cpu_freq) +1 ]; +static struct clk *cpu_clk; + +int spear_cpufreq_verify (struct cpufreq_policy *policy) +{ +return cpufreq_frequency_table_verify (policy, spear_freq_tbl); +} +
arch/arm/plat-spear/cpufreq.c line 69
Quoted 10 lines
arch/arm/plat-spear/cpufreq.c new file +10
-0+unsigned int spear_cpufreq_get (unsigned int cpu) +{ +unsigned long rate; + +if (cpu) +return 0 ; + + rate =clk_get_rate (cpu_clk) /1000 ; +return rate; +}
Can this be simplified to:
unsigned int spear_cpufreq_get(unsigned int cpu)
{
return cpu ? 0 : clk_get_rate(cpu_clk) / 1000;
}? It could also be made static.
Quoted 15 lines
arch/arm/plat-spear/cpufreq.c new file +15
-0+ +static int spear_cpufreq_target (struct cpufreq_policy *policy, +unsigned int target_freq,unsigned int relation) +{ +struct cpufreq_freqs freqs; +int ret =0 ; +int index; + +if (policy->cpu !=0 ) +return -EINVAL ; + +if (cpufreq_frequency_table_target (policy, spear_freq_tbl, + target_freq, relation, &index)) +return -EINVAL ; +
arch/arm/plat-spear/cpufreq.c line 94
Quoted 10 lines
arch/arm/plat-spear/cpufreq.c new file +10
-0+ freqs.old =spear_cpufreq_get (0 ); + freqs.new = spear_cpu_freq[index]; + freqs.cpu = policy->cpu; + +if (freqs.old == target_freq) +return 0 ; + +cpufreq_notify_transition (&freqs,CPUFREQ_PRECHANGE ); + ret =clk_set_rate (cpu_clk, freqs.new *1000 ); +cpufreq_notify_transition (&freqs,CPUFREQ_POSTCHANGE );
If clk_set_rate() failed then do you need to do freqs.new = clk_get_rate(cpu_clk) before doing the CPUFREQ_POSTCHANGE to make sure you don't notify the wrong frequency?
Quoted 21 lines
arch/arm/plat-spear/cpufreq.c new file +21
-0+ +return ret; +} + +static int spear_cpufreq_init (struct cpufreq_policy *policy) +{ +int result; +int i =0 ; + +if (policy->cpu !=0 ) +return -EINVAL ; + + cpu_clk =clk_get (NULL ,CPU_CLK ); +if (IS_ERR (cpu_clk)) +return PTR_ERR (cpu_clk); + + policy->cpuinfo.min_freq =MIN_CPU_FREQ ; + policy->cpuinfo.max_freq =MAX_CPU_FREQ ; + policy->cur = policy->min = policy->max =spear_cpufreq_get (0 ); + +for (i =0 ; i <ARRAY_SIZE (spear_cpu_freq); i++) {
arch/arm/plat-spear/cpufreq.c line 125
Quoted 10 lines
arch/arm/plat-spear/cpufreq.c new file +10
-0+ spear_freq_tbl[i].index = i; + spear_freq_tbl[i].frequency = spear_cpu_freq[i]; + } + + spear_freq_tbl[i].index = i; + spear_freq_tbl[i].frequency =CPUFREQ_TABLE_END ; + result =cpufreq_frequency_table_cpuinfo (policy, spear_freq_tbl); +if (!result) +cpufreq_frequency_table_get_attr (spear_freq_tbl, + policy->cpu);
result doesn't appear to be used to do anything other than check the return of cpufreq_frequency_table_cpuinfo() so could tou just eliminate that local variable?
arch/arm/plat-spear/cpufreq.c line 127
Quoted 2 lines
arch/arm/plat-spear/cpufreq.c new file +2
-0+ + policy->cpuinfo.transition_latency =300 *1000 ;/*250 uS*/
The comment doesn't appear to match the value here.
Quoted 22 lines
arch/arm/plat-spear/cpufreq.c new file +22
-0+ +return 0 ; +} + +static int spear_cpufreq_exit (struct cpufreq_policy *policy) +{ +clk_put (cpu_clk); +return 0 ; +} + +static struct freq_attr *spear_cpufreq_attr[] = { + &cpufreq_freq_attr_scaling_available_freqs, +NULL , +}; + +static struct cpufreq_driver spear_driver = { + .flags =CPUFREQ_STICKY , + .verify = spear_cpufreq_verify, + .target = spear_cpufreq_target, + .get = spear_cpufreq_get, + .init = spear_cpufreq_init, + .exit = spear_cpufreq_exit,
arch/arm/plat-spear/cpufreq.c line 159
Quoted 10 lines
arch/arm/plat-spear/cpufreq.c new file +10
-0+ .name = "spear_cpufreq", + .attr = spear_cpufreq_attr, +}; + +static int __init spear_cpufreq_register (void ) +{ +return cpufreq_register_driver (&spear_driver); +} + +arch_initcall (spear_cpufreq_register);
Jamie
PATCH v4 38/62 SPEAr CPU freq: Adding support for CPU Freq framework
Hi James,
Quoted 92 lines · Jamie Iles
Hi,
Quoted 8 lines · Viresh Kumar
From: Deepak Sikri <[email protected]>
Signed-off-by Deepak Sikri <[email protected]>Signed-off-by Rajeev Kumar <[email protected]>Signed-off-by shiraz hashim <[email protected]>Signed-off-by Viresh Kumar <[email protected]>---
[...]
Quoted 66 lines
arch/arm/plat-spear/cpufreq.c new file +59
-0@@ -0,0 +1,159 @@ +/* +* arch/arm/plat-spear/cpufreq.c +* +* CPU Frequency Scaling for SPEAr platform +* +* Copyright (C) 2010 ST Microelectronics +* Deepak Sikri<[email protected]> +* +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/cpufreq.h> +#include <linux/delay.h> +#include <linux/init.h> +#include <linux/err.h> +#include <linux/clk.h> +#include <linux/io.h> +#include <asm/system.h> +#include <mach/hardware.h> + +#define CPU_CLK "cpu_clk" + +#ifdef CONFIG_ARCH_SPEAR13XX +#define MIN_CPU_FREQ 200000 +#define MAX_CPU_FREQ 500000 + +static u32 spear_cpu_freq[] = { +200000 ,/* 200 MHZ */ +250000 ,/* 250 MHZ */ +332000 ,/* 332 MHZ */ +400000 ,/* 400 MHZ */ +500000 ,/* 500 MHZ */ +}; +#elif defined(CONFIG_ARCH_SPEAR6XX ) || defined(CONFIG_ARCH_SPEAR3XX ) +#define MIN_CPU_FREQ 166000 +#define MAX_CPU_FREQ 332000 + +static u32 spear_cpu_freq[] = { +166000 ,/* 166 MHZ */ +266000 ,/* 266 MHZ */ +332000 ,/* 333 MHZ */ +}; +#endif + +static struct +cpufreq_frequency_table spear_freq_tbl[ARRAY_SIZE (spear_cpu_freq) +1 ]; +static struct clk *cpu_clk; + +int spear_cpufreq_verify (struct cpufreq_policy *policy) +{ +return cpufreq_frequency_table_verify (policy, spear_freq_tbl); +} +arch/arm/plat-spear/cpufreq.c line 69
Quoted 10 lines
arch/arm/plat-spear/cpufreq.c new file +10
-0+unsigned int spear_cpufreq_get (unsigned int cpu) +{ +unsigned long rate; + +if (cpu) +return 0 ; + + rate =clk_get_rate (cpu_clk) /1000 ; +return rate; +}Can this be simplified to:
Quoted 8 lines
unsigned int spear_cpufreq_get(unsigned int cpu) { return cpu ? 0 : clk_get_rate(cpu_clk) / 1000; }? It could also be made static.
Agreed, we will update this in the next patch
Quoted 21 lines
Quoted 21 lines
arch/arm/plat-spear/cpufreq.c new file +21
-0+ +static int spear_cpufreq_target (struct cpufreq_policy *policy, +unsigned int target_freq,unsigned int relation) +{ +struct cpufreq_freqs freqs; +int ret =0 ; +int index; + +if (policy->cpu !=0 ) +return -EINVAL ; + +if (cpufreq_frequency_table_target (policy, spear_freq_tbl, + target_freq, relation, &index)) +return -EINVAL ; + + freqs.old =spear_cpufreq_get (0 ); + freqs.new = spear_cpu_freq[index]; + freqs.cpu = policy->cpu; + +if (freqs.old == target_freq) +return 0 ;
Quoted 10 lines
arch/arm/plat-spear/cpufreq.c line 94
Quoted 5 lines
arch/arm/plat-spear/cpufreq.c new file +4
-0+ +cpufreq_notify_transition (&freqs,CPUFREQ_PRECHANGE ); + ret =clk_set_rate (cpu_clk, freqs.new *1000 ); +cpufreq_notify_transition (&freqs,CPUFREQ_POSTCHANGE );If
clk_set_rate()failed then do you need to do freqs.new =clk_get_rate(cpu_clk)before doing theCPUFREQ_POSTCHANGEto make sure you don't notify the wrong frequency?
I do have a point over here. In few of the drivers where the the pre notifiers have been added, the operations have been stopped (assume a network driver where we stalled a dma operation), and then we set the clock rate, followed by a post notifier where driver resumes it operations.
Now lets take the case, when the clock set rate fails ( Most failure could only be when the driver is unable to find any clock rate which is less then/equal to requested rate) .
The post transition notifier should happen so as to allow the driver to resume its functions. If there are no clock rate changes because of set rate failures, the driver would be aware of that by using calls such as clk_get_rate, and would carry forward it's operations accordingly.
How do you suggest to go about it ?
Quoted 27 lines
Quoted 27 lines
arch/arm/plat-spear/cpufreq.c new file +27
-0+ +return ret; +} + +static int spear_cpufreq_init (struct cpufreq_policy *policy) +{ +int result; +int i =0 ; + +if (policy->cpu !=0 ) +return -EINVAL ; + + cpu_clk =clk_get (NULL ,CPU_CLK ); +if (IS_ERR (cpu_clk)) +return PTR_ERR (cpu_clk); + + policy->cpuinfo.min_freq =MIN_CPU_FREQ ; + policy->cpuinfo.max_freq =MAX_CPU_FREQ ; + policy->cur = policy->min = policy->max =spear_cpufreq_get (0 ); + +for (i =0 ; i <ARRAY_SIZE (spear_cpu_freq); i++) { + spear_freq_tbl[i].index = i; + spear_freq_tbl[i].frequency = spear_cpu_freq[i]; + } + + spear_freq_tbl[i].index = i; + spear_freq_tbl[i].frequency =CPUFREQ_TABLE_END ;
Quoted 10 lines
arch/arm/plat-spear/cpufreq.c line 125
Quoted 5 lines
arch/arm/plat-spear/cpufreq.c new file +4
-0+ result =cpufreq_frequency_table_cpuinfo (policy, spear_freq_tbl); +if (!result) +cpufreq_frequency_table_get_attr (spear_freq_tbl, + policy->cpu);result doesn't appear to be used to do anything other than check the return of
cpufreq_frequency_table_cpuinfo()so could tou just eliminate that local variable?
We will do it
Quoted 6 lines
arch/arm/plat-spear/cpufreq.c line 127
Quoted 3 lines
arch/arm/plat-spear/cpufreq.c new file +2
-0+ + policy->cpuinfo.transition_latency =300 *1000 ;/*250 uS*/ The comment doesn't appear to match the value here.
Will update the comment
Quoted 27 lines
Quoted 27 lines
arch/arm/plat-spear/cpufreq.c new file +27
-0+ +return 0 ; +} + +static int spear_cpufreq_exit (struct cpufreq_policy *policy) +{ +clk_put (cpu_clk); +return 0 ; +} + +static struct freq_attr *spear_cpufreq_attr[] = { + &cpufreq_freq_attr_scaling_available_freqs, +NULL , +}; + +static struct cpufreq_driver spear_driver = { + .flags =CPUFREQ_STICKY , + .verify = spear_cpufreq_verify, + .target = spear_cpufreq_target, + .get = spear_cpufreq_get, + .init = spear_cpufreq_init, + .exit = spear_cpufreq_exit, + .name ="spear_cpufreq" , + .attr = spear_cpufreq_attr, +}; + +static int __init spear_cpufreq_register (void )
Quoted 10 lines
arch/arm/plat-spear/cpufreq.c line 159
Quoted 6 lines
arch/arm/plat-spear/cpufreq.c new file +5
-0+{ +return cpufreq_register_driver (&spear_driver); +} + +arch_initcall (spear_cpufreq_register);Jamie
.
regards
Deepak
v4 cover Updating SPEAr Support
In reply to Russell King - ARM LinuxQuoted 3 lines · Russell King - ARM Linux
Does this mean I can get rid of the entire set of spear patches in the patch system now?
.
Ya. Sure.
PATCH v4 5/62 ST SPEAr: Formalized timer support
In reply to Jamie IlesJamie,
Thanks for reviewing our patches.
Quoted 26 lines · Jamie Iles
Hi,
Quoted 23 lines · Viresh Kumar
arch/arm/mach-spear3xx/spear3xx.c +15
-1@@ -523,5 +523,35 @@ struct pmx_dev pmx_plgpio_45_46_49_50 = { .mode_count = ARRAY_SIZE(pmx_plgpio_45_46_49_50_modes), .enb_on_reset = 1, }; +#endif /* CONFIG_MACH_SPEAR310 || CONFIG_MACH_SPEAR320 */ -#endif +static void __init spear3xx_timer_init (void ) +{ +char pclk_name[] ="pll3_48m_clk" ; +struct clk *gpt_clk, *pclk; + +/* get the system timer clock */ + gpt_clk =clk_get_sys ("gpt0" ,NULL ); +if (!gpt_clk) { +pr_err ("%s:couldn't get clk for gpt\n" , __func__); +BUG (); + } + +/* get the suitable parent clock for timer*/ + pclk =clk_get (NULL , pclk_name);
Quoted 9 lines
arch/arm/mach-spear3xx/spear3xx.c struct pmx_dev pmx_plgpio_45_46_49_50 = { · line 546
Quoted 5 lines
arch/arm/mach-spear3xx/spear3xx.c +5
-0+if (!pclk) { +pr_err ("%s:couldn't get %s as parent for gpt\n" , + __func__, pclk_name); +BUG (); + }These should probably be using
IS_ERR()rather than checking against NULL to be consistent with the API.
Ok.
Quoted 9 lines
[...]
Quoted 8 lines
arch/arm/mach-spear6xx/spear600_evb.c +0
-0@@ -42,10 +42,11 @@ static void __init spear600_evb_init(void)amba_device_register (amba_devs[i], &iomem_resource); }
Quoted 4 lines
arch/arm/mach-spear6xx/spear600_evb.c static void __init spear600_evb_init(void) · line 45
Quoted 1 line
arch/arm/mach-spear6xx/spear600_evb.c +1
-0+Nitpick, why the extra newline?
Will be removed.
Quoted 30 lines
Quoted 30 lines
arch/arm/mach-spear6xx/spear600_evb.c +1
-1MACHINE_START (SPEAR600 ,"ST-SPEAR600-EVB" ) .boot_params = 0x00000100, .map_io = spear6xx_map_io, .init_irq = spear6xx_init_irq, - .timer = &spear_sys_timer, + .timer = &spear6xx_timer, .init_machine = spear600_evb_init,MACHINE_END arch/arm/mach-spear6xx/spear6xx.c +14
-0@@ -155,3 +155,34 @@ void __init spear6xx_map_io(void)/* This will initialize clock framework */ clk_init (); } + +static void __init spear6xx_timer_init (void ) +{ +char pclk_name[] ="pll3_48m_clk" ; +struct clk *gpt_clk, *pclk; + +/* get the system timer clock */ + gpt_clk =clk_get_sys ("gpt0" ,NULL ); +if (!gpt_clk) { +pr_err ("%s:couldn't get clk for gpt\n" , __func__); +BUG (); + } + +/* get the suitable parent clock for timer*/
Quoted 9 lines
arch/arm/mach-spear6xx/spear6xx.c void __init spear6xx_map_io(void) · line 177
Quoted 6 lines
arch/arm/mach-spear6xx/spear6xx.c +6
-0+ pclk =clk_get (NULL , pclk_name); +if (!pclk) { +pr_err ("%s:couldn't get %s as parent for gpt\n" , + __func__, pclk_name); +BUG (); + }As above,
IS_ERR()would be better here.
Ok.
Signature · 1 line
viresh
PATCH v4 4/62 ST SPEAr: Making clock functions more generic
In reply to Russell King - ARM LinuxQuoted 16 lines · Russell King - ARM Linux
Quoted 8 lines · Viresh Kumar
/* pll1 configuration structure */
static structpll_clk_configpll1_config= {arch/arm/mach-spear3xx/clock.c +1
-0.mode_reg = PLL1_CTR, .cfg_reg = PLL1_FRQ, + .masks = &pll1_masks, };/* PLL1 clock */ ...
Quoted 5 lines
arch/arm/plat-spear/clock.c +2
-2- mode = (readl (config->mode_reg) >>PLL_MODE_SHIFT ) & -PLL_MODE_MASK ; + mode = (readl (config->mode_reg) >> config->masks->mode_shift) & + config->masks->mode_mask;...
Quoted 13 lines
arch/arm/plat-spear/include/plat/clock.h struct clk { · line 116
Quoted 7 lines
struct
pll_clk_config{arch/arm/plat-spear/include/plat/clock.h +3
-2-unsigned int *mode_reg; -unsigned int *cfg_reg; +u32 *mode_reg; +u32 *cfg_reg; +struct pll_clk_masks *masks; };Registers should have an
__iomemattribute on them. Preferably, but not absolutely necessary, should be void to prevent any direct dereferencing.
.
Yes, it should be void __iomem *
Signature · 1 line
viresh
PATCH v4 26/62 ST SPEAr: Adding support for SSP PL022
In reply to Russell King - ARM LinuxQuoted 94 lines · Russell King - ARM Linux
arch/arm/mach-spear13xx/spear1300_evb.c line 15
Quoted 9 lines · Viresh Kumar
arch/arm/mach-spear13xx/spear1300_evb.c +1
-0@@ -12,7 +12,10 @@*/ #include <linux/types.h> +#include <linux/gpio.h> :-)
arch/arm/mach-spear3xx/spear300_evb.c line 21
Quoted 12 lines
arch/arm/mach-spear3xx/spear300_evb.c +3
-0@@ -15,10 +15,14 @@#include <linux/mtd/fsmc.h> #include <asm/mach/arch.h> #include <asm/mach-types.h> +#include <linux/spi/flash.h> +#include <linux/spi/spi.h> #include <mach/generic.h> +#include <mach/gpio.h> :-(
arch/arm/mach-spear3xx/spear310_evb.c line 21
Quoted 12 lines
arch/arm/mach-spear3xx/spear310_evb.c +3
-0@@ -15,9 +15,13 @@#include <linux/mtd/fsmc.h> #include <asm/mach/arch.h> #include <asm/mach-types.h> +#include <linux/spi/flash.h> +#include <linux/spi/spi.h> #include <mach/generic.h> +#include <mach/gpio.h> :-(
arch/arm/mach-spear3xx/spear320_evb.c line 21
Quoted 12 lines
arch/arm/mach-spear3xx/spear320_evb.c +3
-0@@ -15,9 +15,13 @@#include <linux/mtd/fsmc.h> #include <asm/mach/arch.h> #include <asm/mach-types.h> +#include <linux/spi/flash.h> +#include <linux/spi/spi.h> #include <mach/generic.h> +#include <mach/gpio.h> :-(
arch/arm/mach-spear6xx/spear600_evb.c line 22
Quoted 13 lines
arch/arm/mach-spear6xx/spear600_evb.c +4
-0@@ -15,15 +15,23 @@#include <linux/mtd/fsmc.h> #include <asm/mach/arch.h> #include <asm/mach-types.h> +#include <linux/gpio.h> +#include <linux/spi/flash.h> +#include <linux/spi/spi.h> #include <mach/generic.h> +#include <mach/gpio.h> :-(
Quoted 20 lines
arch/arm/plat-spear/include/plat/spi.h new file +14
-0@@ -0,0 +1,74 @@ +/* +* arch/arm/plat-spear/include/plat/spi.h +* +* SPI board specific definitions common to multiple boards on multiple +* machines. +* +* Copyright (C) 2010 ST Microelectronics +* Viresh Kumar<[email protected]> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ +
Quoted 8 lines
arch/arm/plat-spear/include/plat/spi.h line 19
Quoted 5 lines
arch/arm/plat-spear/include/plat/spi.h new file +5
-0+#ifndef __PLAT_SPI_H +#define __PLAT_SPI_H + +#include <linux/amba/pl022.h> +#include <linux/gpio.h> :-)
.
Will use linux/gpio.h everywhere and not mach/gpio.h
Signature · 1 line
viresh
PATCH v4 25/62 ST SPEAr: Added PCIE host controller base driver support.
In reply to Russell King - ARM LinuxQuoted 50 lines · Russell King - ARM Linux
Review
Quoted 2 lines · Viresh Kumar
(quoted diff) +2
-0+ clk = clk_get_sys("pcie1", NULL); + if (!clk) {
IS_ERR(clk)Quoted 5 lines
arch/arm/mach-spear13xx/pcie.c new file +5
-0+pr_err ("%s:couldn't get clk for pcie1\n" , + __func__); +continue ; + } +if (clk_enable (clk)) {arch/arm/mach-spear13xx/pcie.c line 576
Quoted 10 lines
arch/arm/mach-spear13xx/pcie.c new file +10
-0+pr_err ("%s:couldn't enable clk for pcie1\n" , + __func__); +continue ; + } + }else if (port ==2 ) { +/* Ideally CFG Clock should have been also enabled +* here. But it is done currently during board +* init routne*/ + clk =clk_get_sys ("pcie2" ,NULL ); +if (!clk) {
IS_ERR(clk)Quoted 15 lines
arch/arm/mach-spear13xx/pcie.c new file +15
-0+pr_err ("%s:couldn't get clk for pcie2\n" , + __func__); +continue ; + } +if (clk_enable (clk)) { +pr_err ("%s:couldn't enable clk for pcie2\n" , + __func__); +continue ; + } + } + +if ((*pcie_port_is_host)(port)) +add_pcie_port (port, spr_pcie_base[port], + spr_pcie_app_base[port]); + }...
Quoted 10 lines
arch/arm/mach-spear13xx/spear13xx.c +10
-0+#ifdef CONFIG_PCIEPORTBUS +/* PCIE0 clock always needs to be enabled if any of the three PCIE port +* have to be used. So call this function from the board initilization +* file. Ideally , all controller should have been independent from +* others with respect to clock. +*/ +int enable_pcie0_clk (void ) +{ +struct clk *clk; +/*Enable all CLK in CFG registers here only. Idealy only PCIE0
Quoted 9 lines
arch/arm/mach-spear13xx/spear13xx.c struct platform_device spear13xx_rtc_device = { · line 317
Quoted 6 lines
arch/arm/mach-spear13xx/spear13xx.c +6
-0+* should have been enabled. But Controler does not work +* properly if PCIE1 and PCIE2's CFG CLK is enabled in stages. +*/ +writel (PCIE0_CFG_VAL |PCIE1_CFG_VAL |PCIE2_CFG_VAL ,PCIE_CFG ); + clk =clk_get_sys ("pcie0" ,NULL ); +if (!clk) {
IS_ERR(clk)
Ok.
Signature · 1 line
viresh
PATCH v4 6/62 ST SPEAr13XX: Adding machine specific header files
In reply to Russell King - ARM LinuxQuoted 15 lines · Russell King - ARM Linux
arch/arm/mach-spear13xx/include/mach/misc_regs.h line 23
Quoted 5 lines · Viresh Kumar
arch/arm/mach-spear13xx/include/mach/misc_regs.h new file +5
-0+#define MISC_BASE VA_SPEAR13XX_MISC_BASE + +/* General Configuration */ +#define SOC_CFG ((unsigned int *)(MISC_BASE + 0x000)) +#define BOOTSTRAP_CFG ((unsigned int *)(MISC_BASE + 0x004))You could really do with an
IOMEM()macro, thus:#ifndef
__ASSEMBLY__
#define IOMEM(x) ((void__iomem__force*)(x))
#else
#define IOMEM(x) (x)
#endif
Quoted 7 lines
You can then use that for stuff like
VA_SPEAR13XX_MISC_BASE, and all these definitions then become:#define
SOC_CFG(MISC_BASE+0x000)because GCC allows void pointer arithmetic (treats it as char).
Yes. I agree with this solution.
Actually the VA* macros are like:
#define VA_SPEAR13XX_MISC_BASE IO_ADDRESS(SPEAR13XX_MISC_BASE)
Adding IOMEM() over IO_ADDRESS(SPEAR13XX_MISC_BASE) will make it too long. And might cross 80 columns. Can we modify IO_ADDRESS() to use IOMEM()?
Signature · 1 line
viresh
PATCH v4 32/62 ST SPEAr 13xx : Adding support for SPEAr1310
In reply to Jamie IlesQuoted 7 lines · Jamie Iles
arch/arm/mach-spear13xx/spear1310_evb.c line 67
Quoted 2 lines · Viresh Kumar
arch/arm/mach-spear13xx/spear1310_evb.c new file +2
-0+static struct spi_board_info __initdata spi_board_info[] = { +};AFAICT
spi_register_board_info()doesn't do anything when passed this empty array so both the array and call could be removed.
Actually we don't have free gpio's in evb boards to use as chip select for ssp. So didn't add any spi devices here in this array. It is just added here so that anybody who needs to test it can simply come here, add a device and test. Can we keep it as it is?
Quoted 19 lines
Quoted 19 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +19
-0+ +#ifdef CONFIG_PCIEPORTBUS +/* this function is needed for PCIE host and device driver. Same +* controller can not be programmed as host as well as device. So host +* driver must call this function and if this function returns 1 then +* only host should add that particular port as RC. +* A port to be added as device, one must also add device's information +* in plat_devs array defined in this file. +* it is the responsibility of calling function to not send port number +* greter than max no of controller(3) +*/ +int spear1310_pcie_port_is_host (int port) +{ +switch (port) { +case 0 : +return 0 ; +case 1 : +return 1 ; +case 2 :
Quoted 9 lines
arch/arm/mach-spear13xx/spear1310_evb.c line 91
Quoted 5 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +5
-0+ return 1; + } +return -EINVAL ; +} +#endif It looks like this can be made static. Also, given the comment, is it worth adding a
BUG_ON(port > 3)?
will be done. BUG_ON() can be added here.
Quoted 16 lines
Quoted 16 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +16
-0+static void __init spear1310_evb_init (void ) +{ +unsigned int i; + +/* set keyboard plat data */ +kbd_set_plat_data (&spear13xx_kbd_device, &kbd_data); + +/* set nand device's plat data */ +fsmc_nand_set_plat_data (&spear13xx_nand_device,NULL ,0 , +NAND_SKIP_BBTSCAN ,FSMC_NAND_BW8 ); +nand_mach_init (FSMC_NAND_BW8 ); + +/* call spear1310 machine init function */ +spear1310_init (); + +/* Register slave devices on the I2C buses */
Quoted 9 lines
arch/arm/mach-spear13xx/spear1310_evb.c line 114
Quoted 6 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +6
-0+i2c_register_default_devices (); + +#ifdef CONFIG_PCIEPORTBUS +/* Enable PCIE0 clk */ +enable_pcie0_clk (); +pcie_init (&spear1310_pcie_port_is_host);No '&' needed before function name.
Ok.
Signature · 1 line
viresh
PATCH v4 7/62 ST SPEAr13XX: Adding machine specific src files
In reply to Russell King - ARM LinuxHello Russell,
Quoted 19 lines · Russell King - ARM Linux
Quoted 18 lines · Viresh Kumar
arch/arm/mach-spear13xx/headsmp.S new file +12
-0@@ -0,0 +1,96 @@ +/* + * arch/arm/mach-spear13XX/headsmp.S + * + * Picked from realview + * Copyright (c) 2010 ST Microelectronics Limited + * Shiraz Hashim <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +
Quoted 9 lines
arch/arm/mach-spear13xx/headsmp.S line 16
Quoted 4 lines
arch/arm/mach-spear13xx/headsmp.S new file +4
-0+#include <linux/linkage.h> +#include <linux/init.h> + + __INITIs this ever called after the kernel text is thrown away? What if we add support in the generic code to start with secondary CPUs offline as a power saving or boot time feature?
No. SPEAr platform has no additional feature to explicitly control this aspect of secondary CPUs. Does ARMv7 itself provdes some features for power management of secondary CPUs ?
Quoted 39 lines
Quoted 39 lines
arch/arm/mach-spear13xx/headsmp.S new file +39
-0+ +/* + * This one is picked from Tegra :- + * + * The secondary kernel init calls v7_flush_dcache_all before it enables + * the L1; however, the L1 comes out of reset in an undefined state, so + * the clean + invalidate performed by v7_flush_dcache_all causes a bunch + * of cache lines with uninitialized data and uninitialized tags to get + * written out to memory, which does really unpleasant things to the ain + * processor. We fix this by performing an invalidate, rather than a + * clean + invalidate, before jumping into the kernel. + */ +ENTRY(v7_invalidate_l1) + mov r0, #0 + mcr p15, 2, r0, c0, c0, 0 + mrc p15, 1, r0, c0, c0, 0 + + ldr r1, =0x7fff + and r2, r1, r0, lsr #13 + + ldr r1, =0x3ff + + and r3, r1, r0, lsr #3 @ NumWays - 1 + add r2, r2, #1 @ NumSets + + and r0, r0, #0x7 + add r0, r0, #4 @ SetShift + + clz r1, r3 @ WayShift + add r4, r3, #1 @ NumWays +1: sub r2, r2, #1 @ NumSets-- + mov r3, r4 @ Temp = NumWays +2: subs r3, r3, #1 @ Temp-- + mov r5, r3, lsl r1 + mov r6, r2, lsl r0 + orr r5, r5, r6 @ Reg = Temp<<WayShift)|(NumSets<<SetShift) + mcr p15, 0, r5, c7, c6, 2 + bgt 2b + cmp r2, #0
Quoted 9 lines
arch/arm/mach-spear13xx/headsmp.S line 60
Quoted 5 lines
arch/arm/mach-spear13xx/headsmp.S new file +5
-0+ bgt 1b + dsb + isb + mov pc, lr +ENDPROC(v7_invalidate_l1)This code appears to have its only caller commented out. Should it be removed?
yes, would remove it.
Quoted 131 lines
Quoted 36 lines
arch/arm/mach-spear13xx/headsmp.S new file +36
-0+ +/* + * spear13xx specific entry point for secondary CPUs. This provides + * a "holding pen" into which all secondary cores are held until we're + * ready for them to initialise. + */ +ENTRY(spear13xx_secondary_startup) + /* If we don't do this then we have a crash */ + + /* + * Since now this is being called from xloader so removing it + * here + */ +#if 0 + bl v7_invalidate_l1 +#endif + + mrc p15, 0, r0, c0, c0, 5 + and r0, r0, #15 + adr r4, 1f + ldmia r4, {r5, r6} + sub r4, r4, r5 + add r6, r6, r4 +pen: ldr r7, [r6] + cmp r7, r0 + bne pen + + /* + * we've been released from the holding pen: secondary_stack + * should now contain the SVC stack for this core + */ + b secondary_startup + + .align +1: .long . + .long pen_release...
Quoted 94 lines
arch/arm/mach-spear13xx/headsmp.S new file +94
-0+volatile int __cpuinitdata pen_release = -1; +static DEFINE_SPINLOCK(boot_lock); + +/* + * Write pen_release in a way that is guaranteed to be visible to all + * observers, irrespective of whether they're taking part in coherency + * or not. This is necessary for the hotplug code to work reliably. + */ +static void write_pen_release(int val) +{ + pen_release = val; + smp_wmb(); + __cpuc_flush_dcache_area((void *)&pen_release, sizeof(pen_release)); + outer_clean_range(__pa(&pen_release), __pa(&pen_release + 1)); +} + +static void __iomem *scu_base_addr(void) +{ + return __io_address(SPEAR13XX_SCU_BASE); +} + +void __cpuinit platform_secondary_init(unsigned int cpu) +{ + /* + * if any interrupts are already enabled for the primary + * core (e.g. timer irq), then they will not have been enabled + * for us: do so + */ + gic_secondary_init(0); + + /* + * let the primary processor know we're out of the + * pen, then head off into the C entry point + */ + write_pen_release(-1); + + /* + * Synchronise with the boot thread. + */ + spin_lock(&boot_lock); + spin_unlock(&boot_lock); +} + +int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) +{ + unsigned long timeout; + + /* + * set synchronisation state between this boot processor + * and the secondary one + */ + spin_lock(&boot_lock); + + /* + * The secondary processor is waiting to be released from + * the holding pen - release it, then wait for it to flag + * that it has been released by resetting pen_release. + * + * Note that "pen_release" is the hardware CPU ID, whereas + * "cpu" is Linux's internal ID. + */ + write_pen_release(cpu); + + timeout = jiffies + (1 * HZ); + while (time_before(jiffies, timeout)) { + smp_rmb(); + if (pen_release == -1) + break; + + udelay(10); + } + + /* + * now the secondary core is starting up let it run its + * calibrations, then wait for it to finish + */ + spin_unlock(&boot_lock); + + return pen_release != -1 ? -ENOSYS : 0; +} + +/* + * Initialise the CPU possible map early - this describes the CPUs + * which may be present or become present in the system. + */ +void __init smp_init_cpus(void) +{ + void __iomem *scu_base = scu_base_addr(); + unsigned int i, ncores; + + ncores = scu_base ? scu_get_core_count(scu_base) : 1; + + for (i = 0; i < ncores; i++) + set_cpu_possible(i, true);
Quoted 9 lines
arch/arm/mach-spear13xx/headsmp.S
Quoted 6 lines
arch/arm/mach-spear13xx/headsmp.S new file +6
-0+} + +static void __init wakeup_secondary(void) +{ + /* nobody is to be released from the pen yet */ + pen_release = -1;But
pen_releasestarts off as -1, so is this really needed?
Not required, would remove.
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-spear13xx/headsmp.S new file +8
-0+ + /* + * Write the address of secondary startup into the system-wide + * location (presently it is in SRAM). The BootMonitor waits + * for this register to become non-zero. + * We must also send an sev to wake it up + */ + __raw_writel(BSYM(virt_to_phys(spear13xx_secondary_startup)),
Quoted 8 lines
arch/arm/mach-spear13xx/headsmp.S
Quoted 3 lines
arch/arm/mach-spear13xx/headsmp.S new file +3
-0+ __io_address(SPEAR13XX_SYS_LOCATION)); + + mb();Do you really need to sync back to L2, or will a
dsb()do here - and as the spinlock code usesdsb()+sev()together, would it make sense to combine the two? (dsb()is required to ensure all previous writes are visible prior to thesev()executing.)
Presently L2 cache is initialized after we bootup secondary CPU but one can have the possibility of initializing L2 earlier also. So this would be safer.
Signature · 2 lines
regards Shiraz
PATCH v4 32/62 ST SPEAr 13xx : Adding support for SPEAr1310
In reply to viresh kumarQuoted 28 lines · viresh kumar
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +20
-0+ +#ifdef CONFIG_PCIEPORTBUS +/* this function is needed for PCIE host and device driver. Same +* controller can not be programmed as host as well as device. So host +* driver must call this function and if this function returns 1 then +* only host should add that particular port as RC. +* A port to be added as device, one must also add device's information +* in plat_devs array defined in this file. +* it is the responsibility of calling function to not send port number +* greter than max no of controller(3) +*/ +int spear1310_pcie_port_is_host (int port) +{ +switch (port) { +case 0 : +return 0 ; +case 1 : +return 1 ; +case 2 : +return 1 ;Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
arch/arm/mach-spear13xx/spear1310_evb.c line 91
Quoted 4 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +4
-0+ } +return -EINVAL ; +} +#endif It looks like this can be made static. Also, given the comment, is it worth adding a
BUG_ON(port > 3)?
Quoted 2 lines
will be done.
BUG_ON()can be added here.
There is another thought here. We may not require a BUG_ON here. Returning error would be better, so that driver can take steps accordingly. Also it is not that much blocking of a issue, that we need BUG_ON.
--
viresh
PATCH v4 32/62 ST SPEAr 13xx : Adding support for SPEAr1310
Quoted 29 lines · viresh kumar
Quoted 28 lines · viresh kumar
Quoted 28 lines
Quoted 28 lines
Quoted 16 lines
Quoted 16 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +16
-0+ +#ifdef CONFIG_PCIEPORTBUS +/* this function is needed for PCIE host and device driver. Same +* controller can not be programmed as host as well as device. So host +* driver must call this function and if this function returns 1 then +* only host should add that particular port as RC. +* A port to be added as device, one must also add device's information +* in plat_devs array defined in this file. +* it is the responsibility of calling function to not send port number +* greter than max no of controller(3) +*/ +int spear1310_pcie_port_is_host (int port) +{ +switch (port) { +case 0 : +return 0 ;Quoted 8 lines
arch/arm/mach-spear13xx/spear1310_evb.c line 91
Quoted 8 lines
arch/arm/mach-spear13xx/spear1310_evb.c new file +8
-0+case 1 : +return 1 ; +case 2 : + return 1; + } +return -EINVAL ; +} +#endif It looks like this can be made static. Also, given the comment, is it worth adding a
BUG_ON(port > 3)?
Quoted 6 lines
Quoted 2 lines
will be done.
BUG_ON()can be added here.There is another thought here. We may not require a
BUG_ONhere. Returning error would be better, so that driver can take steps accordingly. Also it is not that much blocking of a issue, that we needBUG_ON.
Ok, I don't have a problem with that!
Jamie
PATCH v4 38/62 SPEAr CPU freq: Adding support for CPU Freq framework
In reply to deepaksiQuoted 46 lines · deepaksi
Hi James,
Quoted 20 lines · Jamie Iles
Quoted 20 lines
arch/arm/plat-spear/cpufreq.c new file +20
-0+static int spear_cpufreq_target (struct cpufreq_policy *policy, +unsigned int target_freq,unsigned int relation) +{ +struct cpufreq_freqs freqs; +int ret =0 ; +int index; + +if (policy->cpu !=0 ) +return -EINVAL ; + +if (cpufreq_frequency_table_target (policy, spear_freq_tbl, + target_freq, relation, &index)) +return -EINVAL ; + + freqs.old =spear_cpufreq_get (0 ); + freqs.new = spear_cpu_freq[index]; + freqs.cpu = policy->cpu; + +if (freqs.old == target_freq) +return 0 ;Quoted 10 lines
arch/arm/plat-spear/cpufreq.c line 94
Quoted 5 lines
arch/arm/plat-spear/cpufreq.c new file +4
-0+ +cpufreq_notify_transition (&freqs,CPUFREQ_PRECHANGE ); + ret =clk_set_rate (cpu_clk, freqs.new *1000 ); +cpufreq_notify_transition (&freqs,CPUFREQ_POSTCHANGE );If
clk_set_rate()failed then do you need to do freqs.new =clk_get_rate(cpu_clk)before doing theCPUFREQ_POSTCHANGEto make sure you don't notify the wrong frequency?I do have a point over here. In few of the drivers where the the pre notifiers have been added, the operations have been stopped (assume a network driver where we stalled a dma operation), and then we set the clock rate, followed by a post notifier where driver resumes it operations.
Now lets take the case, when the clock set rate fails ( Most failure could only be when the driver is unable to find any clock rate which is less then/equal to requested rate) .
The post transition notifier should happen so as to allow the driver to resume its functions. If there are no clock rate changes because of set rate failures, the driver would be aware of that by using calls such asclk_get_rate, and would carry forward it's operations accordingly.
Quoted 1 line
How do you suggest to go about it ?
Sorry, I didn't mean to remove the post notifier, just do something like:
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); ret = clk_set_rate(cpu_clk, freqs.new * 1000); if (ret) freqs.new = clk_get_rate(cpu_clk); cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
Or:
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); ret = clk_set_rate(cpu_clk, freqs.new * 1000); if (ret) freqs.new = freqs.old; cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
So that you're notifying the cpufreq subsystem of the frequency that you're actually running at with the post change notifier rather than the one you tried to go for. If you don't do this then for UP you'll end up recaculating lpj based on the wrong frequency.
Jamie
PATCH v4 7/62 ST SPEAr13XX: Adding machine specific src files
In reply to Shiraz HashimQuoted 11 lines · Shiraz Hashim
Hello Russell,
Quoted 4 lines · Russell King - ARM Linux
Do you really need to sync back to L2, or will a
dsb()do here - and as the spinlock code usesdsb()+sev()together, would it make sense to combine the two? (dsb()is required to ensure all previous writes are visible prior to thesev()executing.)Presently L2 cache is initialized after we bootup secondary CPU but one can have the possibility of initializing L2 earlier also. So this would be safer.
It shouldn't make any difference as we explicitly flush the required data for the secondary while it is incoherent out of L2 into RAM - that being secondary_data and pen_release.
PATCH v4 38/62 SPEAr CPU freq: Adding support for CPU Freq framework
In reply to Jamie IlesHi James,
Quoted 65 lines · Jamie Iles
Quoted 46 lines · deepaksi
Hi James,
Quoted 20 lines · Jamie Iles
Quoted 20 lines
arch/arm/plat-spear/cpufreq.c new file +20
-0+static int spear_cpufreq_target (struct cpufreq_policy *policy, +unsigned int target_freq,unsigned int relation) +{ +struct cpufreq_freqs freqs; +int ret =0 ; +int index; + +if (policy->cpu !=0 ) +return -EINVAL ; + +if (cpufreq_frequency_table_target (policy, spear_freq_tbl, + target_freq, relation, &index)) +return -EINVAL ; + + freqs.old =spear_cpufreq_get (0 ); + freqs.new = spear_cpu_freq[index]; + freqs.cpu = policy->cpu; + +if (freqs.old == target_freq) +return 0 ;Quoted 10 lines
arch/arm/plat-spear/cpufreq.c line 94
Quoted 5 lines
arch/arm/plat-spear/cpufreq.c new file +4
-0+ +cpufreq_notify_transition (&freqs,CPUFREQ_PRECHANGE ); + ret =clk_set_rate (cpu_clk, freqs.new *1000 ); +cpufreq_notify_transition (&freqs,CPUFREQ_POSTCHANGE );If
clk_set_rate()failed then do you need to do freqs.new =clk_get_rate(cpu_clk)before doing theCPUFREQ_POSTCHANGEto make sure you don't notify the wrong frequency?I do have a point over here. In few of the drivers where the the pre notifiers have been added, the operations have been stopped (assume a network driver where we stalled a dma operation), and then we set the clock rate, followed by a post notifier where driver resumes it operations.
Now lets take the case, when the clock set rate fails ( Most failure could only be when the driver is unable to find any clock rate which is less then/equal to requested rate) .
The post transition notifier should happen so as to allow the driver to resume its functions. If there are no clock rate changes because of set rate failures, the driver would be aware of that by using calls such asclk_get_rate, and would carry forward it's operations accordingly.Quoted 1 line
How do you suggest to go about it ?
Sorry, I didn't mean to remove the post notifier, just do something like:
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); ret = clk_set_rate(cpu_clk, freqs.new * 1000); if (ret) freqs.new = clk_get_rate(cpu_clk); cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);Or:
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); ret = clk_set_rate(cpu_clk, freqs.new * 1000); if (ret) freqs.new = freqs.old; cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
Quoted 4 lines
So that you're notifying the cpufreq subsystem of the frequency that you're actually running at with the post change notifier rather than the one you tried to go for. If you don't do this then for UP you'll end up recaculating lpj based on the wrong frequency.
Agree. We would add it here. Thanks for pointing out.
Signature · 2 lines
regards Shiraz
PATCH v4 6/62 ST SPEAr13XX: Adding machine specific header files
In reply to viresh kumarQuoted 24 lines · viresh kumar
Quoted 15 lines · Russell King - ARM Linux
arch/arm/mach-spear13xx/include/mach/misc_regs.h line 23
Quoted 5 lines · Viresh Kumar
arch/arm/mach-spear13xx/include/mach/misc_regs.h new file +5
-0+#define MISC_BASE VA_SPEAR13XX_MISC_BASE + +/* General Configuration */ +#define SOC_CFG ((unsigned int *)(MISC_BASE + 0x000)) +#define BOOTSTRAP_CFG ((unsigned int *)(MISC_BASE + 0x004))You could really do with an
IOMEM()macro, thus:#ifndef
__ASSEMBLY__
#define IOMEM(x) ((void__iomem__force*)(x))
#else
#define IOMEM(x) (x)
#endifQuoted 7 lines
You can then use that for stuff like
VA_SPEAR13XX_MISC_BASE, and all these definitions then become:#define
SOC_CFG(MISC_BASE+0x000)because GCC allows void pointer arithmetic (treats it as char).
Quoted 7 lines
Yes. I agree with this solution.
Actually the VA* macros are like:
#defineVA_SPEAR13XX_MISC_BASEIO_ADDRESS(SPEAR13XX_MISC_BASE)Adding
IOMEM()overIO_ADDRESS(SPEAR13XX_MISC_BASE)will make it too long. And might cross 80 columns. Can we modifyIO_ADDRESS()to useIOMEM()?
Russell,
I tried to change IO_ADDRESS() to use IOMEM. But even this doesn't seem to be a good enough solution. __typesafe_io expects unsigned long and we have:
define __io_address(n) __io(IO_ADDRESS(n)).
Also, struct map_desc, .virtual field expects unsigned long, where we are getting warnings.
I tried looking at what others did, and found either they are using (unsigned int *) (as earlier done by us) or casting with (unsigned long) for new warnings mentioned above.
Both didn't seem to be good enough to me. Maybe we can use IOMEM only for MISC_BASE and similar places, where we had been using (unsigned int *).
I will do this in V5, unless you suggest something better.
Signature · 1 line
viresh
PATCH v4 7/62 ST SPEAr13XX: Adding machine specific src files
In reply to Russell King - ARM LinuxQuoted 9 lines · Russell King - ARM Linux
Quoted 8 lines · Shiraz Hashim
Hello Russell,
Quoted 4 lines · Russell King - ARM Linux
Do you really need to sync back to L2, or will a
dsb()do here - and as the spinlock code usesdsb()+sev()together, would it make sense to combine the two? (dsb()is required to ensure all previous writes are visible prior to thesev()executing.)
Quoted 7 lines
Quoted 3 lines
Presently L2 cache is initialized after we bootup secondary CPU but one can have the possibility of initializing L2 earlier also. So this would be safer.
It shouldn't make any difference as we explicitly flush the required data for the secondary while it is incoherent out of L2 into RAM - that being
secondary_dataandpen_release.
OK, but sev must follow after the SPEAR13XX_SYS_LOCATION has been updated as secondary CPU boot code is in wfe and expects the location to be updated when it is woken.
Signature · 2 lines
regards Shiraz
PATCH v4 38/62 SPEAr CPU freq: Adding support for CPU Freq framework
In reply to Shiraz HashimHi Jamie,
Quoted 68 lines · Shiraz Hashim
Hi James,
Quoted 65 lines · Jamie Iles
Quoted 46 lines · deepaksi
Hi James,
Quoted 20 lines · Jamie Iles
Quoted 20 lines
arch/arm/plat-spear/cpufreq.c new file +20
-0+static int spear_cpufreq_target (struct cpufreq_policy *policy, +unsigned int target_freq,unsigned int relation) +{ +struct cpufreq_freqs freqs; +int ret =0 ; +int index; + +if (policy->cpu !=0 ) +return -EINVAL ; + +if (cpufreq_frequency_table_target (policy, spear_freq_tbl, + target_freq, relation, &index)) +return -EINVAL ; + + freqs.old =spear_cpufreq_get (0 ); + freqs.new = spear_cpu_freq[index]; + freqs.cpu = policy->cpu; + +if (freqs.old == target_freq) +return 0 ;Quoted 10 lines
arch/arm/plat-spear/cpufreq.c line 94
Quoted 5 lines
arch/arm/plat-spear/cpufreq.c new file +4
-0+ +cpufreq_notify_transition (&freqs,CPUFREQ_PRECHANGE ); + ret =clk_set_rate (cpu_clk, freqs.new *1000 ); +cpufreq_notify_transition (&freqs,CPUFREQ_POSTCHANGE );If
clk_set_rate()failed then do you need to do freqs.new =clk_get_rate(cpu_clk)before doing theCPUFREQ_POSTCHANGEto make sure you don't notify the wrong frequency?I do have a point over here. In few of the drivers where the the pre notifiers have been added, the operations have been stopped (assume a network driver where we stalled a dma operation), and then we set the clock rate, followed by a post notifier where driver resumes it operations.
Now lets take the case, when the clock set rate fails ( Most failure could only be when the driver is unable to find any clock rate which is less then/equal to requested rate) .
The post transition notifier should happen so as to allow the driver to resume its functions. If there are no clock rate changes because of set rate failures, the driver would be aware of that by using calls such asclk_get_rate, and would carry forward it's operations accordingly.Quoted 1 line
How do you suggest to go about it ?
Sorry, I didn't mean to remove the post notifier, just do something like:
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); ret = clk_set_rate(cpu_clk, freqs.new * 1000); if (ret) freqs.new = clk_get_rate(cpu_clk); cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);Or:
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); ret = clk_set_rate(cpu_clk, freqs.new * 1000); if (ret) freqs.new = freqs.old; cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
Quoted 6 lines
Quoted 4 lines
So that you're notifying the cpufreq subsystem of the frequency that you're actually running at with the post change notifier rather than the one you tried to go for. If you don't do this then for UP you'll end up recaculating lpj based on the wrong frequency.
Agree. We would add it here. Thanks for pointing out.
On second thought it should always be there irrespective of failures as in our case it may happen that eventually CPU sets to a clock <= desired clock. So we would do following
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); ret = clk_set_rate(cpu_clk, freqs.new * 1000); if (ret)
pr_err("Could not change cpu clk rate\n");freqs.new = clk_get_rate(cpu_clk); cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
Is it fine?
Signature · 2 lines
regards Shiraz
PATCH v4 38/62 SPEAr CPU freq: Adding support for CPU Freq framework
Quoted 10 lines · Shiraz Hashim
On second thought it should always be there irrespective of failures as in our case it may happen that eventually CPU sets to a clock <= desired clock. So we would do following
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); ret =clk_set_rate(cpu_clk, freqs.new * 1000); if (ret)pr_err("Could not change cpu clk rate\n");freqs.new =
clk_get_rate(cpu_clk);cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
It probably makes more sense to do:
newfreq = clk_round_rate(cpu_clk, freqs.new * 1000);
if (newfreq < 0) {
pr_err("Invalid frequency blah blah\n");
return newfreq;
}
freqs.new = newfreq / 1000;
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
ret = clk_set_rate(cpu_clk, newfreq);
if (ret) {
pr_err("Could not change cpu clk rate\n");
freqs.new = clk_get_rate(cpu_clk) / 1000;
}
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);so that the prechange notifier gets the actual frequency to be switched to too. In theory clk_set_rate() should only fail if the new frequency couldn't be set for some reason.
PATCH v4 38/62 SPEAr CPU freq: Adding support for CPU Freq framework
Quoted 29 lines · Russell King - ARM Linux
Quoted 10 lines · Shiraz Hashim
On second thought it should always be there irrespective of failures as in our case it may happen that eventually CPU sets to a clock <= desired clock. So we would do following
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); ret =clk_set_rate(cpu_clk, freqs.new * 1000); if (ret)
? ? ? ?pr_err("Could not change cpu clk rate\n"); freqs.new =clk_get_rate(cpu_clk);cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);It probably makes more sense to do:
? ? ? ?newfreq =
clk_round_rate(cpu_clk, freqs.new * 1000); ? ? ? ?if (newfreq < 0) {
? ? ? ? ? ? ? ?pr_err("Invalid frequency blah blah\n"); ? ? ? ? ? ? ? ?return newfreq;
? ? ? ?}? ? ? ?freqs.new = newfreq / 1000;
? ? ? ?cpufreq_notify_transition(&freqs,CPUFREQ_PRECHANGE); ? ? ? ?ret =clk_set_rate(cpu_clk, newfreq);
? ? ? ?if (ret) {
? ? ? ? ? ? ? ?pr_err("Could not change cpu clk rate\n"); ? ? ? ? ? ? ? ?freqs.new =clk_get_rate(cpu_clk)/ 1000; ? ? ? ?}
? ? ? ?cpufreq_notify_transition(&freqs,CPUFREQ_POSTCHANGE);
Quoted 4 lines
so that the prechange notifier gets the actual frequency to be switched to too. ?In theory
clk_set_rate()should only fail if the new frequency couldn't be set for some reason.
Ok.