Merge branch 'spear/clock' into next/clock
authorArnd Bergmann <arnd@arndb.de>
Sat, 12 May 2012 22:11:06 +0000 (00:11 +0200)
committerArnd Bergmann <arnd@arndb.de>
Sat, 12 May 2012 22:11:06 +0000 (00:11 +0200)
Viresh Kumar <viresh.kumar@st.com> writes:

 This is rebased over a (merge of Mike's/clk-next & SPEAr's DT) + Russell's
 patch: CLKDEV: provide helpers for common clock framework rebased over them.

* spear/clock:
  SPEAr: Switch to common clock framework
  SPEAr: Call clk_prepare() before calling clk_enable
  SPEAr: clk: Add General Purpose Timer Synthesizer clock
  SPEAr: clk: Add Fractional Synthesizer clock
  SPEAr: clk: Add Auxiliary Synthesizer clock
  SPEAr: clk: Add VCO-PLL Synthesizer clock

Conflicts:
drivers/clk/Makefile

[Arnd: rebased again without the spear/dt branch]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
553 files changed:
Documentation/ABI/testing/sysfs-bus-hsi [new file with mode: 0644]
Documentation/devicetree/bindings/ata/ahci-platform.txt [new file with mode: 0644]
Documentation/devicetree/bindings/ata/calxeda-sata.txt [deleted file]
Documentation/devicetree/bindings/sound/sgtl5000.txt
Documentation/networking/ip-sysctl.txt
Documentation/power/freezing-of-tasks.txt
Documentation/security/keys.txt
MAINTAINERS
Makefile
arch/alpha/Kconfig
arch/alpha/include/asm/rtc.h
arch/alpha/kernel/core_tsunami.c
arch/alpha/kernel/sys_marvel.c
arch/arm/Kconfig
arch/arm/boot/dts/msm8660-surf.dts
arch/arm/boot/dts/versatile-ab.dts
arch/arm/boot/dts/versatile-pb.dts
arch/arm/configs/mini2440_defconfig
arch/arm/include/asm/thread_info.h
arch/arm/include/asm/tls.h
arch/arm/kernel/irq.c
arch/arm/kernel/signal.c
arch/arm/kernel/smp.c
arch/arm/kernel/smp_twd.c
arch/arm/mach-exynos/clock-exynos4.c
arch/arm/mach-exynos/clock-exynos5.c
arch/arm/mach-exynos/common.c
arch/arm/mach-exynos/dev-dwmci.c
arch/arm/mach-exynos/mach-nuri.c
arch/arm/mach-exynos/mach-universal_c210.c
arch/arm/mach-imx/Kconfig
arch/arm/mach-imx/Makefile
arch/arm/mach-imx/clk-busy.c [new file with mode: 0644]
arch/arm/mach-imx/clk-gate2.c [new file with mode: 0644]
arch/arm/mach-imx/clk-imx1.c [new file with mode: 0644]
arch/arm/mach-imx/clk-imx21.c [new file with mode: 0644]
arch/arm/mach-imx/clk-imx25.c [new file with mode: 0644]
arch/arm/mach-imx/clk-imx27.c [new file with mode: 0644]
arch/arm/mach-imx/clk-imx31.c [new file with mode: 0644]
arch/arm/mach-imx/clk-imx35.c [new file with mode: 0644]
arch/arm/mach-imx/clk-imx51-imx53.c [new file with mode: 0644]
arch/arm/mach-imx/clk-imx6q.c [new file with mode: 0644]
arch/arm/mach-imx/clk-pfd.c [new file with mode: 0644]
arch/arm/mach-imx/clk-pllv1.c [new file with mode: 0644]
arch/arm/mach-imx/clk-pllv2.c [new file with mode: 0644]
arch/arm/mach-imx/clk-pllv3.c [new file with mode: 0644]
arch/arm/mach-imx/clk.h [new file with mode: 0644]
arch/arm/mach-imx/clock-imx1.c [deleted file]
arch/arm/mach-imx/clock-imx21.c [deleted file]
arch/arm/mach-imx/clock-imx25.c [deleted file]
arch/arm/mach-imx/clock-imx27.c [deleted file]
arch/arm/mach-imx/clock-imx31.c [deleted file]
arch/arm/mach-imx/clock-imx35.c [deleted file]
arch/arm/mach-imx/clock-imx6q.c [deleted file]
arch/arm/mach-imx/clock-mx51-mx53.c [deleted file]
arch/arm/mach-imx/crmregs-imx3.h
arch/arm/mach-imx/mm-imx3.c
arch/arm/mach-imx/mm-imx5.c
arch/arm/mach-imx/pm-imx3.c
arch/arm/mach-msm/board-msm8x60.c
arch/arm/mach-mxs/Makefile
arch/arm/mach-mxs/clock-mx23.c [deleted file]
arch/arm/mach-mxs/clock-mx28.c [deleted file]
arch/arm/mach-mxs/clock.c [deleted file]
arch/arm/mach-mxs/include/mach/clock.h [deleted file]
arch/arm/mach-mxs/include/mach/common.h
arch/arm/mach-mxs/mach-mx28evk.c
arch/arm/mach-mxs/regs-clkctrl-mx23.h [deleted file]
arch/arm/mach-mxs/regs-clkctrl-mx28.h [deleted file]
arch/arm/mach-mxs/system.c
arch/arm/mach-mxs/timer.c
arch/arm/mach-pxa/include/mach/mfp-pxa2xx.h
arch/arm/mach-pxa/mfp-pxa2xx.c
arch/arm/mach-pxa/pxa27x.c
arch/arm/mach-s3c24xx/Kconfig
arch/arm/mach-s5pv210/mach-goni.c
arch/arm/mach-sa1100/generic.c
arch/arm/mach-u300/core.c
arch/arm/mach-u300/i2c.c
arch/arm/mach-u300/include/mach/irqs.h
arch/arm/mach-ux500/mbox-db5500.c
arch/arm/mm/abort-ev6.S
arch/arm/mm/cache-l2x0.c
arch/arm/mm/init.c
arch/arm/mm/mmu.c
arch/arm/plat-mxc/clock.c
arch/arm/plat-mxc/include/mach/clock.h
arch/arm/plat-mxc/time.c
arch/arm/plat-omap/dma.c
arch/arm/plat-samsung/include/plat/sdhci.h
arch/arm/vfp/vfpmodule.c
arch/blackfin/mach-bf538/boards/ezkit.c
arch/hexagon/kernel/dma.c
arch/hexagon/kernel/process.c
arch/hexagon/kernel/ptrace.c
arch/hexagon/kernel/smp.c
arch/hexagon/kernel/time.c
arch/hexagon/kernel/vdso.c
arch/mips/ath79/dev-wmac.c
arch/mips/include/asm/mach-jz4740/irq.h
arch/mips/include/asm/mmu_context.h
arch/mips/kernel/signal.c
arch/mips/kernel/signal32.c
arch/mips/kernel/signal_n32.c
arch/parisc/kernel/pdc_cons.c
arch/powerpc/boot/dts/fsl/pq3-mpic-message-B.dtsi [new file with mode: 0644]
arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi
arch/powerpc/include/asm/irq.h
arch/powerpc/include/asm/mpic.h
arch/powerpc/include/asm/mpic_msgr.h
arch/powerpc/include/asm/reg_booke.h
arch/powerpc/kernel/irq.c
arch/powerpc/kernel/machine_kexec.c
arch/powerpc/kernel/setup_32.c
arch/powerpc/net/bpf_jit.h
arch/powerpc/net/bpf_jit_64.S
arch/powerpc/net/bpf_jit_comp.c
arch/powerpc/platforms/85xx/common.c
arch/powerpc/platforms/85xx/mpc85xx_mds.c
arch/powerpc/platforms/85xx/p1022_ds.c
arch/powerpc/platforms/cell/axon_msi.c
arch/powerpc/platforms/cell/beat_interrupt.c
arch/powerpc/platforms/powermac/low_i2c.c
arch/powerpc/platforms/powermac/pic.c
arch/powerpc/platforms/pseries/Kconfig
arch/powerpc/platforms/pseries/eeh.c
arch/powerpc/sysdev/cpm2_pic.c
arch/powerpc/sysdev/mpc8xx_pic.c
arch/powerpc/sysdev/mpic.c
arch/powerpc/sysdev/mpic_msgr.c
arch/powerpc/sysdev/scom.c
arch/powerpc/sysdev/xics/xics-common.c
arch/sh/include/asm/atomic.h
arch/sh/mm/fault_32.c
arch/tile/include/asm/pci.h
arch/tile/kernel/pci.c
arch/x86/Kconfig
arch/x86/boot/compressed/head_32.S
arch/x86/boot/compressed/head_64.S
arch/x86/boot/compressed/relocs.c
arch/x86/boot/tools/build.c
arch/x86/ia32/ia32_aout.c
arch/x86/include/asm/posix_types.h
arch/x86/include/asm/sigcontext.h
arch/x86/include/asm/siginfo.h
arch/x86/include/asm/unistd.h
arch/x86/include/asm/word-at-a-time.h
arch/x86/include/asm/x86_init.h
arch/x86/kernel/acpi/sleep.c
arch/x86/kernel/acpi/sleep.h
arch/x86/kernel/acpi/wakeup_32.S
arch/x86/kernel/acpi/wakeup_64.S
arch/x86/kernel/apic/apic.c
arch/x86/kernel/apic/apic_numachip.c
arch/x86/kernel/apic/x2apic_phys.c
arch/x86/kernel/cpu/amd.c
arch/x86/kernel/cpu/common.c
arch/x86/kernel/cpu/intel_cacheinfo.c
arch/x86/kernel/i387.c
arch/x86/kernel/microcode_amd.c
arch/x86/kernel/microcode_core.c
arch/x86/kernel/x86_init.c
arch/x86/platform/geode/net5501.c
arch/x86/platform/mrst/mrst.c
arch/x86/xen/enlighten.c
arch/x86/xen/smp.c
arch/x86/xen/xen-asm.S
arch/xtensa/include/asm/hardirq.h
arch/xtensa/include/asm/io.h
arch/xtensa/kernel/signal.c
drivers/acpi/power.c
drivers/acpi/scan.c
drivers/acpi/sleep.c
drivers/ata/ahci.c
drivers/ata/ahci_platform.c
drivers/ata/libata-core.c
drivers/ata/libata-eh.c
drivers/ata/libata-scsi.c
drivers/ata/pata_arasan_cf.c
drivers/bcma/sprom.c
drivers/bluetooth/ath3k.c
drivers/bluetooth/btusb.c
drivers/clk/Makefile
drivers/clk/mxs/Makefile [new file with mode: 0644]
drivers/clk/mxs/clk-div.c [new file with mode: 0644]
drivers/clk/mxs/clk-frac.c [new file with mode: 0644]
drivers/clk/mxs/clk-imx23.c [new file with mode: 0644]
drivers/clk/mxs/clk-imx28.c [new file with mode: 0644]
drivers/clk/mxs/clk-pll.c [new file with mode: 0644]
drivers/clk/mxs/clk-ref.c [new file with mode: 0644]
drivers/clk/mxs/clk.c [new file with mode: 0644]
drivers/clk/mxs/clk.h [new file with mode: 0644]
drivers/dma/amba-pl08x.c
drivers/dma/at_hdmac.c
drivers/dma/imx-dma.c
drivers/dma/imx-sdma.c
drivers/dma/ipu/ipu_idmac.c
drivers/dma/mxs-dma.c
drivers/dma/pl330.c
drivers/dma/ste_dma40.c
drivers/dma/ste_dma40_ll.h
drivers/firmware/efivars.c
drivers/gpio/gpio-pxa.c
drivers/gpu/drm/exynos/exynos_drm_gem.c
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/i915_dma.c
drivers/gpu/drm/i915/i915_gem_execbuffer.c
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/intel_crt.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/i915/intel_lvds.c
drivers/gpu/drm/i915/intel_ringbuffer.c
drivers/gpu/drm/i915/intel_sdvo.c
drivers/gpu/drm/nouveau/nouveau_acpi.c
drivers/gpu/drm/nouveau/nouveau_bios.c
drivers/gpu/drm/nouveau/nouveau_hdmi.c
drivers/gpu/drm/nouveau/nv10_gpio.c
drivers/gpu/drm/nouveau/nvc0_fb.c
drivers/gpu/drm/radeon/atombios_crtc.c
drivers/gpu/drm/radeon/radeon_device.c
drivers/gpu/drm/radeon/radeon_display.c
drivers/hsi/clients/hsi_char.c
drivers/hsi/hsi.c
drivers/hwmon/ad7314.c
drivers/hwmon/coretemp.c
drivers/hwmon/fam15h_power.c
drivers/i2c/busses/i2c-eg20t.c
drivers/i2c/busses/i2c-mxs.c
drivers/i2c/busses/i2c-pnx.c
drivers/i2c/busses/i2c-tegra.c
drivers/infiniband/core/mad.c
drivers/infiniband/hw/mlx4/main.c
drivers/input/mouse/synaptics.c
drivers/md/bitmap.c
drivers/md/bitmap.h
drivers/md/dm-raid.c
drivers/md/md.c
drivers/media/video/mx3_camera.c
drivers/mfd/omap-usb-host.c
drivers/mmc/host/mxcmmc.c
drivers/mmc/host/mxs-mmc.c
drivers/mmc/host/sdhci-esdhc-imx.c
drivers/mtd/nand/gpmi-nand/gpmi-nand.c
drivers/mtd/nand/mxc_nand.c
drivers/net/arcnet/arc-rimi.c
drivers/net/caif/caif_hsi.c
drivers/net/can/usb/peak_usb/pcan_usb_pro.c
drivers/net/dummy.c
drivers/net/ethernet/atheros/atlx/atl1.c
drivers/net/ethernet/atheros/atlx/atl1.h
drivers/net/ethernet/atheros/atlx/atlx.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
drivers/net/ethernet/broadcom/tg3.c
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
drivers/net/ethernet/dlink/dl2k.c
drivers/net/ethernet/dlink/dl2k.h
drivers/net/ethernet/freescale/fec.c
drivers/net/ethernet/freescale/ucc_geth.c
drivers/net/ethernet/freescale/ucc_geth.h
drivers/net/ethernet/ibm/ehea/ehea_main.c
drivers/net/ethernet/ibm/ehea/ehea_phyp.h
drivers/net/ethernet/intel/e1000e/ich8lan.c
drivers/net/ethernet/intel/e1000e/netdev.c
drivers/net/ethernet/intel/e1000e/param.c
drivers/net/ethernet/intel/igbvf/netdev.c
drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/marvell/sky2.c
drivers/net/ethernet/marvell/sky2.h
drivers/net/ethernet/micrel/ks8851.c
drivers/net/ethernet/micrel/ks8851_mll.c
drivers/net/ethernet/micrel/ksz884x.c
drivers/net/ethernet/realtek/8139cp.c
drivers/net/ethernet/smsc/smsc911x.c
drivers/net/ethernet/sun/sungem.c
drivers/net/ethernet/ti/davinci_emac.c
drivers/net/ethernet/ti/davinci_mdio.c
drivers/net/ethernet/ti/tlan.c
drivers/net/ethernet/xilinx/xilinx_axienet.h
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
drivers/net/hyperv/netvsc_drv.c
drivers/net/phy/icplus.c
drivers/net/ppp/ppp_generic.c
drivers/net/usb/asix.c
drivers/net/usb/qmi_wwan.c
drivers/net/usb/smsc75xx.c
drivers/net/usb/smsc95xx.c
drivers/net/usb/usbnet.c
drivers/net/virtio_net.c
drivers/net/wan/farsync.c
drivers/net/wireless/ath/ath5k/ahb.c
drivers/net/wireless/ath/ath9k/ar5008_phy.c
drivers/net/wireless/ath/ath9k/ar9003_paprd.c
drivers/net/wireless/ath/ath9k/ar9003_phy.c
drivers/net/wireless/ath/ath9k/eeprom_9287.c
drivers/net/wireless/ath/ath9k/hw.c
drivers/net/wireless/ath/ath9k/hw.h
drivers/net/wireless/ath/ath9k/main.c
drivers/net/wireless/ath/ath9k/xmit.c
drivers/net/wireless/b43/main.c
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
drivers/net/wireless/brcm80211/brcmsmac/main.c
drivers/net/wireless/ipw2x00/ipw2200.c
drivers/net/wireless/iwlwifi/iwl-1000.c
drivers/net/wireless/iwlwifi/iwl-2000.c
drivers/net/wireless/iwlwifi/iwl-5000.c
drivers/net/wireless/iwlwifi/iwl-6000.c
drivers/net/wireless/iwlwifi/iwl-agn.c
drivers/net/wireless/iwlwifi/iwl-fh.h
drivers/net/wireless/iwlwifi/iwl-mac80211.c
drivers/net/wireless/iwlwifi/iwl-prph.h
drivers/net/wireless/libertas/cfg.c
drivers/net/wireless/mwifiex/pcie.h
drivers/net/wireless/rtlwifi/pci.c
drivers/net/wireless/wl1251/main.c
drivers/net/wireless/wl1251/sdio.c
drivers/pci/Makefile
drivers/pci/pci-acpi.c
drivers/platform/x86/acerhdf.c
drivers/platform/x86/dell-laptop.c
drivers/platform/x86/intel_ips.c
drivers/platform/x86/intel_mid_powerbtn.c
drivers/rtc/rtc-ds1307.c
drivers/rtc/rtc-imxdi.c
drivers/rtc/rtc-mpc5121.c
drivers/s390/net/qeth_core_main.c
drivers/scsi/ipr.c
drivers/scsi/libfc/fc_lport.c
drivers/scsi/libsas/sas_ata.c
drivers/scsi/libsas/sas_discover.c
drivers/scsi/libsas/sas_event.c
drivers/scsi/libsas/sas_expander.c
drivers/scsi/libsas/sas_init.c
drivers/scsi/libsas/sas_internal.h
drivers/scsi/libsas/sas_phy.c
drivers/scsi/libsas/sas_port.c
drivers/scsi/scsi_lib.c
drivers/spi/Kconfig
drivers/spi/Makefile
drivers/spi/spi-bcm63xx.c
drivers/spi/spi-bfin-sport.c
drivers/spi/spi-bfin5xx.c
drivers/spi/spi-ep93xx.c
drivers/spi/spi-imx.c
drivers/spi/spi-pl022.c
drivers/staging/octeon/ethernet-rx.c
drivers/staging/octeon/ethernet-tx.c
drivers/staging/octeon/ethernet.c
drivers/staging/ozwpan/ozpd.c
drivers/staging/tidspbridge/core/tiomap3430.c
drivers/staging/tidspbridge/core/wdt.c
drivers/staging/zcache/Kconfig
drivers/tty/serial/imx.c
drivers/tty/serial/pmac_zilog.c
drivers/tty/vt/keyboard.c
drivers/usb/class/cdc-wdm.c
drivers/usb/core/hcd-pci.c
drivers/usb/gadget/dummy_hcd.c
drivers/usb/gadget/f_mass_storage.c
drivers/usb/gadget/file_storage.c
drivers/usb/gadget/udc-core.c
drivers/usb/gadget/uvc.h
drivers/usb/gadget/uvc_v4l2.c
drivers/usb/host/ehci-mxc.c
drivers/usb/host/ehci-pci.c
drivers/usb/host/ehci-tegra.c
drivers/usb/musb/davinci.c
drivers/usb/musb/musb_core.h
drivers/usb/otg/gpio_vbus.c
drivers/vhost/net.c
drivers/vhost/vhost.c
drivers/vhost/vhost.h
drivers/video/bfin-lq035q1-fb.c
drivers/video/imxfb.c
drivers/w1/masters/mxc_w1.c
drivers/watchdog/hpwdt.c
drivers/watchdog/imx2_wdt.c
drivers/xen/events.c
drivers/xen/xen-acpi-processor.c
fs/autofs4/autofs_i.h
fs/autofs4/dev-ioctl.c
fs/autofs4/inode.c
fs/autofs4/waitq.c
fs/btrfs/backref.c
fs/btrfs/ctree.c
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/disk-io.h
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/ioctl.h
fs/btrfs/reada.c
fs/btrfs/relocation.c
fs/btrfs/scrub.c
fs/btrfs/super.c
fs/btrfs/transaction.c
fs/btrfs/tree-log.c
fs/btrfs/volumes.c
fs/buffer.c
fs/cifs/cifsfs.c
fs/cifs/cifsfs.h
fs/cifs/cifssmb.c
fs/cifs/connect.c
fs/cifs/dir.c
fs/cifs/file.c
fs/dcache.c
fs/dlm/lock.c
fs/eventpoll.c
fs/ext4/super.c
fs/gfs2/lock_dlm.c
fs/hfsplus/catalog.c
fs/hfsplus/dir.c
fs/hugetlbfs/inode.c
fs/jbd2/commit.c
fs/namei.c
fs/nfs/blocklayout/blocklayout.c
fs/nfs/client.c
fs/nfs/dir.c
fs/nfs/idmap.c
fs/nfs/internal.h
fs/nfs/namespace.c
fs/nfs/nfs4_fs.h
fs/nfs/nfs4filelayoutdev.c
fs/nfs/nfs4namespace.c
fs/nfs/nfs4proc.c
fs/nfs/nfs4state.c
fs/nfs/nfs4xdr.c
fs/nfs/objlayout/objlayout.c
fs/nfs/pnfs.c
fs/nfs/read.c
fs/nfs/super.c
fs/nfs/write.c
fs/nfsd/nfs4recover.c
fs/pipe.c
fs/proc/task_mmu.c
include/acpi/actypes.h
include/asm-generic/siginfo.h
include/asm-generic/statfs.h
include/linux/efi.h
include/linux/gpio-pxa.h
include/linux/hsi/hsi.h
include/linux/irq.h
include/linux/libata.h
include/linux/netfilter_bridge.h
include/linux/nfs_xdr.h
include/linux/pipe_fs_i.h
include/linux/seqlock.h
include/linux/skbuff.h
include/linux/spi/spi.h
include/linux/usb/hcd.h
include/linux/vm_event_item.h
include/net/bluetooth/hci_core.h
include/net/dst.h
include/net/ip6_fib.h
include/net/ip_vs.h
include/net/red.h
include/net/sock.h
include/scsi/libsas.h
include/scsi/sas_ata.h
init/do_mounts.c
init/main.c
kernel/events/core.c
kernel/irq/debug.h
kernel/power/swap.c
kernel/rcutree.c
kernel/sched/core.c
kernel/sched/fair.c
kernel/sched/features.h
kernel/time/tick-broadcast.c
kernel/trace/trace.c
kernel/trace/trace.h
kernel/trace/trace_output.c
mm/hugetlb.c
mm/memcontrol.c
mm/mempolicy.c
mm/migrate.c
mm/nobootmem.c
mm/swap_state.c
mm/vmscan.c
mm/vmstat.c
net/ax25/af_ax25.c
net/bluetooth/hci_core.c
net/bluetooth/hci_event.c
net/bluetooth/mgmt.c
net/bridge/br_forward.c
net/bridge/br_netfilter.c
net/caif/chnl_net.c
net/core/dev.c
net/core/drop_monitor.c
net/core/net_namespace.c
net/ieee802154/6lowpan.c
net/ipv4/inet_diag.c
net/ipv4/tcp.c
net/ipv4/tcp_input.c
net/ipv4/tcp_output.c
net/ipv4/udp_diag.c
net/ipv6/addrconf.c
net/ipv6/ip6_fib.c
net/ipv6/ndisc.c
net/ipv6/route.c
net/ipv6/tcp_ipv6.c
net/key/af_key.c
net/l2tp/l2tp_ip.c
net/mac80211/ibss.c
net/mac80211/ieee80211_i.h
net/mac80211/iface.c
net/mac80211/mlme.c
net/mac80211/rx.c
net/mac80211/tx.c
net/netfilter/ipvs/ip_vs_core.c
net/netfilter/ipvs/ip_vs_ctl.c
net/netfilter/ipvs/ip_vs_ftp.c
net/netfilter/ipvs/ip_vs_lblc.c
net/netfilter/ipvs/ip_vs_lblcr.c
net/netfilter/ipvs/ip_vs_proto.c
net/netfilter/ipvs/ip_vs_proto_sctp.c
net/netfilter/ipvs/ip_vs_proto_tcp.c
net/netfilter/ipvs/ip_vs_proto_udp.c
net/netfilter/xt_CT.c
net/phonet/pn_dev.c
net/sched/sch_gred.c
net/sched/sch_netem.c
net/sunrpc/clnt.c
net/sunrpc/rpc_pipe.c
net/sunrpc/sunrpc_syms.c
net/wireless/util.c
scripts/mod/file2alias.c
sound/pci/hda/patch_realtek.c
sound/soc/blackfin/bf5xx-ssm2602.c
sound/soc/codecs/cs42l73.c
sound/soc/codecs/tlv320aic23.c
sound/soc/codecs/wm8350.c
sound/soc/codecs/wm8994.c
sound/soc/codecs/wm_hubs.c
sound/soc/omap/omap-pcm.c
sound/soc/samsung/s3c2412-i2s.c
sound/soc/sh/fsi.c
sound/soc/soc-core.c
sound/soc/soc-dapm.c
tools/perf/Makefile
tools/perf/builtin-report.c
tools/perf/builtin-test.c
tools/perf/util/parse-events.l
tools/perf/util/symbol.c
tools/testing/ktest/ktest.pl

diff --git a/Documentation/ABI/testing/sysfs-bus-hsi b/Documentation/ABI/testing/sysfs-bus-hsi
new file mode 100644 (file)
index 0000000..1b1b282
--- /dev/null
@@ -0,0 +1,19 @@
+What:          /sys/bus/hsi
+Date:          April 2012
+KernelVersion: 3.4
+Contact:       Carlos Chinea <carlos.chinea@nokia.com>
+Description:
+               High Speed Synchronous Serial Interface (HSI) is a
+               serial interface mainly used for connecting application
+               engines (APE) with cellular modem engines (CMT) in cellular
+               handsets.
+               The bus will be populated with devices (hsi_clients) representing
+               the protocols available in the system. Bus drivers implement
+               those protocols.
+
+What:          /sys/bus/hsi/devices/.../modalias
+Date:          April 2012
+KernelVersion: 3.4
+Contact:       Carlos Chinea <carlos.chinea@nokia.com>
+Description:   Stores the same MODALIAS value emitted by uevent
+               Format: hsi:<hsi_client device name>
diff --git a/Documentation/devicetree/bindings/ata/ahci-platform.txt b/Documentation/devicetree/bindings/ata/ahci-platform.txt
new file mode 100644 (file)
index 0000000..8bb8a76
--- /dev/null
@@ -0,0 +1,16 @@
+* AHCI SATA Controller
+
+SATA nodes are defined to describe on-chip Serial ATA controllers.
+Each SATA controller should have its own node.
+
+Required properties:
+- compatible        : compatible list, contains "calxeda,hb-ahci" or "snps,spear-ahci"
+- interrupts        : <interrupt mapping for SATA IRQ>
+- reg               : <registers mapping>
+
+Example:
+        sata@ffe08000 {
+               compatible = "calxeda,hb-ahci";
+                reg = <0xffe08000 0x1000>;
+                interrupts = <115>;
+        };
diff --git a/Documentation/devicetree/bindings/ata/calxeda-sata.txt b/Documentation/devicetree/bindings/ata/calxeda-sata.txt
deleted file mode 100644 (file)
index 79caa56..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-* Calxeda SATA Controller
-
-SATA nodes are defined to describe on-chip Serial ATA controllers.
-Each SATA controller should have its own node.
-
-Required properties:
-- compatible        : compatible list, contains "calxeda,hb-ahci"
-- interrupts        : <interrupt mapping for SATA IRQ>
-- reg               : <registers mapping>
-
-Example:
-        sata@ffe08000 {
-               compatible = "calxeda,hb-ahci";
-                reg = <0xffe08000 0x1000>;
-                interrupts = <115>;
-        };
-
index 2c3cd413f042522ed9877061c728df94bb4f46e8..9cc44449508df9f2ee6704acf59b113a6ad9e079 100644 (file)
@@ -3,6 +3,8 @@
 Required properties:
 - compatible : "fsl,sgtl5000".
 
+- reg : the I2C address of the device
+
 Example:
 
 codec: sgtl5000@0a {
index bd80ba5847d2b8b44548180c7cd9f912832bc4f1..1619a8c8087341477621388701fec82ca832b70b 100644 (file)
@@ -147,7 +147,7 @@ tcp_adv_win_scale - INTEGER
        (if tcp_adv_win_scale > 0) or bytes-bytes/2^(-tcp_adv_win_scale),
        if it is <= 0.
        Possible values are [-31, 31], inclusive.
-       Default: 2
+       Default: 1
 
 tcp_allowed_congestion_control - STRING
        Show/set the congestion control choices available to non-privileged
@@ -410,7 +410,7 @@ tcp_rmem - vector of 3 INTEGERs: min, default, max
        net.core.rmem_max.  Calling setsockopt() with SO_RCVBUF disables
        automatic tuning of that socket's receive buffer size, in which
        case this value is ignored.
-       Default: between 87380B and 4MB, depending on RAM size.
+       Default: between 87380B and 6MB, depending on RAM size.
 
 tcp_sack - BOOLEAN
        Enable select acknowledgments (SACKS).
index ec715cd78fbb7028bde53c0664a513701b162858..6ec291ea1c78c64e4e1ec35ad614336859ab4c31 100644 (file)
@@ -9,7 +9,7 @@ architectures).
 
 II. How does it work?
 
-There are four per-task flags used for that, PF_NOFREEZE, PF_FROZEN, TIF_FREEZE
+There are three per-task flags used for that, PF_NOFREEZE, PF_FROZEN
 and PF_FREEZER_SKIP (the last one is auxiliary).  The tasks that have
 PF_NOFREEZE unset (all user space processes and some kernel threads) are
 regarded as 'freezable' and treated in a special way before the system enters a
@@ -17,30 +17,31 @@ suspend state as well as before a hibernation image is created (in what follows
 we only consider hibernation, but the description also applies to suspend).
 
 Namely, as the first step of the hibernation procedure the function
-freeze_processes() (defined in kernel/power/process.c) is called.  It executes
-try_to_freeze_tasks() that sets TIF_FREEZE for all of the freezable tasks and
-either wakes them up, if they are kernel threads, or sends fake signals to them,
-if they are user space processes.  A task that has TIF_FREEZE set, should react
-to it by calling the function called __refrigerator() (defined in
-kernel/freezer.c), which sets the task's PF_FROZEN flag, changes its state
-to TASK_UNINTERRUPTIBLE and makes it loop until PF_FROZEN is cleared for it.
-Then, we say that the task is 'frozen' and therefore the set of functions
-handling this mechanism is referred to as 'the freezer' (these functions are
-defined in kernel/power/process.c, kernel/freezer.c & include/linux/freezer.h).
-User space processes are generally frozen before kernel threads.
+freeze_processes() (defined in kernel/power/process.c) is called.  A system-wide
+variable system_freezing_cnt (as opposed to a per-task flag) is used to indicate
+whether the system is to undergo a freezing operation. And freeze_processes()
+sets this variable.  After this, it executes try_to_freeze_tasks() that sends a
+fake signal to all user space processes, and wakes up all the kernel threads.
+All freezable tasks must react to that by calling try_to_freeze(), which
+results in a call to __refrigerator() (defined in kernel/freezer.c), which sets
+the task's PF_FROZEN flag, changes its state to TASK_UNINTERRUPTIBLE and makes
+it loop until PF_FROZEN is cleared for it. Then, we say that the task is
+'frozen' and therefore the set of functions handling this mechanism is referred
+to as 'the freezer' (these functions are defined in kernel/power/process.c,
+kernel/freezer.c & include/linux/freezer.h). User space processes are generally
+frozen before kernel threads.
 
 __refrigerator() must not be called directly.  Instead, use the
 try_to_freeze() function (defined in include/linux/freezer.h), that checks
-the task's TIF_FREEZE flag and makes the task enter __refrigerator() if the
-flag is set.
+if the task is to be frozen and makes the task enter __refrigerator().
 
 For user space processes try_to_freeze() is called automatically from the
 signal-handling code, but the freezable kernel threads need to call it
 explicitly in suitable places or use the wait_event_freezable() or
 wait_event_freezable_timeout() macros (defined in include/linux/freezer.h)
-that combine interruptible sleep with checking if TIF_FREEZE is set and calling
-try_to_freeze().  The main loop of a freezable kernel thread may look like the
-following one:
+that combine interruptible sleep with checking if the task is to be frozen and
+calling try_to_freeze().  The main loop of a freezable kernel thread may look
+like the following one:
 
        set_freezable();
        do {
@@ -53,7 +54,7 @@ following one:
 (from drivers/usb/core/hub.c::hub_thread()).
 
 If a freezable kernel thread fails to call try_to_freeze() after the freezer has
-set TIF_FREEZE for it, the freezing of tasks will fail and the entire
+initiated a freezing operation, the freezing of tasks will fail and the entire
 hibernation operation will be cancelled.  For this reason, freezable kernel
 threads must call try_to_freeze() somewhere or use one of the
 wait_event_freezable() and wait_event_freezable_timeout() macros.
index 787717091421d54ec330f51bdaed0f2520749da8..d389acd31e19405410ca87acbe689739e0d35771 100644 (file)
@@ -123,7 +123,7 @@ KEY SERVICE OVERVIEW
 
 The key service provides a number of features besides keys:
 
- (*) The key service defines two special key types:
+ (*) The key service defines three special key types:
 
      (+) "keyring"
 
@@ -137,6 +137,18 @@ The key service provides a number of features besides keys:
         blobs of data. These can be created, updated and read by userspace,
         and aren't intended for use by kernel services.
 
+     (+) "logon"
+
+        Like a "user" key, a "logon" key has a payload that is an arbitrary
+        blob of data. It is intended as a place to store secrets which are
+        accessible to the kernel but not to userspace programs.
+
+        The description can be arbitrary, but must be prefixed with a non-zero
+        length string that describes the key "subclass". The subclass is
+        separated from the rest of the description by a ':'. "logon" keys can
+        be created and updated from userspace, but the payload is only
+        readable from kernel space.
+
  (*) Each process subscribes to three keyrings: a thread-specific keyring, a
      process-specific keyring, and a session-specific keyring.
 
index cb5425e3cd424bc0a16018db113904f3768e39ed..b7adeed338d458969466ba081a0086a8d5c4c2d0 100644 (file)
@@ -1978,10 +1978,7 @@ S:       Maintained
 F:     drivers/net/ethernet/ti/cpmac.c
 
 CPU FREQUENCY DRIVERS
-M:     Dave Jones <davej@redhat.com>
 L:     cpufreq@vger.kernel.org
-W:     http://www.codemonkey.org.uk/projects/cpufreq/
-T:     git git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq.git
 S:     Maintained
 F:     drivers/cpufreq/
 F:     include/linux/cpufreq.h
@@ -3602,6 +3599,7 @@ S:        Supported
 F:     drivers/net/wireless/iwlegacy/
 
 INTEL WIRELESS WIFI LINK (iwlwifi)
+M:     Johannes Berg <johannes.berg@intel.com>
 M:     Wey-Yi Guy <wey-yi.w.guy@intel.com>
 M:     Intel Linux Wireless <ilw@linux.intel.com>
 L:     linux-wireless@vger.kernel.org
@@ -5901,11 +5899,11 @@ F:      Documentation/scsi/st.txt
 F:     drivers/scsi/st*
 
 SCTP PROTOCOL
-M:     Vlad Yasevich <vladislav.yasevich@hp.com>
+M:     Vlad Yasevich <vyasevich@gmail.com>
 M:     Sridhar Samudrala <sri@us.ibm.com>
 L:     linux-sctp@vger.kernel.org
 W:     http://lksctp.sourceforge.net
-S:     Supported
+S:     Maintained
 F:     Documentation/networking/sctp.txt
 F:     include/linux/sctp.h
 F:     include/net/sctp/
@@ -7586,8 +7584,8 @@ F:        Documentation/filesystems/xfs.txt
 F:     fs/xfs/
 
 XILINX AXI ETHERNET DRIVER
-M:     Ariane Keller <ariane.keller@tik.ee.ethz.ch>
-M:     Daniel Borkmann <daniel.borkmann@tik.ee.ethz.ch>
+M:     Anirudha Sarangi <anirudh@xilinx.com>
+M:     John Linn <John.Linn@xilinx.com>
 S:     Maintained
 F:     drivers/net/ethernet/xilinx/xilinx_axienet*
 
index afc868e6c75dd26dbbf28c3511cbcf29c0471573..9e384ae6c403cb92d3ed633b3e033bf3a6c3c3de 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 3
 PATCHLEVEL = 4
 SUBLEVEL = 0
-EXTRAVERSION = -rc4
+EXTRAVERSION = -rc6
 NAME = Saber-toothed Squirrel
 
 # *DOCUMENTATION*
index 56a4df952fb0f2e68889229133e38b2b34de4716..22e58a99f38b0fd19232ec8fec64249ca429846f 100644 (file)
@@ -477,7 +477,7 @@ config ALPHA_BROKEN_IRQ_MASK
 
 config VGA_HOSE
        bool
-       depends on ALPHA_GENERIC || ALPHA_TITAN || ALPHA_MARVEL || ALPHA_TSUNAMI
+       depends on VGA_CONSOLE && (ALPHA_GENERIC || ALPHA_TITAN || ALPHA_MARVEL || ALPHA_TSUNAMI)
        default y
        help
          Support VGA on an arbitrary hose; needed for several platforms
index 1f7fba671ae68a25f204cf819e3e04bde362810e..d70408d36677c86d0fbd8ce90530724e54d15a57 100644 (file)
@@ -1,14 +1,10 @@
 #ifndef _ALPHA_RTC_H
 #define _ALPHA_RTC_H
 
-#if defined(CONFIG_ALPHA_GENERIC)
+#if defined(CONFIG_ALPHA_MARVEL) && defined(CONFIG_SMP) \
+ || defined(CONFIG_ALPHA_GENERIC)
 # define get_rtc_time          alpha_mv.rtc_get_time
 # define set_rtc_time          alpha_mv.rtc_set_time
-#else
-# if defined(CONFIG_ALPHA_MARVEL) && defined(CONFIG_SMP)
-#  define get_rtc_time         marvel_get_rtc_time
-#  define set_rtc_time         marvel_set_rtc_time
-# endif
 #endif
 
 #include <asm-generic/rtc.h>
index 5e7c28f92f19f29dde28d0e636ceb696f1750457..61893d7bdda552ac50e9fadadf957c6b6badb668 100644 (file)
@@ -11,6 +11,7 @@
 #include <asm/core_tsunami.h>
 #undef __EXTERN_INLINE
 
+#include <linux/module.h>
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <linux/sched.h>
index 14a4b6a7cf59d3fa94b121714c7e3c67792618e8..407accc808777bc4a6f36fa6b912b92686d09a0b 100644 (file)
@@ -317,7 +317,7 @@ marvel_init_irq(void)
 }
 
 static int 
-marvel_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+marvel_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
        struct pci_controller *hose = dev->sysdata;
        struct io7_port *io7_port = hose->sysdata;
index ce030c24264409e00a0fd59462322f8876074f15..40ba2d1acde2e80ebc19014da563090db4ea74da 100644 (file)
@@ -468,6 +468,7 @@ config ARCH_MXS
        select ARCH_REQUIRE_GPIOLIB
        select CLKDEV_LOOKUP
        select CLKSRC_MMIO
+       select COMMON_CLK
        select HAVE_CLK_PREPARE
        help
          Support for Freescale MXS-based family of processors
@@ -1187,6 +1188,15 @@ if !MMU
 source "arch/arm/Kconfig-nommu"
 endif
 
+config ARM_ERRATA_326103
+       bool "ARM errata: FSR write bit incorrect on a SWP to read-only memory"
+       depends on CPU_V6
+       help
+         Executing a SWP instruction to read-only memory does not set bit 11
+         of the FSR on the ARM 1136 prior to r1p0. This causes the kernel to
+         treat the access as a read, preventing a COW from occurring and
+         causing the faulting task to livelock.
+
 config ARM_ERRATA_411920
        bool "ARM errata: Invalidation of the Instruction Cache operation can fail"
        depends on CPU_V6 || CPU_V6K
index 15ded0deaa79aec744760a00b8f80e9f81fe4228..45bc4bb04e5745969184b9baa3e78e4d4c5402f3 100644 (file)
@@ -10,7 +10,7 @@
        intc: interrupt-controller@02080000 {
                compatible = "qcom,msm-8660-qgic";
                interrupt-controller;
-               #interrupt-cells = <1>;
+               #interrupt-cells = <3>;
                reg = < 0x02080000 0x1000 >,
                      < 0x02081000 0x1000 >;
        };
@@ -19,6 +19,6 @@
                compatible = "qcom,msm-hsuart", "qcom,msm-uart";
                reg = <0x19c40000 0x1000>,
                      <0x19c00000 0x1000>;
-               interrupts = <195>;
+               interrupts = <0 195 0x0>;
        };
 };
index 0b32925f21474fcb983716aed17205bd50ee10a3..e2fe3195c0d109c6a31853455171627724c2e2d8 100644 (file)
                        mmc@5000 {
                                compatible = "arm,primecell";
                                reg = < 0x5000 0x1000>;
-                               interrupts = <22>;
+                               interrupts = <22 34>;
                        };
                        kmi@6000 {
                                compatible = "arm,pl050", "arm,primecell";
index 166461073b7893ec6dc49a60957bf8ef1d3e106f..7e8175269064d6f5dbf0a0b3bca1b933aa5efd9f 100644 (file)
@@ -41,7 +41,7 @@
                        mmc@b000 {
                                compatible = "arm,primecell";
                                reg = <0xb000 0x1000>;
-                               interrupts = <23>;
+                               interrupts = <23 34>;
                        };
                };
        };
index 42da9183acc85509342b00bc14a458a6d5d6a267..082175c54e7cc7343a15c7d0f15f3ddbf5631c8a 100644 (file)
@@ -14,6 +14,8 @@ CONFIG_MODULE_FORCE_UNLOAD=y
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_BLK_DEV_INTEGRITY=y
 CONFIG_ARCH_S3C24XX=y
+# CONFIG_CPU_S3C2410 is not set
+CONFIG_CPU_S3C2440=y
 CONFIG_S3C_ADC=y
 CONFIG_S3C24XX_PWM=y
 CONFIG_MACH_MINI2440=y
index d4c24d412a8ddbdaba9f11a6217cd6a8b592c22c..0f04d84582e1d81ef5448ee180d23b42c80a2eee 100644 (file)
@@ -118,6 +118,13 @@ extern void iwmmxt_task_switch(struct thread_info *);
 extern void vfp_sync_hwstate(struct thread_info *);
 extern void vfp_flush_hwstate(struct thread_info *);
 
+struct user_vfp;
+struct user_vfp_exc;
+
+extern int vfp_preserve_user_clear_hwstate(struct user_vfp __user *,
+                                          struct user_vfp_exc __user *);
+extern int vfp_restore_user_hwstate(struct user_vfp __user *,
+                                   struct user_vfp_exc __user *);
 #endif
 
 /*
index 60843eb0f61c3f9f9536d3ebaebc05b3cdfd2189..73409e6c0251001b5b03f27ae811a523cc605f62 100644 (file)
@@ -7,6 +7,8 @@
 
        .macro set_tls_v6k, tp, tmp1, tmp2
        mcr     p15, 0, \tp, c13, c0, 3         @ set TLS register
+       mov     \tmp1, #0
+       mcr     p15, 0, \tmp1, c13, c0, 2       @ clear user r/w TLS register
        .endm
 
        .macro set_tls_v6, tp, tmp1, tmp2
@@ -15,6 +17,8 @@
        mov     \tmp2, #0xffff0fff
        tst     \tmp1, #HWCAP_TLS               @ hardware TLS available?
        mcrne   p15, 0, \tp, c13, c0, 3         @ yes, set TLS register
+       movne   \tmp1, #0
+       mcrne   p15, 0, \tmp1, c13, c0, 2       @ clear user r/w TLS register
        streq   \tp, [\tmp2, #-15]              @ set TLS value at 0xffff0ff0
        .endm
 
index 71ccdbfed66276f2c76db1b683da17cab392f0ad..8349d4e97e2b8b9b7bb5672b2cf974c2cdb74fd0 100644 (file)
@@ -155,10 +155,10 @@ static bool migrate_one_irq(struct irq_desc *desc)
        }
 
        c = irq_data_get_irq_chip(d);
-       if (c->irq_set_affinity)
-               c->irq_set_affinity(d, affinity, true);
-       else
+       if (!c->irq_set_affinity)
                pr_debug("IRQ%u: unable to set affinity\n", d->irq);
+       else if (c->irq_set_affinity(d, affinity, true) == IRQ_SET_MASK_OK && ret)
+               cpumask_copy(d->affinity, affinity);
 
        return ret;
 }
index 7cb532fc8aa4e3a9dc1e9d63d4cb887a08b1fad1..d68d1b6946809831458d03d8a020ea32f571c62f 100644 (file)
@@ -180,44 +180,23 @@ static int restore_iwmmxt_context(struct iwmmxt_sigframe *frame)
 
 static int preserve_vfp_context(struct vfp_sigframe __user *frame)
 {
-       struct thread_info *thread = current_thread_info();
-       struct vfp_hard_struct *h = &thread->vfpstate.hard;
        const unsigned long magic = VFP_MAGIC;
        const unsigned long size = VFP_STORAGE_SIZE;
        int err = 0;
 
-       vfp_sync_hwstate(thread);
        __put_user_error(magic, &frame->magic, err);
        __put_user_error(size, &frame->size, err);
 
-       /*
-        * Copy the floating point registers. There can be unused
-        * registers see asm/hwcap.h for details.
-        */
-       err |= __copy_to_user(&frame->ufp.fpregs, &h->fpregs,
-                             sizeof(h->fpregs));
-       /*
-        * Copy the status and control register.
-        */
-       __put_user_error(h->fpscr, &frame->ufp.fpscr, err);
-
-       /*
-        * Copy the exception registers.
-        */
-       __put_user_error(h->fpexc, &frame->ufp_exc.fpexc, err);
-       __put_user_error(h->fpinst, &frame->ufp_exc.fpinst, err);
-       __put_user_error(h->fpinst2, &frame->ufp_exc.fpinst2, err);
+       if (err)
+               return -EFAULT;
 
-       return err ? -EFAULT : 0;
+       return vfp_preserve_user_clear_hwstate(&frame->ufp, &frame->ufp_exc);
 }
 
 static int restore_vfp_context(struct vfp_sigframe __user *frame)
 {
-       struct thread_info *thread = current_thread_info();
-       struct vfp_hard_struct *h = &thread->vfpstate.hard;
        unsigned long magic;
        unsigned long size;
-       unsigned long fpexc;
        int err = 0;
 
        __get_user_error(magic, &frame->magic, err);
@@ -228,33 +207,7 @@ static int restore_vfp_context(struct vfp_sigframe __user *frame)
        if (magic != VFP_MAGIC || size != VFP_STORAGE_SIZE)
                return -EINVAL;
 
-       vfp_flush_hwstate(thread);
-
-       /*
-        * Copy the floating point registers. There can be unused
-        * registers see asm/hwcap.h for details.
-        */
-       err |= __copy_from_user(&h->fpregs, &frame->ufp.fpregs,
-                               sizeof(h->fpregs));
-       /*
-        * Copy the status and control register.
-        */
-       __get_user_error(h->fpscr, &frame->ufp.fpscr, err);
-
-       /*
-        * Sanitise and restore the exception registers.
-        */
-       __get_user_error(fpexc, &frame->ufp_exc.fpexc, err);
-       /* Ensure the VFP is enabled. */
-       fpexc |= FPEXC_EN;
-       /* Ensure FPINST2 is invalid and the exception flag is cleared. */
-       fpexc &= ~(FPEXC_EX | FPEXC_FP2V);
-       h->fpexc = fpexc;
-
-       __get_user_error(h->fpinst, &frame->ufp_exc.fpinst, err);
-       __get_user_error(h->fpinst2, &frame->ufp_exc.fpinst2, err);
-
-       return err ? -EFAULT : 0;
+       return vfp_restore_user_hwstate(&frame->ufp, &frame->ufp_exc);
 }
 
 #endif
index addbbe8028c29c8789fd730fa784b056065787e5..f6a4d32b0421a9dd35fa1ca2884e8980374a76a3 100644 (file)
@@ -510,10 +510,6 @@ static void ipi_cpu_stop(unsigned int cpu)
        local_fiq_disable();
        local_irq_disable();
 
-#ifdef CONFIG_HOTPLUG_CPU
-       platform_cpu_kill(cpu);
-#endif
-
        while (1)
                cpu_relax();
 }
@@ -576,17 +572,25 @@ void smp_send_reschedule(int cpu)
        smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
 }
 
+#ifdef CONFIG_HOTPLUG_CPU
+static void smp_kill_cpus(cpumask_t *mask)
+{
+       unsigned int cpu;
+       for_each_cpu(cpu, mask)
+               platform_cpu_kill(cpu);
+}
+#else
+static void smp_kill_cpus(cpumask_t *mask) { }
+#endif
+
 void smp_send_stop(void)
 {
        unsigned long timeout;
+       struct cpumask mask;
 
-       if (num_online_cpus() > 1) {
-               struct cpumask mask;
-               cpumask_copy(&mask, cpu_online_mask);
-               cpumask_clear_cpu(smp_processor_id(), &mask);
-
-               smp_cross_call(&mask, IPI_CPU_STOP);
-       }
+       cpumask_copy(&mask, cpu_online_mask);
+       cpumask_clear_cpu(smp_processor_id(), &mask);
+       smp_cross_call(&mask, IPI_CPU_STOP);
 
        /* Wait up to one second for other CPUs to stop */
        timeout = USEC_PER_SEC;
@@ -595,6 +599,8 @@ void smp_send_stop(void)
 
        if (num_online_cpus() > 1)
                pr_warning("SMP: failed to stop secondary CPUs\n");
+
+       smp_kill_cpus(&mask);
 }
 
 /*
index 5b150afb995b8c49857c05b3cd3e70d80e101fbe..fef42b21cecba517e67e8ed74ef8c88d3cfd2afd 100644 (file)
@@ -118,14 +118,10 @@ static int twd_cpufreq_transition(struct notifier_block *nb,
         * The twd clock events must be reprogrammed to account for the new
         * frequency.  The timer is local to a cpu, so cross-call to the
         * changing cpu.
-        *
-        * Only wait for it to finish, if the cpu is active to avoid
-        * deadlock when cpu1 is spinning on while(!cpu_active(cpu1)) during
-        * booting of that cpu.
         */
        if (state == CPUFREQ_POSTCHANGE || state == CPUFREQ_RESUMECHANGE)
                smp_call_function_single(freqs->cpu, twd_update_frequency,
-                                        NULL, cpu_active(freqs->cpu));
+                       NULL, 1);
 
        return NOTIFY_OK;
 }
index df54c2a922252826b6b2f837134da025ca2a6994..6efd1e5919fdebcd389e61cf48e25b1967a75bb1 100644 (file)
@@ -497,25 +497,25 @@ static struct clk exynos4_init_clocks_off[] = {
                .ctrlbit        = (1 << 3),
        }, {
                .name           = "hsmmc",
-               .devname        = "s3c-sdhci.0",
+               .devname        = "exynos4-sdhci.0",
                .parent         = &exynos4_clk_aclk_133.clk,
                .enable         = exynos4_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 5),
        }, {
                .name           = "hsmmc",
-               .devname        = "s3c-sdhci.1",
+               .devname        = "exynos4-sdhci.1",
                .parent         = &exynos4_clk_aclk_133.clk,
                .enable         = exynos4_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 6),
        }, {
                .name           = "hsmmc",
-               .devname        = "s3c-sdhci.2",
+               .devname        = "exynos4-sdhci.2",
                .parent         = &exynos4_clk_aclk_133.clk,
                .enable         = exynos4_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 7),
        }, {
                .name           = "hsmmc",
-               .devname        = "s3c-sdhci.3",
+               .devname        = "exynos4-sdhci.3",
                .parent         = &exynos4_clk_aclk_133.clk,
                .enable         = exynos4_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 8),
@@ -1202,7 +1202,7 @@ static struct clksrc_clk exynos4_clk_sclk_uart3 = {
 static struct clksrc_clk exynos4_clk_sclk_mmc0 = {
        .clk    = {
                .name           = "sclk_mmc",
-               .devname        = "s3c-sdhci.0",
+               .devname        = "exynos4-sdhci.0",
                .parent         = &exynos4_clk_dout_mmc0.clk,
                .enable         = exynos4_clksrc_mask_fsys_ctrl,
                .ctrlbit        = (1 << 0),
@@ -1213,7 +1213,7 @@ static struct clksrc_clk exynos4_clk_sclk_mmc0 = {
 static struct clksrc_clk exynos4_clk_sclk_mmc1 = {
        .clk    = {
                .name           = "sclk_mmc",
-               .devname        = "s3c-sdhci.1",
+               .devname        = "exynos4-sdhci.1",
                .parent         = &exynos4_clk_dout_mmc1.clk,
                .enable         = exynos4_clksrc_mask_fsys_ctrl,
                .ctrlbit        = (1 << 4),
@@ -1224,7 +1224,7 @@ static struct clksrc_clk exynos4_clk_sclk_mmc1 = {
 static struct clksrc_clk exynos4_clk_sclk_mmc2 = {
        .clk    = {
                .name           = "sclk_mmc",
-               .devname        = "s3c-sdhci.2",
+               .devname        = "exynos4-sdhci.2",
                .parent         = &exynos4_clk_dout_mmc2.clk,
                .enable         = exynos4_clksrc_mask_fsys_ctrl,
                .ctrlbit        = (1 << 8),
@@ -1235,7 +1235,7 @@ static struct clksrc_clk exynos4_clk_sclk_mmc2 = {
 static struct clksrc_clk exynos4_clk_sclk_mmc3 = {
        .clk    = {
                .name           = "sclk_mmc",
-               .devname        = "s3c-sdhci.3",
+               .devname        = "exynos4-sdhci.3",
                .parent         = &exynos4_clk_dout_mmc3.clk,
                .enable         = exynos4_clksrc_mask_fsys_ctrl,
                .ctrlbit        = (1 << 12),
@@ -1340,10 +1340,10 @@ static struct clk_lookup exynos4_clk_lookup[] = {
        CLKDEV_INIT("exynos4210-uart.1", "clk_uart_baud0", &exynos4_clk_sclk_uart1.clk),
        CLKDEV_INIT("exynos4210-uart.2", "clk_uart_baud0", &exynos4_clk_sclk_uart2.clk),
        CLKDEV_INIT("exynos4210-uart.3", "clk_uart_baud0", &exynos4_clk_sclk_uart3.clk),
-       CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &exynos4_clk_sclk_mmc0.clk),
-       CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &exynos4_clk_sclk_mmc1.clk),
-       CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &exynos4_clk_sclk_mmc2.clk),
-       CLKDEV_INIT("s3c-sdhci.3", "mmc_busclk.2", &exynos4_clk_sclk_mmc3.clk),
+       CLKDEV_INIT("exynos4-sdhci.0", "mmc_busclk.2", &exynos4_clk_sclk_mmc0.clk),
+       CLKDEV_INIT("exynos4-sdhci.1", "mmc_busclk.2", &exynos4_clk_sclk_mmc1.clk),
+       CLKDEV_INIT("exynos4-sdhci.2", "mmc_busclk.2", &exynos4_clk_sclk_mmc2.clk),
+       CLKDEV_INIT("exynos4-sdhci.3", "mmc_busclk.2", &exynos4_clk_sclk_mmc3.clk),
        CLKDEV_INIT("exynos4-fb.0", "lcd", &exynos4_clk_fimd0),
        CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos4_clk_pdma0),
        CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos4_clk_pdma1),
index d013982d0f8e1bc9e49a80824069c7214dec36be..5cd7a8b8868ce0fbb7e48a1a393e020d17cdcd88 100644 (file)
@@ -455,25 +455,25 @@ static struct clk exynos5_init_clocks_off[] = {
                .ctrlbit        = (1 << 20),
        }, {
                .name           = "hsmmc",
-               .devname        = "s3c-sdhci.0",
+               .devname        = "exynos4-sdhci.0",
                .parent         = &exynos5_clk_aclk_200.clk,
                .enable         = exynos5_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 12),
        }, {
                .name           = "hsmmc",
-               .devname        = "s3c-sdhci.1",
+               .devname        = "exynos4-sdhci.1",
                .parent         = &exynos5_clk_aclk_200.clk,
                .enable         = exynos5_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 13),
        }, {
                .name           = "hsmmc",
-               .devname        = "s3c-sdhci.2",
+               .devname        = "exynos4-sdhci.2",
                .parent         = &exynos5_clk_aclk_200.clk,
                .enable         = exynos5_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 14),
        }, {
                .name           = "hsmmc",
-               .devname        = "s3c-sdhci.3",
+               .devname        = "exynos4-sdhci.3",
                .parent         = &exynos5_clk_aclk_200.clk,
                .enable         = exynos5_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 15),
@@ -813,7 +813,7 @@ static struct clksrc_clk exynos5_clk_sclk_uart3 = {
 static struct clksrc_clk exynos5_clk_sclk_mmc0 = {
        .clk    = {
                .name           = "sclk_mmc",
-               .devname        = "s3c-sdhci.0",
+               .devname        = "exynos4-sdhci.0",
                .parent         = &exynos5_clk_dout_mmc0.clk,
                .enable         = exynos5_clksrc_mask_fsys_ctrl,
                .ctrlbit        = (1 << 0),
@@ -824,7 +824,7 @@ static struct clksrc_clk exynos5_clk_sclk_mmc0 = {
 static struct clksrc_clk exynos5_clk_sclk_mmc1 = {
        .clk    = {
                .name           = "sclk_mmc",
-               .devname        = "s3c-sdhci.1",
+               .devname        = "exynos4-sdhci.1",
                .parent         = &exynos5_clk_dout_mmc1.clk,
                .enable         = exynos5_clksrc_mask_fsys_ctrl,
                .ctrlbit        = (1 << 4),
@@ -835,7 +835,7 @@ static struct clksrc_clk exynos5_clk_sclk_mmc1 = {
 static struct clksrc_clk exynos5_clk_sclk_mmc2 = {
        .clk    = {
                .name           = "sclk_mmc",
-               .devname        = "s3c-sdhci.2",
+               .devname        = "exynos4-sdhci.2",
                .parent         = &exynos5_clk_dout_mmc2.clk,
                .enable         = exynos5_clksrc_mask_fsys_ctrl,
                .ctrlbit        = (1 << 8),
@@ -846,7 +846,7 @@ static struct clksrc_clk exynos5_clk_sclk_mmc2 = {
 static struct clksrc_clk exynos5_clk_sclk_mmc3 = {
        .clk    = {
                .name           = "sclk_mmc",
-               .devname        = "s3c-sdhci.3",
+               .devname        = "exynos4-sdhci.3",
                .parent         = &exynos5_clk_dout_mmc3.clk,
                .enable         = exynos5_clksrc_mask_fsys_ctrl,
                .ctrlbit        = (1 << 12),
@@ -990,10 +990,10 @@ static struct clk_lookup exynos5_clk_lookup[] = {
        CLKDEV_INIT("exynos4210-uart.1", "clk_uart_baud0", &exynos5_clk_sclk_uart1.clk),
        CLKDEV_INIT("exynos4210-uart.2", "clk_uart_baud0", &exynos5_clk_sclk_uart2.clk),
        CLKDEV_INIT("exynos4210-uart.3", "clk_uart_baud0", &exynos5_clk_sclk_uart3.clk),
-       CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &exynos5_clk_sclk_mmc0.clk),
-       CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &exynos5_clk_sclk_mmc1.clk),
-       CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &exynos5_clk_sclk_mmc2.clk),
-       CLKDEV_INIT("s3c-sdhci.3", "mmc_busclk.2", &exynos5_clk_sclk_mmc3.clk),
+       CLKDEV_INIT("exynos4-sdhci.0", "mmc_busclk.2", &exynos5_clk_sclk_mmc0.clk),
+       CLKDEV_INIT("exynos4-sdhci.1", "mmc_busclk.2", &exynos5_clk_sclk_mmc1.clk),
+       CLKDEV_INIT("exynos4-sdhci.2", "mmc_busclk.2", &exynos5_clk_sclk_mmc2.clk),
+       CLKDEV_INIT("exynos4-sdhci.3", "mmc_busclk.2", &exynos5_clk_sclk_mmc3.clk),
        CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos5_clk_pdma0),
        CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos5_clk_pdma1),
        CLKDEV_INIT("dma-pl330.2", "apb_pclk", &exynos5_clk_mdma1),
index 8614aab47cc0e1a4c9cc51549f89af9c17316558..5ccd6e80a607fec8750409d6d5731dfa92f2a73e 100644 (file)
@@ -326,6 +326,11 @@ static void __init exynos4_map_io(void)
        s3c_fimc_setname(2, "exynos4-fimc");
        s3c_fimc_setname(3, "exynos4-fimc");
 
+       s3c_sdhci_setname(0, "exynos4-sdhci");
+       s3c_sdhci_setname(1, "exynos4-sdhci");
+       s3c_sdhci_setname(2, "exynos4-sdhci");
+       s3c_sdhci_setname(3, "exynos4-sdhci");
+
        /* The I2C bus controllers are directly compatible with s3c2440 */
        s3c_i2c0_setname("s3c2440-i2c");
        s3c_i2c1_setname("s3c2440-i2c");
@@ -344,6 +349,11 @@ static void __init exynos5_map_io(void)
        s3c_device_i2c0.resource[1].start = EXYNOS5_IRQ_IIC;
        s3c_device_i2c0.resource[1].end   = EXYNOS5_IRQ_IIC;
 
+       s3c_sdhci_setname(0, "exynos4-sdhci");
+       s3c_sdhci_setname(1, "exynos4-sdhci");
+       s3c_sdhci_setname(2, "exynos4-sdhci");
+       s3c_sdhci_setname(3, "exynos4-sdhci");
+
        /* The I2C bus controllers are directly compatible with s3c2440 */
        s3c_i2c0_setname("s3c2440-i2c");
        s3c_i2c1_setname("s3c2440-i2c");
@@ -537,7 +547,9 @@ void __init exynos5_init_irq(void)
 {
        int irq;
 
-       gic_init(0, IRQ_PPI(0), S5P_VA_GIC_DIST, S5P_VA_GIC_CPU);
+#ifdef CONFIG_OF
+       of_irq_init(exynos4_dt_irq_match);
+#endif
 
        for (irq = 0; irq < EXYNOS5_MAX_COMBINER_NR; irq++) {
                combiner_init(irq, (void __iomem *)S5P_VA_COMBINER(irq),
index b025db4bf602380e465402381a270668ece4b41f..79035018fb746da2a5c0a284bbc2b229d3cebbe9 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
+#include <linux/ioport.h>
 #include <linux/mmc/dw_mmc.h>
 
 #include <plat/devs.h>
@@ -33,16 +34,8 @@ static int exynos4_dwmci_init(u32 slot_id, irq_handler_t handler, void *data)
 }
 
 static struct resource exynos4_dwmci_resource[] = {
-       [0] = {
-               .start  = EXYNOS4_PA_DWMCI,
-               .end    = EXYNOS4_PA_DWMCI + SZ_4K - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = IRQ_DWMCI,
-               .end    = IRQ_DWMCI,
-               .flags  = IORESOURCE_IRQ,
-       }
+       [0] = DEFINE_RES_MEM(EXYNOS4_PA_DWMCI, SZ_4K),
+       [1] = DEFINE_RES_IRQ(EXYNOS4_IRQ_DWMCI),
 };
 
 static struct dw_mci_board exynos4_dwci_pdata = {
index b4f1f902ce6d06a82cd9f9f00d90caa0e9548782..ed90aef404c3175259e4a4ba576e60a6bb018a3f 100644 (file)
@@ -112,6 +112,7 @@ static struct s3c_sdhci_platdata nuri_hsmmc0_data __initdata = {
        .host_caps              = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
                                MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
                                MMC_CAP_ERASE),
+       .host_caps2             = MMC_CAP2_BROKEN_VOLTAGE,
        .cd_type                = S3C_SDHCI_CD_PERMANENT,
        .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
 };
index 7ebf79c2ab348bd273099716d9bd1b4df6cdc572..cb2b027f09a603800477a31bfeb765b27f829942 100644 (file)
@@ -747,6 +747,7 @@ static struct s3c_sdhci_platdata universal_hsmmc0_data __initdata = {
        .max_width              = 8,
        .host_caps              = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
                                MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
+       .host_caps2             = MMC_CAP2_BROKEN_VOLTAGE,
        .cd_type                = S3C_SDHCI_CD_PERMANENT,
        .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
 };
index 7561eca131b0ba989c42afb1a5ec94fbce98f688..c8e4ec11751764933d9902634684477e6b287ce6 100644 (file)
@@ -34,6 +34,7 @@ config ARCH_MX53
 config SOC_IMX1
        bool
        select ARCH_MX1
+       select COMMON_CLK
        select CPU_ARM920T
        select IMX_HAVE_IOMUX_V1
        select MXC_AVIC
@@ -42,12 +43,14 @@ config SOC_IMX21
        bool
        select MACH_MX21
        select CPU_ARM926T
+       select COMMON_CLK
        select IMX_HAVE_IOMUX_V1
        select MXC_AVIC
 
 config SOC_IMX25
        bool
        select ARCH_MX25
+       select COMMON_CLK
        select CPU_ARM926T
        select ARCH_MXC_IOMUX_V3
        select MXC_AVIC
@@ -56,6 +59,7 @@ config SOC_IMX27
        bool
        select MACH_MX27
        select CPU_ARM926T
+       select COMMON_CLK
        select IMX_HAVE_IOMUX_V1
        select MXC_AVIC
 
@@ -64,12 +68,14 @@ config SOC_IMX31
        select CPU_V6
        select IMX_HAVE_PLATFORM_MXC_RNGA
        select MXC_AVIC
+       select COMMON_CLK
        select SMP_ON_UP if SMP
 
 config SOC_IMX35
        bool
        select CPU_V6
        select ARCH_MXC_IOMUX_V3
+       select COMMON_CLK
        select HAVE_EPIT
        select MXC_AVIC
        select SMP_ON_UP if SMP
@@ -77,6 +83,7 @@ config SOC_IMX35
 config SOC_IMX5
        select CPU_V7
        select MXC_TZIC
+       select COMMON_CLK
        select ARCH_MXC_IOMUX_V3
        select ARCH_HAS_CPUFREQ
        select ARCH_MX5
@@ -836,6 +843,7 @@ config SOC_IMX6Q
        bool "i.MX6 Quad support"
        select ARM_CPU_SUSPEND if PM
        select ARM_GIC
+       select COMMON_CLK
        select CPU_V7
        select HAVE_ARM_SCU
        select HAVE_IMX_GPC
index ab939c5046c37080692a37592944ccfa7a2c4100..629a3394feac42b5ce2a189b0c9e7c7eeadb518c 100644 (file)
@@ -1,15 +1,18 @@
-obj-$(CONFIG_SOC_IMX1) += clock-imx1.o mm-imx1.o
-obj-$(CONFIG_SOC_IMX21) += clock-imx21.o mm-imx21.o
+obj-$(CONFIG_SOC_IMX1) += clk-imx1.o mm-imx1.o
+obj-$(CONFIG_SOC_IMX21) += clk-imx21.o mm-imx21.o
 
-obj-$(CONFIG_SOC_IMX25) += clock-imx25.o mm-imx25.o ehci-imx25.o cpu-imx25.o
+obj-$(CONFIG_SOC_IMX25) += clk-imx25.o mm-imx25.o ehci-imx25.o cpu-imx25.o
 
 obj-$(CONFIG_SOC_IMX27) += cpu-imx27.o pm-imx27.o
-obj-$(CONFIG_SOC_IMX27) += clock-imx27.o mm-imx27.o ehci-imx27.o
+obj-$(CONFIG_SOC_IMX27) += clk-imx27.o mm-imx27.o ehci-imx27.o
 
-obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clock-imx31.o iomux-imx31.o ehci-imx31.o pm-imx3.o
-obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clock-imx35.o ehci-imx35.o pm-imx3.o
+obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clk-imx31.o iomux-imx31.o ehci-imx31.o pm-imx3.o
+obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clk-imx35.o ehci-imx35.o pm-imx3.o
 
-obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clock-mx51-mx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o
+obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clk-imx51-imx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o
+
+obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-gate2.o \
+                           clk-pfd.o clk-busy.o
 
 # Support for CMOS sensor interface
 obj-$(CONFIG_MX1_VIDEO) += mx1-camera-fiq.o mx1-camera-fiq-ksym.o
@@ -70,7 +73,7 @@ obj-$(CONFIG_CPU_V7) += head-v7.o
 AFLAGS_head-v7.o :=-Wa,-march=armv7-a
 obj-$(CONFIG_SMP) += platsmp.o
 obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
-obj-$(CONFIG_SOC_IMX6Q) += clock-imx6q.o mach-imx6q.o
+obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o mach-imx6q.o
 
 ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o
diff --git a/arch/arm/mach-imx/clk-busy.c b/arch/arm/mach-imx/clk-busy.c
new file mode 100644 (file)
index 0000000..1a7a8dd
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2012 Linaro Ltd.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/jiffies.h>
+#include <linux/err.h>
+#include "clk.h"
+
+static int clk_busy_wait(void __iomem *reg, u8 shift)
+{
+       unsigned long timeout = jiffies + msecs_to_jiffies(10);
+
+       while (readl_relaxed(reg) & (1 << shift))
+               if (time_after(jiffies, timeout))
+                       return -ETIMEDOUT;
+
+       return 0;
+}
+
+struct clk_busy_divider {
+       struct clk_divider div;
+       const struct clk_ops *div_ops;
+       void __iomem *reg;
+       u8 shift;
+};
+
+static inline struct clk_busy_divider *to_clk_busy_divider(struct clk_hw *hw)
+{
+       struct clk_divider *div = container_of(hw, struct clk_divider, hw);
+
+       return container_of(div, struct clk_busy_divider, div);
+}
+
+static unsigned long clk_busy_divider_recalc_rate(struct clk_hw *hw,
+                                                 unsigned long parent_rate)
+{
+       struct clk_busy_divider *busy = to_clk_busy_divider(hw);
+
+       return busy->div_ops->recalc_rate(&busy->div.hw, parent_rate);
+}
+
+static long clk_busy_divider_round_rate(struct clk_hw *hw, unsigned long rate,
+                                       unsigned long *prate)
+{
+       struct clk_busy_divider *busy = to_clk_busy_divider(hw);
+
+       return busy->div_ops->round_rate(&busy->div.hw, rate, prate);
+}
+
+static int clk_busy_divider_set_rate(struct clk_hw *hw, unsigned long rate,
+               unsigned long parent_rate)
+{
+       struct clk_busy_divider *busy = to_clk_busy_divider(hw);
+       int ret;
+
+       ret = busy->div_ops->set_rate(&busy->div.hw, rate, parent_rate);
+       if (!ret)
+               ret = clk_busy_wait(busy->reg, busy->shift);
+
+       return ret;
+}
+
+static struct clk_ops clk_busy_divider_ops = {
+       .recalc_rate = clk_busy_divider_recalc_rate,
+       .round_rate = clk_busy_divider_round_rate,
+       .set_rate = clk_busy_divider_set_rate,
+};
+
+struct clk *imx_clk_busy_divider(const char *name, const char *parent_name,
+                                void __iomem *reg, u8 shift, u8 width,
+                                void __iomem *busy_reg, u8 busy_shift)
+{
+       struct clk_busy_divider *busy;
+       struct clk *clk;
+       struct clk_init_data init;
+
+       busy = kzalloc(sizeof(*busy), GFP_KERNEL);
+       if (!busy)
+               return ERR_PTR(-ENOMEM);
+
+       busy->reg = busy_reg;
+       busy->shift = busy_shift;
+
+       busy->div.reg = reg;
+       busy->div.shift = shift;
+       busy->div.width = width;
+       busy->div.lock = &imx_ccm_lock;
+       busy->div_ops = &clk_divider_ops;
+
+       init.name = name;
+       init.ops = &clk_busy_divider_ops;
+       init.flags = CLK_SET_RATE_PARENT;
+       init.parent_names = &parent_name;
+       init.num_parents = 1;
+
+       busy->div.hw.init = &init;
+
+       clk = clk_register(NULL, &busy->div.hw);
+       if (!clk)
+               kfree(busy);
+
+       return clk;
+}
+
+struct clk_busy_mux {
+       struct clk_mux mux;
+       const struct clk_ops *mux_ops;
+       void __iomem *reg;
+       u8 shift;
+};
+
+static inline struct clk_busy_mux *to_clk_busy_mux(struct clk_hw *hw)
+{
+       struct clk_mux *mux = container_of(hw, struct clk_mux, hw);
+
+       return container_of(mux, struct clk_busy_mux, mux);
+}
+
+static u8 clk_busy_mux_get_parent(struct clk_hw *hw)
+{
+       struct clk_busy_mux *busy = to_clk_busy_mux(hw);
+
+       return busy->mux_ops->get_parent(&busy->mux.hw);
+}
+
+static int clk_busy_mux_set_parent(struct clk_hw *hw, u8 index)
+{
+       struct clk_busy_mux *busy = to_clk_busy_mux(hw);
+       int ret;
+
+       ret = busy->mux_ops->set_parent(&busy->mux.hw, index);
+       if (!ret)
+               ret = clk_busy_wait(busy->reg, busy->shift);
+
+       return ret;
+}
+
+struct clk_ops clk_busy_mux_ops = {
+       .get_parent = clk_busy_mux_get_parent,
+       .set_parent = clk_busy_mux_set_parent,
+};
+
+struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift,
+                            u8 width, void __iomem *busy_reg, u8 busy_shift,
+                            const char **parent_names, int num_parents)
+{
+       struct clk_busy_mux *busy;
+       struct clk *clk;
+       struct clk_init_data init;
+
+       busy = kzalloc(sizeof(*busy), GFP_KERNEL);
+       if (!busy)
+               return ERR_PTR(-ENOMEM);
+
+       busy->reg = busy_reg;
+       busy->shift = busy_shift;
+
+       busy->mux.reg = reg;
+       busy->mux.shift = shift;
+       busy->mux.width = width;
+       busy->mux.lock = &imx_ccm_lock;
+       busy->mux_ops = &clk_mux_ops;
+
+       init.name = name;
+       init.ops = &clk_busy_mux_ops;
+       init.flags = 0;
+       init.parent_names = parent_names;
+       init.num_parents = num_parents;
+
+       busy->mux.hw.init = &init;
+
+       clk = clk_register(NULL, &busy->mux.hw);
+       if (IS_ERR(clk))
+               kfree(busy);
+
+       return clk;
+}
diff --git a/arch/arm/mach-imx/clk-gate2.c b/arch/arm/mach-imx/clk-gate2.c
new file mode 100644 (file)
index 0000000..3c1b8ff
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2010-2011 Canonical Ltd <jeremy.kerr@canonical.com>
+ * Copyright (C) 2011-2012 Mike Turquette, Linaro Ltd <mturquette@linaro.org>
+ *
+ * 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.
+ *
+ * Gated clock implementation
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/string.h>
+
+/**
+ * DOC: basic gatable clock which can gate and ungate it's ouput
+ *
+ * Traits of this clock:
+ * prepare - clk_(un)prepare only ensures parent is (un)prepared
+ * enable - clk_enable and clk_disable are functional & control gating
+ * rate - inherits rate from parent.  No clk_set_rate support
+ * parent - fixed parent.  No clk_set_parent support
+ */
+
+#define to_clk_gate(_hw) container_of(_hw, struct clk_gate, hw)
+
+static int clk_gate2_enable(struct clk_hw *hw)
+{
+       struct clk_gate *gate = to_clk_gate(hw);
+       u32 reg;
+       unsigned long flags = 0;
+
+       if (gate->lock)
+               spin_lock_irqsave(gate->lock, flags);
+
+       reg = readl(gate->reg);
+       reg |= 3 << gate->bit_idx;
+       writel(reg, gate->reg);
+
+       if (gate->lock)
+               spin_unlock_irqrestore(gate->lock, flags);
+
+       return 0;
+}
+
+static void clk_gate2_disable(struct clk_hw *hw)
+{
+       struct clk_gate *gate = to_clk_gate(hw);
+       u32 reg;
+       unsigned long flags = 0;
+
+       if (gate->lock)
+               spin_lock_irqsave(gate->lock, flags);
+
+       reg = readl(gate->reg);
+       reg &= ~(3 << gate->bit_idx);
+       writel(reg, gate->reg);
+
+       if (gate->lock)
+               spin_unlock_irqrestore(gate->lock, flags);
+}
+
+static int clk_gate2_is_enabled(struct clk_hw *hw)
+{
+       u32 reg;
+       struct clk_gate *gate = to_clk_gate(hw);
+
+       reg = readl(gate->reg);
+
+       if (((reg >> gate->bit_idx) & 3) == 3)
+               return 1;
+
+       return 0;
+}
+
+static struct clk_ops clk_gate2_ops = {
+       .enable = clk_gate2_enable,
+       .disable = clk_gate2_disable,
+       .is_enabled = clk_gate2_is_enabled,
+};
+
+struct clk *clk_register_gate2(struct device *dev, const char *name,
+               const char *parent_name, unsigned long flags,
+               void __iomem *reg, u8 bit_idx,
+               u8 clk_gate2_flags, spinlock_t *lock)
+{
+       struct clk_gate *gate;
+       struct clk *clk;
+       struct clk_init_data init;
+
+       gate = kzalloc(sizeof(struct clk_gate), GFP_KERNEL);
+       if (!gate)
+               return ERR_PTR(-ENOMEM);
+
+       /* struct clk_gate assignments */
+       gate->reg = reg;
+       gate->bit_idx = bit_idx;
+       gate->flags = clk_gate2_flags;
+       gate->lock = lock;
+
+       init.name = name;
+       init.ops = &clk_gate2_ops;
+       init.flags = flags;
+       init.parent_names = parent_name ? &parent_name : NULL;
+       init.num_parents = parent_name ? 1 : 0;
+
+       gate->hw.init = &init;
+
+       clk = clk_register(dev, &gate->hw);
+       if (IS_ERR(clk))
+               kfree(clk);
+
+       return clk;
+}
diff --git a/arch/arm/mach-imx/clk-imx1.c b/arch/arm/mach-imx/clk-imx1.c
new file mode 100644 (file)
index 0000000..0f0beb5
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ *  Copyright (C) 2008 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/clkdev.h>
+#include <linux/err.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include "clk.h"
+
+/* CCM register addresses */
+#define IO_ADDR_CCM(off)       (MX1_IO_ADDRESS(MX1_CCM_BASE_ADDR + (off)))
+
+#define CCM_CSCR       IO_ADDR_CCM(0x0)
+#define CCM_MPCTL0     IO_ADDR_CCM(0x4)
+#define CCM_SPCTL0     IO_ADDR_CCM(0xc)
+#define CCM_PCDR       IO_ADDR_CCM(0x20)
+
+/* SCM register addresses */
+#define IO_ADDR_SCM(off)       (MX1_IO_ADDRESS(MX1_SCM_BASE_ADDR + (off)))
+
+#define SCM_GCCR       IO_ADDR_SCM(0xc)
+
+static const char *prem_sel_clks[] = { "clk32_premult", "clk16m", };
+static const char *clko_sel_clks[] = { "per1", "hclk", "clk48m", "clk16m", "prem",
+                               "fclk", };
+enum imx1_clks {
+       dummy, clk32, clk16m_ext, clk16m, clk32_premult, prem, mpll, spll, mcu,
+       fclk, hclk, clk48m, per1, per2, per3, clko, dma_gate, csi_gate,
+       mma_gate, usbd_gate, clk_max
+};
+
+static struct clk *clk[clk_max];
+
+int __init mx1_clocks_init(unsigned long fref)
+{
+       int i;
+
+       clk[dummy] = imx_clk_fixed("dummy", 0);
+       clk[clk32] = imx_clk_fixed("clk32", fref);
+       clk[clk16m_ext] = imx_clk_fixed("clk16m_ext", 16000000);
+       clk[clk16m] = imx_clk_gate("clk16m", "clk16m_ext", CCM_CSCR, 17);
+       clk[clk32_premult] = imx_clk_fixed_factor("clk32_premult", "clk32", 512, 1);
+       clk[prem] = imx_clk_mux("prem", CCM_CSCR, 16, 1, prem_sel_clks,
+                       ARRAY_SIZE(prem_sel_clks));
+       clk[mpll] = imx_clk_pllv1("mpll", "clk32_premult", CCM_MPCTL0);
+       clk[spll] = imx_clk_pllv1("spll", "prem", CCM_SPCTL0);
+       clk[mcu] = imx_clk_divider("mcu", "clk32_premult", CCM_CSCR, 15, 1);
+       clk[fclk] = imx_clk_divider("fclk", "mpll", CCM_CSCR, 15, 1);
+       clk[hclk] = imx_clk_divider("hclk", "spll", CCM_CSCR, 10, 4);
+       clk[clk48m] = imx_clk_divider("clk48m", "spll", CCM_CSCR, 26, 3);
+       clk[per1] = imx_clk_divider("per1", "spll", CCM_PCDR, 0, 4);
+       clk[per2] = imx_clk_divider("per2", "spll", CCM_PCDR, 4, 4);
+       clk[per3] = imx_clk_divider("per3", "spll", CCM_PCDR, 16, 7);
+       clk[clko] = imx_clk_mux("clko", CCM_CSCR, 29, 3, clko_sel_clks,
+                       ARRAY_SIZE(clko_sel_clks));
+       clk[dma_gate] = imx_clk_gate("dma_gate", "hclk", SCM_GCCR, 4);
+       clk[csi_gate] = imx_clk_gate("csi_gate", "hclk", SCM_GCCR, 2);
+       clk[mma_gate] = imx_clk_gate("mma_gate", "hclk", SCM_GCCR, 1);
+       clk[usbd_gate] = imx_clk_gate("usbd_gate", "clk48m", SCM_GCCR, 0);
+
+       for (i = 0; i < ARRAY_SIZE(clk); i++)
+               if (IS_ERR(clk[i]))
+                       pr_err("imx1 clk %d: register failed with %ld\n",
+                               i, PTR_ERR(clk[i]));
+
+       clk_register_clkdev(clk[dma_gate], "ahb", "imx-dma");
+       clk_register_clkdev(clk[csi_gate], NULL, "mx1-camera.0");
+       clk_register_clkdev(clk[mma_gate], "mma", NULL);
+       clk_register_clkdev(clk[usbd_gate], NULL, "imx_udc.0");
+       clk_register_clkdev(clk[per1], "per", "imx-gpt.0");
+       clk_register_clkdev(clk[hclk], "ipg", "imx-gpt.0");
+       clk_register_clkdev(clk[per1], "per", "imx1-uart.0");
+       clk_register_clkdev(clk[hclk], "ipg", "imx1-uart.0");
+       clk_register_clkdev(clk[per1], "per", "imx1-uart.1");
+       clk_register_clkdev(clk[hclk], "ipg", "imx1-uart.1");
+       clk_register_clkdev(clk[per1], "per", "imx1-uart.2");
+       clk_register_clkdev(clk[hclk], "ipg", "imx1-uart.2");
+       clk_register_clkdev(clk[hclk], NULL, "imx-i2c.0");
+       clk_register_clkdev(clk[per2], "per", "imx1-cspi.0");
+       clk_register_clkdev(clk[dummy], "ipg", "imx1-cspi.0");
+       clk_register_clkdev(clk[per2], "per", "imx1-cspi.1");
+       clk_register_clkdev(clk[dummy], "ipg", "imx1-cspi.1");
+       clk_register_clkdev(clk[per2], NULL, "imx-mmc.0");
+       clk_register_clkdev(clk[per2], "per", "imx-fb.0");
+       clk_register_clkdev(clk[dummy], "ipg", "imx-fb.0");
+       clk_register_clkdev(clk[dummy], "ahb", "imx-fb.0");
+       clk_register_clkdev(clk[hclk], "mshc", NULL);
+       clk_register_clkdev(clk[per3], "ssi", NULL);
+       clk_register_clkdev(clk[clk32], NULL, "mxc_rtc.0");
+       clk_register_clkdev(clk[clko], "clko", NULL);
+
+       mxc_timer_init(NULL, MX1_IO_ADDRESS(MX1_TIM1_BASE_ADDR),
+                       MX1_TIM1_INT);
+
+       return 0;
+}
diff --git a/arch/arm/mach-imx/clk-imx21.c b/arch/arm/mach-imx/clk-imx21.c
new file mode 100644 (file)
index 0000000..4e4f384
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
+ * Copyright 2008 Martin Fuzzey, mfuzzey@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/clkdev.h>
+#include <linux/err.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include "clk.h"
+
+#define IO_ADDR_CCM(off)       (MX21_IO_ADDRESS(MX21_CCM_BASE_ADDR + (off)))
+
+/* Register offsets */
+#define CCM_CSCR               IO_ADDR_CCM(0x0)
+#define CCM_MPCTL0             IO_ADDR_CCM(0x4)
+#define CCM_MPCTL1             IO_ADDR_CCM(0x8)
+#define CCM_SPCTL0             IO_ADDR_CCM(0xc)
+#define CCM_SPCTL1             IO_ADDR_CCM(0x10)
+#define CCM_OSC26MCTL          IO_ADDR_CCM(0x14)
+#define CCM_PCDR0              IO_ADDR_CCM(0x18)
+#define CCM_PCDR1              IO_ADDR_CCM(0x1c)
+#define CCM_PCCR0              IO_ADDR_CCM(0x20)
+#define CCM_PCCR1              IO_ADDR_CCM(0x24)
+#define CCM_CCSR               IO_ADDR_CCM(0x28)
+#define CCM_PMCTL              IO_ADDR_CCM(0x2c)
+#define CCM_PMCOUNT            IO_ADDR_CCM(0x30)
+#define CCM_WKGDCTL            IO_ADDR_CCM(0x34)
+
+static const char *mpll_sel_clks[] = { "fpm", "ckih", };
+static const char *spll_sel_clks[] = { "fpm", "ckih", };
+
+enum imx21_clks {
+       ckil, ckih, fpm, mpll_sel, spll_sel, mpll, spll, fclk, hclk, ipg, per1,
+       per2, per3, per4, uart1_ipg_gate, uart2_ipg_gate, uart3_ipg_gate,
+       uart4_ipg_gate, gpt1_ipg_gate, gpt2_ipg_gate, gpt3_ipg_gate,
+       pwm_ipg_gate, sdhc1_ipg_gate, sdhc2_ipg_gate, lcdc_ipg_gate,
+       lcdc_hclk_gate, cspi3_ipg_gate, cspi2_ipg_gate, cspi1_ipg_gate,
+       per4_gate, csi_hclk_gate, usb_div, usb_gate, usb_hclk_gate, ssi1_gate,
+       ssi2_gate, nfc_div, nfc_gate, dma_gate, dma_hclk_gate, brom_gate,
+       emma_gate, emma_hclk_gate, slcdc_gate, slcdc_hclk_gate, wdog_gate,
+       gpio_gate, i2c_gate, kpp_gate, owire_gate, rtc_gate, clk_max
+};
+
+static struct clk *clk[clk_max];
+
+/*
+ * must be called very early to get information about the
+ * available clock rate when the timer framework starts
+ */
+int __init mx21_clocks_init(unsigned long lref, unsigned long href)
+{
+       int i;
+
+       clk[ckil] = imx_clk_fixed("ckil", lref);
+       clk[ckih] = imx_clk_fixed("ckih", href);
+       clk[fpm] = imx_clk_fixed_factor("fpm", "ckil", 512, 1);
+       clk[mpll_sel] = imx_clk_mux("mpll_sel", CCM_CSCR, 16, 1, mpll_sel_clks,
+                       ARRAY_SIZE(mpll_sel_clks));
+       clk[spll_sel] = imx_clk_mux("spll_sel", CCM_CSCR, 17, 1, spll_sel_clks,
+                       ARRAY_SIZE(spll_sel_clks));
+       clk[mpll] = imx_clk_pllv1("mpll", "mpll_sel", CCM_MPCTL0);
+       clk[spll] = imx_clk_pllv1("spll", "spll_sel", CCM_SPCTL0);
+       clk[fclk] = imx_clk_divider("fclk", "mpll", CCM_CSCR, 29, 3);
+       clk[hclk] = imx_clk_divider("hclk", "fclk", CCM_CSCR, 10, 4);
+       clk[ipg] = imx_clk_divider("ipg", "hclk", CCM_CSCR, 9, 1);
+       clk[per1] = imx_clk_divider("per1", "mpll", CCM_PCDR1, 0, 6);
+       clk[per2] = imx_clk_divider("per2", "mpll", CCM_PCDR1, 8, 6);
+       clk[per3] = imx_clk_divider("per3", "mpll", CCM_PCDR1, 16, 6);
+       clk[per4] = imx_clk_divider("per4", "mpll", CCM_PCDR1, 24, 6);
+       clk[uart1_ipg_gate] = imx_clk_gate("uart1_ipg_gate", "ipg", CCM_PCCR0, 0);
+       clk[uart2_ipg_gate] = imx_clk_gate("uart2_ipg_gate", "ipg", CCM_PCCR0, 1);
+       clk[uart3_ipg_gate] = imx_clk_gate("uart3_ipg_gate", "ipg", CCM_PCCR0, 2);
+       clk[uart4_ipg_gate] = imx_clk_gate("uart4_ipg_gate", "ipg", CCM_PCCR0, 3);
+       clk[gpt1_ipg_gate] = imx_clk_gate("gpt1_ipg_gate", "ipg", CCM_PCCR1, 25);
+       clk[gpt2_ipg_gate] = imx_clk_gate("gpt2_ipg_gate", "ipg", CCM_PCCR1, 26);
+       clk[gpt3_ipg_gate] = imx_clk_gate("gpt3_ipg_gate", "ipg", CCM_PCCR1, 27);
+       clk[pwm_ipg_gate] = imx_clk_gate("pwm_ipg_gate", "ipg", CCM_PCCR1, 28);
+       clk[sdhc1_ipg_gate] = imx_clk_gate("sdhc1_ipg_gate", "ipg", CCM_PCCR0, 9);
+       clk[sdhc2_ipg_gate] = imx_clk_gate("sdhc2_ipg_gate", "ipg", CCM_PCCR0, 10);
+       clk[lcdc_ipg_gate] = imx_clk_gate("lcdc_ipg_gate", "ipg", CCM_PCCR0, 18);
+       clk[lcdc_hclk_gate] = imx_clk_gate("lcdc_hclk_gate", "hclk", CCM_PCCR0, 26);
+       clk[cspi3_ipg_gate] = imx_clk_gate("cspi3_ipg_gate", "ipg", CCM_PCCR1, 23);
+       clk[cspi2_ipg_gate] = imx_clk_gate("cspi2_ipg_gate", "ipg", CCM_PCCR0, 5);
+       clk[cspi1_ipg_gate] = imx_clk_gate("cspi1_ipg_gate", "ipg", CCM_PCCR0, 4);
+       clk[per4_gate] = imx_clk_gate("per4_gate", "per4", CCM_PCCR0, 22);
+       clk[csi_hclk_gate] = imx_clk_gate("csi_hclk_gate", "hclk", CCM_PCCR0, 31);
+       clk[usb_div] = imx_clk_divider("usb_div", "spll", CCM_CSCR, 26, 3);
+       clk[usb_gate] = imx_clk_gate("usb_gate", "usb_div", CCM_PCCR0, 14);
+       clk[usb_hclk_gate] = imx_clk_gate("usb_hclk_gate", "hclk", CCM_PCCR0, 24);
+       clk[ssi1_gate] = imx_clk_gate("ssi1_gate", "ipg", CCM_PCCR0, 6);
+       clk[ssi2_gate] = imx_clk_gate("ssi2_gate", "ipg", CCM_PCCR0, 7);
+       clk[nfc_div] = imx_clk_divider("nfc_div", "ipg", CCM_PCDR0, 12, 4);
+       clk[nfc_gate] = imx_clk_gate("nfc_gate", "nfc_div", CCM_PCCR0, 19);
+       clk[dma_gate] = imx_clk_gate("dma_gate", "ipg", CCM_PCCR0, 13);
+       clk[dma_hclk_gate] = imx_clk_gate("dma_hclk_gate", "hclk", CCM_PCCR0, 30);
+       clk[brom_gate] = imx_clk_gate("brom_gate", "hclk", CCM_PCCR0, 28);
+       clk[emma_gate] = imx_clk_gate("emma_gate", "ipg", CCM_PCCR0, 15);
+       clk[emma_hclk_gate] = imx_clk_gate("emma_hclk_gate", "hclk", CCM_PCCR0, 27);
+       clk[slcdc_gate] = imx_clk_gate("slcdc_gate", "ipg", CCM_PCCR0, 25);
+       clk[slcdc_hclk_gate] = imx_clk_gate("slcdc_hclk_gate", "hclk", CCM_PCCR0, 21);
+       clk[wdog_gate] = imx_clk_gate("wdog_gate", "ipg", CCM_PCCR1, 24);
+       clk[gpio_gate] = imx_clk_gate("gpio_gate", "ipg", CCM_PCCR0, 11);
+       clk[i2c_gate] = imx_clk_gate("i2c_gate", "ipg", CCM_PCCR0, 12);
+       clk[kpp_gate] = imx_clk_gate("kpp_gate", "ipg", CCM_PCCR1, 30);
+       clk[owire_gate] = imx_clk_gate("owire_gate", "ipg", CCM_PCCR1, 31);
+       clk[rtc_gate] = imx_clk_gate("rtc_gate", "ipg", CCM_PCCR1, 29);
+
+       for (i = 0; i < ARRAY_SIZE(clk); i++)
+               if (IS_ERR(clk[i]))
+                       pr_err("i.MX21 clk %d: register failed with %ld\n",
+                               i, PTR_ERR(clk[i]));
+
+       clk_register_clkdev(clk[per1], "per1", NULL);
+       clk_register_clkdev(clk[per2], "per2", NULL);
+       clk_register_clkdev(clk[per3], "per3", NULL);
+       clk_register_clkdev(clk[per4], "per4", NULL);
+       clk_register_clkdev(clk[per1], "per", "imx21-uart.0");
+       clk_register_clkdev(clk[uart1_ipg_gate], "ipg", "imx21-uart.0");
+       clk_register_clkdev(clk[per1], "per", "imx21-uart.1");
+       clk_register_clkdev(clk[uart2_ipg_gate], "ipg", "imx21-uart.1");
+       clk_register_clkdev(clk[per1], "per", "imx21-uart.2");
+       clk_register_clkdev(clk[uart3_ipg_gate], "ipg", "imx21-uart.2");
+       clk_register_clkdev(clk[per1], "per", "imx21-uart.3");
+       clk_register_clkdev(clk[uart4_ipg_gate], "ipg", "imx21-uart.3");
+       clk_register_clkdev(clk[gpt1_ipg_gate], "ipg", "imx-gpt.0");
+       clk_register_clkdev(clk[per1], "per", "imx-gpt.0");
+       clk_register_clkdev(clk[gpt2_ipg_gate], "ipg", "imx-gpt.1");
+       clk_register_clkdev(clk[per1], "per", "imx-gpt.1");
+       clk_register_clkdev(clk[gpt3_ipg_gate], "ipg", "imx-gpt.2");
+       clk_register_clkdev(clk[per1], "per", "imx-gpt.2");
+       clk_register_clkdev(clk[pwm_ipg_gate], "pwm", "mxc_pwm.0");
+       clk_register_clkdev(clk[per2], "per", "imx21-cspi.0");
+       clk_register_clkdev(clk[cspi1_ipg_gate], "ipg", "imx21-cspi.0");
+       clk_register_clkdev(clk[per2], "per", "imx21-cspi.1");
+       clk_register_clkdev(clk[cspi2_ipg_gate], "ipg", "imx21-cspi.1");
+       clk_register_clkdev(clk[per2], "per", "imx21-cspi.2");
+       clk_register_clkdev(clk[cspi3_ipg_gate], "ipg", "imx21-cspi.2");
+       clk_register_clkdev(clk[per3], "per", "imx-fb.0");
+       clk_register_clkdev(clk[lcdc_ipg_gate], "ipg", "imx-fb.0");
+       clk_register_clkdev(clk[lcdc_hclk_gate], "ahb", "imx-fb.0");
+       clk_register_clkdev(clk[usb_gate], "per", "imx21-hcd.0");
+       clk_register_clkdev(clk[usb_hclk_gate], "ahb", "imx21-hcd.0");
+       clk_register_clkdev(clk[nfc_gate], NULL, "mxc_nand.0");
+       clk_register_clkdev(clk[dma_hclk_gate], "ahb", "imx-dma");
+       clk_register_clkdev(clk[dma_gate], "ipg", "imx-dma");
+       clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0");
+       clk_register_clkdev(clk[i2c_gate], NULL, "imx-i2c.0");
+       clk_register_clkdev(clk[kpp_gate], NULL, "mxc-keypad");
+       clk_register_clkdev(clk[owire_gate], NULL, "mxc_w1.0");
+       clk_register_clkdev(clk[brom_gate], "brom", NULL);
+       clk_register_clkdev(clk[emma_gate], "emma", NULL);
+       clk_register_clkdev(clk[slcdc_gate], "slcdc", NULL);
+       clk_register_clkdev(clk[gpio_gate], "gpio", NULL);
+       clk_register_clkdev(clk[rtc_gate], "rtc", NULL);
+       clk_register_clkdev(clk[csi_hclk_gate], "csi", NULL);
+       clk_register_clkdev(clk[ssi1_gate], "ssi1", NULL);
+       clk_register_clkdev(clk[ssi2_gate], "ssi2", NULL);
+       clk_register_clkdev(clk[sdhc1_ipg_gate], "sdhc1", NULL);
+       clk_register_clkdev(clk[sdhc2_ipg_gate], "sdhc2", NULL);
+
+       mxc_timer_init(NULL, MX21_IO_ADDRESS(MX21_GPT1_BASE_ADDR),
+                       MX21_INT_GPT1);
+       return 0;
+}
diff --git a/arch/arm/mach-imx/clk-imx25.c b/arch/arm/mach-imx/clk-imx25.c
new file mode 100644 (file)
index 0000000..d9833bb
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+ * Copyright (C) 2009 by Sascha Hauer, Pengutronix
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/clkdev.h>
+#include <linux/err.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+#include <mach/mx25.h>
+#include "clk.h"
+
+#define CRM_BASE       MX25_IO_ADDRESS(MX25_CRM_BASE_ADDR)
+
+#define CCM_MPCTL      0x00
+#define CCM_UPCTL      0x04
+#define CCM_CCTL       0x08
+#define CCM_CGCR0      0x0C
+#define CCM_CGCR1      0x10
+#define CCM_CGCR2      0x14
+#define CCM_PCDR0      0x18
+#define CCM_PCDR1      0x1C
+#define CCM_PCDR2      0x20
+#define CCM_PCDR3      0x24
+#define CCM_RCSR       0x28
+#define CCM_CRDR       0x2C
+#define CCM_DCVR0      0x30
+#define CCM_DCVR1      0x34
+#define CCM_DCVR2      0x38
+#define CCM_DCVR3      0x3c
+#define CCM_LTR0       0x40
+#define CCM_LTR1       0x44
+#define CCM_LTR2       0x48
+#define CCM_LTR3       0x4c
+#define CCM_MCR                0x64
+
+#define ccm(x) (CRM_BASE + (x))
+
+static const char *cpu_sel_clks[] = { "mpll", "mpll_cpu_3_4", };
+static const char *per_sel_clks[] = { "ahb", "upll", };
+
+enum mx25_clks {
+       dummy, osc, mpll, upll, mpll_cpu_3_4, cpu_sel, cpu, ahb, usb_div, ipg,
+       per0_sel, per1_sel, per2_sel, per3_sel, per4_sel, per5_sel, per6_sel,
+       per7_sel, per8_sel, per9_sel, per10_sel, per11_sel, per12_sel,
+       per13_sel, per14_sel, per15_sel, per0, per1, per2, per3, per4, per5,
+       per6, per7, per8, per9, per10, per11, per12, per13, per14, per15,
+       csi_ipg_per, esdhc1_ipg_per, esdhc2_ipg_per, gpt_ipg_per, i2c_ipg_per,
+       lcdc_ipg_per, nfc_ipg_per, ssi1_ipg_per, ssi2_ipg_per, uart_ipg_per,
+       csi_ahb, esdhc1_ahb, esdhc2_ahb, fec_ahb, lcdc_ahb, sdma_ahb,
+       usbotg_ahb, can1_ipg, can2_ipg, csi_ipg, cspi1_ipg, cspi2_ipg,
+       cspi3_ipg, dryice_ipg, esdhc1_ipg, esdhc2_ipg, fec_ipg, iim_ipg,
+       kpp_ipg, lcdc_ipg, pwm1_ipg, pwm2_ipg, pwm3_ipg, pwm4_ipg, sdma_ipg,
+       ssi1_ipg, ssi2_ipg, tsc_ipg, uart1_ipg, uart2_ipg, uart3_ipg,
+       uart4_ipg, uart5_ipg, wdt_ipg, clk_max
+};
+
+static struct clk *clk[clk_max];
+
+int __init mx25_clocks_init(void)
+{
+       int i;
+
+       clk[dummy] = imx_clk_fixed("dummy", 0);
+       clk[osc] = imx_clk_fixed("osc", 24000000);
+       clk[mpll] = imx_clk_pllv1("mpll", "osc", ccm(CCM_MPCTL));
+       clk[upll] = imx_clk_pllv1("upll", "osc", ccm(CCM_UPCTL));
+       clk[mpll_cpu_3_4] = imx_clk_fixed_factor("mpll_cpu_3_4", "mpll", 3, 4);
+       clk[cpu_sel] = imx_clk_mux("cpu_sel", ccm(CCM_CCTL), 14, 1, cpu_sel_clks, ARRAY_SIZE(cpu_sel_clks));
+       clk[cpu] = imx_clk_divider("cpu", "cpu_sel", ccm(CCM_CCTL), 30, 2);
+       clk[ahb] = imx_clk_divider("ahb", "cpu", ccm(CCM_CCTL), 28, 2);
+       clk[usb_div] = imx_clk_divider("usb_div", "upll", ccm(CCM_CCTL), 16, 6); 
+       clk[ipg] = imx_clk_fixed_factor("ipg", "ahb", 1, 2);
+       clk[per0_sel] = imx_clk_mux("per0_sel", ccm(CCM_MCR), 0, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per1_sel] = imx_clk_mux("per1_sel", ccm(CCM_MCR), 1, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per2_sel] = imx_clk_mux("per2_sel", ccm(CCM_MCR), 2, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per3_sel] = imx_clk_mux("per3_sel", ccm(CCM_MCR), 3, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per4_sel] = imx_clk_mux("per4_sel", ccm(CCM_MCR), 4, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per5_sel] = imx_clk_mux("per5_sel", ccm(CCM_MCR), 5, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per6_sel] = imx_clk_mux("per6_sel", ccm(CCM_MCR), 6, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per7_sel] = imx_clk_mux("per7_sel", ccm(CCM_MCR), 7, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per8_sel] = imx_clk_mux("per8_sel", ccm(CCM_MCR), 8, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per9_sel] = imx_clk_mux("per9_sel", ccm(CCM_MCR), 9, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per10_sel] = imx_clk_mux("per10_sel", ccm(CCM_MCR), 10, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per11_sel] = imx_clk_mux("per11_sel", ccm(CCM_MCR), 11, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per12_sel] = imx_clk_mux("per12_sel", ccm(CCM_MCR), 12, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per13_sel] = imx_clk_mux("per13_sel", ccm(CCM_MCR), 13, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per14_sel] = imx_clk_mux("per14_sel", ccm(CCM_MCR), 14, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per15_sel] = imx_clk_mux("per15_sel", ccm(CCM_MCR), 15, 1, per_sel_clks, ARRAY_SIZE(per_sel_clks));
+       clk[per0] = imx_clk_divider("per0", "per0_sel", ccm(CCM_PCDR0), 0, 6);
+       clk[per1] = imx_clk_divider("per1", "per1_sel", ccm(CCM_PCDR0), 8, 6);
+       clk[per2] = imx_clk_divider("per2", "per2_sel", ccm(CCM_PCDR0), 16, 6);
+       clk[per3] = imx_clk_divider("per3", "per3_sel", ccm(CCM_PCDR0), 24, 6);
+       clk[per4] = imx_clk_divider("per4", "per4_sel", ccm(CCM_PCDR1), 0, 6);
+       clk[per5] = imx_clk_divider("per5", "per5_sel", ccm(CCM_PCDR1), 8, 6);
+       clk[per6] = imx_clk_divider("per6", "per6_sel", ccm(CCM_PCDR1), 16, 6);
+       clk[per7] = imx_clk_divider("per7", "per7_sel", ccm(CCM_PCDR1), 24, 6);
+       clk[per8] = imx_clk_divider("per8", "per8_sel", ccm(CCM_PCDR2), 0, 6);
+       clk[per9] = imx_clk_divider("per9", "per9_sel", ccm(CCM_PCDR2), 8, 6);
+       clk[per10] = imx_clk_divider("per10", "per10_sel", ccm(CCM_PCDR2), 16, 6);
+       clk[per11] = imx_clk_divider("per11", "per11_sel", ccm(CCM_PCDR2), 24, 6);
+       clk[per12] = imx_clk_divider("per12", "per12_sel", ccm(CCM_PCDR3), 0, 6);
+       clk[per13] = imx_clk_divider("per13", "per13_sel", ccm(CCM_PCDR3), 8, 6);
+       clk[per14] = imx_clk_divider("per14", "per14_sel", ccm(CCM_PCDR3), 16, 6);
+       clk[per15] = imx_clk_divider("per15", "per15_sel", ccm(CCM_PCDR3), 24, 6);
+       clk[csi_ipg_per] = imx_clk_gate("csi_ipg_per", "per0", ccm(CCM_CGCR0), 0);
+       clk[esdhc1_ipg_per] = imx_clk_gate("esdhc1_ipg_per", "per3", ccm(CCM_CGCR0),  3);
+       clk[esdhc2_ipg_per] = imx_clk_gate("esdhc2_ipg_per", "per4", ccm(CCM_CGCR0),  4);
+       clk[gpt_ipg_per] = imx_clk_gate("gpt_ipg_per", "per5", ccm(CCM_CGCR0),  5);
+       clk[i2c_ipg_per] = imx_clk_gate("i2c_ipg_per", "per6", ccm(CCM_CGCR0),  6);
+       clk[lcdc_ipg_per] = imx_clk_gate("lcdc_ipg_per", "per8", ccm(CCM_CGCR0),  7);
+       clk[nfc_ipg_per] = imx_clk_gate("nfc_ipg_per", "ipg_per", ccm(CCM_CGCR0),  8);
+       clk[ssi1_ipg_per] = imx_clk_gate("ssi1_ipg_per", "per13", ccm(CCM_CGCR0), 13);
+       clk[ssi2_ipg_per] = imx_clk_gate("ssi2_ipg_per", "per14", ccm(CCM_CGCR0), 14);
+       clk[uart_ipg_per] = imx_clk_gate("uart_ipg_per", "per15", ccm(CCM_CGCR0), 15);
+       clk[csi_ahb] = imx_clk_gate("csi_ahb", "ahb", ccm(CCM_CGCR0), 18);
+       clk[esdhc1_ahb] = imx_clk_gate("esdhc1_ahb", "ahb", ccm(CCM_CGCR0), 21);
+       clk[esdhc2_ahb] = imx_clk_gate("esdhc2_ahb", "ahb", ccm(CCM_CGCR0), 22);
+       clk[fec_ahb] = imx_clk_gate("fec_ahb", "ahb", ccm(CCM_CGCR0), 23);
+       clk[lcdc_ahb] = imx_clk_gate("lcdc_ahb", "ahb", ccm(CCM_CGCR0), 24);
+       clk[sdma_ahb] = imx_clk_gate("sdma_ahb", "ahb", ccm(CCM_CGCR0), 26);
+       clk[usbotg_ahb] = imx_clk_gate("usbotg_ahb", "ahb", ccm(CCM_CGCR0), 28);
+       clk[can1_ipg] = imx_clk_gate("can1_ipg", "ipg", ccm(CCM_CGCR1),  2);
+       clk[can2_ipg] = imx_clk_gate("can2_ipg", "ipg", ccm(CCM_CGCR1),  3);
+       clk[csi_ipg] = imx_clk_gate("csi_ipg", "ipg", ccm(CCM_CGCR1),  4);
+       clk[cspi1_ipg] = imx_clk_gate("cspi1_ipg", "ipg", ccm(CCM_CGCR1),  5);
+       clk[cspi2_ipg] = imx_clk_gate("cspi2_ipg", "ipg", ccm(CCM_CGCR1),  6);
+       clk[cspi3_ipg] = imx_clk_gate("cspi3_ipg", "ipg", ccm(CCM_CGCR1),  7);
+       clk[dryice_ipg] = imx_clk_gate("dryice_ipg", "ipg", ccm(CCM_CGCR1),  8);
+       clk[esdhc1_ipg] = imx_clk_gate("esdhc1_ipg", "ipg", ccm(CCM_CGCR1), 13);
+       clk[esdhc2_ipg] = imx_clk_gate("esdhc2_ipg", "ipg", ccm(CCM_CGCR1), 14);
+       clk[fec_ipg] = imx_clk_gate("fec_ipg", "ipg", ccm(CCM_CGCR1), 15);
+       clk[iim_ipg] = imx_clk_gate("iim_ipg", "ipg", ccm(CCM_CGCR1), 26);
+       clk[kpp_ipg] = imx_clk_gate("kpp_ipg", "ipg", ccm(CCM_CGCR1), 28);
+       clk[lcdc_ipg] = imx_clk_gate("lcdc_ipg", "ipg", ccm(CCM_CGCR1), 29);
+       clk[pwm1_ipg] = imx_clk_gate("pwm1_ipg", "ipg", ccm(CCM_CGCR1), 31);
+       clk[pwm2_ipg] = imx_clk_gate("pwm2_ipg", "ipg", ccm(CCM_CGCR2),  0);
+       clk[pwm3_ipg] = imx_clk_gate("pwm3_ipg", "ipg", ccm(CCM_CGCR2),  1);
+       clk[pwm4_ipg] = imx_clk_gate("pwm4_ipg", "ipg", ccm(CCM_CGCR2),  2);
+       clk[sdma_ipg] = imx_clk_gate("sdma_ipg", "ipg", ccm(CCM_CGCR2),  6);
+       clk[ssi1_ipg] = imx_clk_gate("ssi1_ipg", "ipg", ccm(CCM_CGCR2), 11);
+       clk[ssi2_ipg] = imx_clk_gate("ssi2_ipg", "ipg", ccm(CCM_CGCR2), 12);
+       clk[tsc_ipg] = imx_clk_gate("tsc_ipg", "ipg", ccm(CCM_CGCR2), 13);
+       clk[uart1_ipg] = imx_clk_gate("uart1_ipg", "ipg", ccm(CCM_CGCR2), 14);
+       clk[uart2_ipg] = imx_clk_gate("uart2_ipg", "ipg", ccm(CCM_CGCR2), 15);
+       clk[uart3_ipg] = imx_clk_gate("uart3_ipg", "ipg", ccm(CCM_CGCR2), 16);
+       clk[uart4_ipg] = imx_clk_gate("uart4_ipg", "ipg", ccm(CCM_CGCR2), 17);
+       clk[uart5_ipg] = imx_clk_gate("uart5_ipg", "ipg", ccm(CCM_CGCR2), 18);
+       clk[wdt_ipg] = imx_clk_gate("wdt_ipg", "ipg", ccm(CCM_CGCR2), 19);
+
+       for (i = 0; i < ARRAY_SIZE(clk); i++)
+               if (IS_ERR(clk[i]))
+                       pr_err("i.MX25 clk %d: register failed with %ld\n",
+                               i, PTR_ERR(clk[i]));
+
+       /* i.mx25 has the i.mx21 type uart */
+       clk_register_clkdev(clk[uart1_ipg], "ipg", "imx21-uart.0");
+       clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.0");
+       clk_register_clkdev(clk[uart2_ipg], "ipg", "imx21-uart.1");
+       clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.1");
+       clk_register_clkdev(clk[uart3_ipg], "ipg", "imx21-uart.2");
+       clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.2");
+       clk_register_clkdev(clk[uart4_ipg], "ipg", "imx21-uart.3");
+       clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.3");
+       clk_register_clkdev(clk[uart5_ipg], "ipg", "imx21-uart.4");
+       clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.4");
+       clk_register_clkdev(clk[ipg], "ipg", "imx-gpt.0");
+       clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0");
+       clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.0");
+       clk_register_clkdev(clk[usbotg_ahb], "ahb", "mxc-ehci.0");
+       clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.0");
+       clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.1");
+       clk_register_clkdev(clk[usbotg_ahb], "ahb", "mxc-ehci.1");
+       clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.1");
+       clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.2");
+       clk_register_clkdev(clk[usbotg_ahb], "ahb", "mxc-ehci.2");
+       clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.2");
+       clk_register_clkdev(clk[ipg], "ipg", "fsl-usb2-udc");
+       clk_register_clkdev(clk[usbotg_ahb], "ahb", "fsl-usb2-udc");
+       clk_register_clkdev(clk[usb_div], "per", "fsl-usb2-udc");
+       clk_register_clkdev(clk[nfc_ipg_per], NULL, "mxc_nand.0");
+       /* i.mx25 has the i.mx35 type cspi */
+       clk_register_clkdev(clk[cspi1_ipg], NULL, "imx35-cspi.0");
+       clk_register_clkdev(clk[cspi2_ipg], NULL, "imx35-cspi.1");
+       clk_register_clkdev(clk[cspi3_ipg], NULL, "imx35-cspi.2");
+       clk_register_clkdev(clk[pwm1_ipg], "ipg", "mxc_pwm.0");
+       clk_register_clkdev(clk[per10], "per", "mxc_pwm.0");
+       clk_register_clkdev(clk[pwm1_ipg], "ipg", "mxc_pwm.1");
+       clk_register_clkdev(clk[per10], "per", "mxc_pwm.1");
+       clk_register_clkdev(clk[pwm1_ipg], "ipg", "mxc_pwm.2");
+       clk_register_clkdev(clk[per10], "per", "mxc_pwm.2");
+       clk_register_clkdev(clk[pwm1_ipg], "ipg", "mxc_pwm.3");
+       clk_register_clkdev(clk[per10], "per", "mxc_pwm.3");
+       clk_register_clkdev(clk[kpp_ipg], NULL, "imx-keypad");
+       clk_register_clkdev(clk[tsc_ipg], NULL, "mx25-adc");
+       clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx-i2c.0");
+       clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx-i2c.1");
+       clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx-i2c.2");
+       clk_register_clkdev(clk[fec_ipg], "ipg", "imx25-fec.0");
+       clk_register_clkdev(clk[fec_ahb], "ahb", "imx25-fec.0");
+       clk_register_clkdev(clk[dryice_ipg], NULL, "imxdi_rtc.0");
+       clk_register_clkdev(clk[lcdc_ipg_per], "per", "imx-fb.0");
+       clk_register_clkdev(clk[lcdc_ipg], "ipg", "imx-fb.0");
+       clk_register_clkdev(clk[lcdc_ahb], "ahb", "imx-fb.0");
+       clk_register_clkdev(clk[wdt_ipg], NULL, "imx2-wdt.0");
+       clk_register_clkdev(clk[ssi1_ipg_per], "per", "imx-ssi.0");
+       clk_register_clkdev(clk[ssi1_ipg], "ipg", "imx-ssi.0");
+       clk_register_clkdev(clk[ssi2_ipg_per], "per", "imx-ssi.1");
+       clk_register_clkdev(clk[ssi2_ipg], "ipg", "imx-ssi.1");
+       clk_register_clkdev(clk[esdhc1_ipg_per], "per", "sdhci-esdhc-imx25.0");
+       clk_register_clkdev(clk[esdhc1_ipg], "ipg", "sdhci-esdhc-imx25.0");
+       clk_register_clkdev(clk[esdhc1_ahb], "ahb", "sdhci-esdhc-imx25.0");
+       clk_register_clkdev(clk[esdhc2_ipg_per], "per", "sdhci-esdhc-imx25.1");
+       clk_register_clkdev(clk[esdhc2_ipg], "ipg", "sdhci-esdhc-imx25.1");
+       clk_register_clkdev(clk[esdhc2_ahb], "ahb", "sdhci-esdhc-imx25.1");
+       clk_register_clkdev(clk[csi_ipg_per], "per", "mx2-camera.0");
+       clk_register_clkdev(clk[csi_ipg], "ipg", "mx2-camera.0");
+       clk_register_clkdev(clk[csi_ahb], "ahb", "mx2-camera.0");
+       clk_register_clkdev(clk[dummy], "audmux", NULL);
+       clk_register_clkdev(clk[can1_ipg], NULL, "flexcan.0");
+       clk_register_clkdev(clk[can2_ipg], NULL, "flexcan.1");
+       /* i.mx25 has the i.mx35 type sdma */
+       clk_register_clkdev(clk[sdma_ipg], "ipg", "imx35-sdma");
+       clk_register_clkdev(clk[sdma_ahb], "ahb", "imx35-sdma");
+       clk_register_clkdev(clk[iim_ipg], "iim", NULL);
+
+       mxc_timer_init(NULL, MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54);
+       return 0;
+}
diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.c
new file mode 100644 (file)
index 0000000..50a7ebd
--- /dev/null
@@ -0,0 +1,290 @@
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/clkdev.h>
+#include <linux/err.h>
+#include <linux/clk-provider.h>
+#include <linux/of.h>
+
+#include <mach/common.h>
+#include <mach/hardware.h>
+#include "clk.h"
+
+#define IO_ADDR_CCM(off)       (MX27_IO_ADDRESS(MX27_CCM_BASE_ADDR + (off)))
+
+/* Register offsets */
+#define CCM_CSCR               IO_ADDR_CCM(0x0)
+#define CCM_MPCTL0             IO_ADDR_CCM(0x4)
+#define CCM_MPCTL1             IO_ADDR_CCM(0x8)
+#define CCM_SPCTL0             IO_ADDR_CCM(0xc)
+#define CCM_SPCTL1             IO_ADDR_CCM(0x10)
+#define CCM_OSC26MCTL          IO_ADDR_CCM(0x14)
+#define CCM_PCDR0              IO_ADDR_CCM(0x18)
+#define CCM_PCDR1              IO_ADDR_CCM(0x1c)
+#define CCM_PCCR0              IO_ADDR_CCM(0x20)
+#define CCM_PCCR1              IO_ADDR_CCM(0x24)
+#define CCM_CCSR               IO_ADDR_CCM(0x28)
+#define CCM_PMCTL              IO_ADDR_CCM(0x2c)
+#define CCM_PMCOUNT            IO_ADDR_CCM(0x30)
+#define CCM_WKGDCTL            IO_ADDR_CCM(0x34)
+
+#define CCM_CSCR_UPDATE_DIS    (1 << 31)
+#define CCM_CSCR_SSI2          (1 << 23)
+#define CCM_CSCR_SSI1          (1 << 22)
+#define CCM_CSCR_VPU           (1 << 21)
+#define CCM_CSCR_MSHC           (1 << 20)
+#define CCM_CSCR_SPLLRES        (1 << 19)
+#define CCM_CSCR_MPLLRES        (1 << 18)
+#define CCM_CSCR_SP             (1 << 17)
+#define CCM_CSCR_MCU            (1 << 16)
+#define CCM_CSCR_OSC26MDIV      (1 << 4)
+#define CCM_CSCR_OSC26M         (1 << 3)
+#define CCM_CSCR_FPM            (1 << 2)
+#define CCM_CSCR_SPEN           (1 << 1)
+#define CCM_CSCR_MPEN           (1 << 0)
+
+/* i.MX27 TO 2+ */
+#define CCM_CSCR_ARM_SRC        (1 << 15)
+
+#define CCM_SPCTL1_LF           (1 << 15)
+#define CCM_SPCTL1_BRMO         (1 << 6)
+
+static const char *vpu_sel_clks[] = { "spll", "mpll_main2", };
+static const char *cpu_sel_clks[] = { "mpll_main2", "mpll", };
+static const char *clko_sel_clks[] = {
+       "ckil", "prem", "ckih", "ckih",
+       "ckih", "mpll", "spll", "cpu_div",
+       "ahb", "ipg", "per1_div", "per2_div",
+       "per3_div", "per4_div", "ssi1_div", "ssi2_div",
+       "nfc_div", "mshc_div", "vpu_div", "60m",
+       "32k", "usb_div", "dptc",
+};
+
+static const char *ssi_sel_clks[] = { "spll", "mpll", };
+
+enum mx27_clks {
+       dummy, ckih, ckil, mpll, spll, mpll_main2, ahb, ipg, nfc_div, per1_div,
+       per2_div, per3_div, per4_div, vpu_sel, vpu_div, usb_div, cpu_sel,
+       clko_sel, cpu_div, clko_div, ssi1_sel, ssi2_sel, ssi1_div, ssi2_div,
+       clko_en, ssi2_ipg_gate, ssi1_ipg_gate, slcdc_ipg_gate, sdhc3_ipg_gate,
+       sdhc2_ipg_gate, sdhc1_ipg_gate, scc_ipg_gate, sahara_ipg_gate,
+       rtc_ipg_gate, pwm_ipg_gate, owire_ipg_gate, lcdc_ipg_gate,
+       kpp_ipg_gate, iim_ipg_gate, i2c2_ipg_gate, i2c1_ipg_gate,
+       gpt6_ipg_gate, gpt5_ipg_gate, gpt4_ipg_gate, gpt3_ipg_gate,
+       gpt2_ipg_gate, gpt1_ipg_gate, gpio_ipg_gate, fec_ipg_gate,
+       emma_ipg_gate, dma_ipg_gate, cspi3_ipg_gate, cspi2_ipg_gate,
+       cspi1_ipg_gate, nfc_baud_gate, ssi2_baud_gate, ssi1_baud_gate,
+       vpu_baud_gate, per4_gate, per3_gate, per2_gate, per1_gate,
+       usb_ahb_gate, slcdc_ahb_gate, sahara_ahb_gate, lcdc_ahb_gate,
+       vpu_ahb_gate, fec_ahb_gate, emma_ahb_gate, emi_ahb_gate, dma_ahb_gate,
+       csi_ahb_gate, brom_ahb_gate, ata_ahb_gate, wdog_ipg_gate, usb_ipg_gate,
+       uart6_ipg_gate, uart5_ipg_gate, uart4_ipg_gate, uart3_ipg_gate,
+       uart2_ipg_gate, uart1_ipg_gate, clk_max
+};
+
+static struct clk *clk[clk_max];
+
+int __init mx27_clocks_init(unsigned long fref)
+{
+       int i;
+
+       clk[dummy] = imx_clk_fixed("dummy", 0);
+       clk[ckih] = imx_clk_fixed("ckih", fref);
+       clk[ckil] = imx_clk_fixed("ckil", 32768);
+       clk[mpll] = imx_clk_pllv1("mpll", "ckih", CCM_MPCTL0);
+       clk[spll] = imx_clk_pllv1("spll", "ckih", CCM_SPCTL0);
+       clk[mpll_main2] = imx_clk_fixed_factor("mpll_main2", "mpll", 2, 3);
+
+       if (mx27_revision() >= IMX_CHIP_REVISION_2_0) {
+               clk[ahb] = imx_clk_divider("ahb", "mpll_main2", CCM_CSCR, 8, 2);
+               clk[ipg] = imx_clk_fixed_factor("ipg", "ahb", 1, 2);
+       } else {
+               clk[ahb] = imx_clk_divider("ahb", "mpll_main2", CCM_CSCR, 9, 4);
+               clk[ipg] = imx_clk_divider("ipg", "ahb", CCM_CSCR, 8, 1);
+       }
+
+       clk[nfc_div] = imx_clk_divider("nfc_div", "ahb", CCM_PCDR0, 6, 4);
+       clk[per1_div] = imx_clk_divider("per1_div", "mpll_main2", CCM_PCDR1, 0, 6);
+       clk[per2_div] = imx_clk_divider("per2_div", "mpll_main2", CCM_PCDR1, 8, 6);
+       clk[per3_div] = imx_clk_divider("per3_div", "mpll_main2", CCM_PCDR1, 16, 6);
+       clk[per4_div] = imx_clk_divider("per4_div", "mpll_main2", CCM_PCDR1, 24, 6);
+       clk[vpu_sel] = imx_clk_mux("vpu_sel", CCM_CSCR, 21, 1, vpu_sel_clks, ARRAY_SIZE(vpu_sel_clks));
+       clk[vpu_div] = imx_clk_divider("vpu_div", "vpu_sel", CCM_PCDR0, 10, 3);
+       clk[usb_div] = imx_clk_divider("usb_div", "spll", CCM_CSCR, 28, 3);
+       clk[cpu_sel] = imx_clk_mux("cpu_sel", CCM_CSCR, 15, 1, cpu_sel_clks, ARRAY_SIZE(cpu_sel_clks));
+       clk[clko_sel] = imx_clk_mux("clko_sel", CCM_CCSR, 0, 5, clko_sel_clks, ARRAY_SIZE(clko_sel_clks));
+       if (mx27_revision() >= IMX_CHIP_REVISION_2_0)
+               clk[cpu_div] = imx_clk_divider("cpu_div", "cpu_sel", CCM_CSCR, 12, 2);
+       else
+               clk[cpu_div] = imx_clk_divider("cpu_div", "cpu_sel", CCM_CSCR, 13, 3);
+       clk[clko_div] = imx_clk_divider("clko_div", "clko_sel", CCM_PCDR0, 22, 3);
+       clk[ssi1_sel] = imx_clk_mux("ssi1_sel", CCM_CSCR, 22, 1, ssi_sel_clks, ARRAY_SIZE(ssi_sel_clks));
+       clk[ssi2_sel] = imx_clk_mux("ssi2_sel", CCM_CSCR, 23, 1, ssi_sel_clks, ARRAY_SIZE(ssi_sel_clks));
+       clk[ssi1_div] = imx_clk_divider("ssi1_div", "ssi1_sel", CCM_PCDR0, 16, 6);
+       clk[ssi2_div] = imx_clk_divider("ssi2_div", "ssi2_sel", CCM_PCDR0, 26, 3);
+       clk[clko_en] = imx_clk_gate("clko_en", "clko_div", CCM_PCCR0, 0);
+       clk[ssi2_ipg_gate] = imx_clk_gate("ssi2_ipg_gate", "ipg", CCM_PCCR0, 0);
+       clk[ssi1_ipg_gate] = imx_clk_gate("ssi1_ipg_gate", "ipg", CCM_PCCR0, 1);
+       clk[slcdc_ipg_gate] = imx_clk_gate("slcdc_ipg_gate", "ipg", CCM_PCCR0, 2);
+       clk[sdhc3_ipg_gate] = imx_clk_gate("sdhc3_ipg_gate", "ipg", CCM_PCCR0, 3);
+       clk[sdhc2_ipg_gate] = imx_clk_gate("sdhc2_ipg_gate", "ipg", CCM_PCCR0, 4);
+       clk[sdhc1_ipg_gate] = imx_clk_gate("sdhc1_ipg_gate", "ipg", CCM_PCCR0, 5);
+       clk[scc_ipg_gate] = imx_clk_gate("scc_ipg_gate", "ipg", CCM_PCCR0, 6);
+       clk[sahara_ipg_gate] = imx_clk_gate("sahara_ipg_gate", "ipg", CCM_PCCR0, 7);
+       clk[rtc_ipg_gate] = imx_clk_gate("rtc_ipg_gate", "ipg", CCM_PCCR0, 9);
+       clk[pwm_ipg_gate] = imx_clk_gate("pwm_ipg_gate", "ipg", CCM_PCCR0, 11);
+       clk[owire_ipg_gate] = imx_clk_gate("owire_ipg_gate", "ipg", CCM_PCCR0, 12);
+       clk[lcdc_ipg_gate] = imx_clk_gate("lcdc_ipg_gate", "ipg", CCM_PCCR0, 14);
+       clk[kpp_ipg_gate] = imx_clk_gate("kpp_ipg_gate", "ipg", CCM_PCCR0, 15);
+       clk[iim_ipg_gate] = imx_clk_gate("iim_ipg_gate", "ipg", CCM_PCCR0, 16);
+       clk[i2c2_ipg_gate] = imx_clk_gate("i2c2_ipg_gate", "ipg", CCM_PCCR0, 17);
+       clk[i2c1_ipg_gate] = imx_clk_gate("i2c1_ipg_gate", "ipg", CCM_PCCR0, 18);
+       clk[gpt6_ipg_gate] = imx_clk_gate("gpt6_ipg_gate", "ipg", CCM_PCCR0, 19);
+       clk[gpt5_ipg_gate] = imx_clk_gate("gpt5_ipg_gate", "ipg", CCM_PCCR0, 20);
+       clk[gpt4_ipg_gate] = imx_clk_gate("gpt4_ipg_gate", "ipg", CCM_PCCR0, 21);
+       clk[gpt3_ipg_gate] = imx_clk_gate("gpt3_ipg_gate", "ipg", CCM_PCCR0, 22);
+       clk[gpt2_ipg_gate] = imx_clk_gate("gpt2_ipg_gate", "ipg", CCM_PCCR0, 23);
+       clk[gpt1_ipg_gate] = imx_clk_gate("gpt1_ipg_gate", "ipg", CCM_PCCR0, 24);
+       clk[gpio_ipg_gate] = imx_clk_gate("gpio_ipg_gate", "ipg", CCM_PCCR0, 25);
+       clk[fec_ipg_gate] = imx_clk_gate("fec_ipg_gate", "ipg", CCM_PCCR0, 26);
+       clk[emma_ipg_gate] = imx_clk_gate("emma_ipg_gate", "ipg", CCM_PCCR0, 27);
+       clk[dma_ipg_gate] = imx_clk_gate("dma_ipg_gate", "ipg", CCM_PCCR0, 28);
+       clk[cspi3_ipg_gate] = imx_clk_gate("cspi3_ipg_gate", "ipg", CCM_PCCR0, 29);
+       clk[cspi2_ipg_gate] = imx_clk_gate("cspi2_ipg_gate", "ipg", CCM_PCCR0, 30);
+       clk[cspi1_ipg_gate] = imx_clk_gate("cspi1_ipg_gate", "ipg", CCM_PCCR0, 31);
+       clk[nfc_baud_gate] = imx_clk_gate("nfc_baud_gate", "nfc_div", CCM_PCCR1,  3);
+       clk[ssi2_baud_gate] = imx_clk_gate("ssi2_baud_gate", "ssi2_div", CCM_PCCR1,  4);
+       clk[ssi1_baud_gate] = imx_clk_gate("ssi1_baud_gate", "ssi1_div", CCM_PCCR1,  5);
+       clk[vpu_baud_gate] = imx_clk_gate("vpu_baud_gate", "vpu_div", CCM_PCCR1,  6);
+       clk[per4_gate] = imx_clk_gate("per4_gate", "per4_div", CCM_PCCR1,  7);
+       clk[per3_gate] = imx_clk_gate("per3_gate", "per3_div", CCM_PCCR1,  8);
+       clk[per2_gate] = imx_clk_gate("per2_gate", "per2_div", CCM_PCCR1,  9);
+       clk[per1_gate] = imx_clk_gate("per1_gate", "per1_div", CCM_PCCR1, 10);
+       clk[usb_ahb_gate] = imx_clk_gate("usb_ahb_gate", "ahb", CCM_PCCR1, 11);
+       clk[slcdc_ahb_gate] = imx_clk_gate("slcdc_ahb_gate", "ahb", CCM_PCCR1, 12);
+       clk[sahara_ahb_gate] = imx_clk_gate("sahara_ahb_gate", "ahb", CCM_PCCR1, 13);
+       clk[lcdc_ahb_gate] = imx_clk_gate("lcdc_ahb_gate", "ahb", CCM_PCCR1, 15);
+       clk[vpu_ahb_gate] = imx_clk_gate("vpu_ahb_gate", "ahb", CCM_PCCR1, 16);
+       clk[fec_ahb_gate] = imx_clk_gate("fec_ahb_gate", "ahb", CCM_PCCR1, 17);
+       clk[emma_ahb_gate] = imx_clk_gate("emma_ahb_gate", "ahb", CCM_PCCR1, 18);
+       clk[emi_ahb_gate] = imx_clk_gate("emi_ahb_gate", "ahb", CCM_PCCR1, 19);
+       clk[dma_ahb_gate] = imx_clk_gate("dma_ahb_gate", "ahb", CCM_PCCR1, 20);
+       clk[csi_ahb_gate] = imx_clk_gate("csi_ahb_gate", "ahb", CCM_PCCR1, 21);
+       clk[brom_ahb_gate] = imx_clk_gate("brom_ahb_gate", "ahb", CCM_PCCR1, 22);
+       clk[ata_ahb_gate] = imx_clk_gate("ata_ahb_gate", "ahb", CCM_PCCR1, 23);
+       clk[wdog_ipg_gate] = imx_clk_gate("wdog_ipg_gate", "ipg", CCM_PCCR1, 24);
+       clk[usb_ipg_gate] = imx_clk_gate("usb_ipg_gate", "ipg", CCM_PCCR1, 25);
+       clk[uart6_ipg_gate] = imx_clk_gate("uart6_ipg_gate", "ipg", CCM_PCCR1, 26);
+       clk[uart5_ipg_gate] = imx_clk_gate("uart5_ipg_gate", "ipg", CCM_PCCR1, 27);
+       clk[uart4_ipg_gate] = imx_clk_gate("uart4_ipg_gate", "ipg", CCM_PCCR1, 28);
+       clk[uart3_ipg_gate] = imx_clk_gate("uart3_ipg_gate", "ipg", CCM_PCCR1, 29);
+       clk[uart2_ipg_gate] = imx_clk_gate("uart2_ipg_gate", "ipg", CCM_PCCR1, 30);
+       clk[uart1_ipg_gate] = imx_clk_gate("uart1_ipg_gate", "ipg", CCM_PCCR1, 31);
+
+       for (i = 0; i < ARRAY_SIZE(clk); i++)
+               if (IS_ERR(clk[i]))
+                       pr_err("i.MX27 clk %d: register failed with %ld\n",
+                               i, PTR_ERR(clk[i]));
+
+       clk_register_clkdev(clk[uart1_ipg_gate], "ipg", "imx21-uart.0");
+       clk_register_clkdev(clk[per1_gate], "per", "imx21-uart.0");
+       clk_register_clkdev(clk[uart2_ipg_gate], "ipg", "imx21-uart.1");
+       clk_register_clkdev(clk[per1_gate], "per", "imx21-uart.1");
+       clk_register_clkdev(clk[uart3_ipg_gate], "ipg", "imx21-uart.2");
+       clk_register_clkdev(clk[per1_gate], "per", "imx21-uart.2");
+       clk_register_clkdev(clk[uart4_ipg_gate], "ipg", "imx21-uart.3");
+       clk_register_clkdev(clk[per1_gate], "per", "imx21-uart.3");
+       clk_register_clkdev(clk[uart5_ipg_gate], "ipg", "imx21-uart.4");
+       clk_register_clkdev(clk[per1_gate], "per", "imx21-uart.4");
+       clk_register_clkdev(clk[uart6_ipg_gate], "ipg", "imx21-uart.5");
+       clk_register_clkdev(clk[per1_gate], "per", "imx21-uart.5");
+       clk_register_clkdev(clk[gpt1_ipg_gate], "ipg", "imx-gpt.0");
+       clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.0");
+       clk_register_clkdev(clk[gpt2_ipg_gate], "ipg", "imx-gpt.1");
+       clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.1");
+       clk_register_clkdev(clk[gpt3_ipg_gate], "ipg", "imx-gpt.2");
+       clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.2");
+       clk_register_clkdev(clk[gpt4_ipg_gate], "ipg", "imx-gpt.3");
+       clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.3");
+       clk_register_clkdev(clk[gpt5_ipg_gate], "ipg", "imx-gpt.4");
+       clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.4");
+       clk_register_clkdev(clk[gpt6_ipg_gate], "ipg", "imx-gpt.5");
+       clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.5");
+       clk_register_clkdev(clk[pwm_ipg_gate], NULL, "mxc_pwm.0");
+       clk_register_clkdev(clk[per2_gate], "per", "mxc-mmc.0");
+       clk_register_clkdev(clk[sdhc1_ipg_gate], "ipg", "mxc-mmc.0");
+       clk_register_clkdev(clk[per2_gate], "per", "mxc-mmc.1");
+       clk_register_clkdev(clk[sdhc2_ipg_gate], "ipg", "mxc-mmc.1");
+       clk_register_clkdev(clk[per2_gate], "per", "mxc-mmc.2");
+       clk_register_clkdev(clk[sdhc2_ipg_gate], "ipg", "mxc-mmc.2");
+       clk_register_clkdev(clk[cspi1_ipg_gate], NULL, "imx27-cspi.0");
+       clk_register_clkdev(clk[cspi2_ipg_gate], NULL, "imx27-cspi.1");
+       clk_register_clkdev(clk[cspi3_ipg_gate], NULL, "imx27-cspi.2");
+       clk_register_clkdev(clk[per3_gate], "per", "imx-fb.0");
+       clk_register_clkdev(clk[lcdc_ipg_gate], "ipg", "imx-fb.0");
+       clk_register_clkdev(clk[lcdc_ahb_gate], "ahb", "imx-fb.0");
+       clk_register_clkdev(clk[csi_ahb_gate], NULL, "mx2-camera.0");
+       clk_register_clkdev(clk[usb_div], "per", "fsl-usb2-udc");
+       clk_register_clkdev(clk[usb_ipg_gate], "ipg", "fsl-usb2-udc");
+       clk_register_clkdev(clk[usb_ahb_gate], "ahb", "fsl-usb2-udc");
+       clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.0");
+       clk_register_clkdev(clk[usb_ipg_gate], "ipg", "mxc-ehci.0");
+       clk_register_clkdev(clk[usb_ahb_gate], "ahb", "mxc-ehci.0");
+       clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.1");
+       clk_register_clkdev(clk[usb_ipg_gate], "ipg", "mxc-ehci.1");
+       clk_register_clkdev(clk[usb_ahb_gate], "ahb", "mxc-ehci.1");
+       clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.2");
+       clk_register_clkdev(clk[usb_ipg_gate], "ipg", "mxc-ehci.2");
+       clk_register_clkdev(clk[usb_ahb_gate], "ahb", "mxc-ehci.2");
+       clk_register_clkdev(clk[ssi1_ipg_gate], NULL, "imx-ssi.0");
+       clk_register_clkdev(clk[ssi2_ipg_gate], NULL, "imx-ssi.1");
+       clk_register_clkdev(clk[nfc_baud_gate], NULL, "mxc_nand.0");
+       clk_register_clkdev(clk[vpu_baud_gate], "per", "imx-vpu");
+       clk_register_clkdev(clk[vpu_ahb_gate], "ahb", "imx-vpu");
+       clk_register_clkdev(clk[dma_ahb_gate], "ahb", "imx-dma");
+       clk_register_clkdev(clk[dma_ipg_gate], "ipg", "imx-dma");
+       clk_register_clkdev(clk[fec_ipg_gate], "ipg", "imx27-fec.0");
+       clk_register_clkdev(clk[fec_ahb_gate], "ahb", "imx27-fec.0");
+       clk_register_clkdev(clk[wdog_ipg_gate], NULL, "imx2-wdt.0");
+       clk_register_clkdev(clk[i2c1_ipg_gate], NULL, "imx-i2c.0");
+       clk_register_clkdev(clk[i2c2_ipg_gate], NULL, "imx-i2c.1");
+       clk_register_clkdev(clk[owire_ipg_gate], NULL, "mxc_w1.0");
+       clk_register_clkdev(clk[kpp_ipg_gate], NULL, "imx-keypad");
+       clk_register_clkdev(clk[emma_ahb_gate], "ahb", "imx-emma");
+       clk_register_clkdev(clk[emma_ipg_gate], "ipg", "imx-emma");
+       clk_register_clkdev(clk[iim_ipg_gate], "iim", NULL);
+       clk_register_clkdev(clk[gpio_ipg_gate], "gpio", NULL);
+       clk_register_clkdev(clk[brom_ahb_gate], "brom", NULL);
+       clk_register_clkdev(clk[ata_ahb_gate], "ata", NULL);
+       clk_register_clkdev(clk[rtc_ipg_gate], "rtc", NULL);
+       clk_register_clkdev(clk[scc_ipg_gate], "scc", NULL);
+       clk_register_clkdev(clk[cpu_div], "cpu", NULL);
+       clk_register_clkdev(clk[emi_ahb_gate], "emi_ahb" , NULL);
+       clk_register_clkdev(clk[ssi1_baud_gate], "bitrate" , "imx-ssi.0");
+       clk_register_clkdev(clk[ssi2_baud_gate], "bitrate" , "imx-ssi.1");
+
+       mxc_timer_init(NULL, MX27_IO_ADDRESS(MX27_GPT1_BASE_ADDR),
+                       MX27_INT_GPT1);
+
+       clk_prepare_enable(clk[emi_ahb_gate]);
+
+       return 0;
+}
+
+#ifdef CONFIG_OF
+int __init mx27_clocks_init_dt(void)
+{
+       struct device_node *np;
+       u32 fref = 26000000; /* default */
+
+       for_each_compatible_node(np, NULL, "fixed-clock") {
+               if (!of_device_is_compatible(np, "fsl,imx-osc26m"))
+                       continue;
+
+               if (!of_property_read_u32(np, "clock-frequency", &fref))
+                       break;
+       }
+
+       return mx27_clocks_init(fref);
+}
+#endif
diff --git a/arch/arm/mach-imx/clk-imx31.c b/arch/arm/mach-imx/clk-imx31.c
new file mode 100644 (file)
index 0000000..a854b9c
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2012 Sascha Hauer <kernel@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/io.h>
+#include <linux/err.h>
+
+#include <mach/hardware.h>
+#include <mach/mx31.h>
+#include <mach/common.h>
+
+#include "clk.h"
+#include "crmregs-imx3.h"
+
+static const char *mcu_main_sel[] = { "spll", "mpll", };
+static const char *per_sel[] = { "per_div", "ipg", };
+static const char *csi_sel[] = { "upll", "spll", };
+static const char *fir_sel[] = { "mcu_main", "upll", "spll" };
+
+enum mx31_clks {
+       ckih, ckil, mpll, spll, upll, mcu_main, hsp, ahb, nfc, ipg, per_div,
+       per, csi, fir, csi_div, usb_div_pre, usb_div_post, fir_div_pre,
+       fir_div_post, sdhc1_gate, sdhc2_gate, gpt_gate, epit1_gate, epit2_gate,
+       iim_gate, ata_gate, sdma_gate, cspi3_gate, rng_gate, uart1_gate,
+       uart2_gate, ssi1_gate, i2c1_gate, i2c2_gate, i2c3_gate, hantro_gate,
+       mstick1_gate, mstick2_gate, csi_gate, rtc_gate, wdog_gate, pwm_gate,
+       sim_gate, ect_gate, usb_gate, kpp_gate, ipu_gate, uart3_gate,
+       uart4_gate, uart5_gate, owire_gate, ssi2_gate, cspi1_gate, cspi2_gate,
+       gacc_gate, emi_gate, rtic_gate, firi_gate, clk_max
+};
+
+static struct clk *clk[clk_max];
+
+int __init mx31_clocks_init(unsigned long fref)
+{
+       void __iomem *base = MX31_IO_ADDRESS(MX31_CCM_BASE_ADDR);
+       int i;
+
+       clk[ckih] = imx_clk_fixed("ckih", fref);
+       clk[ckil] = imx_clk_fixed("ckil", 32768);
+       clk[mpll] = imx_clk_pllv1("mpll", "ckih", base + MXC_CCM_MPCTL);
+       clk[spll] = imx_clk_pllv1("spll", "ckih", base + MXC_CCM_SRPCTL);
+       clk[upll] = imx_clk_pllv1("upll", "ckih", base + MXC_CCM_UPCTL);
+       clk[mcu_main] = imx_clk_mux("mcu_main", base + MXC_CCM_PMCR0, 31, 1, mcu_main_sel, ARRAY_SIZE(mcu_main_sel));
+       clk[hsp] = imx_clk_divider("hsp", "mcu_main", base + MXC_CCM_PDR0, 11, 3);
+       clk[ahb] = imx_clk_divider("ahb", "mcu_main", base + MXC_CCM_PDR0, 3, 3);
+       clk[nfc] = imx_clk_divider("nfc", "ahb", base + MXC_CCM_PDR0, 8, 3);
+       clk[ipg] = imx_clk_divider("ipg", "ahb", base + MXC_CCM_PDR0, 6, 2);
+       clk[per_div] = imx_clk_divider("per_div", "upll", base + MXC_CCM_PDR0, 16, 5);
+       clk[per] = imx_clk_mux("per", base + MXC_CCM_CCMR, 24, 1, per_sel, ARRAY_SIZE(per_sel));
+       clk[csi] = imx_clk_mux("csi_sel", base + MXC_CCM_CCMR, 25, 1, csi_sel, ARRAY_SIZE(csi_sel));
+       clk[fir] = imx_clk_mux("fir_sel", base + MXC_CCM_CCMR, 11, 2, fir_sel, ARRAY_SIZE(fir_sel));
+       clk[csi_div] = imx_clk_divider("csi_div", "csi_sel", base + MXC_CCM_PDR0, 23, 9);
+       clk[usb_div_pre] = imx_clk_divider("usb_div_pre", "upll", base + MXC_CCM_PDR1, 30, 2);
+       clk[usb_div_post] = imx_clk_divider("usb_div_post", "usb_div_pre", base + MXC_CCM_PDR1, 27, 3);
+       clk[fir_div_pre] = imx_clk_divider("fir_div_pre", "fir_sel", base + MXC_CCM_PDR1, 24, 3);
+       clk[fir_div_post] = imx_clk_divider("fir_div_post", "fir_div_pre", base + MXC_CCM_PDR1, 23, 6);
+       clk[sdhc1_gate] = imx_clk_gate2("sdhc1_gate", "per", base + MXC_CCM_CGR0, 0);
+       clk[sdhc2_gate] = imx_clk_gate2("sdhc2_gate", "per", base + MXC_CCM_CGR0, 2);
+       clk[gpt_gate] = imx_clk_gate2("gpt_gate", "per", base + MXC_CCM_CGR0, 4);
+       clk[epit1_gate] = imx_clk_gate2("epit1_gate", "per", base + MXC_CCM_CGR0, 6);
+       clk[epit2_gate] = imx_clk_gate2("epit2_gate", "per", base + MXC_CCM_CGR0, 8);
+       clk[iim_gate] = imx_clk_gate2("iim_gate", "ipg", base + MXC_CCM_CGR0, 10);
+       clk[ata_gate] = imx_clk_gate2("ata_gate", "ipg", base + MXC_CCM_CGR0, 12);
+       clk[sdma_gate] = imx_clk_gate2("sdma_gate", "ahb", base + MXC_CCM_CGR0, 14);
+       clk[cspi3_gate] = imx_clk_gate2("cspi3_gate", "ipg", base + MXC_CCM_CGR0, 16);
+       clk[rng_gate] = imx_clk_gate2("rng_gate", "ipg", base + MXC_CCM_CGR0, 18);
+       clk[uart1_gate] = imx_clk_gate2("uart1_gate", "per", base + MXC_CCM_CGR0, 20);
+       clk[uart2_gate] = imx_clk_gate2("uart2_gate", "per", base + MXC_CCM_CGR0, 22);
+       clk[ssi1_gate] = imx_clk_gate2("ssi1_gate", "spll", base + MXC_CCM_CGR0, 24);
+       clk[i2c1_gate] = imx_clk_gate2("i2c1_gate", "per", base + MXC_CCM_CGR0, 26);
+       clk[i2c2_gate] = imx_clk_gate2("i2c2_gate", "per", base + MXC_CCM_CGR0, 28);
+       clk[i2c3_gate] = imx_clk_gate2("i2c3_gate", "per", base + MXC_CCM_CGR0, 30);
+       clk[hantro_gate] = imx_clk_gate2("hantro_gate", "per", base + MXC_CCM_CGR1, 0);
+       clk[mstick1_gate] = imx_clk_gate2("mstick1_gate", "per", base + MXC_CCM_CGR1, 2);
+       clk[mstick2_gate] = imx_clk_gate2("mstick2_gate", "per", base + MXC_CCM_CGR1, 4);
+       clk[csi_gate] = imx_clk_gate2("csi_gate", "csi_div", base + MXC_CCM_CGR1, 6);
+       clk[rtc_gate] = imx_clk_gate2("rtc_gate", "ipg", base + MXC_CCM_CGR1, 8);
+       clk[wdog_gate] = imx_clk_gate2("wdog_gate", "ipg", base + MXC_CCM_CGR1, 10);
+       clk[pwm_gate] = imx_clk_gate2("pwm_gate", "per", base + MXC_CCM_CGR1, 12);
+       clk[sim_gate] = imx_clk_gate2("sim_gate", "per", base + MXC_CCM_CGR1, 14);
+       clk[ect_gate] = imx_clk_gate2("ect_gate", "per", base + MXC_CCM_CGR1, 16);
+       clk[usb_gate] = imx_clk_gate2("usb_gate", "ahb", base + MXC_CCM_CGR1, 18);
+       clk[kpp_gate] = imx_clk_gate2("kpp_gate", "ipg", base + MXC_CCM_CGR1, 20);
+       clk[ipu_gate] = imx_clk_gate2("ipu_gate", "hsp", base + MXC_CCM_CGR1, 22);
+       clk[uart3_gate] = imx_clk_gate2("uart3_gate", "per", base + MXC_CCM_CGR1, 24);
+       clk[uart4_gate] = imx_clk_gate2("uart4_gate", "per", base + MXC_CCM_CGR1, 26);
+       clk[uart5_gate] = imx_clk_gate2("uart5_gate", "per", base + MXC_CCM_CGR1, 28);
+       clk[owire_gate] = imx_clk_gate2("owire_gate", "per", base + MXC_CCM_CGR1, 30);
+       clk[ssi2_gate] = imx_clk_gate2("ssi2_gate", "spll", base + MXC_CCM_CGR2, 0);
+       clk[cspi1_gate] = imx_clk_gate2("cspi1_gate", "ipg", base + MXC_CCM_CGR2, 2);
+       clk[cspi2_gate] = imx_clk_gate2("cspi2_gate", "ipg", base + MXC_CCM_CGR2, 4);
+       clk[gacc_gate] = imx_clk_gate2("gacc_gate", "per", base + MXC_CCM_CGR2, 6);
+       clk[emi_gate] = imx_clk_gate2("emi_gate", "ahb", base + MXC_CCM_CGR2, 8);
+       clk[rtic_gate] = imx_clk_gate2("rtic_gate", "ahb", base + MXC_CCM_CGR2, 10);
+       clk[firi_gate] = imx_clk_gate2("firi_gate", "upll", base+MXC_CCM_CGR2, 12);
+
+       for (i = 0; i < ARRAY_SIZE(clk); i++)
+               if (IS_ERR(clk[i]))
+                       pr_err("imx31 clk %d: register failed with %ld\n",
+                               i, PTR_ERR(clk[i]));
+
+       clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0");
+       clk_register_clkdev(clk[ipg], "ipg", "imx-gpt.0");
+       clk_register_clkdev(clk[cspi1_gate], NULL, "imx31-cspi.0");
+       clk_register_clkdev(clk[cspi2_gate], NULL, "imx31-cspi.1");
+       clk_register_clkdev(clk[cspi3_gate], NULL, "imx31-cspi.2");
+       clk_register_clkdev(clk[pwm_gate], "pwm", NULL);
+       clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0");
+       clk_register_clkdev(clk[rtc_gate], "rtc", NULL);
+       clk_register_clkdev(clk[epit1_gate], "epit", NULL);
+       clk_register_clkdev(clk[epit2_gate], "epit", NULL);
+       clk_register_clkdev(clk[nfc], NULL, "mxc_nand.0");
+       clk_register_clkdev(clk[ipu_gate], NULL, "ipu-core");
+       clk_register_clkdev(clk[ipu_gate], NULL, "mx3_sdc_fb");
+       clk_register_clkdev(clk[kpp_gate], "kpp", NULL);
+       clk_register_clkdev(clk[usb_div_post], "per", "mxc-ehci.0");
+       clk_register_clkdev(clk[usb_gate], "ahb", "mxc-ehci.0");
+       clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.0");
+       clk_register_clkdev(clk[usb_div_post], "per", "mxc-ehci.1");
+       clk_register_clkdev(clk[usb_gate], "ahb", "mxc-ehci.1");
+       clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.1");
+       clk_register_clkdev(clk[usb_div_post], "per", "mxc-ehci.2");
+       clk_register_clkdev(clk[usb_gate], "ahb", "mxc-ehci.2");
+       clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.2");
+       clk_register_clkdev(clk[usb_div_post], "per", "fsl-usb2-udc");
+       clk_register_clkdev(clk[usb_gate], "ahb", "fsl-usb2-udc");
+       clk_register_clkdev(clk[ipg], "ipg", "fsl-usb2-udc");
+       clk_register_clkdev(clk[csi_gate], NULL, "mx3-camera.0");
+       /* i.mx31 has the i.mx21 type uart */
+       clk_register_clkdev(clk[uart1_gate], "per", "imx21-uart.0");
+       clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.0");
+       clk_register_clkdev(clk[uart2_gate], "per", "imx21-uart.1");
+       clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.1");
+       clk_register_clkdev(clk[uart3_gate], "per", "imx21-uart.2");
+       clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.2");
+       clk_register_clkdev(clk[uart4_gate], "per", "imx21-uart.3");
+       clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.3");
+       clk_register_clkdev(clk[uart5_gate], "per", "imx21-uart.4");
+       clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.4");
+       clk_register_clkdev(clk[i2c1_gate], NULL, "imx-i2c.0");
+       clk_register_clkdev(clk[i2c2_gate], NULL, "imx-i2c.1");
+       clk_register_clkdev(clk[i2c3_gate], NULL, "imx-i2c.2");
+       clk_register_clkdev(clk[owire_gate], NULL, "mxc_w1.0");
+       clk_register_clkdev(clk[sdhc1_gate], NULL, "mxc-mmc.0");
+       clk_register_clkdev(clk[sdhc2_gate], NULL, "mxc-mmc.1");
+       clk_register_clkdev(clk[ssi1_gate], NULL, "imx-ssi.0");
+       clk_register_clkdev(clk[ssi2_gate], NULL, "imx-ssi.1");
+       clk_register_clkdev(clk[firi_gate], "firi", NULL);
+       clk_register_clkdev(clk[ata_gate], NULL, "pata_imx");
+       clk_register_clkdev(clk[rtic_gate], "rtic", NULL);
+       clk_register_clkdev(clk[rng_gate], "rng", NULL);
+       clk_register_clkdev(clk[sdma_gate], NULL, "imx31-sdma");
+       clk_register_clkdev(clk[iim_gate], "iim", NULL);
+
+       clk_set_parent(clk[csi], clk[upll]);
+       clk_prepare_enable(clk[emi_gate]);
+       clk_prepare_enable(clk[iim_gate]);
+       mx31_revision();
+       clk_disable_unprepare(clk[iim_gate]);
+
+       mxc_timer_init(NULL, MX31_IO_ADDRESS(MX31_GPT1_BASE_ADDR),
+                       MX31_INT_GPT);
+
+       return 0;
+}
diff --git a/arch/arm/mach-imx/clk-imx35.c b/arch/arm/mach-imx/clk-imx35.c
new file mode 100644 (file)
index 0000000..a9e60bf
--- /dev/null
@@ -0,0 +1,278 @@
+/*
+ * Copyright (C) 2012 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
+ *
+ * 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/mm.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/clkdev.h>
+#include <linux/of.h>
+#include <linux/err.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+
+#include "crmregs-imx3.h"
+#include "clk.h"
+
+struct arm_ahb_div {
+       unsigned char arm, ahb, sel;
+};
+
+static struct arm_ahb_div clk_consumer[] = {
+       { .arm = 1, .ahb = 4, .sel = 0},
+       { .arm = 1, .ahb = 3, .sel = 1},
+       { .arm = 2, .ahb = 2, .sel = 0},
+       { .arm = 0, .ahb = 0, .sel = 0},
+       { .arm = 0, .ahb = 0, .sel = 0},
+       { .arm = 0, .ahb = 0, .sel = 0},
+       { .arm = 4, .ahb = 1, .sel = 0},
+       { .arm = 1, .ahb = 5, .sel = 0},
+       { .arm = 1, .ahb = 8, .sel = 0},
+       { .arm = 1, .ahb = 6, .sel = 1},
+       { .arm = 2, .ahb = 4, .sel = 0},
+       { .arm = 0, .ahb = 0, .sel = 0},
+       { .arm = 0, .ahb = 0, .sel = 0},
+       { .arm = 0, .ahb = 0, .sel = 0},
+       { .arm = 4, .ahb = 2, .sel = 0},
+       { .arm = 0, .ahb = 0, .sel = 0},
+};
+
+static char hsp_div_532[] = { 4, 8, 3, 0 };
+static char hsp_div_400[] = { 3, 6, 3, 0 };
+
+static const char *std_sel[] = {"ppll", "arm"};
+static const char *ipg_per_sel[] = {"ahb_per_div", "arm_per_div"};
+
+enum mx35_clks {
+       ckih, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg,
+       arm_per_div, ahb_per_div, ipg_per, uart_sel, uart_div, esdhc_sel,
+       esdhc1_div, esdhc2_div, esdhc3_div, spdif_sel, spdif_div_pre,
+       spdif_div_post, ssi_sel, ssi1_div_pre, ssi1_div_post, ssi2_div_pre,
+       ssi2_div_post, usb_sel, usb_div, nfc_div, asrc_gate, pata_gate,
+       audmux_gate, can1_gate, can2_gate, cspi1_gate, cspi2_gate, ect_gate,
+       edio_gate, emi_gate, epit1_gate, epit2_gate, esai_gate, esdhc1_gate,
+       esdhc2_gate, esdhc3_gate, fec_gate, gpio1_gate, gpio2_gate, gpio3_gate,
+       gpt_gate, i2c1_gate, i2c2_gate, i2c3_gate, iomuxc_gate, ipu_gate,
+       kpp_gate, mlb_gate, mshc_gate, owire_gate, pwm_gate, rngc_gate,
+       rtc_gate, rtic_gate, scc_gate, sdma_gate, spba_gate, spdif_gate,
+       ssi1_gate, ssi2_gate, uart1_gate, uart2_gate, uart3_gate, usbotg_gate,
+       wdog_gate, max_gate, admux_gate, csi_gate, iim_gate, gpu2d_gate,
+       clk_max
+};
+
+static struct clk *clk[clk_max];
+
+int __init mx35_clocks_init()
+{
+       void __iomem *base = MX35_IO_ADDRESS(MX35_CCM_BASE_ADDR);
+       u32 pdr0, consumer_sel, hsp_sel;
+       struct arm_ahb_div *aad;
+       unsigned char *hsp_div;
+       int i;
+
+       pdr0 = __raw_readl(base + MXC_CCM_PDR0);
+       consumer_sel = (pdr0 >> 16) & 0xf;
+       aad = &clk_consumer[consumer_sel];
+       if (!aad->arm) {
+               pr_err("i.MX35 clk: illegal consumer mux selection 0x%x\n", consumer_sel);
+               /*
+                * We are basically stuck. Continue with a default entry and hope we
+                * get far enough to actually show the above message
+                */
+               aad = &clk_consumer[0];
+       }
+
+       clk[ckih] = imx_clk_fixed("ckih", 24000000);
+       clk[mpll] = imx_clk_pllv1("mpll", "ckih", base + MX35_CCM_MPCTL);
+       clk[ppll] = imx_clk_pllv1("ppll", "ckih", base + MX35_CCM_PPCTL);
+
+       clk[mpll] = imx_clk_fixed_factor("mpll_075", "mpll", 3, 4);
+
+       if (aad->sel)
+               clk[arm] = imx_clk_fixed_factor("arm", "mpll_075", 1, aad->arm);
+       else
+               clk[arm] = imx_clk_fixed_factor("arm", "mpll", 1, aad->arm);
+
+       if (clk_get_rate(clk[arm]) > 400000000)
+               hsp_div = hsp_div_532;
+       else
+               hsp_div = hsp_div_400;
+
+       hsp_sel = (pdr0 >> 20) & 0x3;
+       if (!hsp_div[hsp_sel]) {
+               pr_err("i.MX35 clk: illegal hsp clk selection 0x%x\n", hsp_sel);
+               hsp_sel = 0;
+       }
+
+       clk[hsp] = imx_clk_fixed_factor("hsp", "arm", 1, hsp_div[hsp_sel]);
+
+       clk[ahb] = imx_clk_fixed_factor("ahb", "arm", 1, aad->ahb);
+       clk[ipg] = imx_clk_fixed_factor("ipg", "ahb", 1, 2);
+
+       clk[arm_per_div] = imx_clk_divider("arm_per_div", "arm", base + MX35_CCM_PDR4, 16, 6);
+       clk[ahb_per_div] = imx_clk_divider("ahb_per_div", "ahb", base + MXC_CCM_PDR0, 12, 3);
+       clk[ipg_per] = imx_clk_mux("ipg_per", base + MXC_CCM_PDR0, 26, 1, ipg_per_sel, ARRAY_SIZE(ipg_per_sel));
+
+       clk[uart_sel] = imx_clk_mux("uart_sel", base + MX35_CCM_PDR3, 14, 1, std_sel, ARRAY_SIZE(std_sel));
+       clk[uart_div] = imx_clk_divider("uart_div", "uart_sel", base + MX35_CCM_PDR4, 10, 6);
+
+       clk[esdhc_sel] = imx_clk_mux("esdhc_sel", base + MX35_CCM_PDR4, 9, 1, std_sel, ARRAY_SIZE(std_sel));
+       clk[esdhc1_div] = imx_clk_divider("esdhc1_div", "esdhc_sel", base + MX35_CCM_PDR3, 0, 6);
+       clk[esdhc2_div] = imx_clk_divider("esdhc2_div", "esdhc_sel", base + MX35_CCM_PDR3, 8, 6);
+       clk[esdhc3_div] = imx_clk_divider("esdhc3_div", "esdhc_sel", base + MX35_CCM_PDR3, 16, 6);
+
+       clk[spdif_sel] = imx_clk_mux("spdif_sel", base + MX35_CCM_PDR3, 22, 1, std_sel, ARRAY_SIZE(std_sel));
+       clk[spdif_div_pre] = imx_clk_divider("spdif_div_pre", "spdif_sel", base + MX35_CCM_PDR3, 29, 3); /* divide by 1 not allowed */ 
+       clk[spdif_div_post] = imx_clk_divider("spdif_div_post", "spdif_div_pre", base + MX35_CCM_PDR3, 23, 6);
+
+       clk[ssi_sel] = imx_clk_mux("ssi_sel", base + MX35_CCM_PDR2, 6, 1, std_sel, ARRAY_SIZE(std_sel));
+       clk[ssi1_div_pre] = imx_clk_divider("ssi1_div_pre", "ssi_sel", base + MX35_CCM_PDR2, 24, 3);
+       clk[ssi1_div_post] = imx_clk_divider("ssi1_div_post", "ssi1_div_pre", base + MX35_CCM_PDR2, 0, 6);
+       clk[ssi2_div_pre] = imx_clk_divider("ssi2_div_pre", "ssi_sel", base + MX35_CCM_PDR2, 27, 3);
+       clk[ssi2_div_post] = imx_clk_divider("ssi2_div_post", "ssi2_div_pre", base + MX35_CCM_PDR2, 8, 6);
+
+       clk[usb_sel] = imx_clk_mux("usb_sel", base + MX35_CCM_PDR4, 9, 1, std_sel, ARRAY_SIZE(std_sel));
+       clk[usb_div] = imx_clk_divider("usb_div", "usb_sel", base + MX35_CCM_PDR4, 22, 6);
+
+       clk[nfc_div] = imx_clk_divider("nfc_div", "ahb", base + MX35_CCM_PDR4, 28, 4);
+
+       clk[asrc_gate] = imx_clk_gate2("asrc_gate", "ipg", base + MX35_CCM_CGR0,  0);
+       clk[pata_gate] = imx_clk_gate2("pata_gate", "ipg", base + MX35_CCM_CGR0,  2);
+       clk[audmux_gate] = imx_clk_gate2("audmux_gate", "ipg", base + MX35_CCM_CGR0,  4);
+       clk[can1_gate] = imx_clk_gate2("can1_gate", "ipg", base + MX35_CCM_CGR0,  6);
+       clk[can2_gate] = imx_clk_gate2("can2_gate", "ipg", base + MX35_CCM_CGR0,  8);
+       clk[cspi1_gate] = imx_clk_gate2("cspi1_gate", "ipg", base + MX35_CCM_CGR0, 10);
+       clk[cspi2_gate] = imx_clk_gate2("cspi2_gate", "ipg", base + MX35_CCM_CGR0, 12);
+       clk[ect_gate] = imx_clk_gate2("ect_gate", "ipg", base + MX35_CCM_CGR0, 14);
+       clk[edio_gate] = imx_clk_gate2("edio_gate",   "ipg", base + MX35_CCM_CGR0, 16);
+       clk[emi_gate] = imx_clk_gate2("emi_gate", "ipg", base + MX35_CCM_CGR0, 18);
+       clk[epit1_gate] = imx_clk_gate2("epit1_gate", "ipg", base + MX35_CCM_CGR0, 20);
+       clk[epit2_gate] = imx_clk_gate2("epit2_gate", "ipg", base + MX35_CCM_CGR0, 22);
+       clk[esai_gate] = imx_clk_gate2("esai_gate",   "ipg", base + MX35_CCM_CGR0, 24);
+       clk[esdhc1_gate] = imx_clk_gate2("esdhc1_gate", "esdhc1_div", base + MX35_CCM_CGR0, 26);
+       clk[esdhc2_gate] = imx_clk_gate2("esdhc2_gate", "esdhc2_div", base + MX35_CCM_CGR0, 28);
+       clk[esdhc3_gate] = imx_clk_gate2("esdhc3_gate", "esdhc3_div", base + MX35_CCM_CGR0, 30);
+
+       clk[fec_gate] = imx_clk_gate2("fec_gate", "ipg", base + MX35_CCM_CGR1,  0);
+       clk[gpio1_gate] = imx_clk_gate2("gpio1_gate", "ipg", base + MX35_CCM_CGR1,  2);
+       clk[gpio2_gate] = imx_clk_gate2("gpio2_gate", "ipg", base + MX35_CCM_CGR1,  4);
+       clk[gpio3_gate] = imx_clk_gate2("gpio3_gate", "ipg", base + MX35_CCM_CGR1,  6);
+       clk[gpt_gate] = imx_clk_gate2("gpt_gate", "ipg", base + MX35_CCM_CGR1,  8);
+       clk[i2c1_gate] = imx_clk_gate2("i2c1_gate", "ipg_per", base + MX35_CCM_CGR1, 10);
+       clk[i2c2_gate] = imx_clk_gate2("i2c2_gate", "ipg_per", base + MX35_CCM_CGR1, 12);
+       clk[i2c3_gate] = imx_clk_gate2("i2c3_gate", "ipg_per", base + MX35_CCM_CGR1, 14);
+       clk[iomuxc_gate] = imx_clk_gate2("iomuxc_gate", "ipg", base + MX35_CCM_CGR1, 16);
+       clk[ipu_gate] = imx_clk_gate2("ipu_gate", "hsp", base + MX35_CCM_CGR1, 18);
+       clk[kpp_gate] = imx_clk_gate2("kpp_gate", "ipg", base + MX35_CCM_CGR1, 20);
+       clk[mlb_gate] = imx_clk_gate2("mlb_gate", "ahb", base + MX35_CCM_CGR1, 22);
+       clk[mshc_gate] = imx_clk_gate2("mshc_gate", "dummy", base + MX35_CCM_CGR1, 24);
+       clk[owire_gate] = imx_clk_gate2("owire_gate", "ipg_per", base + MX35_CCM_CGR1, 26);
+       clk[pwm_gate] = imx_clk_gate2("pwm_gate", "ipg_per", base + MX35_CCM_CGR1, 28);
+       clk[rngc_gate] = imx_clk_gate2("rngc_gate", "ipg", base + MX35_CCM_CGR1, 30);
+
+       clk[rtc_gate] = imx_clk_gate2("rtc_gate", "ipg", base + MX35_CCM_CGR2,  0);
+       clk[rtic_gate] = imx_clk_gate2("rtic_gate", "ahb", base + MX35_CCM_CGR2,  2);
+       clk[scc_gate] = imx_clk_gate2("scc_gate", "ipg", base + MX35_CCM_CGR2,  4);
+       clk[sdma_gate] = imx_clk_gate2("sdma_gate", "ahb", base + MX35_CCM_CGR2,  6);
+       clk[spba_gate] = imx_clk_gate2("spba_gate", "ipg", base + MX35_CCM_CGR2,  8);
+       clk[spdif_gate] = imx_clk_gate2("spdif_gate", "spdif_div_post", base + MX35_CCM_CGR2, 10);
+       clk[ssi1_gate] = imx_clk_gate2("ssi1_gate", "ssi1_div_post", base + MX35_CCM_CGR2, 12);
+       clk[ssi2_gate] = imx_clk_gate2("ssi2_gate", "ssi2_div_post", base + MX35_CCM_CGR2, 14);
+       clk[uart1_gate] = imx_clk_gate2("uart1_gate", "uart_div", base + MX35_CCM_CGR2, 16);
+       clk[uart2_gate] = imx_clk_gate2("uart2_gate", "uart_div", base + MX35_CCM_CGR2, 18);
+       clk[uart3_gate] = imx_clk_gate2("uart3_gate", "uart_div", base + MX35_CCM_CGR2, 20);
+       clk[usbotg_gate] = imx_clk_gate2("usbotg_gate", "ahb", base + MX35_CCM_CGR2, 22);
+       clk[wdog_gate] = imx_clk_gate2("wdog_gate", "ipg", base + MX35_CCM_CGR2, 24);
+       clk[max_gate] = imx_clk_gate2("max_gate", "dummy", base + MX35_CCM_CGR2, 26);
+       clk[admux_gate] = imx_clk_gate2("admux_gate", "ipg", base + MX35_CCM_CGR2, 30);
+
+       clk[csi_gate] = imx_clk_gate2("csi_gate", "ipg", base + MX35_CCM_CGR3,  0);
+       clk[iim_gate] = imx_clk_gate2("iim_gate", "ipg", base + MX35_CCM_CGR3,  2);
+       clk[gpu2d_gate] = imx_clk_gate2("gpu2d_gate", "ahb", base + MX35_CCM_CGR3,  4);
+
+       for (i = 0; i < ARRAY_SIZE(clk); i++)
+               if (IS_ERR(clk[i]))
+                       pr_err("i.MX35 clk %d: register failed with %ld\n",
+                               i, PTR_ERR(clk[i]));
+
+
+       clk_register_clkdev(clk[pata_gate], NULL, "pata_imx");
+       clk_register_clkdev(clk[can1_gate], NULL, "flexcan.0");
+       clk_register_clkdev(clk[can2_gate], NULL, "flexcan.1");
+       clk_register_clkdev(clk[cspi1_gate], "per", "imx35-cspi.0");
+       clk_register_clkdev(clk[cspi1_gate], "ipg", "imx35-cspi.0");
+       clk_register_clkdev(clk[cspi2_gate], "per", "imx35-cspi.1");
+       clk_register_clkdev(clk[cspi2_gate], "ipg", "imx35-cspi.1");
+       clk_register_clkdev(clk[epit1_gate], NULL, "imx-epit.0");
+       clk_register_clkdev(clk[epit2_gate], NULL, "imx-epit.1");
+       clk_register_clkdev(clk[esdhc1_gate], "per", "sdhci-esdhc-imx35.0");
+       clk_register_clkdev(clk[ipg], "ipg", "sdhci-esdhc-imx35.0");
+       clk_register_clkdev(clk[ahb], "ahb", "sdhci-esdhc-imx35.0");
+       clk_register_clkdev(clk[esdhc2_gate], "per", "sdhci-esdhc-imx35.1");
+       clk_register_clkdev(clk[ipg], "ipg", "sdhci-esdhc-imx35.1");
+       clk_register_clkdev(clk[ahb], "ahb", "sdhci-esdhc-imx35.1");
+       clk_register_clkdev(clk[esdhc3_gate], "per", "sdhci-esdhc-imx35.2");
+       clk_register_clkdev(clk[ipg], "ipg", "sdhci-esdhc-imx35.2");
+       clk_register_clkdev(clk[ahb], "ahb", "sdhci-esdhc-imx35.2");
+       /* i.mx35 has the i.mx27 type fec */
+       clk_register_clkdev(clk[fec_gate], NULL, "imx27-fec.0");
+       clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0");
+       clk_register_clkdev(clk[ipg], "ipg", "imx-gpt.0");
+       clk_register_clkdev(clk[i2c1_gate], NULL, "imx-i2c.0");
+       clk_register_clkdev(clk[i2c2_gate], NULL, "imx-i2c.1");
+       clk_register_clkdev(clk[i2c3_gate], NULL, "imx-i2c.2");
+       clk_register_clkdev(clk[ipu_gate], NULL, "ipu-core");
+       clk_register_clkdev(clk[ipu_gate], NULL, "mx3_sdc_fb");
+       clk_register_clkdev(clk[owire_gate], NULL, "mxc_w1");
+       clk_register_clkdev(clk[sdma_gate], NULL, "imx35-sdma");
+       clk_register_clkdev(clk[ipg], "ipg", "imx-ssi.0");
+       clk_register_clkdev(clk[ssi1_div_post], "per", "imx-ssi.0");
+       clk_register_clkdev(clk[ipg], "ipg", "imx-ssi.1");
+       clk_register_clkdev(clk[ssi2_div_post], "per", "imx-ssi.1");
+       /* i.mx35 has the i.mx21 type uart */
+       clk_register_clkdev(clk[uart1_gate], "per", "imx21-uart.0");
+       clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.0");
+       clk_register_clkdev(clk[uart2_gate], "per", "imx21-uart.1");
+       clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.1");
+       clk_register_clkdev(clk[uart3_gate], "per", "imx21-uart.2");
+       clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.2");
+       clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.0");
+       clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.0");
+       clk_register_clkdev(clk[usbotg_gate], "ahb", "mxc-ehci.0");
+       clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.1");
+       clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.1");
+       clk_register_clkdev(clk[usbotg_gate], "ahb", "mxc-ehci.1");
+       clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.2");
+       clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.2");
+       clk_register_clkdev(clk[usbotg_gate], "ahb", "mxc-ehci.2");
+       clk_register_clkdev(clk[usb_div], "per", "fsl-usb2-udc");
+       clk_register_clkdev(clk[ipg], "ipg", "fsl-usb2-udc");
+       clk_register_clkdev(clk[usbotg_gate], "ahb", "fsl-usb2-udc");
+       clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0");
+       clk_register_clkdev(clk[nfc_div], NULL, "mxc_nand.0");
+
+       clk_prepare_enable(clk[spba_gate]);
+       clk_prepare_enable(clk[gpio1_gate]);
+       clk_prepare_enable(clk[gpio2_gate]);
+       clk_prepare_enable(clk[gpio3_gate]);
+       clk_prepare_enable(clk[iim_gate]);
+       clk_prepare_enable(clk[emi_gate]);
+
+       imx_print_silicon_rev("i.MX35", mx35_revision());
+
+#ifdef CONFIG_MXC_USE_EPIT
+       epit_timer_init(&epit1_clk,
+                       MX35_IO_ADDRESS(MX35_EPIT1_BASE_ADDR), MX35_INT_EPIT1);
+#else
+       mxc_timer_init(NULL, MX35_IO_ADDRESS(MX35_GPT1_BASE_ADDR),
+                       MX35_INT_GPT);
+#endif
+
+       return 0;
+}
diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c
new file mode 100644 (file)
index 0000000..b8a382d
--- /dev/null
@@ -0,0 +1,466 @@
+/*
+ * Copyright (C) 2011 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
+ *
+ * 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/mm.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/clkdev.h>
+#include <linux/of.h>
+#include <linux/err.h>
+
+#include <mach/hardware.h>
+#include <mach/common.h>
+
+#include "crm-regs-imx5.h"
+#include "clk.h"
+
+/* Low-power Audio Playback Mode clock */
+static const char *lp_apm_sel[] = { "osc", };
+
+/* This is used multiple times */
+static const char *standard_pll_sel[] = { "pll1_sw", "pll2_sw", "pll3_sw", "lp_apm", };
+static const char *periph_apm_sel[] = { "pll1_sw", "pll3_sw", "lp_apm", };
+static const char *main_bus_sel[] = { "pll2_sw", "periph_apm", };
+static const char *per_lp_apm_sel[] = { "main_bus", "lp_apm", };
+static const char *per_root_sel[] = { "per_podf", "ipg", };
+static const char *esdhc_c_sel[] = { "esdhc_a_podf", "esdhc_b_podf", };
+static const char *esdhc_d_sel[] = { "esdhc_a_podf", "esdhc_b_podf", };
+static const char *emi_slow_sel[] = { "main_bus", "ahb", };
+static const char *usb_phy_sel_str[] = { "osc", "usb_phy_podf", };
+static const char *mx51_ipu_di0_sel[] = { "di_pred", "osc", "ckih1", "tve_di", };
+static const char *mx53_ipu_di0_sel[] = { "di_pred", "osc", "ckih1", "di_pll4_podf", "dummy", "ldb_di0", };
+static const char *mx53_ldb_di0_sel[] = { "pll3_sw", "pll4_sw", };
+static const char *mx51_ipu_di1_sel[] = { "di_pred", "osc", "ckih1", "tve_di", "ipp_di1", };
+static const char *mx53_ipu_di1_sel[] = { "di_pred", "osc", "ckih1", "tve_di", "ipp_di1", "ldb_di1", };
+static const char *mx53_ldb_di1_sel[] = { "pll3_sw", "pll4_sw", };
+static const char *mx51_tve_ext_sel[] = { "osc", "ckih1", };
+static const char *mx53_tve_ext_sel[] = { "pll4_sw", "ckih1", };
+static const char *tve_sel[] = { "tve_pred", "tve_ext_sel", };
+static const char *ipu_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb", };
+static const char *vpu_sel[] = { "axi_a", "axi_b", "emi_slow_gate", "ahb", };
+
+enum imx5_clks {
+       dummy, ckil, osc, ckih1, ckih2, ahb, ipg, axi_a, axi_b, uart_pred,
+       uart_root, esdhc_a_pred, esdhc_b_pred, esdhc_c_s, esdhc_d_s,
+       emi_sel, emi_slow_podf, nfc_podf, ecspi_pred, ecspi_podf, usboh3_pred,
+       usboh3_podf, usb_phy_pred, usb_phy_podf, cpu_podf, di_pred, tve_di,
+       tve_s, uart1_ipg_gate, uart1_per_gate, uart2_ipg_gate,
+       uart2_per_gate, uart3_ipg_gate, uart3_per_gate, i2c1_gate, i2c2_gate,
+       gpt_ipg_gate, pwm1_ipg_gate, pwm1_hf_gate, pwm2_ipg_gate, pwm2_hf_gate,
+       gpt_gate, fec_gate, usboh3_per_gate, esdhc1_ipg_gate, esdhc2_ipg_gate,
+       esdhc3_ipg_gate, esdhc4_ipg_gate, ssi1_ipg_gate, ssi2_ipg_gate,
+       ssi3_ipg_gate, ecspi1_ipg_gate, ecspi1_per_gate, ecspi2_ipg_gate,
+       ecspi2_per_gate, cspi_ipg_gate, sdma_gate, emi_slow_gate, ipu_s,
+       ipu_gate, nfc_gate, ipu_di1_gate, vpu_s, vpu_gate,
+       vpu_reference_gate, uart4_ipg_gate, uart4_per_gate, uart5_ipg_gate,
+       uart5_per_gate, tve_gate, tve_pred, esdhc1_per_gate, esdhc2_per_gate,
+       esdhc3_per_gate, esdhc4_per_gate, usb_phy_gate, hsi2c_gate,
+       mipi_hsc1_gate, mipi_hsc2_gate, mipi_esc_gate, mipi_hsp_gate,
+       ldb_di1_div_3_5, ldb_di1_div, ldb_di0_div_3_5, ldb_di0_div,
+       ldb_di1_gate, can2_serial_gate, can2_ipg_gate, i2c3_gate, lp_apm,
+       periph_apm, main_bus, ahb_max, aips_tz1, aips_tz2, tmax1, tmax2,
+       tmax3, spba, uart_sel, esdhc_a_sel, esdhc_b_sel, esdhc_a_podf,
+       esdhc_b_podf, ecspi_sel, usboh3_sel, usb_phy_sel, iim_gate,
+       usboh3_gate, emi_fast_gate, ipu_di0_gate,gpc_dvfs, pll1_sw, pll2_sw,
+       pll3_sw, ipu_di0_sel, ipu_di1_sel, tve_ext_sel, mx51_mipi, pll4_sw,
+       ldb_di1_sel, di_pll4_podf, ldb_di0_sel, ldb_di0_gate, usb_phy1_gate,
+       usb_phy2_gate, per_lp_apm, per_pred1, per_pred2, per_podf, per_root,
+       clk_max
+};
+
+static struct clk *clk[clk_max];
+
+static void __init mx5_clocks_common_init(unsigned long rate_ckil,
+               unsigned long rate_osc, unsigned long rate_ckih1,
+               unsigned long rate_ckih2)
+{
+       int i;
+
+       clk[dummy] = imx_clk_fixed("dummy", 0);
+       clk[ckil] = imx_clk_fixed("ckil", rate_ckil);
+       clk[osc] = imx_clk_fixed("osc", rate_osc);
+       clk[ckih1] = imx_clk_fixed("ckih1", rate_ckih1);
+       clk[ckih2] = imx_clk_fixed("ckih2", rate_ckih2);
+
+       clk[lp_apm] = imx_clk_mux("lp_apm", MXC_CCM_CCSR, 9, 1,
+                               lp_apm_sel, ARRAY_SIZE(lp_apm_sel));
+       clk[periph_apm] = imx_clk_mux("periph_apm", MXC_CCM_CBCMR, 12, 2,
+                               periph_apm_sel, ARRAY_SIZE(periph_apm_sel));
+       clk[main_bus] = imx_clk_mux("main_bus", MXC_CCM_CBCDR, 25, 1,
+                               main_bus_sel, ARRAY_SIZE(main_bus_sel));
+       clk[per_lp_apm] = imx_clk_mux("per_lp_apm", MXC_CCM_CBCDR, 1, 1,
+                               per_lp_apm_sel, ARRAY_SIZE(per_lp_apm_sel));
+       clk[per_pred1] = imx_clk_divider("per_pred1", "per_lp_apm", MXC_CCM_CBCDR, 6, 2);
+       clk[per_pred2] = imx_clk_divider("per_pred2", "per_pred1", MXC_CCM_CBCDR, 3, 3);
+       clk[per_podf] = imx_clk_divider("per_podf", "per_pred2", MXC_CCM_CBCDR, 0, 3);
+       clk[per_root] = imx_clk_mux("per_root", MXC_CCM_CBCDR, 1, 0,
+                               per_root_sel, ARRAY_SIZE(per_root_sel));
+       clk[ahb] = imx_clk_divider("ahb", "main_bus", MXC_CCM_CBCDR, 10, 3);
+       clk[ahb_max] = imx_clk_gate2("ahb_max", "ahb", MXC_CCM_CCGR0, 28);
+       clk[aips_tz1] = imx_clk_gate2("aips_tz1", "ahb", MXC_CCM_CCGR0, 24);
+       clk[aips_tz2] = imx_clk_gate2("aips_tz2", "ahb", MXC_CCM_CCGR0, 26);
+       clk[tmax1] = imx_clk_gate2("tmax1", "ahb", MXC_CCM_CCGR1, 0);
+       clk[tmax2] = imx_clk_gate2("tmax2", "ahb", MXC_CCM_CCGR1, 2);
+       clk[tmax3] = imx_clk_gate2("tmax3", "ahb", MXC_CCM_CCGR1, 4);
+       clk[spba] = imx_clk_gate2("spba", "ipg", MXC_CCM_CCGR5, 0);
+       clk[ipg] = imx_clk_divider("ipg", "ahb", MXC_CCM_CBCDR, 8, 2);
+       clk[axi_a] = imx_clk_divider("axi_a", "main_bus", MXC_CCM_CBCDR, 16, 3);
+       clk[axi_b] = imx_clk_divider("axi_b", "main_bus", MXC_CCM_CBCDR, 19, 3);
+       clk[uart_sel] = imx_clk_mux("uart_sel", MXC_CCM_CSCMR1, 24, 2,
+                               standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
+       clk[uart_pred] = imx_clk_divider("uart_pred", "uart_sel", MXC_CCM_CSCDR1, 3, 3);
+       clk[uart_root] = imx_clk_divider("uart_root", "uart_pred", MXC_CCM_CSCDR1, 0, 3);
+
+       clk[esdhc_a_sel] = imx_clk_mux("esdhc_a_sel", MXC_CCM_CSCMR1, 20, 2,
+                               standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
+       clk[esdhc_b_sel] = imx_clk_mux("esdhc_b_sel", MXC_CCM_CSCMR1, 16, 2,
+                               standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
+       clk[esdhc_a_pred] = imx_clk_divider("esdhc_a_pred", "esdhc_a_sel", MXC_CCM_CSCDR1, 16, 3);
+       clk[esdhc_a_podf] = imx_clk_divider("esdhc_a_podf", "esdhc_a_pred", MXC_CCM_CSCDR1, 11, 3);
+       clk[esdhc_b_pred] = imx_clk_divider("esdhc_b_pred", "esdhc_b_sel", MXC_CCM_CSCDR1, 22, 3);
+       clk[esdhc_b_podf] = imx_clk_divider("esdhc_b_podf", "esdhc_b_pred", MXC_CCM_CSCDR1, 19, 3);
+       clk[esdhc_c_s] = imx_clk_mux("esdhc_c_sel", MXC_CCM_CSCMR1, 19, 1, esdhc_c_sel, ARRAY_SIZE(esdhc_c_sel));
+       clk[esdhc_d_s] = imx_clk_mux("esdhc_d_sel", MXC_CCM_CSCMR1, 18, 1, esdhc_d_sel, ARRAY_SIZE(esdhc_d_sel));
+
+       clk[emi_sel] = imx_clk_mux("emi_sel", MXC_CCM_CBCDR, 26, 1,
+                               emi_slow_sel, ARRAY_SIZE(emi_slow_sel));
+       clk[emi_slow_podf] = imx_clk_divider("emi_slow_podf", "emi_sel", MXC_CCM_CBCDR, 22, 3);
+       clk[nfc_podf] = imx_clk_divider("nfc_podf", "emi_slow_podf", MXC_CCM_CBCDR, 13, 3);
+       clk[ecspi_sel] = imx_clk_mux("ecspi_sel", MXC_CCM_CSCMR1, 4, 2,
+                               standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
+       clk[ecspi_pred] = imx_clk_divider("ecspi_pred", "ecspi_sel", MXC_CCM_CSCDR2, 25, 3);
+       clk[ecspi_podf] = imx_clk_divider("ecspi_podf", "ecspi_pred", MXC_CCM_CSCDR2, 19, 6);
+       clk[usboh3_sel] = imx_clk_mux("usboh3_sel", MXC_CCM_CSCMR1, 22, 2,
+                               standard_pll_sel, ARRAY_SIZE(standard_pll_sel));
+       clk[usboh3_pred] = imx_clk_divider("usboh3_pred", "usboh3_sel", MXC_CCM_CSCDR1, 8, 3);
+       clk[usboh3_podf] = imx_clk_divider("usboh3_podf", "usboh3_pred", MXC_CCM_CSCDR1, 6, 2);
+       clk[usb_phy_pred] = imx_clk_divider("usb_phy_pred", "pll3_sw", MXC_CCM_CDCDR, 3, 3);
+       clk[usb_phy_podf] = imx_clk_divider("usb_phy_podf", "usb_phy_pred", MXC_CCM_CDCDR, 0, 3);
+       clk[usb_phy_sel] = imx_clk_mux("usb_phy_sel", MXC_CCM_CSCMR1, 26, 1,
+                               usb_phy_sel_str, ARRAY_SIZE(usb_phy_sel_str));
+       clk[cpu_podf] = imx_clk_divider("cpu_podf", "pll1_sw", MXC_CCM_CACRR, 0, 3);
+       clk[di_pred] = imx_clk_divider("di_pred", "pll3_sw", MXC_CCM_CDCDR, 6, 3);
+       clk[tve_di] = imx_clk_fixed("tve_di", 65000000); /* FIXME */
+       clk[tve_s] = imx_clk_mux("tve_sel", MXC_CCM_CSCMR1, 7, 1, tve_sel, ARRAY_SIZE(tve_sel));
+       clk[iim_gate] = imx_clk_gate2("iim_gate", "ipg", MXC_CCM_CCGR0, 30);
+       clk[uart1_ipg_gate] = imx_clk_gate2("uart1_ipg_gate", "ipg", MXC_CCM_CCGR1, 6);
+       clk[uart1_per_gate] = imx_clk_gate2("uart1_per_gate", "uart_root", MXC_CCM_CCGR1, 8);
+       clk[uart2_ipg_gate] = imx_clk_gate2("uart2_ipg_gate", "ipg", MXC_CCM_CCGR1, 10);
+       clk[uart2_per_gate] = imx_clk_gate2("uart2_per_gate", "uart_root", MXC_CCM_CCGR1, 12);
+       clk[uart3_ipg_gate] = imx_clk_gate2("uart3_ipg_gate", "ipg", MXC_CCM_CCGR1, 14);
+       clk[uart3_per_gate] = imx_clk_gate2("uart3_per_gate", "uart_root", MXC_CCM_CCGR1, 16);
+       clk[i2c1_gate] = imx_clk_gate2("i2c1_gate", "per_root", MXC_CCM_CCGR1, 18);
+       clk[i2c2_gate] = imx_clk_gate2("i2c2_gate", "per_root", MXC_CCM_CCGR1, 20);
+       clk[gpt_ipg_gate] = imx_clk_gate2("gpt_ipg_gate", "ipg", MXC_CCM_CCGR2, 20);
+       clk[pwm1_ipg_gate] = imx_clk_gate2("pwm1_ipg_gate", "ipg", MXC_CCM_CCGR2, 10);
+       clk[pwm1_hf_gate] = imx_clk_gate2("pwm1_hf_gate", "ipg", MXC_CCM_CCGR2, 12);
+       clk[pwm2_ipg_gate] = imx_clk_gate2("pwm2_ipg_gate", "ipg", MXC_CCM_CCGR2, 14);
+       clk[pwm2_hf_gate] = imx_clk_gate2("pwm2_hf_gate", "ipg", MXC_CCM_CCGR2, 16);
+       clk[gpt_gate] = imx_clk_gate2("gpt_gate", "ipg", MXC_CCM_CCGR2, 18);
+       clk[fec_gate] = imx_clk_gate2("fec_gate", "ipg", MXC_CCM_CCGR2, 24);
+       clk[usboh3_gate] = imx_clk_gate2("usboh3_gate", "ipg", MXC_CCM_CCGR2, 26);
+       clk[usboh3_per_gate] = imx_clk_gate2("usboh3_per_gate", "usboh3_podf", MXC_CCM_CCGR2, 28);
+       clk[esdhc1_ipg_gate] = imx_clk_gate2("esdhc1_ipg_gate", "ipg", MXC_CCM_CCGR3, 0);
+       clk[esdhc2_ipg_gate] = imx_clk_gate2("esdhc2_ipg_gate", "ipg", MXC_CCM_CCGR3, 4);
+       clk[esdhc3_ipg_gate] = imx_clk_gate2("esdhc3_ipg_gate", "ipg", MXC_CCM_CCGR3, 8);
+       clk[esdhc4_ipg_gate] = imx_clk_gate2("esdhc4_ipg_gate", "ipg", MXC_CCM_CCGR3, 12);
+       clk[ssi1_ipg_gate] = imx_clk_gate2("ssi1_ipg_gate", "ipg", MXC_CCM_CCGR3, 16);
+       clk[ssi2_ipg_gate] = imx_clk_gate2("ssi2_ipg_gate", "ipg", MXC_CCM_CCGR3, 20);
+       clk[ssi3_ipg_gate] = imx_clk_gate2("ssi3_ipg_gate", "ipg", MXC_CCM_CCGR3, 24);
+       clk[ecspi1_ipg_gate] = imx_clk_gate2("ecspi1_ipg_gate", "ipg", MXC_CCM_CCGR4, 18);
+       clk[ecspi1_per_gate] = imx_clk_gate2("ecspi1_per_gate", "ecspi_podf", MXC_CCM_CCGR4, 20);
+       clk[ecspi2_ipg_gate] = imx_clk_gate2("ecspi2_ipg_gate", "ipg", MXC_CCM_CCGR4, 22);
+       clk[ecspi2_per_gate] = imx_clk_gate2("ecspi2_per_gate", "ecspi_podf", MXC_CCM_CCGR4, 24);
+       clk[cspi_ipg_gate] = imx_clk_gate2("cspi_ipg_gate", "ipg", MXC_CCM_CCGR4, 26);
+       clk[sdma_gate] = imx_clk_gate2("sdma_gate", "ipg", MXC_CCM_CCGR4, 30);
+       clk[emi_fast_gate] = imx_clk_gate2("emi_fast_gate", "dummy", MXC_CCM_CCGR5, 14);
+       clk[emi_slow_gate] = imx_clk_gate2("emi_slow_gate", "emi_slow_podf", MXC_CCM_CCGR5, 16);
+       clk[ipu_s] = imx_clk_mux("ipu_sel", MXC_CCM_CBCMR, 6, 2, ipu_sel, ARRAY_SIZE(ipu_sel));
+       clk[ipu_gate] = imx_clk_gate2("ipu_gate", "ipu_sel", MXC_CCM_CCGR5, 10);
+       clk[nfc_gate] = imx_clk_gate2("nfc_gate", "nfc_podf", MXC_CCM_CCGR5, 20);
+       clk[ipu_di0_gate] = imx_clk_gate2("ipu_di0_gate", "ipu_di0_sel", MXC_CCM_CCGR6, 10);
+       clk[ipu_di1_gate] = imx_clk_gate2("ipu_di1_gate", "ipu_di1_sel", MXC_CCM_CCGR6, 12);
+       clk[vpu_s] = imx_clk_mux("vpu_sel", MXC_CCM_CBCMR, 14, 2, vpu_sel, ARRAY_SIZE(vpu_sel));
+       clk[vpu_gate] = imx_clk_gate2("vpu_gate", "vpu_sel", MXC_CCM_CCGR5, 6);
+       clk[vpu_reference_gate] = imx_clk_gate2("vpu_reference_gate", "osc", MXC_CCM_CCGR5, 8);
+       clk[uart4_ipg_gate] = imx_clk_gate2("uart4_ipg_gate", "ipg", MXC_CCM_CCGR7, 8);
+       clk[uart4_per_gate] = imx_clk_gate2("uart4_per_gate", "uart_root", MXC_CCM_CCGR7, 10);
+       clk[uart5_ipg_gate] = imx_clk_gate2("uart5_ipg_gate", "ipg", MXC_CCM_CCGR7, 12);
+       clk[uart5_per_gate] = imx_clk_gate2("uart5_per_gate", "uart_root", MXC_CCM_CCGR7, 14);
+       clk[gpc_dvfs] = imx_clk_gate2("gpc_dvfs", "dummy", MXC_CCM_CCGR5, 24);
+
+       for (i = 0; i < ARRAY_SIZE(clk); i++)
+               if (IS_ERR(clk[i]))
+                       pr_err("i.MX5 clk %d: register failed with %ld\n",
+                               i, PTR_ERR(clk[i]));
+       
+       clk_register_clkdev(clk[gpt_gate], "per", "imx-gpt.0");
+       clk_register_clkdev(clk[gpt_ipg_gate], "ipg", "imx-gpt.0");
+       clk_register_clkdev(clk[uart1_per_gate], "per", "imx21-uart.0");
+       clk_register_clkdev(clk[uart1_ipg_gate], "ipg", "imx21-uart.0");
+       clk_register_clkdev(clk[uart2_per_gate], "per", "imx21-uart.1");
+       clk_register_clkdev(clk[uart2_ipg_gate], "ipg", "imx21-uart.1");
+       clk_register_clkdev(clk[uart3_per_gate], "per", "imx21-uart.2");
+       clk_register_clkdev(clk[uart3_ipg_gate], "ipg", "imx21-uart.2");
+       clk_register_clkdev(clk[uart4_per_gate], "per", "imx21-uart.3");
+       clk_register_clkdev(clk[uart4_ipg_gate], "ipg", "imx21-uart.3");
+       clk_register_clkdev(clk[uart5_per_gate], "per", "imx21-uart.4");
+       clk_register_clkdev(clk[uart5_ipg_gate], "ipg", "imx21-uart.4");
+       clk_register_clkdev(clk[ecspi1_per_gate], "per", "imx51-ecspi.0");
+       clk_register_clkdev(clk[ecspi1_ipg_gate], "ipg", "imx51-ecspi.0");
+       clk_register_clkdev(clk[ecspi2_per_gate], "per", "imx51-ecspi.1");
+       clk_register_clkdev(clk[ecspi2_ipg_gate], "ipg", "imx51-ecspi.1");
+       clk_register_clkdev(clk[cspi_ipg_gate], NULL, "imx51-cspi.0");
+       clk_register_clkdev(clk[pwm1_ipg_gate], "pwm", "mxc_pwm.0");
+       clk_register_clkdev(clk[pwm2_ipg_gate], "pwm", "mxc_pwm.1");
+       clk_register_clkdev(clk[i2c1_gate], NULL, "imx-i2c.0");
+       clk_register_clkdev(clk[i2c2_gate], NULL, "imx-i2c.1");
+       clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.0");
+       clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.0");
+       clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.0");
+       clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.1");
+       clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.1");
+       clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.1");
+       clk_register_clkdev(clk[usboh3_per_gate], "per", "mxc-ehci.2");
+       clk_register_clkdev(clk[usboh3_gate], "ipg", "mxc-ehci.2");
+       clk_register_clkdev(clk[usboh3_gate], "ahb", "mxc-ehci.2");
+       clk_register_clkdev(clk[usboh3_per_gate], "per", "fsl-usb2-udc");
+       clk_register_clkdev(clk[usboh3_gate], "ipg", "fsl-usb2-udc");
+       clk_register_clkdev(clk[usboh3_gate], "ahb", "fsl-usb2-udc");
+       clk_register_clkdev(clk[nfc_gate], NULL, "mxc_nand");
+       clk_register_clkdev(clk[ssi1_ipg_gate], NULL, "imx-ssi.0");
+       clk_register_clkdev(clk[ssi2_ipg_gate], NULL, "imx-ssi.1");
+       clk_register_clkdev(clk[ssi3_ipg_gate], NULL, "imx-ssi.2");
+       clk_register_clkdev(clk[sdma_gate], NULL, "imx35-sdma");
+       clk_register_clkdev(clk[cpu_podf], "cpu", NULL);
+       clk_register_clkdev(clk[iim_gate], "iim", NULL);
+       clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.0");
+       clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.1");
+       clk_register_clkdev(clk[dummy], NULL, "imx-keypad");
+       clk_register_clkdev(clk[tve_gate], NULL, "imx-tve.0");
+       clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx-tve.0");
+
+       /* Set SDHC parents to be PLL2 */
+       clk_set_parent(clk[esdhc_a_sel], clk[pll2_sw]);
+       clk_set_parent(clk[esdhc_b_sel], clk[pll2_sw]);
+
+       /* move usb phy clk to 24MHz */
+       clk_set_parent(clk[usb_phy_sel], clk[osc]);
+
+       clk_prepare_enable(clk[gpc_dvfs]);
+       clk_prepare_enable(clk[ahb_max]); /* esdhc3 */
+       clk_prepare_enable(clk[aips_tz1]);
+       clk_prepare_enable(clk[aips_tz2]); /* fec */
+       clk_prepare_enable(clk[spba]);
+       clk_prepare_enable(clk[emi_fast_gate]); /* fec */
+       clk_prepare_enable(clk[tmax1]);
+       clk_prepare_enable(clk[tmax2]); /* esdhc2, fec */
+       clk_prepare_enable(clk[tmax3]); /* esdhc1, esdhc4 */
+}
+
+int __init mx51_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
+                       unsigned long rate_ckih1, unsigned long rate_ckih2)
+{
+       int i;
+
+       clk[pll1_sw] = imx_clk_pllv2("pll1_sw", "osc", MX51_DPLL1_BASE);
+       clk[pll2_sw] = imx_clk_pllv2("pll2_sw", "osc", MX51_DPLL2_BASE);
+       clk[pll3_sw] = imx_clk_pllv2("pll3_sw", "osc", MX51_DPLL3_BASE);
+       clk[ipu_di0_sel] = imx_clk_mux("ipu_di0_sel", MXC_CCM_CSCMR2, 26, 3,
+                               mx51_ipu_di0_sel, ARRAY_SIZE(mx51_ipu_di0_sel));
+       clk[ipu_di1_sel] = imx_clk_mux("ipu_di1_sel", MXC_CCM_CSCMR2, 29, 3,
+                               mx51_ipu_di1_sel, ARRAY_SIZE(mx51_ipu_di1_sel));
+       clk[tve_ext_sel] = imx_clk_mux("tve_ext_sel", MXC_CCM_CSCMR1, 6, 1,
+                               mx51_tve_ext_sel, ARRAY_SIZE(mx51_tve_ext_sel));
+       clk[tve_gate] = imx_clk_gate2("tve_gate", "tve_sel", MXC_CCM_CCGR2, 30);
+       clk[tve_pred] = imx_clk_divider("tve_pred", "pll3_sw", MXC_CCM_CDCDR, 28, 3);
+       clk[esdhc1_per_gate] = imx_clk_gate2("esdhc1_per_gate", "esdhc_a_podf", MXC_CCM_CCGR3, 2);
+       clk[esdhc2_per_gate] = imx_clk_gate2("esdhc2_per_gate", "esdhc_b_podf", MXC_CCM_CCGR3, 6);
+       clk[esdhc3_per_gate] = imx_clk_gate2("esdhc3_per_gate", "esdhc_c_sel", MXC_CCM_CCGR3, 10);
+       clk[esdhc4_per_gate] = imx_clk_gate2("esdhc4_per_gate", "esdhc_d_sel", MXC_CCM_CCGR3, 14);
+       clk[usb_phy_gate] = imx_clk_gate2("usb_phy_gate", "usb_phy_sel", MXC_CCM_CCGR2, 0);
+       clk[hsi2c_gate] = imx_clk_gate2("hsi2c_gate", "ipg", MXC_CCM_CCGR1, 22);
+       clk[mipi_hsc1_gate] = imx_clk_gate2("mipi_hsc1_gate", "ipg", MXC_CCM_CCGR4, 6);
+       clk[mipi_hsc2_gate] = imx_clk_gate2("mipi_hsc2_gate", "ipg", MXC_CCM_CCGR4, 8);
+       clk[mipi_esc_gate] = imx_clk_gate2("mipi_esc_gate", "ipg", MXC_CCM_CCGR4, 10);
+       clk[mipi_hsp_gate] = imx_clk_gate2("mipi_hsp_gate", "ipg", MXC_CCM_CCGR4, 12);
+
+       for (i = 0; i < ARRAY_SIZE(clk); i++)
+               if (IS_ERR(clk[i]))
+                       pr_err("i.MX51 clk %d: register failed with %ld\n",
+                               i, PTR_ERR(clk[i]));
+
+       mx5_clocks_common_init(rate_ckil, rate_osc, rate_ckih1, rate_ckih2);
+
+       clk_register_clkdev(clk[hsi2c_gate], NULL, "imx-i2c.2");
+       clk_register_clkdev(clk[mx51_mipi], "mipi_hsp", NULL);
+       clk_register_clkdev(clk[vpu_gate], NULL, "imx51-vpu.0");
+       clk_register_clkdev(clk[fec_gate], NULL, "imx27-fec.0");
+       clk_register_clkdev(clk[gpc_dvfs], "gpc_dvfs", NULL);
+       clk_register_clkdev(clk[ipu_gate], "bus", "imx51-ipu");
+       clk_register_clkdev(clk[ipu_di0_gate], "di0", "imx51-ipu");
+       clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx51-ipu");
+       clk_register_clkdev(clk[ipu_gate], "hsp", "imx51-ipu");
+       clk_register_clkdev(clk[usb_phy_gate], "phy", "mxc-ehci.0");
+       clk_register_clkdev(clk[esdhc1_ipg_gate], "ipg", "sdhci-esdhc-imx51.0");
+       clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.0");
+       clk_register_clkdev(clk[esdhc1_per_gate], "per", "sdhci-esdhc-imx51.0");
+       clk_register_clkdev(clk[esdhc2_ipg_gate], "ipg", "sdhci-esdhc-imx51.1");
+       clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.1");
+       clk_register_clkdev(clk[esdhc2_per_gate], "per", "sdhci-esdhc-imx51.1");
+       clk_register_clkdev(clk[esdhc3_ipg_gate], "ipg", "sdhci-esdhc-imx51.2");
+       clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.2");
+       clk_register_clkdev(clk[esdhc3_per_gate], "per", "sdhci-esdhc-imx51.2");
+       clk_register_clkdev(clk[esdhc4_ipg_gate], "ipg", "sdhci-esdhc-imx51.3");
+       clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx51.3");
+       clk_register_clkdev(clk[esdhc4_per_gate], "per", "sdhci-esdhc-imx51.3");
+
+       /* set the usboh3 parent to pll2_sw */
+       clk_set_parent(clk[usboh3_sel], clk[pll2_sw]);
+
+       /* set SDHC root clock to 166.25MHZ*/
+       clk_set_rate(clk[esdhc_a_podf], 166250000);
+       clk_set_rate(clk[esdhc_b_podf], 166250000);
+
+       /* System timer */
+       mxc_timer_init(NULL, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR),
+               MX51_INT_GPT);
+
+       clk_prepare_enable(clk[iim_gate]);
+       imx_print_silicon_rev("i.MX51", mx51_revision());
+       clk_disable_unprepare(clk[iim_gate]);
+
+       return 0;
+}
+
+int __init mx53_clocks_init(unsigned long rate_ckil, unsigned long rate_osc,
+                       unsigned long rate_ckih1, unsigned long rate_ckih2)
+{
+       int i;
+       unsigned long r;
+
+       clk[pll1_sw] = imx_clk_pllv2("pll1_sw", "osc", MX53_DPLL1_BASE);
+       clk[pll2_sw] = imx_clk_pllv2("pll2_sw", "osc", MX53_DPLL2_BASE);
+       clk[pll3_sw] = imx_clk_pllv2("pll3_sw", "osc", MX53_DPLL3_BASE);
+       clk[pll4_sw] = imx_clk_pllv2("pll4_sw", "osc", MX53_DPLL4_BASE);
+
+       clk[ldb_di1_sel] = imx_clk_mux("ldb_di1_sel", MXC_CCM_CSCMR2, 9, 1,
+                               mx53_ldb_di1_sel, ARRAY_SIZE(mx53_ldb_di1_sel));
+       clk[ldb_di1_div_3_5] = imx_clk_fixed_factor("ldb_di1_div_3_5", "ldb_di1_sel", 2, 7);
+       clk[ldb_di1_div] = imx_clk_divider("ldb_di1_div", "ldb_di1_div_3_5", MXC_CCM_CSCMR2, 11, 1);
+       clk[di_pll4_podf] = imx_clk_divider("di_pll4_podf", "pll4_sw", MXC_CCM_CDCDR, 16, 3);
+       clk[ldb_di0_sel] = imx_clk_mux("ldb_di0_sel", MXC_CCM_CSCMR2, 8, 1,
+                               mx53_ldb_di0_sel, ARRAY_SIZE(mx53_ldb_di0_sel));
+       clk[ldb_di0_div_3_5] = imx_clk_fixed_factor("ldb_di0_div_3_5", "ldb_di0_sel", 2, 7);
+       clk[ldb_di0_div] = imx_clk_divider("ldb_di0_div", "ldb_di0_div_3_5", MXC_CCM_CSCMR2, 10, 1);
+       clk[ldb_di0_gate] = imx_clk_gate2("ldb_di0_gate", "ldb_di0_div", MXC_CCM_CCGR6, 28);
+       clk[ldb_di1_gate] = imx_clk_gate2("ldb_di1_gate", "ldb_di1_div", MXC_CCM_CCGR6, 30);
+       clk[ipu_di0_sel] = imx_clk_mux("ipu_di0_sel", MXC_CCM_CSCMR2, 26, 3,
+                               mx53_ipu_di0_sel, ARRAY_SIZE(mx53_ipu_di0_sel));
+       clk[ipu_di1_sel] = imx_clk_mux("ipu_di1_sel", MXC_CCM_CSCMR2, 29, 3,
+                               mx53_ipu_di1_sel, ARRAY_SIZE(mx53_ipu_di1_sel));
+       clk[tve_ext_sel] = imx_clk_mux("tve_ext_sel", MXC_CCM_CSCMR1, 6, 1,
+                               mx53_tve_ext_sel, ARRAY_SIZE(mx53_tve_ext_sel));
+       clk[tve_gate] = imx_clk_gate2("tve_gate", "tve_pred", MXC_CCM_CCGR2, 30);
+       clk[tve_pred] = imx_clk_divider("tve_pred", "tve_ext_sel", MXC_CCM_CDCDR, 28, 3);
+       clk[esdhc1_per_gate] = imx_clk_gate2("esdhc1_per_gate", "esdhc_a_podf", MXC_CCM_CCGR3, 2);
+       clk[esdhc2_per_gate] = imx_clk_gate2("esdhc2_per_gate", "esdhc_c_sel", MXC_CCM_CCGR3, 6);
+       clk[esdhc3_per_gate] = imx_clk_gate2("esdhc3_per_gate", "esdhc_b_podf", MXC_CCM_CCGR3, 10);
+       clk[esdhc4_per_gate] = imx_clk_gate2("esdhc4_per_gate", "esdhc_d_sel", MXC_CCM_CCGR3, 14);
+       clk[usb_phy1_gate] = imx_clk_gate2("usb_phy1_gate", "usb_phy_sel", MXC_CCM_CCGR4, 10);
+       clk[usb_phy2_gate] = imx_clk_gate2("usb_phy2_gate", "usb_phy_sel", MXC_CCM_CCGR4, 12);
+       clk[can2_serial_gate] = imx_clk_gate2("can2_serial_gate", "ipg", MXC_CCM_CCGR4, 6);
+       clk[can2_ipg_gate] = imx_clk_gate2("can2_ipg_gate", "ipg", MXC_CCM_CCGR4, 8);
+       clk[i2c3_gate] = imx_clk_gate2("i2c3_gate", "per_root", MXC_CCM_CCGR1, 22);
+
+       for (i = 0; i < ARRAY_SIZE(clk); i++)
+               if (IS_ERR(clk[i]))
+                       pr_err("i.MX53 clk %d: register failed with %ld\n",
+                               i, PTR_ERR(clk[i]));
+
+       mx5_clocks_common_init(rate_ckil, rate_osc, rate_ckih1, rate_ckih2);
+
+       clk_register_clkdev(clk[vpu_gate], NULL, "imx53-vpu.0");
+       clk_register_clkdev(clk[i2c3_gate], NULL, "imx-i2c.2");
+       clk_register_clkdev(clk[fec_gate], NULL, "imx25-fec.0");
+       clk_register_clkdev(clk[ipu_gate], "bus", "imx53-ipu");
+       clk_register_clkdev(clk[ipu_di0_gate], "di0", "imx53-ipu");
+       clk_register_clkdev(clk[ipu_di1_gate], "di1", "imx53-ipu");
+       clk_register_clkdev(clk[ipu_gate], "hsp", "imx53-ipu");
+       clk_register_clkdev(clk[usb_phy1_gate], "usb_phy1", "mxc-ehci.0");
+       clk_register_clkdev(clk[esdhc1_ipg_gate], "ipg", "sdhci-esdhc-imx53.0");
+       clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.0");
+       clk_register_clkdev(clk[esdhc1_per_gate], "per", "sdhci-esdhc-imx53.0");
+       clk_register_clkdev(clk[esdhc2_ipg_gate], "ipg", "sdhci-esdhc-imx53.1");
+       clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.1");
+       clk_register_clkdev(clk[esdhc2_per_gate], "per", "sdhci-esdhc-imx53.1");
+       clk_register_clkdev(clk[esdhc3_ipg_gate], "ipg", "sdhci-esdhc-imx53.2");
+       clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.2");
+       clk_register_clkdev(clk[esdhc3_per_gate], "per", "sdhci-esdhc-imx53.2");
+       clk_register_clkdev(clk[esdhc4_ipg_gate], "ipg", "sdhci-esdhc-imx53.3");
+       clk_register_clkdev(clk[dummy], "ahb", "sdhci-esdhc-imx53.3");
+       clk_register_clkdev(clk[esdhc4_per_gate], "per", "sdhci-esdhc-imx53.3");
+
+       /* set SDHC root clock to 200MHZ*/
+       clk_set_rate(clk[esdhc_a_podf], 200000000);
+       clk_set_rate(clk[esdhc_b_podf], 200000000);
+
+       /* System timer */
+       mxc_timer_init(NULL, MX53_IO_ADDRESS(MX53_GPT1_BASE_ADDR),
+               MX53_INT_GPT);
+
+       clk_prepare_enable(clk[iim_gate]);
+       imx_print_silicon_rev("i.MX53", mx53_revision());
+       clk_disable_unprepare(clk[iim_gate]);
+
+       r = clk_round_rate(clk[usboh3_per_gate], 54000000);
+       clk_set_rate(clk[usboh3_per_gate], r);
+
+       return 0;
+}
+
+#ifdef CONFIG_OF
+static void __init clk_get_freq_dt(unsigned long *ckil, unsigned long *osc,
+                                  unsigned long *ckih1, unsigned long *ckih2)
+{
+       struct device_node *np;
+
+       /* retrieve the freqency of fixed clocks from device tree */
+       for_each_compatible_node(np, NULL, "fixed-clock") {
+               u32 rate;
+               if (of_property_read_u32(np, "clock-frequency", &rate))
+                       continue;
+
+               if (of_device_is_compatible(np, "fsl,imx-ckil"))
+                       *ckil = rate;
+               else if (of_device_is_compatible(np, "fsl,imx-osc"))
+                       *osc = rate;
+               else if (of_device_is_compatible(np, "fsl,imx-ckih1"))
+                       *ckih1 = rate;
+               else if (of_device_is_compatible(np, "fsl,imx-ckih2"))
+                       *ckih2 = rate;
+       }
+}
+
+int __init mx51_clocks_init_dt(void)
+{
+       unsigned long ckil, osc, ckih1, ckih2;
+
+       clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2);
+       return mx51_clocks_init(ckil, osc, ckih1, ckih2);
+}
+
+int __init mx53_clocks_init_dt(void)
+{
+       unsigned long ckil, osc, ckih1, ckih2;
+
+       clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2);
+       return mx53_clocks_init(ckil, osc, ckih1, ckih2);
+}
+#endif
diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
new file mode 100644 (file)
index 0000000..f40a35d
--- /dev/null
@@ -0,0 +1,439 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <mach/common.h>
+#include "clk.h"
+
+#define CCGR0                          0x68
+#define CCGR1                          0x6c
+#define CCGR2                          0x70
+#define CCGR3                          0x74
+#define CCGR4                          0x78
+#define CCGR5                          0x7c
+#define CCGR6                          0x80
+#define CCGR7                          0x84
+
+#define CLPCR                          0x54
+#define BP_CLPCR_LPM                   0
+#define BM_CLPCR_LPM                   (0x3 << 0)
+#define BM_CLPCR_BYPASS_PMIC_READY     (0x1 << 2)
+#define BM_CLPCR_ARM_CLK_DIS_ON_LPM    (0x1 << 5)
+#define BM_CLPCR_SBYOS                 (0x1 << 6)
+#define BM_CLPCR_DIS_REF_OSC           (0x1 << 7)
+#define BM_CLPCR_VSTBY                 (0x1 << 8)
+#define BP_CLPCR_STBY_COUNT            9
+#define BM_CLPCR_STBY_COUNT            (0x3 << 9)
+#define BM_CLPCR_COSC_PWRDOWN          (0x1 << 11)
+#define BM_CLPCR_WB_PER_AT_LPM         (0x1 << 16)
+#define BM_CLPCR_WB_CORE_AT_LPM                (0x1 << 17)
+#define BM_CLPCR_BYP_MMDC_CH0_LPM_HS   (0x1 << 19)
+#define BM_CLPCR_BYP_MMDC_CH1_LPM_HS   (0x1 << 21)
+#define BM_CLPCR_MASK_CORE0_WFI                (0x1 << 22)
+#define BM_CLPCR_MASK_CORE1_WFI                (0x1 << 23)
+#define BM_CLPCR_MASK_CORE2_WFI                (0x1 << 24)
+#define BM_CLPCR_MASK_CORE3_WFI                (0x1 << 25)
+#define BM_CLPCR_MASK_SCU_IDLE         (0x1 << 26)
+#define BM_CLPCR_MASK_L2CC_IDLE                (0x1 << 27)
+
+static void __iomem *ccm_base;
+
+void __init imx6q_clock_map_io(void) { }
+
+int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode)
+{
+       u32 val = readl_relaxed(ccm_base + CLPCR);
+
+       val &= ~BM_CLPCR_LPM;
+       switch (mode) {
+       case WAIT_CLOCKED:
+               break;
+       case WAIT_UNCLOCKED:
+               val |= 0x1 << BP_CLPCR_LPM;
+               break;
+       case STOP_POWER_ON:
+               val |= 0x2 << BP_CLPCR_LPM;
+               break;
+       case WAIT_UNCLOCKED_POWER_OFF:
+               val |= 0x1 << BP_CLPCR_LPM;
+               val &= ~BM_CLPCR_VSTBY;
+               val &= ~BM_CLPCR_SBYOS;
+               break;
+       case STOP_POWER_OFF:
+               val |= 0x2 << BP_CLPCR_LPM;
+               val |= 0x3 << BP_CLPCR_STBY_COUNT;
+               val |= BM_CLPCR_VSTBY;
+               val |= BM_CLPCR_SBYOS;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       writel_relaxed(val, ccm_base + CLPCR);
+
+       return 0;
+}
+
+static const char *step_sels[] = { "osc", "pll2_pfd2_396m", };
+static const char *pll1_sw_sels[]      = { "pll1_sys", "step", };
+static const char *periph_pre_sels[]   = { "pll2_bus", "pll2_pfd2_396m", "pll2_pfd0_352m", "pll2_198m", };
+static const char *periph_clk2_sels[]  = { "pll3_usb_otg", "osc", };
+static const char *periph_sels[]       = { "periph_pre", "periph_clk2", };
+static const char *periph2_sels[]      = { "periph2_pre", "periph2_clk2", };
+static const char *axi_sels[]          = { "periph", "pll2_pfd2_396m", "pll3_pfd1_540m", };
+static const char *audio_sels[]        = { "pll4_audio", "pll3_pfd2_508m", "pll3_pfd3_454m", "pll3_usb_otg", };
+static const char *gpu_axi_sels[]      = { "axi", "ahb", };
+static const char *gpu2d_core_sels[]   = { "axi", "pll3_usb_otg", "pll2_pfd0_352m", "pll2_pfd2_396m", };
+static const char *gpu3d_core_sels[]   = { "mmdc_ch0_axi", "pll3_usb_otg", "pll2_pfd1_594m", "pll2_pfd2_396m", };
+static const char *gpu3d_shader_sels[] = { "mmdc_ch0_axi", "pll3_usb_otg", "pll2_pfd1_594m", "pll2_pfd9_720m", };
+static const char *ipu_sels[]          = { "mmdc_ch0_axi", "pll2_pfd2_396m", "pll3_120m", "pll3_pfd1_540m", };
+static const char *ldb_di_sels[]       = { "pll5_video", "pll2_pfd0_352m", "pll2_pfd2_396m", "pll3_pfd1_540m", };
+static const char *ipu_di_pre_sels[]   = { "mmdc_ch0_axi", "pll3_usb_otg", "pll5_video", "pll2_pfd0_352m", "pll2_pfd2_396m", "pll3_pfd1_540m", };
+static const char *ipu1_di0_sels[]     = { "ipu1_di0_pre", "dummy", "dummy", "ldb_di0", "ldb_di1", };
+static const char *ipu1_di1_sels[]     = { "ipu1_di1_pre", "dummy", "dummy", "ldb_di0", "ldb_di1", };
+static const char *ipu2_di0_sels[]     = { "ipu2_di0_pre", "dummy", "dummy", "ldb_di0", "ldb_di1", };
+static const char *ipu2_di1_sels[]     = { "ipu2_di1_pre", "dummy", "dummy", "ldb_di0", "ldb_di1", };
+static const char *hsi_tx_sels[]       = { "pll3_120m", "pll2_pfd2_396m", };
+static const char *pcie_axi_sels[]     = { "axi", "ahb", };
+static const char *ssi_sels[]          = { "pll3_pfd2_508m", "pll3_pfd3_454m", "pll4_audio", };
+static const char *usdhc_sels[]        = { "pll2_pfd2_396m", "pll2_pfd0_352m", };
+static const char *enfc_sels[] = { "pll2_pfd0_352m", "pll2_bus", "pll3_usb_otg", "pll2_pfd2_396m", };
+static const char *emi_sels[]          = { "axi", "pll3_usb_otg", "pll2_pfd2_396m", "pll2_pfd0_352m", };
+static const char *vdo_axi_sels[]      = { "axi", "ahb", };
+static const char *vpu_axi_sels[]      = { "axi", "pll2_pfd2_396m", "pll2_pfd0_352m", };
+static const char *cko1_sels[] = { "pll3_usb_otg", "pll2_bus", "pll1_sys", "pll5_video",
+                                   "dummy", "axi", "enfc", "ipu1_di0", "ipu1_di1", "ipu2_di0",
+                                   "ipu2_di1", "ahb", "ipg", "ipg_per", "ckil", "pll4_audio", };
+
+static const char * const clks_init_on[] __initconst = {
+       "mmdc_ch0_axi", "mmdc_ch1_axi", "usboh3",
+};
+
+enum mx6q_clks {
+       dummy, ckil, ckih, osc, pll2_pfd0_352m, pll2_pfd1_594m, pll2_pfd2_396m,
+       pll3_pfd0_720m, pll3_pfd1_540m, pll3_pfd2_508m, pll3_pfd3_454m,
+       pll2_198m, pll3_120m, pll3_80m, pll3_60m, twd, step, pll1_sw,
+       periph_pre, periph2_pre, periph_clk2_sel, periph2_clk2_sel, axi_sel,
+       esai_sel, asrc_sel, spdif_sel, gpu2d_axi, gpu3d_axi, gpu2d_core_sel,
+       gpu3d_core_sel, gpu3d_shader_sel, ipu1_sel, ipu2_sel, ldb_di0_sel,
+       ldb_di1_sel, ipu1_di0_pre_sel, ipu1_di1_pre_sel, ipu2_di0_pre_sel,
+       ipu2_di1_pre_sel, ipu1_di0_sel, ipu1_di1_sel, ipu2_di0_sel,
+       ipu2_di1_sel, hsi_tx_sel, pcie_axi_sel, ssi1_sel, ssi2_sel, ssi3_sel,
+       usdhc1_sel, usdhc2_sel, usdhc3_sel, usdhc4_sel, enfc_sel, emi_sel,
+       emi_slow_sel, vdo_axi_sel, vpu_axi_sel, cko1_sel, periph, periph2,
+       periph_clk2, periph2_clk2, ipg, ipg_per, esai_pred, esai_podf,
+       asrc_pred, asrc_podf, spdif_pred, spdif_podf, can_root, ecspi_root,
+       gpu2d_core_podf, gpu3d_core_podf, gpu3d_shader, ipu1_podf, ipu2_podf,
+       ldb_di0_podf, ldb_di1_podf, ipu1_di0_pre, ipu1_di1_pre, ipu2_di0_pre,
+       ipu2_di1_pre, hsi_tx_podf, ssi1_pred, ssi1_podf, ssi2_pred, ssi2_podf,
+       ssi3_pred, ssi3_podf, uart_serial_podf, usdhc1_podf, usdhc2_podf,
+       usdhc3_podf, usdhc4_podf, enfc_pred, enfc_podf, emi_podf,
+       emi_slow_podf, vpu_axi_podf, cko1_podf, axi, mmdc_ch0_axi_podf,
+       mmdc_ch1_axi_podf, arm, ahb, apbh_dma, asrc, can1_ipg, can1_serial,
+       can2_ipg, can2_serial, ecspi1, ecspi2, ecspi3, ecspi4, ecspi5, enet,
+       esai, gpt_ipg, gpt_ipg_per, gpu2d_core, gpu3d_core, hdmi_iahb,
+       hdmi_isfr, i2c1, i2c2, i2c3, iim, enfc, ipu1, ipu1_di0, ipu1_di1, ipu2,
+       ipu2_di0, ldb_di0, ldb_di1, ipu2_di1, hsi_tx, mlb, mmdc_ch0_axi,
+       mmdc_ch1_axi, ocram, openvg_axi, pcie_axi, pwm1, pwm2, pwm3, pwm4,
+       gpmi_bch_apb, gpmi_bch, gpmi_io, gpmi_apb, sata, sdma, spba, ssi1,
+       ssi2, ssi3, uart_ipg, uart_serial, usboh3, usdhc1, usdhc2, usdhc3,
+       usdhc4, vdo_axi, vpu_axi, cko1, pll1_sys, pll2_bus, pll3_usb_otg,
+       pll4_audio, pll5_video, pll6_mlb, pll7_usb_host, pll8_enet, clk_max
+};
+
+static struct clk *clk[clk_max];
+
+int __init mx6q_clocks_init(void)
+{
+       struct device_node *np;
+       void __iomem *base;
+       struct clk *c;
+       int i, irq;
+
+       clk[dummy] = imx_clk_fixed("dummy", 0);
+
+       /* retrieve the freqency of fixed clocks from device tree */
+       for_each_compatible_node(np, NULL, "fixed-clock") {
+               u32 rate;
+               if (of_property_read_u32(np, "clock-frequency", &rate))
+                       continue;
+
+               if (of_device_is_compatible(np, "fsl,imx-ckil"))
+                       clk[ckil] = imx_clk_fixed("ckil", rate);
+               else if (of_device_is_compatible(np, "fsl,imx-ckih1"))
+                       clk[ckih] = imx_clk_fixed("ckih", rate);
+               else if (of_device_is_compatible(np, "fsl,imx-osc"))
+                       clk[osc] = imx_clk_fixed("osc", rate);
+       }
+
+       np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop");
+       base = of_iomap(np, 0);
+       WARN_ON(!base);
+
+       /*                   type                               name         parent_name  base     gate_mask div_mask */
+       clk[pll1_sys]      = imx_clk_pllv3(IMX_PLLV3_SYS,       "pll1_sys",     "osc", base,        0x2000,   0x7f);
+       clk[pll2_bus]      = imx_clk_pllv3(IMX_PLLV3_GENERIC,   "pll2_bus",     "osc", base + 0x30, 0x2000,   0x1);
+       clk[pll3_usb_otg]  = imx_clk_pllv3(IMX_PLLV3_USB,       "pll3_usb_otg", "osc", base + 0x10, 0x2000,   0x3);
+       clk[pll4_audio]    = imx_clk_pllv3(IMX_PLLV3_AV,        "pll4_audio",   "osc", base + 0x70, 0x2000,   0x7f);
+       clk[pll5_video]    = imx_clk_pllv3(IMX_PLLV3_AV,        "pll5_video",   "osc", base + 0xa0, 0x2000,   0x7f);
+       clk[pll6_mlb]      = imx_clk_pllv3(IMX_PLLV3_MLB,       "pll6_mlb",     "osc", base + 0xd0, 0x2000,   0x0);
+       clk[pll7_usb_host] = imx_clk_pllv3(IMX_PLLV3_USB,       "pll7_usb_host","osc", base + 0x20, 0x2000,   0x3);
+       clk[pll8_enet]     = imx_clk_pllv3(IMX_PLLV3_ENET,      "pll8_enet",    "osc", base + 0xe0, 0x182000, 0x3);
+
+       /*                                name              parent_name        reg       idx */
+       clk[pll2_pfd0_352m] = imx_clk_pfd("pll2_pfd0_352m", "pll2_bus",     base + 0x100, 0);
+       clk[pll2_pfd1_594m] = imx_clk_pfd("pll2_pfd1_594m", "pll2_bus",     base + 0x100, 1);
+       clk[pll2_pfd2_396m] = imx_clk_pfd("pll2_pfd2_396m", "pll2_bus",     base + 0x100, 2);
+       clk[pll3_pfd0_720m] = imx_clk_pfd("pll3_pfd0_720m", "pll3_usb_otg", base + 0xf0,  0);
+       clk[pll3_pfd1_540m] = imx_clk_pfd("pll3_pfd1_540m", "pll3_usb_otg", base + 0xf0,  1);
+       clk[pll3_pfd2_508m] = imx_clk_pfd("pll3_pfd2_508m", "pll3_usb_otg", base + 0xf0,  2);
+       clk[pll3_pfd3_454m] = imx_clk_pfd("pll3_pfd3_454m", "pll3_usb_otg", base + 0xf0,  3);
+
+       /*                                    name         parent_name     mult div */
+       clk[pll2_198m] = imx_clk_fixed_factor("pll2_198m", "pll2_pfd2_396m", 1, 2);
+       clk[pll3_120m] = imx_clk_fixed_factor("pll3_120m", "pll3_usb_otg",   1, 4);
+       clk[pll3_80m]  = imx_clk_fixed_factor("pll3_80m",  "pll3_usb_otg",   1, 6);
+       clk[pll3_60m]  = imx_clk_fixed_factor("pll3_60m",  "pll3_usb_otg",   1, 8);
+       clk[twd]       = imx_clk_fixed_factor("twd",       "arm",            1, 2);
+
+       np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ccm");
+       base = of_iomap(np, 0);
+       WARN_ON(!base);
+       ccm_base = base;
+
+       /*                                  name                reg       shift width parent_names     num_parents */
+       clk[step]             = imx_clk_mux("step",             base + 0xc,  8,  1, step_sels,         ARRAY_SIZE(step_sels));
+       clk[pll1_sw]          = imx_clk_mux("pll1_sw",          base + 0xc,  2,  1, pll1_sw_sels,      ARRAY_SIZE(pll1_sw_sels));
+       clk[periph_pre]       = imx_clk_mux("periph_pre",       base + 0x18, 18, 2, periph_pre_sels,   ARRAY_SIZE(periph_pre_sels));
+       clk[periph2_pre]      = imx_clk_mux("periph2_pre",      base + 0x18, 21, 2, periph_pre_sels,   ARRAY_SIZE(periph_pre_sels));
+       clk[periph_clk2_sel]  = imx_clk_mux("periph_clk2_sel",  base + 0x18, 12, 1, periph_clk2_sels,  ARRAY_SIZE(periph_clk2_sels));
+       clk[periph2_clk2_sel] = imx_clk_mux("periph2_clk2_sel", base + 0x18, 20, 1, periph_clk2_sels,  ARRAY_SIZE(periph_clk2_sels));
+       clk[axi_sel]          = imx_clk_mux("axi_sel",          base + 0x14, 6,  2, axi_sels,          ARRAY_SIZE(axi_sels));
+       clk[esai_sel]         = imx_clk_mux("esai_sel",         base + 0x20, 19, 2, audio_sels,        ARRAY_SIZE(audio_sels));
+       clk[asrc_sel]         = imx_clk_mux("asrc_sel",         base + 0x30, 7,  2, audio_sels,        ARRAY_SIZE(audio_sels));
+       clk[spdif_sel]        = imx_clk_mux("spdif_sel",        base + 0x30, 20, 2, audio_sels,        ARRAY_SIZE(audio_sels));
+       clk[gpu2d_axi]        = imx_clk_mux("gpu2d_axi",        base + 0x18, 0,  1, gpu_axi_sels,      ARRAY_SIZE(gpu_axi_sels));
+       clk[gpu3d_axi]        = imx_clk_mux("gpu3d_axi",        base + 0x18, 1,  1, gpu_axi_sels,      ARRAY_SIZE(gpu_axi_sels));
+       clk[gpu2d_core_sel]   = imx_clk_mux("gpu2d_core_sel",   base + 0x18, 16, 2, gpu2d_core_sels,   ARRAY_SIZE(gpu2d_core_sels));
+       clk[gpu3d_core_sel]   = imx_clk_mux("gpu3d_core_sel",   base + 0x18, 4,  2, gpu3d_core_sels,   ARRAY_SIZE(gpu3d_core_sels));
+       clk[gpu3d_shader_sel] = imx_clk_mux("gpu3d_shader_sel", base + 0x18, 8,  2, gpu3d_shader_sels, ARRAY_SIZE(gpu3d_shader_sels));
+       clk[ipu1_sel]         = imx_clk_mux("ipu1_sel",         base + 0x3c, 9,  2, ipu_sels,          ARRAY_SIZE(ipu_sels));
+       clk[ipu2_sel]         = imx_clk_mux("ipu2_sel",         base + 0x3c, 14, 2, ipu_sels,          ARRAY_SIZE(ipu_sels));
+       clk[ldb_di0_sel]      = imx_clk_mux("ldb_di0_sel",      base + 0x2c, 9,  3, ldb_di_sels,       ARRAY_SIZE(ldb_di_sels));
+       clk[ldb_di1_sel]      = imx_clk_mux("ldb_di1_sel",      base + 0x2c, 12, 3, ldb_di_sels,       ARRAY_SIZE(ldb_di_sels));
+       clk[ipu1_di0_pre_sel] = imx_clk_mux("ipu1_di0_pre_sel", base + 0x34, 6,  3, ipu_di_pre_sels,   ARRAY_SIZE(ipu_di_pre_sels));
+       clk[ipu1_di1_pre_sel] = imx_clk_mux("ipu1_di1_pre_sel", base + 0x34, 15, 3, ipu_di_pre_sels,   ARRAY_SIZE(ipu_di_pre_sels));
+       clk[ipu2_di0_pre_sel] = imx_clk_mux("ipu2_di0_pre_sel", base + 0x38, 6,  3, ipu_di_pre_sels,   ARRAY_SIZE(ipu_di_pre_sels));
+       clk[ipu2_di1_pre_sel] = imx_clk_mux("ipu2_di1_pre_sel", base + 0x38, 15, 3, ipu_di_pre_sels,   ARRAY_SIZE(ipu_di_pre_sels));
+       clk[ipu1_di0_sel]     = imx_clk_mux("ipu1_di0_sel",     base + 0x34, 0,  3, ipu1_di0_sels,     ARRAY_SIZE(ipu1_di0_sels));
+       clk[ipu1_di1_sel]     = imx_clk_mux("ipu1_di1_sel",     base + 0x34, 9,  3, ipu1_di1_sels,     ARRAY_SIZE(ipu1_di1_sels));
+       clk[ipu2_di0_sel]     = imx_clk_mux("ipu2_di0_sel",     base + 0x38, 0,  3, ipu2_di0_sels,     ARRAY_SIZE(ipu2_di0_sels));
+       clk[ipu2_di1_sel]     = imx_clk_mux("ipu2_di1_sel",     base + 0x38, 9,  3, ipu2_di1_sels,     ARRAY_SIZE(ipu2_di1_sels));
+       clk[hsi_tx_sel]       = imx_clk_mux("hsi_tx_sel",       base + 0x30, 28, 1, hsi_tx_sels,       ARRAY_SIZE(hsi_tx_sels));
+       clk[pcie_axi_sel]     = imx_clk_mux("pcie_axi_sel",     base + 0x18, 10, 1, pcie_axi_sels,     ARRAY_SIZE(pcie_axi_sels));
+       clk[ssi1_sel]         = imx_clk_mux("ssi1_sel",         base + 0x1c, 10, 2, ssi_sels,          ARRAY_SIZE(ssi_sels));
+       clk[ssi2_sel]         = imx_clk_mux("ssi2_sel",         base + 0x1c, 12, 2, ssi_sels,          ARRAY_SIZE(ssi_sels));
+       clk[ssi3_sel]         = imx_clk_mux("ssi3_sel",         base + 0x1c, 14, 2, ssi_sels,          ARRAY_SIZE(ssi_sels));
+       clk[usdhc1_sel]       = imx_clk_mux("usdhc1_sel",       base + 0x1c, 16, 1, usdhc_sels,        ARRAY_SIZE(usdhc_sels));
+       clk[usdhc2_sel]       = imx_clk_mux("usdhc2_sel",       base + 0x1c, 17, 1, usdhc_sels,        ARRAY_SIZE(usdhc_sels));
+       clk[usdhc3_sel]       = imx_clk_mux("usdhc3_sel",       base + 0x1c, 18, 1, usdhc_sels,        ARRAY_SIZE(usdhc_sels));
+       clk[usdhc4_sel]       = imx_clk_mux("usdhc4_sel",       base + 0x1c, 19, 1, usdhc_sels,        ARRAY_SIZE(usdhc_sels));
+       clk[enfc_sel]         = imx_clk_mux("enfc_sel",         base + 0x2c, 16, 2, enfc_sels,         ARRAY_SIZE(enfc_sels));
+       clk[emi_sel]          = imx_clk_mux("emi_sel",          base + 0x1c, 27, 2, emi_sels,          ARRAY_SIZE(emi_sels));
+       clk[emi_slow_sel]     = imx_clk_mux("emi_slow_sel",     base + 0x1c, 29, 2, emi_sels,          ARRAY_SIZE(emi_sels));
+       clk[vdo_axi_sel]      = imx_clk_mux("vdo_axi_sel",      base + 0x18, 11, 1, vdo_axi_sels,      ARRAY_SIZE(vdo_axi_sels));
+       clk[vpu_axi_sel]      = imx_clk_mux("vpu_axi_sel",      base + 0x18, 14, 2, vpu_axi_sels,      ARRAY_SIZE(vpu_axi_sels));
+       clk[cko1_sel]         = imx_clk_mux("cko1_sel",         base + 0x60, 0,  4, cko1_sels,         ARRAY_SIZE(cko1_sels));
+
+       /*                              name         reg      shift width busy: reg, shift parent_names  num_parents */
+       clk[periph]  = imx_clk_busy_mux("periph",  base + 0x14, 25,  1,   base + 0x48, 5,  periph_sels,  ARRAY_SIZE(periph_sels));
+       clk[periph2] = imx_clk_busy_mux("periph2", base + 0x14, 26,  1,   base + 0x48, 3,  periph2_sels, ARRAY_SIZE(periph2_sels));
+
+       /*                                      name                parent_name          reg       shift width */
+       clk[periph_clk2]      = imx_clk_divider("periph_clk2",      "periph_clk2_sel",   base + 0x14, 27, 3);
+       clk[periph2_clk2]     = imx_clk_divider("periph2_clk2",     "periph2_clk2_sel",  base + 0x14, 0,  3);
+       clk[ipg]              = imx_clk_divider("ipg",              "ahb",               base + 0x14, 8,  2);
+       clk[ipg_per]          = imx_clk_divider("ipg_per",          "ipg",               base + 0x1c, 0,  6);
+       clk[esai_pred]        = imx_clk_divider("esai_pred",        "esai_sel",          base + 0x28, 9,  3);
+       clk[esai_podf]        = imx_clk_divider("esai_podf",        "esai_pred",         base + 0x28, 25, 3);
+       clk[asrc_pred]        = imx_clk_divider("asrc_pred",        "asrc_sel",          base + 0x30, 12, 3);
+       clk[asrc_podf]        = imx_clk_divider("asrc_podf",        "asrc_pred",         base + 0x30, 9,  3);
+       clk[spdif_pred]       = imx_clk_divider("spdif_pred",       "spdif_sel",         base + 0x30, 25, 3);
+       clk[spdif_podf]       = imx_clk_divider("spdif_podf",       "spdif_pred",        base + 0x30, 22, 3);
+       clk[can_root]         = imx_clk_divider("can_root",         "pll3_usb_otg",      base + 0x20, 2,  6);
+       clk[ecspi_root]       = imx_clk_divider("ecspi_root",       "pll3_60m",          base + 0x38, 19, 6);
+       clk[gpu2d_core_podf]  = imx_clk_divider("gpu2d_core_podf",  "gpu2d_core_sel",    base + 0x18, 23, 3);
+       clk[gpu3d_core_podf]  = imx_clk_divider("gpu3d_core_podf",  "gpu3d_core_sel",    base + 0x18, 26, 3);
+       clk[gpu3d_shader]     = imx_clk_divider("gpu3d_shader",     "gpu3d_shader_sel",  base + 0x18, 29, 3);
+       clk[ipu1_podf]        = imx_clk_divider("ipu1_podf",        "ipu1_sel",          base + 0x3c, 11, 3);
+       clk[ipu2_podf]        = imx_clk_divider("ipu2_podf",        "ipu2_sel",          base + 0x3c, 16, 3);
+       clk[ldb_di0_podf]     = imx_clk_divider("ldb_di0_podf",     "ldb_di0_sel",       base + 0x20, 10, 1);
+       clk[ldb_di1_podf]     = imx_clk_divider("ldb_di1_podf",     "ldb_di1_sel",       base + 0x20, 11, 1);
+       clk[ipu1_di0_pre]     = imx_clk_divider("ipu1_di0_pre",     "ipu1_di0_pre_sel",  base + 0x34, 3,  3);
+       clk[ipu1_di1_pre]     = imx_clk_divider("ipu1_di1_pre",     "ipu1_di1_pre_sel",  base + 0x34, 12, 3);
+       clk[ipu2_di0_pre]     = imx_clk_divider("ipu2_di0_pre",     "ipu2_di0_pre_sel",  base + 0x38, 3,  3);
+       clk[ipu2_di1_pre]     = imx_clk_divider("ipu2_di1_pre",     "ipu2_di1_pre_sel",  base + 0x38, 12, 3);
+       clk[hsi_tx_podf]      = imx_clk_divider("hsi_tx_podf",      "hsi_tx_sel",        base + 0x30, 29, 3);
+       clk[ssi1_pred]        = imx_clk_divider("ssi1_pred",        "ssi1_sel",          base + 0x28, 6,  3);
+       clk[ssi1_podf]        = imx_clk_divider("ssi1_podf",        "ssi1_pred",         base + 0x28, 0,  6);
+       clk[ssi2_pred]        = imx_clk_divider("ssi2_pred",        "ssi2_sel",          base + 0x2c, 6,  3);
+       clk[ssi2_podf]        = imx_clk_divider("ssi2_podf",        "ssi2_pred",         base + 0x2c, 0,  6);
+       clk[ssi3_pred]        = imx_clk_divider("ssi3_pred",        "ssi3_sel",          base + 0x28, 22, 3);
+       clk[ssi3_podf]        = imx_clk_divider("ssi3_podf",        "ssi3_pred",         base + 0x28, 16, 6);
+       clk[uart_serial_podf] = imx_clk_divider("uart_serial_podf", "pll3_80m",          base + 0x24, 0,  6);
+       clk[usdhc1_podf]      = imx_clk_divider("usdhc1_podf",      "usdhc1_sel",        base + 0x24, 11, 3);
+       clk[usdhc2_podf]      = imx_clk_divider("usdhc2_podf",      "usdhc2_sel",        base + 0x24, 16, 3);
+       clk[usdhc3_podf]      = imx_clk_divider("usdhc3_podf",      "usdhc3_sel",        base + 0x24, 19, 3);
+       clk[usdhc4_podf]      = imx_clk_divider("usdhc4_podf",      "usdhc4_sel",        base + 0x24, 22, 3);
+       clk[enfc_pred]        = imx_clk_divider("enfc_pred",        "enfc_sel",          base + 0x2c, 18, 3);
+       clk[enfc_podf]        = imx_clk_divider("enfc_podf",        "enfc_pred",         base + 0x2c, 21, 6);
+       clk[emi_podf]         = imx_clk_divider("emi_podf",         "emi_sel",           base + 0x1c, 20, 3);
+       clk[emi_slow_podf]    = imx_clk_divider("emi_slow_podf",    "emi_slow_sel",      base + 0x1c, 23, 3);
+       clk[vpu_axi_podf]     = imx_clk_divider("vpu_axi_podf",     "vpu_axi_sel",       base + 0x24, 25, 3);
+       clk[cko1_podf]        = imx_clk_divider("cko1_podf",        "cko1_sel",          base + 0x60, 4,  3);
+
+       /*                                            name                 parent_name    reg        shift width busy: reg, shift */
+       clk[axi]               = imx_clk_busy_divider("axi",               "axi_sel",     base + 0x14, 16,  3,   base + 0x48, 0);
+       clk[mmdc_ch0_axi_podf] = imx_clk_busy_divider("mmdc_ch0_axi_podf", "periph",      base + 0x14, 19,  3,   base + 0x48, 4);
+       clk[mmdc_ch1_axi_podf] = imx_clk_busy_divider("mmdc_ch1_axi_podf", "periph2",     base + 0x14, 3,   3,   base + 0x48, 2);
+       clk[arm]               = imx_clk_busy_divider("arm",               "pll1_sw",     base + 0x10, 0,   3,   base + 0x48, 16);
+       clk[ahb]               = imx_clk_busy_divider("ahb",               "periph",      base + 0x14, 10,  3,   base + 0x48, 1);
+
+       /*                                name             parent_name          reg         shift */
+       clk[apbh_dma]     = imx_clk_gate2("apbh_dma",      "ahb",               base + 0x68, 4);
+       clk[asrc]         = imx_clk_gate2("asrc",          "asrc_podf",         base + 0x68, 6);
+       clk[can1_ipg]     = imx_clk_gate2("can1_ipg",      "ipg",               base + 0x68, 14);
+       clk[can1_serial]  = imx_clk_gate2("can1_serial",   "can_root",          base + 0x68, 16);
+       clk[can2_ipg]     = imx_clk_gate2("can2_ipg",      "ipg",               base + 0x68, 18);
+       clk[can2_serial]  = imx_clk_gate2("can2_serial",   "can_root",          base + 0x68, 20);
+       clk[ecspi1]       = imx_clk_gate2("ecspi1",        "ecspi_root",        base + 0x6c, 0);
+       clk[ecspi2]       = imx_clk_gate2("ecspi2",        "ecspi_root",        base + 0x6c, 2);
+       clk[ecspi3]       = imx_clk_gate2("ecspi3",        "ecspi_root",        base + 0x6c, 4);
+       clk[ecspi4]       = imx_clk_gate2("ecspi4",        "ecspi_root",        base + 0x6c, 6);
+       clk[ecspi5]       = imx_clk_gate2("ecspi5",        "ecspi_root",        base + 0x6c, 8);
+       clk[enet]         = imx_clk_gate2("enet",          "ipg",               base + 0x6c, 10);
+       clk[esai]         = imx_clk_gate2("esai",          "esai_podf",         base + 0x6c, 16);
+       clk[gpt_ipg]      = imx_clk_gate2("gpt_ipg",       "ipg",               base + 0x6c, 20);
+       clk[gpt_ipg_per]  = imx_clk_gate2("gpt_ipg_per",   "ipg_per",           base + 0x6c, 22);
+       clk[gpu2d_core]   = imx_clk_gate2("gpu2d_core",    "gpu2d_core_podf",   base + 0x6c, 24);
+       clk[gpu3d_core]   = imx_clk_gate2("gpu3d_core",    "gpu3d_core_podf",   base + 0x6c, 26);
+       clk[hdmi_iahb]    = imx_clk_gate2("hdmi_iahb",     "ahb",               base + 0x70, 0);
+       clk[hdmi_isfr]    = imx_clk_gate2("hdmi_isfr",     "pll3_pfd1_540m",    base + 0x70, 4);
+       clk[i2c1]         = imx_clk_gate2("i2c1",          "ipg_per",           base + 0x70, 6);
+       clk[i2c2]         = imx_clk_gate2("i2c2",          "ipg_per",           base + 0x70, 8);
+       clk[i2c3]         = imx_clk_gate2("i2c3",          "ipg_per",           base + 0x70, 10);
+       clk[iim]          = imx_clk_gate2("iim",           "ipg",               base + 0x70, 12);
+       clk[enfc]         = imx_clk_gate2("enfc",          "enfc_podf",         base + 0x70, 14);
+       clk[ipu1]         = imx_clk_gate2("ipu1",          "ipu1_podf",         base + 0x74, 0);
+       clk[ipu1_di0]     = imx_clk_gate2("ipu1_di0",      "ipu1_di0_sel",      base + 0x74, 2);
+       clk[ipu1_di1]     = imx_clk_gate2("ipu1_di1",      "ipu1_di1_sel",      base + 0x74, 4);
+       clk[ipu2]         = imx_clk_gate2("ipu2",          "ipu2_podf",         base + 0x74, 6);
+       clk[ipu2_di0]     = imx_clk_gate2("ipu2_di0",      "ipu2_di0_sel",      base + 0x74, 8);
+       clk[ldb_di0]      = imx_clk_gate2("ldb_di0",       "ldb_di0_podf",      base + 0x74, 12);
+       clk[ldb_di1]      = imx_clk_gate2("ldb_di1",       "ldb_di1_podf",      base + 0x74, 14);
+       clk[ipu2_di1]     = imx_clk_gate2("ipu2_di1",      "ipu2_di1_sel",      base + 0x74, 10);
+       clk[hsi_tx]       = imx_clk_gate2("hsi_tx",        "hsi_tx_podf",       base + 0x74, 16);
+       clk[mlb]          = imx_clk_gate2("mlb",           "pll6_mlb",          base + 0x74, 18);
+       clk[mmdc_ch0_axi] = imx_clk_gate2("mmdc_ch0_axi",  "mmdc_ch0_axi_podf", base + 0x74, 20);
+       clk[mmdc_ch1_axi] = imx_clk_gate2("mmdc_ch1_axi",  "mmdc_ch1_axi_podf", base + 0x74, 22);
+       clk[ocram]        = imx_clk_gate2("ocram",         "ahb",               base + 0x74, 28);
+       clk[openvg_axi]   = imx_clk_gate2("openvg_axi",    "axi",               base + 0x74, 30);
+       clk[pcie_axi]     = imx_clk_gate2("pcie_axi",      "pcie_axi_sel",      base + 0x78, 0);
+       clk[pwm1]         = imx_clk_gate2("pwm1",          "ipg_per",           base + 0x78, 16);
+       clk[pwm2]         = imx_clk_gate2("pwm2",          "ipg_per",           base + 0x78, 18);
+       clk[pwm3]         = imx_clk_gate2("pwm3",          "ipg_per",           base + 0x78, 20);
+       clk[pwm4]         = imx_clk_gate2("pwm4",          "ipg_per",           base + 0x78, 22);
+       clk[gpmi_bch_apb] = imx_clk_gate2("gpmi_bch_apb",  "usdhc3",            base + 0x78, 24);
+       clk[gpmi_bch]     = imx_clk_gate2("gpmi_bch",      "usdhc4",            base + 0x78, 26);
+       clk[gpmi_io]      = imx_clk_gate2("gpmi_io",       "enfc",              base + 0x78, 28);
+       clk[gpmi_apb]     = imx_clk_gate2("gpmi_apb",      "usdhc3",            base + 0x78, 30);
+       clk[sata]         = imx_clk_gate2("sata",          "ipg",               base + 0x7c, 4);
+       clk[sdma]         = imx_clk_gate2("sdma",          "ahb",               base + 0x7c, 6);
+       clk[spba]         = imx_clk_gate2("spba",          "ipg",               base + 0x7c, 12);
+       clk[ssi1]         = imx_clk_gate2("ssi1",          "ssi1_podf",         base + 0x7c, 18);
+       clk[ssi2]         = imx_clk_gate2("ssi2",          "ssi2_podf",         base + 0x7c, 20);
+       clk[ssi3]         = imx_clk_gate2("ssi3",          "ssi3_podf",         base + 0x7c, 22);
+       clk[uart_ipg]     = imx_clk_gate2("uart_ipg",      "ipg",               base + 0x7c, 24);
+       clk[uart_serial]  = imx_clk_gate2("uart_serial",   "uart_serial_podf",  base + 0x7c, 26);
+       clk[usboh3]       = imx_clk_gate2("usboh3",        "ipg",               base + 0x80, 0);
+       clk[usdhc1]       = imx_clk_gate2("usdhc1",        "usdhc1_podf",       base + 0x80, 2);
+       clk[usdhc2]       = imx_clk_gate2("usdhc2",        "usdhc2_podf",       base + 0x80, 4);
+       clk[usdhc3]       = imx_clk_gate2("usdhc3",        "usdhc3_podf",       base + 0x80, 6);
+       clk[usdhc4]       = imx_clk_gate2("usdhc4",        "usdhc4_podf",       base + 0x80, 8);
+       clk[vdo_axi]      = imx_clk_gate2("vdo_axi",       "vdo_axi_sel",       base + 0x80, 12);
+       clk[vpu_axi]      = imx_clk_gate2("vpu_axi",       "vpu_axi_podf",      base + 0x80, 14);
+       clk[cko1]         = imx_clk_gate("cko1",           "cko1_podf",         base + 0x60, 7);
+
+       for (i = 0; i < ARRAY_SIZE(clk); i++)
+               if (IS_ERR(clk[i]))
+                       pr_err("i.MX6q clk %d: register failed with %ld\n",
+                               i, PTR_ERR(clk[i]));
+
+       clk_register_clkdev(clk[mmdc_ch0_axi], NULL, "mmdc_ch0_axi");
+       clk_register_clkdev(clk[mmdc_ch1_axi], NULL, "mmdc_ch1_axi");
+       clk_register_clkdev(clk[gpt_ipg], "ipg", "imx-gpt.0");
+       clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0");
+       clk_register_clkdev(clk[twd], NULL, "smp_twd");
+       clk_register_clkdev(clk[usboh3], NULL, "usboh3");
+       clk_register_clkdev(clk[uart_serial], "per", "2020000.uart");
+       clk_register_clkdev(clk[uart_ipg], "ipg", "2020000.uart");
+       clk_register_clkdev(clk[uart_serial], "per", "21e8000.uart");
+       clk_register_clkdev(clk[uart_ipg], "ipg", "21e8000.uart");
+       clk_register_clkdev(clk[uart_serial], "per", "21ec000.uart");
+       clk_register_clkdev(clk[uart_ipg], "ipg", "21ec000.uart");
+       clk_register_clkdev(clk[uart_serial], "per", "21f0000.uart");
+       clk_register_clkdev(clk[uart_ipg], "ipg", "21f0000.uart");
+       clk_register_clkdev(clk[uart_serial], "per", "21f4000.uart");
+       clk_register_clkdev(clk[uart_ipg], "ipg", "21f4000.uart");
+       clk_register_clkdev(clk[enet], NULL, "2188000.enet");
+       clk_register_clkdev(clk[usdhc1], NULL, "2190000.usdhc");
+       clk_register_clkdev(clk[usdhc2], NULL, "2194000.usdhc");
+       clk_register_clkdev(clk[usdhc3], NULL, "2198000.usdhc");
+       clk_register_clkdev(clk[usdhc4], NULL, "219c000.usdhc");
+       clk_register_clkdev(clk[i2c1], NULL, "21a0000.i2c");
+       clk_register_clkdev(clk[i2c2], NULL, "21a4000.i2c");
+       clk_register_clkdev(clk[i2c3], NULL, "21a8000.i2c");
+       clk_register_clkdev(clk[ecspi1], NULL, "2008000.ecspi");
+       clk_register_clkdev(clk[ecspi2], NULL, "200c000.ecspi");
+       clk_register_clkdev(clk[ecspi3], NULL, "2010000.ecspi");
+       clk_register_clkdev(clk[ecspi4], NULL, "2014000.ecspi");
+       clk_register_clkdev(clk[ecspi5], NULL, "2018000.ecspi");
+       clk_register_clkdev(clk[sdma], NULL, "20ec000.sdma");
+       clk_register_clkdev(clk[dummy], NULL, "20bc000.wdog");
+       clk_register_clkdev(clk[dummy], NULL, "20c0000.wdog");
+
+       for (i = 0; i < ARRAY_SIZE(clks_init_on); i++) {
+               c = clk_get_sys(clks_init_on[i], NULL);
+               if (IS_ERR(c)) {
+                       pr_err("%s: failed to get clk %s", __func__,
+                              clks_init_on[i]);
+                       return PTR_ERR(c);
+               }
+               clk_prepare_enable(c);
+       }
+
+       np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpt");
+       base = of_iomap(np, 0);
+       WARN_ON(!base);
+       irq = irq_of_parse_and_map(np, 0);
+       mxc_timer_init(NULL, base, irq);
+
+       return 0;
+}
diff --git a/arch/arm/mach-imx/clk-pfd.c b/arch/arm/mach-imx/clk-pfd.c
new file mode 100644 (file)
index 0000000..e2ed416
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2012 Linaro Ltd.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include "clk.h"
+
+/**
+ * struct clk_pfd - IMX PFD clock
+ * @clk_hw:    clock source
+ * @reg:       PFD register address
+ * @idx:       the index of PFD encoded in the register
+ *
+ * PFD clock found on i.MX6 series.  Each register for PFD has 4 clk_pfd
+ * data encoded, and member idx is used to specify the one.  And each
+ * register has SET, CLR and TOG registers at offset 0x4 0x8 and 0xc.
+ */
+struct clk_pfd {
+       struct clk_hw   hw;
+       void __iomem    *reg;
+       u8              idx;
+};
+
+#define to_clk_pfd(_hw) container_of(_hw, struct clk_pfd, hw)
+
+#define SET    0x4
+#define CLR    0x8
+#define OTG    0xc
+
+static int clk_pfd_enable(struct clk_hw *hw)
+{
+       struct clk_pfd *pfd = to_clk_pfd(hw);
+
+       writel_relaxed(1 << ((pfd->idx + 1) * 8 - 1), pfd->reg + CLR);
+
+       return 0;
+}
+
+static void clk_pfd_disable(struct clk_hw *hw)
+{
+       struct clk_pfd *pfd = to_clk_pfd(hw);
+
+       writel_relaxed(1 << ((pfd->idx + 1) * 8 - 1), pfd->reg + SET);
+}
+
+static unsigned long clk_pfd_recalc_rate(struct clk_hw *hw,
+                                        unsigned long parent_rate)
+{
+       struct clk_pfd *pfd = to_clk_pfd(hw);
+       u64 tmp = parent_rate;
+       u8 frac = (readl_relaxed(pfd->reg) >> (pfd->idx * 8)) & 0x3f;
+
+       tmp *= 18;
+       do_div(tmp, frac);
+
+       return tmp;
+}
+
+static long clk_pfd_round_rate(struct clk_hw *hw, unsigned long rate,
+                              unsigned long *prate)
+{
+       u64 tmp = *prate;
+       u8 frac;
+
+       tmp = tmp * 18 + rate / 2;
+       do_div(tmp, rate);
+       frac = tmp;
+       if (frac < 12)
+               frac = 12;
+       else if (frac > 35)
+               frac = 35;
+       tmp = *prate;
+       tmp *= 18;
+       do_div(tmp, frac);
+
+       return tmp;
+}
+
+static int clk_pfd_set_rate(struct clk_hw *hw, unsigned long rate,
+               unsigned long parent_rate)
+{
+       struct clk_pfd *pfd = to_clk_pfd(hw);
+       u64 tmp = parent_rate;
+       u8 frac;
+
+       tmp = tmp * 18 + rate / 2;
+       do_div(tmp, rate);
+       frac = tmp;
+       if (frac < 12)
+               frac = 12;
+       else if (frac > 35)
+               frac = 35;
+
+       writel_relaxed(0x3f << (pfd->idx * 8), pfd->reg + CLR);
+       writel_relaxed(frac << (pfd->idx * 8), pfd->reg + SET);
+
+       return 0;
+}
+
+static const struct clk_ops clk_pfd_ops = {
+       .enable         = clk_pfd_enable,
+       .disable        = clk_pfd_disable,
+       .recalc_rate    = clk_pfd_recalc_rate,
+       .round_rate     = clk_pfd_round_rate,
+       .set_rate       = clk_pfd_set_rate,
+};
+
+struct clk *imx_clk_pfd(const char *name, const char *parent_name,
+                       void __iomem *reg, u8 idx)
+{
+       struct clk_pfd *pfd;
+       struct clk *clk;
+       struct clk_init_data init;
+
+       pfd = kzalloc(sizeof(*pfd), GFP_KERNEL);
+       if (!pfd)
+               return ERR_PTR(-ENOMEM);
+
+       pfd->reg = reg;
+       pfd->idx = idx;
+
+       init.name = name;
+       init.ops = &clk_pfd_ops;
+       init.flags = 0;
+       init.parent_names = &parent_name;
+       init.num_parents = 1;
+
+       pfd->hw.init = &init;
+
+       clk = clk_register(NULL, &pfd->hw);
+       if (IS_ERR(clk))
+               kfree(pfd);
+
+       return clk;
+}
diff --git a/arch/arm/mach-imx/clk-pllv1.c b/arch/arm/mach-imx/clk-pllv1.c
new file mode 100644 (file)
index 0000000..2d856f9
--- /dev/null
@@ -0,0 +1,66 @@
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/kernel.h>
+#include <linux/err.h>
+#include <mach/common.h>
+#include <mach/hardware.h>
+#include <mach/clock.h>
+#include "clk.h"
+
+/**
+ * pll v1
+ *
+ * @clk_hw     clock source
+ * @parent     the parent clock name
+ * @base       base address of pll registers
+ *
+ * PLL clock version 1, found on i.MX1/21/25/27/31/35
+ */
+struct clk_pllv1 {
+       struct clk_hw   hw;
+       void __iomem    *base;
+};
+
+#define to_clk_pllv1(clk) (container_of(clk, struct clk_pllv1, clk))
+
+static unsigned long clk_pllv1_recalc_rate(struct clk_hw *hw,
+               unsigned long parent_rate)
+{
+       struct clk_pllv1 *pll = to_clk_pllv1(hw);
+
+       return mxc_decode_pll(readl(pll->base), parent_rate);
+}
+
+struct clk_ops clk_pllv1_ops = {
+       .recalc_rate = clk_pllv1_recalc_rate,
+};
+
+struct clk *imx_clk_pllv1(const char *name, const char *parent,
+               void __iomem *base)
+{
+       struct clk_pllv1 *pll;
+       struct clk *clk;
+       struct clk_init_data init;
+
+       pll = kmalloc(sizeof(*pll), GFP_KERNEL);
+       if (!pll)
+               return ERR_PTR(-ENOMEM);
+
+       pll->base = base;
+
+       init.name = name;
+       init.ops = &clk_pllv1_ops;
+       init.flags = 0;
+       init.parent_names = &parent;
+       init.num_parents = 1;
+
+       pll->hw.init = &init;
+
+       clk = clk_register(NULL, &pll->hw);
+       if (IS_ERR(clk))
+               kfree(pll);
+
+       return clk;
+}
diff --git a/arch/arm/mach-imx/clk-pllv2.c b/arch/arm/mach-imx/clk-pllv2.c
new file mode 100644 (file)
index 0000000..4685919
--- /dev/null
@@ -0,0 +1,249 @@
+#include <linux/kernel.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+
+#include <asm/div64.h>
+
+#include "clk.h"
+
+#define to_clk_pllv2(clk) (container_of(clk, struct clk_pllv2, clk))
+
+/* PLL Register Offsets */
+#define MXC_PLL_DP_CTL                 0x00
+#define MXC_PLL_DP_CONFIG              0x04
+#define MXC_PLL_DP_OP                  0x08
+#define MXC_PLL_DP_MFD                 0x0C
+#define MXC_PLL_DP_MFN                 0x10
+#define MXC_PLL_DP_MFNMINUS            0x14
+#define MXC_PLL_DP_MFNPLUS             0x18
+#define MXC_PLL_DP_HFS_OP              0x1C
+#define MXC_PLL_DP_HFS_MFD             0x20
+#define MXC_PLL_DP_HFS_MFN             0x24
+#define MXC_PLL_DP_MFN_TOGC            0x28
+#define MXC_PLL_DP_DESTAT              0x2c
+
+/* PLL Register Bit definitions */
+#define MXC_PLL_DP_CTL_MUL_CTRL                0x2000
+#define MXC_PLL_DP_CTL_DPDCK0_2_EN     0x1000
+#define MXC_PLL_DP_CTL_DPDCK0_2_OFFSET 12
+#define MXC_PLL_DP_CTL_ADE             0x800
+#define MXC_PLL_DP_CTL_REF_CLK_DIV     0x400
+#define MXC_PLL_DP_CTL_REF_CLK_SEL_MASK        (3 << 8)
+#define MXC_PLL_DP_CTL_REF_CLK_SEL_OFFSET      8
+#define MXC_PLL_DP_CTL_HFSM            0x80
+#define MXC_PLL_DP_CTL_PRE             0x40
+#define MXC_PLL_DP_CTL_UPEN            0x20
+#define MXC_PLL_DP_CTL_RST             0x10
+#define MXC_PLL_DP_CTL_RCP             0x8
+#define MXC_PLL_DP_CTL_PLM             0x4
+#define MXC_PLL_DP_CTL_BRM0            0x2
+#define MXC_PLL_DP_CTL_LRF             0x1
+
+#define MXC_PLL_DP_CONFIG_BIST         0x8
+#define MXC_PLL_DP_CONFIG_SJC_CE       0x4
+#define MXC_PLL_DP_CONFIG_AREN         0x2
+#define MXC_PLL_DP_CONFIG_LDREQ                0x1
+
+#define MXC_PLL_DP_OP_MFI_OFFSET       4
+#define MXC_PLL_DP_OP_MFI_MASK         (0xF << 4)
+#define MXC_PLL_DP_OP_PDF_OFFSET       0
+#define MXC_PLL_DP_OP_PDF_MASK         0xF
+
+#define MXC_PLL_DP_MFD_OFFSET          0
+#define MXC_PLL_DP_MFD_MASK            0x07FFFFFF
+
+#define MXC_PLL_DP_MFN_OFFSET          0x0
+#define MXC_PLL_DP_MFN_MASK            0x07FFFFFF
+
+#define MXC_PLL_DP_MFN_TOGC_TOG_DIS    (1 << 17)
+#define MXC_PLL_DP_MFN_TOGC_TOG_EN     (1 << 16)
+#define MXC_PLL_DP_MFN_TOGC_CNT_OFFSET 0x0
+#define MXC_PLL_DP_MFN_TOGC_CNT_MASK   0xFFFF
+
+#define MXC_PLL_DP_DESTAT_TOG_SEL      (1 << 31)
+#define MXC_PLL_DP_DESTAT_MFN          0x07FFFFFF
+
+#define MAX_DPLL_WAIT_TRIES    1000 /* 1000 * udelay(1) = 1ms */
+
+struct clk_pllv2 {
+       struct clk_hw   hw;
+       void __iomem    *base;
+};
+
+static unsigned long clk_pllv2_recalc_rate(struct clk_hw *hw,
+               unsigned long parent_rate)
+{
+       long mfi, mfn, mfd, pdf, ref_clk, mfn_abs;
+       unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl;
+       void __iomem *pllbase;
+       s64 temp;
+       struct clk_pllv2 *pll = to_clk_pllv2(hw);
+
+       pllbase = pll->base;
+
+       dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+       pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
+       dbl = dp_ctl & MXC_PLL_DP_CTL_DPDCK0_2_EN;
+
+       if (pll_hfsm == 0) {
+               dp_op = __raw_readl(pllbase + MXC_PLL_DP_OP);
+               dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_MFD);
+               dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_MFN);
+       } else {
+               dp_op = __raw_readl(pllbase + MXC_PLL_DP_HFS_OP);
+               dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFD);
+               dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFN);
+       }
+       pdf = dp_op & MXC_PLL_DP_OP_PDF_MASK;
+       mfi = (dp_op & MXC_PLL_DP_OP_MFI_MASK) >> MXC_PLL_DP_OP_MFI_OFFSET;
+       mfi = (mfi <= 5) ? 5 : mfi;
+       mfd = dp_mfd & MXC_PLL_DP_MFD_MASK;
+       mfn = mfn_abs = dp_mfn & MXC_PLL_DP_MFN_MASK;
+       /* Sign extend to 32-bits */
+       if (mfn >= 0x04000000) {
+               mfn |= 0xFC000000;
+               mfn_abs = -mfn;
+       }
+
+       ref_clk = 2 * parent_rate;
+       if (dbl != 0)
+               ref_clk *= 2;
+
+       ref_clk /= (pdf + 1);
+       temp = (u64) ref_clk * mfn_abs;
+       do_div(temp, mfd + 1);
+       if (mfn < 0)
+               temp = -temp;
+       temp = (ref_clk * mfi) + temp;
+
+       return temp;
+}
+
+static int clk_pllv2_set_rate(struct clk_hw *hw, unsigned long rate,
+               unsigned long parent_rate)
+{
+       struct clk_pllv2 *pll = to_clk_pllv2(hw);
+       u32 reg;
+       void __iomem *pllbase;
+       long mfi, pdf, mfn, mfd = 999999;
+       s64 temp64;
+       unsigned long quad_parent_rate;
+       unsigned long pll_hfsm, dp_ctl;
+
+       pllbase = pll->base;
+
+       quad_parent_rate = 4 * parent_rate;
+       pdf = mfi = -1;
+       while (++pdf < 16 && mfi < 5)
+               mfi = rate * (pdf+1) / quad_parent_rate;
+       if (mfi > 15)
+               return -EINVAL;
+       pdf--;
+
+       temp64 = rate * (pdf+1) - quad_parent_rate * mfi;
+       do_div(temp64, quad_parent_rate/1000000);
+       mfn = (long)temp64;
+
+       dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+       /* use dpdck0_2 */
+       __raw_writel(dp_ctl | 0x1000L, pllbase + MXC_PLL_DP_CTL);
+       pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
+       if (pll_hfsm == 0) {
+               reg = mfi << 4 | pdf;
+               __raw_writel(reg, pllbase + MXC_PLL_DP_OP);
+               __raw_writel(mfd, pllbase + MXC_PLL_DP_MFD);
+               __raw_writel(mfn, pllbase + MXC_PLL_DP_MFN);
+       } else {
+               reg = mfi << 4 | pdf;
+               __raw_writel(reg, pllbase + MXC_PLL_DP_HFS_OP);
+               __raw_writel(mfd, pllbase + MXC_PLL_DP_HFS_MFD);
+               __raw_writel(mfn, pllbase + MXC_PLL_DP_HFS_MFN);
+       }
+
+       return 0;
+}
+
+static long clk_pllv2_round_rate(struct clk_hw *hw, unsigned long rate,
+               unsigned long *prate)
+{
+       return rate;
+}
+
+static int clk_pllv2_prepare(struct clk_hw *hw)
+{
+       struct clk_pllv2 *pll = to_clk_pllv2(hw);
+       u32 reg;
+       void __iomem *pllbase;
+       int i = 0;
+
+       pllbase = pll->base;
+       reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) | MXC_PLL_DP_CTL_UPEN;
+       __raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
+
+       /* Wait for lock */
+       do {
+               reg = __raw_readl(pllbase + MXC_PLL_DP_CTL);
+               if (reg & MXC_PLL_DP_CTL_LRF)
+                       break;
+
+               udelay(1);
+       } while (++i < MAX_DPLL_WAIT_TRIES);
+
+       if (i == MAX_DPLL_WAIT_TRIES) {
+               pr_err("MX5: pll locking failed\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static void clk_pllv2_unprepare(struct clk_hw *hw)
+{
+       struct clk_pllv2 *pll = to_clk_pllv2(hw);
+       u32 reg;
+       void __iomem *pllbase;
+
+       pllbase = pll->base;
+       reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) & ~MXC_PLL_DP_CTL_UPEN;
+       __raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
+}
+
+struct clk_ops clk_pllv2_ops = {
+       .prepare = clk_pllv2_prepare,
+       .unprepare = clk_pllv2_unprepare,
+       .recalc_rate = clk_pllv2_recalc_rate,
+       .round_rate = clk_pllv2_round_rate,
+       .set_rate = clk_pllv2_set_rate,
+};
+
+struct clk *imx_clk_pllv2(const char *name, const char *parent,
+               void __iomem *base)
+{
+       struct clk_pllv2 *pll;
+       struct clk *clk;
+       struct clk_init_data init;
+
+       pll = kzalloc(sizeof(*pll), GFP_KERNEL);
+       if (!pll)
+               return ERR_PTR(-ENOMEM);
+
+       pll->base = base;
+
+       init.name = name;
+       init.ops = &clk_pllv2_ops;
+       init.flags = 0;
+       init.parent_names = &parent;
+       init.num_parents = 1;
+
+       pll->hw.init = &init;
+
+       clk = clk_register(NULL, &pll->hw);
+       if (IS_ERR(clk))
+               kfree(pll);
+
+       return clk;
+}
diff --git a/arch/arm/mach-imx/clk-pllv3.c b/arch/arm/mach-imx/clk-pllv3.c
new file mode 100644 (file)
index 0000000..36aac94
--- /dev/null
@@ -0,0 +1,419 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2012 Linaro Ltd.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/jiffies.h>
+#include <linux/err.h>
+#include "clk.h"
+
+#define PLL_NUM_OFFSET         0x10
+#define PLL_DENOM_OFFSET       0x20
+
+#define BM_PLL_POWER           (0x1 << 12)
+#define BM_PLL_ENABLE          (0x1 << 13)
+#define BM_PLL_BYPASS          (0x1 << 16)
+#define BM_PLL_LOCK            (0x1 << 31)
+
+/**
+ * struct clk_pllv3 - IMX PLL clock version 3
+ * @clk_hw:     clock source
+ * @base:       base address of PLL registers
+ * @powerup_set: set POWER bit to power up the PLL
+ * @gate_mask:  mask of gate bits
+ * @div_mask:   mask of divider bits
+ *
+ * IMX PLL clock version 3, found on i.MX6 series.  Divider for pllv3
+ * is actually a multiplier, and always sits at bit 0.
+ */
+struct clk_pllv3 {
+       struct clk_hw   hw;
+       void __iomem    *base;
+       bool            powerup_set;
+       u32             gate_mask;
+       u32             div_mask;
+};
+
+#define to_clk_pllv3(_hw) container_of(_hw, struct clk_pllv3, hw)
+
+static int clk_pllv3_prepare(struct clk_hw *hw)
+{
+       struct clk_pllv3 *pll = to_clk_pllv3(hw);
+       unsigned long timeout = jiffies + msecs_to_jiffies(10);
+       u32 val;
+
+       val = readl_relaxed(pll->base);
+       val &= ~BM_PLL_BYPASS;
+       if (pll->powerup_set)
+               val |= BM_PLL_POWER;
+       else
+               val &= ~BM_PLL_POWER;
+       writel_relaxed(val, pll->base);
+
+       /* Wait for PLL to lock */
+       while (!(readl_relaxed(pll->base) & BM_PLL_LOCK))
+               if (time_after(jiffies, timeout))
+                       return -ETIMEDOUT;
+
+       return 0;
+}
+
+static void clk_pllv3_unprepare(struct clk_hw *hw)
+{
+       struct clk_pllv3 *pll = to_clk_pllv3(hw);
+       u32 val;
+
+       val = readl_relaxed(pll->base);
+       val |= BM_PLL_BYPASS;
+       if (pll->powerup_set)
+               val &= ~BM_PLL_POWER;
+       else
+               val |= BM_PLL_POWER;
+       writel_relaxed(val, pll->base);
+}
+
+static int clk_pllv3_enable(struct clk_hw *hw)
+{
+       struct clk_pllv3 *pll = to_clk_pllv3(hw);
+       u32 val;
+
+       val = readl_relaxed(pll->base);
+       val |= pll->gate_mask;
+       writel_relaxed(val, pll->base);
+
+       return 0;
+}
+
+static void clk_pllv3_disable(struct clk_hw *hw)
+{
+       struct clk_pllv3 *pll = to_clk_pllv3(hw);
+       u32 val;
+
+       val = readl_relaxed(pll->base);
+       val &= ~pll->gate_mask;
+       writel_relaxed(val, pll->base);
+}
+
+static unsigned long clk_pllv3_recalc_rate(struct clk_hw *hw,
+                                          unsigned long parent_rate)
+{
+       struct clk_pllv3 *pll = to_clk_pllv3(hw);
+       u32 div = readl_relaxed(pll->base)  & pll->div_mask;
+
+       return (div == 1) ? parent_rate * 22 : parent_rate * 20;
+}
+
+static long clk_pllv3_round_rate(struct clk_hw *hw, unsigned long rate,
+                                unsigned long *prate)
+{
+       unsigned long parent_rate = *prate;
+
+       return (rate >= parent_rate * 22) ? parent_rate * 22 :
+                                           parent_rate * 20;
+}
+
+static int clk_pllv3_set_rate(struct clk_hw *hw, unsigned long rate,
+               unsigned long parent_rate)
+{
+       struct clk_pllv3 *pll = to_clk_pllv3(hw);
+       u32 val, div;
+
+       if (rate == parent_rate * 22)
+               div = 1;
+       else if (rate == parent_rate * 20)
+               div = 0;
+       else
+               return -EINVAL;
+
+       val = readl_relaxed(pll->base);
+       val &= ~pll->div_mask;
+       val |= div;
+       writel_relaxed(val, pll->base);
+
+       return 0;
+}
+
+static const struct clk_ops clk_pllv3_ops = {
+       .prepare        = clk_pllv3_prepare,
+       .unprepare      = clk_pllv3_unprepare,
+       .enable         = clk_pllv3_enable,
+       .disable        = clk_pllv3_disable,
+       .recalc_rate    = clk_pllv3_recalc_rate,
+       .round_rate     = clk_pllv3_round_rate,
+       .set_rate       = clk_pllv3_set_rate,
+};
+
+static unsigned long clk_pllv3_sys_recalc_rate(struct clk_hw *hw,
+                                              unsigned long parent_rate)
+{
+       struct clk_pllv3 *pll = to_clk_pllv3(hw);
+       u32 div = readl_relaxed(pll->base) & pll->div_mask;
+
+       return parent_rate * div / 2;
+}
+
+static long clk_pllv3_sys_round_rate(struct clk_hw *hw, unsigned long rate,
+                                    unsigned long *prate)
+{
+       unsigned long parent_rate = *prate;
+       unsigned long min_rate = parent_rate * 54 / 2;
+       unsigned long max_rate = parent_rate * 108 / 2;
+       u32 div;
+
+       if (rate > max_rate)
+               rate = max_rate;
+       else if (rate < min_rate)
+               rate = min_rate;
+       div = rate * 2 / parent_rate;
+
+       return parent_rate * div / 2;
+}
+
+static int clk_pllv3_sys_set_rate(struct clk_hw *hw, unsigned long rate,
+               unsigned long parent_rate)
+{
+       struct clk_pllv3 *pll = to_clk_pllv3(hw);
+       unsigned long min_rate = parent_rate * 54 / 2;
+       unsigned long max_rate = parent_rate * 108 / 2;
+       u32 val, div;
+
+       if (rate < min_rate || rate > max_rate)
+               return -EINVAL;
+
+       div = rate * 2 / parent_rate;
+       val = readl_relaxed(pll->base);
+       val &= ~pll->div_mask;
+       val |= div;
+       writel_relaxed(val, pll->base);
+
+       return 0;
+}
+
+static const struct clk_ops clk_pllv3_sys_ops = {
+       .prepare        = clk_pllv3_prepare,
+       .unprepare      = clk_pllv3_unprepare,
+       .enable         = clk_pllv3_enable,
+       .disable        = clk_pllv3_disable,
+       .recalc_rate    = clk_pllv3_sys_recalc_rate,
+       .round_rate     = clk_pllv3_sys_round_rate,
+       .set_rate       = clk_pllv3_sys_set_rate,
+};
+
+static unsigned long clk_pllv3_av_recalc_rate(struct clk_hw *hw,
+                                             unsigned long parent_rate)
+{
+       struct clk_pllv3 *pll = to_clk_pllv3(hw);
+       u32 mfn = readl_relaxed(pll->base + PLL_NUM_OFFSET);
+       u32 mfd = readl_relaxed(pll->base + PLL_DENOM_OFFSET);
+       u32 div = readl_relaxed(pll->base) & pll->div_mask;
+
+       return (parent_rate * div) + ((parent_rate / mfd) * mfn);
+}
+
+static long clk_pllv3_av_round_rate(struct clk_hw *hw, unsigned long rate,
+                                   unsigned long *prate)
+{
+       unsigned long parent_rate = *prate;
+       unsigned long min_rate = parent_rate * 27;
+       unsigned long max_rate = parent_rate * 54;
+       u32 div;
+       u32 mfn, mfd = 1000000;
+       s64 temp64;
+
+       if (rate > max_rate)
+               rate = max_rate;
+       else if (rate < min_rate)
+               rate = min_rate;
+
+       div = rate / parent_rate;
+       temp64 = (u64) (rate - div * parent_rate);
+       temp64 *= mfd;
+       do_div(temp64, parent_rate);
+       mfn = temp64;
+
+       return parent_rate * div + parent_rate / mfd * mfn;
+}
+
+static int clk_pllv3_av_set_rate(struct clk_hw *hw, unsigned long rate,
+               unsigned long parent_rate)
+{
+       struct clk_pllv3 *pll = to_clk_pllv3(hw);
+       unsigned long min_rate = parent_rate * 27;
+       unsigned long max_rate = parent_rate * 54;
+       u32 val, div;
+       u32 mfn, mfd = 1000000;
+       s64 temp64;
+
+       if (rate < min_rate || rate > max_rate)
+               return -EINVAL;
+
+       div = rate / parent_rate;
+       temp64 = (u64) (rate - div * parent_rate);
+       temp64 *= mfd;
+       do_div(temp64, parent_rate);
+       mfn = temp64;
+
+       val = readl_relaxed(pll->base);
+       val &= ~pll->div_mask;
+       val |= div;
+       writel_relaxed(val, pll->base);
+       writel_relaxed(mfn, pll->base + PLL_NUM_OFFSET);
+       writel_relaxed(mfd, pll->base + PLL_DENOM_OFFSET);
+
+       return 0;
+}
+
+static const struct clk_ops clk_pllv3_av_ops = {
+       .prepare        = clk_pllv3_prepare,
+       .unprepare      = clk_pllv3_unprepare,
+       .enable         = clk_pllv3_enable,
+       .disable        = clk_pllv3_disable,
+       .recalc_rate    = clk_pllv3_av_recalc_rate,
+       .round_rate     = clk_pllv3_av_round_rate,
+       .set_rate       = clk_pllv3_av_set_rate,
+};
+
+static unsigned long clk_pllv3_enet_recalc_rate(struct clk_hw *hw,
+                                               unsigned long parent_rate)
+{
+       struct clk_pllv3 *pll = to_clk_pllv3(hw);
+       u32 div = readl_relaxed(pll->base) & pll->div_mask;
+
+       switch (div) {
+       case 0:
+               return 25000000;
+       case 1:
+               return 50000000;
+       case 2:
+               return 100000000;
+       case 3:
+               return 125000000;
+       }
+
+       return 0;
+}
+
+static long clk_pllv3_enet_round_rate(struct clk_hw *hw, unsigned long rate,
+                                     unsigned long *prate)
+{
+       if (rate >= 125000000)
+               rate = 125000000;
+       else if (rate >= 100000000)
+               rate = 100000000;
+       else if (rate >= 50000000)
+               rate = 50000000;
+       else
+               rate = 25000000;
+       return rate;
+}
+
+static int clk_pllv3_enet_set_rate(struct clk_hw *hw, unsigned long rate,
+               unsigned long parent_rate)
+{
+       struct clk_pllv3 *pll = to_clk_pllv3(hw);
+       u32 val, div;
+
+       switch (rate) {
+       case 25000000:
+               div = 0;
+               break;
+       case 50000000:
+               div = 1;
+               break;
+       case 100000000:
+               div = 2;
+               break;
+       case 125000000:
+               div = 3;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       val = readl_relaxed(pll->base);
+       val &= ~pll->div_mask;
+       val |= div;
+       writel_relaxed(val, pll->base);
+
+       return 0;
+}
+
+static const struct clk_ops clk_pllv3_enet_ops = {
+       .prepare        = clk_pllv3_prepare,
+       .unprepare      = clk_pllv3_unprepare,
+       .enable         = clk_pllv3_enable,
+       .disable        = clk_pllv3_disable,
+       .recalc_rate    = clk_pllv3_enet_recalc_rate,
+       .round_rate     = clk_pllv3_enet_round_rate,
+       .set_rate       = clk_pllv3_enet_set_rate,
+};
+
+static const struct clk_ops clk_pllv3_mlb_ops = {
+       .prepare        = clk_pllv3_prepare,
+       .unprepare      = clk_pllv3_unprepare,
+       .enable         = clk_pllv3_enable,
+       .disable        = clk_pllv3_disable,
+};
+
+struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
+                         const char *parent_name, void __iomem *base,
+                         u32 gate_mask, u32 div_mask)
+{
+       struct clk_pllv3 *pll;
+       const struct clk_ops *ops;
+       struct clk *clk;
+       struct clk_init_data init;
+
+       pll = kzalloc(sizeof(*pll), GFP_KERNEL);
+       if (!pll)
+               return ERR_PTR(-ENOMEM);
+
+       switch (type) {
+       case IMX_PLLV3_SYS:
+               ops = &clk_pllv3_sys_ops;
+               break;
+       case IMX_PLLV3_USB:
+               ops = &clk_pllv3_ops;
+               pll->powerup_set = true;
+               break;
+       case IMX_PLLV3_AV:
+               ops = &clk_pllv3_av_ops;
+               break;
+       case IMX_PLLV3_ENET:
+               ops = &clk_pllv3_enet_ops;
+               break;
+       case IMX_PLLV3_MLB:
+               ops = &clk_pllv3_mlb_ops;
+               break;
+       default:
+               ops = &clk_pllv3_ops;
+       }
+       pll->base = base;
+       pll->gate_mask = gate_mask;
+       pll->div_mask = div_mask;
+
+       init.name = name;
+       init.ops = ops;
+       init.flags = 0;
+       init.parent_names = &parent_name;
+       init.num_parents = 1;
+
+       pll->hw.init = &init;
+
+       clk = clk_register(NULL, &pll->hw);
+       if (IS_ERR(clk))
+               kfree(pll);
+
+       return clk;
+}
diff --git a/arch/arm/mach-imx/clk.h b/arch/arm/mach-imx/clk.h
new file mode 100644 (file)
index 0000000..1bf64fe
--- /dev/null
@@ -0,0 +1,83 @@
+#ifndef __MACH_IMX_CLK_H
+#define __MACH_IMX_CLK_H
+
+#include <linux/spinlock.h>
+#include <linux/clk-provider.h>
+#include <mach/clock.h>
+
+struct clk *imx_clk_pllv1(const char *name, const char *parent,
+               void __iomem *base);
+
+struct clk *imx_clk_pllv2(const char *name, const char *parent,
+               void __iomem *base);
+
+enum imx_pllv3_type {
+       IMX_PLLV3_GENERIC,
+       IMX_PLLV3_SYS,
+       IMX_PLLV3_USB,
+       IMX_PLLV3_AV,
+       IMX_PLLV3_ENET,
+       IMX_PLLV3_MLB,
+};
+
+struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
+               const char *parent_name, void __iomem *base, u32 gate_mask,
+               u32 div_mask);
+
+struct clk *clk_register_gate2(struct device *dev, const char *name,
+               const char *parent_name, unsigned long flags,
+               void __iomem *reg, u8 bit_idx,
+               u8 clk_gate_flags, spinlock_t *lock);
+
+static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
+               void __iomem *reg, u8 shift)
+{
+       return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
+                       shift, 0, &imx_ccm_lock);
+}
+
+struct clk *imx_clk_pfd(const char *name, const char *parent_name,
+               void __iomem *reg, u8 idx);
+
+struct clk *imx_clk_busy_divider(const char *name, const char *parent_name,
+                                void __iomem *reg, u8 shift, u8 width,
+                                void __iomem *busy_reg, u8 busy_shift);
+
+struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift,
+                            u8 width, void __iomem *busy_reg, u8 busy_shift,
+                            const char **parent_names, int num_parents);
+
+static inline struct clk *imx_clk_fixed(const char *name, int rate)
+{
+       return clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
+}
+
+static inline struct clk *imx_clk_divider(const char *name, const char *parent,
+               void __iomem *reg, u8 shift, u8 width)
+{
+       return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
+                       reg, shift, width, 0, &imx_ccm_lock);
+}
+
+static inline struct clk *imx_clk_gate(const char *name, const char *parent,
+               void __iomem *reg, u8 shift)
+{
+       return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
+                       shift, 0, &imx_ccm_lock);
+}
+
+static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
+               u8 shift, u8 width, const char **parents, int num_parents)
+{
+       return clk_register_mux(NULL, name, parents, num_parents, 0, reg, shift,
+                       width, 0, &imx_ccm_lock);
+}
+
+static inline struct clk *imx_clk_fixed_factor(const char *name,
+               const char *parent, unsigned int mult, unsigned int div)
+{
+       return clk_register_fixed_factor(NULL, name, parent,
+                       CLK_SET_RATE_PARENT, mult, div);
+}
+
+#endif
diff --git a/arch/arm/mach-imx/clock-imx1.c b/arch/arm/mach-imx/clock-imx1.c
deleted file mode 100644 (file)
index 4aabeb2..0000000
+++ /dev/null
@@ -1,636 +0,0 @@
-/*
- *  Copyright (C) 2008 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/list.h>
-#include <linux/math64.h>
-#include <linux/err.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/clkdev.h>
-
-#include <mach/clock.h>
-#include <mach/hardware.h>
-#include <mach/common.h>
-
-#define IO_ADDR_CCM(off)       (MX1_IO_ADDRESS(MX1_CCM_BASE_ADDR + (off)))
-
-/* CCM register addresses */
-#define CCM_CSCR       IO_ADDR_CCM(0x0)
-#define CCM_MPCTL0     IO_ADDR_CCM(0x4)
-#define CCM_SPCTL0     IO_ADDR_CCM(0xc)
-#define CCM_PCDR       IO_ADDR_CCM(0x20)
-
-#define CCM_CSCR_CLKO_OFFSET   29
-#define CCM_CSCR_CLKO_MASK     (0x7 << 29)
-#define CCM_CSCR_USB_OFFSET    26
-#define CCM_CSCR_USB_MASK      (0x7 << 26)
-#define CCM_CSCR_OSC_EN_SHIFT  17
-#define CCM_CSCR_SYSTEM_SEL    (1 << 16)
-#define CCM_CSCR_BCLK_OFFSET   10
-#define CCM_CSCR_BCLK_MASK     (0xf << 10)
-#define CCM_CSCR_PRESC         (1 << 15)
-
-#define CCM_PCDR_PCLK3_OFFSET  16
-#define CCM_PCDR_PCLK3_MASK    (0x7f << 16)
-#define CCM_PCDR_PCLK2_OFFSET  4
-#define CCM_PCDR_PCLK2_MASK    (0xf << 4)
-#define CCM_PCDR_PCLK1_OFFSET  0
-#define CCM_PCDR_PCLK1_MASK    0xf
-
-#define IO_ADDR_SCM(off)       (MX1_IO_ADDRESS(MX1_SCM_BASE_ADDR + (off)))
-
-/* SCM register addresses */
-#define SCM_GCCR       IO_ADDR_SCM(0xc)
-
-#define SCM_GCCR_DMA_CLK_EN_OFFSET     3
-#define SCM_GCCR_CSI_CLK_EN_OFFSET     2
-#define SCM_GCCR_MMA_CLK_EN_OFFSET     1
-#define SCM_GCCR_USBD_CLK_EN_OFFSET    0
-
-static int _clk_enable(struct clk *clk)
-{
-       unsigned int reg;
-
-       reg = __raw_readl(clk->enable_reg);
-       reg |= 1 << clk->enable_shift;
-       __raw_writel(reg, clk->enable_reg);
-
-       return 0;
-}
-
-static void _clk_disable(struct clk *clk)
-{
-       unsigned int reg;
-
-       reg = __raw_readl(clk->enable_reg);
-       reg &= ~(1 << clk->enable_shift);
-       __raw_writel(reg, clk->enable_reg);
-}
-
-static int _clk_can_use_parent(const struct clk *clk_arr[], unsigned int size,
-                              struct clk *parent)
-{
-       int i;
-
-       for (i = 0; i < size; i++)
-               if (parent == clk_arr[i])
-                       return i;
-
-       return -EINVAL;
-}
-
-static unsigned long
-_clk_simple_round_rate(struct clk *clk, unsigned long rate, unsigned int limit)
-{
-       int div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-       if (parent_rate % rate)
-               div++;
-
-       if (div > limit)
-               div = limit;
-
-       return parent_rate / div;
-}
-
-static unsigned long _clk_parent_round_rate(struct clk *clk, unsigned long rate)
-{
-       return clk->parent->round_rate(clk->parent, rate);
-}
-
-static int _clk_parent_set_rate(struct clk *clk, unsigned long rate)
-{
-       return clk->parent->set_rate(clk->parent, rate);
-}
-
-static unsigned long clk16m_get_rate(struct clk *clk)
-{
-       return 16000000;
-}
-
-static struct clk clk16m = {
-       .get_rate = clk16m_get_rate,
-       .enable = _clk_enable,
-       .enable_reg = CCM_CSCR,
-       .enable_shift = CCM_CSCR_OSC_EN_SHIFT,
-       .disable = _clk_disable,
-};
-
-/* in Hz */
-static unsigned long clk32_rate;
-
-static unsigned long clk32_get_rate(struct clk *clk)
-{
-       return clk32_rate;
-}
-
-static struct clk clk32 = {
-       .get_rate = clk32_get_rate,
-};
-
-static unsigned long clk32_premult_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) * 512;
-}
-
-static struct clk clk32_premult = {
-       .parent = &clk32,
-       .get_rate = clk32_premult_get_rate,
-};
-
-static const struct clk *prem_clk_clocks[] = {
-       &clk32_premult,
-       &clk16m,
-};
-
-static int prem_clk_set_parent(struct clk *clk, struct clk *parent)
-{
-       int i;
-       unsigned int reg = __raw_readl(CCM_CSCR);
-
-       i = _clk_can_use_parent(prem_clk_clocks, ARRAY_SIZE(prem_clk_clocks),
-                               parent);
-
-       switch (i) {
-       case 0:
-               reg &= ~CCM_CSCR_SYSTEM_SEL;
-               break;
-       case 1:
-               reg |= CCM_CSCR_SYSTEM_SEL;
-               break;
-       default:
-               return i;
-       }
-
-       __raw_writel(reg, CCM_CSCR);
-
-       return 0;
-}
-
-static struct clk prem_clk = {
-       .set_parent = prem_clk_set_parent,
-};
-
-static unsigned long system_clk_get_rate(struct clk *clk)
-{
-       return mxc_decode_pll(__raw_readl(CCM_SPCTL0),
-                             clk_get_rate(clk->parent));
-}
-
-static struct clk system_clk = {
-       .parent = &prem_clk,
-       .get_rate = system_clk_get_rate,
-};
-
-static unsigned long mcu_clk_get_rate(struct clk *clk)
-{
-       return mxc_decode_pll(__raw_readl(CCM_MPCTL0),
-                             clk_get_rate(clk->parent));
-}
-
-static struct clk mcu_clk = {
-       .parent = &clk32_premult,
-       .get_rate = mcu_clk_get_rate,
-};
-
-static unsigned long fclk_get_rate(struct clk *clk)
-{
-       unsigned long fclk = clk_get_rate(clk->parent);
-
-       if (__raw_readl(CCM_CSCR) & CCM_CSCR_PRESC)
-               fclk /= 2;
-
-       return fclk;
-}
-
-static struct clk fclk = {
-       .parent = &mcu_clk,
-       .get_rate = fclk_get_rate,
-};
-
-/*
- *  get hclk ( SDRAM, CSI, Memory Stick, I2C, DMA )
- */
-static unsigned long hclk_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / (((__raw_readl(CCM_CSCR) &
-                       CCM_CSCR_BCLK_MASK) >> CCM_CSCR_BCLK_OFFSET) + 1);
-}
-
-static unsigned long hclk_round_rate(struct clk *clk, unsigned long rate)
-{
-       return _clk_simple_round_rate(clk, rate, 16);
-}
-
-static int hclk_set_rate(struct clk *clk, unsigned long rate)
-{
-       unsigned int div;
-       unsigned int reg;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-
-       if (div > 16 || div < 1 || ((parent_rate / div) != rate))
-               return -EINVAL;
-
-       div--;
-
-       reg = __raw_readl(CCM_CSCR);
-       reg &= ~CCM_CSCR_BCLK_MASK;
-       reg |= div << CCM_CSCR_BCLK_OFFSET;
-       __raw_writel(reg, CCM_CSCR);
-
-       return 0;
-}
-
-static struct clk hclk = {
-       .parent = &system_clk,
-       .get_rate = hclk_get_rate,
-       .round_rate = hclk_round_rate,
-       .set_rate = hclk_set_rate,
-};
-
-static unsigned long clk48m_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / (((__raw_readl(CCM_CSCR) &
-                       CCM_CSCR_USB_MASK) >> CCM_CSCR_USB_OFFSET) + 1);
-}
-
-static unsigned long clk48m_round_rate(struct clk *clk, unsigned long rate)
-{
-       return _clk_simple_round_rate(clk, rate, 8);
-}
-
-static int clk48m_set_rate(struct clk *clk, unsigned long rate)
-{
-       unsigned int div;
-       unsigned int reg;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-
-       if (div > 8 || div < 1 || ((parent_rate / div) != rate))
-               return -EINVAL;
-
-       div--;
-
-       reg = __raw_readl(CCM_CSCR);
-       reg &= ~CCM_CSCR_USB_MASK;
-       reg |= div << CCM_CSCR_USB_OFFSET;
-       __raw_writel(reg, CCM_CSCR);
-
-       return 0;
-}
-
-static struct clk clk48m = {
-       .parent = &system_clk,
-       .get_rate = clk48m_get_rate,
-       .round_rate = clk48m_round_rate,
-       .set_rate = clk48m_set_rate,
-};
-
-/*
- *  get peripheral clock 1 ( UART[12], Timer[12], PWM )
- */
-static unsigned long perclk1_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / (((__raw_readl(CCM_PCDR) &
-                       CCM_PCDR_PCLK1_MASK) >> CCM_PCDR_PCLK1_OFFSET) + 1);
-}
-
-static unsigned long perclk1_round_rate(struct clk *clk, unsigned long rate)
-{
-       return _clk_simple_round_rate(clk, rate, 16);
-}
-
-static int perclk1_set_rate(struct clk *clk, unsigned long rate)
-{
-       unsigned int div;
-       unsigned int reg;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-
-       if (div > 16 || div < 1 || ((parent_rate / div) != rate))
-               return -EINVAL;
-
-       div--;
-
-       reg = __raw_readl(CCM_PCDR);
-       reg &= ~CCM_PCDR_PCLK1_MASK;
-       reg |= div << CCM_PCDR_PCLK1_OFFSET;
-       __raw_writel(reg, CCM_PCDR);
-
-       return 0;
-}
-
-/*
- *  get peripheral clock 2 ( LCD, SD, SPI[12] )
- */
-static unsigned long perclk2_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / (((__raw_readl(CCM_PCDR) &
-                       CCM_PCDR_PCLK2_MASK) >> CCM_PCDR_PCLK2_OFFSET) + 1);
-}
-
-static unsigned long perclk2_round_rate(struct clk *clk, unsigned long rate)
-{
-       return _clk_simple_round_rate(clk, rate, 16);
-}
-
-static int perclk2_set_rate(struct clk *clk, unsigned long rate)
-{
-       unsigned int div;
-       unsigned int reg;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-
-       if (div > 16 || div < 1 || ((parent_rate / div) != rate))
-               return -EINVAL;
-
-       div--;
-
-       reg = __raw_readl(CCM_PCDR);
-       reg &= ~CCM_PCDR_PCLK2_MASK;
-       reg |= div << CCM_PCDR_PCLK2_OFFSET;
-       __raw_writel(reg, CCM_PCDR);
-
-       return 0;
-}
-
-/*
- *  get peripheral clock 3 ( SSI )
- */
-static unsigned long perclk3_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / (((__raw_readl(CCM_PCDR) &
-                       CCM_PCDR_PCLK3_MASK) >> CCM_PCDR_PCLK3_OFFSET) + 1);
-}
-
-static unsigned long perclk3_round_rate(struct clk *clk, unsigned long rate)
-{
-       return _clk_simple_round_rate(clk, rate, 128);
-}
-
-static int perclk3_set_rate(struct clk *clk, unsigned long rate)
-{
-       unsigned int div;
-       unsigned int reg;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-
-       if (div > 128 || div < 1 || ((parent_rate / div) != rate))
-               return -EINVAL;
-
-       div--;
-
-       reg = __raw_readl(CCM_PCDR);
-       reg &= ~CCM_PCDR_PCLK3_MASK;
-       reg |= div << CCM_PCDR_PCLK3_OFFSET;
-       __raw_writel(reg, CCM_PCDR);
-
-       return 0;
-}
-
-static struct clk perclk[] = {
-       {
-               .id = 0,
-               .parent = &system_clk,
-               .get_rate = perclk1_get_rate,
-               .round_rate = perclk1_round_rate,
-               .set_rate = perclk1_set_rate,
-       }, {
-               .id = 1,
-               .parent = &system_clk,
-               .get_rate = perclk2_get_rate,
-               .round_rate = perclk2_round_rate,
-               .set_rate = perclk2_set_rate,
-       }, {
-               .id = 2,
-               .parent = &system_clk,
-               .get_rate = perclk3_get_rate,
-               .round_rate = perclk3_round_rate,
-               .set_rate = perclk3_set_rate,
-       }
-};
-
-static const struct clk *clko_clocks[] = {
-       &perclk[0],
-       &hclk,
-       &clk48m,
-       &clk16m,
-       &prem_clk,
-       &fclk,
-};
-
-static int clko_set_parent(struct clk *clk, struct clk *parent)
-{
-       int i;
-       unsigned int reg;
-
-       i = _clk_can_use_parent(clko_clocks, ARRAY_SIZE(clko_clocks), parent);
-       if (i < 0)
-               return i;
-
-       reg = __raw_readl(CCM_CSCR) & ~CCM_CSCR_CLKO_MASK;
-       reg |= i << CCM_CSCR_CLKO_OFFSET;
-       __raw_writel(reg, CCM_CSCR);
-
-       if (clko_clocks[i]->set_rate && clko_clocks[i]->round_rate) {
-               clk->set_rate = _clk_parent_set_rate;
-               clk->round_rate = _clk_parent_round_rate;
-       } else {
-               clk->set_rate = NULL;
-               clk->round_rate = NULL;
-       }
-
-       return 0;
-}
-
-static struct clk clko_clk = {
-       .set_parent = clko_set_parent,
-};
-
-static struct clk dma_clk = {
-       .parent = &hclk,
-       .round_rate = _clk_parent_round_rate,
-       .set_rate = _clk_parent_set_rate,
-       .enable = _clk_enable,
-       .enable_reg = SCM_GCCR,
-       .enable_shift = SCM_GCCR_DMA_CLK_EN_OFFSET,
-       .disable = _clk_disable,
-};
-
-static struct clk csi_clk = {
-       .parent = &hclk,
-       .round_rate = _clk_parent_round_rate,
-       .set_rate = _clk_parent_set_rate,
-       .enable = _clk_enable,
-       .enable_reg = SCM_GCCR,
-       .enable_shift = SCM_GCCR_CSI_CLK_EN_OFFSET,
-       .disable = _clk_disable,
-};
-
-static struct clk mma_clk = {
-       .parent = &hclk,
-       .round_rate = _clk_parent_round_rate,
-       .set_rate = _clk_parent_set_rate,
-       .enable = _clk_enable,
-       .enable_reg = SCM_GCCR,
-       .enable_shift = SCM_GCCR_MMA_CLK_EN_OFFSET,
-       .disable = _clk_disable,
-};
-
-static struct clk usbd_clk = {
-       .parent = &clk48m,
-       .round_rate = _clk_parent_round_rate,
-       .set_rate = _clk_parent_set_rate,
-       .enable = _clk_enable,
-       .enable_reg = SCM_GCCR,
-       .enable_shift = SCM_GCCR_USBD_CLK_EN_OFFSET,
-       .disable = _clk_disable,
-};
-
-static struct clk gpt_clk = {
-       .parent = &perclk[0],
-       .round_rate = _clk_parent_round_rate,
-       .set_rate = _clk_parent_set_rate,
-};
-
-static struct clk uart_clk = {
-       .parent = &perclk[0],
-       .round_rate = _clk_parent_round_rate,
-       .set_rate = _clk_parent_set_rate,
-};
-
-static struct clk i2c_clk = {
-       .parent = &hclk,
-       .round_rate = _clk_parent_round_rate,
-       .set_rate = _clk_parent_set_rate,
-};
-
-static struct clk spi_clk = {
-       .parent = &perclk[1],
-       .round_rate = _clk_parent_round_rate,
-       .set_rate = _clk_parent_set_rate,
-};
-
-static struct clk sdhc_clk = {
-       .parent = &perclk[1],
-       .round_rate = _clk_parent_round_rate,
-       .set_rate = _clk_parent_set_rate,
-};
-
-static struct clk lcdc_clk = {
-       .parent = &perclk[1],
-       .round_rate = _clk_parent_round_rate,
-       .set_rate = _clk_parent_set_rate,
-};
-
-static struct clk mshc_clk = {
-       .parent = &hclk,
-       .round_rate = _clk_parent_round_rate,
-       .set_rate = _clk_parent_set_rate,
-};
-
-static struct clk ssi_clk = {
-       .parent = &perclk[2],
-       .round_rate = _clk_parent_round_rate,
-       .set_rate = _clk_parent_set_rate,
-};
-
-static struct clk rtc_clk = {
-       .parent = &clk32,
-};
-
-#define _REGISTER_CLOCK(d, n, c) \
-       { \
-               .dev_id = d, \
-               .con_id = n, \
-               .clk = &c, \
-       },
-static struct clk_lookup lookups[] __initdata = {
-       _REGISTER_CLOCK(NULL, "dma", dma_clk)
-       _REGISTER_CLOCK("mx1-camera.0", NULL, csi_clk)
-       _REGISTER_CLOCK(NULL, "mma", mma_clk)
-       _REGISTER_CLOCK("imx_udc.0", NULL, usbd_clk)
-       _REGISTER_CLOCK(NULL, "gpt", gpt_clk)
-       _REGISTER_CLOCK("imx1-uart.0", NULL, uart_clk)
-       _REGISTER_CLOCK("imx1-uart.1", NULL, uart_clk)
-       _REGISTER_CLOCK("imx1-uart.2", NULL, uart_clk)
-       _REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk)
-       _REGISTER_CLOCK("imx1-cspi.0", NULL, spi_clk)
-       _REGISTER_CLOCK("imx1-cspi.1", NULL, spi_clk)
-       _REGISTER_CLOCK("imx-mmc.0", NULL, sdhc_clk)
-       _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk)
-       _REGISTER_CLOCK(NULL, "mshc", mshc_clk)
-       _REGISTER_CLOCK(NULL, "ssi", ssi_clk)
-       _REGISTER_CLOCK("mxc_rtc.0", NULL, rtc_clk)
-};
-
-int __init mx1_clocks_init(unsigned long fref)
-{
-       unsigned int reg;
-
-       /* disable clocks we are able to */
-       __raw_writel(0, SCM_GCCR);
-
-       clk32_rate = fref;
-       reg = __raw_readl(CCM_CSCR);
-
-       /* detect clock reference for system PLL */
-       if (reg & CCM_CSCR_SYSTEM_SEL) {
-               prem_clk.parent = &clk16m;
-       } else {
-               /* ensure that oscillator is disabled */
-               reg &= ~(1 << CCM_CSCR_OSC_EN_SHIFT);
-               __raw_writel(reg, CCM_CSCR);
-               prem_clk.parent = &clk32_premult;
-       }
-
-       /* detect reference for CLKO */
-       reg = (reg & CCM_CSCR_CLKO_MASK) >> CCM_CSCR_CLKO_OFFSET;
-       clko_clk.parent = (struct clk *)clko_clocks[reg];
-
-       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
-       clk_enable(&hclk);
-       clk_enable(&fclk);
-
-       mxc_timer_init(&gpt_clk, MX1_IO_ADDRESS(MX1_TIM1_BASE_ADDR),
-                       MX1_TIM1_INT);
-
-       return 0;
-}
diff --git a/arch/arm/mach-imx/clock-imx21.c b/arch/arm/mach-imx/clock-imx21.c
deleted file mode 100644 (file)
index ee15d8c..0000000
+++ /dev/null
@@ -1,1239 +0,0 @@
-/*
- * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
- * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
- * Copyright 2008 Martin Fuzzey, mfuzzey@gmail.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <linux/clkdev.h>
-
-#include <mach/clock.h>
-#include <mach/hardware.h>
-#include <mach/common.h>
-#include <asm/div64.h>
-
-#define IO_ADDR_CCM(off)       (MX21_IO_ADDRESS(MX21_CCM_BASE_ADDR + (off)))
-
-/* Register offsets */
-#define CCM_CSCR               IO_ADDR_CCM(0x0)
-#define CCM_MPCTL0             IO_ADDR_CCM(0x4)
-#define CCM_MPCTL1             IO_ADDR_CCM(0x8)
-#define CCM_SPCTL0             IO_ADDR_CCM(0xc)
-#define CCM_SPCTL1             IO_ADDR_CCM(0x10)
-#define CCM_OSC26MCTL          IO_ADDR_CCM(0x14)
-#define CCM_PCDR0              IO_ADDR_CCM(0x18)
-#define CCM_PCDR1              IO_ADDR_CCM(0x1c)
-#define CCM_PCCR0              IO_ADDR_CCM(0x20)
-#define CCM_PCCR1              IO_ADDR_CCM(0x24)
-#define CCM_CCSR               IO_ADDR_CCM(0x28)
-#define CCM_PMCTL              IO_ADDR_CCM(0x2c)
-#define CCM_PMCOUNT            IO_ADDR_CCM(0x30)
-#define CCM_WKGDCTL            IO_ADDR_CCM(0x34)
-
-#define CCM_CSCR_PRESC_OFFSET  29
-#define CCM_CSCR_PRESC_MASK    (0x7 << CCM_CSCR_PRESC_OFFSET)
-
-#define CCM_CSCR_USB_OFFSET    26
-#define CCM_CSCR_USB_MASK      (0x7 << CCM_CSCR_USB_OFFSET)
-#define CCM_CSCR_SD_OFFSET     24
-#define CCM_CSCR_SD_MASK       (0x3 << CCM_CSCR_SD_OFFSET)
-#define CCM_CSCR_SPLLRES       (1 << 22)
-#define CCM_CSCR_MPLLRES       (1 << 21)
-#define CCM_CSCR_SSI2_OFFSET   20
-#define CCM_CSCR_SSI2          (1 << CCM_CSCR_SSI2_OFFSET)
-#define CCM_CSCR_SSI1_OFFSET   19
-#define CCM_CSCR_SSI1          (1 << CCM_CSCR_SSI1_OFFSET)
-#define CCM_CSCR_FIR_OFFSET    18
-#define CCM_CSCR_FIR           (1 << CCM_CSCR_FIR_OFFSET)
-#define CCM_CSCR_SP            (1 << 17)
-#define CCM_CSCR_MCU           (1 << 16)
-#define CCM_CSCR_BCLK_OFFSET   10
-#define CCM_CSCR_BCLK_MASK     (0xf << CCM_CSCR_BCLK_OFFSET)
-#define CCM_CSCR_IPDIV_OFFSET  9
-#define CCM_CSCR_IPDIV         (1 << CCM_CSCR_IPDIV_OFFSET)
-
-#define CCM_CSCR_OSC26MDIV     (1 << 4)
-#define CCM_CSCR_OSC26M                (1 << 3)
-#define CCM_CSCR_FPM           (1 << 2)
-#define CCM_CSCR_SPEN          (1 << 1)
-#define CCM_CSCR_MPEN          1
-
-#define CCM_MPCTL0_CPLM                (1 << 31)
-#define CCM_MPCTL0_PD_OFFSET   26
-#define CCM_MPCTL0_PD_MASK     (0xf << 26)
-#define CCM_MPCTL0_MFD_OFFSET  16
-#define CCM_MPCTL0_MFD_MASK    (0x3ff << 16)
-#define CCM_MPCTL0_MFI_OFFSET  10
-#define CCM_MPCTL0_MFI_MASK    (0xf << 10)
-#define CCM_MPCTL0_MFN_OFFSET  0
-#define CCM_MPCTL0_MFN_MASK    0x3ff
-
-#define CCM_MPCTL1_LF          (1 << 15)
-#define CCM_MPCTL1_BRMO                (1 << 6)
-
-#define CCM_SPCTL0_CPLM                (1 << 31)
-#define CCM_SPCTL0_PD_OFFSET   26
-#define CCM_SPCTL0_PD_MASK     (0xf << 26)
-#define CCM_SPCTL0_MFD_OFFSET  16
-#define CCM_SPCTL0_MFD_MASK    (0x3ff << 16)
-#define CCM_SPCTL0_MFI_OFFSET  10
-#define CCM_SPCTL0_MFI_MASK    (0xf << 10)
-#define CCM_SPCTL0_MFN_OFFSET  0
-#define CCM_SPCTL0_MFN_MASK    0x3ff
-
-#define CCM_SPCTL1_LF          (1 << 15)
-#define CCM_SPCTL1_BRMO                (1 << 6)
-
-#define CCM_OSC26MCTL_PEAK_OFFSET      16
-#define CCM_OSC26MCTL_PEAK_MASK                (0x3 << 16)
-#define CCM_OSC26MCTL_AGC_OFFSET       8
-#define CCM_OSC26MCTL_AGC_MASK         (0x3f << 8)
-#define CCM_OSC26MCTL_ANATEST_OFFSET   0
-#define CCM_OSC26MCTL_ANATEST_MASK     0x3f
-
-#define CCM_PCDR0_SSI2BAUDDIV_OFFSET   26
-#define CCM_PCDR0_SSI2BAUDDIV_MASK     (0x3f << 26)
-#define CCM_PCDR0_SSI1BAUDDIV_OFFSET   16
-#define CCM_PCDR0_SSI1BAUDDIV_MASK     (0x3f << 16)
-#define CCM_PCDR0_NFCDIV_OFFSET                12
-#define CCM_PCDR0_NFCDIV_MASK          (0xf << 12)
-#define CCM_PCDR0_48MDIV_OFFSET                5
-#define CCM_PCDR0_48MDIV_MASK          (0x7 << CCM_PCDR0_48MDIV_OFFSET)
-#define CCM_PCDR0_FIRIDIV_OFFSET       0
-#define CCM_PCDR0_FIRIDIV_MASK         0x1f
-#define CCM_PCDR1_PERDIV4_OFFSET       24
-#define CCM_PCDR1_PERDIV4_MASK         (0x3f << 24)
-#define CCM_PCDR1_PERDIV3_OFFSET       16
-#define CCM_PCDR1_PERDIV3_MASK         (0x3f << 16)
-#define CCM_PCDR1_PERDIV2_OFFSET       8
-#define CCM_PCDR1_PERDIV2_MASK         (0x3f << 8)
-#define CCM_PCDR1_PERDIV1_OFFSET       0
-#define CCM_PCDR1_PERDIV1_MASK         0x3f
-
-#define CCM_PCCR_HCLK_CSI_OFFSET       31
-#define CCM_PCCR_HCLK_CSI_REG          CCM_PCCR0
-#define CCM_PCCR_HCLK_DMA_OFFSET       30
-#define CCM_PCCR_HCLK_DMA_REG          CCM_PCCR0
-#define CCM_PCCR_HCLK_BROM_OFFSET      28
-#define CCM_PCCR_HCLK_BROM_REG         CCM_PCCR0
-#define CCM_PCCR_HCLK_EMMA_OFFSET      27
-#define CCM_PCCR_HCLK_EMMA_REG         CCM_PCCR0
-#define CCM_PCCR_HCLK_LCDC_OFFSET      26
-#define CCM_PCCR_HCLK_LCDC_REG         CCM_PCCR0
-#define CCM_PCCR_HCLK_SLCDC_OFFSET     25
-#define CCM_PCCR_HCLK_SLCDC_REG                CCM_PCCR0
-#define CCM_PCCR_HCLK_USBOTG_OFFSET    24
-#define CCM_PCCR_HCLK_USBOTG_REG       CCM_PCCR0
-#define CCM_PCCR_HCLK_BMI_OFFSET       23
-#define CCM_PCCR_BMI_MASK              (1 << CCM_PCCR_BMI_MASK)
-#define CCM_PCCR_HCLK_BMI_REG          CCM_PCCR0
-#define CCM_PCCR_PERCLK4_OFFSET                22
-#define CCM_PCCR_PERCLK4_REG           CCM_PCCR0
-#define CCM_PCCR_SLCDC_OFFSET          21
-#define CCM_PCCR_SLCDC_REG             CCM_PCCR0
-#define CCM_PCCR_FIRI_BAUD_OFFSET      20
-#define CCM_PCCR_FIRI_BAUD_MASK                (1 << CCM_PCCR_FIRI_BAUD_MASK)
-#define CCM_PCCR_FIRI_BAUD_REG         CCM_PCCR0
-#define CCM_PCCR_NFC_OFFSET            19
-#define CCM_PCCR_NFC_REG               CCM_PCCR0
-#define CCM_PCCR_LCDC_OFFSET           18
-#define CCM_PCCR_LCDC_REG              CCM_PCCR0
-#define CCM_PCCR_SSI1_BAUD_OFFSET      17
-#define CCM_PCCR_SSI1_BAUD_REG         CCM_PCCR0
-#define CCM_PCCR_SSI2_BAUD_OFFSET      16
-#define CCM_PCCR_SSI2_BAUD_REG         CCM_PCCR0
-#define CCM_PCCR_EMMA_OFFSET           15
-#define CCM_PCCR_EMMA_REG              CCM_PCCR0
-#define CCM_PCCR_USBOTG_OFFSET         14
-#define CCM_PCCR_USBOTG_REG            CCM_PCCR0
-#define CCM_PCCR_DMA_OFFSET            13
-#define CCM_PCCR_DMA_REG               CCM_PCCR0
-#define CCM_PCCR_I2C1_OFFSET           12
-#define CCM_PCCR_I2C1_REG              CCM_PCCR0
-#define CCM_PCCR_GPIO_OFFSET           11
-#define CCM_PCCR_GPIO_REG              CCM_PCCR0
-#define CCM_PCCR_SDHC2_OFFSET          10
-#define CCM_PCCR_SDHC2_REG             CCM_PCCR0
-#define CCM_PCCR_SDHC1_OFFSET          9
-#define CCM_PCCR_SDHC1_REG             CCM_PCCR0
-#define CCM_PCCR_FIRI_OFFSET           8
-#define CCM_PCCR_FIRI_MASK             (1 << CCM_PCCR_BAUD_MASK)
-#define CCM_PCCR_FIRI_REG              CCM_PCCR0
-#define CCM_PCCR_SSI2_IPG_OFFSET       7
-#define CCM_PCCR_SSI2_REG              CCM_PCCR0
-#define CCM_PCCR_SSI1_IPG_OFFSET       6
-#define CCM_PCCR_SSI1_REG              CCM_PCCR0
-#define CCM_PCCR_CSPI2_OFFSET          5
-#define        CCM_PCCR_CSPI2_REG              CCM_PCCR0
-#define CCM_PCCR_CSPI1_OFFSET          4
-#define        CCM_PCCR_CSPI1_REG              CCM_PCCR0
-#define CCM_PCCR_UART4_OFFSET          3
-#define CCM_PCCR_UART4_REG             CCM_PCCR0
-#define CCM_PCCR_UART3_OFFSET          2
-#define CCM_PCCR_UART3_REG             CCM_PCCR0
-#define CCM_PCCR_UART2_OFFSET          1
-#define CCM_PCCR_UART2_REG             CCM_PCCR0
-#define CCM_PCCR_UART1_OFFSET          0
-#define CCM_PCCR_UART1_REG             CCM_PCCR0
-
-#define CCM_PCCR_OWIRE_OFFSET          31
-#define CCM_PCCR_OWIRE_REG             CCM_PCCR1
-#define CCM_PCCR_KPP_OFFSET            30
-#define CCM_PCCR_KPP_REG               CCM_PCCR1
-#define CCM_PCCR_RTC_OFFSET            29
-#define CCM_PCCR_RTC_REG               CCM_PCCR1
-#define CCM_PCCR_PWM_OFFSET            28
-#define CCM_PCCR_PWM_REG               CCM_PCCR1
-#define CCM_PCCR_GPT3_OFFSET           27
-#define CCM_PCCR_GPT3_REG              CCM_PCCR1
-#define CCM_PCCR_GPT2_OFFSET           26
-#define CCM_PCCR_GPT2_REG              CCM_PCCR1
-#define CCM_PCCR_GPT1_OFFSET           25
-#define CCM_PCCR_GPT1_REG              CCM_PCCR1
-#define CCM_PCCR_WDT_OFFSET            24
-#define CCM_PCCR_WDT_REG               CCM_PCCR1
-#define CCM_PCCR_CSPI3_OFFSET          23
-#define        CCM_PCCR_CSPI3_REG              CCM_PCCR1
-
-#define CCM_PCCR_CSPI1_MASK            (1 << CCM_PCCR_CSPI1_OFFSET)
-#define CCM_PCCR_CSPI2_MASK            (1 << CCM_PCCR_CSPI2_OFFSET)
-#define CCM_PCCR_CSPI3_MASK            (1 << CCM_PCCR_CSPI3_OFFSET)
-#define CCM_PCCR_DMA_MASK              (1 << CCM_PCCR_DMA_OFFSET)
-#define CCM_PCCR_EMMA_MASK             (1 << CCM_PCCR_EMMA_OFFSET)
-#define CCM_PCCR_GPIO_MASK             (1 << CCM_PCCR_GPIO_OFFSET)
-#define CCM_PCCR_GPT1_MASK             (1 << CCM_PCCR_GPT1_OFFSET)
-#define CCM_PCCR_GPT2_MASK             (1 << CCM_PCCR_GPT2_OFFSET)
-#define CCM_PCCR_GPT3_MASK             (1 << CCM_PCCR_GPT3_OFFSET)
-#define CCM_PCCR_HCLK_BROM_MASK                (1 << CCM_PCCR_HCLK_BROM_OFFSET)
-#define CCM_PCCR_HCLK_CSI_MASK         (1 << CCM_PCCR_HCLK_CSI_OFFSET)
-#define CCM_PCCR_HCLK_DMA_MASK         (1 << CCM_PCCR_HCLK_DMA_OFFSET)
-#define CCM_PCCR_HCLK_EMMA_MASK                (1 << CCM_PCCR_HCLK_EMMA_OFFSET)
-#define CCM_PCCR_HCLK_LCDC_MASK                (1 << CCM_PCCR_HCLK_LCDC_OFFSET)
-#define CCM_PCCR_HCLK_SLCDC_MASK       (1 << CCM_PCCR_HCLK_SLCDC_OFFSET)
-#define CCM_PCCR_HCLK_USBOTG_MASK      (1 << CCM_PCCR_HCLK_USBOTG_OFFSET)
-#define CCM_PCCR_I2C1_MASK             (1 << CCM_PCCR_I2C1_OFFSET)
-#define CCM_PCCR_KPP_MASK              (1 << CCM_PCCR_KPP_OFFSET)
-#define CCM_PCCR_LCDC_MASK             (1 << CCM_PCCR_LCDC_OFFSET)
-#define CCM_PCCR_NFC_MASK              (1 << CCM_PCCR_NFC_OFFSET)
-#define CCM_PCCR_OWIRE_MASK            (1 << CCM_PCCR_OWIRE_OFFSET)
-#define CCM_PCCR_PERCLK4_MASK          (1 << CCM_PCCR_PERCLK4_OFFSET)
-#define CCM_PCCR_PWM_MASK              (1 << CCM_PCCR_PWM_OFFSET)
-#define CCM_PCCR_RTC_MASK              (1 << CCM_PCCR_RTC_OFFSET)
-#define CCM_PCCR_SDHC1_MASK            (1 << CCM_PCCR_SDHC1_OFFSET)
-#define CCM_PCCR_SDHC2_MASK            (1 << CCM_PCCR_SDHC2_OFFSET)
-#define CCM_PCCR_SLCDC_MASK            (1 << CCM_PCCR_SLCDC_OFFSET)
-#define CCM_PCCR_SSI1_BAUD_MASK                (1 << CCM_PCCR_SSI1_BAUD_OFFSET)
-#define CCM_PCCR_SSI1_IPG_MASK         (1 << CCM_PCCR_SSI1_IPG_OFFSET)
-#define CCM_PCCR_SSI2_BAUD_MASK                (1 << CCM_PCCR_SSI2_BAUD_OFFSET)
-#define CCM_PCCR_SSI2_IPG_MASK         (1 << CCM_PCCR_SSI2_IPG_OFFSET)
-#define CCM_PCCR_UART1_MASK            (1 << CCM_PCCR_UART1_OFFSET)
-#define CCM_PCCR_UART2_MASK            (1 << CCM_PCCR_UART2_OFFSET)
-#define CCM_PCCR_UART3_MASK            (1 << CCM_PCCR_UART3_OFFSET)
-#define CCM_PCCR_UART4_MASK            (1 << CCM_PCCR_UART4_OFFSET)
-#define CCM_PCCR_USBOTG_MASK           (1 << CCM_PCCR_USBOTG_OFFSET)
-#define CCM_PCCR_WDT_MASK              (1 << CCM_PCCR_WDT_OFFSET)
-
-#define CCM_CCSR_32KSR         (1 << 15)
-
-#define CCM_CCSR_CLKMODE1      (1 << 9)
-#define CCM_CCSR_CLKMODE0      (1 << 8)
-
-#define CCM_CCSR_CLKOSEL_OFFSET 0
-#define CCM_CCSR_CLKOSEL_MASK  0x1f
-
-#define SYS_FMCR               0x14    /* Functional Muxing Control Reg */
-#define SYS_CHIP_ID            0x00    /* The offset of CHIP ID register */
-
-static int _clk_enable(struct clk *clk)
-{
-       u32 reg;
-
-       reg = __raw_readl(clk->enable_reg);
-       reg |= 1 << clk->enable_shift;
-       __raw_writel(reg, clk->enable_reg);
-       return 0;
-}
-
-static void _clk_disable(struct clk *clk)
-{
-       u32 reg;
-
-       reg = __raw_readl(clk->enable_reg);
-       reg &= ~(1 << clk->enable_shift);
-       __raw_writel(reg, clk->enable_reg);
-}
-
-static unsigned long _clk_generic_round_rate(struct clk *clk,
-                       unsigned long rate,
-                       u32 max_divisor)
-{
-       u32 div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-       if (parent_rate % rate)
-               div++;
-
-       if (div > max_divisor)
-               div = max_divisor;
-
-       return parent_rate / div;
-}
-
-static int _clk_spll_enable(struct clk *clk)
-{
-       u32 reg;
-
-       reg = __raw_readl(CCM_CSCR);
-       reg |= CCM_CSCR_SPEN;
-       __raw_writel(reg, CCM_CSCR);
-
-       while ((__raw_readl(CCM_SPCTL1) & CCM_SPCTL1_LF) == 0)
-               ;
-       return 0;
-}
-
-static void _clk_spll_disable(struct clk *clk)
-{
-       u32 reg;
-
-       reg = __raw_readl(CCM_CSCR);
-       reg &= ~CCM_CSCR_SPEN;
-       __raw_writel(reg, CCM_CSCR);
-}
-
-
-#define CSCR() (__raw_readl(CCM_CSCR))
-#define PCDR0() (__raw_readl(CCM_PCDR0))
-#define PCDR1() (__raw_readl(CCM_PCDR1))
-
-static unsigned long _clk_perclkx_round_rate(struct clk *clk,
-                                            unsigned long rate)
-{
-       return _clk_generic_round_rate(clk, rate, 64);
-}
-
-static int _clk_perclkx_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 reg;
-       u32 div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       if (clk->id < 0 || clk->id > 3)
-               return -EINVAL;
-
-       div = parent_rate / rate;
-       if (div > 64 || div < 1 || ((parent_rate / div) != rate))
-               return -EINVAL;
-       div--;
-
-       reg =
-           __raw_readl(CCM_PCDR1) & ~(CCM_PCDR1_PERDIV1_MASK <<
-                                      (clk->id << 3));
-       reg |= div << (clk->id << 3);
-       __raw_writel(reg, CCM_PCDR1);
-
-       return 0;
-}
-
-static unsigned long _clk_usb_recalc(struct clk *clk)
-{
-       unsigned long usb_pdf;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       usb_pdf = (CSCR() & CCM_CSCR_USB_MASK) >> CCM_CSCR_USB_OFFSET;
-
-       return parent_rate / (usb_pdf + 1U);
-}
-
-static unsigned long _clk_usb_round_rate(struct clk *clk,
-                                            unsigned long rate)
-{
-       return _clk_generic_round_rate(clk, rate, 8);
-}
-
-static int _clk_usb_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 reg;
-       u32 div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-       if (div > 8 || div < 1 || ((parent_rate / div) != rate))
-               return -EINVAL;
-       div--;
-
-       reg = CSCR() & ~CCM_CSCR_USB_MASK;
-       reg |= div << CCM_CSCR_USB_OFFSET;
-       __raw_writel(reg, CCM_CSCR);
-
-       return 0;
-}
-
-static unsigned long _clk_ssix_recalc(struct clk *clk, unsigned long pdf)
-{
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       pdf = (pdf < 2) ? 124UL : pdf;  /* MX21 & MX27 TO1 */
-
-       return 2UL * parent_rate / pdf;
-}
-
-static unsigned long _clk_ssi1_recalc(struct clk *clk)
-{
-       return _clk_ssix_recalc(clk,
-               (PCDR0() & CCM_PCDR0_SSI1BAUDDIV_MASK)
-               >> CCM_PCDR0_SSI1BAUDDIV_OFFSET);
-}
-
-static unsigned long _clk_ssi2_recalc(struct clk *clk)
-{
-       return _clk_ssix_recalc(clk,
-               (PCDR0() & CCM_PCDR0_SSI2BAUDDIV_MASK) >>
-               CCM_PCDR0_SSI2BAUDDIV_OFFSET);
-}
-
-static unsigned long _clk_nfc_recalc(struct clk *clk)
-{
-       unsigned long nfc_pdf;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       nfc_pdf = (PCDR0() & CCM_PCDR0_NFCDIV_MASK)
-               >> CCM_PCDR0_NFCDIV_OFFSET;
-
-       return parent_rate / (nfc_pdf + 1);
-}
-
-static unsigned long _clk_parent_round_rate(struct clk *clk, unsigned long rate)
-{
-       return clk->parent->round_rate(clk->parent, rate);
-}
-
-static int _clk_parent_set_rate(struct clk *clk, unsigned long rate)
-{
-       return clk->parent->set_rate(clk->parent, rate);
-}
-
-static unsigned long external_high_reference; /* in Hz */
-
-static unsigned long get_high_reference_clock_rate(struct clk *clk)
-{
-       return external_high_reference;
-}
-
-/*
- * the high frequency external clock reference
- * Default case is 26MHz.
- */
-static struct clk ckih_clk = {
-       .get_rate = get_high_reference_clock_rate,
-};
-
-static unsigned long external_low_reference; /* in Hz */
-
-static unsigned long get_low_reference_clock_rate(struct clk *clk)
-{
-       return external_low_reference;
-}
-
-/*
- * the low frequency external clock reference
- * Default case is 32.768kHz.
- */
-static struct clk ckil_clk = {
-       .get_rate = get_low_reference_clock_rate,
-};
-
-
-static unsigned long _clk_fpm_recalc(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) * 512;
-}
-
-/* Output of frequency pre multiplier */
-static struct clk fpm_clk = {
-       .parent = &ckil_clk,
-       .get_rate = _clk_fpm_recalc,
-};
-
-static unsigned long get_mpll_clk(struct clk *clk)
-{
-       uint32_t reg;
-       unsigned long ref_clk;
-       unsigned long mfi = 0, mfn = 0, mfd = 0, pdf = 0;
-       unsigned long long temp;
-
-       ref_clk = clk_get_rate(clk->parent);
-
-       reg = __raw_readl(CCM_MPCTL0);
-       pdf = (reg & CCM_MPCTL0_PD_MASK)  >> CCM_MPCTL0_PD_OFFSET;
-       mfd = (reg & CCM_MPCTL0_MFD_MASK) >> CCM_MPCTL0_MFD_OFFSET;
-       mfi = (reg & CCM_MPCTL0_MFI_MASK) >> CCM_MPCTL0_MFI_OFFSET;
-       mfn = (reg & CCM_MPCTL0_MFN_MASK) >> CCM_MPCTL0_MFN_OFFSET;
-
-       mfi = (mfi <= 5) ? 5 : mfi;
-       temp = 2LL * ref_clk * mfn;
-       do_div(temp, mfd + 1);
-       temp = 2LL * ref_clk * mfi + temp;
-       do_div(temp, pdf + 1);
-
-       return (unsigned long)temp;
-}
-
-static struct clk mpll_clk = {
-       .parent = &ckih_clk,
-       .get_rate = get_mpll_clk,
-};
-
-static unsigned long _clk_fclk_get_rate(struct clk *clk)
-{
-       unsigned long parent_rate;
-       u32 div;
-
-       div = (CSCR() & CCM_CSCR_PRESC_MASK) >> CCM_CSCR_PRESC_OFFSET;
-       parent_rate = clk_get_rate(clk->parent);
-
-       return parent_rate / (div+1);
-}
-
-static struct clk fclk_clk = {
-       .parent = &mpll_clk,
-       .get_rate = _clk_fclk_get_rate
-};
-
-static unsigned long get_spll_clk(struct clk *clk)
-{
-       uint32_t reg;
-       unsigned long ref_clk;
-       unsigned long mfi = 0, mfn = 0, mfd = 0, pdf = 0;
-       unsigned long long temp;
-
-       ref_clk = clk_get_rate(clk->parent);
-
-       reg = __raw_readl(CCM_SPCTL0);
-       pdf = (reg & CCM_SPCTL0_PD_MASK) >> CCM_SPCTL0_PD_OFFSET;
-       mfd = (reg & CCM_SPCTL0_MFD_MASK) >> CCM_SPCTL0_MFD_OFFSET;
-       mfi = (reg & CCM_SPCTL0_MFI_MASK) >> CCM_SPCTL0_MFI_OFFSET;
-       mfn = (reg & CCM_SPCTL0_MFN_MASK) >> CCM_SPCTL0_MFN_OFFSET;
-
-       mfi = (mfi <= 5) ? 5 : mfi;
-       temp = 2LL * ref_clk * mfn;
-       do_div(temp, mfd + 1);
-       temp = 2LL * ref_clk * mfi + temp;
-       do_div(temp, pdf + 1);
-
-       return (unsigned long)temp;
-}
-
-static struct clk spll_clk = {
-       .parent = &ckih_clk,
-       .get_rate = get_spll_clk,
-       .enable = _clk_spll_enable,
-       .disable = _clk_spll_disable,
-};
-
-static unsigned long get_hclk_clk(struct clk *clk)
-{
-       unsigned long rate;
-       unsigned long bclk_pdf;
-
-       bclk_pdf = (CSCR() & CCM_CSCR_BCLK_MASK)
-               >> CCM_CSCR_BCLK_OFFSET;
-
-       rate = clk_get_rate(clk->parent);
-       return rate / (bclk_pdf + 1);
-}
-
-static struct clk hclk_clk = {
-       .parent = &fclk_clk,
-       .get_rate = get_hclk_clk,
-};
-
-static unsigned long get_ipg_clk(struct clk *clk)
-{
-       unsigned long rate;
-       unsigned long ipg_pdf;
-
-       ipg_pdf = (CSCR() & CCM_CSCR_IPDIV) >> CCM_CSCR_IPDIV_OFFSET;
-
-       rate = clk_get_rate(clk->parent);
-       return rate / (ipg_pdf + 1);
-}
-
-static struct clk ipg_clk = {
-       .parent = &hclk_clk,
-       .get_rate = get_ipg_clk,
-};
-
-static unsigned long _clk_perclkx_recalc(struct clk *clk)
-{
-       unsigned long perclk_pdf;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       if (clk->id < 0 || clk->id > 3)
-               return 0;
-
-       perclk_pdf = (PCDR1() >> (clk->id << 3)) & CCM_PCDR1_PERDIV1_MASK;
-
-       return parent_rate / (perclk_pdf + 1);
-}
-
-static struct clk per_clk[] = {
-       {
-               .id = 0,
-               .parent = &mpll_clk,
-               .get_rate = _clk_perclkx_recalc,
-       }, {
-               .id = 1,
-               .parent = &mpll_clk,
-               .get_rate = _clk_perclkx_recalc,
-       }, {
-               .id = 2,
-               .parent = &mpll_clk,
-               .round_rate = _clk_perclkx_round_rate,
-               .set_rate = _clk_perclkx_set_rate,
-               .get_rate = _clk_perclkx_recalc,
-               /* Enable/Disable done via lcd_clkc[1] */
-       }, {
-               .id = 3,
-               .parent = &mpll_clk,
-               .round_rate = _clk_perclkx_round_rate,
-               .set_rate = _clk_perclkx_set_rate,
-               .get_rate = _clk_perclkx_recalc,
-               /* Enable/Disable done via csi_clk[1] */
-       },
-};
-
-static struct clk uart_ipg_clk[];
-
-static struct clk uart_clk[] = {
-       {
-               .id = 0,
-               .parent = &per_clk[0],
-               .secondary = &uart_ipg_clk[0],
-       }, {
-               .id = 1,
-               .parent = &per_clk[0],
-               .secondary = &uart_ipg_clk[1],
-       }, {
-               .id = 2,
-               .parent = &per_clk[0],
-               .secondary = &uart_ipg_clk[2],
-       }, {
-               .id = 3,
-               .parent = &per_clk[0],
-               .secondary = &uart_ipg_clk[3],
-       },
-};
-
-static struct clk uart_ipg_clk[] = {
-       {
-               .id = 0,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_UART1_REG,
-               .enable_shift = CCM_PCCR_UART1_OFFSET,
-               .disable = _clk_disable,
-       }, {
-               .id = 1,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_UART2_REG,
-               .enable_shift = CCM_PCCR_UART2_OFFSET,
-               .disable = _clk_disable,
-       }, {
-               .id = 2,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_UART3_REG,
-               .enable_shift = CCM_PCCR_UART3_OFFSET,
-               .disable = _clk_disable,
-       }, {
-               .id = 3,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_UART4_REG,
-               .enable_shift = CCM_PCCR_UART4_OFFSET,
-               .disable = _clk_disable,
-       },
-};
-
-static struct clk gpt_ipg_clk[];
-
-static struct clk gpt_clk[] = {
-       {
-               .id = 0,
-               .parent = &per_clk[0],
-               .secondary = &gpt_ipg_clk[0],
-       }, {
-               .id = 1,
-               .parent = &per_clk[0],
-               .secondary = &gpt_ipg_clk[1],
-       }, {
-               .id = 2,
-               .parent = &per_clk[0],
-               .secondary = &gpt_ipg_clk[2],
-       },
-};
-
-static struct clk gpt_ipg_clk[] = {
-       {
-               .id = 0,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_GPT1_REG,
-               .enable_shift = CCM_PCCR_GPT1_OFFSET,
-               .disable = _clk_disable,
-       }, {
-               .id = 1,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_GPT2_REG,
-               .enable_shift = CCM_PCCR_GPT2_OFFSET,
-               .disable = _clk_disable,
-       }, {
-               .id = 2,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_GPT3_REG,
-               .enable_shift = CCM_PCCR_GPT3_OFFSET,
-               .disable = _clk_disable,
-       },
-};
-
-static struct clk pwm_clk[] = {
-       {
-               .parent = &per_clk[0],
-               .secondary = &pwm_clk[1],
-       }, {
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_PWM_REG,
-               .enable_shift = CCM_PCCR_PWM_OFFSET,
-               .disable = _clk_disable,
-       },
-};
-
-static struct clk sdhc_ipg_clk[];
-
-static struct clk sdhc_clk[] = {
-       {
-               .id = 0,
-               .parent = &per_clk[1],
-               .secondary = &sdhc_ipg_clk[0],
-       }, {
-               .id = 1,
-               .parent = &per_clk[1],
-               .secondary = &sdhc_ipg_clk[1],
-       },
-};
-
-static struct clk sdhc_ipg_clk[] = {
-       {
-               .id = 0,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_SDHC1_REG,
-               .enable_shift = CCM_PCCR_SDHC1_OFFSET,
-               .disable = _clk_disable,
-       }, {
-               .id = 1,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_SDHC2_REG,
-               .enable_shift = CCM_PCCR_SDHC2_OFFSET,
-               .disable = _clk_disable,
-       },
-};
-
-static struct clk cspi_ipg_clk[];
-
-static struct clk cspi_clk[] = {
-       {
-               .id = 0,
-               .parent = &per_clk[1],
-               .secondary = &cspi_ipg_clk[0],
-       }, {
-               .id = 1,
-               .parent = &per_clk[1],
-               .secondary = &cspi_ipg_clk[1],
-       }, {
-               .id = 2,
-               .parent = &per_clk[1],
-               .secondary = &cspi_ipg_clk[2],
-       },
-};
-
-static struct clk cspi_ipg_clk[] = {
-       {
-               .id = 0,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_CSPI1_REG,
-               .enable_shift = CCM_PCCR_CSPI1_OFFSET,
-               .disable = _clk_disable,
-       }, {
-               .id = 1,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_CSPI2_REG,
-               .enable_shift = CCM_PCCR_CSPI2_OFFSET,
-               .disable = _clk_disable,
-       }, {
-               .id = 3,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_CSPI3_REG,
-               .enable_shift = CCM_PCCR_CSPI3_OFFSET,
-               .disable = _clk_disable,
-       },
-};
-
-static struct clk lcdc_clk[] = {
-       {
-               .parent = &per_clk[2],
-               .secondary = &lcdc_clk[1],
-               .round_rate = _clk_parent_round_rate,
-               .set_rate = _clk_parent_set_rate,
-       }, {
-               .parent = &ipg_clk,
-               .secondary = &lcdc_clk[2],
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_LCDC_REG,
-               .enable_shift = CCM_PCCR_LCDC_OFFSET,
-               .disable = _clk_disable,
-       }, {
-               .parent = &hclk_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_HCLK_LCDC_REG,
-               .enable_shift = CCM_PCCR_HCLK_LCDC_OFFSET,
-               .disable = _clk_disable,
-       },
-};
-
-static struct clk csi_clk[] = {
-       {
-               .parent = &per_clk[3],
-               .secondary = &csi_clk[1],
-               .round_rate = _clk_parent_round_rate,
-               .set_rate = _clk_parent_set_rate,
-       }, {
-               .parent = &hclk_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_HCLK_CSI_REG,
-               .enable_shift = CCM_PCCR_HCLK_CSI_OFFSET,
-               .disable = _clk_disable,
-       },
-};
-
-static struct clk usb_clk[] = {
-       {
-               .parent = &spll_clk,
-               .secondary = &usb_clk[1],
-               .get_rate = _clk_usb_recalc,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_USBOTG_REG,
-               .enable_shift = CCM_PCCR_USBOTG_OFFSET,
-               .disable = _clk_disable,
-               .round_rate = _clk_usb_round_rate,
-               .set_rate = _clk_usb_set_rate,
-       }, {
-               .parent = &hclk_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_HCLK_USBOTG_REG,
-               .enable_shift = CCM_PCCR_HCLK_USBOTG_OFFSET,
-               .disable = _clk_disable,
-       }
-};
-
-static struct clk ssi_ipg_clk[];
-
-static struct clk ssi_clk[] = {
-       {
-               .id = 0,
-               .parent = &mpll_clk,
-               .secondary = &ssi_ipg_clk[0],
-               .get_rate = _clk_ssi1_recalc,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_SSI1_BAUD_REG,
-               .enable_shift = CCM_PCCR_SSI1_BAUD_OFFSET,
-               .disable = _clk_disable,
-       }, {
-               .id = 1,
-               .parent = &mpll_clk,
-               .secondary = &ssi_ipg_clk[1],
-               .get_rate = _clk_ssi2_recalc,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_SSI2_BAUD_REG,
-               .enable_shift = CCM_PCCR_SSI2_BAUD_OFFSET,
-               .disable = _clk_disable,
-       },
-};
-
-static struct clk ssi_ipg_clk[] = {
-       {
-               .id = 0,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_SSI1_REG,
-               .enable_shift = CCM_PCCR_SSI1_IPG_OFFSET,
-               .disable = _clk_disable,
-       }, {
-               .id = 1,
-               .parent = &ipg_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_SSI2_REG,
-               .enable_shift = CCM_PCCR_SSI2_IPG_OFFSET,
-               .disable = _clk_disable,
-       },
-};
-
-
-static struct clk nfc_clk = {
-       .parent = &fclk_clk,
-       .get_rate = _clk_nfc_recalc,
-       .enable = _clk_enable,
-       .enable_reg = CCM_PCCR_NFC_REG,
-       .enable_shift = CCM_PCCR_NFC_OFFSET,
-       .disable = _clk_disable,
-};
-
-static struct clk dma_clk[] = {
-       {
-               .parent = &hclk_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_DMA_REG,
-               .enable_shift = CCM_PCCR_DMA_OFFSET,
-               .disable = _clk_disable,
-               .secondary = &dma_clk[1],
-       },  {
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_HCLK_DMA_REG,
-               .enable_shift = CCM_PCCR_HCLK_DMA_OFFSET,
-               .disable = _clk_disable,
-       },
-};
-
-static struct clk brom_clk = {
-       .parent = &hclk_clk,
-       .enable = _clk_enable,
-       .enable_reg = CCM_PCCR_HCLK_BROM_REG,
-       .enable_shift = CCM_PCCR_HCLK_BROM_OFFSET,
-       .disable = _clk_disable,
-};
-
-static struct clk emma_clk[] = {
-       {
-               .parent = &hclk_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_EMMA_REG,
-               .enable_shift = CCM_PCCR_EMMA_OFFSET,
-               .disable = _clk_disable,
-               .secondary = &emma_clk[1],
-       }, {
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_HCLK_EMMA_REG,
-               .enable_shift = CCM_PCCR_HCLK_EMMA_OFFSET,
-               .disable = _clk_disable,
-       }
-};
-
-static struct clk slcdc_clk[] = {
-       {
-               .parent = &hclk_clk,
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_SLCDC_REG,
-               .enable_shift = CCM_PCCR_SLCDC_OFFSET,
-               .disable = _clk_disable,
-               .secondary = &slcdc_clk[1],
-       }, {
-               .enable = _clk_enable,
-               .enable_reg = CCM_PCCR_HCLK_SLCDC_REG,
-               .enable_shift = CCM_PCCR_HCLK_SLCDC_OFFSET,
-               .disable = _clk_disable,
-       }
-};
-
-static struct clk wdog_clk = {
-       .parent = &ipg_clk,
-       .enable = _clk_enable,
-       .enable_reg = CCM_PCCR_WDT_REG,
-       .enable_shift = CCM_PCCR_WDT_OFFSET,
-       .disable = _clk_disable,
-};
-
-static struct clk gpio_clk = {
-       .parent = &ipg_clk,
-       .enable = _clk_enable,
-       .enable_reg = CCM_PCCR_GPIO_REG,
-       .enable_shift = CCM_PCCR_GPIO_OFFSET,
-       .disable = _clk_disable,
-};
-
-static struct clk i2c_clk = {
-       .id = 0,
-       .parent = &ipg_clk,
-       .enable = _clk_enable,
-       .enable_reg = CCM_PCCR_I2C1_REG,
-       .enable_shift = CCM_PCCR_I2C1_OFFSET,
-       .disable = _clk_disable,
-};
-
-static struct clk kpp_clk = {
-       .parent = &ipg_clk,
-       .enable = _clk_enable,
-       .enable_reg = CCM_PCCR_KPP_REG,
-       .enable_shift = CCM_PCCR_KPP_OFFSET,
-       .disable = _clk_disable,
-};
-
-static struct clk owire_clk = {
-       .parent = &ipg_clk,
-       .enable = _clk_enable,
-       .enable_reg = CCM_PCCR_OWIRE_REG,
-       .enable_shift = CCM_PCCR_OWIRE_OFFSET,
-       .disable = _clk_disable,
-};
-
-static struct clk rtc_clk = {
-       .parent = &ipg_clk,
-       .enable = _clk_enable,
-       .enable_reg = CCM_PCCR_RTC_REG,
-       .enable_shift = CCM_PCCR_RTC_OFFSET,
-       .disable = _clk_disable,
-};
-
-static unsigned long _clk_clko_round_rate(struct clk *clk, unsigned long rate)
-{
-       return _clk_generic_round_rate(clk, rate, 8);
-}
-
-static int _clk_clko_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 reg;
-       u32 div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-
-       if (div > 8 || div < 1 || ((parent_rate / div) != rate))
-               return -EINVAL;
-       div--;
-
-       reg = __raw_readl(CCM_PCDR0);
-
-       if (clk->parent == &usb_clk[0]) {
-               reg &= ~CCM_PCDR0_48MDIV_MASK;
-               reg |= div << CCM_PCDR0_48MDIV_OFFSET;
-       }
-       __raw_writel(reg, CCM_PCDR0);
-
-       return 0;
-}
-
-static unsigned long _clk_clko_recalc(struct clk *clk)
-{
-       u32 div = 0;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       if (clk->parent == &usb_clk[0]) /* 48M */
-               div = __raw_readl(CCM_PCDR0) & CCM_PCDR0_48MDIV_MASK
-                        >> CCM_PCDR0_48MDIV_OFFSET;
-       div++;
-
-       return parent_rate / div;
-}
-
-static struct clk clko_clk;
-
-static int _clk_clko_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 reg;
-
-       reg = __raw_readl(CCM_CCSR) & ~CCM_CCSR_CLKOSEL_MASK;
-
-       if (parent == &ckil_clk)
-               reg |= 0 << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &fpm_clk)
-               reg |= 1 << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &ckih_clk)
-               reg |= 2 << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == mpll_clk.parent)
-               reg |= 3 << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == spll_clk.parent)
-               reg |= 4 << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &mpll_clk)
-               reg |= 5 << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &spll_clk)
-               reg |= 6 << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &fclk_clk)
-               reg |= 7 << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &hclk_clk)
-               reg |= 8 << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &ipg_clk)
-               reg |= 9 << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &per_clk[0])
-               reg |= 0xA << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &per_clk[1])
-               reg |= 0xB << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &per_clk[2])
-               reg |= 0xC << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &per_clk[3])
-               reg |= 0xD << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &ssi_clk[0])
-               reg |= 0xE << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &ssi_clk[1])
-               reg |= 0xF << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &nfc_clk)
-               reg |= 0x10 << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &usb_clk[0])
-               reg |= 0x14 << CCM_CCSR_CLKOSEL_OFFSET;
-       else if (parent == &clko_clk)
-               reg |= 0x15 << CCM_CCSR_CLKOSEL_OFFSET;
-       else
-               return -EINVAL;
-
-       __raw_writel(reg, CCM_CCSR);
-
-       return 0;
-}
-
-static struct clk clko_clk = {
-       .get_rate = _clk_clko_recalc,
-       .set_rate = _clk_clko_set_rate,
-       .round_rate = _clk_clko_round_rate,
-       .set_parent = _clk_clko_set_parent,
-};
-
-
-#define _REGISTER_CLOCK(d, n, c) \
-       { \
-               .dev_id = d, \
-               .con_id = n, \
-               .clk = &c, \
-       },
-static struct clk_lookup lookups[] = {
-/* It's unlikely that any driver wants one of them directly:
-       _REGISTER_CLOCK(NULL, "ckih", ckih_clk)
-       _REGISTER_CLOCK(NULL, "ckil", ckil_clk)
-       _REGISTER_CLOCK(NULL, "fpm", fpm_clk)
-       _REGISTER_CLOCK(NULL, "mpll", mpll_clk)
-       _REGISTER_CLOCK(NULL, "spll", spll_clk)
-       _REGISTER_CLOCK(NULL, "fclk", fclk_clk)
-       _REGISTER_CLOCK(NULL, "hclk", hclk_clk)
-       _REGISTER_CLOCK(NULL, "ipg", ipg_clk)
-*/
-       _REGISTER_CLOCK(NULL, "perclk1", per_clk[0])
-       _REGISTER_CLOCK(NULL, "perclk2", per_clk[1])
-       _REGISTER_CLOCK(NULL, "perclk3", per_clk[2])
-       _REGISTER_CLOCK(NULL, "perclk4", per_clk[3])
-       _REGISTER_CLOCK(NULL, "clko", clko_clk)
-       _REGISTER_CLOCK("imx21-uart.0", NULL, uart_clk[0])
-       _REGISTER_CLOCK("imx21-uart.1", NULL, uart_clk[1])
-       _REGISTER_CLOCK("imx21-uart.2", NULL, uart_clk[2])
-       _REGISTER_CLOCK("imx21-uart.3", NULL, uart_clk[3])
-       _REGISTER_CLOCK(NULL, "gpt1", gpt_clk[0])
-       _REGISTER_CLOCK(NULL, "gpt1", gpt_clk[1])
-       _REGISTER_CLOCK(NULL, "gpt1", gpt_clk[2])
-       _REGISTER_CLOCK(NULL, "pwm", pwm_clk[0])
-       _REGISTER_CLOCK(NULL, "sdhc1", sdhc_clk[0])
-       _REGISTER_CLOCK(NULL, "sdhc2", sdhc_clk[1])
-       _REGISTER_CLOCK("imx21-cspi.0", NULL, cspi_clk[0])
-       _REGISTER_CLOCK("imx21-cspi.1", NULL, cspi_clk[1])
-       _REGISTER_CLOCK("imx21-cspi.2", NULL, cspi_clk[2])
-       _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk[0])
-       _REGISTER_CLOCK(NULL, "csi", csi_clk[0])
-       _REGISTER_CLOCK("imx21-hcd.0", NULL, usb_clk[0])
-       _REGISTER_CLOCK(NULL, "ssi1", ssi_clk[0])
-       _REGISTER_CLOCK(NULL, "ssi2", ssi_clk[1])
-       _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk)
-       _REGISTER_CLOCK(NULL, "dma", dma_clk[0])
-       _REGISTER_CLOCK(NULL, "brom", brom_clk)
-       _REGISTER_CLOCK(NULL, "emma", emma_clk[0])
-       _REGISTER_CLOCK(NULL, "slcdc", slcdc_clk[0])
-       _REGISTER_CLOCK("imx2-wdt.0", NULL, wdog_clk)
-       _REGISTER_CLOCK(NULL, "gpio", gpio_clk)
-       _REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk)
-       _REGISTER_CLOCK("mxc-keypad", NULL, kpp_clk)
-       _REGISTER_CLOCK(NULL, "owire", owire_clk)
-       _REGISTER_CLOCK(NULL, "rtc", rtc_clk)
-};
-
-/*
- * must be called very early to get information about the
- * available clock rate when the timer framework starts
- */
-int __init mx21_clocks_init(unsigned long lref, unsigned long href)
-{
-       u32 cscr;
-
-       external_low_reference = lref;
-       external_high_reference = href;
-
-       /* detect clock reference for both system PLL */
-       cscr = CSCR();
-       if (cscr & CCM_CSCR_MCU)
-               mpll_clk.parent = &ckih_clk;
-       else
-               mpll_clk.parent = &fpm_clk;
-
-       if (cscr & CCM_CSCR_SP)
-               spll_clk.parent = &ckih_clk;
-       else
-               spll_clk.parent = &fpm_clk;
-
-       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
-       /* Turn off all clock gates */
-       __raw_writel(0, CCM_PCCR0);
-       __raw_writel(CCM_PCCR_GPT1_MASK, CCM_PCCR1);
-
-       /* This turns of the serial PLL as well */
-       spll_clk.disable(&spll_clk);
-
-       /* This will propagate to all children and init all the clock rates. */
-       clk_enable(&per_clk[0]);
-       clk_enable(&gpio_clk);
-
-#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC)
-       clk_enable(&uart_clk[0]);
-#endif
-
-       mxc_timer_init(&gpt_clk[0], MX21_IO_ADDRESS(MX21_GPT1_BASE_ADDR),
-                       MX21_INT_GPT1);
-       return 0;
-}
diff --git a/arch/arm/mach-imx/clock-imx25.c b/arch/arm/mach-imx/clock-imx25.c
deleted file mode 100644 (file)
index b0fec74..0000000
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (C) 2009 by Sascha Hauer, Pengutronix
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/list.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/clkdev.h>
-
-#include <mach/clock.h>
-#include <mach/hardware.h>
-#include <mach/common.h>
-#include <mach/mx25.h>
-
-#define CRM_BASE       MX25_IO_ADDRESS(MX25_CRM_BASE_ADDR)
-
-#define CCM_MPCTL      0x00
-#define CCM_UPCTL      0x04
-#define CCM_CCTL       0x08
-#define CCM_CGCR0      0x0C
-#define CCM_CGCR1      0x10
-#define CCM_CGCR2      0x14
-#define CCM_PCDR0      0x18
-#define CCM_PCDR1      0x1C
-#define CCM_PCDR2      0x20
-#define CCM_PCDR3      0x24
-#define CCM_RCSR       0x28
-#define CCM_CRDR       0x2C
-#define CCM_DCVR0      0x30
-#define CCM_DCVR1      0x34
-#define CCM_DCVR2      0x38
-#define CCM_DCVR3      0x3c
-#define CCM_LTR0       0x40
-#define CCM_LTR1       0x44
-#define CCM_LTR2       0x48
-#define CCM_LTR3       0x4c
-
-static unsigned long get_rate_mpll(void)
-{
-       ulong mpctl = __raw_readl(CRM_BASE + CCM_MPCTL);
-
-       return mxc_decode_pll(mpctl, 24000000);
-}
-
-static unsigned long get_rate_upll(void)
-{
-       ulong mpctl = __raw_readl(CRM_BASE + CCM_UPCTL);
-
-       return mxc_decode_pll(mpctl, 24000000);
-}
-
-unsigned long get_rate_arm(struct clk *clk)
-{
-       unsigned long cctl = readl(CRM_BASE + CCM_CCTL);
-       unsigned long rate = get_rate_mpll();
-
-       if (cctl & (1 << 14))
-               rate = (rate * 3) >> 2;
-
-       return rate / ((cctl >> 30) + 1);
-}
-
-static unsigned long get_rate_ahb(struct clk *clk)
-{
-       unsigned long cctl = readl(CRM_BASE + CCM_CCTL);
-
-       return get_rate_arm(NULL) / (((cctl >> 28) & 0x3) + 1);
-}
-
-static unsigned long get_rate_ipg(struct clk *clk)
-{
-       return get_rate_ahb(NULL) >> 1;
-}
-
-static unsigned long get_rate_per(int per)
-{
-       unsigned long ofs = (per & 0x3) * 8;
-       unsigned long reg = per & ~0x3;
-       unsigned long val = (readl(CRM_BASE + CCM_PCDR0 + reg) >> ofs) & 0x3f;
-       unsigned long fref;
-
-       if (readl(CRM_BASE + 0x64) & (1 << per))
-               fref = get_rate_upll();
-       else
-               fref = get_rate_ahb(NULL);
-
-       return fref / (val + 1);
-}
-
-static unsigned long get_rate_uart(struct clk *clk)
-{
-       return get_rate_per(15);
-}
-
-static unsigned long get_rate_ssi2(struct clk *clk)
-{
-       return get_rate_per(14);
-}
-
-static unsigned long get_rate_ssi1(struct clk *clk)
-{
-       return get_rate_per(13);
-}
-
-static unsigned long get_rate_i2c(struct clk *clk)
-{
-       return get_rate_per(6);
-}
-
-static unsigned long get_rate_nfc(struct clk *clk)
-{
-       return get_rate_per(8);
-}
-
-static unsigned long get_rate_gpt(struct clk *clk)
-{
-       return get_rate_per(5);
-}
-
-static unsigned long get_rate_lcdc(struct clk *clk)
-{
-       return get_rate_per(7);
-}
-
-static unsigned long get_rate_esdhc1(struct clk *clk)
-{
-       return get_rate_per(3);
-}
-
-static unsigned long get_rate_esdhc2(struct clk *clk)
-{
-       return get_rate_per(4);
-}
-
-static unsigned long get_rate_csi(struct clk *clk)
-{
-       return get_rate_per(0);
-}
-
-static unsigned long get_rate_otg(struct clk *clk)
-{
-       unsigned long cctl = readl(CRM_BASE + CCM_CCTL);
-       unsigned long rate = get_rate_upll();
-
-       return (cctl & (1 << 23)) ? 0 : rate / ((0x3F & (cctl >> 16)) + 1);
-}
-
-static int clk_cgcr_enable(struct clk *clk)
-{
-       u32 reg;
-
-       reg = __raw_readl(clk->enable_reg);
-       reg |= 1 << clk->enable_shift;
-       __raw_writel(reg, clk->enable_reg);
-
-       return 0;
-}
-
-static void clk_cgcr_disable(struct clk *clk)
-{
-       u32 reg;
-
-       reg = __raw_readl(clk->enable_reg);
-       reg &= ~(1 << clk->enable_shift);
-       __raw_writel(reg, clk->enable_reg);
-}
-
-#define DEFINE_CLOCK(name, i, er, es, gr, sr, s)       \
-       static struct clk name = {                      \
-               .id             = i,                    \
-               .enable_reg     = CRM_BASE + er,        \
-               .enable_shift   = es,                   \
-               .get_rate       = gr,                   \
-               .set_rate       = sr,                   \
-               .enable         = clk_cgcr_enable,      \
-               .disable        = clk_cgcr_disable,     \
-               .secondary      = s,                    \
-       }
-
-/*
- * Note: the following IPG clock gating bits are wrongly marked "Reserved" in
- * the i.MX25 Reference Manual Rev 1, table 15-13. The information below is
- * taken from the Freescale released BSP.
- *
- * bit reg     offset  clock
- *
- * 0   CGCR1   0       AUDMUX
- * 12  CGCR1   12      ESAI
- * 16  CGCR1   16      GPIO1
- * 17  CGCR1   17      GPIO2
- * 18  CGCR1   18      GPIO3
- * 23  CGCR1   23      I2C1
- * 24  CGCR1   24      I2C2
- * 25  CGCR1   25      I2C3
- * 27  CGCR1   27      IOMUXC
- * 28  CGCR1   28      KPP
- * 30  CGCR1   30      OWIRE
- * 36  CGCR2   4       RTIC
- * 51  CGCR2   19      WDOG
- */
-
-DEFINE_CLOCK(gpt_clk,    0, CCM_CGCR0,  5, get_rate_gpt, NULL, NULL);
-DEFINE_CLOCK(uart_per_clk, 0, CCM_CGCR0, 15, get_rate_uart, NULL, NULL);
-DEFINE_CLOCK(ssi1_per_clk, 0, CCM_CGCR0, 13, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(ssi2_per_clk, 0, CCM_CGCR0, 14, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(cspi1_clk,  0, CCM_CGCR1,  5, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(cspi2_clk,  0, CCM_CGCR1,  6, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(cspi3_clk,  0, CCM_CGCR1,  7, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(esdhc1_ahb_clk, 0, CCM_CGCR0, 21, get_rate_esdhc1,         NULL, NULL);
-DEFINE_CLOCK(esdhc1_per_clk, 0, CCM_CGCR0,  3, get_rate_esdhc1,         NULL,
-               &esdhc1_ahb_clk);
-DEFINE_CLOCK(esdhc2_ahb_clk, 0, CCM_CGCR0, 22, get_rate_esdhc2,         NULL, NULL);
-DEFINE_CLOCK(esdhc2_per_clk, 0, CCM_CGCR0,  4, get_rate_esdhc2,         NULL,
-               &esdhc2_ahb_clk);
-DEFINE_CLOCK(sdma_ahb_clk, 0, CCM_CGCR0, 26, NULL,      NULL, NULL);
-DEFINE_CLOCK(fec_ahb_clk, 0, CCM_CGCR0, 23, NULL,       NULL, NULL);
-DEFINE_CLOCK(lcdc_ahb_clk, 0, CCM_CGCR0, 24, NULL,      NULL, NULL);
-DEFINE_CLOCK(lcdc_per_clk, 0, CCM_CGCR0,  7, NULL,      NULL, &lcdc_ahb_clk);
-DEFINE_CLOCK(csi_ahb_clk, 0, CCM_CGCR0, 18, get_rate_csi, NULL, NULL);
-DEFINE_CLOCK(csi_per_clk, 0, CCM_CGCR0, 0, get_rate_csi, NULL, &csi_ahb_clk);
-DEFINE_CLOCK(uart1_clk,  0, CCM_CGCR2, 14, get_rate_uart, NULL, &uart_per_clk);
-DEFINE_CLOCK(uart2_clk,  0, CCM_CGCR2, 15, get_rate_uart, NULL, &uart_per_clk);
-DEFINE_CLOCK(uart3_clk,  0, CCM_CGCR2, 16, get_rate_uart, NULL, &uart_per_clk);
-DEFINE_CLOCK(uart4_clk,  0, CCM_CGCR2, 17, get_rate_uart, NULL, &uart_per_clk);
-DEFINE_CLOCK(uart5_clk,  0, CCM_CGCR2, 18, get_rate_uart, NULL, &uart_per_clk);
-DEFINE_CLOCK(nfc_clk,    0, CCM_CGCR0,  8, get_rate_nfc, NULL, NULL);
-DEFINE_CLOCK(usbotg_clk, 0, CCM_CGCR0, 28, get_rate_otg, NULL, NULL);
-DEFINE_CLOCK(pwm1_clk,  0, CCM_CGCR1, 31, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(pwm2_clk,  0, CCM_CGCR2,  0, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(pwm3_clk,  0, CCM_CGCR2,  1, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(pwm4_clk,  0, CCM_CGCR2,  2, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(kpp_clk,   0, CCM_CGCR1, 28, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(tsc_clk,   0, CCM_CGCR2, 13, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(i2c_clk,   0, CCM_CGCR0,  6, get_rate_i2c, NULL, NULL);
-DEFINE_CLOCK(fec_clk,   0, CCM_CGCR1, 15, get_rate_ipg, NULL, &fec_ahb_clk);
-DEFINE_CLOCK(dryice_clk, 0, CCM_CGCR1,  8, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(lcdc_clk,  0, CCM_CGCR1, 29, get_rate_lcdc, NULL, &lcdc_per_clk);
-DEFINE_CLOCK(wdt_clk,    0, CCM_CGCR2, 19, get_rate_ipg, NULL,  NULL);
-DEFINE_CLOCK(ssi1_clk,  0, CCM_CGCR2, 11, get_rate_ssi1, NULL, &ssi1_per_clk);
-DEFINE_CLOCK(ssi2_clk,  1, CCM_CGCR2, 12, get_rate_ssi2, NULL, &ssi2_per_clk);
-DEFINE_CLOCK(sdma_clk, 0, CCM_CGCR2,  6, get_rate_ipg, NULL, &sdma_ahb_clk);
-DEFINE_CLOCK(esdhc1_clk,  0, CCM_CGCR1, 13, get_rate_esdhc1, NULL,
-               &esdhc1_per_clk);
-DEFINE_CLOCK(esdhc2_clk,  1, CCM_CGCR1, 14, get_rate_esdhc2, NULL,
-               &esdhc2_per_clk);
-DEFINE_CLOCK(audmux_clk, 0, CCM_CGCR1, 0, NULL, NULL, NULL);
-DEFINE_CLOCK(csi_clk,    0, CCM_CGCR1,  4, get_rate_csi, NULL,  &csi_per_clk);
-DEFINE_CLOCK(can1_clk,  0, CCM_CGCR1,  2, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(can2_clk,  1, CCM_CGCR1,  3, get_rate_ipg, NULL, NULL);
-DEFINE_CLOCK(iim_clk,    0, CCM_CGCR1, 26, NULL, NULL, NULL);
-
-#define _REGISTER_CLOCK(d, n, c)       \
-       {                               \
-               .dev_id = d,            \
-               .con_id = n,            \
-               .clk = &c,              \
-       },
-
-static struct clk_lookup lookups[] = {
-       /* i.mx25 has the i.mx21 type uart */
-       _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk)
-       _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk)
-       _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk)
-       _REGISTER_CLOCK("imx21-uart.3", NULL, uart4_clk)
-       _REGISTER_CLOCK("imx21-uart.4", NULL, uart5_clk)
-       _REGISTER_CLOCK("mxc-ehci.0", "usb", usbotg_clk)
-       _REGISTER_CLOCK("mxc-ehci.1", "usb", usbotg_clk)
-       _REGISTER_CLOCK("mxc-ehci.2", "usb", usbotg_clk)
-       _REGISTER_CLOCK("fsl-usb2-udc", "usb", usbotg_clk)
-       _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk)
-       /* i.mx25 has the i.mx35 type cspi */
-       _REGISTER_CLOCK("imx35-cspi.0", NULL, cspi1_clk)
-       _REGISTER_CLOCK("imx35-cspi.1", NULL, cspi2_clk)
-       _REGISTER_CLOCK("imx35-cspi.2", NULL, cspi3_clk)
-       _REGISTER_CLOCK("mxc_pwm.0", NULL, pwm1_clk)
-       _REGISTER_CLOCK("mxc_pwm.1", NULL, pwm2_clk)
-       _REGISTER_CLOCK("mxc_pwm.2", NULL, pwm3_clk)
-       _REGISTER_CLOCK("mxc_pwm.3", NULL, pwm4_clk)
-       _REGISTER_CLOCK("imx-keypad", NULL, kpp_clk)
-       _REGISTER_CLOCK("mx25-adc", NULL, tsc_clk)
-       _REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk)
-       _REGISTER_CLOCK("imx-i2c.1", NULL, i2c_clk)
-       _REGISTER_CLOCK("imx-i2c.2", NULL, i2c_clk)
-       _REGISTER_CLOCK("imx25-fec.0", NULL, fec_clk)
-       _REGISTER_CLOCK("imxdi_rtc.0", NULL, dryice_clk)
-       _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk)
-       _REGISTER_CLOCK("imx2-wdt.0", NULL, wdt_clk)
-       _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
-       _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx25.0", NULL, esdhc1_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx25.1", NULL, esdhc2_clk)
-       _REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk)
-       _REGISTER_CLOCK(NULL, "audmux", audmux_clk)
-       _REGISTER_CLOCK("flexcan.0", NULL, can1_clk)
-       _REGISTER_CLOCK("flexcan.1", NULL, can2_clk)
-       /* i.mx25 has the i.mx35 type sdma */
-       _REGISTER_CLOCK("imx35-sdma", NULL, sdma_clk)
-       _REGISTER_CLOCK(NULL, "iim", iim_clk)
-};
-
-int __init mx25_clocks_init(void)
-{
-       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
-       /* Turn off all clocks except the ones we need to survive, namely:
-        * EMI, GPIO1-3 (CCM_CGCR1[18:16]), GPT1, IOMUXC (CCM_CGCR1[27]), IIM,
-        * SCC
-        */
-       __raw_writel((1 << 19), CRM_BASE + CCM_CGCR0);
-       __raw_writel((0xf << 16) | (3 << 26), CRM_BASE + CCM_CGCR1);
-       __raw_writel((1 << 5), CRM_BASE + CCM_CGCR2);
-#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC)
-       clk_enable(&uart1_clk);
-#endif
-
-       /* Clock source for lcdc and csi is upll */
-       __raw_writel(__raw_readl(CRM_BASE+0x64) | (1 << 7) | (1 << 0),
-                       CRM_BASE + 0x64);
-
-       /* Clock source for gpt is ahb_div */
-       __raw_writel(__raw_readl(CRM_BASE+0x64) & ~(1 << 5), CRM_BASE + 0x64);
-
-       clk_enable(&iim_clk);
-       imx_print_silicon_rev("i.MX25", mx25_revision());
-       clk_disable(&iim_clk);
-
-       mxc_timer_init(&gpt_clk, MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54);
-
-       return 0;
-}
diff --git a/arch/arm/mach-imx/clock-imx27.c b/arch/arm/mach-imx/clock-imx27.c
deleted file mode 100644 (file)
index 98e04f5..0000000
+++ /dev/null
@@ -1,785 +0,0 @@
-/*
- * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
- * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
- * Copyright 2008 Martin Fuzzey, mfuzzey@gmail.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <linux/clkdev.h>
-#include <linux/of.h>
-
-#include <asm/div64.h>
-
-#include <mach/clock.h>
-#include <mach/common.h>
-#include <mach/hardware.h>
-
-#define IO_ADDR_CCM(off)       (MX27_IO_ADDRESS(MX27_CCM_BASE_ADDR + (off)))
-
-/* Register offsets */
-#define CCM_CSCR               IO_ADDR_CCM(0x0)
-#define CCM_MPCTL0             IO_ADDR_CCM(0x4)
-#define CCM_MPCTL1             IO_ADDR_CCM(0x8)
-#define CCM_SPCTL0             IO_ADDR_CCM(0xc)
-#define CCM_SPCTL1             IO_ADDR_CCM(0x10)
-#define CCM_OSC26MCTL          IO_ADDR_CCM(0x14)
-#define CCM_PCDR0              IO_ADDR_CCM(0x18)
-#define CCM_PCDR1              IO_ADDR_CCM(0x1c)
-#define CCM_PCCR0              IO_ADDR_CCM(0x20)
-#define CCM_PCCR1              IO_ADDR_CCM(0x24)
-#define CCM_CCSR               IO_ADDR_CCM(0x28)
-#define CCM_PMCTL              IO_ADDR_CCM(0x2c)
-#define CCM_PMCOUNT            IO_ADDR_CCM(0x30)
-#define CCM_WKGDCTL            IO_ADDR_CCM(0x34)
-
-#define CCM_CSCR_UPDATE_DIS    (1 << 31)
-#define CCM_CSCR_SSI2          (1 << 23)
-#define CCM_CSCR_SSI1          (1 << 22)
-#define CCM_CSCR_VPU           (1 << 21)
-#define CCM_CSCR_MSHC           (1 << 20)
-#define CCM_CSCR_SPLLRES        (1 << 19)
-#define CCM_CSCR_MPLLRES        (1 << 18)
-#define CCM_CSCR_SP             (1 << 17)
-#define CCM_CSCR_MCU            (1 << 16)
-#define CCM_CSCR_OSC26MDIV      (1 << 4)
-#define CCM_CSCR_OSC26M         (1 << 3)
-#define CCM_CSCR_FPM            (1 << 2)
-#define CCM_CSCR_SPEN           (1 << 1)
-#define CCM_CSCR_MPEN           (1 << 0)
-
-/* i.MX27 TO 2+ */
-#define CCM_CSCR_ARM_SRC        (1 << 15)
-
-#define CCM_SPCTL1_LF           (1 << 15)
-#define CCM_SPCTL1_BRMO         (1 << 6)
-
-static struct clk mpll_main1_clk, mpll_main2_clk;
-
-static int clk_pccr_enable(struct clk *clk)
-{
-       unsigned long reg;
-
-       if (!clk->enable_reg)
-               return 0;
-
-       reg = __raw_readl(clk->enable_reg);
-       reg |= 1 << clk->enable_shift;
-       __raw_writel(reg, clk->enable_reg);
-
-       return 0;
-}
-
-static void clk_pccr_disable(struct clk *clk)
-{
-       unsigned long reg;
-
-       if (!clk->enable_reg)
-               return;
-
-       reg = __raw_readl(clk->enable_reg);
-       reg &= ~(1 << clk->enable_shift);
-       __raw_writel(reg, clk->enable_reg);
-}
-
-static int clk_spll_enable(struct clk *clk)
-{
-       unsigned long reg;
-
-       reg = __raw_readl(CCM_CSCR);
-       reg |= CCM_CSCR_SPEN;
-       __raw_writel(reg, CCM_CSCR);
-
-       while (!(__raw_readl(CCM_SPCTL1) & CCM_SPCTL1_LF));
-
-       return 0;
-}
-
-static void clk_spll_disable(struct clk *clk)
-{
-       unsigned long reg;
-
-       reg = __raw_readl(CCM_CSCR);
-       reg &= ~CCM_CSCR_SPEN;
-       __raw_writel(reg, CCM_CSCR);
-}
-
-static int clk_cpu_set_parent(struct clk *clk, struct clk *parent)
-{
-       int cscr = __raw_readl(CCM_CSCR);
-
-       if (clk->parent == parent)
-               return 0;
-
-       if (mx27_revision() >= IMX_CHIP_REVISION_2_0) {
-               if (parent == &mpll_main1_clk) {
-                       cscr |= CCM_CSCR_ARM_SRC;
-               } else {
-                       if (parent == &mpll_main2_clk)
-                               cscr &= ~CCM_CSCR_ARM_SRC;
-                       else
-                               return -EINVAL;
-               }
-               __raw_writel(cscr, CCM_CSCR);
-               clk->parent = parent;
-               return 0;
-       }
-       return -ENODEV;
-}
-
-static unsigned long round_rate_cpu(struct clk *clk, unsigned long rate)
-{
-       int div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-       if (parent_rate % rate)
-               div++;
-
-       if (div > 4)
-               div = 4;
-
-       return parent_rate / div;
-}
-
-static int set_rate_cpu(struct clk *clk, unsigned long rate)
-{
-       unsigned int div;
-       uint32_t reg;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-
-       if (div > 4 || div < 1 || ((parent_rate / div) != rate))
-               return -EINVAL;
-
-       div--;
-
-       reg = __raw_readl(CCM_CSCR);
-       if (mx27_revision() >= IMX_CHIP_REVISION_2_0) {
-               reg &= ~(3 << 12);
-               reg |= div << 12;
-               reg &= ~(CCM_CSCR_FPM | CCM_CSCR_SPEN);
-               __raw_writel(reg | CCM_CSCR_UPDATE_DIS, CCM_CSCR);
-       } else {
-               printk(KERN_ERR "Can't set CPU frequency!\n");
-       }
-
-       return 0;
-}
-
-static unsigned long round_rate_per(struct clk *clk, unsigned long rate)
-{
-       u32 div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-       if (parent_rate % rate)
-               div++;
-
-       if (div > 64)
-               div = 64;
-
-       return parent_rate / div;
-}
-
-static int set_rate_per(struct clk *clk, unsigned long rate)
-{
-       u32 reg;
-       u32 div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       if (clk->id < 0 || clk->id > 3)
-               return -EINVAL;
-
-       div = parent_rate / rate;
-       if (div > 64 || div < 1 || ((parent_rate / div) != rate))
-               return -EINVAL;
-       div--;
-
-       reg = __raw_readl(CCM_PCDR1) & ~(0x3f << (clk->id << 3));
-       reg |= div << (clk->id << 3);
-       __raw_writel(reg, CCM_PCDR1);
-
-       return 0;
-}
-
-static unsigned long get_rate_usb(struct clk *clk)
-{
-       unsigned long usb_pdf;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       usb_pdf = (__raw_readl(CCM_CSCR) >> 28) & 0x7;
-
-       return parent_rate / (usb_pdf + 1U);
-}
-
-static unsigned long get_rate_ssix(struct clk *clk, unsigned long pdf)
-{
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       if (mx27_revision() >= IMX_CHIP_REVISION_2_0)
-               pdf += 4;  /* MX27 TO2+ */
-       else
-               pdf = (pdf < 2) ? 124UL : pdf;  /* MX21 & MX27 TO1 */
-
-       return 2UL * parent_rate / pdf;
-}
-
-static unsigned long get_rate_ssi1(struct clk *clk)
-{
-       return get_rate_ssix(clk, (__raw_readl(CCM_PCDR0) >> 16) & 0x3f);
-}
-
-static unsigned long get_rate_ssi2(struct clk *clk)
-{
-       return get_rate_ssix(clk, (__raw_readl(CCM_PCDR0) >> 26) & 0x3f);
-}
-
-static unsigned long get_rate_nfc(struct clk *clk)
-{
-       unsigned long nfc_pdf;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       if (mx27_revision() >= IMX_CHIP_REVISION_2_0)
-               nfc_pdf = (__raw_readl(CCM_PCDR0) >> 6) & 0xf;
-       else
-               nfc_pdf = (__raw_readl(CCM_PCDR0) >> 12) & 0xf;
-
-       return parent_rate / (nfc_pdf + 1);
-}
-
-static unsigned long get_rate_vpu(struct clk *clk)
-{
-       unsigned long vpu_pdf;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       if (mx27_revision() >= IMX_CHIP_REVISION_2_0) {
-               vpu_pdf = (__raw_readl(CCM_PCDR0) >> 10) & 0x3f;
-               vpu_pdf += 4;
-       } else {
-               vpu_pdf = (__raw_readl(CCM_PCDR0) >> 8) & 0xf;
-               vpu_pdf = (vpu_pdf < 2) ? 124 : vpu_pdf;
-       }
-
-       return 2UL * parent_rate / vpu_pdf;
-}
-
-static unsigned long round_rate_parent(struct clk *clk, unsigned long rate)
-{
-       return clk->parent->round_rate(clk->parent, rate);
-}
-
-static unsigned long get_rate_parent(struct clk *clk)
-{
-       return clk_get_rate(clk->parent);
-}
-
-static int set_rate_parent(struct clk *clk, unsigned long rate)
-{
-       return clk->parent->set_rate(clk->parent, rate);
-}
-
-/* in Hz */
-static unsigned long external_high_reference = 26000000;
-
-static unsigned long get_rate_high_reference(struct clk *clk)
-{
-       return external_high_reference;
-}
-
-/* in Hz */
-static unsigned long external_low_reference = 32768;
-
-static unsigned long get_rate_low_reference(struct clk *clk)
-{
-       return external_low_reference;
-}
-
-static unsigned long get_rate_fpm(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) * 1024;
-}
-
-static unsigned long get_rate_mpll(struct clk *clk)
-{
-       return mxc_decode_pll(__raw_readl(CCM_MPCTL0),
-                       clk_get_rate(clk->parent));
-}
-
-static unsigned long get_rate_mpll_main(struct clk *clk)
-{
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       /* i.MX27 TO2:
-        * clk->id == 0: arm clock source path 1 which is from 2 * MPLL / 2
-        * clk->id == 1: arm clock source path 2 which is from 2 * MPLL / 3
-        */
-       if (mx27_revision() >= IMX_CHIP_REVISION_2_0 && clk->id == 1)
-               return 2UL * parent_rate / 3UL;
-
-       return parent_rate;
-}
-
-static unsigned long get_rate_spll(struct clk *clk)
-{
-       uint32_t reg;
-       unsigned long rate;
-
-       rate = clk_get_rate(clk->parent);
-
-       reg = __raw_readl(CCM_SPCTL0);
-
-       /* On TO2 we have to write the value back. Otherwise we
-        * read 0 from this register the next time.
-        */
-       if (mx27_revision() >= IMX_CHIP_REVISION_2_0)
-               __raw_writel(reg, CCM_SPCTL0);
-
-       return mxc_decode_pll(reg, rate);
-}
-
-static unsigned long get_rate_cpu(struct clk *clk)
-{
-       u32 div;
-       unsigned long rate;
-
-       if (mx27_revision() >= IMX_CHIP_REVISION_2_0)
-               div = (__raw_readl(CCM_CSCR) >> 12) & 0x3;
-       else
-               div = (__raw_readl(CCM_CSCR) >> 13) & 0x7;
-
-       rate = clk_get_rate(clk->parent);
-       return rate / (div + 1);
-}
-
-static unsigned long get_rate_ahb(struct clk *clk)
-{
-       unsigned long rate, bclk_pdf;
-
-       if (mx27_revision() >= IMX_CHIP_REVISION_2_0)
-               bclk_pdf = (__raw_readl(CCM_CSCR) >> 8) & 0x3;
-       else
-               bclk_pdf = (__raw_readl(CCM_CSCR) >> 9) & 0xf;
-
-       rate = clk_get_rate(clk->parent);
-       return rate / (bclk_pdf + 1);
-}
-
-static unsigned long get_rate_ipg(struct clk *clk)
-{
-       unsigned long rate, ipg_pdf;
-
-       if (mx27_revision() >= IMX_CHIP_REVISION_2_0)
-               return clk_get_rate(clk->parent);
-       else
-               ipg_pdf = (__raw_readl(CCM_CSCR) >> 8) & 1;
-
-       rate = clk_get_rate(clk->parent);
-       return rate / (ipg_pdf + 1);
-}
-
-static unsigned long get_rate_per(struct clk *clk)
-{
-       unsigned long perclk_pdf, parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       if (clk->id < 0 || clk->id > 3)
-               return 0;
-
-       perclk_pdf = (__raw_readl(CCM_PCDR1) >> (clk->id << 3)) & 0x3f;
-
-       return parent_rate / (perclk_pdf + 1);
-}
-
-/*
- * the high frequency external clock reference
- * Default case is 26MHz. Could be changed at runtime
- * with a call to change_external_high_reference()
- */
-static struct clk ckih_clk = {
-       .get_rate       = get_rate_high_reference,
-};
-
-static struct clk mpll_clk = {
-       .parent         = &ckih_clk,
-       .get_rate       = get_rate_mpll,
-};
-
-/* For i.MX27 TO2, it is the MPLL path 1 of ARM core
- * It provides the clock source whose rate is same as MPLL
- */
-static struct clk mpll_main1_clk = {
-       .id             = 0,
-       .parent         = &mpll_clk,
-       .get_rate       = get_rate_mpll_main,
-};
-
-/* For i.MX27 TO2, it is the MPLL path 2 of ARM core
- * It provides the clock source whose rate is same MPLL * 2 / 3
- */
-static struct clk mpll_main2_clk = {
-       .id             = 1,
-       .parent         = &mpll_clk,
-       .get_rate       = get_rate_mpll_main,
-};
-
-static struct clk ahb_clk = {
-       .parent         = &mpll_main2_clk,
-       .get_rate       = get_rate_ahb,
-};
-
-static struct clk ipg_clk = {
-       .parent         = &ahb_clk,
-       .get_rate       = get_rate_ipg,
-};
-
-static struct clk cpu_clk = {
-       .parent = &mpll_main2_clk,
-       .set_parent = clk_cpu_set_parent,
-       .round_rate = round_rate_cpu,
-       .get_rate = get_rate_cpu,
-       .set_rate = set_rate_cpu,
-};
-
-static struct clk spll_clk = {
-       .parent = &ckih_clk,
-       .get_rate = get_rate_spll,
-       .enable = clk_spll_enable,
-       .disable = clk_spll_disable,
-};
-
-/*
- * the low frequency external clock reference
- * Default case is 32.768kHz.
- */
-static struct clk ckil_clk = {
-       .get_rate = get_rate_low_reference,
-};
-
-/* Output of frequency pre multiplier */
-static struct clk fpm_clk = {
-       .parent = &ckil_clk,
-       .get_rate = get_rate_fpm,
-};
-
-#define PCCR0 CCM_PCCR0
-#define PCCR1 CCM_PCCR1
-
-#define DEFINE_CLOCK(name, i, er, es, gr, s, p)                \
-       static struct clk name = {                      \
-               .id             = i,                    \
-               .enable_reg     = er,                   \
-               .enable_shift   = es,                   \
-               .get_rate       = gr,                   \
-               .enable         = clk_pccr_enable,      \
-               .disable        = clk_pccr_disable,     \
-               .secondary      = s,                    \
-               .parent         = p,                    \
-       }
-
-#define DEFINE_CLOCK1(name, i, er, es, getsetround, s, p)      \
-       static struct clk name = {                              \
-               .id             = i,                            \
-               .enable_reg     = er,                           \
-               .enable_shift   = es,                           \
-               .get_rate       = get_rate_##getsetround,       \
-               .set_rate       = set_rate_##getsetround,       \
-               .round_rate     = round_rate_##getsetround,     \
-               .enable         = clk_pccr_enable,              \
-               .disable        = clk_pccr_disable,             \
-               .secondary      = s,                            \
-               .parent         = p,                            \
-       }
-
-/* Forward declaration to keep the following list in order */
-static struct clk slcdc_clk1, sahara2_clk1, rtic_clk1, fec_clk1, emma_clk1,
-                 dma_clk1, lcdc_clk2, vpu_clk1;
-
-/* All clocks we can gate through PCCRx in the order of PCCRx bits */
-DEFINE_CLOCK(ssi2_clk1,    1, PCCR0,  0, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(ssi1_clk1,    0, PCCR0,  1, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(slcdc_clk,    0, PCCR0,  2, NULL, &slcdc_clk1, &ahb_clk);
-DEFINE_CLOCK(sdhc3_clk1,   0, PCCR0,  3, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(sdhc2_clk1,   0, PCCR0,  4, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(sdhc1_clk1,   0, PCCR0,  5, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(scc_clk,      0, PCCR0,  6, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(sahara2_clk,  0, PCCR0,  7, NULL, &sahara2_clk1, &ahb_clk);
-DEFINE_CLOCK(rtic_clk,     0, PCCR0,  8, NULL, &rtic_clk1, &ahb_clk);
-DEFINE_CLOCK(rtc_clk,      0, PCCR0,  9, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(pwm_clk1,     0, PCCR0, 11, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(owire_clk,    0, PCCR0, 12, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(mstick_clk1,  0, PCCR0, 13, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(lcdc_clk1,    0, PCCR0, 14, NULL, &lcdc_clk2, &ipg_clk);
-DEFINE_CLOCK(kpp_clk,      0, PCCR0, 15, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(iim_clk,      0, PCCR0, 16, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(i2c2_clk,     1, PCCR0, 17, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(i2c1_clk,     0, PCCR0, 18, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(gpt6_clk1,    0, PCCR0, 29, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(gpt5_clk1,    0, PCCR0, 20, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(gpt4_clk1,    0, PCCR0, 21, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(gpt3_clk1,    0, PCCR0, 22, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(gpt2_clk1,    0, PCCR0, 23, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(gpt1_clk1,    0, PCCR0, 24, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(gpio_clk,     0, PCCR0, 25, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(fec_clk,      0, PCCR0, 26, NULL, &fec_clk1, &ahb_clk);
-DEFINE_CLOCK(emma_clk,     0, PCCR0, 27, NULL, &emma_clk1, &ahb_clk);
-DEFINE_CLOCK(dma_clk,      0, PCCR0, 28, NULL, &dma_clk1, &ahb_clk);
-DEFINE_CLOCK(cspi13_clk1,  0, PCCR0, 29, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(cspi2_clk1,   0, PCCR0, 30, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(cspi1_clk1,   0, PCCR0, 31, NULL, NULL, &ipg_clk);
-
-DEFINE_CLOCK(mstick_clk,   0, PCCR1,  2, NULL, &mstick_clk1, &ipg_clk);
-DEFINE_CLOCK(nfc_clk,      0, PCCR1,  3, get_rate_nfc, NULL, &cpu_clk);
-DEFINE_CLOCK(ssi2_clk,     1, PCCR1,  4, get_rate_ssi2, &ssi2_clk1, &mpll_main2_clk);
-DEFINE_CLOCK(ssi1_clk,     0, PCCR1,  5, get_rate_ssi1, &ssi1_clk1, &mpll_main2_clk);
-DEFINE_CLOCK(vpu_clk,      0, PCCR1,  6, get_rate_vpu, &vpu_clk1, &mpll_main2_clk);
-DEFINE_CLOCK1(per4_clk,    3, PCCR1,  7, per, NULL, &mpll_main2_clk);
-DEFINE_CLOCK1(per3_clk,    2, PCCR1,  8, per, NULL, &mpll_main2_clk);
-DEFINE_CLOCK1(per2_clk,    1, PCCR1,  9, per, NULL, &mpll_main2_clk);
-DEFINE_CLOCK1(per1_clk,    0, PCCR1, 10, per, NULL, &mpll_main2_clk);
-DEFINE_CLOCK(usb_clk1,     0, PCCR1, 11, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(slcdc_clk1,   0, PCCR1, 12, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(sahara2_clk1, 0, PCCR1, 13, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(rtic_clk1,    0, PCCR1, 14, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(lcdc_clk2,    0, PCCR1, 15, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(vpu_clk1,     0, PCCR1, 16, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(fec_clk1,     0, PCCR1, 17, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(emma_clk1,    0, PCCR1, 18, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(emi_clk,      0, PCCR1, 19, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(dma_clk1,     0, PCCR1, 20, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(csi_clk1,     0, PCCR1, 21, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(brom_clk,     0, PCCR1, 22, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(pata_clk,      0, PCCR1, 23, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(wdog_clk,     0, PCCR1, 24, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(usb_clk,      0, PCCR1, 25, get_rate_usb, &usb_clk1, &spll_clk);
-DEFINE_CLOCK(uart6_clk1,   0, PCCR1, 26, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(uart5_clk1,   0, PCCR1, 27, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(uart4_clk1,   0, PCCR1, 28, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(uart3_clk1,   0, PCCR1, 29, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(uart2_clk1,   0, PCCR1, 30, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(uart1_clk1,   0, PCCR1, 31, NULL, NULL, &ipg_clk);
-
-/* Clocks we cannot directly gate, but drivers need their rates */
-DEFINE_CLOCK(cspi1_clk,    0, NULL,   0, NULL, &cspi1_clk1, &per2_clk);
-DEFINE_CLOCK(cspi2_clk,    1, NULL,   0, NULL, &cspi2_clk1, &per2_clk);
-DEFINE_CLOCK(cspi3_clk,    2, NULL,   0, NULL, &cspi13_clk1, &per2_clk);
-DEFINE_CLOCK(sdhc1_clk,    0, NULL,   0, NULL, &sdhc1_clk1, &per2_clk);
-DEFINE_CLOCK(sdhc2_clk,    1, NULL,   0, NULL, &sdhc2_clk1, &per2_clk);
-DEFINE_CLOCK(sdhc3_clk,    2, NULL,   0, NULL, &sdhc3_clk1, &per2_clk);
-DEFINE_CLOCK(pwm_clk,      0, NULL,   0, NULL, &pwm_clk1, &per1_clk);
-DEFINE_CLOCK(gpt1_clk,     0, NULL,   0, NULL, &gpt1_clk1, &per1_clk);
-DEFINE_CLOCK(gpt2_clk,     1, NULL,   0, NULL, &gpt2_clk1, &per1_clk);
-DEFINE_CLOCK(gpt3_clk,     2, NULL,   0, NULL, &gpt3_clk1, &per1_clk);
-DEFINE_CLOCK(gpt4_clk,     3, NULL,   0, NULL, &gpt4_clk1, &per1_clk);
-DEFINE_CLOCK(gpt5_clk,     4, NULL,   0, NULL, &gpt5_clk1, &per1_clk);
-DEFINE_CLOCK(gpt6_clk,     5, NULL,   0, NULL, &gpt6_clk1, &per1_clk);
-DEFINE_CLOCK(uart1_clk,    0, NULL,   0, NULL, &uart1_clk1, &per1_clk);
-DEFINE_CLOCK(uart2_clk,    1, NULL,   0, NULL, &uart2_clk1, &per1_clk);
-DEFINE_CLOCK(uart3_clk,    2, NULL,   0, NULL, &uart3_clk1, &per1_clk);
-DEFINE_CLOCK(uart4_clk,    3, NULL,   0, NULL, &uart4_clk1, &per1_clk);
-DEFINE_CLOCK(uart5_clk,    4, NULL,   0, NULL, &uart5_clk1, &per1_clk);
-DEFINE_CLOCK(uart6_clk,    5, NULL,   0, NULL, &uart6_clk1, &per1_clk);
-DEFINE_CLOCK1(lcdc_clk,    0, NULL,   0, parent, &lcdc_clk1, &per3_clk);
-DEFINE_CLOCK1(csi_clk,     0, NULL,   0, parent, &csi_clk1, &per4_clk);
-
-#define _REGISTER_CLOCK(d, n, c) \
-       { \
-               .dev_id = d, \
-               .con_id = n, \
-               .clk = &c, \
-       },
-
-static struct clk_lookup lookups[] = {
-       /* i.mx27 has the i.mx21 type uart */
-       _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk)
-       _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk)
-       _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk)
-       _REGISTER_CLOCK("imx21-uart.3", NULL, uart4_clk)
-       _REGISTER_CLOCK("imx21-uart.4", NULL, uart5_clk)
-       _REGISTER_CLOCK("imx21-uart.5", NULL, uart6_clk)
-       _REGISTER_CLOCK(NULL, "gpt1", gpt1_clk)
-       _REGISTER_CLOCK(NULL, "gpt2", gpt2_clk)
-       _REGISTER_CLOCK(NULL, "gpt3", gpt3_clk)
-       _REGISTER_CLOCK(NULL, "gpt4", gpt4_clk)
-       _REGISTER_CLOCK(NULL, "gpt5", gpt5_clk)
-       _REGISTER_CLOCK(NULL, "gpt6", gpt6_clk)
-       _REGISTER_CLOCK("mxc_pwm.0", NULL, pwm_clk)
-       _REGISTER_CLOCK("mxc-mmc.0", NULL, sdhc1_clk)
-       _REGISTER_CLOCK("mxc-mmc.1", NULL, sdhc2_clk)
-       _REGISTER_CLOCK("mxc-mmc.2", NULL, sdhc3_clk)
-       _REGISTER_CLOCK("imx27-cspi.0", NULL, cspi1_clk)
-       _REGISTER_CLOCK("imx27-cspi.1", NULL, cspi2_clk)
-       _REGISTER_CLOCK("imx27-cspi.2", NULL, cspi3_clk)
-       _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk)
-       _REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk)
-       _REGISTER_CLOCK("fsl-usb2-udc", "usb", usb_clk)
-       _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", usb_clk1)
-       _REGISTER_CLOCK("mxc-ehci.0", "usb", usb_clk)
-       _REGISTER_CLOCK("mxc-ehci.0", "usb_ahb", usb_clk1)
-       _REGISTER_CLOCK("mxc-ehci.1", "usb", usb_clk)
-       _REGISTER_CLOCK("mxc-ehci.1", "usb_ahb", usb_clk1)
-       _REGISTER_CLOCK("mxc-ehci.2", "usb", usb_clk)
-       _REGISTER_CLOCK("mxc-ehci.2", "usb_ahb", usb_clk1)
-       _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
-       _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
-       _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk)
-       _REGISTER_CLOCK(NULL, "vpu", vpu_clk)
-       _REGISTER_CLOCK(NULL, "dma", dma_clk)
-       _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
-       _REGISTER_CLOCK(NULL, "brom", brom_clk)
-       _REGISTER_CLOCK(NULL, "emma", emma_clk)
-       _REGISTER_CLOCK("m2m-emmaprp.0", NULL, emma_clk)
-       _REGISTER_CLOCK(NULL, "slcdc", slcdc_clk)
-       _REGISTER_CLOCK("imx27-fec.0", NULL, fec_clk)
-       _REGISTER_CLOCK(NULL, "emi", emi_clk)
-       _REGISTER_CLOCK(NULL, "sahara2", sahara2_clk)
-       _REGISTER_CLOCK("pata_imx", NULL, pata_clk)
-       _REGISTER_CLOCK(NULL, "mstick", mstick_clk)
-       _REGISTER_CLOCK("imx2-wdt.0", NULL, wdog_clk)
-       _REGISTER_CLOCK(NULL, "gpio", gpio_clk)
-       _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
-       _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
-       _REGISTER_CLOCK(NULL, "iim", iim_clk)
-       _REGISTER_CLOCK(NULL, "kpp", kpp_clk)
-       _REGISTER_CLOCK("mxc_w1.0", NULL, owire_clk)
-       _REGISTER_CLOCK(NULL, "rtc", rtc_clk)
-       _REGISTER_CLOCK(NULL, "scc", scc_clk)
-};
-
-/* Adjust the clock path for TO2 and later */
-static void __init to2_adjust_clocks(void)
-{
-       unsigned long cscr = __raw_readl(CCM_CSCR);
-
-       if (mx27_revision() >= IMX_CHIP_REVISION_2_0) {
-               if (cscr & CCM_CSCR_ARM_SRC)
-                       cpu_clk.parent = &mpll_main1_clk;
-
-               if (!(cscr & CCM_CSCR_SSI2))
-                       ssi1_clk.parent = &spll_clk;
-
-               if (!(cscr & CCM_CSCR_SSI1))
-                       ssi1_clk.parent = &spll_clk;
-
-               if (!(cscr & CCM_CSCR_VPU))
-                       vpu_clk.parent = &spll_clk;
-       } else {
-               cpu_clk.parent = &mpll_clk;
-               cpu_clk.set_parent = NULL;
-               cpu_clk.round_rate = NULL;
-               cpu_clk.set_rate = NULL;
-               ahb_clk.parent = &mpll_clk;
-
-               per1_clk.parent = &mpll_clk;
-               per2_clk.parent = &mpll_clk;
-               per3_clk.parent = &mpll_clk;
-               per4_clk.parent = &mpll_clk;
-
-               ssi1_clk.parent = &mpll_clk;
-               ssi2_clk.parent = &mpll_clk;
-
-               vpu_clk.parent = &mpll_clk;
-       }
-}
-
-/*
- * must be called very early to get information about the
- * available clock rate when the timer framework starts
- */
-int __init mx27_clocks_init(unsigned long fref)
-{
-       u32 cscr = __raw_readl(CCM_CSCR);
-
-       external_high_reference = fref;
-
-       /* detect clock reference for both system PLLs */
-       if (cscr & CCM_CSCR_MCU)
-               mpll_clk.parent = &ckih_clk;
-       else
-               mpll_clk.parent = &fpm_clk;
-
-       if (cscr & CCM_CSCR_SP)
-               spll_clk.parent = &ckih_clk;
-       else
-               spll_clk.parent = &fpm_clk;
-
-       to2_adjust_clocks();
-
-       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
-       /* Turn off all clocks we do not need */
-       __raw_writel(0, CCM_PCCR0);
-       __raw_writel((1 << 10) | (1 << 19), CCM_PCCR1);
-
-       spll_clk.disable(&spll_clk);
-
-       /* enable basic clocks */
-       clk_enable(&per1_clk);
-       clk_enable(&gpio_clk);
-       clk_enable(&emi_clk);
-       clk_enable(&iim_clk);
-       imx_print_silicon_rev("i.MX27", mx27_revision());
-       clk_disable(&iim_clk);
-
-#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC)
-       clk_enable(&uart1_clk);
-#endif
-
-       mxc_timer_init(&gpt1_clk, MX27_IO_ADDRESS(MX27_GPT1_BASE_ADDR),
-                       MX27_INT_GPT1);
-
-       return 0;
-}
-
-#ifdef CONFIG_OF
-int __init mx27_clocks_init_dt(void)
-{
-       struct device_node *np;
-       u32 fref = 26000000; /* default */
-
-       for_each_compatible_node(np, NULL, "fixed-clock") {
-               if (!of_device_is_compatible(np, "fsl,imx-osc26m"))
-                       continue;
-
-               if (!of_property_read_u32(np, "clock-frequency", &fref))
-                       break;
-       }
-
-       return mx27_clocks_init(fref);
-}
-#endif
diff --git a/arch/arm/mach-imx/clock-imx31.c b/arch/arm/mach-imx/clock-imx31.c
deleted file mode 100644 (file)
index 3a943cd..0000000
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
- * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-
-#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/io.h>
-#include <linux/clkdev.h>
-
-#include <asm/div64.h>
-
-#include <mach/clock.h>
-#include <mach/hardware.h>
-#include <mach/mx31.h>
-#include <mach/common.h>
-
-#include "crmregs-imx3.h"
-
-#define PRE_DIV_MIN_FREQ    10000000 /* Minimum Frequency after Predivider */
-
-static void __calc_pre_post_dividers(u32 div, u32 *pre, u32 *post)
-{
-       u32 min_pre, temp_pre, old_err, err;
-
-       if (div >= 512) {
-               *pre = 8;
-               *post = 64;
-       } else if (div >= 64) {
-               min_pre = (div - 1) / 64 + 1;
-               old_err = 8;
-               for (temp_pre = 8; temp_pre >= min_pre; temp_pre--) {
-                       err = div % temp_pre;
-                       if (err == 0) {
-                               *pre = temp_pre;
-                               break;
-                       }
-                       err = temp_pre - err;
-                       if (err < old_err) {
-                               old_err = err;
-                               *pre = temp_pre;
-                       }
-               }
-               *post = (div + *pre - 1) / *pre;
-       } else if (div <= 8) {
-               *pre = div;
-               *post = 1;
-       } else {
-               *pre = 1;
-               *post = div;
-       }
-}
-
-static struct clk mcu_pll_clk;
-static struct clk serial_pll_clk;
-static struct clk ipg_clk;
-static struct clk ckih_clk;
-
-static int cgr_enable(struct clk *clk)
-{
-       u32 reg;
-
-       if (!clk->enable_reg)
-               return 0;
-
-       reg = __raw_readl(clk->enable_reg);
-       reg |= 3 << clk->enable_shift;
-       __raw_writel(reg, clk->enable_reg);
-
-       return 0;
-}
-
-static void cgr_disable(struct clk *clk)
-{
-       u32 reg;
-
-       if (!clk->enable_reg)
-               return;
-
-       reg = __raw_readl(clk->enable_reg);
-       reg &= ~(3 << clk->enable_shift);
-
-       /* special case for EMI clock */
-       if (clk->enable_reg == MXC_CCM_CGR2 && clk->enable_shift == 8)
-               reg |= (1 << clk->enable_shift);
-
-       __raw_writel(reg, clk->enable_reg);
-}
-
-static unsigned long pll_ref_get_rate(void)
-{
-       unsigned long ccmr;
-       unsigned int prcs;
-
-       ccmr = __raw_readl(MXC_CCM_CCMR);
-       prcs = (ccmr & MXC_CCM_CCMR_PRCS_MASK) >> MXC_CCM_CCMR_PRCS_OFFSET;
-       if (prcs == 0x1)
-               return CKIL_CLK_FREQ * 1024;
-       else
-               return clk_get_rate(&ckih_clk);
-}
-
-static unsigned long usb_pll_get_rate(struct clk *clk)
-{
-       unsigned long reg;
-
-       reg = __raw_readl(MXC_CCM_UPCTL);
-
-       return mxc_decode_pll(reg, pll_ref_get_rate());
-}
-
-static unsigned long serial_pll_get_rate(struct clk *clk)
-{
-       unsigned long reg;
-
-       reg = __raw_readl(MXC_CCM_SRPCTL);
-
-       return mxc_decode_pll(reg, pll_ref_get_rate());
-}
-
-static unsigned long mcu_pll_get_rate(struct clk *clk)
-{
-       unsigned long reg, ccmr;
-
-       ccmr = __raw_readl(MXC_CCM_CCMR);
-
-       if (!(ccmr & MXC_CCM_CCMR_MPE) || (ccmr & MXC_CCM_CCMR_MDS))
-               return clk_get_rate(&ckih_clk);
-
-       reg = __raw_readl(MXC_CCM_MPCTL);
-
-       return mxc_decode_pll(reg, pll_ref_get_rate());
-}
-
-static int usb_pll_enable(struct clk *clk)
-{
-       u32 reg;
-
-       reg = __raw_readl(MXC_CCM_CCMR);
-       reg |= MXC_CCM_CCMR_UPE;
-       __raw_writel(reg, MXC_CCM_CCMR);
-
-       /* No lock bit on MX31, so using max time from spec */
-       udelay(80);
-
-       return 0;
-}
-
-static void usb_pll_disable(struct clk *clk)
-{
-       u32 reg;
-
-       reg = __raw_readl(MXC_CCM_CCMR);
-       reg &= ~MXC_CCM_CCMR_UPE;
-       __raw_writel(reg, MXC_CCM_CCMR);
-}
-
-static int serial_pll_enable(struct clk *clk)
-{
-       u32 reg;
-
-       reg = __raw_readl(MXC_CCM_CCMR);
-       reg |= MXC_CCM_CCMR_SPE;
-       __raw_writel(reg, MXC_CCM_CCMR);
-
-       /* No lock bit on MX31, so using max time from spec */
-       udelay(80);
-
-       return 0;
-}
-
-static void serial_pll_disable(struct clk *clk)
-{
-       u32 reg;
-
-       reg = __raw_readl(MXC_CCM_CCMR);
-       reg &= ~MXC_CCM_CCMR_SPE;
-       __raw_writel(reg, MXC_CCM_CCMR);
-}
-
-#define PDR0(mask, off) ((__raw_readl(MXC_CCM_PDR0) & mask) >> off)
-#define PDR1(mask, off) ((__raw_readl(MXC_CCM_PDR1) & mask) >> off)
-#define PDR2(mask, off) ((__raw_readl(MXC_CCM_PDR2) & mask) >> off)
-
-static unsigned long mcu_main_get_rate(struct clk *clk)
-{
-       u32 pmcr0 = __raw_readl(MXC_CCM_PMCR0);
-
-       if ((pmcr0 & MXC_CCM_PMCR0_DFSUP1) == MXC_CCM_PMCR0_DFSUP1_SPLL)
-               return clk_get_rate(&serial_pll_clk);
-       else
-               return clk_get_rate(&mcu_pll_clk);
-}
-
-static unsigned long ahb_get_rate(struct clk *clk)
-{
-       unsigned long max_pdf;
-
-       max_pdf = PDR0(MXC_CCM_PDR0_MAX_PODF_MASK,
-                      MXC_CCM_PDR0_MAX_PODF_OFFSET);
-       return clk_get_rate(clk->parent) / (max_pdf + 1);
-}
-
-static unsigned long ipg_get_rate(struct clk *clk)
-{
-       unsigned long ipg_pdf;
-
-       ipg_pdf = PDR0(MXC_CCM_PDR0_IPG_PODF_MASK,
-                      MXC_CCM_PDR0_IPG_PODF_OFFSET);
-       return clk_get_rate(clk->parent) / (ipg_pdf + 1);
-}
-
-static unsigned long nfc_get_rate(struct clk *clk)
-{
-       unsigned long nfc_pdf;
-
-       nfc_pdf = PDR0(MXC_CCM_PDR0_NFC_PODF_MASK,
-                      MXC_CCM_PDR0_NFC_PODF_OFFSET);
-       return clk_get_rate(clk->parent) / (nfc_pdf + 1);
-}
-
-static unsigned long hsp_get_rate(struct clk *clk)
-{
-       unsigned long hsp_pdf;
-
-       hsp_pdf = PDR0(MXC_CCM_PDR0_HSP_PODF_MASK,
-                      MXC_CCM_PDR0_HSP_PODF_OFFSET);
-       return clk_get_rate(clk->parent) / (hsp_pdf + 1);
-}
-
-static unsigned long usb_get_rate(struct clk *clk)
-{
-       unsigned long usb_pdf, usb_prepdf;
-
-       usb_pdf = PDR1(MXC_CCM_PDR1_USB_PODF_MASK,
-                      MXC_CCM_PDR1_USB_PODF_OFFSET);
-       usb_prepdf = PDR1(MXC_CCM_PDR1_USB_PRDF_MASK,
-                         MXC_CCM_PDR1_USB_PRDF_OFFSET);
-       return clk_get_rate(clk->parent) / (usb_prepdf + 1) / (usb_pdf + 1);
-}
-
-static unsigned long csi_get_rate(struct clk *clk)
-{
-       u32 reg, pre, post;
-
-       reg = __raw_readl(MXC_CCM_PDR0);
-       pre = (reg & MXC_CCM_PDR0_CSI_PRDF_MASK) >>
-           MXC_CCM_PDR0_CSI_PRDF_OFFSET;
-       pre++;
-       post = (reg & MXC_CCM_PDR0_CSI_PODF_MASK) >>
-           MXC_CCM_PDR0_CSI_PODF_OFFSET;
-       post++;
-       return clk_get_rate(clk->parent) / (pre * post);
-}
-
-static unsigned long csi_round_rate(struct clk *clk, unsigned long rate)
-{
-       u32 pre, post, parent = clk_get_rate(clk->parent);
-       u32 div = parent / rate;
-
-       if (parent % rate)
-               div++;
-
-       __calc_pre_post_dividers(div, &pre, &post);
-
-       return parent / (pre * post);
-}
-
-static int csi_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 reg, div, pre, post, parent = clk_get_rate(clk->parent);
-
-       div = parent / rate;
-
-       if ((parent / div) != rate)
-               return -EINVAL;
-
-       __calc_pre_post_dividers(div, &pre, &post);
-
-       /* Set CSI clock divider */
-       reg = __raw_readl(MXC_CCM_PDR0) &
-           ~(MXC_CCM_PDR0_CSI_PODF_MASK | MXC_CCM_PDR0_CSI_PRDF_MASK);
-       reg |= (post - 1) << MXC_CCM_PDR0_CSI_PODF_OFFSET;
-       reg |= (pre - 1) << MXC_CCM_PDR0_CSI_PRDF_OFFSET;
-       __raw_writel(reg, MXC_CCM_PDR0);
-
-       return 0;
-}
-
-static unsigned long ssi1_get_rate(struct clk *clk)
-{
-       unsigned long ssi1_pdf, ssi1_prepdf;
-
-       ssi1_pdf = PDR1(MXC_CCM_PDR1_SSI1_PODF_MASK,
-                       MXC_CCM_PDR1_SSI1_PODF_OFFSET);
-       ssi1_prepdf = PDR1(MXC_CCM_PDR1_SSI1_PRE_PODF_MASK,
-                          MXC_CCM_PDR1_SSI1_PRE_PODF_OFFSET);
-       return clk_get_rate(clk->parent) / (ssi1_prepdf + 1) / (ssi1_pdf + 1);
-}
-
-static unsigned long ssi2_get_rate(struct clk *clk)
-{
-       unsigned long ssi2_pdf, ssi2_prepdf;
-
-       ssi2_pdf = PDR1(MXC_CCM_PDR1_SSI2_PODF_MASK,
-                       MXC_CCM_PDR1_SSI2_PODF_OFFSET);
-       ssi2_prepdf = PDR1(MXC_CCM_PDR1_SSI2_PRE_PODF_MASK,
-                          MXC_CCM_PDR1_SSI2_PRE_PODF_OFFSET);
-       return clk_get_rate(clk->parent) / (ssi2_prepdf + 1) / (ssi2_pdf + 1);
-}
-
-static unsigned long firi_get_rate(struct clk *clk)
-{
-       unsigned long firi_pdf, firi_prepdf;
-
-       firi_pdf = PDR1(MXC_CCM_PDR1_FIRI_PODF_MASK,
-                       MXC_CCM_PDR1_FIRI_PODF_OFFSET);
-       firi_prepdf = PDR1(MXC_CCM_PDR1_FIRI_PRE_PODF_MASK,
-                          MXC_CCM_PDR1_FIRI_PRE_PODF_OFFSET);
-       return clk_get_rate(clk->parent) / (firi_prepdf + 1) / (firi_pdf + 1);
-}
-
-static unsigned long firi_round_rate(struct clk *clk, unsigned long rate)
-{
-       u32 pre, post;
-       u32 parent = clk_get_rate(clk->parent);
-       u32 div = parent / rate;
-
-       if (parent % rate)
-               div++;
-
-       __calc_pre_post_dividers(div, &pre, &post);
-
-       return parent / (pre * post);
-
-}
-
-static int firi_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 reg, div, pre, post, parent = clk_get_rate(clk->parent);
-
-       div = parent / rate;
-
-       if ((parent / div) != rate)
-               return -EINVAL;
-
-       __calc_pre_post_dividers(div, &pre, &post);
-
-       /* Set FIRI clock divider */
-       reg = __raw_readl(MXC_CCM_PDR1) &
-           ~(MXC_CCM_PDR1_FIRI_PODF_MASK | MXC_CCM_PDR1_FIRI_PRE_PODF_MASK);
-       reg |= (pre - 1) << MXC_CCM_PDR1_FIRI_PRE_PODF_OFFSET;
-       reg |= (post - 1) << MXC_CCM_PDR1_FIRI_PODF_OFFSET;
-       __raw_writel(reg, MXC_CCM_PDR1);
-
-       return 0;
-}
-
-static unsigned long mbx_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / 2;
-}
-
-static unsigned long mstick1_get_rate(struct clk *clk)
-{
-       unsigned long msti_pdf;
-
-       msti_pdf = PDR2(MXC_CCM_PDR2_MST1_PDF_MASK,
-                       MXC_CCM_PDR2_MST1_PDF_OFFSET);
-       return clk_get_rate(clk->parent) / (msti_pdf + 1);
-}
-
-static unsigned long mstick2_get_rate(struct clk *clk)
-{
-       unsigned long msti_pdf;
-
-       msti_pdf = PDR2(MXC_CCM_PDR2_MST2_PDF_MASK,
-                       MXC_CCM_PDR2_MST2_PDF_OFFSET);
-       return clk_get_rate(clk->parent) / (msti_pdf + 1);
-}
-
-static unsigned long ckih_rate;
-
-static unsigned long clk_ckih_get_rate(struct clk *clk)
-{
-       return ckih_rate;
-}
-
-static unsigned long clk_ckil_get_rate(struct clk *clk)
-{
-       return CKIL_CLK_FREQ;
-}
-
-static struct clk ckih_clk = {
-       .get_rate = clk_ckih_get_rate,
-};
-
-static struct clk mcu_pll_clk = {
-       .parent = &ckih_clk,
-       .get_rate = mcu_pll_get_rate,
-};
-
-static struct clk mcu_main_clk = {
-       .parent = &mcu_pll_clk,
-       .get_rate = mcu_main_get_rate,
-};
-
-static struct clk serial_pll_clk = {
-       .parent = &ckih_clk,
-       .get_rate = serial_pll_get_rate,
-       .enable = serial_pll_enable,
-       .disable = serial_pll_disable,
-};
-
-static struct clk usb_pll_clk = {
-       .parent = &ckih_clk,
-       .get_rate = usb_pll_get_rate,
-       .enable = usb_pll_enable,
-       .disable = usb_pll_disable,
-};
-
-static struct clk ahb_clk = {
-       .parent = &mcu_main_clk,
-       .get_rate = ahb_get_rate,
-};
-
-#define DEFINE_CLOCK(name, i, er, es, gr, s, p)                \
-       static struct clk name = {                      \
-               .id             = i,                    \
-               .enable_reg     = er,                   \
-               .enable_shift   = es,                   \
-               .get_rate       = gr,                   \
-               .enable         = cgr_enable,           \
-               .disable        = cgr_disable,          \
-               .secondary      = s,                    \
-               .parent         = p,                    \
-       }
-
-#define DEFINE_CLOCK1(name, i, er, es, getsetround, s, p)      \
-       static struct clk name = {                              \
-               .id             = i,                            \
-               .enable_reg     = er,                           \
-               .enable_shift   = es,                           \
-               .get_rate       = getsetround##_get_rate,       \
-               .set_rate       = getsetround##_set_rate,       \
-               .round_rate     = getsetround##_round_rate,     \
-               .enable         = cgr_enable,                   \
-               .disable        = cgr_disable,                  \
-               .secondary      = s,                            \
-               .parent         = p,                            \
-       }
-
-DEFINE_CLOCK(perclk_clk,  0, NULL,          0, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(ckil_clk,    0, NULL,          0, clk_ckil_get_rate, NULL, NULL);
-
-DEFINE_CLOCK(sdhc1_clk,   0, MXC_CCM_CGR0,  0, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(sdhc2_clk,   1, MXC_CCM_CGR0,  2, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(gpt_clk,     0, MXC_CCM_CGR0,  4, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(epit1_clk,   0, MXC_CCM_CGR0,  6, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(epit2_clk,   1, MXC_CCM_CGR0,  8, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(iim_clk,     0, MXC_CCM_CGR0, 10, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(pata_clk,     0, MXC_CCM_CGR0, 12, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(sdma_clk1,   0, MXC_CCM_CGR0, 14, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(cspi3_clk,   2, MXC_CCM_CGR0, 16, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(rng_clk,     0, MXC_CCM_CGR0, 18, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(uart1_clk,   0, MXC_CCM_CGR0, 20, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(uart2_clk,   1, MXC_CCM_CGR0, 22, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(ssi1_clk,    0, MXC_CCM_CGR0, 24, ssi1_get_rate, NULL, &serial_pll_clk);
-DEFINE_CLOCK(i2c1_clk,    0, MXC_CCM_CGR0, 26, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(i2c2_clk,    1, MXC_CCM_CGR0, 28, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(i2c3_clk,    2, MXC_CCM_CGR0, 30, NULL, NULL, &perclk_clk);
-
-DEFINE_CLOCK(mpeg4_clk,   0, MXC_CCM_CGR1,  0, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(mstick1_clk, 0, MXC_CCM_CGR1,  2, mstick1_get_rate, NULL, &usb_pll_clk);
-DEFINE_CLOCK(mstick2_clk, 1, MXC_CCM_CGR1,  4, mstick2_get_rate, NULL, &usb_pll_clk);
-DEFINE_CLOCK1(csi_clk,    0, MXC_CCM_CGR1,  6, csi, NULL, &serial_pll_clk);
-DEFINE_CLOCK(rtc_clk,     0, MXC_CCM_CGR1,  8, NULL, NULL, &ckil_clk);
-DEFINE_CLOCK(wdog_clk,    0, MXC_CCM_CGR1, 10, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(pwm_clk,     0, MXC_CCM_CGR1, 12, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(usb_clk2,    0, MXC_CCM_CGR1, 18, usb_get_rate, NULL, &ahb_clk);
-DEFINE_CLOCK(kpp_clk,     0, MXC_CCM_CGR1, 20, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(ipu_clk,     0, MXC_CCM_CGR1, 22, hsp_get_rate, NULL, &mcu_main_clk);
-DEFINE_CLOCK(uart3_clk,   2, MXC_CCM_CGR1, 24, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(uart4_clk,   3, MXC_CCM_CGR1, 26, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(uart5_clk,   4, MXC_CCM_CGR1, 28, NULL, NULL, &perclk_clk);
-DEFINE_CLOCK(owire_clk,   0, MXC_CCM_CGR1, 30, NULL, NULL, &perclk_clk);
-
-DEFINE_CLOCK(ssi2_clk,    1, MXC_CCM_CGR2,  0, ssi2_get_rate, NULL, &serial_pll_clk);
-DEFINE_CLOCK(cspi1_clk,   0, MXC_CCM_CGR2,  2, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(cspi2_clk,   1, MXC_CCM_CGR2,  4, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(mbx_clk,     0, MXC_CCM_CGR2,  6, mbx_get_rate, NULL, &ahb_clk);
-DEFINE_CLOCK(emi_clk,     0, MXC_CCM_CGR2,  8, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK(rtic_clk,    0, MXC_CCM_CGR2, 10, NULL, NULL, &ahb_clk);
-DEFINE_CLOCK1(firi_clk,   0, MXC_CCM_CGR2, 12, firi, NULL, &usb_pll_clk);
-
-DEFINE_CLOCK(sdma_clk2,   0, NULL,          0, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(usb_clk1,    0, NULL,          0, usb_get_rate, NULL, &usb_pll_clk);
-DEFINE_CLOCK(nfc_clk,     0, NULL,          0, nfc_get_rate, NULL, &ahb_clk);
-DEFINE_CLOCK(scc_clk,     0, NULL,          0, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(ipg_clk,     0, NULL,          0, ipg_get_rate, NULL, &ahb_clk);
-
-#define _REGISTER_CLOCK(d, n, c) \
-       { \
-               .dev_id = d, \
-               .con_id = n, \
-               .clk = &c, \
-       },
-
-static struct clk_lookup lookups[] = {
-       _REGISTER_CLOCK(NULL, "emi", emi_clk)
-       _REGISTER_CLOCK("imx31-cspi.0", NULL, cspi1_clk)
-       _REGISTER_CLOCK("imx31-cspi.1", NULL, cspi2_clk)
-       _REGISTER_CLOCK("imx31-cspi.2", NULL, cspi3_clk)
-       _REGISTER_CLOCK(NULL, "gpt", gpt_clk)
-       _REGISTER_CLOCK(NULL, "pwm", pwm_clk)
-       _REGISTER_CLOCK("imx2-wdt.0", NULL, wdog_clk)
-       _REGISTER_CLOCK(NULL, "rtc", rtc_clk)
-       _REGISTER_CLOCK(NULL, "epit", epit1_clk)
-       _REGISTER_CLOCK(NULL, "epit", epit2_clk)
-       _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk)
-       _REGISTER_CLOCK("ipu-core", NULL, ipu_clk)
-       _REGISTER_CLOCK("mx3_sdc_fb", NULL, ipu_clk)
-       _REGISTER_CLOCK(NULL, "kpp", kpp_clk)
-       _REGISTER_CLOCK("mxc-ehci.0", "usb", usb_clk1)
-       _REGISTER_CLOCK("mxc-ehci.0", "usb_ahb", usb_clk2)
-       _REGISTER_CLOCK("mxc-ehci.1", "usb", usb_clk1)
-       _REGISTER_CLOCK("mxc-ehci.1", "usb_ahb", usb_clk2)
-       _REGISTER_CLOCK("mxc-ehci.2", "usb", usb_clk1)
-       _REGISTER_CLOCK("mxc-ehci.2", "usb_ahb", usb_clk2)
-       _REGISTER_CLOCK("fsl-usb2-udc", "usb", usb_clk1)
-       _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", usb_clk2)
-       _REGISTER_CLOCK("mx3-camera.0", NULL, csi_clk)
-       /* i.mx31 has the i.mx21 type uart */
-       _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk)
-       _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk)
-       _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk)
-       _REGISTER_CLOCK("imx21-uart.3", NULL, uart4_clk)
-       _REGISTER_CLOCK("imx21-uart.4", NULL, uart5_clk)
-       _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
-       _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
-       _REGISTER_CLOCK("imx-i2c.2", NULL, i2c3_clk)
-       _REGISTER_CLOCK("mxc_w1.0", NULL, owire_clk)
-       _REGISTER_CLOCK("mxc-mmc.0", NULL, sdhc1_clk)
-       _REGISTER_CLOCK("mxc-mmc.1", NULL, sdhc2_clk)
-       _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
-       _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
-       _REGISTER_CLOCK(NULL, "firi", firi_clk)
-       _REGISTER_CLOCK("pata_imx", NULL, pata_clk)
-       _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
-       _REGISTER_CLOCK(NULL, "rng", rng_clk)
-       _REGISTER_CLOCK("imx31-sdma", NULL, sdma_clk1)
-       _REGISTER_CLOCK(NULL, "sdma_ipg", sdma_clk2)
-       _REGISTER_CLOCK(NULL, "mstick", mstick1_clk)
-       _REGISTER_CLOCK(NULL, "mstick", mstick2_clk)
-       _REGISTER_CLOCK(NULL, "scc", scc_clk)
-       _REGISTER_CLOCK(NULL, "iim", iim_clk)
-       _REGISTER_CLOCK(NULL, "mpeg4", mpeg4_clk)
-       _REGISTER_CLOCK(NULL, "mbx", mbx_clk)
-};
-
-int __init mx31_clocks_init(unsigned long fref)
-{
-       u32 reg;
-
-       ckih_rate = fref;
-
-       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
-       /* change the csi_clk parent if necessary */
-       reg = __raw_readl(MXC_CCM_CCMR);
-       if (!(reg & MXC_CCM_CCMR_CSCS))
-               if (clk_set_parent(&csi_clk, &usb_pll_clk))
-                       pr_err("%s: error changing csi_clk parent\n", __func__);
-
-
-       /* Turn off all possible clocks */
-       __raw_writel((3 << 4), MXC_CCM_CGR0);
-       __raw_writel(0, MXC_CCM_CGR1);
-       __raw_writel((3 << 8) | (3 << 14) | (3 << 16)|
-                    1 << 27 | 1 << 28, /* Bit 27 and 28 are not defined for
-                                          MX32, but still required to be set */
-                    MXC_CCM_CGR2);
-
-       /*
-        * Before turning off usb_pll make sure ipg_per_clk is generated
-        * by ipg_clk and not usb_pll.
-        */
-       __raw_writel(__raw_readl(MXC_CCM_CCMR) | (1 << 24), MXC_CCM_CCMR);
-
-       usb_pll_disable(&usb_pll_clk);
-
-       pr_info("Clock input source is %ld\n", clk_get_rate(&ckih_clk));
-
-       clk_enable(&gpt_clk);
-       clk_enable(&emi_clk);
-       clk_enable(&iim_clk);
-       mx31_revision();
-       clk_disable(&iim_clk);
-
-       clk_enable(&serial_pll_clk);
-
-       if (mx31_revision() >= IMX_CHIP_REVISION_2_0) {
-               reg = __raw_readl(MXC_CCM_PMCR1);
-               /* No PLL restart on DVFS switch; enable auto EMI handshake */
-               reg |= MXC_CCM_PMCR1_PLLRDIS | MXC_CCM_PMCR1_EMIRQ_EN;
-               __raw_writel(reg, MXC_CCM_PMCR1);
-       }
-
-       mxc_timer_init(&ipg_clk, MX31_IO_ADDRESS(MX31_GPT1_BASE_ADDR),
-                       MX31_INT_GPT);
-
-       return 0;
-}
diff --git a/arch/arm/mach-imx/clock-imx35.c b/arch/arm/mach-imx/clock-imx35.c
deleted file mode 100644 (file)
index e56c1a8..0000000
+++ /dev/null
@@ -1,536 +0,0 @@
-/*
- * Copyright (C) 2009 by Sascha Hauer, Pengutronix
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/list.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/clkdev.h>
-
-#include <mach/clock.h>
-#include <mach/hardware.h>
-#include <mach/common.h>
-
-#include "crmregs-imx3.h"
-
-#ifdef HAVE_SET_RATE_SUPPORT
-static void calc_dividers(u32 div, u32 *pre, u32 *post, u32 maxpost)
-{
-       u32 min_pre, temp_pre, old_err, err;
-
-       min_pre = (div - 1) / maxpost + 1;
-       old_err = 8;
-
-       for (temp_pre = 8; temp_pre >= min_pre; temp_pre--) {
-               if (div > (temp_pre * maxpost))
-                       break;
-
-               if (div < (temp_pre * temp_pre))
-                       continue;
-
-               err = div % temp_pre;
-
-               if (err == 0) {
-                       *pre = temp_pre;
-                       break;
-               }
-
-               err = temp_pre - err;
-
-               if (err < old_err) {
-                       old_err = err;
-                       *pre = temp_pre;
-               }
-       }
-
-       *post = (div + *pre - 1) / *pre;
-}
-
-/* get the best values for a 3-bit divider combined with a 6-bit divider */
-static void calc_dividers_3_6(u32 div, u32 *pre, u32 *post)
-{
-       if (div >= 512) {
-               *pre = 8;
-               *post = 64;
-       } else if (div >= 64) {
-               calc_dividers(div, pre, post, 64);
-       } else if (div <= 8) {
-               *pre = div;
-               *post = 1;
-       } else {
-               *pre = 1;
-               *post = div;
-       }
-}
-
-/* get the best values for two cascaded 3-bit dividers */
-static void calc_dividers_3_3(u32 div, u32 *pre, u32 *post)
-{
-       if (div >= 64) {
-               *pre = *post = 8;
-       } else if (div > 8) {
-               calc_dividers(div, pre, post, 8);
-       } else {
-               *pre = 1;
-               *post = div;
-       }
-}
-#endif
-
-static unsigned long get_rate_mpll(void)
-{
-       ulong mpctl = __raw_readl(MX35_CCM_MPCTL);
-
-       return mxc_decode_pll(mpctl, 24000000);
-}
-
-static unsigned long get_rate_ppll(void)
-{
-       ulong ppctl = __raw_readl(MX35_CCM_PPCTL);
-
-       return mxc_decode_pll(ppctl, 24000000);
-}
-
-struct arm_ahb_div {
-       unsigned char arm, ahb, sel;
-};
-
-static struct arm_ahb_div clk_consumer[] = {
-       { .arm = 1, .ahb = 4, .sel = 0},
-       { .arm = 1, .ahb = 3, .sel = 1},
-       { .arm = 2, .ahb = 2, .sel = 0},
-       { .arm = 0, .ahb = 0, .sel = 0},
-       { .arm = 0, .ahb = 0, .sel = 0},
-       { .arm = 0, .ahb = 0, .sel = 0},
-       { .arm = 4, .ahb = 1, .sel = 0},
-       { .arm = 1, .ahb = 5, .sel = 0},
-       { .arm = 1, .ahb = 8, .sel = 0},
-       { .arm = 1, .ahb = 6, .sel = 1},
-       { .arm = 2, .ahb = 4, .sel = 0},
-       { .arm = 0, .ahb = 0, .sel = 0},
-       { .arm = 0, .ahb = 0, .sel = 0},
-       { .arm = 0, .ahb = 0, .sel = 0},
-       { .arm = 4, .ahb = 2, .sel = 0},
-       { .arm = 0, .ahb = 0, .sel = 0},
-};
-
-static unsigned long get_rate_arm(void)
-{
-       unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0);
-       struct arm_ahb_div *aad;
-       unsigned long fref = get_rate_mpll();
-
-       aad = &clk_consumer[(pdr0 >> 16) & 0xf];
-       if (aad->sel)
-               fref = fref * 3 / 4;
-
-       return fref / aad->arm;
-}
-
-static unsigned long get_rate_ahb(struct clk *clk)
-{
-       unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0);
-       struct arm_ahb_div *aad;
-       unsigned long fref = get_rate_arm();
-
-       aad = &clk_consumer[(pdr0 >> 16) & 0xf];
-
-       return fref / aad->ahb;
-}
-
-static unsigned long get_rate_ipg(struct clk *clk)
-{
-       return get_rate_ahb(NULL) >> 1;
-}
-
-static unsigned long get_rate_uart(struct clk *clk)
-{
-       unsigned long pdr3 = __raw_readl(MX35_CCM_PDR3);
-       unsigned long pdr4 = __raw_readl(MX35_CCM_PDR4);
-       unsigned long div = ((pdr4 >> 10) & 0x3f) + 1;
-
-       if (pdr3 & (1 << 14))
-               return get_rate_arm() / div;
-       else
-               return get_rate_ppll() / div;
-}
-
-static unsigned long get_rate_sdhc(struct clk *clk)
-{
-       unsigned long pdr3 = __raw_readl(MX35_CCM_PDR3);
-       unsigned long div, rate;
-
-       if (pdr3 & (1 << 6))
-               rate = get_rate_arm();
-       else
-               rate = get_rate_ppll();
-
-       switch (clk->id) {
-       default:
-       case 0:
-               div = pdr3 & 0x3f;
-               break;
-       case 1:
-               div = (pdr3 >> 8) & 0x3f;
-               break;
-       case 2:
-               div = (pdr3 >> 16) & 0x3f;
-               break;
-       }
-
-       return rate / (div + 1);
-}
-
-static unsigned long get_rate_mshc(struct clk *clk)
-{
-       unsigned long pdr1 = __raw_readl(MXC_CCM_PDR1);
-       unsigned long div1, div2, rate;
-
-       if (pdr1 & (1 << 7))
-               rate = get_rate_arm();
-       else
-               rate = get_rate_ppll();
-
-       div1 = (pdr1 >> 29) & 0x7;
-       div2 = (pdr1 >> 22) & 0x3f;
-
-       return rate / ((div1 + 1) * (div2 + 1));
-}
-
-static unsigned long get_rate_ssi(struct clk *clk)
-{
-       unsigned long pdr2 = __raw_readl(MX35_CCM_PDR2);
-       unsigned long div1, div2, rate;
-
-       if (pdr2 & (1 << 6))
-               rate = get_rate_arm();
-       else
-               rate = get_rate_ppll();
-
-       switch (clk->id) {
-       default:
-       case 0:
-               div1 = pdr2 & 0x3f;
-               div2 = (pdr2 >> 24) & 0x7;
-               break;
-       case 1:
-               div1 = (pdr2 >> 8) & 0x3f;
-               div2 = (pdr2 >> 27) & 0x7;
-               break;
-       }
-
-       return rate / ((div1 + 1) * (div2 + 1));
-}
-
-static unsigned long get_rate_csi(struct clk *clk)
-{
-       unsigned long pdr2 = __raw_readl(MX35_CCM_PDR2);
-       unsigned long rate;
-
-       if (pdr2 & (1 << 7))
-               rate = get_rate_arm();
-       else
-               rate = get_rate_ppll();
-
-       return rate / (((pdr2 >> 16) & 0x3f) + 1);
-}
-
-static unsigned long get_rate_otg(struct clk *clk)
-{
-       unsigned long pdr4 = __raw_readl(MX35_CCM_PDR4);
-       unsigned long rate;
-
-       if (pdr4 & (1 << 9))
-               rate = get_rate_arm();
-       else
-               rate = get_rate_ppll();
-
-       return rate / (((pdr4 >> 22) & 0x3f) + 1);
-}
-
-static unsigned long get_rate_ipg_per(struct clk *clk)
-{
-       unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0);
-       unsigned long pdr4 = __raw_readl(MX35_CCM_PDR4);
-       unsigned long div;
-
-       if (pdr0 & (1 << 26)) {
-               div = (pdr4 >> 16) & 0x3f;
-               return get_rate_arm() / (div + 1);
-       } else {
-               div = (pdr0 >> 12) & 0x7;
-               return get_rate_ahb(NULL) / (div + 1);
-       }
-}
-
-static unsigned long get_rate_hsp(struct clk *clk)
-{
-       unsigned long hsp_podf = (__raw_readl(MXC_CCM_PDR0) >> 20) & 0x03;
-       unsigned long fref = get_rate_mpll();
-
-       if (fref > 400 * 1000 * 1000) {
-               switch (hsp_podf) {
-               case 0:
-                       return fref >> 2;
-               case 1:
-                       return fref >> 3;
-               case 2:
-                       return fref / 3;
-               }
-       } else {
-               switch (hsp_podf) {
-               case 0:
-               case 2:
-                       return fref / 3;
-               case 1:
-                       return fref / 6;
-               }
-       }
-
-       return 0;
-}
-
-static int clk_cgr_enable(struct clk *clk)
-{
-       u32 reg;
-
-       reg = __raw_readl(clk->enable_reg);
-       reg |= 3 << clk->enable_shift;
-       __raw_writel(reg, clk->enable_reg);
-
-       return 0;
-}
-
-static void clk_cgr_disable(struct clk *clk)
-{
-       u32 reg;
-
-       reg = __raw_readl(clk->enable_reg);
-       reg &= ~(3 << clk->enable_shift);
-       __raw_writel(reg, clk->enable_reg);
-}
-
-#define DEFINE_CLOCK(name, i, er, es, gr, sr)          \
-       static struct clk name = {                      \
-               .id             = i,                    \
-               .enable_reg     = er,                   \
-               .enable_shift   = es,                   \
-               .get_rate       = gr,                   \
-               .set_rate       = sr,                   \
-               .enable         = clk_cgr_enable,       \
-               .disable        = clk_cgr_disable,      \
-       }
-
-DEFINE_CLOCK(asrc_clk,   0, MX35_CCM_CGR0,  0, NULL, NULL);
-DEFINE_CLOCK(pata_clk,    0, MX35_CCM_CGR0,  2, get_rate_ipg, NULL);
-/* DEFINE_CLOCK(audmux_clk, 0, MX35_CCM_CGR0,  4, NULL, NULL); */
-DEFINE_CLOCK(can1_clk,   0, MX35_CCM_CGR0,  6, get_rate_ipg, NULL);
-DEFINE_CLOCK(can2_clk,   1, MX35_CCM_CGR0,  8, get_rate_ipg, NULL);
-DEFINE_CLOCK(cspi1_clk,  0, MX35_CCM_CGR0, 10, get_rate_ipg, NULL);
-DEFINE_CLOCK(cspi2_clk,  1, MX35_CCM_CGR0, 12, get_rate_ipg, NULL);
-DEFINE_CLOCK(ect_clk,    0, MX35_CCM_CGR0, 14, get_rate_ipg, NULL);
-DEFINE_CLOCK(edio_clk,   0, MX35_CCM_CGR0, 16, NULL, NULL);
-DEFINE_CLOCK(emi_clk,    0, MX35_CCM_CGR0, 18, get_rate_ipg, NULL);
-DEFINE_CLOCK(epit1_clk,  0, MX35_CCM_CGR0, 20, get_rate_ipg, NULL);
-DEFINE_CLOCK(epit2_clk,  1, MX35_CCM_CGR0, 22, get_rate_ipg, NULL);
-DEFINE_CLOCK(esai_clk,   0, MX35_CCM_CGR0, 24, NULL, NULL);
-DEFINE_CLOCK(esdhc1_clk, 0, MX35_CCM_CGR0, 26, get_rate_sdhc, NULL);
-DEFINE_CLOCK(esdhc2_clk, 1, MX35_CCM_CGR0, 28, get_rate_sdhc, NULL);
-DEFINE_CLOCK(esdhc3_clk, 2, MX35_CCM_CGR0, 30, get_rate_sdhc, NULL);
-
-DEFINE_CLOCK(fec_clk,    0, MX35_CCM_CGR1,  0, get_rate_ipg, NULL);
-DEFINE_CLOCK(gpio1_clk,  0, MX35_CCM_CGR1,  2, NULL, NULL);
-DEFINE_CLOCK(gpio2_clk,  1, MX35_CCM_CGR1,  4, NULL, NULL);
-DEFINE_CLOCK(gpio3_clk,  2, MX35_CCM_CGR1,  6, NULL, NULL);
-DEFINE_CLOCK(gpt_clk,    0, MX35_CCM_CGR1,  8, get_rate_ipg, NULL);
-DEFINE_CLOCK(i2c1_clk,   0, MX35_CCM_CGR1, 10, get_rate_ipg_per, NULL);
-DEFINE_CLOCK(i2c2_clk,   1, MX35_CCM_CGR1, 12, get_rate_ipg_per, NULL);
-DEFINE_CLOCK(i2c3_clk,   2, MX35_CCM_CGR1, 14, get_rate_ipg_per, NULL);
-DEFINE_CLOCK(iomuxc_clk, 0, MX35_CCM_CGR1, 16, NULL, NULL);
-DEFINE_CLOCK(ipu_clk,    0, MX35_CCM_CGR1, 18, get_rate_hsp, NULL);
-DEFINE_CLOCK(kpp_clk,    0, MX35_CCM_CGR1, 20, get_rate_ipg, NULL);
-DEFINE_CLOCK(mlb_clk,    0, MX35_CCM_CGR1, 22, get_rate_ahb, NULL);
-DEFINE_CLOCK(mshc_clk,   0, MX35_CCM_CGR1, 24, get_rate_mshc, NULL);
-DEFINE_CLOCK(owire_clk,  0, MX35_CCM_CGR1, 26, get_rate_ipg_per, NULL);
-DEFINE_CLOCK(pwm_clk,    0, MX35_CCM_CGR1, 28, get_rate_ipg_per, NULL);
-DEFINE_CLOCK(rngc_clk,   0, MX35_CCM_CGR1, 30, get_rate_ipg, NULL);
-
-DEFINE_CLOCK(rtc_clk,    0, MX35_CCM_CGR2,  0, get_rate_ipg, NULL);
-DEFINE_CLOCK(rtic_clk,   0, MX35_CCM_CGR2,  2, get_rate_ahb, NULL);
-DEFINE_CLOCK(scc_clk,    0, MX35_CCM_CGR2,  4, get_rate_ipg, NULL);
-DEFINE_CLOCK(sdma_clk,   0, MX35_CCM_CGR2,  6, NULL, NULL);
-DEFINE_CLOCK(spba_clk,   0, MX35_CCM_CGR2,  8, get_rate_ipg, NULL);
-DEFINE_CLOCK(spdif_clk,  0, MX35_CCM_CGR2, 10, NULL, NULL);
-DEFINE_CLOCK(ssi1_clk,   0, MX35_CCM_CGR2, 12, get_rate_ssi, NULL);
-DEFINE_CLOCK(ssi2_clk,   1, MX35_CCM_CGR2, 14, get_rate_ssi, NULL);
-DEFINE_CLOCK(uart1_clk,  0, MX35_CCM_CGR2, 16, get_rate_uart, NULL);
-DEFINE_CLOCK(uart2_clk,  1, MX35_CCM_CGR2, 18, get_rate_uart, NULL);
-DEFINE_CLOCK(uart3_clk,  2, MX35_CCM_CGR2, 20, get_rate_uart, NULL);
-DEFINE_CLOCK(usbotg_clk, 0, MX35_CCM_CGR2, 22, get_rate_otg, NULL);
-DEFINE_CLOCK(wdog_clk,   0, MX35_CCM_CGR2, 24, NULL, NULL);
-DEFINE_CLOCK(max_clk,    0, MX35_CCM_CGR2, 26, NULL, NULL);
-DEFINE_CLOCK(audmux_clk, 0, MX35_CCM_CGR2, 30, NULL, NULL);
-
-DEFINE_CLOCK(csi_clk,    0, MX35_CCM_CGR3,  0, get_rate_csi, NULL);
-DEFINE_CLOCK(iim_clk,    0, MX35_CCM_CGR3,  2, NULL, NULL);
-DEFINE_CLOCK(gpu2d_clk,  0, MX35_CCM_CGR3,  4, NULL, NULL);
-
-DEFINE_CLOCK(usbahb_clk, 0, 0,         0, get_rate_ahb, NULL);
-
-static int clk_dummy_enable(struct clk *clk)
-{
-       return 0;
-}
-
-static void clk_dummy_disable(struct clk *clk)
-{
-}
-
-static unsigned long get_rate_nfc(struct clk *clk)
-{
-       unsigned long div1;
-
-       div1 = (__raw_readl(MX35_CCM_PDR4) >> 28) + 1;
-
-       return get_rate_ahb(NULL) / div1;
-}
-
-/* NAND Controller: It seems it can't be disabled */
-static struct clk nfc_clk = {
-       .id             = 0,
-       .enable_reg     = 0,
-       .enable_shift   = 0,
-       .get_rate       = get_rate_nfc,
-       .set_rate       = NULL, /* set_rate_nfc, */
-       .enable         = clk_dummy_enable,
-       .disable        = clk_dummy_disable
-};
-
-#define _REGISTER_CLOCK(d, n, c)       \
-       {                               \
-               .dev_id = d,            \
-               .con_id = n,            \
-               .clk = &c,              \
-       },
-
-static struct clk_lookup lookups[] = {
-       _REGISTER_CLOCK(NULL, "asrc", asrc_clk)
-       _REGISTER_CLOCK("pata_imx", NULL, pata_clk)
-       _REGISTER_CLOCK("flexcan.0", NULL, can1_clk)
-       _REGISTER_CLOCK("flexcan.1", NULL, can2_clk)
-       _REGISTER_CLOCK("imx35-cspi.0", NULL, cspi1_clk)
-       _REGISTER_CLOCK("imx35-cspi.1", NULL, cspi2_clk)
-       _REGISTER_CLOCK(NULL, "ect", ect_clk)
-       _REGISTER_CLOCK(NULL, "edio", edio_clk)
-       _REGISTER_CLOCK(NULL, "emi", emi_clk)
-       _REGISTER_CLOCK("imx-epit.0", NULL, epit1_clk)
-       _REGISTER_CLOCK("imx-epit.1", NULL, epit2_clk)
-       _REGISTER_CLOCK(NULL, "esai", esai_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx35.0", NULL, esdhc1_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx35.1", NULL, esdhc2_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx35.2", NULL, esdhc3_clk)
-       /* i.mx35 has the i.mx27 type fec */
-       _REGISTER_CLOCK("imx27-fec.0", NULL, fec_clk)
-       _REGISTER_CLOCK(NULL, "gpio", gpio1_clk)
-       _REGISTER_CLOCK(NULL, "gpio", gpio2_clk)
-       _REGISTER_CLOCK(NULL, "gpio", gpio3_clk)
-       _REGISTER_CLOCK("gpt.0", NULL, gpt_clk)
-       _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
-       _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
-       _REGISTER_CLOCK("imx-i2c.2", NULL, i2c3_clk)
-       _REGISTER_CLOCK(NULL, "iomuxc", iomuxc_clk)
-       _REGISTER_CLOCK("ipu-core", NULL, ipu_clk)
-       _REGISTER_CLOCK("mx3_sdc_fb", NULL, ipu_clk)
-       _REGISTER_CLOCK(NULL, "kpp", kpp_clk)
-       _REGISTER_CLOCK(NULL, "mlb", mlb_clk)
-       _REGISTER_CLOCK(NULL, "mshc", mshc_clk)
-       _REGISTER_CLOCK("mxc_w1", NULL, owire_clk)
-       _REGISTER_CLOCK(NULL, "pwm", pwm_clk)
-       _REGISTER_CLOCK(NULL, "rngc", rngc_clk)
-       _REGISTER_CLOCK(NULL, "rtc", rtc_clk)
-       _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
-       _REGISTER_CLOCK(NULL, "scc", scc_clk)
-       _REGISTER_CLOCK("imx35-sdma", NULL, sdma_clk)
-       _REGISTER_CLOCK(NULL, "spba", spba_clk)
-       _REGISTER_CLOCK(NULL, "spdif", spdif_clk)
-       _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
-       _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
-       /* i.mx35 has the i.mx21 type uart */
-       _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk)
-       _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk)
-       _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk)
-       _REGISTER_CLOCK("mxc-ehci.0", "usb", usbotg_clk)
-       _REGISTER_CLOCK("mxc-ehci.1", "usb", usbotg_clk)
-       _REGISTER_CLOCK("mxc-ehci.2", "usb", usbotg_clk)
-       _REGISTER_CLOCK("fsl-usb2-udc", "usb", usbotg_clk)
-       _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", usbahb_clk)
-       _REGISTER_CLOCK("imx2-wdt.0", NULL, wdog_clk)
-       _REGISTER_CLOCK(NULL, "max", max_clk)
-       _REGISTER_CLOCK(NULL, "audmux", audmux_clk)
-       _REGISTER_CLOCK("mx3-camera.0", NULL, csi_clk)
-       _REGISTER_CLOCK(NULL, "iim", iim_clk)
-       _REGISTER_CLOCK(NULL, "gpu2d", gpu2d_clk)
-       _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk)
-};
-
-int __init mx35_clocks_init()
-{
-       unsigned int cgr2 = 3 << 26;
-
-#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC)
-       cgr2 |= 3 << 16;
-#endif
-
-       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
-       /* Turn off all clocks except the ones we need to survive, namely:
-        * EMI, GPIO1/2/3, GPT, IOMUX, MAX and eventually uart
-        */
-       __raw_writel((3 << 18), MX35_CCM_CGR0);
-       __raw_writel((3 << 2) | (3 << 4) | (3 << 6) | (3 << 8) | (3 << 16),
-                       MX35_CCM_CGR1);
-       __raw_writel(cgr2, MX35_CCM_CGR2);
-       __raw_writel(0, MX35_CCM_CGR3);
-
-       clk_enable(&iim_clk);
-       imx_print_silicon_rev("i.MX35", mx35_revision());
-       clk_disable(&iim_clk);
-
-       /*
-        * Check if we came up in internal boot mode. If yes, we need some
-        * extra clocks turned on, otherwise the MX35 boot ROM code will
-        * hang after a watchdog reset.
-        */
-       if (!(__raw_readl(MX35_CCM_RCSR) & (3 << 10))) {
-               /* Additionally turn on UART1, SCC, and IIM clocks */
-               clk_enable(&iim_clk);
-               clk_enable(&uart1_clk);
-               clk_enable(&scc_clk);
-       }
-
-#ifdef CONFIG_MXC_USE_EPIT
-       epit_timer_init(&epit1_clk,
-                       MX35_IO_ADDRESS(MX35_EPIT1_BASE_ADDR), MX35_INT_EPIT1);
-#else
-       mxc_timer_init(&gpt_clk,
-                       MX35_IO_ADDRESS(MX35_GPT1_BASE_ADDR), MX35_INT_GPT);
-#endif
-
-       return 0;
-}
diff --git a/arch/arm/mach-imx/clock-imx6q.c b/arch/arm/mach-imx/clock-imx6q.c
deleted file mode 100644 (file)
index 111c328..0000000
+++ /dev/null
@@ -1,2111 +0,0 @@
-/*
- * Copyright 2011 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/clk.h>
-#include <linux/clkdev.h>
-#include <linux/io.h>
-#include <linux/of.h>
-#include <linux/of_address.h>
-#include <linux/of_irq.h>
-#include <asm/div64.h>
-#include <asm/mach/map.h>
-#include <mach/clock.h>
-#include <mach/common.h>
-#include <mach/hardware.h>
-
-#define PLL_BASE               IMX_IO_ADDRESS(MX6Q_ANATOP_BASE_ADDR)
-#define PLL1_SYS               (PLL_BASE + 0x000)
-#define PLL2_BUS               (PLL_BASE + 0x030)
-#define PLL3_USB_OTG           (PLL_BASE + 0x010)
-#define PLL4_AUDIO             (PLL_BASE + 0x070)
-#define PLL5_VIDEO             (PLL_BASE + 0x0a0)
-#define PLL6_MLB               (PLL_BASE + 0x0d0)
-#define PLL7_USB_HOST          (PLL_BASE + 0x020)
-#define PLL8_ENET              (PLL_BASE + 0x0e0)
-#define PFD_480                        (PLL_BASE + 0x0f0)
-#define PFD_528                        (PLL_BASE + 0x100)
-#define PLL_NUM_OFFSET         0x010
-#define PLL_DENOM_OFFSET       0x020
-
-#define PFD0                   7
-#define PFD1                   15
-#define PFD2                   23
-#define PFD3                   31
-#define PFD_FRAC_MASK          0x3f
-
-#define BM_PLL_BYPASS                  (0x1 << 16)
-#define BM_PLL_ENABLE                  (0x1 << 13)
-#define BM_PLL_POWER_DOWN              (0x1 << 12)
-#define BM_PLL_LOCK                    (0x1 << 31)
-#define BP_PLL_SYS_DIV_SELECT          0
-#define BM_PLL_SYS_DIV_SELECT          (0x7f << 0)
-#define BP_PLL_BUS_DIV_SELECT          0
-#define BM_PLL_BUS_DIV_SELECT          (0x1 << 0)
-#define BP_PLL_USB_DIV_SELECT          0
-#define BM_PLL_USB_DIV_SELECT          (0x3 << 0)
-#define BP_PLL_AV_DIV_SELECT           0
-#define BM_PLL_AV_DIV_SELECT           (0x7f << 0)
-#define BP_PLL_ENET_DIV_SELECT         0
-#define BM_PLL_ENET_DIV_SELECT         (0x3 << 0)
-#define BM_PLL_ENET_EN_PCIE            (0x1 << 19)
-#define BM_PLL_ENET_EN_SATA            (0x1 << 20)
-
-#define CCM_BASE       IMX_IO_ADDRESS(MX6Q_CCM_BASE_ADDR)
-#define CCR            (CCM_BASE + 0x00)
-#define CCDR           (CCM_BASE + 0x04)
-#define CSR            (CCM_BASE + 0x08)
-#define CCSR           (CCM_BASE + 0x0c)
-#define CACRR          (CCM_BASE + 0x10)
-#define CBCDR          (CCM_BASE + 0x14)
-#define CBCMR          (CCM_BASE + 0x18)
-#define CSCMR1         (CCM_BASE + 0x1c)
-#define CSCMR2         (CCM_BASE + 0x20)
-#define CSCDR1         (CCM_BASE + 0x24)
-#define CS1CDR         (CCM_BASE + 0x28)
-#define CS2CDR         (CCM_BASE + 0x2c)
-#define CDCDR          (CCM_BASE + 0x30)
-#define CHSCCDR                (CCM_BASE + 0x34)
-#define CSCDR2         (CCM_BASE + 0x38)
-#define CSCDR3         (CCM_BASE + 0x3c)
-#define CSCDR4         (CCM_BASE + 0x40)
-#define CWDR           (CCM_BASE + 0x44)
-#define CDHIPR         (CCM_BASE + 0x48)
-#define CDCR           (CCM_BASE + 0x4c)
-#define CTOR           (CCM_BASE + 0x50)
-#define CLPCR          (CCM_BASE + 0x54)
-#define CISR           (CCM_BASE + 0x58)
-#define CIMR           (CCM_BASE + 0x5c)
-#define CCOSR          (CCM_BASE + 0x60)
-#define CGPR           (CCM_BASE + 0x64)
-#define CCGR0          (CCM_BASE + 0x68)
-#define CCGR1          (CCM_BASE + 0x6c)
-#define CCGR2          (CCM_BASE + 0x70)
-#define CCGR3          (CCM_BASE + 0x74)
-#define CCGR4          (CCM_BASE + 0x78)
-#define CCGR5          (CCM_BASE + 0x7c)
-#define CCGR6          (CCM_BASE + 0x80)
-#define CCGR7          (CCM_BASE + 0x84)
-#define CMEOR          (CCM_BASE + 0x88)
-
-#define CG0            0
-#define CG1            2
-#define CG2            4
-#define CG3            6
-#define CG4            8
-#define CG5            10
-#define CG6            12
-#define CG7            14
-#define CG8            16
-#define CG9            18
-#define CG10           20
-#define CG11           22
-#define CG12           24
-#define CG13           26
-#define CG14           28
-#define CG15           30
-
-#define BM_CCSR_PLL1_SW_SEL            (0x1 << 2)
-#define BM_CCSR_STEP_SEL               (0x1 << 8)
-
-#define BP_CACRR_ARM_PODF              0
-#define BM_CACRR_ARM_PODF              (0x7 << 0)
-
-#define BP_CBCDR_PERIPH2_CLK2_PODF     0
-#define BM_CBCDR_PERIPH2_CLK2_PODF     (0x7 << 0)
-#define BP_CBCDR_MMDC_CH1_AXI_PODF     3
-#define BM_CBCDR_MMDC_CH1_AXI_PODF     (0x7 << 3)
-#define BP_CBCDR_AXI_SEL               6
-#define BM_CBCDR_AXI_SEL               (0x3 << 6)
-#define BP_CBCDR_IPG_PODF              8
-#define BM_CBCDR_IPG_PODF              (0x3 << 8)
-#define BP_CBCDR_AHB_PODF              10
-#define BM_CBCDR_AHB_PODF              (0x7 << 10)
-#define BP_CBCDR_AXI_PODF              16
-#define BM_CBCDR_AXI_PODF              (0x7 << 16)
-#define BP_CBCDR_MMDC_CH0_AXI_PODF     19
-#define BM_CBCDR_MMDC_CH0_AXI_PODF     (0x7 << 19)
-#define BP_CBCDR_PERIPH_CLK_SEL                25
-#define BM_CBCDR_PERIPH_CLK_SEL                (0x1 << 25)
-#define BP_CBCDR_PERIPH2_CLK_SEL       26
-#define BM_CBCDR_PERIPH2_CLK_SEL       (0x1 << 26)
-#define BP_CBCDR_PERIPH_CLK2_PODF      27
-#define BM_CBCDR_PERIPH_CLK2_PODF      (0x7 << 27)
-
-#define BP_CBCMR_GPU2D_AXI_SEL         0
-#define BM_CBCMR_GPU2D_AXI_SEL         (0x1 << 0)
-#define BP_CBCMR_GPU3D_AXI_SEL         1
-#define BM_CBCMR_GPU3D_AXI_SEL         (0x1 << 1)
-#define BP_CBCMR_GPU3D_CORE_SEL                4
-#define BM_CBCMR_GPU3D_CORE_SEL                (0x3 << 4)
-#define BP_CBCMR_GPU3D_SHADER_SEL      8
-#define BM_CBCMR_GPU3D_SHADER_SEL      (0x3 << 8)
-#define BP_CBCMR_PCIE_AXI_SEL          10
-#define BM_CBCMR_PCIE_AXI_SEL          (0x1 << 10)
-#define BP_CBCMR_VDO_AXI_SEL           11
-#define BM_CBCMR_VDO_AXI_SEL           (0x1 << 11)
-#define BP_CBCMR_PERIPH_CLK2_SEL       12
-#define BM_CBCMR_PERIPH_CLK2_SEL       (0x3 << 12)
-#define BP_CBCMR_VPU_AXI_SEL           14
-#define BM_CBCMR_VPU_AXI_SEL           (0x3 << 14)
-#define BP_CBCMR_GPU2D_CORE_SEL                16
-#define BM_CBCMR_GPU2D_CORE_SEL                (0x3 << 16)
-#define BP_CBCMR_PRE_PERIPH_CLK_SEL    18
-#define BM_CBCMR_PRE_PERIPH_CLK_SEL    (0x3 << 18)
-#define BP_CBCMR_PERIPH2_CLK2_SEL      20
-#define BM_CBCMR_PERIPH2_CLK2_SEL      (0x1 << 20)
-#define BP_CBCMR_PRE_PERIPH2_CLK_SEL   21
-#define BM_CBCMR_PRE_PERIPH2_CLK_SEL   (0x3 << 21)
-#define BP_CBCMR_GPU2D_CORE_PODF       23
-#define BM_CBCMR_GPU2D_CORE_PODF       (0x7 << 23)
-#define BP_CBCMR_GPU3D_CORE_PODF       26
-#define BM_CBCMR_GPU3D_CORE_PODF       (0x7 << 26)
-#define BP_CBCMR_GPU3D_SHADER_PODF     29
-#define BM_CBCMR_GPU3D_SHADER_PODF     (0x7 << 29)
-
-#define BP_CSCMR1_PERCLK_PODF          0
-#define BM_CSCMR1_PERCLK_PODF          (0x3f << 0)
-#define BP_CSCMR1_SSI1_SEL             10
-#define BM_CSCMR1_SSI1_SEL             (0x3 << 10)
-#define BP_CSCMR1_SSI2_SEL             12
-#define BM_CSCMR1_SSI2_SEL             (0x3 << 12)
-#define BP_CSCMR1_SSI3_SEL             14
-#define BM_CSCMR1_SSI3_SEL             (0x3 << 14)
-#define BP_CSCMR1_USDHC1_SEL           16
-#define BM_CSCMR1_USDHC1_SEL           (0x1 << 16)
-#define BP_CSCMR1_USDHC2_SEL           17
-#define BM_CSCMR1_USDHC2_SEL           (0x1 << 17)
-#define BP_CSCMR1_USDHC3_SEL           18
-#define BM_CSCMR1_USDHC3_SEL           (0x1 << 18)
-#define BP_CSCMR1_USDHC4_SEL           19
-#define BM_CSCMR1_USDHC4_SEL           (0x1 << 19)
-#define BP_CSCMR1_EMI_PODF             20
-#define BM_CSCMR1_EMI_PODF             (0x7 << 20)
-#define BP_CSCMR1_EMI_SLOW_PODF                23
-#define BM_CSCMR1_EMI_SLOW_PODF                (0x7 << 23)
-#define BP_CSCMR1_EMI_SEL              27
-#define BM_CSCMR1_EMI_SEL              (0x3 << 27)
-#define BP_CSCMR1_EMI_SLOW_SEL         29
-#define BM_CSCMR1_EMI_SLOW_SEL         (0x3 << 29)
-
-#define BP_CSCMR2_CAN_PODF             2
-#define BM_CSCMR2_CAN_PODF             (0x3f << 2)
-#define BM_CSCMR2_LDB_DI0_IPU_DIV      (0x1 << 10)
-#define BM_CSCMR2_LDB_DI1_IPU_DIV      (0x1 << 11)
-#define BP_CSCMR2_ESAI_SEL             19
-#define BM_CSCMR2_ESAI_SEL             (0x3 << 19)
-
-#define BP_CSCDR1_UART_PODF            0
-#define BM_CSCDR1_UART_PODF            (0x3f << 0)
-#define BP_CSCDR1_USDHC1_PODF          11
-#define BM_CSCDR1_USDHC1_PODF          (0x7 << 11)
-#define BP_CSCDR1_USDHC2_PODF          16
-#define BM_CSCDR1_USDHC2_PODF          (0x7 << 16)
-#define BP_CSCDR1_USDHC3_PODF          19
-#define BM_CSCDR1_USDHC3_PODF          (0x7 << 19)
-#define BP_CSCDR1_USDHC4_PODF          22
-#define BM_CSCDR1_USDHC4_PODF          (0x7 << 22)
-#define BP_CSCDR1_VPU_AXI_PODF         25
-#define BM_CSCDR1_VPU_AXI_PODF         (0x7 << 25)
-
-#define BP_CS1CDR_SSI1_PODF            0
-#define BM_CS1CDR_SSI1_PODF            (0x3f << 0)
-#define BP_CS1CDR_SSI1_PRED            6
-#define BM_CS1CDR_SSI1_PRED            (0x7 << 6)
-#define BP_CS1CDR_ESAI_PRED            9
-#define BM_CS1CDR_ESAI_PRED            (0x7 << 9)
-#define BP_CS1CDR_SSI3_PODF            16
-#define BM_CS1CDR_SSI3_PODF            (0x3f << 16)
-#define BP_CS1CDR_SSI3_PRED            22
-#define BM_CS1CDR_SSI3_PRED            (0x7 << 22)
-#define BP_CS1CDR_ESAI_PODF            25
-#define BM_CS1CDR_ESAI_PODF            (0x7 << 25)
-
-#define BP_CS2CDR_SSI2_PODF            0
-#define BM_CS2CDR_SSI2_PODF            (0x3f << 0)
-#define BP_CS2CDR_SSI2_PRED            6
-#define BM_CS2CDR_SSI2_PRED            (0x7 << 6)
-#define BP_CS2CDR_LDB_DI0_SEL          9
-#define BM_CS2CDR_LDB_DI0_SEL          (0x7 << 9)
-#define BP_CS2CDR_LDB_DI1_SEL          12
-#define BM_CS2CDR_LDB_DI1_SEL          (0x7 << 12)
-#define BP_CS2CDR_ENFC_SEL             16
-#define BM_CS2CDR_ENFC_SEL             (0x3 << 16)
-#define BP_CS2CDR_ENFC_PRED            18
-#define BM_CS2CDR_ENFC_PRED            (0x7 << 18)
-#define BP_CS2CDR_ENFC_PODF            21
-#define BM_CS2CDR_ENFC_PODF            (0x3f << 21)
-
-#define BP_CDCDR_ASRC_SERIAL_SEL       7
-#define BM_CDCDR_ASRC_SERIAL_SEL       (0x3 << 7)
-#define BP_CDCDR_ASRC_SERIAL_PODF      9
-#define BM_CDCDR_ASRC_SERIAL_PODF      (0x7 << 9)
-#define BP_CDCDR_ASRC_SERIAL_PRED      12
-#define BM_CDCDR_ASRC_SERIAL_PRED      (0x7 << 12)
-#define BP_CDCDR_SPDIF_SEL             20
-#define BM_CDCDR_SPDIF_SEL             (0x3 << 20)
-#define BP_CDCDR_SPDIF_PODF            22
-#define BM_CDCDR_SPDIF_PODF            (0x7 << 22)
-#define BP_CDCDR_SPDIF_PRED            25
-#define BM_CDCDR_SPDIF_PRED            (0x7 << 25)
-#define BP_CDCDR_HSI_TX_PODF           29
-#define BM_CDCDR_HSI_TX_PODF           (0x7 << 29)
-#define BP_CDCDR_HSI_TX_SEL            28
-#define BM_CDCDR_HSI_TX_SEL            (0x1 << 28)
-
-#define BP_CHSCCDR_IPU1_DI0_SEL                0
-#define BM_CHSCCDR_IPU1_DI0_SEL                (0x7 << 0)
-#define BP_CHSCCDR_IPU1_DI0_PRE_PODF   3
-#define BM_CHSCCDR_IPU1_DI0_PRE_PODF   (0x7 << 3)
-#define BP_CHSCCDR_IPU1_DI0_PRE_SEL    6
-#define BM_CHSCCDR_IPU1_DI0_PRE_SEL    (0x7 << 6)
-#define BP_CHSCCDR_IPU1_DI1_SEL                9
-#define BM_CHSCCDR_IPU1_DI1_SEL                (0x7 << 9)
-#define BP_CHSCCDR_IPU1_DI1_PRE_PODF   12
-#define BM_CHSCCDR_IPU1_DI1_PRE_PODF   (0x7 << 12)
-#define BP_CHSCCDR_IPU1_DI1_PRE_SEL    15
-#define BM_CHSCCDR_IPU1_DI1_PRE_SEL    (0x7 << 15)
-
-#define BP_CSCDR2_IPU2_DI0_SEL         0
-#define BM_CSCDR2_IPU2_DI0_SEL         (0x7)
-#define BP_CSCDR2_IPU2_DI0_PRE_PODF    3
-#define BM_CSCDR2_IPU2_DI0_PRE_PODF    (0x7 << 3)
-#define BP_CSCDR2_IPU2_DI0_PRE_SEL     6
-#define BM_CSCDR2_IPU2_DI0_PRE_SEL     (0x7 << 6)
-#define BP_CSCDR2_IPU2_DI1_SEL         9
-#define BM_CSCDR2_IPU2_DI1_SEL         (0x7 << 9)
-#define BP_CSCDR2_IPU2_DI1_PRE_PODF    12
-#define BM_CSCDR2_IPU2_DI1_PRE_PODF    (0x7 << 12)
-#define BP_CSCDR2_IPU2_DI1_PRE_SEL     15
-#define BM_CSCDR2_IPU2_DI1_PRE_SEL     (0x7 << 15)
-#define BP_CSCDR2_ECSPI_CLK_PODF       19
-#define BM_CSCDR2_ECSPI_CLK_PODF       (0x3f << 19)
-
-#define BP_CSCDR3_IPU1_HSP_SEL         9
-#define BM_CSCDR3_IPU1_HSP_SEL         (0x3 << 9)
-#define BP_CSCDR3_IPU1_HSP_PODF                11
-#define BM_CSCDR3_IPU1_HSP_PODF                (0x7 << 11)
-#define BP_CSCDR3_IPU2_HSP_SEL         14
-#define BM_CSCDR3_IPU2_HSP_SEL         (0x3 << 14)
-#define BP_CSCDR3_IPU2_HSP_PODF                16
-#define BM_CSCDR3_IPU2_HSP_PODF                (0x7 << 16)
-
-#define BM_CDHIPR_AXI_PODF_BUSY                (0x1 << 0)
-#define BM_CDHIPR_AHB_PODF_BUSY                (0x1 << 1)
-#define BM_CDHIPR_MMDC_CH1_PODF_BUSY   (0x1 << 2)
-#define BM_CDHIPR_PERIPH2_SEL_BUSY     (0x1 << 3)
-#define BM_CDHIPR_MMDC_CH0_PODF_BUSY   (0x1 << 4)
-#define BM_CDHIPR_PERIPH_SEL_BUSY      (0x1 << 5)
-#define BM_CDHIPR_ARM_PODF_BUSY                (0x1 << 16)
-
-#define BP_CLPCR_LPM                   0
-#define BM_CLPCR_LPM                   (0x3 << 0)
-#define BM_CLPCR_BYPASS_PMIC_READY     (0x1 << 2)
-#define BM_CLPCR_ARM_CLK_DIS_ON_LPM    (0x1 << 5)
-#define BM_CLPCR_SBYOS                 (0x1 << 6)
-#define BM_CLPCR_DIS_REF_OSC           (0x1 << 7)
-#define BM_CLPCR_VSTBY                 (0x1 << 8)
-#define BP_CLPCR_STBY_COUNT            9
-#define BM_CLPCR_STBY_COUNT            (0x3 << 9)
-#define BM_CLPCR_COSC_PWRDOWN          (0x1 << 11)
-#define BM_CLPCR_WB_PER_AT_LPM         (0x1 << 16)
-#define BM_CLPCR_WB_CORE_AT_LPM                (0x1 << 17)
-#define BM_CLPCR_BYP_MMDC_CH0_LPM_HS   (0x1 << 19)
-#define BM_CLPCR_BYP_MMDC_CH1_LPM_HS   (0x1 << 21)
-#define BM_CLPCR_MASK_CORE0_WFI                (0x1 << 22)
-#define BM_CLPCR_MASK_CORE1_WFI                (0x1 << 23)
-#define BM_CLPCR_MASK_CORE2_WFI                (0x1 << 24)
-#define BM_CLPCR_MASK_CORE3_WFI                (0x1 << 25)
-#define BM_CLPCR_MASK_SCU_IDLE         (0x1 << 26)
-#define BM_CLPCR_MASK_L2CC_IDLE                (0x1 << 27)
-
-#define BP_CCOSR_CKO1_EN               7
-#define BP_CCOSR_CKO1_PODF             4
-#define BM_CCOSR_CKO1_PODF             (0x7 << 4)
-#define BP_CCOSR_CKO1_SEL              0
-#define BM_CCOSR_CKO1_SEL              (0xf << 0)
-
-#define FREQ_480M      480000000
-#define FREQ_528M      528000000
-#define FREQ_594M      594000000
-#define FREQ_650M      650000000
-#define FREQ_1300M     1300000000
-
-static struct clk pll1_sys;
-static struct clk pll2_bus;
-static struct clk pll3_usb_otg;
-static struct clk pll4_audio;
-static struct clk pll5_video;
-static struct clk pll6_mlb;
-static struct clk pll7_usb_host;
-static struct clk pll8_enet;
-static struct clk apbh_dma_clk;
-static struct clk arm_clk;
-static struct clk ipg_clk;
-static struct clk ahb_clk;
-static struct clk axi_clk;
-static struct clk mmdc_ch0_axi_clk;
-static struct clk mmdc_ch1_axi_clk;
-static struct clk periph_clk;
-static struct clk periph_pre_clk;
-static struct clk periph_clk2_clk;
-static struct clk periph2_clk;
-static struct clk periph2_pre_clk;
-static struct clk periph2_clk2_clk;
-static struct clk gpu2d_core_clk;
-static struct clk gpu3d_core_clk;
-static struct clk gpu3d_shader_clk;
-static struct clk ipg_perclk;
-static struct clk emi_clk;
-static struct clk emi_slow_clk;
-static struct clk can1_clk;
-static struct clk uart_clk;
-static struct clk usdhc1_clk;
-static struct clk usdhc2_clk;
-static struct clk usdhc3_clk;
-static struct clk usdhc4_clk;
-static struct clk vpu_clk;
-static struct clk hsi_tx_clk;
-static struct clk ipu1_di0_pre_clk;
-static struct clk ipu1_di1_pre_clk;
-static struct clk ipu2_di0_pre_clk;
-static struct clk ipu2_di1_pre_clk;
-static struct clk ipu1_clk;
-static struct clk ipu2_clk;
-static struct clk ssi1_clk;
-static struct clk ssi3_clk;
-static struct clk esai_clk;
-static struct clk ssi2_clk;
-static struct clk spdif_clk;
-static struct clk asrc_serial_clk;
-static struct clk gpu2d_axi_clk;
-static struct clk gpu3d_axi_clk;
-static struct clk pcie_clk;
-static struct clk vdo_axi_clk;
-static struct clk ldb_di0_clk;
-static struct clk ldb_di1_clk;
-static struct clk ipu1_di0_clk;
-static struct clk ipu1_di1_clk;
-static struct clk ipu2_di0_clk;
-static struct clk ipu2_di1_clk;
-static struct clk enfc_clk;
-static struct clk cko1_clk;
-static struct clk dummy_clk = {};
-
-static unsigned long external_high_reference;
-static unsigned long external_low_reference;
-static unsigned long oscillator_reference;
-
-static unsigned long get_oscillator_reference_clock_rate(struct clk *clk)
-{
-       return oscillator_reference;
-}
-
-static unsigned long get_high_reference_clock_rate(struct clk *clk)
-{
-       return external_high_reference;
-}
-
-static unsigned long get_low_reference_clock_rate(struct clk *clk)
-{
-       return external_low_reference;
-}
-
-static struct clk ckil_clk = {
-       .get_rate = get_low_reference_clock_rate,
-};
-
-static struct clk ckih_clk = {
-       .get_rate = get_high_reference_clock_rate,
-};
-
-static struct clk osc_clk = {
-       .get_rate = get_oscillator_reference_clock_rate,
-};
-
-static inline void __iomem *pll_get_reg_addr(struct clk *pll)
-{
-       if (pll == &pll1_sys)
-               return PLL1_SYS;
-       else if (pll == &pll2_bus)
-               return PLL2_BUS;
-       else if (pll == &pll3_usb_otg)
-               return PLL3_USB_OTG;
-       else if (pll == &pll4_audio)
-               return PLL4_AUDIO;
-       else if (pll == &pll5_video)
-               return PLL5_VIDEO;
-       else if (pll == &pll6_mlb)
-               return PLL6_MLB;
-       else if (pll == &pll7_usb_host)
-               return PLL7_USB_HOST;
-       else if (pll == &pll8_enet)
-               return PLL8_ENET;
-       else
-               BUG();
-
-       return NULL;
-}
-
-static int pll_enable(struct clk *clk)
-{
-       int timeout = 0x100000;
-       void __iomem *reg;
-       u32 val;
-
-       reg = pll_get_reg_addr(clk);
-       val = readl_relaxed(reg);
-       val &= ~BM_PLL_BYPASS;
-       val &= ~BM_PLL_POWER_DOWN;
-       /* 480MHz PLLs have the opposite definition for power bit */
-       if (clk == &pll3_usb_otg || clk == &pll7_usb_host)
-               val |= BM_PLL_POWER_DOWN;
-       writel_relaxed(val, reg);
-
-       /* Wait for PLL to lock */
-       while (!(readl_relaxed(reg) & BM_PLL_LOCK) && --timeout)
-               cpu_relax();
-
-       if (unlikely(!timeout))
-               return -EBUSY;
-
-       /* Enable the PLL output now */
-       val = readl_relaxed(reg);
-       val |= BM_PLL_ENABLE;
-       writel_relaxed(val, reg);
-
-       return 0;
-}
-
-static void pll_disable(struct clk *clk)
-{
-       void __iomem *reg;
-       u32 val;
-
-       reg = pll_get_reg_addr(clk);
-       val = readl_relaxed(reg);
-       val &= ~BM_PLL_ENABLE;
-       val |= BM_PLL_BYPASS;
-       val |= BM_PLL_POWER_DOWN;
-       if (clk == &pll3_usb_otg || clk == &pll7_usb_host)
-               val &= ~BM_PLL_POWER_DOWN;
-       writel_relaxed(val, reg);
-}
-
-static unsigned long pll1_sys_get_rate(struct clk *clk)
-{
-       u32 div = (readl_relaxed(PLL1_SYS) & BM_PLL_SYS_DIV_SELECT) >>
-                 BP_PLL_SYS_DIV_SELECT;
-
-       return clk_get_rate(clk->parent) * div / 2;
-}
-
-static int pll1_sys_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 val, div;
-
-       if (rate < FREQ_650M || rate > FREQ_1300M)
-               return -EINVAL;
-
-       div = rate * 2 / clk_get_rate(clk->parent);
-       val = readl_relaxed(PLL1_SYS);
-       val &= ~BM_PLL_SYS_DIV_SELECT;
-       val |= div << BP_PLL_SYS_DIV_SELECT;
-       writel_relaxed(val, PLL1_SYS);
-
-       return 0;
-}
-
-static unsigned long pll8_enet_get_rate(struct clk *clk)
-{
-       u32 div = (readl_relaxed(PLL8_ENET) & BM_PLL_ENET_DIV_SELECT) >>
-                 BP_PLL_ENET_DIV_SELECT;
-
-       switch (div) {
-       case 0:
-               return 25000000;
-       case 1:
-               return 50000000;
-       case 2:
-               return 100000000;
-       case 3:
-               return 125000000;
-       }
-
-       return 0;
-}
-
-static int pll8_enet_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 val, div;
-
-       switch (rate) {
-       case 25000000:
-               div = 0;
-               break;
-       case 50000000:
-               div = 1;
-               break;
-       case 100000000:
-               div = 2;
-               break;
-       case 125000000:
-               div = 3;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       val = readl_relaxed(PLL8_ENET);
-       val &= ~BM_PLL_ENET_DIV_SELECT;
-       val |= div << BP_PLL_ENET_DIV_SELECT;
-       writel_relaxed(val, PLL8_ENET);
-
-       return 0;
-}
-
-static unsigned long pll_av_get_rate(struct clk *clk)
-{
-       void __iomem *reg = (clk == &pll4_audio) ? PLL4_AUDIO : PLL5_VIDEO;
-       unsigned long parent_rate = clk_get_rate(clk->parent);
-       u32 mfn = readl_relaxed(reg + PLL_NUM_OFFSET);
-       u32 mfd = readl_relaxed(reg + PLL_DENOM_OFFSET);
-       u32 div = (readl_relaxed(reg) & BM_PLL_AV_DIV_SELECT) >>
-                 BP_PLL_AV_DIV_SELECT;
-
-       return (parent_rate * div) + ((parent_rate / mfd) * mfn);
-}
-
-static int pll_av_set_rate(struct clk *clk, unsigned long rate)
-{
-       void __iomem *reg = (clk == &pll4_audio) ? PLL4_AUDIO : PLL5_VIDEO;
-       unsigned int parent_rate = clk_get_rate(clk->parent);
-       u32 val, div;
-       u32 mfn, mfd = 1000000;
-       s64 temp64;
-
-       if (rate < FREQ_650M || rate > FREQ_1300M)
-               return -EINVAL;
-
-       div = rate / parent_rate;
-       temp64 = (u64) (rate - div * parent_rate);
-       temp64 *= mfd;
-       do_div(temp64, parent_rate);
-       mfn = temp64;
-
-       val = readl_relaxed(reg);
-       val &= ~BM_PLL_AV_DIV_SELECT;
-       val |= div << BP_PLL_AV_DIV_SELECT;
-       writel_relaxed(val, reg);
-       writel_relaxed(mfn, reg + PLL_NUM_OFFSET);
-       writel_relaxed(mfd, reg + PLL_DENOM_OFFSET);
-
-       return 0;
-}
-
-static void __iomem *pll_get_div_reg_bit(struct clk *clk, u32 *bp, u32 *bm)
-{
-       void __iomem *reg;
-
-       if (clk == &pll2_bus) {
-               reg = PLL2_BUS;
-               *bp = BP_PLL_BUS_DIV_SELECT;
-               *bm = BM_PLL_BUS_DIV_SELECT;
-       } else if (clk == &pll3_usb_otg) {
-               reg = PLL3_USB_OTG;
-               *bp = BP_PLL_USB_DIV_SELECT;
-               *bm = BM_PLL_USB_DIV_SELECT;
-       } else if (clk == &pll7_usb_host) {
-               reg = PLL7_USB_HOST;
-               *bp = BP_PLL_USB_DIV_SELECT;
-               *bm = BM_PLL_USB_DIV_SELECT;
-       } else {
-               BUG();
-       }
-
-       return reg;
-}
-
-static unsigned long pll_get_rate(struct clk *clk)
-{
-       void __iomem *reg;
-       u32 div, bp, bm;
-
-       reg = pll_get_div_reg_bit(clk, &bp, &bm);
-       div = (readl_relaxed(reg) & bm) >> bp;
-
-       return (div == 1) ? clk_get_rate(clk->parent) * 22 :
-                           clk_get_rate(clk->parent) * 20;
-}
-
-static int pll_set_rate(struct clk *clk, unsigned long rate)
-{
-       void __iomem *reg;
-       u32 val, div, bp, bm;
-
-       if (rate == FREQ_528M)
-               div = 1;
-       else if (rate == FREQ_480M)
-               div = 0;
-       else
-               return -EINVAL;
-
-       reg = pll_get_div_reg_bit(clk, &bp, &bm);
-       val = readl_relaxed(reg);
-       val &= ~bm;
-       val |= div << bp;
-       writel_relaxed(val, reg);
-
-       return 0;
-}
-
-#define pll2_bus_get_rate      pll_get_rate
-#define pll2_bus_set_rate      pll_set_rate
-#define pll3_usb_otg_get_rate  pll_get_rate
-#define pll3_usb_otg_set_rate  pll_set_rate
-#define pll7_usb_host_get_rate pll_get_rate
-#define pll7_usb_host_set_rate pll_set_rate
-#define pll4_audio_get_rate    pll_av_get_rate
-#define pll4_audio_set_rate    pll_av_set_rate
-#define pll5_video_get_rate    pll_av_get_rate
-#define pll5_video_set_rate    pll_av_set_rate
-#define pll6_mlb_get_rate      NULL
-#define pll6_mlb_set_rate      NULL
-
-#define DEF_PLL(name)                                  \
-       static struct clk name = {                      \
-               .enable         = pll_enable,           \
-               .disable        = pll_disable,          \
-               .get_rate       = name##_get_rate,      \
-               .set_rate       = name##_set_rate,      \
-               .parent         = &osc_clk,             \
-       }
-
-DEF_PLL(pll1_sys);
-DEF_PLL(pll2_bus);
-DEF_PLL(pll3_usb_otg);
-DEF_PLL(pll4_audio);
-DEF_PLL(pll5_video);
-DEF_PLL(pll6_mlb);
-DEF_PLL(pll7_usb_host);
-DEF_PLL(pll8_enet);
-
-static unsigned long pfd_get_rate(struct clk *clk)
-{
-       u64 tmp = (u64) clk_get_rate(clk->parent) * 18;
-       u32 frac, bp_frac;
-
-       if (apbh_dma_clk.usecount == 0)
-               apbh_dma_clk.enable(&apbh_dma_clk);
-
-       bp_frac = clk->enable_shift - 7;
-       frac = readl_relaxed(clk->enable_reg) >> bp_frac & PFD_FRAC_MASK;
-       do_div(tmp, frac);
-
-       return tmp;
-}
-
-static int pfd_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 val, frac, bp_frac;
-       u64 tmp = (u64) clk_get_rate(clk->parent) * 18;
-
-       if (apbh_dma_clk.usecount == 0)
-               apbh_dma_clk.enable(&apbh_dma_clk);
-
-       /*
-        * Round up the divider so that we don't set a rate
-        * higher than what is requested
-        */
-       tmp += rate / 2;
-       do_div(tmp, rate);
-       frac = tmp;
-       frac = (frac < 12) ? 12 : frac;
-       frac = (frac > 35) ? 35 : frac;
-
-       /*
-        * The frac field always starts from 7 bits lower
-        * position of enable bit
-        */
-       bp_frac = clk->enable_shift - 7;
-       val = readl_relaxed(clk->enable_reg);
-       val &= ~(PFD_FRAC_MASK << bp_frac);
-       val |= frac << bp_frac;
-       writel_relaxed(val, clk->enable_reg);
-
-       tmp = (u64) clk_get_rate(clk->parent) * 18;
-       do_div(tmp, frac);
-
-       if (apbh_dma_clk.usecount == 0)
-               apbh_dma_clk.disable(&apbh_dma_clk);
-
-       return 0;
-}
-
-static unsigned long pfd_round_rate(struct clk *clk, unsigned long rate)
-{
-       u32 frac;
-       u64 tmp;
-
-       tmp = (u64) clk_get_rate(clk->parent) * 18;
-       tmp += rate / 2;
-       do_div(tmp, rate);
-       frac = tmp;
-       frac = (frac < 12) ? 12 : frac;
-       frac = (frac > 35) ? 35 : frac;
-       tmp = (u64) clk_get_rate(clk->parent) * 18;
-       do_div(tmp, frac);
-
-       return tmp;
-}
-
-static int pfd_enable(struct clk *clk)
-{
-       u32 val;
-
-       if (apbh_dma_clk.usecount == 0)
-               apbh_dma_clk.enable(&apbh_dma_clk);
-
-       val = readl_relaxed(clk->enable_reg);
-       val &= ~(1 << clk->enable_shift);
-       writel_relaxed(val, clk->enable_reg);
-
-       if (apbh_dma_clk.usecount == 0)
-               apbh_dma_clk.disable(&apbh_dma_clk);
-
-       return 0;
-}
-
-static void pfd_disable(struct clk *clk)
-{
-       u32 val;
-
-       if (apbh_dma_clk.usecount == 0)
-               apbh_dma_clk.enable(&apbh_dma_clk);
-
-       val = readl_relaxed(clk->enable_reg);
-       val |= 1 << clk->enable_shift;
-       writel_relaxed(val, clk->enable_reg);
-
-       if (apbh_dma_clk.usecount == 0)
-               apbh_dma_clk.disable(&apbh_dma_clk);
-}
-
-#define DEF_PFD(name, er, es, p)                       \
-       static struct clk name = {                      \
-               .enable_reg     = er,                   \
-               .enable_shift   = es,                   \
-               .enable         = pfd_enable,           \
-               .disable        = pfd_disable,          \
-               .get_rate       = pfd_get_rate,         \
-               .set_rate       = pfd_set_rate,         \
-               .round_rate     = pfd_round_rate,       \
-               .parent         = p,                    \
-       }
-
-DEF_PFD(pll2_pfd_352m, PFD_528, PFD0, &pll2_bus);
-DEF_PFD(pll2_pfd_594m, PFD_528, PFD1, &pll2_bus);
-DEF_PFD(pll2_pfd_400m, PFD_528, PFD2, &pll2_bus);
-DEF_PFD(pll3_pfd_720m, PFD_480, PFD0, &pll3_usb_otg);
-DEF_PFD(pll3_pfd_540m, PFD_480, PFD1, &pll3_usb_otg);
-DEF_PFD(pll3_pfd_508m, PFD_480, PFD2, &pll3_usb_otg);
-DEF_PFD(pll3_pfd_454m, PFD_480, PFD3, &pll3_usb_otg);
-
-static unsigned long twd_clk_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / 2;
-}
-
-static struct clk twd_clk = {
-       .parent = &arm_clk,
-       .get_rate = twd_clk_get_rate,
-};
-
-static unsigned long pll2_200m_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / 2;
-}
-
-static struct clk pll2_200m = {
-       .parent = &pll2_pfd_400m,
-       .get_rate = pll2_200m_get_rate,
-};
-
-static unsigned long pll3_120m_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / 4;
-}
-
-static struct clk pll3_120m = {
-       .parent = &pll3_usb_otg,
-       .get_rate = pll3_120m_get_rate,
-};
-
-static unsigned long pll3_80m_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / 6;
-}
-
-static struct clk pll3_80m = {
-       .parent = &pll3_usb_otg,
-       .get_rate = pll3_80m_get_rate,
-};
-
-static unsigned long pll3_60m_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / 8;
-}
-
-static struct clk pll3_60m = {
-       .parent = &pll3_usb_otg,
-       .get_rate = pll3_60m_get_rate,
-};
-
-static int pll1_sw_clk_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 val = readl_relaxed(CCSR);
-
-       if (parent == &pll1_sys) {
-               val &= ~BM_CCSR_PLL1_SW_SEL;
-               val &= ~BM_CCSR_STEP_SEL;
-       } else if (parent == &osc_clk) {
-               val |= BM_CCSR_PLL1_SW_SEL;
-               val &= ~BM_CCSR_STEP_SEL;
-       } else if (parent == &pll2_pfd_400m) {
-               val |= BM_CCSR_PLL1_SW_SEL;
-               val |= BM_CCSR_STEP_SEL;
-       } else {
-               return -EINVAL;
-       }
-
-       writel_relaxed(val, CCSR);
-
-       return 0;
-}
-
-static struct clk pll1_sw_clk = {
-       .parent = &pll1_sys,
-       .set_parent = pll1_sw_clk_set_parent,
-};
-
-static void calc_pred_podf_dividers(u32 div, u32 *pred, u32 *podf)
-{
-       u32 min_pred, temp_pred, old_err, err;
-
-       if (div >= 512) {
-               *pred = 8;
-               *podf = 64;
-       } else if (div >= 8) {
-               min_pred = (div - 1) / 64 + 1;
-               old_err = 8;
-               for (temp_pred = 8; temp_pred >= min_pred; temp_pred--) {
-                       err = div % temp_pred;
-                       if (err == 0) {
-                               *pred = temp_pred;
-                               break;
-                       }
-                       err = temp_pred - err;
-                       if (err < old_err) {
-                               old_err = err;
-                               *pred = temp_pred;
-                       }
-               }
-               *podf = (div + *pred - 1) / *pred;
-       } else if (div < 8) {
-               *pred = div;
-               *podf = 1;
-       }
-}
-
-static int _clk_enable(struct clk *clk)
-{
-       u32 reg;
-       reg = readl_relaxed(clk->enable_reg);
-       reg |= 0x3 << clk->enable_shift;
-       writel_relaxed(reg, clk->enable_reg);
-
-       return 0;
-}
-
-static void _clk_disable(struct clk *clk)
-{
-       u32 reg;
-       reg = readl_relaxed(clk->enable_reg);
-       reg &= ~(0x3 << clk->enable_shift);
-       writel_relaxed(reg, clk->enable_reg);
-}
-
-static int _clk_enable_1b(struct clk *clk)
-{
-       u32 reg;
-       reg = readl_relaxed(clk->enable_reg);
-       reg |= 0x1 << clk->enable_shift;
-       writel_relaxed(reg, clk->enable_reg);
-
-       return 0;
-}
-
-static void _clk_disable_1b(struct clk *clk)
-{
-       u32 reg;
-       reg = readl_relaxed(clk->enable_reg);
-       reg &= ~(0x1 << clk->enable_shift);
-       writel_relaxed(reg, clk->enable_reg);
-}
-
-struct divider {
-       struct clk *clk;
-       void __iomem *reg;
-       u32 bp_pred;
-       u32 bm_pred;
-       u32 bp_podf;
-       u32 bm_podf;
-};
-
-#define DEF_CLK_DIV1(d, c, r, b)                               \
-       static struct divider d = {                             \
-               .clk = c,                                       \
-               .reg = r,                                       \
-               .bp_podf = BP_##r##_##b##_PODF,                 \
-               .bm_podf = BM_##r##_##b##_PODF,                 \
-       }
-
-DEF_CLK_DIV1(arm_div,          &arm_clk,               CACRR,  ARM);
-DEF_CLK_DIV1(ipg_div,          &ipg_clk,               CBCDR,  IPG);
-DEF_CLK_DIV1(ahb_div,          &ahb_clk,               CBCDR,  AHB);
-DEF_CLK_DIV1(axi_div,          &axi_clk,               CBCDR,  AXI);
-DEF_CLK_DIV1(mmdc_ch0_axi_div, &mmdc_ch0_axi_clk,      CBCDR,  MMDC_CH0_AXI);
-DEF_CLK_DIV1(mmdc_ch1_axi_div, &mmdc_ch1_axi_clk,      CBCDR,  MMDC_CH1_AXI);
-DEF_CLK_DIV1(periph_clk2_div,  &periph_clk2_clk,       CBCDR,  PERIPH_CLK2);
-DEF_CLK_DIV1(periph2_clk2_div, &periph2_clk2_clk,      CBCDR,  PERIPH2_CLK2);
-DEF_CLK_DIV1(gpu2d_core_div,   &gpu2d_core_clk,        CBCMR,  GPU2D_CORE);
-DEF_CLK_DIV1(gpu3d_core_div,   &gpu3d_core_clk,        CBCMR,  GPU3D_CORE);
-DEF_CLK_DIV1(gpu3d_shader_div, &gpu3d_shader_clk,      CBCMR,  GPU3D_SHADER);
-DEF_CLK_DIV1(ipg_perclk_div,   &ipg_perclk,            CSCMR1, PERCLK);
-DEF_CLK_DIV1(emi_div,          &emi_clk,               CSCMR1, EMI);
-DEF_CLK_DIV1(emi_slow_div,     &emi_slow_clk,          CSCMR1, EMI_SLOW);
-DEF_CLK_DIV1(can_div,          &can1_clk,              CSCMR2, CAN);
-DEF_CLK_DIV1(uart_div,         &uart_clk,              CSCDR1, UART);
-DEF_CLK_DIV1(usdhc1_div,       &usdhc1_clk,            CSCDR1, USDHC1);
-DEF_CLK_DIV1(usdhc2_div,       &usdhc2_clk,            CSCDR1, USDHC2);
-DEF_CLK_DIV1(usdhc3_div,       &usdhc3_clk,            CSCDR1, USDHC3);
-DEF_CLK_DIV1(usdhc4_div,       &usdhc4_clk,            CSCDR1, USDHC4);
-DEF_CLK_DIV1(vpu_div,          &vpu_clk,               CSCDR1, VPU_AXI);
-DEF_CLK_DIV1(hsi_tx_div,       &hsi_tx_clk,            CDCDR,  HSI_TX);
-DEF_CLK_DIV1(ipu1_di0_pre_div, &ipu1_di0_pre_clk,      CHSCCDR, IPU1_DI0_PRE);
-DEF_CLK_DIV1(ipu1_di1_pre_div, &ipu1_di1_pre_clk,      CHSCCDR, IPU1_DI1_PRE);
-DEF_CLK_DIV1(ipu2_di0_pre_div, &ipu2_di0_pre_clk,      CSCDR2, IPU2_DI0_PRE);
-DEF_CLK_DIV1(ipu2_di1_pre_div, &ipu2_di1_pre_clk,      CSCDR2, IPU2_DI1_PRE);
-DEF_CLK_DIV1(ipu1_div,         &ipu1_clk,              CSCDR3, IPU1_HSP);
-DEF_CLK_DIV1(ipu2_div,         &ipu2_clk,              CSCDR3, IPU2_HSP);
-DEF_CLK_DIV1(cko1_div,         &cko1_clk,              CCOSR, CKO1);
-
-#define DEF_CLK_DIV2(d, c, r, b)                               \
-       static struct divider d = {                             \
-               .clk = c,                                       \
-               .reg = r,                                       \
-               .bp_pred = BP_##r##_##b##_PRED,                 \
-               .bm_pred = BM_##r##_##b##_PRED,                 \
-               .bp_podf = BP_##r##_##b##_PODF,                 \
-               .bm_podf = BM_##r##_##b##_PODF,                 \
-       }
-
-DEF_CLK_DIV2(ssi1_div,         &ssi1_clk,              CS1CDR, SSI1);
-DEF_CLK_DIV2(ssi3_div,         &ssi3_clk,              CS1CDR, SSI3);
-DEF_CLK_DIV2(esai_div,         &esai_clk,              CS1CDR, ESAI);
-DEF_CLK_DIV2(ssi2_div,         &ssi2_clk,              CS2CDR, SSI2);
-DEF_CLK_DIV2(enfc_div,         &enfc_clk,              CS2CDR, ENFC);
-DEF_CLK_DIV2(spdif_div,                &spdif_clk,             CDCDR,  SPDIF);
-DEF_CLK_DIV2(asrc_serial_div,  &asrc_serial_clk,       CDCDR,  ASRC_SERIAL);
-
-static struct divider *dividers[] = {
-       &arm_div,
-       &ipg_div,
-       &ahb_div,
-       &axi_div,
-       &mmdc_ch0_axi_div,
-       &mmdc_ch1_axi_div,
-       &periph_clk2_div,
-       &periph2_clk2_div,
-       &gpu2d_core_div,
-       &gpu3d_core_div,
-       &gpu3d_shader_div,
-       &ipg_perclk_div,
-       &emi_div,
-       &emi_slow_div,
-       &can_div,
-       &uart_div,
-       &usdhc1_div,
-       &usdhc2_div,
-       &usdhc3_div,
-       &usdhc4_div,
-       &vpu_div,
-       &hsi_tx_div,
-       &ipu1_di0_pre_div,
-       &ipu1_di1_pre_div,
-       &ipu2_di0_pre_div,
-       &ipu2_di1_pre_div,
-       &ipu1_div,
-       &ipu2_div,
-       &ssi1_div,
-       &ssi3_div,
-       &esai_div,
-       &ssi2_div,
-       &enfc_div,
-       &spdif_div,
-       &asrc_serial_div,
-       &cko1_div,
-};
-
-static unsigned long ldb_di_clk_get_rate(struct clk *clk)
-{
-       u32 val = readl_relaxed(CSCMR2);
-
-       val &= (clk == &ldb_di0_clk) ? BM_CSCMR2_LDB_DI0_IPU_DIV :
-                                      BM_CSCMR2_LDB_DI1_IPU_DIV;
-       if (val)
-               return clk_get_rate(clk->parent) / 7;
-       else
-               return clk_get_rate(clk->parent) * 2 / 7;
-}
-
-static int ldb_di_clk_set_rate(struct clk *clk, unsigned long rate)
-{
-       unsigned long parent_rate = clk_get_rate(clk->parent);
-       u32 val = readl_relaxed(CSCMR2);
-
-       if (rate * 7 <= parent_rate + parent_rate / 20)
-               val |= BM_CSCMR2_LDB_DI0_IPU_DIV;
-       else
-               val &= ~BM_CSCMR2_LDB_DI0_IPU_DIV;
-
-       writel_relaxed(val, CSCMR2);
-
-       return 0;
-}
-
-static unsigned long ldb_di_clk_round_rate(struct clk *clk, unsigned long rate)
-{
-       unsigned long parent_rate = clk_get_rate(clk->parent);
-
-       if (rate * 7 <= parent_rate + parent_rate / 20)
-               return parent_rate / 7;
-       else
-               return 2 * parent_rate / 7;
-}
-
-static unsigned long _clk_get_rate(struct clk *clk)
-{
-       struct divider *d;
-       u32 val, pred, podf;
-       int i, num;
-
-       if (clk == &ldb_di0_clk || clk == &ldb_di1_clk)
-               return ldb_di_clk_get_rate(clk);
-
-       num = ARRAY_SIZE(dividers);
-       for (i = 0; i < num; i++)
-               if (dividers[i]->clk == clk) {
-                       d = dividers[i];
-                       break;
-               }
-       if (i == num)
-               return clk_get_rate(clk->parent);
-
-       val = readl_relaxed(d->reg);
-       pred = ((val & d->bm_pred) >> d->bp_pred) + 1;
-       podf = ((val & d->bm_podf) >> d->bp_podf) + 1;
-
-       return clk_get_rate(clk->parent) / (pred * podf);
-}
-
-static int clk_busy_wait(struct clk *clk)
-{
-       int timeout = 0x100000;
-       u32 bm;
-
-       if (clk == &axi_clk)
-               bm = BM_CDHIPR_AXI_PODF_BUSY;
-       else if (clk == &ahb_clk)
-               bm = BM_CDHIPR_AHB_PODF_BUSY;
-       else if (clk == &mmdc_ch0_axi_clk)
-               bm = BM_CDHIPR_MMDC_CH0_PODF_BUSY;
-       else if (clk == &periph_clk)
-               bm = BM_CDHIPR_PERIPH_SEL_BUSY;
-       else if (clk == &arm_clk)
-               bm = BM_CDHIPR_ARM_PODF_BUSY;
-       else
-               return -EINVAL;
-
-       while ((readl_relaxed(CDHIPR) & bm) && --timeout)
-               cpu_relax();
-
-       if (unlikely(!timeout))
-               return -EBUSY;
-
-       return 0;
-}
-
-static int _clk_set_rate(struct clk *clk, unsigned long rate)
-{
-       unsigned long parent_rate = clk_get_rate(clk->parent);
-       struct divider *d;
-       u32 val, div, max_div, pred = 0, podf;
-       int i, num;
-
-       if (clk == &ldb_di0_clk || clk == &ldb_di1_clk)
-               return ldb_di_clk_set_rate(clk, rate);
-
-       num = ARRAY_SIZE(dividers);
-       for (i = 0; i < num; i++)
-               if (dividers[i]->clk == clk) {
-                       d = dividers[i];
-                       break;
-               }
-       if (i == num)
-               return -EINVAL;
-
-       max_div = ((d->bm_pred >> d->bp_pred) + 1) *
-                 ((d->bm_podf >> d->bp_podf) + 1);
-
-       div = parent_rate / rate;
-       if (div == 0)
-               div++;
-
-       if ((parent_rate / div != rate) || div > max_div)
-               return -EINVAL;
-
-       if (d->bm_pred) {
-               calc_pred_podf_dividers(div, &pred, &podf);
-       } else {
-               pred = 1;
-               podf = div;
-       }
-
-       val = readl_relaxed(d->reg);
-       val &= ~(d->bm_pred | d->bm_podf);
-       val |= (pred - 1) << d->bp_pred | (podf - 1) << d->bp_podf;
-       writel_relaxed(val, d->reg);
-
-       if (clk == &axi_clk || clk == &ahb_clk ||
-           clk == &mmdc_ch0_axi_clk || clk == &arm_clk)
-               return clk_busy_wait(clk);
-
-       return 0;
-}
-
-static unsigned long _clk_round_rate(struct clk *clk, unsigned long rate)
-{
-       unsigned long parent_rate = clk_get_rate(clk->parent);
-       u32 div = parent_rate / rate;
-       u32 div_max, pred = 0, podf;
-       struct divider *d;
-       int i, num;
-
-       if (clk == &ldb_di0_clk || clk == &ldb_di1_clk)
-               return ldb_di_clk_round_rate(clk, rate);
-
-       num = ARRAY_SIZE(dividers);
-       for (i = 0; i < num; i++)
-               if (dividers[i]->clk == clk) {
-                       d = dividers[i];
-                       break;
-               }
-       if (i == num)
-               return -EINVAL;
-
-       if (div == 0 || parent_rate % rate)
-               div++;
-
-       if (d->bm_pred) {
-               calc_pred_podf_dividers(div, &pred, &podf);
-               div = pred * podf;
-       } else {
-               div_max = (d->bm_podf >> d->bp_podf) + 1;
-               if (div > div_max)
-                       div = div_max;
-       }
-
-       return parent_rate / div;
-}
-
-struct multiplexer {
-       struct clk *clk;
-       void __iomem *reg;
-       u32 bp;
-       u32 bm;
-       int pnum;
-       struct clk *parents[];
-};
-
-static struct multiplexer axi_mux = {
-       .clk = &axi_clk,
-       .reg = CBCDR,
-       .bp = BP_CBCDR_AXI_SEL,
-       .bm = BM_CBCDR_AXI_SEL,
-       .parents = {
-               &periph_clk,
-               &pll2_pfd_400m,
-               &pll3_pfd_540m,
-               NULL
-       },
-};
-
-static struct multiplexer periph_mux = {
-       .clk = &periph_clk,
-       .reg = CBCDR,
-       .bp = BP_CBCDR_PERIPH_CLK_SEL,
-       .bm = BM_CBCDR_PERIPH_CLK_SEL,
-       .parents = {
-               &periph_pre_clk,
-               &periph_clk2_clk,
-               NULL
-       },
-};
-
-static struct multiplexer periph_pre_mux = {
-       .clk = &periph_pre_clk,
-       .reg = CBCMR,
-       .bp = BP_CBCMR_PRE_PERIPH_CLK_SEL,
-       .bm = BM_CBCMR_PRE_PERIPH_CLK_SEL,
-       .parents = {
-               &pll2_bus,
-               &pll2_pfd_400m,
-               &pll2_pfd_352m,
-               &pll2_200m,
-               NULL
-       },
-};
-
-static struct multiplexer periph_clk2_mux = {
-       .clk = &periph_clk2_clk,
-       .reg = CBCMR,
-       .bp = BP_CBCMR_PERIPH_CLK2_SEL,
-       .bm = BM_CBCMR_PERIPH_CLK2_SEL,
-       .parents = {
-               &pll3_usb_otg,
-               &osc_clk,
-               NULL
-       },
-};
-
-static struct multiplexer periph2_mux = {
-       .clk = &periph2_clk,
-       .reg = CBCDR,
-       .bp = BP_CBCDR_PERIPH2_CLK_SEL,
-       .bm = BM_CBCDR_PERIPH2_CLK_SEL,
-       .parents = {
-               &periph2_pre_clk,
-               &periph2_clk2_clk,
-               NULL
-       },
-};
-
-static struct multiplexer periph2_pre_mux = {
-       .clk = &periph2_pre_clk,
-       .reg = CBCMR,
-       .bp = BP_CBCMR_PRE_PERIPH2_CLK_SEL,
-       .bm = BM_CBCMR_PRE_PERIPH2_CLK_SEL,
-       .parents = {
-               &pll2_bus,
-               &pll2_pfd_400m,
-               &pll2_pfd_352m,
-               &pll2_200m,
-               NULL
-       },
-};
-
-static struct multiplexer periph2_clk2_mux = {
-       .clk = &periph2_clk2_clk,
-       .reg = CBCMR,
-       .bp = BP_CBCMR_PERIPH2_CLK2_SEL,
-       .bm = BM_CBCMR_PERIPH2_CLK2_SEL,
-       .parents = {
-               &pll3_usb_otg,
-               &osc_clk,
-               NULL
-       },
-};
-
-static struct multiplexer gpu2d_axi_mux = {
-       .clk = &gpu2d_axi_clk,
-       .reg = CBCMR,
-       .bp = BP_CBCMR_GPU2D_AXI_SEL,
-       .bm = BM_CBCMR_GPU2D_AXI_SEL,
-       .parents = {
-               &axi_clk,
-               &ahb_clk,
-               NULL
-       },
-};
-
-static struct multiplexer gpu3d_axi_mux = {
-       .clk = &gpu3d_axi_clk,
-       .reg = CBCMR,
-       .bp = BP_CBCMR_GPU3D_AXI_SEL,
-       .bm = BM_CBCMR_GPU3D_AXI_SEL,
-       .parents = {
-               &axi_clk,
-               &ahb_clk,
-               NULL
-       },
-};
-
-static struct multiplexer gpu3d_core_mux = {
-       .clk = &gpu3d_core_clk,
-       .reg = CBCMR,
-       .bp = BP_CBCMR_GPU3D_CORE_SEL,
-       .bm = BM_CBCMR_GPU3D_CORE_SEL,
-       .parents = {
-               &mmdc_ch0_axi_clk,
-               &pll3_usb_otg,
-               &pll2_pfd_594m,
-               &pll2_pfd_400m,
-               NULL
-       },
-};
-
-static struct multiplexer gpu3d_shader_mux = {
-       .clk = &gpu3d_shader_clk,
-       .reg = CBCMR,
-       .bp = BP_CBCMR_GPU3D_SHADER_SEL,
-       .bm = BM_CBCMR_GPU3D_SHADER_SEL,
-       .parents = {
-               &mmdc_ch0_axi_clk,
-               &pll3_usb_otg,
-               &pll2_pfd_594m,
-               &pll3_pfd_720m,
-               NULL
-       },
-};
-
-static struct multiplexer pcie_axi_mux = {
-       .clk = &pcie_clk,
-       .reg = CBCMR,
-       .bp = BP_CBCMR_PCIE_AXI_SEL,
-       .bm = BM_CBCMR_PCIE_AXI_SEL,
-       .parents = {
-               &axi_clk,
-               &ahb_clk,
-               NULL
-       },
-};
-
-static struct multiplexer vdo_axi_mux = {
-       .clk = &vdo_axi_clk,
-       .reg = CBCMR,
-       .bp = BP_CBCMR_VDO_AXI_SEL,
-       .bm = BM_CBCMR_VDO_AXI_SEL,
-       .parents = {
-               &axi_clk,
-               &ahb_clk,
-               NULL
-       },
-};
-
-static struct multiplexer vpu_axi_mux = {
-       .clk = &vpu_clk,
-       .reg = CBCMR,
-       .bp = BP_CBCMR_VPU_AXI_SEL,
-       .bm = BM_CBCMR_VPU_AXI_SEL,
-       .parents = {
-               &axi_clk,
-               &pll2_pfd_400m,
-               &pll2_pfd_352m,
-               NULL
-       },
-};
-
-static struct multiplexer gpu2d_core_mux = {
-       .clk = &gpu2d_core_clk,
-       .reg = CBCMR,
-       .bp = BP_CBCMR_GPU2D_CORE_SEL,
-       .bm = BM_CBCMR_GPU2D_CORE_SEL,
-       .parents = {
-               &axi_clk,
-               &pll3_usb_otg,
-               &pll2_pfd_352m,
-               &pll2_pfd_400m,
-               NULL
-       },
-};
-
-#define DEF_SSI_MUX(id)                                                        \
-       static struct multiplexer ssi##id##_mux = {                     \
-               .clk = &ssi##id##_clk,                                  \
-               .reg = CSCMR1,                                          \
-               .bp = BP_CSCMR1_SSI##id##_SEL,                          \
-               .bm = BM_CSCMR1_SSI##id##_SEL,                          \
-               .parents = {                                            \
-                       &pll3_pfd_508m,                                 \
-                       &pll3_pfd_454m,                                 \
-                       &pll4_audio,                                    \
-                       NULL                                            \
-               },                                                      \
-       }
-
-DEF_SSI_MUX(1);
-DEF_SSI_MUX(2);
-DEF_SSI_MUX(3);
-
-#define DEF_USDHC_MUX(id)                                              \
-       static struct multiplexer usdhc##id##_mux = {                   \
-               .clk = &usdhc##id##_clk,                                \
-               .reg = CSCMR1,                                          \
-               .bp = BP_CSCMR1_USDHC##id##_SEL,                        \
-               .bm = BM_CSCMR1_USDHC##id##_SEL,                        \
-               .parents = {                                            \
-                       &pll2_pfd_400m,                                 \
-                       &pll2_pfd_352m,                                 \
-                       NULL                                            \
-               },                                                      \
-       }
-
-DEF_USDHC_MUX(1);
-DEF_USDHC_MUX(2);
-DEF_USDHC_MUX(3);
-DEF_USDHC_MUX(4);
-
-static struct multiplexer emi_mux = {
-       .clk = &emi_clk,
-       .reg = CSCMR1,
-       .bp = BP_CSCMR1_EMI_SEL,
-       .bm = BM_CSCMR1_EMI_SEL,
-       .parents = {
-               &axi_clk,
-               &pll3_usb_otg,
-               &pll2_pfd_400m,
-               &pll2_pfd_352m,
-               NULL
-       },
-};
-
-static struct multiplexer emi_slow_mux = {
-       .clk = &emi_slow_clk,
-       .reg = CSCMR1,
-       .bp = BP_CSCMR1_EMI_SLOW_SEL,
-       .bm = BM_CSCMR1_EMI_SLOW_SEL,
-       .parents = {
-               &axi_clk,
-               &pll3_usb_otg,
-               &pll2_pfd_400m,
-               &pll2_pfd_352m,
-               NULL
-       },
-};
-
-static struct multiplexer esai_mux = {
-       .clk = &esai_clk,
-       .reg = CSCMR2,
-       .bp = BP_CSCMR2_ESAI_SEL,
-       .bm = BM_CSCMR2_ESAI_SEL,
-       .parents = {
-               &pll4_audio,
-               &pll3_pfd_508m,
-               &pll3_pfd_454m,
-               &pll3_usb_otg,
-               NULL
-       },
-};
-
-#define DEF_LDB_DI_MUX(id)                                             \
-       static struct multiplexer ldb_di##id##_mux = {                  \
-               .clk = &ldb_di##id##_clk,                               \
-               .reg = CS2CDR,                                          \
-               .bp = BP_CS2CDR_LDB_DI##id##_SEL,                       \
-               .bm = BM_CS2CDR_LDB_DI##id##_SEL,                       \
-               .parents = {                                            \
-                       &pll5_video,                                    \
-                       &pll2_pfd_352m,                                 \
-                       &pll2_pfd_400m,                                 \
-                       &pll3_pfd_540m,                                 \
-                       &pll3_usb_otg,                                  \
-                       NULL                                            \
-               },                                                      \
-       }
-
-DEF_LDB_DI_MUX(0);
-DEF_LDB_DI_MUX(1);
-
-static struct multiplexer enfc_mux = {
-       .clk = &enfc_clk,
-       .reg = CS2CDR,
-       .bp = BP_CS2CDR_ENFC_SEL,
-       .bm = BM_CS2CDR_ENFC_SEL,
-       .parents = {
-               &pll2_pfd_352m,
-               &pll2_bus,
-               &pll3_usb_otg,
-               &pll2_pfd_400m,
-               NULL
-       },
-};
-
-static struct multiplexer spdif_mux = {
-       .clk = &spdif_clk,
-       .reg = CDCDR,
-       .bp = BP_CDCDR_SPDIF_SEL,
-       .bm = BM_CDCDR_SPDIF_SEL,
-       .parents = {
-               &pll4_audio,
-               &pll3_pfd_508m,
-               &pll3_pfd_454m,
-               &pll3_usb_otg,
-               NULL
-       },
-};
-
-static struct multiplexer asrc_serial_mux = {
-       .clk = &asrc_serial_clk,
-       .reg = CDCDR,
-       .bp = BP_CDCDR_ASRC_SERIAL_SEL,
-       .bm = BM_CDCDR_ASRC_SERIAL_SEL,
-       .parents = {
-               &pll4_audio,
-               &pll3_pfd_508m,
-               &pll3_pfd_454m,
-               &pll3_usb_otg,
-               NULL
-       },
-};
-
-static struct multiplexer hsi_tx_mux = {
-       .clk = &hsi_tx_clk,
-       .reg = CDCDR,
-       .bp = BP_CDCDR_HSI_TX_SEL,
-       .bm = BM_CDCDR_HSI_TX_SEL,
-       .parents = {
-               &pll3_120m,
-               &pll2_pfd_400m,
-               NULL
-       },
-};
-
-#define DEF_IPU_DI_PRE_MUX(r, i, d)                                    \
-       static struct multiplexer ipu##i##_di##d##_pre_mux = {          \
-               .clk = &ipu##i##_di##d##_pre_clk,                       \
-               .reg = r,                                               \
-               .bp = BP_##r##_IPU##i##_DI##d##_PRE_SEL,                \
-               .bm = BM_##r##_IPU##i##_DI##d##_PRE_SEL,                \
-               .parents = {                                            \
-                       &mmdc_ch0_axi_clk,                              \
-                       &pll3_usb_otg,                                  \
-                       &pll5_video,                                    \
-                       &pll2_pfd_352m,                                 \
-                       &pll2_pfd_400m,                                 \
-                       &pll3_pfd_540m,                                 \
-                       NULL                                            \
-               },                                                      \
-       }
-
-DEF_IPU_DI_PRE_MUX(CHSCCDR, 1, 0);
-DEF_IPU_DI_PRE_MUX(CHSCCDR, 1, 1);
-DEF_IPU_DI_PRE_MUX(CSCDR2, 2, 0);
-DEF_IPU_DI_PRE_MUX(CSCDR2, 2, 1);
-
-#define DEF_IPU_DI_MUX(r, i, d)                                                \
-       static struct multiplexer ipu##i##_di##d##_mux = {              \
-               .clk = &ipu##i##_di##d##_clk,                           \
-               .reg = r,                                               \
-               .bp = BP_##r##_IPU##i##_DI##d##_SEL,                    \
-               .bm = BM_##r##_IPU##i##_DI##d##_SEL,                    \
-               .parents = {                                            \
-                       &ipu##i##_di##d##_pre_clk,                      \
-                       &dummy_clk,                                     \
-                       &dummy_clk,                                     \
-                       &ldb_di0_clk,                                   \
-                       &ldb_di1_clk,                                   \
-                       NULL                                            \
-               },                                                      \
-       }
-
-DEF_IPU_DI_MUX(CHSCCDR, 1, 0);
-DEF_IPU_DI_MUX(CHSCCDR, 1, 1);
-DEF_IPU_DI_MUX(CSCDR2, 2, 0);
-DEF_IPU_DI_MUX(CSCDR2, 2, 1);
-
-#define DEF_IPU_MUX(id)                                                        \
-       static struct multiplexer ipu##id##_mux = {                     \
-               .clk = &ipu##id##_clk,                                  \
-               .reg = CSCDR3,                                          \
-               .bp = BP_CSCDR3_IPU##id##_HSP_SEL,                      \
-               .bm = BM_CSCDR3_IPU##id##_HSP_SEL,                      \
-               .parents = {                                            \
-                       &mmdc_ch0_axi_clk,                              \
-                       &pll2_pfd_400m,                                 \
-                       &pll3_120m,                                     \
-                       &pll3_pfd_540m,                                 \
-                       NULL                                            \
-               },                                                      \
-       }
-
-DEF_IPU_MUX(1);
-DEF_IPU_MUX(2);
-
-static struct multiplexer cko1_mux = {
-       .clk = &cko1_clk,
-       .reg = CCOSR,
-       .bp = BP_CCOSR_CKO1_SEL,
-       .bm = BM_CCOSR_CKO1_SEL,
-       .parents = {
-               &pll3_usb_otg,
-               &pll2_bus,
-               &pll1_sys,
-               &pll5_video,
-               &dummy_clk,
-               &axi_clk,
-               &enfc_clk,
-               &ipu1_di0_clk,
-               &ipu1_di1_clk,
-               &ipu2_di0_clk,
-               &ipu2_di1_clk,
-               &ahb_clk,
-               &ipg_clk,
-               &ipg_perclk,
-               &ckil_clk,
-               &pll4_audio,
-               NULL
-       },
-};
-
-static struct multiplexer *multiplexers[] = {
-       &axi_mux,
-       &periph_mux,
-       &periph_pre_mux,
-       &periph_clk2_mux,
-       &periph2_mux,
-       &periph2_pre_mux,
-       &periph2_clk2_mux,
-       &gpu2d_axi_mux,
-       &gpu3d_axi_mux,
-       &gpu3d_core_mux,
-       &gpu3d_shader_mux,
-       &pcie_axi_mux,
-       &vdo_axi_mux,
-       &vpu_axi_mux,
-       &gpu2d_core_mux,
-       &ssi1_mux,
-       &ssi2_mux,
-       &ssi3_mux,
-       &usdhc1_mux,
-       &usdhc2_mux,
-       &usdhc3_mux,
-       &usdhc4_mux,
-       &emi_mux,
-       &emi_slow_mux,
-       &esai_mux,
-       &ldb_di0_mux,
-       &ldb_di1_mux,
-       &enfc_mux,
-       &spdif_mux,
-       &asrc_serial_mux,
-       &hsi_tx_mux,
-       &ipu1_di0_pre_mux,
-       &ipu1_di0_mux,
-       &ipu1_di1_pre_mux,
-       &ipu1_di1_mux,
-       &ipu2_di0_pre_mux,
-       &ipu2_di0_mux,
-       &ipu2_di1_pre_mux,
-       &ipu2_di1_mux,
-       &ipu1_mux,
-       &ipu2_mux,
-       &cko1_mux,
-};
-
-static int _clk_set_parent(struct clk *clk, struct clk *parent)
-{
-       struct multiplexer *m;
-       int i, num;
-       u32 val;
-
-       num = ARRAY_SIZE(multiplexers);
-       for (i = 0; i < num; i++)
-               if (multiplexers[i]->clk == clk) {
-                       m = multiplexers[i];
-                       break;
-               }
-       if (i == num)
-               return -EINVAL;
-
-       i = 0;
-       while (m->parents[i]) {
-               if (parent == m->parents[i])
-                       break;
-               i++;
-       }
-       if (!m->parents[i] || m->parents[i] == &dummy_clk)
-               return -EINVAL;
-
-       val = readl_relaxed(m->reg);
-       val &= ~m->bm;
-       val |= i << m->bp;
-       writel_relaxed(val, m->reg);
-
-       if (clk == &periph_clk)
-               return clk_busy_wait(clk);
-
-       return 0;
-}
-
-#define DEF_NG_CLK(name, p)                            \
-       static struct clk name = {                      \
-               .get_rate       = _clk_get_rate,        \
-               .set_rate       = _clk_set_rate,        \
-               .round_rate     = _clk_round_rate,      \
-               .set_parent     = _clk_set_parent,      \
-               .parent         = p,                    \
-       }
-
-DEF_NG_CLK(periph_clk2_clk,    &osc_clk);
-DEF_NG_CLK(periph_pre_clk,     &pll2_bus);
-DEF_NG_CLK(periph_clk,         &periph_pre_clk);
-DEF_NG_CLK(periph2_clk2_clk,   &osc_clk);
-DEF_NG_CLK(periph2_pre_clk,    &pll2_bus);
-DEF_NG_CLK(periph2_clk,                &periph2_pre_clk);
-DEF_NG_CLK(axi_clk,            &periph_clk);
-DEF_NG_CLK(emi_clk,            &axi_clk);
-DEF_NG_CLK(arm_clk,            &pll1_sw_clk);
-DEF_NG_CLK(ahb_clk,            &periph_clk);
-DEF_NG_CLK(ipg_clk,            &ahb_clk);
-DEF_NG_CLK(ipg_perclk,         &ipg_clk);
-DEF_NG_CLK(ipu1_di0_pre_clk,   &pll3_pfd_540m);
-DEF_NG_CLK(ipu1_di1_pre_clk,   &pll3_pfd_540m);
-DEF_NG_CLK(ipu2_di0_pre_clk,   &pll3_pfd_540m);
-DEF_NG_CLK(ipu2_di1_pre_clk,   &pll3_pfd_540m);
-DEF_NG_CLK(asrc_serial_clk,    &pll3_usb_otg);
-
-#define DEF_CLK(name, er, es, p, s)                    \
-       static struct clk name = {                      \
-               .enable_reg     = er,                   \
-               .enable_shift   = es,                   \
-               .enable         = _clk_enable,          \
-               .disable        = _clk_disable,         \
-               .get_rate       = _clk_get_rate,        \
-               .set_rate       = _clk_set_rate,        \
-               .round_rate     = _clk_round_rate,      \
-               .set_parent     = _clk_set_parent,      \
-               .parent         = p,                    \
-               .secondary      = s,                    \
-       }
-
-#define DEF_CLK_1B(name, er, es, p, s)                 \
-       static struct clk name = {                      \
-               .enable_reg     = er,                   \
-               .enable_shift   = es,                   \
-               .enable         = _clk_enable_1b,       \
-               .disable        = _clk_disable_1b,      \
-               .get_rate       = _clk_get_rate,        \
-               .set_rate       = _clk_set_rate,        \
-               .round_rate     = _clk_round_rate,      \
-               .set_parent     = _clk_set_parent,      \
-               .parent         = p,                    \
-               .secondary      = s,                    \
-       }
-
-DEF_CLK(aips_tz1_clk,    CCGR0, CG0,  &ahb_clk,          NULL);
-DEF_CLK(aips_tz2_clk,    CCGR0, CG1,  &ahb_clk,          NULL);
-DEF_CLK(apbh_dma_clk,    CCGR0, CG2,  &ahb_clk,          NULL);
-DEF_CLK(asrc_clk,        CCGR0, CG3,  &pll4_audio,       NULL);
-DEF_CLK(can1_serial_clk,  CCGR0, CG8,  &pll3_usb_otg,    NULL);
-DEF_CLK(can1_clk,        CCGR0, CG7,  &pll3_usb_otg,     &can1_serial_clk);
-DEF_CLK(can2_serial_clk,  CCGR0, CG10, &pll3_usb_otg,    NULL);
-DEF_CLK(can2_clk,        CCGR0, CG9,  &pll3_usb_otg,     &can2_serial_clk);
-DEF_CLK(ecspi1_clk,      CCGR1, CG0,  &pll3_60m,         NULL);
-DEF_CLK(ecspi2_clk,      CCGR1, CG1,  &pll3_60m,         NULL);
-DEF_CLK(ecspi3_clk,      CCGR1, CG2,  &pll3_60m,         NULL);
-DEF_CLK(ecspi4_clk,      CCGR1, CG3,  &pll3_60m,         NULL);
-DEF_CLK(ecspi5_clk,      CCGR1, CG4,  &pll3_60m,         NULL);
-DEF_CLK(enet_clk,        CCGR1, CG5,  &ipg_clk,          NULL);
-DEF_CLK(esai_clk,        CCGR1, CG8,  &pll3_usb_otg,     NULL);
-DEF_CLK(gpt_serial_clk,          CCGR1, CG11, &ipg_perclk,       NULL);
-DEF_CLK(gpt_clk,         CCGR1, CG10, &ipg_perclk,       &gpt_serial_clk);
-DEF_CLK(gpu2d_core_clk,          CCGR1, CG12, &pll2_pfd_352m,    &gpu2d_axi_clk);
-DEF_CLK(gpu3d_core_clk,          CCGR1, CG13, &pll2_pfd_594m,    &gpu3d_axi_clk);
-DEF_CLK(gpu3d_shader_clk, CCGR1, CG13, &pll3_pfd_720m,   &gpu3d_axi_clk);
-DEF_CLK(hdmi_iahb_clk,   CCGR2, CG0,  &ahb_clk,          NULL);
-DEF_CLK(hdmi_isfr_clk,   CCGR2, CG2,  &pll3_pfd_540m,    &hdmi_iahb_clk);
-DEF_CLK(i2c1_clk,        CCGR2, CG3,  &ipg_perclk,       NULL);
-DEF_CLK(i2c2_clk,        CCGR2, CG4,  &ipg_perclk,       NULL);
-DEF_CLK(i2c3_clk,        CCGR2, CG5,  &ipg_perclk,       NULL);
-DEF_CLK(iim_clk,         CCGR2, CG6,  &ipg_clk,          NULL);
-DEF_CLK(enfc_clk,        CCGR2, CG7,  &pll2_pfd_352m,    NULL);
-DEF_CLK(ipu1_clk,        CCGR3, CG0,  &mmdc_ch0_axi_clk, NULL);
-DEF_CLK(ipu1_di0_clk,    CCGR3, CG1,  &ipu1_di0_pre_clk, NULL);
-DEF_CLK(ipu1_di1_clk,    CCGR3, CG2,  &ipu1_di1_pre_clk, NULL);
-DEF_CLK(ipu2_clk,        CCGR3, CG3,  &mmdc_ch0_axi_clk, NULL);
-DEF_CLK(ipu2_di0_clk,    CCGR3, CG4,  &ipu2_di0_pre_clk, NULL);
-DEF_CLK(ipu2_di1_clk,    CCGR3, CG5,  &ipu2_di1_pre_clk, NULL);
-DEF_CLK(ldb_di0_clk,     CCGR3, CG6,  &pll3_pfd_540m,    NULL);
-DEF_CLK(ldb_di1_clk,     CCGR3, CG7,  &pll3_pfd_540m,    NULL);
-DEF_CLK(hsi_tx_clk,      CCGR3, CG8,  &pll2_pfd_400m,    NULL);
-DEF_CLK(mlb_clk,         CCGR3, CG9,  &pll6_mlb,         NULL);
-DEF_CLK(mmdc_ch0_ipg_clk, CCGR3, CG12, &ipg_clk,         NULL);
-DEF_CLK(mmdc_ch0_axi_clk, CCGR3, CG10, &periph_clk,      &mmdc_ch0_ipg_clk);
-DEF_CLK(mmdc_ch1_ipg_clk, CCGR3, CG13, &ipg_clk,         NULL);
-DEF_CLK(mmdc_ch1_axi_clk, CCGR3, CG11, &periph2_clk,     &mmdc_ch1_ipg_clk);
-DEF_CLK(openvg_axi_clk,   CCGR3, CG13, &axi_clk,         NULL);
-DEF_CLK(pwm1_clk,        CCGR4, CG8,  &ipg_perclk,       NULL);
-DEF_CLK(pwm2_clk,        CCGR4, CG9,  &ipg_perclk,       NULL);
-DEF_CLK(pwm3_clk,        CCGR4, CG10, &ipg_perclk,       NULL);
-DEF_CLK(pwm4_clk,        CCGR4, CG11, &ipg_perclk,       NULL);
-DEF_CLK(gpmi_bch_apb_clk, CCGR4, CG12, &usdhc3_clk,      NULL);
-DEF_CLK(gpmi_bch_clk,    CCGR4, CG13, &usdhc4_clk,       &gpmi_bch_apb_clk);
-DEF_CLK(gpmi_apb_clk,    CCGR4, CG15, &usdhc3_clk,       &gpmi_bch_clk);
-DEF_CLK(gpmi_io_clk,     CCGR4, CG14, &enfc_clk,         &gpmi_apb_clk);
-DEF_CLK(sdma_clk,        CCGR5, CG3,  &ahb_clk,          NULL);
-DEF_CLK(spba_clk,        CCGR5, CG6,  &ipg_clk,          NULL);
-DEF_CLK(spdif_clk,       CCGR5, CG7,  &pll3_usb_otg,     &spba_clk);
-DEF_CLK(ssi1_clk,        CCGR5, CG9,  &pll3_pfd_508m,    NULL);
-DEF_CLK(ssi2_clk,        CCGR5, CG10, &pll3_pfd_508m,    NULL);
-DEF_CLK(ssi3_clk,        CCGR5, CG11, &pll3_pfd_508m,    NULL);
-DEF_CLK(uart_serial_clk,  CCGR5, CG13, &pll3_usb_otg,    NULL);
-DEF_CLK(uart_clk,        CCGR5, CG12, &pll3_80m,         &uart_serial_clk);
-DEF_CLK(usboh3_clk,      CCGR6, CG0,  &ipg_clk,          NULL);
-DEF_CLK(usdhc1_clk,      CCGR6, CG1,  &pll2_pfd_400m,    NULL);
-DEF_CLK(usdhc2_clk,      CCGR6, CG2,  &pll2_pfd_400m,    NULL);
-DEF_CLK(usdhc3_clk,      CCGR6, CG3,  &pll2_pfd_400m,    NULL);
-DEF_CLK(usdhc4_clk,      CCGR6, CG4,  &pll2_pfd_400m,    NULL);
-DEF_CLK(emi_slow_clk,    CCGR6, CG5,  &axi_clk,          NULL);
-DEF_CLK(vdo_axi_clk,     CCGR6, CG6,  &axi_clk,          NULL);
-DEF_CLK(vpu_clk,         CCGR6, CG7,  &axi_clk,          NULL);
-DEF_CLK_1B(cko1_clk,     CCOSR, BP_CCOSR_CKO1_EN, &pll2_bus, NULL);
-
-static int pcie_clk_enable(struct clk *clk)
-{
-       u32 val;
-
-       val = readl_relaxed(PLL8_ENET);
-       val |= BM_PLL_ENET_EN_PCIE;
-       writel_relaxed(val, PLL8_ENET);
-
-       return _clk_enable(clk);
-}
-
-static void pcie_clk_disable(struct clk *clk)
-{
-       u32 val;
-
-       _clk_disable(clk);
-
-       val = readl_relaxed(PLL8_ENET);
-       val &= BM_PLL_ENET_EN_PCIE;
-       writel_relaxed(val, PLL8_ENET);
-}
-
-static struct clk pcie_clk = {
-       .enable_reg = CCGR4,
-       .enable_shift = CG0,
-       .enable = pcie_clk_enable,
-       .disable = pcie_clk_disable,
-       .set_parent = _clk_set_parent,
-       .parent = &axi_clk,
-       .secondary = &pll8_enet,
-};
-
-static int sata_clk_enable(struct clk *clk)
-{
-       u32 val;
-
-       val = readl_relaxed(PLL8_ENET);
-       val |= BM_PLL_ENET_EN_SATA;
-       writel_relaxed(val, PLL8_ENET);
-
-       return _clk_enable(clk);
-}
-
-static void sata_clk_disable(struct clk *clk)
-{
-       u32 val;
-
-       _clk_disable(clk);
-
-       val = readl_relaxed(PLL8_ENET);
-       val &= BM_PLL_ENET_EN_SATA;
-       writel_relaxed(val, PLL8_ENET);
-}
-
-static struct clk sata_clk = {
-       .enable_reg = CCGR5,
-       .enable_shift = CG2,
-       .enable = sata_clk_enable,
-       .disable = sata_clk_disable,
-       .parent = &ipg_clk,
-       .secondary = &pll8_enet,
-};
-
-#define _REGISTER_CLOCK(d, n, c) \
-       { \
-               .dev_id = d, \
-               .con_id = n, \
-               .clk = &c, \
-       }
-
-static struct clk_lookup lookups[] = {
-       _REGISTER_CLOCK("2020000.uart", NULL, uart_clk),
-       _REGISTER_CLOCK("21e8000.uart", NULL, uart_clk),
-       _REGISTER_CLOCK("21ec000.uart", NULL, uart_clk),
-       _REGISTER_CLOCK("21f0000.uart", NULL, uart_clk),
-       _REGISTER_CLOCK("21f4000.uart", NULL, uart_clk),
-       _REGISTER_CLOCK("2188000.enet", NULL, enet_clk),
-       _REGISTER_CLOCK("2190000.usdhc", NULL, usdhc1_clk),
-       _REGISTER_CLOCK("2194000.usdhc", NULL, usdhc2_clk),
-       _REGISTER_CLOCK("2198000.usdhc", NULL, usdhc3_clk),
-       _REGISTER_CLOCK("219c000.usdhc", NULL, usdhc4_clk),
-       _REGISTER_CLOCK("21a0000.i2c", NULL, i2c1_clk),
-       _REGISTER_CLOCK("21a4000.i2c", NULL, i2c2_clk),
-       _REGISTER_CLOCK("21a8000.i2c", NULL, i2c3_clk),
-       _REGISTER_CLOCK("2008000.ecspi", NULL, ecspi1_clk),
-       _REGISTER_CLOCK("200c000.ecspi", NULL, ecspi2_clk),
-       _REGISTER_CLOCK("2010000.ecspi", NULL, ecspi3_clk),
-       _REGISTER_CLOCK("2014000.ecspi", NULL, ecspi4_clk),
-       _REGISTER_CLOCK("2018000.ecspi", NULL, ecspi5_clk),
-       _REGISTER_CLOCK("20ec000.sdma", NULL, sdma_clk),
-       _REGISTER_CLOCK("20bc000.wdog", NULL, dummy_clk),
-       _REGISTER_CLOCK("20c0000.wdog", NULL, dummy_clk),
-       _REGISTER_CLOCK("smp_twd", NULL, twd_clk),
-       _REGISTER_CLOCK(NULL, "ckih", ckih_clk),
-       _REGISTER_CLOCK(NULL, "ckil_clk", ckil_clk),
-       _REGISTER_CLOCK(NULL, "aips_tz1_clk", aips_tz1_clk),
-       _REGISTER_CLOCK(NULL, "aips_tz2_clk", aips_tz2_clk),
-       _REGISTER_CLOCK(NULL, "asrc_clk", asrc_clk),
-       _REGISTER_CLOCK(NULL, "can2_clk", can2_clk),
-       _REGISTER_CLOCK(NULL, "hdmi_isfr_clk", hdmi_isfr_clk),
-       _REGISTER_CLOCK(NULL, "iim_clk", iim_clk),
-       _REGISTER_CLOCK(NULL, "mlb_clk", mlb_clk),
-       _REGISTER_CLOCK(NULL, "openvg_axi_clk", openvg_axi_clk),
-       _REGISTER_CLOCK(NULL, "pwm1_clk", pwm1_clk),
-       _REGISTER_CLOCK(NULL, "pwm2_clk", pwm2_clk),
-       _REGISTER_CLOCK(NULL, "pwm3_clk", pwm3_clk),
-       _REGISTER_CLOCK(NULL, "pwm4_clk", pwm4_clk),
-       _REGISTER_CLOCK(NULL, "gpmi_io_clk", gpmi_io_clk),
-       _REGISTER_CLOCK(NULL, "usboh3_clk", usboh3_clk),
-       _REGISTER_CLOCK(NULL, "sata_clk", sata_clk),
-       _REGISTER_CLOCK(NULL, "cko1_clk", cko1_clk),
-};
-
-int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode)
-{
-       u32 val = readl_relaxed(CLPCR);
-
-       val &= ~BM_CLPCR_LPM;
-       switch (mode) {
-       case WAIT_CLOCKED:
-               break;
-       case WAIT_UNCLOCKED:
-               val |= 0x1 << BP_CLPCR_LPM;
-               break;
-       case STOP_POWER_ON:
-               val |= 0x2 << BP_CLPCR_LPM;
-               break;
-       case WAIT_UNCLOCKED_POWER_OFF:
-               val |= 0x1 << BP_CLPCR_LPM;
-               val &= ~BM_CLPCR_VSTBY;
-               val &= ~BM_CLPCR_SBYOS;
-               break;
-       case STOP_POWER_OFF:
-               val |= 0x2 << BP_CLPCR_LPM;
-               val |= 0x3 << BP_CLPCR_STBY_COUNT;
-               val |= BM_CLPCR_VSTBY;
-               val |= BM_CLPCR_SBYOS;
-               break;
-       default:
-               return -EINVAL;
-       }
-       writel_relaxed(val, CLPCR);
-
-       return 0;
-}
-
-static struct map_desc imx6q_clock_desc[] = {
-       imx_map_entry(MX6Q, CCM, MT_DEVICE),
-       imx_map_entry(MX6Q, ANATOP, MT_DEVICE),
-};
-
-void __init imx6q_clock_map_io(void)
-{
-       iotable_init(imx6q_clock_desc, ARRAY_SIZE(imx6q_clock_desc));
-}
-
-int __init mx6q_clocks_init(void)
-{
-       struct device_node *np;
-       void __iomem *base;
-       int i, irq;
-
-       /* retrieve the freqency of fixed clocks from device tree */
-       for_each_compatible_node(np, NULL, "fixed-clock") {
-               u32 rate;
-               if (of_property_read_u32(np, "clock-frequency", &rate))
-                       continue;
-
-               if (of_device_is_compatible(np, "fsl,imx-ckil"))
-                       external_low_reference = rate;
-               else if (of_device_is_compatible(np, "fsl,imx-ckih1"))
-                       external_high_reference = rate;
-               else if (of_device_is_compatible(np, "fsl,imx-osc"))
-                       oscillator_reference = rate;
-       }
-
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
-
-       /* only keep necessary clocks on */
-       writel_relaxed(0x3 << CG0  | 0x3 << CG1  | 0x3 << CG2,  CCGR0);
-       writel_relaxed(0x3 << CG8  | 0x3 << CG9  | 0x3 << CG10, CCGR2);
-       writel_relaxed(0x3 << CG10 | 0x3 << CG12,               CCGR3);
-       writel_relaxed(0x3 << CG4  | 0x3 << CG6  | 0x3 << CG7,  CCGR4);
-       writel_relaxed(0x3 << CG0,                              CCGR5);
-       writel_relaxed(0,                                       CCGR6);
-       writel_relaxed(0,                                       CCGR7);
-
-       clk_enable(&uart_clk);
-       clk_enable(&mmdc_ch0_axi_clk);
-
-       clk_set_rate(&pll4_audio, FREQ_650M);
-       clk_set_rate(&pll5_video, FREQ_650M);
-       clk_set_parent(&ipu1_di0_clk, &ipu1_di0_pre_clk);
-       clk_set_parent(&ipu1_di0_pre_clk, &pll5_video);
-       clk_set_parent(&gpu3d_shader_clk, &pll2_pfd_594m);
-       clk_set_rate(&gpu3d_shader_clk, FREQ_594M);
-       clk_set_parent(&gpu3d_core_clk, &mmdc_ch0_axi_clk);
-       clk_set_rate(&gpu3d_core_clk, FREQ_528M);
-       clk_set_parent(&asrc_serial_clk, &pll3_usb_otg);
-       clk_set_rate(&asrc_serial_clk, 1500000);
-       clk_set_rate(&enfc_clk, 11000000);
-
-       /*
-        * Before pinctrl API is available, we have to rely on the pad
-        * configuration set up by bootloader.  For usdhc example here,
-        * u-boot sets up the pads for 49.5 MHz case, and we have to lower
-        * the usdhc clock from 198 to 49.5 MHz to match the pad configuration.
-        *
-        * FIXME: This is should be removed after pinctrl API is available.
-        * At that time, usdhc driver can call pinctrl API to change pad
-        * configuration dynamically per different usdhc clock settings.
-        */
-       clk_set_rate(&usdhc1_clk, 49500000);
-       clk_set_rate(&usdhc2_clk, 49500000);
-       clk_set_rate(&usdhc3_clk, 49500000);
-       clk_set_rate(&usdhc4_clk, 49500000);
-
-       clk_set_parent(&cko1_clk, &ahb_clk);
-
-       np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpt");
-       base = of_iomap(np, 0);
-       WARN_ON(!base);
-       irq = irq_of_parse_and_map(np, 0);
-       mxc_timer_init(&gpt_clk, base, irq);
-
-       return 0;
-}
diff --git a/arch/arm/mach-imx/clock-mx51-mx53.c b/arch/arm/mach-imx/clock-mx51-mx53.c
deleted file mode 100644 (file)
index 0847050..0000000
+++ /dev/null
@@ -1,1675 +0,0 @@
-/*
- * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
- * Copyright (C) 2009-2010 Amit Kucheria <amit.kucheria@canonical.com>
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-#include <linux/mm.h>
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/clkdev.h>
-#include <linux/of.h>
-
-#include <asm/div64.h>
-
-#include <mach/hardware.h>
-#include <mach/common.h>
-#include <mach/clock.h>
-
-#include "crm-regs-imx5.h"
-
-/* External clock values passed-in by the board code */
-static unsigned long external_high_reference, external_low_reference;
-static unsigned long oscillator_reference, ckih2_reference;
-
-static struct clk osc_clk;
-static struct clk pll1_main_clk;
-static struct clk pll1_sw_clk;
-static struct clk pll2_sw_clk;
-static struct clk pll3_sw_clk;
-static struct clk mx53_pll4_sw_clk;
-static struct clk lp_apm_clk;
-static struct clk periph_apm_clk;
-static struct clk ahb_clk;
-static struct clk ipg_clk;
-static struct clk usboh3_clk;
-static struct clk emi_fast_clk;
-static struct clk ipu_clk;
-static struct clk mipi_hsc1_clk;
-static struct clk esdhc1_clk;
-static struct clk esdhc2_clk;
-static struct clk esdhc3_mx53_clk;
-
-#define MAX_DPLL_WAIT_TRIES    1000 /* 1000 * udelay(1) = 1ms */
-
-/* calculate best pre and post dividers to get the required divider */
-static void __calc_pre_post_dividers(u32 div, u32 *pre, u32 *post,
-       u32 max_pre, u32 max_post)
-{
-       if (div >= max_pre * max_post) {
-               *pre = max_pre;
-               *post = max_post;
-       } else if (div >= max_pre) {
-               u32 min_pre, temp_pre, old_err, err;
-               min_pre = DIV_ROUND_UP(div, max_post);
-               old_err = max_pre;
-               for (temp_pre = max_pre; temp_pre >= min_pre; temp_pre--) {
-                       err = div % temp_pre;
-                       if (err == 0) {
-                               *pre = temp_pre;
-                               break;
-                       }
-                       err = temp_pre - err;
-                       if (err < old_err) {
-                               old_err = err;
-                               *pre = temp_pre;
-                       }
-               }
-               *post = DIV_ROUND_UP(div, *pre);
-       } else {
-               *pre = div;
-               *post = 1;
-       }
-}
-
-static void _clk_ccgr_setclk(struct clk *clk, unsigned mode)
-{
-       u32 reg = __raw_readl(clk->enable_reg);
-
-       reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift);
-       reg |= mode << clk->enable_shift;
-
-       __raw_writel(reg, clk->enable_reg);
-}
-
-static int _clk_ccgr_enable(struct clk *clk)
-{
-       _clk_ccgr_setclk(clk, MXC_CCM_CCGRx_MOD_ON);
-       return 0;
-}
-
-static void _clk_ccgr_disable(struct clk *clk)
-{
-       _clk_ccgr_setclk(clk, MXC_CCM_CCGRx_MOD_OFF);
-}
-
-static int _clk_ccgr_enable_inrun(struct clk *clk)
-{
-       _clk_ccgr_setclk(clk, MXC_CCM_CCGRx_MOD_IDLE);
-       return 0;
-}
-
-static void _clk_ccgr_disable_inwait(struct clk *clk)
-{
-       _clk_ccgr_setclk(clk, MXC_CCM_CCGRx_MOD_IDLE);
-}
-
-/*
- * For the 4-to-1 muxed input clock
- */
-static inline u32 _get_mux(struct clk *parent, struct clk *m0,
-                          struct clk *m1, struct clk *m2, struct clk *m3)
-{
-       if (parent == m0)
-               return 0;
-       else if (parent == m1)
-               return 1;
-       else if (parent == m2)
-               return 2;
-       else if (parent == m3)
-               return 3;
-       else
-               BUG();
-
-       return -EINVAL;
-}
-
-static inline void __iomem *_mx51_get_pll_base(struct clk *pll)
-{
-       if (pll == &pll1_main_clk)
-               return MX51_DPLL1_BASE;
-       else if (pll == &pll2_sw_clk)
-               return MX51_DPLL2_BASE;
-       else if (pll == &pll3_sw_clk)
-               return MX51_DPLL3_BASE;
-       else
-               BUG();
-
-       return NULL;
-}
-
-static inline void __iomem *_mx53_get_pll_base(struct clk *pll)
-{
-       if (pll == &pll1_main_clk)
-               return MX53_DPLL1_BASE;
-       else if (pll == &pll2_sw_clk)
-               return MX53_DPLL2_BASE;
-       else if (pll == &pll3_sw_clk)
-               return MX53_DPLL3_BASE;
-       else if (pll == &mx53_pll4_sw_clk)
-               return MX53_DPLL4_BASE;
-       else
-               BUG();
-
-       return NULL;
-}
-
-static inline void __iomem *_get_pll_base(struct clk *pll)
-{
-       if (cpu_is_mx51())
-               return _mx51_get_pll_base(pll);
-       else
-               return _mx53_get_pll_base(pll);
-}
-
-static unsigned long clk_pll_get_rate(struct clk *clk)
-{
-       long mfi, mfn, mfd, pdf, ref_clk, mfn_abs;
-       unsigned long dp_op, dp_mfd, dp_mfn, dp_ctl, pll_hfsm, dbl;
-       void __iomem *pllbase;
-       s64 temp;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       pllbase = _get_pll_base(clk);
-
-       dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
-       pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
-       dbl = dp_ctl & MXC_PLL_DP_CTL_DPDCK0_2_EN;
-
-       if (pll_hfsm == 0) {
-               dp_op = __raw_readl(pllbase + MXC_PLL_DP_OP);
-               dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_MFD);
-               dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_MFN);
-       } else {
-               dp_op = __raw_readl(pllbase + MXC_PLL_DP_HFS_OP);
-               dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFD);
-               dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_HFS_MFN);
-       }
-       pdf = dp_op & MXC_PLL_DP_OP_PDF_MASK;
-       mfi = (dp_op & MXC_PLL_DP_OP_MFI_MASK) >> MXC_PLL_DP_OP_MFI_OFFSET;
-       mfi = (mfi <= 5) ? 5 : mfi;
-       mfd = dp_mfd & MXC_PLL_DP_MFD_MASK;
-       mfn = mfn_abs = dp_mfn & MXC_PLL_DP_MFN_MASK;
-       /* Sign extend to 32-bits */
-       if (mfn >= 0x04000000) {
-               mfn |= 0xFC000000;
-               mfn_abs = -mfn;
-       }
-
-       ref_clk = 2 * parent_rate;
-       if (dbl != 0)
-               ref_clk *= 2;
-
-       ref_clk /= (pdf + 1);
-       temp = (u64) ref_clk * mfn_abs;
-       do_div(temp, mfd + 1);
-       if (mfn < 0)
-               temp = -temp;
-       temp = (ref_clk * mfi) + temp;
-
-       return temp;
-}
-
-static int _clk_pll_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 reg;
-       void __iomem *pllbase;
-
-       long mfi, pdf, mfn, mfd = 999999;
-       s64 temp64;
-       unsigned long quad_parent_rate;
-       unsigned long pll_hfsm, dp_ctl;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       pllbase = _get_pll_base(clk);
-
-       quad_parent_rate = 4 * parent_rate;
-       pdf = mfi = -1;
-       while (++pdf < 16 && mfi < 5)
-               mfi = rate * (pdf+1) / quad_parent_rate;
-       if (mfi > 15)
-               return -EINVAL;
-       pdf--;
-
-       temp64 = rate * (pdf+1) - quad_parent_rate * mfi;
-       do_div(temp64, quad_parent_rate/1000000);
-       mfn = (long)temp64;
-
-       dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
-       /* use dpdck0_2 */
-       __raw_writel(dp_ctl | 0x1000L, pllbase + MXC_PLL_DP_CTL);
-       pll_hfsm = dp_ctl & MXC_PLL_DP_CTL_HFSM;
-       if (pll_hfsm == 0) {
-               reg = mfi << 4 | pdf;
-               __raw_writel(reg, pllbase + MXC_PLL_DP_OP);
-               __raw_writel(mfd, pllbase + MXC_PLL_DP_MFD);
-               __raw_writel(mfn, pllbase + MXC_PLL_DP_MFN);
-       } else {
-               reg = mfi << 4 | pdf;
-               __raw_writel(reg, pllbase + MXC_PLL_DP_HFS_OP);
-               __raw_writel(mfd, pllbase + MXC_PLL_DP_HFS_MFD);
-               __raw_writel(mfn, pllbase + MXC_PLL_DP_HFS_MFN);
-       }
-
-       return 0;
-}
-
-static int _clk_pll_enable(struct clk *clk)
-{
-       u32 reg;
-       void __iomem *pllbase;
-       int i = 0;
-
-       pllbase = _get_pll_base(clk);
-       reg = __raw_readl(pllbase + MXC_PLL_DP_CTL);
-       if (reg & MXC_PLL_DP_CTL_UPEN)
-               return 0;
-
-       reg |= MXC_PLL_DP_CTL_UPEN;
-       __raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
-
-       /* Wait for lock */
-       do {
-               reg = __raw_readl(pllbase + MXC_PLL_DP_CTL);
-               if (reg & MXC_PLL_DP_CTL_LRF)
-                       break;
-
-               udelay(1);
-       } while (++i < MAX_DPLL_WAIT_TRIES);
-
-       if (i == MAX_DPLL_WAIT_TRIES) {
-               pr_err("MX5: pll locking failed\n");
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-static void _clk_pll_disable(struct clk *clk)
-{
-       u32 reg;
-       void __iomem *pllbase;
-
-       pllbase = _get_pll_base(clk);
-       reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) & ~MXC_PLL_DP_CTL_UPEN;
-       __raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
-}
-
-static int _clk_pll1_sw_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 reg, step;
-
-       reg = __raw_readl(MXC_CCM_CCSR);
-
-       /* When switching from pll_main_clk to a bypass clock, first select a
-        * multiplexed clock in 'step_sel', then shift the glitchless mux
-        * 'pll1_sw_clk_sel'.
-        *
-        * When switching back, do it in reverse order
-        */
-       if (parent == &pll1_main_clk) {
-               /* Switch to pll1_main_clk */
-               reg &= ~MXC_CCM_CCSR_PLL1_SW_CLK_SEL;
-               __raw_writel(reg, MXC_CCM_CCSR);
-               /* step_clk mux switched to lp_apm, to save power. */
-               reg = __raw_readl(MXC_CCM_CCSR);
-               reg &= ~MXC_CCM_CCSR_STEP_SEL_MASK;
-               reg |= (MXC_CCM_CCSR_STEP_SEL_LP_APM <<
-                               MXC_CCM_CCSR_STEP_SEL_OFFSET);
-       } else {
-               if (parent == &lp_apm_clk) {
-                       step = MXC_CCM_CCSR_STEP_SEL_LP_APM;
-               } else  if (parent == &pll2_sw_clk) {
-                       step = MXC_CCM_CCSR_STEP_SEL_PLL2_DIVIDED;
-               } else  if (parent == &pll3_sw_clk) {
-                       step = MXC_CCM_CCSR_STEP_SEL_PLL3_DIVIDED;
-               } else
-                       return -EINVAL;
-
-               reg &= ~MXC_CCM_CCSR_STEP_SEL_MASK;
-               reg |= (step << MXC_CCM_CCSR_STEP_SEL_OFFSET);
-
-               __raw_writel(reg, MXC_CCM_CCSR);
-               /* Switch to step_clk */
-               reg = __raw_readl(MXC_CCM_CCSR);
-               reg |= MXC_CCM_CCSR_PLL1_SW_CLK_SEL;
-       }
-       __raw_writel(reg, MXC_CCM_CCSR);
-       return 0;
-}
-
-static unsigned long clk_pll1_sw_get_rate(struct clk *clk)
-{
-       u32 reg, div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       reg = __raw_readl(MXC_CCM_CCSR);
-
-       if (clk->parent == &pll2_sw_clk) {
-               div = ((reg & MXC_CCM_CCSR_PLL2_PODF_MASK) >>
-                      MXC_CCM_CCSR_PLL2_PODF_OFFSET) + 1;
-       } else if (clk->parent == &pll3_sw_clk) {
-               div = ((reg & MXC_CCM_CCSR_PLL3_PODF_MASK) >>
-                      MXC_CCM_CCSR_PLL3_PODF_OFFSET) + 1;
-       } else
-               div = 1;
-       return parent_rate / div;
-}
-
-static int _clk_pll2_sw_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 reg;
-
-       reg = __raw_readl(MXC_CCM_CCSR);
-
-       if (parent == &pll2_sw_clk)
-               reg &= ~MXC_CCM_CCSR_PLL2_SW_CLK_SEL;
-       else
-               reg |= MXC_CCM_CCSR_PLL2_SW_CLK_SEL;
-
-       __raw_writel(reg, MXC_CCM_CCSR);
-       return 0;
-}
-
-static int _clk_lp_apm_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 reg;
-
-       if (parent == &osc_clk)
-               reg = __raw_readl(MXC_CCM_CCSR) & ~MXC_CCM_CCSR_LP_APM_SEL;
-       else
-               return -EINVAL;
-
-       __raw_writel(reg, MXC_CCM_CCSR);
-
-       return 0;
-}
-
-static unsigned long clk_cpu_get_rate(struct clk *clk)
-{
-       u32 cacrr, div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-       cacrr = __raw_readl(MXC_CCM_CACRR);
-       div = (cacrr & MXC_CCM_CACRR_ARM_PODF_MASK) + 1;
-
-       return parent_rate / div;
-}
-
-static int clk_cpu_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 reg, cpu_podf;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-       cpu_podf = parent_rate / rate - 1;
-       /* use post divider to change freq */
-       reg = __raw_readl(MXC_CCM_CACRR);
-       reg &= ~MXC_CCM_CACRR_ARM_PODF_MASK;
-       reg |= cpu_podf << MXC_CCM_CACRR_ARM_PODF_OFFSET;
-       __raw_writel(reg, MXC_CCM_CACRR);
-
-       return 0;
-}
-
-static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 reg, mux;
-       int i = 0;
-
-       mux = _get_mux(parent, &pll1_sw_clk, &pll3_sw_clk, &lp_apm_clk, NULL);
-
-       reg = __raw_readl(MXC_CCM_CBCMR) & ~MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK;
-       reg |= mux << MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET;
-       __raw_writel(reg, MXC_CCM_CBCMR);
-
-       /* Wait for lock */
-       do {
-               reg = __raw_readl(MXC_CCM_CDHIPR);
-               if (!(reg &  MXC_CCM_CDHIPR_PERIPH_CLK_SEL_BUSY))
-                       break;
-
-               udelay(1);
-       } while (++i < MAX_DPLL_WAIT_TRIES);
-
-       if (i == MAX_DPLL_WAIT_TRIES) {
-               pr_err("MX5: Set parent for periph_apm clock failed\n");
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-static int _clk_main_bus_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 reg;
-
-       reg = __raw_readl(MXC_CCM_CBCDR);
-
-       if (parent == &pll2_sw_clk)
-               reg &= ~MXC_CCM_CBCDR_PERIPH_CLK_SEL;
-       else if (parent == &periph_apm_clk)
-               reg |= MXC_CCM_CBCDR_PERIPH_CLK_SEL;
-       else
-               return -EINVAL;
-
-       __raw_writel(reg, MXC_CCM_CBCDR);
-
-       return 0;
-}
-
-static struct clk main_bus_clk = {
-       .parent = &pll2_sw_clk,
-       .set_parent = _clk_main_bus_set_parent,
-};
-
-static unsigned long clk_ahb_get_rate(struct clk *clk)
-{
-       u32 reg, div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       reg = __raw_readl(MXC_CCM_CBCDR);
-       div = ((reg & MXC_CCM_CBCDR_AHB_PODF_MASK) >>
-              MXC_CCM_CBCDR_AHB_PODF_OFFSET) + 1;
-       return parent_rate / div;
-}
-
-
-static int _clk_ahb_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 reg, div;
-       unsigned long parent_rate;
-       int i = 0;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-       if (div > 8 || div < 1 || ((parent_rate / div) != rate))
-               return -EINVAL;
-
-       reg = __raw_readl(MXC_CCM_CBCDR);
-       reg &= ~MXC_CCM_CBCDR_AHB_PODF_MASK;
-       reg |= (div - 1) << MXC_CCM_CBCDR_AHB_PODF_OFFSET;
-       __raw_writel(reg, MXC_CCM_CBCDR);
-
-       /* Wait for lock */
-       do {
-               reg = __raw_readl(MXC_CCM_CDHIPR);
-               if (!(reg & MXC_CCM_CDHIPR_AHB_PODF_BUSY))
-                       break;
-
-               udelay(1);
-       } while (++i < MAX_DPLL_WAIT_TRIES);
-
-       if (i == MAX_DPLL_WAIT_TRIES) {
-               pr_err("MX5: clk_ahb_set_rate failed\n");
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-static unsigned long _clk_ahb_round_rate(struct clk *clk,
-                                               unsigned long rate)
-{
-       u32 div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-       if (div > 8)
-               div = 8;
-       else if (div == 0)
-               div++;
-       return parent_rate / div;
-}
-
-
-static int _clk_max_enable(struct clk *clk)
-{
-       u32 reg;
-
-       _clk_ccgr_enable(clk);
-
-       /* Handshake with MAX when LPM is entered. */
-       reg = __raw_readl(MXC_CCM_CLPCR);
-       if (cpu_is_mx51())
-               reg &= ~MX51_CCM_CLPCR_BYPASS_MAX_LPM_HS;
-       else if (cpu_is_mx53())
-               reg &= ~MX53_CCM_CLPCR_BYPASS_MAX_LPM_HS;
-       __raw_writel(reg, MXC_CCM_CLPCR);
-
-       return 0;
-}
-
-static void _clk_max_disable(struct clk *clk)
-{
-       u32 reg;
-
-       _clk_ccgr_disable_inwait(clk);
-
-       /* No Handshake with MAX when LPM is entered as its disabled. */
-       reg = __raw_readl(MXC_CCM_CLPCR);
-       if (cpu_is_mx51())
-               reg |= MX51_CCM_CLPCR_BYPASS_MAX_LPM_HS;
-       else if (cpu_is_mx53())
-               reg &= ~MX53_CCM_CLPCR_BYPASS_MAX_LPM_HS;
-       __raw_writel(reg, MXC_CCM_CLPCR);
-}
-
-static unsigned long clk_ipg_get_rate(struct clk *clk)
-{
-       u32 reg, div;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       reg = __raw_readl(MXC_CCM_CBCDR);
-       div = ((reg & MXC_CCM_CBCDR_IPG_PODF_MASK) >>
-              MXC_CCM_CBCDR_IPG_PODF_OFFSET) + 1;
-
-       return parent_rate / div;
-}
-
-static unsigned long clk_ipg_per_get_rate(struct clk *clk)
-{
-       u32 reg, prediv1, prediv2, podf;
-       unsigned long parent_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       if (clk->parent == &main_bus_clk || clk->parent == &lp_apm_clk) {
-               /* the main_bus_clk is the one before the DVFS engine */
-               reg = __raw_readl(MXC_CCM_CBCDR);
-               prediv1 = ((reg & MXC_CCM_CBCDR_PERCLK_PRED1_MASK) >>
-                          MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET) + 1;
-               prediv2 = ((reg & MXC_CCM_CBCDR_PERCLK_PRED2_MASK) >>
-                          MXC_CCM_CBCDR_PERCLK_PRED2_OFFSET) + 1;
-               podf = ((reg & MXC_CCM_CBCDR_PERCLK_PODF_MASK) >>
-                       MXC_CCM_CBCDR_PERCLK_PODF_OFFSET) + 1;
-               return parent_rate / (prediv1 * prediv2 * podf);
-       } else if (clk->parent == &ipg_clk)
-               return parent_rate;
-       else
-               BUG();
-}
-
-static int _clk_ipg_per_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 reg;
-
-       reg = __raw_readl(MXC_CCM_CBCMR);
-
-       reg &= ~MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL;
-       reg &= ~MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL;
-
-       if (parent == &ipg_clk)
-               reg |= MXC_CCM_CBCMR_PERCLK_IPG_CLK_SEL;
-       else if (parent == &lp_apm_clk)
-               reg |= MXC_CCM_CBCMR_PERCLK_LP_APM_CLK_SEL;
-       else if (parent != &main_bus_clk)
-               return -EINVAL;
-
-       __raw_writel(reg, MXC_CCM_CBCMR);
-
-       return 0;
-}
-
-#define clk_nfc_set_parent     NULL
-
-static unsigned long clk_nfc_get_rate(struct clk *clk)
-{
-       unsigned long rate;
-       u32 reg, div;
-
-       reg = __raw_readl(MXC_CCM_CBCDR);
-       div = ((reg & MXC_CCM_CBCDR_NFC_PODF_MASK) >>
-              MXC_CCM_CBCDR_NFC_PODF_OFFSET) + 1;
-       rate = clk_get_rate(clk->parent) / div;
-       WARN_ON(rate == 0);
-       return rate;
-}
-
-static unsigned long clk_nfc_round_rate(struct clk *clk,
-                                               unsigned long rate)
-{
-       u32 div;
-       unsigned long parent_rate = clk_get_rate(clk->parent);
-
-       if (!rate)
-               return -EINVAL;
-
-       div = parent_rate / rate;
-
-       if (parent_rate % rate)
-               div++;
-
-       if (div > 8)
-               return -EINVAL;
-
-       return parent_rate / div;
-
-}
-
-static int clk_nfc_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 reg, div;
-
-       div = clk_get_rate(clk->parent) / rate;
-       if (div == 0)
-               div++;
-       if (((clk_get_rate(clk->parent) / div) != rate) || (div > 8))
-               return -EINVAL;
-
-       reg = __raw_readl(MXC_CCM_CBCDR);
-       reg &= ~MXC_CCM_CBCDR_NFC_PODF_MASK;
-       reg |= (div - 1) << MXC_CCM_CBCDR_NFC_PODF_OFFSET;
-       __raw_writel(reg, MXC_CCM_CBCDR);
-
-       while (__raw_readl(MXC_CCM_CDHIPR) &
-                       MXC_CCM_CDHIPR_NFC_IPG_INT_MEM_PODF_BUSY){
-       }
-
-       return 0;
-}
-
-static unsigned long get_high_reference_clock_rate(struct clk *clk)
-{
-       return external_high_reference;
-}
-
-static unsigned long get_low_reference_clock_rate(struct clk *clk)
-{
-       return external_low_reference;
-}
-
-static unsigned long get_oscillator_reference_clock_rate(struct clk *clk)
-{
-       return oscillator_reference;
-}
-
-static unsigned long get_ckih2_reference_clock_rate(struct clk *clk)
-{
-       return ckih2_reference;
-}
-
-static unsigned long clk_emi_slow_get_rate(struct clk *clk)
-{
-       u32 reg, div;
-
-       reg = __raw_readl(MXC_CCM_CBCDR);
-       div = ((reg & MXC_CCM_CBCDR_EMI_PODF_MASK) >>
-              MXC_CCM_CBCDR_EMI_PODF_OFFSET) + 1;
-
-       return clk_get_rate(clk->parent) / div;
-}
-
-static unsigned long _clk_ddr_hf_get_rate(struct clk *clk)
-{
-       unsigned long rate;
-       u32 reg, div;
-
-       reg = __raw_readl(MXC_CCM_CBCDR);
-       div = ((reg & MXC_CCM_CBCDR_DDR_PODF_MASK) >>
-               MXC_CCM_CBCDR_DDR_PODF_OFFSET) + 1;
-       rate = clk_get_rate(clk->parent) / div;
-
-       return rate;
-}
-
-/* External high frequency clock */
-static struct clk ckih_clk = {
-       .get_rate = get_high_reference_clock_rate,
-};
-
-static struct clk ckih2_clk = {
-       .get_rate = get_ckih2_reference_clock_rate,
-};
-
-static struct clk osc_clk = {
-       .get_rate = get_oscillator_reference_clock_rate,
-};
-
-/* External low frequency (32kHz) clock */
-static struct clk ckil_clk = {
-       .get_rate = get_low_reference_clock_rate,
-};
-
-static struct clk pll1_main_clk = {
-       .parent = &osc_clk,
-       .get_rate = clk_pll_get_rate,
-       .enable = _clk_pll_enable,
-       .disable = _clk_pll_disable,
-};
-
-/* Clock tree block diagram (WIP):
- *     CCM: Clock Controller Module
- *
- * PLL output -> |
- *               | CCM Switcher -> CCM_CLK_ROOT_GEN ->
- * PLL bypass -> |
- *
- */
-
-/* PLL1 SW supplies to ARM core */
-static struct clk pll1_sw_clk = {
-       .parent = &pll1_main_clk,
-       .set_parent = _clk_pll1_sw_set_parent,
-       .get_rate = clk_pll1_sw_get_rate,
-};
-
-/* PLL2 SW supplies to AXI/AHB/IP buses */
-static struct clk pll2_sw_clk = {
-       .parent = &osc_clk,
-       .get_rate = clk_pll_get_rate,
-       .set_rate = _clk_pll_set_rate,
-       .set_parent = _clk_pll2_sw_set_parent,
-       .enable = _clk_pll_enable,
-       .disable = _clk_pll_disable,
-};
-
-/* PLL3 SW supplies to serial clocks like USB, SSI, etc. */
-static struct clk pll3_sw_clk = {
-       .parent = &osc_clk,
-       .set_rate = _clk_pll_set_rate,
-       .get_rate = clk_pll_get_rate,
-       .enable = _clk_pll_enable,
-       .disable = _clk_pll_disable,
-};
-
-/* PLL4 SW supplies to LVDS Display Bridge(LDB) */
-static struct clk mx53_pll4_sw_clk = {
-       .parent = &osc_clk,
-       .set_rate = _clk_pll_set_rate,
-       .enable = _clk_pll_enable,
-       .disable = _clk_pll_disable,
-};
-
-/* Low-power Audio Playback Mode clock */
-static struct clk lp_apm_clk = {
-       .parent = &osc_clk,
-       .set_parent = _clk_lp_apm_set_parent,
-};
-
-static struct clk periph_apm_clk = {
-       .parent = &pll1_sw_clk,
-       .set_parent = _clk_periph_apm_set_parent,
-};
-
-static struct clk cpu_clk = {
-       .parent = &pll1_sw_clk,
-       .get_rate = clk_cpu_get_rate,
-       .set_rate = clk_cpu_set_rate,
-};
-
-static struct clk ahb_clk = {
-       .parent = &main_bus_clk,
-       .get_rate = clk_ahb_get_rate,
-       .set_rate = _clk_ahb_set_rate,
-       .round_rate = _clk_ahb_round_rate,
-};
-
-static struct clk iim_clk = {
-       .parent = &ipg_clk,
-       .enable_reg = MXC_CCM_CCGR0,
-       .enable_shift = MXC_CCM_CCGRx_CG15_OFFSET,
-};
-
-/* Main IP interface clock for access to registers */
-static struct clk ipg_clk = {
-       .parent = &ahb_clk,
-       .get_rate = clk_ipg_get_rate,
-};
-
-static struct clk ipg_perclk = {
-       .parent = &lp_apm_clk,
-       .get_rate = clk_ipg_per_get_rate,
-       .set_parent = _clk_ipg_per_set_parent,
-};
-
-static struct clk ahb_max_clk = {
-       .parent = &ahb_clk,
-       .enable_reg = MXC_CCM_CCGR0,
-       .enable_shift = MXC_CCM_CCGRx_CG14_OFFSET,
-       .enable = _clk_max_enable,
-       .disable = _clk_max_disable,
-};
-
-static struct clk aips_tz1_clk = {
-       .parent = &ahb_clk,
-       .secondary = &ahb_max_clk,
-       .enable_reg = MXC_CCM_CCGR0,
-       .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET,
-       .enable = _clk_ccgr_enable,
-       .disable = _clk_ccgr_disable_inwait,
-};
-
-static struct clk aips_tz2_clk = {
-       .parent = &ahb_clk,
-       .secondary = &ahb_max_clk,
-       .enable_reg = MXC_CCM_CCGR0,
-       .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET,
-       .enable = _clk_ccgr_enable,
-       .disable = _clk_ccgr_disable_inwait,
-};
-
-static struct clk gpc_dvfs_clk = {
-       .enable_reg = MXC_CCM_CCGR5,
-       .enable_shift = MXC_CCM_CCGRx_CG12_OFFSET,
-       .enable = _clk_ccgr_enable,
-       .disable = _clk_ccgr_disable,
-};
-
-static struct clk gpt_32k_clk = {
-       .id = 0,
-       .parent = &ckil_clk,
-};
-
-static struct clk dummy_clk = {
-       .id = 0,
-};
-
-static struct clk emi_slow_clk = {
-       .parent = &pll2_sw_clk,
-       .enable_reg = MXC_CCM_CCGR5,
-       .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET,
-       .enable = _clk_ccgr_enable,
-       .disable = _clk_ccgr_disable_inwait,
-       .get_rate = clk_emi_slow_get_rate,
-};
-
-static int clk_ipu_enable(struct clk *clk)
-{
-       u32 reg;
-
-       _clk_ccgr_enable(clk);
-
-       /* Enable handshake with IPU when certain clock rates are changed */
-       reg = __raw_readl(MXC_CCM_CCDR);
-       reg &= ~MXC_CCM_CCDR_IPU_HS_MASK;
-       __raw_writel(reg, MXC_CCM_CCDR);
-
-       /* Enable handshake with IPU when LPM is entered */
-       reg = __raw_readl(MXC_CCM_CLPCR);
-       reg &= ~MXC_CCM_CLPCR_BYPASS_IPU_LPM_HS;
-       __raw_writel(reg, MXC_CCM_CLPCR);
-
-       return 0;
-}
-
-static void clk_ipu_disable(struct clk *clk)
-{
-       u32 reg;
-
-       _clk_ccgr_disable(clk);
-
-       /* Disable handshake with IPU whe dividers are changed */
-       reg = __raw_readl(MXC_CCM_CCDR);
-       reg |= MXC_CCM_CCDR_IPU_HS_MASK;
-       __raw_writel(reg, MXC_CCM_CCDR);
-
-       /* Disable handshake with IPU when LPM is entered */
-       reg = __raw_readl(MXC_CCM_CLPCR);
-       reg |= MXC_CCM_CLPCR_BYPASS_IPU_LPM_HS;
-       __raw_writel(reg, MXC_CCM_CLPCR);
-}
-
-static struct clk ahbmux1_clk = {
-       .parent = &ahb_clk,
-       .secondary = &ahb_max_clk,
-       .enable_reg = MXC_CCM_CCGR0,
-       .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET,
-       .enable = _clk_ccgr_enable,
-       .disable = _clk_ccgr_disable_inwait,
-};
-
-static struct clk ipu_sec_clk = {
-       .parent = &emi_fast_clk,
-       .secondary = &ahbmux1_clk,
-};
-
-static struct clk ddr_hf_clk = {
-       .parent = &pll1_sw_clk,
-       .get_rate = _clk_ddr_hf_get_rate,
-};
-
-static struct clk ddr_clk = {
-       .parent = &ddr_hf_clk,
-};
-
-/* clock definitions for MIPI HSC unit which has been removed
- * from documentation, but not from hardware
- */
-static int _clk_hsc_enable(struct clk *clk)
-{
-       u32 reg;
-
-       _clk_ccgr_enable(clk);
-       /* Handshake with IPU when certain clock rates are changed. */
-       reg = __raw_readl(MXC_CCM_CCDR);
-       reg &= ~MXC_CCM_CCDR_HSC_HS_MASK;
-       __raw_writel(reg, MXC_CCM_CCDR);
-
-       reg = __raw_readl(MXC_CCM_CLPCR);
-       reg &= ~MXC_CCM_CLPCR_BYPASS_HSC_LPM_HS;
-       __raw_writel(reg, MXC_CCM_CLPCR);
-
-       return 0;
-}
-
-static void _clk_hsc_disable(struct clk *clk)
-{
-       u32 reg;
-
-       _clk_ccgr_disable(clk);
-       /* No handshake with HSC as its not enabled. */
-       reg = __raw_readl(MXC_CCM_CCDR);
-       reg |= MXC_CCM_CCDR_HSC_HS_MASK;
-       __raw_writel(reg, MXC_CCM_CCDR);
-
-       reg = __raw_readl(MXC_CCM_CLPCR);
-       reg |= MXC_CCM_CLPCR_BYPASS_HSC_LPM_HS;
-       __raw_writel(reg, MXC_CCM_CLPCR);
-}
-
-static struct clk mipi_hsp_clk = {
-       .parent = &ipu_clk,
-       .enable_reg = MXC_CCM_CCGR4,
-       .enable_shift = MXC_CCM_CCGRx_CG6_OFFSET,
-       .enable = _clk_hsc_enable,
-       .disable = _clk_hsc_disable,
-       .secondary = &mipi_hsc1_clk,
-};
-
-#define DEFINE_CLOCK_CCGR(name, i, er, es, pfx, p, s)  \
-       static struct clk name = {                      \
-               .id             = i,                    \
-               .enable_reg     = er,                   \
-               .enable_shift   = es,                   \
-               .get_rate       = pfx##_get_rate,       \
-               .set_rate       = pfx##_set_rate,       \
-               .round_rate     = pfx##_round_rate,     \
-               .set_parent     = pfx##_set_parent,     \
-               .enable         = _clk_ccgr_enable,     \
-               .disable        = _clk_ccgr_disable,    \
-               .parent         = p,                    \
-               .secondary      = s,                    \
-       }
-
-#define DEFINE_CLOCK_MAX(name, i, er, es, pfx, p, s)   \
-       static struct clk name = {                      \
-               .id             = i,                    \
-               .enable_reg     = er,                   \
-               .enable_shift   = es,                   \
-               .get_rate       = pfx##_get_rate,       \
-               .set_rate       = pfx##_set_rate,       \
-               .set_parent     = pfx##_set_parent,     \
-               .enable         = _clk_max_enable,      \
-               .disable        = _clk_max_disable,     \
-               .parent         = p,                    \
-               .secondary      = s,                    \
-       }
-
-#define CLK_GET_RATE(name, nr, bitsname)                               \
-static unsigned long clk_##name##_get_rate(struct clk *clk)            \
-{                                                                      \
-       u32 reg, pred, podf;                                            \
-                                                                       \
-       reg = __raw_readl(MXC_CCM_CSCDR##nr);                           \
-       pred = (reg & MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_MASK)   \
-               >> MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_OFFSET;    \
-       podf = (reg & MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_MASK)   \
-               >> MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_OFFSET;    \
-                                                                       \
-       return DIV_ROUND_CLOSEST(clk_get_rate(clk->parent),             \
-                       (pred + 1) * (podf + 1));                       \
-}
-
-#define CLK_SET_PARENT(name, nr, bitsname)                             \
-static int clk_##name##_set_parent(struct clk *clk, struct clk *parent)        \
-{                                                                      \
-       u32 reg, mux;                                                   \
-                                                                       \
-       mux = _get_mux(parent, &pll1_sw_clk, &pll2_sw_clk,              \
-                       &pll3_sw_clk, &lp_apm_clk);                     \
-       reg = __raw_readl(MXC_CCM_CSCMR##nr) &                          \
-               ~MXC_CCM_CSCMR##nr##_##bitsname##_CLK_SEL_MASK;         \
-       reg |= mux << MXC_CCM_CSCMR##nr##_##bitsname##_CLK_SEL_OFFSET;  \
-       __raw_writel(reg, MXC_CCM_CSCMR##nr);                           \
-                                                                       \
-       return 0;                                                       \
-}
-
-#define CLK_SET_RATE(name, nr, bitsname)                               \
-static int clk_##name##_set_rate(struct clk *clk, unsigned long rate)  \
-{                                                                      \
-       u32 reg, div, parent_rate;                                      \
-       u32 pre = 0, post = 0;                                          \
-                                                                       \
-       parent_rate = clk_get_rate(clk->parent);                        \
-       div = parent_rate / rate;                                       \
-                                                                       \
-       if ((parent_rate / div) != rate)                                \
-               return -EINVAL;                                         \
-                                                                       \
-       __calc_pre_post_dividers(div, &pre, &post,                      \
-               (MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_MASK >>      \
-               MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_OFFSET) + 1,  \
-               (MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_MASK >>      \
-               MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_OFFSET) + 1);\
-                                                                       \
-       /* Set sdhc1 clock divider */                                   \
-       reg = __raw_readl(MXC_CCM_CSCDR##nr) &                          \
-               ~(MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_MASK        \
-               | MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_MASK);      \
-       reg |= (post - 1) <<                                            \
-               MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_OFFSET;       \
-       reg |= (pre - 1) <<                                             \
-               MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_OFFSET;       \
-       __raw_writel(reg, MXC_CCM_CSCDR##nr);                           \
-                                                                       \
-       return 0;                                                       \
-}
-
-/* UART */
-CLK_GET_RATE(uart, 1, UART)
-CLK_SET_PARENT(uart, 1, UART)
-
-static struct clk uart_root_clk = {
-       .parent = &pll2_sw_clk,
-       .get_rate = clk_uart_get_rate,
-       .set_parent = clk_uart_set_parent,
-};
-
-/* USBOH3 */
-CLK_GET_RATE(usboh3, 1, USBOH3)
-CLK_SET_PARENT(usboh3, 1, USBOH3)
-
-static struct clk usboh3_clk = {
-       .parent = &pll2_sw_clk,
-       .get_rate = clk_usboh3_get_rate,
-       .set_parent = clk_usboh3_set_parent,
-       .enable = _clk_ccgr_enable,
-       .disable = _clk_ccgr_disable,
-       .enable_reg = MXC_CCM_CCGR2,
-       .enable_shift = MXC_CCM_CCGRx_CG14_OFFSET,
-};
-
-static struct clk usb_ahb_clk = {
-       .parent = &ipg_clk,
-       .enable = _clk_ccgr_enable,
-       .disable = _clk_ccgr_disable,
-       .enable_reg = MXC_CCM_CCGR2,
-       .enable_shift = MXC_CCM_CCGRx_CG13_OFFSET,
-};
-
-static int clk_usb_phy1_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 reg;
-
-       reg = __raw_readl(MXC_CCM_CSCMR1) & ~MXC_CCM_CSCMR1_USB_PHY_CLK_SEL;
-
-       if (parent == &pll3_sw_clk)
-               reg |= 1 << MXC_CCM_CSCMR1_USB_PHY_CLK_SEL_OFFSET;
-
-       __raw_writel(reg, MXC_CCM_CSCMR1);
-
-       return 0;
-}
-
-static struct clk usb_phy1_clk = {
-       .parent = &pll3_sw_clk,
-       .set_parent = clk_usb_phy1_set_parent,
-       .enable = _clk_ccgr_enable,
-       .enable_reg = MXC_CCM_CCGR2,
-       .enable_shift = MXC_CCM_CCGRx_CG0_OFFSET,
-       .disable = _clk_ccgr_disable,
-};
-
-/* eCSPI */
-CLK_GET_RATE(ecspi, 2, CSPI)
-CLK_SET_PARENT(ecspi, 1, CSPI)
-
-static struct clk ecspi_main_clk = {
-       .parent = &pll3_sw_clk,
-       .get_rate = clk_ecspi_get_rate,
-       .set_parent = clk_ecspi_set_parent,
-};
-
-/* eSDHC */
-CLK_GET_RATE(esdhc1, 1, ESDHC1_MSHC1)
-CLK_SET_PARENT(esdhc1, 1, ESDHC1_MSHC1)
-CLK_SET_RATE(esdhc1, 1, ESDHC1_MSHC1)
-
-/* mx51 specific */
-CLK_GET_RATE(esdhc2, 1, ESDHC2_MSHC2)
-CLK_SET_PARENT(esdhc2, 1, ESDHC2_MSHC2)
-CLK_SET_RATE(esdhc2, 1, ESDHC2_MSHC2)
-
-static int clk_esdhc3_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 reg;
-
-       reg = __raw_readl(MXC_CCM_CSCMR1);
-       if (parent == &esdhc1_clk)
-               reg &= ~MXC_CCM_CSCMR1_ESDHC3_CLK_SEL;
-       else if (parent == &esdhc2_clk)
-               reg |= MXC_CCM_CSCMR1_ESDHC3_CLK_SEL;
-       else
-               return -EINVAL;
-       __raw_writel(reg, MXC_CCM_CSCMR1);
-
-       return 0;
-}
-
-static int clk_esdhc4_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 reg;
-
-       reg = __raw_readl(MXC_CCM_CSCMR1);
-       if (parent == &esdhc1_clk)
-               reg &= ~MXC_CCM_CSCMR1_ESDHC4_CLK_SEL;
-       else if (parent == &esdhc2_clk)
-               reg |= MXC_CCM_CSCMR1_ESDHC4_CLK_SEL;
-       else
-               return -EINVAL;
-       __raw_writel(reg, MXC_CCM_CSCMR1);
-
-       return 0;
-}
-
-/* mx53 specific */
-static int clk_esdhc2_mx53_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 reg;
-
-       reg = __raw_readl(MXC_CCM_CSCMR1);
-       if (parent == &esdhc1_clk)
-               reg &= ~MXC_CCM_CSCMR1_ESDHC2_MSHC2_MX53_CLK_SEL;
-       else if (parent == &esdhc3_mx53_clk)
-               reg |= MXC_CCM_CSCMR1_ESDHC2_MSHC2_MX53_CLK_SEL;
-       else
-               return -EINVAL;
-       __raw_writel(reg, MXC_CCM_CSCMR1);
-
-       return 0;
-}
-
-CLK_GET_RATE(esdhc3_mx53, 1, ESDHC3_MX53)
-CLK_SET_PARENT(esdhc3_mx53, 1, ESDHC3_MX53)
-CLK_SET_RATE(esdhc3_mx53, 1, ESDHC3_MX53)
-
-static int clk_esdhc4_mx53_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 reg;
-
-       reg = __raw_readl(MXC_CCM_CSCMR1);
-       if (parent == &esdhc1_clk)
-               reg &= ~MXC_CCM_CSCMR1_ESDHC4_CLK_SEL;
-       else if (parent == &esdhc3_mx53_clk)
-               reg |= MXC_CCM_CSCMR1_ESDHC4_CLK_SEL;
-       else
-               return -EINVAL;
-       __raw_writel(reg, MXC_CCM_CSCMR1);
-
-       return 0;
-}
-
-#define DEFINE_CLOCK_FULL(name, i, er, es, gr, sr, e, d, p, s)         \
-       static struct clk name = {                                      \
-               .id             = i,                                    \
-               .enable_reg     = er,                                   \
-               .enable_shift   = es,                                   \
-               .get_rate       = gr,                                   \
-               .set_rate       = sr,                                   \
-               .enable         = e,                                    \
-               .disable        = d,                                    \
-               .parent         = p,                                    \
-               .secondary      = s,                                    \
-       }
-
-#define DEFINE_CLOCK(name, i, er, es, gr, sr, p, s)                    \
-       DEFINE_CLOCK_FULL(name, i, er, es, gr, sr, _clk_ccgr_enable, _clk_ccgr_disable, p, s)
-
-/* Shared peripheral bus arbiter */
-DEFINE_CLOCK(spba_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG0_OFFSET,
-       NULL,  NULL, &ipg_clk, NULL);
-
-/* UART */
-DEFINE_CLOCK(uart1_ipg_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG3_OFFSET,
-       NULL,  NULL, &ipg_clk, &aips_tz1_clk);
-DEFINE_CLOCK(uart2_ipg_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG5_OFFSET,
-       NULL,  NULL, &ipg_clk, &aips_tz1_clk);
-DEFINE_CLOCK(uart3_ipg_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG7_OFFSET,
-       NULL,  NULL, &ipg_clk, &spba_clk);
-DEFINE_CLOCK(uart4_ipg_clk, 3, MXC_CCM_CCGR7, MXC_CCM_CCGRx_CG4_OFFSET,
-       NULL,  NULL, &ipg_clk, &spba_clk);
-DEFINE_CLOCK(uart5_ipg_clk, 4, MXC_CCM_CCGR7, MXC_CCM_CCGRx_CG6_OFFSET,
-       NULL,  NULL, &ipg_clk, &spba_clk);
-DEFINE_CLOCK(uart1_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG4_OFFSET,
-       NULL,  NULL, &uart_root_clk, &uart1_ipg_clk);
-DEFINE_CLOCK(uart2_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG6_OFFSET,
-       NULL,  NULL, &uart_root_clk, &uart2_ipg_clk);
-DEFINE_CLOCK(uart3_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG8_OFFSET,
-       NULL,  NULL, &uart_root_clk, &uart3_ipg_clk);
-DEFINE_CLOCK(uart4_clk, 3, MXC_CCM_CCGR7, MXC_CCM_CCGRx_CG5_OFFSET,
-       NULL,  NULL, &uart_root_clk, &uart4_ipg_clk);
-DEFINE_CLOCK(uart5_clk, 4, MXC_CCM_CCGR7, MXC_CCM_CCGRx_CG7_OFFSET,
-       NULL,  NULL, &uart_root_clk, &uart5_ipg_clk);
-
-/* GPT */
-DEFINE_CLOCK(gpt_ipg_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG10_OFFSET,
-       NULL,  NULL, &ipg_clk, NULL);
-DEFINE_CLOCK(gpt_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG9_OFFSET,
-       NULL,  NULL, &ipg_clk, &gpt_ipg_clk);
-
-DEFINE_CLOCK(pwm1_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG6_OFFSET,
-       NULL, NULL, &ipg_perclk, NULL);
-DEFINE_CLOCK(pwm2_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG8_OFFSET,
-       NULL, NULL, &ipg_perclk, NULL);
-
-/* I2C */
-DEFINE_CLOCK(i2c1_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG9_OFFSET,
-       NULL, NULL, &ipg_perclk, NULL);
-DEFINE_CLOCK(i2c2_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG10_OFFSET,
-       NULL, NULL, &ipg_perclk, NULL);
-DEFINE_CLOCK(hsi2c_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG11_OFFSET,
-       NULL, NULL, &ipg_clk, NULL);
-DEFINE_CLOCK(i2c3_mx53_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG11_OFFSET,
-       NULL, NULL, &ipg_perclk, NULL);
-
-/* FEC */
-DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET,
-       NULL,  NULL, &ipg_clk, NULL);
-
-/* NFC */
-DEFINE_CLOCK_CCGR(nfc_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG10_OFFSET,
-       clk_nfc, &emi_slow_clk, NULL);
-
-/* SSI */
-DEFINE_CLOCK(ssi1_ipg_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG8_OFFSET,
-       NULL, NULL, &ipg_clk, NULL);
-DEFINE_CLOCK(ssi1_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG9_OFFSET,
-       NULL, NULL, &pll3_sw_clk, &ssi1_ipg_clk);
-DEFINE_CLOCK(ssi2_ipg_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG10_OFFSET,
-       NULL, NULL, &ipg_clk, NULL);
-DEFINE_CLOCK(ssi2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG11_OFFSET,
-       NULL, NULL, &pll3_sw_clk, &ssi2_ipg_clk);
-DEFINE_CLOCK(ssi3_ipg_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG12_OFFSET,
-       NULL, NULL, &ipg_clk, NULL);
-DEFINE_CLOCK(ssi3_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG13_OFFSET,
-       NULL, NULL, &pll3_sw_clk, &ssi3_ipg_clk);
-
-/* eCSPI */
-DEFINE_CLOCK_FULL(ecspi1_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET,
-               NULL, NULL, _clk_ccgr_enable_inrun, _clk_ccgr_disable,
-               &ipg_clk, &spba_clk);
-DEFINE_CLOCK(ecspi1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG10_OFFSET,
-               NULL, NULL, &ecspi_main_clk, &ecspi1_ipg_clk);
-DEFINE_CLOCK_FULL(ecspi2_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG11_OFFSET,
-               NULL, NULL, _clk_ccgr_enable_inrun, _clk_ccgr_disable,
-               &ipg_clk, &aips_tz2_clk);
-DEFINE_CLOCK(ecspi2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG12_OFFSET,
-               NULL, NULL, &ecspi_main_clk, &ecspi2_ipg_clk);
-
-/* CSPI */
-DEFINE_CLOCK(cspi_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET,
-               NULL, NULL, &ipg_clk, &aips_tz2_clk);
-DEFINE_CLOCK(cspi_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG13_OFFSET,
-               NULL, NULL, &ipg_clk, &cspi_ipg_clk);
-
-/* SDMA */
-DEFINE_CLOCK(sdma_clk, 1, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG15_OFFSET,
-               NULL, NULL, &ahb_clk, NULL);
-
-/* eSDHC */
-DEFINE_CLOCK_FULL(esdhc1_ipg_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG0_OFFSET,
-       NULL,  NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL);
-DEFINE_CLOCK_MAX(esdhc1_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG1_OFFSET,
-       clk_esdhc1, &pll2_sw_clk, &esdhc1_ipg_clk);
-DEFINE_CLOCK_FULL(esdhc2_ipg_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG2_OFFSET,
-       NULL,  NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL);
-DEFINE_CLOCK_FULL(esdhc3_ipg_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG4_OFFSET,
-       NULL,  NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL);
-DEFINE_CLOCK_FULL(esdhc4_ipg_clk, 3, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG6_OFFSET,
-       NULL,  NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL);
-
-/* mx51 specific */
-DEFINE_CLOCK_MAX(esdhc2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG3_OFFSET,
-       clk_esdhc2, &pll2_sw_clk, &esdhc2_ipg_clk);
-
-static struct clk esdhc3_clk = {
-       .id = 2,
-       .parent = &esdhc1_clk,
-       .set_parent = clk_esdhc3_set_parent,
-       .enable_reg = MXC_CCM_CCGR3,
-       .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET,
-       .enable  = _clk_max_enable,
-       .disable = _clk_max_disable,
-       .secondary = &esdhc3_ipg_clk,
-};
-static struct clk esdhc4_clk = {
-       .id = 3,
-       .parent = &esdhc1_clk,
-       .set_parent = clk_esdhc4_set_parent,
-       .enable_reg = MXC_CCM_CCGR3,
-       .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET,
-       .enable  = _clk_max_enable,
-       .disable = _clk_max_disable,
-       .secondary = &esdhc4_ipg_clk,
-};
-
-/* mx53 specific */
-static struct clk esdhc2_mx53_clk = {
-       .id = 2,
-       .parent = &esdhc1_clk,
-       .set_parent = clk_esdhc2_mx53_set_parent,
-       .enable_reg = MXC_CCM_CCGR3,
-       .enable_shift = MXC_CCM_CCGRx_CG3_OFFSET,
-       .enable  = _clk_max_enable,
-       .disable = _clk_max_disable,
-       .secondary = &esdhc3_ipg_clk,
-};
-
-DEFINE_CLOCK_MAX(esdhc3_mx53_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG5_OFFSET,
-       clk_esdhc3_mx53, &pll2_sw_clk, &esdhc2_ipg_clk);
-
-static struct clk esdhc4_mx53_clk = {
-       .id = 3,
-       .parent = &esdhc1_clk,
-       .set_parent = clk_esdhc4_mx53_set_parent,
-       .enable_reg = MXC_CCM_CCGR3,
-       .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET,
-       .enable  = _clk_max_enable,
-       .disable = _clk_max_disable,
-       .secondary = &esdhc4_ipg_clk,
-};
-
-static struct clk sata_clk = {
-       .parent = &ipg_clk,
-       .enable = _clk_max_enable,
-       .enable_reg = MXC_CCM_CCGR4,
-       .enable_shift = MXC_CCM_CCGRx_CG1_OFFSET,
-       .disable = _clk_max_disable,
-};
-
-static struct clk ahci_phy_clk = {
-       .parent = &usb_phy1_clk,
-};
-
-static struct clk ahci_dma_clk = {
-       .parent = &ahb_clk,
-};
-
-DEFINE_CLOCK(mipi_esc_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG5_OFFSET, NULL, NULL, NULL, &pll2_sw_clk);
-DEFINE_CLOCK(mipi_hsc2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG4_OFFSET, NULL, NULL, &mipi_esc_clk, &pll2_sw_clk);
-DEFINE_CLOCK(mipi_hsc1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG3_OFFSET, NULL, NULL, &mipi_hsc2_clk, &pll2_sw_clk);
-
-/* IPU */
-DEFINE_CLOCK_FULL(ipu_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG5_OFFSET,
-       NULL,  NULL, clk_ipu_enable, clk_ipu_disable, &ahb_clk, &ipu_sec_clk);
-
-DEFINE_CLOCK_FULL(emi_fast_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG7_OFFSET,
-               NULL, NULL, _clk_ccgr_enable, _clk_ccgr_disable_inwait,
-               &ddr_clk, NULL);
-
-DEFINE_CLOCK(ipu_di0_clk, 0, MXC_CCM_CCGR6, MXC_CCM_CCGRx_CG5_OFFSET,
-               NULL, NULL, &pll3_sw_clk, NULL);
-DEFINE_CLOCK(ipu_di1_clk, 0, MXC_CCM_CCGR6, MXC_CCM_CCGRx_CG6_OFFSET,
-               NULL, NULL, &pll3_sw_clk, NULL);
-
-/* PATA */
-DEFINE_CLOCK(pata_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG0_OFFSET,
-               NULL, NULL, &ipg_clk, &spba_clk);
-
-#define _REGISTER_CLOCK(d, n, c) \
-       { \
-               .dev_id = d, \
-               .con_id = n, \
-               .clk = &c,   \
-       },
-
-static struct clk_lookup mx51_lookups[] = {
-       /* i.mx51 has the i.mx21 type uart */
-       _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk)
-       _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk)
-       _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk)
-       _REGISTER_CLOCK(NULL, "gpt", gpt_clk)
-       /* i.mx51 has the i.mx27 type fec */
-       _REGISTER_CLOCK("imx27-fec.0", NULL, fec_clk)
-       _REGISTER_CLOCK("mxc_pwm.0", "pwm", pwm1_clk)
-       _REGISTER_CLOCK("mxc_pwm.1", "pwm", pwm2_clk)
-       _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
-       _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
-       _REGISTER_CLOCK("imx-i2c.2", NULL, hsi2c_clk)
-       _REGISTER_CLOCK("mxc-ehci.0", "usb", usboh3_clk)
-       _REGISTER_CLOCK("mxc-ehci.0", "usb_ahb", usb_ahb_clk)
-       _REGISTER_CLOCK("mxc-ehci.0", "usb_phy1", usb_phy1_clk)
-       _REGISTER_CLOCK("mxc-ehci.1", "usb", usboh3_clk)
-       _REGISTER_CLOCK("mxc-ehci.1", "usb_ahb", usb_ahb_clk)
-       _REGISTER_CLOCK("mxc-ehci.2", "usb", usboh3_clk)
-       _REGISTER_CLOCK("mxc-ehci.2", "usb_ahb", usb_ahb_clk)
-       _REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk)
-       _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk)
-       _REGISTER_CLOCK("imx-keypad", NULL, dummy_clk)
-       _REGISTER_CLOCK("mxc_nand", NULL, nfc_clk)
-       _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
-       _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
-       _REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk)
-       /* i.mx51 has the i.mx35 type sdma */
-       _REGISTER_CLOCK("imx35-sdma", NULL, sdma_clk)
-       _REGISTER_CLOCK(NULL, "ckih", ckih_clk)
-       _REGISTER_CLOCK(NULL, "ckih2", ckih2_clk)
-       _REGISTER_CLOCK(NULL, "gpt_32k", gpt_32k_clk)
-       _REGISTER_CLOCK("imx51-ecspi.0", NULL, ecspi1_clk)
-       _REGISTER_CLOCK("imx51-ecspi.1", NULL, ecspi2_clk)
-       /* i.mx51 has the i.mx35 type cspi */
-       _REGISTER_CLOCK("imx35-cspi.0", NULL, cspi_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx51.0", NULL, esdhc1_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx51.1", NULL, esdhc2_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx51.2", NULL, esdhc3_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx51.3", NULL, esdhc4_clk)
-       _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk)
-       _REGISTER_CLOCK(NULL, "iim_clk", iim_clk)
-       _REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk)
-       _REGISTER_CLOCK("imx2-wdt.1", NULL, dummy_clk)
-       _REGISTER_CLOCK(NULL, "mipi_hsp", mipi_hsp_clk)
-       _REGISTER_CLOCK("imx-ipuv3", NULL, ipu_clk)
-       _REGISTER_CLOCK("imx-ipuv3", "di0", ipu_di0_clk)
-       _REGISTER_CLOCK("imx-ipuv3", "di1", ipu_di1_clk)
-       _REGISTER_CLOCK(NULL, "gpc_dvfs", gpc_dvfs_clk)
-       _REGISTER_CLOCK("pata_imx", NULL, pata_clk)
-};
-
-static struct clk_lookup mx53_lookups[] = {
-       /* i.mx53 has the i.mx21 type uart */
-       _REGISTER_CLOCK("imx21-uart.0", NULL, uart1_clk)
-       _REGISTER_CLOCK("imx21-uart.1", NULL, uart2_clk)
-       _REGISTER_CLOCK("imx21-uart.2", NULL, uart3_clk)
-       _REGISTER_CLOCK("imx21-uart.3", NULL, uart4_clk)
-       _REGISTER_CLOCK("imx21-uart.4", NULL, uart5_clk)
-       _REGISTER_CLOCK(NULL, "gpt", gpt_clk)
-       /* i.mx53 has the i.mx25 type fec */
-       _REGISTER_CLOCK("imx25-fec.0", NULL, fec_clk)
-       _REGISTER_CLOCK(NULL, "iim_clk", iim_clk)
-       _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
-       _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
-       _REGISTER_CLOCK("imx-i2c.2", NULL, i2c3_mx53_clk)
-       /* i.mx53 has the i.mx51 type ecspi */
-       _REGISTER_CLOCK("imx51-ecspi.0", NULL, ecspi1_clk)
-       _REGISTER_CLOCK("imx51-ecspi.1", NULL, ecspi2_clk)
-       /* i.mx53 has the i.mx25 type cspi */
-       _REGISTER_CLOCK("imx35-cspi.0", NULL, cspi_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx53.0", NULL, esdhc1_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx53.1", NULL, esdhc2_mx53_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx53.2", NULL, esdhc3_mx53_clk)
-       _REGISTER_CLOCK("sdhci-esdhc-imx53.3", NULL, esdhc4_mx53_clk)
-       _REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk)
-       _REGISTER_CLOCK("imx2-wdt.1", NULL, dummy_clk)
-       /* i.mx53 has the i.mx35 type sdma */
-       _REGISTER_CLOCK("imx35-sdma", NULL, sdma_clk)
-       _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
-       _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
-       _REGISTER_CLOCK("imx-ssi.2", NULL, ssi3_clk)
-       _REGISTER_CLOCK("imx-keypad", NULL, dummy_clk)
-       _REGISTER_CLOCK("pata_imx", NULL, pata_clk)
-       _REGISTER_CLOCK("imx53-ahci.0", "ahci", sata_clk)
-       _REGISTER_CLOCK("imx53-ahci.0", "ahci_phy", ahci_phy_clk)
-       _REGISTER_CLOCK("imx53-ahci.0", "ahci_dma", ahci_dma_clk)
-};
-
-static void clk_tree_init(void)
-{
-       u32 reg;
-
-       ipg_perclk.set_parent(&ipg_perclk, &lp_apm_clk);
-
-       /*
-        * Initialise the IPG PER CLK dividers to 3. IPG_PER_CLK should be at
-        * 8MHz, its derived from lp_apm.
-        *
-        * FIXME: Verify if true for all boards
-        */
-       reg = __raw_readl(MXC_CCM_CBCDR);
-       reg &= ~MXC_CCM_CBCDR_PERCLK_PRED1_MASK;
-       reg &= ~MXC_CCM_CBCDR_PERCLK_PRED2_MASK;
-       reg &= ~MXC_CCM_CBCDR_PERCLK_PODF_MASK;
-       reg |= (2 << MXC_CCM_CBCDR_PERCLK_PRED1_OFFSET);
-       __raw_writel(reg, MXC_CCM_CBCDR);
-}
-
-int __init mx51_clocks_init(unsigned long ckil, unsigned long osc,
-                       unsigned long ckih1, unsigned long ckih2)
-{
-       int i;
-
-       external_low_reference = ckil;
-       external_high_reference = ckih1;
-       ckih2_reference = ckih2;
-       oscillator_reference = osc;
-
-       for (i = 0; i < ARRAY_SIZE(mx51_lookups); i++)
-               clkdev_add(&mx51_lookups[i]);
-
-       clk_tree_init();
-
-       clk_enable(&cpu_clk);
-       clk_enable(&main_bus_clk);
-
-       clk_enable(&iim_clk);
-       imx_print_silicon_rev("i.MX51", mx51_revision());
-       clk_disable(&iim_clk);
-
-       /* move usb_phy_clk to 24MHz */
-       clk_set_parent(&usb_phy1_clk, &osc_clk);
-
-       /* set the usboh3_clk parent to pll2_sw_clk */
-       clk_set_parent(&usboh3_clk, &pll2_sw_clk);
-
-       /* Set SDHC parents to be PLL2 */
-       clk_set_parent(&esdhc1_clk, &pll2_sw_clk);
-       clk_set_parent(&esdhc2_clk, &pll2_sw_clk);
-
-       /* set SDHC root clock as 166.25MHZ*/
-       clk_set_rate(&esdhc1_clk, 166250000);
-       clk_set_rate(&esdhc2_clk, 166250000);
-
-       /* System timer */
-       mxc_timer_init(&gpt_clk, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR),
-               MX51_INT_GPT);
-       return 0;
-}
-
-int __init mx53_clocks_init(unsigned long ckil, unsigned long osc,
-                       unsigned long ckih1, unsigned long ckih2)
-{
-       int i;
-
-       external_low_reference = ckil;
-       external_high_reference = ckih1;
-       ckih2_reference = ckih2;
-       oscillator_reference = osc;
-
-       for (i = 0; i < ARRAY_SIZE(mx53_lookups); i++)
-               clkdev_add(&mx53_lookups[i]);
-
-       clk_tree_init();
-
-       clk_set_parent(&uart_root_clk, &pll3_sw_clk);
-       clk_enable(&cpu_clk);
-       clk_enable(&main_bus_clk);
-
-       clk_enable(&iim_clk);
-       imx_print_silicon_rev("i.MX53", mx53_revision());
-       clk_disable(&iim_clk);
-
-       /* Set SDHC parents to be PLL2 */
-       clk_set_parent(&esdhc1_clk, &pll2_sw_clk);
-       clk_set_parent(&esdhc3_mx53_clk, &pll2_sw_clk);
-
-       /* set SDHC root clock as 200MHZ*/
-       clk_set_rate(&esdhc1_clk, 200000000);
-       clk_set_rate(&esdhc3_mx53_clk, 200000000);
-
-       /* System timer */
-       mxc_timer_init(&gpt_clk, MX53_IO_ADDRESS(MX53_GPT1_BASE_ADDR),
-               MX53_INT_GPT);
-       return 0;
-}
-
-#ifdef CONFIG_OF
-static void __init clk_get_freq_dt(unsigned long *ckil, unsigned long *osc,
-                                  unsigned long *ckih1, unsigned long *ckih2)
-{
-       struct device_node *np;
-
-       /* retrieve the freqency of fixed clocks from device tree */
-       for_each_compatible_node(np, NULL, "fixed-clock") {
-               u32 rate;
-               if (of_property_read_u32(np, "clock-frequency", &rate))
-                       continue;
-
-               if (of_device_is_compatible(np, "fsl,imx-ckil"))
-                       *ckil = rate;
-               else if (of_device_is_compatible(np, "fsl,imx-osc"))
-                       *osc = rate;
-               else if (of_device_is_compatible(np, "fsl,imx-ckih1"))
-                       *ckih1 = rate;
-               else if (of_device_is_compatible(np, "fsl,imx-ckih2"))
-                       *ckih2 = rate;
-       }
-}
-
-int __init mx51_clocks_init_dt(void)
-{
-       unsigned long ckil, osc, ckih1, ckih2;
-
-       clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2);
-       return mx51_clocks_init(ckil, osc, ckih1, ckih2);
-}
-
-int __init mx53_clocks_init_dt(void)
-{
-       unsigned long ckil, osc, ckih1, ckih2;
-
-       clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2);
-       return mx53_clocks_init(ckil, osc, ckih1, ckih2);
-}
-#endif
index 53141273df452059ed38e43e0a2cb23e5df8421e..a1dfde53e335bafa291a33faf5a7400b82366be8 100644 (file)
 #define CKIH_CLK_FREQ_27MHZ     27000000
 #define CKIL_CLK_FREQ           32768
 
-#define MXC_CCM_BASE           (cpu_is_mx31() ? \
-MX31_IO_ADDRESS(MX31_CCM_BASE_ADDR) : MX35_IO_ADDRESS(MX35_CCM_BASE_ADDR))
+extern void __iomem *mx3_ccm_base;
 
 /* Register addresses */
-#define MXC_CCM_CCMR           (MXC_CCM_BASE + 0x00)
-#define MXC_CCM_PDR0           (MXC_CCM_BASE + 0x04)
-#define MXC_CCM_PDR1           (MXC_CCM_BASE + 0x08)
-#define MX35_CCM_PDR2          (MXC_CCM_BASE + 0x0C)
-#define MXC_CCM_RCSR           (MXC_CCM_BASE + 0x0C)
-#define MX35_CCM_PDR3          (MXC_CCM_BASE + 0x10)
-#define MXC_CCM_MPCTL          (MXC_CCM_BASE + 0x10)
-#define MX35_CCM_PDR4          (MXC_CCM_BASE + 0x14)
-#define MXC_CCM_UPCTL          (MXC_CCM_BASE + 0x14)
-#define MX35_CCM_RCSR          (MXC_CCM_BASE + 0x18)
-#define MXC_CCM_SRPCTL         (MXC_CCM_BASE + 0x18)
-#define MX35_CCM_MPCTL         (MXC_CCM_BASE + 0x1C)
-#define MXC_CCM_COSR           (MXC_CCM_BASE + 0x1C)
-#define MX35_CCM_PPCTL         (MXC_CCM_BASE + 0x20)
-#define MXC_CCM_CGR0           (MXC_CCM_BASE + 0x20)
-#define MX35_CCM_ACMR          (MXC_CCM_BASE + 0x24)
-#define MXC_CCM_CGR1           (MXC_CCM_BASE + 0x24)
-#define MX35_CCM_COSR          (MXC_CCM_BASE + 0x28)
-#define MXC_CCM_CGR2           (MXC_CCM_BASE + 0x28)
-#define MX35_CCM_CGR0          (MXC_CCM_BASE + 0x2C)
-#define MXC_CCM_WIMR           (MXC_CCM_BASE + 0x2C)
-#define MX35_CCM_CGR1          (MXC_CCM_BASE + 0x30)
-#define MXC_CCM_LDC            (MXC_CCM_BASE + 0x30)
-#define MX35_CCM_CGR2          (MXC_CCM_BASE + 0x34)
-#define MXC_CCM_DCVR0          (MXC_CCM_BASE + 0x34)
-#define MX35_CCM_CGR3          (MXC_CCM_BASE + 0x38)
-#define MXC_CCM_DCVR1          (MXC_CCM_BASE + 0x38)
-#define MXC_CCM_DCVR2          (MXC_CCM_BASE + 0x3C)
-#define MXC_CCM_DCVR3          (MXC_CCM_BASE + 0x40)
-#define MXC_CCM_LTR0           (MXC_CCM_BASE + 0x44)
-#define MXC_CCM_LTR1           (MXC_CCM_BASE + 0x48)
-#define MXC_CCM_LTR2           (MXC_CCM_BASE + 0x4C)
-#define MXC_CCM_LTR3           (MXC_CCM_BASE + 0x50)
-#define MXC_CCM_LTBR0          (MXC_CCM_BASE + 0x54)
-#define MXC_CCM_LTBR1          (MXC_CCM_BASE + 0x58)
-#define MXC_CCM_PMCR0          (MXC_CCM_BASE + 0x5C)
-#define MXC_CCM_PMCR1          (MXC_CCM_BASE + 0x60)
-#define MXC_CCM_PDR2           (MXC_CCM_BASE + 0x64)
+#define MXC_CCM_CCMR           0x00
+#define MXC_CCM_PDR0           0x04
+#define MXC_CCM_PDR1           0x08
+#define MX35_CCM_PDR2          0x0C
+#define MXC_CCM_RCSR           0x0C
+#define MX35_CCM_PDR3          0x10
+#define MXC_CCM_MPCTL          0x10
+#define MX35_CCM_PDR4          0x14
+#define MXC_CCM_UPCTL          0x14
+#define MX35_CCM_RCSR          0x18
+#define MXC_CCM_SRPCTL         0x18
+#define MX35_CCM_MPCTL         0x1C
+#define MXC_CCM_COSR           0x1C
+#define MX35_CCM_PPCTL         0x20
+#define MXC_CCM_CGR0           0x20
+#define MX35_CCM_ACMR          0x24
+#define MXC_CCM_CGR1           0x24
+#define MX35_CCM_COSR          0x28
+#define MXC_CCM_CGR2           0x28
+#define MX35_CCM_CGR0          0x2C
+#define MXC_CCM_WIMR           0x2C
+#define MX35_CCM_CGR1          0x30
+#define MXC_CCM_LDC            0x30
+#define MX35_CCM_CGR2          0x34
+#define MXC_CCM_DCVR0          0x34
+#define MX35_CCM_CGR3          0x38
+#define MXC_CCM_DCVR1          0x38
+#define MXC_CCM_DCVR2          0x3C
+#define MXC_CCM_DCVR3          0x40
+#define MXC_CCM_LTR0           0x44
+#define MXC_CCM_LTR1           0x48
+#define MXC_CCM_LTR2           0x4C
+#define MXC_CCM_LTR3           0x50
+#define MXC_CCM_LTBR0          0x54
+#define MXC_CCM_LTBR1          0x58
+#define MXC_CCM_PMCR0          0x5C
+#define MXC_CCM_PMCR1          0x60
+#define MXC_CCM_PDR2           0x64
 
 /* Register bit definitions */
 #define MXC_CCM_CCMR_WBEN                       (1 << 27)
index 74127389e7abe1b06ca648138137e79d0aa7b38f..57b39f839f9ef1dee502024cecf95778e3e0fb18 100644 (file)
 #include <mach/iomux-v3.h>
 #include <mach/irqs.h>
 
+#include "crmregs-imx3.h"
+
+void __iomem *mx3_ccm_base;
+
 static void imx3_idle(void)
 {
        unsigned long reg = 0;
@@ -137,6 +141,7 @@ void __init imx31_init_early(void)
        mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR));
        arch_ioremap_caller = imx3_ioremap_caller;
        arm_pm_idle = imx3_idle;
+       mx3_ccm_base = MX31_IO_ADDRESS(MX31_CCM_BASE_ADDR);
 }
 
 void __init mx31_init_irq(void)
@@ -210,6 +215,7 @@ void __init imx35_init_early(void)
        mxc_arch_reset_init(MX35_IO_ADDRESS(MX35_WDOG_BASE_ADDR));
        arm_pm_idle = imx3_idle;
        arch_ioremap_caller = imx3_ioremap_caller;
+       mx3_ccm_base = MX35_IO_ADDRESS(MX35_CCM_BASE_ADDR);
 }
 
 void __init mx35_init_irq(void)
index e10f3914fcfe6b1d2c59f9296d373805b4740901..68341cfc4e1ede7ab69a8b470d293239b4c8a797 100644 (file)
@@ -32,6 +32,7 @@ static void imx5_idle(void)
                gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs");
                if (IS_ERR(gpc_dvfs_clk))
                        return;
+               clk_prepare(gpc_dvfs_clk);
        }
        clk_enable(gpc_dvfs_clk);
        mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF);
index b3752439632ec1ecabbbaec64bd8f5ed3dc0e966..822103bdb7092eab3ba63c3260f9da4f587abc2f 100644 (file)
  */
 void mx3_cpu_lp_set(enum mx3_cpu_pwr_mode mode)
 {
-       int reg = __raw_readl(MXC_CCM_CCMR);
+       int reg = __raw_readl(mx3_ccm_base + MXC_CCM_CCMR);
        reg &= ~MXC_CCM_CCMR_LPM_MASK;
 
        switch (mode) {
        case MX3_WAIT:
                if (cpu_is_mx35())
                        reg |= MXC_CCM_CCMR_LPM_WAIT_MX35;
-               __raw_writel(reg, MXC_CCM_CCMR);
+               __raw_writel(reg, mx3_ccm_base + MXC_CCM_CCMR);
                break;
        default:
                pr_err("Unknown cpu power mode: %d\n", mode);
index 962e71169750a0243225b52c1ddda062779eb5e0..fb3496a52ef4c08921de04e75e4682ad00e796a2 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/irqdomain.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/memblock.h>
 
@@ -49,10 +50,22 @@ static void __init msm8x60_map_io(void)
        msm_map_msm8x60_io();
 }
 
+#ifdef CONFIG_OF
+static struct of_device_id msm_dt_gic_match[] __initdata = {
+       { .compatible = "qcom,msm-8660-qgic", .data = gic_of_init },
+       {}
+};
+#endif
+
 static void __init msm8x60_init_irq(void)
 {
-       gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
-                (void *)MSM_QGIC_CPU_BASE);
+       if (!of_have_populated_dt())
+               gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
+                        (void *)MSM_QGIC_CPU_BASE);
+#ifdef CONFIG_OF
+       else
+               of_irq_init(msm_dt_gic_match);
+#endif
 
        /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
        writel(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
@@ -73,16 +86,8 @@ static struct of_dev_auxdata msm_auxdata_lookup[] __initdata = {
        {}
 };
 
-static struct of_device_id msm_dt_gic_match[] __initdata = {
-       { .compatible = "qcom,msm-8660-qgic", },
-       {}
-};
-
 static void __init msm8x60_dt_init(void)
 {
-       irq_domain_generate_simple(msm_dt_gic_match, MSM8X60_QGIC_DIST_PHYS,
-                               GIC_SPI_START);
-
        if (of_machine_is_compatible("qcom,msm8660-surf")) {
                printk(KERN_INFO "Init surf UART registers\n");
                msm8x60_init_uart12dm();
index 908bf9a567f18f490a81c708be9ddb9c4744fc40..6ce21a26412eb32332ec3790aa97c3ba471c5af6 100644 (file)
@@ -1,12 +1,9 @@
 # Common support
-obj-y := clock.o devices.o icoll.o iomux.o system.o timer.o mm.o
+obj-y := devices.o icoll.o iomux.o system.o timer.o mm.o
 
 obj-$(CONFIG_MXS_OCOTP) += ocotp.o
 obj-$(CONFIG_PM) += pm.o
 
-obj-$(CONFIG_SOC_IMX23) += clock-mx23.o
-obj-$(CONFIG_SOC_IMX28) += clock-mx28.o
-
 obj-$(CONFIG_MACH_STMP378X_DEVB) += mach-stmp378x_devb.o
 obj-$(CONFIG_MACH_MX23EVK) += mach-mx23evk.o
 obj-$(CONFIG_MACH_MX28EVK) += mach-mx28evk.o
diff --git a/arch/arm/mach-mxs/clock-mx23.c b/arch/arm/mach-mxs/clock-mx23.c
deleted file mode 100644 (file)
index e3ac52c..0000000
+++ /dev/null
@@ -1,536 +0,0 @@
-/*
- * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <linux/mm.h>
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/jiffies.h>
-#include <linux/clkdev.h>
-
-#include <asm/clkdev.h>
-#include <asm/div64.h>
-
-#include <mach/mx23.h>
-#include <mach/common.h>
-#include <mach/clock.h>
-
-#include "regs-clkctrl-mx23.h"
-
-#define CLKCTRL_BASE_ADDR      MX23_IO_ADDRESS(MX23_CLKCTRL_BASE_ADDR)
-#define DIGCTRL_BASE_ADDR      MX23_IO_ADDRESS(MX23_DIGCTL_BASE_ADDR)
-
-#define PARENT_RATE_SHIFT      8
-
-static int _raw_clk_enable(struct clk *clk)
-{
-       u32 reg;
-
-       if (clk->enable_reg) {
-               reg = __raw_readl(clk->enable_reg);
-               reg &= ~(1 << clk->enable_shift);
-               __raw_writel(reg, clk->enable_reg);
-       }
-
-       return 0;
-}
-
-static void _raw_clk_disable(struct clk *clk)
-{
-       u32 reg;
-
-       if (clk->enable_reg) {
-               reg = __raw_readl(clk->enable_reg);
-               reg |= 1 << clk->enable_shift;
-               __raw_writel(reg, clk->enable_reg);
-       }
-}
-
-/*
- * ref_xtal_clk
- */
-static unsigned long ref_xtal_clk_get_rate(struct clk *clk)
-{
-       return 24000000;
-}
-
-static struct clk ref_xtal_clk = {
-       .get_rate = ref_xtal_clk_get_rate,
-};
-
-/*
- * pll_clk
- */
-static unsigned long pll_clk_get_rate(struct clk *clk)
-{
-       return 480000000;
-}
-
-static int pll_clk_enable(struct clk *clk)
-{
-       __raw_writel(BM_CLKCTRL_PLLCTRL0_POWER |
-                       BM_CLKCTRL_PLLCTRL0_EN_USB_CLKS,
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_PLLCTRL0_SET);
-
-       /* Only a 10us delay is need. PLLCTRL1 LOCK bitfied is only a timer
-        * and is incorrect (excessive). Per definition of the PLLCTRL0
-        * POWER field, waiting at least 10us.
-        */
-       udelay(10);
-
-       return 0;
-}
-
-static void pll_clk_disable(struct clk *clk)
-{
-       __raw_writel(BM_CLKCTRL_PLLCTRL0_POWER |
-                       BM_CLKCTRL_PLLCTRL0_EN_USB_CLKS,
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_PLLCTRL0_CLR);
-}
-
-static struct clk pll_clk = {
-        .get_rate = pll_clk_get_rate,
-        .enable = pll_clk_enable,
-        .disable = pll_clk_disable,
-        .parent = &ref_xtal_clk,
-};
-
-/*
- * ref_clk
- */
-#define _CLK_GET_RATE_REF(name, sr, ss)                                        \
-static unsigned long name##_get_rate(struct clk *clk)                  \
-{                                                                      \
-       unsigned long parent_rate;                                      \
-       u32 reg, div;                                                   \
-                                                                       \
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##sr);         \
-       div = (reg >> BP_CLKCTRL_##sr##_##ss##FRAC) & 0x3f;             \
-       parent_rate = clk_get_rate(clk->parent);                        \
-                                                                       \
-       return SH_DIV((parent_rate >> PARENT_RATE_SHIFT) * 18,          \
-                       div, PARENT_RATE_SHIFT);                        \
-}
-
-_CLK_GET_RATE_REF(ref_cpu_clk, FRAC, CPU)
-_CLK_GET_RATE_REF(ref_emi_clk, FRAC, EMI)
-_CLK_GET_RATE_REF(ref_pix_clk, FRAC, PIX)
-_CLK_GET_RATE_REF(ref_io_clk, FRAC, IO)
-
-#define _DEFINE_CLOCK_REF(name, er, es)                                        \
-       static struct clk name = {                                      \
-               .enable_reg     = CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er,  \
-               .enable_shift   = BP_CLKCTRL_##er##_CLKGATE##es,        \
-               .get_rate       = name##_get_rate,                      \
-               .enable         = _raw_clk_enable,                      \
-               .disable        = _raw_clk_disable,                     \
-               .parent         = &pll_clk,                             \
-       }
-
-_DEFINE_CLOCK_REF(ref_cpu_clk, FRAC, CPU);
-_DEFINE_CLOCK_REF(ref_emi_clk, FRAC, EMI);
-_DEFINE_CLOCK_REF(ref_pix_clk, FRAC, PIX);
-_DEFINE_CLOCK_REF(ref_io_clk, FRAC, IO);
-
-/*
- * General clocks
- *
- * clk_get_rate
- */
-static unsigned long rtc_clk_get_rate(struct clk *clk)
-{
-       /* ref_xtal_clk is implemented as the only parent */
-       return clk_get_rate(clk->parent) / 768;
-}
-
-static unsigned long clk32k_clk_get_rate(struct clk *clk)
-{
-       return clk->parent->get_rate(clk->parent) / 750;
-}
-
-#define _CLK_GET_RATE(name, rs)                                                \
-static unsigned long name##_get_rate(struct clk *clk)                  \
-{                                                                      \
-       u32 reg, div;                                                   \
-                                                                       \
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs);         \
-                                                                       \
-       if (clk->parent == &ref_xtal_clk)                               \
-               div = (reg & BM_CLKCTRL_##rs##_DIV_XTAL) >>             \
-                       BP_CLKCTRL_##rs##_DIV_XTAL;                     \
-       else                                                            \
-               div = (reg & BM_CLKCTRL_##rs##_DIV_##rs) >>             \
-                       BP_CLKCTRL_##rs##_DIV_##rs;                     \
-                                                                       \
-       if (!div)                                                       \
-               return -EINVAL;                                         \
-                                                                       \
-       return clk_get_rate(clk->parent) / div;                         \
-}
-
-_CLK_GET_RATE(cpu_clk, CPU)
-_CLK_GET_RATE(emi_clk, EMI)
-
-#define _CLK_GET_RATE1(name, rs)                                       \
-static unsigned long name##_get_rate(struct clk *clk)                  \
-{                                                                      \
-       u32 reg, div;                                                   \
-                                                                       \
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs);         \
-       div = (reg & BM_CLKCTRL_##rs##_DIV) >> BP_CLKCTRL_##rs##_DIV;   \
-                                                                       \
-       if (!div)                                                       \
-               return -EINVAL;                                         \
-                                                                       \
-       return clk_get_rate(clk->parent) / div;                         \
-}
-
-_CLK_GET_RATE1(hbus_clk, HBUS)
-_CLK_GET_RATE1(xbus_clk, XBUS)
-_CLK_GET_RATE1(ssp_clk, SSP)
-_CLK_GET_RATE1(gpmi_clk, GPMI)
-_CLK_GET_RATE1(lcdif_clk, PIX)
-
-#define _CLK_GET_RATE_STUB(name)                                       \
-static unsigned long name##_get_rate(struct clk *clk)                  \
-{                                                                      \
-       return clk_get_rate(clk->parent);                               \
-}
-
-_CLK_GET_RATE_STUB(uart_clk)
-_CLK_GET_RATE_STUB(audio_clk)
-_CLK_GET_RATE_STUB(pwm_clk)
-
-/*
- * clk_set_rate
- */
-static int cpu_clk_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 reg, bm_busy, div_max, d, f, div, frac;
-       unsigned long diff, parent_rate, calc_rate;
-
-       parent_rate = clk_get_rate(clk->parent);
-
-       if (clk->parent == &ref_xtal_clk) {
-               div_max = BM_CLKCTRL_CPU_DIV_XTAL >> BP_CLKCTRL_CPU_DIV_XTAL;
-               bm_busy = BM_CLKCTRL_CPU_BUSY_REF_XTAL;
-               div = DIV_ROUND_UP(parent_rate, rate);
-               if (div == 0 || div > div_max)
-                       return -EINVAL;
-       } else {
-               div_max = BM_CLKCTRL_CPU_DIV_CPU >> BP_CLKCTRL_CPU_DIV_CPU;
-               bm_busy = BM_CLKCTRL_CPU_BUSY_REF_CPU;
-               rate >>= PARENT_RATE_SHIFT;
-               parent_rate >>= PARENT_RATE_SHIFT;
-               diff = parent_rate;
-               div = frac = 1;
-               for (d = 1; d <= div_max; d++) {
-                       f = parent_rate * 18 / d / rate;
-                       if ((parent_rate * 18 / d) % rate)
-                               f++;
-                       if (f < 18 || f > 35)
-                               continue;
-
-                       calc_rate = parent_rate * 18 / f / d;
-                       if (calc_rate > rate)
-                               continue;
-
-                       if (rate - calc_rate < diff) {
-                               frac = f;
-                               div = d;
-                               diff = rate - calc_rate;
-                       }
-
-                       if (diff == 0)
-                               break;
-               }
-
-               if (diff == parent_rate)
-                       return -EINVAL;
-
-               reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC);
-               reg &= ~BM_CLKCTRL_FRAC_CPUFRAC;
-               reg |= frac;
-               __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC);
-       }
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU);
-       reg &= ~BM_CLKCTRL_CPU_DIV_CPU;
-       reg |= div << BP_CLKCTRL_CPU_DIV_CPU;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU);
-
-       mxs_clkctrl_timeout(HW_CLKCTRL_CPU, bm_busy);
-
-       return 0;
-}
-
-#define _CLK_SET_RATE(name, dr)                                                \
-static int name##_set_rate(struct clk *clk, unsigned long rate)                \
-{                                                                      \
-       u32 reg, div_max, div;                                          \
-       unsigned long parent_rate;                                      \
-                                                                       \
-       parent_rate = clk_get_rate(clk->parent);                        \
-       div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV;       \
-                                                                       \
-       div = DIV_ROUND_UP(parent_rate, rate);                          \
-       if (div == 0 || div > div_max)                                  \
-               return -EINVAL;                                         \
-                                                                       \
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr);         \
-       reg &= ~BM_CLKCTRL_##dr##_DIV;                                  \
-       reg |= div << BP_CLKCTRL_##dr##_DIV;                            \
-       if (reg & (1 << clk->enable_shift)) {                           \
-               pr_err("%s: clock is gated\n", __func__);               \
-               return -EINVAL;                                         \
-       }                                                               \
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr);         \
-                                                                       \
-       mxs_clkctrl_timeout(HW_CLKCTRL_##dr, BM_CLKCTRL_##dr##_BUSY);   \
-       return 0;                                                       \
-}
-
-_CLK_SET_RATE(xbus_clk, XBUS)
-_CLK_SET_RATE(ssp_clk, SSP)
-_CLK_SET_RATE(gpmi_clk, GPMI)
-_CLK_SET_RATE(lcdif_clk, PIX)
-
-#define _CLK_SET_RATE_STUB(name)                                       \
-static int name##_set_rate(struct clk *clk, unsigned long rate)                \
-{                                                                      \
-       return -EINVAL;                                                 \
-}
-
-_CLK_SET_RATE_STUB(emi_clk)
-_CLK_SET_RATE_STUB(uart_clk)
-_CLK_SET_RATE_STUB(audio_clk)
-_CLK_SET_RATE_STUB(pwm_clk)
-_CLK_SET_RATE_STUB(clk32k_clk)
-
-/*
- * clk_set_parent
- */
-#define _CLK_SET_PARENT(name, bit)                                     \
-static int name##_set_parent(struct clk *clk, struct clk *parent)      \
-{                                                                      \
-       if (parent != clk->parent) {                                    \
-               __raw_writel(BM_CLKCTRL_CLKSEQ_BYPASS_##bit,            \
-                        CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ_TOG);    \
-               clk->parent = parent;                                   \
-       }                                                               \
-                                                                       \
-       return 0;                                                       \
-}
-
-_CLK_SET_PARENT(cpu_clk, CPU)
-_CLK_SET_PARENT(emi_clk, EMI)
-_CLK_SET_PARENT(ssp_clk, SSP)
-_CLK_SET_PARENT(gpmi_clk, GPMI)
-_CLK_SET_PARENT(lcdif_clk, PIX)
-
-#define _CLK_SET_PARENT_STUB(name)                                     \
-static int name##_set_parent(struct clk *clk, struct clk *parent)      \
-{                                                                      \
-       if (parent != clk->parent)                                      \
-               return -EINVAL;                                         \
-       else                                                            \
-               return 0;                                               \
-}
-
-_CLK_SET_PARENT_STUB(uart_clk)
-_CLK_SET_PARENT_STUB(audio_clk)
-_CLK_SET_PARENT_STUB(pwm_clk)
-_CLK_SET_PARENT_STUB(clk32k_clk)
-
-/*
- * clk definition
- */
-static struct clk cpu_clk = {
-       .get_rate = cpu_clk_get_rate,
-       .set_rate = cpu_clk_set_rate,
-       .set_parent = cpu_clk_set_parent,
-       .parent = &ref_cpu_clk,
-};
-
-static struct clk hbus_clk = {
-       .get_rate = hbus_clk_get_rate,
-       .parent = &cpu_clk,
-};
-
-static struct clk xbus_clk = {
-       .get_rate = xbus_clk_get_rate,
-       .set_rate = xbus_clk_set_rate,
-       .parent = &ref_xtal_clk,
-};
-
-static struct clk rtc_clk = {
-       .get_rate = rtc_clk_get_rate,
-       .parent = &ref_xtal_clk,
-};
-
-/* usb_clk gate is controlled in DIGCTRL other than CLKCTRL */
-static struct clk usb_clk = {
-       .enable_reg = DIGCTRL_BASE_ADDR,
-       .enable_shift = 2,
-       .enable = _raw_clk_enable,
-       .disable = _raw_clk_disable,
-       .parent = &pll_clk,
-};
-
-#define _DEFINE_CLOCK(name, er, es, p)                                 \
-       static struct clk name = {                                      \
-               .enable_reg     = CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er,  \
-               .enable_shift   = BP_CLKCTRL_##er##_##es,               \
-               .get_rate       = name##_get_rate,                      \
-               .set_rate       = name##_set_rate,                      \
-               .set_parent     = name##_set_parent,                    \
-               .enable         = _raw_clk_enable,                      \
-               .disable        = _raw_clk_disable,                     \
-               .parent         = p,                                    \
-       }
-
-_DEFINE_CLOCK(emi_clk, EMI, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(ssp_clk, SSP, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(gpmi_clk, GPMI, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(lcdif_clk, PIX, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(uart_clk, XTAL, UART_CLK_GATE, &ref_xtal_clk);
-_DEFINE_CLOCK(audio_clk, XTAL, FILT_CLK24M_GATE, &ref_xtal_clk);
-_DEFINE_CLOCK(pwm_clk, XTAL, PWM_CLK24M_GATE, &ref_xtal_clk);
-_DEFINE_CLOCK(clk32k_clk, XTAL, TIMROT_CLK32K_GATE, &ref_xtal_clk);
-
-#define _REGISTER_CLOCK(d, n, c) \
-       { \
-               .dev_id = d, \
-               .con_id = n, \
-               .clk = &c, \
-       },
-
-static struct clk_lookup lookups[] = {
-       /* for amba bus driver */
-       _REGISTER_CLOCK("duart", "apb_pclk", xbus_clk)
-       /* for amba-pl011 driver */
-       _REGISTER_CLOCK("duart", NULL, uart_clk)
-       _REGISTER_CLOCK("mxs-auart.0", NULL, uart_clk)
-       _REGISTER_CLOCK("rtc", NULL, rtc_clk)
-       _REGISTER_CLOCK("mxs-dma-apbh", NULL, hbus_clk)
-       _REGISTER_CLOCK("mxs-dma-apbx", NULL, xbus_clk)
-       _REGISTER_CLOCK("mxs-mmc.0", NULL, ssp_clk)
-       _REGISTER_CLOCK("mxs-mmc.1", NULL, ssp_clk)
-       _REGISTER_CLOCK(NULL, "usb", usb_clk)
-       _REGISTER_CLOCK(NULL, "audio", audio_clk)
-       _REGISTER_CLOCK("mxs-pwm.0", NULL, pwm_clk)
-       _REGISTER_CLOCK("mxs-pwm.1", NULL, pwm_clk)
-       _REGISTER_CLOCK("mxs-pwm.2", NULL, pwm_clk)
-       _REGISTER_CLOCK("mxs-pwm.3", NULL, pwm_clk)
-       _REGISTER_CLOCK("mxs-pwm.4", NULL, pwm_clk)
-       _REGISTER_CLOCK("imx23-fb", NULL, lcdif_clk)
-       _REGISTER_CLOCK("imx23-gpmi-nand", NULL, gpmi_clk)
-};
-
-static int clk_misc_init(void)
-{
-       u32 reg;
-       int ret;
-
-       /* Fix up parent per register setting */
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ);
-       cpu_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_CPU) ?
-                       &ref_xtal_clk : &ref_cpu_clk;
-       emi_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_EMI) ?
-                       &ref_xtal_clk : &ref_emi_clk;
-       ssp_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP) ?
-                       &ref_xtal_clk : &ref_io_clk;
-       gpmi_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_GPMI) ?
-                       &ref_xtal_clk : &ref_io_clk;
-       lcdif_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_PIX) ?
-                       &ref_xtal_clk : &ref_pix_clk;
-
-       /* Use int div over frac when both are available */
-       __raw_writel(BM_CLKCTRL_CPU_DIV_XTAL_FRAC_EN,
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_CLR);
-       __raw_writel(BM_CLKCTRL_CPU_DIV_CPU_FRAC_EN,
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_CLR);
-       __raw_writel(BM_CLKCTRL_HBUS_DIV_FRAC_EN,
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS_CLR);
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_XBUS);
-       reg &= ~BM_CLKCTRL_XBUS_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_XBUS);
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP);
-       reg &= ~BM_CLKCTRL_SSP_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP);
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_GPMI);
-       reg &= ~BM_CLKCTRL_GPMI_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_GPMI);
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_PIX);
-       reg &= ~BM_CLKCTRL_PIX_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_PIX);
-
-       /*
-        * Set safe hbus clock divider. A divider of 3 ensure that
-        * the Vddd voltage required for the cpu clock is sufficiently
-        * high for the hbus clock.
-        */
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS);
-       reg &= BM_CLKCTRL_HBUS_DIV;
-       reg |= 3 << BP_CLKCTRL_HBUS_DIV;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS);
-
-       ret = mxs_clkctrl_timeout(HW_CLKCTRL_HBUS, BM_CLKCTRL_HBUS_BUSY);
-
-       /* Gate off cpu clock in WFI for power saving */
-       __raw_writel(BM_CLKCTRL_CPU_INTERRUPT_WAIT,
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_SET);
-
-       /*
-        * 480 MHz seems too high to be ssp clock source directly,
-        * so set frac to get a 288 MHz ref_io.
-        */
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC);
-       reg &= ~BM_CLKCTRL_FRAC_IOFRAC;
-       reg |= 30 << BP_CLKCTRL_FRAC_IOFRAC;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC);
-
-       return ret;
-}
-
-int __init mx23_clocks_init(void)
-{
-       clk_misc_init();
-
-       /*
-        * source ssp clock from ref_io than ref_xtal,
-        * as ref_xtal only provides 24 MHz as maximum.
-        */
-       clk_set_parent(&ssp_clk, &ref_io_clk);
-
-       clk_prepare_enable(&cpu_clk);
-       clk_prepare_enable(&hbus_clk);
-       clk_prepare_enable(&xbus_clk);
-       clk_prepare_enable(&emi_clk);
-       clk_prepare_enable(&uart_clk);
-
-       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
-       mxs_timer_init(&clk32k_clk, MX23_INT_TIMER0);
-
-       return 0;
-}
diff --git a/arch/arm/mach-mxs/clock-mx28.c b/arch/arm/mach-mxs/clock-mx28.c
deleted file mode 100644 (file)
index cea29c9..0000000
+++ /dev/null
@@ -1,803 +0,0 @@
-/*
- * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <linux/mm.h>
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/jiffies.h>
-#include <linux/clkdev.h>
-#include <linux/spinlock.h>
-
-#include <asm/clkdev.h>
-#include <asm/div64.h>
-
-#include <mach/mx28.h>
-#include <mach/common.h>
-#include <mach/clock.h>
-#include <mach/digctl.h>
-
-#include "regs-clkctrl-mx28.h"
-
-#define CLKCTRL_BASE_ADDR      MX28_IO_ADDRESS(MX28_CLKCTRL_BASE_ADDR)
-#define DIGCTRL_BASE_ADDR      MX28_IO_ADDRESS(MX28_DIGCTL_BASE_ADDR)
-
-#define PARENT_RATE_SHIFT      8
-
-static struct clk pll2_clk;
-static struct clk cpu_clk;
-static struct clk emi_clk;
-static struct clk saif0_clk;
-static struct clk saif1_clk;
-static struct clk clk32k_clk;
-static DEFINE_SPINLOCK(clkmux_lock);
-
-/*
- * HW_SAIF_CLKMUX_SEL:
- *  DIRECT(0x0): SAIF0 clock pins selected for SAIF0 input clocks, and SAIF1
- *             clock pins selected for SAIF1 input clocks.
- *  CROSSINPUT(0x1): SAIF1 clock inputs selected for SAIF0 input clocks, and
- *             SAIF0 clock inputs selected for SAIF1 input clocks.
- *  EXTMSTR0(0x2): SAIF0 clock pin selected for both SAIF0 and SAIF1 input
- *             clocks.
- *  EXTMSTR1(0x3): SAIF1 clock pin selected for both SAIF0 and SAIF1 input
- *             clocks.
- */
-int mxs_saif_clkmux_select(unsigned int clkmux)
-{
-       if (clkmux > 0x3)
-               return -EINVAL;
-
-       spin_lock(&clkmux_lock);
-       __raw_writel(BM_DIGCTL_CTRL_SAIF_CLKMUX,
-                       DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL + MXS_CLR_ADDR);
-       __raw_writel(clkmux << BP_DIGCTL_CTRL_SAIF_CLKMUX,
-                       DIGCTRL_BASE_ADDR + HW_DIGCTL_CTRL + MXS_SET_ADDR);
-       spin_unlock(&clkmux_lock);
-
-       return 0;
-}
-
-static int _raw_clk_enable(struct clk *clk)
-{
-       u32 reg;
-
-       if (clk->enable_reg) {
-               reg = __raw_readl(clk->enable_reg);
-               reg &= ~(1 << clk->enable_shift);
-               __raw_writel(reg, clk->enable_reg);
-       }
-
-       return 0;
-}
-
-static void _raw_clk_disable(struct clk *clk)
-{
-       u32 reg;
-
-       if (clk->enable_reg) {
-               reg = __raw_readl(clk->enable_reg);
-               reg |= 1 << clk->enable_shift;
-               __raw_writel(reg, clk->enable_reg);
-       }
-}
-
-/*
- * ref_xtal_clk
- */
-static unsigned long ref_xtal_clk_get_rate(struct clk *clk)
-{
-       return 24000000;
-}
-
-static struct clk ref_xtal_clk = {
-       .get_rate = ref_xtal_clk_get_rate,
-};
-
-/*
- * pll_clk
- */
-static unsigned long pll0_clk_get_rate(struct clk *clk)
-{
-       return 480000000;
-}
-
-static unsigned long pll1_clk_get_rate(struct clk *clk)
-{
-       return 480000000;
-}
-
-static unsigned long pll2_clk_get_rate(struct clk *clk)
-{
-       return 50000000;
-}
-
-#define _CLK_ENABLE_PLL(name, r, g)                                    \
-static int name##_enable(struct clk *clk)                              \
-{                                                                      \
-       __raw_writel(BM_CLKCTRL_##r##CTRL0_POWER,                       \
-                    CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_SET);    \
-       udelay(10);                                                     \
-                                                                       \
-       if (clk == &pll2_clk)                                           \
-               __raw_writel(BM_CLKCTRL_##r##CTRL0_##g,                 \
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_CLR); \
-       else                                                            \
-               __raw_writel(BM_CLKCTRL_##r##CTRL0_##g,                 \
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_SET); \
-                                                                       \
-       return 0;                                                       \
-}
-
-_CLK_ENABLE_PLL(pll0_clk, PLL0, EN_USB_CLKS)
-_CLK_ENABLE_PLL(pll1_clk, PLL1, EN_USB_CLKS)
-_CLK_ENABLE_PLL(pll2_clk, PLL2, CLKGATE)
-
-#define _CLK_DISABLE_PLL(name, r, g)                                   \
-static void name##_disable(struct clk *clk)                            \
-{                                                                      \
-       __raw_writel(BM_CLKCTRL_##r##CTRL0_POWER,                       \
-                    CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_CLR);    \
-                                                                       \
-       if (clk == &pll2_clk)                                           \
-               __raw_writel(BM_CLKCTRL_##r##CTRL0_##g,                 \
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_SET); \
-       else                                                            \
-               __raw_writel(BM_CLKCTRL_##r##CTRL0_##g,                 \
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_CLR); \
-                                                                       \
-}
-
-_CLK_DISABLE_PLL(pll0_clk, PLL0, EN_USB_CLKS)
-_CLK_DISABLE_PLL(pll1_clk, PLL1, EN_USB_CLKS)
-_CLK_DISABLE_PLL(pll2_clk, PLL2, CLKGATE)
-
-#define _DEFINE_CLOCK_PLL(name)                                                \
-       static struct clk name = {                                      \
-               .get_rate       = name##_get_rate,                      \
-               .enable         = name##_enable,                        \
-               .disable        = name##_disable,                       \
-               .parent         = &ref_xtal_clk,                        \
-       }
-
-_DEFINE_CLOCK_PLL(pll0_clk);
-_DEFINE_CLOCK_PLL(pll1_clk);
-_DEFINE_CLOCK_PLL(pll2_clk);
-
-/*
- * ref_clk
- */
-#define _CLK_GET_RATE_REF(name, sr, ss)                                        \
-static unsigned long name##_get_rate(struct clk *clk)                  \
-{                                                                      \
-       unsigned long parent_rate;                                      \
-       u32 reg, div;                                                   \
-                                                                       \
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##sr);         \
-       div = (reg >> BP_CLKCTRL_##sr##_##ss##FRAC) & 0x3f;             \
-       parent_rate = clk_get_rate(clk->parent);                        \
-                                                                       \
-       return SH_DIV((parent_rate >> PARENT_RATE_SHIFT) * 18,          \
-                       div, PARENT_RATE_SHIFT);                        \
-}
-
-_CLK_GET_RATE_REF(ref_cpu_clk, FRAC0, CPU)
-_CLK_GET_RATE_REF(ref_emi_clk, FRAC0, EMI)
-_CLK_GET_RATE_REF(ref_io0_clk, FRAC0, IO0)
-_CLK_GET_RATE_REF(ref_io1_clk, FRAC0, IO1)
-_CLK_GET_RATE_REF(ref_pix_clk, FRAC1, PIX)
-_CLK_GET_RATE_REF(ref_gpmi_clk, FRAC1, GPMI)
-
-#define _DEFINE_CLOCK_REF(name, er, es)                                        \
-       static struct clk name = {                                      \
-               .enable_reg     = CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er,  \
-               .enable_shift   = BP_CLKCTRL_##er##_CLKGATE##es,        \
-               .get_rate       = name##_get_rate,                      \
-               .enable         = _raw_clk_enable,                      \
-               .disable        = _raw_clk_disable,                     \
-               .parent         = &pll0_clk,                            \
-       }
-
-_DEFINE_CLOCK_REF(ref_cpu_clk, FRAC0, CPU);
-_DEFINE_CLOCK_REF(ref_emi_clk, FRAC0, EMI);
-_DEFINE_CLOCK_REF(ref_io0_clk, FRAC0, IO0);
-_DEFINE_CLOCK_REF(ref_io1_clk, FRAC0, IO1);
-_DEFINE_CLOCK_REF(ref_pix_clk, FRAC1, PIX);
-_DEFINE_CLOCK_REF(ref_gpmi_clk, FRAC1, GPMI);
-
-/*
- * General clocks
- *
- * clk_get_rate
- */
-static unsigned long lradc_clk_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / 16;
-}
-
-static unsigned long rtc_clk_get_rate(struct clk *clk)
-{
-       /* ref_xtal_clk is implemented as the only parent */
-       return clk_get_rate(clk->parent) / 768;
-}
-
-static unsigned long clk32k_clk_get_rate(struct clk *clk)
-{
-       return clk->parent->get_rate(clk->parent) / 750;
-}
-
-static unsigned long spdif_clk_get_rate(struct clk *clk)
-{
-       return clk_get_rate(clk->parent) / 4;
-}
-
-#define _CLK_GET_RATE(name, rs)                                                \
-static unsigned long name##_get_rate(struct clk *clk)                  \
-{                                                                      \
-       u32 reg, div;                                                   \
-                                                                       \
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs);         \
-                                                                       \
-       if (clk->parent == &ref_xtal_clk)                               \
-               div = (reg & BM_CLKCTRL_##rs##_DIV_XTAL) >>             \
-                       BP_CLKCTRL_##rs##_DIV_XTAL;                     \
-       else                                                            \
-               div = (reg & BM_CLKCTRL_##rs##_DIV_##rs) >>             \
-                       BP_CLKCTRL_##rs##_DIV_##rs;                     \
-                                                                       \
-       if (!div)                                                       \
-               return -EINVAL;                                         \
-                                                                       \
-       return clk_get_rate(clk->parent) / div;                         \
-}
-
-_CLK_GET_RATE(cpu_clk, CPU)
-_CLK_GET_RATE(emi_clk, EMI)
-
-#define _CLK_GET_RATE1(name, rs)                                       \
-static unsigned long name##_get_rate(struct clk *clk)                  \
-{                                                                      \
-       u32 reg, div;                                                   \
-                                                                       \
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs);         \
-       div = (reg & BM_CLKCTRL_##rs##_DIV) >> BP_CLKCTRL_##rs##_DIV;   \
-                                                                       \
-       if (!div)                                                       \
-               return -EINVAL;                                         \
-                                                                       \
-       if (clk == &saif0_clk || clk == &saif1_clk)                     \
-               return clk_get_rate(clk->parent) >> 16 * div;           \
-       else                                                            \
-               return clk_get_rate(clk->parent) / div;                 \
-}
-
-_CLK_GET_RATE1(hbus_clk, HBUS)
-_CLK_GET_RATE1(xbus_clk, XBUS)
-_CLK_GET_RATE1(ssp0_clk, SSP0)
-_CLK_GET_RATE1(ssp1_clk, SSP1)
-_CLK_GET_RATE1(ssp2_clk, SSP2)
-_CLK_GET_RATE1(ssp3_clk, SSP3)
-_CLK_GET_RATE1(gpmi_clk, GPMI)
-_CLK_GET_RATE1(lcdif_clk, DIS_LCDIF)
-_CLK_GET_RATE1(saif0_clk, SAIF0)
-_CLK_GET_RATE1(saif1_clk, SAIF1)
-
-#define _CLK_GET_RATE_STUB(name)                                       \
-static unsigned long name##_get_rate(struct clk *clk)                  \
-{                                                                      \
-       return clk_get_rate(clk->parent);                               \
-}
-
-_CLK_GET_RATE_STUB(uart_clk)
-_CLK_GET_RATE_STUB(pwm_clk)
-_CLK_GET_RATE_STUB(can0_clk)
-_CLK_GET_RATE_STUB(can1_clk)
-_CLK_GET_RATE_STUB(fec_clk)
-
-/*
- * clk_set_rate
- */
-/* fool compiler */
-#define BM_CLKCTRL_CPU_DIV     0
-#define BP_CLKCTRL_CPU_DIV     0
-#define BM_CLKCTRL_CPU_BUSY    0
-
-#define _CLK_SET_RATE(name, dr, fr, fs)                                        \
-static int name##_set_rate(struct clk *clk, unsigned long rate)                \
-{                                                                      \
-       u32 reg, bm_busy, div_max, d, f, div, frac;                     \
-       unsigned long diff, parent_rate, calc_rate;                     \
-                                                                       \
-       div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV;       \
-       bm_busy = BM_CLKCTRL_##dr##_BUSY;                               \
-                                                                       \
-       if (clk->parent == &ref_xtal_clk) {                             \
-               parent_rate = clk_get_rate(clk->parent);                \
-               div = DIV_ROUND_UP(parent_rate, rate);                  \
-               if (clk == &cpu_clk) {                                  \
-                       div_max = BM_CLKCTRL_CPU_DIV_XTAL >>            \
-                               BP_CLKCTRL_CPU_DIV_XTAL;                \
-                       bm_busy = BM_CLKCTRL_CPU_BUSY_REF_XTAL;         \
-               }                                                       \
-               if (div == 0 || div > div_max)                          \
-                       return -EINVAL;                                 \
-       } else {                                                        \
-               /*                                                      \
-                * hack alert: this block modifies clk->parent, too,    \
-                * so the base to use it the grand parent.              \
-                */                                                     \
-               parent_rate = clk_get_rate(clk->parent->parent);        \
-               rate >>= PARENT_RATE_SHIFT;                             \
-               parent_rate >>= PARENT_RATE_SHIFT;                      \
-               diff = parent_rate;                                     \
-               div = frac = 1;                                         \
-               if (clk == &cpu_clk) {                                  \
-                       div_max = BM_CLKCTRL_CPU_DIV_CPU >>             \
-                               BP_CLKCTRL_CPU_DIV_CPU;                 \
-                       bm_busy = BM_CLKCTRL_CPU_BUSY_REF_CPU;          \
-               }                                                       \
-               for (d = 1; d <= div_max; d++) {                        \
-                       f = parent_rate * 18 / d / rate;                \
-                       if ((parent_rate * 18 / d) % rate)              \
-                               f++;                                    \
-                       if (f < 18 || f > 35)                           \
-                               continue;                               \
-                                                                       \
-                       calc_rate = parent_rate * 18 / f / d;           \
-                       if (calc_rate > rate)                           \
-                               continue;                               \
-                                                                       \
-                       if (rate - calc_rate < diff) {                  \
-                               frac = f;                               \
-                               div = d;                                \
-                               diff = rate - calc_rate;                \
-                       }                                               \
-                                                                       \
-                       if (diff == 0)                                  \
-                               break;                                  \
-               }                                                       \
-                                                                       \
-               if (diff == parent_rate)                                \
-                       return -EINVAL;                                 \
-                                                                       \
-               reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##fr); \
-               reg &= ~BM_CLKCTRL_##fr##_##fs##FRAC;                   \
-               reg |= frac << BP_CLKCTRL_##fr##_##fs##FRAC;            \
-               __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##fr); \
-       }                                                               \
-                                                                       \
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr);         \
-       if (clk == &cpu_clk) {                                          \
-               reg &= ~BM_CLKCTRL_CPU_DIV_CPU;                         \
-               reg |= div << BP_CLKCTRL_CPU_DIV_CPU;                   \
-       } else {                                                        \
-               reg &= ~BM_CLKCTRL_##dr##_DIV;                          \
-               reg |= div << BP_CLKCTRL_##dr##_DIV;                    \
-               if (reg & (1 << clk->enable_shift)) {                   \
-                       pr_err("%s: clock is gated\n", __func__);       \
-                       return -EINVAL;                                 \
-               }                                                       \
-       }                                                               \
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr);         \
-                                                                       \
-       return mxs_clkctrl_timeout(HW_CLKCTRL_##dr, bm_busy);           \
-}
-
-_CLK_SET_RATE(cpu_clk, CPU, FRAC0, CPU)
-_CLK_SET_RATE(ssp0_clk, SSP0, FRAC0, IO0)
-_CLK_SET_RATE(ssp1_clk, SSP1, FRAC0, IO0)
-_CLK_SET_RATE(ssp2_clk, SSP2, FRAC0, IO1)
-_CLK_SET_RATE(ssp3_clk, SSP3, FRAC0, IO1)
-_CLK_SET_RATE(lcdif_clk, DIS_LCDIF, FRAC1, PIX)
-_CLK_SET_RATE(gpmi_clk, GPMI, FRAC1, GPMI)
-
-#define _CLK_SET_RATE1(name, dr)                                       \
-static int name##_set_rate(struct clk *clk, unsigned long rate)                \
-{                                                                      \
-       u32 reg, div_max, div;                                          \
-       unsigned long parent_rate;                                      \
-                                                                       \
-       parent_rate = clk_get_rate(clk->parent);                        \
-       div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV;       \
-                                                                       \
-       div = DIV_ROUND_UP(parent_rate, rate);                          \
-       if (div == 0 || div > div_max)                                  \
-               return -EINVAL;                                         \
-                                                                       \
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr);         \
-       reg &= ~BM_CLKCTRL_##dr##_DIV;                                  \
-       reg |= div << BP_CLKCTRL_##dr##_DIV;                            \
-       if (reg & (1 << clk->enable_shift)) {                           \
-               pr_err("%s: clock is gated\n", __func__);               \
-               return -EINVAL;                                         \
-       }                                                               \
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr);         \
-                                                                       \
-       return mxs_clkctrl_timeout(HW_CLKCTRL_##dr, BM_CLKCTRL_##dr##_BUSY);\
-}
-
-_CLK_SET_RATE1(xbus_clk, XBUS)
-
-/* saif clock uses 16 bits frac div */
-#define _CLK_SET_RATE_SAIF(name, rs)                                   \
-static int name##_set_rate(struct clk *clk, unsigned long rate)                \
-{                                                                      \
-       u16 div;                                                        \
-       u32 reg;                                                        \
-       u64 lrate;                                                      \
-       unsigned long parent_rate;                                      \
-                                                                       \
-       parent_rate = clk_get_rate(clk->parent);                        \
-       if (rate > parent_rate)                                         \
-               return -EINVAL;                                         \
-                                                                       \
-       lrate = (u64)rate << 16;                                        \
-       do_div(lrate, parent_rate);                                     \
-       div = (u16)lrate;                                               \
-                                                                       \
-       if (!div)                                                       \
-               return -EINVAL;                                         \
-                                                                       \
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs);         \
-       reg &= ~BM_CLKCTRL_##rs##_DIV;                                  \
-       reg |= div << BP_CLKCTRL_##rs##_DIV;                            \
-       if (reg & (1 << clk->enable_shift)) {                           \
-               pr_err("%s: clock is gated\n", __func__);               \
-               return -EINVAL;                                         \
-       }                                                               \
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs);         \
-                                                                       \
-       return mxs_clkctrl_timeout(HW_CLKCTRL_##rs, BM_CLKCTRL_##rs##_BUSY);\
-}
-
-_CLK_SET_RATE_SAIF(saif0_clk, SAIF0)
-_CLK_SET_RATE_SAIF(saif1_clk, SAIF1)
-
-#define _CLK_SET_RATE_STUB(name)                                       \
-static int name##_set_rate(struct clk *clk, unsigned long rate)                \
-{                                                                      \
-       return -EINVAL;                                                 \
-}
-
-_CLK_SET_RATE_STUB(emi_clk)
-_CLK_SET_RATE_STUB(uart_clk)
-_CLK_SET_RATE_STUB(pwm_clk)
-_CLK_SET_RATE_STUB(spdif_clk)
-_CLK_SET_RATE_STUB(clk32k_clk)
-_CLK_SET_RATE_STUB(can0_clk)
-_CLK_SET_RATE_STUB(can1_clk)
-_CLK_SET_RATE_STUB(fec_clk)
-
-/*
- * clk_set_parent
- */
-#define _CLK_SET_PARENT(name, bit)                                     \
-static int name##_set_parent(struct clk *clk, struct clk *parent)      \
-{                                                                      \
-       if (parent != clk->parent) {                                    \
-               __raw_writel(BM_CLKCTRL_CLKSEQ_BYPASS_##bit,            \
-                        CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ_TOG);    \
-               clk->parent = parent;                                   \
-       }                                                               \
-                                                                       \
-       return 0;                                                       \
-}
-
-_CLK_SET_PARENT(cpu_clk, CPU)
-_CLK_SET_PARENT(emi_clk, EMI)
-_CLK_SET_PARENT(ssp0_clk, SSP0)
-_CLK_SET_PARENT(ssp1_clk, SSP1)
-_CLK_SET_PARENT(ssp2_clk, SSP2)
-_CLK_SET_PARENT(ssp3_clk, SSP3)
-_CLK_SET_PARENT(lcdif_clk, DIS_LCDIF)
-_CLK_SET_PARENT(gpmi_clk, GPMI)
-_CLK_SET_PARENT(saif0_clk, SAIF0)
-_CLK_SET_PARENT(saif1_clk, SAIF1)
-
-#define _CLK_SET_PARENT_STUB(name)                                     \
-static int name##_set_parent(struct clk *clk, struct clk *parent)      \
-{                                                                      \
-       if (parent != clk->parent)                                      \
-               return -EINVAL;                                         \
-       else                                                            \
-               return 0;                                               \
-}
-
-_CLK_SET_PARENT_STUB(pwm_clk)
-_CLK_SET_PARENT_STUB(uart_clk)
-_CLK_SET_PARENT_STUB(clk32k_clk)
-_CLK_SET_PARENT_STUB(spdif_clk)
-_CLK_SET_PARENT_STUB(fec_clk)
-_CLK_SET_PARENT_STUB(can0_clk)
-_CLK_SET_PARENT_STUB(can1_clk)
-
-/*
- * clk definition
- */
-static struct clk cpu_clk = {
-       .get_rate = cpu_clk_get_rate,
-       .set_rate = cpu_clk_set_rate,
-       .set_parent = cpu_clk_set_parent,
-       .parent = &ref_cpu_clk,
-};
-
-static struct clk hbus_clk = {
-       .get_rate = hbus_clk_get_rate,
-       .parent = &cpu_clk,
-};
-
-static struct clk xbus_clk = {
-       .get_rate = xbus_clk_get_rate,
-       .set_rate = xbus_clk_set_rate,
-       .parent = &ref_xtal_clk,
-};
-
-static struct clk lradc_clk = {
-       .get_rate = lradc_clk_get_rate,
-       .parent = &clk32k_clk,
-};
-
-static struct clk rtc_clk = {
-       .get_rate = rtc_clk_get_rate,
-       .parent = &ref_xtal_clk,
-};
-
-/* usb_clk gate is controlled in DIGCTRL other than CLKCTRL */
-static struct clk usb0_clk = {
-       .enable_reg = DIGCTRL_BASE_ADDR,
-       .enable_shift = 2,
-       .enable = _raw_clk_enable,
-       .disable = _raw_clk_disable,
-       .parent = &pll0_clk,
-};
-
-static struct clk usb1_clk = {
-       .enable_reg = DIGCTRL_BASE_ADDR,
-       .enable_shift = 16,
-       .enable = _raw_clk_enable,
-       .disable = _raw_clk_disable,
-       .parent = &pll1_clk,
-};
-
-#define _DEFINE_CLOCK(name, er, es, p)                                 \
-       static struct clk name = {                                      \
-               .enable_reg     = CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er,  \
-               .enable_shift   = BP_CLKCTRL_##er##_##es,               \
-               .get_rate       = name##_get_rate,                      \
-               .set_rate       = name##_set_rate,                      \
-               .set_parent     = name##_set_parent,                    \
-               .enable         = _raw_clk_enable,                      \
-               .disable        = _raw_clk_disable,                     \
-               .parent         = p,                                    \
-       }
-
-_DEFINE_CLOCK(emi_clk, EMI, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(ssp0_clk, SSP0, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(ssp1_clk, SSP1, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(ssp2_clk, SSP2, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(ssp3_clk, SSP3, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(lcdif_clk, DIS_LCDIF, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(gpmi_clk, GPMI, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(saif0_clk, SAIF0, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(saif1_clk, SAIF1, CLKGATE, &ref_xtal_clk);
-_DEFINE_CLOCK(can0_clk, FLEXCAN, STOP_CAN0, &ref_xtal_clk);
-_DEFINE_CLOCK(can1_clk, FLEXCAN, STOP_CAN1, &ref_xtal_clk);
-_DEFINE_CLOCK(pwm_clk, XTAL, PWM_CLK24M_GATE, &ref_xtal_clk);
-_DEFINE_CLOCK(uart_clk, XTAL, UART_CLK_GATE, &ref_xtal_clk);
-_DEFINE_CLOCK(clk32k_clk, XTAL, TIMROT_CLK32K_GATE, &ref_xtal_clk);
-_DEFINE_CLOCK(spdif_clk, SPDIF, CLKGATE, &pll0_clk);
-_DEFINE_CLOCK(fec_clk, ENET, DISABLE, &hbus_clk);
-
-#define _REGISTER_CLOCK(d, n, c) \
-       { \
-               .dev_id = d, \
-               .con_id = n, \
-               .clk = &c, \
-       },
-
-static struct clk_lookup lookups[] = {
-       /* for amba bus driver */
-       _REGISTER_CLOCK("duart", "apb_pclk", xbus_clk)
-       /* for amba-pl011 driver */
-       _REGISTER_CLOCK("duart", NULL, uart_clk)
-       _REGISTER_CLOCK("imx28-fec.0", NULL, fec_clk)
-       _REGISTER_CLOCK("imx28-fec.1", NULL, fec_clk)
-       _REGISTER_CLOCK("imx28-gpmi-nand", NULL, gpmi_clk)
-       _REGISTER_CLOCK("mxs-auart.0", NULL, uart_clk)
-       _REGISTER_CLOCK("mxs-auart.1", NULL, uart_clk)
-       _REGISTER_CLOCK("mxs-auart.2", NULL, uart_clk)
-       _REGISTER_CLOCK("mxs-auart.3", NULL, uart_clk)
-       _REGISTER_CLOCK("mxs-auart.4", NULL, uart_clk)
-       _REGISTER_CLOCK("rtc", NULL, rtc_clk)
-       _REGISTER_CLOCK("pll2", NULL, pll2_clk)
-       _REGISTER_CLOCK("mxs-dma-apbh", NULL, hbus_clk)
-       _REGISTER_CLOCK("mxs-dma-apbx", NULL, xbus_clk)
-       _REGISTER_CLOCK("mxs-mmc.0", NULL, ssp0_clk)
-       _REGISTER_CLOCK("mxs-mmc.1", NULL, ssp1_clk)
-       _REGISTER_CLOCK("mxs-mmc.2", NULL, ssp2_clk)
-       _REGISTER_CLOCK("mxs-mmc.3", NULL, ssp3_clk)
-       _REGISTER_CLOCK("flexcan.0", NULL, can0_clk)
-       _REGISTER_CLOCK("flexcan.1", NULL, can1_clk)
-       _REGISTER_CLOCK(NULL, "usb0", usb0_clk)
-       _REGISTER_CLOCK(NULL, "usb1", usb1_clk)
-       _REGISTER_CLOCK("mxs-pwm.0", NULL, pwm_clk)
-       _REGISTER_CLOCK("mxs-pwm.1", NULL, pwm_clk)
-       _REGISTER_CLOCK("mxs-pwm.2", NULL, pwm_clk)
-       _REGISTER_CLOCK("mxs-pwm.3", NULL, pwm_clk)
-       _REGISTER_CLOCK("mxs-pwm.4", NULL, pwm_clk)
-       _REGISTER_CLOCK("mxs-pwm.5", NULL, pwm_clk)
-       _REGISTER_CLOCK("mxs-pwm.6", NULL, pwm_clk)
-       _REGISTER_CLOCK("mxs-pwm.7", NULL, pwm_clk)
-       _REGISTER_CLOCK(NULL, "lradc", lradc_clk)
-       _REGISTER_CLOCK(NULL, "spdif", spdif_clk)
-       _REGISTER_CLOCK("imx28-fb", NULL, lcdif_clk)
-       _REGISTER_CLOCK("mxs-saif.0", NULL, saif0_clk)
-       _REGISTER_CLOCK("mxs-saif.1", NULL, saif1_clk)
-};
-
-static int clk_misc_init(void)
-{
-       u32 reg;
-       int ret;
-
-       /* Fix up parent per register setting */
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ);
-       cpu_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_CPU) ?
-                       &ref_xtal_clk : &ref_cpu_clk;
-       emi_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_EMI) ?
-                       &ref_xtal_clk : &ref_emi_clk;
-       ssp0_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP0) ?
-                       &ref_xtal_clk : &ref_io0_clk;
-       ssp1_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP1) ?
-                       &ref_xtal_clk : &ref_io0_clk;
-       ssp2_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP2) ?
-                       &ref_xtal_clk : &ref_io1_clk;
-       ssp3_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP3) ?
-                       &ref_xtal_clk : &ref_io1_clk;
-       lcdif_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF) ?
-                       &ref_xtal_clk : &ref_pix_clk;
-       gpmi_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_GPMI) ?
-                       &ref_xtal_clk : &ref_gpmi_clk;
-       saif0_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SAIF0) ?
-                       &ref_xtal_clk : &pll0_clk;
-       saif1_clk.parent = (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SAIF1) ?
-                       &ref_xtal_clk : &pll0_clk;
-
-       /* Use int div over frac when both are available */
-       __raw_writel(BM_CLKCTRL_CPU_DIV_XTAL_FRAC_EN,
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_CLR);
-       __raw_writel(BM_CLKCTRL_CPU_DIV_CPU_FRAC_EN,
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_CLR);
-       __raw_writel(BM_CLKCTRL_HBUS_DIV_FRAC_EN,
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS_CLR);
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_XBUS);
-       reg &= ~BM_CLKCTRL_XBUS_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_XBUS);
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP0);
-       reg &= ~BM_CLKCTRL_SSP0_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP0);
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP1);
-       reg &= ~BM_CLKCTRL_SSP1_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP1);
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP2);
-       reg &= ~BM_CLKCTRL_SSP2_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP2);
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP3);
-       reg &= ~BM_CLKCTRL_SSP3_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SSP3);
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_GPMI);
-       reg &= ~BM_CLKCTRL_GPMI_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_GPMI);
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_DIS_LCDIF);
-       reg &= ~BM_CLKCTRL_DIS_LCDIF_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_DIS_LCDIF);
-
-       /* SAIF has to use frac div for functional operation */
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SAIF0);
-       reg |= BM_CLKCTRL_SAIF0_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SAIF0);
-
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_SAIF1);
-       reg |= BM_CLKCTRL_SAIF1_DIV_FRAC_EN;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_SAIF1);
-
-       /*
-        * Set safe hbus clock divider. A divider of 3 ensure that
-        * the Vddd voltage required for the cpu clock is sufficiently
-        * high for the hbus clock.
-        */
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS);
-       reg &= BM_CLKCTRL_HBUS_DIV;
-       reg |= 3 << BP_CLKCTRL_HBUS_DIV;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS);
-
-       ret = mxs_clkctrl_timeout(HW_CLKCTRL_HBUS, BM_CLKCTRL_HBUS_ASM_BUSY);
-
-       /* Gate off cpu clock in WFI for power saving */
-       __raw_writel(BM_CLKCTRL_CPU_INTERRUPT_WAIT,
-                       CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU_SET);
-
-       /*
-        * Extra fec clock setting
-        * The DENX M28 uses an external clock source
-        * and the clock output must not be enabled
-        */
-       if (!machine_is_m28evk()) {
-               reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_ENET);
-               reg &= ~BM_CLKCTRL_ENET_SLEEP;
-               reg |= BM_CLKCTRL_ENET_CLK_OUT_EN;
-               __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_ENET);
-       }
-
-       /*
-        * 480 MHz seems too high to be ssp clock source directly,
-        * so set frac0 to get a 288 MHz ref_io0.
-        */
-       reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC0);
-       reg &= ~BM_CLKCTRL_FRAC0_IO0FRAC;
-       reg |= 30 << BP_CLKCTRL_FRAC0_IO0FRAC;
-       __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC0);
-
-       return ret;
-}
-
-int __init mx28_clocks_init(void)
-{
-       clk_misc_init();
-
-       /*
-        * source ssp clock from ref_io0 than ref_xtal,
-        * as ref_xtal only provides 24 MHz as maximum.
-        */
-       clk_set_parent(&ssp0_clk, &ref_io0_clk);
-       clk_set_parent(&ssp1_clk, &ref_io0_clk);
-       clk_set_parent(&ssp2_clk, &ref_io1_clk);
-       clk_set_parent(&ssp3_clk, &ref_io1_clk);
-
-       clk_prepare_enable(&cpu_clk);
-       clk_prepare_enable(&hbus_clk);
-       clk_prepare_enable(&xbus_clk);
-       clk_prepare_enable(&emi_clk);
-       clk_prepare_enable(&uart_clk);
-
-       clk_set_parent(&lcdif_clk, &ref_pix_clk);
-       clk_set_parent(&saif0_clk, &pll0_clk);
-       clk_set_parent(&saif1_clk, &pll0_clk);
-
-       /*
-        * Set an initial clock rate for the saif internal logic to work
-        * properly. This is important when working in EXTMASTER mode that
-        * uses the other saif's BITCLK&LRCLK but it still needs a basic
-        * clock which should be fast enough for the internal logic.
-        */
-       clk_set_rate(&saif0_clk, 24000000);
-       clk_set_rate(&saif1_clk, 24000000);
-
-       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
-       mxs_timer_init(&clk32k_clk, MX28_INT_TIMER0);
-
-       return 0;
-}
diff --git a/arch/arm/mach-mxs/clock.c b/arch/arm/mach-mxs/clock.c
deleted file mode 100644 (file)
index 97a6f4a..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Based on arch/arm/plat-omap/clock.c
- *
- * Copyright (C) 2004 - 2005 Nokia corporation
- * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
- * Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com>
- * Copyright 2007 Freescale Semiconductor, Inc. All Rights Reserved.
- * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- */
-
-/* #define DEBUG */
-
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/io.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/platform_device.h>
-#include <linux/proc_fs.h>
-#include <linux/semaphore.h>
-#include <linux/string.h>
-
-#include <mach/clock.h>
-
-static LIST_HEAD(clocks);
-static DEFINE_MUTEX(clocks_mutex);
-
-/*-------------------------------------------------------------------------
- * Standard clock functions defined in include/linux/clk.h
- *-------------------------------------------------------------------------*/
-
-static void __clk_disable(struct clk *clk)
-{
-       if (clk == NULL || IS_ERR(clk))
-               return;
-       WARN_ON(!clk->usecount);
-
-       if (!(--clk->usecount)) {
-               if (clk->disable)
-                       clk->disable(clk);
-               __clk_disable(clk->parent);
-       }
-}
-
-static int __clk_enable(struct clk *clk)
-{
-       if (clk == NULL || IS_ERR(clk))
-               return -EINVAL;
-
-       if (clk->usecount++ == 0) {
-               __clk_enable(clk->parent);
-
-               if (clk->enable)
-                       clk->enable(clk);
-       }
-       return 0;
-}
-
-/*
- * The clk_enable/clk_disable could be called by drivers in atomic context,
- * so they should not really hold mutex.  Instead, clk_prepare/clk_unprepare
- * can hold a mutex, as the pair will only be called in non-atomic context.
- * Before migrating to common clk framework, we can have __clk_enable and
- * __clk_disable called in clk_prepare/clk_unprepare with mutex held and
- * leave clk_enable/clk_disable as the dummy functions.
- */
-int clk_prepare(struct clk *clk)
-{
-       int ret = 0;
-
-       if (clk == NULL || IS_ERR(clk))
-               return -EINVAL;
-
-       mutex_lock(&clocks_mutex);
-       ret = __clk_enable(clk);
-       mutex_unlock(&clocks_mutex);
-
-       return ret;
-}
-EXPORT_SYMBOL(clk_prepare);
-
-void clk_unprepare(struct clk *clk)
-{
-       if (clk == NULL || IS_ERR(clk))
-               return;
-
-       mutex_lock(&clocks_mutex);
-       __clk_disable(clk);
-       mutex_unlock(&clocks_mutex);
-}
-EXPORT_SYMBOL(clk_unprepare);
-
-int clk_enable(struct clk *clk)
-{
-       return 0;
-}
-EXPORT_SYMBOL(clk_enable);
-
-void clk_disable(struct clk *clk)
-{
-       /* nothing to do */
-}
-EXPORT_SYMBOL(clk_disable);
-
-/* Retrieve the *current* clock rate. If the clock itself
- * does not provide a special calculation routine, ask
- * its parent and so on, until one is able to return
- * a valid clock rate
- */
-unsigned long clk_get_rate(struct clk *clk)
-{
-       if (clk == NULL || IS_ERR(clk))
-               return 0UL;
-
-       if (clk->get_rate)
-               return clk->get_rate(clk);
-
-       return clk_get_rate(clk->parent);
-}
-EXPORT_SYMBOL(clk_get_rate);
-
-/* Round the requested clock rate to the nearest supported
- * rate that is less than or equal to the requested rate.
- * This is dependent on the clock's current parent.
- */
-long clk_round_rate(struct clk *clk, unsigned long rate)
-{
-       if (clk == NULL || IS_ERR(clk) || !clk->round_rate)
-               return 0;
-
-       return clk->round_rate(clk, rate);
-}
-EXPORT_SYMBOL(clk_round_rate);
-
-/* Set the clock to the requested clock rate. The rate must
- * match a supported rate exactly based on what clk_round_rate returns
- */
-int clk_set_rate(struct clk *clk, unsigned long rate)
-{
-       int ret = -EINVAL;
-
-       if (clk == NULL || IS_ERR(clk) || clk->set_rate == NULL || rate == 0)
-               return ret;
-
-       mutex_lock(&clocks_mutex);
-       ret = clk->set_rate(clk, rate);
-       mutex_unlock(&clocks_mutex);
-
-       return ret;
-}
-EXPORT_SYMBOL(clk_set_rate);
-
-/* Set the clock's parent to another clock source */
-int clk_set_parent(struct clk *clk, struct clk *parent)
-{
-       int ret = -EINVAL;
-       struct clk *old;
-
-       if (clk == NULL || IS_ERR(clk) || parent == NULL ||
-           IS_ERR(parent) || clk->set_parent == NULL)
-               return ret;
-
-       if (clk->usecount)
-               clk_prepare_enable(parent);
-
-       mutex_lock(&clocks_mutex);
-       ret = clk->set_parent(clk, parent);
-       if (ret == 0) {
-               old = clk->parent;
-               clk->parent = parent;
-       } else {
-               old = parent;
-       }
-       mutex_unlock(&clocks_mutex);
-
-       if (clk->usecount)
-               clk_disable(old);
-
-       return ret;
-}
-EXPORT_SYMBOL(clk_set_parent);
-
-/* Retrieve the clock's parent clock source */
-struct clk *clk_get_parent(struct clk *clk)
-{
-       struct clk *ret = NULL;
-
-       if (clk == NULL || IS_ERR(clk))
-               return ret;
-
-       return clk->parent;
-}
-EXPORT_SYMBOL(clk_get_parent);
diff --git a/arch/arm/mach-mxs/include/mach/clock.h b/arch/arm/mach-mxs/include/mach/clock.h
deleted file mode 100644 (file)
index 592c9ab..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
- * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- */
-
-#ifndef __MACH_MXS_CLOCK_H__
-#define __MACH_MXS_CLOCK_H__
-
-#ifndef __ASSEMBLY__
-#include <linux/list.h>
-
-struct module;
-
-struct clk {
-       int id;
-       /* Source clock this clk depends on */
-       struct clk *parent;
-       /* Reference count of clock enable/disable */
-       __s8 usecount;
-       /* Register bit position for clock's enable/disable control. */
-       u8 enable_shift;
-       /* Register address for clock's enable/disable control. */
-       void __iomem *enable_reg;
-       u32 flags;
-       /* get the current clock rate (always a fresh value) */
-       unsigned long (*get_rate) (struct clk *);
-       /* Function ptr to set the clock to a new rate. The rate must match a
-          supported rate returned from round_rate. Leave blank if clock is not
-          programmable */
-       int (*set_rate) (struct clk *, unsigned long);
-       /* Function ptr to round the requested clock rate to the nearest
-          supported rate that is less than or equal to the requested rate. */
-       unsigned long (*round_rate) (struct clk *, unsigned long);
-       /* Function ptr to enable the clock. Leave blank if clock can not
-          be gated. */
-       int (*enable) (struct clk *);
-       /* Function ptr to disable the clock. Leave blank if clock can not
-          be gated. */
-       void (*disable) (struct clk *);
-       /* Function ptr to set the parent clock of the clock. */
-       int (*set_parent) (struct clk *, struct clk *);
-};
-
-int clk_register(struct clk *clk);
-void clk_unregister(struct clk *clk);
-
-#endif /* __ASSEMBLY__ */
-#endif /* __MACH_MXS_CLOCK_H__ */
index c50c3ea28a9d843d3e84cab939a9371ed11c7221..9bdc953888711916a00943478da77f057026b35e 100644 (file)
 #ifndef __MACH_MXS_COMMON_H__
 #define __MACH_MXS_COMMON_H__
 
-struct clk;
-
 extern const u32 *mxs_get_ocotp(void);
 extern int mxs_reset_block(void __iomem *);
-extern void mxs_timer_init(struct clk *, int);
+extern void mxs_timer_init(int);
 extern void mxs_restart(char, const char *);
 extern int mxs_saif_clkmux_select(unsigned int clkmux);
 
@@ -31,6 +29,4 @@ extern void mx28_init_irq(void);
 
 extern void icoll_init_irq(void);
 
-extern int mxs_clkctrl_timeout(unsigned int reg_offset, unsigned int mask);
-
 #endif /* __MACH_MXS_COMMON_H__ */
index e386c142f93c3f48286b5266e48fd56af788b63b..95969407413d86c529f631002a7b179e03dacdb6 100644 (file)
@@ -226,7 +226,7 @@ static void __init mx28evk_fec_reset(void)
        struct clk *clk;
 
        /* Enable fec phy clock */
-       clk = clk_get_sys("pll2", NULL);
+       clk = clk_get_sys("enet_out", NULL);
        if (!IS_ERR(clk))
                clk_prepare_enable(clk);
 
diff --git a/arch/arm/mach-mxs/regs-clkctrl-mx23.h b/arch/arm/mach-mxs/regs-clkctrl-mx23.h
deleted file mode 100644 (file)
index 0ea5c9d..0000000
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Freescale CLKCTRL Register Definitions
- *
- * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
- * Copyright 2008-2010 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- *
- * This file is created by xml file. Don't Edit it.
- *
- * Xml Revision: 1.48
- * Template revision: 26195
- */
-
-#ifndef __REGS_CLKCTRL_MX23_H__
-#define __REGS_CLKCTRL_MX23_H__
-
-
-#define HW_CLKCTRL_PLLCTRL0    (0x00000000)
-#define HW_CLKCTRL_PLLCTRL0_SET        (0x00000004)
-#define HW_CLKCTRL_PLLCTRL0_CLR        (0x00000008)
-#define HW_CLKCTRL_PLLCTRL0_TOG        (0x0000000c)
-
-#define BP_CLKCTRL_PLLCTRL0_LFR_SEL    28
-#define BM_CLKCTRL_PLLCTRL0_LFR_SEL    0x30000000
-#define BF_CLKCTRL_PLLCTRL0_LFR_SEL(v)  \
-               (((v) << 28) & BM_CLKCTRL_PLLCTRL0_LFR_SEL)
-#define BV_CLKCTRL_PLLCTRL0_LFR_SEL__DEFAULT   0x0
-#define BV_CLKCTRL_PLLCTRL0_LFR_SEL__TIMES_2   0x1
-#define BV_CLKCTRL_PLLCTRL0_LFR_SEL__TIMES_05  0x2
-#define BV_CLKCTRL_PLLCTRL0_LFR_SEL__UNDEFINED 0x3
-#define BP_CLKCTRL_PLLCTRL0_CP_SEL     24
-#define BM_CLKCTRL_PLLCTRL0_CP_SEL     0x03000000
-#define BF_CLKCTRL_PLLCTRL0_CP_SEL(v)  \
-               (((v) << 24) & BM_CLKCTRL_PLLCTRL0_CP_SEL)
-#define BV_CLKCTRL_PLLCTRL0_CP_SEL__DEFAULT   0x0
-#define BV_CLKCTRL_PLLCTRL0_CP_SEL__TIMES_2   0x1
-#define BV_CLKCTRL_PLLCTRL0_CP_SEL__TIMES_05  0x2
-#define BV_CLKCTRL_PLLCTRL0_CP_SEL__UNDEFINED 0x3
-#define BP_CLKCTRL_PLLCTRL0_DIV_SEL    20
-#define BM_CLKCTRL_PLLCTRL0_DIV_SEL    0x00300000
-#define BF_CLKCTRL_PLLCTRL0_DIV_SEL(v)  \
-               (((v) << 20) & BM_CLKCTRL_PLLCTRL0_DIV_SEL)
-#define BV_CLKCTRL_PLLCTRL0_DIV_SEL__DEFAULT   0x0
-#define BV_CLKCTRL_PLLCTRL0_DIV_SEL__LOWER     0x1
-#define BV_CLKCTRL_PLLCTRL0_DIV_SEL__LOWEST    0x2
-#define BV_CLKCTRL_PLLCTRL0_DIV_SEL__UNDEFINED 0x3
-#define BM_CLKCTRL_PLLCTRL0_EN_USB_CLKS        0x00040000
-#define BM_CLKCTRL_PLLCTRL0_POWER      0x00010000
-
-#define HW_CLKCTRL_PLLCTRL1    (0x00000010)
-
-#define BM_CLKCTRL_PLLCTRL1_LOCK       0x80000000
-#define BM_CLKCTRL_PLLCTRL1_FORCE_LOCK 0x40000000
-#define BP_CLKCTRL_PLLCTRL1_LOCK_COUNT 0
-#define BM_CLKCTRL_PLLCTRL1_LOCK_COUNT 0x0000FFFF
-#define BF_CLKCTRL_PLLCTRL1_LOCK_COUNT(v)  \
-               (((v) << 0) & BM_CLKCTRL_PLLCTRL1_LOCK_COUNT)
-
-#define HW_CLKCTRL_CPU (0x00000020)
-#define HW_CLKCTRL_CPU_SET     (0x00000024)
-#define HW_CLKCTRL_CPU_CLR     (0x00000028)
-#define HW_CLKCTRL_CPU_TOG     (0x0000002c)
-
-#define BM_CLKCTRL_CPU_BUSY_REF_XTAL   0x20000000
-#define BM_CLKCTRL_CPU_BUSY_REF_CPU    0x10000000
-#define BM_CLKCTRL_CPU_DIV_XTAL_FRAC_EN        0x04000000
-#define BP_CLKCTRL_CPU_DIV_XTAL        16
-#define BM_CLKCTRL_CPU_DIV_XTAL        0x03FF0000
-#define BF_CLKCTRL_CPU_DIV_XTAL(v)  \
-               (((v) << 16) & BM_CLKCTRL_CPU_DIV_XTAL)
-#define BM_CLKCTRL_CPU_INTERRUPT_WAIT  0x00001000
-#define BM_CLKCTRL_CPU_DIV_CPU_FRAC_EN 0x00000400
-#define BP_CLKCTRL_CPU_DIV_CPU 0
-#define BM_CLKCTRL_CPU_DIV_CPU 0x0000003F
-#define BF_CLKCTRL_CPU_DIV_CPU(v)  \
-               (((v) << 0) & BM_CLKCTRL_CPU_DIV_CPU)
-
-#define HW_CLKCTRL_HBUS        (0x00000030)
-#define HW_CLKCTRL_HBUS_SET    (0x00000034)
-#define HW_CLKCTRL_HBUS_CLR    (0x00000038)
-#define HW_CLKCTRL_HBUS_TOG    (0x0000003c)
-
-#define BM_CLKCTRL_HBUS_BUSY   0x20000000
-#define BM_CLKCTRL_HBUS_DCP_AS_ENABLE  0x10000000
-#define BM_CLKCTRL_HBUS_PXP_AS_ENABLE  0x08000000
-#define BM_CLKCTRL_HBUS_APBHDMA_AS_ENABLE      0x04000000
-#define BM_CLKCTRL_HBUS_APBXDMA_AS_ENABLE      0x02000000
-#define BM_CLKCTRL_HBUS_TRAFFIC_JAM_AS_ENABLE  0x01000000
-#define BM_CLKCTRL_HBUS_TRAFFIC_AS_ENABLE      0x00800000
-#define BM_CLKCTRL_HBUS_CPU_DATA_AS_ENABLE     0x00400000
-#define BM_CLKCTRL_HBUS_CPU_INSTR_AS_ENABLE    0x00200000
-#define BM_CLKCTRL_HBUS_AUTO_SLOW_MODE 0x00100000
-#define BP_CLKCTRL_HBUS_SLOW_DIV       16
-#define BM_CLKCTRL_HBUS_SLOW_DIV       0x00070000
-#define BF_CLKCTRL_HBUS_SLOW_DIV(v)  \
-               (((v) << 16) & BM_CLKCTRL_HBUS_SLOW_DIV)
-#define BV_CLKCTRL_HBUS_SLOW_DIV__BY1  0x0
-#define BV_CLKCTRL_HBUS_SLOW_DIV__BY2  0x1
-#define BV_CLKCTRL_HBUS_SLOW_DIV__BY4  0x2
-#define BV_CLKCTRL_HBUS_SLOW_DIV__BY8  0x3
-#define BV_CLKCTRL_HBUS_SLOW_DIV__BY16 0x4
-#define BV_CLKCTRL_HBUS_SLOW_DIV__BY32 0x5
-#define BM_CLKCTRL_HBUS_DIV_FRAC_EN    0x00000020
-#define BP_CLKCTRL_HBUS_DIV    0
-#define BM_CLKCTRL_HBUS_DIV    0x0000001F
-#define BF_CLKCTRL_HBUS_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_HBUS_DIV)
-
-#define HW_CLKCTRL_XBUS        (0x00000040)
-
-#define BM_CLKCTRL_XBUS_BUSY   0x80000000
-#define BM_CLKCTRL_XBUS_DIV_FRAC_EN    0x00000400
-#define BP_CLKCTRL_XBUS_DIV    0
-#define BM_CLKCTRL_XBUS_DIV    0x000003FF
-#define BF_CLKCTRL_XBUS_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_XBUS_DIV)
-
-#define HW_CLKCTRL_XTAL        (0x00000050)
-#define HW_CLKCTRL_XTAL_SET    (0x00000054)
-#define HW_CLKCTRL_XTAL_CLR    (0x00000058)
-#define HW_CLKCTRL_XTAL_TOG    (0x0000005c)
-
-#define BP_CLKCTRL_XTAL_UART_CLK_GATE  31
-#define BM_CLKCTRL_XTAL_UART_CLK_GATE  0x80000000
-#define BP_CLKCTRL_XTAL_FILT_CLK24M_GATE       30
-#define BM_CLKCTRL_XTAL_FILT_CLK24M_GATE       0x40000000
-#define BP_CLKCTRL_XTAL_PWM_CLK24M_GATE        29
-#define BM_CLKCTRL_XTAL_PWM_CLK24M_GATE        0x20000000
-#define BM_CLKCTRL_XTAL_DRI_CLK24M_GATE        0x10000000
-#define BM_CLKCTRL_XTAL_DIGCTRL_CLK1M_GATE     0x08000000
-#define BP_CLKCTRL_XTAL_TIMROT_CLK32K_GATE     26
-#define BM_CLKCTRL_XTAL_TIMROT_CLK32K_GATE     0x04000000
-#define BP_CLKCTRL_XTAL_DIV_UART       0
-#define BM_CLKCTRL_XTAL_DIV_UART       0x00000003
-#define BF_CLKCTRL_XTAL_DIV_UART(v)  \
-               (((v) << 0) & BM_CLKCTRL_XTAL_DIV_UART)
-
-#define HW_CLKCTRL_PIX (0x00000060)
-
-#define BP_CLKCTRL_PIX_CLKGATE 31
-#define BM_CLKCTRL_PIX_CLKGATE 0x80000000
-#define BM_CLKCTRL_PIX_BUSY    0x20000000
-#define BM_CLKCTRL_PIX_DIV_FRAC_EN     0x00001000
-#define BP_CLKCTRL_PIX_DIV     0
-#define BM_CLKCTRL_PIX_DIV     0x00000FFF
-#define BF_CLKCTRL_PIX_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_PIX_DIV)
-
-#define HW_CLKCTRL_SSP (0x00000070)
-
-#define BP_CLKCTRL_SSP_CLKGATE 31
-#define BM_CLKCTRL_SSP_CLKGATE 0x80000000
-#define BM_CLKCTRL_SSP_BUSY    0x20000000
-#define BM_CLKCTRL_SSP_DIV_FRAC_EN     0x00000200
-#define BP_CLKCTRL_SSP_DIV     0
-#define BM_CLKCTRL_SSP_DIV     0x000001FF
-#define BF_CLKCTRL_SSP_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_SSP_DIV)
-
-#define HW_CLKCTRL_GPMI        (0x00000080)
-
-#define BP_CLKCTRL_GPMI_CLKGATE        31
-#define BM_CLKCTRL_GPMI_CLKGATE        0x80000000
-#define BM_CLKCTRL_GPMI_BUSY   0x20000000
-#define BM_CLKCTRL_GPMI_DIV_FRAC_EN    0x00000400
-#define BP_CLKCTRL_GPMI_DIV    0
-#define BM_CLKCTRL_GPMI_DIV    0x000003FF
-#define BF_CLKCTRL_GPMI_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_GPMI_DIV)
-
-#define HW_CLKCTRL_SPDIF       (0x00000090)
-
-#define BM_CLKCTRL_SPDIF_CLKGATE       0x80000000
-
-#define HW_CLKCTRL_EMI (0x000000a0)
-
-#define BP_CLKCTRL_EMI_CLKGATE 31
-#define BM_CLKCTRL_EMI_CLKGATE 0x80000000
-#define BM_CLKCTRL_EMI_SYNC_MODE_EN    0x40000000
-#define BM_CLKCTRL_EMI_BUSY_REF_XTAL   0x20000000
-#define BM_CLKCTRL_EMI_BUSY_REF_EMI    0x10000000
-#define BM_CLKCTRL_EMI_BUSY_REF_CPU    0x08000000
-#define BM_CLKCTRL_EMI_BUSY_SYNC_MODE  0x04000000
-#define BM_CLKCTRL_EMI_BUSY_DCC_RESYNC 0x00020000
-#define BM_CLKCTRL_EMI_DCC_RESYNC_ENABLE       0x00010000
-#define BP_CLKCTRL_EMI_DIV_XTAL        8
-#define BM_CLKCTRL_EMI_DIV_XTAL        0x00000F00
-#define BF_CLKCTRL_EMI_DIV_XTAL(v)  \
-               (((v) << 8) & BM_CLKCTRL_EMI_DIV_XTAL)
-#define BP_CLKCTRL_EMI_DIV_EMI 0
-#define BM_CLKCTRL_EMI_DIV_EMI 0x0000003F
-#define BF_CLKCTRL_EMI_DIV_EMI(v)  \
-               (((v) << 0) & BM_CLKCTRL_EMI_DIV_EMI)
-
-#define HW_CLKCTRL_IR  (0x000000b0)
-
-#define BM_CLKCTRL_IR_CLKGATE  0x80000000
-#define BM_CLKCTRL_IR_AUTO_DIV 0x20000000
-#define BM_CLKCTRL_IR_IR_BUSY  0x10000000
-#define BM_CLKCTRL_IR_IROV_BUSY        0x08000000
-#define BP_CLKCTRL_IR_IROV_DIV 16
-#define BM_CLKCTRL_IR_IROV_DIV 0x01FF0000
-#define BF_CLKCTRL_IR_IROV_DIV(v)  \
-               (((v) << 16) & BM_CLKCTRL_IR_IROV_DIV)
-#define BP_CLKCTRL_IR_IR_DIV   0
-#define BM_CLKCTRL_IR_IR_DIV   0x000003FF
-#define BF_CLKCTRL_IR_IR_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_IR_IR_DIV)
-
-#define HW_CLKCTRL_SAIF        (0x000000c0)
-
-#define BM_CLKCTRL_SAIF_CLKGATE        0x80000000
-#define BM_CLKCTRL_SAIF_BUSY   0x20000000
-#define BM_CLKCTRL_SAIF_DIV_FRAC_EN    0x00010000
-#define BP_CLKCTRL_SAIF_DIV    0
-#define BM_CLKCTRL_SAIF_DIV    0x0000FFFF
-#define BF_CLKCTRL_SAIF_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_SAIF_DIV)
-
-#define HW_CLKCTRL_TV  (0x000000d0)
-
-#define BM_CLKCTRL_TV_CLK_TV108M_GATE  0x80000000
-#define BM_CLKCTRL_TV_CLK_TV_GATE      0x40000000
-
-#define HW_CLKCTRL_ETM (0x000000e0)
-
-#define BM_CLKCTRL_ETM_CLKGATE 0x80000000
-#define BM_CLKCTRL_ETM_BUSY    0x20000000
-#define BM_CLKCTRL_ETM_DIV_FRAC_EN     0x00000040
-#define BP_CLKCTRL_ETM_DIV     0
-#define BM_CLKCTRL_ETM_DIV     0x0000003F
-#define BF_CLKCTRL_ETM_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_ETM_DIV)
-
-#define HW_CLKCTRL_FRAC        (0x000000f0)
-#define HW_CLKCTRL_FRAC_SET    (0x000000f4)
-#define HW_CLKCTRL_FRAC_CLR    (0x000000f8)
-#define HW_CLKCTRL_FRAC_TOG    (0x000000fc)
-
-#define BP_CLKCTRL_FRAC_CLKGATEIO      31
-#define BM_CLKCTRL_FRAC_CLKGATEIO      0x80000000
-#define BM_CLKCTRL_FRAC_IO_STABLE      0x40000000
-#define BP_CLKCTRL_FRAC_IOFRAC 24
-#define BM_CLKCTRL_FRAC_IOFRAC 0x3F000000
-#define BF_CLKCTRL_FRAC_IOFRAC(v)  \
-               (((v) << 24) & BM_CLKCTRL_FRAC_IOFRAC)
-#define BP_CLKCTRL_FRAC_CLKGATEPIX     23
-#define BM_CLKCTRL_FRAC_CLKGATEPIX     0x00800000
-#define BM_CLKCTRL_FRAC_PIX_STABLE     0x00400000
-#define BP_CLKCTRL_FRAC_PIXFRAC        16
-#define BM_CLKCTRL_FRAC_PIXFRAC        0x003F0000
-#define BF_CLKCTRL_FRAC_PIXFRAC(v)  \
-               (((v) << 16) & BM_CLKCTRL_FRAC_PIXFRAC)
-#define BP_CLKCTRL_FRAC_CLKGATEEMI     15
-#define BM_CLKCTRL_FRAC_CLKGATEEMI     0x00008000
-#define BM_CLKCTRL_FRAC_EMI_STABLE     0x00004000
-#define BP_CLKCTRL_FRAC_EMIFRAC        8
-#define BM_CLKCTRL_FRAC_EMIFRAC        0x00003F00
-#define BF_CLKCTRL_FRAC_EMIFRAC(v)  \
-               (((v) << 8) & BM_CLKCTRL_FRAC_EMIFRAC)
-#define BP_CLKCTRL_FRAC_CLKGATECPU     7
-#define BM_CLKCTRL_FRAC_CLKGATECPU     0x00000080
-#define BM_CLKCTRL_FRAC_CPU_STABLE     0x00000040
-#define BP_CLKCTRL_FRAC_CPUFRAC        0
-#define BM_CLKCTRL_FRAC_CPUFRAC        0x0000003F
-#define BF_CLKCTRL_FRAC_CPUFRAC(v)  \
-               (((v) << 0) & BM_CLKCTRL_FRAC_CPUFRAC)
-
-#define HW_CLKCTRL_FRAC1       (0x00000100)
-#define HW_CLKCTRL_FRAC1_SET   (0x00000104)
-#define HW_CLKCTRL_FRAC1_CLR   (0x00000108)
-#define HW_CLKCTRL_FRAC1_TOG   (0x0000010c)
-
-#define BM_CLKCTRL_FRAC1_CLKGATEVID    0x80000000
-#define BM_CLKCTRL_FRAC1_VID_STABLE    0x40000000
-
-#define HW_CLKCTRL_CLKSEQ      (0x00000110)
-#define HW_CLKCTRL_CLKSEQ_SET  (0x00000114)
-#define HW_CLKCTRL_CLKSEQ_CLR  (0x00000118)
-#define HW_CLKCTRL_CLKSEQ_TOG  (0x0000011c)
-
-#define BM_CLKCTRL_CLKSEQ_BYPASS_ETM   0x00000100
-#define BM_CLKCTRL_CLKSEQ_BYPASS_CPU   0x00000080
-#define BM_CLKCTRL_CLKSEQ_BYPASS_EMI   0x00000040
-#define BM_CLKCTRL_CLKSEQ_BYPASS_SSP   0x00000020
-#define BM_CLKCTRL_CLKSEQ_BYPASS_GPMI  0x00000010
-#define BM_CLKCTRL_CLKSEQ_BYPASS_IR    0x00000008
-#define BM_CLKCTRL_CLKSEQ_BYPASS_PIX   0x00000002
-#define BM_CLKCTRL_CLKSEQ_BYPASS_SAIF  0x00000001
-
-#define HW_CLKCTRL_RESET       (0x00000120)
-
-#define BM_CLKCTRL_RESET_CHIP  0x00000002
-#define BM_CLKCTRL_RESET_DIG   0x00000001
-
-#define HW_CLKCTRL_STATUS      (0x00000130)
-
-#define BP_CLKCTRL_STATUS_CPU_LIMIT    30
-#define BM_CLKCTRL_STATUS_CPU_LIMIT    0xC0000000
-#define BF_CLKCTRL_STATUS_CPU_LIMIT(v) \
-               (((v) << 30) & BM_CLKCTRL_STATUS_CPU_LIMIT)
-
-#define HW_CLKCTRL_VERSION     (0x00000140)
-
-#define BP_CLKCTRL_VERSION_MAJOR       24
-#define BM_CLKCTRL_VERSION_MAJOR       0xFF000000
-#define BF_CLKCTRL_VERSION_MAJOR(v) \
-               (((v) << 24) & BM_CLKCTRL_VERSION_MAJOR)
-#define BP_CLKCTRL_VERSION_MINOR       16
-#define BM_CLKCTRL_VERSION_MINOR       0x00FF0000
-#define BF_CLKCTRL_VERSION_MINOR(v)  \
-               (((v) << 16) & BM_CLKCTRL_VERSION_MINOR)
-#define BP_CLKCTRL_VERSION_STEP        0
-#define BM_CLKCTRL_VERSION_STEP        0x0000FFFF
-#define BF_CLKCTRL_VERSION_STEP(v)  \
-               (((v) << 0) & BM_CLKCTRL_VERSION_STEP)
-
-#endif /* __REGS_CLKCTRL_MX23_H__ */
diff --git a/arch/arm/mach-mxs/regs-clkctrl-mx28.h b/arch/arm/mach-mxs/regs-clkctrl-mx28.h
deleted file mode 100644 (file)
index 7d1b061..0000000
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
- * Freescale CLKCTRL Register Definitions
- *
- * Copyright 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- *
- * This file is created by xml file. Don't Edit it.
- *
- * Xml Revision: 1.48
- * Template revision: 26195
- */
-
-#ifndef __REGS_CLKCTRL_MX28_H__
-#define __REGS_CLKCTRL_MX28_H__
-
-#define HW_CLKCTRL_PLL0CTRL0   (0x00000000)
-#define HW_CLKCTRL_PLL0CTRL0_SET       (0x00000004)
-#define HW_CLKCTRL_PLL0CTRL0_CLR       (0x00000008)
-#define HW_CLKCTRL_PLL0CTRL0_TOG       (0x0000000c)
-
-#define BP_CLKCTRL_PLL0CTRL0_LFR_SEL   28
-#define BM_CLKCTRL_PLL0CTRL0_LFR_SEL   0x30000000
-#define BF_CLKCTRL_PLL0CTRL0_LFR_SEL(v)  \
-               (((v) << 28) & BM_CLKCTRL_PLL0CTRL0_LFR_SEL)
-#define BV_CLKCTRL_PLL0CTRL0_LFR_SEL__DEFAULT   0x0
-#define BV_CLKCTRL_PLL0CTRL0_LFR_SEL__TIMES_2   0x1
-#define BV_CLKCTRL_PLL0CTRL0_LFR_SEL__TIMES_05  0x2
-#define BV_CLKCTRL_PLL0CTRL0_LFR_SEL__UNDEFINED 0x3
-#define BP_CLKCTRL_PLL0CTRL0_CP_SEL    24
-#define BM_CLKCTRL_PLL0CTRL0_CP_SEL    0x03000000
-#define BF_CLKCTRL_PLL0CTRL0_CP_SEL(v)  \
-               (((v) << 24) & BM_CLKCTRL_PLL0CTRL0_CP_SEL)
-#define BV_CLKCTRL_PLL0CTRL0_CP_SEL__DEFAULT   0x0
-#define BV_CLKCTRL_PLL0CTRL0_CP_SEL__TIMES_2   0x1
-#define BV_CLKCTRL_PLL0CTRL0_CP_SEL__TIMES_05  0x2
-#define BV_CLKCTRL_PLL0CTRL0_CP_SEL__UNDEFINED 0x3
-#define BP_CLKCTRL_PLL0CTRL0_DIV_SEL   20
-#define BM_CLKCTRL_PLL0CTRL0_DIV_SEL   0x00300000
-#define BF_CLKCTRL_PLL0CTRL0_DIV_SEL(v)  \
-               (((v) << 20) & BM_CLKCTRL_PLL0CTRL0_DIV_SEL)
-#define BV_CLKCTRL_PLL0CTRL0_DIV_SEL__DEFAULT   0x0
-#define BV_CLKCTRL_PLL0CTRL0_DIV_SEL__LOWER     0x1
-#define BV_CLKCTRL_PLL0CTRL0_DIV_SEL__LOWEST    0x2
-#define BV_CLKCTRL_PLL0CTRL0_DIV_SEL__UNDEFINED 0x3
-#define BM_CLKCTRL_PLL0CTRL0_EN_USB_CLKS       0x00040000
-#define BM_CLKCTRL_PLL0CTRL0_POWER     0x00020000
-
-#define HW_CLKCTRL_PLL0CTRL1   (0x00000010)
-
-#define BM_CLKCTRL_PLL0CTRL1_LOCK      0x80000000
-#define BM_CLKCTRL_PLL0CTRL1_FORCE_LOCK        0x40000000
-#define BP_CLKCTRL_PLL0CTRL1_LOCK_COUNT        0
-#define BM_CLKCTRL_PLL0CTRL1_LOCK_COUNT        0x0000FFFF
-#define BF_CLKCTRL_PLL0CTRL1_LOCK_COUNT(v)  \
-               (((v) << 0) & BM_CLKCTRL_PLL0CTRL1_LOCK_COUNT)
-
-#define HW_CLKCTRL_PLL1CTRL0   (0x00000020)
-#define HW_CLKCTRL_PLL1CTRL0_SET       (0x00000024)
-#define HW_CLKCTRL_PLL1CTRL0_CLR       (0x00000028)
-#define HW_CLKCTRL_PLL1CTRL0_TOG       (0x0000002c)
-
-#define BM_CLKCTRL_PLL1CTRL0_CLKGATEEMI        0x80000000
-#define BP_CLKCTRL_PLL1CTRL0_LFR_SEL   28
-#define BM_CLKCTRL_PLL1CTRL0_LFR_SEL   0x30000000
-#define BF_CLKCTRL_PLL1CTRL0_LFR_SEL(v)  \
-               (((v) << 28) & BM_CLKCTRL_PLL1CTRL0_LFR_SEL)
-#define BV_CLKCTRL_PLL1CTRL0_LFR_SEL__DEFAULT   0x0
-#define BV_CLKCTRL_PLL1CTRL0_LFR_SEL__TIMES_2   0x1
-#define BV_CLKCTRL_PLL1CTRL0_LFR_SEL__TIMES_05  0x2
-#define BV_CLKCTRL_PLL1CTRL0_LFR_SEL__UNDEFINED 0x3
-#define BP_CLKCTRL_PLL1CTRL0_CP_SEL    24
-#define BM_CLKCTRL_PLL1CTRL0_CP_SEL    0x03000000
-#define BF_CLKCTRL_PLL1CTRL0_CP_SEL(v)  \
-               (((v) << 24) & BM_CLKCTRL_PLL1CTRL0_CP_SEL)
-#define BV_CLKCTRL_PLL1CTRL0_CP_SEL__DEFAULT   0x0
-#define BV_CLKCTRL_PLL1CTRL0_CP_SEL__TIMES_2   0x1
-#define BV_CLKCTRL_PLL1CTRL0_CP_SEL__TIMES_05  0x2
-#define BV_CLKCTRL_PLL1CTRL0_CP_SEL__UNDEFINED 0x3
-#define BP_CLKCTRL_PLL1CTRL0_DIV_SEL   20
-#define BM_CLKCTRL_PLL1CTRL0_DIV_SEL   0x00300000
-#define BF_CLKCTRL_PLL1CTRL0_DIV_SEL(v)  \
-               (((v) << 20) & BM_CLKCTRL_PLL1CTRL0_DIV_SEL)
-#define BV_CLKCTRL_PLL1CTRL0_DIV_SEL__DEFAULT   0x0
-#define BV_CLKCTRL_PLL1CTRL0_DIV_SEL__LOWER     0x1
-#define BV_CLKCTRL_PLL1CTRL0_DIV_SEL__LOWEST    0x2
-#define BV_CLKCTRL_PLL1CTRL0_DIV_SEL__UNDEFINED 0x3
-#define BM_CLKCTRL_PLL1CTRL0_EN_USB_CLKS       0x00040000
-#define BM_CLKCTRL_PLL1CTRL0_POWER     0x00020000
-
-#define HW_CLKCTRL_PLL1CTRL1   (0x00000030)
-
-#define BM_CLKCTRL_PLL1CTRL1_LOCK      0x80000000
-#define BM_CLKCTRL_PLL1CTRL1_FORCE_LOCK        0x40000000
-#define BP_CLKCTRL_PLL1CTRL1_LOCK_COUNT        0
-#define BM_CLKCTRL_PLL1CTRL1_LOCK_COUNT        0x0000FFFF
-#define BF_CLKCTRL_PLL1CTRL1_LOCK_COUNT(v)  \
-               (((v) << 0) & BM_CLKCTRL_PLL1CTRL1_LOCK_COUNT)
-
-#define HW_CLKCTRL_PLL2CTRL0   (0x00000040)
-#define HW_CLKCTRL_PLL2CTRL0_SET       (0x00000044)
-#define HW_CLKCTRL_PLL2CTRL0_CLR       (0x00000048)
-#define HW_CLKCTRL_PLL2CTRL0_TOG       (0x0000004c)
-
-#define BM_CLKCTRL_PLL2CTRL0_CLKGATE   0x80000000
-#define BP_CLKCTRL_PLL2CTRL0_LFR_SEL   28
-#define BM_CLKCTRL_PLL2CTRL0_LFR_SEL   0x30000000
-#define BF_CLKCTRL_PLL2CTRL0_LFR_SEL(v)  \
-               (((v) << 28) & BM_CLKCTRL_PLL2CTRL0_LFR_SEL)
-#define BM_CLKCTRL_PLL2CTRL0_HOLD_RING_OFF_B   0x04000000
-#define BP_CLKCTRL_PLL2CTRL0_CP_SEL    24
-#define BM_CLKCTRL_PLL2CTRL0_CP_SEL    0x03000000
-#define BF_CLKCTRL_PLL2CTRL0_CP_SEL(v)  \
-               (((v) << 24) & BM_CLKCTRL_PLL2CTRL0_CP_SEL)
-#define BM_CLKCTRL_PLL2CTRL0_POWER     0x00800000
-
-#define HW_CLKCTRL_CPU (0x00000050)
-#define HW_CLKCTRL_CPU_SET     (0x00000054)
-#define HW_CLKCTRL_CPU_CLR     (0x00000058)
-#define HW_CLKCTRL_CPU_TOG     (0x0000005c)
-
-#define BM_CLKCTRL_CPU_BUSY_REF_XTAL   0x20000000
-#define BM_CLKCTRL_CPU_BUSY_REF_CPU    0x10000000
-#define BM_CLKCTRL_CPU_DIV_XTAL_FRAC_EN        0x04000000
-#define BP_CLKCTRL_CPU_DIV_XTAL        16
-#define BM_CLKCTRL_CPU_DIV_XTAL        0x03FF0000
-#define BF_CLKCTRL_CPU_DIV_XTAL(v)  \
-               (((v) << 16) & BM_CLKCTRL_CPU_DIV_XTAL)
-#define BM_CLKCTRL_CPU_INTERRUPT_WAIT  0x00001000
-#define BM_CLKCTRL_CPU_DIV_CPU_FRAC_EN 0x00000400
-#define BP_CLKCTRL_CPU_DIV_CPU 0
-#define BM_CLKCTRL_CPU_DIV_CPU 0x0000003F
-#define BF_CLKCTRL_CPU_DIV_CPU(v)  \
-               (((v) << 0) & BM_CLKCTRL_CPU_DIV_CPU)
-
-#define HW_CLKCTRL_HBUS        (0x00000060)
-#define HW_CLKCTRL_HBUS_SET    (0x00000064)
-#define HW_CLKCTRL_HBUS_CLR    (0x00000068)
-#define HW_CLKCTRL_HBUS_TOG    (0x0000006c)
-
-#define BM_CLKCTRL_HBUS_ASM_BUSY       0x80000000
-#define BM_CLKCTRL_HBUS_DCP_AS_ENABLE  0x40000000
-#define BM_CLKCTRL_HBUS_PXP_AS_ENABLE  0x20000000
-#define BM_CLKCTRL_HBUS_ASM_EMIPORT_AS_ENABLE  0x08000000
-#define BM_CLKCTRL_HBUS_APBHDMA_AS_ENABLE      0x04000000
-#define BM_CLKCTRL_HBUS_APBXDMA_AS_ENABLE      0x02000000
-#define BM_CLKCTRL_HBUS_TRAFFIC_JAM_AS_ENABLE  0x01000000
-#define BM_CLKCTRL_HBUS_TRAFFIC_AS_ENABLE      0x00800000
-#define BM_CLKCTRL_HBUS_CPU_DATA_AS_ENABLE     0x00400000
-#define BM_CLKCTRL_HBUS_CPU_INSTR_AS_ENABLE    0x00200000
-#define BM_CLKCTRL_HBUS_ASM_ENABLE     0x00100000
-#define BM_CLKCTRL_HBUS_AUTO_CLEAR_DIV_ENABLE  0x00080000
-#define BP_CLKCTRL_HBUS_SLOW_DIV       16
-#define BM_CLKCTRL_HBUS_SLOW_DIV       0x00070000
-#define BF_CLKCTRL_HBUS_SLOW_DIV(v)  \
-               (((v) << 16) & BM_CLKCTRL_HBUS_SLOW_DIV)
-#define BV_CLKCTRL_HBUS_SLOW_DIV__BY1  0x0
-#define BV_CLKCTRL_HBUS_SLOW_DIV__BY2  0x1
-#define BV_CLKCTRL_HBUS_SLOW_DIV__BY4  0x2
-#define BV_CLKCTRL_HBUS_SLOW_DIV__BY8  0x3
-#define BV_CLKCTRL_HBUS_SLOW_DIV__BY16 0x4
-#define BV_CLKCTRL_HBUS_SLOW_DIV__BY32 0x5
-#define BM_CLKCTRL_HBUS_DIV_FRAC_EN    0x00000020
-#define BP_CLKCTRL_HBUS_DIV    0
-#define BM_CLKCTRL_HBUS_DIV    0x0000001F
-#define BF_CLKCTRL_HBUS_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_HBUS_DIV)
-
-#define HW_CLKCTRL_XBUS        (0x00000070)
-
-#define BM_CLKCTRL_XBUS_BUSY   0x80000000
-#define BM_CLKCTRL_XBUS_AUTO_CLEAR_DIV_ENABLE  0x00000800
-#define BM_CLKCTRL_XBUS_DIV_FRAC_EN    0x00000400
-#define BP_CLKCTRL_XBUS_DIV    0
-#define BM_CLKCTRL_XBUS_DIV    0x000003FF
-#define BF_CLKCTRL_XBUS_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_XBUS_DIV)
-
-#define HW_CLKCTRL_XTAL        (0x00000080)
-#define HW_CLKCTRL_XTAL_SET    (0x00000084)
-#define HW_CLKCTRL_XTAL_CLR    (0x00000088)
-#define HW_CLKCTRL_XTAL_TOG    (0x0000008c)
-
-#define BP_CLKCTRL_XTAL_UART_CLK_GATE  31
-#define BM_CLKCTRL_XTAL_UART_CLK_GATE  0x80000000
-#define BP_CLKCTRL_XTAL_PWM_CLK24M_GATE        29
-#define BM_CLKCTRL_XTAL_PWM_CLK24M_GATE        0x20000000
-#define BP_CLKCTRL_XTAL_TIMROT_CLK32K_GATE     26
-#define BM_CLKCTRL_XTAL_TIMROT_CLK32K_GATE     0x04000000
-#define BP_CLKCTRL_XTAL_DIV_UART       0
-#define BM_CLKCTRL_XTAL_DIV_UART       0x00000003
-#define BF_CLKCTRL_XTAL_DIV_UART(v)  \
-               (((v) << 0) & BM_CLKCTRL_XTAL_DIV_UART)
-
-#define HW_CLKCTRL_SSP0        (0x00000090)
-
-#define BP_CLKCTRL_SSP0_CLKGATE        31
-#define BM_CLKCTRL_SSP0_CLKGATE        0x80000000
-#define BM_CLKCTRL_SSP0_BUSY   0x20000000
-#define BM_CLKCTRL_SSP0_DIV_FRAC_EN    0x00000200
-#define BP_CLKCTRL_SSP0_DIV    0
-#define BM_CLKCTRL_SSP0_DIV    0x000001FF
-#define BF_CLKCTRL_SSP0_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_SSP0_DIV)
-
-#define HW_CLKCTRL_SSP1        (0x000000a0)
-
-#define BP_CLKCTRL_SSP1_CLKGATE        31
-#define BM_CLKCTRL_SSP1_CLKGATE        0x80000000
-#define BM_CLKCTRL_SSP1_BUSY   0x20000000
-#define BM_CLKCTRL_SSP1_DIV_FRAC_EN    0x00000200
-#define BP_CLKCTRL_SSP1_DIV    0
-#define BM_CLKCTRL_SSP1_DIV    0x000001FF
-#define BF_CLKCTRL_SSP1_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_SSP1_DIV)
-
-#define HW_CLKCTRL_SSP2        (0x000000b0)
-
-#define BP_CLKCTRL_SSP2_CLKGATE        31
-#define BM_CLKCTRL_SSP2_CLKGATE        0x80000000
-#define BM_CLKCTRL_SSP2_BUSY   0x20000000
-#define BM_CLKCTRL_SSP2_DIV_FRAC_EN    0x00000200
-#define BP_CLKCTRL_SSP2_DIV    0
-#define BM_CLKCTRL_SSP2_DIV    0x000001FF
-#define BF_CLKCTRL_SSP2_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_SSP2_DIV)
-
-#define HW_CLKCTRL_SSP3        (0x000000c0)
-
-#define BP_CLKCTRL_SSP3_CLKGATE        31
-#define BM_CLKCTRL_SSP3_CLKGATE        0x80000000
-#define BM_CLKCTRL_SSP3_BUSY   0x20000000
-#define BM_CLKCTRL_SSP3_DIV_FRAC_EN    0x00000200
-#define BP_CLKCTRL_SSP3_DIV    0
-#define BM_CLKCTRL_SSP3_DIV    0x000001FF
-#define BF_CLKCTRL_SSP3_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_SSP3_DIV)
-
-#define HW_CLKCTRL_GPMI        (0x000000d0)
-
-#define BP_CLKCTRL_GPMI_CLKGATE        31
-#define BM_CLKCTRL_GPMI_CLKGATE        0x80000000
-#define BM_CLKCTRL_GPMI_BUSY   0x20000000
-#define BM_CLKCTRL_GPMI_DIV_FRAC_EN    0x00000400
-#define BP_CLKCTRL_GPMI_DIV    0
-#define BM_CLKCTRL_GPMI_DIV    0x000003FF
-#define BF_CLKCTRL_GPMI_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_GPMI_DIV)
-
-#define HW_CLKCTRL_SPDIF       (0x000000e0)
-
-#define BP_CLKCTRL_SPDIF_CLKGATE       31
-#define BM_CLKCTRL_SPDIF_CLKGATE       0x80000000
-
-#define HW_CLKCTRL_EMI (0x000000f0)
-
-#define BP_CLKCTRL_EMI_CLKGATE 31
-#define BM_CLKCTRL_EMI_CLKGATE 0x80000000
-#define BM_CLKCTRL_EMI_SYNC_MODE_EN    0x40000000
-#define BM_CLKCTRL_EMI_BUSY_REF_XTAL   0x20000000
-#define BM_CLKCTRL_EMI_BUSY_REF_EMI    0x10000000
-#define BM_CLKCTRL_EMI_BUSY_REF_CPU    0x08000000
-#define BM_CLKCTRL_EMI_BUSY_SYNC_MODE  0x04000000
-#define BM_CLKCTRL_EMI_BUSY_DCC_RESYNC 0x00020000
-#define BM_CLKCTRL_EMI_DCC_RESYNC_ENABLE       0x00010000
-#define BP_CLKCTRL_EMI_DIV_XTAL        8
-#define BM_CLKCTRL_EMI_DIV_XTAL        0x00000F00
-#define BF_CLKCTRL_EMI_DIV_XTAL(v)  \
-               (((v) << 8) & BM_CLKCTRL_EMI_DIV_XTAL)
-#define BP_CLKCTRL_EMI_DIV_EMI 0
-#define BM_CLKCTRL_EMI_DIV_EMI 0x0000003F
-#define BF_CLKCTRL_EMI_DIV_EMI(v)  \
-               (((v) << 0) & BM_CLKCTRL_EMI_DIV_EMI)
-
-#define HW_CLKCTRL_SAIF0       (0x00000100)
-
-#define BP_CLKCTRL_SAIF0_CLKGATE       31
-#define BM_CLKCTRL_SAIF0_CLKGATE       0x80000000
-#define BM_CLKCTRL_SAIF0_BUSY  0x20000000
-#define BM_CLKCTRL_SAIF0_DIV_FRAC_EN   0x00010000
-#define BP_CLKCTRL_SAIF0_DIV   0
-#define BM_CLKCTRL_SAIF0_DIV   0x0000FFFF
-#define BF_CLKCTRL_SAIF0_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_SAIF0_DIV)
-
-#define HW_CLKCTRL_SAIF1       (0x00000110)
-
-#define BP_CLKCTRL_SAIF1_CLKGATE       31
-#define BM_CLKCTRL_SAIF1_CLKGATE       0x80000000
-#define BM_CLKCTRL_SAIF1_BUSY  0x20000000
-#define BM_CLKCTRL_SAIF1_DIV_FRAC_EN   0x00010000
-#define BP_CLKCTRL_SAIF1_DIV   0
-#define BM_CLKCTRL_SAIF1_DIV   0x0000FFFF
-#define BF_CLKCTRL_SAIF1_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_SAIF1_DIV)
-
-#define HW_CLKCTRL_DIS_LCDIF   (0x00000120)
-
-#define BP_CLKCTRL_DIS_LCDIF_CLKGATE   31
-#define BM_CLKCTRL_DIS_LCDIF_CLKGATE   0x80000000
-#define BM_CLKCTRL_DIS_LCDIF_BUSY      0x20000000
-#define BM_CLKCTRL_DIS_LCDIF_DIV_FRAC_EN       0x00002000
-#define BP_CLKCTRL_DIS_LCDIF_DIV       0
-#define BM_CLKCTRL_DIS_LCDIF_DIV       0x00001FFF
-#define BF_CLKCTRL_DIS_LCDIF_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_DIS_LCDIF_DIV)
-
-#define HW_CLKCTRL_ETM (0x00000130)
-
-#define BM_CLKCTRL_ETM_CLKGATE 0x80000000
-#define BM_CLKCTRL_ETM_BUSY    0x20000000
-#define BM_CLKCTRL_ETM_DIV_FRAC_EN     0x00000080
-#define BP_CLKCTRL_ETM_DIV     0
-#define BM_CLKCTRL_ETM_DIV     0x0000007F
-#define BF_CLKCTRL_ETM_DIV(v)  \
-               (((v) << 0) & BM_CLKCTRL_ETM_DIV)
-
-#define HW_CLKCTRL_ENET        (0x00000140)
-
-#define BM_CLKCTRL_ENET_SLEEP  0x80000000
-#define BP_CLKCTRL_ENET_DISABLE        30
-#define BM_CLKCTRL_ENET_DISABLE        0x40000000
-#define BM_CLKCTRL_ENET_STATUS 0x20000000
-#define BM_CLKCTRL_ENET_BUSY_TIME      0x08000000
-#define BP_CLKCTRL_ENET_DIV_TIME       21
-#define BM_CLKCTRL_ENET_DIV_TIME       0x07E00000
-#define BF_CLKCTRL_ENET_DIV_TIME(v)  \
-               (((v) << 21) & BM_CLKCTRL_ENET_DIV_TIME)
-#define BM_CLKCTRL_ENET_BUSY   0x08000000
-#define BP_CLKCTRL_ENET_DIV    21
-#define BM_CLKCTRL_ENET_DIV    0x07E00000
-#define BF_CLKCTRL_ENET_DIV(v)  \
-               (((v) << 21) & BM_CLKCTRL_ENET_DIV)
-#define BP_CLKCTRL_ENET_TIME_SEL       19
-#define BM_CLKCTRL_ENET_TIME_SEL       0x00180000
-#define BF_CLKCTRL_ENET_TIME_SEL(v)  \
-               (((v) << 19) & BM_CLKCTRL_ENET_TIME_SEL)
-#define BV_CLKCTRL_ENET_TIME_SEL__XTAL      0x0
-#define BV_CLKCTRL_ENET_TIME_SEL__PLL       0x1
-#define BV_CLKCTRL_ENET_TIME_SEL__RMII_CLK  0x2
-#define BV_CLKCTRL_ENET_TIME_SEL__UNDEFINED 0x3
-#define BM_CLKCTRL_ENET_CLK_OUT_EN     0x00040000
-#define BM_CLKCTRL_ENET_RESET_BY_SW_CHIP       0x00020000
-#define BM_CLKCTRL_ENET_RESET_BY_SW    0x00010000
-
-#define HW_CLKCTRL_HSADC       (0x00000150)
-
-#define BM_CLKCTRL_HSADC_RESETB        0x40000000
-#define BP_CLKCTRL_HSADC_FREQDIV       28
-#define BM_CLKCTRL_HSADC_FREQDIV       0x30000000
-#define BF_CLKCTRL_HSADC_FREQDIV(v)  \
-               (((v) << 28) & BM_CLKCTRL_HSADC_FREQDIV)
-
-#define HW_CLKCTRL_FLEXCAN     (0x00000160)
-
-#define BP_CLKCTRL_FLEXCAN_STOP_CAN0   30
-#define BM_CLKCTRL_FLEXCAN_STOP_CAN0   0x40000000
-#define BM_CLKCTRL_FLEXCAN_CAN0_STATUS 0x20000000
-#define BP_CLKCTRL_FLEXCAN_STOP_CAN1   28
-#define BM_CLKCTRL_FLEXCAN_STOP_CAN1   0x10000000
-#define BM_CLKCTRL_FLEXCAN_CAN1_STATUS 0x08000000
-
-#define HW_CLKCTRL_FRAC0       (0x000001b0)
-#define HW_CLKCTRL_FRAC0_SET   (0x000001b4)
-#define HW_CLKCTRL_FRAC0_CLR   (0x000001b8)
-#define HW_CLKCTRL_FRAC0_TOG   (0x000001bc)
-
-#define BP_CLKCTRL_FRAC0_CLKGATEIO0    31
-#define BM_CLKCTRL_FRAC0_CLKGATEIO0    0x80000000
-#define BM_CLKCTRL_FRAC0_IO0_STABLE    0x40000000
-#define BP_CLKCTRL_FRAC0_IO0FRAC       24
-#define BM_CLKCTRL_FRAC0_IO0FRAC       0x3F000000
-#define BF_CLKCTRL_FRAC0_IO0FRAC(v)  \
-               (((v) << 24) & BM_CLKCTRL_FRAC0_IO0FRAC)
-#define BP_CLKCTRL_FRAC0_CLKGATEIO1    23
-#define BM_CLKCTRL_FRAC0_CLKGATEIO1    0x00800000
-#define BM_CLKCTRL_FRAC0_IO1_STABLE    0x00400000
-#define BP_CLKCTRL_FRAC0_IO1FRAC       16
-#define BM_CLKCTRL_FRAC0_IO1FRAC       0x003F0000
-#define BF_CLKCTRL_FRAC0_IO1FRAC(v)  \
-               (((v) << 16) & BM_CLKCTRL_FRAC0_IO1FRAC)
-#define BP_CLKCTRL_FRAC0_CLKGATEEMI    15
-#define BM_CLKCTRL_FRAC0_CLKGATEEMI    0x00008000
-#define BM_CLKCTRL_FRAC0_EMI_STABLE    0x00004000
-#define BP_CLKCTRL_FRAC0_EMIFRAC       8
-#define BM_CLKCTRL_FRAC0_EMIFRAC       0x00003F00
-#define BF_CLKCTRL_FRAC0_EMIFRAC(v)  \
-               (((v) << 8) & BM_CLKCTRL_FRAC0_EMIFRAC)
-#define BP_CLKCTRL_FRAC0_CLKGATECPU    7
-#define BM_CLKCTRL_FRAC0_CLKGATECPU    0x00000080
-#define BM_CLKCTRL_FRAC0_CPU_STABLE    0x00000040
-#define BP_CLKCTRL_FRAC0_CPUFRAC       0
-#define BM_CLKCTRL_FRAC0_CPUFRAC       0x0000003F
-#define BF_CLKCTRL_FRAC0_CPUFRAC(v)  \
-               (((v) << 0) & BM_CLKCTRL_FRAC0_CPUFRAC)
-
-#define HW_CLKCTRL_FRAC1       (0x000001c0)
-#define HW_CLKCTRL_FRAC1_SET   (0x000001c4)
-#define HW_CLKCTRL_FRAC1_CLR   (0x000001c8)
-#define HW_CLKCTRL_FRAC1_TOG   (0x000001cc)
-
-#define BP_CLKCTRL_FRAC1_CLKGATEGPMI   23
-#define BM_CLKCTRL_FRAC1_CLKGATEGPMI   0x00800000
-#define BM_CLKCTRL_FRAC1_GPMI_STABLE   0x00400000
-#define BP_CLKCTRL_FRAC1_GPMIFRAC      16
-#define BM_CLKCTRL_FRAC1_GPMIFRAC      0x003F0000
-#define BF_CLKCTRL_FRAC1_GPMIFRAC(v)  \
-               (((v) << 16) & BM_CLKCTRL_FRAC1_GPMIFRAC)
-#define BP_CLKCTRL_FRAC1_CLKGATEHSADC  15
-#define BM_CLKCTRL_FRAC1_CLKGATEHSADC  0x00008000
-#define BM_CLKCTRL_FRAC1_HSADC_STABLE  0x00004000
-#define BP_CLKCTRL_FRAC1_HSADCFRAC     8
-#define BM_CLKCTRL_FRAC1_HSADCFRAC     0x00003F00
-#define BF_CLKCTRL_FRAC1_HSADCFRAC(v)  \
-               (((v) << 8) & BM_CLKCTRL_FRAC1_HSADCFRAC)
-#define BP_CLKCTRL_FRAC1_CLKGATEPIX    7
-#define BM_CLKCTRL_FRAC1_CLKGATEPIX    0x00000080
-#define BM_CLKCTRL_FRAC1_PIX_STABLE    0x00000040
-#define BP_CLKCTRL_FRAC1_PIXFRAC       0
-#define BM_CLKCTRL_FRAC1_PIXFRAC       0x0000003F
-#define BF_CLKCTRL_FRAC1_PIXFRAC(v)  \
-               (((v) << 0) & BM_CLKCTRL_FRAC1_PIXFRAC)
-
-#define HW_CLKCTRL_CLKSEQ      (0x000001d0)
-#define HW_CLKCTRL_CLKSEQ_SET  (0x000001d4)
-#define HW_CLKCTRL_CLKSEQ_CLR  (0x000001d8)
-#define HW_CLKCTRL_CLKSEQ_TOG  (0x000001dc)
-
-#define BM_CLKCTRL_CLKSEQ_BYPASS_CPU   0x00040000
-#define BM_CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF     0x00004000
-#define BV_CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF__BYPASS 0x1
-#define BV_CLKCTRL_CLKSEQ_BYPASS_DIS_LCDIF__PFD    0x0
-#define BM_CLKCTRL_CLKSEQ_BYPASS_ETM   0x00000100
-#define BM_CLKCTRL_CLKSEQ_BYPASS_EMI   0x00000080
-#define BM_CLKCTRL_CLKSEQ_BYPASS_SSP3  0x00000040
-#define BM_CLKCTRL_CLKSEQ_BYPASS_SSP2  0x00000020
-#define BM_CLKCTRL_CLKSEQ_BYPASS_SSP1  0x00000010
-#define BM_CLKCTRL_CLKSEQ_BYPASS_SSP0  0x00000008
-#define BM_CLKCTRL_CLKSEQ_BYPASS_GPMI  0x00000004
-#define BM_CLKCTRL_CLKSEQ_BYPASS_SAIF1 0x00000002
-#define BM_CLKCTRL_CLKSEQ_BYPASS_SAIF0 0x00000001
-
-#define HW_CLKCTRL_RESET       (0x000001e0)
-
-#define BM_CLKCTRL_RESET_WDOG_POR_DISABLE      0x00000020
-#define BM_CLKCTRL_RESET_EXTERNAL_RESET_ENABLE 0x00000010
-#define BM_CLKCTRL_RESET_THERMAL_RESET_ENABLE  0x00000008
-#define BM_CLKCTRL_RESET_THERMAL_RESET_DEFAULT 0x00000004
-#define BM_CLKCTRL_RESET_CHIP  0x00000002
-#define BM_CLKCTRL_RESET_DIG   0x00000001
-
-#define HW_CLKCTRL_STATUS      (0x000001f0)
-
-#define BP_CLKCTRL_STATUS_CPU_LIMIT    30
-#define BM_CLKCTRL_STATUS_CPU_LIMIT    0xC0000000
-#define BF_CLKCTRL_STATUS_CPU_LIMIT(v) \
-               (((v) << 30) & BM_CLKCTRL_STATUS_CPU_LIMIT)
-
-#define HW_CLKCTRL_VERSION     (0x00000200)
-
-#define BP_CLKCTRL_VERSION_MAJOR       24
-#define BM_CLKCTRL_VERSION_MAJOR       0xFF000000
-#define BF_CLKCTRL_VERSION_MAJOR(v) \
-               (((v) << 24) & BM_CLKCTRL_VERSION_MAJOR)
-#define BP_CLKCTRL_VERSION_MINOR       16
-#define BM_CLKCTRL_VERSION_MINOR       0x00FF0000
-#define BF_CLKCTRL_VERSION_MINOR(v)  \
-               (((v) << 16) & BM_CLKCTRL_VERSION_MINOR)
-#define BP_CLKCTRL_VERSION_STEP        0
-#define BM_CLKCTRL_VERSION_STEP        0x0000FFFF
-#define BF_CLKCTRL_VERSION_STEP(v)  \
-               (((v) << 0) & BM_CLKCTRL_VERSION_STEP)
-
-#endif /* __REGS_CLKCTRL_MX28_H__ */
index 80ac1fca8a004d91bf7f5be1fa4c7adfaf703841..30042e23bfa7cf6ca7eea1fd2f543ae11f8b4fbf 100644 (file)
@@ -37,8 +37,6 @@
 #define MXS_MODULE_CLKGATE             (1 << 30)
 #define MXS_MODULE_SFTRST              (1 << 31)
 
-#define CLKCTRL_TIMEOUT                10      /* 10 ms */
-
 static void __iomem *mxs_clkctrl_reset_addr;
 
 /*
@@ -139,17 +137,3 @@ error:
        return -ETIMEDOUT;
 }
 EXPORT_SYMBOL(mxs_reset_block);
-
-int mxs_clkctrl_timeout(unsigned int reg_offset, unsigned int mask)
-{
-       unsigned long timeout = jiffies + msecs_to_jiffies(CLKCTRL_TIMEOUT);
-       while (readl_relaxed(MXS_IO_ADDRESS(MXS_CLKCTRL_BASE_ADDR)
-                                               + reg_offset) & mask) {
-               if (time_after(jiffies, timeout)) {
-                       pr_err("Timeout at CLKCTRL + 0x%x\n", reg_offset);
-                       return -ETIMEDOUT;
-               }
-       }
-
-       return 0;
-}
index 564a63279f184544455f091c85a7c9543099a805..02d36de9c4e8c394a2b498fff4fbe877dea2a205 100644 (file)
@@ -20,6 +20,7 @@
  * MA 02110-1301, USA.
  */
 
+#include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/clockchips.h>
@@ -243,8 +244,16 @@ static int __init mxs_clocksource_init(struct clk *timer_clk)
        return 0;
 }
 
-void __init mxs_timer_init(struct clk *timer_clk, int irq)
+void __init mxs_timer_init(int irq)
 {
+       struct clk *timer_clk;
+
+       timer_clk = clk_get_sys("timrot", NULL);
+       if (IS_ERR(timer_clk)) {
+               pr_err("%s: failed to get clk\n", __func__);
+               return;
+       }
+
        clk_prepare_enable(timer_clk);
 
        /*
index c54cef25895cdbbbe03c3922490f69be83409868..cbf51ae81855bc5bc255a4aa3abb606cf93bce68 100644 (file)
@@ -17,6 +17,7 @@
  *
  * bit     23 - Input/Output (PXA2xx specific)
  * bit     24 - Wakeup Enable(PXA2xx specific)
+ * bit     25 - Keep Output  (PXA2xx specific)
  */
 
 #define MFP_DIR_IN             (0x0 << 23)
 #define MFP_DIR(x)             (((x) >> 23) & 0x1)
 
 #define MFP_LPM_CAN_WAKEUP     (0x1 << 24)
+
+/*
+ * MFP_LPM_KEEP_OUTPUT must be specified for pins that need to
+ * retain their last output level (low or high).
+ * Note: MFP_LPM_KEEP_OUTPUT has no effect on pins configured for input.
+ */
 #define MFP_LPM_KEEP_OUTPUT    (0x1 << 25)
 
 #define WAKEUP_ON_EDGE_RISE    (MFP_LPM_CAN_WAKEUP | MFP_LPM_EDGE_RISE)
index b0a842887780f9acbe32e4223b4fe769f49b88f1..ef0426a159d4d4e04c681f7097fb8732d7096156 100644 (file)
@@ -33,6 +33,8 @@
 #define BANK_OFF(n)    (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2))
 #define GPLR(x)                __REG2(0x40E00000, BANK_OFF((x) >> 5))
 #define GPDR(x)                __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x0c)
+#define GPSR(x)                __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x18)
+#define GPCR(x)                __REG2(0x40E00000, BANK_OFF((x) >> 5) + 0x24)
 
 #define PWER_WE35      (1 << 24)
 
@@ -348,6 +350,7 @@ static inline void pxa27x_mfp_init(void) {}
 #ifdef CONFIG_PM
 static unsigned long saved_gafr[2][4];
 static unsigned long saved_gpdr[4];
+static unsigned long saved_gplr[4];
 static unsigned long saved_pgsr[4];
 
 static int pxa2xx_mfp_suspend(void)
@@ -366,14 +369,26 @@ static int pxa2xx_mfp_suspend(void)
        }
 
        for (i = 0; i <= gpio_to_bank(pxa_last_gpio); i++) {
-
                saved_gafr[0][i] = GAFR_L(i);
                saved_gafr[1][i] = GAFR_U(i);
                saved_gpdr[i] = GPDR(i * 32);
+               saved_gplr[i] = GPLR(i * 32);
                saved_pgsr[i] = PGSR(i);
 
-               GPDR(i * 32) = gpdr_lpm[i];
+               GPSR(i * 32) = PGSR(i);
+               GPCR(i * 32) = ~PGSR(i);
+       }
+
+       /* set GPDR bits taking into account MFP_LPM_KEEP_OUTPUT */
+       for (i = 0; i < pxa_last_gpio; i++) {
+               if ((gpdr_lpm[gpio_to_bank(i)] & GPIO_bit(i)) ||
+                   ((gpio_desc[i].config & MFP_LPM_KEEP_OUTPUT) &&
+                    (saved_gpdr[gpio_to_bank(i)] & GPIO_bit(i))))
+                       GPDR(i) |= GPIO_bit(i);
+               else
+                       GPDR(i) &= ~GPIO_bit(i);
        }
+
        return 0;
 }
 
@@ -384,6 +399,8 @@ static void pxa2xx_mfp_resume(void)
        for (i = 0; i <= gpio_to_bank(pxa_last_gpio); i++) {
                GAFR_L(i) = saved_gafr[0][i];
                GAFR_U(i) = saved_gafr[1][i];
+               GPSR(i * 32) = saved_gplr[i];
+               GPCR(i * 32) = ~saved_gplr[i];
                GPDR(i * 32) = saved_gpdr[i];
                PGSR(i) = saved_pgsr[i];
        }
index 6bce78edce7a3c070b197b57f1fcb16197c3ba7f..4726c246dcdc930bd5db27feb301221c2edced42 100644 (file)
@@ -421,8 +421,11 @@ void __init pxa27x_set_i2c_power_info(struct i2c_pxa_platform_data *info)
        pxa_register_device(&pxa27x_device_i2c_power, info);
 }
 
+static struct pxa_gpio_platform_data pxa27x_gpio_info __initdata = {
+       .gpio_set_wake = gpio_set_wake,
+};
+
 static struct platform_device *devices[] __initdata = {
-       &pxa_device_gpio,
        &pxa27x_device_udc,
        &pxa_device_pmu,
        &pxa_device_i2s,
@@ -458,6 +461,7 @@ static int __init pxa27x_init(void)
                register_syscore_ops(&pxa2xx_mfp_syscore_ops);
                register_syscore_ops(&pxa2xx_clock_syscore_ops);
 
+               pxa_register_device(&pxa_device_gpio, &pxa27x_gpio_info);
                ret = platform_add_devices(devices, ARRAY_SIZE(devices));
        }
 
index 0f3a327ebcaa380c823d251f65eb819bac9033a0..b34287ab5afd93502e9b5779918085c3b8eb68ec 100644 (file)
@@ -111,10 +111,6 @@ config S3C24XX_SETUP_TS
        help
          Compile in platform device definition for Samsung TouchScreen.
 
-# cpu-specific sections
-
-if CPU_S3C2410
-
 config S3C2410_DMA
        bool
        depends on S3C24XX_DMA && (CPU_S3C2410 || CPU_S3C2442)
@@ -127,6 +123,10 @@ config S3C2410_PM
        help
          Power Management code common to S3C2410 and better
 
+# cpu-specific sections
+
+if CPU_S3C2410
+
 config S3C24XX_SIMTEC_NOR
        bool
        help
index a8933de3d627ca922c3560d1a907c7761f054097..32395664e87917f640cdc70b74f287304a939b6a 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
 #include <linux/gpio.h>
+#include <linux/mmc/host.h>
 #include <linux/interrupt.h>
 
 #include <asm/hardware/vic.h>
@@ -765,6 +766,7 @@ static void __init goni_pmic_init(void)
 /* MoviNAND */
 static struct s3c_sdhci_platdata goni_hsmmc0_data __initdata = {
        .max_width              = 4,
+       .host_caps2             = MMC_CAP2_BROKEN_VOLTAGE,
        .cd_type                = S3C_SDHCI_CD_PERMANENT,
 };
 
index 7c524b4e415d7ec7843dcbd7987c663d2f447bd9..16be4c56abe3ff37a153807b93d066c49c0d94ab 100644 (file)
@@ -306,7 +306,7 @@ void sa11x0_register_irda(struct irda_platform_data *irda)
 }
 
 static struct resource sa1100_rtc_resources[] = {
-       DEFINE_RES_MEM(0x90010000, 0x9001003f),
+       DEFINE_RES_MEM(0x90010000, 0x40),
        DEFINE_RES_IRQ_NAMED(IRQ_RTC1Hz, "rtc 1Hz"),
        DEFINE_RES_IRQ_NAMED(IRQ_RTCAlrm, "rtc alarm"),
 };
index 1621ad07d284fea97626fea99a3e5535844c8417..33339745d432bdf185f23d46a59f4dd1bb9f8eca 100644 (file)
@@ -1667,8 +1667,10 @@ void __init u300_init_irq(void)
 
        for (i = 0; i < U300_VIC_IRQS_END; i++)
                set_bit(i, (unsigned long *) &mask[0]);
-       vic_init((void __iomem *) U300_INTCON0_VBASE, 0, mask[0], mask[0]);
-       vic_init((void __iomem *) U300_INTCON1_VBASE, 32, mask[1], mask[1]);
+       vic_init((void __iomem *) U300_INTCON0_VBASE, IRQ_U300_INTCON0_START,
+                mask[0], mask[0]);
+       vic_init((void __iomem *) U300_INTCON1_VBASE, IRQ_U300_INTCON1_START,
+                mask[1], mask[1]);
 }
 
 
index a38f80238ea97f08a69a9e42fb80a430404ff4a5..cb04bd6ab3e7f07248f57372015cec729e030798 100644 (file)
@@ -146,9 +146,6 @@ static struct ab3100_platform_data ab3100_plf_data = {
                                .min_uV = 1800000,
                                .max_uV = 1800000,
                                .valid_modes_mask = REGULATOR_MODE_NORMAL,
-                               .valid_ops_mask =
-                               REGULATOR_CHANGE_VOLTAGE |
-                               REGULATOR_CHANGE_STATUS,
                                .always_on = 1,
                                .boot_on = 1,
                        },
@@ -160,9 +157,6 @@ static struct ab3100_platform_data ab3100_plf_data = {
                                .min_uV = 2500000,
                                .max_uV = 2500000,
                                .valid_modes_mask = REGULATOR_MODE_NORMAL,
-                               .valid_ops_mask =
-                               REGULATOR_CHANGE_VOLTAGE |
-                               REGULATOR_CHANGE_STATUS,
                                .always_on = 1,
                                .boot_on = 1,
                        },
@@ -230,8 +224,7 @@ static struct ab3100_platform_data ab3100_plf_data = {
                                .max_uV = 1800000,
                                .valid_modes_mask = REGULATOR_MODE_NORMAL,
                                .valid_ops_mask =
-                               REGULATOR_CHANGE_VOLTAGE |
-                               REGULATOR_CHANGE_STATUS,
+                               REGULATOR_CHANGE_VOLTAGE,
                                .always_on = 1,
                                .boot_on = 1,
                        },
index ee78a26707ebe595f00265ccbc3c09a52ea4c1d3..ec09c1e07b1a8f6655e1887c353031f6471bc7f9 100644 (file)
 #ifndef __MACH_IRQS_H
 #define __MACH_IRQS_H
 
-#define IRQ_U300_INTCON0_START         0
-#define IRQ_U300_INTCON1_START         32
+#define IRQ_U300_INTCON0_START         1
+#define IRQ_U300_INTCON1_START         33
 /* These are on INTCON0 - 30 lines */
-#define IRQ_U300_IRQ0_EXT              0
-#define IRQ_U300_IRQ1_EXT              1
-#define IRQ_U300_DMA                   2
-#define IRQ_U300_VIDEO_ENC_0           3
-#define IRQ_U300_VIDEO_ENC_1           4
-#define IRQ_U300_AAIF_RX               5
-#define IRQ_U300_AAIF_TX               6
-#define IRQ_U300_AAIF_VGPIO            7
-#define IRQ_U300_AAIF_WAKEUP           8
-#define IRQ_U300_PCM_I2S0_FRAME                9
-#define IRQ_U300_PCM_I2S0_FIFO         10
-#define IRQ_U300_PCM_I2S1_FRAME                11
-#define IRQ_U300_PCM_I2S1_FIFO         12
-#define IRQ_U300_XGAM_GAMCON           13
-#define IRQ_U300_XGAM_CDI              14
-#define IRQ_U300_XGAM_CDICON           15
+#define IRQ_U300_IRQ0_EXT              1
+#define IRQ_U300_IRQ1_EXT              2
+#define IRQ_U300_DMA                   3
+#define IRQ_U300_VIDEO_ENC_0           4
+#define IRQ_U300_VIDEO_ENC_1           5
+#define IRQ_U300_AAIF_RX               6
+#define IRQ_U300_AAIF_TX               7
+#define IRQ_U300_AAIF_VGPIO            8
+#define IRQ_U300_AAIF_WAKEUP           9
+#define IRQ_U300_PCM_I2S0_FRAME                10
+#define IRQ_U300_PCM_I2S0_FIFO         11
+#define IRQ_U300_PCM_I2S1_FRAME                12
+#define IRQ_U300_PCM_I2S1_FIFO         13
+#define IRQ_U300_XGAM_GAMCON           14
+#define IRQ_U300_XGAM_CDI              15
+#define IRQ_U300_XGAM_CDICON           16
 #if defined(CONFIG_MACH_U300_BS2X) || defined(CONFIG_MACH_U300_BS330)
 /* MMIACC not used on the DB3210 or DB3350 chips */
-#define IRQ_U300_XGAM_MMIACC           16
+#define IRQ_U300_XGAM_MMIACC           17
 #endif
-#define IRQ_U300_XGAM_PDI              17
-#define IRQ_U300_XGAM_PDICON           18
-#define IRQ_U300_XGAM_GAMEACC          19
-#define IRQ_U300_XGAM_MCIDCT           20
-#define IRQ_U300_APEX                  21
-#define IRQ_U300_UART0                 22
-#define IRQ_U300_SPI                   23
-#define IRQ_U300_TIMER_APP_OS          24
-#define IRQ_U300_TIMER_APP_DD          25
-#define IRQ_U300_TIMER_APP_GP1         26
-#define IRQ_U300_TIMER_APP_GP2         27
-#define IRQ_U300_TIMER_OS              28
-#define IRQ_U300_TIMER_MS              29
-#define IRQ_U300_KEYPAD_KEYBF          30
-#define IRQ_U300_KEYPAD_KEYBR          31
+#define IRQ_U300_XGAM_PDI              18
+#define IRQ_U300_XGAM_PDICON           19
+#define IRQ_U300_XGAM_GAMEACC          20
+#define IRQ_U300_XGAM_MCIDCT           21
+#define IRQ_U300_APEX                  22
+#define IRQ_U300_UART0                 23
+#define IRQ_U300_SPI                   24
+#define IRQ_U300_TIMER_APP_OS          25
+#define IRQ_U300_TIMER_APP_DD          26
+#define IRQ_U300_TIMER_APP_GP1         27
+#define IRQ_U300_TIMER_APP_GP2         28
+#define IRQ_U300_TIMER_OS              29
+#define IRQ_U300_TIMER_MS              30
+#define IRQ_U300_KEYPAD_KEYBF          31
+#define IRQ_U300_KEYPAD_KEYBR          32
 /* These are on INTCON1 - 32 lines */
-#define IRQ_U300_GPIO_PORT0            32
-#define IRQ_U300_GPIO_PORT1            33
-#define IRQ_U300_GPIO_PORT2            34
+#define IRQ_U300_GPIO_PORT0            33
+#define IRQ_U300_GPIO_PORT1            34
+#define IRQ_U300_GPIO_PORT2            35
 
 #if defined(CONFIG_MACH_U300_BS2X) || defined(CONFIG_MACH_U300_BS330) || \
     defined(CONFIG_MACH_U300_BS335)
 /* These are for DB3150, DB3200 and DB3350 */
-#define IRQ_U300_WDOG                  35
-#define IRQ_U300_EVHIST                        36
-#define IRQ_U300_MSPRO                 37
-#define IRQ_U300_MMCSD_MCIINTR0                38
-#define IRQ_U300_MMCSD_MCIINTR1                39
-#define IRQ_U300_I2C0                  40
-#define IRQ_U300_I2C1                  41
-#define IRQ_U300_RTC                   42
-#define IRQ_U300_NFIF                  43
-#define IRQ_U300_NFIF2                 44
+#define IRQ_U300_WDOG                  36
+#define IRQ_U300_EVHIST                        37
+#define IRQ_U300_MSPRO                 38
+#define IRQ_U300_MMCSD_MCIINTR0                39
+#define IRQ_U300_MMCSD_MCIINTR1                40
+#define IRQ_U300_I2C0                  41
+#define IRQ_U300_I2C1                  42
+#define IRQ_U300_RTC                   43
+#define IRQ_U300_NFIF                  44
+#define IRQ_U300_NFIF2                 45
 #endif
 
 /* DB3150 and DB3200 have only 45 IRQs */
 #if defined(CONFIG_MACH_U300_BS2X) || defined(CONFIG_MACH_U300_BS330)
-#define U300_VIC_IRQS_END              45
+#define U300_VIC_IRQS_END              46
 #endif
 
 /* The DB3350-specific interrupt lines */
 #ifdef CONFIG_MACH_U300_BS335
-#define IRQ_U300_ISP_F0                        45
-#define IRQ_U300_ISP_F1                        46
-#define IRQ_U300_ISP_F2                        47
-#define IRQ_U300_ISP_F3                        48
-#define IRQ_U300_ISP_F4                        49
-#define IRQ_U300_GPIO_PORT3            50
-#define IRQ_U300_SYSCON_PLL_LOCK       51
-#define IRQ_U300_UART1                 52
-#define IRQ_U300_GPIO_PORT4            53
-#define IRQ_U300_GPIO_PORT5            54
-#define IRQ_U300_GPIO_PORT6            55
-#define U300_VIC_IRQS_END              56
+#define IRQ_U300_ISP_F0                        46
+#define IRQ_U300_ISP_F1                        47
+#define IRQ_U300_ISP_F2                        48
+#define IRQ_U300_ISP_F3                        49
+#define IRQ_U300_ISP_F4                        50
+#define IRQ_U300_GPIO_PORT3            51
+#define IRQ_U300_SYSCON_PLL_LOCK       52
+#define IRQ_U300_UART1                 53
+#define IRQ_U300_GPIO_PORT4            54
+#define IRQ_U300_GPIO_PORT5            55
+#define IRQ_U300_GPIO_PORT6            56
+#define U300_VIC_IRQS_END              57
 #endif
 
 /* The DB3210-specific interrupt lines */
 #ifdef CONFIG_MACH_U300_BS365
-#define IRQ_U300_GPIO_PORT3            35
-#define IRQ_U300_GPIO_PORT4            36
-#define IRQ_U300_WDOG                  37
-#define IRQ_U300_EVHIST                        38
-#define IRQ_U300_MSPRO                 39
-#define IRQ_U300_MMCSD_MCIINTR0                40
-#define IRQ_U300_MMCSD_MCIINTR1                41
-#define IRQ_U300_I2C0                  42
-#define IRQ_U300_I2C1                  43
-#define IRQ_U300_RTC                   44
-#define IRQ_U300_NFIF                  45
-#define IRQ_U300_NFIF2                 46
-#define IRQ_U300_SYSCON_PLL_LOCK       47
-#define U300_VIC_IRQS_END              48
+#define IRQ_U300_GPIO_PORT3            36
+#define IRQ_U300_GPIO_PORT4            37
+#define IRQ_U300_WDOG                  38
+#define IRQ_U300_EVHIST                        39
+#define IRQ_U300_MSPRO                 40
+#define IRQ_U300_MMCSD_MCIINTR0                41
+#define IRQ_U300_MMCSD_MCIINTR1                42
+#define IRQ_U300_I2C0                  43
+#define IRQ_U300_I2C1                  44
+#define IRQ_U300_RTC                   45
+#define IRQ_U300_NFIF                  46
+#define IRQ_U300_NFIF2                 47
+#define IRQ_U300_SYSCON_PLL_LOCK       48
+#define U300_VIC_IRQS_END              49
 #endif
 
 /* Maximum 8*7 GPIO lines */
 #define IRQ_U300_GPIO_END              (U300_VIC_IRQS_END)
 #endif
 
-#define NR_IRQS                                (IRQ_U300_GPIO_END)
+#define NR_IRQS                                (IRQ_U300_GPIO_END - IRQ_U300_INTCON0_START)
 
 #endif
index 2b2d51caf9d8b9f4db2e62c1eaa7a596b3313546..0127490218cdfc4bc00b107be2816a84703d6a4f 100644 (file)
@@ -168,7 +168,7 @@ static ssize_t mbox_read_fifo(struct device *dev,
        return sprintf(buf, "0x%X\n", mbox_value);
 }
 
-static DEVICE_ATTR(fifo, S_IWUGO | S_IRUGO, mbox_read_fifo, mbox_write_fifo);
+static DEVICE_ATTR(fifo, S_IWUSR | S_IRUGO, mbox_read_fifo, mbox_write_fifo);
 
 static int mbox_show(struct seq_file *s, void *data)
 {
index ff1f7cc11f87bdee1509757c7cd0c3cf7c105754..80741992a9fcff0b98d963ec3465bf407c51c5f6 100644 (file)
@@ -26,18 +26,23 @@ ENTRY(v6_early_abort)
        mrc     p15, 0, r1, c5, c0, 0           @ get FSR
        mrc     p15, 0, r0, c6, c0, 0           @ get FAR
 /*
- * Faulty SWP instruction on 1136 doesn't set bit 11 in DFSR (erratum 326103).
- * The test below covers all the write situations, including Java bytecodes
+ * Faulty SWP instruction on 1136 doesn't set bit 11 in DFSR.
  */
-       bic     r1, r1, #1 << 11                @ clear bit 11 of FSR
+#ifdef CONFIG_ARM_ERRATA_326103
+       ldr     ip, =0x4107b36
+       mrc     p15, 0, r3, c0, c0, 0           @ get processor id
+       teq     ip, r3, lsr #4                  @ r0 ARM1136?
+       bne     do_DataAbort
        tst     r5, #PSR_J_BIT                  @ Java?
+       tsteq   r5, #PSR_T_BIT                  @ Thumb?
        bne     do_DataAbort
-       do_thumb_abort fsr=r1, pc=r4, psr=r5, tmp=r3
-       ldreq   r3, [r4]                        @ read aborted ARM instruction
+       bic     r1, r1, #1 << 11                @ clear bit 11 of FSR
+       ldr     r3, [r4]                        @ read aborted ARM instruction
 #ifdef CONFIG_CPU_ENDIAN_BE8
-       reveq   r3, r3
+       rev     r3, r3
 #endif
        do_ldrd_abort tmp=ip, insn=r3
        tst     r3, #1 << 20                    @ L = 0 -> write
        orreq   r1, r1, #1 << 11                @ yes.
+#endif
        b       do_DataAbort
index a53fd2aaa2f4b59397bfa01847b22cd991bcdd8b..2a8e380501e81a2c0bcaf08c8d018f0c9f20050c 100644 (file)
@@ -32,6 +32,7 @@ static void __iomem *l2x0_base;
 static DEFINE_RAW_SPINLOCK(l2x0_lock);
 static u32 l2x0_way_mask;      /* Bitmask of active ways */
 static u32 l2x0_size;
+static unsigned long sync_reg_offset = L2X0_CACHE_SYNC;
 
 struct l2x0_regs l2x0_saved_regs;
 
@@ -61,12 +62,7 @@ static inline void cache_sync(void)
 {
        void __iomem *base = l2x0_base;
 
-#ifdef CONFIG_PL310_ERRATA_753970
-       /* write to an unmmapped register */
-       writel_relaxed(0, base + L2X0_DUMMY_REG);
-#else
-       writel_relaxed(0, base + L2X0_CACHE_SYNC);
-#endif
+       writel_relaxed(0, base + sync_reg_offset);
        cache_wait(base + L2X0_CACHE_SYNC, 1);
 }
 
@@ -85,10 +81,13 @@ static inline void l2x0_inv_line(unsigned long addr)
 }
 
 #if defined(CONFIG_PL310_ERRATA_588369) || defined(CONFIG_PL310_ERRATA_727915)
+static inline void debug_writel(unsigned long val)
+{
+       if (outer_cache.set_debug)
+               outer_cache.set_debug(val);
+}
 
-#define debug_writel(val)      outer_cache.set_debug(val)
-
-static void l2x0_set_debug(unsigned long val)
+static void pl310_set_debug(unsigned long val)
 {
        writel_relaxed(val, l2x0_base + L2X0_DEBUG_CTRL);
 }
@@ -98,7 +97,7 @@ static inline void debug_writel(unsigned long val)
 {
 }
 
-#define l2x0_set_debug NULL
+#define pl310_set_debug        NULL
 #endif
 
 #ifdef CONFIG_PL310_ERRATA_588369
@@ -331,6 +330,11 @@ void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask)
                else
                        ways = 8;
                type = "L310";
+#ifdef CONFIG_PL310_ERRATA_753970
+               /* Unmapped register. */
+               sync_reg_offset = L2X0_DUMMY_REG;
+#endif
+               outer_cache.set_debug = pl310_set_debug;
                break;
        case L2X0_CACHE_ID_PART_L210:
                ways = (aux >> 13) & 0xf;
@@ -379,7 +383,6 @@ void __init l2x0_init(void __iomem *base, u32 aux_val, u32 aux_mask)
        outer_cache.flush_all = l2x0_flush_all;
        outer_cache.inv_all = l2x0_inv_all;
        outer_cache.disable = l2x0_disable;
-       outer_cache.set_debug = l2x0_set_debug;
 
        printk(KERN_INFO "%s cache controller enabled\n", type);
        printk(KERN_INFO "l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x, Cache size: %d B\n",
index 595079fa9d1d2eb342afae05f3b29a4395b87331..8f5813bbffb560b15b44974ff3543f0b5457e026 100644 (file)
@@ -293,11 +293,11 @@ EXPORT_SYMBOL(pfn_valid);
 #endif
 
 #ifndef CONFIG_SPARSEMEM
-static void arm_memory_present(void)
+static void __init arm_memory_present(void)
 {
 }
 #else
-static void arm_memory_present(void)
+static void __init arm_memory_present(void)
 {
        struct memblock_region *reg;
 
index b86f8933ff918908e107afe40553388e0e207988..2c7cf2f9c837263504b139e44137ac027724bd0e 100644 (file)
@@ -618,8 +618,8 @@ static void __init alloc_init_section(pud_t *pud, unsigned long addr,
        }
 }
 
-static void alloc_init_pud(pgd_t *pgd, unsigned long addr, unsigned long end,
-       unsigned long phys, const struct mem_type *type)
+static void __init alloc_init_pud(pgd_t *pgd, unsigned long addr,
+       unsigned long end, unsigned long phys, const struct mem_type *type)
 {
        pud_t *pud = pud_offset(pgd, addr);
        unsigned long next;
index 2ed3ab173addcae894a1c52190e7cc9419dddc90..5079787273d27a4ca0b54cd63bcf62008120847a 100644 (file)
@@ -41,6 +41,7 @@
 #include <mach/clock.h>
 #include <mach/hardware.h>
 
+#ifndef CONFIG_COMMON_CLK
 static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
 
@@ -200,6 +201,16 @@ struct clk *clk_get_parent(struct clk *clk)
 }
 EXPORT_SYMBOL(clk_get_parent);
 
+#else
+
+/*
+ * Lock to protect the clock module (ccm) registers. Used
+ * on all i.MXs
+ */
+DEFINE_SPINLOCK(imx_ccm_lock);
+
+#endif /* CONFIG_COMMON_CLK */
+
 /*
  * Get the resulting clock rate from a PLL register value and the input
  * frequency. PLLs with this register layout can at least be found on
index 753a5988d85c16e9c28181f632462d9e47e60c74..bd940c795cbbff0c3a1785247e43aac1a43e7acf 100644 (file)
@@ -23,6 +23,7 @@
 #ifndef __ASSEMBLY__
 #include <linux/list.h>
 
+#ifndef CONFIG_COMMON_CLK
 struct module;
 
 struct clk {
@@ -59,6 +60,9 @@ struct clk {
 
 int clk_register(struct clk *clk);
 void clk_unregister(struct clk *clk);
+#endif /* CONFIG_COMMON_CLK */
+
+extern spinlock_t imx_ccm_lock;
 
 unsigned long mxc_decode_pll(unsigned int pll, u32 f_ref);
 
index 7daf7c9a413bf62eb9a7ad86f659a0eadf016d44..99f958ca6cb8c34ac650896418d1dc8e1a4cd247 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/irq.h>
 #include <linux/clockchips.h>
 #include <linux/clk.h>
+#include <linux/err.h>
 
 #include <mach/hardware.h>
 #include <asm/sched_clock.h>
@@ -282,6 +283,19 @@ static int __init mxc_clockevent_init(struct clk *timer_clk)
 void __init mxc_timer_init(struct clk *timer_clk, void __iomem *base, int irq)
 {
        uint32_t tctl_val;
+       struct clk *timer_ipg_clk;
+
+       if (!timer_clk) {
+               timer_clk = clk_get_sys("imx-gpt.0", "per");
+               if (IS_ERR(timer_clk)) {
+                       pr_err("i.MX timer: unable to get clk\n");
+                       return;
+               }
+
+               timer_ipg_clk = clk_get_sys("imx-gpt.0", "ipg");
+               if (!IS_ERR(timer_ipg_clk))
+                       clk_prepare_enable(timer_ipg_clk);
+       }
 
        clk_prepare_enable(timer_clk);
 
index ecdb3da0dea93704086df1f83dff342813c3afd3..c58d896cd5c39dba0ab5950d4fb69a657e0a5d0a 100644 (file)
@@ -916,6 +916,13 @@ void omap_start_dma(int lch)
                        l |= OMAP_DMA_CCR_BUFFERING_DISABLE;
        l |= OMAP_DMA_CCR_EN;
 
+       /*
+        * As dma_write() uses IO accessors which are weakly ordered, there
+        * is no guarantee that data in coherent DMA memory will be visible
+        * to the DMA device.  Add a memory barrier here to ensure that any
+        * such data is visible prior to enabling DMA.
+        */
+       mb();
        p->dma_write(l, CCR, lch);
 
        dma_chan[lch].flags |= OMAP_DMA_ACTIVE;
@@ -965,6 +972,13 @@ void omap_stop_dma(int lch)
                p->dma_write(l, CCR, lch);
        }
 
+       /*
+        * Ensure that data transferred by DMA is visible to any access
+        * after DMA has been disabled.  This is important for coherent
+        * DMA regions.
+        */
+       mb();
+
        if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) {
                int next_lch, cur_lch = lch;
                char dma_chan_link_map[dma_lch_count];
index 317e246ffc5604e1c0712054b90c5da23654a6da..e834c5ef437c3c857cfe02d55f84df3307fa35e8 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef __PLAT_S3C_SDHCI_H
 #define __PLAT_S3C_SDHCI_H __FILE__
 
+#include <plat/devs.h>
+
 struct platform_device;
 struct mmc_host;
 struct mmc_card;
@@ -356,4 +358,30 @@ static inline void exynos4_default_sdhci3(void) { }
 
 #endif /* CONFIG_EXYNOS4_SETUP_SDHCI */
 
+static inline void s3c_sdhci_setname(int id, char *name)
+{
+       switch (id) {
+#ifdef CONFIG_S3C_DEV_HSMMC
+       case 0:
+               s3c_device_hsmmc0.name = name;
+               break;
+#endif
+#ifdef CONFIG_S3C_DEV_HSMMC1
+       case 1:
+               s3c_device_hsmmc1.name = name;
+               break;
+#endif
+#ifdef CONFIG_S3C_DEV_HSMMC2
+       case 2:
+               s3c_device_hsmmc2.name = name;
+               break;
+#endif
+#ifdef CONFIG_S3C_DEV_HSMMC3
+       case 3:
+               s3c_device_hsmmc3.name = name;
+               break;
+#endif
+       }
+}
+
 #endif /* __PLAT_S3C_SDHCI_H */
index 858748eaa144f91c7f9b4c88fbc8bb83a8d419d7..bc683b8219b5bf3715345742b0d41d4746e4746b 100644 (file)
@@ -17,6 +17,8 @@
 #include <linux/sched.h>
 #include <linux/smp.h>
 #include <linux/init.h>
+#include <linux/uaccess.h>
+#include <linux/user.h>
 
 #include <asm/cp15.h>
 #include <asm/cputype.h>
@@ -528,6 +530,103 @@ void vfp_flush_hwstate(struct thread_info *thread)
        put_cpu();
 }
 
+/*
+ * Save the current VFP state into the provided structures and prepare
+ * for entry into a new function (signal handler).
+ */
+int vfp_preserve_user_clear_hwstate(struct user_vfp __user *ufp,
+                                   struct user_vfp_exc __user *ufp_exc)
+{
+       struct thread_info *thread = current_thread_info();
+       struct vfp_hard_struct *hwstate = &thread->vfpstate.hard;
+       int err = 0;
+
+       /* Ensure that the saved hwstate is up-to-date. */
+       vfp_sync_hwstate(thread);
+
+       /*
+        * Copy the floating point registers. There can be unused
+        * registers see asm/hwcap.h for details.
+        */
+       err |= __copy_to_user(&ufp->fpregs, &hwstate->fpregs,
+                             sizeof(hwstate->fpregs));
+       /*
+        * Copy the status and control register.
+        */
+       __put_user_error(hwstate->fpscr, &ufp->fpscr, err);
+
+       /*
+        * Copy the exception registers.
+        */
+       __put_user_error(hwstate->fpexc, &ufp_exc->fpexc, err);
+       __put_user_error(hwstate->fpinst, &ufp_exc->fpinst, err);
+       __put_user_error(hwstate->fpinst2, &ufp_exc->fpinst2, err);
+
+       if (err)
+               return -EFAULT;
+
+       /* Ensure that VFP is disabled. */
+       vfp_flush_hwstate(thread);
+
+       /*
+        * As per the PCS, clear the length and stride bits for function
+        * entry.
+        */
+       hwstate->fpscr &= ~(FPSCR_LENGTH_MASK | FPSCR_STRIDE_MASK);
+
+       /*
+        * Disable VFP in the hwstate so that we can detect if it gets
+        * used.
+        */
+       hwstate->fpexc &= ~FPEXC_EN;
+       return 0;
+}
+
+/* Sanitise and restore the current VFP state from the provided structures. */
+int vfp_restore_user_hwstate(struct user_vfp __user *ufp,
+                            struct user_vfp_exc __user *ufp_exc)
+{
+       struct thread_info *thread = current_thread_info();
+       struct vfp_hard_struct *hwstate = &thread->vfpstate.hard;
+       unsigned long fpexc;
+       int err = 0;
+
+       /*
+        * If VFP has been used, then disable it to avoid corrupting
+        * the new thread state.
+        */
+       if (hwstate->fpexc & FPEXC_EN)
+               vfp_flush_hwstate(thread);
+
+       /*
+        * Copy the floating point registers. There can be unused
+        * registers see asm/hwcap.h for details.
+        */
+       err |= __copy_from_user(&hwstate->fpregs, &ufp->fpregs,
+                               sizeof(hwstate->fpregs));
+       /*
+        * Copy the status and control register.
+        */
+       __get_user_error(hwstate->fpscr, &ufp->fpscr, err);
+
+       /*
+        * Sanitise and restore the exception registers.
+        */
+       __get_user_error(fpexc, &ufp_exc->fpexc, err);
+
+       /* Ensure the VFP is enabled. */
+       fpexc |= FPEXC_EN;
+
+       /* Ensure FPINST2 is invalid and the exception flag is cleared. */
+       fpexc &= ~(FPEXC_EX | FPEXC_FP2V);
+       hwstate->fpexc = fpexc;
+
+       __get_user_error(hwstate->fpinst, &ufp_exc->fpinst, err);
+       __get_user_error(hwstate->fpinst2, &ufp_exc->fpinst2, err);
+
+       return err ? -EFAULT : 0;
+}
+
 /*
  * VFP hardware can lose all context when a CPU goes offline.
  * As we will be running in SMP mode with CPU hotplug, we will save the
index 1633a6f306c0e1390fedf5dd12dd805c5ac9c704..85038f54354dc78ac514655972d021e4a0cb63e6 100644 (file)
@@ -38,7 +38,7 @@ static struct platform_device rtc_device = {
        .name = "rtc-bfin",
        .id   = -1,
 };
-#endif
+#endif /* CONFIG_RTC_DRV_BFIN */
 
 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
 #ifdef CONFIG_SERIAL_BFIN_UART0
@@ -100,7 +100,7 @@ static struct platform_device bfin_uart0_device = {
                .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
        },
 };
-#endif
+#endif /* CONFIG_SERIAL_BFIN_UART0 */
 #ifdef CONFIG_SERIAL_BFIN_UART1
 static struct resource bfin_uart1_resources[] = {
        {
@@ -148,7 +148,7 @@ static struct platform_device bfin_uart1_device = {
                .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
        },
 };
-#endif
+#endif /* CONFIG_SERIAL_BFIN_UART1 */
 #ifdef CONFIG_SERIAL_BFIN_UART2
 static struct resource bfin_uart2_resources[] = {
        {
@@ -196,8 +196,8 @@ static struct platform_device bfin_uart2_device = {
                .platform_data = &bfin_uart2_peripherals, /* Passed to driver */
        },
 };
-#endif
-#endif
+#endif /* CONFIG_SERIAL_BFIN_UART2 */
+#endif /* CONFIG_SERIAL_BFIN */
 
 #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
 #ifdef CONFIG_BFIN_SIR0
@@ -224,7 +224,7 @@ static struct platform_device bfin_sir0_device = {
        .num_resources = ARRAY_SIZE(bfin_sir0_resources),
        .resource = bfin_sir0_resources,
 };
-#endif
+#endif /* CONFIG_BFIN_SIR0 */
 #ifdef CONFIG_BFIN_SIR1
 static struct resource bfin_sir1_resources[] = {
        {
@@ -249,7 +249,7 @@ static struct platform_device bfin_sir1_device = {
        .num_resources = ARRAY_SIZE(bfin_sir1_resources),
        .resource = bfin_sir1_resources,
 };
-#endif
+#endif /* CONFIG_BFIN_SIR1 */
 #ifdef CONFIG_BFIN_SIR2
 static struct resource bfin_sir2_resources[] = {
        {
@@ -274,8 +274,8 @@ static struct platform_device bfin_sir2_device = {
        .num_resources = ARRAY_SIZE(bfin_sir2_resources),
        .resource = bfin_sir2_resources,
 };
-#endif
-#endif
+#endif /* CONFIG_BFIN_SIR2 */
+#endif /* CONFIG_BFIN_SIR */
 
 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
@@ -311,7 +311,7 @@ static struct platform_device bfin_sport0_uart_device = {
                .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
        },
 };
-#endif
+#endif /* CONFIG_SERIAL_BFIN_SPORT0_UART */
 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
 static struct resource bfin_sport1_uart_resources[] = {
        {
@@ -345,7 +345,7 @@ static struct platform_device bfin_sport1_uart_device = {
                .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
        },
 };
-#endif
+#endif /* CONFIG_SERIAL_BFIN_SPORT1_UART */
 #ifdef CONFIG_SERIAL_BFIN_SPORT2_UART
 static struct resource bfin_sport2_uart_resources[] = {
        {
@@ -379,7 +379,7 @@ static struct platform_device bfin_sport2_uart_device = {
                .platform_data = &bfin_sport2_peripherals, /* Passed to driver */
        },
 };
-#endif
+#endif /* CONFIG_SERIAL_BFIN_SPORT2_UART */
 #ifdef CONFIG_SERIAL_BFIN_SPORT3_UART
 static struct resource bfin_sport3_uart_resources[] = {
        {
@@ -413,8 +413,8 @@ static struct platform_device bfin_sport3_uart_device = {
                .platform_data = &bfin_sport3_peripherals, /* Passed to driver */
        },
 };
-#endif
-#endif
+#endif /* CONFIG_SERIAL_BFIN_SPORT3_UART */
+#endif /* CONFIG_SERIAL_BFIN_SPORT */
 
 #if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE)
 static unsigned short bfin_can_peripherals[] = {
@@ -452,7 +452,7 @@ static struct platform_device bfin_can_device = {
                .platform_data = &bfin_can_peripherals, /* Passed to driver */
        },
 };
-#endif
+#endif /* CONFIG_CAN_BFIN */
 
 /*
  *  USB-LAN EzExtender board
@@ -488,7 +488,7 @@ static struct platform_device smc91x_device = {
                .platform_data  = &smc91x_info,
        },
 };
-#endif
+#endif /* CONFIG_SMC91X */
 
 #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
 /* all SPI peripherals info goes here */
@@ -518,7 +518,8 @@ static struct flash_platform_data bfin_spi_flash_data = {
 static struct bfin5xx_spi_chip spi_flash_chip_info = {
        .enable_dma = 0,         /* use dma transfer with this chip*/
 };
-#endif
+#endif /* CONFIG_MTD_M25P80 */
+#endif /* CONFIG_SPI_BFIN5XX */
 
 #if defined(CONFIG_TOUCHSCREEN_AD7879) || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
 #include <linux/spi/ad7879.h>
@@ -535,7 +536,7 @@ static const struct ad7879_platform_data bfin_ad7879_ts_info = {
        .gpio_export            = 1,    /* Export GPIO to gpiolib */
        .gpio_base              = -1,   /* Dynamic allocation */
 };
-#endif
+#endif /* CONFIG_TOUCHSCREEN_AD7879 */
 
 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
 #include <asm/bfin-lq035q1.h>
@@ -564,7 +565,7 @@ static struct platform_device bfin_lq035q1_device = {
                .platform_data = &bfin_lq035q1_data,
        },
 };
-#endif
+#endif /* CONFIG_FB_BFIN_LQ035Q1 */
 
 static struct spi_board_info bf538_spi_board_info[] __initdata = {
 #if defined(CONFIG_MTD_M25P80) \
@@ -579,7 +580,7 @@ static struct spi_board_info bf538_spi_board_info[] __initdata = {
                .controller_data = &spi_flash_chip_info,
                .mode = SPI_MODE_3,
        },
-#endif
+#endif /* CONFIG_MTD_M25P80 */
 #if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
        {
                .modalias = "ad7879",
@@ -590,7 +591,7 @@ static struct spi_board_info bf538_spi_board_info[] __initdata = {
                .chip_select = 1,
                .mode = SPI_CPHA | SPI_CPOL,
        },
-#endif
+#endif /* CONFIG_TOUCHSCREEN_AD7879_SPI */
 #if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
        {
                .modalias = "bfin-lq035q1-spi",
@@ -599,7 +600,7 @@ static struct spi_board_info bf538_spi_board_info[] __initdata = {
                .chip_select = 2,
                .mode = SPI_CPHA | SPI_CPOL,
        },
-#endif
+#endif /* CONFIG_FB_BFIN_LQ035Q1 */
 #if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
        {
                .modalias = "spidev",
@@ -607,7 +608,7 @@ static struct spi_board_info bf538_spi_board_info[] __initdata = {
                .bus_num = 0,
                .chip_select = 1,
        },
-#endif
+#endif /* CONFIG_SPI_SPIDEV */
 };
 
 /* SPI (0) */
@@ -716,8 +717,6 @@ static struct platform_device bf538_spi_master2 = {
                },
 };
 
-#endif  /* spi master and devices */
-
 #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
 static struct resource bfin_twi0_resource[] = {
        [0] = {
@@ -759,8 +758,8 @@ static struct platform_device i2c_bfin_twi1_device = {
        .num_resources = ARRAY_SIZE(bfin_twi1_resource),
        .resource = bfin_twi1_resource,
 };
-#endif
-#endif
+#endif /* CONFIG_BF542 */
+#endif /* CONFIG_I2C_BLACKFIN_TWI */
 
 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
 #include <linux/gpio_keys.h>
index 37302218ca4a2e9243bf0fc192047d12c4eac365..0f2367cc549311a3c8ba1911b0707699435716b2 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/bootmem.h>
 #include <linux/genalloc.h>
 #include <asm/dma-mapping.h>
+#include <linux/module.h>
 
 struct dma_map_ops *dma_ops;
 EXPORT_SYMBOL(dma_ops);
index 18c4f0b0f4baeb27adb741e7b88138aad100148a..ff02821bfb7ede3372d76d4f1657a1c3e08d1aea 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Process creation support for Hexagon
  *
- * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -88,7 +88,7 @@ void (*idle_sleep)(void) = default_idle;
 void cpu_idle(void)
 {
        while (1) {
-               tick_nohz_stop_sched_tick(1);
+               tick_nohz_idle_enter();
                local_irq_disable();
                while (!need_resched()) {
                        idle_sleep();
@@ -97,7 +97,7 @@ void cpu_idle(void)
                        local_irq_disable();
                }
                local_irq_enable();
-               tick_nohz_restart_sched_tick();
+               tick_nohz_idle_exit();
                schedule();
        }
 }
index 32342de1a79c7ae6951fe819c56de0d53a3b999d..96c3b2c4dbaded2a24bb0c62a13a5f669637c90d 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/ptrace.h>
 #include <linux/regset.h>
 #include <linux/user.h>
+#include <linux/elf.h>
 
 #include <asm/user.h>
 
index 9b44a9e2d05abcf77809cee85449d65bc78e8ef5..1298141874a3b4890d1dfab3c82529b49ecd5a78 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * SMP support for Hexagon
  *
- * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -28,6 +28,7 @@
 #include <linux/sched.h>
 #include <linux/smp.h>
 #include <linux/spinlock.h>
+#include <linux/cpu.h>
 
 #include <asm/time.h>    /*  timer_interrupt  */
 #include <asm/hexagon_vm.h>
@@ -177,7 +178,12 @@ void __cpuinit start_secondary(void)
 
        printk(KERN_INFO "%s cpu %d\n", __func__, current_thread_info()->cpu);
 
+       notify_cpu_starting(cpu);
+
+       ipi_call_lock();
        set_cpu_online(cpu, true);
+       ipi_call_unlock();
+
        local_irq_enable();
 
        cpu_idle();
index 6bee15c9c113d7854991597fa0d2f0b7af4f9b91..5d9b33b67935529a38c437be63c55f4556a7f0c3 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/module.h>
 
 #include <asm/timer-regs.h>
 #include <asm/hexagon_vm.h>
index f212a453b527d09accbd09c16dbfa5ae506745e1..5d39f42f7085bb1fec3c44a101dceb3615c0cc2d 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/err.h>
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
+#include <linux/binfmts.h>
 
 #include <asm/vdso.h>
 
index e21507052066fbfe5aaec7185286376f2eaf4d02..9c717bf98ffe629f9f9c4061bd49b9114a9a99f5 100644 (file)
@@ -58,8 +58,8 @@ static void __init ar913x_wmac_setup(void)
 
 static int ar933x_wmac_reset(void)
 {
-       ath79_device_reset_clear(AR933X_RESET_WMAC);
        ath79_device_reset_set(AR933X_RESET_WMAC);
+       ath79_device_reset_clear(AR933X_RESET_WMAC);
 
        return 0;
 }
index a865c983c70affffc26ce5c00ab8742df7a442e8..5ad1a9c113c624136c6f2bfd584906c72f62d7a5 100644 (file)
@@ -45,7 +45,7 @@
 #define JZ4740_IRQ_LCD         JZ4740_IRQ(30)
 
 /* 2nd-level interrupts */
-#define JZ4740_IRQ_DMA(x)      (JZ4740_IRQ(32) + (X))
+#define JZ4740_IRQ_DMA(x)      (JZ4740_IRQ(32) + (x))
 
 #define JZ4740_IRQ_INTC_GPIO(x) (JZ4740_IRQ_GPIO0 - (x))
 #define JZ4740_IRQ_GPIO(x)     (JZ4740_IRQ(48) + (x))
index 73c0d45798dec6cf00fc99021fc4bc00664ccaad..9b02cfba7449ff7ceb2a1b56d4f8876efef38ca5 100644 (file)
@@ -37,12 +37,6 @@ extern void tlbmiss_handler_setup_pgd(unsigned long pgd);
                write_c0_xcontext((unsigned long) smp_processor_id() << 51); \
        } while (0)
 
-
-static inline unsigned long get_current_pgd(void)
-{
-       return PHYS_TO_XKSEG_CACHED((read_c0_context() >> 11) & ~0xfffUL);
-}
-
 #else /* CONFIG_MIPS_PGD_C0_CONTEXT: using  pgd_current*/
 
 /*
index 185ca00c4c84d53be39e2d7e98031f37b6a0d5bf..d5a338a1739c9027fcc3db50c30a59f15f6c2e62 100644 (file)
@@ -257,11 +257,8 @@ asmlinkage int sys_sigsuspend(nabi_no_regargs struct pt_regs regs)
                return -EFAULT;
        sigdelsetmask(&newset, ~_BLOCKABLE);
 
-       spin_lock_irq(&current->sighand->siglock);
        current->saved_sigmask = current->blocked;
-       current->blocked = newset;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
+       set_current_blocked(&newset);
 
        current->state = TASK_INTERRUPTIBLE;
        schedule();
@@ -286,11 +283,8 @@ asmlinkage int sys_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
                return -EFAULT;
        sigdelsetmask(&newset, ~_BLOCKABLE);
 
-       spin_lock_irq(&current->sighand->siglock);
        current->saved_sigmask = current->blocked;
-       current->blocked = newset;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
+       set_current_blocked(&newset);
 
        current->state = TASK_INTERRUPTIBLE;
        schedule();
@@ -362,10 +356,7 @@ asmlinkage void sys_sigreturn(nabi_no_regargs struct pt_regs regs)
                goto badframe;
 
        sigdelsetmask(&blocked, ~_BLOCKABLE);
-       spin_lock_irq(&current->sighand->siglock);
-       current->blocked = blocked;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
+       set_current_blocked(&blocked);
 
        sig = restore_sigcontext(&regs, &frame->sf_sc);
        if (sig < 0)
@@ -401,10 +392,7 @@ asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
                goto badframe;
 
        sigdelsetmask(&set, ~_BLOCKABLE);
-       spin_lock_irq(&current->sighand->siglock);
-       current->blocked = set;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
+       set_current_blocked(&set);
 
        sig = restore_sigcontext(&regs, &frame->rs_uc.uc_mcontext);
        if (sig < 0)
@@ -580,12 +568,7 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
        if (ret)
                return ret;
 
-       spin_lock_irq(&current->sighand->siglock);
-       sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
-       if (!(ka->sa.sa_flags & SA_NODEFER))
-               sigaddset(&current->blocked, sig);
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
+       block_sigmask(ka, sig);
 
        return ret;
 }
index 06b5da392e243ec652ba0a2e1dd25128ac005305..ac3b8d89aae51a4a75f14249ddc5a4f894046087 100644 (file)
@@ -290,11 +290,8 @@ asmlinkage int sys32_sigsuspend(nabi_no_regargs struct pt_regs regs)
                return -EFAULT;
        sigdelsetmask(&newset, ~_BLOCKABLE);
 
-       spin_lock_irq(&current->sighand->siglock);
        current->saved_sigmask = current->blocked;
-       current->blocked = newset;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
+       set_current_blocked(&newset);
 
        current->state = TASK_INTERRUPTIBLE;
        schedule();
@@ -318,11 +315,8 @@ asmlinkage int sys32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
                return -EFAULT;
        sigdelsetmask(&newset, ~_BLOCKABLE);
 
-       spin_lock_irq(&current->sighand->siglock);
        current->saved_sigmask = current->blocked;
-       current->blocked = newset;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
+       set_current_blocked(&newset);
 
        current->state = TASK_INTERRUPTIBLE;
        schedule();
@@ -488,10 +482,7 @@ asmlinkage void sys32_sigreturn(nabi_no_regargs struct pt_regs regs)
                goto badframe;
 
        sigdelsetmask(&blocked, ~_BLOCKABLE);
-       spin_lock_irq(&current->sighand->siglock);
-       current->blocked = blocked;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
+       set_current_blocked(&blocked);
 
        sig = restore_sigcontext32(&regs, &frame->sf_sc);
        if (sig < 0)
@@ -529,10 +520,7 @@ asmlinkage void sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
                goto badframe;
 
        sigdelsetmask(&set, ~_BLOCKABLE);
-       spin_lock_irq(&current->sighand->siglock);
-       current->blocked = set;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
+       set_current_blocked(&set);
 
        sig = restore_sigcontext32(&regs, &frame->rs_uc.uc_mcontext);
        if (sig < 0)
index ae29e894ab8d0f0cf099d28dbcc1f6cf0751e546..86eb4b04631c43924527231da81e3e23a5b01d0e 100644 (file)
@@ -93,11 +93,8 @@ asmlinkage int sysn32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
        sigset_from_compat(&newset, &uset);
        sigdelsetmask(&newset, ~_BLOCKABLE);
 
-       spin_lock_irq(&current->sighand->siglock);
        current->saved_sigmask = current->blocked;
-       current->blocked = newset;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
+       set_current_blocked(&newset);
 
        current->state = TASK_INTERRUPTIBLE;
        schedule();
@@ -121,10 +118,7 @@ asmlinkage void sysn32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
                goto badframe;
 
        sigdelsetmask(&set, ~_BLOCKABLE);
-       spin_lock_irq(&current->sighand->siglock);
-       current->blocked = set;
-       recalc_sigpending();
-       spin_unlock_irq(&current->sighand->siglock);
+       set_current_blocked(&set);
 
        sig = restore_sigcontext(&regs, &frame->rs_uc.uc_mcontext);
        if (sig < 0)
index 4f004596a6e7ad920674fb14780c668fe015b965..0b3393381a81261209d8b0fac80d20b6db7654c2 100644 (file)
@@ -104,7 +104,7 @@ static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
 
 static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp)
 {
-       if (!tty->count) {
+       if (tty->count == 1) {
                del_timer_sync(&pdc_console_timer);
                tty_port_tty_set(&tty_port, NULL);
        }
diff --git a/arch/powerpc/boot/dts/fsl/pq3-mpic-message-B.dtsi b/arch/powerpc/boot/dts/fsl/pq3-mpic-message-B.dtsi
new file mode 100644 (file)
index 0000000..1cf0b77
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * PQ3 MPIC Message (Group B) device tree stub [ controller @ offset 0x42400 ]
+ *
+ * Copyright 2012 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Freescale Semiconductor nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+message@42400 {
+       compatible = "fsl,mpic-v3.1-msgr";
+       reg = <0x42400 0x200>;
+       interrupts = <
+               0xb4 2 0 0
+               0xb5 2 0 0
+               0xb6 2 0 0
+               0xb7 2 0 0>;
+};
index fdedf7b1fe0f2e25d47729470e1665be9615a3d8..71c30eb10056962c439d6e7900415d9c27c829fc 100644 (file)
@@ -53,6 +53,16 @@ timer@41100 {
                      3 0 3 0>;
 };
 
+message@41400 {
+       compatible = "fsl,mpic-v3.1-msgr";
+       reg = <0x41400 0x200>;
+       interrupts = <
+               0xb0 2 0 0
+               0xb1 2 0 0
+               0xb2 2 0 0
+               0xb3 2 0 0>;
+};
+
 msi@41600 {
        compatible = "fsl,mpic-msi";
        reg = <0x41600 0x80>;
index e648af92ced18b20384102912fbaeafc903ddfb0..0e40843a1c6ed58273c1a0e2eb22841e9007e977 100644 (file)
 #include <linux/atomic.h>
 
 
-/* Define a way to iterate across irqs. */
-#define for_each_irq(i) \
-       for ((i) = 0; (i) < NR_IRQS; ++(i))
-
 extern atomic_t ppc_n_lost_interrupts;
 
 /* This number is used when no interrupt has been assigned */
index c65b9294376ee8e2e1745cf73b014dc1f49d372e..c9f698a994be246860ee6cfdd6895d27d68cea7b 100644 (file)
@@ -275,9 +275,6 @@ struct mpic
        unsigned int            isu_mask;
        /* Number of sources */
        unsigned int            num_sources;
-       /* default senses array */
-       unsigned char           *senses;
-       unsigned int            senses_count;
 
        /* vector numbers used for internal sources (ipi/timers) */
        unsigned int            ipi_vecs[4];
@@ -415,21 +412,6 @@ extern struct mpic *mpic_alloc(struct device_node *node,
 extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
                            phys_addr_t phys_addr);
 
-/* Set default sense codes
- *
- * @mpic:      controller
- * @senses:    array of sense codes
- * @count:     size of above array
- *
- * Optionally provide an array (indexed on hardware interrupt numbers
- * for this MPIC) of default sense codes for the chip. Those are linux
- * sense codes IRQ_TYPE_*
- *
- * The driver gets ownership of the pointer, don't dispose of it or
- * anything like that. __init only.
- */
-extern void mpic_set_default_senses(struct mpic *mpic, u8 *senses, int count);
-
 
 /* Initialize the controller. After this has been called, none of the above
  * should be called again for this mpic
index 3ec37dc9003e2575ee7170c4786904ab0ac6ee95..326d33ca55cdc33e8b3cb112f0fefb8117bab3af 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/types.h>
 #include <linux/spinlock.h>
+#include <asm/smp.h>
 
 struct mpic_msgr {
        u32 __iomem *base;
index b86faa9107da24338d661d7acf7ba455da413974..8a97aa7289d36b155a1e01df4211a261a7a110e8 100644 (file)
 #ifndef __ASM_POWERPC_REG_BOOKE_H__
 #define __ASM_POWERPC_REG_BOOKE_H__
 
-#ifdef CONFIG_BOOKE_WDT
-extern u32 booke_wdt_enabled;
-extern u32 booke_wdt_period;
-#endif /* CONFIG_BOOKE_WDT */
-
 /* Machine State Register (MSR) Fields */
 #define MSR_GS         (1<<28) /* Guest state */
 #define MSR_UCLE       (1<<26) /* User-mode cache lock enable */
index 5ec1b2354ca62301b83019db2f342bd92c085b80..43eb74fcedde2806da8dd0c5193f3df4c91433dc 100644 (file)
@@ -330,14 +330,10 @@ void migrate_irqs(void)
 
        alloc_cpumask_var(&mask, GFP_KERNEL);
 
-       for_each_irq(irq) {
+       for_each_irq_desc(irq, desc) {
                struct irq_data *data;
                struct irq_chip *chip;
 
-               desc = irq_to_desc(irq);
-               if (!desc)
-                       continue;
-
                data = irq_desc_get_irq_data(desc);
                if (irqd_is_per_cpu(data))
                        continue;
index c957b1202bdca6162479f395c063979b73613ba8..5df777794403d49a3820add9ba6409701b295da4 100644 (file)
 
 void machine_kexec_mask_interrupts(void) {
        unsigned int i;
+       struct irq_desc *desc;
 
-       for_each_irq(i) {
-               struct irq_desc *desc = irq_to_desc(i);
+       for_each_irq_desc(i, desc) {
                struct irq_chip *chip;
 
-               if (!desc)
-                       continue;
-
                chip = irq_desc_get_chip(desc);
                if (!chip)
                        continue;
index 9825f29d1fafbcfd381aec51286137efa51830e9..ec8a53fa9e8f6a07f82b640426ef50f38e224d53 100644 (file)
@@ -150,6 +150,9 @@ notrace void __init machine_init(u64 dt_ptr)
 }
 
 #ifdef CONFIG_BOOKE_WDT
+extern u32 booke_wdt_enabled;
+extern u32 booke_wdt_period;
+
 /* Checks wdt=x and wdt_period=xx command-line option */
 notrace int __init early_parse_wdt(char *p)
 {
index af1ab5e9a691e6b3c70b8d08415992f8c2205049..5c3cf2d04e41ccaa6e8b7aa94eb7ca27ba4baad9 100644 (file)
 /*
  * Assembly helpers from arch/powerpc/net/bpf_jit.S:
  */
-extern u8 sk_load_word[], sk_load_half[], sk_load_byte[], sk_load_byte_msh[];
+#define DECLARE_LOAD_FUNC(func)        \
+       extern u8 func[], func##_negative_offset[], func##_positive_offset[]
+
+DECLARE_LOAD_FUNC(sk_load_word);
+DECLARE_LOAD_FUNC(sk_load_half);
+DECLARE_LOAD_FUNC(sk_load_byte);
+DECLARE_LOAD_FUNC(sk_load_byte_msh);
 
 #define FUNCTION_DESCR_SIZE    24
 
index ff4506e85cce80bc2fdb7003078cec3f5c0d9962..55ba3855a97f58093ec06f343cde1df2dffbb17b 100644 (file)
  * then branch directly to slow_path_XXX if required.  (In fact, could
  * load a spare GPR with the address of slow_path_generic and pass size
  * as an argument, making the call site a mtlr, li and bllr.)
- *
- * Technically, the "is addr < 0" check is unnecessary & slowing down
- * the ABS path, as it's statically checked on generation.
  */
        .globl  sk_load_word
 sk_load_word:
        cmpdi   r_addr, 0
-       blt     bpf_error
+       blt     bpf_slow_path_word_neg
+       .globl  sk_load_word_positive_offset
+sk_load_word_positive_offset:
        /* Are we accessing past headlen? */
        subi    r_scratch1, r_HL, 4
        cmpd    r_scratch1, r_addr
@@ -51,7 +50,9 @@ sk_load_word:
        .globl  sk_load_half
 sk_load_half:
        cmpdi   r_addr, 0
-       blt     bpf_error
+       blt     bpf_slow_path_half_neg
+       .globl  sk_load_half_positive_offset
+sk_load_half_positive_offset:
        subi    r_scratch1, r_HL, 2
        cmpd    r_scratch1, r_addr
        blt     bpf_slow_path_half
@@ -61,7 +62,9 @@ sk_load_half:
        .globl  sk_load_byte
 sk_load_byte:
        cmpdi   r_addr, 0
-       blt     bpf_error
+       blt     bpf_slow_path_byte_neg
+       .globl  sk_load_byte_positive_offset
+sk_load_byte_positive_offset:
        cmpd    r_HL, r_addr
        ble     bpf_slow_path_byte
        lbzx    r_A, r_D, r_addr
@@ -69,22 +72,20 @@ sk_load_byte:
 
 /*
  * BPF_S_LDX_B_MSH: ldxb  4*([offset]&0xf)
- * r_addr is the offset value, already known positive
+ * r_addr is the offset value
  */
        .globl sk_load_byte_msh
 sk_load_byte_msh:
+       cmpdi   r_addr, 0
+       blt     bpf_slow_path_byte_msh_neg
+       .globl sk_load_byte_msh_positive_offset
+sk_load_byte_msh_positive_offset:
        cmpd    r_HL, r_addr
        ble     bpf_slow_path_byte_msh
        lbzx    r_X, r_D, r_addr
        rlwinm  r_X, r_X, 2, 32-4-2, 31-2
        blr
 
-bpf_error:
-       /* Entered with cr0 = lt */
-       li      r3, 0
-       /* Generated code will 'blt epilogue', returning 0. */
-       blr
-
 /* Call out to skb_copy_bits:
  * We'll need to back up our volatile regs first; we have
  * local variable space at r1+(BPF_PPC_STACK_BASIC).
@@ -136,3 +137,84 @@ bpf_slow_path_byte_msh:
        lbz     r_X, BPF_PPC_STACK_BASIC+(2*8)(r1)
        rlwinm  r_X, r_X, 2, 32-4-2, 31-2
        blr
+
+/* Call out to bpf_internal_load_pointer_neg_helper:
+ * We'll need to back up our volatile regs first; we have
+ * local variable space at r1+(BPF_PPC_STACK_BASIC).
+ * Allocate a new stack frame here to remain ABI-compliant in
+ * stashing LR.
+ */
+#define sk_negative_common(SIZE)                               \
+       mflr    r0;                                             \
+       std     r0, 16(r1);                                     \
+       /* R3 goes in parameter space of caller's frame */      \
+       std     r_skb, (BPF_PPC_STACKFRAME+48)(r1);             \
+       std     r_A, (BPF_PPC_STACK_BASIC+(0*8))(r1);           \
+       std     r_X, (BPF_PPC_STACK_BASIC+(1*8))(r1);           \
+       stdu    r1, -BPF_PPC_SLOWPATH_FRAME(r1);                \
+       /* R3 = r_skb, as passed */                             \
+       mr      r4, r_addr;                                     \
+       li      r5, SIZE;                                       \
+       bl      bpf_internal_load_pointer_neg_helper;           \
+       /* R3 != 0 on success */                                \
+       addi    r1, r1, BPF_PPC_SLOWPATH_FRAME;                 \
+       ld      r0, 16(r1);                                     \
+       ld      r_A, (BPF_PPC_STACK_BASIC+(0*8))(r1);           \
+       ld      r_X, (BPF_PPC_STACK_BASIC+(1*8))(r1);           \
+       mtlr    r0;                                             \
+       cmpldi  r3, 0;                                          \
+       beq     bpf_error_slow; /* cr0 = EQ */                  \
+       mr      r_addr, r3;                                     \
+       ld      r_skb, (BPF_PPC_STACKFRAME+48)(r1);             \
+       /* Great success! */
+
+bpf_slow_path_word_neg:
+       lis     r_scratch1,-32  /* SKF_LL_OFF */
+       cmpd    r_addr, r_scratch1      /* addr < SKF_* */
+       blt     bpf_error       /* cr0 = LT */
+       .globl  sk_load_word_negative_offset
+sk_load_word_negative_offset:
+       sk_negative_common(4)
+       lwz     r_A, 0(r_addr)
+       blr
+
+bpf_slow_path_half_neg:
+       lis     r_scratch1,-32  /* SKF_LL_OFF */
+       cmpd    r_addr, r_scratch1      /* addr < SKF_* */
+       blt     bpf_error       /* cr0 = LT */
+       .globl  sk_load_half_negative_offset
+sk_load_half_negative_offset:
+       sk_negative_common(2)
+       lhz     r_A, 0(r_addr)
+       blr
+
+bpf_slow_path_byte_neg:
+       lis     r_scratch1,-32  /* SKF_LL_OFF */
+       cmpd    r_addr, r_scratch1      /* addr < SKF_* */
+       blt     bpf_error       /* cr0 = LT */
+       .globl  sk_load_byte_negative_offset
+sk_load_byte_negative_offset:
+       sk_negative_common(1)
+       lbz     r_A, 0(r_addr)
+       blr
+
+bpf_slow_path_byte_msh_neg:
+       lis     r_scratch1,-32  /* SKF_LL_OFF */
+       cmpd    r_addr, r_scratch1      /* addr < SKF_* */
+       blt     bpf_error       /* cr0 = LT */
+       .globl  sk_load_byte_msh_negative_offset
+sk_load_byte_msh_negative_offset:
+       sk_negative_common(1)
+       lbz     r_X, 0(r_addr)
+       rlwinm  r_X, r_X, 2, 32-4-2, 31-2
+       blr
+
+bpf_error_slow:
+       /* fabricate a cr0 = lt */
+       li      r_scratch1, -1
+       cmpdi   r_scratch1, 0
+bpf_error:
+       /* Entered with cr0 = lt */
+       li      r3, 0
+       /* Generated code will 'blt epilogue', returning 0. */
+       blr
index 73619d3aeb6ceebaa9d54e652b5025234f31660c..2dc8b14848455122918d13cf1d2985984f8a248b 100644 (file)
@@ -127,6 +127,9 @@ static void bpf_jit_build_epilogue(u32 *image, struct codegen_context *ctx)
        PPC_BLR();
 }
 
+#define CHOOSE_LOAD_FUNC(K, func) \
+       ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
+
 /* Assemble the body code between the prologue & epilogue. */
 static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
                              struct codegen_context *ctx,
@@ -391,21 +394,16 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
 
                        /*** Absolute loads from packet header/data ***/
                case BPF_S_LD_W_ABS:
-                       func = sk_load_word;
+                       func = CHOOSE_LOAD_FUNC(K, sk_load_word);
                        goto common_load;
                case BPF_S_LD_H_ABS:
-                       func = sk_load_half;
+                       func = CHOOSE_LOAD_FUNC(K, sk_load_half);
                        goto common_load;
                case BPF_S_LD_B_ABS:
-                       func = sk_load_byte;
+                       func = CHOOSE_LOAD_FUNC(K, sk_load_byte);
                common_load:
-                       /*
-                        * Load from [K].  Reference with the (negative)
-                        * SKF_NET_OFF/SKF_LL_OFF offsets is unsupported.
-                        */
+                       /* Load from [K]. */
                        ctx->seen |= SEEN_DATAREF;
-                       if ((int)K < 0)
-                               return -ENOTSUPP;
                        PPC_LI64(r_scratch1, func);
                        PPC_MTLR(r_scratch1);
                        PPC_LI32(r_addr, K);
@@ -429,7 +427,7 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
                common_load_ind:
                        /*
                         * Load from [X + K].  Negative offsets are tested for
-                        * in the helper functions, and result in a 'ret 0'.
+                        * in the helper functions.
                         */
                        ctx->seen |= SEEN_DATAREF | SEEN_XREG;
                        PPC_LI64(r_scratch1, func);
@@ -443,13 +441,7 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
                        break;
 
                case BPF_S_LDX_B_MSH:
-                       /*
-                        * x86 version drops packet (RET 0) when K<0, whereas
-                        * interpreter does allow K<0 (__load_pointer, special
-                        * ancillary data).  common_load returns ENOTSUPP if K<0,
-                        * so we fall back to interpreter & filter works.
-                        */
-                       func = sk_load_byte_msh;
+                       func = CHOOSE_LOAD_FUNC(K, sk_load_byte_msh);
                        goto common_load;
                        break;
 
index 9fef5302adc127468d821f8335c0ef007e416270..67dac22b4363c07f5add4b0c56c06af0d3225ba9 100644 (file)
@@ -21,6 +21,12 @@ static struct of_device_id __initdata mpc85xx_common_ids[] = {
        { .compatible = "fsl,qe", },
        { .compatible = "fsl,cpm2", },
        { .compatible = "fsl,srio", },
+       /* So that the DMA channel nodes can be probed individually: */
+       { .compatible = "fsl,eloplus-dma", },
+       /* For the PMC driver */
+       { .compatible = "fsl,mpc8548-guts", },
+       /* Probably unnecessary? */
+       { .compatible = "gpio-leds", },
        {},
 };
 
index 9a6f04406e0d63ebee34841a15ebd665a50ad3cd..d208ebccb91cc5f5db92bee1cf47e82e0e0c4b31 100644 (file)
@@ -399,12 +399,6 @@ static int __init board_fixups(void)
 machine_arch_initcall(mpc8568_mds, board_fixups);
 machine_arch_initcall(mpc8569_mds, board_fixups);
 
-static struct of_device_id mpc85xx_ids[] = {
-       { .compatible = "fsl,mpc8548-guts", },
-       { .compatible = "gpio-leds", },
-       {},
-};
-
 static int __init mpc85xx_publish_devices(void)
 {
        if (machine_is(mpc8568_mds))
@@ -412,10 +406,7 @@ static int __init mpc85xx_publish_devices(void)
        if (machine_is(mpc8569_mds))
                simple_gpiochip_init("fsl,mpc8569mds-bcsr-gpio");
 
-       mpc85xx_common_publish_devices();
-       of_platform_bus_probe(NULL, mpc85xx_ids, NULL);
-
-       return 0;
+       return mpc85xx_common_publish_devices();
 }
 
 machine_device_initcall(mpc8568_mds, mpc85xx_publish_devices);
index e74b7cde9aee77482f27c739af6dad8cf024d725..f700c81a1321ca2de222b6f1561408e454094204 100644 (file)
@@ -460,18 +460,7 @@ static void __init p1022_ds_setup_arch(void)
        pr_info("Freescale P1022 DS reference board\n");
 }
 
-static struct of_device_id __initdata p1022_ds_ids[] = {
-       /* So that the DMA channel nodes can be probed individually: */
-       { .compatible = "fsl,eloplus-dma", },
-       {},
-};
-
-static int __init p1022_ds_publish_devices(void)
-{
-       mpc85xx_common_publish_devices();
-       return of_platform_bus_probe(NULL, p1022_ds_ids, NULL);
-}
-machine_device_initcall(p1022_ds, p1022_ds_publish_devices);
+machine_device_initcall(p1022_ds, mpc85xx_common_publish_devices);
 
 machine_arch_initcall(p1022_ds, swiotlb_setup_bus_notifier);
 
index d09f3e8e68670585230e52d33c28109d9ce6cf8e..85825b5401e51d936b81c99b8342b2f2a08cf6c1 100644 (file)
@@ -114,7 +114,7 @@ static void axon_msi_cascade(unsigned int irq, struct irq_desc *desc)
                pr_devel("axon_msi: woff %x roff %x msi %x\n",
                          write_offset, msic->read_offset, msi);
 
-               if (msi < NR_IRQS && irq_get_chip_data(msi) == msic) {
+               if (msi < nr_irqs && irq_get_chip_data(msi) == msic) {
                        generic_handle_irq(msi);
                        msic->fifo_virt[idx] = cpu_to_le32(0xffffffff);
                } else {
@@ -276,9 +276,6 @@ static int axon_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
        if (rc)
                return rc;
 
-       /* We rely on being able to stash a virq in a u16 */
-       BUILD_BUG_ON(NR_IRQS > 65536);
-
        list_for_each_entry(entry, &dev->msi_list, list) {
                virq = irq_create_direct_mapping(msic->irq_domain);
                if (virq == NO_IRQ) {
@@ -392,7 +389,8 @@ static int axon_msi_probe(struct platform_device *device)
        }
        memset(msic->fifo_virt, 0xff, MSIC_FIFO_SIZE_BYTES);
 
-       msic->irq_domain = irq_domain_add_nomap(dn, 0, &msic_host_ops, msic);
+       /* We rely on being able to stash a virq in a u16, so limit irqs to < 65536 */
+       msic->irq_domain = irq_domain_add_nomap(dn, 65536, &msic_host_ops, msic);
        if (!msic->irq_domain) {
                printk(KERN_ERR "axon_msi: couldn't allocate irq_domain for %s\n",
                       dn->full_name);
index f9a48af335cb8d17b52cb1ed34503175d0772fef..8c6dc42ecf65440f0a488e84483b43cdbfa4816f 100644 (file)
@@ -248,6 +248,6 @@ void beatic_deinit_IRQ(void)
 {
        int     i;
 
-       for (i = 1; i < NR_IRQS; i++)
+       for (i = 1; i < nr_irqs; i++)
                beat_destruct_irq_plug(i);
 }
index 996c5ff7824b7b3342e1bce1ce46d44db06e8491..03685a329d7dadde0c52643ddd85a4ee23211747 100644 (file)
@@ -366,11 +366,20 @@ static void kw_i2c_timeout(unsigned long data)
        unsigned long flags;
 
        spin_lock_irqsave(&host->lock, flags);
+
+       /*
+        * If the timer is pending, that means we raced with the
+        * irq, in which case we just return
+        */
+       if (timer_pending(&host->timeout_timer))
+               goto skip;
+
        kw_i2c_handle_interrupt(host, kw_read_reg(reg_isr));
        if (host->state != state_idle) {
                host->timeout_timer.expires = jiffies + KW_POLL_TIMEOUT;
                add_timer(&host->timeout_timer);
        }
+ skip:
        spin_unlock_irqrestore(&host->lock, flags);
 }
 
index 66ad93de1d5571f80b5431dd72b69b88b304f6fc..c4e630576ff283666f74c37ee985cf4f1b22b105 100644 (file)
@@ -57,9 +57,9 @@ static int max_real_irqs;
 
 static DEFINE_RAW_SPINLOCK(pmac_pic_lock);
 
-#define NR_MASK_WORDS  ((NR_IRQS + 31) / 32)
-static unsigned long ppc_lost_interrupts[NR_MASK_WORDS];
-static unsigned long ppc_cached_irq_mask[NR_MASK_WORDS];
+/* The max irq number this driver deals with is 128; see max_irqs */
+static DECLARE_BITMAP(ppc_lost_interrupts, 128);
+static DECLARE_BITMAP(ppc_cached_irq_mask, 128);
 static int pmac_irq_cascade = -1;
 static struct irq_domain *pmac_pic_host;
 
index aadbe4f6d5373d03bef6fd8de146a02c43a04ceb..178a5f300bc973afeb8c4a21799992cbfbdc74e1 100644 (file)
@@ -30,9 +30,9 @@ config PPC_SPLPAR
          two or more partitions.
 
 config EEH
-       bool "PCI Extended Error Handling (EEH)" if EXPERT
+       bool
        depends on PPC_PSERIES && PCI
-       default y if !EXPERT
+       default y
 
 config PSERIES_MSI
        bool
index 309d38ef732209ce68ec99380ef09b97d5bfc41f..a75e37dc41aa7d94dc762c9f9c7afb23acab1841 100644 (file)
@@ -1076,7 +1076,7 @@ static void eeh_add_device_late(struct pci_dev *dev)
        pr_debug("EEH: Adding device %s\n", pci_name(dev));
 
        dn = pci_device_to_OF_node(dev);
-       edev = pci_dev_to_eeh_dev(dev);
+       edev = of_node_to_eeh_dev(dn);
        if (edev->pdev == dev) {
                pr_debug("EEH: Already referenced !\n");
                return;
index d3be961e2ae73d3fd9a3cebe0481a2f0f5e652ad..10386b676d8758b7f52bb8348f7cf321cc8db89a 100644 (file)
@@ -51,8 +51,7 @@
 static intctl_cpm2_t __iomem *cpm2_intctl;
 
 static struct irq_domain *cpm2_pic_host;
-#define NR_MASK_WORDS   ((NR_IRQS + 31) / 32)
-static unsigned long ppc_cached_irq_mask[NR_MASK_WORDS];
+static unsigned long ppc_cached_irq_mask[2]; /* 2 32-bit registers */
 
 static const u_char irq_to_siureg[] = {
        1, 1, 1, 1, 1, 1, 1, 1,
index d5f5416be310b0fc5f78f7466cc5755b34a6f1cd..b724622c3a0b74ab5eddfa3b0cfc10dc6eab2c34 100644 (file)
 extern int cpm_get_irq(struct pt_regs *regs);
 
 static struct irq_domain *mpc8xx_pic_host;
-#define NR_MASK_WORDS   ((NR_IRQS + 31) / 32)
-static unsigned long ppc_cached_irq_mask[NR_MASK_WORDS];
+static unsigned long mpc8xx_cached_irq_mask;
 static sysconf8xx_t __iomem *siu_reg;
 
-int cpm_get_irq(struct pt_regs *regs);
+static inline unsigned long mpc8xx_irqd_to_bit(struct irq_data *d)
+{
+       return 0x80000000 >> irqd_to_hwirq(d);
+}
 
 static void mpc8xx_unmask_irq(struct irq_data *d)
 {
-       int     bit, word;
-       unsigned int irq_nr = (unsigned int)irqd_to_hwirq(d);
-
-       bit = irq_nr & 0x1f;
-       word = irq_nr >> 5;
-
-       ppc_cached_irq_mask[word] |= (1 << (31-bit));
-       out_be32(&siu_reg->sc_simask, ppc_cached_irq_mask[word]);
+       mpc8xx_cached_irq_mask |= mpc8xx_irqd_to_bit(d);
+       out_be32(&siu_reg->sc_simask, mpc8xx_cached_irq_mask);
 }
 
 static void mpc8xx_mask_irq(struct irq_data *d)
 {
-       int     bit, word;
-       unsigned int irq_nr = (unsigned int)irqd_to_hwirq(d);
-
-       bit = irq_nr & 0x1f;
-       word = irq_nr >> 5;
-
-       ppc_cached_irq_mask[word] &= ~(1 << (31-bit));
-       out_be32(&siu_reg->sc_simask, ppc_cached_irq_mask[word]);
+       mpc8xx_cached_irq_mask &= ~mpc8xx_irqd_to_bit(d);
+       out_be32(&siu_reg->sc_simask, mpc8xx_cached_irq_mask);
 }
 
 static void mpc8xx_ack(struct irq_data *d)
 {
-       int     bit;
-       unsigned int irq_nr = (unsigned int)irqd_to_hwirq(d);
-
-       bit = irq_nr & 0x1f;
-       out_be32(&siu_reg->sc_sipend, 1 << (31-bit));
+       out_be32(&siu_reg->sc_sipend, mpc8xx_irqd_to_bit(d));
 }
 
 static void mpc8xx_end_irq(struct irq_data *d)
 {
-       int bit, word;
-       unsigned int irq_nr = (unsigned int)irqd_to_hwirq(d);
-
-       bit = irq_nr & 0x1f;
-       word = irq_nr >> 5;
-
-       ppc_cached_irq_mask[word] |= (1 << (31-bit));
-       out_be32(&siu_reg->sc_simask, ppc_cached_irq_mask[word]);
+       mpc8xx_cached_irq_mask |= mpc8xx_irqd_to_bit(d);
+       out_be32(&siu_reg->sc_simask, mpc8xx_cached_irq_mask);
 }
 
 static int mpc8xx_set_irq_type(struct irq_data *d, unsigned int flow_type)
 {
-       if (flow_type & IRQ_TYPE_EDGE_FALLING) {
-               irq_hw_number_t hw = (unsigned int)irqd_to_hwirq(d);
+       /* only external IRQ senses are programmable */
+       if ((flow_type & IRQ_TYPE_EDGE_FALLING) && !(irqd_to_hwirq(d) & 1)) {
                unsigned int siel = in_be32(&siu_reg->sc_siel);
-
-               /* only external IRQ senses are programmable */
-               if ((hw & 1) == 0) {
-                       siel |= (0x80000000 >> hw);
-                       out_be32(&siu_reg->sc_siel, siel);
-                       __irq_set_handler_locked(d->irq, handle_edge_irq);
-               }
+               siel |= mpc8xx_irqd_to_bit(d);
+               out_be32(&siu_reg->sc_siel, siel);
+               __irq_set_handler_locked(d->irq, handle_edge_irq);
        }
        return 0;
 }
@@ -132,6 +108,9 @@ static int mpc8xx_pic_host_xlate(struct irq_domain *h, struct device_node *ct,
                IRQ_TYPE_EDGE_FALLING,
        };
 
+       if (intspec[0] > 0x1f)
+               return 0;
+
        *out_hwirq = intspec[0];
        if (intsize > 1 && intspec[1] < 4)
                *out_flags = map_pic_senses[intspec[1]];
index 9ac71ebd2c408b47869f5f152ff577e84c958064..395af1347749104aeef3c832fb48dd26e6385ace 100644 (file)
@@ -604,18 +604,14 @@ static struct mpic *mpic_find(unsigned int irq)
 }
 
 /* Determine if the linux irq is an IPI */
-static unsigned int mpic_is_ipi(struct mpic *mpic, unsigned int irq)
+static unsigned int mpic_is_ipi(struct mpic *mpic, unsigned int src)
 {
-       unsigned int src = virq_to_hw(irq);
-
        return (src >= mpic->ipi_vecs[0] && src <= mpic->ipi_vecs[3]);
 }
 
 /* Determine if the linux irq is a timer */
-static unsigned int mpic_is_tm(struct mpic *mpic, unsigned int irq)
+static unsigned int mpic_is_tm(struct mpic *mpic, unsigned int src)
 {
-       unsigned int src = virq_to_hw(irq);
-
        return (src >= mpic->timer_vecs[0] && src <= mpic->timer_vecs[7]);
 }
 
@@ -876,21 +872,45 @@ int mpic_set_irq_type(struct irq_data *d, unsigned int flow_type)
        if (src >= mpic->num_sources)
                return -EINVAL;
 
+       vold = mpic_irq_read(src, MPIC_INFO(IRQ_VECTOR_PRI));
+
+       /* We don't support "none" type */
        if (flow_type == IRQ_TYPE_NONE)
-               if (mpic->senses && src < mpic->senses_count)
-                       flow_type = mpic->senses[src];
-       if (flow_type == IRQ_TYPE_NONE)
-               flow_type = IRQ_TYPE_LEVEL_LOW;
+               flow_type = IRQ_TYPE_DEFAULT;
+
+       /* Default: read HW settings */
+       if (flow_type == IRQ_TYPE_DEFAULT) {
+               switch(vold & (MPIC_INFO(VECPRI_POLARITY_MASK) |
+                              MPIC_INFO(VECPRI_SENSE_MASK))) {
+                       case MPIC_INFO(VECPRI_SENSE_EDGE) |
+                            MPIC_INFO(VECPRI_POLARITY_POSITIVE):
+                               flow_type = IRQ_TYPE_EDGE_RISING;
+                               break;
+                       case MPIC_INFO(VECPRI_SENSE_EDGE) |
+                            MPIC_INFO(VECPRI_POLARITY_NEGATIVE):
+                               flow_type = IRQ_TYPE_EDGE_FALLING;
+                               break;
+                       case MPIC_INFO(VECPRI_SENSE_LEVEL) |
+                            MPIC_INFO(VECPRI_POLARITY_POSITIVE):
+                               flow_type = IRQ_TYPE_LEVEL_HIGH;
+                               break;
+                       case MPIC_INFO(VECPRI_SENSE_LEVEL) |
+                            MPIC_INFO(VECPRI_POLARITY_NEGATIVE):
+                               flow_type = IRQ_TYPE_LEVEL_LOW;
+                               break;
+               }
+       }
 
+       /* Apply to irq desc */
        irqd_set_trigger_type(d, flow_type);
 
+       /* Apply to HW */
        if (mpic_is_ht_interrupt(mpic, src))
                vecpri = MPIC_VECPRI_POLARITY_POSITIVE |
                        MPIC_VECPRI_SENSE_EDGE;
        else
                vecpri = mpic_type_to_vecpri(mpic, flow_type);
 
-       vold = mpic_irq_read(src, MPIC_INFO(IRQ_VECTOR_PRI));
        vnew = vold & ~(MPIC_INFO(VECPRI_POLARITY_MASK) |
                        MPIC_INFO(VECPRI_SENSE_MASK));
        vnew |= vecpri;
@@ -1026,7 +1046,7 @@ static int mpic_host_map(struct irq_domain *h, unsigned int virq,
        irq_set_chip_and_handler(virq, chip, handle_fasteoi_irq);
 
        /* Set default irq type */
-       irq_set_irq_type(virq, IRQ_TYPE_NONE);
+       irq_set_irq_type(virq, IRQ_TYPE_DEFAULT);
 
        /* If the MPIC was reset, then all vectors have already been
         * initialized.  Otherwise, a per source lazy initialization
@@ -1417,12 +1437,6 @@ void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
                mpic->num_sources = isu_first + mpic->isu_size;
 }
 
-void __init mpic_set_default_senses(struct mpic *mpic, u8 *senses, int count)
-{
-       mpic->senses = senses;
-       mpic->senses_count = count;
-}
-
 void __init mpic_init(struct mpic *mpic)
 {
        int i, cpu;
@@ -1555,12 +1569,12 @@ void mpic_irq_set_priority(unsigned int irq, unsigned int pri)
                return;
 
        raw_spin_lock_irqsave(&mpic_lock, flags);
-       if (mpic_is_ipi(mpic, irq)) {
+       if (mpic_is_ipi(mpic, src)) {
                reg = mpic_ipi_read(src - mpic->ipi_vecs[0]) &
                        ~MPIC_VECPRI_PRIORITY_MASK;
                mpic_ipi_write(src - mpic->ipi_vecs[0],
                               reg | (pri << MPIC_VECPRI_PRIORITY_SHIFT));
-       } else if (mpic_is_tm(mpic, irq)) {
+       } else if (mpic_is_tm(mpic, src)) {
                reg = mpic_tm_read(src - mpic->timer_vecs[0]) &
                        ~MPIC_VECPRI_PRIORITY_MASK;
                mpic_tm_write(src - mpic->timer_vecs[0],
index 6e7fa386e76a75c36de9f38cf376d178ef6ea83f..483d8fa72e8ba3bc6bca736faf2f007399282e13 100644 (file)
@@ -27,6 +27,7 @@
 
 static struct mpic_msgr **mpic_msgrs;
 static unsigned int mpic_msgr_count;
+static DEFINE_RAW_SPINLOCK(msgrs_lock);
 
 static inline void _mpic_msgr_mer_write(struct mpic_msgr *msgr, u32 value)
 {
@@ -56,12 +57,11 @@ struct mpic_msgr *mpic_msgr_get(unsigned int reg_num)
        if (reg_num >= mpic_msgr_count)
                return ERR_PTR(-ENODEV);
 
-       raw_spin_lock_irqsave(&msgr->lock, flags);
-       if (mpic_msgrs[reg_num]->in_use == MSGR_FREE) {
-               msgr = mpic_msgrs[reg_num];
+       raw_spin_lock_irqsave(&msgrs_lock, flags);
+       msgr = mpic_msgrs[reg_num];
+       if (msgr->in_use == MSGR_FREE)
                msgr->in_use = MSGR_INUSE;
-       }
-       raw_spin_unlock_irqrestore(&msgr->lock, flags);
+       raw_spin_unlock_irqrestore(&msgrs_lock, flags);
 
        return msgr;
 }
@@ -228,7 +228,7 @@ static __devinit int mpic_msgr_probe(struct platform_device *dev)
 
                reg_number = block_number * MPIC_MSGR_REGISTERS_PER_BLOCK + i;
                msgr->base = msgr_block_addr + i * MPIC_MSGR_STRIDE;
-               msgr->mer = msgr->base + MPIC_MSGR_MER_OFFSET;
+               msgr->mer = (u32 *)((u8 *)msgr->base + MPIC_MSGR_MER_OFFSET);
                msgr->in_use = MSGR_FREE;
                msgr->num = i;
                raw_spin_lock_init(&msgr->lock);
index 49a3ece1c6b3589971872bf4d440cab1e609d764..702256a1ca1184c3044c2ae981cbcaeacb571b88 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/debugfs.h>
 #include <linux/slab.h>
 #include <linux/export.h>
+#include <asm/debug.h>
 #include <asm/prom.h>
 #include <asm/scom.h>
 
index ea5e204e345093cedfc320d06f23a804d3c8589e..cd1d18db92c6afdc5e35c7980b4e038b8a6057a4 100644 (file)
@@ -188,6 +188,7 @@ void xics_migrate_irqs_away(void)
 {
        int cpu = smp_processor_id(), hw_cpu = hard_smp_processor_id();
        unsigned int irq, virq;
+       struct irq_desc *desc;
 
        /* If we used to be the default server, move to the new "boot_cpuid" */
        if (hw_cpu == xics_default_server)
@@ -202,8 +203,7 @@ void xics_migrate_irqs_away(void)
        /* Allow IPIs again... */
        icp_ops->set_priority(DEFAULT_PRIORITY);
 
-       for_each_irq(virq) {
-               struct irq_desc *desc;
+       for_each_irq_desc(virq, desc) {
                struct irq_chip *chip;
                long server;
                unsigned long flags;
@@ -212,9 +212,8 @@ void xics_migrate_irqs_away(void)
                /* We can't set affinity on ISA interrupts */
                if (virq < NUM_ISA_INTERRUPTS)
                        continue;
-               desc = irq_to_desc(virq);
                /* We only need to migrate enabled IRQS */
-               if (!desc || !desc->action)
+               if (!desc->action)
                        continue;
                if (desc->irq_data.domain != xics_host)
                        continue;
index 37f2f4a55231f9c09854708b9f0b07c4f4ad2016..f4c1c20bcdf63289dfb0d94a3c2ed990482c337a 100644 (file)
@@ -11,7 +11,7 @@
 #include <linux/types.h>
 #include <asm/cmpxchg.h>
 
-#define ATOMIC_INIT(i) ( (atomic_t) { (i) } )
+#define ATOMIC_INIT(i) { (i) }
 
 #define atomic_read(v)         (*(volatile int *)&(v)->counter)
 #define atomic_set(v,i)                ((v)->counter = (i))
index 324eef93c90068ae91d202aebe986339aa8bf192..e99b104d967a3464d555459b024a19e09263815f 100644 (file)
@@ -86,7 +86,7 @@ static noinline int vmalloc_fault(unsigned long address)
        pte_t *pte_k;
 
        /* Make sure we are in vmalloc/module/P3 area: */
-       if (!(address >= VMALLOC_START && address < P3_ADDR_MAX))
+       if (!(address >= P3SEG && address < P3_ADDR_MAX))
                return -1;
 
        /*
index 5d5a635530bd5ed527eb6387ce3a0170d605e0b0..32e6cbe8dff3350d1d7e236691fced9a47bd2c8d 100644 (file)
@@ -47,8 +47,8 @@ struct pci_controller {
  */
 #define PCI_DMA_BUS_IS_PHYS     1
 
-int __devinit tile_pci_init(void);
-int __devinit pcibios_init(void);
+int __init tile_pci_init(void);
+int __init pcibios_init(void);
 
 static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {}
 
index a1bb59eecc1850bcd7aedf6f1ec538498e0d1573..b56d12bf5900c8f266132bc9b50dadfb092af10a 100644 (file)
@@ -141,7 +141,7 @@ static int __devinit tile_init_irqs(int controller_id,
  *
  * Returns the number of controllers discovered.
  */
-int __devinit tile_pci_init(void)
+int __init tile_pci_init(void)
 {
        int i;
 
@@ -287,7 +287,7 @@ static void __devinit fixup_read_and_payload_sizes(void)
  * The controllers have been set up by the time we get here, by a call to
  * tile_pci_init.
  */
-int __devinit pcibios_init(void)
+int __init pcibios_init(void)
 {
        int i;
 
index 1d14cc6b79ad399d1ad293030c9f2271d9e5df1d..c9866b0b77d81d678e97ebbacd48ed5d5e659a77 100644 (file)
@@ -81,7 +81,7 @@ config X86
        select CLKEVT_I8253
        select ARCH_HAVE_NMI_SAFE_CMPXCHG
        select GENERIC_IOMAP
-       select DCACHE_WORD_ACCESS if !DEBUG_PAGEALLOC
+       select DCACHE_WORD_ACCESS
 
 config INSTRUCTION_DECODER
        def_bool (KPROBES || PERF_EVENTS)
index a0559930a180ecb810df4b186d173d6fb11e3755..c85e3ac99bbabc597d772cb85b4efd4d4b3bc291 100644 (file)
@@ -33,6 +33,9 @@
        __HEAD
 ENTRY(startup_32)
 #ifdef CONFIG_EFI_STUB
+       jmp     preferred_addr
+
+       .balign 0x10
        /*
         * We don't need the return address, so set up the stack so
         * efi_main() can find its arugments.
@@ -41,12 +44,17 @@ ENTRY(startup_32)
 
        call    efi_main
        cmpl    $0, %eax
-       je      preferred_addr
        movl    %eax, %esi
-       call    1f
+       jne     2f
 1:
+       /* EFI init failed, so hang. */
+       hlt
+       jmp     1b
+2:
+       call    3f
+3:
        popl    %eax
-       subl    $1b, %eax
+       subl    $3b, %eax
        subl    BP_pref_address(%esi), %eax
        add     BP_code32_start(%esi), %eax
        leal    preferred_addr(%eax), %eax
index 558d76ce23bcf3518a4c9b32bced0ef717be000e..87e03a13d8e3f5d9eaad2d515679d97887833ea2 100644 (file)
@@ -200,18 +200,28 @@ ENTRY(startup_64)
         * entire text+data+bss and hopefully all of memory.
         */
 #ifdef CONFIG_EFI_STUB
-       pushq   %rsi
+       /*
+        * The entry point for the PE/COFF executable is 0x210, so only
+        * legacy boot loaders will execute this jmp.
+        */
+       jmp     preferred_addr
+
+       .org 0x210
        mov     %rcx, %rdi
        mov     %rdx, %rsi
        call    efi_main
-       popq    %rsi
-       cmpq    $0,%rax
-       je      preferred_addr
        movq    %rax,%rsi
-       call    1f
+       cmpq    $0,%rax
+       jne     2f
 1:
+       /* EFI init failed, so hang. */
+       hlt
+       jmp     1b
+2:
+       call    3f
+3:
        popq    %rax
-       subq    $1b, %rax
+       subq    $3b, %rax
        subq    BP_pref_address(%rsi), %rax
        add     BP_code32_start(%esi), %eax
        leaq    preferred_addr(%rax), %rax
index d3c0b027766656c69dfc82404b74de3849eaadaa..fb7117a4ade1e259c69d45b47d4ffc3b62196540 100644 (file)
@@ -403,13 +403,11 @@ static void print_absolute_symbols(void)
        for (i = 0; i < ehdr.e_shnum; i++) {
                struct section *sec = &secs[i];
                char *sym_strtab;
-               Elf32_Sym *sh_symtab;
                int j;
 
                if (sec->shdr.sh_type != SHT_SYMTAB) {
                        continue;
                }
-               sh_symtab = sec->symtab;
                sym_strtab = sec->link->strtab;
                for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) {
                        Elf32_Sym *sym;
index ed549767a231eece626dd19cd64746cb2569b6f5..24443a3320838ede8cdf995525851794e8d1052a 100644 (file)
@@ -205,8 +205,13 @@ int main(int argc, char ** argv)
        put_unaligned_le32(file_sz, &buf[pe_header + 0x50]);
 
 #ifdef CONFIG_X86_32
-       /* Address of entry point */
-       put_unaligned_le32(i, &buf[pe_header + 0x28]);
+       /*
+        * Address of entry point.
+        *
+        * The EFI stub entry point is +16 bytes from the start of
+        * the .text section.
+        */
+       put_unaligned_le32(i + 16, &buf[pe_header + 0x28]);
 
        /* .text size */
        put_unaligned_le32(file_sz, &buf[pe_header + 0xb0]);
@@ -217,9 +222,11 @@ int main(int argc, char ** argv)
        /*
         * Address of entry point. startup_32 is at the beginning and
         * the 64-bit entry point (startup_64) is always 512 bytes
-        * after.
+        * after. The EFI stub entry point is 16 bytes after that, as
+        * the first instruction allows legacy loaders to jump over
+        * the EFI stub initialisation
         */
-       put_unaligned_le32(i + 512, &buf[pe_header + 0x28]);
+       put_unaligned_le32(i + 528, &buf[pe_header + 0x28]);
 
        /* .text size */
        put_unaligned_le32(file_sz, &buf[pe_header + 0xc0]);
index 4824fb45560f7b6afe7bef4bf260f9f39f95a117..07b3a68d2d291ab4c8582a1cc5121c6443e208bb 100644 (file)
@@ -294,8 +294,7 @@ static int load_aout_binary(struct linux_binprm *bprm, struct pt_regs *regs)
 
        /* OK, This is the point of no return */
        set_personality(PER_LINUX);
-       set_thread_flag(TIF_IA32);
-       current->mm->context.ia32_compat = 1;
+       set_personality_ia32(false);
 
        setup_new_exec(bprm);
 
index 3427b7798dbcdfed5a93f0e5d448feedb588846c..7ef7c3020e5c5bb8e34b4f573e02434b4202f806 100644 (file)
@@ -7,9 +7,9 @@
 #else
 # ifdef __i386__
 #  include "posix_types_32.h"
-# elif defined(__LP64__)
-#  include "posix_types_64.h"
-# else
+# elif defined(__ILP32__)
 #  include "posix_types_x32.h"
+# else
+#  include "posix_types_64.h"
 # endif
 #endif
index 4a085383af27effcab8935689ef63f0ba9304842..5ca71c065eef2d9a62af1defdb2b06ac7f64cbbd 100644 (file)
@@ -257,7 +257,7 @@ struct sigcontext {
        __u64 oldmask;
        __u64 cr2;
        struct _fpstate __user *fpstate;        /* zero when no FPU context */
-#ifndef __LP64__
+#ifdef __ILP32__
        __u32 __fpstate_pad;
 #endif
        __u64 reserved1[8];
index fc1aa553564604c405569eea428d3a10398bcc55..34c47b3341c0343a7bca3f09fa35e87121df08c8 100644 (file)
@@ -2,7 +2,13 @@
 #define _ASM_X86_SIGINFO_H
 
 #ifdef __x86_64__
-# define __ARCH_SI_PREAMBLE_SIZE       (4 * sizeof(int))
+# ifdef __ILP32__ /* x32 */
+typedef long long __kernel_si_clock_t __attribute__((aligned(4)));
+#  define __ARCH_SI_CLOCK_T            __kernel_si_clock_t
+#  define __ARCH_SI_ATTRIBUTES         __attribute__((aligned(8)))
+# else /* x86-64 */
+#  define __ARCH_SI_PREAMBLE_SIZE      (4 * sizeof(int))
+# endif
 #endif
 
 #include <asm-generic/siginfo.h>
index 37cdc9d99bb18097c5cde1895606864510de3f5f..4437001d8e3d124853e7e12289befb09c12b2e2f 100644 (file)
 #else
 # ifdef __i386__
 #  include <asm/unistd_32.h>
-# elif defined(__LP64__)
-#  include <asm/unistd_64.h>
-# else
+# elif defined(__ILP32__)
 #  include <asm/unistd_x32.h>
+# else
+#  include <asm/unistd_64.h>
 # endif
 #endif
 
index 6fe6767b7124aad25ac92ecd7dccd9a2fd2519ed..e58f03b206c3fb187b469032a1aba09b9d63ec05 100644 (file)
@@ -43,4 +43,37 @@ static inline unsigned long has_zero(unsigned long a)
        return ((a - REPEAT_BYTE(0x01)) & ~a) & REPEAT_BYTE(0x80);
 }
 
+/*
+ * Load an unaligned word from kernel space.
+ *
+ * In the (very unlikely) case of the word being a page-crosser
+ * and the next page not being mapped, take the exception and
+ * return zeroes in the non-existing part.
+ */
+static inline unsigned long load_unaligned_zeropad(const void *addr)
+{
+       unsigned long ret, dummy;
+
+       asm(
+               "1:\tmov %2,%0\n"
+               "2:\n"
+               ".section .fixup,\"ax\"\n"
+               "3:\t"
+               "lea %2,%1\n\t"
+               "and %3,%1\n\t"
+               "mov (%1),%0\n\t"
+               "leal %2,%%ecx\n\t"
+               "andl %4,%%ecx\n\t"
+               "shll $3,%%ecx\n\t"
+               "shr %%cl,%0\n\t"
+               "jmp 2b\n"
+               ".previous\n"
+               _ASM_EXTABLE(1b, 3b)
+               :"=&r" (ret),"=&c" (dummy)
+               :"m" (*(unsigned long *)addr),
+                "i" (-sizeof(unsigned long)),
+                "i" (sizeof(unsigned long)-1));
+       return ret;
+}
+
 #endif /* _ASM_WORD_AT_A_TIME_H */
index baaca8defec8032463d1a87d53137a8c88f63639..764b66a4cf896cc51cbbdc50f9455d51511b64c6 100644 (file)
@@ -195,6 +195,5 @@ extern struct x86_msi_ops x86_msi;
 
 extern void x86_init_noop(void);
 extern void x86_init_uint_noop(unsigned int unused);
-extern void x86_default_fixup_cpu_id(struct cpuinfo_x86 *c, int node);
 
 #endif
index 103b6ab368d39315bc752e02a7bdc5b83ede0acf..146a49c763a49085b50d5b3b6babcda74650463b 100644 (file)
@@ -24,6 +24,10 @@ unsigned long acpi_realmode_flags;
 static char temp_stack[4096];
 #endif
 
+asmlinkage void acpi_enter_s3(void)
+{
+       acpi_enter_sleep_state(3, wake_sleep_flags);
+}
 /**
  * acpi_suspend_lowlevel - save kernel state
  *
index 416d4be13fef6d16cc96936ae3f222a91040ccf0..d68677a2a01037a758496ee31aa575ccbb2badff 100644 (file)
@@ -3,12 +3,16 @@
  */
 
 #include <asm/trampoline.h>
+#include <linux/linkage.h>
 
 extern unsigned long saved_video_mode;
 extern long saved_magic;
 
 extern int wakeup_pmode_return;
 
+extern u8 wake_sleep_flags;
+extern asmlinkage void acpi_enter_s3(void);
+
 extern unsigned long acpi_copy_wakeup_routine(unsigned long);
 extern void wakeup_long64(void);
 
index 13ab720573e3e31e317ac52f977e168401552f17..72610839f03b3d45e8fa6adb49a13fe933b477b2 100644 (file)
@@ -74,9 +74,7 @@ restore_registers:
 ENTRY(do_suspend_lowlevel)
        call    save_processor_state
        call    save_registers
-       pushl   $3
-       call    acpi_enter_sleep_state
-       addl    $4, %esp
+       call    acpi_enter_s3
 
 #      In case of S3 failure, we'll emerge here.  Jump
 #      to ret_point to recover
index 8ea5164cbd0451a27b9048699f60c2420057edb3..014d1d28c397076606be9d50f04af06892bf2f03 100644 (file)
@@ -71,9 +71,7 @@ ENTRY(do_suspend_lowlevel)
        movq    %rsi, saved_rsi
 
        addq    $8, %rsp
-       movl    $3, %edi
-       xorl    %eax, %eax
-       call    acpi_enter_sleep_state
+       call    acpi_enter_s3
        /* in case something went wrong, restore the machine status and go on */
        jmp     resume_point
 
index 11544d8f1e975e30c1e3c0d9aafa58b4ba67a1da..edc24480469f10188e64855ff76f3df2dcab85c4 100644 (file)
@@ -1637,9 +1637,11 @@ static int __init apic_verify(void)
        mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
 
        /* The BIOS may have set up the APIC at some other address */
-       rdmsr(MSR_IA32_APICBASE, l, h);
-       if (l & MSR_IA32_APICBASE_ENABLE)
-               mp_lapic_addr = l & MSR_IA32_APICBASE_BASE;
+       if (boot_cpu_data.x86 >= 6) {
+               rdmsr(MSR_IA32_APICBASE, l, h);
+               if (l & MSR_IA32_APICBASE_ENABLE)
+                       mp_lapic_addr = l & MSR_IA32_APICBASE_BASE;
+       }
 
        pr_info("Found and enabled local APIC!\n");
        return 0;
@@ -1657,13 +1659,15 @@ int __init apic_force_enable(unsigned long addr)
         * MSR. This can only be done in software for Intel P6 or later
         * and AMD K7 (Model > 1) or later.
         */
-       rdmsr(MSR_IA32_APICBASE, l, h);
-       if (!(l & MSR_IA32_APICBASE_ENABLE)) {
-               pr_info("Local APIC disabled by BIOS -- reenabling.\n");
-               l &= ~MSR_IA32_APICBASE_BASE;
-               l |= MSR_IA32_APICBASE_ENABLE | addr;
-               wrmsr(MSR_IA32_APICBASE, l, h);
-               enabled_via_apicbase = 1;
+       if (boot_cpu_data.x86 >= 6) {
+               rdmsr(MSR_IA32_APICBASE, l, h);
+               if (!(l & MSR_IA32_APICBASE_ENABLE)) {
+                       pr_info("Local APIC disabled by BIOS -- reenabling.\n");
+                       l &= ~MSR_IA32_APICBASE_BASE;
+                       l |= MSR_IA32_APICBASE_ENABLE | addr;
+                       wrmsr(MSR_IA32_APICBASE, l, h);
+                       enabled_via_apicbase = 1;
+               }
        }
        return apic_verify();
 }
@@ -2209,10 +2213,12 @@ static void lapic_resume(void)
                 * FIXME! This will be wrong if we ever support suspend on
                 * SMP! We'll need to do this as part of the CPU restore!
                 */
-               rdmsr(MSR_IA32_APICBASE, l, h);
-               l &= ~MSR_IA32_APICBASE_BASE;
-               l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr;
-               wrmsr(MSR_IA32_APICBASE, l, h);
+               if (boot_cpu_data.x86 >= 6) {
+                       rdmsr(MSR_IA32_APICBASE, l, h);
+                       l &= ~MSR_IA32_APICBASE_BASE;
+                       l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr;
+                       wrmsr(MSR_IA32_APICBASE, l, h);
+               }
        }
 
        maxlvt = lapic_get_maxlvt();
index 899803e032142662650389d693ca4594a08ab18d..23e75422e0138aa42e58ff64a5a37322bd9f46bb 100644 (file)
@@ -207,8 +207,11 @@ static void __init map_csrs(void)
 
 static void fixup_cpu_id(struct cpuinfo_x86 *c, int node)
 {
-       c->phys_proc_id = node;
-       per_cpu(cpu_llc_id, smp_processor_id()) = node;
+
+       if (c->phys_proc_id != node) {
+               c->phys_proc_id = node;
+               per_cpu(cpu_llc_id, smp_processor_id()) = node;
+       }
 }
 
 static int __init numachip_system_init(void)
index 8a778db45e3a508ef2402596ee57884eaf639166..991e315f4227c8e69b5bac35372c15a86ab28b60 100644 (file)
@@ -24,6 +24,12 @@ static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
 {
        if (x2apic_phys)
                return x2apic_enabled();
+       else if ((acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) &&
+               (acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL) &&
+               x2apic_enabled()) {
+               printk(KERN_DEBUG "System requires x2apic physical mode\n");
+               return 1;
+       }
        else
                return 0;
 }
index 0a44b90602b036584a6f499759b47c53028e10b2..146bb6218eec3daa3cdbe0472c04bcfac7500e8a 100644 (file)
@@ -26,7 +26,8 @@
  *     contact AMD for precise details and a CPU swap.
  *
  *     See     http://www.multimania.com/poulot/k6bug.html
- *             http://www.amd.com/K6/k6docs/revgd.html
+ *     and     section 2.6.2 of "AMD-K6 Processor Revision Guide - Model 6"
+ *             (Publication # 21266  Issue Date: August 1998)
  *
  *     The following test is erm.. interesting. AMD neglected to up
  *     the chip setting when fixing the bug but they also tweaked some
@@ -94,7 +95,6 @@ static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
                                "system stability may be impaired when more than 32 MB are used.\n");
                else
                        printk(KERN_CONT "probably OK (after B9730xxxx).\n");
-               printk(KERN_INFO "Please see http://membres.lycos.fr/poulot/k6bug.html\n");
        }
 
        /* K6 with old style WHCR */
@@ -353,10 +353,11 @@ static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c)
                node = per_cpu(cpu_llc_id, cpu);
 
        /*
-        * If core numbers are inconsistent, it's likely a multi-fabric platform,
-        * so invoke platform-specific handler
+        * On multi-fabric platform (e.g. Numascale NumaChip) a
+        * platform-specific handler needs to be called to fixup some
+        * IDs of the CPU.
         */
-       if (c->phys_proc_id != node)
+       if (x86_cpuinit.fixup_cpu_id)
                x86_cpuinit.fixup_cpu_id(c, node);
 
        if (!node_online(node)) {
@@ -579,6 +580,24 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
                }
        }
 
+       /* re-enable TopologyExtensions if switched off by BIOS */
+       if ((c->x86 == 0x15) &&
+           (c->x86_model >= 0x10) && (c->x86_model <= 0x1f) &&
+           !cpu_has(c, X86_FEATURE_TOPOEXT)) {
+               u64 val;
+
+               if (!rdmsrl_amd_safe(0xc0011005, &val)) {
+                       val |= 1ULL << 54;
+                       wrmsrl_amd_safe(0xc0011005, val);
+                       rdmsrl(0xc0011005, val);
+                       if (val & (1ULL << 54)) {
+                               set_cpu_cap(c, X86_FEATURE_TOPOEXT);
+                               printk(KERN_INFO FW_INFO "CPU: Re-enabling "
+                                 "disabled Topology Extensions Support\n");
+                       }
+               }
+       }
+
        cpu_detect_cache_sizes(c);
 
        /* Multi core CPU? */
index 67e258362a3d56d7f94c675ec876705003469c3a..cf79302198a620bc1e1e60740487f33d5244edbe 100644 (file)
@@ -1162,15 +1162,6 @@ static void dbg_restore_debug_regs(void)
 #define dbg_restore_debug_regs()
 #endif /* ! CONFIG_KGDB */
 
-/*
- * Prints an error where the NUMA and configured core-number mismatch and the
- * platform didn't override this to fix it up
- */
-void __cpuinit x86_default_fixup_cpu_id(struct cpuinfo_x86 *c, int node)
-{
-       pr_err("NUMA core number %d differs from configured core number %d\n", node, c->phys_proc_id);
-}
-
 /*
  * cpu_init() initializes state that is per-CPU. Some data is already
  * initialized (naturally) in the bootstrap process, such as the GDT
index 73d08ed98a64fc8beafb3c2e6768d19f02c09f89..b8f3653dddbc2daccf1d0da1990e74b8cab57202 100644 (file)
@@ -433,14 +433,14 @@ int amd_set_l3_disable_slot(struct amd_northbridge *nb, int cpu, unsigned slot,
        /*  check if @slot is already used or the index is already disabled */
        ret = amd_get_l3_disable_slot(nb, slot);
        if (ret >= 0)
-               return -EINVAL;
+               return -EEXIST;
 
        if (index > nb->l3_cache.indices)
                return -EINVAL;
 
        /* check whether the other slot has disabled the same index already */
        if (index == amd_get_l3_disable_slot(nb, !slot))
-               return -EINVAL;
+               return -EEXIST;
 
        amd_l3_disable_index(nb, cpu, slot, index);
 
@@ -468,8 +468,8 @@ static ssize_t store_cache_disable(struct _cpuid4_info *this_leaf,
        err = amd_set_l3_disable_slot(this_leaf->base.nb, cpu, slot, val);
        if (err) {
                if (err == -EEXIST)
-                       printk(KERN_WARNING "L3 disable slot %d in use!\n",
-                                           slot);
+                       pr_warning("L3 slot %d in use/index already disabled!\n",
+                                  slot);
                return err;
        }
        return count;
index 7734bcbb5a3a3b21e11374f82747972d678e8999..2d6e6498c176cda24349b01d5d89cd57b2cfb5ac 100644 (file)
@@ -235,6 +235,7 @@ int init_fpu(struct task_struct *tsk)
        if (tsk_used_math(tsk)) {
                if (HAVE_HWFP && tsk == current)
                        unlazy_fpu(tsk);
+               tsk->thread.fpu.last_cpu = ~0;
                return 0;
        }
 
index 73465aab28f87c09b5313e81e79d54a31afff1f1..8a2ce8fd41c0e68bbedc6fce685fb52c95502d24 100644 (file)
@@ -82,11 +82,6 @@ static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
 {
        struct cpuinfo_x86 *c = &cpu_data(cpu);
 
-       if (c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) {
-               pr_warning("CPU%d: family %d not supported\n", cpu, c->x86);
-               return -1;
-       }
-
        csig->rev = c->microcode;
        pr_info("CPU%d: patch_level=0x%08x\n", cpu, csig->rev);
 
@@ -380,6 +375,13 @@ static struct microcode_ops microcode_amd_ops = {
 
 struct microcode_ops * __init init_amd_microcode(void)
 {
+       struct cpuinfo_x86 *c = &cpu_data(0);
+
+       if (c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) {
+               pr_warning("AMD CPU family 0x%x not supported\n", c->x86);
+               return NULL;
+       }
+
        patch = (void *)get_zeroed_page(GFP_KERNEL);
        if (!patch)
                return NULL;
index 87a0f868830141cc6e508341c756640ace7fc34c..c9bda6d6035c83b06b2ac5e26aebca76b9fc4f34 100644 (file)
@@ -419,10 +419,8 @@ static int mc_device_add(struct device *dev, struct subsys_interface *sif)
        if (err)
                return err;
 
-       if (microcode_init_cpu(cpu) == UCODE_ERROR) {
-               sysfs_remove_group(&dev->kobj, &mc_attr_group);
+       if (microcode_init_cpu(cpu) == UCODE_ERROR)
                return -EINVAL;
-       }
 
        return err;
 }
@@ -528,11 +526,11 @@ static int __init microcode_init(void)
                microcode_ops = init_intel_microcode();
        else if (c->x86_vendor == X86_VENDOR_AMD)
                microcode_ops = init_amd_microcode();
-
-       if (!microcode_ops) {
+       else
                pr_err("no support for this CPU vendor\n");
+
+       if (!microcode_ops)
                return -ENODEV;
-       }
 
        microcode_pdev = platform_device_register_simple("microcode", -1,
                                                         NULL, 0);
index e9f265fd79ae11db4d5234e7b7462134c6220619..9cf71d0b2d373598b4db57b508061c08cd44e19b 100644 (file)
@@ -93,7 +93,6 @@ struct x86_init_ops x86_init __initdata = {
 struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
        .early_percpu_clock_init        = x86_init_noop,
        .setup_percpu_clockev           = setup_secondary_APIC_clock,
-       .fixup_cpu_id                   = x86_default_fixup_cpu_id,
 };
 
 static void default_nmi_init(void) { };
index 66d377e334f7711d0d2c388afe485e52d932212d..646e3b5b4bb6af37766f0fa81625b7d7f876d4d2 100644 (file)
@@ -63,7 +63,7 @@ static struct gpio_led net5501_leds[] = {
                .name = "net5501:1",
                .gpio = 6,
                .default_trigger = "default-on",
-               .active_low = 1,
+               .active_low = 0,
        },
 };
 
index e0a37233c0af7ca57362d23b3aba75a4d8bca30e..e31bcd8f2eeef2af6d2db13b824864b74867767d 100644 (file)
@@ -805,7 +805,7 @@ void intel_scu_devices_create(void)
                } else
                        i2c_register_board_info(i2c_bus[i], i2c_devs[i], 1);
        }
-       intel_scu_notifier_post(SCU_AVAILABLE, 0L);
+       intel_scu_notifier_post(SCU_AVAILABLE, NULL);
 }
 EXPORT_SYMBOL_GPL(intel_scu_devices_create);
 
@@ -814,7 +814,7 @@ void intel_scu_devices_destroy(void)
 {
        int i;
 
-       intel_scu_notifier_post(SCU_DOWN, 0L);
+       intel_scu_notifier_post(SCU_DOWN, NULL);
 
        for (i = 0; i < ipc_next_dev; i++)
                platform_device_del(ipc_devs[i]);
index 4f51bebac02c1493c5ed9a606327bf854b22be91..a8f8844b8d32690b8a189bc37d12cd3f286a81cd 100644 (file)
@@ -261,7 +261,8 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
 
 static bool __init xen_check_mwait(void)
 {
-#ifdef CONFIG_ACPI
+#if defined(CONFIG_ACPI) && !defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) && \
+       !defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE)
        struct xen_platform_op op = {
                .cmd                    = XENPF_set_processor_pminfo,
                .u.set_pminfo.id        = -1,
@@ -349,7 +350,6 @@ static void __init xen_init_cpuid_mask(void)
        /* Xen will set CR4.OSXSAVE if supported and not disabled by force */
        if ((cx & xsave_mask) != xsave_mask)
                cpuid_leaf1_ecx_mask &= ~xsave_mask; /* disable XSAVE & OSXSAVE */
-
        if (xen_check_mwait())
                cpuid_leaf1_ecx_set_mask = (1 << (X86_FEATURE_MWAIT % 32));
 }
index 5fac6919b957fa88a9b9cc130007671ffbc00d13..0503c0c493a9a64bf44b41fb237831cb290203fc 100644 (file)
@@ -178,6 +178,7 @@ static void __init xen_fill_possible_map(void)
 static void __init xen_filter_cpu_maps(void)
 {
        int i, rc;
+       unsigned int subtract = 0;
 
        if (!xen_initial_domain())
                return;
@@ -192,8 +193,22 @@ static void __init xen_filter_cpu_maps(void)
                } else {
                        set_cpu_possible(i, false);
                        set_cpu_present(i, false);
+                       subtract++;
                }
        }
+#ifdef CONFIG_HOTPLUG_CPU
+       /* This is akin to using 'nr_cpus' on the Linux command line.
+        * Which is OK as when we use 'dom0_max_vcpus=X' we can only
+        * have up to X, while nr_cpu_ids is greater than X. This
+        * normally is not a problem, except when CPU hotplugging
+        * is involved and then there might be more than X CPUs
+        * in the guest - which will not work as there is no
+        * hypercall to expand the max number of VCPUs an already
+        * running guest has. So cap it up to X. */
+       if (subtract)
+               nr_cpu_ids = nr_cpu_ids - subtract;
+#endif
+
 }
 
 static void __init xen_smp_prepare_boot_cpu(void)
index 79d7362ad6d1f0e0a6fab6aad37700e2a5dd038a..3e45aa000718aa2cd63d78f5c849e42666905d0e 100644 (file)
@@ -96,7 +96,7 @@ ENTRY(xen_restore_fl_direct)
 
        /* check for unmasked and pending */
        cmpw $0x0001, PER_CPU_VAR(xen_vcpu_info) + XEN_vcpu_info_pending
-       jz 1f
+       jnz 1f
 2:     call check_events
 1:
 ENDPATCH(xen_restore_fl_direct)
index 26664cef8f11dc990383fb62d7a5f8f6e4d1aac1..91695a135498cb45958881747f749bb48d98aab9 100644 (file)
@@ -11,9 +11,6 @@
 #ifndef _XTENSA_HARDIRQ_H
 #define _XTENSA_HARDIRQ_H
 
-void ack_bad_irq(unsigned int irq);
-#define ack_bad_irq ack_bad_irq
-
 #include <asm-generic/hardirq.h>
 
 #endif /* _XTENSA_HARDIRQ_H */
index d04cd3a625fa54906eda4e4339855c19aaecc5f5..4beb43c087d3dd6498daa296548c29b854701c5d 100644 (file)
@@ -14,6 +14,7 @@
 #ifdef __KERNEL__
 #include <asm/byteorder.h>
 #include <asm/page.h>
+#include <linux/bug.h>
 #include <linux/kernel.h>
 
 #include <linux/types.h>
index b69b000349fcdb20888a6e080cf8045ae82fc6b7..d78869a00b11c8a2a4584d26b6528dd98ff685c7 100644 (file)
@@ -496,6 +496,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
        signr = get_signal_to_deliver(&info, &ka, regs, NULL);
 
        if (signr > 0) {
+               int ret;
 
                /* Are we from a system call? */
 
index 7049a7d27c4f8bbd80991be1a633616474c0e2f4..330bb4d75852a02b928d3ac4bed0168458115bfc 100644 (file)
@@ -631,7 +631,7 @@ int acpi_power_get_inferred_state(struct acpi_device *device, int *state)
         * We know a device's inferred power state when all the resources
         * required for a given D-state are 'on'.
         */
-       for (i = ACPI_STATE_D0; i < ACPI_STATE_D3; i++) {
+       for (i = ACPI_STATE_D0; i < ACPI_STATE_D3_HOT; i++) {
                list = &device->power.states[i].resources;
                if (list->count < 1)
                        continue;
index 767e2dcb96169a9ef676b409b808ff823c280578..7417267e88fa9763617e0cc7e36fde6154ff4335 100644 (file)
@@ -869,7 +869,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
        /*
         * Enumerate supported power management states
         */
-       for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) {
+       for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3_HOT; i++) {
                struct acpi_device_power_state *ps = &device->power.states[i];
                char object_name[5] = { '_', 'P', 'R', '0' + i, '\0' };
 
@@ -884,21 +884,18 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
                                acpi_bus_add_power_resource(ps->resources.handles[j]);
                }
 
-               /* The exist of _PR3 indicates D3Cold support */
-               if (i == ACPI_STATE_D3) {
-                       status = acpi_get_handle(device->handle, object_name, &handle);
-                       if (ACPI_SUCCESS(status))
-                               device->power.states[ACPI_STATE_D3_COLD].flags.valid = 1;
-               }
-
                /* Evaluate "_PSx" to see if we can do explicit sets */
                object_name[2] = 'S';
                status = acpi_get_handle(device->handle, object_name, &handle);
                if (ACPI_SUCCESS(status))
                        ps->flags.explicit_set = 1;
 
-               /* State is valid if we have some power control */
-               if (ps->resources.count || ps->flags.explicit_set)
+               /*
+                * State is valid if there are means to put the device into it.
+                * D3hot is only valid if _PR3 present.
+                */
+               if (ps->resources.count ||
+                   (ps->flags.explicit_set && i < ACPI_STATE_D3_HOT))
                        ps->flags.valid = 1;
 
                ps->power = -1; /* Unknown - driver assigned */
index 1d661b5c3287fb4b5083a6636d13e48643da8d51..eb6fd233764bdeb7f28bc04626c23a1488db9af7 100644 (file)
 #include "internal.h"
 #include "sleep.h"
 
+u8 wake_sleep_flags = ACPI_NO_OPTIONAL_METHODS;
 static unsigned int gts, bfs;
-module_param(gts, uint, 0644);
-module_param(bfs, uint, 0644);
-MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend.");
-MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".);
-
-static u8 wake_sleep_flags(void)
+static int set_param_wake_flag(const char *val, struct kernel_param *kp)
 {
-       u8 flags = ACPI_NO_OPTIONAL_METHODS;
+       int ret = param_set_int(val, kp);
 
-       if (gts)
-               flags |= ACPI_EXECUTE_GTS;
-       if (bfs)
-               flags |= ACPI_EXECUTE_BFS;
+       if (ret)
+               return ret;
 
-       return flags;
+       if (kp->arg == (const char *)&gts) {
+               if (gts)
+                       wake_sleep_flags |= ACPI_EXECUTE_GTS;
+               else
+                       wake_sleep_flags &= ~ACPI_EXECUTE_GTS;
+       }
+       if (kp->arg == (const char *)&bfs) {
+               if (bfs)
+                       wake_sleep_flags |= ACPI_EXECUTE_BFS;
+               else
+                       wake_sleep_flags &= ~ACPI_EXECUTE_BFS;
+       }
+       return ret;
 }
+module_param_call(gts, set_param_wake_flag, param_get_int, &gts, 0644);
+module_param_call(bfs, set_param_wake_flag, param_get_int, &bfs, 0644);
+MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend.");
+MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".);
 
 static u8 sleep_states[ACPI_S_STATE_COUNT];
 
@@ -263,7 +273,6 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
 {
        acpi_status status = AE_OK;
        u32 acpi_state = acpi_target_sleep_state;
-       u8 flags = wake_sleep_flags();
        int error;
 
        ACPI_FLUSH_CPU_CACHE();
@@ -271,7 +280,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
        switch (acpi_state) {
        case ACPI_STATE_S1:
                barrier();
-               status = acpi_enter_sleep_state(acpi_state, flags);
+               status = acpi_enter_sleep_state(acpi_state, wake_sleep_flags);
                break;
 
        case ACPI_STATE_S3:
@@ -286,7 +295,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
        acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1);
 
        /* Reprogram control registers and execute _BFS */
-       acpi_leave_sleep_state_prep(acpi_state, flags);
+       acpi_leave_sleep_state_prep(acpi_state, wake_sleep_flags);
 
        /* ACPI 3.0 specs (P62) says that it's the responsibility
         * of the OSPM to clear the status bit [ implying that the
@@ -550,30 +559,27 @@ static int acpi_hibernation_begin(void)
 
 static int acpi_hibernation_enter(void)
 {
-       u8 flags = wake_sleep_flags();
        acpi_status status = AE_OK;
 
        ACPI_FLUSH_CPU_CACHE();
 
        /* This shouldn't return.  If it returns, we have a problem */
-       status = acpi_enter_sleep_state(ACPI_STATE_S4, flags);
+       status = acpi_enter_sleep_state(ACPI_STATE_S4, wake_sleep_flags);
        /* Reprogram control registers and execute _BFS */
-       acpi_leave_sleep_state_prep(ACPI_STATE_S4, flags);
+       acpi_leave_sleep_state_prep(ACPI_STATE_S4, wake_sleep_flags);
 
        return ACPI_SUCCESS(status) ? 0 : -EFAULT;
 }
 
 static void acpi_hibernation_leave(void)
 {
-       u8 flags = wake_sleep_flags();
-
        /*
         * If ACPI is not enabled by the BIOS and the boot kernel, we need to
         * enable it here.
         */
        acpi_enable();
        /* Reprogram control registers and execute _BFS */
-       acpi_leave_sleep_state_prep(ACPI_STATE_S4, flags);
+       acpi_leave_sleep_state_prep(ACPI_STATE_S4, wake_sleep_flags);
        /* Check the hardware signature */
        if (facs && s4_hardware_signature != facs->hardware_signature) {
                printk(KERN_EMERG "ACPI: Hardware changed while hibernated, "
@@ -828,12 +834,10 @@ static void acpi_power_off_prepare(void)
 
 static void acpi_power_off(void)
 {
-       u8 flags = wake_sleep_flags();
-
        /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
        printk(KERN_DEBUG "%s called\n", __func__);
        local_irq_disable();
-       acpi_enter_sleep_state(ACPI_STATE_S5, flags);
+       acpi_enter_sleep_state(ACPI_STATE_S5, wake_sleep_flags);
 }
 
 /*
index 79a1e9dd56d98abfc68155d46df733acbb3ee8e0..ebaf67e4b2bc7382f4c2cc6e985df47c9de26c52 100644 (file)
@@ -394,6 +394,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
          .driver_data = board_ahci_yes_fbs },                  /* 88se9128 */
        { PCI_DEVICE(0x1b4b, 0x9125),
          .driver_data = board_ahci_yes_fbs },                  /* 88se9125 */
+       { PCI_DEVICE(0x1b4b, 0x917a),
+         .driver_data = board_ahci_yes_fbs },                  /* 88se9172 */
        { PCI_DEVICE(0x1b4b, 0x91a3),
          .driver_data = board_ahci_yes_fbs },
 
index 0c86c77764bc7dec9f4bb6a2605aebac70abd18d..9e419e1c200629f9a556d519a0a553996727a554 100644 (file)
@@ -280,6 +280,7 @@ static struct dev_pm_ops ahci_pm_ops = {
 
 static const struct of_device_id ahci_of_match[] = {
        { .compatible = "calxeda,hb-ahci", },
+       { .compatible = "snps,spear-ahci", },
        {},
 };
 MODULE_DEVICE_TABLE(of, ahci_of_match);
index 28db50b57b918df812e5bb9f262243421dd97bea..23763a1ec570aa08149e23f65de1a7fb0087c860 100644 (file)
@@ -95,7 +95,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
 static void ata_dev_xfermask(struct ata_device *dev);
 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
 
-atomic_t ata_print_id = ATOMIC_INIT(1);
+atomic_t ata_print_id = ATOMIC_INIT(0);
 
 struct ata_force_param {
        const char      *name;
index c61316e9d2f7fe0aa45cf542093be2fd811eec05..d1fbd59ead167b50544749e40f711ba09e138083 100644 (file)
@@ -3501,7 +3501,8 @@ static int ata_count_probe_trials_cb(struct ata_ering_entry *ent, void *void_arg
        u64 now = get_jiffies_64();
        int *trials = void_arg;
 
-       if (ent->timestamp < now - min(now, interval))
+       if ((ent->eflags & ATA_EFLAG_OLD_ER) ||
+           (ent->timestamp < now - min(now, interval)))
                return -1;
 
        (*trials)++;
index 93dabdcd2cbe3712191f4ae05c0720a1bf42549d..22226350cd0c296b2849e59bc3f1b5e2927da9d2 100644 (file)
@@ -3399,7 +3399,8 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht)
                 */
                shost->max_host_blocked = 1;
 
-               rc = scsi_add_host(ap->scsi_host, &ap->tdev);
+               rc = scsi_add_host_with_dma(ap->scsi_host,
+                                               &ap->tdev, ap->host->dev);
                if (rc)
                        goto err_add;
        }
@@ -3838,18 +3839,25 @@ void ata_sas_port_stop(struct ata_port *ap)
 }
 EXPORT_SYMBOL_GPL(ata_sas_port_stop);
 
-int ata_sas_async_port_init(struct ata_port *ap)
+/**
+ * ata_sas_async_probe - simply schedule probing and return
+ * @ap: Port to probe
+ *
+ * For batch scheduling of probe for sas attached ata devices, assumes
+ * the port has already been through ata_sas_port_init()
+ */
+void ata_sas_async_probe(struct ata_port *ap)
 {
-       int rc = ap->ops->port_start(ap);
-
-       if (!rc) {
-               ap->print_id = atomic_inc_return(&ata_print_id);
-               __ata_port_probe(ap);
-       }
+       __ata_port_probe(ap);
+}
+EXPORT_SYMBOL_GPL(ata_sas_async_probe);
 
-       return rc;
+int ata_sas_sync_probe(struct ata_port *ap)
+{
+       return ata_port_probe(ap);
 }
-EXPORT_SYMBOL_GPL(ata_sas_async_port_init);
+EXPORT_SYMBOL_GPL(ata_sas_sync_probe);
+
 
 /**
  *     ata_sas_port_init - Initialize a SATA device
@@ -3866,12 +3874,10 @@ int ata_sas_port_init(struct ata_port *ap)
 {
        int rc = ap->ops->port_start(ap);
 
-       if (!rc) {
-               ap->print_id = atomic_inc_return(&ata_print_id);
-               rc = ata_port_probe(ap);
-       }
-
-       return rc;
+       if (rc)
+               return rc;
+       ap->print_id = atomic_inc_return(&ata_print_id);
+       return 0;
 }
 EXPORT_SYMBOL_GPL(ata_sas_port_init);
 
index fc2db2a89a6bb27b5d58722814a8e6f3f41957d8..3239517f4d902952654212f0a462d646fbd94608 100644 (file)
@@ -943,9 +943,9 @@ static int arasan_cf_resume(struct device *dev)
 
        return 0;
 }
+#endif
 
 static SIMPLE_DEV_PM_OPS(arasan_cf_pm_ops, arasan_cf_suspend, arasan_cf_resume);
-#endif
 
 static struct platform_driver arasan_cf_driver = {
        .probe          = arasan_cf_probe,
@@ -953,9 +953,7 @@ static struct platform_driver arasan_cf_driver = {
        .driver         = {
                .name   = DRIVER_NAME,
                .owner  = THIS_MODULE,
-#ifdef CONFIG_PM
                .pm     = &arasan_cf_pm_ops,
-#endif
        },
 };
 
index cdcf75c0954febe06c4ac04f030568470284c160..3e2a6002aae6d8ed588de7d33838f9df024798b5 100644 (file)
@@ -404,16 +404,19 @@ int bcma_sprom_get(struct bcma_bus *bus)
                return -EOPNOTSUPP;
 
        if (!bcma_sprom_ext_available(bus)) {
+               bool sprom_onchip;
+
                /*
                 * External SPROM takes precedence so check
                 * on-chip OTP only when no external SPROM
                 * is present.
                 */
-               if (bcma_sprom_onchip_available(bus)) {
+               sprom_onchip = bcma_sprom_onchip_available(bus);
+               if (sprom_onchip) {
                        /* determine offset */
                        offset = bcma_sprom_onchip_offset(bus);
                }
-               if (!offset) {
+               if (!offset || !sprom_onchip) {
                        /*
                         * Maybe there is no SPROM on the device?
                         * Now we ask the arch code if there is some sprom
index ae9edca7b56dc474a140c8f0eb579f556dc8e308..57fd867553d7ab1dc5fcf1737e3c19e8d8181257 100644 (file)
@@ -75,6 +75,8 @@ static struct usb_device_id ath3k_table[] = {
        { USB_DEVICE(0x0CF3, 0x311D) },
        { USB_DEVICE(0x13d3, 0x3375) },
        { USB_DEVICE(0x04CA, 0x3005) },
+       { USB_DEVICE(0x13d3, 0x3362) },
+       { USB_DEVICE(0x0CF3, 0xE004) },
 
        /* Atheros AR5BBU12 with sflash firmware */
        { USB_DEVICE(0x0489, 0xE02C) },
@@ -94,6 +96,8 @@ static struct usb_device_id ath3k_blist_tbl[] = {
        { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
        { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
        { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
+       { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
+       { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
 
        { }     /* Terminating entry */
 };
index 3311b812a0c68a37c9728c7bef3af2c050af587b..9217121362e10820da89b5678311b61ad6cac849 100644 (file)
@@ -101,12 +101,16 @@ static struct usb_device_id btusb_table[] = {
        { USB_DEVICE(0x0c10, 0x0000) },
 
        /* Broadcom BCM20702A0 */
+       { USB_DEVICE(0x0489, 0xe042) },
        { USB_DEVICE(0x0a5c, 0x21e3) },
        { USB_DEVICE(0x0a5c, 0x21e6) },
        { USB_DEVICE(0x0a5c, 0x21e8) },
        { USB_DEVICE(0x0a5c, 0x21f3) },
        { USB_DEVICE(0x413c, 0x8197) },
 
+       /* Foxconn - Hon Hai */
+       { USB_DEVICE(0x0489, 0xe033) },
+
        { }     /* Terminating entry */
 };
 
@@ -133,6 +137,8 @@ static struct usb_device_id blacklist_table[] = {
        { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
        { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
        { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
+       { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
+       { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
 
        /* Atheros AR5BBU12 with sflash firmware */
        { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
index 0f5e03d1ef5cde02c954bcdeba5773502d0f396f..b9a5158a30b1272452dd99e543c18781d797d404 100644 (file)
@@ -2,6 +2,6 @@
 obj-$(CONFIG_CLKDEV_LOOKUP)    += clkdev.o
 obj-$(CONFIG_COMMON_CLK)       += clk.o clk-fixed-rate.o clk-gate.o \
                                   clk-mux.o clk-divider.o clk-fixed-factor.o
-
 # SoCs specific
+obj-$(CONFIG_ARCH_MXS)         += mxs/
 obj-$(CONFIG_PLAT_SPEAR)       += spear/
diff --git a/drivers/clk/mxs/Makefile b/drivers/clk/mxs/Makefile
new file mode 100644 (file)
index 0000000..7bedeec
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# Makefile for mxs specific clk
+#
+
+obj-y += clk.o clk-pll.o clk-ref.o clk-div.o clk-frac.o
+
+obj-$(CONFIG_SOC_IMX23) += clk-imx23.o
+obj-$(CONFIG_SOC_IMX28) += clk-imx28.o
diff --git a/drivers/clk/mxs/clk-div.c b/drivers/clk/mxs/clk-div.c
new file mode 100644 (file)
index 0000000..90e1da9
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include "clk.h"
+
+/**
+ * struct clk_div - mxs integer divider clock
+ * @divider: the parent class
+ * @ops: pointer to clk_ops of parent class
+ * @reg: register address
+ * @busy: busy bit shift
+ *
+ * The mxs divider clock is a subclass of basic clk_divider with an
+ * addtional busy bit.
+ */
+struct clk_div {
+       struct clk_divider divider;
+       const struct clk_ops *ops;
+       void __iomem *reg;
+       u8 busy;
+};
+
+static inline struct clk_div *to_clk_div(struct clk_hw *hw)
+{
+       struct clk_divider *divider = container_of(hw, struct clk_divider, hw);
+
+       return container_of(divider, struct clk_div, divider);
+}
+
+static unsigned long clk_div_recalc_rate(struct clk_hw *hw,
+                                        unsigned long parent_rate)
+{
+       struct clk_div *div = to_clk_div(hw);
+
+       return div->ops->recalc_rate(&div->divider.hw, parent_rate);
+}
+
+static long clk_div_round_rate(struct clk_hw *hw, unsigned long rate,
+                              unsigned long *prate)
+{
+       struct clk_div *div = to_clk_div(hw);
+
+       return div->ops->round_rate(&div->divider.hw, rate, prate);
+}
+
+static int clk_div_set_rate(struct clk_hw *hw, unsigned long rate,
+                           unsigned long parent_rate)
+{
+       struct clk_div *div = to_clk_div(hw);
+       int ret;
+
+       ret = div->ops->set_rate(&div->divider.hw, rate, parent_rate);
+       if (!ret)
+               ret = mxs_clk_wait(div->reg, div->busy);
+
+       return ret;
+}
+
+static struct clk_ops clk_div_ops = {
+       .recalc_rate = clk_div_recalc_rate,
+       .round_rate = clk_div_round_rate,
+       .set_rate = clk_div_set_rate,
+};
+
+struct clk *mxs_clk_div(const char *name, const char *parent_name,
+                       void __iomem *reg, u8 shift, u8 width, u8 busy)
+{
+       struct clk_div *div;
+       struct clk *clk;
+       struct clk_init_data init;
+
+       div = kzalloc(sizeof(*div), GFP_KERNEL);
+       if (!div)
+               return ERR_PTR(-ENOMEM);
+
+       init.name = name;
+       init.ops = &clk_div_ops;
+       init.flags = CLK_SET_RATE_PARENT;
+       init.parent_names = (parent_name ? &parent_name: NULL);
+       init.num_parents = (parent_name ? 1 : 0);
+
+       div->reg = reg;
+       div->busy = busy;
+
+       div->divider.reg = reg;
+       div->divider.shift = shift;
+       div->divider.width = width;
+       div->divider.flags = CLK_DIVIDER_ONE_BASED;
+       div->divider.lock = &mxs_lock;
+       div->divider.hw.init = &init;
+       div->ops = &clk_divider_ops;
+
+       clk = clk_register(NULL, &div->divider.hw);
+       if (IS_ERR(clk))
+               kfree(div);
+
+       return clk;
+}
diff --git a/drivers/clk/mxs/clk-frac.c b/drivers/clk/mxs/clk-frac.c
new file mode 100644 (file)
index 0000000..e6aa6b5
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include "clk.h"
+
+/**
+ * struct clk_frac - mxs fractional divider clock
+ * @hw: clk_hw for the fractional divider clock
+ * @reg: register address
+ * @shift: the divider bit shift
+ * @width: the divider bit width
+ * @busy: busy bit shift
+ *
+ * The clock is an adjustable fractional divider with a busy bit to wait
+ * when the divider is adjusted.
+ */
+struct clk_frac {
+       struct clk_hw hw;
+       void __iomem *reg;
+       u8 shift;
+       u8 width;
+       u8 busy;
+};
+
+#define to_clk_frac(_hw) container_of(_hw, struct clk_frac, hw)
+
+static unsigned long clk_frac_recalc_rate(struct clk_hw *hw,
+                                         unsigned long parent_rate)
+{
+       struct clk_frac *frac = to_clk_frac(hw);
+       u32 div;
+
+       div = readl_relaxed(frac->reg) >> frac->shift;
+       div &= (1 << frac->width) - 1;
+
+       return (parent_rate >> frac->width) * div;
+}
+
+static long clk_frac_round_rate(struct clk_hw *hw, unsigned long rate,
+                               unsigned long *prate)
+{
+       struct clk_frac *frac = to_clk_frac(hw);
+       unsigned long parent_rate = *prate;
+       u32 div;
+       u64 tmp;
+
+       if (rate > parent_rate)
+               return -EINVAL;
+
+       tmp = rate;
+       tmp <<= frac->width;
+       do_div(tmp, parent_rate);
+       div = tmp;
+
+       if (!div)
+               return -EINVAL;
+
+       return (parent_rate >> frac->width) * div;
+}
+
+static int clk_frac_set_rate(struct clk_hw *hw, unsigned long rate,
+                            unsigned long parent_rate)
+{
+       struct clk_frac *frac = to_clk_frac(hw);
+       unsigned long flags;
+       u32 div, val;
+       u64 tmp;
+
+       if (rate > parent_rate)
+               return -EINVAL;
+
+       tmp = rate;
+       tmp <<= frac->width;
+       do_div(tmp, parent_rate);
+       div = tmp;
+
+       if (!div)
+               return -EINVAL;
+
+       spin_lock_irqsave(&mxs_lock, flags);
+
+       val = readl_relaxed(frac->reg);
+       val &= ~(((1 << frac->width) - 1) << frac->shift);
+       val |= div << frac->shift;
+       writel_relaxed(val, frac->reg);
+
+       spin_unlock_irqrestore(&mxs_lock, flags);
+
+       return mxs_clk_wait(frac->reg, frac->busy);
+}
+
+static struct clk_ops clk_frac_ops = {
+       .recalc_rate = clk_frac_recalc_rate,
+       .round_rate = clk_frac_round_rate,
+       .set_rate = clk_frac_set_rate,
+};
+
+struct clk *mxs_clk_frac(const char *name, const char *parent_name,
+                        void __iomem *reg, u8 shift, u8 width, u8 busy)
+{
+       struct clk_frac *frac;
+       struct clk *clk;
+       struct clk_init_data init;
+
+       frac = kzalloc(sizeof(*frac), GFP_KERNEL);
+       if (!frac)
+               return ERR_PTR(-ENOMEM);
+
+       init.name = name;
+       init.ops = &clk_frac_ops;
+       init.flags = CLK_SET_RATE_PARENT;
+       init.parent_names = (parent_name ? &parent_name: NULL);
+       init.num_parents = (parent_name ? 1 : 0);
+
+       frac->reg = reg;
+       frac->shift = shift;
+       frac->width = width;
+       frac->busy = busy;
+       frac->hw.init = &init;
+
+       clk = clk_register(NULL, &frac->hw);
+       if (IS_ERR(clk))
+               kfree(frac);
+
+       return clk;
+}
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
new file mode 100644 (file)
index 0000000..dcae112
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <mach/common.h>
+#include <mach/mx23.h>
+#include "clk.h"
+
+#define DIGCTRL                        MX23_IO_ADDRESS(MX23_DIGCTL_BASE_ADDR)
+#define CLKCTRL                        MX23_IO_ADDRESS(MX23_CLKCTRL_BASE_ADDR)
+#define PLLCTRL0               (CLKCTRL + 0x0000)
+#define CPU                    (CLKCTRL + 0x0020)
+#define HBUS                   (CLKCTRL + 0x0030)
+#define XBUS                   (CLKCTRL + 0x0040)
+#define XTAL                   (CLKCTRL + 0x0050)
+#define PIX                    (CLKCTRL + 0x0060)
+#define SSP                    (CLKCTRL + 0x0070)
+#define GPMI                   (CLKCTRL + 0x0080)
+#define SPDIF                  (CLKCTRL + 0x0090)
+#define EMI                    (CLKCTRL + 0x00a0)
+#define SAIF                   (CLKCTRL + 0x00c0)
+#define TV                     (CLKCTRL + 0x00d0)
+#define ETM                    (CLKCTRL + 0x00e0)
+#define FRAC                   (CLKCTRL + 0x00f0)
+#define CLKSEQ                 (CLKCTRL + 0x0110)
+
+#define BP_CPU_INTERRUPT_WAIT  12
+#define BP_CLKSEQ_BYPASS_SAIF  0
+#define BP_CLKSEQ_BYPASS_SSP   5
+#define BP_SAIF_DIV_FRAC_EN    16
+#define BP_FRAC_IOFRAC         24
+
+static void __init clk_misc_init(void)
+{
+       u32 val;
+
+       /* Gate off cpu clock in WFI for power saving */
+       __mxs_setl(1 << BP_CPU_INTERRUPT_WAIT, CPU);
+
+       /* Clear BYPASS for SAIF */
+       __mxs_clrl(1 << BP_CLKSEQ_BYPASS_SAIF, CLKSEQ);
+
+       /* SAIF has to use frac div for functional operation */
+       val = readl_relaxed(SAIF);
+       val |= 1 << BP_SAIF_DIV_FRAC_EN;
+       writel_relaxed(val, SAIF);
+
+       /*
+        * Source ssp clock from ref_io than ref_xtal,
+        * as ref_xtal only provides 24 MHz as maximum.
+        */
+       __mxs_clrl(1 << BP_CLKSEQ_BYPASS_SSP, CLKSEQ);
+
+       /*
+        * 480 MHz seems too high to be ssp clock source directly,
+        * so set frac to get a 288 MHz ref_io.
+        */
+       __mxs_clrl(0x3f << BP_FRAC_IOFRAC, FRAC);
+       __mxs_setl(30 << BP_FRAC_IOFRAC, FRAC);
+}
+
+static struct clk_lookup uart_lookups[] __initdata = {
+       { .dev_id = "duart", },
+       { .dev_id = "mxs-auart.0", },
+       { .dev_id = "mxs-auart.1", },
+       { .dev_id = "8006c000.serial", },
+       { .dev_id = "8006e000.serial", },
+       { .dev_id = "80070000.serial", },
+};
+
+static struct clk_lookup hbus_lookups[] __initdata = {
+       { .dev_id = "mxs-dma-apbh", },
+       { .dev_id = "80004000.dma-apbh", },
+};
+
+static struct clk_lookup xbus_lookups[] __initdata = {
+       { .dev_id = "duart", .con_id = "apb_pclk"},
+       { .dev_id = "mxs-dma-apbx", },
+       { .dev_id = "80024000.dma-apbx", },
+};
+
+static struct clk_lookup ssp_lookups[] __initdata = {
+       { .dev_id = "mxs-mmc.0", },
+       { .dev_id = "mxs-mmc.1", },
+       { .dev_id = "80010000.ssp", },
+       { .dev_id = "80034000.ssp", },
+};
+
+static struct clk_lookup lcdif_lookups[] __initdata = {
+       { .dev_id = "imx23-fb", },
+       { .dev_id = "80030000.lcdif", },
+};
+
+static struct clk_lookup gpmi_lookups[] __initdata = {
+       { .dev_id = "imx23-gpmi-nand", },
+       { .dev_id = "8000c000.gpmi", },
+};
+
+static const char *sel_pll[]  __initconst = { "pll", "ref_xtal", };
+static const char *sel_cpu[]  __initconst = { "ref_cpu", "ref_xtal", };
+static const char *sel_pix[]  __initconst = { "ref_pix", "ref_xtal", };
+static const char *sel_io[]   __initconst = { "ref_io", "ref_xtal", };
+static const char *cpu_sels[] __initconst = { "cpu_pll", "cpu_xtal", };
+static const char *emi_sels[] __initconst = { "emi_pll", "emi_xtal", };
+
+enum imx23_clk {
+       ref_xtal, pll, ref_cpu, ref_emi, ref_pix, ref_io, saif_sel,
+       lcdif_sel, gpmi_sel, ssp_sel, emi_sel, cpu, etm_sel, cpu_pll,
+       cpu_xtal, hbus, xbus, lcdif_div, ssp_div, gpmi_div, emi_pll,
+       emi_xtal, etm_div, saif_div, clk32k_div, rtc, adc, spdif_div,
+       clk32k, dri, pwm, filt, uart, ssp, gpmi, spdif, emi, saif,
+       lcdif, etm, usb, usb_pwr,
+       clk_max
+};
+
+static struct clk *clks[clk_max];
+
+static enum imx23_clk clks_init_on[] __initdata = {
+       cpu, hbus, xbus, emi, uart,
+};
+
+int __init mx23_clocks_init(void)
+{
+       int i;
+
+       clk_misc_init();
+
+       clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
+       clks[pll] = mxs_clk_pll("pll", "ref_xtal", PLLCTRL0, 16, 480000000);
+       clks[ref_cpu] = mxs_clk_ref("ref_cpu", "pll", FRAC, 0);
+       clks[ref_emi] = mxs_clk_ref("ref_emi", "pll", FRAC, 1);
+       clks[ref_pix] = mxs_clk_ref("ref_pix", "pll", FRAC, 2);
+       clks[ref_io] = mxs_clk_ref("ref_io", "pll", FRAC, 3);
+       clks[saif_sel] = mxs_clk_mux("saif_sel", CLKSEQ, 0, 1, sel_pll, ARRAY_SIZE(sel_pll));
+       clks[lcdif_sel] = mxs_clk_mux("lcdif_sel", CLKSEQ, 1, 1, sel_pix, ARRAY_SIZE(sel_pix));
+       clks[gpmi_sel] = mxs_clk_mux("gpmi_sel", CLKSEQ, 4, 1, sel_io, ARRAY_SIZE(sel_io));
+       clks[ssp_sel] = mxs_clk_mux("ssp_sel", CLKSEQ, 5, 1, sel_io, ARRAY_SIZE(sel_io));
+       clks[emi_sel] = mxs_clk_mux("emi_sel", CLKSEQ, 6, 1, emi_sels, ARRAY_SIZE(emi_sels));
+       clks[cpu] = mxs_clk_mux("cpu", CLKSEQ, 7, 1, cpu_sels, ARRAY_SIZE(cpu_sels));
+       clks[etm_sel] = mxs_clk_mux("etm_sel", CLKSEQ, 8, 1, sel_cpu, ARRAY_SIZE(sel_cpu));
+       clks[cpu_pll] = mxs_clk_div("cpu_pll", "ref_cpu", CPU, 0, 6, 28);
+       clks[cpu_xtal] = mxs_clk_div("cpu_xtal", "ref_xtal", CPU, 16, 10, 29);
+       clks[hbus] = mxs_clk_div("hbus", "cpu", HBUS, 0, 5, 29);
+       clks[xbus] = mxs_clk_div("xbus", "ref_xtal", XBUS, 0, 10, 31);
+       clks[lcdif_div] = mxs_clk_div("lcdif_div", "lcdif_sel", PIX, 0, 12, 29);
+       clks[ssp_div] = mxs_clk_div("ssp_div", "ssp_sel", SSP, 0, 9, 29);
+       clks[gpmi_div] = mxs_clk_div("gpmi_div", "gpmi_sel", GPMI, 0, 10, 29);
+       clks[emi_pll] = mxs_clk_div("emi_pll", "ref_emi", EMI, 0, 6, 28);
+       clks[emi_xtal] = mxs_clk_div("emi_xtal", "ref_xtal", EMI, 8, 4, 29);
+       clks[etm_div] = mxs_clk_div("etm_div", "etm_sel", ETM, 0, 6, 29);
+       clks[saif_div] = mxs_clk_frac("saif_div", "saif_sel", SAIF, 0, 16, 29);
+       clks[clk32k_div] = mxs_clk_fixed_factor("clk32k_div", "ref_xtal", 1, 750);
+       clks[rtc] = mxs_clk_fixed_factor("rtc", "ref_xtal", 1, 768);
+       clks[adc] = mxs_clk_fixed_factor("adc", "clk32k", 1, 16);
+       clks[spdif_div] = mxs_clk_fixed_factor("spdif_div", "pll", 1, 4);
+       clks[clk32k] = mxs_clk_gate("clk32k", "clk32k_div", XTAL, 26);
+       clks[dri] = mxs_clk_gate("dri", "ref_xtal", XTAL, 28);
+       clks[pwm] = mxs_clk_gate("pwm", "ref_xtal", XTAL, 29);
+       clks[filt] = mxs_clk_gate("filt", "ref_xtal", XTAL, 30);
+       clks[uart] = mxs_clk_gate("uart", "ref_xtal", XTAL, 31);
+       clks[ssp] = mxs_clk_gate("ssp", "ssp_div", SSP, 31);
+       clks[gpmi] = mxs_clk_gate("gpmi", "gpmi_div", GPMI, 31);
+       clks[spdif] = mxs_clk_gate("spdif", "spdif_div", SPDIF, 31);
+       clks[emi] = mxs_clk_gate("emi", "emi_sel", EMI, 31);
+       clks[saif] = mxs_clk_gate("saif", "saif_div", SAIF, 31);
+       clks[lcdif] = mxs_clk_gate("lcdif", "lcdif_div", PIX, 31);
+       clks[etm] = mxs_clk_gate("etm", "etm_div", ETM, 31);
+       clks[usb] = mxs_clk_gate("usb", "usb_pwr", DIGCTRL, 2);
+       clks[usb_pwr] = clk_register_gate(NULL, "usb_pwr", "pll", 0, PLLCTRL0, 18, 0, &mxs_lock);
+
+       for (i = 0; i < ARRAY_SIZE(clks); i++)
+               if (IS_ERR(clks[i])) {
+                       pr_err("i.MX23 clk %d: register failed with %ld\n",
+                               i, PTR_ERR(clks[i]));
+                       return PTR_ERR(clks[i]);
+               }
+
+       clk_register_clkdev(clks[clk32k], NULL, "timrot");
+       clk_register_clkdevs(clks[hbus], hbus_lookups, ARRAY_SIZE(hbus_lookups));
+       clk_register_clkdevs(clks[xbus], xbus_lookups, ARRAY_SIZE(xbus_lookups));
+       clk_register_clkdevs(clks[uart], uart_lookups, ARRAY_SIZE(uart_lookups));
+       clk_register_clkdevs(clks[ssp], ssp_lookups, ARRAY_SIZE(ssp_lookups));
+       clk_register_clkdevs(clks[gpmi], gpmi_lookups, ARRAY_SIZE(gpmi_lookups));
+       clk_register_clkdevs(clks[lcdif], lcdif_lookups, ARRAY_SIZE(lcdif_lookups));
+
+       for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
+               clk_prepare_enable(clks[clks_init_on[i]]);
+
+       mxs_timer_init(MX23_INT_TIMER0);
+
+       return 0;
+}
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
new file mode 100644 (file)
index 0000000..b2a3257
--- /dev/null
@@ -0,0 +1,337 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <mach/common.h>
+#include <mach/mx28.h>
+#include "clk.h"
+
+#define CLKCTRL                        MX28_IO_ADDRESS(MX28_CLKCTRL_BASE_ADDR)
+#define PLL0CTRL0              (CLKCTRL + 0x0000)
+#define PLL1CTRL0              (CLKCTRL + 0x0020)
+#define PLL2CTRL0              (CLKCTRL + 0x0040)
+#define CPU                    (CLKCTRL + 0x0050)
+#define HBUS                   (CLKCTRL + 0x0060)
+#define XBUS                   (CLKCTRL + 0x0070)
+#define XTAL                   (CLKCTRL + 0x0080)
+#define SSP0                   (CLKCTRL + 0x0090)
+#define SSP1                   (CLKCTRL + 0x00a0)
+#define SSP2                   (CLKCTRL + 0x00b0)
+#define SSP3                   (CLKCTRL + 0x00c0)
+#define GPMI                   (CLKCTRL + 0x00d0)
+#define SPDIF                  (CLKCTRL + 0x00e0)
+#define EMI                    (CLKCTRL + 0x00f0)
+#define SAIF0                  (CLKCTRL + 0x0100)
+#define SAIF1                  (CLKCTRL + 0x0110)
+#define LCDIF                  (CLKCTRL + 0x0120)
+#define ETM                    (CLKCTRL + 0x0130)
+#define ENET                   (CLKCTRL + 0x0140)
+#define FLEXCAN                        (CLKCTRL + 0x0160)
+#define FRAC0                  (CLKCTRL + 0x01b0)
+#define FRAC1                  (CLKCTRL + 0x01c0)
+#define CLKSEQ                 (CLKCTRL + 0x01d0)
+
+#define BP_CPU_INTERRUPT_WAIT  12
+#define BP_SAIF_DIV_FRAC_EN    16
+#define BP_ENET_DIV_TIME       21
+#define BP_ENET_SLEEP          31
+#define BP_CLKSEQ_BYPASS_SAIF0 0
+#define BP_CLKSEQ_BYPASS_SSP0  3
+#define BP_FRAC0_IO1FRAC       16
+#define BP_FRAC0_IO0FRAC       24
+
+#define DIGCTRL                        MX28_IO_ADDRESS(MX28_DIGCTL_BASE_ADDR)
+#define BP_SAIF_CLKMUX         10
+
+/*
+ * HW_SAIF_CLKMUX_SEL:
+ *  DIRECT(0x0): SAIF0 clock pins selected for SAIF0 input clocks, and SAIF1
+ *             clock pins selected for SAIF1 input clocks.
+ *  CROSSINPUT(0x1): SAIF1 clock inputs selected for SAIF0 input clocks, and
+ *             SAIF0 clock inputs selected for SAIF1 input clocks.
+ *  EXTMSTR0(0x2): SAIF0 clock pin selected for both SAIF0 and SAIF1 input
+ *             clocks.
+ *  EXTMSTR1(0x3): SAIF1 clock pin selected for both SAIF0 and SAIF1 input
+ *             clocks.
+ */
+int mxs_saif_clkmux_select(unsigned int clkmux)
+{
+       if (clkmux > 0x3)
+               return -EINVAL;
+
+       __mxs_clrl(0x3 << BP_SAIF_CLKMUX, DIGCTRL);
+       __mxs_setl(clkmux << BP_SAIF_CLKMUX, DIGCTRL);
+
+       return 0;
+}
+
+static void __init clk_misc_init(void)
+{
+       u32 val;
+
+       /* Gate off cpu clock in WFI for power saving */
+       __mxs_setl(1 << BP_CPU_INTERRUPT_WAIT, CPU);
+
+       /* 0 is a bad default value for a divider */
+       __mxs_setl(1 << BP_ENET_DIV_TIME, ENET);
+
+       /* Clear BYPASS for SAIF */
+       __mxs_clrl(0x3 << BP_CLKSEQ_BYPASS_SAIF0, CLKSEQ);
+
+       /* SAIF has to use frac div for functional operation */
+       val = readl_relaxed(SAIF0);
+       val |= 1 << BP_SAIF_DIV_FRAC_EN;
+       writel_relaxed(val, SAIF0);
+
+       val = readl_relaxed(SAIF1);
+       val |= 1 << BP_SAIF_DIV_FRAC_EN;
+       writel_relaxed(val, SAIF1);
+
+       /* Extra fec clock setting */
+       val = readl_relaxed(ENET);
+       val &= ~(1 << BP_ENET_SLEEP);
+       writel_relaxed(val, ENET);
+
+       /*
+        * Source ssp clock from ref_io than ref_xtal,
+        * as ref_xtal only provides 24 MHz as maximum.
+        */
+       __mxs_clrl(0xf << BP_CLKSEQ_BYPASS_SSP0, CLKSEQ);
+
+       /*
+        * 480 MHz seems too high to be ssp clock source directly,
+        * so set frac0 to get a 288 MHz ref_io0.
+        */
+       val = readl_relaxed(FRAC0);
+       val &= ~(0x3f << BP_FRAC0_IO0FRAC);
+       val |= 30 << BP_FRAC0_IO0FRAC;
+       writel_relaxed(val, FRAC0);
+}
+
+static struct clk_lookup uart_lookups[] __initdata = {
+       { .dev_id = "duart", },
+       { .dev_id = "mxs-auart.0", },
+       { .dev_id = "mxs-auart.1", },
+       { .dev_id = "mxs-auart.2", },
+       { .dev_id = "mxs-auart.3", },
+       { .dev_id = "mxs-auart.4", },
+       { .dev_id = "8006a000.serial", },
+       { .dev_id = "8006c000.serial", },
+       { .dev_id = "8006e000.serial", },
+       { .dev_id = "80070000.serial", },
+       { .dev_id = "80072000.serial", },
+       { .dev_id = "80074000.serial", },
+};
+
+static struct clk_lookup hbus_lookups[] __initdata = {
+       { .dev_id = "mxs-dma-apbh", },
+       { .dev_id = "80004000.dma-apbh", },
+};
+
+static struct clk_lookup xbus_lookups[] __initdata = {
+       { .dev_id = "duart", .con_id = "apb_pclk"},
+       { .dev_id = "mxs-dma-apbx", },
+       { .dev_id = "80024000.dma-apbx", },
+};
+
+static struct clk_lookup ssp0_lookups[] __initdata = {
+       { .dev_id = "mxs-mmc.0", },
+       { .dev_id = "80010000.ssp", },
+};
+
+static struct clk_lookup ssp1_lookups[] __initdata = {
+       { .dev_id = "mxs-mmc.1", },
+       { .dev_id = "80012000.ssp", },
+};
+
+static struct clk_lookup ssp2_lookups[] __initdata = {
+       { .dev_id = "mxs-mmc.2", },
+       { .dev_id = "80014000.ssp", },
+};
+
+static struct clk_lookup ssp3_lookups[] __initdata = {
+       { .dev_id = "mxs-mmc.3", },
+       { .dev_id = "80016000.ssp", },
+};
+
+static struct clk_lookup lcdif_lookups[] __initdata = {
+       { .dev_id = "imx28-fb", },
+       { .dev_id = "80030000.lcdif", },
+};
+
+static struct clk_lookup gpmi_lookups[] __initdata = {
+       { .dev_id = "imx28-gpmi-nand", },
+       { .dev_id = "8000c000.gpmi", },
+};
+
+static struct clk_lookup fec_lookups[] __initdata = {
+       { .dev_id = "imx28-fec.0", },
+       { .dev_id = "imx28-fec.1", },
+       { .dev_id = "800f0000.ethernet", },
+       { .dev_id = "800f4000.ethernet", },
+};
+
+static struct clk_lookup can0_lookups[] __initdata = {
+       { .dev_id = "flexcan.0", },
+       { .dev_id = "80032000.can", },
+};
+
+static struct clk_lookup can1_lookups[] __initdata = {
+       { .dev_id = "flexcan.1", },
+       { .dev_id = "80034000.can", },
+};
+
+static struct clk_lookup saif0_lookups[] __initdata = {
+       { .dev_id = "mxs-saif.0", },
+       { .dev_id = "80042000.saif", },
+};
+
+static struct clk_lookup saif1_lookups[] __initdata = {
+       { .dev_id = "mxs-saif.1", },
+       { .dev_id = "80046000.saif", },
+};
+
+static const char *sel_cpu[]  __initconst = { "ref_cpu", "ref_xtal", };
+static const char *sel_io0[]  __initconst = { "ref_io0", "ref_xtal", };
+static const char *sel_io1[]  __initconst = { "ref_io1", "ref_xtal", };
+static const char *sel_pix[]  __initconst = { "ref_pix", "ref_xtal", };
+static const char *sel_gpmi[] __initconst = { "ref_gpmi", "ref_xtal", };
+static const char *sel_pll0[] __initconst = { "pll0", "ref_xtal", };
+static const char *cpu_sels[] __initconst = { "cpu_pll", "cpu_xtal", };
+static const char *emi_sels[] __initconst = { "emi_pll", "emi_xtal", };
+static const char *ptp_sels[] __initconst = { "ref_xtal", "pll0", };
+
+enum imx28_clk {
+       ref_xtal, pll0, pll1, pll2, ref_cpu, ref_emi, ref_io0, ref_io1,
+       ref_pix, ref_hsadc, ref_gpmi, saif0_sel, saif1_sel, gpmi_sel,
+       ssp0_sel, ssp1_sel, ssp2_sel, ssp3_sel, emi_sel, etm_sel,
+       lcdif_sel, cpu, ptp_sel, cpu_pll, cpu_xtal, hbus, xbus,
+       ssp0_div, ssp1_div, ssp2_div, ssp3_div, gpmi_div, emi_pll,
+       emi_xtal, lcdif_div, etm_div, ptp, saif0_div, saif1_div,
+       clk32k_div, rtc, lradc, spdif_div, clk32k, pwm, uart, ssp0,
+       ssp1, ssp2, ssp3, gpmi, spdif, emi, saif0, saif1, lcdif, etm,
+       fec, can0, can1, usb0, usb1, usb0_pwr, usb1_pwr, enet_out,
+       clk_max
+};
+
+static struct clk *clks[clk_max];
+
+static enum imx28_clk clks_init_on[] __initdata = {
+       cpu, hbus, xbus, emi, uart,
+};
+
+int __init mx28_clocks_init(void)
+{
+       int i;
+
+       clk_misc_init();
+
+       clks[ref_xtal] = mxs_clk_fixed("ref_xtal", 24000000);
+       clks[pll0] = mxs_clk_pll("pll0", "ref_xtal", PLL0CTRL0, 17, 480000000);
+       clks[pll1] = mxs_clk_pll("pll1", "ref_xtal", PLL1CTRL0, 17, 480000000);
+       clks[pll2] = mxs_clk_pll("pll2", "ref_xtal", PLL2CTRL0, 23, 50000000);
+       clks[ref_cpu] = mxs_clk_ref("ref_cpu", "pll0", FRAC0, 0);
+       clks[ref_emi] = mxs_clk_ref("ref_emi", "pll0", FRAC0, 1);
+       clks[ref_io0] = mxs_clk_ref("ref_io0", "pll0", FRAC0, 2);
+       clks[ref_io1] = mxs_clk_ref("ref_io1", "pll0", FRAC0, 3);
+       clks[ref_pix] = mxs_clk_ref("ref_pix", "pll0", FRAC1, 0);
+       clks[ref_hsadc] = mxs_clk_ref("ref_hsadc", "pll0", FRAC1, 1);
+       clks[ref_gpmi] = mxs_clk_ref("ref_gpmi", "pll0", FRAC1, 2);
+       clks[saif0_sel] = mxs_clk_mux("saif0_sel", CLKSEQ, 0, 1, sel_pll0, ARRAY_SIZE(sel_pll0));
+       clks[saif1_sel] = mxs_clk_mux("saif1_sel", CLKSEQ, 1, 1, sel_pll0, ARRAY_SIZE(sel_pll0));
+       clks[gpmi_sel] = mxs_clk_mux("gpmi_sel", CLKSEQ, 2, 1, sel_gpmi, ARRAY_SIZE(sel_gpmi));
+       clks[ssp0_sel] = mxs_clk_mux("ssp0_sel", CLKSEQ, 3, 1, sel_io0, ARRAY_SIZE(sel_io0));
+       clks[ssp1_sel] = mxs_clk_mux("ssp1_sel", CLKSEQ, 4, 1, sel_io0, ARRAY_SIZE(sel_io0));
+       clks[ssp2_sel] = mxs_clk_mux("ssp2_sel", CLKSEQ, 5, 1, sel_io1, ARRAY_SIZE(sel_io1));
+       clks[ssp3_sel] = mxs_clk_mux("ssp3_sel", CLKSEQ, 6, 1, sel_io1, ARRAY_SIZE(sel_io1));
+       clks[emi_sel] = mxs_clk_mux("emi_sel", CLKSEQ, 7, 1, emi_sels, ARRAY_SIZE(emi_sels));
+       clks[etm_sel] = mxs_clk_mux("etm_sel", CLKSEQ, 8, 1, sel_cpu, ARRAY_SIZE(sel_cpu));
+       clks[lcdif_sel] = mxs_clk_mux("lcdif_sel", CLKSEQ, 14, 1, sel_pix, ARRAY_SIZE(sel_pix));
+       clks[cpu] = mxs_clk_mux("cpu", CLKSEQ, 18, 1, cpu_sels, ARRAY_SIZE(cpu_sels));
+       clks[ptp_sel] = mxs_clk_mux("ptp_sel", ENET, 19, 1, ptp_sels, ARRAY_SIZE(ptp_sels));
+       clks[cpu_pll] = mxs_clk_div("cpu_pll", "ref_cpu", CPU, 0, 6, 28);
+       clks[cpu_xtal] = mxs_clk_div("cpu_xtal", "ref_xtal", CPU, 16, 10, 29);
+       clks[hbus] = mxs_clk_div("hbus", "cpu", HBUS, 0, 5, 31);
+       clks[xbus] = mxs_clk_div("xbus", "ref_xtal", XBUS, 0, 10, 31);
+       clks[ssp0_div] = mxs_clk_div("ssp0_div", "ssp0_sel", SSP0, 0, 9, 29);
+       clks[ssp1_div] = mxs_clk_div("ssp1_div", "ssp1_sel", SSP1, 0, 9, 29);
+       clks[ssp2_div] = mxs_clk_div("ssp2_div", "ssp2_sel", SSP2, 0, 9, 29);
+       clks[ssp3_div] = mxs_clk_div("ssp3_div", "ssp3_sel", SSP3, 0, 9, 29);
+       clks[gpmi_div] = mxs_clk_div("gpmi_div", "gpmi_sel", GPMI, 0, 10, 29);
+       clks[emi_pll] = mxs_clk_div("emi_pll", "ref_emi", EMI, 0, 6, 28);
+       clks[emi_xtal] = mxs_clk_div("emi_xtal", "ref_xtal", EMI, 8, 4, 29);
+       clks[lcdif_div] = mxs_clk_div("lcdif_div", "lcdif_sel", LCDIF, 0, 13, 29);
+       clks[etm_div] = mxs_clk_div("etm_div", "etm_sel", ETM, 0, 7, 29);
+       clks[ptp] = mxs_clk_div("ptp", "ptp_sel", ENET, 21, 6, 27);
+       clks[saif0_div] = mxs_clk_frac("saif0_div", "saif0_sel", SAIF0, 0, 16, 29);
+       clks[saif1_div] = mxs_clk_frac("saif1_div", "saif1_sel", SAIF1, 0, 16, 29);
+       clks[clk32k_div] = mxs_clk_fixed_factor("clk32k_div", "ref_xtal", 1, 750);
+       clks[rtc] = mxs_clk_fixed_factor("rtc", "ref_xtal", 1, 768);
+       clks[lradc] = mxs_clk_fixed_factor("lradc", "clk32k", 1, 16);
+       clks[spdif_div] = mxs_clk_fixed_factor("spdif_div", "pll0", 1, 4);
+       clks[clk32k] = mxs_clk_gate("clk32k", "clk32k_div", XTAL, 26);
+       clks[pwm] = mxs_clk_gate("pwm", "ref_xtal", XTAL, 29);
+       clks[uart] = mxs_clk_gate("uart", "ref_xtal", XTAL, 31);
+       clks[ssp0] = mxs_clk_gate("ssp0", "ssp0_div", SSP0, 31);
+       clks[ssp1] = mxs_clk_gate("ssp1", "ssp1_div", SSP1, 31);
+       clks[ssp2] = mxs_clk_gate("ssp2", "ssp2_div", SSP2, 31);
+       clks[ssp3] = mxs_clk_gate("ssp3", "ssp3_div", SSP3, 31);
+       clks[gpmi] = mxs_clk_gate("gpmi", "gpmi_div", GPMI, 31);
+       clks[spdif] = mxs_clk_gate("spdif", "spdif_div", SPDIF, 31);
+       clks[emi] = mxs_clk_gate("emi", "emi_sel", EMI, 31);
+       clks[saif0] = mxs_clk_gate("saif0", "saif0_div", SAIF0, 31);
+       clks[saif1] = mxs_clk_gate("saif1", "saif1_div", SAIF1, 31);
+       clks[lcdif] = mxs_clk_gate("lcdif", "lcdif_div", LCDIF, 31);
+       clks[etm] = mxs_clk_gate("etm", "etm_div", ETM, 31);
+       clks[fec] = mxs_clk_gate("fec", "hbus", ENET, 30);
+       clks[can0] = mxs_clk_gate("can0", "ref_xtal", FLEXCAN, 30);
+       clks[can1] = mxs_clk_gate("can1", "ref_xtal", FLEXCAN, 28);
+       clks[usb0] = mxs_clk_gate("usb0", "usb0_pwr", DIGCTRL, 2);
+       clks[usb1] = mxs_clk_gate("usb1", "usb1_pwr", DIGCTRL, 16);
+       clks[usb0_pwr] = clk_register_gate(NULL, "usb0_pwr", "pll0", 0, PLL0CTRL0, 18, 0, &mxs_lock);
+       clks[usb1_pwr] = clk_register_gate(NULL, "usb1_pwr", "pll1", 0, PLL1CTRL0, 18, 0, &mxs_lock);
+       clks[enet_out] = clk_register_gate(NULL, "enet_out", "pll2", 0, ENET, 18, 0, &mxs_lock);
+
+       for (i = 0; i < ARRAY_SIZE(clks); i++)
+               if (IS_ERR(clks[i])) {
+                       pr_err("i.MX28 clk %d: register failed with %ld\n",
+                               i, PTR_ERR(clks[i]));
+                       return PTR_ERR(clks[i]);
+               }
+
+       clk_register_clkdev(clks[clk32k], NULL, "timrot");
+       clk_register_clkdev(clks[enet_out], NULL, "enet_out");
+       clk_register_clkdevs(clks[hbus], hbus_lookups, ARRAY_SIZE(hbus_lookups));
+       clk_register_clkdevs(clks[xbus], xbus_lookups, ARRAY_SIZE(xbus_lookups));
+       clk_register_clkdevs(clks[uart], uart_lookups, ARRAY_SIZE(uart_lookups));
+       clk_register_clkdevs(clks[ssp0], ssp0_lookups, ARRAY_SIZE(ssp0_lookups));
+       clk_register_clkdevs(clks[ssp1], ssp1_lookups, ARRAY_SIZE(ssp1_lookups));
+       clk_register_clkdevs(clks[ssp2], ssp2_lookups, ARRAY_SIZE(ssp2_lookups));
+       clk_register_clkdevs(clks[ssp3], ssp3_lookups, ARRAY_SIZE(ssp3_lookups));
+       clk_register_clkdevs(clks[gpmi], gpmi_lookups, ARRAY_SIZE(gpmi_lookups));
+       clk_register_clkdevs(clks[saif0], saif0_lookups, ARRAY_SIZE(saif0_lookups));
+       clk_register_clkdevs(clks[saif1], saif1_lookups, ARRAY_SIZE(saif1_lookups));
+       clk_register_clkdevs(clks[lcdif], lcdif_lookups, ARRAY_SIZE(lcdif_lookups));
+       clk_register_clkdevs(clks[fec], fec_lookups, ARRAY_SIZE(fec_lookups));
+       clk_register_clkdevs(clks[can0], can0_lookups, ARRAY_SIZE(can0_lookups));
+       clk_register_clkdevs(clks[can1], can1_lookups, ARRAY_SIZE(can1_lookups));
+
+       for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
+               clk_prepare_enable(clks[clks_init_on[i]]);
+
+       mxs_timer_init(MX28_INT_TIMER0);
+
+       return 0;
+}
diff --git a/drivers/clk/mxs/clk-pll.c b/drivers/clk/mxs/clk-pll.c
new file mode 100644 (file)
index 0000000..fadae41
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include "clk.h"
+
+/**
+ * struct clk_pll - mxs pll clock
+ * @hw: clk_hw for the pll
+ * @base: base address of the pll
+ * @power: the shift of power bit
+ * @rate: the clock rate of the pll
+ *
+ * The mxs pll is a fixed rate clock with power and gate control,
+ * and the shift of gate bit is always 31.
+ */
+struct clk_pll {
+       struct clk_hw hw;
+       void __iomem *base;
+       u8 power;
+       unsigned long rate;
+};
+
+#define to_clk_pll(_hw) container_of(_hw, struct clk_pll, hw)
+
+static int clk_pll_prepare(struct clk_hw *hw)
+{
+       struct clk_pll *pll = to_clk_pll(hw);
+
+       writel_relaxed(1 << pll->power, pll->base + SET);
+
+       udelay(10);
+
+       return 0;
+}
+
+static void clk_pll_unprepare(struct clk_hw *hw)
+{
+       struct clk_pll *pll = to_clk_pll(hw);
+
+       writel_relaxed(1 << pll->power, pll->base + CLR);
+}
+
+static int clk_pll_enable(struct clk_hw *hw)
+{
+       struct clk_pll *pll = to_clk_pll(hw);
+
+       writel_relaxed(1 << 31, pll->base + CLR);
+
+       return 0;
+}
+
+static void clk_pll_disable(struct clk_hw *hw)
+{
+       struct clk_pll *pll = to_clk_pll(hw);
+
+       writel_relaxed(1 << 31, pll->base + SET);
+}
+
+static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,
+                                        unsigned long parent_rate)
+{
+       struct clk_pll *pll = to_clk_pll(hw);
+
+       return pll->rate;
+}
+
+static const struct clk_ops clk_pll_ops = {
+       .prepare = clk_pll_prepare,
+       .unprepare = clk_pll_unprepare,
+       .enable = clk_pll_enable,
+       .disable = clk_pll_disable,
+       .recalc_rate = clk_pll_recalc_rate,
+};
+
+struct clk *mxs_clk_pll(const char *name, const char *parent_name,
+                       void __iomem *base, u8 power, unsigned long rate)
+{
+       struct clk_pll *pll;
+       struct clk *clk;
+       struct clk_init_data init;
+
+       pll = kzalloc(sizeof(*pll), GFP_KERNEL);
+       if (!pll)
+               return ERR_PTR(-ENOMEM);
+
+       init.name = name;
+       init.ops = &clk_pll_ops;
+       init.flags = 0;
+       init.parent_names = (parent_name ? &parent_name: NULL);
+       init.num_parents = (parent_name ? 1 : 0);
+
+       pll->base = base;
+       pll->rate = rate;
+       pll->power = power;
+       pll->hw.init = &init;
+
+       clk = clk_register(NULL, &pll->hw);
+       if (IS_ERR(clk))
+               kfree(pll);
+
+       return clk;
+}
diff --git a/drivers/clk/mxs/clk-ref.c b/drivers/clk/mxs/clk-ref.c
new file mode 100644 (file)
index 0000000..4adeed6
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include "clk.h"
+
+/**
+ * struct clk_ref - mxs reference clock
+ * @hw: clk_hw for the reference clock
+ * @reg: register address
+ * @idx: the index of the reference clock within the same register
+ *
+ * The mxs reference clock sources from pll.  Every 4 reference clocks share
+ * one register space, and @idx is used to identify them.  Each reference
+ * clock has a gate control and a fractional * divider.  The rate is calculated
+ * as pll rate  * (18 / FRAC), where FRAC = 18 ~ 35.
+ */
+struct clk_ref {
+       struct clk_hw hw;
+       void __iomem *reg;
+       u8 idx;
+};
+
+#define to_clk_ref(_hw) container_of(_hw, struct clk_ref, hw)
+
+static int clk_ref_enable(struct clk_hw *hw)
+{
+       struct clk_ref *ref = to_clk_ref(hw);
+
+       writel_relaxed(1 << ((ref->idx + 1) * 8 - 1), ref->reg + CLR);
+
+       return 0;
+}
+
+static void clk_ref_disable(struct clk_hw *hw)
+{
+       struct clk_ref *ref = to_clk_ref(hw);
+
+       writel_relaxed(1 << ((ref->idx + 1) * 8 - 1), ref->reg + SET);
+}
+
+static unsigned long clk_ref_recalc_rate(struct clk_hw *hw,
+                                        unsigned long parent_rate)
+{
+       struct clk_ref *ref = to_clk_ref(hw);
+       u64 tmp = parent_rate;
+       u8 frac = (readl_relaxed(ref->reg) >> (ref->idx * 8)) & 0x3f;
+
+       tmp *= 18;
+       do_div(tmp, frac);
+
+       return tmp;
+}
+
+static long clk_ref_round_rate(struct clk_hw *hw, unsigned long rate,
+                              unsigned long *prate)
+{
+       unsigned long parent_rate = *prate;
+       u64 tmp = parent_rate;
+       u8 frac;
+
+       tmp = tmp * 18 + rate / 2;
+       do_div(tmp, rate);
+       frac = tmp;
+
+       if (frac < 18)
+               frac = 18;
+       else if (frac > 35)
+               frac = 35;
+
+       tmp = parent_rate;
+       tmp *= 18;
+       do_div(tmp, frac);
+
+       return tmp;
+}
+
+static int clk_ref_set_rate(struct clk_hw *hw, unsigned long rate,
+                           unsigned long parent_rate)
+{
+       struct clk_ref *ref = to_clk_ref(hw);
+       unsigned long flags;
+       u64 tmp = parent_rate;
+       u32 val;
+       u8 frac, shift = ref->idx * 8;
+
+       tmp = tmp * 18 + rate / 2;
+       do_div(tmp, rate);
+       frac = tmp;
+
+       if (frac < 18)
+               frac = 18;
+       else if (frac > 35)
+               frac = 35;
+
+       spin_lock_irqsave(&mxs_lock, flags);
+
+       val = readl_relaxed(ref->reg);
+       val &= ~(0x3f << shift);
+       val |= frac << shift;
+       writel_relaxed(val, ref->reg);
+
+       spin_unlock_irqrestore(&mxs_lock, flags);
+
+       return 0;
+}
+
+static const struct clk_ops clk_ref_ops = {
+       .enable         = clk_ref_enable,
+       .disable        = clk_ref_disable,
+       .recalc_rate    = clk_ref_recalc_rate,
+       .round_rate     = clk_ref_round_rate,
+       .set_rate       = clk_ref_set_rate,
+};
+
+struct clk *mxs_clk_ref(const char *name, const char *parent_name,
+                       void __iomem *reg, u8 idx)
+{
+       struct clk_ref *ref;
+       struct clk *clk;
+       struct clk_init_data init;
+
+       ref = kzalloc(sizeof(*ref), GFP_KERNEL);
+       if (!ref)
+               return ERR_PTR(-ENOMEM);
+
+       init.name = name;
+       init.ops = &clk_ref_ops;
+       init.flags = 0;
+       init.parent_names = (parent_name ? &parent_name: NULL);
+       init.num_parents = (parent_name ? 1 : 0);
+
+       ref->reg = reg;
+       ref->idx = idx;
+       ref->hw.init = &init;
+
+       clk = clk_register(NULL, &ref->hw);
+       if (IS_ERR(clk))
+               kfree(ref);
+
+       return clk;
+}
diff --git a/drivers/clk/mxs/clk.c b/drivers/clk/mxs/clk.c
new file mode 100644 (file)
index 0000000..b24d560
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/jiffies.h>
+#include <linux/spinlock.h>
+
+DEFINE_SPINLOCK(mxs_lock);
+
+int mxs_clk_wait(void __iomem *reg, u8 shift)
+{
+       unsigned long timeout = jiffies + msecs_to_jiffies(10);
+
+       while (readl_relaxed(reg) & (1 << shift))
+               if (time_after(jiffies, timeout))
+                       return -ETIMEDOUT;
+
+       return 0;
+}
diff --git a/drivers/clk/mxs/clk.h b/drivers/clk/mxs/clk.h
new file mode 100644 (file)
index 0000000..81421e2
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#ifndef __MXS_CLK_H
+#define __MXS_CLK_H
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/spinlock.h>
+
+#define SET    0x4
+#define CLR    0x8
+
+extern spinlock_t mxs_lock;
+
+int mxs_clk_wait(void __iomem *reg, u8 shift);
+
+struct clk *mxs_clk_pll(const char *name, const char *parent_name,
+                       void __iomem *base, u8 power, unsigned long rate);
+
+struct clk *mxs_clk_ref(const char *name, const char *parent_name,
+                       void __iomem *reg, u8 idx);
+
+struct clk *mxs_clk_div(const char *name, const char *parent_name,
+                       void __iomem *reg, u8 shift, u8 width, u8 busy);
+
+struct clk *mxs_clk_frac(const char *name, const char *parent_name,
+                        void __iomem *reg, u8 shift, u8 width, u8 busy);
+
+static inline struct clk *mxs_clk_fixed(const char *name, int rate)
+{
+       return clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
+}
+
+static inline struct clk *mxs_clk_gate(const char *name,
+                       const char *parent_name, void __iomem *reg, u8 shift)
+{
+       return clk_register_gate(NULL, name, parent_name, CLK_SET_RATE_PARENT,
+                                reg, shift, CLK_GATE_SET_TO_DISABLE,
+                                &mxs_lock);
+}
+
+static inline struct clk *mxs_clk_mux(const char *name, void __iomem *reg,
+               u8 shift, u8 width, const char **parent_names, int num_parents)
+{
+       return clk_register_mux(NULL, name, parent_names, num_parents,
+                               CLK_SET_RATE_PARENT, reg, shift, width,
+                               0, &mxs_lock);
+}
+
+static inline struct clk *mxs_clk_fixed_factor(const char *name,
+               const char *parent_name, unsigned int mult, unsigned int div)
+{
+       return clk_register_fixed_factor(NULL, name, parent_name,
+                                        CLK_SET_RATE_PARENT, mult, div);
+}
+
+#endif /* __MXS_CLK_H */
index c301a8ec31aa109583cd4ab54bc9304c3e95ceb2..3d704abd7912b1ce9a2bd236e84188fdd81aace3 100644 (file)
@@ -1429,6 +1429,7 @@ static int pl08x_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
                         * signal
                         */
                        release_phy_channel(plchan);
+                       plchan->phychan_hold = 0;
                }
                /* Dequeue jobs and free LLIs */
                if (plchan->at) {
index 7aa58d2048923721d7448464120515137ecc961f..445fdf8116959e91bff7469bf45c6283e057b198 100644 (file)
@@ -221,10 +221,6 @@ static void atc_dostart(struct at_dma_chan *atchan, struct at_desc *first)
 
        vdbg_dump_regs(atchan);
 
-       /* clear any pending interrupt */
-       while (dma_readl(atdma, EBCISR))
-               cpu_relax();
-
        channel_writel(atchan, SADDR, 0);
        channel_writel(atchan, DADDR, 0);
        channel_writel(atchan, CTRLA, 0);
index a45b5d2a59879a02b3566dfaf2c8304f8d693921..bb787d8e15296ed17eef8032be17f4b52647d173 100644 (file)
@@ -571,11 +571,14 @@ static void imxdma_tasklet(unsigned long data)
        if (desc->desc.callback)
                desc->desc.callback(desc->desc.callback_param);
 
-       dma_cookie_complete(&desc->desc);
-
-       /* If we are dealing with a cyclic descriptor keep it on ld_active */
+       /* If we are dealing with a cyclic descriptor keep it on ld_active
+        * and dont mark the descripor as complete.
+        * Only in non-cyclic cases it would be marked as complete
+        */
        if (imxdma_chan_is_doing_cyclic(imxdmac))
                goto out;
+       else
+               dma_cookie_complete(&desc->desc);
 
        /* Free 2D slot if it was an interleaved transfer */
        if (imxdmac->enabled_2d) {
index d3e38e28bb6b19a480eb1b05b732a0dc2f40eb7f..fddccae6b47660ce68a3fd7dc72c6625d87a180a 100644 (file)
@@ -322,7 +322,8 @@ struct sdma_engine {
        struct sdma_context_data        *context;
        dma_addr_t                      context_phys;
        struct dma_device               dma_device;
-       struct clk                      *clk;
+       struct clk                      *clk_ipg;
+       struct clk                      *clk_ahb;
        struct mutex                    channel_0_lock;
        struct sdma_script_start_addrs  *script_addrs;
 };
@@ -859,7 +860,8 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan)
        sdmac->peripheral_type = data->peripheral_type;
        sdmac->event_id0 = data->dma_request;
 
-       clk_enable(sdmac->sdma->clk);
+       clk_enable(sdmac->sdma->clk_ipg);
+       clk_enable(sdmac->sdma->clk_ahb);
 
        ret = sdma_request_channel(sdmac);
        if (ret)
@@ -896,7 +898,8 @@ static void sdma_free_chan_resources(struct dma_chan *chan)
 
        dma_free_coherent(NULL, PAGE_SIZE, sdmac->bd, sdmac->bd_phys);
 
-       clk_disable(sdma->clk);
+       clk_disable(sdma->clk_ipg);
+       clk_disable(sdma->clk_ahb);
 }
 
 static struct dma_async_tx_descriptor *sdma_prep_slave_sg(
@@ -1169,12 +1172,14 @@ static void sdma_load_firmware(const struct firmware *fw, void *context)
        addr = (void *)header + header->script_addrs_start;
        ram_code = (void *)header + header->ram_code_start;
 
-       clk_enable(sdma->clk);
+       clk_enable(sdma->clk_ipg);
+       clk_enable(sdma->clk_ahb);
        /* download the RAM image for SDMA */
        sdma_load_script(sdma, ram_code,
                        header->ram_code_size,
                        addr->ram_code_start_addr);
-       clk_disable(sdma->clk);
+       clk_disable(sdma->clk_ipg);
+       clk_disable(sdma->clk_ahb);
 
        sdma_add_scripts(sdma, addr);
 
@@ -1216,7 +1221,8 @@ static int __init sdma_init(struct sdma_engine *sdma)
                return -ENODEV;
        }
 
-       clk_enable(sdma->clk);
+       clk_enable(sdma->clk_ipg);
+       clk_enable(sdma->clk_ahb);
 
        /* Be sure SDMA has not started yet */
        writel_relaxed(0, sdma->regs + SDMA_H_C0PTR);
@@ -1269,12 +1275,14 @@ static int __init sdma_init(struct sdma_engine *sdma)
        /* Initializes channel's priorities */
        sdma_set_channel_priority(&sdma->channel[0], 7);
 
-       clk_disable(sdma->clk);
+       clk_disable(sdma->clk_ipg);
+       clk_disable(sdma->clk_ahb);
 
        return 0;
 
 err_dma_alloc:
-       clk_disable(sdma->clk);
+       clk_disable(sdma->clk_ipg);
+       clk_disable(sdma->clk_ahb);
        dev_err(sdma->dev, "initialisation failed with %d\n", ret);
        return ret;
 }
@@ -1313,12 +1321,21 @@ static int __init sdma_probe(struct platform_device *pdev)
                goto err_request_region;
        }
 
-       sdma->clk = clk_get(&pdev->dev, NULL);
-       if (IS_ERR(sdma->clk)) {
-               ret = PTR_ERR(sdma->clk);
+       sdma->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+       if (IS_ERR(sdma->clk_ipg)) {
+               ret = PTR_ERR(sdma->clk_ipg);
                goto err_clk;
        }
 
+       sdma->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
+       if (IS_ERR(sdma->clk_ahb)) {
+               ret = PTR_ERR(sdma->clk_ahb);
+               goto err_clk;
+       }
+
+       clk_prepare(sdma->clk_ipg);
+       clk_prepare(sdma->clk_ahb);
+
        sdma->regs = ioremap(iores->start, resource_size(iores));
        if (!sdma->regs) {
                ret = -ENOMEM;
@@ -1426,7 +1443,6 @@ err_alloc:
 err_request_irq:
        iounmap(sdma->regs);
 err_ioremap:
-       clk_put(sdma->clk);
 err_clk:
        release_mem_region(iores->start, resource_size(iores));
 err_request_region:
index 62e3f8ec2461f5584fabe343426f7654d678922f..5ec72044ea4c13a5849eef9675c10335c4307416 100644 (file)
@@ -1715,7 +1715,7 @@ static int __init ipu_probe(struct platform_device *pdev)
        }
 
        /* Make sure IPU HSP clock is running */
-       clk_enable(ipu_data.ipu_clk);
+       clk_prepare_enable(ipu_data.ipu_clk);
 
        /* Disable all interrupts */
        idmac_write_ipureg(&ipu_data, 0, IPU_INT_CTRL_1);
@@ -1747,7 +1747,7 @@ static int __init ipu_probe(struct platform_device *pdev)
 err_idmac_init:
 err_attach_irq:
        ipu_irq_detach_irq(&ipu_data, pdev);
-       clk_disable(ipu_data.ipu_clk);
+       clk_disable_unprepare(ipu_data.ipu_clk);
        clk_put(ipu_data.ipu_clk);
 err_clk_get:
        iounmap(ipu_data.reg_ic);
@@ -1765,7 +1765,7 @@ static int __exit ipu_remove(struct platform_device *pdev)
 
        ipu_idmac_exit(ipu);
        ipu_irq_detach_irq(ipu, pdev);
-       clk_disable(ipu->ipu_clk);
+       clk_disable_unprepare(ipu->ipu_clk);
        clk_put(ipu->ipu_clk);
        iounmap(ipu->reg_ic);
        iounmap(ipu->reg_ipu);
index c81ef7e10e08283ce8eaf4fadf6166b5d3ddc19c..655d4ce6ed0d94fcae71ed687641f707e08a8ed8 100644 (file)
@@ -201,10 +201,6 @@ static struct mxs_dma_chan *to_mxs_dma_chan(struct dma_chan *chan)
 
 static dma_cookie_t mxs_dma_tx_submit(struct dma_async_tx_descriptor *tx)
 {
-       struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(tx->chan);
-
-       mxs_dma_enable_chan(mxs_chan);
-
        return dma_cookie_assign(tx);
 }
 
@@ -558,9 +554,9 @@ static enum dma_status mxs_dma_tx_status(struct dma_chan *chan,
 
 static void mxs_dma_issue_pending(struct dma_chan *chan)
 {
-       /*
-        * Nothing to do. We only have a single descriptor.
-        */
+       struct mxs_dma_chan *mxs_chan = to_mxs_dma_chan(chan);
+
+       mxs_dma_enable_chan(mxs_chan);
 }
 
 static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma)
index 282caf118be819c5e9257754a369efd292607951..2ee6e23930ad3258e89bef7513e2c3158b7fe06f 100644 (file)
@@ -2225,12 +2225,9 @@ static inline void free_desc_list(struct list_head *list)
 {
        struct dma_pl330_dmac *pdmac;
        struct dma_pl330_desc *desc;
-       struct dma_pl330_chan *pch;
+       struct dma_pl330_chan *pch = NULL;
        unsigned long flags;
 
-       if (list_empty(list))
-               return;
-
        /* Finish off the work list */
        list_for_each_entry(desc, list, node) {
                dma_async_tx_callback callback;
@@ -2247,6 +2244,10 @@ static inline void free_desc_list(struct list_head *list)
                desc->pchan = NULL;
        }
 
+       /* pch will be unset if list was empty */
+       if (!pch)
+               return;
+
        pdmac = pch->dmac;
 
        spin_lock_irqsave(&pdmac->pool_lock, flags);
@@ -2257,12 +2258,9 @@ static inline void free_desc_list(struct list_head *list)
 static inline void handle_cyclic_desc_list(struct list_head *list)
 {
        struct dma_pl330_desc *desc;
-       struct dma_pl330_chan *pch;
+       struct dma_pl330_chan *pch = NULL;
        unsigned long flags;
 
-       if (list_empty(list))
-               return;
-
        list_for_each_entry(desc, list, node) {
                dma_async_tx_callback callback;
 
@@ -2274,6 +2272,10 @@ static inline void handle_cyclic_desc_list(struct list_head *list)
                        callback(desc->txd.callback_param);
        }
 
+       /* pch will be unset if list was empty */
+       if (!pch)
+               return;
+
        spin_lock_irqsave(&pch->lock, flags);
        list_splice_tail_init(list, &pch->work_list);
        spin_unlock_irqrestore(&pch->lock, flags);
@@ -2926,8 +2928,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
        INIT_LIST_HEAD(&pd->channels);
 
        /* Initialize channel parameters */
-       num_chan = max(pdat ? pdat->nr_valid_peri : (u8)pi->pcfg.num_peri,
-                       (u8)pi->pcfg.num_chan);
+       if (pdat)
+               num_chan = max_t(int, pdat->nr_valid_peri, pi->pcfg.num_chan);
+       else
+               num_chan = max_t(int, pi->pcfg.num_peri, pi->pcfg.num_chan);
+
        pdmac->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);
 
        for (i = 0; i < num_chan; i++) {
index bdd41d4bfa8d8f8bd129e4efffbf0b7187755fa1..2ed1ac3513f3d4de118d7937f40fadc202748a93 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/err.h>
 #include <linux/amba/bus.h>
+#include <linux/regulator/consumer.h>
 
 #include <plat/ste_dma40.h>
 
@@ -68,6 +69,22 @@ enum d40_command {
        D40_DMA_SUSPENDED       = 3
 };
 
+/*
+ * enum d40_events - The different Event Enables for the event lines.
+ *
+ * @D40_DEACTIVATE_EVENTLINE: De-activate Event line, stopping the logical chan.
+ * @D40_ACTIVATE_EVENTLINE: Activate the Event line, to start a logical chan.
+ * @D40_SUSPEND_REQ_EVENTLINE: Requesting for suspending a event line.
+ * @D40_ROUND_EVENTLINE: Status check for event line.
+ */
+
+enum d40_events {
+       D40_DEACTIVATE_EVENTLINE        = 0,
+       D40_ACTIVATE_EVENTLINE          = 1,
+       D40_SUSPEND_REQ_EVENTLINE       = 2,
+       D40_ROUND_EVENTLINE             = 3
+};
+
 /*
  * These are the registers that has to be saved and later restored
  * when the DMA hw is powered off.
@@ -870,8 +887,8 @@ static void d40_save_restore_registers(struct d40_base *base, bool save)
 }
 #endif
 
-static int d40_channel_execute_command(struct d40_chan *d40c,
-                                      enum d40_command command)
+static int __d40_execute_command_phy(struct d40_chan *d40c,
+                                    enum d40_command command)
 {
        u32 status;
        int i;
@@ -880,6 +897,12 @@ static int d40_channel_execute_command(struct d40_chan *d40c,
        unsigned long flags;
        u32 wmask;
 
+       if (command == D40_DMA_STOP) {
+               ret = __d40_execute_command_phy(d40c, D40_DMA_SUSPEND_REQ);
+               if (ret)
+                       return ret;
+       }
+
        spin_lock_irqsave(&d40c->base->execmd_lock, flags);
 
        if (d40c->phy_chan->num % 2 == 0)
@@ -973,67 +996,109 @@ static void d40_term_all(struct d40_chan *d40c)
                }
 
        d40c->pending_tx = 0;
-       d40c->busy = false;
 }
 
-static void __d40_config_set_event(struct d40_chan *d40c, bool enable,
-                                  u32 event, int reg)
+static void __d40_config_set_event(struct d40_chan *d40c,
+                                  enum d40_events event_type, u32 event,
+                                  int reg)
 {
        void __iomem *addr = chan_base(d40c) + reg;
        int tries;
+       u32 status;
+
+       switch (event_type) {
+
+       case D40_DEACTIVATE_EVENTLINE:
 
-       if (!enable) {
                writel((D40_DEACTIVATE_EVENTLINE << D40_EVENTLINE_POS(event))
                       | ~D40_EVENTLINE_MASK(event), addr);
-               return;
-       }
+               break;
+
+       case D40_SUSPEND_REQ_EVENTLINE:
+               status = (readl(addr) & D40_EVENTLINE_MASK(event)) >>
+                         D40_EVENTLINE_POS(event);
+
+               if (status == D40_DEACTIVATE_EVENTLINE ||
+                   status == D40_SUSPEND_REQ_EVENTLINE)
+                       break;
 
+               writel((D40_SUSPEND_REQ_EVENTLINE << D40_EVENTLINE_POS(event))
+                      | ~D40_EVENTLINE_MASK(event), addr);
+
+               for (tries = 0 ; tries < D40_SUSPEND_MAX_IT; tries++) {
+
+                       status = (readl(addr) & D40_EVENTLINE_MASK(event)) >>
+                                 D40_EVENTLINE_POS(event);
+
+                       cpu_relax();
+                       /*
+                        * Reduce the number of bus accesses while
+                        * waiting for the DMA to suspend.
+                        */
+                       udelay(3);
+
+                       if (status == D40_DEACTIVATE_EVENTLINE)
+                               break;
+               }
+
+               if (tries == D40_SUSPEND_MAX_IT) {
+                       chan_err(d40c,
+                               "unable to stop the event_line chl %d (log: %d)"
+                               "status %x\n", d40c->phy_chan->num,
+                                d40c->log_num, status);
+               }
+               break;
+
+       case D40_ACTIVATE_EVENTLINE:
        /*
         * The hardware sometimes doesn't register the enable when src and dst
         * event lines are active on the same logical channel.  Retry to ensure
         * it does.  Usually only one retry is sufficient.
         */
-       tries = 100;
-       while (--tries) {
-               writel((D40_ACTIVATE_EVENTLINE << D40_EVENTLINE_POS(event))
-                      | ~D40_EVENTLINE_MASK(event), addr);
+               tries = 100;
+               while (--tries) {
+                       writel((D40_ACTIVATE_EVENTLINE <<
+                               D40_EVENTLINE_POS(event)) |
+                               ~D40_EVENTLINE_MASK(event), addr);
 
-               if (readl(addr) & D40_EVENTLINE_MASK(event))
-                       break;
-       }
+                       if (readl(addr) & D40_EVENTLINE_MASK(event))
+                               break;
+               }
 
-       if (tries != 99)
-               dev_dbg(chan2dev(d40c),
-                       "[%s] workaround enable S%cLNK (%d tries)\n",
-                       __func__, reg == D40_CHAN_REG_SSLNK ? 'S' : 'D',
-                       100 - tries);
+               if (tries != 99)
+                       dev_dbg(chan2dev(d40c),
+                               "[%s] workaround enable S%cLNK (%d tries)\n",
+                               __func__, reg == D40_CHAN_REG_SSLNK ? 'S' : 'D',
+                               100 - tries);
 
-       WARN_ON(!tries);
-}
+               WARN_ON(!tries);
+               break;
 
-static void d40_config_set_event(struct d40_chan *d40c, bool do_enable)
-{
-       unsigned long flags;
+       case D40_ROUND_EVENTLINE:
+               BUG();
+               break;
 
-       spin_lock_irqsave(&d40c->phy_chan->lock, flags);
+       }
+}
 
+static void d40_config_set_event(struct d40_chan *d40c,
+                                enum d40_events event_type)
+{
        /* Enable event line connected to device (or memcpy) */
        if ((d40c->dma_cfg.dir ==  STEDMA40_PERIPH_TO_MEM) ||
            (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_PERIPH)) {
                u32 event = D40_TYPE_TO_EVENT(d40c->dma_cfg.src_dev_type);
 
-               __d40_config_set_event(d40c, do_enable, event,
+               __d40_config_set_event(d40c, event_type, event,
                                       D40_CHAN_REG_SSLNK);
        }
 
        if (d40c->dma_cfg.dir !=  STEDMA40_PERIPH_TO_MEM) {
                u32 event = D40_TYPE_TO_EVENT(d40c->dma_cfg.dst_dev_type);
 
-               __d40_config_set_event(d40c, do_enable, event,
+               __d40_config_set_event(d40c, event_type, event,
                                       D40_CHAN_REG_SDLNK);
        }
-
-       spin_unlock_irqrestore(&d40c->phy_chan->lock, flags);
 }
 
 static u32 d40_chan_has_events(struct d40_chan *d40c)
@@ -1047,6 +1112,64 @@ static u32 d40_chan_has_events(struct d40_chan *d40c)
        return val;
 }
 
+static int
+__d40_execute_command_log(struct d40_chan *d40c, enum d40_command command)
+{
+       unsigned long flags;
+       int ret = 0;
+       u32 active_status;
+       void __iomem *active_reg;
+
+       if (d40c->phy_chan->num % 2 == 0)
+               active_reg = d40c->base->virtbase + D40_DREG_ACTIVE;
+       else
+               active_reg = d40c->base->virtbase + D40_DREG_ACTIVO;
+
+
+       spin_lock_irqsave(&d40c->phy_chan->lock, flags);
+
+       switch (command) {
+       case D40_DMA_STOP:
+       case D40_DMA_SUSPEND_REQ:
+
+               active_status = (readl(active_reg) &
+                                D40_CHAN_POS_MASK(d40c->phy_chan->num)) >>
+                                D40_CHAN_POS(d40c->phy_chan->num);
+
+               if (active_status == D40_DMA_RUN)
+                       d40_config_set_event(d40c, D40_SUSPEND_REQ_EVENTLINE);
+               else
+                       d40_config_set_event(d40c, D40_DEACTIVATE_EVENTLINE);
+
+               if (!d40_chan_has_events(d40c) && (command == D40_DMA_STOP))
+                       ret = __d40_execute_command_phy(d40c, command);
+
+               break;
+
+       case D40_DMA_RUN:
+
+               d40_config_set_event(d40c, D40_ACTIVATE_EVENTLINE);
+               ret = __d40_execute_command_phy(d40c, command);
+               break;
+
+       case D40_DMA_SUSPENDED:
+               BUG();
+               break;
+       }
+
+       spin_unlock_irqrestore(&d40c->phy_chan->lock, flags);
+       return ret;
+}
+
+static int d40_channel_execute_command(struct d40_chan *d40c,
+                                      enum d40_command command)
+{
+       if (chan_is_logical(d40c))
+               return __d40_execute_command_log(d40c, command);
+       else
+               return __d40_execute_command_phy(d40c, command);
+}
+
 static u32 d40_get_prmo(struct d40_chan *d40c)
 {
        static const unsigned int phy_map[] = {
@@ -1149,15 +1272,7 @@ static int d40_pause(struct d40_chan *d40c)
        spin_lock_irqsave(&d40c->lock, flags);
 
        res = d40_channel_execute_command(d40c, D40_DMA_SUSPEND_REQ);
-       if (res == 0) {
-               if (chan_is_logical(d40c)) {
-                       d40_config_set_event(d40c, false);
-                       /* Resume the other logical channels if any */
-                       if (d40_chan_has_events(d40c))
-                               res = d40_channel_execute_command(d40c,
-                                                                 D40_DMA_RUN);
-               }
-       }
+
        pm_runtime_mark_last_busy(d40c->base->dev);
        pm_runtime_put_autosuspend(d40c->base->dev);
        spin_unlock_irqrestore(&d40c->lock, flags);
@@ -1174,45 +1289,17 @@ static int d40_resume(struct d40_chan *d40c)
 
        spin_lock_irqsave(&d40c->lock, flags);
        pm_runtime_get_sync(d40c->base->dev);
-       if (d40c->base->rev == 0)
-               if (chan_is_logical(d40c)) {
-                       res = d40_channel_execute_command(d40c,
-                                                         D40_DMA_SUSPEND_REQ);
-                       goto no_suspend;
-               }
 
        /* If bytes left to transfer or linked tx resume job */
-       if (d40_residue(d40c) || d40_tx_is_linked(d40c)) {
-
-               if (chan_is_logical(d40c))
-                       d40_config_set_event(d40c, true);
-
+       if (d40_residue(d40c) || d40_tx_is_linked(d40c))
                res = d40_channel_execute_command(d40c, D40_DMA_RUN);
-       }
 
-no_suspend:
        pm_runtime_mark_last_busy(d40c->base->dev);
        pm_runtime_put_autosuspend(d40c->base->dev);
        spin_unlock_irqrestore(&d40c->lock, flags);
        return res;
 }
 
-static int d40_terminate_all(struct d40_chan *chan)
-{
-       unsigned long flags;
-       int ret = 0;
-
-       ret = d40_pause(chan);
-       if (!ret && chan_is_physical(chan))
-               ret = d40_channel_execute_command(chan, D40_DMA_STOP);
-
-       spin_lock_irqsave(&chan->lock, flags);
-       d40_term_all(chan);
-       spin_unlock_irqrestore(&chan->lock, flags);
-
-       return ret;
-}
-
 static dma_cookie_t d40_tx_submit(struct dma_async_tx_descriptor *tx)
 {
        struct d40_chan *d40c = container_of(tx->chan,
@@ -1232,20 +1319,6 @@ static dma_cookie_t d40_tx_submit(struct dma_async_tx_descriptor *tx)
 
 static int d40_start(struct d40_chan *d40c)
 {
-       if (d40c->base->rev == 0) {
-               int err;
-
-               if (chan_is_logical(d40c)) {
-                       err = d40_channel_execute_command(d40c,
-                                                         D40_DMA_SUSPEND_REQ);
-                       if (err)
-                               return err;
-               }
-       }
-
-       if (chan_is_logical(d40c))
-               d40_config_set_event(d40c, true);
-
        return d40_channel_execute_command(d40c, D40_DMA_RUN);
 }
 
@@ -1258,10 +1331,10 @@ static struct d40_desc *d40_queue_start(struct d40_chan *d40c)
        d40d = d40_first_queued(d40c);
 
        if (d40d != NULL) {
-               if (!d40c->busy)
+               if (!d40c->busy) {
                        d40c->busy = true;
-
-               pm_runtime_get_sync(d40c->base->dev);
+                       pm_runtime_get_sync(d40c->base->dev);
+               }
 
                /* Remove from queue */
                d40_desc_remove(d40d);
@@ -1388,8 +1461,8 @@ static void dma_tasklet(unsigned long data)
 
        return;
 
- err:
-       /* Rescue manoeuvre if receiving double interrupts */
+err:
+       /* Rescue manouver if receiving double interrupts */
        if (d40c->pending_tx > 0)
                d40c->pending_tx--;
        spin_unlock_irqrestore(&d40c->lock, flags);
@@ -1770,7 +1843,6 @@ static int d40_config_memcpy(struct d40_chan *d40c)
        return 0;
 }
 
-
 static int d40_free_dma(struct d40_chan *d40c)
 {
 
@@ -1806,43 +1878,18 @@ static int d40_free_dma(struct d40_chan *d40c)
        }
 
        pm_runtime_get_sync(d40c->base->dev);
-       res = d40_channel_execute_command(d40c, D40_DMA_SUSPEND_REQ);
+       res = d40_channel_execute_command(d40c, D40_DMA_STOP);
        if (res) {
-               chan_err(d40c, "suspend failed\n");
+               chan_err(d40c, "stop failed\n");
                goto out;
        }
 
-       if (chan_is_logical(d40c)) {
-               /* Release logical channel, deactivate the event line */
+       d40_alloc_mask_free(phy, is_src, chan_is_logical(d40c) ? event : 0);
 
-               d40_config_set_event(d40c, false);
+       if (chan_is_logical(d40c))
                d40c->base->lookup_log_chans[d40c->log_num] = NULL;
-
-               /*
-                * Check if there are more logical allocation
-                * on this phy channel.
-                */
-               if (!d40_alloc_mask_free(phy, is_src, event)) {
-                       /* Resume the other logical channels if any */
-                       if (d40_chan_has_events(d40c)) {
-                               res = d40_channel_execute_command(d40c,
-                                                                 D40_DMA_RUN);
-                               if (res)
-                                       chan_err(d40c,
-                                               "Executing RUN command\n");
-                       }
-                       goto out;
-               }
-       } else {
-               (void) d40_alloc_mask_free(phy, is_src, 0);
-       }
-
-       /* Release physical channel */
-       res = d40_channel_execute_command(d40c, D40_DMA_STOP);
-       if (res) {
-               chan_err(d40c, "Failed to stop channel\n");
-               goto out;
-       }
+       else
+               d40c->base->lookup_phy_chans[phy->num] = NULL;
 
        if (d40c->busy) {
                pm_runtime_mark_last_busy(d40c->base->dev);
@@ -1852,7 +1899,6 @@ static int d40_free_dma(struct d40_chan *d40c)
        d40c->busy = false;
        d40c->phy_chan = NULL;
        d40c->configured = false;
-       d40c->base->lookup_phy_chans[phy->num] = NULL;
 out:
 
        pm_runtime_mark_last_busy(d40c->base->dev);
@@ -2070,7 +2116,7 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,
        if (sg_next(&sg_src[sg_len - 1]) == sg_src)
                desc->cyclic = true;
 
-       if (direction != DMA_NONE) {
+       if (direction != DMA_TRANS_NONE) {
                dma_addr_t dev_addr = d40_get_dev_addr(chan, direction);
 
                if (direction == DMA_DEV_TO_MEM)
@@ -2371,6 +2417,31 @@ static void d40_issue_pending(struct dma_chan *chan)
        spin_unlock_irqrestore(&d40c->lock, flags);
 }
 
+static void d40_terminate_all(struct dma_chan *chan)
+{
+       unsigned long flags;
+       struct d40_chan *d40c = container_of(chan, struct d40_chan, chan);
+       int ret;
+
+       spin_lock_irqsave(&d40c->lock, flags);
+
+       pm_runtime_get_sync(d40c->base->dev);
+       ret = d40_channel_execute_command(d40c, D40_DMA_STOP);
+       if (ret)
+               chan_err(d40c, "Failed to stop channel\n");
+
+       d40_term_all(d40c);
+       pm_runtime_mark_last_busy(d40c->base->dev);
+       pm_runtime_put_autosuspend(d40c->base->dev);
+       if (d40c->busy) {
+               pm_runtime_mark_last_busy(d40c->base->dev);
+               pm_runtime_put_autosuspend(d40c->base->dev);
+       }
+       d40c->busy = false;
+
+       spin_unlock_irqrestore(&d40c->lock, flags);
+}
+
 static int
 dma40_config_to_halfchannel(struct d40_chan *d40c,
                            struct stedma40_half_channel_info *info,
@@ -2551,7 +2622,8 @@ static int d40_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
 
        switch (cmd) {
        case DMA_TERMINATE_ALL:
-               return d40_terminate_all(d40c);
+               d40_terminate_all(chan);
+               return 0;
        case DMA_PAUSE:
                return d40_pause(d40c);
        case DMA_RESUME:
@@ -2908,6 +2980,12 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
        dev_info(&pdev->dev, "hardware revision: %d @ 0x%x\n",
                 rev, res->start);
 
+       if (rev < 2) {
+               d40_err(&pdev->dev, "hardware revision: %d is not supported",
+                       rev);
+               goto failure;
+       }
+
        plat_data = pdev->dev.platform_data;
 
        /* Count the number of logical channels in use */
@@ -2998,6 +3076,7 @@ failure:
 
        if (base) {
                kfree(base->lcla_pool.alloc_map);
+               kfree(base->reg_val_backup_chan);
                kfree(base->lookup_log_chans);
                kfree(base->lookup_phy_chans);
                kfree(base->phy_res);
index 8d3d490968a3a8240b6f91e1631609a2425c3f4f..51e8e5396e9bd960dbc9f51925567a7b8f768275 100644 (file)
@@ -62,8 +62,6 @@
 #define D40_SREG_ELEM_LOG_LIDX_MASK    (0xFF << D40_SREG_ELEM_LOG_LIDX_POS)
 
 /* Link register */
-#define D40_DEACTIVATE_EVENTLINE       0x0
-#define D40_ACTIVATE_EVENTLINE         0x1
 #define D40_EVENTLINE_POS(i)           (2 * i)
 #define D40_EVENTLINE_MASK(i)          (0x3 << D40_EVENTLINE_POS(i))
 
index d25599f2a3f8bbb882ada61957239f030a06fa18..47408e802ab6effa670f8b3ba0637a3a75a14b36 100644 (file)
@@ -191,6 +191,190 @@ utf16_strncmp(const efi_char16_t *a, const efi_char16_t *b, size_t len)
        }
 }
 
+static bool
+validate_device_path(struct efi_variable *var, int match, u8 *buffer,
+                    unsigned long len)
+{
+       struct efi_generic_dev_path *node;
+       int offset = 0;
+
+       node = (struct efi_generic_dev_path *)buffer;
+
+       if (len < sizeof(*node))
+               return false;
+
+       while (offset <= len - sizeof(*node) &&
+              node->length >= sizeof(*node) &&
+               node->length <= len - offset) {
+               offset += node->length;
+
+               if ((node->type == EFI_DEV_END_PATH ||
+                    node->type == EFI_DEV_END_PATH2) &&
+                   node->sub_type == EFI_DEV_END_ENTIRE)
+                       return true;
+
+               node = (struct efi_generic_dev_path *)(buffer + offset);
+       }
+
+       /*
+        * If we're here then either node->length pointed past the end
+        * of the buffer or we reached the end of the buffer without
+        * finding a device path end node.
+        */
+       return false;
+}
+
+static bool
+validate_boot_order(struct efi_variable *var, int match, u8 *buffer,
+                   unsigned long len)
+{
+       /* An array of 16-bit integers */
+       if ((len % 2) != 0)
+               return false;
+
+       return true;
+}
+
+static bool
+validate_load_option(struct efi_variable *var, int match, u8 *buffer,
+                    unsigned long len)
+{
+       u16 filepathlength;
+       int i, desclength = 0, namelen;
+
+       namelen = utf16_strnlen(var->VariableName, sizeof(var->VariableName));
+
+       /* Either "Boot" or "Driver" followed by four digits of hex */
+       for (i = match; i < match+4; i++) {
+               if (var->VariableName[i] > 127 ||
+                   hex_to_bin(var->VariableName[i] & 0xff) < 0)
+                       return true;
+       }
+
+       /* Reject it if there's 4 digits of hex and then further content */
+       if (namelen > match + 4)
+               return false;
+
+       /* A valid entry must be at least 8 bytes */
+       if (len < 8)
+               return false;
+
+       filepathlength = buffer[4] | buffer[5] << 8;
+
+       /*
+        * There's no stored length for the description, so it has to be
+        * found by hand
+        */
+       desclength = utf16_strsize((efi_char16_t *)(buffer + 6), len - 6) + 2;
+
+       /* Each boot entry must have a descriptor */
+       if (!desclength)
+               return false;
+
+       /*
+        * If the sum of the length of the description, the claimed filepath
+        * length and the original header are greater than the length of the
+        * variable, it's malformed
+        */
+       if ((desclength + filepathlength + 6) > len)
+               return false;
+
+       /*
+        * And, finally, check the filepath
+        */
+       return validate_device_path(var, match, buffer + desclength + 6,
+                                   filepathlength);
+}
+
+static bool
+validate_uint16(struct efi_variable *var, int match, u8 *buffer,
+               unsigned long len)
+{
+       /* A single 16-bit integer */
+       if (len != 2)
+               return false;
+
+       return true;
+}
+
+static bool
+validate_ascii_string(struct efi_variable *var, int match, u8 *buffer,
+                     unsigned long len)
+{
+       int i;
+
+       for (i = 0; i < len; i++) {
+               if (buffer[i] > 127)
+                       return false;
+
+               if (buffer[i] == 0)
+                       return true;
+       }
+
+       return false;
+}
+
+struct variable_validate {
+       char *name;
+       bool (*validate)(struct efi_variable *var, int match, u8 *data,
+                        unsigned long len);
+};
+
+static const struct variable_validate variable_validate[] = {
+       { "BootNext", validate_uint16 },
+       { "BootOrder", validate_boot_order },
+       { "DriverOrder", validate_boot_order },
+       { "Boot*", validate_load_option },
+       { "Driver*", validate_load_option },
+       { "ConIn", validate_device_path },
+       { "ConInDev", validate_device_path },
+       { "ConOut", validate_device_path },
+       { "ConOutDev", validate_device_path },
+       { "ErrOut", validate_device_path },
+       { "ErrOutDev", validate_device_path },
+       { "Timeout", validate_uint16 },
+       { "Lang", validate_ascii_string },
+       { "PlatformLang", validate_ascii_string },
+       { "", NULL },
+};
+
+static bool
+validate_var(struct efi_variable *var, u8 *data, unsigned long len)
+{
+       int i;
+       u16 *unicode_name = var->VariableName;
+
+       for (i = 0; variable_validate[i].validate != NULL; i++) {
+               const char *name = variable_validate[i].name;
+               int match;
+
+               for (match = 0; ; match++) {
+                       char c = name[match];
+                       u16 u = unicode_name[match];
+
+                       /* All special variables are plain ascii */
+                       if (u > 127)
+                               return true;
+
+                       /* Wildcard in the matching name means we've matched */
+                       if (c == '*')
+                               return variable_validate[i].validate(var,
+                                                            match, data, len);
+
+                       /* Case sensitive match */
+                       if (c != u)
+                               break;
+
+                       /* Reached the end of the string while matching */
+                       if (!c)
+                               return variable_validate[i].validate(var,
+                                                            match, data, len);
+               }
+       }
+
+       return true;
+}
+
 static efi_status_t
 get_var_data_locked(struct efivars *efivars, struct efi_variable *var)
 {
@@ -324,6 +508,12 @@ efivar_store_raw(struct efivar_entry *entry, const char *buf, size_t count)
                return -EINVAL;
        }
 
+       if ((new_var->Attributes & ~EFI_VARIABLE_MASK) != 0 ||
+           validate_var(new_var, new_var->Data, new_var->DataSize) == false) {
+               printk(KERN_ERR "efivars: Malformed variable content\n");
+               return -EINVAL;
+       }
+
        spin_lock(&efivars->lock);
        status = efivars->ops->set_variable(new_var->VariableName,
                                            &new_var->VendorGuid,
@@ -626,6 +816,12 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj,
        if (!capable(CAP_SYS_ADMIN))
                return -EACCES;
 
+       if ((new_var->Attributes & ~EFI_VARIABLE_MASK) != 0 ||
+           validate_var(new_var, new_var->Data, new_var->DataSize) == false) {
+               printk(KERN_ERR "efivars: Malformed variable content\n");
+               return -EINVAL;
+       }
+
        spin_lock(&efivars->lock);
 
        /*
index 5689ce62fd81badc2fdeceeb604fdf866d5b3bda..fc3ace3fd4cbc64030764abe51a3788afc7f2e0e 100644 (file)
@@ -64,6 +64,7 @@ struct pxa_gpio_chip {
        unsigned long   irq_mask;
        unsigned long   irq_edge_rise;
        unsigned long   irq_edge_fall;
+       int (*set_wake)(unsigned int gpio, unsigned int on);
 
 #ifdef CONFIG_PM
        unsigned long   saved_gplr;
@@ -269,7 +270,8 @@ static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
                                (value ? GPSR_OFFSET : GPCR_OFFSET));
 }
 
-static int __devinit pxa_init_gpio_chip(int gpio_end)
+static int __devinit pxa_init_gpio_chip(int gpio_end,
+                                       int (*set_wake)(unsigned int, unsigned int))
 {
        int i, gpio, nbanks = gpio_to_bank(gpio_end) + 1;
        struct pxa_gpio_chip *chips;
@@ -285,6 +287,7 @@ static int __devinit pxa_init_gpio_chip(int gpio_end)
 
                sprintf(chips[i].label, "gpio-%d", i);
                chips[i].regbase = gpio_reg_base + BANK_OFF(i);
+               chips[i].set_wake = set_wake;
 
                c->base  = gpio;
                c->label = chips[i].label;
@@ -412,6 +415,17 @@ static void pxa_mask_muxed_gpio(struct irq_data *d)
        writel_relaxed(gfer, c->regbase + GFER_OFFSET);
 }
 
+static int pxa_gpio_set_wake(struct irq_data *d, unsigned int on)
+{
+       int gpio = pxa_irq_to_gpio(d->irq);
+       struct pxa_gpio_chip *c = gpio_to_pxachip(gpio);
+
+       if (c->set_wake)
+               return c->set_wake(gpio, on);
+       else
+               return 0;
+}
+
 static void pxa_unmask_muxed_gpio(struct irq_data *d)
 {
        int gpio = pxa_irq_to_gpio(d->irq);
@@ -427,6 +441,7 @@ static struct irq_chip pxa_muxed_gpio_chip = {
        .irq_mask       = pxa_mask_muxed_gpio,
        .irq_unmask     = pxa_unmask_muxed_gpio,
        .irq_set_type   = pxa_gpio_irq_type,
+       .irq_set_wake   = pxa_gpio_set_wake,
 };
 
 static int pxa_gpio_nums(void)
@@ -471,6 +486,7 @@ static int __devinit pxa_gpio_probe(struct platform_device *pdev)
        struct pxa_gpio_chip *c;
        struct resource *res;
        struct clk *clk;
+       struct pxa_gpio_platform_data *info;
        int gpio, irq, ret;
        int irq0 = 0, irq1 = 0, irq_mux, gpio_offset = 0;
 
@@ -516,7 +532,8 @@ static int __devinit pxa_gpio_probe(struct platform_device *pdev)
        }
 
        /* Initialize GPIO chips */
-       pxa_init_gpio_chip(pxa_last_gpio);
+       info = dev_get_platdata(&pdev->dev);
+       pxa_init_gpio_chip(pxa_last_gpio, info ? info->gpio_set_wake : NULL);
 
        /* clear all GPIO edge detects */
        for_each_gpio_chip(gpio, c) {
index 392ce71ed6a18103db1562ee9024f70f51e6d46e..1dffa8359f88fd6749d99c2882364797ac0e1eee 100644 (file)
@@ -149,22 +149,12 @@ static int exynos_drm_gem_map_pages(struct drm_gem_object *obj,
        unsigned long pfn;
 
        if (exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG) {
-               unsigned long usize = buf->size;
-
                if (!buf->pages)
                        return -EINTR;
 
-               while (usize > 0) {
-                       pfn = page_to_pfn(buf->pages[page_offset++]);
-                       vm_insert_mixed(vma, f_vaddr, pfn);
-                       f_vaddr += PAGE_SIZE;
-                       usize -= PAGE_SIZE;
-               }
-
-               return 0;
-       }
-
-       pfn = (buf->dma_addr >> PAGE_SHIFT) + page_offset;
+               pfn = page_to_pfn(buf->pages[page_offset++]);
+       } else
+               pfn = (buf->dma_addr >> PAGE_SHIFT) + page_offset;
 
        return vm_insert_mixed(vma, f_vaddr, pfn);
 }
@@ -524,6 +514,8 @@ static int exynos_drm_gem_mmap_buffer(struct file *filp,
                if (!buffer->pages)
                        return -EINVAL;
 
+               vma->vm_flags |= VM_MIXEDMAP;
+
                do {
                        ret = vm_insert_page(vma, uaddr, buffer->pages[i++]);
                        if (ret) {
@@ -710,7 +702,6 @@ int exynos_drm_gem_dumb_destroy(struct drm_file *file_priv,
 int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
        struct drm_gem_object *obj = vma->vm_private_data;
-       struct exynos_drm_gem_obj *exynos_gem_obj = to_exynos_gem_obj(obj);
        struct drm_device *dev = obj->dev;
        unsigned long f_vaddr;
        pgoff_t page_offset;
@@ -722,21 +713,10 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 
        mutex_lock(&dev->struct_mutex);
 
-       /*
-        * allocate all pages as desired size if user wants to allocate
-        * physically non-continuous memory.
-        */
-       if (exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG) {
-               ret = exynos_drm_gem_get_pages(obj);
-               if (ret < 0)
-                       goto err;
-       }
-
        ret = exynos_drm_gem_map_pages(obj, vma, f_vaddr, page_offset);
        if (ret < 0)
                DRM_ERROR("failed to map pages.\n");
 
-err:
        mutex_unlock(&dev->struct_mutex);
 
        return convert_to_vm_err_msg(ret);
index b505b70dba05b98a514e35aeba96044ca03e2843..e6162a1681f0931911bcf7a412c174666b23d50a 100644 (file)
@@ -1224,6 +1224,9 @@ static int i915_emon_status(struct seq_file *m, void *unused)
        unsigned long temp, chipset, gfx;
        int ret;
 
+       if (!IS_GEN5(dev))
+               return -ENODEV;
+
        ret = mutex_lock_interruptible(&dev->struct_mutex);
        if (ret)
                return ret;
index 785f67f963efd5b53e0a0358e956888b103da5bd..ba60f3c8f911c187dc636e809af16bd64f51cc8d 100644 (file)
@@ -1701,6 +1701,9 @@ void i915_update_gfx_val(struct drm_i915_private *dev_priv)
        unsigned long diffms;
        u32 count;
 
+       if (dev_priv->info->gen != 5)
+               return;
+
        getrawmonotonic(&now);
        diff1 = timespec_sub(now, dev_priv->last_time2);
 
@@ -2121,12 +2124,14 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
        setup_timer(&dev_priv->hangcheck_timer, i915_hangcheck_elapsed,
                    (unsigned long) dev);
 
-       spin_lock(&mchdev_lock);
-       i915_mch_dev = dev_priv;
-       dev_priv->mchdev_lock = &mchdev_lock;
-       spin_unlock(&mchdev_lock);
+       if (IS_GEN5(dev)) {
+               spin_lock(&mchdev_lock);
+               i915_mch_dev = dev_priv;
+               dev_priv->mchdev_lock = &mchdev_lock;
+               spin_unlock(&mchdev_lock);
 
-       ips_ping_for_i915_load();
+               ips_ping_for_i915_load();
+       }
 
        return 0;
 
index f51a696486cb19f06822f84a10f4a6911c1bd7d8..de431942ded4bb5a7b6f5a380e6009cd6b22b696 100644 (file)
@@ -1133,6 +1133,11 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
                        return -EINVAL;
                }
 
+               if (args->num_cliprects > UINT_MAX / sizeof(*cliprects)) {
+                       DRM_DEBUG("execbuf with %u cliprects\n",
+                                 args->num_cliprects);
+                       return -EINVAL;
+               }
                cliprects = kmalloc(args->num_cliprects * sizeof(*cliprects),
                                    GFP_KERNEL);
                if (cliprects == NULL) {
@@ -1404,7 +1409,8 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
        struct drm_i915_gem_exec_object2 *exec2_list = NULL;
        int ret;
 
-       if (args->buffer_count < 1) {
+       if (args->buffer_count < 1 ||
+           args->buffer_count > UINT_MAX / sizeof(*exec2_list)) {
                DRM_DEBUG("execbuf2 with %d buffers\n", args->buffer_count);
                return -EINVAL;
        }
index b4bb1ef77ddc967d060d0de226ffb1cf80f26468..9d24d65f0c3e54491badaa0e983d2e1ba5edfce1 100644 (file)
 #define   CM0_MASK_SHIFT          16
 #define   CM0_IZ_OPT_DISABLE      (1<<6)
 #define   CM0_ZR_OPT_DISABLE      (1<<5)
+#define          CM0_STC_EVICT_DISABLE_LRA_SNB (1<<5)
 #define   CM0_DEPTH_EVICT_DISABLE (1<<4)
 #define   CM0_COLOR_EVICT_DISABLE (1<<3)
 #define   CM0_DEPTH_WRITE_DISABLE (1<<1)
index 4d3d736a4f56a9c65b315162dac4dc1b2b372c28..90b9793fd5da3bbe0e209c3778187199a0dca665 100644 (file)
@@ -430,8 +430,8 @@ intel_crt_detect(struct drm_connector *connector, bool force)
 {
        struct drm_device *dev = connector->dev;
        struct intel_crt *crt = intel_attached_crt(connector);
-       struct drm_crtc *crtc;
        enum drm_connector_status status;
+       struct intel_load_detect_pipe tmp;
 
        if (I915_HAS_HOTPLUG(dev)) {
                if (intel_crt_detect_hotplug(connector)) {
@@ -450,23 +450,16 @@ intel_crt_detect(struct drm_connector *connector, bool force)
                return connector->status;
 
        /* for pre-945g platforms use load detect */
-       crtc = crt->base.base.crtc;
-       if (crtc && crtc->enabled) {
-               status = intel_crt_load_detect(crt);
-       } else {
-               struct intel_load_detect_pipe tmp;
-
-               if (intel_get_load_detect_pipe(&crt->base, connector, NULL,
-                                              &tmp)) {
-                       if (intel_crt_detect_ddc(connector))
-                               status = connector_status_connected;
-                       else
-                               status = intel_crt_load_detect(crt);
-                       intel_release_load_detect_pipe(&crt->base, connector,
-                                                      &tmp);
-               } else
-                       status = connector_status_unknown;
-       }
+       if (intel_get_load_detect_pipe(&crt->base, connector, NULL,
+                                      &tmp)) {
+               if (intel_crt_detect_ddc(connector))
+                       status = connector_status_connected;
+               else
+                       status = intel_crt_load_detect(crt);
+               intel_release_load_detect_pipe(&crt->base, connector,
+                                              &tmp);
+       } else
+               status = connector_status_unknown;
 
        return status;
 }
index 5908cd563400f486f7ae5a302f6a12f4c62da8af..1b1cf3b3ff515c8612cf69c42837824ab57bc7d9 100644 (file)
@@ -7072,9 +7072,6 @@ static void intel_decrease_pllclock(struct drm_crtc *crtc)
        struct drm_device *dev = crtc->dev;
        drm_i915_private_t *dev_priv = dev->dev_private;
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-       int pipe = intel_crtc->pipe;
-       int dpll_reg = DPLL(pipe);
-       int dpll = I915_READ(dpll_reg);
 
        if (HAS_PCH_SPLIT(dev))
                return;
@@ -7087,10 +7084,15 @@ static void intel_decrease_pllclock(struct drm_crtc *crtc)
         * the manual case.
         */
        if (!HAS_PIPE_CXSR(dev) && intel_crtc->lowfreq_avail) {
+               int pipe = intel_crtc->pipe;
+               int dpll_reg = DPLL(pipe);
+               u32 dpll;
+
                DRM_DEBUG_DRIVER("downclocking LVDS\n");
 
                assert_panel_unlocked(dev_priv, pipe);
 
+               dpll = I915_READ(dpll_reg);
                dpll |= DISPLAY_RATE_SELECT_FPA1;
                I915_WRITE(dpll_reg, dpll);
                intel_wait_for_vblank(dev, pipe);
@@ -7098,7 +7100,6 @@ static void intel_decrease_pllclock(struct drm_crtc *crtc)
                if (!(dpll & DISPLAY_RATE_SELECT_FPA1))
                        DRM_DEBUG_DRIVER("failed to downclock LVDS!\n");
        }
-
 }
 
 /**
index cae3e5f17a49d8b767a371710935dcf89146121a..2d7f47b56b6ae7a7b1922a328ab971fe9d63077a 100644 (file)
@@ -136,7 +136,7 @@ static void i9xx_write_infoframe(struct drm_encoder *encoder,
 
        val &= ~VIDEO_DIP_SELECT_MASK;
 
-       I915_WRITE(VIDEO_DIP_CTL, val | port | flags);
+       I915_WRITE(VIDEO_DIP_CTL, VIDEO_DIP_ENABLE | val | port | flags);
 
        for (i = 0; i < len; i += 4) {
                I915_WRITE(VIDEO_DIP_DATA, *data);
index 30e2c82101de0d8cb0c841d97f77db6acfc501aa..9c71183629c2a08fa1e9bddae13cd12dde26429f 100644 (file)
@@ -750,7 +750,7 @@ static const struct dmi_system_id intel_no_lvds[] = {
                .ident = "Hewlett-Packard t5745",
                .matches = {
                        DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
-                       DMI_MATCH(DMI_BOARD_NAME, "hp t5745"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "hp t5745"),
                },
        },
        {
@@ -758,7 +758,7 @@ static const struct dmi_system_id intel_no_lvds[] = {
                .ident = "Hewlett-Packard st5747",
                .matches = {
                        DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
-                       DMI_MATCH(DMI_BOARD_NAME, "hp st5747"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "hp st5747"),
                },
        },
        {
index f75806e5bff5c62273ddaee7d5f94bd15cb860e8..80fce51e2f439d9bf4825fffadf05051fb6531b9 100644 (file)
@@ -401,6 +401,14 @@ static int init_render_ring(struct intel_ring_buffer *ring)
        if (INTEL_INFO(dev)->gen >= 6) {
                I915_WRITE(INSTPM,
                           INSTPM_FORCE_ORDERING << 16 | INSTPM_FORCE_ORDERING);
+
+               /* From the Sandybridge PRM, volume 1 part 3, page 24:
+                * "If this bit is set, STCunit will have LRA as replacement
+                *  policy. [...] This bit must be reset.  LRA replacement
+                *  policy is not supported."
+                */
+               I915_WRITE(CACHE_MODE_0,
+                          CM0_STC_EVICT_DISABLE_LRA_SNB << CM0_MASK_SHIFT);
        }
 
        return ret;
index e36b171c1e7d5ff2b7a95b0dc6dd5db741f6e2fc..232d77d07d8b241b7ea1ec45ee8333463ac63c3a 100644 (file)
@@ -731,6 +731,7 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,
        uint16_t width, height;
        uint16_t h_blank_len, h_sync_len, v_blank_len, v_sync_len;
        uint16_t h_sync_offset, v_sync_offset;
+       int mode_clock;
 
        width = mode->crtc_hdisplay;
        height = mode->crtc_vdisplay;
@@ -745,7 +746,11 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,
        h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start;
        v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start;
 
-       dtd->part1.clock = mode->clock / 10;
+       mode_clock = mode->clock;
+       mode_clock /= intel_mode_get_pixel_multiplier(mode) ?: 1;
+       mode_clock /= 10;
+       dtd->part1.clock = mode_clock;
+
        dtd->part1.h_active = width & 0xff;
        dtd->part1.h_blank = h_blank_len & 0xff;
        dtd->part1.h_high = (((width >> 8) & 0xf) << 4) |
@@ -996,7 +1001,7 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
        struct intel_sdvo *intel_sdvo = to_intel_sdvo(encoder);
        u32 sdvox;
        struct intel_sdvo_in_out_map in_out;
-       struct intel_sdvo_dtd input_dtd;
+       struct intel_sdvo_dtd input_dtd, output_dtd;
        int pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode);
        int rate;
 
@@ -1021,20 +1026,13 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
                                          intel_sdvo->attached_output))
                return;
 
-       /* We have tried to get input timing in mode_fixup, and filled into
-        * adjusted_mode.
-        */
-       if (intel_sdvo->is_tv || intel_sdvo->is_lvds) {
-               input_dtd = intel_sdvo->input_dtd;
-       } else {
-               /* Set the output timing to the screen */
-               if (!intel_sdvo_set_target_output(intel_sdvo,
-                                                 intel_sdvo->attached_output))
-                       return;
-
-               intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode);
-               (void) intel_sdvo_set_output_timing(intel_sdvo, &input_dtd);
-       }
+       /* lvds has a special fixed output timing. */
+       if (intel_sdvo->is_lvds)
+               intel_sdvo_get_dtd_from_mode(&output_dtd,
+                                            intel_sdvo->sdvo_lvds_fixed_mode);
+       else
+               intel_sdvo_get_dtd_from_mode(&output_dtd, mode);
+       (void) intel_sdvo_set_output_timing(intel_sdvo, &output_dtd);
 
        /* Set the input timing to the screen. Assume always input 0. */
        if (!intel_sdvo_set_target_input(intel_sdvo))
@@ -1052,6 +1050,10 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
            !intel_sdvo_set_tv_format(intel_sdvo))
                return;
 
+       /* We have tried to get input timing in mode_fixup, and filled into
+        * adjusted_mode.
+        */
+       intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode);
        (void) intel_sdvo_set_input_timing(intel_sdvo, &input_dtd);
 
        switch (pixel_multiplier) {
index 7814a760c16439e8d6a0c74da474b4a978ce9793..284bd25d5d2127a3d44f9d8efae7449b77edcfbd 100644 (file)
@@ -270,7 +270,7 @@ static bool nouveau_dsm_detect(void)
        struct acpi_buffer buffer = {sizeof(acpi_method_name), acpi_method_name};
        struct pci_dev *pdev = NULL;
        int has_dsm = 0;
-       int has_optimus;
+       int has_optimus = 0;
        int vga_count = 0;
        bool guid_valid;
        int retval;
index 80963d05b54aad27ebe0e1f3325fc9c923221daf..0be4a815e706cadd4e2bd4b0734f640c807f86ec 100644 (file)
@@ -6156,10 +6156,14 @@ dcb_fake_connectors(struct nvbios *bios)
 
        /* heuristic: if we ever get a non-zero connector field, assume
         * that all the indices are valid and we don't need fake them.
+        *
+        * and, as usual, a blacklist of boards with bad bios data..
         */
-       for (i = 0; i < dcbt->entries; i++) {
-               if (dcbt->entry[i].connector)
-                       return;
+       if (!nv_match_device(bios->dev, 0x0392, 0x107d, 0x20a2)) {
+               for (i = 0; i < dcbt->entries; i++) {
+                       if (dcbt->entry[i].connector)
+                               return;
+               }
        }
 
        /* no useful connector info available, we need to make it up
index 59ea1c14eca0363b7f132abc4c86242e68b82e0f..c3de36384522f9668a99e6aa26fb2da39dc01dd8 100644 (file)
@@ -32,7 +32,9 @@ static bool
 hdmi_sor(struct drm_encoder *encoder)
 {
        struct drm_nouveau_private *dev_priv = encoder->dev->dev_private;
-       if (dev_priv->chipset < 0xa3)
+       if (dev_priv->chipset <  0xa3 ||
+           dev_priv->chipset == 0xaa ||
+           dev_priv->chipset == 0xac)
                return false;
        return true;
 }
index 550ad3fcf0afa691153f293f7e36f64e181105f7..9d79180069df2cdb93b6e8b7ea45cb0508fed38c 100644 (file)
@@ -65,7 +65,7 @@ nv10_gpio_drive(struct drm_device *dev, int line, int dir, int out)
        if (line < 10) {
                line = (line - 2) * 4;
                reg  = NV_PCRTC_GPIO_EXT;
-               mask = 0x00000003 << ((line - 2) * 4);
+               mask = 0x00000003;
                data = (dir << 1) | out;
        } else
        if (line < 14) {
index 5bf55038fd9238a4ec582f0d72b505dc3b804bd2..f704e942372e75b291cc505536a197c4c464a537 100644 (file)
@@ -54,6 +54,11 @@ nvc0_mfb_isr(struct drm_device *dev)
                        nvc0_mfb_subp_isr(dev, unit, subp);
                units &= ~(1 << unit);
        }
+
+       /* we do something horribly wrong and upset PMFB a lot, so mask off
+        * interrupts from it after the first one until it's fixed
+        */
+       nv_mask(dev, 0x000640, 0x02000000, 0x00000000);
 }
 
 static void
index b5ff1f7b6f7ee4f3917d6d83e137ec02998a6d78..af1054f8202a27ac1059b00d0799ee00ebfb1da9 100644 (file)
@@ -575,6 +575,9 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
 
                if (rdev->family < CHIP_RV770)
                        pll->flags |= RADEON_PLL_PREFER_MINM_OVER_MAXP;
+               /* use frac fb div on APUs */
+               if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE61(rdev))
+                       pll->flags |= RADEON_PLL_USE_FRAC_FB_DIV;
        } else {
                pll->flags |= RADEON_PLL_LEGACY;
 
@@ -955,8 +958,8 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode
                break;
        }
 
-       if (radeon_encoder->active_device &
-           (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) {
+       if ((radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) ||
+           (radeon_encoder_get_dp_bridge_encoder_id(encoder) != ENCODER_OBJECT_ID_NONE)) {
                struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
                struct drm_connector *connector =
                        radeon_get_connector_for_encoder(encoder);
index ea7df16e2f84f267f0a129fac762333b96d54b56..5992502a3448dc692e426891751822f26aec3350 100644 (file)
@@ -241,8 +241,8 @@ int radeon_wb_init(struct radeon_device *rdev)
                                rdev->wb.use_event = true;
                }
        }
-       /* always use writeback/events on NI */
-       if (ASIC_IS_DCE5(rdev)) {
+       /* always use writeback/events on NI, APUs */
+       if (rdev->family >= CHIP_PALM) {
                rdev->wb.enabled = true;
                rdev->wb.use_event = true;
        }
index 8086c96e0b06a4b80cf77a03b43736cefdf713e2..0a1d4bd65edcebc31cbb425120e3c5090f7e2382 100644 (file)
@@ -533,7 +533,7 @@ static void radeon_crtc_init(struct drm_device *dev, int index)
                radeon_legacy_init_crtc(dev, radeon_crtc);
 }
 
-static const char *encoder_names[36] = {
+static const char *encoder_names[37] = {
        "NONE",
        "INTERNAL_LVDS",
        "INTERNAL_TMDS1",
@@ -570,6 +570,7 @@ static const char *encoder_names[36] = {
        "INTERNAL_UNIPHY2",
        "NUTMEG",
        "TRAVIS",
+       "INTERNAL_VCE"
 };
 
 static const char *connector_names[15] = {
index 88a050df2389067b37222c7d59a172671a8e1b88..3ad91f6447d8eee319e570f4098a2fb75f9be49e 100644 (file)
@@ -123,7 +123,7 @@ struct hsc_client_data {
 static unsigned int hsc_major;
 /* Maximum buffer size that hsi_char will accept from userspace */
 static unsigned int max_data_size = 0x1000;
-module_param(max_data_size, uint, S_IRUSR | S_IWUSR);
+module_param(max_data_size, uint, 0);
 MODULE_PARM_DESC(max_data_size, "max read/write data size [4,8..65536] (^2)");
 
 static void hsc_add_tail(struct hsc_channel *channel, struct hsi_msg *msg,
index 4e2d79b793349c1d6c3b375677b2af7a87db2ccb..2d58f939d27f0ddbcf404909249c5f2d8f14a3a8 100644 (file)
  */
 #include <linux/hsi/hsi.h>
 #include <linux/compiler.h>
-#include <linux/rwsem.h>
 #include <linux/list.h>
-#include <linux/spinlock.h>
 #include <linux/kobject.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <linux/notifier.h>
 #include "hsi_core.h"
 
-static struct device_type hsi_ctrl = {
-       .name   = "hsi_controller",
-};
-
-static struct device_type hsi_cl = {
-       .name   = "hsi_client",
-};
-
-static struct device_type hsi_port = {
-       .name   = "hsi_port",
-};
-
 static ssize_t modalias_show(struct device *dev,
                        struct device_attribute *a __maybe_unused, char *buf)
 {
@@ -54,8 +41,7 @@ static struct device_attribute hsi_bus_dev_attrs[] = {
 
 static int hsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
-       if (dev->type == &hsi_cl)
-               add_uevent_var(env, "MODALIAS=hsi:%s", dev_name(dev));
+       add_uevent_var(env, "MODALIAS=hsi:%s", dev_name(dev));
 
        return 0;
 }
@@ -80,12 +66,10 @@ static void hsi_client_release(struct device *dev)
 static void hsi_new_client(struct hsi_port *port, struct hsi_board_info *info)
 {
        struct hsi_client *cl;
-       unsigned long flags;
 
        cl = kzalloc(sizeof(*cl), GFP_KERNEL);
        if (!cl)
                return;
-       cl->device.type = &hsi_cl;
        cl->tx_cfg = info->tx_cfg;
        cl->rx_cfg = info->rx_cfg;
        cl->device.bus = &hsi_bus_type;
@@ -93,14 +77,11 @@ static void hsi_new_client(struct hsi_port *port, struct hsi_board_info *info)
        cl->device.release = hsi_client_release;
        dev_set_name(&cl->device, info->name);
        cl->device.platform_data = info->platform_data;
-       spin_lock_irqsave(&port->clock, flags);
-       list_add_tail(&cl->link, &port->clients);
-       spin_unlock_irqrestore(&port->clock, flags);
        if (info->archdata)
                cl->device.archdata = *info->archdata;
        if (device_register(&cl->device) < 0) {
                pr_err("hsi: failed to register client: %s\n", info->name);
-               kfree(cl);
+               put_device(&cl->device);
        }
 }
 
@@ -120,13 +101,6 @@ static void hsi_scan_board_info(struct hsi_controller *hsi)
 
 static int hsi_remove_client(struct device *dev, void *data __maybe_unused)
 {
-       struct hsi_client *cl = to_hsi_client(dev);
-       struct hsi_port *port = to_hsi_port(dev->parent);
-       unsigned long flags;
-
-       spin_lock_irqsave(&port->clock, flags);
-       list_del(&cl->link);
-       spin_unlock_irqrestore(&port->clock, flags);
        device_unregister(dev);
 
        return 0;
@@ -140,12 +114,17 @@ static int hsi_remove_port(struct device *dev, void *data __maybe_unused)
        return 0;
 }
 
-static void hsi_controller_release(struct device *dev __maybe_unused)
+static void hsi_controller_release(struct device *dev)
 {
+       struct hsi_controller *hsi = to_hsi_controller(dev);
+
+       kfree(hsi->port);
+       kfree(hsi);
 }
 
-static void hsi_port_release(struct device *dev __maybe_unused)
+static void hsi_port_release(struct device *dev)
 {
+       kfree(to_hsi_port(dev));
 }
 
 /**
@@ -170,20 +149,12 @@ int hsi_register_controller(struct hsi_controller *hsi)
        unsigned int i;
        int err;
 
-       hsi->device.type = &hsi_ctrl;
-       hsi->device.bus = &hsi_bus_type;
-       hsi->device.release = hsi_controller_release;
-       err = device_register(&hsi->device);
+       err = device_add(&hsi->device);
        if (err < 0)
                return err;
        for (i = 0; i < hsi->num_ports; i++) {
-               hsi->port[i].device.parent = &hsi->device;
-               hsi->port[i].device.bus = &hsi_bus_type;
-               hsi->port[i].device.release = hsi_port_release;
-               hsi->port[i].device.type = &hsi_port;
-               INIT_LIST_HEAD(&hsi->port[i].clients);
-               spin_lock_init(&hsi->port[i].clock);
-               err = device_register(&hsi->port[i].device);
+               hsi->port[i]->device.parent = &hsi->device;
+               err = device_add(&hsi->port[i]->device);
                if (err < 0)
                        goto out;
        }
@@ -192,7 +163,9 @@ int hsi_register_controller(struct hsi_controller *hsi)
 
        return 0;
 out:
-       hsi_unregister_controller(hsi);
+       while (i-- > 0)
+               device_del(&hsi->port[i]->device);
+       device_del(&hsi->device);
 
        return err;
 }
@@ -222,6 +195,29 @@ static inline int hsi_dummy_cl(struct hsi_client *cl __maybe_unused)
        return 0;
 }
 
+/**
+ * hsi_put_controller - Free an HSI controller
+ *
+ * @hsi: Pointer to the HSI controller to freed
+ *
+ * HSI controller drivers should only use this function if they need
+ * to free their allocated hsi_controller structures before a successful
+ * call to hsi_register_controller. Other use is not allowed.
+ */
+void hsi_put_controller(struct hsi_controller *hsi)
+{
+       unsigned int i;
+
+       if (!hsi)
+               return;
+
+       for (i = 0; i < hsi->num_ports; i++)
+               if (hsi->port && hsi->port[i])
+                       put_device(&hsi->port[i]->device);
+       put_device(&hsi->device);
+}
+EXPORT_SYMBOL_GPL(hsi_put_controller);
+
 /**
  * hsi_alloc_controller - Allocate an HSI controller and its ports
  * @n_ports: Number of ports on the HSI controller
@@ -232,54 +228,51 @@ static inline int hsi_dummy_cl(struct hsi_client *cl __maybe_unused)
 struct hsi_controller *hsi_alloc_controller(unsigned int n_ports, gfp_t flags)
 {
        struct hsi_controller   *hsi;
-       struct hsi_port         *port;
+       struct hsi_port         **port;
        unsigned int            i;
 
        if (!n_ports)
                return NULL;
 
-       port = kzalloc(sizeof(*port)*n_ports, flags);
-       if (!port)
-               return NULL;
        hsi = kzalloc(sizeof(*hsi), flags);
        if (!hsi)
-               goto out;
-       for (i = 0; i < n_ports; i++) {
-               dev_set_name(&port[i].device, "port%d", i);
-               port[i].num = i;
-               port[i].async = hsi_dummy_msg;
-               port[i].setup = hsi_dummy_cl;
-               port[i].flush = hsi_dummy_cl;
-               port[i].start_tx = hsi_dummy_cl;
-               port[i].stop_tx = hsi_dummy_cl;
-               port[i].release = hsi_dummy_cl;
-               mutex_init(&port[i].lock);
+               return NULL;
+       port = kzalloc(sizeof(*port)*n_ports, flags);
+       if (!port) {
+               kfree(hsi);
+               return NULL;
        }
        hsi->num_ports = n_ports;
        hsi->port = port;
+       hsi->device.release = hsi_controller_release;
+       device_initialize(&hsi->device);
+
+       for (i = 0; i < n_ports; i++) {
+               port[i] = kzalloc(sizeof(**port), flags);
+               if (port[i] == NULL)
+                       goto out;
+               port[i]->num = i;
+               port[i]->async = hsi_dummy_msg;
+               port[i]->setup = hsi_dummy_cl;
+               port[i]->flush = hsi_dummy_cl;
+               port[i]->start_tx = hsi_dummy_cl;
+               port[i]->stop_tx = hsi_dummy_cl;
+               port[i]->release = hsi_dummy_cl;
+               mutex_init(&port[i]->lock);
+               ATOMIC_INIT_NOTIFIER_HEAD(&port[i]->n_head);
+               dev_set_name(&port[i]->device, "port%d", i);
+               hsi->port[i]->device.release = hsi_port_release;
+               device_initialize(&hsi->port[i]->device);
+       }
 
        return hsi;
 out:
-       kfree(port);
+       hsi_put_controller(hsi);
 
        return NULL;
 }
 EXPORT_SYMBOL_GPL(hsi_alloc_controller);
 
-/**
- * hsi_free_controller - Free an HSI controller
- * @hsi: Pointer to HSI controller
- */
-void hsi_free_controller(struct hsi_controller *hsi)
-{
-       if (!hsi)
-               return;
-
-       kfree(hsi->port);
-       kfree(hsi);
-}
-EXPORT_SYMBOL_GPL(hsi_free_controller);
-
 /**
  * hsi_free_msg - Free an HSI message
  * @msg: Pointer to the HSI message
@@ -414,37 +407,67 @@ void hsi_release_port(struct hsi_client *cl)
 }
 EXPORT_SYMBOL_GPL(hsi_release_port);
 
-static int hsi_start_rx(struct hsi_client *cl, void *data __maybe_unused)
+static int hsi_event_notifier_call(struct notifier_block *nb,
+                               unsigned long event, void *data __maybe_unused)
 {
-       if (cl->hsi_start_rx)
-               (*cl->hsi_start_rx)(cl);
+       struct hsi_client *cl = container_of(nb, struct hsi_client, nb);
+
+       (*cl->ehandler)(cl, event);
 
        return 0;
 }
 
-static int hsi_stop_rx(struct hsi_client *cl, void *data __maybe_unused)
+/**
+ * hsi_register_port_event - Register a client to receive port events
+ * @cl: HSI client that wants to receive port events
+ * @cb: Event handler callback
+ *
+ * Clients should register a callback to be able to receive
+ * events from the ports. Registration should happen after
+ * claiming the port.
+ * The handler can be called in interrupt context.
+ *
+ * Returns -errno on error, or 0 on success.
+ */
+int hsi_register_port_event(struct hsi_client *cl,
+                       void (*handler)(struct hsi_client *, unsigned long))
 {
-       if (cl->hsi_stop_rx)
-               (*cl->hsi_stop_rx)(cl);
+       struct hsi_port *port = hsi_get_port(cl);
 
-       return 0;
+       if (!handler || cl->ehandler)
+               return -EINVAL;
+       if (!hsi_port_claimed(cl))
+               return -EACCES;
+       cl->ehandler = handler;
+       cl->nb.notifier_call = hsi_event_notifier_call;
+
+       return atomic_notifier_chain_register(&port->n_head, &cl->nb);
 }
+EXPORT_SYMBOL_GPL(hsi_register_port_event);
 
-static int hsi_port_for_each_client(struct hsi_port *port, void *data,
-                               int (*fn)(struct hsi_client *cl, void *data))
+/**
+ * hsi_unregister_port_event - Stop receiving port events for a client
+ * @cl: HSI client that wants to stop receiving port events
+ *
+ * Clients should call this function before releasing their associated
+ * port.
+ *
+ * Returns -errno on error, or 0 on success.
+ */
+int hsi_unregister_port_event(struct hsi_client *cl)
 {
-       struct hsi_client *cl;
+       struct hsi_port *port = hsi_get_port(cl);
+       int err;
 
-       spin_lock(&port->clock);
-       list_for_each_entry(cl, &port->clients, link) {
-               spin_unlock(&port->clock);
-               (*fn)(cl, data);
-               spin_lock(&port->clock);
-       }
-       spin_unlock(&port->clock);
+       WARN_ON(!hsi_port_claimed(cl));
 
-       return 0;
+       err = atomic_notifier_chain_unregister(&port->n_head, &cl->nb);
+       if (!err)
+               cl->ehandler = NULL;
+
+       return err;
 }
+EXPORT_SYMBOL_GPL(hsi_unregister_port_event);
 
 /**
  * hsi_event -Notifies clients about port events
@@ -458,22 +481,12 @@ static int hsi_port_for_each_client(struct hsi_port *port, void *data,
  * Events:
  * HSI_EVENT_START_RX - Incoming wake line high
  * HSI_EVENT_STOP_RX - Incoming wake line down
+ *
+ * Returns -errno on error, or 0 on success.
  */
-void hsi_event(struct hsi_port *port, unsigned int event)
+int hsi_event(struct hsi_port *port, unsigned long event)
 {
-       int (*fn)(struct hsi_client *cl, void *data);
-
-       switch (event) {
-       case HSI_EVENT_START_RX:
-               fn = hsi_start_rx;
-               break;
-       case HSI_EVENT_STOP_RX:
-               fn = hsi_stop_rx;
-               break;
-       default:
-               return;
-       }
-       hsi_port_for_each_client(port, NULL, fn);
+       return atomic_notifier_call_chain(&port->n_head, event, NULL);
 }
 EXPORT_SYMBOL_GPL(hsi_event);
 
index ce43642ef03e9f9c50a7c5441c095dfbd0793148..f85ce70d96779b5dcd366983f48d4458cc782704 100644 (file)
@@ -47,7 +47,7 @@ struct ad7314_data {
        u16 rx ____cacheline_aligned;
 };
 
-static int ad7314_spi_read(struct ad7314_data *chip, s16 *data)
+static int ad7314_spi_read(struct ad7314_data *chip)
 {
        int ret;
 
@@ -57,9 +57,7 @@ static int ad7314_spi_read(struct ad7314_data *chip, s16 *data)
                return ret;
        }
 
-       *data = be16_to_cpu(chip->rx);
-
-       return ret;
+       return be16_to_cpu(chip->rx);
 }
 
 static ssize_t ad7314_show_temperature(struct device *dev,
@@ -70,12 +68,12 @@ static ssize_t ad7314_show_temperature(struct device *dev,
        s16 data;
        int ret;
 
-       ret = ad7314_spi_read(chip, &data);
+       ret = ad7314_spi_read(chip);
        if (ret < 0)
                return ret;
        switch (spi_get_device_id(chip->spi_dev)->driver_data) {
        case ad7314:
-               data = (data & AD7314_TEMP_MASK) >> AD7314_TEMP_OFFSET;
+               data = (ret & AD7314_TEMP_MASK) >> AD7314_TEMP_OFFSET;
                data = (data << 6) >> 6;
 
                return sprintf(buf, "%d\n", 250 * data);
@@ -86,7 +84,7 @@ static ssize_t ad7314_show_temperature(struct device *dev,
                 * with a sign bit - which is a 14 bit 2's complement
                 * register.  1lsb - 31.25 milli degrees centigrade
                 */
-               data &= ADT7301_TEMP_MASK;
+               data = ret & ADT7301_TEMP_MASK;
                data = (data << 2) >> 2;
 
                return sprintf(buf, "%d\n",
index 0d3141fbbc204bbb533dfce334bc0a741f0b7095..b9d512331ed49561331b638b78f29e5120288b39 100644 (file)
@@ -52,7 +52,7 @@ module_param_named(tjmax, force_tjmax, int, 0444);
 MODULE_PARM_DESC(tjmax, "TjMax value in degrees Celsius");
 
 #define BASE_SYSFS_ATTR_NO     2       /* Sysfs Base attr no for coretemp */
-#define NUM_REAL_CORES         16      /* Number of Real cores per cpu */
+#define NUM_REAL_CORES         32      /* Number of Real cores per cpu */
 #define CORETEMP_NAME_LENGTH   17      /* String Length of attrs */
 #define MAX_CORE_ATTRS         4       /* Maximum no of basic attrs */
 #define TOTAL_ATTRS            (MAX_CORE_ATTRS + 1)
@@ -709,6 +709,10 @@ static void __cpuinit put_core_offline(unsigned int cpu)
 
        indx = TO_ATTR_NO(cpu);
 
+       /* The core id is too big, just return */
+       if (indx > MAX_CORE_DATA - 1)
+               return;
+
        if (pdata->core_data[indx] && pdata->core_data[indx]->cpu == cpu)
                coretemp_remove_core(pdata, &pdev->dev, indx);
 
index 37a8fc92b44acf50a16d086c9983a9794c03b838..e8e18cab1fb8c34d63c259a64afb461833df8be7 100644 (file)
@@ -128,17 +128,20 @@ static bool __devinit fam15h_power_is_internal_node0(struct pci_dev *f4)
  * counter saturations resulting in bogus power readings.
  * We correct this value ourselves to cope with older BIOSes.
  */
+static DEFINE_PCI_DEVICE_TABLE(affected_device) = {
+       { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) },
+       { 0 }
+};
+
 static void __devinit tweak_runavg_range(struct pci_dev *pdev)
 {
        u32 val;
-       const struct pci_device_id affected_device = {
-               PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) };
 
        /*
         * let this quirk apply only to the current version of the
         * northbridge, since future versions may change the behavior
         */
-       if (!pci_match_id(&affected_device, pdev))
+       if (!pci_match_id(affected_device, pdev))
                return;
 
        pci_bus_read_config_dword(pdev->bus,
index f086131cb1c70372384d1af7be50414ce73b4356..c811289b61e21628f28d79b71f27651c39e3e024 100644 (file)
@@ -324,7 +324,7 @@ static s32 pch_i2c_wait_for_xfer_complete(struct i2c_algo_pch_data *adap)
 {
        long ret;
        ret = wait_event_timeout(pch_event,
-                       (adap->pch_event_flag != 0), msecs_to_jiffies(50));
+                       (adap->pch_event_flag != 0), msecs_to_jiffies(1000));
 
        if (ret == 0) {
                pch_err(adap, "timeout: %x\n", adap->pch_event_flag);
@@ -1063,6 +1063,6 @@ module_exit(pch_pci_exit);
 
 MODULE_DESCRIPTION("Intel EG20T PCH/LAPIS Semico ML7213/ML7223/ML7831 IOH I2C");
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Tomoya MORINAGA. <tomoya-linux@dsn.lapis-semi.com>");
+MODULE_AUTHOR("Tomoya MORINAGA. <tomoya.rohm@gmail.com>");
 module_param(pch_i2c_speed, int, (S_IRUSR | S_IWUSR));
 module_param(pch_clk, int, (S_IRUSR | S_IWUSR));
index 3d471d56bf15d1faf295f606c31f19d90f384e79..76b8af44f63492884d1b2b9ebc70ec58da9b9eba 100644 (file)
@@ -227,6 +227,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
                return -EINVAL;
 
        init_completion(&i2c->cmd_complete);
+       i2c->cmd_err = 0;
 
        flags = stop ? MXS_I2C_CTRL0_POST_SEND_STOP : 0;
 
@@ -252,6 +253,9 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
 
        if (i2c->cmd_err == -ENXIO)
                mxs_i2c_reset(i2c);
+       else
+               writel(MXS_I2C_QUEUECTRL_QUEUE_RUN,
+                               i2c->regs + MXS_I2C_QUEUECTRL_CLR);
 
        dev_dbg(i2c->dev, "Done with err=%d\n", i2c->cmd_err);
 
@@ -299,8 +303,6 @@ static irqreturn_t mxs_i2c_isr(int this_irq, void *dev_id)
                    MXS_I2C_CTRL1_SLAVE_STOP_IRQ | MXS_I2C_CTRL1_SLAVE_IRQ))
                /* MXS_I2C_CTRL1_OVERSIZE_XFER_TERM_IRQ is only for slaves */
                i2c->cmd_err = -EIO;
-       else
-               i2c->cmd_err = 0;
 
        is_last_cmd = (readl(i2c->regs + MXS_I2C_QUEUESTAT) &
                MXS_I2C_QUEUESTAT_WRITE_QUEUE_CNT_MASK) == 0;
@@ -384,8 +386,6 @@ static int __devexit mxs_i2c_remove(struct platform_device *pdev)
        if (ret)
                return -EBUSY;
 
-       writel(MXS_I2C_QUEUECTRL_QUEUE_RUN,
-                       i2c->regs + MXS_I2C_QUEUECTRL_CLR);
        writel(MXS_I2C_CTRL0_SFTRST, i2c->regs + MXS_I2C_CTRL0_SET);
 
        platform_set_drvdata(pdev, NULL);
index 04be9f82e14bda8518c4d9562c680731e42c23b3..eb8ad538c79ffb97616e43f135b5d9ff991cce96 100644 (file)
@@ -546,8 +546,7 @@ static int i2c_pnx_controller_suspend(struct platform_device *pdev,
 {
        struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
 
-       /* FIXME: shouldn't this be clk_disable? */
-       clk_enable(alg_data->clk);
+       clk_disable(alg_data->clk);
 
        return 0;
 }
index e978635e60f04189e6478ccb112a0df4a2596ed3..55e5ea62ccee3b69148c13ce337a1ff8531bc467 100644 (file)
@@ -516,6 +516,14 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
        if (likely(i2c_dev->msg_err == I2C_ERR_NONE))
                return 0;
 
+       /*
+        * NACK interrupt is generated before the I2C controller generates the
+        * STOP condition on the bus. So wait for 2 clock periods before resetting
+        * the controller so that STOP condition has been delivered properly.
+        */
+       if (i2c_dev->msg_err == I2C_ERR_NO_ACK)
+               udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate));
+
        tegra_i2c_init(i2c_dev);
        if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
                if (msg->flags & I2C_M_IGNORE_NAK)
index 426bb7617ec6fa4027dd6d535eab1fa6675562fc..b0d0bc8a6fb6ca58c61206ff11dab9f2f5cd5e8e 100644 (file)
@@ -1854,6 +1854,8 @@ static bool generate_unmatched_resp(struct ib_mad_private *recv,
                response->mad.mad.mad_hdr.method = IB_MGMT_METHOD_GET_RESP;
                response->mad.mad.mad_hdr.status =
                        cpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB);
+               if (recv->mad.mad.mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
+                       response->mad.mad.mad_hdr.status |= IB_SMP_DIRECTION;
 
                return true;
        } else {
@@ -1869,6 +1871,7 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
        struct ib_mad_list_head *mad_list;
        struct ib_mad_agent_private *mad_agent;
        int port_num;
+       int ret = IB_MAD_RESULT_SUCCESS;
 
        mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id;
        qp_info = mad_list->mad_queue->qp_info;
@@ -1952,8 +1955,6 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
 local:
        /* Give driver "right of first refusal" on incoming MAD */
        if (port_priv->device->process_mad) {
-               int ret;
-
                ret = port_priv->device->process_mad(port_priv->device, 0,
                                                     port_priv->port_num,
                                                     wc, &recv->grh,
@@ -1981,7 +1982,8 @@ local:
                 * or via recv_handler in ib_mad_complete_recv()
                 */
                recv = NULL;
-       } else if (generate_unmatched_resp(recv, response)) {
+       } else if ((ret & IB_MAD_RESULT_SUCCESS) &&
+                  generate_unmatched_resp(recv, response)) {
                agent_send_response(&response->mad.mad, &recv->grh, wc,
                                    port_priv->device, port_num, qp_info->qp->qp_num);
        }
index 669673e814393b051c144018292037c973f2fc7b..b948b6dd5d553c9059cb9f655f104e3f9af7de34 100644 (file)
@@ -247,7 +247,7 @@ static int ib_link_query_port(struct ib_device *ibdev, u8 port,
                err = mlx4_MAD_IFC(to_mdev(ibdev), 1, 1, port,
                                   NULL, NULL, in_mad, out_mad);
                if (err)
-                       return err;
+                       goto out;
 
                /* Checking LinkSpeedActive for FDR-10 */
                if (out_mad->data[15] & 0x1)
index 8081a0a5d602c0b9f04557b5323882c4bcf89694..a4b14a41cbf43a2d788989d7bfc3e71294ffc94e 100644 (file)
@@ -274,7 +274,8 @@ static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse)
        static unsigned char param = 0xc8;
        struct synaptics_data *priv = psmouse->private;
 
-       if (!SYN_CAP_ADV_GESTURE(priv->ext_cap_0c))
+       if (!(SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) ||
+             SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)))
                return 0;
 
        if (psmouse_sliced_command(psmouse, SYN_QUE_MODEL))
index 97e73e555d112c8762b7934bd9892d39f5c6e4ce..17e2b472e16dccba1a94202f616f260e8f656b6c 100644 (file)
@@ -1727,8 +1727,7 @@ int bitmap_create(struct mddev *mddev)
        bitmap->chunkshift = (ffz(~mddev->bitmap_info.chunksize)
                              - BITMAP_BLOCK_SHIFT);
 
-       /* now that chunksize and chunkshift are set, we can use these macros */
-       chunks = (blocks + bitmap->chunkshift - 1) >>
+       chunks = (blocks + (1 << bitmap->chunkshift) - 1) >>
                        bitmap->chunkshift;
        pages = (chunks + PAGE_COUNTER_RATIO - 1) / PAGE_COUNTER_RATIO;
 
index 55ca5aec84e4cb06280f335a6b260ac2ae23dd5c..b44b0aba2d47b970f9b76f39763192995e5984fb 100644 (file)
@@ -101,9 +101,6 @@ typedef __u16 bitmap_counter_t;
 
 #define BITMAP_BLOCK_SHIFT 9
 
-/* how many blocks per chunk? (this is variable) */
-#define CHUNK_BLOCK_RATIO(bitmap) ((bitmap)->mddev->bitmap_info.chunksize >> BITMAP_BLOCK_SHIFT)
-
 #endif
 
 /*
index b0ba52459ed7381d4a802acb94e69df02f979149..68965e663248e2f0b0158aaf9a75f2583be2704c 100644 (file)
@@ -859,7 +859,7 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
        int ret;
        unsigned redundancy = 0;
        struct raid_dev *dev;
-       struct md_rdev *rdev, *freshest;
+       struct md_rdev *rdev, *tmp, *freshest;
        struct mddev *mddev = &rs->md;
 
        switch (rs->raid_type->level) {
@@ -877,7 +877,7 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
        }
 
        freshest = NULL;
-       rdev_for_each(rdev, mddev) {
+       rdev_for_each_safe(rdev, tmp, mddev) {
                if (!rdev->meta_bdev)
                        continue;
 
index b572e1e386ceab73643f3d0ffc272c1989b91474..477eb2e180c031d84b33d659167d8aea760babfe 100644 (file)
@@ -7560,14 +7560,14 @@ void md_check_recovery(struct mddev *mddev)
                 * any transients in the value of "sync_action".
                 */
                set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
-               clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
                /* Clear some bits that don't mean anything, but
                 * might be left set
                 */
                clear_bit(MD_RECOVERY_INTR, &mddev->recovery);
                clear_bit(MD_RECOVERY_DONE, &mddev->recovery);
 
-               if (test_bit(MD_RECOVERY_FROZEN, &mddev->recovery))
+               if (!test_and_clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery) ||
+                   test_bit(MD_RECOVERY_FROZEN, &mddev->recovery))
                        goto unlock;
                /* no recovery is running.
                 * remove any failed drives, then
@@ -8140,7 +8140,8 @@ static int md_notify_reboot(struct notifier_block *this,
 
        for_each_mddev(mddev, tmp) {
                if (mddev_trylock(mddev)) {
-                       __md_stop_writes(mddev);
+                       if (mddev->pers)
+                               __md_stop_writes(mddev);
                        mddev->safemode = 2;
                        mddev_unlock(mddev);
                }
index 93c35ef5f0adc30dc89831c55cd425e69db7c756..e2e33df868de5ce743a8d9d93a420101074f0070 100644 (file)
@@ -508,7 +508,7 @@ static void mx3_camera_activate(struct mx3_camera_dev *mx3_cam,
        /* ipu_csi_init_interface() */
        csi_reg_write(mx3_cam, conf, CSI_SENS_CONF);
 
-       clk_enable(mx3_cam->clk);
+       clk_prepare_enable(mx3_cam->clk);
        rate = clk_round_rate(mx3_cam->clk, mx3_cam->mclk);
        dev_dbg(icd->parent, "Set SENS_CONF to %x, rate %ld\n", conf, rate);
        if (rate)
@@ -549,7 +549,7 @@ static void mx3_camera_remove_device(struct soc_camera_device *icd)
                *ichan = NULL;
        }
 
-       clk_disable(mx3_cam->clk);
+       clk_disable_unprepare(mx3_cam->clk);
 
        mx3_cam->icd = NULL;
 
index c8aae6640e64cc00bdc4079f3326ac8ef512df34..7e96bb2297244f7946537a5da5f78226e6a4db40 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/clk.h>
 #include <linux/dma-mapping.h>
 #include <linux/spinlock.h>
+#include <plat/cpu.h>
 #include <plat/usb.h>
 #include <linux/pm_runtime.h>
 
index b2058b4323209ba2a1a97aeabd21654655f02c0a..28ed52d58f7f5262d2ab9500095ee7ec478337f5 100644 (file)
@@ -136,7 +136,8 @@ struct mxcmci_host {
        u16                     rev_no;
        unsigned int            cmdat;
 
-       struct clk              *clk;
+       struct clk              *clk_ipg;
+       struct clk              *clk_per;
 
        int                     clock;
 
@@ -672,7 +673,7 @@ static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios)
 {
        unsigned int divider;
        int prescaler = 0;
-       unsigned int clk_in = clk_get_rate(host->clk);
+       unsigned int clk_in = clk_get_rate(host->clk_per);
 
        while (prescaler <= 0x800) {
                for (divider = 1; divider <= 0xF; divider++) {
@@ -900,12 +901,20 @@ static int mxcmci_probe(struct platform_device *pdev)
        host->res = r;
        host->irq = irq;
 
-       host->clk = clk_get(&pdev->dev, NULL);
-       if (IS_ERR(host->clk)) {
-               ret = PTR_ERR(host->clk);
+       host->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+       if (IS_ERR(host->clk_ipg)) {
+               ret = PTR_ERR(host->clk_ipg);
                goto out_iounmap;
        }
-       clk_enable(host->clk);
+
+       host->clk_per = devm_clk_get(&pdev->dev, "per");
+       if (IS_ERR(host->clk_per)) {
+               ret = PTR_ERR(host->clk_per);
+               goto out_iounmap;
+       }
+
+       clk_prepare_enable(host->clk_per);
+       clk_prepare_enable(host->clk_ipg);
 
        mxcmci_softreset(host);
 
@@ -917,8 +926,8 @@ static int mxcmci_probe(struct platform_device *pdev)
                goto out_clk_put;
        }
 
-       mmc->f_min = clk_get_rate(host->clk) >> 16;
-       mmc->f_max = clk_get_rate(host->clk) >> 1;
+       mmc->f_min = clk_get_rate(host->clk_per) >> 16;
+       mmc->f_max = clk_get_rate(host->clk_per) >> 1;
 
        /* recommended in data sheet */
        writew(0x2db4, host->base + MMC_REG_READ_TO);
@@ -967,8 +976,8 @@ out_free_dma:
        if (host->dma)
                dma_release_channel(host->dma);
 out_clk_put:
-       clk_disable(host->clk);
-       clk_put(host->clk);
+       clk_disable_unprepare(host->clk_per);
+       clk_disable_unprepare(host->clk_ipg);
 out_iounmap:
        iounmap(host->base);
 out_free:
@@ -999,8 +1008,8 @@ static int mxcmci_remove(struct platform_device *pdev)
        if (host->dma)
                dma_release_channel(host->dma);
 
-       clk_disable(host->clk);
-       clk_put(host->clk);
+       clk_disable_unprepare(host->clk_per);
+       clk_disable_unprepare(host->clk_ipg);
 
        release_mem_region(host->res->start, resource_size(host->res));
 
@@ -1018,7 +1027,8 @@ static int mxcmci_suspend(struct device *dev)
 
        if (mmc)
                ret = mmc_suspend_host(mmc);
-       clk_disable(host->clk);
+       clk_disable_unprepare(host->clk_per);
+       clk_disable_unprepare(host->clk_ipg);
 
        return ret;
 }
@@ -1029,7 +1039,8 @@ static int mxcmci_resume(struct device *dev)
        struct mxcmci_host *host = mmc_priv(mmc);
        int ret = 0;
 
-       clk_enable(host->clk);
+       clk_prepare_enable(host->clk_per);
+       clk_prepare_enable(host->clk_ipg);
        if (mmc)
                ret = mmc_resume_host(mmc);
 
index b0f2ef9881883df42f5513eb3f1f0479e6c83653..e3f5af96ab87f325942075ecba8705d137776c0c 100644 (file)
@@ -363,6 +363,7 @@ static void mxs_mmc_bc(struct mxs_mmc_host *host)
                goto out;
 
        dmaengine_submit(desc);
+       dma_async_issue_pending(host->dmach);
        return;
 
 out:
@@ -403,6 +404,7 @@ static void mxs_mmc_ac(struct mxs_mmc_host *host)
                goto out;
 
        dmaengine_submit(desc);
+       dma_async_issue_pending(host->dmach);
        return;
 
 out:
@@ -531,6 +533,7 @@ static void mxs_mmc_adtc(struct mxs_mmc_host *host)
                goto out;
 
        dmaengine_submit(desc);
+       dma_async_issue_pending(host->dmach);
        return;
 out:
        dev_warn(mmc_dev(host->mmc),
index 8abdaf6697a8db6e0bf0949e9c54900cb2ac0889..ce83d6191f4a3cc398e4dd83b9f43456fb4a90c2 100644 (file)
@@ -69,6 +69,9 @@ struct pltfm_imx_data {
        u32 scratchpad;
        enum imx_esdhc_type devtype;
        struct esdhc_platform_data boarddata;
+       struct clk *clk_ipg;
+       struct clk *clk_ahb;
+       struct clk *clk_per;
 };
 
 static struct platform_device_id imx_esdhc_devtype[] = {
@@ -437,7 +440,6 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev)
        struct sdhci_pltfm_host *pltfm_host;
        struct sdhci_host *host;
        struct esdhc_platform_data *boarddata;
-       struct clk *clk;
        int err;
        struct pltfm_imx_data *imx_data;
 
@@ -458,14 +460,29 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev)
        imx_data->devtype = pdev->id_entry->driver_data;
        pltfm_host->priv = imx_data;
 
-       clk = clk_get(mmc_dev(host->mmc), NULL);
-       if (IS_ERR(clk)) {
-               dev_err(mmc_dev(host->mmc), "clk err\n");
-               err = PTR_ERR(clk);
+       imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+       if (IS_ERR(imx_data->clk_ipg)) {
+               err = PTR_ERR(imx_data->clk_ipg);
                goto err_clk_get;
        }
-       clk_prepare_enable(clk);
-       pltfm_host->clk = clk;
+
+       imx_data->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
+       if (IS_ERR(imx_data->clk_ahb)) {
+               err = PTR_ERR(imx_data->clk_ahb);
+               goto err_clk_get;
+       }
+
+       imx_data->clk_per = devm_clk_get(&pdev->dev, "per");
+       if (IS_ERR(imx_data->clk_per)) {
+               err = PTR_ERR(imx_data->clk_per);
+               goto err_clk_get;
+       }
+
+       pltfm_host->clk = imx_data->clk_per;
+
+       clk_prepare_enable(imx_data->clk_per);
+       clk_prepare_enable(imx_data->clk_ipg);
+       clk_prepare_enable(imx_data->clk_ahb);
 
        host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
 
@@ -558,8 +575,9 @@ no_card_detect_irq:
                gpio_free(boarddata->wp_gpio);
 no_card_detect_pin:
 no_board_data:
-       clk_disable_unprepare(pltfm_host->clk);
-       clk_put(pltfm_host->clk);
+       clk_disable_unprepare(imx_data->clk_per);
+       clk_disable_unprepare(imx_data->clk_ipg);
+       clk_disable_unprepare(imx_data->clk_ahb);
 err_clk_get:
        kfree(imx_data);
 err_imx_data:
@@ -585,8 +603,10 @@ static int __devexit sdhci_esdhc_imx_remove(struct platform_device *pdev)
                gpio_free(boarddata->cd_gpio);
        }
 
-       clk_disable_unprepare(pltfm_host->clk);
-       clk_put(pltfm_host->clk);
+       clk_disable_unprepare(imx_data->clk_per);
+       clk_disable_unprepare(imx_data->clk_ipg);
+       clk_disable_unprepare(imx_data->clk_ahb);
+
        kfree(imx_data);
 
        sdhci_pltfm_free(pdev);
index 75b1dde1635884986097786bab730e2264c01072..9ec51cec2e14a42de34d10d1eee0c44c17e78dde 100644 (file)
@@ -266,6 +266,7 @@ int start_dma_without_bch_irq(struct gpmi_nand_data *this,
        desc->callback          = dma_irq_callback;
        desc->callback_param    = this;
        dmaengine_submit(desc);
+       dma_async_issue_pending(get_dma_chan(this));
 
        /* Wait for the interrupt from the DMA block. */
        err = wait_for_completion_timeout(dma_c, msecs_to_jiffies(1000));
index cc0678a967c12c6b054d21ee3fe5b868ee997924..9e374e9bd2966bf197b348744c3e11c6b6fa1df4 100644 (file)
@@ -690,7 +690,7 @@ static void mxc_nand_select_chip(struct mtd_info *mtd, int chip)
        if (chip == -1) {
                /* Disable the NFC clock */
                if (host->clk_act) {
-                       clk_disable(host->clk);
+                       clk_disable_unprepare(host->clk);
                        host->clk_act = 0;
                }
                return;
@@ -698,7 +698,7 @@ static void mxc_nand_select_chip(struct mtd_info *mtd, int chip)
 
        if (!host->clk_act) {
                /* Enable the NFC clock */
-               clk_enable(host->clk);
+               clk_prepare_enable(host->clk);
                host->clk_act = 1;
        }
 
@@ -1078,7 +1078,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
                goto eclk;
        }
 
-       clk_enable(host->clk);
+       clk_prepare_enable(host->clk);
        host->clk_act = 1;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
index 25197b698dd64efad9243bc6579f4808d6a93802..b8b4c7ba884f0c2ed9499e1ede4a20ad1df4f732 100644 (file)
@@ -89,16 +89,16 @@ static int __init arcrimi_probe(struct net_device *dev)
        BUGLVL(D_NORMAL) printk(VERSION);
        BUGLVL(D_NORMAL) printk("E-mail me if you actually test the RIM I driver, please!\n");
 
-       BUGMSG(D_NORMAL, "Given: node %02Xh, shmem %lXh, irq %d\n",
+       BUGLVL(D_NORMAL) printk("Given: node %02Xh, shmem %lXh, irq %d\n",
               dev->dev_addr[0], dev->mem_start, dev->irq);
 
        if (dev->mem_start <= 0 || dev->irq <= 0) {
-               BUGMSG(D_NORMAL, "No autoprobe for RIM I; you "
+               BUGLVL(D_NORMAL) printk("No autoprobe for RIM I; you "
                       "must specify the shmem and irq!\n");
                return -ENODEV;
        }
        if (dev->dev_addr[0] == 0) {
-               BUGMSG(D_NORMAL, "You need to specify your card's station "
+               BUGLVL(D_NORMAL) printk("You need to specify your card's station "
                       "ID!\n");
                return -ENODEV;
        }
@@ -109,7 +109,7 @@ static int __init arcrimi_probe(struct net_device *dev)
         * will be taken.
         */
        if (!request_mem_region(dev->mem_start, MIRROR_SIZE, "arcnet (90xx)")) {
-               BUGMSG(D_NORMAL, "Card memory already allocated\n");
+               BUGLVL(D_NORMAL) printk("Card memory already allocated\n");
                return -ENODEV;
        }
        return arcrimi_found(dev);
index 9a66e2a910ae21f586ff59439b8116fe891d4c95..9c1c8cd5223f4144f90d6eb034d7a2bfcf0ff429 100644 (file)
@@ -744,14 +744,14 @@ static void cfhsi_wake_up(struct work_struct *work)
                size_t fifo_occupancy = 0;
 
                /* Wakeup timeout */
-               dev_err(&cfhsi->ndev->dev, "%s: Timeout.\n",
+               dev_dbg(&cfhsi->ndev->dev, "%s: Timeout.\n",
                        __func__);
 
                /* Check FIFO to check if modem has sent something. */
                WARN_ON(cfhsi->dev->cfhsi_fifo_occupancy(cfhsi->dev,
                                        &fifo_occupancy));
 
-               dev_err(&cfhsi->ndev->dev, "%s: Bytes in FIFO: %u.\n",
+               dev_dbg(&cfhsi->ndev->dev, "%s: Bytes in FIFO: %u.\n",
                                __func__, (unsigned) fifo_occupancy);
 
                /* Check if we misssed the interrupt. */
@@ -1210,7 +1210,7 @@ int cfhsi_probe(struct platform_device *pdev)
 
 static void cfhsi_shutdown(struct cfhsi *cfhsi)
 {
-       u8 *tx_buf, *rx_buf;
+       u8 *tx_buf, *rx_buf, *flip_buf;
 
        /* Stop TXing */
        netif_tx_stop_all_queues(cfhsi->ndev);
@@ -1234,7 +1234,7 @@ static void cfhsi_shutdown(struct cfhsi *cfhsi)
        /* Store bufferes: will be freed later. */
        tx_buf = cfhsi->tx_buf;
        rx_buf = cfhsi->rx_buf;
-
+       flip_buf = cfhsi->rx_flip_buf;
        /* Flush transmit queues. */
        cfhsi_abort_tx(cfhsi);
 
@@ -1247,6 +1247,7 @@ static void cfhsi_shutdown(struct cfhsi *cfhsi)
        /* Free buffers. */
        kfree(tx_buf);
        kfree(rx_buf);
+       kfree(flip_buf);
 }
 
 int cfhsi_remove(struct platform_device *pdev)
index 5234586dff15d32a4ac63dc42246a414ada41760..629c4ba5d49d95792717f75b3a8919543a60b5d0 100644 (file)
@@ -875,6 +875,7 @@ static int pcan_usb_pro_init(struct peak_usb_device *dev)
                                            PCAN_USBPRO_INFO_FW,
                                            &fi, sizeof(fi));
                if (err) {
+                       kfree(usb_if);
                        dev_err(dev->netdev->dev.parent,
                                "unable to read %s firmware info (err %d)\n",
                                pcan_usb_pro.name, err);
@@ -885,6 +886,7 @@ static int pcan_usb_pro_init(struct peak_usb_device *dev)
                                            PCAN_USBPRO_INFO_BL,
                                            &bi, sizeof(bi));
                if (err) {
+                       kfree(usb_if);
                        dev_err(dev->netdev->dev.parent,
                                "unable to read %s bootloader info (err %d)\n",
                                pcan_usb_pro.name, err);
index d5c6d92f1ee77b1df16d59faf4c18e6d5889c07c..442d91a2747b9d8136dd5809ec3d192fc8c1e04c 100644 (file)
@@ -107,14 +107,14 @@ static int dummy_dev_init(struct net_device *dev)
        return 0;
 }
 
-static void dummy_dev_free(struct net_device *dev)
+static void dummy_dev_uninit(struct net_device *dev)
 {
        free_percpu(dev->dstats);
-       free_netdev(dev);
 }
 
 static const struct net_device_ops dummy_netdev_ops = {
        .ndo_init               = dummy_dev_init,
+       .ndo_uninit             = dummy_dev_uninit,
        .ndo_start_xmit         = dummy_xmit,
        .ndo_validate_addr      = eth_validate_addr,
        .ndo_set_rx_mode        = set_multicast_list,
@@ -128,7 +128,7 @@ static void dummy_setup(struct net_device *dev)
 
        /* Initialize the device structure. */
        dev->netdev_ops = &dummy_netdev_ops;
-       dev->destructor = dummy_dev_free;
+       dev->destructor = free_netdev;
 
        /* Fill in device structure with ethernet-generic values. */
        dev->tx_queue_len = 0;
index 40ac414365490b59ac1eacab9fbd11123af39f23..c926857e8205fd79226cc7c0f0a897d7cb65ab88 100644 (file)
@@ -2476,7 +2476,7 @@ static irqreturn_t atl1_intr(int irq, void *data)
                                        "pcie phy link down %x\n", status);
                        if (netif_running(adapter->netdev)) {   /* reset MAC */
                                iowrite32(0, adapter->hw.hw_addr + REG_IMR);
-                               schedule_work(&adapter->pcie_dma_to_rst_task);
+                               schedule_work(&adapter->reset_dev_task);
                                return IRQ_HANDLED;
                        }
                }
@@ -2488,7 +2488,7 @@ static irqreturn_t atl1_intr(int irq, void *data)
                                        "pcie DMA r/w error (status = 0x%x)\n",
                                        status);
                        iowrite32(0, adapter->hw.hw_addr + REG_IMR);
-                       schedule_work(&adapter->pcie_dma_to_rst_task);
+                       schedule_work(&adapter->reset_dev_task);
                        return IRQ_HANDLED;
                }
 
@@ -2633,10 +2633,10 @@ static void atl1_down(struct atl1_adapter *adapter)
        atl1_clean_rx_ring(adapter);
 }
 
-static void atl1_tx_timeout_task(struct work_struct *work)
+static void atl1_reset_dev_task(struct work_struct *work)
 {
        struct atl1_adapter *adapter =
-               container_of(work, struct atl1_adapter, tx_timeout_task);
+               container_of(work, struct atl1_adapter, reset_dev_task);
        struct net_device *netdev = adapter->netdev;
 
        netif_device_detach(netdev);
@@ -3038,12 +3038,10 @@ static int __devinit atl1_probe(struct pci_dev *pdev,
                    (unsigned long)adapter);
        adapter->phy_timer_pending = false;
 
-       INIT_WORK(&adapter->tx_timeout_task, atl1_tx_timeout_task);
+       INIT_WORK(&adapter->reset_dev_task, atl1_reset_dev_task);
 
        INIT_WORK(&adapter->link_chg_task, atlx_link_chg_task);
 
-       INIT_WORK(&adapter->pcie_dma_to_rst_task, atl1_tx_timeout_task);
-
        err = register_netdev(netdev);
        if (err)
                goto err_common;
index 109d6da8be97c14927c2e7fa79fc1b1073f84bb6..e04bf4d71e4657618655ac94f89da96c5cef96fa 100644 (file)
@@ -758,9 +758,8 @@ struct atl1_adapter {
        u16 link_speed;
        u16 link_duplex;
        spinlock_t lock;
-       struct work_struct tx_timeout_task;
+       struct work_struct reset_dev_task;
        struct work_struct link_chg_task;
-       struct work_struct pcie_dma_to_rst_task;
 
        struct timer_list phy_config_timer;
        bool phy_timer_pending;
index 3cd8837236dc1de68727991cc399b6906e30d5c3..c9e9dc57986c0743b3f7800273303f536fa47fc6 100644 (file)
@@ -194,7 +194,7 @@ static void atlx_tx_timeout(struct net_device *netdev)
 {
        struct atlx_adapter *adapter = netdev_priv(netdev);
        /* Do the reset outside of interrupt context */
-       schedule_work(&adapter->tx_timeout_task);
+       schedule_work(&adapter->reset_dev_task);
 }
 
 /*
index ad95324dc0420681c21e12ead836eafdceb35a59..64392ec410a3898b3b4372523db4a19d3614b390 100644 (file)
@@ -942,6 +942,12 @@ static int bnx2x_ets_e3b0_sp_pri_to_cos_set(const struct link_params *params,
        const u8 max_num_of_cos = (port) ? DCBX_E3B0_MAX_NUM_COS_PORT1 :
                DCBX_E3B0_MAX_NUM_COS_PORT0;
 
+       if (pri >= max_num_of_cos) {
+               DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid "
+                  "parameter Illegal strict priority\n");
+           return -EINVAL;
+       }
+
        if (sp_pri_to_cos[pri] != DCBX_INVALID_COS) {
                DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid "
                                   "parameter There can't be two COS's with "
@@ -949,12 +955,6 @@ static int bnx2x_ets_e3b0_sp_pri_to_cos_set(const struct link_params *params,
                return -EINVAL;
        }
 
-       if (pri > max_num_of_cos) {
-               DP(NETIF_MSG_LINK, "bnx2x_ets_e3b0_sp_pri_to_cos_set invalid "
-                  "parameter Illegal strict priority\n");
-           return -EINVAL;
-       }
-
        sp_pri_to_cos[pri] = cos_entry;
        return 0;
 
index 062ac333fde60be0732572f39e0a7a46335da499..ceeab8e852ef6a2cf86b682bb17bd0f17ab5ade8 100644 (file)
@@ -879,8 +879,13 @@ static inline unsigned int tg3_has_work(struct tg3_napi *tnapi)
                if (sblk->status & SD_STATUS_LINK_CHG)
                        work_exists = 1;
        }
-       /* check for RX/TX work to do */
-       if (sblk->idx[0].tx_consumer != tnapi->tx_cons ||
+
+       /* check for TX work to do */
+       if (sblk->idx[0].tx_consumer != tnapi->tx_cons)
+               work_exists = 1;
+
+       /* check for RX work to do */
+       if (tnapi->rx_rcb_prod_idx &&
            *(tnapi->rx_rcb_prod_idx) != tnapi->rx_rcb_ptr)
                work_exists = 1;
 
@@ -6124,6 +6129,9 @@ static int tg3_poll_work(struct tg3_napi *tnapi, int work_done, int budget)
                        return work_done;
        }
 
+       if (!tnapi->rx_rcb_prod_idx)
+               return work_done;
+
        /* run RX thread, within the bounds set by NAPI.
         * All RX "locking" is done by ensuring outside
         * code synchronizes with tg3->napi.poll()
@@ -7567,6 +7575,12 @@ static int tg3_alloc_consistent(struct tg3 *tp)
                 */
                switch (i) {
                default:
+                       if (tg3_flag(tp, ENABLE_RSS)) {
+                               tnapi->rx_rcb_prod_idx = NULL;
+                               break;
+                       }
+                       /* Fall through */
+               case 1:
                        tnapi->rx_rcb_prod_idx = &sblk->idx[0].rx_producer;
                        break;
                case 2:
index 63bfdd10bd6d857b33cb52f4702919f1843fd094..abb6ce7c1b7ed2a67ee6b064377698df2efcb9c6 100644 (file)
@@ -1149,6 +1149,48 @@ release_tpsram:
        return ret;
 }
 
+/**
+ * t3_synchronize_rx - wait for current Rx processing on a port to complete
+ * @adap: the adapter
+ * @p: the port
+ *
+ * Ensures that current Rx processing on any of the queues associated with
+ * the given port completes before returning.  We do this by acquiring and
+ * releasing the locks of the response queues associated with the port.
+ */
+static void t3_synchronize_rx(struct adapter *adap, const struct port_info *p)
+{
+       int i;
+
+       for (i = p->first_qset; i < p->first_qset + p->nqsets; i++) {
+               struct sge_rspq *q = &adap->sge.qs[i].rspq;
+
+               spin_lock_irq(&q->lock);
+               spin_unlock_irq(&q->lock);
+       }
+}
+
+static void cxgb_vlan_mode(struct net_device *dev, netdev_features_t features)
+{
+       struct port_info *pi = netdev_priv(dev);
+       struct adapter *adapter = pi->adapter;
+
+       if (adapter->params.rev > 0) {
+               t3_set_vlan_accel(adapter, 1 << pi->port_id,
+                                 features & NETIF_F_HW_VLAN_RX);
+       } else {
+               /* single control for all ports */
+               unsigned int i, have_vlans = features & NETIF_F_HW_VLAN_RX;
+
+               for_each_port(adapter, i)
+                       have_vlans |=
+                               adapter->port[i]->features & NETIF_F_HW_VLAN_RX;
+
+               t3_set_vlan_accel(adapter, 1, have_vlans);
+       }
+       t3_synchronize_rx(adapter, pi);
+}
+
 /**
  *     cxgb_up - enable the adapter
  *     @adapter: adapter being enabled
@@ -1161,7 +1203,7 @@ release_tpsram:
  */
 static int cxgb_up(struct adapter *adap)
 {
-       int err;
+       int i, err;
 
        if (!(adap->flags & FULL_INIT_DONE)) {
                err = t3_check_fw_version(adap);
@@ -1198,6 +1240,9 @@ static int cxgb_up(struct adapter *adap)
                if (err)
                        goto out;
 
+               for_each_port(adap, i)
+                       cxgb_vlan_mode(adap->port[i], adap->port[i]->features);
+
                setup_rss(adap);
                if (!(adap->flags & NAPI_INIT))
                        init_napi(adap);
@@ -2508,48 +2553,6 @@ static int cxgb_set_mac_addr(struct net_device *dev, void *p)
        return 0;
 }
 
-/**
- * t3_synchronize_rx - wait for current Rx processing on a port to complete
- * @adap: the adapter
- * @p: the port
- *
- * Ensures that current Rx processing on any of the queues associated with
- * the given port completes before returning.  We do this by acquiring and
- * releasing the locks of the response queues associated with the port.
- */
-static void t3_synchronize_rx(struct adapter *adap, const struct port_info *p)
-{
-       int i;
-
-       for (i = p->first_qset; i < p->first_qset + p->nqsets; i++) {
-               struct sge_rspq *q = &adap->sge.qs[i].rspq;
-
-               spin_lock_irq(&q->lock);
-               spin_unlock_irq(&q->lock);
-       }
-}
-
-static void cxgb_vlan_mode(struct net_device *dev, netdev_features_t features)
-{
-       struct port_info *pi = netdev_priv(dev);
-       struct adapter *adapter = pi->adapter;
-
-       if (adapter->params.rev > 0) {
-               t3_set_vlan_accel(adapter, 1 << pi->port_id,
-                                 features & NETIF_F_HW_VLAN_RX);
-       } else {
-               /* single control for all ports */
-               unsigned int i, have_vlans = features & NETIF_F_HW_VLAN_RX;
-
-               for_each_port(adapter, i)
-                       have_vlans |=
-                               adapter->port[i]->features & NETIF_F_HW_VLAN_RX;
-
-               t3_set_vlan_accel(adapter, 1, have_vlans);
-       }
-       t3_synchronize_rx(adapter, pi);
-}
-
 static netdev_features_t cxgb_fix_features(struct net_device *dev,
        netdev_features_t features)
 {
@@ -3353,9 +3356,6 @@ static int __devinit init_one(struct pci_dev *pdev,
        err = sysfs_create_group(&adapter->port[0]->dev.kobj,
                                 &cxgb3_attr_group);
 
-       for_each_port(adapter, i)
-               cxgb_vlan_mode(adapter->port[i], adapter->port[i]->features);
-
        print_port_info(adapter, ai);
        return 0;
 
index b2dc2c81a147f66581d1302f1b8eb1ee92346288..2e09edb9cdf84b3d1cc49d7dad5167a2ce3be75a 100644 (file)
@@ -1259,55 +1259,21 @@ rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
 {
        int phy_addr;
        struct netdev_private *np = netdev_priv(dev);
-       struct mii_data *miidata = (struct mii_data *) &rq->ifr_ifru;
-
-       struct netdev_desc *desc;
-       int i;
+       struct mii_ioctl_data *miidata = if_mii(rq);
 
        phy_addr = np->phy_addr;
        switch (cmd) {
-       case SIOCDEVPRIVATE:
-               break;
-
-       case SIOCDEVPRIVATE + 1:
-               miidata->out_value = mii_read (dev, phy_addr, miidata->reg_num);
+       case SIOCGMIIPHY:
+               miidata->phy_id = phy_addr;
                break;
-       case SIOCDEVPRIVATE + 2:
-               mii_write (dev, phy_addr, miidata->reg_num, miidata->in_value);
+       case SIOCGMIIREG:
+               miidata->val_out = mii_read (dev, phy_addr, miidata->reg_num);
                break;
-       case SIOCDEVPRIVATE + 3:
-               break;
-       case SIOCDEVPRIVATE + 4:
-               break;
-       case SIOCDEVPRIVATE + 5:
-               netif_stop_queue (dev);
+       case SIOCSMIIREG:
+               if (!capable(CAP_NET_ADMIN))
+                       return -EPERM;
+               mii_write (dev, phy_addr, miidata->reg_num, miidata->val_in);
                break;
-       case SIOCDEVPRIVATE + 6:
-               netif_wake_queue (dev);
-               break;
-       case SIOCDEVPRIVATE + 7:
-               printk
-                   ("tx_full=%x cur_tx=%lx old_tx=%lx cur_rx=%lx old_rx=%lx\n",
-                    netif_queue_stopped(dev), np->cur_tx, np->old_tx, np->cur_rx,
-                    np->old_rx);
-               break;
-       case SIOCDEVPRIVATE + 8:
-               printk("TX ring:\n");
-               for (i = 0; i < TX_RING_SIZE; i++) {
-                       desc = &np->tx_ring[i];
-                       printk
-                           ("%02x:cur:%08x next:%08x status:%08x frag1:%08x frag0:%08x",
-                            i,
-                            (u32) (np->tx_ring_dma + i * sizeof (*desc)),
-                            (u32)le64_to_cpu(desc->next_desc),
-                            (u32)le64_to_cpu(desc->status),
-                            (u32)(le64_to_cpu(desc->fraginfo) >> 32),
-                            (u32)le64_to_cpu(desc->fraginfo));
-                       printk ("\n");
-               }
-               printk ("\n");
-               break;
-
        default:
                return -EOPNOTSUPP;
        }
index ba0adcafa55ad71c2dd63098796ce003a4cb6701..30c2da3de548f92ce0ebe794dc9c894af284c010 100644 (file)
@@ -365,13 +365,6 @@ struct ioctl_data {
        char *data;
 };
 
-struct mii_data {
-       __u16 reserved;
-       __u16 reg_num;
-       __u16 in_value;
-       __u16 out_value;
-};
-
 /* The Rx and Tx buffer descriptors. */
 struct netdev_desc {
        __le64 next_desc;
index a12b3f5bc025a1dd84d80d51ab7d6ecf29f7f6c9..b2494637cb60dfded6e1a03157c75160cd248839 100644 (file)
@@ -206,7 +206,8 @@ struct fec_enet_private {
 
        struct net_device *netdev;
 
-       struct clk *clk;
+       struct clk *clk_ipg;
+       struct clk *clk_ahb;
 
        /* The saved address of a sent-in-place packet/buffer, for skfree(). */
        unsigned char *tx_bounce[TX_RING_SIZE];
@@ -1064,7 +1065,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
         * Reference Manual has an error on this, and gets fixed on i.MX6Q
         * document.
         */
-       fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk), 5000000);
+       fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk_ahb), 5000000);
        if (id_entry->driver_data & FEC_QUIRK_ENET_MAC)
                fep->phy_speed--;
        fep->phy_speed <<= 1;
@@ -1609,12 +1610,20 @@ fec_probe(struct platform_device *pdev)
                }
        }
 
-       fep->clk = clk_get(&pdev->dev, NULL);
-       if (IS_ERR(fep->clk)) {
-               ret = PTR_ERR(fep->clk);
+       fep->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+       if (IS_ERR(fep->clk_ipg)) {
+               ret = PTR_ERR(fep->clk_ipg);
                goto failed_clk;
        }
-       clk_prepare_enable(fep->clk);
+
+       fep->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
+       if (IS_ERR(fep->clk_ahb)) {
+               ret = PTR_ERR(fep->clk_ahb);
+               goto failed_clk;
+       }
+
+       clk_prepare_enable(fep->clk_ahb);
+       clk_prepare_enable(fep->clk_ipg);
 
        ret = fec_enet_init(ndev);
        if (ret)
@@ -1637,8 +1646,8 @@ failed_register:
        fec_enet_mii_remove(fep);
 failed_mii_init:
 failed_init:
-       clk_disable_unprepare(fep->clk);
-       clk_put(fep->clk);
+       clk_disable_unprepare(fep->clk_ahb);
+       clk_disable_unprepare(fep->clk_ipg);
 failed_clk:
        for (i = 0; i < FEC_IRQ_NUM; i++) {
                irq = platform_get_irq(pdev, i);
@@ -1670,8 +1679,8 @@ fec_drv_remove(struct platform_device *pdev)
                if (irq > 0)
                        free_irq(irq, ndev);
        }
-       clk_disable_unprepare(fep->clk);
-       clk_put(fep->clk);
+       clk_disable_unprepare(fep->clk_ahb);
+       clk_disable_unprepare(fep->clk_ipg);
        iounmap(fep->hwp);
        free_netdev(ndev);
 
@@ -1695,7 +1704,8 @@ fec_suspend(struct device *dev)
                fec_stop(ndev);
                netif_device_detach(ndev);
        }
-       clk_disable_unprepare(fep->clk);
+       clk_disable_unprepare(fep->clk_ahb);
+       clk_disable_unprepare(fep->clk_ipg);
 
        return 0;
 }
@@ -1706,7 +1716,8 @@ fec_resume(struct device *dev)
        struct net_device *ndev = dev_get_drvdata(dev);
        struct fec_enet_private *fep = netdev_priv(ndev);
 
-       clk_prepare_enable(fep->clk);
+       clk_prepare_enable(fep->clk_ahb);
+       clk_prepare_enable(fep->clk_ipg);
        if (netif_running(ndev)) {
                fec_restart(ndev, fep->full_duplex);
                netif_device_attach(ndev);
index 17a46e76123f92a510b39d2ebaa29eeecf8e97ab..9ac14f8048512a66aef3a8fc2bba992d198393ef 100644 (file)
@@ -116,10 +116,10 @@ static struct ucc_geth_info ugeth_primary_info = {
        .maxGroupAddrInHash = 4,
        .maxIndAddrInHash = 4,
        .prel = 7,
-       .maxFrameLength = 1518,
+       .maxFrameLength = 1518+16, /* Add extra bytes for VLANs etc. */
        .minFrameLength = 64,
-       .maxD1Length = 1520,
-       .maxD2Length = 1520,
+       .maxD1Length = 1520+16, /* Add extra bytes for VLANs etc. */
+       .maxD2Length = 1520+16, /* Add extra bytes for VLANs etc. */
        .vlantype = 0x8100,
        .ecamptr = ((uint32_t) NULL),
        .eventRegMask = UCCE_OTHER,
index 2e395a2566b8d6221747f79828cbdfb70f72947c..f71b3e7b12defe7c92489ca967fbfe72819ab382 100644 (file)
@@ -877,7 +877,7 @@ struct ucc_geth_hardware_statistics {
 
 /* Driver definitions */
 #define TX_BD_RING_LEN                          0x10
-#define RX_BD_RING_LEN                          0x10
+#define RX_BD_RING_LEN                          0x20
 
 #define TX_RING_MOD_MASK(size)                  (size-1)
 #define RX_RING_MOD_MASK(size)                  (size-1)
index 3516e17a399d3137ccf0e2eea06318c0171aeba4..c9069a28832b0bfa39e4b118c7399a744ac0c8a2 100644 (file)
@@ -290,16 +290,18 @@ static void ehea_update_bcmc_registrations(void)
 
                                arr[i].adh = adapter->handle;
                                arr[i].port_id = port->logical_port_id;
-                               arr[i].reg_type = EHEA_BCMC_SCOPE_ALL |
-                                                 EHEA_BCMC_MULTICAST |
+                               arr[i].reg_type = EHEA_BCMC_MULTICAST |
                                                  EHEA_BCMC_UNTAGGED;
+                               if (mc_entry->macaddr == 0)
+                                       arr[i].reg_type |= EHEA_BCMC_SCOPE_ALL;
                                arr[i++].macaddr = mc_entry->macaddr;
 
                                arr[i].adh = adapter->handle;
                                arr[i].port_id = port->logical_port_id;
-                               arr[i].reg_type = EHEA_BCMC_SCOPE_ALL |
-                                                 EHEA_BCMC_MULTICAST |
+                               arr[i].reg_type = EHEA_BCMC_MULTICAST |
                                                  EHEA_BCMC_VLANID_ALL;
+                               if (mc_entry->macaddr == 0)
+                                       arr[i].reg_type |= EHEA_BCMC_SCOPE_ALL;
                                arr[i++].macaddr = mc_entry->macaddr;
                                num_registrations -= 2;
                        }
@@ -1838,8 +1840,9 @@ static u64 ehea_multicast_reg_helper(struct ehea_port *port, u64 mc_mac_addr,
        u64 hret;
        u8 reg_type;
 
-       reg_type = EHEA_BCMC_SCOPE_ALL | EHEA_BCMC_MULTICAST
-                | EHEA_BCMC_UNTAGGED;
+       reg_type = EHEA_BCMC_MULTICAST | EHEA_BCMC_UNTAGGED;
+       if (mc_mac_addr == 0)
+               reg_type |= EHEA_BCMC_SCOPE_ALL;
 
        hret = ehea_h_reg_dereg_bcmc(port->adapter->handle,
                                     port->logical_port_id,
@@ -1847,8 +1850,9 @@ static u64 ehea_multicast_reg_helper(struct ehea_port *port, u64 mc_mac_addr,
        if (hret)
                goto out;
 
-       reg_type = EHEA_BCMC_SCOPE_ALL | EHEA_BCMC_MULTICAST
-                | EHEA_BCMC_VLANID_ALL;
+       reg_type = EHEA_BCMC_MULTICAST | EHEA_BCMC_VLANID_ALL;
+       if (mc_mac_addr == 0)
+               reg_type |= EHEA_BCMC_SCOPE_ALL;
 
        hret = ehea_h_reg_dereg_bcmc(port->adapter->handle,
                                     port->logical_port_id,
@@ -1898,7 +1902,7 @@ static void ehea_allmulti(struct net_device *dev, int enable)
                                netdev_err(dev,
                                           "failed enabling IFF_ALLMULTI\n");
                }
-       } else
+       } else {
                if (!enable) {
                        /* Disable ALLMULTI */
                        hret = ehea_multicast_reg_helper(port, 0, H_DEREG_BCMC);
@@ -1908,6 +1912,7 @@ static void ehea_allmulti(struct net_device *dev, int enable)
                                netdev_err(dev,
                                           "failed disabling IFF_ALLMULTI\n");
                }
+       }
 }
 
 static void ehea_add_multicast_entry(struct ehea_port *port, u8 *mc_mac_addr)
@@ -1941,11 +1946,7 @@ static void ehea_set_multicast_list(struct net_device *dev)
        struct netdev_hw_addr *ha;
        int ret;
 
-       if (port->promisc) {
-               ehea_promiscuous(dev, 1);
-               return;
-       }
-       ehea_promiscuous(dev, 0);
+       ehea_promiscuous(dev, !!(dev->flags & IFF_PROMISC));
 
        if (dev->flags & IFF_ALLMULTI) {
                ehea_allmulti(dev, 1);
@@ -2463,6 +2464,7 @@ static int ehea_down(struct net_device *dev)
                return 0;
 
        ehea_drop_multicast_list(dev);
+       ehea_allmulti(dev, 0);
        ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
 
        ehea_free_interrupts(dev);
@@ -3261,6 +3263,7 @@ static int __devinit ehea_probe_adapter(struct platform_device *dev,
        struct ehea_adapter *adapter;
        const u64 *adapter_handle;
        int ret;
+       int i;
 
        if (!dev || !dev->dev.of_node) {
                pr_err("Invalid ibmebus device probed\n");
@@ -3314,17 +3317,9 @@ static int __devinit ehea_probe_adapter(struct platform_device *dev,
        tasklet_init(&adapter->neq_tasklet, ehea_neq_tasklet,
                     (unsigned long)adapter);
 
-       ret = ibmebus_request_irq(adapter->neq->attr.ist1,
-                                 ehea_interrupt_neq, IRQF_DISABLED,
-                                 "ehea_neq", adapter);
-       if (ret) {
-               dev_err(&dev->dev, "requesting NEQ IRQ failed\n");
-               goto out_kill_eq;
-       }
-
        ret = ehea_create_device_sysfs(dev);
        if (ret)
-               goto out_free_irq;
+               goto out_kill_eq;
 
        ret = ehea_setup_ports(adapter);
        if (ret) {
@@ -3332,15 +3327,28 @@ static int __devinit ehea_probe_adapter(struct platform_device *dev,
                goto out_rem_dev_sysfs;
        }
 
+       ret = ibmebus_request_irq(adapter->neq->attr.ist1,
+                                 ehea_interrupt_neq, IRQF_DISABLED,
+                                 "ehea_neq", adapter);
+       if (ret) {
+               dev_err(&dev->dev, "requesting NEQ IRQ failed\n");
+               goto out_shutdown_ports;
+       }
+
+
        ret = 0;
        goto out;
 
+out_shutdown_ports:
+       for (i = 0; i < EHEA_MAX_PORTS; i++)
+               if (adapter->port[i]) {
+                       ehea_shutdown_single_port(adapter->port[i]);
+                       adapter->port[i] = NULL;
+               }
+
 out_rem_dev_sysfs:
        ehea_remove_device_sysfs(dev);
 
-out_free_irq:
-       ibmebus_free_irq(adapter->neq->attr.ist1, adapter);
-
 out_kill_eq:
        ehea_destroy_eq(adapter->neq);
 
index 52c456ec4d6cf811567f82f80477b4e32910ee9a..8364815c32ff63f04fd7942d2f240b980e156f2f 100644 (file)
@@ -450,7 +450,7 @@ u64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num,
                            void *cb_addr);
 
 #define H_REGBCMC_PN            EHEA_BMASK_IBM(48, 63)
-#define H_REGBCMC_REGTYPE       EHEA_BMASK_IBM(61, 63)
+#define H_REGBCMC_REGTYPE       EHEA_BMASK_IBM(60, 63)
 #define H_REGBCMC_MACADDR       EHEA_BMASK_IBM(16, 63)
 #define H_REGBCMC_VLANID        EHEA_BMASK_IBM(52, 63)
 
index 64c76443a7aa2f2c661f5ea0f0f3455055eb2306..b461c24945e3abc707d13ab5ba64f549c12949c8 100644 (file)
@@ -1310,10 +1310,6 @@ static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
 
                if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
                        oem_reg |= HV_OEM_BITS_LPLU;
-
-               /* Set Restart auto-neg to activate the bits */
-               if (!hw->phy.ops.check_reset_block(hw))
-                       oem_reg |= HV_OEM_BITS_RESTART_AN;
        } else {
                if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
                               E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
@@ -1324,6 +1320,11 @@ static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
                        oem_reg |= HV_OEM_BITS_LPLU;
        }
 
+       /* Set Restart auto-neg to activate the bits */
+       if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
+           !hw->phy.ops.check_reset_block(hw))
+               oem_reg |= HV_OEM_BITS_RESTART_AN;
+
        ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
 
 release:
@@ -3682,7 +3683,11 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
 
        if (hw->mac.type >= e1000_pchlan) {
                e1000_oem_bits_config_ich8lan(hw, false);
-               e1000_phy_hw_reset_ich8lan(hw);
+
+               /* Reset PHY to activate OEM bits on 82577/8 */
+               if (hw->mac.type == e1000_pchlan)
+                       e1000e_phy_hw_reset_generic(hw);
+
                ret_val = hw->phy.ops.acquire(hw);
                if (ret_val)
                        return;
index 19ab2154802c171fcadaeceb82419681b51c90f2..9520a6ac1f3069592be3cc199c9d5e2ee99215b3 100644 (file)
@@ -3799,7 +3799,7 @@ static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
        /* fire an unusual interrupt on the test handler */
        ew32(ICS, E1000_ICS_RXSEQ);
        e1e_flush();
-       msleep(50);
+       msleep(100);
 
        e1000_irq_disable(adapter);
 
index ff796e42c3ebbf1b146a28b677e7bb885e1f6bf6..16adeb9418a8903e5ccbb7503e513f1918978930 100644 (file)
@@ -106,7 +106,7 @@ E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
 /*
  * Interrupt Throttle Rate (interrupts/sec)
  *
- * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
+ * Valid Range: 100-100000 or one of: 0=off, 1=dynamic, 3=dynamic conservative
  */
 E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
 #define DEFAULT_ITR 3
@@ -344,53 +344,60 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
 
                if (num_InterruptThrottleRate > bd) {
                        adapter->itr = InterruptThrottleRate[bd];
-                       switch (adapter->itr) {
-                       case 0:
-                               e_info("%s turned off\n", opt.name);
-                               break;
-                       case 1:
-                               e_info("%s set to dynamic mode\n", opt.name);
-                               adapter->itr_setting = adapter->itr;
-                               adapter->itr = 20000;
-                               break;
-                       case 3:
-                               e_info("%s set to dynamic conservative mode\n",
-                                       opt.name);
-                               adapter->itr_setting = adapter->itr;
-                               adapter->itr = 20000;
-                               break;
-                       case 4:
-                               e_info("%s set to simplified (2000-8000 ints) "
-                                      "mode\n", opt.name);
-                               adapter->itr_setting = 4;
-                               break;
-                       default:
-                               /*
-                                * Save the setting, because the dynamic bits
-                                * change itr.
-                                */
-                               if (e1000_validate_option(&adapter->itr, &opt,
-                                                         adapter) &&
-                                   (adapter->itr == 3)) {
-                                       /*
-                                        * In case of invalid user value,
-                                        * default to conservative mode.
-                                        */
-                                       adapter->itr_setting = adapter->itr;
-                                       adapter->itr = 20000;
-                               } else {
-                                       /*
-                                        * Clear the lower two bits because
-                                        * they are used as control.
-                                        */
-                                       adapter->itr_setting =
-                                               adapter->itr & ~3;
-                               }
-                               break;
-                       }
+
+                       /*
+                        * Make sure a message is printed for non-special
+                        * values.  And in case of an invalid option, display
+                        * warning, use default and got through itr/itr_setting
+                        * adjustment logic below
+                        */
+                       if ((adapter->itr > 4) &&
+                           e1000_validate_option(&adapter->itr, &opt, adapter))
+                               adapter->itr = opt.def;
                } else {
-                       adapter->itr_setting = opt.def;
+                       /*
+                        * If no option specified, use default value and go
+                        * through the logic below to adjust itr/itr_setting
+                        */
+                       adapter->itr = opt.def;
+
+                       /*
+                        * Make sure a message is printed for non-special
+                        * default values
+                        */
+                       if (adapter->itr > 40)
+                               e_info("%s set to default %d\n", opt.name,
+                                      adapter->itr);
+               }
+
+               adapter->itr_setting = adapter->itr;
+               switch (adapter->itr) {
+               case 0:
+                       e_info("%s turned off\n", opt.name);
+                       break;
+               case 1:
+                       e_info("%s set to dynamic mode\n", opt.name);
+                       adapter->itr = 20000;
+                       break;
+               case 3:
+                       e_info("%s set to dynamic conservative mode\n",
+                              opt.name);
                        adapter->itr = 20000;
+                       break;
+               case 4:
+                       e_info("%s set to simplified (2000-8000 ints) mode\n",
+                              opt.name);
+                       break;
+               default:
+                       /*
+                        * Save the setting, because the dynamic bits
+                        * change itr.
+                        *
+                        * Clear the lower two bits because
+                        * they are used as control.
+                        */
+                       adapter->itr_setting &= ~3;
+                       break;
                }
        }
        { /* Interrupt Mode */
index d61ca2a732f0ef341ccaf036ce0dcb6efb468013..8ec74b07f940a234ccc1691e9dcd2b67691e0f4b 100644 (file)
@@ -2731,14 +2731,14 @@ static int __devinit igbvf_probe(struct pci_dev *pdev,
                        netdev->addr_len);
        }
 
-       if (!is_valid_ether_addr(netdev->perm_addr)) {
+       if (!is_valid_ether_addr(netdev->dev_addr)) {
                dev_err(&pdev->dev, "Invalid MAC Address: %pM\n",
                        netdev->dev_addr);
                err = -EIO;
                goto err_hw_init;
        }
 
-       memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len);
+       memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len);
 
        setup_timer(&adapter->watchdog_timer, &igbvf_watchdog,
                    (unsigned long) adapter);
index 77ea4b7165351707192dde0ea3c678950502a71b..bc07933d67dadec6845fb667fbc9cc1edf025c3e 100644 (file)
@@ -437,6 +437,7 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
         */
        if ((fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA) &&
            (fctl & FC_FC_END_SEQ)) {
+               skb_linearize(skb);
                crc = (struct fcoe_crc_eof *)skb_put(skb, sizeof(*crc));
                crc->fcoe_eof = FC_EOF_T;
        }
index 027d7a75be39b025c6de30a63d63a30a528424a2..ed1b47dc0834f5a5c1f76fc667e810e23125ba03 100644 (file)
@@ -622,6 +622,16 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter, int v_idx,
                if (adapter->hw.mac.type == ixgbe_mac_82599EB)
                        set_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state);
 
+#ifdef IXGBE_FCOE
+               if (adapter->netdev->features & NETIF_F_FCOE_MTU) {
+                       struct ixgbe_ring_feature *f;
+                       f = &adapter->ring_feature[RING_F_FCOE];
+                       if ((rxr_idx >= f->mask) &&
+                           (rxr_idx < f->mask + f->indices))
+                               set_bit(__IXGBE_RX_FCOE_BUFSZ, &ring->state);
+               }
+
+#endif /* IXGBE_FCOE */
                /* apply Rx specific ring traits */
                ring->count = adapter->rx_ring_count;
                ring->queue_index = rxr_idx;
index 3e26b1f9ac75f0811e9b6e4662b4b77c94a77c25..88f6b2e9b72db2ddb22b917fcb4e4ae4c9b99514 100644 (file)
@@ -3154,14 +3154,6 @@ static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter)
                        set_ring_rsc_enabled(rx_ring);
                else
                        clear_ring_rsc_enabled(rx_ring);
-#ifdef IXGBE_FCOE
-               if (netdev->features & NETIF_F_FCOE_MTU) {
-                       struct ixgbe_ring_feature *f;
-                       f = &adapter->ring_feature[RING_F_FCOE];
-                       if ((i >= f->mask) && (i < f->mask + f->indices))
-                               set_bit(__IXGBE_RX_FCOE_BUFSZ, &rx_ring->state);
-               }
-#endif /* IXGBE_FCOE */
        }
 }
 
@@ -4836,7 +4828,9 @@ static int ixgbe_resume(struct pci_dev *pdev)
 
        pci_wake_from_d3(pdev, false);
 
+       rtnl_lock();
        err = ixgbe_init_interrupt_scheme(adapter);
+       rtnl_unlock();
        if (err) {
                e_dev_err("Cannot initialize interrupts for device\n");
                return err;
@@ -4879,10 +4873,6 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
        }
 
        ixgbe_clear_interrupt_scheme(adapter);
-#ifdef CONFIG_DCB
-       kfree(adapter->ixgbe_ieee_pfc);
-       kfree(adapter->ixgbe_ieee_ets);
-#endif
 
 #ifdef CONFIG_PM
        retval = pci_save_state(pdev);
@@ -4893,6 +4883,16 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
        if (wufc) {
                ixgbe_set_rx_mode(netdev);
 
+               /*
+                * enable the optics for both mult-speed fiber and
+                * 82599 SFP+ fiber as we can WoL.
+                */
+               if (hw->mac.ops.enable_tx_laser &&
+                   (hw->phy.multispeed_fiber ||
+                   (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber &&
+                    hw->mac.type == ixgbe_mac_82599EB)))
+                       hw->mac.ops.enable_tx_laser(hw);
+
                /* turn on all-multi mode if wake on multicast is enabled */
                if (wufc & IXGBE_WUFC_MC) {
                        fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
@@ -7220,6 +7220,11 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev)
 
        ixgbe_release_hw_control(adapter);
 
+#ifdef CONFIG_DCB
+       kfree(adapter->ixgbe_ieee_pfc);
+       kfree(adapter->ixgbe_ieee_ets);
+
+#endif
        iounmap(adapter->hw.hw_addr);
        pci_release_selected_regions(pdev, pci_select_bars(pdev,
                                     IORESOURCE_MEM));
index c9b504e2dfc3bfdc4707dd0f3db240b1f365ec0c..487a6c8bd4eccf6c21dc394c317e408cabe9aa12 100644 (file)
@@ -2494,8 +2494,13 @@ static struct sk_buff *receive_copy(struct sky2_port *sky2,
                skb_copy_from_linear_data(re->skb, skb->data, length);
                skb->ip_summed = re->skb->ip_summed;
                skb->csum = re->skb->csum;
+               skb->rxhash = re->skb->rxhash;
+               skb->vlan_tci = re->skb->vlan_tci;
+
                pci_dma_sync_single_for_device(sky2->hw->pdev, re->data_addr,
                                               length, PCI_DMA_FROMDEVICE);
+               re->skb->vlan_tci = 0;
+               re->skb->rxhash = 0;
                re->skb->ip_summed = CHECKSUM_NONE;
                skb_put(skb, length);
        }
@@ -2580,9 +2585,6 @@ static struct sk_buff *sky2_receive(struct net_device *dev,
        struct sk_buff *skb = NULL;
        u16 count = (status & GMR_FS_LEN) >> 16;
 
-       if (status & GMR_FS_VLAN)
-               count -= VLAN_HLEN;     /* Account for vlan tag */
-
        netif_printk(sky2, rx_status, KERN_DEBUG, dev,
                     "rx slot %u status 0x%x len %d\n",
                     sky2->rx_next, status, length);
@@ -2590,6 +2592,9 @@ static struct sk_buff *sky2_receive(struct net_device *dev,
        sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_pending;
        prefetch(sky2->rx_ring + sky2->rx_next);
 
+       if (vlan_tx_tag_present(re->skb))
+               count -= VLAN_HLEN;     /* Account for vlan tag */
+
        /* This chip has hardware problems that generates bogus status.
         * So do only marginal checking and expect higher level protocols
         * to handle crap frames.
@@ -2647,11 +2652,8 @@ static inline void sky2_tx_done(struct net_device *dev, u16 last)
 }
 
 static inline void sky2_skb_rx(const struct sky2_port *sky2,
-                              u32 status, struct sk_buff *skb)
+                              struct sk_buff *skb)
 {
-       if (status & GMR_FS_VLAN)
-               __vlan_hwaccel_put_tag(skb, be16_to_cpu(sky2->rx_tag));
-
        if (skb->ip_summed == CHECKSUM_NONE)
                netif_receive_skb(skb);
        else
@@ -2705,6 +2707,14 @@ static void sky2_rx_checksum(struct sky2_port *sky2, u32 status)
        }
 }
 
+static void sky2_rx_tag(struct sky2_port *sky2, u16 length)
+{
+       struct sk_buff *skb;
+
+       skb = sky2->rx_ring[sky2->rx_next].skb;
+       __vlan_hwaccel_put_tag(skb, be16_to_cpu(length));
+}
+
 static void sky2_rx_hash(struct sky2_port *sky2, u32 status)
 {
        struct sk_buff *skb;
@@ -2763,8 +2773,7 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
                        }
 
                        skb->protocol = eth_type_trans(skb, dev);
-
-                       sky2_skb_rx(sky2, status, skb);
+                       sky2_skb_rx(sky2, skb);
 
                        /* Stop after net poll weight */
                        if (++work_done >= to_do)
@@ -2772,11 +2781,11 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
                        break;
 
                case OP_RXVLAN:
-                       sky2->rx_tag = length;
+                       sky2_rx_tag(sky2, length);
                        break;
 
                case OP_RXCHKSVLAN:
-                       sky2->rx_tag = length;
+                       sky2_rx_tag(sky2, length);
                        /* fall through */
                case OP_RXCHKS:
                        if (likely(dev->features & NETIF_F_RXCSUM))
index ff6f58bf822aa378ffa0975140733fa40bf41f5d..3c896ce80b71ec1facc6f04f666ab80711c5dfe3 100644 (file)
@@ -2241,7 +2241,6 @@ struct sky2_port {
        u16                  rx_pending;
        u16                  rx_data_size;
        u16                  rx_nfrags;
-       u16                  rx_tag;
 
        struct {
                unsigned long last;
index c722aa607d074796985b9028c5c91752459aad8e..f8dda009d3c04722e54c659bfa3bb921d8b62fa8 100644 (file)
@@ -889,16 +889,17 @@ static int ks8851_net_stop(struct net_device *dev)
        netif_stop_queue(dev);
 
        mutex_lock(&ks->lock);
+       /* turn off the IRQs and ack any outstanding */
+       ks8851_wrreg16(ks, KS_IER, 0x0000);
+       ks8851_wrreg16(ks, KS_ISR, 0xffff);
+       mutex_unlock(&ks->lock);
 
        /* stop any outstanding work */
        flush_work(&ks->irq_work);
        flush_work(&ks->tx_work);
        flush_work(&ks->rxctrl_work);
 
-       /* turn off the IRQs and ack any outstanding */
-       ks8851_wrreg16(ks, KS_IER, 0x0000);
-       ks8851_wrreg16(ks, KS_ISR, 0xffff);
-
+       mutex_lock(&ks->lock);
        /* shutdown RX process */
        ks8851_wrreg16(ks, KS_RXCR1, 0x0000);
 
@@ -907,6 +908,7 @@ static int ks8851_net_stop(struct net_device *dev)
 
        /* set powermode to soft power down to save power */
        ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN);
+       mutex_unlock(&ks->lock);
 
        /* ensure any queued tx buffers are dumped */
        while (!skb_queue_empty(&ks->txq)) {
@@ -918,7 +920,6 @@ static int ks8851_net_stop(struct net_device *dev)
                dev_kfree_skb(txb);
        }
 
-       mutex_unlock(&ks->lock);
        return 0;
 }
 
@@ -1418,6 +1419,7 @@ static int __devinit ks8851_probe(struct spi_device *spi)
        struct net_device *ndev;
        struct ks8851_net *ks;
        int ret;
+       unsigned cider;
 
        ndev = alloc_etherdev(sizeof(struct ks8851_net));
        if (!ndev)
@@ -1484,8 +1486,8 @@ static int __devinit ks8851_probe(struct spi_device *spi)
        ks8851_soft_reset(ks, GRR_GSR);
 
        /* simple check for a valid chip being connected to the bus */
-
-       if ((ks8851_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) {
+       cider = ks8851_rdreg16(ks, KS_CIDER);
+       if ((cider & ~CIDER_REV_MASK) != CIDER_ID) {
                dev_err(&spi->dev, "failed to read device ID\n");
                ret = -ENODEV;
                goto err_id;
@@ -1516,15 +1518,14 @@ static int __devinit ks8851_probe(struct spi_device *spi)
        }
 
        netdev_info(ndev, "revision %d, MAC %pM, IRQ %d, %s EEPROM\n",
-                   CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)),
-                   ndev->dev_addr, ndev->irq,
+                   CIDER_REV_GET(cider), ndev->dev_addr, ndev->irq,
                    ks->rc_ccr & CCR_EEPROM ? "has" : "no");
 
        return 0;
 
 
 err_netdev:
-       free_irq(ndev->irq, ndev);
+       free_irq(ndev->irq, ks);
 
 err_id:
 err_irq:
index b8104d9f40810871525eb360edaf16e483f6e945..5ffde23ac8fb729526a9dc9c7cfebd95fb2e9b09 100644 (file)
@@ -40,7 +40,7 @@
 #define        DRV_NAME        "ks8851_mll"
 
 static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 };
-#define MAX_RECV_FRAMES                        32
+#define MAX_RECV_FRAMES                        255
 #define MAX_BUF_SIZE                   2048
 #define TX_BUF_SIZE                    2000
 #define RX_BUF_SIZE                    2000
index ef723b185d853794746a3882cf54e4c00a205699..eaf9ff0262a9c63594e7d80c617d87098c957fa6 100644 (file)
@@ -5675,7 +5675,7 @@ static int netdev_set_mac_address(struct net_device *dev, void *addr)
                memcpy(hw->override_addr, mac->sa_data, ETH_ALEN);
        }
 
-       memcpy(dev->dev_addr, mac->sa_data, MAX_ADDR_LEN);
+       memcpy(dev->dev_addr, mac->sa_data, ETH_ALEN);
 
        interrupt = hw_block_intr(hw);
 
index abc79076f867baa5220361e0d6810d11e7edc8ef..b3287c0fe279b95636f80325549833edd137f590 100644 (file)
@@ -958,6 +958,11 @@ static inline void cp_start_hw (struct cp_private *cp)
        cpw8(Cmd, RxOn | TxOn);
 }
 
+static void cp_enable_irq(struct cp_private *cp)
+{
+       cpw16_f(IntrMask, cp_intr_mask);
+}
+
 static void cp_init_hw (struct cp_private *cp)
 {
        struct net_device *dev = cp->dev;
@@ -997,8 +1002,6 @@ static void cp_init_hw (struct cp_private *cp)
 
        cpw16(MultiIntr, 0);
 
-       cpw16_f(IntrMask, cp_intr_mask);
-
        cpw8_f(Cfg9346, Cfg9346_Lock);
 }
 
@@ -1130,6 +1133,8 @@ static int cp_open (struct net_device *dev)
        if (rc)
                goto err_out_hw;
 
+       cp_enable_irq(cp);
+
        netif_carrier_off(dev);
        mii_check_media(&cp->mii_if, netif_msg_link(cp), true);
        netif_start_queue(dev);
@@ -2031,6 +2036,7 @@ static int cp_resume (struct pci_dev *pdev)
        /* FIXME: sh*t may happen if the Rx ring buffer is depleted */
        cp_init_rings_index (cp);
        cp_init_hw (cp);
+       cp_enable_irq(cp);
        netif_start_queue (dev);
 
        spin_lock_irqsave (&cp->lock, flags);
index 4a6971027076613f7765a187e2c28eb11df56104..cd3defb11ffb3e09822b5f20555796ddd8960fd2 100644 (file)
@@ -1166,10 +1166,8 @@ smsc911x_rx_counterrors(struct net_device *dev, unsigned int rxstat)
 
 /* Quickly dumps bad packets */
 static void
-smsc911x_rx_fastforward(struct smsc911x_data *pdata, unsigned int pktbytes)
+smsc911x_rx_fastforward(struct smsc911x_data *pdata, unsigned int pktwords)
 {
-       unsigned int pktwords = (pktbytes + NET_IP_ALIGN + 3) >> 2;
-
        if (likely(pktwords >= 4)) {
                unsigned int timeout = 500;
                unsigned int val;
@@ -1233,7 +1231,7 @@ static int smsc911x_poll(struct napi_struct *napi, int budget)
                        continue;
                }
 
-               skb = netdev_alloc_skb(dev, pktlength + NET_IP_ALIGN);
+               skb = netdev_alloc_skb(dev, pktwords << 2);
                if (unlikely(!skb)) {
                        SMSC_WARN(pdata, rx_err,
                                  "Unable to allocate skb for rx packet");
@@ -1243,14 +1241,12 @@ static int smsc911x_poll(struct napi_struct *napi, int budget)
                        break;
                }
 
-               skb->data = skb->head;
-               skb_reset_tail_pointer(skb);
+               pdata->ops->rx_readfifo(pdata,
+                                (unsigned int *)skb->data, pktwords);
 
                /* Align IP on 16B boundary */
                skb_reserve(skb, NET_IP_ALIGN);
                skb_put(skb, pktlength - 4);
-               pdata->ops->rx_readfifo(pdata,
-                                (unsigned int *)skb->head, pktwords);
                skb->protocol = eth_type_trans(skb, dev);
                skb_checksum_none_assert(skb);
                netif_receive_skb(skb);
@@ -1565,7 +1561,7 @@ static int smsc911x_open(struct net_device *dev)
        smsc911x_reg_write(pdata, FIFO_INT, temp);
 
        /* set RX Data offset to 2 bytes for alignment */
-       smsc911x_reg_write(pdata, RX_CFG, (2 << 8));
+       smsc911x_reg_write(pdata, RX_CFG, (NET_IP_ALIGN << 8));
 
        /* enable NAPI polling before enabling RX interrupts */
        napi_enable(&pdata->napi);
@@ -2382,7 +2378,6 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
        SET_NETDEV_DEV(dev, &pdev->dev);
 
        pdata = netdev_priv(dev);
-
        dev->irq = irq_res->start;
        irq_flags = irq_res->flags & IRQF_TRIGGER_MASK;
        pdata->ioaddr = ioremap_nocache(res->start, res_size);
@@ -2446,7 +2441,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
        if (retval) {
                SMSC_WARN(pdata, probe,
                          "Unable to claim requested irq: %d", dev->irq);
-               goto out_free_irq;
+               goto out_disable_resources;
        }
 
        retval = register_netdev(dev);
index 558409ff40582fa9f5cd1ae91248f9d214c51d3e..4ba969096717a7ce59e55eaa97f40bdc974ef8b2 100644 (file)
@@ -2339,7 +2339,7 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state)
        netif_device_detach(dev);
 
        /* Switch off chip, remember WOL setting */
-       gp->asleep_wol = gp->wake_on_lan;
+       gp->asleep_wol = !!gp->wake_on_lan;
        gem_do_stop(dev, gp->asleep_wol);
 
        /* Unlock the network stack */
index 174a3348f6762d67a661801342ea6cbe95a7810f..08aff1a2087c920207f544bf540917b481c35344 100644 (file)
@@ -1511,7 +1511,7 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
 
 static int match_first_device(struct device *dev, void *data)
 {
-       return 1;
+       return !strncmp(dev_name(dev), "davinci_mdio", 12);
 }
 
 /**
index 2757c7d6e6330460c179d025a1ddc2267d32b27d..e4e47088e26b98fe0118c16ae17da61ec0f07dde 100644 (file)
@@ -181,6 +181,11 @@ static inline int wait_for_user_access(struct davinci_mdio_data *data)
                __davinci_mdio_reset(data);
                return -EAGAIN;
        }
+
+       reg = __raw_readl(&regs->user[0].access);
+       if ((reg & USERACCESS_GO) == 0)
+               return 0;
+
        dev_err(data->dev, "timed out waiting for user access\n");
        return -ETIMEDOUT;
 }
index 817ad3bc49574670ab6040b6805528c5b863c852..efd36691ce5450881dd14114037071708df4e7c1 100644 (file)
@@ -228,7 +228,7 @@ tlan_get_skb(const struct tlan_list *tag)
        unsigned long addr;
 
        addr = tag->buffer[9].address;
-       addr |= (tag->buffer[8].address << 16) << 16;
+       addr |= ((unsigned long) tag->buffer[8].address << 16) << 16;
        return (struct sk_buff *) addr;
 }
 
index cc83af083fd7b7b17a650471436ca42e74f8fbe0..44b8d2bad8c3efd09a1d572d2ef7cf36f8d4a227 100644 (file)
@@ -2,9 +2,7 @@
  * Definitions for Xilinx Axi Ethernet device driver.
  *
  * Copyright (c) 2009 Secret Lab Technologies, Ltd.
- * Copyright (c) 2010 Xilinx, Inc. All rights reserved.
- * Copyright (c) 2012 Daniel Borkmann, <daniel.borkmann@tik.ee.ethz.ch>
- * Copyright (c) 2012 Ariane Keller, <ariane.keller@tik.ee.ethz.ch>
+ * Copyright (c) 2010 - 2012 Xilinx, Inc. All rights reserved.
  */
 
 #ifndef XILINX_AXIENET_H
index 2fcbeba6814bead15acdae0feff0e3e264c5656d..9c365e192a3197dc11267f37ce572985c12f274b 100644 (file)
@@ -4,9 +4,9 @@
  * Copyright (c) 2008 Nissin Systems Co., Ltd.,  Yoshio Kashiwagi
  * Copyright (c) 2005-2008 DLA Systems,  David H. Lynch Jr. <dhlii@dlasys.net>
  * Copyright (c) 2008-2009 Secret Lab Technologies Ltd.
- * Copyright (c) 2010 Xilinx, Inc. All rights reserved.
- * Copyright (c) 2012 Daniel Borkmann, <daniel.borkmann@tik.ee.ethz.ch>
- * Copyright (c) 2012 Ariane Keller, <ariane.keller@tik.ee.ethz.ch>
+ * Copyright (c) 2010 - 2011 Michal Simek <monstr@monstr.eu>
+ * Copyright (c) 2010 - 2011 PetaLogix
+ * Copyright (c) 2010 - 2012 Xilinx, Inc. All rights reserved.
  *
  * This is a driver for the Xilinx Axi Ethernet which is used in the Virtex6
  * and Spartan6.
index d70b6e79f6c0cd4a9236a67a1dcd8b67f327aeb3..e90e1f46121ef2e0fcacc1a1b3ec5b198b2df94d 100644 (file)
@@ -2,9 +2,9 @@
  * MDIO bus driver for the Xilinx Axi Ethernet device
  *
  * Copyright (c) 2009 Secret Lab Technologies, Ltd.
- * Copyright (c) 2010 Xilinx, Inc. All rights reserved.
- * Copyright (c) 2012 Daniel Borkmann, <daniel.borkmann@tik.ee.ethz.ch>
- * Copyright (c) 2012 Ariane Keller, <ariane.keller@tik.ee.ethz.ch>
+ * Copyright (c) 2010 - 2011 Michal Simek <monstr@monstr.eu>
+ * Copyright (c) 2010 - 2011 PetaLogix
+ * Copyright (c) 2010 - 2012 Xilinx, Inc. All rights reserved.
  */
 
 #include <linux/of_address.h>
index dd294783b5c5b77c3d48ecd14067921d9e90d4bb..2d59138db7f3fd688840d6bf5ce1f449838271be 100644 (file)
@@ -44,6 +44,7 @@ struct net_device_context {
        /* point back to our device context */
        struct hv_device *device_ctx;
        struct delayed_work dwork;
+       struct work_struct work;
 };
 
 
@@ -51,30 +52,22 @@ static int ring_size = 128;
 module_param(ring_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
 
-struct set_multicast_work {
-       struct work_struct work;
-       struct net_device *net;
-};
-
 static void do_set_multicast(struct work_struct *w)
 {
-       struct set_multicast_work *swk =
-               container_of(w, struct set_multicast_work, work);
-       struct net_device *net = swk->net;
-
-       struct net_device_context *ndevctx = netdev_priv(net);
+       struct net_device_context *ndevctx =
+               container_of(w, struct net_device_context, work);
        struct netvsc_device *nvdev;
        struct rndis_device *rdev;
 
        nvdev = hv_get_drvdata(ndevctx->device_ctx);
-       if (nvdev == NULL)
-               goto out;
+       if (nvdev == NULL || nvdev->ndev == NULL)
+               return;
 
        rdev = nvdev->extension;
        if (rdev == NULL)
-               goto out;
+               return;
 
-       if (net->flags & IFF_PROMISC)
+       if (nvdev->ndev->flags & IFF_PROMISC)
                rndis_filter_set_packet_filter(rdev,
                        NDIS_PACKET_TYPE_PROMISCUOUS);
        else
@@ -82,21 +75,13 @@ static void do_set_multicast(struct work_struct *w)
                        NDIS_PACKET_TYPE_BROADCAST |
                        NDIS_PACKET_TYPE_ALL_MULTICAST |
                        NDIS_PACKET_TYPE_DIRECTED);
-
-out:
-       kfree(w);
 }
 
 static void netvsc_set_multicast_list(struct net_device *net)
 {
-       struct set_multicast_work *swk =
-               kmalloc(sizeof(struct set_multicast_work), GFP_ATOMIC);
-       if (swk == NULL)
-               return;
+       struct net_device_context *net_device_ctx = netdev_priv(net);
 
-       swk->net = net;
-       INIT_WORK(&swk->work, do_set_multicast);
-       schedule_work(&swk->work);
+       schedule_work(&net_device_ctx->work);
 }
 
 static int netvsc_open(struct net_device *net)
@@ -125,6 +110,8 @@ static int netvsc_close(struct net_device *net)
 
        netif_tx_disable(net);
 
+       /* Make sure netvsc_set_multicast_list doesn't re-enable filter! */
+       cancel_work_sync(&net_device_ctx->work);
        ret = rndis_filter_close(device_obj);
        if (ret != 0)
                netdev_err(net, "unable to close device (ret %d).\n", ret);
@@ -335,6 +322,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
 
        nvdev->start_remove = true;
        cancel_delayed_work_sync(&ndevctx->dwork);
+       cancel_work_sync(&ndevctx->work);
        netif_tx_disable(ndev);
        rndis_filter_device_remove(hdev);
 
@@ -403,6 +391,7 @@ static int netvsc_probe(struct hv_device *dev,
        net_device_ctx->device_ctx = dev;
        hv_set_drvdata(dev, net);
        INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_send_garp);
+       INIT_WORK(&net_device_ctx->work, do_set_multicast);
 
        net->netdev_ops = &device_ops;
 
@@ -456,6 +445,7 @@ static int netvsc_remove(struct hv_device *dev)
 
        ndev_ctx = netdev_priv(net);
        cancel_delayed_work_sync(&ndev_ctx->dwork);
+       cancel_work_sync(&ndev_ctx->work);
 
        /* Stop outbound asap */
        netif_tx_disable(net);
index f08c85acf761d3893b54f3d2f70e2fddcb6c5904..5ac46f5226f3c5b4b1d35e3450ec922326902896 100644 (file)
@@ -40,6 +40,7 @@ MODULE_LICENSE("GPL");
 #define IP1001_PHASE_SEL_MASK          3       /* IP1001 RX/TXPHASE_SEL */
 #define IP1001_APS_ON                  11      /* IP1001 APS Mode  bit */
 #define IP101A_G_APS_ON                        2       /* IP101A/G APS Mode bit */
+#define IP101A_G_IRQ_CONF_STATUS       0x11    /* Conf Info IRQ & Status Reg */
 
 static int ip175c_config_init(struct phy_device *phydev)
 {
@@ -185,6 +186,15 @@ static int ip175c_config_aneg(struct phy_device *phydev)
        return 0;
 }
 
+static int ip101a_g_ack_interrupt(struct phy_device *phydev)
+{
+       int err = phy_read(phydev, IP101A_G_IRQ_CONF_STATUS);
+       if (err < 0)
+               return err;
+
+       return 0;
+}
+
 static struct phy_driver ip175c_driver = {
        .phy_id         = 0x02430d80,
        .name           = "ICPlus IP175C",
@@ -204,7 +214,6 @@ static struct phy_driver ip1001_driver = {
        .phy_id_mask    = 0x0ffffff0,
        .features       = PHY_GBIT_FEATURES | SUPPORTED_Pause |
                          SUPPORTED_Asym_Pause,
-       .flags          = PHY_HAS_INTERRUPT,
        .config_init    = &ip1001_config_init,
        .config_aneg    = &genphy_config_aneg,
        .read_status    = &genphy_read_status,
@@ -220,6 +229,7 @@ static struct phy_driver ip101a_g_driver = {
        .features       = PHY_BASIC_FEATURES | SUPPORTED_Pause |
                          SUPPORTED_Asym_Pause,
        .flags          = PHY_HAS_INTERRUPT,
+       .ack_interrupt  = ip101a_g_ack_interrupt,
        .config_init    = &ip101a_g_config_init,
        .config_aneg    = &genphy_config_aneg,
        .read_status    = &genphy_read_status,
index 33f8c51968b6da62cff64d968445fcf0d55249d9..21d7151fb0ab3ea03c93208cf6d0c2749d1b825b 100644 (file)
@@ -235,7 +235,7 @@ struct ppp_net {
 /* Prototypes. */
 static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
                        struct file *file, unsigned int cmd, unsigned long arg);
-static int ppp_xmit_process(struct ppp *ppp);
+static void ppp_xmit_process(struct ppp *ppp);
 static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb);
 static void ppp_push(struct ppp *ppp);
 static void ppp_channel_push(struct channel *pch);
@@ -969,8 +969,7 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
        put_unaligned_be16(proto, pp);
 
        skb_queue_tail(&ppp->file.xq, skb);
-       if (!ppp_xmit_process(ppp))
-               netif_stop_queue(dev);
+       ppp_xmit_process(ppp);
        return NETDEV_TX_OK;
 
  outf:
@@ -1048,11 +1047,10 @@ static void ppp_setup(struct net_device *dev)
  * Called to do any work queued up on the transmit side
  * that can now be done.
  */
-static int
+static void
 ppp_xmit_process(struct ppp *ppp)
 {
        struct sk_buff *skb;
-       int ret = 0;
 
        ppp_xmit_lock(ppp);
        if (!ppp->closing) {
@@ -1062,13 +1060,12 @@ ppp_xmit_process(struct ppp *ppp)
                        ppp_send_frame(ppp, skb);
                /* If there's no work left to do, tell the core net
                   code that we can accept some more. */
-               if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq)) {
+               if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq))
                        netif_wake_queue(ppp->dev);
-                       ret = 1;
-               }
+               else
+                       netif_stop_queue(ppp->dev);
        }
        ppp_xmit_unlock(ppp);
-       return ret;
 }
 
 static inline struct sk_buff *
index 5ee032cafadea0f8405f4d8f66cb356eec236262..42b5151aa78ae8523b27493394ba87e9900338a5 100644 (file)
@@ -355,7 +355,7 @@ static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
        u32 packet_len;
        u32 padbytes = 0xffff0000;
 
-       padlen = ((skb->len + 4) % 512) ? 0 : 4;
+       padlen = ((skb->len + 4) & (dev->maxpacket - 1)) ? 0 : 4;
 
        if ((!skb_cloned(skb)) &&
            ((headroom + tailroom) >= (4 + padlen))) {
@@ -377,7 +377,7 @@ static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
        cpu_to_le32s(&packet_len);
        skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len));
 
-       if ((skb->len % 512) == 0) {
+       if (padlen) {
                cpu_to_le32s(&padbytes);
                memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes));
                skb_put(skb, sizeof(padbytes));
index 552d24bf862e124cdae480ed301418469053ccdd..d316503b35d477c3d0338c2ceeb8ba1cc5b107cf 100644 (file)
@@ -365,6 +365,27 @@ static const struct driver_info    qmi_wwan_force_int4 = {
        .data           = BIT(4), /* interface whitelist bitmap */
 };
 
+/* Sierra Wireless provide equally useless interface descriptors
+ * Devices in QMI mode can be switched between two different
+ * configurations:
+ *   a) USB interface #8 is QMI/wwan
+ *   b) USB interfaces #8, #19 and #20 are QMI/wwan
+ *
+ * Both configurations provide a number of other interfaces (serial++),
+ * some of which have the same endpoint configuration as we expect, so
+ * a whitelist or blacklist is necessary.
+ *
+ * FIXME: The below whitelist should include BIT(20).  It does not
+ * because I cannot get it to work...
+ */
+static const struct driver_info        qmi_wwan_sierra = {
+       .description    = "Sierra Wireless wwan/QMI device",
+       .flags          = FLAG_WWAN,
+       .bind           = qmi_wwan_bind_gobi,
+       .unbind         = qmi_wwan_unbind_shared,
+       .manage_power   = qmi_wwan_manage_power,
+       .data           = BIT(8) | BIT(19), /* interface whitelist bitmap */
+};
 
 #define HUAWEI_VENDOR_ID       0x12D1
 #define QMI_GOBI_DEVICE(vend, prod) \
@@ -445,6 +466,15 @@ static const struct usb_device_id products[] = {
                .bInterfaceProtocol = 0xff,
                .driver_info        = (unsigned long)&qmi_wwan_force_int4,
        },
+       {       /* Sierra Wireless MC77xx in QMI mode */
+               .match_flags        = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
+               .idVendor           = 0x1199,
+               .idProduct          = 0x68a2,
+               .bInterfaceClass    = 0xff,
+               .bInterfaceSubClass = 0xff,
+               .bInterfaceProtocol = 0xff,
+               .driver_info        = (unsigned long)&qmi_wwan_sierra,
+       },
        {QMI_GOBI_DEVICE(0x05c6, 0x9212)},      /* Acer Gobi Modem Device */
        {QMI_GOBI_DEVICE(0x03f0, 0x1f1d)},      /* HP un2400 Gobi Modem Device */
        {QMI_GOBI_DEVICE(0x03f0, 0x371d)},      /* HP un2430 Mobile Broadband Module */
index 187d01ccb97367099b04ce40f8b44fe2824293d5..00103a8c5e04d69e17408d32f139c9bee93aa03c 100644 (file)
@@ -98,7 +98,7 @@ static int __must_check smsc75xx_read_reg(struct usbnet *dev, u32 index,
 
        if (unlikely(ret < 0))
                netdev_warn(dev->net,
-                       "Failed to read register index 0x%08x", index);
+                       "Failed to read reg index 0x%08x: %d", index, ret);
 
        le32_to_cpus(buf);
        *data = *buf;
@@ -128,7 +128,7 @@ static int __must_check smsc75xx_write_reg(struct usbnet *dev, u32 index,
 
        if (unlikely(ret < 0))
                netdev_warn(dev->net,
-                       "Failed to write register index 0x%08x", index);
+                       "Failed to write reg index 0x%08x: %d", index, ret);
 
        kfree(buf);
 
@@ -171,7 +171,7 @@ static int smsc75xx_mdio_read(struct net_device *netdev, int phy_id, int idx)
        idx &= dev->mii.reg_num_mask;
        addr = ((phy_id << MII_ACCESS_PHY_ADDR_SHIFT) & MII_ACCESS_PHY_ADDR)
                | ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR)
-               | MII_ACCESS_READ;
+               | MII_ACCESS_READ | MII_ACCESS_BUSY;
        ret = smsc75xx_write_reg(dev, MII_ACCESS, addr);
        check_warn_goto_done(ret, "Error writing MII_ACCESS");
 
@@ -210,7 +210,7 @@ static void smsc75xx_mdio_write(struct net_device *netdev, int phy_id, int idx,
        idx &= dev->mii.reg_num_mask;
        addr = ((phy_id << MII_ACCESS_PHY_ADDR_SHIFT) & MII_ACCESS_PHY_ADDR)
                | ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR)
-               | MII_ACCESS_WRITE;
+               | MII_ACCESS_WRITE | MII_ACCESS_BUSY;
        ret = smsc75xx_write_reg(dev, MII_ACCESS, addr);
        check_warn_goto_done(ret, "Error writing MII_ACCESS");
 
@@ -508,9 +508,10 @@ static int smsc75xx_link_reset(struct usbnet *dev)
        u16 lcladv, rmtadv;
        int ret;
 
-       /* clear interrupt status */
+       /* read and write to clear phy interrupt status */
        ret = smsc75xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC);
        check_warn_return(ret, "Error reading PHY_INT_SRC");
+       smsc75xx_mdio_write(dev->net, mii->phy_id, PHY_INT_SRC, 0xffff);
 
        ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL);
        check_warn_return(ret, "Error writing INT_STS");
@@ -643,7 +644,7 @@ static int smsc75xx_set_mac_address(struct usbnet *dev)
 
 static int smsc75xx_phy_initialize(struct usbnet *dev)
 {
-       int bmcr, timeout = 0;
+       int bmcr, ret, timeout = 0;
 
        /* Initialize MII structure */
        dev->mii.dev = dev->net;
@@ -651,6 +652,7 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
        dev->mii.mdio_write = smsc75xx_mdio_write;
        dev->mii.phy_id_mask = 0x1f;
        dev->mii.reg_num_mask = 0x1f;
+       dev->mii.supports_gmii = 1;
        dev->mii.phy_id = SMSC75XX_INTERNAL_PHY_ID;
 
        /* reset phy and wait for reset to complete */
@@ -661,7 +663,7 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
                bmcr = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR);
                check_warn_return(bmcr, "Error reading MII_BMCR");
                timeout++;
-       } while ((bmcr & MII_BMCR) && (timeout < 100));
+       } while ((bmcr & BMCR_RESET) && (timeout < 100));
 
        if (timeout >= 100) {
                netdev_warn(dev->net, "timeout on PHY Reset");
@@ -671,10 +673,13 @@ static int smsc75xx_phy_initialize(struct usbnet *dev)
        smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
                ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP |
                ADVERTISE_PAUSE_ASYM);
+       smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000,
+               ADVERTISE_1000FULL);
 
-       /* read to clear */
-       smsc75xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC);
-       check_warn_return(bmcr, "Error reading PHY_INT_SRC");
+       /* read and write to clear phy interrupt status */
+       ret = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC);
+       check_warn_return(ret, "Error reading PHY_INT_SRC");
+       smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_SRC, 0xffff);
 
        smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK,
                PHY_INT_MASK_DEFAULT);
@@ -946,6 +951,14 @@ static int smsc75xx_reset(struct usbnet *dev)
        ret = smsc75xx_write_reg(dev, INT_EP_CTL, buf);
        check_warn_return(ret, "Failed to write INT_EP_CTL: %d", ret);
 
+       /* allow mac to detect speed and duplex from phy */
+       ret = smsc75xx_read_reg(dev, MAC_CR, &buf);
+       check_warn_return(ret, "Failed to read MAC_CR: %d", ret);
+
+       buf |= (MAC_CR_ADD | MAC_CR_ASD);
+       ret = smsc75xx_write_reg(dev, MAC_CR, buf);
+       check_warn_return(ret, "Failed to write MAC_CR: %d", ret);
+
        ret = smsc75xx_read_reg(dev, MAC_TX, &buf);
        check_warn_return(ret, "Failed to read MAC_TX: %d", ret);
 
@@ -1051,6 +1064,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
        dev->net->ethtool_ops = &smsc75xx_ethtool_ops;
        dev->net->flags |= IFF_MULTICAST;
        dev->net->hard_header_len += SMSC75XX_TX_OVERHEAD;
+       dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
        return 0;
 }
 
@@ -1211,7 +1225,7 @@ static const struct driver_info smsc75xx_info = {
        .rx_fixup       = smsc75xx_rx_fixup,
        .tx_fixup       = smsc75xx_tx_fixup,
        .status         = smsc75xx_status,
-       .flags          = FLAG_ETHER | FLAG_SEND_ZLP,
+       .flags          = FLAG_ETHER | FLAG_SEND_ZLP | FLAG_LINK_INTR,
 };
 
 static const struct usb_device_id products[] = {
index 5f19f84d3494696254793320cda6a1f132a0e6e1..94ae66999f592a4a8a1c45fdc24505050271d086 100644 (file)
@@ -1017,6 +1017,7 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
        dev->net->ethtool_ops = &smsc95xx_ethtool_ops;
        dev->net->flags |= IFF_MULTICAST;
        dev->net->hard_header_len += SMSC95XX_TX_OVERHEAD_CSUM;
+       dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
        return 0;
 }
 
@@ -1191,7 +1192,7 @@ static const struct driver_info smsc95xx_info = {
        .rx_fixup       = smsc95xx_rx_fixup,
        .tx_fixup       = smsc95xx_tx_fixup,
        .status         = smsc95xx_status,
-       .flags          = FLAG_ETHER | FLAG_SEND_ZLP,
+       .flags          = FLAG_ETHER | FLAG_SEND_ZLP | FLAG_LINK_INTR,
 };
 
 static const struct usb_device_id products[] = {
index b7b3f5b0d40654c3c50b18ae56c969c03382c71c..2d927fb4adf4ea6805b2aeb02d06c8cb5108f496 100644 (file)
@@ -210,6 +210,7 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf)
                } else {
                        usb_fill_int_urb(dev->interrupt, dev->udev, pipe,
                                buf, maxp, intr_complete, dev, period);
+                       dev->interrupt->transfer_flags |= URB_FREE_BUFFER;
                        dev_dbg(&intf->dev,
                                "status ep%din, %d bytes period %d\n",
                                usb_pipeendpoint(pipe), maxp, period);
@@ -1443,7 +1444,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 
        status = register_netdev (net);
        if (status)
-               goto out3;
+               goto out4;
        netif_info(dev, probe, dev->net,
                   "register '%s' at usb-%s-%s, %s, %pM\n",
                   udev->dev.driver->name,
@@ -1461,6 +1462,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 
        return 0;
 
+out4:
+       usb_free_urb(dev->interrupt);
 out3:
        if (info->unbind)
                info->unbind (dev, udev);
index 4de2760c593762634f0925cf9ccb1ab9c7f2c111..af8acc85f4bbd15bf01e939db20932845d7b8312 100644 (file)
@@ -626,16 +626,15 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
        /* This can happen with OOM and indirect buffers. */
        if (unlikely(capacity < 0)) {
                if (likely(capacity == -ENOMEM)) {
-                       if (net_ratelimit()) {
+                       if (net_ratelimit())
                                dev_warn(&dev->dev,
                                         "TX queue failure: out of memory\n");
-                       } else {
+               } else {
                        dev->stats.tx_fifo_errors++;
                        if (net_ratelimit())
                                dev_warn(&dev->dev,
                                         "Unexpected TX queue failure: %d\n",
                                         capacity);
-                       }
                }
                dev->stats.tx_dropped++;
                kfree_skb(skb);
index ebb9f24eefb5e568f90b859e2b3e47028a868a70..1a623183cbe54d63f8392f924953b127ded83c1f 100644 (file)
@@ -2483,6 +2483,7 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                pr_err("Control memory remap failed\n");
                pci_release_regions(pdev);
                pci_disable_device(pdev);
+               iounmap(card->mem);
                kfree(card);
                return -ENODEV;
        }
index 8faa129da5a00b60c74dd255ae1692effb3d329d..aec33cc207fdbba47e67a6aa28a52ac19f4bfede 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/nl80211.h>
 #include <linux/platform_device.h>
 #include <linux/etherdevice.h>
+#include <linux/export.h>
 #include <ar231x_platform.h>
 #include "ath5k.h"
 #include "debug.h"
@@ -119,7 +120,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
        if (res == NULL) {
                dev_err(&pdev->dev, "no IRQ resource found\n");
                ret = -ENXIO;
-               goto err_out;
+               goto err_iounmap;
        }
 
        irq = res->start;
@@ -128,7 +129,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
        if (hw == NULL) {
                dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
                ret = -ENOMEM;
-               goto err_out;
+               goto err_iounmap;
        }
 
        ah = hw->priv;
@@ -185,6 +186,8 @@ static int ath_ahb_probe(struct platform_device *pdev)
  err_free_hw:
        ieee80211_free_hw(hw);
        platform_set_drvdata(pdev, NULL);
+ err_iounmap:
+        iounmap(mem);
  err_out:
        return ret;
 }
@@ -217,6 +220,7 @@ static int ath_ahb_remove(struct platform_device *pdev)
        }
 
        ath5k_deinit_ah(ah);
+       iounmap(ah->iobase);
        platform_set_drvdata(pdev, NULL);
        ieee80211_free_hw(hw);
 
index d7d8e91991408a7a5c18fea055a4f17f1a0741cf..aba088005b2274a43873f277993113ec59cca45e 100644 (file)
@@ -869,7 +869,7 @@ static int ar5008_hw_process_ini(struct ath_hw *ah,
        ar5008_hw_set_channel_regs(ah, chan);
        ar5008_hw_init_chain_masks(ah);
        ath9k_olc_init(ah);
-       ath9k_hw_apply_txpower(ah, chan);
+       ath9k_hw_apply_txpower(ah, chan, false);
 
        /* Write analog registers */
        if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
index 59647a3ceb7f98ea568d34e16248c80471290f78..3d400e8d653544ffd16bc3db8710f075598dce2f 100644 (file)
@@ -54,7 +54,7 @@ void ar9003_paprd_enable(struct ath_hw *ah, bool val)
 
        if (val) {
                ah->paprd_table_write_done = true;
-               ath9k_hw_apply_txpower(ah, chan);
+               ath9k_hw_apply_txpower(ah, chan, false);
        }
 
        REG_RMW_FIELD(ah, AR_PHY_PAPRD_CTRL0_B0,
index bc992b237ae5a47a42f53db6b59a5cd5a59cf94d..deb6cfb2959a7344886bb7e10799feb3a5106de0 100644 (file)
@@ -694,7 +694,7 @@ static int ar9003_hw_process_ini(struct ath_hw *ah,
        ar9003_hw_override_ini(ah);
        ar9003_hw_set_channel_regs(ah, chan);
        ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
-       ath9k_hw_apply_txpower(ah, chan);
+       ath9k_hw_apply_txpower(ah, chan, false);
 
        if (AR_SREV_9462(ah)) {
                if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
index f272236d8053d58201b973b6397b11362a112bb1..b34e8b2990b127a359b88991af37687307fbcf60 100644 (file)
@@ -824,6 +824,8 @@ static void ath9k_hw_ar9287_set_txpower(struct ath_hw *ah,
                        regulatory->max_power_level = ratesArray[i];
        }
 
+       ath9k_hw_update_regulatory_maxpower(ah);
+
        if (test)
                return;
 
index 6c69e4e8b1cb7ca85b6710aecb8fbe3cba1e10c9..fa84e37bf091546035c6638130892a5bbe559c66 100644 (file)
@@ -1454,7 +1454,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
                return false;
        }
        ath9k_hw_set_clockrate(ah);
-       ath9k_hw_apply_txpower(ah, chan);
+       ath9k_hw_apply_txpower(ah, chan, false);
        ath9k_hw_rfbus_done(ah);
 
        if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
@@ -2652,7 +2652,8 @@ static int get_antenna_gain(struct ath_hw *ah, struct ath9k_channel *chan)
        return ah->eep_ops->get_eeprom(ah, gain_param);
 }
 
-void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan)
+void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan,
+                           bool test)
 {
        struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
        struct ieee80211_channel *channel;
@@ -2673,7 +2674,7 @@ void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan)
 
        ah->eep_ops->set_txpower(ah, chan,
                                 ath9k_regd_get_ctl(reg, chan),
-                                ant_reduction, new_pwr, false);
+                                ant_reduction, new_pwr, test);
 }
 
 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
@@ -2686,7 +2687,7 @@ void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
        if (test)
                channel->max_power = MAX_RATE_POWER / 2;
 
-       ath9k_hw_apply_txpower(ah, chan);
+       ath9k_hw_apply_txpower(ah, chan, test);
 
        if (test)
                channel->max_power = DIV_ROUND_UP(reg->max_power_level, 2);
index aa1680a0c7fdbeccd4ba36a7be8733b5a1a0ed4c..e88f182ff45c1b36b88cd8eda93af3d335b0a0e2 100644 (file)
@@ -985,7 +985,8 @@ void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len);
 /* PHY */
 void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled,
                                   u32 *coef_mantissa, u32 *coef_exponent);
-void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan);
+void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan,
+                           bool test);
 
 /*
  * Code Specific to AR5008, AR9001 or AR9002,
index 2504ab00558971d15f77569593e7d8756ede1761..798ea57252b403d11823aaec9582e6df0122b5a3 100644 (file)
@@ -1548,6 +1548,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
        struct ath_hw *ah = sc->sc_ah;
        struct ath_common *common = ath9k_hw_common(ah);
        struct ieee80211_conf *conf = &hw->conf;
+       bool reset_channel = false;
 
        ath9k_ps_wakeup(sc);
        mutex_lock(&sc->mutex);
@@ -1556,6 +1557,12 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
                sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
                if (sc->ps_idle)
                        ath_cancel_work(sc);
+               else
+                       /*
+                        * The chip needs a reset to properly wake up from
+                        * full sleep
+                        */
+                       reset_channel = ah->chip_fullsleep;
        }
 
        /*
@@ -1584,7 +1591,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
                }
        }
 
-       if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
+       if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
                struct ieee80211_channel *curchan = hw->conf.channel;
                int pos = curchan->hw_value;
                int old_pos = -1;
index 834e6bc45e8b13eb2b5175043287ee5d381f622e..23eaa1b26ebe5ca9a1a242ea4de5e9fa6508b02c 100644 (file)
@@ -1820,6 +1820,7 @@ static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
        struct ath_frame_info *fi = get_frame_info(skb);
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
        struct ath_buf *bf;
+       int fragno;
        u16 seqno;
 
        bf = ath_tx_get_buffer(sc);
@@ -1831,9 +1832,16 @@ static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
        ATH_TXBUF_RESET(bf);
 
        if (tid) {
+               fragno = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
                seqno = tid->seq_next;
                hdr->seq_ctrl = cpu_to_le16(tid->seq_next << IEEE80211_SEQ_SEQ_SHIFT);
-               INCR(tid->seq_next, IEEE80211_SEQ_MAX);
+
+               if (fragno)
+                       hdr->seq_ctrl |= cpu_to_le16(fragno);
+
+               if (!ieee80211_has_morefrags(hdr->frame_control))
+                       INCR(tid->seq_next, IEEE80211_SEQ_MAX);
+
                bf->bf_state.seqno = seqno;
        }
 
index c79e6638c88d599e6efdcd048c9145b869d6211a..e4d6dc2e37d12479ab2bdef3560d8f700e9e0d13 100644 (file)
@@ -4827,8 +4827,14 @@ static int b43_op_start(struct ieee80211_hw *hw)
  out_mutex_unlock:
        mutex_unlock(&wl->mutex);
 
-       /* reload configuration */
-       b43_op_config(hw, ~0);
+       /*
+        * Configuration may have been overwritten during initialization.
+        * Reload the configuration, but only if initialization was
+        * successful. Reloading the configuration after a failed init
+        * may hang the system.
+        */
+       if (!err)
+               b43_op_config(hw, ~0);
 
        return err;
 }
index 4688904908ec464b3b9895504e8566eb61d6c5e7..758c115b556ebbcde32b669ccd563c12969b01e7 100644 (file)
@@ -108,9 +108,15 @@ static inline int brcmf_sdioh_f0_write_byte(struct brcmf_sdio_dev *sdiodev,
                        sdio_release_host(sdfunc);
                }
        } else if (regaddr == SDIO_CCCR_ABORT) {
+               sdfunc = kmemdup(sdiodev->func[0], sizeof(struct sdio_func),
+                                GFP_KERNEL);
+               if (!sdfunc)
+                       return -ENOMEM;
+               sdfunc->num = 0;
                sdio_claim_host(sdfunc);
                sdio_writeb(sdfunc, *byte, regaddr, &err_ret);
                sdio_release_host(sdfunc);
+               kfree(sdfunc);
        } else if (regaddr < 0xF0) {
                brcmf_dbg(ERROR, "F0 Wr:0x%02x: write disallowed\n", regaddr);
                err_ret = -EPERM;
@@ -486,7 +492,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
                        kfree(bus_if);
                        return -ENOMEM;
                }
-               sdiodev->func[0] = func->card->sdio_func[0];
+               sdiodev->func[0] = func;
                sdiodev->func[1] = func;
                sdiodev->bus_if = bus_if;
                bus_if->bus_priv.sdio = sdiodev;
index 2bf5dda292919868a90a9dad3722f0a4991f7024..eb3829b03cd37cf587edab5e4e12aa839e6635e0 100644 (file)
@@ -574,6 +574,8 @@ struct brcmf_sdio {
 
        struct task_struct *dpc_tsk;
        struct completion dpc_wait;
+       struct list_head dpc_tsklst;
+       spinlock_t dpc_tl_lock;
 
        struct semaphore sdsem;
 
@@ -2594,29 +2596,58 @@ clkwait:
        return resched;
 }
 
+static inline void brcmf_sdbrcm_adddpctsk(struct brcmf_sdio *bus)
+{
+       struct list_head *new_hd;
+       unsigned long flags;
+
+       if (in_interrupt())
+               new_hd = kzalloc(sizeof(struct list_head), GFP_ATOMIC);
+       else
+               new_hd = kzalloc(sizeof(struct list_head), GFP_KERNEL);
+       if (new_hd == NULL)
+               return;
+
+       spin_lock_irqsave(&bus->dpc_tl_lock, flags);
+       list_add_tail(new_hd, &bus->dpc_tsklst);
+       spin_unlock_irqrestore(&bus->dpc_tl_lock, flags);
+}
+
 static int brcmf_sdbrcm_dpc_thread(void *data)
 {
        struct brcmf_sdio *bus = (struct brcmf_sdio *) data;
+       struct list_head *cur_hd, *tmp_hd;
+       unsigned long flags;
 
        allow_signal(SIGTERM);
        /* Run until signal received */
        while (1) {
                if (kthread_should_stop())
                        break;
-               if (!wait_for_completion_interruptible(&bus->dpc_wait)) {
-                       /* Call bus dpc unless it indicated down
-                       (then clean stop) */
-                       if (bus->sdiodev->bus_if->state != BRCMF_BUS_DOWN) {
-                               if (brcmf_sdbrcm_dpc(bus))
-                                       complete(&bus->dpc_wait);
-                       } else {
+
+               if (list_empty(&bus->dpc_tsklst))
+                       if (wait_for_completion_interruptible(&bus->dpc_wait))
+                               break;
+
+               spin_lock_irqsave(&bus->dpc_tl_lock, flags);
+               list_for_each_safe(cur_hd, tmp_hd, &bus->dpc_tsklst) {
+                       spin_unlock_irqrestore(&bus->dpc_tl_lock, flags);
+
+                       if (bus->sdiodev->bus_if->state == BRCMF_BUS_DOWN) {
                                /* after stopping the bus, exit thread */
                                brcmf_sdbrcm_bus_stop(bus->sdiodev->dev);
                                bus->dpc_tsk = NULL;
                                break;
                        }
-               } else
-                       break;
+
+                       if (brcmf_sdbrcm_dpc(bus))
+                               brcmf_sdbrcm_adddpctsk(bus);
+
+                       spin_lock_irqsave(&bus->dpc_tl_lock, flags);
+                       list_del(cur_hd);
+                       kfree(cur_hd);
+               }
+               spin_unlock_irqrestore(&bus->dpc_tl_lock, flags);
        }
        return 0;
 }
@@ -2669,8 +2700,10 @@ static int brcmf_sdbrcm_bus_txdata(struct device *dev, struct sk_buff *pkt)
        /* Schedule DPC if needed to send queued packet(s) */
        if (!bus->dpc_sched) {
                bus->dpc_sched = true;
-               if (bus->dpc_tsk)
+               if (bus->dpc_tsk) {
+                       brcmf_sdbrcm_adddpctsk(bus);
                        complete(&bus->dpc_wait);
+               }
        }
 
        return ret;
@@ -3514,8 +3547,10 @@ void brcmf_sdbrcm_isr(void *arg)
                brcmf_dbg(ERROR, "isr w/o interrupt configured!\n");
 
        bus->dpc_sched = true;
-       if (bus->dpc_tsk)
+       if (bus->dpc_tsk) {
+               brcmf_sdbrcm_adddpctsk(bus);
                complete(&bus->dpc_wait);
+       }
 }
 
 static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus)
@@ -3559,8 +3594,10 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus)
                                bus->ipend = true;
 
                                bus->dpc_sched = true;
-                               if (bus->dpc_tsk)
+                               if (bus->dpc_tsk) {
+                                       brcmf_sdbrcm_adddpctsk(bus);
                                        complete(&bus->dpc_wait);
+                               }
                        }
                }
 
@@ -3897,6 +3934,8 @@ void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev)
        }
        /* Initialize DPC thread */
        init_completion(&bus->dpc_wait);
+       INIT_LIST_HEAD(&bus->dpc_tsklst);
+       spin_lock_init(&bus->dpc_tl_lock);
        bus->dpc_tsk = kthread_run(brcmf_sdbrcm_dpc_thread,
                                   bus, "brcmf_dpc");
        if (IS_ERR(bus->dpc_tsk)) {
index 231ddf4a674f8523e850d50ea73160f5d0b8d069..b4d92792c5028de56ef78b5bbdd1ef3c9c0c317b 100644 (file)
@@ -847,8 +847,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
         */
        if (!(txs->status & TX_STATUS_AMPDU)
            && (txs->status & TX_STATUS_INTERMEDIATE)) {
-               wiphy_err(wlc->wiphy, "%s: INTERMEDIATE but not AMPDU\n",
-                         __func__);
+               BCMMSG(wlc->wiphy, "INTERMEDIATE but not AMPDU\n");
                return false;
        }
 
@@ -7614,6 +7613,7 @@ brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh,
 {
        int len_mpdu;
        struct ieee80211_rx_status rx_status;
+       struct ieee80211_hdr *hdr;
 
        memset(&rx_status, 0, sizeof(rx_status));
        prep_mac80211_status(wlc, rxh, p, &rx_status);
@@ -7623,6 +7623,13 @@ brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh,
        skb_pull(p, D11_PHY_HDR_LEN);
        __skb_trim(p, len_mpdu);
 
+       /* unmute transmit */
+       if (wlc->hw->suspended_fifos) {
+               hdr = (struct ieee80211_hdr *)p->data;
+               if (ieee80211_is_beacon(hdr->frame_control))
+                       brcms_b_mute(wlc->hw, false);
+       }
+
        memcpy(IEEE80211_SKB_RXCB(p), &rx_status, sizeof(rx_status));
        ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p);
 }
index 2b022571a8595a5dd41c89bdd515d0f1fd0dc70b..1779db3aa2b00c3a11bbcad080dadf8f0da0984c 100644 (file)
@@ -2191,6 +2191,7 @@ static int __ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd)
 {
        int rc = 0;
        unsigned long flags;
+       unsigned long now, end;
 
        spin_lock_irqsave(&priv->lock, flags);
        if (priv->status & STATUS_HCMD_ACTIVE) {
@@ -2232,10 +2233,20 @@ static int __ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd)
        }
        spin_unlock_irqrestore(&priv->lock, flags);
 
+       now = jiffies;
+       end = now + HOST_COMPLETE_TIMEOUT;
+again:
        rc = wait_event_interruptible_timeout(priv->wait_command_queue,
                                              !(priv->
                                                status & STATUS_HCMD_ACTIVE),
-                                             HOST_COMPLETE_TIMEOUT);
+                                             end - now);
+       if (rc < 0) {
+               now = jiffies;
+               if (time_before(now, end))
+                       goto again;
+               rc = 0;
+       }
+
        if (rc == 0) {
                spin_lock_irqsave(&priv->lock, flags);
                if (priv->status & STATUS_HCMD_ACTIVE) {
index 5b0d888f746bbc27ea492d6351458476aabdbd4d..8d80e233bc7a73aec74b267edb61bd191bdf5eb2 100644 (file)
@@ -46,8 +46,8 @@
 #include "iwl-prph.h"
 
 /* Highest firmware API version supported */
-#define IWL1000_UCODE_API_MAX 6
-#define IWL100_UCODE_API_MAX 6
+#define IWL1000_UCODE_API_MAX 5
+#define IWL100_UCODE_API_MAX 5
 
 /* Oldest version we won't warn about */
 #define IWL1000_UCODE_API_OK 5
@@ -226,5 +226,5 @@ const struct iwl_cfg iwl100_bg_cfg = {
        IWL_DEVICE_100,
 };
 
-MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_MAX));
-MODULE_FIRMWARE(IWL100_MODULE_FIRMWARE(IWL100_UCODE_API_MAX));
+MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_OK));
+MODULE_FIRMWARE(IWL100_MODULE_FIRMWARE(IWL100_UCODE_API_OK));
index 5635b9e2c69e6b4e27e9337d88f97095ac71029d..ea108622e0bd0adf4a961be817378df86664e1c1 100644 (file)
 #define IWL135_UCODE_API_MAX 6
 
 /* Oldest version we won't warn about */
-#define IWL2030_UCODE_API_OK 5
-#define IWL2000_UCODE_API_OK 5
-#define IWL105_UCODE_API_OK 5
-#define IWL135_UCODE_API_OK 5
+#define IWL2030_UCODE_API_OK 6
+#define IWL2000_UCODE_API_OK 6
+#define IWL105_UCODE_API_OK 6
+#define IWL135_UCODE_API_OK 6
 
 /* Lowest firmware API version supported */
 #define IWL2030_UCODE_API_MIN 5
@@ -328,7 +328,7 @@ const struct iwl_cfg iwl135_bgn_cfg = {
        .ht_params = &iwl2000_ht_params,
 };
 
-MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX));
-MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX));
-MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX));
-MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_MAX));
+MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_OK));
+MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_OK));
+MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_OK));
+MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_OK));
index a805e97b89af85cb1a066c156cc1899dde7034c7..de0920c74cdd2369b7a528de29536163aba01f50 100644 (file)
 #define IWL5000_UCODE_API_MAX 5
 #define IWL5150_UCODE_API_MAX 2
 
+/* Oldest version we won't warn about */
+#define IWL5000_UCODE_API_OK 5
+#define IWL5150_UCODE_API_OK 2
+
 /* Lowest firmware API version supported */
 #define IWL5000_UCODE_API_MIN 1
 #define IWL5150_UCODE_API_MIN 1
@@ -326,6 +330,7 @@ static const struct iwl_ht_params iwl5000_ht_params = {
 #define IWL_DEVICE_5000                                                \
        .fw_name_pre = IWL5000_FW_PRE,                          \
        .ucode_api_max = IWL5000_UCODE_API_MAX,                 \
+       .ucode_api_ok = IWL5000_UCODE_API_OK,                   \
        .ucode_api_min = IWL5000_UCODE_API_MIN,                 \
        .max_inst_size = IWLAGN_RTC_INST_SIZE,                  \
        .max_data_size = IWLAGN_RTC_DATA_SIZE,                  \
@@ -371,6 +376,7 @@ const struct iwl_cfg iwl5350_agn_cfg = {
        .name = "Intel(R) WiMAX/WiFi Link 5350 AGN",
        .fw_name_pre = IWL5000_FW_PRE,
        .ucode_api_max = IWL5000_UCODE_API_MAX,
+       .ucode_api_ok = IWL5000_UCODE_API_OK,
        .ucode_api_min = IWL5000_UCODE_API_MIN,
        .max_inst_size = IWLAGN_RTC_INST_SIZE,
        .max_data_size = IWLAGN_RTC_DATA_SIZE,
@@ -386,6 +392,7 @@ const struct iwl_cfg iwl5350_agn_cfg = {
 #define IWL_DEVICE_5150                                                \
        .fw_name_pre = IWL5150_FW_PRE,                          \
        .ucode_api_max = IWL5150_UCODE_API_MAX,                 \
+       .ucode_api_ok = IWL5150_UCODE_API_OK,                   \
        .ucode_api_min = IWL5150_UCODE_API_MIN,                 \
        .max_inst_size = IWLAGN_RTC_INST_SIZE,                  \
        .max_data_size = IWLAGN_RTC_DATA_SIZE,                  \
@@ -409,5 +416,5 @@ const struct iwl_cfg iwl5150_abg_cfg = {
        IWL_DEVICE_5150,
 };
 
-MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
-MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE(IWL5150_UCODE_API_MAX));
+MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_OK));
+MODULE_FIRMWARE(IWL5150_MODULE_FIRMWARE(IWL5150_UCODE_API_OK));
index 64060cd738b5d90b069a8289eba923842365a023..f0c91505a7f775ac0e8cb819dca0be1bfc983094 100644 (file)
@@ -53,6 +53,8 @@
 /* Oldest version we won't warn about */
 #define IWL6000_UCODE_API_OK 4
 #define IWL6000G2_UCODE_API_OK 5
+#define IWL6050_UCODE_API_OK 5
+#define IWL6000G2B_UCODE_API_OK 6
 
 /* Lowest firmware API version supported */
 #define IWL6000_UCODE_API_MIN 4
@@ -388,7 +390,7 @@ const struct iwl_cfg iwl6005_2agn_mow2_cfg = {
 #define IWL_DEVICE_6030                                                \
        .fw_name_pre = IWL6030_FW_PRE,                          \
        .ucode_api_max = IWL6000G2_UCODE_API_MAX,               \
-       .ucode_api_ok = IWL6000G2_UCODE_API_OK,                 \
+       .ucode_api_ok = IWL6000G2B_UCODE_API_OK,                \
        .ucode_api_min = IWL6000G2_UCODE_API_MIN,               \
        .max_inst_size = IWL60_RTC_INST_SIZE,                   \
        .max_data_size = IWL60_RTC_DATA_SIZE,                   \
@@ -557,6 +559,6 @@ const struct iwl_cfg iwl6000_3agn_cfg = {
 };
 
 MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_OK));
-MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX));
-MODULE_FIRMWARE(IWL6005_MODULE_FIRMWARE(IWL6000G2_UCODE_API_MAX));
-MODULE_FIRMWARE(IWL6030_MODULE_FIRMWARE(IWL6000G2_UCODE_API_MAX));
+MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_OK));
+MODULE_FIRMWARE(IWL6005_MODULE_FIRMWARE(IWL6000G2_UCODE_API_OK));
+MODULE_FIRMWARE(IWL6030_MODULE_FIRMWARE(IWL6000G2B_UCODE_API_OK));
index f1226dbf789d796c7c366fe102f410eb32537f7f..2a9a16f901c3f940dd87f4865bcab51a53a7a48d 100644 (file)
@@ -863,7 +863,6 @@ static void iwl_bg_run_time_calib_work(struct work_struct *work)
 
 void iwlagn_prepare_restart(struct iwl_priv *priv)
 {
-       struct iwl_rxon_context *ctx;
        bool bt_full_concurrent;
        u8 bt_ci_compliance;
        u8 bt_load;
@@ -872,8 +871,6 @@ void iwlagn_prepare_restart(struct iwl_priv *priv)
 
        lockdep_assert_held(&priv->mutex);
 
-       for_each_context(priv, ctx)
-               ctx->vif = NULL;
        priv->is_open = 0;
 
        /*
index 90208094b8ebdb472fcc9078ca605c83f37d9197..74bce97a860004b3fc8e921df2afef593379ebfb 100644 (file)
  * (see struct iwl_tfd_frame).  These 16 pointer registers are offset by 0x04
  * bytes from one another.  Each TFD circular buffer in DRAM must be 256-byte
  * aligned (address bits 0-7 must be 0).
+ * Later devices have 20 (5000 series) or 30 (higher) queues, but the registers
+ * for them are in different places.
  *
  * Bit fields in each pointer register:
  *  27-0: TFD CB physical base address [35:8], must be 256-byte aligned
  */
-#define FH_MEM_CBBC_LOWER_BOUND          (FH_MEM_LOWER_BOUND + 0x9D0)
-#define FH_MEM_CBBC_UPPER_BOUND          (FH_MEM_LOWER_BOUND + 0xA10)
-
-/* Find TFD CB base pointer for given queue (range 0-15). */
-#define FH_MEM_CBBC_QUEUE(x)  (FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
+#define FH_MEM_CBBC_0_15_LOWER_BOUND           (FH_MEM_LOWER_BOUND + 0x9D0)
+#define FH_MEM_CBBC_0_15_UPPER_BOUND           (FH_MEM_LOWER_BOUND + 0xA10)
+#define FH_MEM_CBBC_16_19_LOWER_BOUND          (FH_MEM_LOWER_BOUND + 0xBF0)
+#define FH_MEM_CBBC_16_19_UPPER_BOUND          (FH_MEM_LOWER_BOUND + 0xC00)
+#define FH_MEM_CBBC_20_31_LOWER_BOUND          (FH_MEM_LOWER_BOUND + 0xB20)
+#define FH_MEM_CBBC_20_31_UPPER_BOUND          (FH_MEM_LOWER_BOUND + 0xB80)
+
+/* Find TFD CB base pointer for given queue */
+static inline unsigned int FH_MEM_CBBC_QUEUE(unsigned int chnl)
+{
+       if (chnl < 16)
+               return FH_MEM_CBBC_0_15_LOWER_BOUND + 4 * chnl;
+       if (chnl < 20)
+               return FH_MEM_CBBC_16_19_LOWER_BOUND + 4 * (chnl - 16);
+       WARN_ON_ONCE(chnl >= 32);
+       return FH_MEM_CBBC_20_31_LOWER_BOUND + 4 * (chnl - 20);
+}
 
 
 /**
index b6805f8e9a014553cca088e4992aa09c421897f7..c24a7134a6f9a3729d81350ea699246744805884 100644 (file)
@@ -1244,6 +1244,7 @@ static int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
        struct iwl_rxon_context *tmp, *ctx = NULL;
        int err;
        enum nl80211_iftype viftype = ieee80211_vif_type_p2p(vif);
+       bool reset = false;
 
        IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n",
                           viftype, vif->addr);
@@ -1265,6 +1266,13 @@ static int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
                        tmp->interface_modes | tmp->exclusive_interface_modes;
 
                if (tmp->vif) {
+                       /* On reset we need to add the same interface again */
+                       if (tmp->vif == vif) {
+                               reset = true;
+                               ctx = tmp;
+                               break;
+                       }
+
                        /* check if this busy context is exclusive */
                        if (tmp->exclusive_interface_modes &
                                                BIT(tmp->vif->type)) {
@@ -1291,7 +1299,7 @@ static int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
        ctx->vif = vif;
 
        err = iwl_setup_interface(priv, ctx);
-       if (!err)
+       if (!err || reset)
                goto out;
 
        ctx->vif = NULL;
index 75dc20bd965b4d80715881b5657d099c75274854..3b1069290fa9a9cf646a2f04325d6c1862b70a7a 100644 (file)
 #define SCD_AIT                        (SCD_BASE + 0x0c)
 #define SCD_TXFACT             (SCD_BASE + 0x10)
 #define SCD_ACTIVE             (SCD_BASE + 0x14)
-#define SCD_QUEUE_WRPTR(x)     (SCD_BASE + 0x18 + (x) * 4)
-#define SCD_QUEUE_RDPTR(x)     (SCD_BASE + 0x68 + (x) * 4)
 #define SCD_QUEUECHAIN_SEL     (SCD_BASE + 0xe8)
 #define SCD_AGGR_SEL           (SCD_BASE + 0x248)
 #define SCD_INTERRUPT_MASK     (SCD_BASE + 0x108)
-#define SCD_QUEUE_STATUS_BITS(x)       (SCD_BASE + 0x10c + (x) * 4)
+
+static inline unsigned int SCD_QUEUE_WRPTR(unsigned int chnl)
+{
+       if (chnl < 20)
+               return SCD_BASE + 0x18 + chnl * 4;
+       WARN_ON_ONCE(chnl >= 32);
+       return SCD_BASE + 0x284 + (chnl - 20) * 4;
+}
+
+static inline unsigned int SCD_QUEUE_RDPTR(unsigned int chnl)
+{
+       if (chnl < 20)
+               return SCD_BASE + 0x68 + chnl * 4;
+       WARN_ON_ONCE(chnl >= 32);
+       return SCD_BASE + 0x2B4 + (chnl - 20) * 4;
+}
+
+static inline unsigned int SCD_QUEUE_STATUS_BITS(unsigned int chnl)
+{
+       if (chnl < 20)
+               return SCD_BASE + 0x10c + chnl * 4;
+       WARN_ON_ONCE(chnl >= 32);
+       return SCD_BASE + 0x384 + (chnl - 20) * 4;
+}
 
 /*********************** END TX SCHEDULER *************************************/
 
index 3fa1ecebadfd33e3d15e63e1f79de46d851a7ab3..2fa879b015b6817d24e558395c0f74ef638cbc96 100644 (file)
@@ -103,7 +103,7 @@ static const u32 cipher_suites[] = {
  * Convert NL80211's auth_type to the one from Libertas, see chapter 5.9.1
  * in the firmware spec
  */
-static u8 lbs_auth_to_authtype(enum nl80211_auth_type auth_type)
+static int lbs_auth_to_authtype(enum nl80211_auth_type auth_type)
 {
        int ret = -ENOTSUPP;
 
@@ -1411,7 +1411,12 @@ static int lbs_cfg_connect(struct wiphy *wiphy, struct net_device *dev,
                goto done;
        }
 
-       lbs_set_authtype(priv, sme);
+       ret = lbs_set_authtype(priv, sme);
+       if (ret == -ENOTSUPP) {
+               wiphy_err(wiphy, "unsupported authtype 0x%x\n", sme->auth_type);
+               goto done;
+       }
+
        lbs_set_radio(priv, preamble, 1);
 
        /* Do the actual association */
index 445ff21772e2ec948948e6338525663b9b34f6eb..2f218f9a3fd3efea52e8038345a326bfb7341243 100644 (file)
 #define PCIE_HOST_INT_STATUS_MASK                      0xC3C
 #define PCIE_SCRATCH_2_REG                             0xC40
 #define PCIE_SCRATCH_3_REG                             0xC44
-#define PCIE_SCRATCH_4_REG                             0xCC0
-#define PCIE_SCRATCH_5_REG                             0xCC4
-#define PCIE_SCRATCH_6_REG                             0xCC8
-#define PCIE_SCRATCH_7_REG                             0xCCC
-#define PCIE_SCRATCH_8_REG                             0xCD0
-#define PCIE_SCRATCH_9_REG                             0xCD4
-#define PCIE_SCRATCH_10_REG                            0xCD8
-#define PCIE_SCRATCH_11_REG                            0xCDC
-#define PCIE_SCRATCH_12_REG                            0xCE0
+#define PCIE_SCRATCH_4_REG                             0xCD0
+#define PCIE_SCRATCH_5_REG                             0xCD4
+#define PCIE_SCRATCH_6_REG                             0xCD8
+#define PCIE_SCRATCH_7_REG                             0xCDC
+#define PCIE_SCRATCH_8_REG                             0xCE0
+#define PCIE_SCRATCH_9_REG                             0xCE4
+#define PCIE_SCRATCH_10_REG                            0xCE8
+#define PCIE_SCRATCH_11_REG                            0xCEC
+#define PCIE_SCRATCH_12_REG                            0xCF0
 
 #define CPU_INTR_DNLD_RDY                              BIT(0)
 #define CPU_INTR_DOOR_BELL                             BIT(1)
index 288b035a3579b06b2dfba78c17369416b4ab2a44..cc15fdb36060b3dd387124e6288ac288c901cc78 100644 (file)
@@ -1941,6 +1941,7 @@ void rtl_pci_disconnect(struct pci_dev *pdev)
                rtl_deinit_deferred_work(hw);
                rtlpriv->intf_ops->adapter_stop(hw);
        }
+       rtlpriv->cfg->ops->disable_interrupt(hw);
 
        /*deinit rfkill */
        rtl_deinit_rfkill(hw);
index 41302c7b1ad0089480a495a26dac4da2552eecf2..d1afb8e3b2ef0a3673b5ff9ef60f98379180bfa3 100644 (file)
@@ -479,6 +479,7 @@ static void wl1251_op_stop(struct ieee80211_hw *hw)
        cancel_work_sync(&wl->irq_work);
        cancel_work_sync(&wl->tx_work);
        cancel_work_sync(&wl->filter_work);
+       cancel_delayed_work_sync(&wl->elp_work);
 
        mutex_lock(&wl->mutex);
 
index f78694295c397f053f4a00115ff2aff22d8a4379..1b851f650e074eb795ffb708dd25b3c94a2cb9e1 100644 (file)
@@ -315,8 +315,8 @@ static void __devexit wl1251_sdio_remove(struct sdio_func *func)
 
        if (wl->irq)
                free_irq(wl->irq, wl);
-       kfree(wl_sdio);
        wl1251_free_hw(wl);
+       kfree(wl_sdio);
 
        sdio_claim_host(func);
        sdio_release_irq(func);
index 083a49fee56a8bbaa0d3834d92fd459225a69d0e..165274c064bc723b4c344b1755d760267074563a 100644 (file)
@@ -42,6 +42,7 @@ obj-$(CONFIG_UNICORE32) += setup-bus.o setup-irq.o
 obj-$(CONFIG_PARISC) += setup-bus.o
 obj-$(CONFIG_SUPERH) += setup-bus.o setup-irq.o
 obj-$(CONFIG_PPC) += setup-bus.o
+obj-$(CONFIG_FRV) += setup-bus.o
 obj-$(CONFIG_MIPS) += setup-bus.o setup-irq.o
 obj-$(CONFIG_X86_VISWS) += setup-irq.o
 obj-$(CONFIG_MN10300) += setup-bus.o
index 0f150f271c2aa4040c8fcb9905783c99cb8b4e7a..1929c0c63b75b0773d45e39a845f663678b55d67 100644 (file)
@@ -200,7 +200,7 @@ static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev)
                return PCI_D1;
        case ACPI_STATE_D2:
                return PCI_D2;
-       case ACPI_STATE_D3:
+       case ACPI_STATE_D3_HOT:
                return PCI_D3hot;
        case ACPI_STATE_D3_COLD:
                return PCI_D3cold;
@@ -223,7 +223,7 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
                [PCI_D0] = ACPI_STATE_D0,
                [PCI_D1] = ACPI_STATE_D1,
                [PCI_D2] = ACPI_STATE_D2,
-               [PCI_D3hot] = ACPI_STATE_D3,
+               [PCI_D3hot] = ACPI_STATE_D3_HOT,
                [PCI_D3cold] = ACPI_STATE_D3
        };
        int error = -EINVAL;
index bc8384c6f3ebe889d10678fe6147214c3b56858d..639db4d0aa768ef70f3be5293fc5209c8ba60cb8 100644 (file)
@@ -50,7 +50,7 @@
  */
 #undef START_IN_KERNEL_MODE
 
-#define DRV_VER "0.5.24"
+#define DRV_VER "0.5.26"
 
 /*
  * According to the Atom N270 datasheet,
@@ -83,8 +83,8 @@ static int kernelmode;
 #endif
 
 static unsigned int interval = 10;
-static unsigned int fanon = 63000;
-static unsigned int fanoff = 58000;
+static unsigned int fanon = 60000;
+static unsigned int fanoff = 53000;
 static unsigned int verbose;
 static unsigned int fanstate = ACERHDF_FAN_AUTO;
 static char force_bios[16];
@@ -150,6 +150,8 @@ static const struct bios_settings_t bios_tbl[] = {
        {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00} },
        {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00} },
        {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
+       /* LT1005u */
+       {"Acer", "LT-10Q", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
        /* Acer 1410 */
        {"Acer", "Aspire 1410", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
        {"Acer", "Aspire 1410", "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
@@ -161,6 +163,7 @@ static const struct bios_settings_t bios_tbl[] = {
        {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
        {"Acer", "Aspire 1410", "v1.3308", 0x55, 0x58, {0x9e, 0x00} },
        {"Acer", "Aspire 1410", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
+       {"Acer", "Aspire 1410", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
        /* Acer 1810xx */
        {"Acer", "Aspire 1810TZ", "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
        {"Acer", "Aspire 1810T",  "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
@@ -183,29 +186,44 @@ static const struct bios_settings_t bios_tbl[] = {
        {"Acer", "Aspire 1810TZ", "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
        {"Acer", "Aspire 1810T",  "v1.3310", 0x55, 0x58, {0x9e, 0x00} },
        {"Acer", "Aspire 1810TZ", "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
+       {"Acer", "Aspire 1810T",  "v1.3314", 0x55, 0x58, {0x9e, 0x00} },
        /* Acer 531 */
+       {"Acer", "AO531h", "v0.3104", 0x55, 0x58, {0x20, 0x00} },
        {"Acer", "AO531h", "v0.3201", 0x55, 0x58, {0x20, 0x00} },
+       {"Acer", "AO531h", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
+       /* Acer 751 */
+       {"Acer", "AO751h", "V0.3212", 0x55, 0x58, {0x21, 0x00} },
+       /* Acer 1825 */
+       {"Acer", "Aspire 1825PTZ", "V1.3118", 0x55, 0x58, {0x9e, 0x00} },
+       {"Acer", "Aspire 1825PTZ", "V1.3127", 0x55, 0x58, {0x9e, 0x00} },
+       /* Acer TravelMate 7730 */
+       {"Acer", "TravelMate 7730G", "v0.3509", 0x55, 0x58, {0xaf, 0x00} },
        /* Gateway */
-       {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00} },
-       {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00} },
-       {"Gateway", "LT31",   "v1.3103", 0x55, 0x58, {0x9e, 0x00} },
-       {"Gateway", "LT31",   "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
-       {"Gateway", "LT31",   "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
+       {"Gateway", "AOA110", "v0.3103",  0x55, 0x58, {0x21, 0x00} },
+       {"Gateway", "AOA150", "v0.3103",  0x55, 0x58, {0x20, 0x00} },
+       {"Gateway", "LT31",   "v1.3103",  0x55, 0x58, {0x9e, 0x00} },
+       {"Gateway", "LT31",   "v1.3201",  0x55, 0x58, {0x9e, 0x00} },
+       {"Gateway", "LT31",   "v1.3302",  0x55, 0x58, {0x9e, 0x00} },
+       {"Gateway", "LT31",   "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
        /* Packard Bell */
-       {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00} },
-       {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
-       {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00} },
-       {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
-       {"Packard Bell", "DOTMU",  "v1.3303", 0x55, 0x58, {0x9e, 0x00} },
-       {"Packard Bell", "DOTMU",  "v0.3120", 0x55, 0x58, {0x9e, 0x00} },
-       {"Packard Bell", "DOTMU",  "v0.3108", 0x55, 0x58, {0x9e, 0x00} },
-       {"Packard Bell", "DOTMU",  "v0.3113", 0x55, 0x58, {0x9e, 0x00} },
-       {"Packard Bell", "DOTMU",  "v0.3115", 0x55, 0x58, {0x9e, 0x00} },
-       {"Packard Bell", "DOTMU",  "v0.3117", 0x55, 0x58, {0x9e, 0x00} },
-       {"Packard Bell", "DOTMU",  "v0.3119", 0x55, 0x58, {0x9e, 0x00} },
-       {"Packard Bell", "DOTMU",  "v1.3204", 0x55, 0x58, {0x9e, 0x00} },
-       {"Packard Bell", "DOTMA",  "v1.3201", 0x55, 0x58, {0x9e, 0x00} },
-       {"Packard Bell", "DOTMA",  "v1.3302", 0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOA150",  "v0.3104",  0x55, 0x58, {0x21, 0x00} },
+       {"Packard Bell", "DOA150",  "v0.3105",  0x55, 0x58, {0x20, 0x00} },
+       {"Packard Bell", "AOA110",  "v0.3105",  0x55, 0x58, {0x21, 0x00} },
+       {"Packard Bell", "AOA150",  "v0.3105",  0x55, 0x58, {0x20, 0x00} },
+       {"Packard Bell", "ENBFT",   "V1.3118",  0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "ENBFT",   "V1.3127",  0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOTMU",   "v1.3303",  0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOTMU",   "v0.3120",  0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOTMU",   "v0.3108",  0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOTMU",   "v0.3113",  0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOTMU",   "v0.3115",  0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOTMU",   "v0.3117",  0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOTMU",   "v0.3119",  0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOTMU",   "v1.3204",  0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOTMA",   "v1.3201",  0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOTMA",   "v1.3302",  0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOTMA",   "v1.3303t", 0x55, 0x58, {0x9e, 0x00} },
+       {"Packard Bell", "DOTVR46", "v1.3308",  0x55, 0x58, {0x9e, 0x00} },
        /* pewpew-terminator */
        {"", "", "", 0, 0, {0, 0} }
 };
@@ -701,15 +719,20 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Peter Feuerer");
 MODULE_DESCRIPTION("Aspire One temperature and fan driver");
 MODULE_ALIAS("dmi:*:*Acer*:pnAOA*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAO751h*:");
 MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1410*:");
 MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1810*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire*1825PTZ:");
 MODULE_ALIAS("dmi:*:*Acer*:pnAO531*:");
+MODULE_ALIAS("dmi:*:*Acer*:TravelMate*7730G:");
 MODULE_ALIAS("dmi:*:*Gateway*:pnAOA*:");
 MODULE_ALIAS("dmi:*:*Gateway*:pnLT31*:");
 MODULE_ALIAS("dmi:*:*Packard*Bell*:pnAOA*:");
 MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOA*:");
 MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMU*:");
+MODULE_ALIAS("dmi:*:*Packard*Bell*:pnENBFT*:");
 MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTMA*:");
+MODULE_ALIAS("dmi:*:*Packard*Bell*:pnDOTVR46*:");
 
 module_init(acerhdf_init);
 module_exit(acerhdf_exit);
index a05fc9c955d86212cc274b8f78296c994342e2b0..e6c08ee8d46c0acb5d1652b2627bc65b5f2d4922 100644 (file)
@@ -212,6 +212,7 @@ static struct dmi_system_id __devinitdata dell_quirks[] = {
                },
                .driver_data = &quirk_dell_vostro_v130,
        },
+       { }
 };
 
 static struct calling_interface_buffer *buffer;
index f7ba316e0ed612f7adddafd75fe7f94b13d78656..0ffdb3cde2bbc3ff569fee774dcd842333585031 100644 (file)
@@ -1565,7 +1565,7 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id)
                ips->poll_turbo_status = true;
 
        if (!ips_get_i915_syms(ips)) {
-               dev_err(&dev->dev, "failed to get i915 symbols, graphics turbo disabled\n");
+               dev_info(&dev->dev, "failed to get i915 symbols, graphics turbo disabled until i915 loads\n");
                ips->gpu_turbo_enabled = false;
        } else {
                dev_dbg(&dev->dev, "graphics turbo enabled\n");
index 0a3594c7e91263fcf7d1498e4e3634d4d8690ac2..bcbad8452a6f0ca5bb818b684837e207ffef7b5f 100644 (file)
@@ -78,7 +78,7 @@ static int __devinit mfld_pb_probe(struct platform_device *pdev)
 
        input_set_capability(input, EV_KEY, KEY_POWER);
 
-       error = request_threaded_irq(irq, NULL, mfld_pb_isr, 0,
+       error = request_threaded_irq(irq, NULL, mfld_pb_isr, IRQF_NO_SUSPEND,
                        DRIVER_NAME, input);
        if (error) {
                dev_err(&pdev->dev, "Unable to request irq %d for mfld power"
index cd188ab72f79c7bba15f5c59d055705d2a68e140..c293d0cdb10483502784653f8617d0f0ecb55562 100644 (file)
@@ -902,6 +902,7 @@ read_rtc:
                }
                ds1307->nvram->attr.name = "nvram";
                ds1307->nvram->attr.mode = S_IRUGO | S_IWUSR;
+               sysfs_bin_attr_init(ds1307->nvram);
                ds1307->nvram->read = ds1307_nvram_read,
                ds1307->nvram->write = ds1307_nvram_write,
                ds1307->nvram->size = chip->nvram_size;
index d93a9608b1f0dfec14db5c3e5e3e6e941382b618..891cd6c61d0ae76112ccc0f6b6da3876d21569ad 100644 (file)
@@ -405,7 +405,7 @@ static int dryice_rtc_probe(struct platform_device *pdev)
        imxdi->clk = clk_get(&pdev->dev, NULL);
        if (IS_ERR(imxdi->clk))
                return PTR_ERR(imxdi->clk);
-       clk_enable(imxdi->clk);
+       clk_prepare_enable(imxdi->clk);
 
        /*
         * Initialize dryice hardware
@@ -470,7 +470,7 @@ static int dryice_rtc_probe(struct platform_device *pdev)
        return 0;
 
 err:
-       clk_disable(imxdi->clk);
+       clk_disable_unprepare(imxdi->clk);
        clk_put(imxdi->clk);
 
        return rc;
@@ -487,7 +487,7 @@ static int __devexit dryice_rtc_remove(struct platform_device *pdev)
 
        rtc_device_unregister(imxdi->rtc);
 
-       clk_disable(imxdi->clk);
+       clk_disable_unprepare(imxdi->clk);
        clk_put(imxdi->clk);
 
        return 0;
index 42f5f829b3ee1c0ff8adfcc3d120f47367b7cd05..029e421baaed49b7f62c58c0ef89454d2fa2053b 100644 (file)
@@ -360,12 +360,11 @@ static int __devinit mpc5121_rtc_probe(struct platform_device *op)
                                                &mpc5200_rtc_ops, THIS_MODULE);
        }
 
-       rtc->rtc->uie_unsupported = 1;
-
        if (IS_ERR(rtc->rtc)) {
                err = PTR_ERR(rtc->rtc);
                goto out_free_irq;
        }
+       rtc->rtc->uie_unsupported = 1;
 
        return 0;
 
index 120955c66410faf8e4c8254baebba15895d38aa9..8334dadc681de98eeb7ac78fed5755336ff58d63 100644 (file)
@@ -1672,7 +1672,8 @@ static void qeth_configure_blkt_default(struct qeth_card *card, char *prcd)
 {
        QETH_DBF_TEXT(SETUP, 2, "cfgblkt");
 
-       if (prcd[74] == 0xF0 && prcd[75] == 0xF0 && prcd[76] == 0xF5) {
+       if (prcd[74] == 0xF0 && prcd[75] == 0xF0 &&
+           (prcd[76] == 0xF5 || prcd[76] == 0xF6)) {
                card->info.blkt.time_total = 250;
                card->info.blkt.inter_packet = 5;
                card->info.blkt.inter_packet_jumbo = 15;
@@ -4540,7 +4541,8 @@ static void qeth_determine_capabilities(struct qeth_card *card)
                goto out_offline;
        }
        qeth_configure_unitaddr(card, prcd);
-       qeth_configure_blkt_default(card, prcd);
+       if (ddev_offline)
+               qeth_configure_blkt_default(card, prcd);
        kfree(prcd);
 
        rc = qdio_get_ssqd_desc(ddev, &card->ssqd);
index e002cd466e9a916d24d6064012d0488c854cd63e..467dc38246f93317221239e45a798c867bd1cdb0 100644 (file)
@@ -4549,8 +4549,12 @@ static int ipr_ata_slave_alloc(struct scsi_device *sdev)
        ENTER;
        if (sdev->sdev_target)
                sata_port = sdev->sdev_target->hostdata;
-       if (sata_port)
+       if (sata_port) {
                rc = ata_sas_port_init(sata_port->ap);
+               if (rc == 0)
+                       rc = ata_sas_sync_probe(sata_port->ap);
+       }
+
        if (rc)
                ipr_slave_destroy(sdev);
 
index ef9560dff295f9252bf9ccdf3a4d9d2de61d1852..cc83b66d45b7836aebe4fe55085935922fdb4a56 100644 (file)
@@ -1742,17 +1742,19 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
 
        mfs = ntohs(flp->fl_csp.sp_bb_data) &
                FC_SP_BB_DATA_MASK;
-       if (mfs >= FC_SP_MIN_MAX_PAYLOAD &&
-           mfs <= lport->mfs) {
-               lport->mfs = mfs;
-               fc_host_maxframe_size(lport->host) = mfs;
-       } else {
+
+       if (mfs < FC_SP_MIN_MAX_PAYLOAD || mfs > FC_SP_MAX_MAX_PAYLOAD) {
                FC_LPORT_DBG(lport, "FLOGI bad mfs:%hu response, "
                             "lport->mfs:%hu\n", mfs, lport->mfs);
                fc_lport_error(lport, fp);
                goto err;
        }
 
+       if (mfs <= lport->mfs) {
+               lport->mfs = mfs;
+               fc_host_maxframe_size(lport->host) = mfs;
+       }
+
        csp_flags = ntohs(flp->fl_csp.sp_features);
        r_a_tov = ntohl(flp->fl_csp.sp_r_a_tov);
        e_d_tov = ntohl(flp->fl_csp.sp_e_d_tov);
index bc0cecc6ad62492c02b153ecee767ed0cfd650b1..441d88ad99a7bb3abadb8b1e9af25281ced8334b 100644 (file)
@@ -546,11 +546,12 @@ static struct ata_port_info sata_port_info = {
        .port_ops = &sas_sata_ops
 };
 
-int sas_ata_init_host_and_port(struct domain_device *found_dev)
+int sas_ata_init(struct domain_device *found_dev)
 {
        struct sas_ha_struct *ha = found_dev->port->ha;
        struct Scsi_Host *shost = ha->core.shost;
        struct ata_port *ap;
+       int rc;
 
        ata_host_init(&found_dev->sata_dev.ata_host,
                      ha->dev,
@@ -567,8 +568,11 @@ int sas_ata_init_host_and_port(struct domain_device *found_dev)
        ap->private_data = found_dev;
        ap->cbl = ATA_CBL_SATA;
        ap->scsi_host = shost;
-       /* publish initialized ata port */
-       smp_wmb();
+       rc = ata_sas_port_init(ap);
+       if (rc) {
+               ata_sas_port_destroy(ap);
+               return rc;
+       }
        found_dev->sata_dev.ap = ap;
 
        return 0;
@@ -648,18 +652,13 @@ static void sas_get_ata_command_set(struct domain_device *dev)
 void sas_probe_sata(struct asd_sas_port *port)
 {
        struct domain_device *dev, *n;
-       int err;
 
        mutex_lock(&port->ha->disco_mutex);
-       list_for_each_entry_safe(dev, n, &port->disco_list, disco_list_node) {
+       list_for_each_entry(dev, &port->disco_list, disco_list_node) {
                if (!dev_is_sata(dev))
                        continue;
 
-               err = sas_ata_init_host_and_port(dev);
-               if (err)
-                       sas_fail_probe(dev, __func__, err);
-               else
-                       ata_sas_async_port_init(dev->sata_dev.ap);
+               ata_sas_async_probe(dev->sata_dev.ap);
        }
        mutex_unlock(&port->ha->disco_mutex);
 
@@ -718,18 +717,6 @@ static void async_sas_ata_eh(void *data, async_cookie_t cookie)
        sas_put_device(dev);
 }
 
-static bool sas_ata_dev_eh_valid(struct domain_device *dev)
-{
-       struct ata_port *ap;
-
-       if (!dev_is_sata(dev))
-               return false;
-       ap = dev->sata_dev.ap;
-       /* consume fully initialized ata ports */
-       smp_rmb();
-       return !!ap;
-}
-
 void sas_ata_strategy_handler(struct Scsi_Host *shost)
 {
        struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
@@ -753,7 +740,7 @@ void sas_ata_strategy_handler(struct Scsi_Host *shost)
 
                spin_lock(&port->dev_list_lock);
                list_for_each_entry(dev, &port->dev_list, dev_list_node) {
-                       if (!sas_ata_dev_eh_valid(dev))
+                       if (!dev_is_sata(dev))
                                continue;
                        async_schedule_domain(async_sas_ata_eh, dev, &async);
                }
index 3646796756028bd1258a7dd920025d860baa294d..629a0865b130db3fc25036103ab78aaf94eba5ea 100644 (file)
@@ -72,6 +72,7 @@ static int sas_get_port_device(struct asd_sas_port *port)
        struct asd_sas_phy *phy;
        struct sas_rphy *rphy;
        struct domain_device *dev;
+       int rc = -ENODEV;
 
        dev = sas_alloc_device();
        if (!dev)
@@ -110,9 +111,16 @@ static int sas_get_port_device(struct asd_sas_port *port)
 
        sas_init_dev(dev);
 
+       dev->port = port;
        switch (dev->dev_type) {
-       case SAS_END_DEV:
        case SATA_DEV:
+               rc = sas_ata_init(dev);
+               if (rc) {
+                       rphy = NULL;
+                       break;
+               }
+               /* fall through */
+       case SAS_END_DEV:
                rphy = sas_end_device_alloc(port->port);
                break;
        case EDGE_DEV:
@@ -131,19 +139,14 @@ static int sas_get_port_device(struct asd_sas_port *port)
 
        if (!rphy) {
                sas_put_device(dev);
-               return -ENODEV;
+               return rc;
        }
 
-       spin_lock_irq(&port->phy_list_lock);
-       list_for_each_entry(phy, &port->phy_list, port_phy_el)
-               sas_phy_set_target(phy, dev);
-       spin_unlock_irq(&port->phy_list_lock);
        rphy->identify.phy_identifier = phy->phy->identify.phy_identifier;
        memcpy(dev->sas_addr, port->attached_sas_addr, SAS_ADDR_SIZE);
        sas_fill_in_rphy(dev, rphy);
        sas_hash_addr(dev->hashed_sas_addr, dev->sas_addr);
        port->port_dev = dev;
-       dev->port = port;
        dev->linkrate = port->linkrate;
        dev->min_linkrate = port->linkrate;
        dev->max_linkrate = port->linkrate;
@@ -155,6 +158,7 @@ static int sas_get_port_device(struct asd_sas_port *port)
        sas_device_set_phy(dev, port->port);
 
        dev->rphy = rphy;
+       get_device(&dev->rphy->dev);
 
        if (dev_is_sata(dev) || dev->dev_type == SAS_END_DEV)
                list_add_tail(&dev->disco_list_node, &port->disco_list);
@@ -164,6 +168,11 @@ static int sas_get_port_device(struct asd_sas_port *port)
                spin_unlock_irq(&port->dev_list_lock);
        }
 
+       spin_lock_irq(&port->phy_list_lock);
+       list_for_each_entry(phy, &port->phy_list, port_phy_el)
+               sas_phy_set_target(phy, dev);
+       spin_unlock_irq(&port->phy_list_lock);
+
        return 0;
 }
 
@@ -205,8 +214,7 @@ void sas_notify_lldd_dev_gone(struct domain_device *dev)
 static void sas_probe_devices(struct work_struct *work)
 {
        struct domain_device *dev, *n;
-       struct sas_discovery_event *ev =
-               container_of(work, struct sas_discovery_event, work);
+       struct sas_discovery_event *ev = to_sas_discovery_event(work);
        struct asd_sas_port *port = ev->port;
 
        clear_bit(DISCE_PROBE, &port->disc.pending);
@@ -255,6 +263,9 @@ void sas_free_device(struct kref *kref)
 {
        struct domain_device *dev = container_of(kref, typeof(*dev), kref);
 
+       put_device(&dev->rphy->dev);
+       dev->rphy = NULL;
+
        if (dev->parent)
                sas_put_device(dev->parent);
 
@@ -291,8 +302,7 @@ static void sas_unregister_common_dev(struct asd_sas_port *port, struct domain_d
 static void sas_destruct_devices(struct work_struct *work)
 {
        struct domain_device *dev, *n;
-       struct sas_discovery_event *ev =
-               container_of(work, struct sas_discovery_event, work);
+       struct sas_discovery_event *ev = to_sas_discovery_event(work);
        struct asd_sas_port *port = ev->port;
 
        clear_bit(DISCE_DESTRUCT, &port->disc.pending);
@@ -302,7 +312,6 @@ static void sas_destruct_devices(struct work_struct *work)
 
                sas_remove_children(&dev->rphy->dev);
                sas_rphy_delete(dev->rphy);
-               dev->rphy = NULL;
                sas_unregister_common_dev(port, dev);
        }
 }
@@ -314,11 +323,11 @@ void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *dev)
                /* this rphy never saw sas_rphy_add */
                list_del_init(&dev->disco_list_node);
                sas_rphy_free(dev->rphy);
-               dev->rphy = NULL;
                sas_unregister_common_dev(port, dev);
+               return;
        }
 
-       if (dev->rphy && !test_and_set_bit(SAS_DEV_DESTROY, &dev->state)) {
+       if (!test_and_set_bit(SAS_DEV_DESTROY, &dev->state)) {
                sas_rphy_unlink(dev->rphy);
                list_move_tail(&dev->disco_list_node, &port->destroy_list);
                sas_discover_event(dev->port, DISCE_DESTRUCT);
@@ -377,8 +386,7 @@ static void sas_discover_domain(struct work_struct *work)
 {
        struct domain_device *dev;
        int error = 0;
-       struct sas_discovery_event *ev =
-               container_of(work, struct sas_discovery_event, work);
+       struct sas_discovery_event *ev = to_sas_discovery_event(work);
        struct asd_sas_port *port = ev->port;
 
        clear_bit(DISCE_DISCOVER_DOMAIN, &port->disc.pending);
@@ -419,8 +427,6 @@ static void sas_discover_domain(struct work_struct *work)
 
        if (error) {
                sas_rphy_free(dev->rphy);
-               dev->rphy = NULL;
-
                list_del_init(&dev->disco_list_node);
                spin_lock_irq(&port->dev_list_lock);
                list_del_init(&dev->dev_list_node);
@@ -437,8 +443,7 @@ static void sas_discover_domain(struct work_struct *work)
 static void sas_revalidate_domain(struct work_struct *work)
 {
        int res = 0;
-       struct sas_discovery_event *ev =
-               container_of(work, struct sas_discovery_event, work);
+       struct sas_discovery_event *ev = to_sas_discovery_event(work);
        struct asd_sas_port *port = ev->port;
        struct sas_ha_struct *ha = port->ha;
 
@@ -466,21 +471,25 @@ static void sas_revalidate_domain(struct work_struct *work)
 
 /* ---------- Events ---------- */
 
-static void sas_chain_work(struct sas_ha_struct *ha, struct work_struct *work)
+static void sas_chain_work(struct sas_ha_struct *ha, struct sas_work *sw)
 {
-       /* chained work is not subject to SA_HA_DRAINING or SAS_HA_REGISTERED */
-       scsi_queue_work(ha->core.shost, work);
+       /* chained work is not subject to SA_HA_DRAINING or
+        * SAS_HA_REGISTERED, because it is either submitted in the
+        * workqueue, or known to be submitted from a context that is
+        * not racing against draining
+        */
+       scsi_queue_work(ha->core.shost, &sw->work);
 }
 
 static void sas_chain_event(int event, unsigned long *pending,
-                           struct work_struct *work,
+                           struct sas_work *sw,
                            struct sas_ha_struct *ha)
 {
        if (!test_and_set_bit(event, pending)) {
                unsigned long flags;
 
                spin_lock_irqsave(&ha->state_lock, flags);
-               sas_chain_work(ha, work);
+               sas_chain_work(ha, sw);
                spin_unlock_irqrestore(&ha->state_lock, flags);
        }
 }
@@ -519,7 +528,7 @@ void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *port)
 
        disc->pending = 0;
        for (i = 0; i < DISC_NUM_EVENTS; i++) {
-               INIT_WORK(&disc->disc_work[i].work, sas_event_fns[i]);
+               INIT_SAS_WORK(&disc->disc_work[i].work, sas_event_fns[i]);
                disc->disc_work[i].port = port;
        }
 }
index 16639bbae629d279af43a33f78072e4d88d09fc8..4e4292d210c1478131b6eda3260f51b6ffc3fa52 100644 (file)
 #include "sas_internal.h"
 #include "sas_dump.h"
 
-void sas_queue_work(struct sas_ha_struct *ha, struct work_struct *work)
+void sas_queue_work(struct sas_ha_struct *ha, struct sas_work *sw)
 {
        if (!test_bit(SAS_HA_REGISTERED, &ha->state))
                return;
 
-       if (test_bit(SAS_HA_DRAINING, &ha->state))
-               list_add(&work->entry, &ha->defer_q);
-       else
-               scsi_queue_work(ha->core.shost, work);
+       if (test_bit(SAS_HA_DRAINING, &ha->state)) {
+               /* add it to the defer list, if not already pending */
+               if (list_empty(&sw->drain_node))
+                       list_add(&sw->drain_node, &ha->defer_q);
+       } else
+               scsi_queue_work(ha->core.shost, &sw->work);
 }
 
 static void sas_queue_event(int event, unsigned long *pending,
-                           struct work_struct *work,
+                           struct sas_work *work,
                            struct sas_ha_struct *ha)
 {
        if (!test_and_set_bit(event, pending)) {
@@ -55,7 +57,7 @@ static void sas_queue_event(int event, unsigned long *pending,
 void __sas_drain_work(struct sas_ha_struct *ha)
 {
        struct workqueue_struct *wq = ha->core.shost->work_q;
-       struct work_struct *w, *_w;
+       struct sas_work *sw, *_sw;
 
        set_bit(SAS_HA_DRAINING, &ha->state);
        /* flush submitters */
@@ -66,9 +68,9 @@ void __sas_drain_work(struct sas_ha_struct *ha)
 
        spin_lock_irq(&ha->state_lock);
        clear_bit(SAS_HA_DRAINING, &ha->state);
-       list_for_each_entry_safe(w, _w, &ha->defer_q, entry) {
-               list_del_init(&w->entry);
-               sas_queue_work(ha, w);
+       list_for_each_entry_safe(sw, _sw, &ha->defer_q, drain_node) {
+               list_del_init(&sw->drain_node);
+               sas_queue_work(ha, sw);
        }
        spin_unlock_irq(&ha->state_lock);
 }
@@ -151,7 +153,7 @@ int sas_init_events(struct sas_ha_struct *sas_ha)
        int i;
 
        for (i = 0; i < HA_NUM_EVENTS; i++) {
-               INIT_WORK(&sas_ha->ha_events[i].work, sas_ha_event_fns[i]);
+               INIT_SAS_WORK(&sas_ha->ha_events[i].work, sas_ha_event_fns[i]);
                sas_ha->ha_events[i].ha = sas_ha;
        }
 
index 05acd9e35fc4def9872d8b19debdb2875302b65b..caa0525d2523037f7bace6a27cfdb007176b0448 100644 (file)
@@ -202,6 +202,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
        u8 sas_addr[SAS_ADDR_SIZE];
        struct smp_resp *resp = rsp;
        struct discover_resp *dr = &resp->disc;
+       struct sas_ha_struct *ha = dev->port->ha;
        struct expander_device *ex = &dev->ex_dev;
        struct ex_phy *phy = &ex->ex_phy[phy_id];
        struct sas_rphy *rphy = dev->rphy;
@@ -209,6 +210,8 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
        char *type;
 
        if (new_phy) {
+               if (WARN_ON_ONCE(test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state)))
+                       return;
                phy->phy = sas_phy_alloc(&rphy->dev, phy_id);
 
                /* FIXME: error_handling */
@@ -233,6 +236,8 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
        memcpy(sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE);
 
        phy->attached_dev_type = to_dev_type(dr);
+       if (test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state))
+               goto out;
        phy->phy_id = phy_id;
        phy->linkrate = dr->linkrate;
        phy->attached_sata_host = dr->attached_sata_host;
@@ -240,7 +245,14 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
        phy->attached_sata_ps   = dr->attached_sata_ps;
        phy->attached_iproto = dr->iproto << 1;
        phy->attached_tproto = dr->tproto << 1;
-       memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE);
+       /* help some expanders that fail to zero sas_address in the 'no
+        * device' case
+        */
+       if (phy->attached_dev_type == NO_DEVICE ||
+           phy->linkrate < SAS_LINK_RATE_1_5_GBPS)
+               memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
+       else
+               memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE);
        phy->attached_phy_id = dr->attached_phy_id;
        phy->phy_change_count = dr->change_count;
        phy->routing_attr = dr->routing_attr;
@@ -266,6 +278,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
                        return;
                }
 
+ out:
        switch (phy->attached_dev_type) {
        case SATA_PENDING:
                type = "stp pending";
@@ -304,7 +317,15 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
        else
                return;
 
-       SAS_DPRINTK("ex %016llx phy%02d:%c:%X attached: %016llx (%s)\n",
+       /* if the attached device type changed and ata_eh is active,
+        * make sure we run revalidation when eh completes (see:
+        * sas_enable_revalidation)
+        */
+       if (test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state))
+               set_bit(DISCE_REVALIDATE_DOMAIN, &dev->port->disc.pending);
+
+       SAS_DPRINTK("%sex %016llx phy%02d:%c:%X attached: %016llx (%s)\n",
+                   test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state) ? "ata: " : "",
                    SAS_ADDR(dev->sas_addr), phy->phy_id,
                    sas_route_char(dev, phy), phy->linkrate,
                    SAS_ADDR(phy->attached_sas_addr), type);
@@ -776,13 +797,16 @@ static struct domain_device *sas_ex_discover_end_dev(
                if (res)
                        goto out_free;
 
+               sas_init_dev(child);
+               res = sas_ata_init(child);
+               if (res)
+                       goto out_free;
                rphy = sas_end_device_alloc(phy->port);
-               if (unlikely(!rphy))
+               if (!rphy)
                        goto out_free;
 
-               sas_init_dev(child);
-
                child->rphy = rphy;
+               get_device(&rphy->dev);
 
                list_add_tail(&child->disco_list_node, &parent->port->disco_list);
 
@@ -806,6 +830,7 @@ static struct domain_device *sas_ex_discover_end_dev(
                sas_init_dev(child);
 
                child->rphy = rphy;
+               get_device(&rphy->dev);
                sas_fill_in_rphy(child, rphy);
 
                list_add_tail(&child->disco_list_node, &parent->port->disco_list);
@@ -830,8 +855,6 @@ static struct domain_device *sas_ex_discover_end_dev(
 
  out_list_del:
        sas_rphy_free(child->rphy);
-       child->rphy = NULL;
-
        list_del(&child->disco_list_node);
        spin_lock_irq(&parent->port->dev_list_lock);
        list_del(&child->dev_list_node);
@@ -911,6 +934,7 @@ static struct domain_device *sas_ex_discover_expander(
        }
        port = parent->port;
        child->rphy = rphy;
+       get_device(&rphy->dev);
        edev = rphy_to_expander_device(rphy);
        child->dev_type = phy->attached_dev_type;
        kref_get(&parent->kref);
@@ -934,6 +958,7 @@ static struct domain_device *sas_ex_discover_expander(
 
        res = sas_discover_expander(child);
        if (res) {
+               sas_rphy_delete(rphy);
                spin_lock_irq(&parent->port->dev_list_lock);
                list_del(&child->dev_list_node);
                spin_unlock_irq(&parent->port->dev_list_lock);
@@ -1718,9 +1743,17 @@ static int sas_find_bcast_phy(struct domain_device *dev, int *phy_id,
                int phy_change_count = 0;
 
                res = sas_get_phy_change_count(dev, i, &phy_change_count);
-               if (res)
-                       goto out;
-               else if (phy_change_count != ex->ex_phy[i].phy_change_count) {
+               switch (res) {
+               case SMP_RESP_PHY_VACANT:
+               case SMP_RESP_NO_PHY:
+                       continue;
+               case SMP_RESP_FUNC_ACC:
+                       break;
+               default:
+                       return res;
+               }
+
+               if (phy_change_count != ex->ex_phy[i].phy_change_count) {
                        if (update)
                                ex->ex_phy[i].phy_change_count =
                                        phy_change_count;
@@ -1728,8 +1761,7 @@ static int sas_find_bcast_phy(struct domain_device *dev, int *phy_id,
                        return 0;
                }
        }
-out:
-       return res;
+       return 0;
 }
 
 static int sas_get_ex_change_count(struct domain_device *dev, int *ecc)
index 120bff64be303c67cc66aba9fdfae3af7d58e2c8..10cb5ae30977cfaa9da66f5ad0b7b497aa51b758 100644 (file)
@@ -94,8 +94,7 @@ void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
 
 void sas_hae_reset(struct work_struct *work)
 {
-       struct sas_ha_event *ev =
-               container_of(work, struct sas_ha_event, work);
+       struct sas_ha_event *ev = to_sas_ha_event(work);
        struct sas_ha_struct *ha = ev->ha;
 
        clear_bit(HAE_RESET, &ha->pending);
@@ -369,14 +368,14 @@ static void sas_phy_release(struct sas_phy *phy)
 
 static void phy_reset_work(struct work_struct *work)
 {
-       struct sas_phy_data *d = container_of(work, typeof(*d), reset_work);
+       struct sas_phy_data *d = container_of(work, typeof(*d), reset_work.work);
 
        d->reset_result = transport_sas_phy_reset(d->phy, d->hard_reset);
 }
 
 static void phy_enable_work(struct work_struct *work)
 {
-       struct sas_phy_data *d = container_of(work, typeof(*d), enable_work);
+       struct sas_phy_data *d = container_of(work, typeof(*d), enable_work.work);
 
        d->enable_result = sas_phy_enable(d->phy, d->enable);
 }
@@ -389,8 +388,8 @@ static int sas_phy_setup(struct sas_phy *phy)
                return -ENOMEM;
 
        mutex_init(&d->event_lock);
-       INIT_WORK(&d->reset_work, phy_reset_work);
-       INIT_WORK(&d->enable_work, phy_enable_work);
+       INIT_SAS_WORK(&d->reset_work, phy_reset_work);
+       INIT_SAS_WORK(&d->enable_work, phy_enable_work);
        d->phy = phy;
        phy->hostdata = d;
 
index f05c63879949a1b70ef1553571d54e87922f0d18..507e4cf12e56cef87cd3b80af00215cc62db6078 100644 (file)
@@ -45,10 +45,10 @@ struct sas_phy_data {
        struct mutex event_lock;
        int hard_reset;
        int reset_result;
-       struct work_struct reset_work;
+       struct sas_work reset_work;
        int enable;
        int enable_result;
-       struct work_struct enable_work;
+       struct sas_work enable_work;
 };
 
 void sas_scsi_recover_host(struct Scsi_Host *shost);
@@ -80,7 +80,7 @@ void sas_porte_broadcast_rcvd(struct work_struct *work);
 void sas_porte_link_reset_err(struct work_struct *work);
 void sas_porte_timer_event(struct work_struct *work);
 void sas_porte_hard_reset(struct work_struct *work);
-void sas_queue_work(struct sas_ha_struct *ha, struct work_struct *work);
+void sas_queue_work(struct sas_ha_struct *ha, struct sas_work *sw);
 
 int sas_notify_lldd_dev_found(struct domain_device *);
 void sas_notify_lldd_dev_gone(struct domain_device *);
index dcfd4a9105c5e2429b210bf427f85cf97ae2620b..521422e857ab330ee3a659ad11dae2dd02aee9f0 100644 (file)
@@ -32,8 +32,7 @@
 
 static void sas_phye_loss_of_signal(struct work_struct *work)
 {
-       struct asd_sas_event *ev =
-               container_of(work, struct asd_sas_event, work);
+       struct asd_sas_event *ev = to_asd_sas_event(work);
        struct asd_sas_phy *phy = ev->phy;
 
        clear_bit(PHYE_LOSS_OF_SIGNAL, &phy->phy_events_pending);
@@ -43,8 +42,7 @@ static void sas_phye_loss_of_signal(struct work_struct *work)
 
 static void sas_phye_oob_done(struct work_struct *work)
 {
-       struct asd_sas_event *ev =
-               container_of(work, struct asd_sas_event, work);
+       struct asd_sas_event *ev = to_asd_sas_event(work);
        struct asd_sas_phy *phy = ev->phy;
 
        clear_bit(PHYE_OOB_DONE, &phy->phy_events_pending);
@@ -53,8 +51,7 @@ static void sas_phye_oob_done(struct work_struct *work)
 
 static void sas_phye_oob_error(struct work_struct *work)
 {
-       struct asd_sas_event *ev =
-               container_of(work, struct asd_sas_event, work);
+       struct asd_sas_event *ev = to_asd_sas_event(work);
        struct asd_sas_phy *phy = ev->phy;
        struct sas_ha_struct *sas_ha = phy->ha;
        struct asd_sas_port *port = phy->port;
@@ -85,8 +82,7 @@ static void sas_phye_oob_error(struct work_struct *work)
 
 static void sas_phye_spinup_hold(struct work_struct *work)
 {
-       struct asd_sas_event *ev =
-               container_of(work, struct asd_sas_event, work);
+       struct asd_sas_event *ev = to_asd_sas_event(work);
        struct asd_sas_phy *phy = ev->phy;
        struct sas_ha_struct *sas_ha = phy->ha;
        struct sas_internal *i =
@@ -127,14 +123,12 @@ int sas_register_phys(struct sas_ha_struct *sas_ha)
                phy->error = 0;
                INIT_LIST_HEAD(&phy->port_phy_el);
                for (k = 0; k < PORT_NUM_EVENTS; k++) {
-                       INIT_WORK(&phy->port_events[k].work,
-                                 sas_port_event_fns[k]);
+                       INIT_SAS_WORK(&phy->port_events[k].work, sas_port_event_fns[k]);
                        phy->port_events[k].phy = phy;
                }
 
                for (k = 0; k < PHY_NUM_EVENTS; k++) {
-                       INIT_WORK(&phy->phy_events[k].work,
-                                 sas_phy_event_fns[k]);
+                       INIT_SAS_WORK(&phy->phy_events[k].work, sas_phy_event_fns[k]);
                        phy->phy_events[k].phy = phy;
                }
 
@@ -144,8 +138,7 @@ int sas_register_phys(struct sas_ha_struct *sas_ha)
                spin_lock_init(&phy->sas_prim_lock);
                phy->frame_rcvd_size = 0;
 
-               phy->phy = sas_phy_alloc(&sas_ha->core.shost->shost_gendev,
-                                        i);
+               phy->phy = sas_phy_alloc(&sas_ha->core.shost->shost_gendev, i);
                if (!phy->phy)
                        return -ENOMEM;
 
index eb19c016d5001b1890feafa0f8ae140e1982a1bf..e884a8c58a0ccb181424051281fda4b4a45fc1a9 100644 (file)
@@ -123,7 +123,7 @@ static void sas_form_port(struct asd_sas_phy *phy)
        spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags);
 
        if (!port->port) {
-               port->port = sas_port_alloc(phy->phy->dev.parent, phy->id);
+               port->port = sas_port_alloc(phy->phy->dev.parent, port->id);
                BUG_ON(!port->port);
                sas_port_add(port->port);
        }
@@ -208,8 +208,7 @@ void sas_deform_port(struct asd_sas_phy *phy, int gone)
 
 void sas_porte_bytes_dmaed(struct work_struct *work)
 {
-       struct asd_sas_event *ev =
-               container_of(work, struct asd_sas_event, work);
+       struct asd_sas_event *ev = to_asd_sas_event(work);
        struct asd_sas_phy *phy = ev->phy;
 
        clear_bit(PORTE_BYTES_DMAED, &phy->port_events_pending);
@@ -219,8 +218,7 @@ void sas_porte_bytes_dmaed(struct work_struct *work)
 
 void sas_porte_broadcast_rcvd(struct work_struct *work)
 {
-       struct asd_sas_event *ev =
-               container_of(work, struct asd_sas_event, work);
+       struct asd_sas_event *ev = to_asd_sas_event(work);
        struct asd_sas_phy *phy = ev->phy;
        unsigned long flags;
        u32 prim;
@@ -237,8 +235,7 @@ void sas_porte_broadcast_rcvd(struct work_struct *work)
 
 void sas_porte_link_reset_err(struct work_struct *work)
 {
-       struct asd_sas_event *ev =
-               container_of(work, struct asd_sas_event, work);
+       struct asd_sas_event *ev = to_asd_sas_event(work);
        struct asd_sas_phy *phy = ev->phy;
 
        clear_bit(PORTE_LINK_RESET_ERR, &phy->port_events_pending);
@@ -248,8 +245,7 @@ void sas_porte_link_reset_err(struct work_struct *work)
 
 void sas_porte_timer_event(struct work_struct *work)
 {
-       struct asd_sas_event *ev =
-               container_of(work, struct asd_sas_event, work);
+       struct asd_sas_event *ev = to_asd_sas_event(work);
        struct asd_sas_phy *phy = ev->phy;
 
        clear_bit(PORTE_TIMER_EVENT, &phy->port_events_pending);
@@ -259,8 +255,7 @@ void sas_porte_timer_event(struct work_struct *work)
 
 void sas_porte_hard_reset(struct work_struct *work)
 {
-       struct asd_sas_event *ev =
-               container_of(work, struct asd_sas_event, work);
+       struct asd_sas_event *ev = to_asd_sas_event(work);
        struct asd_sas_phy *phy = ev->phy;
 
        clear_bit(PORTE_HARD_RESET, &phy->port_events_pending);
index ead6405f3e51465f5dfe95412cb4d242fa704608..5dfd7495d1a1bc4231123760090aa3d38eb9a764 100644 (file)
@@ -1638,7 +1638,7 @@ struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
                                         request_fn_proc *request_fn)
 {
        struct request_queue *q;
-       struct device *dev = shost->shost_gendev.parent;
+       struct device *dev = shost->dma_dev;
 
        q = blk_init_queue(request_fn, NULL);
        if (!q)
index 3ed748355b98f629619bdb5ff9e0eae4dbf2bf32..00c024039c9713a7b8468d91f5a7e42316db65d5 100644 (file)
@@ -74,7 +74,7 @@ config SPI_ATMEL
          This selects a driver for the Atmel SPI Controller, present on
          many AT32 (AVR32) and AT91 (ARM) chips.
 
-config SPI_BFIN
+config SPI_BFIN5XX
        tristate "SPI controller driver for ADI Blackfin5xx"
        depends on BLACKFIN
        help
index a1d48e0ba3dc91ad5e7ba8691be345ed5f1cc428..9d75d2198ff58bcce9ca60e587b72112a0b3c292 100644 (file)
@@ -15,7 +15,7 @@ obj-$(CONFIG_SPI_ATMEL)                       += spi-atmel.o
 obj-$(CONFIG_SPI_ATH79)                        += spi-ath79.o
 obj-$(CONFIG_SPI_AU1550)               += spi-au1550.o
 obj-$(CONFIG_SPI_BCM63XX)              += spi-bcm63xx.o
-obj-$(CONFIG_SPI_BFIN)                 += spi-bfin5xx.o
+obj-$(CONFIG_SPI_BFIN5XX)              += spi-bfin5xx.o
 obj-$(CONFIG_SPI_BFIN_SPORT)           += spi-bfin-sport.o
 obj-$(CONFIG_SPI_BITBANG)              += spi-bitbang.o
 obj-$(CONFIG_SPI_BUTTERFLY)            += spi-butterfly.o
index f01b2648452e61887ce7a8712d8b91dd15559d11..7491971139a63000aac97854132645fe5125fff4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom BCM63xx SPI controller support
  *
- * Copyright (C) 2009-2011 Florian Fainelli <florian@openwrt.org>
+ * Copyright (C) 2009-2012 Florian Fainelli <florian@openwrt.org>
  * Copyright (C) 2010 Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com>
  *
  * This program is free software; you can redistribute it and/or
@@ -30,6 +30,8 @@
 #include <linux/spi/spi.h>
 #include <linux/completion.h>
 #include <linux/err.h>
+#include <linux/workqueue.h>
+#include <linux/pm_runtime.h>
 
 #include <bcm63xx_dev_spi.h>
 
@@ -37,8 +39,6 @@
 #define DRV_VER                "0.1.2"
 
 struct bcm63xx_spi {
-       spinlock_t              lock;
-       int                     stopping;
        struct completion       done;
 
        void __iomem            *regs;
@@ -96,17 +96,12 @@ static const unsigned bcm63xx_spi_freq_table[SPI_CLK_MASK][2] = {
        {   391000, SPI_CLK_0_391MHZ }
 };
 
-static int bcm63xx_spi_setup_transfer(struct spi_device *spi,
-                                     struct spi_transfer *t)
+static int bcm63xx_spi_check_transfer(struct spi_device *spi,
+                                       struct spi_transfer *t)
 {
-       struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
        u8 bits_per_word;
-       u8 clk_cfg, reg;
-       u32 hz;
-       int i;
 
        bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word;
-       hz = (t) ? t->speed_hz : spi->max_speed_hz;
        if (bits_per_word != 8) {
                dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
                        __func__, bits_per_word);
@@ -119,6 +114,19 @@ static int bcm63xx_spi_setup_transfer(struct spi_device *spi,
                return -EINVAL;
        }
 
+       return 0;
+}
+
+static void bcm63xx_spi_setup_transfer(struct spi_device *spi,
+                                     struct spi_transfer *t)
+{
+       struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
+       u32 hz;
+       u8 clk_cfg, reg;
+       int i;
+
+       hz = (t) ? t->speed_hz : spi->max_speed_hz;
+
        /* Find the closest clock configuration */
        for (i = 0; i < SPI_CLK_MASK; i++) {
                if (hz <= bcm63xx_spi_freq_table[i][0]) {
@@ -139,8 +147,6 @@ static int bcm63xx_spi_setup_transfer(struct spi_device *spi,
        bcm_spi_writeb(bs, reg, SPI_CLK_CFG);
        dev_dbg(&spi->dev, "Setting clock register to %02x (hz %d)\n",
                clk_cfg, hz);
-
-       return 0;
 }
 
 /* the spi->mode bits understood by this driver: */
@@ -153,9 +159,6 @@ static int bcm63xx_spi_setup(struct spi_device *spi)
 
        bs = spi_master_get_devdata(spi->master);
 
-       if (bs->stopping)
-               return -ESHUTDOWN;
-
        if (!spi->bits_per_word)
                spi->bits_per_word = 8;
 
@@ -165,7 +168,7 @@ static int bcm63xx_spi_setup(struct spi_device *spi)
                return -EINVAL;
        }
 
-       ret = bcm63xx_spi_setup_transfer(spi, NULL);
+       ret = bcm63xx_spi_check_transfer(spi, NULL);
        if (ret < 0) {
                dev_err(&spi->dev, "setup: unsupported mode bits %x\n",
                        spi->mode & ~MODEBITS);
@@ -190,28 +193,29 @@ static void bcm63xx_spi_fill_tx_fifo(struct bcm63xx_spi *bs)
        bs->remaining_bytes -= size;
 }
 
-static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
+static unsigned int bcm63xx_txrx_bufs(struct spi_device *spi,
+                                       struct spi_transfer *t)
 {
        struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
        u16 msg_ctl;
        u16 cmd;
 
+       /* Disable the CMD_DONE interrupt */
+       bcm_spi_writeb(bs, 0, SPI_INT_MASK);
+
        dev_dbg(&spi->dev, "txrx: tx %p, rx %p, len %d\n",
                t->tx_buf, t->rx_buf, t->len);
 
        /* Transmitter is inhibited */
        bs->tx_ptr = t->tx_buf;
        bs->rx_ptr = t->rx_buf;
-       init_completion(&bs->done);
 
        if (t->tx_buf) {
                bs->remaining_bytes = t->len;
                bcm63xx_spi_fill_tx_fifo(bs);
        }
 
-       /* Enable the command done interrupt which
-        * we use to determine completion of a command */
-       bcm_spi_writeb(bs, SPI_INTR_CMD_DONE, SPI_INT_MASK);
+       init_completion(&bs->done);
 
        /* Fill in the Message control register */
        msg_ctl = (t->len << SPI_BYTE_CNT_SHIFT);
@@ -230,33 +234,76 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
        cmd |= (0 << SPI_CMD_PREPEND_BYTE_CNT_SHIFT);
        cmd |= (spi->chip_select << SPI_CMD_DEVICE_ID_SHIFT);
        bcm_spi_writew(bs, cmd, SPI_CMD);
-       wait_for_completion(&bs->done);
 
-       /* Disable the CMD_DONE interrupt */
-       bcm_spi_writeb(bs, 0, SPI_INT_MASK);
+       /* Enable the CMD_DONE interrupt */
+       bcm_spi_writeb(bs, SPI_INTR_CMD_DONE, SPI_INT_MASK);
 
        return t->len - bs->remaining_bytes;
 }
 
-static int bcm63xx_transfer(struct spi_device *spi, struct spi_message *m)
+static int bcm63xx_spi_prepare_transfer(struct spi_master *master)
 {
-       struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
-       struct spi_transfer *t;
-       int ret = 0;
+       struct bcm63xx_spi *bs = spi_master_get_devdata(master);
 
-       if (unlikely(list_empty(&m->transfers)))
-               return -EINVAL;
+       pm_runtime_get_sync(&bs->pdev->dev);
 
-       if (bs->stopping)
-               return -ESHUTDOWN;
+       return 0;
+}
+
+static int bcm63xx_spi_unprepare_transfer(struct spi_master *master)
+{
+       struct bcm63xx_spi *bs = spi_master_get_devdata(master);
+
+       pm_runtime_put(&bs->pdev->dev);
+
+       return 0;
+}
+
+static int bcm63xx_spi_transfer_one(struct spi_master *master,
+                                       struct spi_message *m)
+{
+       struct bcm63xx_spi *bs = spi_master_get_devdata(master);
+       struct spi_transfer *t;
+       struct spi_device *spi = m->spi;
+       int status = 0;
+       unsigned int timeout = 0;
 
        list_for_each_entry(t, &m->transfers, transfer_list) {
-               ret += bcm63xx_txrx_bufs(spi, t);
-       }
+               unsigned int len = t->len;
+               u8 rx_tail;
 
-       m->complete(m->context);
+               status = bcm63xx_spi_check_transfer(spi, t);
+               if (status < 0)
+                       goto exit;
 
-       return ret;
+               /* configure adapter for a new transfer */
+               bcm63xx_spi_setup_transfer(spi, t);
+
+               while (len) {
+                       /* send the data */
+                       len -= bcm63xx_txrx_bufs(spi, t);
+
+                       timeout = wait_for_completion_timeout(&bs->done, HZ);
+                       if (!timeout) {
+                               status = -ETIMEDOUT;
+                               goto exit;
+                       }
+
+                       /* read out all data */
+                       rx_tail = bcm_spi_readb(bs, SPI_RX_TAIL);
+
+                       /* Read out all the data */
+                       if (rx_tail)
+                               memcpy_fromio(bs->rx_ptr, bs->rx_io, rx_tail);
+               }
+
+               m->actual_length += t->len;
+       }
+exit:
+       m->status = status;
+       spi_finalize_current_message(master);
+
+       return 0;
 }
 
 /* This driver supports single master mode only. Hence
@@ -267,39 +314,15 @@ static irqreturn_t bcm63xx_spi_interrupt(int irq, void *dev_id)
        struct spi_master *master = (struct spi_master *)dev_id;
        struct bcm63xx_spi *bs = spi_master_get_devdata(master);
        u8 intr;
-       u16 cmd;
 
        /* Read interupts and clear them immediately */
        intr = bcm_spi_readb(bs, SPI_INT_STATUS);
        bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS);
        bcm_spi_writeb(bs, 0, SPI_INT_MASK);
 
-       /* A tansfer completed */
-       if (intr & SPI_INTR_CMD_DONE) {
-               u8 rx_tail;
-
-               rx_tail = bcm_spi_readb(bs, SPI_RX_TAIL);
-
-               /* Read out all the data */
-               if (rx_tail)
-                       memcpy_fromio(bs->rx_ptr, bs->rx_io, rx_tail);
-
-               /* See if there is more data to send */
-               if (bs->remaining_bytes > 0) {
-                       bcm63xx_spi_fill_tx_fifo(bs);
-
-                       /* Start the transfer */
-                       bcm_spi_writew(bs, SPI_HD_W << SPI_MSG_TYPE_SHIFT,
-                                      SPI_MSG_CTL);
-                       cmd = bcm_spi_readw(bs, SPI_CMD);
-                       cmd |= SPI_CMD_START_IMMEDIATE;
-                       cmd |= (0 << SPI_CMD_PREPEND_BYTE_CNT_SHIFT);
-                       bcm_spi_writeb(bs, SPI_INTR_CMD_DONE, SPI_INT_MASK);
-                       bcm_spi_writew(bs, cmd, SPI_CMD);
-               } else {
-                       complete(&bs->done);
-               }
-       }
+       /* A transfer completed */
+       if (intr & SPI_INTR_CMD_DONE)
+               complete(&bs->done);
 
        return IRQ_HANDLED;
 }
@@ -345,7 +368,6 @@ static int __devinit bcm63xx_spi_probe(struct platform_device *pdev)
        }
 
        bs = spi_master_get_devdata(master);
-       init_completion(&bs->done);
 
        platform_set_drvdata(pdev, master);
        bs->pdev = pdev;
@@ -379,12 +401,13 @@ static int __devinit bcm63xx_spi_probe(struct platform_device *pdev)
        master->bus_num = pdata->bus_num;
        master->num_chipselect = pdata->num_chipselect;
        master->setup = bcm63xx_spi_setup;
-       master->transfer = bcm63xx_transfer;
+       master->prepare_transfer_hardware = bcm63xx_spi_prepare_transfer;
+       master->unprepare_transfer_hardware = bcm63xx_spi_unprepare_transfer;
+       master->transfer_one_message = bcm63xx_spi_transfer_one;
+       master->mode_bits = MODEBITS;
        bs->speed_hz = pdata->speed_hz;
-       bs->stopping = 0;
        bs->tx_io = (u8 *)(bs->regs + bcm63xx_spireg(SPI_MSG_DATA));
        bs->rx_io = (const u8 *)(bs->regs + bcm63xx_spireg(SPI_RX_DATA));
-       spin_lock_init(&bs->lock);
 
        /* Initialize hardware */
        clk_enable(bs->clk);
@@ -418,18 +441,16 @@ static int __devexit bcm63xx_spi_remove(struct platform_device *pdev)
        struct spi_master *master = platform_get_drvdata(pdev);
        struct bcm63xx_spi *bs = spi_master_get_devdata(master);
 
+       spi_unregister_master(master);
+
        /* reset spi block */
        bcm_spi_writeb(bs, 0, SPI_INT_MASK);
-       spin_lock(&bs->lock);
-       bs->stopping = 1;
 
        /* HW shutdown */
        clk_disable(bs->clk);
        clk_put(bs->clk);
 
-       spin_unlock(&bs->lock);
        platform_set_drvdata(pdev, 0);
-       spi_unregister_master(master);
 
        return 0;
 }
index 248a2cc671a9bc8e6c6a83c5b515557f432c7841..1fe51198a62292310473d22d4bdbb502cf6cf304 100644 (file)
@@ -252,19 +252,15 @@ static void
 bfin_sport_spi_restore_state(struct bfin_sport_spi_master_data *drv_data)
 {
        struct bfin_sport_spi_slave_data *chip = drv_data->cur_chip;
-       unsigned int bits = (drv_data->ops == &bfin_sport_transfer_ops_u8 ? 7 : 15);
 
        bfin_sport_spi_disable(drv_data);
        dev_dbg(drv_data->dev, "restoring spi ctl state\n");
 
        bfin_write(&drv_data->regs->tcr1, chip->ctl_reg);
-       bfin_write(&drv_data->regs->tcr2, bits);
        bfin_write(&drv_data->regs->tclkdiv, chip->baud);
-       bfin_write(&drv_data->regs->tfsdiv, bits);
        SSYNC();
 
        bfin_write(&drv_data->regs->rcr1, chip->ctl_reg & ~(ITCLK | ITFS));
-       bfin_write(&drv_data->regs->rcr2, bits);
        SSYNC();
 
        bfin_sport_spi_cs_active(chip);
@@ -420,11 +416,15 @@ bfin_sport_spi_pump_transfers(unsigned long data)
        drv_data->cs_change = transfer->cs_change;
 
        /* Bits per word setup */
-       bits_per_word = transfer->bits_per_word ? : message->spi->bits_per_word;
-       if (bits_per_word == 8)
-               drv_data->ops = &bfin_sport_transfer_ops_u8;
-       else
+       bits_per_word = transfer->bits_per_word ? :
+               message->spi->bits_per_word ? : 8;
+       if (bits_per_word % 16 == 0)
                drv_data->ops = &bfin_sport_transfer_ops_u16;
+       else
+               drv_data->ops = &bfin_sport_transfer_ops_u8;
+       bfin_write(&drv_data->regs->tcr2, bits_per_word - 1);
+       bfin_write(&drv_data->regs->tfsdiv, bits_per_word - 1);
+       bfin_write(&drv_data->regs->rcr2, bits_per_word - 1);
 
        drv_data->state = RUNNING_STATE;
 
@@ -598,11 +598,12 @@ bfin_sport_spi_setup(struct spi_device *spi)
                        }
                        chip->cs_chg_udelay = chip_info->cs_chg_udelay;
                        chip->idle_tx_val = chip_info->idle_tx_val;
-                       spi->bits_per_word = chip_info->bits_per_word;
                }
        }
 
-       if (spi->bits_per_word != 8 && spi->bits_per_word != 16) {
+       if (spi->bits_per_word % 8) {
+               dev_err(&spi->dev, "%d bits_per_word is not supported\n",
+                               spi->bits_per_word);
                ret = -EINVAL;
                goto error;
        }
index 3b83ff8b1e2b7ac60fb5494347fbc2a189b6dc14..9bb4d4af85475f8cfed48dce4530598fd45cc73d 100644 (file)
@@ -396,7 +396,7 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
                /* last read */
                if (drv_data->rx) {
                        dev_dbg(&drv_data->pdev->dev, "last read\n");
-                       if (n_bytes % 2) {
+                       if (!(n_bytes % 2)) {
                                u16 *buf = (u16 *)drv_data->rx;
                                for (loop = 0; loop < n_bytes / 2; loop++)
                                        *buf++ = bfin_read(&drv_data->regs->rdbr);
@@ -424,7 +424,7 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
        if (drv_data->rx && drv_data->tx) {
                /* duplex */
                dev_dbg(&drv_data->pdev->dev, "duplex: write_TDBR\n");
-               if (n_bytes % 2) {
+               if (!(n_bytes % 2)) {
                        u16 *buf = (u16 *)drv_data->rx;
                        u16 *buf2 = (u16 *)drv_data->tx;
                        for (loop = 0; loop < n_bytes / 2; loop++) {
@@ -442,7 +442,7 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
        } else if (drv_data->rx) {
                /* read */
                dev_dbg(&drv_data->pdev->dev, "read: write_TDBR\n");
-               if (n_bytes % 2) {
+               if (!(n_bytes % 2)) {
                        u16 *buf = (u16 *)drv_data->rx;
                        for (loop = 0; loop < n_bytes / 2; loop++) {
                                *buf++ = bfin_read(&drv_data->regs->rdbr);
@@ -458,7 +458,7 @@ static irqreturn_t bfin_spi_pio_irq_handler(int irq, void *dev_id)
        } else if (drv_data->tx) {
                /* write */
                dev_dbg(&drv_data->pdev->dev, "write: write_TDBR\n");
-               if (n_bytes % 2) {
+               if (!(n_bytes % 2)) {
                        u16 *buf = (u16 *)drv_data->tx;
                        for (loop = 0; loop < n_bytes / 2; loop++) {
                                bfin_read(&drv_data->regs->rdbr);
@@ -587,6 +587,7 @@ static void bfin_spi_pump_transfers(unsigned long data)
        if (message->state == DONE_STATE) {
                dev_dbg(&drv_data->pdev->dev, "transfer: all done!\n");
                message->status = 0;
+               bfin_spi_flush(drv_data);
                bfin_spi_giveback(drv_data);
                return;
        }
@@ -870,8 +871,10 @@ static void bfin_spi_pump_transfers(unsigned long data)
                message->actual_length += drv_data->len_in_bytes;
                /* Move to next transfer of this msg */
                message->state = bfin_spi_next_transfer(drv_data);
-               if (drv_data->cs_change)
+               if (drv_data->cs_change && message->state != DONE_STATE) {
+                       bfin_spi_flush(drv_data);
                        bfin_spi_cs_deactive(drv_data, chip);
+               }
        }
 
        /* Schedule next transfer tasklet */
@@ -1026,7 +1029,6 @@ static int bfin_spi_setup(struct spi_device *spi)
                chip->cs_chg_udelay = chip_info->cs_chg_udelay;
                chip->idle_tx_val = chip_info->idle_tx_val;
                chip->pio_interrupt = chip_info->pio_interrupt;
-               spi->bits_per_word = chip_info->bits_per_word;
        } else {
                /* force a default base state */
                chip->ctl_reg &= bfin_ctl_reg;
index 6db2887852d6befe327b53cacdf2731b8328c68b..e8055073e84df898bbd0e281745bf633377a5eda 100644 (file)
@@ -545,13 +545,12 @@ static void ep93xx_spi_pio_transfer(struct ep93xx_spi *espi)
  * in case of failure.
  */
 static struct dma_async_tx_descriptor *
-ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_data_direction dir)
+ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_transfer_direction dir)
 {
        struct spi_transfer *t = espi->current_msg->state;
        struct dma_async_tx_descriptor *txd;
        enum dma_slave_buswidth buswidth;
        struct dma_slave_config conf;
-       enum dma_transfer_direction slave_dirn;
        struct scatterlist *sg;
        struct sg_table *sgt;
        struct dma_chan *chan;
@@ -567,14 +566,13 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_data_direction dir)
        memset(&conf, 0, sizeof(conf));
        conf.direction = dir;
 
-       if (dir == DMA_FROM_DEVICE) {
+       if (dir == DMA_DEV_TO_MEM) {
                chan = espi->dma_rx;
                buf = t->rx_buf;
                sgt = &espi->rx_sgt;
 
                conf.src_addr = espi->sspdr_phys;
                conf.src_addr_width = buswidth;
-               slave_dirn = DMA_DEV_TO_MEM;
        } else {
                chan = espi->dma_tx;
                buf = t->tx_buf;
@@ -582,7 +580,6 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_data_direction dir)
 
                conf.dst_addr = espi->sspdr_phys;
                conf.dst_addr_width = buswidth;
-               slave_dirn = DMA_MEM_TO_DEV;
        }
 
        ret = dmaengine_slave_config(chan, &conf);
@@ -633,8 +630,7 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_data_direction dir)
        if (!nents)
                return ERR_PTR(-ENOMEM);
 
-       txd = dmaengine_prep_slave_sg(chan, sgt->sgl, nents,
-                                       slave_dirn, DMA_CTRL_ACK);
+       txd = dmaengine_prep_slave_sg(chan, sgt->sgl, nents, dir, DMA_CTRL_ACK);
        if (!txd) {
                dma_unmap_sg(chan->device->dev, sgt->sgl, sgt->nents, dir);
                return ERR_PTR(-ENOMEM);
@@ -651,12 +647,12 @@ ep93xx_spi_dma_prepare(struct ep93xx_spi *espi, enum dma_data_direction dir)
  * unmapped.
  */
 static void ep93xx_spi_dma_finish(struct ep93xx_spi *espi,
-                                 enum dma_data_direction dir)
+                                 enum dma_transfer_direction dir)
 {
        struct dma_chan *chan;
        struct sg_table *sgt;
 
-       if (dir == DMA_FROM_DEVICE) {
+       if (dir == DMA_DEV_TO_MEM) {
                chan = espi->dma_rx;
                sgt = &espi->rx_sgt;
        } else {
@@ -677,16 +673,16 @@ static void ep93xx_spi_dma_transfer(struct ep93xx_spi *espi)
        struct spi_message *msg = espi->current_msg;
        struct dma_async_tx_descriptor *rxd, *txd;
 
-       rxd = ep93xx_spi_dma_prepare(espi, DMA_FROM_DEVICE);
+       rxd = ep93xx_spi_dma_prepare(espi, DMA_DEV_TO_MEM);
        if (IS_ERR(rxd)) {
                dev_err(&espi->pdev->dev, "DMA RX failed: %ld\n", PTR_ERR(rxd));
                msg->status = PTR_ERR(rxd);
                return;
        }
 
-       txd = ep93xx_spi_dma_prepare(espi, DMA_TO_DEVICE);
+       txd = ep93xx_spi_dma_prepare(espi, DMA_MEM_TO_DEV);
        if (IS_ERR(txd)) {
-               ep93xx_spi_dma_finish(espi, DMA_FROM_DEVICE);
+               ep93xx_spi_dma_finish(espi, DMA_DEV_TO_MEM);
                dev_err(&espi->pdev->dev, "DMA TX failed: %ld\n", PTR_ERR(rxd));
                msg->status = PTR_ERR(txd);
                return;
@@ -705,8 +701,8 @@ static void ep93xx_spi_dma_transfer(struct ep93xx_spi *espi)
 
        wait_for_completion(&espi->wait);
 
-       ep93xx_spi_dma_finish(espi, DMA_TO_DEVICE);
-       ep93xx_spi_dma_finish(espi, DMA_FROM_DEVICE);
+       ep93xx_spi_dma_finish(espi, DMA_MEM_TO_DEV);
+       ep93xx_spi_dma_finish(espi, DMA_DEV_TO_MEM);
 }
 
 /**
index 570f22053be89fb56d99b464ecc36a9443e2cc8d..4b6688630b9c3297ba4b861d7aed53993bcc6769 100644 (file)
@@ -85,7 +85,8 @@ struct spi_imx_data {
        struct completion xfer_done;
        void __iomem *base;
        int irq;
-       struct clk *clk;
+       struct clk *clk_per;
+       struct clk *clk_ipg;
        unsigned long spi_clk;
 
        unsigned int count;
@@ -845,15 +846,22 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
                goto out_iounmap;
        }
 
-       spi_imx->clk = clk_get(&pdev->dev, NULL);
-       if (IS_ERR(spi_imx->clk)) {
-               dev_err(&pdev->dev, "unable to get clock\n");
-               ret = PTR_ERR(spi_imx->clk);
+       spi_imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+       if (IS_ERR(spi_imx->clk_ipg)) {
+               ret = PTR_ERR(spi_imx->clk_ipg);
                goto out_free_irq;
        }
 
-       clk_enable(spi_imx->clk);
-       spi_imx->spi_clk = clk_get_rate(spi_imx->clk);
+       spi_imx->clk_per = devm_clk_get(&pdev->dev, "per");
+       if (IS_ERR(spi_imx->clk_per)) {
+               ret = PTR_ERR(spi_imx->clk_per);
+               goto out_free_irq;
+       }
+
+       clk_prepare_enable(spi_imx->clk_per);
+       clk_prepare_enable(spi_imx->clk_ipg);
+
+       spi_imx->spi_clk = clk_get_rate(spi_imx->clk_per);
 
        spi_imx->devtype_data->reset(spi_imx);
 
@@ -871,8 +879,8 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
        return ret;
 
 out_clk_put:
-       clk_disable(spi_imx->clk);
-       clk_put(spi_imx->clk);
+       clk_disable_unprepare(spi_imx->clk_per);
+       clk_disable_unprepare(spi_imx->clk_ipg);
 out_free_irq:
        free_irq(spi_imx->irq, spi_imx);
 out_iounmap:
@@ -900,8 +908,8 @@ static int __devexit spi_imx_remove(struct platform_device *pdev)
        spi_bitbang_stop(&spi_imx->bitbang);
 
        writel(0, spi_imx->base + MXC_CSPICTRL);
-       clk_disable(spi_imx->clk);
-       clk_put(spi_imx->clk);
+       clk_disable_unprepare(spi_imx->clk_per);
+       clk_disable_unprepare(spi_imx->clk_ipg);
        free_irq(spi_imx->irq, spi_imx);
        iounmap(spi_imx->base);
 
index 09c925aaf3207dac61b61278cfdddf0f59b39f4c..400ae2121a2a48cd1c78469f0c727972b180a777 100644 (file)
@@ -1667,9 +1667,15 @@ static int calculate_effective_freq(struct pl022 *pl022, int freq, struct
        /* cpsdvsr = 254 & scr = 255 */
        min_tclk = spi_rate(rate, CPSDVR_MAX, SCR_MAX);
 
-       if (!((freq <= max_tclk) && (freq >= min_tclk))) {
+       if (freq > max_tclk)
+               dev_warn(&pl022->adev->dev,
+                       "Max speed that can be programmed is %d Hz, you requested %d\n",
+                       max_tclk, freq);
+
+       if (freq < min_tclk) {
                dev_err(&pl022->adev->dev,
-                       "controller data is incorrect: out of range frequency");
+                       "Requested frequency: %d Hz is less than minimum possible %d Hz\n",
+                       freq, min_tclk);
                return -EINVAL;
        }
 
@@ -1681,26 +1687,37 @@ static int calculate_effective_freq(struct pl022 *pl022, int freq, struct
                while (scr <= SCR_MAX) {
                        tmp = spi_rate(rate, cpsdvsr, scr);
 
-                       if (tmp > freq)
+                       if (tmp > freq) {
+                               /* we need lower freq */
                                scr++;
+                               continue;
+                       }
+
                        /*
-                        * If found exact value, update and break.
-                        * If found more closer value, update and continue.
+                        * If found exact value, mark found and break.
+                        * If found more closer value, update and break.
                         */
-                       else if ((tmp == freq) || (tmp > best_freq)) {
+                       if (tmp > best_freq) {
                                best_freq = tmp;
                                best_cpsdvsr = cpsdvsr;
                                best_scr = scr;
 
                                if (tmp == freq)
-                                       break;
+                                       found = 1;
                        }
-                       scr++;
+                       /*
+                        * increased scr will give lower rates, which are not
+                        * required
+                        */
+                       break;
                }
                cpsdvsr += 2;
                scr = SCR_MIN;
        }
 
+       WARN(!best_freq, "pl022: Matching cpsdvsr and scr not found for %d Hz rate \n",
+                       freq);
+
        clk_freq->cpsdvsr = (u8) (best_cpsdvsr & 0xFF);
        clk_freq->scr = (u8) (best_scr & 0xFF);
        dev_dbg(&pl022->adev->dev,
@@ -1823,9 +1840,12 @@ static int pl022_setup(struct spi_device *spi)
        } else
                chip->cs_control = chip_info->cs_control;
 
-       if (bits <= 3) {
-               /* PL022 doesn't support less than 4-bits */
+       /* Check bits per word with vendor specific range */
+       if ((bits <= 3) || (bits > pl022->vendor->max_bpw)) {
                status = -ENOTSUPP;
+               dev_err(&spi->dev, "illegal data size for this controller!\n");
+               dev_err(&spi->dev, "This controller can only handle 4 <= n <= %d bit words\n",
+                               pl022->vendor->max_bpw);
                goto err_config_params;
        } else if (bits <= 8) {
                dev_dbg(&spi->dev, "4 <= n <=8 bits per word\n");
@@ -1838,20 +1858,10 @@ static int pl022_setup(struct spi_device *spi)
                chip->read = READING_U16;
                chip->write = WRITING_U16;
        } else {
-               if (pl022->vendor->max_bpw >= 32) {
-                       dev_dbg(&spi->dev, "17 <= n <= 32 bits per word\n");
-                       chip->n_bytes = 4;
-                       chip->read = READING_U32;
-                       chip->write = WRITING_U32;
-               } else {
-                       dev_err(&spi->dev,
-                               "illegal data size for this controller!\n");
-                       dev_err(&spi->dev,
-                               "a standard pl022 can only handle "
-                               "1 <= n <= 16 bit words\n");
-                       status = -ENOTSUPP;
-                       goto err_config_params;
-               }
+               dev_dbg(&spi->dev, "17 <= n <= 32 bits per word\n");
+               chip->n_bytes = 4;
+               chip->read = READING_U32;
+               chip->write = WRITING_U32;
        }
 
        /* Now Initialize all register settings required for this chip */
index 400df8cbee538b55a50e7baa92ceb18cae9e28c5..d91751f9ffe860372d070be165b49d128d9dce45 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/prefetch.h>
 #include <linux/ratelimit.h>
 #include <linux/smp.h>
+#include <linux/interrupt.h>
 #include <net/dst.h>
 #ifdef CONFIG_XFRM
 #include <linux/xfrm.h>
index 56d74dc2fbd5b5f3b7122371554d51647b5effb9..91a97b3e45c67b718fdf15a90b6348d58c43f4a0 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/ip.h>
 #include <linux/ratelimit.h>
 #include <linux/string.h>
+#include <linux/interrupt.h>
 #include <net/dst.h>
 #ifdef CONFIG_XFRM
 #include <linux/xfrm.h>
index 9112cd8821540f692acfd5559183ad125459f73c..60cba8194de341c4aef6d4e565e7456ae7cc381e 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/etherdevice.h>
 #include <linux/phy.h>
 #include <linux/slab.h>
+#include <linux/interrupt.h>
 
 #include <net/dst.h>
 
index 2b45d3d1800c13bc1a6341a9b5c5d2c8f4048086..04cd57f2a6da50eea26b54e163eef6f39af91c1a 100644 (file)
@@ -383,8 +383,6 @@ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f)
                pd->tx_pool = &f->link;
                pd->tx_pool_count++;
                f = 0;
-       } else {
-               kfree(f);
        }
        spin_unlock_bh(&pd->tx_frame_lock);
        if (f)
index 7862513cc295449cf5479d5ff148b366effb9d8f..9cf29fcea11e58700c8010e7249fec7516042190 100644 (file)
 #define OMAP343X_CONTROL_IVA2_BOOTADDR (OMAP2_CONTROL_GENERAL + 0x0190)
 #define OMAP343X_CONTROL_IVA2_BOOTMOD (OMAP2_CONTROL_GENERAL + 0x0194)
 
-#define OMAP343X_CTRL_REGADDR(reg) \
-       OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE + (reg))
-
-
 /* Forward Declarations: */
 static int bridge_brd_monitor(struct bridge_dev_context *dev_ctxt);
 static int bridge_brd_read(struct bridge_dev_context *dev_ctxt,
@@ -418,19 +414,27 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
 
                /* Assert RST1 i.e only the RST only for DSP megacell */
                if (!status) {
+                       /*
+                        * XXX: ioremapping  MUST be removed once ctrl
+                        * function is made available.
+                        */
+                       void __iomem *ctrl = ioremap(OMAP343X_CTRL_BASE, SZ_4K);
+                       if (!ctrl)
+                               return -ENOMEM;
+
                        (*pdata->dsp_prm_rmw_bits)(OMAP3430_RST1_IVA2_MASK,
                                        OMAP3430_RST1_IVA2_MASK, OMAP3430_IVA2_MOD,
                                        OMAP2_RM_RSTCTRL);
                        /* Mask address with 1K for compatibility */
                        __raw_writel(dsp_addr & OMAP3_IVA2_BOOTADDR_MASK,
-                                       OMAP343X_CTRL_REGADDR(
-                                       OMAP343X_CONTROL_IVA2_BOOTADDR));
+                                       ctrl + OMAP343X_CONTROL_IVA2_BOOTADDR);
                        /*
                         * Set bootmode to self loop if dsp_debug flag is true
                         */
                        __raw_writel((dsp_debug) ? OMAP3_IVA2_BOOTMOD_IDLE : 0,
-                                       OMAP343X_CTRL_REGADDR(
-                                       OMAP343X_CONTROL_IVA2_BOOTMOD));
+                                       ctrl + OMAP343X_CONTROL_IVA2_BOOTMOD);
+
+                       iounmap(ctrl);
                }
        }
        if (!status) {
index 70055c8111ed2d208162dbcd7f93f3b6c52c70c7..870f934f4f3bee4002e0400ba77afc96e155cc23 100644 (file)
@@ -53,7 +53,10 @@ int dsp_wdt_init(void)
        int ret = 0;
 
        dsp_wdt.sm_wdt = NULL;
-       dsp_wdt.reg_base = OMAP2_L4_IO_ADDRESS(OMAP34XX_WDT3_BASE);
+       dsp_wdt.reg_base = ioremap(OMAP34XX_WDT3_BASE, SZ_4K);
+       if (!dsp_wdt.reg_base)
+               return -ENOMEM;
+
        tasklet_init(&dsp_wdt.wdt3_tasklet, dsp_wdt_dpc, 0);
 
        dsp_wdt.fclk = clk_get(NULL, "wdt3_fck");
@@ -99,6 +102,9 @@ void dsp_wdt_exit(void)
        dsp_wdt.fclk = NULL;
        dsp_wdt.iclk = NULL;
        dsp_wdt.sm_wdt = NULL;
+
+       if (dsp_wdt.reg_base)
+               iounmap(dsp_wdt.reg_base);
        dsp_wdt.reg_base = NULL;
 }
 
index 3ed2c8f656a52d8ce46eae00e6ff908314a507fa..7048e01f081714bf506c1c4f83f6e6740faacb7b 100644 (file)
@@ -2,7 +2,7 @@ config ZCACHE
        bool "Dynamic compression of swap pages and clean pagecache pages"
        # X86 dependency is because zsmalloc uses non-portable pte/tlb
        # functions
-       depends on (CLEANCACHE || FRONTSWAP) && CRYPTO && X86
+       depends on (CLEANCACHE || FRONTSWAP) && CRYPTO=y && X86
        select ZSMALLOC
        select CRYPTO_LZO
        default n
index e7feceeebc2fc9be490e3325e92f317fde5feedb..267ec6da5af2d06a6651d48f2094699cbb1a1d7f 100644 (file)
@@ -204,7 +204,8 @@ struct imx_port {
        unsigned int            irda_inv_rx:1;
        unsigned int            irda_inv_tx:1;
        unsigned short          trcv_delay; /* transceiver delay */
-       struct clk              *clk;
+       struct clk              *clk_ipg;
+       struct clk              *clk_per;
        struct imx_uart_data    *devdata;
 };
 
@@ -672,7 +673,7 @@ static int imx_setup_ufcr(struct imx_port *sport, unsigned int mode)
         * RFDIV is set such way to satisfy requested uartclk value
         */
        val = TXTL << 10 | RXTL;
-       ufcr_rfdiv = (clk_get_rate(sport->clk) + sport->port.uartclk / 2)
+       ufcr_rfdiv = (clk_get_rate(sport->clk_per) + sport->port.uartclk / 2)
                        / sport->port.uartclk;
 
        if(!ufcr_rfdiv)
@@ -1285,7 +1286,7 @@ imx_console_get_options(struct imx_port *sport, int *baud,
                else
                        ucfr_rfdiv = 6 - ucfr_rfdiv;
 
-               uartclk = clk_get_rate(sport->clk);
+               uartclk = clk_get_rate(sport->clk_per);
                uartclk /= ucfr_rfdiv;
 
                {       /*
@@ -1503,14 +1504,22 @@ static int serial_imx_probe(struct platform_device *pdev)
        sport->timer.function = imx_timeout;
        sport->timer.data     = (unsigned long)sport;
 
-       sport->clk = clk_get(&pdev->dev, "uart");
-       if (IS_ERR(sport->clk)) {
-               ret = PTR_ERR(sport->clk);
+       sport->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+       if (IS_ERR(sport->clk_ipg)) {
+               ret = PTR_ERR(sport->clk_ipg);
                goto unmap;
        }
-       clk_prepare_enable(sport->clk);
 
-       sport->port.uartclk = clk_get_rate(sport->clk);
+       sport->clk_per = devm_clk_get(&pdev->dev, "per");
+       if (IS_ERR(sport->clk_per)) {
+               ret = PTR_ERR(sport->clk_per);
+               goto unmap;
+       }
+
+       clk_prepare_enable(sport->clk_per);
+       clk_prepare_enable(sport->clk_ipg);
+
+       sport->port.uartclk = clk_get_rate(sport->clk_per);
 
        imx_ports[sport->port.line] = sport;
 
@@ -1531,8 +1540,8 @@ deinit:
        if (pdata && pdata->exit)
                pdata->exit(pdev);
 clkput:
-       clk_disable_unprepare(sport->clk);
-       clk_put(sport->clk);
+       clk_disable_unprepare(sport->clk_per);
+       clk_disable_unprepare(sport->clk_ipg);
 unmap:
        iounmap(sport->port.membase);
 free:
@@ -1550,11 +1559,10 @@ static int serial_imx_remove(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, NULL);
 
-       if (sport) {
-               uart_remove_one_port(&imx_reg, &sport->port);
-               clk_disable_unprepare(sport->clk);
-               clk_put(sport->clk);
-       }
+       uart_remove_one_port(&imx_reg, &sport->port);
+
+       clk_disable_unprepare(sport->clk_per);
+       clk_disable_unprepare(sport->clk_ipg);
 
        if (pdata && pdata->exit)
                pdata->exit(pdev);
index 08ebe901bb59875a95b87148a04d15404523c019..654755a990dfc30cac559567e260b17978bbc54b 100644 (file)
@@ -469,7 +469,7 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id)
        tty = NULL;
        if (r3 & (CHAEXT | CHATxIP | CHARxIP)) {
                if (!ZS_IS_OPEN(uap_a)) {
-                       pmz_debug("ChanA interrupt while open !\n");
+                       pmz_debug("ChanA interrupt while not open !\n");
                        goto skip_a;
                }
                write_zsreg(uap_a, R0, RES_H_IUS);
@@ -493,8 +493,8 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id)
        spin_lock(&uap_b->port.lock);
        tty = NULL;
        if (r3 & (CHBEXT | CHBTxIP | CHBRxIP)) {
-               if (!ZS_IS_OPEN(uap_a)) {
-                       pmz_debug("ChanB interrupt while open !\n");
+               if (!ZS_IS_OPEN(uap_b)) {
+                       pmz_debug("ChanB interrupt while not open !\n");
                        goto skip_b;
                }
                write_zsreg(uap_b, R0, RES_H_IUS);
index 86dd1e302bb3f0989d52ba2b136d1ec39e29c488..29ca20dbd335da2235339b8f7970849f2d22895f 100644 (file)
@@ -1085,15 +1085,21 @@ void vt_set_led_state(int console, int leds)
  *
  *     Handle console start. This is a wrapper for the VT layer
  *     so that we can keep kbd knowledge internal
+ *
+ *     FIXME: We eventually need to hold the kbd lock here to protect
+ *     the LED updating. We can't do it yet because fn_hold calls stop_tty
+ *     and start_tty under the kbd_event_lock, while normal tty paths
+ *     don't hold the lock. We probably need to split out an LED lock
+ *     but not during an -rc release!
  */
 void vt_kbd_con_start(int console)
 {
        struct kbd_struct * kbd = kbd_table + console;
-       unsigned long flags;
-       spin_lock_irqsave(&kbd_event_lock, flags);
+/*     unsigned long flags; */
+/*     spin_lock_irqsave(&kbd_event_lock, flags); */
        clr_vc_kbd_led(kbd, VC_SCROLLOCK);
        set_leds();
-       spin_unlock_irqrestore(&kbd_event_lock, flags);
+/*     spin_unlock_irqrestore(&kbd_event_lock, flags); */
 }
 
 /**
@@ -1102,22 +1108,28 @@ void vt_kbd_con_start(int console)
  *
  *     Handle console stop. This is a wrapper for the VT layer
  *     so that we can keep kbd knowledge internal
+ *
+ *     FIXME: We eventually need to hold the kbd lock here to protect
+ *     the LED updating. We can't do it yet because fn_hold calls stop_tty
+ *     and start_tty under the kbd_event_lock, while normal tty paths
+ *     don't hold the lock. We probably need to split out an LED lock
+ *     but not during an -rc release!
  */
 void vt_kbd_con_stop(int console)
 {
        struct kbd_struct * kbd = kbd_table + console;
-       unsigned long flags;
-       spin_lock_irqsave(&kbd_event_lock, flags);
+/*     unsigned long flags; */
+/*     spin_lock_irqsave(&kbd_event_lock, flags); */
        set_vc_kbd_led(kbd, VC_SCROLLOCK);
        set_leds();
-       spin_unlock_irqrestore(&kbd_event_lock, flags);
+/*     spin_unlock_irqrestore(&kbd_event_lock, flags); */
 }
 
 /*
  * This is the tasklet that updates LED state on all keyboards
  * attached to the box. The reason we use tasklet is that we
  * need to handle the scenario when keyboard handler is not
- * registered yet but we already getting updates form VT to
+ * registered yet but we already getting updates from the VT to
  * update led state.
  */
 static void kbd_bh(unsigned long dummy)
index c6f6560d436c804bba1f539a2b6cd1c12be8633d..0bb2b3248dad99b0e114b83dc1028edd5fadb4a1 100644 (file)
@@ -157,8 +157,9 @@ static void wdm_out_callback(struct urb *urb)
        spin_lock(&desc->iuspin);
        desc->werr = urb->status;
        spin_unlock(&desc->iuspin);
-       clear_bit(WDM_IN_USE, &desc->flags);
        kfree(desc->outbuf);
+       desc->outbuf = NULL;
+       clear_bit(WDM_IN_USE, &desc->flags);
        wake_up(&desc->wait);
 }
 
@@ -338,7 +339,7 @@ static ssize_t wdm_write
        if (we < 0)
                return -EIO;
 
-       desc->outbuf = buf = kmalloc(count, GFP_KERNEL);
+       buf = kmalloc(count, GFP_KERNEL);
        if (!buf) {
                rv = -ENOMEM;
                goto outnl;
@@ -406,10 +407,12 @@ static ssize_t wdm_write
        req->wIndex = desc->inum;
        req->wLength = cpu_to_le16(count);
        set_bit(WDM_IN_USE, &desc->flags);
+       desc->outbuf = buf;
 
        rv = usb_submit_urb(desc->command, GFP_KERNEL);
        if (rv < 0) {
                kfree(buf);
+               desc->outbuf = NULL;
                clear_bit(WDM_IN_USE, &desc->flags);
                dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv);
        } else {
index 622b4a48e732e7a83b6c760d6563994394b0caa9..57ed9e400c06d938a91fd9713b95a9e97030b3a3 100644 (file)
@@ -493,6 +493,15 @@ static int hcd_pci_suspend_noirq(struct device *dev)
 
        pci_save_state(pci_dev);
 
+       /*
+        * Some systems crash if an EHCI controller is in D3 during
+        * a sleep transition.  We have to leave such controllers in D0.
+        */
+       if (hcd->broken_pci_sleep) {
+               dev_dbg(dev, "Staying in PCI D0\n");
+               return retval;
+       }
+
        /* If the root hub is dead rather than suspended, disallow remote
         * wakeup.  usb_hc_died() should ensure that both hosts are marked as
         * dying, so we only need to check the primary roothub.
index a6dfd21641661c08df7a524850ee6ccf670a4f3e..170cbe89d9f8ad47b9bb6ee54596521012c8de7f 100644 (file)
@@ -927,7 +927,6 @@ static int dummy_udc_stop(struct usb_gadget *g,
 
        dum->driver = NULL;
 
-       dummy_pullup(&dum->gadget, 0);
        return 0;
 }
 
index a371e966425fce2ccf391e13d2d523f02bee52c3..cb8c162cae5af059c5c8cce2c07679b9b3611177 100644 (file)
@@ -2189,7 +2189,7 @@ unknown_cmnd:
                common->data_size_from_cmnd = 0;
                sprintf(unknown, "Unknown x%02x", common->cmnd[0]);
                reply = check_command(common, common->cmnd_size,
-                                     DATA_DIR_UNKNOWN, 0xff, 0, unknown);
+                                     DATA_DIR_UNKNOWN, ~0, 0, unknown);
                if (reply == 0) {
                        common->curlun->sense_data = SS_INVALID_COMMAND;
                        reply = -EINVAL;
index 4fac569277411b45815aa1ff6d3ffe3d398d3623..a896d73f7a9336f5a34015c44ea5a6b04ce34f10 100644 (file)
@@ -2579,7 +2579,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
                fsg->data_size_from_cmnd = 0;
                sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]);
                if ((reply = check_command(fsg, fsg->cmnd_size,
-                               DATA_DIR_UNKNOWN, 0xff, 0, unknown)) == 0) {
+                               DATA_DIR_UNKNOWN, ~0, 0, unknown)) == 0) {
                        fsg->curlun->sense_data = SS_INVALID_COMMAND;
                        reply = -EINVAL;
                }
index 2fa9865babedb0d76e28d6cfa2ac2ad6cf859628..e5e44f8cde9a3c99052e19e5e8c641ab3123a534 100644 (file)
@@ -263,8 +263,8 @@ static void usb_gadget_remove_driver(struct usb_udc *udc)
 
        if (udc_is_newstyle(udc)) {
                udc->driver->disconnect(udc->gadget);
-               udc->driver->unbind(udc->gadget);
                usb_gadget_disconnect(udc->gadget);
+               udc->driver->unbind(udc->gadget);
                usb_gadget_udc_stop(udc->gadget, udc->driver);
        } else {
                usb_gadget_stop(udc->gadget, udc->driver);
@@ -415,9 +415,9 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
                        usb_gadget_udc_start(udc->gadget, udc->driver);
                usb_gadget_connect(udc->gadget);
        } else if (sysfs_streq(buf, "disconnect")) {
+               usb_gadget_disconnect(udc->gadget);
                if (udc_is_newstyle(udc))
                        usb_gadget_udc_stop(udc->gadget, udc->driver);
-               usb_gadget_disconnect(udc->gadget);
        } else {
                dev_err(dev, "unsupported command '%s'\n", buf);
                return -EINVAL;
index bc78c606c12bbe5726f077832c3dff1897918134..ca4e03a1c73a6d9ec030d133a15558d50362de4a 100644 (file)
@@ -28,7 +28,7 @@
 
 struct uvc_request_data
 {
-       unsigned int length;
+       __s32 length;
        __u8 data[60];
 };
 
index f6e083b5019137db248fc67731f24eb6e683b1ac..54d7ca559cb215f5fc963d10cdd0b99d6367c777 100644 (file)
@@ -39,7 +39,7 @@ uvc_send_response(struct uvc_device *uvc, struct uvc_request_data *data)
        if (data->length < 0)
                return usb_ep_set_halt(cdev->gadget->ep0);
 
-       req->length = min(uvc->event_length, data->length);
+       req->length = min_t(unsigned int, uvc->event_length, data->length);
        req->zero = data->length < uvc->event_length;
        req->dma = DMA_ADDR_INVALID;
 
index a797d51ecbe83fd9daa651d435a9931219333b4f..c778ffe4e4e528544e8f70007c851f521bd90675 100644 (file)
@@ -32,7 +32,7 @@
 #define ULPI_VIEWPORT_OFFSET   0x170
 
 struct ehci_mxc_priv {
-       struct clk *usbclk, *ahbclk, *phy1clk;
+       struct clk *usbclk, *ahbclk, *phyclk;
        struct usb_hcd *hcd;
 };
 
@@ -166,31 +166,26 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
        }
 
        /* enable clocks */
-       priv->usbclk = clk_get(dev, "usb");
+       priv->usbclk = clk_get(dev, "ipg");
        if (IS_ERR(priv->usbclk)) {
                ret = PTR_ERR(priv->usbclk);
                goto err_clk;
        }
-       clk_enable(priv->usbclk);
+       clk_prepare_enable(priv->usbclk);
 
-       if (!cpu_is_mx35() && !cpu_is_mx25()) {
-               priv->ahbclk = clk_get(dev, "usb_ahb");
-               if (IS_ERR(priv->ahbclk)) {
-                       ret = PTR_ERR(priv->ahbclk);
-                       goto err_clk_ahb;
-               }
-               clk_enable(priv->ahbclk);
+       priv->ahbclk = clk_get(dev, "ahb");
+       if (IS_ERR(priv->ahbclk)) {
+               ret = PTR_ERR(priv->ahbclk);
+               goto err_clk_ahb;
        }
+       clk_prepare_enable(priv->ahbclk);
 
        /* "dr" device has its own clock on i.MX51 */
-       if (cpu_is_mx51() && (pdev->id == 0)) {
-               priv->phy1clk = clk_get(dev, "usb_phy1");
-               if (IS_ERR(priv->phy1clk)) {
-                       ret = PTR_ERR(priv->phy1clk);
-                       goto err_clk_phy;
-               }
-               clk_enable(priv->phy1clk);
-       }
+       priv->phyclk = clk_get(dev, "phy");
+       if (IS_ERR(priv->phyclk))
+               priv->phyclk = NULL;
+       if (priv->phyclk)
+               clk_prepare_enable(priv->phyclk);
 
 
        /* call platform specific init function */
@@ -265,17 +260,15 @@ err_add:
        if (pdata && pdata->exit)
                pdata->exit(pdev);
 err_init:
-       if (priv->phy1clk) {
-               clk_disable(priv->phy1clk);
-               clk_put(priv->phy1clk);
-       }
-err_clk_phy:
-       if (priv->ahbclk) {
-               clk_disable(priv->ahbclk);
-               clk_put(priv->ahbclk);
+       if (priv->phyclk) {
+               clk_disable_unprepare(priv->phyclk);
+               clk_put(priv->phyclk);
        }
+
+       clk_disable_unprepare(priv->ahbclk);
+       clk_put(priv->ahbclk);
 err_clk_ahb:
-       clk_disable(priv->usbclk);
+       clk_disable_unprepare(priv->usbclk);
        clk_put(priv->usbclk);
 err_clk:
        iounmap(hcd->regs);
@@ -307,15 +300,14 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev)
        usb_put_hcd(hcd);
        platform_set_drvdata(pdev, NULL);
 
-       clk_disable(priv->usbclk);
+       clk_disable_unprepare(priv->usbclk);
        clk_put(priv->usbclk);
-       if (priv->ahbclk) {
-               clk_disable(priv->ahbclk);
-               clk_put(priv->ahbclk);
-       }
-       if (priv->phy1clk) {
-               clk_disable(priv->phy1clk);
-               clk_put(priv->phy1clk);
+       clk_disable_unprepare(priv->ahbclk);
+       clk_put(priv->ahbclk);
+
+       if (priv->phyclk) {
+               clk_disable_unprepare(priv->phyclk);
+               clk_put(priv->phyclk);
        }
 
        kfree(priv);
index 01bb7241d6efd53f3769d47e86d59a28c5cf9ce2..fe8dc069164ead9f271b3e487d2704e0e74aeaed 100644 (file)
@@ -144,6 +144,14 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
                        hcd->has_tt = 1;
                        tdi_reset(ehci);
                }
+               if (pdev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK) {
+                       /* EHCI #1 or #2 on 6 Series/C200 Series chipset */
+                       if (pdev->device == 0x1c26 || pdev->device == 0x1c2d) {
+                               ehci_info(ehci, "broken D3 during system sleep on ASUS\n");
+                               hcd->broken_pci_sleep = 1;
+                               device_set_wakeup_capable(&pdev->dev, false);
+                       }
+               }
                break;
        case PCI_VENDOR_ID_TDI:
                if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) {
index 86183366647f7803f256d2ef6d05da639818c8e5..f214a80cdee212ec816601ef51645b05fd3f6d68 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/gpio.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
+#include <linux/pm_runtime.h>
 
 #include <mach/usb_phy.h>
 #include <mach/iomap.h>
@@ -37,9 +38,7 @@ struct tegra_ehci_hcd {
        struct clk *emc_clk;
        struct usb_phy *transceiver;
        int host_resumed;
-       int bus_suspended;
        int port_resuming;
-       int power_down_on_bus_suspend;
        enum tegra_usb_phy_port_speed port_speed;
 };
 
@@ -273,120 +272,6 @@ static void tegra_ehci_restart(struct usb_hcd *hcd)
        up_write(&ehci_cf_port_reset_rwsem);
 }
 
-static int tegra_usb_suspend(struct usb_hcd *hcd)
-{
-       struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
-       struct ehci_regs __iomem *hw = tegra->ehci->regs;
-       unsigned long flags;
-
-       spin_lock_irqsave(&tegra->ehci->lock, flags);
-
-       tegra->port_speed = (readl(&hw->port_status[0]) >> 26) & 0x3;
-       ehci_halt(tegra->ehci);
-       clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
-
-       spin_unlock_irqrestore(&tegra->ehci->lock, flags);
-
-       tegra_ehci_power_down(hcd);
-       return 0;
-}
-
-static int tegra_usb_resume(struct usb_hcd *hcd)
-{
-       struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
-       struct ehci_hcd *ehci = hcd_to_ehci(hcd);
-       struct ehci_regs __iomem *hw = ehci->regs;
-       unsigned long val;
-
-       set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
-       tegra_ehci_power_up(hcd);
-
-       if (tegra->port_speed > TEGRA_USB_PHY_PORT_SPEED_HIGH) {
-               /* Wait for the phy to detect new devices
-                * before we restart the controller */
-               msleep(10);
-               goto restart;
-       }
-
-       /* Force the phy to keep data lines in suspend state */
-       tegra_ehci_phy_restore_start(tegra->phy, tegra->port_speed);
-
-       /* Enable host mode */
-       tdi_reset(ehci);
-
-       /* Enable Port Power */
-       val = readl(&hw->port_status[0]);
-       val |= PORT_POWER;
-       writel(val, &hw->port_status[0]);
-       udelay(10);
-
-       /* Check if the phy resume from LP0. When the phy resume from LP0
-        * USB register will be reset. */
-       if (!readl(&hw->async_next)) {
-               /* Program the field PTC based on the saved speed mode */
-               val = readl(&hw->port_status[0]);
-               val &= ~PORT_TEST(~0);
-               if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_HIGH)
-                       val |= PORT_TEST_FORCE;
-               else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_FULL)
-                       val |= PORT_TEST(6);
-               else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_LOW)
-                       val |= PORT_TEST(7);
-               writel(val, &hw->port_status[0]);
-               udelay(10);
-
-               /* Disable test mode by setting PTC field to NORMAL_OP */
-               val = readl(&hw->port_status[0]);
-               val &= ~PORT_TEST(~0);
-               writel(val, &hw->port_status[0]);
-               udelay(10);
-       }
-
-       /* Poll until CCS is enabled */
-       if (handshake(ehci, &hw->port_status[0], PORT_CONNECT,
-                                                PORT_CONNECT, 2000)) {
-               pr_err("%s: timeout waiting for PORT_CONNECT\n", __func__);
-               goto restart;
-       }
-
-       /* Poll until PE is enabled */
-       if (handshake(ehci, &hw->port_status[0], PORT_PE,
-                                                PORT_PE, 2000)) {
-               pr_err("%s: timeout waiting for USB_PORTSC1_PE\n", __func__);
-               goto restart;
-       }
-
-       /* Clear the PCI status, to avoid an interrupt taken upon resume */
-       val = readl(&hw->status);
-       val |= STS_PCD;
-       writel(val, &hw->status);
-
-       /* Put controller in suspend mode by writing 1 to SUSP bit of PORTSC */
-       val = readl(&hw->port_status[0]);
-       if ((val & PORT_POWER) && (val & PORT_PE)) {
-               val |= PORT_SUSPEND;
-               writel(val, &hw->port_status[0]);
-
-               /* Wait until port suspend completes */
-               if (handshake(ehci, &hw->port_status[0], PORT_SUSPEND,
-                                                        PORT_SUSPEND, 1000)) {
-                       pr_err("%s: timeout waiting for PORT_SUSPEND\n",
-                                                               __func__);
-                       goto restart;
-               }
-       }
-
-       tegra_ehci_phy_restore_end(tegra->phy);
-       return 0;
-
-restart:
-       if (tegra->port_speed <= TEGRA_USB_PHY_PORT_SPEED_HIGH)
-               tegra_ehci_phy_restore_end(tegra->phy);
-
-       tegra_ehci_restart(hcd);
-       return 0;
-}
-
 static void tegra_ehci_shutdown(struct usb_hcd *hcd)
 {
        struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
@@ -434,36 +319,6 @@ static int tegra_ehci_setup(struct usb_hcd *hcd)
        return retval;
 }
 
-#ifdef CONFIG_PM
-static int tegra_ehci_bus_suspend(struct usb_hcd *hcd)
-{
-       struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
-       int error_status = 0;
-
-       error_status = ehci_bus_suspend(hcd);
-       if (!error_status && tegra->power_down_on_bus_suspend) {
-               tegra_usb_suspend(hcd);
-               tegra->bus_suspended = 1;
-       }
-
-       return error_status;
-}
-
-static int tegra_ehci_bus_resume(struct usb_hcd *hcd)
-{
-       struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
-
-       if (tegra->bus_suspended && tegra->power_down_on_bus_suspend) {
-               tegra_usb_resume(hcd);
-               tegra->bus_suspended = 0;
-       }
-
-       tegra_usb_phy_preresume(tegra->phy);
-       tegra->port_resuming = 1;
-       return ehci_bus_resume(hcd);
-}
-#endif
-
 struct temp_buffer {
        void *kmalloc_ptr;
        void *old_xfer_buffer;
@@ -574,8 +429,8 @@ static const struct hc_driver tegra_ehci_hc_driver = {
        .hub_control            = tegra_ehci_hub_control,
        .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
 #ifdef CONFIG_PM
-       .bus_suspend            = tegra_ehci_bus_suspend,
-       .bus_resume             = tegra_ehci_bus_resume,
+       .bus_suspend            = ehci_bus_suspend,
+       .bus_resume             = ehci_bus_resume,
 #endif
        .relinquish_port        = ehci_relinquish_port,
        .port_handed_over       = ehci_port_handed_over,
@@ -603,11 +458,187 @@ static int setup_vbus_gpio(struct platform_device *pdev)
                dev_err(&pdev->dev, "can't enable vbus\n");
                return err;
        }
-       gpio_set_value(gpio, 1);
 
        return err;
 }
 
+#ifdef CONFIG_PM
+
+static int controller_suspend(struct device *dev)
+{
+       struct tegra_ehci_hcd *tegra =
+                       platform_get_drvdata(to_platform_device(dev));
+       struct ehci_hcd *ehci = tegra->ehci;
+       struct usb_hcd *hcd = ehci_to_hcd(ehci);
+       struct ehci_regs __iomem *hw = ehci->regs;
+       unsigned long flags;
+
+       if (time_before(jiffies, ehci->next_statechange))
+               msleep(10);
+
+       spin_lock_irqsave(&ehci->lock, flags);
+
+       tegra->port_speed = (readl(&hw->port_status[0]) >> 26) & 0x3;
+       ehci_halt(ehci);
+       clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+
+       spin_unlock_irqrestore(&ehci->lock, flags);
+
+       tegra_ehci_power_down(hcd);
+       return 0;
+}
+
+static int controller_resume(struct device *dev)
+{
+       struct tegra_ehci_hcd *tegra =
+                       platform_get_drvdata(to_platform_device(dev));
+       struct ehci_hcd *ehci = tegra->ehci;
+       struct usb_hcd *hcd = ehci_to_hcd(ehci);
+       struct ehci_regs __iomem *hw = ehci->regs;
+       unsigned long val;
+
+       set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+       tegra_ehci_power_up(hcd);
+
+       if (tegra->port_speed > TEGRA_USB_PHY_PORT_SPEED_HIGH) {
+               /* Wait for the phy to detect new devices
+                * before we restart the controller */
+               msleep(10);
+               goto restart;
+       }
+
+       /* Force the phy to keep data lines in suspend state */
+       tegra_ehci_phy_restore_start(tegra->phy, tegra->port_speed);
+
+       /* Enable host mode */
+       tdi_reset(ehci);
+
+       /* Enable Port Power */
+       val = readl(&hw->port_status[0]);
+       val |= PORT_POWER;
+       writel(val, &hw->port_status[0]);
+       udelay(10);
+
+       /* Check if the phy resume from LP0. When the phy resume from LP0
+        * USB register will be reset. */
+       if (!readl(&hw->async_next)) {
+               /* Program the field PTC based on the saved speed mode */
+               val = readl(&hw->port_status[0]);
+               val &= ~PORT_TEST(~0);
+               if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_HIGH)
+                       val |= PORT_TEST_FORCE;
+               else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_FULL)
+                       val |= PORT_TEST(6);
+               else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_LOW)
+                       val |= PORT_TEST(7);
+               writel(val, &hw->port_status[0]);
+               udelay(10);
+
+               /* Disable test mode by setting PTC field to NORMAL_OP */
+               val = readl(&hw->port_status[0]);
+               val &= ~PORT_TEST(~0);
+               writel(val, &hw->port_status[0]);
+               udelay(10);
+       }
+
+       /* Poll until CCS is enabled */
+       if (handshake(ehci, &hw->port_status[0], PORT_CONNECT,
+                                                PORT_CONNECT, 2000)) {
+               pr_err("%s: timeout waiting for PORT_CONNECT\n", __func__);
+               goto restart;
+       }
+
+       /* Poll until PE is enabled */
+       if (handshake(ehci, &hw->port_status[0], PORT_PE,
+                                                PORT_PE, 2000)) {
+               pr_err("%s: timeout waiting for USB_PORTSC1_PE\n", __func__);
+               goto restart;
+       }
+
+       /* Clear the PCI status, to avoid an interrupt taken upon resume */
+       val = readl(&hw->status);
+       val |= STS_PCD;
+       writel(val, &hw->status);
+
+       /* Put controller in suspend mode by writing 1 to SUSP bit of PORTSC */
+       val = readl(&hw->port_status[0]);
+       if ((val & PORT_POWER) && (val & PORT_PE)) {
+               val |= PORT_SUSPEND;
+               writel(val, &hw->port_status[0]);
+
+               /* Wait until port suspend completes */
+               if (handshake(ehci, &hw->port_status[0], PORT_SUSPEND,
+                                                        PORT_SUSPEND, 1000)) {
+                       pr_err("%s: timeout waiting for PORT_SUSPEND\n",
+                                                               __func__);
+                       goto restart;
+               }
+       }
+
+       tegra_ehci_phy_restore_end(tegra->phy);
+       goto done;
+
+ restart:
+       if (tegra->port_speed <= TEGRA_USB_PHY_PORT_SPEED_HIGH)
+               tegra_ehci_phy_restore_end(tegra->phy);
+
+       tegra_ehci_restart(hcd);
+
+ done:
+       tegra_usb_phy_preresume(tegra->phy);
+       tegra->port_resuming = 1;
+       return 0;
+}
+
+static int tegra_ehci_suspend(struct device *dev)
+{
+       struct tegra_ehci_hcd *tegra =
+                       platform_get_drvdata(to_platform_device(dev));
+       struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
+       int rc = 0;
+
+       /*
+        * When system sleep is supported and USB controller wakeup is
+        * implemented: If the controller is runtime-suspended and the
+        * wakeup setting needs to be changed, call pm_runtime_resume().
+        */
+       if (HCD_HW_ACCESSIBLE(hcd))
+               rc = controller_suspend(dev);
+       return rc;
+}
+
+static int tegra_ehci_resume(struct device *dev)
+{
+       int rc;
+
+       rc = controller_resume(dev);
+       if (rc == 0) {
+               pm_runtime_disable(dev);
+               pm_runtime_set_active(dev);
+               pm_runtime_enable(dev);
+       }
+       return rc;
+}
+
+static int tegra_ehci_runtime_suspend(struct device *dev)
+{
+       return controller_suspend(dev);
+}
+
+static int tegra_ehci_runtime_resume(struct device *dev)
+{
+       return controller_resume(dev);
+}
+
+static const struct dev_pm_ops tegra_ehci_pm_ops = {
+       .suspend        = tegra_ehci_suspend,
+       .resume         = tegra_ehci_resume,
+       .runtime_suspend = tegra_ehci_runtime_suspend,
+       .runtime_resume = tegra_ehci_runtime_resume,
+};
+
+#endif
+
 static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32);
 
 static int tegra_ehci_probe(struct platform_device *pdev)
@@ -722,7 +753,6 @@ static int tegra_ehci_probe(struct platform_device *pdev)
        }
 
        tegra->host_resumed = 1;
-       tegra->power_down_on_bus_suspend = pdata->power_down_on_bus_suspend;
        tegra->ehci = hcd_to_ehci(hcd);
 
        irq = platform_get_irq(pdev, 0);
@@ -746,6 +776,14 @@ static int tegra_ehci_probe(struct platform_device *pdev)
                goto fail;
        }
 
+       pm_runtime_set_active(&pdev->dev);
+       pm_runtime_get_noresume(&pdev->dev);
+
+       /* Don't skip the pm_runtime_forbid call if wakeup isn't working */
+       /* if (!pdata->power_down_on_bus_suspend) */
+               pm_runtime_forbid(&pdev->dev);
+       pm_runtime_enable(&pdev->dev);
+       pm_runtime_put_sync(&pdev->dev);
        return err;
 
 fail:
@@ -772,33 +810,6 @@ fail_hcd:
        return err;
 }
 
-#ifdef CONFIG_PM
-static int tegra_ehci_resume(struct platform_device *pdev)
-{
-       struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
-       struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
-
-       if (tegra->bus_suspended)
-               return 0;
-
-       return tegra_usb_resume(hcd);
-}
-
-static int tegra_ehci_suspend(struct platform_device *pdev, pm_message_t state)
-{
-       struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
-       struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
-
-       if (tegra->bus_suspended)
-               return 0;
-
-       if (time_before(jiffies, tegra->ehci->next_statechange))
-               msleep(10);
-
-       return tegra_usb_suspend(hcd);
-}
-#endif
-
 static int tegra_ehci_remove(struct platform_device *pdev)
 {
        struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
@@ -807,6 +818,10 @@ static int tegra_ehci_remove(struct platform_device *pdev)
        if (tegra == NULL || hcd == NULL)
                return -EINVAL;
 
+       pm_runtime_get_sync(&pdev->dev);
+       pm_runtime_disable(&pdev->dev);
+       pm_runtime_put_noidle(&pdev->dev);
+
 #ifdef CONFIG_USB_OTG_UTILS
        if (tegra->transceiver) {
                otg_set_host(tegra->transceiver->otg, NULL);
@@ -847,13 +862,12 @@ static struct of_device_id tegra_ehci_of_match[] __devinitdata = {
 static struct platform_driver tegra_ehci_driver = {
        .probe          = tegra_ehci_probe,
        .remove         = tegra_ehci_remove,
-#ifdef CONFIG_PM
-       .suspend        = tegra_ehci_suspend,
-       .resume         = tegra_ehci_resume,
-#endif
        .shutdown       = tegra_ehci_hcd_shutdown,
        .driver         = {
                .name   = "tegra-ehci",
                .of_match_table = tegra_ehci_of_match,
+#ifdef CONFIG_PM
+               .pm     = &tegra_ehci_pm_ops,
+#endif
        }
 };
index 97ab975fa4424c3bcb4b6cce5368fc144aaba845..768b4b55c816a6960733f73d7e0d7b86be54697f 100644 (file)
@@ -386,7 +386,7 @@ static int davinci_musb_init(struct musb *musb)
        usb_nop_xceiv_register();
        musb->xceiv = usb_get_transceiver();
        if (!musb->xceiv)
-               return -ENODEV;
+               goto unregister;
 
        musb->mregs += DAVINCI_BASE_OFFSET;
 
@@ -444,6 +444,7 @@ static int davinci_musb_init(struct musb *musb)
 
 fail:
        usb_put_transceiver(musb->xceiv);
+unregister:
        usb_nop_xceiv_unregister();
        return -ENODEV;
 }
index 93de517a32a00009aeffbdf6691906a979ae506f..f4a40f001c8803eecfedab2af6dfcdd50d95ed22 100644 (file)
@@ -449,7 +449,7 @@ struct musb {
         * We added this flag to forcefully disable double
         * buffering until we get it working.
         */
-       unsigned                double_buffer_not_ok:1 __deprecated;
+       unsigned                double_buffer_not_ok:1;
 
        struct musb_hdrc_config *config;
 
index 3ece43a2e4c14b2b4a07fee9dcfaab4be03cfa3c..a0a2178974fe149f99da263627d8ada256faace5 100644 (file)
@@ -96,7 +96,7 @@ static void gpio_vbus_work(struct work_struct *work)
        struct gpio_vbus_data *gpio_vbus =
                container_of(work, struct gpio_vbus_data, work);
        struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data;
-       int gpio;
+       int gpio, status;
 
        if (!gpio_vbus->phy.otg->gadget)
                return;
@@ -108,7 +108,9 @@ static void gpio_vbus_work(struct work_struct *work)
         */
        gpio = pdata->gpio_pullup;
        if (is_vbus_powered(pdata)) {
+               status = USB_EVENT_VBUS;
                gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL;
+               gpio_vbus->phy.last_event = status;
                usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget);
 
                /* drawing a "unit load" is *always* OK, except for OTG */
@@ -117,6 +119,9 @@ static void gpio_vbus_work(struct work_struct *work)
                /* optionally enable D+ pullup */
                if (gpio_is_valid(gpio))
                        gpio_set_value(gpio, !pdata->gpio_pullup_inverted);
+
+               atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
+                                          status, gpio_vbus->phy.otg->gadget);
        } else {
                /* optionally disable D+ pullup */
                if (gpio_is_valid(gpio))
@@ -125,7 +130,12 @@ static void gpio_vbus_work(struct work_struct *work)
                set_vbus_draw(gpio_vbus, 0);
 
                usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget);
+               status = USB_EVENT_NONE;
                gpio_vbus->phy.state = OTG_STATE_B_IDLE;
+               gpio_vbus->phy.last_event = status;
+
+               atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
+                                          status, gpio_vbus->phy.otg->gadget);
        }
 }
 
@@ -287,6 +297,9 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
                        irq, err);
                goto err_irq;
        }
+
+       ATOMIC_INIT_NOTIFIER_HEAD(&gpio_vbus->phy.notifier);
+
        INIT_WORK(&gpio_vbus->work, gpio_vbus_work);
 
        gpio_vbus->vbus_draw = regulator_get(&pdev->dev, "vbus_draw");
index f0da2c32fbdefce2ff9d791f9fa23a73ac49de8d..1f21d2a1e52885af8db0a691170b8ab0364aa7b4 100644 (file)
@@ -238,7 +238,7 @@ static void handle_tx(struct vhost_net *net)
 
                                vq->heads[vq->upend_idx].len = len;
                                ubuf->callback = vhost_zerocopy_callback;
-                               ubuf->arg = vq->ubufs;
+                               ubuf->ctx = vq->ubufs;
                                ubuf->desc = vq->upend_idx;
                                msg.msg_control = ubuf;
                                msg.msg_controllen = sizeof(ubuf);
index 947f00d8e091a3f2f3c01cc7cc23f5f2658d37df..51e4c1eeec4f0b09af84b5feb58c63313cd7d0cb 100644 (file)
@@ -1598,10 +1598,9 @@ void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *ubufs)
        kfree(ubufs);
 }
 
-void vhost_zerocopy_callback(void *arg)
+void vhost_zerocopy_callback(struct ubuf_info *ubuf)
 {
-       struct ubuf_info *ubuf = arg;
-       struct vhost_ubuf_ref *ubufs = ubuf->arg;
+       struct vhost_ubuf_ref *ubufs = ubuf->ctx;
        struct vhost_virtqueue *vq = ubufs->vq;
 
        /* set len = 1 to mark this desc buffers done DMA */
index 8dcf4cca6bf224ec5c36f105a994ba76b0b19188..8de1fd5b8efba8a39c20e7872a23b517e710b9ec 100644 (file)
@@ -188,7 +188,7 @@ bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *);
 
 int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
                    unsigned int log_num, u64 len);
-void vhost_zerocopy_callback(void *arg);
+void vhost_zerocopy_callback(struct ubuf_info *);
 int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq);
 
 #define vq_err(vq, fmt, ...) do {                                  \
index 86922ac84412b3f6a8be0ef41b52e209c684d87c..353c02fe8a952816af0f5c0d668d80e81f31d204 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/fb.h>
+#include <linux/gpio.h>
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/types.h>
index f135dbead07d8921068de3513dafb2c32ea10973..caad3689b4e6fb4677a393c44a9373ff1543f851 100644 (file)
@@ -131,7 +131,9 @@ struct imxfb_rgb {
 struct imxfb_info {
        struct platform_device  *pdev;
        void __iomem            *regs;
-       struct clk              *clk;
+       struct clk              *clk_ipg;
+       struct clk              *clk_ahb;
+       struct clk              *clk_per;
 
        /*
         * These are the addresses we mapped
@@ -340,7 +342,7 @@ static int imxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 
        pr_debug("var->bits_per_pixel=%d\n", var->bits_per_pixel);
 
-       lcd_clk = clk_get_rate(fbi->clk);
+       lcd_clk = clk_get_rate(fbi->clk_per);
 
        tmp = var->pixclock * (unsigned long long)lcd_clk;
 
@@ -455,11 +457,17 @@ static int imxfb_bl_update_status(struct backlight_device *bl)
 
        fbi->pwmr = (fbi->pwmr & ~0xFF) | brightness;
 
-       if (bl->props.fb_blank != FB_BLANK_UNBLANK)
-               clk_enable(fbi->clk);
+       if (bl->props.fb_blank != FB_BLANK_UNBLANK) {
+               clk_prepare_enable(fbi->clk_ipg);
+               clk_prepare_enable(fbi->clk_ahb);
+               clk_prepare_enable(fbi->clk_per);
+       }
        writel(fbi->pwmr, fbi->regs + LCDC_PWMR);
-       if (bl->props.fb_blank != FB_BLANK_UNBLANK)
-               clk_disable(fbi->clk);
+       if (bl->props.fb_blank != FB_BLANK_UNBLANK) {
+               clk_disable_unprepare(fbi->clk_per);
+               clk_disable_unprepare(fbi->clk_ahb);
+               clk_disable_unprepare(fbi->clk_ipg);
+       }
 
        return 0;
 }
@@ -522,7 +530,9 @@ static void imxfb_enable_controller(struct imxfb_info *fbi)
         */
        writel(RMCR_LCDC_EN_MX1, fbi->regs + LCDC_RMCR);
 
-       clk_enable(fbi->clk);
+       clk_prepare_enable(fbi->clk_ipg);
+       clk_prepare_enable(fbi->clk_ahb);
+       clk_prepare_enable(fbi->clk_per);
 
        if (fbi->backlight_power)
                fbi->backlight_power(1);
@@ -539,7 +549,9 @@ static void imxfb_disable_controller(struct imxfb_info *fbi)
        if (fbi->lcd_power)
                fbi->lcd_power(0);
 
-       clk_disable(fbi->clk);
+       clk_disable_unprepare(fbi->clk_per);
+       clk_disable_unprepare(fbi->clk_ipg);
+       clk_disable_unprepare(fbi->clk_ahb);
 
        writel(0, fbi->regs + LCDC_RMCR);
 }
@@ -770,10 +782,21 @@ static int __init imxfb_probe(struct platform_device *pdev)
                goto failed_req;
        }
 
-       fbi->clk = clk_get(&pdev->dev, NULL);
-       if (IS_ERR(fbi->clk)) {
-               ret = PTR_ERR(fbi->clk);
-               dev_err(&pdev->dev, "unable to get clock: %d\n", ret);
+       fbi->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+       if (IS_ERR(fbi->clk_ipg)) {
+               ret = PTR_ERR(fbi->clk_ipg);
+               goto failed_getclock;
+       }
+
+       fbi->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
+       if (IS_ERR(fbi->clk_ahb)) {
+               ret = PTR_ERR(fbi->clk_ahb);
+               goto failed_getclock;
+       }
+
+       fbi->clk_per = devm_clk_get(&pdev->dev, "per");
+       if (IS_ERR(fbi->clk_per)) {
+               ret = PTR_ERR(fbi->clk_per);
                goto failed_getclock;
        }
 
@@ -858,7 +881,6 @@ failed_platform_init:
 failed_map:
        iounmap(fbi->regs);
 failed_ioremap:
-       clk_put(fbi->clk);
 failed_getclock:
        release_mem_region(res->start, resource_size(res));
 failed_req:
@@ -895,8 +917,6 @@ static int __devexit imxfb_remove(struct platform_device *pdev)
 
        iounmap(fbi->regs);
        release_mem_region(res->start, resource_size(res));
-       clk_disable(fbi->clk);
-       clk_put(fbi->clk);
 
        platform_set_drvdata(pdev, NULL);
 
index a3b6a74c67a729b93949a1e06c89c40cf252c1a1..1cc61a700fa84bd7830bd37f4b3d069438f4ba87 100644 (file)
@@ -138,7 +138,7 @@ static int __devinit mxc_w1_probe(struct platform_device *pdev)
                goto failed_ioremap;
        }
 
-       clk_enable(mdev->clk);
+       clk_prepare_enable(mdev->clk);
        __raw_writeb(mdev->clkdiv, mdev->regs + MXC_W1_TIME_DIVIDER);
 
        mdev->bus_master.data = mdev;
@@ -178,7 +178,7 @@ static int __devexit mxc_w1_remove(struct platform_device *pdev)
 
        iounmap(mdev->regs);
        release_mem_region(res->start, resource_size(res));
-       clk_disable(mdev->clk);
+       clk_disable_unprepare(mdev->clk);
        clk_put(mdev->clk);
 
        platform_set_drvdata(pdev, NULL);
index cbc7ceef2786d418e81a1ed055c8676ad627253f..9f13b897fd6443bfccff87445bd62bc7145da30c 100644 (file)
@@ -435,16 +435,16 @@ static void hpwdt_start(void)
 {
        reload = SECS_TO_TICKS(soft_margin);
        iowrite16(reload, hpwdt_timer_reg);
-       iowrite16(0x85, hpwdt_timer_con);
+       iowrite8(0x85, hpwdt_timer_con);
 }
 
 static void hpwdt_stop(void)
 {
        unsigned long data;
 
-       data = ioread16(hpwdt_timer_con);
+       data = ioread8(hpwdt_timer_con);
        data &= 0xFE;
-       iowrite16(data, hpwdt_timer_con);
+       iowrite8(data, hpwdt_timer_con);
 }
 
 static void hpwdt_ping(void)
index 7a2b734fcdc78f89c3c7f1b9a3eb0f3eb005842c..bcfab2b00ad20ae5c1e72fbf0e2809aa02cfdf2d 100644 (file)
@@ -121,7 +121,7 @@ static void imx2_wdt_start(void)
 {
        if (!test_and_set_bit(IMX2_WDT_STATUS_STARTED, &imx2_wdt.status)) {
                /* at our first start we enable clock and do initialisations */
-               clk_enable(imx2_wdt.clk);
+               clk_prepare_enable(imx2_wdt.clk);
 
                imx2_wdt_setup();
        } else  /* delete the timer that pings the watchdog after close */
index 4b33acd8ed4ef262bfa43940eab2be7a3deb66f5..0a8a17cd80bea172d767f02609b0164b45fe1717 100644 (file)
@@ -274,7 +274,7 @@ static unsigned int cpu_from_evtchn(unsigned int evtchn)
 
 static bool pirq_check_eoi_map(unsigned irq)
 {
-       return test_bit(irq, pirq_eoi_map);
+       return test_bit(pirq_from_irq(irq), pirq_eoi_map);
 }
 
 static bool pirq_needs_eoi_flag(unsigned irq)
index 174b5653cd8afd7b1ca9190d73e87e9d72f2694b..0b48579a9cd6066c170741913875ebbe716dce0c 100644 (file)
@@ -128,7 +128,10 @@ static int push_cxx_to_hypervisor(struct acpi_processor *_pr)
                        pr_debug("     C%d: %s %d uS\n",
                                 cx->type, cx->desc, (u32)cx->latency);
                }
-       } else
+       } else if (ret != -EINVAL)
+               /* EINVAL means the ACPI ID is incorrect - meaning the ACPI
+                * table is referencing a non-existing CPU - which can happen
+                * with broken ACPI tables. */
                pr_err(DRV_NAME "(CX): Hypervisor error (%d) for ACPI CPU%u\n",
                       ret, _pr->acpi_id);
 
index eb1cc92cd67d26d2966fa1191bb373f646144583..908e18455413fc2e49a4d845c8020007dce95252 100644 (file)
@@ -110,7 +110,6 @@ struct autofs_sb_info {
        int sub_version;
        int min_proto;
        int max_proto;
-       int compat_daemon;
        unsigned long exp_timeout;
        unsigned int type;
        int reghost_enabled;
@@ -270,6 +269,17 @@ int autofs4_fill_super(struct super_block *, void *, int);
 struct autofs_info *autofs4_new_ino(struct autofs_sb_info *);
 void autofs4_clean_ino(struct autofs_info *);
 
+static inline int autofs_prepare_pipe(struct file *pipe)
+{
+       if (!pipe->f_op || !pipe->f_op->write)
+               return -EINVAL;
+       if (!S_ISFIFO(pipe->f_dentry->d_inode->i_mode))
+               return -EINVAL;
+       /* We want a packet pipe */
+       pipe->f_flags |= O_DIRECT;
+       return 0;
+}
+
 /* Queue management functions */
 
 int autofs4_wait(struct autofs_sb_info *,struct dentry *, enum autofs_notify);
index 9dacb858670107bab207d4378e77d79dd3f25605..aa9103f8f01bf8d3bad8d0dcbcc8036895226e3f 100644 (file)
@@ -376,7 +376,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
                        err = -EBADF;
                        goto out;
                }
-               if (!pipe->f_op || !pipe->f_op->write) {
+               if (autofs_prepare_pipe(pipe) < 0) {
                        err = -EPIPE;
                        fput(pipe);
                        goto out;
@@ -385,7 +385,6 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
                sbi->pipefd = pipefd;
                sbi->pipe = pipe;
                sbi->catatonic = 0;
-               sbi->compat_daemon = is_compat_task();
        }
 out:
        mutex_unlock(&sbi->wq_mutex);
index d8dc002e9cc39d4b15511a6cc6df4d6b8b39897f..6e488ebe7784458623139c91ebd42fbba0752074 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/parser.h>
 #include <linux/bitops.h>
 #include <linux/magic.h>
-#include <linux/compat.h>
 #include "autofs_i.h"
 #include <linux/module.h>
 
@@ -225,7 +224,6 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
        set_autofs_type_indirect(&sbi->type);
        sbi->min_proto = 0;
        sbi->max_proto = 0;
-       sbi->compat_daemon = is_compat_task();
        mutex_init(&sbi->wq_mutex);
        mutex_init(&sbi->pipe_mutex);
        spin_lock_init(&sbi->fs_lock);
@@ -292,7 +290,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
                printk("autofs: could not open pipe file descriptor\n");
                goto fail_dput;
        }
-       if (!pipe->f_op || !pipe->f_op->write)
+       if (autofs_prepare_pipe(pipe) < 0)
                goto fail_fput;
        sbi->pipe = pipe;
        sbi->pipefd = pipefd;
index 9c098db433441a36613dd126b8487ed54036f49e..da8876d38a7b7e3a50101f02817cbbbc460cec20 100644 (file)
@@ -91,24 +91,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
 
        return (bytes > 0);
 }
-
-/*
- * The autofs_v5 packet was misdesigned.
- *
- * The packets are identical on x86-32 and x86-64, but have different
- * alignment. Which means that 'sizeof()' will give different results.
- * Fix it up for the case of running 32-bit user mode on a 64-bit kernel.
- */
-static noinline size_t autofs_v5_packet_size(struct autofs_sb_info *sbi)
-{
-       size_t pktsz = sizeof(struct autofs_v5_packet);
-#if defined(CONFIG_X86_64) && defined(CONFIG_COMPAT)
-       if (sbi->compat_daemon > 0)
-               pktsz -= 4;
-#endif
-       return pktsz;
-}
-
+       
 static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
                                 struct autofs_wait_queue *wq,
                                 int type)
@@ -172,7 +155,8 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
        {
                struct autofs_v5_packet *packet = &pkt.v5_pkt.v5_packet;
 
-               pktsz = autofs_v5_packet_size(sbi);
+               pktsz = sizeof(*packet);
+
                packet->wait_queue_token = wq->wait_queue_token;
                packet->len = wq->name.len;
                memcpy(packet->name, wq->name.name, wq->name.len);
index f4e90748940abf6c1f36f3186177e4640bd24546..bcec06750232e6cc3de09c62648201547709222b 100644 (file)
@@ -22,6 +22,7 @@
 #include "ulist.h"
 #include "transaction.h"
 #include "delayed-ref.h"
+#include "locking.h"
 
 /*
  * this structure records all encountered refs on the way up to the root
@@ -893,18 +894,22 @@ static char *iref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
        s64 bytes_left = size - 1;
        struct extent_buffer *eb = eb_in;
        struct btrfs_key found_key;
+       int leave_spinning = path->leave_spinning;
 
        if (bytes_left >= 0)
                dest[bytes_left] = '\0';
 
+       path->leave_spinning = 1;
        while (1) {
                len = btrfs_inode_ref_name_len(eb, iref);
                bytes_left -= len;
                if (bytes_left >= 0)
                        read_extent_buffer(eb, dest + bytes_left,
                                                (unsigned long)(iref + 1), len);
-               if (eb != eb_in)
+               if (eb != eb_in) {
+                       btrfs_tree_read_unlock_blocking(eb);
                        free_extent_buffer(eb);
+               }
                ret = inode_ref_info(parent, 0, fs_root, path, &found_key);
                if (ret > 0)
                        ret = -ENOENT;
@@ -919,8 +924,11 @@ static char *iref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
                slot = path->slots[0];
                eb = path->nodes[0];
                /* make sure we can use eb after releasing the path */
-               if (eb != eb_in)
+               if (eb != eb_in) {
                        atomic_inc(&eb->refs);
+                       btrfs_tree_read_lock(eb);
+                       btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK);
+               }
                btrfs_release_path(path);
 
                iref = btrfs_item_ptr(eb, slot, struct btrfs_inode_ref);
@@ -931,6 +939,7 @@ static char *iref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
        }
 
        btrfs_release_path(path);
+       path->leave_spinning = leave_spinning;
 
        if (ret)
                return ERR_PTR(ret);
@@ -1247,7 +1256,7 @@ static int iterate_irefs(u64 inum, struct btrfs_root *fs_root,
                                struct btrfs_path *path,
                                iterate_irefs_t *iterate, void *ctx)
 {
-       int ret;
+       int ret = 0;
        int slot;
        u32 cur;
        u32 len;
@@ -1259,7 +1268,8 @@ static int iterate_irefs(u64 inum, struct btrfs_root *fs_root,
        struct btrfs_inode_ref *iref;
        struct btrfs_key found_key;
 
-       while (1) {
+       while (!ret) {
+               path->leave_spinning = 1;
                ret = inode_ref_info(inum, parent ? parent+1 : 0, fs_root, path,
                                        &found_key);
                if (ret < 0)
@@ -1275,6 +1285,8 @@ static int iterate_irefs(u64 inum, struct btrfs_root *fs_root,
                eb = path->nodes[0];
                /* make sure we can use eb after releasing the path */
                atomic_inc(&eb->refs);
+               btrfs_tree_read_lock(eb);
+               btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK);
                btrfs_release_path(path);
 
                item = btrfs_item_nr(eb, slot);
@@ -1288,13 +1300,12 @@ static int iterate_irefs(u64 inum, struct btrfs_root *fs_root,
                                 (unsigned long long)found_key.objectid,
                                 (unsigned long long)fs_root->objectid);
                        ret = iterate(parent, iref, eb, ctx);
-                       if (ret) {
-                               free_extent_buffer(eb);
+                       if (ret)
                                break;
-                       }
                        len = sizeof(*iref) + name_len;
                        iref = (struct btrfs_inode_ref *)((char *)iref + len);
                }
+               btrfs_tree_read_unlock_blocking(eb);
                free_extent_buffer(eb);
        }
 
@@ -1414,6 +1425,8 @@ struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root,
 
 void free_ipath(struct inode_fs_paths *ipath)
 {
+       if (!ipath)
+               return;
        kfree(ipath->fspath);
        kfree(ipath);
 }
index e801f226d7e028b72ca08b5726ed409215c27b84..4106264fbc655ac79b26efa1177384ea92b72988 100644 (file)
@@ -220,10 +220,12 @@ struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root)
  */
 static void add_root_to_dirty_list(struct btrfs_root *root)
 {
+       spin_lock(&root->fs_info->trans_lock);
        if (root->track_dirty && list_empty(&root->dirty_list)) {
                list_add(&root->dirty_list,
                         &root->fs_info->dirty_cowonly_roots);
        }
+       spin_unlock(&root->fs_info->trans_lock);
 }
 
 /*
@@ -723,7 +725,7 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
 
                cur = btrfs_find_tree_block(root, blocknr, blocksize);
                if (cur)
-                       uptodate = btrfs_buffer_uptodate(cur, gen);
+                       uptodate = btrfs_buffer_uptodate(cur, gen, 0);
                else
                        uptodate = 0;
                if (!cur || !uptodate) {
@@ -1358,7 +1360,12 @@ static noinline int reada_for_balance(struct btrfs_root *root,
                block1 = btrfs_node_blockptr(parent, slot - 1);
                gen = btrfs_node_ptr_generation(parent, slot - 1);
                eb = btrfs_find_tree_block(root, block1, blocksize);
-               if (eb && btrfs_buffer_uptodate(eb, gen))
+               /*
+                * if we get -eagain from btrfs_buffer_uptodate, we
+                * don't want to return eagain here.  That will loop
+                * forever
+                */
+               if (eb && btrfs_buffer_uptodate(eb, gen, 1) != 0)
                        block1 = 0;
                free_extent_buffer(eb);
        }
@@ -1366,7 +1373,7 @@ static noinline int reada_for_balance(struct btrfs_root *root,
                block2 = btrfs_node_blockptr(parent, slot + 1);
                gen = btrfs_node_ptr_generation(parent, slot + 1);
                eb = btrfs_find_tree_block(root, block2, blocksize);
-               if (eb && btrfs_buffer_uptodate(eb, gen))
+               if (eb && btrfs_buffer_uptodate(eb, gen, 1) != 0)
                        block2 = 0;
                free_extent_buffer(eb);
        }
@@ -1504,8 +1511,9 @@ read_block_for_search(struct btrfs_trans_handle *trans,
 
        tmp = btrfs_find_tree_block(root, blocknr, blocksize);
        if (tmp) {
-               if (btrfs_buffer_uptodate(tmp, 0)) {
-                       if (btrfs_buffer_uptodate(tmp, gen)) {
+               /* first we do an atomic uptodate check */
+               if (btrfs_buffer_uptodate(tmp, 0, 1) > 0) {
+                       if (btrfs_buffer_uptodate(tmp, gen, 1) > 0) {
                                /*
                                 * we found an up to date block without
                                 * sleeping, return
@@ -1523,8 +1531,9 @@ read_block_for_search(struct btrfs_trans_handle *trans,
                        free_extent_buffer(tmp);
                        btrfs_set_path_blocking(p);
 
+                       /* now we're allowed to do a blocking uptodate check */
                        tmp = read_tree_block(root, blocknr, blocksize, gen);
-                       if (tmp && btrfs_buffer_uptodate(tmp, gen)) {
+                       if (tmp && btrfs_buffer_uptodate(tmp, gen, 0) > 0) {
                                *eb_ret = tmp;
                                return 0;
                        }
@@ -1559,7 +1568,7 @@ read_block_for_search(struct btrfs_trans_handle *trans,
                 * and give up so that our caller doesn't loop forever
                 * on our EAGAINs.
                 */
-               if (!btrfs_buffer_uptodate(tmp, 0))
+               if (!btrfs_buffer_uptodate(tmp, 0, 0))
                        ret = -EIO;
                free_extent_buffer(tmp);
        }
@@ -4043,7 +4052,7 @@ again:
                        tmp = btrfs_find_tree_block(root, blockptr,
                                            btrfs_level_size(root, level - 1));
 
-                       if (tmp && btrfs_buffer_uptodate(tmp, gen)) {
+                       if (tmp && btrfs_buffer_uptodate(tmp, gen, 1) > 0) {
                                free_extent_buffer(tmp);
                                break;
                        }
@@ -4166,7 +4175,8 @@ next:
                                struct extent_buffer *cur;
                                cur = btrfs_find_tree_block(root, blockptr,
                                            btrfs_level_size(root, level - 1));
-                               if (!cur || !btrfs_buffer_uptodate(cur, gen)) {
+                               if (!cur ||
+                                   btrfs_buffer_uptodate(cur, gen, 1) <= 0) {
                                        slot++;
                                        if (cur)
                                                free_extent_buffer(cur);
index 3f65a812e282d00744e9de5b89acc09ead08acb8..8fd72331d6008c100e48db1c808566eb382187b2 100644 (file)
@@ -1078,7 +1078,7 @@ struct btrfs_fs_info {
         * is required instead of the faster short fsync log commits
         */
        u64 last_trans_log_full_commit;
-       unsigned long mount_opt:21;
+       unsigned long mount_opt;
        unsigned long compress_type:4;
        u64 max_inline;
        u64 alloc_start;
index 20196f41120698f5d7efd7c6be5c56415bd44651..a7ffc88a7dbe4bcc028d3397970275dffcf0492e 100644 (file)
@@ -323,7 +323,8 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
  * in the wrong place.
  */
 static int verify_parent_transid(struct extent_io_tree *io_tree,
-                                struct extent_buffer *eb, u64 parent_transid)
+                                struct extent_buffer *eb, u64 parent_transid,
+                                int atomic)
 {
        struct extent_state *cached_state = NULL;
        int ret;
@@ -331,6 +332,9 @@ static int verify_parent_transid(struct extent_io_tree *io_tree,
        if (!parent_transid || btrfs_header_generation(eb) == parent_transid)
                return 0;
 
+       if (atomic)
+               return -EAGAIN;
+
        lock_extent_bits(io_tree, eb->start, eb->start + eb->len - 1,
                         0, &cached_state);
        if (extent_buffer_uptodate(eb) &&
@@ -372,7 +376,8 @@ static int btree_read_extent_buffer_pages(struct btrfs_root *root,
                ret = read_extent_buffer_pages(io_tree, eb, start,
                                               WAIT_COMPLETE,
                                               btree_get_extent, mirror_num);
-               if (!ret && !verify_parent_transid(io_tree, eb, parent_transid))
+               if (!ret && !verify_parent_transid(io_tree, eb,
+                                                  parent_transid, 0))
                        break;
 
                /*
@@ -383,17 +388,16 @@ static int btree_read_extent_buffer_pages(struct btrfs_root *root,
                if (test_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags))
                        break;
 
-               if (!failed_mirror) {
-                       failed = 1;
-                       printk(KERN_ERR "failed mirror was %d\n", eb->failed_mirror);
-                       failed_mirror = eb->failed_mirror;
-               }
-
                num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
                                              eb->start, eb->len);
                if (num_copies == 1)
                        break;
 
+               if (!failed_mirror) {
+                       failed = 1;
+                       failed_mirror = eb->read_mirror;
+               }
+
                mirror_num++;
                if (mirror_num == failed_mirror)
                        mirror_num++;
@@ -564,7 +568,7 @@ struct extent_buffer *find_eb_for_page(struct extent_io_tree *tree,
 }
 
 static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
-                              struct extent_state *state)
+                              struct extent_state *state, int mirror)
 {
        struct extent_io_tree *tree;
        u64 found_start;
@@ -589,6 +593,7 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
        if (!reads_done)
                goto err;
 
+       eb->read_mirror = mirror;
        if (test_bit(EXTENT_BUFFER_IOERR, &eb->bflags)) {
                ret = -EIO;
                goto err;
@@ -652,7 +657,7 @@ static int btree_io_failed_hook(struct page *page, int failed_mirror)
 
        eb = (struct extent_buffer *)page->private;
        set_bit(EXTENT_BUFFER_IOERR, &eb->bflags);
-       eb->failed_mirror = failed_mirror;
+       eb->read_mirror = failed_mirror;
        if (test_and_clear_bit(EXTENT_BUFFER_READAHEAD, &eb->bflags))
                btree_readahead_hook(root, eb, eb->start, -EIO);
        return -EIO;    /* we fixed nothing */
@@ -1202,7 +1207,7 @@ static int __must_check find_and_setup_root(struct btrfs_root *tree_root,
        root->commit_root = NULL;
        root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item),
                                     blocksize, generation);
-       if (!root->node || !btrfs_buffer_uptodate(root->node, generation)) {
+       if (!root->node || !btrfs_buffer_uptodate(root->node, generation, 0)) {
                free_extent_buffer(root->node);
                root->node = NULL;
                return -EIO;
@@ -2254,9 +2259,9 @@ int open_ctree(struct super_block *sb,
                goto fail_sb_buffer;
        }
 
-       if (sectorsize < PAGE_SIZE) {
-               printk(KERN_WARNING "btrfs: Incompatible sector size "
-                      "found on %s\n", sb->s_id);
+       if (sectorsize != PAGE_SIZE) {
+               printk(KERN_WARNING "btrfs: Incompatible sector size(%lu) "
+                      "found on %s\n", (unsigned long)sectorsize, sb->s_id);
                goto fail_sb_buffer;
        }
 
@@ -3143,7 +3148,8 @@ int close_ctree(struct btrfs_root *root)
        return 0;
 }
 
-int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid)
+int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,
+                         int atomic)
 {
        int ret;
        struct inode *btree_inode = buf->pages[0]->mapping->host;
@@ -3153,7 +3159,9 @@ int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid)
                return ret;
 
        ret = verify_parent_transid(&BTRFS_I(btree_inode)->io_tree, buf,
-                                   parent_transid);
+                                   parent_transid, atomic);
+       if (ret == -EAGAIN)
+               return ret;
        return !ret;
 }
 
index a7ace1a2dd12516a57102e44591f881e922ed89d..ab1830aaf0edbffba6a0cef86d13e9b3f2742cda 100644 (file)
@@ -66,7 +66,8 @@ void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr);
 void __btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr);
 void btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root);
 void btrfs_mark_buffer_dirty(struct extent_buffer *buf);
-int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid);
+int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,
+                         int atomic);
 int btrfs_set_buffer_uptodate(struct extent_buffer *buf);
 int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid);
 u32 btrfs_csum_data(struct btrfs_root *root, char *data, u32 seed, size_t len);
index 2b35f8d14bb9a14c7f1539268dce04973413512f..49fd7b66d57b272c7aeaea7db4b1bbd0985f8aa2 100644 (file)
@@ -2301,6 +2301,7 @@ static noinline int run_clustered_refs(struct btrfs_trans_handle *trans,
 
                                if (ret) {
                                        printk(KERN_DEBUG "btrfs: run_delayed_extent_op returned %d\n", ret);
+                                       spin_lock(&delayed_refs->lock);
                                        return ret;
                                }
 
@@ -2331,6 +2332,7 @@ static noinline int run_clustered_refs(struct btrfs_trans_handle *trans,
 
                if (ret) {
                        printk(KERN_DEBUG "btrfs: run_one_delayed_ref returned %d\n", ret);
+                       spin_lock(&delayed_refs->lock);
                        return ret;
                }
 
@@ -3769,13 +3771,10 @@ again:
                 */
                if (current->journal_info)
                        return -EAGAIN;
-               ret = wait_event_interruptible(space_info->wait,
-                                              !space_info->flush);
-               /* Must have been interrupted, return */
-               if (ret) {
-                       printk(KERN_DEBUG "btrfs: %s returning -EINTR\n", __func__);
+               ret = wait_event_killable(space_info->wait, !space_info->flush);
+               /* Must have been killed, return */
+               if (ret)
                        return -EINTR;
-               }
 
                spin_lock(&space_info->lock);
        }
@@ -4215,8 +4214,8 @@ static void update_global_block_rsv(struct btrfs_fs_info *fs_info)
 
        num_bytes = calc_global_metadata_size(fs_info);
 
-       spin_lock(&block_rsv->lock);
        spin_lock(&sinfo->lock);
+       spin_lock(&block_rsv->lock);
 
        block_rsv->size = num_bytes;
 
@@ -4242,8 +4241,8 @@ static void update_global_block_rsv(struct btrfs_fs_info *fs_info)
                block_rsv->full = 1;
        }
 
-       spin_unlock(&sinfo->lock);
        spin_unlock(&block_rsv->lock);
+       spin_unlock(&sinfo->lock);
 }
 
 static void init_global_block_rsv(struct btrfs_fs_info *fs_info)
@@ -6569,7 +6568,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
                        goto skip;
        }
 
-       if (!btrfs_buffer_uptodate(next, generation)) {
+       if (!btrfs_buffer_uptodate(next, generation, 0)) {
                btrfs_tree_unlock(next);
                free_extent_buffer(next);
                next = NULL;
index cd4b5e40022128894dacfa5d51e60b400a0793bc..c9018a05036e943a52ad91d81019bb4b934b6b9a 100644 (file)
@@ -402,20 +402,28 @@ static int split_state(struct extent_io_tree *tree, struct extent_state *orig,
        return 0;
 }
 
+static struct extent_state *next_state(struct extent_state *state)
+{
+       struct rb_node *next = rb_next(&state->rb_node);
+       if (next)
+               return rb_entry(next, struct extent_state, rb_node);
+       else
+               return NULL;
+}
+
 /*
  * utility function to clear some bits in an extent state struct.
- * it will optionally wake up any one waiting on this state (wake == 1), or
- * forcibly remove the state from the tree (delete == 1).
+ * it will optionally wake up any one waiting on this state (wake == 1)
  *
  * If no bits are set on the state struct after clearing things, the
  * struct is freed and removed from the tree
  */
-static int clear_state_bit(struct extent_io_tree *tree,
-                           struct extent_state *state,
-                           int *bits, int wake)
+static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
+                                           struct extent_state *state,
+                                           int *bits, int wake)
 {
+       struct extent_state *next;
        int bits_to_clear = *bits & ~EXTENT_CTLBITS;
-       int ret = state->state & bits_to_clear;
 
        if ((bits_to_clear & EXTENT_DIRTY) && (state->state & EXTENT_DIRTY)) {
                u64 range = state->end - state->start + 1;
@@ -427,6 +435,7 @@ static int clear_state_bit(struct extent_io_tree *tree,
        if (wake)
                wake_up(&state->wq);
        if (state->state == 0) {
+               next = next_state(state);
                if (state->tree) {
                        rb_erase(&state->rb_node, &tree->state);
                        state->tree = NULL;
@@ -436,8 +445,9 @@ static int clear_state_bit(struct extent_io_tree *tree,
                }
        } else {
                merge_state(tree, state);
+               next = next_state(state);
        }
-       return ret;
+       return next;
 }
 
 static struct extent_state *
@@ -476,7 +486,6 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
        struct extent_state *state;
        struct extent_state *cached;
        struct extent_state *prealloc = NULL;
-       struct rb_node *next_node;
        struct rb_node *node;
        u64 last_end;
        int err;
@@ -528,14 +537,11 @@ hit_next:
        WARN_ON(state->end < start);
        last_end = state->end;
 
-       if (state->end < end && !need_resched())
-               next_node = rb_next(&state->rb_node);
-       else
-               next_node = NULL;
-
        /* the state doesn't have the wanted bits, go ahead */
-       if (!(state->state & bits))
+       if (!(state->state & bits)) {
+               state = next_state(state);
                goto next;
+       }
 
        /*
         *     | ---- desired range ---- |
@@ -593,16 +599,13 @@ hit_next:
                goto out;
        }
 
-       clear_state_bit(tree, state, &bits, wake);
+       state = clear_state_bit(tree, state, &bits, wake);
 next:
        if (last_end == (u64)-1)
                goto out;
        start = last_end + 1;
-       if (start <= end && next_node) {
-               state = rb_entry(next_node, struct extent_state,
-                                rb_node);
+       if (start <= end && state && !need_resched())
                goto hit_next;
-       }
        goto search_again;
 
 out:
@@ -2301,7 +2304,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
        u64 start;
        u64 end;
        int whole_page;
-       int failed_mirror;
+       int mirror;
        int ret;
 
        if (err)
@@ -2340,20 +2343,18 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
                }
                spin_unlock(&tree->lock);
 
+               mirror = (int)(unsigned long)bio->bi_bdev;
                if (uptodate && tree->ops && tree->ops->readpage_end_io_hook) {
                        ret = tree->ops->readpage_end_io_hook(page, start, end,
-                                                             state);
+                                                             state, mirror);
                        if (ret)
                                uptodate = 0;
                        else
                                clean_io_failure(start, page);
                }
 
-               if (!uptodate)
-                       failed_mirror = (int)(unsigned long)bio->bi_bdev;
-
                if (!uptodate && tree->ops && tree->ops->readpage_io_failed_hook) {
-                       ret = tree->ops->readpage_io_failed_hook(page, failed_mirror);
+                       ret = tree->ops->readpage_io_failed_hook(page, mirror);
                        if (!ret && !err &&
                            test_bit(BIO_UPTODATE, &bio->bi_flags))
                                uptodate = 1;
@@ -2368,8 +2369,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
                         * can't handle the error it will return -EIO and we
                         * remain responsible for that page.
                         */
-                       ret = bio_readpage_error(bio, page, start, end,
-                                                       failed_mirror, NULL);
+                       ret = bio_readpage_error(bio, page, start, end, mirror, NULL);
                        if (ret == 0) {
                                uptodate =
                                        test_bit(BIO_UPTODATE, &bio->bi_flags);
@@ -4120,6 +4120,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
                        if (atomic_inc_not_zero(&exists->refs)) {
                                spin_unlock(&mapping->private_lock);
                                unlock_page(p);
+                               page_cache_release(p);
                                mark_extent_buffer_accessed(exists);
                                goto free_eb;
                        }
@@ -4199,8 +4200,7 @@ free_eb:
                        unlock_page(eb->pages[i]);
        }
 
-       if (!atomic_dec_and_test(&eb->refs))
-               return exists;
+       WARN_ON(!atomic_dec_and_test(&eb->refs));
        btrfs_release_extent_buffer(eb);
        return exists;
 }
@@ -4462,7 +4462,7 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
        }
 
        clear_bit(EXTENT_BUFFER_IOERR, &eb->bflags);
-       eb->failed_mirror = 0;
+       eb->read_mirror = 0;
        atomic_set(&eb->io_pages, num_reads);
        for (i = start_i; i < num_pages; i++) {
                page = extent_buffer_page(eb, i);
index faf10eb57f75eb29edf1a8fb42468fb7924b666a..b516c3b8dec68d825e380a1930976f34c8a3e1a4 100644 (file)
@@ -79,7 +79,7 @@ struct extent_io_ops {
                                        u64 start, u64 end,
                                       struct extent_state *state);
        int (*readpage_end_io_hook)(struct page *page, u64 start, u64 end,
-                                   struct extent_state *state);
+                                   struct extent_state *state, int mirror);
        int (*writepage_end_io_hook)(struct page *page, u64 start, u64 end,
                                      struct extent_state *state, int uptodate);
        void (*set_bit_hook)(struct inode *inode, struct extent_state *state,
@@ -135,7 +135,7 @@ struct extent_buffer {
        spinlock_t refs_lock;
        atomic_t refs;
        atomic_t io_pages;
-       int failed_mirror;
+       int read_mirror;
        struct list_head leak_list;
        struct rcu_head rcu_head;
        pid_t lock_owner;
index d83260d7498fe2b535a59069ebba7c3ae78e255e..53bf2d764bbc4f5814db04710d3123d03c3779ba 100644 (file)
@@ -567,6 +567,7 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode,
        int extent_type;
        int recow;
        int ret;
+       int modify_tree = -1;
 
        if (drop_cache)
                btrfs_drop_extent_cache(inode, start, end - 1, 0);
@@ -575,10 +576,13 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode,
        if (!path)
                return -ENOMEM;
 
+       if (start >= BTRFS_I(inode)->disk_i_size)
+               modify_tree = 0;
+
        while (1) {
                recow = 0;
                ret = btrfs_lookup_file_extent(trans, root, path, ino,
-                                              search_start, -1);
+                                              search_start, modify_tree);
                if (ret < 0)
                        break;
                if (ret > 0 && path->slots[0] > 0 && search_start == start) {
@@ -634,7 +638,8 @@ next_slot:
                }
 
                search_start = max(key.offset, start);
-               if (recow) {
+               if (recow || !modify_tree) {
+                       modify_tree = -1;
                        btrfs_release_path(path);
                        continue;
                }
index 115bc05e42b06fee05ef7551cef1ad4174557634..61b16c641ce0975fcbd302fc6156820233c15c93 100644 (file)
@@ -1947,7 +1947,7 @@ static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end,
  * extent_io.c will try to find good copies for us.
  */
 static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end,
-                              struct extent_state *state)
+                              struct extent_state *state, int mirror)
 {
        size_t offset = start - ((u64)page->index << PAGE_CACHE_SHIFT);
        struct inode *inode = page->mapping->host;
@@ -4069,7 +4069,7 @@ static struct inode *new_simple_dir(struct super_block *s,
        BTRFS_I(inode)->dummy_inode = 1;
 
        inode->i_ino = BTRFS_EMPTY_SUBVOL_DIR_OBJECTID;
-       inode->i_op = &simple_dir_inode_operations;
+       inode->i_op = &btrfs_dir_ro_inode_operations;
        inode->i_fop = &simple_dir_operations;
        inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
        inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
@@ -4140,14 +4140,18 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
 static int btrfs_dentry_delete(const struct dentry *dentry)
 {
        struct btrfs_root *root;
+       struct inode *inode = dentry->d_inode;
 
-       if (!dentry->d_inode && !IS_ROOT(dentry))
-               dentry = dentry->d_parent;
+       if (!inode && !IS_ROOT(dentry))
+               inode = dentry->d_parent->d_inode;
 
-       if (dentry->d_inode) {
-               root = BTRFS_I(dentry->d_inode)->root;
+       if (inode) {
+               root = BTRFS_I(inode)->root;
                if (btrfs_root_refs(&root->root_item) == 0)
                        return 1;
+
+               if (btrfs_ino(inode) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)
+                       return 1;
        }
        return 0;
 }
@@ -4188,7 +4192,6 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
        struct btrfs_path *path;
        struct list_head ins_list;
        struct list_head del_list;
-       struct qstr q;
        int ret;
        struct extent_buffer *leaf;
        int slot;
@@ -4279,7 +4282,6 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
 
                while (di_cur < di_total) {
                        struct btrfs_key location;
-                       struct dentry *tmp;
 
                        if (verify_dir_item(root, leaf, di))
                                break;
@@ -4300,35 +4302,15 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
                        d_type = btrfs_filetype_table[btrfs_dir_type(leaf, di)];
                        btrfs_dir_item_key_to_cpu(leaf, di, &location);
 
-                       q.name = name_ptr;
-                       q.len = name_len;
-                       q.hash = full_name_hash(q.name, q.len);
-                       tmp = d_lookup(filp->f_dentry, &q);
-                       if (!tmp) {
-                               struct btrfs_key *newkey;
-
-                               newkey = kzalloc(sizeof(struct btrfs_key),
-                                                GFP_NOFS);
-                               if (!newkey)
-                                       goto no_dentry;
-                               tmp = d_alloc(filp->f_dentry, &q);
-                               if (!tmp) {
-                                       kfree(newkey);
-                                       dput(tmp);
-                                       goto no_dentry;
-                               }
-                               memcpy(newkey, &location,
-                                      sizeof(struct btrfs_key));
-                               tmp->d_fsdata = newkey;
-                               tmp->d_flags |= DCACHE_NEED_LOOKUP;
-                               d_rehash(tmp);
-                               dput(tmp);
-                       } else {
-                               dput(tmp);
-                       }
-no_dentry:
+
                        /* is this a reference to our own snapshot? If so
-                        * skip it
+                        * skip it.
+                        *
+                        * In contrast to old kernels, we insert the snapshot's
+                        * dir item and dir index after it has been created, so
+                        * we won't find a reference to our own snapshot. We
+                        * still keep the following code for backward
+                        * compatibility.
                         */
                        if (location.type == BTRFS_ROOT_ITEM_KEY &&
                            location.objectid == root->root_key.objectid) {
index 18cc23d164a80b7ccc717a83499214b81f395896..14f8e1faa46ee0478ebb83d6f82d205d25c1dc51 100644 (file)
@@ -2262,7 +2262,10 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg)
        di_args->bytes_used = dev->bytes_used;
        di_args->total_bytes = dev->total_bytes;
        memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid));
-       strncpy(di_args->path, dev->name, sizeof(di_args->path));
+       if (dev->name)
+               strncpy(di_args->path, dev->name, sizeof(di_args->path));
+       else
+               di_args->path[0] = '\0';
 
 out:
        if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args)))
index 4f69028a68c486268bf5bcfc097a5412dbdd2ad0..086e6bdae1c4482b93b6dda4d16b1c5af288f2eb 100644 (file)
@@ -252,7 +252,7 @@ struct btrfs_data_container {
 
 struct btrfs_ioctl_ino_path_args {
        __u64                           inum;           /* in */
-       __u32                           size;           /* in */
+       __u64                           size;           /* in */
        __u64                           reserved[4];
        /* struct btrfs_data_container  *fspath;           out */
        __u64                           fspath;         /* out */
@@ -260,7 +260,7 @@ struct btrfs_ioctl_ino_path_args {
 
 struct btrfs_ioctl_logical_ino_args {
        __u64                           logical;        /* in */
-       __u32                           size;           /* in */
+       __u64                           size;           /* in */
        __u64                           reserved[4];
        /* struct btrfs_data_container  *inodes;        out   */
        __u64                           inodes;
index dc5d33146fdbb9f4fb3cf899d78a97ca361b6ac8..ac5d010858848d007e380d529476ad9eb4f6fb31 100644 (file)
@@ -250,14 +250,12 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
                                          struct btrfs_bio *bbio)
 {
        int ret;
-       int looped = 0;
        struct reada_zone *zone;
        struct btrfs_block_group_cache *cache = NULL;
        u64 start;
        u64 end;
        int i;
 
-again:
        zone = NULL;
        spin_lock(&fs_info->reada_lock);
        ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone,
@@ -274,9 +272,6 @@ again:
                spin_unlock(&fs_info->reada_lock);
        }
 
-       if (looped)
-               return NULL;
-
        cache = btrfs_lookup_block_group(fs_info, logical);
        if (!cache)
                return NULL;
@@ -307,13 +302,15 @@ again:
        ret = radix_tree_insert(&dev->reada_zones,
                                (unsigned long)(zone->end >> PAGE_CACHE_SHIFT),
                                zone);
-       spin_unlock(&fs_info->reada_lock);
 
-       if (ret) {
+       if (ret == -EEXIST) {
                kfree(zone);
-               looped = 1;
-               goto again;
+               ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone,
+                                            logical >> PAGE_CACHE_SHIFT, 1);
+               if (ret == 1)
+                       kref_get(&zone->refcnt);
        }
+       spin_unlock(&fs_info->reada_lock);
 
        return zone;
 }
@@ -323,26 +320,26 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
                                              struct btrfs_key *top, int level)
 {
        int ret;
-       int looped = 0;
        struct reada_extent *re = NULL;
+       struct reada_extent *re_exist = NULL;
        struct btrfs_fs_info *fs_info = root->fs_info;
        struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree;
        struct btrfs_bio *bbio = NULL;
        struct btrfs_device *dev;
+       struct btrfs_device *prev_dev;
        u32 blocksize;
        u64 length;
        int nzones = 0;
        int i;
        unsigned long index = logical >> PAGE_CACHE_SHIFT;
 
-again:
        spin_lock(&fs_info->reada_lock);
        re = radix_tree_lookup(&fs_info->reada_tree, index);
        if (re)
                kref_get(&re->refcnt);
        spin_unlock(&fs_info->reada_lock);
 
-       if (re || looped)
+       if (re)
                return re;
 
        re = kzalloc(sizeof(*re), GFP_NOFS);
@@ -398,16 +395,31 @@ again:
        /* insert extent in reada_tree + all per-device trees, all or nothing */
        spin_lock(&fs_info->reada_lock);
        ret = radix_tree_insert(&fs_info->reada_tree, index, re);
+       if (ret == -EEXIST) {
+               re_exist = radix_tree_lookup(&fs_info->reada_tree, index);
+               BUG_ON(!re_exist);
+               kref_get(&re_exist->refcnt);
+               spin_unlock(&fs_info->reada_lock);
+               goto error;
+       }
        if (ret) {
                spin_unlock(&fs_info->reada_lock);
-               if (ret != -ENOMEM) {
-                       /* someone inserted the extent in the meantime */
-                       looped = 1;
-               }
                goto error;
        }
+       prev_dev = NULL;
        for (i = 0; i < nzones; ++i) {
                dev = bbio->stripes[i].dev;
+               if (dev == prev_dev) {
+                       /*
+                        * in case of DUP, just add the first zone. As both
+                        * are on the same device, there's nothing to gain
+                        * from adding both.
+                        * Also, it wouldn't work, as the tree is per device
+                        * and adding would fail with EEXIST
+                        */
+                       continue;
+               }
+               prev_dev = dev;
                ret = radix_tree_insert(&dev->reada_extents, index, re);
                if (ret) {
                        while (--i >= 0) {
@@ -450,9 +462,7 @@ error:
        }
        kfree(bbio);
        kfree(re);
-       if (looped)
-               goto again;
-       return NULL;
+       return re_exist;
 }
 
 static void reada_kref_dummy(struct kref *kr)
index 017281dbb2a71f6a0c51f4f8cc52cf9e651f2fd0..646ee21bb035d9ad8a4b1628e6883544c0603ea6 100644 (file)
@@ -1279,7 +1279,9 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
                if (rb_node)
                        backref_tree_panic(rb_node, -EEXIST, node->bytenr);
        } else {
+               spin_lock(&root->fs_info->trans_lock);
                list_del_init(&root->root_list);
+               spin_unlock(&root->fs_info->trans_lock);
                kfree(node);
        }
        return 0;
@@ -3811,7 +3813,7 @@ restart:
 
                ret = btrfs_block_rsv_check(rc->extent_root, rc->block_rsv, 5);
                if (ret < 0) {
-                       if (ret != -EAGAIN) {
+                       if (ret != -ENOSPC) {
                                err = ret;
                                WARN_ON(1);
                                break;
index bc015f77f3ea2e2c0500d4428ce2cbd54aa6834f..2f3d6f917fb3373c02335b6912fcba1006f5fabe 100644 (file)
@@ -998,6 +998,7 @@ static int scrub_setup_recheck_block(struct scrub_dev *sdev,
                        page = sblock->pagev + page_index;
                        page->logical = logical;
                        page->physical = bbio->stripes[mirror_index].physical;
+                       /* for missing devices, bdev is NULL */
                        page->bdev = bbio->stripes[mirror_index].dev->bdev;
                        page->mirror_num = mirror_index + 1;
                        page->page = alloc_page(GFP_NOFS);
@@ -1042,6 +1043,12 @@ static int scrub_recheck_block(struct btrfs_fs_info *fs_info,
                struct scrub_page *page = sblock->pagev + page_num;
                DECLARE_COMPLETION_ONSTACK(complete);
 
+               if (page->bdev == NULL) {
+                       page->io_error = 1;
+                       sblock->no_io_error_seen = 0;
+                       continue;
+               }
+
                BUG_ON(!page->page);
                bio = bio_alloc(GFP_NOFS, 1);
                if (!bio)
@@ -1257,12 +1264,6 @@ static int scrub_checksum_data(struct scrub_block *sblock)
        if (memcmp(csum, on_disk_csum, sdev->csum_size))
                fail = 1;
 
-       if (fail) {
-               spin_lock(&sdev->stat_lock);
-               ++sdev->stat.csum_errors;
-               spin_unlock(&sdev->stat_lock);
-       }
-
        return fail;
 }
 
@@ -1335,15 +1336,6 @@ static int scrub_checksum_tree_block(struct scrub_block *sblock)
        if (memcmp(calculated_csum, on_disk_csum, sdev->csum_size))
                ++crc_fail;
 
-       if (crc_fail || fail) {
-               spin_lock(&sdev->stat_lock);
-               if (crc_fail)
-                       ++sdev->stat.csum_errors;
-               if (fail)
-                       ++sdev->stat.verify_errors;
-               spin_unlock(&sdev->stat_lock);
-       }
-
        return fail || crc_fail;
 }
 
index 8d5d380f7bdb8a81b576c51ac487ccc492051d2f..c5f8fca4195fca9eb3806ebfbccf52d03049691e 100644 (file)
@@ -815,7 +815,6 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
                return 0;
        }
 
-       btrfs_start_delalloc_inodes(root, 0);
        btrfs_wait_ordered_extents(root, 0, 0);
 
        trans = btrfs_start_transaction(root, 0);
@@ -1148,13 +1147,15 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
                if (ret)
                        goto restore;
        } else {
-               if (fs_info->fs_devices->rw_devices == 0)
+               if (fs_info->fs_devices->rw_devices == 0) {
                        ret = -EACCES;
                        goto restore;
+               }
 
-               if (btrfs_super_log_root(fs_info->super_copy) != 0)
+               if (btrfs_super_log_root(fs_info->super_copy) != 0) {
                        ret = -EINVAL;
                        goto restore;
+               }
 
                ret = btrfs_cleanup_fs_roots(fs_info);
                if (ret)
index 11b77a59db629923368f993b3a3b5f6e7a883f15..36422254ef6765c14290a2373fa6d83cf2d364d5 100644 (file)
@@ -73,8 +73,10 @@ loop:
 
        cur_trans = root->fs_info->running_transaction;
        if (cur_trans) {
-               if (cur_trans->aborted)
+               if (cur_trans->aborted) {
+                       spin_unlock(&root->fs_info->trans_lock);
                        return cur_trans->aborted;
+               }
                atomic_inc(&cur_trans->use_count);
                atomic_inc(&cur_trans->num_writers);
                cur_trans->num_joined++;
@@ -1400,6 +1402,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
        ret = commit_fs_roots(trans, root);
        if (ret) {
                mutex_unlock(&root->fs_info->tree_log_mutex);
+               mutex_unlock(&root->fs_info->reloc_mutex);
                goto cleanup_transaction;
        }
 
@@ -1411,6 +1414,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
        ret = commit_cowonly_roots(trans, root);
        if (ret) {
                mutex_unlock(&root->fs_info->tree_log_mutex);
+               mutex_unlock(&root->fs_info->reloc_mutex);
                goto cleanup_transaction;
        }
 
index d017283ae6f56fa8ea0ba1eeaa04077d443eb0fb..eb1ae908582cc51162a61798c80f3ed38e7ab6e8 100644 (file)
@@ -279,7 +279,7 @@ static int process_one_buffer(struct btrfs_root *log,
                                                log->fs_info->extent_root,
                                                eb->start, eb->len);
 
-       if (btrfs_buffer_uptodate(eb, gen)) {
+       if (btrfs_buffer_uptodate(eb, gen, 0)) {
                if (wc->write)
                        btrfs_write_tree_block(eb);
                if (wc->wait)
index 759d02486d7ccb2dcb2ff1b1334396cc219880ca..1411b99555a4c1f138a6a3bf699842849d2b3e08 100644 (file)
@@ -3324,12 +3324,14 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
        stripe_size = devices_info[ndevs-1].max_avail;
        num_stripes = ndevs * dev_stripes;
 
-       if (stripe_size * num_stripes > max_chunk_size * ncopies) {
+       if (stripe_size * ndevs > max_chunk_size * ncopies) {
                stripe_size = max_chunk_size * ncopies;
-               do_div(stripe_size, num_stripes);
+               do_div(stripe_size, ndevs);
        }
 
        do_div(stripe_size, dev_stripes);
+
+       /* align to BTRFS_STRIPE_LEN */
        do_div(stripe_size, BTRFS_STRIPE_LEN);
        stripe_size *= BTRFS_STRIPE_LEN;
 
@@ -3805,10 +3807,11 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,
                else if (mirror_num)
                        stripe_index += mirror_num - 1;
                else {
+                       int old_stripe_index = stripe_index;
                        stripe_index = find_live_mirror(map, stripe_index,
                                              map->sub_stripes, stripe_index +
                                              current->pid % map->sub_stripes);
-                       mirror_num = stripe_index + 1;
+                       mirror_num = stripe_index - old_stripe_index + 1;
                }
        } else {
                /*
@@ -4350,8 +4353,10 @@ static int open_seed_devices(struct btrfs_root *root, u8 *fsid)
 
        ret = __btrfs_open_devices(fs_devices, FMODE_READ,
                                   root->fs_info->bdev_holder);
-       if (ret)
+       if (ret) {
+               free_fs_devices(fs_devices);
                goto out;
+       }
 
        if (!fs_devices->seeding) {
                __btrfs_close_devices(fs_devices);
index 36d66653b93191c9c13c21e74dea6f511a6ac9ab..351e18ea2e53a911abcab29f57325a4f31ded786 100644 (file)
@@ -985,7 +985,6 @@ grow_dev_page(struct block_device *bdev, sector_t block,
        return page;
 
 failed:
-       BUG();
        unlock_page(page);
        page_cache_release(page);
        return NULL;
index d34212822444221d8698b716bc817857ab577f5d..ca6a3796a33bb0640b6444891713196834340eb4 100644 (file)
@@ -370,13 +370,13 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
                                   (int)(srcaddr->sa_family));
        }
 
-       seq_printf(s, ",uid=%d", cifs_sb->mnt_uid);
+       seq_printf(s, ",uid=%u", cifs_sb->mnt_uid);
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
                seq_printf(s, ",forceuid");
        else
                seq_printf(s, ",noforceuid");
 
-       seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
+       seq_printf(s, ",gid=%u", cifs_sb->mnt_gid);
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
                seq_printf(s, ",forcegid");
        else
@@ -434,11 +434,15 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
                seq_printf(s, ",noperm");
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)
                seq_printf(s, ",strictcache");
+       if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID)
+               seq_printf(s, ",backupuid=%u", cifs_sb->mnt_backupuid);
+       if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID)
+               seq_printf(s, ",backupgid=%u", cifs_sb->mnt_backupgid);
 
-       seq_printf(s, ",rsize=%d", cifs_sb->rsize);
-       seq_printf(s, ",wsize=%d", cifs_sb->wsize);
+       seq_printf(s, ",rsize=%u", cifs_sb->rsize);
+       seq_printf(s, ",wsize=%u", cifs_sb->wsize);
        /* convert actimeo and display it in seconds */
-               seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
+       seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
 
        return 0;
 }
index d1389bb33ceb98ffdc068b1192dad4f1d2b3f425..65365358c9766dcd2882ab643805565e552f4e25 100644 (file)
@@ -125,5 +125,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
 extern const struct export_operations cifs_export_ops;
 #endif /* CONFIG_CIFS_NFSD_EXPORT */
 
-#define CIFS_VERSION   "1.77"
+#define CIFS_VERSION   "1.78"
 #endif                         /* _CIFSFS_H */
index f52c5ab78f9dde7fa782bbb2ca26e7da70e450af..da2f5446fa7ae3d3bbba6bb1b7a92cd1cc8743e4 100644 (file)
@@ -4844,8 +4844,12 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
                max_len = data_end - temp;
                node->node_name = cifs_strndup_from_utf16(temp, max_len,
                                                is_unicode, nls_codepage);
-               if (!node->node_name)
+               if (!node->node_name) {
                        rc = -ENOMEM;
+                       goto parse_DFS_referrals_exit;
+               }
+
+               ref++;
        }
 
 parse_DFS_referrals_exit:
index f31dc9ac37b76f0014fe5584c88d35d836bb1659..5dcc55197fb3ff93f3ff3960e3f0b1522f163fc5 100644 (file)
@@ -215,6 +215,8 @@ static const match_table_t cifs_mount_option_tokens = {
 
        { Opt_ignore, "cred" },
        { Opt_ignore, "credentials" },
+       { Opt_ignore, "cred=%s" },
+       { Opt_ignore, "credentials=%s" },
        { Opt_ignore, "guest" },
        { Opt_ignore, "rw" },
        { Opt_ignore, "ro" },
@@ -2183,6 +2185,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
        tcp_ses->session_estab = false;
        tcp_ses->sequence_number = 0;
        tcp_ses->lstrp = jiffies;
+       spin_lock_init(&tcp_ses->req_lock);
        INIT_LIST_HEAD(&tcp_ses->tcp_ses_list);
        INIT_LIST_HEAD(&tcp_ses->smb_ses_list);
        INIT_DELAYED_WORK(&tcp_ses->echo, cifs_echo_request);
@@ -3228,10 +3231,6 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
 
        cifs_sb->mnt_uid = pvolume_info->linux_uid;
        cifs_sb->mnt_gid = pvolume_info->linux_gid;
-       if (pvolume_info->backupuid_specified)
-               cifs_sb->mnt_backupuid = pvolume_info->backupuid;
-       if (pvolume_info->backupgid_specified)
-               cifs_sb->mnt_backupgid = pvolume_info->backupgid;
        cifs_sb->mnt_file_mode = pvolume_info->file_mode;
        cifs_sb->mnt_dir_mode = pvolume_info->dir_mode;
        cFYI(1, "file mode: 0x%hx  dir mode: 0x%hx",
@@ -3262,10 +3261,14 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
                cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_RWPIDFORWARD;
        if (pvolume_info->cifs_acl)
                cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;
-       if (pvolume_info->backupuid_specified)
+       if (pvolume_info->backupuid_specified) {
                cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPUID;
-       if (pvolume_info->backupgid_specified)
+               cifs_sb->mnt_backupuid = pvolume_info->backupuid;
+       }
+       if (pvolume_info->backupgid_specified) {
                cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPGID;
+               cifs_sb->mnt_backupgid = pvolume_info->backupgid;
+       }
        if (pvolume_info->override_uid)
                cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID;
        if (pvolume_info->override_gid)
@@ -3614,22 +3617,6 @@ cifs_get_volume_info(char *mount_data, const char *devname)
        return volume_info;
 }
 
-/* make sure ra_pages is a multiple of rsize */
-static inline unsigned int
-cifs_ra_pages(struct cifs_sb_info *cifs_sb)
-{
-       unsigned int reads;
-       unsigned int rsize_pages = cifs_sb->rsize / PAGE_CACHE_SIZE;
-
-       if (rsize_pages >= default_backing_dev_info.ra_pages)
-               return default_backing_dev_info.ra_pages;
-       else if (rsize_pages == 0)
-               return rsize_pages;
-
-       reads = default_backing_dev_info.ra_pages / rsize_pages;
-       return reads * rsize_pages;
-}
-
 int
 cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info)
 {
@@ -3717,7 +3704,7 @@ try_mount_again:
        cifs_sb->rsize = cifs_negotiate_rsize(tcon, volume_info);
 
        /* tune readahead according to rsize */
-       cifs_sb->bdi.ra_pages = cifs_ra_pages(cifs_sb);
+       cifs_sb->bdi.ra_pages = cifs_sb->rsize / PAGE_CACHE_SIZE;
 
 remote_path_check:
 #ifdef CONFIG_CIFS_DFS_UPCALL
index d172c8ed901786f9e72ee40a50cb6bc22a3be571..ec4e9a2a12f843edf9e8d2f60c8a32f58011ec4d 100644 (file)
@@ -668,12 +668,19 @@ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
                        return 0;
                else {
                        /*
-                        * Forcibly invalidate automounting directory inodes
-                        * (remote DFS directories) so to have them
-                        * instantiated again for automount
+                        * If the inode wasn't known to be a dfs entry when
+                        * the dentry was instantiated, such as when created
+                        * via ->readdir(), it needs to be set now since the
+                        * attributes will have been updated by
+                        * cifs_revalidate_dentry().
                         */
-                       if (IS_AUTOMOUNT(direntry->d_inode))
-                               return 0;
+                       if (IS_AUTOMOUNT(direntry->d_inode) &&
+                          !(direntry->d_flags & DCACHE_NEED_AUTOMOUNT)) {
+                               spin_lock(&direntry->d_lock);
+                               direntry->d_flags |= DCACHE_NEED_AUTOMOUNT;
+                               spin_unlock(&direntry->d_lock);
+                       }
+
                        return 1;
                }
        }
index fae765dac934c61f894ef7216de527493316b37c..81725e9286e911f501e4a78d1d7c28768753d118 100644 (file)
@@ -2178,7 +2178,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
        unsigned long nr_pages, i;
        size_t copied, len, cur_len;
        ssize_t total_written = 0;
-       loff_t offset = *poffset;
+       loff_t offset;
        struct iov_iter it;
        struct cifsFileInfo *open_file;
        struct cifs_tcon *tcon;
@@ -2200,6 +2200,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
        cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
        open_file = file->private_data;
        tcon = tlink_tcon(open_file->tlink);
+       offset = *poffset;
 
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)
                pid = open_file->pid;
index b60ddc41d78385d168e67e98adc6020fedc1cfeb..b80531c917799475147ba59234c821ea52306fd3 100644 (file)
@@ -141,18 +141,29 @@ int proc_nr_dentry(ctl_table *table, int write, void __user *buffer,
  * Compare 2 name strings, return 0 if they match, otherwise non-zero.
  * The strings are both count bytes long, and count is non-zero.
  */
+#ifdef CONFIG_DCACHE_WORD_ACCESS
+
+#include <asm/word-at-a-time.h>
+/*
+ * NOTE! 'cs' and 'scount' come from a dentry, so it has a
+ * aligned allocation for this particular component. We don't
+ * strictly need the load_unaligned_zeropad() safety, but it
+ * doesn't hurt either.
+ *
+ * In contrast, 'ct' and 'tcount' can be from a pathname, and do
+ * need the careful unaligned handling.
+ */
 static inline int dentry_cmp(const unsigned char *cs, size_t scount,
                                const unsigned char *ct, size_t tcount)
 {
-#ifdef CONFIG_DCACHE_WORD_ACCESS
        unsigned long a,b,mask;
 
        if (unlikely(scount != tcount))
                return 1;
 
        for (;;) {
-               a = *(unsigned long *)cs;
-               b = *(unsigned long *)ct;
+               a = load_unaligned_zeropad(cs);
+               b = load_unaligned_zeropad(ct);
                if (tcount < sizeof(unsigned long))
                        break;
                if (unlikely(a != b))
@@ -165,7 +176,13 @@ static inline int dentry_cmp(const unsigned char *cs, size_t scount,
        }
        mask = ~(~0ul << tcount*8);
        return unlikely(!!((a ^ b) & mask));
+}
+
 #else
+
+static inline int dentry_cmp(const unsigned char *cs, size_t scount,
+                               const unsigned char *ct, size_t tcount)
+{
        if (scount != tcount)
                return 1;
 
@@ -177,9 +194,10 @@ static inline int dentry_cmp(const unsigned char *cs, size_t scount,
                tcount--;
        } while (tcount);
        return 0;
-#endif
 }
 
+#endif
+
 static void __d_free(struct rcu_head *head)
 {
        struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu);
index fa5c07d51dccf2cb1b66d4b2d04a4eec8a92e7da..4c58d4a3adc4f29c6a2829bc54ac4be122c77ae7 100644 (file)
@@ -1736,6 +1736,18 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
        if (now && conv && !(lkb->lkb_exflags & DLM_LKF_QUECVT))
                return 1;
 
+       /*
+        * Even if the convert is compat with all granted locks,
+        * QUECVT forces it behind other locks on the convert queue.
+        */
+
+       if (now && conv && (lkb->lkb_exflags & DLM_LKF_QUECVT)) {
+               if (list_empty(&r->res_convertqueue))
+                       return 1;
+               else
+                       goto out;
+       }
+
        /*
         * The NOORDER flag is set to avoid the standard vms rules on grant
         * order.
index 739b0985b398ea2d837af83e26fa305a6cdfdc30..c0b3c70ee87a2b8e0e46c01a87d63ac692aecc71 100644 (file)
@@ -1663,8 +1663,10 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd,
        if (op == EPOLL_CTL_ADD) {
                if (is_file_epoll(tfile)) {
                        error = -ELOOP;
-                       if (ep_loop_check(ep, tfile) != 0)
+                       if (ep_loop_check(ep, tfile) != 0) {
+                               clear_tfile_check_list();
                                goto error_tgt_fput;
+                       }
                } else
                        list_add(&tfile->f_tfile_llink, &tfile_check_list);
        }
index 6da193564e43b2dc6862dcca4c4aa52689479939..e1fb1d5de58eab4150792974f9784751f4638557 100644 (file)
@@ -1597,7 +1597,9 @@ static int parse_options(char *options, struct super_block *sb,
                         unsigned int *journal_ioprio,
                         int is_remount)
 {
+#ifdef CONFIG_QUOTA
        struct ext4_sb_info *sbi = EXT4_SB(sb);
+#endif
        char *p;
        substring_t args[MAX_OPT_ARGS];
        int token;
index f8411bd1b805b9f93df3dd4ea53e3a388bf5957e..5f5e70e047dc73440ab88f1c08adc51938d7930b 100644 (file)
@@ -200,10 +200,11 @@ static int make_mode(const unsigned int lmstate)
        return -1;
 }
 
-static u32 make_flags(const u32 lkid, const unsigned int gfs_flags,
+static u32 make_flags(struct gfs2_glock *gl, const unsigned int gfs_flags,
                      const int req)
 {
        u32 lkf = DLM_LKF_VALBLK;
+       u32 lkid = gl->gl_lksb.sb_lkid;
 
        if (gfs_flags & LM_FLAG_TRY)
                lkf |= DLM_LKF_NOQUEUE;
@@ -227,8 +228,11 @@ static u32 make_flags(const u32 lkid, const unsigned int gfs_flags,
                        BUG();
        }
 
-       if (lkid != 0) 
+       if (lkid != 0) {
                lkf |= DLM_LKF_CONVERT;
+               if (test_bit(GLF_BLOCKING, &gl->gl_flags))
+                       lkf |= DLM_LKF_QUECVT;
+       }
 
        return lkf;
 }
@@ -250,7 +254,7 @@ static int gdlm_lock(struct gfs2_glock *gl, unsigned int req_state,
        char strname[GDLM_STRNAME_BYTES] = "";
 
        req = make_mode(req_state);
-       lkf = make_flags(gl->gl_lksb.sb_lkid, flags, req);
+       lkf = make_flags(gl, flags, req);
        gfs2_glstats_inc(gl, GFS2_LKS_DCOUNT);
        gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT);
        if (gl->gl_lksb.sb_lkid) {
index 4dfbfec357e8837055c2131206e0ca812fbec4de..ec2a9c23f0c9a58b66a517aceeeab8092efaf11b 100644 (file)
@@ -366,6 +366,10 @@ int hfsplus_rename_cat(u32 cnid,
        err = hfs_brec_find(&src_fd);
        if (err)
                goto out;
+       if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
+               err = -EIO;
+               goto out;
+       }
 
        hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
                                src_fd.entrylength);
index 88e155f895c6f0376db9e387b9f56f521bbbeb2f..26b53fb09f684404b2c488057f13c08ec8b2c0e2 100644 (file)
@@ -150,6 +150,11 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
                filp->f_pos++;
                /* fall through */
        case 1:
+               if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+                       err = -EIO;
+                       goto out;
+               }
+
                hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
                        fd.entrylength);
                if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
@@ -181,6 +186,12 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
                        err = -EIO;
                        goto out;
                }
+
+               if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+                       err = -EIO;
+                       goto out;
+               }
+
                hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
                        fd.entrylength);
                type = be16_to_cpu(entry.type);
index 28cf06e4ec8466478ce34db5db271f179dc0d7b5..001ef01d2fe2705a6767075032ea9f9f9ed0ec04 100644 (file)
@@ -485,6 +485,7 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb,
                inode->i_fop = &simple_dir_operations;
                /* directory inodes start off with i_nlink == 2 (for "." entry) */
                inc_nlink(inode);
+               lockdep_annotate_inode_mutex_key(inode);
        }
        return inode;
 }
index 806525a7269c5e7bd7cd864a7350563e792c1858..840f70f507924a0ac4db70a9d729f715783b49be 100644 (file)
@@ -723,7 +723,7 @@ start_journal_io:
        if (commit_transaction->t_need_data_flush &&
            (journal->j_fs_dev != journal->j_dev) &&
            (journal->j_flags & JBD2_BARRIER))
-               blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL, NULL);
+               blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS, NULL);
 
        /* Done it all: now write the commit record asynchronously. */
        if (JBD2_HAS_INCOMPAT_FEATURE(journal,
@@ -859,7 +859,7 @@ wait_for_iobuf:
        if (JBD2_HAS_INCOMPAT_FEATURE(journal,
                                      JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT) &&
            journal->j_flags & JBD2_BARRIER) {
-               blkdev_issue_flush(journal->j_dev, GFP_KERNEL, NULL);
+               blkdev_issue_flush(journal->j_dev, GFP_NOFS, NULL);
        }
 
        if (err)
index 0062dd17eb55d0f7bc365d0e06064cfb34d43449..c42791914f8205e8608923608a44fcab5478a6ea 100644 (file)
@@ -1429,7 +1429,7 @@ unsigned int full_name_hash(const unsigned char *name, unsigned int len)
        unsigned long hash = 0;
 
        for (;;) {
-               a = *(unsigned long *)name;
+               a = load_unaligned_zeropad(name);
                if (len < sizeof(unsigned long))
                        break;
                hash += a;
@@ -1459,7 +1459,7 @@ static inline unsigned long hash_name(const char *name, unsigned int *hashp)
        do {
                hash = (hash + a) * 9;
                len += sizeof(unsigned long);
-               a = *(unsigned long *)(name+len);
+               a = load_unaligned_zeropad(name+len);
                /* Do we have any NUL or '/' bytes in this word? */
                mask = has_zero(a) | has_zero(a ^ REPEAT_BYTE('/'));
        } while (!mask);
index 9c94297bb70e9502c40825249eecb24093e142d2..7f6a23f0244e7340f2861ac6fb0d3a2d20721287 100644 (file)
@@ -38,6 +38,8 @@
 #include <linux/buffer_head.h> /* various write calls */
 #include <linux/prefetch.h>
 
+#include "../pnfs.h"
+#include "../internal.h"
 #include "blocklayout.h"
 
 #define NFSDBG_FACILITY        NFSDBG_PNFS_LD
@@ -868,7 +870,7 @@ nfs4_blk_get_deviceinfo(struct nfs_server *server, const struct nfs_fh *fh,
         * GETDEVICEINFO's maxcount
         */
        max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz;
-       max_pages = max_resp_sz >> PAGE_SHIFT;
+       max_pages = nfs_page_array_len(0, max_resp_sz);
        dprintk("%s max_resp_sz %u max_pages %d\n",
                __func__, max_resp_sz, max_pages);
 
index da7b5e4ff9ec19adc0c7e53452a87d7cd35a609b..60f7e4ec842cf1d4fd48f21862d1d5ece26efc88 100644 (file)
@@ -1729,7 +1729,8 @@ error:
  */
 struct nfs_server *nfs_clone_server(struct nfs_server *source,
                                    struct nfs_fh *fh,
-                                   struct nfs_fattr *fattr)
+                                   struct nfs_fattr *fattr,
+                                   rpc_authflavor_t flavor)
 {
        struct nfs_server *server;
        struct nfs_fattr *fattr_fsinfo;
@@ -1758,7 +1759,7 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
 
        error = nfs_init_server_rpcclient(server,
                        source->client->cl_timeout,
-                       source->client->cl_auth->au_flavor);
+                       flavor);
        if (error < 0)
                goto out_free_server;
        if (!IS_ERR(source->client_acl))
index 4aaf0316d76a040a1e17e60e00060b28005d59a2..8789210c6905a666c86612d9ac080f567ddbd89f 100644 (file)
@@ -1429,7 +1429,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
        }
 
        open_flags = nd->intent.open.flags;
-       attr.ia_valid = 0;
+       attr.ia_valid = ATTR_OPEN;
 
        ctx = create_nfs_open_context(dentry, open_flags);
        res = ERR_CAST(ctx);
@@ -1536,7 +1536,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
        if (IS_ERR(ctx))
                goto out;
 
-       attr.ia_valid = 0;
+       attr.ia_valid = ATTR_OPEN;
        if (openflags & O_TRUNC) {
                attr.ia_valid |= ATTR_SIZE;
                attr.ia_size = 0;
index b7f348bb618b8d8864f7a5e2569aff8f4ef4e3a7..ba3019f5934c21a610a96569b1d239b90eca0459 100644 (file)
@@ -554,12 +554,16 @@ static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,
        struct nfs_client *clp;
        int error = 0;
 
+       if (!try_module_get(THIS_MODULE))
+               return 0;
+
        while ((clp = nfs_get_client_for_event(sb->s_fs_info, event))) {
                error = __rpc_pipefs_event(clp, event, sb);
                nfs_put_client(clp);
                if (error)
                        break;
        }
+       module_put(THIS_MODULE);
        return error;
 }
 
index 2476dc69365f223d78a0b514991bcb88fa144ec9..b777bdaba4c52e72ee86a1d6c1e67ec381a37788 100644 (file)
@@ -165,7 +165,8 @@ extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *,
 extern void nfs_free_server(struct nfs_server *server);
 extern struct nfs_server *nfs_clone_server(struct nfs_server *,
                                           struct nfs_fh *,
-                                          struct nfs_fattr *);
+                                          struct nfs_fattr *,
+                                          rpc_authflavor_t);
 extern void nfs_mark_client_ready(struct nfs_client *clp, int state);
 extern int nfs4_check_client_ready(struct nfs_client *clp);
 extern struct nfs_client *nfs4_set_ds_client(struct nfs_client* mds_clp,
@@ -186,10 +187,10 @@ static inline void nfs_fs_proc_exit(void)
 
 /* nfs4namespace.c */
 #ifdef CONFIG_NFS_V4
-extern struct vfsmount *nfs_do_refmount(struct dentry *dentry);
+extern struct vfsmount *nfs_do_refmount(struct rpc_clnt *client, struct dentry *dentry);
 #else
 static inline
-struct vfsmount *nfs_do_refmount(struct dentry *dentry)
+struct vfsmount *nfs_do_refmount(struct rpc_clnt *client, struct dentry *dentry)
 {
        return ERR_PTR(-ENOENT);
 }
@@ -234,7 +235,6 @@ extern const u32 nfs41_maxwrite_overhead;
 /* nfs4proc.c */
 #ifdef CONFIG_NFS_V4
 extern struct rpc_procinfo nfs4_procedures[];
-void nfs_fixup_secinfo_attributes(struct nfs_fattr *, struct nfs_fh *);
 #endif
 
 extern int nfs4_init_ds_session(struct nfs_client *clp);
index 1807866bb3ab845098de2a95c695bee5460aaf37..d51868e5683c0b34530c9db38a0cd4c26277c0b8 100644 (file)
@@ -148,66 +148,31 @@ rpc_authflavor_t nfs_find_best_sec(struct nfs4_secinfo_flavors *flavors)
        return pseudoflavor;
 }
 
-static int nfs_negotiate_security(const struct dentry *parent,
-                                 const struct dentry *dentry,
-                                 rpc_authflavor_t *flavor)
+static struct rpc_clnt *nfs_lookup_mountpoint(struct inode *dir,
+                                             struct qstr *name,
+                                             struct nfs_fh *fh,
+                                             struct nfs_fattr *fattr)
 {
-       struct page *page;
-       struct nfs4_secinfo_flavors *flavors;
-       int (*secinfo)(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
-       int ret = -EPERM;
-
-       secinfo = NFS_PROTO(parent->d_inode)->secinfo;
-       if (secinfo != NULL) {
-               page = alloc_page(GFP_KERNEL);
-               if (!page) {
-                       ret = -ENOMEM;
-                       goto out;
-               }
-               flavors = page_address(page);
-               ret = secinfo(parent->d_inode, &dentry->d_name, flavors);
-               *flavor = nfs_find_best_sec(flavors);
-               put_page(page);
-       }
-
-out:
-       return ret;
-}
-
-static int nfs_lookup_with_sec(struct nfs_server *server, struct dentry *parent,
-                              struct dentry *dentry, struct path *path,
-                              struct nfs_fh *fh, struct nfs_fattr *fattr,
-                              rpc_authflavor_t *flavor)
-{
-       struct rpc_clnt *clone;
-       struct rpc_auth *auth;
        int err;
 
-       err = nfs_negotiate_security(parent, path->dentry, flavor);
-       if (err < 0)
-               goto out;
-       clone  = rpc_clone_client(server->client);
-       auth   = rpcauth_create(*flavor, clone);
-       if (!auth) {
-               err = -EIO;
-               goto out_shutdown;
-       }
-       err = server->nfs_client->rpc_ops->lookup(clone, parent->d_inode,
-                                                 &path->dentry->d_name,
-                                                 fh, fattr);
-out_shutdown:
-       rpc_shutdown_client(clone);
-out:
-       return err;
+       if (NFS_PROTO(dir)->version == 4)
+               return nfs4_proc_lookup_mountpoint(dir, name, fh, fattr);
+
+       err = NFS_PROTO(dir)->lookup(NFS_SERVER(dir)->client, dir, name, fh, fattr);
+       if (err)
+               return ERR_PTR(err);
+       return rpc_clone_client(NFS_SERVER(dir)->client);
 }
 #else /* CONFIG_NFS_V4 */
-static inline int nfs_lookup_with_sec(struct nfs_server *server,
-                                     struct dentry *parent, struct dentry *dentry,
-                                     struct path *path, struct nfs_fh *fh,
-                                     struct nfs_fattr *fattr,
-                                     rpc_authflavor_t *flavor)
+static inline struct rpc_clnt *nfs_lookup_mountpoint(struct inode *dir,
+                                                    struct qstr *name,
+                                                    struct nfs_fh *fh,
+                                                    struct nfs_fattr *fattr)
 {
-       return -EPERM;
+       int err = NFS_PROTO(dir)->lookup(NFS_SERVER(dir)->client, dir, name, fh, fattr);
+       if (err)
+               return ERR_PTR(err);
+       return rpc_clone_client(NFS_SERVER(dir)->client);
 }
 #endif /* CONFIG_NFS_V4 */
 
@@ -226,12 +191,10 @@ static inline int nfs_lookup_with_sec(struct nfs_server *server,
 struct vfsmount *nfs_d_automount(struct path *path)
 {
        struct vfsmount *mnt;
-       struct nfs_server *server = NFS_SERVER(path->dentry->d_inode);
        struct dentry *parent;
        struct nfs_fh *fh = NULL;
        struct nfs_fattr *fattr = NULL;
-       int err;
-       rpc_authflavor_t flavor = RPC_AUTH_UNIX;
+       struct rpc_clnt *client;
 
        dprintk("--> nfs_d_automount()\n");
 
@@ -249,21 +212,19 @@ struct vfsmount *nfs_d_automount(struct path *path)
 
        /* Look it up again to get its attributes */
        parent = dget_parent(path->dentry);
-       err = server->nfs_client->rpc_ops->lookup(server->client, parent->d_inode,
-                                                 &path->dentry->d_name,
-                                                 fh, fattr);
-       if (err == -EPERM && NFS_PROTO(parent->d_inode)->secinfo != NULL)
-               err = nfs_lookup_with_sec(server, parent, path->dentry, path, fh, fattr, &flavor);
+       client = nfs_lookup_mountpoint(parent->d_inode, &path->dentry->d_name, fh, fattr);
        dput(parent);
-       if (err != 0) {
-               mnt = ERR_PTR(err);
+       if (IS_ERR(client)) {
+               mnt = ERR_CAST(client);
                goto out;
        }
 
        if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL)
-               mnt = nfs_do_refmount(path->dentry);
+               mnt = nfs_do_refmount(client, path->dentry);
        else
-               mnt = nfs_do_submount(path->dentry, fh, fattr, flavor);
+               mnt = nfs_do_submount(path->dentry, fh, fattr, client->cl_auth->au_flavor);
+       rpc_shutdown_client(client);
+
        if (IS_ERR(mnt))
                goto out;
 
index 97ecc863dd76b46900e23758d4cbdda2f28f63d0..8d75021020b31f44f0fcb9ec6f1ff05a8b39b313 100644 (file)
@@ -59,6 +59,7 @@ struct nfs_unique_id {
 
 #define NFS_SEQID_CONFIRMED 1
 struct nfs_seqid_counter {
+       ktime_t create_time;
        int owner_id;
        int flags;
        u32 counter;
@@ -204,6 +205,9 @@ struct nfs4_state_maintenance_ops {
 extern const struct dentry_operations nfs4_dentry_operations;
 extern const struct inode_operations nfs4_dir_inode_operations;
 
+/* nfs4namespace.c */
+struct rpc_clnt *nfs4_create_sec_client(struct rpc_clnt *, struct inode *, struct qstr *);
+
 /* nfs4proc.c */
 extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);
 extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *);
@@ -212,8 +216,11 @@ extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);
 extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);
 extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait, bool roc);
 extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle);
-extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
-               struct nfs4_fs_locations *fs_locations, struct page *page);
+extern int nfs4_proc_fs_locations(struct rpc_clnt *, struct inode *, const struct qstr *,
+                                 struct nfs4_fs_locations *, struct page *);
+extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *, struct qstr *,
+                           struct nfs_fh *, struct nfs_fattr *);
+extern int nfs4_proc_secinfo(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
 extern int nfs4_release_lockowner(struct nfs4_lock_state *);
 extern const struct xattr_handler *nfs4_xattr_handlers[];
 
index a866bbd2890a056b530ebe3ae91cd74b0862f4a1..c9cff9adb2d3f7c832f3e3bc7e6d76ec45a6e692 100644 (file)
@@ -699,7 +699,7 @@ get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id, gfp_t gfp_fla
         * GETDEVICEINFO's maxcount
         */
        max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz;
-       max_pages = max_resp_sz >> PAGE_SHIFT;
+       max_pages = nfs_page_array_len(0, max_resp_sz);
        dprintk("%s inode %p max_resp_sz %u max_pages %d\n",
                __func__, inode, max_resp_sz, max_pages);
 
index 9c8eca315f431199aa481c0eabc6ae3e044f8267..a7f3dedc4ec7bade9df84ed6f0fc7524507b9c21 100644 (file)
@@ -51,6 +51,30 @@ Elong:
        return ERR_PTR(-ENAMETOOLONG);
 }
 
+/*
+ * return the path component of "<server>:<path>"
+ *  nfspath - the "<server>:<path>" string
+ *  end - one past the last char that could contain "<server>:"
+ * returns NULL on failure
+ */
+static char *nfs_path_component(const char *nfspath, const char *end)
+{
+       char *p;
+
+       if (*nfspath == '[') {
+               /* parse [] escaped IPv6 addrs */
+               p = strchr(nfspath, ']');
+               if (p != NULL && ++p < end && *p == ':')
+                       return p + 1;
+       } else {
+               /* otherwise split on first colon */
+               p = strchr(nfspath, ':');
+               if (p != NULL && p < end)
+                       return p + 1;
+       }
+       return NULL;
+}
+
 /*
  * Determine the mount path as a string
  */
@@ -59,9 +83,9 @@ static char *nfs4_path(struct dentry *dentry, char *buffer, ssize_t buflen)
        char *limit;
        char *path = nfs_path(&limit, dentry, buffer, buflen);
        if (!IS_ERR(path)) {
-               char *colon = strchr(path, ':');
-               if (colon && colon < limit)
-                       path = colon + 1;
+               char *path_component = nfs_path_component(path, limit);
+               if (path_component)
+                       return path_component;
        }
        return path;
 }
@@ -108,6 +132,58 @@ static size_t nfs_parse_server_name(char *string, size_t len,
        return ret;
 }
 
+static rpc_authflavor_t nfs4_negotiate_security(struct inode *inode, struct qstr *name)
+{
+       struct page *page;
+       struct nfs4_secinfo_flavors *flavors;
+       rpc_authflavor_t flavor;
+       int err;
+
+       page = alloc_page(GFP_KERNEL);
+       if (!page)
+               return -ENOMEM;
+       flavors = page_address(page);
+
+       err = nfs4_proc_secinfo(inode, name, flavors);
+       if (err < 0) {
+               flavor = err;
+               goto out;
+       }
+
+       flavor = nfs_find_best_sec(flavors);
+
+out:
+       put_page(page);
+       return flavor;
+}
+
+/*
+ * Please call rpc_shutdown_client() when you are done with this client.
+ */
+struct rpc_clnt *nfs4_create_sec_client(struct rpc_clnt *clnt, struct inode *inode,
+                                       struct qstr *name)
+{
+       struct rpc_clnt *clone;
+       struct rpc_auth *auth;
+       rpc_authflavor_t flavor;
+
+       flavor = nfs4_negotiate_security(inode, name);
+       if (flavor < 0)
+               return ERR_PTR(flavor);
+
+       clone = rpc_clone_client(clnt);
+       if (IS_ERR(clone))
+               return clone;
+
+       auth = rpcauth_create(flavor, clone);
+       if (!auth) {
+               rpc_shutdown_client(clone);
+               clone = ERR_PTR(-EIO);
+       }
+
+       return clone;
+}
+
 static struct vfsmount *try_location(struct nfs_clone_mount *mountdata,
                                     char *page, char *page2,
                                     const struct nfs4_fs_location *location)
@@ -224,7 +300,7 @@ out:
  * @dentry - dentry of referral
  *
  */
-struct vfsmount *nfs_do_refmount(struct dentry *dentry)
+struct vfsmount *nfs_do_refmount(struct rpc_clnt *client, struct dentry *dentry)
 {
        struct vfsmount *mnt = ERR_PTR(-ENOMEM);
        struct dentry *parent;
@@ -250,7 +326,7 @@ struct vfsmount *nfs_do_refmount(struct dentry *dentry)
        dprintk("%s: getting locations for %s/%s\n",
                __func__, parent->d_name.name, dentry->d_name.name);
 
-       err = nfs4_proc_fs_locations(parent->d_inode, &dentry->d_name, fs_locations, page);
+       err = nfs4_proc_fs_locations(client, parent->d_inode, &dentry->d_name, fs_locations, page);
        dput(parent);
        if (err != 0 ||
            fs_locations->nlocations <= 0 ||
index f82bde005a822435fe8c4e7e20e99a60f3a5764c..99650aaf8937a28a52f9fca9946771f61379a8c7 100644 (file)
@@ -838,7 +838,8 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
        p->o_arg.open_flags = flags;
        p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE);
        p->o_arg.clientid = server->nfs_client->cl_clientid;
-       p->o_arg.id = sp->so_seqid.owner_id;
+       p->o_arg.id.create_time = ktime_to_ns(sp->so_seqid.create_time);
+       p->o_arg.id.uniquifier = sp->so_seqid.owner_id;
        p->o_arg.name = &dentry->d_name;
        p->o_arg.server = server;
        p->o_arg.bitmask = server->attr_bitmask;
@@ -1466,8 +1467,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)
                        goto unlock_no_action;
                rcu_read_unlock();
        }
-       /* Update sequence id. */
-       data->o_arg.id = sp->so_seqid.owner_id;
+       /* Update client id. */
        data->o_arg.clientid = sp->so_server->nfs_client->cl_clientid;
        if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) {
                task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR];
@@ -1954,10 +1954,19 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
        };
        int err;
        do {
-               err = nfs4_handle_exception(server,
-                               _nfs4_do_setattr(inode, cred, fattr, sattr, state),
-                               &exception);
+               err = _nfs4_do_setattr(inode, cred, fattr, sattr, state);
+               switch (err) {
+               case -NFS4ERR_OPENMODE:
+                       if (state && !(state->state & FMODE_WRITE)) {
+                               err = -EBADF;
+                               if (sattr->ia_valid & ATTR_OPEN)
+                                       err = -EACCES;
+                               goto out;
+                       }
+               }
+               err = nfs4_handle_exception(server, err, &exception);
        } while (exception.retry);
+out:
        return err;
 }
 
@@ -2368,8 +2377,9 @@ static int nfs4_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
  * Note that we'll actually follow the referral later when
  * we detect fsid mismatch in inode revalidation
  */
-static int nfs4_get_referral(struct inode *dir, const struct qstr *name,
-                            struct nfs_fattr *fattr, struct nfs_fh *fhandle)
+static int nfs4_get_referral(struct rpc_clnt *client, struct inode *dir,
+                            const struct qstr *name, struct nfs_fattr *fattr,
+                            struct nfs_fh *fhandle)
 {
        int status = -ENOMEM;
        struct page *page = NULL;
@@ -2382,7 +2392,7 @@ static int nfs4_get_referral(struct inode *dir, const struct qstr *name,
        if (locations == NULL)
                goto out;
 
-       status = nfs4_proc_fs_locations(dir, name, locations, page);
+       status = nfs4_proc_fs_locations(client, dir, name, locations, page);
        if (status != 0)
                goto out;
        /* Make sure server returned a different fsid for the referral */
@@ -2519,39 +2529,84 @@ static int _nfs4_proc_lookup(struct rpc_clnt *clnt, struct inode *dir,
        return status;
 }
 
-void nfs_fixup_secinfo_attributes(struct nfs_fattr *fattr, struct nfs_fh *fh)
+static void nfs_fixup_secinfo_attributes(struct nfs_fattr *fattr)
 {
-       memset(fh, 0, sizeof(struct nfs_fh));
-       fattr->fsid.major = 1;
        fattr->valid |= NFS_ATTR_FATTR_TYPE | NFS_ATTR_FATTR_MODE |
-               NFS_ATTR_FATTR_NLINK | NFS_ATTR_FATTR_FSID | NFS_ATTR_FATTR_MOUNTPOINT;
+               NFS_ATTR_FATTR_NLINK | NFS_ATTR_FATTR_MOUNTPOINT;
        fattr->mode = S_IFDIR | S_IRUGO | S_IXUGO;
        fattr->nlink = 2;
 }
 
-static int nfs4_proc_lookup(struct rpc_clnt *clnt, struct inode *dir, struct qstr *name,
-                           struct nfs_fh *fhandle, struct nfs_fattr *fattr)
+static int nfs4_proc_lookup_common(struct rpc_clnt **clnt, struct inode *dir,
+                                  struct qstr *name, struct nfs_fh *fhandle,
+                                  struct nfs_fattr *fattr)
 {
        struct nfs4_exception exception = { };
+       struct rpc_clnt *client = *clnt;
        int err;
        do {
-               int status;
-
-               status = _nfs4_proc_lookup(clnt, dir, name, fhandle, fattr);
-               switch (status) {
+               err = _nfs4_proc_lookup(client, dir, name, fhandle, fattr);
+               switch (err) {
                case -NFS4ERR_BADNAME:
-                       return -ENOENT;
+                       err = -ENOENT;
+                       goto out;
                case -NFS4ERR_MOVED:
-                       return nfs4_get_referral(dir, name, fattr, fhandle);
+                       err = nfs4_get_referral(client, dir, name, fattr, fhandle);
+                       goto out;
                case -NFS4ERR_WRONGSEC:
-                       nfs_fixup_secinfo_attributes(fattr, fhandle);
+                       err = -EPERM;
+                       if (client != *clnt)
+                               goto out;
+
+                       client = nfs4_create_sec_client(client, dir, name);
+                       if (IS_ERR(client))
+                               return PTR_ERR(client);
+
+                       exception.retry = 1;
+                       break;
+               default:
+                       err = nfs4_handle_exception(NFS_SERVER(dir), err, &exception);
                }
-               err = nfs4_handle_exception(NFS_SERVER(dir),
-                               status, &exception);
        } while (exception.retry);
+
+out:
+       if (err == 0)
+               *clnt = client;
+       else if (client != *clnt)
+               rpc_shutdown_client(client);
+
        return err;
 }
 
+static int nfs4_proc_lookup(struct rpc_clnt *clnt, struct inode *dir, struct qstr *name,
+                           struct nfs_fh *fhandle, struct nfs_fattr *fattr)
+{
+       int status;
+       struct rpc_clnt *client = NFS_CLIENT(dir);
+
+       status = nfs4_proc_lookup_common(&client, dir, name, fhandle, fattr);
+       if (client != NFS_CLIENT(dir)) {
+               rpc_shutdown_client(client);
+               nfs_fixup_secinfo_attributes(fattr);
+       }
+       return status;
+}
+
+struct rpc_clnt *
+nfs4_proc_lookup_mountpoint(struct inode *dir, struct qstr *name,
+                           struct nfs_fh *fhandle, struct nfs_fattr *fattr)
+{
+       int status;
+       struct rpc_clnt *client = rpc_clone_client(NFS_CLIENT(dir));
+
+       status = nfs4_proc_lookup_common(&client, dir, name, fhandle, fattr);
+       if (status < 0) {
+               rpc_shutdown_client(client);
+               return ERR_PTR(status);
+       }
+       return client;
+}
+
 static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry)
 {
        struct nfs_server *server = NFS_SERVER(inode);
@@ -3619,16 +3674,16 @@ out:
        return ret;
 }
 
-static void nfs4_write_cached_acl(struct inode *inode, const char *buf, size_t acl_len)
+static void nfs4_write_cached_acl(struct inode *inode, struct page **pages, size_t pgbase, size_t acl_len)
 {
        struct nfs4_cached_acl *acl;
 
-       if (buf && acl_len <= PAGE_SIZE) {
+       if (pages && acl_len <= PAGE_SIZE) {
                acl = kmalloc(sizeof(*acl) + acl_len, GFP_KERNEL);
                if (acl == NULL)
                        goto out;
                acl->cached = 1;
-               memcpy(acl->data, buf, acl_len);
+               _copy_from_pages(acl->data, pages, pgbase, acl_len);
        } else {
                acl = kmalloc(sizeof(*acl), GFP_KERNEL);
                if (acl == NULL)
@@ -3661,7 +3716,6 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t bu
        struct nfs_getaclres res = {
                .acl_len = buflen,
        };
-       void *resp_buf;
        struct rpc_message msg = {
                .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_GETACL],
                .rpc_argp = &args,
@@ -3675,24 +3729,27 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t bu
        if (npages == 0)
                npages = 1;
 
+       /* Add an extra page to handle the bitmap returned */
+       npages++;
+
        for (i = 0; i < npages; i++) {
                pages[i] = alloc_page(GFP_KERNEL);
                if (!pages[i])
                        goto out_free;
        }
-       if (npages > 1) {
-               /* for decoding across pages */
-               res.acl_scratch = alloc_page(GFP_KERNEL);
-               if (!res.acl_scratch)
-                       goto out_free;
-       }
+
+       /* for decoding across pages */
+       res.acl_scratch = alloc_page(GFP_KERNEL);
+       if (!res.acl_scratch)
+               goto out_free;
+
        args.acl_len = npages * PAGE_SIZE;
        args.acl_pgbase = 0;
+
        /* Let decode_getfacl know not to fail if the ACL data is larger than
         * the page we send as a guess */
        if (buf == NULL)
                res.acl_flags |= NFS4_ACL_LEN_REQUEST;
-       resp_buf = page_address(pages[0]);
 
        dprintk("%s  buf %p buflen %zu npages %d args.acl_len %zu\n",
                __func__, buf, buflen, npages, args.acl_len);
@@ -3703,9 +3760,9 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t bu
 
        acl_len = res.acl_len - res.acl_data_offset;
        if (acl_len > args.acl_len)
-               nfs4_write_cached_acl(inode, NULL, acl_len);
+               nfs4_write_cached_acl(inode, NULL, 0, acl_len);
        else
-               nfs4_write_cached_acl(inode, resp_buf + res.acl_data_offset,
+               nfs4_write_cached_acl(inode, pages, res.acl_data_offset,
                                      acl_len);
        if (buf) {
                ret = -ERANGE;
@@ -4558,7 +4615,9 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
 static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request)
 {
        struct nfs_server *server = NFS_SERVER(state->inode);
-       struct nfs4_exception exception = { };
+       struct nfs4_exception exception = {
+               .inode = state->inode,
+       };
        int err;
 
        do {
@@ -4576,7 +4635,9 @@ static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request
 static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request)
 {
        struct nfs_server *server = NFS_SERVER(state->inode);
-       struct nfs4_exception exception = { };
+       struct nfs4_exception exception = {
+               .inode = state->inode,
+       };
        int err;
 
        err = nfs4_set_lock_state(state, request);
@@ -4676,6 +4737,7 @@ static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *
 {
        struct nfs4_exception exception = {
                .state = state,
+               .inode = state->inode,
        };
        int err;
 
@@ -4721,6 +4783,20 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
 
        if (state == NULL)
                return -ENOLCK;
+       /*
+        * Don't rely on the VFS having checked the file open mode,
+        * since it won't do this for flock() locks.
+        */
+       switch (request->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) {
+       case F_RDLCK:
+               if (!(filp->f_mode & FMODE_READ))
+                       return -EBADF;
+               break;
+       case F_WRLCK:
+               if (!(filp->f_mode & FMODE_WRITE))
+                       return -EBADF;
+       }
+
        do {
                status = nfs4_proc_setlk(state, cmd, request);
                if ((status != -EAGAIN) || IS_SETLK(cmd))
@@ -4891,8 +4967,10 @@ static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr)
        fattr->nlink = 2;
 }
 
-int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
-               struct nfs4_fs_locations *fs_locations, struct page *page)
+static int _nfs4_proc_fs_locations(struct rpc_clnt *client, struct inode *dir,
+                                  const struct qstr *name,
+                                  struct nfs4_fs_locations *fs_locations,
+                                  struct page *page)
 {
        struct nfs_server *server = NFS_SERVER(dir);
        u32 bitmask[2] = {
@@ -4926,11 +5004,26 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
        nfs_fattr_init(&fs_locations->fattr);
        fs_locations->server = server;
        fs_locations->nlocations = 0;
-       status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0);
+       status = nfs4_call_sync(client, server, &msg, &args.seq_args, &res.seq_res, 0);
        dprintk("%s: returned status = %d\n", __func__, status);
        return status;
 }
 
+int nfs4_proc_fs_locations(struct rpc_clnt *client, struct inode *dir,
+                          const struct qstr *name,
+                          struct nfs4_fs_locations *fs_locations,
+                          struct page *page)
+{
+       struct nfs4_exception exception = { };
+       int err;
+       do {
+               err = nfs4_handle_exception(NFS_SERVER(dir),
+                               _nfs4_proc_fs_locations(client, dir, name, fs_locations, page),
+                               &exception);
+       } while (exception.retry);
+       return err;
+}
+
 static int _nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, struct nfs4_secinfo_flavors *flavors)
 {
        int status;
@@ -4953,8 +5046,8 @@ static int _nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, struct
        return status;
 }
 
-static int nfs4_proc_secinfo(struct inode *dir, const struct qstr *name,
-               struct nfs4_secinfo_flavors *flavors)
+int nfs4_proc_secinfo(struct inode *dir, const struct qstr *name,
+                     struct nfs4_secinfo_flavors *flavors)
 {
        struct nfs4_exception exception = { };
        int err;
@@ -5029,10 +5122,9 @@ int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred)
        nfs4_construct_boot_verifier(clp, &verifier);
 
        args.id_len = scnprintf(args.id, sizeof(args.id),
-                               "%s/%s.%s/%u",
+                               "%s/%s/%u",
                                clp->cl_ipaddr,
-                               init_utsname()->nodename,
-                               init_utsname()->domainname,
+                               clp->cl_rpcclient->cl_nodename,
                                clp->cl_rpcclient->cl_auth->au_flavor);
 
        res.server_scope = kzalloc(sizeof(struct server_scope), GFP_KERNEL);
index 0f43414eb25a141be336c34bef78cc126cd9039f..7f0fcfc1fe9db51e9bc3748f511163dfed7cdce7 100644 (file)
@@ -393,6 +393,7 @@ nfs4_remove_state_owner_locked(struct nfs4_state_owner *sp)
 static void
 nfs4_init_seqid_counter(struct nfs_seqid_counter *sc)
 {
+       sc->create_time = ktime_get();
        sc->flags = 0;
        sc->counter = 0;
        spin_lock_init(&sc->lock);
@@ -434,13 +435,17 @@ nfs4_alloc_state_owner(struct nfs_server *server,
 static void
 nfs4_drop_state_owner(struct nfs4_state_owner *sp)
 {
-       if (!RB_EMPTY_NODE(&sp->so_server_node)) {
+       struct rb_node *rb_node = &sp->so_server_node;
+
+       if (!RB_EMPTY_NODE(rb_node)) {
                struct nfs_server *server = sp->so_server;
                struct nfs_client *clp = server->nfs_client;
 
                spin_lock(&clp->cl_lock);
-               rb_erase(&sp->so_server_node, &server->state_owners);
-               RB_CLEAR_NODE(&sp->so_server_node);
+               if (!RB_EMPTY_NODE(rb_node)) {
+                       rb_erase(rb_node, &server->state_owners);
+                       RB_CLEAR_NODE(rb_node);
+               }
                spin_unlock(&clp->cl_lock);
        }
 }
@@ -516,6 +521,14 @@ out:
 /**
  * nfs4_put_state_owner - Release a nfs4_state_owner
  * @sp: state owner data to release
+ *
+ * Note that we keep released state owners on an LRU
+ * list.
+ * This caches valid state owners so that they can be
+ * reused, to avoid the OPEN_CONFIRM on minor version 0.
+ * It also pins the uniquifier of dropped state owners for
+ * a while, to ensure that those state owner names are
+ * never reused.
  */
 void nfs4_put_state_owner(struct nfs4_state_owner *sp)
 {
@@ -525,15 +538,9 @@ void nfs4_put_state_owner(struct nfs4_state_owner *sp)
        if (!atomic_dec_and_lock(&sp->so_count, &clp->cl_lock))
                return;
 
-       if (!RB_EMPTY_NODE(&sp->so_server_node)) {
-               sp->so_expires = jiffies;
-               list_add_tail(&sp->so_lru, &server->state_owners_lru);
-               spin_unlock(&clp->cl_lock);
-       } else {
-               nfs4_remove_state_owner_locked(sp);
-               spin_unlock(&clp->cl_lock);
-               nfs4_free_state_owner(sp);
-       }
+       sp->so_expires = jiffies;
+       list_add_tail(&sp->so_lru, &server->state_owners_lru);
+       spin_unlock(&clp->cl_lock);
 }
 
 /**
index c74fdb114b48af141a719d1facd11ed249c5f5d1..c54aae364beebd38833151f97328c3edfe7c2337 100644 (file)
@@ -74,7 +74,7 @@ static int nfs4_stat_to_errno(int);
 /* lock,open owner id:
  * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT  >> 2)
  */
-#define open_owner_id_maxsz    (1 + 1 + 4)
+#define open_owner_id_maxsz    (1 + 2 + 1 + 1 + 2)
 #define lock_owner_id_maxsz    (1 + 1 + 4)
 #define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
 #define compound_encode_hdr_maxsz      (3 + (NFS4_MAXTAGLEN >> 2))
@@ -1340,12 +1340,13 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
  */
        encode_nfs4_seqid(xdr, arg->seqid);
        encode_share_access(xdr, arg->fmode);
-       p = reserve_space(xdr, 32);
+       p = reserve_space(xdr, 36);
        p = xdr_encode_hyper(p, arg->clientid);
-       *p++ = cpu_to_be32(20);
+       *p++ = cpu_to_be32(24);
        p = xdr_encode_opaque_fixed(p, "open id:", 8);
        *p++ = cpu_to_be32(arg->server->s_dev);
-       xdr_encode_hyper(p, arg->id);
+       *p++ = cpu_to_be32(arg->id.uniquifier);
+       xdr_encode_hyper(p, arg->id.create_time);
 }
 
 static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
@@ -4257,8 +4258,6 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap,
        status = decode_attr_error(xdr, bitmap, &err);
        if (status < 0)
                goto xdr_error;
-       if (err == -NFS4ERR_WRONGSEC)
-               nfs_fixup_secinfo_attributes(fattr, fh);
 
        status = decode_attr_filehandle(xdr, bitmap, fh);
        if (status < 0)
@@ -4901,11 +4900,19 @@ static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
                 bitmap[3] = {0};
        struct kvec *iov = req->rq_rcv_buf.head;
        int status;
+       size_t page_len = xdr->buf->page_len;
 
        res->acl_len = 0;
        if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0)
                goto out;
+
        bm_p = xdr->p;
+       res->acl_data_offset = be32_to_cpup(bm_p) + 2;
+       res->acl_data_offset <<= 2;
+       /* Check if the acl data starts beyond the allocated buffer */
+       if (res->acl_data_offset > page_len)
+               return -ERANGE;
+
        if ((status = decode_attr_bitmap(xdr, bitmap)) != 0)
                goto out;
        if ((status = decode_attr_length(xdr, &attrlen, &savep)) != 0)
@@ -4915,28 +4922,24 @@ static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
                return -EIO;
        if (likely(bitmap[0] & FATTR4_WORD0_ACL)) {
                size_t hdrlen;
-               u32 recvd;
 
                /* The bitmap (xdr len + bitmaps) and the attr xdr len words
                 * are stored with the acl data to handle the problem of
                 * variable length bitmaps.*/
                xdr->p = bm_p;
-               res->acl_data_offset = be32_to_cpup(bm_p) + 2;
-               res->acl_data_offset <<= 2;
 
                /* We ignore &savep and don't do consistency checks on
                 * the attr length.  Let userspace figure it out.... */
                hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base;
                attrlen += res->acl_data_offset;
-               recvd = req->rq_rcv_buf.len - hdrlen;
-               if (attrlen > recvd) {
+               if (attrlen > page_len) {
                        if (res->acl_flags & NFS4_ACL_LEN_REQUEST) {
                                /* getxattr interface called with a NULL buf */
                                res->acl_len = attrlen;
                                goto out;
                        }
-                       dprintk("NFS: acl reply: attrlen %u > recvd %u\n",
-                                       attrlen, recvd);
+                       dprintk("NFS: acl reply: attrlen %u > page_len %zu\n",
+                                       attrlen, page_len);
                        return -EINVAL;
                }
                xdr_read_pages(xdr, attrlen);
@@ -5089,16 +5092,13 @@ out_err:
        return -EINVAL;
 }
 
-static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
+static int decode_secinfo_common(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
 {
        struct nfs4_secinfo_flavor *sec_flavor;
        int status;
        __be32 *p;
        int i, num_flavors;
 
-       status = decode_op_hdr(xdr, OP_SECINFO);
-       if (status)
-               goto out;
        p = xdr_inline_decode(xdr, 4);
        if (unlikely(!p))
                goto out_overflow;
@@ -5124,6 +5124,7 @@ static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
                res->flavors->num_flavors++;
        }
 
+       status = 0;
 out:
        return status;
 out_overflow:
@@ -5131,7 +5132,23 @@ out_overflow:
        return -EIO;
 }
 
+static int decode_secinfo(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
+{
+       int status = decode_op_hdr(xdr, OP_SECINFO);
+       if (status)
+               return status;
+       return decode_secinfo_common(xdr, res);
+}
+
 #if defined(CONFIG_NFS_V4_1)
+static int decode_secinfo_no_name(struct xdr_stream *xdr, struct nfs4_secinfo_res *res)
+{
+       int status = decode_op_hdr(xdr, OP_SECINFO_NO_NAME);
+       if (status)
+               return status;
+       return decode_secinfo_common(xdr, res);
+}
+
 static int decode_exchange_id(struct xdr_stream *xdr,
                              struct nfs41_exchange_id_res *res)
 {
@@ -6816,7 +6833,7 @@ static int nfs4_xdr_dec_secinfo_no_name(struct rpc_rqst *rqstp,
        status = decode_putrootfh(xdr);
        if (status)
                goto out;
-       status = decode_secinfo(xdr, res);
+       status = decode_secinfo_no_name(xdr, res);
 out:
        return status;
 }
index 8d45f1c318ce40ac453b7b4a71288e71ba3c6a34..595c5fc21a19d15efaab48bff059336d7762c1b3 100644 (file)
@@ -604,7 +604,6 @@ int objlayout_get_deviceinfo(struct pnfs_layout_hdr *pnfslay,
 {
        struct objlayout_deviceinfo *odi;
        struct pnfs_device pd;
-       struct super_block *sb;
        struct page *page, **pages;
        u32 *p;
        int err;
@@ -623,7 +622,6 @@ int objlayout_get_deviceinfo(struct pnfs_layout_hdr *pnfslay,
        pd.pglen = PAGE_SIZE;
        pd.mincount = 0;
 
-       sb = pnfslay->plh_inode->i_sb;
        err = nfs4_proc_getdeviceinfo(NFS_SERVER(pnfslay->plh_inode), &pd);
        dprintk("%s nfs_getdeviceinfo returned %d\n", __func__, err);
        if (err)
index b5d4515869436dc6bd16a483590a433ac04c665c..38512bcd2e98b4c82e3b03e2592061c06897abe5 100644 (file)
@@ -587,7 +587,7 @@ send_layoutget(struct pnfs_layout_hdr *lo,
 
        /* allocate pages for xdr post processing */
        max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz;
-       max_pages = max_resp_sz >> PAGE_SHIFT;
+       max_pages = nfs_page_array_len(0, max_resp_sz);
 
        pages = kcalloc(max_pages, sizeof(struct page *), gfp_flags);
        if (!pages)
index 9a0e8ef4a40948d83d87d7a0898a49d55c3099c1..0a4be28c2ea3c76f57321bf765708924c4a2fdcf 100644 (file)
@@ -322,7 +322,7 @@ out_bad:
        while (!list_empty(res)) {
                data = list_entry(res->next, struct nfs_read_data, list);
                list_del(&data->list);
-               nfs_readdata_free(data);
+               nfs_readdata_release(data);
        }
        nfs_readpage_release(req);
        return -ENOMEM;
index 37412f706b32c83d5e0b3a95ae8665038ef43d68..4ac7fca7e4bf32fc01ac980c26dfcb255325f3b1 100644 (file)
@@ -2428,7 +2428,7 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags,
        dprintk("--> nfs_xdev_mount()\n");
 
        /* create a new volume representation */
-       server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
+       server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr, data->authflavor);
        if (IS_ERR(server)) {
                error = PTR_ERR(server);
                goto out_err_noserver;
@@ -2767,11 +2767,15 @@ static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type,
        char *root_devname;
        size_t len;
 
-       len = strlen(hostname) + 3;
+       len = strlen(hostname) + 5;
        root_devname = kmalloc(len, GFP_KERNEL);
        if (root_devname == NULL)
                return ERR_PTR(-ENOMEM);
-       snprintf(root_devname, len, "%s:/", hostname);
+       /* Does hostname needs to be enclosed in brackets? */
+       if (strchr(hostname, ':'))
+               snprintf(root_devname, len, "[%s]:/", hostname);
+       else
+               snprintf(root_devname, len, "%s:/", hostname);
        root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data);
        kfree(root_devname);
        return root_mnt;
@@ -2951,7 +2955,7 @@ nfs4_xdev_mount(struct file_system_type *fs_type, int flags,
        dprintk("--> nfs4_xdev_mount()\n");
 
        /* create a new volume representation */
-       server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
+       server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr, data->authflavor);
        if (IS_ERR(server)) {
                error = PTR_ERR(server);
                goto out_err_noserver;
index 2c68818f68ac056b8587c22bf40f8f5d229a6403..c07462320f6b5c41c09ba2ff054e75048951691f 100644 (file)
@@ -682,7 +682,8 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
                req->wb_bytes = rqend - req->wb_offset;
 out_unlock:
        spin_unlock(&inode->i_lock);
-       nfs_clear_request_commit(req);
+       if (req)
+               nfs_clear_request_commit(req);
        return req;
 out_flushme:
        spin_unlock(&inode->i_lock);
@@ -1018,7 +1019,7 @@ out_bad:
        while (!list_empty(res)) {
                data = list_entry(res->next, struct nfs_write_data, list);
                list_del(&data->list);
-               nfs_writedata_free(data);
+               nfs_writedata_release(data);
        }
        nfs_redirty_request(req);
        return -ENOMEM;
index 4767429264a25b3e6003953c8d3f1e70627b075d..ed3f9206a0ee87c914f133492f1f6011775bdef8 100644 (file)
@@ -577,7 +577,7 @@ cld_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
        struct cld_net *cn = nn->cld_net;
 
        if (mlen != sizeof(*cmsg)) {
-               dprintk("%s: got %lu bytes, expected %lu\n", __func__, mlen,
+               dprintk("%s: got %zu bytes, expected %zu\n", __func__, mlen,
                        sizeof(*cmsg));
                return -EINVAL;
        }
index 25feaa3faac068eba842438f9171f78ff189d7f8..fec5e4ad071a36bb8783bdcc8c40c07c614340a5 100644 (file)
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -346,6 +346,16 @@ static const struct pipe_buf_operations anon_pipe_buf_ops = {
        .get = generic_pipe_buf_get,
 };
 
+static const struct pipe_buf_operations packet_pipe_buf_ops = {
+       .can_merge = 0,
+       .map = generic_pipe_buf_map,
+       .unmap = generic_pipe_buf_unmap,
+       .confirm = generic_pipe_buf_confirm,
+       .release = anon_pipe_buf_release,
+       .steal = generic_pipe_buf_steal,
+       .get = generic_pipe_buf_get,
+};
+
 static ssize_t
 pipe_read(struct kiocb *iocb, const struct iovec *_iov,
           unsigned long nr_segs, loff_t pos)
@@ -407,6 +417,13 @@ redo:
                        ret += chars;
                        buf->offset += chars;
                        buf->len -= chars;
+
+                       /* Was it a packet buffer? Clean up and exit */
+                       if (buf->flags & PIPE_BUF_FLAG_PACKET) {
+                               total_len = chars;
+                               buf->len = 0;
+                       }
+
                        if (!buf->len) {
                                buf->ops = NULL;
                                ops->release(pipe, buf);
@@ -459,6 +476,11 @@ redo:
        return ret;
 }
 
+static inline int is_packetized(struct file *file)
+{
+       return (file->f_flags & O_DIRECT) != 0;
+}
+
 static ssize_t
 pipe_write(struct kiocb *iocb, const struct iovec *_iov,
            unsigned long nr_segs, loff_t ppos)
@@ -593,6 +615,11 @@ redo2:
                        buf->ops = &anon_pipe_buf_ops;
                        buf->offset = 0;
                        buf->len = chars;
+                       buf->flags = 0;
+                       if (is_packetized(filp)) {
+                               buf->ops = &packet_pipe_buf_ops;
+                               buf->flags = PIPE_BUF_FLAG_PACKET;
+                       }
                        pipe->nrbufs = ++bufs;
                        pipe->tmp_page = NULL;
 
@@ -1013,7 +1040,7 @@ struct file *create_write_pipe(int flags)
                goto err_dentry;
        f->f_mapping = inode->i_mapping;
 
-       f->f_flags = O_WRONLY | (flags & O_NONBLOCK);
+       f->f_flags = O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT));
        f->f_version = 0;
 
        return f;
@@ -1057,7 +1084,7 @@ int do_pipe_flags(int *fd, int flags)
        int error;
        int fdw, fdr;
 
-       if (flags & ~(O_CLOEXEC | O_NONBLOCK))
+       if (flags & ~(O_CLOEXEC | O_NONBLOCK | O_DIRECT))
                return -EINVAL;
 
        fw = create_write_pipe(flags);
index 2b9a7607cbd5496084ec386fcc2377752ab75107..2d60492d6df80c2e97694b066836b6c1377a570a 100644 (file)
@@ -597,9 +597,6 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,
                if (!page)
                        continue;
 
-               if (PageReserved(page))
-                       continue;
-
                /* Clear accessed and referenced bits. */
                ptep_test_and_clear_young(vma, addr, pte);
                ClearPageReferenced(page);
index eba66043cf1b7d1dccfc1956446ea9bafdbb588c..e8bcc4742e0e9a1f9563a27907871ab6ce727817 100644 (file)
@@ -499,9 +499,10 @@ typedef u64 acpi_integer;
 #define ACPI_STATE_D0                   (u8) 0
 #define ACPI_STATE_D1                   (u8) 1
 #define ACPI_STATE_D2                   (u8) 2
-#define ACPI_STATE_D3                   (u8) 3
-#define ACPI_STATE_D3_COLD              (u8) 4
-#define ACPI_D_STATES_MAX               ACPI_STATE_D3_COLD
+#define ACPI_STATE_D3_HOT               (u8) 3
+#define ACPI_STATE_D3                   (u8) 4
+#define ACPI_STATE_D3_COLD              ACPI_STATE_D3
+#define ACPI_D_STATES_MAX               ACPI_STATE_D3
 #define ACPI_D_STATE_COUNT              5
 
 #define ACPI_STATE_C0                   (u8) 0
index 0dd4e87f6fba9bb85dade657f99aa1fbafa2712f..5e5e3865f1edb3df5b928b6d0b2951b91c3dbccc 100644 (file)
@@ -35,6 +35,14 @@ typedef union sigval {
 #define __ARCH_SI_BAND_T long
 #endif
 
+#ifndef __ARCH_SI_CLOCK_T
+#define __ARCH_SI_CLOCK_T __kernel_clock_t
+#endif
+
+#ifndef __ARCH_SI_ATTRIBUTES
+#define __ARCH_SI_ATTRIBUTES
+#endif
+
 #ifndef HAVE_ARCH_SIGINFO_T
 
 typedef struct siginfo {
@@ -72,8 +80,8 @@ typedef struct siginfo {
                        __kernel_pid_t _pid;    /* which child */
                        __ARCH_SI_UID_T _uid;   /* sender's uid */
                        int _status;            /* exit code */
-                       __kernel_clock_t _utime;
-                       __kernel_clock_t _stime;
+                       __ARCH_SI_CLOCK_T _utime;
+                       __ARCH_SI_CLOCK_T _stime;
                } _sigchld;
 
                /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
@@ -91,7 +99,7 @@ typedef struct siginfo {
                        int _fd;
                } _sigpoll;
        } _sifields;
-} siginfo_t;
+} __ARCH_SI_ATTRIBUTES siginfo_t;
 
 #endif
 
index 0fd28e028de1d83130aeb751294159dffc39fa6a..c749af9c0983022876bffacf1aea628c270d4a34 100644 (file)
@@ -15,7 +15,7 @@ typedef __kernel_fsid_t       fsid_t;
  * with a 10' pole.
  */
 #ifndef __statfs_word
-#if BITS_PER_LONG == 64
+#if __BITS_PER_LONG == 64
 #define __statfs_word long
 #else
 #define __statfs_word __u32
index 88ec80670d5ff1da744a4a5d9174fb8c6f3512da..ec45ccd8708a85f54a903d769b0b5c2fbaf8bc3f 100644 (file)
@@ -554,7 +554,18 @@ extern int __init efi_setup_pcdp_console(char *);
 #define EFI_VARIABLE_NON_VOLATILE       0x0000000000000001
 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
 #define EFI_VARIABLE_RUNTIME_ACCESS     0x0000000000000004
-
+#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x0000000000000008
+#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x0000000000000010
+#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020
+#define EFI_VARIABLE_APPEND_WRITE      0x0000000000000040
+
+#define EFI_VARIABLE_MASK      (EFI_VARIABLE_NON_VOLATILE | \
+                               EFI_VARIABLE_BOOTSERVICE_ACCESS | \
+                               EFI_VARIABLE_RUNTIME_ACCESS | \
+                               EFI_VARIABLE_HARDWARE_ERROR_RECORD | \
+                               EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \
+                               EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
+                               EFI_VARIABLE_APPEND_WRITE)
 /*
  * The type of search to perform when calling boottime->locate_handle
  */
index 05071ee34c3f5332ecf0ca9bc4c6766e01ca1d01..d755b28ba63541cc1f803993573c66aa3870eed5 100644 (file)
@@ -13,4 +13,8 @@ extern int pxa_last_gpio;
 
 extern int pxa_irq_to_gpio(int irq);
 
+struct pxa_gpio_platform_data {
+       int (*gpio_set_wake)(unsigned int gpio, unsigned int on);
+};
+
 #endif /* __GPIO_PXA_H */
index 4b178067f405508e06f3af7adfd09cb3d7a46e7b..56fae865e272f0200894059b9661ebdd23288993 100644 (file)
@@ -26,9 +26,9 @@
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/scatterlist.h>
-#include <linux/spinlock.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/notifier.h>
 
 /* HSI message ttype */
 #define HSI_MSG_READ   0
@@ -121,18 +121,18 @@ static inline int hsi_register_board_info(struct hsi_board_info const *info,
  * @device: Driver model representation of the device
  * @tx_cfg: HSI TX configuration
  * @rx_cfg: HSI RX configuration
- * @hsi_start_rx: Called after incoming wake line goes high
- * @hsi_stop_rx: Called after incoming wake line goes low
+ * @e_handler: Callback for handling port events (RX Wake High/Low)
+ * @pclaimed: Keeps tracks if the clients claimed its associated HSI port
+ * @nb: Notifier block for port events
  */
 struct hsi_client {
        struct device           device;
        struct hsi_config       tx_cfg;
        struct hsi_config       rx_cfg;
-       void                    (*hsi_start_rx)(struct hsi_client *cl);
-       void                    (*hsi_stop_rx)(struct hsi_client *cl);
        /* private: */
+       void                    (*ehandler)(struct hsi_client *, unsigned long);
        unsigned int            pclaimed:1;
-       struct list_head        link;
+       struct notifier_block   nb;
 };
 
 #define to_hsi_client(dev) container_of(dev, struct hsi_client, device)
@@ -147,6 +147,10 @@ static inline void *hsi_client_drvdata(struct hsi_client *cl)
        return dev_get_drvdata(&cl->device);
 }
 
+int hsi_register_port_event(struct hsi_client *cl,
+                       void (*handler)(struct hsi_client *, unsigned long));
+int hsi_unregister_port_event(struct hsi_client *cl);
+
 /**
  * struct hsi_client_driver - Driver associated to an HSI client
  * @driver: Driver model representation of the driver
@@ -214,8 +218,7 @@ void hsi_free_msg(struct hsi_msg *msg);
  * @start_tx: Callback to inform that a client wants to TX data
  * @stop_tx: Callback to inform that a client no longer wishes to TX data
  * @release: Callback to inform that a client no longer uses the port
- * @clients: List of hsi_clients using the port.
- * @clock: Lock to serialize access to the clients list.
+ * @n_head: Notifier chain for signaling port events to the clients.
  */
 struct hsi_port {
        struct device                   device;
@@ -231,14 +234,14 @@ struct hsi_port {
        int                             (*start_tx)(struct hsi_client *cl);
        int                             (*stop_tx)(struct hsi_client *cl);
        int                             (*release)(struct hsi_client *cl);
-       struct list_head                clients;
-       spinlock_t                      clock;
+       /* private */
+       struct atomic_notifier_head     n_head;
 };
 
 #define to_hsi_port(dev) container_of(dev, struct hsi_port, device)
 #define hsi_get_port(cl) to_hsi_port((cl)->device.parent)
 
-void hsi_event(struct hsi_port *port, unsigned int event);
+int hsi_event(struct hsi_port *port, unsigned long event);
 int hsi_claim_port(struct hsi_client *cl, unsigned int share);
 void hsi_release_port(struct hsi_client *cl);
 
@@ -270,13 +273,13 @@ struct hsi_controller {
        struct module           *owner;
        unsigned int            id;
        unsigned int            num_ports;
-       struct hsi_port         *port;
+       struct hsi_port         **port;
 };
 
 #define to_hsi_controller(dev) container_of(dev, struct hsi_controller, device)
 
 struct hsi_controller *hsi_alloc_controller(unsigned int n_ports, gfp_t flags);
-void hsi_free_controller(struct hsi_controller *hsi);
+void hsi_put_controller(struct hsi_controller *hsi);
 int hsi_register_controller(struct hsi_controller *hsi);
 void hsi_unregister_controller(struct hsi_controller *hsi);
 
@@ -294,7 +297,7 @@ static inline void *hsi_controller_drvdata(struct hsi_controller *hsi)
 static inline struct hsi_port *hsi_find_port_num(struct hsi_controller *hsi,
                                                        unsigned int num)
 {
-       return (num < hsi->num_ports) ? &hsi->port[num] : NULL;
+       return (num < hsi->num_ports) ? hsi->port[num] : NULL;
 }
 
 /*
index 7810406f3d8021c0d07049aace417ea82a67f862..b27cfcfd3a59c15319488580a14de42c18174744 100644 (file)
@@ -49,6 +49,12 @@ typedef      void (*irq_preflow_handler_t)(struct irq_data *data);
  * IRQ_TYPE_LEVEL_LOW          - low level triggered
  * IRQ_TYPE_LEVEL_MASK         - Mask to filter out the level bits
  * IRQ_TYPE_SENSE_MASK         - Mask for all the above bits
+ * IRQ_TYPE_DEFAULT            - For use by some PICs to ask irq_set_type
+ *                               to setup the HW to a sane default (used
+ *                                by irqdomain map() callbacks to synchronize
+ *                                the HW state and SW flags for a newly
+ *                                allocated descriptor).
+ *
  * IRQ_TYPE_PROBE              - Special flag for probing in progress
  *
  * Bits which can be modified via irq_set/clear/modify_status_flags()
@@ -77,6 +83,7 @@ enum {
        IRQ_TYPE_LEVEL_LOW      = 0x00000008,
        IRQ_TYPE_LEVEL_MASK     = (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH),
        IRQ_TYPE_SENSE_MASK     = 0x0000000f,
+       IRQ_TYPE_DEFAULT        = IRQ_TYPE_SENSE_MASK,
 
        IRQ_TYPE_PROBE          = 0x00000010,
 
index 42378d637ffbe489c65c0220b8a3a8dc2955f6c9..e926df7b54c963745d043e1041d8876a5a7c65e6 100644 (file)
@@ -996,7 +996,8 @@ extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev,
 extern void ata_sas_port_destroy(struct ata_port *);
 extern struct ata_port *ata_sas_port_alloc(struct ata_host *,
                                           struct ata_port_info *, struct Scsi_Host *);
-extern int ata_sas_async_port_init(struct ata_port *);
+extern void ata_sas_async_probe(struct ata_port *ap);
+extern int ata_sas_sync_probe(struct ata_port *ap);
 extern int ata_sas_port_init(struct ata_port *);
 extern int ata_sas_port_start(struct ata_port *ap);
 extern void ata_sas_port_stop(struct ata_port *ap);
index 0ddd161f3b060c2e2ec0d665c1ddc719213443f7..31d2844e6572be34ed104e1a92fafd48abc0bf76 100644 (file)
@@ -104,9 +104,18 @@ struct bridge_skb_cb {
        } daddr;
 };
 
+static inline void br_drop_fake_rtable(struct sk_buff *skb)
+{
+       struct dst_entry *dst = skb_dst(skb);
+
+       if (dst && (dst->flags & DST_FAKE_RTABLE))
+               skb_dst_drop(skb);
+}
+
 #else
 #define nf_bridge_maybe_copy_header(skb)       (0)
 #define nf_bridge_pad(skb)                     (0)
+#define br_drop_fake_rtable(skb)               do { } while (0)
 #endif /* CONFIG_BRIDGE_NETFILTER */
 
 #endif /* __KERNEL__ */
index bfd0d1bf67072e9a5a6f6c143e80f56fcc6238aa..7ba3551a0414a867cffe38e52cc720004e32592e 100644 (file)
@@ -312,6 +312,11 @@ struct nfs4_layoutreturn {
        int rpc_status;
 };
 
+struct stateowner_id {
+       __u64   create_time;
+       __u32   uniquifier;
+};
+
 /*
  * Arguments to the open call.
  */
@@ -321,7 +326,7 @@ struct nfs_openargs {
        int                     open_flags;
        fmode_t                 fmode;
        __u64                   clientid;
-       __u64                   id;
+       struct stateowner_id    id;
        union {
                struct {
                        struct iattr *  attrs;    /* UNCHECKED, GUARDED */
index 6d626ff0cfd065f8446370902240a865a312ee00..e1ac1ce16fb0b60f07ec961b3ec8f1b7fb0763d0 100644 (file)
@@ -6,6 +6,7 @@
 #define PIPE_BUF_FLAG_LRU      0x01    /* page is on the LRU */
 #define PIPE_BUF_FLAG_ATOMIC   0x02    /* was atomically mapped */
 #define PIPE_BUF_FLAG_GIFT     0x04    /* page is a gift */
+#define PIPE_BUF_FLAG_PACKET   0x08    /* read() as a packet */
 
 /**
  *     struct pipe_buffer - a linux kernel pipe buffer
index c6db9fb33c448f28197ffb6d135689daf58625b6..600060e25ec6cb644fd4141f48e2493490305c8a 100644 (file)
@@ -141,7 +141,7 @@ static inline unsigned __read_seqcount_begin(const seqcount_t *s)
        unsigned ret;
 
 repeat:
-       ret = s->sequence;
+       ret = ACCESS_ONCE(s->sequence);
        if (unlikely(ret & 1)) {
                cpu_relax();
                goto repeat;
@@ -165,6 +165,27 @@ static inline unsigned read_seqcount_begin(const seqcount_t *s)
        return ret;
 }
 
+/**
+ * raw_seqcount_begin - begin a seq-read critical section
+ * @s: pointer to seqcount_t
+ * Returns: count to be passed to read_seqcount_retry
+ *
+ * raw_seqcount_begin opens a read critical section of the given seqcount.
+ * Validity of the critical section is tested by checking read_seqcount_retry
+ * function.
+ *
+ * Unlike read_seqcount_begin(), this function will not wait for the count
+ * to stabilize. If a writer is active when we begin, we will fail the
+ * read_seqcount_retry() instead of stabilizing at the beginning of the
+ * critical section.
+ */
+static inline unsigned raw_seqcount_begin(const seqcount_t *s)
+{
+       unsigned ret = ACCESS_ONCE(s->sequence);
+       smp_rmb();
+       return ret & ~1;
+}
+
 /**
  * __read_seqcount_retry - end a seq-read critical section (without barrier)
  * @s: pointer to seqcount_t
index 70a3f8d49118599510af86a6ef1022a0c064c850..111f26b6e28b992bbebbe645819712bf8c07ab63 100644 (file)
@@ -238,11 +238,12 @@ enum {
 /*
  * The callback notifies userspace to release buffers when skb DMA is done in
  * lower device, the skb last reference should be 0 when calling this.
- * The desc is used to track userspace buffer index.
+ * The ctx field is used to track device context.
+ * The desc field is used to track userspace buffer index.
  */
 struct ubuf_info {
-       void (*callback)(void *);
-       void *arg;
+       void (*callback)(struct ubuf_info *);
+       void *ctx;
        unsigned long desc;
 };
 
@@ -1019,7 +1020,7 @@ static inline void skb_queue_splice(const struct sk_buff_head *list,
 }
 
 /**
- *     skb_queue_splice - join two skb lists and reinitialise the emptied list
+ *     skb_queue_splice_init - join two skb lists and reinitialise the emptied list
  *     @list: the new list to add
  *     @head: the place to add it in the first list
  *
@@ -1050,7 +1051,7 @@ static inline void skb_queue_splice_tail(const struct sk_buff_head *list,
 }
 
 /**
- *     skb_queue_splice_tail - join two skb lists and reinitialise the emptied list
+ *     skb_queue_splice_tail_init - join two skb lists and reinitialise the emptied list
  *     @list: the new list to add
  *     @head: the place to add it in the first list
  *
index 98679b061b6382cbdffd0d979eb5e1e7dea61ea5..fa702aeb5038d40b096e61cc65ba1b8d54d7ef39 100644 (file)
@@ -254,7 +254,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
  *     driver is finished with this message, it must call
  *     spi_finalize_current_message() so the subsystem can issue the next
  *     transfer
- * @prepare_transfer_hardware: there are currently no more messages on the
+ * @unprepare_transfer_hardware: there are currently no more messages on the
  *     queue so the subsystem notifies the driver that it may relax the
  *     hardware by issuing this call
  *
index 5de415707c234f0e54939195062b5dc39f0a1c06..d28cc78a38e442e75e435c0dede140291c57ce2c 100644 (file)
@@ -126,6 +126,8 @@ struct usb_hcd {
        unsigned                wireless:1;     /* Wireless USB HCD */
        unsigned                authorized_default:1;
        unsigned                has_tt:1;       /* Integrated TT in root hub */
+       unsigned                broken_pci_sleep:1;     /* Don't put the
+                       controller in PCI-D3 for system sleep */
 
        unsigned int            irq;            /* irq allocated */
        void __iomem            *regs;          /* device memory/io */
index 03b90cdc1921aa7737427817066b8917edd0a808..06f8e38582512eb7be8713f5579887cdd559a813 100644 (file)
@@ -26,13 +26,14 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
                PGFREE, PGACTIVATE, PGDEACTIVATE,
                PGFAULT, PGMAJFAULT,
                FOR_ALL_ZONES(PGREFILL),
-               FOR_ALL_ZONES(PGSTEAL),
+               FOR_ALL_ZONES(PGSTEAL_KSWAPD),
+               FOR_ALL_ZONES(PGSTEAL_DIRECT),
                FOR_ALL_ZONES(PGSCAN_KSWAPD),
                FOR_ALL_ZONES(PGSCAN_DIRECT),
 #ifdef CONFIG_NUMA
                PGSCAN_ZONE_RECLAIM_FAILED,
 #endif
-               PGINODESTEAL, SLABS_SCANNED, KSWAPD_STEAL, KSWAPD_INODESTEAL,
+               PGINODESTEAL, SLABS_SCANNED, KSWAPD_INODESTEAL,
                KSWAPD_LOW_WMARK_HIT_QUICKLY, KSWAPD_HIGH_WMARK_HIT_QUICKLY,
                KSWAPD_SKIP_CONGESTION_WAIT,
                PAGEOUTRUN, ALLOCSTALL, PGROTATED,
index 6822d2595aff983451b5c01b6286162635f25d9b..db1c5df45224d1635d7de925c51e5cb585e5346a 100644 (file)
@@ -314,6 +314,7 @@ struct hci_conn {
 
        __u8            remote_cap;
        __u8            remote_auth;
+       bool            flush_key;
 
        unsigned int    sent;
 
@@ -980,7 +981,7 @@ int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable);
 int mgmt_connectable(struct hci_dev *hdev, u8 connectable);
 int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status);
 int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
-                     u8 persistent);
+                     bool persistent);
 int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
                          u8 addr_type, u32 flags, u8 *name, u8 name_len,
                          u8 *dev_class);
index 59c5d18cc3857da85690627b085e1065eeeb78ad..bed833d9796aed86bac5ca7d45ad53cde3447e52 100644 (file)
@@ -36,7 +36,11 @@ struct dst_entry {
        struct net_device       *dev;
        struct  dst_ops         *ops;
        unsigned long           _metrics;
-       unsigned long           expires;
+       union {
+               unsigned long           expires;
+               /* point to where the dst_entry copied from */
+               struct dst_entry        *from;
+       };
        struct dst_entry        *path;
        struct neighbour __rcu  *_neighbour;
 #ifdef CONFIG_XFRM
@@ -55,6 +59,7 @@ struct dst_entry {
 #define DST_NOCACHE            0x0010
 #define DST_NOCOUNT            0x0020
 #define DST_NOPEER             0x0040
+#define DST_FAKE_RTABLE                0x0080
 
        short                   error;
        short                   obsolete;
index b26bb810198169c9b0d10462c282d284a6ad1bca..0ae759a6c76ef7f2b58ba28588195223443ca352 100644 (file)
@@ -123,6 +123,54 @@ static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
        return ((struct rt6_info *)dst)->rt6i_idev;
 }
 
+static inline void rt6_clean_expires(struct rt6_info *rt)
+{
+       if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from)
+               dst_release(rt->dst.from);
+
+       rt->rt6i_flags &= ~RTF_EXPIRES;
+       rt->dst.from = NULL;
+}
+
+static inline void rt6_set_expires(struct rt6_info *rt, unsigned long expires)
+{
+       if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from)
+               dst_release(rt->dst.from);
+
+       rt->rt6i_flags |= RTF_EXPIRES;
+       rt->dst.expires = expires;
+}
+
+static inline void rt6_update_expires(struct rt6_info *rt, int timeout)
+{
+       if (!(rt->rt6i_flags & RTF_EXPIRES)) {
+               if (rt->dst.from)
+                       dst_release(rt->dst.from);
+               /* dst_set_expires relies on expires == 0 
+                * if it has not been set previously.
+                */
+               rt->dst.expires = 0;
+       }
+
+       dst_set_expires(&rt->dst, timeout);
+       rt->rt6i_flags |= RTF_EXPIRES;
+}
+
+static inline void rt6_set_from(struct rt6_info *rt, struct rt6_info *from)
+{
+       struct dst_entry *new = (struct dst_entry *) from;
+
+       if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from) {
+               if (new == rt->dst.from)
+                       return;
+               dst_release(rt->dst.from);
+       }
+
+       rt->rt6i_flags &= ~RTF_EXPIRES;
+       rt->dst.from = new;
+       dst_hold(new);
+}
+
 struct fib6_walker_t {
        struct list_head lh;
        struct fib6_node *root, *node;
index 2bdee51ba30d29f1ccd296fdbdcd06a709a5b4c4..72522f0873757ae08507671667cc7bc7cc849110 100644 (file)
@@ -393,7 +393,7 @@ struct ip_vs_protocol {
 
        void (*exit)(struct ip_vs_protocol *pp);
 
-       void (*init_netns)(struct net *net, struct ip_vs_proto_data *pd);
+       int (*init_netns)(struct net *net, struct ip_vs_proto_data *pd);
 
        void (*exit_netns)(struct net *net, struct ip_vs_proto_data *pd);
 
@@ -1203,6 +1203,8 @@ ip_vs_lookup_real_service(struct net *net, int af, __u16 protocol,
 
 extern int ip_vs_use_count_inc(void);
 extern void ip_vs_use_count_dec(void);
+extern int ip_vs_register_nl_ioctl(void);
+extern void ip_vs_unregister_nl_ioctl(void);
 extern int ip_vs_control_init(void);
 extern void ip_vs_control_cleanup(void);
 extern struct ip_vs_dest *
index 77d4c3745cb5be169f87507a34349cd853e8da10..ef46058d35bf0de1fdabf80915594f9d201a0a5c 100644 (file)
@@ -245,7 +245,7 @@ static inline unsigned long red_calc_qavg_from_idle_time(const struct red_parms
         *
         * dummy packets as a burst after idle time, i.e.
         *
-        *      p->qavg *= (1-W)^m
+        *      v->qavg *= (1-W)^m
         *
         * This is an apparently overcomplicated solution (f.e. we have to
         * precompute a table to make this calculation in reasonable time)
@@ -279,7 +279,7 @@ static inline unsigned long red_calc_qavg_no_idle_time(const struct red_parms *p
                                                       unsigned int backlog)
 {
        /*
-        * NOTE: p->qavg is fixed point number with point at Wlog.
+        * NOTE: v->qavg is fixed point number with point at Wlog.
         * The formula below is equvalent to floating point
         * version:
         *
@@ -390,7 +390,7 @@ static inline void red_adaptative_algo(struct red_parms *p, struct red_vars *v)
        if (red_is_idling(v))
                qavg = red_calc_qavg_from_idle_time(p, v);
 
-       /* p->qavg is fixed point number with point at Wlog */
+       /* v->qavg is fixed point number with point at Wlog */
        qavg >>= p->Wlog;
 
        if (qavg > p->target_max && p->max_P <= MAX_P_MAX)
index a6ba1f8871fda3077183717a1e099cd5161b555c..5a0a58ac4126c47517ea5a4da0fdb051cc88daba 100644 (file)
@@ -246,6 +246,7 @@ struct cg_proto;
   *    @sk_user_data: RPC layer private data
   *    @sk_sndmsg_page: cached page for sendmsg
   *    @sk_sndmsg_off: cached offset for sendmsg
+  *    @sk_peek_off: current peek_offset value
   *    @sk_send_head: front of stuff to transmit
   *    @sk_security: used by security modules
   *    @sk_mark: generic packet mark
@@ -1128,9 +1129,9 @@ sk_sockets_allocated_read_positive(struct sock *sk)
        struct proto *prot = sk->sk_prot;
 
        if (mem_cgroup_sockets_enabled && sk->sk_cgrp)
-               return percpu_counter_sum_positive(sk->sk_cgrp->sockets_allocated);
+               return percpu_counter_read_positive(sk->sk_cgrp->sockets_allocated);
 
-       return percpu_counter_sum_positive(prot->sockets_allocated);
+       return percpu_counter_read_positive(prot->sockets_allocated);
 }
 
 static inline int
index 5f5ed1b8b41bb7d28886895e7742cb80e16f6a8b..f4f1c96dca726ff2f00211994dcf7381ef55b5b0 100644 (file)
@@ -217,11 +217,29 @@ struct domain_device {
        struct kref kref;
 };
 
-struct sas_discovery_event {
+struct sas_work {
+       struct list_head drain_node;
        struct work_struct work;
+};
+
+static inline void INIT_SAS_WORK(struct sas_work *sw, void (*fn)(struct work_struct *))
+{
+       INIT_WORK(&sw->work, fn);
+       INIT_LIST_HEAD(&sw->drain_node);
+}
+
+struct sas_discovery_event {
+       struct sas_work work;
        struct asd_sas_port *port;
 };
 
+static inline struct sas_discovery_event *to_sas_discovery_event(struct work_struct *work)
+{
+       struct sas_discovery_event *ev = container_of(work, typeof(*ev), work.work);
+
+       return ev;
+}
+
 struct sas_discovery {
        struct sas_discovery_event disc_work[DISC_NUM_EVENTS];
        unsigned long    pending;
@@ -244,7 +262,7 @@ struct asd_sas_port {
        struct list_head destroy_list;
        enum   sas_linkrate linkrate;
 
-       struct work_struct work;
+       struct sas_work work;
 
 /* public: */
        int id;
@@ -270,10 +288,17 @@ struct asd_sas_port {
 };
 
 struct asd_sas_event {
-       struct work_struct work;
+       struct sas_work work;
        struct asd_sas_phy *phy;
 };
 
+static inline struct asd_sas_event *to_asd_sas_event(struct work_struct *work)
+{
+       struct asd_sas_event *ev = container_of(work, typeof(*ev), work.work);
+
+       return ev;
+}
+
 /* The phy pretty much is controlled by the LLDD.
  * The class only reads those fields.
  */
@@ -333,10 +358,17 @@ struct scsi_core {
 };
 
 struct sas_ha_event {
-       struct work_struct work;
+       struct sas_work work;
        struct sas_ha_struct *ha;
 };
 
+static inline struct sas_ha_event *to_sas_ha_event(struct work_struct *work)
+{
+       struct sas_ha_event *ev = container_of(work, typeof(*ev), work.work);
+
+       return ev;
+}
+
 enum sas_ha_state {
        SAS_HA_REGISTERED,
        SAS_HA_DRAINING,
index cdccd2eb7b6cd759003ecd11903d397a166bc87a..77670e823ed8e7926c617c6a736f6c427f3b437e 100644 (file)
@@ -37,7 +37,7 @@ static inline int dev_is_sata(struct domain_device *dev)
 }
 
 int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy);
-int sas_ata_init_host_and_port(struct domain_device *found_dev);
+int sas_ata_init(struct domain_device *dev);
 void sas_ata_task_abort(struct sas_task *task);
 void sas_ata_strategy_handler(struct Scsi_Host *shost);
 void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q,
@@ -52,7 +52,7 @@ static inline int dev_is_sata(struct domain_device *dev)
 {
        return 0;
 }
-static inline int sas_ata_init_host_and_port(struct domain_device *found_dev)
+static inline int sas_ata_init(struct domain_device *dev)
 {
        return 0;
 }
index 0e93f92a0345a09a2aa84608a3bca34153a2eabb..42b0707c348108b98f6ce05ae1a98ad4f64a0e86 100644 (file)
@@ -472,7 +472,7 @@ void __init change_floppy(char *fmt, ...)
 void __init mount_root(void)
 {
 #ifdef CONFIG_ROOT_NFS
-       if (MAJOR(ROOT_DEV) == UNNAMED_MAJOR) {
+       if (ROOT_DEV == Root_NFS) {
                if (mount_nfs_root())
                        return;
 
index 9d454f09f3b1522c850b99d31f517641e47a8503..44b2433334c749ed92d7e42e5938f840efd843c0 100644 (file)
@@ -225,13 +225,9 @@ static int __init loglevel(char *str)
 
 early_param("loglevel", loglevel);
 
-/*
- * Unknown boot options get handed to init, unless they look like
- * unused parameters (modprobe will find them in /proc/cmdline).
- */
-static int __init unknown_bootoption(char *param, char *val)
+/* Change NUL term back to "=", to make "param" the whole string. */
+static int __init repair_env_string(char *param, char *val)
 {
-       /* Change NUL term back to "=", to make "param" the whole string. */
        if (val) {
                /* param=val or param="val"? */
                if (val == param+strlen(param)+1)
@@ -243,6 +239,16 @@ static int __init unknown_bootoption(char *param, char *val)
                } else
                        BUG();
        }
+       return 0;
+}
+
+/*
+ * Unknown boot options get handed to init, unless they look like
+ * unused parameters (modprobe will find them in /proc/cmdline).
+ */
+static int __init unknown_bootoption(char *param, char *val)
+{
+       repair_env_string(param, val);
 
        /* Handle obsolete-style parameters */
        if (obsolete_checksetup(param))
@@ -732,11 +738,6 @@ static char *initcall_level_names[] __initdata = {
        "late parameters",
 };
 
-static int __init ignore_unknown_bootoption(char *param, char *val)
-{
-       return 0;
-}
-
 static void __init do_initcall_level(int level)
 {
        extern const struct kernel_param __start___param[], __stop___param[];
@@ -747,7 +748,7 @@ static void __init do_initcall_level(int level)
                   static_command_line, __start___param,
                   __stop___param - __start___param,
                   level, level,
-                  ignore_unknown_bootoption);
+                  repair_env_string);
 
        for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
                do_one_initcall(*fn);
index a6a9ec4cd8f583d640ab0da9e4941b19fe8fd990..fd126f82b57cc77db01c5fd42e3e30b230d98a30 100644 (file)
@@ -3183,7 +3183,7 @@ static void perf_event_for_each(struct perf_event *event,
        perf_event_for_each_child(event, func);
        func(event);
        list_for_each_entry(sibling, &event->sibling_list, group_entry)
-               perf_event_for_each_child(event, func);
+               perf_event_for_each_child(sibling, func);
        mutex_unlock(&ctx->mutex);
 }
 
index 97a8bfadc88a0cec4192bd457e18a54aca159cf0..e75e29e4434a9073b0d05f39903df2cf7f4c2d10 100644 (file)
@@ -4,10 +4,10 @@
 
 #include <linux/kallsyms.h>
 
-#define P(f) if (desc->status_use_accessors & f) printk("%14s set\n", #f)
-#define PS(f) if (desc->istate & f) printk("%14s set\n", #f)
+#define ___P(f) if (desc->status_use_accessors & f) printk("%14s set\n", #f)
+#define ___PS(f) if (desc->istate & f) printk("%14s set\n", #f)
 /* FIXME */
-#define PD(f) do { } while (0)
+#define ___PD(f) do { } while (0)
 
 static inline void print_irq_desc(unsigned int irq, struct irq_desc *desc)
 {
@@ -23,23 +23,23 @@ static inline void print_irq_desc(unsigned int irq, struct irq_desc *desc)
                print_symbol("%s\n", (unsigned long)desc->action->handler);
        }
 
-       P(IRQ_LEVEL);
-       P(IRQ_PER_CPU);
-       P(IRQ_NOPROBE);
-       P(IRQ_NOREQUEST);
-       P(IRQ_NOTHREAD);
-       P(IRQ_NOAUTOEN);
+       ___P(IRQ_LEVEL);
+       ___P(IRQ_PER_CPU);
+       ___P(IRQ_NOPROBE);
+       ___P(IRQ_NOREQUEST);
+       ___P(IRQ_NOTHREAD);
+       ___P(IRQ_NOAUTOEN);
 
-       PS(IRQS_AUTODETECT);
-       PS(IRQS_REPLAY);
-       PS(IRQS_WAITING);
-       PS(IRQS_PENDING);
+       ___PS(IRQS_AUTODETECT);
+       ___PS(IRQS_REPLAY);
+       ___PS(IRQS_WAITING);
+       ___PS(IRQS_PENDING);
 
-       PD(IRQS_INPROGRESS);
-       PD(IRQS_DISABLED);
-       PD(IRQS_MASKED);
+       ___PD(IRQS_INPROGRESS);
+       ___PD(IRQS_DISABLED);
+       ___PD(IRQS_MASKED);
 }
 
-#undef P
-#undef PS
-#undef PD
+#undef ___P
+#undef ___PS
+#undef ___PD
index 8742fd013a94e3b56efdbf91cf27c709679615e4..eef311a58a649821f60532602a085f2a79b014bc 100644 (file)
 
 #define MAP_PAGE_ENTRIES       (PAGE_SIZE / sizeof(sector_t) - 1)
 
+/*
+ * Number of free pages that are not high.
+ */
+static inline unsigned long low_free_pages(void)
+{
+       return nr_free_pages() - nr_free_highpages();
+}
+
+/*
+ * Number of pages required to be kept free while writing the image. Always
+ * half of all available low pages before the writing starts.
+ */
+static inline unsigned long reqd_free_pages(void)
+{
+       return low_free_pages() / 2;
+}
+
 struct swap_map_page {
        sector_t entries[MAP_PAGE_ENTRIES];
        sector_t next_swap;
@@ -72,7 +89,7 @@ struct swap_map_handle {
        sector_t cur_swap;
        sector_t first_sector;
        unsigned int k;
-       unsigned long nr_free_pages, written;
+       unsigned long reqd_free_pages;
        u32 crc32;
 };
 
@@ -316,8 +333,7 @@ static int get_swap_writer(struct swap_map_handle *handle)
                goto err_rel;
        }
        handle->k = 0;
-       handle->nr_free_pages = nr_free_pages() >> 1;
-       handle->written = 0;
+       handle->reqd_free_pages = reqd_free_pages();
        handle->first_sector = handle->cur_swap;
        return 0;
 err_rel:
@@ -352,11 +368,11 @@ static int swap_write_page(struct swap_map_handle *handle, void *buf,
                handle->cur_swap = offset;
                handle->k = 0;
        }
-       if (bio_chain && ++handle->written > handle->nr_free_pages) {
+       if (bio_chain && low_free_pages() <= handle->reqd_free_pages) {
                error = hib_wait_on_bio_chain(bio_chain);
                if (error)
                        goto out;
-               handle->written = 0;
+               handle->reqd_free_pages = reqd_free_pages();
        }
  out:
        return error;
@@ -618,7 +634,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
         * Adjust number of free pages after all allocations have been done.
         * We don't want to run out of pages when writing.
         */
-       handle->nr_free_pages = nr_free_pages() >> 1;
+       handle->reqd_free_pages = reqd_free_pages();
 
        /*
         * Start the CRC32 thread.
index 1050d6d3922c182f09bfe602ee07e3a185f4be80..d0c5baf1ab18a254753f2d3c2eb5ba2cf56202b6 100644 (file)
@@ -1820,7 +1820,6 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
         * a quiescent state betweentimes.
         */
        local_irq_save(flags);
-       WARN_ON_ONCE(cpu_is_offline(smp_processor_id()));
        rdp = this_cpu_ptr(rsp->rda);
 
        /* Add the callback to our list. */
index 4603b9d8f30a362d15dc60e4bd0cd659fd7c3f89..0533a688ce22fc378dc66a02e901132049ee8efd 100644 (file)
@@ -6405,16 +6405,26 @@ static void __sdt_free(const struct cpumask *cpu_map)
                struct sd_data *sdd = &tl->data;
 
                for_each_cpu(j, cpu_map) {
-                       struct sched_domain *sd = *per_cpu_ptr(sdd->sd, j);
-                       if (sd && (sd->flags & SD_OVERLAP))
-                               free_sched_groups(sd->groups, 0);
-                       kfree(*per_cpu_ptr(sdd->sd, j));
-                       kfree(*per_cpu_ptr(sdd->sg, j));
-                       kfree(*per_cpu_ptr(sdd->sgp, j));
+                       struct sched_domain *sd;
+
+                       if (sdd->sd) {
+                               sd = *per_cpu_ptr(sdd->sd, j);
+                               if (sd && (sd->flags & SD_OVERLAP))
+                                       free_sched_groups(sd->groups, 0);
+                               kfree(*per_cpu_ptr(sdd->sd, j));
+                       }
+
+                       if (sdd->sg)
+                               kfree(*per_cpu_ptr(sdd->sg, j));
+                       if (sdd->sgp)
+                               kfree(*per_cpu_ptr(sdd->sgp, j));
                }
                free_percpu(sdd->sd);
+               sdd->sd = NULL;
                free_percpu(sdd->sg);
+               sdd->sg = NULL;
                free_percpu(sdd->sgp);
+               sdd->sgp = NULL;
        }
 }
 
index 0d97ebdc58f078f821a59c29965509a5e47f02f5..e9553640c1c3b679b6ae80b6ff4446b05b486c4b 100644 (file)
@@ -784,7 +784,7 @@ account_entity_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se)
                update_load_add(&rq_of(cfs_rq)->load, se->load.weight);
 #ifdef CONFIG_SMP
        if (entity_is_task(se))
-               list_add_tail(&se->group_node, &rq_of(cfs_rq)->cfs_tasks);
+               list_add(&se->group_node, &rq_of(cfs_rq)->cfs_tasks);
 #endif
        cfs_rq->nr_running++;
 }
@@ -3215,6 +3215,8 @@ static int move_one_task(struct lb_env *env)
 
 static unsigned long task_h_load(struct task_struct *p);
 
+static const unsigned int sched_nr_migrate_break = 32;
+
 /*
  * move_tasks tries to move up to load_move weighted load from busiest to
  * this_rq, as part of a balancing operation within domain "sd".
@@ -3242,7 +3244,7 @@ static int move_tasks(struct lb_env *env)
 
                /* take a breather every nr_migrate tasks */
                if (env->loop > env->loop_break) {
-                       env->loop_break += sysctl_sched_nr_migrate;
+                       env->loop_break += sched_nr_migrate_break;
                        env->flags |= LBF_NEED_BREAK;
                        break;
                }
@@ -3252,7 +3254,7 @@ static int move_tasks(struct lb_env *env)
 
                load = task_h_load(p);
 
-               if (load < 16 && !env->sd->nr_balance_failed)
+               if (sched_feat(LB_MIN) && load < 16 && !env->sd->nr_balance_failed)
                        goto next;
 
                if ((load / 2) > env->load_move)
@@ -4407,7 +4409,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
                .dst_cpu        = this_cpu,
                .dst_rq         = this_rq,
                .idle           = idle,
-               .loop_break     = sysctl_sched_nr_migrate,
+               .loop_break     = sched_nr_migrate_break,
        };
 
        cpumask_copy(cpus, cpu_active_mask);
@@ -4445,10 +4447,10 @@ redo:
                 * correctly treated as an imbalance.
                 */
                env.flags |= LBF_ALL_PINNED;
-               env.load_move = imbalance;
-               env.src_cpu = busiest->cpu;
-               env.src_rq = busiest;
-               env.loop_max = busiest->nr_running;
+               env.load_move   = imbalance;
+               env.src_cpu     = busiest->cpu;
+               env.src_rq      = busiest;
+               env.loop_max    = min_t(unsigned long, sysctl_sched_nr_migrate, busiest->nr_running);
 
 more_balance:
                local_irq_save(flags);
index e61fd73913d0613d7fc66a3f8e7dec5c6a55b58b..de00a486c5c693ac7038fa3c5dd139e642a1c307 100644 (file)
@@ -68,3 +68,4 @@ SCHED_FEAT(TTWU_QUEUE, true)
 
 SCHED_FEAT(FORCE_SD_OVERLAP, false)
 SCHED_FEAT(RT_RUNTIME_SHARE, true)
+SCHED_FEAT(LB_MIN, false)
index bf57abdc7bd04dbf2c8f16d5dbd3ee07e688383d..f113755695e2351ad9f32b7e38a808e98c0ad5f4 100644 (file)
@@ -346,7 +346,8 @@ int tick_resume_broadcast(void)
                                                     tick_get_broadcast_mask());
                        break;
                case TICKDEV_MODE_ONESHOT:
-                       broadcast = tick_resume_broadcast_oneshot(bc);
+                       if (!cpumask_empty(tick_get_broadcast_mask()))
+                               broadcast = tick_resume_broadcast_oneshot(bc);
                        break;
                }
        }
@@ -373,6 +374,9 @@ static int tick_broadcast_set_event(ktime_t expires, int force)
 {
        struct clock_event_device *bc = tick_broadcast_device.evtdev;
 
+       if (bc->mode != CLOCK_EVT_MODE_ONESHOT)
+               clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
+
        return clockevents_program_event(bc, expires, force);
 }
 
@@ -531,7 +535,6 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
                int was_periodic = bc->mode == CLOCK_EVT_MODE_PERIODIC;
 
                bc->event_handler = tick_handle_oneshot_broadcast;
-               clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
 
                /* Take the do_timer update */
                tick_do_timer_cpu = cpu;
@@ -549,6 +552,7 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
                           to_cpumask(tmpmask));
 
                if (was_periodic && !cpumask_empty(to_cpumask(tmpmask))) {
+                       clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
                        tick_broadcast_init_next_event(to_cpumask(tmpmask),
                                                       tick_next_period);
                        tick_broadcast_set_event(tick_next_period, 1);
@@ -577,15 +581,10 @@ void tick_broadcast_switch_to_oneshot(void)
        raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
 
        tick_broadcast_device.mode = TICKDEV_MODE_ONESHOT;
-
-       if (cpumask_empty(tick_get_broadcast_mask()))
-               goto end;
-
        bc = tick_broadcast_device.evtdev;
        if (bc)
                tick_broadcast_setup_oneshot(bc);
 
-end:
        raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
 }
 
index ed7b5d1e12f468168178b1a3c144d9736e0b4614..2a22255c10101c7a55939955a04a9834bbbb940a 100644 (file)
@@ -4629,7 +4629,8 @@ static ssize_t
 rb_simple_read(struct file *filp, char __user *ubuf,
               size_t cnt, loff_t *ppos)
 {
-       struct ring_buffer *buffer = filp->private_data;
+       struct trace_array *tr = filp->private_data;
+       struct ring_buffer *buffer = tr->buffer;
        char buf[64];
        int r;
 
@@ -4647,7 +4648,8 @@ static ssize_t
 rb_simple_write(struct file *filp, const char __user *ubuf,
                size_t cnt, loff_t *ppos)
 {
-       struct ring_buffer *buffer = filp->private_data;
+       struct trace_array *tr = filp->private_data;
+       struct ring_buffer *buffer = tr->buffer;
        unsigned long val;
        int ret;
 
@@ -4734,7 +4736,7 @@ static __init int tracer_init_debugfs(void)
                          &trace_clock_fops);
 
        trace_create_file("tracing_on", 0644, d_tracer,
-                           global_trace.buffer, &rb_simple_fops);
+                           &global_trace, &rb_simple_fops);
 
 #ifdef CONFIG_DYNAMIC_FTRACE
        trace_create_file("dyn_ftrace_total_info", 0444, d_tracer,
index 95059f091a242abcfd60bbe9169131e7870e4a2c..f95d65da6db8acaba3498616bbac09643d48ed47 100644 (file)
@@ -836,11 +836,11 @@ extern const char *__stop___trace_bprintk_fmt[];
                     filter)
 #include "trace_entries.h"
 
-#ifdef CONFIG_FUNCTION_TRACER
+#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_FUNCTION_TRACER)
 int perf_ftrace_event_register(struct ftrace_event_call *call,
                               enum trace_reg type, void *data);
 #else
 #define perf_ftrace_event_register NULL
-#endif /* CONFIG_FUNCTION_TRACER */
+#endif
 
 #endif /* _LINUX_KERNEL_TRACE_H */
index 859fae6b18253e9d31331222c138e318397ab0d1..df611a0e76c55b0d47febf4312874e839114bb13 100644 (file)
@@ -652,6 +652,8 @@ int trace_print_lat_context(struct trace_iterator *iter)
 {
        u64 next_ts;
        int ret;
+       /* trace_find_next_entry will reset ent_size */
+       int ent_size = iter->ent_size;
        struct trace_seq *s = &iter->seq;
        struct trace_entry *entry = iter->ent,
                           *next_entry = trace_find_next_entry(iter, NULL,
@@ -660,6 +662,9 @@ int trace_print_lat_context(struct trace_iterator *iter)
        unsigned long abs_usecs = ns2usecs(iter->ts - iter->tr->time_start);
        unsigned long rel_usecs;
 
+       /* Restore the original ent_size */
+       iter->ent_size = ent_size;
+
        if (!next_entry)
                next_ts = iter->ts;
        rel_usecs = ns2usecs(next_ts - iter->ts);
index cd65cb19c941b2bf04cb86777cb8312ecad6c0ae..5a16423a512c4a7f0192d0f10af806473c25b0b9 100644 (file)
@@ -532,7 +532,7 @@ static struct page *dequeue_huge_page_vma(struct hstate *h,
                                struct vm_area_struct *vma,
                                unsigned long address, int avoid_reserve)
 {
-       struct page *page;
+       struct page *page = NULL;
        struct mempolicy *mpol;
        nodemask_t *nodemask;
        struct zonelist *zonelist;
index b868def9bcc1e1f20c05406b1e9b90e0eae5d182..31ab9c3f0178d3f7193d5e2b6e6935926cf1d48d 100644 (file)
@@ -2476,10 +2476,10 @@ struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page)
 static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg,
                                       struct page *page,
                                       unsigned int nr_pages,
-                                      struct page_cgroup *pc,
                                       enum charge_type ctype,
                                       bool lrucare)
 {
+       struct page_cgroup *pc = lookup_page_cgroup(page);
        struct zone *uninitialized_var(zone);
        bool was_on_lru = false;
        bool anon;
@@ -2716,7 +2716,6 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
 {
        struct mem_cgroup *memcg = NULL;
        unsigned int nr_pages = 1;
-       struct page_cgroup *pc;
        bool oom = true;
        int ret;
 
@@ -2730,11 +2729,10 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm,
                oom = false;
        }
 
-       pc = lookup_page_cgroup(page);
        ret = __mem_cgroup_try_charge(mm, gfp_mask, nr_pages, &memcg, oom);
        if (ret == -ENOMEM)
                return ret;
-       __mem_cgroup_commit_charge(memcg, page, nr_pages, pc, ctype, false);
+       __mem_cgroup_commit_charge(memcg, page, nr_pages, ctype, false);
        return 0;
 }
 
@@ -2831,16 +2829,13 @@ static void
 __mem_cgroup_commit_charge_swapin(struct page *page, struct mem_cgroup *memcg,
                                        enum charge_type ctype)
 {
-       struct page_cgroup *pc;
-
        if (mem_cgroup_disabled())
                return;
        if (!memcg)
                return;
        cgroup_exclude_rmdir(&memcg->css);
 
-       pc = lookup_page_cgroup(page);
-       __mem_cgroup_commit_charge(memcg, page, 1, pc, ctype, true);
+       __mem_cgroup_commit_charge(memcg, page, 1, ctype, true);
        /*
         * Now swap is on-memory. This means this page may be
         * counted both as mem and swap....double count.
@@ -3298,14 +3293,13 @@ int mem_cgroup_prepare_migration(struct page *page,
         * page. In the case new page is migrated but not remapped, new page's
         * mapcount will be finally 0 and we call uncharge in end_migration().
         */
-       pc = lookup_page_cgroup(newpage);
        if (PageAnon(page))
                ctype = MEM_CGROUP_CHARGE_TYPE_MAPPED;
        else if (page_is_file_cache(page))
                ctype = MEM_CGROUP_CHARGE_TYPE_CACHE;
        else
                ctype = MEM_CGROUP_CHARGE_TYPE_SHMEM;
-       __mem_cgroup_commit_charge(memcg, newpage, 1, pc, ctype, false);
+       __mem_cgroup_commit_charge(memcg, newpage, 1, ctype, false);
        return ret;
 }
 
@@ -3392,8 +3386,7 @@ void mem_cgroup_replace_page_cache(struct page *oldpage,
         * the newpage may be on LRU(or pagevec for LRU) already. We lock
         * LRU while we overwrite pc->mem_cgroup.
         */
-       pc = lookup_page_cgroup(newpage);
-       __mem_cgroup_commit_charge(memcg, newpage, 1, pc, type, true);
+       __mem_cgroup_commit_charge(memcg, newpage, 1, type, true);
 }
 
 #ifdef CONFIG_DEBUG_VM
index cfb6c8678754fdb3baf411e2331e87ea64766fb2..b19569137529221163e6b51bd96e3a161805a97f 100644 (file)
@@ -1361,11 +1361,14 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
 
        mm = get_task_mm(task);
        put_task_struct(task);
-       if (mm)
-               err = do_migrate_pages(mm, old, new,
-                       capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
-       else
+
+       if (!mm) {
                err = -EINVAL;
+               goto out;
+       }
+
+       err = do_migrate_pages(mm, old, new,
+               capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
 
        mmput(mm);
 out:
index 51c08a0c6f68ac6e78d09568bd270ad95aac7622..11072383ae12e5698498be5b3da5b8d991192535 100644 (file)
@@ -1388,14 +1388,14 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
        mm = get_task_mm(task);
        put_task_struct(task);
 
-       if (mm) {
-               if (nodes)
-                       err = do_pages_move(mm, task_nodes, nr_pages, pages,
-                                           nodes, status, flags);
-               else
-                       err = do_pages_stat(mm, nr_pages, pages, status);
-       else
-               err = -EINVAL;
+       if (!mm)
+               return -EINVAL;
+
+       if (nodes)
+               err = do_pages_move(mm, task_nodes, nr_pages, pages,
+                                   nodes, status, flags);
+       else
+               err = do_pages_stat(mm, nr_pages, pages, status);
 
        mmput(mm);
        return err;
index 24f0fc1a56d60ebbbacf1950ac0ebec7067dbf41..e53bb8a256b196018c26899427897a0f471d8193 100644 (file)
@@ -298,13 +298,19 @@ void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
        if (WARN_ON_ONCE(slab_is_available()))
                return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
 
+again:
        ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
                                         goal, -1ULL);
        if (ptr)
                return ptr;
 
-       return __alloc_memory_core_early(MAX_NUMNODES, size, align,
-                                        goal, -1ULL);
+       ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
+                                       goal, -1ULL);
+       if (!ptr && goal) {
+               goal = 0;
+               goto again;
+       }
+       return ptr;
 }
 
 void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
index 9d3dd3763cf763460b0f4f17b7ff630e5c8115c0..4c5ff7f284d9b299d7ea9cf3b7bfe374550ce5ca 100644 (file)
@@ -26,7 +26,7 @@
  */
 static const struct address_space_operations swap_aops = {
        .writepage      = swap_writepage,
-       .set_page_dirty = __set_page_dirty_nobuffers,
+       .set_page_dirty = __set_page_dirty_no_writeback,
        .migratepage    = migrate_page,
 };
 
index 1a518684a32f0a55e516dc642c7284ee44ae803f..33dc256033b5020c3679a4578af854c640fc826a 100644 (file)
@@ -1568,9 +1568,14 @@ shrink_inactive_list(unsigned long nr_to_scan, struct mem_cgroup_zone *mz,
        reclaim_stat->recent_scanned[0] += nr_anon;
        reclaim_stat->recent_scanned[1] += nr_file;
 
-       if (current_is_kswapd())
-               __count_vm_events(KSWAPD_STEAL, nr_reclaimed);
-       __count_zone_vm_events(PGSTEAL, zone, nr_reclaimed);
+       if (global_reclaim(sc)) {
+               if (current_is_kswapd())
+                       __count_zone_vm_events(PGSTEAL_KSWAPD, zone,
+                                              nr_reclaimed);
+               else
+                       __count_zone_vm_events(PGSTEAL_DIRECT, zone,
+                                              nr_reclaimed);
+       }
 
        putback_inactive_pages(mz, &page_list);
 
index f600557a76596231ef659fdff0c9f2ea8aed71ae..7db1b9bab4929d13b3b23dbe7b08c2c782e66ab1 100644 (file)
@@ -738,7 +738,8 @@ const char * const vmstat_text[] = {
        "pgmajfault",
 
        TEXTS_FOR_ZONES("pgrefill")
-       TEXTS_FOR_ZONES("pgsteal")
+       TEXTS_FOR_ZONES("pgsteal_kswapd")
+       TEXTS_FOR_ZONES("pgsteal_direct")
        TEXTS_FOR_ZONES("pgscan_kswapd")
        TEXTS_FOR_ZONES("pgscan_direct")
 
@@ -747,7 +748,6 @@ const char * const vmstat_text[] = {
 #endif
        "pginodesteal",
        "slabs_scanned",
-       "kswapd_steal",
        "kswapd_inodesteal",
        "kswapd_low_wmark_hit_quickly",
        "kswapd_high_wmark_hit_quickly",
index 0906c194a4139b1cf56e368876c7ba463e911c5b..9d9a6a3edbd58584fdceffdf680de6e28dc72c90 100644 (file)
@@ -2011,16 +2011,17 @@ static void __exit ax25_exit(void)
        proc_net_remove(&init_net, "ax25_route");
        proc_net_remove(&init_net, "ax25");
        proc_net_remove(&init_net, "ax25_calls");
-       ax25_rt_free();
-       ax25_uid_free();
-       ax25_dev_free();
 
-       ax25_unregister_sysctl();
        unregister_netdevice_notifier(&ax25_dev_notifier);
+       ax25_unregister_sysctl();
 
        dev_remove_pack(&ax25_packet_type);
 
        sock_unregister(PF_AX25);
        proto_unregister(&ax25_proto);
+
+       ax25_rt_free();
+       ax25_uid_free();
+       ax25_dev_free();
 }
 module_exit(ax25_exit);
index 92a857e3786d173273986ba179f7e9bac1856af7..edfd61addceca4b269891734646fedbe6fbe8606 100644 (file)
@@ -1215,40 +1215,40 @@ struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
        return NULL;
 }
 
-static int hci_persistent_key(struct hci_dev *hdev, struct hci_conn *conn,
+static bool hci_persistent_key(struct hci_dev *hdev, struct hci_conn *conn,
                                                u8 key_type, u8 old_key_type)
 {
        /* Legacy key */
        if (key_type < 0x03)
-               return 1;
+               return true;
 
        /* Debug keys are insecure so don't store them persistently */
        if (key_type == HCI_LK_DEBUG_COMBINATION)
-               return 0;
+               return false;
 
        /* Changed combination key and there's no previous one */
        if (key_type == HCI_LK_CHANGED_COMBINATION && old_key_type == 0xff)
-               return 0;
+               return false;
 
        /* Security mode 3 case */
        if (!conn)
-               return 1;
+               return true;
 
        /* Neither local nor remote side had no-bonding as requirement */
        if (conn->auth_type > 0x01 && conn->remote_auth > 0x01)
-               return 1;
+               return true;
 
        /* Local side had dedicated bonding as requirement */
        if (conn->auth_type == 0x02 || conn->auth_type == 0x03)
-               return 1;
+               return true;
 
        /* Remote side had dedicated bonding as requirement */
        if (conn->remote_auth == 0x02 || conn->remote_auth == 0x03)
-               return 1;
+               return true;
 
        /* If none of the above criteria match, then don't store the key
         * persistently */
-       return 0;
+       return false;
 }
 
 struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8])
@@ -1285,7 +1285,8 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
                     bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len)
 {
        struct link_key *key, *old_key;
-       u8 old_key_type, persistent;
+       u8 old_key_type;
+       bool persistent;
 
        old_key = hci_find_link_key(hdev, bdaddr);
        if (old_key) {
@@ -1328,10 +1329,8 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
 
        mgmt_new_link_key(hdev, key, persistent);
 
-       if (!persistent) {
-               list_del(&key->list);
-               kfree(key);
-       }
+       if (conn)
+               conn->flush_key = !persistent;
 
        return 0;
 }
index b37531094c4999a6b9224056e4d5f283a9bdcece..6c065254afc03dcfbd11bad037791561b7f99f45 100644 (file)
@@ -1901,6 +1901,8 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
        }
 
        if (ev->status == 0) {
+               if (conn->type == ACL_LINK && conn->flush_key)
+                       hci_remove_link_key(hdev, &conn->dst);
                hci_proto_disconn_cfm(conn, ev->reason);
                hci_conn_del(conn);
        }
@@ -2311,6 +2313,7 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
 
        case HCI_OP_USER_PASSKEY_NEG_REPLY:
                hci_cc_user_passkey_neg_reply(hdev, skb);
+               break;
 
        case HCI_OP_LE_SET_SCAN_PARAM:
                hci_cc_le_set_scan_param(hdev, skb);
index 4ef275c69675ab116897da18663626a53ab6c6fe..4bb03b111122ca6c911ee1c7e74fbd8c03f22d30 100644 (file)
@@ -2884,7 +2884,7 @@ int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status)
        return 0;
 }
 
-int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, u8 persistent)
+int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, bool persistent)
 {
        struct mgmt_ev_new_link_key ev;
 
index 61f65344e711fc4b87856889c8d83e89d0d911d6..a2098e3de500d4ab34c3d3b14435eddb5089b354 100644 (file)
@@ -47,6 +47,7 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
                kfree_skb(skb);
        } else {
                skb_push(skb, ETH_HLEN);
+               br_drop_fake_rtable(skb);
                dev_queue_xmit(skb);
        }
 
index dec4f3817133c879b524a65f0919b5dabcff46ea..d7f49b63ab0fd17b82828f60278b5f8a99664a1d 100644 (file)
@@ -156,7 +156,7 @@ void br_netfilter_rtable_init(struct net_bridge *br)
        rt->dst.dev = br->dev;
        rt->dst.path = &rt->dst;
        dst_init_metrics(&rt->dst, br_dst_default_metrics, true);
-       rt->dst.flags   = DST_NOXFRM | DST_NOPEER;
+       rt->dst.flags   = DST_NOXFRM | DST_NOPEER | DST_FAKE_RTABLE;
        rt->dst.ops = &fake_dst_ops;
 }
 
@@ -694,11 +694,7 @@ static unsigned int br_nf_local_in(unsigned int hook, struct sk_buff *skb,
                                   const struct net_device *out,
                                   int (*okfn)(struct sk_buff *))
 {
-       struct rtable *rt = skb_rtable(skb);
-
-       if (rt && rt == bridge_parent_rtable(in))
-               skb_dst_drop(skb);
-
+       br_drop_fake_rtable(skb);
        return NF_ACCEPT;
 }
 
index 20618dd3088b79e0f1528436c7b1c9359f9c9cd6..d09340e1523f64d0aa1f7ba71cf0d0626c22036a 100644 (file)
@@ -103,6 +103,7 @@ static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt)
                skb->protocol = htons(ETH_P_IPV6);
                break;
        default:
+               kfree_skb(skb);
                priv->netdev->stats.rx_errors++;
                return -EINVAL;
        }
@@ -220,14 +221,16 @@ static int chnl_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        if (skb->len > priv->netdev->mtu) {
                pr_warn("Size of skb exceeded MTU\n");
+               kfree_skb(skb);
                dev->stats.tx_errors++;
-               return -ENOSPC;
+               return NETDEV_TX_OK;
        }
 
        if (!priv->flowenabled) {
                pr_debug("dropping packets flow off\n");
+               kfree_skb(skb);
                dev->stats.tx_dropped++;
-               return NETDEV_TX_BUSY;
+               return NETDEV_TX_OK;
        }
 
        if (priv->conn_req.protocol == CAIFPROTO_DATAGRAM_LOOP)
@@ -242,7 +245,7 @@ static int chnl_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
        result = priv->chnl.dn->transmit(priv->chnl.dn, pkt);
        if (result) {
                dev->stats.tx_dropped++;
-               return result;
+               return NETDEV_TX_OK;
        }
 
        /* Update statistics. */
index c25d453b2803be9a5ad1261fee7cd7120aa60fd5..9bb8f87c4cdad35481e6fc2389090d32a6d5b917 100644 (file)
@@ -1409,14 +1409,34 @@ EXPORT_SYMBOL(register_netdevice_notifier);
  *     register_netdevice_notifier(). The notifier is unlinked into the
  *     kernel structures and may then be reused. A negative errno code
  *     is returned on a failure.
+ *
+ *     After unregistering unregister and down device events are synthesized
+ *     for all devices on the device list to the removed notifier to remove
+ *     the need for special case cleanup code.
  */
 
 int unregister_netdevice_notifier(struct notifier_block *nb)
 {
+       struct net_device *dev;
+       struct net *net;
        int err;
 
        rtnl_lock();
        err = raw_notifier_chain_unregister(&netdev_chain, nb);
+       if (err)
+               goto unlock;
+
+       for_each_net(net) {
+               for_each_netdev(net, dev) {
+                       if (dev->flags & IFF_UP) {
+                               nb->notifier_call(nb, NETDEV_GOING_DOWN, dev);
+                               nb->notifier_call(nb, NETDEV_DOWN, dev);
+                       }
+                       nb->notifier_call(nb, NETDEV_UNREGISTER, dev);
+                       nb->notifier_call(nb, NETDEV_UNREGISTER_BATCH, dev);
+               }
+       }
+unlock:
        rtnl_unlock();
        return err;
 }
index 7f36b38e060fcfbf98ed35cd1dff84067f75d11c..a7cad741df012a2b7790246d6c2d569bac38bda4 100644 (file)
@@ -42,13 +42,14 @@ static void send_dm_alert(struct work_struct *unused);
  * netlink alerts
  */
 static int trace_state = TRACE_OFF;
-static DEFINE_SPINLOCK(trace_state_lock);
+static DEFINE_MUTEX(trace_state_mutex);
 
 struct per_cpu_dm_data {
        struct work_struct dm_alert_work;
-       struct sk_buff *skb;
+       struct sk_buff __rcu *skb;
        atomic_t dm_hit_count;
        struct timer_list send_timer;
+       int cpu;
 };
 
 struct dm_hw_stat_delta {
@@ -79,29 +80,53 @@ static void reset_per_cpu_data(struct per_cpu_dm_data *data)
        size_t al;
        struct net_dm_alert_msg *msg;
        struct nlattr *nla;
+       struct sk_buff *skb;
+       struct sk_buff *oskb = rcu_dereference_protected(data->skb, 1);
 
        al = sizeof(struct net_dm_alert_msg);
        al += dm_hit_limit * sizeof(struct net_dm_drop_point);
        al += sizeof(struct nlattr);
 
-       data->skb = genlmsg_new(al, GFP_KERNEL);
-       genlmsg_put(data->skb, 0, 0, &net_drop_monitor_family,
-                       0, NET_DM_CMD_ALERT);
-       nla = nla_reserve(data->skb, NLA_UNSPEC, sizeof(struct net_dm_alert_msg));
-       msg = nla_data(nla);
-       memset(msg, 0, al);
-       atomic_set(&data->dm_hit_count, dm_hit_limit);
+       skb = genlmsg_new(al, GFP_KERNEL);
+
+       if (skb) {
+               genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
+                               0, NET_DM_CMD_ALERT);
+               nla = nla_reserve(skb, NLA_UNSPEC,
+                                 sizeof(struct net_dm_alert_msg));
+               msg = nla_data(nla);
+               memset(msg, 0, al);
+       } else
+               schedule_work_on(data->cpu, &data->dm_alert_work);
+
+       /*
+        * Don't need to lock this, since we are guaranteed to only
+        * run this on a single cpu at a time.
+        * Note also that we only update data->skb if the old and new skb
+        * pointers don't match.  This ensures that we don't continually call
+        * synchornize_rcu if we repeatedly fail to alloc a new netlink message.
+        */
+       if (skb != oskb) {
+               rcu_assign_pointer(data->skb, skb);
+
+               synchronize_rcu();
+
+               atomic_set(&data->dm_hit_count, dm_hit_limit);
+       }
+
 }
 
 static void send_dm_alert(struct work_struct *unused)
 {
        struct sk_buff *skb;
-       struct per_cpu_dm_data *data = &__get_cpu_var(dm_cpu_data);
+       struct per_cpu_dm_data *data = &get_cpu_var(dm_cpu_data);
+
+       WARN_ON_ONCE(data->cpu != smp_processor_id());
 
        /*
         * Grab the skb we're about to send
         */
-       skb = data->skb;
+       skb = rcu_dereference_protected(data->skb, 1);
 
        /*
         * Replace it with a new one
@@ -111,8 +136,10 @@ static void send_dm_alert(struct work_struct *unused)
        /*
         * Ship it!
         */
-       genlmsg_multicast(skb, 0, NET_DM_GRP_ALERT, GFP_KERNEL);
+       if (skb)
+               genlmsg_multicast(skb, 0, NET_DM_GRP_ALERT, GFP_KERNEL);
 
+       put_cpu_var(dm_cpu_data);
 }
 
 /*
@@ -123,9 +150,11 @@ static void send_dm_alert(struct work_struct *unused)
  */
 static void sched_send_work(unsigned long unused)
 {
-       struct per_cpu_dm_data *data =  &__get_cpu_var(dm_cpu_data);
+       struct per_cpu_dm_data *data =  &get_cpu_var(dm_cpu_data);
+
+       schedule_work_on(smp_processor_id(), &data->dm_alert_work);
 
-       schedule_work(&data->dm_alert_work);
+       put_cpu_var(dm_cpu_data);
 }
 
 static void trace_drop_common(struct sk_buff *skb, void *location)
@@ -134,8 +163,15 @@ static void trace_drop_common(struct sk_buff *skb, void *location)
        struct nlmsghdr *nlh;
        struct nlattr *nla;
        int i;
-       struct per_cpu_dm_data *data = &__get_cpu_var(dm_cpu_data);
+       struct sk_buff *dskb;
+       struct per_cpu_dm_data *data = &get_cpu_var(dm_cpu_data);
+
+
+       rcu_read_lock();
+       dskb = rcu_dereference(data->skb);
 
+       if (!dskb)
+               goto out;
 
        if (!atomic_add_unless(&data->dm_hit_count, -1, 0)) {
                /*
@@ -144,12 +180,13 @@ static void trace_drop_common(struct sk_buff *skb, void *location)
                goto out;
        }
 
-       nlh = (struct nlmsghdr *)data->skb->data;
+       nlh = (struct nlmsghdr *)dskb->data;
        nla = genlmsg_data(nlmsg_data(nlh));
        msg = nla_data(nla);
        for (i = 0; i < msg->entries; i++) {
                if (!memcmp(&location, msg->points[i].pc, sizeof(void *))) {
                        msg->points[i].count++;
+                       atomic_inc(&data->dm_hit_count);
                        goto out;
                }
        }
@@ -157,7 +194,7 @@ static void trace_drop_common(struct sk_buff *skb, void *location)
        /*
         * We need to create a new entry
         */
-       __nla_reserve_nohdr(data->skb, sizeof(struct net_dm_drop_point));
+       __nla_reserve_nohdr(dskb, sizeof(struct net_dm_drop_point));
        nla->nla_len += NLA_ALIGN(sizeof(struct net_dm_drop_point));
        memcpy(msg->points[msg->entries].pc, &location, sizeof(void *));
        msg->points[msg->entries].count = 1;
@@ -169,6 +206,8 @@ static void trace_drop_common(struct sk_buff *skb, void *location)
        }
 
 out:
+       rcu_read_unlock();
+       put_cpu_var(dm_cpu_data);
        return;
 }
 
@@ -213,7 +252,7 @@ static int set_all_monitor_traces(int state)
        struct dm_hw_stat_delta *new_stat = NULL;
        struct dm_hw_stat_delta *temp;
 
-       spin_lock(&trace_state_lock);
+       mutex_lock(&trace_state_mutex);
 
        if (state == trace_state) {
                rc = -EAGAIN;
@@ -252,7 +291,7 @@ static int set_all_monitor_traces(int state)
                rc = -EINPROGRESS;
 
 out_unlock:
-       spin_unlock(&trace_state_lock);
+       mutex_unlock(&trace_state_mutex);
 
        return rc;
 }
@@ -295,12 +334,12 @@ static int dropmon_net_event(struct notifier_block *ev_block,
 
                new_stat->dev = dev;
                new_stat->last_rx = jiffies;
-               spin_lock(&trace_state_lock);
+               mutex_lock(&trace_state_mutex);
                list_add_rcu(&new_stat->list, &hw_stats_list);
-               spin_unlock(&trace_state_lock);
+               mutex_unlock(&trace_state_mutex);
                break;
        case NETDEV_UNREGISTER:
-               spin_lock(&trace_state_lock);
+               mutex_lock(&trace_state_mutex);
                list_for_each_entry_safe(new_stat, tmp, &hw_stats_list, list) {
                        if (new_stat->dev == dev) {
                                new_stat->dev = NULL;
@@ -311,7 +350,7 @@ static int dropmon_net_event(struct notifier_block *ev_block,
                                }
                        }
                }
-               spin_unlock(&trace_state_lock);
+               mutex_unlock(&trace_state_mutex);
                break;
        }
 out:
@@ -367,13 +406,15 @@ static int __init init_net_drop_monitor(void)
 
        for_each_present_cpu(cpu) {
                data = &per_cpu(dm_cpu_data, cpu);
-               reset_per_cpu_data(data);
+               data->cpu = cpu;
                INIT_WORK(&data->dm_alert_work, send_dm_alert);
                init_timer(&data->send_timer);
                data->send_timer.data = cpu;
                data->send_timer.function = sched_send_work;
+               reset_per_cpu_data(data);
        }
 
+
        goto out;
 
 out_unreg:
index 0e950fda9a0abc88ffaa9e3e62b2a11c023a7b8b..31a5ae51a45c8770136ac1b60b76da842d9803df 100644 (file)
@@ -83,21 +83,29 @@ assign:
 
 static int ops_init(const struct pernet_operations *ops, struct net *net)
 {
-       int err;
+       int err = -ENOMEM;
+       void *data = NULL;
+
        if (ops->id && ops->size) {
-               void *data = kzalloc(ops->size, GFP_KERNEL);
+               data = kzalloc(ops->size, GFP_KERNEL);
                if (!data)
-                       return -ENOMEM;
+                       goto out;
 
                err = net_assign_generic(net, *ops->id, data);
-               if (err) {
-                       kfree(data);
-                       return err;
-               }
+               if (err)
+                       goto cleanup;
        }
+       err = 0;
        if (ops->init)
-               return ops->init(net);
-       return 0;
+               err = ops->init(net);
+       if (!err)
+               return 0;
+
+cleanup:
+       kfree(data);
+
+out:
+       return err;
 }
 
 static void ops_free(const struct pernet_operations *ops, struct net *net)
@@ -448,12 +456,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
 static int __register_pernet_operations(struct list_head *list,
                                        struct pernet_operations *ops)
 {
-       int err = 0;
-       err = ops_init(ops, &init_net);
-       if (err)
-               ops_free(ops, &init_net);
-       return err;
-       
+       return ops_init(ops, &init_net);
 }
 
 static void __unregister_pernet_operations(struct pernet_operations *ops)
index 36851588536861bb5fe67f61c69829807e599fb4..840821b90bcd7e11c79c14dd44bcc02aedcedf23 100644 (file)
@@ -1044,6 +1044,24 @@ static void lowpan_dev_free(struct net_device *dev)
        free_netdev(dev);
 }
 
+static struct wpan_phy *lowpan_get_phy(const struct net_device *dev)
+{
+       struct net_device *real_dev = lowpan_dev_info(dev)->real_dev;
+       return ieee802154_mlme_ops(real_dev)->get_phy(real_dev);
+}
+
+static u16 lowpan_get_pan_id(const struct net_device *dev)
+{
+       struct net_device *real_dev = lowpan_dev_info(dev)->real_dev;
+       return ieee802154_mlme_ops(real_dev)->get_pan_id(real_dev);
+}
+
+static u16 lowpan_get_short_addr(const struct net_device *dev)
+{
+       struct net_device *real_dev = lowpan_dev_info(dev)->real_dev;
+       return ieee802154_mlme_ops(real_dev)->get_short_addr(real_dev);
+}
+
 static struct header_ops lowpan_header_ops = {
        .create = lowpan_header_create,
 };
@@ -1053,6 +1071,12 @@ static const struct net_device_ops lowpan_netdev_ops = {
        .ndo_set_mac_address    = eth_mac_addr,
 };
 
+static struct ieee802154_mlme_ops lowpan_mlme = {
+       .get_pan_id = lowpan_get_pan_id,
+       .get_phy = lowpan_get_phy,
+       .get_short_addr = lowpan_get_short_addr,
+};
+
 static void lowpan_setup(struct net_device *dev)
 {
        pr_debug("(%s)\n", __func__);
@@ -1070,6 +1094,7 @@ static void lowpan_setup(struct net_device *dev)
 
        dev->netdev_ops         = &lowpan_netdev_ops;
        dev->header_ops         = &lowpan_header_ops;
+       dev->ml_priv            = &lowpan_mlme;
        dev->destructor         = lowpan_dev_free;
 }
 
@@ -1143,6 +1168,8 @@ static int lowpan_newlink(struct net *src_net, struct net_device *dev,
        list_add_tail(&entry->list, &lowpan_devices);
        mutex_unlock(&lowpan_dev_info(dev)->dev_list_mtx);
 
+       spin_lock_init(&flist_lock);
+
        register_netdevice(dev);
 
        return 0;
@@ -1152,11 +1179,20 @@ static void lowpan_dellink(struct net_device *dev, struct list_head *head)
 {
        struct lowpan_dev_info *lowpan_dev = lowpan_dev_info(dev);
        struct net_device *real_dev = lowpan_dev->real_dev;
-       struct lowpan_dev_record *entry;
-       struct lowpan_dev_record *tmp;
+       struct lowpan_dev_record *entry, *tmp;
+       struct lowpan_fragment *frame, *tframe;
 
        ASSERT_RTNL();
 
+       spin_lock(&flist_lock);
+       list_for_each_entry_safe(frame, tframe, &lowpan_fragments, list) {
+               del_timer(&frame->timer);
+               list_del(&frame->list);
+               dev_kfree_skb(frame->skb);
+               kfree(frame);
+       }
+       spin_unlock(&flist_lock);
+
        mutex_lock(&lowpan_dev_info(dev)->dev_list_mtx);
        list_for_each_entry_safe(entry, tmp, &lowpan_devices, list) {
                if (entry->ldev == dev) {
index 8d25a1c557eb50f012761227634d0ae7155c7180..8f8db724bfafe5f744a8f956dc7e710a67dc7faa 100644 (file)
@@ -141,7 +141,7 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
                        goto rtattr_failure;
 
        if (icsk == NULL) {
-               r->idiag_rqueue = r->idiag_wqueue = 0;
+               handler->idiag_get_info(sk, r, NULL);
                goto out;
        }
 
index 8bb6adeb62c0eb7dcba14841a1f08375cfde6304..1272a88c2a6331bb749d3a016710de649c1de057 100644 (file)
@@ -3243,7 +3243,7 @@ void __init tcp_init(void)
 {
        struct sk_buff *skb = NULL;
        unsigned long limit;
-       int max_share, cnt;
+       int max_rshare, max_wshare, cnt;
        unsigned int i;
        unsigned long jiffy = jiffies;
 
@@ -3303,15 +3303,16 @@ void __init tcp_init(void)
        tcp_init_mem(&init_net);
        /* Set per-socket limits to no more than 1/128 the pressure threshold */
        limit = nr_free_buffer_pages() << (PAGE_SHIFT - 7);
-       max_share = min(4UL*1024*1024, limit);
+       max_wshare = min(4UL*1024*1024, limit);
+       max_rshare = min(6UL*1024*1024, limit);
 
        sysctl_tcp_wmem[0] = SK_MEM_QUANTUM;
        sysctl_tcp_wmem[1] = 16*1024;
-       sysctl_tcp_wmem[2] = max(64*1024, max_share);
+       sysctl_tcp_wmem[2] = max(64*1024, max_wshare);
 
        sysctl_tcp_rmem[0] = SK_MEM_QUANTUM;
        sysctl_tcp_rmem[1] = 87380;
-       sysctl_tcp_rmem[2] = max(87380, max_share);
+       sysctl_tcp_rmem[2] = max(87380, max_rshare);
 
        pr_info("Hash tables configured (established %u bind %u)\n",
                tcp_hashinfo.ehash_mask + 1, tcp_hashinfo.bhash_size);
index 9944c1d9a2180b8fab1b431b1a2792d7ccbc3b87..257b61789eeba9fd064470c91e3a8bffb8d1812d 100644 (file)
@@ -85,7 +85,7 @@ int sysctl_tcp_ecn __read_mostly = 2;
 EXPORT_SYMBOL(sysctl_tcp_ecn);
 int sysctl_tcp_dsack __read_mostly = 1;
 int sysctl_tcp_app_win __read_mostly = 31;
-int sysctl_tcp_adv_win_scale __read_mostly = 2;
+int sysctl_tcp_adv_win_scale __read_mostly = 1;
 EXPORT_SYMBOL(sysctl_tcp_adv_win_scale);
 
 int sysctl_tcp_stdurg __read_mostly;
@@ -335,6 +335,7 @@ static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb)
                        incr = __tcp_grow_window(sk, skb);
 
                if (incr) {
+                       incr = max_t(int, incr, 2 * skb->len);
                        tp->rcv_ssthresh = min(tp->rcv_ssthresh + incr,
                                               tp->window_clamp);
                        inet_csk(sk)->icsk_ack.quick |= 1;
@@ -494,7 +495,7 @@ static inline void tcp_rcv_rtt_measure(struct tcp_sock *tp)
                goto new_measure;
        if (before(tp->rcv_nxt, tp->rcv_rtt_est.seq))
                return;
-       tcp_rcv_rtt_update(tp, jiffies - tp->rcv_rtt_est.time, 1);
+       tcp_rcv_rtt_update(tp, tcp_time_stamp - tp->rcv_rtt_est.time, 1);
 
 new_measure:
        tp->rcv_rtt_est.seq = tp->rcv_nxt + tp->rcv_wnd;
@@ -2867,11 +2868,14 @@ static inline void tcp_complete_cwr(struct sock *sk)
 
        /* Do not moderate cwnd if it's already undone in cwr or recovery. */
        if (tp->undo_marker) {
-               if (inet_csk(sk)->icsk_ca_state == TCP_CA_CWR)
+               if (inet_csk(sk)->icsk_ca_state == TCP_CA_CWR) {
                        tp->snd_cwnd = min(tp->snd_cwnd, tp->snd_ssthresh);
-               else /* PRR */
+                       tp->snd_cwnd_stamp = tcp_time_stamp;
+               } else if (tp->snd_ssthresh < TCP_INFINITE_SSTHRESH) {
+                       /* PRR algorithm. */
                        tp->snd_cwnd = tp->snd_ssthresh;
-               tp->snd_cwnd_stamp = tcp_time_stamp;
+                       tp->snd_cwnd_stamp = tcp_time_stamp;
+               }
        }
        tcp_ca_event(sk, CA_EVENT_COMPLETE_CWR);
 }
index 376b2cfbb685f78fb32d61823f0d4252729b6156..7ac6423117adfb333f433cc1b86356d38cb995ea 100644 (file)
@@ -1096,6 +1096,7 @@ static void __pskb_trim_head(struct sk_buff *skb, int len)
        eat = min_t(int, len, skb_headlen(skb));
        if (eat) {
                __skb_pull(skb, eat);
+               skb->avail_size -= eat;
                len -= eat;
                if (!len)
                        return;
index 8a949f19deb6dc93542396138004a5a6b2bfeeab..a7f86a3cd5023e2a7489167fcdd84df0d75a26a0 100644 (file)
@@ -146,9 +146,17 @@ static int udp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh,
        return udp_dump_one(&udp_table, in_skb, nlh, req);
 }
 
+static void udp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
+               void *info)
+{
+       r->idiag_rqueue = sk_rmem_alloc_get(sk);
+       r->idiag_wqueue = sk_wmem_alloc_get(sk);
+}
+
 static const struct inet_diag_handler udp_diag_handler = {
        .dump            = udp_diag_dump,
        .dump_one        = udp_diag_dump_one,
+       .idiag_get_info  = udp_diag_get_info,
        .idiag_type      = IPPROTO_UDP,
 };
 
@@ -167,6 +175,7 @@ static int udplite_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *
 static const struct inet_diag_handler udplite_diag_handler = {
        .dump            = udplite_diag_dump,
        .dump_one        = udplite_diag_dump_one,
+       .idiag_get_info  = udp_diag_get_info,
        .idiag_type      = IPPROTO_UDPLITE,
 };
 
index 6a3bb6077e19715bf2732bbce3d1c09d06aed104..7d5cb975cc6f8e6c22581daaa638b6b3df5a52d2 100644 (file)
@@ -803,8 +803,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
                                ip6_del_rt(rt);
                                rt = NULL;
                        } else if (!(rt->rt6i_flags & RTF_EXPIRES)) {
-                               rt->dst.expires = expires;
-                               rt->rt6i_flags |= RTF_EXPIRES;
+                               rt6_set_expires(rt, expires);
                        }
                }
                dst_release(&rt->dst);
@@ -1887,11 +1886,9 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
                                rt = NULL;
                        } else if (addrconf_finite_timeout(rt_expires)) {
                                /* not infinity */
-                               rt->dst.expires = jiffies + rt_expires;
-                               rt->rt6i_flags |= RTF_EXPIRES;
+                               rt6_set_expires(rt, jiffies + rt_expires);
                        } else {
-                               rt->rt6i_flags &= ~RTF_EXPIRES;
-                               rt->dst.expires = 0;
+                               rt6_clean_expires(rt);
                        }
                } else if (valid_lft) {
                        clock_t expires = 0;
index 5b27fbcae346677a28db262c5ffc1a272e1b1cd5..93717435013e0a146c10bc8cf3ea4cbddb627f9b 100644 (file)
@@ -673,11 +673,10 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
                                            &rt->rt6i_gateway)) {
                                if (!(iter->rt6i_flags & RTF_EXPIRES))
                                        return -EEXIST;
-                               iter->dst.expires = rt->dst.expires;
-                               if (!(rt->rt6i_flags & RTF_EXPIRES)) {
-                                       iter->rt6i_flags &= ~RTF_EXPIRES;
-                                       iter->dst.expires = 0;
-                               }
+                               if (!(rt->rt6i_flags & RTF_EXPIRES))
+                                       rt6_clean_expires(iter);
+                               else
+                                       rt6_set_expires(iter, rt->dst.expires);
                                return -EEXIST;
                        }
                }
index 3dcdb81ec3e8abdb934627cd243aed0e5ce3b5a3..176b469322acd0b63b6e8d7ad0f095129b165868 100644 (file)
@@ -1264,8 +1264,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
        }
 
        if (rt)
-               rt->dst.expires = jiffies + (HZ * lifetime);
-
+               rt6_set_expires(rt, jiffies + (HZ * lifetime));
        if (ra_msg->icmph.icmp6_hop_limit) {
                in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
                if (rt)
index 3992e26a603987cf8bba458dd4f687af5c900a2f..bc4888d902b2ed904f0ca767ac3e4d9cd35c252c 100644 (file)
@@ -62,7 +62,7 @@
 #include <linux/sysctl.h>
 #endif
 
-static struct rt6_info *ip6_rt_copy(const struct rt6_info *ort,
+static struct rt6_info *ip6_rt_copy(struct rt6_info *ort,
                                    const struct in6_addr *dest);
 static struct dst_entry        *ip6_dst_check(struct dst_entry *dst, u32 cookie);
 static unsigned int     ip6_default_advmss(const struct dst_entry *dst);
@@ -285,6 +285,10 @@ static void ip6_dst_destroy(struct dst_entry *dst)
                rt->rt6i_idev = NULL;
                in6_dev_put(idev);
        }
+
+       if (!(rt->rt6i_flags & RTF_EXPIRES) && dst->from)
+               dst_release(dst->from);
+
        if (peer) {
                rt->rt6i_peer = NULL;
                inet_putpeer(peer);
@@ -329,8 +333,17 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
 
 static __inline__ int rt6_check_expired(const struct rt6_info *rt)
 {
-       return (rt->rt6i_flags & RTF_EXPIRES) &&
-               time_after(jiffies, rt->dst.expires);
+       struct rt6_info *ort = NULL;
+
+       if (rt->rt6i_flags & RTF_EXPIRES) {
+               if (time_after(jiffies, rt->dst.expires))
+                       return 1;
+       } else if (rt->dst.from) {
+               ort = (struct rt6_info *) rt->dst.from;
+               return (ort->rt6i_flags & RTF_EXPIRES) &&
+                       time_after(jiffies, ort->dst.expires);
+       }
+       return 0;
 }
 
 static inline int rt6_need_strict(const struct in6_addr *daddr)
@@ -620,12 +633,11 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
                                 (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref);
 
        if (rt) {
-               if (!addrconf_finite_timeout(lifetime)) {
-                       rt->rt6i_flags &= ~RTF_EXPIRES;
-               } else {
-                       rt->dst.expires = jiffies + HZ * lifetime;
-                       rt->rt6i_flags |= RTF_EXPIRES;
-               }
+               if (!addrconf_finite_timeout(lifetime))
+                       rt6_clean_expires(rt);
+               else
+                       rt6_set_expires(rt, jiffies + HZ * lifetime);
+
                dst_release(&rt->dst);
        }
        return 0;
@@ -730,7 +742,7 @@ int ip6_ins_rt(struct rt6_info *rt)
        return __ip6_ins_rt(rt, &info);
 }
 
-static struct rt6_info *rt6_alloc_cow(const struct rt6_info *ort,
+static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort,
                                      const struct in6_addr *daddr,
                                      const struct in6_addr *saddr)
 {
@@ -954,10 +966,10 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori
                rt->rt6i_idev = ort->rt6i_idev;
                if (rt->rt6i_idev)
                        in6_dev_hold(rt->rt6i_idev);
-               rt->dst.expires = 0;
 
                rt->rt6i_gateway = ort->rt6i_gateway;
-               rt->rt6i_flags = ort->rt6i_flags & ~RTF_EXPIRES;
+               rt->rt6i_flags = ort->rt6i_flags;
+               rt6_clean_expires(rt);
                rt->rt6i_metric = 0;
 
                memcpy(&rt->rt6i_dst, &ort->rt6i_dst, sizeof(struct rt6key));
@@ -1019,10 +1031,9 @@ static void ip6_link_failure(struct sk_buff *skb)
 
        rt = (struct rt6_info *) skb_dst(skb);
        if (rt) {
-               if (rt->rt6i_flags & RTF_CACHE) {
-                       dst_set_expires(&rt->dst, 0);
-                       rt->rt6i_flags |= RTF_EXPIRES;
-               } else if (rt->rt6i_node && (rt->rt6i_flags & RTF_DEFAULT))
+               if (rt->rt6i_flags & RTF_CACHE)
+                       rt6_update_expires(rt, 0);
+               else if (rt->rt6i_node && (rt->rt6i_flags & RTF_DEFAULT))
                        rt->rt6i_node->fn_sernum = -1;
        }
 }
@@ -1289,9 +1300,12 @@ int ip6_route_add(struct fib6_config *cfg)
        }
 
        rt->dst.obsolete = -1;
-       rt->dst.expires = (cfg->fc_flags & RTF_EXPIRES) ?
-                               jiffies + clock_t_to_jiffies(cfg->fc_expires) :
-                               0;
+
+       if (cfg->fc_flags & RTF_EXPIRES)
+               rt6_set_expires(rt, jiffies +
+                               clock_t_to_jiffies(cfg->fc_expires));
+       else
+               rt6_clean_expires(rt);
 
        if (cfg->fc_protocol == RTPROT_UNSPEC)
                cfg->fc_protocol = RTPROT_BOOT;
@@ -1736,8 +1750,8 @@ again:
                        features |= RTAX_FEATURE_ALLFRAG;
                        dst_metric_set(&rt->dst, RTAX_FEATURES, features);
                }
-               dst_set_expires(&rt->dst, net->ipv6.sysctl.ip6_rt_mtu_expires);
-               rt->rt6i_flags |= RTF_MODIFIED|RTF_EXPIRES;
+               rt6_update_expires(rt, net->ipv6.sysctl.ip6_rt_mtu_expires);
+               rt->rt6i_flags |= RTF_MODIFIED;
                goto out;
        }
 
@@ -1765,9 +1779,8 @@ again:
                 * which is 10 mins. After 10 mins the decreased pmtu is expired
                 * and detecting PMTU increase will be automatically happened.
                 */
-               dst_set_expires(&nrt->dst, net->ipv6.sysctl.ip6_rt_mtu_expires);
-               nrt->rt6i_flags |= RTF_DYNAMIC|RTF_EXPIRES;
-
+               rt6_update_expires(nrt, net->ipv6.sysctl.ip6_rt_mtu_expires);
+               nrt->rt6i_flags |= RTF_DYNAMIC;
                ip6_ins_rt(nrt);
        }
 out:
@@ -1799,7 +1812,7 @@ void rt6_pmtu_discovery(const struct in6_addr *daddr, const struct in6_addr *sad
  *     Misc support functions
  */
 
-static struct rt6_info *ip6_rt_copy(const struct rt6_info *ort,
+static struct rt6_info *ip6_rt_copy(struct rt6_info *ort,
                                    const struct in6_addr *dest)
 {
        struct net *net = dev_net(ort->dst.dev);
@@ -1819,10 +1832,14 @@ static struct rt6_info *ip6_rt_copy(const struct rt6_info *ort,
                if (rt->rt6i_idev)
                        in6_dev_hold(rt->rt6i_idev);
                rt->dst.lastuse = jiffies;
-               rt->dst.expires = 0;
 
                rt->rt6i_gateway = ort->rt6i_gateway;
-               rt->rt6i_flags = ort->rt6i_flags & ~RTF_EXPIRES;
+               rt->rt6i_flags = ort->rt6i_flags;
+               if ((ort->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) ==
+                   (RTF_DEFAULT | RTF_ADDRCONF))
+                       rt6_set_from(rt, ort);
+               else
+                       rt6_clean_expires(rt);
                rt->rt6i_metric = 0;
 
 #ifdef CONFIG_IPV6_SUBTREES
index 86cfe6005f40a76c716676161efa521cbd808171..98256cf72f9dbca22dc80b3405ac80ec4fdb158f 100644 (file)
@@ -1383,6 +1383,10 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
        tcp_mtup_init(newsk);
        tcp_sync_mss(newsk, dst_mtu(dst));
        newtp->advmss = dst_metric_advmss(dst);
+       if (tcp_sk(sk)->rx_opt.user_mss &&
+           tcp_sk(sk)->rx_opt.user_mss < newtp->advmss)
+               newtp->advmss = tcp_sk(sk)->rx_opt.user_mss;
+
        tcp_initialize_rcv_mss(newsk);
        if (tcp_rsk(req)->snt_synack)
                tcp_valid_rtt_meas(newsk,
index 11dbb2255ccbce3f1e34c34f35a56a9ebd9428c1..7e5d927b576f79b8163b765ff5dcb6f6e0c4be43 100644 (file)
@@ -3480,7 +3480,7 @@ static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
 
        /* Addresses to be used by KM for negotiation, if ext is available */
        if (k != NULL && (set_sadb_kmaddress(skb, k) < 0))
-               return -EINVAL;
+               goto err;
 
        /* selector src */
        set_sadb_address(skb, sasize_sel, SADB_EXT_ADDRESS_SRC, sel);
index 55670ec3cd0f916143759cbc73320cf85b7ef196..6274f0be82b0c3445f6288f7fb8c7612d5325d69 100644 (file)
@@ -232,7 +232,7 @@ static void l2tp_ip_close(struct sock *sk, long timeout)
 {
        write_lock_bh(&l2tp_ip_lock);
        hlist_del_init(&sk->sk_bind_node);
-       hlist_del_init(&sk->sk_node);
+       sk_del_node_init(sk);
        write_unlock_bh(&l2tp_ip_lock);
        sk_common_release(sk);
 }
@@ -271,7 +271,8 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
            chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
                goto out;
 
-       inet->inet_rcv_saddr = inet->inet_saddr = addr->l2tp_addr.s_addr;
+       if (addr->l2tp_addr.s_addr)
+               inet->inet_rcv_saddr = inet->inet_saddr = addr->l2tp_addr.s_addr;
        if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
                inet->inet_saddr = 0;  /* Use device */
        sk_dst_reset(sk);
@@ -441,8 +442,9 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m
 
                daddr = lip->l2tp_addr.s_addr;
        } else {
+               rc = -EDESTADDRREQ;
                if (sk->sk_state != TCP_ESTABLISHED)
-                       return -EDESTADDRREQ;
+                       goto out;
 
                daddr = inet->inet_daddr;
                connected = 1;
index 33fd8d9f714ec05db8aeba88d0bb5c6bf97e8fd0..cef7c29214a8492b3e67f62c4248e5c89dfe7daf 100644 (file)
@@ -457,8 +457,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
                         * fall back to HT20 if we don't use or use
                         * the other extension channel
                         */
-                       if ((channel_type == NL80211_CHAN_HT40MINUS ||
-                            channel_type == NL80211_CHAN_HT40PLUS) &&
+                       if (!(channel_type == NL80211_CHAN_HT40MINUS ||
+                             channel_type == NL80211_CHAN_HT40PLUS) ||
                            channel_type != sdata->u.ibss.channel_type)
                                sta_ht_cap_new.cap &=
                                        ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
index d9798a307f20dabdeea69179e76008bccf144673..db8fae51714c54f35310777bb61a7052fa532297 100644 (file)
@@ -1210,7 +1210,7 @@ void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
                                  struct sk_buff *skb);
 void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata);
 void ieee80211_sta_reset_conn_monitor(struct ieee80211_sub_if_data *sdata);
-void ieee80211_mgd_teardown(struct ieee80211_sub_if_data *sdata);
+void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata);
 
 /* IBSS code */
 void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);
index 401c01f0731e996e5c22435f0066b53c97529559..c20051b7ffcd8518e6dd8e01c042b3fbf6981677 100644 (file)
@@ -486,6 +486,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
                /* free all potentially still buffered bcast frames */
                local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps_bc_buf);
                skb_queue_purge(&sdata->u.ap.ps_bc_buf);
+       } else if (sdata->vif.type == NL80211_IFTYPE_STATION) {
+               ieee80211_mgd_stop(sdata);
        }
 
        if (going_down)
@@ -644,8 +646,6 @@ static void ieee80211_teardown_sdata(struct net_device *dev)
 
        if (ieee80211_vif_is_mesh(&sdata->vif))
                mesh_rmc_free(sdata);
-       else if (sdata->vif.type == NL80211_IFTYPE_STATION)
-               ieee80211_mgd_teardown(sdata);
 
        flushed = sta_info_flush(local, sdata);
        WARN_ON(flushed);
index f76da5b3f5c5864f0b649187fca47517d244ce77..20c680bfc3ae0fd52f502c9c920a0ea4c0f20f86 100644 (file)
@@ -3497,7 +3497,7 @@ int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
        return 0;
 }
 
-void ieee80211_mgd_teardown(struct ieee80211_sub_if_data *sdata)
+void ieee80211_mgd_stop(struct ieee80211_sub_if_data *sdata)
 {
        struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
 
index bcfe8c77c8392dae5e730d8b76c0c18bb9720622..d64e285400aaab3245c31af4ec6401cd1e77b294 100644 (file)
@@ -103,7 +103,7 @@ static void
 ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
                                 struct sk_buff *skb,
                                 struct ieee80211_rate *rate,
-                                int rtap_len)
+                                int rtap_len, bool has_fcs)
 {
        struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
        struct ieee80211_radiotap_header *rthdr;
@@ -134,7 +134,7 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
        }
 
        /* IEEE80211_RADIOTAP_FLAGS */
-       if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS)
+       if (has_fcs && (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS))
                *pos |= IEEE80211_RADIOTAP_F_FCS;
        if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
                *pos |= IEEE80211_RADIOTAP_F_BADFCS;
@@ -294,7 +294,8 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
        }
 
        /* prepend radiotap information */
-       ieee80211_add_rx_radiotap_header(local, skb, rate, needed_headroom);
+       ieee80211_add_rx_radiotap_header(local, skb, rate, needed_headroom,
+                                        true);
 
        skb_reset_mac_header(skb);
        skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -2571,7 +2572,8 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx,
                goto out_free_skb;
 
        /* prepend radiotap information */
-       ieee80211_add_rx_radiotap_header(local, skb, rate, needed_headroom);
+       ieee80211_add_rx_radiotap_header(local, skb, rate, needed_headroom,
+                                        false);
 
        skb_set_mac_header(skb, 0);
        skb->ip_summed = CHECKSUM_UNNECESSARY;
index 782a60198df46977754c8720f101ed8016b928e5..e76facc69e952c9aedb835bbfeedbb7fbea0d5ea 100644 (file)
@@ -1158,7 +1158,8 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata,
                tx->sta = rcu_dereference(sdata->u.vlan.sta);
                if (!tx->sta && sdata->dev->ieee80211_ptr->use_4addr)
                        return TX_DROP;
-       } else if (info->flags & IEEE80211_TX_CTL_INJECTED) {
+       } else if (info->flags & IEEE80211_TX_CTL_INJECTED ||
+                  tx->sdata->control_port_protocol == tx->skb->protocol) {
                tx->sta = sta_info_get_bss(sdata, hdr->addr1);
        }
        if (!tx->sta)
index 2555816e778827250e5aec0d33eaa2fa9512addc..00bdb1d9d690b5acb100fe38c2e455a110d8f09b 100644 (file)
@@ -1924,6 +1924,7 @@ protocol_fail:
 control_fail:
        ip_vs_estimator_net_cleanup(net);
 estimator_fail:
+       net->ipvs = NULL;
        return -ENOMEM;
 }
 
@@ -1936,6 +1937,7 @@ static void __net_exit __ip_vs_cleanup(struct net *net)
        ip_vs_control_net_cleanup(net);
        ip_vs_estimator_net_cleanup(net);
        IP_VS_DBG(2, "ipvs netns %d released\n", net_ipvs(net)->gen);
+       net->ipvs = NULL;
 }
 
 static void __net_exit __ip_vs_dev_cleanup(struct net *net)
@@ -1993,10 +1995,18 @@ static int __init ip_vs_init(void)
                goto cleanup_dev;
        }
 
+       ret = ip_vs_register_nl_ioctl();
+       if (ret < 0) {
+               pr_err("can't register netlink/ioctl.\n");
+               goto cleanup_hooks;
+       }
+
        pr_info("ipvs loaded.\n");
 
        return ret;
 
+cleanup_hooks:
+       nf_unregister_hooks(ip_vs_ops, ARRAY_SIZE(ip_vs_ops));
 cleanup_dev:
        unregister_pernet_device(&ipvs_core_dev_ops);
 cleanup_sub:
@@ -2012,6 +2022,7 @@ exit:
 
 static void __exit ip_vs_cleanup(void)
 {
+       ip_vs_unregister_nl_ioctl();
        nf_unregister_hooks(ip_vs_ops, ARRAY_SIZE(ip_vs_ops));
        unregister_pernet_device(&ipvs_core_dev_ops);
        unregister_pernet_subsys(&ipvs_core_ops);       /* free ip_vs struct */
index b3afe189af61880464ef6562c568016509957293..f5589987fc80d59a8d1fc5ec1e546d72562521fa 100644 (file)
@@ -3680,7 +3680,7 @@ int __net_init ip_vs_control_net_init_sysctl(struct net *net)
        return 0;
 }
 
-void __net_init ip_vs_control_net_cleanup_sysctl(struct net *net)
+void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net)
 {
        struct netns_ipvs *ipvs = net_ipvs(net);
 
@@ -3692,7 +3692,7 @@ void __net_init ip_vs_control_net_cleanup_sysctl(struct net *net)
 #else
 
 int __net_init ip_vs_control_net_init_sysctl(struct net *net) { return 0; }
-void __net_init ip_vs_control_net_cleanup_sysctl(struct net *net) { }
+void __net_exit ip_vs_control_net_cleanup_sysctl(struct net *net) { }
 
 #endif
 
@@ -3750,21 +3750,10 @@ void __net_exit ip_vs_control_net_cleanup(struct net *net)
        free_percpu(ipvs->tot_stats.cpustats);
 }
 
-int __init ip_vs_control_init(void)
+int __init ip_vs_register_nl_ioctl(void)
 {
-       int idx;
        int ret;
 
-       EnterFunction(2);
-
-       /* Initialize svc_table, ip_vs_svc_fwm_table, rs_table */
-       for(idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++)  {
-               INIT_LIST_HEAD(&ip_vs_svc_table[idx]);
-               INIT_LIST_HEAD(&ip_vs_svc_fwm_table[idx]);
-       }
-
-       smp_wmb();      /* Do we really need it now ? */
-
        ret = nf_register_sockopt(&ip_vs_sockopts);
        if (ret) {
                pr_err("cannot register sockopt.\n");
@@ -3776,28 +3765,47 @@ int __init ip_vs_control_init(void)
                pr_err("cannot register Generic Netlink interface.\n");
                goto err_genl;
        }
-
-       ret = register_netdevice_notifier(&ip_vs_dst_notifier);
-       if (ret < 0)
-               goto err_notf;
-
-       LeaveFunction(2);
        return 0;
 
-err_notf:
-       ip_vs_genl_unregister();
 err_genl:
        nf_unregister_sockopt(&ip_vs_sockopts);
 err_sock:
        return ret;
 }
 
+void ip_vs_unregister_nl_ioctl(void)
+{
+       ip_vs_genl_unregister();
+       nf_unregister_sockopt(&ip_vs_sockopts);
+}
+
+int __init ip_vs_control_init(void)
+{
+       int idx;
+       int ret;
+
+       EnterFunction(2);
+
+       /* Initialize svc_table, ip_vs_svc_fwm_table, rs_table */
+       for (idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) {
+               INIT_LIST_HEAD(&ip_vs_svc_table[idx]);
+               INIT_LIST_HEAD(&ip_vs_svc_fwm_table[idx]);
+       }
+
+       smp_wmb();      /* Do we really need it now ? */
+
+       ret = register_netdevice_notifier(&ip_vs_dst_notifier);
+       if (ret < 0)
+               return ret;
+
+       LeaveFunction(2);
+       return 0;
+}
+
 
 void ip_vs_control_cleanup(void)
 {
        EnterFunction(2);
        unregister_netdevice_notifier(&ip_vs_dst_notifier);
-       ip_vs_genl_unregister();
-       nf_unregister_sockopt(&ip_vs_sockopts);
        LeaveFunction(2);
 }
index 538d74ee4f68bc18e7bb379d7432388aba305425..e39f693dd3e49b9595ced939bd0531c07acdd159 100644 (file)
@@ -439,6 +439,8 @@ static int __net_init __ip_vs_ftp_init(struct net *net)
        struct ip_vs_app *app;
        struct netns_ipvs *ipvs = net_ipvs(net);
 
+       if (!ipvs)
+               return -ENOENT;
        app = kmemdup(&ip_vs_ftp, sizeof(struct ip_vs_app), GFP_KERNEL);
        if (!app)
                return -ENOMEM;
index 0f16283fd05854fccc68fad349c7f29509926252..caa43704e55ead5f5c6c2287e78c818cacb038e4 100644 (file)
@@ -551,6 +551,9 @@ static int __net_init __ip_vs_lblc_init(struct net *net)
 {
        struct netns_ipvs *ipvs = net_ipvs(net);
 
+       if (!ipvs)
+               return -ENOENT;
+
        if (!net_eq(net, &init_net)) {
                ipvs->lblc_ctl_table = kmemdup(vs_vars_table,
                                                sizeof(vs_vars_table),
index eec797f8cce705a1676caeb3c3078053ddcdf523..548bf37aa29e07ebd53eaa760dbcadf844edfa13 100644 (file)
@@ -745,6 +745,9 @@ static int __net_init __ip_vs_lblcr_init(struct net *net)
 {
        struct netns_ipvs *ipvs = net_ipvs(net);
 
+       if (!ipvs)
+               return -ENOENT;
+
        if (!net_eq(net, &init_net)) {
                ipvs->lblcr_ctl_table = kmemdup(vs_vars_table,
                                                sizeof(vs_vars_table),
index f843a88332509edc9ac7ed509cba6d679685664f..ed835e67a07e07598408b130f64fbafd85a33679 100644 (file)
@@ -59,9 +59,6 @@ static int __used __init register_ip_vs_protocol(struct ip_vs_protocol *pp)
        return 0;
 }
 
-#if defined(CONFIG_IP_VS_PROTO_TCP) || defined(CONFIG_IP_VS_PROTO_UDP) || \
-    defined(CONFIG_IP_VS_PROTO_SCTP) || defined(CONFIG_IP_VS_PROTO_AH) || \
-    defined(CONFIG_IP_VS_PROTO_ESP)
 /*
  *     register an ipvs protocols netns related data
  */
@@ -81,12 +78,18 @@ register_ip_vs_proto_netns(struct net *net, struct ip_vs_protocol *pp)
        ipvs->proto_data_table[hash] = pd;
        atomic_set(&pd->appcnt, 0);     /* Init app counter */
 
-       if (pp->init_netns != NULL)
-               pp->init_netns(net, pd);
+       if (pp->init_netns != NULL) {
+               int ret = pp->init_netns(net, pd);
+               if (ret) {
+                       /* unlink an free proto data */
+                       ipvs->proto_data_table[hash] = pd->next;
+                       kfree(pd);
+                       return ret;
+               }
+       }
 
        return 0;
 }
-#endif
 
 /*
  *     unregister an ipvs protocol
@@ -316,22 +319,35 @@ ip_vs_tcpudp_debug_packet(int af, struct ip_vs_protocol *pp,
  */
 int __net_init ip_vs_protocol_net_init(struct net *net)
 {
+       int i, ret;
+       static struct ip_vs_protocol *protos[] = {
 #ifdef CONFIG_IP_VS_PROTO_TCP
-       register_ip_vs_proto_netns(net, &ip_vs_protocol_tcp);
+        &ip_vs_protocol_tcp,
 #endif
 #ifdef CONFIG_IP_VS_PROTO_UDP
-       register_ip_vs_proto_netns(net, &ip_vs_protocol_udp);
+       &ip_vs_protocol_udp,
 #endif
 #ifdef CONFIG_IP_VS_PROTO_SCTP
-       register_ip_vs_proto_netns(net, &ip_vs_protocol_sctp);
+       &ip_vs_protocol_sctp,
 #endif
 #ifdef CONFIG_IP_VS_PROTO_AH
-       register_ip_vs_proto_netns(net, &ip_vs_protocol_ah);
+       &ip_vs_protocol_ah,
 #endif
 #ifdef CONFIG_IP_VS_PROTO_ESP
-       register_ip_vs_proto_netns(net, &ip_vs_protocol_esp);
+       &ip_vs_protocol_esp,
 #endif
+       };
+
+       for (i = 0; i < ARRAY_SIZE(protos); i++) {
+               ret = register_ip_vs_proto_netns(net, protos[i]);
+               if (ret < 0)
+                       goto cleanup;
+       }
        return 0;
+
+cleanup:
+       ip_vs_protocol_net_cleanup(net);
+       return ret;
 }
 
 void __net_exit ip_vs_protocol_net_cleanup(struct net *net)
index 1fbf7a2816f5ade317a747737840588d41621bf0..9f3fb751c49154bac37fa4baa84853a2c0dd0c06 100644 (file)
@@ -1090,7 +1090,7 @@ out:
  *   timeouts is netns related now.
  * ---------------------------------------------
  */
-static void __ip_vs_sctp_init(struct net *net, struct ip_vs_proto_data *pd)
+static int __ip_vs_sctp_init(struct net *net, struct ip_vs_proto_data *pd)
 {
        struct netns_ipvs *ipvs = net_ipvs(net);
 
@@ -1098,6 +1098,9 @@ static void __ip_vs_sctp_init(struct net *net, struct ip_vs_proto_data *pd)
        spin_lock_init(&ipvs->sctp_app_lock);
        pd->timeout_table = ip_vs_create_timeout_table((int *)sctp_timeouts,
                                                        sizeof(sctp_timeouts));
+       if (!pd->timeout_table)
+               return -ENOMEM;
+       return 0;
 }
 
 static void __ip_vs_sctp_exit(struct net *net, struct ip_vs_proto_data *pd)
index ef8641f7af8300efae329a3a74cb4325eba1761f..cd609cc62721095baf50475d14e80384089f280a 100644 (file)
@@ -677,7 +677,7 @@ void ip_vs_tcp_conn_listen(struct net *net, struct ip_vs_conn *cp)
  *   timeouts is netns related now.
  * ---------------------------------------------
  */
-static void __ip_vs_tcp_init(struct net *net, struct ip_vs_proto_data *pd)
+static int __ip_vs_tcp_init(struct net *net, struct ip_vs_proto_data *pd)
 {
        struct netns_ipvs *ipvs = net_ipvs(net);
 
@@ -685,7 +685,10 @@ static void __ip_vs_tcp_init(struct net *net, struct ip_vs_proto_data *pd)
        spin_lock_init(&ipvs->tcp_app_lock);
        pd->timeout_table = ip_vs_create_timeout_table((int *)tcp_timeouts,
                                                        sizeof(tcp_timeouts));
+       if (!pd->timeout_table)
+               return -ENOMEM;
        pd->tcp_state_table =  tcp_states;
+       return 0;
 }
 
 static void __ip_vs_tcp_exit(struct net *net, struct ip_vs_proto_data *pd)
index f4b7262896bbd272fb8d3cff5298455b1deff703..2fedb2dcb3d1f5e831546b59480eceee14e59a84 100644 (file)
@@ -467,7 +467,7 @@ udp_state_transition(struct ip_vs_conn *cp, int direction,
        cp->timeout = pd->timeout_table[IP_VS_UDP_S_NORMAL];
 }
 
-static void __udp_init(struct net *net, struct ip_vs_proto_data *pd)
+static int __udp_init(struct net *net, struct ip_vs_proto_data *pd)
 {
        struct netns_ipvs *ipvs = net_ipvs(net);
 
@@ -475,6 +475,9 @@ static void __udp_init(struct net *net, struct ip_vs_proto_data *pd)
        spin_lock_init(&ipvs->udp_app_lock);
        pd->timeout_table = ip_vs_create_timeout_table((int *)udp_timeouts,
                                                        sizeof(udp_timeouts));
+       if (!pd->timeout_table)
+               return -ENOMEM;
+       return 0;
 }
 
 static void __udp_exit(struct net *net, struct ip_vs_proto_data *pd)
index 59530e93fa58f7abdaa4a0734ad2fd1e5241c040..3746d8b9a47868694be0848fc0d09013a0a5b282 100644 (file)
@@ -227,7 +227,7 @@ static int xt_ct_tg_check_v1(const struct xt_tgchk_param *par)
        }
 
 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
-       if (info->timeout) {
+       if (info->timeout[0]) {
                typeof(nf_ct_timeout_find_get_hook) timeout_find_get;
                struct nf_conn_timeout *timeout_ext;
 
index 9b9a85ecc4c79d70c88db78a12e5d54309e28d43..bf5cf69c820a285be318ecb3dab044530f2c8bc2 100644 (file)
@@ -331,23 +331,6 @@ static int __net_init phonet_init_net(struct net *net)
 
 static void __net_exit phonet_exit_net(struct net *net)
 {
-       struct phonet_net *pnn = phonet_pernet(net);
-       struct net_device *dev;
-       unsigned i;
-
-       rtnl_lock();
-       for_each_netdev(net, dev)
-               phonet_device_destroy(dev);
-
-       for (i = 0; i < 64; i++) {
-               dev = pnn->routes.table[i];
-               if (dev) {
-                       rtm_phonet_notify(RTM_DELROUTE, dev, i);
-                       dev_put(dev);
-               }
-       }
-       rtnl_unlock();
-
        proc_net_remove(net, "phonet");
 }
 
@@ -361,7 +344,7 @@ static struct pernet_operations phonet_net_ops = {
 /* Initialize Phonet devices list */
 int __init phonet_device_init(void)
 {
-       int err = register_pernet_device(&phonet_net_ops);
+       int err = register_pernet_subsys(&phonet_net_ops);
        if (err)
                return err;
 
@@ -377,7 +360,7 @@ void phonet_device_exit(void)
 {
        rtnl_unregister_all(PF_PHONET);
        unregister_netdevice_notifier(&phonet_device_notifier);
-       unregister_pernet_device(&phonet_net_ops);
+       unregister_pernet_subsys(&phonet_net_ops);
        proc_net_remove(&init_net, "pnresource");
 }
 
index 0b15236be7b609251199a36b5fdd0f9b6075b18f..8179494c269a205467da62e5c97c125a1a6b09c6 100644 (file)
@@ -565,11 +565,8 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb)
                opt.packets     = q->packetsin;
                opt.bytesin     = q->bytesin;
 
-               if (gred_wred_mode(table)) {
-                       q->vars.qidlestart =
-                               table->tab[table->def]->vars.qidlestart;
-                       q->vars.qavg = table->tab[table->def]->vars.qavg;
-               }
+               if (gred_wred_mode(table))
+                       gred_load_wred_set(table, q);
 
                opt.qave = red_calc_qavg(&q->parms, &q->vars, q->vars.qavg);
 
index 5da548fa7ae9d46de78f5b75152e1a84b99ca9a7..ebd22966f7480aaacb49ca892c774ac23c477acb 100644 (file)
@@ -408,10 +408,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
        if (q->corrupt && q->corrupt >= get_crandom(&q->corrupt_cor)) {
                if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
                    (skb->ip_summed == CHECKSUM_PARTIAL &&
-                    skb_checksum_help(skb))) {
-                       sch->qstats.drops++;
-                       return NET_XMIT_DROP;
-               }
+                    skb_checksum_help(skb)))
+                       return qdisc_drop(skb, sch);
 
                skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8);
        }
index 67972462a543d1bad6326ec214c73bc9dce17d0b..adf2990acebfd2ff7513f2344f0a143c326eb6ef 100644 (file)
@@ -176,16 +176,22 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, const char *dir_name)
        return 0;
 }
 
-static int __rpc_pipefs_event(struct rpc_clnt *clnt, unsigned long event,
-                               struct super_block *sb)
+static inline int rpc_clnt_skip_event(struct rpc_clnt *clnt, unsigned long event)
+{
+       if (((event == RPC_PIPEFS_MOUNT) && clnt->cl_dentry) ||
+           ((event == RPC_PIPEFS_UMOUNT) && !clnt->cl_dentry))
+               return 1;
+       return 0;
+}
+
+static int __rpc_clnt_handle_event(struct rpc_clnt *clnt, unsigned long event,
+                                  struct super_block *sb)
 {
        struct dentry *dentry;
        int err = 0;
 
        switch (event) {
        case RPC_PIPEFS_MOUNT:
-               if (clnt->cl_program->pipe_dir_name == NULL)
-                       break;
                dentry = rpc_setup_pipedir_sb(sb, clnt,
                                              clnt->cl_program->pipe_dir_name);
                BUG_ON(dentry == NULL);
@@ -208,6 +214,20 @@ static int __rpc_pipefs_event(struct rpc_clnt *clnt, unsigned long event,
        return err;
 }
 
+static int __rpc_pipefs_event(struct rpc_clnt *clnt, unsigned long event,
+                               struct super_block *sb)
+{
+       int error = 0;
+
+       for (;; clnt = clnt->cl_parent) {
+               if (!rpc_clnt_skip_event(clnt, event))
+                       error = __rpc_clnt_handle_event(clnt, event, sb);
+               if (error || clnt == clnt->cl_parent)
+                       break;
+       }
+       return error;
+}
+
 static struct rpc_clnt *rpc_get_client_for_event(struct net *net, int event)
 {
        struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
@@ -215,10 +235,12 @@ static struct rpc_clnt *rpc_get_client_for_event(struct net *net, int event)
 
        spin_lock(&sn->rpc_client_lock);
        list_for_each_entry(clnt, &sn->all_clients, cl_clients) {
-               if (((event == RPC_PIPEFS_MOUNT) && clnt->cl_dentry) ||
-                   ((event == RPC_PIPEFS_UMOUNT) && !clnt->cl_dentry))
+               if (clnt->cl_program->pipe_dir_name == NULL)
+                       break;
+               if (rpc_clnt_skip_event(clnt, event))
+                       continue;
+               if (atomic_inc_not_zero(&clnt->cl_count) == 0)
                        continue;
-               atomic_inc(&clnt->cl_count);
                spin_unlock(&sn->rpc_client_lock);
                return clnt;
        }
@@ -257,6 +279,14 @@ void rpc_clients_notifier_unregister(void)
        return rpc_pipefs_notifier_unregister(&rpc_clients_block);
 }
 
+static void rpc_clnt_set_nodename(struct rpc_clnt *clnt, const char *nodename)
+{
+       clnt->cl_nodelen = strlen(nodename);
+       if (clnt->cl_nodelen > UNX_MAXNODENAME)
+               clnt->cl_nodelen = UNX_MAXNODENAME;
+       memcpy(clnt->cl_nodename, nodename, clnt->cl_nodelen);
+}
+
 static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, struct rpc_xprt *xprt)
 {
        const struct rpc_program *program = args->program;
@@ -337,10 +367,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
        }
 
        /* save the nodename */
-       clnt->cl_nodelen = strlen(init_utsname()->nodename);
-       if (clnt->cl_nodelen > UNX_MAXNODENAME)
-               clnt->cl_nodelen = UNX_MAXNODENAME;
-       memcpy(clnt->cl_nodename, init_utsname()->nodename, clnt->cl_nodelen);
+       rpc_clnt_set_nodename(clnt, utsname()->nodename);
        rpc_register_client(clnt);
        return clnt;
 
@@ -499,6 +526,7 @@ rpc_clone_client(struct rpc_clnt *clnt)
        err = rpc_setup_pipedir(new, clnt->cl_program->pipe_dir_name);
        if (err != 0)
                goto out_no_path;
+       rpc_clnt_set_nodename(new, utsname()->nodename);
        if (new->cl_auth)
                atomic_inc(&new->cl_auth->au_count);
        atomic_inc(&clnt->cl_count);
index 0af37fc468181e9a6917c695d8f60dd381734e78..3b62cf2880316bfb9942960e1fc34e39c64f92bf 100644 (file)
@@ -1126,19 +1126,20 @@ rpc_fill_super(struct super_block *sb, void *data, int silent)
                return -ENOMEM;
        dprintk("RPC:   sending pipefs MOUNT notification for net %p%s\n", net,
                                                                NET_NAME(net));
+       sn->pipefs_sb = sb;
        err = blocking_notifier_call_chain(&rpc_pipefs_notifier_list,
                                           RPC_PIPEFS_MOUNT,
                                           sb);
        if (err)
                goto err_depopulate;
        sb->s_fs_info = get_net(net);
-       sn->pipefs_sb = sb;
        return 0;
 
 err_depopulate:
        blocking_notifier_call_chain(&rpc_pipefs_notifier_list,
                                           RPC_PIPEFS_UMOUNT,
                                           sb);
+       sn->pipefs_sb = NULL;
        __rpc_depopulate(root, files, RPCAUTH_lockd, RPCAUTH_RootEOF);
        return err;
 }
index 8adfc88e793a72308f72012bd30e447cd40dd6bf..3d6498af9adc1a1035005c735ee932de6488bee3 100644 (file)
@@ -75,19 +75,20 @@ static struct pernet_operations sunrpc_net_ops = {
 static int __init
 init_sunrpc(void)
 {
-       int err = register_rpc_pipefs();
+       int err = rpc_init_mempool();
        if (err)
                goto out;
-       err = rpc_init_mempool();
-       if (err)
-               goto out2;
        err = rpcauth_init_module();
        if (err)
-               goto out3;
+               goto out2;
 
        cache_initialize();
 
        err = register_pernet_subsys(&sunrpc_net_ops);
+       if (err)
+               goto out3;
+
+       err = register_rpc_pipefs();
        if (err)
                goto out4;
 #ifdef RPC_DEBUG
@@ -98,11 +99,11 @@ init_sunrpc(void)
        return 0;
 
 out4:
-       rpcauth_remove_module();
+       unregister_pernet_subsys(&sunrpc_net_ops);
 out3:
-       rpc_destroy_mempool();
+       rpcauth_remove_module();
 out2:
-       unregister_rpc_pipefs();
+       rpc_destroy_mempool();
 out:
        return err;
 }
index 1b7a08df933c79bf4ffe62455747464468c84bdb..957f2562161753fcec3b8789734bc0a36afebb84 100644 (file)
@@ -989,7 +989,7 @@ int cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,
                        if (rdev->wiphy.software_iftypes & BIT(iftype))
                                continue;
                        for (j = 0; j < c->n_limits; j++) {
-                               if (!(limits[j].types & iftype))
+                               if (!(limits[j].types & BIT(iftype)))
                                        continue;
                                if (limits[j].max < num[iftype])
                                        goto cont;
index 8e730ccc3f2b22d55e7b716cf20298da4e9b7475..44ddaa542db6fbb6612560ac312b65ffca330b4c 100644 (file)
@@ -1100,6 +1100,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
        if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections)
                return;
 
+       /* We're looking for an object */
+       if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT)
+               return;
+
        /* All our symbols are of form <prefix>__mod_XXX_device_table. */
        name = strstr(symname, "__mod_");
        if (!name)
index e65e3543305568a9ab910057502ba583f656e724..818f90bc7d57c6fc78bc0ede0372e976b2db7cf3 100644 (file)
@@ -6109,6 +6109,7 @@ static const struct alc_fixup alc269_fixups[] = {
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED),
+       SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC),
        SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
        SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
        SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
index df3ac73f8778288d6666e29728e6136b44630827..b39ad356b92b84e2d649c0ea986c2ba23aecbac9 100644 (file)
@@ -99,6 +99,7 @@ static struct snd_soc_dai_link bf5xx_ssm2602_dai[] = {
                .platform_name = "bfin-i2s-pcm-audio",
                .codec_name = "ssm2602.0-001b",
                .ops = &bf5xx_ssm2602_ops,
+               .dai_fmt = BF5XX_SSM2602_DAIFMT,
        },
        {
                .name = "ssm2602",
@@ -108,6 +109,7 @@ static struct snd_soc_dai_link bf5xx_ssm2602_dai[] = {
                .platform_name = "bfin-i2s-pcm-audio",
                .codec_name = "ssm2602.0-001b",
                .ops = &bf5xx_ssm2602_ops,
+               .dai_fmt = BF5XX_SSM2602_DAIFMT,
        },
 };
 
index 78979b3e0e95ad41c3af9836889e03a422da00ec..07c44b71f096067a3ffa6c5dd27aa0d36322984c 100644 (file)
@@ -929,6 +929,8 @@ static int cs42l73_set_mclk(struct snd_soc_dai *dai, unsigned int freq)
 
        /* MCLKX -> MCLK */
        mclkx_coeff = cs42l73_get_mclkx_coeff(freq);
+       if (mclkx_coeff < 0)
+               return mclkx_coeff;
 
        mclk = cs42l73_mclkx_coeffs[mclkx_coeff].mclkx /
                cs42l73_mclkx_coeffs[mclkx_coeff].ratio;
index 16d55f91a6535e088dff5999ee9bae408999dd7e..df1e07ffac32f6057f1e94d2a9421b14a8a89c9b 100644 (file)
@@ -472,7 +472,7 @@ static int tlv320aic23_set_dai_sysclk(struct snd_soc_dai *codec_dai,
 static int tlv320aic23_set_bias_level(struct snd_soc_codec *codec,
                                      enum snd_soc_bias_level level)
 {
-       u16 reg = snd_soc_read(codec, TLV320AIC23_PWR) & 0xff7f;
+       u16 reg = snd_soc_read(codec, TLV320AIC23_PWR) & 0x17f;
 
        switch (level) {
        case SND_SOC_BIAS_ON:
@@ -491,7 +491,7 @@ static int tlv320aic23_set_bias_level(struct snd_soc_codec *codec,
        case SND_SOC_BIAS_OFF:
                /* everything off, dac mute, inactive */
                snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x0);
-               snd_soc_write(codec, TLV320AIC23_PWR, 0xffff);
+               snd_soc_write(codec, TLV320AIC23_PWR, 0x1ff);
                break;
        }
        codec->dapm.bias_level = level;
index 8c4c9591ec055103eb1cf3381ae3e3d969abac85..aa12c6b6beeb40c0cb80580772739259b1e9f27a 100644 (file)
@@ -60,7 +60,7 @@ struct wm8350_jack_data {
 };
 
 struct wm8350_data {
-       struct snd_soc_codec codec;
+       struct wm8350 *wm8350;
        struct wm8350_output out1;
        struct wm8350_output out2;
        struct wm8350_jack_data hpl;
@@ -1309,7 +1309,7 @@ static void wm8350_hp_work(struct wm8350_data *priv,
                           struct wm8350_jack_data *jack,
                           u16 mask)
 {
-       struct wm8350 *wm8350 = priv->codec.control_data;
+       struct wm8350 *wm8350 = priv->wm8350;
        u16 reg;
        int report;
 
@@ -1342,7 +1342,7 @@ static void wm8350_hpr_work(struct work_struct *work)
 static irqreturn_t wm8350_hp_jack_handler(int irq, void *data)
 {
        struct wm8350_data *priv = data;
-       struct wm8350 *wm8350 = priv->codec.control_data;
+       struct wm8350 *wm8350 = priv->wm8350;
        struct wm8350_jack_data *jack = NULL;
 
        switch (irq - wm8350->irq_base) {
@@ -1427,7 +1427,7 @@ EXPORT_SYMBOL_GPL(wm8350_hp_jack_detect);
 static irqreturn_t wm8350_mic_handler(int irq, void *data)
 {
        struct wm8350_data *priv = data;
-       struct wm8350 *wm8350 = priv->codec.control_data;
+       struct wm8350 *wm8350 = priv->wm8350;
        u16 reg;
        int report = 0;
 
@@ -1536,6 +1536,8 @@ static  int wm8350_codec_probe(struct snd_soc_codec *codec)
                return -ENOMEM;
        snd_soc_codec_set_drvdata(codec, priv);
 
+       priv->wm8350 = wm8350;
+
        for (i = 0; i < ARRAY_SIZE(supply_names); i++)
                priv->supplies[i].supply = supply_names[i];
 
@@ -1544,7 +1546,6 @@ static  int wm8350_codec_probe(struct snd_soc_codec *codec)
        if (ret != 0)
                return ret;
 
-       wm8350->codec.codec = codec;
        codec->control_data = wm8350;
 
        /* Put the codec into reset if it wasn't already */
index 7c49642af05249197f233c94832a16e6792200f5..6c1fe3afd4b59311686ce3c9e2940cf5d223b1ed 100644 (file)
@@ -1000,61 +1000,170 @@ static void wm8994_update_class_w(struct snd_soc_codec *codec)
        }
 }
 
-static int late_enable_ev(struct snd_soc_dapm_widget *w,
-                         struct snd_kcontrol *kcontrol, int event)
+static int aif1clk_ev(struct snd_soc_dapm_widget *w,
+                     struct snd_kcontrol *kcontrol, int event)
 {
        struct snd_soc_codec *codec = w->codec;
-       struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
+       struct wm8994 *control = codec->control_data;
+       int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA;
+       int dac;
+       int adc;
+       int val;
+
+       switch (control->type) {
+       case WM8994:
+       case WM8958:
+               mask |= WM8994_AIF1DAC2L_ENA | WM8994_AIF1DAC2R_ENA;
+               break;
+       default:
+               break;
+       }
 
        switch (event) {
        case SND_SOC_DAPM_PRE_PMU:
-               if (wm8994->aif1clk_enable) {
-                       snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
-                                           WM8994_AIF1CLK_ENA_MASK,
-                                           WM8994_AIF1CLK_ENA);
-                       wm8994->aif1clk_enable = 0;
-               }
-               if (wm8994->aif2clk_enable) {
-                       snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1,
-                                           WM8994_AIF2CLK_ENA_MASK,
-                                           WM8994_AIF2CLK_ENA);
-                       wm8994->aif2clk_enable = 0;
-               }
+               val = snd_soc_read(codec, WM8994_AIF1_CONTROL_1);
+               if ((val & WM8994_AIF1ADCL_SRC) &&
+                   (val & WM8994_AIF1ADCR_SRC))
+                       adc = WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC2R_ENA;
+               else if (!(val & WM8994_AIF1ADCL_SRC) &&
+                        !(val & WM8994_AIF1ADCR_SRC))
+                       adc = WM8994_AIF1ADC1L_ENA | WM8994_AIF1ADC2L_ENA;
+               else
+                       adc = WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC2R_ENA |
+                               WM8994_AIF1ADC1L_ENA | WM8994_AIF1ADC2L_ENA;
+
+               val = snd_soc_read(codec, WM8994_AIF1_CONTROL_2);
+               if ((val & WM8994_AIF1DACL_SRC) &&
+                   (val & WM8994_AIF1DACR_SRC))
+                       dac = WM8994_AIF1DAC1R_ENA | WM8994_AIF1DAC2R_ENA;
+               else if (!(val & WM8994_AIF1DACL_SRC) &&
+                        !(val & WM8994_AIF1DACR_SRC))
+                       dac = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC2L_ENA;
+               else
+                       dac = WM8994_AIF1DAC1R_ENA | WM8994_AIF1DAC2R_ENA |
+                               WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC2L_ENA;
+
+               snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4,
+                                   mask, adc);
+               snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
+                                   mask, dac);
+               snd_soc_update_bits(codec, WM8994_CLOCKING_1,
+                                   WM8994_AIF1DSPCLK_ENA |
+                                   WM8994_SYSDSPCLK_ENA,
+                                   WM8994_AIF1DSPCLK_ENA |
+                                   WM8994_SYSDSPCLK_ENA);
+               snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, mask,
+                                   WM8994_AIF1ADC1R_ENA |
+                                   WM8994_AIF1ADC1L_ENA |
+                                   WM8994_AIF1ADC2R_ENA |
+                                   WM8994_AIF1ADC2L_ENA);
+               snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, mask,
+                                   WM8994_AIF1DAC1R_ENA |
+                                   WM8994_AIF1DAC1L_ENA |
+                                   WM8994_AIF1DAC2R_ENA |
+                                   WM8994_AIF1DAC2L_ENA);
                break;
-       }
 
-       /* We may also have postponed startup of DSP, handle that. */
-       wm8958_aif_ev(w, kcontrol, event);
+       case SND_SOC_DAPM_PRE_PMD:
+       case SND_SOC_DAPM_POST_PMD:
+               snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
+                                   mask, 0);
+               snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4,
+                                   mask, 0);
+
+               val = snd_soc_read(codec, WM8994_CLOCKING_1);
+               if (val & WM8994_AIF2DSPCLK_ENA)
+                       val = WM8994_SYSDSPCLK_ENA;
+               else
+                       val = 0;
+               snd_soc_update_bits(codec, WM8994_CLOCKING_1,
+                                   WM8994_SYSDSPCLK_ENA |
+                                   WM8994_AIF1DSPCLK_ENA, val);
+               break;
+       }
 
        return 0;
 }
 
-static int late_disable_ev(struct snd_soc_dapm_widget *w,
-                          struct snd_kcontrol *kcontrol, int event)
+static int aif2clk_ev(struct snd_soc_dapm_widget *w,
+                     struct snd_kcontrol *kcontrol, int event)
 {
        struct snd_soc_codec *codec = w->codec;
-       struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
+       int dac;
+       int adc;
+       int val;
 
        switch (event) {
+       case SND_SOC_DAPM_PRE_PMU:
+               val = snd_soc_read(codec, WM8994_AIF2_CONTROL_1);
+               if ((val & WM8994_AIF2ADCL_SRC) &&
+                   (val & WM8994_AIF2ADCR_SRC))
+                       adc = WM8994_AIF2ADCR_ENA;
+               else if (!(val & WM8994_AIF2ADCL_SRC) &&
+                        !(val & WM8994_AIF2ADCR_SRC))
+                       adc = WM8994_AIF2ADCL_ENA;
+               else
+                       adc = WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCR_ENA;
+
+
+               val = snd_soc_read(codec, WM8994_AIF2_CONTROL_2);
+               if ((val & WM8994_AIF2DACL_SRC) &&
+                   (val & WM8994_AIF2DACR_SRC))
+                       dac = WM8994_AIF2DACR_ENA;
+               else if (!(val & WM8994_AIF2DACL_SRC) &&
+                        !(val & WM8994_AIF2DACR_SRC))
+                       dac = WM8994_AIF2DACL_ENA;
+               else
+                       dac = WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA;
+
+               snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4,
+                                   WM8994_AIF2ADCL_ENA |
+                                   WM8994_AIF2ADCR_ENA, adc);
+               snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
+                                   WM8994_AIF2DACL_ENA |
+                                   WM8994_AIF2DACR_ENA, dac);
+               snd_soc_update_bits(codec, WM8994_CLOCKING_1,
+                                   WM8994_AIF2DSPCLK_ENA |
+                                   WM8994_SYSDSPCLK_ENA,
+                                   WM8994_AIF2DSPCLK_ENA |
+                                   WM8994_SYSDSPCLK_ENA);
+               snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4,
+                                   WM8994_AIF2ADCL_ENA |
+                                   WM8994_AIF2ADCR_ENA,
+                                   WM8994_AIF2ADCL_ENA |
+                                   WM8994_AIF2ADCR_ENA);
+               snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
+                                   WM8994_AIF2DACL_ENA |
+                                   WM8994_AIF2DACR_ENA,
+                                   WM8994_AIF2DACL_ENA |
+                                   WM8994_AIF2DACR_ENA);
+               break;
+
+       case SND_SOC_DAPM_PRE_PMD:
        case SND_SOC_DAPM_POST_PMD:
-               if (wm8994->aif1clk_disable) {
-                       snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
-                                           WM8994_AIF1CLK_ENA_MASK, 0);
-                       wm8994->aif1clk_disable = 0;
-               }
-               if (wm8994->aif2clk_disable) {
-                       snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1,
-                                           WM8994_AIF2CLK_ENA_MASK, 0);
-                       wm8994->aif2clk_disable = 0;
-               }
+               snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
+                                   WM8994_AIF2DACL_ENA |
+                                   WM8994_AIF2DACR_ENA, 0);
+               snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
+                                   WM8994_AIF2ADCL_ENA |
+                                   WM8994_AIF2ADCR_ENA, 0);
+
+               val = snd_soc_read(codec, WM8994_CLOCKING_1);
+               if (val & WM8994_AIF1DSPCLK_ENA)
+                       val = WM8994_SYSDSPCLK_ENA;
+               else
+                       val = 0;
+               snd_soc_update_bits(codec, WM8994_CLOCKING_1,
+                                   WM8994_SYSDSPCLK_ENA |
+                                   WM8994_AIF2DSPCLK_ENA, val);
                break;
        }
 
        return 0;
 }
 
-static int aif1clk_ev(struct snd_soc_dapm_widget *w,
-                     struct snd_kcontrol *kcontrol, int event)
+static int aif1clk_late_ev(struct snd_soc_dapm_widget *w,
+                          struct snd_kcontrol *kcontrol, int event)
 {
        struct snd_soc_codec *codec = w->codec;
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
@@ -1071,8 +1180,8 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
        return 0;
 }
 
-static int aif2clk_ev(struct snd_soc_dapm_widget *w,
-                     struct snd_kcontrol *kcontrol, int event)
+static int aif2clk_late_ev(struct snd_soc_dapm_widget *w,
+                          struct snd_kcontrol *kcontrol, int event)
 {
        struct snd_soc_codec *codec = w->codec;
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
@@ -1089,6 +1198,63 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
        return 0;
 }
 
+static int late_enable_ev(struct snd_soc_dapm_widget *w,
+                         struct snd_kcontrol *kcontrol, int event)
+{
+       struct snd_soc_codec *codec = w->codec;
+       struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
+
+       switch (event) {
+       case SND_SOC_DAPM_PRE_PMU:
+               if (wm8994->aif1clk_enable) {
+                       aif1clk_ev(w, kcontrol, event);
+                       snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
+                                           WM8994_AIF1CLK_ENA_MASK,
+                                           WM8994_AIF1CLK_ENA);
+                       wm8994->aif1clk_enable = 0;
+               }
+               if (wm8994->aif2clk_enable) {
+                       aif2clk_ev(w, kcontrol, event);
+                       snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1,
+                                           WM8994_AIF2CLK_ENA_MASK,
+                                           WM8994_AIF2CLK_ENA);
+                       wm8994->aif2clk_enable = 0;
+               }
+               break;
+       }
+
+       /* We may also have postponed startup of DSP, handle that. */
+       wm8958_aif_ev(w, kcontrol, event);
+
+       return 0;
+}
+
+static int late_disable_ev(struct snd_soc_dapm_widget *w,
+                          struct snd_kcontrol *kcontrol, int event)
+{
+       struct snd_soc_codec *codec = w->codec;
+       struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
+
+       switch (event) {
+       case SND_SOC_DAPM_POST_PMD:
+               if (wm8994->aif1clk_disable) {
+                       snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
+                                           WM8994_AIF1CLK_ENA_MASK, 0);
+                       aif1clk_ev(w, kcontrol, event);
+                       wm8994->aif1clk_disable = 0;
+               }
+               if (wm8994->aif2clk_disable) {
+                       snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1,
+                                           WM8994_AIF2CLK_ENA_MASK, 0);
+                       aif2clk_ev(w, kcontrol, event);
+                       wm8994->aif2clk_disable = 0;
+               }
+               break;
+       }
+
+       return 0;
+}
+
 static int adc_mux_ev(struct snd_soc_dapm_widget *w,
                      struct snd_kcontrol *kcontrol, int event)
 {
@@ -1385,9 +1551,9 @@ static const struct snd_kcontrol_new aif2dacr_src_mux =
        SOC_DAPM_ENUM("AIF2DACR Mux", aif2dacr_src_enum);
 
 static const struct snd_soc_dapm_widget wm8994_lateclk_revd_widgets[] = {
-SND_SOC_DAPM_SUPPLY("AIF1CLK", SND_SOC_NOPM, 0, 0, aif1clk_ev,
+SND_SOC_DAPM_SUPPLY("AIF1CLK", SND_SOC_NOPM, 0, 0, aif1clk_late_ev,
        SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-SND_SOC_DAPM_SUPPLY("AIF2CLK", SND_SOC_NOPM, 0, 0, aif2clk_ev,
+SND_SOC_DAPM_SUPPLY("AIF2CLK", SND_SOC_NOPM, 0, 0, aif2clk_late_ev,
        SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
 
 SND_SOC_DAPM_PGA_E("Late DAC1L Enable PGA", SND_SOC_NOPM, 0, 0, NULL, 0,
@@ -1416,8 +1582,10 @@ SND_SOC_DAPM_POST("Late Disable PGA", late_disable_ev)
 };
 
 static const struct snd_soc_dapm_widget wm8994_lateclk_widgets[] = {
-SND_SOC_DAPM_SUPPLY("AIF1CLK", WM8994_AIF1_CLOCKING_1, 0, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("AIF2CLK", WM8994_AIF2_CLOCKING_1, 0, 0, NULL, 0),
+SND_SOC_DAPM_SUPPLY("AIF1CLK", WM8994_AIF1_CLOCKING_1, 0, 0, aif1clk_ev,
+                   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
+SND_SOC_DAPM_SUPPLY("AIF2CLK", WM8994_AIF2_CLOCKING_1, 0, 0, aif2clk_ev,
+                   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
 SND_SOC_DAPM_PGA("Direct Voice", SND_SOC_NOPM, 0, 0, NULL, 0),
 SND_SOC_DAPM_MIXER("SPKL", WM8994_POWER_MANAGEMENT_3, 8, 0,
                   left_speaker_mixer, ARRAY_SIZE(left_speaker_mixer)),
@@ -1470,30 +1638,30 @@ SND_SOC_DAPM_SUPPLY("VMID", SND_SOC_NOPM, 0, 0, vmid_event,
 SND_SOC_DAPM_SUPPLY("CLK_SYS", SND_SOC_NOPM, 0, 0, clk_sys_event,
                    SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
 
-SND_SOC_DAPM_SUPPLY("DSP1CLK", WM8994_CLOCKING_1, 3, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("DSP2CLK", WM8994_CLOCKING_1, 2, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("DSPINTCLK", WM8994_CLOCKING_1, 1, 0, NULL, 0),
+SND_SOC_DAPM_SUPPLY("DSP1CLK", SND_SOC_NOPM, 3, 0, NULL, 0),
+SND_SOC_DAPM_SUPPLY("DSP2CLK", SND_SOC_NOPM, 2, 0, NULL, 0),
+SND_SOC_DAPM_SUPPLY("DSPINTCLK", SND_SOC_NOPM, 1, 0, NULL, 0),
 
 SND_SOC_DAPM_AIF_OUT("AIF1ADC1L", NULL,
-                    0, WM8994_POWER_MANAGEMENT_4, 9, 0),
+                    0, SND_SOC_NOPM, 9, 0),
 SND_SOC_DAPM_AIF_OUT("AIF1ADC1R", NULL,
-                    0, WM8994_POWER_MANAGEMENT_4, 8, 0),
+                    0, SND_SOC_NOPM, 8, 0),
 SND_SOC_DAPM_AIF_IN_E("AIF1DAC1L", NULL, 0,
-                     WM8994_POWER_MANAGEMENT_5, 9, 0, wm8958_aif_ev,
+                     SND_SOC_NOPM, 9, 0, wm8958_aif_ev,
                      SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
 SND_SOC_DAPM_AIF_IN_E("AIF1DAC1R", NULL, 0,
-                     WM8994_POWER_MANAGEMENT_5, 8, 0, wm8958_aif_ev,
+                     SND_SOC_NOPM, 8, 0, wm8958_aif_ev,
                      SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
 
 SND_SOC_DAPM_AIF_OUT("AIF1ADC2L", NULL,
-                    0, WM8994_POWER_MANAGEMENT_4, 11, 0),
+                    0, SND_SOC_NOPM, 11, 0),
 SND_SOC_DAPM_AIF_OUT("AIF1ADC2R", NULL,
-                    0, WM8994_POWER_MANAGEMENT_4, 10, 0),
+                    0, SND_SOC_NOPM, 10, 0),
 SND_SOC_DAPM_AIF_IN_E("AIF1DAC2L", NULL, 0,
-                     WM8994_POWER_MANAGEMENT_5, 11, 0, wm8958_aif_ev,
+                     SND_SOC_NOPM, 11, 0, wm8958_aif_ev,
                      SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
 SND_SOC_DAPM_AIF_IN_E("AIF1DAC2R", NULL, 0,
-                     WM8994_POWER_MANAGEMENT_5, 10, 0, wm8958_aif_ev,
+                     SND_SOC_NOPM, 10, 0, wm8958_aif_ev,
                      SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
 
 SND_SOC_DAPM_MIXER("AIF1ADC1L Mixer", SND_SOC_NOPM, 0, 0,
@@ -1520,14 +1688,14 @@ SND_SOC_DAPM_MIXER("DAC1R Mixer", SND_SOC_NOPM, 0, 0,
                   dac1r_mix, ARRAY_SIZE(dac1r_mix)),
 
 SND_SOC_DAPM_AIF_OUT("AIF2ADCL", NULL, 0,
-                    WM8994_POWER_MANAGEMENT_4, 13, 0),
+                    SND_SOC_NOPM, 13, 0),
 SND_SOC_DAPM_AIF_OUT("AIF2ADCR", NULL, 0,
-                    WM8994_POWER_MANAGEMENT_4, 12, 0),
+                    SND_SOC_NOPM, 12, 0),
 SND_SOC_DAPM_AIF_IN_E("AIF2DACL", NULL, 0,
-                     WM8994_POWER_MANAGEMENT_5, 13, 0, wm8958_aif_ev,
+                     SND_SOC_NOPM, 13, 0, wm8958_aif_ev,
                      SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
 SND_SOC_DAPM_AIF_IN_E("AIF2DACR", NULL, 0,
-                     WM8994_POWER_MANAGEMENT_5, 12, 0, wm8958_aif_ev,
+                     SND_SOC_NOPM, 12, 0, wm8958_aif_ev,
                      SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
 
 SND_SOC_DAPM_AIF_IN("AIF1DACDAT", NULL, 0, SND_SOC_NOPM, 0, 0),
index f13f2886339ca4dee110746da3bbe838d99976c1..6c028c4706016e1f56bb36114d6ee9108e597736 100644 (file)
@@ -1035,7 +1035,7 @@ void wm_hubs_set_bias_level(struct snd_soc_codec *codec,
                            enum snd_soc_bias_level level)
 {
        struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
-       int val;
+       int mask, val;
 
        switch (level) {
        case SND_SOC_BIAS_STANDBY:
@@ -1047,6 +1047,13 @@ void wm_hubs_set_bias_level(struct snd_soc_codec *codec,
        case SND_SOC_BIAS_ON:
                /* Turn off any unneded single ended outputs */
                val = 0;
+               mask = 0;
+
+               if (hubs->lineout1_se)
+                       mask |= WM8993_LINEOUT1N_ENA | WM8993_LINEOUT1P_ENA;
+
+               if (hubs->lineout2_se)
+                       mask |= WM8993_LINEOUT2N_ENA | WM8993_LINEOUT2P_ENA;
 
                if (hubs->lineout1_se && hubs->lineout1n_ena)
                        val |= WM8993_LINEOUT1N_ENA;
@@ -1061,11 +1068,7 @@ void wm_hubs_set_bias_level(struct snd_soc_codec *codec,
                        val |= WM8993_LINEOUT2P_ENA;
 
                snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_3,
-                                   WM8993_LINEOUT1N_ENA |
-                                   WM8993_LINEOUT1P_ENA |
-                                   WM8993_LINEOUT2N_ENA |
-                                   WM8993_LINEOUT2P_ENA,
-                                   val);
+                                   mask, val);
 
                /* Remove the input clamps */
                snd_soc_update_bits(codec, WM8993_INPUTS_CLAMP_REG,
index a59bd352d34231981a99998a27ce6ad611f584ec..5a649da9122a3e798713999a766885f0f732a5cd 100644 (file)
@@ -401,6 +401,10 @@ static int omap_pcm_new(struct snd_soc_pcm_runtime *rtd)
        }
 
 out:
+       /* free preallocated buffers in case of error */
+       if (ret)
+               omap_pcm_free_dma_buffers(pcm);
+
        return ret;
 }
 
index 72185078ddf8ef6f40a78105a6af09a4f33bf1b4..79fbeea99d46ddcd9b01ab4f0b67538369ce5c68 100644 (file)
@@ -166,7 +166,7 @@ static struct snd_soc_dai_driver s3c2412_i2s_dai = {
 
 static __devinit int s3c2412_iis_dev_probe(struct platform_device *pdev)
 {
-       return snd_soc_register_dai(&pdev->dev, &s3c2412_i2s_dai);
+       return s3c_i2sv2_register_dai(&pdev->dev, -1, &s3c2412_i2s_dai);
 }
 
 static __devexit int s3c2412_iis_dev_remove(struct platform_device *pdev)
index 378cc5b056d72f6c9ed5d28481869e3a608df871..74ed2dffbffda4313401793b72bde4b6b2224eeb 100644 (file)
@@ -1001,11 +1001,10 @@ static void fsi_dma_do_tasklet(unsigned long data)
        sg_dma_address(&sg) = buf;
        sg_dma_len(&sg) = len;
 
-       desc = chan->device->device_prep_slave_sg(chan, &sg, 1, dir,
-                                                 DMA_PREP_INTERRUPT |
-                                                 DMA_CTRL_ACK);
+       desc = dmaengine_prep_slave_sg(chan, &sg, 1, dir,
+                                      DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
        if (!desc) {
-               dev_err(dai->dev, "device_prep_slave_sg() fail\n");
+               dev_err(dai->dev, "dmaengine_prep_slave_sg() fail\n");
                return;
        }
 
index accdcb7d4d9dafbf5397cc33bc199fa2c86bbb03..c88d9741b9e7942e60ba17e3d98231136b607dc9 100644 (file)
@@ -3113,6 +3113,7 @@ int snd_soc_register_card(struct snd_soc_card *card)
                                 GFP_KERNEL);
        if (card->rtd == NULL)
                return -ENOMEM;
+       card->num_rtd = 0;
        card->rtd_aux = &card->rtd[card->num_links];
 
        for (i = 0; i < card->num_links; i++)
@@ -3624,10 +3625,10 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
        int i, ret;
 
        num_routes = of_property_count_strings(np, propname);
-       if (num_routes & 1) {
+       if (num_routes < 0 || num_routes & 1) {
                dev_err(card->dev,
-                       "Property '%s's length is not even\n",
-                       propname);
+                    "Property '%s' does not exist or its length is not even\n",
+                    propname);
                return -EINVAL;
        }
        num_routes /= 2;
index 5cbd2d7623b8cbf611db0e123ef4d8a01e6f88b0..1bb6d4a63cd8630854ae2b82f47a70057cdd753a 100644 (file)
@@ -67,6 +67,7 @@ static int dapm_up_seq[] = {
        [snd_soc_dapm_out_drv] = 10,
        [snd_soc_dapm_hp] = 10,
        [snd_soc_dapm_spk] = 10,
+       [snd_soc_dapm_line] = 10,
        [snd_soc_dapm_post] = 11,
 };
 
@@ -75,6 +76,7 @@ static int dapm_down_seq[] = {
        [snd_soc_dapm_adc] = 1,
        [snd_soc_dapm_hp] = 2,
        [snd_soc_dapm_spk] = 2,
+       [snd_soc_dapm_line] = 2,
        [snd_soc_dapm_out_drv] = 2,
        [snd_soc_dapm_pga] = 4,
        [snd_soc_dapm_mixer_named_ctl] = 5,
index 03059e75665a267b39baa45b5f7e107557b96542..9bf3fc759344031d05cb915c97d770cddef5a756 100644 (file)
@@ -234,8 +234,8 @@ endif
 
 export PERL_PATH
 
-FLEX = $(CROSS_COMPILE)flex
-BISON= $(CROSS_COMPILE)bison
+FLEX = flex
+BISON= bison
 
 $(OUTPUT)util/parse-events-flex.c: util/parse-events.l
        $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c
index 2e317438980b4767bbca4fdc3512cbd55d4ad1d2..cdae9b2db1cc0ed270e536e6c3b368a353cd780a 100644 (file)
@@ -374,16 +374,23 @@ static int __cmd_report(struct perf_report *rep)
            (kernel_map->dso->hit &&
             (kernel_kmap->ref_reloc_sym == NULL ||
              kernel_kmap->ref_reloc_sym->addr == 0))) {
-               const struct dso *kdso = kernel_map->dso;
+               const char *desc =
+                   "As no suitable kallsyms nor vmlinux was found, kernel samples\n"
+                   "can't be resolved.";
+
+               if (kernel_map) {
+                       const struct dso *kdso = kernel_map->dso;
+                       if (!RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION])) {
+                               desc = "If some relocation was applied (e.g. "
+                                      "kexec) symbols may be misresolved.";
+                       }
+               }
 
                ui__warning(
 "Kernel address maps (/proc/{kallsyms,modules}) were restricted.\n\n"
 "Check /proc/sys/kernel/kptr_restrict before running 'perf record'.\n\n%s\n\n"
 "Samples in kernel modules can't be resolved as well.\n\n",
-                           RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION]) ?
-"As no suitable kallsyms nor vmlinux was found, kernel samples\n"
-"can't be resolved." :
-"If some relocation was applied (e.g. kexec) symbols may be misresolved.");
+               desc);
        }
 
        if (dump_trace) {
index 1c5b9801ac6115547039599ff1424048efefd0e7..223ffdcc0fd8a730079f09205c45ecb4fbf5d341 100644 (file)
@@ -851,6 +851,28 @@ static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist)
        return test__checkevent_symbolic_name(evlist);
 }
 
+static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist)
+{
+       struct perf_evsel *evsel = list_entry(evlist->entries.next,
+                                             struct perf_evsel, node);
+
+       TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
+       TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
+
+       return test__checkevent_symbolic_name(evlist);
+}
+
+static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist)
+{
+       struct perf_evsel *evsel = list_entry(evlist->entries.next,
+                                             struct perf_evsel, node);
+
+       TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
+       TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
+
+       return test__checkevent_symbolic_name(evlist);
+}
+
 static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist)
 {
        struct perf_evsel *evsel = list_entry(evlist->entries.next,
@@ -1091,6 +1113,14 @@ static struct test__event_st {
                .name  = "r1,syscalls:sys_enter_open:k,1:1:hp",
                .check = test__checkevent_list,
        },
+       {
+               .name  = "instructions:G",
+               .check = test__checkevent_exclude_host_modifier,
+       },
+       {
+               .name  = "instructions:H",
+               .check = test__checkevent_exclude_guest_modifier,
+       },
 };
 
 #define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st))
index 05d766e3ecb571732e7ce873e24c22bac391845c..1fcf1bbc5458e4a8d626f671a6455348a2225f1f 100644 (file)
@@ -54,7 +54,7 @@ num_dec               [0-9]+
 num_hex                0x[a-fA-F0-9]+
 num_raw_hex    [a-fA-F0-9]+
 name           [a-zA-Z_*?][a-zA-Z0-9_*?]*
-modifier_event [ukhp]{1,5}
+modifier_event [ukhpGH]{1,8}
 modifier_bp    [rwx]
 
 %%
index c0a028c3ebaf35905e99e69f4cef76e5e343f44f..ab9867b2b433c97dd5bbd63f4079acdc2fceeaba 100644 (file)
@@ -977,8 +977,9 @@ static Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
  * And always look at the original dso, not at debuginfo packages, that
  * have the PLT data stripped out (shdr_rel_plt.sh_type == SHT_NOBITS).
  */
-static int dso__synthesize_plt_symbols(struct  dso *dso, struct map *map,
-                                      symbol_filter_t filter)
+static int
+dso__synthesize_plt_symbols(struct dso *dso, char *name, struct map *map,
+                           symbol_filter_t filter)
 {
        uint32_t nr_rel_entries, idx;
        GElf_Sym sym;
@@ -993,10 +994,7 @@ static int dso__synthesize_plt_symbols(struct  dso *dso, struct map *map,
        char sympltname[1024];
        Elf *elf;
        int nr = 0, symidx, fd, err = 0;
-       char name[PATH_MAX];
 
-       snprintf(name, sizeof(name), "%s%s",
-                symbol_conf.symfs, dso->long_name);
        fd = open(name, O_RDONLY);
        if (fd < 0)
                goto out;
@@ -1703,8 +1701,9 @@ restart:
                        continue;
 
                if (ret > 0) {
-                       int nr_plt = dso__synthesize_plt_symbols(dso, map,
-                                                                filter);
+                       int nr_plt;
+
+                       nr_plt = dso__synthesize_plt_symbols(dso, name, map, filter);
                        if (nr_plt > 0)
                                ret += nr_plt;
                        break;
index 95d6a6f7c33aa7971c50f9b107f0c8474a16d70a..4915408f6a98c0c6d970a7ef341da7733fa8e6bc 100755 (executable)
@@ -183,6 +183,9 @@ my %force_config;
 # do not force reboots on config problems
 my $no_reboot = 1;
 
+# reboot on success
+my $reboot_success = 0;
+
 my %option_map = (
     "MACHINE"                  => \$machine,
     "SSH_USER"                 => \$ssh_user,
@@ -2192,7 +2195,7 @@ sub run_bisect {
     }
 
     # Are we looking for where it worked, not failed?
-    if ($reverse_bisect) {
+    if ($reverse_bisect && $ret >= 0) {
        $ret = !$ret;
     }
 
@@ -3469,6 +3472,7 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
 
     # Do not reboot on failing test options
     $no_reboot = 1;
+    $reboot_success = 0;
 
     $iteration = $i;
 
@@ -3554,9 +3558,11 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
            die "failed to checkout $checkout";
     }
 
+    $no_reboot = 0;
+
     # A test may opt to not reboot the box
     if ($reboot_on_success) {
-       $no_reboot = 0;
+       $reboot_success = 1;
     }
 
     if ($test_type eq "bisect") {
@@ -3600,7 +3606,7 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
 
 if ($opt{"POWEROFF_ON_SUCCESS"}) {
     halt;
-} elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot) {
+} elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot && $reboot_success) {
     reboot_to_good;
 } elsif (defined($switch_to_good)) {
     # still need to get to the good kernel
This page took 0.799014 seconds and 5 git commands to generate.