aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/stable/sysfs-bus-firewire11
-rw-r--r--Documentation/ABI/testing/sysfs-devices-edac140
-rw-r--r--Documentation/ABI/testing/sysfs-platform-asus-wmi7
-rw-r--r--Documentation/DMA-attributes.txt42
-rw-r--r--Documentation/device-mapper/striped.txt7
-rw-r--r--Documentation/device-mapper/thin-provisioning.txt24
-rw-r--r--Documentation/devicetree/bindings/arm/calxeda/l2ecc.txt15
-rw-r--r--Documentation/devicetree/bindings/arm/calxeda/mem-ctrlr.txt14
-rw-r--r--Documentation/devicetree/bindings/ata/cavium-compact-flash.txt30
-rw-r--r--Documentation/devicetree/bindings/gpio/cavium-octeon-gpio.txt49
-rw-r--r--Documentation/devicetree/bindings/i2c/cavium-i2c.txt34
-rw-r--r--Documentation/devicetree/bindings/mfd/ab8500.txt123
-rw-r--r--Documentation/devicetree/bindings/mfd/max77686.txt59
-rw-r--r--Documentation/devicetree/bindings/mfd/tps65910.txt2
-rw-r--r--Documentation/devicetree/bindings/mfd/twl6040.txt2
-rw-r--r--Documentation/devicetree/bindings/mips/cavium/bootbus.txt126
-rw-r--r--Documentation/devicetree/bindings/mips/cavium/ciu.txt26
-rw-r--r--Documentation/devicetree/bindings/mips/cavium/ciu2.txt27
-rw-r--r--Documentation/devicetree/bindings/mips/cavium/dma-engine.txt21
-rw-r--r--Documentation/devicetree/bindings/mips/cavium/uctl.txt46
-rw-r--r--Documentation/devicetree/bindings/net/cavium-mdio.txt27
-rw-r--r--Documentation/devicetree/bindings/net/cavium-mix.txt39
-rw-r--r--Documentation/devicetree/bindings/net/cavium-pip.txt98
-rw-r--r--Documentation/devicetree/bindings/pwm/lpc32xx-pwm.txt12
-rw-r--r--Documentation/devicetree/bindings/pwm/mxs-pwm.txt17
-rw-r--r--Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt18
-rw-r--r--Documentation/devicetree/bindings/pwm/pwm.txt57
-rw-r--r--Documentation/devicetree/bindings/serial/cavium-uart.txt19
-rw-r--r--Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt28
-rw-r--r--Documentation/dontdiff1
-rw-r--r--Documentation/edac.txt112
-rw-r--r--Documentation/input/edt-ft5x06.txt54
-rw-r--r--Documentation/kernel-parameters.txt2
-rw-r--r--Documentation/pwm.txt76
-rw-r--r--MAINTAINERS22
-rw-r--r--Makefile24
-rw-r--r--arch/arm/Kconfig1
-rw-r--r--arch/arm/boot/dts/highbank.dts12
-rw-r--r--arch/arm/boot/dts/r8a7740.dtsi21
-rw-r--r--arch/arm/boot/dts/sh7377.dtsi21
-rw-r--r--arch/arm/boot/dts/tegra20.dtsi6
-rw-r--r--arch/arm/boot/dts/tegra30.dtsi6
-rw-r--r--arch/arm/common/dmabounce.c1
-rw-r--r--arch/arm/configs/armadillo800eva_defconfig25
-rw-r--r--arch/arm/configs/kzm9d_defconfig89
-rw-r--r--arch/arm/configs/kzm9g_defconfig8
-rw-r--r--arch/arm/configs/tegra_defconfig1
-rw-r--r--arch/arm/include/asm/dma-mapping.h24
-rw-r--r--arch/arm/mach-exynos/clock-exynos4.c41
-rw-r--r--arch/arm/mach-exynos/clock-exynos4.h3
-rw-r--r--arch/arm/mach-exynos/clock-exynos4210.c37
-rw-r--r--arch/arm/mach-exynos/clock-exynos4212.c41
-rw-r--r--arch/arm/mach-exynos/mach-nuri.c4
-rw-r--r--arch/arm/mach-exynos/mach-origen.c1
-rw-r--r--arch/arm/mach-pxa/eseries.h14
-rw-r--r--arch/arm/mach-pxa/hx4700.c56
-rw-r--r--arch/arm/mach-s3c64xx/include/mach/pm-core.h4
-rw-r--r--arch/arm/mach-shmobile/Kconfig13
-rw-r--r--arch/arm/mach-shmobile/Makefile2
-rw-r--r--arch/arm/mach-shmobile/board-ag5evm.c82
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c62
-rw-r--r--arch/arm/mach-shmobile/board-armadillo800eva.c455
-rw-r--r--arch/arm/mach-shmobile/board-bonito.c10
-rw-r--r--arch/arm/mach-shmobile/board-g4evm.c52
-rw-r--r--arch/arm/mach-shmobile/board-kota2.c30
-rw-r--r--arch/arm/mach-shmobile/board-kzm9d.c10
-rw-r--r--arch/arm/mach-shmobile/board-kzm9g.c320
-rw-r--r--arch/arm/mach-shmobile/board-mackerel.c83
-rw-r--r--arch/arm/mach-shmobile/board-marzen.c10
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7740.c150
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7779.c2
-rw-r--r--arch/arm/mach-shmobile/clock-sh7367.c2
-rw-r--r--arch/arm/mach-shmobile/clock-sh7372.c2
-rw-r--r--arch/arm/mach-shmobile/clock-sh7377.c2
-rw-r--r--arch/arm/mach-shmobile/clock-sh73a0.c12
-rw-r--r--arch/arm/mach-shmobile/include/mach/common.h1
-rw-r--r--arch/arm/mach-shmobile/include/mach/dma-register.h84
-rw-r--r--arch/arm/mach-shmobile/include/mach/gpio.h32
-rw-r--r--arch/arm/mach-shmobile/include/mach/pm-rmobile.h44
-rw-r--r--arch/arm/mach-shmobile/include/mach/r8a7740.h33
-rw-r--r--arch/arm/mach-shmobile/include/mach/sh7372.h45
-rw-r--r--arch/arm/mach-shmobile/include/mach/sh73a0.h7
-rw-r--r--arch/arm/mach-shmobile/intc-r8a7740.c13
-rw-r--r--arch/arm/mach-shmobile/pfc-r8a7740.c24
-rw-r--r--arch/arm/mach-shmobile/pm-r8a7740.c54
-rw-r--r--arch/arm/mach-shmobile/pm-rmobile.c167
-rw-r--r--arch/arm/mach-shmobile/pm-sh7372.c297
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7740.c360
-rw-r--r--arch/arm/mach-shmobile/setup-sh7372.c209
-rw-r--r--arch/arm/mach-shmobile/setup-sh7377.c47
-rw-r--r--arch/arm/mach-shmobile/setup-sh73a0.c152
-rw-r--r--arch/arm/mach-tegra/board-dt-tegra20.c3
-rw-r--r--arch/arm/mach-tegra/board-dt-tegra30.c3
-rw-r--r--arch/arm/mach-ux500/board-mop500.c30
-rw-r--r--arch/arm/mach-ux500/cpu-db8500.c7
-rw-r--r--arch/arm/mach-ux500/include/mach/setup.h3
-rw-r--r--arch/arm/mach-vt8500/Makefile2
-rw-r--r--arch/arm/mach-vt8500/pwm.c265
-rw-r--r--arch/arm/mm/dma-mapping.c561
-rw-r--r--arch/arm/mm/mm.h3
-rw-r--r--arch/arm/plat-mxc/Kconfig6
-rw-r--r--arch/arm/plat-mxc/Makefile1
-rw-r--r--arch/arm/plat-pxa/Makefile1
-rw-r--r--arch/arm/plat-pxa/pwm.c304
-rw-r--r--arch/arm/plat-samsung/Makefile4
-rw-r--r--arch/blackfin/Kconfig10
-rw-r--r--arch/blackfin/kernel/Makefile1
-rw-r--r--arch/blackfin/kernel/pwm.c100
-rw-r--r--arch/frv/include/asm/cpumask.h6
-rw-r--r--arch/hexagon/include/asm/Kbuild2
-rw-r--r--arch/ia64/Kconfig3
-rw-r--r--arch/ia64/include/asm/atomic.h4
-rw-r--r--arch/ia64/include/asm/machvec.h2
-rw-r--r--arch/ia64/include/asm/machvec_dig.h2
-rw-r--r--arch/ia64/include/asm/machvec_dig_vtd.h2
-rw-r--r--arch/ia64/include/asm/machvec_hpsim.h2
-rw-r--r--arch/ia64/include/asm/machvec_hpzx1.h2
-rw-r--r--arch/ia64/include/asm/machvec_hpzx1_swiotlb.h2
-rw-r--r--arch/ia64/include/asm/machvec_sn2.h2
-rw-r--r--arch/ia64/include/asm/machvec_uv.h2
-rw-r--r--arch/ia64/include/asm/machvec_xen.h2
-rw-r--r--arch/ia64/include/asm/processor.h2
-rw-r--r--arch/ia64/kvm/Kconfig1
-rw-r--r--arch/ia64/pci/fixup.c4
-rw-r--r--arch/mips/Kbuild.platforms1
-rw-r--r--arch/mips/Kconfig38
-rw-r--r--arch/mips/alchemy/board-mtx1.c4
-rw-r--r--arch/mips/alchemy/common/platform.c10
-rw-r--r--arch/mips/alchemy/devboards/Makefile2
-rw-r--r--arch/mips/alchemy/devboards/bcsr.c5
-rw-r--r--arch/mips/alchemy/devboards/pb1100.c4
-rw-r--r--arch/mips/alchemy/devboards/pb1500.c4
-rw-r--r--arch/mips/alchemy/devboards/platform.c30
-rw-r--r--arch/mips/alchemy/devboards/prom.c69
-rw-r--r--arch/mips/bcm63xx/Kconfig4
-rw-r--r--arch/mips/bcm63xx/Makefile3
-rw-r--r--arch/mips/bcm63xx/boards/board_bcm963xx.c107
-rw-r--r--arch/mips/bcm63xx/clk.c26
-rw-r--r--arch/mips/bcm63xx/cpu.c63
-rw-r--r--arch/mips/bcm63xx/dev-dsp.c2
-rw-r--r--arch/mips/bcm63xx/dev-flash.c123
-rw-r--r--arch/mips/bcm63xx/dev-rng.c40
-rw-r--r--arch/mips/bcm63xx/dev-spi.c119
-rw-r--r--arch/mips/bcm63xx/dev-wdt.c2
-rw-r--r--arch/mips/bcm63xx/irq.c21
-rw-r--r--arch/mips/bcm63xx/prom.c4
-rw-r--r--arch/mips/bcm63xx/setup.c13
-rw-r--r--arch/mips/boot/compressed/Makefile4
-rw-r--r--arch/mips/boot/compressed/uart-16550.c5
-rw-r--r--arch/mips/cavium-octeon/.gitignore2
-rw-r--r--arch/mips/cavium-octeon/Makefile16
-rw-r--r--arch/mips/cavium-octeon/executive/cvmx-fpa.c183
-rw-r--r--arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c243
-rw-r--r--arch/mips/cavium-octeon/octeon-irq.c399
-rw-r--r--arch/mips/cavium-octeon/octeon-memcpy.S16
-rw-r--r--arch/mips/cavium-octeon/octeon-platform.c699
-rw-r--r--arch/mips/cavium-octeon/octeon_3xxx.dts571
-rw-r--r--arch/mips/cavium-octeon/octeon_68xx.dts625
-rw-r--r--arch/mips/cavium-octeon/serial.c134
-rw-r--r--arch/mips/cavium-octeon/setup.c45
-rw-r--r--arch/mips/configs/ls1b_defconfig109
-rw-r--r--arch/mips/configs/nlm_xlr_defconfig4
-rw-r--r--arch/mips/dec/prom/memory.c2
-rw-r--r--arch/mips/include/asm/cpu.h3
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h150
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h12
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h89
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h2
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h8
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h286
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/ioremap.h1
-rw-r--r--arch/mips/include/asm/mach-cavium-octeon/irq.h45
-rw-r--r--arch/mips/include/asm/mach-jz4740/jz4740_nand.h4
-rw-r--r--arch/mips/include/asm/mach-loongson/loongson.h3
-rw-r--r--arch/mips/include/asm/mach-loongson1/irq.h73
-rw-r--r--arch/mips/include/asm/mach-loongson1/loongson1.h44
-rw-r--r--arch/mips/include/asm/mach-loongson1/platform.h23
-rw-r--r--arch/mips/include/asm/mach-loongson1/prom.h24
-rw-r--r--arch/mips/include/asm/mach-loongson1/regs-clk.h33
-rw-r--r--arch/mips/include/asm/mach-loongson1/regs-wdt.h22
-rw-r--r--arch/mips/include/asm/mach-loongson1/war.h25
-rw-r--r--arch/mips/include/asm/mach-netlogic/cpu-feature-overrides.h1
-rw-r--r--arch/mips/include/asm/mach-tx49xx/mangle-port.h2
-rw-r--r--arch/mips/include/asm/mipsmtregs.h13
-rw-r--r--arch/mips/include/asm/module.h2
-rw-r--r--arch/mips/include/asm/netlogic/xlp-hal/cpucontrol.h4
-rw-r--r--arch/mips/include/asm/netlogic/xlp-hal/iomap.h5
-rw-r--r--arch/mips/include/asm/netlogic/xlp-hal/pcibus.h76
-rw-r--r--arch/mips/include/asm/netlogic/xlp-hal/pic.h4
-rw-r--r--arch/mips/include/asm/netlogic/xlp-hal/usb.h64
-rw-r--r--arch/mips/include/asm/netlogic/xlp-hal/xlp.h17
-rw-r--r--arch/mips/include/asm/netlogic/xlr/bridge.h104
-rw-r--r--arch/mips/include/asm/netlogic/xlr/flash.h55
-rw-r--r--arch/mips/include/asm/netlogic/xlr/gpio.h59
-rw-r--r--arch/mips/include/asm/octeon/cvmx-helper-fpa.h64
-rw-r--r--arch/mips/include/asm/octeon/cvmx-helper.h2
-rw-r--r--arch/mips/include/asm/octeon/octeon.h5
-rw-r--r--arch/mips/include/asm/prom.h3
-rw-r--r--arch/mips/include/asm/smtc.h6
-rw-r--r--arch/mips/include/asm/uaccess.h6
-rw-r--r--arch/mips/include/asm/uasm.h100
-rw-r--r--arch/mips/jz4740/board-qi_lb60.c1
-rw-r--r--arch/mips/jz4740/platform.c20
-rw-r--r--arch/mips/jz4740/reset.c49
-rw-r--r--arch/mips/kernel/cpu-probe.c299
-rw-r--r--arch/mips/kernel/perf_event_mipsxx.c5
-rw-r--r--arch/mips/kernel/prom.c29
-rw-r--r--arch/mips/kernel/smp.c4
-rw-r--r--arch/mips/kernel/smtc.c76
-rw-r--r--arch/mips/kernel/traps.c1
-rw-r--r--arch/mips/lib/Makefile2
-rw-r--r--arch/mips/lib/memcpy-inatomic.S451
-rw-r--r--arch/mips/lib/memcpy.S11
-rw-r--r--arch/mips/loongson1/Kconfig21
-rw-r--r--arch/mips/loongson1/Makefile11
-rw-r--r--arch/mips/loongson1/Platform7
-rw-r--r--arch/mips/loongson1/common/Makefile5
-rw-r--r--arch/mips/loongson1/common/clock.c165
-rw-r--r--arch/mips/loongson1/common/irq.c147
-rw-r--r--arch/mips/loongson1/common/platform.c124
-rw-r--r--arch/mips/loongson1/common/prom.c87
-rw-r--r--arch/mips/loongson1/common/reset.c45
-rw-r--r--arch/mips/loongson1/common/setup.c29
-rw-r--r--arch/mips/loongson1/ls1b/Makefile5
-rw-r--r--arch/mips/loongson1/ls1b/board.c33
-rw-r--r--arch/mips/mm/uasm.c62
-rw-r--r--arch/mips/netlogic/common/earlycons.c2
-rw-r--r--arch/mips/netlogic/common/smpboot.S157
-rw-r--r--arch/mips/netlogic/xlp/Makefile2
-rw-r--r--arch/mips/netlogic/xlp/nlm_hal.c52
-rw-r--r--arch/mips/netlogic/xlp/of.c34
-rw-r--r--arch/mips/netlogic/xlp/platform.c2
-rw-r--r--arch/mips/netlogic/xlp/setup.c16
-rw-r--r--arch/mips/netlogic/xlp/usb-init.c124
-rw-r--r--arch/mips/netlogic/xlr/Makefile2
-rw-r--r--arch/mips/netlogic/xlr/platform-flash.c220
-rw-r--r--arch/mips/netlogic/xlr/platform.c140
-rw-r--r--arch/mips/netlogic/xlr/setup.c2
-rw-r--r--arch/mips/oprofile/common.c1
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c10
-rw-r--r--arch/mips/pci/Makefile1
-rw-r--r--arch/mips/pci/fixup-cobalt.c8
-rw-r--r--arch/mips/pci/fixup-malta.c14
-rw-r--r--arch/mips/pci/fixup-rc32434.c2
-rw-r--r--arch/mips/pci/ops-bcm63xx.c63
-rw-r--r--arch/mips/pci/pci-bcm63xx.c133
-rw-r--r--arch/mips/pci/pci-bcm63xx.h5
-rw-r--r--arch/mips/pci/pci-xlp.c248
-rw-r--r--arch/mips/pci/pci-xlr.c4
-rw-r--r--arch/mips/pnx833x/stb22x/board.c4
-rw-r--r--arch/mips/txx9/generic/pci.c6
-rw-r--r--arch/mips/txx9/generic/setup.c12
-rw-r--r--arch/mips/txx9/generic/setup_tx4939.c2
-rw-r--r--arch/mips/txx9/rbtx4939/setup.c11
-rw-r--r--arch/mn10300/include/asm/ipc.h1
-rw-r--r--arch/openrisc/include/asm/Kbuild2
-rw-r--r--arch/powerpc/include/asm/dma-mapping.h8
-rw-r--r--arch/powerpc/kernel/dma-iommu.c1
-rw-r--r--arch/powerpc/kernel/dma-swiotlb.c1
-rw-r--r--arch/powerpc/kernel/dma.c36
-rw-r--r--arch/powerpc/kernel/vio.c1
-rw-r--r--arch/tile/include/asm/Kbuild1
-rw-r--r--arch/xtensa/include/asm/cpumask.h16
-rw-r--r--arch/xtensa/include/asm/rmap.h16
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/acpi/video_detect.c60
-rw-r--r--drivers/base/dma-mapping.c49
-rw-r--r--drivers/block/virtio_blk.c115
-rw-r--r--drivers/char/hw_random/Kconfig14
-rw-r--r--drivers/char/hw_random/Makefile1
-rw-r--r--drivers/char/hw_random/bcm63xx-rng.c175
-rw-r--r--drivers/char/hw_random/virtio-rng.c37
-rw-r--r--drivers/char/mspec.c2
-rw-r--r--drivers/cpufreq/exynos5250-cpufreq.c55
-rw-r--r--drivers/edac/Kconfig24
-rw-r--r--drivers/edac/Makefile3
-rw-r--r--drivers/edac/amd64_edac.c376
-rw-r--r--drivers/edac/amd64_edac.h29
-rw-r--r--drivers/edac/amd64_edac_dbg.c89
-rw-r--r--drivers/edac/amd64_edac_inj.c134
-rw-r--r--drivers/edac/amd76x_edac.c34
-rw-r--r--drivers/edac/cell_edac.c28
-rw-r--r--drivers/edac/cpc925_edac.c96
-rw-r--r--drivers/edac/e752x_edac.c92
-rw-r--r--drivers/edac/e7xxx_edac.c89
-rw-r--r--drivers/edac/edac_core.h39
-rw-r--r--drivers/edac/edac_device.c47
-rw-r--r--drivers/edac/edac_device_sysfs.c71
-rw-r--r--drivers/edac/edac_mc.c395
-rw-r--r--drivers/edac/edac_mc_sysfs.c1355
-rw-r--r--drivers/edac/edac_module.c20
-rw-r--r--drivers/edac/edac_module.h26
-rw-r--r--drivers/edac/edac_pci.c26
-rw-r--r--drivers/edac/edac_pci_sysfs.c49
-rw-r--r--drivers/edac/highbank_l2_edac.c149
-rw-r--r--drivers/edac/highbank_mc_edac.c264
-rw-r--r--drivers/edac/i3000_edac.c47
-rw-r--r--drivers/edac/i3200_edac.c48
-rw-r--r--drivers/edac/i5000_edac.c207
-rw-r--r--drivers/edac/i5100_edac.c14
-rw-r--r--drivers/edac/i5400_edac.c201
-rw-r--r--drivers/edac/i7300_edac.c173
-rw-r--r--drivers/edac/i7core_edac.c520
-rw-r--r--drivers/edac/i82443bxgx_edac.c51
-rw-r--r--drivers/edac/i82860_edac.c45
-rw-r--r--drivers/edac/i82875p_edac.c53
-rw-r--r--drivers/edac/i82975x_edac.c55
-rw-r--r--drivers/edac/mpc85xx_edac.c131
-rw-r--r--drivers/edac/mv64x60_edac.c40
-rw-r--r--drivers/edac/pasemi_edac.c22
-rw-r--r--drivers/edac/ppc4xx_edac.c16
-rw-r--r--drivers/edac/r82600_edac.c48
-rw-r--r--drivers/edac/sb_edac.c257
-rw-r--r--drivers/edac/tile_edac.c12
-rw-r--r--drivers/edac/x38_edac.c48
-rw-r--r--drivers/extcon/Kconfig2
-rw-r--r--drivers/extcon/extcon-max8997.c29
-rw-r--r--drivers/firewire/core-device.c9
-rw-r--r--drivers/firewire/core-iso.c2
-rw-r--r--drivers/firewire/core-transaction.c23
-rw-r--r--drivers/firewire/ohci.c30
-rw-r--r--drivers/gpio/Kconfig7
-rw-r--r--drivers/gpio/Makefile1
-rw-r--r--drivers/gpio/gpio-tps6586x.c158
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_connector.c3
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_core.c5
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_crtc.c294
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_crtc.h31
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dmabuf.c33
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c9
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.h4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_encoder.c123
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_encoder.h12
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c40
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_gem.c49
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_gem.h3
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_plane.c246
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_plane.h12
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_vidi.c53
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c36
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c48
-rw-r--r--drivers/hwmon/acpi_power_meter.c4
-rw-r--r--drivers/hwmon/applesmc.c70
-rw-r--r--drivers/hwmon/coretemp.c2
-rw-r--r--drivers/hwmon/jc42.c26
-rw-r--r--drivers/hwmon/via-cputemp.c2
-rw-r--r--drivers/i2c/busses/i2c-octeon.c92
-rw-r--r--drivers/input/misc/88pm80x_onkey.c168
-rw-r--r--drivers/input/misc/Kconfig10
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/ab8500-ponkey.c4
-rw-r--r--drivers/input/mouse/synaptics.c22
-rw-r--r--drivers/input/tablet/wacom_wac.c21
-rw-r--r--drivers/input/tablet/wacom_wac.h3
-rw-r--r--drivers/input/touchscreen/Kconfig13
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/edt-ft5x06.c898
-rw-r--r--drivers/md/Kconfig9
-rw-r--r--drivers/md/dm-crypt.c219
-rw-r--r--drivers/md/dm-delay.c2
-rw-r--r--drivers/md/dm-exception-store.c13
-rw-r--r--drivers/md/dm-flakey.c2
-rw-r--r--drivers/md/dm-ioctl.c5
-rw-r--r--drivers/md/dm-linear.c2
-rw-r--r--drivers/md/dm-mpath.c49
-rw-r--r--drivers/md/dm-raid.c56
-rw-r--r--drivers/md/dm-raid1.c10
-rw-r--r--drivers/md/dm-snap.c34
-rw-r--r--drivers/md/dm-stripe.c87
-rw-r--r--drivers/md/dm-table.c3
-rw-r--r--drivers/md/dm-thin-metadata.c769
-rw-r--r--drivers/md/dm-thin-metadata.h25
-rw-r--r--drivers/md/dm-thin.c542
-rw-r--r--drivers/md/dm-verity.c2
-rw-r--r--drivers/md/dm.c40
-rw-r--r--drivers/md/dm.h5
-rw-r--r--drivers/md/persistent-data/Makefile1
-rw-r--r--drivers/md/persistent-data/dm-block-manager.c105
-rw-r--r--drivers/md/persistent-data/dm-block-manager.h21
-rw-r--r--drivers/md/persistent-data/dm-space-map-checker.c446
-rw-r--r--drivers/md/persistent-data/dm-space-map-checker.h26
-rw-r--r--drivers/md/persistent-data/dm-space-map-common.c12
-rw-r--r--drivers/md/persistent-data/dm-space-map-common.h1
-rw-r--r--drivers/md/persistent-data/dm-space-map-disk.c34
-rw-r--r--drivers/md/persistent-data/dm-transaction-manager.c91
-rw-r--r--drivers/md/persistent-data/dm-transaction-manager.h11
-rw-r--r--drivers/mfd/88pm800.c596
-rw-r--r--drivers/mfd/88pm805.c301
-rw-r--r--drivers/mfd/88pm80x.c145
-rw-r--r--drivers/mfd/88pm860x-core.c23
-rw-r--r--drivers/mfd/Kconfig99
-rw-r--r--drivers/mfd/Makefile15
-rw-r--r--drivers/mfd/ab3100-core.c23
-rw-r--r--drivers/mfd/ab8500-core.c242
-rw-r--r--drivers/mfd/ab8500-debugfs.c12
-rw-r--r--drivers/mfd/ab8500-gpadc.c9
-rw-r--r--drivers/mfd/ab8500-sysctrl.c6
-rw-r--r--drivers/mfd/adp5520.c2
-rw-r--r--drivers/mfd/anatop-mfd.c2
-rw-r--r--drivers/mfd/arizona-core.c566
-rw-r--r--drivers/mfd/arizona-i2c.c97
-rw-r--r--drivers/mfd/arizona-irq.c275
-rw-r--r--drivers/mfd/arizona-spi.c97
-rw-r--r--drivers/mfd/arizona.h40
-rw-r--r--drivers/mfd/da9052-core.c1
-rw-r--r--drivers/mfd/db8500-prcmu.c92
-rw-r--r--drivers/mfd/dbx500-prcmu-regs.h1
-rw-r--r--drivers/mfd/max77686-irq.c319
-rw-r--r--drivers/mfd/max77686.c187
-rw-r--r--drivers/mfd/max77693.c11
-rw-r--r--drivers/mfd/max8925-core.c8
-rw-r--r--drivers/mfd/max8997-irq.c62
-rw-r--r--drivers/mfd/max8997.c9
-rw-r--r--drivers/mfd/mc13xxx-core.c4
-rw-r--r--drivers/mfd/mc13xxx-i2c.c12
-rw-r--r--drivers/mfd/mc13xxx-spi.c15
-rw-r--r--drivers/mfd/mfd-core.c30
-rw-r--r--drivers/mfd/pcf50633-core.c9
-rw-r--r--drivers/mfd/s5m-core.c206
-rw-r--r--drivers/mfd/s5m-irq.c495
-rw-r--r--drivers/mfd/sec-core.c216
-rw-r--r--drivers/mfd/sec-irq.c317
-rw-r--r--drivers/mfd/tc3589x.c9
-rw-r--r--drivers/mfd/tps65090.c4
-rw-r--r--drivers/mfd/tps6586x.c296
-rw-r--r--drivers/mfd/tps65910.c23
-rw-r--r--drivers/mfd/twl-core.c3
-rw-r--r--drivers/mfd/twl6040-core.c24
-rw-r--r--drivers/mfd/wm5102-tables.c2399
-rw-r--r--drivers/mfd/wm5110-tables.c2281
-rw-r--r--drivers/mfd/wm8350-core.c354
-rw-r--r--drivers/mfd/wm8350-i2c.c5
-rw-r--r--drivers/mfd/wm8350-irq.c8
-rw-r--r--drivers/mfd/wm8350-regmap.c3222
-rw-r--r--drivers/mfd/wm8994-core.c17
-rw-r--r--drivers/mfd/wm8994-irq.c10
-rw-r--r--drivers/misc/Kconfig1
-rw-r--r--drivers/misc/ab8500-pwm.c6
-rw-r--r--drivers/mtd/nand/jz4740_nand.c228
-rw-r--r--drivers/net/ethernet/octeon/octeon_mgmt.c312
-rw-r--r--drivers/net/phy/mdio-octeon.c92
-rw-r--r--drivers/platform/x86/acer-wmi.c153
-rw-r--r--drivers/platform/x86/apple-gmux.c6
-rw-r--r--drivers/platform/x86/asus-nb-wmi.c108
-rw-r--r--drivers/platform/x86/asus-wmi.c23
-rw-r--r--drivers/platform/x86/asus-wmi.h1
-rw-r--r--drivers/platform/x86/classmate-laptop.c405
-rw-r--r--drivers/platform/x86/dell-laptop.c54
-rw-r--r--drivers/platform/x86/eeepc-wmi.c25
-rw-r--r--drivers/platform/x86/samsung-laptop.c41
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c5
-rw-r--r--drivers/pwm/Kconfig108
-rw-r--r--drivers/pwm/Makefile11
-rw-r--r--drivers/pwm/core.c713
-rw-r--r--drivers/pwm/pwm-bfin.c162
-rw-r--r--drivers/pwm/pwm-imx.c (renamed from arch/arm/plat-mxc/pwm.c)204
-rw-r--r--drivers/pwm/pwm-lpc32xx.c148
-rw-r--r--drivers/pwm/pwm-mxs.c203
-rw-r--r--drivers/pwm/pwm-pxa.c218
-rw-r--r--drivers/pwm/pwm-samsung.c (renamed from arch/arm/plat-samsung/pwm.c)234
-rw-r--r--drivers/pwm/pwm-tegra.c261
-rw-r--r--drivers/pwm/pwm-tiecap.c232
-rw-r--r--drivers/pwm/pwm-tiehrpwm.c411
-rw-r--r--drivers/pwm/pwm-vt8500.c177
-rw-r--r--drivers/regulator/Kconfig2
-rw-r--r--drivers/regulator/ab8500.c6
-rw-r--r--drivers/regulator/db8500-prcmu.c6
-rw-r--r--drivers/regulator/s5m8767.c72
-rw-r--r--drivers/rtc/Kconfig10
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-88pm80x.c371
-rw-r--r--drivers/rtc/rtc-max8925.c13
-rw-r--r--drivers/spi/Kconfig9
-rw-r--r--drivers/spi/Makefile1
-rw-r--r--drivers/spi/spi-falcon.c469
-rw-r--r--drivers/staging/octeon/ethernet-mdio.c28
-rw-r--r--drivers/staging/octeon/ethernet.c153
-rw-r--r--drivers/staging/octeon/octeon-ethernet.h3
-rw-r--r--drivers/usb/host/ehci-omap.c8
-rw-r--r--drivers/video/backlight/Kconfig2
-rw-r--r--drivers/video/backlight/pwm_bl.c159
-rw-r--r--fs/xfs/xfs_alloc_btree.h14
-rw-r--r--fs/xfs/xfs_aops.c79
-rw-r--r--fs/xfs/xfs_aops.h14
-rw-r--r--fs/xfs/xfs_attr.c78
-rw-r--r--fs/xfs/xfs_attr_leaf.c255
-rw-r--r--fs/xfs/xfs_attr_leaf.h21
-rw-r--r--fs/xfs/xfs_bmap.c2
-rw-r--r--fs/xfs/xfs_buf.c240
-rw-r--r--fs/xfs/xfs_buf.h116
-rw-r--r--fs/xfs/xfs_buf_item.c345
-rw-r--r--fs/xfs/xfs_buf_item.h38
-rw-r--r--fs/xfs/xfs_da_btree.c823
-rw-r--r--fs/xfs/xfs_da_btree.h38
-rw-r--r--fs/xfs/xfs_dinode.h2
-rw-r--r--fs/xfs/xfs_dir2.c4
-rw-r--r--fs/xfs/xfs_dir2_block.c118
-rw-r--r--fs/xfs/xfs_dir2_data.c50
-rw-r--r--fs/xfs/xfs_dir2_leaf.c621
-rw-r--r--fs/xfs/xfs_dir2_node.c236
-rw-r--r--fs/xfs/xfs_dir2_priv.h46
-rw-r--r--fs/xfs/xfs_dir2_sf.c4
-rw-r--r--fs/xfs/xfs_file.c19
-rw-r--r--fs/xfs/xfs_ialloc.c446
-rw-r--r--fs/xfs/xfs_ialloc.h2
-rw-r--r--fs/xfs/xfs_iget.c15
-rw-r--r--fs/xfs/xfs_inode.c208
-rw-r--r--fs/xfs/xfs_inode.h13
-rw-r--r--fs/xfs/xfs_iomap.c6
-rw-r--r--fs/xfs/xfs_iops.c45
-rw-r--r--fs/xfs/xfs_itable.c2
-rw-r--r--fs/xfs/xfs_log.c223
-rw-r--r--fs/xfs/xfs_log_priv.h18
-rw-r--r--fs/xfs/xfs_log_recover.c142
-rw-r--r--fs/xfs/xfs_mount.c11
-rw-r--r--fs/xfs/xfs_mount.h3
-rw-r--r--fs/xfs/xfs_qm.c2
-rw-r--r--fs/xfs/xfs_super.c88
-rw-r--r--fs/xfs/xfs_sync.c13
-rw-r--r--fs/xfs/xfs_trace.h2
-rw-r--r--fs/xfs/xfs_trans.h50
-rw-r--r--fs/xfs/xfs_trans_ail.c35
-rw-r--r--fs/xfs/xfs_trans_buf.c68
-rw-r--r--fs/xfs/xfs_trans_priv.h1
-rw-r--r--fs/xfs/xfs_types.h14
-rw-r--r--fs/xfs/xfs_utils.c17
-rw-r--r--fs/xfs/xfs_vnodeops.c285
-rw-r--r--include/asm-generic/dma-coherent.h1
-rw-r--r--include/asm-generic/dma-mapping-common.h55
-rw-r--r--include/drm/exynos_drm.h9
-rw-r--r--include/linux/acpi.h10
-rw-r--r--include/linux/device-mapper.h29
-rw-r--r--include/linux/dm-ioctl.h6
-rw-r--r--include/linux/dma-attrs.h2
-rw-r--r--include/linux/dma-mapping.h3
-rw-r--r--include/linux/edac.h208
-rw-r--r--include/linux/firewire.h4
-rw-r--r--include/linux/input/edt-ft5x06.h24
-rw-r--r--include/linux/key-type.h1
-rw-r--r--include/linux/libfdt.h8
-rw-r--r--include/linux/libfdt_env.h13
-rw-r--r--include/linux/mempolicy.h2
-rw-r--r--include/linux/mfd/88pm80x.h369
-rw-r--r--include/linux/mfd/88pm860x.h1
-rw-r--r--include/linux/mfd/abx500/ab8500.h5
-rw-r--r--include/linux/mfd/arizona/core.h114
-rw-r--r--include/linux/mfd/arizona/pdata.h119
-rw-r--r--include/linux/mfd/arizona/registers.h6594
-rw-r--r--include/linux/mfd/core.h5
-rw-r--r--include/linux/mfd/db8500-prcmu.h7
-rw-r--r--include/linux/mfd/dbx500-prcmu.h7
-rw-r--r--include/linux/mfd/max77686-private.h246
-rw-r--r--include/linux/mfd/max77686.h114
-rw-r--r--include/linux/mfd/max77693-private.h1
-rw-r--r--include/linux/mfd/max8997-private.h4
-rw-r--r--include/linux/mfd/max8997.h1
-rw-r--r--include/linux/mfd/s5m87xx/s5m-core.h379
-rw-r--r--include/linux/mfd/s5m87xx/s5m-pmic.h129
-rw-r--r--include/linux/mfd/samsung/core.h159
-rw-r--r--include/linux/mfd/samsung/irq.h152
-rw-r--r--include/linux/mfd/samsung/rtc.h (renamed from include/linux/mfd/s5m87xx/s5m-rtc.h)69
-rw-r--r--include/linux/mfd/samsung/s2mps11.h196
-rw-r--r--include/linux/mfd/samsung/s5m8763.h96
-rw-r--r--include/linux/mfd/samsung/s5m8767.h188
-rw-r--r--include/linux/mfd/tps65910.h1
-rw-r--r--include/linux/mfd/twl6040.h6
-rw-r--r--include/linux/mfd/wm8350/core.h26
-rw-r--r--include/linux/mfd/wm8994/pdata.h1
-rw-r--r--include/linux/mm_types.h11
-rw-r--r--include/linux/of.h16
-rw-r--r--include/linux/pwm.h117
-rw-r--r--include/linux/pwm_backlight.h1
-rw-r--r--include/linux/scatterlist.h4
-rw-r--r--include/linux/slab.h24
-rw-r--r--include/linux/slab_def.h12
-rw-r--r--include/linux/slub_def.h3
-rw-r--r--include/linux/virtio_blk.h10
-rw-r--r--include/linux/virtio_ids.h2
-rw-r--r--include/linux/vmalloc.h9
-rw-r--r--include/ras/ras_event.h102
-rw-r--r--lib/Kconfig6
-rw-r--r--lib/Makefile5
-rw-r--r--lib/fdt.c2
-rw-r--r--lib/fdt_ro.c2
-rw-r--r--lib/fdt_rw.c2
-rw-r--r--lib/fdt_strerror.c2
-rw-r--r--lib/fdt_sw.c2
-rw-r--r--lib/fdt_wip.c2
-rw-r--r--lib/scatterlist.c64
-rw-r--r--mm/Makefile3
-rw-r--r--mm/mempolicy.c8
-rw-r--r--mm/slab.c406
-rw-r--r--mm/slab.h33
-rw-r--r--mm/slab_common.c120
-rw-r--r--mm/slob.c152
-rw-r--r--mm/slub.c436
-rw-r--r--mm/vmalloc.c28
-rw-r--r--scripts/coccinelle/iterators/use_after_iter.cocci147
-rw-r--r--scripts/coccinelle/misc/irqf_oneshot.cocci65
-rwxr-xr-xscripts/config62
-rw-r--r--scripts/kconfig/.gitignore1
-rw-r--r--scripts/kconfig/Makefile41
-rw-r--r--scripts/kconfig/confdata.c61
-rw-r--r--scripts/kconfig/lxdialog/check-lxdialog.sh8
-rw-r--r--scripts/kconfig/lxdialog/textbox.c3
-rw-r--r--scripts/kconfig/mconf.c6
-rw-r--r--scripts/kconfig/nconf.c10
-rw-r--r--scripts/kconfig/nconf.gui.c8
-rw-r--r--scripts/kconfig/streamline_config.pl175
-rw-r--r--scripts/link-vmlinux.sh4
-rw-r--r--scripts/package/builddeb7
-rwxr-xr-xscripts/tags.sh6
-rw-r--r--security/selinux/hooks.c15
-rw-r--r--security/smack/smackfs.c8
-rw-r--r--sound/soc/codecs/twl6040.c2
-rwxr-xr-xtools/testing/ktest/ktest.pl167
-rw-r--r--tools/testing/ktest/sample.conf52
-rw-r--r--tools/vm/slabinfo.c14
619 files changed, 43806 insertions, 17363 deletions
diff --git a/Documentation/ABI/stable/sysfs-bus-firewire b/Documentation/ABI/stable/sysfs-bus-firewire
index 3d484e5dc846..41e5a0cd1e3e 100644
--- a/Documentation/ABI/stable/sysfs-bus-firewire
+++ b/Documentation/ABI/stable/sysfs-bus-firewire
@@ -39,6 +39,17 @@ Users: udev rules to set ownership and access permissions or ACLs of
39 /dev/fw[0-9]+ character device files 39 /dev/fw[0-9]+ character device files
40 40
41 41
42What: /sys/bus/firewire/devices/fw[0-9]+/is_local
43Date: July 2012
44KernelVersion: 3.6
45Contact: linux1394-devel@lists.sourceforge.net
46Description:
47 IEEE 1394 node device attribute.
48 Read-only and immutable.
49Values: 1: The sysfs entry represents a local node (a controller card).
50 0: The sysfs entry represents a remote node.
51
52
42What: /sys/bus/firewire/devices/fw[0-9]+[.][0-9]+/ 53What: /sys/bus/firewire/devices/fw[0-9]+[.][0-9]+/
43Date: May 2007 54Date: May 2007
44KernelVersion: 2.6.22 55KernelVersion: 2.6.22
diff --git a/Documentation/ABI/testing/sysfs-devices-edac b/Documentation/ABI/testing/sysfs-devices-edac
new file mode 100644
index 000000000000..30ee78aaed75
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-edac
@@ -0,0 +1,140 @@
1What: /sys/devices/system/edac/mc/mc*/reset_counters
2Date: January 2006
3Contact: linux-edac@vger.kernel.org
4Description: This write-only control file will zero all the statistical
5 counters for UE and CE errors on the given memory controller.
6 Zeroing the counters will also reset the timer indicating how
7 long since the last counter were reset. This is useful for
8 computing errors/time. Since the counters are always reset
9 at driver initialization time, no module/kernel parameter
10 is available.
11
12What: /sys/devices/system/edac/mc/mc*/seconds_since_reset
13Date: January 2006
14Contact: linux-edac@vger.kernel.org
15Description: This attribute file displays how many seconds have elapsed
16 since the last counter reset. This can be used with the error
17 counters to measure error rates.
18
19What: /sys/devices/system/edac/mc/mc*/mc_name
20Date: January 2006
21Contact: linux-edac@vger.kernel.org
22Description: This attribute file displays the type of memory controller
23 that is being utilized.
24
25What: /sys/devices/system/edac/mc/mc*/size_mb
26Date: January 2006
27Contact: linux-edac@vger.kernel.org
28Description: This attribute file displays, in count of megabytes, of memory
29 that this memory controller manages.
30
31What: /sys/devices/system/edac/mc/mc*/ue_count
32Date: January 2006
33Contact: linux-edac@vger.kernel.org
34Description: This attribute file displays the total count of uncorrectable
35 errors that have occurred on this memory controller. If
36 panic_on_ue is set, this counter will not have a chance to
37 increment, since EDAC will panic the system
38
39What: /sys/devices/system/edac/mc/mc*/ue_noinfo_count
40Date: January 2006
41Contact: linux-edac@vger.kernel.org
42Description: This attribute file displays the number of UEs that have
43 occurred on this memory controller with no information as to
44 which DIMM slot is having errors.
45
46What: /sys/devices/system/edac/mc/mc*/ce_count
47Date: January 2006
48Contact: linux-edac@vger.kernel.org
49Description: This attribute file displays the total count of correctable
50 errors that have occurred on this memory controller. This
51 count is very important to examine. CEs provide early
52 indications that a DIMM is beginning to fail. This count
53 field should be monitored for non-zero values and report
54 such information to the system administrator.
55
56What: /sys/devices/system/edac/mc/mc*/ce_noinfo_count
57Date: January 2006
58Contact: linux-edac@vger.kernel.org
59Description: This attribute file displays the number of CEs that
60 have occurred on this memory controller wherewith no
61 information as to which DIMM slot is having errors. Memory is
62 handicapped, but operational, yet no information is available
63 to indicate which slot the failing memory is in. This count
64 field should be also be monitored for non-zero values.
65
66What: /sys/devices/system/edac/mc/mc*/sdram_scrub_rate
67Date: February 2007
68Contact: linux-edac@vger.kernel.org
69Description: Read/Write attribute file that controls memory scrubbing.
70 The scrubbing rate used by the memory controller is set by
71 writing a minimum bandwidth in bytes/sec to the attribute file.
72 The rate will be translated to an internal value that gives at
73 least the specified rate.
74 Reading the file will return the actual scrubbing rate employed.
75 If configuration fails or memory scrubbing is not implemented,
76 the value of the attribute file will be -1.
77
78What: /sys/devices/system/edac/mc/mc*/max_location
79Date: April 2012
80Contact: Mauro Carvalho Chehab <mchehab@redhat.com>
81 linux-edac@vger.kernel.org
82Description: This attribute file displays the information about the last
83 available memory slot in this memory controller. It is used by
84 userspace tools in order to display the memory filling layout.
85
86What: /sys/devices/system/edac/mc/mc*/(dimm|rank)*/size
87Date: April 2012
88Contact: Mauro Carvalho Chehab <mchehab@redhat.com>
89 linux-edac@vger.kernel.org
90Description: This attribute file will display the size of dimm or rank.
91 For dimm*/size, this is the size, in MB of the DIMM memory
92 stick. For rank*/size, this is the size, in MB for one rank
93 of the DIMM memory stick. On single rank memories (1R), this
94 is also the total size of the dimm. On dual rank (2R) memories,
95 this is half the size of the total DIMM memories.
96
97What: /sys/devices/system/edac/mc/mc*/(dimm|rank)*/dimm_dev_type
98Date: April 2012
99Contact: Mauro Carvalho Chehab <mchehab@redhat.com>
100 linux-edac@vger.kernel.org
101Description: This attribute file will display what type of DRAM device is
102 being utilized on this DIMM (x1, x2, x4, x8, ...).
103
104What: /sys/devices/system/edac/mc/mc*/(dimm|rank)*/dimm_edac_mode
105Date: April 2012
106Contact: Mauro Carvalho Chehab <mchehab@redhat.com>
107 linux-edac@vger.kernel.org
108Description: This attribute file will display what type of Error detection
109 and correction is being utilized. For example: S4ECD4ED would
110 mean a Chipkill with x4 DRAM.
111
112What: /sys/devices/system/edac/mc/mc*/(dimm|rank)*/dimm_label
113Date: April 2012
114Contact: Mauro Carvalho Chehab <mchehab@redhat.com>
115 linux-edac@vger.kernel.org
116Description: This control file allows this DIMM to have a label assigned
117 to it. With this label in the module, when errors occur
118 the output can provide the DIMM label in the system log.
119 This becomes vital for panic events to isolate the
120 cause of the UE event.
121 DIMM Labels must be assigned after booting, with information
122 that correctly identifies the physical slot with its
123 silk screen label. This information is currently very
124 motherboard specific and determination of this information
125 must occur in userland at this time.
126
127What: /sys/devices/system/edac/mc/mc*/(dimm|rank)*/dimm_location
128Date: April 2012
129Contact: Mauro Carvalho Chehab <mchehab@redhat.com>
130 linux-edac@vger.kernel.org
131Description: This attribute file will display the location (csrow/channel,
132 branch/channel/slot or channel/slot) of the dimm or rank.
133
134What: /sys/devices/system/edac/mc/mc*/(dimm|rank)*/dimm_mem_type
135Date: April 2012
136Contact: Mauro Carvalho Chehab <mchehab@redhat.com>
137 linux-edac@vger.kernel.org
138Description: This attribute file will display what type of memory is
139 currently on this csrow. Normally, either buffered or
140 unbuffered memory (for example, Unbuffered-DDR3).
diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi
index 2e7df91620de..019e1e29370e 100644
--- a/Documentation/ABI/testing/sysfs-platform-asus-wmi
+++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi
@@ -29,3 +29,10 @@ KernelVersion: 2.6.39
29Contact: "Corentin Chary" <corentincj@iksaif.net> 29Contact: "Corentin Chary" <corentincj@iksaif.net>
30Description: 30Description:
31 Control the card touchpad. 1 means on, 0 means off. 31 Control the card touchpad. 1 means on, 0 means off.
32
33What: /sys/devices/platform/<platform>/lid_resume
34Date: May 2012
35KernelVersion: 3.5
36Contact: "AceLan Kao" <acelan.kao@canonical.com>
37Description:
38 Resume on lid open. 1 means on, 0 means off.
diff --git a/Documentation/DMA-attributes.txt b/Documentation/DMA-attributes.txt
index 5c72eed89563..f50309081ac7 100644
--- a/Documentation/DMA-attributes.txt
+++ b/Documentation/DMA-attributes.txt
@@ -49,3 +49,45 @@ DMA_ATTR_NON_CONSISTENT lets the platform to choose to return either
49consistent or non-consistent memory as it sees fit. By using this API, 49consistent or non-consistent memory as it sees fit. By using this API,
50you are guaranteeing to the platform that you have all the correct and 50you are guaranteeing to the platform that you have all the correct and
51necessary sync points for this memory in the driver. 51necessary sync points for this memory in the driver.
52
53DMA_ATTR_NO_KERNEL_MAPPING
54--------------------------
55
56DMA_ATTR_NO_KERNEL_MAPPING lets the platform to avoid creating a kernel
57virtual mapping for the allocated buffer. On some architectures creating
58such mapping is non-trivial task and consumes very limited resources
59(like kernel virtual address space or dma consistent address space).
60Buffers allocated with this attribute can be only passed to user space
61by calling dma_mmap_attrs(). By using this API, you are guaranteeing
62that you won't dereference the pointer returned by dma_alloc_attr(). You
63can threat it as a cookie that must be passed to dma_mmap_attrs() and
64dma_free_attrs(). Make sure that both of these also get this attribute
65set on each call.
66
67Since it is optional for platforms to implement
68DMA_ATTR_NO_KERNEL_MAPPING, those that do not will simply ignore the
69attribute and exhibit default behavior.
70
71DMA_ATTR_SKIP_CPU_SYNC
72----------------------
73
74By default dma_map_{single,page,sg} functions family transfer a given
75buffer from CPU domain to device domain. Some advanced use cases might
76require sharing a buffer between more than one device. This requires
77having a mapping created separately for each device and is usually
78performed by calling dma_map_{single,page,sg} function more than once
79for the given buffer with device pointer to each device taking part in
80the buffer sharing. The first call transfers a buffer from 'CPU' domain
81to 'device' domain, what synchronizes CPU caches for the given region
82(usually it means that the cache has been flushed or invalidated
83depending on the dma direction). However, next calls to
84dma_map_{single,page,sg}() for other devices will perform exactly the
85same sychronization operation on the CPU cache. CPU cache sychronization
86might be a time consuming operation, especially if the buffers are
87large, so it is highly recommended to avoid it if possible.
88DMA_ATTR_SKIP_CPU_SYNC allows platform code to skip synchronization of
89the CPU cache for the given buffer assuming that it has been already
90transferred to 'device' domain. This attribute can be also used for
91dma_unmap_{single,page,sg} functions family to force buffer to stay in
92device domain after releasing a mapping for it. Use this attribute with
93care!
diff --git a/Documentation/device-mapper/striped.txt b/Documentation/device-mapper/striped.txt
index f34d3236b9da..45f3b91ea4c3 100644
--- a/Documentation/device-mapper/striped.txt
+++ b/Documentation/device-mapper/striped.txt
@@ -9,15 +9,14 @@ devices in parallel.
9 9
10Parameters: <num devs> <chunk size> [<dev path> <offset>]+ 10Parameters: <num devs> <chunk size> [<dev path> <offset>]+
11 <num devs>: Number of underlying devices. 11 <num devs>: Number of underlying devices.
12 <chunk size>: Size of each chunk of data. Must be a power-of-2 and at 12 <chunk size>: Size of each chunk of data. Must be at least as
13 least as large as the system's PAGE_SIZE. 13 large as the system's PAGE_SIZE.
14 <dev path>: Full pathname to the underlying block-device, or a 14 <dev path>: Full pathname to the underlying block-device, or a
15 "major:minor" device-number. 15 "major:minor" device-number.
16 <offset>: Starting sector within the device. 16 <offset>: Starting sector within the device.
17 17
18One or more underlying devices can be specified. The striped device size must 18One or more underlying devices can be specified. The striped device size must
19be a multiple of the chunk size and a multiple of the number of underlying 19be a multiple of the chunk size multiplied by the number of underlying devices.
20devices.
21 20
22 21
23Example scripts 22Example scripts
diff --git a/Documentation/device-mapper/thin-provisioning.txt b/Documentation/device-mapper/thin-provisioning.txt
index f5cfc62b7ad3..30b8b83bd333 100644
--- a/Documentation/device-mapper/thin-provisioning.txt
+++ b/Documentation/device-mapper/thin-provisioning.txt
@@ -231,6 +231,9 @@ i) Constructor
231 no_discard_passdown: Don't pass discards down to the underlying 231 no_discard_passdown: Don't pass discards down to the underlying
232 data device, but just remove the mapping. 232 data device, but just remove the mapping.
233 233
234 read_only: Don't allow any changes to be made to the pool
235 metadata.
236
234 Data block size must be between 64KB (128 sectors) and 1GB 237 Data block size must be between 64KB (128 sectors) and 1GB
235 (2097152 sectors) inclusive. 238 (2097152 sectors) inclusive.
236 239
@@ -239,7 +242,7 @@ ii) Status
239 242
240 <transaction id> <used metadata blocks>/<total metadata blocks> 243 <transaction id> <used metadata blocks>/<total metadata blocks>
241 <used data blocks>/<total data blocks> <held metadata root> 244 <used data blocks>/<total data blocks> <held metadata root>
242 245 [no_]discard_passdown ro|rw
243 246
244 transaction id: 247 transaction id:
245 A 64-bit number used by userspace to help synchronise with metadata 248 A 64-bit number used by userspace to help synchronise with metadata
@@ -257,6 +260,21 @@ ii) Status
257 held root. This feature is not yet implemented so '-' is 260 held root. This feature is not yet implemented so '-' is
258 always returned. 261 always returned.
259 262
263 discard_passdown|no_discard_passdown
264 Whether or not discards are actually being passed down to the
265 underlying device. When this is enabled when loading the table,
266 it can get disabled if the underlying device doesn't support it.
267
268 ro|rw
269 If the pool encounters certain types of device failures it will
270 drop into a read-only metadata mode in which no changes to
271 the pool metadata (like allocating new blocks) are permitted.
272
273 In serious cases where even a read-only mode is deemed unsafe
274 no further I/O will be permitted and the status will just
275 contain the string 'Fail'. The userspace recovery tools
276 should then be used.
277
260iii) Messages 278iii) Messages
261 279
262 create_thin <dev id> 280 create_thin <dev id>
@@ -329,3 +347,7 @@ regain some space then send the 'trim' message to the pool.
329ii) Status 347ii) Status
330 348
331 <nr mapped sectors> <highest mapped sector> 349 <nr mapped sectors> <highest mapped sector>
350
351 If the pool has encountered device errors and failed, the status
352 will just contain the string 'Fail'. The userspace recovery
353 tools should then be used.
diff --git a/Documentation/devicetree/bindings/arm/calxeda/l2ecc.txt b/Documentation/devicetree/bindings/arm/calxeda/l2ecc.txt
new file mode 100644
index 000000000000..94e642a33db0
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/calxeda/l2ecc.txt
@@ -0,0 +1,15 @@
1Calxeda Highbank L2 cache ECC
2
3Properties:
4- compatible : Should be "calxeda,hb-sregs-l2-ecc"
5- reg : Address and size for ECC error interrupt clear registers.
6- interrupts : Should be single bit error interrupt, then double bit error
7 interrupt.
8
9Example:
10
11 sregs@fff3c200 {
12 compatible = "calxeda,hb-sregs-l2-ecc";
13 reg = <0xfff3c200 0x100>;
14 interrupts = <0 71 4 0 72 4>;
15 };
diff --git a/Documentation/devicetree/bindings/arm/calxeda/mem-ctrlr.txt b/Documentation/devicetree/bindings/arm/calxeda/mem-ctrlr.txt
new file mode 100644
index 000000000000..f770ac0893d4
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/calxeda/mem-ctrlr.txt
@@ -0,0 +1,14 @@
1Calxeda DDR memory controller
2
3Properties:
4- compatible : Should be "calxeda,hb-ddr-ctrl"
5- reg : Address and size for DDR controller registers.
6- interrupts : Interrupt for DDR controller.
7
8Example:
9
10 memory-controller@fff00000 {
11 compatible = "calxeda,hb-ddr-ctrl";
12 reg = <0xfff00000 0x1000>;
13 interrupts = <0 91 4>;
14 };
diff --git a/Documentation/devicetree/bindings/ata/cavium-compact-flash.txt b/Documentation/devicetree/bindings/ata/cavium-compact-flash.txt
new file mode 100644
index 000000000000..93986a5a8018
--- /dev/null
+++ b/Documentation/devicetree/bindings/ata/cavium-compact-flash.txt
@@ -0,0 +1,30 @@
1* Compact Flash
2
3The Cavium Compact Flash device is connected to the Octeon Boot Bus,
4and is thus a child of the Boot Bus device. It can read and write
5industry standard compact flash devices.
6
7Properties:
8- compatible: "cavium,ebt3000-compact-flash";
9
10 Compatibility with many Cavium evaluation boards.
11
12- reg: The base address of the the CF chip select banks. Depending on
13 the device configuration, there may be one or two banks.
14
15- cavium,bus-width: The width of the connection to the CF devices. Valid
16 values are 8 and 16.
17
18- cavium,true-ide: Optional, if present the CF connection is in True IDE mode.
19
20- cavium,dma-engine-handle: Optional, a phandle for the DMA Engine connected
21 to this device.
22
23Example:
24 compact-flash@5,0 {
25 compatible = "cavium,ebt3000-compact-flash";
26 reg = <5 0 0x10000>, <6 0 0x10000>;
27 cavium,bus-width = <16>;
28 cavium,true-ide;
29 cavium,dma-engine-handle = <&dma0>;
30 };
diff --git a/Documentation/devicetree/bindings/gpio/cavium-octeon-gpio.txt b/Documentation/devicetree/bindings/gpio/cavium-octeon-gpio.txt
new file mode 100644
index 000000000000..9d6dcd3fe7f9
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/cavium-octeon-gpio.txt
@@ -0,0 +1,49 @@
1* General Purpose Input Output (GPIO) bus.
2
3Properties:
4- compatible: "cavium,octeon-3860-gpio"
5
6 Compatibility with all cn3XXX, cn5XXX and cn6XXX SOCs.
7
8- reg: The base address of the GPIO unit's register bank.
9
10- gpio-controller: This is a GPIO controller.
11
12- #gpio-cells: Must be <2>. The first cell is the GPIO pin.
13
14- interrupt-controller: The GPIO controller is also an interrupt
15 controller, many of its pins may be configured as an interrupt
16 source.
17
18- #interrupt-cells: Must be <2>. The first cell is the GPIO pin
19 connected to the interrupt source. The second cell is the interrupt
20 triggering protocol and may have one of four values:
21 1 - edge triggered on the rising edge.
22 2 - edge triggered on the falling edge
23 4 - level triggered active high.
24 8 - level triggered active low.
25
26- interrupts: Interrupt routing for each pin.
27
28Example:
29
30 gpio-controller@1070000000800 {
31 #gpio-cells = <2>;
32 compatible = "cavium,octeon-3860-gpio";
33 reg = <0x10700 0x00000800 0x0 0x100>;
34 gpio-controller;
35 /* Interrupts are specified by two parts:
36 * 1) GPIO pin number (0..15)
37 * 2) Triggering (1 - edge rising
38 * 2 - edge falling
39 * 4 - level active high
40 * 8 - level active low)
41 */
42 interrupt-controller;
43 #interrupt-cells = <2>;
44 /* The GPIO pin connect to 16 consecutive CUI bits */
45 interrupts = <0 16>, <0 17>, <0 18>, <0 19>,
46 <0 20>, <0 21>, <0 22>, <0 23>,
47 <0 24>, <0 25>, <0 26>, <0 27>,
48 <0 28>, <0 29>, <0 30>, <0 31>;
49 };
diff --git a/Documentation/devicetree/bindings/i2c/cavium-i2c.txt b/Documentation/devicetree/bindings/i2c/cavium-i2c.txt
new file mode 100644
index 000000000000..dced82ebe31d
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/cavium-i2c.txt
@@ -0,0 +1,34 @@
1* Two Wire Serial Interface (TWSI) / I2C
2
3- compatible: "cavium,octeon-3860-twsi"
4
5 Compatibility with all cn3XXX, cn5XXX and cn6XXX SOCs.
6
7- reg: The base address of the TWSI/I2C bus controller register bank.
8
9- #address-cells: Must be <1>.
10
11- #size-cells: Must be <0>. I2C addresses have no size component.
12
13- interrupts: A single interrupt specifier.
14
15- clock-frequency: The I2C bus clock rate in Hz.
16
17Example:
18 twsi0: i2c@1180000001000 {
19 #address-cells = <1>;
20 #size-cells = <0>;
21 compatible = "cavium,octeon-3860-twsi";
22 reg = <0x11800 0x00001000 0x0 0x200>;
23 interrupts = <0 45>;
24 clock-frequency = <100000>;
25
26 rtc@68 {
27 compatible = "dallas,ds1337";
28 reg = <0x68>;
29 };
30 tmp@4c {
31 compatible = "ti,tmp421";
32 reg = <0x4c>;
33 };
34 };
diff --git a/Documentation/devicetree/bindings/mfd/ab8500.txt b/Documentation/devicetree/bindings/mfd/ab8500.txt
new file mode 100644
index 000000000000..69e757a657a0
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/ab8500.txt
@@ -0,0 +1,123 @@
1* AB8500 Multi-Functional Device (MFD)
2
3Required parent device properties:
4- compatible : contains "stericsson,ab8500";
5- interrupts : contains the IRQ line for the AB8500
6- interrupt-controller : describes the AB8500 as an Interrupt Controller (has its own domain)
7- #interrupt-cells : should be 2, for 2-cell format
8 - The first cell is the AB8500 local IRQ number
9 - The second cell is used to specify optional parameters
10 - bits[3:0] trigger type and level flags:
11 1 = low-to-high edge triggered
12 2 = high-to-low edge triggered
13 4 = active high level-sensitive
14 8 = active low level-sensitive
15
16Optional parent device properties:
17- reg : contains the PRCMU mailbox address for the AB8500 i2c port
18
19The AB8500 consists of a large and varied group of sub-devices:
20
21Device IRQ Names Supply Names Description
22------ --------- ------------ -----------
23ab8500-bm : : : Battery Manager
24ab8500-btemp : : : Battery Temperature
25ab8500-charger : : : Battery Charger
26ab8500-fg : : : Fuel Gauge
27ab8500-gpadc : HW_CONV_END : vddadc : Analogue to Digital Converter
28 SW_CONV_END : :
29ab8500-gpio : : : GPIO Controller
30ab8500-ponkey : ONKEY_DBF : : Power-on Key
31 ONKEY_DBR : :
32ab8500-pwm : : : Pulse Width Modulator
33ab8500-regulator : : : Regulators
34ab8500-rtc : 60S : : Real Time Clock
35 : ALARM : :
36ab8500-sysctrl : : : System Control
37ab8500-usb : ID_WAKEUP_R : vddulpivio18 : Universal Serial Bus
38 : ID_WAKEUP_F : v-ape :
39 : VBUS_DET_F : musb_1v8 :
40 : VBUS_DET_R : :
41 : USB_LINK_STATUS : :
42 : USB_ADP_PROBE_PLUG : :
43 : USB_ADP_PROBE_UNPLUG : :
44
45Required child device properties:
46- compatible : "stericsson,ab8500-[bm|btemp|charger|fg|gpadc|gpio|ponkey|
47 pwm|regulator|rtc|sysctrl|usb]";
48
49Optional child device properties:
50- interrupts : contains the device IRQ(s) using the 2-cell format (see above)
51- interrupt-names : contains names of IRQ resource in the order in which they were
52 supplied in the interrupts property
53- <supply_name>-supply : contains a phandle to the regulator supply node in Device Tree
54
55ab8500@5 {
56 compatible = "stericsson,ab8500";
57 reg = <5>; /* mailbox 5 is i2c */
58 interrupts = <0 40 0x4>;
59 interrupt-controller;
60 #interrupt-cells = <2>;
61
62 ab8500-rtc {
63 compatible = "stericsson,ab8500-rtc";
64 interrupts = <17 0x4
65 18 0x4>;
66 interrupt-names = "60S", "ALARM";
67 };
68
69 ab8500-gpadc {
70 compatible = "stericsson,ab8500-gpadc";
71 interrupts = <32 0x4
72 39 0x4>;
73 interrupt-names = "HW_CONV_END", "SW_CONV_END";
74 vddadc-supply = <&ab8500_ldo_tvout_reg>;
75 };
76
77 ab8500-usb {
78 compatible = "stericsson,ab8500-usb";
79 interrupts = < 90 0x4
80 96 0x4
81 14 0x4
82 15 0x4
83 79 0x4
84 74 0x4
85 75 0x4>;
86 interrupt-names = "ID_WAKEUP_R",
87 "ID_WAKEUP_F",
88 "VBUS_DET_F",
89 "VBUS_DET_R",
90 "USB_LINK_STATUS",
91 "USB_ADP_PROBE_PLUG",
92 "USB_ADP_PROBE_UNPLUG";
93 vddulpivio18-supply = <&ab8500_ldo_initcore_reg>;
94 v-ape-supply = <&db8500_vape_reg>;
95 musb_1v8-supply = <&db8500_vsmps2_reg>;
96 };
97
98 ab8500-ponkey {
99 compatible = "stericsson,ab8500-ponkey";
100 interrupts = <6 0x4
101 7 0x4>;
102 interrupt-names = "ONKEY_DBF", "ONKEY_DBR";
103 };
104
105 ab8500-sysctrl {
106 compatible = "stericsson,ab8500-sysctrl";
107 };
108
109 ab8500-pwm {
110 compatible = "stericsson,ab8500-pwm";
111 };
112
113 ab8500-regulators {
114 compatible = "stericsson,ab8500-regulator";
115
116 ab8500_ldo_aux1_reg: ab8500_ldo_aux1 {
117 /*
118 * See: Documentation/devicetree/bindings/regulator/regulator.txt
119 * for more information on regulators
120 */
121 };
122 };
123};
diff --git a/Documentation/devicetree/bindings/mfd/max77686.txt b/Documentation/devicetree/bindings/mfd/max77686.txt
new file mode 100644
index 000000000000..c6a3469d3436
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/max77686.txt
@@ -0,0 +1,59 @@
1Maxim MAX77686 multi-function device
2
3MAX77686 is a Mulitifunction device with PMIC, RTC and Charger on chip. It is
4interfaced to host controller using i2c interface. PMIC and Charger submodules
5are addressed using same i2c slave address whereas RTC submodule uses
6different i2c slave address,presently for which we are statically creating i2c
7client while probing.This document describes the binding for mfd device and
8PMIC submodule.
9
10Required properties:
11- compatible : Must be "maxim,max77686";
12- reg : Specifies the i2c slave address of PMIC block.
13- interrupts : This i2c device has an IRQ line connected to the main SoC.
14- interrupt-parent : The parent interrupt controller.
15
16Optional node:
17- voltage-regulators : The regulators of max77686 have to be instantiated
18 under subnode named "voltage-regulators" using the following format.
19
20 regulator_name {
21 regulator-compatible = LDOn/BUCKn
22 standard regulator constraints....
23 };
24 refer Documentation/devicetree/bindings/regulator/regulator.txt
25
26 The regulator-compatible property of regulator should initialized with string
27to get matched with their hardware counterparts as follow:
28
29 -LDOn : for LDOs, where n can lie in range 1 to 26.
30 example: LDO1, LDO2, LDO26.
31 -BUCKn : for BUCKs, where n can lie in range 1 to 9.
32 example: BUCK1, BUCK5, BUCK9.
33
34Example:
35
36 max77686@09 {
37 compatible = "maxim,max77686";
38 interrupt-parent = <&wakeup_eint>;
39 interrupts = <26 0>;
40 reg = <0x09>;
41
42 voltage-regulators {
43 ldo11_reg {
44 regulator-compatible = "LDO11";
45 regulator-name = "vdd_ldo11";
46 regulator-min-microvolt = <1900000>;
47 regulator-max-microvolt = <1900000>;
48 regulator-always-on;
49 };
50
51 buck1_reg {
52 regulator-compatible = "BUCK1";
53 regulator-name = "vdd_mif";
54 regulator-min-microvolt = <950000>;
55 regulator-max-microvolt = <1300000>;
56 regulator-always-on;
57 regulator-boot-on;
58 };
59 }
diff --git a/Documentation/devicetree/bindings/mfd/tps65910.txt b/Documentation/devicetree/bindings/mfd/tps65910.txt
index d2802d4717bc..db03599ae4dc 100644
--- a/Documentation/devicetree/bindings/mfd/tps65910.txt
+++ b/Documentation/devicetree/bindings/mfd/tps65910.txt
@@ -81,7 +81,7 @@ Example:
81 81
82 ti,vmbch-threshold = 0; 82 ti,vmbch-threshold = 0;
83 ti,vmbch2-threshold = 0; 83 ti,vmbch2-threshold = 0;
84 84 ti,en-ck32k-xtal;
85 ti,en-gpio-sleep = <0 0 1 0 0 0 0 0 0>; 85 ti,en-gpio-sleep = <0 0 1 0 0 0 0 0 0>;
86 86
87 vcc1-supply = <&reg_parent>; 87 vcc1-supply = <&reg_parent>;
diff --git a/Documentation/devicetree/bindings/mfd/twl6040.txt b/Documentation/devicetree/bindings/mfd/twl6040.txt
index bc67c6f424aa..c855240f3a0e 100644
--- a/Documentation/devicetree/bindings/mfd/twl6040.txt
+++ b/Documentation/devicetree/bindings/mfd/twl6040.txt
@@ -6,7 +6,7 @@ They are connected ot the host processor via i2c for commands, McPDM for audio
6data and commands. 6data and commands.
7 7
8Required properties: 8Required properties:
9- compatible : Must be "ti,twl6040"; 9- compatible : "ti,twl6040" for twl6040, "ti,twl6041" for twl6041
10- reg: must be 0x4b for i2c address 10- reg: must be 0x4b for i2c address
11- interrupts: twl6040 has one interrupt line connecteded to the main SoC 11- interrupts: twl6040 has one interrupt line connecteded to the main SoC
12- interrupt-parent: The parent interrupt controller 12- interrupt-parent: The parent interrupt controller
diff --git a/Documentation/devicetree/bindings/mips/cavium/bootbus.txt b/Documentation/devicetree/bindings/mips/cavium/bootbus.txt
new file mode 100644
index 000000000000..6581478225a2
--- /dev/null
+++ b/Documentation/devicetree/bindings/mips/cavium/bootbus.txt
@@ -0,0 +1,126 @@
1* Boot Bus
2
3The Octeon Boot Bus is a configurable parallel bus with 8 chip
4selects. Each chip select is independently configurable.
5
6Properties:
7- compatible: "cavium,octeon-3860-bootbus"
8
9 Compatibility with all cn3XXX, cn5XXX and cn6XXX SOCs.
10
11- reg: The base address of the Boot Bus' register bank.
12
13- #address-cells: Must be <2>. The first cell is the chip select
14 within the bootbus. The second cell is the offset from the chip select.
15
16- #size-cells: Must be <1>.
17
18- ranges: There must be one one triplet of (child-bus-address,
19 parent-bus-address, length) for each active chip select. If the
20 length element for any triplet is zero, the chip select is disabled,
21 making it inactive.
22
23The configuration parameters for each chip select are stored in child
24nodes.
25
26Configuration Properties:
27- compatible: "cavium,octeon-3860-bootbus-config"
28
29- cavium,cs-index: A single cell indicating the chip select that
30 corresponds to this configuration.
31
32- cavium,t-adr: A cell specifying the ADR timing (in nS).
33
34- cavium,t-ce: A cell specifying the CE timing (in nS).
35
36- cavium,t-oe: A cell specifying the OE timing (in nS).
37
38- cavium,t-we: A cell specifying the WE timing (in nS).
39
40- cavium,t-rd-hld: A cell specifying the RD_HLD timing (in nS).
41
42- cavium,t-wr-hld: A cell specifying the WR_HLD timing (in nS).
43
44- cavium,t-pause: A cell specifying the PAUSE timing (in nS).
45
46- cavium,t-wait: A cell specifying the WAIT timing (in nS).
47
48- cavium,t-page: A cell specifying the PAGE timing (in nS).
49
50- cavium,t-rd-dly: A cell specifying the RD_DLY timing (in nS).
51
52- cavium,pages: A cell specifying the PAGES parameter (0 = 8 bytes, 1
53 = 2 bytes, 2 = 4 bytes, 3 = 8 bytes).
54
55- cavium,wait-mode: Optional. If present, wait mode (WAITM) is selected.
56
57- cavium,page-mode: Optional. If present, page mode (PAGEM) is selected.
58
59- cavium,bus-width: A cell specifying the WIDTH parameter (in bits) of
60 the bus for this chip select.
61
62- cavium,ale-mode: Optional. If present, ALE mode is selected.
63
64- cavium,sam-mode: Optional. If present, SAM mode is selected.
65
66- cavium,or-mode: Optional. If present, OR mode is selected.
67
68Example:
69 bootbus: bootbus@1180000000000 {
70 compatible = "cavium,octeon-3860-bootbus";
71 reg = <0x11800 0x00000000 0x0 0x200>;
72 /* The chip select number and offset */
73 #address-cells = <2>;
74 /* The size of the chip select region */
75 #size-cells = <1>;
76 ranges = <0 0 0x0 0x1f400000 0xc00000>,
77 <1 0 0x10000 0x30000000 0>,
78 <2 0 0x10000 0x40000000 0>,
79 <3 0 0x10000 0x50000000 0>,
80 <4 0 0x0 0x1d020000 0x10000>,
81 <5 0 0x0 0x1d040000 0x10000>,
82 <6 0 0x0 0x1d050000 0x10000>,
83 <7 0 0x10000 0x90000000 0>;
84
85 cavium,cs-config@0 {
86 compatible = "cavium,octeon-3860-bootbus-config";
87 cavium,cs-index = <0>;
88 cavium,t-adr = <20>;
89 cavium,t-ce = <60>;
90 cavium,t-oe = <60>;
91 cavium,t-we = <45>;
92 cavium,t-rd-hld = <35>;
93 cavium,t-wr-hld = <45>;
94 cavium,t-pause = <0>;
95 cavium,t-wait = <0>;
96 cavium,t-page = <35>;
97 cavium,t-rd-dly = <0>;
98
99 cavium,pages = <0>;
100 cavium,bus-width = <8>;
101 };
102 .
103 .
104 .
105 cavium,cs-config@6 {
106 compatible = "cavium,octeon-3860-bootbus-config";
107 cavium,cs-index = <6>;
108 cavium,t-adr = <5>;
109 cavium,t-ce = <300>;
110 cavium,t-oe = <270>;
111 cavium,t-we = <150>;
112 cavium,t-rd-hld = <100>;
113 cavium,t-wr-hld = <70>;
114 cavium,t-pause = <0>;
115 cavium,t-wait = <0>;
116 cavium,t-page = <320>;
117 cavium,t-rd-dly = <0>;
118
119 cavium,pages = <0>;
120 cavium,wait-mode;
121 cavium,bus-width = <16>;
122 };
123 .
124 .
125 .
126 };
diff --git a/Documentation/devicetree/bindings/mips/cavium/ciu.txt b/Documentation/devicetree/bindings/mips/cavium/ciu.txt
new file mode 100644
index 000000000000..2c2d0746b43d
--- /dev/null
+++ b/Documentation/devicetree/bindings/mips/cavium/ciu.txt
@@ -0,0 +1,26 @@
1* Central Interrupt Unit
2
3Properties:
4- compatible: "cavium,octeon-3860-ciu"
5
6 Compatibility with all cn3XXX, cn5XXX and cn63XX SOCs.
7
8- interrupt-controller: This is an interrupt controller.
9
10- reg: The base address of the CIU's register bank.
11
12- #interrupt-cells: Must be <2>. The first cell is the bank within
13 the CIU and may have a value of 0 or 1. The second cell is the bit
14 within the bank and may have a value between 0 and 63.
15
16Example:
17 interrupt-controller@1070000000000 {
18 compatible = "cavium,octeon-3860-ciu";
19 interrupt-controller;
20 /* Interrupts are specified by two parts:
21 * 1) Controller register (0 or 1)
22 * 2) Bit within the register (0..63)
23 */
24 #interrupt-cells = <2>;
25 reg = <0x10700 0x00000000 0x0 0x7000>;
26 };
diff --git a/Documentation/devicetree/bindings/mips/cavium/ciu2.txt b/Documentation/devicetree/bindings/mips/cavium/ciu2.txt
new file mode 100644
index 000000000000..0ec7ba8bbbcb
--- /dev/null
+++ b/Documentation/devicetree/bindings/mips/cavium/ciu2.txt
@@ -0,0 +1,27 @@
1* Central Interrupt Unit
2
3Properties:
4- compatible: "cavium,octeon-6880-ciu2"
5
6 Compatibility with 68XX SOCs.
7
8- interrupt-controller: This is an interrupt controller.
9
10- reg: The base address of the CIU's register bank.
11
12- #interrupt-cells: Must be <2>. The first cell is the bank within
13 the CIU and may have a value between 0 and 63. The second cell is
14 the bit within the bank and may also have a value between 0 and 63.
15
16Example:
17 interrupt-controller@1070100000000 {
18 compatible = "cavium,octeon-6880-ciu2";
19 interrupt-controller;
20 /* Interrupts are specified by two parts:
21 * 1) Controller register (0..63)
22 * 2) Bit within the register (0..63)
23 */
24 #address-cells = <0>;
25 #interrupt-cells = <2>;
26 reg = <0x10701 0x00000000 0x0 0x4000000>;
27 };
diff --git a/Documentation/devicetree/bindings/mips/cavium/dma-engine.txt b/Documentation/devicetree/bindings/mips/cavium/dma-engine.txt
new file mode 100644
index 000000000000..cb4291e3b1d1
--- /dev/null
+++ b/Documentation/devicetree/bindings/mips/cavium/dma-engine.txt
@@ -0,0 +1,21 @@
1* DMA Engine.
2
3The Octeon DMA Engine transfers between the Boot Bus and main memory.
4The DMA Engine will be refered to by phandle by any device that is
5connected to it.
6
7Properties:
8- compatible: "cavium,octeon-5750-bootbus-dma"
9
10 Compatibility with all cn52XX, cn56XX and cn6XXX SOCs.
11
12- reg: The base address of the DMA Engine's register bank.
13
14- interrupts: A single interrupt specifier.
15
16Example:
17 dma0: dma-engine@1180000000100 {
18 compatible = "cavium,octeon-5750-bootbus-dma";
19 reg = <0x11800 0x00000100 0x0 0x8>;
20 interrupts = <0 63>;
21 };
diff --git a/Documentation/devicetree/bindings/mips/cavium/uctl.txt b/Documentation/devicetree/bindings/mips/cavium/uctl.txt
new file mode 100644
index 000000000000..aa66b9b8d801
--- /dev/null
+++ b/Documentation/devicetree/bindings/mips/cavium/uctl.txt
@@ -0,0 +1,46 @@
1* UCTL USB controller glue
2
3Properties:
4- compatible: "cavium,octeon-6335-uctl"
5
6 Compatibility with all cn6XXX SOCs.
7
8- reg: The base address of the UCTL register bank.
9
10- #address-cells: Must be <2>.
11
12- #size-cells: Must be <2>.
13
14- ranges: Empty to signify direct mapping of the children.
15
16- refclk-frequency: A single cell containing the reference clock
17 frequency in Hz.
18
19- refclk-type: A string describing the reference clock connection
20 either "crystal" or "external".
21
22Example:
23 uctl@118006f000000 {
24 compatible = "cavium,octeon-6335-uctl";
25 reg = <0x11800 0x6f000000 0x0 0x100>;
26 ranges; /* Direct mapping */
27 #address-cells = <2>;
28 #size-cells = <2>;
29 /* 12MHz, 24MHz and 48MHz allowed */
30 refclk-frequency = <24000000>;
31 /* Either "crystal" or "external" */
32 refclk-type = "crystal";
33
34 ehci@16f0000000000 {
35 compatible = "cavium,octeon-6335-ehci","usb-ehci";
36 reg = <0x16f00 0x00000000 0x0 0x100>;
37 interrupts = <0 56>;
38 big-endian-regs;
39 };
40 ohci@16f0000000400 {
41 compatible = "cavium,octeon-6335-ohci","usb-ohci";
42 reg = <0x16f00 0x00000400 0x0 0x100>;
43 interrupts = <0 56>;
44 big-endian-regs;
45 };
46 };
diff --git a/Documentation/devicetree/bindings/net/cavium-mdio.txt b/Documentation/devicetree/bindings/net/cavium-mdio.txt
new file mode 100644
index 000000000000..04cb7491d232
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/cavium-mdio.txt
@@ -0,0 +1,27 @@
1* System Management Interface (SMI) / MDIO
2
3Properties:
4- compatible: "cavium,octeon-3860-mdio"
5
6 Compatibility with all cn3XXX, cn5XXX and cn6XXX SOCs.
7
8- reg: The base address of the MDIO bus controller register bank.
9
10- #address-cells: Must be <1>.
11
12- #size-cells: Must be <0>. MDIO addresses have no size component.
13
14Typically an MDIO bus might have several children.
15
16Example:
17 mdio@1180000001800 {
18 compatible = "cavium,octeon-3860-mdio";
19 #address-cells = <1>;
20 #size-cells = <0>;
21 reg = <0x11800 0x00001800 0x0 0x40>;
22
23 ethernet-phy@0 {
24 ...
25 reg = <0>;
26 };
27 };
diff --git a/Documentation/devicetree/bindings/net/cavium-mix.txt b/Documentation/devicetree/bindings/net/cavium-mix.txt
new file mode 100644
index 000000000000..5da628db68bf
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/cavium-mix.txt
@@ -0,0 +1,39 @@
1* MIX Ethernet controller.
2
3Properties:
4- compatible: "cavium,octeon-5750-mix"
5
6 Compatibility with all cn5XXX and cn6XXX SOCs populated with MIX
7 devices.
8
9- reg: The base addresses of four separate register banks. The first
10 bank contains the MIX registers. The second bank the corresponding
11 AGL registers. The third bank are the AGL registers shared by all
12 MIX devices present. The fourth bank is the AGL_PRT_CTL shared by
13 all MIX devices present.
14
15- cell-index: A single cell specifying which portion of the shared
16 register banks corresponds to this MIX device.
17
18- interrupts: Two interrupt specifiers. The first is the MIX
19 interrupt routing and the second the routing for the AGL interrupts.
20
21- mac-address: Optional, the MAC address to assign to the device.
22
23- local-mac-address: Optional, the MAC address to assign to the device
24 if mac-address is not specified.
25
26- phy-handle: Optional, a phandle for the PHY device connected to this device.
27
28Example:
29 ethernet@1070000100800 {
30 compatible = "cavium,octeon-5750-mix";
31 reg = <0x10700 0x00100800 0x0 0x100>, /* MIX */
32 <0x11800 0xE0000800 0x0 0x300>, /* AGL */
33 <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
34 <0x11800 0xE0002008 0x0 0x8>; /* AGL_PRT_CTL */
35 cell-index = <1>;
36 interrupts = <1 18>, < 1 46>;
37 local-mac-address = [ 00 0f b7 10 63 54 ];
38 phy-handle = <&phy1>;
39 };
diff --git a/Documentation/devicetree/bindings/net/cavium-pip.txt b/Documentation/devicetree/bindings/net/cavium-pip.txt
new file mode 100644
index 000000000000..d4c53ba04b3b
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/cavium-pip.txt
@@ -0,0 +1,98 @@
1* PIP Ethernet nexus.
2
3The PIP Ethernet nexus can control several data packet input/output
4devices. The devices have a two level grouping scheme. There may be
5several interfaces, and each interface may have several ports. These
6ports might be an individual Ethernet PHY.
7
8
9Properties for the PIP nexus:
10- compatible: "cavium,octeon-3860-pip"
11
12 Compatibility with all cn3XXX, cn5XXX and cn6XXX SOCs.
13
14- reg: The base address of the PIP's register bank.
15
16- #address-cells: Must be <1>.
17
18- #size-cells: Must be <0>.
19
20Properties for PIP interfaces which is a child the PIP nexus:
21- compatible: "cavium,octeon-3860-pip-interface"
22
23 Compatibility with all cn3XXX, cn5XXX and cn6XXX SOCs.
24
25- reg: The interface number.
26
27- #address-cells: Must be <1>.
28
29- #size-cells: Must be <0>.
30
31Properties for PIP port which is a child the PIP interface:
32- compatible: "cavium,octeon-3860-pip-port"
33
34 Compatibility with all cn3XXX, cn5XXX and cn6XXX SOCs.
35
36- reg: The port number within the interface group.
37
38- mac-address: Optional, the MAC address to assign to the device.
39
40- local-mac-address: Optional, the MAC address to assign to the device
41 if mac-address is not specified.
42
43- phy-handle: Optional, a phandle for the PHY device connected to this device.
44
45Example:
46
47 pip@11800a0000000 {
48 compatible = "cavium,octeon-3860-pip";
49 #address-cells = <1>;
50 #size-cells = <0>;
51 reg = <0x11800 0xa0000000 0x0 0x2000>;
52
53 interface@0 {
54 compatible = "cavium,octeon-3860-pip-interface";
55 #address-cells = <1>;
56 #size-cells = <0>;
57 reg = <0>; /* interface */
58
59 ethernet@0 {
60 compatible = "cavium,octeon-3860-pip-port";
61 reg = <0x0>; /* Port */
62 local-mac-address = [ 00 0f b7 10 63 60 ];
63 phy-handle = <&phy2>;
64 };
65 ethernet@1 {
66 compatible = "cavium,octeon-3860-pip-port";
67 reg = <0x1>; /* Port */
68 local-mac-address = [ 00 0f b7 10 63 61 ];
69 phy-handle = <&phy3>;
70 };
71 ethernet@2 {
72 compatible = "cavium,octeon-3860-pip-port";
73 reg = <0x2>; /* Port */
74 local-mac-address = [ 00 0f b7 10 63 62 ];
75 phy-handle = <&phy4>;
76 };
77 ethernet@3 {
78 compatible = "cavium,octeon-3860-pip-port";
79 reg = <0x3>; /* Port */
80 local-mac-address = [ 00 0f b7 10 63 63 ];
81 phy-handle = <&phy5>;
82 };
83 };
84
85 interface@1 {
86 compatible = "cavium,octeon-3860-pip-interface";
87 #address-cells = <1>;
88 #size-cells = <0>;
89 reg = <1>; /* interface */
90
91 ethernet@0 {
92 compatible = "cavium,octeon-3860-pip-port";
93 reg = <0x0>; /* Port */
94 local-mac-address = [ 00 0f b7 10 63 64 ];
95 phy-handle = <&phy6>;
96 };
97 };
98 };
diff --git a/Documentation/devicetree/bindings/pwm/lpc32xx-pwm.txt b/Documentation/devicetree/bindings/pwm/lpc32xx-pwm.txt
new file mode 100644
index 000000000000..cfe1db3bb6e9
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/lpc32xx-pwm.txt
@@ -0,0 +1,12 @@
1LPC32XX PWM controller
2
3Required properties:
4- compatible: should be "nxp,lpc3220-pwm"
5- reg: physical base address and length of the controller's registers
6
7Examples:
8
9pwm@0x4005C000 {
10 compatible = "nxp,lpc3220-pwm";
11 reg = <0x4005C000 0x8>;
12};
diff --git a/Documentation/devicetree/bindings/pwm/mxs-pwm.txt b/Documentation/devicetree/bindings/pwm/mxs-pwm.txt
new file mode 100644
index 000000000000..b16f4a57d111
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/mxs-pwm.txt
@@ -0,0 +1,17 @@
1Freescale MXS PWM controller
2
3Required properties:
4- compatible: should be "fsl,imx23-pwm"
5- reg: physical base address and length of the controller's registers
6- #pwm-cells: should be 2. The first cell specifies the per-chip index
7 of the PWM to use and the second cell is the duty cycle in nanoseconds.
8- fsl,pwm-number: the number of PWM devices
9
10Example:
11
12pwm: pwm@80064000 {
13 compatible = "fsl,imx28-pwm", "fsl,imx23-pwm";
14 reg = <0x80064000 2000>;
15 #pwm-cells = <2>;
16 fsl,pwm-number = <8>;
17};
diff --git a/Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt b/Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt
new file mode 100644
index 000000000000..bbbeedb4ec05
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt
@@ -0,0 +1,18 @@
1Tegra SoC PWFM controller
2
3Required properties:
4- compatible: should be one of:
5 - "nvidia,tegra20-pwm"
6 - "nvidia,tegra30-pwm"
7- reg: physical base address and length of the controller's registers
8- #pwm-cells: On Tegra the number of cells used to specify a PWM is 2. The
9 first cell specifies the per-chip index of the PWM to use and the second
10 cell is the duty cycle in nanoseconds.
11
12Example:
13
14 pwm: pwm@7000a000 {
15 compatible = "nvidia,tegra20-pwm";
16 reg = <0x7000a000 0x100>;
17 #pwm-cells = <2>;
18 };
diff --git a/Documentation/devicetree/bindings/pwm/pwm.txt b/Documentation/devicetree/bindings/pwm/pwm.txt
new file mode 100644
index 000000000000..73ec962bfe8c
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/pwm.txt
@@ -0,0 +1,57 @@
1Specifying PWM information for devices
2======================================
3
41) PWM user nodes
5-----------------
6
7PWM users should specify a list of PWM devices that they want to use
8with a property containing a 'pwm-list':
9
10 pwm-list ::= <single-pwm> [pwm-list]
11 single-pwm ::= <pwm-phandle> <pwm-specifier>
12 pwm-phandle : phandle to PWM controller node
13 pwm-specifier : array of #pwm-cells specifying the given PWM
14 (controller specific)
15
16PWM properties should be named "pwms". The exact meaning of each pwms
17property must be documented in the device tree binding for each device.
18An optional property "pwm-names" may contain a list of strings to label
19each of the PWM devices listed in the "pwms" property. If no "pwm-names"
20property is given, the name of the user node will be used as fallback.
21
22Drivers for devices that use more than a single PWM device can use the
23"pwm-names" property to map the name of the PWM device requested by the
24pwm_get() call to an index into the list given by the "pwms" property.
25
26The following example could be used to describe a PWM-based backlight
27device:
28
29 pwm: pwm {
30 #pwm-cells = <2>;
31 };
32
33 [...]
34
35 bl: backlight {
36 pwms = <&pwm 0 5000000>;
37 pwm-names = "backlight";
38 };
39
40pwm-specifier typically encodes the chip-relative PWM number and the PWM
41period in nanoseconds. Note that in the example above, specifying the
42"pwm-names" is redundant because the name "backlight" would be used as
43fallback anyway.
44
452) PWM controller nodes
46-----------------------
47
48PWM controller nodes must specify the number of cells used for the
49specifier using the '#pwm-cells' property.
50
51An example PWM controller might look like this:
52
53 pwm: pwm@7000a000 {
54 compatible = "nvidia,tegra20-pwm";
55 reg = <0x7000a000 0x100>;
56 #pwm-cells = <2>;
57 };
diff --git a/Documentation/devicetree/bindings/serial/cavium-uart.txt b/Documentation/devicetree/bindings/serial/cavium-uart.txt
new file mode 100644
index 000000000000..87a6c375cd44
--- /dev/null
+++ b/Documentation/devicetree/bindings/serial/cavium-uart.txt
@@ -0,0 +1,19 @@
1* Universal Asynchronous Receiver/Transmitter (UART)
2
3- compatible: "cavium,octeon-3860-uart"
4
5 Compatibility with all cn3XXX, cn5XXX and cn6XXX SOCs.
6
7- reg: The base address of the UART register bank.
8
9- interrupts: A single interrupt specifier.
10
11- current-speed: Optional, the current bit rate in bits per second.
12
13Example:
14 uart1: serial@1180000000c00 {
15 compatible = "cavium,octeon-3860-uart","ns16550";
16 reg = <0x11800 0x00000c00 0x0 0x400>;
17 current-speed = <115200>;
18 interrupts = <0 35>;
19 };
diff --git a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt
new file mode 100644
index 000000000000..1e4fc727f3b1
--- /dev/null
+++ b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt
@@ -0,0 +1,28 @@
1pwm-backlight bindings
2
3Required properties:
4 - compatible: "pwm-backlight"
5 - pwms: OF device-tree PWM specification (see PWM binding[0])
6 - brightness-levels: Array of distinct brightness levels. Typically these
7 are in the range from 0 to 255, but any range starting at 0 will do.
8 The actual brightness level (PWM duty cycle) will be interpolated
9 from these values. 0 means a 0% duty cycle (darkest/off), while the
10 last value in the array represents a 100% duty cycle (brightest).
11 - default-brightness-level: the default brightness level (index into the
12 array defined by the "brightness-levels" property)
13
14Optional properties:
15 - pwm-names: a list of names for the PWM devices specified in the
16 "pwms" property (see PWM binding[0])
17
18[0]: Documentation/devicetree/bindings/pwm/pwm.txt
19
20Example:
21
22 backlight {
23 compatible = "pwm-backlight";
24 pwms = <&pwm 0 5000000>;
25
26 brightness-levels = <0 4 8 16 32 64 128 255>;
27 default-brightness-level = <6>;
28 };
diff --git a/Documentation/dontdiff b/Documentation/dontdiff
index b4a898f43c37..39462cf35cd4 100644
--- a/Documentation/dontdiff
+++ b/Documentation/dontdiff
@@ -150,7 +150,6 @@ keywords.c
150ksym.c* 150ksym.c*
151ksym.h* 151ksym.h*
152kxgettext 152kxgettext
153lkc_defs.h
154lex.c 153lex.c
155lex.*.c 154lex.*.c
156linux 155linux
diff --git a/Documentation/edac.txt b/Documentation/edac.txt
index 03df2b020332..56c7e936430f 100644
--- a/Documentation/edac.txt
+++ b/Documentation/edac.txt
@@ -232,116 +232,20 @@ EDAC control and attribute files.
232 232
233 233
234In 'mcX' directories are EDAC control and attribute files for 234In 'mcX' directories are EDAC control and attribute files for
235this 'X' instance of the memory controllers: 235this 'X' instance of the memory controllers.
236
237
238Counter reset control file:
239
240 'reset_counters'
241
242 This write-only control file will zero all the statistical counters
243 for UE and CE errors. Zeroing the counters will also reset the timer
244 indicating how long since the last counter zero. This is useful
245 for computing errors/time. Since the counters are always reset at
246 driver initialization time, no module/kernel parameter is available.
247
248 RUN TIME: echo "anything" >/sys/devices/system/edac/mc/mc0/counter_reset
249
250 This resets the counters on memory controller 0
251
252
253Seconds since last counter reset control file:
254
255 'seconds_since_reset'
256
257 This attribute file displays how many seconds have elapsed since the
258 last counter reset. This can be used with the error counters to
259 measure error rates.
260
261
262
263Memory Controller name attribute file:
264
265 'mc_name'
266
267 This attribute file displays the type of memory controller
268 that is being utilized.
269
270
271Total memory managed by this memory controller attribute file:
272
273 'size_mb'
274
275 This attribute file displays, in count of megabytes, of memory
276 that this instance of memory controller manages.
277
278
279Total Uncorrectable Errors count attribute file:
280
281 'ue_count'
282
283 This attribute file displays the total count of uncorrectable
284 errors that have occurred on this memory controller. If panic_on_ue
285 is set this counter will not have a chance to increment,
286 since EDAC will panic the system.
287
288
289Total UE count that had no information attribute fileY:
290
291 'ue_noinfo_count'
292
293 This attribute file displays the number of UEs that have occurred
294 with no information as to which DIMM slot is having errors.
295
296
297Total Correctable Errors count attribute file:
298
299 'ce_count'
300
301 This attribute file displays the total count of correctable
302 errors that have occurred on this memory controller. This
303 count is very important to examine. CEs provide early
304 indications that a DIMM is beginning to fail. This count
305 field should be monitored for non-zero values and report
306 such information to the system administrator.
307
308
309Total Correctable Errors count attribute file:
310
311 'ce_noinfo_count'
312
313 This attribute file displays the number of CEs that
314 have occurred wherewith no information as to which DIMM slot
315 is having errors. Memory is handicapped, but operational,
316 yet no information is available to indicate which slot
317 the failing memory is in. This count field should be also
318 be monitored for non-zero values.
319
320Device Symlink:
321
322 'device'
323
324 Symlink to the memory controller device.
325
326Sdram memory scrubbing rate:
327
328 'sdram_scrub_rate'
329
330 Read/Write attribute file that controls memory scrubbing. The scrubbing
331 rate is set by writing a minimum bandwidth in bytes/sec to the attribute
332 file. The rate will be translated to an internal value that gives at
333 least the specified rate.
334
335 Reading the file will return the actual scrubbing rate employed.
336
337 If configuration fails or memory scrubbing is not implemented, accessing
338 that attribute will fail.
339 236
237For a description of the sysfs API, please see:
238 Documentation/ABI/testing/sysfs/devices-edac
340 239
341 240
342============================================================================ 241============================================================================
343'csrowX' DIRECTORIES 242'csrowX' DIRECTORIES
344 243
244When CONFIG_EDAC_LEGACY_SYSFS is enabled, the sysfs will contain the
245csrowX directories. As this API doesn't work properly for Rambus, FB-DIMMs
246and modern Intel Memory Controllers, this is being deprecated in favor
247of dimmX directories.
248
345In the 'csrowX' directories are EDAC control and attribute files for 249In the 'csrowX' directories are EDAC control and attribute files for
346this 'X' instance of csrow: 250this 'X' instance of csrow:
347 251
diff --git a/Documentation/input/edt-ft5x06.txt b/Documentation/input/edt-ft5x06.txt
new file mode 100644
index 000000000000..2032f0b7a8fa
--- /dev/null
+++ b/Documentation/input/edt-ft5x06.txt
@@ -0,0 +1,54 @@
1EDT ft5x06 based Polytouch devices
2----------------------------------
3
4The edt-ft5x06 driver is useful for the EDT "Polytouch" family of capacitive
5touch screens. Note that it is *not* suitable for other devices based on the
6focaltec ft5x06 devices, since they contain vendor-specific firmware. In
7particular this driver is not suitable for the Nook tablet.
8
9It has been tested with the following devices:
10 * EP0350M06
11 * EP0430M06
12 * EP0570M06
13 * EP0700M06
14
15The driver allows configuration of the touch screen via a set of sysfs files:
16
17/sys/class/input/eventX/device/device/threshold:
18 allows setting the "click"-threshold in the range from 20 to 80.
19
20/sys/class/input/eventX/device/device/gain:
21 allows setting the sensitivity in the range from 0 to 31. Note that
22 lower values indicate higher sensitivity.
23
24/sys/class/input/eventX/device/device/offset:
25 allows setting the edge compensation in the range from 0 to 31.
26
27/sys/class/input/eventX/device/device/report_rate:
28 allows setting the report rate in the range from 3 to 14.
29
30
31For debugging purposes the driver provides a few files in the debug
32filesystem (if available in the kernel). In /sys/kernel/debug/edt_ft5x06
33you'll find the following files:
34
35num_x, num_y:
36 (readonly) contains the number of sensor fields in X- and
37 Y-direction.
38
39mode:
40 allows switching the sensor between "factory mode" and "operation
41 mode" by writing "1" or "0" to it. In factory mode (1) it is
42 possible to get the raw data from the sensor. Note that in factory
43 mode regular events don't get delivered and the options described
44 above are unavailable.
45
46raw_data:
47 contains num_x * num_y big endian 16 bit values describing the raw
48 values for each sensor field. Note that each read() call on this
49 files triggers a new readout. It is recommended to provide a buffer
50 big enough to contain num_x * num_y * 2 bytes.
51
52Note that reading raw_data gives a I/O error when the device is not in factory
53mode. The same happens when reading/writing to the parameter files when the
54device is not in regular operation mode.
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index c2619ef44a72..ad7e2e5088c1 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -526,7 +526,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
526 526
527 coherent_pool=nn[KMG] [ARM,KNL] 527 coherent_pool=nn[KMG] [ARM,KNL]
528 Sets the size of memory pool for coherent, atomic dma 528 Sets the size of memory pool for coherent, atomic dma
529 allocations if Contiguous Memory Allocator (CMA) is used. 529 allocations, by default set to 256K.
530 530
531 code_bytes [X86] How many bytes of object code to print 531 code_bytes [X86] How many bytes of object code to print
532 in an oops report. 532 in an oops report.
diff --git a/Documentation/pwm.txt b/Documentation/pwm.txt
new file mode 100644
index 000000000000..554290ebab94
--- /dev/null
+++ b/Documentation/pwm.txt
@@ -0,0 +1,76 @@
1Pulse Width Modulation (PWM) interface
2
3This provides an overview about the Linux PWM interface
4
5PWMs are commonly used for controlling LEDs, fans or vibrators in
6cell phones. PWMs with a fixed purpose have no need implementing
7the Linux PWM API (although they could). However, PWMs are often
8found as discrete devices on SoCs which have no fixed purpose. It's
9up to the board designer to connect them to LEDs or fans. To provide
10this kind of flexibility the generic PWM API exists.
11
12Identifying PWMs
13----------------
14
15Users of the legacy PWM API use unique IDs to refer to PWM devices.
16
17Instead of referring to a PWM device via its unique ID, board setup code
18should instead register a static mapping that can be used to match PWM
19consumers to providers, as given in the following example:
20
21 static struct pwm_lookup board_pwm_lookup[] = {
22 PWM_LOOKUP("tegra-pwm", 0, "pwm-backlight", NULL),
23 };
24
25 static void __init board_init(void)
26 {
27 ...
28 pwm_add_table(board_pwm_lookup, ARRAY_SIZE(board_pwm_lookup));
29 ...
30 }
31
32Using PWMs
33----------
34
35Legacy users can request a PWM device using pwm_request() and free it
36after usage with pwm_free().
37
38New users should use the pwm_get() function and pass to it the consumer
39device or a consumer name. pwm_put() is used to free the PWM device.
40
41After being requested a PWM has to be configured using:
42
43int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns);
44
45To start/stop toggling the PWM output use pwm_enable()/pwm_disable().
46
47Implementing a PWM driver
48-------------------------
49
50Currently there are two ways to implement pwm drivers. Traditionally
51there only has been the barebone API meaning that each driver has
52to implement the pwm_*() functions itself. This means that it's impossible
53to have multiple PWM drivers in the system. For this reason it's mandatory
54for new drivers to use the generic PWM framework.
55
56A new PWM controller/chip can be added using pwmchip_add() and removed
57again with pwmchip_remove(). pwmchip_add() takes a filled in struct
58pwm_chip as argument which provides a description of the PWM chip, the
59number of PWM devices provider by the chip and the chip-specific
60implementation of the supported PWM operations to the framework.
61
62Locking
63-------
64
65The PWM core list manipulations are protected by a mutex, so pwm_request()
66and pwm_free() may not be called from an atomic context. Currently the
67PWM core does not enforce any locking to pwm_enable(), pwm_disable() and
68pwm_config(), so the calling context is currently driver specific. This
69is an issue derived from the former barebone API and should be fixed soon.
70
71Helpers
72-------
73
74Currently a PWM can only be configured with period_ns and duty_ns. For several
75use cases freq_hz and duty_percent might be better. Instead of calculating
76this in your driver please consider adding appropriate helpers to the framework.
diff --git a/MAINTAINERS b/MAINTAINERS
index c8804c048ac8..b2e3d88ff4cd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5527,6 +5527,18 @@ S: Maintained
5527F: Documentation/video4linux/README.pvrusb2 5527F: Documentation/video4linux/README.pvrusb2
5528F: drivers/media/video/pvrusb2/ 5528F: drivers/media/video/pvrusb2/
5529 5529
5530PWM SUBSYSTEM
5531M: Thierry Reding <thierry.reding@avionic-design.de>
5532L: linux-kernel@vger.kernel.org
5533S: Maintained
5534W: http://gitorious.org/linux-pwm
5535T: git git://gitorious.org/linux-pwm/linux-pwm.git
5536F: Documentation/pwm.txt
5537F: Documentation/devicetree/bindings/pwm/
5538F: include/linux/pwm.h
5539F: include/linux/of_pwm.h
5540F: drivers/pwm/
5541
5530PXA2xx/PXA3xx SUPPORT 5542PXA2xx/PXA3xx SUPPORT
5531M: Eric Miao <eric.y.miao@gmail.com> 5543M: Eric Miao <eric.y.miao@gmail.com>
5532M: Russell King <linux@arm.linux.org.uk> 5544M: Russell King <linux@arm.linux.org.uk>
@@ -5901,6 +5913,16 @@ L: linux-fbdev@vger.kernel.org
5901S: Maintained 5913S: Maintained
5902F: drivers/video/s3c-fb.c 5914F: drivers/video/s3c-fb.c
5903 5915
5916SAMSUNG MULTIFUNCTION DEVICE DRIVERS
5917M: Sangbeom Kim <sbkim73@samsung.com>
5918L: linux-kernel@vger.kernel.org
5919S: Supported
5920F: drivers/mfd/sec*.c
5921F: drivers/regulator/s2m*.c
5922F: drivers/regulator/s5m*.c
5923F: drivers/rtc/rtc-sec.c
5924F: include/linux/mfd/samsung/
5925
5904SERIAL DRIVERS 5926SERIAL DRIVERS
5905M: Alan Cox <alan@linux.intel.com> 5927M: Alan Cox <alan@linux.intel.com>
5906L: linux-serial@vger.kernel.org 5928L: linux-serial@vger.kernel.org
diff --git a/Makefile b/Makefile
index 4bb09e1b1230..8e4c0a7d402b 100644
--- a/Makefile
+++ b/Makefile
@@ -535,11 +535,11 @@ PHONY += include/config/auto.conf
535 535
536include/config/auto.conf: 536include/config/auto.conf:
537 $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \ 537 $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \
538 echo; \ 538 echo >&2; \
539 echo " ERROR: Kernel configuration is invalid."; \ 539 echo >&2 " ERROR: Kernel configuration is invalid."; \
540 echo " include/generated/autoconf.h or $@ are missing.";\ 540 echo >&2 " include/generated/autoconf.h or $@ are missing.";\
541 echo " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ 541 echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
542 echo; \ 542 echo >&2 ; \
543 /bin/false) 543 /bin/false)
544 544
545endif # KBUILD_EXTMOD 545endif # KBUILD_EXTMOD
@@ -796,8 +796,8 @@ prepare3: include/config/kernel.release
796ifneq ($(KBUILD_SRC),) 796ifneq ($(KBUILD_SRC),)
797 @$(kecho) ' Using $(srctree) as source for kernel' 797 @$(kecho) ' Using $(srctree) as source for kernel'
798 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \ 798 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
799 echo " $(srctree) is not clean, please run 'make mrproper'"; \ 799 echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \
800 echo " in the '$(srctree)' directory.";\ 800 echo >&2 " in the '$(srctree)' directory.";\
801 /bin/false; \ 801 /bin/false; \
802 fi; 802 fi;
803endif 803endif
@@ -971,11 +971,11 @@ else # CONFIG_MODULES
971# --------------------------------------------------------------------------- 971# ---------------------------------------------------------------------------
972 972
973modules modules_install: FORCE 973modules modules_install: FORCE
974 @echo 974 @echo >&2
975 @echo "The present kernel configuration has modules disabled." 975 @echo >&2 "The present kernel configuration has modules disabled."
976 @echo "Type 'make config' and enable loadable module support." 976 @echo >&2 "Type 'make config' and enable loadable module support."
977 @echo "Then build a kernel with module support enabled." 977 @echo >&2 "Then build a kernel with module support enabled."
978 @echo 978 @echo >&2
979 @exit 1 979 @exit 1
980 980
981endif # CONFIG_MODULES 981endif # CONFIG_MODULES
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5df11147be84..7980873525b2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1011,7 +1011,6 @@ config ARCH_VT8500
1011 select ARCH_HAS_CPUFREQ 1011 select ARCH_HAS_CPUFREQ
1012 select GENERIC_CLOCKEVENTS 1012 select GENERIC_CLOCKEVENTS
1013 select ARCH_REQUIRE_GPIOLIB 1013 select ARCH_REQUIRE_GPIOLIB
1014 select HAVE_PWM
1015 help 1014 help
1016 Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. 1015 Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip.
1017 1016
diff --git a/arch/arm/boot/dts/highbank.dts b/arch/arm/boot/dts/highbank.dts
index 2e1cfa00c25b..9fecf1ae777b 100644
--- a/arch/arm/boot/dts/highbank.dts
+++ b/arch/arm/boot/dts/highbank.dts
@@ -130,6 +130,12 @@
130 clocks = <&eclk>; 130 clocks = <&eclk>;
131 }; 131 };
132 132
133 memory-controller@fff00000 {
134 compatible = "calxeda,hb-ddr-ctrl";
135 reg = <0xfff00000 0x1000>;
136 interrupts = <0 91 4>;
137 };
138
133 ipc@fff20000 { 139 ipc@fff20000 {
134 compatible = "arm,pl320", "arm,primecell"; 140 compatible = "arm,pl320", "arm,primecell";
135 reg = <0xfff20000 0x1000>; 141 reg = <0xfff20000 0x1000>;
@@ -275,6 +281,12 @@
275 }; 281 };
276 }; 282 };
277 283
284 sregs@fff3c200 {
285 compatible = "calxeda,hb-sregs-l2-ecc";
286 reg = <0xfff3c200 0x100>;
287 interrupts = <0 71 4 0 72 4>;
288 };
289
278 dma@fff3d000 { 290 dma@fff3d000 {
279 compatible = "arm,pl330", "arm,primecell"; 291 compatible = "arm,pl330", "arm,primecell";
280 reg = <0xfff3d000 0x1000>; 292 reg = <0xfff3d000 0x1000>;
diff --git a/arch/arm/boot/dts/r8a7740.dtsi b/arch/arm/boot/dts/r8a7740.dtsi
new file mode 100644
index 000000000000..798fa35c0005
--- /dev/null
+++ b/arch/arm/boot/dts/r8a7740.dtsi
@@ -0,0 +1,21 @@
1/*
2 * Device Tree Source for the r8a7740 SoC
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 */
10
11/include/ "skeleton.dtsi"
12
13/ {
14 compatible = "renesas,r8a7740";
15
16 cpus {
17 cpu@0 {
18 compatible = "arm,cortex-a9";
19 };
20 };
21};
diff --git a/arch/arm/boot/dts/sh7377.dtsi b/arch/arm/boot/dts/sh7377.dtsi
new file mode 100644
index 000000000000..767ee0796daa
--- /dev/null
+++ b/arch/arm/boot/dts/sh7377.dtsi
@@ -0,0 +1,21 @@
1/*
2 * Device Tree Source for the sh7377 SoC
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 */
10
11/include/ "skeleton.dtsi"
12
13/ {
14 compatible = "renesas,sh7377";
15
16 cpus {
17 cpu@0 {
18 compatible = "arm,cortex-a8";
19 };
20 };
21};
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index 9f1921634eb7..405d1673904e 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -123,6 +123,12 @@
123 status = "disabled"; 123 status = "disabled";
124 }; 124 };
125 125
126 pwm {
127 compatible = "nvidia,tegra20-pwm";
128 reg = <0x7000a000 0x100>;
129 #pwm-cells = <2>;
130 };
131
126 i2c@7000c000 { 132 i2c@7000c000 {
127 compatible = "nvidia,tegra20-i2c"; 133 compatible = "nvidia,tegra20-i2c";
128 reg = <0x7000c000 0x100>; 134 reg = <0x7000c000 0x100>;
diff --git a/arch/arm/boot/dts/tegra30.dtsi b/arch/arm/boot/dts/tegra30.dtsi
index da740191771f..3e4334d14efb 100644
--- a/arch/arm/boot/dts/tegra30.dtsi
+++ b/arch/arm/boot/dts/tegra30.dtsi
@@ -117,6 +117,12 @@
117 status = "disabled"; 117 status = "disabled";
118 }; 118 };
119 119
120 pwm {
121 compatible = "nvidia,tegra30-pwm", "nvidia,tegra20-pwm";
122 reg = <0x7000a000 0x100>;
123 #pwm-cells = <2>;
124 };
125
120 i2c@7000c000 { 126 i2c@7000c000 {
121 compatible = "nvidia,tegra30-i2c", "nvidia,tegra20-i2c"; 127 compatible = "nvidia,tegra30-i2c", "nvidia,tegra20-i2c";
122 reg = <0x7000c000 0x100>; 128 reg = <0x7000c000 0x100>;
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index aa07f5938f05..1143c4d5c567 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -452,6 +452,7 @@ static struct dma_map_ops dmabounce_ops = {
452 .alloc = arm_dma_alloc, 452 .alloc = arm_dma_alloc,
453 .free = arm_dma_free, 453 .free = arm_dma_free,
454 .mmap = arm_dma_mmap, 454 .mmap = arm_dma_mmap,
455 .get_sgtable = arm_dma_get_sgtable,
455 .map_page = dmabounce_map_page, 456 .map_page = dmabounce_map_page,
456 .unmap_page = dmabounce_unmap_page, 457 .unmap_page = dmabounce_unmap_page,
457 .sync_single_for_cpu = dmabounce_sync_for_cpu, 458 .sync_single_for_cpu = dmabounce_sync_for_cpu,
diff --git a/arch/arm/configs/armadillo800eva_defconfig b/arch/arm/configs/armadillo800eva_defconfig
index ddc9fe6a78ac..7d8718468e0d 100644
--- a/arch/arm/configs/armadillo800eva_defconfig
+++ b/arch/arm/configs/armadillo800eva_defconfig
@@ -5,10 +5,7 @@ CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=16 5CONFIG_LOG_BUF_SHIFT=16
6# CONFIG_UTS_NS is not set 6# CONFIG_UTS_NS is not set
7# CONFIG_IPC_NS is not set 7# CONFIG_IPC_NS is not set
8# CONFIG_USER_NS is not set
9# CONFIG_PID_NS is not set 8# CONFIG_PID_NS is not set
10CONFIG_SYSFS_DEPRECATED=y
11CONFIG_SYSFS_DEPRECATED_V2=y
12CONFIG_CC_OPTIMIZE_FOR_SIZE=y 9CONFIG_CC_OPTIMIZE_FOR_SIZE=y
13CONFIG_SLAB=y 10CONFIG_SLAB=y
14CONFIG_MODULES=y 11CONFIG_MODULES=y
@@ -21,7 +18,7 @@ CONFIG_ARCH_SHMOBILE=y
21CONFIG_ARCH_R8A7740=y 18CONFIG_ARCH_R8A7740=y
22CONFIG_MACH_ARMADILLO800EVA=y 19CONFIG_MACH_ARMADILLO800EVA=y
23# CONFIG_SH_TIMER_TMU is not set 20# CONFIG_SH_TIMER_TMU is not set
24# CONFIG_ARM_THUMB is not set 21CONFIG_ARM_THUMB=y
25CONFIG_CPU_BPREDICT_DISABLE=y 22CONFIG_CPU_BPREDICT_DISABLE=y
26# CONFIG_CACHE_L2X0 is not set 23# CONFIG_CACHE_L2X0 is not set
27CONFIG_ARM_ERRATA_430973=y 24CONFIG_ARM_ERRATA_430973=y
@@ -39,6 +36,7 @@ CONFIG_ZBOOT_ROM_BSS=0x0
39CONFIG_CMDLINE="console=tty0 console=ttySC1,115200 earlyprintk=sh-sci.1,115200 ignore_loglevel root=/dev/nfs ip=dhcp nfsroot=,rsize=4096,wsize=4096" 36CONFIG_CMDLINE="console=tty0 console=ttySC1,115200 earlyprintk=sh-sci.1,115200 ignore_loglevel root=/dev/nfs ip=dhcp nfsroot=,rsize=4096,wsize=4096"
40CONFIG_CMDLINE_FORCE=y 37CONFIG_CMDLINE_FORCE=y
41CONFIG_KEXEC=y 38CONFIG_KEXEC=y
39CONFIG_VFP=y
42# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 40# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
43# CONFIG_SUSPEND is not set 41# CONFIG_SUSPEND is not set
44CONFIG_NET=y 42CONFIG_NET=y
@@ -89,26 +87,32 @@ CONFIG_SERIAL_SH_SCI_CONSOLE=y
89CONFIG_I2C=y 87CONFIG_I2C=y
90CONFIG_I2C_SH_MOBILE=y 88CONFIG_I2C_SH_MOBILE=y
91# CONFIG_HWMON is not set 89# CONFIG_HWMON is not set
90CONFIG_MEDIA_SUPPORT=y
91CONFIG_VIDEO_DEV=y
92# CONFIG_RC_CORE is not set
93# CONFIG_VIDEO_HELPER_CHIPS_AUTO is not set
94# CONFIG_V4L_USB_DRIVERS is not set
95CONFIG_V4L_PLATFORM_DRIVERS=y
96CONFIG_SOC_CAMERA=y
97CONFIG_SOC_CAMERA_MT9T112=y
98CONFIG_VIDEO_SH_MOBILE_CEU=y
99# CONFIG_RADIO_ADAPTERS is not set
92CONFIG_FB=y 100CONFIG_FB=y
93CONFIG_FB_MODE_HELPERS=y
94CONFIG_FB_SH_MOBILE_LCDC=y 101CONFIG_FB_SH_MOBILE_LCDC=y
102CONFIG_FB_SH_MOBILE_HDMI=y
95CONFIG_LCD_CLASS_DEVICE=y 103CONFIG_LCD_CLASS_DEVICE=y
96CONFIG_FRAMEBUFFER_CONSOLE=y 104CONFIG_FRAMEBUFFER_CONSOLE=y
97CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y 105CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
98CONFIG_LOGO=y 106CONFIG_LOGO=y
99# CONFIG_LOGO_LINUX_MONO is not set 107# CONFIG_LOGO_LINUX_MONO is not set
100# CONFIG_LOGO_LINUX_VGA16 is not set 108# CONFIG_LOGO_LINUX_VGA16 is not set
101CONFIG_SOUND=y
102CONFIG_SND=y
103# CONFIG_SND_SUPPORT_OLD_API is not set 109# CONFIG_SND_SUPPORT_OLD_API is not set
104# CONFIG_SND_VERBOSE_PROCFS is not set 110# CONFIG_SND_VERBOSE_PROCFS is not set
105# CONFIG_SND_DRIVERS is not set 111# CONFIG_SND_DRIVERS is not set
106# CONFIG_SND_ARM is not set 112# CONFIG_SND_ARM is not set
107CONFIG_SND_SOC=y
108CONFIG_SND_SOC_SH4_FSI=y 113CONFIG_SND_SOC_SH4_FSI=y
109# CONFIG_HID_SUPPORT is not set 114# CONFIG_HID_SUPPORT is not set
110CONFIG_USB=y 115CONFIG_USB=y
111# CONFIG_USB_DEVICE_CLASS is not set
112CONFIG_USB_RENESAS_USBHS=y 116CONFIG_USB_RENESAS_USBHS=y
113CONFIG_USB_GADGET=y 117CONFIG_USB_GADGET=y
114CONFIG_USB_RENESAS_USBHS_UDC=y 118CONFIG_USB_RENESAS_USBHS_UDC=y
@@ -116,6 +120,8 @@ CONFIG_USB_ETH=m
116CONFIG_MMC=y 120CONFIG_MMC=y
117CONFIG_MMC_SDHI=y 121CONFIG_MMC_SDHI=y
118CONFIG_MMC_SH_MMCIF=y 122CONFIG_MMC_SH_MMCIF=y
123CONFIG_DMADEVICES=y
124CONFIG_SH_DMAE=y
119CONFIG_UIO=y 125CONFIG_UIO=y
120CONFIG_UIO_PDRV_GENIRQ=y 126CONFIG_UIO_PDRV_GENIRQ=y
121# CONFIG_DNOTIFY is not set 127# CONFIG_DNOTIFY is not set
@@ -124,7 +130,6 @@ CONFIG_VFAT_FS=y
124CONFIG_TMPFS=y 130CONFIG_TMPFS=y
125# CONFIG_MISC_FILESYSTEMS is not set 131# CONFIG_MISC_FILESYSTEMS is not set
126CONFIG_NFS_FS=y 132CONFIG_NFS_FS=y
127CONFIG_NFS_V3=y
128CONFIG_NFS_V3_ACL=y 133CONFIG_NFS_V3_ACL=y
129CONFIG_NFS_V4=y 134CONFIG_NFS_V4=y
130CONFIG_NFS_V4_1=y 135CONFIG_NFS_V4_1=y
diff --git a/arch/arm/configs/kzm9d_defconfig b/arch/arm/configs/kzm9d_defconfig
new file mode 100644
index 000000000000..26146ffea1a5
--- /dev/null
+++ b/arch/arm/configs/kzm9d_defconfig
@@ -0,0 +1,89 @@
1# CONFIG_ARM_PATCH_PHYS_VIRT is not set
2CONFIG_EXPERIMENTAL=y
3CONFIG_SYSVIPC=y
4CONFIG_NO_HZ=y
5CONFIG_IKCONFIG=y
6CONFIG_IKCONFIG_PROC=y
7CONFIG_LOG_BUF_SHIFT=16
8CONFIG_CC_OPTIMIZE_FOR_SIZE=y
9CONFIG_SYSCTL_SYSCALL=y
10CONFIG_EMBEDDED=y
11CONFIG_SLAB=y
12# CONFIG_BLK_DEV_BSG is not set
13# CONFIG_IOSCHED_DEADLINE is not set
14# CONFIG_IOSCHED_CFQ is not set
15CONFIG_ARCH_SHMOBILE=y
16CONFIG_ARCH_EMEV2=y
17CONFIG_MACH_KZM9D=y
18CONFIG_MEMORY_START=0x40000000
19CONFIG_MEMORY_SIZE=0x10000000
20# CONFIG_SH_TIMER_TMU is not set
21# CONFIG_SWP_EMULATE is not set
22# CONFIG_CACHE_L2X0 is not set
23CONFIG_SMP=y
24CONFIG_NR_CPUS=2
25CONFIG_HOTPLUG_CPU=y
26# CONFIG_LOCAL_TIMERS is not set
27CONFIG_AEABI=y
28# CONFIG_OABI_COMPAT is not set
29# CONFIG_CROSS_MEMORY_ATTACH is not set
30CONFIG_FORCE_MAX_ZONEORDER=13
31CONFIG_ZBOOT_ROM_TEXT=0x0
32CONFIG_ZBOOT_ROM_BSS=0x0
33CONFIG_ARM_APPENDED_DTB=y
34CONFIG_CMDLINE="console=tty0 console=ttyS1,115200n81 earlyprintk=serial8250-em.1,115200n81 mem=128M@0x40000000 ignore_loglevel root=/dev/nfs ip=dhcp nfsroot=,rsize=4096,wsize=4096"
35CONFIG_CMDLINE_FORCE=y
36CONFIG_VFP=y
37# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
38# CONFIG_SUSPEND is not set
39CONFIG_NET=y
40CONFIG_PACKET=y
41CONFIG_UNIX=y
42CONFIG_INET=y
43CONFIG_IP_PNP=y
44CONFIG_IP_PNP_DHCP=y
45# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
46# CONFIG_INET_XFRM_MODE_TUNNEL is not set
47# CONFIG_INET_XFRM_MODE_BEET is not set
48# CONFIG_INET_LRO is not set
49# CONFIG_INET_DIAG is not set
50# CONFIG_IPV6 is not set
51# CONFIG_WIRELESS is not set
52CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
53# CONFIG_BLK_DEV is not set
54CONFIG_NETDEVICES=y
55# CONFIG_NET_VENDOR_BROADCOM is not set
56# CONFIG_NET_VENDOR_CHELSIO is not set
57# CONFIG_NET_VENDOR_CIRRUS is not set
58# CONFIG_NET_VENDOR_FARADAY is not set
59# CONFIG_NET_VENDOR_INTEL is not set
60# CONFIG_NET_VENDOR_MARVELL is not set
61# CONFIG_NET_VENDOR_MICREL is not set
62# CONFIG_NET_VENDOR_NATSEMI is not set
63# CONFIG_NET_VENDOR_SEEQ is not set
64CONFIG_SMSC911X=y
65# CONFIG_NET_VENDOR_STMICRO is not set
66# CONFIG_NET_VENDOR_WIZNET is not set
67# CONFIG_WLAN is not set
68# CONFIG_INPUT_MOUSEDEV is not set
69# CONFIG_INPUT_KEYBOARD is not set
70# CONFIG_INPUT_MOUSE is not set
71# CONFIG_SERIO is not set
72# CONFIG_LEGACY_PTYS is not set
73# CONFIG_DEVKMEM is not set
74CONFIG_SERIAL_8250=y
75CONFIG_SERIAL_8250_CONSOLE=y
76CONFIG_SERIAL_8250_EM=y
77# CONFIG_HW_RANDOM is not set
78CONFIG_GPIOLIB=y
79CONFIG_GPIO_EM=y
80# CONFIG_HWMON is not set
81# CONFIG_HID_SUPPORT is not set
82# CONFIG_USB_SUPPORT is not set
83# CONFIG_IOMMU_SUPPORT is not set
84# CONFIG_DNOTIFY is not set
85CONFIG_TMPFS=y
86# CONFIG_MISC_FILESYSTEMS is not set
87CONFIG_NFS_FS=y
88CONFIG_ROOT_NFS=y
89# CONFIG_FTRACE is not set
diff --git a/arch/arm/configs/kzm9g_defconfig b/arch/arm/configs/kzm9g_defconfig
index e3ebc20ed0a7..2388c8610627 100644
--- a/arch/arm/configs/kzm9g_defconfig
+++ b/arch/arm/configs/kzm9g_defconfig
@@ -100,7 +100,12 @@ CONFIG_SND_SOC_SH4_FSI=y
100CONFIG_USB=y 100CONFIG_USB=y
101CONFIG_USB_DEVICEFS=y 101CONFIG_USB_DEVICEFS=y
102CONFIG_USB_R8A66597_HCD=y 102CONFIG_USB_R8A66597_HCD=y
103CONFIG_USB_RENESAS_USBHS=y
103CONFIG_USB_STORAGE=y 104CONFIG_USB_STORAGE=y
105CONFIG_USB_GADGET=y
106CONFIG_USB_RENESAS_USBHS_UDC=y
107CONFIG_USB_ETH=m
108CONFIG_USB_MASS_STORAGE=m
104CONFIG_MMC=y 109CONFIG_MMC=y
105# CONFIG_MMC_BLOCK_BOUNCE is not set 110# CONFIG_MMC_BLOCK_BOUNCE is not set
106CONFIG_MMC_SDHI=y 111CONFIG_MMC_SDHI=y
@@ -108,12 +113,13 @@ CONFIG_MMC_SH_MMCIF=y
108CONFIG_NEW_LEDS=y 113CONFIG_NEW_LEDS=y
109CONFIG_LEDS_CLASS=y 114CONFIG_LEDS_CLASS=y
110CONFIG_RTC_CLASS=y 115CONFIG_RTC_CLASS=y
116CONFIG_RTC_DRV_RS5C372=y
111CONFIG_DMADEVICES=y 117CONFIG_DMADEVICES=y
112CONFIG_SH_DMAE=y 118CONFIG_SH_DMAE=y
113CONFIG_ASYNC_TX_DMA=y 119CONFIG_ASYNC_TX_DMA=y
114CONFIG_STAGING=y 120CONFIG_STAGING=y
115# CONFIG_DNOTIFY is not set 121# CONFIG_DNOTIFY is not set
116# CONFIG_INOTIFY_USER is not set 122CONFIG_INOTIFY_USER=y
117CONFIG_VFAT_FS=y 123CONFIG_VFAT_FS=y
118CONFIG_TMPFS=y 124CONFIG_TMPFS=y
119# CONFIG_MISC_FILESYSTEMS is not set 125# CONFIG_MISC_FILESYSTEMS is not set
diff --git a/arch/arm/configs/tegra_defconfig b/arch/arm/configs/tegra_defconfig
index 4be9c1e80ee6..db2245353f0f 100644
--- a/arch/arm/configs/tegra_defconfig
+++ b/arch/arm/configs/tegra_defconfig
@@ -106,6 +106,7 @@ CONFIG_I2C_TEGRA=y
106CONFIG_SPI=y 106CONFIG_SPI=y
107CONFIG_SPI_TEGRA=y 107CONFIG_SPI_TEGRA=y
108CONFIG_GPIO_TPS65910=y 108CONFIG_GPIO_TPS65910=y
109CONFIG_GPIO_TPS6586X=y
109CONFIG_POWER_SUPPLY=y 110CONFIG_POWER_SUPPLY=y
110CONFIG_BATTERY_SBS=y 111CONFIG_BATTERY_SBS=y
111CONFIG_SENSORS_LM90=y 112CONFIG_SENSORS_LM90=y
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index bbef15d04890..2ae842df4551 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -186,17 +186,6 @@ extern int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma,
186 void *cpu_addr, dma_addr_t dma_addr, size_t size, 186 void *cpu_addr, dma_addr_t dma_addr, size_t size,
187 struct dma_attrs *attrs); 187 struct dma_attrs *attrs);
188 188
189#define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, NULL)
190
191static inline int dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
192 void *cpu_addr, dma_addr_t dma_addr,
193 size_t size, struct dma_attrs *attrs)
194{
195 struct dma_map_ops *ops = get_dma_ops(dev);
196 BUG_ON(!ops);
197 return ops->mmap(dev, vma, cpu_addr, dma_addr, size, attrs);
198}
199
200static inline void *dma_alloc_writecombine(struct device *dev, size_t size, 189static inline void *dma_alloc_writecombine(struct device *dev, size_t size,
201 dma_addr_t *dma_handle, gfp_t flag) 190 dma_addr_t *dma_handle, gfp_t flag)
202{ 191{
@@ -213,20 +202,12 @@ static inline void dma_free_writecombine(struct device *dev, size_t size,
213 return dma_free_attrs(dev, size, cpu_addr, dma_handle, &attrs); 202 return dma_free_attrs(dev, size, cpu_addr, dma_handle, &attrs);
214} 203}
215 204
216static inline int dma_mmap_writecombine(struct device *dev, struct vm_area_struct *vma,
217 void *cpu_addr, dma_addr_t dma_addr, size_t size)
218{
219 DEFINE_DMA_ATTRS(attrs);
220 dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
221 return dma_mmap_attrs(dev, vma, cpu_addr, dma_addr, size, &attrs);
222}
223
224/* 205/*
225 * This can be called during boot to increase the size of the consistent 206 * This can be called during boot to increase the size of the consistent
226 * DMA region above it's default value of 2MB. It must be called before the 207 * DMA region above it's default value of 2MB. It must be called before the
227 * memory allocator is initialised, i.e. before any core_initcall. 208 * memory allocator is initialised, i.e. before any core_initcall.
228 */ 209 */
229extern void __init init_consistent_dma_size(unsigned long size); 210static inline void init_consistent_dma_size(unsigned long size) { }
230 211
231/* 212/*
232 * For SA-1111, IXP425, and ADI systems the dma-mapping functions are "magic" 213 * For SA-1111, IXP425, and ADI systems the dma-mapping functions are "magic"
@@ -280,6 +261,9 @@ extern void arm_dma_sync_sg_for_cpu(struct device *, struct scatterlist *, int,
280 enum dma_data_direction); 261 enum dma_data_direction);
281extern void arm_dma_sync_sg_for_device(struct device *, struct scatterlist *, int, 262extern void arm_dma_sync_sg_for_device(struct device *, struct scatterlist *, int,
282 enum dma_data_direction); 263 enum dma_data_direction);
264extern int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt,
265 void *cpu_addr, dma_addr_t dma_addr, size_t size,
266 struct dma_attrs *attrs);
283 267
284#endif /* __KERNEL__ */ 268#endif /* __KERNEL__ */
285#endif 269#endif
diff --git a/arch/arm/mach-exynos/clock-exynos4.c b/arch/arm/mach-exynos/clock-exynos4.c
index 26fe9de35ecb..2f51293c1875 100644
--- a/arch/arm/mach-exynos/clock-exynos4.c
+++ b/arch/arm/mach-exynos/clock-exynos4.c
@@ -620,10 +620,6 @@ static struct clk exynos4_init_clocks_off[] = {
620 .enable = exynos4_clk_ip_peril_ctrl, 620 .enable = exynos4_clk_ip_peril_ctrl,
621 .ctrlbit = (1 << 27), 621 .ctrlbit = (1 << 27),
622 }, { 622 }, {
623 .name = "fimg2d",
624 .enable = exynos4_clk_ip_image_ctrl,
625 .ctrlbit = (1 << 0),
626 }, {
627 .name = "mfc", 623 .name = "mfc",
628 .devname = "s5p-mfc", 624 .devname = "s5p-mfc",
629 .enable = exynos4_clk_ip_mfc_ctrl, 625 .enable = exynos4_clk_ip_mfc_ctrl,
@@ -819,47 +815,21 @@ static struct clk *exynos4_clkset_mout_g2d0_list[] = {
819 [1] = &exynos4_clk_sclk_apll.clk, 815 [1] = &exynos4_clk_sclk_apll.clk,
820}; 816};
821 817
822static struct clksrc_sources exynos4_clkset_mout_g2d0 = { 818struct clksrc_sources exynos4_clkset_mout_g2d0 = {
823 .sources = exynos4_clkset_mout_g2d0_list, 819 .sources = exynos4_clkset_mout_g2d0_list,
824 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d0_list), 820 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d0_list),
825}; 821};
826 822
827static struct clksrc_clk exynos4_clk_mout_g2d0 = {
828 .clk = {
829 .name = "mout_g2d0",
830 },
831 .sources = &exynos4_clkset_mout_g2d0,
832 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 0, .size = 1 },
833};
834
835static struct clk *exynos4_clkset_mout_g2d1_list[] = { 823static struct clk *exynos4_clkset_mout_g2d1_list[] = {
836 [0] = &exynos4_clk_mout_epll.clk, 824 [0] = &exynos4_clk_mout_epll.clk,
837 [1] = &exynos4_clk_sclk_vpll.clk, 825 [1] = &exynos4_clk_sclk_vpll.clk,
838}; 826};
839 827
840static struct clksrc_sources exynos4_clkset_mout_g2d1 = { 828struct clksrc_sources exynos4_clkset_mout_g2d1 = {
841 .sources = exynos4_clkset_mout_g2d1_list, 829 .sources = exynos4_clkset_mout_g2d1_list,
842 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d1_list), 830 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d1_list),
843}; 831};
844 832
845static struct clksrc_clk exynos4_clk_mout_g2d1 = {
846 .clk = {
847 .name = "mout_g2d1",
848 },
849 .sources = &exynos4_clkset_mout_g2d1,
850 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 4, .size = 1 },
851};
852
853static struct clk *exynos4_clkset_mout_g2d_list[] = {
854 [0] = &exynos4_clk_mout_g2d0.clk,
855 [1] = &exynos4_clk_mout_g2d1.clk,
856};
857
858static struct clksrc_sources exynos4_clkset_mout_g2d = {
859 .sources = exynos4_clkset_mout_g2d_list,
860 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d_list),
861};
862
863static struct clk *exynos4_clkset_mout_mfc0_list[] = { 833static struct clk *exynos4_clkset_mout_mfc0_list[] = {
864 [0] = &exynos4_clk_mout_mpll.clk, 834 [0] = &exynos4_clk_mout_mpll.clk,
865 [1] = &exynos4_clk_sclk_apll.clk, 835 [1] = &exynos4_clk_sclk_apll.clk,
@@ -1126,13 +1096,6 @@ static struct clksrc_clk exynos4_clksrcs[] = {
1126 .reg_div = { .reg = EXYNOS4_CLKDIV_LCD0, .shift = 0, .size = 4 }, 1096 .reg_div = { .reg = EXYNOS4_CLKDIV_LCD0, .shift = 0, .size = 4 },
1127 }, { 1097 }, {
1128 .clk = { 1098 .clk = {
1129 .name = "sclk_fimg2d",
1130 },
1131 .sources = &exynos4_clkset_mout_g2d,
1132 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 8, .size = 1 },
1133 .reg_div = { .reg = EXYNOS4_CLKDIV_IMAGE, .shift = 0, .size = 4 },
1134 }, {
1135 .clk = {
1136 .name = "sclk_mfc", 1099 .name = "sclk_mfc",
1137 .devname = "s5p-mfc", 1100 .devname = "s5p-mfc",
1138 }, 1101 },
diff --git a/arch/arm/mach-exynos/clock-exynos4.h b/arch/arm/mach-exynos/clock-exynos4.h
index 28a119701182..bd12d5f8b63d 100644
--- a/arch/arm/mach-exynos/clock-exynos4.h
+++ b/arch/arm/mach-exynos/clock-exynos4.h
@@ -23,6 +23,9 @@ extern struct clksrc_sources exynos4_clkset_group;
23extern struct clk *exynos4_clkset_aclk_top_list[]; 23extern struct clk *exynos4_clkset_aclk_top_list[];
24extern struct clk *exynos4_clkset_group_list[]; 24extern struct clk *exynos4_clkset_group_list[];
25 25
26extern struct clksrc_sources exynos4_clkset_mout_g2d0;
27extern struct clksrc_sources exynos4_clkset_mout_g2d1;
28
26extern int exynos4_clksrc_mask_fsys_ctrl(struct clk *clk, int enable); 29extern int exynos4_clksrc_mask_fsys_ctrl(struct clk *clk, int enable);
27extern int exynos4_clk_ip_fsys_ctrl(struct clk *clk, int enable); 30extern int exynos4_clk_ip_fsys_ctrl(struct clk *clk, int enable);
28extern int exynos4_clk_ip_lcd1_ctrl(struct clk *clk, int enable); 31extern int exynos4_clk_ip_lcd1_ctrl(struct clk *clk, int enable);
diff --git a/arch/arm/mach-exynos/clock-exynos4210.c b/arch/arm/mach-exynos/clock-exynos4210.c
index b8689ff60baf..fed4c26e9dad 100644
--- a/arch/arm/mach-exynos/clock-exynos4210.c
+++ b/arch/arm/mach-exynos/clock-exynos4210.c
@@ -48,6 +48,32 @@ static struct clksrc_clk *sysclks[] = {
48 /* nothing here yet */ 48 /* nothing here yet */
49}; 49};
50 50
51static struct clksrc_clk exynos4210_clk_mout_g2d0 = {
52 .clk = {
53 .name = "mout_g2d0",
54 },
55 .sources = &exynos4_clkset_mout_g2d0,
56 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 0, .size = 1 },
57};
58
59static struct clksrc_clk exynos4210_clk_mout_g2d1 = {
60 .clk = {
61 .name = "mout_g2d1",
62 },
63 .sources = &exynos4_clkset_mout_g2d1,
64 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 4, .size = 1 },
65};
66
67static struct clk *exynos4210_clkset_mout_g2d_list[] = {
68 [0] = &exynos4210_clk_mout_g2d0.clk,
69 [1] = &exynos4210_clk_mout_g2d1.clk,
70};
71
72static struct clksrc_sources exynos4210_clkset_mout_g2d = {
73 .sources = exynos4210_clkset_mout_g2d_list,
74 .nr_sources = ARRAY_SIZE(exynos4210_clkset_mout_g2d_list),
75};
76
51static int exynos4_clksrc_mask_lcd1_ctrl(struct clk *clk, int enable) 77static int exynos4_clksrc_mask_lcd1_ctrl(struct clk *clk, int enable)
52{ 78{
53 return s5p_gatectrl(EXYNOS4210_CLKSRC_MASK_LCD1, clk, enable); 79 return s5p_gatectrl(EXYNOS4210_CLKSRC_MASK_LCD1, clk, enable);
@@ -74,6 +100,13 @@ static struct clksrc_clk clksrcs[] = {
74 .sources = &exynos4_clkset_group, 100 .sources = &exynos4_clkset_group,
75 .reg_src = { .reg = EXYNOS4210_CLKSRC_LCD1, .shift = 0, .size = 4 }, 101 .reg_src = { .reg = EXYNOS4210_CLKSRC_LCD1, .shift = 0, .size = 4 },
76 .reg_div = { .reg = EXYNOS4210_CLKDIV_LCD1, .shift = 0, .size = 4 }, 102 .reg_div = { .reg = EXYNOS4210_CLKDIV_LCD1, .shift = 0, .size = 4 },
103 }, {
104 .clk = {
105 .name = "sclk_fimg2d",
106 },
107 .sources = &exynos4210_clkset_mout_g2d,
108 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 8, .size = 1 },
109 .reg_div = { .reg = EXYNOS4_CLKDIV_IMAGE, .shift = 0, .size = 4 },
77 }, 110 },
78}; 111};
79 112
@@ -105,6 +138,10 @@ static struct clk init_clocks_off[] = {
105 .devname = SYSMMU_CLOCK_DEVNAME(fimd1, 11), 138 .devname = SYSMMU_CLOCK_DEVNAME(fimd1, 11),
106 .enable = exynos4_clk_ip_lcd1_ctrl, 139 .enable = exynos4_clk_ip_lcd1_ctrl,
107 .ctrlbit = (1 << 4), 140 .ctrlbit = (1 << 4),
141 }, {
142 .name = "fimg2d",
143 .enable = exynos4_clk_ip_image_ctrl,
144 .ctrlbit = (1 << 0),
108 }, 145 },
109}; 146};
110 147
diff --git a/arch/arm/mach-exynos/clock-exynos4212.c b/arch/arm/mach-exynos/clock-exynos4212.c
index da397d21bbcf..8fba0b5fb8ab 100644
--- a/arch/arm/mach-exynos/clock-exynos4212.c
+++ b/arch/arm/mach-exynos/clock-exynos4212.c
@@ -68,12 +68,45 @@ static struct clksrc_clk clk_mout_mpll_user = {
68 .reg_src = { .reg = EXYNOS4_CLKSRC_CPU, .shift = 24, .size = 1 }, 68 .reg_src = { .reg = EXYNOS4_CLKSRC_CPU, .shift = 24, .size = 1 },
69}; 69};
70 70
71static struct clksrc_clk exynos4x12_clk_mout_g2d0 = {
72 .clk = {
73 .name = "mout_g2d0",
74 },
75 .sources = &exynos4_clkset_mout_g2d0,
76 .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 20, .size = 1 },
77};
78
79static struct clksrc_clk exynos4x12_clk_mout_g2d1 = {
80 .clk = {
81 .name = "mout_g2d1",
82 },
83 .sources = &exynos4_clkset_mout_g2d1,
84 .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 24, .size = 1 },
85};
86
87static struct clk *exynos4x12_clkset_mout_g2d_list[] = {
88 [0] = &exynos4x12_clk_mout_g2d0.clk,
89 [1] = &exynos4x12_clk_mout_g2d1.clk,
90};
91
92static struct clksrc_sources exynos4x12_clkset_mout_g2d = {
93 .sources = exynos4x12_clkset_mout_g2d_list,
94 .nr_sources = ARRAY_SIZE(exynos4x12_clkset_mout_g2d_list),
95};
96
71static struct clksrc_clk *sysclks[] = { 97static struct clksrc_clk *sysclks[] = {
72 &clk_mout_mpll_user, 98 &clk_mout_mpll_user,
73}; 99};
74 100
75static struct clksrc_clk clksrcs[] = { 101static struct clksrc_clk clksrcs[] = {
76 /* nothing here yet */ 102 {
103 .clk = {
104 .name = "sclk_fimg2d",
105 },
106 .sources = &exynos4x12_clkset_mout_g2d,
107 .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 28, .size = 1 },
108 .reg_div = { .reg = EXYNOS4_CLKDIV_DMC1, .shift = 0, .size = 4 },
109 },
77}; 110};
78 111
79static struct clk init_clocks_off[] = { 112static struct clk init_clocks_off[] = {
@@ -102,7 +135,11 @@ static struct clk init_clocks_off[] = {
102 .devname = "exynos-fimc-lite.1", 135 .devname = "exynos-fimc-lite.1",
103 .enable = exynos4212_clk_ip_isp0_ctrl, 136 .enable = exynos4212_clk_ip_isp0_ctrl,
104 .ctrlbit = (1 << 3), 137 .ctrlbit = (1 << 3),
105 } 138 }, {
139 .name = "fimg2d",
140 .enable = exynos4_clk_ip_dmc_ctrl,
141 .ctrlbit = (1 << 23),
142 },
106}; 143};
107 144
108#ifdef CONFIG_PM_SLEEP 145#ifdef CONFIG_PM_SLEEP
diff --git a/arch/arm/mach-exynos/mach-nuri.c b/arch/arm/mach-exynos/mach-nuri.c
index f98a83a81ce7..ea785fcaf6c3 100644
--- a/arch/arm/mach-exynos/mach-nuri.c
+++ b/arch/arm/mach-exynos/mach-nuri.c
@@ -1066,12 +1066,8 @@ static struct platform_device nuri_max8903_device = {
1066static void __init nuri_power_init(void) 1066static void __init nuri_power_init(void)
1067{ 1067{
1068 int gpio; 1068 int gpio;
1069 int irq_base = IRQ_GPIO_END + 1;
1070 int ta_en = 0; 1069 int ta_en = 0;
1071 1070
1072 nuri_max8997_pdata.irq_base = irq_base;
1073 irq_base += MAX8997_IRQ_NR;
1074
1075 gpio = EXYNOS4_GPX0(7); 1071 gpio = EXYNOS4_GPX0(7);
1076 gpio_request(gpio, "AP_PMIC_IRQ"); 1072 gpio_request(gpio, "AP_PMIC_IRQ");
1077 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf)); 1073 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c
index 5a12dc26f496..5ca80307d6d7 100644
--- a/arch/arm/mach-exynos/mach-origen.c
+++ b/arch/arm/mach-exynos/mach-origen.c
@@ -426,7 +426,6 @@ static struct max8997_platform_data __initdata origen_max8997_pdata = {
426 .buck1_gpiodvs = false, 426 .buck1_gpiodvs = false,
427 .buck2_gpiodvs = false, 427 .buck2_gpiodvs = false,
428 .buck5_gpiodvs = false, 428 .buck5_gpiodvs = false,
429 .irq_base = IRQ_GPIO_END + 1,
430 429
431 .ignore_gpiodvs_side_effect = true, 430 .ignore_gpiodvs_side_effect = true,
432 .buck125_default_idx = 0x0, 431 .buck125_default_idx = 0x0,
diff --git a/arch/arm/mach-pxa/eseries.h b/arch/arm/mach-pxa/eseries.h
deleted file mode 100644
index b96949dd5adb..000000000000
--- a/arch/arm/mach-pxa/eseries.h
+++ /dev/null
@@ -1,14 +0,0 @@
1void __init eseries_fixup(struct tag *tags, char **cmdline, struct meminfo *mi);
2
3extern struct pxa2xx_udc_mach_info e7xx_udc_mach_info;
4extern struct pxaficp_platform_data e7xx_ficp_platform_data;
5extern int e7xx_irda_init(void);
6
7extern int eseries_tmio_enable(struct platform_device *dev);
8extern int eseries_tmio_disable(struct platform_device *dev);
9extern int eseries_tmio_suspend(struct platform_device *dev);
10extern int eseries_tmio_resume(struct platform_device *dev);
11extern void eseries_get_tmio_gpios(void);
12extern struct resource eseries_tmio_resources[];
13extern struct platform_device e300_tc6387xb_device;
14
diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
index d3de84b0dcbe..e6311988add2 100644
--- a/arch/arm/mach-pxa/hx4700.c
+++ b/arch/arm/mach-pxa/hx4700.c
@@ -296,27 +296,11 @@ static struct asic3_led asic3_leds[ASIC3_NUM_LEDS] = {
296 296
297static struct resource asic3_resources[] = { 297static struct resource asic3_resources[] = {
298 /* GPIO part */ 298 /* GPIO part */
299 [0] = { 299 [0] = DEFINE_RES_MEM(ASIC3_PHYS, ASIC3_MAP_SIZE_16BIT),
300 .start = ASIC3_PHYS, 300 [1] = DEFINE_RES_IRQ(PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ)),
301 .end = ASIC3_PHYS + ASIC3_MAP_SIZE_16BIT - 1,
302 .flags = IORESOURCE_MEM,
303 },
304 [1] = {
305 .start = PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ),
306 .end = PXA_GPIO_TO_IRQ(GPIO12_HX4700_ASIC3_IRQ),
307 .flags = IORESOURCE_IRQ,
308 },
309 /* SD part */ 301 /* SD part */
310 [2] = { 302 [2] = DEFINE_RES_MEM(ASIC3_SD_PHYS, ASIC3_MAP_SIZE_16BIT),
311 .start = ASIC3_SD_PHYS, 303 [3] = DEFINE_RES_IRQ(PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ)),
312 .end = ASIC3_SD_PHYS + ASIC3_MAP_SIZE_16BIT - 1,
313 .flags = IORESOURCE_MEM,
314 },
315 [3] = {
316 .start = PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ),
317 .end = PXA_GPIO_TO_IRQ(GPIO66_HX4700_ASIC3_nSDIO_IRQ),
318 .flags = IORESOURCE_IRQ,
319 },
320}; 304};
321 305
322static struct asic3_platform_data asic3_platform_data = { 306static struct asic3_platform_data asic3_platform_data = {
@@ -343,11 +327,7 @@ static struct platform_device asic3 = {
343 */ 327 */
344 328
345static struct resource egpio_resources[] = { 329static struct resource egpio_resources[] = {
346 [0] = { 330 [0] = DEFINE_RES_MEM(PXA_CS5_PHYS, 0x4),
347 .start = PXA_CS5_PHYS,
348 .end = PXA_CS5_PHYS + 0x4 - 1,
349 .flags = IORESOURCE_MEM,
350 },
351}; 331};
352 332
353static struct htc_egpio_chip egpio_chips[] = { 333static struct htc_egpio_chip egpio_chips[] = {
@@ -537,11 +517,7 @@ static struct w100fb_mach_info w3220_info = {
537}; 517};
538 518
539static struct resource w3220_resources[] = { 519static struct resource w3220_resources[] = {
540 [0] = { 520 [0] = DEFINE_RES_MEM(ATI_W3220_PHYS, SZ_16M),
541 .start = ATI_W3220_PHYS,
542 .end = ATI_W3220_PHYS + 0x00ffffff,
543 .flags = IORESOURCE_MEM,
544 },
545}; 521};
546 522
547static struct platform_device w3220 = { 523static struct platform_device w3220 = {
@@ -683,20 +659,12 @@ static struct pda_power_pdata power_supply_info = {
683}; 659};
684 660
685static struct resource power_supply_resources[] = { 661static struct resource power_supply_resources[] = {
686 [0] = { 662 [0] = DEFINE_RES_NAMED(PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN), 1, "ac",
687 .name = "ac", 663 IORESOURCE_IRQ |
688 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | 664 IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE),
689 IORESOURCE_IRQ_LOWEDGE, 665 [1] = DEFINE_RES_NAMED(PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT), 1, "usb",
690 .start = PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN), 666 IORESOURCE_IRQ |
691 .end = PXA_GPIO_TO_IRQ(GPIOD9_nAC_IN), 667 IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_LOWEDGE),
692 },
693 [1] = {
694 .name = "usb",
695 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
696 IORESOURCE_IRQ_LOWEDGE,
697 .start = PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT),
698 .end = PXA_GPIO_TO_IRQ(GPIOD14_nUSBC_DETECT),
699 },
700}; 668};
701 669
702static struct platform_device power_supply = { 670static struct platform_device power_supply = {
diff --git a/arch/arm/mach-s3c64xx/include/mach/pm-core.h b/arch/arm/mach-s3c64xx/include/mach/pm-core.h
index fcf3dcabb694..c0537f40a3d8 100644
--- a/arch/arm/mach-s3c64xx/include/mach/pm-core.h
+++ b/arch/arm/mach-s3c64xx/include/mach/pm-core.h
@@ -12,6 +12,9 @@
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14 14
15#ifndef __MACH_S3C64XX_PM_CORE_H
16#define __MACH_S3C64XX_PM_CORE_H __FILE__
17
15#include <mach/regs-gpio.h> 18#include <mach/regs-gpio.h>
16 19
17static inline void s3c_pm_debug_init_uart(void) 20static inline void s3c_pm_debug_init_uart(void)
@@ -113,3 +116,4 @@ static inline void samsung_pm_saved_gpios(void)
113 116
114 __raw_writel(S3C64XX_SLPEN_USE_xSLP, S3C64XX_SLPEN); 117 __raw_writel(S3C64XX_SLPEN_USE_xSLP, S3C64XX_SLPEN);
115} 118}
119#endif /* __MACH_S3C64XX_PM_CORE_H */
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index df33909205e2..4cacc2d22fbe 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -19,6 +19,7 @@ config ARCH_SH7372
19 select CPU_V7 19 select CPU_V7
20 select SH_CLK_CPG 20 select SH_CLK_CPG
21 select ARCH_WANT_OPTIONAL_GPIOLIB 21 select ARCH_WANT_OPTIONAL_GPIOLIB
22 select ARM_CPU_SUSPEND if PM || CPU_IDLE
22 23
23config ARCH_SH73A0 24config ARCH_SH73A0
24 bool "SH-Mobile AG5 (R8A73A00)" 25 bool "SH-Mobile AG5 (R8A73A00)"
@@ -58,6 +59,7 @@ config MACH_G4EVM
58 bool "G4EVM board" 59 bool "G4EVM board"
59 depends on ARCH_SH7377 60 depends on ARCH_SH7377
60 select ARCH_REQUIRE_GPIOLIB 61 select ARCH_REQUIRE_GPIOLIB
62 select REGULATOR_FIXED_VOLTAGE if REGULATOR
61 63
62config MACH_AP4EVB 64config MACH_AP4EVB
63 bool "AP4EVB board" 65 bool "AP4EVB board"
@@ -65,6 +67,7 @@ config MACH_AP4EVB
65 select ARCH_REQUIRE_GPIOLIB 67 select ARCH_REQUIRE_GPIOLIB
66 select SH_LCD_MIPI_DSI 68 select SH_LCD_MIPI_DSI
67 select SND_SOC_AK4642 if SND_SIMPLE_CARD 69 select SND_SOC_AK4642 if SND_SIMPLE_CARD
70 select REGULATOR_FIXED_VOLTAGE if REGULATOR
68 71
69choice 72choice
70 prompt "AP4EVB LCD panel selection" 73 prompt "AP4EVB LCD panel selection"
@@ -83,6 +86,7 @@ config MACH_AG5EVM
83 bool "AG5EVM board" 86 bool "AG5EVM board"
84 select ARCH_REQUIRE_GPIOLIB 87 select ARCH_REQUIRE_GPIOLIB
85 select SH_LCD_MIPI_DSI 88 select SH_LCD_MIPI_DSI
89 select REGULATOR_FIXED_VOLTAGE if REGULATOR
86 depends on ARCH_SH73A0 90 depends on ARCH_SH73A0
87 91
88config MACH_MACKEREL 92config MACH_MACKEREL
@@ -90,15 +94,18 @@ config MACH_MACKEREL
90 depends on ARCH_SH7372 94 depends on ARCH_SH7372
91 select ARCH_REQUIRE_GPIOLIB 95 select ARCH_REQUIRE_GPIOLIB
92 select SND_SOC_AK4642 if SND_SIMPLE_CARD 96 select SND_SOC_AK4642 if SND_SIMPLE_CARD
97 select REGULATOR_FIXED_VOLTAGE if REGULATOR
93 98
94config MACH_KOTA2 99config MACH_KOTA2
95 bool "KOTA2 board" 100 bool "KOTA2 board"
96 select ARCH_REQUIRE_GPIOLIB 101 select ARCH_REQUIRE_GPIOLIB
102 select REGULATOR_FIXED_VOLTAGE if REGULATOR
97 depends on ARCH_SH73A0 103 depends on ARCH_SH73A0
98 104
99config MACH_BONITO 105config MACH_BONITO
100 bool "bonito board" 106 bool "bonito board"
101 select ARCH_REQUIRE_GPIOLIB 107 select ARCH_REQUIRE_GPIOLIB
108 select REGULATOR_FIXED_VOLTAGE if REGULATOR
102 depends on ARCH_R8A7740 109 depends on ARCH_R8A7740
103 110
104config MACH_ARMADILLO800EVA 111config MACH_ARMADILLO800EVA
@@ -106,22 +113,28 @@ config MACH_ARMADILLO800EVA
106 depends on ARCH_R8A7740 113 depends on ARCH_R8A7740
107 select ARCH_REQUIRE_GPIOLIB 114 select ARCH_REQUIRE_GPIOLIB
108 select USE_OF 115 select USE_OF
116 select REGULATOR_FIXED_VOLTAGE if REGULATOR
117 select SND_SOC_WM8978 if SND_SIMPLE_CARD
109 118
110config MACH_MARZEN 119config MACH_MARZEN
111 bool "MARZEN board" 120 bool "MARZEN board"
112 depends on ARCH_R8A7779 121 depends on ARCH_R8A7779
113 select ARCH_REQUIRE_GPIOLIB 122 select ARCH_REQUIRE_GPIOLIB
123 select REGULATOR_FIXED_VOLTAGE if REGULATOR
114 124
115config MACH_KZM9D 125config MACH_KZM9D
116 bool "KZM9D board" 126 bool "KZM9D board"
117 depends on ARCH_EMEV2 127 depends on ARCH_EMEV2
118 select USE_OF 128 select USE_OF
129 select REGULATOR_FIXED_VOLTAGE if REGULATOR
119 130
120config MACH_KZM9G 131config MACH_KZM9G
121 bool "KZM-A9-GT board" 132 bool "KZM-A9-GT board"
122 depends on ARCH_SH73A0 133 depends on ARCH_SH73A0
123 select ARCH_REQUIRE_GPIOLIB 134 select ARCH_REQUIRE_GPIOLIB
124 select USE_OF 135 select USE_OF
136 select SND_SOC_AK4642 if SND_SIMPLE_CARD
137 select REGULATOR_FIXED_VOLTAGE if REGULATOR
125 138
126comment "SH-Mobile System Configuration" 139comment "SH-Mobile System Configuration"
127 140
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
index 8aa1962c22a2..0df5ae6740c6 100644
--- a/arch/arm/mach-shmobile/Makefile
+++ b/arch/arm/mach-shmobile/Makefile
@@ -39,7 +39,9 @@ obj-$(CONFIG_ARCH_R8A7740) += entry-intc.o
39# PM objects 39# PM objects
40obj-$(CONFIG_SUSPEND) += suspend.o 40obj-$(CONFIG_SUSPEND) += suspend.o
41obj-$(CONFIG_CPU_IDLE) += cpuidle.o 41obj-$(CONFIG_CPU_IDLE) += cpuidle.o
42obj-$(CONFIG_ARCH_SHMOBILE) += pm-rmobile.o
42obj-$(CONFIG_ARCH_SH7372) += pm-sh7372.o sleep-sh7372.o 43obj-$(CONFIG_ARCH_SH7372) += pm-sh7372.o sleep-sh7372.o
44obj-$(CONFIG_ARCH_R8A7740) += pm-r8a7740.o
43obj-$(CONFIG_ARCH_R8A7779) += pm-r8a7779.o 45obj-$(CONFIG_ARCH_R8A7779) += pm-r8a7779.o
44 46
45# Board objects 47# Board objects
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index 5a6f22f05e99..d82c010fdfc6 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -27,6 +27,8 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
30#include <linux/regulator/fixed.h>
31#include <linux/regulator/machine.h>
30#include <linux/serial_sci.h> 32#include <linux/serial_sci.h>
31#include <linux/smsc911x.h> 33#include <linux/smsc911x.h>
32#include <linux/gpio.h> 34#include <linux/gpio.h>
@@ -52,6 +54,12 @@
52#include <asm/hardware/cache-l2x0.h> 54#include <asm/hardware/cache-l2x0.h>
53#include <asm/traps.h> 55#include <asm/traps.h>
54 56
57/* Dummy supplies, where voltage doesn't matter */
58static struct regulator_consumer_supply dummy_supplies[] = {
59 REGULATOR_SUPPLY("vddvario", "smsc911x"),
60 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
61};
62
55static struct resource smsc9220_resources[] = { 63static struct resource smsc9220_resources[] = {
56 [0] = { 64 [0] = {
57 .start = 0x14000000, 65 .start = 0x14000000,
@@ -142,6 +150,13 @@ static struct platform_device fsi_device = {
142 .resource = fsi_resources, 150 .resource = fsi_resources,
143}; 151};
144 152
153/* Fixed 1.8V regulator to be used by MMCIF */
154static struct regulator_consumer_supply fixed1v8_power_consumers[] =
155{
156 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
157 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
158};
159
145static struct resource sh_mmcif_resources[] = { 160static struct resource sh_mmcif_resources[] = {
146 [0] = { 161 [0] = {
147 .name = "MMCIF", 162 .name = "MMCIF",
@@ -364,6 +379,13 @@ static struct platform_device mipidsi0_device = {
364 }, 379 },
365}; 380};
366 381
382/* Fixed 2.8V regulators to be used by SDHI0 */
383static struct regulator_consumer_supply fixed2v8_power_consumers[] =
384{
385 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
386 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
387};
388
367/* SDHI0 */ 389/* SDHI0 */
368static struct sh_mobile_sdhi_info sdhi0_info = { 390static struct sh_mobile_sdhi_info sdhi0_info = {
369 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, 391 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
@@ -408,8 +430,57 @@ static struct platform_device sdhi0_device = {
408 }, 430 },
409}; 431};
410 432
411void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state) 433/* Fixed 3.3V regulator to be used by SDHI1 */
434static struct regulator_consumer_supply cn4_power_consumers[] =
412{ 435{
436 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
437 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
438};
439
440static struct regulator_init_data cn4_power_init_data = {
441 .constraints = {
442 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
443 },
444 .num_consumer_supplies = ARRAY_SIZE(cn4_power_consumers),
445 .consumer_supplies = cn4_power_consumers,
446};
447
448static struct fixed_voltage_config cn4_power_info = {
449 .supply_name = "CN4 SD/MMC Vdd",
450 .microvolts = 3300000,
451 .gpio = GPIO_PORT114,
452 .enable_high = 1,
453 .init_data = &cn4_power_init_data,
454};
455
456static struct platform_device cn4_power = {
457 .name = "reg-fixed-voltage",
458 .id = 2,
459 .dev = {
460 .platform_data = &cn4_power_info,
461 },
462};
463
464static void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state)
465{
466 static int power_gpio = -EINVAL;
467
468 if (power_gpio < 0) {
469 int ret = gpio_request(GPIO_PORT114, "sdhi1_power");
470 if (!ret) {
471 power_gpio = GPIO_PORT114;
472 gpio_direction_output(power_gpio, 0);
473 }
474 }
475
476 /*
477 * If requesting the GPIO above failed, it means, that the regulator got
478 * probed and grabbed the GPIO, but we don't know, whether the sdhi
479 * driver already uses the regulator. If it doesn't, we have to toggle
480 * the GPIO ourselves, even though it is now owned by the fixed
481 * regulator driver. We have to live with the race in case the driver
482 * gets unloaded and the GPIO freed between these two steps.
483 */
413 gpio_set_value(GPIO_PORT114, state); 484 gpio_set_value(GPIO_PORT114, state);
414} 485}
415 486
@@ -455,6 +526,7 @@ static struct platform_device sdhi1_device = {
455}; 526};
456 527
457static struct platform_device *ag5evm_devices[] __initdata = { 528static struct platform_device *ag5evm_devices[] __initdata = {
529 &cn4_power,
458 &eth_device, 530 &eth_device,
459 &keysc_device, 531 &keysc_device,
460 &fsi_device, 532 &fsi_device,
@@ -468,6 +540,12 @@ static struct platform_device *ag5evm_devices[] __initdata = {
468 540
469static void __init ag5evm_init(void) 541static void __init ag5evm_init(void)
470{ 542{
543 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
544 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
545 regulator_register_always_on(1, "fixed-2.8V", fixed2v8_power_consumers,
546 ARRAY_SIZE(fixed2v8_power_consumers), 3300000);
547 regulator_register_fixed(3, dummy_supplies, ARRAY_SIZE(dummy_supplies));
548
471 sh73a0_pinmux_init(); 549 sh73a0_pinmux_init();
472 550
473 /* enable SCIFA2 */ 551 /* enable SCIFA2 */
@@ -562,8 +640,6 @@ static void __init ag5evm_init(void)
562 gpio_request(GPIO_FN_SDHID1_2_PU, NULL); 640 gpio_request(GPIO_FN_SDHID1_2_PU, NULL);
563 gpio_request(GPIO_FN_SDHID1_1_PU, NULL); 641 gpio_request(GPIO_FN_SDHID1_1_PU, NULL);
564 gpio_request(GPIO_FN_SDHID1_0_PU, NULL); 642 gpio_request(GPIO_FN_SDHID1_0_PU, NULL);
565 gpio_request(GPIO_PORT114, "sdhi1_power");
566 gpio_direction_output(GPIO_PORT114, 0);
567 643
568#ifdef CONFIG_CACHE_L2X0 644#ifdef CONFIG_CACHE_L2X0
569 /* Shared attribute override enable, 64K*8way */ 645 /* Shared attribute override enable, 64K*8way */
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index ace60246a5df..f172ca85905c 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -34,6 +34,8 @@
34#include <linux/i2c.h> 34#include <linux/i2c.h>
35#include <linux/i2c/tsc2007.h> 35#include <linux/i2c/tsc2007.h>
36#include <linux/io.h> 36#include <linux/io.h>
37#include <linux/regulator/fixed.h>
38#include <linux/regulator/machine.h>
37#include <linux/smsc911x.h> 39#include <linux/smsc911x.h>
38#include <linux/sh_intc.h> 40#include <linux/sh_intc.h>
39#include <linux/sh_clk.h> 41#include <linux/sh_clk.h>
@@ -159,6 +161,27 @@
159 * CN12: 3.3v 161 * CN12: 3.3v
160 */ 162 */
161 163
164/* Dummy supplies, where voltage doesn't matter */
165static struct regulator_consumer_supply fixed1v8_power_consumers[] =
166{
167 /* J22 default position: 1.8V */
168 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
169 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
170 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
171 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
172};
173
174static struct regulator_consumer_supply fixed3v3_power_consumers[] =
175{
176 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
177 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
178};
179
180static struct regulator_consumer_supply dummy_supplies[] = {
181 REGULATOR_SUPPLY("vddvario", "smsc911x"),
182 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
183};
184
162/* MTD */ 185/* MTD */
163static struct mtd_partition nor_flash_partitions[] = { 186static struct mtd_partition nor_flash_partitions[] = {
164 { 187 {
@@ -1138,21 +1161,6 @@ static void __init fsi_init_pm_clock(void)
1138 clk_put(fsia_ick); 1161 clk_put(fsia_ick);
1139} 1162}
1140 1163
1141/*
1142 * FIXME !!
1143 *
1144 * gpio_no_direction
1145 * are quick_hack.
1146 *
1147 * current gpio frame work doesn't have
1148 * the method to control only pull up/down/free.
1149 * this function should be replaced by correct gpio function
1150 */
1151static void __init gpio_no_direction(u32 addr)
1152{
1153 __raw_writeb(0x00, addr);
1154}
1155
1156/* TouchScreen */ 1164/* TouchScreen */
1157#ifdef CONFIG_AP4EVB_QHD 1165#ifdef CONFIG_AP4EVB_QHD
1158# define GPIO_TSC_IRQ GPIO_FN_IRQ28_123 1166# define GPIO_TSC_IRQ GPIO_FN_IRQ28_123
@@ -1224,6 +1232,12 @@ static void __init ap4evb_init(void)
1224 u32 srcr4; 1232 u32 srcr4;
1225 struct clk *clk; 1233 struct clk *clk;
1226 1234
1235 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
1236 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
1237 regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers,
1238 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
1239 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
1240
1227 /* External clock source */ 1241 /* External clock source */
1228 clk_set_rate(&sh7372_dv_clki_clk, 27000000); 1242 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1229 1243
@@ -1302,8 +1316,8 @@ static void __init ap4evb_init(void)
1302 1316
1303 gpio_request(GPIO_PORT9, NULL); 1317 gpio_request(GPIO_PORT9, NULL);
1304 gpio_request(GPIO_PORT10, NULL); 1318 gpio_request(GPIO_PORT10, NULL);
1305 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */ 1319 gpio_direction_none(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1306 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */ 1320 gpio_direction_none(GPIO_PORT10CR); /* FSIAOLR needs no direction */
1307 1321
1308 /* card detect pin for MMC slot (CN7) */ 1322 /* card detect pin for MMC slot (CN7) */
1309 gpio_request(GPIO_PORT41, NULL); 1323 gpio_request(GPIO_PORT41, NULL);
@@ -1447,14 +1461,14 @@ static void __init ap4evb_init(void)
1447 1461
1448 platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices)); 1462 platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
1449 1463
1450 sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc1_device); 1464 rmobile_add_device_to_domain(&sh7372_pd_a4lc, &lcdc1_device);
1451 sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc_device); 1465 rmobile_add_device_to_domain(&sh7372_pd_a4lc, &lcdc_device);
1452 sh7372_add_device_to_domain(&sh7372_a4mp, &fsi_device); 1466 rmobile_add_device_to_domain(&sh7372_pd_a4mp, &fsi_device);
1453 1467
1454 sh7372_add_device_to_domain(&sh7372_a3sp, &sh_mmcif_device); 1468 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sh_mmcif_device);
1455 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi0_device); 1469 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sdhi0_device);
1456 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi1_device); 1470 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sdhi1_device);
1457 sh7372_add_device_to_domain(&sh7372_a4r, &ceu_device); 1471 rmobile_add_device_to_domain(&sh7372_pd_a4r, &ceu_device);
1458 1472
1459 hdmi_init_pm_clock(); 1473 hdmi_init_pm_clock();
1460 fsi_init_pm_clock(); 1474 fsi_init_pm_clock();
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index 9bd135531d76..cf10f92856dc 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -28,6 +28,8 @@
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/gpio.h> 29#include <linux/gpio.h>
30#include <linux/gpio_keys.h> 30#include <linux/gpio_keys.h>
31#include <linux/regulator/fixed.h>
32#include <linux/regulator/machine.h>
31#include <linux/sh_eth.h> 33#include <linux/sh_eth.h>
32#include <linux/videodev2.h> 34#include <linux/videodev2.h>
33#include <linux/usb/renesas_usbhs.h> 35#include <linux/usb/renesas_usbhs.h>
@@ -37,14 +39,20 @@
37#include <linux/mmc/sh_mobile_sdhi.h> 39#include <linux/mmc/sh_mobile_sdhi.h>
38#include <mach/common.h> 40#include <mach/common.h>
39#include <mach/irqs.h> 41#include <mach/irqs.h>
42#include <mach/r8a7740.h>
43#include <media/mt9t112.h>
44#include <media/sh_mobile_ceu.h>
45#include <media/soc_camera.h>
40#include <asm/page.h> 46#include <asm/page.h>
41#include <asm/mach-types.h> 47#include <asm/mach-types.h>
42#include <asm/mach/arch.h> 48#include <asm/mach/arch.h>
43#include <asm/mach/map.h> 49#include <asm/mach/map.h>
44#include <asm/mach/time.h> 50#include <asm/mach/time.h>
45#include <asm/hardware/cache-l2x0.h> 51#include <asm/hardware/cache-l2x0.h>
46#include <mach/r8a7740.h>
47#include <video/sh_mobile_lcdc.h> 52#include <video/sh_mobile_lcdc.h>
53#include <video/sh_mobile_hdmi.h>
54#include <sound/sh_fsi.h>
55#include <sound/simple_card.h>
48 56
49/* 57/*
50 * CON1 Camera Module 58 * CON1 Camera Module
@@ -108,6 +116,14 @@
108 */ 116 */
109 117
110/* 118/*
119 * FSI-WM8978
120 *
121 * this command is required when playback.
122 *
123 * # amixer set "Headphone" 50
124 */
125
126/*
111 * USB function 127 * USB function
112 * 128 *
113 * When you use USB Function, 129 * When you use USB Function,
@@ -117,14 +133,8 @@
117 * These are a little bit complex. 133 * These are a little bit complex.
118 * see 134 * see
119 * usbhsf_power_ctrl() 135 * usbhsf_power_ctrl()
120 *
121 * CAUTION
122 *
123 * It uses autonomy mode for USB hotplug at this point
124 * (= usbhs_private.platform_callback.get_vbus is NULL),
125 * since we don't know what's happen on PM control
126 * on this workaround.
127 */ 136 */
137#define IRQ7 evt2irq(0x02e0)
128#define USBCR1 0xe605810a 138#define USBCR1 0xe605810a
129#define USBH 0xC6700000 139#define USBH 0xC6700000
130#define USBH_USBCTR 0x10834 140#define USBH_USBCTR 0x10834
@@ -204,6 +214,20 @@ static void usbhsf_power_ctrl(struct platform_device *pdev,
204 } 214 }
205} 215}
206 216
217static int usbhsf_get_vbus(struct platform_device *pdev)
218{
219 return gpio_get_value(GPIO_PORT209);
220}
221
222static irqreturn_t usbhsf_interrupt(int irq, void *data)
223{
224 struct platform_device *pdev = data;
225
226 renesas_usbhs_call_notify_hotplug(pdev);
227
228 return IRQ_HANDLED;
229}
230
207static void usbhsf_hardware_exit(struct platform_device *pdev) 231static void usbhsf_hardware_exit(struct platform_device *pdev)
208{ 232{
209 struct usbhsf_private *priv = usbhsf_get_priv(pdev); 233 struct usbhsf_private *priv = usbhsf_get_priv(pdev);
@@ -227,11 +251,14 @@ static void usbhsf_hardware_exit(struct platform_device *pdev)
227 priv->host = NULL; 251 priv->host = NULL;
228 priv->func = NULL; 252 priv->func = NULL;
229 priv->usbh_base = NULL; 253 priv->usbh_base = NULL;
254
255 free_irq(IRQ7, pdev);
230} 256}
231 257
232static int usbhsf_hardware_init(struct platform_device *pdev) 258static int usbhsf_hardware_init(struct platform_device *pdev)
233{ 259{
234 struct usbhsf_private *priv = usbhsf_get_priv(pdev); 260 struct usbhsf_private *priv = usbhsf_get_priv(pdev);
261 int ret;
235 262
236 priv->phy = clk_get(&pdev->dev, "phy"); 263 priv->phy = clk_get(&pdev->dev, "phy");
237 priv->usb24 = clk_get(&pdev->dev, "usb24"); 264 priv->usb24 = clk_get(&pdev->dev, "usb24");
@@ -251,6 +278,14 @@ static int usbhsf_hardware_init(struct platform_device *pdev)
251 return -EIO; 278 return -EIO;
252 } 279 }
253 280
281 ret = request_irq(IRQ7, usbhsf_interrupt, IRQF_TRIGGER_NONE,
282 dev_name(&pdev->dev), pdev);
283 if (ret) {
284 dev_err(&pdev->dev, "request_irq err\n");
285 return ret;
286 }
287 irq_set_irq_type(IRQ7, IRQ_TYPE_EDGE_BOTH);
288
254 /* usb24 use 1/1 of parent clock (= usb24s = 24MHz) */ 289 /* usb24 use 1/1 of parent clock (= usb24s = 24MHz) */
255 clk_set_rate(priv->usb24, 290 clk_set_rate(priv->usb24,
256 clk_get_rate(clk_get_parent(priv->usb24))); 291 clk_get_rate(clk_get_parent(priv->usb24)));
@@ -262,6 +297,7 @@ static struct usbhsf_private usbhsf_private = {
262 .info = { 297 .info = {
263 .platform_callback = { 298 .platform_callback = {
264 .get_id = usbhsf_get_id, 299 .get_id = usbhsf_get_id,
300 .get_vbus = usbhsf_get_vbus,
265 .hardware_init = usbhsf_hardware_init, 301 .hardware_init = usbhsf_hardware_init,
266 .hardware_exit = usbhsf_hardware_exit, 302 .hardware_exit = usbhsf_hardware_exit,
267 .power_ctrl = usbhsf_power_ctrl, 303 .power_ctrl = usbhsf_power_ctrl,
@@ -269,6 +305,8 @@ static struct usbhsf_private usbhsf_private = {
269 .driver_param = { 305 .driver_param = {
270 .buswait_bwait = 5, 306 .buswait_bwait = 5,
271 .detection_delay = 5, 307 .detection_delay = 5,
308 .d0_rx_id = SHDMA_SLAVE_USBHS_RX,
309 .d1_tx_id = SHDMA_SLAVE_USBHS_TX,
272 }, 310 },
273 } 311 }
274}; 312};
@@ -384,6 +422,103 @@ static struct platform_device lcdc0_device = {
384 }, 422 },
385}; 423};
386 424
425/*
426 * LCDC1/HDMI
427 */
428static struct sh_mobile_hdmi_info hdmi_info = {
429 .flags = HDMI_OUTPUT_PUSH_PULL |
430 HDMI_OUTPUT_POLARITY_HI |
431 HDMI_32BIT_REG |
432 HDMI_HAS_HTOP1 |
433 HDMI_SND_SRC_SPDIF,
434};
435
436static struct resource hdmi_resources[] = {
437 [0] = {
438 .name = "HDMI",
439 .start = 0xe6be0000,
440 .end = 0xe6be03ff,
441 .flags = IORESOURCE_MEM,
442 },
443 [1] = {
444 .start = evt2irq(0x1700),
445 .flags = IORESOURCE_IRQ,
446 },
447 [2] = {
448 .name = "HDMI emma3pf",
449 .start = 0xe6be4000,
450 .end = 0xe6be43ff,
451 .flags = IORESOURCE_MEM,
452 },
453};
454
455static struct platform_device hdmi_device = {
456 .name = "sh-mobile-hdmi",
457 .num_resources = ARRAY_SIZE(hdmi_resources),
458 .resource = hdmi_resources,
459 .id = -1,
460 .dev = {
461 .platform_data = &hdmi_info,
462 },
463};
464
465static const struct fb_videomode lcdc1_mode = {
466 .name = "HDMI 720p",
467 .xres = 1280,
468 .yres = 720,
469 .pixclock = 13468,
470 .left_margin = 220,
471 .right_margin = 110,
472 .hsync_len = 40,
473 .upper_margin = 20,
474 .lower_margin = 5,
475 .vsync_len = 5,
476 .refresh = 60,
477 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
478};
479
480static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
481 .clock_source = LCDC_CLK_PERIPHERAL, /* HDMI clock */
482 .ch[0] = {
483 .chan = LCDC_CHAN_MAINLCD,
484 .fourcc = V4L2_PIX_FMT_RGB565,
485 .interface_type = RGB24,
486 .clock_divider = 1,
487 .flags = LCDC_FLAGS_DWPOL,
488 .lcd_modes = &lcdc1_mode,
489 .num_modes = 1,
490 .tx_dev = &hdmi_device,
491 .panel_cfg = {
492 .width = 1280,
493 .height = 720,
494 },
495 },
496};
497
498static struct resource hdmi_lcdc_resources[] = {
499 [0] = {
500 .name = "LCDC1",
501 .start = 0xfe944000,
502 .end = 0xfe948000 - 1,
503 .flags = IORESOURCE_MEM,
504 },
505 [1] = {
506 .start = intcs_evt2irq(0x1780),
507 .flags = IORESOURCE_IRQ,
508 },
509};
510
511static struct platform_device hdmi_lcdc_device = {
512 .name = "sh_mobile_lcdc_fb",
513 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
514 .resource = hdmi_lcdc_resources,
515 .id = 1,
516 .dev = {
517 .platform_data = &hdmi_lcdc_info,
518 .coherent_dma_mask = ~0,
519 },
520};
521
387/* GPIO KEY */ 522/* GPIO KEY */
388#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 } 523#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
389 524
@@ -407,6 +542,17 @@ static struct platform_device gpio_keys_device = {
407 }, 542 },
408}; 543};
409 544
545/* Fixed 3.3V regulator to be used by SDHI0, SDHI1, MMCIF */
546static struct regulator_consumer_supply fixed3v3_power_consumers[] =
547{
548 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
549 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
550 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
551 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
552 REGULATOR_SUPPLY("vmmc", "sh_mmcif"),
553 REGULATOR_SUPPLY("vqmmc", "sh_mmcif"),
554};
555
410/* SDHI0 */ 556/* SDHI0 */
411/* 557/*
412 * FIXME 558 * FIXME
@@ -418,6 +564,8 @@ static struct platform_device gpio_keys_device = {
418 */ 564 */
419#define IRQ31 evt2irq(0x33E0) 565#define IRQ31 evt2irq(0x33E0)
420static struct sh_mobile_sdhi_info sdhi0_info = { 566static struct sh_mobile_sdhi_info sdhi0_info = {
567 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
568 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
421 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |\ 569 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |\
422 MMC_CAP_NEEDS_POLL, 570 MMC_CAP_NEEDS_POLL,
423 .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, 571 .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
@@ -458,6 +606,8 @@ static struct platform_device sdhi0_device = {
458 606
459/* SDHI1 */ 607/* SDHI1 */
460static struct sh_mobile_sdhi_info sdhi1_info = { 608static struct sh_mobile_sdhi_info sdhi1_info = {
609 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
610 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
461 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, 611 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
462 .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, 612 .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
463 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, 613 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
@@ -532,12 +682,209 @@ static struct platform_device sh_mmcif_device = {
532 .resource = sh_mmcif_resources, 682 .resource = sh_mmcif_resources,
533}; 683};
534 684
685/* Camera */
686static int mt9t111_power(struct device *dev, int mode)
687{
688 struct clk *mclk = clk_get(NULL, "video1");
689
690 if (IS_ERR(mclk)) {
691 dev_err(dev, "can't get video1 clock\n");
692 return -EINVAL;
693 }
694
695 if (mode) {
696 /* video1 (= CON1 camera) expect 24MHz */
697 clk_set_rate(mclk, clk_round_rate(mclk, 24000000));
698 clk_enable(mclk);
699 gpio_direction_output(GPIO_PORT158, 1);
700 } else {
701 gpio_direction_output(GPIO_PORT158, 0);
702 clk_disable(mclk);
703 }
704
705 clk_put(mclk);
706
707 return 0;
708}
709
710static struct i2c_board_info i2c_camera_mt9t111 = {
711 I2C_BOARD_INFO("mt9t112", 0x3d),
712};
713
714static struct mt9t112_camera_info mt9t111_info = {
715 .divider = { 16, 0, 0, 7, 0, 10, 14, 7, 7 },
716};
717
718static struct soc_camera_link mt9t111_link = {
719 .i2c_adapter_id = 0,
720 .bus_id = 0,
721 .board_info = &i2c_camera_mt9t111,
722 .power = mt9t111_power,
723 .priv = &mt9t111_info,
724};
725
726static struct platform_device camera_device = {
727 .name = "soc-camera-pdrv",
728 .id = 0,
729 .dev = {
730 .platform_data = &mt9t111_link,
731 },
732};
733
734/* CEU0 */
735static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
736 .flags = SH_CEU_FLAG_LOWER_8BIT,
737};
738
739static struct resource ceu0_resources[] = {
740 [0] = {
741 .name = "CEU",
742 .start = 0xfe910000,
743 .end = 0xfe91009f,
744 .flags = IORESOURCE_MEM,
745 },
746 [1] = {
747 .start = intcs_evt2irq(0x0500),
748 .flags = IORESOURCE_IRQ,
749 },
750 [2] = {
751 /* place holder for contiguous memory */
752 },
753};
754
755static struct platform_device ceu0_device = {
756 .name = "sh_mobile_ceu",
757 .id = 0,
758 .num_resources = ARRAY_SIZE(ceu0_resources),
759 .resource = ceu0_resources,
760 .dev = {
761 .platform_data = &sh_mobile_ceu0_info,
762 .coherent_dma_mask = 0xffffffff,
763 },
764};
765
766/* FSI */
767static int fsi_hdmi_set_rate(struct device *dev, int rate, int enable)
768{
769 struct clk *fsib;
770 int ret;
771
772 /* it support 48KHz only */
773 if (48000 != rate)
774 return -EINVAL;
775
776 fsib = clk_get(dev, "ickb");
777 if (IS_ERR(fsib))
778 return -EINVAL;
779
780 if (enable) {
781 ret = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
782 clk_enable(fsib);
783 } else {
784 ret = 0;
785 clk_disable(fsib);
786 }
787
788 clk_put(fsib);
789
790 return ret;
791}
792
793static struct sh_fsi_platform_info fsi_info = {
794 /* FSI-WM8978 */
795 .port_a = {
796 .tx_id = SHDMA_SLAVE_FSIA_TX,
797 },
798 /* FSI-HDMI */
799 .port_b = {
800 .flags = SH_FSI_FMT_SPDIF |
801 SH_FSI_ENABLE_STREAM_MODE,
802 .set_rate = fsi_hdmi_set_rate,
803 .tx_id = SHDMA_SLAVE_FSIB_TX,
804 }
805};
806
807static struct resource fsi_resources[] = {
808 [0] = {
809 .name = "FSI",
810 .start = 0xfe1f0000,
811 .end = 0xfe1f8400 - 1,
812 .flags = IORESOURCE_MEM,
813 },
814 [1] = {
815 .start = evt2irq(0x1840),
816 .flags = IORESOURCE_IRQ,
817 },
818};
819
820static struct platform_device fsi_device = {
821 .name = "sh_fsi2",
822 .id = -1,
823 .num_resources = ARRAY_SIZE(fsi_resources),
824 .resource = fsi_resources,
825 .dev = {
826 .platform_data = &fsi_info,
827 },
828};
829
830/* FSI-WM8978 */
831static struct asoc_simple_dai_init_info fsi_wm8978_init_info = {
832 .fmt = SND_SOC_DAIFMT_I2S,
833 .codec_daifmt = SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_NB_NF,
834 .cpu_daifmt = SND_SOC_DAIFMT_CBS_CFS,
835 .sysclk = 12288000,
836};
837
838static struct asoc_simple_card_info fsi_wm8978_info = {
839 .name = "wm8978",
840 .card = "FSI2A-WM8978",
841 .cpu_dai = "fsia-dai",
842 .codec = "wm8978.0-001a",
843 .platform = "sh_fsi2",
844 .codec_dai = "wm8978-hifi",
845 .init = &fsi_wm8978_init_info,
846};
847
848static struct platform_device fsi_wm8978_device = {
849 .name = "asoc-simple-card",
850 .id = 0,
851 .dev = {
852 .platform_data = &fsi_wm8978_info,
853 },
854};
855
856/* FSI-HDMI */
857static struct asoc_simple_dai_init_info fsi2_hdmi_init_info = {
858 .cpu_daifmt = SND_SOC_DAIFMT_CBM_CFM,
859};
860
861static struct asoc_simple_card_info fsi2_hdmi_info = {
862 .name = "HDMI",
863 .card = "FSI2B-HDMI",
864 .cpu_dai = "fsib-dai",
865 .codec = "sh-mobile-hdmi",
866 .platform = "sh_fsi2",
867 .codec_dai = "sh_mobile_hdmi-hifi",
868 .init = &fsi2_hdmi_init_info,
869};
870
871static struct platform_device fsi_hdmi_device = {
872 .name = "asoc-simple-card",
873 .id = 1,
874 .dev = {
875 .platform_data = &fsi2_hdmi_info,
876 },
877};
878
535/* I2C */ 879/* I2C */
536static struct i2c_board_info i2c0_devices[] = { 880static struct i2c_board_info i2c0_devices[] = {
537 { 881 {
538 I2C_BOARD_INFO("st1232-ts", 0x55), 882 I2C_BOARD_INFO("st1232-ts", 0x55),
539 .irq = evt2irq(0x0340), 883 .irq = evt2irq(0x0340),
540 }, 884 },
885 {
886 I2C_BOARD_INFO("wm8978", 0x1a),
887 },
541}; 888};
542 889
543/* 890/*
@@ -549,6 +896,13 @@ static struct platform_device *eva_devices[] __initdata = {
549 &sh_eth_device, 896 &sh_eth_device,
550 &sdhi0_device, 897 &sdhi0_device,
551 &sh_mmcif_device, 898 &sh_mmcif_device,
899 &hdmi_device,
900 &hdmi_lcdc_device,
901 &camera_device,
902 &ceu0_device,
903 &fsi_device,
904 &fsi_hdmi_device,
905 &fsi_wm8978_device,
552}; 906};
553 907
554static void __init eva_clock_init(void) 908static void __init eva_clock_init(void)
@@ -556,10 +910,14 @@ static void __init eva_clock_init(void)
556 struct clk *system = clk_get(NULL, "system_clk"); 910 struct clk *system = clk_get(NULL, "system_clk");
557 struct clk *xtal1 = clk_get(NULL, "extal1"); 911 struct clk *xtal1 = clk_get(NULL, "extal1");
558 struct clk *usb24s = clk_get(NULL, "usb24s"); 912 struct clk *usb24s = clk_get(NULL, "usb24s");
913 struct clk *fsibck = clk_get(NULL, "fsibck");
914 struct clk *fsib = clk_get(&fsi_device.dev, "ickb");
559 915
560 if (IS_ERR(system) || 916 if (IS_ERR(system) ||
561 IS_ERR(xtal1) || 917 IS_ERR(xtal1) ||
562 IS_ERR(usb24s)) { 918 IS_ERR(usb24s) ||
919 IS_ERR(fsibck) ||
920 IS_ERR(fsib)) {
563 pr_err("armadillo800eva board clock init failed\n"); 921 pr_err("armadillo800eva board clock init failed\n");
564 goto clock_error; 922 goto clock_error;
565 } 923 }
@@ -570,6 +928,11 @@ static void __init eva_clock_init(void)
570 /* usb24s use extal1 (= system) clock (= 24MHz) */ 928 /* usb24s use extal1 (= system) clock (= 24MHz) */
571 clk_set_parent(usb24s, system); 929 clk_set_parent(usb24s, system);
572 930
931 /* FSIBCK is 12.288MHz, and it is parent of FSI-B */
932 clk_set_parent(fsib, fsibck);
933 clk_set_rate(fsibck, 12288000);
934 clk_set_rate(fsib, 12288000);
935
573clock_error: 936clock_error:
574 if (!IS_ERR(system)) 937 if (!IS_ERR(system))
575 clk_put(system); 938 clk_put(system);
@@ -577,16 +940,26 @@ clock_error:
577 clk_put(xtal1); 940 clk_put(xtal1);
578 if (!IS_ERR(usb24s)) 941 if (!IS_ERR(usb24s))
579 clk_put(usb24s); 942 clk_put(usb24s);
943 if (!IS_ERR(fsibck))
944 clk_put(fsibck);
945 if (!IS_ERR(fsib))
946 clk_put(fsib);
580} 947}
581 948
582/* 949/*
583 * board init 950 * board init
584 */ 951 */
952#define GPIO_PORT7CR 0xe6050007
953#define GPIO_PORT8CR 0xe6050008
585static void __init eva_init(void) 954static void __init eva_init(void)
586{ 955{
587 eva_clock_init(); 956 struct platform_device *usb = NULL;
957
958 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
959 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
588 960
589 r8a7740_pinmux_init(); 961 r8a7740_pinmux_init();
962 r8a7740_meram_workaround();
590 963
591 /* SCIFA1 */ 964 /* SCIFA1 */
592 gpio_request(GPIO_FN_SCIFA1_RXD, NULL); 965 gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
@@ -667,8 +1040,19 @@ static void __init eva_init(void)
667 /* USB Host */ 1040 /* USB Host */
668 } else { 1041 } else {
669 /* USB Func */ 1042 /* USB Func */
670 gpio_request(GPIO_FN_VBUS, NULL); 1043 /*
1044 * A1 chip has 2 IRQ7 pin and it was controled by MSEL register.
1045 * OTOH, usbhs interrupt needs its value (HI/LOW) to decide
1046 * USB connection/disconnection (usbhsf_get_vbus()).
1047 * This means we needs to select GPIO_FN_IRQ7_PORT209 first,
1048 * and select GPIO_PORT209 here
1049 */
1050 gpio_request(GPIO_FN_IRQ7_PORT209, NULL);
1051 gpio_request(GPIO_PORT209, NULL);
1052 gpio_direction_input(GPIO_PORT209);
1053
671 platform_device_register(&usbhsf_device); 1054 platform_device_register(&usbhsf_device);
1055 usb = &usbhsf_device;
672 } 1056 }
673 1057
674 /* SDHI0 */ 1058 /* SDHI0 */
@@ -706,6 +1090,48 @@ static void __init eva_init(void)
706 gpio_request(GPIO_FN_MMC1_D6_PORT143, NULL); 1090 gpio_request(GPIO_FN_MMC1_D6_PORT143, NULL);
707 gpio_request(GPIO_FN_MMC1_D7_PORT142, NULL); 1091 gpio_request(GPIO_FN_MMC1_D7_PORT142, NULL);
708 1092
1093 /* CEU0 */
1094 gpio_request(GPIO_FN_VIO0_D7, NULL);
1095 gpio_request(GPIO_FN_VIO0_D6, NULL);
1096 gpio_request(GPIO_FN_VIO0_D5, NULL);
1097 gpio_request(GPIO_FN_VIO0_D4, NULL);
1098 gpio_request(GPIO_FN_VIO0_D3, NULL);
1099 gpio_request(GPIO_FN_VIO0_D2, NULL);
1100 gpio_request(GPIO_FN_VIO0_D1, NULL);
1101 gpio_request(GPIO_FN_VIO0_D0, NULL);
1102 gpio_request(GPIO_FN_VIO0_CLK, NULL);
1103 gpio_request(GPIO_FN_VIO0_HD, NULL);
1104 gpio_request(GPIO_FN_VIO0_VD, NULL);
1105 gpio_request(GPIO_FN_VIO0_FIELD, NULL);
1106 gpio_request(GPIO_FN_VIO_CKO, NULL);
1107
1108 /* CON1/CON15 Camera */
1109 gpio_request(GPIO_PORT173, NULL); /* STANDBY */
1110 gpio_request(GPIO_PORT172, NULL); /* RST */
1111 gpio_request(GPIO_PORT158, NULL); /* CAM_PON */
1112 gpio_direction_output(GPIO_PORT173, 0);
1113 gpio_direction_output(GPIO_PORT172, 1);
1114 gpio_direction_output(GPIO_PORT158, 0); /* see mt9t111_power() */
1115
1116 /* FSI-WM8978 */
1117 gpio_request(GPIO_FN_FSIAIBT, NULL);
1118 gpio_request(GPIO_FN_FSIAILR, NULL);
1119 gpio_request(GPIO_FN_FSIAOMC, NULL);
1120 gpio_request(GPIO_FN_FSIAOSLD, NULL);
1121 gpio_request(GPIO_FN_FSIAISLD_PORT5, NULL);
1122
1123 gpio_request(GPIO_PORT7, NULL);
1124 gpio_request(GPIO_PORT8, NULL);
1125 gpio_direction_none(GPIO_PORT7CR); /* FSIAOBT needs no direction */
1126 gpio_direction_none(GPIO_PORT8CR); /* FSIAOLR needs no direction */
1127
1128 /* FSI-HDMI */
1129 gpio_request(GPIO_FN_FSIBCK, NULL);
1130
1131 /* HDMI */
1132 gpio_request(GPIO_FN_HDMI_HPD, NULL);
1133 gpio_request(GPIO_FN_HDMI_CEC, NULL);
1134
709 /* 1135 /*
710 * CAUTION 1136 * CAUTION
711 * 1137 *
@@ -752,6 +1178,13 @@ static void __init eva_init(void)
752 1178
753 platform_add_devices(eva_devices, 1179 platform_add_devices(eva_devices,
754 ARRAY_SIZE(eva_devices)); 1180 ARRAY_SIZE(eva_devices));
1181
1182 eva_clock_init();
1183
1184 rmobile_add_device_to_domain(&r8a7740_pd_a4lc, &lcdc0_device);
1185 rmobile_add_device_to_domain(&r8a7740_pd_a4lc, &hdmi_lcdc_device);
1186 if (usb)
1187 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, usb);
755} 1188}
756 1189
757static void __init eva_earlytimer_init(void) 1190static void __init eva_earlytimer_init(void)
diff --git a/arch/arm/mach-shmobile/board-bonito.c b/arch/arm/mach-shmobile/board-bonito.c
index e9b32cfbf741..4129008eae29 100644
--- a/arch/arm/mach-shmobile/board-bonito.c
+++ b/arch/arm/mach-shmobile/board-bonito.c
@@ -26,6 +26,8 @@
26#include <linux/irq.h> 26#include <linux/irq.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/gpio.h> 28#include <linux/gpio.h>
29#include <linux/regulator/fixed.h>
30#include <linux/regulator/machine.h>
29#include <linux/smsc911x.h> 31#include <linux/smsc911x.h>
30#include <linux/videodev2.h> 32#include <linux/videodev2.h>
31#include <mach/common.h> 33#include <mach/common.h>
@@ -75,6 +77,12 @@
75 * S38.2 = OFF 77 * S38.2 = OFF
76 */ 78 */
77 79
80/* Dummy supplies, where voltage doesn't matter */
81static struct regulator_consumer_supply dummy_supplies[] = {
82 REGULATOR_SUPPLY("vddvario", "smsc911x"),
83 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
84};
85
78/* 86/*
79 * FPGA 87 * FPGA
80 */ 88 */
@@ -360,6 +368,8 @@ static void __init bonito_init(void)
360{ 368{
361 u16 val; 369 u16 val;
362 370
371 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
372
363 r8a7740_pinmux_init(); 373 r8a7740_pinmux_init();
364 bonito_fpga_init(); 374 bonito_fpga_init();
365 375
diff --git a/arch/arm/mach-shmobile/board-g4evm.c b/arch/arm/mach-shmobile/board-g4evm.c
index f1257321999a..fa5dfc5c8ed6 100644
--- a/arch/arm/mach-shmobile/board-g4evm.c
+++ b/arch/arm/mach-shmobile/board-g4evm.c
@@ -26,6 +26,8 @@
26#include <linux/mtd/mtd.h> 26#include <linux/mtd/mtd.h>
27#include <linux/mtd/partitions.h> 27#include <linux/mtd/partitions.h>
28#include <linux/mtd/physmap.h> 28#include <linux/mtd/physmap.h>
29#include <linux/regulator/fixed.h>
30#include <linux/regulator/machine.h>
29#include <linux/usb/r8a66597.h> 31#include <linux/usb/r8a66597.h>
30#include <linux/io.h> 32#include <linux/io.h>
31#include <linux/input.h> 33#include <linux/input.h>
@@ -196,6 +198,15 @@ static struct platform_device keysc_device = {
196 }, 198 },
197}; 199};
198 200
201/* Fixed 3.3V regulator to be used by SDHI0 and SDHI1 */
202static struct regulator_consumer_supply fixed3v3_power_consumers[] =
203{
204 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
205 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
206 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
207 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
208};
209
199/* SDHI */ 210/* SDHI */
200static struct sh_mobile_sdhi_info sdhi0_info = { 211static struct sh_mobile_sdhi_info sdhi0_info = {
201 .tmio_caps = MMC_CAP_SDIO_IRQ, 212 .tmio_caps = MMC_CAP_SDIO_IRQ,
@@ -271,26 +282,11 @@ static struct platform_device *g4evm_devices[] __initdata = {
271#define GPIO_SDHID1_D3 0xe6052106 282#define GPIO_SDHID1_D3 0xe6052106
272#define GPIO_SDHICMD1 0xe6052107 283#define GPIO_SDHICMD1 0xe6052107
273 284
274/*
275 * FIXME !!
276 *
277 * gpio_pull_up is quick_hack.
278 *
279 * current gpio frame work doesn't have
280 * the method to control only pull up/down/free.
281 * this function should be replaced by correct gpio function
282 */
283static void __init gpio_pull_up(u32 addr)
284{
285 u8 data = __raw_readb(addr);
286
287 data &= 0x0F;
288 data |= 0xC0;
289 __raw_writeb(data, addr);
290}
291
292static void __init g4evm_init(void) 285static void __init g4evm_init(void)
293{ 286{
287 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
288 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
289
294 sh7377_pinmux_init(); 290 sh7377_pinmux_init();
295 291
296 /* Lit DS14 LED */ 292 /* Lit DS14 LED */
@@ -351,11 +347,11 @@ static void __init g4evm_init(void)
351 gpio_request(GPIO_FN_SDHID0_3, NULL); 347 gpio_request(GPIO_FN_SDHID0_3, NULL);
352 gpio_request(GPIO_FN_SDHICMD0, NULL); 348 gpio_request(GPIO_FN_SDHICMD0, NULL);
353 gpio_request(GPIO_FN_SDHIWP0, NULL); 349 gpio_request(GPIO_FN_SDHIWP0, NULL);
354 gpio_pull_up(GPIO_SDHID0_D0); 350 gpio_request_pullup(GPIO_SDHID0_D0);
355 gpio_pull_up(GPIO_SDHID0_D1); 351 gpio_request_pullup(GPIO_SDHID0_D1);
356 gpio_pull_up(GPIO_SDHID0_D2); 352 gpio_request_pullup(GPIO_SDHID0_D2);
357 gpio_pull_up(GPIO_SDHID0_D3); 353 gpio_request_pullup(GPIO_SDHID0_D3);
358 gpio_pull_up(GPIO_SDHICMD0); 354 gpio_request_pullup(GPIO_SDHICMD0);
359 355
360 /* SDHI1 */ 356 /* SDHI1 */
361 gpio_request(GPIO_FN_SDHICLK1, NULL); 357 gpio_request(GPIO_FN_SDHICLK1, NULL);
@@ -364,11 +360,11 @@ static void __init g4evm_init(void)
364 gpio_request(GPIO_FN_SDHID1_2, NULL); 360 gpio_request(GPIO_FN_SDHID1_2, NULL);
365 gpio_request(GPIO_FN_SDHID1_3, NULL); 361 gpio_request(GPIO_FN_SDHID1_3, NULL);
366 gpio_request(GPIO_FN_SDHICMD1, NULL); 362 gpio_request(GPIO_FN_SDHICMD1, NULL);
367 gpio_pull_up(GPIO_SDHID1_D0); 363 gpio_request_pullup(GPIO_SDHID1_D0);
368 gpio_pull_up(GPIO_SDHID1_D1); 364 gpio_request_pullup(GPIO_SDHID1_D1);
369 gpio_pull_up(GPIO_SDHID1_D2); 365 gpio_request_pullup(GPIO_SDHID1_D2);
370 gpio_pull_up(GPIO_SDHID1_D3); 366 gpio_request_pullup(GPIO_SDHID1_D3);
371 gpio_pull_up(GPIO_SDHICMD1); 367 gpio_request_pullup(GPIO_SDHICMD1);
372 368
373 sh7377_add_standard_devices(); 369 sh7377_add_standard_devices();
374 370
diff --git a/arch/arm/mach-shmobile/board-kota2.c b/arch/arm/mach-shmobile/board-kota2.c
index f60f1b281cc4..21dbe54304d5 100644
--- a/arch/arm/mach-shmobile/board-kota2.c
+++ b/arch/arm/mach-shmobile/board-kota2.c
@@ -27,6 +27,8 @@
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/regulator/fixed.h>
31#include <linux/regulator/machine.h>
30#include <linux/smsc911x.h> 32#include <linux/smsc911x.h>
31#include <linux/gpio.h> 33#include <linux/gpio.h>
32#include <linux/input.h> 34#include <linux/input.h>
@@ -49,6 +51,12 @@
49#include <asm/hardware/cache-l2x0.h> 51#include <asm/hardware/cache-l2x0.h>
50#include <asm/traps.h> 52#include <asm/traps.h>
51 53
54/* Dummy supplies, where voltage doesn't matter */
55static struct regulator_consumer_supply dummy_supplies[] = {
56 REGULATOR_SUPPLY("vddvario", "smsc911x"),
57 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
58};
59
52/* SMSC 9220 */ 60/* SMSC 9220 */
53static struct resource smsc9220_resources[] = { 61static struct resource smsc9220_resources[] = {
54 [0] = { 62 [0] = {
@@ -288,6 +296,13 @@ static struct platform_device leds_tpu30_device = {
288 .resource = tpu30_resources, 296 .resource = tpu30_resources,
289}; 297};
290 298
299/* Fixed 1.8V regulator to be used by MMCIF */
300static struct regulator_consumer_supply fixed1v8_power_consumers[] =
301{
302 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
303 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
304};
305
291/* MMCIF */ 306/* MMCIF */
292static struct resource mmcif_resources[] = { 307static struct resource mmcif_resources[] = {
293 [0] = { 308 [0] = {
@@ -321,6 +336,15 @@ static struct platform_device mmcif_device = {
321 .resource = mmcif_resources, 336 .resource = mmcif_resources,
322}; 337};
323 338
339/* Fixed 3.3V regulator to be used by SDHI0 and SDHI1 */
340static struct regulator_consumer_supply fixed3v3_power_consumers[] =
341{
342 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
343 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
344 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
345 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
346};
347
324/* SDHI0 */ 348/* SDHI0 */
325static struct sh_mobile_sdhi_info sdhi0_info = { 349static struct sh_mobile_sdhi_info sdhi0_info = {
326 .tmio_caps = MMC_CAP_SD_HIGHSPEED, 350 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
@@ -411,6 +435,12 @@ static struct platform_device *kota2_devices[] __initdata = {
411 435
412static void __init kota2_init(void) 436static void __init kota2_init(void)
413{ 437{
438 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
439 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
440 regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers,
441 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
442 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
443
414 sh73a0_pinmux_init(); 444 sh73a0_pinmux_init();
415 445
416 /* SCIFA2 (UART2) */ 446 /* SCIFA2 (UART2) */
diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
index 6a33cf393428..2c986eaae7b4 100644
--- a/arch/arm/mach-shmobile/board-kzm9d.c
+++ b/arch/arm/mach-shmobile/board-kzm9d.c
@@ -21,6 +21,8 @@
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/regulator/fixed.h>
25#include <linux/regulator/machine.h>
24#include <linux/smsc911x.h> 26#include <linux/smsc911x.h>
25#include <mach/common.h> 27#include <mach/common.h>
26#include <mach/emev2.h> 28#include <mach/emev2.h>
@@ -28,6 +30,12 @@
28#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
29#include <asm/hardware/gic.h> 31#include <asm/hardware/gic.h>
30 32
33/* Dummy supplies, where voltage doesn't matter */
34static struct regulator_consumer_supply dummy_supplies[] = {
35 REGULATOR_SUPPLY("vddvario", "smsc911x"),
36 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
37};
38
31/* Ether */ 39/* Ether */
32static struct resource smsc911x_resources[] = { 40static struct resource smsc911x_resources[] = {
33 [0] = { 41 [0] = {
@@ -63,6 +71,8 @@ static struct platform_device *kzm9d_devices[] __initdata = {
63 71
64void __init kzm9d_add_standard_devices(void) 72void __init kzm9d_add_standard_devices(void)
65{ 73{
74 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
75
66 emev2_add_standard_devices(); 76 emev2_add_standard_devices();
67 77
68 platform_add_devices(kzm9d_devices, ARRAY_SIZE(kzm9d_devices)); 78 platform_add_devices(kzm9d_devices, ARRAY_SIZE(kzm9d_devices));
diff --git a/arch/arm/mach-shmobile/board-kzm9g.c b/arch/arm/mach-shmobile/board-kzm9g.c
index c0ae815e7beb..53b7ea92c32c 100644
--- a/arch/arm/mach-shmobile/board-kzm9g.c
+++ b/arch/arm/mach-shmobile/board-kzm9g.c
@@ -30,9 +30,14 @@
30#include <linux/mmc/sh_mobile_sdhi.h> 30#include <linux/mmc/sh_mobile_sdhi.h>
31#include <linux/mfd/tmio.h> 31#include <linux/mfd/tmio.h>
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/regulator/fixed.h>
34#include <linux/regulator/machine.h>
33#include <linux/smsc911x.h> 35#include <linux/smsc911x.h>
34#include <linux/usb/r8a66597.h> 36#include <linux/usb/r8a66597.h>
37#include <linux/usb/renesas_usbhs.h>
35#include <linux/videodev2.h> 38#include <linux/videodev2.h>
39#include <sound/sh_fsi.h>
40#include <sound/simple_card.h>
36#include <mach/irqs.h> 41#include <mach/irqs.h>
37#include <mach/sh73a0.h> 42#include <mach/sh73a0.h>
38#include <mach/common.h> 43#include <mach/common.h>
@@ -54,6 +59,20 @@
54#define GPIO_PCF8575_PORT15 (GPIO_NR + 13) 59#define GPIO_PCF8575_PORT15 (GPIO_NR + 13)
55#define GPIO_PCF8575_PORT16 (GPIO_NR + 14) 60#define GPIO_PCF8575_PORT16 (GPIO_NR + 14)
56 61
62/* Dummy supplies, where voltage doesn't matter */
63static struct regulator_consumer_supply dummy_supplies[] = {
64 REGULATOR_SUPPLY("vddvario", "smsc911x"),
65 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
66};
67
68/*
69 * FSI-AK4648
70 *
71 * this command is required when playback.
72 *
73 * # amixer set "LINEOUT Mixer DACL" on
74 */
75
57/* SMSC 9221 */ 76/* SMSC 9221 */
58static struct resource smsc9221_resources[] = { 77static struct resource smsc9221_resources[] = {
59 [0] = { 78 [0] = {
@@ -112,6 +131,151 @@ static struct platform_device usb_host_device = {
112 .resource = usb_resources, 131 .resource = usb_resources,
113}; 132};
114 133
134/* USB Func CN17 */
135struct usbhs_private {
136 unsigned int phy;
137 unsigned int cr2;
138 struct renesas_usbhs_platform_info info;
139};
140
141#define IRQ15 intcs_evt2irq(0x03e0)
142#define USB_PHY_MODE (1 << 4)
143#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
144#define USB_PHY_ON (1 << 1)
145#define USB_PHY_OFF (1 << 0)
146#define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
147
148#define usbhs_get_priv(pdev) \
149 container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info)
150
151static int usbhs_get_vbus(struct platform_device *pdev)
152{
153 struct usbhs_private *priv = usbhs_get_priv(pdev);
154
155 return !((1 << 7) & __raw_readw(priv->cr2));
156}
157
158static void usbhs_phy_reset(struct platform_device *pdev)
159{
160 struct usbhs_private *priv = usbhs_get_priv(pdev);
161
162 /* init phy */
163 __raw_writew(0x8a0a, priv->cr2);
164}
165
166static int usbhs_get_id(struct platform_device *pdev)
167{
168 return USBHS_GADGET;
169}
170
171static irqreturn_t usbhs_interrupt(int irq, void *data)
172{
173 struct platform_device *pdev = data;
174 struct usbhs_private *priv = usbhs_get_priv(pdev);
175
176 renesas_usbhs_call_notify_hotplug(pdev);
177
178 /* clear status */
179 __raw_writew(__raw_readw(priv->phy) | USB_PHY_INT_CLR, priv->phy);
180
181 return IRQ_HANDLED;
182}
183
184static int usbhs_hardware_init(struct platform_device *pdev)
185{
186 struct usbhs_private *priv = usbhs_get_priv(pdev);
187 int ret;
188
189 /* clear interrupt status */
190 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
191
192 ret = request_irq(IRQ15, usbhs_interrupt, IRQF_TRIGGER_HIGH,
193 dev_name(&pdev->dev), pdev);
194 if (ret) {
195 dev_err(&pdev->dev, "request_irq err\n");
196 return ret;
197 }
198
199 /* enable USB phy interrupt */
200 __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->phy);
201
202 return 0;
203}
204
205static void usbhs_hardware_exit(struct platform_device *pdev)
206{
207 struct usbhs_private *priv = usbhs_get_priv(pdev);
208
209 /* clear interrupt status */
210 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy);
211
212 free_irq(IRQ15, pdev);
213}
214
215static u32 usbhs_pipe_cfg[] = {
216 USB_ENDPOINT_XFER_CONTROL,
217 USB_ENDPOINT_XFER_ISOC,
218 USB_ENDPOINT_XFER_ISOC,
219 USB_ENDPOINT_XFER_BULK,
220 USB_ENDPOINT_XFER_BULK,
221 USB_ENDPOINT_XFER_BULK,
222 USB_ENDPOINT_XFER_INT,
223 USB_ENDPOINT_XFER_INT,
224 USB_ENDPOINT_XFER_INT,
225 USB_ENDPOINT_XFER_BULK,
226 USB_ENDPOINT_XFER_BULK,
227 USB_ENDPOINT_XFER_BULK,
228 USB_ENDPOINT_XFER_BULK,
229 USB_ENDPOINT_XFER_BULK,
230 USB_ENDPOINT_XFER_BULK,
231 USB_ENDPOINT_XFER_BULK,
232};
233
234static struct usbhs_private usbhs_private = {
235 .phy = 0xe60781e0, /* USBPHYINT */
236 .cr2 = 0xe605810c, /* USBCR2 */
237 .info = {
238 .platform_callback = {
239 .hardware_init = usbhs_hardware_init,
240 .hardware_exit = usbhs_hardware_exit,
241 .get_id = usbhs_get_id,
242 .phy_reset = usbhs_phy_reset,
243 .get_vbus = usbhs_get_vbus,
244 },
245 .driver_param = {
246 .buswait_bwait = 4,
247 .has_otg = 1,
248 .pipe_type = usbhs_pipe_cfg,
249 .pipe_size = ARRAY_SIZE(usbhs_pipe_cfg),
250 },
251 },
252};
253
254static struct resource usbhs_resources[] = {
255 [0] = {
256 .start = 0xE6890000,
257 .end = 0xE68900e6 - 1,
258 .flags = IORESOURCE_MEM,
259 },
260 [1] = {
261 .start = gic_spi(62),
262 .end = gic_spi(62),
263 .flags = IORESOURCE_IRQ,
264 },
265};
266
267static struct platform_device usbhs_device = {
268 .name = "renesas_usbhs",
269 .id = -1,
270 .dev = {
271 .dma_mask = NULL,
272 .coherent_dma_mask = 0xffffffff,
273 .platform_data = &usbhs_private.info,
274 },
275 .num_resources = ARRAY_SIZE(usbhs_resources),
276 .resource = usbhs_resources,
277};
278
115/* LCDC */ 279/* LCDC */
116static struct fb_videomode kzm_lcdc_mode = { 280static struct fb_videomode kzm_lcdc_mode = {
117 .name = "WVGA Panel", 281 .name = "WVGA Panel",
@@ -166,6 +330,13 @@ static struct platform_device lcdc_device = {
166 }, 330 },
167}; 331};
168 332
333/* Fixed 1.8V regulator to be used by MMCIF */
334static struct regulator_consumer_supply fixed1v8_power_consumers[] =
335{
336 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
337 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
338};
339
169/* MMCIF */ 340/* MMCIF */
170static struct resource sh_mmcif_resources[] = { 341static struct resource sh_mmcif_resources[] = {
171 [0] = { 342 [0] = {
@@ -187,6 +358,8 @@ static struct resource sh_mmcif_resources[] = {
187static struct sh_mmcif_plat_data sh_mmcif_platdata = { 358static struct sh_mmcif_plat_data sh_mmcif_platdata = {
188 .ocr = MMC_VDD_165_195, 359 .ocr = MMC_VDD_165_195,
189 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE, 360 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
361 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
362 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
190}; 363};
191 364
192static struct platform_device mmc_device = { 365static struct platform_device mmc_device = {
@@ -200,6 +373,15 @@ static struct platform_device mmc_device = {
200 .resource = sh_mmcif_resources, 373 .resource = sh_mmcif_resources,
201}; 374};
202 375
376/* Fixed 2.8V regulators to be used by SDHI0 and SDHI2 */
377static struct regulator_consumer_supply fixed2v8_power_consumers[] =
378{
379 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
380 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
381 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
382 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"),
383};
384
203/* SDHI */ 385/* SDHI */
204static struct sh_mobile_sdhi_info sdhi0_info = { 386static struct sh_mobile_sdhi_info sdhi0_info = {
205 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, 387 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
@@ -240,6 +422,50 @@ static struct platform_device sdhi0_device = {
240 }, 422 },
241}; 423};
242 424
425/* Micro SD */
426static struct sh_mobile_sdhi_info sdhi2_info = {
427 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
428 TMIO_MMC_USE_GPIO_CD |
429 TMIO_MMC_WRPROTECT_DISABLE,
430 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
431 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
432 .cd_gpio = GPIO_PORT13,
433};
434
435static struct resource sdhi2_resources[] = {
436 [0] = {
437 .name = "SDHI2",
438 .start = 0xee140000,
439 .end = 0xee1400ff,
440 .flags = IORESOURCE_MEM,
441 },
442 [1] = {
443 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
444 .start = gic_spi(103),
445 .flags = IORESOURCE_IRQ,
446 },
447 [2] = {
448 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
449 .start = gic_spi(104),
450 .flags = IORESOURCE_IRQ,
451 },
452 [3] = {
453 .name = SH_MOBILE_SDHI_IRQ_SDIO,
454 .start = gic_spi(105),
455 .flags = IORESOURCE_IRQ,
456 },
457};
458
459static struct platform_device sdhi2_device = {
460 .name = "sh_mobile_sdhi",
461 .id = 2,
462 .num_resources = ARRAY_SIZE(sdhi2_resources),
463 .resource = sdhi2_resources,
464 .dev = {
465 .platform_data = &sdhi2_info,
466 },
467};
468
243/* KEY */ 469/* KEY */
244#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 } 470#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
245 471
@@ -267,11 +493,74 @@ static struct platform_device gpio_keys_device = {
267 }, 493 },
268}; 494};
269 495
496/* FSI-AK4648 */
497static struct sh_fsi_platform_info fsi_info = {
498 .port_a = {
499 .tx_id = SHDMA_SLAVE_FSI2A_TX,
500 },
501};
502
503static struct resource fsi_resources[] = {
504 [0] = {
505 .name = "FSI",
506 .start = 0xEC230000,
507 .end = 0xEC230400 - 1,
508 .flags = IORESOURCE_MEM,
509 },
510 [1] = {
511 .start = gic_spi(146),
512 .flags = IORESOURCE_IRQ,
513 },
514};
515
516static struct platform_device fsi_device = {
517 .name = "sh_fsi2",
518 .id = -1,
519 .num_resources = ARRAY_SIZE(fsi_resources),
520 .resource = fsi_resources,
521 .dev = {
522 .platform_data = &fsi_info,
523 },
524};
525
526static struct asoc_simple_dai_init_info fsi2_ak4648_init_info = {
527 .fmt = SND_SOC_DAIFMT_LEFT_J,
528 .codec_daifmt = SND_SOC_DAIFMT_CBM_CFM,
529 .cpu_daifmt = SND_SOC_DAIFMT_CBS_CFS,
530 .sysclk = 11289600,
531};
532
533static struct asoc_simple_card_info fsi2_ak4648_info = {
534 .name = "AK4648",
535 .card = "FSI2A-AK4648",
536 .cpu_dai = "fsia-dai",
537 .codec = "ak4642-codec.0-0012",
538 .platform = "sh_fsi2",
539 .codec_dai = "ak4642-hifi",
540 .init = &fsi2_ak4648_init_info,
541};
542
543static struct platform_device fsi_ak4648_device = {
544 .name = "asoc-simple-card",
545 .dev = {
546 .platform_data = &fsi2_ak4648_info,
547 },
548};
549
270/* I2C */ 550/* I2C */
271static struct pcf857x_platform_data pcf8575_pdata = { 551static struct pcf857x_platform_data pcf8575_pdata = {
272 .gpio_base = GPIO_PCF8575_BASE, 552 .gpio_base = GPIO_PCF8575_BASE,
273}; 553};
274 554
555static struct i2c_board_info i2c0_devices[] = {
556 {
557 I2C_BOARD_INFO("ak4648", 0x12),
558 },
559 {
560 I2C_BOARD_INFO("r2025sd", 0x32),
561 }
562};
563
275static struct i2c_board_info i2c1_devices[] = { 564static struct i2c_board_info i2c1_devices[] = {
276 { 565 {
277 I2C_BOARD_INFO("st1232-ts", 0x55), 566 I2C_BOARD_INFO("st1232-ts", 0x55),
@@ -289,10 +578,14 @@ static struct i2c_board_info i2c3_devices[] = {
289static struct platform_device *kzm_devices[] __initdata = { 578static struct platform_device *kzm_devices[] __initdata = {
290 &smsc_device, 579 &smsc_device,
291 &usb_host_device, 580 &usb_host_device,
581 &usbhs_device,
292 &lcdc_device, 582 &lcdc_device,
293 &mmc_device, 583 &mmc_device,
294 &sdhi0_device, 584 &sdhi0_device,
585 &sdhi2_device,
295 &gpio_keys_device, 586 &gpio_keys_device,
587 &fsi_device,
588 &fsi_ak4648_device,
296}; 589};
297 590
298/* 591/*
@@ -350,6 +643,12 @@ device_initcall(as3711_enable_lcdc_backlight);
350 643
351static void __init kzm_init(void) 644static void __init kzm_init(void)
352{ 645{
646 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
647 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
648 regulator_register_always_on(1, "fixed-2.8V", fixed2v8_power_consumers,
649 ARRAY_SIZE(fixed2v8_power_consumers), 2800000);
650 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
651
353 sh73a0_pinmux_init(); 652 sh73a0_pinmux_init();
354 653
355 /* enable SCIFA4 */ 654 /* enable SCIFA4 */
@@ -427,15 +726,36 @@ static void __init kzm_init(void)
427 gpio_request(GPIO_PORT15, NULL); 726 gpio_request(GPIO_PORT15, NULL);
428 gpio_direction_output(GPIO_PORT15, 1); /* power */ 727 gpio_direction_output(GPIO_PORT15, 1); /* power */
429 728
729 /* enable Micro SD */
730 gpio_request(GPIO_FN_SDHID2_0, NULL);
731 gpio_request(GPIO_FN_SDHID2_1, NULL);
732 gpio_request(GPIO_FN_SDHID2_2, NULL);
733 gpio_request(GPIO_FN_SDHID2_3, NULL);
734 gpio_request(GPIO_FN_SDHICMD2, NULL);
735 gpio_request(GPIO_FN_SDHICLK2, NULL);
736 gpio_request(GPIO_PORT14, NULL);
737 gpio_direction_output(GPIO_PORT14, 1); /* power */
738
430 /* I2C 3 */ 739 /* I2C 3 */
431 gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL); 740 gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL);
432 gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL); 741 gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL);
433 742
743 /* enable FSI2 port A (ak4648) */
744 gpio_request(GPIO_FN_FSIACK, NULL);
745 gpio_request(GPIO_FN_FSIAILR, NULL);
746 gpio_request(GPIO_FN_FSIAIBT, NULL);
747 gpio_request(GPIO_FN_FSIAISLD, NULL);
748 gpio_request(GPIO_FN_FSIAOSLD, NULL);
749
750 /* enable USB */
751 gpio_request(GPIO_FN_VBUS_0, NULL);
752
434#ifdef CONFIG_CACHE_L2X0 753#ifdef CONFIG_CACHE_L2X0
435 /* Early BRESP enable, Shared attribute override enable, 64K*8way */ 754 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
436 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff); 755 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
437#endif 756#endif
438 757
758 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
439 i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices)); 759 i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
440 i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices)); 760 i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
441 761
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index 150122a44630..7ea2b31e3199 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -41,6 +41,8 @@
41#include <linux/mtd/physmap.h> 41#include <linux/mtd/physmap.h>
42#include <linux/mtd/sh_flctl.h> 42#include <linux/mtd/sh_flctl.h>
43#include <linux/pm_clock.h> 43#include <linux/pm_clock.h>
44#include <linux/regulator/fixed.h>
45#include <linux/regulator/machine.h>
44#include <linux/smsc911x.h> 46#include <linux/smsc911x.h>
45#include <linux/sh_intc.h> 47#include <linux/sh_intc.h>
46#include <linux/tca6416_keypad.h> 48#include <linux/tca6416_keypad.h>
@@ -203,31 +205,32 @@
203 * amixer set "HPOUTR Mixer DACH" on 205 * amixer set "HPOUTR Mixer DACH" on
204 */ 206 */
205 207
206/* 208/* Fixed 3.3V and 1.8V regulators to be used by multiple devices */
207 * FIXME !! 209static struct regulator_consumer_supply fixed1v8_power_consumers[] =
208 *
209 * gpio_no_direction
210 * gpio_pull_down
211 * are quick_hack.
212 *
213 * current gpio frame work doesn't have
214 * the method to control only pull up/down/free.
215 * this function should be replaced by correct gpio function
216 */
217static void __init gpio_no_direction(u32 addr)
218{ 210{
219 __raw_writeb(0x00, addr); 211 /*
220} 212 * J22 on mackerel switches mmcif.0 and sdhi.1 between 1.8V and 3.3V
213 * Since we cannot support both voltages, we support the default 1.8V
214 */
215 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
216 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
217 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
218 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
219};
221 220
222static void __init gpio_pull_down(u32 addr) 221static struct regulator_consumer_supply fixed3v3_power_consumers[] =
223{ 222{
224 u8 data = __raw_readb(addr); 223 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
225 224 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
226 data &= 0x0F; 225 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
227 data |= 0xA0; 226 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"),
227};
228 228
229 __raw_writeb(data, addr); 229/* Dummy supplies, where voltage doesn't matter */
230} 230static struct regulator_consumer_supply dummy_supplies[] = {
231 REGULATOR_SUPPLY("vddvario", "smsc911x"),
232 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
233};
231 234
232/* MTD */ 235/* MTD */
233static struct mtd_partition nor_flash_partitions[] = { 236static struct mtd_partition nor_flash_partitions[] = {
@@ -1409,6 +1412,12 @@ static void __init mackerel_init(void)
1409 u32 srcr4; 1412 u32 srcr4;
1410 struct clk *clk; 1413 struct clk *clk;
1411 1414
1415 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
1416 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
1417 regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers,
1418 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
1419 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
1420
1412 /* External clock source */ 1421 /* External clock source */
1413 clk_set_rate(&sh7372_dv_clki_clk, 27000000); 1422 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1414 1423
@@ -1458,11 +1467,11 @@ static void __init mackerel_init(void)
1458 1467
1459 /* USBHS0 */ 1468 /* USBHS0 */
1460 gpio_request(GPIO_FN_VBUS0_0, NULL); 1469 gpio_request(GPIO_FN_VBUS0_0, NULL);
1461 gpio_pull_down(GPIO_PORT168CR); /* VBUS0_0 pull down */ 1470 gpio_request_pulldown(GPIO_PORT168CR); /* VBUS0_0 pull down */
1462 1471
1463 /* USBHS1 */ 1472 /* USBHS1 */
1464 gpio_request(GPIO_FN_VBUS0_1, NULL); 1473 gpio_request(GPIO_FN_VBUS0_1, NULL);
1465 gpio_pull_down(GPIO_PORT167CR); /* VBUS0_1 pull down */ 1474 gpio_request_pulldown(GPIO_PORT167CR); /* VBUS0_1 pull down */
1466 gpio_request(GPIO_FN_IDIN_1_113, NULL); 1475 gpio_request(GPIO_FN_IDIN_1_113, NULL);
1467 1476
1468 /* enable FSI2 port A (ak4643) */ 1477 /* enable FSI2 port A (ak4643) */
@@ -1475,8 +1484,8 @@ static void __init mackerel_init(void)
1475 1484
1476 gpio_request(GPIO_PORT9, NULL); 1485 gpio_request(GPIO_PORT9, NULL);
1477 gpio_request(GPIO_PORT10, NULL); 1486 gpio_request(GPIO_PORT10, NULL);
1478 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */ 1487 gpio_direction_none(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1479 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */ 1488 gpio_direction_none(GPIO_PORT10CR); /* FSIAOLR needs no direction */
1480 1489
1481 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */ 1490 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
1482 1491
@@ -1614,20 +1623,20 @@ static void __init mackerel_init(void)
1614 1623
1615 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices)); 1624 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
1616 1625
1617 sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc_device); 1626 rmobile_add_device_to_domain(&sh7372_pd_a4lc, &lcdc_device);
1618 sh7372_add_device_to_domain(&sh7372_a4lc, &hdmi_lcdc_device); 1627 rmobile_add_device_to_domain(&sh7372_pd_a4lc, &hdmi_lcdc_device);
1619 sh7372_add_device_to_domain(&sh7372_a4lc, &meram_device); 1628 rmobile_add_device_to_domain(&sh7372_pd_a4lc, &meram_device);
1620 sh7372_add_device_to_domain(&sh7372_a4mp, &fsi_device); 1629 rmobile_add_device_to_domain(&sh7372_pd_a4mp, &fsi_device);
1621 sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs0_device); 1630 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &usbhs0_device);
1622 sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs1_device); 1631 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &usbhs1_device);
1623 sh7372_add_device_to_domain(&sh7372_a3sp, &nand_flash_device); 1632 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &nand_flash_device);
1624 sh7372_add_device_to_domain(&sh7372_a3sp, &sh_mmcif_device); 1633 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sh_mmcif_device);
1625 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi0_device); 1634 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sdhi0_device);
1626#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) 1635#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1627 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi1_device); 1636 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sdhi1_device);
1628#endif 1637#endif
1629 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi2_device); 1638 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &sdhi2_device);
1630 sh7372_add_device_to_domain(&sh7372_a4r, &ceu_device); 1639 rmobile_add_device_to_domain(&sh7372_pd_a4r, &ceu_device);
1631 1640
1632 hdmi_init_pm_clock(); 1641 hdmi_init_pm_clock();
1633 sh7372_pm_init(); 1642 sh7372_pm_init();
diff --git a/arch/arm/mach-shmobile/board-marzen.c b/arch/arm/mach-shmobile/board-marzen.c
index 14de3787cafc..3a528cf4366c 100644
--- a/arch/arm/mach-shmobile/board-marzen.c
+++ b/arch/arm/mach-shmobile/board-marzen.c
@@ -27,6 +27,8 @@
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/gpio.h> 28#include <linux/gpio.h>
29#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
30#include <linux/regulator/fixed.h>
31#include <linux/regulator/machine.h>
30#include <linux/smsc911x.h> 32#include <linux/smsc911x.h>
31#include <mach/hardware.h> 33#include <mach/hardware.h>
32#include <mach/r8a7779.h> 34#include <mach/r8a7779.h>
@@ -37,6 +39,12 @@
37#include <asm/hardware/gic.h> 39#include <asm/hardware/gic.h>
38#include <asm/traps.h> 40#include <asm/traps.h>
39 41
42/* Dummy supplies, where voltage doesn't matter */
43static struct regulator_consumer_supply dummy_supplies[] = {
44 REGULATOR_SUPPLY("vddvario", "smsc911x"),
45 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
46};
47
40/* SMSC LAN89218 */ 48/* SMSC LAN89218 */
41static struct resource smsc911x_resources[] = { 49static struct resource smsc911x_resources[] = {
42 [0] = { 50 [0] = {
@@ -73,6 +81,8 @@ static struct platform_device *marzen_devices[] __initdata = {
73 81
74static void __init marzen_init(void) 82static void __init marzen_init(void)
75{ 83{
84 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
85
76 r8a7779_pinmux_init(); 86 r8a7779_pinmux_init();
77 87
78 /* SCIF2 (CN18: DEBUG0) */ 88 /* SCIF2 (CN18: DEBUG0) */
diff --git a/arch/arm/mach-shmobile/clock-r8a7740.c b/arch/arm/mach-shmobile/clock-r8a7740.c
index 26eea5f21054..ad5fccc7b5e7 100644
--- a/arch/arm/mach-shmobile/clock-r8a7740.c
+++ b/arch/arm/mach-shmobile/clock-r8a7740.c
@@ -43,7 +43,10 @@
43/* CPG registers */ 43/* CPG registers */
44#define FRQCRA 0xe6150000 44#define FRQCRA 0xe6150000
45#define FRQCRB 0xe6150004 45#define FRQCRB 0xe6150004
46#define VCLKCR1 0xE6150008
47#define VCLKCR2 0xE615000c
46#define FRQCRC 0xe61500e0 48#define FRQCRC 0xe61500e0
49#define FSIACKCR 0xe6150018
47#define PLLC01CR 0xe6150028 50#define PLLC01CR 0xe6150028
48 51
49#define SUBCKCR 0xe6150080 52#define SUBCKCR 0xe6150080
@@ -54,6 +57,8 @@
54#define MSTPSR2 0xe6150040 57#define MSTPSR2 0xe6150040
55#define MSTPSR3 0xe6150048 58#define MSTPSR3 0xe6150048
56#define MSTPSR4 0xe615004c 59#define MSTPSR4 0xe615004c
60#define FSIBCKCR 0xe6150090
61#define HDMICKCR 0xe6150094
57#define SMSTPCR0 0xe6150130 62#define SMSTPCR0 0xe6150130
58#define SMSTPCR1 0xe6150134 63#define SMSTPCR1 0xe6150134
59#define SMSTPCR2 0xe6150138 64#define SMSTPCR2 0xe6150138
@@ -271,6 +276,13 @@ static struct clk usb24_clk = {
271 .parent = &usb24s_clk, 276 .parent = &usb24s_clk,
272}; 277};
273 278
279/* External FSIACK/FSIBCK clock */
280static struct clk fsiack_clk = {
281};
282
283static struct clk fsibck_clk = {
284};
285
274struct clk *main_clks[] = { 286struct clk *main_clks[] = {
275 &extalr_clk, 287 &extalr_clk,
276 &extal1_clk, 288 &extal1_clk,
@@ -288,6 +300,8 @@ struct clk *main_clks[] = {
288 &pllc1_div2_clk, 300 &pllc1_div2_clk,
289 &usb24s_clk, 301 &usb24s_clk,
290 &usb24_clk, 302 &usb24_clk,
303 &fsiack_clk,
304 &fsibck_clk,
291}; 305};
292 306
293static void div4_kick(struct clk *clk) 307static void div4_kick(struct clk *clk)
@@ -313,6 +327,107 @@ static struct clk_div4_table div4_table = {
313 .kick = div4_kick, 327 .kick = div4_kick,
314}; 328};
315 329
330/* DIV6 reparent */
331enum {
332 DIV6_HDMI,
333 DIV6_VCLK1, DIV6_VCLK2,
334 DIV6_FSIA, DIV6_FSIB,
335 DIV6_REPARENT_NR,
336};
337
338static struct clk *hdmi_parent[] = {
339 [0] = &pllc1_div2_clk,
340 [1] = &system_clk,
341 [2] = &dv_clk
342};
343
344static struct clk *vclk_parents[8] = {
345 [0] = &pllc1_div2_clk,
346 [2] = &dv_clk,
347 [3] = &usb24s_clk,
348 [4] = &extal1_div2_clk,
349 [5] = &extalr_clk,
350};
351
352static struct clk *fsia_parents[] = {
353 [0] = &pllc1_div2_clk,
354 [1] = &fsiack_clk, /* external clock */
355};
356
357static struct clk *fsib_parents[] = {
358 [0] = &pllc1_div2_clk,
359 [1] = &fsibck_clk, /* external clock */
360};
361
362static struct clk div6_reparent_clks[DIV6_REPARENT_NR] = {
363 [DIV6_HDMI] = SH_CLK_DIV6_EXT(HDMICKCR, 0,
364 hdmi_parent, ARRAY_SIZE(hdmi_parent), 6, 2),
365 [DIV6_VCLK1] = SH_CLK_DIV6_EXT(VCLKCR1, 0,
366 vclk_parents, ARRAY_SIZE(vclk_parents), 12, 3),
367 [DIV6_VCLK2] = SH_CLK_DIV6_EXT(VCLKCR2, 0,
368 vclk_parents, ARRAY_SIZE(vclk_parents), 12, 3),
369 [DIV6_FSIA] = SH_CLK_DIV6_EXT(FSIACKCR, 0,
370 fsia_parents, ARRAY_SIZE(fsia_parents), 6, 2),
371 [DIV6_FSIB] = SH_CLK_DIV6_EXT(FSIBCKCR, 0,
372 fsib_parents, ARRAY_SIZE(fsib_parents), 6, 2),
373};
374
375/* HDMI1/2 clock */
376static unsigned long hdmi12_recalc(struct clk *clk)
377{
378 u32 val = __raw_readl(HDMICKCR);
379 int shift = (int)clk->priv;
380
381 val >>= shift;
382 val &= 0x3;
383
384 return clk->parent->rate / (1 << val);
385};
386
387static int hdmi12_set_rate(struct clk *clk, unsigned long rate)
388{
389 u32 val, mask;
390 int i, shift;
391
392 for (i = 0; i < 3; i++)
393 if (rate == clk->parent->rate / (1 << i))
394 goto find;
395 return -ENODEV;
396
397find:
398 shift = (int)clk->priv;
399
400 val = __raw_readl(HDMICKCR);
401 mask = ~(0x3 << shift);
402 val = (val & mask) | i << shift;
403 __raw_writel(val, HDMICKCR);
404
405 return 0;
406};
407
408static struct sh_clk_ops hdmi12_clk_ops = {
409 .recalc = hdmi12_recalc,
410 .set_rate = hdmi12_set_rate,
411};
412
413static struct clk hdmi1_clk = {
414 .ops = &hdmi12_clk_ops,
415 .priv = (void *)9,
416 .parent = &div6_reparent_clks[DIV6_HDMI], /* late install */
417};
418
419static struct clk hdmi2_clk = {
420 .ops = &hdmi12_clk_ops,
421 .priv = (void *)11,
422 .parent = &div6_reparent_clks[DIV6_HDMI], /* late install */
423};
424
425static struct clk *late_main_clks[] = {
426 &hdmi1_clk,
427 &hdmi2_clk,
428};
429
430/* MSTP */
316enum { 431enum {
317 DIV4_I, DIV4_ZG, DIV4_B, DIV4_M1, DIV4_HP, 432 DIV4_I, DIV4_ZG, DIV4_B, DIV4_M1, DIV4_HP,
318 DIV4_HPP, DIV4_USBP, DIV4_S, DIV4_ZB, DIV4_M3, DIV4_CP, 433 DIV4_HPP, DIV4_USBP, DIV4_S, DIV4_ZB, DIV4_M3, DIV4_CP,
@@ -343,11 +458,12 @@ static struct clk div6_clks[DIV6_NR] = {
343}; 458};
344 459
345enum { 460enum {
346 MSTP125, 461 MSTP128, MSTP127, MSTP125,
347 MSTP116, MSTP111, MSTP100, MSTP117, 462 MSTP116, MSTP111, MSTP100, MSTP117,
348 463
349 MSTP230, 464 MSTP230,
350 MSTP222, 465 MSTP222,
466 MSTP218, MSTP217, MSTP216, MSTP214,
351 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200, 467 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
352 468
353 MSTP329, MSTP328, MSTP323, MSTP320, 469 MSTP329, MSTP328, MSTP323, MSTP320,
@@ -360,6 +476,8 @@ enum {
360}; 476};
361 477
362static struct clk mstp_clks[MSTP_NR] = { 478static struct clk mstp_clks[MSTP_NR] = {
479 [MSTP128] = SH_CLK_MSTP32(&div4_clks[DIV4_S], SMSTPCR1, 28, 0), /* CEU21 */
480 [MSTP127] = SH_CLK_MSTP32(&div4_clks[DIV4_S], SMSTPCR1, 27, 0), /* CEU20 */
363 [MSTP125] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 25, 0), /* TMU0 */ 481 [MSTP125] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 25, 0), /* TMU0 */
364 [MSTP117] = SH_CLK_MSTP32(&div4_clks[DIV4_B], SMSTPCR1, 17, 0), /* LCDC1 */ 482 [MSTP117] = SH_CLK_MSTP32(&div4_clks[DIV4_B], SMSTPCR1, 17, 0), /* LCDC1 */
365 [MSTP116] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 16, 0), /* IIC0 */ 483 [MSTP116] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 16, 0), /* IIC0 */
@@ -368,6 +486,10 @@ static struct clk mstp_clks[MSTP_NR] = {
368 486
369 [MSTP230] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 30, 0), /* SCIFA6 */ 487 [MSTP230] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 30, 0), /* SCIFA6 */
370 [MSTP222] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 22, 0), /* SCIFA7 */ 488 [MSTP222] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 22, 0), /* SCIFA7 */
489 [MSTP218] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 18, 0), /* DMAC1 */
490 [MSTP217] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 17, 0), /* DMAC2 */
491 [MSTP216] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 16, 0), /* DMAC3 */
492 [MSTP214] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 14, 0), /* USBDMAC */
371 [MSTP207] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */ 493 [MSTP207] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */
372 [MSTP206] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */ 494 [MSTP206] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */
373 [MSTP204] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 4, 0), /* SCIFA0 */ 495 [MSTP204] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 4, 0), /* SCIFA0 */
@@ -408,6 +530,12 @@ static struct clk_lookup lookups[] = {
408 CLKDEV_CON_ID("pllc1_clk", &pllc1_clk), 530 CLKDEV_CON_ID("pllc1_clk", &pllc1_clk),
409 CLKDEV_CON_ID("pllc1_div2_clk", &pllc1_div2_clk), 531 CLKDEV_CON_ID("pllc1_div2_clk", &pllc1_div2_clk),
410 CLKDEV_CON_ID("usb24s", &usb24s_clk), 532 CLKDEV_CON_ID("usb24s", &usb24s_clk),
533 CLKDEV_CON_ID("hdmi1", &hdmi1_clk),
534 CLKDEV_CON_ID("hdmi2", &hdmi2_clk),
535 CLKDEV_CON_ID("video1", &div6_reparent_clks[DIV6_VCLK1]),
536 CLKDEV_CON_ID("video2", &div6_reparent_clks[DIV6_VCLK2]),
537 CLKDEV_CON_ID("fsiack", &fsiack_clk),
538 CLKDEV_CON_ID("fsibck", &fsibck_clk),
411 539
412 /* DIV4 clocks */ 540 /* DIV4 clocks */
413 CLKDEV_CON_ID("i_clk", &div4_clks[DIV4_I]), 541 CLKDEV_CON_ID("i_clk", &div4_clks[DIV4_I]),
@@ -430,6 +558,8 @@ static struct clk_lookup lookups[] = {
430 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), 558 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]),
431 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]), 559 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]),
432 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), 560 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]),
561 CLKDEV_DEV_ID("sh_mobile_ceu.0", &mstp_clks[MSTP127]),
562 CLKDEV_DEV_ID("sh_mobile_ceu.1", &mstp_clks[MSTP128]),
433 563
434 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), 564 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]),
435 CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP201]), 565 CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP201]),
@@ -438,7 +568,10 @@ static struct clk_lookup lookups[] = {
438 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), 568 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]),
439 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]), 569 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]),
440 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]), 570 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]),
441 571 CLKDEV_DEV_ID("sh-dma-engine.3", &mstp_clks[MSTP214]),
572 CLKDEV_DEV_ID("sh-dma-engine.2", &mstp_clks[MSTP216]),
573 CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[MSTP217]),
574 CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]),
442 CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP222]), 575 CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP222]),
443 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP230]), 576 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP230]),
444 577
@@ -459,6 +592,10 @@ static struct clk_lookup lookups[] = {
459 CLKDEV_ICK_ID("phy", "renesas_usbhs", &mstp_clks[MSTP406]), 592 CLKDEV_ICK_ID("phy", "renesas_usbhs", &mstp_clks[MSTP406]),
460 CLKDEV_ICK_ID("pci", "renesas_usbhs", &div4_clks[DIV4_USBP]), 593 CLKDEV_ICK_ID("pci", "renesas_usbhs", &div4_clks[DIV4_USBP]),
461 CLKDEV_ICK_ID("usb24", "renesas_usbhs", &usb24_clk), 594 CLKDEV_ICK_ID("usb24", "renesas_usbhs", &usb24_clk),
595 CLKDEV_ICK_ID("ick", "sh-mobile-hdmi", &div6_reparent_clks[DIV6_HDMI]),
596
597 CLKDEV_ICK_ID("icka", "sh_fsi2", &div6_reparent_clks[DIV6_FSIA]),
598 CLKDEV_ICK_ID("ickb", "sh_fsi2", &div6_reparent_clks[DIV6_FSIB]),
462}; 599};
463 600
464void __init r8a7740_clock_init(u8 md_ck) 601void __init r8a7740_clock_init(u8 md_ck)
@@ -495,7 +632,14 @@ void __init r8a7740_clock_init(u8 md_ck)
495 ret = sh_clk_div6_register(div6_clks, DIV6_NR); 632 ret = sh_clk_div6_register(div6_clks, DIV6_NR);
496 633
497 if (!ret) 634 if (!ret)
498 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 635 ret = sh_clk_div6_reparent_register(div6_reparent_clks,
636 DIV6_REPARENT_NR);
637
638 if (!ret)
639 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
640
641 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++)
642 ret = clk_register(late_main_clks[k]);
499 643
500 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 644 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
501 645
diff --git a/arch/arm/mach-shmobile/clock-r8a7779.c b/arch/arm/mach-shmobile/clock-r8a7779.c
index 7d6e9fe47b56..339c62c824d5 100644
--- a/arch/arm/mach-shmobile/clock-r8a7779.c
+++ b/arch/arm/mach-shmobile/clock-r8a7779.c
@@ -162,7 +162,7 @@ void __init r8a7779_clock_init(void)
162 ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table); 162 ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table);
163 163
164 if (!ret) 164 if (!ret)
165 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 165 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
166 166
167 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++) 167 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++)
168 ret = clk_register(late_main_clks[k]); 168 ret = clk_register(late_main_clks[k]);
diff --git a/arch/arm/mach-shmobile/clock-sh7367.c b/arch/arm/mach-shmobile/clock-sh7367.c
index 006e7b5d304c..162b791b8984 100644
--- a/arch/arm/mach-shmobile/clock-sh7367.c
+++ b/arch/arm/mach-shmobile/clock-sh7367.c
@@ -344,7 +344,7 @@ void __init sh7367_clock_init(void)
344 ret = sh_clk_div6_register(div6_clks, DIV6_NR); 344 ret = sh_clk_div6_register(div6_clks, DIV6_NR);
345 345
346 if (!ret) 346 if (!ret)
347 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 347 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
348 348
349 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 349 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
350 350
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
index 94d1f88246d3..5a2894b1c965 100644
--- a/arch/arm/mach-shmobile/clock-sh7372.c
+++ b/arch/arm/mach-shmobile/clock-sh7372.c
@@ -704,7 +704,7 @@ void __init sh7372_clock_init(void)
704 ret = sh_clk_div6_reparent_register(div6_reparent_clks, DIV6_REPARENT_NR); 704 ret = sh_clk_div6_reparent_register(div6_reparent_clks, DIV6_REPARENT_NR);
705 705
706 if (!ret) 706 if (!ret)
707 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 707 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
708 708
709 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++) 709 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++)
710 ret = clk_register(late_main_clks[k]); 710 ret = clk_register(late_main_clks[k]);
diff --git a/arch/arm/mach-shmobile/clock-sh7377.c b/arch/arm/mach-shmobile/clock-sh7377.c
index 0798a15936c3..85f2a3ec2c44 100644
--- a/arch/arm/mach-shmobile/clock-sh7377.c
+++ b/arch/arm/mach-shmobile/clock-sh7377.c
@@ -355,7 +355,7 @@ void __init sh7377_clock_init(void)
355 ret = sh_clk_div6_register(div6_clks, DIV6_NR); 355 ret = sh_clk_div6_register(div6_clks, DIV6_NR);
356 356
357 if (!ret) 357 if (!ret)
358 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 358 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
359 359
360 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 360 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
361 361
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index 3946c4ba2aa8..7f8da18a8580 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -475,9 +475,9 @@ static struct clk *late_main_clks[] = {
475 475
476enum { MSTP001, 476enum { MSTP001,
477 MSTP129, MSTP128, MSTP127, MSTP126, MSTP125, MSTP118, MSTP116, MSTP100, 477 MSTP129, MSTP128, MSTP127, MSTP126, MSTP125, MSTP118, MSTP116, MSTP100,
478 MSTP219, MSTP218, 478 MSTP219, MSTP218, MSTP217,
479 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200, 479 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
480 MSTP331, MSTP329, MSTP325, MSTP323, 480 MSTP331, MSTP329, MSTP328, MSTP325, MSTP323, MSTP322,
481 MSTP314, MSTP313, MSTP312, MSTP311, 481 MSTP314, MSTP313, MSTP312, MSTP311,
482 MSTP303, MSTP302, MSTP301, MSTP300, 482 MSTP303, MSTP302, MSTP301, MSTP300,
483 MSTP411, MSTP410, MSTP403, 483 MSTP411, MSTP410, MSTP403,
@@ -498,6 +498,7 @@ static struct clk mstp_clks[MSTP_NR] = {
498 [MSTP100] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 0, 0), /* LCDC0 */ 498 [MSTP100] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 0, 0), /* LCDC0 */
499 [MSTP219] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 19, 0), /* SCIFA7 */ 499 [MSTP219] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 19, 0), /* SCIFA7 */
500 [MSTP218] = MSTP(&div4_clks[DIV4_HP], SMSTPCR2, 18, 0), /* SY-DMAC */ 500 [MSTP218] = MSTP(&div4_clks[DIV4_HP], SMSTPCR2, 18, 0), /* SY-DMAC */
501 [MSTP217] = MSTP(&div4_clks[DIV4_HP], SMSTPCR2, 17, 0), /* MP-DMAC */
501 [MSTP207] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */ 502 [MSTP207] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 7, 0), /* SCIFA5 */
502 [MSTP206] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */ 503 [MSTP206] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 6, 0), /* SCIFB */
503 [MSTP204] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 4, 0), /* SCIFA0 */ 504 [MSTP204] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 4, 0), /* SCIFA0 */
@@ -507,8 +508,10 @@ static struct clk mstp_clks[MSTP_NR] = {
507 [MSTP200] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 0, 0), /* SCIFA4 */ 508 [MSTP200] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 0, 0), /* SCIFA4 */
508 [MSTP331] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 31, 0), /* SCIFA6 */ 509 [MSTP331] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 31, 0), /* SCIFA6 */
509 [MSTP329] = MSTP(&r_clk, SMSTPCR3, 29, 0), /* CMT10 */ 510 [MSTP329] = MSTP(&r_clk, SMSTPCR3, 29, 0), /* CMT10 */
511 [MSTP328] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 28, 0), /*FSI*/
510 [MSTP325] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 25, 0), /* IrDA */ 512 [MSTP325] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 25, 0), /* IrDA */
511 [MSTP323] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 23, 0), /* IIC1 */ 513 [MSTP323] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 23, 0), /* IIC1 */
514 [MSTP322] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 22, 0), /* USB */
512 [MSTP314] = MSTP(&div6_clks[DIV6_SDHI0], SMSTPCR3, 14, 0), /* SDHI0 */ 515 [MSTP314] = MSTP(&div6_clks[DIV6_SDHI0], SMSTPCR3, 14, 0), /* SDHI0 */
513 [MSTP313] = MSTP(&div6_clks[DIV6_SDHI1], SMSTPCR3, 13, 0), /* SDHI1 */ 516 [MSTP313] = MSTP(&div6_clks[DIV6_SDHI1], SMSTPCR3, 13, 0), /* SDHI1 */
514 [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMCIF0 */ 517 [MSTP312] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 12, 0), /* MMCIF0 */
@@ -553,6 +556,7 @@ static struct clk_lookup lookups[] = {
553 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0", &mstp_clks[MSTP100]), /* LCDC0 */ 556 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0", &mstp_clks[MSTP100]), /* LCDC0 */
554 CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP219]), /* SCIFA7 */ 557 CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP219]), /* SCIFA7 */
555 CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]), /* SY-DMAC */ 558 CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]), /* SY-DMAC */
559 CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[MSTP217]), /* MP-DMAC */
556 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]), /* SCIFA5 */ 560 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]), /* SCIFA5 */
557 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]), /* SCIFB */ 561 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]), /* SCIFB */
558 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), /* SCIFA0 */ 562 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), /* SCIFA0 */
@@ -562,8 +566,10 @@ static struct clk_lookup lookups[] = {
562 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */ 566 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */
563 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */ 567 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */
564 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */ 568 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */
569 CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]), /* FSI */
565 CLKDEV_DEV_ID("sh_irda.0", &mstp_clks[MSTP325]), /* IrDA */ 570 CLKDEV_DEV_ID("sh_irda.0", &mstp_clks[MSTP325]), /* IrDA */
566 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* I2C1 */ 571 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* I2C1 */
572 CLKDEV_DEV_ID("renesas_usbhs", &mstp_clks[MSTP322]), /* USB */
567 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]), /* SDHI0 */ 573 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]), /* SDHI0 */
568 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]), /* SDHI1 */ 574 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]), /* SDHI1 */
569 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMCIF0 */ 575 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP312]), /* MMCIF0 */
@@ -612,7 +618,7 @@ void __init sh73a0_clock_init(void)
612 ret = sh_clk_div6_reparent_register(div6_clks, DIV6_NR); 618 ret = sh_clk_div6_reparent_register(div6_clks, DIV6_NR);
613 619
614 if (!ret) 620 if (!ret)
615 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 621 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
616 622
617 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++) 623 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++)
618 ret = clk_register(late_main_clks[k]); 624 ret = clk_register(late_main_clks[k]);
diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index 01e2bc014f15..45e61dada030 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -77,6 +77,7 @@ extern void r8a7779_add_standard_devices(void);
77extern void r8a7779_clock_init(void); 77extern void r8a7779_clock_init(void);
78extern void r8a7779_pinmux_init(void); 78extern void r8a7779_pinmux_init(void);
79extern void r8a7779_pm_init(void); 79extern void r8a7779_pm_init(void);
80extern void r8a7740_meram_workaround(void);
80 81
81extern unsigned int r8a7779_get_core_count(void); 82extern unsigned int r8a7779_get_core_count(void);
82extern int r8a7779_platform_cpu_kill(unsigned int cpu); 83extern int r8a7779_platform_cpu_kill(unsigned int cpu);
diff --git a/arch/arm/mach-shmobile/include/mach/dma-register.h b/arch/arm/mach-shmobile/include/mach/dma-register.h
new file mode 100644
index 000000000000..97c40bd9b94f
--- /dev/null
+++ b/arch/arm/mach-shmobile/include/mach/dma-register.h
@@ -0,0 +1,84 @@
1/*
2 * SH-ARM CPU-specific DMA definitions, used by both DMA drivers
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp
5 *
6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7 *
8 * Based on arch/sh/include/cpu-sh4/cpu/dma-register.h
9 * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#ifndef DMA_REGISTER_H
17#define DMA_REGISTER_H
18
19/*
20 * Direct Memory Access Controller
21 */
22
23/* Transmit sizes and respective CHCR register values */
24enum {
25 XMIT_SZ_8BIT = 0,
26 XMIT_SZ_16BIT = 1,
27 XMIT_SZ_32BIT = 2,
28 XMIT_SZ_64BIT = 7,
29 XMIT_SZ_128BIT = 3,
30 XMIT_SZ_256BIT = 4,
31 XMIT_SZ_512BIT = 5,
32};
33
34/* log2(size / 8) - used to calculate number of transfers */
35static const unsigned int dma_ts_shift[] = {
36 [XMIT_SZ_8BIT] = 0,
37 [XMIT_SZ_16BIT] = 1,
38 [XMIT_SZ_32BIT] = 2,
39 [XMIT_SZ_64BIT] = 3,
40 [XMIT_SZ_128BIT] = 4,
41 [XMIT_SZ_256BIT] = 5,
42 [XMIT_SZ_512BIT] = 6,
43};
44
45#define TS_LOW_BIT 0x3 /* --xx */
46#define TS_HI_BIT 0xc /* xx-- */
47
48#define TS_LOW_SHIFT (3)
49#define TS_HI_SHIFT (20 - 2) /* 2 bits for shifted low TS */
50
51#define TS_INDEX2VAL(i) \
52 ((((i) & TS_LOW_BIT) << TS_LOW_SHIFT) |\
53 (((i) & TS_HI_BIT) << TS_HI_SHIFT))
54
55#define CHCR_TX(xmit_sz) (DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL((xmit_sz)))
56#define CHCR_RX(xmit_sz) (DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL((xmit_sz)))
57
58
59/*
60 * USB High-Speed DMAC
61 */
62/* Transmit sizes and respective CHCR register values */
63enum {
64 USBTS_XMIT_SZ_8BYTE = 0,
65 USBTS_XMIT_SZ_16BYTE = 1,
66 USBTS_XMIT_SZ_32BYTE = 2,
67};
68
69/* log2(size / 8) - used to calculate number of transfers */
70static const unsigned int dma_usbts_shift[] = {
71 [USBTS_XMIT_SZ_8BYTE] = 3,
72 [USBTS_XMIT_SZ_16BYTE] = 4,
73 [USBTS_XMIT_SZ_32BYTE] = 5,
74};
75
76#define USBTS_LOW_BIT 0x3 /* --xx */
77#define USBTS_HI_BIT 0x0 /* ---- */
78
79#define USBTS_LOW_SHIFT 6
80#define USBTS_HI_SHIFT 0
81
82#define USBTS_INDEX2VAL(i) (((i) & 3) << 6)
83
84#endif /* DMA_REGISTER_H */
diff --git a/arch/arm/mach-shmobile/include/mach/gpio.h b/arch/arm/mach-shmobile/include/mach/gpio.h
index de795b42232a..844507d937cb 100644
--- a/arch/arm/mach-shmobile/include/mach/gpio.h
+++ b/arch/arm/mach-shmobile/include/mach/gpio.h
@@ -13,6 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/sh_pfc.h> 15#include <linux/sh_pfc.h>
16#include <linux/io.h>
16 17
17#ifdef CONFIG_GPIOLIB 18#ifdef CONFIG_GPIOLIB
18 19
@@ -27,4 +28,35 @@ static inline int irq_to_gpio(unsigned int irq)
27 28
28#endif /* CONFIG_GPIOLIB */ 29#endif /* CONFIG_GPIOLIB */
29 30
31/*
32 * FIXME !!
33 *
34 * current gpio frame work doesn't have
35 * the method to control only pull up/down/free.
36 * this function should be replaced by correct gpio function
37 */
38static inline void __init gpio_direction_none(u32 addr)
39{
40 __raw_writeb(0x00, addr);
41}
42
43static inline void __init gpio_request_pullup(u32 addr)
44{
45 u8 data = __raw_readb(addr);
46
47 data &= 0x0F;
48 data |= 0xC0;
49 __raw_writeb(data, addr);
50}
51
52static inline void __init gpio_request_pulldown(u32 addr)
53{
54 u8 data = __raw_readb(addr);
55
56 data &= 0x0F;
57 data |= 0xA0;
58
59 __raw_writeb(data, addr);
60}
61
30#endif /* __ASM_ARCH_GPIO_H */ 62#endif /* __ASM_ARCH_GPIO_H */
diff --git a/arch/arm/mach-shmobile/include/mach/pm-rmobile.h b/arch/arm/mach-shmobile/include/mach/pm-rmobile.h
new file mode 100644
index 000000000000..5a402840fe28
--- /dev/null
+++ b/arch/arm/mach-shmobile/include/mach/pm-rmobile.h
@@ -0,0 +1,44 @@
1/*
2 * Copyright (C) 2012 Renesas Solutions Corp.
3 *
4 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#ifndef PM_RMOBILE_H
11#define PM_RMOBILE_H
12
13#include <linux/pm_domain.h>
14
15struct platform_device;
16
17struct rmobile_pm_domain {
18 struct generic_pm_domain genpd;
19 struct dev_power_governor *gov;
20 int (*suspend)(void);
21 void (*resume)(void);
22 unsigned int bit_shift;
23 bool no_debug;
24};
25
26static inline
27struct rmobile_pm_domain *to_rmobile_pd(struct generic_pm_domain *d)
28{
29 return container_of(d, struct rmobile_pm_domain, genpd);
30}
31
32#ifdef CONFIG_PM
33extern void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd);
34extern void rmobile_add_device_to_domain(struct rmobile_pm_domain *rmobile_pd,
35 struct platform_device *pdev);
36extern void rmobile_pm_add_subdomain(struct rmobile_pm_domain *rmobile_pd,
37 struct rmobile_pm_domain *rmobile_sd);
38#else
39#define rmobile_init_pm_domain(pd) do { } while (0)
40#define rmobile_add_device_to_domain(pd, pdev) do { } while (0)
41#define rmobile_pm_add_subdomain(pd, sd) do { } while (0)
42#endif /* CONFIG_PM */
43
44#endif /* PM_RMOBILE_H */
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7740.h b/arch/arm/mach-shmobile/include/mach/r8a7740.h
index 9d447abb969c..7143147780df 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7740.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7740.h
@@ -19,6 +19,8 @@
19#ifndef __ASM_R8A7740_H__ 19#ifndef __ASM_R8A7740_H__
20#define __ASM_R8A7740_H__ 20#define __ASM_R8A7740_H__
21 21
22#include <mach/pm-rmobile.h>
23
22/* 24/*
23 * MD_CKx pin 25 * MD_CKx pin
24 */ 26 */
@@ -139,7 +141,7 @@ enum {
139 GPIO_FN_DBGMD10, GPIO_FN_DBGMD11, GPIO_FN_DBGMD20, 141 GPIO_FN_DBGMD10, GPIO_FN_DBGMD11, GPIO_FN_DBGMD20,
140 GPIO_FN_DBGMD21, 142 GPIO_FN_DBGMD21,
141 143
142 /* FSI */ 144 /* FSI-A */
143 GPIO_FN_FSIAISLD_PORT0, /* FSIAISLD Port 0/5 */ 145 GPIO_FN_FSIAISLD_PORT0, /* FSIAISLD Port 0/5 */
144 GPIO_FN_FSIAISLD_PORT5, 146 GPIO_FN_FSIAISLD_PORT5,
145 GPIO_FN_FSIASPDIF_PORT9, /* FSIASPDIF Port 9/18 */ 147 GPIO_FN_FSIASPDIF_PORT9, /* FSIASPDIF Port 9/18 */
@@ -150,6 +152,9 @@ enum {
150 GPIO_FN_FSIACK, GPIO_FN_FSIAILR, 152 GPIO_FN_FSIACK, GPIO_FN_FSIAILR,
151 GPIO_FN_FSIAIBT, 153 GPIO_FN_FSIAIBT,
152 154
155 /* FSI-B */
156 GPIO_FN_FSIBCK,
157
153 /* FMSI */ 158 /* FMSI */
154 GPIO_FN_FMSISLD_PORT1, /* FMSISLD Port 1/6 */ 159 GPIO_FN_FMSISLD_PORT1, /* FMSISLD Port 1/6 */
155 GPIO_FN_FMSISLD_PORT6, 160 GPIO_FN_FMSISLD_PORT6,
@@ -565,6 +570,10 @@ enum {
565 GPIO_FN_RESETP_PULLUP, 570 GPIO_FN_RESETP_PULLUP,
566 GPIO_FN_RESETP_PLAIN, 571 GPIO_FN_RESETP_PLAIN,
567 572
573 /* HDMI */
574 GPIO_FN_HDMI_HPD,
575 GPIO_FN_HDMI_CEC,
576
568 /* SDENC */ 577 /* SDENC */
569 GPIO_FN_SDENC_CPG, 578 GPIO_FN_SDENC_CPG,
570 GPIO_FN_SDENC_DV_CLKI, 579 GPIO_FN_SDENC_DV_CLKI,
@@ -581,4 +590,26 @@ enum {
581 GPIO_FN_TRACEAUD_FROM_MEMC, 590 GPIO_FN_TRACEAUD_FROM_MEMC,
582}; 591};
583 592
593/* DMA slave IDs */
594enum {
595 SHDMA_SLAVE_INVALID,
596 SHDMA_SLAVE_SDHI0_RX,
597 SHDMA_SLAVE_SDHI0_TX,
598 SHDMA_SLAVE_SDHI1_RX,
599 SHDMA_SLAVE_SDHI1_TX,
600 SHDMA_SLAVE_SDHI2_RX,
601 SHDMA_SLAVE_SDHI2_TX,
602 SHDMA_SLAVE_FSIA_RX,
603 SHDMA_SLAVE_FSIA_TX,
604 SHDMA_SLAVE_FSIB_TX,
605 SHDMA_SLAVE_USBHS_TX,
606 SHDMA_SLAVE_USBHS_RX,
607};
608
609#ifdef CONFIG_PM
610extern struct rmobile_pm_domain r8a7740_pd_a4s;
611extern struct rmobile_pm_domain r8a7740_pd_a3sp;
612extern struct rmobile_pm_domain r8a7740_pd_a4lc;
613#endif /* CONFIG_PM */
614
584#endif /* __ASM_R8A7740_H__ */ 615#endif /* __ASM_R8A7740_H__ */
diff --git a/arch/arm/mach-shmobile/include/mach/sh7372.h b/arch/arm/mach-shmobile/include/mach/sh7372.h
index 915d0093da08..b59048e6d8fd 100644
--- a/arch/arm/mach-shmobile/include/mach/sh7372.h
+++ b/arch/arm/mach-shmobile/include/mach/sh7372.h
@@ -13,6 +13,7 @@
13 13
14#include <linux/sh_clk.h> 14#include <linux/sh_clk.h>
15#include <linux/pm_domain.h> 15#include <linux/pm_domain.h>
16#include <mach/pm-rmobile.h>
16 17
17/* 18/*
18 * Pin Function Controller: 19 * Pin Function Controller:
@@ -477,42 +478,16 @@ extern struct clk sh7372_fsibck_clk;
477extern struct clk sh7372_fsidiva_clk; 478extern struct clk sh7372_fsidiva_clk;
478extern struct clk sh7372_fsidivb_clk; 479extern struct clk sh7372_fsidivb_clk;
479 480
480struct platform_device;
481
482struct sh7372_pm_domain {
483 struct generic_pm_domain genpd;
484 struct dev_power_governor *gov;
485 int (*suspend)(void);
486 void (*resume)(void);
487 unsigned int bit_shift;
488 bool no_debug;
489};
490
491static inline struct sh7372_pm_domain *to_sh7372_pd(struct generic_pm_domain *d)
492{
493 return container_of(d, struct sh7372_pm_domain, genpd);
494}
495
496#ifdef CONFIG_PM 481#ifdef CONFIG_PM
497extern struct sh7372_pm_domain sh7372_a4lc; 482extern struct rmobile_pm_domain sh7372_pd_a4lc;
498extern struct sh7372_pm_domain sh7372_a4mp; 483extern struct rmobile_pm_domain sh7372_pd_a4mp;
499extern struct sh7372_pm_domain sh7372_d4; 484extern struct rmobile_pm_domain sh7372_pd_d4;
500extern struct sh7372_pm_domain sh7372_a4r; 485extern struct rmobile_pm_domain sh7372_pd_a4r;
501extern struct sh7372_pm_domain sh7372_a3rv; 486extern struct rmobile_pm_domain sh7372_pd_a3rv;
502extern struct sh7372_pm_domain sh7372_a3ri; 487extern struct rmobile_pm_domain sh7372_pd_a3ri;
503extern struct sh7372_pm_domain sh7372_a4s; 488extern struct rmobile_pm_domain sh7372_pd_a4s;
504extern struct sh7372_pm_domain sh7372_a3sp; 489extern struct rmobile_pm_domain sh7372_pd_a3sp;
505extern struct sh7372_pm_domain sh7372_a3sg; 490extern struct rmobile_pm_domain sh7372_pd_a3sg;
506
507extern void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd);
508extern void sh7372_add_device_to_domain(struct sh7372_pm_domain *sh7372_pd,
509 struct platform_device *pdev);
510extern void sh7372_pm_add_subdomain(struct sh7372_pm_domain *sh7372_pd,
511 struct sh7372_pm_domain *sh7372_sd);
512#else
513#define sh7372_init_pm_domain(pd) do { } while(0)
514#define sh7372_add_device_to_domain(pd, pdev) do { } while(0)
515#define sh7372_pm_add_subdomain(pd, sd) do { } while(0)
516#endif /* CONFIG_PM */ 491#endif /* CONFIG_PM */
517 492
518extern void sh7372_intcs_suspend(void); 493extern void sh7372_intcs_suspend(void);
diff --git a/arch/arm/mach-shmobile/include/mach/sh73a0.h b/arch/arm/mach-shmobile/include/mach/sh73a0.h
index 398e2c10913b..fe950f25d793 100644
--- a/arch/arm/mach-shmobile/include/mach/sh73a0.h
+++ b/arch/arm/mach-shmobile/include/mach/sh73a0.h
@@ -516,6 +516,13 @@ enum {
516 SHDMA_SLAVE_SDHI2_RX, 516 SHDMA_SLAVE_SDHI2_RX,
517 SHDMA_SLAVE_MMCIF_TX, 517 SHDMA_SLAVE_MMCIF_TX,
518 SHDMA_SLAVE_MMCIF_RX, 518 SHDMA_SLAVE_MMCIF_RX,
519 SHDMA_SLAVE_FSI2A_TX,
520 SHDMA_SLAVE_FSI2A_RX,
521 SHDMA_SLAVE_FSI2B_TX,
522 SHDMA_SLAVE_FSI2B_RX,
523 SHDMA_SLAVE_FSI2C_TX,
524 SHDMA_SLAVE_FSI2C_RX,
525 SHDMA_SLAVE_FSI2D_RX,
519}; 526};
520 527
521/* 528/*
diff --git a/arch/arm/mach-shmobile/intc-r8a7740.c b/arch/arm/mach-shmobile/intc-r8a7740.c
index 09c42afcb22d..9a69a31918ba 100644
--- a/arch/arm/mach-shmobile/intc-r8a7740.c
+++ b/arch/arm/mach-shmobile/intc-r8a7740.c
@@ -71,10 +71,12 @@ enum {
71 DMAC3_1_DEI0, DMAC3_1_DEI1, DMAC3_1_DEI2, DMAC3_1_DEI3, 71 DMAC3_1_DEI0, DMAC3_1_DEI1, DMAC3_1_DEI2, DMAC3_1_DEI3,
72 DMAC3_2_DEI4, DMAC3_2_DEI5, DMAC3_2_DADERR, 72 DMAC3_2_DEI4, DMAC3_2_DEI5, DMAC3_2_DADERR,
73 SHWYSTAT_RT, SHWYSTAT_HS, SHWYSTAT_COM, 73 SHWYSTAT_RT, SHWYSTAT_HS, SHWYSTAT_COM,
74 HDMI,
74 USBH_INT, USBH_OHCI, USBH_EHCI, USBH_PME, USBH_BIND, 75 USBH_INT, USBH_OHCI, USBH_EHCI, USBH_PME, USBH_BIND,
75 RSPI_OVRF, RSPI_SPTEF, RSPI_SPRF, 76 RSPI_OVRF, RSPI_SPTEF, RSPI_SPRF,
76 SPU2_0, SPU2_1, 77 SPU2_0, SPU2_1,
77 FSI, FMSI, 78 FSI, FMSI,
79 HDMI_SSS, HDMI_KEY,
78 IPMMU, 80 IPMMU,
79 AP_ARM_CTIIRQ, AP_ARM_PMURQ, 81 AP_ARM_CTIIRQ, AP_ARM_PMURQ,
80 MFIS2, 82 MFIS2,
@@ -182,6 +184,7 @@ static struct intc_vect intca_vectors[] __initdata = {
182 INTC_VECT(USBH_EHCI, 0x1580), 184 INTC_VECT(USBH_EHCI, 0x1580),
183 INTC_VECT(USBH_PME, 0x15A0), 185 INTC_VECT(USBH_PME, 0x15A0),
184 INTC_VECT(USBH_BIND, 0x15C0), 186 INTC_VECT(USBH_BIND, 0x15C0),
187 INTC_VECT(HDMI, 0x1700),
185 INTC_VECT(RSPI_OVRF, 0x1780), 188 INTC_VECT(RSPI_OVRF, 0x1780),
186 INTC_VECT(RSPI_SPTEF, 0x17A0), 189 INTC_VECT(RSPI_SPTEF, 0x17A0),
187 INTC_VECT(RSPI_SPRF, 0x17C0), 190 INTC_VECT(RSPI_SPRF, 0x17C0),
@@ -189,6 +192,8 @@ static struct intc_vect intca_vectors[] __initdata = {
189 INTC_VECT(SPU2_1, 0x1820), 192 INTC_VECT(SPU2_1, 0x1820),
190 INTC_VECT(FSI, 0x1840), 193 INTC_VECT(FSI, 0x1840),
191 INTC_VECT(FMSI, 0x1860), 194 INTC_VECT(FMSI, 0x1860),
195 INTC_VECT(HDMI_SSS, 0x18A0),
196 INTC_VECT(HDMI_KEY, 0x18C0),
192 INTC_VECT(IPMMU, 0x1920), 197 INTC_VECT(IPMMU, 0x1920),
193 INTC_VECT(AP_ARM_CTIIRQ, 0x1980), 198 INTC_VECT(AP_ARM_CTIIRQ, 0x1980),
194 INTC_VECT(AP_ARM_PMURQ, 0x19A0), 199 INTC_VECT(AP_ARM_PMURQ, 0x19A0),
@@ -304,11 +309,11 @@ static struct intc_mask_reg intca_mask_registers[] __initdata = {
304 USBH_EHCI, USBH_PME, USBH_BIND, 0 } }, 309 USBH_EHCI, USBH_PME, USBH_BIND, 0 } },
305 /* IMR3A3 / IMCR3A3 */ 310 /* IMR3A3 / IMCR3A3 */
306 { /* IMR4A3 / IMCR4A3 */ 0xe6950090, 0xe69500d0, 8, 311 { /* IMR4A3 / IMCR4A3 */ 0xe6950090, 0xe69500d0, 8,
307 { 0, 0, 0, 0, 312 { HDMI, 0, 0, 0,
308 RSPI_OVRF, RSPI_SPTEF, RSPI_SPRF, 0 } }, 313 RSPI_OVRF, RSPI_SPTEF, RSPI_SPRF, 0 } },
309 { /* IMR5A3 / IMCR5A3 */ 0xe6950094, 0xe69500d4, 8, 314 { /* IMR5A3 / IMCR5A3 */ 0xe6950094, 0xe69500d4, 8,
310 { SPU2_0, SPU2_1, FSI, FMSI, 315 { SPU2_0, SPU2_1, FSI, FMSI,
311 0, 0, 0, 0 } }, 316 0, HDMI_SSS, HDMI_KEY, 0 } },
312 { /* IMR6A3 / IMCR6A3 */ 0xe6950098, 0xe69500d8, 8, 317 { /* IMR6A3 / IMCR6A3 */ 0xe6950098, 0xe69500d8, 8,
313 { 0, IPMMU, 0, 0, 318 { 0, IPMMU, 0, 0,
314 AP_ARM_CTIIRQ, AP_ARM_PMURQ, 0, 0 } }, 319 AP_ARM_CTIIRQ, AP_ARM_PMURQ, 0, 0 } },
@@ -353,10 +358,10 @@ static struct intc_prio_reg intca_prio_registers[] __initdata = {
353 { 0xe6950014, 0, 16, 4, /* IPRFA3 */ { USBH2, 0, 0, 0 } }, 358 { 0xe6950014, 0, 16, 4, /* IPRFA3 */ { USBH2, 0, 0, 0 } },
354 /* IPRGA3 */ 359 /* IPRGA3 */
355 /* IPRHA3 */ 360 /* IPRHA3 */
356 /* IPRIA3 */ 361 { 0xe6950020, 0, 16, 4, /* IPRIA3 */ { HDMI, 0, 0, 0 } },
357 { 0xe6950024, 0, 16, 4, /* IPRJA3 */ { RSPI, 0, 0, 0 } }, 362 { 0xe6950024, 0, 16, 4, /* IPRJA3 */ { RSPI, 0, 0, 0 } },
358 { 0xe6950028, 0, 16, 4, /* IPRKA3 */ { SPU2, 0, FSI, FMSI } }, 363 { 0xe6950028, 0, 16, 4, /* IPRKA3 */ { SPU2, 0, FSI, FMSI } },
359 /* IPRLA3 */ 364 { 0xe695002c, 0, 16, 4, /* IPRLA3 */ { 0, HDMI_SSS, HDMI_KEY, 0 } },
360 { 0xe6950030, 0, 16, 4, /* IPRMA3 */ { IPMMU, 0, 0, 0 } }, 365 { 0xe6950030, 0, 16, 4, /* IPRMA3 */ { IPMMU, 0, 0, 0 } },
361 { 0xe6950034, 0, 16, 4, /* IPRNA3 */ { AP_ARM2, 0, 0, 0 } }, 366 { 0xe6950034, 0, 16, 4, /* IPRNA3 */ { AP_ARM2, 0, 0, 0 } },
362 { 0xe6950038, 0, 16, 4, /* IPROA3 */ { MFIS2, CPORTR2S, 367 { 0xe6950038, 0, 16, 4, /* IPROA3 */ { MFIS2, CPORTR2S,
diff --git a/arch/arm/mach-shmobile/pfc-r8a7740.c b/arch/arm/mach-shmobile/pfc-r8a7740.c
index 670fe1869dbc..ce9e7fa5cc8a 100644
--- a/arch/arm/mach-shmobile/pfc-r8a7740.c
+++ b/arch/arm/mach-shmobile/pfc-r8a7740.c
@@ -169,7 +169,7 @@ enum {
169 DBGMD10_MARK, DBGMD11_MARK, DBGMD20_MARK, 169 DBGMD10_MARK, DBGMD11_MARK, DBGMD20_MARK,
170 DBGMD21_MARK, 170 DBGMD21_MARK,
171 171
172 /* FSI */ 172 /* FSI-A */
173 FSIAISLD_PORT0_MARK, /* FSIAISLD Port 0/5 */ 173 FSIAISLD_PORT0_MARK, /* FSIAISLD Port 0/5 */
174 FSIAISLD_PORT5_MARK, 174 FSIAISLD_PORT5_MARK,
175 FSIASPDIF_PORT9_MARK, /* FSIASPDIF Port 9/18 */ 175 FSIASPDIF_PORT9_MARK, /* FSIASPDIF Port 9/18 */
@@ -178,6 +178,9 @@ enum {
178 FSIAOBT_MARK, FSIAOSLD_MARK, FSIAOMC_MARK, 178 FSIAOBT_MARK, FSIAOSLD_MARK, FSIAOMC_MARK,
179 FSIACK_MARK, FSIAILR_MARK, FSIAIBT_MARK, 179 FSIACK_MARK, FSIAILR_MARK, FSIAIBT_MARK,
180 180
181 /* FSI-B */
182 FSIBCK_MARK,
183
181 /* FMSI */ 184 /* FMSI */
182 FMSISLD_PORT1_MARK, /* FMSISLD Port 1/6 */ 185 FMSISLD_PORT1_MARK, /* FMSISLD Port 1/6 */
183 FMSISLD_PORT6_MARK, 186 FMSISLD_PORT6_MARK,
@@ -560,6 +563,9 @@ enum {
560 /* SDENC */ 563 /* SDENC */
561 SDENC_CPG_MARK, SDENC_DV_CLKI_MARK, 564 SDENC_CPG_MARK, SDENC_DV_CLKI_MARK,
562 565
566 /* HDMI */
567 HDMI_HPD_MARK, HDMI_CEC_MARK,
568
563 /* DEBUG */ 569 /* DEBUG */
564 EDEBGREQ_PULLUP_MARK, /* for JTAG */ 570 EDEBGREQ_PULLUP_MARK, /* for JTAG */
565 EDEBGREQ_PULLDOWN_MARK, 571 EDEBGREQ_PULLDOWN_MARK,
@@ -771,6 +777,7 @@ static pinmux_enum_t pinmux_data[] = {
771 777
772 /* Port11 */ 778 /* Port11 */
773 PINMUX_DATA(FSIACK_MARK, PORT11_FN1), 779 PINMUX_DATA(FSIACK_MARK, PORT11_FN1),
780 PINMUX_DATA(FSIBCK_MARK, PORT11_FN2),
774 PINMUX_DATA(IRQ2_PORT11_MARK, PORT11_FN0, MSEL1CR_2_0), 781 PINMUX_DATA(IRQ2_PORT11_MARK, PORT11_FN0, MSEL1CR_2_0),
775 782
776 /* Port12 */ 783 /* Port12 */
@@ -1254,7 +1261,7 @@ static pinmux_enum_t pinmux_data[] = {
1254 PINMUX_DATA(A21_MARK, PORT120_FN1), 1261 PINMUX_DATA(A21_MARK, PORT120_FN1),
1255 PINMUX_DATA(MSIOF0_RSYNC_MARK, PORT120_FN2), 1262 PINMUX_DATA(MSIOF0_RSYNC_MARK, PORT120_FN2),
1256 PINMUX_DATA(MSIOF1_TSYNC_PORT120_MARK, PORT120_FN3, MSEL4CR_10_0), 1263 PINMUX_DATA(MSIOF1_TSYNC_PORT120_MARK, PORT120_FN3, MSEL4CR_10_0),
1257 PINMUX_DATA(IRQ7_PORT120_MARK, PORT120_FN0, MSEL1CR_7_0), 1264 PINMUX_DATA(IRQ7_PORT120_MARK, PORT120_FN0, MSEL1CR_7_1),
1258 1265
1259 /* Port121 */ 1266 /* Port121 */
1260 PINMUX_DATA(A20_MARK, PORT121_FN1), 1267 PINMUX_DATA(A20_MARK, PORT121_FN1),
@@ -1616,13 +1623,15 @@ static pinmux_enum_t pinmux_data[] = {
1616 1623
1617 /* Port209 */ 1624 /* Port209 */
1618 PINMUX_DATA(VBUS_MARK, PORT209_FN1), 1625 PINMUX_DATA(VBUS_MARK, PORT209_FN1),
1619 PINMUX_DATA(IRQ7_PORT209_MARK, PORT209_FN0, MSEL1CR_7_1), 1626 PINMUX_DATA(IRQ7_PORT209_MARK, PORT209_FN0, MSEL1CR_7_0),
1620 1627
1621 /* Port210 */ 1628 /* Port210 */
1622 PINMUX_DATA(IRQ9_PORT210_MARK, PORT210_FN0, MSEL1CR_9_1), 1629 PINMUX_DATA(IRQ9_PORT210_MARK, PORT210_FN0, MSEL1CR_9_1),
1630 PINMUX_DATA(HDMI_HPD_MARK, PORT210_FN1),
1623 1631
1624 /* Port211 */ 1632 /* Port211 */
1625 PINMUX_DATA(IRQ16_PORT211_MARK, PORT211_FN0, MSEL1CR_16_1), 1633 PINMUX_DATA(IRQ16_PORT211_MARK, PORT211_FN0, MSEL1CR_16_1),
1634 PINMUX_DATA(HDMI_CEC_MARK, PORT211_FN1),
1626 1635
1627 /* LCDC select */ 1636 /* LCDC select */
1628 PINMUX_DATA(LCDC0_SELECT_MARK, MSEL3CR_6_0), 1637 PINMUX_DATA(LCDC0_SELECT_MARK, MSEL3CR_6_0),
@@ -1691,7 +1700,7 @@ static struct pinmux_gpio pinmux_gpios[] = {
1691 GPIO_FN(DBGMD10), GPIO_FN(DBGMD11), GPIO_FN(DBGMD20), 1700 GPIO_FN(DBGMD10), GPIO_FN(DBGMD11), GPIO_FN(DBGMD20),
1692 GPIO_FN(DBGMD21), 1701 GPIO_FN(DBGMD21),
1693 1702
1694 /* FSI */ 1703 /* FSI-A */
1695 GPIO_FN(FSIAISLD_PORT0), /* FSIAISLD Port 0/5 */ 1704 GPIO_FN(FSIAISLD_PORT0), /* FSIAISLD Port 0/5 */
1696 GPIO_FN(FSIAISLD_PORT5), 1705 GPIO_FN(FSIAISLD_PORT5),
1697 GPIO_FN(FSIASPDIF_PORT9), /* FSIASPDIF Port 9/18 */ 1706 GPIO_FN(FSIASPDIF_PORT9), /* FSIASPDIF Port 9/18 */
@@ -1700,6 +1709,9 @@ static struct pinmux_gpio pinmux_gpios[] = {
1700 GPIO_FN(FSIAOBT), GPIO_FN(FSIAOSLD), GPIO_FN(FSIAOMC), 1709 GPIO_FN(FSIAOBT), GPIO_FN(FSIAOSLD), GPIO_FN(FSIAOMC),
1701 GPIO_FN(FSIACK), GPIO_FN(FSIAILR), GPIO_FN(FSIAIBT), 1710 GPIO_FN(FSIACK), GPIO_FN(FSIAILR), GPIO_FN(FSIAIBT),
1702 1711
1712 /* FSI-B */
1713 GPIO_FN(FSIBCK),
1714
1703 /* FMSI */ 1715 /* FMSI */
1704 GPIO_FN(FMSISLD_PORT1), /* FMSISLD Port 1/6 */ 1716 GPIO_FN(FMSISLD_PORT1), /* FMSISLD Port 1/6 */
1705 GPIO_FN(FMSISLD_PORT6), 1717 GPIO_FN(FMSISLD_PORT6),
@@ -2097,6 +2109,10 @@ static struct pinmux_gpio pinmux_gpios[] = {
2097 GPIO_FN(SDENC_CPG), 2109 GPIO_FN(SDENC_CPG),
2098 GPIO_FN(SDENC_DV_CLKI), 2110 GPIO_FN(SDENC_DV_CLKI),
2099 2111
2112 /* HDMI */
2113 GPIO_FN(HDMI_HPD),
2114 GPIO_FN(HDMI_CEC),
2115
2100 /* SYSC */ 2116 /* SYSC */
2101 GPIO_FN(RESETP_PULLUP), 2117 GPIO_FN(RESETP_PULLUP),
2102 GPIO_FN(RESETP_PLAIN), 2118 GPIO_FN(RESETP_PLAIN),
diff --git a/arch/arm/mach-shmobile/pm-r8a7740.c b/arch/arm/mach-shmobile/pm-r8a7740.c
new file mode 100644
index 000000000000..893504d012a6
--- /dev/null
+++ b/arch/arm/mach-shmobile/pm-r8a7740.c
@@ -0,0 +1,54 @@
1/*
2 * r8a7740 power management support
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
11#include <linux/console.h>
12#include <mach/pm-rmobile.h>
13
14#ifdef CONFIG_PM
15static int r8a7740_pd_a4s_suspend(void)
16{
17 /*
18 * The A4S domain contains the CPU core and therefore it should
19 * only be turned off if the CPU is in use.
20 */
21 return -EBUSY;
22}
23
24struct rmobile_pm_domain r8a7740_pd_a4s = {
25 .genpd.name = "A4S",
26 .bit_shift = 10,
27 .gov = &pm_domain_always_on_gov,
28 .no_debug = true,
29 .suspend = r8a7740_pd_a4s_suspend,
30};
31
32static int r8a7740_pd_a3sp_suspend(void)
33{
34 /*
35 * Serial consoles make use of SCIF hardware located in A3SP,
36 * keep such power domain on if "no_console_suspend" is set.
37 */
38 return console_suspend_enabled ? 0 : -EBUSY;
39}
40
41struct rmobile_pm_domain r8a7740_pd_a3sp = {
42 .genpd.name = "A3SP",
43 .bit_shift = 11,
44 .gov = &pm_domain_always_on_gov,
45 .no_debug = true,
46 .suspend = r8a7740_pd_a3sp_suspend,
47};
48
49struct rmobile_pm_domain r8a7740_pd_a4lc = {
50 .genpd.name = "A4LC",
51 .bit_shift = 1,
52};
53
54#endif /* CONFIG_PM */
diff --git a/arch/arm/mach-shmobile/pm-rmobile.c b/arch/arm/mach-shmobile/pm-rmobile.c
new file mode 100644
index 000000000000..a8562540f1d6
--- /dev/null
+++ b/arch/arm/mach-shmobile/pm-rmobile.c
@@ -0,0 +1,167 @@
1/*
2 * rmobile power management support
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * based on pm-sh7372.c
8 * Copyright (C) 2011 Magnus Damm
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
13 */
14#include <linux/console.h>
15#include <linux/delay.h>
16#include <linux/platform_device.h>
17#include <linux/pm.h>
18#include <linux/pm_clock.h>
19#include <asm/io.h>
20#include <mach/pm-rmobile.h>
21
22/* SYSC */
23#define SPDCR 0xe6180008
24#define SWUCR 0xe6180014
25#define PSTR 0xe6180080
26
27#define PSTR_RETRIES 100
28#define PSTR_DELAY_US 10
29
30#ifdef CONFIG_PM
31static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
32{
33 struct rmobile_pm_domain *rmobile_pd = to_rmobile_pd(genpd);
34 unsigned int mask = 1 << rmobile_pd->bit_shift;
35
36 if (rmobile_pd->suspend) {
37 int ret = rmobile_pd->suspend();
38
39 if (ret)
40 return ret;
41 }
42
43 if (__raw_readl(PSTR) & mask) {
44 unsigned int retry_count;
45 __raw_writel(mask, SPDCR);
46
47 for (retry_count = PSTR_RETRIES; retry_count; retry_count--) {
48 if (!(__raw_readl(SPDCR) & mask))
49 break;
50 cpu_relax();
51 }
52 }
53
54 if (!rmobile_pd->no_debug)
55 pr_debug("%s: Power off, 0x%08x -> PSTR = 0x%08x\n",
56 genpd->name, mask, __raw_readl(PSTR));
57
58 return 0;
59}
60
61static int __rmobile_pd_power_up(struct rmobile_pm_domain *rmobile_pd,
62 bool do_resume)
63{
64 unsigned int mask = 1 << rmobile_pd->bit_shift;
65 unsigned int retry_count;
66 int ret = 0;
67
68 if (__raw_readl(PSTR) & mask)
69 goto out;
70
71 __raw_writel(mask, SWUCR);
72
73 for (retry_count = 2 * PSTR_RETRIES; retry_count; retry_count--) {
74 if (!(__raw_readl(SWUCR) & mask))
75 break;
76 if (retry_count > PSTR_RETRIES)
77 udelay(PSTR_DELAY_US);
78 else
79 cpu_relax();
80 }
81 if (!retry_count)
82 ret = -EIO;
83
84 if (!rmobile_pd->no_debug)
85 pr_debug("%s: Power on, 0x%08x -> PSTR = 0x%08x\n",
86 rmobile_pd->genpd.name, mask, __raw_readl(PSTR));
87
88out:
89 if (ret == 0 && rmobile_pd->resume && do_resume)
90 rmobile_pd->resume();
91
92 return ret;
93}
94
95static int rmobile_pd_power_up(struct generic_pm_domain *genpd)
96{
97 return __rmobile_pd_power_up(to_rmobile_pd(genpd), true);
98}
99
100static bool rmobile_pd_active_wakeup(struct device *dev)
101{
102 bool (*active_wakeup)(struct device *dev);
103
104 active_wakeup = dev_gpd_data(dev)->ops.active_wakeup;
105 return active_wakeup ? active_wakeup(dev) : true;
106}
107
108static int rmobile_pd_stop_dev(struct device *dev)
109{
110 int (*stop)(struct device *dev);
111
112 stop = dev_gpd_data(dev)->ops.stop;
113 if (stop) {
114 int ret = stop(dev);
115 if (ret)
116 return ret;
117 }
118 return pm_clk_suspend(dev);
119}
120
121static int rmobile_pd_start_dev(struct device *dev)
122{
123 int (*start)(struct device *dev);
124 int ret;
125
126 ret = pm_clk_resume(dev);
127 if (ret)
128 return ret;
129
130 start = dev_gpd_data(dev)->ops.start;
131 if (start)
132 ret = start(dev);
133
134 return ret;
135}
136
137void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd)
138{
139 struct generic_pm_domain *genpd = &rmobile_pd->genpd;
140 struct dev_power_governor *gov = rmobile_pd->gov;
141
142 pm_genpd_init(genpd, gov ? : &simple_qos_governor, false);
143 genpd->dev_ops.stop = rmobile_pd_stop_dev;
144 genpd->dev_ops.start = rmobile_pd_start_dev;
145 genpd->dev_ops.active_wakeup = rmobile_pd_active_wakeup;
146 genpd->dev_irq_safe = true;
147 genpd->power_off = rmobile_pd_power_down;
148 genpd->power_on = rmobile_pd_power_up;
149 __rmobile_pd_power_up(rmobile_pd, false);
150}
151
152void rmobile_add_device_to_domain(struct rmobile_pm_domain *rmobile_pd,
153 struct platform_device *pdev)
154{
155 struct device *dev = &pdev->dev;
156
157 pm_genpd_add_device(&rmobile_pd->genpd, dev);
158 if (pm_clk_no_clocks(dev))
159 pm_clk_add(dev, NULL);
160}
161
162void rmobile_pm_add_subdomain(struct rmobile_pm_domain *rmobile_pd,
163 struct rmobile_pm_domain *rmobile_sd)
164{
165 pm_genpd_add_subdomain(&rmobile_pd->genpd, &rmobile_sd->genpd);
166}
167#endif /* CONFIG_PM */
diff --git a/arch/arm/mach-shmobile/pm-sh7372.c b/arch/arm/mach-shmobile/pm-sh7372.c
index a3bdb12acde9..792037069226 100644
--- a/arch/arm/mach-shmobile/pm-sh7372.c
+++ b/arch/arm/mach-shmobile/pm-sh7372.c
@@ -26,6 +26,7 @@
26#include <asm/suspend.h> 26#include <asm/suspend.h>
27#include <mach/common.h> 27#include <mach/common.h>
28#include <mach/sh7372.h> 28#include <mach/sh7372.h>
29#include <mach/pm-rmobile.h>
29 30
30/* DBG */ 31/* DBG */
31#define DBGREG1 0xe6100020 32#define DBGREG1 0xe6100020
@@ -41,13 +42,10 @@
41#define PLLC01STPCR 0xe61500c8 42#define PLLC01STPCR 0xe61500c8
42 43
43/* SYSC */ 44/* SYSC */
44#define SPDCR 0xe6180008
45#define SWUCR 0xe6180014
46#define SBAR 0xe6180020 45#define SBAR 0xe6180020
47#define WUPRMSK 0xe6180028 46#define WUPRMSK 0xe6180028
48#define WUPSMSK 0xe618002c 47#define WUPSMSK 0xe618002c
49#define WUPSMSK2 0xe6180048 48#define WUPSMSK2 0xe6180048
50#define PSTR 0xe6180080
51#define WUPSFAC 0xe6180098 49#define WUPSFAC 0xe6180098
52#define IRQCR 0xe618022c 50#define IRQCR 0xe618022c
53#define IRQCR2 0xe6180238 51#define IRQCR2 0xe6180238
@@ -71,188 +69,48 @@
71/* AP-System Core */ 69/* AP-System Core */
72#define APARMBAREA 0xe6f10020 70#define APARMBAREA 0xe6f10020
73 71
74#define PSTR_RETRIES 100
75#define PSTR_DELAY_US 10
76
77#ifdef CONFIG_PM 72#ifdef CONFIG_PM
78 73
79static int pd_power_down(struct generic_pm_domain *genpd) 74struct rmobile_pm_domain sh7372_pd_a4lc = {
80{
81 struct sh7372_pm_domain *sh7372_pd = to_sh7372_pd(genpd);
82 unsigned int mask = 1 << sh7372_pd->bit_shift;
83
84 if (sh7372_pd->suspend) {
85 int ret = sh7372_pd->suspend();
86
87 if (ret)
88 return ret;
89 }
90
91 if (__raw_readl(PSTR) & mask) {
92 unsigned int retry_count;
93
94 __raw_writel(mask, SPDCR);
95
96 for (retry_count = PSTR_RETRIES; retry_count; retry_count--) {
97 if (!(__raw_readl(SPDCR) & mask))
98 break;
99 cpu_relax();
100 }
101 }
102
103 if (!sh7372_pd->no_debug)
104 pr_debug("%s: Power off, 0x%08x -> PSTR = 0x%08x\n",
105 genpd->name, mask, __raw_readl(PSTR));
106
107 return 0;
108}
109
110static int __pd_power_up(struct sh7372_pm_domain *sh7372_pd, bool do_resume)
111{
112 unsigned int mask = 1 << sh7372_pd->bit_shift;
113 unsigned int retry_count;
114 int ret = 0;
115
116 if (__raw_readl(PSTR) & mask)
117 goto out;
118
119 __raw_writel(mask, SWUCR);
120
121 for (retry_count = 2 * PSTR_RETRIES; retry_count; retry_count--) {
122 if (!(__raw_readl(SWUCR) & mask))
123 break;
124 if (retry_count > PSTR_RETRIES)
125 udelay(PSTR_DELAY_US);
126 else
127 cpu_relax();
128 }
129 if (!retry_count)
130 ret = -EIO;
131
132 if (!sh7372_pd->no_debug)
133 pr_debug("%s: Power on, 0x%08x -> PSTR = 0x%08x\n",
134 sh7372_pd->genpd.name, mask, __raw_readl(PSTR));
135
136 out:
137 if (ret == 0 && sh7372_pd->resume && do_resume)
138 sh7372_pd->resume();
139
140 return ret;
141}
142
143static int pd_power_up(struct generic_pm_domain *genpd)
144{
145 return __pd_power_up(to_sh7372_pd(genpd), true);
146}
147
148static int sh7372_a4r_suspend(void)
149{
150 sh7372_intcs_suspend();
151 __raw_writel(0x300fffff, WUPRMSK); /* avoid wakeup */
152 return 0;
153}
154
155static bool pd_active_wakeup(struct device *dev)
156{
157 bool (*active_wakeup)(struct device *dev);
158
159 active_wakeup = dev_gpd_data(dev)->ops.active_wakeup;
160 return active_wakeup ? active_wakeup(dev) : true;
161}
162
163static int sh7372_stop_dev(struct device *dev)
164{
165 int (*stop)(struct device *dev);
166
167 stop = dev_gpd_data(dev)->ops.stop;
168 if (stop) {
169 int ret = stop(dev);
170 if (ret)
171 return ret;
172 }
173 return pm_clk_suspend(dev);
174}
175
176static int sh7372_start_dev(struct device *dev)
177{
178 int (*start)(struct device *dev);
179 int ret;
180
181 ret = pm_clk_resume(dev);
182 if (ret)
183 return ret;
184
185 start = dev_gpd_data(dev)->ops.start;
186 if (start)
187 ret = start(dev);
188
189 return ret;
190}
191
192void sh7372_init_pm_domain(struct sh7372_pm_domain *sh7372_pd)
193{
194 struct generic_pm_domain *genpd = &sh7372_pd->genpd;
195 struct dev_power_governor *gov = sh7372_pd->gov;
196
197 pm_genpd_init(genpd, gov ? : &simple_qos_governor, false);
198 genpd->dev_ops.stop = sh7372_stop_dev;
199 genpd->dev_ops.start = sh7372_start_dev;
200 genpd->dev_ops.active_wakeup = pd_active_wakeup;
201 genpd->dev_irq_safe = true;
202 genpd->power_off = pd_power_down;
203 genpd->power_on = pd_power_up;
204 __pd_power_up(sh7372_pd, false);
205}
206
207void sh7372_add_device_to_domain(struct sh7372_pm_domain *sh7372_pd,
208 struct platform_device *pdev)
209{
210 struct device *dev = &pdev->dev;
211
212 pm_genpd_add_device(&sh7372_pd->genpd, dev);
213 if (pm_clk_no_clocks(dev))
214 pm_clk_add(dev, NULL);
215}
216
217void sh7372_pm_add_subdomain(struct sh7372_pm_domain *sh7372_pd,
218 struct sh7372_pm_domain *sh7372_sd)
219{
220 pm_genpd_add_subdomain(&sh7372_pd->genpd, &sh7372_sd->genpd);
221}
222
223struct sh7372_pm_domain sh7372_a4lc = {
224 .genpd.name = "A4LC", 75 .genpd.name = "A4LC",
225 .bit_shift = 1, 76 .bit_shift = 1,
226}; 77};
227 78
228struct sh7372_pm_domain sh7372_a4mp = { 79struct rmobile_pm_domain sh7372_pd_a4mp = {
229 .genpd.name = "A4MP", 80 .genpd.name = "A4MP",
230 .bit_shift = 2, 81 .bit_shift = 2,
231}; 82};
232 83
233struct sh7372_pm_domain sh7372_d4 = { 84struct rmobile_pm_domain sh7372_pd_d4 = {
234 .genpd.name = "D4", 85 .genpd.name = "D4",
235 .bit_shift = 3, 86 .bit_shift = 3,
236}; 87};
237 88
238struct sh7372_pm_domain sh7372_a4r = { 89static int sh7372_a4r_pd_suspend(void)
90{
91 sh7372_intcs_suspend();
92 __raw_writel(0x300fffff, WUPRMSK); /* avoid wakeup */
93 return 0;
94}
95
96struct rmobile_pm_domain sh7372_pd_a4r = {
239 .genpd.name = "A4R", 97 .genpd.name = "A4R",
240 .bit_shift = 5, 98 .bit_shift = 5,
241 .suspend = sh7372_a4r_suspend, 99 .suspend = sh7372_a4r_pd_suspend,
242 .resume = sh7372_intcs_resume, 100 .resume = sh7372_intcs_resume,
243}; 101};
244 102
245struct sh7372_pm_domain sh7372_a3rv = { 103struct rmobile_pm_domain sh7372_pd_a3rv = {
246 .genpd.name = "A3RV", 104 .genpd.name = "A3RV",
247 .bit_shift = 6, 105 .bit_shift = 6,
248}; 106};
249 107
250struct sh7372_pm_domain sh7372_a3ri = { 108struct rmobile_pm_domain sh7372_pd_a3ri = {
251 .genpd.name = "A3RI", 109 .genpd.name = "A3RI",
252 .bit_shift = 8, 110 .bit_shift = 8,
253}; 111};
254 112
255static int sh7372_a4s_suspend(void) 113static int sh7372_pd_a4s_suspend(void)
256{ 114{
257 /* 115 /*
258 * The A4S domain contains the CPU core and therefore it should 116 * The A4S domain contains the CPU core and therefore it should
@@ -261,15 +119,15 @@ static int sh7372_a4s_suspend(void)
261 return -EBUSY; 119 return -EBUSY;
262} 120}
263 121
264struct sh7372_pm_domain sh7372_a4s = { 122struct rmobile_pm_domain sh7372_pd_a4s = {
265 .genpd.name = "A4S", 123 .genpd.name = "A4S",
266 .bit_shift = 10, 124 .bit_shift = 10,
267 .gov = &pm_domain_always_on_gov, 125 .gov = &pm_domain_always_on_gov,
268 .no_debug = true, 126 .no_debug = true,
269 .suspend = sh7372_a4s_suspend, 127 .suspend = sh7372_pd_a4s_suspend,
270}; 128};
271 129
272static int sh7372_a3sp_suspend(void) 130static int sh7372_a3sp_pd_suspend(void)
273{ 131{
274 /* 132 /*
275 * Serial consoles make use of SCIF hardware located in A3SP, 133 * Serial consoles make use of SCIF hardware located in A3SP,
@@ -278,32 +136,22 @@ static int sh7372_a3sp_suspend(void)
278 return console_suspend_enabled ? 0 : -EBUSY; 136 return console_suspend_enabled ? 0 : -EBUSY;
279} 137}
280 138
281struct sh7372_pm_domain sh7372_a3sp = { 139struct rmobile_pm_domain sh7372_pd_a3sp = {
282 .genpd.name = "A3SP", 140 .genpd.name = "A3SP",
283 .bit_shift = 11, 141 .bit_shift = 11,
284 .gov = &pm_domain_always_on_gov, 142 .gov = &pm_domain_always_on_gov,
285 .no_debug = true, 143 .no_debug = true,
286 .suspend = sh7372_a3sp_suspend, 144 .suspend = sh7372_a3sp_pd_suspend,
287}; 145};
288 146
289struct sh7372_pm_domain sh7372_a3sg = { 147struct rmobile_pm_domain sh7372_pd_a3sg = {
290 .genpd.name = "A3SG", 148 .genpd.name = "A3SG",
291 .bit_shift = 13, 149 .bit_shift = 13,
292}; 150};
293 151
294#else /* !CONFIG_PM */ 152#endif /* CONFIG_PM */
295
296static inline void sh7372_a3sp_init(void) {}
297
298#endif /* !CONFIG_PM */
299 153
300#if defined(CONFIG_SUSPEND) || defined(CONFIG_CPU_IDLE) 154#if defined(CONFIG_SUSPEND) || defined(CONFIG_CPU_IDLE)
301static int sh7372_do_idle_core_standby(unsigned long unused)
302{
303 cpu_do_idle(); /* WFI when SYSTBCR == 0x10 -> Core Standby */
304 return 0;
305}
306
307static void sh7372_set_reset_vector(unsigned long address) 155static void sh7372_set_reset_vector(unsigned long address)
308{ 156{
309 /* set reset vector, translate 4k */ 157 /* set reset vector, translate 4k */
@@ -311,21 +159,6 @@ static void sh7372_set_reset_vector(unsigned long address)
311 __raw_writel(0, APARMBAREA); 159 __raw_writel(0, APARMBAREA);
312} 160}
313 161
314static void sh7372_enter_core_standby(void)
315{
316 sh7372_set_reset_vector(__pa(sh7372_resume_core_standby_sysc));
317
318 /* enter sleep mode with SYSTBCR to 0x10 */
319 __raw_writel(0x10, SYSTBCR);
320 cpu_suspend(0, sh7372_do_idle_core_standby);
321 __raw_writel(0, SYSTBCR);
322
323 /* disable reset vector translation */
324 __raw_writel(0, SBAR);
325}
326#endif
327
328#ifdef CONFIG_SUSPEND
329static void sh7372_enter_sysc(int pllc0_on, unsigned long sleep_mode) 162static void sh7372_enter_sysc(int pllc0_on, unsigned long sleep_mode)
330{ 163{
331 if (pllc0_on) 164 if (pllc0_on)
@@ -465,22 +298,42 @@ static void sh7372_setup_sysc(unsigned long msk, unsigned long msk2)
465 298
466static void sh7372_enter_a3sm_common(int pllc0_on) 299static void sh7372_enter_a3sm_common(int pllc0_on)
467{ 300{
301 /* use INTCA together with SYSC for wakeup */
302 sh7372_setup_sysc(1 << 0, 0);
468 sh7372_set_reset_vector(__pa(sh7372_resume_core_standby_sysc)); 303 sh7372_set_reset_vector(__pa(sh7372_resume_core_standby_sysc));
469 sh7372_enter_sysc(pllc0_on, 1 << 12); 304 sh7372_enter_sysc(pllc0_on, 1 << 12);
470} 305}
306#endif /* CONFIG_SUSPEND || CONFIG_CPU_IDLE */
471 307
472static void sh7372_enter_a4s_common(int pllc0_on) 308#ifdef CONFIG_CPU_IDLE
309static int sh7372_do_idle_core_standby(unsigned long unused)
473{ 310{
474 sh7372_intca_suspend(); 311 cpu_do_idle(); /* WFI when SYSTBCR == 0x10 -> Core Standby */
475 memcpy((void *)SMFRAM, sh7372_resume_core_standby_sysc, 0x100); 312 return 0;
476 sh7372_set_reset_vector(SMFRAM);
477 sh7372_enter_sysc(pllc0_on, 1 << 10);
478 sh7372_intca_resume();
479} 313}
480 314
481#endif 315static void sh7372_enter_core_standby(void)
316{
317 sh7372_set_reset_vector(__pa(sh7372_resume_core_standby_sysc));
482 318
483#ifdef CONFIG_CPU_IDLE 319 /* enter sleep mode with SYSTBCR to 0x10 */
320 __raw_writel(0x10, SYSTBCR);
321 cpu_suspend(0, sh7372_do_idle_core_standby);
322 __raw_writel(0, SYSTBCR);
323
324 /* disable reset vector translation */
325 __raw_writel(0, SBAR);
326}
327
328static void sh7372_enter_a3sm_pll_on(void)
329{
330 sh7372_enter_a3sm_common(1);
331}
332
333static void sh7372_enter_a3sm_pll_off(void)
334{
335 sh7372_enter_a3sm_common(0);
336}
484 337
485static void sh7372_cpuidle_setup(struct cpuidle_driver *drv) 338static void sh7372_cpuidle_setup(struct cpuidle_driver *drv)
486{ 339{
@@ -492,7 +345,24 @@ static void sh7372_cpuidle_setup(struct cpuidle_driver *drv)
492 state->target_residency = 20 + 10; 345 state->target_residency = 20 + 10;
493 state->flags = CPUIDLE_FLAG_TIME_VALID; 346 state->flags = CPUIDLE_FLAG_TIME_VALID;
494 shmobile_cpuidle_modes[drv->state_count] = sh7372_enter_core_standby; 347 shmobile_cpuidle_modes[drv->state_count] = sh7372_enter_core_standby;
348 drv->state_count++;
349
350 state = &drv->states[drv->state_count];
351 snprintf(state->name, CPUIDLE_NAME_LEN, "C3");
352 strncpy(state->desc, "A3SM PLL ON", CPUIDLE_DESC_LEN);
353 state->exit_latency = 20;
354 state->target_residency = 30 + 20;
355 state->flags = CPUIDLE_FLAG_TIME_VALID;
356 shmobile_cpuidle_modes[drv->state_count] = sh7372_enter_a3sm_pll_on;
357 drv->state_count++;
495 358
359 state = &drv->states[drv->state_count];
360 snprintf(state->name, CPUIDLE_NAME_LEN, "C4");
361 strncpy(state->desc, "A3SM PLL OFF", CPUIDLE_DESC_LEN);
362 state->exit_latency = 120;
363 state->target_residency = 30 + 120;
364 state->flags = CPUIDLE_FLAG_TIME_VALID;
365 shmobile_cpuidle_modes[drv->state_count] = sh7372_enter_a3sm_pll_off;
496 drv->state_count++; 366 drv->state_count++;
497} 367}
498 368
@@ -505,6 +375,14 @@ static void sh7372_cpuidle_init(void) {}
505#endif 375#endif
506 376
507#ifdef CONFIG_SUSPEND 377#ifdef CONFIG_SUSPEND
378static void sh7372_enter_a4s_common(int pllc0_on)
379{
380 sh7372_intca_suspend();
381 memcpy((void *)SMFRAM, sh7372_resume_core_standby_sysc, 0x100);
382 sh7372_set_reset_vector(SMFRAM);
383 sh7372_enter_sysc(pllc0_on, 1 << 10);
384 sh7372_intca_resume();
385}
508 386
509static int sh7372_enter_suspend(suspend_state_t suspend_state) 387static int sh7372_enter_suspend(suspend_state_t suspend_state)
510{ 388{
@@ -512,24 +390,21 @@ static int sh7372_enter_suspend(suspend_state_t suspend_state)
512 390
513 /* check active clocks to determine potential wakeup sources */ 391 /* check active clocks to determine potential wakeup sources */
514 if (sh7372_sysc_valid(&msk, &msk2)) { 392 if (sh7372_sysc_valid(&msk, &msk2)) {
515 /* convert INTC mask and sense to SYSC mask and sense */
516 sh7372_setup_sysc(msk, msk2);
517
518 if (!console_suspend_enabled && 393 if (!console_suspend_enabled &&
519 sh7372_a4s.genpd.status == GPD_STATE_POWER_OFF) { 394 sh7372_pd_a4s.genpd.status == GPD_STATE_POWER_OFF) {
395 /* convert INTC mask/sense to SYSC mask/sense */
396 sh7372_setup_sysc(msk, msk2);
397
520 /* enter A4S sleep with PLLC0 off */ 398 /* enter A4S sleep with PLLC0 off */
521 pr_debug("entering A4S\n"); 399 pr_debug("entering A4S\n");
522 sh7372_enter_a4s_common(0); 400 sh7372_enter_a4s_common(0);
523 } else { 401 return 0;
524 /* enter A3SM sleep with PLLC0 off */
525 pr_debug("entering A3SM\n");
526 sh7372_enter_a3sm_common(0);
527 } 402 }
528 } else {
529 /* default to Core Standby that supports all wakeup sources */
530 pr_debug("entering Core Standby\n");
531 sh7372_enter_core_standby();
532 } 403 }
404
405 /* default to enter A3SM sleep with PLLC0 off */
406 pr_debug("entering A3SM\n");
407 sh7372_enter_a3sm_common(0);
533 return 0; 408 return 0;
534} 409}
535 410
@@ -550,7 +425,7 @@ static int sh7372_pm_notifier_fn(struct notifier_block *notifier,
550 * executed during system suspend and resume, respectively, so 425 * executed during system suspend and resume, respectively, so
551 * that those functions don't crash while accessing the INTCS. 426 * that those functions don't crash while accessing the INTCS.
552 */ 427 */
553 pm_genpd_poweron(&sh7372_a4r.genpd); 428 pm_genpd_poweron(&sh7372_pd_a4r.genpd);
554 break; 429 break;
555 case PM_POST_SUSPEND: 430 case PM_POST_SUSPEND:
556 pm_genpd_poweroff_unused(); 431 pm_genpd_poweroff_unused();
diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
index ec4eb49c1693..78948a9dba0e 100644
--- a/arch/arm/mach-shmobile/setup-r8a7740.c
+++ b/arch/arm/mach-shmobile/setup-r8a7740.c
@@ -23,9 +23,14 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/of_platform.h>
26#include <linux/serial_sci.h> 27#include <linux/serial_sci.h>
28#include <linux/sh_dma.h>
27#include <linux/sh_timer.h> 29#include <linux/sh_timer.h>
30#include <linux/dma-mapping.h>
31#include <mach/dma-register.h>
28#include <mach/r8a7740.h> 32#include <mach/r8a7740.h>
33#include <mach/pm-rmobile.h>
29#include <mach/common.h> 34#include <mach/common.h>
30#include <mach/irqs.h> 35#include <mach/irqs.h>
31#include <asm/mach-types.h> 36#include <asm/mach-types.h>
@@ -276,6 +281,272 @@ static struct platform_device *r8a7740_early_devices[] __initdata = {
276 &cmt10_device, 281 &cmt10_device,
277}; 282};
278 283
284/* DMA */
285static const struct sh_dmae_slave_config r8a7740_dmae_slaves[] = {
286 {
287 .slave_id = SHDMA_SLAVE_SDHI0_TX,
288 .addr = 0xe6850030,
289 .chcr = CHCR_TX(XMIT_SZ_16BIT),
290 .mid_rid = 0xc1,
291 }, {
292 .slave_id = SHDMA_SLAVE_SDHI0_RX,
293 .addr = 0xe6850030,
294 .chcr = CHCR_RX(XMIT_SZ_16BIT),
295 .mid_rid = 0xc2,
296 }, {
297 .slave_id = SHDMA_SLAVE_SDHI1_TX,
298 .addr = 0xe6860030,
299 .chcr = CHCR_TX(XMIT_SZ_16BIT),
300 .mid_rid = 0xc9,
301 }, {
302 .slave_id = SHDMA_SLAVE_SDHI1_RX,
303 .addr = 0xe6860030,
304 .chcr = CHCR_RX(XMIT_SZ_16BIT),
305 .mid_rid = 0xca,
306 }, {
307 .slave_id = SHDMA_SLAVE_SDHI2_TX,
308 .addr = 0xe6870030,
309 .chcr = CHCR_TX(XMIT_SZ_16BIT),
310 .mid_rid = 0xcd,
311 }, {
312 .slave_id = SHDMA_SLAVE_SDHI2_RX,
313 .addr = 0xe6870030,
314 .chcr = CHCR_RX(XMIT_SZ_16BIT),
315 .mid_rid = 0xce,
316 }, {
317 .slave_id = SHDMA_SLAVE_FSIA_TX,
318 .addr = 0xfe1f0024,
319 .chcr = CHCR_TX(XMIT_SZ_32BIT),
320 .mid_rid = 0xb1,
321 }, {
322 .slave_id = SHDMA_SLAVE_FSIA_RX,
323 .addr = 0xfe1f0020,
324 .chcr = CHCR_RX(XMIT_SZ_32BIT),
325 .mid_rid = 0xb2,
326 }, {
327 .slave_id = SHDMA_SLAVE_FSIB_TX,
328 .addr = 0xfe1f0064,
329 .chcr = CHCR_TX(XMIT_SZ_32BIT),
330 .mid_rid = 0xb5,
331 },
332};
333
334#define DMA_CHANNEL(a, b, c) \
335{ \
336 .offset = a, \
337 .dmars = b, \
338 .dmars_bit = c, \
339 .chclr_offset = (0x220 - 0x20) + a \
340}
341
342static const struct sh_dmae_channel r8a7740_dmae_channels[] = {
343 DMA_CHANNEL(0x00, 0, 0),
344 DMA_CHANNEL(0x10, 0, 8),
345 DMA_CHANNEL(0x20, 4, 0),
346 DMA_CHANNEL(0x30, 4, 8),
347 DMA_CHANNEL(0x50, 8, 0),
348 DMA_CHANNEL(0x60, 8, 8),
349};
350
351static struct sh_dmae_pdata dma_platform_data = {
352 .slave = r8a7740_dmae_slaves,
353 .slave_num = ARRAY_SIZE(r8a7740_dmae_slaves),
354 .channel = r8a7740_dmae_channels,
355 .channel_num = ARRAY_SIZE(r8a7740_dmae_channels),
356 .ts_low_shift = TS_LOW_SHIFT,
357 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
358 .ts_high_shift = TS_HI_SHIFT,
359 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
360 .ts_shift = dma_ts_shift,
361 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
362 .dmaor_init = DMAOR_DME,
363 .chclr_present = 1,
364};
365
366/* Resource order important! */
367static struct resource r8a7740_dmae0_resources[] = {
368 {
369 /* Channel registers and DMAOR */
370 .start = 0xfe008020,
371 .end = 0xfe00828f,
372 .flags = IORESOURCE_MEM,
373 },
374 {
375 /* DMARSx */
376 .start = 0xfe009000,
377 .end = 0xfe00900b,
378 .flags = IORESOURCE_MEM,
379 },
380 {
381 .name = "error_irq",
382 .start = evt2irq(0x20c0),
383 .end = evt2irq(0x20c0),
384 .flags = IORESOURCE_IRQ,
385 },
386 {
387 /* IRQ for channels 0-5 */
388 .start = evt2irq(0x2000),
389 .end = evt2irq(0x20a0),
390 .flags = IORESOURCE_IRQ,
391 },
392};
393
394/* Resource order important! */
395static struct resource r8a7740_dmae1_resources[] = {
396 {
397 /* Channel registers and DMAOR */
398 .start = 0xfe018020,
399 .end = 0xfe01828f,
400 .flags = IORESOURCE_MEM,
401 },
402 {
403 /* DMARSx */
404 .start = 0xfe019000,
405 .end = 0xfe01900b,
406 .flags = IORESOURCE_MEM,
407 },
408 {
409 .name = "error_irq",
410 .start = evt2irq(0x21c0),
411 .end = evt2irq(0x21c0),
412 .flags = IORESOURCE_IRQ,
413 },
414 {
415 /* IRQ for channels 0-5 */
416 .start = evt2irq(0x2100),
417 .end = evt2irq(0x21a0),
418 .flags = IORESOURCE_IRQ,
419 },
420};
421
422/* Resource order important! */
423static struct resource r8a7740_dmae2_resources[] = {
424 {
425 /* Channel registers and DMAOR */
426 .start = 0xfe028020,
427 .end = 0xfe02828f,
428 .flags = IORESOURCE_MEM,
429 },
430 {
431 /* DMARSx */
432 .start = 0xfe029000,
433 .end = 0xfe02900b,
434 .flags = IORESOURCE_MEM,
435 },
436 {
437 .name = "error_irq",
438 .start = evt2irq(0x22c0),
439 .end = evt2irq(0x22c0),
440 .flags = IORESOURCE_IRQ,
441 },
442 {
443 /* IRQ for channels 0-5 */
444 .start = evt2irq(0x2200),
445 .end = evt2irq(0x22a0),
446 .flags = IORESOURCE_IRQ,
447 },
448};
449
450static struct platform_device dma0_device = {
451 .name = "sh-dma-engine",
452 .id = 0,
453 .resource = r8a7740_dmae0_resources,
454 .num_resources = ARRAY_SIZE(r8a7740_dmae0_resources),
455 .dev = {
456 .platform_data = &dma_platform_data,
457 },
458};
459
460static struct platform_device dma1_device = {
461 .name = "sh-dma-engine",
462 .id = 1,
463 .resource = r8a7740_dmae1_resources,
464 .num_resources = ARRAY_SIZE(r8a7740_dmae1_resources),
465 .dev = {
466 .platform_data = &dma_platform_data,
467 },
468};
469
470static struct platform_device dma2_device = {
471 .name = "sh-dma-engine",
472 .id = 2,
473 .resource = r8a7740_dmae2_resources,
474 .num_resources = ARRAY_SIZE(r8a7740_dmae2_resources),
475 .dev = {
476 .platform_data = &dma_platform_data,
477 },
478};
479
480/* USB-DMAC */
481static const struct sh_dmae_channel r8a7740_usb_dma_channels[] = {
482 {
483 .offset = 0,
484 }, {
485 .offset = 0x20,
486 },
487};
488
489static const struct sh_dmae_slave_config r8a7740_usb_dma_slaves[] = {
490 {
491 .slave_id = SHDMA_SLAVE_USBHS_TX,
492 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
493 }, {
494 .slave_id = SHDMA_SLAVE_USBHS_RX,
495 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
496 },
497};
498
499static struct sh_dmae_pdata usb_dma_platform_data = {
500 .slave = r8a7740_usb_dma_slaves,
501 .slave_num = ARRAY_SIZE(r8a7740_usb_dma_slaves),
502 .channel = r8a7740_usb_dma_channels,
503 .channel_num = ARRAY_SIZE(r8a7740_usb_dma_channels),
504 .ts_low_shift = USBTS_LOW_SHIFT,
505 .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
506 .ts_high_shift = USBTS_HI_SHIFT,
507 .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
508 .ts_shift = dma_usbts_shift,
509 .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
510 .dmaor_init = DMAOR_DME,
511 .chcr_offset = 0x14,
512 .chcr_ie_bit = 1 << 5,
513 .dmaor_is_32bit = 1,
514 .needs_tend_set = 1,
515 .no_dmars = 1,
516 .slave_only = 1,
517};
518
519static struct resource r8a7740_usb_dma_resources[] = {
520 {
521 /* Channel registers and DMAOR */
522 .start = 0xe68a0020,
523 .end = 0xe68a0064 - 1,
524 .flags = IORESOURCE_MEM,
525 },
526 {
527 /* VCR/SWR/DMICR */
528 .start = 0xe68a0000,
529 .end = 0xe68a0014 - 1,
530 .flags = IORESOURCE_MEM,
531 },
532 {
533 /* IRQ for channels */
534 .start = evt2irq(0x0a00),
535 .end = evt2irq(0x0a00),
536 .flags = IORESOURCE_IRQ,
537 },
538};
539
540static struct platform_device usb_dma_device = {
541 .name = "sh-dma-engine",
542 .id = 3,
543 .resource = r8a7740_usb_dma_resources,
544 .num_resources = ARRAY_SIZE(r8a7740_usb_dma_resources),
545 .dev = {
546 .platform_data = &usb_dma_platform_data,
547 },
548};
549
279/* I2C */ 550/* I2C */
280static struct resource i2c0_resources[] = { 551static struct resource i2c0_resources[] = {
281 [0] = { 552 [0] = {
@@ -322,8 +593,30 @@ static struct platform_device i2c1_device = {
322static struct platform_device *r8a7740_late_devices[] __initdata = { 593static struct platform_device *r8a7740_late_devices[] __initdata = {
323 &i2c0_device, 594 &i2c0_device,
324 &i2c1_device, 595 &i2c1_device,
596 &dma0_device,
597 &dma1_device,
598 &dma2_device,
599 &usb_dma_device,
325}; 600};
326 601
602/*
603 * r8a7740 chip has lasting errata on MERAM buffer.
604 * this is work-around for it.
605 * see
606 * "Media RAM (MERAM)" on r8a7740 documentation
607 */
608#define MEBUFCNTR 0xFE950098
609void r8a7740_meram_workaround(void)
610{
611 void __iomem *reg;
612
613 reg = ioremap_nocache(MEBUFCNTR, 4);
614 if (reg) {
615 iowrite32(0x01600164, reg);
616 iounmap(reg);
617 }
618}
619
327#define ICCR 0x0004 620#define ICCR 0x0004
328#define ICSTART 0x0070 621#define ICSTART 0x0070
329 622
@@ -380,10 +673,31 @@ void __init r8a7740_add_standard_devices(void)
380 r8a7740_i2c_workaround(&i2c0_device); 673 r8a7740_i2c_workaround(&i2c0_device);
381 r8a7740_i2c_workaround(&i2c1_device); 674 r8a7740_i2c_workaround(&i2c1_device);
382 675
676 /* PM domain */
677 rmobile_init_pm_domain(&r8a7740_pd_a4s);
678 rmobile_init_pm_domain(&r8a7740_pd_a3sp);
679 rmobile_init_pm_domain(&r8a7740_pd_a4lc);
680
681 rmobile_pm_add_subdomain(&r8a7740_pd_a4s, &r8a7740_pd_a3sp);
682
683 /* add devices */
383 platform_add_devices(r8a7740_early_devices, 684 platform_add_devices(r8a7740_early_devices,
384 ARRAY_SIZE(r8a7740_early_devices)); 685 ARRAY_SIZE(r8a7740_early_devices));
385 platform_add_devices(r8a7740_late_devices, 686 platform_add_devices(r8a7740_late_devices,
386 ARRAY_SIZE(r8a7740_late_devices)); 687 ARRAY_SIZE(r8a7740_late_devices));
688
689 /* add devices to PM domain */
690
691 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif0_device);
692 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif1_device);
693 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif2_device);
694 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif3_device);
695 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif4_device);
696 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif5_device);
697 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif6_device);
698 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scif7_device);
699 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &scifb_device);
700 rmobile_add_device_to_domain(&r8a7740_pd_a3sp, &i2c1_device);
387} 701}
388 702
389static void __init r8a7740_earlytimer_init(void) 703static void __init r8a7740_earlytimer_init(void)
@@ -403,3 +717,49 @@ void __init r8a7740_add_early_devices(void)
403 /* override timer setup with soc-specific code */ 717 /* override timer setup with soc-specific code */
404 shmobile_timer.init = r8a7740_earlytimer_init; 718 shmobile_timer.init = r8a7740_earlytimer_init;
405} 719}
720
721#ifdef CONFIG_USE_OF
722
723void __init r8a7740_add_early_devices_dt(void)
724{
725 shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
726
727 early_platform_add_devices(r8a7740_early_devices,
728 ARRAY_SIZE(r8a7740_early_devices));
729
730 /* setup early console here as well */
731 shmobile_setup_console();
732}
733
734static const struct of_dev_auxdata r8a7740_auxdata_lookup[] __initconst = {
735 { }
736};
737
738void __init r8a7740_add_standard_devices_dt(void)
739{
740 /* clocks are setup late during boot in the case of DT */
741 r8a7740_clock_init(0);
742
743 platform_add_devices(r8a7740_early_devices,
744 ARRAY_SIZE(r8a7740_early_devices));
745
746 of_platform_populate(NULL, of_default_bus_match_table,
747 r8a7740_auxdata_lookup, NULL);
748}
749
750static const char *r8a7740_boards_compat_dt[] __initdata = {
751 "renesas,r8a7740",
752 NULL,
753};
754
755DT_MACHINE_START(SH7372_DT, "Generic R8A7740 (Flattened Device Tree)")
756 .map_io = r8a7740_map_io,
757 .init_early = r8a7740_add_early_devices_dt,
758 .init_irq = r8a7740_init_irq,
759 .handle_irq = shmobile_handle_irq_intc,
760 .init_machine = r8a7740_add_standard_devices_dt,
761 .timer = &shmobile_timer,
762 .dt_compat = r8a7740_boards_compat_dt,
763MACHINE_END
764
765#endif /* CONFIG_USE_OF */
diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
index fafce9ce8218..838a87be1d5c 100644
--- a/arch/arm/mach-shmobile/setup-sh7372.c
+++ b/arch/arm/mach-shmobile/setup-sh7372.c
@@ -33,6 +33,7 @@
33#include <linux/sh_timer.h> 33#include <linux/sh_timer.h>
34#include <linux/pm_domain.h> 34#include <linux/pm_domain.h>
35#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
36#include <mach/dma-register.h>
36#include <mach/hardware.h> 37#include <mach/hardware.h>
37#include <mach/irqs.h> 38#include <mach/irqs.h>
38#include <mach/sh7372.h> 39#include <mach/sh7372.h>
@@ -335,151 +336,126 @@ static struct platform_device iic1_device = {
335}; 336};
336 337
337/* DMA */ 338/* DMA */
338/* Transmit sizes and respective CHCR register values */
339enum {
340 XMIT_SZ_8BIT = 0,
341 XMIT_SZ_16BIT = 1,
342 XMIT_SZ_32BIT = 2,
343 XMIT_SZ_64BIT = 7,
344 XMIT_SZ_128BIT = 3,
345 XMIT_SZ_256BIT = 4,
346 XMIT_SZ_512BIT = 5,
347};
348
349/* log2(size / 8) - used to calculate number of transfers */
350#define TS_SHIFT { \
351 [XMIT_SZ_8BIT] = 0, \
352 [XMIT_SZ_16BIT] = 1, \
353 [XMIT_SZ_32BIT] = 2, \
354 [XMIT_SZ_64BIT] = 3, \
355 [XMIT_SZ_128BIT] = 4, \
356 [XMIT_SZ_256BIT] = 5, \
357 [XMIT_SZ_512BIT] = 6, \
358}
359
360#define TS_INDEX2VAL(i) ((((i) & 3) << 3) | \
361 (((i) & 0xc) << (20 - 2)))
362
363static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = { 339static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = {
364 { 340 {
365 .slave_id = SHDMA_SLAVE_SCIF0_TX, 341 .slave_id = SHDMA_SLAVE_SCIF0_TX,
366 .addr = 0xe6c40020, 342 .addr = 0xe6c40020,
367 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 343 .chcr = CHCR_TX(XMIT_SZ_8BIT),
368 .mid_rid = 0x21, 344 .mid_rid = 0x21,
369 }, { 345 }, {
370 .slave_id = SHDMA_SLAVE_SCIF0_RX, 346 .slave_id = SHDMA_SLAVE_SCIF0_RX,
371 .addr = 0xe6c40024, 347 .addr = 0xe6c40024,
372 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 348 .chcr = CHCR_RX(XMIT_SZ_8BIT),
373 .mid_rid = 0x22, 349 .mid_rid = 0x22,
374 }, { 350 }, {
375 .slave_id = SHDMA_SLAVE_SCIF1_TX, 351 .slave_id = SHDMA_SLAVE_SCIF1_TX,
376 .addr = 0xe6c50020, 352 .addr = 0xe6c50020,
377 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 353 .chcr = CHCR_TX(XMIT_SZ_8BIT),
378 .mid_rid = 0x25, 354 .mid_rid = 0x25,
379 }, { 355 }, {
380 .slave_id = SHDMA_SLAVE_SCIF1_RX, 356 .slave_id = SHDMA_SLAVE_SCIF1_RX,
381 .addr = 0xe6c50024, 357 .addr = 0xe6c50024,
382 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 358 .chcr = CHCR_RX(XMIT_SZ_8BIT),
383 .mid_rid = 0x26, 359 .mid_rid = 0x26,
384 }, { 360 }, {
385 .slave_id = SHDMA_SLAVE_SCIF2_TX, 361 .slave_id = SHDMA_SLAVE_SCIF2_TX,
386 .addr = 0xe6c60020, 362 .addr = 0xe6c60020,
387 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 363 .chcr = CHCR_TX(XMIT_SZ_8BIT),
388 .mid_rid = 0x29, 364 .mid_rid = 0x29,
389 }, { 365 }, {
390 .slave_id = SHDMA_SLAVE_SCIF2_RX, 366 .slave_id = SHDMA_SLAVE_SCIF2_RX,
391 .addr = 0xe6c60024, 367 .addr = 0xe6c60024,
392 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 368 .chcr = CHCR_RX(XMIT_SZ_8BIT),
393 .mid_rid = 0x2a, 369 .mid_rid = 0x2a,
394 }, { 370 }, {
395 .slave_id = SHDMA_SLAVE_SCIF3_TX, 371 .slave_id = SHDMA_SLAVE_SCIF3_TX,
396 .addr = 0xe6c70020, 372 .addr = 0xe6c70020,
397 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 373 .chcr = CHCR_TX(XMIT_SZ_8BIT),
398 .mid_rid = 0x2d, 374 .mid_rid = 0x2d,
399 }, { 375 }, {
400 .slave_id = SHDMA_SLAVE_SCIF3_RX, 376 .slave_id = SHDMA_SLAVE_SCIF3_RX,
401 .addr = 0xe6c70024, 377 .addr = 0xe6c70024,
402 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 378 .chcr = CHCR_RX(XMIT_SZ_8BIT),
403 .mid_rid = 0x2e, 379 .mid_rid = 0x2e,
404 }, { 380 }, {
405 .slave_id = SHDMA_SLAVE_SCIF4_TX, 381 .slave_id = SHDMA_SLAVE_SCIF4_TX,
406 .addr = 0xe6c80020, 382 .addr = 0xe6c80020,
407 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 383 .chcr = CHCR_TX(XMIT_SZ_8BIT),
408 .mid_rid = 0x39, 384 .mid_rid = 0x39,
409 }, { 385 }, {
410 .slave_id = SHDMA_SLAVE_SCIF4_RX, 386 .slave_id = SHDMA_SLAVE_SCIF4_RX,
411 .addr = 0xe6c80024, 387 .addr = 0xe6c80024,
412 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 388 .chcr = CHCR_RX(XMIT_SZ_8BIT),
413 .mid_rid = 0x3a, 389 .mid_rid = 0x3a,
414 }, { 390 }, {
415 .slave_id = SHDMA_SLAVE_SCIF5_TX, 391 .slave_id = SHDMA_SLAVE_SCIF5_TX,
416 .addr = 0xe6cb0020, 392 .addr = 0xe6cb0020,
417 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 393 .chcr = CHCR_TX(XMIT_SZ_8BIT),
418 .mid_rid = 0x35, 394 .mid_rid = 0x35,
419 }, { 395 }, {
420 .slave_id = SHDMA_SLAVE_SCIF5_RX, 396 .slave_id = SHDMA_SLAVE_SCIF5_RX,
421 .addr = 0xe6cb0024, 397 .addr = 0xe6cb0024,
422 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 398 .chcr = CHCR_RX(XMIT_SZ_8BIT),
423 .mid_rid = 0x36, 399 .mid_rid = 0x36,
424 }, { 400 }, {
425 .slave_id = SHDMA_SLAVE_SCIF6_TX, 401 .slave_id = SHDMA_SLAVE_SCIF6_TX,
426 .addr = 0xe6c30040, 402 .addr = 0xe6c30040,
427 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 403 .chcr = CHCR_TX(XMIT_SZ_8BIT),
428 .mid_rid = 0x3d, 404 .mid_rid = 0x3d,
429 }, { 405 }, {
430 .slave_id = SHDMA_SLAVE_SCIF6_RX, 406 .slave_id = SHDMA_SLAVE_SCIF6_RX,
431 .addr = 0xe6c30060, 407 .addr = 0xe6c30060,
432 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_8BIT), 408 .chcr = CHCR_RX(XMIT_SZ_8BIT),
433 .mid_rid = 0x3e, 409 .mid_rid = 0x3e,
434 }, { 410 }, {
435 .slave_id = SHDMA_SLAVE_SDHI0_TX, 411 .slave_id = SHDMA_SLAVE_SDHI0_TX,
436 .addr = 0xe6850030, 412 .addr = 0xe6850030,
437 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 413 .chcr = CHCR_TX(XMIT_SZ_16BIT),
438 .mid_rid = 0xc1, 414 .mid_rid = 0xc1,
439 }, { 415 }, {
440 .slave_id = SHDMA_SLAVE_SDHI0_RX, 416 .slave_id = SHDMA_SLAVE_SDHI0_RX,
441 .addr = 0xe6850030, 417 .addr = 0xe6850030,
442 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 418 .chcr = CHCR_RX(XMIT_SZ_16BIT),
443 .mid_rid = 0xc2, 419 .mid_rid = 0xc2,
444 }, { 420 }, {
445 .slave_id = SHDMA_SLAVE_SDHI1_TX, 421 .slave_id = SHDMA_SLAVE_SDHI1_TX,
446 .addr = 0xe6860030, 422 .addr = 0xe6860030,
447 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 423 .chcr = CHCR_TX(XMIT_SZ_16BIT),
448 .mid_rid = 0xc9, 424 .mid_rid = 0xc9,
449 }, { 425 }, {
450 .slave_id = SHDMA_SLAVE_SDHI1_RX, 426 .slave_id = SHDMA_SLAVE_SDHI1_RX,
451 .addr = 0xe6860030, 427 .addr = 0xe6860030,
452 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 428 .chcr = CHCR_RX(XMIT_SZ_16BIT),
453 .mid_rid = 0xca, 429 .mid_rid = 0xca,
454 }, { 430 }, {
455 .slave_id = SHDMA_SLAVE_SDHI2_TX, 431 .slave_id = SHDMA_SLAVE_SDHI2_TX,
456 .addr = 0xe6870030, 432 .addr = 0xe6870030,
457 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 433 .chcr = CHCR_TX(XMIT_SZ_16BIT),
458 .mid_rid = 0xcd, 434 .mid_rid = 0xcd,
459 }, { 435 }, {
460 .slave_id = SHDMA_SLAVE_SDHI2_RX, 436 .slave_id = SHDMA_SLAVE_SDHI2_RX,
461 .addr = 0xe6870030, 437 .addr = 0xe6870030,
462 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_16BIT), 438 .chcr = CHCR_RX(XMIT_SZ_16BIT),
463 .mid_rid = 0xce, 439 .mid_rid = 0xce,
464 }, { 440 }, {
465 .slave_id = SHDMA_SLAVE_FSIA_TX, 441 .slave_id = SHDMA_SLAVE_FSIA_TX,
466 .addr = 0xfe1f0024, 442 .addr = 0xfe1f0024,
467 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT), 443 .chcr = CHCR_TX(XMIT_SZ_32BIT),
468 .mid_rid = 0xb1, 444 .mid_rid = 0xb1,
469 }, { 445 }, {
470 .slave_id = SHDMA_SLAVE_FSIA_RX, 446 .slave_id = SHDMA_SLAVE_FSIA_RX,
471 .addr = 0xfe1f0020, 447 .addr = 0xfe1f0020,
472 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT), 448 .chcr = CHCR_RX(XMIT_SZ_32BIT),
473 .mid_rid = 0xb2, 449 .mid_rid = 0xb2,
474 }, { 450 }, {
475 .slave_id = SHDMA_SLAVE_MMCIF_TX, 451 .slave_id = SHDMA_SLAVE_MMCIF_TX,
476 .addr = 0xe6bd0034, 452 .addr = 0xe6bd0034,
477 .chcr = DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT), 453 .chcr = CHCR_TX(XMIT_SZ_32BIT),
478 .mid_rid = 0xd1, 454 .mid_rid = 0xd1,
479 }, { 455 }, {
480 .slave_id = SHDMA_SLAVE_MMCIF_RX, 456 .slave_id = SHDMA_SLAVE_MMCIF_RX,
481 .addr = 0xe6bd0034, 457 .addr = 0xe6bd0034,
482 .chcr = DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL(XMIT_SZ_32BIT), 458 .chcr = CHCR_RX(XMIT_SZ_32BIT),
483 .mid_rid = 0xd2, 459 .mid_rid = 0xd2,
484 }, 460 },
485}; 461};
@@ -520,19 +496,17 @@ static const struct sh_dmae_channel sh7372_dmae_channels[] = {
520 } 496 }
521}; 497};
522 498
523static const unsigned int ts_shift[] = TS_SHIFT;
524
525static struct sh_dmae_pdata dma_platform_data = { 499static struct sh_dmae_pdata dma_platform_data = {
526 .slave = sh7372_dmae_slaves, 500 .slave = sh7372_dmae_slaves,
527 .slave_num = ARRAY_SIZE(sh7372_dmae_slaves), 501 .slave_num = ARRAY_SIZE(sh7372_dmae_slaves),
528 .channel = sh7372_dmae_channels, 502 .channel = sh7372_dmae_channels,
529 .channel_num = ARRAY_SIZE(sh7372_dmae_channels), 503 .channel_num = ARRAY_SIZE(sh7372_dmae_channels),
530 .ts_low_shift = 3, 504 .ts_low_shift = TS_LOW_SHIFT,
531 .ts_low_mask = 0x18, 505 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
532 .ts_high_shift = (20 - 2), /* 2 bits for shifted low TS */ 506 .ts_high_shift = TS_HI_SHIFT,
533 .ts_high_mask = 0x00300000, 507 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
534 .ts_shift = ts_shift, 508 .ts_shift = dma_ts_shift,
535 .ts_shift_num = ARRAY_SIZE(ts_shift), 509 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
536 .dmaor_init = DMAOR_DME, 510 .dmaor_init = DMAOR_DME,
537 .chclr_present = 1, 511 .chclr_present = 1,
538}; 512};
@@ -654,17 +628,6 @@ static struct platform_device dma2_device = {
654/* 628/*
655 * USB-DMAC 629 * USB-DMAC
656 */ 630 */
657
658unsigned int usbts_shift[] = {3, 4, 5};
659
660enum {
661 XMIT_SZ_8BYTE = 0,
662 XMIT_SZ_16BYTE = 1,
663 XMIT_SZ_32BYTE = 2,
664};
665
666#define USBTS_INDEX2VAL(i) (((i) & 3) << 6)
667
668static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = { 631static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
669 { 632 {
670 .offset = 0, 633 .offset = 0,
@@ -677,10 +640,10 @@ static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
677static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = { 640static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = {
678 { 641 {
679 .slave_id = SHDMA_SLAVE_USB0_TX, 642 .slave_id = SHDMA_SLAVE_USB0_TX,
680 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE), 643 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
681 }, { 644 }, {
682 .slave_id = SHDMA_SLAVE_USB0_RX, 645 .slave_id = SHDMA_SLAVE_USB0_RX,
683 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE), 646 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
684 }, 647 },
685}; 648};
686 649
@@ -689,12 +652,12 @@ static struct sh_dmae_pdata usb_dma0_platform_data = {
689 .slave_num = ARRAY_SIZE(sh7372_usb_dmae0_slaves), 652 .slave_num = ARRAY_SIZE(sh7372_usb_dmae0_slaves),
690 .channel = sh7372_usb_dmae_channels, 653 .channel = sh7372_usb_dmae_channels,
691 .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels), 654 .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
692 .ts_low_shift = 6, 655 .ts_low_shift = USBTS_LOW_SHIFT,
693 .ts_low_mask = 0xc0, 656 .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
694 .ts_high_shift = 0, 657 .ts_high_shift = USBTS_HI_SHIFT,
695 .ts_high_mask = 0, 658 .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
696 .ts_shift = usbts_shift, 659 .ts_shift = dma_usbts_shift,
697 .ts_shift_num = ARRAY_SIZE(usbts_shift), 660 .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
698 .dmaor_init = DMAOR_DME, 661 .dmaor_init = DMAOR_DME,
699 .chcr_offset = 0x14, 662 .chcr_offset = 0x14,
700 .chcr_ie_bit = 1 << 5, 663 .chcr_ie_bit = 1 << 5,
@@ -739,10 +702,10 @@ static struct platform_device usb_dma0_device = {
739static const struct sh_dmae_slave_config sh7372_usb_dmae1_slaves[] = { 702static const struct sh_dmae_slave_config sh7372_usb_dmae1_slaves[] = {
740 { 703 {
741 .slave_id = SHDMA_SLAVE_USB1_TX, 704 .slave_id = SHDMA_SLAVE_USB1_TX,
742 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE), 705 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
743 }, { 706 }, {
744 .slave_id = SHDMA_SLAVE_USB1_RX, 707 .slave_id = SHDMA_SLAVE_USB1_RX,
745 .chcr = USBTS_INDEX2VAL(XMIT_SZ_8BYTE), 708 .chcr = USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
746 }, 709 },
747}; 710};
748 711
@@ -751,12 +714,12 @@ static struct sh_dmae_pdata usb_dma1_platform_data = {
751 .slave_num = ARRAY_SIZE(sh7372_usb_dmae1_slaves), 714 .slave_num = ARRAY_SIZE(sh7372_usb_dmae1_slaves),
752 .channel = sh7372_usb_dmae_channels, 715 .channel = sh7372_usb_dmae_channels,
753 .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels), 716 .channel_num = ARRAY_SIZE(sh7372_usb_dmae_channels),
754 .ts_low_shift = 6, 717 .ts_low_shift = USBTS_LOW_SHIFT,
755 .ts_low_mask = 0xc0, 718 .ts_low_mask = USBTS_LOW_BIT << USBTS_LOW_SHIFT,
756 .ts_high_shift = 0, 719 .ts_high_shift = USBTS_HI_SHIFT,
757 .ts_high_mask = 0, 720 .ts_high_mask = USBTS_HI_BIT << USBTS_HI_SHIFT,
758 .ts_shift = usbts_shift, 721 .ts_shift = dma_usbts_shift,
759 .ts_shift_num = ARRAY_SIZE(usbts_shift), 722 .ts_shift_num = ARRAY_SIZE(dma_usbts_shift),
760 .dmaor_init = DMAOR_DME, 723 .dmaor_init = DMAOR_DME,
761 .chcr_offset = 0x14, 724 .chcr_offset = 0x14,
762 .chcr_ie_bit = 1 << 5, 725 .chcr_ie_bit = 1 << 5,
@@ -1038,21 +1001,21 @@ static struct platform_device *sh7372_late_devices[] __initdata = {
1038 1001
1039void __init sh7372_add_standard_devices(void) 1002void __init sh7372_add_standard_devices(void)
1040{ 1003{
1041 sh7372_init_pm_domain(&sh7372_a4lc); 1004 rmobile_init_pm_domain(&sh7372_pd_a4lc);
1042 sh7372_init_pm_domain(&sh7372_a4mp); 1005 rmobile_init_pm_domain(&sh7372_pd_a4mp);
1043 sh7372_init_pm_domain(&sh7372_d4); 1006 rmobile_init_pm_domain(&sh7372_pd_d4);
1044 sh7372_init_pm_domain(&sh7372_a4r); 1007 rmobile_init_pm_domain(&sh7372_pd_a4r);
1045 sh7372_init_pm_domain(&sh7372_a3rv); 1008 rmobile_init_pm_domain(&sh7372_pd_a3rv);
1046 sh7372_init_pm_domain(&sh7372_a3ri); 1009 rmobile_init_pm_domain(&sh7372_pd_a3ri);
1047 sh7372_init_pm_domain(&sh7372_a4s); 1010 rmobile_init_pm_domain(&sh7372_pd_a4s);
1048 sh7372_init_pm_domain(&sh7372_a3sp); 1011 rmobile_init_pm_domain(&sh7372_pd_a3sp);
1049 sh7372_init_pm_domain(&sh7372_a3sg); 1012 rmobile_init_pm_domain(&sh7372_pd_a3sg);
1050 1013
1051 sh7372_pm_add_subdomain(&sh7372_a4lc, &sh7372_a3rv); 1014 rmobile_pm_add_subdomain(&sh7372_pd_a4lc, &sh7372_pd_a3rv);
1052 sh7372_pm_add_subdomain(&sh7372_a4r, &sh7372_a4lc); 1015 rmobile_pm_add_subdomain(&sh7372_pd_a4r, &sh7372_pd_a4lc);
1053 1016
1054 sh7372_pm_add_subdomain(&sh7372_a4s, &sh7372_a3sg); 1017 rmobile_pm_add_subdomain(&sh7372_pd_a4s, &sh7372_pd_a3sg);
1055 sh7372_pm_add_subdomain(&sh7372_a4s, &sh7372_a3sp); 1018 rmobile_pm_add_subdomain(&sh7372_pd_a4s, &sh7372_pd_a3sp);
1056 1019
1057 platform_add_devices(sh7372_early_devices, 1020 platform_add_devices(sh7372_early_devices,
1058 ARRAY_SIZE(sh7372_early_devices)); 1021 ARRAY_SIZE(sh7372_early_devices));
@@ -1060,30 +1023,30 @@ void __init sh7372_add_standard_devices(void)
1060 platform_add_devices(sh7372_late_devices, 1023 platform_add_devices(sh7372_late_devices,
1061 ARRAY_SIZE(sh7372_late_devices)); 1024 ARRAY_SIZE(sh7372_late_devices));
1062 1025
1063 sh7372_add_device_to_domain(&sh7372_a3rv, &vpu_device); 1026 rmobile_add_device_to_domain(&sh7372_pd_a3rv, &vpu_device);
1064 sh7372_add_device_to_domain(&sh7372_a4mp, &spu0_device); 1027 rmobile_add_device_to_domain(&sh7372_pd_a4mp, &spu0_device);
1065 sh7372_add_device_to_domain(&sh7372_a4mp, &spu1_device); 1028 rmobile_add_device_to_domain(&sh7372_pd_a4mp, &spu1_device);
1066 sh7372_add_device_to_domain(&sh7372_a3sp, &scif0_device); 1029 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif0_device);
1067 sh7372_add_device_to_domain(&sh7372_a3sp, &scif1_device); 1030 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif1_device);
1068 sh7372_add_device_to_domain(&sh7372_a3sp, &scif2_device); 1031 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif2_device);
1069 sh7372_add_device_to_domain(&sh7372_a3sp, &scif3_device); 1032 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif3_device);
1070 sh7372_add_device_to_domain(&sh7372_a3sp, &scif4_device); 1033 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif4_device);
1071 sh7372_add_device_to_domain(&sh7372_a3sp, &scif5_device); 1034 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif5_device);
1072 sh7372_add_device_to_domain(&sh7372_a3sp, &scif6_device); 1035 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &scif6_device);
1073 sh7372_add_device_to_domain(&sh7372_a3sp, &iic1_device); 1036 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &iic1_device);
1074 sh7372_add_device_to_domain(&sh7372_a3sp, &dma0_device); 1037 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &dma0_device);
1075 sh7372_add_device_to_domain(&sh7372_a3sp, &dma1_device); 1038 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &dma1_device);
1076 sh7372_add_device_to_domain(&sh7372_a3sp, &dma2_device); 1039 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &dma2_device);
1077 sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma0_device); 1040 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &usb_dma0_device);
1078 sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma1_device); 1041 rmobile_add_device_to_domain(&sh7372_pd_a3sp, &usb_dma1_device);
1079 sh7372_add_device_to_domain(&sh7372_a4r, &iic0_device); 1042 rmobile_add_device_to_domain(&sh7372_pd_a4r, &iic0_device);
1080 sh7372_add_device_to_domain(&sh7372_a4r, &veu0_device); 1043 rmobile_add_device_to_domain(&sh7372_pd_a4r, &veu0_device);
1081 sh7372_add_device_to_domain(&sh7372_a4r, &veu1_device); 1044 rmobile_add_device_to_domain(&sh7372_pd_a4r, &veu1_device);
1082 sh7372_add_device_to_domain(&sh7372_a4r, &veu2_device); 1045 rmobile_add_device_to_domain(&sh7372_pd_a4r, &veu2_device);
1083 sh7372_add_device_to_domain(&sh7372_a4r, &veu3_device); 1046 rmobile_add_device_to_domain(&sh7372_pd_a4r, &veu3_device);
1084 sh7372_add_device_to_domain(&sh7372_a4r, &jpu_device); 1047 rmobile_add_device_to_domain(&sh7372_pd_a4r, &jpu_device);
1085 sh7372_add_device_to_domain(&sh7372_a4r, &tmu00_device); 1048 rmobile_add_device_to_domain(&sh7372_pd_a4r, &tmu00_device);
1086 sh7372_add_device_to_domain(&sh7372_a4r, &tmu01_device); 1049 rmobile_add_device_to_domain(&sh7372_pd_a4r, &tmu01_device);
1087} 1050}
1088 1051
1089static void __init sh7372_earlytimer_init(void) 1052static void __init sh7372_earlytimer_init(void)
diff --git a/arch/arm/mach-shmobile/setup-sh7377.c b/arch/arm/mach-shmobile/setup-sh7377.c
index d576a6abbade..855b1506caf8 100644
--- a/arch/arm/mach-shmobile/setup-sh7377.c
+++ b/arch/arm/mach-shmobile/setup-sh7377.c
@@ -22,6 +22,7 @@
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/irq.h> 23#include <linux/irq.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/of_platform.h>
25#include <linux/uio_driver.h> 26#include <linux/uio_driver.h>
26#include <linux/delay.h> 27#include <linux/delay.h>
27#include <linux/input.h> 28#include <linux/input.h>
@@ -500,3 +501,49 @@ void __init sh7377_add_early_devices(void)
500 /* override timer setup with soc-specific code */ 501 /* override timer setup with soc-specific code */
501 shmobile_timer.init = sh7377_earlytimer_init; 502 shmobile_timer.init = sh7377_earlytimer_init;
502} 503}
504
505#ifdef CONFIG_USE_OF
506
507void __init sh7377_add_early_devices_dt(void)
508{
509 shmobile_setup_delay(600, 1, 3); /* Cortex-A8 @ 600MHz */
510
511 early_platform_add_devices(sh7377_early_devices,
512 ARRAY_SIZE(sh7377_early_devices));
513
514 /* setup early console here as well */
515 shmobile_setup_console();
516}
517
518static const struct of_dev_auxdata sh7377_auxdata_lookup[] __initconst = {
519 { }
520};
521
522void __init sh7377_add_standard_devices_dt(void)
523{
524 /* clocks are setup late during boot in the case of DT */
525 sh7377_clock_init();
526
527 platform_add_devices(sh7377_early_devices,
528 ARRAY_SIZE(sh7377_early_devices));
529
530 of_platform_populate(NULL, of_default_bus_match_table,
531 sh7377_auxdata_lookup, NULL);
532}
533
534static const char *sh7377_boards_compat_dt[] __initdata = {
535 "renesas,sh7377",
536 NULL,
537};
538
539DT_MACHINE_START(SH7377_DT, "Generic SH7377 (Flattened Device Tree)")
540 .map_io = sh7377_map_io,
541 .init_early = sh7377_add_early_devices_dt,
542 .init_irq = sh7377_init_irq,
543 .handle_irq = shmobile_handle_irq_intc,
544 .init_machine = sh7377_add_standard_devices_dt,
545 .timer = &shmobile_timer,
546 .dt_compat = sh7377_boards_compat_dt,
547MACHINE_END
548
549#endif /* CONFIG_USE_OF */
diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
index 04a0dfe75493..d230af656fc9 100644
--- a/arch/arm/mach-shmobile/setup-sh73a0.c
+++ b/arch/arm/mach-shmobile/setup-sh73a0.c
@@ -30,6 +30,7 @@
30#include <linux/sh_dma.h> 30#include <linux/sh_dma.h>
31#include <linux/sh_intc.h> 31#include <linux/sh_intc.h>
32#include <linux/sh_timer.h> 32#include <linux/sh_timer.h>
33#include <mach/dma-register.h>
33#include <mach/hardware.h> 34#include <mach/hardware.h>
34#include <mach/irqs.h> 35#include <mach/irqs.h>
35#include <mach/sh73a0.h> 36#include <mach/sh73a0.h>
@@ -415,32 +416,6 @@ static struct platform_device i2c4_device = {
415 .num_resources = ARRAY_SIZE(i2c4_resources), 416 .num_resources = ARRAY_SIZE(i2c4_resources),
416}; 417};
417 418
418/* Transmit sizes and respective CHCR register values */
419enum {
420 XMIT_SZ_8BIT = 0,
421 XMIT_SZ_16BIT = 1,
422 XMIT_SZ_32BIT = 2,
423 XMIT_SZ_64BIT = 7,
424 XMIT_SZ_128BIT = 3,
425 XMIT_SZ_256BIT = 4,
426 XMIT_SZ_512BIT = 5,
427};
428
429/* log2(size / 8) - used to calculate number of transfers */
430#define TS_SHIFT { \
431 [XMIT_SZ_8BIT] = 0, \
432 [XMIT_SZ_16BIT] = 1, \
433 [XMIT_SZ_32BIT] = 2, \
434 [XMIT_SZ_64BIT] = 3, \
435 [XMIT_SZ_128BIT] = 4, \
436 [XMIT_SZ_256BIT] = 5, \
437 [XMIT_SZ_512BIT] = 6, \
438}
439
440#define TS_INDEX2VAL(i) ((((i) & 3) << 3) | (((i) & 0xc) << (20 - 2)))
441#define CHCR_TX(xmit_sz) (DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL((xmit_sz)))
442#define CHCR_RX(xmit_sz) (DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL((xmit_sz)))
443
444static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = { 419static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
445 { 420 {
446 .slave_id = SHDMA_SLAVE_SCIF0_TX, 421 .slave_id = SHDMA_SLAVE_SCIF0_TX,
@@ -604,19 +579,17 @@ static const struct sh_dmae_channel sh73a0_dmae_channels[] = {
604 DMAE_CHANNEL(0x8980), 579 DMAE_CHANNEL(0x8980),
605}; 580};
606 581
607static const unsigned int ts_shift[] = TS_SHIFT;
608
609static struct sh_dmae_pdata sh73a0_dmae_platform_data = { 582static struct sh_dmae_pdata sh73a0_dmae_platform_data = {
610 .slave = sh73a0_dmae_slaves, 583 .slave = sh73a0_dmae_slaves,
611 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves), 584 .slave_num = ARRAY_SIZE(sh73a0_dmae_slaves),
612 .channel = sh73a0_dmae_channels, 585 .channel = sh73a0_dmae_channels,
613 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels), 586 .channel_num = ARRAY_SIZE(sh73a0_dmae_channels),
614 .ts_low_shift = 3, 587 .ts_low_shift = TS_LOW_SHIFT,
615 .ts_low_mask = 0x18, 588 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
616 .ts_high_shift = (20 - 2), /* 2 bits for shifted low TS */ 589 .ts_high_shift = TS_HI_SHIFT,
617 .ts_high_mask = 0x00300000, 590 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
618 .ts_shift = ts_shift, 591 .ts_shift = dma_ts_shift,
619 .ts_shift_num = ARRAY_SIZE(ts_shift), 592 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
620 .dmaor_init = DMAOR_DME, 593 .dmaor_init = DMAOR_DME,
621}; 594};
622 595
@@ -651,6 +624,116 @@ static struct platform_device dma0_device = {
651 }, 624 },
652}; 625};
653 626
627/* MPDMAC */
628static const struct sh_dmae_slave_config sh73a0_mpdma_slaves[] = {
629 {
630 .slave_id = SHDMA_SLAVE_FSI2A_RX,
631 .addr = 0xec230020,
632 .chcr = CHCR_RX(XMIT_SZ_32BIT),
633 .mid_rid = 0xd6, /* CHECK ME */
634 }, {
635 .slave_id = SHDMA_SLAVE_FSI2A_TX,
636 .addr = 0xec230024,
637 .chcr = CHCR_TX(XMIT_SZ_32BIT),
638 .mid_rid = 0xd5, /* CHECK ME */
639 }, {
640 .slave_id = SHDMA_SLAVE_FSI2C_RX,
641 .addr = 0xec230060,
642 .chcr = CHCR_RX(XMIT_SZ_32BIT),
643 .mid_rid = 0xda, /* CHECK ME */
644 }, {
645 .slave_id = SHDMA_SLAVE_FSI2C_TX,
646 .addr = 0xec230064,
647 .chcr = CHCR_TX(XMIT_SZ_32BIT),
648 .mid_rid = 0xd9, /* CHECK ME */
649 }, {
650 .slave_id = SHDMA_SLAVE_FSI2B_RX,
651 .addr = 0xec240020,
652 .chcr = CHCR_RX(XMIT_SZ_32BIT),
653 .mid_rid = 0x8e, /* CHECK ME */
654 }, {
655 .slave_id = SHDMA_SLAVE_FSI2B_TX,
656 .addr = 0xec240024,
657 .chcr = CHCR_RX(XMIT_SZ_32BIT),
658 .mid_rid = 0x8d, /* CHECK ME */
659 }, {
660 .slave_id = SHDMA_SLAVE_FSI2D_RX,
661 .addr = 0xec240060,
662 .chcr = CHCR_RX(XMIT_SZ_32BIT),
663 .mid_rid = 0x9a, /* CHECK ME */
664 },
665};
666
667#define MPDMA_CHANNEL(a, b, c) \
668{ \
669 .offset = a, \
670 .dmars = b, \
671 .dmars_bit = c, \
672 .chclr_offset = (0x220 - 0x20) + a \
673}
674
675static const struct sh_dmae_channel sh73a0_mpdma_channels[] = {
676 MPDMA_CHANNEL(0x00, 0, 0),
677 MPDMA_CHANNEL(0x10, 0, 8),
678 MPDMA_CHANNEL(0x20, 4, 0),
679 MPDMA_CHANNEL(0x30, 4, 8),
680 MPDMA_CHANNEL(0x50, 8, 0),
681 MPDMA_CHANNEL(0x70, 8, 8),
682};
683
684static struct sh_dmae_pdata sh73a0_mpdma_platform_data = {
685 .slave = sh73a0_mpdma_slaves,
686 .slave_num = ARRAY_SIZE(sh73a0_mpdma_slaves),
687 .channel = sh73a0_mpdma_channels,
688 .channel_num = ARRAY_SIZE(sh73a0_mpdma_channels),
689 .ts_low_shift = TS_LOW_SHIFT,
690 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
691 .ts_high_shift = TS_HI_SHIFT,
692 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
693 .ts_shift = dma_ts_shift,
694 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
695 .dmaor_init = DMAOR_DME,
696 .chclr_present = 1,
697};
698
699/* Resource order important! */
700static struct resource sh73a0_mpdma_resources[] = {
701 {
702 /* Channel registers and DMAOR */
703 .start = 0xec618020,
704 .end = 0xec61828f,
705 .flags = IORESOURCE_MEM,
706 },
707 {
708 /* DMARSx */
709 .start = 0xec619000,
710 .end = 0xec61900b,
711 .flags = IORESOURCE_MEM,
712 },
713 {
714 .name = "error_irq",
715 .start = gic_spi(181),
716 .end = gic_spi(181),
717 .flags = IORESOURCE_IRQ,
718 },
719 {
720 /* IRQ for channels 0-5 */
721 .start = gic_spi(175),
722 .end = gic_spi(180),
723 .flags = IORESOURCE_IRQ,
724 },
725};
726
727static struct platform_device mpdma0_device = {
728 .name = "sh-dma-engine",
729 .id = 1,
730 .resource = sh73a0_mpdma_resources,
731 .num_resources = ARRAY_SIZE(sh73a0_mpdma_resources),
732 .dev = {
733 .platform_data = &sh73a0_mpdma_platform_data,
734 },
735};
736
654static struct platform_device *sh73a0_early_devices[] __initdata = { 737static struct platform_device *sh73a0_early_devices[] __initdata = {
655 &scif0_device, 738 &scif0_device,
656 &scif1_device, 739 &scif1_device,
@@ -673,6 +756,7 @@ static struct platform_device *sh73a0_late_devices[] __initdata = {
673 &i2c3_device, 756 &i2c3_device,
674 &i2c4_device, 757 &i2c4_device,
675 &dma0_device, 758 &dma0_device,
759 &mpdma0_device,
676}; 760};
677 761
678#define SRCR2 0xe61580b0 762#define SRCR2 0xe61580b0
diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c b/arch/arm/mach-tegra/board-dt-tegra20.c
index d0de9c1192f7..c0999633a9ab 100644
--- a/arch/arm/mach-tegra/board-dt-tegra20.c
+++ b/arch/arm/mach-tegra/board-dt-tegra20.c
@@ -64,7 +64,8 @@ struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = {
64 &tegra_ehci2_pdata), 64 &tegra_ehci2_pdata),
65 OF_DEV_AUXDATA("nvidia,tegra20-ehci", TEGRA_USB3_BASE, "tegra-ehci.2", 65 OF_DEV_AUXDATA("nvidia,tegra20-ehci", TEGRA_USB3_BASE, "tegra-ehci.2",
66 &tegra_ehci3_pdata), 66 &tegra_ehci3_pdata),
67 OF_DEV_AUXDATA("nvidia,tegra20-apbdma", 0x6000a000, "tegra-apbdma", NULL), 67 OF_DEV_AUXDATA("nvidia,tegra20-apbdma", TEGRA_APB_DMA_BASE, "tegra-apbdma", NULL),
68 OF_DEV_AUXDATA("nvidia,tegra20-pwm", TEGRA_PWFM_BASE, "tegra-pwm", NULL),
68 {} 69 {}
69}; 70};
70 71
diff --git a/arch/arm/mach-tegra/board-dt-tegra30.c b/arch/arm/mach-tegra/board-dt-tegra30.c
index ee48214bfd89..53bf60f11580 100644
--- a/arch/arm/mach-tegra/board-dt-tegra30.c
+++ b/arch/arm/mach-tegra/board-dt-tegra30.c
@@ -33,6 +33,8 @@
33#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
34#include <asm/hardware/gic.h> 34#include <asm/hardware/gic.h>
35 35
36#include <mach/iomap.h>
37
36#include "board.h" 38#include "board.h"
37#include "clock.h" 39#include "clock.h"
38 40
@@ -48,6 +50,7 @@ struct of_dev_auxdata tegra30_auxdata_lookup[] __initdata = {
48 OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000D000, "tegra-i2c.4", NULL), 50 OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000D000, "tegra-i2c.4", NULL),
49 OF_DEV_AUXDATA("nvidia,tegra30-ahub", 0x70080000, "tegra30-ahub", NULL), 51 OF_DEV_AUXDATA("nvidia,tegra30-ahub", 0x70080000, "tegra30-ahub", NULL),
50 OF_DEV_AUXDATA("nvidia,tegra30-apbdma", 0x6000a000, "tegra-apbdma", NULL), 52 OF_DEV_AUXDATA("nvidia,tegra30-apbdma", 0x6000a000, "tegra-apbdma", NULL),
53 OF_DEV_AUXDATA("nvidia,tegra30-pwm", TEGRA_PWFM_BASE, "tegra-pwm", NULL),
51 {} 54 {}
52}; 55};
53 56
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index 8f421c0ca45c..8674a890fd1c 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -211,24 +211,6 @@ static struct ab8500_platform_data ab8500_platdata = {
211 .codec = &ab8500_codec_pdata, 211 .codec = &ab8500_codec_pdata,
212}; 212};
213 213
214static struct resource ab8500_resources[] = {
215 [0] = {
216 .start = IRQ_DB8500_AB8500,
217 .end = IRQ_DB8500_AB8500,
218 .flags = IORESOURCE_IRQ
219 }
220};
221
222struct platform_device ab8500_device = {
223 .name = "ab8500-core",
224 .id = 0,
225 .dev = {
226 .platform_data = &ab8500_platdata,
227 },
228 .num_resources = 1,
229 .resource = ab8500_resources,
230};
231
232/* 214/*
233 * TPS61052 215 * TPS61052
234 */ 216 */
@@ -443,7 +425,6 @@ static struct hash_platform_data u8500_hash1_platform_data = {
443/* add any platform devices here - TODO */ 425/* add any platform devices here - TODO */
444static struct platform_device *mop500_platform_devs[] __initdata = { 426static struct platform_device *mop500_platform_devs[] __initdata = {
445 &mop500_gpio_keys_device, 427 &mop500_gpio_keys_device,
446 &ab8500_device,
447}; 428};
448 429
449#ifdef CONFIG_STE_DMA40 430#ifdef CONFIG_STE_DMA40
@@ -605,7 +586,6 @@ static struct platform_device *snowball_platform_devs[] __initdata = {
605 &snowball_led_dev, 586 &snowball_led_dev,
606 &snowball_key_dev, 587 &snowball_key_dev,
607 &snowball_sbnet_dev, 588 &snowball_sbnet_dev,
608 &ab8500_device,
609}; 589};
610 590
611static void __init mop500_init_machine(void) 591static void __init mop500_init_machine(void)
@@ -617,9 +597,8 @@ static void __init mop500_init_machine(void)
617 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR; 597 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
618 598
619 mop500_pinmaps_init(); 599 mop500_pinmaps_init();
620 parent = u8500_init_devices(); 600 parent = u8500_init_devices(&ab8500_platdata);
621 601
622 /* FIXME: parent of ab8500 should be prcmu */
623 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++) 602 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
624 mop500_platform_devs[i]->dev.parent = parent; 603 mop500_platform_devs[i]->dev.parent = parent;
625 604
@@ -652,7 +631,7 @@ static void __init snowball_init_machine(void)
652 int i; 631 int i;
653 632
654 snowball_pinmaps_init(); 633 snowball_pinmaps_init();
655 parent = u8500_init_devices(); 634 parent = u8500_init_devices(&ab8500_platdata);
656 635
657 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++) 636 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
658 snowball_platform_devs[i]->dev.parent = parent; 637 snowball_platform_devs[i]->dev.parent = parent;
@@ -684,7 +663,7 @@ static void __init hrefv60_init_machine(void)
684 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO; 663 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
685 664
686 hrefv60_pinmaps_init(); 665 hrefv60_pinmaps_init();
687 parent = u8500_init_devices(); 666 parent = u8500_init_devices(&ab8500_platdata);
688 667
689 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++) 668 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
690 mop500_platform_devs[i]->dev.parent = parent; 669 mop500_platform_devs[i]->dev.parent = parent;
@@ -785,9 +764,6 @@ static const struct of_device_id u8500_local_bus_nodes[] = {
785 /* only create devices below soc node */ 764 /* only create devices below soc node */
786 { .compatible = "stericsson,db8500", }, 765 { .compatible = "stericsson,db8500", },
787 { .compatible = "stericsson,db8500-prcmu", }, 766 { .compatible = "stericsson,db8500-prcmu", },
788 { .compatible = "stericsson,db8500-prcmu-regulator", },
789 { .compatible = "stericsson,ab8500", },
790 { .compatible = "stericsson,ab8500-regulator", },
791 { .compatible = "simple-bus"}, 767 { .compatible = "simple-bus"},
792 { }, 768 { },
793}; 769};
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index c8dd94f606dc..db3c52d56ca4 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -16,6 +16,7 @@
16#include <linux/irq.h> 16#include <linux/irq.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/mfd/abx500/ab8500.h>
19 20
20#include <asm/mach/map.h> 21#include <asm/mach/map.h>
21#include <asm/pmu.h> 22#include <asm/pmu.h>
@@ -115,7 +116,7 @@ static irqreturn_t db8500_pmu_handler(int irq, void *dev, irq_handler_t handler)
115 return ret; 116 return ret;
116} 117}
117 118
118static struct arm_pmu_platdata db8500_pmu_platdata = { 119struct arm_pmu_platdata db8500_pmu_platdata = {
119 .handle_irq = db8500_pmu_handler, 120 .handle_irq = db8500_pmu_handler,
120}; 121};
121 122
@@ -206,7 +207,7 @@ static struct device * __init db8500_soc_device_init(void)
206/* 207/*
207 * This function is called from the board init 208 * This function is called from the board init
208 */ 209 */
209struct device * __init u8500_init_devices(void) 210struct device * __init u8500_init_devices(struct ab8500_platform_data *ab8500)
210{ 211{
211 struct device *parent; 212 struct device *parent;
212 int i; 213 int i;
@@ -223,6 +224,8 @@ struct device * __init u8500_init_devices(void)
223 for (i = 0; i < ARRAY_SIZE(platform_devs); i++) 224 for (i = 0; i < ARRAY_SIZE(platform_devs); i++)
224 platform_devs[i]->dev.parent = parent; 225 platform_devs[i]->dev.parent = parent;
225 226
227 db8500_prcmu_device.dev.platform_data = ab8500;
228
226 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); 229 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
227 230
228 return parent; 231 return parent;
diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
index 8b7ed82a2866..7914e5eaa9c7 100644
--- a/arch/arm/mach-ux500/include/mach/setup.h
+++ b/arch/arm/mach-ux500/include/mach/setup.h
@@ -13,11 +13,12 @@
13 13
14#include <asm/mach/time.h> 14#include <asm/mach/time.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/mfd/abx500/ab8500.h>
16 17
17void __init ux500_map_io(void); 18void __init ux500_map_io(void);
18extern void __init u8500_map_io(void); 19extern void __init u8500_map_io(void);
19 20
20extern struct device * __init u8500_init_devices(void); 21extern struct device * __init u8500_init_devices(struct ab8500_platform_data *ab8500);
21 22
22extern void __init ux500_init_irq(void); 23extern void __init ux500_init_irq(void);
23extern void __init ux500_init_late(void); 24extern void __init ux500_init_late(void);
diff --git a/arch/arm/mach-vt8500/Makefile b/arch/arm/mach-vt8500/Makefile
index 54e69973f39b..7ce51767c99c 100644
--- a/arch/arm/mach-vt8500/Makefile
+++ b/arch/arm/mach-vt8500/Makefile
@@ -5,5 +5,3 @@ obj-$(CONFIG_VTWM_VERSION_WM8505) += devices-wm8505.o
5 5
6obj-$(CONFIG_MACH_BV07) += bv07.o 6obj-$(CONFIG_MACH_BV07) += bv07.o
7obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o 7obj-$(CONFIG_MACH_WM8505_7IN_NETBOOK) += wm8505_7in.o
8
9obj-$(CONFIG_HAVE_PWM) += pwm.o
diff --git a/arch/arm/mach-vt8500/pwm.c b/arch/arm/mach-vt8500/pwm.c
deleted file mode 100644
index 8ad825e93592..000000000000
--- a/arch/arm/mach-vt8500/pwm.c
+++ /dev/null
@@ -1,265 +0,0 @@
1/*
2 * arch/arm/mach-vt8500/pwm.c
3 *
4 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/platform_device.h>
19#include <linux/slab.h>
20#include <linux/err.h>
21#include <linux/io.h>
22#include <linux/pwm.h>
23#include <linux/delay.h>
24
25#include <asm/div64.h>
26
27#define VT8500_NR_PWMS 4
28
29static DEFINE_MUTEX(pwm_lock);
30static LIST_HEAD(pwm_list);
31
32struct pwm_device {
33 struct list_head node;
34 struct platform_device *pdev;
35
36 const char *label;
37
38 void __iomem *regbase;
39
40 unsigned int use_count;
41 unsigned int pwm_id;
42};
43
44#define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
45static inline void pwm_busy_wait(void __iomem *reg, u8 bitmask)
46{
47 int loops = msecs_to_loops(10);
48 while ((readb(reg) & bitmask) && --loops)
49 cpu_relax();
50
51 if (unlikely(!loops))
52 pr_warning("Waiting for status bits 0x%x to clear timed out\n",
53 bitmask);
54}
55
56int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
57{
58 unsigned long long c;
59 unsigned long period_cycles, prescale, pv, dc;
60
61 if (pwm == NULL || period_ns == 0 || duty_ns > period_ns)
62 return -EINVAL;
63
64 c = 25000000/2; /* wild guess --- need to implement clocks */
65 c = c * period_ns;
66 do_div(c, 1000000000);
67 period_cycles = c;
68
69 if (period_cycles < 1)
70 period_cycles = 1;
71 prescale = (period_cycles - 1) / 4096;
72 pv = period_cycles / (prescale + 1) - 1;
73 if (pv > 4095)
74 pv = 4095;
75
76 if (prescale > 1023)
77 return -EINVAL;
78
79 c = (unsigned long long)pv * duty_ns;
80 do_div(c, period_ns);
81 dc = c;
82
83 pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 1));
84 writel(prescale, pwm->regbase + 0x4 + (pwm->pwm_id << 4));
85
86 pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 2));
87 writel(pv, pwm->regbase + 0x8 + (pwm->pwm_id << 4));
88
89 pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 3));
90 writel(dc, pwm->regbase + 0xc + (pwm->pwm_id << 4));
91
92 return 0;
93}
94EXPORT_SYMBOL(pwm_config);
95
96int pwm_enable(struct pwm_device *pwm)
97{
98 pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 0));
99 writel(5, pwm->regbase + (pwm->pwm_id << 4));
100 return 0;
101}
102EXPORT_SYMBOL(pwm_enable);
103
104void pwm_disable(struct pwm_device *pwm)
105{
106 pwm_busy_wait(pwm->regbase + 0x40 + pwm->pwm_id, (1 << 0));
107 writel(0, pwm->regbase + (pwm->pwm_id << 4));
108}
109EXPORT_SYMBOL(pwm_disable);
110
111struct pwm_device *pwm_request(int pwm_id, const char *label)
112{
113 struct pwm_device *pwm;
114 int found = 0;
115
116 mutex_lock(&pwm_lock);
117
118 list_for_each_entry(pwm, &pwm_list, node) {
119 if (pwm->pwm_id == pwm_id) {
120 found = 1;
121 break;
122 }
123 }
124
125 if (found) {
126 if (pwm->use_count == 0) {
127 pwm->use_count++;
128 pwm->label = label;
129 } else {
130 pwm = ERR_PTR(-EBUSY);
131 }
132 } else {
133 pwm = ERR_PTR(-ENOENT);
134 }
135
136 mutex_unlock(&pwm_lock);
137 return pwm;
138}
139EXPORT_SYMBOL(pwm_request);
140
141void pwm_free(struct pwm_device *pwm)
142{
143 mutex_lock(&pwm_lock);
144
145 if (pwm->use_count) {
146 pwm->use_count--;
147 pwm->label = NULL;
148 } else {
149 pr_warning("PWM device already freed\n");
150 }
151
152 mutex_unlock(&pwm_lock);
153}
154EXPORT_SYMBOL(pwm_free);
155
156static inline void __add_pwm(struct pwm_device *pwm)
157{
158 mutex_lock(&pwm_lock);
159 list_add_tail(&pwm->node, &pwm_list);
160 mutex_unlock(&pwm_lock);
161}
162
163static int __devinit pwm_probe(struct platform_device *pdev)
164{
165 struct pwm_device *pwms;
166 struct resource *r;
167 int ret = 0;
168 int i;
169
170 pwms = kzalloc(sizeof(struct pwm_device) * VT8500_NR_PWMS, GFP_KERNEL);
171 if (pwms == NULL) {
172 dev_err(&pdev->dev, "failed to allocate memory\n");
173 return -ENOMEM;
174 }
175
176 for (i = 0; i < VT8500_NR_PWMS; i++) {
177 pwms[i].use_count = 0;
178 pwms[i].pwm_id = i;
179 pwms[i].pdev = pdev;
180 }
181
182 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
183 if (r == NULL) {
184 dev_err(&pdev->dev, "no memory resource defined\n");
185 ret = -ENODEV;
186 goto err_free;
187 }
188
189 r = request_mem_region(r->start, resource_size(r), pdev->name);
190 if (r == NULL) {
191 dev_err(&pdev->dev, "failed to request memory resource\n");
192 ret = -EBUSY;
193 goto err_free;
194 }
195
196 pwms[0].regbase = ioremap(r->start, resource_size(r));
197 if (pwms[0].regbase == NULL) {
198 dev_err(&pdev->dev, "failed to ioremap() registers\n");
199 ret = -ENODEV;
200 goto err_free_mem;
201 }
202
203 for (i = 1; i < VT8500_NR_PWMS; i++)
204 pwms[i].regbase = pwms[0].regbase;
205
206 for (i = 0; i < VT8500_NR_PWMS; i++)
207 __add_pwm(&pwms[i]);
208
209 platform_set_drvdata(pdev, pwms);
210 return 0;
211
212err_free_mem:
213 release_mem_region(r->start, resource_size(r));
214err_free:
215 kfree(pwms);
216 return ret;
217}
218
219static int __devexit pwm_remove(struct platform_device *pdev)
220{
221 struct pwm_device *pwms;
222 struct resource *r;
223 int i;
224
225 pwms = platform_get_drvdata(pdev);
226 if (pwms == NULL)
227 return -ENODEV;
228
229 mutex_lock(&pwm_lock);
230
231 for (i = 0; i < VT8500_NR_PWMS; i++)
232 list_del(&pwms[i].node);
233 mutex_unlock(&pwm_lock);
234
235 iounmap(pwms[0].regbase);
236
237 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
238 release_mem_region(r->start, resource_size(r));
239
240 kfree(pwms);
241 return 0;
242}
243
244static struct platform_driver pwm_driver = {
245 .driver = {
246 .name = "vt8500-pwm",
247 .owner = THIS_MODULE,
248 },
249 .probe = pwm_probe,
250 .remove = __devexit_p(pwm_remove),
251};
252
253static int __init pwm_init(void)
254{
255 return platform_driver_register(&pwm_driver);
256}
257arch_initcall(pwm_init);
258
259static void __exit pwm_exit(void)
260{
261 platform_driver_unregister(&pwm_driver);
262}
263module_exit(pwm_exit);
264
265MODULE_LICENSE("GPL");
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 5cfc98994076..c2cdf6500f75 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -22,6 +22,7 @@
22#include <linux/memblock.h> 22#include <linux/memblock.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/iommu.h> 24#include <linux/iommu.h>
25#include <linux/io.h>
25#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
26#include <linux/sizes.h> 27#include <linux/sizes.h>
27 28
@@ -72,7 +73,7 @@ static dma_addr_t arm_dma_map_page(struct device *dev, struct page *page,
72 unsigned long offset, size_t size, enum dma_data_direction dir, 73 unsigned long offset, size_t size, enum dma_data_direction dir,
73 struct dma_attrs *attrs) 74 struct dma_attrs *attrs)
74{ 75{
75 if (!arch_is_coherent()) 76 if (!arch_is_coherent() && !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
76 __dma_page_cpu_to_dev(page, offset, size, dir); 77 __dma_page_cpu_to_dev(page, offset, size, dir);
77 return pfn_to_dma(dev, page_to_pfn(page)) + offset; 78 return pfn_to_dma(dev, page_to_pfn(page)) + offset;
78} 79}
@@ -95,7 +96,7 @@ static void arm_dma_unmap_page(struct device *dev, dma_addr_t handle,
95 size_t size, enum dma_data_direction dir, 96 size_t size, enum dma_data_direction dir,
96 struct dma_attrs *attrs) 97 struct dma_attrs *attrs)
97{ 98{
98 if (!arch_is_coherent()) 99 if (!arch_is_coherent() && !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
99 __dma_page_dev_to_cpu(pfn_to_page(dma_to_pfn(dev, handle)), 100 __dma_page_dev_to_cpu(pfn_to_page(dma_to_pfn(dev, handle)),
100 handle & ~PAGE_MASK, size, dir); 101 handle & ~PAGE_MASK, size, dir);
101} 102}
@@ -124,6 +125,7 @@ struct dma_map_ops arm_dma_ops = {
124 .alloc = arm_dma_alloc, 125 .alloc = arm_dma_alloc,
125 .free = arm_dma_free, 126 .free = arm_dma_free,
126 .mmap = arm_dma_mmap, 127 .mmap = arm_dma_mmap,
128 .get_sgtable = arm_dma_get_sgtable,
127 .map_page = arm_dma_map_page, 129 .map_page = arm_dma_map_page,
128 .unmap_page = arm_dma_unmap_page, 130 .unmap_page = arm_dma_unmap_page,
129 .map_sg = arm_dma_map_sg, 131 .map_sg = arm_dma_map_sg,
@@ -217,115 +219,70 @@ static void __dma_free_buffer(struct page *page, size_t size)
217} 219}
218 220
219#ifdef CONFIG_MMU 221#ifdef CONFIG_MMU
222#ifdef CONFIG_HUGETLB_PAGE
223#error ARM Coherent DMA allocator does not (yet) support huge TLB
224#endif
220 225
221#define CONSISTENT_OFFSET(x) (((unsigned long)(x) - consistent_base) >> PAGE_SHIFT) 226static void *__alloc_from_contiguous(struct device *dev, size_t size,
222#define CONSISTENT_PTE_INDEX(x) (((unsigned long)(x) - consistent_base) >> PMD_SHIFT) 227 pgprot_t prot, struct page **ret_page);
223
224/*
225 * These are the page tables (2MB each) covering uncached, DMA consistent allocations
226 */
227static pte_t **consistent_pte;
228
229#define DEFAULT_CONSISTENT_DMA_SIZE SZ_2M
230 228
231static unsigned long consistent_base = CONSISTENT_END - DEFAULT_CONSISTENT_DMA_SIZE; 229static void *__alloc_remap_buffer(struct device *dev, size_t size, gfp_t gfp,
230 pgprot_t prot, struct page **ret_page,
231 const void *caller);
232 232
233void __init init_consistent_dma_size(unsigned long size) 233static void *
234__dma_alloc_remap(struct page *page, size_t size, gfp_t gfp, pgprot_t prot,
235 const void *caller)
234{ 236{
235 unsigned long base = CONSISTENT_END - ALIGN(size, SZ_2M); 237 struct vm_struct *area;
238 unsigned long addr;
236 239
237 BUG_ON(consistent_pte); /* Check we're called before DMA region init */ 240 /*
238 BUG_ON(base < VMALLOC_END); 241 * DMA allocation can be mapped to user space, so lets
242 * set VM_USERMAP flags too.
243 */
244 area = get_vm_area_caller(size, VM_ARM_DMA_CONSISTENT | VM_USERMAP,
245 caller);
246 if (!area)
247 return NULL;
248 addr = (unsigned long)area->addr;
249 area->phys_addr = __pfn_to_phys(page_to_pfn(page));
239 250
240 /* Grow region to accommodate specified size */ 251 if (ioremap_page_range(addr, addr + size, area->phys_addr, prot)) {
241 if (base < consistent_base) 252 vunmap((void *)addr);
242 consistent_base = base; 253 return NULL;
254 }
255 return (void *)addr;
243} 256}
244 257
245#include "vmregion.h" 258static void __dma_free_remap(void *cpu_addr, size_t size)
246
247static struct arm_vmregion_head consistent_head = {
248 .vm_lock = __SPIN_LOCK_UNLOCKED(&consistent_head.vm_lock),
249 .vm_list = LIST_HEAD_INIT(consistent_head.vm_list),
250 .vm_end = CONSISTENT_END,
251};
252
253#ifdef CONFIG_HUGETLB_PAGE
254#error ARM Coherent DMA allocator does not (yet) support huge TLB
255#endif
256
257/*
258 * Initialise the consistent memory allocation.
259 */
260static int __init consistent_init(void)
261{ 259{
262 int ret = 0; 260 unsigned int flags = VM_ARM_DMA_CONSISTENT | VM_USERMAP;
263 pgd_t *pgd; 261 struct vm_struct *area = find_vm_area(cpu_addr);
264 pud_t *pud; 262 if (!area || (area->flags & flags) != flags) {
265 pmd_t *pmd; 263 WARN(1, "trying to free invalid coherent area: %p\n", cpu_addr);
266 pte_t *pte; 264 return;
267 int i = 0;
268 unsigned long base = consistent_base;
269 unsigned long num_ptes = (CONSISTENT_END - base) >> PMD_SHIFT;
270
271 if (IS_ENABLED(CONFIG_CMA) && !IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU))
272 return 0;
273
274 consistent_pte = kmalloc(num_ptes * sizeof(pte_t), GFP_KERNEL);
275 if (!consistent_pte) {
276 pr_err("%s: no memory\n", __func__);
277 return -ENOMEM;
278 } 265 }
279 266 unmap_kernel_range((unsigned long)cpu_addr, size);
280 pr_debug("DMA memory: 0x%08lx - 0x%08lx:\n", base, CONSISTENT_END); 267 vunmap(cpu_addr);
281 consistent_head.vm_start = base;
282
283 do {
284 pgd = pgd_offset(&init_mm, base);
285
286 pud = pud_alloc(&init_mm, pgd, base);
287 if (!pud) {
288 pr_err("%s: no pud tables\n", __func__);
289 ret = -ENOMEM;
290 break;
291 }
292
293 pmd = pmd_alloc(&init_mm, pud, base);
294 if (!pmd) {
295 pr_err("%s: no pmd tables\n", __func__);
296 ret = -ENOMEM;
297 break;
298 }
299 WARN_ON(!pmd_none(*pmd));
300
301 pte = pte_alloc_kernel(pmd, base);
302 if (!pte) {
303 pr_err("%s: no pte tables\n", __func__);
304 ret = -ENOMEM;
305 break;
306 }
307
308 consistent_pte[i++] = pte;
309 base += PMD_SIZE;
310 } while (base < CONSISTENT_END);
311
312 return ret;
313} 268}
314core_initcall(consistent_init);
315 269
316static void *__alloc_from_contiguous(struct device *dev, size_t size, 270struct dma_pool {
317 pgprot_t prot, struct page **ret_page); 271 size_t size;
318 272 spinlock_t lock;
319static struct arm_vmregion_head coherent_head = { 273 unsigned long *bitmap;
320 .vm_lock = __SPIN_LOCK_UNLOCKED(&coherent_head.vm_lock), 274 unsigned long nr_pages;
321 .vm_list = LIST_HEAD_INIT(coherent_head.vm_list), 275 void *vaddr;
276 struct page *page;
322}; 277};
323 278
324static size_t coherent_pool_size = DEFAULT_CONSISTENT_DMA_SIZE / 8; 279static struct dma_pool atomic_pool = {
280 .size = SZ_256K,
281};
325 282
326static int __init early_coherent_pool(char *p) 283static int __init early_coherent_pool(char *p)
327{ 284{
328 coherent_pool_size = memparse(p, &p); 285 atomic_pool.size = memparse(p, &p);
329 return 0; 286 return 0;
330} 287}
331early_param("coherent_pool", early_coherent_pool); 288early_param("coherent_pool", early_coherent_pool);
@@ -333,32 +290,45 @@ early_param("coherent_pool", early_coherent_pool);
333/* 290/*
334 * Initialise the coherent pool for atomic allocations. 291 * Initialise the coherent pool for atomic allocations.
335 */ 292 */
336static int __init coherent_init(void) 293static int __init atomic_pool_init(void)
337{ 294{
295 struct dma_pool *pool = &atomic_pool;
338 pgprot_t prot = pgprot_dmacoherent(pgprot_kernel); 296 pgprot_t prot = pgprot_dmacoherent(pgprot_kernel);
339 size_t size = coherent_pool_size; 297 unsigned long nr_pages = pool->size >> PAGE_SHIFT;
298 unsigned long *bitmap;
340 struct page *page; 299 struct page *page;
341 void *ptr; 300 void *ptr;
301 int bitmap_size = BITS_TO_LONGS(nr_pages) * sizeof(long);
342 302
343 if (!IS_ENABLED(CONFIG_CMA)) 303 bitmap = kzalloc(bitmap_size, GFP_KERNEL);
344 return 0; 304 if (!bitmap)
305 goto no_bitmap;
345 306
346 ptr = __alloc_from_contiguous(NULL, size, prot, &page); 307 if (IS_ENABLED(CONFIG_CMA))
308 ptr = __alloc_from_contiguous(NULL, pool->size, prot, &page);
309 else
310 ptr = __alloc_remap_buffer(NULL, pool->size, GFP_KERNEL, prot,
311 &page, NULL);
347 if (ptr) { 312 if (ptr) {
348 coherent_head.vm_start = (unsigned long) ptr; 313 spin_lock_init(&pool->lock);
349 coherent_head.vm_end = (unsigned long) ptr + size; 314 pool->vaddr = ptr;
350 printk(KERN_INFO "DMA: preallocated %u KiB pool for atomic coherent allocations\n", 315 pool->page = page;
351 (unsigned)size / 1024); 316 pool->bitmap = bitmap;
317 pool->nr_pages = nr_pages;
318 pr_info("DMA: preallocated %u KiB pool for atomic coherent allocations\n",
319 (unsigned)pool->size / 1024);
352 return 0; 320 return 0;
353 } 321 }
354 printk(KERN_ERR "DMA: failed to allocate %u KiB pool for atomic coherent allocation\n", 322 kfree(bitmap);
355 (unsigned)size / 1024); 323no_bitmap:
324 pr_err("DMA: failed to allocate %u KiB pool for atomic coherent allocation\n",
325 (unsigned)pool->size / 1024);
356 return -ENOMEM; 326 return -ENOMEM;
357} 327}
358/* 328/*
359 * CMA is activated by core_initcall, so we must be called after it. 329 * CMA is activated by core_initcall, so we must be called after it.
360 */ 330 */
361postcore_initcall(coherent_init); 331postcore_initcall(atomic_pool_init);
362 332
363struct dma_contig_early_reserve { 333struct dma_contig_early_reserve {
364 phys_addr_t base; 334 phys_addr_t base;
@@ -406,112 +376,6 @@ void __init dma_contiguous_remap(void)
406 } 376 }
407} 377}
408 378
409static void *
410__dma_alloc_remap(struct page *page, size_t size, gfp_t gfp, pgprot_t prot,
411 const void *caller)
412{
413 struct arm_vmregion *c;
414 size_t align;
415 int bit;
416
417 if (!consistent_pte) {
418 pr_err("%s: not initialised\n", __func__);
419 dump_stack();
420 return NULL;
421 }
422
423 /*
424 * Align the virtual region allocation - maximum alignment is
425 * a section size, minimum is a page size. This helps reduce
426 * fragmentation of the DMA space, and also prevents allocations
427 * smaller than a section from crossing a section boundary.
428 */
429 bit = fls(size - 1);
430 if (bit > SECTION_SHIFT)
431 bit = SECTION_SHIFT;
432 align = 1 << bit;
433
434 /*
435 * Allocate a virtual address in the consistent mapping region.
436 */
437 c = arm_vmregion_alloc(&consistent_head, align, size,
438 gfp & ~(__GFP_DMA | __GFP_HIGHMEM), caller);
439 if (c) {
440 pte_t *pte;
441 int idx = CONSISTENT_PTE_INDEX(c->vm_start);
442 u32 off = CONSISTENT_OFFSET(c->vm_start) & (PTRS_PER_PTE-1);
443
444 pte = consistent_pte[idx] + off;
445 c->priv = page;
446
447 do {
448 BUG_ON(!pte_none(*pte));
449
450 set_pte_ext(pte, mk_pte(page, prot), 0);
451 page++;
452 pte++;
453 off++;
454 if (off >= PTRS_PER_PTE) {
455 off = 0;
456 pte = consistent_pte[++idx];
457 }
458 } while (size -= PAGE_SIZE);
459
460 dsb();
461
462 return (void *)c->vm_start;
463 }
464 return NULL;
465}
466
467static void __dma_free_remap(void *cpu_addr, size_t size)
468{
469 struct arm_vmregion *c;
470 unsigned long addr;
471 pte_t *ptep;
472 int idx;
473 u32 off;
474
475 c = arm_vmregion_find_remove(&consistent_head, (unsigned long)cpu_addr);
476 if (!c) {
477 pr_err("%s: trying to free invalid coherent area: %p\n",
478 __func__, cpu_addr);
479 dump_stack();
480 return;
481 }
482
483 if ((c->vm_end - c->vm_start) != size) {
484 pr_err("%s: freeing wrong coherent size (%ld != %d)\n",
485 __func__, c->vm_end - c->vm_start, size);
486 dump_stack();
487 size = c->vm_end - c->vm_start;
488 }
489
490 idx = CONSISTENT_PTE_INDEX(c->vm_start);
491 off = CONSISTENT_OFFSET(c->vm_start) & (PTRS_PER_PTE-1);
492 ptep = consistent_pte[idx] + off;
493 addr = c->vm_start;
494 do {
495 pte_t pte = ptep_get_and_clear(&init_mm, addr, ptep);
496
497 ptep++;
498 addr += PAGE_SIZE;
499 off++;
500 if (off >= PTRS_PER_PTE) {
501 off = 0;
502 ptep = consistent_pte[++idx];
503 }
504
505 if (pte_none(pte) || !pte_present(pte))
506 pr_crit("%s: bad page in kernel page table\n",
507 __func__);
508 } while (size -= PAGE_SIZE);
509
510 flush_tlb_kernel_range(c->vm_start, c->vm_end);
511
512 arm_vmregion_free(&consistent_head, c);
513}
514
515static int __dma_update_pte(pte_t *pte, pgtable_t token, unsigned long addr, 379static int __dma_update_pte(pte_t *pte, pgtable_t token, unsigned long addr,
516 void *data) 380 void *data)
517{ 381{
@@ -552,16 +416,17 @@ static void *__alloc_remap_buffer(struct device *dev, size_t size, gfp_t gfp,
552 return ptr; 416 return ptr;
553} 417}
554 418
555static void *__alloc_from_pool(struct device *dev, size_t size, 419static void *__alloc_from_pool(size_t size, struct page **ret_page)
556 struct page **ret_page, const void *caller)
557{ 420{
558 struct arm_vmregion *c; 421 struct dma_pool *pool = &atomic_pool;
422 unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
423 unsigned int pageno;
424 unsigned long flags;
425 void *ptr = NULL;
559 size_t align; 426 size_t align;
560 427
561 if (!coherent_head.vm_start) { 428 if (!pool->vaddr) {
562 printk(KERN_ERR "%s: coherent pool not initialised!\n", 429 WARN(1, "coherent pool not initialised!\n");
563 __func__);
564 dump_stack();
565 return NULL; 430 return NULL;
566 } 431 }
567 432
@@ -571,35 +436,41 @@ static void *__alloc_from_pool(struct device *dev, size_t size,
571 * size. This helps reduce fragmentation of the DMA space. 436 * size. This helps reduce fragmentation of the DMA space.
572 */ 437 */
573 align = PAGE_SIZE << get_order(size); 438 align = PAGE_SIZE << get_order(size);
574 c = arm_vmregion_alloc(&coherent_head, align, size, 0, caller); 439
575 if (c) { 440 spin_lock_irqsave(&pool->lock, flags);
576 void *ptr = (void *)c->vm_start; 441 pageno = bitmap_find_next_zero_area(pool->bitmap, pool->nr_pages,
577 struct page *page = virt_to_page(ptr); 442 0, count, (1 << align) - 1);
578 *ret_page = page; 443 if (pageno < pool->nr_pages) {
579 return ptr; 444 bitmap_set(pool->bitmap, pageno, count);
445 ptr = pool->vaddr + PAGE_SIZE * pageno;
446 *ret_page = pool->page + pageno;
580 } 447 }
581 return NULL; 448 spin_unlock_irqrestore(&pool->lock, flags);
449
450 return ptr;
582} 451}
583 452
584static int __free_from_pool(void *cpu_addr, size_t size) 453static int __free_from_pool(void *start, size_t size)
585{ 454{
586 unsigned long start = (unsigned long)cpu_addr; 455 struct dma_pool *pool = &atomic_pool;
587 unsigned long end = start + size; 456 unsigned long pageno, count;
588 struct arm_vmregion *c; 457 unsigned long flags;
589 458
590 if (start < coherent_head.vm_start || end > coherent_head.vm_end) 459 if (start < pool->vaddr || start > pool->vaddr + pool->size)
591 return 0; 460 return 0;
592 461
593 c = arm_vmregion_find_remove(&coherent_head, (unsigned long)start); 462 if (start + size > pool->vaddr + pool->size) {
594 463 WARN(1, "freeing wrong coherent size from pool\n");
595 if ((c->vm_end - c->vm_start) != size) { 464 return 0;
596 printk(KERN_ERR "%s: freeing wrong coherent size (%ld != %d)\n",
597 __func__, c->vm_end - c->vm_start, size);
598 dump_stack();
599 size = c->vm_end - c->vm_start;
600 } 465 }
601 466
602 arm_vmregion_free(&coherent_head, c); 467 pageno = (start - pool->vaddr) >> PAGE_SHIFT;
468 count = size >> PAGE_SHIFT;
469
470 spin_lock_irqsave(&pool->lock, flags);
471 bitmap_clear(pool->bitmap, pageno, count);
472 spin_unlock_irqrestore(&pool->lock, flags);
473
603 return 1; 474 return 1;
604} 475}
605 476
@@ -644,7 +515,7 @@ static inline pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot)
644 515
645#define __get_dma_pgprot(attrs, prot) __pgprot(0) 516#define __get_dma_pgprot(attrs, prot) __pgprot(0)
646#define __alloc_remap_buffer(dev, size, gfp, prot, ret, c) NULL 517#define __alloc_remap_buffer(dev, size, gfp, prot, ret, c) NULL
647#define __alloc_from_pool(dev, size, ret_page, c) NULL 518#define __alloc_from_pool(size, ret_page) NULL
648#define __alloc_from_contiguous(dev, size, prot, ret) NULL 519#define __alloc_from_contiguous(dev, size, prot, ret) NULL
649#define __free_from_pool(cpu_addr, size) 0 520#define __free_from_pool(cpu_addr, size) 0
650#define __free_from_contiguous(dev, page, size) do { } while (0) 521#define __free_from_contiguous(dev, page, size) do { } while (0)
@@ -702,10 +573,10 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
702 573
703 if (arch_is_coherent() || nommu()) 574 if (arch_is_coherent() || nommu())
704 addr = __alloc_simple_buffer(dev, size, gfp, &page); 575 addr = __alloc_simple_buffer(dev, size, gfp, &page);
576 else if (gfp & GFP_ATOMIC)
577 addr = __alloc_from_pool(size, &page);
705 else if (!IS_ENABLED(CONFIG_CMA)) 578 else if (!IS_ENABLED(CONFIG_CMA))
706 addr = __alloc_remap_buffer(dev, size, gfp, prot, &page, caller); 579 addr = __alloc_remap_buffer(dev, size, gfp, prot, &page, caller);
707 else if (gfp & GFP_ATOMIC)
708 addr = __alloc_from_pool(dev, size, &page, caller);
709 else 580 else
710 addr = __alloc_from_contiguous(dev, size, prot, &page); 581 addr = __alloc_from_contiguous(dev, size, prot, &page);
711 582
@@ -741,16 +612,22 @@ int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma,
741{ 612{
742 int ret = -ENXIO; 613 int ret = -ENXIO;
743#ifdef CONFIG_MMU 614#ifdef CONFIG_MMU
615 unsigned long nr_vma_pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
616 unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
744 unsigned long pfn = dma_to_pfn(dev, dma_addr); 617 unsigned long pfn = dma_to_pfn(dev, dma_addr);
618 unsigned long off = vma->vm_pgoff;
619
745 vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot); 620 vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot);
746 621
747 if (dma_mmap_from_coherent(dev, vma, cpu_addr, size, &ret)) 622 if (dma_mmap_from_coherent(dev, vma, cpu_addr, size, &ret))
748 return ret; 623 return ret;
749 624
750 ret = remap_pfn_range(vma, vma->vm_start, 625 if (off < nr_pages && nr_vma_pages <= (nr_pages - off)) {
751 pfn + vma->vm_pgoff, 626 ret = remap_pfn_range(vma, vma->vm_start,
752 vma->vm_end - vma->vm_start, 627 pfn + off,
753 vma->vm_page_prot); 628 vma->vm_end - vma->vm_start,
629 vma->vm_page_prot);
630 }
754#endif /* CONFIG_MMU */ 631#endif /* CONFIG_MMU */
755 632
756 return ret; 633 return ret;
@@ -785,6 +662,21 @@ void arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
785 } 662 }
786} 663}
787 664
665int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt,
666 void *cpu_addr, dma_addr_t handle, size_t size,
667 struct dma_attrs *attrs)
668{
669 struct page *page = pfn_to_page(dma_to_pfn(dev, handle));
670 int ret;
671
672 ret = sg_alloc_table(sgt, 1, GFP_KERNEL);
673 if (unlikely(ret))
674 return ret;
675
676 sg_set_page(sgt->sgl, page, PAGE_ALIGN(size), 0);
677 return 0;
678}
679
788static void dma_cache_maint_page(struct page *page, unsigned long offset, 680static void dma_cache_maint_page(struct page *page, unsigned long offset,
789 size_t size, enum dma_data_direction dir, 681 size_t size, enum dma_data_direction dir,
790 void (*op)(const void *, size_t, int)) 682 void (*op)(const void *, size_t, int))
@@ -998,9 +890,6 @@ static int arm_dma_set_mask(struct device *dev, u64 dma_mask)
998 890
999static int __init dma_debug_do_init(void) 891static int __init dma_debug_do_init(void)
1000{ 892{
1001#ifdef CONFIG_MMU
1002 arm_vmregion_create_proc("dma-mappings", &consistent_head);
1003#endif
1004 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); 893 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
1005 return 0; 894 return 0;
1006} 895}
@@ -1088,7 +977,7 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, gfp_t
1088 977
1089 return pages; 978 return pages;
1090error: 979error:
1091 while (--i) 980 while (i--)
1092 if (pages[i]) 981 if (pages[i])
1093 __free_pages(pages[i], 0); 982 __free_pages(pages[i], 0);
1094 if (array_size <= PAGE_SIZE) 983 if (array_size <= PAGE_SIZE)
@@ -1117,61 +1006,32 @@ static int __iommu_free_buffer(struct device *dev, struct page **pages, size_t s
1117 * Create a CPU mapping for a specified pages 1006 * Create a CPU mapping for a specified pages
1118 */ 1007 */
1119static void * 1008static void *
1120__iommu_alloc_remap(struct page **pages, size_t size, gfp_t gfp, pgprot_t prot) 1009__iommu_alloc_remap(struct page **pages, size_t size, gfp_t gfp, pgprot_t prot,
1010 const void *caller)
1121{ 1011{
1122 struct arm_vmregion *c; 1012 unsigned int i, nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
1123 size_t align; 1013 struct vm_struct *area;
1124 size_t count = size >> PAGE_SHIFT; 1014 unsigned long p;
1125 int bit;
1126 1015
1127 if (!consistent_pte[0]) { 1016 area = get_vm_area_caller(size, VM_ARM_DMA_CONSISTENT | VM_USERMAP,
1128 pr_err("%s: not initialised\n", __func__); 1017 caller);
1129 dump_stack(); 1018 if (!area)
1130 return NULL; 1019 return NULL;
1131 }
1132
1133 /*
1134 * Align the virtual region allocation - maximum alignment is
1135 * a section size, minimum is a page size. This helps reduce
1136 * fragmentation of the DMA space, and also prevents allocations
1137 * smaller than a section from crossing a section boundary.
1138 */
1139 bit = fls(size - 1);
1140 if (bit > SECTION_SHIFT)
1141 bit = SECTION_SHIFT;
1142 align = 1 << bit;
1143
1144 /*
1145 * Allocate a virtual address in the consistent mapping region.
1146 */
1147 c = arm_vmregion_alloc(&consistent_head, align, size,
1148 gfp & ~(__GFP_DMA | __GFP_HIGHMEM), NULL);
1149 if (c) {
1150 pte_t *pte;
1151 int idx = CONSISTENT_PTE_INDEX(c->vm_start);
1152 int i = 0;
1153 u32 off = CONSISTENT_OFFSET(c->vm_start) & (PTRS_PER_PTE-1);
1154
1155 pte = consistent_pte[idx] + off;
1156 c->priv = pages;
1157
1158 do {
1159 BUG_ON(!pte_none(*pte));
1160
1161 set_pte_ext(pte, mk_pte(pages[i], prot), 0);
1162 pte++;
1163 off++;
1164 i++;
1165 if (off >= PTRS_PER_PTE) {
1166 off = 0;
1167 pte = consistent_pte[++idx];
1168 }
1169 } while (i < count);
1170 1020
1171 dsb(); 1021 area->pages = pages;
1022 area->nr_pages = nr_pages;
1023 p = (unsigned long)area->addr;
1172 1024
1173 return (void *)c->vm_start; 1025 for (i = 0; i < nr_pages; i++) {
1026 phys_addr_t phys = __pfn_to_phys(page_to_pfn(pages[i]));
1027 if (ioremap_page_range(p, p + PAGE_SIZE, phys, prot))
1028 goto err;
1029 p += PAGE_SIZE;
1174 } 1030 }
1031 return area->addr;
1032err:
1033 unmap_kernel_range((unsigned long)area->addr, size);
1034 vunmap(area->addr);
1175 return NULL; 1035 return NULL;
1176} 1036}
1177 1037
@@ -1230,6 +1090,19 @@ static int __iommu_remove_mapping(struct device *dev, dma_addr_t iova, size_t si
1230 return 0; 1090 return 0;
1231} 1091}
1232 1092
1093static struct page **__iommu_get_pages(void *cpu_addr, struct dma_attrs *attrs)
1094{
1095 struct vm_struct *area;
1096
1097 if (dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs))
1098 return cpu_addr;
1099
1100 area = find_vm_area(cpu_addr);
1101 if (area && (area->flags & VM_ARM_DMA_CONSISTENT))
1102 return area->pages;
1103 return NULL;
1104}
1105
1233static void *arm_iommu_alloc_attrs(struct device *dev, size_t size, 1106static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
1234 dma_addr_t *handle, gfp_t gfp, struct dma_attrs *attrs) 1107 dma_addr_t *handle, gfp_t gfp, struct dma_attrs *attrs)
1235{ 1108{
@@ -1248,7 +1121,11 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
1248 if (*handle == DMA_ERROR_CODE) 1121 if (*handle == DMA_ERROR_CODE)
1249 goto err_buffer; 1122 goto err_buffer;
1250 1123
1251 addr = __iommu_alloc_remap(pages, size, gfp, prot); 1124 if (dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs))
1125 return pages;
1126
1127 addr = __iommu_alloc_remap(pages, size, gfp, prot,
1128 __builtin_return_address(0));
1252 if (!addr) 1129 if (!addr)
1253 goto err_mapping; 1130 goto err_mapping;
1254 1131
@@ -1265,31 +1142,25 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
1265 void *cpu_addr, dma_addr_t dma_addr, size_t size, 1142 void *cpu_addr, dma_addr_t dma_addr, size_t size,
1266 struct dma_attrs *attrs) 1143 struct dma_attrs *attrs)
1267{ 1144{
1268 struct arm_vmregion *c; 1145 unsigned long uaddr = vma->vm_start;
1146 unsigned long usize = vma->vm_end - vma->vm_start;
1147 struct page **pages = __iommu_get_pages(cpu_addr, attrs);
1269 1148
1270 vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot); 1149 vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot);
1271 c = arm_vmregion_find(&consistent_head, (unsigned long)cpu_addr);
1272
1273 if (c) {
1274 struct page **pages = c->priv;
1275
1276 unsigned long uaddr = vma->vm_start;
1277 unsigned long usize = vma->vm_end - vma->vm_start;
1278 int i = 0;
1279 1150
1280 do { 1151 if (!pages)
1281 int ret; 1152 return -ENXIO;
1282 1153
1283 ret = vm_insert_page(vma, uaddr, pages[i++]); 1154 do {
1284 if (ret) { 1155 int ret = vm_insert_page(vma, uaddr, *pages++);
1285 pr_err("Remapping memory, error: %d\n", ret); 1156 if (ret) {
1286 return ret; 1157 pr_err("Remapping memory failed: %d\n", ret);
1287 } 1158 return ret;
1159 }
1160 uaddr += PAGE_SIZE;
1161 usize -= PAGE_SIZE;
1162 } while (usize > 0);
1288 1163
1289 uaddr += PAGE_SIZE;
1290 usize -= PAGE_SIZE;
1291 } while (usize > 0);
1292 }
1293 return 0; 1164 return 0;
1294} 1165}
1295 1166
@@ -1300,16 +1171,35 @@ static int arm_iommu_mmap_attrs(struct device *dev, struct vm_area_struct *vma,
1300void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr, 1171void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr,
1301 dma_addr_t handle, struct dma_attrs *attrs) 1172 dma_addr_t handle, struct dma_attrs *attrs)
1302{ 1173{
1303 struct arm_vmregion *c; 1174 struct page **pages = __iommu_get_pages(cpu_addr, attrs);
1304 size = PAGE_ALIGN(size); 1175 size = PAGE_ALIGN(size);
1305 1176
1306 c = arm_vmregion_find(&consistent_head, (unsigned long)cpu_addr); 1177 if (!pages) {
1307 if (c) { 1178 WARN(1, "trying to free invalid coherent area: %p\n", cpu_addr);
1308 struct page **pages = c->priv; 1179 return;
1309 __dma_free_remap(cpu_addr, size);
1310 __iommu_remove_mapping(dev, handle, size);
1311 __iommu_free_buffer(dev, pages, size);
1312 } 1180 }
1181
1182 if (!dma_get_attr(DMA_ATTR_NO_KERNEL_MAPPING, attrs)) {
1183 unmap_kernel_range((unsigned long)cpu_addr, size);
1184 vunmap(cpu_addr);
1185 }
1186
1187 __iommu_remove_mapping(dev, handle, size);
1188 __iommu_free_buffer(dev, pages, size);
1189}
1190
1191static int arm_iommu_get_sgtable(struct device *dev, struct sg_table *sgt,
1192 void *cpu_addr, dma_addr_t dma_addr,
1193 size_t size, struct dma_attrs *attrs)
1194{
1195 unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
1196 struct page **pages = __iommu_get_pages(cpu_addr, attrs);
1197
1198 if (!pages)
1199 return -ENXIO;
1200
1201 return sg_alloc_table_from_pages(sgt, pages, count, 0, size,
1202 GFP_KERNEL);
1313} 1203}
1314 1204
1315/* 1205/*
@@ -1317,7 +1207,7 @@ void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr,
1317 */ 1207 */
1318static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, 1208static int __map_sg_chunk(struct device *dev, struct scatterlist *sg,
1319 size_t size, dma_addr_t *handle, 1209 size_t size, dma_addr_t *handle,
1320 enum dma_data_direction dir) 1210 enum dma_data_direction dir, struct dma_attrs *attrs)
1321{ 1211{
1322 struct dma_iommu_mapping *mapping = dev->archdata.mapping; 1212 struct dma_iommu_mapping *mapping = dev->archdata.mapping;
1323 dma_addr_t iova, iova_base; 1213 dma_addr_t iova, iova_base;
@@ -1336,7 +1226,8 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg,
1336 phys_addr_t phys = page_to_phys(sg_page(s)); 1226 phys_addr_t phys = page_to_phys(sg_page(s));
1337 unsigned int len = PAGE_ALIGN(s->offset + s->length); 1227 unsigned int len = PAGE_ALIGN(s->offset + s->length);
1338 1228
1339 if (!arch_is_coherent()) 1229 if (!arch_is_coherent() &&
1230 !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
1340 __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir); 1231 __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir);
1341 1232
1342 ret = iommu_map(mapping->domain, iova, phys, len, 0); 1233 ret = iommu_map(mapping->domain, iova, phys, len, 0);
@@ -1383,7 +1274,7 @@ int arm_iommu_map_sg(struct device *dev, struct scatterlist *sg, int nents,
1383 1274
1384 if (s->offset || (size & ~PAGE_MASK) || size + s->length > max) { 1275 if (s->offset || (size & ~PAGE_MASK) || size + s->length > max) {
1385 if (__map_sg_chunk(dev, start, size, &dma->dma_address, 1276 if (__map_sg_chunk(dev, start, size, &dma->dma_address,
1386 dir) < 0) 1277 dir, attrs) < 0)
1387 goto bad_mapping; 1278 goto bad_mapping;
1388 1279
1389 dma->dma_address += offset; 1280 dma->dma_address += offset;
@@ -1396,7 +1287,7 @@ int arm_iommu_map_sg(struct device *dev, struct scatterlist *sg, int nents,
1396 } 1287 }
1397 size += s->length; 1288 size += s->length;
1398 } 1289 }
1399 if (__map_sg_chunk(dev, start, size, &dma->dma_address, dir) < 0) 1290 if (__map_sg_chunk(dev, start, size, &dma->dma_address, dir, attrs) < 0)
1400 goto bad_mapping; 1291 goto bad_mapping;
1401 1292
1402 dma->dma_address += offset; 1293 dma->dma_address += offset;
@@ -1430,7 +1321,8 @@ void arm_iommu_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
1430 if (sg_dma_len(s)) 1321 if (sg_dma_len(s))
1431 __iommu_remove_mapping(dev, sg_dma_address(s), 1322 __iommu_remove_mapping(dev, sg_dma_address(s),
1432 sg_dma_len(s)); 1323 sg_dma_len(s));
1433 if (!arch_is_coherent()) 1324 if (!arch_is_coherent() &&
1325 !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
1434 __dma_page_dev_to_cpu(sg_page(s), s->offset, 1326 __dma_page_dev_to_cpu(sg_page(s), s->offset,
1435 s->length, dir); 1327 s->length, dir);
1436 } 1328 }
@@ -1492,7 +1384,7 @@ static dma_addr_t arm_iommu_map_page(struct device *dev, struct page *page,
1492 dma_addr_t dma_addr; 1384 dma_addr_t dma_addr;
1493 int ret, len = PAGE_ALIGN(size + offset); 1385 int ret, len = PAGE_ALIGN(size + offset);
1494 1386
1495 if (!arch_is_coherent()) 1387 if (!arch_is_coherent() && !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
1496 __dma_page_cpu_to_dev(page, offset, size, dir); 1388 __dma_page_cpu_to_dev(page, offset, size, dir);
1497 1389
1498 dma_addr = __alloc_iova(mapping, len); 1390 dma_addr = __alloc_iova(mapping, len);
@@ -1531,7 +1423,7 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle,
1531 if (!iova) 1423 if (!iova)
1532 return; 1424 return;
1533 1425
1534 if (!arch_is_coherent()) 1426 if (!arch_is_coherent() && !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
1535 __dma_page_dev_to_cpu(page, offset, size, dir); 1427 __dma_page_dev_to_cpu(page, offset, size, dir);
1536 1428
1537 iommu_unmap(mapping->domain, iova, len); 1429 iommu_unmap(mapping->domain, iova, len);
@@ -1571,6 +1463,7 @@ struct dma_map_ops iommu_ops = {
1571 .alloc = arm_iommu_alloc_attrs, 1463 .alloc = arm_iommu_alloc_attrs,
1572 .free = arm_iommu_free_attrs, 1464 .free = arm_iommu_free_attrs,
1573 .mmap = arm_iommu_mmap_attrs, 1465 .mmap = arm_iommu_mmap_attrs,
1466 .get_sgtable = arm_iommu_get_sgtable,
1574 1467
1575 .map_page = arm_iommu_map_page, 1468 .map_page = arm_iommu_map_page,
1576 .unmap_page = arm_iommu_unmap_page, 1469 .unmap_page = arm_iommu_unmap_page,
diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h
index 2e8a1efdf7b8..6776160618ef 100644
--- a/arch/arm/mm/mm.h
+++ b/arch/arm/mm/mm.h
@@ -59,6 +59,9 @@ extern void __flush_dcache_page(struct address_space *mapping, struct page *page
59#define VM_ARM_MTYPE(mt) ((mt) << 20) 59#define VM_ARM_MTYPE(mt) ((mt) << 20)
60#define VM_ARM_MTYPE_MASK (0x1f << 20) 60#define VM_ARM_MTYPE_MASK (0x1f << 20)
61 61
62/* consistent regions used by dma_alloc_attrs() */
63#define VM_ARM_DMA_CONSISTENT 0x20000000
64
62#endif 65#endif
63 66
64#ifdef CONFIG_ZONE_DMA 67#ifdef CONFIG_ZONE_DMA
diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig
index c722f9ce6918..baf9064c0844 100644
--- a/arch/arm/plat-mxc/Kconfig
+++ b/arch/arm/plat-mxc/Kconfig
@@ -47,12 +47,6 @@ config MXC_TZIC
47config MXC_AVIC 47config MXC_AVIC
48 bool 48 bool
49 49
50config MXC_PWM
51 tristate "Enable PWM driver"
52 select HAVE_PWM
53 help
54 Enable support for the i.MX PWM controller(s).
55
56config MXC_DEBUG_BOARD 50config MXC_DEBUG_BOARD
57 bool "Enable MXC debug board(for 3-stack)" 51 bool "Enable MXC debug board(for 3-stack)"
58 help 52 help
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index 63b064b5c1d5..6ac720031150 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -11,7 +11,6 @@ obj-$(CONFIG_MXC_AVIC) += avic.o
11obj-$(CONFIG_IMX_HAVE_IOMUX_V1) += iomux-v1.o 11obj-$(CONFIG_IMX_HAVE_IOMUX_V1) += iomux-v1.o
12obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o 12obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
13obj-$(CONFIG_IRAM_ALLOC) += iram_alloc.o 13obj-$(CONFIG_IRAM_ALLOC) += iram_alloc.o
14obj-$(CONFIG_MXC_PWM) += pwm.o
15obj-$(CONFIG_MXC_ULPI) += ulpi.o 14obj-$(CONFIG_MXC_ULPI) += ulpi.o
16obj-$(CONFIG_MXC_USE_EPIT) += epit.o 15obj-$(CONFIG_MXC_USE_EPIT) += epit.o
17obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o 16obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
diff --git a/arch/arm/plat-pxa/Makefile b/arch/arm/plat-pxa/Makefile
index f302d048392d..af8e484001e5 100644
--- a/arch/arm/plat-pxa/Makefile
+++ b/arch/arm/plat-pxa/Makefile
@@ -8,5 +8,4 @@ obj-$(CONFIG_PXA3xx) += mfp.o
8obj-$(CONFIG_PXA95x) += mfp.o 8obj-$(CONFIG_PXA95x) += mfp.o
9obj-$(CONFIG_ARCH_MMP) += mfp.o 9obj-$(CONFIG_ARCH_MMP) += mfp.o
10 10
11obj-$(CONFIG_HAVE_PWM) += pwm.o
12obj-$(CONFIG_PXA_SSP) += ssp.o 11obj-$(CONFIG_PXA_SSP) += ssp.o
diff --git a/arch/arm/plat-pxa/pwm.c b/arch/arm/plat-pxa/pwm.c
deleted file mode 100644
index ef32686feef9..000000000000
--- a/arch/arm/plat-pxa/pwm.c
+++ /dev/null
@@ -1,304 +0,0 @@
1/*
2 * linux/arch/arm/mach-pxa/pwm.c
3 *
4 * simple driver for PWM (Pulse Width Modulator) controller
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * 2008-02-13 initial version
11 * eric miao <eric.miao@marvell.com>
12 */
13
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/platform_device.h>
17#include <linux/slab.h>
18#include <linux/err.h>
19#include <linux/clk.h>
20#include <linux/io.h>
21#include <linux/pwm.h>
22
23#include <asm/div64.h>
24
25#define HAS_SECONDARY_PWM 0x10
26#define PWM_ID_BASE(d) ((d) & 0xf)
27
28static const struct platform_device_id pwm_id_table[] = {
29 /* PWM has_secondary_pwm? */
30 { "pxa25x-pwm", 0 },
31 { "pxa27x-pwm", 0 | HAS_SECONDARY_PWM },
32 { "pxa168-pwm", 1 },
33 { "pxa910-pwm", 1 },
34 { },
35};
36MODULE_DEVICE_TABLE(platform, pwm_id_table);
37
38/* PWM registers and bits definitions */
39#define PWMCR (0x00)
40#define PWMDCR (0x04)
41#define PWMPCR (0x08)
42
43#define PWMCR_SD (1 << 6)
44#define PWMDCR_FD (1 << 10)
45
46struct pwm_device {
47 struct list_head node;
48 struct pwm_device *secondary;
49 struct platform_device *pdev;
50
51 const char *label;
52 struct clk *clk;
53 int clk_enabled;
54 void __iomem *mmio_base;
55
56 unsigned int use_count;
57 unsigned int pwm_id;
58};
59
60/*
61 * period_ns = 10^9 * (PRESCALE + 1) * (PV + 1) / PWM_CLK_RATE
62 * duty_ns = 10^9 * (PRESCALE + 1) * DC / PWM_CLK_RATE
63 */
64int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
65{
66 unsigned long long c;
67 unsigned long period_cycles, prescale, pv, dc;
68
69 if (pwm == NULL || period_ns == 0 || duty_ns > period_ns)
70 return -EINVAL;
71
72 c = clk_get_rate(pwm->clk);
73 c = c * period_ns;
74 do_div(c, 1000000000);
75 period_cycles = c;
76
77 if (period_cycles < 1)
78 period_cycles = 1;
79 prescale = (period_cycles - 1) / 1024;
80 pv = period_cycles / (prescale + 1) - 1;
81
82 if (prescale > 63)
83 return -EINVAL;
84
85 if (duty_ns == period_ns)
86 dc = PWMDCR_FD;
87 else
88 dc = (pv + 1) * duty_ns / period_ns;
89
90 /* NOTE: the clock to PWM has to be enabled first
91 * before writing to the registers
92 */
93 clk_enable(pwm->clk);
94 __raw_writel(prescale, pwm->mmio_base + PWMCR);
95 __raw_writel(dc, pwm->mmio_base + PWMDCR);
96 __raw_writel(pv, pwm->mmio_base + PWMPCR);
97 clk_disable(pwm->clk);
98
99 return 0;
100}
101EXPORT_SYMBOL(pwm_config);
102
103int pwm_enable(struct pwm_device *pwm)
104{
105 int rc = 0;
106
107 if (!pwm->clk_enabled) {
108 rc = clk_enable(pwm->clk);
109 if (!rc)
110 pwm->clk_enabled = 1;
111 }
112 return rc;
113}
114EXPORT_SYMBOL(pwm_enable);
115
116void pwm_disable(struct pwm_device *pwm)
117{
118 if (pwm->clk_enabled) {
119 clk_disable(pwm->clk);
120 pwm->clk_enabled = 0;
121 }
122}
123EXPORT_SYMBOL(pwm_disable);
124
125static DEFINE_MUTEX(pwm_lock);
126static LIST_HEAD(pwm_list);
127
128struct pwm_device *pwm_request(int pwm_id, const char *label)
129{
130 struct pwm_device *pwm;
131 int found = 0;
132
133 mutex_lock(&pwm_lock);
134
135 list_for_each_entry(pwm, &pwm_list, node) {
136 if (pwm->pwm_id == pwm_id) {
137 found = 1;
138 break;
139 }
140 }
141
142 if (found) {
143 if (pwm->use_count == 0) {
144 pwm->use_count++;
145 pwm->label = label;
146 } else
147 pwm = ERR_PTR(-EBUSY);
148 } else
149 pwm = ERR_PTR(-ENOENT);
150
151 mutex_unlock(&pwm_lock);
152 return pwm;
153}
154EXPORT_SYMBOL(pwm_request);
155
156void pwm_free(struct pwm_device *pwm)
157{
158 mutex_lock(&pwm_lock);
159
160 if (pwm->use_count) {
161 pwm->use_count--;
162 pwm->label = NULL;
163 } else
164 pr_warning("PWM device already freed\n");
165
166 mutex_unlock(&pwm_lock);
167}
168EXPORT_SYMBOL(pwm_free);
169
170static inline void __add_pwm(struct pwm_device *pwm)
171{
172 mutex_lock(&pwm_lock);
173 list_add_tail(&pwm->node, &pwm_list);
174 mutex_unlock(&pwm_lock);
175}
176
177static int __devinit pwm_probe(struct platform_device *pdev)
178{
179 const struct platform_device_id *id = platform_get_device_id(pdev);
180 struct pwm_device *pwm, *secondary = NULL;
181 struct resource *r;
182 int ret = 0;
183
184 pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL);
185 if (pwm == NULL) {
186 dev_err(&pdev->dev, "failed to allocate memory\n");
187 return -ENOMEM;
188 }
189
190 pwm->clk = clk_get(&pdev->dev, NULL);
191 if (IS_ERR(pwm->clk)) {
192 ret = PTR_ERR(pwm->clk);
193 goto err_free;
194 }
195 pwm->clk_enabled = 0;
196
197 pwm->use_count = 0;
198 pwm->pwm_id = PWM_ID_BASE(id->driver_data) + pdev->id;
199 pwm->pdev = pdev;
200
201 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
202 if (r == NULL) {
203 dev_err(&pdev->dev, "no memory resource defined\n");
204 ret = -ENODEV;
205 goto err_free_clk;
206 }
207
208 r = request_mem_region(r->start, resource_size(r), pdev->name);
209 if (r == NULL) {
210 dev_err(&pdev->dev, "failed to request memory resource\n");
211 ret = -EBUSY;
212 goto err_free_clk;
213 }
214
215 pwm->mmio_base = ioremap(r->start, resource_size(r));
216 if (pwm->mmio_base == NULL) {
217 dev_err(&pdev->dev, "failed to ioremap() registers\n");
218 ret = -ENODEV;
219 goto err_free_mem;
220 }
221
222 if (id->driver_data & HAS_SECONDARY_PWM) {
223 secondary = kzalloc(sizeof(struct pwm_device), GFP_KERNEL);
224 if (secondary == NULL) {
225 ret = -ENOMEM;
226 goto err_free_mem;
227 }
228
229 *secondary = *pwm;
230 pwm->secondary = secondary;
231
232 /* registers for the second PWM has offset of 0x10 */
233 secondary->mmio_base = pwm->mmio_base + 0x10;
234 secondary->pwm_id = pdev->id + 2;
235 }
236
237 __add_pwm(pwm);
238 if (secondary)
239 __add_pwm(secondary);
240
241 platform_set_drvdata(pdev, pwm);
242 return 0;
243
244err_free_mem:
245 release_mem_region(r->start, resource_size(r));
246err_free_clk:
247 clk_put(pwm->clk);
248err_free:
249 kfree(pwm);
250 return ret;
251}
252
253static int __devexit pwm_remove(struct platform_device *pdev)
254{
255 struct pwm_device *pwm;
256 struct resource *r;
257
258 pwm = platform_get_drvdata(pdev);
259 if (pwm == NULL)
260 return -ENODEV;
261
262 mutex_lock(&pwm_lock);
263
264 if (pwm->secondary) {
265 list_del(&pwm->secondary->node);
266 kfree(pwm->secondary);
267 }
268
269 list_del(&pwm->node);
270 mutex_unlock(&pwm_lock);
271
272 iounmap(pwm->mmio_base);
273
274 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
275 release_mem_region(r->start, resource_size(r));
276
277 clk_put(pwm->clk);
278 kfree(pwm);
279 return 0;
280}
281
282static struct platform_driver pwm_driver = {
283 .driver = {
284 .name = "pxa25x-pwm",
285 .owner = THIS_MODULE,
286 },
287 .probe = pwm_probe,
288 .remove = __devexit_p(pwm_remove),
289 .id_table = pwm_id_table,
290};
291
292static int __init pwm_init(void)
293{
294 return platform_driver_register(&pwm_driver);
295}
296arch_initcall(pwm_init);
297
298static void __exit pwm_exit(void)
299{
300 platform_driver_unregister(&pwm_driver);
301}
302module_exit(pwm_exit);
303
304MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile
index b78717496677..9e40e8d00740 100644
--- a/arch/arm/plat-samsung/Makefile
+++ b/arch/arm/plat-samsung/Makefile
@@ -59,7 +59,3 @@ obj-$(CONFIG_SAMSUNG_WAKEMASK) += wakeup-mask.o
59 59
60obj-$(CONFIG_S5P_PM) += s5p-pm.o s5p-irq-pm.o 60obj-$(CONFIG_S5P_PM) += s5p-pm.o s5p-irq-pm.o
61obj-$(CONFIG_S5P_SLEEP) += s5p-sleep.o 61obj-$(CONFIG_S5P_SLEEP) += s5p-sleep.o
62
63# PWM support
64
65obj-$(CONFIG_HAVE_PWM) += pwm.o
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index fb9fe00e51a6..f34861920634 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -1003,16 +1003,6 @@ config BFIN_GPTIMERS
1003 To compile this driver as a module, choose M here: the module 1003 To compile this driver as a module, choose M here: the module
1004 will be called gptimers. 1004 will be called gptimers.
1005 1005
1006config HAVE_PWM
1007 tristate "Enable PWM API support"
1008 depends on BFIN_GPTIMERS
1009 help
1010 Enable support for the Pulse Width Modulation framework (as
1011 found in linux/pwm.h).
1012
1013 To compile this driver as a module, choose M here: the module
1014 will be called pwm.
1015
1016choice 1006choice
1017 prompt "Uncached DMA region" 1007 prompt "Uncached DMA region"
1018 default DMA_UNCACHED_1M 1008 default DMA_UNCACHED_1M
diff --git a/arch/blackfin/kernel/Makefile b/arch/blackfin/kernel/Makefile
index 08e6625106be..735f24e07425 100644
--- a/arch/blackfin/kernel/Makefile
+++ b/arch/blackfin/kernel/Makefile
@@ -21,7 +21,6 @@ obj-$(CONFIG_FUNCTION_TRACER) += ftrace-entry.o
21obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o 21obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
22CFLAGS_REMOVE_ftrace.o = -pg 22CFLAGS_REMOVE_ftrace.o = -pg
23 23
24obj-$(CONFIG_HAVE_PWM) += pwm.o
25obj-$(CONFIG_IPIPE) += ipipe.o 24obj-$(CONFIG_IPIPE) += ipipe.o
26obj-$(CONFIG_BFIN_GPTIMERS) += gptimers.o 25obj-$(CONFIG_BFIN_GPTIMERS) += gptimers.o
27obj-$(CONFIG_CPLB_INFO) += cplbinfo.o 26obj-$(CONFIG_CPLB_INFO) += cplbinfo.o
diff --git a/arch/blackfin/kernel/pwm.c b/arch/blackfin/kernel/pwm.c
deleted file mode 100644
index 33f5942733bd..000000000000
--- a/arch/blackfin/kernel/pwm.c
+++ /dev/null
@@ -1,100 +0,0 @@
1/*
2 * Blackfin Pulse Width Modulation (PWM) core
3 *
4 * Copyright (c) 2011 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <linux/module.h>
10#include <linux/pwm.h>
11#include <linux/slab.h>
12
13#include <asm/gptimers.h>
14#include <asm/portmux.h>
15
16struct pwm_device {
17 unsigned id;
18 unsigned short pin;
19};
20
21static const unsigned short pwm_to_gptimer_per[] = {
22 P_TMR0, P_TMR1, P_TMR2, P_TMR3, P_TMR4, P_TMR5,
23 P_TMR6, P_TMR7, P_TMR8, P_TMR9, P_TMR10, P_TMR11,
24};
25
26struct pwm_device *pwm_request(int pwm_id, const char *label)
27{
28 struct pwm_device *pwm;
29 int ret;
30
31 /* XXX: pwm_id really should be unsigned */
32 if (pwm_id < 0)
33 return NULL;
34
35 pwm = kzalloc(sizeof(*pwm), GFP_KERNEL);
36 if (!pwm)
37 return pwm;
38
39 pwm->id = pwm_id;
40 if (pwm->id >= ARRAY_SIZE(pwm_to_gptimer_per))
41 goto err;
42
43 pwm->pin = pwm_to_gptimer_per[pwm->id];
44 ret = peripheral_request(pwm->pin, label);
45 if (ret)
46 goto err;
47
48 return pwm;
49 err:
50 kfree(pwm);
51 return NULL;
52}
53EXPORT_SYMBOL(pwm_request);
54
55void pwm_free(struct pwm_device *pwm)
56{
57 peripheral_free(pwm->pin);
58 kfree(pwm);
59}
60EXPORT_SYMBOL(pwm_free);
61
62int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
63{
64 unsigned long period, duty;
65 unsigned long long val;
66
67 if (duty_ns < 0 || duty_ns > period_ns)
68 return -EINVAL;
69
70 val = (unsigned long long)get_sclk() * period_ns;
71 do_div(val, NSEC_PER_SEC);
72 period = val;
73
74 val = (unsigned long long)period * duty_ns;
75 do_div(val, period_ns);
76 duty = period - val;
77
78 if (duty >= period)
79 duty = period - 1;
80
81 set_gptimer_config(pwm->id, TIMER_MODE_PWM | TIMER_PERIOD_CNT);
82 set_gptimer_pwidth(pwm->id, duty);
83 set_gptimer_period(pwm->id, period);
84
85 return 0;
86}
87EXPORT_SYMBOL(pwm_config);
88
89int pwm_enable(struct pwm_device *pwm)
90{
91 enable_gptimer(pwm->id);
92 return 0;
93}
94EXPORT_SYMBOL(pwm_enable);
95
96void pwm_disable(struct pwm_device *pwm)
97{
98 disable_gptimer(pwm->id);
99}
100EXPORT_SYMBOL(pwm_disable);
diff --git a/arch/frv/include/asm/cpumask.h b/arch/frv/include/asm/cpumask.h
deleted file mode 100644
index d999c20c84d2..000000000000
--- a/arch/frv/include/asm/cpumask.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_CPUMASK_H
2#define _ASM_CPUMASK_H
3
4#include <asm-generic/cpumask.h>
5
6#endif /* _ASM_CPUMASK_H */
diff --git a/arch/hexagon/include/asm/Kbuild b/arch/hexagon/include/asm/Kbuild
index 9aa17f1917ea..06906427c0ac 100644
--- a/arch/hexagon/include/asm/Kbuild
+++ b/arch/hexagon/include/asm/Kbuild
@@ -7,7 +7,6 @@ header-y += user.h
7generic-y += auxvec.h 7generic-y += auxvec.h
8generic-y += bug.h 8generic-y += bug.h
9generic-y += bugs.h 9generic-y += bugs.h
10generic-y += cpumask.h
11generic-y += cputime.h 10generic-y += cputime.h
12generic-y += current.h 11generic-y += current.h
13generic-y += device.h 12generic-y += device.h
@@ -23,7 +22,6 @@ generic-y += ioctl.h
23generic-y += ioctls.h 22generic-y += ioctls.h
24generic-y += iomap.h 23generic-y += iomap.h
25generic-y += ipcbuf.h 24generic-y += ipcbuf.h
26generic-y += ipc.h
27generic-y += irq_regs.h 25generic-y += irq_regs.h
28generic-y += kdebug.h 26generic-y += kdebug.h
29generic-y += kmap_types.h 27generic-y += kmap_types.h
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 8186ec5ea151..310cf5781fad 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -126,6 +126,7 @@ config AUDIT_ARCH
126 126
127menuconfig PARAVIRT_GUEST 127menuconfig PARAVIRT_GUEST
128 bool "Paravirtualized guest support" 128 bool "Paravirtualized guest support"
129 depends on BROKEN
129 help 130 help
130 Say Y here to get to see options related to running Linux under 131 Say Y here to get to see options related to running Linux under
131 various hypervisors. This option alone does not add any kernel code. 132 various hypervisors. This option alone does not add any kernel code.
@@ -138,8 +139,6 @@ config PARAVIRT
138 bool "Enable paravirtualization code" 139 bool "Enable paravirtualization code"
139 depends on PARAVIRT_GUEST 140 depends on PARAVIRT_GUEST
140 default y 141 default y
141 bool
142 default y
143 help 142 help
144 This changes the kernel so it can modify itself when it is run 143 This changes the kernel so it can modify itself when it is run
145 under a hypervisor, potentially improving performance significantly 144 under a hypervisor, potentially improving performance significantly
diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
index 7d9116600a36..6e6fe1839f5d 100644
--- a/arch/ia64/include/asm/atomic.h
+++ b/arch/ia64/include/asm/atomic.h
@@ -17,8 +17,8 @@
17#include <asm/intrinsics.h> 17#include <asm/intrinsics.h>
18 18
19 19
20#define ATOMIC_INIT(i) ((atomic_t) { (i) }) 20#define ATOMIC_INIT(i) { (i) }
21#define ATOMIC64_INIT(i) ((atomic64_t) { (i) }) 21#define ATOMIC64_INIT(i) { (i) }
22 22
23#define atomic_read(v) (*(volatile int *)&(v)->counter) 23#define atomic_read(v) (*(volatile int *)&(v)->counter)
24#define atomic64_read(v) (*(volatile long *)&(v)->counter) 24#define atomic64_read(v) (*(volatile long *)&(v)->counter)
diff --git a/arch/ia64/include/asm/machvec.h b/arch/ia64/include/asm/machvec.h
index 367d299d9938..2d1ad4b11a85 100644
--- a/arch/ia64/include/asm/machvec.h
+++ b/arch/ia64/include/asm/machvec.h
@@ -120,7 +120,7 @@ extern void machvec_tlb_migrate_finish (struct mm_struct *);
120# ifdef MACHVEC_PLATFORM_HEADER 120# ifdef MACHVEC_PLATFORM_HEADER
121# include MACHVEC_PLATFORM_HEADER 121# include MACHVEC_PLATFORM_HEADER
122# else 122# else
123# define platform_name ia64_mv.name 123# define ia64_platform_name ia64_mv.name
124# define platform_setup ia64_mv.setup 124# define platform_setup ia64_mv.setup
125# define platform_cpu_init ia64_mv.cpu_init 125# define platform_cpu_init ia64_mv.cpu_init
126# define platform_irq_init ia64_mv.irq_init 126# define platform_irq_init ia64_mv.irq_init
diff --git a/arch/ia64/include/asm/machvec_dig.h b/arch/ia64/include/asm/machvec_dig.h
index 8a0752f40987..1f7403a2fbee 100644
--- a/arch/ia64/include/asm/machvec_dig.h
+++ b/arch/ia64/include/asm/machvec_dig.h
@@ -10,7 +10,7 @@ extern ia64_mv_setup_t dig_setup;
10 * platform's machvec structure. When compiling a non-generic kernel, 10 * platform's machvec structure. When compiling a non-generic kernel,
11 * the macros are used directly. 11 * the macros are used directly.
12 */ 12 */
13#define platform_name "dig" 13#define ia64_platform_name "dig"
14#define platform_setup dig_setup 14#define platform_setup dig_setup
15 15
16#endif /* _ASM_IA64_MACHVEC_DIG_h */ 16#endif /* _ASM_IA64_MACHVEC_DIG_h */
diff --git a/arch/ia64/include/asm/machvec_dig_vtd.h b/arch/ia64/include/asm/machvec_dig_vtd.h
index 6ab1de5c45ef..44308b4c3f6e 100644
--- a/arch/ia64/include/asm/machvec_dig_vtd.h
+++ b/arch/ia64/include/asm/machvec_dig_vtd.h
@@ -11,7 +11,7 @@ extern ia64_mv_dma_init pci_iommu_alloc;
11 * platform's machvec structure. When compiling a non-generic kernel, 11 * platform's machvec structure. When compiling a non-generic kernel,
12 * the macros are used directly. 12 * the macros are used directly.
13 */ 13 */
14#define platform_name "dig_vtd" 14#define ia64_platform_name "dig_vtd"
15#define platform_setup dig_setup 15#define platform_setup dig_setup
16#define platform_dma_init pci_iommu_alloc 16#define platform_dma_init pci_iommu_alloc
17 17
diff --git a/arch/ia64/include/asm/machvec_hpsim.h b/arch/ia64/include/asm/machvec_hpsim.h
index cf72fc87fdfe..e75711279366 100644
--- a/arch/ia64/include/asm/machvec_hpsim.h
+++ b/arch/ia64/include/asm/machvec_hpsim.h
@@ -11,7 +11,7 @@ extern ia64_mv_irq_init_t hpsim_irq_init;
11 * platform's machvec structure. When compiling a non-generic kernel, 11 * platform's machvec structure. When compiling a non-generic kernel,
12 * the macros are used directly. 12 * the macros are used directly.
13 */ 13 */
14#define platform_name "hpsim" 14#define ia64_platform_name "hpsim"
15#define platform_setup hpsim_setup 15#define platform_setup hpsim_setup
16#define platform_irq_init hpsim_irq_init 16#define platform_irq_init hpsim_irq_init
17 17
diff --git a/arch/ia64/include/asm/machvec_hpzx1.h b/arch/ia64/include/asm/machvec_hpzx1.h
index 3bd83d78a412..c74d3159e9eb 100644
--- a/arch/ia64/include/asm/machvec_hpzx1.h
+++ b/arch/ia64/include/asm/machvec_hpzx1.h
@@ -11,7 +11,7 @@ extern ia64_mv_dma_init sba_dma_init;
11 * platform's machvec structure. When compiling a non-generic kernel, 11 * platform's machvec structure. When compiling a non-generic kernel,
12 * the macros are used directly. 12 * the macros are used directly.
13 */ 13 */
14#define platform_name "hpzx1" 14#define ia64_platform_name "hpzx1"
15#define platform_setup dig_setup 15#define platform_setup dig_setup
16#define platform_dma_init sba_dma_init 16#define platform_dma_init sba_dma_init
17 17
diff --git a/arch/ia64/include/asm/machvec_hpzx1_swiotlb.h b/arch/ia64/include/asm/machvec_hpzx1_swiotlb.h
index 1091ac39740c..906ef6210774 100644
--- a/arch/ia64/include/asm/machvec_hpzx1_swiotlb.h
+++ b/arch/ia64/include/asm/machvec_hpzx1_swiotlb.h
@@ -11,7 +11,7 @@ extern ia64_mv_dma_get_ops hwsw_dma_get_ops;
11 * platform's machvec structure. When compiling a non-generic kernel, 11 * platform's machvec structure. When compiling a non-generic kernel,
12 * the macros are used directly. 12 * the macros are used directly.
13 */ 13 */
14#define platform_name "hpzx1_swiotlb" 14#define ia64_platform_name "hpzx1_swiotlb"
15#define platform_setup dig_setup 15#define platform_setup dig_setup
16#define platform_dma_init machvec_noop 16#define platform_dma_init machvec_noop
17#define platform_dma_get_ops hwsw_dma_get_ops 17#define platform_dma_get_ops hwsw_dma_get_ops
diff --git a/arch/ia64/include/asm/machvec_sn2.h b/arch/ia64/include/asm/machvec_sn2.h
index f061a30aac42..ece9fa85be88 100644
--- a/arch/ia64/include/asm/machvec_sn2.h
+++ b/arch/ia64/include/asm/machvec_sn2.h
@@ -71,7 +71,7 @@ extern ia64_mv_pci_fixup_bus_t sn_pci_fixup_bus;
71 * platform's machvec structure. When compiling a non-generic kernel, 71 * platform's machvec structure. When compiling a non-generic kernel,
72 * the macros are used directly. 72 * the macros are used directly.
73 */ 73 */
74#define platform_name "sn2" 74#define ia64_platform_name "sn2"
75#define platform_setup sn_setup 75#define platform_setup sn_setup
76#define platform_cpu_init sn_cpu_init 76#define platform_cpu_init sn_cpu_init
77#define platform_irq_init sn_irq_init 77#define platform_irq_init sn_irq_init
diff --git a/arch/ia64/include/asm/machvec_uv.h b/arch/ia64/include/asm/machvec_uv.h
index 2931447f3813..2c50853f35ac 100644
--- a/arch/ia64/include/asm/machvec_uv.h
+++ b/arch/ia64/include/asm/machvec_uv.h
@@ -20,7 +20,7 @@ extern ia64_mv_setup_t uv_setup;
20 * platform's machvec structure. When compiling a non-generic kernel, 20 * platform's machvec structure. When compiling a non-generic kernel,
21 * the macros are used directly. 21 * the macros are used directly.
22 */ 22 */
23#define platform_name "uv" 23#define ia64_platform_name "uv"
24#define platform_setup uv_setup 24#define platform_setup uv_setup
25 25
26#endif /* _ASM_IA64_MACHVEC_UV_H */ 26#endif /* _ASM_IA64_MACHVEC_UV_H */
diff --git a/arch/ia64/include/asm/machvec_xen.h b/arch/ia64/include/asm/machvec_xen.h
index 55f9228056cd..8b8bd0eb3923 100644
--- a/arch/ia64/include/asm/machvec_xen.h
+++ b/arch/ia64/include/asm/machvec_xen.h
@@ -13,7 +13,7 @@ extern ia64_mv_send_ipi_t xen_platform_send_ipi;
13 * platform's machvec structure. When compiling a non-generic kernel, 13 * platform's machvec structure. When compiling a non-generic kernel,
14 * the macros are used directly. 14 * the macros are used directly.
15 */ 15 */
16#define platform_name "xen" 16#define ia64_platform_name "xen"
17#define platform_setup dig_setup 17#define platform_setup dig_setup
18#define platform_cpu_init xen_cpu_init 18#define platform_cpu_init xen_cpu_init
19#define platform_irq_init xen_irq_init 19#define platform_irq_init xen_irq_init
diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
index 832dd3789e9d..944152a50912 100644
--- a/arch/ia64/include/asm/processor.h
+++ b/arch/ia64/include/asm/processor.h
@@ -719,7 +719,7 @@ enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_FORCE_MWAIT,
719 719
720void default_idle(void); 720void default_idle(void);
721 721
722#define ia64_platform_is(x) (strcmp(x, platform_name) == 0) 722#define ia64_platform_is(x) (strcmp(x, ia64_platform_name) == 0)
723 723
724#endif /* !__ASSEMBLY__ */ 724#endif /* !__ASSEMBLY__ */
725 725
diff --git a/arch/ia64/kvm/Kconfig b/arch/ia64/kvm/Kconfig
index df5351e3eed7..e7947528aee6 100644
--- a/arch/ia64/kvm/Kconfig
+++ b/arch/ia64/kvm/Kconfig
@@ -23,6 +23,7 @@ config KVM
23 depends on HAVE_KVM && MODULES && EXPERIMENTAL 23 depends on HAVE_KVM && MODULES && EXPERIMENTAL
24 # for device assignment: 24 # for device assignment:
25 depends on PCI 25 depends on PCI
26 depends on BROKEN
26 select PREEMPT_NOTIFIERS 27 select PREEMPT_NOTIFIERS
27 select ANON_INODES 28 select ANON_INODES
28 select HAVE_KVM_IRQCHIP 29 select HAVE_KVM_IRQCHIP
diff --git a/arch/ia64/pci/fixup.c b/arch/ia64/pci/fixup.c
index f5959c0c1810..eab28e314022 100644
--- a/arch/ia64/pci/fixup.c
+++ b/arch/ia64/pci/fixup.c
@@ -30,8 +30,8 @@ static void __devinit pci_fixup_video(struct pci_dev *pdev)
30 struct pci_bus *bus; 30 struct pci_bus *bus;
31 u16 config; 31 u16 config;
32 32
33 if ((strcmp(platform_name, "dig") != 0) 33 if ((strcmp(ia64_platform_name, "dig") != 0)
34 && (strcmp(platform_name, "hpzx1") != 0)) 34 && (strcmp(ia64_platform_name, "hpzx1") != 0))
35 return; 35 return;
36 /* Maybe, this machine supports legacy memory map. */ 36 /* Maybe, this machine supports legacy memory map. */
37 37
diff --git a/arch/mips/Kbuild.platforms b/arch/mips/Kbuild.platforms
index 5ce8029f558b..d64786d5e2f3 100644
--- a/arch/mips/Kbuild.platforms
+++ b/arch/mips/Kbuild.platforms
@@ -14,6 +14,7 @@ platforms += jz4740
14platforms += lantiq 14platforms += lantiq
15platforms += lasat 15platforms += lasat
16platforms += loongson 16platforms += loongson
17platforms += loongson1
17platforms += mipssim 18platforms += mipssim
18platforms += mti-malta 19platforms += mti-malta
19platforms += netlogic 20platforms += netlogic
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 2d56cd5af336..e3efc06e6409 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -211,6 +211,7 @@ config MACH_JZ4740
211 select SYS_HAS_CPU_MIPS32_R1 211 select SYS_HAS_CPU_MIPS32_R1
212 select SYS_SUPPORTS_32BIT_KERNEL 212 select SYS_SUPPORTS_32BIT_KERNEL
213 select SYS_SUPPORTS_LITTLE_ENDIAN 213 select SYS_SUPPORTS_LITTLE_ENDIAN
214 select SYS_SUPPORTS_ZBOOT_UART16550
214 select DMA_NONCOHERENT 215 select DMA_NONCOHERENT
215 select IRQ_CPU 216 select IRQ_CPU
216 select GENERIC_GPIO 217 select GENERIC_GPIO
@@ -266,6 +267,16 @@ config MACH_LOONGSON
266 Chinese Academy of Sciences (CAS) in the People's Republic 267 Chinese Academy of Sciences (CAS) in the People's Republic
267 of China. The chief architect is Professor Weiwu Hu. 268 of China. The chief architect is Professor Weiwu Hu.
268 269
270config MACH_LOONGSON1
271 bool "Loongson 1 family of machines"
272 select SYS_SUPPORTS_ZBOOT
273 help
274 This enables support for the Loongson 1 based machines.
275
276 Loongson 1 is a family of 32-bit MIPS-compatible SoCs developed by
277 the ICT (Institute of Computing Technology) and the Chinese Academy
278 of Sciences.
279
269config MIPS_MALTA 280config MIPS_MALTA
270 bool "MIPS Malta board" 281 bool "MIPS Malta board"
271 select ARCH_MAY_HAVE_PC_FDC 282 select ARCH_MAY_HAVE_PC_FDC
@@ -789,6 +800,8 @@ config NLM_XLR_BOARD
789 select ZONE_DMA if 64BIT 800 select ZONE_DMA if 64BIT
790 select SYNC_R4K 801 select SYNC_R4K
791 select SYS_HAS_EARLY_PRINTK 802 select SYS_HAS_EARLY_PRINTK
803 select USB_ARCH_HAS_OHCI if USB_SUPPORT
804 select USB_ARCH_HAS_EHCI if USB_SUPPORT
792 help 805 help
793 Support for systems based on Netlogic XLR and XLS processors. 806 Support for systems based on Netlogic XLR and XLS processors.
794 Say Y here if you have a XLR or XLS based board. 807 Say Y here if you have a XLR or XLS based board.
@@ -801,7 +814,6 @@ config NLM_XLP_BOARD
801 select SYS_HAS_CPU_XLP 814 select SYS_HAS_CPU_XLP
802 select SYS_SUPPORTS_SMP 815 select SYS_SUPPORTS_SMP
803 select HW_HAS_PCI 816 select HW_HAS_PCI
804 select SWAP_IO_SPACE
805 select SYS_SUPPORTS_32BIT_KERNEL 817 select SYS_SUPPORTS_32BIT_KERNEL
806 select SYS_SUPPORTS_64BIT_KERNEL 818 select SYS_SUPPORTS_64BIT_KERNEL
807 select 64BIT_PHYS_ADDR 819 select 64BIT_PHYS_ADDR
@@ -838,6 +850,7 @@ source "arch/mips/txx9/Kconfig"
838source "arch/mips/vr41xx/Kconfig" 850source "arch/mips/vr41xx/Kconfig"
839source "arch/mips/cavium-octeon/Kconfig" 851source "arch/mips/cavium-octeon/Kconfig"
840source "arch/mips/loongson/Kconfig" 852source "arch/mips/loongson/Kconfig"
853source "arch/mips/loongson1/Kconfig"
841source "arch/mips/netlogic/Kconfig" 854source "arch/mips/netlogic/Kconfig"
842 855
843endmenu 856endmenu
@@ -1219,6 +1232,14 @@ config CPU_LOONGSON2F
1219 have a similar programming interface with FPGA northbridge used in 1232 have a similar programming interface with FPGA northbridge used in
1220 Loongson2E. 1233 Loongson2E.
1221 1234
1235config CPU_LOONGSON1B
1236 bool "Loongson 1B"
1237 depends on SYS_HAS_CPU_LOONGSON1B
1238 select CPU_LOONGSON1
1239 help
1240 The Loongson 1B is a 32-bit SoC, which implements the MIPS32
1241 release 2 instruction set.
1242
1222config CPU_MIPS32_R1 1243config CPU_MIPS32_R1
1223 bool "MIPS32 Release 1" 1244 bool "MIPS32 Release 1"
1224 depends on SYS_HAS_CPU_MIPS32_R1 1245 depends on SYS_HAS_CPU_MIPS32_R1
@@ -1434,6 +1455,8 @@ config CPU_CAVIUM_OCTEON
1434 select WEAK_ORDERING 1455 select WEAK_ORDERING
1435 select CPU_SUPPORTS_HIGHMEM 1456 select CPU_SUPPORTS_HIGHMEM
1436 select CPU_SUPPORTS_HUGEPAGES 1457 select CPU_SUPPORTS_HUGEPAGES
1458 select LIBFDT
1459 select USE_OF
1437 help 1460 help
1438 The Cavium Octeon processor is a highly integrated chip containing 1461 The Cavium Octeon processor is a highly integrated chip containing
1439 many ethernet hardware widgets for networking tasks. The processor 1462 many ethernet hardware widgets for networking tasks. The processor
@@ -1546,6 +1569,14 @@ config CPU_LOONGSON2
1546 select CPU_SUPPORTS_64BIT_KERNEL 1569 select CPU_SUPPORTS_64BIT_KERNEL
1547 select CPU_SUPPORTS_HIGHMEM 1570 select CPU_SUPPORTS_HIGHMEM
1548 1571
1572config CPU_LOONGSON1
1573 bool
1574 select CPU_MIPS32
1575 select CPU_MIPSR2
1576 select CPU_HAS_PREFETCH
1577 select CPU_SUPPORTS_32BIT_KERNEL
1578 select CPU_SUPPORTS_HIGHMEM
1579
1549config CPU_BMIPS 1580config CPU_BMIPS
1550 bool 1581 bool
1551 select CPU_MIPS32 1582 select CPU_MIPS32
@@ -1564,6 +1595,9 @@ config SYS_HAS_CPU_LOONGSON2F
1564 select CPU_SUPPORTS_ADDRWINCFG if 64BIT 1595 select CPU_SUPPORTS_ADDRWINCFG if 64BIT
1565 select CPU_SUPPORTS_UNCACHED_ACCELERATED 1596 select CPU_SUPPORTS_UNCACHED_ACCELERATED
1566 1597
1598config SYS_HAS_CPU_LOONGSON1B
1599 bool
1600
1567config SYS_HAS_CPU_MIPS32_R1 1601config SYS_HAS_CPU_MIPS32_R1
1568 bool 1602 bool
1569 1603
@@ -2368,6 +2402,8 @@ config PCI_DOMAINS
2368 2402
2369source "drivers/pci/Kconfig" 2403source "drivers/pci/Kconfig"
2370 2404
2405source "drivers/pci/pcie/Kconfig"
2406
2371# 2407#
2372# ISA support is now enabled via select. Too many systems still have the one 2408# ISA support is now enabled via select. Too many systems still have the one
2373# or other ISA chip on the board that users don't know about so don't expect 2409# or other ISA chip on the board that users don't know about so don't expect
diff --git a/arch/mips/alchemy/board-mtx1.c b/arch/mips/alchemy/board-mtx1.c
index 295f1a95f745..99969484c475 100644
--- a/arch/mips/alchemy/board-mtx1.c
+++ b/arch/mips/alchemy/board-mtx1.c
@@ -81,10 +81,10 @@ static void mtx1_power_off(void)
81 81
82void __init board_setup(void) 82void __init board_setup(void)
83{ 83{
84#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 84#if IS_ENABLED(CONFIG_USB_OHCI_HCD)
85 /* Enable USB power switch */ 85 /* Enable USB power switch */
86 alchemy_gpio_direction_output(204, 0); 86 alchemy_gpio_direction_output(204, 0);
87#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */ 87#endif /* IS_ENABLED(CONFIG_USB_OHCI_HCD) */
88 88
89 /* Initialize sys_pinfunc */ 89 /* Initialize sys_pinfunc */
90 au_writel(SYS_PF_NI2, SYS_PINFUNC); 90 au_writel(SYS_PF_NI2, SYS_PINFUNC);
diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c
index 95cb9113b12c..c0f3ce6dcb56 100644
--- a/arch/mips/alchemy/common/platform.c
+++ b/arch/mips/alchemy/common/platform.c
@@ -334,13 +334,12 @@ static void __init alchemy_setup_macs(int ctype)
334 if (alchemy_get_macs(ctype) < 1) 334 if (alchemy_get_macs(ctype) < 1)
335 return; 335 return;
336 336
337 macres = kmalloc(sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL); 337 macres = kmemdup(au1xxx_eth0_resources[ctype],
338 sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL);
338 if (!macres) { 339 if (!macres) {
339 printk(KERN_INFO "Alchemy: no memory for MAC0 resources\n"); 340 printk(KERN_INFO "Alchemy: no memory for MAC0 resources\n");
340 return; 341 return;
341 } 342 }
342 memcpy(macres, au1xxx_eth0_resources[ctype],
343 sizeof(struct resource) * MAC_RES_COUNT);
344 au1xxx_eth0_device.resource = macres; 343 au1xxx_eth0_device.resource = macres;
345 344
346 i = prom_get_ethernet_addr(ethaddr); 345 i = prom_get_ethernet_addr(ethaddr);
@@ -356,13 +355,12 @@ static void __init alchemy_setup_macs(int ctype)
356 if (alchemy_get_macs(ctype) < 2) 355 if (alchemy_get_macs(ctype) < 2)
357 return; 356 return;
358 357
359 macres = kmalloc(sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL); 358 macres = kmemdup(au1xxx_eth1_resources[ctype],
359 sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL);
360 if (!macres) { 360 if (!macres) {
361 printk(KERN_INFO "Alchemy: no memory for MAC1 resources\n"); 361 printk(KERN_INFO "Alchemy: no memory for MAC1 resources\n");
362 return; 362 return;
363 } 363 }
364 memcpy(macres, au1xxx_eth1_resources[ctype],
365 sizeof(struct resource) * MAC_RES_COUNT);
366 au1xxx_eth1_device.resource = macres; 364 au1xxx_eth1_device.resource = macres;
367 365
368 ethaddr[5] += 1; /* next addr for 2nd MAC */ 366 ethaddr[5] += 1; /* next addr for 2nd MAC */
diff --git a/arch/mips/alchemy/devboards/Makefile b/arch/mips/alchemy/devboards/Makefile
index 3c37fb303364..c9e747dd9fc2 100644
--- a/arch/mips/alchemy/devboards/Makefile
+++ b/arch/mips/alchemy/devboards/Makefile
@@ -2,7 +2,7 @@
2# Alchemy Develboards 2# Alchemy Develboards
3# 3#
4 4
5obj-y += prom.o bcsr.o platform.o 5obj-y += bcsr.o platform.o
6obj-$(CONFIG_PM) += pm.o 6obj-$(CONFIG_PM) += pm.o
7obj-$(CONFIG_MIPS_PB1100) += pb1100.o 7obj-$(CONFIG_MIPS_PB1100) += pb1100.o
8obj-$(CONFIG_MIPS_PB1500) += pb1500.o 8obj-$(CONFIG_MIPS_PB1500) += pb1500.o
diff --git a/arch/mips/alchemy/devboards/bcsr.c b/arch/mips/alchemy/devboards/bcsr.c
index 1e83ce2e1147..f2039ef2c293 100644
--- a/arch/mips/alchemy/devboards/bcsr.c
+++ b/arch/mips/alchemy/devboards/bcsr.c
@@ -90,10 +90,7 @@ static void bcsr_csc_handler(unsigned int irq, struct irq_desc *d)
90 unsigned short bisr = __raw_readw(bcsr_virt + BCSR_REG_INTSTAT); 90 unsigned short bisr = __raw_readw(bcsr_virt + BCSR_REG_INTSTAT);
91 91
92 disable_irq_nosync(irq); 92 disable_irq_nosync(irq);
93 93 generic_handle_irq(bcsr_csc_base + __ffs(bisr));
94 for ( ; bisr; bisr &= bisr - 1)
95 generic_handle_irq(bcsr_csc_base + __ffs(bisr));
96
97 enable_irq(irq); 94 enable_irq(irq);
98} 95}
99 96
diff --git a/arch/mips/alchemy/devboards/pb1100.c b/arch/mips/alchemy/devboards/pb1100.c
index cff50d05ddd4..78c77a44a317 100644
--- a/arch/mips/alchemy/devboards/pb1100.c
+++ b/arch/mips/alchemy/devboards/pb1100.c
@@ -46,7 +46,7 @@ void __init board_setup(void)
46 alchemy_gpio1_input_enable(); 46 alchemy_gpio1_input_enable();
47 udelay(100); 47 udelay(100);
48 48
49#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 49#if IS_ENABLED(CONFIG_USB_OHCI_HCD)
50 { 50 {
51 u32 pin_func, sys_freqctrl, sys_clksrc; 51 u32 pin_func, sys_freqctrl, sys_clksrc;
52 52
@@ -93,7 +93,7 @@ void __init board_setup(void)
93 pin_func |= SYS_PF_USB; 93 pin_func |= SYS_PF_USB;
94 au_writel(pin_func, SYS_PINFUNC); 94 au_writel(pin_func, SYS_PINFUNC);
95 } 95 }
96#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */ 96#endif /* IS_ENABLED(CONFIG_USB_OHCI_HCD) */
97 97
98 /* Enable sys bus clock divider when IDLE state or no bus activity. */ 98 /* Enable sys bus clock divider when IDLE state or no bus activity. */
99 au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL); 99 au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL);
diff --git a/arch/mips/alchemy/devboards/pb1500.c b/arch/mips/alchemy/devboards/pb1500.c
index e7b807b3ec51..232fee942000 100644
--- a/arch/mips/alchemy/devboards/pb1500.c
+++ b/arch/mips/alchemy/devboards/pb1500.c
@@ -53,7 +53,7 @@ void __init board_setup(void)
53 alchemy_gpio_direction_input(201); 53 alchemy_gpio_direction_input(201);
54 alchemy_gpio_direction_input(203); 54 alchemy_gpio_direction_input(203);
55 55
56#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 56#if IS_ENABLED(CONFIG_USB_OHCI_HCD)
57 57
58 /* Zero and disable FREQ2 */ 58 /* Zero and disable FREQ2 */
59 sys_freqctrl = au_readl(SYS_FREQCTRL0); 59 sys_freqctrl = au_readl(SYS_FREQCTRL0);
@@ -87,7 +87,7 @@ void __init board_setup(void)
87 /* 2nd USB port is USB host */ 87 /* 2nd USB port is USB host */
88 pin_func |= SYS_PF_USB; 88 pin_func |= SYS_PF_USB;
89 au_writel(pin_func, SYS_PINFUNC); 89 au_writel(pin_func, SYS_PINFUNC);
90#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */ 90#endif /* IS_ENABLED(CONFIG_USB_OHCI_HCD) */
91 91
92#ifdef CONFIG_PCI 92#ifdef CONFIG_PCI
93 { 93 {
diff --git a/arch/mips/alchemy/devboards/platform.c b/arch/mips/alchemy/devboards/platform.c
index 621f70afb63a..f39042e99d0d 100644
--- a/arch/mips/alchemy/devboards/platform.c
+++ b/arch/mips/alchemy/devboards/platform.c
@@ -10,9 +10,39 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/pm.h> 11#include <linux/pm.h>
12 12
13#include <asm/bootinfo.h>
13#include <asm/reboot.h> 14#include <asm/reboot.h>
15#include <asm/mach-au1x00/au1000.h>
14#include <asm/mach-db1x00/bcsr.h> 16#include <asm/mach-db1x00/bcsr.h>
15 17
18#include <prom.h>
19
20void __init prom_init(void)
21{
22 unsigned char *memsize_str;
23 unsigned long memsize;
24
25 prom_argc = (int)fw_arg0;
26 prom_argv = (char **)fw_arg1;
27 prom_envp = (char **)fw_arg2;
28
29 prom_init_cmdline();
30 memsize_str = prom_getenv("memsize");
31 if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
32 memsize = 64 << 20; /* all devboards have at least 64MB RAM */
33
34 add_memory_region(0, memsize, BOOT_MEM_RAM);
35}
36
37void prom_putchar(unsigned char c)
38{
39#ifdef CONFIG_MIPS_DB1300
40 alchemy_uart_putchar(AU1300_UART2_PHYS_ADDR, c);
41#else
42 alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
43#endif
44}
45
16 46
17static struct platform_device db1x00_rtc_dev = { 47static struct platform_device db1x00_rtc_dev = {
18 .name = "rtc-au1xxx", 48 .name = "rtc-au1xxx",
diff --git a/arch/mips/alchemy/devboards/prom.c b/arch/mips/alchemy/devboards/prom.c
deleted file mode 100644
index 93a22107cc41..000000000000
--- a/arch/mips/alchemy/devboards/prom.c
+++ /dev/null
@@ -1,69 +0,0 @@
1/*
2 * Common code used by all Alchemy develboards.
3 *
4 * Extracted from files which had this to say:
5 *
6 * Copyright 2000, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
20 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 */
29
30#include <linux/init.h>
31#include <linux/kernel.h>
32#include <asm/bootinfo.h>
33#include <asm/mach-au1x00/au1000.h>
34#include <prom.h>
35
36#if defined(CONFIG_MIPS_DB1000) || \
37 defined(CONFIG_MIPS_PB1100) || \
38 defined(CONFIG_MIPS_PB1500)
39#define ALCHEMY_BOARD_DEFAULT_MEMSIZE 0x04000000
40
41#else /* Au1550/Au1200-based develboards */
42#define ALCHEMY_BOARD_DEFAULT_MEMSIZE 0x08000000
43#endif
44
45void __init prom_init(void)
46{
47 unsigned char *memsize_str;
48 unsigned long memsize;
49
50 prom_argc = (int)fw_arg0;
51 prom_argv = (char **)fw_arg1;
52 prom_envp = (char **)fw_arg2;
53
54 prom_init_cmdline();
55 memsize_str = prom_getenv("memsize");
56 if (!memsize_str || strict_strtoul(memsize_str, 0, &memsize))
57 memsize = ALCHEMY_BOARD_DEFAULT_MEMSIZE;
58
59 add_memory_region(0, memsize, BOOT_MEM_RAM);
60}
61
62void prom_putchar(unsigned char c)
63{
64#ifdef CONFIG_MIPS_DB1300
65 alchemy_uart_putchar(AU1300_UART2_PHYS_ADDR, c);
66#else
67 alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
68#endif
69}
diff --git a/arch/mips/bcm63xx/Kconfig b/arch/mips/bcm63xx/Kconfig
index 6b1b9ad8d857..d03e8799d1cf 100644
--- a/arch/mips/bcm63xx/Kconfig
+++ b/arch/mips/bcm63xx/Kconfig
@@ -1,6 +1,10 @@
1menu "CPU support" 1menu "CPU support"
2 depends on BCM63XX 2 depends on BCM63XX
3 3
4config BCM63XX_CPU_6328
5 bool "support 6328 CPU"
6 select HW_HAS_PCI
7
4config BCM63XX_CPU_6338 8config BCM63XX_CPU_6338
5 bool "support 6338 CPU" 9 bool "support 6338 CPU"
6 select HW_HAS_PCI 10 select HW_HAS_PCI
diff --git a/arch/mips/bcm63xx/Makefile b/arch/mips/bcm63xx/Makefile
index 6dfdc69928ac..833af72c852a 100644
--- a/arch/mips/bcm63xx/Makefile
+++ b/arch/mips/bcm63xx/Makefile
@@ -1,5 +1,6 @@
1obj-y += clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \ 1obj-y += clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \
2 dev-dsp.o dev-enet.o dev-pcmcia.o dev-uart.o dev-wdt.o 2 dev-dsp.o dev-enet.o dev-flash.o dev-pcmcia.o dev-rng.o \
3 dev-spi.o dev-uart.o dev-wdt.o
3obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 4obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
4 5
5obj-y += boards/ 6obj-y += boards/
diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
index 2f1773f3fb7a..feb05258a4d1 100644
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -11,9 +11,6 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/string.h> 12#include <linux/string.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/mtd/mtd.h>
15#include <linux/mtd/partitions.h>
16#include <linux/mtd/physmap.h>
17#include <linux/ssb/ssb.h> 14#include <linux/ssb/ssb.h>
18#include <asm/addrspace.h> 15#include <asm/addrspace.h>
19#include <bcm63xx_board.h> 16#include <bcm63xx_board.h>
@@ -24,7 +21,9 @@
24#include <bcm63xx_dev_pci.h> 21#include <bcm63xx_dev_pci.h>
25#include <bcm63xx_dev_enet.h> 22#include <bcm63xx_dev_enet.h>
26#include <bcm63xx_dev_dsp.h> 23#include <bcm63xx_dev_dsp.h>
24#include <bcm63xx_dev_flash.h>
27#include <bcm63xx_dev_pcmcia.h> 25#include <bcm63xx_dev_pcmcia.h>
26#include <bcm63xx_dev_spi.h>
28#include <board_bcm963xx.h> 27#include <board_bcm963xx.h>
29 28
30#define PFX "board_bcm963xx: " 29#define PFX "board_bcm963xx: "
@@ -34,6 +33,48 @@ static unsigned int mac_addr_used;
34static struct board_info board; 33static struct board_info board;
35 34
36/* 35/*
36 * known 6328 boards
37 */
38#ifdef CONFIG_BCM63XX_CPU_6328
39static struct board_info __initdata board_96328avng = {
40 .name = "96328avng",
41 .expected_cpu_id = 0x6328,
42
43 .has_uart0 = 1,
44 .has_pci = 1,
45
46 .leds = {
47 {
48 .name = "96328avng::ppp-fail",
49 .gpio = 2,
50 .active_low = 1,
51 },
52 {
53 .name = "96328avng::power",
54 .gpio = 4,
55 .active_low = 1,
56 .default_trigger = "default-on",
57 },
58 {
59 .name = "96328avng::power-fail",
60 .gpio = 8,
61 .active_low = 1,
62 },
63 {
64 .name = "96328avng::wps",
65 .gpio = 9,
66 .active_low = 1,
67 },
68 {
69 .name = "96328avng::ppp",
70 .gpio = 11,
71 .active_low = 1,
72 },
73 },
74};
75#endif
76
77/*
37 * known 6338 boards 78 * known 6338 boards
38 */ 79 */
39#ifdef CONFIG_BCM63XX_CPU_6338 80#ifdef CONFIG_BCM63XX_CPU_6338
@@ -592,6 +633,9 @@ static struct board_info __initdata board_DWVS0 = {
592 * all boards 633 * all boards
593 */ 634 */
594static const struct board_info __initdata *bcm963xx_boards[] = { 635static const struct board_info __initdata *bcm963xx_boards[] = {
636#ifdef CONFIG_BCM63XX_CPU_6328
637 &board_96328avng,
638#endif
595#ifdef CONFIG_BCM63XX_CPU_6338 639#ifdef CONFIG_BCM63XX_CPU_6338
596 &board_96338gw, 640 &board_96338gw,
597 &board_96338w, 641 &board_96338w,
@@ -709,9 +753,15 @@ void __init board_prom_init(void)
709 char cfe_version[32]; 753 char cfe_version[32];
710 u32 val; 754 u32 val;
711 755
712 /* read base address of boot chip select (0) */ 756 /* read base address of boot chip select (0)
713 val = bcm_mpi_readl(MPI_CSBASE_REG(0)); 757 * 6328 does not have MPI but boots from a fixed address
714 val &= MPI_CSBASE_BASE_MASK; 758 */
759 if (BCMCPU_IS_6328())
760 val = 0x18000000;
761 else {
762 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
763 val &= MPI_CSBASE_BASE_MASK;
764 }
715 boot_addr = (u8 *)KSEG1ADDR(val); 765 boot_addr = (u8 *)KSEG1ADDR(val);
716 766
717 /* dump cfe version */ 767 /* dump cfe version */
@@ -808,40 +858,6 @@ void __init board_setup(void)
808 panic("unexpected CPU for bcm963xx board"); 858 panic("unexpected CPU for bcm963xx board");
809} 859}
810 860
811static struct mtd_partition mtd_partitions[] = {
812 {
813 .name = "cfe",
814 .offset = 0x0,
815 .size = 0x40000,
816 }
817};
818
819static const char *bcm63xx_part_types[] = { "bcm63xxpart", NULL };
820
821static struct physmap_flash_data flash_data = {
822 .width = 2,
823 .nr_parts = ARRAY_SIZE(mtd_partitions),
824 .parts = mtd_partitions,
825 .part_probe_types = bcm63xx_part_types,
826};
827
828static struct resource mtd_resources[] = {
829 {
830 .start = 0, /* filled at runtime */
831 .end = 0, /* filled at runtime */
832 .flags = IORESOURCE_MEM,
833 }
834};
835
836static struct platform_device mtd_dev = {
837 .name = "physmap-flash",
838 .resource = mtd_resources,
839 .num_resources = ARRAY_SIZE(mtd_resources),
840 .dev = {
841 .platform_data = &flash_data,
842 },
843};
844
845static struct gpio_led_platform_data bcm63xx_led_data; 861static struct gpio_led_platform_data bcm63xx_led_data;
846 862
847static struct platform_device bcm63xx_gpio_leds = { 863static struct platform_device bcm63xx_gpio_leds = {
@@ -855,8 +871,6 @@ static struct platform_device bcm63xx_gpio_leds = {
855 */ 871 */
856int __init board_register_devices(void) 872int __init board_register_devices(void)
857{ 873{
858 u32 val;
859
860 if (board.has_uart0) 874 if (board.has_uart0)
861 bcm63xx_uart_register(0); 875 bcm63xx_uart_register(0);
862 876
@@ -890,14 +904,9 @@ int __init board_register_devices(void)
890 } 904 }
891#endif 905#endif
892 906
893 /* read base address of boot chip select (0) */ 907 bcm63xx_spi_register();
894 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
895 val &= MPI_CSBASE_BASE_MASK;
896
897 mtd_resources[0].start = val;
898 mtd_resources[0].end = 0x1FFFFFFF;
899 908
900 platform_device_register(&mtd_dev); 909 bcm63xx_flash_register();
901 910
902 bcm63xx_led_data.num_leds = ARRAY_SIZE(board.leds); 911 bcm63xx_led_data.num_leds = ARRAY_SIZE(board.leds);
903 bcm63xx_led_data.leds = board.leds; 912 bcm63xx_led_data.leds = board.leds;
diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c
index 9d57c71b7b58..1db48adb543a 100644
--- a/arch/mips/bcm63xx/clk.c
+++ b/arch/mips/bcm63xx/clk.c
@@ -120,7 +120,7 @@ static void enetsw_set(struct clk *clk, int enable)
120{ 120{
121 if (!BCMCPU_IS_6368()) 121 if (!BCMCPU_IS_6368())
122 return; 122 return;
123 bcm_hwclock_set(CKCTL_6368_ROBOSW_CLK_EN | 123 bcm_hwclock_set(CKCTL_6368_ROBOSW_EN |
124 CKCTL_6368_SWPKT_USB_EN | 124 CKCTL_6368_SWPKT_USB_EN |
125 CKCTL_6368_SWPKT_SAR_EN, enable); 125 CKCTL_6368_SWPKT_SAR_EN, enable);
126 if (enable) { 126 if (enable) {
@@ -163,7 +163,7 @@ static void usbh_set(struct clk *clk, int enable)
163 if (BCMCPU_IS_6348()) 163 if (BCMCPU_IS_6348())
164 bcm_hwclock_set(CKCTL_6348_USBH_EN, enable); 164 bcm_hwclock_set(CKCTL_6348_USBH_EN, enable);
165 else if (BCMCPU_IS_6368()) 165 else if (BCMCPU_IS_6368())
166 bcm_hwclock_set(CKCTL_6368_USBH_CLK_EN, enable); 166 bcm_hwclock_set(CKCTL_6368_USBH_EN, enable);
167} 167}
168 168
169static struct clk clk_usbh = { 169static struct clk clk_usbh = {
@@ -181,9 +181,11 @@ static void spi_set(struct clk *clk, int enable)
181 mask = CKCTL_6338_SPI_EN; 181 mask = CKCTL_6338_SPI_EN;
182 else if (BCMCPU_IS_6348()) 182 else if (BCMCPU_IS_6348())
183 mask = CKCTL_6348_SPI_EN; 183 mask = CKCTL_6348_SPI_EN;
184 else 184 else if (BCMCPU_IS_6358())
185 /* BCMCPU_IS_6358 */
186 mask = CKCTL_6358_SPI_EN; 185 mask = CKCTL_6358_SPI_EN;
186 else
187 /* BCMCPU_IS_6368 */
188 mask = CKCTL_6368_SPI_EN;
187 bcm_hwclock_set(mask, enable); 189 bcm_hwclock_set(mask, enable);
188} 190}
189 191
@@ -199,7 +201,7 @@ static void xtm_set(struct clk *clk, int enable)
199 if (!BCMCPU_IS_6368()) 201 if (!BCMCPU_IS_6368())
200 return; 202 return;
201 203
202 bcm_hwclock_set(CKCTL_6368_SAR_CLK_EN | 204 bcm_hwclock_set(CKCTL_6368_SAR_EN |
203 CKCTL_6368_SWPKT_SAR_EN, enable); 205 CKCTL_6368_SWPKT_SAR_EN, enable);
204 206
205 if (enable) { 207 if (enable) {
@@ -222,6 +224,18 @@ static struct clk clk_xtm = {
222}; 224};
223 225
224/* 226/*
227 * IPsec clock
228 */
229static void ipsec_set(struct clk *clk, int enable)
230{
231 bcm_hwclock_set(CKCTL_6368_IPSEC_EN, enable);
232}
233
234static struct clk clk_ipsec = {
235 .set = ipsec_set,
236};
237
238/*
225 * Internal peripheral clock 239 * Internal peripheral clock
226 */ 240 */
227static struct clk clk_periph = { 241static struct clk clk_periph = {
@@ -278,6 +292,8 @@ struct clk *clk_get(struct device *dev, const char *id)
278 return &clk_periph; 292 return &clk_periph;
279 if (BCMCPU_IS_6358() && !strcmp(id, "pcm")) 293 if (BCMCPU_IS_6358() && !strcmp(id, "pcm"))
280 return &clk_pcm; 294 return &clk_pcm;
295 if (BCMCPU_IS_6368() && !strcmp(id, "ipsec"))
296 return &clk_ipsec;
281 return ERR_PTR(-ENOENT); 297 return ERR_PTR(-ENOENT);
282} 298}
283 299
diff --git a/arch/mips/bcm63xx/cpu.c b/arch/mips/bcm63xx/cpu.c
index 8f0d6c7725ea..a7afb289b15a 100644
--- a/arch/mips/bcm63xx/cpu.c
+++ b/arch/mips/bcm63xx/cpu.c
@@ -29,6 +29,14 @@ static u16 bcm63xx_cpu_rev;
29static unsigned int bcm63xx_cpu_freq; 29static unsigned int bcm63xx_cpu_freq;
30static unsigned int bcm63xx_memory_size; 30static unsigned int bcm63xx_memory_size;
31 31
32static const unsigned long bcm6328_regs_base[] = {
33 __GEN_CPU_REGS_TABLE(6328)
34};
35
36static const int bcm6328_irqs[] = {
37 __GEN_CPU_IRQ_TABLE(6328)
38};
39
32static const unsigned long bcm6338_regs_base[] = { 40static const unsigned long bcm6338_regs_base[] = {
33 __GEN_CPU_REGS_TABLE(6338) 41 __GEN_CPU_REGS_TABLE(6338)
34}; 42};
@@ -99,6 +107,33 @@ unsigned int bcm63xx_get_memory_size(void)
99static unsigned int detect_cpu_clock(void) 107static unsigned int detect_cpu_clock(void)
100{ 108{
101 switch (bcm63xx_get_cpu_id()) { 109 switch (bcm63xx_get_cpu_id()) {
110 case BCM6328_CPU_ID:
111 {
112 unsigned int tmp, mips_pll_fcvo;
113
114 tmp = bcm_misc_readl(MISC_STRAPBUS_6328_REG);
115 mips_pll_fcvo = (tmp & STRAPBUS_6328_FCVO_MASK)
116 >> STRAPBUS_6328_FCVO_SHIFT;
117
118 switch (mips_pll_fcvo) {
119 case 0x12:
120 case 0x14:
121 case 0x19:
122 return 160000000;
123 case 0x1c:
124 return 192000000;
125 case 0x13:
126 case 0x15:
127 return 200000000;
128 case 0x1a:
129 return 384000000;
130 case 0x16:
131 return 400000000;
132 default:
133 return 320000000;
134 }
135
136 }
102 case BCM6338_CPU_ID: 137 case BCM6338_CPU_ID:
103 /* BCM6338 has a fixed 240 Mhz frequency */ 138 /* BCM6338 has a fixed 240 Mhz frequency */
104 return 240000000; 139 return 240000000;
@@ -170,6 +205,9 @@ static unsigned int detect_memory_size(void)
170 unsigned int cols = 0, rows = 0, is_32bits = 0, banks = 0; 205 unsigned int cols = 0, rows = 0, is_32bits = 0, banks = 0;
171 u32 val; 206 u32 val;
172 207
208 if (BCMCPU_IS_6328())
209 return bcm_ddr_readl(DDR_CSEND_REG) << 24;
210
173 if (BCMCPU_IS_6345()) { 211 if (BCMCPU_IS_6345()) {
174 val = bcm_sdram_readl(SDRAM_MBASE_REG); 212 val = bcm_sdram_readl(SDRAM_MBASE_REG);
175 return (val * 8 * 1024 * 1024); 213 return (val * 8 * 1024 * 1024);
@@ -228,17 +266,26 @@ void __init bcm63xx_cpu_init(void)
228 bcm63xx_irqs = bcm6345_irqs; 266 bcm63xx_irqs = bcm6345_irqs;
229 break; 267 break;
230 case CPU_BMIPS4350: 268 case CPU_BMIPS4350:
231 switch (read_c0_prid() & 0xf0) { 269 if ((read_c0_prid() & 0xf0) == 0x10) {
232 case 0x10:
233 expected_cpu_id = BCM6358_CPU_ID; 270 expected_cpu_id = BCM6358_CPU_ID;
234 bcm63xx_regs_base = bcm6358_regs_base; 271 bcm63xx_regs_base = bcm6358_regs_base;
235 bcm63xx_irqs = bcm6358_irqs; 272 bcm63xx_irqs = bcm6358_irqs;
236 break; 273 } else {
237 case 0x30: 274 /* all newer chips have the same chip id location */
238 expected_cpu_id = BCM6368_CPU_ID; 275 u16 chip_id = bcm_readw(BCM_6368_PERF_BASE);
239 bcm63xx_regs_base = bcm6368_regs_base; 276
240 bcm63xx_irqs = bcm6368_irqs; 277 switch (chip_id) {
241 break; 278 case BCM6328_CPU_ID:
279 expected_cpu_id = BCM6328_CPU_ID;
280 bcm63xx_regs_base = bcm6328_regs_base;
281 bcm63xx_irqs = bcm6328_irqs;
282 break;
283 case BCM6368_CPU_ID:
284 expected_cpu_id = BCM6368_CPU_ID;
285 bcm63xx_regs_base = bcm6368_regs_base;
286 bcm63xx_irqs = bcm6368_irqs;
287 break;
288 }
242 } 289 }
243 break; 290 break;
244 } 291 }
diff --git a/arch/mips/bcm63xx/dev-dsp.c b/arch/mips/bcm63xx/dev-dsp.c
index da46d1d3c77c..5bb5b154c9bd 100644
--- a/arch/mips/bcm63xx/dev-dsp.c
+++ b/arch/mips/bcm63xx/dev-dsp.c
@@ -31,7 +31,7 @@ static struct resource voip_dsp_resources[] = {
31 31
32static struct platform_device bcm63xx_voip_dsp_device = { 32static struct platform_device bcm63xx_voip_dsp_device = {
33 .name = "bcm63xx-voip-dsp", 33 .name = "bcm63xx-voip-dsp",
34 .id = 0, 34 .id = -1,
35 .num_resources = ARRAY_SIZE(voip_dsp_resources), 35 .num_resources = ARRAY_SIZE(voip_dsp_resources),
36 .resource = voip_dsp_resources, 36 .resource = voip_dsp_resources,
37}; 37};
diff --git a/arch/mips/bcm63xx/dev-flash.c b/arch/mips/bcm63xx/dev-flash.c
new file mode 100644
index 000000000000..58371c7deac2
--- /dev/null
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -0,0 +1,123 @@
1/*
2 * Broadcom BCM63xx flash registration
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
9 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
10 * Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
11 */
12
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/mtd/mtd.h>
17#include <linux/mtd/partitions.h>
18#include <linux/mtd/physmap.h>
19
20#include <bcm63xx_cpu.h>
21#include <bcm63xx_dev_flash.h>
22#include <bcm63xx_regs.h>
23#include <bcm63xx_io.h>
24
25static struct mtd_partition mtd_partitions[] = {
26 {
27 .name = "cfe",
28 .offset = 0x0,
29 .size = 0x40000,
30 }
31};
32
33static const char *bcm63xx_part_types[] = { "bcm63xxpart", NULL };
34
35static struct physmap_flash_data flash_data = {
36 .width = 2,
37 .parts = mtd_partitions,
38 .part_probe_types = bcm63xx_part_types,
39};
40
41static struct resource mtd_resources[] = {
42 {
43 .start = 0, /* filled at runtime */
44 .end = 0, /* filled at runtime */
45 .flags = IORESOURCE_MEM,
46 }
47};
48
49static struct platform_device mtd_dev = {
50 .name = "physmap-flash",
51 .resource = mtd_resources,
52 .num_resources = ARRAY_SIZE(mtd_resources),
53 .dev = {
54 .platform_data = &flash_data,
55 },
56};
57
58static int __init bcm63xx_detect_flash_type(void)
59{
60 u32 val;
61
62 switch (bcm63xx_get_cpu_id()) {
63 case BCM6328_CPU_ID:
64 val = bcm_misc_readl(MISC_STRAPBUS_6328_REG);
65 if (val & STRAPBUS_6328_BOOT_SEL_SERIAL)
66 return BCM63XX_FLASH_TYPE_SERIAL;
67 else
68 return BCM63XX_FLASH_TYPE_NAND;
69 case BCM6338_CPU_ID:
70 case BCM6345_CPU_ID:
71 case BCM6348_CPU_ID:
72 /* no way to auto detect so assume parallel */
73 return BCM63XX_FLASH_TYPE_PARALLEL;
74 case BCM6358_CPU_ID:
75 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
76 if (val & STRAPBUS_6358_BOOT_SEL_PARALLEL)
77 return BCM63XX_FLASH_TYPE_PARALLEL;
78 else
79 return BCM63XX_FLASH_TYPE_SERIAL;
80 case BCM6368_CPU_ID:
81 val = bcm_gpio_readl(GPIO_STRAPBUS_REG);
82 switch (val & STRAPBUS_6368_BOOT_SEL_MASK) {
83 case STRAPBUS_6368_BOOT_SEL_NAND:
84 return BCM63XX_FLASH_TYPE_NAND;
85 case STRAPBUS_6368_BOOT_SEL_SERIAL:
86 return BCM63XX_FLASH_TYPE_SERIAL;
87 case STRAPBUS_6368_BOOT_SEL_PARALLEL:
88 return BCM63XX_FLASH_TYPE_PARALLEL;
89 }
90 default:
91 return -EINVAL;
92 }
93}
94
95int __init bcm63xx_flash_register(void)
96{
97 int flash_type;
98 u32 val;
99
100 flash_type = bcm63xx_detect_flash_type();
101
102 switch (flash_type) {
103 case BCM63XX_FLASH_TYPE_PARALLEL:
104 /* read base address of boot chip select (0) */
105 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
106 val &= MPI_CSBASE_BASE_MASK;
107
108 mtd_resources[0].start = val;
109 mtd_resources[0].end = 0x1FFFFFFF;
110
111 return platform_device_register(&mtd_dev);
112 case BCM63XX_FLASH_TYPE_SERIAL:
113 pr_warn("unsupported serial flash detected\n");
114 return -ENODEV;
115 case BCM63XX_FLASH_TYPE_NAND:
116 pr_warn("unsupported NAND flash detected\n");
117 return -ENODEV;
118 default:
119 pr_err("flash detection failed for BCM%x: %d\n",
120 bcm63xx_get_cpu_id(), flash_type);
121 return -ENODEV;
122 }
123}
diff --git a/arch/mips/bcm63xx/dev-rng.c b/arch/mips/bcm63xx/dev-rng.c
new file mode 100644
index 000000000000..d277b4dc6c68
--- /dev/null
+++ b/arch/mips/bcm63xx/dev-rng.c
@@ -0,0 +1,40 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2011 Florian Fainelli <florian@openwrt.org>
7 */
8
9#include <linux/init.h>
10#include <linux/kernel.h>
11#include <linux/platform_device.h>
12#include <bcm63xx_cpu.h>
13
14static struct resource rng_resources[] = {
15 {
16 .start = -1, /* filled at runtime */
17 .end = -1, /* filled at runtime */
18 .flags = IORESOURCE_MEM,
19 },
20};
21
22static struct platform_device bcm63xx_rng_device = {
23 .name = "bcm63xx-rng",
24 .id = -1,
25 .num_resources = ARRAY_SIZE(rng_resources),
26 .resource = rng_resources,
27};
28
29int __init bcm63xx_rng_register(void)
30{
31 if (!BCMCPU_IS_6368())
32 return -ENODEV;
33
34 rng_resources[0].start = bcm63xx_regset_address(RSET_RNG);
35 rng_resources[0].end = rng_resources[0].start;
36 rng_resources[0].end += RSET_RNG_SIZE - 1;
37
38 return platform_device_register(&bcm63xx_rng_device);
39}
40arch_initcall(bcm63xx_rng_register);
diff --git a/arch/mips/bcm63xx/dev-spi.c b/arch/mips/bcm63xx/dev-spi.c
new file mode 100644
index 000000000000..e39f73048d4f
--- /dev/null
+++ b/arch/mips/bcm63xx/dev-spi.c
@@ -0,0 +1,119 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2009-2011 Florian Fainelli <florian@openwrt.org>
7 * Copyright (C) 2010 Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com>
8 */
9
10#include <linux/init.h>
11#include <linux/kernel.h>
12#include <linux/export.h>
13#include <linux/platform_device.h>
14#include <linux/err.h>
15#include <linux/clk.h>
16
17#include <bcm63xx_cpu.h>
18#include <bcm63xx_dev_spi.h>
19#include <bcm63xx_regs.h>
20
21#ifdef BCMCPU_RUNTIME_DETECT
22/*
23 * register offsets
24 */
25static const unsigned long bcm6338_regs_spi[] = {
26 __GEN_SPI_REGS_TABLE(6338)
27};
28
29static const unsigned long bcm6348_regs_spi[] = {
30 __GEN_SPI_REGS_TABLE(6348)
31};
32
33static const unsigned long bcm6358_regs_spi[] = {
34 __GEN_SPI_REGS_TABLE(6358)
35};
36
37static const unsigned long bcm6368_regs_spi[] = {
38 __GEN_SPI_REGS_TABLE(6368)
39};
40
41const unsigned long *bcm63xx_regs_spi;
42EXPORT_SYMBOL(bcm63xx_regs_spi);
43
44static __init void bcm63xx_spi_regs_init(void)
45{
46 if (BCMCPU_IS_6338())
47 bcm63xx_regs_spi = bcm6338_regs_spi;
48 if (BCMCPU_IS_6348())
49 bcm63xx_regs_spi = bcm6348_regs_spi;
50 if (BCMCPU_IS_6358())
51 bcm63xx_regs_spi = bcm6358_regs_spi;
52 if (BCMCPU_IS_6368())
53 bcm63xx_regs_spi = bcm6368_regs_spi;
54}
55#else
56static __init void bcm63xx_spi_regs_init(void) { }
57#endif
58
59static struct resource spi_resources[] = {
60 {
61 .start = -1, /* filled at runtime */
62 .end = -1, /* filled at runtime */
63 .flags = IORESOURCE_MEM,
64 },
65 {
66 .start = -1, /* filled at runtime */
67 .flags = IORESOURCE_IRQ,
68 },
69};
70
71static struct bcm63xx_spi_pdata spi_pdata = {
72 .bus_num = 0,
73 .num_chipselect = 8,
74};
75
76static struct platform_device bcm63xx_spi_device = {
77 .name = "bcm63xx-spi",
78 .id = -1,
79 .num_resources = ARRAY_SIZE(spi_resources),
80 .resource = spi_resources,
81 .dev = {
82 .platform_data = &spi_pdata,
83 },
84};
85
86int __init bcm63xx_spi_register(void)
87{
88 struct clk *periph_clk;
89
90 if (BCMCPU_IS_6328() || BCMCPU_IS_6345())
91 return -ENODEV;
92
93 periph_clk = clk_get(NULL, "periph");
94 if (IS_ERR(periph_clk)) {
95 pr_err("unable to get periph clock\n");
96 return -ENODEV;
97 }
98
99 /* Set bus frequency */
100 spi_pdata.speed_hz = clk_get_rate(periph_clk);
101
102 spi_resources[0].start = bcm63xx_regset_address(RSET_SPI);
103 spi_resources[0].end = spi_resources[0].start;
104 spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI);
105
106 if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) {
107 spi_resources[0].end += BCM_6338_RSET_SPI_SIZE - 1;
108 spi_pdata.fifo_size = SPI_6338_MSG_DATA_SIZE;
109 }
110
111 if (BCMCPU_IS_6358() || BCMCPU_IS_6368()) {
112 spi_resources[0].end += BCM_6358_RSET_SPI_SIZE - 1;
113 spi_pdata.fifo_size = SPI_6358_MSG_DATA_SIZE;
114 }
115
116 bcm63xx_spi_regs_init();
117
118 return platform_device_register(&bcm63xx_spi_device);
119}
diff --git a/arch/mips/bcm63xx/dev-wdt.c b/arch/mips/bcm63xx/dev-wdt.c
index 3e6c716a4c11..2a2346a99bcb 100644
--- a/arch/mips/bcm63xx/dev-wdt.c
+++ b/arch/mips/bcm63xx/dev-wdt.c
@@ -21,7 +21,7 @@ static struct resource wdt_resources[] = {
21 21
22static struct platform_device bcm63xx_wdt_device = { 22static struct platform_device bcm63xx_wdt_device = {
23 .name = "bcm63xx-wdt", 23 .name = "bcm63xx-wdt",
24 .id = 0, 24 .id = -1,
25 .num_resources = ARRAY_SIZE(wdt_resources), 25 .num_resources = ARRAY_SIZE(wdt_resources),
26 .resource = wdt_resources, 26 .resource = wdt_resources,
27}; 27};
diff --git a/arch/mips/bcm63xx/irq.c b/arch/mips/bcm63xx/irq.c
index 9a216a451d92..18e051ad18a5 100644
--- a/arch/mips/bcm63xx/irq.c
+++ b/arch/mips/bcm63xx/irq.c
@@ -27,6 +27,17 @@ static void __internal_irq_unmask_32(unsigned int irq) __maybe_unused;
27static void __internal_irq_unmask_64(unsigned int irq) __maybe_unused; 27static void __internal_irq_unmask_64(unsigned int irq) __maybe_unused;
28 28
29#ifndef BCMCPU_RUNTIME_DETECT 29#ifndef BCMCPU_RUNTIME_DETECT
30#ifdef CONFIG_BCM63XX_CPU_6328
31#define irq_stat_reg PERF_IRQSTAT_6328_REG
32#define irq_mask_reg PERF_IRQMASK_6328_REG
33#define irq_bits 64
34#define is_ext_irq_cascaded 1
35#define ext_irq_start (BCM_6328_EXT_IRQ0 - IRQ_INTERNAL_BASE)
36#define ext_irq_end (BCM_6328_EXT_IRQ3 - IRQ_INTERNAL_BASE)
37#define ext_irq_count 4
38#define ext_irq_cfg_reg1 PERF_EXTIRQ_CFG_REG_6328
39#define ext_irq_cfg_reg2 0
40#endif
30#ifdef CONFIG_BCM63XX_CPU_6338 41#ifdef CONFIG_BCM63XX_CPU_6338
31#define irq_stat_reg PERF_IRQSTAT_6338_REG 42#define irq_stat_reg PERF_IRQSTAT_6338_REG
32#define irq_mask_reg PERF_IRQMASK_6338_REG 43#define irq_mask_reg PERF_IRQMASK_6338_REG
@@ -118,6 +129,16 @@ static void bcm63xx_init_irq(void)
118 irq_mask_addr = bcm63xx_regset_address(RSET_PERF); 129 irq_mask_addr = bcm63xx_regset_address(RSET_PERF);
119 130
120 switch (bcm63xx_get_cpu_id()) { 131 switch (bcm63xx_get_cpu_id()) {
132 case BCM6328_CPU_ID:
133 irq_stat_addr += PERF_IRQSTAT_6328_REG;
134 irq_mask_addr += PERF_IRQMASK_6328_REG;
135 irq_bits = 64;
136 ext_irq_count = 4;
137 is_ext_irq_cascaded = 1;
138 ext_irq_start = BCM_6328_EXT_IRQ0 - IRQ_INTERNAL_BASE;
139 ext_irq_end = BCM_6328_EXT_IRQ3 - IRQ_INTERNAL_BASE;
140 ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6328;
141 break;
121 case BCM6338_CPU_ID: 142 case BCM6338_CPU_ID:
122 irq_stat_addr += PERF_IRQSTAT_6338_REG; 143 irq_stat_addr += PERF_IRQSTAT_6338_REG;
123 irq_mask_addr += PERF_IRQMASK_6338_REG; 144 irq_mask_addr += PERF_IRQMASK_6338_REG;
diff --git a/arch/mips/bcm63xx/prom.c b/arch/mips/bcm63xx/prom.c
index 99d7f405cbeb..10eaff458071 100644
--- a/arch/mips/bcm63xx/prom.c
+++ b/arch/mips/bcm63xx/prom.c
@@ -26,7 +26,9 @@ void __init prom_init(void)
26 bcm_wdt_writel(WDT_STOP_2, WDT_CTL_REG); 26 bcm_wdt_writel(WDT_STOP_2, WDT_CTL_REG);
27 27
28 /* disable all hardware blocks clock for now */ 28 /* disable all hardware blocks clock for now */
29 if (BCMCPU_IS_6338()) 29 if (BCMCPU_IS_6328())
30 mask = CKCTL_6328_ALL_SAFE_EN;
31 else if (BCMCPU_IS_6338())
30 mask = CKCTL_6338_ALL_SAFE_EN; 32 mask = CKCTL_6338_ALL_SAFE_EN;
31 else if (BCMCPU_IS_6345()) 33 else if (BCMCPU_IS_6345())
32 mask = CKCTL_6345_ALL_SAFE_EN; 34 mask = CKCTL_6345_ALL_SAFE_EN;
diff --git a/arch/mips/bcm63xx/setup.c b/arch/mips/bcm63xx/setup.c
index 356b05583e14..0e74a13639cd 100644
--- a/arch/mips/bcm63xx/setup.c
+++ b/arch/mips/bcm63xx/setup.c
@@ -68,6 +68,9 @@ void bcm63xx_machine_reboot(void)
68 68
69 /* mask and clear all external irq */ 69 /* mask and clear all external irq */
70 switch (bcm63xx_get_cpu_id()) { 70 switch (bcm63xx_get_cpu_id()) {
71 case BCM6328_CPU_ID:
72 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6328;
73 break;
71 case BCM6338_CPU_ID: 74 case BCM6338_CPU_ID:
72 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6338; 75 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6338;
73 break; 76 break;
@@ -95,9 +98,13 @@ void bcm63xx_machine_reboot(void)
95 bcm6348_a1_reboot(); 98 bcm6348_a1_reboot();
96 99
97 printk(KERN_INFO "triggering watchdog soft-reset...\n"); 100 printk(KERN_INFO "triggering watchdog soft-reset...\n");
98 reg = bcm_perf_readl(PERF_SYS_PLL_CTL_REG); 101 if (BCMCPU_IS_6328()) {
99 reg |= SYS_PLL_SOFT_RESET; 102 bcm_wdt_writel(1, WDT_SOFTRESET_REG);
100 bcm_perf_writel(reg, PERF_SYS_PLL_CTL_REG); 103 } else {
104 reg = bcm_perf_readl(PERF_SYS_PLL_CTL_REG);
105 reg |= SYS_PLL_SOFT_RESET;
106 bcm_perf_writel(reg, PERF_SYS_PLL_CTL_REG);
107 }
101 while (1) 108 while (1)
102 ; 109 ;
103} 110}
diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
index 5042d51b0512..c2a3fb0ffc87 100644
--- a/arch/mips/boot/compressed/Makefile
+++ b/arch/mips/boot/compressed/Makefile
@@ -58,8 +58,12 @@ $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
58# Calculate the load address of the compressed kernel image 58# Calculate the load address of the compressed kernel image
59hostprogs-y := calc_vmlinuz_load_addr 59hostprogs-y := calc_vmlinuz_load_addr
60 60
61ifeq ($(CONFIG_MACH_JZ4740),y)
62VMLINUZ_LOAD_ADDRESS := 0x80600000
63else
61VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ 64VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
62 $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS)) 65 $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
66endif
63 67
64vmlinuzobjs-y += $(obj)/piggy.o 68vmlinuzobjs-y += $(obj)/piggy.o
65 69
diff --git a/arch/mips/boot/compressed/uart-16550.c b/arch/mips/boot/compressed/uart-16550.c
index c9caaf4fbf60..1c7b739b6a1d 100644
--- a/arch/mips/boot/compressed/uart-16550.c
+++ b/arch/mips/boot/compressed/uart-16550.c
@@ -18,6 +18,11 @@
18#define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset)) 18#define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset))
19#endif 19#endif
20 20
21#ifdef CONFIG_MACH_JZ4740
22#define UART0_BASE 0xB0030000
23#define PORT(offset) (UART0_BASE + (4 * offset))
24#endif
25
21#ifndef PORT 26#ifndef PORT
22#error please define the serial port address for your own machine 27#error please define the serial port address for your own machine
23#endif 28#endif
diff --git a/arch/mips/cavium-octeon/.gitignore b/arch/mips/cavium-octeon/.gitignore
new file mode 100644
index 000000000000..39c968605ff6
--- /dev/null
+++ b/arch/mips/cavium-octeon/.gitignore
@@ -0,0 +1,2 @@
1*.dtb.S
2*.dtb
diff --git a/arch/mips/cavium-octeon/Makefile b/arch/mips/cavium-octeon/Makefile
index 19eb0434269f..bc96e2908f14 100644
--- a/arch/mips/cavium-octeon/Makefile
+++ b/arch/mips/cavium-octeon/Makefile
@@ -9,9 +9,25 @@
9# Copyright (C) 2005-2009 Cavium Networks 9# Copyright (C) 2005-2009 Cavium Networks
10# 10#
11 11
12CFLAGS_octeon-platform.o = -I$(src)/../../../scripts/dtc/libfdt
13CFLAGS_setup.o = -I$(src)/../../../scripts/dtc/libfdt
14
12obj-y := cpu.o setup.o serial.o octeon-platform.o octeon-irq.o csrc-octeon.o 15obj-y := cpu.o setup.o serial.o octeon-platform.o octeon-irq.o csrc-octeon.o
13obj-y += dma-octeon.o flash_setup.o 16obj-y += dma-octeon.o flash_setup.o
14obj-y += octeon-memcpy.o 17obj-y += octeon-memcpy.o
15obj-y += executive/ 18obj-y += executive/
16 19
17obj-$(CONFIG_SMP) += smp.o 20obj-$(CONFIG_SMP) += smp.o
21
22DTS_FILES = octeon_3xxx.dts octeon_68xx.dts
23DTB_FILES = $(patsubst %.dts, %.dtb, $(DTS_FILES))
24
25obj-y += $(patsubst %.dts, %.dtb.o, $(DTS_FILES))
26
27$(obj)/%.dtb: $(src)/%.dts FORCE
28 $(call if_changed_dep,dtc)
29
30# Let's keep the .dtb files around in case we want to look at them.
31.SECONDARY: $(addprefix $(obj)/, $(DTB_FILES))
32
33clean-files += $(DTB_FILES) $(patsubst %.dtb, %.dtb.S, $(DTB_FILES))
diff --git a/arch/mips/cavium-octeon/executive/cvmx-fpa.c b/arch/mips/cavium-octeon/executive/cvmx-fpa.c
deleted file mode 100644
index ad44b8bd8057..000000000000
--- a/arch/mips/cavium-octeon/executive/cvmx-fpa.c
+++ /dev/null
@@ -1,183 +0,0 @@
1/***********************license start***************
2 * Author: Cavium Networks
3 *
4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK
6 *
7 * Copyright (c) 2003-2008 Cavium Networks
8 *
9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as
11 * published by the Free Software Foundation.
12 *
13 * This file is distributed in the hope that it will be useful, but
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16 * NONINFRINGEMENT. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this file; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * or visit http://www.gnu.org/licenses/.
23 *
24 * This file may also be available under a different license from Cavium.
25 * Contact Cavium Networks for more information
26 ***********************license end**************************************/
27
28/**
29 * @file
30 *
31 * Support library for the hardware Free Pool Allocator.
32 *
33 *
34 */
35
36#include "cvmx-config.h"
37#include "cvmx.h"
38#include "cvmx-fpa.h"
39#include "cvmx-ipd.h"
40
41/**
42 * Current state of all the pools. Use access functions
43 * instead of using it directly.
44 */
45CVMX_SHARED cvmx_fpa_pool_info_t cvmx_fpa_pool_info[CVMX_FPA_NUM_POOLS];
46
47/**
48 * Setup a FPA pool to control a new block of memory. The
49 * buffer pointer must be a physical address.
50 *
51 * @pool: Pool to initialize
52 * 0 <= pool < 8
53 * @name: Constant character string to name this pool.
54 * String is not copied.
55 * @buffer: Pointer to the block of memory to use. This must be
56 * accessible by all processors and external hardware.
57 * @block_size: Size for each block controlled by the FPA
58 * @num_blocks: Number of blocks
59 *
60 * Returns 0 on Success,
61 * -1 on failure
62 */
63int cvmx_fpa_setup_pool(uint64_t pool, const char *name, void *buffer,
64 uint64_t block_size, uint64_t num_blocks)
65{
66 char *ptr;
67 if (!buffer) {
68 cvmx_dprintf
69 ("ERROR: cvmx_fpa_setup_pool: NULL buffer pointer!\n");
70 return -1;
71 }
72 if (pool >= CVMX_FPA_NUM_POOLS) {
73 cvmx_dprintf("ERROR: cvmx_fpa_setup_pool: Illegal pool!\n");
74 return -1;
75 }
76
77 if (block_size < CVMX_FPA_MIN_BLOCK_SIZE) {
78 cvmx_dprintf
79 ("ERROR: cvmx_fpa_setup_pool: Block size too small.\n");
80 return -1;
81 }
82
83 if (((unsigned long)buffer & (CVMX_FPA_ALIGNMENT - 1)) != 0) {
84 cvmx_dprintf
85 ("ERROR: cvmx_fpa_setup_pool: Buffer not aligned properly.\n");
86 return -1;
87 }
88
89 cvmx_fpa_pool_info[pool].name = name;
90 cvmx_fpa_pool_info[pool].size = block_size;
91 cvmx_fpa_pool_info[pool].starting_element_count = num_blocks;
92 cvmx_fpa_pool_info[pool].base = buffer;
93
94 ptr = (char *)buffer;
95 while (num_blocks--) {
96 cvmx_fpa_free(ptr, pool, 0);
97 ptr += block_size;
98 }
99 return 0;
100}
101
102/**
103 * Shutdown a Memory pool and validate that it had all of
104 * the buffers originally placed in it.
105 *
106 * @pool: Pool to shutdown
107 * Returns Zero on success
108 * - Positive is count of missing buffers
109 * - Negative is too many buffers or corrupted pointers
110 */
111uint64_t cvmx_fpa_shutdown_pool(uint64_t pool)
112{
113 uint64_t errors = 0;
114 uint64_t count = 0;
115 uint64_t base = cvmx_ptr_to_phys(cvmx_fpa_pool_info[pool].base);
116 uint64_t finish =
117 base +
118 cvmx_fpa_pool_info[pool].size *
119 cvmx_fpa_pool_info[pool].starting_element_count;
120 void *ptr;
121 uint64_t address;
122
123 count = 0;
124 do {
125 ptr = cvmx_fpa_alloc(pool);
126 if (ptr)
127 address = cvmx_ptr_to_phys(ptr);
128 else
129 address = 0;
130 if (address) {
131 if ((address >= base) && (address < finish) &&
132 (((address -
133 base) % cvmx_fpa_pool_info[pool].size) == 0)) {
134 count++;
135 } else {
136 cvmx_dprintf
137 ("ERROR: cvmx_fpa_shutdown_pool: Illegal address 0x%llx in pool %s(%d)\n",
138 (unsigned long long)address,
139 cvmx_fpa_pool_info[pool].name, (int)pool);
140 errors++;
141 }
142 }
143 } while (address);
144
145#ifdef CVMX_ENABLE_PKO_FUNCTIONS
146 if (pool == 0)
147 cvmx_ipd_free_ptr();
148#endif
149
150 if (errors) {
151 cvmx_dprintf
152 ("ERROR: cvmx_fpa_shutdown_pool: Pool %s(%d) started at 0x%llx, ended at 0x%llx, with a step of 0x%llx\n",
153 cvmx_fpa_pool_info[pool].name, (int)pool,
154 (unsigned long long)base, (unsigned long long)finish,
155 (unsigned long long)cvmx_fpa_pool_info[pool].size);
156 return -errors;
157 } else
158 return 0;
159}
160
161uint64_t cvmx_fpa_get_block_size(uint64_t pool)
162{
163 switch (pool) {
164 case 0:
165 return CVMX_FPA_POOL_0_SIZE;
166 case 1:
167 return CVMX_FPA_POOL_1_SIZE;
168 case 2:
169 return CVMX_FPA_POOL_2_SIZE;
170 case 3:
171 return CVMX_FPA_POOL_3_SIZE;
172 case 4:
173 return CVMX_FPA_POOL_4_SIZE;
174 case 5:
175 return CVMX_FPA_POOL_5_SIZE;
176 case 6:
177 return CVMX_FPA_POOL_6_SIZE;
178 case 7:
179 return CVMX_FPA_POOL_7_SIZE;
180 default:
181 return 0;
182 }
183}
diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c b/arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c
deleted file mode 100644
index c239e5f4ab9a..000000000000
--- a/arch/mips/cavium-octeon/executive/cvmx-helper-fpa.c
+++ /dev/null
@@ -1,243 +0,0 @@
1/***********************license start***************
2 * Author: Cavium Networks
3 *
4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK
6 *
7 * Copyright (c) 2003-2008 Cavium Networks
8 *
9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as
11 * published by the Free Software Foundation.
12 *
13 * This file is distributed in the hope that it will be useful, but
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16 * NONINFRINGEMENT. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this file; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * or visit http://www.gnu.org/licenses/.
23 *
24 * This file may also be available under a different license from Cavium.
25 * Contact Cavium Networks for more information
26 ***********************license end**************************************/
27
28/**
29 * @file
30 *
31 * Helper functions for FPA setup.
32 *
33 */
34#include "executive-config.h"
35#include "cvmx-config.h"
36#include "cvmx.h"
37#include "cvmx-bootmem.h"
38#include "cvmx-fpa.h"
39#include "cvmx-helper-fpa.h"
40
41/**
42 * Allocate memory for and initialize a single FPA pool.
43 *
44 * @pool: Pool to initialize
45 * @buffer_size: Size of buffers to allocate in bytes
46 * @buffers: Number of buffers to put in the pool. Zero is allowed
47 * @name: String name of the pool for debugging purposes
48 * Returns Zero on success, non-zero on failure
49 */
50static int __cvmx_helper_initialize_fpa_pool(int pool, uint64_t buffer_size,
51 uint64_t buffers, const char *name)
52{
53 uint64_t current_num;
54 void *memory;
55 uint64_t align = CVMX_CACHE_LINE_SIZE;
56
57 /*
58 * Align the allocation so that power of 2 size buffers are
59 * naturally aligned.
60 */
61 while (align < buffer_size)
62 align = align << 1;
63
64 if (buffers == 0)
65 return 0;
66
67 current_num = cvmx_read_csr(CVMX_FPA_QUEX_AVAILABLE(pool));
68 if (current_num) {
69 cvmx_dprintf("Fpa pool %d(%s) already has %llu buffers. "
70 "Skipping setup.\n",
71 pool, name, (unsigned long long)current_num);
72 return 0;
73 }
74
75 memory = cvmx_bootmem_alloc(buffer_size * buffers, align);
76 if (memory == NULL) {
77 cvmx_dprintf("Out of memory initializing fpa pool %d(%s).\n",
78 pool, name);
79 return -1;
80 }
81 cvmx_fpa_setup_pool(pool, name, memory, buffer_size, buffers);
82 return 0;
83}
84
85/**
86 * Allocate memory and initialize the FPA pools using memory
87 * from cvmx-bootmem. Specifying zero for the number of
88 * buffers will cause that FPA pool to not be setup. This is
89 * useful if you aren't using some of the hardware and want
90 * to save memory. Use cvmx_helper_initialize_fpa instead of
91 * this function directly.
92 *
93 * @pip_pool: Should always be CVMX_FPA_PACKET_POOL
94 * @pip_size: Should always be CVMX_FPA_PACKET_POOL_SIZE
95 * @pip_buffers:
96 * Number of packet buffers.
97 * @wqe_pool: Should always be CVMX_FPA_WQE_POOL
98 * @wqe_size: Should always be CVMX_FPA_WQE_POOL_SIZE
99 * @wqe_entries:
100 * Number of work queue entries
101 * @pko_pool: Should always be CVMX_FPA_OUTPUT_BUFFER_POOL
102 * @pko_size: Should always be CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE
103 * @pko_buffers:
104 * PKO Command buffers. You should at minimum have two per
105 * each PKO queue.
106 * @tim_pool: Should always be CVMX_FPA_TIMER_POOL
107 * @tim_size: Should always be CVMX_FPA_TIMER_POOL_SIZE
108 * @tim_buffers:
109 * TIM ring buffer command queues. At least two per timer bucket
110 * is recommened.
111 * @dfa_pool: Should always be CVMX_FPA_DFA_POOL
112 * @dfa_size: Should always be CVMX_FPA_DFA_POOL_SIZE
113 * @dfa_buffers:
114 * DFA command buffer. A relatively small (32 for example)
115 * number should work.
116 * Returns Zero on success, non-zero if out of memory
117 */
118static int __cvmx_helper_initialize_fpa(int pip_pool, int pip_size,
119 int pip_buffers, int wqe_pool,
120 int wqe_size, int wqe_entries,
121 int pko_pool, int pko_size,
122 int pko_buffers, int tim_pool,
123 int tim_size, int tim_buffers,
124 int dfa_pool, int dfa_size,
125 int dfa_buffers)
126{
127 int status;
128
129 cvmx_fpa_enable();
130
131 if ((pip_buffers > 0) && (pip_buffers <= 64))
132 cvmx_dprintf
133 ("Warning: %d packet buffers may not be enough for hardware"
134 " prefetch. 65 or more is recommended.\n", pip_buffers);
135
136 if (pip_pool >= 0) {
137 status =
138 __cvmx_helper_initialize_fpa_pool(pip_pool, pip_size,
139 pip_buffers,
140 "Packet Buffers");
141 if (status)
142 return status;
143 }
144
145 if (wqe_pool >= 0) {
146 status =
147 __cvmx_helper_initialize_fpa_pool(wqe_pool, wqe_size,
148 wqe_entries,
149 "Work Queue Entries");
150 if (status)
151 return status;
152 }
153
154 if (pko_pool >= 0) {
155 status =
156 __cvmx_helper_initialize_fpa_pool(pko_pool, pko_size,
157 pko_buffers,
158 "PKO Command Buffers");
159 if (status)
160 return status;
161 }
162
163 if (tim_pool >= 0) {
164 status =
165 __cvmx_helper_initialize_fpa_pool(tim_pool, tim_size,
166 tim_buffers,
167 "TIM Command Buffers");
168 if (status)
169 return status;
170 }
171
172 if (dfa_pool >= 0) {
173 status =
174 __cvmx_helper_initialize_fpa_pool(dfa_pool, dfa_size,
175 dfa_buffers,
176 "DFA Command Buffers");
177 if (status)
178 return status;
179 }
180
181 return 0;
182}
183
184/**
185 * Allocate memory and initialize the FPA pools using memory
186 * from cvmx-bootmem. Sizes of each element in the pools is
187 * controlled by the cvmx-config.h header file. Specifying
188 * zero for any parameter will cause that FPA pool to not be
189 * setup. This is useful if you aren't using some of the
190 * hardware and want to save memory.
191 *
192 * @packet_buffers:
193 * Number of packet buffers to allocate
194 * @work_queue_entries:
195 * Number of work queue entries
196 * @pko_buffers:
197 * PKO Command buffers. You should at minimum have two per
198 * each PKO queue.
199 * @tim_buffers:
200 * TIM ring buffer command queues. At least two per timer bucket
201 * is recommened.
202 * @dfa_buffers:
203 * DFA command buffer. A relatively small (32 for example)
204 * number should work.
205 * Returns Zero on success, non-zero if out of memory
206 */
207int cvmx_helper_initialize_fpa(int packet_buffers, int work_queue_entries,
208 int pko_buffers, int tim_buffers,
209 int dfa_buffers)
210{
211#ifndef CVMX_FPA_PACKET_POOL
212#define CVMX_FPA_PACKET_POOL -1
213#define CVMX_FPA_PACKET_POOL_SIZE 0
214#endif
215#ifndef CVMX_FPA_WQE_POOL
216#define CVMX_FPA_WQE_POOL -1
217#define CVMX_FPA_WQE_POOL_SIZE 0
218#endif
219#ifndef CVMX_FPA_OUTPUT_BUFFER_POOL
220#define CVMX_FPA_OUTPUT_BUFFER_POOL -1
221#define CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE 0
222#endif
223#ifndef CVMX_FPA_TIMER_POOL
224#define CVMX_FPA_TIMER_POOL -1
225#define CVMX_FPA_TIMER_POOL_SIZE 0
226#endif
227#ifndef CVMX_FPA_DFA_POOL
228#define CVMX_FPA_DFA_POOL -1
229#define CVMX_FPA_DFA_POOL_SIZE 0
230#endif
231 return __cvmx_helper_initialize_fpa(CVMX_FPA_PACKET_POOL,
232 CVMX_FPA_PACKET_POOL_SIZE,
233 packet_buffers, CVMX_FPA_WQE_POOL,
234 CVMX_FPA_WQE_POOL_SIZE,
235 work_queue_entries,
236 CVMX_FPA_OUTPUT_BUFFER_POOL,
237 CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE,
238 pko_buffers, CVMX_FPA_TIMER_POOL,
239 CVMX_FPA_TIMER_POOL_SIZE,
240 tim_buffers, CVMX_FPA_DFA_POOL,
241 CVMX_FPA_DFA_POOL_SIZE,
242 dfa_buffers);
243}
diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
index ffd4ae660f79..7fb1f222b8a5 100644
--- a/arch/mips/cavium-octeon/octeon-irq.c
+++ b/arch/mips/cavium-octeon/octeon-irq.c
@@ -3,14 +3,17 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2004-2008, 2009, 2010, 2011 Cavium Networks 6 * Copyright (C) 2004-2012 Cavium, Inc.
7 */ 7 */
8 8
9#include <linux/interrupt.h> 9#include <linux/interrupt.h>
10#include <linux/irqdomain.h>
10#include <linux/bitops.h> 11#include <linux/bitops.h>
11#include <linux/percpu.h> 12#include <linux/percpu.h>
13#include <linux/slab.h>
12#include <linux/irq.h> 14#include <linux/irq.h>
13#include <linux/smp.h> 15#include <linux/smp.h>
16#include <linux/of.h>
14 17
15#include <asm/octeon/octeon.h> 18#include <asm/octeon/octeon.h>
16 19
@@ -42,9 +45,9 @@ struct octeon_core_chip_data {
42 45
43static struct octeon_core_chip_data octeon_irq_core_chip_data[MIPS_CORE_IRQ_LINES]; 46static struct octeon_core_chip_data octeon_irq_core_chip_data[MIPS_CORE_IRQ_LINES];
44 47
45static void __init octeon_irq_set_ciu_mapping(int irq, int line, int bit, 48static void octeon_irq_set_ciu_mapping(int irq, int line, int bit,
46 struct irq_chip *chip, 49 struct irq_chip *chip,
47 irq_flow_handler_t handler) 50 irq_flow_handler_t handler)
48{ 51{
49 union octeon_ciu_chip_data cd; 52 union octeon_ciu_chip_data cd;
50 53
@@ -505,6 +508,85 @@ static void octeon_irq_ciu_enable_all_v2(struct irq_data *data)
505 } 508 }
506} 509}
507 510
511static void octeon_irq_gpio_setup(struct irq_data *data)
512{
513 union cvmx_gpio_bit_cfgx cfg;
514 union octeon_ciu_chip_data cd;
515 u32 t = irqd_get_trigger_type(data);
516
517 cd.p = irq_data_get_irq_chip_data(data);
518
519 cfg.u64 = 0;
520 cfg.s.int_en = 1;
521 cfg.s.int_type = (t & IRQ_TYPE_EDGE_BOTH) != 0;
522 cfg.s.rx_xor = (t & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING)) != 0;
523
524 /* 140 nS glitch filter*/
525 cfg.s.fil_cnt = 7;
526 cfg.s.fil_sel = 3;
527
528 cvmx_write_csr(CVMX_GPIO_BIT_CFGX(cd.s.bit - 16), cfg.u64);
529}
530
531static void octeon_irq_ciu_enable_gpio_v2(struct irq_data *data)
532{
533 octeon_irq_gpio_setup(data);
534 octeon_irq_ciu_enable_v2(data);
535}
536
537static void octeon_irq_ciu_enable_gpio(struct irq_data *data)
538{
539 octeon_irq_gpio_setup(data);
540 octeon_irq_ciu_enable(data);
541}
542
543static int octeon_irq_ciu_gpio_set_type(struct irq_data *data, unsigned int t)
544{
545 irqd_set_trigger_type(data, t);
546 octeon_irq_gpio_setup(data);
547
548 return IRQ_SET_MASK_OK;
549}
550
551static void octeon_irq_ciu_disable_gpio_v2(struct irq_data *data)
552{
553 union octeon_ciu_chip_data cd;
554
555 cd.p = irq_data_get_irq_chip_data(data);
556 cvmx_write_csr(CVMX_GPIO_BIT_CFGX(cd.s.bit - 16), 0);
557
558 octeon_irq_ciu_disable_all_v2(data);
559}
560
561static void octeon_irq_ciu_disable_gpio(struct irq_data *data)
562{
563 union octeon_ciu_chip_data cd;
564
565 cd.p = irq_data_get_irq_chip_data(data);
566 cvmx_write_csr(CVMX_GPIO_BIT_CFGX(cd.s.bit - 16), 0);
567
568 octeon_irq_ciu_disable_all(data);
569}
570
571static void octeon_irq_ciu_gpio_ack(struct irq_data *data)
572{
573 union octeon_ciu_chip_data cd;
574 u64 mask;
575
576 cd.p = irq_data_get_irq_chip_data(data);
577 mask = 1ull << (cd.s.bit - 16);
578
579 cvmx_write_csr(CVMX_GPIO_INT_CLR, mask);
580}
581
582static void octeon_irq_handle_gpio(unsigned int irq, struct irq_desc *desc)
583{
584 if (irqd_get_trigger_type(irq_desc_get_irq_data(desc)) & IRQ_TYPE_EDGE_BOTH)
585 handle_edge_irq(irq, desc);
586 else
587 handle_level_irq(irq, desc);
588}
589
508#ifdef CONFIG_SMP 590#ifdef CONFIG_SMP
509 591
510static void octeon_irq_cpu_offline_ciu(struct irq_data *data) 592static void octeon_irq_cpu_offline_ciu(struct irq_data *data)
@@ -650,18 +732,6 @@ static struct irq_chip octeon_irq_chip_ciu_v2 = {
650 .name = "CIU", 732 .name = "CIU",
651 .irq_enable = octeon_irq_ciu_enable_v2, 733 .irq_enable = octeon_irq_ciu_enable_v2,
652 .irq_disable = octeon_irq_ciu_disable_all_v2, 734 .irq_disable = octeon_irq_ciu_disable_all_v2,
653 .irq_mask = octeon_irq_ciu_disable_local_v2,
654 .irq_unmask = octeon_irq_ciu_enable_v2,
655#ifdef CONFIG_SMP
656 .irq_set_affinity = octeon_irq_ciu_set_affinity_v2,
657 .irq_cpu_offline = octeon_irq_cpu_offline_ciu,
658#endif
659};
660
661static struct irq_chip octeon_irq_chip_ciu_edge_v2 = {
662 .name = "CIU-E",
663 .irq_enable = octeon_irq_ciu_enable_v2,
664 .irq_disable = octeon_irq_ciu_disable_all_v2,
665 .irq_ack = octeon_irq_ciu_ack, 735 .irq_ack = octeon_irq_ciu_ack,
666 .irq_mask = octeon_irq_ciu_disable_local_v2, 736 .irq_mask = octeon_irq_ciu_disable_local_v2,
667 .irq_unmask = octeon_irq_ciu_enable_v2, 737 .irq_unmask = octeon_irq_ciu_enable_v2,
@@ -675,19 +745,8 @@ static struct irq_chip octeon_irq_chip_ciu = {
675 .name = "CIU", 745 .name = "CIU",
676 .irq_enable = octeon_irq_ciu_enable, 746 .irq_enable = octeon_irq_ciu_enable,
677 .irq_disable = octeon_irq_ciu_disable_all, 747 .irq_disable = octeon_irq_ciu_disable_all,
678 .irq_mask = octeon_irq_dummy_mask,
679#ifdef CONFIG_SMP
680 .irq_set_affinity = octeon_irq_ciu_set_affinity,
681 .irq_cpu_offline = octeon_irq_cpu_offline_ciu,
682#endif
683};
684
685static struct irq_chip octeon_irq_chip_ciu_edge = {
686 .name = "CIU-E",
687 .irq_enable = octeon_irq_ciu_enable,
688 .irq_disable = octeon_irq_ciu_disable_all,
689 .irq_mask = octeon_irq_dummy_mask,
690 .irq_ack = octeon_irq_ciu_ack, 748 .irq_ack = octeon_irq_ciu_ack,
749 .irq_mask = octeon_irq_dummy_mask,
691#ifdef CONFIG_SMP 750#ifdef CONFIG_SMP
692 .irq_set_affinity = octeon_irq_ciu_set_affinity, 751 .irq_set_affinity = octeon_irq_ciu_set_affinity,
693 .irq_cpu_offline = octeon_irq_cpu_offline_ciu, 752 .irq_cpu_offline = octeon_irq_cpu_offline_ciu,
@@ -717,6 +776,33 @@ static struct irq_chip octeon_irq_chip_ciu_mbox = {
717 .flags = IRQCHIP_ONOFFLINE_ENABLED, 776 .flags = IRQCHIP_ONOFFLINE_ENABLED,
718}; 777};
719 778
779static struct irq_chip octeon_irq_chip_ciu_gpio_v2 = {
780 .name = "CIU-GPIO",
781 .irq_enable = octeon_irq_ciu_enable_gpio_v2,
782 .irq_disable = octeon_irq_ciu_disable_gpio_v2,
783 .irq_ack = octeon_irq_ciu_gpio_ack,
784 .irq_mask = octeon_irq_ciu_disable_local_v2,
785 .irq_unmask = octeon_irq_ciu_enable_v2,
786 .irq_set_type = octeon_irq_ciu_gpio_set_type,
787#ifdef CONFIG_SMP
788 .irq_set_affinity = octeon_irq_ciu_set_affinity_v2,
789#endif
790 .flags = IRQCHIP_SET_TYPE_MASKED,
791};
792
793static struct irq_chip octeon_irq_chip_ciu_gpio = {
794 .name = "CIU-GPIO",
795 .irq_enable = octeon_irq_ciu_enable_gpio,
796 .irq_disable = octeon_irq_ciu_disable_gpio,
797 .irq_mask = octeon_irq_dummy_mask,
798 .irq_ack = octeon_irq_ciu_gpio_ack,
799 .irq_set_type = octeon_irq_ciu_gpio_set_type,
800#ifdef CONFIG_SMP
801 .irq_set_affinity = octeon_irq_ciu_set_affinity,
802#endif
803 .flags = IRQCHIP_SET_TYPE_MASKED,
804};
805
720/* 806/*
721 * Watchdog interrupts are special. They are associated with a single 807 * Watchdog interrupts are special. They are associated with a single
722 * core, so we hardwire the affinity to that core. 808 * core, so we hardwire the affinity to that core.
@@ -764,6 +850,178 @@ static struct irq_chip octeon_irq_chip_ciu_wd = {
764 .irq_mask = octeon_irq_dummy_mask, 850 .irq_mask = octeon_irq_dummy_mask,
765}; 851};
766 852
853static bool octeon_irq_ciu_is_edge(unsigned int line, unsigned int bit)
854{
855 bool edge = false;
856
857 if (line == 0)
858 switch (bit) {
859 case 48 ... 49: /* GMX DRP */
860 case 50: /* IPD_DRP */
861 case 52 ... 55: /* Timers */
862 case 58: /* MPI */
863 edge = true;
864 break;
865 default:
866 break;
867 }
868 else /* line == 1 */
869 switch (bit) {
870 case 47: /* PTP */
871 edge = true;
872 break;
873 default:
874 break;
875 }
876 return edge;
877}
878
879struct octeon_irq_gpio_domain_data {
880 unsigned int base_hwirq;
881};
882
883static int octeon_irq_gpio_xlat(struct irq_domain *d,
884 struct device_node *node,
885 const u32 *intspec,
886 unsigned int intsize,
887 unsigned long *out_hwirq,
888 unsigned int *out_type)
889{
890 unsigned int type;
891 unsigned int pin;
892 unsigned int trigger;
893 struct octeon_irq_gpio_domain_data *gpiod;
894
895 if (d->of_node != node)
896 return -EINVAL;
897
898 if (intsize < 2)
899 return -EINVAL;
900
901 pin = intspec[0];
902 if (pin >= 16)
903 return -EINVAL;
904
905 trigger = intspec[1];
906
907 switch (trigger) {
908 case 1:
909 type = IRQ_TYPE_EDGE_RISING;
910 break;
911 case 2:
912 type = IRQ_TYPE_EDGE_FALLING;
913 break;
914 case 4:
915 type = IRQ_TYPE_LEVEL_HIGH;
916 break;
917 case 8:
918 type = IRQ_TYPE_LEVEL_LOW;
919 break;
920 default:
921 pr_err("Error: (%s) Invalid irq trigger specification: %x\n",
922 node->name,
923 trigger);
924 type = IRQ_TYPE_LEVEL_LOW;
925 break;
926 }
927 *out_type = type;
928 gpiod = d->host_data;
929 *out_hwirq = gpiod->base_hwirq + pin;
930
931 return 0;
932}
933
934static int octeon_irq_ciu_xlat(struct irq_domain *d,
935 struct device_node *node,
936 const u32 *intspec,
937 unsigned int intsize,
938 unsigned long *out_hwirq,
939 unsigned int *out_type)
940{
941 unsigned int ciu, bit;
942
943 ciu = intspec[0];
944 bit = intspec[1];
945
946 if (ciu > 1 || bit > 63)
947 return -EINVAL;
948
949 /* These are the GPIO lines */
950 if (ciu == 0 && bit >= 16 && bit < 32)
951 return -EINVAL;
952
953 *out_hwirq = (ciu << 6) | bit;
954 *out_type = 0;
955
956 return 0;
957}
958
959static struct irq_chip *octeon_irq_ciu_chip;
960static struct irq_chip *octeon_irq_gpio_chip;
961
962static bool octeon_irq_virq_in_range(unsigned int virq)
963{
964 /* We cannot let it overflow the mapping array. */
965 if (virq < (1ul << 8 * sizeof(octeon_irq_ciu_to_irq[0][0])))
966 return true;
967
968 WARN_ONCE(true, "virq out of range %u.\n", virq);
969 return false;
970}
971
972static int octeon_irq_ciu_map(struct irq_domain *d,
973 unsigned int virq, irq_hw_number_t hw)
974{
975 unsigned int line = hw >> 6;
976 unsigned int bit = hw & 63;
977
978 if (!octeon_irq_virq_in_range(virq))
979 return -EINVAL;
980
981 if (line > 1 || octeon_irq_ciu_to_irq[line][bit] != 0)
982 return -EINVAL;
983
984 if (octeon_irq_ciu_is_edge(line, bit))
985 octeon_irq_set_ciu_mapping(virq, line, bit,
986 octeon_irq_ciu_chip,
987 handle_edge_irq);
988 else
989 octeon_irq_set_ciu_mapping(virq, line, bit,
990 octeon_irq_ciu_chip,
991 handle_level_irq);
992
993 return 0;
994}
995
996static int octeon_irq_gpio_map(struct irq_domain *d,
997 unsigned int virq, irq_hw_number_t hw)
998{
999 unsigned int line = hw >> 6;
1000 unsigned int bit = hw & 63;
1001
1002 if (!octeon_irq_virq_in_range(virq))
1003 return -EINVAL;
1004
1005 if (line > 1 || octeon_irq_ciu_to_irq[line][bit] != 0)
1006 return -EINVAL;
1007
1008 octeon_irq_set_ciu_mapping(virq, line, bit,
1009 octeon_irq_gpio_chip,
1010 octeon_irq_handle_gpio);
1011
1012 return 0;
1013}
1014
1015static struct irq_domain_ops octeon_irq_domain_ciu_ops = {
1016 .map = octeon_irq_ciu_map,
1017 .xlate = octeon_irq_ciu_xlat,
1018};
1019
1020static struct irq_domain_ops octeon_irq_domain_gpio_ops = {
1021 .map = octeon_irq_gpio_map,
1022 .xlate = octeon_irq_gpio_xlat,
1023};
1024
767static void octeon_irq_ip2_v1(void) 1025static void octeon_irq_ip2_v1(void)
768{ 1026{
769 const unsigned long core_id = cvmx_get_core_num(); 1027 const unsigned long core_id = cvmx_get_core_num();
@@ -887,9 +1145,10 @@ static void __init octeon_irq_init_ciu(void)
887{ 1145{
888 unsigned int i; 1146 unsigned int i;
889 struct irq_chip *chip; 1147 struct irq_chip *chip;
890 struct irq_chip *chip_edge;
891 struct irq_chip *chip_mbox; 1148 struct irq_chip *chip_mbox;
892 struct irq_chip *chip_wd; 1149 struct irq_chip *chip_wd;
1150 struct device_node *gpio_node;
1151 struct device_node *ciu_node;
893 1152
894 octeon_irq_init_ciu_percpu(); 1153 octeon_irq_init_ciu_percpu();
895 octeon_irq_setup_secondary = octeon_irq_setup_secondary_ciu; 1154 octeon_irq_setup_secondary = octeon_irq_setup_secondary_ciu;
@@ -901,17 +1160,18 @@ static void __init octeon_irq_init_ciu(void)
901 octeon_irq_ip2 = octeon_irq_ip2_v2; 1160 octeon_irq_ip2 = octeon_irq_ip2_v2;
902 octeon_irq_ip3 = octeon_irq_ip3_v2; 1161 octeon_irq_ip3 = octeon_irq_ip3_v2;
903 chip = &octeon_irq_chip_ciu_v2; 1162 chip = &octeon_irq_chip_ciu_v2;
904 chip_edge = &octeon_irq_chip_ciu_edge_v2;
905 chip_mbox = &octeon_irq_chip_ciu_mbox_v2; 1163 chip_mbox = &octeon_irq_chip_ciu_mbox_v2;
906 chip_wd = &octeon_irq_chip_ciu_wd_v2; 1164 chip_wd = &octeon_irq_chip_ciu_wd_v2;
1165 octeon_irq_gpio_chip = &octeon_irq_chip_ciu_gpio_v2;
907 } else { 1166 } else {
908 octeon_irq_ip2 = octeon_irq_ip2_v1; 1167 octeon_irq_ip2 = octeon_irq_ip2_v1;
909 octeon_irq_ip3 = octeon_irq_ip3_v1; 1168 octeon_irq_ip3 = octeon_irq_ip3_v1;
910 chip = &octeon_irq_chip_ciu; 1169 chip = &octeon_irq_chip_ciu;
911 chip_edge = &octeon_irq_chip_ciu_edge;
912 chip_mbox = &octeon_irq_chip_ciu_mbox; 1170 chip_mbox = &octeon_irq_chip_ciu_mbox;
913 chip_wd = &octeon_irq_chip_ciu_wd; 1171 chip_wd = &octeon_irq_chip_ciu_wd;
1172 octeon_irq_gpio_chip = &octeon_irq_chip_ciu_gpio;
914 } 1173 }
1174 octeon_irq_ciu_chip = chip;
915 octeon_irq_ip4 = octeon_irq_ip4_mask; 1175 octeon_irq_ip4 = octeon_irq_ip4_mask;
916 1176
917 /* Mips internal */ 1177 /* Mips internal */
@@ -920,80 +1180,49 @@ static void __init octeon_irq_init_ciu(void)
920 /* CIU_0 */ 1180 /* CIU_0 */
921 for (i = 0; i < 16; i++) 1181 for (i = 0; i < 16; i++)
922 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_WORKQ0, 0, i + 0, chip, handle_level_irq); 1182 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_WORKQ0, 0, i + 0, chip, handle_level_irq);
923 for (i = 0; i < 16; i++)
924 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_GPIO0, 0, i + 16, chip, handle_level_irq);
925 1183
926 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MBOX0, 0, 32, chip_mbox, handle_percpu_irq); 1184 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MBOX0, 0, 32, chip_mbox, handle_percpu_irq);
927 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MBOX1, 0, 33, chip_mbox, handle_percpu_irq); 1185 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MBOX1, 0, 33, chip_mbox, handle_percpu_irq);
928 1186
929 octeon_irq_set_ciu_mapping(OCTEON_IRQ_UART0, 0, 34, chip, handle_level_irq);
930 octeon_irq_set_ciu_mapping(OCTEON_IRQ_UART1, 0, 35, chip, handle_level_irq);
931
932 for (i = 0; i < 4; i++) 1187 for (i = 0; i < 4; i++)
933 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_PCI_INT0, 0, i + 36, chip, handle_level_irq); 1188 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_PCI_INT0, 0, i + 36, chip, handle_level_irq);
934 for (i = 0; i < 4; i++) 1189 for (i = 0; i < 4; i++)
935 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_PCI_MSI0, 0, i + 40, chip, handle_level_irq); 1190 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_PCI_MSI0, 0, i + 40, chip, handle_level_irq);
936 1191
937 octeon_irq_set_ciu_mapping(OCTEON_IRQ_TWSI, 0, 45, chip, handle_level_irq);
938 octeon_irq_set_ciu_mapping(OCTEON_IRQ_RML, 0, 46, chip, handle_level_irq); 1192 octeon_irq_set_ciu_mapping(OCTEON_IRQ_RML, 0, 46, chip, handle_level_irq);
939 octeon_irq_set_ciu_mapping(OCTEON_IRQ_TRACE0, 0, 47, chip, handle_level_irq);
940
941 for (i = 0; i < 2; i++)
942 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_GMX_DRP0, 0, i + 48, chip_edge, handle_edge_irq);
943
944 octeon_irq_set_ciu_mapping(OCTEON_IRQ_IPD_DRP, 0, 50, chip_edge, handle_edge_irq);
945 octeon_irq_set_ciu_mapping(OCTEON_IRQ_KEY_ZERO, 0, 51, chip_edge, handle_edge_irq);
946
947 for (i = 0; i < 4; i++) 1193 for (i = 0; i < 4; i++)
948 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_TIMER0, 0, i + 52, chip_edge, handle_edge_irq); 1194 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_TIMER0, 0, i + 52, chip, handle_edge_irq);
949 1195
950 octeon_irq_set_ciu_mapping(OCTEON_IRQ_USB0, 0, 56, chip, handle_level_irq); 1196 octeon_irq_set_ciu_mapping(OCTEON_IRQ_USB0, 0, 56, chip, handle_level_irq);
951 octeon_irq_set_ciu_mapping(OCTEON_IRQ_PCM, 0, 57, chip, handle_level_irq);
952 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MPI, 0, 58, chip, handle_level_irq);
953 octeon_irq_set_ciu_mapping(OCTEON_IRQ_TWSI2, 0, 59, chip, handle_level_irq);
954 octeon_irq_set_ciu_mapping(OCTEON_IRQ_POWIQ, 0, 60, chip, handle_level_irq);
955 octeon_irq_set_ciu_mapping(OCTEON_IRQ_IPDPPTHR, 0, 61, chip, handle_level_irq);
956 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MII0, 0, 62, chip, handle_level_irq);
957 octeon_irq_set_ciu_mapping(OCTEON_IRQ_BOOTDMA, 0, 63, chip, handle_level_irq); 1197 octeon_irq_set_ciu_mapping(OCTEON_IRQ_BOOTDMA, 0, 63, chip, handle_level_irq);
958 1198
959 /* CIU_1 */ 1199 /* CIU_1 */
960 for (i = 0; i < 16; i++) 1200 for (i = 0; i < 16; i++)
961 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_WDOG0, 1, i + 0, chip_wd, handle_level_irq); 1201 octeon_irq_set_ciu_mapping(i + OCTEON_IRQ_WDOG0, 1, i + 0, chip_wd, handle_level_irq);
962 1202
963 octeon_irq_set_ciu_mapping(OCTEON_IRQ_UART2, 1, 16, chip, handle_level_irq);
964 octeon_irq_set_ciu_mapping(OCTEON_IRQ_USB1, 1, 17, chip, handle_level_irq); 1203 octeon_irq_set_ciu_mapping(OCTEON_IRQ_USB1, 1, 17, chip, handle_level_irq);
965 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MII1, 1, 18, chip, handle_level_irq); 1204
966 octeon_irq_set_ciu_mapping(OCTEON_IRQ_NAND, 1, 19, chip, handle_level_irq); 1205 gpio_node = of_find_compatible_node(NULL, NULL, "cavium,octeon-3860-gpio");
967 octeon_irq_set_ciu_mapping(OCTEON_IRQ_MIO, 1, 20, chip, handle_level_irq); 1206 if (gpio_node) {
968 octeon_irq_set_ciu_mapping(OCTEON_IRQ_IOB, 1, 21, chip, handle_level_irq); 1207 struct octeon_irq_gpio_domain_data *gpiod;
969 octeon_irq_set_ciu_mapping(OCTEON_IRQ_FPA, 1, 22, chip, handle_level_irq); 1208
970 octeon_irq_set_ciu_mapping(OCTEON_IRQ_POW, 1, 23, chip, handle_level_irq); 1209 gpiod = kzalloc(sizeof(*gpiod), GFP_KERNEL);
971 octeon_irq_set_ciu_mapping(OCTEON_IRQ_L2C, 1, 24, chip, handle_level_irq); 1210 if (gpiod) {
972 octeon_irq_set_ciu_mapping(OCTEON_IRQ_IPD, 1, 25, chip, handle_level_irq); 1211 /* gpio domain host_data is the base hwirq number. */
973 octeon_irq_set_ciu_mapping(OCTEON_IRQ_PIP, 1, 26, chip, handle_level_irq); 1212 gpiod->base_hwirq = 16;
974 octeon_irq_set_ciu_mapping(OCTEON_IRQ_PKO, 1, 27, chip, handle_level_irq); 1213 irq_domain_add_linear(gpio_node, 16, &octeon_irq_domain_gpio_ops, gpiod);
975 octeon_irq_set_ciu_mapping(OCTEON_IRQ_ZIP, 1, 28, chip, handle_level_irq); 1214 of_node_put(gpio_node);
976 octeon_irq_set_ciu_mapping(OCTEON_IRQ_TIM, 1, 29, chip, handle_level_irq); 1215 } else
977 octeon_irq_set_ciu_mapping(OCTEON_IRQ_RAD, 1, 30, chip, handle_level_irq); 1216 pr_warn("Cannot allocate memory for GPIO irq_domain.\n");
978 octeon_irq_set_ciu_mapping(OCTEON_IRQ_KEY, 1, 31, chip, handle_level_irq); 1217 } else
979 octeon_irq_set_ciu_mapping(OCTEON_IRQ_DFA, 1, 32, chip, handle_level_irq); 1218 pr_warn("Cannot find device node for cavium,octeon-3860-gpio.\n");
980 octeon_irq_set_ciu_mapping(OCTEON_IRQ_USBCTL, 1, 33, chip, handle_level_irq); 1219
981 octeon_irq_set_ciu_mapping(OCTEON_IRQ_SLI, 1, 34, chip, handle_level_irq); 1220 ciu_node = of_find_compatible_node(NULL, NULL, "cavium,octeon-3860-ciu");
982 octeon_irq_set_ciu_mapping(OCTEON_IRQ_DPI, 1, 35, chip, handle_level_irq); 1221 if (ciu_node) {
983 1222 irq_domain_add_tree(ciu_node, &octeon_irq_domain_ciu_ops, NULL);
984 octeon_irq_set_ciu_mapping(OCTEON_IRQ_AGX0, 1, 36, chip, handle_level_irq); 1223 of_node_put(ciu_node);
985 1224 } else
986 octeon_irq_set_ciu_mapping(OCTEON_IRQ_AGL, 1, 46, chip, handle_level_irq); 1225 pr_warn("Cannot find device node for cavium,octeon-3860-ciu.\n");
987
988 octeon_irq_set_ciu_mapping(OCTEON_IRQ_PTP, 1, 47, chip_edge, handle_edge_irq);
989
990 octeon_irq_set_ciu_mapping(OCTEON_IRQ_PEM0, 1, 48, chip, handle_level_irq);
991 octeon_irq_set_ciu_mapping(OCTEON_IRQ_PEM1, 1, 49, chip, handle_level_irq);
992 octeon_irq_set_ciu_mapping(OCTEON_IRQ_SRIO0, 1, 50, chip, handle_level_irq);
993 octeon_irq_set_ciu_mapping(OCTEON_IRQ_SRIO1, 1, 51, chip, handle_level_irq);
994 octeon_irq_set_ciu_mapping(OCTEON_IRQ_LMC0, 1, 52, chip, handle_level_irq);
995 octeon_irq_set_ciu_mapping(OCTEON_IRQ_DFM, 1, 56, chip, handle_level_irq);
996 octeon_irq_set_ciu_mapping(OCTEON_IRQ_RST, 1, 63, chip, handle_level_irq);
997 1226
998 /* Enable the CIU lines */ 1227 /* Enable the CIU lines */
999 set_c0_status(STATUSF_IP3 | STATUSF_IP2); 1228 set_c0_status(STATUSF_IP3 | STATUSF_IP2);
diff --git a/arch/mips/cavium-octeon/octeon-memcpy.S b/arch/mips/cavium-octeon/octeon-memcpy.S
index 88e0cddca205..db478dbb9c7b 100644
--- a/arch/mips/cavium-octeon/octeon-memcpy.S
+++ b/arch/mips/cavium-octeon/octeon-memcpy.S
@@ -164,6 +164,14 @@
164 .set noat 164 .set noat
165 165
166/* 166/*
167 * t7 is used as a flag to note inatomic mode.
168 */
169LEAF(__copy_user_inatomic)
170 b __copy_user_common
171 li t7, 1
172 END(__copy_user_inatomic)
173
174/*
167 * A combined memcpy/__copy_user 175 * A combined memcpy/__copy_user
168 * __copy_user sets len to 0 for success; else to an upper bound of 176 * __copy_user sets len to 0 for success; else to an upper bound of
169 * the number of uncopied bytes. 177 * the number of uncopied bytes.
@@ -174,6 +182,8 @@ LEAF(memcpy) /* a0=dst a1=src a2=len */
174 move v0, dst /* return value */ 182 move v0, dst /* return value */
175__memcpy: 183__memcpy:
176FEXPORT(__copy_user) 184FEXPORT(__copy_user)
185 li t7, 0 /* not inatomic */
186__copy_user_common:
177 /* 187 /*
178 * Note: dst & src may be unaligned, len may be 0 188 * Note: dst & src may be unaligned, len may be 0
179 * Temps 189 * Temps
@@ -412,7 +422,6 @@ l_exc_copy:
412 * Assumes src < THREAD_BUADDR($28) 422 * Assumes src < THREAD_BUADDR($28)
413 */ 423 */
414 LOAD t0, TI_TASK($28) 424 LOAD t0, TI_TASK($28)
415 nop
416 LOAD t0, THREAD_BUADDR(t0) 425 LOAD t0, THREAD_BUADDR(t0)
4171: 4261:
418EXC( lb t1, 0(src), l_exc) 427EXC( lb t1, 0(src), l_exc)
@@ -422,10 +431,9 @@ EXC( lb t1, 0(src), l_exc)
422 ADD dst, dst, 1 431 ADD dst, dst, 1
423l_exc: 432l_exc:
424 LOAD t0, TI_TASK($28) 433 LOAD t0, TI_TASK($28)
425 nop
426 LOAD t0, THREAD_BUADDR(t0) # t0 is just past last good address 434 LOAD t0, THREAD_BUADDR(t0) # t0 is just past last good address
427 nop
428 SUB len, AT, t0 # len number of uncopied bytes 435 SUB len, AT, t0 # len number of uncopied bytes
436 bnez t7, 2f /* Skip the zeroing out part if inatomic */
429 /* 437 /*
430 * Here's where we rely on src and dst being incremented in tandem, 438 * Here's where we rely on src and dst being incremented in tandem,
431 * See (3) above. 439 * See (3) above.
@@ -443,7 +451,7 @@ l_exc:
443 ADD dst, dst, 1 451 ADD dst, dst, 1
444 bnez src, 1b 452 bnez src, 1b
445 SUB src, src, 1 453 SUB src, src, 1
446 jr ra 4542: jr ra
447 nop 455 nop
448 456
449 457
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index cd61d7281d91..0938df10a71c 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2004-2010 Cavium Networks 6 * Copyright (C) 2004-2011 Cavium Networks
7 * Copyright (C) 2008 Wind River Systems 7 * Copyright (C) 2008 Wind River Systems
8 */ 8 */
9 9
@@ -13,10 +13,16 @@
13#include <linux/usb.h> 13#include <linux/usb.h>
14#include <linux/dma-mapping.h> 14#include <linux/dma-mapping.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/slab.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/of_platform.h>
19#include <linux/of_fdt.h>
20#include <linux/libfdt.h>
17 21
18#include <asm/octeon/octeon.h> 22#include <asm/octeon/octeon.h>
19#include <asm/octeon/cvmx-rnm-defs.h> 23#include <asm/octeon/cvmx-rnm-defs.h>
24#include <asm/octeon/cvmx-helper.h>
25#include <asm/octeon/cvmx-helper-board.h>
20 26
21static struct octeon_cf_data octeon_cf_data; 27static struct octeon_cf_data octeon_cf_data;
22 28
@@ -162,182 +168,6 @@ out:
162} 168}
163device_initcall(octeon_rng_device_init); 169device_initcall(octeon_rng_device_init);
164 170
165static struct i2c_board_info __initdata octeon_i2c_devices[] = {
166 {
167 I2C_BOARD_INFO("ds1337", 0x68),
168 },
169};
170
171static int __init octeon_i2c_devices_init(void)
172{
173 return i2c_register_board_info(0, octeon_i2c_devices,
174 ARRAY_SIZE(octeon_i2c_devices));
175}
176arch_initcall(octeon_i2c_devices_init);
177
178#define OCTEON_I2C_IO_BASE 0x1180000001000ull
179#define OCTEON_I2C_IO_UNIT_OFFSET 0x200
180
181static struct octeon_i2c_data octeon_i2c_data[2];
182
183static int __init octeon_i2c_device_init(void)
184{
185 struct platform_device *pd;
186 int ret = 0;
187 int port, num_ports;
188
189 struct resource i2c_resources[] = {
190 {
191 .flags = IORESOURCE_MEM,
192 }, {
193 .flags = IORESOURCE_IRQ,
194 }
195 };
196
197 if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX))
198 num_ports = 2;
199 else
200 num_ports = 1;
201
202 for (port = 0; port < num_ports; port++) {
203 octeon_i2c_data[port].sys_freq = octeon_get_io_clock_rate();
204 /*FIXME: should be examined. At the moment is set for 100Khz */
205 octeon_i2c_data[port].i2c_freq = 100000;
206
207 pd = platform_device_alloc("i2c-octeon", port);
208 if (!pd) {
209 ret = -ENOMEM;
210 goto out;
211 }
212
213 pd->dev.platform_data = octeon_i2c_data + port;
214
215 i2c_resources[0].start =
216 OCTEON_I2C_IO_BASE + (port * OCTEON_I2C_IO_UNIT_OFFSET);
217 i2c_resources[0].end = i2c_resources[0].start + 0x1f;
218 switch (port) {
219 case 0:
220 i2c_resources[1].start = OCTEON_IRQ_TWSI;
221 i2c_resources[1].end = OCTEON_IRQ_TWSI;
222 break;
223 case 1:
224 i2c_resources[1].start = OCTEON_IRQ_TWSI2;
225 i2c_resources[1].end = OCTEON_IRQ_TWSI2;
226 break;
227 default:
228 BUG();
229 }
230
231 ret = platform_device_add_resources(pd,
232 i2c_resources,
233 ARRAY_SIZE(i2c_resources));
234 if (ret)
235 goto fail;
236
237 ret = platform_device_add(pd);
238 if (ret)
239 goto fail;
240 }
241 return ret;
242fail:
243 platform_device_put(pd);
244out:
245 return ret;
246}
247device_initcall(octeon_i2c_device_init);
248
249/* Octeon SMI/MDIO interface. */
250static int __init octeon_mdiobus_device_init(void)
251{
252 struct platform_device *pd;
253 int ret = 0;
254
255 if (octeon_is_simulation())
256 return 0; /* No mdio in the simulator. */
257
258 /* The bus number is the platform_device id. */
259 pd = platform_device_alloc("mdio-octeon", 0);
260 if (!pd) {
261 ret = -ENOMEM;
262 goto out;
263 }
264
265 ret = platform_device_add(pd);
266 if (ret)
267 goto fail;
268
269 return ret;
270fail:
271 platform_device_put(pd);
272
273out:
274 return ret;
275
276}
277device_initcall(octeon_mdiobus_device_init);
278
279/* Octeon mgmt port Ethernet interface. */
280static int __init octeon_mgmt_device_init(void)
281{
282 struct platform_device *pd;
283 int ret = 0;
284 int port, num_ports;
285
286 struct resource mgmt_port_resource = {
287 .flags = IORESOURCE_IRQ,
288 .start = -1,
289 .end = -1
290 };
291
292 if (!OCTEON_IS_MODEL(OCTEON_CN56XX) && !OCTEON_IS_MODEL(OCTEON_CN52XX))
293 return 0;
294
295 if (OCTEON_IS_MODEL(OCTEON_CN56XX))
296 num_ports = 1;
297 else
298 num_ports = 2;
299
300 for (port = 0; port < num_ports; port++) {
301 pd = platform_device_alloc("octeon_mgmt", port);
302 if (!pd) {
303 ret = -ENOMEM;
304 goto out;
305 }
306 /* No DMA restrictions */
307 pd->dev.coherent_dma_mask = DMA_BIT_MASK(64);
308 pd->dev.dma_mask = &pd->dev.coherent_dma_mask;
309
310 switch (port) {
311 case 0:
312 mgmt_port_resource.start = OCTEON_IRQ_MII0;
313 break;
314 case 1:
315 mgmt_port_resource.start = OCTEON_IRQ_MII1;
316 break;
317 default:
318 BUG();
319 }
320 mgmt_port_resource.end = mgmt_port_resource.start;
321
322 ret = platform_device_add_resources(pd, &mgmt_port_resource, 1);
323
324 if (ret)
325 goto fail;
326
327 ret = platform_device_add(pd);
328 if (ret)
329 goto fail;
330 }
331 return ret;
332fail:
333 platform_device_put(pd);
334
335out:
336 return ret;
337
338}
339device_initcall(octeon_mgmt_device_init);
340
341#ifdef CONFIG_USB 171#ifdef CONFIG_USB
342 172
343static int __init octeon_ehci_device_init(void) 173static int __init octeon_ehci_device_init(void)
@@ -440,6 +270,521 @@ device_initcall(octeon_ohci_device_init);
440 270
441#endif /* CONFIG_USB */ 271#endif /* CONFIG_USB */
442 272
273static struct of_device_id __initdata octeon_ids[] = {
274 { .compatible = "simple-bus", },
275 { .compatible = "cavium,octeon-6335-uctl", },
276 { .compatible = "cavium,octeon-3860-bootbus", },
277 { .compatible = "cavium,mdio-mux", },
278 { .compatible = "gpio-leds", },
279 {},
280};
281
282static bool __init octeon_has_88e1145(void)
283{
284 return !OCTEON_IS_MODEL(OCTEON_CN52XX) &&
285 !OCTEON_IS_MODEL(OCTEON_CN6XXX) &&
286 !OCTEON_IS_MODEL(OCTEON_CN56XX);
287}
288
289static void __init octeon_fdt_set_phy(int eth, int phy_addr)
290{
291 const __be32 *phy_handle;
292 const __be32 *alt_phy_handle;
293 const __be32 *reg;
294 u32 phandle;
295 int phy;
296 int alt_phy;
297 const char *p;
298 int current_len;
299 char new_name[20];
300
301 phy_handle = fdt_getprop(initial_boot_params, eth, "phy-handle", NULL);
302 if (!phy_handle)
303 return;
304
305 phandle = be32_to_cpup(phy_handle);
306 phy = fdt_node_offset_by_phandle(initial_boot_params, phandle);
307
308 alt_phy_handle = fdt_getprop(initial_boot_params, eth, "cavium,alt-phy-handle", NULL);
309 if (alt_phy_handle) {
310 u32 alt_phandle = be32_to_cpup(alt_phy_handle);
311 alt_phy = fdt_node_offset_by_phandle(initial_boot_params, alt_phandle);
312 } else {
313 alt_phy = -1;
314 }
315
316 if (phy_addr < 0 || phy < 0) {
317 /* Delete the PHY things */
318 fdt_nop_property(initial_boot_params, eth, "phy-handle");
319 /* This one may fail */
320 fdt_nop_property(initial_boot_params, eth, "cavium,alt-phy-handle");
321 if (phy >= 0)
322 fdt_nop_node(initial_boot_params, phy);
323 if (alt_phy >= 0)
324 fdt_nop_node(initial_boot_params, alt_phy);
325 return;
326 }
327
328 if (phy_addr >= 256 && alt_phy > 0) {
329 const struct fdt_property *phy_prop;
330 struct fdt_property *alt_prop;
331 u32 phy_handle_name;
332
333 /* Use the alt phy node instead.*/
334 phy_prop = fdt_get_property(initial_boot_params, eth, "phy-handle", NULL);
335 phy_handle_name = phy_prop->nameoff;
336 fdt_nop_node(initial_boot_params, phy);
337 fdt_nop_property(initial_boot_params, eth, "phy-handle");
338 alt_prop = fdt_get_property_w(initial_boot_params, eth, "cavium,alt-phy-handle", NULL);
339 alt_prop->nameoff = phy_handle_name;
340 phy = alt_phy;
341 }
342
343 phy_addr &= 0xff;
344
345 if (octeon_has_88e1145()) {
346 fdt_nop_property(initial_boot_params, phy, "marvell,reg-init");
347 memset(new_name, 0, sizeof(new_name));
348 strcpy(new_name, "marvell,88e1145");
349 p = fdt_getprop(initial_boot_params, phy, "compatible",
350 &current_len);
351 if (p && current_len >= strlen(new_name))
352 fdt_setprop_inplace(initial_boot_params, phy,
353 "compatible", new_name, current_len);
354 }
355
356 reg = fdt_getprop(initial_boot_params, phy, "reg", NULL);
357 if (phy_addr == be32_to_cpup(reg))
358 return;
359
360 fdt_setprop_inplace_cell(initial_boot_params, phy, "reg", phy_addr);
361
362 snprintf(new_name, sizeof(new_name), "ethernet-phy@%x", phy_addr);
363
364 p = fdt_get_name(initial_boot_params, phy, &current_len);
365 if (p && current_len == strlen(new_name))
366 fdt_set_name(initial_boot_params, phy, new_name);
367 else
368 pr_err("Error: could not rename ethernet phy: <%s>", p);
369}
370
371static void __init octeon_fdt_set_mac_addr(int n, u64 *pmac)
372{
373 u8 new_mac[6];
374 u64 mac = *pmac;
375 int r;
376
377 new_mac[0] = (mac >> 40) & 0xff;
378 new_mac[1] = (mac >> 32) & 0xff;
379 new_mac[2] = (mac >> 24) & 0xff;
380 new_mac[3] = (mac >> 16) & 0xff;
381 new_mac[4] = (mac >> 8) & 0xff;
382 new_mac[5] = mac & 0xff;
383
384 r = fdt_setprop_inplace(initial_boot_params, n, "local-mac-address",
385 new_mac, sizeof(new_mac));
386
387 if (r) {
388 pr_err("Setting \"local-mac-address\" failed %d", r);
389 return;
390 }
391 *pmac = mac + 1;
392}
393
394static void __init octeon_fdt_rm_ethernet(int node)
395{
396 const __be32 *phy_handle;
397
398 phy_handle = fdt_getprop(initial_boot_params, node, "phy-handle", NULL);
399 if (phy_handle) {
400 u32 ph = be32_to_cpup(phy_handle);
401 int p = fdt_node_offset_by_phandle(initial_boot_params, ph);
402 if (p >= 0)
403 fdt_nop_node(initial_boot_params, p);
404 }
405 fdt_nop_node(initial_boot_params, node);
406}
407
408static void __init octeon_fdt_pip_port(int iface, int i, int p, int max, u64 *pmac)
409{
410 char name_buffer[20];
411 int eth;
412 int phy_addr;
413 int ipd_port;
414
415 snprintf(name_buffer, sizeof(name_buffer), "ethernet@%x", p);
416 eth = fdt_subnode_offset(initial_boot_params, iface, name_buffer);
417 if (eth < 0)
418 return;
419 if (p > max) {
420 pr_debug("Deleting port %x:%x\n", i, p);
421 octeon_fdt_rm_ethernet(eth);
422 return;
423 }
424 if (OCTEON_IS_MODEL(OCTEON_CN68XX))
425 ipd_port = (0x100 * i) + (0x10 * p) + 0x800;
426 else
427 ipd_port = 16 * i + p;
428
429 phy_addr = cvmx_helper_board_get_mii_address(ipd_port);
430 octeon_fdt_set_phy(eth, phy_addr);
431 octeon_fdt_set_mac_addr(eth, pmac);
432}
433
434static void __init octeon_fdt_pip_iface(int pip, int idx, u64 *pmac)
435{
436 char name_buffer[20];
437 int iface;
438 int p;
439 int count;
440
441 count = cvmx_helper_interface_enumerate(idx);
442
443 snprintf(name_buffer, sizeof(name_buffer), "interface@%d", idx);
444 iface = fdt_subnode_offset(initial_boot_params, pip, name_buffer);
445 if (iface < 0)
446 return;
447
448 for (p = 0; p < 16; p++)
449 octeon_fdt_pip_port(iface, idx, p, count - 1, pmac);
450}
451
452int __init octeon_prune_device_tree(void)
453{
454 int i, max_port, uart_mask;
455 const char *pip_path;
456 const char *alias_prop;
457 char name_buffer[20];
458 int aliases;
459 u64 mac_addr_base;
460
461 if (fdt_check_header(initial_boot_params))
462 panic("Corrupt Device Tree.");
463
464 aliases = fdt_path_offset(initial_boot_params, "/aliases");
465 if (aliases < 0) {
466 pr_err("Error: No /aliases node in device tree.");
467 return -EINVAL;
468 }
469
470
471 mac_addr_base =
472 ((octeon_bootinfo->mac_addr_base[0] & 0xffull)) << 40 |
473 ((octeon_bootinfo->mac_addr_base[1] & 0xffull)) << 32 |
474 ((octeon_bootinfo->mac_addr_base[2] & 0xffull)) << 24 |
475 ((octeon_bootinfo->mac_addr_base[3] & 0xffull)) << 16 |
476 ((octeon_bootinfo->mac_addr_base[4] & 0xffull)) << 8 |
477 (octeon_bootinfo->mac_addr_base[5] & 0xffull);
478
479 if (OCTEON_IS_MODEL(OCTEON_CN52XX) || OCTEON_IS_MODEL(OCTEON_CN63XX))
480 max_port = 2;
481 else if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN68XX))
482 max_port = 1;
483 else
484 max_port = 0;
485
486 if (octeon_bootinfo->board_type == CVMX_BOARD_TYPE_NIC10E)
487 max_port = 0;
488
489 for (i = 0; i < 2; i++) {
490 int mgmt;
491 snprintf(name_buffer, sizeof(name_buffer),
492 "mix%d", i);
493 alias_prop = fdt_getprop(initial_boot_params, aliases,
494 name_buffer, NULL);
495 if (alias_prop) {
496 mgmt = fdt_path_offset(initial_boot_params, alias_prop);
497 if (mgmt < 0)
498 continue;
499 if (i >= max_port) {
500 pr_debug("Deleting mix%d\n", i);
501 octeon_fdt_rm_ethernet(mgmt);
502 fdt_nop_property(initial_boot_params, aliases,
503 name_buffer);
504 } else {
505 int phy_addr = cvmx_helper_board_get_mii_address(CVMX_HELPER_BOARD_MGMT_IPD_PORT + i);
506 octeon_fdt_set_phy(mgmt, phy_addr);
507 octeon_fdt_set_mac_addr(mgmt, &mac_addr_base);
508 }
509 }
510 }
511
512 pip_path = fdt_getprop(initial_boot_params, aliases, "pip", NULL);
513 if (pip_path) {
514 int pip = fdt_path_offset(initial_boot_params, pip_path);
515 if (pip >= 0)
516 for (i = 0; i <= 4; i++)
517 octeon_fdt_pip_iface(pip, i, &mac_addr_base);
518 }
519
520 /* I2C */
521 if (OCTEON_IS_MODEL(OCTEON_CN52XX) ||
522 OCTEON_IS_MODEL(OCTEON_CN63XX) ||
523 OCTEON_IS_MODEL(OCTEON_CN68XX) ||
524 OCTEON_IS_MODEL(OCTEON_CN56XX))
525 max_port = 2;
526 else
527 max_port = 1;
528
529 for (i = 0; i < 2; i++) {
530 int i2c;
531 snprintf(name_buffer, sizeof(name_buffer),
532 "twsi%d", i);
533 alias_prop = fdt_getprop(initial_boot_params, aliases,
534 name_buffer, NULL);
535
536 if (alias_prop) {
537 i2c = fdt_path_offset(initial_boot_params, alias_prop);
538 if (i2c < 0)
539 continue;
540 if (i >= max_port) {
541 pr_debug("Deleting twsi%d\n", i);
542 fdt_nop_node(initial_boot_params, i2c);
543 fdt_nop_property(initial_boot_params, aliases,
544 name_buffer);
545 }
546 }
547 }
548
549 /* SMI/MDIO */
550 if (OCTEON_IS_MODEL(OCTEON_CN68XX))
551 max_port = 4;
552 else if (OCTEON_IS_MODEL(OCTEON_CN52XX) ||
553 OCTEON_IS_MODEL(OCTEON_CN63XX) ||
554 OCTEON_IS_MODEL(OCTEON_CN56XX))
555 max_port = 2;
556 else
557 max_port = 1;
558
559 for (i = 0; i < 2; i++) {
560 int i2c;
561 snprintf(name_buffer, sizeof(name_buffer),
562 "smi%d", i);
563 alias_prop = fdt_getprop(initial_boot_params, aliases,
564 name_buffer, NULL);
565
566 if (alias_prop) {
567 i2c = fdt_path_offset(initial_boot_params, alias_prop);
568 if (i2c < 0)
569 continue;
570 if (i >= max_port) {
571 pr_debug("Deleting smi%d\n", i);
572 fdt_nop_node(initial_boot_params, i2c);
573 fdt_nop_property(initial_boot_params, aliases,
574 name_buffer);
575 }
576 }
577 }
578
579 /* Serial */
580 uart_mask = 3;
581
582 /* Right now CN52XX is the only chip with a third uart */
583 if (OCTEON_IS_MODEL(OCTEON_CN52XX))
584 uart_mask |= 4; /* uart2 */
585
586 for (i = 0; i < 3; i++) {
587 int uart;
588 snprintf(name_buffer, sizeof(name_buffer),
589 "uart%d", i);
590 alias_prop = fdt_getprop(initial_boot_params, aliases,
591 name_buffer, NULL);
592
593 if (alias_prop) {
594 uart = fdt_path_offset(initial_boot_params, alias_prop);
595 if (uart_mask & (1 << i))
596 continue;
597 pr_debug("Deleting uart%d\n", i);
598 fdt_nop_node(initial_boot_params, uart);
599 fdt_nop_property(initial_boot_params, aliases,
600 name_buffer);
601 }
602 }
603
604 /* Compact Flash */
605 alias_prop = fdt_getprop(initial_boot_params, aliases,
606 "cf0", NULL);
607 if (alias_prop) {
608 union cvmx_mio_boot_reg_cfgx mio_boot_reg_cfg;
609 unsigned long base_ptr, region_base, region_size;
610 unsigned long region1_base = 0;
611 unsigned long region1_size = 0;
612 int cs, bootbus;
613 bool is_16bit = false;
614 bool is_true_ide = false;
615 __be32 new_reg[6];
616 __be32 *ranges;
617 int len;
618
619 int cf = fdt_path_offset(initial_boot_params, alias_prop);
620 base_ptr = 0;
621 if (octeon_bootinfo->major_version == 1
622 && octeon_bootinfo->minor_version >= 1) {
623 if (octeon_bootinfo->compact_flash_common_base_addr)
624 base_ptr = octeon_bootinfo->compact_flash_common_base_addr;
625 } else {
626 base_ptr = 0x1d000800;
627 }
628
629 if (!base_ptr)
630 goto no_cf;
631
632 /* Find CS0 region. */
633 for (cs = 0; cs < 8; cs++) {
634 mio_boot_reg_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(cs));
635 region_base = mio_boot_reg_cfg.s.base << 16;
636 region_size = (mio_boot_reg_cfg.s.size + 1) << 16;
637 if (mio_boot_reg_cfg.s.en && base_ptr >= region_base
638 && base_ptr < region_base + region_size) {
639 is_16bit = mio_boot_reg_cfg.s.width;
640 break;
641 }
642 }
643 if (cs >= 7) {
644 /* cs and cs + 1 are CS0 and CS1, both must be less than 8. */
645 goto no_cf;
646 }
647
648 if (!(base_ptr & 0xfffful)) {
649 /*
650 * Boot loader signals availability of DMA (true_ide
651 * mode) by setting low order bits of base_ptr to
652 * zero.
653 */
654
655 /* Asume that CS1 immediately follows. */
656 mio_boot_reg_cfg.u64 =
657 cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(cs + 1));
658 region1_base = mio_boot_reg_cfg.s.base << 16;
659 region1_size = (mio_boot_reg_cfg.s.size + 1) << 16;
660 if (!mio_boot_reg_cfg.s.en)
661 goto no_cf;
662 is_true_ide = true;
663
664 } else {
665 fdt_nop_property(initial_boot_params, cf, "cavium,true-ide");
666 fdt_nop_property(initial_boot_params, cf, "cavium,dma-engine-handle");
667 if (!is_16bit) {
668 __be32 width = cpu_to_be32(8);
669 fdt_setprop_inplace(initial_boot_params, cf,
670 "cavium,bus-width", &width, sizeof(width));
671 }
672 }
673 new_reg[0] = cpu_to_be32(cs);
674 new_reg[1] = cpu_to_be32(0);
675 new_reg[2] = cpu_to_be32(0x10000);
676 new_reg[3] = cpu_to_be32(cs + 1);
677 new_reg[4] = cpu_to_be32(0);
678 new_reg[5] = cpu_to_be32(0x10000);
679 fdt_setprop_inplace(initial_boot_params, cf,
680 "reg", new_reg, sizeof(new_reg));
681
682 bootbus = fdt_parent_offset(initial_boot_params, cf);
683 if (bootbus < 0)
684 goto no_cf;
685 ranges = fdt_getprop_w(initial_boot_params, bootbus, "ranges", &len);
686 if (!ranges || len < (5 * 8 * sizeof(__be32)))
687 goto no_cf;
688
689 ranges[(cs * 5) + 2] = cpu_to_be32(region_base >> 32);
690 ranges[(cs * 5) + 3] = cpu_to_be32(region_base & 0xffffffff);
691 ranges[(cs * 5) + 4] = cpu_to_be32(region_size);
692 if (is_true_ide) {
693 cs++;
694 ranges[(cs * 5) + 2] = cpu_to_be32(region1_base >> 32);
695 ranges[(cs * 5) + 3] = cpu_to_be32(region1_base & 0xffffffff);
696 ranges[(cs * 5) + 4] = cpu_to_be32(region1_size);
697 }
698 goto end_cf;
699no_cf:
700 fdt_nop_node(initial_boot_params, cf);
701
702end_cf:
703 ;
704 }
705
706 /* 8 char LED */
707 alias_prop = fdt_getprop(initial_boot_params, aliases,
708 "led0", NULL);
709 if (alias_prop) {
710 union cvmx_mio_boot_reg_cfgx mio_boot_reg_cfg;
711 unsigned long base_ptr, region_base, region_size;
712 int cs, bootbus;
713 __be32 new_reg[6];
714 __be32 *ranges;
715 int len;
716 int led = fdt_path_offset(initial_boot_params, alias_prop);
717
718 base_ptr = octeon_bootinfo->led_display_base_addr;
719 if (base_ptr == 0)
720 goto no_led;
721 /* Find CS0 region. */
722 for (cs = 0; cs < 8; cs++) {
723 mio_boot_reg_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(cs));
724 region_base = mio_boot_reg_cfg.s.base << 16;
725 region_size = (mio_boot_reg_cfg.s.size + 1) << 16;
726 if (mio_boot_reg_cfg.s.en && base_ptr >= region_base
727 && base_ptr < region_base + region_size)
728 break;
729 }
730
731 if (cs > 7)
732 goto no_led;
733
734 new_reg[0] = cpu_to_be32(cs);
735 new_reg[1] = cpu_to_be32(0x20);
736 new_reg[2] = cpu_to_be32(0x20);
737 new_reg[3] = cpu_to_be32(cs);
738 new_reg[4] = cpu_to_be32(0);
739 new_reg[5] = cpu_to_be32(0x20);
740 fdt_setprop_inplace(initial_boot_params, led,
741 "reg", new_reg, sizeof(new_reg));
742
743 bootbus = fdt_parent_offset(initial_boot_params, led);
744 if (bootbus < 0)
745 goto no_led;
746 ranges = fdt_getprop_w(initial_boot_params, bootbus, "ranges", &len);
747 if (!ranges || len < (5 * 8 * sizeof(__be32)))
748 goto no_led;
749
750 ranges[(cs * 5) + 2] = cpu_to_be32(region_base >> 32);
751 ranges[(cs * 5) + 3] = cpu_to_be32(region_base & 0xffffffff);
752 ranges[(cs * 5) + 4] = cpu_to_be32(region_size);
753 goto end_led;
754
755no_led:
756 fdt_nop_node(initial_boot_params, led);
757end_led:
758 ;
759 }
760
761 /* OHCI/UHCI USB */
762 alias_prop = fdt_getprop(initial_boot_params, aliases,
763 "uctl", NULL);
764 if (alias_prop) {
765 int uctl = fdt_path_offset(initial_boot_params, alias_prop);
766
767 if (uctl >= 0 && (!OCTEON_IS_MODEL(OCTEON_CN6XXX) ||
768 octeon_bootinfo->board_type == CVMX_BOARD_TYPE_NIC2E)) {
769 pr_debug("Deleting uctl\n");
770 fdt_nop_node(initial_boot_params, uctl);
771 fdt_nop_property(initial_boot_params, aliases, "uctl");
772 } else if (octeon_bootinfo->board_type == CVMX_BOARD_TYPE_NIC10E ||
773 octeon_bootinfo->board_type == CVMX_BOARD_TYPE_NIC4E) {
774 /* Missing "refclk-type" defaults to crystal. */
775 fdt_nop_property(initial_boot_params, uctl, "refclk-type");
776 }
777 }
778
779 return 0;
780}
781
782static int __init octeon_publish_devices(void)
783{
784 return of_platform_bus_probe(NULL, octeon_ids, NULL);
785}
786device_initcall(octeon_publish_devices);
787
443MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>"); 788MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>");
444MODULE_LICENSE("GPL"); 789MODULE_LICENSE("GPL");
445MODULE_DESCRIPTION("Platform driver for Octeon SOC"); 790MODULE_DESCRIPTION("Platform driver for Octeon SOC");
diff --git a/arch/mips/cavium-octeon/octeon_3xxx.dts b/arch/mips/cavium-octeon/octeon_3xxx.dts
new file mode 100644
index 000000000000..f28b2d0fde22
--- /dev/null
+++ b/arch/mips/cavium-octeon/octeon_3xxx.dts
@@ -0,0 +1,571 @@
1/dts-v1/;
2/*
3 * OCTEON 3XXX, 5XXX, 63XX device tree skeleton.
4 *
5 * This device tree is pruned and patched by early boot code before
6 * use. Because of this, it contains a super-set of the available
7 * devices and properties.
8 */
9/ {
10 compatible = "cavium,octeon-3860";
11 #address-cells = <2>;
12 #size-cells = <2>;
13 interrupt-parent = <&ciu>;
14
15 soc@0 {
16 compatible = "simple-bus";
17 #address-cells = <2>;
18 #size-cells = <2>;
19 ranges; /* Direct mapping */
20
21 ciu: interrupt-controller@1070000000000 {
22 compatible = "cavium,octeon-3860-ciu";
23 interrupt-controller;
24 /* Interrupts are specified by two parts:
25 * 1) Controller register (0 or 1)
26 * 2) Bit within the register (0..63)
27 */
28 #interrupt-cells = <2>;
29 reg = <0x10700 0x00000000 0x0 0x7000>;
30 };
31
32 gpio: gpio-controller@1070000000800 {
33 #gpio-cells = <2>;
34 compatible = "cavium,octeon-3860-gpio";
35 reg = <0x10700 0x00000800 0x0 0x100>;
36 gpio-controller;
37 /* Interrupts are specified by two parts:
38 * 1) GPIO pin number (0..15)
39 * 2) Triggering (1 - edge rising
40 * 2 - edge falling
41 * 4 - level active high
42 * 8 - level active low)
43 */
44 interrupt-controller;
45 #interrupt-cells = <2>;
46 /* The GPIO pin connect to 16 consecutive CUI bits */
47 interrupts = <0 16>, <0 17>, <0 18>, <0 19>,
48 <0 20>, <0 21>, <0 22>, <0 23>,
49 <0 24>, <0 25>, <0 26>, <0 27>,
50 <0 28>, <0 29>, <0 30>, <0 31>;
51 };
52
53 smi0: mdio@1180000001800 {
54 compatible = "cavium,octeon-3860-mdio";
55 #address-cells = <1>;
56 #size-cells = <0>;
57 reg = <0x11800 0x00001800 0x0 0x40>;
58
59 phy0: ethernet-phy@0 {
60 compatible = "marvell,88e1118";
61 marvell,reg-init =
62 /* Fix rx and tx clock transition timing */
63 <2 0x15 0xffcf 0>, /* Reg 2,21 Clear bits 4, 5 */
64 /* Adjust LED drive. */
65 <3 0x11 0 0x442a>, /* Reg 3,17 <- 0442a */
66 /* irq, blink-activity, blink-link */
67 <3 0x10 0 0x0242>; /* Reg 3,16 <- 0x0242 */
68 reg = <0>;
69 };
70
71 phy1: ethernet-phy@1 {
72 compatible = "marvell,88e1118";
73 marvell,reg-init =
74 /* Fix rx and tx clock transition timing */
75 <2 0x15 0xffcf 0>, /* Reg 2,21 Clear bits 4, 5 */
76 /* Adjust LED drive. */
77 <3 0x11 0 0x442a>, /* Reg 3,17 <- 0442a */
78 /* irq, blink-activity, blink-link */
79 <3 0x10 0 0x0242>; /* Reg 3,16 <- 0x0242 */
80 reg = <1>;
81 };
82
83 phy2: ethernet-phy@2 {
84 reg = <2>;
85 compatible = "marvell,88e1149r";
86 marvell,reg-init = <3 0x10 0 0x5777>,
87 <3 0x11 0 0x00aa>,
88 <3 0x12 0 0x4105>,
89 <3 0x13 0 0x0a60>;
90 };
91 phy3: ethernet-phy@3 {
92 reg = <3>;
93 compatible = "marvell,88e1149r";
94 marvell,reg-init = <3 0x10 0 0x5777>,
95 <3 0x11 0 0x00aa>,
96 <3 0x12 0 0x4105>,
97 <3 0x13 0 0x0a60>;
98 };
99 phy4: ethernet-phy@4 {
100 reg = <4>;
101 compatible = "marvell,88e1149r";
102 marvell,reg-init = <3 0x10 0 0x5777>,
103 <3 0x11 0 0x00aa>,
104 <3 0x12 0 0x4105>,
105 <3 0x13 0 0x0a60>;
106 };
107 phy5: ethernet-phy@5 {
108 reg = <5>;
109 compatible = "marvell,88e1149r";
110 marvell,reg-init = <3 0x10 0 0x5777>,
111 <3 0x11 0 0x00aa>,
112 <3 0x12 0 0x4105>,
113 <3 0x13 0 0x0a60>;
114 };
115
116 phy6: ethernet-phy@6 {
117 reg = <6>;
118 compatible = "marvell,88e1149r";
119 marvell,reg-init = <3 0x10 0 0x5777>,
120 <3 0x11 0 0x00aa>,
121 <3 0x12 0 0x4105>,
122 <3 0x13 0 0x0a60>;
123 };
124 phy7: ethernet-phy@7 {
125 reg = <7>;
126 compatible = "marvell,88e1149r";
127 marvell,reg-init = <3 0x10 0 0x5777>,
128 <3 0x11 0 0x00aa>,
129 <3 0x12 0 0x4105>,
130 <3 0x13 0 0x0a60>;
131 };
132 phy8: ethernet-phy@8 {
133 reg = <8>;
134 compatible = "marvell,88e1149r";
135 marvell,reg-init = <3 0x10 0 0x5777>,
136 <3 0x11 0 0x00aa>,
137 <3 0x12 0 0x4105>,
138 <3 0x13 0 0x0a60>;
139 };
140 phy9: ethernet-phy@9 {
141 reg = <9>;
142 compatible = "marvell,88e1149r";
143 marvell,reg-init = <3 0x10 0 0x5777>,
144 <3 0x11 0 0x00aa>,
145 <3 0x12 0 0x4105>,
146 <3 0x13 0 0x0a60>;
147 };
148 };
149
150 smi1: mdio@1180000001900 {
151 compatible = "cavium,octeon-3860-mdio";
152 #address-cells = <1>;
153 #size-cells = <0>;
154 reg = <0x11800 0x00001900 0x0 0x40>;
155
156 phy100: ethernet-phy@1 {
157 reg = <1>;
158 compatible = "marvell,88e1149r";
159 marvell,reg-init = <3 0x10 0 0x5777>,
160 <3 0x11 0 0x00aa>,
161 <3 0x12 0 0x4105>,
162 <3 0x13 0 0x0a60>;
163 interrupt-parent = <&gpio>;
164 interrupts = <12 8>; /* Pin 12, active low */
165 };
166 phy101: ethernet-phy@2 {
167 reg = <2>;
168 compatible = "marvell,88e1149r";
169 marvell,reg-init = <3 0x10 0 0x5777>,
170 <3 0x11 0 0x00aa>,
171 <3 0x12 0 0x4105>,
172 <3 0x13 0 0x0a60>;
173 interrupt-parent = <&gpio>;
174 interrupts = <12 8>; /* Pin 12, active low */
175 };
176 phy102: ethernet-phy@3 {
177 reg = <3>;
178 compatible = "marvell,88e1149r";
179 marvell,reg-init = <3 0x10 0 0x5777>,
180 <3 0x11 0 0x00aa>,
181 <3 0x12 0 0x4105>,
182 <3 0x13 0 0x0a60>;
183 interrupt-parent = <&gpio>;
184 interrupts = <12 8>; /* Pin 12, active low */
185 };
186 phy103: ethernet-phy@4 {
187 reg = <4>;
188 compatible = "marvell,88e1149r";
189 marvell,reg-init = <3 0x10 0 0x5777>,
190 <3 0x11 0 0x00aa>,
191 <3 0x12 0 0x4105>,
192 <3 0x13 0 0x0a60>;
193 interrupt-parent = <&gpio>;
194 interrupts = <12 8>; /* Pin 12, active low */
195 };
196 };
197
198 mix0: ethernet@1070000100000 {
199 compatible = "cavium,octeon-5750-mix";
200 reg = <0x10700 0x00100000 0x0 0x100>, /* MIX */
201 <0x11800 0xE0000000 0x0 0x300>, /* AGL */
202 <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
203 <0x11800 0xE0002000 0x0 0x8>; /* AGL_PRT_CTL */
204 cell-index = <0>;
205 interrupts = <0 62>, <1 46>;
206 local-mac-address = [ 00 00 00 00 00 00 ];
207 phy-handle = <&phy0>;
208 };
209
210 mix1: ethernet@1070000100800 {
211 compatible = "cavium,octeon-5750-mix";
212 reg = <0x10700 0x00100800 0x0 0x100>, /* MIX */
213 <0x11800 0xE0000800 0x0 0x300>, /* AGL */
214 <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
215 <0x11800 0xE0002008 0x0 0x8>; /* AGL_PRT_CTL */
216 cell-index = <1>;
217 interrupts = <1 18>, < 1 46>;
218 local-mac-address = [ 00 00 00 00 00 00 ];
219 phy-handle = <&phy1>;
220 };
221
222 pip: pip@11800a0000000 {
223 compatible = "cavium,octeon-3860-pip";
224 #address-cells = <1>;
225 #size-cells = <0>;
226 reg = <0x11800 0xa0000000 0x0 0x2000>;
227
228 interface@0 {
229 compatible = "cavium,octeon-3860-pip-interface";
230 #address-cells = <1>;
231 #size-cells = <0>;
232 reg = <0>; /* interface */
233
234 ethernet@0 {
235 compatible = "cavium,octeon-3860-pip-port";
236 reg = <0x0>; /* Port */
237 local-mac-address = [ 00 00 00 00 00 00 ];
238 phy-handle = <&phy2>;
239 cavium,alt-phy-handle = <&phy100>;
240 };
241 ethernet@1 {
242 compatible = "cavium,octeon-3860-pip-port";
243 reg = <0x1>; /* Port */
244 local-mac-address = [ 00 00 00 00 00 00 ];
245 phy-handle = <&phy3>;
246 cavium,alt-phy-handle = <&phy101>;
247 };
248 ethernet@2 {
249 compatible = "cavium,octeon-3860-pip-port";
250 reg = <0x2>; /* Port */
251 local-mac-address = [ 00 00 00 00 00 00 ];
252 phy-handle = <&phy4>;
253 cavium,alt-phy-handle = <&phy102>;
254 };
255 ethernet@3 {
256 compatible = "cavium,octeon-3860-pip-port";
257 reg = <0x3>; /* Port */
258 local-mac-address = [ 00 00 00 00 00 00 ];
259 phy-handle = <&phy5>;
260 cavium,alt-phy-handle = <&phy103>;
261 };
262 ethernet@4 {
263 compatible = "cavium,octeon-3860-pip-port";
264 reg = <0x4>; /* Port */
265 local-mac-address = [ 00 00 00 00 00 00 ];
266 };
267 ethernet@5 {
268 compatible = "cavium,octeon-3860-pip-port";
269 reg = <0x5>; /* Port */
270 local-mac-address = [ 00 00 00 00 00 00 ];
271 };
272 ethernet@6 {
273 compatible = "cavium,octeon-3860-pip-port";
274 reg = <0x6>; /* Port */
275 local-mac-address = [ 00 00 00 00 00 00 ];
276 };
277 ethernet@7 {
278 compatible = "cavium,octeon-3860-pip-port";
279 reg = <0x7>; /* Port */
280 local-mac-address = [ 00 00 00 00 00 00 ];
281 };
282 ethernet@8 {
283 compatible = "cavium,octeon-3860-pip-port";
284 reg = <0x8>; /* Port */
285 local-mac-address = [ 00 00 00 00 00 00 ];
286 };
287 ethernet@9 {
288 compatible = "cavium,octeon-3860-pip-port";
289 reg = <0x9>; /* Port */
290 local-mac-address = [ 00 00 00 00 00 00 ];
291 };
292 ethernet@a {
293 compatible = "cavium,octeon-3860-pip-port";
294 reg = <0xa>; /* Port */
295 local-mac-address = [ 00 00 00 00 00 00 ];
296 };
297 ethernet@b {
298 compatible = "cavium,octeon-3860-pip-port";
299 reg = <0xb>; /* Port */
300 local-mac-address = [ 00 00 00 00 00 00 ];
301 };
302 ethernet@c {
303 compatible = "cavium,octeon-3860-pip-port";
304 reg = <0xc>; /* Port */
305 local-mac-address = [ 00 00 00 00 00 00 ];
306 };
307 ethernet@d {
308 compatible = "cavium,octeon-3860-pip-port";
309 reg = <0xd>; /* Port */
310 local-mac-address = [ 00 00 00 00 00 00 ];
311 };
312 ethernet@e {
313 compatible = "cavium,octeon-3860-pip-port";
314 reg = <0xe>; /* Port */
315 local-mac-address = [ 00 00 00 00 00 00 ];
316 };
317 ethernet@f {
318 compatible = "cavium,octeon-3860-pip-port";
319 reg = <0xf>; /* Port */
320 local-mac-address = [ 00 00 00 00 00 00 ];
321 };
322 };
323
324 interface@1 {
325 compatible = "cavium,octeon-3860-pip-interface";
326 #address-cells = <1>;
327 #size-cells = <0>;
328 reg = <1>; /* interface */
329
330 ethernet@0 {
331 compatible = "cavium,octeon-3860-pip-port";
332 reg = <0x0>; /* Port */
333 local-mac-address = [ 00 00 00 00 00 00 ];
334 phy-handle = <&phy6>;
335 };
336 ethernet@1 {
337 compatible = "cavium,octeon-3860-pip-port";
338 reg = <0x1>; /* Port */
339 local-mac-address = [ 00 00 00 00 00 00 ];
340 phy-handle = <&phy7>;
341 };
342 ethernet@2 {
343 compatible = "cavium,octeon-3860-pip-port";
344 reg = <0x2>; /* Port */
345 local-mac-address = [ 00 00 00 00 00 00 ];
346 phy-handle = <&phy8>;
347 };
348 ethernet@3 {
349 compatible = "cavium,octeon-3860-pip-port";
350 reg = <0x3>; /* Port */
351 local-mac-address = [ 00 00 00 00 00 00 ];
352 phy-handle = <&phy9>;
353 };
354 };
355 };
356
357 twsi0: i2c@1180000001000 {
358 #address-cells = <1>;
359 #size-cells = <0>;
360 compatible = "cavium,octeon-3860-twsi";
361 reg = <0x11800 0x00001000 0x0 0x200>;
362 interrupts = <0 45>;
363 clock-frequency = <100000>;
364
365 rtc@68 {
366 compatible = "dallas,ds1337";
367 reg = <0x68>;
368 };
369 tmp@4c {
370 compatible = "ti,tmp421";
371 reg = <0x4c>;
372 };
373 };
374
375 twsi1: i2c@1180000001200 {
376 #address-cells = <1>;
377 #size-cells = <0>;
378 compatible = "cavium,octeon-3860-twsi";
379 reg = <0x11800 0x00001200 0x0 0x200>;
380 interrupts = <0 59>;
381 clock-frequency = <100000>;
382 };
383
384 uart0: serial@1180000000800 {
385 compatible = "cavium,octeon-3860-uart","ns16550";
386 reg = <0x11800 0x00000800 0x0 0x400>;
387 clock-frequency = <0>;
388 current-speed = <115200>;
389 reg-shift = <3>;
390 interrupts = <0 34>;
391 };
392
393 uart1: serial@1180000000c00 {
394 compatible = "cavium,octeon-3860-uart","ns16550";
395 reg = <0x11800 0x00000c00 0x0 0x400>;
396 clock-frequency = <0>;
397 current-speed = <115200>;
398 reg-shift = <3>;
399 interrupts = <0 35>;
400 };
401
402 uart2: serial@1180000000400 {
403 compatible = "cavium,octeon-3860-uart","ns16550";
404 reg = <0x11800 0x00000400 0x0 0x400>;
405 clock-frequency = <0>;
406 current-speed = <115200>;
407 reg-shift = <3>;
408 interrupts = <1 16>;
409 };
410
411 bootbus: bootbus@1180000000000 {
412 compatible = "cavium,octeon-3860-bootbus";
413 reg = <0x11800 0x00000000 0x0 0x200>;
414 /* The chip select number and offset */
415 #address-cells = <2>;
416 /* The size of the chip select region */
417 #size-cells = <1>;
418 ranges = <0 0 0x0 0x1f400000 0xc00000>,
419 <1 0 0x10000 0x30000000 0>,
420 <2 0 0x10000 0x40000000 0>,
421 <3 0 0x10000 0x50000000 0>,
422 <4 0 0x0 0x1d020000 0x10000>,
423 <5 0 0x0 0x1d040000 0x10000>,
424 <6 0 0x0 0x1d050000 0x10000>,
425 <7 0 0x10000 0x90000000 0>;
426
427 cavium,cs-config@0 {
428 compatible = "cavium,octeon-3860-bootbus-config";
429 cavium,cs-index = <0>;
430 cavium,t-adr = <20>;
431 cavium,t-ce = <60>;
432 cavium,t-oe = <60>;
433 cavium,t-we = <45>;
434 cavium,t-rd-hld = <35>;
435 cavium,t-wr-hld = <45>;
436 cavium,t-pause = <0>;
437 cavium,t-wait = <0>;
438 cavium,t-page = <35>;
439 cavium,t-rd-dly = <0>;
440
441 cavium,pages = <0>;
442 cavium,bus-width = <8>;
443 };
444 cavium,cs-config@4 {
445 compatible = "cavium,octeon-3860-bootbus-config";
446 cavium,cs-index = <4>;
447 cavium,t-adr = <320>;
448 cavium,t-ce = <320>;
449 cavium,t-oe = <320>;
450 cavium,t-we = <320>;
451 cavium,t-rd-hld = <320>;
452 cavium,t-wr-hld = <320>;
453 cavium,t-pause = <320>;
454 cavium,t-wait = <320>;
455 cavium,t-page = <320>;
456 cavium,t-rd-dly = <0>;
457
458 cavium,pages = <0>;
459 cavium,bus-width = <8>;
460 };
461 cavium,cs-config@5 {
462 compatible = "cavium,octeon-3860-bootbus-config";
463 cavium,cs-index = <5>;
464 cavium,t-adr = <5>;
465 cavium,t-ce = <300>;
466 cavium,t-oe = <125>;
467 cavium,t-we = <150>;
468 cavium,t-rd-hld = <100>;
469 cavium,t-wr-hld = <30>;
470 cavium,t-pause = <0>;
471 cavium,t-wait = <30>;
472 cavium,t-page = <320>;
473 cavium,t-rd-dly = <0>;
474
475 cavium,pages = <0>;
476 cavium,bus-width = <16>;
477 };
478 cavium,cs-config@6 {
479 compatible = "cavium,octeon-3860-bootbus-config";
480 cavium,cs-index = <6>;
481 cavium,t-adr = <5>;
482 cavium,t-ce = <300>;
483 cavium,t-oe = <270>;
484 cavium,t-we = <150>;
485 cavium,t-rd-hld = <100>;
486 cavium,t-wr-hld = <70>;
487 cavium,t-pause = <0>;
488 cavium,t-wait = <0>;
489 cavium,t-page = <320>;
490 cavium,t-rd-dly = <0>;
491
492 cavium,pages = <0>;
493 cavium,wait-mode;
494 cavium,bus-width = <16>;
495 };
496
497 flash0: nor@0,0 {
498 compatible = "cfi-flash";
499 reg = <0 0 0x800000>;
500 #address-cells = <1>;
501 #size-cells = <1>;
502 };
503
504 led0: led-display@4,0 {
505 compatible = "avago,hdsp-253x";
506 reg = <4 0x20 0x20>, <4 0 0x20>;
507 };
508
509 cf0: compact-flash@5,0 {
510 compatible = "cavium,ebt3000-compact-flash";
511 reg = <5 0 0x10000>, <6 0 0x10000>;
512 cavium,bus-width = <16>;
513 cavium,true-ide;
514 cavium,dma-engine-handle = <&dma0>;
515 };
516 };
517
518 dma0: dma-engine@1180000000100 {
519 compatible = "cavium,octeon-5750-bootbus-dma";
520 reg = <0x11800 0x00000100 0x0 0x8>;
521 interrupts = <0 63>;
522 };
523 dma1: dma-engine@1180000000108 {
524 compatible = "cavium,octeon-5750-bootbus-dma";
525 reg = <0x11800 0x00000108 0x0 0x8>;
526 interrupts = <0 63>;
527 };
528
529 uctl: uctl@118006f000000 {
530 compatible = "cavium,octeon-6335-uctl";
531 reg = <0x11800 0x6f000000 0x0 0x100>;
532 ranges; /* Direct mapping */
533 #address-cells = <2>;
534 #size-cells = <2>;
535 /* 12MHz, 24MHz and 48MHz allowed */
536 refclk-frequency = <12000000>;
537 /* Either "crystal" or "external" */
538 refclk-type = "crystal";
539
540 ehci@16f0000000000 {
541 compatible = "cavium,octeon-6335-ehci","usb-ehci";
542 reg = <0x16f00 0x00000000 0x0 0x100>;
543 interrupts = <0 56>;
544 big-endian-regs;
545 };
546 ohci@16f0000000400 {
547 compatible = "cavium,octeon-6335-ohci","usb-ohci";
548 reg = <0x16f00 0x00000400 0x0 0x100>;
549 interrupts = <0 56>;
550 big-endian-regs;
551 };
552 };
553 };
554
555 aliases {
556 mix0 = &mix0;
557 mix1 = &mix1;
558 pip = &pip;
559 smi0 = &smi0;
560 smi1 = &smi1;
561 twsi0 = &twsi0;
562 twsi1 = &twsi1;
563 uart0 = &uart0;
564 uart1 = &uart1;
565 uart2 = &uart2;
566 flash0 = &flash0;
567 cf0 = &cf0;
568 uctl = &uctl;
569 led0 = &led0;
570 };
571 };
diff --git a/arch/mips/cavium-octeon/octeon_68xx.dts b/arch/mips/cavium-octeon/octeon_68xx.dts
new file mode 100644
index 000000000000..1839468932b6
--- /dev/null
+++ b/arch/mips/cavium-octeon/octeon_68xx.dts
@@ -0,0 +1,625 @@
1/dts-v1/;
2/*
3 * OCTEON 68XX device tree skeleton.
4 *
5 * This device tree is pruned and patched by early boot code before
6 * use. Because of this, it contains a super-set of the available
7 * devices and properties.
8 */
9/ {
10 compatible = "cavium,octeon-6880";
11 #address-cells = <2>;
12 #size-cells = <2>;
13 interrupt-parent = <&ciu2>;
14
15 soc@0 {
16 compatible = "simple-bus";
17 #address-cells = <2>;
18 #size-cells = <2>;
19 ranges; /* Direct mapping */
20
21 ciu2: interrupt-controller@1070100000000 {
22 compatible = "cavium,octeon-6880-ciu2";
23 interrupt-controller;
24 /* Interrupts are specified by two parts:
25 * 1) Controller register (0 or 7)
26 * 2) Bit within the register (0..63)
27 */
28 #address-cells = <0>;
29 #interrupt-cells = <2>;
30 reg = <0x10701 0x00000000 0x0 0x4000000>;
31 };
32
33 gpio: gpio-controller@1070000000800 {
34 #gpio-cells = <2>;
35 compatible = "cavium,octeon-3860-gpio";
36 reg = <0x10700 0x00000800 0x0 0x100>;
37 gpio-controller;
38 /* Interrupts are specified by two parts:
39 * 1) GPIO pin number (0..15)
40 * 2) Triggering (1 - edge rising
41 * 2 - edge falling
42 * 4 - level active high
43 * 8 - level active low)
44 */
45 interrupt-controller;
46 #interrupt-cells = <2>;
47 /* The GPIO pins connect to 16 consecutive CUI bits */
48 interrupts = <7 0>, <7 1>, <7 2>, <7 3>,
49 <7 4>, <7 5>, <7 6>, <7 7>,
50 <7 8>, <7 9>, <7 10>, <7 11>,
51 <7 12>, <7 13>, <7 14>, <7 15>;
52 };
53
54 smi0: mdio@1180000003800 {
55 compatible = "cavium,octeon-3860-mdio";
56 #address-cells = <1>;
57 #size-cells = <0>;
58 reg = <0x11800 0x00003800 0x0 0x40>;
59
60 phy0: ethernet-phy@6 {
61 compatible = "marvell,88e1118";
62 marvell,reg-init =
63 /* Fix rx and tx clock transition timing */
64 <2 0x15 0xffcf 0>, /* Reg 2,21 Clear bits 4, 5 */
65 /* Adjust LED drive. */
66 <3 0x11 0 0x442a>, /* Reg 3,17 <- 0442a */
67 /* irq, blink-activity, blink-link */
68 <3 0x10 0 0x0242>; /* Reg 3,16 <- 0x0242 */
69 reg = <6>;
70 };
71
72 phy1: ethernet-phy@1 {
73 cavium,qlm-trim = "4,sgmii";
74 reg = <1>;
75 compatible = "marvell,88e1149r";
76 marvell,reg-init = <3 0x10 0 0x5777>,
77 <3 0x11 0 0x00aa>,
78 <3 0x12 0 0x4105>,
79 <3 0x13 0 0x0a60>;
80 };
81 phy2: ethernet-phy@2 {
82 cavium,qlm-trim = "4,sgmii";
83 reg = <2>;
84 compatible = "marvell,88e1149r";
85 marvell,reg-init = <3 0x10 0 0x5777>,
86 <3 0x11 0 0x00aa>,
87 <3 0x12 0 0x4105>,
88 <3 0x13 0 0x0a60>;
89 };
90 phy3: ethernet-phy@3 {
91 cavium,qlm-trim = "4,sgmii";
92 reg = <3>;
93 compatible = "marvell,88e1149r";
94 marvell,reg-init = <3 0x10 0 0x5777>,
95 <3 0x11 0 0x00aa>,
96 <3 0x12 0 0x4105>,
97 <3 0x13 0 0x0a60>;
98 };
99 phy4: ethernet-phy@4 {
100 cavium,qlm-trim = "4,sgmii";
101 reg = <4>;
102 compatible = "marvell,88e1149r";
103 marvell,reg-init = <3 0x10 0 0x5777>,
104 <3 0x11 0 0x00aa>,
105 <3 0x12 0 0x4105>,
106 <3 0x13 0 0x0a60>;
107 };
108 };
109
110 smi1: mdio@1180000003880 {
111 compatible = "cavium,octeon-3860-mdio";
112 #address-cells = <1>;
113 #size-cells = <0>;
114 reg = <0x11800 0x00003880 0x0 0x40>;
115
116 phy41: ethernet-phy@1 {
117 cavium,qlm-trim = "0,sgmii";
118 reg = <1>;
119 compatible = "marvell,88e1149r";
120 marvell,reg-init = <3 0x10 0 0x5777>,
121 <3 0x11 0 0x00aa>,
122 <3 0x12 0 0x4105>,
123 <3 0x13 0 0x0a60>;
124 };
125 phy42: ethernet-phy@2 {
126 cavium,qlm-trim = "0,sgmii";
127 reg = <2>;
128 compatible = "marvell,88e1149r";
129 marvell,reg-init = <3 0x10 0 0x5777>,
130 <3 0x11 0 0x00aa>,
131 <3 0x12 0 0x4105>,
132 <3 0x13 0 0x0a60>;
133 };
134 phy43: ethernet-phy@3 {
135 cavium,qlm-trim = "0,sgmii";
136 reg = <3>;
137 compatible = "marvell,88e1149r";
138 marvell,reg-init = <3 0x10 0 0x5777>,
139 <3 0x11 0 0x00aa>,
140 <3 0x12 0 0x4105>,
141 <3 0x13 0 0x0a60>;
142 };
143 phy44: ethernet-phy@4 {
144 cavium,qlm-trim = "0,sgmii";
145 reg = <4>;
146 compatible = "marvell,88e1149r";
147 marvell,reg-init = <3 0x10 0 0x5777>,
148 <3 0x11 0 0x00aa>,
149 <3 0x12 0 0x4105>,
150 <3 0x13 0 0x0a60>;
151 };
152 };
153
154 smi2: mdio@1180000003900 {
155 compatible = "cavium,octeon-3860-mdio";
156 #address-cells = <1>;
157 #size-cells = <0>;
158 reg = <0x11800 0x00003900 0x0 0x40>;
159
160 phy21: ethernet-phy@1 {
161 cavium,qlm-trim = "2,sgmii";
162 reg = <1>;
163 compatible = "marvell,88e1149r";
164 marvell,reg-init = <3 0x10 0 0x5777>,
165 <3 0x11 0 0x00aa>,
166 <3 0x12 0 0x4105>,
167 <3 0x13 0 0x0a60>;
168 };
169 phy22: ethernet-phy@2 {
170 cavium,qlm-trim = "2,sgmii";
171 reg = <2>;
172 compatible = "marvell,88e1149r";
173 marvell,reg-init = <3 0x10 0 0x5777>,
174 <3 0x11 0 0x00aa>,
175 <3 0x12 0 0x4105>,
176 <3 0x13 0 0x0a60>;
177 };
178 phy23: ethernet-phy@3 {
179 cavium,qlm-trim = "2,sgmii";
180 reg = <3>;
181 compatible = "marvell,88e1149r";
182 marvell,reg-init = <3 0x10 0 0x5777>,
183 <3 0x11 0 0x00aa>,
184 <3 0x12 0 0x4105>,
185 <3 0x13 0 0x0a60>;
186 };
187 phy24: ethernet-phy@4 {
188 cavium,qlm-trim = "2,sgmii";
189 reg = <4>;
190 compatible = "marvell,88e1149r";
191 marvell,reg-init = <3 0x10 0 0x5777>,
192 <3 0x11 0 0x00aa>,
193 <3 0x12 0 0x4105>,
194 <3 0x13 0 0x0a60>;
195 };
196 };
197
198 smi3: mdio@1180000003980 {
199 compatible = "cavium,octeon-3860-mdio";
200 #address-cells = <1>;
201 #size-cells = <0>;
202 reg = <0x11800 0x00003980 0x0 0x40>;
203
204 phy11: ethernet-phy@1 {
205 cavium,qlm-trim = "3,sgmii";
206 reg = <1>;
207 compatible = "marvell,88e1149r";
208 marvell,reg-init = <3 0x10 0 0x5777>,
209 <3 0x11 0 0x00aa>,
210 <3 0x12 0 0x4105>,
211 <3 0x13 0 0x0a60>;
212 };
213 phy12: ethernet-phy@2 {
214 cavium,qlm-trim = "3,sgmii";
215 reg = <2>;
216 compatible = "marvell,88e1149r";
217 marvell,reg-init = <3 0x10 0 0x5777>,
218 <3 0x11 0 0x00aa>,
219 <3 0x12 0 0x4105>,
220 <3 0x13 0 0x0a60>;
221 };
222 phy13: ethernet-phy@3 {
223 cavium,qlm-trim = "3,sgmii";
224 reg = <3>;
225 compatible = "marvell,88e1149r";
226 marvell,reg-init = <3 0x10 0 0x5777>,
227 <3 0x11 0 0x00aa>,
228 <3 0x12 0 0x4105>,
229 <3 0x13 0 0x0a60>;
230 };
231 phy14: ethernet-phy@4 {
232 cavium,qlm-trim = "3,sgmii";
233 reg = <4>;
234 compatible = "marvell,88e1149r";
235 marvell,reg-init = <3 0x10 0 0x5777>,
236 <3 0x11 0 0x00aa>,
237 <3 0x12 0 0x4105>,
238 <3 0x13 0 0x0a60>;
239 };
240 };
241
242 mix0: ethernet@1070000100000 {
243 compatible = "cavium,octeon-5750-mix";
244 reg = <0x10700 0x00100000 0x0 0x100>, /* MIX */
245 <0x11800 0xE0000000 0x0 0x300>, /* AGL */
246 <0x11800 0xE0000400 0x0 0x400>, /* AGL_SHARED */
247 <0x11800 0xE0002000 0x0 0x8>; /* AGL_PRT_CTL */
248 cell-index = <0>;
249 interrupts = <6 40>, <6 32>;
250 local-mac-address = [ 00 00 00 00 00 00 ];
251 phy-handle = <&phy0>;
252 };
253
254 pip: pip@11800a0000000 {
255 compatible = "cavium,octeon-3860-pip";
256 #address-cells = <1>;
257 #size-cells = <0>;
258 reg = <0x11800 0xa0000000 0x0 0x2000>;
259
260 interface@4 {
261 compatible = "cavium,octeon-3860-pip-interface";
262 #address-cells = <1>;
263 #size-cells = <0>;
264 reg = <0x4>; /* interface */
265
266 ethernet@0 {
267 compatible = "cavium,octeon-3860-pip-port";
268 reg = <0x0>; /* Port */
269 local-mac-address = [ 00 00 00 00 00 00 ];
270 phy-handle = <&phy1>;
271 };
272 ethernet@1 {
273 compatible = "cavium,octeon-3860-pip-port";
274 reg = <0x1>; /* Port */
275 local-mac-address = [ 00 00 00 00 00 00 ];
276 phy-handle = <&phy2>;
277 };
278 ethernet@2 {
279 compatible = "cavium,octeon-3860-pip-port";
280 reg = <0x2>; /* Port */
281 local-mac-address = [ 00 00 00 00 00 00 ];
282 phy-handle = <&phy3>;
283 };
284 ethernet@3 {
285 compatible = "cavium,octeon-3860-pip-port";
286 reg = <0x3>; /* Port */
287 local-mac-address = [ 00 00 00 00 00 00 ];
288 phy-handle = <&phy4>;
289 };
290 };
291
292 interface@3 {
293 compatible = "cavium,octeon-3860-pip-interface";
294 #address-cells = <1>;
295 #size-cells = <0>;
296 reg = <0x3>; /* interface */
297
298 ethernet@0 {
299 compatible = "cavium,octeon-3860-pip-port";
300 reg = <0x0>; /* Port */
301 local-mac-address = [ 00 00 00 00 00 00 ];
302 phy-handle = <&phy11>;
303 };
304 ethernet@1 {
305 compatible = "cavium,octeon-3860-pip-port";
306 reg = <0x1>; /* Port */
307 local-mac-address = [ 00 00 00 00 00 00 ];
308 phy-handle = <&phy12>;
309 };
310 ethernet@2 {
311 compatible = "cavium,octeon-3860-pip-port";
312 reg = <0x2>; /* Port */
313 local-mac-address = [ 00 00 00 00 00 00 ];
314 phy-handle = <&phy13>;
315 };
316 ethernet@3 {
317 compatible = "cavium,octeon-3860-pip-port";
318 reg = <0x3>; /* Port */
319 local-mac-address = [ 00 00 00 00 00 00 ];
320 phy-handle = <&phy14>;
321 };
322 };
323
324 interface@2 {
325 compatible = "cavium,octeon-3860-pip-interface";
326 #address-cells = <1>;
327 #size-cells = <0>;
328 reg = <0x2>; /* interface */
329
330 ethernet@0 {
331 compatible = "cavium,octeon-3860-pip-port";
332 reg = <0x0>; /* Port */
333 local-mac-address = [ 00 00 00 00 00 00 ];
334 phy-handle = <&phy21>;
335 };
336 ethernet@1 {
337 compatible = "cavium,octeon-3860-pip-port";
338 reg = <0x1>; /* Port */
339 local-mac-address = [ 00 00 00 00 00 00 ];
340 phy-handle = <&phy22>;
341 };
342 ethernet@2 {
343 compatible = "cavium,octeon-3860-pip-port";
344 reg = <0x2>; /* Port */
345 local-mac-address = [ 00 00 00 00 00 00 ];
346 phy-handle = <&phy23>;
347 };
348 ethernet@3 {
349 compatible = "cavium,octeon-3860-pip-port";
350 reg = <0x3>; /* Port */
351 local-mac-address = [ 00 00 00 00 00 00 ];
352 phy-handle = <&phy24>;
353 };
354 };
355
356 interface@1 {
357 compatible = "cavium,octeon-3860-pip-interface";
358 #address-cells = <1>;
359 #size-cells = <0>;
360 reg = <0x1>; /* interface */
361
362 ethernet@0 {
363 compatible = "cavium,octeon-3860-pip-port";
364 reg = <0x0>; /* Port */
365 local-mac-address = [ 00 00 00 00 00 00 ];
366 };
367 };
368
369 interface@0 {
370 compatible = "cavium,octeon-3860-pip-interface";
371 #address-cells = <1>;
372 #size-cells = <0>;
373 reg = <0x0>; /* interface */
374
375 ethernet@0 {
376 compatible = "cavium,octeon-3860-pip-port";
377 reg = <0x0>; /* Port */
378 local-mac-address = [ 00 00 00 00 00 00 ];
379 phy-handle = <&phy41>;
380 };
381 ethernet@1 {
382 compatible = "cavium,octeon-3860-pip-port";
383 reg = <0x1>; /* Port */
384 local-mac-address = [ 00 00 00 00 00 00 ];
385 phy-handle = <&phy42>;
386 };
387 ethernet@2 {
388 compatible = "cavium,octeon-3860-pip-port";
389 reg = <0x2>; /* Port */
390 local-mac-address = [ 00 00 00 00 00 00 ];
391 phy-handle = <&phy43>;
392 };
393 ethernet@3 {
394 compatible = "cavium,octeon-3860-pip-port";
395 reg = <0x3>; /* Port */
396 local-mac-address = [ 00 00 00 00 00 00 ];
397 phy-handle = <&phy44>;
398 };
399 };
400 };
401
402 twsi0: i2c@1180000001000 {
403 #address-cells = <1>;
404 #size-cells = <0>;
405 compatible = "cavium,octeon-3860-twsi";
406 reg = <0x11800 0x00001000 0x0 0x200>;
407 interrupts = <3 32>;
408 clock-frequency = <100000>;
409
410 rtc@68 {
411 compatible = "dallas,ds1337";
412 reg = <0x68>;
413 };
414 tmp@4c {
415 compatible = "ti,tmp421";
416 reg = <0x4c>;
417 };
418 };
419
420 twsi1: i2c@1180000001200 {
421 #address-cells = <1>;
422 #size-cells = <0>;
423 compatible = "cavium,octeon-3860-twsi";
424 reg = <0x11800 0x00001200 0x0 0x200>;
425 interrupts = <3 33>;
426 clock-frequency = <100000>;
427 };
428
429 uart0: serial@1180000000800 {
430 compatible = "cavium,octeon-3860-uart","ns16550";
431 reg = <0x11800 0x00000800 0x0 0x400>;
432 clock-frequency = <0>;
433 current-speed = <115200>;
434 reg-shift = <3>;
435 interrupts = <3 36>;
436 };
437
438 uart1: serial@1180000000c00 {
439 compatible = "cavium,octeon-3860-uart","ns16550";
440 reg = <0x11800 0x00000c00 0x0 0x400>;
441 clock-frequency = <0>;
442 current-speed = <115200>;
443 reg-shift = <3>;
444 interrupts = <3 37>;
445 };
446
447 bootbus: bootbus@1180000000000 {
448 compatible = "cavium,octeon-3860-bootbus";
449 reg = <0x11800 0x00000000 0x0 0x200>;
450 /* The chip select number and offset */
451 #address-cells = <2>;
452 /* The size of the chip select region */
453 #size-cells = <1>;
454 ranges = <0 0 0 0x1f400000 0xc00000>,
455 <1 0 0x10000 0x30000000 0>,
456 <2 0 0x10000 0x40000000 0>,
457 <3 0 0x10000 0x50000000 0>,
458 <4 0 0 0x1d020000 0x10000>,
459 <5 0 0 0x1d040000 0x10000>,
460 <6 0 0 0x1d050000 0x10000>,
461 <7 0 0x10000 0x90000000 0>;
462
463 cavium,cs-config@0 {
464 compatible = "cavium,octeon-3860-bootbus-config";
465 cavium,cs-index = <0>;
466 cavium,t-adr = <10>;
467 cavium,t-ce = <50>;
468 cavium,t-oe = <50>;
469 cavium,t-we = <35>;
470 cavium,t-rd-hld = <25>;
471 cavium,t-wr-hld = <35>;
472 cavium,t-pause = <0>;
473 cavium,t-wait = <300>;
474 cavium,t-page = <25>;
475 cavium,t-rd-dly = <0>;
476
477 cavium,pages = <0>;
478 cavium,bus-width = <8>;
479 };
480 cavium,cs-config@4 {
481 compatible = "cavium,octeon-3860-bootbus-config";
482 cavium,cs-index = <4>;
483 cavium,t-adr = <320>;
484 cavium,t-ce = <320>;
485 cavium,t-oe = <320>;
486 cavium,t-we = <320>;
487 cavium,t-rd-hld = <320>;
488 cavium,t-wr-hld = <320>;
489 cavium,t-pause = <320>;
490 cavium,t-wait = <320>;
491 cavium,t-page = <320>;
492 cavium,t-rd-dly = <0>;
493
494 cavium,pages = <0>;
495 cavium,bus-width = <8>;
496 };
497 cavium,cs-config@5 {
498 compatible = "cavium,octeon-3860-bootbus-config";
499 cavium,cs-index = <5>;
500 cavium,t-adr = <0>;
501 cavium,t-ce = <300>;
502 cavium,t-oe = <125>;
503 cavium,t-we = <150>;
504 cavium,t-rd-hld = <100>;
505 cavium,t-wr-hld = <300>;
506 cavium,t-pause = <0>;
507 cavium,t-wait = <300>;
508 cavium,t-page = <310>;
509 cavium,t-rd-dly = <0>;
510
511 cavium,pages = <0>;
512 cavium,bus-width = <16>;
513 };
514 cavium,cs-config@6 {
515 compatible = "cavium,octeon-3860-bootbus-config";
516 cavium,cs-index = <6>;
517 cavium,t-adr = <0>;
518 cavium,t-ce = <30>;
519 cavium,t-oe = <125>;
520 cavium,t-we = <150>;
521 cavium,t-rd-hld = <100>;
522 cavium,t-wr-hld = <30>;
523 cavium,t-pause = <0>;
524 cavium,t-wait = <30>;
525 cavium,t-page = <310>;
526 cavium,t-rd-dly = <0>;
527
528 cavium,pages = <0>;
529 cavium,wait-mode;
530 cavium,bus-width = <16>;
531 };
532
533 flash0: nor@0,0 {
534 compatible = "cfi-flash";
535 reg = <0 0 0x800000>;
536 #address-cells = <1>;
537 #size-cells = <1>;
538
539 partition@0 {
540 label = "bootloader";
541 reg = <0 0x200000>;
542 read-only;
543 };
544 partition@200000 {
545 label = "kernel";
546 reg = <0x200000 0x200000>;
547 };
548 partition@400000 {
549 label = "cramfs";
550 reg = <0x400000 0x3fe000>;
551 };
552 partition@7fe000 {
553 label = "environment";
554 reg = <0x7fe000 0x2000>;
555 read-only;
556 };
557 };
558
559 led0: led-display@4,0 {
560 compatible = "avago,hdsp-253x";
561 reg = <4 0x20 0x20>, <4 0 0x20>;
562 };
563
564 compact-flash@5,0 {
565 compatible = "cavium,ebt3000-compact-flash";
566 reg = <5 0 0x10000>, <6 0 0x10000>;
567 cavium,bus-width = <16>;
568 cavium,true-ide;
569 cavium,dma-engine-handle = <&dma0>;
570 };
571 };
572
573 dma0: dma-engine@1180000000100 {
574 compatible = "cavium,octeon-5750-bootbus-dma";
575 reg = <0x11800 0x00000100 0x0 0x8>;
576 interrupts = <0 63>;
577 };
578 dma1: dma-engine@1180000000108 {
579 compatible = "cavium,octeon-5750-bootbus-dma";
580 reg = <0x11800 0x00000108 0x0 0x8>;
581 interrupts = <0 63>;
582 };
583
584 uctl: uctl@118006f000000 {
585 compatible = "cavium,octeon-6335-uctl";
586 reg = <0x11800 0x6f000000 0x0 0x100>;
587 ranges; /* Direct mapping */
588 #address-cells = <2>;
589 #size-cells = <2>;
590 /* 12MHz, 24MHz and 48MHz allowed */
591 refclk-frequency = <12000000>;
592 /* Either "crystal" or "external" */
593 refclk-type = "crystal";
594
595 ehci@16f0000000000 {
596 compatible = "cavium,octeon-6335-ehci","usb-ehci";
597 reg = <0x16f00 0x00000000 0x0 0x100>;
598 interrupts = <3 44>;
599 big-endian-regs;
600 };
601 ohci@16f0000000400 {
602 compatible = "cavium,octeon-6335-ohci","usb-ohci";
603 reg = <0x16f00 0x00000400 0x0 0x100>;
604 interrupts = <3 44>;
605 big-endian-regs;
606 };
607 };
608 };
609
610 aliases {
611 mix0 = &mix0;
612 pip = &pip;
613 smi0 = &smi0;
614 smi1 = &smi1;
615 smi2 = &smi2;
616 smi3 = &smi3;
617 twsi0 = &twsi0;
618 twsi1 = &twsi1;
619 uart0 = &uart0;
620 uart1 = &uart1;
621 uctl = &uctl;
622 led0 = &led0;
623 flash0 = &flash0;
624 };
625 };
diff --git a/arch/mips/cavium-octeon/serial.c b/arch/mips/cavium-octeon/serial.c
index 057f0ae88c99..138b2216b4f8 100644
--- a/arch/mips/cavium-octeon/serial.c
+++ b/arch/mips/cavium-octeon/serial.c
@@ -43,95 +43,67 @@ void octeon_serial_out(struct uart_port *up, int offset, int value)
43 cvmx_write_csr((uint64_t)(up->membase + (offset << 3)), (u8)value); 43 cvmx_write_csr((uint64_t)(up->membase + (offset << 3)), (u8)value);
44} 44}
45 45
46/* 46static int __devinit octeon_serial_probe(struct platform_device *pdev)
47 * Allocated in .bss, so it is all zeroed.
48 */
49#define OCTEON_MAX_UARTS 3
50static struct plat_serial8250_port octeon_uart8250_data[OCTEON_MAX_UARTS + 1];
51static struct platform_device octeon_uart8250_device = {
52 .name = "serial8250",
53 .id = PLAT8250_DEV_PLATFORM,
54 .dev = {
55 .platform_data = octeon_uart8250_data,
56 },
57};
58
59static void __init octeon_uart_set_common(struct plat_serial8250_port *p)
60{ 47{
61 p->flags = ASYNC_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; 48 int irq, res;
62 p->type = PORT_OCTEON; 49 struct resource *res_mem;
63 p->iotype = UPIO_MEM; 50 struct uart_port port;
64 p->regshift = 3; /* I/O addresses are every 8 bytes */ 51
52 /* All adaptors have an irq. */
53 irq = platform_get_irq(pdev, 0);
54 if (irq < 0)
55 return irq;
56
57 memset(&port, 0, sizeof(port));
58
59 port.flags = ASYNC_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
60 port.type = PORT_OCTEON;
61 port.iotype = UPIO_MEM;
62 port.regshift = 3;
63 port.dev = &pdev->dev;
64
65 if (octeon_is_simulation()) 65 if (octeon_is_simulation())
66 /* Make simulator output fast*/ 66 /* Make simulator output fast*/
67 p->uartclk = 115200 * 16; 67 port.uartclk = 115200 * 16;
68 else 68 else
69 p->uartclk = octeon_get_io_clock_rate(); 69 port.uartclk = octeon_get_io_clock_rate();
70 p->serial_in = octeon_serial_in;
71 p->serial_out = octeon_serial_out;
72}
73 70
74static int __init octeon_serial_init(void) 71 port.serial_in = octeon_serial_in;
75{ 72 port.serial_out = octeon_serial_out;
76 int enable_uart0; 73 port.irq = irq;
77 int enable_uart1;
78 int enable_uart2;
79 struct plat_serial8250_port *p;
80
81#ifdef CONFIG_CAVIUM_OCTEON_2ND_KERNEL
82 /*
83 * If we are configured to run as the second of two kernels,
84 * disable uart0 and enable uart1. Uart0 is owned by the first
85 * kernel
86 */
87 enable_uart0 = 0;
88 enable_uart1 = 1;
89#else
90 /*
91 * We are configured for the first kernel. We'll enable uart0
92 * if the bootloader told us to use 0, otherwise will enable
93 * uart 1.
94 */
95 enable_uart0 = (octeon_get_boot_uart() == 0);
96 enable_uart1 = (octeon_get_boot_uart() == 1);
97#ifdef CONFIG_KGDB
98 enable_uart1 = 1;
99#endif
100#endif
101
102 /* Right now CN52XX is the only chip with a third uart */
103 enable_uart2 = OCTEON_IS_MODEL(OCTEON_CN52XX);
104
105 p = octeon_uart8250_data;
106 if (enable_uart0) {
107 /* Add a ttyS device for hardware uart 0 */
108 octeon_uart_set_common(p);
109 p->membase = (void *) CVMX_MIO_UARTX_RBR(0);
110 p->mapbase = CVMX_MIO_UARTX_RBR(0) & ((1ull << 49) - 1);
111 p->irq = OCTEON_IRQ_UART0;
112 p++;
113 }
114 74
115 if (enable_uart1) { 75 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
116 /* Add a ttyS device for hardware uart 1 */ 76 if (res_mem == NULL) {
117 octeon_uart_set_common(p); 77 dev_err(&pdev->dev, "found no memory resource\n");
118 p->membase = (void *) CVMX_MIO_UARTX_RBR(1); 78 return -ENXIO;
119 p->mapbase = CVMX_MIO_UARTX_RBR(1) & ((1ull << 49) - 1);
120 p->irq = OCTEON_IRQ_UART1;
121 p++;
122 }
123 if (enable_uart2) {
124 /* Add a ttyS device for hardware uart 2 */
125 octeon_uart_set_common(p);
126 p->membase = (void *) CVMX_MIO_UART2_RBR;
127 p->mapbase = CVMX_MIO_UART2_RBR & ((1ull << 49) - 1);
128 p->irq = OCTEON_IRQ_UART2;
129 p++;
130 } 79 }
80 port.mapbase = res_mem->start;
81 port.membase = ioremap(res_mem->start, resource_size(res_mem));
131 82
132 BUG_ON(p > &octeon_uart8250_data[OCTEON_MAX_UARTS]); 83 res = serial8250_register_port(&port);
133 84
134 return platform_device_register(&octeon_uart8250_device); 85 return res >= 0 ? 0 : res;
135} 86}
136 87
137device_initcall(octeon_serial_init); 88static struct of_device_id octeon_serial_match[] = {
89 {
90 .compatible = "cavium,octeon-3860-uart",
91 },
92 {},
93};
94MODULE_DEVICE_TABLE(of, octeon_serial_match);
95
96static struct platform_driver octeon_serial_driver = {
97 .probe = octeon_serial_probe,
98 .driver = {
99 .owner = THIS_MODULE,
100 .name = "octeon_serial",
101 .of_match_table = octeon_serial_match,
102 },
103};
104
105static int __init octeon_serial_init(void)
106{
107 return platform_driver_register(&octeon_serial_driver);
108}
109late_initcall(octeon_serial_init);
diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
index 260dc247c052..919b0fb7bb1a 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -21,6 +21,8 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/serial_core.h> 22#include <linux/serial_core.h>
23#include <linux/serial_8250.h> 23#include <linux/serial_8250.h>
24#include <linux/of_fdt.h>
25#include <linux/libfdt.h>
24 26
25#include <asm/processor.h> 27#include <asm/processor.h>
26#include <asm/reboot.h> 28#include <asm/reboot.h>
@@ -775,3 +777,46 @@ void prom_free_prom_memory(void)
775 } 777 }
776#endif 778#endif
777} 779}
780
781int octeon_prune_device_tree(void);
782
783extern const char __dtb_octeon_3xxx_begin;
784extern const char __dtb_octeon_3xxx_end;
785extern const char __dtb_octeon_68xx_begin;
786extern const char __dtb_octeon_68xx_end;
787void __init device_tree_init(void)
788{
789 int dt_size;
790 struct boot_param_header *fdt;
791 bool do_prune;
792
793 if (octeon_bootinfo->minor_version >= 3 && octeon_bootinfo->fdt_addr) {
794 fdt = phys_to_virt(octeon_bootinfo->fdt_addr);
795 if (fdt_check_header(fdt))
796 panic("Corrupt Device Tree passed to kernel.");
797 dt_size = be32_to_cpu(fdt->totalsize);
798 do_prune = false;
799 } else if (OCTEON_IS_MODEL(OCTEON_CN68XX)) {
800 fdt = (struct boot_param_header *)&__dtb_octeon_68xx_begin;
801 dt_size = &__dtb_octeon_68xx_end - &__dtb_octeon_68xx_begin;
802 do_prune = true;
803 } else {
804 fdt = (struct boot_param_header *)&__dtb_octeon_3xxx_begin;
805 dt_size = &__dtb_octeon_3xxx_end - &__dtb_octeon_3xxx_begin;
806 do_prune = true;
807 }
808
809 /* Copy the default tree from init memory. */
810 initial_boot_params = early_init_dt_alloc_memory_arch(dt_size, 8);
811 if (initial_boot_params == NULL)
812 panic("Could not allocate initial_boot_params\n");
813 memcpy(initial_boot_params, fdt, dt_size);
814
815 if (do_prune) {
816 octeon_prune_device_tree();
817 pr_info("Using internal Device Tree.\n");
818 } else {
819 pr_info("Using passed Device Tree.\n");
820 }
821 unflatten_device_tree();
822}
diff --git a/arch/mips/configs/ls1b_defconfig b/arch/mips/configs/ls1b_defconfig
new file mode 100644
index 000000000000..80cff8bea8e8
--- /dev/null
+++ b/arch/mips/configs/ls1b_defconfig
@@ -0,0 +1,109 @@
1CONFIG_MACH_LOONGSON1=y
2CONFIG_PREEMPT=y
3# CONFIG_SECCOMP is not set
4CONFIG_EXPERIMENTAL=y
5# CONFIG_LOCALVERSION_AUTO is not set
6CONFIG_SYSVIPC=y
7CONFIG_BSD_PROCESS_ACCT=y
8CONFIG_BSD_PROCESS_ACCT_V3=y
9CONFIG_HIGH_RES_TIMERS=y
10CONFIG_IKCONFIG=y
11CONFIG_IKCONFIG_PROC=y
12CONFIG_LOG_BUF_SHIFT=16
13CONFIG_NAMESPACES=y
14CONFIG_BLK_DEV_INITRD=y
15CONFIG_RD_BZIP2=y
16CONFIG_RD_LZMA=y
17CONFIG_EXPERT=y
18CONFIG_PERF_EVENTS=y
19# CONFIG_COMPAT_BRK is not set
20CONFIG_MODULES=y
21CONFIG_MODULE_UNLOAD=y
22CONFIG_MODVERSIONS=y
23# CONFIG_LBDAF is not set
24# CONFIG_BLK_DEV_BSG is not set
25# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
26# CONFIG_SUSPEND is not set
27CONFIG_NET=y
28CONFIG_PACKET=y
29CONFIG_UNIX=y
30CONFIG_INET=y
31CONFIG_IP_PNP=y
32CONFIG_IP_PNP_DHCP=y
33CONFIG_SYN_COOKIES=y
34# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
35# CONFIG_INET_XFRM_MODE_TUNNEL is not set
36# CONFIG_INET_XFRM_MODE_BEET is not set
37# CONFIG_INET_DIAG is not set
38# CONFIG_IPV6 is not set
39# CONFIG_WIRELESS is not set
40CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
41CONFIG_DEVTMPFS=y
42CONFIG_DEVTMPFS_MOUNT=y
43# CONFIG_STANDALONE is not set
44CONFIG_BLK_DEV_LOOP=y
45CONFIG_SCSI=m
46# CONFIG_SCSI_PROC_FS is not set
47CONFIG_BLK_DEV_SD=m
48# CONFIG_SCSI_LOWLEVEL is not set
49CONFIG_NETDEVICES=y
50# CONFIG_NET_VENDOR_BROADCOM is not set
51# CONFIG_NET_VENDOR_CHELSIO is not set
52# CONFIG_NET_VENDOR_INTEL is not set
53# CONFIG_NET_VENDOR_MARVELL is not set
54# CONFIG_NET_VENDOR_MICREL is not set
55# CONFIG_NET_VENDOR_NATSEMI is not set
56# CONFIG_NET_VENDOR_SEEQ is not set
57# CONFIG_NET_VENDOR_SMSC is not set
58CONFIG_STMMAC_ETH=y
59CONFIG_STMMAC_DA=y
60# CONFIG_NET_VENDOR_WIZNET is not set
61# CONFIG_WLAN is not set
62CONFIG_INPUT_EVDEV=y
63# CONFIG_INPUT_KEYBOARD is not set
64# CONFIG_INPUT_MOUSE is not set
65# CONFIG_SERIO is not set
66CONFIG_VT_HW_CONSOLE_BINDING=y
67CONFIG_LEGACY_PTY_COUNT=8
68# CONFIG_DEVKMEM is not set
69CONFIG_SERIAL_8250=y
70CONFIG_SERIAL_8250_CONSOLE=y
71# CONFIG_HW_RANDOM is not set
72# CONFIG_HWMON is not set
73# CONFIG_VGA_CONSOLE is not set
74CONFIG_USB_HID=m
75CONFIG_HID_GENERIC=m
76CONFIG_USB=y
77CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
78CONFIG_USB_EHCI_HCD=y
79# CONFIG_USB_EHCI_TT_NEWSCHED is not set
80CONFIG_USB_STORAGE=m
81CONFIG_USB_SERIAL=m
82CONFIG_USB_SERIAL_PL2303=m
83CONFIG_RTC_CLASS=y
84CONFIG_RTC_DRV_LOONGSON1=y
85# CONFIG_IOMMU_SUPPORT is not set
86CONFIG_EXT2_FS=y
87CONFIG_EXT2_FS_XATTR=y
88CONFIG_EXT2_FS_POSIX_ACL=y
89CONFIG_EXT2_FS_SECURITY=y
90CONFIG_EXT3_FS=y
91CONFIG_EXT3_FS_POSIX_ACL=y
92CONFIG_EXT3_FS_SECURITY=y
93# CONFIG_DNOTIFY is not set
94CONFIG_VFAT_FS=y
95CONFIG_PROC_KCORE=y
96CONFIG_TMPFS=y
97CONFIG_TMPFS_POSIX_ACL=y
98# CONFIG_MISC_FILESYSTEMS is not set
99CONFIG_NFS_FS=y
100CONFIG_ROOT_NFS=y
101CONFIG_NLS_CODEPAGE_437=m
102CONFIG_NLS_ISO8859_1=m
103# CONFIG_ENABLE_WARN_DEPRECATED is not set
104# CONFIG_ENABLE_MUST_CHECK is not set
105CONFIG_MAGIC_SYSRQ=y
106# CONFIG_SCHED_DEBUG is not set
107# CONFIG_DEBUG_PREEMPT is not set
108# CONFIG_FTRACE is not set
109# CONFIG_EARLY_PRINTK is not set
diff --git a/arch/mips/configs/nlm_xlr_defconfig b/arch/mips/configs/nlm_xlr_defconfig
index d0b857d98c91..138f698d7c00 100644
--- a/arch/mips/configs/nlm_xlr_defconfig
+++ b/arch/mips/configs/nlm_xlr_defconfig
@@ -367,6 +367,10 @@ CONFIG_SERIAL_8250_RSA=y
367CONFIG_HW_RANDOM=y 367CONFIG_HW_RANDOM=y
368CONFIG_HW_RANDOM_TIMERIOMEM=m 368CONFIG_HW_RANDOM_TIMERIOMEM=m
369CONFIG_RAW_DRIVER=m 369CONFIG_RAW_DRIVER=m
370CONFIG_I2C=y
371CONFIG_I2C_XLR=y
372CONFIG_RTC_CLASS=y
373CONFIG_RTC_DRV_DS1374=y
370# CONFIG_HWMON is not set 374# CONFIG_HWMON is not set
371# CONFIG_VGA_CONSOLE is not set 375# CONFIG_VGA_CONSOLE is not set
372# CONFIG_HID_SUPPORT is not set 376# CONFIG_HID_SUPPORT is not set
diff --git a/arch/mips/dec/prom/memory.c b/arch/mips/dec/prom/memory.c
index e95ff3054ff6..8c62316f22f4 100644
--- a/arch/mips/dec/prom/memory.c
+++ b/arch/mips/dec/prom/memory.c
@@ -101,7 +101,7 @@ void __init prom_free_prom_memory(void)
101 * the first page reserved for the exception handlers. 101 * the first page reserved for the exception handlers.
102 */ 102 */
103 103
104#if defined(CONFIG_DECLANCE) || defined(CONFIG_DECLANCE_MODULE) 104#if IS_ENABLED(CONFIG_DECLANCE)
105 /* 105 /*
106 * Leave 128 KB reserved for Lance memory for 106 * Leave 128 KB reserved for Lance memory for
107 * IOASIC DECstations. 107 * IOASIC DECstations.
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index 95e40c1e8ed1..f21b7c04e95a 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -197,6 +197,7 @@
197#define PRID_REV_VR4181A 0x0070 /* Same as VR4122 */ 197#define PRID_REV_VR4181A 0x0070 /* Same as VR4122 */
198#define PRID_REV_VR4130 0x0080 198#define PRID_REV_VR4130 0x0080
199#define PRID_REV_34K_V1_0_2 0x0022 199#define PRID_REV_34K_V1_0_2 0x0022
200#define PRID_REV_LOONGSON1B 0x0020
200#define PRID_REV_LOONGSON2E 0x0002 201#define PRID_REV_LOONGSON2E 0x0002
201#define PRID_REV_LOONGSON2F 0x0003 202#define PRID_REV_LOONGSON2F 0x0003
202 203
@@ -261,7 +262,7 @@ enum cpu_type_enum {
261 */ 262 */
262 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_1004K, CPU_74K, 263 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_1004K, CPU_74K,
263 CPU_ALCHEMY, CPU_PR4450, CPU_BMIPS32, CPU_BMIPS3300, CPU_BMIPS4350, 264 CPU_ALCHEMY, CPU_PR4450, CPU_BMIPS32, CPU_BMIPS3300, CPU_BMIPS4350,
264 CPU_BMIPS4380, CPU_BMIPS5000, CPU_JZRISC, CPU_M14KC, 265 CPU_BMIPS4380, CPU_BMIPS5000, CPU_JZRISC, CPU_LOONGSON1, CPU_M14KC,
265 266
266 /* 267 /*
267 * MIPS64 class processors 268 * MIPS64 class processors
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
index 5b8d15bb5fe8..e104ddb694a8 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
@@ -9,6 +9,7 @@
9 * compile time if only one CPU support is enabled (idea stolen from 9 * compile time if only one CPU support is enabled (idea stolen from
10 * arm mach-types) 10 * arm mach-types)
11 */ 11 */
12#define BCM6328_CPU_ID 0x6328
12#define BCM6338_CPU_ID 0x6338 13#define BCM6338_CPU_ID 0x6338
13#define BCM6345_CPU_ID 0x6345 14#define BCM6345_CPU_ID 0x6345
14#define BCM6348_CPU_ID 0x6348 15#define BCM6348_CPU_ID 0x6348
@@ -20,6 +21,19 @@ u16 __bcm63xx_get_cpu_id(void);
20u16 bcm63xx_get_cpu_rev(void); 21u16 bcm63xx_get_cpu_rev(void);
21unsigned int bcm63xx_get_cpu_freq(void); 22unsigned int bcm63xx_get_cpu_freq(void);
22 23
24#ifdef CONFIG_BCM63XX_CPU_6328
25# ifdef bcm63xx_get_cpu_id
26# undef bcm63xx_get_cpu_id
27# define bcm63xx_get_cpu_id() __bcm63xx_get_cpu_id()
28# define BCMCPU_RUNTIME_DETECT
29# else
30# define bcm63xx_get_cpu_id() BCM6328_CPU_ID
31# endif
32# define BCMCPU_IS_6328() (bcm63xx_get_cpu_id() == BCM6328_CPU_ID)
33#else
34# define BCMCPU_IS_6328() (0)
35#endif
36
23#ifdef CONFIG_BCM63XX_CPU_6338 37#ifdef CONFIG_BCM63XX_CPU_6338
24# ifdef bcm63xx_get_cpu_id 38# ifdef bcm63xx_get_cpu_id
25# undef bcm63xx_get_cpu_id 39# undef bcm63xx_get_cpu_id
@@ -102,13 +116,13 @@ enum bcm63xx_regs_set {
102 RSET_UART1, 116 RSET_UART1,
103 RSET_GPIO, 117 RSET_GPIO,
104 RSET_SPI, 118 RSET_SPI,
105 RSET_SPI2,
106 RSET_UDC0, 119 RSET_UDC0,
107 RSET_OHCI0, 120 RSET_OHCI0,
108 RSET_OHCI_PRIV, 121 RSET_OHCI_PRIV,
109 RSET_USBH_PRIV, 122 RSET_USBH_PRIV,
110 RSET_MPI, 123 RSET_MPI,
111 RSET_PCMCIA, 124 RSET_PCMCIA,
125 RSET_PCIE,
112 RSET_DSL, 126 RSET_DSL,
113 RSET_ENET0, 127 RSET_ENET0,
114 RSET_ENET1, 128 RSET_ENET1,
@@ -130,11 +144,17 @@ enum bcm63xx_regs_set {
130 RSET_PCMDMA, 144 RSET_PCMDMA,
131 RSET_PCMDMAC, 145 RSET_PCMDMAC,
132 RSET_PCMDMAS, 146 RSET_PCMDMAS,
147 RSET_RNG,
148 RSET_MISC
133}; 149};
134 150
135#define RSET_DSL_LMEM_SIZE (64 * 1024 * 4) 151#define RSET_DSL_LMEM_SIZE (64 * 1024 * 4)
136#define RSET_DSL_SIZE 4096 152#define RSET_DSL_SIZE 4096
137#define RSET_WDT_SIZE 12 153#define RSET_WDT_SIZE 12
154#define BCM_6338_RSET_SPI_SIZE 64
155#define BCM_6348_RSET_SPI_SIZE 64
156#define BCM_6358_RSET_SPI_SIZE 1804
157#define BCM_6368_RSET_SPI_SIZE 1804
138#define RSET_ENET_SIZE 2048 158#define RSET_ENET_SIZE 2048
139#define RSET_ENETDMA_SIZE 2048 159#define RSET_ENETDMA_SIZE 2048
140#define RSET_ENETSW_SIZE 65536 160#define RSET_ENETSW_SIZE 65536
@@ -149,8 +169,53 @@ enum bcm63xx_regs_set {
149#define RSET_XTMDMA_SIZE 256 169#define RSET_XTMDMA_SIZE 256
150#define RSET_XTMDMAC_SIZE(chans) (16 * (chans)) 170#define RSET_XTMDMAC_SIZE(chans) (16 * (chans))
151#define RSET_XTMDMAS_SIZE(chans) (16 * (chans)) 171#define RSET_XTMDMAS_SIZE(chans) (16 * (chans))
172#define RSET_RNG_SIZE 20
152 173
153/* 174/*
175 * 6328 register sets base address
176 */
177#define BCM_6328_DSL_LMEM_BASE (0xdeadbeef)
178#define BCM_6328_PERF_BASE (0xb0000000)
179#define BCM_6328_TIMER_BASE (0xb0000040)
180#define BCM_6328_WDT_BASE (0xb000005c)
181#define BCM_6328_UART0_BASE (0xb0000100)
182#define BCM_6328_UART1_BASE (0xb0000120)
183#define BCM_6328_GPIO_BASE (0xb0000080)
184#define BCM_6328_SPI_BASE (0xdeadbeef)
185#define BCM_6328_UDC0_BASE (0xdeadbeef)
186#define BCM_6328_USBDMA_BASE (0xdeadbeef)
187#define BCM_6328_OHCI0_BASE (0xdeadbeef)
188#define BCM_6328_OHCI_PRIV_BASE (0xdeadbeef)
189#define BCM_6328_USBH_PRIV_BASE (0xdeadbeef)
190#define BCM_6328_MPI_BASE (0xdeadbeef)
191#define BCM_6328_PCMCIA_BASE (0xdeadbeef)
192#define BCM_6328_PCIE_BASE (0xb0e40000)
193#define BCM_6328_SDRAM_REGS_BASE (0xdeadbeef)
194#define BCM_6328_DSL_BASE (0xb0001900)
195#define BCM_6328_UBUS_BASE (0xdeadbeef)
196#define BCM_6328_ENET0_BASE (0xdeadbeef)
197#define BCM_6328_ENET1_BASE (0xdeadbeef)
198#define BCM_6328_ENETDMA_BASE (0xb000d800)
199#define BCM_6328_ENETDMAC_BASE (0xb000da00)
200#define BCM_6328_ENETDMAS_BASE (0xb000dc00)
201#define BCM_6328_ENETSW_BASE (0xb0e00000)
202#define BCM_6328_EHCI0_BASE (0x10002500)
203#define BCM_6328_SDRAM_BASE (0xdeadbeef)
204#define BCM_6328_MEMC_BASE (0xdeadbeef)
205#define BCM_6328_DDR_BASE (0xb0003000)
206#define BCM_6328_M2M_BASE (0xdeadbeef)
207#define BCM_6328_ATM_BASE (0xdeadbeef)
208#define BCM_6328_XTM_BASE (0xdeadbeef)
209#define BCM_6328_XTMDMA_BASE (0xb000b800)
210#define BCM_6328_XTMDMAC_BASE (0xdeadbeef)
211#define BCM_6328_XTMDMAS_BASE (0xdeadbeef)
212#define BCM_6328_PCM_BASE (0xb000a800)
213#define BCM_6328_PCMDMA_BASE (0xdeadbeef)
214#define BCM_6328_PCMDMAC_BASE (0xdeadbeef)
215#define BCM_6328_PCMDMAS_BASE (0xdeadbeef)
216#define BCM_6328_RNG_BASE (0xdeadbeef)
217#define BCM_6328_MISC_BASE (0xb0001800)
218/*
154 * 6338 register sets base address 219 * 6338 register sets base address
155 */ 220 */
156#define BCM_6338_DSL_LMEM_BASE (0xfff00000) 221#define BCM_6338_DSL_LMEM_BASE (0xfff00000)
@@ -162,7 +227,6 @@ enum bcm63xx_regs_set {
162#define BCM_6338_UART1_BASE (0xdeadbeef) 227#define BCM_6338_UART1_BASE (0xdeadbeef)
163#define BCM_6338_GPIO_BASE (0xfffe0400) 228#define BCM_6338_GPIO_BASE (0xfffe0400)
164#define BCM_6338_SPI_BASE (0xfffe0c00) 229#define BCM_6338_SPI_BASE (0xfffe0c00)
165#define BCM_6338_SPI2_BASE (0xdeadbeef)
166#define BCM_6338_UDC0_BASE (0xdeadbeef) 230#define BCM_6338_UDC0_BASE (0xdeadbeef)
167#define BCM_6338_USBDMA_BASE (0xfffe2400) 231#define BCM_6338_USBDMA_BASE (0xfffe2400)
168#define BCM_6338_OHCI0_BASE (0xdeadbeef) 232#define BCM_6338_OHCI0_BASE (0xdeadbeef)
@@ -170,6 +234,7 @@ enum bcm63xx_regs_set {
170#define BCM_6338_USBH_PRIV_BASE (0xdeadbeef) 234#define BCM_6338_USBH_PRIV_BASE (0xdeadbeef)
171#define BCM_6338_MPI_BASE (0xfffe3160) 235#define BCM_6338_MPI_BASE (0xfffe3160)
172#define BCM_6338_PCMCIA_BASE (0xdeadbeef) 236#define BCM_6338_PCMCIA_BASE (0xdeadbeef)
237#define BCM_6338_PCIE_BASE (0xdeadbeef)
173#define BCM_6338_SDRAM_REGS_BASE (0xfffe3100) 238#define BCM_6338_SDRAM_REGS_BASE (0xfffe3100)
174#define BCM_6338_DSL_BASE (0xfffe1000) 239#define BCM_6338_DSL_BASE (0xfffe1000)
175#define BCM_6338_UBUS_BASE (0xdeadbeef) 240#define BCM_6338_UBUS_BASE (0xdeadbeef)
@@ -193,6 +258,8 @@ enum bcm63xx_regs_set {
193#define BCM_6338_PCMDMA_BASE (0xdeadbeef) 258#define BCM_6338_PCMDMA_BASE (0xdeadbeef)
194#define BCM_6338_PCMDMAC_BASE (0xdeadbeef) 259#define BCM_6338_PCMDMAC_BASE (0xdeadbeef)
195#define BCM_6338_PCMDMAS_BASE (0xdeadbeef) 260#define BCM_6338_PCMDMAS_BASE (0xdeadbeef)
261#define BCM_6338_RNG_BASE (0xdeadbeef)
262#define BCM_6338_MISC_BASE (0xdeadbeef)
196 263
197/* 264/*
198 * 6345 register sets base address 265 * 6345 register sets base address
@@ -206,7 +273,6 @@ enum bcm63xx_regs_set {
206#define BCM_6345_UART1_BASE (0xdeadbeef) 273#define BCM_6345_UART1_BASE (0xdeadbeef)
207#define BCM_6345_GPIO_BASE (0xfffe0400) 274#define BCM_6345_GPIO_BASE (0xfffe0400)
208#define BCM_6345_SPI_BASE (0xdeadbeef) 275#define BCM_6345_SPI_BASE (0xdeadbeef)
209#define BCM_6345_SPI2_BASE (0xdeadbeef)
210#define BCM_6345_UDC0_BASE (0xdeadbeef) 276#define BCM_6345_UDC0_BASE (0xdeadbeef)
211#define BCM_6345_USBDMA_BASE (0xfffe2800) 277#define BCM_6345_USBDMA_BASE (0xfffe2800)
212#define BCM_6345_ENET0_BASE (0xfffe1800) 278#define BCM_6345_ENET0_BASE (0xfffe1800)
@@ -216,6 +282,7 @@ enum bcm63xx_regs_set {
216#define BCM_6345_ENETSW_BASE (0xdeadbeef) 282#define BCM_6345_ENETSW_BASE (0xdeadbeef)
217#define BCM_6345_PCMCIA_BASE (0xfffe2028) 283#define BCM_6345_PCMCIA_BASE (0xfffe2028)
218#define BCM_6345_MPI_BASE (0xfffe2000) 284#define BCM_6345_MPI_BASE (0xfffe2000)
285#define BCM_6345_PCIE_BASE (0xdeadbeef)
219#define BCM_6345_OHCI0_BASE (0xfffe2100) 286#define BCM_6345_OHCI0_BASE (0xfffe2100)
220#define BCM_6345_OHCI_PRIV_BASE (0xfffe2200) 287#define BCM_6345_OHCI_PRIV_BASE (0xfffe2200)
221#define BCM_6345_USBH_PRIV_BASE (0xdeadbeef) 288#define BCM_6345_USBH_PRIV_BASE (0xdeadbeef)
@@ -237,6 +304,8 @@ enum bcm63xx_regs_set {
237#define BCM_6345_PCMDMA_BASE (0xdeadbeef) 304#define BCM_6345_PCMDMA_BASE (0xdeadbeef)
238#define BCM_6345_PCMDMAC_BASE (0xdeadbeef) 305#define BCM_6345_PCMDMAC_BASE (0xdeadbeef)
239#define BCM_6345_PCMDMAS_BASE (0xdeadbeef) 306#define BCM_6345_PCMDMAS_BASE (0xdeadbeef)
307#define BCM_6345_RNG_BASE (0xdeadbeef)
308#define BCM_6345_MISC_BASE (0xdeadbeef)
240 309
241/* 310/*
242 * 6348 register sets base address 311 * 6348 register sets base address
@@ -249,13 +318,13 @@ enum bcm63xx_regs_set {
249#define BCM_6348_UART1_BASE (0xdeadbeef) 318#define BCM_6348_UART1_BASE (0xdeadbeef)
250#define BCM_6348_GPIO_BASE (0xfffe0400) 319#define BCM_6348_GPIO_BASE (0xfffe0400)
251#define BCM_6348_SPI_BASE (0xfffe0c00) 320#define BCM_6348_SPI_BASE (0xfffe0c00)
252#define BCM_6348_SPI2_BASE (0xdeadbeef)
253#define BCM_6348_UDC0_BASE (0xfffe1000) 321#define BCM_6348_UDC0_BASE (0xfffe1000)
254#define BCM_6348_OHCI0_BASE (0xfffe1b00) 322#define BCM_6348_OHCI0_BASE (0xfffe1b00)
255#define BCM_6348_OHCI_PRIV_BASE (0xfffe1c00) 323#define BCM_6348_OHCI_PRIV_BASE (0xfffe1c00)
256#define BCM_6348_USBH_PRIV_BASE (0xdeadbeef) 324#define BCM_6348_USBH_PRIV_BASE (0xdeadbeef)
257#define BCM_6348_MPI_BASE (0xfffe2000) 325#define BCM_6348_MPI_BASE (0xfffe2000)
258#define BCM_6348_PCMCIA_BASE (0xfffe2054) 326#define BCM_6348_PCMCIA_BASE (0xfffe2054)
327#define BCM_6348_PCIE_BASE (0xdeadbeef)
259#define BCM_6348_SDRAM_REGS_BASE (0xfffe2300) 328#define BCM_6348_SDRAM_REGS_BASE (0xfffe2300)
260#define BCM_6348_M2M_BASE (0xfffe2800) 329#define BCM_6348_M2M_BASE (0xfffe2800)
261#define BCM_6348_DSL_BASE (0xfffe3000) 330#define BCM_6348_DSL_BASE (0xfffe3000)
@@ -278,6 +347,8 @@ enum bcm63xx_regs_set {
278#define BCM_6348_PCMDMA_BASE (0xdeadbeef) 347#define BCM_6348_PCMDMA_BASE (0xdeadbeef)
279#define BCM_6348_PCMDMAC_BASE (0xdeadbeef) 348#define BCM_6348_PCMDMAC_BASE (0xdeadbeef)
280#define BCM_6348_PCMDMAS_BASE (0xdeadbeef) 349#define BCM_6348_PCMDMAS_BASE (0xdeadbeef)
350#define BCM_6348_RNG_BASE (0xdeadbeef)
351#define BCM_6348_MISC_BASE (0xdeadbeef)
281 352
282/* 353/*
283 * 6358 register sets base address 354 * 6358 register sets base address
@@ -289,14 +360,14 @@ enum bcm63xx_regs_set {
289#define BCM_6358_UART0_BASE (0xfffe0100) 360#define BCM_6358_UART0_BASE (0xfffe0100)
290#define BCM_6358_UART1_BASE (0xfffe0120) 361#define BCM_6358_UART1_BASE (0xfffe0120)
291#define BCM_6358_GPIO_BASE (0xfffe0080) 362#define BCM_6358_GPIO_BASE (0xfffe0080)
292#define BCM_6358_SPI_BASE (0xdeadbeef) 363#define BCM_6358_SPI_BASE (0xfffe0800)
293#define BCM_6358_SPI2_BASE (0xfffe0800)
294#define BCM_6358_UDC0_BASE (0xfffe0800) 364#define BCM_6358_UDC0_BASE (0xfffe0800)
295#define BCM_6358_OHCI0_BASE (0xfffe1400) 365#define BCM_6358_OHCI0_BASE (0xfffe1400)
296#define BCM_6358_OHCI_PRIV_BASE (0xdeadbeef) 366#define BCM_6358_OHCI_PRIV_BASE (0xdeadbeef)
297#define BCM_6358_USBH_PRIV_BASE (0xfffe1500) 367#define BCM_6358_USBH_PRIV_BASE (0xfffe1500)
298#define BCM_6358_MPI_BASE (0xfffe1000) 368#define BCM_6358_MPI_BASE (0xfffe1000)
299#define BCM_6358_PCMCIA_BASE (0xfffe1054) 369#define BCM_6358_PCMCIA_BASE (0xfffe1054)
370#define BCM_6358_PCIE_BASE (0xdeadbeef)
300#define BCM_6358_SDRAM_REGS_BASE (0xfffe2300) 371#define BCM_6358_SDRAM_REGS_BASE (0xfffe2300)
301#define BCM_6358_M2M_BASE (0xdeadbeef) 372#define BCM_6358_M2M_BASE (0xdeadbeef)
302#define BCM_6358_DSL_BASE (0xfffe3000) 373#define BCM_6358_DSL_BASE (0xfffe3000)
@@ -319,6 +390,8 @@ enum bcm63xx_regs_set {
319#define BCM_6358_PCMDMA_BASE (0xfffe1800) 390#define BCM_6358_PCMDMA_BASE (0xfffe1800)
320#define BCM_6358_PCMDMAC_BASE (0xfffe1900) 391#define BCM_6358_PCMDMAC_BASE (0xfffe1900)
321#define BCM_6358_PCMDMAS_BASE (0xfffe1a00) 392#define BCM_6358_PCMDMAS_BASE (0xfffe1a00)
393#define BCM_6358_RNG_BASE (0xdeadbeef)
394#define BCM_6358_MISC_BASE (0xdeadbeef)
322 395
323 396
324/* 397/*
@@ -331,14 +404,14 @@ enum bcm63xx_regs_set {
331#define BCM_6368_UART0_BASE (0xb0000100) 404#define BCM_6368_UART0_BASE (0xb0000100)
332#define BCM_6368_UART1_BASE (0xb0000120) 405#define BCM_6368_UART1_BASE (0xb0000120)
333#define BCM_6368_GPIO_BASE (0xb0000080) 406#define BCM_6368_GPIO_BASE (0xb0000080)
334#define BCM_6368_SPI_BASE (0xdeadbeef) 407#define BCM_6368_SPI_BASE (0xb0000800)
335#define BCM_6368_SPI2_BASE (0xb0000800)
336#define BCM_6368_UDC0_BASE (0xdeadbeef) 408#define BCM_6368_UDC0_BASE (0xdeadbeef)
337#define BCM_6368_OHCI0_BASE (0xb0001600) 409#define BCM_6368_OHCI0_BASE (0xb0001600)
338#define BCM_6368_OHCI_PRIV_BASE (0xdeadbeef) 410#define BCM_6368_OHCI_PRIV_BASE (0xdeadbeef)
339#define BCM_6368_USBH_PRIV_BASE (0xb0001700) 411#define BCM_6368_USBH_PRIV_BASE (0xb0001700)
340#define BCM_6368_MPI_BASE (0xb0001000) 412#define BCM_6368_MPI_BASE (0xb0001000)
341#define BCM_6368_PCMCIA_BASE (0xb0001054) 413#define BCM_6368_PCMCIA_BASE (0xb0001054)
414#define BCM_6368_PCIE_BASE (0xdeadbeef)
342#define BCM_6368_SDRAM_REGS_BASE (0xdeadbeef) 415#define BCM_6368_SDRAM_REGS_BASE (0xdeadbeef)
343#define BCM_6368_M2M_BASE (0xdeadbeef) 416#define BCM_6368_M2M_BASE (0xdeadbeef)
344#define BCM_6368_DSL_BASE (0xdeadbeef) 417#define BCM_6368_DSL_BASE (0xdeadbeef)
@@ -361,6 +434,8 @@ enum bcm63xx_regs_set {
361#define BCM_6368_PCMDMA_BASE (0xb0005800) 434#define BCM_6368_PCMDMA_BASE (0xb0005800)
362#define BCM_6368_PCMDMAC_BASE (0xb0005a00) 435#define BCM_6368_PCMDMAC_BASE (0xb0005a00)
363#define BCM_6368_PCMDMAS_BASE (0xb0005c00) 436#define BCM_6368_PCMDMAS_BASE (0xb0005c00)
437#define BCM_6368_RNG_BASE (0xb0004180)
438#define BCM_6368_MISC_BASE (0xdeadbeef)
364 439
365 440
366extern const unsigned long *bcm63xx_regs_base; 441extern const unsigned long *bcm63xx_regs_base;
@@ -379,13 +454,13 @@ extern const unsigned long *bcm63xx_regs_base;
379 __GEN_RSET_BASE(__cpu, UART1) \ 454 __GEN_RSET_BASE(__cpu, UART1) \
380 __GEN_RSET_BASE(__cpu, GPIO) \ 455 __GEN_RSET_BASE(__cpu, GPIO) \
381 __GEN_RSET_BASE(__cpu, SPI) \ 456 __GEN_RSET_BASE(__cpu, SPI) \
382 __GEN_RSET_BASE(__cpu, SPI2) \
383 __GEN_RSET_BASE(__cpu, UDC0) \ 457 __GEN_RSET_BASE(__cpu, UDC0) \
384 __GEN_RSET_BASE(__cpu, OHCI0) \ 458 __GEN_RSET_BASE(__cpu, OHCI0) \
385 __GEN_RSET_BASE(__cpu, OHCI_PRIV) \ 459 __GEN_RSET_BASE(__cpu, OHCI_PRIV) \
386 __GEN_RSET_BASE(__cpu, USBH_PRIV) \ 460 __GEN_RSET_BASE(__cpu, USBH_PRIV) \
387 __GEN_RSET_BASE(__cpu, MPI) \ 461 __GEN_RSET_BASE(__cpu, MPI) \
388 __GEN_RSET_BASE(__cpu, PCMCIA) \ 462 __GEN_RSET_BASE(__cpu, PCMCIA) \
463 __GEN_RSET_BASE(__cpu, PCIE) \
389 __GEN_RSET_BASE(__cpu, DSL) \ 464 __GEN_RSET_BASE(__cpu, DSL) \
390 __GEN_RSET_BASE(__cpu, ENET0) \ 465 __GEN_RSET_BASE(__cpu, ENET0) \
391 __GEN_RSET_BASE(__cpu, ENET1) \ 466 __GEN_RSET_BASE(__cpu, ENET1) \
@@ -407,6 +482,8 @@ extern const unsigned long *bcm63xx_regs_base;
407 __GEN_RSET_BASE(__cpu, PCMDMA) \ 482 __GEN_RSET_BASE(__cpu, PCMDMA) \
408 __GEN_RSET_BASE(__cpu, PCMDMAC) \ 483 __GEN_RSET_BASE(__cpu, PCMDMAC) \
409 __GEN_RSET_BASE(__cpu, PCMDMAS) \ 484 __GEN_RSET_BASE(__cpu, PCMDMAS) \
485 __GEN_RSET_BASE(__cpu, RNG) \
486 __GEN_RSET_BASE(__cpu, MISC) \
410 } 487 }
411 488
412#define __GEN_CPU_REGS_TABLE(__cpu) \ 489#define __GEN_CPU_REGS_TABLE(__cpu) \
@@ -418,13 +495,13 @@ extern const unsigned long *bcm63xx_regs_base;
418 [RSET_UART1] = BCM_## __cpu ##_UART1_BASE, \ 495 [RSET_UART1] = BCM_## __cpu ##_UART1_BASE, \
419 [RSET_GPIO] = BCM_## __cpu ##_GPIO_BASE, \ 496 [RSET_GPIO] = BCM_## __cpu ##_GPIO_BASE, \
420 [RSET_SPI] = BCM_## __cpu ##_SPI_BASE, \ 497 [RSET_SPI] = BCM_## __cpu ##_SPI_BASE, \
421 [RSET_SPI2] = BCM_## __cpu ##_SPI2_BASE, \
422 [RSET_UDC0] = BCM_## __cpu ##_UDC0_BASE, \ 498 [RSET_UDC0] = BCM_## __cpu ##_UDC0_BASE, \
423 [RSET_OHCI0] = BCM_## __cpu ##_OHCI0_BASE, \ 499 [RSET_OHCI0] = BCM_## __cpu ##_OHCI0_BASE, \
424 [RSET_OHCI_PRIV] = BCM_## __cpu ##_OHCI_PRIV_BASE, \ 500 [RSET_OHCI_PRIV] = BCM_## __cpu ##_OHCI_PRIV_BASE, \
425 [RSET_USBH_PRIV] = BCM_## __cpu ##_USBH_PRIV_BASE, \ 501 [RSET_USBH_PRIV] = BCM_## __cpu ##_USBH_PRIV_BASE, \
426 [RSET_MPI] = BCM_## __cpu ##_MPI_BASE, \ 502 [RSET_MPI] = BCM_## __cpu ##_MPI_BASE, \
427 [RSET_PCMCIA] = BCM_## __cpu ##_PCMCIA_BASE, \ 503 [RSET_PCMCIA] = BCM_## __cpu ##_PCMCIA_BASE, \
504 [RSET_PCIE] = BCM_## __cpu ##_PCIE_BASE, \
428 [RSET_DSL] = BCM_## __cpu ##_DSL_BASE, \ 505 [RSET_DSL] = BCM_## __cpu ##_DSL_BASE, \
429 [RSET_ENET0] = BCM_## __cpu ##_ENET0_BASE, \ 506 [RSET_ENET0] = BCM_## __cpu ##_ENET0_BASE, \
430 [RSET_ENET1] = BCM_## __cpu ##_ENET1_BASE, \ 507 [RSET_ENET1] = BCM_## __cpu ##_ENET1_BASE, \
@@ -446,6 +523,8 @@ extern const unsigned long *bcm63xx_regs_base;
446 [RSET_PCMDMA] = BCM_## __cpu ##_PCMDMA_BASE, \ 523 [RSET_PCMDMA] = BCM_## __cpu ##_PCMDMA_BASE, \
447 [RSET_PCMDMAC] = BCM_## __cpu ##_PCMDMAC_BASE, \ 524 [RSET_PCMDMAC] = BCM_## __cpu ##_PCMDMAC_BASE, \
448 [RSET_PCMDMAS] = BCM_## __cpu ##_PCMDMAS_BASE, \ 525 [RSET_PCMDMAS] = BCM_## __cpu ##_PCMDMAS_BASE, \
526 [RSET_RNG] = BCM_## __cpu ##_RNG_BASE, \
527 [RSET_MISC] = BCM_## __cpu ##_MISC_BASE, \
449 528
450 529
451static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set) 530static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
@@ -453,6 +532,9 @@ static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
453#ifdef BCMCPU_RUNTIME_DETECT 532#ifdef BCMCPU_RUNTIME_DETECT
454 return bcm63xx_regs_base[set]; 533 return bcm63xx_regs_base[set];
455#else 534#else
535#ifdef CONFIG_BCM63XX_CPU_6328
536 __GEN_RSET(6328)
537#endif
456#ifdef CONFIG_BCM63XX_CPU_6338 538#ifdef CONFIG_BCM63XX_CPU_6338
457 __GEN_RSET(6338) 539 __GEN_RSET(6338)
458#endif 540#endif
@@ -478,6 +560,7 @@ static inline unsigned long bcm63xx_regset_address(enum bcm63xx_regs_set set)
478 */ 560 */
479enum bcm63xx_irq { 561enum bcm63xx_irq {
480 IRQ_TIMER = 0, 562 IRQ_TIMER = 0,
563 IRQ_SPI,
481 IRQ_UART0, 564 IRQ_UART0,
482 IRQ_UART1, 565 IRQ_UART1,
483 IRQ_DSL, 566 IRQ_DSL,
@@ -506,9 +589,51 @@ enum bcm63xx_irq {
506}; 589};
507 590
508/* 591/*
592 * 6328 irqs
593 */
594#define BCM_6328_HIGH_IRQ_BASE (IRQ_INTERNAL_BASE + 32)
595
596#define BCM_6328_TIMER_IRQ (IRQ_INTERNAL_BASE + 31)
597#define BCM_6328_SPI_IRQ 0
598#define BCM_6328_UART0_IRQ (IRQ_INTERNAL_BASE + 28)
599#define BCM_6328_UART1_IRQ (BCM_6328_HIGH_IRQ_BASE + 7)
600#define BCM_6328_DSL_IRQ (IRQ_INTERNAL_BASE + 4)
601#define BCM_6328_UDC0_IRQ 0
602#define BCM_6328_ENET0_IRQ 0
603#define BCM_6328_ENET1_IRQ 0
604#define BCM_6328_ENET_PHY_IRQ (IRQ_INTERNAL_BASE + 12)
605#define BCM_6328_OHCI0_IRQ (IRQ_INTERNAL_BASE + 9)
606#define BCM_6328_EHCI0_IRQ (IRQ_INTERNAL_BASE + 10)
607#define BCM_6328_PCMCIA_IRQ 0
608#define BCM_6328_ENET0_RXDMA_IRQ 0
609#define BCM_6328_ENET0_TXDMA_IRQ 0
610#define BCM_6328_ENET1_RXDMA_IRQ 0
611#define BCM_6328_ENET1_TXDMA_IRQ 0
612#define BCM_6328_PCI_IRQ (IRQ_INTERNAL_BASE + 23)
613#define BCM_6328_ATM_IRQ 0
614#define BCM_6328_ENETSW_RXDMA0_IRQ (BCM_6328_HIGH_IRQ_BASE + 0)
615#define BCM_6328_ENETSW_RXDMA1_IRQ (BCM_6328_HIGH_IRQ_BASE + 1)
616#define BCM_6328_ENETSW_RXDMA2_IRQ (BCM_6328_HIGH_IRQ_BASE + 2)
617#define BCM_6328_ENETSW_RXDMA3_IRQ (BCM_6328_HIGH_IRQ_BASE + 3)
618#define BCM_6328_ENETSW_TXDMA0_IRQ (BCM_6328_HIGH_IRQ_BASE + 4)
619#define BCM_6328_ENETSW_TXDMA1_IRQ (BCM_6328_HIGH_IRQ_BASE + 5)
620#define BCM_6328_ENETSW_TXDMA2_IRQ (BCM_6328_HIGH_IRQ_BASE + 6)
621#define BCM_6328_ENETSW_TXDMA3_IRQ (BCM_6328_HIGH_IRQ_BASE + 7)
622#define BCM_6328_XTM_IRQ (BCM_6328_HIGH_IRQ_BASE + 31)
623#define BCM_6328_XTM_DMA0_IRQ (BCM_6328_HIGH_IRQ_BASE + 11)
624
625#define BCM_6328_PCM_DMA0_IRQ (IRQ_INTERNAL_BASE + 2)
626#define BCM_6328_PCM_DMA1_IRQ (IRQ_INTERNAL_BASE + 3)
627#define BCM_6328_EXT_IRQ0 (IRQ_INTERNAL_BASE + 24)
628#define BCM_6328_EXT_IRQ1 (IRQ_INTERNAL_BASE + 25)
629#define BCM_6328_EXT_IRQ2 (IRQ_INTERNAL_BASE + 26)
630#define BCM_6328_EXT_IRQ3 (IRQ_INTERNAL_BASE + 27)
631
632/*
509 * 6338 irqs 633 * 6338 irqs
510 */ 634 */
511#define BCM_6338_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) 635#define BCM_6338_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
636#define BCM_6338_SPI_IRQ (IRQ_INTERNAL_BASE + 1)
512#define BCM_6338_UART0_IRQ (IRQ_INTERNAL_BASE + 2) 637#define BCM_6338_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
513#define BCM_6338_UART1_IRQ 0 638#define BCM_6338_UART1_IRQ 0
514#define BCM_6338_DSL_IRQ (IRQ_INTERNAL_BASE + 5) 639#define BCM_6338_DSL_IRQ (IRQ_INTERNAL_BASE + 5)
@@ -539,6 +664,7 @@ enum bcm63xx_irq {
539 * 6345 irqs 664 * 6345 irqs
540 */ 665 */
541#define BCM_6345_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) 666#define BCM_6345_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
667#define BCM_6345_SPI_IRQ 0
542#define BCM_6345_UART0_IRQ (IRQ_INTERNAL_BASE + 2) 668#define BCM_6345_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
543#define BCM_6345_UART1_IRQ 0 669#define BCM_6345_UART1_IRQ 0
544#define BCM_6345_DSL_IRQ (IRQ_INTERNAL_BASE + 3) 670#define BCM_6345_DSL_IRQ (IRQ_INTERNAL_BASE + 3)
@@ -569,6 +695,7 @@ enum bcm63xx_irq {
569 * 6348 irqs 695 * 6348 irqs
570 */ 696 */
571#define BCM_6348_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) 697#define BCM_6348_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
698#define BCM_6348_SPI_IRQ (IRQ_INTERNAL_BASE + 1)
572#define BCM_6348_UART0_IRQ (IRQ_INTERNAL_BASE + 2) 699#define BCM_6348_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
573#define BCM_6348_UART1_IRQ 0 700#define BCM_6348_UART1_IRQ 0
574#define BCM_6348_DSL_IRQ (IRQ_INTERNAL_BASE + 4) 701#define BCM_6348_DSL_IRQ (IRQ_INTERNAL_BASE + 4)
@@ -599,6 +726,7 @@ enum bcm63xx_irq {
599 * 6358 irqs 726 * 6358 irqs
600 */ 727 */
601#define BCM_6358_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) 728#define BCM_6358_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
729#define BCM_6358_SPI_IRQ (IRQ_INTERNAL_BASE + 1)
602#define BCM_6358_UART0_IRQ (IRQ_INTERNAL_BASE + 2) 730#define BCM_6358_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
603#define BCM_6358_UART1_IRQ (IRQ_INTERNAL_BASE + 3) 731#define BCM_6358_UART1_IRQ (IRQ_INTERNAL_BASE + 3)
604#define BCM_6358_DSL_IRQ (IRQ_INTERNAL_BASE + 29) 732#define BCM_6358_DSL_IRQ (IRQ_INTERNAL_BASE + 29)
@@ -638,6 +766,7 @@ enum bcm63xx_irq {
638#define BCM_6368_HIGH_IRQ_BASE (IRQ_INTERNAL_BASE + 32) 766#define BCM_6368_HIGH_IRQ_BASE (IRQ_INTERNAL_BASE + 32)
639 767
640#define BCM_6368_TIMER_IRQ (IRQ_INTERNAL_BASE + 0) 768#define BCM_6368_TIMER_IRQ (IRQ_INTERNAL_BASE + 0)
769#define BCM_6368_SPI_IRQ (IRQ_INTERNAL_BASE + 1)
641#define BCM_6368_UART0_IRQ (IRQ_INTERNAL_BASE + 2) 770#define BCM_6368_UART0_IRQ (IRQ_INTERNAL_BASE + 2)
642#define BCM_6368_UART1_IRQ (IRQ_INTERNAL_BASE + 3) 771#define BCM_6368_UART1_IRQ (IRQ_INTERNAL_BASE + 3)
643#define BCM_6368_DSL_IRQ (IRQ_INTERNAL_BASE + 4) 772#define BCM_6368_DSL_IRQ (IRQ_INTERNAL_BASE + 4)
@@ -677,6 +806,7 @@ extern const int *bcm63xx_irqs;
677 806
678#define __GEN_CPU_IRQ_TABLE(__cpu) \ 807#define __GEN_CPU_IRQ_TABLE(__cpu) \
679 [IRQ_TIMER] = BCM_## __cpu ##_TIMER_IRQ, \ 808 [IRQ_TIMER] = BCM_## __cpu ##_TIMER_IRQ, \
809 [IRQ_SPI] = BCM_## __cpu ##_SPI_IRQ, \
680 [IRQ_UART0] = BCM_## __cpu ##_UART0_IRQ, \ 810 [IRQ_UART0] = BCM_## __cpu ##_UART0_IRQ, \
681 [IRQ_UART1] = BCM_## __cpu ##_UART1_IRQ, \ 811 [IRQ_UART1] = BCM_## __cpu ##_UART1_IRQ, \
682 [IRQ_DSL] = BCM_## __cpu ##_DSL_IRQ, \ 812 [IRQ_DSL] = BCM_## __cpu ##_DSL_IRQ, \
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
new file mode 100644
index 000000000000..354b8481ec4a
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_flash.h
@@ -0,0 +1,12 @@
1#ifndef __BCM63XX_FLASH_H
2#define __BCM63XX_FLASH_H
3
4enum {
5 BCM63XX_FLASH_TYPE_PARALLEL,
6 BCM63XX_FLASH_TYPE_SERIAL,
7 BCM63XX_FLASH_TYPE_NAND,
8};
9
10int __init bcm63xx_flash_register(void);
11
12#endif /* __BCM63XX_FLASH_H */
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h
new file mode 100644
index 000000000000..7d98dbe5d4b5
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_spi.h
@@ -0,0 +1,89 @@
1#ifndef BCM63XX_DEV_SPI_H
2#define BCM63XX_DEV_SPI_H
3
4#include <linux/types.h>
5#include <bcm63xx_io.h>
6#include <bcm63xx_regs.h>
7
8int __init bcm63xx_spi_register(void);
9
10struct bcm63xx_spi_pdata {
11 unsigned int fifo_size;
12 int bus_num;
13 int num_chipselect;
14 u32 speed_hz;
15};
16
17enum bcm63xx_regs_spi {
18 SPI_CMD,
19 SPI_INT_STATUS,
20 SPI_INT_MASK_ST,
21 SPI_INT_MASK,
22 SPI_ST,
23 SPI_CLK_CFG,
24 SPI_FILL_BYTE,
25 SPI_MSG_TAIL,
26 SPI_RX_TAIL,
27 SPI_MSG_CTL,
28 SPI_MSG_DATA,
29 SPI_RX_DATA,
30};
31
32#define __GEN_SPI_RSET_BASE(__cpu, __rset) \
33 case SPI_## __rset: \
34 return SPI_## __cpu ##_## __rset;
35
36#define __GEN_SPI_RSET(__cpu) \
37 switch (reg) { \
38 __GEN_SPI_RSET_BASE(__cpu, CMD) \
39 __GEN_SPI_RSET_BASE(__cpu, INT_STATUS) \
40 __GEN_SPI_RSET_BASE(__cpu, INT_MASK_ST) \
41 __GEN_SPI_RSET_BASE(__cpu, INT_MASK) \
42 __GEN_SPI_RSET_BASE(__cpu, ST) \
43 __GEN_SPI_RSET_BASE(__cpu, CLK_CFG) \
44 __GEN_SPI_RSET_BASE(__cpu, FILL_BYTE) \
45 __GEN_SPI_RSET_BASE(__cpu, MSG_TAIL) \
46 __GEN_SPI_RSET_BASE(__cpu, RX_TAIL) \
47 __GEN_SPI_RSET_BASE(__cpu, MSG_CTL) \
48 __GEN_SPI_RSET_BASE(__cpu, MSG_DATA) \
49 __GEN_SPI_RSET_BASE(__cpu, RX_DATA) \
50 }
51
52#define __GEN_SPI_REGS_TABLE(__cpu) \
53 [SPI_CMD] = SPI_## __cpu ##_CMD, \
54 [SPI_INT_STATUS] = SPI_## __cpu ##_INT_STATUS, \
55 [SPI_INT_MASK_ST] = SPI_## __cpu ##_INT_MASK_ST, \
56 [SPI_INT_MASK] = SPI_## __cpu ##_INT_MASK, \
57 [SPI_ST] = SPI_## __cpu ##_ST, \
58 [SPI_CLK_CFG] = SPI_## __cpu ##_CLK_CFG, \
59 [SPI_FILL_BYTE] = SPI_## __cpu ##_FILL_BYTE, \
60 [SPI_MSG_TAIL] = SPI_## __cpu ##_MSG_TAIL, \
61 [SPI_RX_TAIL] = SPI_## __cpu ##_RX_TAIL, \
62 [SPI_MSG_CTL] = SPI_## __cpu ##_MSG_CTL, \
63 [SPI_MSG_DATA] = SPI_## __cpu ##_MSG_DATA, \
64 [SPI_RX_DATA] = SPI_## __cpu ##_RX_DATA,
65
66static inline unsigned long bcm63xx_spireg(enum bcm63xx_regs_spi reg)
67{
68#ifdef BCMCPU_RUNTIME_DETECT
69 extern const unsigned long *bcm63xx_regs_spi;
70
71 return bcm63xx_regs_spi[reg];
72#else
73#ifdef CONFIG_BCM63XX_CPU_6338
74 __GEN_SPI_RSET(6338)
75#endif
76#ifdef CONFIG_BCM63XX_CPU_6348
77 __GEN_SPI_RSET(6348)
78#endif
79#ifdef CONFIG_BCM63XX_CPU_6358
80 __GEN_SPI_RSET(6358)
81#endif
82#ifdef CONFIG_BCM63XX_CPU_6368
83 __GEN_SPI_RSET(6368)
84#endif
85#endif
86 return 0;
87}
88
89#endif /* BCM63XX_DEV_SPI_H */
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
index 1d7dd96aa460..0a9891f7580d 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
@@ -9,6 +9,8 @@ int __init bcm63xx_gpio_init(void);
9static inline unsigned long bcm63xx_gpio_count(void) 9static inline unsigned long bcm63xx_gpio_count(void)
10{ 10{
11 switch (bcm63xx_get_cpu_id()) { 11 switch (bcm63xx_get_cpu_id()) {
12 case BCM6328_CPU_ID:
13 return 32;
12 case BCM6358_CPU_ID: 14 case BCM6358_CPU_ID:
13 return 40; 15 return 40;
14 case BCM6338_CPU_ID: 16 case BCM6338_CPU_ID:
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h
index 72477a6441dd..9203d90e610c 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h
@@ -40,6 +40,10 @@
40#define BCM_CB_MEM_END_PA (BCM_CB_MEM_BASE_PA + \ 40#define BCM_CB_MEM_END_PA (BCM_CB_MEM_BASE_PA + \
41 BCM_CB_MEM_SIZE - 1) 41 BCM_CB_MEM_SIZE - 1)
42 42
43#define BCM_PCIE_MEM_BASE_PA 0x10f00000
44#define BCM_PCIE_MEM_SIZE (16 * 1024 * 1024)
45#define BCM_PCIE_MEM_END_PA (BCM_PCIE_MEM_BASE_PA + \
46 BCM_PCIE_MEM_SIZE - 1)
43 47
44/* 48/*
45 * Internal registers are accessed through KSEG3 49 * Internal registers are accessed through KSEG3
@@ -85,11 +89,15 @@
85#define bcm_mpi_writel(v, o) bcm_rset_writel(RSET_MPI, (v), (o)) 89#define bcm_mpi_writel(v, o) bcm_rset_writel(RSET_MPI, (v), (o))
86#define bcm_pcmcia_readl(o) bcm_rset_readl(RSET_PCMCIA, (o)) 90#define bcm_pcmcia_readl(o) bcm_rset_readl(RSET_PCMCIA, (o))
87#define bcm_pcmcia_writel(v, o) bcm_rset_writel(RSET_PCMCIA, (v), (o)) 91#define bcm_pcmcia_writel(v, o) bcm_rset_writel(RSET_PCMCIA, (v), (o))
92#define bcm_pcie_readl(o) bcm_rset_readl(RSET_PCIE, (o))
93#define bcm_pcie_writel(v, o) bcm_rset_writel(RSET_PCIE, (v), (o))
88#define bcm_sdram_readl(o) bcm_rset_readl(RSET_SDRAM, (o)) 94#define bcm_sdram_readl(o) bcm_rset_readl(RSET_SDRAM, (o))
89#define bcm_sdram_writel(v, o) bcm_rset_writel(RSET_SDRAM, (v), (o)) 95#define bcm_sdram_writel(v, o) bcm_rset_writel(RSET_SDRAM, (v), (o))
90#define bcm_memc_readl(o) bcm_rset_readl(RSET_MEMC, (o)) 96#define bcm_memc_readl(o) bcm_rset_readl(RSET_MEMC, (o))
91#define bcm_memc_writel(v, o) bcm_rset_writel(RSET_MEMC, (v), (o)) 97#define bcm_memc_writel(v, o) bcm_rset_writel(RSET_MEMC, (v), (o))
92#define bcm_ddr_readl(o) bcm_rset_readl(RSET_DDR, (o)) 98#define bcm_ddr_readl(o) bcm_rset_readl(RSET_DDR, (o))
93#define bcm_ddr_writel(v, o) bcm_rset_writel(RSET_DDR, (v), (o)) 99#define bcm_ddr_writel(v, o) bcm_rset_writel(RSET_DDR, (v), (o))
100#define bcm_misc_readl(o) bcm_rset_readl(RSET_MISC, (o))
101#define bcm_misc_writel(v, o) bcm_rset_writel(RSET_MISC, (v), (o))
94 102
95#endif /* ! BCM63XX_IO_H_ */ 103#endif /* ! BCM63XX_IO_H_ */
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
index fdcd78ca1b03..4ccc2a748aff 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
@@ -15,6 +15,30 @@
15/* Clock Control register */ 15/* Clock Control register */
16#define PERF_CKCTL_REG 0x4 16#define PERF_CKCTL_REG 0x4
17 17
18#define CKCTL_6328_PHYMIPS_EN (1 << 0)
19#define CKCTL_6328_ADSL_QPROC_EN (1 << 1)
20#define CKCTL_6328_ADSL_AFE_EN (1 << 2)
21#define CKCTL_6328_ADSL_EN (1 << 3)
22#define CKCTL_6328_MIPS_EN (1 << 4)
23#define CKCTL_6328_SAR_EN (1 << 5)
24#define CKCTL_6328_PCM_EN (1 << 6)
25#define CKCTL_6328_USBD_EN (1 << 7)
26#define CKCTL_6328_USBH_EN (1 << 8)
27#define CKCTL_6328_HSSPI_EN (1 << 9)
28#define CKCTL_6328_PCIE_EN (1 << 10)
29#define CKCTL_6328_ROBOSW_EN (1 << 11)
30
31#define CKCTL_6328_ALL_SAFE_EN (CKCTL_6328_PHYMIPS_EN | \
32 CKCTL_6328_ADSL_QPROC_EN | \
33 CKCTL_6328_ADSL_AFE_EN | \
34 CKCTL_6328_ADSL_EN | \
35 CKCTL_6328_SAR_EN | \
36 CKCTL_6328_PCM_EN | \
37 CKCTL_6328_USBD_EN | \
38 CKCTL_6328_USBH_EN | \
39 CKCTL_6328_ROBOSW_EN | \
40 CKCTL_6328_PCIE_EN)
41
18#define CKCTL_6338_ADSLPHY_EN (1 << 0) 42#define CKCTL_6338_ADSLPHY_EN (1 << 0)
19#define CKCTL_6338_MPI_EN (1 << 1) 43#define CKCTL_6338_MPI_EN (1 << 1)
20#define CKCTL_6338_DRAM_EN (1 << 2) 44#define CKCTL_6338_DRAM_EN (1 << 2)
@@ -90,35 +114,36 @@
90#define CKCTL_6368_PHYMIPS_EN (1 << 6) 114#define CKCTL_6368_PHYMIPS_EN (1 << 6)
91#define CKCTL_6368_SWPKT_USB_EN (1 << 7) 115#define CKCTL_6368_SWPKT_USB_EN (1 << 7)
92#define CKCTL_6368_SWPKT_SAR_EN (1 << 8) 116#define CKCTL_6368_SWPKT_SAR_EN (1 << 8)
93#define CKCTL_6368_SPI_CLK_EN (1 << 9) 117#define CKCTL_6368_SPI_EN (1 << 9)
94#define CKCTL_6368_USBD_CLK_EN (1 << 10) 118#define CKCTL_6368_USBD_EN (1 << 10)
95#define CKCTL_6368_SAR_CLK_EN (1 << 11) 119#define CKCTL_6368_SAR_EN (1 << 11)
96#define CKCTL_6368_ROBOSW_CLK_EN (1 << 12) 120#define CKCTL_6368_ROBOSW_EN (1 << 12)
97#define CKCTL_6368_UTOPIA_CLK_EN (1 << 13) 121#define CKCTL_6368_UTOPIA_EN (1 << 13)
98#define CKCTL_6368_PCM_CLK_EN (1 << 14) 122#define CKCTL_6368_PCM_EN (1 << 14)
99#define CKCTL_6368_USBH_CLK_EN (1 << 15) 123#define CKCTL_6368_USBH_EN (1 << 15)
100#define CKCTL_6368_DISABLE_GLESS_EN (1 << 16) 124#define CKCTL_6368_DISABLE_GLESS_EN (1 << 16)
101#define CKCTL_6368_NAND_CLK_EN (1 << 17) 125#define CKCTL_6368_NAND_EN (1 << 17)
102#define CKCTL_6368_IPSEC_CLK_EN (1 << 18) 126#define CKCTL_6368_IPSEC_EN (1 << 18)
103 127
104#define CKCTL_6368_ALL_SAFE_EN (CKCTL_6368_SWPKT_USB_EN | \ 128#define CKCTL_6368_ALL_SAFE_EN (CKCTL_6368_SWPKT_USB_EN | \
105 CKCTL_6368_SWPKT_SAR_EN | \ 129 CKCTL_6368_SWPKT_SAR_EN | \
106 CKCTL_6368_SPI_CLK_EN | \ 130 CKCTL_6368_SPI_EN | \
107 CKCTL_6368_USBD_CLK_EN | \ 131 CKCTL_6368_USBD_EN | \
108 CKCTL_6368_SAR_CLK_EN | \ 132 CKCTL_6368_SAR_EN | \
109 CKCTL_6368_ROBOSW_CLK_EN | \ 133 CKCTL_6368_ROBOSW_EN | \
110 CKCTL_6368_UTOPIA_CLK_EN | \ 134 CKCTL_6368_UTOPIA_EN | \
111 CKCTL_6368_PCM_CLK_EN | \ 135 CKCTL_6368_PCM_EN | \
112 CKCTL_6368_USBH_CLK_EN | \ 136 CKCTL_6368_USBH_EN | \
113 CKCTL_6368_DISABLE_GLESS_EN | \ 137 CKCTL_6368_DISABLE_GLESS_EN | \
114 CKCTL_6368_NAND_CLK_EN | \ 138 CKCTL_6368_NAND_EN | \
115 CKCTL_6368_IPSEC_CLK_EN) 139 CKCTL_6368_IPSEC_EN)
116 140
117/* System PLL Control register */ 141/* System PLL Control register */
118#define PERF_SYS_PLL_CTL_REG 0x8 142#define PERF_SYS_PLL_CTL_REG 0x8
119#define SYS_PLL_SOFT_RESET 0x1 143#define SYS_PLL_SOFT_RESET 0x1
120 144
121/* Interrupt Mask register */ 145/* Interrupt Mask register */
146#define PERF_IRQMASK_6328_REG 0x20
122#define PERF_IRQMASK_6338_REG 0xc 147#define PERF_IRQMASK_6338_REG 0xc
123#define PERF_IRQMASK_6345_REG 0xc 148#define PERF_IRQMASK_6345_REG 0xc
124#define PERF_IRQMASK_6348_REG 0xc 149#define PERF_IRQMASK_6348_REG 0xc
@@ -126,6 +151,7 @@
126#define PERF_IRQMASK_6368_REG 0x20 151#define PERF_IRQMASK_6368_REG 0x20
127 152
128/* Interrupt Status register */ 153/* Interrupt Status register */
154#define PERF_IRQSTAT_6328_REG 0x28
129#define PERF_IRQSTAT_6338_REG 0x10 155#define PERF_IRQSTAT_6338_REG 0x10
130#define PERF_IRQSTAT_6345_REG 0x10 156#define PERF_IRQSTAT_6345_REG 0x10
131#define PERF_IRQSTAT_6348_REG 0x10 157#define PERF_IRQSTAT_6348_REG 0x10
@@ -133,6 +159,7 @@
133#define PERF_IRQSTAT_6368_REG 0x28 159#define PERF_IRQSTAT_6368_REG 0x28
134 160
135/* External Interrupt Configuration register */ 161/* External Interrupt Configuration register */
162#define PERF_EXTIRQ_CFG_REG_6328 0x18
136#define PERF_EXTIRQ_CFG_REG_6338 0x14 163#define PERF_EXTIRQ_CFG_REG_6338 0x14
137#define PERF_EXTIRQ_CFG_REG_6348 0x14 164#define PERF_EXTIRQ_CFG_REG_6348 0x14
138#define PERF_EXTIRQ_CFG_REG_6358 0x14 165#define PERF_EXTIRQ_CFG_REG_6358 0x14
@@ -162,8 +189,21 @@
162 189
163/* Soft Reset register */ 190/* Soft Reset register */
164#define PERF_SOFTRESET_REG 0x28 191#define PERF_SOFTRESET_REG 0x28
192#define PERF_SOFTRESET_6328_REG 0x10
165#define PERF_SOFTRESET_6368_REG 0x10 193#define PERF_SOFTRESET_6368_REG 0x10
166 194
195#define SOFTRESET_6328_SPI_MASK (1 << 0)
196#define SOFTRESET_6328_EPHY_MASK (1 << 1)
197#define SOFTRESET_6328_SAR_MASK (1 << 2)
198#define SOFTRESET_6328_ENETSW_MASK (1 << 3)
199#define SOFTRESET_6328_USBS_MASK (1 << 4)
200#define SOFTRESET_6328_USBH_MASK (1 << 5)
201#define SOFTRESET_6328_PCM_MASK (1 << 6)
202#define SOFTRESET_6328_PCIE_CORE_MASK (1 << 7)
203#define SOFTRESET_6328_PCIE_MASK (1 << 8)
204#define SOFTRESET_6328_PCIE_EXT_MASK (1 << 9)
205#define SOFTRESET_6328_PCIE_HARD_MASK (1 << 10)
206
167#define SOFTRESET_6338_SPI_MASK (1 << 0) 207#define SOFTRESET_6338_SPI_MASK (1 << 0)
168#define SOFTRESET_6338_ENET_MASK (1 << 2) 208#define SOFTRESET_6338_ENET_MASK (1 << 2)
169#define SOFTRESET_6338_USBH_MASK (1 << 3) 209#define SOFTRESET_6338_USBH_MASK (1 << 3)
@@ -307,6 +347,8 @@
307/* Watchdog reset length register */ 347/* Watchdog reset length register */
308#define WDT_RSTLEN_REG 0x8 348#define WDT_RSTLEN_REG 0x8
309 349
350/* Watchdog soft reset register (BCM6328 only) */
351#define WDT_SOFTRESET_REG 0xc
310 352
311/************************************************************************* 353/*************************************************************************
312 * _REG relative to RSET_UARTx 354 * _REG relative to RSET_UARTx
@@ -507,6 +549,15 @@
507#define GPIO_BASEMODE_6368_MASK 0x7 549#define GPIO_BASEMODE_6368_MASK 0x7
508/* those bits must be kept as read in gpio basemode register*/ 550/* those bits must be kept as read in gpio basemode register*/
509 551
552#define GPIO_STRAPBUS_REG 0x40
553#define STRAPBUS_6358_BOOT_SEL_PARALLEL (1 << 1)
554#define STRAPBUS_6358_BOOT_SEL_SERIAL (0 << 1)
555#define STRAPBUS_6368_BOOT_SEL_MASK 0x3
556#define STRAPBUS_6368_BOOT_SEL_NAND 0
557#define STRAPBUS_6368_BOOT_SEL_SERIAL 1
558#define STRAPBUS_6368_BOOT_SEL_PARALLEL 3
559
560
510/************************************************************************* 561/*************************************************************************
511 * _REG relative to RSET_ENET 562 * _REG relative to RSET_ENET
512 *************************************************************************/ 563 *************************************************************************/
@@ -924,6 +975,8 @@
924 * _REG relative to RSET_DDR 975 * _REG relative to RSET_DDR
925 *************************************************************************/ 976 *************************************************************************/
926 977
978#define DDR_CSEND_REG 0x8
979
927#define DDR_DMIPSPLLCFG_REG 0x18 980#define DDR_DMIPSPLLCFG_REG 0x18
928#define DMIPSPLLCFG_M1_SHIFT 0 981#define DMIPSPLLCFG_M1_SHIFT 0
929#define DMIPSPLLCFG_M1_MASK (0xff << DMIPSPLLCFG_M1_SHIFT) 982#define DMIPSPLLCFG_M1_MASK (0xff << DMIPSPLLCFG_M1_SHIFT)
@@ -973,4 +1026,201 @@
973#define M2M_SRCID_REG(x) ((x) * 0x40 + 0x14) 1026#define M2M_SRCID_REG(x) ((x) * 0x40 + 0x14)
974#define M2M_DSTID_REG(x) ((x) * 0x40 + 0x18) 1027#define M2M_DSTID_REG(x) ((x) * 0x40 + 0x18)
975 1028
1029/*************************************************************************
1030 * _REG relative to RSET_RNG
1031 *************************************************************************/
1032
1033#define RNG_CTRL 0x00
1034#define RNG_EN (1 << 0)
1035
1036#define RNG_STAT 0x04
1037#define RNG_AVAIL_MASK (0xff000000)
1038
1039#define RNG_DATA 0x08
1040#define RNG_THRES 0x0c
1041#define RNG_MASK 0x10
1042
1043/*************************************************************************
1044 * _REG relative to RSET_SPI
1045 *************************************************************************/
1046
1047/* BCM 6338 SPI core */
1048#define SPI_6338_CMD 0x00 /* 16-bits register */
1049#define SPI_6338_INT_STATUS 0x02
1050#define SPI_6338_INT_MASK_ST 0x03
1051#define SPI_6338_INT_MASK 0x04
1052#define SPI_6338_ST 0x05
1053#define SPI_6338_CLK_CFG 0x06
1054#define SPI_6338_FILL_BYTE 0x07
1055#define SPI_6338_MSG_TAIL 0x09
1056#define SPI_6338_RX_TAIL 0x0b
1057#define SPI_6338_MSG_CTL 0x40
1058#define SPI_6338_MSG_DATA 0x41
1059#define SPI_6338_MSG_DATA_SIZE 0x3f
1060#define SPI_6338_RX_DATA 0x80
1061#define SPI_6338_RX_DATA_SIZE 0x3f
1062
1063/* BCM 6348 SPI core */
1064#define SPI_6348_CMD 0x00 /* 16-bits register */
1065#define SPI_6348_INT_STATUS 0x02
1066#define SPI_6348_INT_MASK_ST 0x03
1067#define SPI_6348_INT_MASK 0x04
1068#define SPI_6348_ST 0x05
1069#define SPI_6348_CLK_CFG 0x06
1070#define SPI_6348_FILL_BYTE 0x07
1071#define SPI_6348_MSG_TAIL 0x09
1072#define SPI_6348_RX_TAIL 0x0b
1073#define SPI_6348_MSG_CTL 0x40
1074#define SPI_6348_MSG_DATA 0x41
1075#define SPI_6348_MSG_DATA_SIZE 0x3f
1076#define SPI_6348_RX_DATA 0x80
1077#define SPI_6348_RX_DATA_SIZE 0x3f
1078
1079/* BCM 6358 SPI core */
1080#define SPI_6358_MSG_CTL 0x00 /* 16-bits register */
1081#define SPI_6358_MSG_DATA 0x02
1082#define SPI_6358_MSG_DATA_SIZE 0x21e
1083#define SPI_6358_RX_DATA 0x400
1084#define SPI_6358_RX_DATA_SIZE 0x220
1085#define SPI_6358_CMD 0x700 /* 16-bits register */
1086#define SPI_6358_INT_STATUS 0x702
1087#define SPI_6358_INT_MASK_ST 0x703
1088#define SPI_6358_INT_MASK 0x704
1089#define SPI_6358_ST 0x705
1090#define SPI_6358_CLK_CFG 0x706
1091#define SPI_6358_FILL_BYTE 0x707
1092#define SPI_6358_MSG_TAIL 0x709
1093#define SPI_6358_RX_TAIL 0x70B
1094
1095/* BCM 6358 SPI core */
1096#define SPI_6368_MSG_CTL 0x00 /* 16-bits register */
1097#define SPI_6368_MSG_DATA 0x02
1098#define SPI_6368_MSG_DATA_SIZE 0x21e
1099#define SPI_6368_RX_DATA 0x400
1100#define SPI_6368_RX_DATA_SIZE 0x220
1101#define SPI_6368_CMD 0x700 /* 16-bits register */
1102#define SPI_6368_INT_STATUS 0x702
1103#define SPI_6368_INT_MASK_ST 0x703
1104#define SPI_6368_INT_MASK 0x704
1105#define SPI_6368_ST 0x705
1106#define SPI_6368_CLK_CFG 0x706
1107#define SPI_6368_FILL_BYTE 0x707
1108#define SPI_6368_MSG_TAIL 0x709
1109#define SPI_6368_RX_TAIL 0x70B
1110
1111/* Shared SPI definitions */
1112
1113/* Message configuration */
1114#define SPI_FD_RW 0x00
1115#define SPI_HD_W 0x01
1116#define SPI_HD_R 0x02
1117#define SPI_BYTE_CNT_SHIFT 0
1118#define SPI_MSG_TYPE_SHIFT 14
1119
1120/* Command */
1121#define SPI_CMD_NOOP 0x00
1122#define SPI_CMD_SOFT_RESET 0x01
1123#define SPI_CMD_HARD_RESET 0x02
1124#define SPI_CMD_START_IMMEDIATE 0x03
1125#define SPI_CMD_COMMAND_SHIFT 0
1126#define SPI_CMD_COMMAND_MASK 0x000f
1127#define SPI_CMD_DEVICE_ID_SHIFT 4
1128#define SPI_CMD_PREPEND_BYTE_CNT_SHIFT 8
1129#define SPI_CMD_ONE_BYTE_SHIFT 11
1130#define SPI_CMD_ONE_WIRE_SHIFT 12
1131#define SPI_DEV_ID_0 0
1132#define SPI_DEV_ID_1 1
1133#define SPI_DEV_ID_2 2
1134#define SPI_DEV_ID_3 3
1135
1136/* Interrupt mask */
1137#define SPI_INTR_CMD_DONE 0x01
1138#define SPI_INTR_RX_OVERFLOW 0x02
1139#define SPI_INTR_TX_UNDERFLOW 0x04
1140#define SPI_INTR_TX_OVERFLOW 0x08
1141#define SPI_INTR_RX_UNDERFLOW 0x10
1142#define SPI_INTR_CLEAR_ALL 0x1f
1143
1144/* Status */
1145#define SPI_RX_EMPTY 0x02
1146#define SPI_CMD_BUSY 0x04
1147#define SPI_SERIAL_BUSY 0x08
1148
1149/* Clock configuration */
1150#define SPI_CLK_20MHZ 0x00
1151#define SPI_CLK_0_391MHZ 0x01
1152#define SPI_CLK_0_781MHZ 0x02 /* default */
1153#define SPI_CLK_1_563MHZ 0x03
1154#define SPI_CLK_3_125MHZ 0x04
1155#define SPI_CLK_6_250MHZ 0x05
1156#define SPI_CLK_12_50MHZ 0x06
1157#define SPI_CLK_MASK 0x07
1158#define SPI_SSOFFTIME_MASK 0x38
1159#define SPI_SSOFFTIME_SHIFT 3
1160#define SPI_BYTE_SWAP 0x80
1161
1162/*************************************************************************
1163 * _REG relative to RSET_MISC
1164 *************************************************************************/
1165#define MISC_SERDES_CTRL_REG 0x0
1166#define SERDES_PCIE_EN (1 << 0)
1167#define SERDES_PCIE_EXD_EN (1 << 15)
1168
1169#define MISC_STRAPBUS_6328_REG 0x240
1170#define STRAPBUS_6328_FCVO_SHIFT 7
1171#define STRAPBUS_6328_FCVO_MASK (0x1f << STRAPBUS_6328_FCVO_SHIFT)
1172#define STRAPBUS_6328_BOOT_SEL_SERIAL (1 << 28)
1173#define STRAPBUS_6328_BOOT_SEL_NAND (0 << 28)
1174
1175/*************************************************************************
1176 * _REG relative to RSET_PCIE
1177 *************************************************************************/
1178
1179#define PCIE_CONFIG2_REG 0x408
1180#define CONFIG2_BAR1_SIZE_EN 1
1181#define CONFIG2_BAR1_SIZE_MASK 0xf
1182
1183#define PCIE_IDVAL3_REG 0x43c
1184#define IDVAL3_CLASS_CODE_MASK 0xffffff
1185#define IDVAL3_SUBCLASS_SHIFT 8
1186#define IDVAL3_CLASS_SHIFT 16
1187
1188#define PCIE_DLSTATUS_REG 0x1048
1189#define DLSTATUS_PHYLINKUP (1 << 13)
1190
1191#define PCIE_BRIDGE_OPT1_REG 0x2820
1192#define OPT1_RD_BE_OPT_EN (1 << 7)
1193#define OPT1_RD_REPLY_BE_FIX_EN (1 << 9)
1194#define OPT1_PCIE_BRIDGE_HOLE_DET_EN (1 << 11)
1195#define OPT1_L1_INT_STATUS_MASK_POL (1 << 12)
1196
1197#define PCIE_BRIDGE_OPT2_REG 0x2824
1198#define OPT2_UBUS_UR_DECODE_DIS (1 << 2)
1199#define OPT2_TX_CREDIT_CHK_EN (1 << 4)
1200#define OPT2_CFG_TYPE1_BD_SEL (1 << 7)
1201#define OPT2_CFG_TYPE1_BUS_NO_SHIFT 16
1202#define OPT2_CFG_TYPE1_BUS_NO_MASK (0xff << OPT2_CFG_TYPE1_BUS_NO_SHIFT)
1203
1204#define PCIE_BRIDGE_BAR0_BASEMASK_REG 0x2828
1205#define PCIE_BRIDGE_BAR1_BASEMASK_REG 0x2830
1206#define BASEMASK_REMAP_EN (1 << 0)
1207#define BASEMASK_SWAP_EN (1 << 1)
1208#define BASEMASK_MASK_SHIFT 4
1209#define BASEMASK_MASK_MASK (0xfff << BASEMASK_MASK_SHIFT)
1210#define BASEMASK_BASE_SHIFT 20
1211#define BASEMASK_BASE_MASK (0xfff << BASEMASK_BASE_SHIFT)
1212
1213#define PCIE_BRIDGE_BAR0_REBASE_ADDR_REG 0x282c
1214#define PCIE_BRIDGE_BAR1_REBASE_ADDR_REG 0x2834
1215#define REBASE_ADDR_BASE_SHIFT 20
1216#define REBASE_ADDR_BASE_MASK (0xfff << REBASE_ADDR_BASE_SHIFT)
1217
1218#define PCIE_BRIDGE_RC_INT_MASK_REG 0x2854
1219#define PCIE_RC_INT_A (1 << 0)
1220#define PCIE_RC_INT_B (1 << 1)
1221#define PCIE_RC_INT_C (1 << 2)
1222#define PCIE_RC_INT_D (1 << 3)
1223
1224#define PCIE_DEVICE_OFFSET 0x8000
1225
976#endif /* BCM63XX_REGS_H_ */ 1226#endif /* BCM63XX_REGS_H_ */
diff --git a/arch/mips/include/asm/mach-bcm63xx/ioremap.h b/arch/mips/include/asm/mach-bcm63xx/ioremap.h
index ef94ba73646e..30931c42379d 100644
--- a/arch/mips/include/asm/mach-bcm63xx/ioremap.h
+++ b/arch/mips/include/asm/mach-bcm63xx/ioremap.h
@@ -18,6 +18,7 @@ static inline int is_bcm63xx_internal_registers(phys_t offset)
18 if (offset >= 0xfff00000) 18 if (offset >= 0xfff00000)
19 return 1; 19 return 1;
20 break; 20 break;
21 case BCM6328_CPU_ID:
21 case BCM6368_CPU_ID: 22 case BCM6368_CPU_ID:
22 if (offset >= 0xb0000000 && offset < 0xb1000000) 23 if (offset >= 0xb0000000 && offset < 0xb1000000)
23 return 1; 24 return 1;
diff --git a/arch/mips/include/asm/mach-cavium-octeon/irq.h b/arch/mips/include/asm/mach-cavium-octeon/irq.h
index 5b05f186e395..418992042f6f 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/irq.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/irq.h
@@ -41,61 +41,26 @@ enum octeon_irq {
41 OCTEON_IRQ_TWSI, 41 OCTEON_IRQ_TWSI,
42 OCTEON_IRQ_TWSI2, 42 OCTEON_IRQ_TWSI2,
43 OCTEON_IRQ_RML, 43 OCTEON_IRQ_RML,
44 OCTEON_IRQ_TRACE0,
45 OCTEON_IRQ_GMX_DRP0 = OCTEON_IRQ_TRACE0 + 4,
46 OCTEON_IRQ_IPD_DRP = OCTEON_IRQ_GMX_DRP0 + 5,
47 OCTEON_IRQ_KEY_ZERO,
48 OCTEON_IRQ_TIMER0, 44 OCTEON_IRQ_TIMER0,
49 OCTEON_IRQ_TIMER1, 45 OCTEON_IRQ_TIMER1,
50 OCTEON_IRQ_TIMER2, 46 OCTEON_IRQ_TIMER2,
51 OCTEON_IRQ_TIMER3, 47 OCTEON_IRQ_TIMER3,
52 OCTEON_IRQ_USB0, 48 OCTEON_IRQ_USB0,
53 OCTEON_IRQ_USB1, 49 OCTEON_IRQ_USB1,
54 OCTEON_IRQ_PCM,
55 OCTEON_IRQ_MPI,
56 OCTEON_IRQ_POWIQ,
57 OCTEON_IRQ_IPDPPTHR,
58 OCTEON_IRQ_MII0, 50 OCTEON_IRQ_MII0,
59 OCTEON_IRQ_MII1, 51 OCTEON_IRQ_MII1,
60 OCTEON_IRQ_BOOTDMA, 52 OCTEON_IRQ_BOOTDMA,
61 53#ifndef CONFIG_PCI_MSI
62 OCTEON_IRQ_NAND, 54 OCTEON_IRQ_LAST = 127
63 OCTEON_IRQ_MIO, /* Summary of MIO_BOOT_ERR */ 55#endif
64 OCTEON_IRQ_IOB, /* Summary of IOB_INT_SUM */
65 OCTEON_IRQ_FPA, /* Summary of FPA_INT_SUM */
66 OCTEON_IRQ_POW, /* Summary of POW_ECC_ERR */
67 OCTEON_IRQ_L2C, /* Summary of L2C_INT_STAT */
68 OCTEON_IRQ_IPD, /* Summary of IPD_INT_SUM */
69 OCTEON_IRQ_PIP, /* Summary of PIP_INT_REG */
70 OCTEON_IRQ_PKO, /* Summary of PKO_REG_ERROR */
71 OCTEON_IRQ_ZIP, /* Summary of ZIP_ERROR */
72 OCTEON_IRQ_TIM, /* Summary of TIM_REG_ERROR */
73 OCTEON_IRQ_RAD, /* Summary of RAD_REG_ERROR */
74 OCTEON_IRQ_KEY, /* Summary of KEY_INT_SUM */
75 OCTEON_IRQ_DFA, /* Summary of DFA */
76 OCTEON_IRQ_USBCTL, /* Summary of USBN0_INT_SUM */
77 OCTEON_IRQ_SLI, /* Summary of SLI_INT_SUM */
78 OCTEON_IRQ_DPI, /* Summary of DPI_INT_SUM */
79 OCTEON_IRQ_AGX0, /* Summary of GMX0*+PCS0_INT*_REG */
80 OCTEON_IRQ_AGL = OCTEON_IRQ_AGX0 + 5,
81 OCTEON_IRQ_PTP,
82 OCTEON_IRQ_PEM0,
83 OCTEON_IRQ_PEM1,
84 OCTEON_IRQ_SRIO0,
85 OCTEON_IRQ_SRIO1,
86 OCTEON_IRQ_LMC0,
87 OCTEON_IRQ_DFM = OCTEON_IRQ_LMC0 + 4, /* Summary of DFM */
88 OCTEON_IRQ_RST,
89}; 56};
90 57
91#ifdef CONFIG_PCI_MSI 58#ifdef CONFIG_PCI_MSI
92/* 152 - 407 represent the MSI interrupts 0-255 */ 59/* 256 - 511 represent the MSI interrupts 0-255 */
93#define OCTEON_IRQ_MSI_BIT0 (OCTEON_IRQ_RST + 1) 60#define OCTEON_IRQ_MSI_BIT0 (256)
94 61
95#define OCTEON_IRQ_MSI_LAST (OCTEON_IRQ_MSI_BIT0 + 255) 62#define OCTEON_IRQ_MSI_LAST (OCTEON_IRQ_MSI_BIT0 + 255)
96#define OCTEON_IRQ_LAST (OCTEON_IRQ_MSI_LAST + 1) 63#define OCTEON_IRQ_LAST (OCTEON_IRQ_MSI_LAST + 1)
97#else
98#define OCTEON_IRQ_LAST (OCTEON_IRQ_RST + 1)
99#endif 64#endif
100 65
101#endif 66#endif
diff --git a/arch/mips/include/asm/mach-jz4740/jz4740_nand.h b/arch/mips/include/asm/mach-jz4740/jz4740_nand.h
index bb5b9a4e29c8..986982db7c38 100644
--- a/arch/mips/include/asm/mach-jz4740/jz4740_nand.h
+++ b/arch/mips/include/asm/mach-jz4740/jz4740_nand.h
@@ -19,6 +19,8 @@
19#include <linux/mtd/nand.h> 19#include <linux/mtd/nand.h>
20#include <linux/mtd/partitions.h> 20#include <linux/mtd/partitions.h>
21 21
22#define JZ_NAND_NUM_BANKS 4
23
22struct jz_nand_platform_data { 24struct jz_nand_platform_data {
23 int num_partitions; 25 int num_partitions;
24 struct mtd_partition *partitions; 26 struct mtd_partition *partitions;
@@ -27,6 +29,8 @@ struct jz_nand_platform_data {
27 29
28 unsigned int busy_gpio; 30 unsigned int busy_gpio;
29 31
32 unsigned char banks[JZ_NAND_NUM_BANKS];
33
30 void (*ident_callback)(struct platform_device *, struct nand_chip *, 34 void (*ident_callback)(struct platform_device *, struct nand_chip *,
31 struct mtd_partition **, int *num_partitions); 35 struct mtd_partition **, int *num_partitions);
32}; 36};
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
index 1e29b9dd1d73..06367c37e1b2 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -14,6 +14,7 @@
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/irq.h> 16#include <linux/irq.h>
17#include <linux/kconfig.h>
17 18
18/* loongson internal northbridge initialization */ 19/* loongson internal northbridge initialization */
19extern void bonito_irq_init(void); 20extern void bonito_irq_init(void);
@@ -66,7 +67,7 @@ extern int mach_i8259_irq(void);
66#include <linux/interrupt.h> 67#include <linux/interrupt.h>
67static inline void do_perfcnt_IRQ(void) 68static inline void do_perfcnt_IRQ(void)
68{ 69{
69#if defined(CONFIG_OPROFILE) || defined(CONFIG_OPROFILE_MODULE) 70#if IS_ENABLED(CONFIG_OPROFILE)
70 do_IRQ(LOONGSON2_PERFCNT_IRQ); 71 do_IRQ(LOONGSON2_PERFCNT_IRQ);
71#endif 72#endif
72} 73}
diff --git a/arch/mips/include/asm/mach-loongson1/irq.h b/arch/mips/include/asm/mach-loongson1/irq.h
new file mode 100644
index 000000000000..da96ed42f733
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/irq.h
@@ -0,0 +1,73 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * IRQ mappings for Loongson 1
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12
13#ifndef __ASM_MACH_LOONGSON1_IRQ_H
14#define __ASM_MACH_LOONGSON1_IRQ_H
15
16/*
17 * CPU core Interrupt Numbers
18 */
19#define MIPS_CPU_IRQ_BASE 0
20#define MIPS_CPU_IRQ(x) (MIPS_CPU_IRQ_BASE + (x))
21
22#define SOFTINT0_IRQ MIPS_CPU_IRQ(0)
23#define SOFTINT1_IRQ MIPS_CPU_IRQ(1)
24#define INT0_IRQ MIPS_CPU_IRQ(2)
25#define INT1_IRQ MIPS_CPU_IRQ(3)
26#define INT2_IRQ MIPS_CPU_IRQ(4)
27#define INT3_IRQ MIPS_CPU_IRQ(5)
28#define INT4_IRQ MIPS_CPU_IRQ(6)
29#define TIMER_IRQ MIPS_CPU_IRQ(7) /* cpu timer */
30
31#define MIPS_CPU_IRQS (MIPS_CPU_IRQ(7) + 1 - MIPS_CPU_IRQ_BASE)
32
33/*
34 * INT0~3 Interrupt Numbers
35 */
36#define LS1X_IRQ_BASE MIPS_CPU_IRQS
37#define LS1X_IRQ(n, x) (LS1X_IRQ_BASE + (n << 5) + (x))
38
39#define LS1X_UART0_IRQ LS1X_IRQ(0, 2)
40#define LS1X_UART1_IRQ LS1X_IRQ(0, 3)
41#define LS1X_UART2_IRQ LS1X_IRQ(0, 4)
42#define LS1X_UART3_IRQ LS1X_IRQ(0, 5)
43#define LS1X_CAN0_IRQ LS1X_IRQ(0, 6)
44#define LS1X_CAN1_IRQ LS1X_IRQ(0, 7)
45#define LS1X_SPI0_IRQ LS1X_IRQ(0, 8)
46#define LS1X_SPI1_IRQ LS1X_IRQ(0, 9)
47#define LS1X_AC97_IRQ LS1X_IRQ(0, 10)
48#define LS1X_DMA0_IRQ LS1X_IRQ(0, 13)
49#define LS1X_DMA1_IRQ LS1X_IRQ(0, 14)
50#define LS1X_DMA2_IRQ LS1X_IRQ(0, 15)
51#define LS1X_PWM0_IRQ LS1X_IRQ(0, 17)
52#define LS1X_PWM1_IRQ LS1X_IRQ(0, 18)
53#define LS1X_PWM2_IRQ LS1X_IRQ(0, 19)
54#define LS1X_PWM3_IRQ LS1X_IRQ(0, 20)
55#define LS1X_RTC_INT0_IRQ LS1X_IRQ(0, 21)
56#define LS1X_RTC_INT1_IRQ LS1X_IRQ(0, 22)
57#define LS1X_RTC_INT2_IRQ LS1X_IRQ(0, 23)
58#define LS1X_TOY_INT0_IRQ LS1X_IRQ(0, 24)
59#define LS1X_TOY_INT1_IRQ LS1X_IRQ(0, 25)
60#define LS1X_TOY_INT2_IRQ LS1X_IRQ(0, 26)
61#define LS1X_RTC_TICK_IRQ LS1X_IRQ(0, 27)
62#define LS1X_TOY_TICK_IRQ LS1X_IRQ(0, 28)
63
64#define LS1X_EHCI_IRQ LS1X_IRQ(1, 0)
65#define LS1X_OHCI_IRQ LS1X_IRQ(1, 1)
66#define LS1X_GMAC0_IRQ LS1X_IRQ(1, 2)
67#define LS1X_GMAC1_IRQ LS1X_IRQ(1, 3)
68
69#define LS1X_IRQS (LS1X_IRQ(4, 31) + 1 - LS1X_IRQ_BASE)
70
71#define NR_IRQS (MIPS_CPU_IRQS + LS1X_IRQS)
72
73#endif /* __ASM_MACH_LOONGSON1_IRQ_H */
diff --git a/arch/mips/include/asm/mach-loongson1/loongson1.h b/arch/mips/include/asm/mach-loongson1/loongson1.h
new file mode 100644
index 000000000000..4e18e88cebbf
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/loongson1.h
@@ -0,0 +1,44 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * Register mappings for Loongson 1
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12
13#ifndef __ASM_MACH_LOONGSON1_LOONGSON1_H
14#define __ASM_MACH_LOONGSON1_LOONGSON1_H
15
16#define DEFAULT_MEMSIZE 256 /* If no memsize provided */
17
18/* Loongson 1 Register Bases */
19#define LS1X_INTC_BASE 0x1fd01040
20#define LS1X_EHCI_BASE 0x1fe00000
21#define LS1X_OHCI_BASE 0x1fe08000
22#define LS1X_GMAC0_BASE 0x1fe10000
23#define LS1X_GMAC1_BASE 0x1fe20000
24
25#define LS1X_UART0_BASE 0x1fe40000
26#define LS1X_UART1_BASE 0x1fe44000
27#define LS1X_UART2_BASE 0x1fe48000
28#define LS1X_UART3_BASE 0x1fe4c000
29#define LS1X_CAN0_BASE 0x1fe50000
30#define LS1X_CAN1_BASE 0x1fe54000
31#define LS1X_I2C0_BASE 0x1fe58000
32#define LS1X_I2C1_BASE 0x1fe68000
33#define LS1X_I2C2_BASE 0x1fe70000
34#define LS1X_PWM_BASE 0x1fe5c000
35#define LS1X_WDT_BASE 0x1fe5c060
36#define LS1X_RTC_BASE 0x1fe64000
37#define LS1X_AC97_BASE 0x1fe74000
38#define LS1X_NAND_BASE 0x1fe78000
39#define LS1X_CLK_BASE 0x1fe78030
40
41#include <regs-clk.h>
42#include <regs-wdt.h>
43
44#endif /* __ASM_MACH_LOONGSON1_LOONGSON1_H */
diff --git a/arch/mips/include/asm/mach-loongson1/platform.h b/arch/mips/include/asm/mach-loongson1/platform.h
new file mode 100644
index 000000000000..2f171617bade
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/platform.h
@@ -0,0 +1,23 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10
11#ifndef __ASM_MACH_LOONGSON1_PLATFORM_H
12#define __ASM_MACH_LOONGSON1_PLATFORM_H
13
14#include <linux/platform_device.h>
15
16extern struct platform_device ls1x_uart_device;
17extern struct platform_device ls1x_eth0_device;
18extern struct platform_device ls1x_ehci_device;
19extern struct platform_device ls1x_rtc_device;
20
21void ls1x_serial_setup(void);
22
23#endif /* __ASM_MACH_LOONGSON1_PLATFORM_H */
diff --git a/arch/mips/include/asm/mach-loongson1/prom.h b/arch/mips/include/asm/mach-loongson1/prom.h
new file mode 100644
index 000000000000..b871dc41b8d9
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/prom.h
@@ -0,0 +1,24 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#ifndef __ASM_MACH_LOONGSON1_PROM_H
11#define __ASM_MACH_LOONGSON1_PROM_H
12
13#include <linux/io.h>
14#include <linux/init.h>
15#include <linux/irq.h>
16
17/* environment arguments from bootloader */
18extern unsigned long memsize, highmemsize;
19
20/* loongson-specific command line, env and memory initialization */
21extern char *prom_getenv(char *name);
22extern void __init prom_init_cmdline(void);
23
24#endif /* __ASM_MACH_LOONGSON1_PROM_H */
diff --git a/arch/mips/include/asm/mach-loongson1/regs-clk.h b/arch/mips/include/asm/mach-loongson1/regs-clk.h
new file mode 100644
index 000000000000..8efa7fb9f73a
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/regs-clk.h
@@ -0,0 +1,33 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * Loongson 1 Clock Register Definitions.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#ifndef __ASM_MACH_LOONGSON1_REGS_CLK_H
13#define __ASM_MACH_LOONGSON1_REGS_CLK_H
14
15#define LS1X_CLK_REG(x) \
16 ((void __iomem *)KSEG1ADDR(LS1X_CLK_BASE + (x)))
17
18#define LS1X_CLK_PLL_FREQ LS1X_CLK_REG(0x0)
19#define LS1X_CLK_PLL_DIV LS1X_CLK_REG(0x4)
20
21/* Clock PLL Divisor Register Bits */
22#define DIV_DC_EN (0x1 << 31)
23#define DIV_DC (0x1f << 26)
24#define DIV_CPU_EN (0x1 << 25)
25#define DIV_CPU (0x1f << 20)
26#define DIV_DDR_EN (0x1 << 19)
27#define DIV_DDR (0x1f << 14)
28
29#define DIV_DC_SHIFT 26
30#define DIV_CPU_SHIFT 20
31#define DIV_DDR_SHIFT 14
32
33#endif /* __ASM_MACH_LOONGSON1_REGS_CLK_H */
diff --git a/arch/mips/include/asm/mach-loongson1/regs-wdt.h b/arch/mips/include/asm/mach-loongson1/regs-wdt.h
new file mode 100644
index 000000000000..f897de68c527
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/regs-wdt.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * Loongson 1 watchdog register definitions.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#ifndef __ASM_MACH_LOONGSON1_REGS_WDT_H
13#define __ASM_MACH_LOONGSON1_REGS_WDT_H
14
15#define LS1X_WDT_REG(x) \
16 ((void __iomem *)KSEG1ADDR(LS1X_WDT_BASE + (x)))
17
18#define LS1X_WDT_EN LS1X_WDT_REG(0x0)
19#define LS1X_WDT_SET LS1X_WDT_REG(0x4)
20#define LS1X_WDT_TIMER LS1X_WDT_REG(0x8)
21
22#endif /* __ASM_MACH_LOONGSON1_REGS_WDT_H */
diff --git a/arch/mips/include/asm/mach-loongson1/war.h b/arch/mips/include/asm/mach-loongson1/war.h
new file mode 100644
index 000000000000..e3680a8fb349
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson1/war.h
@@ -0,0 +1,25 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */
8#ifndef __ASM_MACH_LOONGSON1_WAR_H
9#define __ASM_MACH_LOONGSON1_WAR_H
10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0
13#define R4600_V2_HIT_CACHEOP_WAR 0
14#define R5432_CP0_INTERRUPT_WAR 0
15#define BCM1250_M3_WAR 0
16#define SIBYTE_1956_WAR 0
17#define MIPS4K_ICACHE_REFILL_WAR 0
18#define MIPS_CACHE_SYNC_WAR 0
19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0
24
25#endif /* __ASM_MACH_LOONGSON1_WAR_H */
diff --git a/arch/mips/include/asm/mach-netlogic/cpu-feature-overrides.h b/arch/mips/include/asm/mach-netlogic/cpu-feature-overrides.h
index d193fb68cf27..966db4be377c 100644
--- a/arch/mips/include/asm/mach-netlogic/cpu-feature-overrides.h
+++ b/arch/mips/include/asm/mach-netlogic/cpu-feature-overrides.h
@@ -48,7 +48,6 @@
48#define cpu_has_userlocal 1 48#define cpu_has_userlocal 1
49#define cpu_has_mips32r2 1 49#define cpu_has_mips32r2 1
50#define cpu_has_mips64r2 1 50#define cpu_has_mips64r2 1
51#define cpu_has_dc_aliases 1
52#else 51#else
53#error "Unknown Netlogic CPU" 52#error "Unknown Netlogic CPU"
54#endif 53#endif
diff --git a/arch/mips/include/asm/mach-tx49xx/mangle-port.h b/arch/mips/include/asm/mach-tx49xx/mangle-port.h
index 5e6912fdd0ed..490867b03c8f 100644
--- a/arch/mips/include/asm/mach-tx49xx/mangle-port.h
+++ b/arch/mips/include/asm/mach-tx49xx/mangle-port.h
@@ -9,7 +9,7 @@
9#define ioswabb(a, x) (x) 9#define ioswabb(a, x) (x)
10#define __mem_ioswabb(a, x) (x) 10#define __mem_ioswabb(a, x) (x)
11#if defined(CONFIG_TOSHIBA_RBTX4939) && \ 11#if defined(CONFIG_TOSHIBA_RBTX4939) && \
12 (defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)) && \ 12 IS_ENABLED(CONFIG_SMC91X) && \
13 defined(__BIG_ENDIAN) 13 defined(__BIG_ENDIAN)
14#define NEEDS_TXX9_IOSWABW 14#define NEEDS_TXX9_IOSWABW
15extern u16 (*ioswabw)(volatile u16 *a, u16 x); 15extern u16 (*ioswabw)(volatile u16 *a, u16 x);
diff --git a/arch/mips/include/asm/mipsmtregs.h b/arch/mips/include/asm/mipsmtregs.h
index e71ff4c317f2..5b3cb8553e9a 100644
--- a/arch/mips/include/asm/mipsmtregs.h
+++ b/arch/mips/include/asm/mipsmtregs.h
@@ -28,6 +28,9 @@
28#define read_c0_vpeconf0() __read_32bit_c0_register($1, 2) 28#define read_c0_vpeconf0() __read_32bit_c0_register($1, 2)
29#define write_c0_vpeconf0(val) __write_32bit_c0_register($1, 2, val) 29#define write_c0_vpeconf0(val) __write_32bit_c0_register($1, 2, val)
30 30
31#define read_c0_vpeconf1() __read_32bit_c0_register($1, 3)
32#define write_c0_vpeconf1(val) __write_32bit_c0_register($1, 3, val)
33
31#define read_c0_tcstatus() __read_32bit_c0_register($2, 1) 34#define read_c0_tcstatus() __read_32bit_c0_register($2, 1)
32#define write_c0_tcstatus(val) __write_32bit_c0_register($2, 1, val) 35#define write_c0_tcstatus(val) __write_32bit_c0_register($2, 1, val)
33 36
@@ -124,6 +127,14 @@
124#define VPECONF0_XTC_SHIFT 21 127#define VPECONF0_XTC_SHIFT 21
125#define VPECONF0_XTC (_ULCAST_(0xff) << VPECONF0_XTC_SHIFT) 128#define VPECONF0_XTC (_ULCAST_(0xff) << VPECONF0_XTC_SHIFT)
126 129
130/* VPEConf1 fields (per VPE) */
131#define VPECONF1_NCP1_SHIFT 0
132#define VPECONF1_NCP1 (_ULCAST_(0xff) << VPECONF1_NCP1_SHIFT)
133#define VPECONF1_NCP2_SHIFT 10
134#define VPECONF1_NCP2 (_ULCAST_(0xff) << VPECONF1_NCP2_SHIFT)
135#define VPECONF1_NCX_SHIFT 20
136#define VPECONF1_NCX (_ULCAST_(0xff) << VPECONF1_NCX_SHIFT)
137
127/* TCStatus fields (per TC) */ 138/* TCStatus fields (per TC) */
128#define TCSTATUS_TASID (_ULCAST_(0xff)) 139#define TCSTATUS_TASID (_ULCAST_(0xff))
129#define TCSTATUS_IXMT_SHIFT 10 140#define TCSTATUS_IXMT_SHIFT 10
@@ -350,6 +361,8 @@ do { \
350#define write_vpe_c0_vpecontrol(val) mttc0(1, 1, val) 361#define write_vpe_c0_vpecontrol(val) mttc0(1, 1, val)
351#define read_vpe_c0_vpeconf0() mftc0(1, 2) 362#define read_vpe_c0_vpeconf0() mftc0(1, 2)
352#define write_vpe_c0_vpeconf0(val) mttc0(1, 2, val) 363#define write_vpe_c0_vpeconf0(val) mttc0(1, 2, val)
364#define read_vpe_c0_vpeconf1() mftc0(1, 3)
365#define write_vpe_c0_vpeconf1(val) mttc0(1, 3, val)
353#define read_vpe_c0_count() mftc0(9, 0) 366#define read_vpe_c0_count() mftc0(9, 0)
354#define write_vpe_c0_count(val) mttc0(9, 0, val) 367#define write_vpe_c0_count(val) mttc0(9, 0, val)
355#define read_vpe_c0_status() mftc0(12, 0) 368#define read_vpe_c0_status() mftc0(12, 0)
diff --git a/arch/mips/include/asm/module.h b/arch/mips/include/asm/module.h
index 530008048c62..7531ecd654d6 100644
--- a/arch/mips/include/asm/module.h
+++ b/arch/mips/include/asm/module.h
@@ -117,6 +117,8 @@ search_module_dbetables(unsigned long addr)
117#define MODULE_PROC_FAMILY "RM9000 " 117#define MODULE_PROC_FAMILY "RM9000 "
118#elif defined CONFIG_CPU_SB1 118#elif defined CONFIG_CPU_SB1
119#define MODULE_PROC_FAMILY "SB1 " 119#define MODULE_PROC_FAMILY "SB1 "
120#elif defined CONFIG_CPU_LOONGSON1
121#define MODULE_PROC_FAMILY "LOONGSON1 "
120#elif defined CONFIG_CPU_LOONGSON2 122#elif defined CONFIG_CPU_LOONGSON2
121#define MODULE_PROC_FAMILY "LOONGSON2 " 123#define MODULE_PROC_FAMILY "LOONGSON2 "
122#elif defined CONFIG_CPU_CAVIUM_OCTEON 124#elif defined CONFIG_CPU_CAVIUM_OCTEON
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/cpucontrol.h b/arch/mips/include/asm/netlogic/xlp-hal/cpucontrol.h
index bf7d41deb9be..7b63a6b722a0 100644
--- a/arch/mips/include/asm/netlogic/xlp-hal/cpucontrol.h
+++ b/arch/mips/include/asm/netlogic/xlp-hal/cpucontrol.h
@@ -47,7 +47,9 @@
47#define CPU_BLOCKID_MAP 10 47#define CPU_BLOCKID_MAP 10
48 48
49#define LSU_DEFEATURE 0x304 49#define LSU_DEFEATURE 0x304
50#define LSU_CERRLOG_REGID 0x09 50#define LSU_DEBUG_ADDR 0x305
51#define LSU_DEBUG_DATA0 0x306
52#define LSU_CERRLOG_REGID 0x309
51#define SCHED_DEFEATURE 0x700 53#define SCHED_DEFEATURE 0x700
52 54
53/* Offsets of interest from the 'MAP' Block */ 55/* Offsets of interest from the 'MAP' Block */
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/iomap.h b/arch/mips/include/asm/netlogic/xlp-hal/iomap.h
index 86cc3391e50c..2c63f9754640 100644
--- a/arch/mips/include/asm/netlogic/xlp-hal/iomap.h
+++ b/arch/mips/include/asm/netlogic/xlp-hal/iomap.h
@@ -36,6 +36,9 @@
36#define __NLM_HAL_IOMAP_H__ 36#define __NLM_HAL_IOMAP_H__
37 37
38#define XLP_DEFAULT_IO_BASE 0x18000000 38#define XLP_DEFAULT_IO_BASE 0x18000000
39#define XLP_DEFAULT_PCI_ECFG_BASE XLP_DEFAULT_IO_BASE
40#define XLP_DEFAULT_PCI_CFG_BASE 0x1c000000
41
39#define NMI_BASE 0xbfc00000 42#define NMI_BASE 0xbfc00000
40#define XLP_IO_CLK 133333333 43#define XLP_IO_CLK 133333333
41 44
@@ -129,7 +132,7 @@
129#define PCI_DEVICE_ID_NLM_PIC 0x1003 132#define PCI_DEVICE_ID_NLM_PIC 0x1003
130#define PCI_DEVICE_ID_NLM_PCIE 0x1004 133#define PCI_DEVICE_ID_NLM_PCIE 0x1004
131#define PCI_DEVICE_ID_NLM_EHCI 0x1007 134#define PCI_DEVICE_ID_NLM_EHCI 0x1007
132#define PCI_DEVICE_ID_NLM_ILK 0x1008 135#define PCI_DEVICE_ID_NLM_OHCI 0x1008
133#define PCI_DEVICE_ID_NLM_NAE 0x1009 136#define PCI_DEVICE_ID_NLM_NAE 0x1009
134#define PCI_DEVICE_ID_NLM_POE 0x100A 137#define PCI_DEVICE_ID_NLM_POE 0x100A
135#define PCI_DEVICE_ID_NLM_FMN 0x100B 138#define PCI_DEVICE_ID_NLM_FMN 0x100B
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/pcibus.h b/arch/mips/include/asm/netlogic/xlp-hal/pcibus.h
new file mode 100644
index 000000000000..66c323d1bd7d
--- /dev/null
+++ b/arch/mips/include/asm/netlogic/xlp-hal/pcibus.h
@@ -0,0 +1,76 @@
1/*
2 * Copyright (c) 2003-2012 Broadcom Corporation
3 * All Rights Reserved
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the Broadcom
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#ifndef __NLM_HAL_PCIBUS_H__
36#define __NLM_HAL_PCIBUS_H__
37
38/* PCIE Memory and IO regions */
39#define PCIE_MEM_BASE 0xd0000000ULL
40#define PCIE_MEM_LIMIT 0xdfffffffULL
41#define PCIE_IO_BASE 0x14000000ULL
42#define PCIE_IO_LIMIT 0x15ffffffULL
43
44#define PCIE_BRIDGE_CMD 0x1
45#define PCIE_BRIDGE_MSI_CAP 0x14
46#define PCIE_BRIDGE_MSI_ADDRL 0x15
47#define PCIE_BRIDGE_MSI_ADDRH 0x16
48#define PCIE_BRIDGE_MSI_DATA 0x17
49
50/* XLP Global PCIE configuration space registers */
51#define PCIE_BYTE_SWAP_MEM_BASE 0x247
52#define PCIE_BYTE_SWAP_MEM_LIM 0x248
53#define PCIE_BYTE_SWAP_IO_BASE 0x249
54#define PCIE_BYTE_SWAP_IO_LIM 0x24A
55#define PCIE_MSI_STATUS 0x25A
56#define PCIE_MSI_EN 0x25B
57#define PCIE_INT_EN0 0x261
58
59/* PCIE_MSI_EN */
60#define PCIE_MSI_VECTOR_INT_EN 0xFFFFFFFF
61
62/* PCIE_INT_EN0 */
63#define PCIE_MSI_INT_EN (1 << 9)
64
65#ifndef __ASSEMBLY__
66
67#define nlm_read_pcie_reg(b, r) nlm_read_reg(b, r)
68#define nlm_write_pcie_reg(b, r, v) nlm_write_reg(b, r, v)
69#define nlm_get_pcie_base(node, inst) \
70 nlm_pcicfg_base(XLP_IO_PCIE_OFFSET(node, inst))
71#define nlm_get_pcie_regbase(node, inst) \
72 (nlm_get_pcie_base(node, inst) + XLP_IO_PCI_HDRSZ)
73
74int xlp_pcie_link_irt(int link);
75#endif
76#endif /* __NLM_HAL_PCIBUS_H__ */
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/pic.h b/arch/mips/include/asm/netlogic/xlp-hal/pic.h
index b6628f7ccf74..ad8b80233a63 100644
--- a/arch/mips/include/asm/netlogic/xlp-hal/pic.h
+++ b/arch/mips/include/asm/netlogic/xlp-hal/pic.h
@@ -201,7 +201,11 @@
201#define PIC_NUM_USB_IRTS 6 201#define PIC_NUM_USB_IRTS 6
202#define PIC_IRT_USB_0_INDEX 115 202#define PIC_IRT_USB_0_INDEX 115
203#define PIC_IRT_EHCI_0_INDEX 115 203#define PIC_IRT_EHCI_0_INDEX 115
204#define PIC_IRT_OHCI_0_INDEX 116
205#define PIC_IRT_OHCI_1_INDEX 117
204#define PIC_IRT_EHCI_1_INDEX 118 206#define PIC_IRT_EHCI_1_INDEX 118
207#define PIC_IRT_OHCI_2_INDEX 119
208#define PIC_IRT_OHCI_3_INDEX 120
205#define PIC_IRT_USB_INDEX(num) ((num) + PIC_IRT_USB_0_INDEX) 209#define PIC_IRT_USB_INDEX(num) ((num) + PIC_IRT_USB_0_INDEX)
206/* 115 to 120 */ 210/* 115 to 120 */
207#define PIC_IRT_GDX_INDEX 121 211#define PIC_IRT_GDX_INDEX 121
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/usb.h b/arch/mips/include/asm/netlogic/xlp-hal/usb.h
new file mode 100644
index 000000000000..a9cd350dfb6c
--- /dev/null
+++ b/arch/mips/include/asm/netlogic/xlp-hal/usb.h
@@ -0,0 +1,64 @@
1/*
2 * Copyright (c) 2003-2012 Broadcom Corporation
3 * All Rights Reserved
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the Broadcom
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#ifndef __NLM_HAL_USB_H__
36#define __NLM_HAL_USB_H__
37
38#define USB_CTL_0 0x01
39#define USB_PHY_0 0x0A
40#define USB_PHY_RESET 0x01
41#define USB_PHY_PORT_RESET_0 0x10
42#define USB_PHY_PORT_RESET_1 0x20
43#define USB_CONTROLLER_RESET 0x01
44#define USB_INT_STATUS 0x0E
45#define USB_INT_EN 0x0F
46#define USB_PHY_INTERRUPT_EN 0x01
47#define USB_OHCI_INTERRUPT_EN 0x02
48#define USB_OHCI_INTERRUPT1_EN 0x04
49#define USB_OHCI_INTERRUPT2_EN 0x08
50#define USB_CTRL_INTERRUPT_EN 0x10
51
52#ifndef __ASSEMBLY__
53
54#define nlm_read_usb_reg(b, r) nlm_read_reg(b, r)
55#define nlm_write_usb_reg(b, r, v) nlm_write_reg(b, r, v)
56#define nlm_get_usb_pcibase(node, inst) \
57 nlm_pcicfg_base(XLP_IO_USB_OFFSET(node, inst))
58#define nlm_get_usb_hcd_base(node, inst) \
59 nlm_xkphys_map_pcibar0(nlm_get_usb_pcibase(node, inst))
60#define nlm_get_usb_regbase(node, inst) \
61 (nlm_get_usb_pcibase(node, inst) + XLP_IO_PCI_HDRSZ)
62
63#endif
64#endif /* __NLM_HAL_USB_H__ */
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/xlp.h b/arch/mips/include/asm/netlogic/xlp-hal/xlp.h
index 1540588e396d..7e47209327a5 100644
--- a/arch/mips/include/asm/netlogic/xlp-hal/xlp.h
+++ b/arch/mips/include/asm/netlogic/xlp-hal/xlp.h
@@ -35,8 +35,21 @@
35#ifndef _NLM_HAL_XLP_H 35#ifndef _NLM_HAL_XLP_H
36#define _NLM_HAL_XLP_H 36#define _NLM_HAL_XLP_H
37 37
38#define PIC_UART_0_IRQ 17 38#define PIC_UART_0_IRQ 17
39#define PIC_UART_1_IRQ 18 39#define PIC_UART_1_IRQ 18
40#define PIC_PCIE_LINK_0_IRQ 19
41#define PIC_PCIE_LINK_1_IRQ 20
42#define PIC_PCIE_LINK_2_IRQ 21
43#define PIC_PCIE_LINK_3_IRQ 22
44#define PIC_EHCI_0_IRQ 23
45#define PIC_EHCI_1_IRQ 24
46#define PIC_OHCI_0_IRQ 25
47#define PIC_OHCI_1_IRQ 26
48#define PIC_OHCI_2_IRQ 27
49#define PIC_OHCI_3_IRQ 28
50#define PIC_MMC_IRQ 29
51#define PIC_I2C_0_IRQ 30
52#define PIC_I2C_1_IRQ 31
40 53
41#ifndef __ASSEMBLY__ 54#ifndef __ASSEMBLY__
42 55
diff --git a/arch/mips/include/asm/netlogic/xlr/bridge.h b/arch/mips/include/asm/netlogic/xlr/bridge.h
new file mode 100644
index 000000000000..2d02428c4f1b
--- /dev/null
+++ b/arch/mips/include/asm/netlogic/xlr/bridge.h
@@ -0,0 +1,104 @@
1/*
2 * Copyright (c) 2003-2012 Broadcom Corporation
3 * All Rights Reserved
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the Broadcom
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34#ifndef _ASM_NLM_BRIDGE_H_
35#define _ASM_NLM_BRIDGE_H_
36
37#define BRIDGE_DRAM_0_BAR 0
38#define BRIDGE_DRAM_1_BAR 1
39#define BRIDGE_DRAM_2_BAR 2
40#define BRIDGE_DRAM_3_BAR 3
41#define BRIDGE_DRAM_4_BAR 4
42#define BRIDGE_DRAM_5_BAR 5
43#define BRIDGE_DRAM_6_BAR 6
44#define BRIDGE_DRAM_7_BAR 7
45#define BRIDGE_DRAM_CHN_0_MTR_0_BAR 8
46#define BRIDGE_DRAM_CHN_0_MTR_1_BAR 9
47#define BRIDGE_DRAM_CHN_0_MTR_2_BAR 10
48#define BRIDGE_DRAM_CHN_0_MTR_3_BAR 11
49#define BRIDGE_DRAM_CHN_0_MTR_4_BAR 12
50#define BRIDGE_DRAM_CHN_0_MTR_5_BAR 13
51#define BRIDGE_DRAM_CHN_0_MTR_6_BAR 14
52#define BRIDGE_DRAM_CHN_0_MTR_7_BAR 15
53#define BRIDGE_DRAM_CHN_1_MTR_0_BAR 16
54#define BRIDGE_DRAM_CHN_1_MTR_1_BAR 17
55#define BRIDGE_DRAM_CHN_1_MTR_2_BAR 18
56#define BRIDGE_DRAM_CHN_1_MTR_3_BAR 19
57#define BRIDGE_DRAM_CHN_1_MTR_4_BAR 20
58#define BRIDGE_DRAM_CHN_1_MTR_5_BAR 21
59#define BRIDGE_DRAM_CHN_1_MTR_6_BAR 22
60#define BRIDGE_DRAM_CHN_1_MTR_7_BAR 23
61#define BRIDGE_CFG_BAR 24
62#define BRIDGE_PHNX_IO_BAR 25
63#define BRIDGE_FLASH_BAR 26
64#define BRIDGE_SRAM_BAR 27
65#define BRIDGE_HTMEM_BAR 28
66#define BRIDGE_HTINT_BAR 29
67#define BRIDGE_HTPIC_BAR 30
68#define BRIDGE_HTSM_BAR 31
69#define BRIDGE_HTIO_BAR 32
70#define BRIDGE_HTCFG_BAR 33
71#define BRIDGE_PCIXCFG_BAR 34
72#define BRIDGE_PCIXMEM_BAR 35
73#define BRIDGE_PCIXIO_BAR 36
74#define BRIDGE_DEVICE_MASK 37
75#define BRIDGE_AERR_INTR_LOG1 38
76#define BRIDGE_AERR_INTR_LOG2 39
77#define BRIDGE_AERR_INTR_LOG3 40
78#define BRIDGE_AERR_DEV_STAT 41
79#define BRIDGE_AERR1_LOG1 42
80#define BRIDGE_AERR1_LOG2 43
81#define BRIDGE_AERR1_LOG3 44
82#define BRIDGE_AERR1_DEV_STAT 45
83#define BRIDGE_AERR_INTR_EN 46
84#define BRIDGE_AERR_UPG 47
85#define BRIDGE_AERR_CLEAR 48
86#define BRIDGE_AERR1_CLEAR 49
87#define BRIDGE_SBE_COUNTS 50
88#define BRIDGE_DBE_COUNTS 51
89#define BRIDGE_BITERR_INT_EN 52
90
91#define BRIDGE_SYS2IO_CREDITS 53
92#define BRIDGE_EVNT_CNT_CTRL1 54
93#define BRIDGE_EVNT_COUNTER1 55
94#define BRIDGE_EVNT_CNT_CTRL2 56
95#define BRIDGE_EVNT_COUNTER2 57
96#define BRIDGE_RESERVED1 58
97
98#define BRIDGE_DEFEATURE 59
99#define BRIDGE_SCRATCH0 60
100#define BRIDGE_SCRATCH1 61
101#define BRIDGE_SCRATCH2 62
102#define BRIDGE_SCRATCH3 63
103
104#endif
diff --git a/arch/mips/include/asm/netlogic/xlr/flash.h b/arch/mips/include/asm/netlogic/xlr/flash.h
new file mode 100644
index 000000000000..f8aca5472b6c
--- /dev/null
+++ b/arch/mips/include/asm/netlogic/xlr/flash.h
@@ -0,0 +1,55 @@
1/*
2 * Copyright (c) 2003-2012 Broadcom Corporation
3 * All Rights Reserved
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the Broadcom
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34#ifndef _ASM_NLM_FLASH_H_
35#define _ASM_NLM_FLASH_H_
36
37#define FLASH_CSBASE_ADDR(cs) (cs)
38#define FLASH_CSADDR_MASK(cs) (0x10 + (cs))
39#define FLASH_CSDEV_PARM(cs) (0x20 + (cs))
40#define FLASH_CSTIME_PARMA(cs) (0x30 + (cs))
41#define FLASH_CSTIME_PARMB(cs) (0x40 + (cs))
42
43#define FLASH_INT_MASK 0x50
44#define FLASH_INT_STATUS 0x60
45#define FLASH_ERROR_STATUS 0x70
46#define FLASH_ERROR_ADDR 0x80
47
48#define FLASH_NAND_CLE(cs) (0x90 + (cs))
49#define FLASH_NAND_ALE(cs) (0xa0 + (cs))
50
51#define FLASH_NAND_CSDEV_PARAM 0x000041e6
52#define FLASH_NAND_CSTIME_PARAMA 0x4f400e22
53#define FLASH_NAND_CSTIME_PARAMB 0x000083cf
54
55#endif
diff --git a/arch/mips/include/asm/netlogic/xlr/gpio.h b/arch/mips/include/asm/netlogic/xlr/gpio.h
index 51f6ad4aeb14..8492e835b110 100644
--- a/arch/mips/include/asm/netlogic/xlr/gpio.h
+++ b/arch/mips/include/asm/netlogic/xlr/gpio.h
@@ -35,39 +35,40 @@
35#ifndef _ASM_NLM_GPIO_H 35#ifndef _ASM_NLM_GPIO_H
36#define _ASM_NLM_GPIO_H 36#define _ASM_NLM_GPIO_H
37 37
38#define NETLOGIC_GPIO_INT_EN_REG 0 38#define GPIO_INT_EN_REG 0
39#define NETLOGIC_GPIO_INPUT_INVERSION_REG 1 39#define GPIO_INPUT_INVERSION_REG 1
40#define NETLOGIC_GPIO_IO_DIR_REG 2 40#define GPIO_IO_DIR_REG 2
41#define NETLOGIC_GPIO_IO_DATA_WR_REG 3 41#define GPIO_IO_DATA_WR_REG 3
42#define NETLOGIC_GPIO_IO_DATA_RD_REG 4 42#define GPIO_IO_DATA_RD_REG 4
43 43
44#define NETLOGIC_GPIO_SWRESET_REG 8 44#define GPIO_SWRESET_REG 8
45#define NETLOGIC_GPIO_DRAM1_CNTRL_REG 9 45#define GPIO_DRAM1_CNTRL_REG 9
46#define NETLOGIC_GPIO_DRAM1_RATIO_REG 10 46#define GPIO_DRAM1_RATIO_REG 10
47#define NETLOGIC_GPIO_DRAM1_RESET_REG 11 47#define GPIO_DRAM1_RESET_REG 11
48#define NETLOGIC_GPIO_DRAM1_STATUS_REG 12 48#define GPIO_DRAM1_STATUS_REG 12
49#define NETLOGIC_GPIO_DRAM2_CNTRL_REG 13 49#define GPIO_DRAM2_CNTRL_REG 13
50#define NETLOGIC_GPIO_DRAM2_RATIO_REG 14 50#define GPIO_DRAM2_RATIO_REG 14
51#define NETLOGIC_GPIO_DRAM2_RESET_REG 15 51#define GPIO_DRAM2_RESET_REG 15
52#define NETLOGIC_GPIO_DRAM2_STATUS_REG 16 52#define GPIO_DRAM2_STATUS_REG 16
53 53
54#define NETLOGIC_GPIO_PWRON_RESET_CFG_REG 21 54#define GPIO_PWRON_RESET_CFG_REG 21
55#define NETLOGIC_GPIO_BIST_ALL_GO_STATUS_REG 24 55#define GPIO_BIST_ALL_GO_STATUS_REG 24
56#define NETLOGIC_GPIO_BIST_CPU_GO_STATUS_REG 25 56#define GPIO_BIST_CPU_GO_STATUS_REG 25
57#define NETLOGIC_GPIO_BIST_DEV_GO_STATUS_REG 26 57#define GPIO_BIST_DEV_GO_STATUS_REG 26
58 58
59#define NETLOGIC_GPIO_FUSE_BANK_REG 35 59#define GPIO_FUSE_BANK_REG 35
60#define NETLOGIC_GPIO_CPU_RESET_REG 40 60#define GPIO_CPU_RESET_REG 40
61#define NETLOGIC_GPIO_RNG_REG 43 61#define GPIO_RNG_REG 43
62 62
63#define NETLOGIC_PWRON_RESET_PCMCIA_BOOT 17 63#define PWRON_RESET_PCMCIA_BOOT 17
64#define NETLOGIC_GPIO_LED_BITMAP 0x1700000
65#define NETLOGIC_GPIO_LED_0_SHIFT 20
66#define NETLOGIC_GPIO_LED_1_SHIFT 24
67 64
68#define NETLOGIC_GPIO_LED_OUTPUT_CODE_RESET 0x01 65#define GPIO_LED_BITMAP 0x1700000
69#define NETLOGIC_GPIO_LED_OUTPUT_CODE_HARD_RESET 0x02 66#define GPIO_LED_0_SHIFT 20
70#define NETLOGIC_GPIO_LED_OUTPUT_CODE_SOFT_RESET 0x03 67#define GPIO_LED_1_SHIFT 24
71#define NETLOGIC_GPIO_LED_OUTPUT_CODE_MAIN 0x04 68
69#define GPIO_LED_OUTPUT_CODE_RESET 0x01
70#define GPIO_LED_OUTPUT_CODE_HARD_RESET 0x02
71#define GPIO_LED_OUTPUT_CODE_SOFT_RESET 0x03
72#define GPIO_LED_OUTPUT_CODE_MAIN 0x04
72 73
73#endif 74#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-helper-fpa.h b/arch/mips/include/asm/octeon/cvmx-helper-fpa.h
deleted file mode 100644
index 5ff8c93198de..000000000000
--- a/arch/mips/include/asm/octeon/cvmx-helper-fpa.h
+++ /dev/null
@@ -1,64 +0,0 @@
1/***********************license start***************
2 * Author: Cavium Networks
3 *
4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK
6 *
7 * Copyright (c) 2003-2008 Cavium Networks
8 *
9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as
11 * published by the Free Software Foundation.
12 *
13 * This file is distributed in the hope that it will be useful, but
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16 * NONINFRINGEMENT. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this file; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * or visit http://www.gnu.org/licenses/.
23 *
24 * This file may also be available under a different license from Cavium.
25 * Contact Cavium Networks for more information
26 ***********************license end**************************************/
27
28/**
29 * @file
30 *
31 * Helper functions for FPA setup.
32 *
33 */
34#ifndef __CVMX_HELPER_H_FPA__
35#define __CVMX_HELPER_H_FPA__
36
37/**
38 * Allocate memory and initialize the FPA pools using memory
39 * from cvmx-bootmem. Sizes of each element in the pools is
40 * controlled by the cvmx-config.h header file. Specifying
41 * zero for any parameter will cause that FPA pool to not be
42 * setup. This is useful if you aren't using some of the
43 * hardware and want to save memory.
44 *
45 * @packet_buffers:
46 * Number of packet buffers to allocate
47 * @work_queue_entries:
48 * Number of work queue entries
49 * @pko_buffers:
50 * PKO Command buffers. You should at minimum have two per
51 * each PKO queue.
52 * @tim_buffers:
53 * TIM ring buffer command queues. At least two per timer bucket
54 * is recommened.
55 * @dfa_buffers:
56 * DFA command buffer. A relatively small (32 for example)
57 * number should work.
58 * Returns Zero on success, non-zero if out of memory
59 */
60extern int cvmx_helper_initialize_fpa(int packet_buffers,
61 int work_queue_entries, int pko_buffers,
62 int tim_buffers, int dfa_buffers);
63
64#endif /* __CVMX_HELPER_H__ */
diff --git a/arch/mips/include/asm/octeon/cvmx-helper.h b/arch/mips/include/asm/octeon/cvmx-helper.h
index 3169cd79f2ac..0ac6b9f412be 100644
--- a/arch/mips/include/asm/octeon/cvmx-helper.h
+++ b/arch/mips/include/asm/octeon/cvmx-helper.h
@@ -61,8 +61,6 @@ typedef union {
61 } s; 61 } s;
62} cvmx_helper_link_info_t; 62} cvmx_helper_link_info_t;
63 63
64#include "cvmx-helper-fpa.h"
65
66#include <asm/octeon/cvmx-helper-errata.h> 64#include <asm/octeon/cvmx-helper-errata.h>
67#include "cvmx-helper-loop.h" 65#include "cvmx-helper-loop.h"
68#include "cvmx-helper-npi.h" 66#include "cvmx-helper-npi.h"
diff --git a/arch/mips/include/asm/octeon/octeon.h b/arch/mips/include/asm/octeon/octeon.h
index f72f768cd3a4..1e2486e23573 100644
--- a/arch/mips/include/asm/octeon/octeon.h
+++ b/arch/mips/include/asm/octeon/octeon.h
@@ -215,11 +215,6 @@ struct octeon_cf_data {
215 int dma_engine; /* -1 for no DMA */ 215 int dma_engine; /* -1 for no DMA */
216}; 216};
217 217
218struct octeon_i2c_data {
219 unsigned int sys_freq;
220 unsigned int i2c_freq;
221};
222
223extern void octeon_write_lcd(const char *s); 218extern void octeon_write_lcd(const char *s);
224extern void octeon_check_cpu_bist(void); 219extern void octeon_check_cpu_bist(void);
225extern int octeon_get_boot_debug_flag(void); 220extern int octeon_get_boot_debug_flag(void);
diff --git a/arch/mips/include/asm/prom.h b/arch/mips/include/asm/prom.h
index 7206d445bab8..8808bf548b99 100644
--- a/arch/mips/include/asm/prom.h
+++ b/arch/mips/include/asm/prom.h
@@ -20,9 +20,6 @@
20extern int early_init_dt_scan_memory_arch(unsigned long node, 20extern int early_init_dt_scan_memory_arch(unsigned long node,
21 const char *uname, int depth, void *data); 21 const char *uname, int depth, void *data);
22 22
23extern int reserve_mem_mach(unsigned long addr, unsigned long size);
24extern void free_mem_mach(unsigned long addr, unsigned long size);
25
26extern void device_tree_init(void); 23extern void device_tree_init(void);
27 24
28static inline unsigned long pci_address_to_pio(phys_addr_t address) 25static inline unsigned long pci_address_to_pio(phys_addr_t address)
diff --git a/arch/mips/include/asm/smtc.h b/arch/mips/include/asm/smtc.h
index c9736fc06325..8935426a56ab 100644
--- a/arch/mips/include/asm/smtc.h
+++ b/arch/mips/include/asm/smtc.h
@@ -33,6 +33,12 @@ typedef long asiduse;
33#endif 33#endif
34#endif 34#endif
35 35
36/*
37 * VPE Management information
38 */
39
40#define MAX_SMTC_VPES MAX_SMTC_TLBS /* FIXME: May not always be true. */
41
36extern asiduse smtc_live_asid[MAX_SMTC_TLBS][MAX_SMTC_ASIDS]; 42extern asiduse smtc_live_asid[MAX_SMTC_TLBS][MAX_SMTC_ASIDS];
37 43
38struct mm_struct; 44struct mm_struct;
diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h
index 653a412c036c..3b92efef56d3 100644
--- a/arch/mips/include/asm/uaccess.h
+++ b/arch/mips/include/asm/uaccess.h
@@ -687,7 +687,7 @@ extern size_t __copy_user(void *__to, const void *__from, size_t __n);
687 __MODULE_JAL(__copy_user) \ 687 __MODULE_JAL(__copy_user) \
688 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \ 688 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \
689 : \ 689 : \
690 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \ 690 : "$8", "$9", "$10", "$11", "$12", "$14", "$15", "$24", "$31", \
691 DADDI_SCRATCH, "memory"); \ 691 DADDI_SCRATCH, "memory"); \
692 __cu_len_r; \ 692 __cu_len_r; \
693}) 693})
@@ -797,7 +797,7 @@ extern size_t __copy_user_inatomic(void *__to, const void *__from, size_t __n);
797 ".set\treorder" \ 797 ".set\treorder" \
798 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \ 798 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \
799 : \ 799 : \
800 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \ 800 : "$8", "$9", "$10", "$11", "$12", "$14", "$15", "$24", "$31", \
801 DADDI_SCRATCH, "memory"); \ 801 DADDI_SCRATCH, "memory"); \
802 __cu_len_r; \ 802 __cu_len_r; \
803}) 803})
@@ -820,7 +820,7 @@ extern size_t __copy_user_inatomic(void *__to, const void *__from, size_t __n);
820 ".set\treorder" \ 820 ".set\treorder" \
821 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \ 821 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \
822 : \ 822 : \
823 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \ 823 : "$8", "$9", "$10", "$11", "$12", "$14", "$15", "$24", "$31", \
824 DADDI_SCRATCH, "memory"); \ 824 DADDI_SCRATCH, "memory"); \
825 __cu_len_r; \ 825 __cu_len_r; \
826}) 826})
diff --git a/arch/mips/include/asm/uasm.h b/arch/mips/include/asm/uasm.h
index 440a21dab575..3d9f75f7ffc9 100644
--- a/arch/mips/include/asm/uasm.h
+++ b/arch/mips/include/asm/uasm.h
@@ -6,6 +6,7 @@
6 * Copyright (C) 2004, 2005, 2006, 2008 Thiemo Seufer 6 * Copyright (C) 2004, 2005, 2006, 2008 Thiemo Seufer
7 * Copyright (C) 2005 Maciej W. Rozycki 7 * Copyright (C) 2005 Maciej W. Rozycki
8 * Copyright (C) 2006 Ralf Baechle (ralf@linux-mips.org) 8 * Copyright (C) 2006 Ralf Baechle (ralf@linux-mips.org)
9 * Copyright (C) 2012 MIPS Technologies, Inc.
9 */ 10 */
10 11
11#include <linux/types.h> 12#include <linux/types.h>
@@ -62,8 +63,10 @@ void __uasminit uasm_i##op(u32 **buf, unsigned int a, signed int b)
62 63
63Ip_u2u1s3(_addiu); 64Ip_u2u1s3(_addiu);
64Ip_u3u1u2(_addu); 65Ip_u3u1u2(_addu);
65Ip_u2u1u3(_andi);
66Ip_u3u1u2(_and); 66Ip_u3u1u2(_and);
67Ip_u2u1u3(_andi);
68Ip_u1u2s3(_bbit0);
69Ip_u1u2s3(_bbit1);
67Ip_u1u2s3(_beq); 70Ip_u1u2s3(_beq);
68Ip_u1u2s3(_beql); 71Ip_u1u2s3(_beql);
69Ip_u1s2(_bgez); 72Ip_u1s2(_bgez);
@@ -72,55 +75,54 @@ Ip_u1s2(_bltz);
72Ip_u1s2(_bltzl); 75Ip_u1s2(_bltzl);
73Ip_u1u2s3(_bne); 76Ip_u1u2s3(_bne);
74Ip_u2s3u1(_cache); 77Ip_u2s3u1(_cache);
75Ip_u1u2u3(_dmfc0);
76Ip_u1u2u3(_dmtc0);
77Ip_u2u1s3(_daddiu); 78Ip_u2u1s3(_daddiu);
78Ip_u3u1u2(_daddu); 79Ip_u3u1u2(_daddu);
80Ip_u2u1msbu3(_dins);
81Ip_u2u1msbu3(_dinsm);
82Ip_u1u2u3(_dmfc0);
83Ip_u1u2u3(_dmtc0);
84Ip_u2u1u3(_drotr);
85Ip_u2u1u3(_drotr32);
79Ip_u2u1u3(_dsll); 86Ip_u2u1u3(_dsll);
80Ip_u2u1u3(_dsll32); 87Ip_u2u1u3(_dsll32);
81Ip_u2u1u3(_dsra); 88Ip_u2u1u3(_dsra);
82Ip_u2u1u3(_dsrl); 89Ip_u2u1u3(_dsrl);
83Ip_u2u1u3(_dsrl32); 90Ip_u2u1u3(_dsrl32);
84Ip_u2u1u3(_drotr);
85Ip_u2u1u3(_drotr32);
86Ip_u3u1u2(_dsubu); 91Ip_u3u1u2(_dsubu);
87Ip_0(_eret); 92Ip_0(_eret);
88Ip_u1(_j); 93Ip_u1(_j);
89Ip_u1(_jal); 94Ip_u1(_jal);
90Ip_u1(_jr); 95Ip_u1(_jr);
91Ip_u2s3u1(_ld); 96Ip_u2s3u1(_ld);
97Ip_u3u1u2(_ldx);
92Ip_u2s3u1(_ll); 98Ip_u2s3u1(_ll);
93Ip_u2s3u1(_lld); 99Ip_u2s3u1(_lld);
94Ip_u1s2(_lui); 100Ip_u1s2(_lui);
95Ip_u2s3u1(_lw); 101Ip_u2s3u1(_lw);
102Ip_u3u1u2(_lwx);
96Ip_u1u2u3(_mfc0); 103Ip_u1u2u3(_mfc0);
97Ip_u1u2u3(_mtc0); 104Ip_u1u2u3(_mtc0);
98Ip_u2u1u3(_ori);
99Ip_u3u1u2(_or); 105Ip_u3u1u2(_or);
106Ip_u2u1u3(_ori);
100Ip_u2s3u1(_pref); 107Ip_u2s3u1(_pref);
101Ip_0(_rfe); 108Ip_0(_rfe);
109Ip_u2u1u3(_rotr);
102Ip_u2s3u1(_sc); 110Ip_u2s3u1(_sc);
103Ip_u2s3u1(_scd); 111Ip_u2s3u1(_scd);
104Ip_u2s3u1(_sd); 112Ip_u2s3u1(_sd);
105Ip_u2u1u3(_sll); 113Ip_u2u1u3(_sll);
106Ip_u2u1u3(_sra); 114Ip_u2u1u3(_sra);
107Ip_u2u1u3(_srl); 115Ip_u2u1u3(_srl);
108Ip_u2u1u3(_rotr);
109Ip_u3u1u2(_subu); 116Ip_u3u1u2(_subu);
110Ip_u2s3u1(_sw); 117Ip_u2s3u1(_sw);
118Ip_u1(_syscall);
111Ip_0(_tlbp); 119Ip_0(_tlbp);
112Ip_0(_tlbr); 120Ip_0(_tlbr);
113Ip_0(_tlbwi); 121Ip_0(_tlbwi);
114Ip_0(_tlbwr); 122Ip_0(_tlbwr);
115Ip_u3u1u2(_xor); 123Ip_u3u1u2(_xor);
116Ip_u2u1u3(_xori); 124Ip_u2u1u3(_xori);
117Ip_u2u1msbu3(_dins); 125
118Ip_u2u1msbu3(_dinsm);
119Ip_u1(_syscall);
120Ip_u1u2s3(_bbit0);
121Ip_u1u2s3(_bbit1);
122Ip_u3u1u2(_lwx);
123Ip_u3u1u2(_ldx);
124 126
125/* Handle labels. */ 127/* Handle labels. */
126struct uasm_label { 128struct uasm_label {
@@ -145,37 +147,37 @@ static inline void __uasminit uasm_l##lb(struct uasm_label **lab, u32 *addr) \
145 147
146/* convenience macros for instructions */ 148/* convenience macros for instructions */
147#ifdef CONFIG_64BIT 149#ifdef CONFIG_64BIT
150# define UASM_i_ADDIU(buf, rs, rt, val) uasm_i_daddiu(buf, rs, rt, val)
151# define UASM_i_ADDU(buf, rs, rt, rd) uasm_i_daddu(buf, rs, rt, rd)
152# define UASM_i_LL(buf, rs, rt, off) uasm_i_lld(buf, rs, rt, off)
148# define UASM_i_LW(buf, rs, rt, off) uasm_i_ld(buf, rs, rt, off) 153# define UASM_i_LW(buf, rs, rt, off) uasm_i_ld(buf, rs, rt, off)
149# define UASM_i_SW(buf, rs, rt, off) uasm_i_sd(buf, rs, rt, off) 154# define UASM_i_LWX(buf, rs, rt, rd) uasm_i_ldx(buf, rs, rt, rd)
155# define UASM_i_MFC0(buf, rt, rd...) uasm_i_dmfc0(buf, rt, rd)
156# define UASM_i_MTC0(buf, rt, rd...) uasm_i_dmtc0(buf, rt, rd)
157# define UASM_i_ROTR(buf, rs, rt, sh) uasm_i_drotr(buf, rs, rt, sh)
158# define UASM_i_SC(buf, rs, rt, off) uasm_i_scd(buf, rs, rt, off)
150# define UASM_i_SLL(buf, rs, rt, sh) uasm_i_dsll(buf, rs, rt, sh) 159# define UASM_i_SLL(buf, rs, rt, sh) uasm_i_dsll(buf, rs, rt, sh)
151# define UASM_i_SRA(buf, rs, rt, sh) uasm_i_dsra(buf, rs, rt, sh) 160# define UASM_i_SRA(buf, rs, rt, sh) uasm_i_dsra(buf, rs, rt, sh)
152# define UASM_i_SRL(buf, rs, rt, sh) uasm_i_dsrl(buf, rs, rt, sh) 161# define UASM_i_SRL(buf, rs, rt, sh) uasm_i_dsrl(buf, rs, rt, sh)
153# define UASM_i_SRL_SAFE(buf, rs, rt, sh) uasm_i_dsrl_safe(buf, rs, rt, sh) 162# define UASM_i_SRL_SAFE(buf, rs, rt, sh) uasm_i_dsrl_safe(buf, rs, rt, sh)
154# define UASM_i_ROTR(buf, rs, rt, sh) uasm_i_drotr(buf, rs, rt, sh)
155# define UASM_i_MFC0(buf, rt, rd...) uasm_i_dmfc0(buf, rt, rd)
156# define UASM_i_MTC0(buf, rt, rd...) uasm_i_dmtc0(buf, rt, rd)
157# define UASM_i_ADDIU(buf, rs, rt, val) uasm_i_daddiu(buf, rs, rt, val)
158# define UASM_i_ADDU(buf, rs, rt, rd) uasm_i_daddu(buf, rs, rt, rd)
159# define UASM_i_SUBU(buf, rs, rt, rd) uasm_i_dsubu(buf, rs, rt, rd) 163# define UASM_i_SUBU(buf, rs, rt, rd) uasm_i_dsubu(buf, rs, rt, rd)
160# define UASM_i_LL(buf, rs, rt, off) uasm_i_lld(buf, rs, rt, off) 164# define UASM_i_SW(buf, rs, rt, off) uasm_i_sd(buf, rs, rt, off)
161# define UASM_i_SC(buf, rs, rt, off) uasm_i_scd(buf, rs, rt, off)
162# define UASM_i_LWX(buf, rs, rt, rd) uasm_i_ldx(buf, rs, rt, rd)
163#else 165#else
166# define UASM_i_ADDIU(buf, rs, rt, val) uasm_i_addiu(buf, rs, rt, val)
167# define UASM_i_ADDU(buf, rs, rt, rd) uasm_i_addu(buf, rs, rt, rd)
168# define UASM_i_LL(buf, rs, rt, off) uasm_i_ll(buf, rs, rt, off)
164# define UASM_i_LW(buf, rs, rt, off) uasm_i_lw(buf, rs, rt, off) 169# define UASM_i_LW(buf, rs, rt, off) uasm_i_lw(buf, rs, rt, off)
165# define UASM_i_SW(buf, rs, rt, off) uasm_i_sw(buf, rs, rt, off) 170# define UASM_i_LWX(buf, rs, rt, rd) uasm_i_lwx(buf, rs, rt, rd)
171# define UASM_i_MFC0(buf, rt, rd...) uasm_i_mfc0(buf, rt, rd)
172# define UASM_i_MTC0(buf, rt, rd...) uasm_i_mtc0(buf, rt, rd)
173# define UASM_i_ROTR(buf, rs, rt, sh) uasm_i_rotr(buf, rs, rt, sh)
174# define UASM_i_SC(buf, rs, rt, off) uasm_i_sc(buf, rs, rt, off)
166# define UASM_i_SLL(buf, rs, rt, sh) uasm_i_sll(buf, rs, rt, sh) 175# define UASM_i_SLL(buf, rs, rt, sh) uasm_i_sll(buf, rs, rt, sh)
167# define UASM_i_SRA(buf, rs, rt, sh) uasm_i_sra(buf, rs, rt, sh) 176# define UASM_i_SRA(buf, rs, rt, sh) uasm_i_sra(buf, rs, rt, sh)
168# define UASM_i_SRL(buf, rs, rt, sh) uasm_i_srl(buf, rs, rt, sh) 177# define UASM_i_SRL(buf, rs, rt, sh) uasm_i_srl(buf, rs, rt, sh)
169# define UASM_i_SRL_SAFE(buf, rs, rt, sh) uasm_i_srl(buf, rs, rt, sh) 178# define UASM_i_SRL_SAFE(buf, rs, rt, sh) uasm_i_srl(buf, rs, rt, sh)
170# define UASM_i_ROTR(buf, rs, rt, sh) uasm_i_rotr(buf, rs, rt, sh)
171# define UASM_i_MFC0(buf, rt, rd...) uasm_i_mfc0(buf, rt, rd)
172# define UASM_i_MTC0(buf, rt, rd...) uasm_i_mtc0(buf, rt, rd)
173# define UASM_i_ADDIU(buf, rs, rt, val) uasm_i_addiu(buf, rs, rt, val)
174# define UASM_i_ADDU(buf, rs, rt, rd) uasm_i_addu(buf, rs, rt, rd)
175# define UASM_i_SUBU(buf, rs, rt, rd) uasm_i_subu(buf, rs, rt, rd) 179# define UASM_i_SUBU(buf, rs, rt, rd) uasm_i_subu(buf, rs, rt, rd)
176# define UASM_i_LL(buf, rs, rt, off) uasm_i_ll(buf, rs, rt, off) 180# define UASM_i_SW(buf, rs, rt, off) uasm_i_sw(buf, rs, rt, off)
177# define UASM_i_SC(buf, rs, rt, off) uasm_i_sc(buf, rs, rt, off)
178# define UASM_i_LWX(buf, rs, rt, rd) uasm_i_lwx(buf, rs, rt, rd)
179#endif 181#endif
180 182
181#define uasm_i_b(buf, off) uasm_i_beq(buf, 0, 0, off) 183#define uasm_i_b(buf, off) uasm_i_beq(buf, 0, 0, off)
@@ -183,19 +185,10 @@ static inline void __uasminit uasm_l##lb(struct uasm_label **lab, u32 *addr) \
183#define uasm_i_beqzl(buf, rs, off) uasm_i_beql(buf, rs, 0, off) 185#define uasm_i_beqzl(buf, rs, off) uasm_i_beql(buf, rs, 0, off)
184#define uasm_i_bnez(buf, rs, off) uasm_i_bne(buf, rs, 0, off) 186#define uasm_i_bnez(buf, rs, off) uasm_i_bne(buf, rs, 0, off)
185#define uasm_i_bnezl(buf, rs, off) uasm_i_bnel(buf, rs, 0, off) 187#define uasm_i_bnezl(buf, rs, off) uasm_i_bnel(buf, rs, 0, off)
188#define uasm_i_ehb(buf) uasm_i_sll(buf, 0, 0, 3)
186#define uasm_i_move(buf, a, b) UASM_i_ADDU(buf, a, 0, b) 189#define uasm_i_move(buf, a, b) UASM_i_ADDU(buf, a, 0, b)
187#define uasm_i_nop(buf) uasm_i_sll(buf, 0, 0, 0) 190#define uasm_i_nop(buf) uasm_i_sll(buf, 0, 0, 0)
188#define uasm_i_ssnop(buf) uasm_i_sll(buf, 0, 0, 1) 191#define uasm_i_ssnop(buf) uasm_i_sll(buf, 0, 0, 1)
189#define uasm_i_ehb(buf) uasm_i_sll(buf, 0, 0, 3)
190
191static inline void uasm_i_dsrl_safe(u32 **p, unsigned int a1,
192 unsigned int a2, unsigned int a3)
193{
194 if (a3 < 32)
195 uasm_i_dsrl(p, a1, a2, a3);
196 else
197 uasm_i_dsrl32(p, a1, a2, a3 - 32);
198}
199 192
200static inline void uasm_i_drotr_safe(u32 **p, unsigned int a1, 193static inline void uasm_i_drotr_safe(u32 **p, unsigned int a1,
201 unsigned int a2, unsigned int a3) 194 unsigned int a2, unsigned int a3)
@@ -215,6 +208,15 @@ static inline void uasm_i_dsll_safe(u32 **p, unsigned int a1,
215 uasm_i_dsll32(p, a1, a2, a3 - 32); 208 uasm_i_dsll32(p, a1, a2, a3 - 32);
216} 209}
217 210
211static inline void uasm_i_dsrl_safe(u32 **p, unsigned int a1,
212 unsigned int a2, unsigned int a3)
213{
214 if (a3 < 32)
215 uasm_i_dsrl(p, a1, a2, a3);
216 else
217 uasm_i_dsrl32(p, a1, a2, a3 - 32);
218}
219
218/* Handle relocations. */ 220/* Handle relocations. */
219struct uasm_reloc { 221struct uasm_reloc {
220 u32 *addr; 222 u32 *addr;
@@ -234,16 +236,16 @@ void uasm_copy_handler(struct uasm_reloc *rel, struct uasm_label *lab,
234int uasm_insn_has_bdelay(struct uasm_reloc *rel, u32 *addr); 236int uasm_insn_has_bdelay(struct uasm_reloc *rel, u32 *addr);
235 237
236/* Convenience functions for labeled branches. */ 238/* Convenience functions for labeled branches. */
237void uasm_il_bltz(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
238void uasm_il_b(u32 **p, struct uasm_reloc **r, int lid); 239void uasm_il_b(u32 **p, struct uasm_reloc **r, int lid);
240void uasm_il_bbit0(u32 **p, struct uasm_reloc **r, unsigned int reg,
241 unsigned int bit, int lid);
242void uasm_il_bbit1(u32 **p, struct uasm_reloc **r, unsigned int reg,
243 unsigned int bit, int lid);
239void uasm_il_beqz(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid); 244void uasm_il_beqz(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
240void uasm_il_beqzl(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid); 245void uasm_il_beqzl(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
246void uasm_il_bgezl(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
247void uasm_il_bgez(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
248void uasm_il_bltz(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
241void uasm_il_bne(u32 **p, struct uasm_reloc **r, unsigned int reg1, 249void uasm_il_bne(u32 **p, struct uasm_reloc **r, unsigned int reg1,
242 unsigned int reg2, int lid); 250 unsigned int reg2, int lid);
243void uasm_il_bnez(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid); 251void uasm_il_bnez(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
244void uasm_il_bgezl(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
245void uasm_il_bgez(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid);
246void uasm_il_bbit0(u32 **p, struct uasm_reloc **r, unsigned int reg,
247 unsigned int bit, int lid);
248void uasm_il_bbit1(u32 **p, struct uasm_reloc **r, unsigned int reg,
249 unsigned int bit, int lid);
diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
index 9a91fe9de696..9a3d9de4d04e 100644
--- a/arch/mips/jz4740/board-qi_lb60.c
+++ b/arch/mips/jz4740/board-qi_lb60.c
@@ -140,6 +140,7 @@ static void qi_lb60_nand_ident(struct platform_device *pdev,
140static struct jz_nand_platform_data qi_lb60_nand_pdata = { 140static struct jz_nand_platform_data qi_lb60_nand_pdata = {
141 .ident_callback = qi_lb60_nand_ident, 141 .ident_callback = qi_lb60_nand_ident,
142 .busy_gpio = 94, 142 .busy_gpio = 94,
143 .banks = { 1 },
143}; 144};
144 145
145/* Keyboard*/ 146/* Keyboard*/
diff --git a/arch/mips/jz4740/platform.c b/arch/mips/jz4740/platform.c
index 10929e2bc6d8..e342ed4cbd43 100644
--- a/arch/mips/jz4740/platform.c
+++ b/arch/mips/jz4740/platform.c
@@ -157,11 +157,29 @@ static struct resource jz4740_nand_resources[] = {
157 .flags = IORESOURCE_MEM, 157 .flags = IORESOURCE_MEM,
158 }, 158 },
159 { 159 {
160 .name = "bank", 160 .name = "bank1",
161 .start = 0x18000000, 161 .start = 0x18000000,
162 .end = 0x180C0000 - 1, 162 .end = 0x180C0000 - 1,
163 .flags = IORESOURCE_MEM, 163 .flags = IORESOURCE_MEM,
164 }, 164 },
165 {
166 .name = "bank2",
167 .start = 0x14000000,
168 .end = 0x140C0000 - 1,
169 .flags = IORESOURCE_MEM,
170 },
171 {
172 .name = "bank3",
173 .start = 0x0C000000,
174 .end = 0x0C0C0000 - 1,
175 .flags = IORESOURCE_MEM,
176 },
177 {
178 .name = "bank4",
179 .start = 0x08000000,
180 .end = 0x080C0000 - 1,
181 .flags = IORESOURCE_MEM,
182 },
165}; 183};
166 184
167struct platform_device jz4740_nand_device = { 185struct platform_device jz4740_nand_device = {
diff --git a/arch/mips/jz4740/reset.c b/arch/mips/jz4740/reset.c
index 5f1fb95c0d0d..6c0da5afcf17 100644
--- a/arch/mips/jz4740/reset.c
+++ b/arch/mips/jz4740/reset.c
@@ -21,6 +21,9 @@
21#include <asm/mach-jz4740/base.h> 21#include <asm/mach-jz4740/base.h>
22#include <asm/mach-jz4740/timer.h> 22#include <asm/mach-jz4740/timer.h>
23 23
24#include "reset.h"
25#include "clock.h"
26
24static void jz4740_halt(void) 27static void jz4740_halt(void)
25{ 28{
26 while (1) { 29 while (1) {
@@ -53,21 +56,57 @@ static void jz4740_restart(char *command)
53 jz4740_halt(); 56 jz4740_halt();
54} 57}
55 58
56#define JZ_REG_RTC_CTRL 0x00 59#define JZ_REG_RTC_CTRL 0x00
57#define JZ_REG_RTC_HIBERNATE 0x20 60#define JZ_REG_RTC_HIBERNATE 0x20
61#define JZ_REG_RTC_WAKEUP_FILTER 0x24
62#define JZ_REG_RTC_RESET_COUNTER 0x28
58 63
59#define JZ_RTC_CTRL_WRDY BIT(7) 64#define JZ_RTC_CTRL_WRDY BIT(7)
65#define JZ_RTC_WAKEUP_FILTER_MASK 0x0000FFE0
66#define JZ_RTC_RESET_COUNTER_MASK 0x00000FE0
60 67
61static void jz4740_power_off(void) 68static inline void jz4740_rtc_wait_ready(void __iomem *rtc_base)
62{ 69{
63 void __iomem *rtc_base = ioremap(JZ4740_RTC_BASE_ADDR, 0x24);
64 uint32_t ctrl; 70 uint32_t ctrl;
65 71
66 do { 72 do {
67 ctrl = readl(rtc_base + JZ_REG_RTC_CTRL); 73 ctrl = readl(rtc_base + JZ_REG_RTC_CTRL);
68 } while (!(ctrl & JZ_RTC_CTRL_WRDY)); 74 } while (!(ctrl & JZ_RTC_CTRL_WRDY));
75}
69 76
77static void jz4740_power_off(void)
78{
79 void __iomem *rtc_base = ioremap(JZ4740_RTC_BASE_ADDR, 0x38);
80 unsigned long wakeup_filter_ticks;
81 unsigned long reset_counter_ticks;
82
83 /*
84 * Set minimum wakeup pin assertion time: 100 ms.
85 * Range is 0 to 2 sec if RTC is clocked at 32 kHz.
86 */
87 wakeup_filter_ticks = (100 * jz4740_clock_bdata.rtc_rate) / 1000;
88 if (wakeup_filter_ticks < JZ_RTC_WAKEUP_FILTER_MASK)
89 wakeup_filter_ticks &= JZ_RTC_WAKEUP_FILTER_MASK;
90 else
91 wakeup_filter_ticks = JZ_RTC_WAKEUP_FILTER_MASK;
92 jz4740_rtc_wait_ready(rtc_base);
93 writel(wakeup_filter_ticks, rtc_base + JZ_REG_RTC_WAKEUP_FILTER);
94
95 /*
96 * Set reset pin low-level assertion time after wakeup: 60 ms.
97 * Range is 0 to 125 ms if RTC is clocked at 32 kHz.
98 */
99 reset_counter_ticks = (60 * jz4740_clock_bdata.rtc_rate) / 1000;
100 if (reset_counter_ticks < JZ_RTC_RESET_COUNTER_MASK)
101 reset_counter_ticks &= JZ_RTC_RESET_COUNTER_MASK;
102 else
103 reset_counter_ticks = JZ_RTC_RESET_COUNTER_MASK;
104 jz4740_rtc_wait_ready(rtc_base);
105 writel(reset_counter_ticks, rtc_base + JZ_REG_RTC_RESET_COUNTER);
106
107 jz4740_rtc_wait_ready(rtc_base);
70 writel(1, rtc_base + JZ_REG_RTC_HIBERNATE); 108 writel(1, rtc_base + JZ_REG_RTC_HIBERNATE);
109
71 jz4740_halt(); 110 jz4740_halt();
72} 111}
73 112
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index f4630e1082ab..1b51046191e8 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -190,6 +190,7 @@ void __init check_wait(void)
190 case CPU_CAVIUM_OCTEON_PLUS: 190 case CPU_CAVIUM_OCTEON_PLUS:
191 case CPU_CAVIUM_OCTEON2: 191 case CPU_CAVIUM_OCTEON2:
192 case CPU_JZRISC: 192 case CPU_JZRISC:
193 case CPU_LOONGSON1:
193 case CPU_XLR: 194 case CPU_XLR:
194 case CPU_XLP: 195 case CPU_XLP:
195 cpu_wait = r4k_wait; 196 cpu_wait = r4k_wait;
@@ -330,6 +331,154 @@ static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
330#endif 331#endif
331} 332}
332 333
334static char unknown_isa[] __cpuinitdata = KERN_ERR \
335 "Unsupported ISA type, c0.config0: %d.";
336
337static inline unsigned int decode_config0(struct cpuinfo_mips *c)
338{
339 unsigned int config0;
340 int isa;
341
342 config0 = read_c0_config();
343
344 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
345 c->options |= MIPS_CPU_TLB;
346 isa = (config0 & MIPS_CONF_AT) >> 13;
347 switch (isa) {
348 case 0:
349 switch ((config0 & MIPS_CONF_AR) >> 10) {
350 case 0:
351 c->isa_level = MIPS_CPU_ISA_M32R1;
352 break;
353 case 1:
354 c->isa_level = MIPS_CPU_ISA_M32R2;
355 break;
356 default:
357 goto unknown;
358 }
359 break;
360 case 2:
361 switch ((config0 & MIPS_CONF_AR) >> 10) {
362 case 0:
363 c->isa_level = MIPS_CPU_ISA_M64R1;
364 break;
365 case 1:
366 c->isa_level = MIPS_CPU_ISA_M64R2;
367 break;
368 default:
369 goto unknown;
370 }
371 break;
372 default:
373 goto unknown;
374 }
375
376 return config0 & MIPS_CONF_M;
377
378unknown:
379 panic(unknown_isa, config0);
380}
381
382static inline unsigned int decode_config1(struct cpuinfo_mips *c)
383{
384 unsigned int config1;
385
386 config1 = read_c0_config1();
387
388 if (config1 & MIPS_CONF1_MD)
389 c->ases |= MIPS_ASE_MDMX;
390 if (config1 & MIPS_CONF1_WR)
391 c->options |= MIPS_CPU_WATCH;
392 if (config1 & MIPS_CONF1_CA)
393 c->ases |= MIPS_ASE_MIPS16;
394 if (config1 & MIPS_CONF1_EP)
395 c->options |= MIPS_CPU_EJTAG;
396 if (config1 & MIPS_CONF1_FP) {
397 c->options |= MIPS_CPU_FPU;
398 c->options |= MIPS_CPU_32FPR;
399 }
400 if (cpu_has_tlb)
401 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
402
403 return config1 & MIPS_CONF_M;
404}
405
406static inline unsigned int decode_config2(struct cpuinfo_mips *c)
407{
408 unsigned int config2;
409
410 config2 = read_c0_config2();
411
412 if (config2 & MIPS_CONF2_SL)
413 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
414
415 return config2 & MIPS_CONF_M;
416}
417
418static inline unsigned int decode_config3(struct cpuinfo_mips *c)
419{
420 unsigned int config3;
421
422 config3 = read_c0_config3();
423
424 if (config3 & MIPS_CONF3_SM)
425 c->ases |= MIPS_ASE_SMARTMIPS;
426 if (config3 & MIPS_CONF3_DSP)
427 c->ases |= MIPS_ASE_DSP;
428 if (config3 & MIPS_CONF3_VINT)
429 c->options |= MIPS_CPU_VINT;
430 if (config3 & MIPS_CONF3_VEIC)
431 c->options |= MIPS_CPU_VEIC;
432 if (config3 & MIPS_CONF3_MT)
433 c->ases |= MIPS_ASE_MIPSMT;
434 if (config3 & MIPS_CONF3_ULRI)
435 c->options |= MIPS_CPU_ULRI;
436
437 return config3 & MIPS_CONF_M;
438}
439
440static inline unsigned int decode_config4(struct cpuinfo_mips *c)
441{
442 unsigned int config4;
443
444 config4 = read_c0_config4();
445
446 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
447 && cpu_has_tlb)
448 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
449
450 c->kscratch_mask = (config4 >> 16) & 0xff;
451
452 return config4 & MIPS_CONF_M;
453}
454
455static void __cpuinit decode_configs(struct cpuinfo_mips *c)
456{
457 int ok;
458
459 /* MIPS32 or MIPS64 compliant CPU. */
460 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
461 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
462
463 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
464
465 ok = decode_config0(c); /* Read Config registers. */
466 BUG_ON(!ok); /* Arch spec violation! */
467 if (ok)
468 ok = decode_config1(c);
469 if (ok)
470 ok = decode_config2(c);
471 if (ok)
472 ok = decode_config3(c);
473 if (ok)
474 ok = decode_config4(c);
475
476 mips_probe_watch_registers(c);
477
478 if (cpu_has_mips_r2)
479 c->core = read_c0_ebase() & 0x3ff;
480}
481
333#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \ 482#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
334 | MIPS_CPU_COUNTER) 483 | MIPS_CPU_COUNTER)
335 484
@@ -638,155 +787,19 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
638 MIPS_CPU_32FPR; 787 MIPS_CPU_32FPR;
639 c->tlbsize = 64; 788 c->tlbsize = 64;
640 break; 789 break;
641 } 790 case PRID_IMP_LOONGSON1:
642} 791 decode_configs(c);
643
644static char unknown_isa[] __cpuinitdata = KERN_ERR \
645 "Unsupported ISA type, c0.config0: %d.";
646 792
647static inline unsigned int decode_config0(struct cpuinfo_mips *c) 793 c->cputype = CPU_LOONGSON1;
648{
649 unsigned int config0;
650 int isa;
651 794
652 config0 = read_c0_config(); 795 switch (c->processor_id & PRID_REV_MASK) {
653 796 case PRID_REV_LOONGSON1B:
654 if (((config0 & MIPS_CONF_MT) >> 7) == 1) 797 __cpu_name[cpu] = "Loongson 1B";
655 c->options |= MIPS_CPU_TLB;
656 isa = (config0 & MIPS_CONF_AT) >> 13;
657 switch (isa) {
658 case 0:
659 switch ((config0 & MIPS_CONF_AR) >> 10) {
660 case 0:
661 c->isa_level = MIPS_CPU_ISA_M32R1;
662 break;
663 case 1:
664 c->isa_level = MIPS_CPU_ISA_M32R2;
665 break; 798 break;
666 default:
667 goto unknown;
668 } 799 }
669 break;
670 case 2:
671 switch ((config0 & MIPS_CONF_AR) >> 10) {
672 case 0:
673 c->isa_level = MIPS_CPU_ISA_M64R1;
674 break;
675 case 1:
676 c->isa_level = MIPS_CPU_ISA_M64R2;
677 break;
678 default:
679 goto unknown;
680 }
681 break;
682 default:
683 goto unknown;
684 }
685
686 return config0 & MIPS_CONF_M;
687
688unknown:
689 panic(unknown_isa, config0);
690}
691 800
692static inline unsigned int decode_config1(struct cpuinfo_mips *c) 801 break;
693{
694 unsigned int config1;
695
696 config1 = read_c0_config1();
697
698 if (config1 & MIPS_CONF1_MD)
699 c->ases |= MIPS_ASE_MDMX;
700 if (config1 & MIPS_CONF1_WR)
701 c->options |= MIPS_CPU_WATCH;
702 if (config1 & MIPS_CONF1_CA)
703 c->ases |= MIPS_ASE_MIPS16;
704 if (config1 & MIPS_CONF1_EP)
705 c->options |= MIPS_CPU_EJTAG;
706 if (config1 & MIPS_CONF1_FP) {
707 c->options |= MIPS_CPU_FPU;
708 c->options |= MIPS_CPU_32FPR;
709 } 802 }
710 if (cpu_has_tlb)
711 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
712
713 return config1 & MIPS_CONF_M;
714}
715
716static inline unsigned int decode_config2(struct cpuinfo_mips *c)
717{
718 unsigned int config2;
719
720 config2 = read_c0_config2();
721
722 if (config2 & MIPS_CONF2_SL)
723 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
724
725 return config2 & MIPS_CONF_M;
726}
727
728static inline unsigned int decode_config3(struct cpuinfo_mips *c)
729{
730 unsigned int config3;
731
732 config3 = read_c0_config3();
733
734 if (config3 & MIPS_CONF3_SM)
735 c->ases |= MIPS_ASE_SMARTMIPS;
736 if (config3 & MIPS_CONF3_DSP)
737 c->ases |= MIPS_ASE_DSP;
738 if (config3 & MIPS_CONF3_VINT)
739 c->options |= MIPS_CPU_VINT;
740 if (config3 & MIPS_CONF3_VEIC)
741 c->options |= MIPS_CPU_VEIC;
742 if (config3 & MIPS_CONF3_MT)
743 c->ases |= MIPS_ASE_MIPSMT;
744 if (config3 & MIPS_CONF3_ULRI)
745 c->options |= MIPS_CPU_ULRI;
746
747 return config3 & MIPS_CONF_M;
748}
749
750static inline unsigned int decode_config4(struct cpuinfo_mips *c)
751{
752 unsigned int config4;
753
754 config4 = read_c0_config4();
755
756 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
757 && cpu_has_tlb)
758 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
759
760 c->kscratch_mask = (config4 >> 16) & 0xff;
761
762 return config4 & MIPS_CONF_M;
763}
764
765static void __cpuinit decode_configs(struct cpuinfo_mips *c)
766{
767 int ok;
768
769 /* MIPS32 or MIPS64 compliant CPU. */
770 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
771 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
772
773 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
774
775 ok = decode_config0(c); /* Read Config registers. */
776 BUG_ON(!ok); /* Arch spec violation! */
777 if (ok)
778 ok = decode_config1(c);
779 if (ok)
780 ok = decode_config2(c);
781 if (ok)
782 ok = decode_config3(c);
783 if (ok)
784 ok = decode_config4(c);
785
786 mips_probe_watch_registers(c);
787
788 if (cpu_has_mips_r2)
789 c->core = read_c0_ebase() & 0x3ff;
790} 803}
791 804
792static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu) 805static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
index eb5e394a4650..2f28d3b55687 100644
--- a/arch/mips/kernel/perf_event_mipsxx.c
+++ b/arch/mips/kernel/perf_event_mipsxx.c
@@ -1559,6 +1559,11 @@ init_hw_perf_events(void)
1559 mipspmu.general_event_map = &mipsxxcore_event_map; 1559 mipspmu.general_event_map = &mipsxxcore_event_map;
1560 mipspmu.cache_event_map = &mipsxxcore_cache_map; 1560 mipspmu.cache_event_map = &mipsxxcore_cache_map;
1561 break; 1561 break;
1562 case CPU_LOONGSON1:
1563 mipspmu.name = "mips/loongson1";
1564 mipspmu.general_event_map = &mipsxxcore_event_map;
1565 mipspmu.cache_event_map = &mipsxxcore_cache_map;
1566 break;
1562 case CPU_CAVIUM_OCTEON: 1567 case CPU_CAVIUM_OCTEON:
1563 case CPU_CAVIUM_OCTEON_PLUS: 1568 case CPU_CAVIUM_OCTEON_PLUS:
1564 case CPU_CAVIUM_OCTEON2: 1569 case CPU_CAVIUM_OCTEON2:
diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
index f11b2bbb826d..028f6f837ef9 100644
--- a/arch/mips/kernel/prom.c
+++ b/arch/mips/kernel/prom.c
@@ -35,16 +35,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
35 return add_memory_region(base, size, BOOT_MEM_RAM); 35 return add_memory_region(base, size, BOOT_MEM_RAM);
36} 36}
37 37
38int __init reserve_mem_mach(unsigned long addr, unsigned long size)
39{
40 return reserve_bootmem(addr, size, BOOTMEM_DEFAULT);
41}
42
43void __init free_mem_mach(unsigned long addr, unsigned long size)
44{
45 return free_bootmem(addr, size);
46}
47
48void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 38void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
49{ 39{
50 return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)); 40 return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS));
@@ -77,25 +67,6 @@ void __init early_init_devtree(void *params)
77 of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL); 67 of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
78} 68}
79 69
80void __init device_tree_init(void)
81{
82 unsigned long base, size;
83
84 if (!initial_boot_params)
85 return;
86
87 base = virt_to_phys((void *)initial_boot_params);
88 size = be32_to_cpu(initial_boot_params->totalsize);
89
90 /* Before we do anything, lets reserve the dt blob */
91 reserve_mem_mach(base, size);
92
93 unflatten_device_tree();
94
95 /* free the space reserved for the dt blob */
96 free_mem_mach(base, size);
97}
98
99void __init __dt_setup_arch(struct boot_param_header *bph) 70void __init __dt_setup_arch(struct boot_param_header *bph)
100{ 71{
101 if (be32_to_cpu(bph->magic) != OF_DT_HEADER) { 72 if (be32_to_cpu(bph->magic) != OF_DT_HEADER) {
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 1268392f1d27..31637d8c8738 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -102,7 +102,9 @@ asmlinkage __cpuinit void start_secondary(void)
102 102
103#ifdef CONFIG_MIPS_MT_SMTC 103#ifdef CONFIG_MIPS_MT_SMTC
104 /* Only do cpu_probe for first TC of CPU */ 104 /* Only do cpu_probe for first TC of CPU */
105 if ((read_c0_tcbind() & TCBIND_CURTC) == 0) 105 if ((read_c0_tcbind() & TCBIND_CURTC) != 0)
106 __cpu_name[smp_processor_id()] = __cpu_name[0];
107 else
106#endif /* CONFIG_MIPS_MT_SMTC */ 108#endif /* CONFIG_MIPS_MT_SMTC */
107 cpu_probe(); 109 cpu_probe();
108 cpu_report(); 110 cpu_report();
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index 15b5f3cfd20c..1d47843d3cc0 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -86,6 +86,13 @@ struct smtc_ipi_q IPIQ[NR_CPUS];
86static struct smtc_ipi_q freeIPIq; 86static struct smtc_ipi_q freeIPIq;
87 87
88 88
89/*
90 * Number of FPU contexts for each VPE
91 */
92
93static int smtc_nconf1[MAX_SMTC_VPES];
94
95
89/* Forward declarations */ 96/* Forward declarations */
90 97
91void ipi_decode(struct smtc_ipi *); 98void ipi_decode(struct smtc_ipi *);
@@ -174,9 +181,9 @@ static int __init tintq(char *str)
174 181
175__setup("tintq=", tintq); 182__setup("tintq=", tintq);
176 183
177static int imstuckcount[2][8]; 184static int imstuckcount[MAX_SMTC_VPES][8];
178/* vpemask represents IM/IE bits of per-VPE Status registers, low-to-high */ 185/* vpemask represents IM/IE bits of per-VPE Status registers, low-to-high */
179static int vpemask[2][8] = { 186static int vpemask[MAX_SMTC_VPES][8] = {
180 {0, 0, 1, 0, 0, 0, 0, 1}, 187 {0, 0, 1, 0, 0, 0, 0, 1},
181 {0, 0, 0, 0, 0, 0, 0, 1} 188 {0, 0, 0, 0, 0, 0, 0, 1}
182}; 189};
@@ -331,6 +338,22 @@ int __init smtc_build_cpu_map(int start_cpu_slot)
331 338
332static void smtc_tc_setup(int vpe, int tc, int cpu) 339static void smtc_tc_setup(int vpe, int tc, int cpu)
333{ 340{
341 static int cp1contexts[MAX_SMTC_VPES];
342
343 /*
344 * Make a local copy of the available FPU contexts in order
345 * to keep track of TCs that can have one.
346 */
347 if (tc == 1)
348 {
349 /*
350 * FIXME: Multi-core SMTC hasn't been tested and the
351 * maximum number of VPEs may change.
352 */
353 cp1contexts[0] = smtc_nconf1[0] - 1;
354 cp1contexts[1] = smtc_nconf1[1];
355 }
356
334 settc(tc); 357 settc(tc);
335 write_tc_c0_tchalt(TCHALT_H); 358 write_tc_c0_tchalt(TCHALT_H);
336 mips_ihb(); 359 mips_ihb();
@@ -343,22 +366,29 @@ static void smtc_tc_setup(int vpe, int tc, int cpu)
343 * an active IPI queue. 366 * an active IPI queue.
344 */ 367 */
345 write_tc_c0_tccontext((sizeof(struct smtc_ipi_q) * cpu) << 16); 368 write_tc_c0_tccontext((sizeof(struct smtc_ipi_q) * cpu) << 16);
346 /* Bind tc to vpe */ 369
370 /* Bind TC to VPE. */
347 write_tc_c0_tcbind(vpe); 371 write_tc_c0_tcbind(vpe);
372
348 /* In general, all TCs should have the same cpu_data indications. */ 373 /* In general, all TCs should have the same cpu_data indications. */
349 memcpy(&cpu_data[cpu], &cpu_data[0], sizeof(struct cpuinfo_mips)); 374 memcpy(&cpu_data[cpu], &cpu_data[0], sizeof(struct cpuinfo_mips));
350 /* For 34Kf, start with TC/CPU 0 as sole owner of single FPU context */ 375
351 if (cpu_data[0].cputype == CPU_34K || 376 /* Check to see if there is a FPU context available for this TC. */
352 cpu_data[0].cputype == CPU_1004K) 377 if (!cp1contexts[vpe])
353 cpu_data[cpu].options &= ~MIPS_CPU_FPU; 378 cpu_data[cpu].options &= ~MIPS_CPU_FPU;
379 else
380 cp1contexts[vpe]--;
381
382 /* Store the TC and VPE into the cpu_data structure. */
354 cpu_data[cpu].vpe_id = vpe; 383 cpu_data[cpu].vpe_id = vpe;
355 cpu_data[cpu].tc_id = tc; 384 cpu_data[cpu].tc_id = tc;
356 /* Multi-core SMTC hasn't been tested, but be prepared */ 385
386 /* FIXME: Multi-core SMTC hasn't been tested, but be prepared. */
357 cpu_data[cpu].core = (read_vpe_c0_ebase() >> 1) & 0xff; 387 cpu_data[cpu].core = (read_vpe_c0_ebase() >> 1) & 0xff;
358} 388}
359 389
360/* 390/*
361 * Tweak to get Count registes in as close a sync as possible. The 391 * Tweak to get Count registers synced as closely as possible. The
362 * value seems good for 34K-class cores. 392 * value seems good for 34K-class cores.
363 */ 393 */
364 394
@@ -466,6 +496,24 @@ void smtc_prepare_cpus(int cpus)
466 smtc_configure_tlb(); 496 smtc_configure_tlb();
467 497
468 for (tc = 0, vpe = 0 ; (vpe < nvpe) && (tc < ntc) ; vpe++) { 498 for (tc = 0, vpe = 0 ; (vpe < nvpe) && (tc < ntc) ; vpe++) {
499 /* Get number of CP1 contexts for each VPE. */
500 if (tc == 0)
501 {
502 /*
503 * Do not call settc() for TC0 or the FPU context
504 * value will be incorrect. Besides, we know that
505 * we are TC0 anyway.
506 */
507 smtc_nconf1[0] = ((read_vpe_c0_vpeconf1() &
508 VPECONF1_NCP1) >> VPECONF1_NCP1_SHIFT);
509 if (nvpe == 2)
510 {
511 settc(1);
512 smtc_nconf1[1] = ((read_vpe_c0_vpeconf1() &
513 VPECONF1_NCP1) >> VPECONF1_NCP1_SHIFT);
514 settc(0);
515 }
516 }
469 if (tcpervpe[vpe] == 0) 517 if (tcpervpe[vpe] == 0)
470 continue; 518 continue;
471 if (vpe != 0) 519 if (vpe != 0)
@@ -479,6 +527,18 @@ void smtc_prepare_cpus(int cpus)
479 */ 527 */
480 if (tc != 0) { 528 if (tc != 0) {
481 smtc_tc_setup(vpe, tc, cpu); 529 smtc_tc_setup(vpe, tc, cpu);
530 if (vpe != 0) {
531 /*
532 * Set MVP bit (possibly again). Do it
533 * here to catch CPUs that have no TCs
534 * bound to the VPE at reset. In that
535 * case, a TC must be bound to the VPE
536 * before we can set VPEControl[MVP]
537 */
538 write_vpe_c0_vpeconf0(
539 read_vpe_c0_vpeconf0() |
540 VPECONF0_MVP);
541 }
482 cpu++; 542 cpu++;
483 } 543 }
484 printk(" %d", tc); 544 printk(" %d", tc);
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index c3c293543703..9be3df1fa8a4 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -1253,6 +1253,7 @@ static inline void parity_protection_init(void)
1253 1253
1254 case CPU_5KC: 1254 case CPU_5KC:
1255 case CPU_5KE: 1255 case CPU_5KE:
1256 case CPU_LOONGSON1:
1256 write_c0_ecc(0x80000000); 1257 write_c0_ecc(0x80000000);
1257 back_to_back_c0_hazard(); 1258 back_to_back_c0_hazard();
1258 /* Set the PE bit (bit 31) in the c0_errctl register. */ 1259 /* Set the PE bit (bit 31) in the c0_errctl register. */
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index 2a7c74fc15fc..399a50a541d4 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -2,7 +2,7 @@
2# Makefile for MIPS-specific library files.. 2# Makefile for MIPS-specific library files..
3# 3#
4 4
5lib-y += csum_partial.o delay.o memcpy.o memcpy-inatomic.o memset.o \ 5lib-y += csum_partial.o delay.o memcpy.o memset.o \
6 strlen_user.o strncpy_user.o strnlen_user.o uncached.o 6 strlen_user.o strncpy_user.o strnlen_user.o uncached.o
7 7
8obj-y += iomap.o 8obj-y += iomap.o
diff --git a/arch/mips/lib/memcpy-inatomic.S b/arch/mips/lib/memcpy-inatomic.S
deleted file mode 100644
index 68853a038d3f..000000000000
--- a/arch/mips/lib/memcpy-inatomic.S
+++ /dev/null
@@ -1,451 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Unified implementation of memcpy, memmove and the __copy_user backend.
7 *
8 * Copyright (C) 1998, 99, 2000, 01, 2002 Ralf Baechle (ralf@gnu.org)
9 * Copyright (C) 1999, 2000, 01, 2002 Silicon Graphics, Inc.
10 * Copyright (C) 2002 Broadcom, Inc.
11 * memcpy/copy_user author: Mark Vandevoorde
12 * Copyright (C) 2007 Maciej W. Rozycki
13 *
14 * Mnemonic names for arguments to memcpy/__copy_user
15 */
16
17/*
18 * Hack to resolve longstanding prefetch issue
19 *
20 * Prefetching may be fatal on some systems if we're prefetching beyond the
21 * end of memory on some systems. It's also a seriously bad idea on non
22 * dma-coherent systems.
23 */
24#ifdef CONFIG_DMA_NONCOHERENT
25#undef CONFIG_CPU_HAS_PREFETCH
26#endif
27#ifdef CONFIG_MIPS_MALTA
28#undef CONFIG_CPU_HAS_PREFETCH
29#endif
30
31#include <asm/asm.h>
32#include <asm/asm-offsets.h>
33#include <asm/regdef.h>
34
35#define dst a0
36#define src a1
37#define len a2
38
39/*
40 * Spec
41 *
42 * memcpy copies len bytes from src to dst and sets v0 to dst.
43 * It assumes that
44 * - src and dst don't overlap
45 * - src is readable
46 * - dst is writable
47 * memcpy uses the standard calling convention
48 *
49 * __copy_user copies up to len bytes from src to dst and sets a2 (len) to
50 * the number of uncopied bytes due to an exception caused by a read or write.
51 * __copy_user assumes that src and dst don't overlap, and that the call is
52 * implementing one of the following:
53 * copy_to_user
54 * - src is readable (no exceptions when reading src)
55 * copy_from_user
56 * - dst is writable (no exceptions when writing dst)
57 * __copy_user uses a non-standard calling convention; see
58 * include/asm-mips/uaccess.h
59 *
60 * When an exception happens on a load, the handler must
61 # ensure that all of the destination buffer is overwritten to prevent
62 * leaking information to user mode programs.
63 */
64
65/*
66 * Implementation
67 */
68
69/*
70 * The exception handler for loads requires that:
71 * 1- AT contain the address of the byte just past the end of the source
72 * of the copy,
73 * 2- src_entry <= src < AT, and
74 * 3- (dst - src) == (dst_entry - src_entry),
75 * The _entry suffix denotes values when __copy_user was called.
76 *
77 * (1) is set up up by uaccess.h and maintained by not writing AT in copy_user
78 * (2) is met by incrementing src by the number of bytes copied
79 * (3) is met by not doing loads between a pair of increments of dst and src
80 *
81 * The exception handlers for stores adjust len (if necessary) and return.
82 * These handlers do not need to overwrite any data.
83 *
84 * For __rmemcpy and memmove an exception is always a kernel bug, therefore
85 * they're not protected.
86 */
87
88#define EXC(inst_reg,addr,handler) \
899: inst_reg, addr; \
90 .section __ex_table,"a"; \
91 PTR 9b, handler; \
92 .previous
93
94/*
95 * Only on the 64-bit kernel we can made use of 64-bit registers.
96 */
97#ifdef CONFIG_64BIT
98#define USE_DOUBLE
99#endif
100
101#ifdef USE_DOUBLE
102
103#define LOAD ld
104#define LOADL ldl
105#define LOADR ldr
106#define STOREL sdl
107#define STORER sdr
108#define STORE sd
109#define ADD daddu
110#define SUB dsubu
111#define SRL dsrl
112#define SRA dsra
113#define SLL dsll
114#define SLLV dsllv
115#define SRLV dsrlv
116#define NBYTES 8
117#define LOG_NBYTES 3
118
119/*
120 * As we are sharing code base with the mips32 tree (which use the o32 ABI
121 * register definitions). We need to redefine the register definitions from
122 * the n64 ABI register naming to the o32 ABI register naming.
123 */
124#undef t0
125#undef t1
126#undef t2
127#undef t3
128#define t0 $8
129#define t1 $9
130#define t2 $10
131#define t3 $11
132#define t4 $12
133#define t5 $13
134#define t6 $14
135#define t7 $15
136
137#else
138
139#define LOAD lw
140#define LOADL lwl
141#define LOADR lwr
142#define STOREL swl
143#define STORER swr
144#define STORE sw
145#define ADD addu
146#define SUB subu
147#define SRL srl
148#define SLL sll
149#define SRA sra
150#define SLLV sllv
151#define SRLV srlv
152#define NBYTES 4
153#define LOG_NBYTES 2
154
155#endif /* USE_DOUBLE */
156
157#ifdef CONFIG_CPU_LITTLE_ENDIAN
158#define LDFIRST LOADR
159#define LDREST LOADL
160#define STFIRST STORER
161#define STREST STOREL
162#define SHIFT_DISCARD SLLV
163#else
164#define LDFIRST LOADL
165#define LDREST LOADR
166#define STFIRST STOREL
167#define STREST STORER
168#define SHIFT_DISCARD SRLV
169#endif
170
171#define FIRST(unit) ((unit)*NBYTES)
172#define REST(unit) (FIRST(unit)+NBYTES-1)
173#define UNIT(unit) FIRST(unit)
174
175#define ADDRMASK (NBYTES-1)
176
177 .text
178 .set noreorder
179#ifndef CONFIG_CPU_DADDI_WORKAROUNDS
180 .set noat
181#else
182 .set at=v1
183#endif
184
185/*
186 * A combined memcpy/__copy_user
187 * __copy_user sets len to 0 for success; else to an upper bound of
188 * the number of uncopied bytes.
189 * memcpy sets v0 to dst.
190 */
191 .align 5
192LEAF(__copy_user_inatomic)
193 /*
194 * Note: dst & src may be unaligned, len may be 0
195 * Temps
196 */
197#define rem t8
198
199 /*
200 * The "issue break"s below are very approximate.
201 * Issue delays for dcache fills will perturb the schedule, as will
202 * load queue full replay traps, etc.
203 *
204 * If len < NBYTES use byte operations.
205 */
206 PREF( 0, 0(src) )
207 PREF( 1, 0(dst) )
208 sltu t2, len, NBYTES
209 and t1, dst, ADDRMASK
210 PREF( 0, 1*32(src) )
211 PREF( 1, 1*32(dst) )
212 bnez t2, .Lcopy_bytes_checklen
213 and t0, src, ADDRMASK
214 PREF( 0, 2*32(src) )
215 PREF( 1, 2*32(dst) )
216 bnez t1, .Ldst_unaligned
217 nop
218 bnez t0, .Lsrc_unaligned_dst_aligned
219 /*
220 * use delay slot for fall-through
221 * src and dst are aligned; need to compute rem
222 */
223.Lboth_aligned:
224 SRL t0, len, LOG_NBYTES+3 # +3 for 8 units/iter
225 beqz t0, .Lcleanup_both_aligned # len < 8*NBYTES
226 and rem, len, (8*NBYTES-1) # rem = len % (8*NBYTES)
227 PREF( 0, 3*32(src) )
228 PREF( 1, 3*32(dst) )
229 .align 4
2301:
231EXC( LOAD t0, UNIT(0)(src), .Ll_exc)
232EXC( LOAD t1, UNIT(1)(src), .Ll_exc_copy)
233EXC( LOAD t2, UNIT(2)(src), .Ll_exc_copy)
234EXC( LOAD t3, UNIT(3)(src), .Ll_exc_copy)
235 SUB len, len, 8*NBYTES
236EXC( LOAD t4, UNIT(4)(src), .Ll_exc_copy)
237EXC( LOAD t7, UNIT(5)(src), .Ll_exc_copy)
238 STORE t0, UNIT(0)(dst)
239 STORE t1, UNIT(1)(dst)
240EXC( LOAD t0, UNIT(6)(src), .Ll_exc_copy)
241EXC( LOAD t1, UNIT(7)(src), .Ll_exc_copy)
242 ADD src, src, 8*NBYTES
243 ADD dst, dst, 8*NBYTES
244 STORE t2, UNIT(-6)(dst)
245 STORE t3, UNIT(-5)(dst)
246 STORE t4, UNIT(-4)(dst)
247 STORE t7, UNIT(-3)(dst)
248 STORE t0, UNIT(-2)(dst)
249 STORE t1, UNIT(-1)(dst)
250 PREF( 0, 8*32(src) )
251 PREF( 1, 8*32(dst) )
252 bne len, rem, 1b
253 nop
254
255 /*
256 * len == rem == the number of bytes left to copy < 8*NBYTES
257 */
258.Lcleanup_both_aligned:
259 beqz len, .Ldone
260 sltu t0, len, 4*NBYTES
261 bnez t0, .Lless_than_4units
262 and rem, len, (NBYTES-1) # rem = len % NBYTES
263 /*
264 * len >= 4*NBYTES
265 */
266EXC( LOAD t0, UNIT(0)(src), .Ll_exc)
267EXC( LOAD t1, UNIT(1)(src), .Ll_exc_copy)
268EXC( LOAD t2, UNIT(2)(src), .Ll_exc_copy)
269EXC( LOAD t3, UNIT(3)(src), .Ll_exc_copy)
270 SUB len, len, 4*NBYTES
271 ADD src, src, 4*NBYTES
272 STORE t0, UNIT(0)(dst)
273 STORE t1, UNIT(1)(dst)
274 STORE t2, UNIT(2)(dst)
275 STORE t3, UNIT(3)(dst)
276 .set reorder /* DADDI_WAR */
277 ADD dst, dst, 4*NBYTES
278 beqz len, .Ldone
279 .set noreorder
280.Lless_than_4units:
281 /*
282 * rem = len % NBYTES
283 */
284 beq rem, len, .Lcopy_bytes
285 nop
2861:
287EXC( LOAD t0, 0(src), .Ll_exc)
288 ADD src, src, NBYTES
289 SUB len, len, NBYTES
290 STORE t0, 0(dst)
291 .set reorder /* DADDI_WAR */
292 ADD dst, dst, NBYTES
293 bne rem, len, 1b
294 .set noreorder
295
296 /*
297 * src and dst are aligned, need to copy rem bytes (rem < NBYTES)
298 * A loop would do only a byte at a time with possible branch
299 * mispredicts. Can't do an explicit LOAD dst,mask,or,STORE
300 * because can't assume read-access to dst. Instead, use
301 * STREST dst, which doesn't require read access to dst.
302 *
303 * This code should perform better than a simple loop on modern,
304 * wide-issue mips processors because the code has fewer branches and
305 * more instruction-level parallelism.
306 */
307#define bits t2
308 beqz len, .Ldone
309 ADD t1, dst, len # t1 is just past last byte of dst
310 li bits, 8*NBYTES
311 SLL rem, len, 3 # rem = number of bits to keep
312EXC( LOAD t0, 0(src), .Ll_exc)
313 SUB bits, bits, rem # bits = number of bits to discard
314 SHIFT_DISCARD t0, t0, bits
315 STREST t0, -1(t1)
316 jr ra
317 move len, zero
318.Ldst_unaligned:
319 /*
320 * dst is unaligned
321 * t0 = src & ADDRMASK
322 * t1 = dst & ADDRMASK; T1 > 0
323 * len >= NBYTES
324 *
325 * Copy enough bytes to align dst
326 * Set match = (src and dst have same alignment)
327 */
328#define match rem
329EXC( LDFIRST t3, FIRST(0)(src), .Ll_exc)
330 ADD t2, zero, NBYTES
331EXC( LDREST t3, REST(0)(src), .Ll_exc_copy)
332 SUB t2, t2, t1 # t2 = number of bytes copied
333 xor match, t0, t1
334 STFIRST t3, FIRST(0)(dst)
335 beq len, t2, .Ldone
336 SUB len, len, t2
337 ADD dst, dst, t2
338 beqz match, .Lboth_aligned
339 ADD src, src, t2
340
341.Lsrc_unaligned_dst_aligned:
342 SRL t0, len, LOG_NBYTES+2 # +2 for 4 units/iter
343 PREF( 0, 3*32(src) )
344 beqz t0, .Lcleanup_src_unaligned
345 and rem, len, (4*NBYTES-1) # rem = len % 4*NBYTES
346 PREF( 1, 3*32(dst) )
3471:
348/*
349 * Avoid consecutive LD*'s to the same register since some mips
350 * implementations can't issue them in the same cycle.
351 * It's OK to load FIRST(N+1) before REST(N) because the two addresses
352 * are to the same unit (unless src is aligned, but it's not).
353 */
354EXC( LDFIRST t0, FIRST(0)(src), .Ll_exc)
355EXC( LDFIRST t1, FIRST(1)(src), .Ll_exc_copy)
356 SUB len, len, 4*NBYTES
357EXC( LDREST t0, REST(0)(src), .Ll_exc_copy)
358EXC( LDREST t1, REST(1)(src), .Ll_exc_copy)
359EXC( LDFIRST t2, FIRST(2)(src), .Ll_exc_copy)
360EXC( LDFIRST t3, FIRST(3)(src), .Ll_exc_copy)
361EXC( LDREST t2, REST(2)(src), .Ll_exc_copy)
362EXC( LDREST t3, REST(3)(src), .Ll_exc_copy)
363 PREF( 0, 9*32(src) ) # 0 is PREF_LOAD (not streamed)
364 ADD src, src, 4*NBYTES
365#ifdef CONFIG_CPU_SB1
366 nop # improves slotting
367#endif
368 STORE t0, UNIT(0)(dst)
369 STORE t1, UNIT(1)(dst)
370 STORE t2, UNIT(2)(dst)
371 STORE t3, UNIT(3)(dst)
372 PREF( 1, 9*32(dst) ) # 1 is PREF_STORE (not streamed)
373 .set reorder /* DADDI_WAR */
374 ADD dst, dst, 4*NBYTES
375 bne len, rem, 1b
376 .set noreorder
377
378.Lcleanup_src_unaligned:
379 beqz len, .Ldone
380 and rem, len, NBYTES-1 # rem = len % NBYTES
381 beq rem, len, .Lcopy_bytes
382 nop
3831:
384EXC( LDFIRST t0, FIRST(0)(src), .Ll_exc)
385EXC( LDREST t0, REST(0)(src), .Ll_exc_copy)
386 ADD src, src, NBYTES
387 SUB len, len, NBYTES
388 STORE t0, 0(dst)
389 .set reorder /* DADDI_WAR */
390 ADD dst, dst, NBYTES
391 bne len, rem, 1b
392 .set noreorder
393
394.Lcopy_bytes_checklen:
395 beqz len, .Ldone
396 nop
397.Lcopy_bytes:
398 /* 0 < len < NBYTES */
399#define COPY_BYTE(N) \
400EXC( lb t0, N(src), .Ll_exc); \
401 SUB len, len, 1; \
402 beqz len, .Ldone; \
403 sb t0, N(dst)
404
405 COPY_BYTE(0)
406 COPY_BYTE(1)
407#ifdef USE_DOUBLE
408 COPY_BYTE(2)
409 COPY_BYTE(3)
410 COPY_BYTE(4)
411 COPY_BYTE(5)
412#endif
413EXC( lb t0, NBYTES-2(src), .Ll_exc)
414 SUB len, len, 1
415 jr ra
416 sb t0, NBYTES-2(dst)
417.Ldone:
418 jr ra
419 nop
420 END(__copy_user_inatomic)
421
422.Ll_exc_copy:
423 /*
424 * Copy bytes from src until faulting load address (or until a
425 * lb faults)
426 *
427 * When reached by a faulting LDFIRST/LDREST, THREAD_BUADDR($28)
428 * may be more than a byte beyond the last address.
429 * Hence, the lb below may get an exception.
430 *
431 * Assumes src < THREAD_BUADDR($28)
432 */
433 LOAD t0, TI_TASK($28)
434 nop
435 LOAD t0, THREAD_BUADDR(t0)
4361:
437EXC( lb t1, 0(src), .Ll_exc)
438 ADD src, src, 1
439 sb t1, 0(dst) # can't fault -- we're copy_from_user
440 .set reorder /* DADDI_WAR */
441 ADD dst, dst, 1
442 bne src, t0, 1b
443 .set noreorder
444.Ll_exc:
445 LOAD t0, TI_TASK($28)
446 nop
447 LOAD t0, THREAD_BUADDR(t0) # t0 is just past last good address
448 nop
449 SUB len, AT, t0 # len number of uncopied bytes
450 jr ra
451 nop
diff --git a/arch/mips/lib/memcpy.S b/arch/mips/lib/memcpy.S
index 56a1f85a1ce8..65192c06781e 100644
--- a/arch/mips/lib/memcpy.S
+++ b/arch/mips/lib/memcpy.S
@@ -183,6 +183,14 @@
183#endif 183#endif
184 184
185/* 185/*
186 * t6 is used as a flag to note inatomic mode.
187 */
188LEAF(__copy_user_inatomic)
189 b __copy_user_common
190 li t6, 1
191 END(__copy_user_inatomic)
192
193/*
186 * A combined memcpy/__copy_user 194 * A combined memcpy/__copy_user
187 * __copy_user sets len to 0 for success; else to an upper bound of 195 * __copy_user sets len to 0 for success; else to an upper bound of
188 * the number of uncopied bytes. 196 * the number of uncopied bytes.
@@ -193,6 +201,8 @@ LEAF(memcpy) /* a0=dst a1=src a2=len */
193 move v0, dst /* return value */ 201 move v0, dst /* return value */
194.L__memcpy: 202.L__memcpy:
195FEXPORT(__copy_user) 203FEXPORT(__copy_user)
204 li t6, 0 /* not inatomic */
205__copy_user_common:
196 /* 206 /*
197 * Note: dst & src may be unaligned, len may be 0 207 * Note: dst & src may be unaligned, len may be 0
198 * Temps 208 * Temps
@@ -458,6 +468,7 @@ EXC( lb t1, 0(src), .Ll_exc)
458 LOAD t0, THREAD_BUADDR(t0) # t0 is just past last good address 468 LOAD t0, THREAD_BUADDR(t0) # t0 is just past last good address
459 nop 469 nop
460 SUB len, AT, t0 # len number of uncopied bytes 470 SUB len, AT, t0 # len number of uncopied bytes
471 bnez t6, .Ldone /* Skip the zeroing part if inatomic */
461 /* 472 /*
462 * Here's where we rely on src and dst being incremented in tandem, 473 * Here's where we rely on src and dst being incremented in tandem,
463 * See (3) above. 474 * See (3) above.
diff --git a/arch/mips/loongson1/Kconfig b/arch/mips/loongson1/Kconfig
new file mode 100644
index 000000000000..237fa214de9f
--- /dev/null
+++ b/arch/mips/loongson1/Kconfig
@@ -0,0 +1,21 @@
1if MACH_LOONGSON1
2
3choice
4 prompt "Machine Type"
5
6config LOONGSON1_LS1B
7 bool "Loongson LS1B board"
8 select CEVT_R4K
9 select CSRC_R4K
10 select SYS_HAS_CPU_LOONGSON1B
11 select DMA_NONCOHERENT
12 select BOOT_ELF32
13 select IRQ_CPU
14 select SYS_SUPPORTS_32BIT_KERNEL
15 select SYS_SUPPORTS_LITTLE_ENDIAN
16 select SYS_SUPPORTS_HIGHMEM
17 select SYS_HAS_EARLY_PRINTK
18
19endchoice
20
21endif # MACH_LOONGSON1
diff --git a/arch/mips/loongson1/Makefile b/arch/mips/loongson1/Makefile
new file mode 100644
index 000000000000..9719c75886f5
--- /dev/null
+++ b/arch/mips/loongson1/Makefile
@@ -0,0 +1,11 @@
1#
2# Common code for all Loongson 1 based systems
3#
4
5obj-$(CONFIG_MACH_LOONGSON1) += common/
6
7#
8# Loongson LS1B board
9#
10
11obj-$(CONFIG_LOONGSON1_LS1B) += ls1b/
diff --git a/arch/mips/loongson1/Platform b/arch/mips/loongson1/Platform
new file mode 100644
index 000000000000..99bdefe627af
--- /dev/null
+++ b/arch/mips/loongson1/Platform
@@ -0,0 +1,7 @@
1cflags-$(CONFIG_CPU_LOONGSON1) += \
2 $(call cc-option,-march=mips32r2,-mips32r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) \
3 -Wa,-mips32r2 -Wa,--trap
4
5platform-$(CONFIG_MACH_LOONGSON1) += loongson1/
6cflags-$(CONFIG_MACH_LOONGSON1) += -I$(srctree)/arch/mips/include/asm/mach-loongson1
7load-$(CONFIG_LOONGSON1_LS1B) += 0xffffffff80100000
diff --git a/arch/mips/loongson1/common/Makefile b/arch/mips/loongson1/common/Makefile
new file mode 100644
index 000000000000..b2797709ef5b
--- /dev/null
+++ b/arch/mips/loongson1/common/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for common code of loongson1 based machines.
3#
4
5obj-y += clock.o irq.o platform.o prom.o reset.o setup.o
diff --git a/arch/mips/loongson1/common/clock.c b/arch/mips/loongson1/common/clock.c
new file mode 100644
index 000000000000..2d98fb030596
--- /dev/null
+++ b/arch/mips/loongson1/common/clock.c
@@ -0,0 +1,165 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <linux/module.h>
11#include <linux/list.h>
12#include <linux/mutex.h>
13#include <linux/clk.h>
14#include <linux/err.h>
15#include <asm/clock.h>
16#include <asm/time.h>
17
18#include <loongson1.h>
19
20static LIST_HEAD(clocks);
21static DEFINE_MUTEX(clocks_mutex);
22
23struct clk *clk_get(struct device *dev, const char *name)
24{
25 struct clk *c;
26 struct clk *ret = NULL;
27
28 mutex_lock(&clocks_mutex);
29 list_for_each_entry(c, &clocks, node) {
30 if (!strcmp(c->name, name)) {
31 ret = c;
32 break;
33 }
34 }
35 mutex_unlock(&clocks_mutex);
36
37 return ret;
38}
39EXPORT_SYMBOL(clk_get);
40
41unsigned long clk_get_rate(struct clk *clk)
42{
43 return clk->rate;
44}
45EXPORT_SYMBOL(clk_get_rate);
46
47static void pll_clk_init(struct clk *clk)
48{
49 u32 pll;
50
51 pll = __raw_readl(LS1X_CLK_PLL_FREQ);
52 clk->rate = (12 + (pll & 0x3f)) * 33 / 2
53 + ((pll >> 8) & 0x3ff) * 33 / 1024 / 2;
54 clk->rate *= 1000000;
55}
56
57static void cpu_clk_init(struct clk *clk)
58{
59 u32 pll, ctrl;
60
61 pll = clk_get_rate(clk->parent);
62 ctrl = __raw_readl(LS1X_CLK_PLL_DIV) & DIV_CPU;
63 clk->rate = pll / (ctrl >> DIV_CPU_SHIFT);
64}
65
66static void ddr_clk_init(struct clk *clk)
67{
68 u32 pll, ctrl;
69
70 pll = clk_get_rate(clk->parent);
71 ctrl = __raw_readl(LS1X_CLK_PLL_DIV) & DIV_DDR;
72 clk->rate = pll / (ctrl >> DIV_DDR_SHIFT);
73}
74
75static void dc_clk_init(struct clk *clk)
76{
77 u32 pll, ctrl;
78
79 pll = clk_get_rate(clk->parent);
80 ctrl = __raw_readl(LS1X_CLK_PLL_DIV) & DIV_DC;
81 clk->rate = pll / (ctrl >> DIV_DC_SHIFT);
82}
83
84static struct clk_ops pll_clk_ops = {
85 .init = pll_clk_init,
86};
87
88static struct clk_ops cpu_clk_ops = {
89 .init = cpu_clk_init,
90};
91
92static struct clk_ops ddr_clk_ops = {
93 .init = ddr_clk_init,
94};
95
96static struct clk_ops dc_clk_ops = {
97 .init = dc_clk_init,
98};
99
100static struct clk pll_clk = {
101 .name = "pll",
102 .ops = &pll_clk_ops,
103};
104
105static struct clk cpu_clk = {
106 .name = "cpu",
107 .parent = &pll_clk,
108 .ops = &cpu_clk_ops,
109};
110
111static struct clk ddr_clk = {
112 .name = "ddr",
113 .parent = &pll_clk,
114 .ops = &ddr_clk_ops,
115};
116
117static struct clk dc_clk = {
118 .name = "dc",
119 .parent = &pll_clk,
120 .ops = &dc_clk_ops,
121};
122
123int clk_register(struct clk *clk)
124{
125 mutex_lock(&clocks_mutex);
126 list_add(&clk->node, &clocks);
127 if (clk->ops->init)
128 clk->ops->init(clk);
129 mutex_unlock(&clocks_mutex);
130
131 return 0;
132}
133EXPORT_SYMBOL(clk_register);
134
135static struct clk *ls1x_clks[] = {
136 &pll_clk,
137 &cpu_clk,
138 &ddr_clk,
139 &dc_clk,
140};
141
142int __init ls1x_clock_init(void)
143{
144 int i;
145
146 for (i = 0; i < ARRAY_SIZE(ls1x_clks); i++)
147 clk_register(ls1x_clks[i]);
148
149 return 0;
150}
151
152void __init plat_time_init(void)
153{
154 struct clk *clk;
155
156 /* Initialize LS1X clocks */
157 ls1x_clock_init();
158
159 /* setup mips r4k timer */
160 clk = clk_get(NULL, "cpu");
161 if (IS_ERR(clk))
162 panic("unable to get dc clock, err=%ld", PTR_ERR(clk));
163
164 mips_hpt_frequency = clk_get_rate(clk) / 2;
165}
diff --git a/arch/mips/loongson1/common/irq.c b/arch/mips/loongson1/common/irq.c
new file mode 100644
index 000000000000..41bc8ffe7bba
--- /dev/null
+++ b/arch/mips/loongson1/common/irq.c
@@ -0,0 +1,147 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <linux/interrupt.h>
11#include <linux/irq.h>
12#include <asm/irq_cpu.h>
13
14#include <loongson1.h>
15#include <irq.h>
16
17#define LS1X_INTC_REG(n, x) \
18 ((void __iomem *)KSEG1ADDR(LS1X_INTC_BASE + (n * 0x18) + (x)))
19
20#define LS1X_INTC_INTISR(n) LS1X_INTC_REG(n, 0x0)
21#define LS1X_INTC_INTIEN(n) LS1X_INTC_REG(n, 0x4)
22#define LS1X_INTC_INTSET(n) LS1X_INTC_REG(n, 0x8)
23#define LS1X_INTC_INTCLR(n) LS1X_INTC_REG(n, 0xc)
24#define LS1X_INTC_INTPOL(n) LS1X_INTC_REG(n, 0x10)
25#define LS1X_INTC_INTEDGE(n) LS1X_INTC_REG(n, 0x14)
26
27static void ls1x_irq_ack(struct irq_data *d)
28{
29 unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f;
30 unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5;
31
32 __raw_writel(__raw_readl(LS1X_INTC_INTCLR(n))
33 | (1 << bit), LS1X_INTC_INTCLR(n));
34}
35
36static void ls1x_irq_mask(struct irq_data *d)
37{
38 unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f;
39 unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5;
40
41 __raw_writel(__raw_readl(LS1X_INTC_INTIEN(n))
42 & ~(1 << bit), LS1X_INTC_INTIEN(n));
43}
44
45static void ls1x_irq_mask_ack(struct irq_data *d)
46{
47 unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f;
48 unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5;
49
50 __raw_writel(__raw_readl(LS1X_INTC_INTIEN(n))
51 & ~(1 << bit), LS1X_INTC_INTIEN(n));
52 __raw_writel(__raw_readl(LS1X_INTC_INTCLR(n))
53 | (1 << bit), LS1X_INTC_INTCLR(n));
54}
55
56static void ls1x_irq_unmask(struct irq_data *d)
57{
58 unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f;
59 unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5;
60
61 __raw_writel(__raw_readl(LS1X_INTC_INTIEN(n))
62 | (1 << bit), LS1X_INTC_INTIEN(n));
63}
64
65static struct irq_chip ls1x_irq_chip = {
66 .name = "LS1X-INTC",
67 .irq_ack = ls1x_irq_ack,
68 .irq_mask = ls1x_irq_mask,
69 .irq_mask_ack = ls1x_irq_mask_ack,
70 .irq_unmask = ls1x_irq_unmask,
71};
72
73static void ls1x_irq_dispatch(int n)
74{
75 u32 int_status, irq;
76
77 /* Get pending sources, masked by current enables */
78 int_status = __raw_readl(LS1X_INTC_INTISR(n)) &
79 __raw_readl(LS1X_INTC_INTIEN(n));
80
81 if (int_status) {
82 irq = LS1X_IRQ(n, __ffs(int_status));
83 do_IRQ(irq);
84 }
85}
86
87asmlinkage void plat_irq_dispatch(void)
88{
89 unsigned int pending;
90
91 pending = read_c0_cause() & read_c0_status() & ST0_IM;
92
93 if (pending & CAUSEF_IP7)
94 do_IRQ(TIMER_IRQ);
95 else if (pending & CAUSEF_IP2)
96 ls1x_irq_dispatch(0); /* INT0 */
97 else if (pending & CAUSEF_IP3)
98 ls1x_irq_dispatch(1); /* INT1 */
99 else if (pending & CAUSEF_IP4)
100 ls1x_irq_dispatch(2); /* INT2 */
101 else if (pending & CAUSEF_IP5)
102 ls1x_irq_dispatch(3); /* INT3 */
103 else if (pending & CAUSEF_IP6)
104 ls1x_irq_dispatch(4); /* INT4 */
105 else
106 spurious_interrupt();
107
108}
109
110struct irqaction cascade_irqaction = {
111 .handler = no_action,
112 .name = "cascade",
113 .flags = IRQF_NO_THREAD,
114};
115
116static void __init ls1x_irq_init(int base)
117{
118 int n;
119
120 /* Disable interrupts and clear pending,
121 * setup all IRQs as high level triggered
122 */
123 for (n = 0; n < 4; n++) {
124 __raw_writel(0x0, LS1X_INTC_INTIEN(n));
125 __raw_writel(0xffffffff, LS1X_INTC_INTCLR(n));
126 __raw_writel(0xffffffff, LS1X_INTC_INTPOL(n));
127 /* set DMA0, DMA1 and DMA2 to edge trigger */
128 __raw_writel(n ? 0x0 : 0xe000, LS1X_INTC_INTEDGE(n));
129 }
130
131
132 for (n = base; n < LS1X_IRQS; n++) {
133 irq_set_chip_and_handler(n, &ls1x_irq_chip,
134 handle_level_irq);
135 }
136
137 setup_irq(INT0_IRQ, &cascade_irqaction);
138 setup_irq(INT1_IRQ, &cascade_irqaction);
139 setup_irq(INT2_IRQ, &cascade_irqaction);
140 setup_irq(INT3_IRQ, &cascade_irqaction);
141}
142
143void __init arch_init_irq(void)
144{
145 mips_cpu_irq_init();
146 ls1x_irq_init(LS1X_IRQ_BASE);
147}
diff --git a/arch/mips/loongson1/common/platform.c b/arch/mips/loongson1/common/platform.c
new file mode 100644
index 000000000000..e92d59c4bd78
--- /dev/null
+++ b/arch/mips/loongson1/common/platform.c
@@ -0,0 +1,124 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <linux/clk.h>
11#include <linux/dma-mapping.h>
12#include <linux/err.h>
13#include <linux/phy.h>
14#include <linux/serial_8250.h>
15#include <linux/stmmac.h>
16#include <asm-generic/sizes.h>
17
18#include <loongson1.h>
19
20#define LS1X_UART(_id) \
21 { \
22 .mapbase = LS1X_UART ## _id ## _BASE, \
23 .irq = LS1X_UART ## _id ## _IRQ, \
24 .iotype = UPIO_MEM, \
25 .flags = UPF_IOREMAP | UPF_FIXED_TYPE, \
26 .type = PORT_16550A, \
27 }
28
29static struct plat_serial8250_port ls1x_serial8250_port[] = {
30 LS1X_UART(0),
31 LS1X_UART(1),
32 LS1X_UART(2),
33 LS1X_UART(3),
34 {},
35};
36
37struct platform_device ls1x_uart_device = {
38 .name = "serial8250",
39 .id = PLAT8250_DEV_PLATFORM,
40 .dev = {
41 .platform_data = ls1x_serial8250_port,
42 },
43};
44
45void __init ls1x_serial_setup(void)
46{
47 struct clk *clk;
48 struct plat_serial8250_port *p;
49
50 clk = clk_get(NULL, "dc");
51 if (IS_ERR(clk))
52 panic("unable to get dc clock, err=%ld", PTR_ERR(clk));
53
54 for (p = ls1x_serial8250_port; p->flags != 0; ++p)
55 p->uartclk = clk_get_rate(clk);
56}
57
58/* Synopsys Ethernet GMAC */
59static struct resource ls1x_eth0_resources[] = {
60 [0] = {
61 .start = LS1X_GMAC0_BASE,
62 .end = LS1X_GMAC0_BASE + SZ_64K - 1,
63 .flags = IORESOURCE_MEM,
64 },
65 [1] = {
66 .name = "macirq",
67 .start = LS1X_GMAC0_IRQ,
68 .flags = IORESOURCE_IRQ,
69 },
70};
71
72static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = {
73 .bus_id = 0,
74 .phy_mask = 0,
75};
76
77static struct plat_stmmacenet_data ls1x_eth_data = {
78 .bus_id = 0,
79 .phy_addr = -1,
80 .mdio_bus_data = &ls1x_mdio_bus_data,
81 .has_gmac = 1,
82 .tx_coe = 1,
83};
84
85struct platform_device ls1x_eth0_device = {
86 .name = "stmmaceth",
87 .id = 0,
88 .num_resources = ARRAY_SIZE(ls1x_eth0_resources),
89 .resource = ls1x_eth0_resources,
90 .dev = {
91 .platform_data = &ls1x_eth_data,
92 },
93};
94
95/* USB EHCI */
96static u64 ls1x_ehci_dmamask = DMA_BIT_MASK(32);
97
98static struct resource ls1x_ehci_resources[] = {
99 [0] = {
100 .start = LS1X_EHCI_BASE,
101 .end = LS1X_EHCI_BASE + SZ_32K - 1,
102 .flags = IORESOURCE_MEM,
103 },
104 [1] = {
105 .start = LS1X_EHCI_IRQ,
106 .flags = IORESOURCE_IRQ,
107 },
108};
109
110struct platform_device ls1x_ehci_device = {
111 .name = "ls1x-ehci",
112 .id = -1,
113 .num_resources = ARRAY_SIZE(ls1x_ehci_resources),
114 .resource = ls1x_ehci_resources,
115 .dev = {
116 .dma_mask = &ls1x_ehci_dmamask,
117 },
118};
119
120/* Real Time Clock */
121struct platform_device ls1x_rtc_device = {
122 .name = "ls1x-rtc",
123 .id = -1,
124};
diff --git a/arch/mips/loongson1/common/prom.c b/arch/mips/loongson1/common/prom.c
new file mode 100644
index 000000000000..1f8e49f9886d
--- /dev/null
+++ b/arch/mips/loongson1/common/prom.c
@@ -0,0 +1,87 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * Modified from arch/mips/pnx833x/common/prom.c.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/serial_reg.h>
13#include <asm/bootinfo.h>
14
15#include <loongson1.h>
16#include <prom.h>
17
18int prom_argc;
19char **prom_argv, **prom_envp;
20unsigned long memsize, highmemsize;
21
22char *prom_getenv(char *envname)
23{
24 char **env = prom_envp;
25 int i;
26
27 i = strlen(envname);
28
29 while (*env) {
30 if (strncmp(envname, *env, i) == 0 && *(*env+i) == '=')
31 return *env + i + 1;
32 env++;
33 }
34
35 return 0;
36}
37
38static inline unsigned long env_or_default(char *env, unsigned long dfl)
39{
40 char *str = prom_getenv(env);
41 return str ? simple_strtol(str, 0, 0) : dfl;
42}
43
44void __init prom_init_cmdline(void)
45{
46 char *c = &(arcs_cmdline[0]);
47 int i;
48
49 for (i = 1; i < prom_argc; i++) {
50 strcpy(c, prom_argv[i]);
51 c += strlen(prom_argv[i]);
52 if (i < prom_argc-1)
53 *c++ = ' ';
54 }
55 *c = 0;
56}
57
58void __init prom_init(void)
59{
60 prom_argc = fw_arg0;
61 prom_argv = (char **)fw_arg1;
62 prom_envp = (char **)fw_arg2;
63
64 prom_init_cmdline();
65
66 memsize = env_or_default("memsize", DEFAULT_MEMSIZE);
67 highmemsize = env_or_default("highmemsize", 0x0);
68}
69
70void __init prom_free_prom_memory(void)
71{
72}
73
74#define PORT(offset) (u8 *)(KSEG1ADDR(LS1X_UART0_BASE + offset))
75
76void __init prom_putchar(char c)
77{
78 int timeout;
79
80 timeout = 1024;
81
82 while (((readb(PORT(UART_LSR)) & UART_LSR_THRE) == 0)
83 && (timeout-- > 0))
84 ;
85
86 writeb(c, PORT(UART_TX));
87}
diff --git a/arch/mips/loongson1/common/reset.c b/arch/mips/loongson1/common/reset.c
new file mode 100644
index 000000000000..fb979a784eca
--- /dev/null
+++ b/arch/mips/loongson1/common/reset.c
@@ -0,0 +1,45 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <linux/io.h>
11#include <linux/pm.h>
12#include <asm/reboot.h>
13
14#include <loongson1.h>
15
16static void ls1x_restart(char *command)
17{
18 __raw_writel(0x1, LS1X_WDT_EN);
19 __raw_writel(0x5000000, LS1X_WDT_TIMER);
20 __raw_writel(0x1, LS1X_WDT_SET);
21}
22
23static void ls1x_halt(void)
24{
25 while (1) {
26 if (cpu_wait)
27 cpu_wait();
28 }
29}
30
31static void ls1x_power_off(void)
32{
33 ls1x_halt();
34}
35
36static int __init ls1x_reboot_setup(void)
37{
38 _machine_restart = ls1x_restart;
39 _machine_halt = ls1x_halt;
40 pm_power_off = ls1x_power_off;
41
42 return 0;
43}
44
45arch_initcall(ls1x_reboot_setup);
diff --git a/arch/mips/loongson1/common/setup.c b/arch/mips/loongson1/common/setup.c
new file mode 100644
index 000000000000..62128cc27e68
--- /dev/null
+++ b/arch/mips/loongson1/common/setup.c
@@ -0,0 +1,29 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <asm/bootinfo.h>
11
12#include <prom.h>
13
14void __init plat_mem_setup(void)
15{
16 add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM);
17}
18
19const char *get_system_type(void)
20{
21 unsigned int processor_id = (&current_cpu_data)->processor_id;
22
23 switch (processor_id & PRID_REV_MASK) {
24 case PRID_REV_LOONGSON1B:
25 return "LOONGSON LS1B";
26 default:
27 return "LOONGSON (unknown)";
28 }
29}
diff --git a/arch/mips/loongson1/ls1b/Makefile b/arch/mips/loongson1/ls1b/Makefile
new file mode 100644
index 000000000000..891eac482b82
--- /dev/null
+++ b/arch/mips/loongson1/ls1b/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for loongson1B based machines.
3#
4
5obj-y += board.o
diff --git a/arch/mips/loongson1/ls1b/board.c b/arch/mips/loongson1/ls1b/board.c
new file mode 100644
index 000000000000..295b1be893e3
--- /dev/null
+++ b/arch/mips/loongson1/ls1b/board.c
@@ -0,0 +1,33 @@
1/*
2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
9
10#include <platform.h>
11
12#include <linux/serial_8250.h>
13#include <loongson1.h>
14
15static struct platform_device *ls1b_platform_devices[] __initdata = {
16 &ls1x_uart_device,
17 &ls1x_eth0_device,
18 &ls1x_ehci_device,
19 &ls1x_rtc_device,
20};
21
22static int __init ls1b_platform_init(void)
23{
24 int err;
25
26 ls1x_serial_setup();
27
28 err = platform_add_devices(ls1b_platform_devices,
29 ARRAY_SIZE(ls1b_platform_devices));
30 return err;
31}
32
33arch_initcall(ls1b_platform_init);
diff --git a/arch/mips/mm/uasm.c b/arch/mips/mm/uasm.c
index 5fa185151fc8..64a28e819064 100644
--- a/arch/mips/mm/uasm.c
+++ b/arch/mips/mm/uasm.c
@@ -58,18 +58,16 @@ enum fields {
58 58
59enum opcode { 59enum opcode {
60 insn_invalid, 60 insn_invalid,
61 insn_addu, insn_addiu, insn_and, insn_andi, insn_beq, 61 insn_addiu, insn_addu, insn_and, insn_andi, insn_bbit0, insn_bbit1,
62 insn_beql, insn_bgez, insn_bgezl, insn_bltz, insn_bltzl, 62 insn_beq, insn_beql, insn_bgez, insn_bgezl, insn_bltz, insn_bltzl,
63 insn_bne, insn_cache, insn_daddu, insn_daddiu, insn_dmfc0, 63 insn_bne, insn_cache, insn_daddiu, insn_daddu, insn_dins, insn_dinsm,
64 insn_dmtc0, insn_dsll, insn_dsll32, insn_dsra, insn_dsrl, 64 insn_dmfc0, insn_dmtc0, insn_drotr, insn_drotr32, insn_dsll,
65 insn_dsrl32, insn_drotr, insn_drotr32, insn_dsubu, insn_eret, 65 insn_dsll32, insn_dsra, insn_dsrl, insn_dsrl32, insn_dsubu, insn_eret,
66 insn_j, insn_jal, insn_jr, insn_ld, insn_ll, insn_lld, 66 insn_j, insn_jal, insn_jr, insn_ld, insn_ldx, insn_ll, insn_lld,
67 insn_lui, insn_lw, insn_mfc0, insn_mtc0, insn_or, insn_ori, 67 insn_lui, insn_lw, insn_lwx, insn_mfc0, insn_mtc0, insn_or, insn_ori,
68 insn_pref, insn_rfe, insn_sc, insn_scd, insn_sd, insn_sll, 68 insn_pref, insn_rfe, insn_rotr, insn_sc, insn_scd, insn_sd, insn_sll,
69 insn_sra, insn_srl, insn_rotr, insn_subu, insn_sw, insn_tlbp, 69 insn_sra, insn_srl, insn_subu, insn_sw, insn_syscall, insn_tlbp,
70 insn_tlbr, insn_tlbwi, insn_tlbwr, insn_xor, insn_xori, 70 insn_tlbr, insn_tlbwi, insn_tlbwr, insn_xor, insn_xori,
71 insn_dins, insn_dinsm, insn_syscall, insn_bbit0, insn_bbit1,
72 insn_lwx, insn_ldx
73}; 71};
74 72
75struct insn { 73struct insn {
@@ -90,65 +88,65 @@ struct insn {
90static struct insn insn_table[] __uasminitdata = { 88static struct insn insn_table[] __uasminitdata = {
91 { insn_addiu, M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 89 { insn_addiu, M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
92 { insn_addu, M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD }, 90 { insn_addu, M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD },
93 { insn_and, M(spec_op, 0, 0, 0, 0, and_op), RS | RT | RD },
94 { insn_andi, M(andi_op, 0, 0, 0, 0, 0), RS | RT | UIMM }, 91 { insn_andi, M(andi_op, 0, 0, 0, 0, 0), RS | RT | UIMM },
95 { insn_beq, M(beq_op, 0, 0, 0, 0, 0), RS | RT | BIMM }, 92 { insn_and, M(spec_op, 0, 0, 0, 0, and_op), RS | RT | RD },
93 { insn_bbit0, M(lwc2_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
94 { insn_bbit1, M(swc2_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
96 { insn_beql, M(beql_op, 0, 0, 0, 0, 0), RS | RT | BIMM }, 95 { insn_beql, M(beql_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
97 { insn_bgez, M(bcond_op, 0, bgez_op, 0, 0, 0), RS | BIMM }, 96 { insn_beq, M(beq_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
98 { insn_bgezl, M(bcond_op, 0, bgezl_op, 0, 0, 0), RS | BIMM }, 97 { insn_bgezl, M(bcond_op, 0, bgezl_op, 0, 0, 0), RS | BIMM },
99 { insn_bltz, M(bcond_op, 0, bltz_op, 0, 0, 0), RS | BIMM }, 98 { insn_bgez, M(bcond_op, 0, bgez_op, 0, 0, 0), RS | BIMM },
100 { insn_bltzl, M(bcond_op, 0, bltzl_op, 0, 0, 0), RS | BIMM }, 99 { insn_bltzl, M(bcond_op, 0, bltzl_op, 0, 0, 0), RS | BIMM },
100 { insn_bltz, M(bcond_op, 0, bltz_op, 0, 0, 0), RS | BIMM },
101 { insn_bne, M(bne_op, 0, 0, 0, 0, 0), RS | RT | BIMM }, 101 { insn_bne, M(bne_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
102 { insn_cache, M(cache_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 102 { insn_cache, M(cache_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
103 { insn_daddiu, M(daddiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 103 { insn_daddiu, M(daddiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
104 { insn_daddu, M(spec_op, 0, 0, 0, 0, daddu_op), RS | RT | RD }, 104 { insn_daddu, M(spec_op, 0, 0, 0, 0, daddu_op), RS | RT | RD },
105 { insn_dinsm, M(spec3_op, 0, 0, 0, 0, dinsm_op), RS | RT | RD | RE },
106 { insn_dins, M(spec3_op, 0, 0, 0, 0, dins_op), RS | RT | RD | RE },
105 { insn_dmfc0, M(cop0_op, dmfc_op, 0, 0, 0, 0), RT | RD | SET}, 107 { insn_dmfc0, M(cop0_op, dmfc_op, 0, 0, 0, 0), RT | RD | SET},
106 { insn_dmtc0, M(cop0_op, dmtc_op, 0, 0, 0, 0), RT | RD | SET}, 108 { insn_dmtc0, M(cop0_op, dmtc_op, 0, 0, 0, 0), RT | RD | SET},
107 { insn_dsll, M(spec_op, 0, 0, 0, 0, dsll_op), RT | RD | RE }, 109 { insn_drotr32, M(spec_op, 1, 0, 0, 0, dsrl32_op), RT | RD | RE },
110 { insn_drotr, M(spec_op, 1, 0, 0, 0, dsrl_op), RT | RD | RE },
108 { insn_dsll32, M(spec_op, 0, 0, 0, 0, dsll32_op), RT | RD | RE }, 111 { insn_dsll32, M(spec_op, 0, 0, 0, 0, dsll32_op), RT | RD | RE },
112 { insn_dsll, M(spec_op, 0, 0, 0, 0, dsll_op), RT | RD | RE },
109 { insn_dsra, M(spec_op, 0, 0, 0, 0, dsra_op), RT | RD | RE }, 113 { insn_dsra, M(spec_op, 0, 0, 0, 0, dsra_op), RT | RD | RE },
110 { insn_dsrl, M(spec_op, 0, 0, 0, 0, dsrl_op), RT | RD | RE },
111 { insn_dsrl32, M(spec_op, 0, 0, 0, 0, dsrl32_op), RT | RD | RE }, 114 { insn_dsrl32, M(spec_op, 0, 0, 0, 0, dsrl32_op), RT | RD | RE },
112 { insn_drotr, M(spec_op, 1, 0, 0, 0, dsrl_op), RT | RD | RE }, 115 { insn_dsrl, M(spec_op, 0, 0, 0, 0, dsrl_op), RT | RD | RE },
113 { insn_drotr32, M(spec_op, 1, 0, 0, 0, dsrl32_op), RT | RD | RE },
114 { insn_dsubu, M(spec_op, 0, 0, 0, 0, dsubu_op), RS | RT | RD }, 116 { insn_dsubu, M(spec_op, 0, 0, 0, 0, dsubu_op), RS | RT | RD },
115 { insn_eret, M(cop0_op, cop_op, 0, 0, 0, eret_op), 0 }, 117 { insn_eret, M(cop0_op, cop_op, 0, 0, 0, eret_op), 0 },
116 { insn_j, M(j_op, 0, 0, 0, 0, 0), JIMM },
117 { insn_jal, M(jal_op, 0, 0, 0, 0, 0), JIMM }, 118 { insn_jal, M(jal_op, 0, 0, 0, 0, 0), JIMM },
119 { insn_j, M(j_op, 0, 0, 0, 0, 0), JIMM },
118 { insn_jr, M(spec_op, 0, 0, 0, 0, jr_op), RS }, 120 { insn_jr, M(spec_op, 0, 0, 0, 0, jr_op), RS },
119 { insn_ld, M(ld_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 121 { insn_ld, M(ld_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
120 { insn_ll, M(ll_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 122 { insn_ldx, M(spec3_op, 0, 0, 0, ldx_op, lx_op), RS | RT | RD },
121 { insn_lld, M(lld_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 123 { insn_lld, M(lld_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
124 { insn_ll, M(ll_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
122 { insn_lui, M(lui_op, 0, 0, 0, 0, 0), RT | SIMM }, 125 { insn_lui, M(lui_op, 0, 0, 0, 0, 0), RT | SIMM },
123 { insn_lw, M(lw_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 126 { insn_lw, M(lw_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
127 { insn_lwx, M(spec3_op, 0, 0, 0, lwx_op, lx_op), RS | RT | RD },
124 { insn_mfc0, M(cop0_op, mfc_op, 0, 0, 0, 0), RT | RD | SET}, 128 { insn_mfc0, M(cop0_op, mfc_op, 0, 0, 0, 0), RT | RD | SET},
125 { insn_mtc0, M(cop0_op, mtc_op, 0, 0, 0, 0), RT | RD | SET}, 129 { insn_mtc0, M(cop0_op, mtc_op, 0, 0, 0, 0), RT | RD | SET},
126 { insn_or, M(spec_op, 0, 0, 0, 0, or_op), RS | RT | RD },
127 { insn_ori, M(ori_op, 0, 0, 0, 0, 0), RS | RT | UIMM }, 130 { insn_ori, M(ori_op, 0, 0, 0, 0, 0), RS | RT | UIMM },
131 { insn_or, M(spec_op, 0, 0, 0, 0, or_op), RS | RT | RD },
128 { insn_pref, M(pref_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 132 { insn_pref, M(pref_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
129 { insn_rfe, M(cop0_op, cop_op, 0, 0, 0, rfe_op), 0 }, 133 { insn_rfe, M(cop0_op, cop_op, 0, 0, 0, rfe_op), 0 },
130 { insn_sc, M(sc_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 134 { insn_rotr, M(spec_op, 1, 0, 0, 0, srl_op), RT | RD | RE },
131 { insn_scd, M(scd_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 135 { insn_scd, M(scd_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
136 { insn_sc, M(sc_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
132 { insn_sd, M(sd_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 137 { insn_sd, M(sd_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
133 { insn_sll, M(spec_op, 0, 0, 0, 0, sll_op), RT | RD | RE }, 138 { insn_sll, M(spec_op, 0, 0, 0, 0, sll_op), RT | RD | RE },
134 { insn_sra, M(spec_op, 0, 0, 0, 0, sra_op), RT | RD | RE }, 139 { insn_sra, M(spec_op, 0, 0, 0, 0, sra_op), RT | RD | RE },
135 { insn_srl, M(spec_op, 0, 0, 0, 0, srl_op), RT | RD | RE }, 140 { insn_srl, M(spec_op, 0, 0, 0, 0, srl_op), RT | RD | RE },
136 { insn_rotr, M(spec_op, 1, 0, 0, 0, srl_op), RT | RD | RE },
137 { insn_subu, M(spec_op, 0, 0, 0, 0, subu_op), RS | RT | RD }, 141 { insn_subu, M(spec_op, 0, 0, 0, 0, subu_op), RS | RT | RD },
138 { insn_sw, M(sw_op, 0, 0, 0, 0, 0), RS | RT | SIMM }, 142 { insn_sw, M(sw_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
143 { insn_syscall, M(spec_op, 0, 0, 0, 0, syscall_op), SCIMM},
139 { insn_tlbp, M(cop0_op, cop_op, 0, 0, 0, tlbp_op), 0 }, 144 { insn_tlbp, M(cop0_op, cop_op, 0, 0, 0, tlbp_op), 0 },
140 { insn_tlbr, M(cop0_op, cop_op, 0, 0, 0, tlbr_op), 0 }, 145 { insn_tlbr, M(cop0_op, cop_op, 0, 0, 0, tlbr_op), 0 },
141 { insn_tlbwi, M(cop0_op, cop_op, 0, 0, 0, tlbwi_op), 0 }, 146 { insn_tlbwi, M(cop0_op, cop_op, 0, 0, 0, tlbwi_op), 0 },
142 { insn_tlbwr, M(cop0_op, cop_op, 0, 0, 0, tlbwr_op), 0 }, 147 { insn_tlbwr, M(cop0_op, cop_op, 0, 0, 0, tlbwr_op), 0 },
143 { insn_xor, M(spec_op, 0, 0, 0, 0, xor_op), RS | RT | RD },
144 { insn_xori, M(xori_op, 0, 0, 0, 0, 0), RS | RT | UIMM }, 148 { insn_xori, M(xori_op, 0, 0, 0, 0, 0), RS | RT | UIMM },
145 { insn_dins, M(spec3_op, 0, 0, 0, 0, dins_op), RS | RT | RD | RE }, 149 { insn_xor, M(spec_op, 0, 0, 0, 0, xor_op), RS | RT | RD },
146 { insn_dinsm, M(spec3_op, 0, 0, 0, 0, dinsm_op), RS | RT | RD | RE },
147 { insn_syscall, M(spec_op, 0, 0, 0, 0, syscall_op), SCIMM},
148 { insn_bbit0, M(lwc2_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
149 { insn_bbit1, M(swc2_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
150 { insn_lwx, M(spec3_op, 0, 0, 0, lwx_op, lx_op), RS | RT | RD },
151 { insn_ldx, M(spec3_op, 0, 0, 0, ldx_op, lx_op), RS | RT | RD },
152 { insn_invalid, 0, 0 } 150 { insn_invalid, 0, 0 }
153}; 151};
154 152
diff --git a/arch/mips/netlogic/common/earlycons.c b/arch/mips/netlogic/common/earlycons.c
index f193f7b3bd81..1902fa22d277 100644
--- a/arch/mips/netlogic/common/earlycons.c
+++ b/arch/mips/netlogic/common/earlycons.c
@@ -54,7 +54,7 @@ void prom_putchar(char c)
54#elif defined(CONFIG_CPU_XLR) 54#elif defined(CONFIG_CPU_XLR)
55 uartbase = nlm_mmio_base(NETLOGIC_IO_UART_0_OFFSET); 55 uartbase = nlm_mmio_base(NETLOGIC_IO_UART_0_OFFSET);
56#endif 56#endif
57 while (nlm_read_reg(uartbase, UART_LSR) == 0) 57 while ((nlm_read_reg(uartbase, UART_LSR) & UART_LSR_THRE) == 0)
58 ; 58 ;
59 nlm_write_reg(uartbase, UART_TX, c); 59 nlm_write_reg(uartbase, UART_TX, c);
60} 60}
diff --git a/arch/mips/netlogic/common/smpboot.S b/arch/mips/netlogic/common/smpboot.S
index c138b1a6dec3..a13355cc97eb 100644
--- a/arch/mips/netlogic/common/smpboot.S
+++ b/arch/mips/netlogic/common/smpboot.S
@@ -54,28 +54,68 @@
54 XLP_IO_SYS_OFFSET(node) + XLP_IO_PCI_HDRSZ + \ 54 XLP_IO_SYS_OFFSET(node) + XLP_IO_PCI_HDRSZ + \
55 SYS_CPU_NONCOHERENT_MODE * 4 55 SYS_CPU_NONCOHERENT_MODE * 4
56 56
57.macro __config_lsu 57#define XLP_AX_WORKAROUND /* enable Ax silicon workarounds */
58 li t0, LSU_DEFEATURE
59 mfcr t1, t0
60 58
61 lui t2, 0x4080 /* Enable Unaligned Access, L2HPE */ 59/* Enable XLP features and workarounds in the LSU */
62 or t1, t1, t2 60.macro xlp_config_lsu
63 li t2, ~0xe /* S1RCM */ 61 li t0, LSU_DEFEATURE
62 mfcr t1, t0
63
64 lui t2, 0x4080 /* Enable Unaligned Access, L2HPE */
65 or t1, t1, t2
66#ifdef XLP_AX_WORKAROUND
67 li t2, ~0xe /* S1RCM */
64 and t1, t1, t2 68 and t1, t1, t2
65 mtcr t1, t0 69#endif
70 mtcr t1, t0
66 71
67 li t0, SCHED_DEFEATURE 72#ifdef XLP_AX_WORKAROUND
68 lui t1, 0x0100 /* Experimental: Disable BRU accepting ALU ops */ 73 li t0, SCHED_DEFEATURE
69 mtcr t1, t0 74 lui t1, 0x0100 /* Disable BRU accepting ALU ops */
75 mtcr t1, t0
76#endif
77.endm
78
79/*
80 * This is the code that will be copied to the reset entry point for
81 * XLR and XLP. The XLP cores start here when they are woken up. This
82 * is also the NMI entry point.
83 */
84.macro xlp_flush_l1_dcache
85 li t0, LSU_DEBUG_DATA0
86 li t1, LSU_DEBUG_ADDR
87 li t2, 0 /* index */
88 li t3, 0x1000 /* loop count */
891:
90 sll v0, t2, 5
91 mtcr zero, t0
92 ori v1, v0, 0x3 /* way0 | write_enable | write_active */
93 mtcr v1, t1
942:
95 mfcr v1, t1
96 andi v1, 0x1 /* wait for write_active == 0 */
97 bnez v1, 2b
98 nop
99 mtcr zero, t0
100 ori v1, v0, 0x7 /* way1 | write_enable | write_active */
101 mtcr v1, t1
1023:
103 mfcr v1, t1
104 andi v1, 0x1 /* wait for write_active == 0 */
105 bnez v1, 3b
106 nop
107 addi t2, 1
108 bne t3, t2, 1b
109 nop
70.endm 110.endm
71 111
72/* 112/*
73 * The cores can come start when they are woken up. This is also the NMI 113 * The cores can come start when they are woken up. This is also the NMI
74 * entry, so check that first. 114 * entry, so check that first.
75 * 115 *
76 * The data corresponding to reset is stored at RESET_DATA_PHYS location, 116 * The data corresponding to reset/NMI is stored at RESET_DATA_PHYS
77 * this will have the thread mask (used when core is woken up) and the 117 * location, this will have the thread mask (used when core is woken up)
78 * current NMI handler in case we reached here for an NMI. 118 * and the current NMI handler in case we reached here for an NMI.
79 * 119 *
80 * When a core or thread is newly woken up, it loops in a 'wait'. When 120 * When a core or thread is newly woken up, it loops in a 'wait'. When
81 * the CPU really needs waking up, we send an NMI to it, with the NMI 121 * the CPU really needs waking up, we send an NMI to it, with the NMI
@@ -89,12 +129,12 @@
89FEXPORT(nlm_reset_entry) 129FEXPORT(nlm_reset_entry)
90 dmtc0 k0, $22, 6 130 dmtc0 k0, $22, 6
91 dmtc0 k1, $22, 7 131 dmtc0 k1, $22, 7
92 mfc0 k0, CP0_STATUS 132 mfc0 k0, CP0_STATUS
93 li k1, 0x80000 133 li k1, 0x80000
94 and k1, k0, k1 134 and k1, k0, k1
95 beqz k1, 1f /* go to real reset entry */ 135 beqz k1, 1f /* go to real reset entry */
96 nop 136 nop
97 li k1, CKSEG1ADDR(RESET_DATA_PHYS) /* NMI */ 137 li k1, CKSEG1ADDR(RESET_DATA_PHYS) /* NMI */
98 ld k0, BOOT_NMI_HANDLER(k1) 138 ld k0, BOOT_NMI_HANDLER(k1)
99 jr k0 139 jr k0
100 nop 140 nop
@@ -114,21 +154,25 @@ FEXPORT(nlm_reset_entry)
114 li t2, SYS_CPU_COHERENT_BASE(0) 154 li t2, SYS_CPU_COHERENT_BASE(0)
115 add t2, t2, t3 /* t2 <- SYS offset for node */ 155 add t2, t2, t3 /* t2 <- SYS offset for node */
116 lw t1, 0(t2) 156 lw t1, 0(t2)
117 and t1, t1, t0 157 and t1, t1, t0
118 sw t1, 0(t2) 158 sw t1, 0(t2)
119 159
120 /* read back to ensure complete */ 160 /* read back to ensure complete */
121 lw t1, 0(t2) 161 lw t1, 0(t2)
122 sync 162 sync
123 163
124 /* Configure LSU on Non-0 Cores. */ 164 /* Configure LSU on Non-0 Cores. */
125 __config_lsu 165 xlp_config_lsu
166 /* FALL THROUGH */
126 167
127/* 168/*
128 * Wake up sibling threads from the initial thread in 169 * Wake up sibling threads from the initial thread in
129 * a core. 170 * a core.
130 */ 171 */
131EXPORT(nlm_boot_siblings) 172EXPORT(nlm_boot_siblings)
173 /* core L1D flush before enable threads */
174 xlp_flush_l1_dcache
175 /* Enable hw threads by writing to MAP_THREADMODE of the core */
132 li t0, CKSEG1ADDR(RESET_DATA_PHYS) 176 li t0, CKSEG1ADDR(RESET_DATA_PHYS)
133 lw t1, BOOT_THREAD_MODE(t0) /* t1 <- thread mode */ 177 lw t1, BOOT_THREAD_MODE(t0) /* t1 <- thread mode */
134 li t0, ((CPU_BLOCKID_MAP << 8) | MAP_THREADMODE) 178 li t0, ((CPU_BLOCKID_MAP << 8) | MAP_THREADMODE)
@@ -139,31 +183,28 @@ EXPORT(nlm_boot_siblings)
139 /* 183 /*
140 * The new hardware thread starts at the next instruction 184 * The new hardware thread starts at the next instruction
141 * For all the cases other than core 0 thread 0, we will 185 * For all the cases other than core 0 thread 0, we will
142 * jump to the secondary wait function. 186 * jump to the secondary wait function.
143 */ 187 */
144 mfc0 v0, CP0_EBASE, 1 188 mfc0 v0, CP0_EBASE, 1
145 andi v0, 0x7f /* v0 <- node/core */ 189 andi v0, 0x7f /* v0 <- node/core */
146 190
147#if 1 191 /* Init MMU in the first thread after changing THREAD_MODE
148 /* A0 errata - Write MMU_SETUP after changing thread mode register. */ 192 * register (Ax Errata?)
193 */
149 andi v1, v0, 0x3 /* v1 <- thread id */ 194 andi v1, v0, 0x3 /* v1 <- thread id */
150 bnez v1, 2f 195 bnez v1, 2f
151 nop 196 nop
152 197
153 li t0, MMU_SETUP 198 li t0, MMU_SETUP
154 li t1, 0 199 li t1, 0
155 mtcr t1, t0 200 mtcr t1, t0
156 ehb 201 _ehb
157#endif
158 202
1592: beqz v0, 4f 2032: beqz v0, 4f /* boot cpu (cpuid == 0)? */
160 nop 204 nop
161 205
162 /* setup status reg */ 206 /* setup status reg */
163 mfc0 t1, CP0_STATUS 207 move t1, zero
164 li t0, ST0_BEV
165 or t1, t0
166 xor t1, t0
167#ifdef CONFIG_64BIT 208#ifdef CONFIG_64BIT
168 ori t1, ST0_KX 209 ori t1, ST0_KX
169#endif 210#endif
@@ -183,9 +224,9 @@ EXPORT(nlm_boot_siblings)
183 * For the boot CPU, we have to restore registers and 224 * For the boot CPU, we have to restore registers and
184 * return 225 * return
185 */ 226 */
1864: dmfc0 t0, $4, 2 /* restore SP from UserLocal */ 2274: dmfc0 t0, $4, 2 /* restore SP from UserLocal */
187 li t1, 0xfadebeef 228 li t1, 0xfadebeef
188 dmtc0 t1, $4, 2 /* restore SP from UserLocal */ 229 dmtc0 t1, $4, 2 /* restore SP from UserLocal */
189 PTR_SUBU sp, t0, PT_SIZE 230 PTR_SUBU sp, t0, PT_SIZE
190 RESTORE_ALL 231 RESTORE_ALL
191 jr ra 232 jr ra
@@ -193,7 +234,7 @@ EXPORT(nlm_boot_siblings)
193EXPORT(nlm_reset_entry_end) 234EXPORT(nlm_reset_entry_end)
194 235
195FEXPORT(xlp_boot_core0_siblings) /* "Master" cpu starts from here */ 236FEXPORT(xlp_boot_core0_siblings) /* "Master" cpu starts from here */
196 __config_lsu 237 xlp_config_lsu
197 dmtc0 sp, $4, 2 /* SP saved in UserLocal */ 238 dmtc0 sp, $4, 2 /* SP saved in UserLocal */
198 SAVE_ALL 239 SAVE_ALL
199 sync 240 sync
@@ -210,6 +251,12 @@ FEXPORT(xlp_boot_core0_siblings) /* "Master" cpu starts from here */
210 251
211 __CPUINIT 252 __CPUINIT
212NESTED(nlm_boot_secondary_cpus, 16, sp) 253NESTED(nlm_boot_secondary_cpus, 16, sp)
254 /* Initialize CP0 Status */
255 move t1, zero
256#ifdef CONFIG_64BIT
257 ori t1, ST0_KX
258#endif
259 mtc0 t1, CP0_STATUS
213 PTR_LA t1, nlm_next_sp 260 PTR_LA t1, nlm_next_sp
214 PTR_L sp, 0(t1) 261 PTR_L sp, 0(t1)
215 PTR_LA t1, nlm_next_gp 262 PTR_LA t1, nlm_next_gp
@@ -234,36 +281,36 @@ END(nlm_boot_secondary_cpus)
234 */ 281 */
235 __CPUINIT 282 __CPUINIT
236NESTED(nlm_rmiboot_preboot, 16, sp) 283NESTED(nlm_rmiboot_preboot, 16, sp)
237 mfc0 t0, $15, 1 # read ebase 284 mfc0 t0, $15, 1 /* read ebase */
238 andi t0, 0x1f # t0 has the processor_id() 285 andi t0, 0x1f /* t0 has the processor_id() */
239 andi t2, t0, 0x3 # thread no 286 andi t2, t0, 0x3 /* thread num */
240 sll t0, 2 # offset in cpu array 287 sll t0, 2 /* offset in cpu array */
241 288
242 PTR_LA t1, nlm_cpu_ready # mark CPU ready 289 PTR_LA t1, nlm_cpu_ready /* mark CPU ready */
243 PTR_ADDU t1, t0 290 PTR_ADDU t1, t0
244 li t3, 1 291 li t3, 1
245 sw t3, 0(t1) 292 sw t3, 0(t1)
246 293
247 bnez t2, 1f # skip thread programming 294 bnez t2, 1f /* skip thread programming */
248 nop # for non zero hw threads 295 nop /* for thread id != 0 */
249 296
250 /* 297 /*
251 * MMU setup only for first thread in core 298 * XLR MMU setup only for first thread in core
252 */ 299 */
253 li t0, 0x400 300 li t0, 0x400
254 mfcr t1, t0 301 mfcr t1, t0
255 li t2, 6 # XLR thread mode mask 302 li t2, 6 /* XLR thread mode mask */
256 nor t3, t2, zero 303 nor t3, t2, zero
257 and t2, t1, t2 # t2 - current thread mode 304 and t2, t1, t2 /* t2 - current thread mode */
258 li v0, CKSEG1ADDR(RESET_DATA_PHYS) 305 li v0, CKSEG1ADDR(RESET_DATA_PHYS)
259 lw v1, BOOT_THREAD_MODE(v0) # v1 - new thread mode 306 lw v1, BOOT_THREAD_MODE(v0) /* v1 - new thread mode */
260 sll v1, 1 307 sll v1, 1
261 beq v1, t2, 1f # same as request value 308 beq v1, t2, 1f /* same as request value */
262 nop # nothing to do */ 309 nop /* nothing to do */
263 310
264 and t2, t1, t3 # mask out old thread mode 311 and t2, t1, t3 /* mask out old thread mode */
265 or t1, t2, v1 # put in new value 312 or t1, t2, v1 /* put in new value */
266 mtcr t1, t0 # update core control 313 mtcr t1, t0 /* update core control */
267 314
2681: wait 3151: wait
269 j 1b 316 j 1b
diff --git a/arch/mips/netlogic/xlp/Makefile b/arch/mips/netlogic/xlp/Makefile
index b93ed83474ec..6b4b972218f0 100644
--- a/arch/mips/netlogic/xlp/Makefile
+++ b/arch/mips/netlogic/xlp/Makefile
@@ -1,2 +1,4 @@
1obj-y += setup.o platform.o nlm_hal.o 1obj-y += setup.o platform.o nlm_hal.o
2obj-$(CONFIG_OF) += of.o
2obj-$(CONFIG_SMP) += wakeup.o 3obj-$(CONFIG_SMP) += wakeup.o
4obj-$(CONFIG_USB) += usb-init.o
diff --git a/arch/mips/netlogic/xlp/nlm_hal.c b/arch/mips/netlogic/xlp/nlm_hal.c
index 9428e7125fed..6c65ac701912 100644
--- a/arch/mips/netlogic/xlp/nlm_hal.c
+++ b/arch/mips/netlogic/xlp/nlm_hal.c
@@ -69,6 +69,32 @@ int nlm_irq_to_irt(int irq)
69 return PIC_IRT_UART_0_INDEX; 69 return PIC_IRT_UART_0_INDEX;
70 case PIC_UART_1_IRQ: 70 case PIC_UART_1_IRQ:
71 return PIC_IRT_UART_1_INDEX; 71 return PIC_IRT_UART_1_INDEX;
72 case PIC_PCIE_LINK_0_IRQ:
73 return PIC_IRT_PCIE_LINK_0_INDEX;
74 case PIC_PCIE_LINK_1_IRQ:
75 return PIC_IRT_PCIE_LINK_1_INDEX;
76 case PIC_PCIE_LINK_2_IRQ:
77 return PIC_IRT_PCIE_LINK_2_INDEX;
78 case PIC_PCIE_LINK_3_IRQ:
79 return PIC_IRT_PCIE_LINK_3_INDEX;
80 case PIC_EHCI_0_IRQ:
81 return PIC_IRT_EHCI_0_INDEX;
82 case PIC_EHCI_1_IRQ:
83 return PIC_IRT_EHCI_1_INDEX;
84 case PIC_OHCI_0_IRQ:
85 return PIC_IRT_OHCI_0_INDEX;
86 case PIC_OHCI_1_IRQ:
87 return PIC_IRT_OHCI_1_INDEX;
88 case PIC_OHCI_2_IRQ:
89 return PIC_IRT_OHCI_2_INDEX;
90 case PIC_OHCI_3_IRQ:
91 return PIC_IRT_OHCI_3_INDEX;
92 case PIC_MMC_IRQ:
93 return PIC_IRT_MMC_INDEX;
94 case PIC_I2C_0_IRQ:
95 return PIC_IRT_I2C_0_INDEX;
96 case PIC_I2C_1_IRQ:
97 return PIC_IRT_I2C_1_INDEX;
72 default: 98 default:
73 return -1; 99 return -1;
74 } 100 }
@@ -81,6 +107,32 @@ int nlm_irt_to_irq(int irt)
81 return PIC_UART_0_IRQ; 107 return PIC_UART_0_IRQ;
82 case PIC_IRT_UART_1_INDEX: 108 case PIC_IRT_UART_1_INDEX:
83 return PIC_UART_1_IRQ; 109 return PIC_UART_1_IRQ;
110 case PIC_IRT_PCIE_LINK_0_INDEX:
111 return PIC_PCIE_LINK_0_IRQ;
112 case PIC_IRT_PCIE_LINK_1_INDEX:
113 return PIC_PCIE_LINK_1_IRQ;
114 case PIC_IRT_PCIE_LINK_2_INDEX:
115 return PIC_PCIE_LINK_2_IRQ;
116 case PIC_IRT_PCIE_LINK_3_INDEX:
117 return PIC_PCIE_LINK_3_IRQ;
118 case PIC_IRT_EHCI_0_INDEX:
119 return PIC_EHCI_0_IRQ;
120 case PIC_IRT_EHCI_1_INDEX:
121 return PIC_EHCI_1_IRQ;
122 case PIC_IRT_OHCI_0_INDEX:
123 return PIC_OHCI_0_IRQ;
124 case PIC_IRT_OHCI_1_INDEX:
125 return PIC_OHCI_1_IRQ;
126 case PIC_IRT_OHCI_2_INDEX:
127 return PIC_OHCI_2_IRQ;
128 case PIC_IRT_OHCI_3_INDEX:
129 return PIC_OHCI_3_IRQ;
130 case PIC_IRT_MMC_INDEX:
131 return PIC_MMC_IRQ;
132 case PIC_IRT_I2C_0_INDEX:
133 return PIC_I2C_0_IRQ;
134 case PIC_IRT_I2C_1_INDEX:
135 return PIC_I2C_1_IRQ;
84 default: 136 default:
85 return -1; 137 return -1;
86 } 138 }
diff --git a/arch/mips/netlogic/xlp/of.c b/arch/mips/netlogic/xlp/of.c
new file mode 100644
index 000000000000..8e3921c0c201
--- /dev/null
+++ b/arch/mips/netlogic/xlp/of.c
@@ -0,0 +1,34 @@
1#include <linux/bootmem.h>
2#include <linux/init.h>
3#include <linux/io.h>
4#include <linux/of_fdt.h>
5#include <asm/byteorder.h>
6
7static int __init reserve_mem_mach(unsigned long addr, unsigned long size)
8{
9 return reserve_bootmem(addr, size, BOOTMEM_DEFAULT);
10}
11
12void __init free_mem_mach(unsigned long addr, unsigned long size)
13{
14 return free_bootmem(addr, size);
15}
16
17void __init device_tree_init(void)
18{
19 unsigned long base, size;
20
21 if (!initial_boot_params)
22 return;
23
24 base = virt_to_phys((void *)initial_boot_params);
25 size = be32_to_cpu(initial_boot_params->totalsize);
26
27 /* Before we do anything, lets reserve the dt blob */
28 reserve_mem_mach(base, size);
29
30 unflatten_device_tree();
31
32 /* free the space reserved for the dt blob */
33 free_mem_mach(base, size);
34}
diff --git a/arch/mips/netlogic/xlp/platform.c b/arch/mips/netlogic/xlp/platform.c
index 1f5e4cba891d..2c510d585447 100644
--- a/arch/mips/netlogic/xlp/platform.c
+++ b/arch/mips/netlogic/xlp/platform.c
@@ -53,7 +53,7 @@
53 53
54static unsigned int nlm_xlp_uart_in(struct uart_port *p, int offset) 54static unsigned int nlm_xlp_uart_in(struct uart_port *p, int offset)
55{ 55{
56 return nlm_read_reg(p->iobase, offset); 56 return nlm_read_reg(p->iobase, offset);
57} 57}
58 58
59static void nlm_xlp_uart_out(struct uart_port *p, int offset, int value) 59static void nlm_xlp_uart_out(struct uart_port *p, int offset, int value)
diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c
index b3df7c2aad1e..3dec9f28b65b 100644
--- a/arch/mips/netlogic/xlp/setup.c
+++ b/arch/mips/netlogic/xlp/setup.c
@@ -41,6 +41,8 @@
41#include <asm/bootinfo.h> 41#include <asm/bootinfo.h>
42 42
43#include <linux/of_fdt.h> 43#include <linux/of_fdt.h>
44#include <linux/of_platform.h>
45#include <linux/of_device.h>
44 46
45#include <asm/netlogic/haldefs.h> 47#include <asm/netlogic/haldefs.h>
46#include <asm/netlogic/common.h> 48#include <asm/netlogic/common.h>
@@ -109,3 +111,17 @@ void __init prom_init(void)
109 register_smp_ops(&nlm_smp_ops); 111 register_smp_ops(&nlm_smp_ops);
110#endif 112#endif
111} 113}
114
115static struct of_device_id __initdata xlp_ids[] = {
116 { .compatible = "simple-bus", },
117 {},
118};
119
120int __init xlp8xx_ds_publish_devices(void)
121{
122 if (!of_have_populated_dt())
123 return 0;
124 return of_platform_bus_probe(NULL, xlp_ids, NULL);
125}
126
127device_initcall(xlp8xx_ds_publish_devices);
diff --git a/arch/mips/netlogic/xlp/usb-init.c b/arch/mips/netlogic/xlp/usb-init.c
new file mode 100644
index 000000000000..dbe083a93538
--- /dev/null
+++ b/arch/mips/netlogic/xlp/usb-init.c
@@ -0,0 +1,124 @@
1/*
2 * Copyright (c) 2003-2012 Broadcom Corporation
3 * All Rights Reserved
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the Broadcom
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#include <linux/dma-mapping.h>
36#include <linux/kernel.h>
37#include <linux/delay.h>
38#include <linux/init.h>
39#include <linux/pci.h>
40#include <linux/platform_device.h>
41
42#include <asm/netlogic/haldefs.h>
43#include <asm/netlogic/xlp-hal/iomap.h>
44#include <asm/netlogic/xlp-hal/xlp.h>
45#include <asm/netlogic/xlp-hal/usb.h>
46
47static void nlm_usb_intr_en(int node, int port)
48{
49 uint32_t val;
50 uint64_t port_addr;
51
52 port_addr = nlm_get_usb_regbase(node, port);
53 val = nlm_read_usb_reg(port_addr, USB_INT_EN);
54 val = USB_CTRL_INTERRUPT_EN | USB_OHCI_INTERRUPT_EN |
55 USB_OHCI_INTERRUPT1_EN | USB_CTRL_INTERRUPT_EN |
56 USB_OHCI_INTERRUPT_EN | USB_OHCI_INTERRUPT2_EN;
57 nlm_write_usb_reg(port_addr, USB_INT_EN, val);
58}
59
60static void nlm_usb_hw_reset(int node, int port)
61{
62 uint64_t port_addr;
63 uint32_t val;
64
65 /* reset USB phy */
66 port_addr = nlm_get_usb_regbase(node, port);
67 val = nlm_read_usb_reg(port_addr, USB_PHY_0);
68 val &= ~(USB_PHY_RESET | USB_PHY_PORT_RESET_0 | USB_PHY_PORT_RESET_1);
69 nlm_write_usb_reg(port_addr, USB_PHY_0, val);
70
71 mdelay(100);
72 val = nlm_read_usb_reg(port_addr, USB_CTL_0);
73 val &= ~(USB_CONTROLLER_RESET);
74 val |= 0x4;
75 nlm_write_usb_reg(port_addr, USB_CTL_0, val);
76}
77
78static int __init nlm_platform_usb_init(void)
79{
80 pr_info("Initializing USB Interface\n");
81 nlm_usb_hw_reset(0, 0);
82 nlm_usb_hw_reset(0, 3);
83
84 /* Enable PHY interrupts */
85 nlm_usb_intr_en(0, 0);
86 nlm_usb_intr_en(0, 3);
87
88 return 0;
89}
90
91arch_initcall(nlm_platform_usb_init);
92
93static u64 xlp_usb_dmamask = ~(u32)0;
94
95/* Fixup the IRQ for USB devices which is exist on XLP SOC PCIE bus */
96static void nlm_usb_fixup_final(struct pci_dev *dev)
97{
98 dev->dev.dma_mask = &xlp_usb_dmamask;
99 dev->dev.coherent_dma_mask = DMA_BIT_MASK(64);
100 switch (dev->devfn) {
101 case 0x10:
102 dev->irq = PIC_EHCI_0_IRQ;
103 break;
104 case 0x11:
105 dev->irq = PIC_OHCI_0_IRQ;
106 break;
107 case 0x12:
108 dev->irq = PIC_OHCI_1_IRQ;
109 break;
110 case 0x13:
111 dev->irq = PIC_EHCI_1_IRQ;
112 break;
113 case 0x14:
114 dev->irq = PIC_OHCI_2_IRQ;
115 break;
116 case 0x15:
117 dev->irq = PIC_OHCI_3_IRQ;
118 break;
119 }
120}
121DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_NETLOGIC, PCI_DEVICE_ID_NLM_EHCI,
122 nlm_usb_fixup_final);
123DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_NETLOGIC, PCI_DEVICE_ID_NLM_OHCI,
124 nlm_usb_fixup_final);
diff --git a/arch/mips/netlogic/xlr/Makefile b/arch/mips/netlogic/xlr/Makefile
index f01e4d7a0600..c287dea87570 100644
--- a/arch/mips/netlogic/xlr/Makefile
+++ b/arch/mips/netlogic/xlr/Makefile
@@ -1,2 +1,2 @@
1obj-y += setup.o platform.o 1obj-y += setup.o platform.o platform-flash.o
2obj-$(CONFIG_SMP) += wakeup.o 2obj-$(CONFIG_SMP) += wakeup.o
diff --git a/arch/mips/netlogic/xlr/platform-flash.c b/arch/mips/netlogic/xlr/platform-flash.c
new file mode 100644
index 000000000000..340ab1601c42
--- /dev/null
+++ b/arch/mips/netlogic/xlr/platform-flash.c
@@ -0,0 +1,220 @@
1/*
2 * Copyright 2011, Netlogic Microsystems.
3 * Copyright 2004, Matt Porter <mporter@kernel.crashing.org>
4 *
5 * This file is licensed under the terms of the GNU General Public
6 * License version 2. This program is licensed "as is" without any
7 * warranty of any kind, whether express or implied.
8 */
9
10#include <linux/device.h>
11#include <linux/platform_device.h>
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/io.h>
15#include <linux/delay.h>
16#include <linux/ioport.h>
17#include <linux/resource.h>
18#include <linux/spi/flash.h>
19
20#include <linux/mtd/mtd.h>
21#include <linux/mtd/physmap.h>
22#include <linux/mtd/nand.h>
23#include <linux/mtd/partitions.h>
24
25#include <asm/netlogic/haldefs.h>
26#include <asm/netlogic/xlr/iomap.h>
27#include <asm/netlogic/xlr/flash.h>
28#include <asm/netlogic/xlr/bridge.h>
29#include <asm/netlogic/xlr/gpio.h>
30#include <asm/netlogic/xlr/xlr.h>
31
32/*
33 * Default NOR partition layout
34 */
35static struct mtd_partition xlr_nor_parts[] = {
36 {
37 .name = "User FS",
38 .offset = 0x800000,
39 .size = MTDPART_SIZ_FULL,
40 }
41};
42
43/*
44 * Default NAND partition layout
45 */
46static struct mtd_partition xlr_nand_parts[] = {
47 {
48 .name = "Root Filesystem",
49 .offset = 64 * 64 * 2048,
50 .size = 432 * 64 * 2048,
51 },
52 {
53 .name = "Home Filesystem",
54 .offset = MTDPART_OFS_APPEND,
55 .size = MTDPART_SIZ_FULL,
56 },
57};
58
59/* Use PHYSMAP flash for NOR */
60struct physmap_flash_data xlr_nor_data = {
61 .width = 2,
62 .parts = xlr_nor_parts,
63 .nr_parts = ARRAY_SIZE(xlr_nor_parts),
64};
65
66static struct resource xlr_nor_res[] = {
67 {
68 .flags = IORESOURCE_MEM,
69 },
70};
71
72static struct platform_device xlr_nor_dev = {
73 .name = "physmap-flash",
74 .dev = {
75 .platform_data = &xlr_nor_data,
76 },
77 .num_resources = ARRAY_SIZE(xlr_nor_res),
78 .resource = xlr_nor_res,
79};
80
81const char *xlr_part_probes[] = { "cmdlinepart", NULL };
82
83/*
84 * Use "gen_nand" driver for NAND flash
85 *
86 * There seems to be no way to store a private pointer containing
87 * platform specific info in gen_nand drivier. We will use a global
88 * struct for now, since we currently have only one NAND chip per board.
89 */
90struct xlr_nand_flash_priv {
91 int cs;
92 uint64_t flash_mmio;
93};
94
95static struct xlr_nand_flash_priv nand_priv;
96
97static void xlr_nand_ctrl(struct mtd_info *mtd, int cmd,
98 unsigned int ctrl)
99{
100 if (ctrl & NAND_CLE)
101 nlm_write_reg(nand_priv.flash_mmio,
102 FLASH_NAND_CLE(nand_priv.cs), cmd);
103 else if (ctrl & NAND_ALE)
104 nlm_write_reg(nand_priv.flash_mmio,
105 FLASH_NAND_ALE(nand_priv.cs), cmd);
106}
107
108struct platform_nand_data xlr_nand_data = {
109 .chip = {
110 .nr_chips = 1,
111 .nr_partitions = ARRAY_SIZE(xlr_nand_parts),
112 .chip_delay = 50,
113 .partitions = xlr_nand_parts,
114 .part_probe_types = xlr_part_probes,
115 },
116 .ctrl = {
117 .cmd_ctrl = xlr_nand_ctrl,
118 },
119};
120
121static struct resource xlr_nand_res[] = {
122 {
123 .flags = IORESOURCE_MEM,
124 },
125};
126
127static struct platform_device xlr_nand_dev = {
128 .name = "gen_nand",
129 .id = -1,
130 .num_resources = ARRAY_SIZE(xlr_nand_res),
131 .resource = xlr_nand_res,
132 .dev = {
133 .platform_data = &xlr_nand_data,
134 }
135};
136
137/*
138 * XLR/XLS supports upto 8 devices on its FLASH interface. The value in
139 * FLASH_BAR (on the MEM/IO bridge) gives the base for mapping all the
140 * flash devices.
141 * Under this, each flash device has an offset and size given by the
142 * CSBASE_ADDR and CSBASE_MASK registers for the device.
143 *
144 * The CSBASE_ registers are expected to be setup by the bootloader.
145 */
146static void setup_flash_resource(uint64_t flash_mmio,
147 uint64_t flash_map_base, int cs, struct resource *res)
148{
149 u32 base, mask;
150
151 base = nlm_read_reg(flash_mmio, FLASH_CSBASE_ADDR(cs));
152 mask = nlm_read_reg(flash_mmio, FLASH_CSADDR_MASK(cs));
153
154 res->start = flash_map_base + ((unsigned long)base << 16);
155 res->end = res->start + (mask + 1) * 64 * 1024;
156}
157
158static int __init xlr_flash_init(void)
159{
160 uint64_t gpio_mmio, flash_mmio, flash_map_base;
161 u32 gpio_resetcfg, flash_bar;
162 int cs, boot_nand, boot_nor;
163
164 /* Flash address bits 39:24 is in bridge flash BAR */
165 flash_bar = nlm_read_reg(nlm_io_base, BRIDGE_FLASH_BAR);
166 flash_map_base = (flash_bar & 0xffff0000) << 8;
167
168 gpio_mmio = nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET);
169 flash_mmio = nlm_mmio_base(NETLOGIC_IO_FLASH_OFFSET);
170
171 /* Get the chip reset config */
172 gpio_resetcfg = nlm_read_reg(gpio_mmio, GPIO_PWRON_RESET_CFG_REG);
173
174 /* Check for boot flash type */
175 boot_nor = boot_nand = 0;
176 if (nlm_chip_is_xls()) {
177 /* On XLS, check boot from NAND bit (GPIO reset reg bit 16) */
178 if (gpio_resetcfg & (1 << 16))
179 boot_nand = 1;
180
181 /* check boot from PCMCIA, (GPIO reset reg bit 15 */
182 if ((gpio_resetcfg & (1 << 15)) == 0)
183 boot_nor = 1; /* not set, booted from NOR */
184 } else { /* XLR */
185 /* check boot from PCMCIA (bit 16 in GPIO reset on XLR) */
186 if ((gpio_resetcfg & (1 << 16)) == 0)
187 boot_nor = 1; /* not set, booted from NOR */
188 }
189
190 /* boot flash at chip select 0 */
191 cs = 0;
192
193 if (boot_nand) {
194 nand_priv.cs = cs;
195 nand_priv.flash_mmio = flash_mmio;
196 setup_flash_resource(flash_mmio, flash_map_base, cs,
197 xlr_nand_res);
198
199 /* Initialize NAND flash at CS 0 */
200 nlm_write_reg(flash_mmio, FLASH_CSDEV_PARM(cs),
201 FLASH_NAND_CSDEV_PARAM);
202 nlm_write_reg(flash_mmio, FLASH_CSTIME_PARMA(cs),
203 FLASH_NAND_CSTIME_PARAMA);
204 nlm_write_reg(flash_mmio, FLASH_CSTIME_PARMB(cs),
205 FLASH_NAND_CSTIME_PARAMB);
206
207 pr_info("ChipSelect %d: NAND Flash %pR\n", cs, xlr_nand_res);
208 return platform_device_register(&xlr_nand_dev);
209 }
210
211 if (boot_nor) {
212 setup_flash_resource(flash_mmio, flash_map_base, cs,
213 xlr_nor_res);
214 pr_info("ChipSelect %d: NOR Flash %pR\n", cs, xlr_nor_res);
215 return platform_device_register(&xlr_nor_dev);
216 }
217 return 0;
218}
219
220arch_initcall(xlr_flash_init);
diff --git a/arch/mips/netlogic/xlr/platform.c b/arch/mips/netlogic/xlr/platform.c
index eab64b45dffd..71b44d82621d 100644
--- a/arch/mips/netlogic/xlr/platform.c
+++ b/arch/mips/netlogic/xlr/platform.c
@@ -14,6 +14,7 @@
14#include <linux/resource.h> 14#include <linux/resource.h>
15#include <linux/serial_8250.h> 15#include <linux/serial_8250.h>
16#include <linux/serial_reg.h> 16#include <linux/serial_reg.h>
17#include <linux/i2c.h>
17 18
18#include <asm/netlogic/haldefs.h> 19#include <asm/netlogic/haldefs.h>
19#include <asm/netlogic/xlr/iomap.h> 20#include <asm/netlogic/xlr/iomap.h>
@@ -97,3 +98,142 @@ static int __init nlm_uart_init(void)
97} 98}
98 99
99arch_initcall(nlm_uart_init); 100arch_initcall(nlm_uart_init);
101
102#ifdef CONFIG_USB
103/* Platform USB devices, only on XLS chips */
104static u64 xls_usb_dmamask = ~(u32)0;
105#define USB_PLATFORM_DEV(n, i, irq) \
106 { \
107 .name = n, \
108 .id = i, \
109 .num_resources = 2, \
110 .dev = { \
111 .dma_mask = &xls_usb_dmamask, \
112 .coherent_dma_mask = 0xffffffff, \
113 }, \
114 .resource = (struct resource[]) { \
115 { \
116 .flags = IORESOURCE_MEM, \
117 }, \
118 { \
119 .start = irq, \
120 .end = irq, \
121 .flags = IORESOURCE_IRQ, \
122 }, \
123 }, \
124 }
125
126static struct platform_device xls_usb_ehci_device =
127 USB_PLATFORM_DEV("ehci-xls", 0, PIC_USB_IRQ);
128static struct platform_device xls_usb_ohci_device_0 =
129 USB_PLATFORM_DEV("ohci-xls-0", 1, PIC_USB_IRQ);
130static struct platform_device xls_usb_ohci_device_1 =
131 USB_PLATFORM_DEV("ohci-xls-1", 2, PIC_USB_IRQ);
132
133static struct platform_device *xls_platform_devices[] = {
134 &xls_usb_ehci_device,
135 &xls_usb_ohci_device_0,
136 &xls_usb_ohci_device_1,
137};
138
139int xls_platform_usb_init(void)
140{
141 uint64_t usb_mmio, gpio_mmio;
142 unsigned long memres;
143 uint32_t val;
144
145 if (!nlm_chip_is_xls())
146 return 0;
147
148 gpio_mmio = nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET);
149 usb_mmio = nlm_mmio_base(NETLOGIC_IO_USB_1_OFFSET);
150
151 /* Clear Rogue Phy INTs */
152 nlm_write_reg(usb_mmio, 49, 0x10000000);
153 /* Enable all interrupts */
154 nlm_write_reg(usb_mmio, 50, 0x1f000000);
155
156 /* Enable ports */
157 nlm_write_reg(usb_mmio, 1, 0x07000500);
158
159 val = nlm_read_reg(gpio_mmio, 21);
160 if (((val >> 22) & 0x01) == 0) {
161 pr_info("Detected USB Device mode - Not supported!\n");
162 nlm_write_reg(usb_mmio, 0, 0x01000000);
163 return 0;
164 }
165
166 pr_info("Detected USB Host mode - Adding XLS USB devices.\n");
167 /* Clear reset, host mode */
168 nlm_write_reg(usb_mmio, 0, 0x02000000);
169
170 /* Memory resource for various XLS usb ports */
171 usb_mmio = nlm_mmio_base(NETLOGIC_IO_USB_0_OFFSET);
172 memres = CPHYSADDR((unsigned long)usb_mmio);
173 xls_usb_ehci_device.resource[0].start = memres;
174 xls_usb_ehci_device.resource[0].end = memres + 0x400 - 1;
175
176 memres += 0x400;
177 xls_usb_ohci_device_0.resource[0].start = memres;
178 xls_usb_ohci_device_0.resource[0].end = memres + 0x400 - 1;
179
180 memres += 0x400;
181 xls_usb_ohci_device_1.resource[0].start = memres;
182 xls_usb_ohci_device_1.resource[0].end = memres + 0x400 - 1;
183
184 return platform_add_devices(xls_platform_devices,
185 ARRAY_SIZE(xls_platform_devices));
186}
187
188arch_initcall(xls_platform_usb_init);
189#endif
190
191#ifdef CONFIG_I2C
192static struct i2c_board_info nlm_i2c_board_info1[] __initdata = {
193 /* All XLR boards have this RTC and Max6657 Temp Chip */
194 [0] = {
195 .type = "ds1374",
196 .addr = 0x68
197 },
198 [1] = {
199 .type = "lm90",
200 .addr = 0x4c
201 },
202};
203
204static struct resource i2c_resources[] = {
205 [0] = {
206 .start = 0, /* filled at init */
207 .end = 0,
208 .flags = IORESOURCE_MEM,
209 },
210};
211
212static struct platform_device nlm_xlr_i2c_1 = {
213 .name = "xlr-i2cbus",
214 .id = 1,
215 .num_resources = 1,
216 .resource = i2c_resources,
217};
218
219static int __init nlm_i2c_init(void)
220{
221 int err = 0;
222 unsigned int offset;
223
224 /* I2C bus 0 does not have any useful devices, configure only bus 1 */
225 offset = NETLOGIC_IO_I2C_1_OFFSET;
226 nlm_xlr_i2c_1.resource[0].start = CPHYSADDR(nlm_mmio_base(offset));
227 nlm_xlr_i2c_1.resource[0].end = nlm_xlr_i2c_1.resource[0].start + 0xfff;
228
229 platform_device_register(&nlm_xlr_i2c_1);
230
231 err = i2c_register_board_info(1, nlm_i2c_board_info1,
232 ARRAY_SIZE(nlm_i2c_board_info1));
233 if (err < 0)
234 pr_err("nlm-i2c: cannot register board I2C devices\n");
235 return err;
236}
237
238arch_initcall(nlm_i2c_init);
239#endif
diff --git a/arch/mips/netlogic/xlr/setup.c b/arch/mips/netlogic/xlr/setup.c
index c9d066dedc4e..81b1d311834f 100644
--- a/arch/mips/netlogic/xlr/setup.c
+++ b/arch/mips/netlogic/xlr/setup.c
@@ -85,7 +85,7 @@ static void nlm_linux_exit(void)
85 85
86 gpiobase = nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET); 86 gpiobase = nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET);
87 /* trigger a chip reset by writing 1 to GPIO_SWRESET_REG */ 87 /* trigger a chip reset by writing 1 to GPIO_SWRESET_REG */
88 nlm_write_reg(gpiobase, NETLOGIC_GPIO_SWRESET_REG, 1); 88 nlm_write_reg(gpiobase, GPIO_SWRESET_REG, 1);
89 for ( ; ; ) 89 for ( ; ; )
90 cpu_wait(); 90 cpu_wait();
91} 91}
diff --git a/arch/mips/oprofile/common.c b/arch/mips/oprofile/common.c
index b6e378211a2c..f80480a5a032 100644
--- a/arch/mips/oprofile/common.c
+++ b/arch/mips/oprofile/common.c
@@ -85,6 +85,7 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
85 case CPU_34K: 85 case CPU_34K:
86 case CPU_1004K: 86 case CPU_1004K:
87 case CPU_74K: 87 case CPU_74K:
88 case CPU_LOONGSON1:
88 case CPU_SB1: 89 case CPU_SB1:
89 case CPU_SB1A: 90 case CPU_SB1A:
90 case CPU_R10000: 91 case CPU_R10000:
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index 4d80a856048d..28ea1a4cc576 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -339,12 +339,6 @@ static int __init mipsxx_init(void)
339 break; 339 break;
340 340
341 case CPU_1004K: 341 case CPU_1004K:
342#if 0
343 /* FIXME: report as 34K for now */
344 op_model_mipsxx_ops.cpu_type = "mips/1004K";
345 break;
346#endif
347
348 case CPU_34K: 342 case CPU_34K:
349 op_model_mipsxx_ops.cpu_type = "mips/34K"; 343 op_model_mipsxx_ops.cpu_type = "mips/34K";
350 break; 344 break;
@@ -374,6 +368,10 @@ static int __init mipsxx_init(void)
374 op_model_mipsxx_ops.cpu_type = "mips/sb1"; 368 op_model_mipsxx_ops.cpu_type = "mips/sb1";
375 break; 369 break;
376 370
371 case CPU_LOONGSON1:
372 op_model_mipsxx_ops.cpu_type = "mips/loongson1";
373 break;
374
377 default: 375 default:
378 printk(KERN_ERR "Profiling unsupported for this CPU\n"); 376 printk(KERN_ERR "Profiling unsupported for this CPU\n");
379 377
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index c703f43a9914..e13a71cbc3c7 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -59,6 +59,7 @@ obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o
59obj-$(CONFIG_MIKROTIK_RB532) += pci-rc32434.o ops-rc32434.o fixup-rc32434.o 59obj-$(CONFIG_MIKROTIK_RB532) += pci-rc32434.o ops-rc32434.o fixup-rc32434.o
60obj-$(CONFIG_CPU_CAVIUM_OCTEON) += pci-octeon.o pcie-octeon.o 60obj-$(CONFIG_CPU_CAVIUM_OCTEON) += pci-octeon.o pcie-octeon.o
61obj-$(CONFIG_CPU_XLR) += pci-xlr.o 61obj-$(CONFIG_CPU_XLR) += pci-xlr.o
62obj-$(CONFIG_CPU_XLP) += pci-xlp.o
62 63
63ifdef CONFIG_PCI_MSI 64ifdef CONFIG_PCI_MSI
64obj-$(CONFIG_CPU_CAVIUM_OCTEON) += msi-octeon.o 65obj-$(CONFIG_CPU_CAVIUM_OCTEON) += msi-octeon.o
diff --git a/arch/mips/pci/fixup-cobalt.c b/arch/mips/pci/fixup-cobalt.c
index 9553b14002dd..3e7ce65d776c 100644
--- a/arch/mips/pci/fixup-cobalt.c
+++ b/arch/mips/pci/fixup-cobalt.c
@@ -37,7 +37,7 @@
37#define VIA_COBALT_BRD_ID_REG 0x94 37#define VIA_COBALT_BRD_ID_REG 0x94
38#define VIA_COBALT_BRD_REG_to_ID(reg) ((unsigned char)(reg) >> 4) 38#define VIA_COBALT_BRD_REG_to_ID(reg) ((unsigned char)(reg) >> 4)
39 39
40static void qube_raq_galileo_early_fixup(struct pci_dev *dev) 40static void __devinit qube_raq_galileo_early_fixup(struct pci_dev *dev)
41{ 41{
42 if (dev->devfn == PCI_DEVFN(0, 0) && 42 if (dev->devfn == PCI_DEVFN(0, 0) &&
43 (dev->class >> 8) == PCI_CLASS_MEMORY_OTHER) { 43 (dev->class >> 8) == PCI_CLASS_MEMORY_OTHER) {
@@ -51,7 +51,7 @@ static void qube_raq_galileo_early_fixup(struct pci_dev *dev)
51DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111, 51DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111,
52 qube_raq_galileo_early_fixup); 52 qube_raq_galileo_early_fixup);
53 53
54static void qube_raq_via_bmIDE_fixup(struct pci_dev *dev) 54static void __devinit qube_raq_via_bmIDE_fixup(struct pci_dev *dev)
55{ 55{
56 unsigned short cfgword; 56 unsigned short cfgword;
57 unsigned char lt; 57 unsigned char lt;
@@ -74,7 +74,7 @@ static void qube_raq_via_bmIDE_fixup(struct pci_dev *dev)
74DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, 74DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1,
75 qube_raq_via_bmIDE_fixup); 75 qube_raq_via_bmIDE_fixup);
76 76
77static void qube_raq_galileo_fixup(struct pci_dev *dev) 77static void __devinit qube_raq_galileo_fixup(struct pci_dev *dev)
78{ 78{
79 if (dev->devfn != PCI_DEVFN(0, 0)) 79 if (dev->devfn != PCI_DEVFN(0, 0))
80 return; 80 return;
@@ -129,7 +129,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111,
129 129
130int cobalt_board_id; 130int cobalt_board_id;
131 131
132static void qube_raq_via_board_id_fixup(struct pci_dev *dev) 132static void __devinit qube_raq_via_board_id_fixup(struct pci_dev *dev)
133{ 133{
134 u8 id; 134 u8 id;
135 int retval; 135 int retval;
diff --git a/arch/mips/pci/fixup-malta.c b/arch/mips/pci/fixup-malta.c
index 70073c98ed32..819622f93e9c 100644
--- a/arch/mips/pci/fixup-malta.c
+++ b/arch/mips/pci/fixup-malta.c
@@ -101,3 +101,17 @@ static void __devinit malta_piix_func1_fixup(struct pci_dev *pdev)
101 101
102DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB, 102DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB,
103 malta_piix_func1_fixup); 103 malta_piix_func1_fixup);
104
105/* Enable PCI 2.1 compatibility in PIIX4 */
106static void __devinit quirk_dlcsetup(struct pci_dev *dev)
107{
108 u8 odlc, ndlc;
109
110 (void) pci_read_config_byte(dev, 0x82, &odlc);
111 /* Enable passive releases and delayed transaction */
112 ndlc = odlc | 7;
113 (void) pci_write_config_byte(dev, 0x82, ndlc);
114}
115
116DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0,
117 quirk_dlcsetup);
diff --git a/arch/mips/pci/fixup-rc32434.c b/arch/mips/pci/fixup-rc32434.c
index 3d86823d03a0..76bb1be99d43 100644
--- a/arch/mips/pci/fixup-rc32434.c
+++ b/arch/mips/pci/fixup-rc32434.c
@@ -47,7 +47,7 @@ int __devinit pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
47 return irq + GROUP4_IRQ_BASE + 4; 47 return irq + GROUP4_IRQ_BASE + 4;
48} 48}
49 49
50static void rc32434_pci_early_fixup(struct pci_dev *dev) 50static void __devinit rc32434_pci_early_fixup(struct pci_dev *dev)
51{ 51{
52 if (PCI_SLOT(dev->devfn) == 6 && dev->bus->number == 0) { 52 if (PCI_SLOT(dev->devfn) == 6 && dev->bus->number == 0) {
53 /* disable prefetched memory range */ 53 /* disable prefetched memory range */
diff --git a/arch/mips/pci/ops-bcm63xx.c b/arch/mips/pci/ops-bcm63xx.c
index 822ae179bc56..65c7bd100486 100644
--- a/arch/mips/pci/ops-bcm63xx.c
+++ b/arch/mips/pci/ops-bcm63xx.c
@@ -411,7 +411,7 @@ struct pci_ops bcm63xx_cb_ops = {
411 * only one IO window, so it cannot be shared by PCI and cardbus, use 411 * only one IO window, so it cannot be shared by PCI and cardbus, use
412 * fixup to choose and detect unhandled configuration 412 * fixup to choose and detect unhandled configuration
413 */ 413 */
414static void bcm63xx_fixup(struct pci_dev *dev) 414static void __devinit bcm63xx_fixup(struct pci_dev *dev)
415{ 415{
416 static int io_window = -1; 416 static int io_window = -1;
417 int i, found, new_io_window; 417 int i, found, new_io_window;
@@ -465,3 +465,64 @@ static void bcm63xx_fixup(struct pci_dev *dev)
465 465
466DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, bcm63xx_fixup); 466DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, bcm63xx_fixup);
467#endif 467#endif
468
469static int bcm63xx_pcie_can_access(struct pci_bus *bus, int devfn)
470{
471 switch (bus->number) {
472 case PCIE_BUS_BRIDGE:
473 return (PCI_SLOT(devfn) == 0);
474 case PCIE_BUS_DEVICE:
475 if (PCI_SLOT(devfn) == 0)
476 return bcm_pcie_readl(PCIE_DLSTATUS_REG)
477 & DLSTATUS_PHYLINKUP;
478 default:
479 return false;
480 }
481}
482
483static int bcm63xx_pcie_read(struct pci_bus *bus, unsigned int devfn,
484 int where, int size, u32 *val)
485{
486 u32 data;
487 u32 reg = where & ~3;
488
489 if (!bcm63xx_pcie_can_access(bus, devfn))
490 return PCIBIOS_DEVICE_NOT_FOUND;
491
492 if (bus->number == PCIE_BUS_DEVICE)
493 reg += PCIE_DEVICE_OFFSET;
494
495 data = bcm_pcie_readl(reg);
496
497 *val = postprocess_read(data, where, size);
498
499 return PCIBIOS_SUCCESSFUL;
500
501}
502
503static int bcm63xx_pcie_write(struct pci_bus *bus, unsigned int devfn,
504 int where, int size, u32 val)
505{
506 u32 data;
507 u32 reg = where & ~3;
508
509 if (!bcm63xx_pcie_can_access(bus, devfn))
510 return PCIBIOS_DEVICE_NOT_FOUND;
511
512 if (bus->number == PCIE_BUS_DEVICE)
513 reg += PCIE_DEVICE_OFFSET;
514
515
516 data = bcm_pcie_readl(reg);
517
518 data = preprocess_write(data, val, where, size);
519 bcm_pcie_writel(data, reg);
520
521 return PCIBIOS_SUCCESSFUL;
522}
523
524
525struct pci_ops bcm63xx_pcie_ops = {
526 .read = bcm63xx_pcie_read,
527 .write = bcm63xx_pcie_write
528};
diff --git a/arch/mips/pci/pci-bcm63xx.c b/arch/mips/pci/pci-bcm63xx.c
index 39eb7c417e2f..8a48139d219c 100644
--- a/arch/mips/pci/pci-bcm63xx.c
+++ b/arch/mips/pci/pci-bcm63xx.c
@@ -10,6 +10,7 @@
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/delay.h>
13#include <asm/bootinfo.h> 14#include <asm/bootinfo.h>
14 15
15#include "pci-bcm63xx.h" 16#include "pci-bcm63xx.h"
@@ -71,6 +72,26 @@ struct pci_controller bcm63xx_cb_controller = {
71}; 72};
72#endif 73#endif
73 74
75static struct resource bcm_pcie_mem_resource = {
76 .name = "bcm63xx PCIe memory space",
77 .start = BCM_PCIE_MEM_BASE_PA,
78 .end = BCM_PCIE_MEM_END_PA,
79 .flags = IORESOURCE_MEM,
80};
81
82static struct resource bcm_pcie_io_resource = {
83 .name = "bcm63xx PCIe IO space",
84 .start = 0,
85 .end = 0,
86 .flags = 0,
87};
88
89struct pci_controller bcm63xx_pcie_controller = {
90 .pci_ops = &bcm63xx_pcie_ops,
91 .io_resource = &bcm_pcie_io_resource,
92 .mem_resource = &bcm_pcie_mem_resource,
93};
94
74static u32 bcm63xx_int_cfg_readl(u32 reg) 95static u32 bcm63xx_int_cfg_readl(u32 reg)
75{ 96{
76 u32 tmp; 97 u32 tmp;
@@ -94,17 +115,99 @@ static void bcm63xx_int_cfg_writel(u32 val, u32 reg)
94 115
95void __iomem *pci_iospace_start; 116void __iomem *pci_iospace_start;
96 117
97static int __init bcm63xx_pci_init(void) 118static void __init bcm63xx_reset_pcie(void)
98{ 119{
99 unsigned int mem_size;
100 u32 val; 120 u32 val;
101 121
102 if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358() && !BCMCPU_IS_6368()) 122 /* enable clock */
103 return -ENODEV; 123 val = bcm_perf_readl(PERF_CKCTL_REG);
124 val |= CKCTL_6328_PCIE_EN;
125 bcm_perf_writel(val, PERF_CKCTL_REG);
126
127 /* enable SERDES */
128 val = bcm_misc_readl(MISC_SERDES_CTRL_REG);
129 val |= SERDES_PCIE_EN | SERDES_PCIE_EXD_EN;
130 bcm_misc_writel(val, MISC_SERDES_CTRL_REG);
131
132 /* reset the PCIe core */
133 val = bcm_perf_readl(PERF_SOFTRESET_6328_REG);
134
135 val &= ~SOFTRESET_6328_PCIE_MASK;
136 val &= ~SOFTRESET_6328_PCIE_CORE_MASK;
137 val &= ~SOFTRESET_6328_PCIE_HARD_MASK;
138 val &= ~SOFTRESET_6328_PCIE_EXT_MASK;
139 bcm_perf_writel(val, PERF_SOFTRESET_6328_REG);
140 mdelay(10);
141
142 val |= SOFTRESET_6328_PCIE_MASK;
143 val |= SOFTRESET_6328_PCIE_CORE_MASK;
144 val |= SOFTRESET_6328_PCIE_HARD_MASK;
145 bcm_perf_writel(val, PERF_SOFTRESET_6328_REG);
146 mdelay(10);
147
148 val |= SOFTRESET_6328_PCIE_EXT_MASK;
149 bcm_perf_writel(val, PERF_SOFTRESET_6328_REG);
150 mdelay(200);
151}
104 152
105 if (!bcm63xx_pci_enabled) 153static int __init bcm63xx_register_pcie(void)
106 return -ENODEV; 154{
155 u32 val;
107 156
157 bcm63xx_reset_pcie();
158
159 /* configure the PCIe bridge */
160 val = bcm_pcie_readl(PCIE_BRIDGE_OPT1_REG);
161 val |= OPT1_RD_BE_OPT_EN;
162 val |= OPT1_RD_REPLY_BE_FIX_EN;
163 val |= OPT1_PCIE_BRIDGE_HOLE_DET_EN;
164 val |= OPT1_L1_INT_STATUS_MASK_POL;
165 bcm_pcie_writel(val, PCIE_BRIDGE_OPT1_REG);
166
167 /* setup the interrupts */
168 val = bcm_pcie_readl(PCIE_BRIDGE_RC_INT_MASK_REG);
169 val |= PCIE_RC_INT_A | PCIE_RC_INT_B | PCIE_RC_INT_C | PCIE_RC_INT_D;
170 bcm_pcie_writel(val, PCIE_BRIDGE_RC_INT_MASK_REG);
171
172 val = bcm_pcie_readl(PCIE_BRIDGE_OPT2_REG);
173 /* enable credit checking and error checking */
174 val |= OPT2_TX_CREDIT_CHK_EN;
175 val |= OPT2_UBUS_UR_DECODE_DIS;
176
177 /* set device bus/func for the pcie device */
178 val |= (PCIE_BUS_DEVICE << OPT2_CFG_TYPE1_BUS_NO_SHIFT);
179 val |= OPT2_CFG_TYPE1_BD_SEL;
180 bcm_pcie_writel(val, PCIE_BRIDGE_OPT2_REG);
181
182 /* setup class code as bridge */
183 val = bcm_pcie_readl(PCIE_IDVAL3_REG);
184 val &= ~IDVAL3_CLASS_CODE_MASK;
185 val |= (PCI_CLASS_BRIDGE_PCI << IDVAL3_SUBCLASS_SHIFT);
186 bcm_pcie_writel(val, PCIE_IDVAL3_REG);
187
188 /* disable bar1 size */
189 val = bcm_pcie_readl(PCIE_CONFIG2_REG);
190 val &= ~CONFIG2_BAR1_SIZE_MASK;
191 bcm_pcie_writel(val, PCIE_CONFIG2_REG);
192
193 /* set bar0 to little endian */
194 val = (BCM_PCIE_MEM_BASE_PA >> 20) << BASEMASK_BASE_SHIFT;
195 val |= (BCM_PCIE_MEM_BASE_PA >> 20) << BASEMASK_MASK_SHIFT;
196 val |= BASEMASK_REMAP_EN;
197 bcm_pcie_writel(val, PCIE_BRIDGE_BAR0_BASEMASK_REG);
198
199 val = (BCM_PCIE_MEM_BASE_PA >> 20) << REBASE_ADDR_BASE_SHIFT;
200 bcm_pcie_writel(val, PCIE_BRIDGE_BAR0_REBASE_ADDR_REG);
201
202 register_pci_controller(&bcm63xx_pcie_controller);
203
204 return 0;
205}
206
207static int __init bcm63xx_register_pci(void)
208{
209 unsigned int mem_size;
210 u32 val;
108 /* 211 /*
109 * configuration access are done through IO space, remap 4 212 * configuration access are done through IO space, remap 4
110 * first bytes to access it from CPU. 213 * first bytes to access it from CPU.
@@ -221,4 +324,22 @@ static int __init bcm63xx_pci_init(void)
221 return 0; 324 return 0;
222} 325}
223 326
327
328static int __init bcm63xx_pci_init(void)
329{
330 if (!bcm63xx_pci_enabled)
331 return -ENODEV;
332
333 switch (bcm63xx_get_cpu_id()) {
334 case BCM6328_CPU_ID:
335 return bcm63xx_register_pcie();
336 case BCM6348_CPU_ID:
337 case BCM6358_CPU_ID:
338 case BCM6368_CPU_ID:
339 return bcm63xx_register_pci();
340 default:
341 return -ENODEV;
342 }
343}
344
224arch_initcall(bcm63xx_pci_init); 345arch_initcall(bcm63xx_pci_init);
diff --git a/arch/mips/pci/pci-bcm63xx.h b/arch/mips/pci/pci-bcm63xx.h
index a6e594ef3d6a..e6736d558ac7 100644
--- a/arch/mips/pci/pci-bcm63xx.h
+++ b/arch/mips/pci/pci-bcm63xx.h
@@ -13,11 +13,16 @@
13 */ 13 */
14#define CARDBUS_PCI_IDSEL 0x8 14#define CARDBUS_PCI_IDSEL 0x8
15 15
16
17#define PCIE_BUS_BRIDGE 0
18#define PCIE_BUS_DEVICE 1
19
16/* 20/*
17 * defined in ops-bcm63xx.c 21 * defined in ops-bcm63xx.c
18 */ 22 */
19extern struct pci_ops bcm63xx_pci_ops; 23extern struct pci_ops bcm63xx_pci_ops;
20extern struct pci_ops bcm63xx_cb_ops; 24extern struct pci_ops bcm63xx_cb_ops;
25extern struct pci_ops bcm63xx_pcie_ops;
21 26
22/* 27/*
23 * defined in pci-bcm63xx.c 28 * defined in pci-bcm63xx.c
diff --git a/arch/mips/pci/pci-xlp.c b/arch/mips/pci/pci-xlp.c
new file mode 100644
index 000000000000..140557a20488
--- /dev/null
+++ b/arch/mips/pci/pci-xlp.c
@@ -0,0 +1,248 @@
1/*
2 * Copyright (c) 2003-2012 Broadcom Corporation
3 * All Rights Reserved
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the Broadcom
9 * license below:
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
31 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#include <linux/types.h>
36#include <linux/pci.h>
37#include <linux/kernel.h>
38#include <linux/init.h>
39#include <linux/msi.h>
40#include <linux/mm.h>
41#include <linux/irq.h>
42#include <linux/irqdesc.h>
43#include <linux/console.h>
44
45#include <asm/io.h>
46
47#include <asm/netlogic/interrupt.h>
48#include <asm/netlogic/haldefs.h>
49
50#include <asm/netlogic/xlp-hal/iomap.h>
51#include <asm/netlogic/xlp-hal/pic.h>
52#include <asm/netlogic/xlp-hal/xlp.h>
53#include <asm/netlogic/xlp-hal/pcibus.h>
54#include <asm/netlogic/xlp-hal/bridge.h>
55
56static void *pci_config_base;
57
58#define pci_cfg_addr(bus, devfn, off) (((bus) << 20) | ((devfn) << 12) | (off))
59
60/* PCI ops */
61static inline u32 pci_cfg_read_32bit(struct pci_bus *bus, unsigned int devfn,
62 int where)
63{
64 u32 data;
65 u32 *cfgaddr;
66
67 cfgaddr = (u32 *)(pci_config_base +
68 pci_cfg_addr(bus->number, devfn, where & ~3));
69 data = *cfgaddr;
70 return data;
71}
72
73static inline void pci_cfg_write_32bit(struct pci_bus *bus, unsigned int devfn,
74 int where, u32 data)
75{
76 u32 *cfgaddr;
77
78 cfgaddr = (u32 *)(pci_config_base +
79 pci_cfg_addr(bus->number, devfn, where & ~3));
80 *cfgaddr = data;
81}
82
83static int nlm_pcibios_read(struct pci_bus *bus, unsigned int devfn,
84 int where, int size, u32 *val)
85{
86 u32 data;
87
88 if ((size == 2) && (where & 1))
89 return PCIBIOS_BAD_REGISTER_NUMBER;
90 else if ((size == 4) && (where & 3))
91 return PCIBIOS_BAD_REGISTER_NUMBER;
92
93 data = pci_cfg_read_32bit(bus, devfn, where);
94
95 if (size == 1)
96 *val = (data >> ((where & 3) << 3)) & 0xff;
97 else if (size == 2)
98 *val = (data >> ((where & 3) << 3)) & 0xffff;
99 else
100 *val = data;
101
102 return PCIBIOS_SUCCESSFUL;
103}
104
105
106static int nlm_pcibios_write(struct pci_bus *bus, unsigned int devfn,
107 int where, int size, u32 val)
108{
109 u32 data;
110
111 if ((size == 2) && (where & 1))
112 return PCIBIOS_BAD_REGISTER_NUMBER;
113 else if ((size == 4) && (where & 3))
114 return PCIBIOS_BAD_REGISTER_NUMBER;
115
116 data = pci_cfg_read_32bit(bus, devfn, where);
117
118 if (size == 1)
119 data = (data & ~(0xff << ((where & 3) << 3))) |
120 (val << ((where & 3) << 3));
121 else if (size == 2)
122 data = (data & ~(0xffff << ((where & 3) << 3))) |
123 (val << ((where & 3) << 3));
124 else
125 data = val;
126
127 pci_cfg_write_32bit(bus, devfn, where, data);
128
129 return PCIBIOS_SUCCESSFUL;
130}
131
132struct pci_ops nlm_pci_ops = {
133 .read = nlm_pcibios_read,
134 .write = nlm_pcibios_write
135};
136
137static struct resource nlm_pci_mem_resource = {
138 .name = "XLP PCI MEM",
139 .start = 0xd0000000UL, /* 256MB PCI mem @ 0xd000_0000 */
140 .end = 0xdfffffffUL,
141 .flags = IORESOURCE_MEM,
142};
143
144static struct resource nlm_pci_io_resource = {
145 .name = "XLP IO MEM",
146 .start = 0x14000000UL, /* 64MB PCI IO @ 0x1000_0000 */
147 .end = 0x17ffffffUL,
148 .flags = IORESOURCE_IO,
149};
150
151struct pci_controller nlm_pci_controller = {
152 .index = 0,
153 .pci_ops = &nlm_pci_ops,
154 .mem_resource = &nlm_pci_mem_resource,
155 .mem_offset = 0x00000000UL,
156 .io_resource = &nlm_pci_io_resource,
157 .io_offset = 0x00000000UL,
158};
159
160static int get_irq_vector(const struct pci_dev *dev)
161{
162 /*
163 * For XLP PCIe, there is an IRQ per Link, find out which
164 * link the device is on to assign interrupts
165 */
166 if (dev->bus->self == NULL)
167 return 0;
168
169 switch (dev->bus->self->devfn) {
170 case 0x8:
171 return PIC_PCIE_LINK_0_IRQ;
172 case 0x9:
173 return PIC_PCIE_LINK_1_IRQ;
174 case 0xa:
175 return PIC_PCIE_LINK_2_IRQ;
176 case 0xb:
177 return PIC_PCIE_LINK_3_IRQ;
178 }
179 WARN(1, "Unexpected devfn %d\n", dev->bus->self->devfn);
180 return 0;
181}
182
183int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
184{
185 return get_irq_vector(dev);
186}
187
188/* Do platform specific device initialization at pci_enable_device() time */
189int pcibios_plat_dev_init(struct pci_dev *dev)
190{
191 return 0;
192}
193
194static int xlp_enable_pci_bswap(void)
195{
196 uint64_t pciebase, sysbase;
197 int node, i;
198 u32 reg;
199
200 /* Chip-0 so node set to 0 */
201 node = 0;
202 sysbase = nlm_get_bridge_regbase(node);
203 /*
204 * Enable byte swap in hardware. Program each link's PCIe SWAP regions
205 * from the link's address ranges.
206 */
207 for (i = 0; i < 4; i++) {
208 pciebase = nlm_pcicfg_base(XLP_IO_PCIE_OFFSET(node, i));
209 if (nlm_read_pci_reg(pciebase, 0) == 0xffffffff)
210 continue;
211
212 reg = nlm_read_bridge_reg(sysbase, BRIDGE_PCIEMEM_BASE0 + i);
213 nlm_write_pci_reg(pciebase, PCIE_BYTE_SWAP_MEM_BASE, reg);
214
215 reg = nlm_read_bridge_reg(sysbase, BRIDGE_PCIEMEM_LIMIT0 + i);
216 nlm_write_pci_reg(pciebase, PCIE_BYTE_SWAP_MEM_LIM,
217 reg | 0xfff);
218
219 reg = nlm_read_bridge_reg(sysbase, BRIDGE_PCIEIO_BASE0 + i);
220 nlm_write_pci_reg(pciebase, PCIE_BYTE_SWAP_IO_BASE, reg);
221
222 reg = nlm_read_bridge_reg(sysbase, BRIDGE_PCIEIO_LIMIT0 + i);
223 nlm_write_pci_reg(pciebase, PCIE_BYTE_SWAP_IO_LIM, reg | 0xfff);
224 }
225 return 0;
226}
227
228static int __init pcibios_init(void)
229{
230 /* Firmware assigns PCI resources */
231 pci_set_flags(PCI_PROBE_ONLY);
232 pci_config_base = ioremap(XLP_DEFAULT_PCI_ECFG_BASE, 64 << 20);
233
234 /* Extend IO port for memory mapped io */
235 ioport_resource.start = 0;
236 ioport_resource.end = ~0;
237
238 xlp_enable_pci_bswap();
239 set_io_port_base(CKSEG1);
240 nlm_pci_controller.io_map_base = CKSEG1;
241
242 register_pci_controller(&nlm_pci_controller);
243 pr_info("XLP PCIe Controller %pR%pR.\n", &nlm_pci_io_resource,
244 &nlm_pci_mem_resource);
245
246 return 0;
247}
248arch_initcall(pcibios_init);
diff --git a/arch/mips/pci/pci-xlr.c b/arch/mips/pci/pci-xlr.c
index 172af1cd5867..18af021d289a 100644
--- a/arch/mips/pci/pci-xlr.c
+++ b/arch/mips/pci/pci-xlr.c
@@ -375,7 +375,3 @@ static int __init pcibios_init(void)
375} 375}
376 376
377arch_initcall(pcibios_init); 377arch_initcall(pcibios_init);
378
379struct pci_fixup pcibios_fixups[] = {
380 {0}
381};
diff --git a/arch/mips/pnx833x/stb22x/board.c b/arch/mips/pnx833x/stb22x/board.c
index 644eb7c3210f..4b328ac43050 100644
--- a/arch/mips/pnx833x/stb22x/board.c
+++ b/arch/mips/pnx833x/stb22x/board.c
@@ -91,7 +91,7 @@ void __init pnx833x_board_setup(void)
91 pnx833x_gpio_select_function_alt(32); 91 pnx833x_gpio_select_function_alt(32);
92 pnx833x_gpio_select_function_alt(33); 92 pnx833x_gpio_select_function_alt(33);
93 93
94#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE) 94#if IS_ENABLED(CONFIG_MTD_NAND_PLATFORM)
95 /* Setup MIU for NAND access on CS0... 95 /* Setup MIU for NAND access on CS0...
96 * 96 *
97 * (it seems that we must also configure CS1 for reliable operation, 97 * (it seems that we must also configure CS1 for reliable operation,
@@ -117,7 +117,7 @@ void __init pnx833x_board_setup(void)
117 pnx833x_gpio_select_output(5); 117 pnx833x_gpio_select_output(5);
118 pnx833x_gpio_write(1, 5); 118 pnx833x_gpio_write(1, 5);
119 119
120#elif defined(CONFIG_MTD_CFI) || defined(CONFIG_MTD_CFI_MODULE) 120#elif IS_ENABLED(CONFIG_MTD_CFI)
121 121
122 /* Set up MIU for 16-bit NOR access on CS0 and CS1... */ 122 /* Set up MIU for 16-bit NOR access on CS0 and CS1... */
123 123
diff --git a/arch/mips/txx9/generic/pci.c b/arch/mips/txx9/generic/pci.c
index 125db323ab1e..4efd9185f294 100644
--- a/arch/mips/txx9/generic/pci.c
+++ b/arch/mips/txx9/generic/pci.c
@@ -304,7 +304,7 @@ static void __devinit quirk_slc90e66_bridge(struct pci_dev *dev)
304 smsc_fdc37m81x_config_end(); 304 smsc_fdc37m81x_config_end();
305} 305}
306 306
307static void quirk_slc90e66_ide(struct pci_dev *dev) 307static void __devinit quirk_slc90e66_ide(struct pci_dev *dev)
308{ 308{
309 unsigned char dat; 309 unsigned char dat;
310 int regs[2] = {0x41, 0x43}; 310 int regs[2] = {0x41, 0x43};
@@ -339,7 +339,7 @@ static void quirk_slc90e66_ide(struct pci_dev *dev)
339} 339}
340#endif /* CONFIG_TOSHIBA_FPCIB0 */ 340#endif /* CONFIG_TOSHIBA_FPCIB0 */
341 341
342static void tc35815_fixup(struct pci_dev *dev) 342static void __devinit tc35815_fixup(struct pci_dev *dev)
343{ 343{
344 /* This device may have PM registers but not they are not suported. */ 344 /* This device may have PM registers but not they are not suported. */
345 if (dev->pm_cap) { 345 if (dev->pm_cap) {
@@ -348,7 +348,7 @@ static void tc35815_fixup(struct pci_dev *dev)
348 } 348 }
349} 349}
350 350
351static void final_fixup(struct pci_dev *dev) 351static void __devinit final_fixup(struct pci_dev *dev)
352{ 352{
353 unsigned char bist; 353 unsigned char bist;
354 354
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index ae77a7916c03..560fe8991753 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -632,7 +632,7 @@ void __init txx9_physmap_flash_init(int no, unsigned long addr,
632 unsigned long size, 632 unsigned long size,
633 const struct physmap_flash_data *pdata) 633 const struct physmap_flash_data *pdata)
634{ 634{
635#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 635#if IS_ENABLED(CONFIG_MTD_PHYSMAP)
636 struct resource res = { 636 struct resource res = {
637 .start = addr, 637 .start = addr,
638 .end = addr + size - 1, 638 .end = addr + size - 1,
@@ -670,8 +670,7 @@ void __init txx9_physmap_flash_init(int no, unsigned long addr,
670void __init txx9_ndfmc_init(unsigned long baseaddr, 670void __init txx9_ndfmc_init(unsigned long baseaddr,
671 const struct txx9ndfmc_platform_data *pdata) 671 const struct txx9ndfmc_platform_data *pdata)
672{ 672{
673#if defined(CONFIG_MTD_NAND_TXX9NDFMC) || \ 673#if IS_ENABLED(CONFIG_MTD_NAND_TXX9NDFMC)
674 defined(CONFIG_MTD_NAND_TXX9NDFMC_MODULE)
675 struct resource res = { 674 struct resource res = {
676 .start = baseaddr, 675 .start = baseaddr,
677 .end = baseaddr + 0x1000 - 1, 676 .end = baseaddr + 0x1000 - 1,
@@ -687,7 +686,7 @@ void __init txx9_ndfmc_init(unsigned long baseaddr,
687#endif 686#endif
688} 687}
689 688
690#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) 689#if IS_ENABLED(CONFIG_LEDS_GPIO)
691static DEFINE_SPINLOCK(txx9_iocled_lock); 690static DEFINE_SPINLOCK(txx9_iocled_lock);
692 691
693#define TXX9_IOCLED_MAXLEDS 8 692#define TXX9_IOCLED_MAXLEDS 8
@@ -810,7 +809,7 @@ void __init txx9_iocled_init(unsigned long baseaddr,
810void __init txx9_dmac_init(int id, unsigned long baseaddr, int irq, 809void __init txx9_dmac_init(int id, unsigned long baseaddr, int irq,
811 const struct txx9dmac_platform_data *pdata) 810 const struct txx9dmac_platform_data *pdata)
812{ 811{
813#if defined(CONFIG_TXX9_DMAC) || defined(CONFIG_TXX9_DMAC_MODULE) 812#if IS_ENABLED(CONFIG_TXX9_DMAC)
814 struct resource res[] = { 813 struct resource res[] = {
815 { 814 {
816 .start = baseaddr, 815 .start = baseaddr,
@@ -866,8 +865,7 @@ void __init txx9_aclc_init(unsigned long baseaddr, int irq,
866 unsigned int dma_chan_out, 865 unsigned int dma_chan_out,
867 unsigned int dma_chan_in) 866 unsigned int dma_chan_in)
868{ 867{
869#if defined(CONFIG_SND_SOC_TXX9ACLC) || \ 868#if IS_ENABLED(CONFIG_SND_SOC_TXX9ACLC)
870 defined(CONFIG_SND_SOC_TXX9ACLC_MODULE)
871 unsigned int dma_base = dmac_id * TXX9_DMA_MAX_NR_CHANNELS; 869 unsigned int dma_base = dmac_id * TXX9_DMA_MAX_NR_CHANNELS;
872 struct resource res[] = { 870 struct resource res[] = {
873 { 871 {
diff --git a/arch/mips/txx9/generic/setup_tx4939.c b/arch/mips/txx9/generic/setup_tx4939.c
index 6567895d1f59..5ff7a9584daf 100644
--- a/arch/mips/txx9/generic/setup_tx4939.c
+++ b/arch/mips/txx9/generic/setup_tx4939.c
@@ -317,7 +317,7 @@ void __init tx4939_sio_init(unsigned int sclk, unsigned int cts_mask)
317 } 317 }
318} 318}
319 319
320#if defined(CONFIG_TC35815) || defined(CONFIG_TC35815_MODULE) 320#if IS_ENABLED(CONFIG_TC35815)
321static u32 tx4939_get_eth_speed(struct net_device *dev) 321static u32 tx4939_get_eth_speed(struct net_device *dev)
322{ 322{
323 struct ethtool_cmd cmd; 323 struct ethtool_cmd cmd;
diff --git a/arch/mips/txx9/rbtx4939/setup.c b/arch/mips/txx9/rbtx4939/setup.c
index 2ad8973ba13d..e15641d93092 100644
--- a/arch/mips/txx9/rbtx4939/setup.c
+++ b/arch/mips/txx9/rbtx4939/setup.c
@@ -40,8 +40,7 @@ static void __init rbtx4939_time_init(void)
40 tx4939_time_init(0); 40 tx4939_time_init(0);
41} 41}
42 42
43#if defined(__BIG_ENDIAN) && \ 43#if defined(__BIG_ENDIAN) && IS_ENABLED(CONFIG_SMC91X)
44 (defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE))
45#define HAVE_RBTX4939_IOSWAB 44#define HAVE_RBTX4939_IOSWAB
46#define IS_CE1_ADDR(addr) \ 45#define IS_CE1_ADDR(addr) \
47 ((((unsigned long)(addr) - IO_BASE) & 0xfff00000) == TXX9_CE(1)) 46 ((((unsigned long)(addr) - IO_BASE) & 0xfff00000) == TXX9_CE(1))
@@ -187,7 +186,7 @@ static void __init rbtx4939_update_ioc_pen(void)
187 186
188#define RBTX4939_MAX_7SEGLEDS 8 187#define RBTX4939_MAX_7SEGLEDS 8
189 188
190#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) 189#if IS_ENABLED(CONFIG_LEDS_CLASS)
191static u8 led_val[RBTX4939_MAX_7SEGLEDS]; 190static u8 led_val[RBTX4939_MAX_7SEGLEDS];
192struct rbtx4939_led_data { 191struct rbtx4939_led_data {
193 struct led_classdev cdev; 192 struct led_classdev cdev;
@@ -263,7 +262,7 @@ static inline void rbtx4939_led_setup(void)
263 262
264static void __rbtx4939_7segled_putc(unsigned int pos, unsigned char val) 263static void __rbtx4939_7segled_putc(unsigned int pos, unsigned char val)
265{ 264{
266#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) 265#if IS_ENABLED(CONFIG_LEDS_CLASS)
267 unsigned long flags; 266 unsigned long flags;
268 local_irq_save(flags); 267 local_irq_save(flags);
269 /* bit7: reserved for LED class */ 268 /* bit7: reserved for LED class */
@@ -287,7 +286,7 @@ static void rbtx4939_7segled_putc(unsigned int pos, unsigned char val)
287 __rbtx4939_7segled_putc(pos, val); 286 __rbtx4939_7segled_putc(pos, val);
288} 287}
289 288
290#if defined(CONFIG_MTD_RBTX4939) || defined(CONFIG_MTD_RBTX4939_MODULE) 289#if IS_ENABLED(CONFIG_MTD_RBTX4939)
291/* special mapping for boot rom */ 290/* special mapping for boot rom */
292static unsigned long rbtx4939_flash_fixup_ofs(unsigned long ofs) 291static unsigned long rbtx4939_flash_fixup_ofs(unsigned long ofs)
293{ 292{
@@ -463,7 +462,7 @@ static void __init rbtx4939_device_init(void)
463 .flags = SMC91X_USE_16BIT, 462 .flags = SMC91X_USE_16BIT,
464 }; 463 };
465 struct platform_device *pdev; 464 struct platform_device *pdev;
466#if defined(CONFIG_TC35815) || defined(CONFIG_TC35815_MODULE) 465#if IS_ENABLED(CONFIG_TC35815)
467 int i, j; 466 int i, j;
468 unsigned char ethaddr[2][6]; 467 unsigned char ethaddr[2][6];
469 u8 bdipsw = readb(rbtx4939_bdipsw_addr) & 0x0f; 468 u8 bdipsw = readb(rbtx4939_bdipsw_addr) & 0x0f;
diff --git a/arch/mn10300/include/asm/ipc.h b/arch/mn10300/include/asm/ipc.h
deleted file mode 100644
index a46e3d9c2a3f..000000000000
--- a/arch/mn10300/include/asm/ipc.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/ipc.h>
diff --git a/arch/openrisc/include/asm/Kbuild b/arch/openrisc/include/asm/Kbuild
index 3f35c38d7b64..0922959663a0 100644
--- a/arch/openrisc/include/asm/Kbuild
+++ b/arch/openrisc/include/asm/Kbuild
@@ -13,7 +13,6 @@ generic-y += cacheflush.h
13generic-y += checksum.h 13generic-y += checksum.h
14generic-y += cmpxchg.h 14generic-y += cmpxchg.h
15generic-y += cmpxchg-local.h 15generic-y += cmpxchg-local.h
16generic-y += cpumask.h
17generic-y += cputime.h 16generic-y += cputime.h
18generic-y += current.h 17generic-y += current.h
19generic-y += device.h 18generic-y += device.h
@@ -43,7 +42,6 @@ generic-y += percpu.h
43generic-y += poll.h 42generic-y += poll.h
44generic-y += posix_types.h 43generic-y += posix_types.h
45generic-y += resource.h 44generic-y += resource.h
46generic-y += rmap.h
47generic-y += scatterlist.h 45generic-y += scatterlist.h
48generic-y += sections.h 46generic-y += sections.h
49generic-y += segment.h 47generic-y += segment.h
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 62678e365ca0..78160874809a 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -27,7 +27,10 @@ extern void *dma_direct_alloc_coherent(struct device *dev, size_t size,
27extern void dma_direct_free_coherent(struct device *dev, size_t size, 27extern void dma_direct_free_coherent(struct device *dev, size_t size,
28 void *vaddr, dma_addr_t dma_handle, 28 void *vaddr, dma_addr_t dma_handle,
29 struct dma_attrs *attrs); 29 struct dma_attrs *attrs);
30 30extern int dma_direct_mmap_coherent(struct device *dev,
31 struct vm_area_struct *vma,
32 void *cpu_addr, dma_addr_t handle,
33 size_t size, struct dma_attrs *attrs);
31 34
32#ifdef CONFIG_NOT_COHERENT_CACHE 35#ifdef CONFIG_NOT_COHERENT_CACHE
33/* 36/*
@@ -207,11 +210,8 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
207#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 210#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
208#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 211#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
209 212
210extern int dma_mmap_coherent(struct device *, struct vm_area_struct *,
211 void *, dma_addr_t, size_t);
212#define ARCH_HAS_DMA_MMAP_COHERENT 213#define ARCH_HAS_DMA_MMAP_COHERENT
213 214
214
215static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 215static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
216 enum dma_data_direction direction) 216 enum dma_data_direction direction)
217{ 217{
diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index bcfdcd22c766..2d7bb8ced136 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -109,6 +109,7 @@ static u64 dma_iommu_get_required_mask(struct device *dev)
109struct dma_map_ops dma_iommu_ops = { 109struct dma_map_ops dma_iommu_ops = {
110 .alloc = dma_iommu_alloc_coherent, 110 .alloc = dma_iommu_alloc_coherent,
111 .free = dma_iommu_free_coherent, 111 .free = dma_iommu_free_coherent,
112 .mmap = dma_direct_mmap_coherent,
112 .map_sg = dma_iommu_map_sg, 113 .map_sg = dma_iommu_map_sg,
113 .unmap_sg = dma_iommu_unmap_sg, 114 .unmap_sg = dma_iommu_unmap_sg,
114 .dma_supported = dma_iommu_dma_supported, 115 .dma_supported = dma_iommu_dma_supported,
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index 4ab88dafb235..46943651da23 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -49,6 +49,7 @@ static u64 swiotlb_powerpc_get_required(struct device *dev)
49struct dma_map_ops swiotlb_dma_ops = { 49struct dma_map_ops swiotlb_dma_ops = {
50 .alloc = dma_direct_alloc_coherent, 50 .alloc = dma_direct_alloc_coherent,
51 .free = dma_direct_free_coherent, 51 .free = dma_direct_free_coherent,
52 .mmap = dma_direct_mmap_coherent,
52 .map_sg = swiotlb_map_sg_attrs, 53 .map_sg = swiotlb_map_sg_attrs,
53 .unmap_sg = swiotlb_unmap_sg_attrs, 54 .unmap_sg = swiotlb_unmap_sg_attrs,
54 .dma_supported = swiotlb_dma_supported, 55 .dma_supported = swiotlb_dma_supported,
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 289be751cd75..355b9d84b0f8 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -67,6 +67,24 @@ void dma_direct_free_coherent(struct device *dev, size_t size,
67#endif 67#endif
68} 68}
69 69
70int dma_direct_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
71 void *cpu_addr, dma_addr_t handle, size_t size,
72 struct dma_attrs *attrs)
73{
74 unsigned long pfn;
75
76#ifdef CONFIG_NOT_COHERENT_CACHE
77 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
78 pfn = __dma_get_coherent_pfn((unsigned long)cpu_addr);
79#else
80 pfn = page_to_pfn(virt_to_page(cpu_addr));
81#endif
82 return remap_pfn_range(vma, vma->vm_start,
83 pfn + vma->vm_pgoff,
84 vma->vm_end - vma->vm_start,
85 vma->vm_page_prot);
86}
87
70static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, 88static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
71 int nents, enum dma_data_direction direction, 89 int nents, enum dma_data_direction direction,
72 struct dma_attrs *attrs) 90 struct dma_attrs *attrs)
@@ -156,6 +174,7 @@ static inline void dma_direct_sync_single(struct device *dev,
156struct dma_map_ops dma_direct_ops = { 174struct dma_map_ops dma_direct_ops = {
157 .alloc = dma_direct_alloc_coherent, 175 .alloc = dma_direct_alloc_coherent,
158 .free = dma_direct_free_coherent, 176 .free = dma_direct_free_coherent,
177 .mmap = dma_direct_mmap_coherent,
159 .map_sg = dma_direct_map_sg, 178 .map_sg = dma_direct_map_sg,
160 .unmap_sg = dma_direct_unmap_sg, 179 .unmap_sg = dma_direct_unmap_sg,
161 .dma_supported = dma_direct_dma_supported, 180 .dma_supported = dma_direct_dma_supported,
@@ -219,20 +238,3 @@ static int __init dma_init(void)
219} 238}
220fs_initcall(dma_init); 239fs_initcall(dma_init);
221 240
222int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
223 void *cpu_addr, dma_addr_t handle, size_t size)
224{
225 unsigned long pfn;
226
227#ifdef CONFIG_NOT_COHERENT_CACHE
228 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
229 pfn = __dma_get_coherent_pfn((unsigned long)cpu_addr);
230#else
231 pfn = page_to_pfn(virt_to_page(cpu_addr));
232#endif
233 return remap_pfn_range(vma, vma->vm_start,
234 pfn + vma->vm_pgoff,
235 vma->vm_end - vma->vm_start,
236 vma->vm_page_prot);
237}
238EXPORT_SYMBOL_GPL(dma_mmap_coherent);
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 3052a931f2b5..02b32216bbc3 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -611,6 +611,7 @@ static u64 vio_dma_get_required_mask(struct device *dev)
611struct dma_map_ops vio_dma_mapping_ops = { 611struct dma_map_ops vio_dma_mapping_ops = {
612 .alloc = vio_dma_iommu_alloc_coherent, 612 .alloc = vio_dma_iommu_alloc_coherent,
613 .free = vio_dma_iommu_free_coherent, 613 .free = vio_dma_iommu_free_coherent,
614 .mmap = dma_direct_mmap_coherent,
614 .map_sg = vio_dma_iommu_map_sg, 615 .map_sg = vio_dma_iommu_map_sg,
615 .unmap_sg = vio_dma_iommu_unmap_sg, 616 .unmap_sg = vio_dma_iommu_unmap_sg,
616 .map_page = vio_dma_iommu_map_page, 617 .map_page = vio_dma_iommu_map_page,
diff --git a/arch/tile/include/asm/Kbuild b/arch/tile/include/asm/Kbuild
index fb7c65ae8de0..5bd71994452d 100644
--- a/arch/tile/include/asm/Kbuild
+++ b/arch/tile/include/asm/Kbuild
@@ -16,7 +16,6 @@ generic-y += fb.h
16generic-y += fcntl.h 16generic-y += fcntl.h
17generic-y += ioctl.h 17generic-y += ioctl.h
18generic-y += ioctls.h 18generic-y += ioctls.h
19generic-y += ipc.h
20generic-y += ipcbuf.h 19generic-y += ipcbuf.h
21generic-y += irq_regs.h 20generic-y += irq_regs.h
22generic-y += kdebug.h 21generic-y += kdebug.h
diff --git a/arch/xtensa/include/asm/cpumask.h b/arch/xtensa/include/asm/cpumask.h
deleted file mode 100644
index ebeede397db3..000000000000
--- a/arch/xtensa/include/asm/cpumask.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/cpumask.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_CPUMASK_H
12#define _XTENSA_CPUMASK_H
13
14#include <asm-generic/cpumask.h>
15
16#endif /* _XTENSA_CPUMASK_H */
diff --git a/arch/xtensa/include/asm/rmap.h b/arch/xtensa/include/asm/rmap.h
deleted file mode 100644
index 649588b7e9ad..000000000000
--- a/arch/xtensa/include/asm/rmap.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/rmap.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_RMAP_H
12#define _XTENSA_RMAP_H
13
14#include <asm-generic/rmap.h>
15
16#endif
diff --git a/drivers/Kconfig b/drivers/Kconfig
index bfc918633fd9..805c432c9439 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -148,4 +148,6 @@ source "drivers/iio/Kconfig"
148 148
149source "drivers/vme/Kconfig" 149source "drivers/vme/Kconfig"
150 150
151source "drivers/pwm/Kconfig"
152
151endmenu 153endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 2ba29ffef2cb..bd36f09f2246 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -8,6 +8,7 @@
8# GPIO must come after pinctrl as gpios may need to mux pins etc 8# GPIO must come after pinctrl as gpios may need to mux pins etc
9obj-y += pinctrl/ 9obj-y += pinctrl/
10obj-y += gpio/ 10obj-y += gpio/
11obj-y += pwm/
11obj-$(CONFIG_PCI) += pci/ 12obj-$(CONFIG_PCI) += pci/
12obj-$(CONFIG_PARISC) += parisc/ 13obj-$(CONFIG_PARISC) += parisc/
13obj-$(CONFIG_RAPIDIO) += rapidio/ 14obj-$(CONFIG_RAPIDIO) += rapidio/
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 45d8097ef4cf..b728880ef10e 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -132,6 +132,33 @@ find_video(acpi_handle handle, u32 lvl, void *context, void **rv)
132 return AE_OK; 132 return AE_OK;
133} 133}
134 134
135/* Force to use vendor driver when the ACPI device is known to be
136 * buggy */
137static int video_detect_force_vendor(const struct dmi_system_id *d)
138{
139 acpi_video_support |= ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
140 return 0;
141}
142
143static struct dmi_system_id video_detect_dmi_table[] = {
144 /* On Samsung X360, the BIOS will set a flag (VDRV) if generic
145 * ACPI backlight device is used. This flag will definitively break
146 * the backlight interface (even the vendor interface) untill next
147 * reboot. It's why we should prevent video.ko from being used here
148 * and we can't rely on a later call to acpi_video_unregister().
149 */
150 {
151 .callback = video_detect_force_vendor,
152 .ident = "X360",
153 .matches = {
154 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
155 DMI_MATCH(DMI_PRODUCT_NAME, "X360"),
156 DMI_MATCH(DMI_BOARD_NAME, "X360"),
157 },
158 },
159 { },
160};
161
135/* 162/*
136 * Returns the video capabilities of a specific ACPI graphics device 163 * Returns the video capabilities of a specific ACPI graphics device
137 * 164 *
@@ -164,6 +191,8 @@ long acpi_video_get_capabilities(acpi_handle graphics_handle)
164 * ACPI_VIDEO_BACKLIGHT_DMI_VENDOR; 191 * ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
165 *} 192 *}
166 */ 193 */
194
195 dmi_check_system(video_detect_dmi_table);
167 } else { 196 } else {
168 status = acpi_bus_get_device(graphics_handle, &tmp_dev); 197 status = acpi_bus_get_device(graphics_handle, &tmp_dev);
169 if (ACPI_FAILURE(status)) { 198 if (ACPI_FAILURE(status)) {
@@ -182,8 +211,7 @@ long acpi_video_get_capabilities(acpi_handle graphics_handle)
182} 211}
183EXPORT_SYMBOL(acpi_video_get_capabilities); 212EXPORT_SYMBOL(acpi_video_get_capabilities);
184 213
185/* Returns true if video.ko can do backlight switching */ 214static void acpi_video_caps_check(void)
186int acpi_video_backlight_support(void)
187{ 215{
188 /* 216 /*
189 * We must check whether the ACPI graphics device is physically plugged 217 * We must check whether the ACPI graphics device is physically plugged
@@ -191,6 +219,34 @@ int acpi_video_backlight_support(void)
191 */ 219 */
192 if (!acpi_video_caps_checked) 220 if (!acpi_video_caps_checked)
193 acpi_video_get_capabilities(NULL); 221 acpi_video_get_capabilities(NULL);
222}
223
224/* Promote the vendor interface instead of the generic video module.
225 * This function allow DMI blacklists to be implemented by externals
226 * platform drivers instead of putting a big blacklist in video_detect.c
227 * After calling this function you will probably want to call
228 * acpi_video_unregister() to make sure the video module is not loaded
229 */
230void acpi_video_dmi_promote_vendor(void)
231{
232 acpi_video_caps_check();
233 acpi_video_support |= ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
234}
235EXPORT_SYMBOL(acpi_video_dmi_promote_vendor);
236
237/* To be called when a driver who previously promoted the vendor
238 * interface */
239void acpi_video_dmi_demote_vendor(void)
240{
241 acpi_video_caps_check();
242 acpi_video_support &= ~ACPI_VIDEO_BACKLIGHT_DMI_VENDOR;
243}
244EXPORT_SYMBOL(acpi_video_dmi_demote_vendor);
245
246/* Returns true if video.ko can do backlight switching */
247int acpi_video_backlight_support(void)
248{
249 acpi_video_caps_check();
194 250
195 /* First check for boot param -> highest prio */ 251 /* First check for boot param -> highest prio */
196 if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR) 252 if (acpi_video_support & ACPI_VIDEO_BACKLIGHT_FORCE_VENDOR)
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index 6f3676f1559f..3fbedc75e7c5 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -10,6 +10,7 @@
10#include <linux/dma-mapping.h> 10#include <linux/dma-mapping.h>
11#include <linux/export.h> 11#include <linux/export.h>
12#include <linux/gfp.h> 12#include <linux/gfp.h>
13#include <asm-generic/dma-coherent.h>
13 14
14/* 15/*
15 * Managed DMA API 16 * Managed DMA API
@@ -217,4 +218,52 @@ void dmam_release_declared_memory(struct device *dev)
217} 218}
218EXPORT_SYMBOL(dmam_release_declared_memory); 219EXPORT_SYMBOL(dmam_release_declared_memory);
219 220
221/*
222 * Create scatter-list for the already allocated DMA buffer.
223 */
224int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
225 void *cpu_addr, dma_addr_t handle, size_t size)
226{
227 struct page *page = virt_to_page(cpu_addr);
228 int ret;
229
230 ret = sg_alloc_table(sgt, 1, GFP_KERNEL);
231 if (unlikely(ret))
232 return ret;
233
234 sg_set_page(sgt->sgl, page, PAGE_ALIGN(size), 0);
235 return 0;
236}
237EXPORT_SYMBOL(dma_common_get_sgtable);
238
220#endif 239#endif
240
241/*
242 * Create userspace mapping for the DMA-coherent memory.
243 */
244int dma_common_mmap(struct device *dev, struct vm_area_struct *vma,
245 void *cpu_addr, dma_addr_t dma_addr, size_t size)
246{
247 int ret = -ENXIO;
248#ifdef CONFIG_MMU
249 unsigned long user_count = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
250 unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT;
251 unsigned long pfn = page_to_pfn(virt_to_page(cpu_addr));
252 unsigned long off = vma->vm_pgoff;
253
254 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
255
256 if (dma_mmap_from_coherent(dev, vma, cpu_addr, size, &ret))
257 return ret;
258
259 if (off < count && user_count <= (count - off)) {
260 ret = remap_pfn_range(vma, vma->vm_start,
261 pfn + off,
262 user_count << PAGE_SHIFT,
263 vma->vm_page_prot);
264 }
265#endif /* CONFIG_MMU */
266
267 return ret;
268}
269EXPORT_SYMBOL(dma_common_mmap);
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 693187df7601..c0bbeb470754 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -21,8 +21,6 @@ struct workqueue_struct *virtblk_wq;
21 21
22struct virtio_blk 22struct virtio_blk
23{ 23{
24 spinlock_t lock;
25
26 struct virtio_device *vdev; 24 struct virtio_device *vdev;
27 struct virtqueue *vq; 25 struct virtqueue *vq;
28 26
@@ -65,7 +63,7 @@ static void blk_done(struct virtqueue *vq)
65 unsigned int len; 63 unsigned int len;
66 unsigned long flags; 64 unsigned long flags;
67 65
68 spin_lock_irqsave(&vblk->lock, flags); 66 spin_lock_irqsave(vblk->disk->queue->queue_lock, flags);
69 while ((vbr = virtqueue_get_buf(vblk->vq, &len)) != NULL) { 67 while ((vbr = virtqueue_get_buf(vblk->vq, &len)) != NULL) {
70 int error; 68 int error;
71 69
@@ -99,7 +97,7 @@ static void blk_done(struct virtqueue *vq)
99 } 97 }
100 /* In case queue is stopped waiting for more buffers. */ 98 /* In case queue is stopped waiting for more buffers. */
101 blk_start_queue(vblk->disk->queue); 99 blk_start_queue(vblk->disk->queue);
102 spin_unlock_irqrestore(&vblk->lock, flags); 100 spin_unlock_irqrestore(vblk->disk->queue->queue_lock, flags);
103} 101}
104 102
105static bool do_req(struct request_queue *q, struct virtio_blk *vblk, 103static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
@@ -397,6 +395,83 @@ static int virtblk_name_format(char *prefix, int index, char *buf, int buflen)
397 return 0; 395 return 0;
398} 396}
399 397
398static int virtblk_get_cache_mode(struct virtio_device *vdev)
399{
400 u8 writeback;
401 int err;
402
403 err = virtio_config_val(vdev, VIRTIO_BLK_F_CONFIG_WCE,
404 offsetof(struct virtio_blk_config, wce),
405 &writeback);
406 if (err)
407 writeback = virtio_has_feature(vdev, VIRTIO_BLK_F_WCE);
408
409 return writeback;
410}
411
412static void virtblk_update_cache_mode(struct virtio_device *vdev)
413{
414 u8 writeback = virtblk_get_cache_mode(vdev);
415 struct virtio_blk *vblk = vdev->priv;
416
417 if (writeback)
418 blk_queue_flush(vblk->disk->queue, REQ_FLUSH);
419 else
420 blk_queue_flush(vblk->disk->queue, 0);
421
422 revalidate_disk(vblk->disk);
423}
424
425static const char *const virtblk_cache_types[] = {
426 "write through", "write back"
427};
428
429static ssize_t
430virtblk_cache_type_store(struct device *dev, struct device_attribute *attr,
431 const char *buf, size_t count)
432{
433 struct gendisk *disk = dev_to_disk(dev);
434 struct virtio_blk *vblk = disk->private_data;
435 struct virtio_device *vdev = vblk->vdev;
436 int i;
437 u8 writeback;
438
439 BUG_ON(!virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_CONFIG_WCE));
440 for (i = ARRAY_SIZE(virtblk_cache_types); --i >= 0; )
441 if (sysfs_streq(buf, virtblk_cache_types[i]))
442 break;
443
444 if (i < 0)
445 return -EINVAL;
446
447 writeback = i;
448 vdev->config->set(vdev,
449 offsetof(struct virtio_blk_config, wce),
450 &writeback, sizeof(writeback));
451
452 virtblk_update_cache_mode(vdev);
453 return count;
454}
455
456static ssize_t
457virtblk_cache_type_show(struct device *dev, struct device_attribute *attr,
458 char *buf)
459{
460 struct gendisk *disk = dev_to_disk(dev);
461 struct virtio_blk *vblk = disk->private_data;
462 u8 writeback = virtblk_get_cache_mode(vblk->vdev);
463
464 BUG_ON(writeback >= ARRAY_SIZE(virtblk_cache_types));
465 return snprintf(buf, 40, "%s\n", virtblk_cache_types[writeback]);
466}
467
468static const struct device_attribute dev_attr_cache_type_ro =
469 __ATTR(cache_type, S_IRUGO,
470 virtblk_cache_type_show, NULL);
471static const struct device_attribute dev_attr_cache_type_rw =
472 __ATTR(cache_type, S_IRUGO|S_IWUSR,
473 virtblk_cache_type_show, virtblk_cache_type_store);
474
400static int __devinit virtblk_probe(struct virtio_device *vdev) 475static int __devinit virtblk_probe(struct virtio_device *vdev)
401{ 476{
402 struct virtio_blk *vblk; 477 struct virtio_blk *vblk;
@@ -431,7 +506,6 @@ static int __devinit virtblk_probe(struct virtio_device *vdev)
431 goto out_free_index; 506 goto out_free_index;
432 } 507 }
433 508
434 spin_lock_init(&vblk->lock);
435 vblk->vdev = vdev; 509 vblk->vdev = vdev;
436 vblk->sg_elems = sg_elems; 510 vblk->sg_elems = sg_elems;
437 sg_init_table(vblk->sg, vblk->sg_elems); 511 sg_init_table(vblk->sg, vblk->sg_elems);
@@ -456,7 +530,7 @@ static int __devinit virtblk_probe(struct virtio_device *vdev)
456 goto out_mempool; 530 goto out_mempool;
457 } 531 }
458 532
459 q = vblk->disk->queue = blk_init_queue(do_virtblk_request, &vblk->lock); 533 q = vblk->disk->queue = blk_init_queue(do_virtblk_request, NULL);
460 if (!q) { 534 if (!q) {
461 err = -ENOMEM; 535 err = -ENOMEM;
462 goto out_put_disk; 536 goto out_put_disk;
@@ -474,8 +548,7 @@ static int __devinit virtblk_probe(struct virtio_device *vdev)
474 vblk->index = index; 548 vblk->index = index;
475 549
476 /* configure queue flush support */ 550 /* configure queue flush support */
477 if (virtio_has_feature(vdev, VIRTIO_BLK_F_FLUSH)) 551 virtblk_update_cache_mode(vdev);
478 blk_queue_flush(q, REQ_FLUSH);
479 552
480 /* If disk is read-only in the host, the guest should obey */ 553 /* If disk is read-only in the host, the guest should obey */
481 if (virtio_has_feature(vdev, VIRTIO_BLK_F_RO)) 554 if (virtio_has_feature(vdev, VIRTIO_BLK_F_RO))
@@ -553,6 +626,14 @@ static int __devinit virtblk_probe(struct virtio_device *vdev)
553 if (err) 626 if (err)
554 goto out_del_disk; 627 goto out_del_disk;
555 628
629 if (virtio_has_feature(vdev, VIRTIO_BLK_F_CONFIG_WCE))
630 err = device_create_file(disk_to_dev(vblk->disk),
631 &dev_attr_cache_type_rw);
632 else
633 err = device_create_file(disk_to_dev(vblk->disk),
634 &dev_attr_cache_type_ro);
635 if (err)
636 goto out_del_disk;
556 return 0; 637 return 0;
557 638
558out_del_disk: 639out_del_disk:
@@ -576,30 +657,20 @@ static void __devexit virtblk_remove(struct virtio_device *vdev)
576{ 657{
577 struct virtio_blk *vblk = vdev->priv; 658 struct virtio_blk *vblk = vdev->priv;
578 int index = vblk->index; 659 int index = vblk->index;
579 struct virtblk_req *vbr;
580 unsigned long flags;
581 660
582 /* Prevent config work handler from accessing the device. */ 661 /* Prevent config work handler from accessing the device. */
583 mutex_lock(&vblk->config_lock); 662 mutex_lock(&vblk->config_lock);
584 vblk->config_enable = false; 663 vblk->config_enable = false;
585 mutex_unlock(&vblk->config_lock); 664 mutex_unlock(&vblk->config_lock);
586 665
666 del_gendisk(vblk->disk);
667 blk_cleanup_queue(vblk->disk->queue);
668
587 /* Stop all the virtqueues. */ 669 /* Stop all the virtqueues. */
588 vdev->config->reset(vdev); 670 vdev->config->reset(vdev);
589 671
590 flush_work(&vblk->config_work); 672 flush_work(&vblk->config_work);
591 673
592 del_gendisk(vblk->disk);
593
594 /* Abort requests dispatched to driver. */
595 spin_lock_irqsave(&vblk->lock, flags);
596 while ((vbr = virtqueue_detach_unused_buf(vblk->vq))) {
597 __blk_end_request_all(vbr->req, -EIO);
598 mempool_free(vbr, vblk->pool);
599 }
600 spin_unlock_irqrestore(&vblk->lock, flags);
601
602 blk_cleanup_queue(vblk->disk->queue);
603 put_disk(vblk->disk); 674 put_disk(vblk->disk);
604 mempool_destroy(vblk->pool); 675 mempool_destroy(vblk->pool);
605 vdev->config->del_vqs(vdev); 676 vdev->config->del_vqs(vdev);
@@ -655,7 +726,7 @@ static const struct virtio_device_id id_table[] = {
655static unsigned int features[] = { 726static unsigned int features[] = {
656 VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, VIRTIO_BLK_F_GEOMETRY, 727 VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, VIRTIO_BLK_F_GEOMETRY,
657 VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE, VIRTIO_BLK_F_SCSI, 728 VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE, VIRTIO_BLK_F_SCSI,
658 VIRTIO_BLK_F_FLUSH, VIRTIO_BLK_F_TOPOLOGY 729 VIRTIO_BLK_F_WCE, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_CONFIG_WCE
659}; 730};
660 731
661/* 732/*
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index b01d67328243..7c0d391996b5 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -73,6 +73,20 @@ config HW_RANDOM_ATMEL
73 73
74 If unsure, say Y. 74 If unsure, say Y.
75 75
76config HW_RANDOM_BCM63XX
77 tristate "Broadcom BCM63xx Random Number Generator support"
78 depends on HW_RANDOM && BCM63XX
79 default HW_RANDOM
80 ---help---
81 This driver provides kernel-side support for the Random Number
82 Generator hardware found on the Broadcom BCM63xx SoCs.
83
84 To compile this driver as a module, choose M here: the
85 module will be called bcm63xx-rng
86
87 If unusure, say Y.
88
89
76config HW_RANDOM_GEODE 90config HW_RANDOM_GEODE
77 tristate "AMD Geode HW Random Number Generator support" 91 tristate "AMD Geode HW Random Number Generator support"
78 depends on HW_RANDOM && X86_32 && PCI 92 depends on HW_RANDOM && X86_32 && PCI
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index 8d6d173b65e6..39a757ca15b6 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_HW_RANDOM_TIMERIOMEM) += timeriomem-rng.o
8obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o 8obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o
9obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o 9obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o
10obj-$(CONFIG_HW_RANDOM_ATMEL) += atmel-rng.o 10obj-$(CONFIG_HW_RANDOM_ATMEL) += atmel-rng.o
11obj-$(CONFIG_HW_RANDOM_BCM63XX) += bcm63xx-rng.o
11obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o 12obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o
12obj-$(CONFIG_HW_RANDOM_N2RNG) += n2-rng.o 13obj-$(CONFIG_HW_RANDOM_N2RNG) += n2-rng.o
13n2-rng-y := n2-drv.o n2-asm.o 14n2-rng-y := n2-drv.o n2-asm.o
diff --git a/drivers/char/hw_random/bcm63xx-rng.c b/drivers/char/hw_random/bcm63xx-rng.c
new file mode 100644
index 000000000000..aec6a4277caa
--- /dev/null
+++ b/drivers/char/hw_random/bcm63xx-rng.c
@@ -0,0 +1,175 @@
1/*
2 * Broadcom BCM63xx Random Number Generator support
3 *
4 * Copyright (C) 2011, Florian Fainelli <florian@openwrt.org>
5 * Copyright (C) 2009, Broadcom Corporation
6 *
7 */
8#include <linux/module.h>
9#include <linux/slab.h>
10#include <linux/io.h>
11#include <linux/err.h>
12#include <linux/clk.h>
13#include <linux/platform_device.h>
14#include <linux/hw_random.h>
15
16#include <bcm63xx_io.h>
17#include <bcm63xx_regs.h>
18
19struct bcm63xx_rng_priv {
20 struct clk *clk;
21 void __iomem *regs;
22};
23
24#define to_rng_priv(rng) ((struct bcm63xx_rng_priv *)rng->priv)
25
26static int bcm63xx_rng_init(struct hwrng *rng)
27{
28 struct bcm63xx_rng_priv *priv = to_rng_priv(rng);
29 u32 val;
30
31 val = bcm_readl(priv->regs + RNG_CTRL);
32 val |= RNG_EN;
33 bcm_writel(val, priv->regs + RNG_CTRL);
34
35 return 0;
36}
37
38static void bcm63xx_rng_cleanup(struct hwrng *rng)
39{
40 struct bcm63xx_rng_priv *priv = to_rng_priv(rng);
41 u32 val;
42
43 val = bcm_readl(priv->regs + RNG_CTRL);
44 val &= ~RNG_EN;
45 bcm_writel(val, priv->regs + RNG_CTRL);
46}
47
48static int bcm63xx_rng_data_present(struct hwrng *rng, int wait)
49{
50 struct bcm63xx_rng_priv *priv = to_rng_priv(rng);
51
52 return bcm_readl(priv->regs + RNG_STAT) & RNG_AVAIL_MASK;
53}
54
55static int bcm63xx_rng_data_read(struct hwrng *rng, u32 *data)
56{
57 struct bcm63xx_rng_priv *priv = to_rng_priv(rng);
58
59 *data = bcm_readl(priv->regs + RNG_DATA);
60
61 return 4;
62}
63
64static int __devinit bcm63xx_rng_probe(struct platform_device *pdev)
65{
66 struct resource *r;
67 struct clk *clk;
68 int ret;
69 struct bcm63xx_rng_priv *priv;
70 struct hwrng *rng;
71
72 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
73 if (!r) {
74 dev_err(&pdev->dev, "no iomem resource\n");
75 ret = -ENXIO;
76 goto out;
77 }
78
79 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
80 if (!priv) {
81 dev_err(&pdev->dev, "no memory for private structure\n");
82 ret = -ENOMEM;
83 goto out;
84 }
85
86 rng = kzalloc(sizeof(*rng), GFP_KERNEL);
87 if (!rng) {
88 dev_err(&pdev->dev, "no memory for rng structure\n");
89 ret = -ENOMEM;
90 goto out_free_priv;
91 }
92
93 platform_set_drvdata(pdev, rng);
94 rng->priv = (unsigned long)priv;
95 rng->name = pdev->name;
96 rng->init = bcm63xx_rng_init;
97 rng->cleanup = bcm63xx_rng_cleanup;
98 rng->data_present = bcm63xx_rng_data_present;
99 rng->data_read = bcm63xx_rng_data_read;
100
101 clk = clk_get(&pdev->dev, "ipsec");
102 if (IS_ERR(clk)) {
103 dev_err(&pdev->dev, "no clock for device\n");
104 ret = PTR_ERR(clk);
105 goto out_free_rng;
106 }
107
108 priv->clk = clk;
109
110 if (!devm_request_mem_region(&pdev->dev, r->start,
111 resource_size(r), pdev->name)) {
112 dev_err(&pdev->dev, "request mem failed");
113 ret = -ENOMEM;
114 goto out_free_rng;
115 }
116
117 priv->regs = devm_ioremap_nocache(&pdev->dev, r->start,
118 resource_size(r));
119 if (!priv->regs) {
120 dev_err(&pdev->dev, "ioremap failed");
121 ret = -ENOMEM;
122 goto out_free_rng;
123 }
124
125 clk_enable(clk);
126
127 ret = hwrng_register(rng);
128 if (ret) {
129 dev_err(&pdev->dev, "failed to register rng device\n");
130 goto out_clk_disable;
131 }
132
133 dev_info(&pdev->dev, "registered RNG driver\n");
134
135 return 0;
136
137out_clk_disable:
138 clk_disable(clk);
139out_free_rng:
140 platform_set_drvdata(pdev, NULL);
141 kfree(rng);
142out_free_priv:
143 kfree(priv);
144out:
145 return ret;
146}
147
148static int __devexit bcm63xx_rng_remove(struct platform_device *pdev)
149{
150 struct hwrng *rng = platform_get_drvdata(pdev);
151 struct bcm63xx_rng_priv *priv = to_rng_priv(rng);
152
153 hwrng_unregister(rng);
154 clk_disable(priv->clk);
155 kfree(priv);
156 kfree(rng);
157 platform_set_drvdata(pdev, NULL);
158
159 return 0;
160}
161
162static struct platform_driver bcm63xx_rng_driver = {
163 .probe = bcm63xx_rng_probe,
164 .remove = __devexit_p(bcm63xx_rng_remove),
165 .driver = {
166 .name = "bcm63xx-rng",
167 .owner = THIS_MODULE,
168 },
169};
170
171module_platform_driver(bcm63xx_rng_driver);
172
173MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
174MODULE_DESCRIPTION("Broadcom BCM63xx RNG driver");
175MODULE_LICENSE("GPL");
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index 723725bbb96b..5708299507d0 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -55,6 +55,7 @@ static void register_buffer(u8 *buf, size_t size)
55 55
56static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait) 56static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
57{ 57{
58 int ret;
58 59
59 if (!busy) { 60 if (!busy) {
60 busy = true; 61 busy = true;
@@ -65,7 +66,9 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
65 if (!wait) 66 if (!wait)
66 return 0; 67 return 0;
67 68
68 wait_for_completion(&have_data); 69 ret = wait_for_completion_killable(&have_data);
70 if (ret < 0)
71 return ret;
69 72
70 busy = false; 73 busy = false;
71 74
@@ -85,7 +88,7 @@ static struct hwrng virtio_hwrng = {
85 .read = virtio_read, 88 .read = virtio_read,
86}; 89};
87 90
88static int virtrng_probe(struct virtio_device *vdev) 91static int probe_common(struct virtio_device *vdev)
89{ 92{
90 int err; 93 int err;
91 94
@@ -103,13 +106,37 @@ static int virtrng_probe(struct virtio_device *vdev)
103 return 0; 106 return 0;
104} 107}
105 108
106static void __devexit virtrng_remove(struct virtio_device *vdev) 109static void remove_common(struct virtio_device *vdev)
107{ 110{
108 vdev->config->reset(vdev); 111 vdev->config->reset(vdev);
112 busy = false;
109 hwrng_unregister(&virtio_hwrng); 113 hwrng_unregister(&virtio_hwrng);
110 vdev->config->del_vqs(vdev); 114 vdev->config->del_vqs(vdev);
111} 115}
112 116
117static int virtrng_probe(struct virtio_device *vdev)
118{
119 return probe_common(vdev);
120}
121
122static void __devexit virtrng_remove(struct virtio_device *vdev)
123{
124 remove_common(vdev);
125}
126
127#ifdef CONFIG_PM
128static int virtrng_freeze(struct virtio_device *vdev)
129{
130 remove_common(vdev);
131 return 0;
132}
133
134static int virtrng_restore(struct virtio_device *vdev)
135{
136 return probe_common(vdev);
137}
138#endif
139
113static struct virtio_device_id id_table[] = { 140static struct virtio_device_id id_table[] = {
114 { VIRTIO_ID_RNG, VIRTIO_DEV_ANY_ID }, 141 { VIRTIO_ID_RNG, VIRTIO_DEV_ANY_ID },
115 { 0 }, 142 { 0 },
@@ -121,6 +148,10 @@ static struct virtio_driver virtio_rng_driver = {
121 .id_table = id_table, 148 .id_table = id_table,
122 .probe = virtrng_probe, 149 .probe = virtrng_probe,
123 .remove = __devexit_p(virtrng_remove), 150 .remove = __devexit_p(virtrng_remove),
151#ifdef CONFIG_PM
152 .freeze = virtrng_freeze,
153 .restore = virtrng_restore,
154#endif
124}; 155};
125 156
126static int __init init(void) 157static int __init init(void)
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c
index 8b78750f1efe..845f97fd1832 100644
--- a/drivers/char/mspec.c
+++ b/drivers/char/mspec.c
@@ -283,7 +283,7 @@ mspec_mmap(struct file *file, struct vm_area_struct *vma,
283 vdata->flags = flags; 283 vdata->flags = flags;
284 vdata->type = type; 284 vdata->type = type;
285 spin_lock_init(&vdata->lock); 285 spin_lock_init(&vdata->lock);
286 vdata->refcnt = ATOMIC_INIT(1); 286 atomic_set(&vdata->refcnt, 1);
287 vma->vm_private_data = vdata; 287 vma->vm_private_data = vdata;
288 288
289 vma->vm_flags |= (VM_IO | VM_RESERVED | VM_PFNMAP | VM_DONTEXPAND); 289 vma->vm_flags |= (VM_IO | VM_RESERVED | VM_PFNMAP | VM_DONTEXPAND);
diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index a88331644ebf..e64c253cb169 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -65,20 +65,20 @@ static unsigned int clkdiv_cpu0_5250[CPUFREQ_LEVEL_END][8] = {
65 * Clock divider value for following 65 * Clock divider value for following
66 * { ARM, CPUD, ACP, PERIPH, ATB, PCLK_DBG, APLL, ARM2 } 66 * { ARM, CPUD, ACP, PERIPH, ATB, PCLK_DBG, APLL, ARM2 }
67 */ 67 */
68 { 0, 3, 7, 7, 6, 1, 3, 0 }, /* 1700 MHz - N/A */ 68 { 0, 3, 7, 7, 7, 3, 5, 0 }, /* 1700 MHz */
69 { 0, 3, 7, 7, 6, 1, 3, 0 }, /* 1600 MHz - N/A */ 69 { 0, 3, 7, 7, 7, 1, 4, 0 }, /* 1600 MHz */
70 { 0, 3, 7, 7, 5, 1, 3, 0 }, /* 1500 MHz - N/A */ 70 { 0, 2, 7, 7, 7, 1, 4, 0 }, /* 1500 MHz */
71 { 0, 3, 7, 7, 6, 1, 3, 0 }, /* 1400 MHz */ 71 { 0, 2, 7, 7, 6, 1, 4, 0 }, /* 1400 MHz */
72 { 0, 3, 7, 7, 6, 1, 3, 0 }, /* 1300 MHz */ 72 { 0, 2, 7, 7, 6, 1, 3, 0 }, /* 1300 MHz */
73 { 0, 3, 7, 7, 5, 1, 3, 0 }, /* 1200 MHz */ 73 { 0, 2, 7, 7, 5, 1, 3, 0 }, /* 1200 MHz */
74 { 0, 2, 7, 7, 5, 1, 2, 0 }, /* 1100 MHz */ 74 { 0, 3, 7, 7, 5, 1, 3, 0 }, /* 1100 MHz */
75 { 0, 2, 7, 7, 4, 1, 2, 0 }, /* 1000 MHz */ 75 { 0, 1, 7, 7, 4, 1, 2, 0 }, /* 1000 MHz */
76 { 0, 2, 7, 7, 4, 1, 2, 0 }, /* 900 MHz */ 76 { 0, 1, 7, 7, 4, 1, 2, 0 }, /* 900 MHz */
77 { 0, 2, 7, 7, 3, 1, 1, 0 }, /* 800 MHz */ 77 { 0, 1, 7, 7, 4, 1, 2, 0 }, /* 800 MHz */
78 { 0, 1, 7, 7, 3, 1, 1, 0 }, /* 700 MHz */ 78 { 0, 1, 7, 7, 3, 1, 1, 0 }, /* 700 MHz */
79 { 0, 1, 7, 7, 2, 1, 1, 0 }, /* 600 MHz */ 79 { 0, 1, 7, 7, 3, 1, 1, 0 }, /* 600 MHz */
80 { 0, 1, 7, 7, 2, 1, 1, 0 }, /* 500 MHz */ 80 { 0, 1, 7, 7, 2, 1, 1, 0 }, /* 500 MHz */
81 { 0, 1, 7, 7, 1, 1, 1, 0 }, /* 400 MHz */ 81 { 0, 1, 7, 7, 2, 1, 1, 0 }, /* 400 MHz */
82 { 0, 1, 7, 7, 1, 1, 1, 0 }, /* 300 MHz */ 82 { 0, 1, 7, 7, 1, 1, 1, 0 }, /* 300 MHz */
83 { 0, 1, 7, 7, 1, 1, 1, 0 }, /* 200 MHz */ 83 { 0, 1, 7, 7, 1, 1, 1, 0 }, /* 200 MHz */
84}; 84};
@@ -87,9 +87,9 @@ static unsigned int clkdiv_cpu1_5250[CPUFREQ_LEVEL_END][2] = {
87 /* Clock divider value for following 87 /* Clock divider value for following
88 * { COPY, HPM } 88 * { COPY, HPM }
89 */ 89 */
90 { 0, 2 }, /* 1700 MHz - N/A */ 90 { 0, 2 }, /* 1700 MHz */
91 { 0, 2 }, /* 1600 MHz - N/A */ 91 { 0, 2 }, /* 1600 MHz */
92 { 0, 2 }, /* 1500 MHz - N/A */ 92 { 0, 2 }, /* 1500 MHz */
93 { 0, 2 }, /* 1400 MHz */ 93 { 0, 2 }, /* 1400 MHz */
94 { 0, 2 }, /* 1300 MHz */ 94 { 0, 2 }, /* 1300 MHz */
95 { 0, 2 }, /* 1200 MHz */ 95 { 0, 2 }, /* 1200 MHz */
@@ -106,10 +106,10 @@ static unsigned int clkdiv_cpu1_5250[CPUFREQ_LEVEL_END][2] = {
106}; 106};
107 107
108static unsigned int exynos5_apll_pms_table[CPUFREQ_LEVEL_END] = { 108static unsigned int exynos5_apll_pms_table[CPUFREQ_LEVEL_END] = {
109 (0), /* 1700 MHz - N/A */ 109 ((425 << 16) | (6 << 8) | 0), /* 1700 MHz */
110 (0), /* 1600 MHz - N/A */ 110 ((200 << 16) | (3 << 8) | 0), /* 1600 MHz */
111 (0), /* 1500 MHz - N/A */ 111 ((250 << 16) | (4 << 8) | 0), /* 1500 MHz */
112 (0), /* 1400 MHz */ 112 ((175 << 16) | (3 << 8) | 0), /* 1400 MHz */
113 ((325 << 16) | (6 << 8) | 0), /* 1300 MHz */ 113 ((325 << 16) | (6 << 8) | 0), /* 1300 MHz */
114 ((200 << 16) | (4 << 8) | 0), /* 1200 MHz */ 114 ((200 << 16) | (4 << 8) | 0), /* 1200 MHz */
115 ((275 << 16) | (6 << 8) | 0), /* 1100 MHz */ 115 ((275 << 16) | (6 << 8) | 0), /* 1100 MHz */
@@ -126,9 +126,10 @@ static unsigned int exynos5_apll_pms_table[CPUFREQ_LEVEL_END] = {
126 126
127/* ASV group voltage table */ 127/* ASV group voltage table */
128static const unsigned int asv_voltage_5250[CPUFREQ_LEVEL_END] = { 128static const unsigned int asv_voltage_5250[CPUFREQ_LEVEL_END] = {
129 0, 0, 0, 0, 0, 0, 0, /* 1700 MHz ~ 1100 MHz Not supported */ 129 1300000, 1250000, 1225000, 1200000, 1150000,
130 1175000, 1125000, 1075000, 1050000, 1000000, 130 1125000, 1100000, 1075000, 1050000, 1025000,
131 950000, 925000, 925000, 900000 131 1012500, 1000000, 975000, 950000, 937500,
132 925000
132}; 133};
133 134
134static void set_clkdiv(unsigned int div_index) 135static void set_clkdiv(unsigned int div_index)
@@ -248,15 +249,7 @@ static void __init set_volt_table(void)
248{ 249{
249 unsigned int i; 250 unsigned int i;
250 251
251 exynos5250_freq_table[L0].frequency = CPUFREQ_ENTRY_INVALID; 252 max_support_idx = L0;
252 exynos5250_freq_table[L1].frequency = CPUFREQ_ENTRY_INVALID;
253 exynos5250_freq_table[L2].frequency = CPUFREQ_ENTRY_INVALID;
254 exynos5250_freq_table[L3].frequency = CPUFREQ_ENTRY_INVALID;
255 exynos5250_freq_table[L4].frequency = CPUFREQ_ENTRY_INVALID;
256 exynos5250_freq_table[L5].frequency = CPUFREQ_ENTRY_INVALID;
257 exynos5250_freq_table[L6].frequency = CPUFREQ_ENTRY_INVALID;
258
259 max_support_idx = L7;
260 253
261 for (i = 0 ; i < CPUFREQ_LEVEL_END ; i++) 254 for (i = 0 ; i < CPUFREQ_LEVEL_END ; i++)
262 exynos5250_volt_table[i] = asv_voltage_5250[i]; 255 exynos5250_volt_table[i] = asv_voltage_5250[i];
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index fdffa1beca17..409b92b8d346 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -7,7 +7,7 @@
7menuconfig EDAC 7menuconfig EDAC
8 bool "EDAC (Error Detection And Correction) reporting" 8 bool "EDAC (Error Detection And Correction) reporting"
9 depends on HAS_IOMEM 9 depends on HAS_IOMEM
10 depends on X86 || PPC || TILE 10 depends on X86 || PPC || TILE || ARM
11 help 11 help
12 EDAC is designed to report errors in the core system. 12 EDAC is designed to report errors in the core system.
13 These are low-level errors that are reported in the CPU or 13 These are low-level errors that are reported in the CPU or
@@ -31,6 +31,14 @@ if EDAC
31 31
32comment "Reporting subsystems" 32comment "Reporting subsystems"
33 33
34config EDAC_LEGACY_SYSFS
35 bool "EDAC legacy sysfs"
36 default y
37 help
38 Enable the compatibility sysfs nodes.
39 Use 'Y' if your edac utilities aren't ported to work with the newer
40 structures.
41
34config EDAC_DEBUG 42config EDAC_DEBUG
35 bool "Debugging" 43 bool "Debugging"
36 help 44 help
@@ -294,4 +302,18 @@ config EDAC_TILE
294 Support for error detection and correction on the 302 Support for error detection and correction on the
295 Tilera memory controller. 303 Tilera memory controller.
296 304
305config EDAC_HIGHBANK_MC
306 tristate "Highbank Memory Controller"
307 depends on EDAC_MM_EDAC && ARCH_HIGHBANK
308 help
309 Support for error detection and correction on the
310 Calxeda Highbank memory controller.
311
312config EDAC_HIGHBANK_L2
313 tristate "Highbank L2 Cache"
314 depends on EDAC_MM_EDAC && ARCH_HIGHBANK
315 help
316 Support for error detection and correction on the
317 Calxeda Highbank memory controller.
318
297endif # EDAC 319endif # EDAC
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 196a63dd37c5..7e5129a733f8 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -55,3 +55,6 @@ obj-$(CONFIG_EDAC_AMD8111) += amd8111_edac.o
55obj-$(CONFIG_EDAC_AMD8131) += amd8131_edac.o 55obj-$(CONFIG_EDAC_AMD8131) += amd8131_edac.o
56 56
57obj-$(CONFIG_EDAC_TILE) += tile_edac.o 57obj-$(CONFIG_EDAC_TILE) += tile_edac.o
58
59obj-$(CONFIG_EDAC_HIGHBANK_MC) += highbank_mc_edac.o
60obj-$(CONFIG_EDAC_HIGHBANK_L2) += highbank_l2_edac.o
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 7be9b7288e90..5a297a26211d 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -321,8 +321,8 @@ found:
321 return edac_mc_find((int)node_id); 321 return edac_mc_find((int)node_id);
322 322
323err_no_match: 323err_no_match:
324 debugf2("sys_addr 0x%lx doesn't match any node\n", 324 edac_dbg(2, "sys_addr 0x%lx doesn't match any node\n",
325 (unsigned long)sys_addr); 325 (unsigned long)sys_addr);
326 326
327 return NULL; 327 return NULL;
328} 328}
@@ -393,15 +393,15 @@ static int input_addr_to_csrow(struct mem_ctl_info *mci, u64 input_addr)
393 mask = ~mask; 393 mask = ~mask;
394 394
395 if ((input_addr & mask) == (base & mask)) { 395 if ((input_addr & mask) == (base & mask)) {
396 debugf2("InputAddr 0x%lx matches csrow %d (node %d)\n", 396 edac_dbg(2, "InputAddr 0x%lx matches csrow %d (node %d)\n",
397 (unsigned long)input_addr, csrow, 397 (unsigned long)input_addr, csrow,
398 pvt->mc_node_id); 398 pvt->mc_node_id);
399 399
400 return csrow; 400 return csrow;
401 } 401 }
402 } 402 }
403 debugf2("no matching csrow for InputAddr 0x%lx (MC node %d)\n", 403 edac_dbg(2, "no matching csrow for InputAddr 0x%lx (MC node %d)\n",
404 (unsigned long)input_addr, pvt->mc_node_id); 404 (unsigned long)input_addr, pvt->mc_node_id);
405 405
406 return -1; 406 return -1;
407} 407}
@@ -430,20 +430,20 @@ int amd64_get_dram_hole_info(struct mem_ctl_info *mci, u64 *hole_base,
430 430
431 /* only revE and later have the DRAM Hole Address Register */ 431 /* only revE and later have the DRAM Hole Address Register */
432 if (boot_cpu_data.x86 == 0xf && pvt->ext_model < K8_REV_E) { 432 if (boot_cpu_data.x86 == 0xf && pvt->ext_model < K8_REV_E) {
433 debugf1(" revision %d for node %d does not support DHAR\n", 433 edac_dbg(1, " revision %d for node %d does not support DHAR\n",
434 pvt->ext_model, pvt->mc_node_id); 434 pvt->ext_model, pvt->mc_node_id);
435 return 1; 435 return 1;
436 } 436 }
437 437
438 /* valid for Fam10h and above */ 438 /* valid for Fam10h and above */
439 if (boot_cpu_data.x86 >= 0x10 && !dhar_mem_hoist_valid(pvt)) { 439 if (boot_cpu_data.x86 >= 0x10 && !dhar_mem_hoist_valid(pvt)) {
440 debugf1(" Dram Memory Hoisting is DISABLED on this system\n"); 440 edac_dbg(1, " Dram Memory Hoisting is DISABLED on this system\n");
441 return 1; 441 return 1;
442 } 442 }
443 443
444 if (!dhar_valid(pvt)) { 444 if (!dhar_valid(pvt)) {
445 debugf1(" Dram Memory Hoisting is DISABLED on this node %d\n", 445 edac_dbg(1, " Dram Memory Hoisting is DISABLED on this node %d\n",
446 pvt->mc_node_id); 446 pvt->mc_node_id);
447 return 1; 447 return 1;
448 } 448 }
449 449
@@ -475,9 +475,9 @@ int amd64_get_dram_hole_info(struct mem_ctl_info *mci, u64 *hole_base,
475 else 475 else
476 *hole_offset = k8_dhar_offset(pvt); 476 *hole_offset = k8_dhar_offset(pvt);
477 477
478 debugf1(" DHAR info for node %d base 0x%lx offset 0x%lx size 0x%lx\n", 478 edac_dbg(1, " DHAR info for node %d base 0x%lx offset 0x%lx size 0x%lx\n",
479 pvt->mc_node_id, (unsigned long)*hole_base, 479 pvt->mc_node_id, (unsigned long)*hole_base,
480 (unsigned long)*hole_offset, (unsigned long)*hole_size); 480 (unsigned long)*hole_offset, (unsigned long)*hole_size);
481 481
482 return 0; 482 return 0;
483} 483}
@@ -528,10 +528,9 @@ static u64 sys_addr_to_dram_addr(struct mem_ctl_info *mci, u64 sys_addr)
528 /* use DHAR to translate SysAddr to DramAddr */ 528 /* use DHAR to translate SysAddr to DramAddr */
529 dram_addr = sys_addr - hole_offset; 529 dram_addr = sys_addr - hole_offset;
530 530
531 debugf2("using DHAR to translate SysAddr 0x%lx to " 531 edac_dbg(2, "using DHAR to translate SysAddr 0x%lx to DramAddr 0x%lx\n",
532 "DramAddr 0x%lx\n", 532 (unsigned long)sys_addr,
533 (unsigned long)sys_addr, 533 (unsigned long)dram_addr);
534 (unsigned long)dram_addr);
535 534
536 return dram_addr; 535 return dram_addr;
537 } 536 }
@@ -548,9 +547,8 @@ static u64 sys_addr_to_dram_addr(struct mem_ctl_info *mci, u64 sys_addr)
548 */ 547 */
549 dram_addr = (sys_addr & GENMASK(0, 39)) - dram_base; 548 dram_addr = (sys_addr & GENMASK(0, 39)) - dram_base;
550 549
551 debugf2("using DRAM Base register to translate SysAddr 0x%lx to " 550 edac_dbg(2, "using DRAM Base register to translate SysAddr 0x%lx to DramAddr 0x%lx\n",
552 "DramAddr 0x%lx\n", (unsigned long)sys_addr, 551 (unsigned long)sys_addr, (unsigned long)dram_addr);
553 (unsigned long)dram_addr);
554 return dram_addr; 552 return dram_addr;
555} 553}
556 554
@@ -586,9 +584,9 @@ static u64 dram_addr_to_input_addr(struct mem_ctl_info *mci, u64 dram_addr)
586 input_addr = ((dram_addr >> intlv_shift) & GENMASK(12, 35)) + 584 input_addr = ((dram_addr >> intlv_shift) & GENMASK(12, 35)) +
587 (dram_addr & 0xfff); 585 (dram_addr & 0xfff);
588 586
589 debugf2(" Intlv Shift=%d DramAddr=0x%lx maps to InputAddr=0x%lx\n", 587 edac_dbg(2, " Intlv Shift=%d DramAddr=0x%lx maps to InputAddr=0x%lx\n",
590 intlv_shift, (unsigned long)dram_addr, 588 intlv_shift, (unsigned long)dram_addr,
591 (unsigned long)input_addr); 589 (unsigned long)input_addr);
592 590
593 return input_addr; 591 return input_addr;
594} 592}
@@ -604,8 +602,8 @@ static u64 sys_addr_to_input_addr(struct mem_ctl_info *mci, u64 sys_addr)
604 input_addr = 602 input_addr =
605 dram_addr_to_input_addr(mci, sys_addr_to_dram_addr(mci, sys_addr)); 603 dram_addr_to_input_addr(mci, sys_addr_to_dram_addr(mci, sys_addr));
606 604
607 debugf2("SysAdddr 0x%lx translates to InputAddr 0x%lx\n", 605 edac_dbg(2, "SysAdddr 0x%lx translates to InputAddr 0x%lx\n",
608 (unsigned long)sys_addr, (unsigned long)input_addr); 606 (unsigned long)sys_addr, (unsigned long)input_addr);
609 607
610 return input_addr; 608 return input_addr;
611} 609}
@@ -637,8 +635,8 @@ static u64 input_addr_to_dram_addr(struct mem_ctl_info *mci, u64 input_addr)
637 635
638 intlv_shift = num_node_interleave_bits(dram_intlv_en(pvt, 0)); 636 intlv_shift = num_node_interleave_bits(dram_intlv_en(pvt, 0));
639 if (intlv_shift == 0) { 637 if (intlv_shift == 0) {
640 debugf1(" InputAddr 0x%lx translates to DramAddr of " 638 edac_dbg(1, " InputAddr 0x%lx translates to DramAddr of same value\n",
641 "same value\n", (unsigned long)input_addr); 639 (unsigned long)input_addr);
642 640
643 return input_addr; 641 return input_addr;
644 } 642 }
@@ -649,9 +647,9 @@ static u64 input_addr_to_dram_addr(struct mem_ctl_info *mci, u64 input_addr)
649 intlv_sel = dram_intlv_sel(pvt, node_id) & ((1 << intlv_shift) - 1); 647 intlv_sel = dram_intlv_sel(pvt, node_id) & ((1 << intlv_shift) - 1);
650 dram_addr = bits + (intlv_sel << 12); 648 dram_addr = bits + (intlv_sel << 12);
651 649
652 debugf1("InputAddr 0x%lx translates to DramAddr 0x%lx " 650 edac_dbg(1, "InputAddr 0x%lx translates to DramAddr 0x%lx (%d node interleave bits)\n",
653 "(%d node interleave bits)\n", (unsigned long)input_addr, 651 (unsigned long)input_addr,
654 (unsigned long)dram_addr, intlv_shift); 652 (unsigned long)dram_addr, intlv_shift);
655 653
656 return dram_addr; 654 return dram_addr;
657} 655}
@@ -673,9 +671,9 @@ static u64 dram_addr_to_sys_addr(struct mem_ctl_info *mci, u64 dram_addr)
673 (dram_addr < (hole_base + hole_size))) { 671 (dram_addr < (hole_base + hole_size))) {
674 sys_addr = dram_addr + hole_offset; 672 sys_addr = dram_addr + hole_offset;
675 673
676 debugf1("using DHAR to translate DramAddr 0x%lx to " 674 edac_dbg(1, "using DHAR to translate DramAddr 0x%lx to SysAddr 0x%lx\n",
677 "SysAddr 0x%lx\n", (unsigned long)dram_addr, 675 (unsigned long)dram_addr,
678 (unsigned long)sys_addr); 676 (unsigned long)sys_addr);
679 677
680 return sys_addr; 678 return sys_addr;
681 } 679 }
@@ -697,9 +695,9 @@ static u64 dram_addr_to_sys_addr(struct mem_ctl_info *mci, u64 dram_addr)
697 */ 695 */
698 sys_addr |= ~((sys_addr & (1ull << 39)) - 1); 696 sys_addr |= ~((sys_addr & (1ull << 39)) - 1);
699 697
700 debugf1(" Node %d, DramAddr 0x%lx to SysAddr 0x%lx\n", 698 edac_dbg(1, " Node %d, DramAddr 0x%lx to SysAddr 0x%lx\n",
701 pvt->mc_node_id, (unsigned long)dram_addr, 699 pvt->mc_node_id, (unsigned long)dram_addr,
702 (unsigned long)sys_addr); 700 (unsigned long)sys_addr);
703 701
704 return sys_addr; 702 return sys_addr;
705} 703}
@@ -768,49 +766,48 @@ static void amd64_debug_display_dimm_sizes(struct amd64_pvt *, u8);
768 766
769static void amd64_dump_dramcfg_low(u32 dclr, int chan) 767static void amd64_dump_dramcfg_low(u32 dclr, int chan)
770{ 768{
771 debugf1("F2x%d90 (DRAM Cfg Low): 0x%08x\n", chan, dclr); 769 edac_dbg(1, "F2x%d90 (DRAM Cfg Low): 0x%08x\n", chan, dclr);
772 770
773 debugf1(" DIMM type: %sbuffered; all DIMMs support ECC: %s\n", 771 edac_dbg(1, " DIMM type: %sbuffered; all DIMMs support ECC: %s\n",
774 (dclr & BIT(16)) ? "un" : "", 772 (dclr & BIT(16)) ? "un" : "",
775 (dclr & BIT(19)) ? "yes" : "no"); 773 (dclr & BIT(19)) ? "yes" : "no");
776 774
777 debugf1(" PAR/ERR parity: %s\n", 775 edac_dbg(1, " PAR/ERR parity: %s\n",
778 (dclr & BIT(8)) ? "enabled" : "disabled"); 776 (dclr & BIT(8)) ? "enabled" : "disabled");
779 777
780 if (boot_cpu_data.x86 == 0x10) 778 if (boot_cpu_data.x86 == 0x10)
781 debugf1(" DCT 128bit mode width: %s\n", 779 edac_dbg(1, " DCT 128bit mode width: %s\n",
782 (dclr & BIT(11)) ? "128b" : "64b"); 780 (dclr & BIT(11)) ? "128b" : "64b");
783 781
784 debugf1(" x4 logical DIMMs present: L0: %s L1: %s L2: %s L3: %s\n", 782 edac_dbg(1, " x4 logical DIMMs present: L0: %s L1: %s L2: %s L3: %s\n",
785 (dclr & BIT(12)) ? "yes" : "no", 783 (dclr & BIT(12)) ? "yes" : "no",
786 (dclr & BIT(13)) ? "yes" : "no", 784 (dclr & BIT(13)) ? "yes" : "no",
787 (dclr & BIT(14)) ? "yes" : "no", 785 (dclr & BIT(14)) ? "yes" : "no",
788 (dclr & BIT(15)) ? "yes" : "no"); 786 (dclr & BIT(15)) ? "yes" : "no");
789} 787}
790 788
791/* Display and decode various NB registers for debug purposes. */ 789/* Display and decode various NB registers for debug purposes. */
792static void dump_misc_regs(struct amd64_pvt *pvt) 790static void dump_misc_regs(struct amd64_pvt *pvt)
793{ 791{
794 debugf1("F3xE8 (NB Cap): 0x%08x\n", pvt->nbcap); 792 edac_dbg(1, "F3xE8 (NB Cap): 0x%08x\n", pvt->nbcap);
795 793
796 debugf1(" NB two channel DRAM capable: %s\n", 794 edac_dbg(1, " NB two channel DRAM capable: %s\n",
797 (pvt->nbcap & NBCAP_DCT_DUAL) ? "yes" : "no"); 795 (pvt->nbcap & NBCAP_DCT_DUAL) ? "yes" : "no");
798 796
799 debugf1(" ECC capable: %s, ChipKill ECC capable: %s\n", 797 edac_dbg(1, " ECC capable: %s, ChipKill ECC capable: %s\n",
800 (pvt->nbcap & NBCAP_SECDED) ? "yes" : "no", 798 (pvt->nbcap & NBCAP_SECDED) ? "yes" : "no",
801 (pvt->nbcap & NBCAP_CHIPKILL) ? "yes" : "no"); 799 (pvt->nbcap & NBCAP_CHIPKILL) ? "yes" : "no");
802 800
803 amd64_dump_dramcfg_low(pvt->dclr0, 0); 801 amd64_dump_dramcfg_low(pvt->dclr0, 0);
804 802
805 debugf1("F3xB0 (Online Spare): 0x%08x\n", pvt->online_spare); 803 edac_dbg(1, "F3xB0 (Online Spare): 0x%08x\n", pvt->online_spare);
806 804
807 debugf1("F1xF0 (DRAM Hole Address): 0x%08x, base: 0x%08x, " 805 edac_dbg(1, "F1xF0 (DRAM Hole Address): 0x%08x, base: 0x%08x, offset: 0x%08x\n",
808 "offset: 0x%08x\n", 806 pvt->dhar, dhar_base(pvt),
809 pvt->dhar, dhar_base(pvt), 807 (boot_cpu_data.x86 == 0xf) ? k8_dhar_offset(pvt)
810 (boot_cpu_data.x86 == 0xf) ? k8_dhar_offset(pvt) 808 : f10_dhar_offset(pvt));
811 : f10_dhar_offset(pvt));
812 809
813 debugf1(" DramHoleValid: %s\n", dhar_valid(pvt) ? "yes" : "no"); 810 edac_dbg(1, " DramHoleValid: %s\n", dhar_valid(pvt) ? "yes" : "no");
814 811
815 amd64_debug_display_dimm_sizes(pvt, 0); 812 amd64_debug_display_dimm_sizes(pvt, 0);
816 813
@@ -857,15 +854,15 @@ static void read_dct_base_mask(struct amd64_pvt *pvt)
857 u32 *base1 = &pvt->csels[1].csbases[cs]; 854 u32 *base1 = &pvt->csels[1].csbases[cs];
858 855
859 if (!amd64_read_dct_pci_cfg(pvt, reg0, base0)) 856 if (!amd64_read_dct_pci_cfg(pvt, reg0, base0))
860 debugf0(" DCSB0[%d]=0x%08x reg: F2x%x\n", 857 edac_dbg(0, " DCSB0[%d]=0x%08x reg: F2x%x\n",
861 cs, *base0, reg0); 858 cs, *base0, reg0);
862 859
863 if (boot_cpu_data.x86 == 0xf || dct_ganging_enabled(pvt)) 860 if (boot_cpu_data.x86 == 0xf || dct_ganging_enabled(pvt))
864 continue; 861 continue;
865 862
866 if (!amd64_read_dct_pci_cfg(pvt, reg1, base1)) 863 if (!amd64_read_dct_pci_cfg(pvt, reg1, base1))
867 debugf0(" DCSB1[%d]=0x%08x reg: F2x%x\n", 864 edac_dbg(0, " DCSB1[%d]=0x%08x reg: F2x%x\n",
868 cs, *base1, reg1); 865 cs, *base1, reg1);
869 } 866 }
870 867
871 for_each_chip_select_mask(cs, 0, pvt) { 868 for_each_chip_select_mask(cs, 0, pvt) {
@@ -875,15 +872,15 @@ static void read_dct_base_mask(struct amd64_pvt *pvt)
875 u32 *mask1 = &pvt->csels[1].csmasks[cs]; 872 u32 *mask1 = &pvt->csels[1].csmasks[cs];
876 873
877 if (!amd64_read_dct_pci_cfg(pvt, reg0, mask0)) 874 if (!amd64_read_dct_pci_cfg(pvt, reg0, mask0))
878 debugf0(" DCSM0[%d]=0x%08x reg: F2x%x\n", 875 edac_dbg(0, " DCSM0[%d]=0x%08x reg: F2x%x\n",
879 cs, *mask0, reg0); 876 cs, *mask0, reg0);
880 877
881 if (boot_cpu_data.x86 == 0xf || dct_ganging_enabled(pvt)) 878 if (boot_cpu_data.x86 == 0xf || dct_ganging_enabled(pvt))
882 continue; 879 continue;
883 880
884 if (!amd64_read_dct_pci_cfg(pvt, reg1, mask1)) 881 if (!amd64_read_dct_pci_cfg(pvt, reg1, mask1))
885 debugf0(" DCSM1[%d]=0x%08x reg: F2x%x\n", 882 edac_dbg(0, " DCSM1[%d]=0x%08x reg: F2x%x\n",
886 cs, *mask1, reg1); 883 cs, *mask1, reg1);
887 } 884 }
888} 885}
889 886
@@ -1049,24 +1046,22 @@ static void k8_map_sysaddr_to_csrow(struct mem_ctl_info *mci, u64 sys_addr,
1049 if (!src_mci) { 1046 if (!src_mci) {
1050 amd64_mc_err(mci, "failed to map error addr 0x%lx to a node\n", 1047 amd64_mc_err(mci, "failed to map error addr 0x%lx to a node\n",
1051 (unsigned long)sys_addr); 1048 (unsigned long)sys_addr);
1052 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1049 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
1053 page, offset, syndrome, 1050 page, offset, syndrome,
1054 -1, -1, -1, 1051 -1, -1, -1,
1055 EDAC_MOD_STR,
1056 "failed to map error addr to a node", 1052 "failed to map error addr to a node",
1057 NULL); 1053 "");
1058 return; 1054 return;
1059 } 1055 }
1060 1056
1061 /* Now map the sys_addr to a CSROW */ 1057 /* Now map the sys_addr to a CSROW */
1062 csrow = sys_addr_to_csrow(src_mci, sys_addr); 1058 csrow = sys_addr_to_csrow(src_mci, sys_addr);
1063 if (csrow < 0) { 1059 if (csrow < 0) {
1064 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1060 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
1065 page, offset, syndrome, 1061 page, offset, syndrome,
1066 -1, -1, -1, 1062 -1, -1, -1,
1067 EDAC_MOD_STR,
1068 "failed to map error addr to a csrow", 1063 "failed to map error addr to a csrow",
1069 NULL); 1064 "");
1070 return; 1065 return;
1071 } 1066 }
1072 1067
@@ -1082,12 +1077,11 @@ static void k8_map_sysaddr_to_csrow(struct mem_ctl_info *mci, u64 sys_addr,
1082 amd64_mc_warn(src_mci, "unknown syndrome 0x%04x - " 1077 amd64_mc_warn(src_mci, "unknown syndrome 0x%04x - "
1083 "possible error reporting race\n", 1078 "possible error reporting race\n",
1084 syndrome); 1079 syndrome);
1085 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1080 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
1086 page, offset, syndrome, 1081 page, offset, syndrome,
1087 csrow, -1, -1, 1082 csrow, -1, -1,
1088 EDAC_MOD_STR,
1089 "unknown syndrome - possible error reporting race", 1083 "unknown syndrome - possible error reporting race",
1090 NULL); 1084 "");
1091 return; 1085 return;
1092 } 1086 }
1093 } else { 1087 } else {
@@ -1102,10 +1096,10 @@ static void k8_map_sysaddr_to_csrow(struct mem_ctl_info *mci, u64 sys_addr,
1102 channel = ((sys_addr & BIT(3)) != 0); 1096 channel = ((sys_addr & BIT(3)) != 0);
1103 } 1097 }
1104 1098
1105 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, src_mci, 1099 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, src_mci, 1,
1106 page, offset, syndrome, 1100 page, offset, syndrome,
1107 csrow, channel, -1, 1101 csrow, channel, -1,
1108 EDAC_MOD_STR, "", NULL); 1102 "", "");
1109} 1103}
1110 1104
1111static int ddr2_cs_size(unsigned i, bool dct_width) 1105static int ddr2_cs_size(unsigned i, bool dct_width)
@@ -1193,7 +1187,7 @@ static int f1x_early_channel_count(struct amd64_pvt *pvt)
1193 * Need to check DCT0[0] and DCT1[0] to see if only one of them has 1187 * Need to check DCT0[0] and DCT1[0] to see if only one of them has
1194 * their CSEnable bit on. If so, then SINGLE DIMM case. 1188 * their CSEnable bit on. If so, then SINGLE DIMM case.
1195 */ 1189 */
1196 debugf0("Data width is not 128 bits - need more decoding\n"); 1190 edac_dbg(0, "Data width is not 128 bits - need more decoding\n");
1197 1191
1198 /* 1192 /*
1199 * Check DRAM Bank Address Mapping values for each DIMM to see if there 1193 * Check DRAM Bank Address Mapping values for each DIMM to see if there
@@ -1272,25 +1266,24 @@ static void read_dram_ctl_register(struct amd64_pvt *pvt)
1272 return; 1266 return;
1273 1267
1274 if (!amd64_read_dct_pci_cfg(pvt, DCT_SEL_LO, &pvt->dct_sel_lo)) { 1268 if (!amd64_read_dct_pci_cfg(pvt, DCT_SEL_LO, &pvt->dct_sel_lo)) {
1275 debugf0("F2x110 (DCTSelLow): 0x%08x, High range addrs at: 0x%x\n", 1269 edac_dbg(0, "F2x110 (DCTSelLow): 0x%08x, High range addrs at: 0x%x\n",
1276 pvt->dct_sel_lo, dct_sel_baseaddr(pvt)); 1270 pvt->dct_sel_lo, dct_sel_baseaddr(pvt));
1277 1271
1278 debugf0(" DCTs operate in %s mode.\n", 1272 edac_dbg(0, " DCTs operate in %s mode\n",
1279 (dct_ganging_enabled(pvt) ? "ganged" : "unganged")); 1273 (dct_ganging_enabled(pvt) ? "ganged" : "unganged"));
1280 1274
1281 if (!dct_ganging_enabled(pvt)) 1275 if (!dct_ganging_enabled(pvt))
1282 debugf0(" Address range split per DCT: %s\n", 1276 edac_dbg(0, " Address range split per DCT: %s\n",
1283 (dct_high_range_enabled(pvt) ? "yes" : "no")); 1277 (dct_high_range_enabled(pvt) ? "yes" : "no"));
1284 1278
1285 debugf0(" data interleave for ECC: %s, " 1279 edac_dbg(0, " data interleave for ECC: %s, DRAM cleared since last warm reset: %s\n",
1286 "DRAM cleared since last warm reset: %s\n", 1280 (dct_data_intlv_enabled(pvt) ? "enabled" : "disabled"),
1287 (dct_data_intlv_enabled(pvt) ? "enabled" : "disabled"), 1281 (dct_memory_cleared(pvt) ? "yes" : "no"));
1288 (dct_memory_cleared(pvt) ? "yes" : "no"));
1289 1282
1290 debugf0(" channel interleave: %s, " 1283 edac_dbg(0, " channel interleave: %s, "
1291 "interleave bits selector: 0x%x\n", 1284 "interleave bits selector: 0x%x\n",
1292 (dct_interleave_enabled(pvt) ? "enabled" : "disabled"), 1285 (dct_interleave_enabled(pvt) ? "enabled" : "disabled"),
1293 dct_sel_interleave_addr(pvt)); 1286 dct_sel_interleave_addr(pvt));
1294 } 1287 }
1295 1288
1296 amd64_read_dct_pci_cfg(pvt, DCT_SEL_HI, &pvt->dct_sel_hi); 1289 amd64_read_dct_pci_cfg(pvt, DCT_SEL_HI, &pvt->dct_sel_hi);
@@ -1428,7 +1421,7 @@ static int f1x_lookup_addr_in_dct(u64 in_addr, u32 nid, u8 dct)
1428 1421
1429 pvt = mci->pvt_info; 1422 pvt = mci->pvt_info;
1430 1423
1431 debugf1("input addr: 0x%llx, DCT: %d\n", in_addr, dct); 1424 edac_dbg(1, "input addr: 0x%llx, DCT: %d\n", in_addr, dct);
1432 1425
1433 for_each_chip_select(csrow, dct, pvt) { 1426 for_each_chip_select(csrow, dct, pvt) {
1434 if (!csrow_enabled(csrow, dct, pvt)) 1427 if (!csrow_enabled(csrow, dct, pvt))
@@ -1436,19 +1429,18 @@ static int f1x_lookup_addr_in_dct(u64 in_addr, u32 nid, u8 dct)
1436 1429
1437 get_cs_base_and_mask(pvt, csrow, dct, &cs_base, &cs_mask); 1430 get_cs_base_and_mask(pvt, csrow, dct, &cs_base, &cs_mask);
1438 1431
1439 debugf1(" CSROW=%d CSBase=0x%llx CSMask=0x%llx\n", 1432 edac_dbg(1, " CSROW=%d CSBase=0x%llx CSMask=0x%llx\n",
1440 csrow, cs_base, cs_mask); 1433 csrow, cs_base, cs_mask);
1441 1434
1442 cs_mask = ~cs_mask; 1435 cs_mask = ~cs_mask;
1443 1436
1444 debugf1(" (InputAddr & ~CSMask)=0x%llx " 1437 edac_dbg(1, " (InputAddr & ~CSMask)=0x%llx (CSBase & ~CSMask)=0x%llx\n",
1445 "(CSBase & ~CSMask)=0x%llx\n", 1438 (in_addr & cs_mask), (cs_base & cs_mask));
1446 (in_addr & cs_mask), (cs_base & cs_mask));
1447 1439
1448 if ((in_addr & cs_mask) == (cs_base & cs_mask)) { 1440 if ((in_addr & cs_mask) == (cs_base & cs_mask)) {
1449 cs_found = f10_process_possible_spare(pvt, dct, csrow); 1441 cs_found = f10_process_possible_spare(pvt, dct, csrow);
1450 1442
1451 debugf1(" MATCH csrow=%d\n", cs_found); 1443 edac_dbg(1, " MATCH csrow=%d\n", cs_found);
1452 break; 1444 break;
1453 } 1445 }
1454 } 1446 }
@@ -1505,8 +1497,8 @@ static int f1x_match_to_this_node(struct amd64_pvt *pvt, unsigned range,
1505 u8 intlv_en = dram_intlv_en(pvt, range); 1497 u8 intlv_en = dram_intlv_en(pvt, range);
1506 u32 intlv_sel = dram_intlv_sel(pvt, range); 1498 u32 intlv_sel = dram_intlv_sel(pvt, range);
1507 1499
1508 debugf1("(range %d) SystemAddr= 0x%llx Limit=0x%llx\n", 1500 edac_dbg(1, "(range %d) SystemAddr= 0x%llx Limit=0x%llx\n",
1509 range, sys_addr, get_dram_limit(pvt, range)); 1501 range, sys_addr, get_dram_limit(pvt, range));
1510 1502
1511 if (dhar_valid(pvt) && 1503 if (dhar_valid(pvt) &&
1512 dhar_base(pvt) <= sys_addr && 1504 dhar_base(pvt) <= sys_addr &&
@@ -1562,7 +1554,7 @@ static int f1x_match_to_this_node(struct amd64_pvt *pvt, unsigned range,
1562 (chan_addr & 0xfff); 1554 (chan_addr & 0xfff);
1563 } 1555 }
1564 1556
1565 debugf1(" Normalized DCT addr: 0x%llx\n", chan_addr); 1557 edac_dbg(1, " Normalized DCT addr: 0x%llx\n", chan_addr);
1566 1558
1567 cs_found = f1x_lookup_addr_in_dct(chan_addr, node_id, channel); 1559 cs_found = f1x_lookup_addr_in_dct(chan_addr, node_id, channel);
1568 1560
@@ -1616,12 +1608,11 @@ static void f1x_map_sysaddr_to_csrow(struct mem_ctl_info *mci, u64 sys_addr,
1616 csrow = f1x_translate_sysaddr_to_cs(pvt, sys_addr, &nid, &chan); 1608 csrow = f1x_translate_sysaddr_to_cs(pvt, sys_addr, &nid, &chan);
1617 1609
1618 if (csrow < 0) { 1610 if (csrow < 0) {
1619 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1611 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
1620 page, offset, syndrome, 1612 page, offset, syndrome,
1621 -1, -1, -1, 1613 -1, -1, -1,
1622 EDAC_MOD_STR,
1623 "failed to map error addr to a csrow", 1614 "failed to map error addr to a csrow",
1624 NULL); 1615 "");
1625 return; 1616 return;
1626 } 1617 }
1627 1618
@@ -1633,10 +1624,10 @@ static void f1x_map_sysaddr_to_csrow(struct mem_ctl_info *mci, u64 sys_addr,
1633 if (dct_ganging_enabled(pvt)) 1624 if (dct_ganging_enabled(pvt))
1634 chan = get_channel_from_ecc_syndrome(mci, syndrome); 1625 chan = get_channel_from_ecc_syndrome(mci, syndrome);
1635 1626
1636 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1627 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
1637 page, offset, syndrome, 1628 page, offset, syndrome,
1638 csrow, chan, -1, 1629 csrow, chan, -1,
1639 EDAC_MOD_STR, "", NULL); 1630 "", "");
1640} 1631}
1641 1632
1642/* 1633/*
@@ -1664,7 +1655,8 @@ static void amd64_debug_display_dimm_sizes(struct amd64_pvt *pvt, u8 ctrl)
1664 dcsb = (ctrl && !dct_ganging_enabled(pvt)) ? pvt->csels[1].csbases 1655 dcsb = (ctrl && !dct_ganging_enabled(pvt)) ? pvt->csels[1].csbases
1665 : pvt->csels[0].csbases; 1656 : pvt->csels[0].csbases;
1666 1657
1667 debugf1("F2x%d80 (DRAM Bank Address Mapping): 0x%08x\n", ctrl, dbam); 1658 edac_dbg(1, "F2x%d80 (DRAM Bank Address Mapping): 0x%08x\n",
1659 ctrl, dbam);
1668 1660
1669 edac_printk(KERN_DEBUG, EDAC_MC, "DCT%d chip selects:\n", ctrl); 1661 edac_printk(KERN_DEBUG, EDAC_MC, "DCT%d chip selects:\n", ctrl);
1670 1662
@@ -1840,7 +1832,7 @@ static int decode_syndrome(u16 syndrome, u16 *vectors, unsigned num_vecs,
1840 } 1832 }
1841 } 1833 }
1842 1834
1843 debugf0("syndrome(%x) not found\n", syndrome); 1835 edac_dbg(0, "syndrome(%x) not found\n", syndrome);
1844 return -1; 1836 return -1;
1845} 1837}
1846 1838
@@ -1917,12 +1909,11 @@ static void amd64_handle_ce(struct mem_ctl_info *mci, struct mce *m)
1917 /* Ensure that the Error Address is VALID */ 1909 /* Ensure that the Error Address is VALID */
1918 if (!(m->status & MCI_STATUS_ADDRV)) { 1910 if (!(m->status & MCI_STATUS_ADDRV)) {
1919 amd64_mc_err(mci, "HW has no ERROR_ADDRESS available\n"); 1911 amd64_mc_err(mci, "HW has no ERROR_ADDRESS available\n");
1920 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1912 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
1921 0, 0, 0, 1913 0, 0, 0,
1922 -1, -1, -1, 1914 -1, -1, -1,
1923 EDAC_MOD_STR,
1924 "HW has no ERROR_ADDRESS available", 1915 "HW has no ERROR_ADDRESS available",
1925 NULL); 1916 "");
1926 return; 1917 return;
1927 } 1918 }
1928 1919
@@ -1946,12 +1937,11 @@ static void amd64_handle_ue(struct mem_ctl_info *mci, struct mce *m)
1946 1937
1947 if (!(m->status & MCI_STATUS_ADDRV)) { 1938 if (!(m->status & MCI_STATUS_ADDRV)) {
1948 amd64_mc_err(mci, "HW has no ERROR_ADDRESS available\n"); 1939 amd64_mc_err(mci, "HW has no ERROR_ADDRESS available\n");
1949 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1940 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
1950 0, 0, 0, 1941 0, 0, 0,
1951 -1, -1, -1, 1942 -1, -1, -1,
1952 EDAC_MOD_STR,
1953 "HW has no ERROR_ADDRESS available", 1943 "HW has no ERROR_ADDRESS available",
1954 NULL); 1944 "");
1955 return; 1945 return;
1956 } 1946 }
1957 1947
@@ -1966,11 +1956,11 @@ static void amd64_handle_ue(struct mem_ctl_info *mci, struct mce *m)
1966 if (!src_mci) { 1956 if (!src_mci) {
1967 amd64_mc_err(mci, "ERROR ADDRESS (0x%lx) NOT mapped to a MC\n", 1957 amd64_mc_err(mci, "ERROR ADDRESS (0x%lx) NOT mapped to a MC\n",
1968 (unsigned long)sys_addr); 1958 (unsigned long)sys_addr);
1969 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1959 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
1970 page, offset, 0, 1960 page, offset, 0,
1971 -1, -1, -1, 1961 -1, -1, -1,
1972 EDAC_MOD_STR, 1962 "ERROR ADDRESS NOT mapped to a MC",
1973 "ERROR ADDRESS NOT mapped to a MC", NULL); 1963 "");
1974 return; 1964 return;
1975 } 1965 }
1976 1966
@@ -1980,17 +1970,16 @@ static void amd64_handle_ue(struct mem_ctl_info *mci, struct mce *m)
1980 if (csrow < 0) { 1970 if (csrow < 0) {
1981 amd64_mc_err(mci, "ERROR_ADDRESS (0x%lx) NOT mapped to CS\n", 1971 amd64_mc_err(mci, "ERROR_ADDRESS (0x%lx) NOT mapped to CS\n",
1982 (unsigned long)sys_addr); 1972 (unsigned long)sys_addr);
1983 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1973 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
1984 page, offset, 0, 1974 page, offset, 0,
1985 -1, -1, -1, 1975 -1, -1, -1,
1986 EDAC_MOD_STR,
1987 "ERROR ADDRESS NOT mapped to CS", 1976 "ERROR ADDRESS NOT mapped to CS",
1988 NULL); 1977 "");
1989 } else { 1978 } else {
1990 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1979 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
1991 page, offset, 0, 1980 page, offset, 0,
1992 csrow, -1, -1, 1981 csrow, -1, -1,
1993 EDAC_MOD_STR, "", NULL); 1982 "", "");
1994 } 1983 }
1995} 1984}
1996 1985
@@ -2047,9 +2036,9 @@ static int reserve_mc_sibling_devs(struct amd64_pvt *pvt, u16 f1_id, u16 f3_id)
2047 2036
2048 return -ENODEV; 2037 return -ENODEV;
2049 } 2038 }
2050 debugf1("F1: %s\n", pci_name(pvt->F1)); 2039 edac_dbg(1, "F1: %s\n", pci_name(pvt->F1));
2051 debugf1("F2: %s\n", pci_name(pvt->F2)); 2040 edac_dbg(1, "F2: %s\n", pci_name(pvt->F2));
2052 debugf1("F3: %s\n", pci_name(pvt->F3)); 2041 edac_dbg(1, "F3: %s\n", pci_name(pvt->F3));
2053 2042
2054 return 0; 2043 return 0;
2055} 2044}
@@ -2076,15 +2065,15 @@ static void read_mc_regs(struct amd64_pvt *pvt)
2076 * those are Read-As-Zero 2065 * those are Read-As-Zero
2077 */ 2066 */
2078 rdmsrl(MSR_K8_TOP_MEM1, pvt->top_mem); 2067 rdmsrl(MSR_K8_TOP_MEM1, pvt->top_mem);
2079 debugf0(" TOP_MEM: 0x%016llx\n", pvt->top_mem); 2068 edac_dbg(0, " TOP_MEM: 0x%016llx\n", pvt->top_mem);
2080 2069
2081 /* check first whether TOP_MEM2 is enabled */ 2070 /* check first whether TOP_MEM2 is enabled */
2082 rdmsrl(MSR_K8_SYSCFG, msr_val); 2071 rdmsrl(MSR_K8_SYSCFG, msr_val);
2083 if (msr_val & (1U << 21)) { 2072 if (msr_val & (1U << 21)) {
2084 rdmsrl(MSR_K8_TOP_MEM2, pvt->top_mem2); 2073 rdmsrl(MSR_K8_TOP_MEM2, pvt->top_mem2);
2085 debugf0(" TOP_MEM2: 0x%016llx\n", pvt->top_mem2); 2074 edac_dbg(0, " TOP_MEM2: 0x%016llx\n", pvt->top_mem2);
2086 } else 2075 } else
2087 debugf0(" TOP_MEM2 disabled.\n"); 2076 edac_dbg(0, " TOP_MEM2 disabled\n");
2088 2077
2089 amd64_read_pci_cfg(pvt->F3, NBCAP, &pvt->nbcap); 2078 amd64_read_pci_cfg(pvt->F3, NBCAP, &pvt->nbcap);
2090 2079
@@ -2100,17 +2089,17 @@ static void read_mc_regs(struct amd64_pvt *pvt)
2100 if (!rw) 2089 if (!rw)
2101 continue; 2090 continue;
2102 2091
2103 debugf1(" DRAM range[%d], base: 0x%016llx; limit: 0x%016llx\n", 2092 edac_dbg(1, " DRAM range[%d], base: 0x%016llx; limit: 0x%016llx\n",
2104 range, 2093 range,
2105 get_dram_base(pvt, range), 2094 get_dram_base(pvt, range),
2106 get_dram_limit(pvt, range)); 2095 get_dram_limit(pvt, range));
2107 2096
2108 debugf1(" IntlvEn=%s; Range access: %s%s IntlvSel=%d DstNode=%d\n", 2097 edac_dbg(1, " IntlvEn=%s; Range access: %s%s IntlvSel=%d DstNode=%d\n",
2109 dram_intlv_en(pvt, range) ? "Enabled" : "Disabled", 2098 dram_intlv_en(pvt, range) ? "Enabled" : "Disabled",
2110 (rw & 0x1) ? "R" : "-", 2099 (rw & 0x1) ? "R" : "-",
2111 (rw & 0x2) ? "W" : "-", 2100 (rw & 0x2) ? "W" : "-",
2112 dram_intlv_sel(pvt, range), 2101 dram_intlv_sel(pvt, range),
2113 dram_dst_node(pvt, range)); 2102 dram_dst_node(pvt, range));
2114 } 2103 }
2115 2104
2116 read_dct_base_mask(pvt); 2105 read_dct_base_mask(pvt);
@@ -2191,9 +2180,9 @@ static u32 amd64_csrow_nr_pages(struct amd64_pvt *pvt, u8 dct, int csrow_nr)
2191 2180
2192 nr_pages = pvt->ops->dbam_to_cs(pvt, dct, cs_mode) << (20 - PAGE_SHIFT); 2181 nr_pages = pvt->ops->dbam_to_cs(pvt, dct, cs_mode) << (20 - PAGE_SHIFT);
2193 2182
2194 debugf0(" (csrow=%d) DBAM map index= %d\n", csrow_nr, cs_mode); 2183 edac_dbg(0, " (csrow=%d) DBAM map index= %d\n", csrow_nr, cs_mode);
2195 debugf0(" nr_pages/channel= %u channel-count = %d\n", 2184 edac_dbg(0, " nr_pages/channel= %u channel-count = %d\n",
2196 nr_pages, pvt->channel_count); 2185 nr_pages, pvt->channel_count);
2197 2186
2198 return nr_pages; 2187 return nr_pages;
2199} 2188}
@@ -2205,6 +2194,7 @@ static u32 amd64_csrow_nr_pages(struct amd64_pvt *pvt, u8 dct, int csrow_nr)
2205static int init_csrows(struct mem_ctl_info *mci) 2194static int init_csrows(struct mem_ctl_info *mci)
2206{ 2195{
2207 struct csrow_info *csrow; 2196 struct csrow_info *csrow;
2197 struct dimm_info *dimm;
2208 struct amd64_pvt *pvt = mci->pvt_info; 2198 struct amd64_pvt *pvt = mci->pvt_info;
2209 u64 base, mask; 2199 u64 base, mask;
2210 u32 val; 2200 u32 val;
@@ -2217,22 +2207,19 @@ static int init_csrows(struct mem_ctl_info *mci)
2217 2207
2218 pvt->nbcfg = val; 2208 pvt->nbcfg = val;
2219 2209
2220 debugf0("node %d, NBCFG=0x%08x[ChipKillEccCap: %d|DramEccEn: %d]\n", 2210 edac_dbg(0, "node %d, NBCFG=0x%08x[ChipKillEccCap: %d|DramEccEn: %d]\n",
2221 pvt->mc_node_id, val, 2211 pvt->mc_node_id, val,
2222 !!(val & NBCFG_CHIPKILL), !!(val & NBCFG_ECC_ENABLE)); 2212 !!(val & NBCFG_CHIPKILL), !!(val & NBCFG_ECC_ENABLE));
2223 2213
2224 for_each_chip_select(i, 0, pvt) { 2214 for_each_chip_select(i, 0, pvt) {
2225 csrow = &mci->csrows[i]; 2215 csrow = mci->csrows[i];
2226 2216
2227 if (!csrow_enabled(i, 0, pvt) && !csrow_enabled(i, 1, pvt)) { 2217 if (!csrow_enabled(i, 0, pvt) && !csrow_enabled(i, 1, pvt)) {
2228 debugf1("----CSROW %d EMPTY for node %d\n", i, 2218 edac_dbg(1, "----CSROW %d VALID for MC node %d\n",
2229 pvt->mc_node_id); 2219 i, pvt->mc_node_id);
2230 continue; 2220 continue;
2231 } 2221 }
2232 2222
2233 debugf1("----CSROW %d VALID for MC node %d\n",
2234 i, pvt->mc_node_id);
2235
2236 empty = 0; 2223 empty = 0;
2237 if (csrow_enabled(i, 0, pvt)) 2224 if (csrow_enabled(i, 0, pvt))
2238 nr_pages = amd64_csrow_nr_pages(pvt, 0, i); 2225 nr_pages = amd64_csrow_nr_pages(pvt, 0, i);
@@ -2244,8 +2231,9 @@ static int init_csrows(struct mem_ctl_info *mci)
2244 2231
2245 mtype = amd64_determine_memory_type(pvt, i); 2232 mtype = amd64_determine_memory_type(pvt, i);
2246 2233
2247 debugf1(" for MC node %d csrow %d:\n", pvt->mc_node_id, i); 2234 edac_dbg(1, " for MC node %d csrow %d:\n", pvt->mc_node_id, i);
2248 debugf1(" nr_pages: %u\n", nr_pages * pvt->channel_count); 2235 edac_dbg(1, " nr_pages: %u\n",
2236 nr_pages * pvt->channel_count);
2249 2237
2250 /* 2238 /*
2251 * determine whether CHIPKILL or JUST ECC or NO ECC is operating 2239 * determine whether CHIPKILL or JUST ECC or NO ECC is operating
@@ -2257,9 +2245,10 @@ static int init_csrows(struct mem_ctl_info *mci)
2257 edac_mode = EDAC_NONE; 2245 edac_mode = EDAC_NONE;
2258 2246
2259 for (j = 0; j < pvt->channel_count; j++) { 2247 for (j = 0; j < pvt->channel_count; j++) {
2260 csrow->channels[j].dimm->mtype = mtype; 2248 dimm = csrow->channels[j]->dimm;
2261 csrow->channels[j].dimm->edac_mode = edac_mode; 2249 dimm->mtype = mtype;
2262 csrow->channels[j].dimm->nr_pages = nr_pages; 2250 dimm->edac_mode = edac_mode;
2251 dimm->nr_pages = nr_pages;
2263 } 2252 }
2264 } 2253 }
2265 2254
@@ -2296,9 +2285,9 @@ static bool amd64_nb_mce_bank_enabled_on_node(unsigned nid)
2296 struct msr *reg = per_cpu_ptr(msrs, cpu); 2285 struct msr *reg = per_cpu_ptr(msrs, cpu);
2297 nbe = reg->l & MSR_MCGCTL_NBE; 2286 nbe = reg->l & MSR_MCGCTL_NBE;
2298 2287
2299 debugf0("core: %u, MCG_CTL: 0x%llx, NB MSR is %s\n", 2288 edac_dbg(0, "core: %u, MCG_CTL: 0x%llx, NB MSR is %s\n",
2300 cpu, reg->q, 2289 cpu, reg->q,
2301 (nbe ? "enabled" : "disabled")); 2290 (nbe ? "enabled" : "disabled"));
2302 2291
2303 if (!nbe) 2292 if (!nbe)
2304 goto out; 2293 goto out;
@@ -2369,8 +2358,8 @@ static bool enable_ecc_error_reporting(struct ecc_settings *s, u8 nid,
2369 2358
2370 amd64_read_pci_cfg(F3, NBCFG, &value); 2359 amd64_read_pci_cfg(F3, NBCFG, &value);
2371 2360
2372 debugf0("1: node %d, NBCFG=0x%08x[DramEccEn: %d]\n", 2361 edac_dbg(0, "1: node %d, NBCFG=0x%08x[DramEccEn: %d]\n",
2373 nid, value, !!(value & NBCFG_ECC_ENABLE)); 2362 nid, value, !!(value & NBCFG_ECC_ENABLE));
2374 2363
2375 if (!(value & NBCFG_ECC_ENABLE)) { 2364 if (!(value & NBCFG_ECC_ENABLE)) {
2376 amd64_warn("DRAM ECC disabled on this node, enabling...\n"); 2365 amd64_warn("DRAM ECC disabled on this node, enabling...\n");
@@ -2394,8 +2383,8 @@ static bool enable_ecc_error_reporting(struct ecc_settings *s, u8 nid,
2394 s->flags.nb_ecc_prev = 1; 2383 s->flags.nb_ecc_prev = 1;
2395 } 2384 }
2396 2385
2397 debugf0("2: node %d, NBCFG=0x%08x[DramEccEn: %d]\n", 2386 edac_dbg(0, "2: node %d, NBCFG=0x%08x[DramEccEn: %d]\n",
2398 nid, value, !!(value & NBCFG_ECC_ENABLE)); 2387 nid, value, !!(value & NBCFG_ECC_ENABLE));
2399 2388
2400 return ret; 2389 return ret;
2401} 2390}
@@ -2463,26 +2452,29 @@ static bool ecc_enabled(struct pci_dev *F3, u8 nid)
2463 return true; 2452 return true;
2464} 2453}
2465 2454
2466struct mcidev_sysfs_attribute sysfs_attrs[ARRAY_SIZE(amd64_dbg_attrs) + 2455static int set_mc_sysfs_attrs(struct mem_ctl_info *mci)
2467 ARRAY_SIZE(amd64_inj_attrs) +
2468 1];
2469
2470struct mcidev_sysfs_attribute terminator = { .attr = { .name = NULL } };
2471
2472static void set_mc_sysfs_attrs(struct mem_ctl_info *mci)
2473{ 2456{
2474 unsigned int i = 0, j = 0; 2457 int rc;
2475 2458
2476 for (; i < ARRAY_SIZE(amd64_dbg_attrs); i++) 2459 rc = amd64_create_sysfs_dbg_files(mci);
2477 sysfs_attrs[i] = amd64_dbg_attrs[i]; 2460 if (rc < 0)
2461 return rc;
2478 2462
2479 if (boot_cpu_data.x86 >= 0x10) 2463 if (boot_cpu_data.x86 >= 0x10) {
2480 for (j = 0; j < ARRAY_SIZE(amd64_inj_attrs); j++, i++) 2464 rc = amd64_create_sysfs_inject_files(mci);
2481 sysfs_attrs[i] = amd64_inj_attrs[j]; 2465 if (rc < 0)
2466 return rc;
2467 }
2468
2469 return 0;
2470}
2482 2471
2483 sysfs_attrs[i] = terminator; 2472static void del_mc_sysfs_attrs(struct mem_ctl_info *mci)
2473{
2474 amd64_remove_sysfs_dbg_files(mci);
2484 2475
2485 mci->mc_driver_sysfs_attributes = sysfs_attrs; 2476 if (boot_cpu_data.x86 >= 0x10)
2477 amd64_remove_sysfs_inject_files(mci);
2486} 2478}
2487 2479
2488static void setup_mci_misc_attrs(struct mem_ctl_info *mci, 2480static void setup_mci_misc_attrs(struct mem_ctl_info *mci,
@@ -2601,20 +2593,22 @@ static int amd64_init_one_instance(struct pci_dev *F2)
2601 goto err_siblings; 2593 goto err_siblings;
2602 2594
2603 mci->pvt_info = pvt; 2595 mci->pvt_info = pvt;
2604 mci->dev = &pvt->F2->dev; 2596 mci->pdev = &pvt->F2->dev;
2605 2597
2606 setup_mci_misc_attrs(mci, fam_type); 2598 setup_mci_misc_attrs(mci, fam_type);
2607 2599
2608 if (init_csrows(mci)) 2600 if (init_csrows(mci))
2609 mci->edac_cap = EDAC_FLAG_NONE; 2601 mci->edac_cap = EDAC_FLAG_NONE;
2610 2602
2611 set_mc_sysfs_attrs(mci);
2612
2613 ret = -ENODEV; 2603 ret = -ENODEV;
2614 if (edac_mc_add_mc(mci)) { 2604 if (edac_mc_add_mc(mci)) {
2615 debugf1("failed edac_mc_add_mc()\n"); 2605 edac_dbg(1, "failed edac_mc_add_mc()\n");
2616 goto err_add_mc; 2606 goto err_add_mc;
2617 } 2607 }
2608 if (set_mc_sysfs_attrs(mci)) {
2609 edac_dbg(1, "failed edac_mc_add_mc()\n");
2610 goto err_add_sysfs;
2611 }
2618 2612
2619 /* register stuff with EDAC MCE */ 2613 /* register stuff with EDAC MCE */
2620 if (report_gart_errors) 2614 if (report_gart_errors)
@@ -2628,6 +2622,8 @@ static int amd64_init_one_instance(struct pci_dev *F2)
2628 2622
2629 return 0; 2623 return 0;
2630 2624
2625err_add_sysfs:
2626 edac_mc_del_mc(mci->pdev);
2631err_add_mc: 2627err_add_mc:
2632 edac_mc_free(mci); 2628 edac_mc_free(mci);
2633 2629
@@ -2651,7 +2647,7 @@ static int __devinit amd64_probe_one_instance(struct pci_dev *pdev,
2651 2647
2652 ret = pci_enable_device(pdev); 2648 ret = pci_enable_device(pdev);
2653 if (ret < 0) { 2649 if (ret < 0) {
2654 debugf0("ret=%d\n", ret); 2650 edac_dbg(0, "ret=%d\n", ret);
2655 return -EIO; 2651 return -EIO;
2656 } 2652 }
2657 2653
@@ -2698,6 +2694,8 @@ static void __devexit amd64_remove_one_instance(struct pci_dev *pdev)
2698 struct pci_dev *F3 = node_to_amd_nb(nid)->misc; 2694 struct pci_dev *F3 = node_to_amd_nb(nid)->misc;
2699 struct ecc_settings *s = ecc_stngs[nid]; 2695 struct ecc_settings *s = ecc_stngs[nid];
2700 2696
2697 mci = find_mci_by_dev(&pdev->dev);
2698 del_mc_sysfs_attrs(mci);
2701 /* Remove from EDAC CORE tracking list */ 2699 /* Remove from EDAC CORE tracking list */
2702 mci = edac_mc_del_mc(&pdev->dev); 2700 mci = edac_mc_del_mc(&pdev->dev);
2703 if (!mci) 2701 if (!mci)
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index 9a666cb985b2..8d4804732bac 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -413,20 +413,33 @@ struct ecc_settings {
413}; 413};
414 414
415#ifdef CONFIG_EDAC_DEBUG 415#ifdef CONFIG_EDAC_DEBUG
416#define NUM_DBG_ATTRS 5 416int amd64_create_sysfs_dbg_files(struct mem_ctl_info *mci);
417void amd64_remove_sysfs_dbg_files(struct mem_ctl_info *mci);
418
417#else 419#else
418#define NUM_DBG_ATTRS 0 420static inline int amd64_create_sysfs_dbg_files(struct mem_ctl_info *mci)
421{
422 return 0;
423}
424static void inline amd64_remove_sysfs_dbg_files(struct mem_ctl_info *mci)
425{
426}
419#endif 427#endif
420 428
421#ifdef CONFIG_EDAC_AMD64_ERROR_INJECTION 429#ifdef CONFIG_EDAC_AMD64_ERROR_INJECTION
422#define NUM_INJ_ATTRS 5 430int amd64_create_sysfs_inject_files(struct mem_ctl_info *mci);
431void amd64_remove_sysfs_inject_files(struct mem_ctl_info *mci);
432
423#else 433#else
424#define NUM_INJ_ATTRS 0 434static inline int amd64_create_sysfs_inject_files(struct mem_ctl_info *mci)
435{
436 return 0;
437}
438static inline void amd64_remove_sysfs_inject_files(struct mem_ctl_info *mci)
439{
440}
425#endif 441#endif
426 442
427extern struct mcidev_sysfs_attribute amd64_dbg_attrs[NUM_DBG_ATTRS],
428 amd64_inj_attrs[NUM_INJ_ATTRS];
429
430/* 443/*
431 * Each of the PCI Device IDs types have their own set of hardware accessor 444 * Each of the PCI Device IDs types have their own set of hardware accessor
432 * functions and per device encoding/decoding logic. 445 * functions and per device encoding/decoding logic.
@@ -460,3 +473,5 @@ int __amd64_write_pci_cfg_dword(struct pci_dev *pdev, int offset,
460 473
461int amd64_get_dram_hole_info(struct mem_ctl_info *mci, u64 *hole_base, 474int amd64_get_dram_hole_info(struct mem_ctl_info *mci, u64 *hole_base,
462 u64 *hole_offset, u64 *hole_size); 475 u64 *hole_offset, u64 *hole_size);
476
477#define to_mci(k) container_of(k, struct mem_ctl_info, dev)
diff --git a/drivers/edac/amd64_edac_dbg.c b/drivers/edac/amd64_edac_dbg.c
index e3562288f4ce..2c1bbf740605 100644
--- a/drivers/edac/amd64_edac_dbg.c
+++ b/drivers/edac/amd64_edac_dbg.c
@@ -1,8 +1,11 @@
1#include "amd64_edac.h" 1#include "amd64_edac.h"
2 2
3#define EDAC_DCT_ATTR_SHOW(reg) \ 3#define EDAC_DCT_ATTR_SHOW(reg) \
4static ssize_t amd64_##reg##_show(struct mem_ctl_info *mci, char *data) \ 4static ssize_t amd64_##reg##_show(struct device *dev, \
5 struct device_attribute *mattr, \
6 char *data) \
5{ \ 7{ \
8 struct mem_ctl_info *mci = to_mci(dev); \
6 struct amd64_pvt *pvt = mci->pvt_info; \ 9 struct amd64_pvt *pvt = mci->pvt_info; \
7 return sprintf(data, "0x%016llx\n", (u64)pvt->reg); \ 10 return sprintf(data, "0x%016llx\n", (u64)pvt->reg); \
8} 11}
@@ -12,8 +15,12 @@ EDAC_DCT_ATTR_SHOW(dbam0);
12EDAC_DCT_ATTR_SHOW(top_mem); 15EDAC_DCT_ATTR_SHOW(top_mem);
13EDAC_DCT_ATTR_SHOW(top_mem2); 16EDAC_DCT_ATTR_SHOW(top_mem2);
14 17
15static ssize_t amd64_hole_show(struct mem_ctl_info *mci, char *data) 18static ssize_t amd64_hole_show(struct device *dev,
19 struct device_attribute *mattr,
20 char *data)
16{ 21{
22 struct mem_ctl_info *mci = to_mci(dev);
23
17 u64 hole_base = 0; 24 u64 hole_base = 0;
18 u64 hole_offset = 0; 25 u64 hole_offset = 0;
19 u64 hole_size = 0; 26 u64 hole_size = 0;
@@ -27,46 +34,40 @@ static ssize_t amd64_hole_show(struct mem_ctl_info *mci, char *data)
27/* 34/*
28 * update NUM_DBG_ATTRS in case you add new members 35 * update NUM_DBG_ATTRS in case you add new members
29 */ 36 */
30struct mcidev_sysfs_attribute amd64_dbg_attrs[] = { 37static DEVICE_ATTR(dhar, S_IRUGO, amd64_dhar_show, NULL);
38static DEVICE_ATTR(dbam, S_IRUGO, amd64_dbam0_show, NULL);
39static DEVICE_ATTR(topmem, S_IRUGO, amd64_top_mem_show, NULL);
40static DEVICE_ATTR(topmem2, S_IRUGO, amd64_top_mem2_show, NULL);
41static DEVICE_ATTR(dram_hole, S_IRUGO, amd64_hole_show, NULL);
42
43int amd64_create_sysfs_dbg_files(struct mem_ctl_info *mci)
44{
45 int rc;
46
47 rc = device_create_file(&mci->dev, &dev_attr_dhar);
48 if (rc < 0)
49 return rc;
50 rc = device_create_file(&mci->dev, &dev_attr_dbam);
51 if (rc < 0)
52 return rc;
53 rc = device_create_file(&mci->dev, &dev_attr_topmem);
54 if (rc < 0)
55 return rc;
56 rc = device_create_file(&mci->dev, &dev_attr_topmem2);
57 if (rc < 0)
58 return rc;
59 rc = device_create_file(&mci->dev, &dev_attr_dram_hole);
60 if (rc < 0)
61 return rc;
31 62
32 { 63 return 0;
33 .attr = { 64}
34 .name = "dhar", 65
35 .mode = (S_IRUGO) 66void amd64_remove_sysfs_dbg_files(struct mem_ctl_info *mci)
36 }, 67{
37 .show = amd64_dhar_show, 68 device_remove_file(&mci->dev, &dev_attr_dhar);
38 .store = NULL, 69 device_remove_file(&mci->dev, &dev_attr_dbam);
39 }, 70 device_remove_file(&mci->dev, &dev_attr_topmem);
40 { 71 device_remove_file(&mci->dev, &dev_attr_topmem2);
41 .attr = { 72 device_remove_file(&mci->dev, &dev_attr_dram_hole);
42 .name = "dbam", 73}
43 .mode = (S_IRUGO)
44 },
45 .show = amd64_dbam0_show,
46 .store = NULL,
47 },
48 {
49 .attr = {
50 .name = "topmem",
51 .mode = (S_IRUGO)
52 },
53 .show = amd64_top_mem_show,
54 .store = NULL,
55 },
56 {
57 .attr = {
58 .name = "topmem2",
59 .mode = (S_IRUGO)
60 },
61 .show = amd64_top_mem2_show,
62 .store = NULL,
63 },
64 {
65 .attr = {
66 .name = "dram_hole",
67 .mode = (S_IRUGO)
68 },
69 .show = amd64_hole_show,
70 .store = NULL,
71 },
72};
diff --git a/drivers/edac/amd64_edac_inj.c b/drivers/edac/amd64_edac_inj.c
index 303f10e03dda..53d972e00dfb 100644
--- a/drivers/edac/amd64_edac_inj.c
+++ b/drivers/edac/amd64_edac_inj.c
@@ -1,7 +1,10 @@
1#include "amd64_edac.h" 1#include "amd64_edac.h"
2 2
3static ssize_t amd64_inject_section_show(struct mem_ctl_info *mci, char *buf) 3static ssize_t amd64_inject_section_show(struct device *dev,
4 struct device_attribute *mattr,
5 char *buf)
4{ 6{
7 struct mem_ctl_info *mci = to_mci(dev);
5 struct amd64_pvt *pvt = mci->pvt_info; 8 struct amd64_pvt *pvt = mci->pvt_info;
6 return sprintf(buf, "0x%x\n", pvt->injection.section); 9 return sprintf(buf, "0x%x\n", pvt->injection.section);
7} 10}
@@ -12,9 +15,11 @@ static ssize_t amd64_inject_section_show(struct mem_ctl_info *mci, char *buf)
12 * 15 *
13 * range: 0..3 16 * range: 0..3
14 */ 17 */
15static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci, 18static ssize_t amd64_inject_section_store(struct device *dev,
19 struct device_attribute *mattr,
16 const char *data, size_t count) 20 const char *data, size_t count)
17{ 21{
22 struct mem_ctl_info *mci = to_mci(dev);
18 struct amd64_pvt *pvt = mci->pvt_info; 23 struct amd64_pvt *pvt = mci->pvt_info;
19 unsigned long value; 24 unsigned long value;
20 int ret = 0; 25 int ret = 0;
@@ -33,8 +38,11 @@ static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci,
33 return ret; 38 return ret;
34} 39}
35 40
36static ssize_t amd64_inject_word_show(struct mem_ctl_info *mci, char *buf) 41static ssize_t amd64_inject_word_show(struct device *dev,
42 struct device_attribute *mattr,
43 char *buf)
37{ 44{
45 struct mem_ctl_info *mci = to_mci(dev);
38 struct amd64_pvt *pvt = mci->pvt_info; 46 struct amd64_pvt *pvt = mci->pvt_info;
39 return sprintf(buf, "0x%x\n", pvt->injection.word); 47 return sprintf(buf, "0x%x\n", pvt->injection.word);
40} 48}
@@ -45,9 +53,11 @@ static ssize_t amd64_inject_word_show(struct mem_ctl_info *mci, char *buf)
45 * 53 *
46 * range: 0..8 54 * range: 0..8
47 */ 55 */
48static ssize_t amd64_inject_word_store(struct mem_ctl_info *mci, 56static ssize_t amd64_inject_word_store(struct device *dev,
49 const char *data, size_t count) 57 struct device_attribute *mattr,
58 const char *data, size_t count)
50{ 59{
60 struct mem_ctl_info *mci = to_mci(dev);
51 struct amd64_pvt *pvt = mci->pvt_info; 61 struct amd64_pvt *pvt = mci->pvt_info;
52 unsigned long value; 62 unsigned long value;
53 int ret = 0; 63 int ret = 0;
@@ -66,8 +76,11 @@ static ssize_t amd64_inject_word_store(struct mem_ctl_info *mci,
66 return ret; 76 return ret;
67} 77}
68 78
69static ssize_t amd64_inject_ecc_vector_show(struct mem_ctl_info *mci, char *buf) 79static ssize_t amd64_inject_ecc_vector_show(struct device *dev,
80 struct device_attribute *mattr,
81 char *buf)
70{ 82{
83 struct mem_ctl_info *mci = to_mci(dev);
71 struct amd64_pvt *pvt = mci->pvt_info; 84 struct amd64_pvt *pvt = mci->pvt_info;
72 return sprintf(buf, "0x%x\n", pvt->injection.bit_map); 85 return sprintf(buf, "0x%x\n", pvt->injection.bit_map);
73} 86}
@@ -77,9 +90,11 @@ static ssize_t amd64_inject_ecc_vector_show(struct mem_ctl_info *mci, char *buf)
77 * corresponding bit within the error injection word above. When used during a 90 * corresponding bit within the error injection word above. When used during a
78 * DRAM ECC read, it holds the contents of the of the DRAM ECC bits. 91 * DRAM ECC read, it holds the contents of the of the DRAM ECC bits.
79 */ 92 */
80static ssize_t amd64_inject_ecc_vector_store(struct mem_ctl_info *mci, 93static ssize_t amd64_inject_ecc_vector_store(struct device *dev,
81 const char *data, size_t count) 94 struct device_attribute *mattr,
95 const char *data, size_t count)
82{ 96{
97 struct mem_ctl_info *mci = to_mci(dev);
83 struct amd64_pvt *pvt = mci->pvt_info; 98 struct amd64_pvt *pvt = mci->pvt_info;
84 unsigned long value; 99 unsigned long value;
85 int ret = 0; 100 int ret = 0;
@@ -103,9 +118,11 @@ static ssize_t amd64_inject_ecc_vector_store(struct mem_ctl_info *mci,
103 * Do a DRAM ECC read. Assemble staged values in the pvt area, format into 118 * Do a DRAM ECC read. Assemble staged values in the pvt area, format into
104 * fields needed by the injection registers and read the NB Array Data Port. 119 * fields needed by the injection registers and read the NB Array Data Port.
105 */ 120 */
106static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci, 121static ssize_t amd64_inject_read_store(struct device *dev,
107 const char *data, size_t count) 122 struct device_attribute *mattr,
123 const char *data, size_t count)
108{ 124{
125 struct mem_ctl_info *mci = to_mci(dev);
109 struct amd64_pvt *pvt = mci->pvt_info; 126 struct amd64_pvt *pvt = mci->pvt_info;
110 unsigned long value; 127 unsigned long value;
111 u32 section, word_bits; 128 u32 section, word_bits;
@@ -125,7 +142,8 @@ static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci,
125 /* Issue 'word' and 'bit' along with the READ request */ 142 /* Issue 'word' and 'bit' along with the READ request */
126 amd64_write_pci_cfg(pvt->F3, F10_NB_ARRAY_DATA, word_bits); 143 amd64_write_pci_cfg(pvt->F3, F10_NB_ARRAY_DATA, word_bits);
127 144
128 debugf0("section=0x%x word_bits=0x%x\n", section, word_bits); 145 edac_dbg(0, "section=0x%x word_bits=0x%x\n",
146 section, word_bits);
129 147
130 return count; 148 return count;
131 } 149 }
@@ -136,9 +154,11 @@ static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci,
136 * Do a DRAM ECC write. Assemble staged values in the pvt area and format into 154 * Do a DRAM ECC write. Assemble staged values in the pvt area and format into
137 * fields needed by the injection registers. 155 * fields needed by the injection registers.
138 */ 156 */
139static ssize_t amd64_inject_write_store(struct mem_ctl_info *mci, 157static ssize_t amd64_inject_write_store(struct device *dev,
158 struct device_attribute *mattr,
140 const char *data, size_t count) 159 const char *data, size_t count)
141{ 160{
161 struct mem_ctl_info *mci = to_mci(dev);
142 struct amd64_pvt *pvt = mci->pvt_info; 162 struct amd64_pvt *pvt = mci->pvt_info;
143 unsigned long value; 163 unsigned long value;
144 u32 section, word_bits; 164 u32 section, word_bits;
@@ -158,7 +178,8 @@ static ssize_t amd64_inject_write_store(struct mem_ctl_info *mci,
158 /* Issue 'word' and 'bit' along with the READ request */ 178 /* Issue 'word' and 'bit' along with the READ request */
159 amd64_write_pci_cfg(pvt->F3, F10_NB_ARRAY_DATA, word_bits); 179 amd64_write_pci_cfg(pvt->F3, F10_NB_ARRAY_DATA, word_bits);
160 180
161 debugf0("section=0x%x word_bits=0x%x\n", section, word_bits); 181 edac_dbg(0, "section=0x%x word_bits=0x%x\n",
182 section, word_bits);
162 183
163 return count; 184 return count;
164 } 185 }
@@ -168,46 +189,47 @@ static ssize_t amd64_inject_write_store(struct mem_ctl_info *mci,
168/* 189/*
169 * update NUM_INJ_ATTRS in case you add new members 190 * update NUM_INJ_ATTRS in case you add new members
170 */ 191 */
171struct mcidev_sysfs_attribute amd64_inj_attrs[] = { 192
172 193static DEVICE_ATTR(inject_section, S_IRUGO | S_IWUSR,
173 { 194 amd64_inject_section_show, amd64_inject_section_store);
174 .attr = { 195static DEVICE_ATTR(inject_word, S_IRUGO | S_IWUSR,
175 .name = "inject_section", 196 amd64_inject_word_show, amd64_inject_word_store);
176 .mode = (S_IRUGO | S_IWUSR) 197static DEVICE_ATTR(inject_ecc_vector, S_IRUGO | S_IWUSR,
177 }, 198 amd64_inject_ecc_vector_show, amd64_inject_ecc_vector_store);
178 .show = amd64_inject_section_show, 199static DEVICE_ATTR(inject_write, S_IRUGO | S_IWUSR,
179 .store = amd64_inject_section_store, 200 NULL, amd64_inject_write_store);
180 }, 201static DEVICE_ATTR(inject_read, S_IRUGO | S_IWUSR,
181 { 202 NULL, amd64_inject_read_store);
182 .attr = { 203
183 .name = "inject_word", 204
184 .mode = (S_IRUGO | S_IWUSR) 205int amd64_create_sysfs_inject_files(struct mem_ctl_info *mci)
185 }, 206{
186 .show = amd64_inject_word_show, 207 int rc;
187 .store = amd64_inject_word_store, 208
188 }, 209 rc = device_create_file(&mci->dev, &dev_attr_inject_section);
189 { 210 if (rc < 0)
190 .attr = { 211 return rc;
191 .name = "inject_ecc_vector", 212 rc = device_create_file(&mci->dev, &dev_attr_inject_word);
192 .mode = (S_IRUGO | S_IWUSR) 213 if (rc < 0)
193 }, 214 return rc;
194 .show = amd64_inject_ecc_vector_show, 215 rc = device_create_file(&mci->dev, &dev_attr_inject_ecc_vector);
195 .store = amd64_inject_ecc_vector_store, 216 if (rc < 0)
196 }, 217 return rc;
197 { 218 rc = device_create_file(&mci->dev, &dev_attr_inject_write);
198 .attr = { 219 if (rc < 0)
199 .name = "inject_write", 220 return rc;
200 .mode = (S_IRUGO | S_IWUSR) 221 rc = device_create_file(&mci->dev, &dev_attr_inject_read);
201 }, 222 if (rc < 0)
202 .show = NULL, 223 return rc;
203 .store = amd64_inject_write_store, 224
204 }, 225 return 0;
205 { 226}
206 .attr = { 227
207 .name = "inject_read", 228void amd64_remove_sysfs_inject_files(struct mem_ctl_info *mci)
208 .mode = (S_IRUGO | S_IWUSR) 229{
209 }, 230 device_remove_file(&mci->dev, &dev_attr_inject_section);
210 .show = NULL, 231 device_remove_file(&mci->dev, &dev_attr_inject_word);
211 .store = amd64_inject_read_store, 232 device_remove_file(&mci->dev, &dev_attr_inject_ecc_vector);
212 }, 233 device_remove_file(&mci->dev, &dev_attr_inject_write);
213}; 234 device_remove_file(&mci->dev, &dev_attr_inject_read);
235}
diff --git a/drivers/edac/amd76x_edac.c b/drivers/edac/amd76x_edac.c
index 9774d443fa57..29eeb68a200c 100644
--- a/drivers/edac/amd76x_edac.c
+++ b/drivers/edac/amd76x_edac.c
@@ -105,7 +105,7 @@ static void amd76x_get_error_info(struct mem_ctl_info *mci,
105{ 105{
106 struct pci_dev *pdev; 106 struct pci_dev *pdev;
107 107
108 pdev = to_pci_dev(mci->dev); 108 pdev = to_pci_dev(mci->pdev);
109 pci_read_config_dword(pdev, AMD76X_ECC_MODE_STATUS, 109 pci_read_config_dword(pdev, AMD76X_ECC_MODE_STATUS,
110 &info->ecc_mode_status); 110 &info->ecc_mode_status);
111 111
@@ -145,10 +145,10 @@ static int amd76x_process_error_info(struct mem_ctl_info *mci,
145 145
146 if (handle_errors) { 146 if (handle_errors) {
147 row = (info->ecc_mode_status >> 4) & 0xf; 147 row = (info->ecc_mode_status >> 4) & 0xf;
148 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 148 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
149 mci->csrows[row].first_page, 0, 0, 149 mci->csrows[row]->first_page, 0, 0,
150 row, 0, -1, 150 row, 0, -1,
151 mci->ctl_name, "", NULL); 151 mci->ctl_name, "");
152 } 152 }
153 } 153 }
154 154
@@ -160,10 +160,10 @@ static int amd76x_process_error_info(struct mem_ctl_info *mci,
160 160
161 if (handle_errors) { 161 if (handle_errors) {
162 row = info->ecc_mode_status & 0xf; 162 row = info->ecc_mode_status & 0xf;
163 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 163 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
164 mci->csrows[row].first_page, 0, 0, 164 mci->csrows[row]->first_page, 0, 0,
165 row, 0, -1, 165 row, 0, -1,
166 mci->ctl_name, "", NULL); 166 mci->ctl_name, "");
167 } 167 }
168 } 168 }
169 169
@@ -180,7 +180,7 @@ static int amd76x_process_error_info(struct mem_ctl_info *mci,
180static void amd76x_check(struct mem_ctl_info *mci) 180static void amd76x_check(struct mem_ctl_info *mci)
181{ 181{
182 struct amd76x_error_info info; 182 struct amd76x_error_info info;
183 debugf3("%s()\n", __func__); 183 edac_dbg(3, "\n");
184 amd76x_get_error_info(mci, &info); 184 amd76x_get_error_info(mci, &info);
185 amd76x_process_error_info(mci, &info, 1); 185 amd76x_process_error_info(mci, &info, 1);
186} 186}
@@ -194,8 +194,8 @@ static void amd76x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
194 int index; 194 int index;
195 195
196 for (index = 0; index < mci->nr_csrows; index++) { 196 for (index = 0; index < mci->nr_csrows; index++) {
197 csrow = &mci->csrows[index]; 197 csrow = mci->csrows[index];
198 dimm = csrow->channels[0].dimm; 198 dimm = csrow->channels[0]->dimm;
199 199
200 /* find the DRAM Chip Select Base address and mask */ 200 /* find the DRAM Chip Select Base address and mask */
201 pci_read_config_dword(pdev, 201 pci_read_config_dword(pdev,
@@ -241,7 +241,7 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
241 u32 ems_mode; 241 u32 ems_mode;
242 struct amd76x_error_info discard; 242 struct amd76x_error_info discard;
243 243
244 debugf0("%s()\n", __func__); 244 edac_dbg(0, "\n");
245 pci_read_config_dword(pdev, AMD76X_ECC_MODE_STATUS, &ems); 245 pci_read_config_dword(pdev, AMD76X_ECC_MODE_STATUS, &ems);
246 ems_mode = (ems >> 10) & 0x3; 246 ems_mode = (ems >> 10) & 0x3;
247 247
@@ -256,8 +256,8 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
256 if (mci == NULL) 256 if (mci == NULL)
257 return -ENOMEM; 257 return -ENOMEM;
258 258
259 debugf0("%s(): mci = %p\n", __func__, mci); 259 edac_dbg(0, "mci = %p\n", mci);
260 mci->dev = &pdev->dev; 260 mci->pdev = &pdev->dev;
261 mci->mtype_cap = MEM_FLAG_RDDR; 261 mci->mtype_cap = MEM_FLAG_RDDR;
262 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; 262 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
263 mci->edac_cap = ems_mode ? 263 mci->edac_cap = ems_mode ?
@@ -276,7 +276,7 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
276 * type of memory controller. The ID is therefore hardcoded to 0. 276 * type of memory controller. The ID is therefore hardcoded to 0.
277 */ 277 */
278 if (edac_mc_add_mc(mci)) { 278 if (edac_mc_add_mc(mci)) {
279 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 279 edac_dbg(3, "failed edac_mc_add_mc()\n");
280 goto fail; 280 goto fail;
281 } 281 }
282 282
@@ -292,7 +292,7 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
292 } 292 }
293 293
294 /* get this far and it's successful */ 294 /* get this far and it's successful */
295 debugf3("%s(): success\n", __func__); 295 edac_dbg(3, "success\n");
296 return 0; 296 return 0;
297 297
298fail: 298fail:
@@ -304,7 +304,7 @@ fail:
304static int __devinit amd76x_init_one(struct pci_dev *pdev, 304static int __devinit amd76x_init_one(struct pci_dev *pdev,
305 const struct pci_device_id *ent) 305 const struct pci_device_id *ent)
306{ 306{
307 debugf0("%s()\n", __func__); 307 edac_dbg(0, "\n");
308 308
309 /* don't need to call pci_enable_device() */ 309 /* don't need to call pci_enable_device() */
310 return amd76x_probe1(pdev, ent->driver_data); 310 return amd76x_probe1(pdev, ent->driver_data);
@@ -322,7 +322,7 @@ static void __devexit amd76x_remove_one(struct pci_dev *pdev)
322{ 322{
323 struct mem_ctl_info *mci; 323 struct mem_ctl_info *mci;
324 324
325 debugf0("%s()\n", __func__); 325 edac_dbg(0, "\n");
326 326
327 if (amd76x_pci) 327 if (amd76x_pci)
328 edac_pci_release_generic_ctl(amd76x_pci); 328 edac_pci_release_generic_ctl(amd76x_pci);
diff --git a/drivers/edac/cell_edac.c b/drivers/edac/cell_edac.c
index 69ee6aab5c71..a1bbd8edd257 100644
--- a/drivers/edac/cell_edac.c
+++ b/drivers/edac/cell_edac.c
@@ -33,10 +33,10 @@ struct cell_edac_priv
33static void cell_edac_count_ce(struct mem_ctl_info *mci, int chan, u64 ar) 33static void cell_edac_count_ce(struct mem_ctl_info *mci, int chan, u64 ar)
34{ 34{
35 struct cell_edac_priv *priv = mci->pvt_info; 35 struct cell_edac_priv *priv = mci->pvt_info;
36 struct csrow_info *csrow = &mci->csrows[0]; 36 struct csrow_info *csrow = mci->csrows[0];
37 unsigned long address, pfn, offset, syndrome; 37 unsigned long address, pfn, offset, syndrome;
38 38
39 dev_dbg(mci->dev, "ECC CE err on node %d, channel %d, ar = 0x%016llx\n", 39 dev_dbg(mci->pdev, "ECC CE err on node %d, channel %d, ar = 0x%016llx\n",
40 priv->node, chan, ar); 40 priv->node, chan, ar);
41 41
42 /* Address decoding is likely a bit bogus, to dbl check */ 42 /* Address decoding is likely a bit bogus, to dbl check */
@@ -48,18 +48,18 @@ static void cell_edac_count_ce(struct mem_ctl_info *mci, int chan, u64 ar)
48 syndrome = (ar & 0x000000001fe00000ul) >> 21; 48 syndrome = (ar & 0x000000001fe00000ul) >> 21;
49 49
50 /* TODO: Decoding of the error address */ 50 /* TODO: Decoding of the error address */
51 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 51 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
52 csrow->first_page + pfn, offset, syndrome, 52 csrow->first_page + pfn, offset, syndrome,
53 0, chan, -1, "", "", NULL); 53 0, chan, -1, "", "");
54} 54}
55 55
56static void cell_edac_count_ue(struct mem_ctl_info *mci, int chan, u64 ar) 56static void cell_edac_count_ue(struct mem_ctl_info *mci, int chan, u64 ar)
57{ 57{
58 struct cell_edac_priv *priv = mci->pvt_info; 58 struct cell_edac_priv *priv = mci->pvt_info;
59 struct csrow_info *csrow = &mci->csrows[0]; 59 struct csrow_info *csrow = mci->csrows[0];
60 unsigned long address, pfn, offset; 60 unsigned long address, pfn, offset;
61 61
62 dev_dbg(mci->dev, "ECC UE err on node %d, channel %d, ar = 0x%016llx\n", 62 dev_dbg(mci->pdev, "ECC UE err on node %d, channel %d, ar = 0x%016llx\n",
63 priv->node, chan, ar); 63 priv->node, chan, ar);
64 64
65 /* Address decoding is likely a bit bogus, to dbl check */ 65 /* Address decoding is likely a bit bogus, to dbl check */
@@ -70,9 +70,9 @@ static void cell_edac_count_ue(struct mem_ctl_info *mci, int chan, u64 ar)
70 offset = address & ~PAGE_MASK; 70 offset = address & ~PAGE_MASK;
71 71
72 /* TODO: Decoding of the error address */ 72 /* TODO: Decoding of the error address */
73 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 73 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
74 csrow->first_page + pfn, offset, 0, 74 csrow->first_page + pfn, offset, 0,
75 0, chan, -1, "", "", NULL); 75 0, chan, -1, "", "");
76} 76}
77 77
78static void cell_edac_check(struct mem_ctl_info *mci) 78static void cell_edac_check(struct mem_ctl_info *mci)
@@ -83,7 +83,7 @@ static void cell_edac_check(struct mem_ctl_info *mci)
83 fir = in_be64(&priv->regs->mic_fir); 83 fir = in_be64(&priv->regs->mic_fir);
84#ifdef DEBUG 84#ifdef DEBUG
85 if (fir != priv->prev_fir) { 85 if (fir != priv->prev_fir) {
86 dev_dbg(mci->dev, "fir change : 0x%016lx\n", fir); 86 dev_dbg(mci->pdev, "fir change : 0x%016lx\n", fir);
87 priv->prev_fir = fir; 87 priv->prev_fir = fir;
88 } 88 }
89#endif 89#endif
@@ -119,14 +119,14 @@ static void cell_edac_check(struct mem_ctl_info *mci)
119 mb(); /* sync up */ 119 mb(); /* sync up */
120#ifdef DEBUG 120#ifdef DEBUG
121 fir = in_be64(&priv->regs->mic_fir); 121 fir = in_be64(&priv->regs->mic_fir);
122 dev_dbg(mci->dev, "fir clear : 0x%016lx\n", fir); 122 dev_dbg(mci->pdev, "fir clear : 0x%016lx\n", fir);
123#endif 123#endif
124 } 124 }
125} 125}
126 126
127static void __devinit cell_edac_init_csrows(struct mem_ctl_info *mci) 127static void __devinit cell_edac_init_csrows(struct mem_ctl_info *mci)
128{ 128{
129 struct csrow_info *csrow = &mci->csrows[0]; 129 struct csrow_info *csrow = mci->csrows[0];
130 struct dimm_info *dimm; 130 struct dimm_info *dimm;
131 struct cell_edac_priv *priv = mci->pvt_info; 131 struct cell_edac_priv *priv = mci->pvt_info;
132 struct device_node *np; 132 struct device_node *np;
@@ -150,12 +150,12 @@ static void __devinit cell_edac_init_csrows(struct mem_ctl_info *mci)
150 csrow->last_page = csrow->first_page + nr_pages - 1; 150 csrow->last_page = csrow->first_page + nr_pages - 1;
151 151
152 for (j = 0; j < csrow->nr_channels; j++) { 152 for (j = 0; j < csrow->nr_channels; j++) {
153 dimm = csrow->channels[j].dimm; 153 dimm = csrow->channels[j]->dimm;
154 dimm->mtype = MEM_XDR; 154 dimm->mtype = MEM_XDR;
155 dimm->edac_mode = EDAC_SECDED; 155 dimm->edac_mode = EDAC_SECDED;
156 dimm->nr_pages = nr_pages / csrow->nr_channels; 156 dimm->nr_pages = nr_pages / csrow->nr_channels;
157 } 157 }
158 dev_dbg(mci->dev, 158 dev_dbg(mci->pdev,
159 "Initialized on node %d, chanmask=0x%x," 159 "Initialized on node %d, chanmask=0x%x,"
160 " first_page=0x%lx, nr_pages=0x%x\n", 160 " first_page=0x%lx, nr_pages=0x%x\n",
161 priv->node, priv->chanmask, 161 priv->node, priv->chanmask,
@@ -212,7 +212,7 @@ static int __devinit cell_edac_probe(struct platform_device *pdev)
212 priv->regs = regs; 212 priv->regs = regs;
213 priv->node = pdev->id; 213 priv->node = pdev->id;
214 priv->chanmask = chanmask; 214 priv->chanmask = chanmask;
215 mci->dev = &pdev->dev; 215 mci->pdev = &pdev->dev;
216 mci->mtype_cap = MEM_FLAG_XDR; 216 mci->mtype_cap = MEM_FLAG_XDR;
217 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; 217 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
218 mci->edac_cap = EDAC_FLAG_EC | EDAC_FLAG_SECDED; 218 mci->edac_cap = EDAC_FLAG_EC | EDAC_FLAG_SECDED;
diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
index e22030a9de66..c2ef13495873 100644
--- a/drivers/edac/cpc925_edac.c
+++ b/drivers/edac/cpc925_edac.c
@@ -316,13 +316,12 @@ static void get_total_mem(struct cpc925_mc_pdata *pdata)
316 reg += aw; 316 reg += aw;
317 size = of_read_number(reg, sw); 317 size = of_read_number(reg, sw);
318 reg += sw; 318 reg += sw;
319 debugf1("%s: start 0x%lx, size 0x%lx\n", __func__, 319 edac_dbg(1, "start 0x%lx, size 0x%lx\n", start, size);
320 start, size);
321 pdata->total_mem += size; 320 pdata->total_mem += size;
322 } while (reg < reg_end); 321 } while (reg < reg_end);
323 322
324 of_node_put(np); 323 of_node_put(np);
325 debugf0("%s: total_mem 0x%lx\n", __func__, pdata->total_mem); 324 edac_dbg(0, "total_mem 0x%lx\n", pdata->total_mem);
326} 325}
327 326
328static void cpc925_init_csrows(struct mem_ctl_info *mci) 327static void cpc925_init_csrows(struct mem_ctl_info *mci)
@@ -330,8 +329,9 @@ static void cpc925_init_csrows(struct mem_ctl_info *mci)
330 struct cpc925_mc_pdata *pdata = mci->pvt_info; 329 struct cpc925_mc_pdata *pdata = mci->pvt_info;
331 struct csrow_info *csrow; 330 struct csrow_info *csrow;
332 struct dimm_info *dimm; 331 struct dimm_info *dimm;
332 enum dev_type dtype;
333 int index, j; 333 int index, j;
334 u32 mbmr, mbbar, bba; 334 u32 mbmr, mbbar, bba, grain;
335 unsigned long row_size, nr_pages, last_nr_pages = 0; 335 unsigned long row_size, nr_pages, last_nr_pages = 0;
336 336
337 get_total_mem(pdata); 337 get_total_mem(pdata);
@@ -347,7 +347,7 @@ static void cpc925_init_csrows(struct mem_ctl_info *mci)
347 if (bba == 0) 347 if (bba == 0)
348 continue; /* not populated */ 348 continue; /* not populated */
349 349
350 csrow = &mci->csrows[index]; 350 csrow = mci->csrows[index];
351 351
352 row_size = bba * (1UL << 28); /* 256M */ 352 row_size = bba * (1UL << 28); /* 256M */
353 csrow->first_page = last_nr_pages; 353 csrow->first_page = last_nr_pages;
@@ -355,37 +355,36 @@ static void cpc925_init_csrows(struct mem_ctl_info *mci)
355 csrow->last_page = csrow->first_page + nr_pages - 1; 355 csrow->last_page = csrow->first_page + nr_pages - 1;
356 last_nr_pages = csrow->last_page + 1; 356 last_nr_pages = csrow->last_page + 1;
357 357
358 switch (csrow->nr_channels) {
359 case 1: /* Single channel */
360 grain = 32; /* four-beat burst of 32 bytes */
361 break;
362 case 2: /* Dual channel */
363 default:
364 grain = 64; /* four-beat burst of 64 bytes */
365 break;
366 }
367 switch ((mbmr & MBMR_MODE_MASK) >> MBMR_MODE_SHIFT) {
368 case 6: /* 0110, no way to differentiate X8 VS X16 */
369 case 5: /* 0101 */
370 case 8: /* 1000 */
371 dtype = DEV_X16;
372 break;
373 case 7: /* 0111 */
374 case 9: /* 1001 */
375 dtype = DEV_X8;
376 break;
377 default:
378 dtype = DEV_UNKNOWN;
379 break;
380 }
358 for (j = 0; j < csrow->nr_channels; j++) { 381 for (j = 0; j < csrow->nr_channels; j++) {
359 dimm = csrow->channels[j].dimm; 382 dimm = csrow->channels[j]->dimm;
360
361 dimm->nr_pages = nr_pages / csrow->nr_channels; 383 dimm->nr_pages = nr_pages / csrow->nr_channels;
362 dimm->mtype = MEM_RDDR; 384 dimm->mtype = MEM_RDDR;
363 dimm->edac_mode = EDAC_SECDED; 385 dimm->edac_mode = EDAC_SECDED;
364 386 dimm->grain = grain;
365 switch (csrow->nr_channels) { 387 dimm->dtype = dtype;
366 case 1: /* Single channel */
367 dimm->grain = 32; /* four-beat burst of 32 bytes */
368 break;
369 case 2: /* Dual channel */
370 default:
371 dimm->grain = 64; /* four-beat burst of 64 bytes */
372 break;
373 }
374
375 switch ((mbmr & MBMR_MODE_MASK) >> MBMR_MODE_SHIFT) {
376 case 6: /* 0110, no way to differentiate X8 VS X16 */
377 case 5: /* 0101 */
378 case 8: /* 1000 */
379 dimm->dtype = DEV_X16;
380 break;
381 case 7: /* 0111 */
382 case 9: /* 1001 */
383 dimm->dtype = DEV_X8;
384 break;
385 default:
386 dimm->dtype = DEV_UNKNOWN;
387 break;
388 }
389 } 388 }
390 } 389 }
391} 390}
@@ -463,7 +462,7 @@ static void cpc925_mc_get_pfn(struct mem_ctl_info *mci, u32 mear,
463 *csrow = rank; 462 *csrow = rank;
464 463
465#ifdef CONFIG_EDAC_DEBUG 464#ifdef CONFIG_EDAC_DEBUG
466 if (mci->csrows[rank].first_page == 0) { 465 if (mci->csrows[rank]->first_page == 0) {
467 cpc925_mc_printk(mci, KERN_ERR, "ECC occurs in a " 466 cpc925_mc_printk(mci, KERN_ERR, "ECC occurs in a "
468 "non-populated csrow, broken hardware?\n"); 467 "non-populated csrow, broken hardware?\n");
469 return; 468 return;
@@ -471,7 +470,7 @@ static void cpc925_mc_get_pfn(struct mem_ctl_info *mci, u32 mear,
471#endif 470#endif
472 471
473 /* Revert csrow number */ 472 /* Revert csrow number */
474 pa = mci->csrows[rank].first_page << PAGE_SHIFT; 473 pa = mci->csrows[rank]->first_page << PAGE_SHIFT;
475 474
476 /* Revert column address */ 475 /* Revert column address */
477 col += bcnt; 476 col += bcnt;
@@ -512,7 +511,7 @@ static void cpc925_mc_get_pfn(struct mem_ctl_info *mci, u32 mear,
512 *offset = pa & (PAGE_SIZE - 1); 511 *offset = pa & (PAGE_SIZE - 1);
513 *pfn = pa >> PAGE_SHIFT; 512 *pfn = pa >> PAGE_SHIFT;
514 513
515 debugf0("%s: ECC physical address 0x%lx\n", __func__, pa); 514 edac_dbg(0, "ECC physical address 0x%lx\n", pa);
516} 515}
517 516
518static int cpc925_mc_find_channel(struct mem_ctl_info *mci, u16 syndrome) 517static int cpc925_mc_find_channel(struct mem_ctl_info *mci, u16 syndrome)
@@ -555,18 +554,18 @@ static void cpc925_mc_check(struct mem_ctl_info *mci)
555 if (apiexcp & CECC_EXCP_DETECTED) { 554 if (apiexcp & CECC_EXCP_DETECTED) {
556 cpc925_mc_printk(mci, KERN_INFO, "DRAM CECC Fault\n"); 555 cpc925_mc_printk(mci, KERN_INFO, "DRAM CECC Fault\n");
557 channel = cpc925_mc_find_channel(mci, syndrome); 556 channel = cpc925_mc_find_channel(mci, syndrome);
558 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 557 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
559 pfn, offset, syndrome, 558 pfn, offset, syndrome,
560 csrow, channel, -1, 559 csrow, channel, -1,
561 mci->ctl_name, "", NULL); 560 mci->ctl_name, "");
562 } 561 }
563 562
564 if (apiexcp & UECC_EXCP_DETECTED) { 563 if (apiexcp & UECC_EXCP_DETECTED) {
565 cpc925_mc_printk(mci, KERN_INFO, "DRAM UECC Fault\n"); 564 cpc925_mc_printk(mci, KERN_INFO, "DRAM UECC Fault\n");
566 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 565 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
567 pfn, offset, 0, 566 pfn, offset, 0,
568 csrow, -1, -1, 567 csrow, -1, -1,
569 mci->ctl_name, "", NULL); 568 mci->ctl_name, "");
570 } 569 }
571 570
572 cpc925_mc_printk(mci, KERN_INFO, "Dump registers:\n"); 571 cpc925_mc_printk(mci, KERN_INFO, "Dump registers:\n");
@@ -852,8 +851,8 @@ static void cpc925_add_edac_devices(void __iomem *vbase)
852 goto err2; 851 goto err2;
853 } 852 }
854 853
855 debugf0("%s: Successfully added edac device for %s\n", 854 edac_dbg(0, "Successfully added edac device for %s\n",
856 __func__, dev_info->ctl_name); 855 dev_info->ctl_name);
857 856
858 continue; 857 continue;
859 858
@@ -884,8 +883,8 @@ static void cpc925_del_edac_devices(void)
884 if (dev_info->exit) 883 if (dev_info->exit)
885 dev_info->exit(dev_info); 884 dev_info->exit(dev_info);
886 885
887 debugf0("%s: Successfully deleted edac device for %s\n", 886 edac_dbg(0, "Successfully deleted edac device for %s\n",
888 __func__, dev_info->ctl_name); 887 dev_info->ctl_name);
889 } 888 }
890} 889}
891 890
@@ -900,7 +899,7 @@ static int cpc925_get_sdram_scrub_rate(struct mem_ctl_info *mci)
900 mscr = __raw_readl(pdata->vbase + REG_MSCR_OFFSET); 899 mscr = __raw_readl(pdata->vbase + REG_MSCR_OFFSET);
901 si = (mscr & MSCR_SI_MASK) >> MSCR_SI_SHIFT; 900 si = (mscr & MSCR_SI_MASK) >> MSCR_SI_SHIFT;
902 901
903 debugf0("%s, Mem Scrub Ctrl Register 0x%x\n", __func__, mscr); 902 edac_dbg(0, "Mem Scrub Ctrl Register 0x%x\n", mscr);
904 903
905 if (((mscr & MSCR_SCRUB_MOD_MASK) != MSCR_BACKGR_SCRUB) || 904 if (((mscr & MSCR_SCRUB_MOD_MASK) != MSCR_BACKGR_SCRUB) ||
906 (si == 0)) { 905 (si == 0)) {
@@ -928,8 +927,7 @@ static int cpc925_mc_get_channels(void __iomem *vbase)
928 ((mbcr & MBCR_64BITBUS_MASK) == 0)) 927 ((mbcr & MBCR_64BITBUS_MASK) == 0))
929 dual = 1; 928 dual = 1;
930 929
931 debugf0("%s: %s channel\n", __func__, 930 edac_dbg(0, "%s channel\n", (dual > 0) ? "Dual" : "Single");
932 (dual > 0) ? "Dual" : "Single");
933 931
934 return dual; 932 return dual;
935} 933}
@@ -944,7 +942,7 @@ static int __devinit cpc925_probe(struct platform_device *pdev)
944 struct resource *r; 942 struct resource *r;
945 int res = 0, nr_channels; 943 int res = 0, nr_channels;
946 944
947 debugf0("%s: %s platform device found!\n", __func__, pdev->name); 945 edac_dbg(0, "%s platform device found!\n", pdev->name);
948 946
949 if (!devres_open_group(&pdev->dev, cpc925_probe, GFP_KERNEL)) { 947 if (!devres_open_group(&pdev->dev, cpc925_probe, GFP_KERNEL)) {
950 res = -ENOMEM; 948 res = -ENOMEM;
@@ -995,7 +993,7 @@ static int __devinit cpc925_probe(struct platform_device *pdev)
995 pdata->edac_idx = edac_mc_idx++; 993 pdata->edac_idx = edac_mc_idx++;
996 pdata->name = pdev->name; 994 pdata->name = pdev->name;
997 995
998 mci->dev = &pdev->dev; 996 mci->pdev = &pdev->dev;
999 platform_set_drvdata(pdev, mci); 997 platform_set_drvdata(pdev, mci);
1000 mci->dev_name = dev_name(&pdev->dev); 998 mci->dev_name = dev_name(&pdev->dev);
1001 mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR; 999 mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR;
@@ -1026,7 +1024,7 @@ static int __devinit cpc925_probe(struct platform_device *pdev)
1026 cpc925_add_edac_devices(vbase); 1024 cpc925_add_edac_devices(vbase);
1027 1025
1028 /* get this far and it's successful */ 1026 /* get this far and it's successful */
1029 debugf0("%s: success\n", __func__); 1027 edac_dbg(0, "success\n");
1030 1028
1031 res = 0; 1029 res = 0;
1032 goto out; 1030 goto out;
diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
index 3186512c9739..a5ed6b795fd4 100644
--- a/drivers/edac/e752x_edac.c
+++ b/drivers/edac/e752x_edac.c
@@ -309,7 +309,7 @@ static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci,
309 u32 remap; 309 u32 remap;
310 struct e752x_pvt *pvt = (struct e752x_pvt *)mci->pvt_info; 310 struct e752x_pvt *pvt = (struct e752x_pvt *)mci->pvt_info;
311 311
312 debugf3("%s()\n", __func__); 312 edac_dbg(3, "\n");
313 313
314 if (page < pvt->tolm) 314 if (page < pvt->tolm)
315 return page; 315 return page;
@@ -335,7 +335,7 @@ static void do_process_ce(struct mem_ctl_info *mci, u16 error_one,
335 int i; 335 int i;
336 struct e752x_pvt *pvt = (struct e752x_pvt *)mci->pvt_info; 336 struct e752x_pvt *pvt = (struct e752x_pvt *)mci->pvt_info;
337 337
338 debugf3("%s()\n", __func__); 338 edac_dbg(3, "\n");
339 339
340 /* convert the addr to 4k page */ 340 /* convert the addr to 4k page */
341 page = sec1_add >> (PAGE_SHIFT - 4); 341 page = sec1_add >> (PAGE_SHIFT - 4);
@@ -371,10 +371,10 @@ static void do_process_ce(struct mem_ctl_info *mci, u16 error_one,
371 channel = !(error_one & 1); 371 channel = !(error_one & 1);
372 372
373 /* e752x mc reads 34:6 of the DRAM linear address */ 373 /* e752x mc reads 34:6 of the DRAM linear address */
374 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 374 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
375 page, offset_in_page(sec1_add << 4), sec1_syndrome, 375 page, offset_in_page(sec1_add << 4), sec1_syndrome,
376 row, channel, -1, 376 row, channel, -1,
377 "e752x CE", "", NULL); 377 "e752x CE", "");
378} 378}
379 379
380static inline void process_ce(struct mem_ctl_info *mci, u16 error_one, 380static inline void process_ce(struct mem_ctl_info *mci, u16 error_one,
@@ -394,7 +394,7 @@ static void do_process_ue(struct mem_ctl_info *mci, u16 error_one,
394 int row; 394 int row;
395 struct e752x_pvt *pvt = (struct e752x_pvt *)mci->pvt_info; 395 struct e752x_pvt *pvt = (struct e752x_pvt *)mci->pvt_info;
396 396
397 debugf3("%s()\n", __func__); 397 edac_dbg(3, "\n");
398 398
399 if (error_one & 0x0202) { 399 if (error_one & 0x0202) {
400 error_2b = ded_add; 400 error_2b = ded_add;
@@ -408,11 +408,11 @@ static void do_process_ue(struct mem_ctl_info *mci, u16 error_one,
408 edac_mc_find_csrow_by_page(mci, block_page); 408 edac_mc_find_csrow_by_page(mci, block_page);
409 409
410 /* e752x mc reads 34:6 of the DRAM linear address */ 410 /* e752x mc reads 34:6 of the DRAM linear address */
411 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 411 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
412 block_page, 412 block_page,
413 offset_in_page(error_2b << 4), 0, 413 offset_in_page(error_2b << 4), 0,
414 row, -1, -1, 414 row, -1, -1,
415 "e752x UE from Read", "", NULL); 415 "e752x UE from Read", "");
416 416
417 } 417 }
418 if (error_one & 0x0404) { 418 if (error_one & 0x0404) {
@@ -427,11 +427,11 @@ static void do_process_ue(struct mem_ctl_info *mci, u16 error_one,
427 edac_mc_find_csrow_by_page(mci, block_page); 427 edac_mc_find_csrow_by_page(mci, block_page);
428 428
429 /* e752x mc reads 34:6 of the DRAM linear address */ 429 /* e752x mc reads 34:6 of the DRAM linear address */
430 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 430 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
431 block_page, 431 block_page,
432 offset_in_page(error_2b << 4), 0, 432 offset_in_page(error_2b << 4), 0,
433 row, -1, -1, 433 row, -1, -1,
434 "e752x UE from Scruber", "", NULL); 434 "e752x UE from Scruber", "");
435 } 435 }
436} 436}
437 437
@@ -453,10 +453,10 @@ static inline void process_ue_no_info_wr(struct mem_ctl_info *mci,
453 if (!handle_error) 453 if (!handle_error)
454 return; 454 return;
455 455
456 debugf3("%s()\n", __func__); 456 edac_dbg(3, "\n");
457 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 0, 0, 0, 457 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0,
458 -1, -1, -1, 458 -1, -1, -1,
459 "e752x UE log memory write", "", NULL); 459 "e752x UE log memory write", "");
460} 460}
461 461
462static void do_process_ded_retry(struct mem_ctl_info *mci, u16 error, 462static void do_process_ded_retry(struct mem_ctl_info *mci, u16 error,
@@ -982,7 +982,7 @@ static void e752x_check(struct mem_ctl_info *mci)
982{ 982{
983 struct e752x_error_info info; 983 struct e752x_error_info info;
984 984
985 debugf3("%s()\n", __func__); 985 edac_dbg(3, "\n");
986 e752x_get_error_info(mci, &info); 986 e752x_get_error_info(mci, &info);
987 e752x_process_error_info(mci, &info, 1); 987 e752x_process_error_info(mci, &info, 1);
988} 988}
@@ -1069,6 +1069,7 @@ static void e752x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
1069 u16 ddrcsr) 1069 u16 ddrcsr)
1070{ 1070{
1071 struct csrow_info *csrow; 1071 struct csrow_info *csrow;
1072 enum edac_type edac_mode;
1072 unsigned long last_cumul_size; 1073 unsigned long last_cumul_size;
1073 int index, mem_dev, drc_chan; 1074 int index, mem_dev, drc_chan;
1074 int drc_drbg; /* DRB granularity 0=64mb, 1=128mb */ 1075 int drc_drbg; /* DRB granularity 0=64mb, 1=128mb */
@@ -1095,14 +1096,13 @@ static void e752x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
1095 for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) { 1096 for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
1096 /* mem_dev 0=x8, 1=x4 */ 1097 /* mem_dev 0=x8, 1=x4 */
1097 mem_dev = (dra >> (index * 4 + 2)) & 0x3; 1098 mem_dev = (dra >> (index * 4 + 2)) & 0x3;
1098 csrow = &mci->csrows[remap_csrow_index(mci, index)]; 1099 csrow = mci->csrows[remap_csrow_index(mci, index)];
1099 1100
1100 mem_dev = (mem_dev == 2); 1101 mem_dev = (mem_dev == 2);
1101 pci_read_config_byte(pdev, E752X_DRB + index, &value); 1102 pci_read_config_byte(pdev, E752X_DRB + index, &value);
1102 /* convert a 128 or 64 MiB DRB to a page size. */ 1103 /* convert a 128 or 64 MiB DRB to a page size. */
1103 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT); 1104 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
1104 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, 1105 edac_dbg(3, "(%d) cumul_size 0x%x\n", index, cumul_size);
1105 cumul_size);
1106 if (cumul_size == last_cumul_size) 1106 if (cumul_size == last_cumul_size)
1107 continue; /* not populated */ 1107 continue; /* not populated */
1108 1108
@@ -1111,29 +1111,29 @@ static void e752x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
1111 nr_pages = cumul_size - last_cumul_size; 1111 nr_pages = cumul_size - last_cumul_size;
1112 last_cumul_size = cumul_size; 1112 last_cumul_size = cumul_size;
1113 1113
1114 /*
1115 * if single channel or x8 devices then SECDED
1116 * if dual channel and x4 then S4ECD4ED
1117 */
1118 if (drc_ddim) {
1119 if (drc_chan && mem_dev) {
1120 edac_mode = EDAC_S4ECD4ED;
1121 mci->edac_cap |= EDAC_FLAG_S4ECD4ED;
1122 } else {
1123 edac_mode = EDAC_SECDED;
1124 mci->edac_cap |= EDAC_FLAG_SECDED;
1125 }
1126 } else
1127 edac_mode = EDAC_NONE;
1114 for (i = 0; i < csrow->nr_channels; i++) { 1128 for (i = 0; i < csrow->nr_channels; i++) {
1115 struct dimm_info *dimm = csrow->channels[i].dimm; 1129 struct dimm_info *dimm = csrow->channels[i]->dimm;
1116 1130
1117 debugf3("Initializing rank at (%i,%i)\n", index, i); 1131 edac_dbg(3, "Initializing rank at (%i,%i)\n", index, i);
1118 dimm->nr_pages = nr_pages / csrow->nr_channels; 1132 dimm->nr_pages = nr_pages / csrow->nr_channels;
1119 dimm->grain = 1 << 12; /* 4KiB - resolution of CELOG */ 1133 dimm->grain = 1 << 12; /* 4KiB - resolution of CELOG */
1120 dimm->mtype = MEM_RDDR; /* only one type supported */ 1134 dimm->mtype = MEM_RDDR; /* only one type supported */
1121 dimm->dtype = mem_dev ? DEV_X4 : DEV_X8; 1135 dimm->dtype = mem_dev ? DEV_X4 : DEV_X8;
1122 1136 dimm->edac_mode = edac_mode;
1123 /*
1124 * if single channel or x8 devices then SECDED
1125 * if dual channel and x4 then S4ECD4ED
1126 */
1127 if (drc_ddim) {
1128 if (drc_chan && mem_dev) {
1129 dimm->edac_mode = EDAC_S4ECD4ED;
1130 mci->edac_cap |= EDAC_FLAG_S4ECD4ED;
1131 } else {
1132 dimm->edac_mode = EDAC_SECDED;
1133 mci->edac_cap |= EDAC_FLAG_SECDED;
1134 }
1135 } else
1136 dimm->edac_mode = EDAC_NONE;
1137 } 1137 }
1138 } 1138 }
1139} 1139}
@@ -1269,8 +1269,8 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
1269 int drc_chan; /* Number of channels 0=1chan,1=2chan */ 1269 int drc_chan; /* Number of channels 0=1chan,1=2chan */
1270 struct e752x_error_info discard; 1270 struct e752x_error_info discard;
1271 1271
1272 debugf0("%s(): mci\n", __func__); 1272 edac_dbg(0, "mci\n");
1273 debugf0("Starting Probe1\n"); 1273 edac_dbg(0, "Starting Probe1\n");
1274 1274
1275 /* check to see if device 0 function 1 is enabled; if it isn't, we 1275 /* check to see if device 0 function 1 is enabled; if it isn't, we
1276 * assume the BIOS has reserved it for a reason and is expecting 1276 * assume the BIOS has reserved it for a reason and is expecting
@@ -1300,7 +1300,7 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
1300 if (mci == NULL) 1300 if (mci == NULL)
1301 return -ENOMEM; 1301 return -ENOMEM;
1302 1302
1303 debugf3("%s(): init mci\n", __func__); 1303 edac_dbg(3, "init mci\n");
1304 mci->mtype_cap = MEM_FLAG_RDDR; 1304 mci->mtype_cap = MEM_FLAG_RDDR;
1305 /* 3100 IMCH supports SECDEC only */ 1305 /* 3100 IMCH supports SECDEC only */
1306 mci->edac_ctl_cap = (dev_idx == I3100) ? EDAC_FLAG_SECDED : 1306 mci->edac_ctl_cap = (dev_idx == I3100) ? EDAC_FLAG_SECDED :
@@ -1308,9 +1308,9 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
1308 /* FIXME - what if different memory types are in different csrows? */ 1308 /* FIXME - what if different memory types are in different csrows? */
1309 mci->mod_name = EDAC_MOD_STR; 1309 mci->mod_name = EDAC_MOD_STR;
1310 mci->mod_ver = E752X_REVISION; 1310 mci->mod_ver = E752X_REVISION;
1311 mci->dev = &pdev->dev; 1311 mci->pdev = &pdev->dev;
1312 1312
1313 debugf3("%s(): init pvt\n", __func__); 1313 edac_dbg(3, "init pvt\n");
1314 pvt = (struct e752x_pvt *)mci->pvt_info; 1314 pvt = (struct e752x_pvt *)mci->pvt_info;
1315 pvt->dev_info = &e752x_devs[dev_idx]; 1315 pvt->dev_info = &e752x_devs[dev_idx];
1316 pvt->mc_symmetric = ((ddrcsr & 0x10) != 0); 1316 pvt->mc_symmetric = ((ddrcsr & 0x10) != 0);
@@ -1320,7 +1320,7 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
1320 return -ENODEV; 1320 return -ENODEV;
1321 } 1321 }
1322 1322
1323 debugf3("%s(): more mci init\n", __func__); 1323 edac_dbg(3, "more mci init\n");
1324 mci->ctl_name = pvt->dev_info->ctl_name; 1324 mci->ctl_name = pvt->dev_info->ctl_name;
1325 mci->dev_name = pci_name(pdev); 1325 mci->dev_name = pci_name(pdev);
1326 mci->edac_check = e752x_check; 1326 mci->edac_check = e752x_check;
@@ -1342,7 +1342,7 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
1342 mci->edac_cap = EDAC_FLAG_SECDED; /* the only mode supported */ 1342 mci->edac_cap = EDAC_FLAG_SECDED; /* the only mode supported */
1343 else 1343 else
1344 mci->edac_cap |= EDAC_FLAG_NONE; 1344 mci->edac_cap |= EDAC_FLAG_NONE;
1345 debugf3("%s(): tolm, remapbase, remaplimit\n", __func__); 1345 edac_dbg(3, "tolm, remapbase, remaplimit\n");
1346 1346
1347 /* load the top of low memory, remap base, and remap limit vars */ 1347 /* load the top of low memory, remap base, and remap limit vars */
1348 pci_read_config_word(pdev, E752X_TOLM, &pci_data); 1348 pci_read_config_word(pdev, E752X_TOLM, &pci_data);
@@ -1359,7 +1359,7 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
1359 * type of memory controller. The ID is therefore hardcoded to 0. 1359 * type of memory controller. The ID is therefore hardcoded to 0.
1360 */ 1360 */
1361 if (edac_mc_add_mc(mci)) { 1361 if (edac_mc_add_mc(mci)) {
1362 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 1362 edac_dbg(3, "failed edac_mc_add_mc()\n");
1363 goto fail; 1363 goto fail;
1364 } 1364 }
1365 1365
@@ -1377,7 +1377,7 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
1377 } 1377 }
1378 1378
1379 /* get this far and it's successful */ 1379 /* get this far and it's successful */
1380 debugf3("%s(): success\n", __func__); 1380 edac_dbg(3, "success\n");
1381 return 0; 1381 return 0;
1382 1382
1383fail: 1383fail:
@@ -1393,7 +1393,7 @@ fail:
1393static int __devinit e752x_init_one(struct pci_dev *pdev, 1393static int __devinit e752x_init_one(struct pci_dev *pdev,
1394 const struct pci_device_id *ent) 1394 const struct pci_device_id *ent)
1395{ 1395{
1396 debugf0("%s()\n", __func__); 1396 edac_dbg(0, "\n");
1397 1397
1398 /* wake up and enable device */ 1398 /* wake up and enable device */
1399 if (pci_enable_device(pdev) < 0) 1399 if (pci_enable_device(pdev) < 0)
@@ -1407,7 +1407,7 @@ static void __devexit e752x_remove_one(struct pci_dev *pdev)
1407 struct mem_ctl_info *mci; 1407 struct mem_ctl_info *mci;
1408 struct e752x_pvt *pvt; 1408 struct e752x_pvt *pvt;
1409 1409
1410 debugf0("%s()\n", __func__); 1410 edac_dbg(0, "\n");
1411 1411
1412 if (e752x_pci) 1412 if (e752x_pci)
1413 edac_pci_release_generic_ctl(e752x_pci); 1413 edac_pci_release_generic_ctl(e752x_pci);
@@ -1453,7 +1453,7 @@ static int __init e752x_init(void)
1453{ 1453{
1454 int pci_rc; 1454 int pci_rc;
1455 1455
1456 debugf3("%s()\n", __func__); 1456 edac_dbg(3, "\n");
1457 1457
1458 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 1458 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
1459 opstate_init(); 1459 opstate_init();
@@ -1464,7 +1464,7 @@ static int __init e752x_init(void)
1464 1464
1465static void __exit e752x_exit(void) 1465static void __exit e752x_exit(void)
1466{ 1466{
1467 debugf3("%s()\n", __func__); 1467 edac_dbg(3, "\n");
1468 pci_unregister_driver(&e752x_driver); 1468 pci_unregister_driver(&e752x_driver);
1469} 1469}
1470 1470
diff --git a/drivers/edac/e7xxx_edac.c b/drivers/edac/e7xxx_edac.c
index 9a9c1a546797..9ff57f361a43 100644
--- a/drivers/edac/e7xxx_edac.c
+++ b/drivers/edac/e7xxx_edac.c
@@ -166,7 +166,7 @@ static const struct e7xxx_dev_info e7xxx_devs[] = {
166/* FIXME - is this valid for both SECDED and S4ECD4ED? */ 166/* FIXME - is this valid for both SECDED and S4ECD4ED? */
167static inline int e7xxx_find_channel(u16 syndrome) 167static inline int e7xxx_find_channel(u16 syndrome)
168{ 168{
169 debugf3("%s()\n", __func__); 169 edac_dbg(3, "\n");
170 170
171 if ((syndrome & 0xff00) == 0) 171 if ((syndrome & 0xff00) == 0)
172 return 0; 172 return 0;
@@ -186,7 +186,7 @@ static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci,
186 u32 remap; 186 u32 remap;
187 struct e7xxx_pvt *pvt = (struct e7xxx_pvt *)mci->pvt_info; 187 struct e7xxx_pvt *pvt = (struct e7xxx_pvt *)mci->pvt_info;
188 188
189 debugf3("%s()\n", __func__); 189 edac_dbg(3, "\n");
190 190
191 if ((page < pvt->tolm) || 191 if ((page < pvt->tolm) ||
192 ((page >= 0x100000) && (page < pvt->remapbase))) 192 ((page >= 0x100000) && (page < pvt->remapbase)))
@@ -208,7 +208,7 @@ static void process_ce(struct mem_ctl_info *mci, struct e7xxx_error_info *info)
208 int row; 208 int row;
209 int channel; 209 int channel;
210 210
211 debugf3("%s()\n", __func__); 211 edac_dbg(3, "\n");
212 /* read the error address */ 212 /* read the error address */
213 error_1b = info->dram_celog_add; 213 error_1b = info->dram_celog_add;
214 /* FIXME - should use PAGE_SHIFT */ 214 /* FIXME - should use PAGE_SHIFT */
@@ -219,15 +219,15 @@ static void process_ce(struct mem_ctl_info *mci, struct e7xxx_error_info *info)
219 row = edac_mc_find_csrow_by_page(mci, page); 219 row = edac_mc_find_csrow_by_page(mci, page);
220 /* convert syndrome to channel */ 220 /* convert syndrome to channel */
221 channel = e7xxx_find_channel(syndrome); 221 channel = e7xxx_find_channel(syndrome);
222 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, page, 0, syndrome, 222 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, page, 0, syndrome,
223 row, channel, -1, "e7xxx CE", "", NULL); 223 row, channel, -1, "e7xxx CE", "");
224} 224}
225 225
226static void process_ce_no_info(struct mem_ctl_info *mci) 226static void process_ce_no_info(struct mem_ctl_info *mci)
227{ 227{
228 debugf3("%s()\n", __func__); 228 edac_dbg(3, "\n");
229 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 0, 0, 0, -1, -1, -1, 229 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0, -1, -1, -1,
230 "e7xxx CE log register overflow", "", NULL); 230 "e7xxx CE log register overflow", "");
231} 231}
232 232
233static void process_ue(struct mem_ctl_info *mci, struct e7xxx_error_info *info) 233static void process_ue(struct mem_ctl_info *mci, struct e7xxx_error_info *info)
@@ -235,23 +235,23 @@ static void process_ue(struct mem_ctl_info *mci, struct e7xxx_error_info *info)
235 u32 error_2b, block_page; 235 u32 error_2b, block_page;
236 int row; 236 int row;
237 237
238 debugf3("%s()\n", __func__); 238 edac_dbg(3, "\n");
239 /* read the error address */ 239 /* read the error address */
240 error_2b = info->dram_uelog_add; 240 error_2b = info->dram_uelog_add;
241 /* FIXME - should use PAGE_SHIFT */ 241 /* FIXME - should use PAGE_SHIFT */
242 block_page = error_2b >> 6; /* convert to 4k address */ 242 block_page = error_2b >> 6; /* convert to 4k address */
243 row = edac_mc_find_csrow_by_page(mci, block_page); 243 row = edac_mc_find_csrow_by_page(mci, block_page);
244 244
245 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, block_page, 0, 0, 245 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, block_page, 0, 0,
246 row, -1, -1, "e7xxx UE", "", NULL); 246 row, -1, -1, "e7xxx UE", "");
247} 247}
248 248
249static void process_ue_no_info(struct mem_ctl_info *mci) 249static void process_ue_no_info(struct mem_ctl_info *mci)
250{ 250{
251 debugf3("%s()\n", __func__); 251 edac_dbg(3, "\n");
252 252
253 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 0, 0, 0, -1, -1, -1, 253 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0, -1, -1, -1,
254 "e7xxx UE log register overflow", "", NULL); 254 "e7xxx UE log register overflow", "");
255} 255}
256 256
257static void e7xxx_get_error_info(struct mem_ctl_info *mci, 257static void e7xxx_get_error_info(struct mem_ctl_info *mci,
@@ -334,7 +334,7 @@ static void e7xxx_check(struct mem_ctl_info *mci)
334{ 334{
335 struct e7xxx_error_info info; 335 struct e7xxx_error_info info;
336 336
337 debugf3("%s()\n", __func__); 337 edac_dbg(3, "\n");
338 e7xxx_get_error_info(mci, &info); 338 e7xxx_get_error_info(mci, &info);
339 e7xxx_process_error_info(mci, &info, 1); 339 e7xxx_process_error_info(mci, &info, 1);
340} 340}
@@ -362,6 +362,7 @@ static void e7xxx_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
362 int drc_chan, drc_drbg, drc_ddim, mem_dev; 362 int drc_chan, drc_drbg, drc_ddim, mem_dev;
363 struct csrow_info *csrow; 363 struct csrow_info *csrow;
364 struct dimm_info *dimm; 364 struct dimm_info *dimm;
365 enum edac_type edac_mode;
365 366
366 pci_read_config_dword(pdev, E7XXX_DRA, &dra); 367 pci_read_config_dword(pdev, E7XXX_DRA, &dra);
367 drc_chan = dual_channel_active(drc, dev_idx); 368 drc_chan = dual_channel_active(drc, dev_idx);
@@ -377,13 +378,12 @@ static void e7xxx_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
377 for (index = 0; index < mci->nr_csrows; index++) { 378 for (index = 0; index < mci->nr_csrows; index++) {
378 /* mem_dev 0=x8, 1=x4 */ 379 /* mem_dev 0=x8, 1=x4 */
379 mem_dev = (dra >> (index * 4 + 3)) & 0x1; 380 mem_dev = (dra >> (index * 4 + 3)) & 0x1;
380 csrow = &mci->csrows[index]; 381 csrow = mci->csrows[index];
381 382
382 pci_read_config_byte(pdev, E7XXX_DRB + index, &value); 383 pci_read_config_byte(pdev, E7XXX_DRB + index, &value);
383 /* convert a 64 or 32 MiB DRB to a page size. */ 384 /* convert a 64 or 32 MiB DRB to a page size. */
384 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT); 385 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
385 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, 386 edac_dbg(3, "(%d) cumul_size 0x%x\n", index, cumul_size);
386 cumul_size);
387 if (cumul_size == last_cumul_size) 387 if (cumul_size == last_cumul_size)
388 continue; /* not populated */ 388 continue; /* not populated */
389 389
@@ -392,28 +392,29 @@ static void e7xxx_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
392 nr_pages = cumul_size - last_cumul_size; 392 nr_pages = cumul_size - last_cumul_size;
393 last_cumul_size = cumul_size; 393 last_cumul_size = cumul_size;
394 394
395 /*
396 * if single channel or x8 devices then SECDED
397 * if dual channel and x4 then S4ECD4ED
398 */
399 if (drc_ddim) {
400 if (drc_chan && mem_dev) {
401 edac_mode = EDAC_S4ECD4ED;
402 mci->edac_cap |= EDAC_FLAG_S4ECD4ED;
403 } else {
404 edac_mode = EDAC_SECDED;
405 mci->edac_cap |= EDAC_FLAG_SECDED;
406 }
407 } else
408 edac_mode = EDAC_NONE;
409
395 for (j = 0; j < drc_chan + 1; j++) { 410 for (j = 0; j < drc_chan + 1; j++) {
396 dimm = csrow->channels[j].dimm; 411 dimm = csrow->channels[j]->dimm;
397 412
398 dimm->nr_pages = nr_pages / (drc_chan + 1); 413 dimm->nr_pages = nr_pages / (drc_chan + 1);
399 dimm->grain = 1 << 12; /* 4KiB - resolution of CELOG */ 414 dimm->grain = 1 << 12; /* 4KiB - resolution of CELOG */
400 dimm->mtype = MEM_RDDR; /* only one type supported */ 415 dimm->mtype = MEM_RDDR; /* only one type supported */
401 dimm->dtype = mem_dev ? DEV_X4 : DEV_X8; 416 dimm->dtype = mem_dev ? DEV_X4 : DEV_X8;
402 417 dimm->edac_mode = edac_mode;
403 /*
404 * if single channel or x8 devices then SECDED
405 * if dual channel and x4 then S4ECD4ED
406 */
407 if (drc_ddim) {
408 if (drc_chan && mem_dev) {
409 dimm->edac_mode = EDAC_S4ECD4ED;
410 mci->edac_cap |= EDAC_FLAG_S4ECD4ED;
411 } else {
412 dimm->edac_mode = EDAC_SECDED;
413 mci->edac_cap |= EDAC_FLAG_SECDED;
414 }
415 } else
416 dimm->edac_mode = EDAC_NONE;
417 } 418 }
418 } 419 }
419} 420}
@@ -428,7 +429,7 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
428 int drc_chan; 429 int drc_chan;
429 struct e7xxx_error_info discard; 430 struct e7xxx_error_info discard;
430 431
431 debugf0("%s(): mci\n", __func__); 432 edac_dbg(0, "mci\n");
432 433
433 pci_read_config_dword(pdev, E7XXX_DRC, &drc); 434 pci_read_config_dword(pdev, E7XXX_DRC, &drc);
434 435
@@ -451,15 +452,15 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
451 if (mci == NULL) 452 if (mci == NULL)
452 return -ENOMEM; 453 return -ENOMEM;
453 454
454 debugf3("%s(): init mci\n", __func__); 455 edac_dbg(3, "init mci\n");
455 mci->mtype_cap = MEM_FLAG_RDDR; 456 mci->mtype_cap = MEM_FLAG_RDDR;
456 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED | 457 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED |
457 EDAC_FLAG_S4ECD4ED; 458 EDAC_FLAG_S4ECD4ED;
458 /* FIXME - what if different memory types are in different csrows? */ 459 /* FIXME - what if different memory types are in different csrows? */
459 mci->mod_name = EDAC_MOD_STR; 460 mci->mod_name = EDAC_MOD_STR;
460 mci->mod_ver = E7XXX_REVISION; 461 mci->mod_ver = E7XXX_REVISION;
461 mci->dev = &pdev->dev; 462 mci->pdev = &pdev->dev;
462 debugf3("%s(): init pvt\n", __func__); 463 edac_dbg(3, "init pvt\n");
463 pvt = (struct e7xxx_pvt *)mci->pvt_info; 464 pvt = (struct e7xxx_pvt *)mci->pvt_info;
464 pvt->dev_info = &e7xxx_devs[dev_idx]; 465 pvt->dev_info = &e7xxx_devs[dev_idx];
465 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL, 466 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
@@ -472,14 +473,14 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
472 goto fail0; 473 goto fail0;
473 } 474 }
474 475
475 debugf3("%s(): more mci init\n", __func__); 476 edac_dbg(3, "more mci init\n");
476 mci->ctl_name = pvt->dev_info->ctl_name; 477 mci->ctl_name = pvt->dev_info->ctl_name;
477 mci->dev_name = pci_name(pdev); 478 mci->dev_name = pci_name(pdev);
478 mci->edac_check = e7xxx_check; 479 mci->edac_check = e7xxx_check;
479 mci->ctl_page_to_phys = ctl_page_to_phys; 480 mci->ctl_page_to_phys = ctl_page_to_phys;
480 e7xxx_init_csrows(mci, pdev, dev_idx, drc); 481 e7xxx_init_csrows(mci, pdev, dev_idx, drc);
481 mci->edac_cap |= EDAC_FLAG_NONE; 482 mci->edac_cap |= EDAC_FLAG_NONE;
482 debugf3("%s(): tolm, remapbase, remaplimit\n", __func__); 483 edac_dbg(3, "tolm, remapbase, remaplimit\n");
483 /* load the top of low memory, remap base, and remap limit vars */ 484 /* load the top of low memory, remap base, and remap limit vars */
484 pci_read_config_word(pdev, E7XXX_TOLM, &pci_data); 485 pci_read_config_word(pdev, E7XXX_TOLM, &pci_data);
485 pvt->tolm = ((u32) pci_data) << 4; 486 pvt->tolm = ((u32) pci_data) << 4;
@@ -498,7 +499,7 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
498 * type of memory controller. The ID is therefore hardcoded to 0. 499 * type of memory controller. The ID is therefore hardcoded to 0.
499 */ 500 */
500 if (edac_mc_add_mc(mci)) { 501 if (edac_mc_add_mc(mci)) {
501 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 502 edac_dbg(3, "failed edac_mc_add_mc()\n");
502 goto fail1; 503 goto fail1;
503 } 504 }
504 505
@@ -514,7 +515,7 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
514 } 515 }
515 516
516 /* get this far and it's successful */ 517 /* get this far and it's successful */
517 debugf3("%s(): success\n", __func__); 518 edac_dbg(3, "success\n");
518 return 0; 519 return 0;
519 520
520fail1: 521fail1:
@@ -530,7 +531,7 @@ fail0:
530static int __devinit e7xxx_init_one(struct pci_dev *pdev, 531static int __devinit e7xxx_init_one(struct pci_dev *pdev,
531 const struct pci_device_id *ent) 532 const struct pci_device_id *ent)
532{ 533{
533 debugf0("%s()\n", __func__); 534 edac_dbg(0, "\n");
534 535
535 /* wake up and enable device */ 536 /* wake up and enable device */
536 return pci_enable_device(pdev) ? 537 return pci_enable_device(pdev) ?
@@ -542,7 +543,7 @@ static void __devexit e7xxx_remove_one(struct pci_dev *pdev)
542 struct mem_ctl_info *mci; 543 struct mem_ctl_info *mci;
543 struct e7xxx_pvt *pvt; 544 struct e7xxx_pvt *pvt;
544 545
545 debugf0("%s()\n", __func__); 546 edac_dbg(0, "\n");
546 547
547 if (e7xxx_pci) 548 if (e7xxx_pci)
548 edac_pci_release_generic_ctl(e7xxx_pci); 549 edac_pci_release_generic_ctl(e7xxx_pci);
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h
index 117490d4f835..23bb99fa44f1 100644
--- a/drivers/edac/edac_core.h
+++ b/drivers/edac/edac_core.h
@@ -71,26 +71,21 @@ extern const char *edac_mem_types[];
71#ifdef CONFIG_EDAC_DEBUG 71#ifdef CONFIG_EDAC_DEBUG
72extern int edac_debug_level; 72extern int edac_debug_level;
73 73
74#define edac_debug_printk(level, fmt, arg...) \ 74#define edac_dbg(level, fmt, ...) \
75 do { \ 75do { \
76 if (level <= edac_debug_level) \ 76 if (level <= edac_debug_level) \
77 edac_printk(KERN_DEBUG, EDAC_DEBUG, \ 77 edac_printk(KERN_DEBUG, EDAC_DEBUG, \
78 "%s: " fmt, __func__, ##arg); \ 78 "%s: " fmt, __func__, ##__VA_ARGS__); \
79 } while (0) 79} while (0)
80
81#define debugf0( ... ) edac_debug_printk(0, __VA_ARGS__ )
82#define debugf1( ... ) edac_debug_printk(1, __VA_ARGS__ )
83#define debugf2( ... ) edac_debug_printk(2, __VA_ARGS__ )
84#define debugf3( ... ) edac_debug_printk(3, __VA_ARGS__ )
85#define debugf4( ... ) edac_debug_printk(4, __VA_ARGS__ )
86 80
87#else /* !CONFIG_EDAC_DEBUG */ 81#else /* !CONFIG_EDAC_DEBUG */
88 82
89#define debugf0( ... ) 83#define edac_dbg(level, fmt, ...) \
90#define debugf1( ... ) 84do { \
91#define debugf2( ... ) 85 if (0) \
92#define debugf3( ... ) 86 edac_printk(KERN_DEBUG, EDAC_DEBUG, \
93#define debugf4( ... ) 87 "%s: " fmt, __func__, ##__VA_ARGS__); \
88} while (0)
94 89
95#endif /* !CONFIG_EDAC_DEBUG */ 90#endif /* !CONFIG_EDAC_DEBUG */
96 91
@@ -460,15 +455,15 @@ extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
460 unsigned long page); 455 unsigned long page);
461void edac_mc_handle_error(const enum hw_event_mc_err_type type, 456void edac_mc_handle_error(const enum hw_event_mc_err_type type,
462 struct mem_ctl_info *mci, 457 struct mem_ctl_info *mci,
458 const u16 error_count,
463 const unsigned long page_frame_number, 459 const unsigned long page_frame_number,
464 const unsigned long offset_in_page, 460 const unsigned long offset_in_page,
465 const unsigned long syndrome, 461 const unsigned long syndrome,
466 const int layer0, 462 const int top_layer,
467 const int layer1, 463 const int mid_layer,
468 const int layer2, 464 const int low_layer,
469 const char *msg, 465 const char *msg,
470 const char *other_detail, 466 const char *other_detail);
471 const void *mcelog);
472 467
473/* 468/*
474 * edac_device APIs 469 * edac_device APIs
diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
index ee3f1f810c1e..211021dfec73 100644
--- a/drivers/edac/edac_device.c
+++ b/drivers/edac/edac_device.c
@@ -40,12 +40,13 @@ static LIST_HEAD(edac_device_list);
40#ifdef CONFIG_EDAC_DEBUG 40#ifdef CONFIG_EDAC_DEBUG
41static void edac_device_dump_device(struct edac_device_ctl_info *edac_dev) 41static void edac_device_dump_device(struct edac_device_ctl_info *edac_dev)
42{ 42{
43 debugf3("\tedac_dev = %p dev_idx=%d \n", edac_dev, edac_dev->dev_idx); 43 edac_dbg(3, "\tedac_dev = %p dev_idx=%d\n",
44 debugf4("\tedac_dev->edac_check = %p\n", edac_dev->edac_check); 44 edac_dev, edac_dev->dev_idx);
45 debugf3("\tdev = %p\n", edac_dev->dev); 45 edac_dbg(4, "\tedac_dev->edac_check = %p\n", edac_dev->edac_check);
46 debugf3("\tmod_name:ctl_name = %s:%s\n", 46 edac_dbg(3, "\tdev = %p\n", edac_dev->dev);
47 edac_dev->mod_name, edac_dev->ctl_name); 47 edac_dbg(3, "\tmod_name:ctl_name = %s:%s\n",
48 debugf3("\tpvt_info = %p\n\n", edac_dev->pvt_info); 48 edac_dev->mod_name, edac_dev->ctl_name);
49 edac_dbg(3, "\tpvt_info = %p\n\n", edac_dev->pvt_info);
49} 50}
50#endif /* CONFIG_EDAC_DEBUG */ 51#endif /* CONFIG_EDAC_DEBUG */
51 52
@@ -82,8 +83,7 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
82 void *pvt, *p; 83 void *pvt, *p;
83 int err; 84 int err;
84 85
85 debugf4("%s() instances=%d blocks=%d\n", 86 edac_dbg(4, "instances=%d blocks=%d\n", nr_instances, nr_blocks);
86 __func__, nr_instances, nr_blocks);
87 87
88 /* Calculate the size of memory we need to allocate AND 88 /* Calculate the size of memory we need to allocate AND
89 * determine the offsets of the various item arrays 89 * determine the offsets of the various item arrays
@@ -156,8 +156,8 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
156 /* Name of this edac device */ 156 /* Name of this edac device */
157 snprintf(dev_ctl->name,sizeof(dev_ctl->name),"%s",edac_device_name); 157 snprintf(dev_ctl->name,sizeof(dev_ctl->name),"%s",edac_device_name);
158 158
159 debugf4("%s() edac_dev=%p next after end=%p\n", 159 edac_dbg(4, "edac_dev=%p next after end=%p\n",
160 __func__, dev_ctl, pvt + sz_private ); 160 dev_ctl, pvt + sz_private);
161 161
162 /* Initialize every Instance */ 162 /* Initialize every Instance */
163 for (instance = 0; instance < nr_instances; instance++) { 163 for (instance = 0; instance < nr_instances; instance++) {
@@ -178,10 +178,8 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
178 snprintf(blk->name, sizeof(blk->name), 178 snprintf(blk->name, sizeof(blk->name),
179 "%s%d", edac_block_name, block+offset_value); 179 "%s%d", edac_block_name, block+offset_value);
180 180
181 debugf4("%s() instance=%d inst_p=%p block=#%d " 181 edac_dbg(4, "instance=%d inst_p=%p block=#%d block_p=%p name='%s'\n",
182 "block_p=%p name='%s'\n", 182 instance, inst, block, blk, blk->name);
183 __func__, instance, inst, block,
184 blk, blk->name);
185 183
186 /* if there are NO attributes OR no attribute pointer 184 /* if there are NO attributes OR no attribute pointer
187 * then continue on to next block iteration 185 * then continue on to next block iteration
@@ -194,8 +192,8 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
194 attrib_p = &dev_attrib[block*nr_instances*nr_attrib]; 192 attrib_p = &dev_attrib[block*nr_instances*nr_attrib];
195 blk->block_attributes = attrib_p; 193 blk->block_attributes = attrib_p;
196 194
197 debugf4("%s() THIS BLOCK_ATTRIB=%p\n", 195 edac_dbg(4, "THIS BLOCK_ATTRIB=%p\n",
198 __func__, blk->block_attributes); 196 blk->block_attributes);
199 197
200 /* Initialize every user specified attribute in this 198 /* Initialize every user specified attribute in this
201 * block with the data the caller passed in 199 * block with the data the caller passed in
@@ -214,11 +212,10 @@ struct edac_device_ctl_info *edac_device_alloc_ctl_info(
214 212
215 attrib->block = blk; /* up link */ 213 attrib->block = blk; /* up link */
216 214
217 debugf4("%s() alloc-attrib=%p attrib_name='%s' " 215 edac_dbg(4, "alloc-attrib=%p attrib_name='%s' attrib-spec=%p spec-name=%s\n",
218 "attrib-spec=%p spec-name=%s\n", 216 attrib, attrib->attr.name,
219 __func__, attrib, attrib->attr.name, 217 &attrib_spec[attr],
220 &attrib_spec[attr], 218 attrib_spec[attr].attr.name
221 attrib_spec[attr].attr.name
222 ); 219 );
223 } 220 }
224 } 221 }
@@ -273,7 +270,7 @@ static struct edac_device_ctl_info *find_edac_device_by_dev(struct device *dev)
273 struct edac_device_ctl_info *edac_dev; 270 struct edac_device_ctl_info *edac_dev;
274 struct list_head *item; 271 struct list_head *item;
275 272
276 debugf0("%s()\n", __func__); 273 edac_dbg(0, "\n");
277 274
278 list_for_each(item, &edac_device_list) { 275 list_for_each(item, &edac_device_list) {
279 edac_dev = list_entry(item, struct edac_device_ctl_info, link); 276 edac_dev = list_entry(item, struct edac_device_ctl_info, link);
@@ -408,7 +405,7 @@ static void edac_device_workq_function(struct work_struct *work_req)
408void edac_device_workq_setup(struct edac_device_ctl_info *edac_dev, 405void edac_device_workq_setup(struct edac_device_ctl_info *edac_dev,
409 unsigned msec) 406 unsigned msec)
410{ 407{
411 debugf0("%s()\n", __func__); 408 edac_dbg(0, "\n");
412 409
413 /* take the arg 'msec' and set it into the control structure 410 /* take the arg 'msec' and set it into the control structure
414 * to used in the time period calculation 411 * to used in the time period calculation
@@ -496,7 +493,7 @@ EXPORT_SYMBOL_GPL(edac_device_alloc_index);
496 */ 493 */
497int edac_device_add_device(struct edac_device_ctl_info *edac_dev) 494int edac_device_add_device(struct edac_device_ctl_info *edac_dev)
498{ 495{
499 debugf0("%s()\n", __func__); 496 edac_dbg(0, "\n");
500 497
501#ifdef CONFIG_EDAC_DEBUG 498#ifdef CONFIG_EDAC_DEBUG
502 if (edac_debug_level >= 3) 499 if (edac_debug_level >= 3)
@@ -570,7 +567,7 @@ struct edac_device_ctl_info *edac_device_del_device(struct device *dev)
570{ 567{
571 struct edac_device_ctl_info *edac_dev; 568 struct edac_device_ctl_info *edac_dev;
572 569
573 debugf0("%s()\n", __func__); 570 edac_dbg(0, "\n");
574 571
575 mutex_lock(&device_ctls_mutex); 572 mutex_lock(&device_ctls_mutex);
576 573
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index b4ea185ccebf..fb68a06ad683 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -202,7 +202,7 @@ static void edac_device_ctrl_master_release(struct kobject *kobj)
202{ 202{
203 struct edac_device_ctl_info *edac_dev = to_edacdev(kobj); 203 struct edac_device_ctl_info *edac_dev = to_edacdev(kobj);
204 204
205 debugf4("%s() control index=%d\n", __func__, edac_dev->dev_idx); 205 edac_dbg(4, "control index=%d\n", edac_dev->dev_idx);
206 206
207 /* decrement the EDAC CORE module ref count */ 207 /* decrement the EDAC CORE module ref count */
208 module_put(edac_dev->owner); 208 module_put(edac_dev->owner);
@@ -233,12 +233,12 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
233 struct bus_type *edac_subsys; 233 struct bus_type *edac_subsys;
234 int err; 234 int err;
235 235
236 debugf1("%s()\n", __func__); 236 edac_dbg(1, "\n");
237 237
238 /* get the /sys/devices/system/edac reference */ 238 /* get the /sys/devices/system/edac reference */
239 edac_subsys = edac_get_sysfs_subsys(); 239 edac_subsys = edac_get_sysfs_subsys();
240 if (edac_subsys == NULL) { 240 if (edac_subsys == NULL) {
241 debugf1("%s() no edac_subsys error\n", __func__); 241 edac_dbg(1, "no edac_subsys error\n");
242 err = -ENODEV; 242 err = -ENODEV;
243 goto err_out; 243 goto err_out;
244 } 244 }
@@ -264,8 +264,8 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
264 &edac_subsys->dev_root->kobj, 264 &edac_subsys->dev_root->kobj,
265 "%s", edac_dev->name); 265 "%s", edac_dev->name);
266 if (err) { 266 if (err) {
267 debugf1("%s()Failed to register '.../edac/%s'\n", 267 edac_dbg(1, "Failed to register '.../edac/%s'\n",
268 __func__, edac_dev->name); 268 edac_dev->name);
269 goto err_kobj_reg; 269 goto err_kobj_reg;
270 } 270 }
271 kobject_uevent(&edac_dev->kobj, KOBJ_ADD); 271 kobject_uevent(&edac_dev->kobj, KOBJ_ADD);
@@ -274,8 +274,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
274 * edac_device_unregister_sysfs_main_kobj() must be used 274 * edac_device_unregister_sysfs_main_kobj() must be used
275 */ 275 */
276 276
277 debugf4("%s() Registered '.../edac/%s' kobject\n", 277 edac_dbg(4, "Registered '.../edac/%s' kobject\n", edac_dev->name);
278 __func__, edac_dev->name);
279 278
280 return 0; 279 return 0;
281 280
@@ -296,9 +295,8 @@ err_out:
296 */ 295 */
297void edac_device_unregister_sysfs_main_kobj(struct edac_device_ctl_info *dev) 296void edac_device_unregister_sysfs_main_kobj(struct edac_device_ctl_info *dev)
298{ 297{
299 debugf0("%s()\n", __func__); 298 edac_dbg(0, "\n");
300 debugf4("%s() name of kobject is: %s\n", 299 edac_dbg(4, "name of kobject is: %s\n", kobject_name(&dev->kobj));
301 __func__, kobject_name(&dev->kobj));
302 300
303 /* 301 /*
304 * Unregister the edac device's kobject and 302 * Unregister the edac device's kobject and
@@ -336,7 +334,7 @@ static void edac_device_ctrl_instance_release(struct kobject *kobj)
336{ 334{
337 struct edac_device_instance *instance; 335 struct edac_device_instance *instance;
338 336
339 debugf1("%s()\n", __func__); 337 edac_dbg(1, "\n");
340 338
341 /* map from this kobj to the main control struct 339 /* map from this kobj to the main control struct
342 * and then dec the main kobj count 340 * and then dec the main kobj count
@@ -442,7 +440,7 @@ static void edac_device_ctrl_block_release(struct kobject *kobj)
442{ 440{
443 struct edac_device_block *block; 441 struct edac_device_block *block;
444 442
445 debugf1("%s()\n", __func__); 443 edac_dbg(1, "\n");
446 444
447 /* get the container of the kobj */ 445 /* get the container of the kobj */
448 block = to_block(kobj); 446 block = to_block(kobj);
@@ -524,10 +522,10 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev,
524 struct edac_dev_sysfs_block_attribute *sysfs_attrib; 522 struct edac_dev_sysfs_block_attribute *sysfs_attrib;
525 struct kobject *main_kobj; 523 struct kobject *main_kobj;
526 524
527 debugf4("%s() Instance '%s' inst_p=%p block '%s' block_p=%p\n", 525 edac_dbg(4, "Instance '%s' inst_p=%p block '%s' block_p=%p\n",
528 __func__, instance->name, instance, block->name, block); 526 instance->name, instance, block->name, block);
529 debugf4("%s() block kobj=%p block kobj->parent=%p\n", 527 edac_dbg(4, "block kobj=%p block kobj->parent=%p\n",
530 __func__, &block->kobj, &block->kobj.parent); 528 &block->kobj, &block->kobj.parent);
531 529
532 /* init this block's kobject */ 530 /* init this block's kobject */
533 memset(&block->kobj, 0, sizeof(struct kobject)); 531 memset(&block->kobj, 0, sizeof(struct kobject));
@@ -546,8 +544,7 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev,
546 &instance->kobj, 544 &instance->kobj,
547 "%s", block->name); 545 "%s", block->name);
548 if (err) { 546 if (err) {
549 debugf1("%s() Failed to register instance '%s'\n", 547 edac_dbg(1, "Failed to register instance '%s'\n", block->name);
550 __func__, block->name);
551 kobject_put(main_kobj); 548 kobject_put(main_kobj);
552 err = -ENODEV; 549 err = -ENODEV;
553 goto err_out; 550 goto err_out;
@@ -560,11 +557,9 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev,
560 if (sysfs_attrib && block->nr_attribs) { 557 if (sysfs_attrib && block->nr_attribs) {
561 for (i = 0; i < block->nr_attribs; i++, sysfs_attrib++) { 558 for (i = 0; i < block->nr_attribs; i++, sysfs_attrib++) {
562 559
563 debugf4("%s() creating block attrib='%s' " 560 edac_dbg(4, "creating block attrib='%s' attrib->%p to kobj=%p\n",
564 "attrib->%p to kobj=%p\n", 561 sysfs_attrib->attr.name,
565 __func__, 562 sysfs_attrib, &block->kobj);
566 sysfs_attrib->attr.name,
567 sysfs_attrib, &block->kobj);
568 563
569 /* Create each block_attribute file */ 564 /* Create each block_attribute file */
570 err = sysfs_create_file(&block->kobj, 565 err = sysfs_create_file(&block->kobj,
@@ -647,14 +642,14 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev,
647 err = kobject_init_and_add(&instance->kobj, &ktype_instance_ctrl, 642 err = kobject_init_and_add(&instance->kobj, &ktype_instance_ctrl,
648 &edac_dev->kobj, "%s", instance->name); 643 &edac_dev->kobj, "%s", instance->name);
649 if (err != 0) { 644 if (err != 0) {
650 debugf2("%s() Failed to register instance '%s'\n", 645 edac_dbg(2, "Failed to register instance '%s'\n",
651 __func__, instance->name); 646 instance->name);
652 kobject_put(main_kobj); 647 kobject_put(main_kobj);
653 goto err_out; 648 goto err_out;
654 } 649 }
655 650
656 debugf4("%s() now register '%d' blocks for instance %d\n", 651 edac_dbg(4, "now register '%d' blocks for instance %d\n",
657 __func__, instance->nr_blocks, idx); 652 instance->nr_blocks, idx);
658 653
659 /* register all blocks of this instance */ 654 /* register all blocks of this instance */
660 for (i = 0; i < instance->nr_blocks; i++) { 655 for (i = 0; i < instance->nr_blocks; i++) {
@@ -670,8 +665,8 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev,
670 } 665 }
671 kobject_uevent(&instance->kobj, KOBJ_ADD); 666 kobject_uevent(&instance->kobj, KOBJ_ADD);
672 667
673 debugf4("%s() Registered instance %d '%s' kobject\n", 668 edac_dbg(4, "Registered instance %d '%s' kobject\n",
674 __func__, idx, instance->name); 669 idx, instance->name);
675 670
676 return 0; 671 return 0;
677 672
@@ -715,7 +710,7 @@ static int edac_device_create_instances(struct edac_device_ctl_info *edac_dev)
715 int i, j; 710 int i, j;
716 int err; 711 int err;
717 712
718 debugf0("%s()\n", __func__); 713 edac_dbg(0, "\n");
719 714
720 /* iterate over creation of the instances */ 715 /* iterate over creation of the instances */
721 for (i = 0; i < edac_dev->nr_instances; i++) { 716 for (i = 0; i < edac_dev->nr_instances; i++) {
@@ -817,12 +812,12 @@ int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev)
817 int err; 812 int err;
818 struct kobject *edac_kobj = &edac_dev->kobj; 813 struct kobject *edac_kobj = &edac_dev->kobj;
819 814
820 debugf0("%s() idx=%d\n", __func__, edac_dev->dev_idx); 815 edac_dbg(0, "idx=%d\n", edac_dev->dev_idx);
821 816
822 /* go create any main attributes callers wants */ 817 /* go create any main attributes callers wants */
823 err = edac_device_add_main_sysfs_attributes(edac_dev); 818 err = edac_device_add_main_sysfs_attributes(edac_dev);
824 if (err) { 819 if (err) {
825 debugf0("%s() failed to add sysfs attribs\n", __func__); 820 edac_dbg(0, "failed to add sysfs attribs\n");
826 goto err_out; 821 goto err_out;
827 } 822 }
828 823
@@ -832,8 +827,7 @@ int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev)
832 err = sysfs_create_link(edac_kobj, 827 err = sysfs_create_link(edac_kobj,
833 &edac_dev->dev->kobj, EDAC_DEVICE_SYMLINK); 828 &edac_dev->dev->kobj, EDAC_DEVICE_SYMLINK);
834 if (err) { 829 if (err) {
835 debugf0("%s() sysfs_create_link() returned err= %d\n", 830 edac_dbg(0, "sysfs_create_link() returned err= %d\n", err);
836 __func__, err);
837 goto err_remove_main_attribs; 831 goto err_remove_main_attribs;
838 } 832 }
839 833
@@ -843,14 +837,13 @@ int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev)
843 */ 837 */
844 err = edac_device_create_instances(edac_dev); 838 err = edac_device_create_instances(edac_dev);
845 if (err) { 839 if (err) {
846 debugf0("%s() edac_device_create_instances() " 840 edac_dbg(0, "edac_device_create_instances() returned err= %d\n",
847 "returned err= %d\n", __func__, err); 841 err);
848 goto err_remove_link; 842 goto err_remove_link;
849 } 843 }
850 844
851 845
852 debugf4("%s() create-instances done, idx=%d\n", 846 edac_dbg(4, "create-instances done, idx=%d\n", edac_dev->dev_idx);
853 __func__, edac_dev->dev_idx);
854 847
855 return 0; 848 return 0;
856 849
@@ -873,7 +866,7 @@ err_out:
873 */ 866 */
874void edac_device_remove_sysfs(struct edac_device_ctl_info *edac_dev) 867void edac_device_remove_sysfs(struct edac_device_ctl_info *edac_dev)
875{ 868{
876 debugf0("%s()\n", __func__); 869 edac_dbg(0, "\n");
877 870
878 /* remove any main attributes for this device */ 871 /* remove any main attributes for this device */
879 edac_device_remove_main_sysfs_attributes(edac_dev); 872 edac_device_remove_main_sysfs_attributes(edac_dev);
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index de5ba86e8b89..616d90bcb3a4 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -27,70 +27,95 @@
27#include <linux/list.h> 27#include <linux/list.h>
28#include <linux/ctype.h> 28#include <linux/ctype.h>
29#include <linux/edac.h> 29#include <linux/edac.h>
30#include <linux/bitops.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <asm/page.h> 32#include <asm/page.h>
32#include <asm/edac.h> 33#include <asm/edac.h>
33#include "edac_core.h" 34#include "edac_core.h"
34#include "edac_module.h" 35#include "edac_module.h"
35 36
37#define CREATE_TRACE_POINTS
38#define TRACE_INCLUDE_PATH ../../include/ras
39#include <ras/ras_event.h>
40
36/* lock to memory controller's control array */ 41/* lock to memory controller's control array */
37static DEFINE_MUTEX(mem_ctls_mutex); 42static DEFINE_MUTEX(mem_ctls_mutex);
38static LIST_HEAD(mc_devices); 43static LIST_HEAD(mc_devices);
39 44
45unsigned edac_dimm_info_location(struct dimm_info *dimm, char *buf,
46 unsigned len)
47{
48 struct mem_ctl_info *mci = dimm->mci;
49 int i, n, count = 0;
50 char *p = buf;
51
52 for (i = 0; i < mci->n_layers; i++) {
53 n = snprintf(p, len, "%s %d ",
54 edac_layer_name[mci->layers[i].type],
55 dimm->location[i]);
56 p += n;
57 len -= n;
58 count += n;
59 if (!len)
60 break;
61 }
62
63 return count;
64}
65
40#ifdef CONFIG_EDAC_DEBUG 66#ifdef CONFIG_EDAC_DEBUG
41 67
42static void edac_mc_dump_channel(struct rank_info *chan) 68static void edac_mc_dump_channel(struct rank_info *chan)
43{ 69{
44 debugf4("\tchannel = %p\n", chan); 70 edac_dbg(4, " channel->chan_idx = %d\n", chan->chan_idx);
45 debugf4("\tchannel->chan_idx = %d\n", chan->chan_idx); 71 edac_dbg(4, " channel = %p\n", chan);
46 debugf4("\tchannel->csrow = %p\n\n", chan->csrow); 72 edac_dbg(4, " channel->csrow = %p\n", chan->csrow);
47 debugf4("\tchannel->dimm = %p\n", chan->dimm); 73 edac_dbg(4, " channel->dimm = %p\n", chan->dimm);
48} 74}
49 75
50static void edac_mc_dump_dimm(struct dimm_info *dimm) 76static void edac_mc_dump_dimm(struct dimm_info *dimm, int number)
51{ 77{
52 int i; 78 char location[80];
53 79
54 debugf4("\tdimm = %p\n", dimm); 80 edac_dimm_info_location(dimm, location, sizeof(location));
55 debugf4("\tdimm->label = '%s'\n", dimm->label); 81
56 debugf4("\tdimm->nr_pages = 0x%x\n", dimm->nr_pages); 82 edac_dbg(4, "%s%i: %smapped as virtual row %d, chan %d\n",
57 debugf4("\tdimm location "); 83 dimm->mci->mem_is_per_rank ? "rank" : "dimm",
58 for (i = 0; i < dimm->mci->n_layers; i++) { 84 number, location, dimm->csrow, dimm->cschannel);
59 printk(KERN_CONT "%d", dimm->location[i]); 85 edac_dbg(4, " dimm = %p\n", dimm);
60 if (i < dimm->mci->n_layers - 1) 86 edac_dbg(4, " dimm->label = '%s'\n", dimm->label);
61 printk(KERN_CONT "."); 87 edac_dbg(4, " dimm->nr_pages = 0x%x\n", dimm->nr_pages);
62 } 88 edac_dbg(4, " dimm->grain = %d\n", dimm->grain);
63 printk(KERN_CONT "\n"); 89 edac_dbg(4, " dimm->nr_pages = 0x%x\n", dimm->nr_pages);
64 debugf4("\tdimm->grain = %d\n", dimm->grain);
65 debugf4("\tdimm->nr_pages = 0x%x\n", dimm->nr_pages);
66} 90}
67 91
68static void edac_mc_dump_csrow(struct csrow_info *csrow) 92static void edac_mc_dump_csrow(struct csrow_info *csrow)
69{ 93{
70 debugf4("\tcsrow = %p\n", csrow); 94 edac_dbg(4, "csrow->csrow_idx = %d\n", csrow->csrow_idx);
71 debugf4("\tcsrow->csrow_idx = %d\n", csrow->csrow_idx); 95 edac_dbg(4, " csrow = %p\n", csrow);
72 debugf4("\tcsrow->first_page = 0x%lx\n", csrow->first_page); 96 edac_dbg(4, " csrow->first_page = 0x%lx\n", csrow->first_page);
73 debugf4("\tcsrow->last_page = 0x%lx\n", csrow->last_page); 97 edac_dbg(4, " csrow->last_page = 0x%lx\n", csrow->last_page);
74 debugf4("\tcsrow->page_mask = 0x%lx\n", csrow->page_mask); 98 edac_dbg(4, " csrow->page_mask = 0x%lx\n", csrow->page_mask);
75 debugf4("\tcsrow->nr_channels = %d\n", csrow->nr_channels); 99 edac_dbg(4, " csrow->nr_channels = %d\n", csrow->nr_channels);
76 debugf4("\tcsrow->channels = %p\n", csrow->channels); 100 edac_dbg(4, " csrow->channels = %p\n", csrow->channels);
77 debugf4("\tcsrow->mci = %p\n\n", csrow->mci); 101 edac_dbg(4, " csrow->mci = %p\n", csrow->mci);
78} 102}
79 103
80static void edac_mc_dump_mci(struct mem_ctl_info *mci) 104static void edac_mc_dump_mci(struct mem_ctl_info *mci)
81{ 105{
82 debugf3("\tmci = %p\n", mci); 106 edac_dbg(3, "\tmci = %p\n", mci);
83 debugf3("\tmci->mtype_cap = %lx\n", mci->mtype_cap); 107 edac_dbg(3, "\tmci->mtype_cap = %lx\n", mci->mtype_cap);
84 debugf3("\tmci->edac_ctl_cap = %lx\n", mci->edac_ctl_cap); 108 edac_dbg(3, "\tmci->edac_ctl_cap = %lx\n", mci->edac_ctl_cap);
85 debugf3("\tmci->edac_cap = %lx\n", mci->edac_cap); 109 edac_dbg(3, "\tmci->edac_cap = %lx\n", mci->edac_cap);
86 debugf4("\tmci->edac_check = %p\n", mci->edac_check); 110 edac_dbg(4, "\tmci->edac_check = %p\n", mci->edac_check);
87 debugf3("\tmci->nr_csrows = %d, csrows = %p\n", 111 edac_dbg(3, "\tmci->nr_csrows = %d, csrows = %p\n",
88 mci->nr_csrows, mci->csrows); 112 mci->nr_csrows, mci->csrows);
89 debugf3("\tmci->nr_dimms = %d, dimms = %p\n", 113 edac_dbg(3, "\tmci->nr_dimms = %d, dimms = %p\n",
90 mci->tot_dimms, mci->dimms); 114 mci->tot_dimms, mci->dimms);
91 debugf3("\tdev = %p\n", mci->dev); 115 edac_dbg(3, "\tdev = %p\n", mci->pdev);
92 debugf3("\tmod_name:ctl_name = %s:%s\n", mci->mod_name, mci->ctl_name); 116 edac_dbg(3, "\tmod_name:ctl_name = %s:%s\n",
93 debugf3("\tpvt_info = %p\n\n", mci->pvt_info); 117 mci->mod_name, mci->ctl_name);
118 edac_dbg(3, "\tpvt_info = %p\n\n", mci->pvt_info);
94} 119}
95 120
96#endif /* CONFIG_EDAC_DEBUG */ 121#endif /* CONFIG_EDAC_DEBUG */
@@ -205,15 +230,15 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
205{ 230{
206 struct mem_ctl_info *mci; 231 struct mem_ctl_info *mci;
207 struct edac_mc_layer *layer; 232 struct edac_mc_layer *layer;
208 struct csrow_info *csi, *csr; 233 struct csrow_info *csr;
209 struct rank_info *chi, *chp, *chan; 234 struct rank_info *chan;
210 struct dimm_info *dimm; 235 struct dimm_info *dimm;
211 u32 *ce_per_layer[EDAC_MAX_LAYERS], *ue_per_layer[EDAC_MAX_LAYERS]; 236 u32 *ce_per_layer[EDAC_MAX_LAYERS], *ue_per_layer[EDAC_MAX_LAYERS];
212 unsigned pos[EDAC_MAX_LAYERS]; 237 unsigned pos[EDAC_MAX_LAYERS];
213 unsigned size, tot_dimms = 1, count = 1; 238 unsigned size, tot_dimms = 1, count = 1;
214 unsigned tot_csrows = 1, tot_channels = 1, tot_errcount = 0; 239 unsigned tot_csrows = 1, tot_channels = 1, tot_errcount = 0;
215 void *pvt, *p, *ptr = NULL; 240 void *pvt, *p, *ptr = NULL;
216 int i, j, err, row, chn, n, len; 241 int i, j, row, chn, n, len, off;
217 bool per_rank = false; 242 bool per_rank = false;
218 243
219 BUG_ON(n_layers > EDAC_MAX_LAYERS || n_layers == 0); 244 BUG_ON(n_layers > EDAC_MAX_LAYERS || n_layers == 0);
@@ -239,26 +264,24 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
239 */ 264 */
240 mci = edac_align_ptr(&ptr, sizeof(*mci), 1); 265 mci = edac_align_ptr(&ptr, sizeof(*mci), 1);
241 layer = edac_align_ptr(&ptr, sizeof(*layer), n_layers); 266 layer = edac_align_ptr(&ptr, sizeof(*layer), n_layers);
242 csi = edac_align_ptr(&ptr, sizeof(*csi), tot_csrows);
243 chi = edac_align_ptr(&ptr, sizeof(*chi), tot_csrows * tot_channels);
244 dimm = edac_align_ptr(&ptr, sizeof(*dimm), tot_dimms);
245 for (i = 0; i < n_layers; i++) { 267 for (i = 0; i < n_layers; i++) {
246 count *= layers[i].size; 268 count *= layers[i].size;
247 debugf4("%s: errcount layer %d size %d\n", __func__, i, count); 269 edac_dbg(4, "errcount layer %d size %d\n", i, count);
248 ce_per_layer[i] = edac_align_ptr(&ptr, sizeof(u32), count); 270 ce_per_layer[i] = edac_align_ptr(&ptr, sizeof(u32), count);
249 ue_per_layer[i] = edac_align_ptr(&ptr, sizeof(u32), count); 271 ue_per_layer[i] = edac_align_ptr(&ptr, sizeof(u32), count);
250 tot_errcount += 2 * count; 272 tot_errcount += 2 * count;
251 } 273 }
252 274
253 debugf4("%s: allocating %d error counters\n", __func__, tot_errcount); 275 edac_dbg(4, "allocating %d error counters\n", tot_errcount);
254 pvt = edac_align_ptr(&ptr, sz_pvt, 1); 276 pvt = edac_align_ptr(&ptr, sz_pvt, 1);
255 size = ((unsigned long)pvt) + sz_pvt; 277 size = ((unsigned long)pvt) + sz_pvt;
256 278
257 debugf1("%s(): allocating %u bytes for mci data (%d %s, %d csrows/channels)\n", 279 edac_dbg(1, "allocating %u bytes for mci data (%d %s, %d csrows/channels)\n",
258 __func__, size, 280 size,
259 tot_dimms, 281 tot_dimms,
260 per_rank ? "ranks" : "dimms", 282 per_rank ? "ranks" : "dimms",
261 tot_csrows * tot_channels); 283 tot_csrows * tot_channels);
284
262 mci = kzalloc(size, GFP_KERNEL); 285 mci = kzalloc(size, GFP_KERNEL);
263 if (mci == NULL) 286 if (mci == NULL)
264 return NULL; 287 return NULL;
@@ -267,9 +290,6 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
267 * rather than an imaginary chunk of memory located at address 0. 290 * rather than an imaginary chunk of memory located at address 0.
268 */ 291 */
269 layer = (struct edac_mc_layer *)(((char *)mci) + ((unsigned long)layer)); 292 layer = (struct edac_mc_layer *)(((char *)mci) + ((unsigned long)layer));
270 csi = (struct csrow_info *)(((char *)mci) + ((unsigned long)csi));
271 chi = (struct rank_info *)(((char *)mci) + ((unsigned long)chi));
272 dimm = (struct dimm_info *)(((char *)mci) + ((unsigned long)dimm));
273 for (i = 0; i < n_layers; i++) { 293 for (i = 0; i < n_layers; i++) {
274 mci->ce_per_layer[i] = (u32 *)((char *)mci + ((unsigned long)ce_per_layer[i])); 294 mci->ce_per_layer[i] = (u32 *)((char *)mci + ((unsigned long)ce_per_layer[i]));
275 mci->ue_per_layer[i] = (u32 *)((char *)mci + ((unsigned long)ue_per_layer[i])); 295 mci->ue_per_layer[i] = (u32 *)((char *)mci + ((unsigned long)ue_per_layer[i]));
@@ -278,8 +298,6 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
278 298
279 /* setup index and various internal pointers */ 299 /* setup index and various internal pointers */
280 mci->mc_idx = mc_num; 300 mci->mc_idx = mc_num;
281 mci->csrows = csi;
282 mci->dimms = dimm;
283 mci->tot_dimms = tot_dimms; 301 mci->tot_dimms = tot_dimms;
284 mci->pvt_info = pvt; 302 mci->pvt_info = pvt;
285 mci->n_layers = n_layers; 303 mci->n_layers = n_layers;
@@ -290,40 +308,57 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
290 mci->mem_is_per_rank = per_rank; 308 mci->mem_is_per_rank = per_rank;
291 309
292 /* 310 /*
293 * Fill the csrow struct 311 * Alocate and fill the csrow/channels structs
294 */ 312 */
313 mci->csrows = kcalloc(sizeof(*mci->csrows), tot_csrows, GFP_KERNEL);
314 if (!mci->csrows)
315 goto error;
295 for (row = 0; row < tot_csrows; row++) { 316 for (row = 0; row < tot_csrows; row++) {
296 csr = &csi[row]; 317 csr = kzalloc(sizeof(**mci->csrows), GFP_KERNEL);
318 if (!csr)
319 goto error;
320 mci->csrows[row] = csr;
297 csr->csrow_idx = row; 321 csr->csrow_idx = row;
298 csr->mci = mci; 322 csr->mci = mci;
299 csr->nr_channels = tot_channels; 323 csr->nr_channels = tot_channels;
300 chp = &chi[row * tot_channels]; 324 csr->channels = kcalloc(sizeof(*csr->channels), tot_channels,
301 csr->channels = chp; 325 GFP_KERNEL);
326 if (!csr->channels)
327 goto error;
302 328
303 for (chn = 0; chn < tot_channels; chn++) { 329 for (chn = 0; chn < tot_channels; chn++) {
304 chan = &chp[chn]; 330 chan = kzalloc(sizeof(**csr->channels), GFP_KERNEL);
331 if (!chan)
332 goto error;
333 csr->channels[chn] = chan;
305 chan->chan_idx = chn; 334 chan->chan_idx = chn;
306 chan->csrow = csr; 335 chan->csrow = csr;
307 } 336 }
308 } 337 }
309 338
310 /* 339 /*
311 * Fill the dimm struct 340 * Allocate and fill the dimm structs
312 */ 341 */
342 mci->dimms = kcalloc(sizeof(*mci->dimms), tot_dimms, GFP_KERNEL);
343 if (!mci->dimms)
344 goto error;
345
313 memset(&pos, 0, sizeof(pos)); 346 memset(&pos, 0, sizeof(pos));
314 row = 0; 347 row = 0;
315 chn = 0; 348 chn = 0;
316 debugf4("%s: initializing %d %s\n", __func__, tot_dimms,
317 per_rank ? "ranks" : "dimms");
318 for (i = 0; i < tot_dimms; i++) { 349 for (i = 0; i < tot_dimms; i++) {
319 chan = &csi[row].channels[chn]; 350 chan = mci->csrows[row]->channels[chn];
320 dimm = EDAC_DIMM_PTR(layer, mci->dimms, n_layers, 351 off = EDAC_DIMM_OFF(layer, n_layers, pos[0], pos[1], pos[2]);
321 pos[0], pos[1], pos[2]); 352 if (off < 0 || off >= tot_dimms) {
322 dimm->mci = mci; 353 edac_mc_printk(mci, KERN_ERR, "EDAC core bug: EDAC_DIMM_OFF is trying to do an illegal data access\n");
354 goto error;
355 }
323 356
324 debugf2("%s: %d: %s%zd (%d:%d:%d): row %d, chan %d\n", __func__, 357 dimm = kzalloc(sizeof(**mci->dimms), GFP_KERNEL);
325 i, per_rank ? "rank" : "dimm", (dimm - mci->dimms), 358 if (!dimm)
326 pos[0], pos[1], pos[2], row, chn); 359 goto error;
360 mci->dimms[off] = dimm;
361 dimm->mci = mci;
327 362
328 /* 363 /*
329 * Copy DIMM location and initialize it. 364 * Copy DIMM location and initialize it.
@@ -367,16 +402,6 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
367 } 402 }
368 403
369 mci->op_state = OP_ALLOC; 404 mci->op_state = OP_ALLOC;
370 INIT_LIST_HEAD(&mci->grp_kobj_list);
371
372 /*
373 * Initialize the 'root' kobj for the edac_mc controller
374 */
375 err = edac_mc_register_sysfs_main_kobj(mci);
376 if (err) {
377 kfree(mci);
378 return NULL;
379 }
380 405
381 /* at this point, the root kobj is valid, and in order to 406 /* at this point, the root kobj is valid, and in order to
382 * 'free' the object, then the function: 407 * 'free' the object, then the function:
@@ -384,7 +409,30 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
384 * which will perform kobj unregistration and the actual free 409 * which will perform kobj unregistration and the actual free
385 * will occur during the kobject callback operation 410 * will occur during the kobject callback operation
386 */ 411 */
412
387 return mci; 413 return mci;
414
415error:
416 if (mci->dimms) {
417 for (i = 0; i < tot_dimms; i++)
418 kfree(mci->dimms[i]);
419 kfree(mci->dimms);
420 }
421 if (mci->csrows) {
422 for (chn = 0; chn < tot_channels; chn++) {
423 csr = mci->csrows[chn];
424 if (csr) {
425 for (chn = 0; chn < tot_channels; chn++)
426 kfree(csr->channels[chn]);
427 kfree(csr);
428 }
429 kfree(mci->csrows[i]);
430 }
431 kfree(mci->csrows);
432 }
433 kfree(mci);
434
435 return NULL;
388} 436}
389EXPORT_SYMBOL_GPL(edac_mc_alloc); 437EXPORT_SYMBOL_GPL(edac_mc_alloc);
390 438
@@ -395,12 +443,10 @@ EXPORT_SYMBOL_GPL(edac_mc_alloc);
395 */ 443 */
396void edac_mc_free(struct mem_ctl_info *mci) 444void edac_mc_free(struct mem_ctl_info *mci)
397{ 445{
398 debugf1("%s()\n", __func__); 446 edac_dbg(1, "\n");
399 447
400 edac_mc_unregister_sysfs_main_kobj(mci); 448 /* the mci instance is freed here, when the sysfs object is dropped */
401 449 edac_unregister_sysfs(mci);
402 /* free the mci instance memory here */
403 kfree(mci);
404} 450}
405EXPORT_SYMBOL_GPL(edac_mc_free); 451EXPORT_SYMBOL_GPL(edac_mc_free);
406 452
@@ -417,12 +463,12 @@ struct mem_ctl_info *find_mci_by_dev(struct device *dev)
417 struct mem_ctl_info *mci; 463 struct mem_ctl_info *mci;
418 struct list_head *item; 464 struct list_head *item;
419 465
420 debugf3("%s()\n", __func__); 466 edac_dbg(3, "\n");
421 467
422 list_for_each(item, &mc_devices) { 468 list_for_each(item, &mc_devices) {
423 mci = list_entry(item, struct mem_ctl_info, link); 469 mci = list_entry(item, struct mem_ctl_info, link);
424 470
425 if (mci->dev == dev) 471 if (mci->pdev == dev)
426 return mci; 472 return mci;
427 } 473 }
428 474
@@ -485,7 +531,7 @@ static void edac_mc_workq_function(struct work_struct *work_req)
485 */ 531 */
486static void edac_mc_workq_setup(struct mem_ctl_info *mci, unsigned msec) 532static void edac_mc_workq_setup(struct mem_ctl_info *mci, unsigned msec)
487{ 533{
488 debugf0("%s()\n", __func__); 534 edac_dbg(0, "\n");
489 535
490 /* if this instance is not in the POLL state, then simply return */ 536 /* if this instance is not in the POLL state, then simply return */
491 if (mci->op_state != OP_RUNNING_POLL) 537 if (mci->op_state != OP_RUNNING_POLL)
@@ -512,8 +558,7 @@ static void edac_mc_workq_teardown(struct mem_ctl_info *mci)
512 558
513 status = cancel_delayed_work(&mci->work); 559 status = cancel_delayed_work(&mci->work);
514 if (status == 0) { 560 if (status == 0) {
515 debugf0("%s() not canceled, flush the queue\n", 561 edac_dbg(0, "not canceled, flush the queue\n");
516 __func__);
517 562
518 /* workq instance might be running, wait for it */ 563 /* workq instance might be running, wait for it */
519 flush_workqueue(edac_workqueue); 564 flush_workqueue(edac_workqueue);
@@ -574,7 +619,7 @@ static int add_mc_to_global_list(struct mem_ctl_info *mci)
574 619
575 insert_before = &mc_devices; 620 insert_before = &mc_devices;
576 621
577 p = find_mci_by_dev(mci->dev); 622 p = find_mci_by_dev(mci->pdev);
578 if (unlikely(p != NULL)) 623 if (unlikely(p != NULL))
579 goto fail0; 624 goto fail0;
580 625
@@ -596,7 +641,7 @@ static int add_mc_to_global_list(struct mem_ctl_info *mci)
596 641
597fail0: 642fail0:
598 edac_printk(KERN_WARNING, EDAC_MC, 643 edac_printk(KERN_WARNING, EDAC_MC,
599 "%s (%s) %s %s already assigned %d\n", dev_name(p->dev), 644 "%s (%s) %s %s already assigned %d\n", dev_name(p->pdev),
600 edac_dev_name(mci), p->mod_name, p->ctl_name, p->mc_idx); 645 edac_dev_name(mci), p->mod_name, p->ctl_name, p->mc_idx);
601 return 1; 646 return 1;
602 647
@@ -660,7 +705,7 @@ EXPORT_SYMBOL(edac_mc_find);
660/* FIXME - should a warning be printed if no error detection? correction? */ 705/* FIXME - should a warning be printed if no error detection? correction? */
661int edac_mc_add_mc(struct mem_ctl_info *mci) 706int edac_mc_add_mc(struct mem_ctl_info *mci)
662{ 707{
663 debugf0("%s()\n", __func__); 708 edac_dbg(0, "\n");
664 709
665#ifdef CONFIG_EDAC_DEBUG 710#ifdef CONFIG_EDAC_DEBUG
666 if (edac_debug_level >= 3) 711 if (edac_debug_level >= 3)
@@ -670,15 +715,22 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
670 int i; 715 int i;
671 716
672 for (i = 0; i < mci->nr_csrows; i++) { 717 for (i = 0; i < mci->nr_csrows; i++) {
718 struct csrow_info *csrow = mci->csrows[i];
719 u32 nr_pages = 0;
673 int j; 720 int j;
674 721
675 edac_mc_dump_csrow(&mci->csrows[i]); 722 for (j = 0; j < csrow->nr_channels; j++)
676 for (j = 0; j < mci->csrows[i].nr_channels; j++) 723 nr_pages += csrow->channels[j]->dimm->nr_pages;
677 edac_mc_dump_channel(&mci->csrows[i]. 724 if (!nr_pages)
678 channels[j]); 725 continue;
726 edac_mc_dump_csrow(csrow);
727 for (j = 0; j < csrow->nr_channels; j++)
728 if (csrow->channels[j]->dimm->nr_pages)
729 edac_mc_dump_channel(csrow->channels[j]);
679 } 730 }
680 for (i = 0; i < mci->tot_dimms; i++) 731 for (i = 0; i < mci->tot_dimms; i++)
681 edac_mc_dump_dimm(&mci->dimms[i]); 732 if (mci->dimms[i]->nr_pages)
733 edac_mc_dump_dimm(mci->dimms[i], i);
682 } 734 }
683#endif 735#endif
684 mutex_lock(&mem_ctls_mutex); 736 mutex_lock(&mem_ctls_mutex);
@@ -732,7 +784,7 @@ struct mem_ctl_info *edac_mc_del_mc(struct device *dev)
732{ 784{
733 struct mem_ctl_info *mci; 785 struct mem_ctl_info *mci;
734 786
735 debugf0("%s()\n", __func__); 787 edac_dbg(0, "\n");
736 788
737 mutex_lock(&mem_ctls_mutex); 789 mutex_lock(&mem_ctls_mutex);
738 790
@@ -770,7 +822,7 @@ static void edac_mc_scrub_block(unsigned long page, unsigned long offset,
770 void *virt_addr; 822 void *virt_addr;
771 unsigned long flags = 0; 823 unsigned long flags = 0;
772 824
773 debugf3("%s()\n", __func__); 825 edac_dbg(3, "\n");
774 826
775 /* ECC error page was not in our memory. Ignore it. */ 827 /* ECC error page was not in our memory. Ignore it. */
776 if (!pfn_valid(page)) 828 if (!pfn_valid(page))
@@ -797,26 +849,26 @@ static void edac_mc_scrub_block(unsigned long page, unsigned long offset,
797/* FIXME - should return -1 */ 849/* FIXME - should return -1 */
798int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci, unsigned long page) 850int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci, unsigned long page)
799{ 851{
800 struct csrow_info *csrows = mci->csrows; 852 struct csrow_info **csrows = mci->csrows;
801 int row, i, j, n; 853 int row, i, j, n;
802 854
803 debugf1("MC%d: %s(): 0x%lx\n", mci->mc_idx, __func__, page); 855 edac_dbg(1, "MC%d: 0x%lx\n", mci->mc_idx, page);
804 row = -1; 856 row = -1;
805 857
806 for (i = 0; i < mci->nr_csrows; i++) { 858 for (i = 0; i < mci->nr_csrows; i++) {
807 struct csrow_info *csrow = &csrows[i]; 859 struct csrow_info *csrow = csrows[i];
808 n = 0; 860 n = 0;
809 for (j = 0; j < csrow->nr_channels; j++) { 861 for (j = 0; j < csrow->nr_channels; j++) {
810 struct dimm_info *dimm = csrow->channels[j].dimm; 862 struct dimm_info *dimm = csrow->channels[j]->dimm;
811 n += dimm->nr_pages; 863 n += dimm->nr_pages;
812 } 864 }
813 if (n == 0) 865 if (n == 0)
814 continue; 866 continue;
815 867
816 debugf3("MC%d: %s(): first(0x%lx) page(0x%lx) last(0x%lx) " 868 edac_dbg(3, "MC%d: first(0x%lx) page(0x%lx) last(0x%lx) mask(0x%lx)\n",
817 "mask(0x%lx)\n", mci->mc_idx, __func__, 869 mci->mc_idx,
818 csrow->first_page, page, csrow->last_page, 870 csrow->first_page, page, csrow->last_page,
819 csrow->page_mask); 871 csrow->page_mask);
820 872
821 if ((page >= csrow->first_page) && 873 if ((page >= csrow->first_page) &&
822 (page <= csrow->last_page) && 874 (page <= csrow->last_page) &&
@@ -845,15 +897,16 @@ const char *edac_layer_name[] = {
845EXPORT_SYMBOL_GPL(edac_layer_name); 897EXPORT_SYMBOL_GPL(edac_layer_name);
846 898
847static void edac_inc_ce_error(struct mem_ctl_info *mci, 899static void edac_inc_ce_error(struct mem_ctl_info *mci,
848 bool enable_per_layer_report, 900 bool enable_per_layer_report,
849 const int pos[EDAC_MAX_LAYERS]) 901 const int pos[EDAC_MAX_LAYERS],
902 const u16 count)
850{ 903{
851 int i, index = 0; 904 int i, index = 0;
852 905
853 mci->ce_mc++; 906 mci->ce_mc += count;
854 907
855 if (!enable_per_layer_report) { 908 if (!enable_per_layer_report) {
856 mci->ce_noinfo_count++; 909 mci->ce_noinfo_count += count;
857 return; 910 return;
858 } 911 }
859 912
@@ -861,7 +914,7 @@ static void edac_inc_ce_error(struct mem_ctl_info *mci,
861 if (pos[i] < 0) 914 if (pos[i] < 0)
862 break; 915 break;
863 index += pos[i]; 916 index += pos[i];
864 mci->ce_per_layer[i][index]++; 917 mci->ce_per_layer[i][index] += count;
865 918
866 if (i < mci->n_layers - 1) 919 if (i < mci->n_layers - 1)
867 index *= mci->layers[i + 1].size; 920 index *= mci->layers[i + 1].size;
@@ -870,14 +923,15 @@ static void edac_inc_ce_error(struct mem_ctl_info *mci,
870 923
871static void edac_inc_ue_error(struct mem_ctl_info *mci, 924static void edac_inc_ue_error(struct mem_ctl_info *mci,
872 bool enable_per_layer_report, 925 bool enable_per_layer_report,
873 const int pos[EDAC_MAX_LAYERS]) 926 const int pos[EDAC_MAX_LAYERS],
927 const u16 count)
874{ 928{
875 int i, index = 0; 929 int i, index = 0;
876 930
877 mci->ue_mc++; 931 mci->ue_mc += count;
878 932
879 if (!enable_per_layer_report) { 933 if (!enable_per_layer_report) {
880 mci->ce_noinfo_count++; 934 mci->ce_noinfo_count += count;
881 return; 935 return;
882 } 936 }
883 937
@@ -885,7 +939,7 @@ static void edac_inc_ue_error(struct mem_ctl_info *mci,
885 if (pos[i] < 0) 939 if (pos[i] < 0)
886 break; 940 break;
887 index += pos[i]; 941 index += pos[i];
888 mci->ue_per_layer[i][index]++; 942 mci->ue_per_layer[i][index] += count;
889 943
890 if (i < mci->n_layers - 1) 944 if (i < mci->n_layers - 1)
891 index *= mci->layers[i + 1].size; 945 index *= mci->layers[i + 1].size;
@@ -893,6 +947,7 @@ static void edac_inc_ue_error(struct mem_ctl_info *mci,
893} 947}
894 948
895static void edac_ce_error(struct mem_ctl_info *mci, 949static void edac_ce_error(struct mem_ctl_info *mci,
950 const u16 error_count,
896 const int pos[EDAC_MAX_LAYERS], 951 const int pos[EDAC_MAX_LAYERS],
897 const char *msg, 952 const char *msg,
898 const char *location, 953 const char *location,
@@ -902,23 +957,25 @@ static void edac_ce_error(struct mem_ctl_info *mci,
902 const bool enable_per_layer_report, 957 const bool enable_per_layer_report,
903 const unsigned long page_frame_number, 958 const unsigned long page_frame_number,
904 const unsigned long offset_in_page, 959 const unsigned long offset_in_page,
905 u32 grain) 960 long grain)
906{ 961{
907 unsigned long remapped_page; 962 unsigned long remapped_page;
908 963
909 if (edac_mc_get_log_ce()) { 964 if (edac_mc_get_log_ce()) {
910 if (other_detail && *other_detail) 965 if (other_detail && *other_detail)
911 edac_mc_printk(mci, KERN_WARNING, 966 edac_mc_printk(mci, KERN_WARNING,
912 "CE %s on %s (%s%s - %s)\n", 967 "%d CE %s on %s (%s %s - %s)\n",
968 error_count,
913 msg, label, location, 969 msg, label, location,
914 detail, other_detail); 970 detail, other_detail);
915 else 971 else
916 edac_mc_printk(mci, KERN_WARNING, 972 edac_mc_printk(mci, KERN_WARNING,
917 "CE %s on %s (%s%s)\n", 973 "%d CE %s on %s (%s %s)\n",
974 error_count,
918 msg, label, location, 975 msg, label, location,
919 detail); 976 detail);
920 } 977 }
921 edac_inc_ce_error(mci, enable_per_layer_report, pos); 978 edac_inc_ce_error(mci, enable_per_layer_report, pos, error_count);
922 979
923 if (mci->scrub_mode & SCRUB_SW_SRC) { 980 if (mci->scrub_mode & SCRUB_SW_SRC) {
924 /* 981 /*
@@ -942,6 +999,7 @@ static void edac_ce_error(struct mem_ctl_info *mci,
942} 999}
943 1000
944static void edac_ue_error(struct mem_ctl_info *mci, 1001static void edac_ue_error(struct mem_ctl_info *mci,
1002 const u16 error_count,
945 const int pos[EDAC_MAX_LAYERS], 1003 const int pos[EDAC_MAX_LAYERS],
946 const char *msg, 1004 const char *msg,
947 const char *location, 1005 const char *location,
@@ -953,12 +1011,14 @@ static void edac_ue_error(struct mem_ctl_info *mci,
953 if (edac_mc_get_log_ue()) { 1011 if (edac_mc_get_log_ue()) {
954 if (other_detail && *other_detail) 1012 if (other_detail && *other_detail)
955 edac_mc_printk(mci, KERN_WARNING, 1013 edac_mc_printk(mci, KERN_WARNING,
956 "UE %s on %s (%s%s - %s)\n", 1014 "%d UE %s on %s (%s %s - %s)\n",
1015 error_count,
957 msg, label, location, detail, 1016 msg, label, location, detail,
958 other_detail); 1017 other_detail);
959 else 1018 else
960 edac_mc_printk(mci, KERN_WARNING, 1019 edac_mc_printk(mci, KERN_WARNING,
961 "UE %s on %s (%s%s)\n", 1020 "%d UE %s on %s (%s %s)\n",
1021 error_count,
962 msg, label, location, detail); 1022 msg, label, location, detail);
963 } 1023 }
964 1024
@@ -971,33 +1031,53 @@ static void edac_ue_error(struct mem_ctl_info *mci,
971 msg, label, location, detail); 1031 msg, label, location, detail);
972 } 1032 }
973 1033
974 edac_inc_ue_error(mci, enable_per_layer_report, pos); 1034 edac_inc_ue_error(mci, enable_per_layer_report, pos, error_count);
975} 1035}
976 1036
977#define OTHER_LABEL " or " 1037#define OTHER_LABEL " or "
1038
1039/**
1040 * edac_mc_handle_error - reports a memory event to userspace
1041 *
1042 * @type: severity of the error (CE/UE/Fatal)
1043 * @mci: a struct mem_ctl_info pointer
1044 * @error_count: Number of errors of the same type
1045 * @page_frame_number: mem page where the error occurred
1046 * @offset_in_page: offset of the error inside the page
1047 * @syndrome: ECC syndrome
1048 * @top_layer: Memory layer[0] position
1049 * @mid_layer: Memory layer[1] position
1050 * @low_layer: Memory layer[2] position
1051 * @msg: Message meaningful to the end users that
1052 * explains the event
1053 * @other_detail: Technical details about the event that
1054 * may help hardware manufacturers and
1055 * EDAC developers to analyse the event
1056 */
978void edac_mc_handle_error(const enum hw_event_mc_err_type type, 1057void edac_mc_handle_error(const enum hw_event_mc_err_type type,
979 struct mem_ctl_info *mci, 1058 struct mem_ctl_info *mci,
1059 const u16 error_count,
980 const unsigned long page_frame_number, 1060 const unsigned long page_frame_number,
981 const unsigned long offset_in_page, 1061 const unsigned long offset_in_page,
982 const unsigned long syndrome, 1062 const unsigned long syndrome,
983 const int layer0, 1063 const int top_layer,
984 const int layer1, 1064 const int mid_layer,
985 const int layer2, 1065 const int low_layer,
986 const char *msg, 1066 const char *msg,
987 const char *other_detail, 1067 const char *other_detail)
988 const void *mcelog)
989{ 1068{
990 /* FIXME: too much for stack: move it to some pre-alocated area */ 1069 /* FIXME: too much for stack: move it to some pre-alocated area */
991 char detail[80], location[80]; 1070 char detail[80], location[80];
992 char label[(EDAC_MC_LABEL_LEN + 1 + sizeof(OTHER_LABEL)) * mci->tot_dimms]; 1071 char label[(EDAC_MC_LABEL_LEN + 1 + sizeof(OTHER_LABEL)) * mci->tot_dimms];
993 char *p; 1072 char *p;
994 int row = -1, chan = -1; 1073 int row = -1, chan = -1;
995 int pos[EDAC_MAX_LAYERS] = { layer0, layer1, layer2 }; 1074 int pos[EDAC_MAX_LAYERS] = { top_layer, mid_layer, low_layer };
996 int i; 1075 int i;
997 u32 grain; 1076 long grain;
998 bool enable_per_layer_report = false; 1077 bool enable_per_layer_report = false;
1078 u8 grain_bits;
999 1079
1000 debugf3("MC%d: %s()\n", mci->mc_idx, __func__); 1080 edac_dbg(3, "MC%d\n", mci->mc_idx);
1001 1081
1002 /* 1082 /*
1003 * Check if the event report is consistent and if the memory 1083 * Check if the event report is consistent and if the memory
@@ -1043,13 +1123,13 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,
1043 p = label; 1123 p = label;
1044 *p = '\0'; 1124 *p = '\0';
1045 for (i = 0; i < mci->tot_dimms; i++) { 1125 for (i = 0; i < mci->tot_dimms; i++) {
1046 struct dimm_info *dimm = &mci->dimms[i]; 1126 struct dimm_info *dimm = mci->dimms[i];
1047 1127
1048 if (layer0 >= 0 && layer0 != dimm->location[0]) 1128 if (top_layer >= 0 && top_layer != dimm->location[0])
1049 continue; 1129 continue;
1050 if (layer1 >= 0 && layer1 != dimm->location[1]) 1130 if (mid_layer >= 0 && mid_layer != dimm->location[1])
1051 continue; 1131 continue;
1052 if (layer2 >= 0 && layer2 != dimm->location[2]) 1132 if (low_layer >= 0 && low_layer != dimm->location[2])
1053 continue; 1133 continue;
1054 1134
1055 /* get the max grain, over the error match range */ 1135 /* get the max grain, over the error match range */
@@ -1075,11 +1155,9 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,
1075 * get csrow/channel of the DIMM, in order to allow 1155 * get csrow/channel of the DIMM, in order to allow
1076 * incrementing the compat API counters 1156 * incrementing the compat API counters
1077 */ 1157 */
1078 debugf4("%s: %s csrows map: (%d,%d)\n", 1158 edac_dbg(4, "%s csrows map: (%d,%d)\n",
1079 __func__, 1159 mci->mem_is_per_rank ? "rank" : "dimm",
1080 mci->mem_is_per_rank ? "rank" : "dimm", 1160 dimm->csrow, dimm->cschannel);
1081 dimm->csrow, dimm->cschannel);
1082
1083 if (row == -1) 1161 if (row == -1)
1084 row = dimm->csrow; 1162 row = dimm->csrow;
1085 else if (row >= 0 && row != dimm->csrow) 1163 else if (row >= 0 && row != dimm->csrow)
@@ -1095,19 +1173,18 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,
1095 if (!enable_per_layer_report) { 1173 if (!enable_per_layer_report) {
1096 strcpy(label, "any memory"); 1174 strcpy(label, "any memory");
1097 } else { 1175 } else {
1098 debugf4("%s: csrow/channel to increment: (%d,%d)\n", 1176 edac_dbg(4, "csrow/channel to increment: (%d,%d)\n", row, chan);
1099 __func__, row, chan);
1100 if (p == label) 1177 if (p == label)
1101 strcpy(label, "unknown memory"); 1178 strcpy(label, "unknown memory");
1102 if (type == HW_EVENT_ERR_CORRECTED) { 1179 if (type == HW_EVENT_ERR_CORRECTED) {
1103 if (row >= 0) { 1180 if (row >= 0) {
1104 mci->csrows[row].ce_count++; 1181 mci->csrows[row]->ce_count += error_count;
1105 if (chan >= 0) 1182 if (chan >= 0)
1106 mci->csrows[row].channels[chan].ce_count++; 1183 mci->csrows[row]->channels[chan]->ce_count += error_count;
1107 } 1184 }
1108 } else 1185 } else
1109 if (row >= 0) 1186 if (row >= 0)
1110 mci->csrows[row].ue_count++; 1187 mci->csrows[row]->ue_count += error_count;
1111 } 1188 }
1112 1189
1113 /* Fill the RAM location data */ 1190 /* Fill the RAM location data */
@@ -1120,23 +1197,33 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,
1120 edac_layer_name[mci->layers[i].type], 1197 edac_layer_name[mci->layers[i].type],
1121 pos[i]); 1198 pos[i]);
1122 } 1199 }
1200 if (p > location)
1201 *(p - 1) = '\0';
1202
1203 /* Report the error via the trace interface */
1204
1205 grain_bits = fls_long(grain) + 1;
1206 trace_mc_event(type, msg, label, error_count,
1207 mci->mc_idx, top_layer, mid_layer, low_layer,
1208 PAGES_TO_MiB(page_frame_number) | offset_in_page,
1209 grain_bits, syndrome, other_detail);
1123 1210
1124 /* Memory type dependent details about the error */ 1211 /* Memory type dependent details about the error */
1125 if (type == HW_EVENT_ERR_CORRECTED) { 1212 if (type == HW_EVENT_ERR_CORRECTED) {
1126 snprintf(detail, sizeof(detail), 1213 snprintf(detail, sizeof(detail),
1127 "page:0x%lx offset:0x%lx grain:%d syndrome:0x%lx", 1214 "page:0x%lx offset:0x%lx grain:%ld syndrome:0x%lx",
1128 page_frame_number, offset_in_page, 1215 page_frame_number, offset_in_page,
1129 grain, syndrome); 1216 grain, syndrome);
1130 edac_ce_error(mci, pos, msg, location, label, detail, 1217 edac_ce_error(mci, error_count, pos, msg, location, label,
1131 other_detail, enable_per_layer_report, 1218 detail, other_detail, enable_per_layer_report,
1132 page_frame_number, offset_in_page, grain); 1219 page_frame_number, offset_in_page, grain);
1133 } else { 1220 } else {
1134 snprintf(detail, sizeof(detail), 1221 snprintf(detail, sizeof(detail),
1135 "page:0x%lx offset:0x%lx grain:%d", 1222 "page:0x%lx offset:0x%lx grain:%ld",
1136 page_frame_number, offset_in_page, grain); 1223 page_frame_number, offset_in_page, grain);
1137 1224
1138 edac_ue_error(mci, pos, msg, location, label, detail, 1225 edac_ue_error(mci, error_count, pos, msg, location, label,
1139 other_detail, enable_per_layer_report); 1226 detail, other_detail, enable_per_layer_report);
1140 } 1227 }
1141} 1228}
1142EXPORT_SYMBOL_GPL(edac_mc_handle_error); 1229EXPORT_SYMBOL_GPL(edac_mc_handle_error);
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index f6a29b0eedc8..ed0bc07b8503 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -7,17 +7,21 @@
7 * 7 *
8 * Written Doug Thompson <norsk5@xmission.com> www.softwarebitmaker.com 8 * Written Doug Thompson <norsk5@xmission.com> www.softwarebitmaker.com
9 * 9 *
10 * (c) 2012 - Mauro Carvalho Chehab <mchehab@redhat.com>
11 * The entire API were re-written, and ported to use struct device
12 *
10 */ 13 */
11 14
12#include <linux/ctype.h> 15#include <linux/ctype.h>
13#include <linux/slab.h> 16#include <linux/slab.h>
14#include <linux/edac.h> 17#include <linux/edac.h>
15#include <linux/bug.h> 18#include <linux/bug.h>
19#include <linux/pm_runtime.h>
20#include <linux/uaccess.h>
16 21
17#include "edac_core.h" 22#include "edac_core.h"
18#include "edac_module.h" 23#include "edac_module.h"
19 24
20
21/* MC EDAC Controls, setable by module parameter, and sysfs */ 25/* MC EDAC Controls, setable by module parameter, and sysfs */
22static int edac_mc_log_ue = 1; 26static int edac_mc_log_ue = 1;
23static int edac_mc_log_ce = 1; 27static int edac_mc_log_ce = 1;
@@ -78,6 +82,8 @@ module_param_call(edac_mc_poll_msec, edac_set_poll_msec, param_get_int,
78 &edac_mc_poll_msec, 0644); 82 &edac_mc_poll_msec, 0644);
79MODULE_PARM_DESC(edac_mc_poll_msec, "Polling period in milliseconds"); 83MODULE_PARM_DESC(edac_mc_poll_msec, "Polling period in milliseconds");
80 84
85static struct device *mci_pdev;
86
81/* 87/*
82 * various constants for Memory Controllers 88 * various constants for Memory Controllers
83 */ 89 */
@@ -125,317 +131,526 @@ static const char *edac_caps[] = {
125 [EDAC_S16ECD16ED] = "S16ECD16ED" 131 [EDAC_S16ECD16ED] = "S16ECD16ED"
126}; 132};
127 133
128/* EDAC sysfs CSROW data structures and methods 134#ifdef CONFIG_EDAC_LEGACY_SYSFS
135/*
136 * EDAC sysfs CSROW data structures and methods
137 */
138
139#define to_csrow(k) container_of(k, struct csrow_info, dev)
140
141/*
142 * We need it to avoid namespace conflicts between the legacy API
143 * and the per-dimm/per-rank one
129 */ 144 */
145#define DEVICE_ATTR_LEGACY(_name, _mode, _show, _store) \
146 struct device_attribute dev_attr_legacy_##_name = __ATTR(_name, _mode, _show, _store)
147
148struct dev_ch_attribute {
149 struct device_attribute attr;
150 int channel;
151};
152
153#define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
154 struct dev_ch_attribute dev_attr_legacy_##_name = \
155 { __ATTR(_name, _mode, _show, _store), (_var) }
156
157#define to_channel(k) (container_of(k, struct dev_ch_attribute, attr)->channel)
130 158
131/* Set of more default csrow<id> attribute show/store functions */ 159/* Set of more default csrow<id> attribute show/store functions */
132static ssize_t csrow_ue_count_show(struct csrow_info *csrow, char *data, 160static ssize_t csrow_ue_count_show(struct device *dev,
133 int private) 161 struct device_attribute *mattr, char *data)
134{ 162{
163 struct csrow_info *csrow = to_csrow(dev);
164
135 return sprintf(data, "%u\n", csrow->ue_count); 165 return sprintf(data, "%u\n", csrow->ue_count);
136} 166}
137 167
138static ssize_t csrow_ce_count_show(struct csrow_info *csrow, char *data, 168static ssize_t csrow_ce_count_show(struct device *dev,
139 int private) 169 struct device_attribute *mattr, char *data)
140{ 170{
171 struct csrow_info *csrow = to_csrow(dev);
172
141 return sprintf(data, "%u\n", csrow->ce_count); 173 return sprintf(data, "%u\n", csrow->ce_count);
142} 174}
143 175
144static ssize_t csrow_size_show(struct csrow_info *csrow, char *data, 176static ssize_t csrow_size_show(struct device *dev,
145 int private) 177 struct device_attribute *mattr, char *data)
146{ 178{
179 struct csrow_info *csrow = to_csrow(dev);
147 int i; 180 int i;
148 u32 nr_pages = 0; 181 u32 nr_pages = 0;
149 182
150 for (i = 0; i < csrow->nr_channels; i++) 183 for (i = 0; i < csrow->nr_channels; i++)
151 nr_pages += csrow->channels[i].dimm->nr_pages; 184 nr_pages += csrow->channels[i]->dimm->nr_pages;
152
153 return sprintf(data, "%u\n", PAGES_TO_MiB(nr_pages)); 185 return sprintf(data, "%u\n", PAGES_TO_MiB(nr_pages));
154} 186}
155 187
156static ssize_t csrow_mem_type_show(struct csrow_info *csrow, char *data, 188static ssize_t csrow_mem_type_show(struct device *dev,
157 int private) 189 struct device_attribute *mattr, char *data)
158{ 190{
159 return sprintf(data, "%s\n", mem_types[csrow->channels[0].dimm->mtype]); 191 struct csrow_info *csrow = to_csrow(dev);
192
193 return sprintf(data, "%s\n", mem_types[csrow->channels[0]->dimm->mtype]);
160} 194}
161 195
162static ssize_t csrow_dev_type_show(struct csrow_info *csrow, char *data, 196static ssize_t csrow_dev_type_show(struct device *dev,
163 int private) 197 struct device_attribute *mattr, char *data)
164{ 198{
165 return sprintf(data, "%s\n", dev_types[csrow->channels[0].dimm->dtype]); 199 struct csrow_info *csrow = to_csrow(dev);
200
201 return sprintf(data, "%s\n", dev_types[csrow->channels[0]->dimm->dtype]);
166} 202}
167 203
168static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data, 204static ssize_t csrow_edac_mode_show(struct device *dev,
169 int private) 205 struct device_attribute *mattr,
206 char *data)
170{ 207{
171 return sprintf(data, "%s\n", edac_caps[csrow->channels[0].dimm->edac_mode]); 208 struct csrow_info *csrow = to_csrow(dev);
209
210 return sprintf(data, "%s\n", edac_caps[csrow->channels[0]->dimm->edac_mode]);
172} 211}
173 212
174/* show/store functions for DIMM Label attributes */ 213/* show/store functions for DIMM Label attributes */
175static ssize_t channel_dimm_label_show(struct csrow_info *csrow, 214static ssize_t channel_dimm_label_show(struct device *dev,
176 char *data, int channel) 215 struct device_attribute *mattr,
216 char *data)
177{ 217{
218 struct csrow_info *csrow = to_csrow(dev);
219 unsigned chan = to_channel(mattr);
220 struct rank_info *rank = csrow->channels[chan];
221
178 /* if field has not been initialized, there is nothing to send */ 222 /* if field has not been initialized, there is nothing to send */
179 if (!csrow->channels[channel].dimm->label[0]) 223 if (!rank->dimm->label[0])
180 return 0; 224 return 0;
181 225
182 return snprintf(data, EDAC_MC_LABEL_LEN, "%s\n", 226 return snprintf(data, EDAC_MC_LABEL_LEN, "%s\n",
183 csrow->channels[channel].dimm->label); 227 rank->dimm->label);
184} 228}
185 229
186static ssize_t channel_dimm_label_store(struct csrow_info *csrow, 230static ssize_t channel_dimm_label_store(struct device *dev,
187 const char *data, 231 struct device_attribute *mattr,
188 size_t count, int channel) 232 const char *data, size_t count)
189{ 233{
234 struct csrow_info *csrow = to_csrow(dev);
235 unsigned chan = to_channel(mattr);
236 struct rank_info *rank = csrow->channels[chan];
237
190 ssize_t max_size = 0; 238 ssize_t max_size = 0;
191 239
192 max_size = min((ssize_t) count, (ssize_t) EDAC_MC_LABEL_LEN - 1); 240 max_size = min((ssize_t) count, (ssize_t) EDAC_MC_LABEL_LEN - 1);
193 strncpy(csrow->channels[channel].dimm->label, data, max_size); 241 strncpy(rank->dimm->label, data, max_size);
194 csrow->channels[channel].dimm->label[max_size] = '\0'; 242 rank->dimm->label[max_size] = '\0';
195 243
196 return max_size; 244 return max_size;
197} 245}
198 246
199/* show function for dynamic chX_ce_count attribute */ 247/* show function for dynamic chX_ce_count attribute */
200static ssize_t channel_ce_count_show(struct csrow_info *csrow, 248static ssize_t channel_ce_count_show(struct device *dev,
201 char *data, int channel) 249 struct device_attribute *mattr, char *data)
202{ 250{
203 return sprintf(data, "%u\n", csrow->channels[channel].ce_count); 251 struct csrow_info *csrow = to_csrow(dev);
252 unsigned chan = to_channel(mattr);
253 struct rank_info *rank = csrow->channels[chan];
254
255 return sprintf(data, "%u\n", rank->ce_count);
204} 256}
205 257
206/* csrow specific attribute structure */ 258/* cwrow<id>/attribute files */
207struct csrowdev_attribute { 259DEVICE_ATTR_LEGACY(size_mb, S_IRUGO, csrow_size_show, NULL);
208 struct attribute attr; 260DEVICE_ATTR_LEGACY(dev_type, S_IRUGO, csrow_dev_type_show, NULL);
209 ssize_t(*show) (struct csrow_info *, char *, int); 261DEVICE_ATTR_LEGACY(mem_type, S_IRUGO, csrow_mem_type_show, NULL);
210 ssize_t(*store) (struct csrow_info *, const char *, size_t, int); 262DEVICE_ATTR_LEGACY(edac_mode, S_IRUGO, csrow_edac_mode_show, NULL);
211 int private; 263DEVICE_ATTR_LEGACY(ue_count, S_IRUGO, csrow_ue_count_show, NULL);
212}; 264DEVICE_ATTR_LEGACY(ce_count, S_IRUGO, csrow_ce_count_show, NULL);
213 265
214#define to_csrow(k) container_of(k, struct csrow_info, kobj) 266/* default attributes of the CSROW<id> object */
215#define to_csrowdev_attr(a) container_of(a, struct csrowdev_attribute, attr) 267static struct attribute *csrow_attrs[] = {
268 &dev_attr_legacy_dev_type.attr,
269 &dev_attr_legacy_mem_type.attr,
270 &dev_attr_legacy_edac_mode.attr,
271 &dev_attr_legacy_size_mb.attr,
272 &dev_attr_legacy_ue_count.attr,
273 &dev_attr_legacy_ce_count.attr,
274 NULL,
275};
216 276
217/* Set of show/store higher level functions for default csrow attributes */ 277static struct attribute_group csrow_attr_grp = {
218static ssize_t csrowdev_show(struct kobject *kobj, 278 .attrs = csrow_attrs,
219 struct attribute *attr, char *buffer) 279};
220{
221 struct csrow_info *csrow = to_csrow(kobj);
222 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr);
223 280
224 if (csrowdev_attr->show) 281static const struct attribute_group *csrow_attr_groups[] = {
225 return csrowdev_attr->show(csrow, 282 &csrow_attr_grp,
226 buffer, csrowdev_attr->private); 283 NULL
227 return -EIO; 284};
228}
229 285
230static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr, 286static void csrow_attr_release(struct device *dev)
231 const char *buffer, size_t count)
232{ 287{
233 struct csrow_info *csrow = to_csrow(kobj); 288 struct csrow_info *csrow = container_of(dev, struct csrow_info, dev);
234 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr);
235
236 if (csrowdev_attr->store)
237 return csrowdev_attr->store(csrow,
238 buffer,
239 count, csrowdev_attr->private);
240 return -EIO;
241}
242 289
243static const struct sysfs_ops csrowfs_ops = { 290 edac_dbg(1, "Releasing csrow device %s\n", dev_name(dev));
244 .show = csrowdev_show, 291 kfree(csrow);
245 .store = csrowdev_store 292}
246};
247 293
248#define CSROWDEV_ATTR(_name,_mode,_show,_store,_private) \ 294static struct device_type csrow_attr_type = {
249static struct csrowdev_attribute attr_##_name = { \ 295 .groups = csrow_attr_groups,
250 .attr = {.name = __stringify(_name), .mode = _mode }, \ 296 .release = csrow_attr_release,
251 .show = _show, \
252 .store = _store, \
253 .private = _private, \
254}; 297};
255 298
256/* default cwrow<id>/attribute files */ 299/*
257CSROWDEV_ATTR(size_mb, S_IRUGO, csrow_size_show, NULL, 0); 300 * possible dynamic channel DIMM Label attribute files
258CSROWDEV_ATTR(dev_type, S_IRUGO, csrow_dev_type_show, NULL, 0); 301 *
259CSROWDEV_ATTR(mem_type, S_IRUGO, csrow_mem_type_show, NULL, 0); 302 */
260CSROWDEV_ATTR(edac_mode, S_IRUGO, csrow_edac_mode_show, NULL, 0);
261CSROWDEV_ATTR(ue_count, S_IRUGO, csrow_ue_count_show, NULL, 0);
262CSROWDEV_ATTR(ce_count, S_IRUGO, csrow_ce_count_show, NULL, 0);
263 303
264/* default attributes of the CSROW<id> object */ 304#define EDAC_NR_CHANNELS 6
265static struct csrowdev_attribute *default_csrow_attr[] = {
266 &attr_dev_type,
267 &attr_mem_type,
268 &attr_edac_mode,
269 &attr_size_mb,
270 &attr_ue_count,
271 &attr_ce_count,
272 NULL,
273};
274 305
275/* possible dynamic channel DIMM Label attribute files */ 306DEVICE_CHANNEL(ch0_dimm_label, S_IRUGO | S_IWUSR,
276CSROWDEV_ATTR(ch0_dimm_label, S_IRUGO | S_IWUSR,
277 channel_dimm_label_show, channel_dimm_label_store, 0); 307 channel_dimm_label_show, channel_dimm_label_store, 0);
278CSROWDEV_ATTR(ch1_dimm_label, S_IRUGO | S_IWUSR, 308DEVICE_CHANNEL(ch1_dimm_label, S_IRUGO | S_IWUSR,
279 channel_dimm_label_show, channel_dimm_label_store, 1); 309 channel_dimm_label_show, channel_dimm_label_store, 1);
280CSROWDEV_ATTR(ch2_dimm_label, S_IRUGO | S_IWUSR, 310DEVICE_CHANNEL(ch2_dimm_label, S_IRUGO | S_IWUSR,
281 channel_dimm_label_show, channel_dimm_label_store, 2); 311 channel_dimm_label_show, channel_dimm_label_store, 2);
282CSROWDEV_ATTR(ch3_dimm_label, S_IRUGO | S_IWUSR, 312DEVICE_CHANNEL(ch3_dimm_label, S_IRUGO | S_IWUSR,
283 channel_dimm_label_show, channel_dimm_label_store, 3); 313 channel_dimm_label_show, channel_dimm_label_store, 3);
284CSROWDEV_ATTR(ch4_dimm_label, S_IRUGO | S_IWUSR, 314DEVICE_CHANNEL(ch4_dimm_label, S_IRUGO | S_IWUSR,
285 channel_dimm_label_show, channel_dimm_label_store, 4); 315 channel_dimm_label_show, channel_dimm_label_store, 4);
286CSROWDEV_ATTR(ch5_dimm_label, S_IRUGO | S_IWUSR, 316DEVICE_CHANNEL(ch5_dimm_label, S_IRUGO | S_IWUSR,
287 channel_dimm_label_show, channel_dimm_label_store, 5); 317 channel_dimm_label_show, channel_dimm_label_store, 5);
288 318
289/* Total possible dynamic DIMM Label attribute file table */ 319/* Total possible dynamic DIMM Label attribute file table */
290static struct csrowdev_attribute *dynamic_csrow_dimm_attr[] = { 320static struct device_attribute *dynamic_csrow_dimm_attr[] = {
291 &attr_ch0_dimm_label, 321 &dev_attr_legacy_ch0_dimm_label.attr,
292 &attr_ch1_dimm_label, 322 &dev_attr_legacy_ch1_dimm_label.attr,
293 &attr_ch2_dimm_label, 323 &dev_attr_legacy_ch2_dimm_label.attr,
294 &attr_ch3_dimm_label, 324 &dev_attr_legacy_ch3_dimm_label.attr,
295 &attr_ch4_dimm_label, 325 &dev_attr_legacy_ch4_dimm_label.attr,
296 &attr_ch5_dimm_label 326 &dev_attr_legacy_ch5_dimm_label.attr
297}; 327};
298 328
299/* possible dynamic channel ce_count attribute files */ 329/* possible dynamic channel ce_count attribute files */
300CSROWDEV_ATTR(ch0_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 0); 330DEVICE_CHANNEL(ch0_ce_count, S_IRUGO | S_IWUSR,
301CSROWDEV_ATTR(ch1_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 1); 331 channel_ce_count_show, NULL, 0);
302CSROWDEV_ATTR(ch2_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 2); 332DEVICE_CHANNEL(ch1_ce_count, S_IRUGO | S_IWUSR,
303CSROWDEV_ATTR(ch3_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 3); 333 channel_ce_count_show, NULL, 1);
304CSROWDEV_ATTR(ch4_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 4); 334DEVICE_CHANNEL(ch2_ce_count, S_IRUGO | S_IWUSR,
305CSROWDEV_ATTR(ch5_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 5); 335 channel_ce_count_show, NULL, 2);
336DEVICE_CHANNEL(ch3_ce_count, S_IRUGO | S_IWUSR,
337 channel_ce_count_show, NULL, 3);
338DEVICE_CHANNEL(ch4_ce_count, S_IRUGO | S_IWUSR,
339 channel_ce_count_show, NULL, 4);
340DEVICE_CHANNEL(ch5_ce_count, S_IRUGO | S_IWUSR,
341 channel_ce_count_show, NULL, 5);
306 342
307/* Total possible dynamic ce_count attribute file table */ 343/* Total possible dynamic ce_count attribute file table */
308static struct csrowdev_attribute *dynamic_csrow_ce_count_attr[] = { 344static struct device_attribute *dynamic_csrow_ce_count_attr[] = {
309 &attr_ch0_ce_count, 345 &dev_attr_legacy_ch0_ce_count.attr,
310 &attr_ch1_ce_count, 346 &dev_attr_legacy_ch1_ce_count.attr,
311 &attr_ch2_ce_count, 347 &dev_attr_legacy_ch2_ce_count.attr,
312 &attr_ch3_ce_count, 348 &dev_attr_legacy_ch3_ce_count.attr,
313 &attr_ch4_ce_count, 349 &dev_attr_legacy_ch4_ce_count.attr,
314 &attr_ch5_ce_count 350 &dev_attr_legacy_ch5_ce_count.attr
315}; 351};
316 352
317#define EDAC_NR_CHANNELS 6 353static inline int nr_pages_per_csrow(struct csrow_info *csrow)
354{
355 int chan, nr_pages = 0;
356
357 for (chan = 0; chan < csrow->nr_channels; chan++)
358 nr_pages += csrow->channels[chan]->dimm->nr_pages;
359
360 return nr_pages;
361}
318 362
319/* Create dynamic CHANNEL files, indexed by 'chan', under specifed CSROW */ 363/* Create a CSROW object under specifed edac_mc_device */
320static int edac_create_channel_files(struct kobject *kobj, int chan) 364static int edac_create_csrow_object(struct mem_ctl_info *mci,
365 struct csrow_info *csrow, int index)
321{ 366{
322 int err = -ENODEV; 367 int err, chan;
368
369 if (csrow->nr_channels >= EDAC_NR_CHANNELS)
370 return -ENODEV;
371
372 csrow->dev.type = &csrow_attr_type;
373 csrow->dev.bus = &mci->bus;
374 device_initialize(&csrow->dev);
375 csrow->dev.parent = &mci->dev;
376 dev_set_name(&csrow->dev, "csrow%d", index);
377 dev_set_drvdata(&csrow->dev, csrow);
323 378
324 if (chan >= EDAC_NR_CHANNELS) 379 edac_dbg(0, "creating (virtual) csrow node %s\n",
380 dev_name(&csrow->dev));
381
382 err = device_add(&csrow->dev);
383 if (err < 0)
325 return err; 384 return err;
326 385
327 /* create the DIMM label attribute file */ 386 for (chan = 0; chan < csrow->nr_channels; chan++) {
328 err = sysfs_create_file(kobj, 387 /* Only expose populated DIMMs */
329 (struct attribute *) 388 if (!csrow->channels[chan]->dimm->nr_pages)
330 dynamic_csrow_dimm_attr[chan]); 389 continue;
331 390 err = device_create_file(&csrow->dev,
332 if (!err) { 391 dynamic_csrow_dimm_attr[chan]);
333 /* create the CE Count attribute file */ 392 if (err < 0)
334 err = sysfs_create_file(kobj, 393 goto error;
335 (struct attribute *) 394 err = device_create_file(&csrow->dev,
336 dynamic_csrow_ce_count_attr[chan]); 395 dynamic_csrow_ce_count_attr[chan]);
337 } else { 396 if (err < 0) {
338 debugf1("%s() dimm labels and ce_count files created", 397 device_remove_file(&csrow->dev,
339 __func__); 398 dynamic_csrow_dimm_attr[chan]);
399 goto error;
400 }
401 }
402
403 return 0;
404
405error:
406 for (--chan; chan >= 0; chan--) {
407 device_remove_file(&csrow->dev,
408 dynamic_csrow_dimm_attr[chan]);
409 device_remove_file(&csrow->dev,
410 dynamic_csrow_ce_count_attr[chan]);
340 } 411 }
412 put_device(&csrow->dev);
341 413
342 return err; 414 return err;
343} 415}
344 416
345/* No memory to release for this kobj */ 417/* Create a CSROW object under specifed edac_mc_device */
346static void edac_csrow_instance_release(struct kobject *kobj) 418static int edac_create_csrow_objects(struct mem_ctl_info *mci)
347{ 419{
348 struct mem_ctl_info *mci; 420 int err, i, chan;
349 struct csrow_info *cs; 421 struct csrow_info *csrow;
422
423 for (i = 0; i < mci->nr_csrows; i++) {
424 csrow = mci->csrows[i];
425 if (!nr_pages_per_csrow(csrow))
426 continue;
427 err = edac_create_csrow_object(mci, mci->csrows[i], i);
428 if (err < 0)
429 goto error;
430 }
431 return 0;
350 432
351 debugf1("%s()\n", __func__); 433error:
434 for (--i; i >= 0; i--) {
435 csrow = mci->csrows[i];
436 if (!nr_pages_per_csrow(csrow))
437 continue;
438 for (chan = csrow->nr_channels - 1; chan >= 0; chan--) {
439 if (!csrow->channels[chan]->dimm->nr_pages)
440 continue;
441 device_remove_file(&csrow->dev,
442 dynamic_csrow_dimm_attr[chan]);
443 device_remove_file(&csrow->dev,
444 dynamic_csrow_ce_count_attr[chan]);
445 }
446 put_device(&mci->csrows[i]->dev);
447 }
352 448
353 cs = container_of(kobj, struct csrow_info, kobj); 449 return err;
354 mci = cs->mci; 450}
355 451
356 kobject_put(&mci->edac_mci_kobj); 452static void edac_delete_csrow_objects(struct mem_ctl_info *mci)
453{
454 int i, chan;
455 struct csrow_info *csrow;
456
457 for (i = mci->nr_csrows - 1; i >= 0; i--) {
458 csrow = mci->csrows[i];
459 if (!nr_pages_per_csrow(csrow))
460 continue;
461 for (chan = csrow->nr_channels - 1; chan >= 0; chan--) {
462 if (!csrow->channels[chan]->dimm->nr_pages)
463 continue;
464 edac_dbg(1, "Removing csrow %d channel %d sysfs nodes\n",
465 i, chan);
466 device_remove_file(&csrow->dev,
467 dynamic_csrow_dimm_attr[chan]);
468 device_remove_file(&csrow->dev,
469 dynamic_csrow_ce_count_attr[chan]);
470 }
471 put_device(&mci->csrows[i]->dev);
472 device_del(&mci->csrows[i]->dev);
473 }
357} 474}
475#endif
358 476
359/* the kobj_type instance for a CSROW */ 477/*
360static struct kobj_type ktype_csrow = { 478 * Per-dimm (or per-rank) devices
361 .release = edac_csrow_instance_release, 479 */
362 .sysfs_ops = &csrowfs_ops, 480
363 .default_attrs = (struct attribute **)default_csrow_attr, 481#define to_dimm(k) container_of(k, struct dimm_info, dev)
482
483/* show/store functions for DIMM Label attributes */
484static ssize_t dimmdev_location_show(struct device *dev,
485 struct device_attribute *mattr, char *data)
486{
487 struct dimm_info *dimm = to_dimm(dev);
488
489 return edac_dimm_info_location(dimm, data, PAGE_SIZE);
490}
491
492static ssize_t dimmdev_label_show(struct device *dev,
493 struct device_attribute *mattr, char *data)
494{
495 struct dimm_info *dimm = to_dimm(dev);
496
497 /* if field has not been initialized, there is nothing to send */
498 if (!dimm->label[0])
499 return 0;
500
501 return snprintf(data, EDAC_MC_LABEL_LEN, "%s\n", dimm->label);
502}
503
504static ssize_t dimmdev_label_store(struct device *dev,
505 struct device_attribute *mattr,
506 const char *data,
507 size_t count)
508{
509 struct dimm_info *dimm = to_dimm(dev);
510
511 ssize_t max_size = 0;
512
513 max_size = min((ssize_t) count, (ssize_t) EDAC_MC_LABEL_LEN - 1);
514 strncpy(dimm->label, data, max_size);
515 dimm->label[max_size] = '\0';
516
517 return max_size;
518}
519
520static ssize_t dimmdev_size_show(struct device *dev,
521 struct device_attribute *mattr, char *data)
522{
523 struct dimm_info *dimm = to_dimm(dev);
524
525 return sprintf(data, "%u\n", PAGES_TO_MiB(dimm->nr_pages));
526}
527
528static ssize_t dimmdev_mem_type_show(struct device *dev,
529 struct device_attribute *mattr, char *data)
530{
531 struct dimm_info *dimm = to_dimm(dev);
532
533 return sprintf(data, "%s\n", mem_types[dimm->mtype]);
534}
535
536static ssize_t dimmdev_dev_type_show(struct device *dev,
537 struct device_attribute *mattr, char *data)
538{
539 struct dimm_info *dimm = to_dimm(dev);
540
541 return sprintf(data, "%s\n", dev_types[dimm->dtype]);
542}
543
544static ssize_t dimmdev_edac_mode_show(struct device *dev,
545 struct device_attribute *mattr,
546 char *data)
547{
548 struct dimm_info *dimm = to_dimm(dev);
549
550 return sprintf(data, "%s\n", edac_caps[dimm->edac_mode]);
551}
552
553/* dimm/rank attribute files */
554static DEVICE_ATTR(dimm_label, S_IRUGO | S_IWUSR,
555 dimmdev_label_show, dimmdev_label_store);
556static DEVICE_ATTR(dimm_location, S_IRUGO, dimmdev_location_show, NULL);
557static DEVICE_ATTR(size, S_IRUGO, dimmdev_size_show, NULL);
558static DEVICE_ATTR(dimm_mem_type, S_IRUGO, dimmdev_mem_type_show, NULL);
559static DEVICE_ATTR(dimm_dev_type, S_IRUGO, dimmdev_dev_type_show, NULL);
560static DEVICE_ATTR(dimm_edac_mode, S_IRUGO, dimmdev_edac_mode_show, NULL);
561
562/* attributes of the dimm<id>/rank<id> object */
563static struct attribute *dimm_attrs[] = {
564 &dev_attr_dimm_label.attr,
565 &dev_attr_dimm_location.attr,
566 &dev_attr_size.attr,
567 &dev_attr_dimm_mem_type.attr,
568 &dev_attr_dimm_dev_type.attr,
569 &dev_attr_dimm_edac_mode.attr,
570 NULL,
364}; 571};
365 572
366/* Create a CSROW object under specifed edac_mc_device */ 573static struct attribute_group dimm_attr_grp = {
367static int edac_create_csrow_object(struct mem_ctl_info *mci, 574 .attrs = dimm_attrs,
368 struct csrow_info *csrow, int index) 575};
576
577static const struct attribute_group *dimm_attr_groups[] = {
578 &dimm_attr_grp,
579 NULL
580};
581
582static void dimm_attr_release(struct device *dev)
369{ 583{
370 struct kobject *kobj_mci = &mci->edac_mci_kobj; 584 struct dimm_info *dimm = container_of(dev, struct dimm_info, dev);
371 struct kobject *kobj;
372 int chan;
373 int err;
374 585
375 /* generate ..../edac/mc/mc<id>/csrow<index> */ 586 edac_dbg(1, "Releasing dimm device %s\n", dev_name(dev));
376 memset(&csrow->kobj, 0, sizeof(csrow->kobj)); 587 kfree(dimm);
377 csrow->mci = mci; /* include container up link */ 588}
378 589
379 /* bump the mci instance's kobject's ref count */ 590static struct device_type dimm_attr_type = {
380 kobj = kobject_get(&mci->edac_mci_kobj); 591 .groups = dimm_attr_groups,
381 if (!kobj) { 592 .release = dimm_attr_release,
382 err = -ENODEV; 593};
383 goto err_out; 594
384 } 595/* Create a DIMM object under specifed memory controller device */
596static int edac_create_dimm_object(struct mem_ctl_info *mci,
597 struct dimm_info *dimm,
598 int index)
599{
600 int err;
601 dimm->mci = mci;
385 602
386 /* Instanstiate the csrow object */ 603 dimm->dev.type = &dimm_attr_type;
387 err = kobject_init_and_add(&csrow->kobj, &ktype_csrow, kobj_mci, 604 dimm->dev.bus = &mci->bus;
388 "csrow%d", index); 605 device_initialize(&dimm->dev);
389 if (err)
390 goto err_release_top_kobj;
391 606
392 /* At this point, to release a csrow kobj, one must 607 dimm->dev.parent = &mci->dev;
393 * call the kobject_put and allow that tear down 608 if (mci->mem_is_per_rank)
394 * to work the releasing 609 dev_set_name(&dimm->dev, "rank%d", index);
395 */ 610 else
611 dev_set_name(&dimm->dev, "dimm%d", index);
612 dev_set_drvdata(&dimm->dev, dimm);
613 pm_runtime_forbid(&mci->dev);
396 614
397 /* Create the dyanmic attribute files on this csrow, 615 err = device_add(&dimm->dev);
398 * namely, the DIMM labels and the channel ce_count
399 */
400 for (chan = 0; chan < csrow->nr_channels; chan++) {
401 err = edac_create_channel_files(&csrow->kobj, chan);
402 if (err) {
403 /* special case the unregister here */
404 kobject_put(&csrow->kobj);
405 goto err_out;
406 }
407 }
408 kobject_uevent(&csrow->kobj, KOBJ_ADD);
409 return 0;
410 616
411 /* error unwind stack */ 617 edac_dbg(0, "creating rank/dimm device %s\n", dev_name(&dimm->dev));
412err_release_top_kobj:
413 kobject_put(&mci->edac_mci_kobj);
414 618
415err_out:
416 return err; 619 return err;
417} 620}
418 621
419/* default sysfs methods and data structures for the main MCI kobject */ 622/*
623 * Memory controller device
624 */
625
626#define to_mci(k) container_of(k, struct mem_ctl_info, dev)
420 627
421static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci, 628static ssize_t mci_reset_counters_store(struct device *dev,
629 struct device_attribute *mattr,
422 const char *data, size_t count) 630 const char *data, size_t count)
423{ 631{
424 int row, chan; 632 struct mem_ctl_info *mci = to_mci(dev);
425 633 int cnt, row, chan, i;
426 mci->ue_noinfo_count = 0;
427 mci->ce_noinfo_count = 0;
428 mci->ue_mc = 0; 634 mci->ue_mc = 0;
429 mci->ce_mc = 0; 635 mci->ce_mc = 0;
636 mci->ue_noinfo_count = 0;
637 mci->ce_noinfo_count = 0;
430 638
431 for (row = 0; row < mci->nr_csrows; row++) { 639 for (row = 0; row < mci->nr_csrows; row++) {
432 struct csrow_info *ri = &mci->csrows[row]; 640 struct csrow_info *ri = mci->csrows[row];
433 641
434 ri->ue_count = 0; 642 ri->ue_count = 0;
435 ri->ce_count = 0; 643 ri->ce_count = 0;
436 644
437 for (chan = 0; chan < ri->nr_channels; chan++) 645 for (chan = 0; chan < ri->nr_channels; chan++)
438 ri->channels[chan].ce_count = 0; 646 ri->channels[chan]->ce_count = 0;
647 }
648
649 cnt = 1;
650 for (i = 0; i < mci->n_layers; i++) {
651 cnt *= mci->layers[i].size;
652 memset(mci->ce_per_layer[i], 0, cnt * sizeof(u32));
653 memset(mci->ue_per_layer[i], 0, cnt * sizeof(u32));
439 } 654 }
440 655
441 mci->start_time = jiffies; 656 mci->start_time = jiffies;
@@ -451,9 +666,11 @@ static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
451 * Negative value still means that an error has occurred while setting 666 * Negative value still means that an error has occurred while setting
452 * the scrub rate. 667 * the scrub rate.
453 */ 668 */
454static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci, 669static ssize_t mci_sdram_scrub_rate_store(struct device *dev,
670 struct device_attribute *mattr,
455 const char *data, size_t count) 671 const char *data, size_t count)
456{ 672{
673 struct mem_ctl_info *mci = to_mci(dev);
457 unsigned long bandwidth = 0; 674 unsigned long bandwidth = 0;
458 int new_bw = 0; 675 int new_bw = 0;
459 676
@@ -476,8 +693,11 @@ static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci,
476/* 693/*
477 * ->get_sdram_scrub_rate() return value semantics same as above. 694 * ->get_sdram_scrub_rate() return value semantics same as above.
478 */ 695 */
479static ssize_t mci_sdram_scrub_rate_show(struct mem_ctl_info *mci, char *data) 696static ssize_t mci_sdram_scrub_rate_show(struct device *dev,
697 struct device_attribute *mattr,
698 char *data)
480{ 699{
700 struct mem_ctl_info *mci = to_mci(dev);
481 int bandwidth = 0; 701 int bandwidth = 0;
482 702
483 if (!mci->get_sdram_scrub_rate) 703 if (!mci->get_sdram_scrub_rate)
@@ -493,45 +713,72 @@ static ssize_t mci_sdram_scrub_rate_show(struct mem_ctl_info *mci, char *data)
493} 713}
494 714
495/* default attribute files for the MCI object */ 715/* default attribute files for the MCI object */
496static ssize_t mci_ue_count_show(struct mem_ctl_info *mci, char *data) 716static ssize_t mci_ue_count_show(struct device *dev,
717 struct device_attribute *mattr,
718 char *data)
497{ 719{
720 struct mem_ctl_info *mci = to_mci(dev);
721
498 return sprintf(data, "%d\n", mci->ue_mc); 722 return sprintf(data, "%d\n", mci->ue_mc);
499} 723}
500 724
501static ssize_t mci_ce_count_show(struct mem_ctl_info *mci, char *data) 725static ssize_t mci_ce_count_show(struct device *dev,
726 struct device_attribute *mattr,
727 char *data)
502{ 728{
729 struct mem_ctl_info *mci = to_mci(dev);
730
503 return sprintf(data, "%d\n", mci->ce_mc); 731 return sprintf(data, "%d\n", mci->ce_mc);
504} 732}
505 733
506static ssize_t mci_ce_noinfo_show(struct mem_ctl_info *mci, char *data) 734static ssize_t mci_ce_noinfo_show(struct device *dev,
735 struct device_attribute *mattr,
736 char *data)
507{ 737{
738 struct mem_ctl_info *mci = to_mci(dev);
739
508 return sprintf(data, "%d\n", mci->ce_noinfo_count); 740 return sprintf(data, "%d\n", mci->ce_noinfo_count);
509} 741}
510 742
511static ssize_t mci_ue_noinfo_show(struct mem_ctl_info *mci, char *data) 743static ssize_t mci_ue_noinfo_show(struct device *dev,
744 struct device_attribute *mattr,
745 char *data)
512{ 746{
747 struct mem_ctl_info *mci = to_mci(dev);
748
513 return sprintf(data, "%d\n", mci->ue_noinfo_count); 749 return sprintf(data, "%d\n", mci->ue_noinfo_count);
514} 750}
515 751
516static ssize_t mci_seconds_show(struct mem_ctl_info *mci, char *data) 752static ssize_t mci_seconds_show(struct device *dev,
753 struct device_attribute *mattr,
754 char *data)
517{ 755{
756 struct mem_ctl_info *mci = to_mci(dev);
757
518 return sprintf(data, "%ld\n", (jiffies - mci->start_time) / HZ); 758 return sprintf(data, "%ld\n", (jiffies - mci->start_time) / HZ);
519} 759}
520 760
521static ssize_t mci_ctl_name_show(struct mem_ctl_info *mci, char *data) 761static ssize_t mci_ctl_name_show(struct device *dev,
762 struct device_attribute *mattr,
763 char *data)
522{ 764{
765 struct mem_ctl_info *mci = to_mci(dev);
766
523 return sprintf(data, "%s\n", mci->ctl_name); 767 return sprintf(data, "%s\n", mci->ctl_name);
524} 768}
525 769
526static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data) 770static ssize_t mci_size_mb_show(struct device *dev,
771 struct device_attribute *mattr,
772 char *data)
527{ 773{
774 struct mem_ctl_info *mci = to_mci(dev);
528 int total_pages = 0, csrow_idx, j; 775 int total_pages = 0, csrow_idx, j;
529 776
530 for (csrow_idx = 0; csrow_idx < mci->nr_csrows; csrow_idx++) { 777 for (csrow_idx = 0; csrow_idx < mci->nr_csrows; csrow_idx++) {
531 struct csrow_info *csrow = &mci->csrows[csrow_idx]; 778 struct csrow_info *csrow = mci->csrows[csrow_idx];
532 779
533 for (j = 0; j < csrow->nr_channels; j++) { 780 for (j = 0; j < csrow->nr_channels; j++) {
534 struct dimm_info *dimm = csrow->channels[j].dimm; 781 struct dimm_info *dimm = csrow->channels[j]->dimm;
535 782
536 total_pages += dimm->nr_pages; 783 total_pages += dimm->nr_pages;
537 } 784 }
@@ -540,361 +787,187 @@ static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data)
540 return sprintf(data, "%u\n", PAGES_TO_MiB(total_pages)); 787 return sprintf(data, "%u\n", PAGES_TO_MiB(total_pages));
541} 788}
542 789
543#define to_mci(k) container_of(k, struct mem_ctl_info, edac_mci_kobj) 790static ssize_t mci_max_location_show(struct device *dev,
544#define to_mcidev_attr(a) container_of(a,struct mcidev_sysfs_attribute,attr) 791 struct device_attribute *mattr,
545 792 char *data)
546/* MCI show/store functions for top most object */
547static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr,
548 char *buffer)
549{ 793{
550 struct mem_ctl_info *mem_ctl_info = to_mci(kobj); 794 struct mem_ctl_info *mci = to_mci(dev);
551 struct mcidev_sysfs_attribute *mcidev_attr = to_mcidev_attr(attr); 795 int i;
552 796 char *p = data;
553 debugf1("%s() mem_ctl_info %p\n", __func__, mem_ctl_info);
554 797
555 if (mcidev_attr->show) 798 for (i = 0; i < mci->n_layers; i++) {
556 return mcidev_attr->show(mem_ctl_info, buffer); 799 p += sprintf(p, "%s %d ",
800 edac_layer_name[mci->layers[i].type],
801 mci->layers[i].size - 1);
802 }
557 803
558 return -EIO; 804 return p - data;
559} 805}
560 806
561static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr, 807#ifdef CONFIG_EDAC_DEBUG
562 const char *buffer, size_t count) 808static ssize_t edac_fake_inject_write(struct file *file,
809 const char __user *data,
810 size_t count, loff_t *ppos)
563{ 811{
564 struct mem_ctl_info *mem_ctl_info = to_mci(kobj); 812 struct device *dev = file->private_data;
565 struct mcidev_sysfs_attribute *mcidev_attr = to_mcidev_attr(attr); 813 struct mem_ctl_info *mci = to_mci(dev);
566 814 static enum hw_event_mc_err_type type;
567 debugf1("%s() mem_ctl_info %p\n", __func__, mem_ctl_info); 815 u16 errcount = mci->fake_inject_count;
568 816
569 if (mcidev_attr->store) 817 if (!errcount)
570 return mcidev_attr->store(mem_ctl_info, buffer, count); 818 errcount = 1;
819
820 type = mci->fake_inject_ue ? HW_EVENT_ERR_UNCORRECTED
821 : HW_EVENT_ERR_CORRECTED;
822
823 printk(KERN_DEBUG
824 "Generating %d %s fake error%s to %d.%d.%d to test core handling. NOTE: this won't test the driver-specific decoding logic.\n",
825 errcount,
826 (type == HW_EVENT_ERR_UNCORRECTED) ? "UE" : "CE",
827 errcount > 1 ? "s" : "",
828 mci->fake_inject_layer[0],
829 mci->fake_inject_layer[1],
830 mci->fake_inject_layer[2]
831 );
832 edac_mc_handle_error(type, mci, errcount, 0, 0, 0,
833 mci->fake_inject_layer[0],
834 mci->fake_inject_layer[1],
835 mci->fake_inject_layer[2],
836 "FAKE ERROR", "for EDAC testing only");
571 837
572 return -EIO; 838 return count;
573} 839}
574 840
575/* Intermediate show/store table */ 841static int debugfs_open(struct inode *inode, struct file *file)
576static const struct sysfs_ops mci_ops = { 842{
577 .show = mcidev_show, 843 file->private_data = inode->i_private;
578 .store = mcidev_store 844 return 0;
579}; 845}
580 846
581#define MCIDEV_ATTR(_name,_mode,_show,_store) \ 847static const struct file_operations debug_fake_inject_fops = {
582static struct mcidev_sysfs_attribute mci_attr_##_name = { \ 848 .open = debugfs_open,
583 .attr = {.name = __stringify(_name), .mode = _mode }, \ 849 .write = edac_fake_inject_write,
584 .show = _show, \ 850 .llseek = generic_file_llseek,
585 .store = _store, \
586}; 851};
852#endif
587 853
588/* default Control file */ 854/* default Control file */
589MCIDEV_ATTR(reset_counters, S_IWUSR, NULL, mci_reset_counters_store); 855DEVICE_ATTR(reset_counters, S_IWUSR, NULL, mci_reset_counters_store);
590 856
591/* default Attribute files */ 857/* default Attribute files */
592MCIDEV_ATTR(mc_name, S_IRUGO, mci_ctl_name_show, NULL); 858DEVICE_ATTR(mc_name, S_IRUGO, mci_ctl_name_show, NULL);
593MCIDEV_ATTR(size_mb, S_IRUGO, mci_size_mb_show, NULL); 859DEVICE_ATTR(size_mb, S_IRUGO, mci_size_mb_show, NULL);
594MCIDEV_ATTR(seconds_since_reset, S_IRUGO, mci_seconds_show, NULL); 860DEVICE_ATTR(seconds_since_reset, S_IRUGO, mci_seconds_show, NULL);
595MCIDEV_ATTR(ue_noinfo_count, S_IRUGO, mci_ue_noinfo_show, NULL); 861DEVICE_ATTR(ue_noinfo_count, S_IRUGO, mci_ue_noinfo_show, NULL);
596MCIDEV_ATTR(ce_noinfo_count, S_IRUGO, mci_ce_noinfo_show, NULL); 862DEVICE_ATTR(ce_noinfo_count, S_IRUGO, mci_ce_noinfo_show, NULL);
597MCIDEV_ATTR(ue_count, S_IRUGO, mci_ue_count_show, NULL); 863DEVICE_ATTR(ue_count, S_IRUGO, mci_ue_count_show, NULL);
598MCIDEV_ATTR(ce_count, S_IRUGO, mci_ce_count_show, NULL); 864DEVICE_ATTR(ce_count, S_IRUGO, mci_ce_count_show, NULL);
865DEVICE_ATTR(max_location, S_IRUGO, mci_max_location_show, NULL);
599 866
600/* memory scrubber attribute file */ 867/* memory scrubber attribute file */
601MCIDEV_ATTR(sdram_scrub_rate, S_IRUGO | S_IWUSR, mci_sdram_scrub_rate_show, 868DEVICE_ATTR(sdram_scrub_rate, S_IRUGO | S_IWUSR, mci_sdram_scrub_rate_show,
602 mci_sdram_scrub_rate_store); 869 mci_sdram_scrub_rate_store);
603 870
604static struct mcidev_sysfs_attribute *mci_attr[] = { 871static struct attribute *mci_attrs[] = {
605 &mci_attr_reset_counters, 872 &dev_attr_reset_counters.attr,
606 &mci_attr_mc_name, 873 &dev_attr_mc_name.attr,
607 &mci_attr_size_mb, 874 &dev_attr_size_mb.attr,
608 &mci_attr_seconds_since_reset, 875 &dev_attr_seconds_since_reset.attr,
609 &mci_attr_ue_noinfo_count, 876 &dev_attr_ue_noinfo_count.attr,
610 &mci_attr_ce_noinfo_count, 877 &dev_attr_ce_noinfo_count.attr,
611 &mci_attr_ue_count, 878 &dev_attr_ue_count.attr,
612 &mci_attr_ce_count, 879 &dev_attr_ce_count.attr,
613 &mci_attr_sdram_scrub_rate, 880 &dev_attr_sdram_scrub_rate.attr,
881 &dev_attr_max_location.attr,
614 NULL 882 NULL
615}; 883};
616 884
885static struct attribute_group mci_attr_grp = {
886 .attrs = mci_attrs,
887};
617 888
618/* 889static const struct attribute_group *mci_attr_groups[] = {
619 * Release of a MC controlling instance 890 &mci_attr_grp,
620 * 891 NULL
621 * each MC control instance has the following resources upon entry: 892};
622 * a) a ref count on the top memctl kobj
623 * b) a ref count on this module
624 *
625 * this function must decrement those ref counts and then
626 * issue a free on the instance's memory
627 */
628static void edac_mci_control_release(struct kobject *kobj)
629{
630 struct mem_ctl_info *mci;
631
632 mci = to_mci(kobj);
633 893
634 debugf0("%s() mci instance idx=%d releasing\n", __func__, mci->mc_idx); 894static void mci_attr_release(struct device *dev)
895{
896 struct mem_ctl_info *mci = container_of(dev, struct mem_ctl_info, dev);
635 897
636 /* decrement the module ref count */ 898 edac_dbg(1, "Releasing csrow device %s\n", dev_name(dev));
637 module_put(mci->owner); 899 kfree(mci);
638} 900}
639 901
640static struct kobj_type ktype_mci = { 902static struct device_type mci_attr_type = {
641 .release = edac_mci_control_release, 903 .groups = mci_attr_groups,
642 .sysfs_ops = &mci_ops, 904 .release = mci_attr_release,
643 .default_attrs = (struct attribute **)mci_attr,
644}; 905};
645 906
646/* EDAC memory controller sysfs kset: 907#ifdef CONFIG_EDAC_DEBUG
647 * /sys/devices/system/edac/mc 908static struct dentry *edac_debugfs;
648 */
649static struct kset *mc_kset;
650 909
651/* 910int __init edac_debugfs_init(void)
652 * edac_mc_register_sysfs_main_kobj
653 *
654 * setups and registers the main kobject for each mci
655 */
656int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci)
657{ 911{
658 struct kobject *kobj_mci; 912 edac_debugfs = debugfs_create_dir("edac", NULL);
659 int err; 913 if (IS_ERR(edac_debugfs)) {
660 914 edac_debugfs = NULL;
661 debugf1("%s()\n", __func__); 915 return -ENOMEM;
662
663 kobj_mci = &mci->edac_mci_kobj;
664
665 /* Init the mci's kobject */
666 memset(kobj_mci, 0, sizeof(*kobj_mci));
667
668 /* Record which module 'owns' this control structure
669 * and bump the ref count of the module
670 */
671 mci->owner = THIS_MODULE;
672
673 /* bump ref count on this module */
674 if (!try_module_get(mci->owner)) {
675 err = -ENODEV;
676 goto fail_out;
677 }
678
679 /* this instance become part of the mc_kset */
680 kobj_mci->kset = mc_kset;
681
682 /* register the mc<id> kobject to the mc_kset */
683 err = kobject_init_and_add(kobj_mci, &ktype_mci, NULL,
684 "mc%d", mci->mc_idx);
685 if (err) {
686 debugf1("%s()Failed to register '.../edac/mc%d'\n",
687 __func__, mci->mc_idx);
688 goto kobj_reg_fail;
689 } 916 }
690 kobject_uevent(kobj_mci, KOBJ_ADD);
691
692 /* At this point, to 'free' the control struct,
693 * edac_mc_unregister_sysfs_main_kobj() must be used
694 */
695
696 debugf1("%s() Registered '.../edac/mc%d' kobject\n",
697 __func__, mci->mc_idx);
698
699 return 0; 917 return 0;
700
701 /* Error exit stack */
702
703kobj_reg_fail:
704 module_put(mci->owner);
705
706fail_out:
707 return err;
708}
709
710/*
711 * edac_mc_register_sysfs_main_kobj
712 *
713 * tears down and the main mci kobject from the mc_kset
714 */
715void edac_mc_unregister_sysfs_main_kobj(struct mem_ctl_info *mci)
716{
717 debugf1("%s()\n", __func__);
718
719 /* delete the kobj from the mc_kset */
720 kobject_put(&mci->edac_mci_kobj);
721}
722
723#define EDAC_DEVICE_SYMLINK "device"
724
725#define grp_to_mci(k) (container_of(k, struct mcidev_sysfs_group_kobj, kobj)->mci)
726
727/* MCI show/store functions for top most object */
728static ssize_t inst_grp_show(struct kobject *kobj, struct attribute *attr,
729 char *buffer)
730{
731 struct mem_ctl_info *mem_ctl_info = grp_to_mci(kobj);
732 struct mcidev_sysfs_attribute *mcidev_attr = to_mcidev_attr(attr);
733
734 debugf1("%s() mem_ctl_info %p\n", __func__, mem_ctl_info);
735
736 if (mcidev_attr->show)
737 return mcidev_attr->show(mem_ctl_info, buffer);
738
739 return -EIO;
740} 918}
741 919
742static ssize_t inst_grp_store(struct kobject *kobj, struct attribute *attr, 920void __exit edac_debugfs_exit(void)
743 const char *buffer, size_t count)
744{ 921{
745 struct mem_ctl_info *mem_ctl_info = grp_to_mci(kobj); 922 debugfs_remove(edac_debugfs);
746 struct mcidev_sysfs_attribute *mcidev_attr = to_mcidev_attr(attr);
747
748 debugf1("%s() mem_ctl_info %p\n", __func__, mem_ctl_info);
749
750 if (mcidev_attr->store)
751 return mcidev_attr->store(mem_ctl_info, buffer, count);
752
753 return -EIO;
754} 923}
755 924
756/* No memory to release for this kobj */ 925int edac_create_debug_nodes(struct mem_ctl_info *mci)
757static void edac_inst_grp_release(struct kobject *kobj)
758{ 926{
759 struct mcidev_sysfs_group_kobj *grp; 927 struct dentry *d, *parent;
760 struct mem_ctl_info *mci; 928 char name[80];
761 929 int i;
762 debugf1("%s()\n", __func__);
763
764 grp = container_of(kobj, struct mcidev_sysfs_group_kobj, kobj);
765 mci = grp->mci;
766}
767
768/* Intermediate show/store table */
769static struct sysfs_ops inst_grp_ops = {
770 .show = inst_grp_show,
771 .store = inst_grp_store
772};
773
774/* the kobj_type instance for a instance group */
775static struct kobj_type ktype_inst_grp = {
776 .release = edac_inst_grp_release,
777 .sysfs_ops = &inst_grp_ops,
778};
779
780 930
781/* 931 if (!edac_debugfs)
782 * edac_create_mci_instance_attributes 932 return -ENODEV;
783 * create MC driver specific attributes bellow an specified kobj
784 * This routine calls itself recursively, in order to create an entire
785 * object tree.
786 */
787static int edac_create_mci_instance_attributes(struct mem_ctl_info *mci,
788 const struct mcidev_sysfs_attribute *sysfs_attrib,
789 struct kobject *kobj)
790{
791 int err;
792 933
793 debugf4("%s()\n", __func__); 934 d = debugfs_create_dir(mci->dev.kobj.name, edac_debugfs);
794 935 if (!d)
795 while (sysfs_attrib) { 936 return -ENOMEM;
796 debugf4("%s() sysfs_attrib = %p\n",__func__, sysfs_attrib); 937 parent = d;
797 if (sysfs_attrib->grp) { 938
798 struct mcidev_sysfs_group_kobj *grp_kobj; 939 for (i = 0; i < mci->n_layers; i++) {
799 940 sprintf(name, "fake_inject_%s",
800 grp_kobj = kzalloc(sizeof(*grp_kobj), GFP_KERNEL); 941 edac_layer_name[mci->layers[i].type]);
801 if (!grp_kobj) 942 d = debugfs_create_u8(name, S_IRUGO | S_IWUSR, parent,
802 return -ENOMEM; 943 &mci->fake_inject_layer[i]);
803 944 if (!d)
804 grp_kobj->grp = sysfs_attrib->grp; 945 goto nomem;
805 grp_kobj->mci = mci;
806 list_add_tail(&grp_kobj->list, &mci->grp_kobj_list);
807
808 debugf0("%s() grp %s, mci %p\n", __func__,
809 sysfs_attrib->grp->name, mci);
810
811 err = kobject_init_and_add(&grp_kobj->kobj,
812 &ktype_inst_grp,
813 &mci->edac_mci_kobj,
814 sysfs_attrib->grp->name);
815 if (err < 0) {
816 printk(KERN_ERR "kobject_init_and_add failed: %d\n", err);
817 return err;
818 }
819 err = edac_create_mci_instance_attributes(mci,
820 grp_kobj->grp->mcidev_attr,
821 &grp_kobj->kobj);
822
823 if (err < 0)
824 return err;
825 } else if (sysfs_attrib->attr.name) {
826 debugf4("%s() file %s\n", __func__,
827 sysfs_attrib->attr.name);
828
829 err = sysfs_create_file(kobj, &sysfs_attrib->attr);
830 if (err < 0) {
831 printk(KERN_ERR "sysfs_create_file failed: %d\n", err);
832 return err;
833 }
834 } else
835 break;
836
837 sysfs_attrib++;
838 } 946 }
839 947
840 return 0; 948 d = debugfs_create_bool("fake_inject_ue", S_IRUGO | S_IWUSR, parent,
841} 949 &mci->fake_inject_ue);
950 if (!d)
951 goto nomem;
842 952
843/* 953 d = debugfs_create_u16("fake_inject_count", S_IRUGO | S_IWUSR, parent,
844 * edac_remove_mci_instance_attributes 954 &mci->fake_inject_count);
845 * remove MC driver specific attributes at the topmost level 955 if (!d)
846 * directory of this mci instance. 956 goto nomem;
847 */
848static void edac_remove_mci_instance_attributes(struct mem_ctl_info *mci,
849 const struct mcidev_sysfs_attribute *sysfs_attrib,
850 struct kobject *kobj, int count)
851{
852 struct mcidev_sysfs_group_kobj *grp_kobj, *tmp;
853 957
854 debugf1("%s()\n", __func__); 958 d = debugfs_create_file("fake_inject", S_IWUSR, parent,
855 959 &mci->dev,
856 /* 960 &debug_fake_inject_fops);
857 * loop if there are attributes and until we hit a NULL entry 961 if (!d)
858 * Remove first all the attributes 962 goto nomem;
859 */
860 while (sysfs_attrib) {
861 debugf4("%s() sysfs_attrib = %p\n",__func__, sysfs_attrib);
862 if (sysfs_attrib->grp) {
863 debugf4("%s() seeking for group %s\n",
864 __func__, sysfs_attrib->grp->name);
865 list_for_each_entry(grp_kobj,
866 &mci->grp_kobj_list, list) {
867 debugf4("%s() grp_kobj->grp = %p\n",__func__, grp_kobj->grp);
868 if (grp_kobj->grp == sysfs_attrib->grp) {
869 edac_remove_mci_instance_attributes(mci,
870 grp_kobj->grp->mcidev_attr,
871 &grp_kobj->kobj, count + 1);
872 debugf4("%s() group %s\n", __func__,
873 sysfs_attrib->grp->name);
874 kobject_put(&grp_kobj->kobj);
875 }
876 }
877 debugf4("%s() end of seeking for group %s\n",
878 __func__, sysfs_attrib->grp->name);
879 } else if (sysfs_attrib->attr.name) {
880 debugf4("%s() file %s\n", __func__,
881 sysfs_attrib->attr.name);
882 sysfs_remove_file(kobj, &sysfs_attrib->attr);
883 } else
884 break;
885 sysfs_attrib++;
886 }
887 963
888 /* Remove the group objects */ 964 mci->debugfs = parent;
889 if (count) 965 return 0;
890 return; 966nomem:
891 list_for_each_entry_safe(grp_kobj, tmp, 967 debugfs_remove(mci->debugfs);
892 &mci->grp_kobj_list, list) { 968 return -ENOMEM;
893 list_del(&grp_kobj->list);
894 kfree(grp_kobj);
895 }
896} 969}
897 970#endif
898 971
899/* 972/*
900 * Create a new Memory Controller kobject instance, 973 * Create a new Memory Controller kobject instance,
@@ -906,77 +979,87 @@ static void edac_remove_mci_instance_attributes(struct mem_ctl_info *mci,
906 */ 979 */
907int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) 980int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
908{ 981{
909 int i, j; 982 int i, err;
910 int err;
911 struct csrow_info *csrow;
912 struct kobject *kobj_mci = &mci->edac_mci_kobj;
913 983
914 debugf0("%s() idx=%d\n", __func__, mci->mc_idx); 984 /*
915 985 * The memory controller needs its own bus, in order to avoid
916 INIT_LIST_HEAD(&mci->grp_kobj_list); 986 * namespace conflicts at /sys/bus/edac.
987 */
988 mci->bus.name = kasprintf(GFP_KERNEL, "mc%d", mci->mc_idx);
989 if (!mci->bus.name)
990 return -ENOMEM;
991 edac_dbg(0, "creating bus %s\n", mci->bus.name);
992 err = bus_register(&mci->bus);
993 if (err < 0)
994 return err;
917 995
918 /* create a symlink for the device */ 996 /* get the /sys/devices/system/edac subsys reference */
919 err = sysfs_create_link(kobj_mci, &mci->dev->kobj, 997 mci->dev.type = &mci_attr_type;
920 EDAC_DEVICE_SYMLINK); 998 device_initialize(&mci->dev);
921 if (err) { 999
922 debugf1("%s() failure to create symlink\n", __func__); 1000 mci->dev.parent = mci_pdev;
923 goto fail0; 1001 mci->dev.bus = &mci->bus;
1002 dev_set_name(&mci->dev, "mc%d", mci->mc_idx);
1003 dev_set_drvdata(&mci->dev, mci);
1004 pm_runtime_forbid(&mci->dev);
1005
1006 edac_dbg(0, "creating device %s\n", dev_name(&mci->dev));
1007 err = device_add(&mci->dev);
1008 if (err < 0) {
1009 bus_unregister(&mci->bus);
1010 kfree(mci->bus.name);
1011 return err;
924 } 1012 }
925 1013
926 /* If the low level driver desires some attributes, 1014 /*
927 * then create them now for the driver. 1015 * Create the dimm/rank devices
928 */ 1016 */
929 if (mci->mc_driver_sysfs_attributes) { 1017 for (i = 0; i < mci->tot_dimms; i++) {
930 err = edac_create_mci_instance_attributes(mci, 1018 struct dimm_info *dimm = mci->dimms[i];
931 mci->mc_driver_sysfs_attributes, 1019 /* Only expose populated DIMMs */
932 &mci->edac_mci_kobj); 1020 if (dimm->nr_pages == 0)
1021 continue;
1022#ifdef CONFIG_EDAC_DEBUG
1023 edac_dbg(1, "creating dimm%d, located at ", i);
1024 if (edac_debug_level >= 1) {
1025 int lay;
1026 for (lay = 0; lay < mci->n_layers; lay++)
1027 printk(KERN_CONT "%s %d ",
1028 edac_layer_name[mci->layers[lay].type],
1029 dimm->location[lay]);
1030 printk(KERN_CONT "\n");
1031 }
1032#endif
1033 err = edac_create_dimm_object(mci, dimm, i);
933 if (err) { 1034 if (err) {
934 debugf1("%s() failure to create mci attributes\n", 1035 edac_dbg(1, "failure: create dimm %d obj\n", i);
935 __func__); 1036 goto fail;
936 goto fail0;
937 } 1037 }
938 } 1038 }
939 1039
940 /* Make directories for each CSROW object under the mc<id> kobject 1040#ifdef CONFIG_EDAC_LEGACY_SYSFS
941 */ 1041 err = edac_create_csrow_objects(mci);
942 for (i = 0; i < mci->nr_csrows; i++) { 1042 if (err < 0)
943 int nr_pages = 0; 1043 goto fail;
944 1044#endif
945 csrow = &mci->csrows[i];
946 for (j = 0; j < csrow->nr_channels; j++)
947 nr_pages += csrow->channels[j].dimm->nr_pages;
948
949 if (nr_pages > 0) {
950 err = edac_create_csrow_object(mci, csrow, i);
951 if (err) {
952 debugf1("%s() failure: create csrow %d obj\n",
953 __func__, i);
954 goto fail1;
955 }
956 }
957 }
958 1045
1046#ifdef CONFIG_EDAC_DEBUG
1047 edac_create_debug_nodes(mci);
1048#endif
959 return 0; 1049 return 0;
960 1050
961fail1: 1051fail:
962 for (i--; i >= 0; i--) { 1052 for (i--; i >= 0; i--) {
963 int nr_pages = 0; 1053 struct dimm_info *dimm = mci->dimms[i];
964 1054 if (dimm->nr_pages == 0)
965 csrow = &mci->csrows[i]; 1055 continue;
966 for (j = 0; j < csrow->nr_channels; j++) 1056 put_device(&dimm->dev);
967 nr_pages += csrow->channels[j].dimm->nr_pages; 1057 device_del(&dimm->dev);
968 if (nr_pages > 0)
969 kobject_put(&mci->csrows[i].kobj);
970 } 1058 }
971 1059 put_device(&mci->dev);
972 /* remove the mci instance's attributes, if any */ 1060 device_del(&mci->dev);
973 edac_remove_mci_instance_attributes(mci, 1061 bus_unregister(&mci->bus);
974 mci->mc_driver_sysfs_attributes, &mci->edac_mci_kobj, 0); 1062 kfree(mci->bus.name);
975
976 /* remove the symlink */
977 sysfs_remove_link(kobj_mci, EDAC_DEVICE_SYMLINK);
978
979fail0:
980 return err; 1063 return err;
981} 1064}
982 1065
@@ -985,98 +1068,84 @@ fail0:
985 */ 1068 */
986void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) 1069void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
987{ 1070{
988 struct csrow_info *csrow; 1071 int i;
989 int i, j;
990
991 debugf0("%s()\n", __func__);
992
993 /* remove all csrow kobjects */
994 debugf4("%s() unregister this mci kobj\n", __func__);
995 for (i = 0; i < mci->nr_csrows; i++) {
996 int nr_pages = 0;
997
998 csrow = &mci->csrows[i];
999 for (j = 0; j < csrow->nr_channels; j++)
1000 nr_pages += csrow->channels[j].dimm->nr_pages;
1001 if (nr_pages > 0) {
1002 debugf0("%s() unreg csrow-%d\n", __func__, i);
1003 kobject_put(&mci->csrows[i].kobj);
1004 }
1005 }
1006 1072
1007 /* remove this mci instance's attribtes */ 1073 edac_dbg(0, "\n");
1008 if (mci->mc_driver_sysfs_attributes) { 1074
1009 debugf4("%s() unregister mci private attributes\n", __func__); 1075#ifdef CONFIG_EDAC_DEBUG
1010 edac_remove_mci_instance_attributes(mci, 1076 debugfs_remove(mci->debugfs);
1011 mci->mc_driver_sysfs_attributes, 1077#endif
1012 &mci->edac_mci_kobj, 0); 1078#ifdef CONFIG_EDAC_LEGACY_SYSFS
1079 edac_delete_csrow_objects(mci);
1080#endif
1081
1082 for (i = 0; i < mci->tot_dimms; i++) {
1083 struct dimm_info *dimm = mci->dimms[i];
1084 if (dimm->nr_pages == 0)
1085 continue;
1086 edac_dbg(0, "removing device %s\n", dev_name(&dimm->dev));
1087 put_device(&dimm->dev);
1088 device_del(&dimm->dev);
1013 } 1089 }
1014
1015 /* remove the symlink */
1016 debugf4("%s() remove_link\n", __func__);
1017 sysfs_remove_link(&mci->edac_mci_kobj, EDAC_DEVICE_SYMLINK);
1018
1019 /* unregister this instance's kobject */
1020 debugf4("%s() remove_mci_instance\n", __func__);
1021 kobject_put(&mci->edac_mci_kobj);
1022} 1090}
1023 1091
1092void edac_unregister_sysfs(struct mem_ctl_info *mci)
1093{
1094 edac_dbg(1, "Unregistering device %s\n", dev_name(&mci->dev));
1095 put_device(&mci->dev);
1096 device_del(&mci->dev);
1097 bus_unregister(&mci->bus);
1098 kfree(mci->bus.name);
1099}
1024 1100
1101static void mc_attr_release(struct device *dev)
1102{
1103 /*
1104 * There's no container structure here, as this is just the mci
1105 * parent device, used to create the /sys/devices/mc sysfs node.
1106 * So, there are no attributes on it.
1107 */
1108 edac_dbg(1, "Releasing device %s\n", dev_name(dev));
1109 kfree(dev);
1110}
1025 1111
1026 1112static struct device_type mc_attr_type = {
1113 .release = mc_attr_release,
1114};
1027/* 1115/*
1028 * edac_setup_sysfs_mc_kset(void) 1116 * Init/exit code for the module. Basically, creates/removes /sys/class/rc
1029 *
1030 * Initialize the mc_kset for the 'mc' entry
1031 * This requires creating the top 'mc' directory with a kset
1032 * and its controls/attributes.
1033 *
1034 * To this 'mc' kset, instance 'mci' will be grouped as children.
1035 *
1036 * Return: 0 SUCCESS
1037 * !0 FAILURE error code
1038 */ 1117 */
1039int edac_sysfs_setup_mc_kset(void) 1118int __init edac_mc_sysfs_init(void)
1040{ 1119{
1041 int err = -EINVAL;
1042 struct bus_type *edac_subsys; 1120 struct bus_type *edac_subsys;
1043 1121 int err;
1044 debugf1("%s()\n", __func__);
1045 1122
1046 /* get the /sys/devices/system/edac subsys reference */ 1123 /* get the /sys/devices/system/edac subsys reference */
1047 edac_subsys = edac_get_sysfs_subsys(); 1124 edac_subsys = edac_get_sysfs_subsys();
1048 if (edac_subsys == NULL) { 1125 if (edac_subsys == NULL) {
1049 debugf1("%s() no edac_subsys error=%d\n", __func__, err); 1126 edac_dbg(1, "no edac_subsys\n");
1050 goto fail_out; 1127 return -EINVAL;
1051 } 1128 }
1052 1129
1053 /* Init the MC's kobject */ 1130 mci_pdev = kzalloc(sizeof(*mci_pdev), GFP_KERNEL);
1054 mc_kset = kset_create_and_add("mc", NULL, &edac_subsys->dev_root->kobj);
1055 if (!mc_kset) {
1056 err = -ENOMEM;
1057 debugf1("%s() Failed to register '.../edac/mc'\n", __func__);
1058 goto fail_kset;
1059 }
1060 1131
1061 debugf1("%s() Registered '.../edac/mc' kobject\n", __func__); 1132 mci_pdev->bus = edac_subsys;
1133 mci_pdev->type = &mc_attr_type;
1134 device_initialize(mci_pdev);
1135 dev_set_name(mci_pdev, "mc");
1062 1136
1063 return 0; 1137 err = device_add(mci_pdev);
1138 if (err < 0)
1139 return err;
1064 1140
1065fail_kset: 1141 edac_dbg(0, "device %s created\n", dev_name(mci_pdev));
1066 edac_put_sysfs_subsys();
1067 1142
1068fail_out: 1143 return 0;
1069 return err;
1070} 1144}
1071 1145
1072/* 1146void __exit edac_mc_sysfs_exit(void)
1073 * edac_sysfs_teardown_mc_kset
1074 *
1075 * deconstruct the mc_ket for memory controllers
1076 */
1077void edac_sysfs_teardown_mc_kset(void)
1078{ 1147{
1079 kset_unregister(mc_kset); 1148 put_device(mci_pdev);
1149 device_del(mci_pdev);
1080 edac_put_sysfs_subsys(); 1150 edac_put_sysfs_subsys();
1081} 1151}
1082
diff --git a/drivers/edac/edac_module.c b/drivers/edac/edac_module.c
index 5ddaa86d6a6e..58a28d838f37 100644
--- a/drivers/edac/edac_module.c
+++ b/drivers/edac/edac_module.c
@@ -15,7 +15,7 @@
15#include "edac_core.h" 15#include "edac_core.h"
16#include "edac_module.h" 16#include "edac_module.h"
17 17
18#define EDAC_VERSION "Ver: 2.1.0" 18#define EDAC_VERSION "Ver: 3.0.0"
19 19
20#ifdef CONFIG_EDAC_DEBUG 20#ifdef CONFIG_EDAC_DEBUG
21/* Values of 0 to 4 will generate output */ 21/* Values of 0 to 4 will generate output */
@@ -90,26 +90,21 @@ static int __init edac_init(void)
90 */ 90 */
91 edac_pci_clear_parity_errors(); 91 edac_pci_clear_parity_errors();
92 92
93 /* 93 err = edac_mc_sysfs_init();
94 * now set up the mc_kset under the edac class object
95 */
96 err = edac_sysfs_setup_mc_kset();
97 if (err) 94 if (err)
98 goto error; 95 goto error;
99 96
97 edac_debugfs_init();
98
100 /* Setup/Initialize the workq for this core */ 99 /* Setup/Initialize the workq for this core */
101 err = edac_workqueue_setup(); 100 err = edac_workqueue_setup();
102 if (err) { 101 if (err) {
103 edac_printk(KERN_ERR, EDAC_MC, "init WorkQueue failure\n"); 102 edac_printk(KERN_ERR, EDAC_MC, "init WorkQueue failure\n");
104 goto workq_fail; 103 goto error;
105 } 104 }
106 105
107 return 0; 106 return 0;
108 107
109 /* Error teardown stack */
110workq_fail:
111 edac_sysfs_teardown_mc_kset();
112
113error: 108error:
114 return err; 109 return err;
115} 110}
@@ -120,11 +115,12 @@ error:
120 */ 115 */
121static void __exit edac_exit(void) 116static void __exit edac_exit(void)
122{ 117{
123 debugf0("%s()\n", __func__); 118 edac_dbg(0, "\n");
124 119
125 /* tear down the various subsystems */ 120 /* tear down the various subsystems */
126 edac_workqueue_teardown(); 121 edac_workqueue_teardown();
127 edac_sysfs_teardown_mc_kset(); 122 edac_mc_sysfs_exit();
123 edac_debugfs_exit();
128} 124}
129 125
130/* 126/*
diff --git a/drivers/edac/edac_module.h b/drivers/edac/edac_module.h
index 0ea7d14cb930..3d139c6e7fe3 100644
--- a/drivers/edac/edac_module.h
+++ b/drivers/edac/edac_module.h
@@ -19,12 +19,12 @@
19 * 19 *
20 * edac_mc objects 20 * edac_mc objects
21 */ 21 */
22extern int edac_sysfs_setup_mc_kset(void); 22 /* on edac_mc_sysfs.c */
23extern void edac_sysfs_teardown_mc_kset(void); 23int edac_mc_sysfs_init(void);
24extern int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci); 24void edac_mc_sysfs_exit(void);
25extern void edac_mc_unregister_sysfs_main_kobj(struct mem_ctl_info *mci);
26extern int edac_create_sysfs_mci_device(struct mem_ctl_info *mci); 25extern int edac_create_sysfs_mci_device(struct mem_ctl_info *mci);
27extern void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci); 26extern void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci);
27void edac_unregister_sysfs(struct mem_ctl_info *mci);
28extern int edac_get_log_ue(void); 28extern int edac_get_log_ue(void);
29extern int edac_get_log_ce(void); 29extern int edac_get_log_ce(void);
30extern int edac_get_panic_on_ue(void); 30extern int edac_get_panic_on_ue(void);
@@ -34,6 +34,10 @@ extern int edac_mc_get_panic_on_ue(void);
34extern int edac_get_poll_msec(void); 34extern int edac_get_poll_msec(void);
35extern int edac_mc_get_poll_msec(void); 35extern int edac_mc_get_poll_msec(void);
36 36
37unsigned edac_dimm_info_location(struct dimm_info *dimm, char *buf,
38 unsigned len);
39
40 /* on edac_device.c */
37extern int edac_device_register_sysfs_main_kobj( 41extern int edac_device_register_sysfs_main_kobj(
38 struct edac_device_ctl_info *edac_dev); 42 struct edac_device_ctl_info *edac_dev);
39extern void edac_device_unregister_sysfs_main_kobj( 43extern void edac_device_unregister_sysfs_main_kobj(
@@ -53,6 +57,20 @@ extern void edac_mc_reset_delay_period(int value);
53extern void *edac_align_ptr(void **p, unsigned size, int n_elems); 57extern void *edac_align_ptr(void **p, unsigned size, int n_elems);
54 58
55/* 59/*
60 * EDAC debugfs functions
61 */
62#ifdef CONFIG_EDAC_DEBUG
63int edac_debugfs_init(void);
64void edac_debugfs_exit(void);
65#else
66static inline int edac_debugfs_init(void)
67{
68 return -ENODEV;
69}
70static inline void edac_debugfs_exit(void) {}
71#endif
72
73/*
56 * EDAC PCI functions 74 * EDAC PCI functions
57 */ 75 */
58#ifdef CONFIG_PCI 76#ifdef CONFIG_PCI
diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
index f1ac86649886..ee87ef972ead 100644
--- a/drivers/edac/edac_pci.c
+++ b/drivers/edac/edac_pci.c
@@ -45,7 +45,7 @@ struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt,
45 void *p = NULL, *pvt; 45 void *p = NULL, *pvt;
46 unsigned int size; 46 unsigned int size;
47 47
48 debugf1("%s()\n", __func__); 48 edac_dbg(1, "\n");
49 49
50 pci = edac_align_ptr(&p, sizeof(*pci), 1); 50 pci = edac_align_ptr(&p, sizeof(*pci), 1);
51 pvt = edac_align_ptr(&p, 1, sz_pvt); 51 pvt = edac_align_ptr(&p, 1, sz_pvt);
@@ -80,7 +80,7 @@ EXPORT_SYMBOL_GPL(edac_pci_alloc_ctl_info);
80 */ 80 */
81void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci) 81void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci)
82{ 82{
83 debugf1("%s()\n", __func__); 83 edac_dbg(1, "\n");
84 84
85 edac_pci_remove_sysfs(pci); 85 edac_pci_remove_sysfs(pci);
86} 86}
@@ -97,7 +97,7 @@ static struct edac_pci_ctl_info *find_edac_pci_by_dev(struct device *dev)
97 struct edac_pci_ctl_info *pci; 97 struct edac_pci_ctl_info *pci;
98 struct list_head *item; 98 struct list_head *item;
99 99
100 debugf1("%s()\n", __func__); 100 edac_dbg(1, "\n");
101 101
102 list_for_each(item, &edac_pci_list) { 102 list_for_each(item, &edac_pci_list) {
103 pci = list_entry(item, struct edac_pci_ctl_info, link); 103 pci = list_entry(item, struct edac_pci_ctl_info, link);
@@ -122,7 +122,7 @@ static int add_edac_pci_to_global_list(struct edac_pci_ctl_info *pci)
122 struct list_head *item, *insert_before; 122 struct list_head *item, *insert_before;
123 struct edac_pci_ctl_info *rover; 123 struct edac_pci_ctl_info *rover;
124 124
125 debugf1("%s()\n", __func__); 125 edac_dbg(1, "\n");
126 126
127 insert_before = &edac_pci_list; 127 insert_before = &edac_pci_list;
128 128
@@ -226,7 +226,7 @@ static void edac_pci_workq_function(struct work_struct *work_req)
226 int msec; 226 int msec;
227 unsigned long delay; 227 unsigned long delay;
228 228
229 debugf3("%s() checking\n", __func__); 229 edac_dbg(3, "checking\n");
230 230
231 mutex_lock(&edac_pci_ctls_mutex); 231 mutex_lock(&edac_pci_ctls_mutex);
232 232
@@ -261,7 +261,7 @@ static void edac_pci_workq_function(struct work_struct *work_req)
261static void edac_pci_workq_setup(struct edac_pci_ctl_info *pci, 261static void edac_pci_workq_setup(struct edac_pci_ctl_info *pci,
262 unsigned int msec) 262 unsigned int msec)
263{ 263{
264 debugf0("%s()\n", __func__); 264 edac_dbg(0, "\n");
265 265
266 INIT_DELAYED_WORK(&pci->work, edac_pci_workq_function); 266 INIT_DELAYED_WORK(&pci->work, edac_pci_workq_function);
267 queue_delayed_work(edac_workqueue, &pci->work, 267 queue_delayed_work(edac_workqueue, &pci->work,
@@ -276,7 +276,7 @@ static void edac_pci_workq_teardown(struct edac_pci_ctl_info *pci)
276{ 276{
277 int status; 277 int status;
278 278
279 debugf0("%s()\n", __func__); 279 edac_dbg(0, "\n");
280 280
281 status = cancel_delayed_work(&pci->work); 281 status = cancel_delayed_work(&pci->work);
282 if (status == 0) 282 if (status == 0)
@@ -293,7 +293,7 @@ static void edac_pci_workq_teardown(struct edac_pci_ctl_info *pci)
293void edac_pci_reset_delay_period(struct edac_pci_ctl_info *pci, 293void edac_pci_reset_delay_period(struct edac_pci_ctl_info *pci,
294 unsigned long value) 294 unsigned long value)
295{ 295{
296 debugf0("%s()\n", __func__); 296 edac_dbg(0, "\n");
297 297
298 edac_pci_workq_teardown(pci); 298 edac_pci_workq_teardown(pci);
299 299
@@ -333,7 +333,7 @@ EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
333 */ 333 */
334int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx) 334int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx)
335{ 335{
336 debugf0("%s()\n", __func__); 336 edac_dbg(0, "\n");
337 337
338 pci->pci_idx = edac_idx; 338 pci->pci_idx = edac_idx;
339 pci->start_time = jiffies; 339 pci->start_time = jiffies;
@@ -393,7 +393,7 @@ struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev)
393{ 393{
394 struct edac_pci_ctl_info *pci; 394 struct edac_pci_ctl_info *pci;
395 395
396 debugf0("%s()\n", __func__); 396 edac_dbg(0, "\n");
397 397
398 mutex_lock(&edac_pci_ctls_mutex); 398 mutex_lock(&edac_pci_ctls_mutex);
399 399
@@ -430,7 +430,7 @@ EXPORT_SYMBOL_GPL(edac_pci_del_device);
430 */ 430 */
431static void edac_pci_generic_check(struct edac_pci_ctl_info *pci) 431static void edac_pci_generic_check(struct edac_pci_ctl_info *pci)
432{ 432{
433 debugf4("%s()\n", __func__); 433 edac_dbg(4, "\n");
434 edac_pci_do_parity_check(); 434 edac_pci_do_parity_check();
435} 435}
436 436
@@ -475,7 +475,7 @@ struct edac_pci_ctl_info *edac_pci_create_generic_ctl(struct device *dev,
475 pdata->edac_idx = edac_pci_idx++; 475 pdata->edac_idx = edac_pci_idx++;
476 476
477 if (edac_pci_add_device(pci, pdata->edac_idx) > 0) { 477 if (edac_pci_add_device(pci, pdata->edac_idx) > 0) {
478 debugf3("%s(): failed edac_pci_add_device()\n", __func__); 478 edac_dbg(3, "failed edac_pci_add_device()\n");
479 edac_pci_free_ctl_info(pci); 479 edac_pci_free_ctl_info(pci);
480 return NULL; 480 return NULL;
481 } 481 }
@@ -491,7 +491,7 @@ EXPORT_SYMBOL_GPL(edac_pci_create_generic_ctl);
491 */ 491 */
492void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci) 492void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci)
493{ 493{
494 debugf0("%s() pci mod=%s\n", __func__, pci->mod_name); 494 edac_dbg(0, "pci mod=%s\n", pci->mod_name);
495 495
496 edac_pci_del_device(pci->dev); 496 edac_pci_del_device(pci->dev);
497 edac_pci_free_ctl_info(pci); 497 edac_pci_free_ctl_info(pci);
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index 97f5064e3992..e164c555a337 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -78,7 +78,7 @@ static void edac_pci_instance_release(struct kobject *kobj)
78{ 78{
79 struct edac_pci_ctl_info *pci; 79 struct edac_pci_ctl_info *pci;
80 80
81 debugf0("%s()\n", __func__); 81 edac_dbg(0, "\n");
82 82
83 /* Form pointer to containing struct, the pci control struct */ 83 /* Form pointer to containing struct, the pci control struct */
84 pci = to_instance(kobj); 84 pci = to_instance(kobj);
@@ -161,7 +161,7 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
161 struct kobject *main_kobj; 161 struct kobject *main_kobj;
162 int err; 162 int err;
163 163
164 debugf0("%s()\n", __func__); 164 edac_dbg(0, "\n");
165 165
166 /* First bump the ref count on the top main kobj, which will 166 /* First bump the ref count on the top main kobj, which will
167 * track the number of PCI instances we have, and thus nest 167 * track the number of PCI instances we have, and thus nest
@@ -177,14 +177,13 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
177 err = kobject_init_and_add(&pci->kobj, &ktype_pci_instance, 177 err = kobject_init_and_add(&pci->kobj, &ktype_pci_instance,
178 edac_pci_top_main_kobj, "pci%d", idx); 178 edac_pci_top_main_kobj, "pci%d", idx);
179 if (err != 0) { 179 if (err != 0) {
180 debugf2("%s() failed to register instance pci%d\n", 180 edac_dbg(2, "failed to register instance pci%d\n", idx);
181 __func__, idx);
182 kobject_put(edac_pci_top_main_kobj); 181 kobject_put(edac_pci_top_main_kobj);
183 goto error_out; 182 goto error_out;
184 } 183 }
185 184
186 kobject_uevent(&pci->kobj, KOBJ_ADD); 185 kobject_uevent(&pci->kobj, KOBJ_ADD);
187 debugf1("%s() Register instance 'pci%d' kobject\n", __func__, idx); 186 edac_dbg(1, "Register instance 'pci%d' kobject\n", idx);
188 187
189 return 0; 188 return 0;
190 189
@@ -201,7 +200,7 @@ error_out:
201static void edac_pci_unregister_sysfs_instance_kobj( 200static void edac_pci_unregister_sysfs_instance_kobj(
202 struct edac_pci_ctl_info *pci) 201 struct edac_pci_ctl_info *pci)
203{ 202{
204 debugf0("%s()\n", __func__); 203 edac_dbg(0, "\n");
205 204
206 /* Unregister the instance kobject and allow its release 205 /* Unregister the instance kobject and allow its release
207 * function release the main reference count and then 206 * function release the main reference count and then
@@ -317,7 +316,7 @@ static struct edac_pci_dev_attribute *edac_pci_attr[] = {
317 */ 316 */
318static void edac_pci_release_main_kobj(struct kobject *kobj) 317static void edac_pci_release_main_kobj(struct kobject *kobj)
319{ 318{
320 debugf0("%s() here to module_put(THIS_MODULE)\n", __func__); 319 edac_dbg(0, "here to module_put(THIS_MODULE)\n");
321 320
322 kfree(kobj); 321 kfree(kobj);
323 322
@@ -345,7 +344,7 @@ static int edac_pci_main_kobj_setup(void)
345 int err; 344 int err;
346 struct bus_type *edac_subsys; 345 struct bus_type *edac_subsys;
347 346
348 debugf0("%s()\n", __func__); 347 edac_dbg(0, "\n");
349 348
350 /* check and count if we have already created the main kobject */ 349 /* check and count if we have already created the main kobject */
351 if (atomic_inc_return(&edac_pci_sysfs_refcount) != 1) 350 if (atomic_inc_return(&edac_pci_sysfs_refcount) != 1)
@@ -356,7 +355,7 @@ static int edac_pci_main_kobj_setup(void)
356 */ 355 */
357 edac_subsys = edac_get_sysfs_subsys(); 356 edac_subsys = edac_get_sysfs_subsys();
358 if (edac_subsys == NULL) { 357 if (edac_subsys == NULL) {
359 debugf1("%s() no edac_subsys\n", __func__); 358 edac_dbg(1, "no edac_subsys\n");
360 err = -ENODEV; 359 err = -ENODEV;
361 goto decrement_count_fail; 360 goto decrement_count_fail;
362 } 361 }
@@ -366,14 +365,14 @@ static int edac_pci_main_kobj_setup(void)
366 * level main kobj for EDAC PCI 365 * level main kobj for EDAC PCI
367 */ 366 */
368 if (!try_module_get(THIS_MODULE)) { 367 if (!try_module_get(THIS_MODULE)) {
369 debugf1("%s() try_module_get() failed\n", __func__); 368 edac_dbg(1, "try_module_get() failed\n");
370 err = -ENODEV; 369 err = -ENODEV;
371 goto mod_get_fail; 370 goto mod_get_fail;
372 } 371 }
373 372
374 edac_pci_top_main_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL); 373 edac_pci_top_main_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL);
375 if (!edac_pci_top_main_kobj) { 374 if (!edac_pci_top_main_kobj) {
376 debugf1("Failed to allocate\n"); 375 edac_dbg(1, "Failed to allocate\n");
377 err = -ENOMEM; 376 err = -ENOMEM;
378 goto kzalloc_fail; 377 goto kzalloc_fail;
379 } 378 }
@@ -383,7 +382,7 @@ static int edac_pci_main_kobj_setup(void)
383 &ktype_edac_pci_main_kobj, 382 &ktype_edac_pci_main_kobj,
384 &edac_subsys->dev_root->kobj, "pci"); 383 &edac_subsys->dev_root->kobj, "pci");
385 if (err) { 384 if (err) {
386 debugf1("Failed to register '.../edac/pci'\n"); 385 edac_dbg(1, "Failed to register '.../edac/pci'\n");
387 goto kobject_init_and_add_fail; 386 goto kobject_init_and_add_fail;
388 } 387 }
389 388
@@ -392,7 +391,7 @@ static int edac_pci_main_kobj_setup(void)
392 * must be used, for resources to be cleaned up properly 391 * must be used, for resources to be cleaned up properly
393 */ 392 */
394 kobject_uevent(edac_pci_top_main_kobj, KOBJ_ADD); 393 kobject_uevent(edac_pci_top_main_kobj, KOBJ_ADD);
395 debugf1("Registered '.../edac/pci' kobject\n"); 394 edac_dbg(1, "Registered '.../edac/pci' kobject\n");
396 395
397 return 0; 396 return 0;
398 397
@@ -421,15 +420,14 @@ decrement_count_fail:
421 */ 420 */
422static void edac_pci_main_kobj_teardown(void) 421static void edac_pci_main_kobj_teardown(void)
423{ 422{
424 debugf0("%s()\n", __func__); 423 edac_dbg(0, "\n");
425 424
426 /* Decrement the count and only if no more controller instances 425 /* Decrement the count and only if no more controller instances
427 * are connected perform the unregisteration of the top level 426 * are connected perform the unregisteration of the top level
428 * main kobj 427 * main kobj
429 */ 428 */
430 if (atomic_dec_return(&edac_pci_sysfs_refcount) == 0) { 429 if (atomic_dec_return(&edac_pci_sysfs_refcount) == 0) {
431 debugf0("%s() called kobject_put on main kobj\n", 430 edac_dbg(0, "called kobject_put on main kobj\n");
432 __func__);
433 kobject_put(edac_pci_top_main_kobj); 431 kobject_put(edac_pci_top_main_kobj);
434 } 432 }
435 edac_put_sysfs_subsys(); 433 edac_put_sysfs_subsys();
@@ -446,7 +444,7 @@ int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci)
446 int err; 444 int err;
447 struct kobject *edac_kobj = &pci->kobj; 445 struct kobject *edac_kobj = &pci->kobj;
448 446
449 debugf0("%s() idx=%d\n", __func__, pci->pci_idx); 447 edac_dbg(0, "idx=%d\n", pci->pci_idx);
450 448
451 /* create the top main EDAC PCI kobject, IF needed */ 449 /* create the top main EDAC PCI kobject, IF needed */
452 err = edac_pci_main_kobj_setup(); 450 err = edac_pci_main_kobj_setup();
@@ -460,8 +458,7 @@ int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci)
460 458
461 err = sysfs_create_link(edac_kobj, &pci->dev->kobj, EDAC_PCI_SYMLINK); 459 err = sysfs_create_link(edac_kobj, &pci->dev->kobj, EDAC_PCI_SYMLINK);
462 if (err) { 460 if (err) {
463 debugf0("%s() sysfs_create_link() returned err= %d\n", 461 edac_dbg(0, "sysfs_create_link() returned err= %d\n", err);
464 __func__, err);
465 goto symlink_fail; 462 goto symlink_fail;
466 } 463 }
467 464
@@ -484,7 +481,7 @@ unregister_cleanup:
484 */ 481 */
485void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci) 482void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci)
486{ 483{
487 debugf0("%s() index=%d\n", __func__, pci->pci_idx); 484 edac_dbg(0, "index=%d\n", pci->pci_idx);
488 485
489 /* Remove the symlink */ 486 /* Remove the symlink */
490 sysfs_remove_link(&pci->kobj, EDAC_PCI_SYMLINK); 487 sysfs_remove_link(&pci->kobj, EDAC_PCI_SYMLINK);
@@ -496,7 +493,7 @@ void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci)
496 * if this 'pci' is the last instance. 493 * if this 'pci' is the last instance.
497 * If it is, the main kobject will be unregistered as a result 494 * If it is, the main kobject will be unregistered as a result
498 */ 495 */
499 debugf0("%s() calling edac_pci_main_kobj_teardown()\n", __func__); 496 edac_dbg(0, "calling edac_pci_main_kobj_teardown()\n");
500 edac_pci_main_kobj_teardown(); 497 edac_pci_main_kobj_teardown();
501} 498}
502 499
@@ -572,7 +569,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
572 569
573 local_irq_restore(flags); 570 local_irq_restore(flags);
574 571
575 debugf4("PCI STATUS= 0x%04x %s\n", status, dev_name(&dev->dev)); 572 edac_dbg(4, "PCI STATUS= 0x%04x %s\n", status, dev_name(&dev->dev));
576 573
577 /* check the status reg for errors on boards NOT marked as broken 574 /* check the status reg for errors on boards NOT marked as broken
578 * if broken, we cannot trust any of the status bits 575 * if broken, we cannot trust any of the status bits
@@ -603,13 +600,15 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
603 } 600 }
604 601
605 602
606 debugf4("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev_name(&dev->dev)); 603 edac_dbg(4, "PCI HEADER TYPE= 0x%02x %s\n",
604 header_type, dev_name(&dev->dev));
607 605
608 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 606 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
609 /* On bridges, need to examine secondary status register */ 607 /* On bridges, need to examine secondary status register */
610 status = get_pci_parity_status(dev, 1); 608 status = get_pci_parity_status(dev, 1);
611 609
612 debugf4("PCI SEC_STATUS= 0x%04x %s\n", status, dev_name(&dev->dev)); 610 edac_dbg(4, "PCI SEC_STATUS= 0x%04x %s\n",
611 status, dev_name(&dev->dev));
613 612
614 /* check the secondary status reg for errors, 613 /* check the secondary status reg for errors,
615 * on NOT broken boards 614 * on NOT broken boards
@@ -671,7 +670,7 @@ void edac_pci_do_parity_check(void)
671{ 670{
672 int before_count; 671 int before_count;
673 672
674 debugf3("%s()\n", __func__); 673 edac_dbg(3, "\n");
675 674
676 /* if policy has PCI check off, leave now */ 675 /* if policy has PCI check off, leave now */
677 if (!check_pci_errors) 676 if (!check_pci_errors)
diff --git a/drivers/edac/highbank_l2_edac.c b/drivers/edac/highbank_l2_edac.c
new file mode 100644
index 000000000000..e599b00c05a8
--- /dev/null
+++ b/drivers/edac/highbank_l2_edac.c
@@ -0,0 +1,149 @@
1/*
2 * Copyright 2011-2012 Calxeda, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include <linux/types.h>
17#include <linux/kernel.h>
18#include <linux/ctype.h>
19#include <linux/edac.h>
20#include <linux/interrupt.h>
21#include <linux/platform_device.h>
22#include <linux/of_platform.h>
23
24#include "edac_core.h"
25#include "edac_module.h"
26
27#define SR_CLR_SB_ECC_INTR 0x0
28#define SR_CLR_DB_ECC_INTR 0x4
29
30struct hb_l2_drvdata {
31 void __iomem *base;
32 int sb_irq;
33 int db_irq;
34};
35
36static irqreturn_t highbank_l2_err_handler(int irq, void *dev_id)
37{
38 struct edac_device_ctl_info *dci = dev_id;
39 struct hb_l2_drvdata *drvdata = dci->pvt_info;
40
41 if (irq == drvdata->sb_irq) {
42 writel(1, drvdata->base + SR_CLR_SB_ECC_INTR);
43 edac_device_handle_ce(dci, 0, 0, dci->ctl_name);
44 }
45 if (irq == drvdata->db_irq) {
46 writel(1, drvdata->base + SR_CLR_DB_ECC_INTR);
47 edac_device_handle_ue(dci, 0, 0, dci->ctl_name);
48 }
49
50 return IRQ_HANDLED;
51}
52
53static int __devinit highbank_l2_err_probe(struct platform_device *pdev)
54{
55 struct edac_device_ctl_info *dci;
56 struct hb_l2_drvdata *drvdata;
57 struct resource *r;
58 int res = 0;
59
60 dci = edac_device_alloc_ctl_info(sizeof(*drvdata), "cpu",
61 1, "L", 1, 2, NULL, 0, 0);
62 if (!dci)
63 return -ENOMEM;
64
65 drvdata = dci->pvt_info;
66 dci->dev = &pdev->dev;
67 platform_set_drvdata(pdev, dci);
68
69 if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL))
70 return -ENOMEM;
71
72 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
73 if (!r) {
74 dev_err(&pdev->dev, "Unable to get mem resource\n");
75 res = -ENODEV;
76 goto err;
77 }
78
79 if (!devm_request_mem_region(&pdev->dev, r->start,
80 resource_size(r), dev_name(&pdev->dev))) {
81 dev_err(&pdev->dev, "Error while requesting mem region\n");
82 res = -EBUSY;
83 goto err;
84 }
85
86 drvdata->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
87 if (!drvdata->base) {
88 dev_err(&pdev->dev, "Unable to map regs\n");
89 res = -ENOMEM;
90 goto err;
91 }
92
93 drvdata->db_irq = platform_get_irq(pdev, 0);
94 res = devm_request_irq(&pdev->dev, drvdata->db_irq,
95 highbank_l2_err_handler,
96 0, dev_name(&pdev->dev), dci);
97 if (res < 0)
98 goto err;
99
100 drvdata->sb_irq = platform_get_irq(pdev, 1);
101 res = devm_request_irq(&pdev->dev, drvdata->sb_irq,
102 highbank_l2_err_handler,
103 0, dev_name(&pdev->dev), dci);
104 if (res < 0)
105 goto err;
106
107 dci->mod_name = dev_name(&pdev->dev);
108 dci->dev_name = dev_name(&pdev->dev);
109
110 if (edac_device_add_device(dci))
111 goto err;
112
113 devres_close_group(&pdev->dev, NULL);
114 return 0;
115err:
116 devres_release_group(&pdev->dev, NULL);
117 edac_device_free_ctl_info(dci);
118 return res;
119}
120
121static int highbank_l2_err_remove(struct platform_device *pdev)
122{
123 struct edac_device_ctl_info *dci = platform_get_drvdata(pdev);
124
125 edac_device_del_device(&pdev->dev);
126 edac_device_free_ctl_info(dci);
127 return 0;
128}
129
130static const struct of_device_id hb_l2_err_of_match[] = {
131 { .compatible = "calxeda,hb-sregs-l2-ecc", },
132 {},
133};
134MODULE_DEVICE_TABLE(of, hb_l2_err_of_match);
135
136static struct platform_driver highbank_l2_edac_driver = {
137 .probe = highbank_l2_err_probe,
138 .remove = highbank_l2_err_remove,
139 .driver = {
140 .name = "hb_l2_edac",
141 .of_match_table = hb_l2_err_of_match,
142 },
143};
144
145module_platform_driver(highbank_l2_edac_driver);
146
147MODULE_LICENSE("GPL v2");
148MODULE_AUTHOR("Calxeda, Inc.");
149MODULE_DESCRIPTION("EDAC Driver for Calxeda Highbank L2 Cache");
diff --git a/drivers/edac/highbank_mc_edac.c b/drivers/edac/highbank_mc_edac.c
new file mode 100644
index 000000000000..c769f477fd22
--- /dev/null
+++ b/drivers/edac/highbank_mc_edac.c
@@ -0,0 +1,264 @@
1/*
2 * Copyright 2011-2012 Calxeda, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include <linux/types.h>
17#include <linux/kernel.h>
18#include <linux/ctype.h>
19#include <linux/edac.h>
20#include <linux/interrupt.h>
21#include <linux/platform_device.h>
22#include <linux/of_platform.h>
23#include <linux/uaccess.h>
24
25#include "edac_core.h"
26#include "edac_module.h"
27
28/* DDR Ctrlr Error Registers */
29#define HB_DDR_ECC_OPT 0x128
30#define HB_DDR_ECC_U_ERR_ADDR 0x130
31#define HB_DDR_ECC_U_ERR_STAT 0x134
32#define HB_DDR_ECC_U_ERR_DATAL 0x138
33#define HB_DDR_ECC_U_ERR_DATAH 0x13c
34#define HB_DDR_ECC_C_ERR_ADDR 0x140
35#define HB_DDR_ECC_C_ERR_STAT 0x144
36#define HB_DDR_ECC_C_ERR_DATAL 0x148
37#define HB_DDR_ECC_C_ERR_DATAH 0x14c
38#define HB_DDR_ECC_INT_STATUS 0x180
39#define HB_DDR_ECC_INT_ACK 0x184
40#define HB_DDR_ECC_U_ERR_ID 0x424
41#define HB_DDR_ECC_C_ERR_ID 0x428
42
43#define HB_DDR_ECC_INT_STAT_CE 0x8
44#define HB_DDR_ECC_INT_STAT_DOUBLE_CE 0x10
45#define HB_DDR_ECC_INT_STAT_UE 0x20
46#define HB_DDR_ECC_INT_STAT_DOUBLE_UE 0x40
47
48#define HB_DDR_ECC_OPT_MODE_MASK 0x3
49#define HB_DDR_ECC_OPT_FWC 0x100
50#define HB_DDR_ECC_OPT_XOR_SHIFT 16
51
52struct hb_mc_drvdata {
53 void __iomem *mc_vbase;
54};
55
56static irqreturn_t highbank_mc_err_handler(int irq, void *dev_id)
57{
58 struct mem_ctl_info *mci = dev_id;
59 struct hb_mc_drvdata *drvdata = mci->pvt_info;
60 u32 status, err_addr;
61
62 /* Read the interrupt status register */
63 status = readl(drvdata->mc_vbase + HB_DDR_ECC_INT_STATUS);
64
65 if (status & HB_DDR_ECC_INT_STAT_UE) {
66 err_addr = readl(drvdata->mc_vbase + HB_DDR_ECC_U_ERR_ADDR);
67 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
68 err_addr >> PAGE_SHIFT,
69 err_addr & ~PAGE_MASK, 0,
70 0, 0, -1,
71 mci->ctl_name, "");
72 }
73 if (status & HB_DDR_ECC_INT_STAT_CE) {
74 u32 syndrome = readl(drvdata->mc_vbase + HB_DDR_ECC_C_ERR_STAT);
75 syndrome = (syndrome >> 8) & 0xff;
76 err_addr = readl(drvdata->mc_vbase + HB_DDR_ECC_C_ERR_ADDR);
77 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
78 err_addr >> PAGE_SHIFT,
79 err_addr & ~PAGE_MASK, syndrome,
80 0, 0, -1,
81 mci->ctl_name, "");
82 }
83
84 /* clear the error, clears the interrupt */
85 writel(status, drvdata->mc_vbase + HB_DDR_ECC_INT_ACK);
86 return IRQ_HANDLED;
87}
88
89#ifdef CONFIG_EDAC_DEBUG
90static ssize_t highbank_mc_err_inject_write(struct file *file,
91 const char __user *data,
92 size_t count, loff_t *ppos)
93{
94 struct mem_ctl_info *mci = file->private_data;
95 struct hb_mc_drvdata *pdata = mci->pvt_info;
96 char buf[32];
97 size_t buf_size;
98 u32 reg;
99 u8 synd;
100
101 buf_size = min(count, (sizeof(buf)-1));
102 if (copy_from_user(buf, data, buf_size))
103 return -EFAULT;
104 buf[buf_size] = 0;
105
106 if (!kstrtou8(buf, 16, &synd)) {
107 reg = readl(pdata->mc_vbase + HB_DDR_ECC_OPT);
108 reg &= HB_DDR_ECC_OPT_MODE_MASK;
109 reg |= (synd << HB_DDR_ECC_OPT_XOR_SHIFT) | HB_DDR_ECC_OPT_FWC;
110 writel(reg, pdata->mc_vbase + HB_DDR_ECC_OPT);
111 }
112
113 return count;
114}
115
116static int debugfs_open(struct inode *inode, struct file *file)
117{
118 file->private_data = inode->i_private;
119 return 0;
120}
121
122static const struct file_operations highbank_mc_debug_inject_fops = {
123 .open = debugfs_open,
124 .write = highbank_mc_err_inject_write,
125 .llseek = generic_file_llseek,
126};
127
128static void __devinit highbank_mc_create_debugfs_nodes(struct mem_ctl_info *mci)
129{
130 if (mci->debugfs)
131 debugfs_create_file("inject_ctrl", S_IWUSR, mci->debugfs, mci,
132 &highbank_mc_debug_inject_fops);
133;
134}
135#else
136static void __devinit highbank_mc_create_debugfs_nodes(struct mem_ctl_info *mci)
137{}
138#endif
139
140static int __devinit highbank_mc_probe(struct platform_device *pdev)
141{
142 struct edac_mc_layer layers[2];
143 struct mem_ctl_info *mci;
144 struct hb_mc_drvdata *drvdata;
145 struct dimm_info *dimm;
146 struct resource *r;
147 u32 control;
148 int irq;
149 int res = 0;
150
151 layers[0].type = EDAC_MC_LAYER_CHIP_SELECT;
152 layers[0].size = 1;
153 layers[0].is_virt_csrow = true;
154 layers[1].type = EDAC_MC_LAYER_CHANNEL;
155 layers[1].size = 1;
156 layers[1].is_virt_csrow = false;
157 mci = edac_mc_alloc(0, ARRAY_SIZE(layers), layers,
158 sizeof(struct hb_mc_drvdata));
159 if (!mci)
160 return -ENOMEM;
161
162 mci->pdev = &pdev->dev;
163 drvdata = mci->pvt_info;
164 platform_set_drvdata(pdev, mci);
165
166 if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL))
167 return -ENOMEM;
168
169 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
170 if (!r) {
171 dev_err(&pdev->dev, "Unable to get mem resource\n");
172 res = -ENODEV;
173 goto err;
174 }
175
176 if (!devm_request_mem_region(&pdev->dev, r->start,
177 resource_size(r), dev_name(&pdev->dev))) {
178 dev_err(&pdev->dev, "Error while requesting mem region\n");
179 res = -EBUSY;
180 goto err;
181 }
182
183 drvdata->mc_vbase = devm_ioremap(&pdev->dev,
184 r->start, resource_size(r));
185 if (!drvdata->mc_vbase) {
186 dev_err(&pdev->dev, "Unable to map regs\n");
187 res = -ENOMEM;
188 goto err;
189 }
190
191 control = readl(drvdata->mc_vbase + HB_DDR_ECC_OPT) & 0x3;
192 if (!control || (control == 0x2)) {
193 dev_err(&pdev->dev, "No ECC present, or ECC disabled\n");
194 res = -ENODEV;
195 goto err;
196 }
197
198 irq = platform_get_irq(pdev, 0);
199 res = devm_request_irq(&pdev->dev, irq, highbank_mc_err_handler,
200 0, dev_name(&pdev->dev), mci);
201 if (res < 0) {
202 dev_err(&pdev->dev, "Unable to request irq %d\n", irq);
203 goto err;
204 }
205
206 mci->mtype_cap = MEM_FLAG_DDR3;
207 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
208 mci->edac_cap = EDAC_FLAG_SECDED;
209 mci->mod_name = dev_name(&pdev->dev);
210 mci->mod_ver = "1";
211 mci->ctl_name = dev_name(&pdev->dev);
212 mci->scrub_mode = SCRUB_SW_SRC;
213
214 /* Only a single 4GB DIMM is supported */
215 dimm = *mci->dimms;
216 dimm->nr_pages = (~0UL >> PAGE_SHIFT) + 1;
217 dimm->grain = 8;
218 dimm->dtype = DEV_X8;
219 dimm->mtype = MEM_DDR3;
220 dimm->edac_mode = EDAC_SECDED;
221
222 res = edac_mc_add_mc(mci);
223 if (res < 0)
224 goto err;
225
226 highbank_mc_create_debugfs_nodes(mci);
227
228 devres_close_group(&pdev->dev, NULL);
229 return 0;
230err:
231 devres_release_group(&pdev->dev, NULL);
232 edac_mc_free(mci);
233 return res;
234}
235
236static int highbank_mc_remove(struct platform_device *pdev)
237{
238 struct mem_ctl_info *mci = platform_get_drvdata(pdev);
239
240 edac_mc_del_mc(&pdev->dev);
241 edac_mc_free(mci);
242 return 0;
243}
244
245static const struct of_device_id hb_ddr_ctrl_of_match[] = {
246 { .compatible = "calxeda,hb-ddr-ctrl", },
247 {},
248};
249MODULE_DEVICE_TABLE(of, hb_ddr_ctrl_of_match);
250
251static struct platform_driver highbank_mc_edac_driver = {
252 .probe = highbank_mc_probe,
253 .remove = highbank_mc_remove,
254 .driver = {
255 .name = "hb_mc_edac",
256 .of_match_table = hb_ddr_ctrl_of_match,
257 },
258};
259
260module_platform_driver(highbank_mc_edac_driver);
261
262MODULE_LICENSE("GPL v2");
263MODULE_AUTHOR("Calxeda, Inc.");
264MODULE_DESCRIPTION("EDAC Driver for Calxeda Highbank");
diff --git a/drivers/edac/i3000_edac.c b/drivers/edac/i3000_edac.c
index 8ad1744faacd..d3d19cc4e9a1 100644
--- a/drivers/edac/i3000_edac.c
+++ b/drivers/edac/i3000_edac.c
@@ -194,7 +194,7 @@ static void i3000_get_error_info(struct mem_ctl_info *mci,
194{ 194{
195 struct pci_dev *pdev; 195 struct pci_dev *pdev;
196 196
197 pdev = to_pci_dev(mci->dev); 197 pdev = to_pci_dev(mci->pdev);
198 198
199 /* 199 /*
200 * This is a mess because there is no atomic way to read all the 200 * This is a mess because there is no atomic way to read all the
@@ -236,7 +236,7 @@ static int i3000_process_error_info(struct mem_ctl_info *mci,
236 int row, multi_chan, channel; 236 int row, multi_chan, channel;
237 unsigned long pfn, offset; 237 unsigned long pfn, offset;
238 238
239 multi_chan = mci->csrows[0].nr_channels - 1; 239 multi_chan = mci->csrows[0]->nr_channels - 1;
240 240
241 if (!(info->errsts & I3000_ERRSTS_BITS)) 241 if (!(info->errsts & I3000_ERRSTS_BITS))
242 return 0; 242 return 0;
@@ -245,9 +245,9 @@ static int i3000_process_error_info(struct mem_ctl_info *mci,
245 return 1; 245 return 1;
246 246
247 if ((info->errsts ^ info->errsts2) & I3000_ERRSTS_BITS) { 247 if ((info->errsts ^ info->errsts2) & I3000_ERRSTS_BITS) {
248 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 0, 0, 0, 248 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0,
249 -1, -1, -1, 249 -1, -1, -1,
250 "UE overwrote CE", "", NULL); 250 "UE overwrote CE", "");
251 info->errsts = info->errsts2; 251 info->errsts = info->errsts2;
252 } 252 }
253 253
@@ -258,15 +258,15 @@ static int i3000_process_error_info(struct mem_ctl_info *mci,
258 row = edac_mc_find_csrow_by_page(mci, pfn); 258 row = edac_mc_find_csrow_by_page(mci, pfn);
259 259
260 if (info->errsts & I3000_ERRSTS_UE) 260 if (info->errsts & I3000_ERRSTS_UE)
261 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 261 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
262 pfn, offset, 0, 262 pfn, offset, 0,
263 row, -1, -1, 263 row, -1, -1,
264 "i3000 UE", "", NULL); 264 "i3000 UE", "");
265 else 265 else
266 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 266 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
267 pfn, offset, info->derrsyn, 267 pfn, offset, info->derrsyn,
268 row, multi_chan ? channel : 0, -1, 268 row, multi_chan ? channel : 0, -1,
269 "i3000 CE", "", NULL); 269 "i3000 CE", "");
270 270
271 return 1; 271 return 1;
272} 272}
@@ -275,7 +275,7 @@ static void i3000_check(struct mem_ctl_info *mci)
275{ 275{
276 struct i3000_error_info info; 276 struct i3000_error_info info;
277 277
278 debugf1("MC%d: %s()\n", mci->mc_idx, __func__); 278 edac_dbg(1, "MC%d\n", mci->mc_idx);
279 i3000_get_error_info(mci, &info); 279 i3000_get_error_info(mci, &info);
280 i3000_process_error_info(mci, &info, 1); 280 i3000_process_error_info(mci, &info, 1);
281} 281}
@@ -322,7 +322,7 @@ static int i3000_probe1(struct pci_dev *pdev, int dev_idx)
322 unsigned long mchbar; 322 unsigned long mchbar;
323 void __iomem *window; 323 void __iomem *window;
324 324
325 debugf0("MC: %s()\n", __func__); 325 edac_dbg(0, "MC:\n");
326 326
327 pci_read_config_dword(pdev, I3000_MCHBAR, (u32 *) & mchbar); 327 pci_read_config_dword(pdev, I3000_MCHBAR, (u32 *) & mchbar);
328 mchbar &= I3000_MCHBAR_MASK; 328 mchbar &= I3000_MCHBAR_MASK;
@@ -366,9 +366,9 @@ static int i3000_probe1(struct pci_dev *pdev, int dev_idx)
366 if (!mci) 366 if (!mci)
367 return -ENOMEM; 367 return -ENOMEM;
368 368
369 debugf3("MC: %s(): init mci\n", __func__); 369 edac_dbg(3, "MC: init mci\n");
370 370
371 mci->dev = &pdev->dev; 371 mci->pdev = &pdev->dev;
372 mci->mtype_cap = MEM_FLAG_DDR2; 372 mci->mtype_cap = MEM_FLAG_DDR2;
373 373
374 mci->edac_ctl_cap = EDAC_FLAG_SECDED; 374 mci->edac_ctl_cap = EDAC_FLAG_SECDED;
@@ -393,14 +393,13 @@ static int i3000_probe1(struct pci_dev *pdev, int dev_idx)
393 for (last_cumul_size = i = 0; i < mci->nr_csrows; i++) { 393 for (last_cumul_size = i = 0; i < mci->nr_csrows; i++) {
394 u8 value; 394 u8 value;
395 u32 cumul_size; 395 u32 cumul_size;
396 struct csrow_info *csrow = &mci->csrows[i]; 396 struct csrow_info *csrow = mci->csrows[i];
397 397
398 value = drb[i]; 398 value = drb[i];
399 cumul_size = value << (I3000_DRB_SHIFT - PAGE_SHIFT); 399 cumul_size = value << (I3000_DRB_SHIFT - PAGE_SHIFT);
400 if (interleaved) 400 if (interleaved)
401 cumul_size <<= 1; 401 cumul_size <<= 1;
402 debugf3("MC: %s(): (%d) cumul_size 0x%x\n", 402 edac_dbg(3, "MC: (%d) cumul_size 0x%x\n", i, cumul_size);
403 __func__, i, cumul_size);
404 if (cumul_size == last_cumul_size) 403 if (cumul_size == last_cumul_size)
405 continue; 404 continue;
406 405
@@ -410,7 +409,7 @@ static int i3000_probe1(struct pci_dev *pdev, int dev_idx)
410 last_cumul_size = cumul_size; 409 last_cumul_size = cumul_size;
411 410
412 for (j = 0; j < nr_channels; j++) { 411 for (j = 0; j < nr_channels; j++) {
413 struct dimm_info *dimm = csrow->channels[j].dimm; 412 struct dimm_info *dimm = csrow->channels[j]->dimm;
414 413
415 dimm->nr_pages = nr_pages / nr_channels; 414 dimm->nr_pages = nr_pages / nr_channels;
416 dimm->grain = I3000_DEAP_GRAIN; 415 dimm->grain = I3000_DEAP_GRAIN;
@@ -429,7 +428,7 @@ static int i3000_probe1(struct pci_dev *pdev, int dev_idx)
429 428
430 rc = -ENODEV; 429 rc = -ENODEV;
431 if (edac_mc_add_mc(mci)) { 430 if (edac_mc_add_mc(mci)) {
432 debugf3("MC: %s(): failed edac_mc_add_mc()\n", __func__); 431 edac_dbg(3, "MC: failed edac_mc_add_mc()\n");
433 goto fail; 432 goto fail;
434 } 433 }
435 434
@@ -445,7 +444,7 @@ static int i3000_probe1(struct pci_dev *pdev, int dev_idx)
445 } 444 }
446 445
447 /* get this far and it's successful */ 446 /* get this far and it's successful */
448 debugf3("MC: %s(): success\n", __func__); 447 edac_dbg(3, "MC: success\n");
449 return 0; 448 return 0;
450 449
451fail: 450fail:
@@ -461,7 +460,7 @@ static int __devinit i3000_init_one(struct pci_dev *pdev,
461{ 460{
462 int rc; 461 int rc;
463 462
464 debugf0("MC: %s()\n", __func__); 463 edac_dbg(0, "MC:\n");
465 464
466 if (pci_enable_device(pdev) < 0) 465 if (pci_enable_device(pdev) < 0)
467 return -EIO; 466 return -EIO;
@@ -477,7 +476,7 @@ static void __devexit i3000_remove_one(struct pci_dev *pdev)
477{ 476{
478 struct mem_ctl_info *mci; 477 struct mem_ctl_info *mci;
479 478
480 debugf0("%s()\n", __func__); 479 edac_dbg(0, "\n");
481 480
482 if (i3000_pci) 481 if (i3000_pci)
483 edac_pci_release_generic_ctl(i3000_pci); 482 edac_pci_release_generic_ctl(i3000_pci);
@@ -511,7 +510,7 @@ static int __init i3000_init(void)
511{ 510{
512 int pci_rc; 511 int pci_rc;
513 512
514 debugf3("MC: %s()\n", __func__); 513 edac_dbg(3, "MC:\n");
515 514
516 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 515 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
517 opstate_init(); 516 opstate_init();
@@ -525,14 +524,14 @@ static int __init i3000_init(void)
525 mci_pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 524 mci_pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
526 PCI_DEVICE_ID_INTEL_3000_HB, NULL); 525 PCI_DEVICE_ID_INTEL_3000_HB, NULL);
527 if (!mci_pdev) { 526 if (!mci_pdev) {
528 debugf0("i3000 pci_get_device fail\n"); 527 edac_dbg(0, "i3000 pci_get_device fail\n");
529 pci_rc = -ENODEV; 528 pci_rc = -ENODEV;
530 goto fail1; 529 goto fail1;
531 } 530 }
532 531
533 pci_rc = i3000_init_one(mci_pdev, i3000_pci_tbl); 532 pci_rc = i3000_init_one(mci_pdev, i3000_pci_tbl);
534 if (pci_rc < 0) { 533 if (pci_rc < 0) {
535 debugf0("i3000 init fail\n"); 534 edac_dbg(0, "i3000 init fail\n");
536 pci_rc = -ENODEV; 535 pci_rc = -ENODEV;
537 goto fail1; 536 goto fail1;
538 } 537 }
@@ -552,7 +551,7 @@ fail0:
552 551
553static void __exit i3000_exit(void) 552static void __exit i3000_exit(void)
554{ 553{
555 debugf3("MC: %s()\n", __func__); 554 edac_dbg(3, "MC:\n");
556 555
557 pci_unregister_driver(&i3000_driver); 556 pci_unregister_driver(&i3000_driver);
558 if (!i3000_registered) { 557 if (!i3000_registered) {
diff --git a/drivers/edac/i3200_edac.c b/drivers/edac/i3200_edac.c
index bbe43ef71823..47180a08edad 100644
--- a/drivers/edac/i3200_edac.c
+++ b/drivers/edac/i3200_edac.c
@@ -110,10 +110,10 @@ static int how_many_channels(struct pci_dev *pdev)
110 110
111 pci_read_config_byte(pdev, I3200_CAPID0 + 8, &capid0_8b); 111 pci_read_config_byte(pdev, I3200_CAPID0 + 8, &capid0_8b);
112 if (capid0_8b & 0x20) { /* check DCD: Dual Channel Disable */ 112 if (capid0_8b & 0x20) { /* check DCD: Dual Channel Disable */
113 debugf0("In single channel mode.\n"); 113 edac_dbg(0, "In single channel mode\n");
114 return 1; 114 return 1;
115 } else { 115 } else {
116 debugf0("In dual channel mode.\n"); 116 edac_dbg(0, "In dual channel mode\n");
117 return 2; 117 return 2;
118 } 118 }
119} 119}
@@ -159,7 +159,7 @@ static void i3200_clear_error_info(struct mem_ctl_info *mci)
159{ 159{
160 struct pci_dev *pdev; 160 struct pci_dev *pdev;
161 161
162 pdev = to_pci_dev(mci->dev); 162 pdev = to_pci_dev(mci->pdev);
163 163
164 /* 164 /*
165 * Clear any error bits. 165 * Clear any error bits.
@@ -176,7 +176,7 @@ static void i3200_get_and_clear_error_info(struct mem_ctl_info *mci,
176 struct i3200_priv *priv = mci->pvt_info; 176 struct i3200_priv *priv = mci->pvt_info;
177 void __iomem *window = priv->window; 177 void __iomem *window = priv->window;
178 178
179 pdev = to_pci_dev(mci->dev); 179 pdev = to_pci_dev(mci->pdev);
180 180
181 /* 181 /*
182 * This is a mess because there is no atomic way to read all the 182 * This is a mess because there is no atomic way to read all the
@@ -218,25 +218,25 @@ static void i3200_process_error_info(struct mem_ctl_info *mci,
218 return; 218 return;
219 219
220 if ((info->errsts ^ info->errsts2) & I3200_ERRSTS_BITS) { 220 if ((info->errsts ^ info->errsts2) & I3200_ERRSTS_BITS) {
221 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 0, 0, 0, 221 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0,
222 -1, -1, -1, "UE overwrote CE", "", NULL); 222 -1, -1, -1, "UE overwrote CE", "");
223 info->errsts = info->errsts2; 223 info->errsts = info->errsts2;
224 } 224 }
225 225
226 for (channel = 0; channel < nr_channels; channel++) { 226 for (channel = 0; channel < nr_channels; channel++) {
227 log = info->eccerrlog[channel]; 227 log = info->eccerrlog[channel];
228 if (log & I3200_ECCERRLOG_UE) { 228 if (log & I3200_ECCERRLOG_UE) {
229 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 229 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
230 0, 0, 0, 230 0, 0, 0,
231 eccerrlog_row(channel, log), 231 eccerrlog_row(channel, log),
232 -1, -1, 232 -1, -1,
233 "i3000 UE", "", NULL); 233 "i3000 UE", "");
234 } else if (log & I3200_ECCERRLOG_CE) { 234 } else if (log & I3200_ECCERRLOG_CE) {
235 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 235 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
236 0, 0, eccerrlog_syndrome(log), 236 0, 0, eccerrlog_syndrome(log),
237 eccerrlog_row(channel, log), 237 eccerrlog_row(channel, log),
238 -1, -1, 238 -1, -1,
239 "i3000 UE", "", NULL); 239 "i3000 UE", "");
240 } 240 }
241 } 241 }
242} 242}
@@ -245,7 +245,7 @@ static void i3200_check(struct mem_ctl_info *mci)
245{ 245{
246 struct i3200_error_info info; 246 struct i3200_error_info info;
247 247
248 debugf1("MC%d: %s()\n", mci->mc_idx, __func__); 248 edac_dbg(1, "MC%d\n", mci->mc_idx);
249 i3200_get_and_clear_error_info(mci, &info); 249 i3200_get_and_clear_error_info(mci, &info);
250 i3200_process_error_info(mci, &info); 250 i3200_process_error_info(mci, &info);
251} 251}
@@ -332,7 +332,7 @@ static int i3200_probe1(struct pci_dev *pdev, int dev_idx)
332 void __iomem *window; 332 void __iomem *window;
333 struct i3200_priv *priv; 333 struct i3200_priv *priv;
334 334
335 debugf0("MC: %s()\n", __func__); 335 edac_dbg(0, "MC:\n");
336 336
337 window = i3200_map_mchbar(pdev); 337 window = i3200_map_mchbar(pdev);
338 if (!window) 338 if (!window)
@@ -352,9 +352,9 @@ static int i3200_probe1(struct pci_dev *pdev, int dev_idx)
352 if (!mci) 352 if (!mci)
353 return -ENOMEM; 353 return -ENOMEM;
354 354
355 debugf3("MC: %s(): init mci\n", __func__); 355 edac_dbg(3, "MC: init mci\n");
356 356
357 mci->dev = &pdev->dev; 357 mci->pdev = &pdev->dev;
358 mci->mtype_cap = MEM_FLAG_DDR2; 358 mci->mtype_cap = MEM_FLAG_DDR2;
359 359
360 mci->edac_ctl_cap = EDAC_FLAG_SECDED; 360 mci->edac_ctl_cap = EDAC_FLAG_SECDED;
@@ -379,7 +379,7 @@ static int i3200_probe1(struct pci_dev *pdev, int dev_idx)
379 */ 379 */
380 for (i = 0; i < mci->nr_csrows; i++) { 380 for (i = 0; i < mci->nr_csrows; i++) {
381 unsigned long nr_pages; 381 unsigned long nr_pages;
382 struct csrow_info *csrow = &mci->csrows[i]; 382 struct csrow_info *csrow = mci->csrows[i];
383 383
384 nr_pages = drb_to_nr_pages(drbs, stacked, 384 nr_pages = drb_to_nr_pages(drbs, stacked,
385 i / I3200_RANKS_PER_CHANNEL, 385 i / I3200_RANKS_PER_CHANNEL,
@@ -389,7 +389,7 @@ static int i3200_probe1(struct pci_dev *pdev, int dev_idx)
389 continue; 389 continue;
390 390
391 for (j = 0; j < nr_channels; j++) { 391 for (j = 0; j < nr_channels; j++) {
392 struct dimm_info *dimm = csrow->channels[j].dimm; 392 struct dimm_info *dimm = csrow->channels[j]->dimm;
393 393
394 dimm->nr_pages = nr_pages / nr_channels; 394 dimm->nr_pages = nr_pages / nr_channels;
395 dimm->grain = nr_pages << PAGE_SHIFT; 395 dimm->grain = nr_pages << PAGE_SHIFT;
@@ -403,12 +403,12 @@ static int i3200_probe1(struct pci_dev *pdev, int dev_idx)
403 403
404 rc = -ENODEV; 404 rc = -ENODEV;
405 if (edac_mc_add_mc(mci)) { 405 if (edac_mc_add_mc(mci)) {
406 debugf3("MC: %s(): failed edac_mc_add_mc()\n", __func__); 406 edac_dbg(3, "MC: failed edac_mc_add_mc()\n");
407 goto fail; 407 goto fail;
408 } 408 }
409 409
410 /* get this far and it's successful */ 410 /* get this far and it's successful */
411 debugf3("MC: %s(): success\n", __func__); 411 edac_dbg(3, "MC: success\n");
412 return 0; 412 return 0;
413 413
414fail: 414fail:
@@ -424,7 +424,7 @@ static int __devinit i3200_init_one(struct pci_dev *pdev,
424{ 424{
425 int rc; 425 int rc;
426 426
427 debugf0("MC: %s()\n", __func__); 427 edac_dbg(0, "MC:\n");
428 428
429 if (pci_enable_device(pdev) < 0) 429 if (pci_enable_device(pdev) < 0)
430 return -EIO; 430 return -EIO;
@@ -441,7 +441,7 @@ static void __devexit i3200_remove_one(struct pci_dev *pdev)
441 struct mem_ctl_info *mci; 441 struct mem_ctl_info *mci;
442 struct i3200_priv *priv; 442 struct i3200_priv *priv;
443 443
444 debugf0("%s()\n", __func__); 444 edac_dbg(0, "\n");
445 445
446 mci = edac_mc_del_mc(&pdev->dev); 446 mci = edac_mc_del_mc(&pdev->dev);
447 if (!mci) 447 if (!mci)
@@ -475,7 +475,7 @@ static int __init i3200_init(void)
475{ 475{
476 int pci_rc; 476 int pci_rc;
477 477
478 debugf3("MC: %s()\n", __func__); 478 edac_dbg(3, "MC:\n");
479 479
480 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 480 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
481 opstate_init(); 481 opstate_init();
@@ -489,14 +489,14 @@ static int __init i3200_init(void)
489 mci_pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 489 mci_pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
490 PCI_DEVICE_ID_INTEL_3200_HB, NULL); 490 PCI_DEVICE_ID_INTEL_3200_HB, NULL);
491 if (!mci_pdev) { 491 if (!mci_pdev) {
492 debugf0("i3200 pci_get_device fail\n"); 492 edac_dbg(0, "i3200 pci_get_device fail\n");
493 pci_rc = -ENODEV; 493 pci_rc = -ENODEV;
494 goto fail1; 494 goto fail1;
495 } 495 }
496 496
497 pci_rc = i3200_init_one(mci_pdev, i3200_pci_tbl); 497 pci_rc = i3200_init_one(mci_pdev, i3200_pci_tbl);
498 if (pci_rc < 0) { 498 if (pci_rc < 0) {
499 debugf0("i3200 init fail\n"); 499 edac_dbg(0, "i3200 init fail\n");
500 pci_rc = -ENODEV; 500 pci_rc = -ENODEV;
501 goto fail1; 501 goto fail1;
502 } 502 }
@@ -516,7 +516,7 @@ fail0:
516 516
517static void __exit i3200_exit(void) 517static void __exit i3200_exit(void)
518{ 518{
519 debugf3("MC: %s()\n", __func__); 519 edac_dbg(3, "MC:\n");
520 520
521 pci_unregister_driver(&i3200_driver); 521 pci_unregister_driver(&i3200_driver);
522 if (!i3200_registered) { 522 if (!i3200_registered) {
diff --git a/drivers/edac/i5000_edac.c b/drivers/edac/i5000_edac.c
index 11ea835f155a..39c63757c2a1 100644
--- a/drivers/edac/i5000_edac.c
+++ b/drivers/edac/i5000_edac.c
@@ -273,7 +273,7 @@
273#define CHANNELS_PER_BRANCH 2 273#define CHANNELS_PER_BRANCH 2
274#define MAX_BRANCHES 2 274#define MAX_BRANCHES 2
275 275
276/* Defines to extract the vaious fields from the 276/* Defines to extract the various fields from the
277 * MTRx - Memory Technology Registers 277 * MTRx - Memory Technology Registers
278 */ 278 */
279#define MTR_DIMMS_PRESENT(mtr) ((mtr) & (0x1 << 8)) 279#define MTR_DIMMS_PRESENT(mtr) ((mtr) & (0x1 << 8))
@@ -287,22 +287,6 @@
287#define MTR_DIMM_COLS(mtr) ((mtr) & 0x3) 287#define MTR_DIMM_COLS(mtr) ((mtr) & 0x3)
288#define MTR_DIMM_COLS_ADDR_BITS(mtr) (MTR_DIMM_COLS(mtr) + 10) 288#define MTR_DIMM_COLS_ADDR_BITS(mtr) (MTR_DIMM_COLS(mtr) + 10)
289 289
290#ifdef CONFIG_EDAC_DEBUG
291static char *numrow_toString[] = {
292 "8,192 - 13 rows",
293 "16,384 - 14 rows",
294 "32,768 - 15 rows",
295 "reserved"
296};
297
298static char *numcol_toString[] = {
299 "1,024 - 10 columns",
300 "2,048 - 11 columns",
301 "4,096 - 12 columns",
302 "reserved"
303};
304#endif
305
306/* enables the report of miscellaneous messages as CE errors - default off */ 290/* enables the report of miscellaneous messages as CE errors - default off */
307static int misc_messages; 291static int misc_messages;
308 292
@@ -344,7 +328,13 @@ struct i5000_pvt {
344 struct pci_dev *branch_1; /* 22.0 */ 328 struct pci_dev *branch_1; /* 22.0 */
345 329
346 u16 tolm; /* top of low memory */ 330 u16 tolm; /* top of low memory */
347 u64 ambase; /* AMB BAR */ 331 union {
332 u64 ambase; /* AMB BAR */
333 struct {
334 u32 ambase_bottom;
335 u32 ambase_top;
336 } u __packed;
337 };
348 338
349 u16 mir0, mir1, mir2; 339 u16 mir0, mir1, mir2;
350 340
@@ -494,10 +484,9 @@ static void i5000_process_fatal_error_info(struct mem_ctl_info *mci,
494 ras = NREC_RAS(info->nrecmemb); 484 ras = NREC_RAS(info->nrecmemb);
495 cas = NREC_CAS(info->nrecmemb); 485 cas = NREC_CAS(info->nrecmemb);
496 486
497 debugf0("\t\tCSROW= %d Channel= %d " 487 edac_dbg(0, "\t\tCSROW= %d Channel= %d (DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n",
498 "(DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n", 488 rank, channel, bank,
499 rank, channel, bank, 489 rdwr ? "Write" : "Read", ras, cas);
500 rdwr ? "Write" : "Read", ras, cas);
501 490
502 /* Only 1 bit will be on */ 491 /* Only 1 bit will be on */
503 switch (allErrors) { 492 switch (allErrors) {
@@ -536,10 +525,10 @@ static void i5000_process_fatal_error_info(struct mem_ctl_info *mci,
536 bank, ras, cas, allErrors, specific); 525 bank, ras, cas, allErrors, specific);
537 526
538 /* Call the helper to output message */ 527 /* Call the helper to output message */
539 edac_mc_handle_error(HW_EVENT_ERR_FATAL, mci, 0, 0, 0, 528 edac_mc_handle_error(HW_EVENT_ERR_FATAL, mci, 1, 0, 0, 0,
540 channel >> 1, channel & 1, rank, 529 channel >> 1, channel & 1, rank,
541 rdwr ? "Write error" : "Read error", 530 rdwr ? "Write error" : "Read error",
542 msg, NULL); 531 msg);
543} 532}
544 533
545/* 534/*
@@ -574,7 +563,7 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci,
574 /* ONLY ONE of the possible error bits will be set, as per the docs */ 563 /* ONLY ONE of the possible error bits will be set, as per the docs */
575 ue_errors = allErrors & FERR_NF_UNCORRECTABLE; 564 ue_errors = allErrors & FERR_NF_UNCORRECTABLE;
576 if (ue_errors) { 565 if (ue_errors) {
577 debugf0("\tUncorrected bits= 0x%x\n", ue_errors); 566 edac_dbg(0, "\tUncorrected bits= 0x%x\n", ue_errors);
578 567
579 branch = EXTRACT_FBDCHAN_INDX(info->ferr_nf_fbd); 568 branch = EXTRACT_FBDCHAN_INDX(info->ferr_nf_fbd);
580 569
@@ -590,11 +579,9 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci,
590 ras = NREC_RAS(info->nrecmemb); 579 ras = NREC_RAS(info->nrecmemb);
591 cas = NREC_CAS(info->nrecmemb); 580 cas = NREC_CAS(info->nrecmemb);
592 581
593 debugf0 582 edac_dbg(0, "\t\tCSROW= %d Channels= %d,%d (Branch= %d DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n",
594 ("\t\tCSROW= %d Channels= %d,%d (Branch= %d " 583 rank, channel, channel + 1, branch >> 1, bank,
595 "DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n", 584 rdwr ? "Write" : "Read", ras, cas);
596 rank, channel, channel + 1, branch >> 1, bank,
597 rdwr ? "Write" : "Read", ras, cas);
598 585
599 switch (ue_errors) { 586 switch (ue_errors) {
600 case FERR_NF_M12ERR: 587 case FERR_NF_M12ERR:
@@ -637,16 +624,16 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci,
637 rank, bank, ras, cas, ue_errors, specific); 624 rank, bank, ras, cas, ue_errors, specific);
638 625
639 /* Call the helper to output message */ 626 /* Call the helper to output message */
640 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 0, 0, 0, 627 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0,
641 channel >> 1, -1, rank, 628 channel >> 1, -1, rank,
642 rdwr ? "Write error" : "Read error", 629 rdwr ? "Write error" : "Read error",
643 msg, NULL); 630 msg);
644 } 631 }
645 632
646 /* Check correctable errors */ 633 /* Check correctable errors */
647 ce_errors = allErrors & FERR_NF_CORRECTABLE; 634 ce_errors = allErrors & FERR_NF_CORRECTABLE;
648 if (ce_errors) { 635 if (ce_errors) {
649 debugf0("\tCorrected bits= 0x%x\n", ce_errors); 636 edac_dbg(0, "\tCorrected bits= 0x%x\n", ce_errors);
650 637
651 branch = EXTRACT_FBDCHAN_INDX(info->ferr_nf_fbd); 638 branch = EXTRACT_FBDCHAN_INDX(info->ferr_nf_fbd);
652 639
@@ -664,10 +651,9 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci,
664 ras = REC_RAS(info->recmemb); 651 ras = REC_RAS(info->recmemb);
665 cas = REC_CAS(info->recmemb); 652 cas = REC_CAS(info->recmemb);
666 653
667 debugf0("\t\tCSROW= %d Channel= %d (Branch %d " 654 edac_dbg(0, "\t\tCSROW= %d Channel= %d (Branch %d DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n",
668 "DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n", 655 rank, channel, branch >> 1, bank,
669 rank, channel, branch >> 1, bank, 656 rdwr ? "Write" : "Read", ras, cas);
670 rdwr ? "Write" : "Read", ras, cas);
671 657
672 switch (ce_errors) { 658 switch (ce_errors) {
673 case FERR_NF_M17ERR: 659 case FERR_NF_M17ERR:
@@ -692,10 +678,10 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci,
692 specific); 678 specific);
693 679
694 /* Call the helper to output message */ 680 /* Call the helper to output message */
695 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 0, 0, 0, 681 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, 0, 0, 0,
696 channel >> 1, channel % 2, rank, 682 channel >> 1, channel % 2, rank,
697 rdwr ? "Write error" : "Read error", 683 rdwr ? "Write error" : "Read error",
698 msg, NULL); 684 msg);
699 } 685 }
700 686
701 if (!misc_messages) 687 if (!misc_messages)
@@ -738,9 +724,9 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci,
738 "Err=%#x (%s)", misc_errors, specific); 724 "Err=%#x (%s)", misc_errors, specific);
739 725
740 /* Call the helper to output message */ 726 /* Call the helper to output message */
741 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 0, 0, 0, 727 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, 0, 0, 0,
742 branch >> 1, -1, -1, 728 branch >> 1, -1, -1,
743 "Misc error", msg, NULL); 729 "Misc error", msg);
744 } 730 }
745} 731}
746 732
@@ -779,7 +765,7 @@ static void i5000_clear_error(struct mem_ctl_info *mci)
779static void i5000_check_error(struct mem_ctl_info *mci) 765static void i5000_check_error(struct mem_ctl_info *mci)
780{ 766{
781 struct i5000_error_info info; 767 struct i5000_error_info info;
782 debugf4("MC%d: %s: %s()\n", mci->mc_idx, __FILE__, __func__); 768 edac_dbg(4, "MC%d\n", mci->mc_idx);
783 i5000_get_error_info(mci, &info); 769 i5000_get_error_info(mci, &info);
784 i5000_process_error_info(mci, &info, 1); 770 i5000_process_error_info(mci, &info, 1);
785} 771}
@@ -850,15 +836,16 @@ static int i5000_get_devices(struct mem_ctl_info *mci, int dev_idx)
850 836
851 pvt->fsb_error_regs = pdev; 837 pvt->fsb_error_regs = pdev;
852 838
853 debugf1("System Address, processor bus- PCI Bus ID: %s %x:%x\n", 839 edac_dbg(1, "System Address, processor bus- PCI Bus ID: %s %x:%x\n",
854 pci_name(pvt->system_address), 840 pci_name(pvt->system_address),
855 pvt->system_address->vendor, pvt->system_address->device); 841 pvt->system_address->vendor, pvt->system_address->device);
856 debugf1("Branchmap, control and errors - PCI Bus ID: %s %x:%x\n", 842 edac_dbg(1, "Branchmap, control and errors - PCI Bus ID: %s %x:%x\n",
857 pci_name(pvt->branchmap_werrors), 843 pci_name(pvt->branchmap_werrors),
858 pvt->branchmap_werrors->vendor, pvt->branchmap_werrors->device); 844 pvt->branchmap_werrors->vendor,
859 debugf1("FSB Error Regs - PCI Bus ID: %s %x:%x\n", 845 pvt->branchmap_werrors->device);
860 pci_name(pvt->fsb_error_regs), 846 edac_dbg(1, "FSB Error Regs - PCI Bus ID: %s %x:%x\n",
861 pvt->fsb_error_regs->vendor, pvt->fsb_error_regs->device); 847 pci_name(pvt->fsb_error_regs),
848 pvt->fsb_error_regs->vendor, pvt->fsb_error_regs->device);
862 849
863 pdev = NULL; 850 pdev = NULL;
864 pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 851 pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
@@ -981,16 +968,25 @@ static void decode_mtr(int slot_row, u16 mtr)
981 968
982 ans = MTR_DIMMS_PRESENT(mtr); 969 ans = MTR_DIMMS_PRESENT(mtr);
983 970
984 debugf2("\tMTR%d=0x%x: DIMMs are %s\n", slot_row, mtr, 971 edac_dbg(2, "\tMTR%d=0x%x: DIMMs are %sPresent\n",
985 ans ? "Present" : "NOT Present"); 972 slot_row, mtr, ans ? "" : "NOT ");
986 if (!ans) 973 if (!ans)
987 return; 974 return;
988 975
989 debugf2("\t\tWIDTH: x%d\n", MTR_DRAM_WIDTH(mtr)); 976 edac_dbg(2, "\t\tWIDTH: x%d\n", MTR_DRAM_WIDTH(mtr));
990 debugf2("\t\tNUMBANK: %d bank(s)\n", MTR_DRAM_BANKS(mtr)); 977 edac_dbg(2, "\t\tNUMBANK: %d bank(s)\n", MTR_DRAM_BANKS(mtr));
991 debugf2("\t\tNUMRANK: %s\n", MTR_DIMM_RANK(mtr) ? "double" : "single"); 978 edac_dbg(2, "\t\tNUMRANK: %s\n",
992 debugf2("\t\tNUMROW: %s\n", numrow_toString[MTR_DIMM_ROWS(mtr)]); 979 MTR_DIMM_RANK(mtr) ? "double" : "single");
993 debugf2("\t\tNUMCOL: %s\n", numcol_toString[MTR_DIMM_COLS(mtr)]); 980 edac_dbg(2, "\t\tNUMROW: %s\n",
981 MTR_DIMM_ROWS(mtr) == 0 ? "8,192 - 13 rows" :
982 MTR_DIMM_ROWS(mtr) == 1 ? "16,384 - 14 rows" :
983 MTR_DIMM_ROWS(mtr) == 2 ? "32,768 - 15 rows" :
984 "reserved");
985 edac_dbg(2, "\t\tNUMCOL: %s\n",
986 MTR_DIMM_COLS(mtr) == 0 ? "1,024 - 10 columns" :
987 MTR_DIMM_COLS(mtr) == 1 ? "2,048 - 11 columns" :
988 MTR_DIMM_COLS(mtr) == 2 ? "4,096 - 12 columns" :
989 "reserved");
994} 990}
995 991
996static void handle_channel(struct i5000_pvt *pvt, int slot, int channel, 992static void handle_channel(struct i5000_pvt *pvt, int slot, int channel,
@@ -1061,7 +1057,7 @@ static void calculate_dimm_size(struct i5000_pvt *pvt)
1061 "--------------------------------"); 1057 "--------------------------------");
1062 p += n; 1058 p += n;
1063 space -= n; 1059 space -= n;
1064 debugf2("%s\n", mem_buffer); 1060 edac_dbg(2, "%s\n", mem_buffer);
1065 p = mem_buffer; 1061 p = mem_buffer;
1066 space = PAGE_SIZE; 1062 space = PAGE_SIZE;
1067 } 1063 }
@@ -1082,7 +1078,7 @@ static void calculate_dimm_size(struct i5000_pvt *pvt)
1082 } 1078 }
1083 p += n; 1079 p += n;
1084 space -= n; 1080 space -= n;
1085 debugf2("%s\n", mem_buffer); 1081 edac_dbg(2, "%s\n", mem_buffer);
1086 p = mem_buffer; 1082 p = mem_buffer;
1087 space = PAGE_SIZE; 1083 space = PAGE_SIZE;
1088 } 1084 }
@@ -1092,7 +1088,7 @@ static void calculate_dimm_size(struct i5000_pvt *pvt)
1092 "--------------------------------"); 1088 "--------------------------------");
1093 p += n; 1089 p += n;
1094 space -= n; 1090 space -= n;
1095 debugf2("%s\n", mem_buffer); 1091 edac_dbg(2, "%s\n", mem_buffer);
1096 p = mem_buffer; 1092 p = mem_buffer;
1097 space = PAGE_SIZE; 1093 space = PAGE_SIZE;
1098 1094
@@ -1105,7 +1101,7 @@ static void calculate_dimm_size(struct i5000_pvt *pvt)
1105 p += n; 1101 p += n;
1106 space -= n; 1102 space -= n;
1107 } 1103 }
1108 debugf2("%s\n", mem_buffer); 1104 edac_dbg(2, "%s\n", mem_buffer);
1109 p = mem_buffer; 1105 p = mem_buffer;
1110 space = PAGE_SIZE; 1106 space = PAGE_SIZE;
1111 1107
@@ -1118,7 +1114,7 @@ static void calculate_dimm_size(struct i5000_pvt *pvt)
1118 } 1114 }
1119 1115
1120 /* output the last message and free buffer */ 1116 /* output the last message and free buffer */
1121 debugf2("%s\n", mem_buffer); 1117 edac_dbg(2, "%s\n", mem_buffer);
1122 kfree(mem_buffer); 1118 kfree(mem_buffer);
1123} 1119}
1124 1120
@@ -1141,24 +1137,25 @@ static void i5000_get_mc_regs(struct mem_ctl_info *mci)
1141 pvt = mci->pvt_info; 1137 pvt = mci->pvt_info;
1142 1138
1143 pci_read_config_dword(pvt->system_address, AMBASE, 1139 pci_read_config_dword(pvt->system_address, AMBASE,
1144 (u32 *) & pvt->ambase); 1140 &pvt->u.ambase_bottom);
1145 pci_read_config_dword(pvt->system_address, AMBASE + sizeof(u32), 1141 pci_read_config_dword(pvt->system_address, AMBASE + sizeof(u32),
1146 ((u32 *) & pvt->ambase) + sizeof(u32)); 1142 &pvt->u.ambase_top);
1147 1143
1148 maxdimmperch = pvt->maxdimmperch; 1144 maxdimmperch = pvt->maxdimmperch;
1149 maxch = pvt->maxch; 1145 maxch = pvt->maxch;
1150 1146
1151 debugf2("AMBASE= 0x%lx MAXCH= %d MAX-DIMM-Per-CH= %d\n", 1147 edac_dbg(2, "AMBASE= 0x%lx MAXCH= %d MAX-DIMM-Per-CH= %d\n",
1152 (long unsigned int)pvt->ambase, pvt->maxch, pvt->maxdimmperch); 1148 (long unsigned int)pvt->ambase, pvt->maxch, pvt->maxdimmperch);
1153 1149
1154 /* Get the Branch Map regs */ 1150 /* Get the Branch Map regs */
1155 pci_read_config_word(pvt->branchmap_werrors, TOLM, &pvt->tolm); 1151 pci_read_config_word(pvt->branchmap_werrors, TOLM, &pvt->tolm);
1156 pvt->tolm >>= 12; 1152 pvt->tolm >>= 12;
1157 debugf2("\nTOLM (number of 256M regions) =%u (0x%x)\n", pvt->tolm, 1153 edac_dbg(2, "TOLM (number of 256M regions) =%u (0x%x)\n",
1158 pvt->tolm); 1154 pvt->tolm, pvt->tolm);
1159 1155
1160 actual_tolm = pvt->tolm << 28; 1156 actual_tolm = pvt->tolm << 28;
1161 debugf2("Actual TOLM byte addr=%u (0x%x)\n", actual_tolm, actual_tolm); 1157 edac_dbg(2, "Actual TOLM byte addr=%u (0x%x)\n",
1158 actual_tolm, actual_tolm);
1162 1159
1163 pci_read_config_word(pvt->branchmap_werrors, MIR0, &pvt->mir0); 1160 pci_read_config_word(pvt->branchmap_werrors, MIR0, &pvt->mir0);
1164 pci_read_config_word(pvt->branchmap_werrors, MIR1, &pvt->mir1); 1161 pci_read_config_word(pvt->branchmap_werrors, MIR1, &pvt->mir1);
@@ -1168,15 +1165,18 @@ static void i5000_get_mc_regs(struct mem_ctl_info *mci)
1168 limit = (pvt->mir0 >> 4) & 0x0FFF; 1165 limit = (pvt->mir0 >> 4) & 0x0FFF;
1169 way0 = pvt->mir0 & 0x1; 1166 way0 = pvt->mir0 & 0x1;
1170 way1 = pvt->mir0 & 0x2; 1167 way1 = pvt->mir0 & 0x2;
1171 debugf2("MIR0: limit= 0x%x WAY1= %u WAY0= %x\n", limit, way1, way0); 1168 edac_dbg(2, "MIR0: limit= 0x%x WAY1= %u WAY0= %x\n",
1169 limit, way1, way0);
1172 limit = (pvt->mir1 >> 4) & 0x0FFF; 1170 limit = (pvt->mir1 >> 4) & 0x0FFF;
1173 way0 = pvt->mir1 & 0x1; 1171 way0 = pvt->mir1 & 0x1;
1174 way1 = pvt->mir1 & 0x2; 1172 way1 = pvt->mir1 & 0x2;
1175 debugf2("MIR1: limit= 0x%x WAY1= %u WAY0= %x\n", limit, way1, way0); 1173 edac_dbg(2, "MIR1: limit= 0x%x WAY1= %u WAY0= %x\n",
1174 limit, way1, way0);
1176 limit = (pvt->mir2 >> 4) & 0x0FFF; 1175 limit = (pvt->mir2 >> 4) & 0x0FFF;
1177 way0 = pvt->mir2 & 0x1; 1176 way0 = pvt->mir2 & 0x1;
1178 way1 = pvt->mir2 & 0x2; 1177 way1 = pvt->mir2 & 0x2;
1179 debugf2("MIR2: limit= 0x%x WAY1= %u WAY0= %x\n", limit, way1, way0); 1178 edac_dbg(2, "MIR2: limit= 0x%x WAY1= %u WAY0= %x\n",
1179 limit, way1, way0);
1180 1180
1181 /* Get the MTR[0-3] regs */ 1181 /* Get the MTR[0-3] regs */
1182 for (slot_row = 0; slot_row < NUM_MTRS; slot_row++) { 1182 for (slot_row = 0; slot_row < NUM_MTRS; slot_row++) {
@@ -1185,31 +1185,31 @@ static void i5000_get_mc_regs(struct mem_ctl_info *mci)
1185 pci_read_config_word(pvt->branch_0, where, 1185 pci_read_config_word(pvt->branch_0, where,
1186 &pvt->b0_mtr[slot_row]); 1186 &pvt->b0_mtr[slot_row]);
1187 1187
1188 debugf2("MTR%d where=0x%x B0 value=0x%x\n", slot_row, where, 1188 edac_dbg(2, "MTR%d where=0x%x B0 value=0x%x\n",
1189 pvt->b0_mtr[slot_row]); 1189 slot_row, where, pvt->b0_mtr[slot_row]);
1190 1190
1191 if (pvt->maxch >= CHANNELS_PER_BRANCH) { 1191 if (pvt->maxch >= CHANNELS_PER_BRANCH) {
1192 pci_read_config_word(pvt->branch_1, where, 1192 pci_read_config_word(pvt->branch_1, where,
1193 &pvt->b1_mtr[slot_row]); 1193 &pvt->b1_mtr[slot_row]);
1194 debugf2("MTR%d where=0x%x B1 value=0x%x\n", slot_row, 1194 edac_dbg(2, "MTR%d where=0x%x B1 value=0x%x\n",
1195 where, pvt->b1_mtr[slot_row]); 1195 slot_row, where, pvt->b1_mtr[slot_row]);
1196 } else { 1196 } else {
1197 pvt->b1_mtr[slot_row] = 0; 1197 pvt->b1_mtr[slot_row] = 0;
1198 } 1198 }
1199 } 1199 }
1200 1200
1201 /* Read and dump branch 0's MTRs */ 1201 /* Read and dump branch 0's MTRs */
1202 debugf2("\nMemory Technology Registers:\n"); 1202 edac_dbg(2, "Memory Technology Registers:\n");
1203 debugf2(" Branch 0:\n"); 1203 edac_dbg(2, " Branch 0:\n");
1204 for (slot_row = 0; slot_row < NUM_MTRS; slot_row++) { 1204 for (slot_row = 0; slot_row < NUM_MTRS; slot_row++) {
1205 decode_mtr(slot_row, pvt->b0_mtr[slot_row]); 1205 decode_mtr(slot_row, pvt->b0_mtr[slot_row]);
1206 } 1206 }
1207 pci_read_config_word(pvt->branch_0, AMB_PRESENT_0, 1207 pci_read_config_word(pvt->branch_0, AMB_PRESENT_0,
1208 &pvt->b0_ambpresent0); 1208 &pvt->b0_ambpresent0);
1209 debugf2("\t\tAMB-Branch 0-present0 0x%x:\n", pvt->b0_ambpresent0); 1209 edac_dbg(2, "\t\tAMB-Branch 0-present0 0x%x:\n", pvt->b0_ambpresent0);
1210 pci_read_config_word(pvt->branch_0, AMB_PRESENT_1, 1210 pci_read_config_word(pvt->branch_0, AMB_PRESENT_1,
1211 &pvt->b0_ambpresent1); 1211 &pvt->b0_ambpresent1);
1212 debugf2("\t\tAMB-Branch 0-present1 0x%x:\n", pvt->b0_ambpresent1); 1212 edac_dbg(2, "\t\tAMB-Branch 0-present1 0x%x:\n", pvt->b0_ambpresent1);
1213 1213
1214 /* Only if we have 2 branchs (4 channels) */ 1214 /* Only if we have 2 branchs (4 channels) */
1215 if (pvt->maxch < CHANNELS_PER_BRANCH) { 1215 if (pvt->maxch < CHANNELS_PER_BRANCH) {
@@ -1217,18 +1217,18 @@ static void i5000_get_mc_regs(struct mem_ctl_info *mci)
1217 pvt->b1_ambpresent1 = 0; 1217 pvt->b1_ambpresent1 = 0;
1218 } else { 1218 } else {
1219 /* Read and dump branch 1's MTRs */ 1219 /* Read and dump branch 1's MTRs */
1220 debugf2(" Branch 1:\n"); 1220 edac_dbg(2, " Branch 1:\n");
1221 for (slot_row = 0; slot_row < NUM_MTRS; slot_row++) { 1221 for (slot_row = 0; slot_row < NUM_MTRS; slot_row++) {
1222 decode_mtr(slot_row, pvt->b1_mtr[slot_row]); 1222 decode_mtr(slot_row, pvt->b1_mtr[slot_row]);
1223 } 1223 }
1224 pci_read_config_word(pvt->branch_1, AMB_PRESENT_0, 1224 pci_read_config_word(pvt->branch_1, AMB_PRESENT_0,
1225 &pvt->b1_ambpresent0); 1225 &pvt->b1_ambpresent0);
1226 debugf2("\t\tAMB-Branch 1-present0 0x%x:\n", 1226 edac_dbg(2, "\t\tAMB-Branch 1-present0 0x%x:\n",
1227 pvt->b1_ambpresent0); 1227 pvt->b1_ambpresent0);
1228 pci_read_config_word(pvt->branch_1, AMB_PRESENT_1, 1228 pci_read_config_word(pvt->branch_1, AMB_PRESENT_1,
1229 &pvt->b1_ambpresent1); 1229 &pvt->b1_ambpresent1);
1230 debugf2("\t\tAMB-Branch 1-present1 0x%x:\n", 1230 edac_dbg(2, "\t\tAMB-Branch 1-present1 0x%x:\n",
1231 pvt->b1_ambpresent1); 1231 pvt->b1_ambpresent1);
1232 } 1232 }
1233 1233
1234 /* Go and determine the size of each DIMM and place in an 1234 /* Go and determine the size of each DIMM and place in an
@@ -1363,10 +1363,9 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx)
1363 int num_channels; 1363 int num_channels;
1364 int num_dimms_per_channel; 1364 int num_dimms_per_channel;
1365 1365
1366 debugf0("MC: %s: %s(), pdev bus %u dev=0x%x fn=0x%x\n", 1366 edac_dbg(0, "MC: pdev bus %u dev=0x%x fn=0x%x\n",
1367 __FILE__, __func__, 1367 pdev->bus->number,
1368 pdev->bus->number, 1368 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
1369 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
1370 1369
1371 /* We only are looking for func 0 of the set */ 1370 /* We only are looking for func 0 of the set */
1372 if (PCI_FUNC(pdev->devfn) != 0) 1371 if (PCI_FUNC(pdev->devfn) != 0)
@@ -1388,8 +1387,8 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx)
1388 i5000_get_dimm_and_channel_counts(pdev, &num_dimms_per_channel, 1387 i5000_get_dimm_and_channel_counts(pdev, &num_dimms_per_channel,
1389 &num_channels); 1388 &num_channels);
1390 1389
1391 debugf0("MC: %s(): Number of Branches=2 Channels= %d DIMMS= %d\n", 1390 edac_dbg(0, "MC: Number of Branches=2 Channels= %d DIMMS= %d\n",
1392 __func__, num_channels, num_dimms_per_channel); 1391 num_channels, num_dimms_per_channel);
1393 1392
1394 /* allocate a new MC control structure */ 1393 /* allocate a new MC control structure */
1395 1394
@@ -1406,10 +1405,9 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx)
1406 if (mci == NULL) 1405 if (mci == NULL)
1407 return -ENOMEM; 1406 return -ENOMEM;
1408 1407
1409 kobject_get(&mci->edac_mci_kobj); 1408 edac_dbg(0, "MC: mci = %p\n", mci);
1410 debugf0("MC: %s: %s(): mci = %p\n", __FILE__, __func__, mci);
1411 1409
1412 mci->dev = &pdev->dev; /* record ptr to the generic device */ 1410 mci->pdev = &pdev->dev; /* record ptr to the generic device */
1413 1411
1414 pvt = mci->pvt_info; 1412 pvt = mci->pvt_info;
1415 pvt->system_address = pdev; /* Record this device in our private */ 1413 pvt->system_address = pdev; /* Record this device in our private */
@@ -1439,19 +1437,16 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx)
1439 /* initialize the MC control structure 'csrows' table 1437 /* initialize the MC control structure 'csrows' table
1440 * with the mapping and control information */ 1438 * with the mapping and control information */
1441 if (i5000_init_csrows(mci)) { 1439 if (i5000_init_csrows(mci)) {
1442 debugf0("MC: Setting mci->edac_cap to EDAC_FLAG_NONE\n" 1440 edac_dbg(0, "MC: Setting mci->edac_cap to EDAC_FLAG_NONE because i5000_init_csrows() returned nonzero value\n");
1443 " because i5000_init_csrows() returned nonzero "
1444 "value\n");
1445 mci->edac_cap = EDAC_FLAG_NONE; /* no csrows found */ 1441 mci->edac_cap = EDAC_FLAG_NONE; /* no csrows found */
1446 } else { 1442 } else {
1447 debugf1("MC: Enable error reporting now\n"); 1443 edac_dbg(1, "MC: Enable error reporting now\n");
1448 i5000_enable_error_reporting(mci); 1444 i5000_enable_error_reporting(mci);
1449 } 1445 }
1450 1446
1451 /* add this new MC control structure to EDAC's list of MCs */ 1447 /* add this new MC control structure to EDAC's list of MCs */
1452 if (edac_mc_add_mc(mci)) { 1448 if (edac_mc_add_mc(mci)) {
1453 debugf0("MC: %s: %s(): failed edac_mc_add_mc()\n", 1449 edac_dbg(0, "MC: failed edac_mc_add_mc()\n");
1454 __FILE__, __func__);
1455 /* FIXME: perhaps some code should go here that disables error 1450 /* FIXME: perhaps some code should go here that disables error
1456 * reporting if we just enabled it 1451 * reporting if we just enabled it
1457 */ 1452 */
@@ -1479,7 +1474,6 @@ fail1:
1479 i5000_put_devices(mci); 1474 i5000_put_devices(mci);
1480 1475
1481fail0: 1476fail0:
1482 kobject_put(&mci->edac_mci_kobj);
1483 edac_mc_free(mci); 1477 edac_mc_free(mci);
1484 return -ENODEV; 1478 return -ENODEV;
1485} 1479}
@@ -1496,7 +1490,7 @@ static int __devinit i5000_init_one(struct pci_dev *pdev,
1496{ 1490{
1497 int rc; 1491 int rc;
1498 1492
1499 debugf0("MC: %s: %s()\n", __FILE__, __func__); 1493 edac_dbg(0, "MC:\n");
1500 1494
1501 /* wake up device */ 1495 /* wake up device */
1502 rc = pci_enable_device(pdev); 1496 rc = pci_enable_device(pdev);
@@ -1515,7 +1509,7 @@ static void __devexit i5000_remove_one(struct pci_dev *pdev)
1515{ 1509{
1516 struct mem_ctl_info *mci; 1510 struct mem_ctl_info *mci;
1517 1511
1518 debugf0("%s: %s()\n", __FILE__, __func__); 1512 edac_dbg(0, "\n");
1519 1513
1520 if (i5000_pci) 1514 if (i5000_pci)
1521 edac_pci_release_generic_ctl(i5000_pci); 1515 edac_pci_release_generic_ctl(i5000_pci);
@@ -1525,7 +1519,6 @@ static void __devexit i5000_remove_one(struct pci_dev *pdev)
1525 1519
1526 /* retrieve references to resources, and free those resources */ 1520 /* retrieve references to resources, and free those resources */
1527 i5000_put_devices(mci); 1521 i5000_put_devices(mci);
1528 kobject_put(&mci->edac_mci_kobj);
1529 edac_mc_free(mci); 1522 edac_mc_free(mci);
1530} 1523}
1531 1524
@@ -1562,7 +1555,7 @@ static int __init i5000_init(void)
1562{ 1555{
1563 int pci_rc; 1556 int pci_rc;
1564 1557
1565 debugf2("MC: %s: %s()\n", __FILE__, __func__); 1558 edac_dbg(2, "MC:\n");
1566 1559
1567 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 1560 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
1568 opstate_init(); 1561 opstate_init();
@@ -1578,7 +1571,7 @@ static int __init i5000_init(void)
1578 */ 1571 */
1579static void __exit i5000_exit(void) 1572static void __exit i5000_exit(void)
1580{ 1573{
1581 debugf2("MC: %s: %s()\n", __FILE__, __func__); 1574 edac_dbg(2, "MC:\n");
1582 pci_unregister_driver(&i5000_driver); 1575 pci_unregister_driver(&i5000_driver);
1583} 1576}
1584 1577
diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
index e9e7c2a29dc3..c4b5e5f868e8 100644
--- a/drivers/edac/i5100_edac.c
+++ b/drivers/edac/i5100_edac.c
@@ -431,10 +431,10 @@ static void i5100_handle_ce(struct mem_ctl_info *mci,
431 "bank %u, cas %u, ras %u\n", 431 "bank %u, cas %u, ras %u\n",
432 bank, cas, ras); 432 bank, cas, ras);
433 433
434 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 434 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
435 0, 0, syndrome, 435 0, 0, syndrome,
436 chan, rank, -1, 436 chan, rank, -1,
437 msg, detail, NULL); 437 msg, detail);
438} 438}
439 439
440static void i5100_handle_ue(struct mem_ctl_info *mci, 440static void i5100_handle_ue(struct mem_ctl_info *mci,
@@ -453,10 +453,10 @@ static void i5100_handle_ue(struct mem_ctl_info *mci,
453 "bank %u, cas %u, ras %u\n", 453 "bank %u, cas %u, ras %u\n",
454 bank, cas, ras); 454 bank, cas, ras);
455 455
456 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 456 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
457 0, 0, syndrome, 457 0, 0, syndrome,
458 chan, rank, -1, 458 chan, rank, -1,
459 msg, detail, NULL); 459 msg, detail);
460} 460}
461 461
462static void i5100_read_log(struct mem_ctl_info *mci, int chan, 462static void i5100_read_log(struct mem_ctl_info *mci, int chan,
@@ -859,8 +859,8 @@ static void __devinit i5100_init_csrows(struct mem_ctl_info *mci)
859 i5100_rank_to_slot(mci, chan, rank)); 859 i5100_rank_to_slot(mci, chan, rank));
860 } 860 }
861 861
862 debugf2("dimm channel %d, rank %d, size %ld\n", 862 edac_dbg(2, "dimm channel %d, rank %d, size %ld\n",
863 chan, rank, (long)PAGES_TO_MiB(npages)); 863 chan, rank, (long)PAGES_TO_MiB(npages));
864 } 864 }
865} 865}
866 866
@@ -943,7 +943,7 @@ static int __devinit i5100_init_one(struct pci_dev *pdev,
943 goto bail_disable_ch1; 943 goto bail_disable_ch1;
944 } 944 }
945 945
946 mci->dev = &pdev->dev; 946 mci->pdev = &pdev->dev;
947 947
948 priv = mci->pvt_info; 948 priv = mci->pvt_info;
949 priv->ranksperchan = ranksperch; 949 priv->ranksperchan = ranksperch;
diff --git a/drivers/edac/i5400_edac.c b/drivers/edac/i5400_edac.c
index 6640c29e1885..277246998b80 100644
--- a/drivers/edac/i5400_edac.c
+++ b/drivers/edac/i5400_edac.c
@@ -300,24 +300,6 @@ static inline int extract_fbdchan_indx(u32 x)
300 return (x>>28) & 0x3; 300 return (x>>28) & 0x3;
301} 301}
302 302
303#ifdef CONFIG_EDAC_DEBUG
304/* MTR NUMROW */
305static const char *numrow_toString[] = {
306 "8,192 - 13 rows",
307 "16,384 - 14 rows",
308 "32,768 - 15 rows",
309 "65,536 - 16 rows"
310};
311
312/* MTR NUMCOL */
313static const char *numcol_toString[] = {
314 "1,024 - 10 columns",
315 "2,048 - 11 columns",
316 "4,096 - 12 columns",
317 "reserved"
318};
319#endif
320
321/* Device name and register DID (Device ID) */ 303/* Device name and register DID (Device ID) */
322struct i5400_dev_info { 304struct i5400_dev_info {
323 const char *ctl_name; /* name for this device */ 305 const char *ctl_name; /* name for this device */
@@ -345,7 +327,13 @@ struct i5400_pvt {
345 struct pci_dev *branch_1; /* 22.0 */ 327 struct pci_dev *branch_1; /* 22.0 */
346 328
347 u16 tolm; /* top of low memory */ 329 u16 tolm; /* top of low memory */
348 u64 ambase; /* AMB BAR */ 330 union {
331 u64 ambase; /* AMB BAR */
332 struct {
333 u32 ambase_bottom;
334 u32 ambase_top;
335 } u __packed;
336 };
349 337
350 u16 mir0, mir1; 338 u16 mir0, mir1;
351 339
@@ -560,10 +548,9 @@ static void i5400_proccess_non_recoverable_info(struct mem_ctl_info *mci,
560 ras = nrec_ras(info); 548 ras = nrec_ras(info);
561 cas = nrec_cas(info); 549 cas = nrec_cas(info);
562 550
563 debugf0("\t\tDIMM= %d Channels= %d,%d (Branch= %d " 551 edac_dbg(0, "\t\tDIMM= %d Channels= %d,%d (Branch= %d DRAM Bank= %d Buffer ID = %d rdwr= %s ras= %d cas= %d)\n",
564 "DRAM Bank= %d Buffer ID = %d rdwr= %s ras= %d cas= %d)\n", 552 rank, channel, channel + 1, branch >> 1, bank,
565 rank, channel, channel + 1, branch >> 1, bank, 553 buf_id, rdwr_str(rdwr), ras, cas);
566 buf_id, rdwr_str(rdwr), ras, cas);
567 554
568 /* Only 1 bit will be on */ 555 /* Only 1 bit will be on */
569 errnum = find_first_bit(&allErrors, ARRAY_SIZE(error_name)); 556 errnum = find_first_bit(&allErrors, ARRAY_SIZE(error_name));
@@ -573,10 +560,10 @@ static void i5400_proccess_non_recoverable_info(struct mem_ctl_info *mci,
573 "Bank=%d Buffer ID = %d RAS=%d CAS=%d Err=0x%lx (%s)", 560 "Bank=%d Buffer ID = %d RAS=%d CAS=%d Err=0x%lx (%s)",
574 bank, buf_id, ras, cas, allErrors, error_name[errnum]); 561 bank, buf_id, ras, cas, allErrors, error_name[errnum]);
575 562
576 edac_mc_handle_error(tp_event, mci, 0, 0, 0, 563 edac_mc_handle_error(tp_event, mci, 1, 0, 0, 0,
577 branch >> 1, -1, rank, 564 branch >> 1, -1, rank,
578 rdwr ? "Write error" : "Read error", 565 rdwr ? "Write error" : "Read error",
579 msg, NULL); 566 msg);
580} 567}
581 568
582/* 569/*
@@ -613,7 +600,7 @@ static void i5400_process_nonfatal_error_info(struct mem_ctl_info *mci,
613 600
614 /* Correctable errors */ 601 /* Correctable errors */
615 if (allErrors & ERROR_NF_CORRECTABLE) { 602 if (allErrors & ERROR_NF_CORRECTABLE) {
616 debugf0("\tCorrected bits= 0x%lx\n", allErrors); 603 edac_dbg(0, "\tCorrected bits= 0x%lx\n", allErrors);
617 604
618 branch = extract_fbdchan_indx(info->ferr_nf_fbd); 605 branch = extract_fbdchan_indx(info->ferr_nf_fbd);
619 606
@@ -634,10 +621,9 @@ static void i5400_process_nonfatal_error_info(struct mem_ctl_info *mci,
634 /* Only 1 bit will be on */ 621 /* Only 1 bit will be on */
635 errnum = find_first_bit(&allErrors, ARRAY_SIZE(error_name)); 622 errnum = find_first_bit(&allErrors, ARRAY_SIZE(error_name));
636 623
637 debugf0("\t\tDIMM= %d Channel= %d (Branch %d " 624 edac_dbg(0, "\t\tDIMM= %d Channel= %d (Branch %d DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n",
638 "DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n", 625 rank, channel, branch >> 1, bank,
639 rank, channel, branch >> 1, bank, 626 rdwr_str(rdwr), ras, cas);
640 rdwr_str(rdwr), ras, cas);
641 627
642 /* Form out message */ 628 /* Form out message */
643 snprintf(msg, sizeof(msg), 629 snprintf(msg, sizeof(msg),
@@ -646,10 +632,10 @@ static void i5400_process_nonfatal_error_info(struct mem_ctl_info *mci,
646 branch >> 1, bank, rdwr_str(rdwr), ras, cas, 632 branch >> 1, bank, rdwr_str(rdwr), ras, cas,
647 allErrors, error_name[errnum]); 633 allErrors, error_name[errnum]);
648 634
649 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 0, 0, 0, 635 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, 0, 0, 0,
650 branch >> 1, channel % 2, rank, 636 branch >> 1, channel % 2, rank,
651 rdwr ? "Write error" : "Read error", 637 rdwr ? "Write error" : "Read error",
652 msg, NULL); 638 msg);
653 639
654 return; 640 return;
655 } 641 }
@@ -700,7 +686,7 @@ static void i5400_clear_error(struct mem_ctl_info *mci)
700static void i5400_check_error(struct mem_ctl_info *mci) 686static void i5400_check_error(struct mem_ctl_info *mci)
701{ 687{
702 struct i5400_error_info info; 688 struct i5400_error_info info;
703 debugf4("MC%d: %s: %s()\n", mci->mc_idx, __FILE__, __func__); 689 edac_dbg(4, "MC%d\n", mci->mc_idx);
704 i5400_get_error_info(mci, &info); 690 i5400_get_error_info(mci, &info);
705 i5400_process_error_info(mci, &info); 691 i5400_process_error_info(mci, &info);
706} 692}
@@ -786,15 +772,16 @@ static int i5400_get_devices(struct mem_ctl_info *mci, int dev_idx)
786 } 772 }
787 pvt->fsb_error_regs = pdev; 773 pvt->fsb_error_regs = pdev;
788 774
789 debugf1("System Address, processor bus- PCI Bus ID: %s %x:%x\n", 775 edac_dbg(1, "System Address, processor bus- PCI Bus ID: %s %x:%x\n",
790 pci_name(pvt->system_address), 776 pci_name(pvt->system_address),
791 pvt->system_address->vendor, pvt->system_address->device); 777 pvt->system_address->vendor, pvt->system_address->device);
792 debugf1("Branchmap, control and errors - PCI Bus ID: %s %x:%x\n", 778 edac_dbg(1, "Branchmap, control and errors - PCI Bus ID: %s %x:%x\n",
793 pci_name(pvt->branchmap_werrors), 779 pci_name(pvt->branchmap_werrors),
794 pvt->branchmap_werrors->vendor, pvt->branchmap_werrors->device); 780 pvt->branchmap_werrors->vendor,
795 debugf1("FSB Error Regs - PCI Bus ID: %s %x:%x\n", 781 pvt->branchmap_werrors->device);
796 pci_name(pvt->fsb_error_regs), 782 edac_dbg(1, "FSB Error Regs - PCI Bus ID: %s %x:%x\n",
797 pvt->fsb_error_regs->vendor, pvt->fsb_error_regs->device); 783 pci_name(pvt->fsb_error_regs),
784 pvt->fsb_error_regs->vendor, pvt->fsb_error_regs->device);
798 785
799 pvt->branch_0 = pci_get_device(PCI_VENDOR_ID_INTEL, 786 pvt->branch_0 = pci_get_device(PCI_VENDOR_ID_INTEL,
800 PCI_DEVICE_ID_INTEL_5400_FBD0, NULL); 787 PCI_DEVICE_ID_INTEL_5400_FBD0, NULL);
@@ -882,8 +869,8 @@ static int determine_mtr(struct i5400_pvt *pvt, int dimm, int channel)
882 n = dimm; 869 n = dimm;
883 870
884 if (n >= DIMMS_PER_CHANNEL) { 871 if (n >= DIMMS_PER_CHANNEL) {
885 debugf0("ERROR: trying to access an invalid dimm: %d\n", 872 edac_dbg(0, "ERROR: trying to access an invalid dimm: %d\n",
886 dimm); 873 dimm);
887 return 0; 874 return 0;
888 } 875 }
889 876
@@ -903,20 +890,29 @@ static void decode_mtr(int slot_row, u16 mtr)
903 890
904 ans = MTR_DIMMS_PRESENT(mtr); 891 ans = MTR_DIMMS_PRESENT(mtr);
905 892
906 debugf2("\tMTR%d=0x%x: DIMMs are %s\n", slot_row, mtr, 893 edac_dbg(2, "\tMTR%d=0x%x: DIMMs are %sPresent\n",
907 ans ? "Present" : "NOT Present"); 894 slot_row, mtr, ans ? "" : "NOT ");
908 if (!ans) 895 if (!ans)
909 return; 896 return;
910 897
911 debugf2("\t\tWIDTH: x%d\n", MTR_DRAM_WIDTH(mtr)); 898 edac_dbg(2, "\t\tWIDTH: x%d\n", MTR_DRAM_WIDTH(mtr));
912 899
913 debugf2("\t\tELECTRICAL THROTTLING is %s\n", 900 edac_dbg(2, "\t\tELECTRICAL THROTTLING is %s\n",
914 MTR_DIMMS_ETHROTTLE(mtr) ? "enabled" : "disabled"); 901 MTR_DIMMS_ETHROTTLE(mtr) ? "enabled" : "disabled");
915 902
916 debugf2("\t\tNUMBANK: %d bank(s)\n", MTR_DRAM_BANKS(mtr)); 903 edac_dbg(2, "\t\tNUMBANK: %d bank(s)\n", MTR_DRAM_BANKS(mtr));
917 debugf2("\t\tNUMRANK: %s\n", MTR_DIMM_RANK(mtr) ? "double" : "single"); 904 edac_dbg(2, "\t\tNUMRANK: %s\n",
918 debugf2("\t\tNUMROW: %s\n", numrow_toString[MTR_DIMM_ROWS(mtr)]); 905 MTR_DIMM_RANK(mtr) ? "double" : "single");
919 debugf2("\t\tNUMCOL: %s\n", numcol_toString[MTR_DIMM_COLS(mtr)]); 906 edac_dbg(2, "\t\tNUMROW: %s\n",
907 MTR_DIMM_ROWS(mtr) == 0 ? "8,192 - 13 rows" :
908 MTR_DIMM_ROWS(mtr) == 1 ? "16,384 - 14 rows" :
909 MTR_DIMM_ROWS(mtr) == 2 ? "32,768 - 15 rows" :
910 "65,536 - 16 rows");
911 edac_dbg(2, "\t\tNUMCOL: %s\n",
912 MTR_DIMM_COLS(mtr) == 0 ? "1,024 - 10 columns" :
913 MTR_DIMM_COLS(mtr) == 1 ? "2,048 - 11 columns" :
914 MTR_DIMM_COLS(mtr) == 2 ? "4,096 - 12 columns" :
915 "reserved");
920} 916}
921 917
922static void handle_channel(struct i5400_pvt *pvt, int dimm, int channel, 918static void handle_channel(struct i5400_pvt *pvt, int dimm, int channel,
@@ -989,7 +985,7 @@ static void calculate_dimm_size(struct i5400_pvt *pvt)
989 "-------------------------------"); 985 "-------------------------------");
990 p += n; 986 p += n;
991 space -= n; 987 space -= n;
992 debugf2("%s\n", mem_buffer); 988 edac_dbg(2, "%s\n", mem_buffer);
993 p = mem_buffer; 989 p = mem_buffer;
994 space = PAGE_SIZE; 990 space = PAGE_SIZE;
995 } 991 }
@@ -1004,7 +1000,7 @@ static void calculate_dimm_size(struct i5400_pvt *pvt)
1004 p += n; 1000 p += n;
1005 space -= n; 1001 space -= n;
1006 } 1002 }
1007 debugf2("%s\n", mem_buffer); 1003 edac_dbg(2, "%s\n", mem_buffer);
1008 p = mem_buffer; 1004 p = mem_buffer;
1009 space = PAGE_SIZE; 1005 space = PAGE_SIZE;
1010 } 1006 }
@@ -1014,7 +1010,7 @@ static void calculate_dimm_size(struct i5400_pvt *pvt)
1014 "-------------------------------"); 1010 "-------------------------------");
1015 p += n; 1011 p += n;
1016 space -= n; 1012 space -= n;
1017 debugf2("%s\n", mem_buffer); 1013 edac_dbg(2, "%s\n", mem_buffer);
1018 p = mem_buffer; 1014 p = mem_buffer;
1019 space = PAGE_SIZE; 1015 space = PAGE_SIZE;
1020 1016
@@ -1029,7 +1025,7 @@ static void calculate_dimm_size(struct i5400_pvt *pvt)
1029 } 1025 }
1030 1026
1031 space -= n; 1027 space -= n;
1032 debugf2("%s\n", mem_buffer); 1028 edac_dbg(2, "%s\n", mem_buffer);
1033 p = mem_buffer; 1029 p = mem_buffer;
1034 space = PAGE_SIZE; 1030 space = PAGE_SIZE;
1035 1031
@@ -1042,7 +1038,7 @@ static void calculate_dimm_size(struct i5400_pvt *pvt)
1042 } 1038 }
1043 1039
1044 /* output the last message and free buffer */ 1040 /* output the last message and free buffer */
1045 debugf2("%s\n", mem_buffer); 1041 edac_dbg(2, "%s\n", mem_buffer);
1046 kfree(mem_buffer); 1042 kfree(mem_buffer);
1047} 1043}
1048 1044
@@ -1065,25 +1061,25 @@ static void i5400_get_mc_regs(struct mem_ctl_info *mci)
1065 pvt = mci->pvt_info; 1061 pvt = mci->pvt_info;
1066 1062
1067 pci_read_config_dword(pvt->system_address, AMBASE, 1063 pci_read_config_dword(pvt->system_address, AMBASE,
1068 (u32 *) &pvt->ambase); 1064 &pvt->u.ambase_bottom);
1069 pci_read_config_dword(pvt->system_address, AMBASE + sizeof(u32), 1065 pci_read_config_dword(pvt->system_address, AMBASE + sizeof(u32),
1070 ((u32 *) &pvt->ambase) + sizeof(u32)); 1066 &pvt->u.ambase_top);
1071 1067
1072 maxdimmperch = pvt->maxdimmperch; 1068 maxdimmperch = pvt->maxdimmperch;
1073 maxch = pvt->maxch; 1069 maxch = pvt->maxch;
1074 1070
1075 debugf2("AMBASE= 0x%lx MAXCH= %d MAX-DIMM-Per-CH= %d\n", 1071 edac_dbg(2, "AMBASE= 0x%lx MAXCH= %d MAX-DIMM-Per-CH= %d\n",
1076 (long unsigned int)pvt->ambase, pvt->maxch, pvt->maxdimmperch); 1072 (long unsigned int)pvt->ambase, pvt->maxch, pvt->maxdimmperch);
1077 1073
1078 /* Get the Branch Map regs */ 1074 /* Get the Branch Map regs */
1079 pci_read_config_word(pvt->branchmap_werrors, TOLM, &pvt->tolm); 1075 pci_read_config_word(pvt->branchmap_werrors, TOLM, &pvt->tolm);
1080 pvt->tolm >>= 12; 1076 pvt->tolm >>= 12;
1081 debugf2("\nTOLM (number of 256M regions) =%u (0x%x)\n", pvt->tolm, 1077 edac_dbg(2, "\nTOLM (number of 256M regions) =%u (0x%x)\n",
1082 pvt->tolm); 1078 pvt->tolm, pvt->tolm);
1083 1079
1084 actual_tolm = (u32) ((1000l * pvt->tolm) >> (30 - 28)); 1080 actual_tolm = (u32) ((1000l * pvt->tolm) >> (30 - 28));
1085 debugf2("Actual TOLM byte addr=%u.%03u GB (0x%x)\n", 1081 edac_dbg(2, "Actual TOLM byte addr=%u.%03u GB (0x%x)\n",
1086 actual_tolm/1000, actual_tolm % 1000, pvt->tolm << 28); 1082 actual_tolm/1000, actual_tolm % 1000, pvt->tolm << 28);
1087 1083
1088 pci_read_config_word(pvt->branchmap_werrors, MIR0, &pvt->mir0); 1084 pci_read_config_word(pvt->branchmap_werrors, MIR0, &pvt->mir0);
1089 pci_read_config_word(pvt->branchmap_werrors, MIR1, &pvt->mir1); 1085 pci_read_config_word(pvt->branchmap_werrors, MIR1, &pvt->mir1);
@@ -1092,11 +1088,13 @@ static void i5400_get_mc_regs(struct mem_ctl_info *mci)
1092 limit = (pvt->mir0 >> 4) & 0x0fff; 1088 limit = (pvt->mir0 >> 4) & 0x0fff;
1093 way0 = pvt->mir0 & 0x1; 1089 way0 = pvt->mir0 & 0x1;
1094 way1 = pvt->mir0 & 0x2; 1090 way1 = pvt->mir0 & 0x2;
1095 debugf2("MIR0: limit= 0x%x WAY1= %u WAY0= %x\n", limit, way1, way0); 1091 edac_dbg(2, "MIR0: limit= 0x%x WAY1= %u WAY0= %x\n",
1092 limit, way1, way0);
1096 limit = (pvt->mir1 >> 4) & 0xfff; 1093 limit = (pvt->mir1 >> 4) & 0xfff;
1097 way0 = pvt->mir1 & 0x1; 1094 way0 = pvt->mir1 & 0x1;
1098 way1 = pvt->mir1 & 0x2; 1095 way1 = pvt->mir1 & 0x2;
1099 debugf2("MIR1: limit= 0x%x WAY1= %u WAY0= %x\n", limit, way1, way0); 1096 edac_dbg(2, "MIR1: limit= 0x%x WAY1= %u WAY0= %x\n",
1097 limit, way1, way0);
1100 1098
1101 /* Get the set of MTR[0-3] regs by each branch */ 1099 /* Get the set of MTR[0-3] regs by each branch */
1102 for (slot_row = 0; slot_row < DIMMS_PER_CHANNEL; slot_row++) { 1100 for (slot_row = 0; slot_row < DIMMS_PER_CHANNEL; slot_row++) {
@@ -1106,8 +1104,8 @@ static void i5400_get_mc_regs(struct mem_ctl_info *mci)
1106 pci_read_config_word(pvt->branch_0, where, 1104 pci_read_config_word(pvt->branch_0, where,
1107 &pvt->b0_mtr[slot_row]); 1105 &pvt->b0_mtr[slot_row]);
1108 1106
1109 debugf2("MTR%d where=0x%x B0 value=0x%x\n", slot_row, where, 1107 edac_dbg(2, "MTR%d where=0x%x B0 value=0x%x\n",
1110 pvt->b0_mtr[slot_row]); 1108 slot_row, where, pvt->b0_mtr[slot_row]);
1111 1109
1112 if (pvt->maxch < CHANNELS_PER_BRANCH) { 1110 if (pvt->maxch < CHANNELS_PER_BRANCH) {
1113 pvt->b1_mtr[slot_row] = 0; 1111 pvt->b1_mtr[slot_row] = 0;
@@ -1117,22 +1115,22 @@ static void i5400_get_mc_regs(struct mem_ctl_info *mci)
1117 /* Branch 1 set of MTR registers */ 1115 /* Branch 1 set of MTR registers */
1118 pci_read_config_word(pvt->branch_1, where, 1116 pci_read_config_word(pvt->branch_1, where,
1119 &pvt->b1_mtr[slot_row]); 1117 &pvt->b1_mtr[slot_row]);
1120 debugf2("MTR%d where=0x%x B1 value=0x%x\n", slot_row, where, 1118 edac_dbg(2, "MTR%d where=0x%x B1 value=0x%x\n",
1121 pvt->b1_mtr[slot_row]); 1119 slot_row, where, pvt->b1_mtr[slot_row]);
1122 } 1120 }
1123 1121
1124 /* Read and dump branch 0's MTRs */ 1122 /* Read and dump branch 0's MTRs */
1125 debugf2("\nMemory Technology Registers:\n"); 1123 edac_dbg(2, "Memory Technology Registers:\n");
1126 debugf2(" Branch 0:\n"); 1124 edac_dbg(2, " Branch 0:\n");
1127 for (slot_row = 0; slot_row < DIMMS_PER_CHANNEL; slot_row++) 1125 for (slot_row = 0; slot_row < DIMMS_PER_CHANNEL; slot_row++)
1128 decode_mtr(slot_row, pvt->b0_mtr[slot_row]); 1126 decode_mtr(slot_row, pvt->b0_mtr[slot_row]);
1129 1127
1130 pci_read_config_word(pvt->branch_0, AMBPRESENT_0, 1128 pci_read_config_word(pvt->branch_0, AMBPRESENT_0,
1131 &pvt->b0_ambpresent0); 1129 &pvt->b0_ambpresent0);
1132 debugf2("\t\tAMB-Branch 0-present0 0x%x:\n", pvt->b0_ambpresent0); 1130 edac_dbg(2, "\t\tAMB-Branch 0-present0 0x%x:\n", pvt->b0_ambpresent0);
1133 pci_read_config_word(pvt->branch_0, AMBPRESENT_1, 1131 pci_read_config_word(pvt->branch_0, AMBPRESENT_1,
1134 &pvt->b0_ambpresent1); 1132 &pvt->b0_ambpresent1);
1135 debugf2("\t\tAMB-Branch 0-present1 0x%x:\n", pvt->b0_ambpresent1); 1133 edac_dbg(2, "\t\tAMB-Branch 0-present1 0x%x:\n", pvt->b0_ambpresent1);
1136 1134
1137 /* Only if we have 2 branchs (4 channels) */ 1135 /* Only if we have 2 branchs (4 channels) */
1138 if (pvt->maxch < CHANNELS_PER_BRANCH) { 1136 if (pvt->maxch < CHANNELS_PER_BRANCH) {
@@ -1140,18 +1138,18 @@ static void i5400_get_mc_regs(struct mem_ctl_info *mci)
1140 pvt->b1_ambpresent1 = 0; 1138 pvt->b1_ambpresent1 = 0;
1141 } else { 1139 } else {
1142 /* Read and dump branch 1's MTRs */ 1140 /* Read and dump branch 1's MTRs */
1143 debugf2(" Branch 1:\n"); 1141 edac_dbg(2, " Branch 1:\n");
1144 for (slot_row = 0; slot_row < DIMMS_PER_CHANNEL; slot_row++) 1142 for (slot_row = 0; slot_row < DIMMS_PER_CHANNEL; slot_row++)
1145 decode_mtr(slot_row, pvt->b1_mtr[slot_row]); 1143 decode_mtr(slot_row, pvt->b1_mtr[slot_row]);
1146 1144
1147 pci_read_config_word(pvt->branch_1, AMBPRESENT_0, 1145 pci_read_config_word(pvt->branch_1, AMBPRESENT_0,
1148 &pvt->b1_ambpresent0); 1146 &pvt->b1_ambpresent0);
1149 debugf2("\t\tAMB-Branch 1-present0 0x%x:\n", 1147 edac_dbg(2, "\t\tAMB-Branch 1-present0 0x%x:\n",
1150 pvt->b1_ambpresent0); 1148 pvt->b1_ambpresent0);
1151 pci_read_config_word(pvt->branch_1, AMBPRESENT_1, 1149 pci_read_config_word(pvt->branch_1, AMBPRESENT_1,
1152 &pvt->b1_ambpresent1); 1150 &pvt->b1_ambpresent1);
1153 debugf2("\t\tAMB-Branch 1-present1 0x%x:\n", 1151 edac_dbg(2, "\t\tAMB-Branch 1-present1 0x%x:\n",
1154 pvt->b1_ambpresent1); 1152 pvt->b1_ambpresent1);
1155 } 1153 }
1156 1154
1157 /* Go and determine the size of each DIMM and place in an 1155 /* Go and determine the size of each DIMM and place in an
@@ -1203,10 +1201,9 @@ static int i5400_init_dimms(struct mem_ctl_info *mci)
1203 1201
1204 size_mb = pvt->dimm_info[slot][channel].megabytes; 1202 size_mb = pvt->dimm_info[slot][channel].megabytes;
1205 1203
1206 debugf2("%s: dimm%zd (branch %d channel %d slot %d): %d.%03d GB\n", 1204 edac_dbg(2, "dimm (branch %d channel %d slot %d): %d.%03d GB\n",
1207 __func__, dimm - mci->dimms, 1205 channel / 2, channel % 2, slot,
1208 channel / 2, channel % 2, slot, 1206 size_mb / 1000, size_mb % 1000);
1209 size_mb / 1000, size_mb % 1000);
1210 1207
1211 dimm->nr_pages = size_mb << 8; 1208 dimm->nr_pages = size_mb << 8;
1212 dimm->grain = 8; 1209 dimm->grain = 8;
@@ -1227,7 +1224,7 @@ static int i5400_init_dimms(struct mem_ctl_info *mci)
1227 * With such single-DIMM mode, the SDCC algorithm degrades to SECDEC+. 1224 * With such single-DIMM mode, the SDCC algorithm degrades to SECDEC+.
1228 */ 1225 */
1229 if (ndimms == 1) 1226 if (ndimms == 1)
1230 mci->dimms[0].edac_mode = EDAC_SECDED; 1227 mci->dimms[0]->edac_mode = EDAC_SECDED;
1231 1228
1232 return (ndimms == 0); 1229 return (ndimms == 0);
1233} 1230}
@@ -1270,10 +1267,9 @@ static int i5400_probe1(struct pci_dev *pdev, int dev_idx)
1270 if (dev_idx >= ARRAY_SIZE(i5400_devs)) 1267 if (dev_idx >= ARRAY_SIZE(i5400_devs))
1271 return -EINVAL; 1268 return -EINVAL;
1272 1269
1273 debugf0("MC: %s: %s(), pdev bus %u dev=0x%x fn=0x%x\n", 1270 edac_dbg(0, "MC: pdev bus %u dev=0x%x fn=0x%x\n",
1274 __FILE__, __func__, 1271 pdev->bus->number,
1275 pdev->bus->number, 1272 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
1276 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
1277 1273
1278 /* We only are looking for func 0 of the set */ 1274 /* We only are looking for func 0 of the set */
1279 if (PCI_FUNC(pdev->devfn) != 0) 1275 if (PCI_FUNC(pdev->devfn) != 0)
@@ -1297,9 +1293,9 @@ static int i5400_probe1(struct pci_dev *pdev, int dev_idx)
1297 if (mci == NULL) 1293 if (mci == NULL)
1298 return -ENOMEM; 1294 return -ENOMEM;
1299 1295
1300 debugf0("MC: %s: %s(): mci = %p\n", __FILE__, __func__, mci); 1296 edac_dbg(0, "MC: mci = %p\n", mci);
1301 1297
1302 mci->dev = &pdev->dev; /* record ptr to the generic device */ 1298 mci->pdev = &pdev->dev; /* record ptr to the generic device */
1303 1299
1304 pvt = mci->pvt_info; 1300 pvt = mci->pvt_info;
1305 pvt->system_address = pdev; /* Record this device in our private */ 1301 pvt->system_address = pdev; /* Record this device in our private */
@@ -1329,19 +1325,16 @@ static int i5400_probe1(struct pci_dev *pdev, int dev_idx)
1329 /* initialize the MC control structure 'dimms' table 1325 /* initialize the MC control structure 'dimms' table
1330 * with the mapping and control information */ 1326 * with the mapping and control information */
1331 if (i5400_init_dimms(mci)) { 1327 if (i5400_init_dimms(mci)) {
1332 debugf0("MC: Setting mci->edac_cap to EDAC_FLAG_NONE\n" 1328 edac_dbg(0, "MC: Setting mci->edac_cap to EDAC_FLAG_NONE because i5400_init_dimms() returned nonzero value\n");
1333 " because i5400_init_dimms() returned nonzero "
1334 "value\n");
1335 mci->edac_cap = EDAC_FLAG_NONE; /* no dimms found */ 1329 mci->edac_cap = EDAC_FLAG_NONE; /* no dimms found */
1336 } else { 1330 } else {
1337 debugf1("MC: Enable error reporting now\n"); 1331 edac_dbg(1, "MC: Enable error reporting now\n");
1338 i5400_enable_error_reporting(mci); 1332 i5400_enable_error_reporting(mci);
1339 } 1333 }
1340 1334
1341 /* add this new MC control structure to EDAC's list of MCs */ 1335 /* add this new MC control structure to EDAC's list of MCs */
1342 if (edac_mc_add_mc(mci)) { 1336 if (edac_mc_add_mc(mci)) {
1343 debugf0("MC: %s: %s(): failed edac_mc_add_mc()\n", 1337 edac_dbg(0, "MC: failed edac_mc_add_mc()\n");
1344 __FILE__, __func__);
1345 /* FIXME: perhaps some code should go here that disables error 1338 /* FIXME: perhaps some code should go here that disables error
1346 * reporting if we just enabled it 1339 * reporting if we just enabled it
1347 */ 1340 */
@@ -1385,7 +1378,7 @@ static int __devinit i5400_init_one(struct pci_dev *pdev,
1385{ 1378{
1386 int rc; 1379 int rc;
1387 1380
1388 debugf0("MC: %s: %s()\n", __FILE__, __func__); 1381 edac_dbg(0, "MC:\n");
1389 1382
1390 /* wake up device */ 1383 /* wake up device */
1391 rc = pci_enable_device(pdev); 1384 rc = pci_enable_device(pdev);
@@ -1404,7 +1397,7 @@ static void __devexit i5400_remove_one(struct pci_dev *pdev)
1404{ 1397{
1405 struct mem_ctl_info *mci; 1398 struct mem_ctl_info *mci;
1406 1399
1407 debugf0("%s: %s()\n", __FILE__, __func__); 1400 edac_dbg(0, "\n");
1408 1401
1409 if (i5400_pci) 1402 if (i5400_pci)
1410 edac_pci_release_generic_ctl(i5400_pci); 1403 edac_pci_release_generic_ctl(i5400_pci);
@@ -1450,7 +1443,7 @@ static int __init i5400_init(void)
1450{ 1443{
1451 int pci_rc; 1444 int pci_rc;
1452 1445
1453 debugf2("MC: %s: %s()\n", __FILE__, __func__); 1446 edac_dbg(2, "MC:\n");
1454 1447
1455 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 1448 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
1456 opstate_init(); 1449 opstate_init();
@@ -1466,7 +1459,7 @@ static int __init i5400_init(void)
1466 */ 1459 */
1467static void __exit i5400_exit(void) 1460static void __exit i5400_exit(void)
1468{ 1461{
1469 debugf2("MC: %s: %s()\n", __FILE__, __func__); 1462 edac_dbg(2, "MC:\n");
1470 pci_unregister_driver(&i5400_driver); 1463 pci_unregister_driver(&i5400_driver);
1471} 1464}
1472 1465
diff --git a/drivers/edac/i7300_edac.c b/drivers/edac/i7300_edac.c
index 97c22fd650ee..a09d0667f72a 100644
--- a/drivers/edac/i7300_edac.c
+++ b/drivers/edac/i7300_edac.c
@@ -182,24 +182,6 @@ static const u16 mtr_regs[MAX_SLOTS] = {
182#define MTR_DIMM_COLS(mtr) ((mtr) & 0x3) 182#define MTR_DIMM_COLS(mtr) ((mtr) & 0x3)
183#define MTR_DIMM_COLS_ADDR_BITS(mtr) (MTR_DIMM_COLS(mtr) + 10) 183#define MTR_DIMM_COLS_ADDR_BITS(mtr) (MTR_DIMM_COLS(mtr) + 10)
184 184
185#ifdef CONFIG_EDAC_DEBUG
186/* MTR NUMROW */
187static const char *numrow_toString[] = {
188 "8,192 - 13 rows",
189 "16,384 - 14 rows",
190 "32,768 - 15 rows",
191 "65,536 - 16 rows"
192};
193
194/* MTR NUMCOL */
195static const char *numcol_toString[] = {
196 "1,024 - 10 columns",
197 "2,048 - 11 columns",
198 "4,096 - 12 columns",
199 "reserved"
200};
201#endif
202
203/************************************************ 185/************************************************
204 * i7300 Register definitions for error detection 186 * i7300 Register definitions for error detection
205 ************************************************/ 187 ************************************************/
@@ -467,10 +449,10 @@ static void i7300_process_fbd_error(struct mem_ctl_info *mci)
467 "Bank=%d RAS=%d CAS=%d Err=0x%lx (%s))", 449 "Bank=%d RAS=%d CAS=%d Err=0x%lx (%s))",
468 bank, ras, cas, errors, specific); 450 bank, ras, cas, errors, specific);
469 451
470 edac_mc_handle_error(HW_EVENT_ERR_FATAL, mci, 0, 0, 0, 452 edac_mc_handle_error(HW_EVENT_ERR_FATAL, mci, 1, 0, 0, 0,
471 branch, -1, rank, 453 branch, -1, rank,
472 is_wr ? "Write error" : "Read error", 454 is_wr ? "Write error" : "Read error",
473 pvt->tmp_prt_buffer, NULL); 455 pvt->tmp_prt_buffer);
474 456
475 } 457 }
476 458
@@ -513,11 +495,11 @@ static void i7300_process_fbd_error(struct mem_ctl_info *mci)
513 "DRAM-Bank=%d RAS=%d CAS=%d, Err=0x%lx (%s))", 495 "DRAM-Bank=%d RAS=%d CAS=%d, Err=0x%lx (%s))",
514 bank, ras, cas, errors, specific); 496 bank, ras, cas, errors, specific);
515 497
516 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 0, 0, 498 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, 0, 0,
517 syndrome, 499 syndrome,
518 branch >> 1, channel % 2, rank, 500 branch >> 1, channel % 2, rank,
519 is_wr ? "Write error" : "Read error", 501 is_wr ? "Write error" : "Read error",
520 pvt->tmp_prt_buffer, NULL); 502 pvt->tmp_prt_buffer);
521 } 503 }
522 return; 504 return;
523} 505}
@@ -614,9 +596,8 @@ static int decode_mtr(struct i7300_pvt *pvt,
614 mtr = pvt->mtr[slot][branch]; 596 mtr = pvt->mtr[slot][branch];
615 ans = MTR_DIMMS_PRESENT(mtr) ? 1 : 0; 597 ans = MTR_DIMMS_PRESENT(mtr) ? 1 : 0;
616 598
617 debugf2("\tMTR%d CH%d: DIMMs are %s (mtr)\n", 599 edac_dbg(2, "\tMTR%d CH%d: DIMMs are %sPresent (mtr)\n",
618 slot, channel, 600 slot, channel, ans ? "" : "NOT ");
619 ans ? "Present" : "NOT Present");
620 601
621 /* Determine if there is a DIMM present in this DIMM slot */ 602 /* Determine if there is a DIMM present in this DIMM slot */
622 if (!ans) 603 if (!ans)
@@ -638,16 +619,25 @@ static int decode_mtr(struct i7300_pvt *pvt,
638 619
639 dinfo->megabytes = 1 << addrBits; 620 dinfo->megabytes = 1 << addrBits;
640 621
641 debugf2("\t\tWIDTH: x%d\n", MTR_DRAM_WIDTH(mtr)); 622 edac_dbg(2, "\t\tWIDTH: x%d\n", MTR_DRAM_WIDTH(mtr));
642 623
643 debugf2("\t\tELECTRICAL THROTTLING is %s\n", 624 edac_dbg(2, "\t\tELECTRICAL THROTTLING is %s\n",
644 MTR_DIMMS_ETHROTTLE(mtr) ? "enabled" : "disabled"); 625 MTR_DIMMS_ETHROTTLE(mtr) ? "enabled" : "disabled");
645 626
646 debugf2("\t\tNUMBANK: %d bank(s)\n", MTR_DRAM_BANKS(mtr)); 627 edac_dbg(2, "\t\tNUMBANK: %d bank(s)\n", MTR_DRAM_BANKS(mtr));
647 debugf2("\t\tNUMRANK: %s\n", MTR_DIMM_RANKS(mtr) ? "double" : "single"); 628 edac_dbg(2, "\t\tNUMRANK: %s\n",
648 debugf2("\t\tNUMROW: %s\n", numrow_toString[MTR_DIMM_ROWS(mtr)]); 629 MTR_DIMM_RANKS(mtr) ? "double" : "single");
649 debugf2("\t\tNUMCOL: %s\n", numcol_toString[MTR_DIMM_COLS(mtr)]); 630 edac_dbg(2, "\t\tNUMROW: %s\n",
650 debugf2("\t\tSIZE: %d MB\n", dinfo->megabytes); 631 MTR_DIMM_ROWS(mtr) == 0 ? "8,192 - 13 rows" :
632 MTR_DIMM_ROWS(mtr) == 1 ? "16,384 - 14 rows" :
633 MTR_DIMM_ROWS(mtr) == 2 ? "32,768 - 15 rows" :
634 "65,536 - 16 rows");
635 edac_dbg(2, "\t\tNUMCOL: %s\n",
636 MTR_DIMM_COLS(mtr) == 0 ? "1,024 - 10 columns" :
637 MTR_DIMM_COLS(mtr) == 1 ? "2,048 - 11 columns" :
638 MTR_DIMM_COLS(mtr) == 2 ? "4,096 - 12 columns" :
639 "reserved");
640 edac_dbg(2, "\t\tSIZE: %d MB\n", dinfo->megabytes);
651 641
652 /* 642 /*
653 * The type of error detection actually depends of the 643 * The type of error detection actually depends of the
@@ -663,9 +653,9 @@ static int decode_mtr(struct i7300_pvt *pvt,
663 dimm->mtype = MEM_FB_DDR2; 653 dimm->mtype = MEM_FB_DDR2;
664 if (IS_SINGLE_MODE(pvt->mc_settings_a)) { 654 if (IS_SINGLE_MODE(pvt->mc_settings_a)) {
665 dimm->edac_mode = EDAC_SECDED; 655 dimm->edac_mode = EDAC_SECDED;
666 debugf2("\t\tECC code is 8-byte-over-32-byte SECDED+ code\n"); 656 edac_dbg(2, "\t\tECC code is 8-byte-over-32-byte SECDED+ code\n");
667 } else { 657 } else {
668 debugf2("\t\tECC code is on Lockstep mode\n"); 658 edac_dbg(2, "\t\tECC code is on Lockstep mode\n");
669 if (MTR_DRAM_WIDTH(mtr) == 8) 659 if (MTR_DRAM_WIDTH(mtr) == 8)
670 dimm->edac_mode = EDAC_S8ECD8ED; 660 dimm->edac_mode = EDAC_S8ECD8ED;
671 else 661 else
@@ -674,9 +664,9 @@ static int decode_mtr(struct i7300_pvt *pvt,
674 664
675 /* ask what device type on this row */ 665 /* ask what device type on this row */
676 if (MTR_DRAM_WIDTH(mtr) == 8) { 666 if (MTR_DRAM_WIDTH(mtr) == 8) {
677 debugf2("\t\tScrub algorithm for x8 is on %s mode\n", 667 edac_dbg(2, "\t\tScrub algorithm for x8 is on %s mode\n",
678 IS_SCRBALGO_ENHANCED(pvt->mc_settings) ? 668 IS_SCRBALGO_ENHANCED(pvt->mc_settings) ?
679 "enhanced" : "normal"); 669 "enhanced" : "normal");
680 670
681 dimm->dtype = DEV_X8; 671 dimm->dtype = DEV_X8;
682 } else 672 } else
@@ -710,14 +700,14 @@ static void print_dimm_size(struct i7300_pvt *pvt)
710 p += n; 700 p += n;
711 space -= n; 701 space -= n;
712 } 702 }
713 debugf2("%s\n", pvt->tmp_prt_buffer); 703 edac_dbg(2, "%s\n", pvt->tmp_prt_buffer);
714 p = pvt->tmp_prt_buffer; 704 p = pvt->tmp_prt_buffer;
715 space = PAGE_SIZE; 705 space = PAGE_SIZE;
716 n = snprintf(p, space, "-------------------------------" 706 n = snprintf(p, space, "-------------------------------"
717 "------------------------------"); 707 "------------------------------");
718 p += n; 708 p += n;
719 space -= n; 709 space -= n;
720 debugf2("%s\n", pvt->tmp_prt_buffer); 710 edac_dbg(2, "%s\n", pvt->tmp_prt_buffer);
721 p = pvt->tmp_prt_buffer; 711 p = pvt->tmp_prt_buffer;
722 space = PAGE_SIZE; 712 space = PAGE_SIZE;
723 713
@@ -733,7 +723,7 @@ static void print_dimm_size(struct i7300_pvt *pvt)
733 space -= n; 723 space -= n;
734 } 724 }
735 725
736 debugf2("%s\n", pvt->tmp_prt_buffer); 726 edac_dbg(2, "%s\n", pvt->tmp_prt_buffer);
737 p = pvt->tmp_prt_buffer; 727 p = pvt->tmp_prt_buffer;
738 space = PAGE_SIZE; 728 space = PAGE_SIZE;
739 } 729 }
@@ -742,7 +732,7 @@ static void print_dimm_size(struct i7300_pvt *pvt)
742 "------------------------------"); 732 "------------------------------");
743 p += n; 733 p += n;
744 space -= n; 734 space -= n;
745 debugf2("%s\n", pvt->tmp_prt_buffer); 735 edac_dbg(2, "%s\n", pvt->tmp_prt_buffer);
746 p = pvt->tmp_prt_buffer; 736 p = pvt->tmp_prt_buffer;
747 space = PAGE_SIZE; 737 space = PAGE_SIZE;
748#endif 738#endif
@@ -765,7 +755,7 @@ static int i7300_init_csrows(struct mem_ctl_info *mci)
765 755
766 pvt = mci->pvt_info; 756 pvt = mci->pvt_info;
767 757
768 debugf2("Memory Technology Registers:\n"); 758 edac_dbg(2, "Memory Technology Registers:\n");
769 759
770 /* Get the AMB present registers for the four channels */ 760 /* Get the AMB present registers for the four channels */
771 for (branch = 0; branch < MAX_BRANCHES; branch++) { 761 for (branch = 0; branch < MAX_BRANCHES; branch++) {
@@ -774,15 +764,15 @@ static int i7300_init_csrows(struct mem_ctl_info *mci)
774 pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch], 764 pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch],
775 AMBPRESENT_0, 765 AMBPRESENT_0,
776 &pvt->ambpresent[channel]); 766 &pvt->ambpresent[channel]);
777 debugf2("\t\tAMB-present CH%d = 0x%x:\n", 767 edac_dbg(2, "\t\tAMB-present CH%d = 0x%x:\n",
778 channel, pvt->ambpresent[channel]); 768 channel, pvt->ambpresent[channel]);
779 769
780 channel = to_channel(1, branch); 770 channel = to_channel(1, branch);
781 pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch], 771 pci_read_config_word(pvt->pci_dev_2x_0_fbd_branch[branch],
782 AMBPRESENT_1, 772 AMBPRESENT_1,
783 &pvt->ambpresent[channel]); 773 &pvt->ambpresent[channel]);
784 debugf2("\t\tAMB-present CH%d = 0x%x:\n", 774 edac_dbg(2, "\t\tAMB-present CH%d = 0x%x:\n",
785 channel, pvt->ambpresent[channel]); 775 channel, pvt->ambpresent[channel]);
786 } 776 }
787 777
788 /* Get the set of MTR[0-7] regs by each branch */ 778 /* Get the set of MTR[0-7] regs by each branch */
@@ -824,12 +814,11 @@ static int i7300_init_csrows(struct mem_ctl_info *mci)
824static void decode_mir(int mir_no, u16 mir[MAX_MIR]) 814static void decode_mir(int mir_no, u16 mir[MAX_MIR])
825{ 815{
826 if (mir[mir_no] & 3) 816 if (mir[mir_no] & 3)
827 debugf2("MIR%d: limit= 0x%x Branch(es) that participate:" 817 edac_dbg(2, "MIR%d: limit= 0x%x Branch(es) that participate: %s %s\n",
828 " %s %s\n", 818 mir_no,
829 mir_no, 819 (mir[mir_no] >> 4) & 0xfff,
830 (mir[mir_no] >> 4) & 0xfff, 820 (mir[mir_no] & 1) ? "B0" : "",
831 (mir[mir_no] & 1) ? "B0" : "", 821 (mir[mir_no] & 2) ? "B1" : "");
832 (mir[mir_no] & 2) ? "B1" : "");
833} 822}
834 823
835/** 824/**
@@ -849,17 +838,17 @@ static int i7300_get_mc_regs(struct mem_ctl_info *mci)
849 pci_read_config_dword(pvt->pci_dev_16_0_fsb_ctlr, AMBASE, 838 pci_read_config_dword(pvt->pci_dev_16_0_fsb_ctlr, AMBASE,
850 (u32 *) &pvt->ambase); 839 (u32 *) &pvt->ambase);
851 840
852 debugf2("AMBASE= 0x%lx\n", (long unsigned int)pvt->ambase); 841 edac_dbg(2, "AMBASE= 0x%lx\n", (long unsigned int)pvt->ambase);
853 842
854 /* Get the Branch Map regs */ 843 /* Get the Branch Map regs */
855 pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, TOLM, &pvt->tolm); 844 pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, TOLM, &pvt->tolm);
856 pvt->tolm >>= 12; 845 pvt->tolm >>= 12;
857 debugf2("TOLM (number of 256M regions) =%u (0x%x)\n", pvt->tolm, 846 edac_dbg(2, "TOLM (number of 256M regions) =%u (0x%x)\n",
858 pvt->tolm); 847 pvt->tolm, pvt->tolm);
859 848
860 actual_tolm = (u32) ((1000l * pvt->tolm) >> (30 - 28)); 849 actual_tolm = (u32) ((1000l * pvt->tolm) >> (30 - 28));
861 debugf2("Actual TOLM byte addr=%u.%03u GB (0x%x)\n", 850 edac_dbg(2, "Actual TOLM byte addr=%u.%03u GB (0x%x)\n",
862 actual_tolm/1000, actual_tolm % 1000, pvt->tolm << 28); 851 actual_tolm/1000, actual_tolm % 1000, pvt->tolm << 28);
863 852
864 /* Get memory controller settings */ 853 /* Get memory controller settings */
865 pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, MC_SETTINGS, 854 pci_read_config_dword(pvt->pci_dev_16_1_fsb_addr_map, MC_SETTINGS,
@@ -868,15 +857,15 @@ static int i7300_get_mc_regs(struct mem_ctl_info *mci)
868 &pvt->mc_settings_a); 857 &pvt->mc_settings_a);
869 858
870 if (IS_SINGLE_MODE(pvt->mc_settings_a)) 859 if (IS_SINGLE_MODE(pvt->mc_settings_a))
871 debugf0("Memory controller operating on single mode\n"); 860 edac_dbg(0, "Memory controller operating on single mode\n");
872 else 861 else
873 debugf0("Memory controller operating on %s mode\n", 862 edac_dbg(0, "Memory controller operating on %smirrored mode\n",
874 IS_MIRRORED(pvt->mc_settings) ? "mirrored" : "non-mirrored"); 863 IS_MIRRORED(pvt->mc_settings) ? "" : "non-");
875 864
876 debugf0("Error detection is %s\n", 865 edac_dbg(0, "Error detection is %s\n",
877 IS_ECC_ENABLED(pvt->mc_settings) ? "enabled" : "disabled"); 866 IS_ECC_ENABLED(pvt->mc_settings) ? "enabled" : "disabled");
878 debugf0("Retry is %s\n", 867 edac_dbg(0, "Retry is %s\n",
879 IS_RETRY_ENABLED(pvt->mc_settings) ? "enabled" : "disabled"); 868 IS_RETRY_ENABLED(pvt->mc_settings) ? "enabled" : "disabled");
880 869
881 /* Get Memory Interleave Range registers */ 870 /* Get Memory Interleave Range registers */
882 pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, MIR0, 871 pci_read_config_word(pvt->pci_dev_16_1_fsb_addr_map, MIR0,
@@ -970,18 +959,18 @@ static int __devinit i7300_get_devices(struct mem_ctl_info *mci)
970 } 959 }
971 } 960 }
972 961
973 debugf1("System Address, processor bus- PCI Bus ID: %s %x:%x\n", 962 edac_dbg(1, "System Address, processor bus- PCI Bus ID: %s %x:%x\n",
974 pci_name(pvt->pci_dev_16_0_fsb_ctlr), 963 pci_name(pvt->pci_dev_16_0_fsb_ctlr),
975 pvt->pci_dev_16_0_fsb_ctlr->vendor, 964 pvt->pci_dev_16_0_fsb_ctlr->vendor,
976 pvt->pci_dev_16_0_fsb_ctlr->device); 965 pvt->pci_dev_16_0_fsb_ctlr->device);
977 debugf1("Branchmap, control and errors - PCI Bus ID: %s %x:%x\n", 966 edac_dbg(1, "Branchmap, control and errors - PCI Bus ID: %s %x:%x\n",
978 pci_name(pvt->pci_dev_16_1_fsb_addr_map), 967 pci_name(pvt->pci_dev_16_1_fsb_addr_map),
979 pvt->pci_dev_16_1_fsb_addr_map->vendor, 968 pvt->pci_dev_16_1_fsb_addr_map->vendor,
980 pvt->pci_dev_16_1_fsb_addr_map->device); 969 pvt->pci_dev_16_1_fsb_addr_map->device);
981 debugf1("FSB Error Regs - PCI Bus ID: %s %x:%x\n", 970 edac_dbg(1, "FSB Error Regs - PCI Bus ID: %s %x:%x\n",
982 pci_name(pvt->pci_dev_16_2_fsb_err_regs), 971 pci_name(pvt->pci_dev_16_2_fsb_err_regs),
983 pvt->pci_dev_16_2_fsb_err_regs->vendor, 972 pvt->pci_dev_16_2_fsb_err_regs->vendor,
984 pvt->pci_dev_16_2_fsb_err_regs->device); 973 pvt->pci_dev_16_2_fsb_err_regs->device);
985 974
986 pvt->pci_dev_2x_0_fbd_branch[0] = pci_get_device(PCI_VENDOR_ID_INTEL, 975 pvt->pci_dev_2x_0_fbd_branch[0] = pci_get_device(PCI_VENDOR_ID_INTEL,
987 PCI_DEVICE_ID_INTEL_I7300_MCH_FB0, 976 PCI_DEVICE_ID_INTEL_I7300_MCH_FB0,
@@ -1032,10 +1021,9 @@ static int __devinit i7300_init_one(struct pci_dev *pdev,
1032 if (rc == -EIO) 1021 if (rc == -EIO)
1033 return rc; 1022 return rc;
1034 1023
1035 debugf0("MC: " __FILE__ ": %s(), pdev bus %u dev=0x%x fn=0x%x\n", 1024 edac_dbg(0, "MC: pdev bus %u dev=0x%x fn=0x%x\n",
1036 __func__, 1025 pdev->bus->number,
1037 pdev->bus->number, 1026 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
1038 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
1039 1027
1040 /* We only are looking for func 0 of the set */ 1028 /* We only are looking for func 0 of the set */
1041 if (PCI_FUNC(pdev->devfn) != 0) 1029 if (PCI_FUNC(pdev->devfn) != 0)
@@ -1055,9 +1043,9 @@ static int __devinit i7300_init_one(struct pci_dev *pdev,
1055 if (mci == NULL) 1043 if (mci == NULL)
1056 return -ENOMEM; 1044 return -ENOMEM;
1057 1045
1058 debugf0("MC: " __FILE__ ": %s(): mci = %p\n", __func__, mci); 1046 edac_dbg(0, "MC: mci = %p\n", mci);
1059 1047
1060 mci->dev = &pdev->dev; /* record ptr to the generic device */ 1048 mci->pdev = &pdev->dev; /* record ptr to the generic device */
1061 1049
1062 pvt = mci->pvt_info; 1050 pvt = mci->pvt_info;
1063 pvt->pci_dev_16_0_fsb_ctlr = pdev; /* Record this device in our private */ 1051 pvt->pci_dev_16_0_fsb_ctlr = pdev; /* Record this device in our private */
@@ -1088,19 +1076,16 @@ static int __devinit i7300_init_one(struct pci_dev *pdev,
1088 /* initialize the MC control structure 'csrows' table 1076 /* initialize the MC control structure 'csrows' table
1089 * with the mapping and control information */ 1077 * with the mapping and control information */
1090 if (i7300_get_mc_regs(mci)) { 1078 if (i7300_get_mc_regs(mci)) {
1091 debugf0("MC: Setting mci->edac_cap to EDAC_FLAG_NONE\n" 1079 edac_dbg(0, "MC: Setting mci->edac_cap to EDAC_FLAG_NONE because i7300_init_csrows() returned nonzero value\n");
1092 " because i7300_init_csrows() returned nonzero "
1093 "value\n");
1094 mci->edac_cap = EDAC_FLAG_NONE; /* no csrows found */ 1080 mci->edac_cap = EDAC_FLAG_NONE; /* no csrows found */
1095 } else { 1081 } else {
1096 debugf1("MC: Enable error reporting now\n"); 1082 edac_dbg(1, "MC: Enable error reporting now\n");
1097 i7300_enable_error_reporting(mci); 1083 i7300_enable_error_reporting(mci);
1098 } 1084 }
1099 1085
1100 /* add this new MC control structure to EDAC's list of MCs */ 1086 /* add this new MC control structure to EDAC's list of MCs */
1101 if (edac_mc_add_mc(mci)) { 1087 if (edac_mc_add_mc(mci)) {
1102 debugf0("MC: " __FILE__ 1088 edac_dbg(0, "MC: failed edac_mc_add_mc()\n");
1103 ": %s(): failed edac_mc_add_mc()\n", __func__);
1104 /* FIXME: perhaps some code should go here that disables error 1089 /* FIXME: perhaps some code should go here that disables error
1105 * reporting if we just enabled it 1090 * reporting if we just enabled it
1106 */ 1091 */
@@ -1142,7 +1127,7 @@ static void __devexit i7300_remove_one(struct pci_dev *pdev)
1142 struct mem_ctl_info *mci; 1127 struct mem_ctl_info *mci;
1143 char *tmp; 1128 char *tmp;
1144 1129
1145 debugf0(__FILE__ ": %s()\n", __func__); 1130 edac_dbg(0, "\n");
1146 1131
1147 if (i7300_pci) 1132 if (i7300_pci)
1148 edac_pci_release_generic_ctl(i7300_pci); 1133 edac_pci_release_generic_ctl(i7300_pci);
@@ -1189,7 +1174,7 @@ static int __init i7300_init(void)
1189{ 1174{
1190 int pci_rc; 1175 int pci_rc;
1191 1176
1192 debugf2("MC: " __FILE__ ": %s()\n", __func__); 1177 edac_dbg(2, "\n");
1193 1178
1194 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 1179 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
1195 opstate_init(); 1180 opstate_init();
@@ -1204,7 +1189,7 @@ static int __init i7300_init(void)
1204 */ 1189 */
1205static void __exit i7300_exit(void) 1190static void __exit i7300_exit(void)
1206{ 1191{
1207 debugf2("MC: " __FILE__ ": %s()\n", __func__); 1192 edac_dbg(2, "\n");
1208 pci_unregister_driver(&i7300_driver); 1193 pci_unregister_driver(&i7300_driver);
1209} 1194}
1210 1195
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index a499c7ed820a..3672101023bd 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -248,6 +248,8 @@ struct i7core_dev {
248}; 248};
249 249
250struct i7core_pvt { 250struct i7core_pvt {
251 struct device *addrmatch_dev, *chancounts_dev;
252
251 struct pci_dev *pci_noncore; 253 struct pci_dev *pci_noncore;
252 struct pci_dev *pci_mcr[MAX_MCR_FUNC + 1]; 254 struct pci_dev *pci_mcr[MAX_MCR_FUNC + 1];
253 struct pci_dev *pci_ch[NUM_CHANS][MAX_CHAN_FUNC + 1]; 255 struct pci_dev *pci_ch[NUM_CHANS][MAX_CHAN_FUNC + 1];
@@ -514,29 +516,28 @@ static int get_dimm_config(struct mem_ctl_info *mci)
514 pci_read_config_dword(pdev, MC_MAX_DOD, &pvt->info.max_dod); 516 pci_read_config_dword(pdev, MC_MAX_DOD, &pvt->info.max_dod);
515 pci_read_config_dword(pdev, MC_CHANNEL_MAPPER, &pvt->info.ch_map); 517 pci_read_config_dword(pdev, MC_CHANNEL_MAPPER, &pvt->info.ch_map);
516 518
517 debugf0("QPI %d control=0x%08x status=0x%08x dod=0x%08x map=0x%08x\n", 519 edac_dbg(0, "QPI %d control=0x%08x status=0x%08x dod=0x%08x map=0x%08x\n",
518 pvt->i7core_dev->socket, pvt->info.mc_control, pvt->info.mc_status, 520 pvt->i7core_dev->socket, pvt->info.mc_control,
519 pvt->info.max_dod, pvt->info.ch_map); 521 pvt->info.mc_status, pvt->info.max_dod, pvt->info.ch_map);
520 522
521 if (ECC_ENABLED(pvt)) { 523 if (ECC_ENABLED(pvt)) {
522 debugf0("ECC enabled with x%d SDCC\n", ECCx8(pvt) ? 8 : 4); 524 edac_dbg(0, "ECC enabled with x%d SDCC\n", ECCx8(pvt) ? 8 : 4);
523 if (ECCx8(pvt)) 525 if (ECCx8(pvt))
524 mode = EDAC_S8ECD8ED; 526 mode = EDAC_S8ECD8ED;
525 else 527 else
526 mode = EDAC_S4ECD4ED; 528 mode = EDAC_S4ECD4ED;
527 } else { 529 } else {
528 debugf0("ECC disabled\n"); 530 edac_dbg(0, "ECC disabled\n");
529 mode = EDAC_NONE; 531 mode = EDAC_NONE;
530 } 532 }
531 533
532 /* FIXME: need to handle the error codes */ 534 /* FIXME: need to handle the error codes */
533 debugf0("DOD Max limits: DIMMS: %d, %d-ranked, %d-banked " 535 edac_dbg(0, "DOD Max limits: DIMMS: %d, %d-ranked, %d-banked x%x x 0x%x\n",
534 "x%x x 0x%x\n", 536 numdimms(pvt->info.max_dod),
535 numdimms(pvt->info.max_dod), 537 numrank(pvt->info.max_dod >> 2),
536 numrank(pvt->info.max_dod >> 2), 538 numbank(pvt->info.max_dod >> 4),
537 numbank(pvt->info.max_dod >> 4), 539 numrow(pvt->info.max_dod >> 6),
538 numrow(pvt->info.max_dod >> 6), 540 numcol(pvt->info.max_dod >> 9));
539 numcol(pvt->info.max_dod >> 9));
540 541
541 for (i = 0; i < NUM_CHANS; i++) { 542 for (i = 0; i < NUM_CHANS; i++) {
542 u32 data, dimm_dod[3], value[8]; 543 u32 data, dimm_dod[3], value[8];
@@ -545,11 +546,11 @@ static int get_dimm_config(struct mem_ctl_info *mci)
545 continue; 546 continue;
546 547
547 if (!CH_ACTIVE(pvt, i)) { 548 if (!CH_ACTIVE(pvt, i)) {
548 debugf0("Channel %i is not active\n", i); 549 edac_dbg(0, "Channel %i is not active\n", i);
549 continue; 550 continue;
550 } 551 }
551 if (CH_DISABLED(pvt, i)) { 552 if (CH_DISABLED(pvt, i)) {
552 debugf0("Channel %i is disabled\n", i); 553 edac_dbg(0, "Channel %i is disabled\n", i);
553 continue; 554 continue;
554 } 555 }
555 556
@@ -580,15 +581,14 @@ static int get_dimm_config(struct mem_ctl_info *mci)
580 pci_read_config_dword(pvt->pci_ch[i][1], 581 pci_read_config_dword(pvt->pci_ch[i][1],
581 MC_DOD_CH_DIMM2, &dimm_dod[2]); 582 MC_DOD_CH_DIMM2, &dimm_dod[2]);
582 583
583 debugf0("Ch%d phy rd%d, wr%d (0x%08x): " 584 edac_dbg(0, "Ch%d phy rd%d, wr%d (0x%08x): %s%s%s%cDIMMs\n",
584 "%s%s%s%cDIMMs\n", 585 i,
585 i, 586 RDLCH(pvt->info.ch_map, i), WRLCH(pvt->info.ch_map, i),
586 RDLCH(pvt->info.ch_map, i), WRLCH(pvt->info.ch_map, i), 587 data,
587 data, 588 pvt->channel[i].is_3dimms_present ? "3DIMMS " : "",
588 pvt->channel[i].is_3dimms_present ? "3DIMMS " : "", 589 pvt->channel[i].is_3dimms_present ? "SINGLE_4R " : "",
589 pvt->channel[i].is_3dimms_present ? "SINGLE_4R " : "", 590 pvt->channel[i].has_4rank ? "HAS_4R " : "",
590 pvt->channel[i].has_4rank ? "HAS_4R " : "", 591 (data & REGISTERED_DIMM) ? 'R' : 'U');
591 (data & REGISTERED_DIMM) ? 'R' : 'U');
592 592
593 for (j = 0; j < 3; j++) { 593 for (j = 0; j < 3; j++) {
594 u32 banks, ranks, rows, cols; 594 u32 banks, ranks, rows, cols;
@@ -607,11 +607,10 @@ static int get_dimm_config(struct mem_ctl_info *mci)
607 /* DDR3 has 8 I/O banks */ 607 /* DDR3 has 8 I/O banks */
608 size = (rows * cols * banks * ranks) >> (20 - 3); 608 size = (rows * cols * banks * ranks) >> (20 - 3);
609 609
610 debugf0("\tdimm %d %d Mb offset: %x, " 610 edac_dbg(0, "\tdimm %d %d Mb offset: %x, bank: %d, rank: %d, row: %#x, col: %#x\n",
611 "bank: %d, rank: %d, row: %#x, col: %#x\n", 611 j, size,
612 j, size, 612 RANKOFFSET(dimm_dod[j]),
613 RANKOFFSET(dimm_dod[j]), 613 banks, ranks, rows, cols);
614 banks, ranks, rows, cols);
615 614
616 npages = MiB_TO_PAGES(size); 615 npages = MiB_TO_PAGES(size);
617 616
@@ -647,12 +646,12 @@ static int get_dimm_config(struct mem_ctl_info *mci)
647 pci_read_config_dword(pdev, MC_SAG_CH_5, &value[5]); 646 pci_read_config_dword(pdev, MC_SAG_CH_5, &value[5]);
648 pci_read_config_dword(pdev, MC_SAG_CH_6, &value[6]); 647 pci_read_config_dword(pdev, MC_SAG_CH_6, &value[6]);
649 pci_read_config_dword(pdev, MC_SAG_CH_7, &value[7]); 648 pci_read_config_dword(pdev, MC_SAG_CH_7, &value[7]);
650 debugf1("\t[%i] DIVBY3\tREMOVED\tOFFSET\n", i); 649 edac_dbg(1, "\t[%i] DIVBY3\tREMOVED\tOFFSET\n", i);
651 for (j = 0; j < 8; j++) 650 for (j = 0; j < 8; j++)
652 debugf1("\t\t%#x\t%#x\t%#x\n", 651 edac_dbg(1, "\t\t%#x\t%#x\t%#x\n",
653 (value[j] >> 27) & 0x1, 652 (value[j] >> 27) & 0x1,
654 (value[j] >> 24) & 0x7, 653 (value[j] >> 24) & 0x7,
655 (value[j] & ((1 << 24) - 1))); 654 (value[j] & ((1 << 24) - 1)));
656 } 655 }
657 656
658 return 0; 657 return 0;
@@ -662,6 +661,8 @@ static int get_dimm_config(struct mem_ctl_info *mci)
662 Error insertion routines 661 Error insertion routines
663 ****************************************************************************/ 662 ****************************************************************************/
664 663
664#define to_mci(k) container_of(k, struct mem_ctl_info, dev)
665
665/* The i7core has independent error injection features per channel. 666/* The i7core has independent error injection features per channel.
666 However, to have a simpler code, we don't allow enabling error injection 667 However, to have a simpler code, we don't allow enabling error injection
667 on more than one channel. 668 on more than one channel.
@@ -691,9 +692,11 @@ static int disable_inject(const struct mem_ctl_info *mci)
691 * bit 0 - refers to the lower 32-byte half cacheline 692 * bit 0 - refers to the lower 32-byte half cacheline
692 * bit 1 - refers to the upper 32-byte half cacheline 693 * bit 1 - refers to the upper 32-byte half cacheline
693 */ 694 */
694static ssize_t i7core_inject_section_store(struct mem_ctl_info *mci, 695static ssize_t i7core_inject_section_store(struct device *dev,
696 struct device_attribute *mattr,
695 const char *data, size_t count) 697 const char *data, size_t count)
696{ 698{
699 struct mem_ctl_info *mci = to_mci(dev);
697 struct i7core_pvt *pvt = mci->pvt_info; 700 struct i7core_pvt *pvt = mci->pvt_info;
698 unsigned long value; 701 unsigned long value;
699 int rc; 702 int rc;
@@ -709,9 +712,11 @@ static ssize_t i7core_inject_section_store(struct mem_ctl_info *mci,
709 return count; 712 return count;
710} 713}
711 714
712static ssize_t i7core_inject_section_show(struct mem_ctl_info *mci, 715static ssize_t i7core_inject_section_show(struct device *dev,
713 char *data) 716 struct device_attribute *mattr,
717 char *data)
714{ 718{
719 struct mem_ctl_info *mci = to_mci(dev);
715 struct i7core_pvt *pvt = mci->pvt_info; 720 struct i7core_pvt *pvt = mci->pvt_info;
716 return sprintf(data, "0x%08x\n", pvt->inject.section); 721 return sprintf(data, "0x%08x\n", pvt->inject.section);
717} 722}
@@ -724,10 +729,12 @@ static ssize_t i7core_inject_section_show(struct mem_ctl_info *mci,
724 * bit 1 - inject ECC error 729 * bit 1 - inject ECC error
725 * bit 2 - inject parity error 730 * bit 2 - inject parity error
726 */ 731 */
727static ssize_t i7core_inject_type_store(struct mem_ctl_info *mci, 732static ssize_t i7core_inject_type_store(struct device *dev,
733 struct device_attribute *mattr,
728 const char *data, size_t count) 734 const char *data, size_t count)
729{ 735{
730 struct i7core_pvt *pvt = mci->pvt_info; 736 struct mem_ctl_info *mci = to_mci(dev);
737struct i7core_pvt *pvt = mci->pvt_info;
731 unsigned long value; 738 unsigned long value;
732 int rc; 739 int rc;
733 740
@@ -742,10 +749,13 @@ static ssize_t i7core_inject_type_store(struct mem_ctl_info *mci,
742 return count; 749 return count;
743} 750}
744 751
745static ssize_t i7core_inject_type_show(struct mem_ctl_info *mci, 752static ssize_t i7core_inject_type_show(struct device *dev,
746 char *data) 753 struct device_attribute *mattr,
754 char *data)
747{ 755{
756 struct mem_ctl_info *mci = to_mci(dev);
748 struct i7core_pvt *pvt = mci->pvt_info; 757 struct i7core_pvt *pvt = mci->pvt_info;
758
749 return sprintf(data, "0x%08x\n", pvt->inject.type); 759 return sprintf(data, "0x%08x\n", pvt->inject.type);
750} 760}
751 761
@@ -759,9 +769,11 @@ static ssize_t i7core_inject_type_show(struct mem_ctl_info *mci,
759 * 23:16 and 31:24). Flipping bits in two symbol pairs will cause an 769 * 23:16 and 31:24). Flipping bits in two symbol pairs will cause an
760 * uncorrectable error to be injected. 770 * uncorrectable error to be injected.
761 */ 771 */
762static ssize_t i7core_inject_eccmask_store(struct mem_ctl_info *mci, 772static ssize_t i7core_inject_eccmask_store(struct device *dev,
763 const char *data, size_t count) 773 struct device_attribute *mattr,
774 const char *data, size_t count)
764{ 775{
776 struct mem_ctl_info *mci = to_mci(dev);
765 struct i7core_pvt *pvt = mci->pvt_info; 777 struct i7core_pvt *pvt = mci->pvt_info;
766 unsigned long value; 778 unsigned long value;
767 int rc; 779 int rc;
@@ -777,10 +789,13 @@ static ssize_t i7core_inject_eccmask_store(struct mem_ctl_info *mci,
777 return count; 789 return count;
778} 790}
779 791
780static ssize_t i7core_inject_eccmask_show(struct mem_ctl_info *mci, 792static ssize_t i7core_inject_eccmask_show(struct device *dev,
781 char *data) 793 struct device_attribute *mattr,
794 char *data)
782{ 795{
796 struct mem_ctl_info *mci = to_mci(dev);
783 struct i7core_pvt *pvt = mci->pvt_info; 797 struct i7core_pvt *pvt = mci->pvt_info;
798
784 return sprintf(data, "0x%08x\n", pvt->inject.eccmask); 799 return sprintf(data, "0x%08x\n", pvt->inject.eccmask);
785} 800}
786 801
@@ -797,14 +812,16 @@ static ssize_t i7core_inject_eccmask_show(struct mem_ctl_info *mci,
797 812
798#define DECLARE_ADDR_MATCH(param, limit) \ 813#define DECLARE_ADDR_MATCH(param, limit) \
799static ssize_t i7core_inject_store_##param( \ 814static ssize_t i7core_inject_store_##param( \
800 struct mem_ctl_info *mci, \ 815 struct device *dev, \
801 const char *data, size_t count) \ 816 struct device_attribute *mattr, \
817 const char *data, size_t count) \
802{ \ 818{ \
819 struct mem_ctl_info *mci = to_mci(dev); \
803 struct i7core_pvt *pvt; \ 820 struct i7core_pvt *pvt; \
804 long value; \ 821 long value; \
805 int rc; \ 822 int rc; \
806 \ 823 \
807 debugf1("%s()\n", __func__); \ 824 edac_dbg(1, "\n"); \
808 pvt = mci->pvt_info; \ 825 pvt = mci->pvt_info; \
809 \ 826 \
810 if (pvt->inject.enable) \ 827 if (pvt->inject.enable) \
@@ -824,13 +841,15 @@ static ssize_t i7core_inject_store_##param( \
824} \ 841} \
825 \ 842 \
826static ssize_t i7core_inject_show_##param( \ 843static ssize_t i7core_inject_show_##param( \
827 struct mem_ctl_info *mci, \ 844 struct device *dev, \
828 char *data) \ 845 struct device_attribute *mattr, \
846 char *data) \
829{ \ 847{ \
848 struct mem_ctl_info *mci = to_mci(dev); \
830 struct i7core_pvt *pvt; \ 849 struct i7core_pvt *pvt; \
831 \ 850 \
832 pvt = mci->pvt_info; \ 851 pvt = mci->pvt_info; \
833 debugf1("%s() pvt=%p\n", __func__, pvt); \ 852 edac_dbg(1, "pvt=%p\n", pvt); \
834 if (pvt->inject.param < 0) \ 853 if (pvt->inject.param < 0) \
835 return sprintf(data, "any\n"); \ 854 return sprintf(data, "any\n"); \
836 else \ 855 else \
@@ -838,14 +857,9 @@ static ssize_t i7core_inject_show_##param( \
838} 857}
839 858
840#define ATTR_ADDR_MATCH(param) \ 859#define ATTR_ADDR_MATCH(param) \
841 { \ 860 static DEVICE_ATTR(param, S_IRUGO | S_IWUSR, \
842 .attr = { \ 861 i7core_inject_show_##param, \
843 .name = #param, \ 862 i7core_inject_store_##param)
844 .mode = (S_IRUGO | S_IWUSR) \
845 }, \
846 .show = i7core_inject_show_##param, \
847 .store = i7core_inject_store_##param, \
848 }
849 863
850DECLARE_ADDR_MATCH(channel, 3); 864DECLARE_ADDR_MATCH(channel, 3);
851DECLARE_ADDR_MATCH(dimm, 3); 865DECLARE_ADDR_MATCH(dimm, 3);
@@ -854,14 +868,21 @@ DECLARE_ADDR_MATCH(bank, 32);
854DECLARE_ADDR_MATCH(page, 0x10000); 868DECLARE_ADDR_MATCH(page, 0x10000);
855DECLARE_ADDR_MATCH(col, 0x4000); 869DECLARE_ADDR_MATCH(col, 0x4000);
856 870
871ATTR_ADDR_MATCH(channel);
872ATTR_ADDR_MATCH(dimm);
873ATTR_ADDR_MATCH(rank);
874ATTR_ADDR_MATCH(bank);
875ATTR_ADDR_MATCH(page);
876ATTR_ADDR_MATCH(col);
877
857static int write_and_test(struct pci_dev *dev, const int where, const u32 val) 878static int write_and_test(struct pci_dev *dev, const int where, const u32 val)
858{ 879{
859 u32 read; 880 u32 read;
860 int count; 881 int count;
861 882
862 debugf0("setting pci %02x:%02x.%x reg=%02x value=%08x\n", 883 edac_dbg(0, "setting pci %02x:%02x.%x reg=%02x value=%08x\n",
863 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), 884 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn),
864 where, val); 885 where, val);
865 886
866 for (count = 0; count < 10; count++) { 887 for (count = 0; count < 10; count++) {
867 if (count) 888 if (count)
@@ -899,9 +920,11 @@ static int write_and_test(struct pci_dev *dev, const int where, const u32 val)
899 * is reliable enough to check if the MC is using the 920 * is reliable enough to check if the MC is using the
900 * three channels. However, this is not clear at the datasheet. 921 * three channels. However, this is not clear at the datasheet.
901 */ 922 */
902static ssize_t i7core_inject_enable_store(struct mem_ctl_info *mci, 923static ssize_t i7core_inject_enable_store(struct device *dev,
903 const char *data, size_t count) 924 struct device_attribute *mattr,
925 const char *data, size_t count)
904{ 926{
927 struct mem_ctl_info *mci = to_mci(dev);
905 struct i7core_pvt *pvt = mci->pvt_info; 928 struct i7core_pvt *pvt = mci->pvt_info;
906 u32 injectmask; 929 u32 injectmask;
907 u64 mask = 0; 930 u64 mask = 0;
@@ -994,17 +1017,18 @@ static ssize_t i7core_inject_enable_store(struct mem_ctl_info *mci,
994 pci_write_config_dword(pvt->pci_noncore, 1017 pci_write_config_dword(pvt->pci_noncore,
995 MC_CFG_CONTROL, 8); 1018 MC_CFG_CONTROL, 8);
996 1019
997 debugf0("Error inject addr match 0x%016llx, ecc 0x%08x," 1020 edac_dbg(0, "Error inject addr match 0x%016llx, ecc 0x%08x, inject 0x%08x\n",
998 " inject 0x%08x\n", 1021 mask, pvt->inject.eccmask, injectmask);
999 mask, pvt->inject.eccmask, injectmask);
1000 1022
1001 1023
1002 return count; 1024 return count;
1003} 1025}
1004 1026
1005static ssize_t i7core_inject_enable_show(struct mem_ctl_info *mci, 1027static ssize_t i7core_inject_enable_show(struct device *dev,
1006 char *data) 1028 struct device_attribute *mattr,
1029 char *data)
1007{ 1030{
1031 struct mem_ctl_info *mci = to_mci(dev);
1008 struct i7core_pvt *pvt = mci->pvt_info; 1032 struct i7core_pvt *pvt = mci->pvt_info;
1009 u32 injectmask; 1033 u32 injectmask;
1010 1034
@@ -1014,7 +1038,7 @@ static ssize_t i7core_inject_enable_show(struct mem_ctl_info *mci,
1014 pci_read_config_dword(pvt->pci_ch[pvt->inject.channel][0], 1038 pci_read_config_dword(pvt->pci_ch[pvt->inject.channel][0],
1015 MC_CHANNEL_ERROR_INJECT, &injectmask); 1039 MC_CHANNEL_ERROR_INJECT, &injectmask);
1016 1040
1017 debugf0("Inject error read: 0x%018x\n", injectmask); 1041 edac_dbg(0, "Inject error read: 0x%018x\n", injectmask);
1018 1042
1019 if (injectmask & 0x0c) 1043 if (injectmask & 0x0c)
1020 pvt->inject.enable = 1; 1044 pvt->inject.enable = 1;
@@ -1024,12 +1048,14 @@ static ssize_t i7core_inject_enable_show(struct mem_ctl_info *mci,
1024 1048
1025#define DECLARE_COUNTER(param) \ 1049#define DECLARE_COUNTER(param) \
1026static ssize_t i7core_show_counter_##param( \ 1050static ssize_t i7core_show_counter_##param( \
1027 struct mem_ctl_info *mci, \ 1051 struct device *dev, \
1028 char *data) \ 1052 struct device_attribute *mattr, \
1053 char *data) \
1029{ \ 1054{ \
1055 struct mem_ctl_info *mci = to_mci(dev); \
1030 struct i7core_pvt *pvt = mci->pvt_info; \ 1056 struct i7core_pvt *pvt = mci->pvt_info; \
1031 \ 1057 \
1032 debugf1("%s() \n", __func__); \ 1058 edac_dbg(1, "\n"); \
1033 if (!pvt->ce_count_available || (pvt->is_registered)) \ 1059 if (!pvt->ce_count_available || (pvt->is_registered)) \
1034 return sprintf(data, "data unavailable\n"); \ 1060 return sprintf(data, "data unavailable\n"); \
1035 return sprintf(data, "%lu\n", \ 1061 return sprintf(data, "%lu\n", \
@@ -1037,121 +1063,179 @@ static ssize_t i7core_show_counter_##param( \
1037} 1063}
1038 1064
1039#define ATTR_COUNTER(param) \ 1065#define ATTR_COUNTER(param) \
1040 { \ 1066 static DEVICE_ATTR(udimm##param, S_IRUGO | S_IWUSR, \
1041 .attr = { \ 1067 i7core_show_counter_##param, \
1042 .name = __stringify(udimm##param), \ 1068 NULL)
1043 .mode = (S_IRUGO | S_IWUSR) \
1044 }, \
1045 .show = i7core_show_counter_##param \
1046 }
1047 1069
1048DECLARE_COUNTER(0); 1070DECLARE_COUNTER(0);
1049DECLARE_COUNTER(1); 1071DECLARE_COUNTER(1);
1050DECLARE_COUNTER(2); 1072DECLARE_COUNTER(2);
1051 1073
1074ATTR_COUNTER(0);
1075ATTR_COUNTER(1);
1076ATTR_COUNTER(2);
1077
1052/* 1078/*
1053 * Sysfs struct 1079 * inject_addrmatch device sysfs struct
1054 */ 1080 */
1055 1081
1056static const struct mcidev_sysfs_attribute i7core_addrmatch_attrs[] = { 1082static struct attribute *i7core_addrmatch_attrs[] = {
1057 ATTR_ADDR_MATCH(channel), 1083 &dev_attr_channel.attr,
1058 ATTR_ADDR_MATCH(dimm), 1084 &dev_attr_dimm.attr,
1059 ATTR_ADDR_MATCH(rank), 1085 &dev_attr_rank.attr,
1060 ATTR_ADDR_MATCH(bank), 1086 &dev_attr_bank.attr,
1061 ATTR_ADDR_MATCH(page), 1087 &dev_attr_page.attr,
1062 ATTR_ADDR_MATCH(col), 1088 &dev_attr_col.attr,
1063 { } /* End of list */ 1089 NULL
1064}; 1090};
1065 1091
1066static const struct mcidev_sysfs_group i7core_inject_addrmatch = { 1092static struct attribute_group addrmatch_grp = {
1067 .name = "inject_addrmatch", 1093 .attrs = i7core_addrmatch_attrs,
1068 .mcidev_attr = i7core_addrmatch_attrs,
1069}; 1094};
1070 1095
1071static const struct mcidev_sysfs_attribute i7core_udimm_counters_attrs[] = { 1096static const struct attribute_group *addrmatch_groups[] = {
1072 ATTR_COUNTER(0), 1097 &addrmatch_grp,
1073 ATTR_COUNTER(1), 1098 NULL
1074 ATTR_COUNTER(2),
1075 { .attr = { .name = NULL } }
1076}; 1099};
1077 1100
1078static const struct mcidev_sysfs_group i7core_udimm_counters = { 1101static void addrmatch_release(struct device *device)
1079 .name = "all_channel_counts", 1102{
1080 .mcidev_attr = i7core_udimm_counters_attrs, 1103 edac_dbg(1, "Releasing device %s\n", dev_name(device));
1104 kfree(device);
1105}
1106
1107static struct device_type addrmatch_type = {
1108 .groups = addrmatch_groups,
1109 .release = addrmatch_release,
1081}; 1110};
1082 1111
1083static const struct mcidev_sysfs_attribute i7core_sysfs_rdimm_attrs[] = { 1112/*
1084 { 1113 * all_channel_counts sysfs struct
1085 .attr = { 1114 */
1086 .name = "inject_section", 1115
1087 .mode = (S_IRUGO | S_IWUSR) 1116static struct attribute *i7core_udimm_counters_attrs[] = {
1088 }, 1117 &dev_attr_udimm0.attr,
1089 .show = i7core_inject_section_show, 1118 &dev_attr_udimm1.attr,
1090 .store = i7core_inject_section_store, 1119 &dev_attr_udimm2.attr,
1091 }, { 1120 NULL
1092 .attr = {
1093 .name = "inject_type",
1094 .mode = (S_IRUGO | S_IWUSR)
1095 },
1096 .show = i7core_inject_type_show,
1097 .store = i7core_inject_type_store,
1098 }, {
1099 .attr = {
1100 .name = "inject_eccmask",
1101 .mode = (S_IRUGO | S_IWUSR)
1102 },
1103 .show = i7core_inject_eccmask_show,
1104 .store = i7core_inject_eccmask_store,
1105 }, {
1106 .grp = &i7core_inject_addrmatch,
1107 }, {
1108 .attr = {
1109 .name = "inject_enable",
1110 .mode = (S_IRUGO | S_IWUSR)
1111 },
1112 .show = i7core_inject_enable_show,
1113 .store = i7core_inject_enable_store,
1114 },
1115 { } /* End of list */
1116}; 1121};
1117 1122
1118static const struct mcidev_sysfs_attribute i7core_sysfs_udimm_attrs[] = { 1123static struct attribute_group all_channel_counts_grp = {
1119 { 1124 .attrs = i7core_udimm_counters_attrs,
1120 .attr = {
1121 .name = "inject_section",
1122 .mode = (S_IRUGO | S_IWUSR)
1123 },
1124 .show = i7core_inject_section_show,
1125 .store = i7core_inject_section_store,
1126 }, {
1127 .attr = {
1128 .name = "inject_type",
1129 .mode = (S_IRUGO | S_IWUSR)
1130 },
1131 .show = i7core_inject_type_show,
1132 .store = i7core_inject_type_store,
1133 }, {
1134 .attr = {
1135 .name = "inject_eccmask",
1136 .mode = (S_IRUGO | S_IWUSR)
1137 },
1138 .show = i7core_inject_eccmask_show,
1139 .store = i7core_inject_eccmask_store,
1140 }, {
1141 .grp = &i7core_inject_addrmatch,
1142 }, {
1143 .attr = {
1144 .name = "inject_enable",
1145 .mode = (S_IRUGO | S_IWUSR)
1146 },
1147 .show = i7core_inject_enable_show,
1148 .store = i7core_inject_enable_store,
1149 }, {
1150 .grp = &i7core_udimm_counters,
1151 },
1152 { } /* End of list */
1153}; 1125};
1154 1126
1127static const struct attribute_group *all_channel_counts_groups[] = {
1128 &all_channel_counts_grp,
1129 NULL
1130};
1131
1132static void all_channel_counts_release(struct device *device)
1133{
1134 edac_dbg(1, "Releasing device %s\n", dev_name(device));
1135 kfree(device);
1136}
1137
1138static struct device_type all_channel_counts_type = {
1139 .groups = all_channel_counts_groups,
1140 .release = all_channel_counts_release,
1141};
1142
1143/*
1144 * inject sysfs attributes
1145 */
1146
1147static DEVICE_ATTR(inject_section, S_IRUGO | S_IWUSR,
1148 i7core_inject_section_show, i7core_inject_section_store);
1149
1150static DEVICE_ATTR(inject_type, S_IRUGO | S_IWUSR,
1151 i7core_inject_type_show, i7core_inject_type_store);
1152
1153
1154static DEVICE_ATTR(inject_eccmask, S_IRUGO | S_IWUSR,
1155 i7core_inject_eccmask_show, i7core_inject_eccmask_store);
1156
1157static DEVICE_ATTR(inject_enable, S_IRUGO | S_IWUSR,
1158 i7core_inject_enable_show, i7core_inject_enable_store);
1159
1160static int i7core_create_sysfs_devices(struct mem_ctl_info *mci)
1161{
1162 struct i7core_pvt *pvt = mci->pvt_info;
1163 int rc;
1164
1165 rc = device_create_file(&mci->dev, &dev_attr_inject_section);
1166 if (rc < 0)
1167 return rc;
1168 rc = device_create_file(&mci->dev, &dev_attr_inject_type);
1169 if (rc < 0)
1170 return rc;
1171 rc = device_create_file(&mci->dev, &dev_attr_inject_eccmask);
1172 if (rc < 0)
1173 return rc;
1174 rc = device_create_file(&mci->dev, &dev_attr_inject_enable);
1175 if (rc < 0)
1176 return rc;
1177
1178 pvt->addrmatch_dev = kzalloc(sizeof(*pvt->addrmatch_dev), GFP_KERNEL);
1179 if (!pvt->addrmatch_dev)
1180 return rc;
1181
1182 pvt->addrmatch_dev->type = &addrmatch_type;
1183 pvt->addrmatch_dev->bus = mci->dev.bus;
1184 device_initialize(pvt->addrmatch_dev);
1185 pvt->addrmatch_dev->parent = &mci->dev;
1186 dev_set_name(pvt->addrmatch_dev, "inject_addrmatch");
1187 dev_set_drvdata(pvt->addrmatch_dev, mci);
1188
1189 edac_dbg(1, "creating %s\n", dev_name(pvt->addrmatch_dev));
1190
1191 rc = device_add(pvt->addrmatch_dev);
1192 if (rc < 0)
1193 return rc;
1194
1195 if (!pvt->is_registered) {
1196 pvt->chancounts_dev = kzalloc(sizeof(*pvt->chancounts_dev),
1197 GFP_KERNEL);
1198 if (!pvt->chancounts_dev) {
1199 put_device(pvt->addrmatch_dev);
1200 device_del(pvt->addrmatch_dev);
1201 return rc;
1202 }
1203
1204 pvt->chancounts_dev->type = &all_channel_counts_type;
1205 pvt->chancounts_dev->bus = mci->dev.bus;
1206 device_initialize(pvt->chancounts_dev);
1207 pvt->chancounts_dev->parent = &mci->dev;
1208 dev_set_name(pvt->chancounts_dev, "all_channel_counts");
1209 dev_set_drvdata(pvt->chancounts_dev, mci);
1210
1211 edac_dbg(1, "creating %s\n", dev_name(pvt->chancounts_dev));
1212
1213 rc = device_add(pvt->chancounts_dev);
1214 if (rc < 0)
1215 return rc;
1216 }
1217 return 0;
1218}
1219
1220static void i7core_delete_sysfs_devices(struct mem_ctl_info *mci)
1221{
1222 struct i7core_pvt *pvt = mci->pvt_info;
1223
1224 edac_dbg(1, "\n");
1225
1226 device_remove_file(&mci->dev, &dev_attr_inject_section);
1227 device_remove_file(&mci->dev, &dev_attr_inject_type);
1228 device_remove_file(&mci->dev, &dev_attr_inject_eccmask);
1229 device_remove_file(&mci->dev, &dev_attr_inject_enable);
1230
1231 if (!pvt->is_registered) {
1232 put_device(pvt->chancounts_dev);
1233 device_del(pvt->chancounts_dev);
1234 }
1235 put_device(pvt->addrmatch_dev);
1236 device_del(pvt->addrmatch_dev);
1237}
1238
1155/**************************************************************************** 1239/****************************************************************************
1156 Device initialization routines: put/get, init/exit 1240 Device initialization routines: put/get, init/exit
1157 ****************************************************************************/ 1241 ****************************************************************************/
@@ -1164,14 +1248,14 @@ static void i7core_put_devices(struct i7core_dev *i7core_dev)
1164{ 1248{
1165 int i; 1249 int i;
1166 1250
1167 debugf0(__FILE__ ": %s()\n", __func__); 1251 edac_dbg(0, "\n");
1168 for (i = 0; i < i7core_dev->n_devs; i++) { 1252 for (i = 0; i < i7core_dev->n_devs; i++) {
1169 struct pci_dev *pdev = i7core_dev->pdev[i]; 1253 struct pci_dev *pdev = i7core_dev->pdev[i];
1170 if (!pdev) 1254 if (!pdev)
1171 continue; 1255 continue;
1172 debugf0("Removing dev %02x:%02x.%d\n", 1256 edac_dbg(0, "Removing dev %02x:%02x.%d\n",
1173 pdev->bus->number, 1257 pdev->bus->number,
1174 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); 1258 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
1175 pci_dev_put(pdev); 1259 pci_dev_put(pdev);
1176 } 1260 }
1177} 1261}
@@ -1214,12 +1298,12 @@ static unsigned i7core_pci_lastbus(void)
1214 1298
1215 while ((b = pci_find_next_bus(b)) != NULL) { 1299 while ((b = pci_find_next_bus(b)) != NULL) {
1216 bus = b->number; 1300 bus = b->number;
1217 debugf0("Found bus %d\n", bus); 1301 edac_dbg(0, "Found bus %d\n", bus);
1218 if (bus > last_bus) 1302 if (bus > last_bus)
1219 last_bus = bus; 1303 last_bus = bus;
1220 } 1304 }
1221 1305
1222 debugf0("Last bus %d\n", last_bus); 1306 edac_dbg(0, "Last bus %d\n", last_bus);
1223 1307
1224 return last_bus; 1308 return last_bus;
1225} 1309}
@@ -1326,10 +1410,10 @@ static int i7core_get_onedevice(struct pci_dev **prev,
1326 return -ENODEV; 1410 return -ENODEV;
1327 } 1411 }
1328 1412
1329 debugf0("Detected socket %d dev %02x:%02x.%d PCI ID %04x:%04x\n", 1413 edac_dbg(0, "Detected socket %d dev %02x:%02x.%d PCI ID %04x:%04x\n",
1330 socket, bus, dev_descr->dev, 1414 socket, bus, dev_descr->dev,
1331 dev_descr->func, 1415 dev_descr->func,
1332 PCI_VENDOR_ID_INTEL, dev_descr->dev_id); 1416 PCI_VENDOR_ID_INTEL, dev_descr->dev_id);
1333 1417
1334 /* 1418 /*
1335 * As stated on drivers/pci/search.c, the reference count for 1419 * As stated on drivers/pci/search.c, the reference count for
@@ -1427,13 +1511,13 @@ static int mci_bind_devs(struct mem_ctl_info *mci,
1427 family = "unknown"; 1511 family = "unknown";
1428 pvt->enable_scrub = false; 1512 pvt->enable_scrub = false;
1429 } 1513 }
1430 debugf0("Detected a processor type %s\n", family); 1514 edac_dbg(0, "Detected a processor type %s\n", family);
1431 } else 1515 } else
1432 goto error; 1516 goto error;
1433 1517
1434 debugf0("Associated fn %d.%d, dev = %p, socket %d\n", 1518 edac_dbg(0, "Associated fn %d.%d, dev = %p, socket %d\n",
1435 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), 1519 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
1436 pdev, i7core_dev->socket); 1520 pdev, i7core_dev->socket);
1437 1521
1438 if (PCI_SLOT(pdev->devfn) == 3 && 1522 if (PCI_SLOT(pdev->devfn) == 3 &&
1439 PCI_FUNC(pdev->devfn) == 2) 1523 PCI_FUNC(pdev->devfn) == 2)
@@ -1452,18 +1536,6 @@ error:
1452/**************************************************************************** 1536/****************************************************************************
1453 Error check routines 1537 Error check routines
1454 ****************************************************************************/ 1538 ****************************************************************************/
1455static void i7core_rdimm_update_errcount(struct mem_ctl_info *mci,
1456 const int chan,
1457 const int dimm,
1458 const int add)
1459{
1460 int i;
1461
1462 for (i = 0; i < add; i++) {
1463 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 0, 0, 0,
1464 chan, dimm, -1, "error", "", NULL);
1465 }
1466}
1467 1539
1468static void i7core_rdimm_update_ce_count(struct mem_ctl_info *mci, 1540static void i7core_rdimm_update_ce_count(struct mem_ctl_info *mci,
1469 const int chan, 1541 const int chan,
@@ -1502,12 +1574,17 @@ static void i7core_rdimm_update_ce_count(struct mem_ctl_info *mci,
1502 1574
1503 /*updated the edac core */ 1575 /*updated the edac core */
1504 if (add0 != 0) 1576 if (add0 != 0)
1505 i7core_rdimm_update_errcount(mci, chan, 0, add0); 1577 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, add0,
1578 0, 0, 0,
1579 chan, 0, -1, "error", "");
1506 if (add1 != 0) 1580 if (add1 != 0)
1507 i7core_rdimm_update_errcount(mci, chan, 1, add1); 1581 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, add1,
1582 0, 0, 0,
1583 chan, 1, -1, "error", "");
1508 if (add2 != 0) 1584 if (add2 != 0)
1509 i7core_rdimm_update_errcount(mci, chan, 2, add2); 1585 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, add2,
1510 1586 0, 0, 0,
1587 chan, 2, -1, "error", "");
1511} 1588}
1512 1589
1513static void i7core_rdimm_check_mc_ecc_err(struct mem_ctl_info *mci) 1590static void i7core_rdimm_check_mc_ecc_err(struct mem_ctl_info *mci)
@@ -1530,8 +1607,8 @@ static void i7core_rdimm_check_mc_ecc_err(struct mem_ctl_info *mci)
1530 pci_read_config_dword(pvt->pci_mcr[2], MC_COR_ECC_CNT_5, 1607 pci_read_config_dword(pvt->pci_mcr[2], MC_COR_ECC_CNT_5,
1531 &rcv[2][1]); 1608 &rcv[2][1]);
1532 for (i = 0 ; i < 3; i++) { 1609 for (i = 0 ; i < 3; i++) {
1533 debugf3("MC_COR_ECC_CNT%d = 0x%x; MC_COR_ECC_CNT%d = 0x%x\n", 1610 edac_dbg(3, "MC_COR_ECC_CNT%d = 0x%x; MC_COR_ECC_CNT%d = 0x%x\n",
1534 (i * 2), rcv[i][0], (i * 2) + 1, rcv[i][1]); 1611 (i * 2), rcv[i][0], (i * 2) + 1, rcv[i][1]);
1535 /*if the channel has 3 dimms*/ 1612 /*if the channel has 3 dimms*/
1536 if (pvt->channel[i].dimms > 2) { 1613 if (pvt->channel[i].dimms > 2) {
1537 new0 = DIMM_BOT_COR_ERR(rcv[i][0]); 1614 new0 = DIMM_BOT_COR_ERR(rcv[i][0]);
@@ -1562,7 +1639,7 @@ static void i7core_udimm_check_mc_ecc_err(struct mem_ctl_info *mci)
1562 int new0, new1, new2; 1639 int new0, new1, new2;
1563 1640
1564 if (!pvt->pci_mcr[4]) { 1641 if (!pvt->pci_mcr[4]) {
1565 debugf0("%s MCR registers not found\n", __func__); 1642 edac_dbg(0, "MCR registers not found\n");
1566 return; 1643 return;
1567 } 1644 }
1568 1645
@@ -1626,7 +1703,7 @@ static void i7core_mce_output_error(struct mem_ctl_info *mci,
1626 const struct mce *m) 1703 const struct mce *m)
1627{ 1704{
1628 struct i7core_pvt *pvt = mci->pvt_info; 1705 struct i7core_pvt *pvt = mci->pvt_info;
1629 char *type, *optype, *err, msg[80]; 1706 char *type, *optype, *err;
1630 enum hw_event_mc_err_type tp_event; 1707 enum hw_event_mc_err_type tp_event;
1631 unsigned long error = m->status & 0x1ff0000l; 1708 unsigned long error = m->status & 0x1ff0000l;
1632 bool uncorrected_error = m->mcgstatus & 1ll << 61; 1709 bool uncorrected_error = m->mcgstatus & 1ll << 61;
@@ -1704,20 +1781,18 @@ static void i7core_mce_output_error(struct mem_ctl_info *mci,
1704 err = "unknown"; 1781 err = "unknown";
1705 } 1782 }
1706 1783
1707 snprintf(msg, sizeof(msg), "count=%d %s", core_err_cnt, optype);
1708
1709 /* 1784 /*
1710 * Call the helper to output message 1785 * Call the helper to output message
1711 * FIXME: what to do if core_err_cnt > 1? Currently, it generates 1786 * FIXME: what to do if core_err_cnt > 1? Currently, it generates
1712 * only one event 1787 * only one event
1713 */ 1788 */
1714 if (uncorrected_error || !pvt->is_registered) 1789 if (uncorrected_error || !pvt->is_registered)
1715 edac_mc_handle_error(tp_event, mci, 1790 edac_mc_handle_error(tp_event, mci, core_err_cnt,
1716 m->addr >> PAGE_SHIFT, 1791 m->addr >> PAGE_SHIFT,
1717 m->addr & ~PAGE_MASK, 1792 m->addr & ~PAGE_MASK,
1718 syndrome, 1793 syndrome,
1719 channel, dimm, -1, 1794 channel, dimm, -1,
1720 err, msg, m); 1795 err, optype);
1721} 1796}
1722 1797
1723/* 1798/*
@@ -2094,8 +2169,7 @@ static void i7core_unregister_mci(struct i7core_dev *i7core_dev)
2094 struct i7core_pvt *pvt; 2169 struct i7core_pvt *pvt;
2095 2170
2096 if (unlikely(!mci || !mci->pvt_info)) { 2171 if (unlikely(!mci || !mci->pvt_info)) {
2097 debugf0("MC: " __FILE__ ": %s(): dev = %p\n", 2172 edac_dbg(0, "MC: dev = %p\n", &i7core_dev->pdev[0]->dev);
2098 __func__, &i7core_dev->pdev[0]->dev);
2099 2173
2100 i7core_printk(KERN_ERR, "Couldn't find mci handler\n"); 2174 i7core_printk(KERN_ERR, "Couldn't find mci handler\n");
2101 return; 2175 return;
@@ -2103,8 +2177,7 @@ static void i7core_unregister_mci(struct i7core_dev *i7core_dev)
2103 2177
2104 pvt = mci->pvt_info; 2178 pvt = mci->pvt_info;
2105 2179
2106 debugf0("MC: " __FILE__ ": %s(): mci = %p, dev = %p\n", 2180 edac_dbg(0, "MC: mci = %p, dev = %p\n", mci, &i7core_dev->pdev[0]->dev);
2107 __func__, mci, &i7core_dev->pdev[0]->dev);
2108 2181
2109 /* Disable scrubrate setting */ 2182 /* Disable scrubrate setting */
2110 if (pvt->enable_scrub) 2183 if (pvt->enable_scrub)
@@ -2114,9 +2187,10 @@ static void i7core_unregister_mci(struct i7core_dev *i7core_dev)
2114 i7core_pci_ctl_release(pvt); 2187 i7core_pci_ctl_release(pvt);
2115 2188
2116 /* Remove MC sysfs nodes */ 2189 /* Remove MC sysfs nodes */
2117 edac_mc_del_mc(mci->dev); 2190 i7core_delete_sysfs_devices(mci);
2191 edac_mc_del_mc(mci->pdev);
2118 2192
2119 debugf1("%s: free mci struct\n", mci->ctl_name); 2193 edac_dbg(1, "%s: free mci struct\n", mci->ctl_name);
2120 kfree(mci->ctl_name); 2194 kfree(mci->ctl_name);
2121 edac_mc_free(mci); 2195 edac_mc_free(mci);
2122 i7core_dev->mci = NULL; 2196 i7core_dev->mci = NULL;
@@ -2142,8 +2216,7 @@ static int i7core_register_mci(struct i7core_dev *i7core_dev)
2142 if (unlikely(!mci)) 2216 if (unlikely(!mci))
2143 return -ENOMEM; 2217 return -ENOMEM;
2144 2218
2145 debugf0("MC: " __FILE__ ": %s(): mci = %p, dev = %p\n", 2219 edac_dbg(0, "MC: mci = %p, dev = %p\n", mci, &i7core_dev->pdev[0]->dev);
2146 __func__, mci, &i7core_dev->pdev[0]->dev);
2147 2220
2148 pvt = mci->pvt_info; 2221 pvt = mci->pvt_info;
2149 memset(pvt, 0, sizeof(*pvt)); 2222 memset(pvt, 0, sizeof(*pvt));
@@ -2172,15 +2245,11 @@ static int i7core_register_mci(struct i7core_dev *i7core_dev)
2172 if (unlikely(rc < 0)) 2245 if (unlikely(rc < 0))
2173 goto fail0; 2246 goto fail0;
2174 2247
2175 if (pvt->is_registered)
2176 mci->mc_driver_sysfs_attributes = i7core_sysfs_rdimm_attrs;
2177 else
2178 mci->mc_driver_sysfs_attributes = i7core_sysfs_udimm_attrs;
2179 2248
2180 /* Get dimm basic config */ 2249 /* Get dimm basic config */
2181 get_dimm_config(mci); 2250 get_dimm_config(mci);
2182 /* record ptr to the generic device */ 2251 /* record ptr to the generic device */
2183 mci->dev = &i7core_dev->pdev[0]->dev; 2252 mci->pdev = &i7core_dev->pdev[0]->dev;
2184 /* Set the function pointer to an actual operation function */ 2253 /* Set the function pointer to an actual operation function */
2185 mci->edac_check = i7core_check_error; 2254 mci->edac_check = i7core_check_error;
2186 2255
@@ -2190,8 +2259,7 @@ static int i7core_register_mci(struct i7core_dev *i7core_dev)
2190 2259
2191 /* add this new MC control structure to EDAC's list of MCs */ 2260 /* add this new MC control structure to EDAC's list of MCs */
2192 if (unlikely(edac_mc_add_mc(mci))) { 2261 if (unlikely(edac_mc_add_mc(mci))) {
2193 debugf0("MC: " __FILE__ 2262 edac_dbg(0, "MC: failed edac_mc_add_mc()\n");
2194 ": %s(): failed edac_mc_add_mc()\n", __func__);
2195 /* FIXME: perhaps some code should go here that disables error 2263 /* FIXME: perhaps some code should go here that disables error
2196 * reporting if we just enabled it 2264 * reporting if we just enabled it
2197 */ 2265 */
@@ -2199,6 +2267,12 @@ static int i7core_register_mci(struct i7core_dev *i7core_dev)
2199 rc = -EINVAL; 2267 rc = -EINVAL;
2200 goto fail0; 2268 goto fail0;
2201 } 2269 }
2270 if (i7core_create_sysfs_devices(mci)) {
2271 edac_dbg(0, "MC: failed to create sysfs nodes\n");
2272 edac_mc_del_mc(mci->pdev);
2273 rc = -EINVAL;
2274 goto fail0;
2275 }
2202 2276
2203 /* Default error mask is any memory */ 2277 /* Default error mask is any memory */
2204 pvt->inject.channel = 0; 2278 pvt->inject.channel = 0;
@@ -2298,7 +2372,7 @@ static void __devexit i7core_remove(struct pci_dev *pdev)
2298{ 2372{
2299 struct i7core_dev *i7core_dev; 2373 struct i7core_dev *i7core_dev;
2300 2374
2301 debugf0(__FILE__ ": %s()\n", __func__); 2375 edac_dbg(0, "\n");
2302 2376
2303 /* 2377 /*
2304 * we have a trouble here: pdev value for removal will be wrong, since 2378 * we have a trouble here: pdev value for removal will be wrong, since
@@ -2347,7 +2421,7 @@ static int __init i7core_init(void)
2347{ 2421{
2348 int pci_rc; 2422 int pci_rc;
2349 2423
2350 debugf2("MC: " __FILE__ ": %s()\n", __func__); 2424 edac_dbg(2, "\n");
2351 2425
2352 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 2426 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
2353 opstate_init(); 2427 opstate_init();
@@ -2374,7 +2448,7 @@ static int __init i7core_init(void)
2374 */ 2448 */
2375static void __exit i7core_exit(void) 2449static void __exit i7core_exit(void)
2376{ 2450{
2377 debugf2("MC: " __FILE__ ": %s()\n", __func__); 2451 edac_dbg(2, "\n");
2378 pci_unregister_driver(&i7core_driver); 2452 pci_unregister_driver(&i7core_driver);
2379 mce_unregister_decode_chain(&i7_mce_dec); 2453 mce_unregister_decode_chain(&i7_mce_dec);
2380} 2454}
diff --git a/drivers/edac/i82443bxgx_edac.c b/drivers/edac/i82443bxgx_edac.c
index 52072c28a8a6..90f303db5d1d 100644
--- a/drivers/edac/i82443bxgx_edac.c
+++ b/drivers/edac/i82443bxgx_edac.c
@@ -124,7 +124,7 @@ static void i82443bxgx_edacmc_get_error_info(struct mem_ctl_info *mci,
124 *info) 124 *info)
125{ 125{
126 struct pci_dev *pdev; 126 struct pci_dev *pdev;
127 pdev = to_pci_dev(mci->dev); 127 pdev = to_pci_dev(mci->pdev);
128 pci_read_config_dword(pdev, I82443BXGX_EAP, &info->eap); 128 pci_read_config_dword(pdev, I82443BXGX_EAP, &info->eap);
129 if (info->eap & I82443BXGX_EAP_OFFSET_SBE) 129 if (info->eap & I82443BXGX_EAP_OFFSET_SBE)
130 /* Clear error to allow next error to be reported [p.61] */ 130 /* Clear error to allow next error to be reported [p.61] */
@@ -156,19 +156,19 @@ static int i82443bxgx_edacmc_process_error_info(struct mem_ctl_info *mci,
156 if (info->eap & I82443BXGX_EAP_OFFSET_SBE) { 156 if (info->eap & I82443BXGX_EAP_OFFSET_SBE) {
157 error_found = 1; 157 error_found = 1;
158 if (handle_errors) 158 if (handle_errors)
159 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 159 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
160 page, pageoffset, 0, 160 page, pageoffset, 0,
161 edac_mc_find_csrow_by_page(mci, page), 161 edac_mc_find_csrow_by_page(mci, page),
162 0, -1, mci->ctl_name, "", NULL); 162 0, -1, mci->ctl_name, "");
163 } 163 }
164 164
165 if (info->eap & I82443BXGX_EAP_OFFSET_MBE) { 165 if (info->eap & I82443BXGX_EAP_OFFSET_MBE) {
166 error_found = 1; 166 error_found = 1;
167 if (handle_errors) 167 if (handle_errors)
168 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 168 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
169 page, pageoffset, 0, 169 page, pageoffset, 0,
170 edac_mc_find_csrow_by_page(mci, page), 170 edac_mc_find_csrow_by_page(mci, page),
171 0, -1, mci->ctl_name, "", NULL); 171 0, -1, mci->ctl_name, "");
172 } 172 }
173 173
174 return error_found; 174 return error_found;
@@ -178,7 +178,7 @@ static void i82443bxgx_edacmc_check(struct mem_ctl_info *mci)
178{ 178{
179 struct i82443bxgx_edacmc_error_info info; 179 struct i82443bxgx_edacmc_error_info info;
180 180
181 debugf1("MC%d: %s: %s()\n", mci->mc_idx, __FILE__, __func__); 181 edac_dbg(1, "MC%d\n", mci->mc_idx);
182 i82443bxgx_edacmc_get_error_info(mci, &info); 182 i82443bxgx_edacmc_get_error_info(mci, &info);
183 i82443bxgx_edacmc_process_error_info(mci, &info, 1); 183 i82443bxgx_edacmc_process_error_info(mci, &info, 1);
184} 184}
@@ -197,18 +197,17 @@ static void i82443bxgx_init_csrows(struct mem_ctl_info *mci,
197 pci_read_config_byte(pdev, I82443BXGX_DRAMC, &dramc); 197 pci_read_config_byte(pdev, I82443BXGX_DRAMC, &dramc);
198 row_high_limit_last = 0; 198 row_high_limit_last = 0;
199 for (index = 0; index < mci->nr_csrows; index++) { 199 for (index = 0; index < mci->nr_csrows; index++) {
200 csrow = &mci->csrows[index]; 200 csrow = mci->csrows[index];
201 dimm = csrow->channels[0].dimm; 201 dimm = csrow->channels[0]->dimm;
202 202
203 pci_read_config_byte(pdev, I82443BXGX_DRB + index, &drbar); 203 pci_read_config_byte(pdev, I82443BXGX_DRB + index, &drbar);
204 debugf1("MC%d: %s: %s() Row=%d DRB = %#0x\n", 204 edac_dbg(1, "MC%d: Row=%d DRB = %#0x\n",
205 mci->mc_idx, __FILE__, __func__, index, drbar); 205 mci->mc_idx, index, drbar);
206 row_high_limit = ((u32) drbar << 23); 206 row_high_limit = ((u32) drbar << 23);
207 /* find the DRAM Chip Select Base address and mask */ 207 /* find the DRAM Chip Select Base address and mask */
208 debugf1("MC%d: %s: %s() Row=%d, " 208 edac_dbg(1, "MC%d: Row=%d, Boundary Address=%#0x, Last = %#0x\n",
209 "Boundary Address=%#0x, Last = %#0x\n", 209 mci->mc_idx, index, row_high_limit,
210 mci->mc_idx, __FILE__, __func__, index, row_high_limit, 210 row_high_limit_last);
211 row_high_limit_last);
212 211
213 /* 440GX goes to 2GB, represented with a DRB of 0. */ 212 /* 440GX goes to 2GB, represented with a DRB of 0. */
214 if (row_high_limit_last && !row_high_limit) 213 if (row_high_limit_last && !row_high_limit)
@@ -241,7 +240,7 @@ static int i82443bxgx_edacmc_probe1(struct pci_dev *pdev, int dev_idx)
241 enum mem_type mtype; 240 enum mem_type mtype;
242 enum edac_type edac_mode; 241 enum edac_type edac_mode;
243 242
244 debugf0("MC: %s: %s()\n", __FILE__, __func__); 243 edac_dbg(0, "MC:\n");
245 244
246 /* Something is really hosed if PCI config space reads from 245 /* Something is really hosed if PCI config space reads from
247 * the MC aren't working. 246 * the MC aren't working.
@@ -259,8 +258,8 @@ static int i82443bxgx_edacmc_probe1(struct pci_dev *pdev, int dev_idx)
259 if (mci == NULL) 258 if (mci == NULL)
260 return -ENOMEM; 259 return -ENOMEM;
261 260
262 debugf0("MC: %s: %s(): mci = %p\n", __FILE__, __func__, mci); 261 edac_dbg(0, "MC: mci = %p\n", mci);
263 mci->dev = &pdev->dev; 262 mci->pdev = &pdev->dev;
264 mci->mtype_cap = MEM_FLAG_EDO | MEM_FLAG_SDR | MEM_FLAG_RDR; 263 mci->mtype_cap = MEM_FLAG_EDO | MEM_FLAG_SDR | MEM_FLAG_RDR;
265 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; 264 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
266 pci_read_config_byte(pdev, I82443BXGX_DRAMC, &dramc); 265 pci_read_config_byte(pdev, I82443BXGX_DRAMC, &dramc);
@@ -275,8 +274,7 @@ static int i82443bxgx_edacmc_probe1(struct pci_dev *pdev, int dev_idx)
275 mtype = MEM_RDR; 274 mtype = MEM_RDR;
276 break; 275 break;
277 default: 276 default:
278 debugf0("Unknown/reserved DRAM type value " 277 edac_dbg(0, "Unknown/reserved DRAM type value in DRAMC register!\n");
279 "in DRAMC register!\n");
280 mtype = -MEM_UNKNOWN; 278 mtype = -MEM_UNKNOWN;
281 } 279 }
282 280
@@ -305,8 +303,7 @@ static int i82443bxgx_edacmc_probe1(struct pci_dev *pdev, int dev_idx)
305 edac_mode = EDAC_SECDED; 303 edac_mode = EDAC_SECDED;
306 break; 304 break;
307 default: 305 default:
308 debugf0("%s(): Unknown/reserved ECC state " 306 edac_dbg(0, "Unknown/reserved ECC state in NBXCFG register!\n");
309 "in NBXCFG register!\n", __func__);
310 edac_mode = EDAC_UNKNOWN; 307 edac_mode = EDAC_UNKNOWN;
311 break; 308 break;
312 } 309 }
@@ -330,7 +327,7 @@ static int i82443bxgx_edacmc_probe1(struct pci_dev *pdev, int dev_idx)
330 mci->ctl_page_to_phys = NULL; 327 mci->ctl_page_to_phys = NULL;
331 328
332 if (edac_mc_add_mc(mci)) { 329 if (edac_mc_add_mc(mci)) {
333 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 330 edac_dbg(3, "failed edac_mc_add_mc()\n");
334 goto fail; 331 goto fail;
335 } 332 }
336 333
@@ -345,7 +342,7 @@ static int i82443bxgx_edacmc_probe1(struct pci_dev *pdev, int dev_idx)
345 __func__); 342 __func__);
346 } 343 }
347 344
348 debugf3("MC: %s: %s(): success\n", __FILE__, __func__); 345 edac_dbg(3, "MC: success\n");
349 return 0; 346 return 0;
350 347
351fail: 348fail:
@@ -361,7 +358,7 @@ static int __devinit i82443bxgx_edacmc_init_one(struct pci_dev *pdev,
361{ 358{
362 int rc; 359 int rc;
363 360
364 debugf0("MC: %s: %s()\n", __FILE__, __func__); 361 edac_dbg(0, "MC:\n");
365 362
366 /* don't need to call pci_enable_device() */ 363 /* don't need to call pci_enable_device() */
367 rc = i82443bxgx_edacmc_probe1(pdev, ent->driver_data); 364 rc = i82443bxgx_edacmc_probe1(pdev, ent->driver_data);
@@ -376,7 +373,7 @@ static void __devexit i82443bxgx_edacmc_remove_one(struct pci_dev *pdev)
376{ 373{
377 struct mem_ctl_info *mci; 374 struct mem_ctl_info *mci;
378 375
379 debugf0("%s: %s()\n", __FILE__, __func__); 376 edac_dbg(0, "\n");
380 377
381 if (i82443bxgx_pci) 378 if (i82443bxgx_pci)
382 edac_pci_release_generic_ctl(i82443bxgx_pci); 379 edac_pci_release_generic_ctl(i82443bxgx_pci);
@@ -428,7 +425,7 @@ static int __init i82443bxgx_edacmc_init(void)
428 id = &i82443bxgx_pci_tbl[i]; 425 id = &i82443bxgx_pci_tbl[i];
429 } 426 }
430 if (!mci_pdev) { 427 if (!mci_pdev) {
431 debugf0("i82443bxgx pci_get_device fail\n"); 428 edac_dbg(0, "i82443bxgx pci_get_device fail\n");
432 pci_rc = -ENODEV; 429 pci_rc = -ENODEV;
433 goto fail1; 430 goto fail1;
434 } 431 }
@@ -436,7 +433,7 @@ static int __init i82443bxgx_edacmc_init(void)
436 pci_rc = i82443bxgx_edacmc_init_one(mci_pdev, i82443bxgx_pci_tbl); 433 pci_rc = i82443bxgx_edacmc_init_one(mci_pdev, i82443bxgx_pci_tbl);
437 434
438 if (pci_rc < 0) { 435 if (pci_rc < 0) {
439 debugf0("i82443bxgx init fail\n"); 436 edac_dbg(0, "i82443bxgx init fail\n");
440 pci_rc = -ENODEV; 437 pci_rc = -ENODEV;
441 goto fail1; 438 goto fail1;
442 } 439 }
diff --git a/drivers/edac/i82860_edac.c b/drivers/edac/i82860_edac.c
index 08045059d10b..1faa74971513 100644
--- a/drivers/edac/i82860_edac.c
+++ b/drivers/edac/i82860_edac.c
@@ -67,7 +67,7 @@ static void i82860_get_error_info(struct mem_ctl_info *mci,
67{ 67{
68 struct pci_dev *pdev; 68 struct pci_dev *pdev;
69 69
70 pdev = to_pci_dev(mci->dev); 70 pdev = to_pci_dev(mci->pdev);
71 71
72 /* 72 /*
73 * This is a mess because there is no atomic way to read all the 73 * This is a mess because there is no atomic way to read all the
@@ -109,25 +109,25 @@ static int i82860_process_error_info(struct mem_ctl_info *mci,
109 return 1; 109 return 1;
110 110
111 if ((info->errsts ^ info->errsts2) & 0x0003) { 111 if ((info->errsts ^ info->errsts2) & 0x0003) {
112 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 0, 0, 0, 112 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0,
113 -1, -1, -1, "UE overwrote CE", "", NULL); 113 -1, -1, -1, "UE overwrote CE", "");
114 info->errsts = info->errsts2; 114 info->errsts = info->errsts2;
115 } 115 }
116 116
117 info->eap >>= PAGE_SHIFT; 117 info->eap >>= PAGE_SHIFT;
118 row = edac_mc_find_csrow_by_page(mci, info->eap); 118 row = edac_mc_find_csrow_by_page(mci, info->eap);
119 dimm = mci->csrows[row].channels[0].dimm; 119 dimm = mci->csrows[row]->channels[0]->dimm;
120 120
121 if (info->errsts & 0x0002) 121 if (info->errsts & 0x0002)
122 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 122 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
123 info->eap, 0, 0, 123 info->eap, 0, 0,
124 dimm->location[0], dimm->location[1], -1, 124 dimm->location[0], dimm->location[1], -1,
125 "i82860 UE", "", NULL); 125 "i82860 UE", "");
126 else 126 else
127 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 127 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
128 info->eap, 0, info->derrsyn, 128 info->eap, 0, info->derrsyn,
129 dimm->location[0], dimm->location[1], -1, 129 dimm->location[0], dimm->location[1], -1,
130 "i82860 CE", "", NULL); 130 "i82860 CE", "");
131 131
132 return 1; 132 return 1;
133} 133}
@@ -136,7 +136,7 @@ static void i82860_check(struct mem_ctl_info *mci)
136{ 136{
137 struct i82860_error_info info; 137 struct i82860_error_info info;
138 138
139 debugf1("MC%d: %s()\n", mci->mc_idx, __func__); 139 edac_dbg(1, "MC%d\n", mci->mc_idx);
140 i82860_get_error_info(mci, &info); 140 i82860_get_error_info(mci, &info);
141 i82860_process_error_info(mci, &info, 1); 141 i82860_process_error_info(mci, &info, 1);
142} 142}
@@ -161,14 +161,13 @@ static void i82860_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev)
161 * in all eight rows. 161 * in all eight rows.
162 */ 162 */
163 for (index = 0; index < mci->nr_csrows; index++) { 163 for (index = 0; index < mci->nr_csrows; index++) {
164 csrow = &mci->csrows[index]; 164 csrow = mci->csrows[index];
165 dimm = csrow->channels[0].dimm; 165 dimm = csrow->channels[0]->dimm;
166 166
167 pci_read_config_word(pdev, I82860_GBA + index * 2, &value); 167 pci_read_config_word(pdev, I82860_GBA + index * 2, &value);
168 cumul_size = (value & I82860_GBA_MASK) << 168 cumul_size = (value & I82860_GBA_MASK) <<
169 (I82860_GBA_SHIFT - PAGE_SHIFT); 169 (I82860_GBA_SHIFT - PAGE_SHIFT);
170 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, 170 edac_dbg(3, "(%d) cumul_size 0x%x\n", index, cumul_size);
171 cumul_size);
172 171
173 if (cumul_size == last_cumul_size) 172 if (cumul_size == last_cumul_size)
174 continue; /* not populated */ 173 continue; /* not populated */
@@ -210,8 +209,8 @@ static int i82860_probe1(struct pci_dev *pdev, int dev_idx)
210 if (!mci) 209 if (!mci)
211 return -ENOMEM; 210 return -ENOMEM;
212 211
213 debugf3("%s(): init mci\n", __func__); 212 edac_dbg(3, "init mci\n");
214 mci->dev = &pdev->dev; 213 mci->pdev = &pdev->dev;
215 mci->mtype_cap = MEM_FLAG_DDR; 214 mci->mtype_cap = MEM_FLAG_DDR;
216 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; 215 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
217 /* I"m not sure about this but I think that all RDRAM is SECDED */ 216 /* I"m not sure about this but I think that all RDRAM is SECDED */
@@ -229,7 +228,7 @@ static int i82860_probe1(struct pci_dev *pdev, int dev_idx)
229 * type of memory controller. The ID is therefore hardcoded to 0. 228 * type of memory controller. The ID is therefore hardcoded to 0.
230 */ 229 */
231 if (edac_mc_add_mc(mci)) { 230 if (edac_mc_add_mc(mci)) {
232 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 231 edac_dbg(3, "failed edac_mc_add_mc()\n");
233 goto fail; 232 goto fail;
234 } 233 }
235 234
@@ -245,7 +244,7 @@ static int i82860_probe1(struct pci_dev *pdev, int dev_idx)
245 } 244 }
246 245
247 /* get this far and it's successful */ 246 /* get this far and it's successful */
248 debugf3("%s(): success\n", __func__); 247 edac_dbg(3, "success\n");
249 248
250 return 0; 249 return 0;
251 250
@@ -260,7 +259,7 @@ static int __devinit i82860_init_one(struct pci_dev *pdev,
260{ 259{
261 int rc; 260 int rc;
262 261
263 debugf0("%s()\n", __func__); 262 edac_dbg(0, "\n");
264 i82860_printk(KERN_INFO, "i82860 init one\n"); 263 i82860_printk(KERN_INFO, "i82860 init one\n");
265 264
266 if (pci_enable_device(pdev) < 0) 265 if (pci_enable_device(pdev) < 0)
@@ -278,7 +277,7 @@ static void __devexit i82860_remove_one(struct pci_dev *pdev)
278{ 277{
279 struct mem_ctl_info *mci; 278 struct mem_ctl_info *mci;
280 279
281 debugf0("%s()\n", __func__); 280 edac_dbg(0, "\n");
282 281
283 if (i82860_pci) 282 if (i82860_pci)
284 edac_pci_release_generic_ctl(i82860_pci); 283 edac_pci_release_generic_ctl(i82860_pci);
@@ -311,7 +310,7 @@ static int __init i82860_init(void)
311{ 310{
312 int pci_rc; 311 int pci_rc;
313 312
314 debugf3("%s()\n", __func__); 313 edac_dbg(3, "\n");
315 314
316 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 315 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
317 opstate_init(); 316 opstate_init();
@@ -324,7 +323,7 @@ static int __init i82860_init(void)
324 PCI_DEVICE_ID_INTEL_82860_0, NULL); 323 PCI_DEVICE_ID_INTEL_82860_0, NULL);
325 324
326 if (mci_pdev == NULL) { 325 if (mci_pdev == NULL) {
327 debugf0("860 pci_get_device fail\n"); 326 edac_dbg(0, "860 pci_get_device fail\n");
328 pci_rc = -ENODEV; 327 pci_rc = -ENODEV;
329 goto fail1; 328 goto fail1;
330 } 329 }
@@ -332,7 +331,7 @@ static int __init i82860_init(void)
332 pci_rc = i82860_init_one(mci_pdev, i82860_pci_tbl); 331 pci_rc = i82860_init_one(mci_pdev, i82860_pci_tbl);
333 332
334 if (pci_rc < 0) { 333 if (pci_rc < 0) {
335 debugf0("860 init fail\n"); 334 edac_dbg(0, "860 init fail\n");
336 pci_rc = -ENODEV; 335 pci_rc = -ENODEV;
337 goto fail1; 336 goto fail1;
338 } 337 }
@@ -352,7 +351,7 @@ fail0:
352 351
353static void __exit i82860_exit(void) 352static void __exit i82860_exit(void)
354{ 353{
355 debugf3("%s()\n", __func__); 354 edac_dbg(3, "\n");
356 355
357 pci_unregister_driver(&i82860_driver); 356 pci_unregister_driver(&i82860_driver);
358 357
diff --git a/drivers/edac/i82875p_edac.c b/drivers/edac/i82875p_edac.c
index b613e31c16e5..3e416b1a6b53 100644
--- a/drivers/edac/i82875p_edac.c
+++ b/drivers/edac/i82875p_edac.c
@@ -189,7 +189,7 @@ static void i82875p_get_error_info(struct mem_ctl_info *mci,
189{ 189{
190 struct pci_dev *pdev; 190 struct pci_dev *pdev;
191 191
192 pdev = to_pci_dev(mci->dev); 192 pdev = to_pci_dev(mci->pdev);
193 193
194 /* 194 /*
195 * This is a mess because there is no atomic way to read all the 195 * This is a mess because there is no atomic way to read all the
@@ -227,7 +227,7 @@ static int i82875p_process_error_info(struct mem_ctl_info *mci,
227{ 227{
228 int row, multi_chan; 228 int row, multi_chan;
229 229
230 multi_chan = mci->csrows[0].nr_channels - 1; 230 multi_chan = mci->csrows[0]->nr_channels - 1;
231 231
232 if (!(info->errsts & 0x0081)) 232 if (!(info->errsts & 0x0081))
233 return 0; 233 return 0;
@@ -236,9 +236,9 @@ static int i82875p_process_error_info(struct mem_ctl_info *mci,
236 return 1; 236 return 1;
237 237
238 if ((info->errsts ^ info->errsts2) & 0x0081) { 238 if ((info->errsts ^ info->errsts2) & 0x0081) {
239 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 0, 0, 0, 239 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0,
240 -1, -1, -1, 240 -1, -1, -1,
241 "UE overwrote CE", "", NULL); 241 "UE overwrote CE", "");
242 info->errsts = info->errsts2; 242 info->errsts = info->errsts2;
243 } 243 }
244 244
@@ -246,15 +246,15 @@ static int i82875p_process_error_info(struct mem_ctl_info *mci,
246 row = edac_mc_find_csrow_by_page(mci, info->eap); 246 row = edac_mc_find_csrow_by_page(mci, info->eap);
247 247
248 if (info->errsts & 0x0080) 248 if (info->errsts & 0x0080)
249 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 249 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
250 info->eap, 0, 0, 250 info->eap, 0, 0,
251 row, -1, -1, 251 row, -1, -1,
252 "i82875p UE", "", NULL); 252 "i82875p UE", "");
253 else 253 else
254 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 254 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
255 info->eap, 0, info->derrsyn, 255 info->eap, 0, info->derrsyn,
256 row, multi_chan ? (info->des & 0x1) : 0, 256 row, multi_chan ? (info->des & 0x1) : 0,
257 -1, "i82875p CE", "", NULL); 257 -1, "i82875p CE", "");
258 258
259 return 1; 259 return 1;
260} 260}
@@ -263,7 +263,7 @@ static void i82875p_check(struct mem_ctl_info *mci)
263{ 263{
264 struct i82875p_error_info info; 264 struct i82875p_error_info info;
265 265
266 debugf1("MC%d: %s()\n", mci->mc_idx, __func__); 266 edac_dbg(1, "MC%d\n", mci->mc_idx);
267 i82875p_get_error_info(mci, &info); 267 i82875p_get_error_info(mci, &info);
268 i82875p_process_error_info(mci, &info, 1); 268 i82875p_process_error_info(mci, &info, 1);
269} 269}
@@ -367,12 +367,11 @@ static void i82875p_init_csrows(struct mem_ctl_info *mci,
367 */ 367 */
368 368
369 for (index = 0; index < mci->nr_csrows; index++) { 369 for (index = 0; index < mci->nr_csrows; index++) {
370 csrow = &mci->csrows[index]; 370 csrow = mci->csrows[index];
371 371
372 value = readb(ovrfl_window + I82875P_DRB + index); 372 value = readb(ovrfl_window + I82875P_DRB + index);
373 cumul_size = value << (I82875P_DRB_SHIFT - PAGE_SHIFT); 373 cumul_size = value << (I82875P_DRB_SHIFT - PAGE_SHIFT);
374 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, 374 edac_dbg(3, "(%d) cumul_size 0x%x\n", index, cumul_size);
375 cumul_size);
376 if (cumul_size == last_cumul_size) 375 if (cumul_size == last_cumul_size)
377 continue; /* not populated */ 376 continue; /* not populated */
378 377
@@ -382,7 +381,7 @@ static void i82875p_init_csrows(struct mem_ctl_info *mci,
382 last_cumul_size = cumul_size; 381 last_cumul_size = cumul_size;
383 382
384 for (j = 0; j < nr_chans; j++) { 383 for (j = 0; j < nr_chans; j++) {
385 dimm = csrow->channels[j].dimm; 384 dimm = csrow->channels[j]->dimm;
386 385
387 dimm->nr_pages = nr_pages / nr_chans; 386 dimm->nr_pages = nr_pages / nr_chans;
388 dimm->grain = 1 << 12; /* I82875P_EAP has 4KiB reolution */ 387 dimm->grain = 1 << 12; /* I82875P_EAP has 4KiB reolution */
@@ -405,7 +404,7 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
405 u32 nr_chans; 404 u32 nr_chans;
406 struct i82875p_error_info discard; 405 struct i82875p_error_info discard;
407 406
408 debugf0("%s()\n", __func__); 407 edac_dbg(0, "\n");
409 408
410 ovrfl_pdev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL); 409 ovrfl_pdev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL);
411 410
@@ -426,11 +425,8 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
426 goto fail0; 425 goto fail0;
427 } 426 }
428 427
429 /* Keeps mci available after edac_mc_del_mc() till edac_mc_free() */ 428 edac_dbg(3, "init mci\n");
430 kobject_get(&mci->edac_mci_kobj); 429 mci->pdev = &pdev->dev;
431
432 debugf3("%s(): init mci\n", __func__);
433 mci->dev = &pdev->dev;
434 mci->mtype_cap = MEM_FLAG_DDR; 430 mci->mtype_cap = MEM_FLAG_DDR;
435 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; 431 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
436 mci->edac_cap = EDAC_FLAG_UNKNOWN; 432 mci->edac_cap = EDAC_FLAG_UNKNOWN;
@@ -440,7 +436,7 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
440 mci->dev_name = pci_name(pdev); 436 mci->dev_name = pci_name(pdev);
441 mci->edac_check = i82875p_check; 437 mci->edac_check = i82875p_check;
442 mci->ctl_page_to_phys = NULL; 438 mci->ctl_page_to_phys = NULL;
443 debugf3("%s(): init pvt\n", __func__); 439 edac_dbg(3, "init pvt\n");
444 pvt = (struct i82875p_pvt *)mci->pvt_info; 440 pvt = (struct i82875p_pvt *)mci->pvt_info;
445 pvt->ovrfl_pdev = ovrfl_pdev; 441 pvt->ovrfl_pdev = ovrfl_pdev;
446 pvt->ovrfl_window = ovrfl_window; 442 pvt->ovrfl_window = ovrfl_window;
@@ -451,7 +447,7 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
451 * type of memory controller. The ID is therefore hardcoded to 0. 447 * type of memory controller. The ID is therefore hardcoded to 0.
452 */ 448 */
453 if (edac_mc_add_mc(mci)) { 449 if (edac_mc_add_mc(mci)) {
454 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 450 edac_dbg(3, "failed edac_mc_add_mc()\n");
455 goto fail1; 451 goto fail1;
456 } 452 }
457 453
@@ -467,11 +463,10 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
467 } 463 }
468 464
469 /* get this far and it's successful */ 465 /* get this far and it's successful */
470 debugf3("%s(): success\n", __func__); 466 edac_dbg(3, "success\n");
471 return 0; 467 return 0;
472 468
473fail1: 469fail1:
474 kobject_put(&mci->edac_mci_kobj);
475 edac_mc_free(mci); 470 edac_mc_free(mci);
476 471
477fail0: 472fail0:
@@ -489,7 +484,7 @@ static int __devinit i82875p_init_one(struct pci_dev *pdev,
489{ 484{
490 int rc; 485 int rc;
491 486
492 debugf0("%s()\n", __func__); 487 edac_dbg(0, "\n");
493 i82875p_printk(KERN_INFO, "i82875p init one\n"); 488 i82875p_printk(KERN_INFO, "i82875p init one\n");
494 489
495 if (pci_enable_device(pdev) < 0) 490 if (pci_enable_device(pdev) < 0)
@@ -508,7 +503,7 @@ static void __devexit i82875p_remove_one(struct pci_dev *pdev)
508 struct mem_ctl_info *mci; 503 struct mem_ctl_info *mci;
509 struct i82875p_pvt *pvt = NULL; 504 struct i82875p_pvt *pvt = NULL;
510 505
511 debugf0("%s()\n", __func__); 506 edac_dbg(0, "\n");
512 507
513 if (i82875p_pci) 508 if (i82875p_pci)
514 edac_pci_release_generic_ctl(i82875p_pci); 509 edac_pci_release_generic_ctl(i82875p_pci);
@@ -554,7 +549,7 @@ static int __init i82875p_init(void)
554{ 549{
555 int pci_rc; 550 int pci_rc;
556 551
557 debugf3("%s()\n", __func__); 552 edac_dbg(3, "\n");
558 553
559 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 554 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
560 opstate_init(); 555 opstate_init();
@@ -569,7 +564,7 @@ static int __init i82875p_init(void)
569 PCI_DEVICE_ID_INTEL_82875_0, NULL); 564 PCI_DEVICE_ID_INTEL_82875_0, NULL);
570 565
571 if (!mci_pdev) { 566 if (!mci_pdev) {
572 debugf0("875p pci_get_device fail\n"); 567 edac_dbg(0, "875p pci_get_device fail\n");
573 pci_rc = -ENODEV; 568 pci_rc = -ENODEV;
574 goto fail1; 569 goto fail1;
575 } 570 }
@@ -577,7 +572,7 @@ static int __init i82875p_init(void)
577 pci_rc = i82875p_init_one(mci_pdev, i82875p_pci_tbl); 572 pci_rc = i82875p_init_one(mci_pdev, i82875p_pci_tbl);
578 573
579 if (pci_rc < 0) { 574 if (pci_rc < 0) {
580 debugf0("875p init fail\n"); 575 edac_dbg(0, "875p init fail\n");
581 pci_rc = -ENODEV; 576 pci_rc = -ENODEV;
582 goto fail1; 577 goto fail1;
583 } 578 }
@@ -597,7 +592,7 @@ fail0:
597 592
598static void __exit i82875p_exit(void) 593static void __exit i82875p_exit(void)
599{ 594{
600 debugf3("%s()\n", __func__); 595 edac_dbg(3, "\n");
601 596
602 i82875p_remove_one(mci_pdev); 597 i82875p_remove_one(mci_pdev);
603 pci_dev_put(mci_pdev); 598 pci_dev_put(mci_pdev);
diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c
index 433332c7cdba..069e26c11c4f 100644
--- a/drivers/edac/i82975x_edac.c
+++ b/drivers/edac/i82975x_edac.c
@@ -241,7 +241,7 @@ static void i82975x_get_error_info(struct mem_ctl_info *mci,
241{ 241{
242 struct pci_dev *pdev; 242 struct pci_dev *pdev;
243 243
244 pdev = to_pci_dev(mci->dev); 244 pdev = to_pci_dev(mci->pdev);
245 245
246 /* 246 /*
247 * This is a mess because there is no atomic way to read all the 247 * This is a mess because there is no atomic way to read all the
@@ -288,8 +288,8 @@ static int i82975x_process_error_info(struct mem_ctl_info *mci,
288 return 1; 288 return 1;
289 289
290 if ((info->errsts ^ info->errsts2) & 0x0003) { 290 if ((info->errsts ^ info->errsts2) & 0x0003) {
291 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 0, 0, 0, 291 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0,
292 -1, -1, -1, "UE overwrote CE", "", NULL); 292 -1, -1, -1, "UE overwrote CE", "");
293 info->errsts = info->errsts2; 293 info->errsts = info->errsts2;
294 } 294 }
295 295
@@ -308,21 +308,21 @@ static int i82975x_process_error_info(struct mem_ctl_info *mci,
308 (info->xeap & 1) ? 1 : 0, info->eap, (unsigned int) page); 308 (info->xeap & 1) ? 1 : 0, info->eap, (unsigned int) page);
309 return 0; 309 return 0;
310 } 310 }
311 chan = (mci->csrows[row].nr_channels == 1) ? 0 : info->eap & 1; 311 chan = (mci->csrows[row]->nr_channels == 1) ? 0 : info->eap & 1;
312 offst = info->eap 312 offst = info->eap
313 & ((1 << PAGE_SHIFT) - 313 & ((1 << PAGE_SHIFT) -
314 (1 << mci->csrows[row].channels[chan].dimm->grain)); 314 (1 << mci->csrows[row]->channels[chan]->dimm->grain));
315 315
316 if (info->errsts & 0x0002) 316 if (info->errsts & 0x0002)
317 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 317 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
318 page, offst, 0, 318 page, offst, 0,
319 row, -1, -1, 319 row, -1, -1,
320 "i82975x UE", "", NULL); 320 "i82975x UE", "");
321 else 321 else
322 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 322 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
323 page, offst, info->derrsyn, 323 page, offst, info->derrsyn,
324 row, chan ? chan : 0, -1, 324 row, chan ? chan : 0, -1,
325 "i82975x CE", "", NULL); 325 "i82975x CE", "");
326 326
327 return 1; 327 return 1;
328} 328}
@@ -331,7 +331,7 @@ static void i82975x_check(struct mem_ctl_info *mci)
331{ 331{
332 struct i82975x_error_info info; 332 struct i82975x_error_info info;
333 333
334 debugf1("MC%d: %s()\n", mci->mc_idx, __func__); 334 edac_dbg(1, "MC%d\n", mci->mc_idx);
335 i82975x_get_error_info(mci, &info); 335 i82975x_get_error_info(mci, &info);
336 i82975x_process_error_info(mci, &info, 1); 336 i82975x_process_error_info(mci, &info, 1);
337} 337}
@@ -394,7 +394,7 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci,
394 */ 394 */
395 395
396 for (index = 0; index < mci->nr_csrows; index++) { 396 for (index = 0; index < mci->nr_csrows; index++) {
397 csrow = &mci->csrows[index]; 397 csrow = mci->csrows[index];
398 398
399 value = readb(mch_window + I82975X_DRB + index + 399 value = readb(mch_window + I82975X_DRB + index +
400 ((index >= 4) ? 0x80 : 0)); 400 ((index >= 4) ? 0x80 : 0));
@@ -406,8 +406,7 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci,
406 */ 406 */
407 if (csrow->nr_channels > 1) 407 if (csrow->nr_channels > 1)
408 cumul_size <<= 1; 408 cumul_size <<= 1;
409 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, 409 edac_dbg(3, "(%d) cumul_size 0x%x\n", index, cumul_size);
410 cumul_size);
411 410
412 nr_pages = cumul_size - last_cumul_size; 411 nr_pages = cumul_size - last_cumul_size;
413 if (!nr_pages) 412 if (!nr_pages)
@@ -421,10 +420,10 @@ static void i82975x_init_csrows(struct mem_ctl_info *mci,
421 */ 420 */
422 dtype = i82975x_dram_type(mch_window, index); 421 dtype = i82975x_dram_type(mch_window, index);
423 for (chan = 0; chan < csrow->nr_channels; chan++) { 422 for (chan = 0; chan < csrow->nr_channels; chan++) {
424 dimm = mci->csrows[index].channels[chan].dimm; 423 dimm = mci->csrows[index]->channels[chan]->dimm;
425 424
426 dimm->nr_pages = nr_pages / csrow->nr_channels; 425 dimm->nr_pages = nr_pages / csrow->nr_channels;
427 strncpy(csrow->channels[chan].dimm->label, 426 strncpy(csrow->channels[chan]->dimm->label,
428 labels[(index >> 1) + (chan * 2)], 427 labels[(index >> 1) + (chan * 2)],
429 EDAC_MC_LABEL_LEN); 428 EDAC_MC_LABEL_LEN);
430 dimm->grain = 1 << 7; /* 128Byte cache-line resolution */ 429 dimm->grain = 1 << 7; /* 128Byte cache-line resolution */
@@ -489,11 +488,11 @@ static int i82975x_probe1(struct pci_dev *pdev, int dev_idx)
489 u8 c1drb[4]; 488 u8 c1drb[4];
490#endif 489#endif
491 490
492 debugf0("%s()\n", __func__); 491 edac_dbg(0, "\n");
493 492
494 pci_read_config_dword(pdev, I82975X_MCHBAR, &mchbar); 493 pci_read_config_dword(pdev, I82975X_MCHBAR, &mchbar);
495 if (!(mchbar & 1)) { 494 if (!(mchbar & 1)) {
496 debugf3("%s(): failed, MCHBAR disabled!\n", __func__); 495 edac_dbg(3, "failed, MCHBAR disabled!\n");
497 goto fail0; 496 goto fail0;
498 } 497 }
499 mchbar &= 0xffffc000; /* bits 31:14 used for 16K window */ 498 mchbar &= 0xffffc000; /* bits 31:14 used for 16K window */
@@ -558,8 +557,8 @@ static int i82975x_probe1(struct pci_dev *pdev, int dev_idx)
558 goto fail1; 557 goto fail1;
559 } 558 }
560 559
561 debugf3("%s(): init mci\n", __func__); 560 edac_dbg(3, "init mci\n");
562 mci->dev = &pdev->dev; 561 mci->pdev = &pdev->dev;
563 mci->mtype_cap = MEM_FLAG_DDR2; 562 mci->mtype_cap = MEM_FLAG_DDR2;
564 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; 563 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
565 mci->edac_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; 564 mci->edac_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
@@ -569,7 +568,7 @@ static int i82975x_probe1(struct pci_dev *pdev, int dev_idx)
569 mci->dev_name = pci_name(pdev); 568 mci->dev_name = pci_name(pdev);
570 mci->edac_check = i82975x_check; 569 mci->edac_check = i82975x_check;
571 mci->ctl_page_to_phys = NULL; 570 mci->ctl_page_to_phys = NULL;
572 debugf3("%s(): init pvt\n", __func__); 571 edac_dbg(3, "init pvt\n");
573 pvt = (struct i82975x_pvt *) mci->pvt_info; 572 pvt = (struct i82975x_pvt *) mci->pvt_info;
574 pvt->mch_window = mch_window; 573 pvt->mch_window = mch_window;
575 i82975x_init_csrows(mci, pdev, mch_window); 574 i82975x_init_csrows(mci, pdev, mch_window);
@@ -578,12 +577,12 @@ static int i82975x_probe1(struct pci_dev *pdev, int dev_idx)
578 577
579 /* finalize this instance of memory controller with edac core */ 578 /* finalize this instance of memory controller with edac core */
580 if (edac_mc_add_mc(mci)) { 579 if (edac_mc_add_mc(mci)) {
581 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 580 edac_dbg(3, "failed edac_mc_add_mc()\n");
582 goto fail2; 581 goto fail2;
583 } 582 }
584 583
585 /* get this far and it's successful */ 584 /* get this far and it's successful */
586 debugf3("%s(): success\n", __func__); 585 edac_dbg(3, "success\n");
587 return 0; 586 return 0;
588 587
589fail2: 588fail2:
@@ -601,7 +600,7 @@ static int __devinit i82975x_init_one(struct pci_dev *pdev,
601{ 600{
602 int rc; 601 int rc;
603 602
604 debugf0("%s()\n", __func__); 603 edac_dbg(0, "\n");
605 604
606 if (pci_enable_device(pdev) < 0) 605 if (pci_enable_device(pdev) < 0)
607 return -EIO; 606 return -EIO;
@@ -619,7 +618,7 @@ static void __devexit i82975x_remove_one(struct pci_dev *pdev)
619 struct mem_ctl_info *mci; 618 struct mem_ctl_info *mci;
620 struct i82975x_pvt *pvt; 619 struct i82975x_pvt *pvt;
621 620
622 debugf0("%s()\n", __func__); 621 edac_dbg(0, "\n");
623 622
624 mci = edac_mc_del_mc(&pdev->dev); 623 mci = edac_mc_del_mc(&pdev->dev);
625 if (mci == NULL) 624 if (mci == NULL)
@@ -655,7 +654,7 @@ static int __init i82975x_init(void)
655{ 654{
656 int pci_rc; 655 int pci_rc;
657 656
658 debugf3("%s()\n", __func__); 657 edac_dbg(3, "\n");
659 658
660 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 659 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
661 opstate_init(); 660 opstate_init();
@@ -669,7 +668,7 @@ static int __init i82975x_init(void)
669 PCI_DEVICE_ID_INTEL_82975_0, NULL); 668 PCI_DEVICE_ID_INTEL_82975_0, NULL);
670 669
671 if (!mci_pdev) { 670 if (!mci_pdev) {
672 debugf0("i82975x pci_get_device fail\n"); 671 edac_dbg(0, "i82975x pci_get_device fail\n");
673 pci_rc = -ENODEV; 672 pci_rc = -ENODEV;
674 goto fail1; 673 goto fail1;
675 } 674 }
@@ -677,7 +676,7 @@ static int __init i82975x_init(void)
677 pci_rc = i82975x_init_one(mci_pdev, i82975x_pci_tbl); 676 pci_rc = i82975x_init_one(mci_pdev, i82975x_pci_tbl);
678 677
679 if (pci_rc < 0) { 678 if (pci_rc < 0) {
680 debugf0("i82975x init fail\n"); 679 edac_dbg(0, "i82975x init fail\n");
681 pci_rc = -ENODEV; 680 pci_rc = -ENODEV;
682 goto fail1; 681 goto fail1;
683 } 682 }
@@ -697,7 +696,7 @@ fail0:
697 696
698static void __exit i82975x_exit(void) 697static void __exit i82975x_exit(void)
699{ 698{
700 debugf3("%s()\n", __func__); 699 edac_dbg(3, "\n");
701 700
702 pci_unregister_driver(&i82975x_driver); 701 pci_unregister_driver(&i82975x_driver);
703 702
diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 0e374625f6f8..a1e791ec25d3 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -49,34 +49,45 @@ static u32 orig_hid1[2];
49 49
50/************************ MC SYSFS parts ***********************************/ 50/************************ MC SYSFS parts ***********************************/
51 51
52static ssize_t mpc85xx_mc_inject_data_hi_show(struct mem_ctl_info *mci, 52#define to_mci(k) container_of(k, struct mem_ctl_info, dev)
53
54static ssize_t mpc85xx_mc_inject_data_hi_show(struct device *dev,
55 struct device_attribute *mattr,
53 char *data) 56 char *data)
54{ 57{
58 struct mem_ctl_info *mci = to_mci(dev);
55 struct mpc85xx_mc_pdata *pdata = mci->pvt_info; 59 struct mpc85xx_mc_pdata *pdata = mci->pvt_info;
56 return sprintf(data, "0x%08x", 60 return sprintf(data, "0x%08x",
57 in_be32(pdata->mc_vbase + 61 in_be32(pdata->mc_vbase +
58 MPC85XX_MC_DATA_ERR_INJECT_HI)); 62 MPC85XX_MC_DATA_ERR_INJECT_HI));
59} 63}
60 64
61static ssize_t mpc85xx_mc_inject_data_lo_show(struct mem_ctl_info *mci, 65static ssize_t mpc85xx_mc_inject_data_lo_show(struct device *dev,
66 struct device_attribute *mattr,
62 char *data) 67 char *data)
63{ 68{
69 struct mem_ctl_info *mci = to_mci(dev);
64 struct mpc85xx_mc_pdata *pdata = mci->pvt_info; 70 struct mpc85xx_mc_pdata *pdata = mci->pvt_info;
65 return sprintf(data, "0x%08x", 71 return sprintf(data, "0x%08x",
66 in_be32(pdata->mc_vbase + 72 in_be32(pdata->mc_vbase +
67 MPC85XX_MC_DATA_ERR_INJECT_LO)); 73 MPC85XX_MC_DATA_ERR_INJECT_LO));
68} 74}
69 75
70static ssize_t mpc85xx_mc_inject_ctrl_show(struct mem_ctl_info *mci, char *data) 76static ssize_t mpc85xx_mc_inject_ctrl_show(struct device *dev,
77 struct device_attribute *mattr,
78 char *data)
71{ 79{
80 struct mem_ctl_info *mci = to_mci(dev);
72 struct mpc85xx_mc_pdata *pdata = mci->pvt_info; 81 struct mpc85xx_mc_pdata *pdata = mci->pvt_info;
73 return sprintf(data, "0x%08x", 82 return sprintf(data, "0x%08x",
74 in_be32(pdata->mc_vbase + MPC85XX_MC_ECC_ERR_INJECT)); 83 in_be32(pdata->mc_vbase + MPC85XX_MC_ECC_ERR_INJECT));
75} 84}
76 85
77static ssize_t mpc85xx_mc_inject_data_hi_store(struct mem_ctl_info *mci, 86static ssize_t mpc85xx_mc_inject_data_hi_store(struct device *dev,
87 struct device_attribute *mattr,
78 const char *data, size_t count) 88 const char *data, size_t count)
79{ 89{
90 struct mem_ctl_info *mci = to_mci(dev);
80 struct mpc85xx_mc_pdata *pdata = mci->pvt_info; 91 struct mpc85xx_mc_pdata *pdata = mci->pvt_info;
81 if (isdigit(*data)) { 92 if (isdigit(*data)) {
82 out_be32(pdata->mc_vbase + MPC85XX_MC_DATA_ERR_INJECT_HI, 93 out_be32(pdata->mc_vbase + MPC85XX_MC_DATA_ERR_INJECT_HI,
@@ -86,9 +97,11 @@ static ssize_t mpc85xx_mc_inject_data_hi_store(struct mem_ctl_info *mci,
86 return 0; 97 return 0;
87} 98}
88 99
89static ssize_t mpc85xx_mc_inject_data_lo_store(struct mem_ctl_info *mci, 100static ssize_t mpc85xx_mc_inject_data_lo_store(struct device *dev,
101 struct device_attribute *mattr,
90 const char *data, size_t count) 102 const char *data, size_t count)
91{ 103{
104 struct mem_ctl_info *mci = to_mci(dev);
92 struct mpc85xx_mc_pdata *pdata = mci->pvt_info; 105 struct mpc85xx_mc_pdata *pdata = mci->pvt_info;
93 if (isdigit(*data)) { 106 if (isdigit(*data)) {
94 out_be32(pdata->mc_vbase + MPC85XX_MC_DATA_ERR_INJECT_LO, 107 out_be32(pdata->mc_vbase + MPC85XX_MC_DATA_ERR_INJECT_LO,
@@ -98,9 +111,11 @@ static ssize_t mpc85xx_mc_inject_data_lo_store(struct mem_ctl_info *mci,
98 return 0; 111 return 0;
99} 112}
100 113
101static ssize_t mpc85xx_mc_inject_ctrl_store(struct mem_ctl_info *mci, 114static ssize_t mpc85xx_mc_inject_ctrl_store(struct device *dev,
102 const char *data, size_t count) 115 struct device_attribute *mattr,
116 const char *data, size_t count)
103{ 117{
118 struct mem_ctl_info *mci = to_mci(dev);
104 struct mpc85xx_mc_pdata *pdata = mci->pvt_info; 119 struct mpc85xx_mc_pdata *pdata = mci->pvt_info;
105 if (isdigit(*data)) { 120 if (isdigit(*data)) {
106 out_be32(pdata->mc_vbase + MPC85XX_MC_ECC_ERR_INJECT, 121 out_be32(pdata->mc_vbase + MPC85XX_MC_ECC_ERR_INJECT,
@@ -110,38 +125,35 @@ static ssize_t mpc85xx_mc_inject_ctrl_store(struct mem_ctl_info *mci,
110 return 0; 125 return 0;
111} 126}
112 127
113static struct mcidev_sysfs_attribute mpc85xx_mc_sysfs_attributes[] = { 128DEVICE_ATTR(inject_data_hi, S_IRUGO | S_IWUSR,
114 { 129 mpc85xx_mc_inject_data_hi_show, mpc85xx_mc_inject_data_hi_store);
115 .attr = { 130DEVICE_ATTR(inject_data_lo, S_IRUGO | S_IWUSR,
116 .name = "inject_data_hi", 131 mpc85xx_mc_inject_data_lo_show, mpc85xx_mc_inject_data_lo_store);
117 .mode = (S_IRUGO | S_IWUSR) 132DEVICE_ATTR(inject_ctrl, S_IRUGO | S_IWUSR,
118 }, 133 mpc85xx_mc_inject_ctrl_show, mpc85xx_mc_inject_ctrl_store);
119 .show = mpc85xx_mc_inject_data_hi_show,
120 .store = mpc85xx_mc_inject_data_hi_store},
121 {
122 .attr = {
123 .name = "inject_data_lo",
124 .mode = (S_IRUGO | S_IWUSR)
125 },
126 .show = mpc85xx_mc_inject_data_lo_show,
127 .store = mpc85xx_mc_inject_data_lo_store},
128 {
129 .attr = {
130 .name = "inject_ctrl",
131 .mode = (S_IRUGO | S_IWUSR)
132 },
133 .show = mpc85xx_mc_inject_ctrl_show,
134 .store = mpc85xx_mc_inject_ctrl_store},
135 134
136 /* End of list */ 135static int mpc85xx_create_sysfs_attributes(struct mem_ctl_info *mci)
137 { 136{
138 .attr = {.name = NULL} 137 int rc;
139 } 138
140}; 139 rc = device_create_file(&mci->dev, &dev_attr_inject_data_hi);
140 if (rc < 0)
141 return rc;
142 rc = device_create_file(&mci->dev, &dev_attr_inject_data_lo);
143 if (rc < 0)
144 return rc;
145 rc = device_create_file(&mci->dev, &dev_attr_inject_ctrl);
146 if (rc < 0)
147 return rc;
141 148
142static void mpc85xx_set_mc_sysfs_attributes(struct mem_ctl_info *mci) 149 return 0;
150}
151
152static void mpc85xx_remove_sysfs_attributes(struct mem_ctl_info *mci)
143{ 153{
144 mci->mc_driver_sysfs_attributes = mpc85xx_mc_sysfs_attributes; 154 device_remove_file(&mci->dev, &dev_attr_inject_data_hi);
155 device_remove_file(&mci->dev, &dev_attr_inject_data_lo);
156 device_remove_file(&mci->dev, &dev_attr_inject_ctrl);
145} 157}
146 158
147/**************************** PCI Err device ***************************/ 159/**************************** PCI Err device ***************************/
@@ -268,7 +280,7 @@ static int __devinit mpc85xx_pci_err_probe(struct platform_device *op)
268 out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR, ~0); 280 out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR, ~0);
269 281
270 if (edac_pci_add_device(pci, pdata->edac_idx) > 0) { 282 if (edac_pci_add_device(pci, pdata->edac_idx) > 0) {
271 debugf3("%s(): failed edac_pci_add_device()\n", __func__); 283 edac_dbg(3, "failed edac_pci_add_device()\n");
272 goto err; 284 goto err;
273 } 285 }
274 286
@@ -291,7 +303,7 @@ static int __devinit mpc85xx_pci_err_probe(struct platform_device *op)
291 } 303 }
292 304
293 devres_remove_group(&op->dev, mpc85xx_pci_err_probe); 305 devres_remove_group(&op->dev, mpc85xx_pci_err_probe);
294 debugf3("%s(): success\n", __func__); 306 edac_dbg(3, "success\n");
295 printk(KERN_INFO EDAC_MOD_STR " PCI err registered\n"); 307 printk(KERN_INFO EDAC_MOD_STR " PCI err registered\n");
296 308
297 return 0; 309 return 0;
@@ -309,7 +321,7 @@ static int mpc85xx_pci_err_remove(struct platform_device *op)
309 struct edac_pci_ctl_info *pci = dev_get_drvdata(&op->dev); 321 struct edac_pci_ctl_info *pci = dev_get_drvdata(&op->dev);
310 struct mpc85xx_pci_pdata *pdata = pci->pvt_info; 322 struct mpc85xx_pci_pdata *pdata = pci->pvt_info;
311 323
312 debugf0("%s()\n", __func__); 324 edac_dbg(0, "\n");
313 325
314 out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR, 326 out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR,
315 orig_pci_err_cap_dr); 327 orig_pci_err_cap_dr);
@@ -570,7 +582,7 @@ static int __devinit mpc85xx_l2_err_probe(struct platform_device *op)
570 pdata->edac_idx = edac_dev_idx++; 582 pdata->edac_idx = edac_dev_idx++;
571 583
572 if (edac_device_add_device(edac_dev) > 0) { 584 if (edac_device_add_device(edac_dev) > 0) {
573 debugf3("%s(): failed edac_device_add_device()\n", __func__); 585 edac_dbg(3, "failed edac_device_add_device()\n");
574 goto err; 586 goto err;
575 } 587 }
576 588
@@ -598,7 +610,7 @@ static int __devinit mpc85xx_l2_err_probe(struct platform_device *op)
598 610
599 devres_remove_group(&op->dev, mpc85xx_l2_err_probe); 611 devres_remove_group(&op->dev, mpc85xx_l2_err_probe);
600 612
601 debugf3("%s(): success\n", __func__); 613 edac_dbg(3, "success\n");
602 printk(KERN_INFO EDAC_MOD_STR " L2 err registered\n"); 614 printk(KERN_INFO EDAC_MOD_STR " L2 err registered\n");
603 615
604 return 0; 616 return 0;
@@ -616,7 +628,7 @@ static int mpc85xx_l2_err_remove(struct platform_device *op)
616 struct edac_device_ctl_info *edac_dev = dev_get_drvdata(&op->dev); 628 struct edac_device_ctl_info *edac_dev = dev_get_drvdata(&op->dev);
617 struct mpc85xx_l2_pdata *pdata = edac_dev->pvt_info; 629 struct mpc85xx_l2_pdata *pdata = edac_dev->pvt_info;
618 630
619 debugf0("%s()\n", __func__); 631 edac_dbg(0, "\n");
620 632
621 if (edac_op_state == EDAC_OPSTATE_INT) { 633 if (edac_op_state == EDAC_OPSTATE_INT) {
622 out_be32(pdata->l2_vbase + MPC85XX_L2_ERRINTEN, 0); 634 out_be32(pdata->l2_vbase + MPC85XX_L2_ERRINTEN, 0);
@@ -813,7 +825,7 @@ static void mpc85xx_mc_check(struct mem_ctl_info *mci)
813 pfn = err_addr >> PAGE_SHIFT; 825 pfn = err_addr >> PAGE_SHIFT;
814 826
815 for (row_index = 0; row_index < mci->nr_csrows; row_index++) { 827 for (row_index = 0; row_index < mci->nr_csrows; row_index++) {
816 csrow = &mci->csrows[row_index]; 828 csrow = mci->csrows[row_index];
817 if ((pfn >= csrow->first_page) && (pfn <= csrow->last_page)) 829 if ((pfn >= csrow->first_page) && (pfn <= csrow->last_page))
818 break; 830 break;
819 } 831 }
@@ -854,16 +866,16 @@ static void mpc85xx_mc_check(struct mem_ctl_info *mci)
854 mpc85xx_mc_printk(mci, KERN_ERR, "PFN out of range!\n"); 866 mpc85xx_mc_printk(mci, KERN_ERR, "PFN out of range!\n");
855 867
856 if (err_detect & DDR_EDE_SBE) 868 if (err_detect & DDR_EDE_SBE)
857 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 869 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
858 pfn, err_addr & ~PAGE_MASK, syndrome, 870 pfn, err_addr & ~PAGE_MASK, syndrome,
859 row_index, 0, -1, 871 row_index, 0, -1,
860 mci->ctl_name, "", NULL); 872 mci->ctl_name, "");
861 873
862 if (err_detect & DDR_EDE_MBE) 874 if (err_detect & DDR_EDE_MBE)
863 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 875 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
864 pfn, err_addr & ~PAGE_MASK, syndrome, 876 pfn, err_addr & ~PAGE_MASK, syndrome,
865 row_index, 0, -1, 877 row_index, 0, -1,
866 mci->ctl_name, "", NULL); 878 mci->ctl_name, "");
867 879
868 out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_DETECT, err_detect); 880 out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_DETECT, err_detect);
869} 881}
@@ -933,8 +945,8 @@ static void __devinit mpc85xx_init_csrows(struct mem_ctl_info *mci)
933 u32 start; 945 u32 start;
934 u32 end; 946 u32 end;
935 947
936 csrow = &mci->csrows[index]; 948 csrow = mci->csrows[index];
937 dimm = csrow->channels[0].dimm; 949 dimm = csrow->channels[0]->dimm;
938 950
939 cs_bnds = in_be32(pdata->mc_vbase + MPC85XX_MC_CS_BNDS_0 + 951 cs_bnds = in_be32(pdata->mc_vbase + MPC85XX_MC_CS_BNDS_0 +
940 (index * MPC85XX_MC_CS_BNDS_OFS)); 952 (index * MPC85XX_MC_CS_BNDS_OFS));
@@ -990,9 +1002,9 @@ static int __devinit mpc85xx_mc_err_probe(struct platform_device *op)
990 pdata = mci->pvt_info; 1002 pdata = mci->pvt_info;
991 pdata->name = "mpc85xx_mc_err"; 1003 pdata->name = "mpc85xx_mc_err";
992 pdata->irq = NO_IRQ; 1004 pdata->irq = NO_IRQ;
993 mci->dev = &op->dev; 1005 mci->pdev = &op->dev;
994 pdata->edac_idx = edac_mc_idx++; 1006 pdata->edac_idx = edac_mc_idx++;
995 dev_set_drvdata(mci->dev, mci); 1007 dev_set_drvdata(mci->pdev, mci);
996 mci->ctl_name = pdata->name; 1008 mci->ctl_name = pdata->name;
997 mci->dev_name = pdata->name; 1009 mci->dev_name = pdata->name;
998 1010
@@ -1026,7 +1038,7 @@ static int __devinit mpc85xx_mc_err_probe(struct platform_device *op)
1026 goto err; 1038 goto err;
1027 } 1039 }
1028 1040
1029 debugf3("%s(): init mci\n", __func__); 1041 edac_dbg(3, "init mci\n");
1030 mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_RDDR2 | 1042 mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_RDDR2 |
1031 MEM_FLAG_DDR | MEM_FLAG_DDR2; 1043 MEM_FLAG_DDR | MEM_FLAG_DDR2;
1032 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; 1044 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
@@ -1041,8 +1053,6 @@ static int __devinit mpc85xx_mc_err_probe(struct platform_device *op)
1041 1053
1042 mci->scrub_mode = SCRUB_SW_SRC; 1054 mci->scrub_mode = SCRUB_SW_SRC;
1043 1055
1044 mpc85xx_set_mc_sysfs_attributes(mci);
1045
1046 mpc85xx_init_csrows(mci); 1056 mpc85xx_init_csrows(mci);
1047 1057
1048 /* store the original error disable bits */ 1058 /* store the original error disable bits */
@@ -1054,7 +1064,13 @@ static int __devinit mpc85xx_mc_err_probe(struct platform_device *op)
1054 out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_DETECT, ~0); 1064 out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_DETECT, ~0);
1055 1065
1056 if (edac_mc_add_mc(mci)) { 1066 if (edac_mc_add_mc(mci)) {
1057 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 1067 edac_dbg(3, "failed edac_mc_add_mc()\n");
1068 goto err;
1069 }
1070
1071 if (mpc85xx_create_sysfs_attributes(mci)) {
1072 edac_mc_del_mc(mci->pdev);
1073 edac_dbg(3, "failed edac_mc_add_mc()\n");
1058 goto err; 1074 goto err;
1059 } 1075 }
1060 1076
@@ -1088,7 +1104,7 @@ static int __devinit mpc85xx_mc_err_probe(struct platform_device *op)
1088 } 1104 }
1089 1105
1090 devres_remove_group(&op->dev, mpc85xx_mc_err_probe); 1106 devres_remove_group(&op->dev, mpc85xx_mc_err_probe);
1091 debugf3("%s(): success\n", __func__); 1107 edac_dbg(3, "success\n");
1092 printk(KERN_INFO EDAC_MOD_STR " MC err registered\n"); 1108 printk(KERN_INFO EDAC_MOD_STR " MC err registered\n");
1093 1109
1094 return 0; 1110 return 0;
@@ -1106,7 +1122,7 @@ static int mpc85xx_mc_err_remove(struct platform_device *op)
1106 struct mem_ctl_info *mci = dev_get_drvdata(&op->dev); 1122 struct mem_ctl_info *mci = dev_get_drvdata(&op->dev);
1107 struct mpc85xx_mc_pdata *pdata = mci->pvt_info; 1123 struct mpc85xx_mc_pdata *pdata = mci->pvt_info;
1108 1124
1109 debugf0("%s()\n", __func__); 1125 edac_dbg(0, "\n");
1110 1126
1111 if (edac_op_state == EDAC_OPSTATE_INT) { 1127 if (edac_op_state == EDAC_OPSTATE_INT) {
1112 out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_INT_EN, 0); 1128 out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_INT_EN, 0);
@@ -1117,6 +1133,7 @@ static int mpc85xx_mc_err_remove(struct platform_device *op)
1117 orig_ddr_err_disable); 1133 orig_ddr_err_disable);
1118 out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_SBE, orig_ddr_err_sbe); 1134 out_be32(pdata->mc_vbase + MPC85XX_MC_ERR_SBE, orig_ddr_err_sbe);
1119 1135
1136 mpc85xx_remove_sysfs_attributes(mci);
1120 edac_mc_del_mc(&op->dev); 1137 edac_mc_del_mc(&op->dev);
1121 edac_mc_free(mci); 1138 edac_mc_free(mci);
1122 return 0; 1139 return 0;
diff --git a/drivers/edac/mv64x60_edac.c b/drivers/edac/mv64x60_edac.c
index b0bb5a3d2527..2b315c2edc3c 100644
--- a/drivers/edac/mv64x60_edac.c
+++ b/drivers/edac/mv64x60_edac.c
@@ -169,7 +169,7 @@ static int __devinit mv64x60_pci_err_probe(struct platform_device *pdev)
169 MV64X60_PCIx_ERR_MASK_VAL); 169 MV64X60_PCIx_ERR_MASK_VAL);
170 170
171 if (edac_pci_add_device(pci, pdata->edac_idx) > 0) { 171 if (edac_pci_add_device(pci, pdata->edac_idx) > 0) {
172 debugf3("%s(): failed edac_pci_add_device()\n", __func__); 172 edac_dbg(3, "failed edac_pci_add_device()\n");
173 goto err; 173 goto err;
174 } 174 }
175 175
@@ -194,7 +194,7 @@ static int __devinit mv64x60_pci_err_probe(struct platform_device *pdev)
194 devres_remove_group(&pdev->dev, mv64x60_pci_err_probe); 194 devres_remove_group(&pdev->dev, mv64x60_pci_err_probe);
195 195
196 /* get this far and it's successful */ 196 /* get this far and it's successful */
197 debugf3("%s(): success\n", __func__); 197 edac_dbg(3, "success\n");
198 198
199 return 0; 199 return 0;
200 200
@@ -210,7 +210,7 @@ static int mv64x60_pci_err_remove(struct platform_device *pdev)
210{ 210{
211 struct edac_pci_ctl_info *pci = platform_get_drvdata(pdev); 211 struct edac_pci_ctl_info *pci = platform_get_drvdata(pdev);
212 212
213 debugf0("%s()\n", __func__); 213 edac_dbg(0, "\n");
214 214
215 edac_pci_del_device(&pdev->dev); 215 edac_pci_del_device(&pdev->dev);
216 216
@@ -336,7 +336,7 @@ static int __devinit mv64x60_sram_err_probe(struct platform_device *pdev)
336 pdata->edac_idx = edac_dev_idx++; 336 pdata->edac_idx = edac_dev_idx++;
337 337
338 if (edac_device_add_device(edac_dev) > 0) { 338 if (edac_device_add_device(edac_dev) > 0) {
339 debugf3("%s(): failed edac_device_add_device()\n", __func__); 339 edac_dbg(3, "failed edac_device_add_device()\n");
340 goto err; 340 goto err;
341 } 341 }
342 342
@@ -363,7 +363,7 @@ static int __devinit mv64x60_sram_err_probe(struct platform_device *pdev)
363 devres_remove_group(&pdev->dev, mv64x60_sram_err_probe); 363 devres_remove_group(&pdev->dev, mv64x60_sram_err_probe);
364 364
365 /* get this far and it's successful */ 365 /* get this far and it's successful */
366 debugf3("%s(): success\n", __func__); 366 edac_dbg(3, "success\n");
367 367
368 return 0; 368 return 0;
369 369
@@ -379,7 +379,7 @@ static int mv64x60_sram_err_remove(struct platform_device *pdev)
379{ 379{
380 struct edac_device_ctl_info *edac_dev = platform_get_drvdata(pdev); 380 struct edac_device_ctl_info *edac_dev = platform_get_drvdata(pdev);
381 381
382 debugf0("%s()\n", __func__); 382 edac_dbg(0, "\n");
383 383
384 edac_device_del_device(&pdev->dev); 384 edac_device_del_device(&pdev->dev);
385 edac_device_free_ctl_info(edac_dev); 385 edac_device_free_ctl_info(edac_dev);
@@ -531,7 +531,7 @@ static int __devinit mv64x60_cpu_err_probe(struct platform_device *pdev)
531 pdata->edac_idx = edac_dev_idx++; 531 pdata->edac_idx = edac_dev_idx++;
532 532
533 if (edac_device_add_device(edac_dev) > 0) { 533 if (edac_device_add_device(edac_dev) > 0) {
534 debugf3("%s(): failed edac_device_add_device()\n", __func__); 534 edac_dbg(3, "failed edac_device_add_device()\n");
535 goto err; 535 goto err;
536 } 536 }
537 537
@@ -558,7 +558,7 @@ static int __devinit mv64x60_cpu_err_probe(struct platform_device *pdev)
558 devres_remove_group(&pdev->dev, mv64x60_cpu_err_probe); 558 devres_remove_group(&pdev->dev, mv64x60_cpu_err_probe);
559 559
560 /* get this far and it's successful */ 560 /* get this far and it's successful */
561 debugf3("%s(): success\n", __func__); 561 edac_dbg(3, "success\n");
562 562
563 return 0; 563 return 0;
564 564
@@ -574,7 +574,7 @@ static int mv64x60_cpu_err_remove(struct platform_device *pdev)
574{ 574{
575 struct edac_device_ctl_info *edac_dev = platform_get_drvdata(pdev); 575 struct edac_device_ctl_info *edac_dev = platform_get_drvdata(pdev);
576 576
577 debugf0("%s()\n", __func__); 577 edac_dbg(0, "\n");
578 578
579 edac_device_del_device(&pdev->dev); 579 edac_device_del_device(&pdev->dev);
580 edac_device_free_ctl_info(edac_dev); 580 edac_device_free_ctl_info(edac_dev);
@@ -611,17 +611,17 @@ static void mv64x60_mc_check(struct mem_ctl_info *mci)
611 611
612 /* first bit clear in ECC Err Reg, 1 bit error, correctable by HW */ 612 /* first bit clear in ECC Err Reg, 1 bit error, correctable by HW */
613 if (!(reg & 0x1)) 613 if (!(reg & 0x1))
614 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 614 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
615 err_addr >> PAGE_SHIFT, 615 err_addr >> PAGE_SHIFT,
616 err_addr & PAGE_MASK, syndrome, 616 err_addr & PAGE_MASK, syndrome,
617 0, 0, -1, 617 0, 0, -1,
618 mci->ctl_name, "", NULL); 618 mci->ctl_name, "");
619 else /* 2 bit error, UE */ 619 else /* 2 bit error, UE */
620 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 620 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
621 err_addr >> PAGE_SHIFT, 621 err_addr >> PAGE_SHIFT,
622 err_addr & PAGE_MASK, 0, 622 err_addr & PAGE_MASK, 0,
623 0, 0, -1, 623 0, 0, -1,
624 mci->ctl_name, "", NULL); 624 mci->ctl_name, "");
625 625
626 /* clear the error */ 626 /* clear the error */
627 out_le32(pdata->mc_vbase + MV64X60_SDRAM_ERR_ADDR, 0); 627 out_le32(pdata->mc_vbase + MV64X60_SDRAM_ERR_ADDR, 0);
@@ -670,8 +670,8 @@ static void mv64x60_init_csrows(struct mem_ctl_info *mci,
670 670
671 ctl = in_le32(pdata->mc_vbase + MV64X60_SDRAM_CONFIG); 671 ctl = in_le32(pdata->mc_vbase + MV64X60_SDRAM_CONFIG);
672 672
673 csrow = &mci->csrows[0]; 673 csrow = mci->csrows[0];
674 dimm = csrow->channels[0].dimm; 674 dimm = csrow->channels[0]->dimm;
675 675
676 dimm->nr_pages = pdata->total_mem >> PAGE_SHIFT; 676 dimm->nr_pages = pdata->total_mem >> PAGE_SHIFT;
677 dimm->grain = 8; 677 dimm->grain = 8;
@@ -724,7 +724,7 @@ static int __devinit mv64x60_mc_err_probe(struct platform_device *pdev)
724 } 724 }
725 725
726 pdata = mci->pvt_info; 726 pdata = mci->pvt_info;
727 mci->dev = &pdev->dev; 727 mci->pdev = &pdev->dev;
728 platform_set_drvdata(pdev, mci); 728 platform_set_drvdata(pdev, mci);
729 pdata->name = "mv64x60_mc_err"; 729 pdata->name = "mv64x60_mc_err";
730 pdata->irq = NO_IRQ; 730 pdata->irq = NO_IRQ;
@@ -766,7 +766,7 @@ static int __devinit mv64x60_mc_err_probe(struct platform_device *pdev)
766 goto err2; 766 goto err2;
767 } 767 }
768 768
769 debugf3("%s(): init mci\n", __func__); 769 edac_dbg(3, "init mci\n");
770 mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR; 770 mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR;
771 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; 771 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
772 mci->edac_cap = EDAC_FLAG_SECDED; 772 mci->edac_cap = EDAC_FLAG_SECDED;
@@ -790,7 +790,7 @@ static int __devinit mv64x60_mc_err_probe(struct platform_device *pdev)
790 out_le32(pdata->mc_vbase + MV64X60_SDRAM_ERR_ECC_CNTL, ctl); 790 out_le32(pdata->mc_vbase + MV64X60_SDRAM_ERR_ECC_CNTL, ctl);
791 791
792 if (edac_mc_add_mc(mci)) { 792 if (edac_mc_add_mc(mci)) {
793 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 793 edac_dbg(3, "failed edac_mc_add_mc()\n");
794 goto err; 794 goto err;
795 } 795 }
796 796
@@ -815,7 +815,7 @@ static int __devinit mv64x60_mc_err_probe(struct platform_device *pdev)
815 } 815 }
816 816
817 /* get this far and it's successful */ 817 /* get this far and it's successful */
818 debugf3("%s(): success\n", __func__); 818 edac_dbg(3, "success\n");
819 819
820 return 0; 820 return 0;
821 821
@@ -831,7 +831,7 @@ static int mv64x60_mc_err_remove(struct platform_device *pdev)
831{ 831{
832 struct mem_ctl_info *mci = platform_get_drvdata(pdev); 832 struct mem_ctl_info *mci = platform_get_drvdata(pdev);
833 833
834 debugf0("%s()\n", __func__); 834 edac_dbg(0, "\n");
835 835
836 edac_mc_del_mc(&pdev->dev); 836 edac_mc_del_mc(&pdev->dev);
837 edac_mc_free(mci); 837 edac_mc_free(mci);
diff --git a/drivers/edac/pasemi_edac.c b/drivers/edac/pasemi_edac.c
index b095a906a994..2d35b78ada3c 100644
--- a/drivers/edac/pasemi_edac.c
+++ b/drivers/edac/pasemi_edac.c
@@ -74,7 +74,7 @@ static int system_mmc_id;
74 74
75static u32 pasemi_edac_get_error_info(struct mem_ctl_info *mci) 75static u32 pasemi_edac_get_error_info(struct mem_ctl_info *mci)
76{ 76{
77 struct pci_dev *pdev = to_pci_dev(mci->dev); 77 struct pci_dev *pdev = to_pci_dev(mci->pdev);
78 u32 tmp; 78 u32 tmp;
79 79
80 pci_read_config_dword(pdev, MCDEBUG_ERRSTA, 80 pci_read_config_dword(pdev, MCDEBUG_ERRSTA,
@@ -95,7 +95,7 @@ static u32 pasemi_edac_get_error_info(struct mem_ctl_info *mci)
95 95
96static void pasemi_edac_process_error_info(struct mem_ctl_info *mci, u32 errsta) 96static void pasemi_edac_process_error_info(struct mem_ctl_info *mci, u32 errsta)
97{ 97{
98 struct pci_dev *pdev = to_pci_dev(mci->dev); 98 struct pci_dev *pdev = to_pci_dev(mci->pdev);
99 u32 errlog1a; 99 u32 errlog1a;
100 u32 cs; 100 u32 cs;
101 101
@@ -110,16 +110,16 @@ static void pasemi_edac_process_error_info(struct mem_ctl_info *mci, u32 errsta)
110 /* uncorrectable/multi-bit errors */ 110 /* uncorrectable/multi-bit errors */
111 if (errsta & (MCDEBUG_ERRSTA_MBE_STATUS | 111 if (errsta & (MCDEBUG_ERRSTA_MBE_STATUS |
112 MCDEBUG_ERRSTA_RFL_STATUS)) { 112 MCDEBUG_ERRSTA_RFL_STATUS)) {
113 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 113 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
114 mci->csrows[cs].first_page, 0, 0, 114 mci->csrows[cs]->first_page, 0, 0,
115 cs, 0, -1, mci->ctl_name, "", NULL); 115 cs, 0, -1, mci->ctl_name, "");
116 } 116 }
117 117
118 /* correctable/single-bit errors */ 118 /* correctable/single-bit errors */
119 if (errsta & MCDEBUG_ERRSTA_SBE_STATUS) 119 if (errsta & MCDEBUG_ERRSTA_SBE_STATUS)
120 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 120 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
121 mci->csrows[cs].first_page, 0, 0, 121 mci->csrows[cs]->first_page, 0, 0,
122 cs, 0, -1, mci->ctl_name, "", NULL); 122 cs, 0, -1, mci->ctl_name, "");
123} 123}
124 124
125static void pasemi_edac_check(struct mem_ctl_info *mci) 125static void pasemi_edac_check(struct mem_ctl_info *mci)
@@ -141,8 +141,8 @@ static int pasemi_edac_init_csrows(struct mem_ctl_info *mci,
141 int index; 141 int index;
142 142
143 for (index = 0; index < mci->nr_csrows; index++) { 143 for (index = 0; index < mci->nr_csrows; index++) {
144 csrow = &mci->csrows[index]; 144 csrow = mci->csrows[index];
145 dimm = csrow->channels[0].dimm; 145 dimm = csrow->channels[0]->dimm;
146 146
147 pci_read_config_dword(pdev, 147 pci_read_config_dword(pdev,
148 MCDRAM_RANKCFG + (index * 12), 148 MCDRAM_RANKCFG + (index * 12),
@@ -225,7 +225,7 @@ static int __devinit pasemi_edac_probe(struct pci_dev *pdev,
225 MCCFG_ERRCOR_ECC_GEN_EN | 225 MCCFG_ERRCOR_ECC_GEN_EN |
226 MCCFG_ERRCOR_ECC_CRR_EN; 226 MCCFG_ERRCOR_ECC_CRR_EN;
227 227
228 mci->dev = &pdev->dev; 228 mci->pdev = &pdev->dev;
229 mci->mtype_cap = MEM_FLAG_DDR | MEM_FLAG_RDDR; 229 mci->mtype_cap = MEM_FLAG_DDR | MEM_FLAG_RDDR;
230 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; 230 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
231 mci->edac_cap = (errcor & MCCFG_ERRCOR_ECC_GEN_EN) ? 231 mci->edac_cap = (errcor & MCCFG_ERRCOR_ECC_GEN_EN) ?
diff --git a/drivers/edac/ppc4xx_edac.c b/drivers/edac/ppc4xx_edac.c
index f3f9fed06ad7..bf0957635991 100644
--- a/drivers/edac/ppc4xx_edac.c
+++ b/drivers/edac/ppc4xx_edac.c
@@ -727,10 +727,10 @@ ppc4xx_edac_handle_ce(struct mem_ctl_info *mci,
727 727
728 for (row = 0; row < mci->nr_csrows; row++) 728 for (row = 0; row < mci->nr_csrows; row++)
729 if (ppc4xx_edac_check_bank_error(status, row)) 729 if (ppc4xx_edac_check_bank_error(status, row))
730 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 730 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
731 0, 0, 0, 731 0, 0, 0,
732 row, 0, -1, 732 row, 0, -1,
733 message, "", NULL); 733 message, "");
734} 734}
735 735
736/** 736/**
@@ -758,10 +758,10 @@ ppc4xx_edac_handle_ue(struct mem_ctl_info *mci,
758 758
759 for (row = 0; row < mci->nr_csrows; row++) 759 for (row = 0; row < mci->nr_csrows; row++)
760 if (ppc4xx_edac_check_bank_error(status, row)) 760 if (ppc4xx_edac_check_bank_error(status, row))
761 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 761 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
762 page, offset, 0, 762 page, offset, 0,
763 row, 0, -1, 763 row, 0, -1,
764 message, "", NULL); 764 message, "");
765} 765}
766 766
767/** 767/**
@@ -1027,9 +1027,9 @@ ppc4xx_edac_mc_init(struct mem_ctl_info *mci,
1027 1027
1028 /* Initial driver pointers and private data */ 1028 /* Initial driver pointers and private data */
1029 1029
1030 mci->dev = &op->dev; 1030 mci->pdev = &op->dev;
1031 1031
1032 dev_set_drvdata(mci->dev, mci); 1032 dev_set_drvdata(mci->pdev, mci);
1033 1033
1034 pdata = mci->pvt_info; 1034 pdata = mci->pvt_info;
1035 1035
@@ -1334,7 +1334,7 @@ static int __devinit ppc4xx_edac_probe(struct platform_device *op)
1334 return 0; 1334 return 0;
1335 1335
1336 fail1: 1336 fail1:
1337 edac_mc_del_mc(mci->dev); 1337 edac_mc_del_mc(mci->pdev);
1338 1338
1339 fail: 1339 fail:
1340 edac_mc_free(mci); 1340 edac_mc_free(mci);
@@ -1368,7 +1368,7 @@ ppc4xx_edac_remove(struct platform_device *op)
1368 1368
1369 dcr_unmap(pdata->dcr_host, SDRAM_DCR_RESOURCE_LEN); 1369 dcr_unmap(pdata->dcr_host, SDRAM_DCR_RESOURCE_LEN);
1370 1370
1371 edac_mc_del_mc(mci->dev); 1371 edac_mc_del_mc(mci->pdev);
1372 edac_mc_free(mci); 1372 edac_mc_free(mci);
1373 1373
1374 return 0; 1374 return 0;
diff --git a/drivers/edac/r82600_edac.c b/drivers/edac/r82600_edac.c
index e1cacd164f31..f854debd5533 100644
--- a/drivers/edac/r82600_edac.c
+++ b/drivers/edac/r82600_edac.c
@@ -140,7 +140,7 @@ static void r82600_get_error_info(struct mem_ctl_info *mci,
140{ 140{
141 struct pci_dev *pdev; 141 struct pci_dev *pdev;
142 142
143 pdev = to_pci_dev(mci->dev); 143 pdev = to_pci_dev(mci->pdev);
144 pci_read_config_dword(pdev, R82600_EAP, &info->eapr); 144 pci_read_config_dword(pdev, R82600_EAP, &info->eapr);
145 145
146 if (info->eapr & BIT(0)) 146 if (info->eapr & BIT(0))
@@ -179,11 +179,11 @@ static int r82600_process_error_info(struct mem_ctl_info *mci,
179 error_found = 1; 179 error_found = 1;
180 180
181 if (handle_errors) 181 if (handle_errors)
182 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 182 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
183 page, 0, syndrome, 183 page, 0, syndrome,
184 edac_mc_find_csrow_by_page(mci, page), 184 edac_mc_find_csrow_by_page(mci, page),
185 0, -1, 185 0, -1,
186 mci->ctl_name, "", NULL); 186 mci->ctl_name, "");
187 } 187 }
188 188
189 if (info->eapr & BIT(1)) { /* UE? */ 189 if (info->eapr & BIT(1)) { /* UE? */
@@ -191,11 +191,11 @@ static int r82600_process_error_info(struct mem_ctl_info *mci,
191 191
192 if (handle_errors) 192 if (handle_errors)
193 /* 82600 doesn't give enough info */ 193 /* 82600 doesn't give enough info */
194 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 194 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
195 page, 0, 0, 195 page, 0, 0,
196 edac_mc_find_csrow_by_page(mci, page), 196 edac_mc_find_csrow_by_page(mci, page),
197 0, -1, 197 0, -1,
198 mci->ctl_name, "", NULL); 198 mci->ctl_name, "");
199 } 199 }
200 200
201 return error_found; 201 return error_found;
@@ -205,7 +205,7 @@ static void r82600_check(struct mem_ctl_info *mci)
205{ 205{
206 struct r82600_error_info info; 206 struct r82600_error_info info;
207 207
208 debugf1("MC%d: %s()\n", mci->mc_idx, __func__); 208 edac_dbg(1, "MC%d\n", mci->mc_idx);
209 r82600_get_error_info(mci, &info); 209 r82600_get_error_info(mci, &info);
210 r82600_process_error_info(mci, &info, 1); 210 r82600_process_error_info(mci, &info, 1);
211} 211}
@@ -230,19 +230,19 @@ static void r82600_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
230 row_high_limit_last = 0; 230 row_high_limit_last = 0;
231 231
232 for (index = 0; index < mci->nr_csrows; index++) { 232 for (index = 0; index < mci->nr_csrows; index++) {
233 csrow = &mci->csrows[index]; 233 csrow = mci->csrows[index];
234 dimm = csrow->channels[0].dimm; 234 dimm = csrow->channels[0]->dimm;
235 235
236 /* find the DRAM Chip Select Base address and mask */ 236 /* find the DRAM Chip Select Base address and mask */
237 pci_read_config_byte(pdev, R82600_DRBA + index, &drbar); 237 pci_read_config_byte(pdev, R82600_DRBA + index, &drbar);
238 238
239 debugf1("%s() Row=%d DRBA = %#0x\n", __func__, index, drbar); 239 edac_dbg(1, "Row=%d DRBA = %#0x\n", index, drbar);
240 240
241 row_high_limit = ((u32) drbar << 24); 241 row_high_limit = ((u32) drbar << 24);
242/* row_high_limit = ((u32)drbar << 24) | 0xffffffUL; */ 242/* row_high_limit = ((u32)drbar << 24) | 0xffffffUL; */
243 243
244 debugf1("%s() Row=%d, Boundary Address=%#0x, Last = %#0x\n", 244 edac_dbg(1, "Row=%d, Boundary Address=%#0x, Last = %#0x\n",
245 __func__, index, row_high_limit, row_high_limit_last); 245 index, row_high_limit, row_high_limit_last);
246 246
247 /* Empty row [p.57] */ 247 /* Empty row [p.57] */
248 if (row_high_limit == row_high_limit_last) 248 if (row_high_limit == row_high_limit_last)
@@ -277,14 +277,13 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
277 u32 sdram_refresh_rate; 277 u32 sdram_refresh_rate;
278 struct r82600_error_info discard; 278 struct r82600_error_info discard;
279 279
280 debugf0("%s()\n", __func__); 280 edac_dbg(0, "\n");
281 pci_read_config_byte(pdev, R82600_DRAMC, &dramcr); 281 pci_read_config_byte(pdev, R82600_DRAMC, &dramcr);
282 pci_read_config_dword(pdev, R82600_EAP, &eapr); 282 pci_read_config_dword(pdev, R82600_EAP, &eapr);
283 scrub_disabled = eapr & BIT(31); 283 scrub_disabled = eapr & BIT(31);
284 sdram_refresh_rate = dramcr & (BIT(0) | BIT(1)); 284 sdram_refresh_rate = dramcr & (BIT(0) | BIT(1));
285 debugf2("%s(): sdram refresh rate = %#0x\n", __func__, 285 edac_dbg(2, "sdram refresh rate = %#0x\n", sdram_refresh_rate);
286 sdram_refresh_rate); 286 edac_dbg(2, "DRAMC register = %#0x\n", dramcr);
287 debugf2("%s(): DRAMC register = %#0x\n", __func__, dramcr);
288 layers[0].type = EDAC_MC_LAYER_CHIP_SELECT; 287 layers[0].type = EDAC_MC_LAYER_CHIP_SELECT;
289 layers[0].size = R82600_NR_CSROWS; 288 layers[0].size = R82600_NR_CSROWS;
290 layers[0].is_virt_csrow = true; 289 layers[0].is_virt_csrow = true;
@@ -295,8 +294,8 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
295 if (mci == NULL) 294 if (mci == NULL)
296 return -ENOMEM; 295 return -ENOMEM;
297 296
298 debugf0("%s(): mci = %p\n", __func__, mci); 297 edac_dbg(0, "mci = %p\n", mci);
299 mci->dev = &pdev->dev; 298 mci->pdev = &pdev->dev;
300 mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR; 299 mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR;
301 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; 300 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
302 /* FIXME try to work out if the chip leads have been used for COM2 301 /* FIXME try to work out if the chip leads have been used for COM2
@@ -311,8 +310,8 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
311 310
312 if (ecc_enabled(dramcr)) { 311 if (ecc_enabled(dramcr)) {
313 if (scrub_disabled) 312 if (scrub_disabled)
314 debugf3("%s(): mci = %p - Scrubbing disabled! EAP: " 313 edac_dbg(3, "mci = %p - Scrubbing disabled! EAP: %#0x\n",
315 "%#0x\n", __func__, mci, eapr); 314 mci, eapr);
316 } else 315 } else
317 mci->edac_cap = EDAC_FLAG_NONE; 316 mci->edac_cap = EDAC_FLAG_NONE;
318 317
@@ -329,15 +328,14 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
329 * type of memory controller. The ID is therefore hardcoded to 0. 328 * type of memory controller. The ID is therefore hardcoded to 0.
330 */ 329 */
331 if (edac_mc_add_mc(mci)) { 330 if (edac_mc_add_mc(mci)) {
332 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 331 edac_dbg(3, "failed edac_mc_add_mc()\n");
333 goto fail; 332 goto fail;
334 } 333 }
335 334
336 /* get this far and it's successful */ 335 /* get this far and it's successful */
337 336
338 if (disable_hardware_scrub) { 337 if (disable_hardware_scrub) {
339 debugf3("%s(): Disabling Hardware Scrub (scrub on error)\n", 338 edac_dbg(3, "Disabling Hardware Scrub (scrub on error)\n");
340 __func__);
341 pci_write_bits32(pdev, R82600_EAP, BIT(31), BIT(31)); 339 pci_write_bits32(pdev, R82600_EAP, BIT(31), BIT(31));
342 } 340 }
343 341
@@ -352,7 +350,7 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
352 __func__); 350 __func__);
353 } 351 }
354 352
355 debugf3("%s(): success\n", __func__); 353 edac_dbg(3, "success\n");
356 return 0; 354 return 0;
357 355
358fail: 356fail:
@@ -364,7 +362,7 @@ fail:
364static int __devinit r82600_init_one(struct pci_dev *pdev, 362static int __devinit r82600_init_one(struct pci_dev *pdev,
365 const struct pci_device_id *ent) 363 const struct pci_device_id *ent)
366{ 364{
367 debugf0("%s()\n", __func__); 365 edac_dbg(0, "\n");
368 366
369 /* don't need to call pci_enable_device() */ 367 /* don't need to call pci_enable_device() */
370 return r82600_probe1(pdev, ent->driver_data); 368 return r82600_probe1(pdev, ent->driver_data);
@@ -374,7 +372,7 @@ static void __devexit r82600_remove_one(struct pci_dev *pdev)
374{ 372{
375 struct mem_ctl_info *mci; 373 struct mem_ctl_info *mci;
376 374
377 debugf0("%s()\n", __func__); 375 edac_dbg(0, "\n");
378 376
379 if (r82600_pci) 377 if (r82600_pci)
380 edac_pci_release_generic_ctl(r82600_pci); 378 edac_pci_release_generic_ctl(r82600_pci);
diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index 36ad17e79d61..f3b1f9fafa4b 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -381,8 +381,8 @@ static inline int numrank(u32 mtr)
381 int ranks = (1 << RANK_CNT_BITS(mtr)); 381 int ranks = (1 << RANK_CNT_BITS(mtr));
382 382
383 if (ranks > 4) { 383 if (ranks > 4) {
384 debugf0("Invalid number of ranks: %d (max = 4) raw value = %x (%04x)", 384 edac_dbg(0, "Invalid number of ranks: %d (max = 4) raw value = %x (%04x)\n",
385 ranks, (unsigned int)RANK_CNT_BITS(mtr), mtr); 385 ranks, (unsigned int)RANK_CNT_BITS(mtr), mtr);
386 return -EINVAL; 386 return -EINVAL;
387 } 387 }
388 388
@@ -394,8 +394,8 @@ static inline int numrow(u32 mtr)
394 int rows = (RANK_WIDTH_BITS(mtr) + 12); 394 int rows = (RANK_WIDTH_BITS(mtr) + 12);
395 395
396 if (rows < 13 || rows > 18) { 396 if (rows < 13 || rows > 18) {
397 debugf0("Invalid number of rows: %d (should be between 14 and 17) raw value = %x (%04x)", 397 edac_dbg(0, "Invalid number of rows: %d (should be between 14 and 17) raw value = %x (%04x)\n",
398 rows, (unsigned int)RANK_WIDTH_BITS(mtr), mtr); 398 rows, (unsigned int)RANK_WIDTH_BITS(mtr), mtr);
399 return -EINVAL; 399 return -EINVAL;
400 } 400 }
401 401
@@ -407,8 +407,8 @@ static inline int numcol(u32 mtr)
407 int cols = (COL_WIDTH_BITS(mtr) + 10); 407 int cols = (COL_WIDTH_BITS(mtr) + 10);
408 408
409 if (cols > 12) { 409 if (cols > 12) {
410 debugf0("Invalid number of cols: %d (max = 4) raw value = %x (%04x)", 410 edac_dbg(0, "Invalid number of cols: %d (max = 4) raw value = %x (%04x)\n",
411 cols, (unsigned int)COL_WIDTH_BITS(mtr), mtr); 411 cols, (unsigned int)COL_WIDTH_BITS(mtr), mtr);
412 return -EINVAL; 412 return -EINVAL;
413 } 413 }
414 414
@@ -475,8 +475,8 @@ static struct pci_dev *get_pdev_slot_func(u8 bus, unsigned slot,
475 475
476 if (PCI_SLOT(sbridge_dev->pdev[i]->devfn) == slot && 476 if (PCI_SLOT(sbridge_dev->pdev[i]->devfn) == slot &&
477 PCI_FUNC(sbridge_dev->pdev[i]->devfn) == func) { 477 PCI_FUNC(sbridge_dev->pdev[i]->devfn) == func) {
478 debugf1("Associated %02x.%02x.%d with %p\n", 478 edac_dbg(1, "Associated %02x.%02x.%d with %p\n",
479 bus, slot, func, sbridge_dev->pdev[i]); 479 bus, slot, func, sbridge_dev->pdev[i]);
480 return sbridge_dev->pdev[i]; 480 return sbridge_dev->pdev[i];
481 } 481 }
482 } 482 }
@@ -523,45 +523,45 @@ static int get_dimm_config(struct mem_ctl_info *mci)
523 523
524 pci_read_config_dword(pvt->pci_br, SAD_CONTROL, &reg); 524 pci_read_config_dword(pvt->pci_br, SAD_CONTROL, &reg);
525 pvt->sbridge_dev->node_id = NODE_ID(reg); 525 pvt->sbridge_dev->node_id = NODE_ID(reg);
526 debugf0("mc#%d: Node ID: %d, source ID: %d\n", 526 edac_dbg(0, "mc#%d: Node ID: %d, source ID: %d\n",
527 pvt->sbridge_dev->mc, 527 pvt->sbridge_dev->mc,
528 pvt->sbridge_dev->node_id, 528 pvt->sbridge_dev->node_id,
529 pvt->sbridge_dev->source_id); 529 pvt->sbridge_dev->source_id);
530 530
531 pci_read_config_dword(pvt->pci_ras, RASENABLES, &reg); 531 pci_read_config_dword(pvt->pci_ras, RASENABLES, &reg);
532 if (IS_MIRROR_ENABLED(reg)) { 532 if (IS_MIRROR_ENABLED(reg)) {
533 debugf0("Memory mirror is enabled\n"); 533 edac_dbg(0, "Memory mirror is enabled\n");
534 pvt->is_mirrored = true; 534 pvt->is_mirrored = true;
535 } else { 535 } else {
536 debugf0("Memory mirror is disabled\n"); 536 edac_dbg(0, "Memory mirror is disabled\n");
537 pvt->is_mirrored = false; 537 pvt->is_mirrored = false;
538 } 538 }
539 539
540 pci_read_config_dword(pvt->pci_ta, MCMTR, &pvt->info.mcmtr); 540 pci_read_config_dword(pvt->pci_ta, MCMTR, &pvt->info.mcmtr);
541 if (IS_LOCKSTEP_ENABLED(pvt->info.mcmtr)) { 541 if (IS_LOCKSTEP_ENABLED(pvt->info.mcmtr)) {
542 debugf0("Lockstep is enabled\n"); 542 edac_dbg(0, "Lockstep is enabled\n");
543 mode = EDAC_S8ECD8ED; 543 mode = EDAC_S8ECD8ED;
544 pvt->is_lockstep = true; 544 pvt->is_lockstep = true;
545 } else { 545 } else {
546 debugf0("Lockstep is disabled\n"); 546 edac_dbg(0, "Lockstep is disabled\n");
547 mode = EDAC_S4ECD4ED; 547 mode = EDAC_S4ECD4ED;
548 pvt->is_lockstep = false; 548 pvt->is_lockstep = false;
549 } 549 }
550 if (IS_CLOSE_PG(pvt->info.mcmtr)) { 550 if (IS_CLOSE_PG(pvt->info.mcmtr)) {
551 debugf0("address map is on closed page mode\n"); 551 edac_dbg(0, "address map is on closed page mode\n");
552 pvt->is_close_pg = true; 552 pvt->is_close_pg = true;
553 } else { 553 } else {
554 debugf0("address map is on open page mode\n"); 554 edac_dbg(0, "address map is on open page mode\n");
555 pvt->is_close_pg = false; 555 pvt->is_close_pg = false;
556 } 556 }
557 557
558 pci_read_config_dword(pvt->pci_ddrio, RANK_CFG_A, &reg); 558 pci_read_config_dword(pvt->pci_ddrio, RANK_CFG_A, &reg);
559 if (IS_RDIMM_ENABLED(reg)) { 559 if (IS_RDIMM_ENABLED(reg)) {
560 /* FIXME: Can also be LRDIMM */ 560 /* FIXME: Can also be LRDIMM */
561 debugf0("Memory is registered\n"); 561 edac_dbg(0, "Memory is registered\n");
562 mtype = MEM_RDDR3; 562 mtype = MEM_RDDR3;
563 } else { 563 } else {
564 debugf0("Memory is unregistered\n"); 564 edac_dbg(0, "Memory is unregistered\n");
565 mtype = MEM_DDR3; 565 mtype = MEM_DDR3;
566 } 566 }
567 567
@@ -576,7 +576,7 @@ static int get_dimm_config(struct mem_ctl_info *mci)
576 i, j, 0); 576 i, j, 0);
577 pci_read_config_dword(pvt->pci_tad[i], 577 pci_read_config_dword(pvt->pci_tad[i],
578 mtr_regs[j], &mtr); 578 mtr_regs[j], &mtr);
579 debugf4("Channel #%d MTR%d = %x\n", i, j, mtr); 579 edac_dbg(4, "Channel #%d MTR%d = %x\n", i, j, mtr);
580 if (IS_DIMM_PRESENT(mtr)) { 580 if (IS_DIMM_PRESENT(mtr)) {
581 pvt->channel[i].dimms++; 581 pvt->channel[i].dimms++;
582 582
@@ -588,10 +588,10 @@ static int get_dimm_config(struct mem_ctl_info *mci)
588 size = (rows * cols * banks * ranks) >> (20 - 3); 588 size = (rows * cols * banks * ranks) >> (20 - 3);
589 npages = MiB_TO_PAGES(size); 589 npages = MiB_TO_PAGES(size);
590 590
591 debugf0("mc#%d: channel %d, dimm %d, %d Mb (%d pages) bank: %d, rank: %d, row: %#x, col: %#x\n", 591 edac_dbg(0, "mc#%d: channel %d, dimm %d, %d Mb (%d pages) bank: %d, rank: %d, row: %#x, col: %#x\n",
592 pvt->sbridge_dev->mc, i, j, 592 pvt->sbridge_dev->mc, i, j,
593 size, npages, 593 size, npages,
594 banks, ranks, rows, cols); 594 banks, ranks, rows, cols);
595 595
596 dimm->nr_pages = npages; 596 dimm->nr_pages = npages;
597 dimm->grain = 32; 597 dimm->grain = 32;
@@ -629,8 +629,7 @@ static void get_memory_layout(const struct mem_ctl_info *mci)
629 tmp_mb = (1 + pvt->tolm) >> 20; 629 tmp_mb = (1 + pvt->tolm) >> 20;
630 630
631 mb = div_u64_rem(tmp_mb, 1000, &kb); 631 mb = div_u64_rem(tmp_mb, 1000, &kb);
632 debugf0("TOLM: %u.%03u GB (0x%016Lx)\n", 632 edac_dbg(0, "TOLM: %u.%03u GB (0x%016Lx)\n", mb, kb, (u64)pvt->tolm);
633 mb, kb, (u64)pvt->tolm);
634 633
635 /* Address range is already 45:25 */ 634 /* Address range is already 45:25 */
636 pci_read_config_dword(pvt->pci_sad1, TOHM, 635 pci_read_config_dword(pvt->pci_sad1, TOHM,
@@ -639,8 +638,7 @@ static void get_memory_layout(const struct mem_ctl_info *mci)
639 tmp_mb = (1 + pvt->tohm) >> 20; 638 tmp_mb = (1 + pvt->tohm) >> 20;
640 639
641 mb = div_u64_rem(tmp_mb, 1000, &kb); 640 mb = div_u64_rem(tmp_mb, 1000, &kb);
642 debugf0("TOHM: %u.%03u GB (0x%016Lx)", 641 edac_dbg(0, "TOHM: %u.%03u GB (0x%016Lx)", mb, kb, (u64)pvt->tohm);
643 mb, kb, (u64)pvt->tohm);
644 642
645 /* 643 /*
646 * Step 2) Get SAD range and SAD Interleave list 644 * Step 2) Get SAD range and SAD Interleave list
@@ -663,13 +661,13 @@ static void get_memory_layout(const struct mem_ctl_info *mci)
663 661
664 tmp_mb = (limit + 1) >> 20; 662 tmp_mb = (limit + 1) >> 20;
665 mb = div_u64_rem(tmp_mb, 1000, &kb); 663 mb = div_u64_rem(tmp_mb, 1000, &kb);
666 debugf0("SAD#%d %s up to %u.%03u GB (0x%016Lx) %s reg=0x%08x\n", 664 edac_dbg(0, "SAD#%d %s up to %u.%03u GB (0x%016Lx) Interleave: %s reg=0x%08x\n",
667 n_sads, 665 n_sads,
668 get_dram_attr(reg), 666 get_dram_attr(reg),
669 mb, kb, 667 mb, kb,
670 ((u64)tmp_mb) << 20L, 668 ((u64)tmp_mb) << 20L,
671 INTERLEAVE_MODE(reg) ? "Interleave: 8:6" : "Interleave: [8:6]XOR[18:16]", 669 INTERLEAVE_MODE(reg) ? "8:6" : "[8:6]XOR[18:16]",
672 reg); 670 reg);
673 prv = limit; 671 prv = limit;
674 672
675 pci_read_config_dword(pvt->pci_sad0, interleave_list[n_sads], 673 pci_read_config_dword(pvt->pci_sad0, interleave_list[n_sads],
@@ -679,8 +677,8 @@ static void get_memory_layout(const struct mem_ctl_info *mci)
679 if (j > 0 && sad_interl == sad_pkg(reg, j)) 677 if (j > 0 && sad_interl == sad_pkg(reg, j))
680 break; 678 break;
681 679
682 debugf0("SAD#%d, interleave #%d: %d\n", 680 edac_dbg(0, "SAD#%d, interleave #%d: %d\n",
683 n_sads, j, sad_pkg(reg, j)); 681 n_sads, j, sad_pkg(reg, j));
684 } 682 }
685 } 683 }
686 684
@@ -697,16 +695,16 @@ static void get_memory_layout(const struct mem_ctl_info *mci)
697 tmp_mb = (limit + 1) >> 20; 695 tmp_mb = (limit + 1) >> 20;
698 696
699 mb = div_u64_rem(tmp_mb, 1000, &kb); 697 mb = div_u64_rem(tmp_mb, 1000, &kb);
700 debugf0("TAD#%d: up to %u.%03u GB (0x%016Lx), socket interleave %d, memory interleave %d, TGT: %d, %d, %d, %d, reg=0x%08x\n", 698 edac_dbg(0, "TAD#%d: up to %u.%03u GB (0x%016Lx), socket interleave %d, memory interleave %d, TGT: %d, %d, %d, %d, reg=0x%08x\n",
701 n_tads, mb, kb, 699 n_tads, mb, kb,
702 ((u64)tmp_mb) << 20L, 700 ((u64)tmp_mb) << 20L,
703 (u32)TAD_SOCK(reg), 701 (u32)TAD_SOCK(reg),
704 (u32)TAD_CH(reg), 702 (u32)TAD_CH(reg),
705 (u32)TAD_TGT0(reg), 703 (u32)TAD_TGT0(reg),
706 (u32)TAD_TGT1(reg), 704 (u32)TAD_TGT1(reg),
707 (u32)TAD_TGT2(reg), 705 (u32)TAD_TGT2(reg),
708 (u32)TAD_TGT3(reg), 706 (u32)TAD_TGT3(reg),
709 reg); 707 reg);
710 prv = limit; 708 prv = limit;
711 } 709 }
712 710
@@ -722,11 +720,11 @@ static void get_memory_layout(const struct mem_ctl_info *mci)
722 &reg); 720 &reg);
723 tmp_mb = TAD_OFFSET(reg) >> 20; 721 tmp_mb = TAD_OFFSET(reg) >> 20;
724 mb = div_u64_rem(tmp_mb, 1000, &kb); 722 mb = div_u64_rem(tmp_mb, 1000, &kb);
725 debugf0("TAD CH#%d, offset #%d: %u.%03u GB (0x%016Lx), reg=0x%08x\n", 723 edac_dbg(0, "TAD CH#%d, offset #%d: %u.%03u GB (0x%016Lx), reg=0x%08x\n",
726 i, j, 724 i, j,
727 mb, kb, 725 mb, kb,
728 ((u64)tmp_mb) << 20L, 726 ((u64)tmp_mb) << 20L,
729 reg); 727 reg);
730 } 728 }
731 } 729 }
732 730
@@ -747,12 +745,12 @@ static void get_memory_layout(const struct mem_ctl_info *mci)
747 tmp_mb = RIR_LIMIT(reg) >> 20; 745 tmp_mb = RIR_LIMIT(reg) >> 20;
748 rir_way = 1 << RIR_WAY(reg); 746 rir_way = 1 << RIR_WAY(reg);
749 mb = div_u64_rem(tmp_mb, 1000, &kb); 747 mb = div_u64_rem(tmp_mb, 1000, &kb);
750 debugf0("CH#%d RIR#%d, limit: %u.%03u GB (0x%016Lx), way: %d, reg=0x%08x\n", 748 edac_dbg(0, "CH#%d RIR#%d, limit: %u.%03u GB (0x%016Lx), way: %d, reg=0x%08x\n",
751 i, j, 749 i, j,
752 mb, kb, 750 mb, kb,
753 ((u64)tmp_mb) << 20L, 751 ((u64)tmp_mb) << 20L,
754 rir_way, 752 rir_way,
755 reg); 753 reg);
756 754
757 for (k = 0; k < rir_way; k++) { 755 for (k = 0; k < rir_way; k++) {
758 pci_read_config_dword(pvt->pci_tad[i], 756 pci_read_config_dword(pvt->pci_tad[i],
@@ -761,12 +759,12 @@ static void get_memory_layout(const struct mem_ctl_info *mci)
761 tmp_mb = RIR_OFFSET(reg) << 6; 759 tmp_mb = RIR_OFFSET(reg) << 6;
762 760
763 mb = div_u64_rem(tmp_mb, 1000, &kb); 761 mb = div_u64_rem(tmp_mb, 1000, &kb);
764 debugf0("CH#%d RIR#%d INTL#%d, offset %u.%03u GB (0x%016Lx), tgt: %d, reg=0x%08x\n", 762 edac_dbg(0, "CH#%d RIR#%d INTL#%d, offset %u.%03u GB (0x%016Lx), tgt: %d, reg=0x%08x\n",
765 i, j, k, 763 i, j, k,
766 mb, kb, 764 mb, kb,
767 ((u64)tmp_mb) << 20L, 765 ((u64)tmp_mb) << 20L,
768 (u32)RIR_RNK_TGT(reg), 766 (u32)RIR_RNK_TGT(reg),
769 reg); 767 reg);
770 } 768 }
771 } 769 }
772 } 770 }
@@ -853,16 +851,16 @@ static int get_memory_error_data(struct mem_ctl_info *mci,
853 if (sad_way > 0 && sad_interl == sad_pkg(reg, sad_way)) 851 if (sad_way > 0 && sad_interl == sad_pkg(reg, sad_way))
854 break; 852 break;
855 sad_interleave[sad_way] = sad_pkg(reg, sad_way); 853 sad_interleave[sad_way] = sad_pkg(reg, sad_way);
856 debugf0("SAD interleave #%d: %d\n", 854 edac_dbg(0, "SAD interleave #%d: %d\n",
857 sad_way, sad_interleave[sad_way]); 855 sad_way, sad_interleave[sad_way]);
858 } 856 }
859 debugf0("mc#%d: Error detected on SAD#%d: address 0x%016Lx < 0x%016Lx, Interleave [%d:6]%s\n", 857 edac_dbg(0, "mc#%d: Error detected on SAD#%d: address 0x%016Lx < 0x%016Lx, Interleave [%d:6]%s\n",
860 pvt->sbridge_dev->mc, 858 pvt->sbridge_dev->mc,
861 n_sads, 859 n_sads,
862 addr, 860 addr,
863 limit, 861 limit,
864 sad_way + 7, 862 sad_way + 7,
865 interleave_mode ? "" : "XOR[18:16]"); 863 interleave_mode ? "" : "XOR[18:16]");
866 if (interleave_mode) 864 if (interleave_mode)
867 idx = ((addr >> 6) ^ (addr >> 16)) & 7; 865 idx = ((addr >> 6) ^ (addr >> 16)) & 7;
868 else 866 else
@@ -884,8 +882,8 @@ static int get_memory_error_data(struct mem_ctl_info *mci,
884 return -EINVAL; 882 return -EINVAL;
885 } 883 }
886 *socket = sad_interleave[idx]; 884 *socket = sad_interleave[idx];
887 debugf0("SAD interleave index: %d (wayness %d) = CPU socket %d\n", 885 edac_dbg(0, "SAD interleave index: %d (wayness %d) = CPU socket %d\n",
888 idx, sad_way, *socket); 886 idx, sad_way, *socket);
889 887
890 /* 888 /*
891 * Move to the proper node structure, in order to access the 889 * Move to the proper node structure, in order to access the
@@ -972,16 +970,16 @@ static int get_memory_error_data(struct mem_ctl_info *mci,
972 970
973 offset = TAD_OFFSET(tad_offset); 971 offset = TAD_OFFSET(tad_offset);
974 972
975 debugf0("TAD#%d: address 0x%016Lx < 0x%016Lx, socket interleave %d, channel interleave %d (offset 0x%08Lx), index %d, base ch: %d, ch mask: 0x%02lx\n", 973 edac_dbg(0, "TAD#%d: address 0x%016Lx < 0x%016Lx, socket interleave %d, channel interleave %d (offset 0x%08Lx), index %d, base ch: %d, ch mask: 0x%02lx\n",
976 n_tads, 974 n_tads,
977 addr, 975 addr,
978 limit, 976 limit,
979 (u32)TAD_SOCK(reg), 977 (u32)TAD_SOCK(reg),
980 ch_way, 978 ch_way,
981 offset, 979 offset,
982 idx, 980 idx,
983 base_ch, 981 base_ch,
984 *channel_mask); 982 *channel_mask);
985 983
986 /* Calculate channel address */ 984 /* Calculate channel address */
987 /* Remove the TAD offset */ 985 /* Remove the TAD offset */
@@ -1017,11 +1015,11 @@ static int get_memory_error_data(struct mem_ctl_info *mci,
1017 1015
1018 limit = RIR_LIMIT(reg); 1016 limit = RIR_LIMIT(reg);
1019 mb = div_u64_rem(limit >> 20, 1000, &kb); 1017 mb = div_u64_rem(limit >> 20, 1000, &kb);
1020 debugf0("RIR#%d, limit: %u.%03u GB (0x%016Lx), way: %d\n", 1018 edac_dbg(0, "RIR#%d, limit: %u.%03u GB (0x%016Lx), way: %d\n",
1021 n_rir, 1019 n_rir,
1022 mb, kb, 1020 mb, kb,
1023 limit, 1021 limit,
1024 1 << RIR_WAY(reg)); 1022 1 << RIR_WAY(reg));
1025 if (ch_addr <= limit) 1023 if (ch_addr <= limit)
1026 break; 1024 break;
1027 } 1025 }
@@ -1042,12 +1040,12 @@ static int get_memory_error_data(struct mem_ctl_info *mci,
1042 &reg); 1040 &reg);
1043 *rank = RIR_RNK_TGT(reg); 1041 *rank = RIR_RNK_TGT(reg);
1044 1042
1045 debugf0("RIR#%d: channel address 0x%08Lx < 0x%08Lx, RIR interleave %d, index %d\n", 1043 edac_dbg(0, "RIR#%d: channel address 0x%08Lx < 0x%08Lx, RIR interleave %d, index %d\n",
1046 n_rir, 1044 n_rir,
1047 ch_addr, 1045 ch_addr,
1048 limit, 1046 limit,
1049 rir_way, 1047 rir_way,
1050 idx); 1048 idx);
1051 1049
1052 return 0; 1050 return 0;
1053} 1051}
@@ -1064,14 +1062,14 @@ static void sbridge_put_devices(struct sbridge_dev *sbridge_dev)
1064{ 1062{
1065 int i; 1063 int i;
1066 1064
1067 debugf0(__FILE__ ": %s()\n", __func__); 1065 edac_dbg(0, "\n");
1068 for (i = 0; i < sbridge_dev->n_devs; i++) { 1066 for (i = 0; i < sbridge_dev->n_devs; i++) {
1069 struct pci_dev *pdev = sbridge_dev->pdev[i]; 1067 struct pci_dev *pdev = sbridge_dev->pdev[i];
1070 if (!pdev) 1068 if (!pdev)
1071 continue; 1069 continue;
1072 debugf0("Removing dev %02x:%02x.%d\n", 1070 edac_dbg(0, "Removing dev %02x:%02x.%d\n",
1073 pdev->bus->number, 1071 pdev->bus->number,
1074 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); 1072 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
1075 pci_dev_put(pdev); 1073 pci_dev_put(pdev);
1076 } 1074 }
1077} 1075}
@@ -1177,10 +1175,9 @@ static int sbridge_get_onedevice(struct pci_dev **prev,
1177 return -ENODEV; 1175 return -ENODEV;
1178 } 1176 }
1179 1177
1180 debugf0("Detected dev %02x:%d.%d PCI ID %04x:%04x\n", 1178 edac_dbg(0, "Detected dev %02x:%d.%d PCI ID %04x:%04x\n",
1181 bus, dev_descr->dev, 1179 bus, dev_descr->dev, dev_descr->func,
1182 dev_descr->func, 1180 PCI_VENDOR_ID_INTEL, dev_descr->dev_id);
1183 PCI_VENDOR_ID_INTEL, dev_descr->dev_id);
1184 1181
1185 /* 1182 /*
1186 * As stated on drivers/pci/search.c, the reference count for 1183 * As stated on drivers/pci/search.c, the reference count for
@@ -1297,10 +1294,10 @@ static int mci_bind_devs(struct mem_ctl_info *mci,
1297 goto error; 1294 goto error;
1298 } 1295 }
1299 1296
1300 debugf0("Associated PCI %02x.%02d.%d with dev = %p\n", 1297 edac_dbg(0, "Associated PCI %02x.%02d.%d with dev = %p\n",
1301 sbridge_dev->bus, 1298 sbridge_dev->bus,
1302 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), 1299 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
1303 pdev); 1300 pdev);
1304 } 1301 }
1305 1302
1306 /* Check if everything were registered */ 1303 /* Check if everything were registered */
@@ -1435,8 +1432,7 @@ static void sbridge_mce_output_error(struct mem_ctl_info *mci,
1435 * to the group of dimm's where the error may be happening. 1432 * to the group of dimm's where the error may be happening.
1436 */ 1433 */
1437 snprintf(msg, sizeof(msg), 1434 snprintf(msg, sizeof(msg),
1438 "count:%d%s%s area:%s err_code:%04x:%04x socket:%d channel_mask:%ld rank:%d", 1435 "%s%s area:%s err_code:%04x:%04x socket:%d channel_mask:%ld rank:%d",
1439 core_err_cnt,
1440 overflow ? " OVERFLOW" : "", 1436 overflow ? " OVERFLOW" : "",
1441 (uncorrected_error && recoverable) ? " recoverable" : "", 1437 (uncorrected_error && recoverable) ? " recoverable" : "",
1442 area_type, 1438 area_type,
@@ -1445,20 +1441,20 @@ static void sbridge_mce_output_error(struct mem_ctl_info *mci,
1445 channel_mask, 1441 channel_mask,
1446 rank); 1442 rank);
1447 1443
1448 debugf0("%s", msg); 1444 edac_dbg(0, "%s\n", msg);
1449 1445
1450 /* FIXME: need support for channel mask */ 1446 /* FIXME: need support for channel mask */
1451 1447
1452 /* Call the helper to output message */ 1448 /* Call the helper to output message */
1453 edac_mc_handle_error(tp_event, mci, 1449 edac_mc_handle_error(tp_event, mci, core_err_cnt,
1454 m->addr >> PAGE_SHIFT, m->addr & ~PAGE_MASK, 0, 1450 m->addr >> PAGE_SHIFT, m->addr & ~PAGE_MASK, 0,
1455 channel, dimm, -1, 1451 channel, dimm, -1,
1456 optype, msg, m); 1452 optype, msg);
1457 return; 1453 return;
1458err_parsing: 1454err_parsing:
1459 edac_mc_handle_error(tp_event, mci, 0, 0, 0, 1455 edac_mc_handle_error(tp_event, mci, core_err_cnt, 0, 0, 0,
1460 -1, -1, -1, 1456 -1, -1, -1,
1461 msg, "", m); 1457 msg, "");
1462 1458
1463} 1459}
1464 1460
@@ -1592,8 +1588,7 @@ static void sbridge_unregister_mci(struct sbridge_dev *sbridge_dev)
1592 struct sbridge_pvt *pvt; 1588 struct sbridge_pvt *pvt;
1593 1589
1594 if (unlikely(!mci || !mci->pvt_info)) { 1590 if (unlikely(!mci || !mci->pvt_info)) {
1595 debugf0("MC: " __FILE__ ": %s(): dev = %p\n", 1591 edac_dbg(0, "MC: dev = %p\n", &sbridge_dev->pdev[0]->dev);
1596 __func__, &sbridge_dev->pdev[0]->dev);
1597 1592
1598 sbridge_printk(KERN_ERR, "Couldn't find mci handler\n"); 1593 sbridge_printk(KERN_ERR, "Couldn't find mci handler\n");
1599 return; 1594 return;
@@ -1601,13 +1596,13 @@ static void sbridge_unregister_mci(struct sbridge_dev *sbridge_dev)
1601 1596
1602 pvt = mci->pvt_info; 1597 pvt = mci->pvt_info;
1603 1598
1604 debugf0("MC: " __FILE__ ": %s(): mci = %p, dev = %p\n", 1599 edac_dbg(0, "MC: mci = %p, dev = %p\n",
1605 __func__, mci, &sbridge_dev->pdev[0]->dev); 1600 mci, &sbridge_dev->pdev[0]->dev);
1606 1601
1607 /* Remove MC sysfs nodes */ 1602 /* Remove MC sysfs nodes */
1608 edac_mc_del_mc(mci->dev); 1603 edac_mc_del_mc(mci->pdev);
1609 1604
1610 debugf1("%s: free mci struct\n", mci->ctl_name); 1605 edac_dbg(1, "%s: free mci struct\n", mci->ctl_name);
1611 kfree(mci->ctl_name); 1606 kfree(mci->ctl_name);
1612 edac_mc_free(mci); 1607 edac_mc_free(mci);
1613 sbridge_dev->mci = NULL; 1608 sbridge_dev->mci = NULL;
@@ -1638,8 +1633,8 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev)
1638 if (unlikely(!mci)) 1633 if (unlikely(!mci))
1639 return -ENOMEM; 1634 return -ENOMEM;
1640 1635
1641 debugf0("MC: " __FILE__ ": %s(): mci = %p, dev = %p\n", 1636 edac_dbg(0, "MC: mci = %p, dev = %p\n",
1642 __func__, mci, &sbridge_dev->pdev[0]->dev); 1637 mci, &sbridge_dev->pdev[0]->dev);
1643 1638
1644 pvt = mci->pvt_info; 1639 pvt = mci->pvt_info;
1645 memset(pvt, 0, sizeof(*pvt)); 1640 memset(pvt, 0, sizeof(*pvt));
@@ -1670,12 +1665,11 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev)
1670 get_memory_layout(mci); 1665 get_memory_layout(mci);
1671 1666
1672 /* record ptr to the generic device */ 1667 /* record ptr to the generic device */
1673 mci->dev = &sbridge_dev->pdev[0]->dev; 1668 mci->pdev = &sbridge_dev->pdev[0]->dev;
1674 1669
1675 /* add this new MC control structure to EDAC's list of MCs */ 1670 /* add this new MC control structure to EDAC's list of MCs */
1676 if (unlikely(edac_mc_add_mc(mci))) { 1671 if (unlikely(edac_mc_add_mc(mci))) {
1677 debugf0("MC: " __FILE__ 1672 edac_dbg(0, "MC: failed edac_mc_add_mc()\n");
1678 ": %s(): failed edac_mc_add_mc()\n", __func__);
1679 rc = -EINVAL; 1673 rc = -EINVAL;
1680 goto fail0; 1674 goto fail0;
1681 } 1675 }
@@ -1722,7 +1716,8 @@ static int __devinit sbridge_probe(struct pci_dev *pdev,
1722 mc = 0; 1716 mc = 0;
1723 1717
1724 list_for_each_entry(sbridge_dev, &sbridge_edac_list, list) { 1718 list_for_each_entry(sbridge_dev, &sbridge_edac_list, list) {
1725 debugf0("Registering MC#%d (%d of %d)\n", mc, mc + 1, num_mc); 1719 edac_dbg(0, "Registering MC#%d (%d of %d)\n",
1720 mc, mc + 1, num_mc);
1726 sbridge_dev->mc = mc++; 1721 sbridge_dev->mc = mc++;
1727 rc = sbridge_register_mci(sbridge_dev); 1722 rc = sbridge_register_mci(sbridge_dev);
1728 if (unlikely(rc < 0)) 1723 if (unlikely(rc < 0))
@@ -1752,7 +1747,7 @@ static void __devexit sbridge_remove(struct pci_dev *pdev)
1752{ 1747{
1753 struct sbridge_dev *sbridge_dev; 1748 struct sbridge_dev *sbridge_dev;
1754 1749
1755 debugf0(__FILE__ ": %s()\n", __func__); 1750 edac_dbg(0, "\n");
1756 1751
1757 /* 1752 /*
1758 * we have a trouble here: pdev value for removal will be wrong, since 1753 * we have a trouble here: pdev value for removal will be wrong, since
@@ -1801,7 +1796,7 @@ static int __init sbridge_init(void)
1801{ 1796{
1802 int pci_rc; 1797 int pci_rc;
1803 1798
1804 debugf2("MC: " __FILE__ ": %s()\n", __func__); 1799 edac_dbg(2, "\n");
1805 1800
1806 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 1801 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
1807 opstate_init(); 1802 opstate_init();
@@ -1825,7 +1820,7 @@ static int __init sbridge_init(void)
1825 */ 1820 */
1826static void __exit sbridge_exit(void) 1821static void __exit sbridge_exit(void)
1827{ 1822{
1828 debugf2("MC: " __FILE__ ": %s()\n", __func__); 1823 edac_dbg(2, "\n");
1829 pci_unregister_driver(&sbridge_driver); 1824 pci_unregister_driver(&sbridge_driver);
1830 mce_unregister_decode_chain(&sbridge_mce_dec); 1825 mce_unregister_decode_chain(&sbridge_mce_dec);
1831} 1826}
diff --git a/drivers/edac/tile_edac.c b/drivers/edac/tile_edac.c
index 7bb4614730db..1e904b7b79a0 100644
--- a/drivers/edac/tile_edac.c
+++ b/drivers/edac/tile_edac.c
@@ -69,12 +69,12 @@ static void tile_edac_check(struct mem_ctl_info *mci)
69 69
70 /* Check if the current error count is different from the saved one. */ 70 /* Check if the current error count is different from the saved one. */
71 if (mem_error.sbe_count != priv->ce_count) { 71 if (mem_error.sbe_count != priv->ce_count) {
72 dev_dbg(mci->dev, "ECC CE err on node %d\n", priv->node); 72 dev_dbg(mci->pdev, "ECC CE err on node %d\n", priv->node);
73 priv->ce_count = mem_error.sbe_count; 73 priv->ce_count = mem_error.sbe_count;
74 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 74 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
75 0, 0, 0, 75 0, 0, 0,
76 0, 0, -1, 76 0, 0, -1,
77 mci->ctl_name, "", NULL); 77 mci->ctl_name, "");
78 } 78 }
79} 79}
80 80
@@ -84,10 +84,10 @@ static void tile_edac_check(struct mem_ctl_info *mci)
84 */ 84 */
85static int __devinit tile_edac_init_csrows(struct mem_ctl_info *mci) 85static int __devinit tile_edac_init_csrows(struct mem_ctl_info *mci)
86{ 86{
87 struct csrow_info *csrow = &mci->csrows[0]; 87 struct csrow_info *csrow = mci->csrows[0];
88 struct tile_edac_priv *priv = mci->pvt_info; 88 struct tile_edac_priv *priv = mci->pvt_info;
89 struct mshim_mem_info mem_info; 89 struct mshim_mem_info mem_info;
90 struct dimm_info *dimm = csrow->channels[0].dimm; 90 struct dimm_info *dimm = csrow->channels[0]->dimm;
91 91
92 if (hv_dev_pread(priv->hv_devhdl, 0, (HV_VirtAddr)&mem_info, 92 if (hv_dev_pread(priv->hv_devhdl, 0, (HV_VirtAddr)&mem_info,
93 sizeof(struct mshim_mem_info), MSHIM_MEM_INFO_OFF) != 93 sizeof(struct mshim_mem_info), MSHIM_MEM_INFO_OFF) !=
@@ -149,7 +149,7 @@ static int __devinit tile_edac_mc_probe(struct platform_device *pdev)
149 priv->node = pdev->id; 149 priv->node = pdev->id;
150 priv->hv_devhdl = hv_devhdl; 150 priv->hv_devhdl = hv_devhdl;
151 151
152 mci->dev = &pdev->dev; 152 mci->pdev = &pdev->dev;
153 mci->mtype_cap = MEM_FLAG_DDR2; 153 mci->mtype_cap = MEM_FLAG_DDR2;
154 mci->edac_ctl_cap = EDAC_FLAG_SECDED; 154 mci->edac_ctl_cap = EDAC_FLAG_SECDED;
155 155
diff --git a/drivers/edac/x38_edac.c b/drivers/edac/x38_edac.c
index 1ac7962d63ea..08a992693e62 100644
--- a/drivers/edac/x38_edac.c
+++ b/drivers/edac/x38_edac.c
@@ -103,10 +103,10 @@ static int how_many_channel(struct pci_dev *pdev)
103 103
104 pci_read_config_byte(pdev, X38_CAPID0 + 8, &capid0_8b); 104 pci_read_config_byte(pdev, X38_CAPID0 + 8, &capid0_8b);
105 if (capid0_8b & 0x20) { /* check DCD: Dual Channel Disable */ 105 if (capid0_8b & 0x20) { /* check DCD: Dual Channel Disable */
106 debugf0("In single channel mode.\n"); 106 edac_dbg(0, "In single channel mode\n");
107 x38_channel_num = 1; 107 x38_channel_num = 1;
108 } else { 108 } else {
109 debugf0("In dual channel mode.\n"); 109 edac_dbg(0, "In dual channel mode\n");
110 x38_channel_num = 2; 110 x38_channel_num = 2;
111 } 111 }
112 112
@@ -151,7 +151,7 @@ static void x38_clear_error_info(struct mem_ctl_info *mci)
151{ 151{
152 struct pci_dev *pdev; 152 struct pci_dev *pdev;
153 153
154 pdev = to_pci_dev(mci->dev); 154 pdev = to_pci_dev(mci->pdev);
155 155
156 /* 156 /*
157 * Clear any error bits. 157 * Clear any error bits.
@@ -172,7 +172,7 @@ static void x38_get_and_clear_error_info(struct mem_ctl_info *mci,
172 struct pci_dev *pdev; 172 struct pci_dev *pdev;
173 void __iomem *window = mci->pvt_info; 173 void __iomem *window = mci->pvt_info;
174 174
175 pdev = to_pci_dev(mci->dev); 175 pdev = to_pci_dev(mci->pdev);
176 176
177 /* 177 /*
178 * This is a mess because there is no atomic way to read all the 178 * This is a mess because there is no atomic way to read all the
@@ -215,26 +215,26 @@ static void x38_process_error_info(struct mem_ctl_info *mci,
215 return; 215 return;
216 216
217 if ((info->errsts ^ info->errsts2) & X38_ERRSTS_BITS) { 217 if ((info->errsts ^ info->errsts2) & X38_ERRSTS_BITS) {
218 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 0, 0, 0, 218 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0,
219 -1, -1, -1, 219 -1, -1, -1,
220 "UE overwrote CE", "", NULL); 220 "UE overwrote CE", "");
221 info->errsts = info->errsts2; 221 info->errsts = info->errsts2;
222 } 222 }
223 223
224 for (channel = 0; channel < x38_channel_num; channel++) { 224 for (channel = 0; channel < x38_channel_num; channel++) {
225 log = info->eccerrlog[channel]; 225 log = info->eccerrlog[channel];
226 if (log & X38_ECCERRLOG_UE) { 226 if (log & X38_ECCERRLOG_UE) {
227 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 227 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
228 0, 0, 0, 228 0, 0, 0,
229 eccerrlog_row(channel, log), 229 eccerrlog_row(channel, log),
230 -1, -1, 230 -1, -1,
231 "x38 UE", "", NULL); 231 "x38 UE", "");
232 } else if (log & X38_ECCERRLOG_CE) { 232 } else if (log & X38_ECCERRLOG_CE) {
233 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 233 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
234 0, 0, eccerrlog_syndrome(log), 234 0, 0, eccerrlog_syndrome(log),
235 eccerrlog_row(channel, log), 235 eccerrlog_row(channel, log),
236 -1, -1, 236 -1, -1,
237 "x38 CE", "", NULL); 237 "x38 CE", "");
238 } 238 }
239 } 239 }
240} 240}
@@ -243,7 +243,7 @@ static void x38_check(struct mem_ctl_info *mci)
243{ 243{
244 struct x38_error_info info; 244 struct x38_error_info info;
245 245
246 debugf1("MC%d: %s()\n", mci->mc_idx, __func__); 246 edac_dbg(1, "MC%d\n", mci->mc_idx);
247 x38_get_and_clear_error_info(mci, &info); 247 x38_get_and_clear_error_info(mci, &info);
248 x38_process_error_info(mci, &info); 248 x38_process_error_info(mci, &info);
249} 249}
@@ -331,7 +331,7 @@ static int x38_probe1(struct pci_dev *pdev, int dev_idx)
331 bool stacked; 331 bool stacked;
332 void __iomem *window; 332 void __iomem *window;
333 333
334 debugf0("MC: %s()\n", __func__); 334 edac_dbg(0, "MC:\n");
335 335
336 window = x38_map_mchbar(pdev); 336 window = x38_map_mchbar(pdev);
337 if (!window) 337 if (!window)
@@ -352,9 +352,9 @@ static int x38_probe1(struct pci_dev *pdev, int dev_idx)
352 if (!mci) 352 if (!mci)
353 return -ENOMEM; 353 return -ENOMEM;
354 354
355 debugf3("MC: %s(): init mci\n", __func__); 355 edac_dbg(3, "MC: init mci\n");
356 356
357 mci->dev = &pdev->dev; 357 mci->pdev = &pdev->dev;
358 mci->mtype_cap = MEM_FLAG_DDR2; 358 mci->mtype_cap = MEM_FLAG_DDR2;
359 359
360 mci->edac_ctl_cap = EDAC_FLAG_SECDED; 360 mci->edac_ctl_cap = EDAC_FLAG_SECDED;
@@ -378,7 +378,7 @@ static int x38_probe1(struct pci_dev *pdev, int dev_idx)
378 */ 378 */
379 for (i = 0; i < mci->nr_csrows; i++) { 379 for (i = 0; i < mci->nr_csrows; i++) {
380 unsigned long nr_pages; 380 unsigned long nr_pages;
381 struct csrow_info *csrow = &mci->csrows[i]; 381 struct csrow_info *csrow = mci->csrows[i];
382 382
383 nr_pages = drb_to_nr_pages(drbs, stacked, 383 nr_pages = drb_to_nr_pages(drbs, stacked,
384 i / X38_RANKS_PER_CHANNEL, 384 i / X38_RANKS_PER_CHANNEL,
@@ -388,7 +388,7 @@ static int x38_probe1(struct pci_dev *pdev, int dev_idx)
388 continue; 388 continue;
389 389
390 for (j = 0; j < x38_channel_num; j++) { 390 for (j = 0; j < x38_channel_num; j++) {
391 struct dimm_info *dimm = csrow->channels[j].dimm; 391 struct dimm_info *dimm = csrow->channels[j]->dimm;
392 392
393 dimm->nr_pages = nr_pages / x38_channel_num; 393 dimm->nr_pages = nr_pages / x38_channel_num;
394 dimm->grain = nr_pages << PAGE_SHIFT; 394 dimm->grain = nr_pages << PAGE_SHIFT;
@@ -402,12 +402,12 @@ static int x38_probe1(struct pci_dev *pdev, int dev_idx)
402 402
403 rc = -ENODEV; 403 rc = -ENODEV;
404 if (edac_mc_add_mc(mci)) { 404 if (edac_mc_add_mc(mci)) {
405 debugf3("MC: %s(): failed edac_mc_add_mc()\n", __func__); 405 edac_dbg(3, "MC: failed edac_mc_add_mc()\n");
406 goto fail; 406 goto fail;
407 } 407 }
408 408
409 /* get this far and it's successful */ 409 /* get this far and it's successful */
410 debugf3("MC: %s(): success\n", __func__); 410 edac_dbg(3, "MC: success\n");
411 return 0; 411 return 0;
412 412
413fail: 413fail:
@@ -423,7 +423,7 @@ static int __devinit x38_init_one(struct pci_dev *pdev,
423{ 423{
424 int rc; 424 int rc;
425 425
426 debugf0("MC: %s()\n", __func__); 426 edac_dbg(0, "MC:\n");
427 427
428 if (pci_enable_device(pdev) < 0) 428 if (pci_enable_device(pdev) < 0)
429 return -EIO; 429 return -EIO;
@@ -439,7 +439,7 @@ static void __devexit x38_remove_one(struct pci_dev *pdev)
439{ 439{
440 struct mem_ctl_info *mci; 440 struct mem_ctl_info *mci;
441 441
442 debugf0("%s()\n", __func__); 442 edac_dbg(0, "\n");
443 443
444 mci = edac_mc_del_mc(&pdev->dev); 444 mci = edac_mc_del_mc(&pdev->dev);
445 if (!mci) 445 if (!mci)
@@ -472,7 +472,7 @@ static int __init x38_init(void)
472{ 472{
473 int pci_rc; 473 int pci_rc;
474 474
475 debugf3("MC: %s()\n", __func__); 475 edac_dbg(3, "MC:\n");
476 476
477 /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 477 /* Ensure that the OPSTATE is set correctly for POLL or NMI */
478 opstate_init(); 478 opstate_init();
@@ -486,14 +486,14 @@ static int __init x38_init(void)
486 mci_pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 486 mci_pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
487 PCI_DEVICE_ID_INTEL_X38_HB, NULL); 487 PCI_DEVICE_ID_INTEL_X38_HB, NULL);
488 if (!mci_pdev) { 488 if (!mci_pdev) {
489 debugf0("x38 pci_get_device fail\n"); 489 edac_dbg(0, "x38 pci_get_device fail\n");
490 pci_rc = -ENODEV; 490 pci_rc = -ENODEV;
491 goto fail1; 491 goto fail1;
492 } 492 }
493 493
494 pci_rc = x38_init_one(mci_pdev, x38_pci_tbl); 494 pci_rc = x38_init_one(mci_pdev, x38_pci_tbl);
495 if (pci_rc < 0) { 495 if (pci_rc < 0) {
496 debugf0("x38 init fail\n"); 496 edac_dbg(0, "x38 init fail\n");
497 pci_rc = -ENODEV; 497 pci_rc = -ENODEV;
498 goto fail1; 498 goto fail1;
499 } 499 }
@@ -513,7 +513,7 @@ fail0:
513 513
514static void __exit x38_exit(void) 514static void __exit x38_exit(void)
515{ 515{
516 debugf3("MC: %s()\n", __func__); 516 edac_dbg(3, "MC:\n");
517 517
518 pci_unregister_driver(&x38_driver); 518 pci_unregister_driver(&x38_driver);
519 if (!x38_registered) { 519 if (!x38_registered) {
diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
index 16716356d1fe..e175c8ed4ec4 100644
--- a/drivers/extcon/Kconfig
+++ b/drivers/extcon/Kconfig
@@ -33,7 +33,7 @@ config EXTCON_MAX77693
33 33
34config EXTCON_MAX8997 34config EXTCON_MAX8997
35 tristate "MAX8997 EXTCON Support" 35 tristate "MAX8997 EXTCON Support"
36 depends on MFD_MAX8997 36 depends on MFD_MAX8997 && IRQ_DOMAIN
37 help 37 help
38 If you say yes here you get support for the MUIC device of 38 If you say yes here you get support for the MUIC device of
39 Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory 39 Maxim MAX8997 PMIC. The MAX8997 MUIC is a USB port accessory
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index a4ed30bd9a41..ef9090a4271d 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -26,6 +26,7 @@
26#include <linux/mfd/max8997.h> 26#include <linux/mfd/max8997.h>
27#include <linux/mfd/max8997-private.h> 27#include <linux/mfd/max8997-private.h>
28#include <linux/extcon.h> 28#include <linux/extcon.h>
29#include <linux/irqdomain.h>
29 30
30#define DEV_NAME "max8997-muic" 31#define DEV_NAME "max8997-muic"
31 32
@@ -77,6 +78,7 @@
77struct max8997_muic_irq { 78struct max8997_muic_irq {
78 unsigned int irq; 79 unsigned int irq;
79 const char *name; 80 const char *name;
81 unsigned int virq;
80}; 82};
81 83
82static struct max8997_muic_irq muic_irqs[] = { 84static struct max8997_muic_irq muic_irqs[] = {
@@ -343,12 +345,10 @@ static void max8997_muic_irq_work(struct work_struct *work)
343{ 345{
344 struct max8997_muic_info *info = container_of(work, 346 struct max8997_muic_info *info = container_of(work,
345 struct max8997_muic_info, irq_work); 347 struct max8997_muic_info, irq_work);
346 struct max8997_dev *max8997 = i2c_get_clientdata(info->muic);
347 u8 status[2]; 348 u8 status[2];
348 u8 adc, chg_type; 349 u8 adc, chg_type;
349 350 int irq_type = 0;
350 int irq_type = info->irq - max8997->irq_base; 351 int i, ret;
351 int ret;
352 352
353 mutex_lock(&info->mutex); 353 mutex_lock(&info->mutex);
354 354
@@ -363,6 +363,10 @@ static void max8997_muic_irq_work(struct work_struct *work)
363 dev_dbg(info->dev, "%s: STATUS1:0x%x, 2:0x%x\n", __func__, 363 dev_dbg(info->dev, "%s: STATUS1:0x%x, 2:0x%x\n", __func__,
364 status[0], status[1]); 364 status[0], status[1]);
365 365
366 for (i = 0 ; i < ARRAY_SIZE(muic_irqs) ; i++)
367 if (info->irq == muic_irqs[i].virq)
368 irq_type = muic_irqs[i].irq;
369
366 switch (irq_type) { 370 switch (irq_type) {
367 case MAX8997_MUICIRQ_ADC: 371 case MAX8997_MUICIRQ_ADC:
368 adc = status[0] & STATUS1_ADC_MASK; 372 adc = status[0] & STATUS1_ADC_MASK;
@@ -448,11 +452,15 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev)
448 452
449 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { 453 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
450 struct max8997_muic_irq *muic_irq = &muic_irqs[i]; 454 struct max8997_muic_irq *muic_irq = &muic_irqs[i];
455 int virq = 0;
456
457 virq = irq_create_mapping(max8997->irq_domain, muic_irq->irq);
458 if (!virq)
459 goto err_irq;
460 muic_irq->virq = virq;
451 461
452 ret = request_threaded_irq(pdata->irq_base + muic_irq->irq, 462 ret = request_threaded_irq(virq, NULL,max8997_muic_irq_handler,
453 NULL, max8997_muic_irq_handler, 463 0, muic_irq->name, info);
454 0, muic_irq->name,
455 info);
456 if (ret) { 464 if (ret) {
457 dev_err(&pdev->dev, 465 dev_err(&pdev->dev,
458 "failed: irq request (IRQ: %d," 466 "failed: irq request (IRQ: %d,"
@@ -496,7 +504,7 @@ err_extcon:
496 kfree(info->edev); 504 kfree(info->edev);
497err_irq: 505err_irq:
498 while (--i >= 0) 506 while (--i >= 0)
499 free_irq(pdata->irq_base + muic_irqs[i].irq, info); 507 free_irq(muic_irqs[i].virq, info);
500 kfree(info); 508 kfree(info);
501err_kfree: 509err_kfree:
502 return ret; 510 return ret;
@@ -505,11 +513,10 @@ err_kfree:
505static int __devexit max8997_muic_remove(struct platform_device *pdev) 513static int __devexit max8997_muic_remove(struct platform_device *pdev)
506{ 514{
507 struct max8997_muic_info *info = platform_get_drvdata(pdev); 515 struct max8997_muic_info *info = platform_get_drvdata(pdev);
508 struct max8997_dev *max8997 = i2c_get_clientdata(info->muic);
509 int i; 516 int i;
510 517
511 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) 518 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++)
512 free_irq(max8997->irq_base + muic_irqs[i].irq, info); 519 free_irq(muic_irqs[i].virq, info);
513 cancel_work_sync(&info->irq_work); 520 cancel_work_sync(&info->irq_work);
514 521
515 extcon_dev_unregister(info->edev); 522 extcon_dev_unregister(info->edev);
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index 4d460ef87161..7a05fd24d68b 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -398,6 +398,14 @@ static ssize_t guid_show(struct device *dev,
398 return ret; 398 return ret;
399} 399}
400 400
401static ssize_t is_local_show(struct device *dev,
402 struct device_attribute *attr, char *buf)
403{
404 struct fw_device *device = fw_device(dev);
405
406 return sprintf(buf, "%u\n", device->is_local);
407}
408
401static int units_sprintf(char *buf, const u32 *directory) 409static int units_sprintf(char *buf, const u32 *directory)
402{ 410{
403 struct fw_csr_iterator ci; 411 struct fw_csr_iterator ci;
@@ -447,6 +455,7 @@ static ssize_t units_show(struct device *dev,
447static struct device_attribute fw_device_attributes[] = { 455static struct device_attribute fw_device_attributes[] = {
448 __ATTR_RO(config_rom), 456 __ATTR_RO(config_rom),
449 __ATTR_RO(guid), 457 __ATTR_RO(guid),
458 __ATTR_RO(is_local),
450 __ATTR_RO(units), 459 __ATTR_RO(units),
451 __ATTR_NULL, 460 __ATTR_NULL,
452}; 461};
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c
index 8382e27e9a27..38c0aa60b2cb 100644
--- a/drivers/firewire/core-iso.c
+++ b/drivers/firewire/core-iso.c
@@ -146,7 +146,7 @@ EXPORT_SYMBOL(fw_iso_buffer_destroy);
146/* Convert DMA address to offset into virtually contiguous buffer. */ 146/* Convert DMA address to offset into virtually contiguous buffer. */
147size_t fw_iso_buffer_lookup(struct fw_iso_buffer *buffer, dma_addr_t completed) 147size_t fw_iso_buffer_lookup(struct fw_iso_buffer *buffer, dma_addr_t completed)
148{ 148{
149 int i; 149 size_t i;
150 dma_addr_t address; 150 dma_addr_t address;
151 ssize_t offset; 151 ssize_t offset;
152 152
diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index 780708dc6e25..87d6f2d2f02d 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -525,9 +525,10 @@ const struct fw_address_region fw_high_memory_region =
525 { .start = 0x000100000000ULL, .end = 0xffffe0000000ULL, }; 525 { .start = 0x000100000000ULL, .end = 0xffffe0000000ULL, };
526EXPORT_SYMBOL(fw_high_memory_region); 526EXPORT_SYMBOL(fw_high_memory_region);
527 527
528#if 0 528static const struct fw_address_region low_memory_region =
529const struct fw_address_region fw_low_memory_region =
530 { .start = 0x000000000000ULL, .end = 0x000100000000ULL, }; 529 { .start = 0x000000000000ULL, .end = 0x000100000000ULL, };
530
531#if 0
531const struct fw_address_region fw_private_region = 532const struct fw_address_region fw_private_region =
532 { .start = 0xffffe0000000ULL, .end = 0xfffff0000000ULL, }; 533 { .start = 0xffffe0000000ULL, .end = 0xfffff0000000ULL, };
533const struct fw_address_region fw_csr_region = 534const struct fw_address_region fw_csr_region =
@@ -1198,6 +1199,23 @@ static struct fw_address_handler registers = {
1198 .address_callback = handle_registers, 1199 .address_callback = handle_registers,
1199}; 1200};
1200 1201
1202static void handle_low_memory(struct fw_card *card, struct fw_request *request,
1203 int tcode, int destination, int source, int generation,
1204 unsigned long long offset, void *payload, size_t length,
1205 void *callback_data)
1206{
1207 /*
1208 * This catches requests not handled by the physical DMA unit,
1209 * i.e., wrong transaction types or unauthorized source nodes.
1210 */
1211 fw_send_response(card, request, RCODE_TYPE_ERROR);
1212}
1213
1214static struct fw_address_handler low_memory = {
1215 .length = 0x000100000000ULL,
1216 .address_callback = handle_low_memory,
1217};
1218
1201MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); 1219MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");
1202MODULE_DESCRIPTION("Core IEEE1394 transaction logic"); 1220MODULE_DESCRIPTION("Core IEEE1394 transaction logic");
1203MODULE_LICENSE("GPL"); 1221MODULE_LICENSE("GPL");
@@ -1259,6 +1277,7 @@ static int __init fw_core_init(void)
1259 1277
1260 fw_core_add_address_handler(&topology_map, &topology_map_region); 1278 fw_core_add_address_handler(&topology_map, &topology_map_region);
1261 fw_core_add_address_handler(&registers, &registers_region); 1279 fw_core_add_address_handler(&registers, &registers_region);
1280 fw_core_add_address_handler(&low_memory, &low_memory_region);
1262 fw_core_add_descriptor(&vendor_id_descriptor); 1281 fw_core_add_descriptor(&vendor_id_descriptor);
1263 fw_core_add_descriptor(&model_id_descriptor); 1282 fw_core_add_descriptor(&model_id_descriptor);
1264 1283
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index c1af05e834b6..c788dbdaf3bc 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -191,6 +191,7 @@ struct fw_ohci {
191 unsigned quirks; 191 unsigned quirks;
192 unsigned int pri_req_max; 192 unsigned int pri_req_max;
193 u32 bus_time; 193 u32 bus_time;
194 bool bus_time_running;
194 bool is_root; 195 bool is_root;
195 bool csr_state_setclear_abdicate; 196 bool csr_state_setclear_abdicate;
196 int n_ir; 197 int n_ir;
@@ -1726,6 +1727,13 @@ static u32 update_bus_time(struct fw_ohci *ohci)
1726{ 1727{
1727 u32 cycle_time_seconds = get_cycle_time(ohci) >> 25; 1728 u32 cycle_time_seconds = get_cycle_time(ohci) >> 25;
1728 1729
1730 if (unlikely(!ohci->bus_time_running)) {
1731 reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_cycle64Seconds);
1732 ohci->bus_time = (lower_32_bits(get_seconds()) & ~0x7f) |
1733 (cycle_time_seconds & 0x40);
1734 ohci->bus_time_running = true;
1735 }
1736
1729 if ((ohci->bus_time & 0x40) != (cycle_time_seconds & 0x40)) 1737 if ((ohci->bus_time & 0x40) != (cycle_time_seconds & 0x40))
1730 ohci->bus_time += 0x40; 1738 ohci->bus_time += 0x40;
1731 1739
@@ -2213,7 +2221,7 @@ static int ohci_enable(struct fw_card *card,
2213{ 2221{
2214 struct fw_ohci *ohci = fw_ohci(card); 2222 struct fw_ohci *ohci = fw_ohci(card);
2215 struct pci_dev *dev = to_pci_dev(card->device); 2223 struct pci_dev *dev = to_pci_dev(card->device);
2216 u32 lps, seconds, version, irqs; 2224 u32 lps, version, irqs;
2217 int i, ret; 2225 int i, ret;
2218 2226
2219 if (software_reset(ohci)) { 2227 if (software_reset(ohci)) {
@@ -2269,9 +2277,12 @@ static int ohci_enable(struct fw_card *card,
2269 (OHCI1394_MAX_PHYS_RESP_RETRIES << 8) | 2277 (OHCI1394_MAX_PHYS_RESP_RETRIES << 8) |
2270 (200 << 16)); 2278 (200 << 16));
2271 2279
2272 seconds = lower_32_bits(get_seconds()); 2280 ohci->bus_time_running = false;
2273 reg_write(ohci, OHCI1394_IsochronousCycleTimer, seconds << 25); 2281
2274 ohci->bus_time = seconds & ~0x3f; 2282 for (i = 0; i < 32; i++)
2283 if (ohci->ir_context_support & (1 << i))
2284 reg_write(ohci, OHCI1394_IsoRcvContextControlClear(i),
2285 IR_CONTEXT_MULTI_CHANNEL_MODE);
2275 2286
2276 version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff; 2287 version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff;
2277 if (version >= OHCI_VERSION_1_1) { 2288 if (version >= OHCI_VERSION_1_1) {
@@ -2369,7 +2380,6 @@ static int ohci_enable(struct fw_card *card,
2369 OHCI1394_postedWriteErr | 2380 OHCI1394_postedWriteErr |
2370 OHCI1394_selfIDComplete | 2381 OHCI1394_selfIDComplete |
2371 OHCI1394_regAccessFail | 2382 OHCI1394_regAccessFail |
2372 OHCI1394_cycle64Seconds |
2373 OHCI1394_cycleInconsistent | 2383 OHCI1394_cycleInconsistent |
2374 OHCI1394_unrecoverableError | 2384 OHCI1394_unrecoverableError |
2375 OHCI1394_cycleTooLong | 2385 OHCI1394_cycleTooLong |
@@ -2658,7 +2668,8 @@ static void ohci_write_csr(struct fw_card *card, int csr_offset, u32 value)
2658 2668
2659 case CSR_BUS_TIME: 2669 case CSR_BUS_TIME:
2660 spin_lock_irqsave(&ohci->lock, flags); 2670 spin_lock_irqsave(&ohci->lock, flags);
2661 ohci->bus_time = (ohci->bus_time & 0x7f) | (value & ~0x7f); 2671 ohci->bus_time = (update_bus_time(ohci) & 0x40) |
2672 (value & ~0x7f);
2662 spin_unlock_irqrestore(&ohci->lock, flags); 2673 spin_unlock_irqrestore(&ohci->lock, flags);
2663 break; 2674 break;
2664 2675
@@ -3539,6 +3550,13 @@ static int __devinit pci_probe(struct pci_dev *dev,
3539 3550
3540 INIT_WORK(&ohci->bus_reset_work, bus_reset_work); 3551 INIT_WORK(&ohci->bus_reset_work, bus_reset_work);
3541 3552
3553 if (!(pci_resource_flags(dev, 0) & IORESOURCE_MEM) ||
3554 pci_resource_len(dev, 0) < OHCI1394_REGISTER_SIZE) {
3555 dev_err(&dev->dev, "invalid MMIO resource\n");
3556 err = -ENXIO;
3557 goto fail_disable;
3558 }
3559
3542 err = pci_request_region(dev, 0, ohci_driver_name); 3560 err = pci_request_region(dev, 0, ohci_driver_name);
3543 if (err) { 3561 if (err) {
3544 dev_err(&dev->dev, "MMIO resource unavailable\n"); 3562 dev_err(&dev->dev, "MMIO resource unavailable\n");
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 502b5ea43f4f..b16c8a72a2e2 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -597,6 +597,13 @@ config GPIO_AB8500
597 help 597 help
598 Select this to enable the AB8500 IC GPIO driver 598 Select this to enable the AB8500 IC GPIO driver
599 599
600config GPIO_TPS6586X
601 bool "TPS6586X GPIO"
602 depends on MFD_TPS6586X
603 help
604 Select this option to enable GPIO driver for the TPS6586X
605 chip family.
606
600config GPIO_TPS65910 607config GPIO_TPS65910
601 bool "TPS65910 GPIO" 608 bool "TPS65910 GPIO"
602 depends on MFD_TPS65910 609 depends on MFD_TPS65910
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index d37048105a87..153caceeb053 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o
63obj-$(CONFIG_ARCH_TEGRA) += gpio-tegra.o 63obj-$(CONFIG_ARCH_TEGRA) += gpio-tegra.o
64obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o 64obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o
65obj-$(CONFIG_ARCH_DAVINCI_TNETV107X) += gpio-tnetv107x.o 65obj-$(CONFIG_ARCH_DAVINCI_TNETV107X) += gpio-tnetv107x.o
66obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o
66obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o 67obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o
67obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o 68obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o
68obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o 69obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o
diff --git a/drivers/gpio/gpio-tps6586x.c b/drivers/gpio/gpio-tps6586x.c
new file mode 100644
index 000000000000..2526b3bb0fae
--- /dev/null
+++ b/drivers/gpio/gpio-tps6586x.c
@@ -0,0 +1,158 @@
1/*
2 * TI TPS6586x GPIO driver
3 *
4 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
5 * Author: Laxman dewangan <ldewangan@nvidia.com>
6 *
7 * Based on tps6586x.c
8 * Copyright (c) 2010 CompuLab Ltd.
9 * Mike Rapoport <mike@compulab.co.il>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms and conditions of the GNU General Public License,
13 * version 2, as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#include <linux/errno.h>
25#include <linux/gpio.h>
26#include <linux/kernel.h>
27#include <linux/module.h>
28#include <linux/mfd/tps6586x.h>
29#include <linux/of_device.h>
30#include <linux/platform_device.h>
31
32/* GPIO control registers */
33#define TPS6586X_GPIOSET1 0x5d
34#define TPS6586X_GPIOSET2 0x5e
35
36struct tps6586x_gpio {
37 struct gpio_chip gpio_chip;
38 struct device *parent;
39};
40
41static inline struct tps6586x_gpio *to_tps6586x_gpio(struct gpio_chip *chip)
42{
43 return container_of(chip, struct tps6586x_gpio, gpio_chip);
44}
45
46static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset)
47{
48 struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc);
49 uint8_t val;
50 int ret;
51
52 ret = tps6586x_read(tps6586x_gpio->parent, TPS6586X_GPIOSET2, &val);
53 if (ret)
54 return ret;
55
56 return !!(val & (1 << offset));
57}
58
59static void tps6586x_gpio_set(struct gpio_chip *gc, unsigned offset,
60 int value)
61{
62 struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc);
63
64 tps6586x_update(tps6586x_gpio->parent, TPS6586X_GPIOSET2,
65 value << offset, 1 << offset);
66}
67
68static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset,
69 int value)
70{
71 struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc);
72 uint8_t val, mask;
73
74 tps6586x_gpio_set(gc, offset, value);
75
76 val = 0x1 << (offset * 2);
77 mask = 0x3 << (offset * 2);
78
79 return tps6586x_update(tps6586x_gpio->parent, TPS6586X_GPIOSET1,
80 val, mask);
81}
82
83static int __devinit tps6586x_gpio_probe(struct platform_device *pdev)
84{
85 struct tps6586x_platform_data *pdata;
86 struct tps6586x_gpio *tps6586x_gpio;
87 int ret;
88
89 pdata = dev_get_platdata(pdev->dev.parent);
90 tps6586x_gpio = devm_kzalloc(&pdev->dev,
91 sizeof(*tps6586x_gpio), GFP_KERNEL);
92 if (!tps6586x_gpio) {
93 dev_err(&pdev->dev, "Could not allocate tps6586x_gpio\n");
94 return -ENOMEM;
95 }
96
97 tps6586x_gpio->parent = pdev->dev.parent;
98
99 tps6586x_gpio->gpio_chip.owner = THIS_MODULE;
100 tps6586x_gpio->gpio_chip.label = pdev->name;
101 tps6586x_gpio->gpio_chip.dev = &pdev->dev;
102 tps6586x_gpio->gpio_chip.ngpio = 4;
103 tps6586x_gpio->gpio_chip.can_sleep = 1;
104
105 /* FIXME: add handling of GPIOs as dedicated inputs */
106 tps6586x_gpio->gpio_chip.direction_output = tps6586x_gpio_output;
107 tps6586x_gpio->gpio_chip.set = tps6586x_gpio_set;
108 tps6586x_gpio->gpio_chip.get = tps6586x_gpio_get;
109
110#ifdef CONFIG_OF_GPIO
111 tps6586x_gpio->gpio_chip.of_node = pdev->dev.parent->of_node;
112#endif
113 if (pdata && pdata->gpio_base)
114 tps6586x_gpio->gpio_chip.base = pdata->gpio_base;
115 else
116 tps6586x_gpio->gpio_chip.base = -1;
117
118 ret = gpiochip_add(&tps6586x_gpio->gpio_chip);
119 if (ret < 0) {
120 dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
121 return ret;
122 }
123
124 platform_set_drvdata(pdev, tps6586x_gpio);
125
126 return ret;
127}
128
129static int __devexit tps6586x_gpio_remove(struct platform_device *pdev)
130{
131 struct tps6586x_gpio *tps6586x_gpio = platform_get_drvdata(pdev);
132
133 return gpiochip_remove(&tps6586x_gpio->gpio_chip);
134}
135
136static struct platform_driver tps6586x_gpio_driver = {
137 .driver.name = "tps6586x-gpio",
138 .driver.owner = THIS_MODULE,
139 .probe = tps6586x_gpio_probe,
140 .remove = __devexit_p(tps6586x_gpio_remove),
141};
142
143static int __init tps6586x_gpio_init(void)
144{
145 return platform_driver_register(&tps6586x_gpio_driver);
146}
147subsys_initcall(tps6586x_gpio_init);
148
149static void __exit tps6586x_gpio_exit(void)
150{
151 platform_driver_unregister(&tps6586x_gpio_driver);
152}
153module_exit(tps6586x_gpio_exit);
154
155MODULE_ALIAS("platform:tps6586x-gpio");
156MODULE_DESCRIPTION("GPIO interface for TPS6586X PMIC");
157MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
158MODULE_LICENSE("GPL");
diff --git a/drivers/gpu/drm/exynos/exynos_drm_connector.c b/drivers/gpu/drm/exynos/exynos_drm_connector.c
index bf791fa0e50d..d9568198c300 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_connector.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_connector.c
@@ -196,7 +196,8 @@ static int exynos_drm_connector_mode_valid(struct drm_connector *connector,
196 return ret; 196 return ret;
197} 197}
198 198
199struct drm_encoder *exynos_drm_best_encoder(struct drm_connector *connector) 199static struct drm_encoder *exynos_drm_best_encoder(
200 struct drm_connector *connector)
200{ 201{
201 struct drm_device *dev = connector->dev; 202 struct drm_device *dev = connector->dev;
202 struct exynos_drm_connector *exynos_connector = 203 struct exynos_drm_connector *exynos_connector =
diff --git a/drivers/gpu/drm/exynos/exynos_drm_core.c b/drivers/gpu/drm/exynos/exynos_drm_core.c
index eaf630dc5dba..84dd099eae3b 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_core.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_core.c
@@ -33,7 +33,6 @@
33#include "exynos_drm_fbdev.h" 33#include "exynos_drm_fbdev.h"
34 34
35static LIST_HEAD(exynos_drm_subdrv_list); 35static LIST_HEAD(exynos_drm_subdrv_list);
36static struct drm_device *drm_dev;
37 36
38static int exynos_drm_subdrv_probe(struct drm_device *dev, 37static int exynos_drm_subdrv_probe(struct drm_device *dev,
39 struct exynos_drm_subdrv *subdrv) 38 struct exynos_drm_subdrv *subdrv)
@@ -120,8 +119,6 @@ int exynos_drm_device_register(struct drm_device *dev)
120 if (!dev) 119 if (!dev)
121 return -EINVAL; 120 return -EINVAL;
122 121
123 drm_dev = dev;
124
125 list_for_each_entry_safe(subdrv, n, &exynos_drm_subdrv_list, list) { 122 list_for_each_entry_safe(subdrv, n, &exynos_drm_subdrv_list, list) {
126 subdrv->drm_dev = dev; 123 subdrv->drm_dev = dev;
127 err = exynos_drm_subdrv_probe(dev, subdrv); 124 err = exynos_drm_subdrv_probe(dev, subdrv);
@@ -149,8 +146,6 @@ int exynos_drm_device_unregister(struct drm_device *dev)
149 list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list) 146 list_for_each_entry(subdrv, &exynos_drm_subdrv_list, list)
150 exynos_drm_subdrv_remove(dev, subdrv); 147 exynos_drm_subdrv_remove(dev, subdrv);
151 148
152 drm_dev = NULL;
153
154 return 0; 149 return 0;
155} 150}
156EXPORT_SYMBOL_GPL(exynos_drm_device_unregister); 151EXPORT_SYMBOL_GPL(exynos_drm_device_unregister);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 32a34c85899b..abb1e2f8227f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -29,21 +29,23 @@
29#include "drmP.h" 29#include "drmP.h"
30#include "drm_crtc_helper.h" 30#include "drm_crtc_helper.h"
31 31
32#include "exynos_drm_crtc.h"
33#include "exynos_drm_drv.h" 32#include "exynos_drm_drv.h"
34#include "exynos_drm_fb.h"
35#include "exynos_drm_encoder.h" 33#include "exynos_drm_encoder.h"
36#include "exynos_drm_gem.h" 34#include "exynos_drm_plane.h"
37 35
38#define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc,\ 36#define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc,\
39 drm_crtc) 37 drm_crtc)
40 38
39enum exynos_crtc_mode {
40 CRTC_MODE_NORMAL, /* normal mode */
41 CRTC_MODE_BLANK, /* The private plane of crtc is blank */
42};
43
41/* 44/*
42 * Exynos specific crtc structure. 45 * Exynos specific crtc structure.
43 * 46 *
44 * @drm_crtc: crtc object. 47 * @drm_crtc: crtc object.
45 * @overlay: contain information common to display controller and hdmi and 48 * @drm_plane: pointer of private plane object for this crtc
46 * contents of this overlay object would be copied to sub driver size.
47 * @pipe: a crtc index created at load() with a new crtc object creation 49 * @pipe: a crtc index created at load() with a new crtc object creation
48 * and the crtc object would be set to private->crtc array 50 * and the crtc object would be set to private->crtc array
49 * to get a crtc object corresponding to this pipe from private->crtc 51 * to get a crtc object corresponding to this pipe from private->crtc
@@ -52,115 +54,16 @@
52 * we can refer to the crtc to current hardware interrupt occured through 54 * we can refer to the crtc to current hardware interrupt occured through
53 * this pipe value. 55 * this pipe value.
54 * @dpms: store the crtc dpms value 56 * @dpms: store the crtc dpms value
57 * @mode: store the crtc mode value
55 */ 58 */
56struct exynos_drm_crtc { 59struct exynos_drm_crtc {
57 struct drm_crtc drm_crtc; 60 struct drm_crtc drm_crtc;
58 struct exynos_drm_overlay overlay; 61 struct drm_plane *plane;
59 unsigned int pipe; 62 unsigned int pipe;
60 unsigned int dpms; 63 unsigned int dpms;
64 enum exynos_crtc_mode mode;
61}; 65};
62 66
63static void exynos_drm_crtc_apply(struct drm_crtc *crtc)
64{
65 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
66 struct exynos_drm_overlay *overlay = &exynos_crtc->overlay;
67
68 exynos_drm_fn_encoder(crtc, overlay,
69 exynos_drm_encoder_crtc_mode_set);
70 exynos_drm_fn_encoder(crtc, &exynos_crtc->pipe,
71 exynos_drm_encoder_crtc_commit);
72}
73
74int exynos_drm_overlay_update(struct exynos_drm_overlay *overlay,
75 struct drm_framebuffer *fb,
76 struct drm_display_mode *mode,
77 struct exynos_drm_crtc_pos *pos)
78{
79 struct exynos_drm_gem_buf *buffer;
80 unsigned int actual_w;
81 unsigned int actual_h;
82 int nr = exynos_drm_format_num_buffers(fb->pixel_format);
83 int i;
84
85 for (i = 0; i < nr; i++) {
86 buffer = exynos_drm_fb_buffer(fb, i);
87 if (!buffer) {
88 DRM_LOG_KMS("buffer is null\n");
89 return -EFAULT;
90 }
91
92 overlay->dma_addr[i] = buffer->dma_addr;
93 overlay->vaddr[i] = buffer->kvaddr;
94
95 DRM_DEBUG_KMS("buffer: %d, vaddr = 0x%lx, dma_addr = 0x%lx\n",
96 i, (unsigned long)overlay->vaddr[i],
97 (unsigned long)overlay->dma_addr[i]);
98 }
99
100 actual_w = min((mode->hdisplay - pos->crtc_x), pos->crtc_w);
101 actual_h = min((mode->vdisplay - pos->crtc_y), pos->crtc_h);
102
103 /* set drm framebuffer data. */
104 overlay->fb_x = pos->fb_x;
105 overlay->fb_y = pos->fb_y;
106 overlay->fb_width = fb->width;
107 overlay->fb_height = fb->height;
108 overlay->src_width = pos->src_w;
109 overlay->src_height = pos->src_h;
110 overlay->bpp = fb->bits_per_pixel;
111 overlay->pitch = fb->pitches[0];
112 overlay->pixel_format = fb->pixel_format;
113
114 /* set overlay range to be displayed. */
115 overlay->crtc_x = pos->crtc_x;
116 overlay->crtc_y = pos->crtc_y;
117 overlay->crtc_width = actual_w;
118 overlay->crtc_height = actual_h;
119
120 /* set drm mode data. */
121 overlay->mode_width = mode->hdisplay;
122 overlay->mode_height = mode->vdisplay;
123 overlay->refresh = mode->vrefresh;
124 overlay->scan_flag = mode->flags;
125
126 DRM_DEBUG_KMS("overlay : offset_x/y(%d,%d), width/height(%d,%d)",
127 overlay->crtc_x, overlay->crtc_y,
128 overlay->crtc_width, overlay->crtc_height);
129
130 return 0;
131}
132
133static int exynos_drm_crtc_update(struct drm_crtc *crtc)
134{
135 struct exynos_drm_crtc *exynos_crtc;
136 struct exynos_drm_overlay *overlay;
137 struct exynos_drm_crtc_pos pos;
138 struct drm_display_mode *mode = &crtc->mode;
139 struct drm_framebuffer *fb = crtc->fb;
140
141 if (!mode || !fb)
142 return -EINVAL;
143
144 exynos_crtc = to_exynos_crtc(crtc);
145 overlay = &exynos_crtc->overlay;
146
147 memset(&pos, 0, sizeof(struct exynos_drm_crtc_pos));
148
149 /* it means the offset of framebuffer to be displayed. */
150 pos.fb_x = crtc->x;
151 pos.fb_y = crtc->y;
152
153 /* OSD position to be displayed. */
154 pos.crtc_x = 0;
155 pos.crtc_y = 0;
156 pos.crtc_w = fb->width - crtc->x;
157 pos.crtc_h = fb->height - crtc->y;
158 pos.src_w = pos.crtc_w;
159 pos.src_h = pos.crtc_h;
160
161 return exynos_drm_overlay_update(overlay, crtc->fb, mode, &pos);
162}
163
164static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode) 67static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
165{ 68{
166 struct drm_device *dev = crtc->dev; 69 struct drm_device *dev = crtc->dev;
@@ -175,23 +78,8 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
175 78
176 mutex_lock(&dev->struct_mutex); 79 mutex_lock(&dev->struct_mutex);
177 80
178 switch (mode) { 81 exynos_drm_fn_encoder(crtc, &mode, exynos_drm_encoder_crtc_dpms);
179 case DRM_MODE_DPMS_ON: 82 exynos_crtc->dpms = mode;
180 exynos_drm_fn_encoder(crtc, &mode,
181 exynos_drm_encoder_crtc_dpms);
182 exynos_crtc->dpms = mode;
183 break;
184 case DRM_MODE_DPMS_STANDBY:
185 case DRM_MODE_DPMS_SUSPEND:
186 case DRM_MODE_DPMS_OFF:
187 exynos_drm_fn_encoder(crtc, &mode,
188 exynos_drm_encoder_crtc_dpms);
189 exynos_crtc->dpms = mode;
190 break;
191 default:
192 DRM_ERROR("unspecified mode %d\n", mode);
193 break;
194 }
195 83
196 mutex_unlock(&dev->struct_mutex); 84 mutex_unlock(&dev->struct_mutex);
197} 85}
@@ -209,30 +97,8 @@ static void exynos_drm_crtc_commit(struct drm_crtc *crtc)
209 97
210 DRM_DEBUG_KMS("%s\n", __FILE__); 98 DRM_DEBUG_KMS("%s\n", __FILE__);
211 99
212 /* 100 exynos_plane_commit(exynos_crtc->plane);
213 * when set_crtc is requested from user or at booting time, 101 exynos_plane_dpms(exynos_crtc->plane, DRM_MODE_DPMS_ON);
214 * crtc->commit would be called without dpms call so if dpms is
215 * no power on then crtc->dpms should be called
216 * with DRM_MODE_DPMS_ON for the hardware power to be on.
217 */
218 if (exynos_crtc->dpms != DRM_MODE_DPMS_ON) {
219 int mode = DRM_MODE_DPMS_ON;
220
221 /*
222 * enable hardware(power on) to all encoders hdmi connected
223 * to current crtc.
224 */
225 exynos_drm_crtc_dpms(crtc, mode);
226 /*
227 * enable dma to all encoders connected to current crtc and
228 * lcd panel.
229 */
230 exynos_drm_fn_encoder(crtc, &mode,
231 exynos_drm_encoder_dpms_from_crtc);
232 }
233
234 exynos_drm_fn_encoder(crtc, &exynos_crtc->pipe,
235 exynos_drm_encoder_crtc_commit);
236} 102}
237 103
238static bool 104static bool
@@ -251,31 +117,61 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
251 struct drm_display_mode *adjusted_mode, int x, int y, 117 struct drm_display_mode *adjusted_mode, int x, int y,
252 struct drm_framebuffer *old_fb) 118 struct drm_framebuffer *old_fb)
253{ 119{
120 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
121 struct drm_plane *plane = exynos_crtc->plane;
122 unsigned int crtc_w;
123 unsigned int crtc_h;
124 int pipe = exynos_crtc->pipe;
125 int ret;
126
254 DRM_DEBUG_KMS("%s\n", __FILE__); 127 DRM_DEBUG_KMS("%s\n", __FILE__);
255 128
129 exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
130
256 /* 131 /*
257 * copy the mode data adjusted by mode_fixup() into crtc->mode 132 * copy the mode data adjusted by mode_fixup() into crtc->mode
258 * so that hardware can be seet to proper mode. 133 * so that hardware can be seet to proper mode.
259 */ 134 */
260 memcpy(&crtc->mode, adjusted_mode, sizeof(*adjusted_mode)); 135 memcpy(&crtc->mode, adjusted_mode, sizeof(*adjusted_mode));
261 136
262 return exynos_drm_crtc_update(crtc); 137 crtc_w = crtc->fb->width - x;
138 crtc_h = crtc->fb->height - y;
139
140 ret = exynos_plane_mode_set(plane, crtc, crtc->fb, 0, 0, crtc_w, crtc_h,
141 x, y, crtc_w, crtc_h);
142 if (ret)
143 return ret;
144
145 plane->crtc = crtc;
146 plane->fb = crtc->fb;
147
148 exynos_drm_fn_encoder(crtc, &pipe, exynos_drm_encoder_crtc_pipe);
149
150 return 0;
263} 151}
264 152
265static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, 153static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
266 struct drm_framebuffer *old_fb) 154 struct drm_framebuffer *old_fb)
267{ 155{
156 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
157 struct drm_plane *plane = exynos_crtc->plane;
158 unsigned int crtc_w;
159 unsigned int crtc_h;
268 int ret; 160 int ret;
269 161
270 DRM_DEBUG_KMS("%s\n", __FILE__); 162 DRM_DEBUG_KMS("%s\n", __FILE__);
271 163
272 ret = exynos_drm_crtc_update(crtc); 164 crtc_w = crtc->fb->width - x;
165 crtc_h = crtc->fb->height - y;
166
167 ret = exynos_plane_mode_set(plane, crtc, crtc->fb, 0, 0, crtc_w, crtc_h,
168 x, y, crtc_w, crtc_h);
273 if (ret) 169 if (ret)
274 return ret; 170 return ret;
275 171
276 exynos_drm_crtc_apply(crtc); 172 exynos_drm_crtc_commit(crtc);
277 173
278 return ret; 174 return 0;
279} 175}
280 176
281static void exynos_drm_crtc_load_lut(struct drm_crtc *crtc) 177static void exynos_drm_crtc_load_lut(struct drm_crtc *crtc)
@@ -284,6 +180,16 @@ static void exynos_drm_crtc_load_lut(struct drm_crtc *crtc)
284 /* drm framework doesn't check NULL */ 180 /* drm framework doesn't check NULL */
285} 181}
286 182
183static void exynos_drm_crtc_disable(struct drm_crtc *crtc)
184{
185 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
186
187 DRM_DEBUG_KMS("%s\n", __FILE__);
188
189 exynos_plane_dpms(exynos_crtc->plane, DRM_MODE_DPMS_OFF);
190 exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
191}
192
287static struct drm_crtc_helper_funcs exynos_crtc_helper_funcs = { 193static struct drm_crtc_helper_funcs exynos_crtc_helper_funcs = {
288 .dpms = exynos_drm_crtc_dpms, 194 .dpms = exynos_drm_crtc_dpms,
289 .prepare = exynos_drm_crtc_prepare, 195 .prepare = exynos_drm_crtc_prepare,
@@ -292,6 +198,7 @@ static struct drm_crtc_helper_funcs exynos_crtc_helper_funcs = {
292 .mode_set = exynos_drm_crtc_mode_set, 198 .mode_set = exynos_drm_crtc_mode_set,
293 .mode_set_base = exynos_drm_crtc_mode_set_base, 199 .mode_set_base = exynos_drm_crtc_mode_set_base,
294 .load_lut = exynos_drm_crtc_load_lut, 200 .load_lut = exynos_drm_crtc_load_lut,
201 .disable = exynos_drm_crtc_disable,
295}; 202};
296 203
297static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc, 204static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc,
@@ -327,7 +234,8 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc,
327 &dev_priv->pageflip_event_list); 234 &dev_priv->pageflip_event_list);
328 235
329 crtc->fb = fb; 236 crtc->fb = fb;
330 ret = exynos_drm_crtc_update(crtc); 237 ret = exynos_drm_crtc_mode_set_base(crtc, crtc->x, crtc->y,
238 NULL);
331 if (ret) { 239 if (ret) {
332 crtc->fb = old_fb; 240 crtc->fb = old_fb;
333 drm_vblank_put(dev, exynos_crtc->pipe); 241 drm_vblank_put(dev, exynos_crtc->pipe);
@@ -335,14 +243,6 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc,
335 243
336 goto out; 244 goto out;
337 } 245 }
338
339 /*
340 * the values related to a buffer of the drm framebuffer
341 * to be applied should be set at here. because these values
342 * first, are set to shadow registers and then to
343 * real registers at vsync front porch period.
344 */
345 exynos_drm_crtc_apply(crtc);
346 } 246 }
347out: 247out:
348 mutex_unlock(&dev->struct_mutex); 248 mutex_unlock(&dev->struct_mutex);
@@ -362,18 +262,73 @@ static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
362 kfree(exynos_crtc); 262 kfree(exynos_crtc);
363} 263}
364 264
265static int exynos_drm_crtc_set_property(struct drm_crtc *crtc,
266 struct drm_property *property,
267 uint64_t val)
268{
269 struct drm_device *dev = crtc->dev;
270 struct exynos_drm_private *dev_priv = dev->dev_private;
271 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
272
273 DRM_DEBUG_KMS("%s\n", __func__);
274
275 if (property == dev_priv->crtc_mode_property) {
276 enum exynos_crtc_mode mode = val;
277
278 if (mode == exynos_crtc->mode)
279 return 0;
280
281 exynos_crtc->mode = mode;
282
283 switch (mode) {
284 case CRTC_MODE_NORMAL:
285 exynos_drm_crtc_commit(crtc);
286 break;
287 case CRTC_MODE_BLANK:
288 exynos_plane_dpms(exynos_crtc->plane,
289 DRM_MODE_DPMS_OFF);
290 break;
291 default:
292 break;
293 }
294
295 return 0;
296 }
297
298 return -EINVAL;
299}
300
365static struct drm_crtc_funcs exynos_crtc_funcs = { 301static struct drm_crtc_funcs exynos_crtc_funcs = {
366 .set_config = drm_crtc_helper_set_config, 302 .set_config = drm_crtc_helper_set_config,
367 .page_flip = exynos_drm_crtc_page_flip, 303 .page_flip = exynos_drm_crtc_page_flip,
368 .destroy = exynos_drm_crtc_destroy, 304 .destroy = exynos_drm_crtc_destroy,
305 .set_property = exynos_drm_crtc_set_property,
306};
307
308static const struct drm_prop_enum_list mode_names[] = {
309 { CRTC_MODE_NORMAL, "normal" },
310 { CRTC_MODE_BLANK, "blank" },
369}; 311};
370 312
371struct exynos_drm_overlay *get_exynos_drm_overlay(struct drm_device *dev, 313static void exynos_drm_crtc_attach_mode_property(struct drm_crtc *crtc)
372 struct drm_crtc *crtc)
373{ 314{
374 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); 315 struct drm_device *dev = crtc->dev;
316 struct exynos_drm_private *dev_priv = dev->dev_private;
317 struct drm_property *prop;
375 318
376 return &exynos_crtc->overlay; 319 DRM_DEBUG_KMS("%s\n", __func__);
320
321 prop = dev_priv->crtc_mode_property;
322 if (!prop) {
323 prop = drm_property_create_enum(dev, 0, "mode", mode_names,
324 ARRAY_SIZE(mode_names));
325 if (!prop)
326 return;
327
328 dev_priv->crtc_mode_property = prop;
329 }
330
331 drm_object_attach_property(&crtc->base, prop, 0);
377} 332}
378 333
379int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr) 334int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr)
@@ -392,7 +347,12 @@ int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr)
392 347
393 exynos_crtc->pipe = nr; 348 exynos_crtc->pipe = nr;
394 exynos_crtc->dpms = DRM_MODE_DPMS_OFF; 349 exynos_crtc->dpms = DRM_MODE_DPMS_OFF;
395 exynos_crtc->overlay.zpos = DEFAULT_ZPOS; 350 exynos_crtc->plane = exynos_plane_init(dev, 1 << nr, true);
351 if (!exynos_crtc->plane) {
352 kfree(exynos_crtc);
353 return -ENOMEM;
354 }
355
396 crtc = &exynos_crtc->drm_crtc; 356 crtc = &exynos_crtc->drm_crtc;
397 357
398 private->crtc[nr] = crtc; 358 private->crtc[nr] = crtc;
@@ -400,6 +360,8 @@ int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr)
400 drm_crtc_init(dev, crtc, &exynos_crtc_funcs); 360 drm_crtc_init(dev, crtc, &exynos_crtc_funcs);
401 drm_crtc_helper_add(crtc, &exynos_crtc_helper_funcs); 361 drm_crtc_helper_add(crtc, &exynos_crtc_helper_funcs);
402 362
363 exynos_drm_crtc_attach_mode_property(crtc);
364
403 return 0; 365 return 0;
404} 366}
405 367
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
index 16b8e2195a0d..6bae8d8c250e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
@@ -29,39 +29,8 @@
29#ifndef _EXYNOS_DRM_CRTC_H_ 29#ifndef _EXYNOS_DRM_CRTC_H_
30#define _EXYNOS_DRM_CRTC_H_ 30#define _EXYNOS_DRM_CRTC_H_
31 31
32struct exynos_drm_overlay *get_exynos_drm_overlay(struct drm_device *dev,
33 struct drm_crtc *crtc);
34int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr); 32int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr);
35int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int crtc); 33int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int crtc);
36void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int crtc); 34void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int crtc);
37 35
38/*
39 * Exynos specific crtc postion structure.
40 *
41 * @fb_x: offset x on a framebuffer to be displyed
42 * - the unit is screen coordinates.
43 * @fb_y: offset y on a framebuffer to be displayed
44 * - the unit is screen coordinates.
45 * @src_w: width of source area to be displayed from a framebuffer.
46 * @src_h: height of source area to be displayed from a framebuffer.
47 * @crtc_x: offset x on hardware screen.
48 * @crtc_y: offset y on hardware screen.
49 * @crtc_w: width of hardware screen.
50 * @crtc_h: height of hardware screen.
51 */
52struct exynos_drm_crtc_pos {
53 unsigned int fb_x;
54 unsigned int fb_y;
55 unsigned int src_w;
56 unsigned int src_h;
57 unsigned int crtc_x;
58 unsigned int crtc_y;
59 unsigned int crtc_w;
60 unsigned int crtc_h;
61};
62
63int exynos_drm_overlay_update(struct exynos_drm_overlay *overlay,
64 struct drm_framebuffer *fb,
65 struct drm_display_mode *mode,
66 struct exynos_drm_crtc_pos *pos);
67#endif 36#endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
index 274909271c36..613bf8a5d9b2 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
@@ -25,6 +25,7 @@
25 25
26#include "drmP.h" 26#include "drmP.h"
27#include "drm.h" 27#include "drm.h"
28#include "exynos_drm.h"
28#include "exynos_drm_drv.h" 29#include "exynos_drm_drv.h"
29#include "exynos_drm_gem.h" 30#include "exynos_drm_gem.h"
30 31
@@ -86,6 +87,10 @@ static struct sg_table *
86 npages = buf->size / buf->page_size; 87 npages = buf->size / buf->page_size;
87 88
88 sgt = exynos_pages_to_sg(buf->pages, npages, buf->page_size); 89 sgt = exynos_pages_to_sg(buf->pages, npages, buf->page_size);
90 if (!sgt) {
91 DRM_DEBUG_PRIME("exynos_pages_to_sg returned NULL!\n");
92 goto err_unlock;
93 }
89 nents = dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir); 94 nents = dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir);
90 95
91 DRM_DEBUG_PRIME("npages = %d buffer size = 0x%lx page_size = 0x%lx\n", 96 DRM_DEBUG_PRIME("npages = %d buffer size = 0x%lx page_size = 0x%lx\n",
@@ -186,7 +191,7 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev,
186 struct exynos_drm_gem_obj *exynos_gem_obj; 191 struct exynos_drm_gem_obj *exynos_gem_obj;
187 struct exynos_drm_gem_buf *buffer; 192 struct exynos_drm_gem_buf *buffer;
188 struct page *page; 193 struct page *page;
189 int ret, i = 0; 194 int ret;
190 195
191 DRM_DEBUG_PRIME("%s\n", __FILE__); 196 DRM_DEBUG_PRIME("%s\n", __FILE__);
192 197
@@ -210,7 +215,7 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev,
210 215
211 216
212 sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL); 217 sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
213 if (IS_ERR(sgt)) { 218 if (IS_ERR_OR_NULL(sgt)) {
214 ret = PTR_ERR(sgt); 219 ret = PTR_ERR(sgt);
215 goto err_buf_detach; 220 goto err_buf_detach;
216 } 221 }
@@ -236,13 +241,25 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev,
236 } 241 }
237 242
238 sgl = sgt->sgl; 243 sgl = sgt->sgl;
239 buffer->dma_addr = sg_dma_address(sgl);
240 244
241 while (i < sgt->nents) { 245 if (sgt->nents == 1) {
242 buffer->pages[i] = sg_page(sgl); 246 buffer->dma_addr = sg_dma_address(sgt->sgl);
243 buffer->size += sg_dma_len(sgl); 247 buffer->size = sg_dma_len(sgt->sgl);
244 sgl = sg_next(sgl); 248
245 i++; 249 /* always physically continuous memory if sgt->nents is 1. */
250 exynos_gem_obj->flags |= EXYNOS_BO_CONTIG;
251 } else {
252 unsigned int i = 0;
253
254 buffer->dma_addr = sg_dma_address(sgl);
255 while (i < sgt->nents) {
256 buffer->pages[i] = sg_page(sgl);
257 buffer->size += sg_dma_len(sgl);
258 sgl = sg_next(sgl);
259 i++;
260 }
261
262 exynos_gem_obj->flags |= EXYNOS_BO_NONCONTIG;
246 } 263 }
247 264
248 exynos_gem_obj->buffer = buffer; 265 exynos_gem_obj->buffer = buffer;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index d6de2e07fa03..ebacec6f1e48 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -85,8 +85,11 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
85 } 85 }
86 86
87 for (nr = 0; nr < MAX_PLANE; nr++) { 87 for (nr = 0; nr < MAX_PLANE; nr++) {
88 ret = exynos_plane_init(dev, nr); 88 struct drm_plane *plane;
89 if (ret) 89 unsigned int possible_crtcs = (1 << MAX_CRTC) - 1;
90
91 plane = exynos_plane_init(dev, possible_crtcs, false);
92 if (!plane)
90 goto err_crtc; 93 goto err_crtc;
91 } 94 }
92 95
@@ -221,8 +224,6 @@ static struct drm_ioctl_desc exynos_ioctls[] = {
221 exynos_drm_gem_mmap_ioctl, DRM_UNLOCKED | DRM_AUTH), 224 exynos_drm_gem_mmap_ioctl, DRM_UNLOCKED | DRM_AUTH),
222 DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET, 225 DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET,
223 exynos_drm_gem_get_ioctl, DRM_UNLOCKED), 226 exynos_drm_gem_get_ioctl, DRM_UNLOCKED),
224 DRM_IOCTL_DEF_DRV(EXYNOS_PLANE_SET_ZPOS, exynos_plane_set_zpos_ioctl,
225 DRM_UNLOCKED | DRM_AUTH),
226 DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, 227 DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION,
227 vidi_connection_ioctl, DRM_UNLOCKED | DRM_AUTH), 228 vidi_connection_ioctl, DRM_UNLOCKED | DRM_AUTH),
228 DRM_IOCTL_DEF_DRV(EXYNOS_G2D_GET_VER, 229 DRM_IOCTL_DEF_DRV(EXYNOS_G2D_GET_VER,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 277653d5fda0..e22704b249d7 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -59,12 +59,14 @@ enum exynos_drm_output_type {
59 * 59 *
60 * @mode_set: copy drm overlay info to hw specific overlay info. 60 * @mode_set: copy drm overlay info to hw specific overlay info.
61 * @commit: apply hardware specific overlay data to registers. 61 * @commit: apply hardware specific overlay data to registers.
62 * @enable: enable hardware specific overlay.
62 * @disable: disable hardware specific overlay. 63 * @disable: disable hardware specific overlay.
63 */ 64 */
64struct exynos_drm_overlay_ops { 65struct exynos_drm_overlay_ops {
65 void (*mode_set)(struct device *subdrv_dev, 66 void (*mode_set)(struct device *subdrv_dev,
66 struct exynos_drm_overlay *overlay); 67 struct exynos_drm_overlay *overlay);
67 void (*commit)(struct device *subdrv_dev, int zpos); 68 void (*commit)(struct device *subdrv_dev, int zpos);
69 void (*enable)(struct device *subdrv_dev, int zpos);
68 void (*disable)(struct device *subdrv_dev, int zpos); 70 void (*disable)(struct device *subdrv_dev, int zpos);
69}; 71};
70 72
@@ -235,6 +237,8 @@ struct exynos_drm_private {
235 * this array is used to be aware of which crtc did it request vblank. 237 * this array is used to be aware of which crtc did it request vblank.
236 */ 238 */
237 struct drm_crtc *crtc[MAX_CRTC]; 239 struct drm_crtc *crtc[MAX_CRTC];
240 struct drm_property *plane_zpos_property;
241 struct drm_property *crtc_mode_property;
238}; 242};
239 243
240/* 244/*
diff --git a/drivers/gpu/drm/exynos/exynos_drm_encoder.c b/drivers/gpu/drm/exynos/exynos_drm_encoder.c
index 4a13a747f5d4..2c037cd7d2d4 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_encoder.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_encoder.c
@@ -30,7 +30,6 @@
30#include "drm_crtc_helper.h" 30#include "drm_crtc_helper.h"
31 31
32#include "exynos_drm_drv.h" 32#include "exynos_drm_drv.h"
33#include "exynos_drm_crtc.h"
34#include "exynos_drm_encoder.h" 33#include "exynos_drm_encoder.h"
35 34
36#define to_exynos_encoder(x) container_of(x, struct exynos_drm_encoder,\ 35#define to_exynos_encoder(x) container_of(x, struct exynos_drm_encoder,\
@@ -136,21 +135,16 @@ static void exynos_drm_encoder_mode_set(struct drm_encoder *encoder,
136 struct drm_connector *connector; 135 struct drm_connector *connector;
137 struct exynos_drm_manager *manager = exynos_drm_get_manager(encoder); 136 struct exynos_drm_manager *manager = exynos_drm_get_manager(encoder);
138 struct exynos_drm_manager_ops *manager_ops = manager->ops; 137 struct exynos_drm_manager_ops *manager_ops = manager->ops;
139 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops;
140 struct exynos_drm_overlay *overlay = get_exynos_drm_overlay(dev,
141 encoder->crtc);
142 138
143 DRM_DEBUG_KMS("%s\n", __FILE__); 139 DRM_DEBUG_KMS("%s\n", __FILE__);
144 140
141 exynos_drm_encoder_dpms(encoder, DRM_MODE_DPMS_ON);
142
145 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 143 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
146 if (connector->encoder == encoder) { 144 if (connector->encoder == encoder)
147 if (manager_ops && manager_ops->mode_set) 145 if (manager_ops && manager_ops->mode_set)
148 manager_ops->mode_set(manager->dev, 146 manager_ops->mode_set(manager->dev,
149 adjusted_mode); 147 adjusted_mode);
150
151 if (overlay_ops && overlay_ops->mode_set)
152 overlay_ops->mode_set(manager->dev, overlay);
153 }
154 } 148 }
155} 149}
156 150
@@ -310,8 +304,8 @@ void exynos_drm_enable_vblank(struct drm_encoder *encoder, void *data)
310 struct exynos_drm_manager_ops *manager_ops = manager->ops; 304 struct exynos_drm_manager_ops *manager_ops = manager->ops;
311 int crtc = *(int *)data; 305 int crtc = *(int *)data;
312 306
313 if (manager->pipe == -1) 307 if (manager->pipe != crtc)
314 manager->pipe = crtc; 308 return;
315 309
316 if (manager_ops->enable_vblank) 310 if (manager_ops->enable_vblank)
317 manager_ops->enable_vblank(manager->dev); 311 manager_ops->enable_vblank(manager->dev);
@@ -324,34 +318,41 @@ void exynos_drm_disable_vblank(struct drm_encoder *encoder, void *data)
324 struct exynos_drm_manager_ops *manager_ops = manager->ops; 318 struct exynos_drm_manager_ops *manager_ops = manager->ops;
325 int crtc = *(int *)data; 319 int crtc = *(int *)data;
326 320
327 if (manager->pipe == -1) 321 if (manager->pipe != crtc)
328 manager->pipe = crtc; 322 return;
329 323
330 if (manager_ops->disable_vblank) 324 if (manager_ops->disable_vblank)
331 manager_ops->disable_vblank(manager->dev); 325 manager_ops->disable_vblank(manager->dev);
332} 326}
333 327
334void exynos_drm_encoder_crtc_plane_commit(struct drm_encoder *encoder, 328void exynos_drm_encoder_crtc_dpms(struct drm_encoder *encoder, void *data)
335 void *data)
336{ 329{
337 struct exynos_drm_manager *manager = 330 struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder);
338 to_exynos_encoder(encoder)->manager; 331 struct exynos_drm_manager *manager = exynos_encoder->manager;
339 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops; 332 struct exynos_drm_manager_ops *manager_ops = manager->ops;
340 int zpos = DEFAULT_ZPOS; 333 int mode = *(int *)data;
341 334
342 if (data) 335 DRM_DEBUG_KMS("%s\n", __FILE__);
343 zpos = *(int *)data;
344 336
345 if (overlay_ops && overlay_ops->commit) 337 if (manager_ops && manager_ops->dpms)
346 overlay_ops->commit(manager->dev, zpos); 338 manager_ops->dpms(manager->dev, mode);
339
340 /*
341 * if this condition is ok then it means that the crtc is already
342 * detached from encoder and last function for detaching is properly
343 * done, so clear pipe from manager to prevent repeated call.
344 */
345 if (mode > DRM_MODE_DPMS_ON) {
346 if (!encoder->crtc)
347 manager->pipe = -1;
348 }
347} 349}
348 350
349void exynos_drm_encoder_crtc_commit(struct drm_encoder *encoder, void *data) 351void exynos_drm_encoder_crtc_pipe(struct drm_encoder *encoder, void *data)
350{ 352{
351 struct exynos_drm_manager *manager = 353 struct exynos_drm_manager *manager =
352 to_exynos_encoder(encoder)->manager; 354 to_exynos_encoder(encoder)->manager;
353 int crtc = *(int *)data; 355 int pipe = *(int *)data;
354 int zpos = DEFAULT_ZPOS;
355 356
356 DRM_DEBUG_KMS("%s\n", __FILE__); 357 DRM_DEBUG_KMS("%s\n", __FILE__);
357 358
@@ -359,76 +360,62 @@ void exynos_drm_encoder_crtc_commit(struct drm_encoder *encoder, void *data)
359 * when crtc is detached from encoder, this pipe is used 360 * when crtc is detached from encoder, this pipe is used
360 * to select manager operation 361 * to select manager operation
361 */ 362 */
362 manager->pipe = crtc; 363 manager->pipe = pipe;
363
364 exynos_drm_encoder_crtc_plane_commit(encoder, &zpos);
365} 364}
366 365
367void exynos_drm_encoder_dpms_from_crtc(struct drm_encoder *encoder, void *data) 366void exynos_drm_encoder_plane_mode_set(struct drm_encoder *encoder, void *data)
368{ 367{
369 struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder); 368 struct exynos_drm_manager *manager =
370 int mode = *(int *)data; 369 to_exynos_encoder(encoder)->manager;
370 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops;
371 struct exynos_drm_overlay *overlay = data;
371 372
372 DRM_DEBUG_KMS("%s\n", __FILE__); 373 DRM_DEBUG_KMS("%s\n", __FILE__);
373 374
374 exynos_drm_encoder_dpms(encoder, mode); 375 if (overlay_ops && overlay_ops->mode_set)
375 376 overlay_ops->mode_set(manager->dev, overlay);
376 exynos_encoder->dpms = mode;
377} 377}
378 378
379void exynos_drm_encoder_crtc_dpms(struct drm_encoder *encoder, void *data) 379void exynos_drm_encoder_plane_commit(struct drm_encoder *encoder, void *data)
380{ 380{
381 struct drm_device *dev = encoder->dev; 381 struct exynos_drm_manager *manager =
382 struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder); 382 to_exynos_encoder(encoder)->manager;
383 struct exynos_drm_manager *manager = exynos_encoder->manager; 383 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops;
384 struct exynos_drm_manager_ops *manager_ops = manager->ops; 384 int zpos = DEFAULT_ZPOS;
385 struct drm_connector *connector;
386 int mode = *(int *)data;
387 385
388 DRM_DEBUG_KMS("%s\n", __FILE__); 386 DRM_DEBUG_KMS("%s\n", __FILE__);
389 387
390 if (manager_ops && manager_ops->dpms) 388 if (data)
391 manager_ops->dpms(manager->dev, mode); 389 zpos = *(int *)data;
392
393 /*
394 * set current dpms mode to the connector connected to
395 * current encoder. connector->dpms would be checked
396 * at drm_helper_connector_dpms()
397 */
398 list_for_each_entry(connector, &dev->mode_config.connector_list, head)
399 if (connector->encoder == encoder)
400 connector->dpms = mode;
401 390
402 /* 391 if (overlay_ops && overlay_ops->commit)
403 * if this condition is ok then it means that the crtc is already 392 overlay_ops->commit(manager->dev, zpos);
404 * detached from encoder and last function for detaching is properly
405 * done, so clear pipe from manager to prevent repeated call.
406 */
407 if (mode > DRM_MODE_DPMS_ON) {
408 if (!encoder->crtc)
409 manager->pipe = -1;
410 }
411} 393}
412 394
413void exynos_drm_encoder_crtc_mode_set(struct drm_encoder *encoder, void *data) 395void exynos_drm_encoder_plane_enable(struct drm_encoder *encoder, void *data)
414{ 396{
415 struct exynos_drm_manager *manager = 397 struct exynos_drm_manager *manager =
416 to_exynos_encoder(encoder)->manager; 398 to_exynos_encoder(encoder)->manager;
417 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops; 399 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops;
418 struct exynos_drm_overlay *overlay = data; 400 int zpos = DEFAULT_ZPOS;
419 401
420 if (overlay_ops && overlay_ops->mode_set) 402 DRM_DEBUG_KMS("%s\n", __FILE__);
421 overlay_ops->mode_set(manager->dev, overlay); 403
404 if (data)
405 zpos = *(int *)data;
406
407 if (overlay_ops && overlay_ops->enable)
408 overlay_ops->enable(manager->dev, zpos);
422} 409}
423 410
424void exynos_drm_encoder_crtc_disable(struct drm_encoder *encoder, void *data) 411void exynos_drm_encoder_plane_disable(struct drm_encoder *encoder, void *data)
425{ 412{
426 struct exynos_drm_manager *manager = 413 struct exynos_drm_manager *manager =
427 to_exynos_encoder(encoder)->manager; 414 to_exynos_encoder(encoder)->manager;
428 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops; 415 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops;
429 int zpos = DEFAULT_ZPOS; 416 int zpos = DEFAULT_ZPOS;
430 417
431 DRM_DEBUG_KMS("\n"); 418 DRM_DEBUG_KMS("%s\n", __FILE__);
432 419
433 if (data) 420 if (data)
434 zpos = *(int *)data; 421 zpos = *(int *)data;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_encoder.h b/drivers/gpu/drm/exynos/exynos_drm_encoder.h
index eb7d2316847e..6470d9ddf5a1 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_encoder.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_encoder.h
@@ -40,13 +40,11 @@ void exynos_drm_fn_encoder(struct drm_crtc *crtc, void *data,
40 void (*fn)(struct drm_encoder *, void *)); 40 void (*fn)(struct drm_encoder *, void *));
41void exynos_drm_enable_vblank(struct drm_encoder *encoder, void *data); 41void exynos_drm_enable_vblank(struct drm_encoder *encoder, void *data);
42void exynos_drm_disable_vblank(struct drm_encoder *encoder, void *data); 42void exynos_drm_disable_vblank(struct drm_encoder *encoder, void *data);
43void exynos_drm_encoder_crtc_plane_commit(struct drm_encoder *encoder,
44 void *data);
45void exynos_drm_encoder_crtc_commit(struct drm_encoder *encoder, void *data);
46void exynos_drm_encoder_dpms_from_crtc(struct drm_encoder *encoder,
47 void *data);
48void exynos_drm_encoder_crtc_dpms(struct drm_encoder *encoder, void *data); 43void exynos_drm_encoder_crtc_dpms(struct drm_encoder *encoder, void *data);
49void exynos_drm_encoder_crtc_mode_set(struct drm_encoder *encoder, void *data); 44void exynos_drm_encoder_crtc_pipe(struct drm_encoder *encoder, void *data);
50void exynos_drm_encoder_crtc_disable(struct drm_encoder *encoder, void *data); 45void exynos_drm_encoder_plane_mode_set(struct drm_encoder *encoder, void *data);
46void exynos_drm_encoder_plane_commit(struct drm_encoder *encoder, void *data);
47void exynos_drm_encoder_plane_enable(struct drm_encoder *encoder, void *data);
48void exynos_drm_encoder_plane_disable(struct drm_encoder *encoder, void *data);
51 49
52#endif 50#endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 29fdbfeb43cb..a68d2b313f03 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -78,7 +78,6 @@ struct fimd_context {
78 struct drm_crtc *crtc; 78 struct drm_crtc *crtc;
79 struct clk *bus_clk; 79 struct clk *bus_clk;
80 struct clk *lcd_clk; 80 struct clk *lcd_clk;
81 struct resource *regs_res;
82 void __iomem *regs; 81 void __iomem *regs;
83 struct fimd_win_data win_data[WINDOWS_NR]; 82 struct fimd_win_data win_data[WINDOWS_NR];
84 unsigned int clkdiv; 83 unsigned int clkdiv;
@@ -813,7 +812,7 @@ static int __devinit fimd_probe(struct platform_device *pdev)
813 return -EINVAL; 812 return -EINVAL;
814 } 813 }
815 814
816 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 815 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
817 if (!ctx) 816 if (!ctx)
818 return -ENOMEM; 817 return -ENOMEM;
819 818
@@ -838,33 +837,26 @@ static int __devinit fimd_probe(struct platform_device *pdev)
838 goto err_clk; 837 goto err_clk;
839 } 838 }
840 839
841 ctx->regs_res = request_mem_region(res->start, resource_size(res), 840 ctx->regs = devm_request_and_ioremap(&pdev->dev, res);
842 dev_name(dev));
843 if (!ctx->regs_res) {
844 dev_err(dev, "failed to claim register region\n");
845 ret = -ENOENT;
846 goto err_clk;
847 }
848
849 ctx->regs = ioremap(res->start, resource_size(res));
850 if (!ctx->regs) { 841 if (!ctx->regs) {
851 dev_err(dev, "failed to map registers\n"); 842 dev_err(dev, "failed to map registers\n");
852 ret = -ENXIO; 843 ret = -ENXIO;
853 goto err_req_region_io; 844 goto err_clk;
854 } 845 }
855 846
856 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 847 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
857 if (!res) { 848 if (!res) {
858 dev_err(dev, "irq request failed.\n"); 849 dev_err(dev, "irq request failed.\n");
859 goto err_req_region_irq; 850 goto err_clk;
860 } 851 }
861 852
862 ctx->irq = res->start; 853 ctx->irq = res->start;
863 854
864 ret = request_irq(ctx->irq, fimd_irq_handler, 0, "drm_fimd", ctx); 855 ret = devm_request_irq(&pdev->dev, ctx->irq, fimd_irq_handler,
865 if (ret < 0) { 856 0, "drm_fimd", ctx);
857 if (ret) {
866 dev_err(dev, "irq request failed.\n"); 858 dev_err(dev, "irq request failed.\n");
867 goto err_req_irq; 859 goto err_clk;
868 } 860 }
869 861
870 ctx->vidcon0 = pdata->vidcon0; 862 ctx->vidcon0 = pdata->vidcon0;
@@ -899,14 +891,6 @@ static int __devinit fimd_probe(struct platform_device *pdev)
899 891
900 return 0; 892 return 0;
901 893
902err_req_irq:
903err_req_region_irq:
904 iounmap(ctx->regs);
905
906err_req_region_io:
907 release_resource(ctx->regs_res);
908 kfree(ctx->regs_res);
909
910err_clk: 894err_clk:
911 clk_disable(ctx->lcd_clk); 895 clk_disable(ctx->lcd_clk);
912 clk_put(ctx->lcd_clk); 896 clk_put(ctx->lcd_clk);
@@ -916,7 +900,6 @@ err_bus_clk:
916 clk_put(ctx->bus_clk); 900 clk_put(ctx->bus_clk);
917 901
918err_clk_get: 902err_clk_get:
919 kfree(ctx);
920 return ret; 903 return ret;
921} 904}
922 905
@@ -944,13 +927,6 @@ out:
944 clk_put(ctx->lcd_clk); 927 clk_put(ctx->lcd_clk);
945 clk_put(ctx->bus_clk); 928 clk_put(ctx->bus_clk);
946 929
947 iounmap(ctx->regs);
948 release_resource(ctx->regs_res);
949 kfree(ctx->regs_res);
950 free_irq(ctx->irq, ctx);
951
952 kfree(ctx);
953
954 return 0; 930 return 0;
955} 931}
956 932
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index 5c8b683029ea..f9efde40c097 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -99,25 +99,17 @@ out:
99struct page **exynos_gem_get_pages(struct drm_gem_object *obj, 99struct page **exynos_gem_get_pages(struct drm_gem_object *obj,
100 gfp_t gfpmask) 100 gfp_t gfpmask)
101{ 101{
102 struct inode *inode;
103 struct address_space *mapping;
104 struct page *p, **pages; 102 struct page *p, **pages;
105 int i, npages; 103 int i, npages;
106 104
107 /* This is the shared memory object that backs the GEM resource */
108 inode = obj->filp->f_path.dentry->d_inode;
109 mapping = inode->i_mapping;
110
111 npages = obj->size >> PAGE_SHIFT; 105 npages = obj->size >> PAGE_SHIFT;
112 106
113 pages = drm_malloc_ab(npages, sizeof(struct page *)); 107 pages = drm_malloc_ab(npages, sizeof(struct page *));
114 if (pages == NULL) 108 if (pages == NULL)
115 return ERR_PTR(-ENOMEM); 109 return ERR_PTR(-ENOMEM);
116 110
117 gfpmask |= mapping_gfp_mask(mapping);
118
119 for (i = 0; i < npages; i++) { 111 for (i = 0; i < npages; i++) {
120 p = shmem_read_mapping_page_gfp(mapping, i, gfpmask); 112 p = alloc_page(gfpmask);
121 if (IS_ERR(p)) 113 if (IS_ERR(p))
122 goto fail; 114 goto fail;
123 pages[i] = p; 115 pages[i] = p;
@@ -126,31 +118,22 @@ struct page **exynos_gem_get_pages(struct drm_gem_object *obj,
126 return pages; 118 return pages;
127 119
128fail: 120fail:
129 while (i--) 121 while (--i)
130 page_cache_release(pages[i]); 122 __free_page(pages[i]);
131 123
132 drm_free_large(pages); 124 drm_free_large(pages);
133 return ERR_PTR(PTR_ERR(p)); 125 return ERR_PTR(PTR_ERR(p));
134} 126}
135 127
136static void exynos_gem_put_pages(struct drm_gem_object *obj, 128static void exynos_gem_put_pages(struct drm_gem_object *obj,
137 struct page **pages, 129 struct page **pages)
138 bool dirty, bool accessed)
139{ 130{
140 int i, npages; 131 int npages;
141 132
142 npages = obj->size >> PAGE_SHIFT; 133 npages = obj->size >> PAGE_SHIFT;
143 134
144 for (i = 0; i < npages; i++) { 135 while (--npages >= 0)
145 if (dirty) 136 __free_page(pages[npages]);
146 set_page_dirty(pages[i]);
147
148 if (accessed)
149 mark_page_accessed(pages[i]);
150
151 /* Undo the reference we took when populating the table */
152 page_cache_release(pages[i]);
153 }
154 137
155 drm_free_large(pages); 138 drm_free_large(pages);
156} 139}
@@ -189,7 +172,7 @@ static int exynos_drm_gem_get_pages(struct drm_gem_object *obj)
189 return -EINVAL; 172 return -EINVAL;
190 } 173 }
191 174
192 pages = exynos_gem_get_pages(obj, GFP_KERNEL); 175 pages = exynos_gem_get_pages(obj, GFP_HIGHUSER_MOVABLE);
193 if (IS_ERR(pages)) { 176 if (IS_ERR(pages)) {
194 DRM_ERROR("failed to get pages.\n"); 177 DRM_ERROR("failed to get pages.\n");
195 return PTR_ERR(pages); 178 return PTR_ERR(pages);
@@ -230,7 +213,7 @@ err1:
230 kfree(buf->sgt); 213 kfree(buf->sgt);
231 buf->sgt = NULL; 214 buf->sgt = NULL;
232err: 215err:
233 exynos_gem_put_pages(obj, pages, true, false); 216 exynos_gem_put_pages(obj, pages);
234 return ret; 217 return ret;
235 218
236} 219}
@@ -248,7 +231,7 @@ static void exynos_drm_gem_put_pages(struct drm_gem_object *obj)
248 kfree(buf->sgt); 231 kfree(buf->sgt);
249 buf->sgt = NULL; 232 buf->sgt = NULL;
250 233
251 exynos_gem_put_pages(obj, buf->pages, true, false); 234 exynos_gem_put_pages(obj, buf->pages);
252 buf->pages = NULL; 235 buf->pages = NULL;
253 236
254 /* add some codes for UNCACHED type here. TODO */ 237 /* add some codes for UNCACHED type here. TODO */
@@ -291,11 +274,21 @@ void exynos_drm_gem_destroy(struct exynos_drm_gem_obj *exynos_gem_obj)
291 if (!buf->pages) 274 if (!buf->pages)
292 return; 275 return;
293 276
277 /*
278 * do not release memory region from exporter.
279 *
280 * the region will be released by exporter
281 * once dmabuf's refcount becomes 0.
282 */
283 if (obj->import_attach)
284 goto out;
285
294 if (exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG) 286 if (exynos_gem_obj->flags & EXYNOS_BO_NONCONTIG)
295 exynos_drm_gem_put_pages(obj); 287 exynos_drm_gem_put_pages(obj);
296 else 288 else
297 exynos_drm_free_buf(obj->dev, exynos_gem_obj->flags, buf); 289 exynos_drm_free_buf(obj->dev, exynos_gem_obj->flags, buf);
298 290
291out:
299 exynos_drm_fini_buf(obj->dev, buf); 292 exynos_drm_fini_buf(obj->dev, buf);
300 exynos_gem_obj->buffer = NULL; 293 exynos_gem_obj->buffer = NULL;
301 294
@@ -668,7 +661,7 @@ int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
668 * with DRM_IOCTL_MODE_CREATE_DUMB command. 661 * with DRM_IOCTL_MODE_CREATE_DUMB command.
669 */ 662 */
670 663
671 args->pitch = args->width * args->bpp >> 3; 664 args->pitch = args->width * ((args->bpp + 7) / 8);
672 args->size = PAGE_ALIGN(args->pitch * args->height); 665 args->size = PAGE_ALIGN(args->pitch * args->height);
673 666
674 exynos_gem_obj = exynos_drm_gem_create(dev, args->flags, args->size); 667 exynos_gem_obj = exynos_drm_gem_create(dev, args->flags, args->size);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h b/drivers/gpu/drm/exynos/exynos_drm_gem.h
index 14d038b6cb02..085b2a5d5f70 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h
@@ -63,7 +63,8 @@ struct exynos_drm_gem_buf {
63 * by user request or at framebuffer creation. 63 * by user request or at framebuffer creation.
64 * continuous memory region allocated by user request 64 * continuous memory region allocated by user request
65 * or at framebuffer creation. 65 * or at framebuffer creation.
66 * @size: total memory size to physically non-continuous memory region. 66 * @size: size requested from user, in bytes and this size is aligned
67 * in page unit.
67 * @flags: indicate memory type to allocated buffer and cache attruibute. 68 * @flags: indicate memory type to allocated buffer and cache attruibute.
68 * 69 *
69 * P.S. this object would be transfered to user as kms_bo.handle so 70 * P.S. this object would be transfered to user as kms_bo.handle so
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index c4c6525d4653..b89829e5043a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -12,9 +12,12 @@
12#include "drmP.h" 12#include "drmP.h"
13 13
14#include "exynos_drm.h" 14#include "exynos_drm.h"
15#include "exynos_drm_crtc.h"
16#include "exynos_drm_drv.h" 15#include "exynos_drm_drv.h"
17#include "exynos_drm_encoder.h" 16#include "exynos_drm_encoder.h"
17#include "exynos_drm_fb.h"
18#include "exynos_drm_gem.h"
19
20#define to_exynos_plane(x) container_of(x, struct exynos_plane, base)
18 21
19struct exynos_plane { 22struct exynos_plane {
20 struct drm_plane base; 23 struct drm_plane base;
@@ -30,6 +33,108 @@ static const uint32_t formats[] = {
30 DRM_FORMAT_NV12MT, 33 DRM_FORMAT_NV12MT,
31}; 34};
32 35
36int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc,
37 struct drm_framebuffer *fb, int crtc_x, int crtc_y,
38 unsigned int crtc_w, unsigned int crtc_h,
39 uint32_t src_x, uint32_t src_y,
40 uint32_t src_w, uint32_t src_h)
41{
42 struct exynos_plane *exynos_plane = to_exynos_plane(plane);
43 struct exynos_drm_overlay *overlay = &exynos_plane->overlay;
44 unsigned int actual_w;
45 unsigned int actual_h;
46 int nr;
47 int i;
48
49 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
50
51 nr = exynos_drm_format_num_buffers(fb->pixel_format);
52 for (i = 0; i < nr; i++) {
53 struct exynos_drm_gem_buf *buffer = exynos_drm_fb_buffer(fb, i);
54
55 if (!buffer) {
56 DRM_LOG_KMS("buffer is null\n");
57 return -EFAULT;
58 }
59
60 overlay->dma_addr[i] = buffer->dma_addr;
61 overlay->vaddr[i] = buffer->kvaddr;
62
63 DRM_DEBUG_KMS("buffer: %d, vaddr = 0x%lx, dma_addr = 0x%lx\n",
64 i, (unsigned long)overlay->vaddr[i],
65 (unsigned long)overlay->dma_addr[i]);
66 }
67
68 actual_w = min((unsigned)(crtc->mode.hdisplay - crtc_x), crtc_w);
69 actual_h = min((unsigned)(crtc->mode.vdisplay - crtc_y), crtc_h);
70
71 /* set drm framebuffer data. */
72 overlay->fb_x = src_x;
73 overlay->fb_y = src_y;
74 overlay->fb_width = fb->width;
75 overlay->fb_height = fb->height;
76 overlay->src_width = src_w;
77 overlay->src_height = src_h;
78 overlay->bpp = fb->bits_per_pixel;
79 overlay->pitch = fb->pitches[0];
80 overlay->pixel_format = fb->pixel_format;
81
82 /* set overlay range to be displayed. */
83 overlay->crtc_x = crtc_x;
84 overlay->crtc_y = crtc_y;
85 overlay->crtc_width = actual_w;
86 overlay->crtc_height = actual_h;
87
88 /* set drm mode data. */
89 overlay->mode_width = crtc->mode.hdisplay;
90 overlay->mode_height = crtc->mode.vdisplay;
91 overlay->refresh = crtc->mode.vrefresh;
92 overlay->scan_flag = crtc->mode.flags;
93
94 DRM_DEBUG_KMS("overlay : offset_x/y(%d,%d), width/height(%d,%d)",
95 overlay->crtc_x, overlay->crtc_y,
96 overlay->crtc_width, overlay->crtc_height);
97
98 exynos_drm_fn_encoder(crtc, overlay, exynos_drm_encoder_plane_mode_set);
99
100 return 0;
101}
102
103void exynos_plane_commit(struct drm_plane *plane)
104{
105 struct exynos_plane *exynos_plane = to_exynos_plane(plane);
106 struct exynos_drm_overlay *overlay = &exynos_plane->overlay;
107
108 exynos_drm_fn_encoder(plane->crtc, &overlay->zpos,
109 exynos_drm_encoder_plane_commit);
110}
111
112void exynos_plane_dpms(struct drm_plane *plane, int mode)
113{
114 struct exynos_plane *exynos_plane = to_exynos_plane(plane);
115 struct exynos_drm_overlay *overlay = &exynos_plane->overlay;
116
117 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
118
119 if (mode == DRM_MODE_DPMS_ON) {
120 if (exynos_plane->enabled)
121 return;
122
123 exynos_drm_fn_encoder(plane->crtc, &overlay->zpos,
124 exynos_drm_encoder_plane_enable);
125
126 exynos_plane->enabled = true;
127 } else {
128 if (!exynos_plane->enabled)
129 return;
130
131 exynos_drm_fn_encoder(plane->crtc, &overlay->zpos,
132 exynos_drm_encoder_plane_disable);
133
134 exynos_plane->enabled = false;
135 }
136}
137
33static int 138static int
34exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, 139exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
35 struct drm_framebuffer *fb, int crtc_x, int crtc_y, 140 struct drm_framebuffer *fb, int crtc_x, int crtc_y,
@@ -37,64 +142,37 @@ exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
37 uint32_t src_x, uint32_t src_y, 142 uint32_t src_x, uint32_t src_y,
38 uint32_t src_w, uint32_t src_h) 143 uint32_t src_w, uint32_t src_h)
39{ 144{
40 struct exynos_plane *exynos_plane =
41 container_of(plane, struct exynos_plane, base);
42 struct exynos_drm_overlay *overlay = &exynos_plane->overlay;
43 struct exynos_drm_crtc_pos pos;
44 int ret; 145 int ret;
45 146
46 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 147 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
47 148
48 memset(&pos, 0, sizeof(struct exynos_drm_crtc_pos)); 149 ret = exynos_plane_mode_set(plane, crtc, fb, crtc_x, crtc_y,
49 pos.crtc_x = crtc_x; 150 crtc_w, crtc_h, src_x >> 16, src_y >> 16,
50 pos.crtc_y = crtc_y; 151 src_w >> 16, src_h >> 16);
51 pos.crtc_w = crtc_w;
52 pos.crtc_h = crtc_h;
53
54 /* considering 16.16 fixed point of source values */
55 pos.fb_x = src_x >> 16;
56 pos.fb_y = src_y >> 16;
57 pos.src_w = src_w >> 16;
58 pos.src_h = src_h >> 16;
59
60 ret = exynos_drm_overlay_update(overlay, fb, &crtc->mode, &pos);
61 if (ret < 0) 152 if (ret < 0)
62 return ret; 153 return ret;
63 154
64 exynos_drm_fn_encoder(crtc, overlay, 155 plane->crtc = crtc;
65 exynos_drm_encoder_crtc_mode_set); 156 plane->fb = crtc->fb;
66 exynos_drm_fn_encoder(crtc, &overlay->zpos,
67 exynos_drm_encoder_crtc_plane_commit);
68 157
69 exynos_plane->enabled = true; 158 exynos_plane_commit(plane);
159 exynos_plane_dpms(plane, DRM_MODE_DPMS_ON);
70 160
71 return 0; 161 return 0;
72} 162}
73 163
74static int exynos_disable_plane(struct drm_plane *plane) 164static int exynos_disable_plane(struct drm_plane *plane)
75{ 165{
76 struct exynos_plane *exynos_plane =
77 container_of(plane, struct exynos_plane, base);
78 struct exynos_drm_overlay *overlay = &exynos_plane->overlay;
79
80 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 166 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
81 167
82 if (!exynos_plane->enabled) 168 exynos_plane_dpms(plane, DRM_MODE_DPMS_OFF);
83 return 0;
84
85 exynos_drm_fn_encoder(plane->crtc, &overlay->zpos,
86 exynos_drm_encoder_crtc_disable);
87
88 exynos_plane->enabled = false;
89 exynos_plane->overlay.zpos = DEFAULT_ZPOS;
90 169
91 return 0; 170 return 0;
92} 171}
93 172
94static void exynos_plane_destroy(struct drm_plane *plane) 173static void exynos_plane_destroy(struct drm_plane *plane)
95{ 174{
96 struct exynos_plane *exynos_plane = 175 struct exynos_plane *exynos_plane = to_exynos_plane(plane);
97 container_of(plane, struct exynos_plane, base);
98 176
99 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 177 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
100 178
@@ -103,69 +181,79 @@ static void exynos_plane_destroy(struct drm_plane *plane)
103 kfree(exynos_plane); 181 kfree(exynos_plane);
104} 182}
105 183
184static int exynos_plane_set_property(struct drm_plane *plane,
185 struct drm_property *property,
186 uint64_t val)
187{
188 struct drm_device *dev = plane->dev;
189 struct exynos_plane *exynos_plane = to_exynos_plane(plane);
190 struct exynos_drm_private *dev_priv = dev->dev_private;
191
192 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
193
194 if (property == dev_priv->plane_zpos_property) {
195 exynos_plane->overlay.zpos = val;
196 return 0;
197 }
198
199 return -EINVAL;
200}
201
106static struct drm_plane_funcs exynos_plane_funcs = { 202static struct drm_plane_funcs exynos_plane_funcs = {
107 .update_plane = exynos_update_plane, 203 .update_plane = exynos_update_plane,
108 .disable_plane = exynos_disable_plane, 204 .disable_plane = exynos_disable_plane,
109 .destroy = exynos_plane_destroy, 205 .destroy = exynos_plane_destroy,
206 .set_property = exynos_plane_set_property,
110}; 207};
111 208
112int exynos_plane_init(struct drm_device *dev, unsigned int nr) 209static void exynos_plane_attach_zpos_property(struct drm_plane *plane)
113{ 210{
114 struct exynos_plane *exynos_plane; 211 struct drm_device *dev = plane->dev;
115 uint32_t possible_crtcs; 212 struct exynos_drm_private *dev_priv = dev->dev_private;
213 struct drm_property *prop;
116 214
117 exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL); 215 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
118 if (!exynos_plane)
119 return -ENOMEM;
120 216
121 /* all CRTCs are available */ 217 prop = dev_priv->plane_zpos_property;
122 possible_crtcs = (1 << MAX_CRTC) - 1; 218 if (!prop) {
219 prop = drm_property_create_range(dev, 0, "zpos", 0,
220 MAX_PLANE - 1);
221 if (!prop)
222 return;
123 223
124 exynos_plane->overlay.zpos = DEFAULT_ZPOS; 224 dev_priv->plane_zpos_property = prop;
225 }
125 226
126 return drm_plane_init(dev, &exynos_plane->base, possible_crtcs, 227 drm_object_attach_property(&plane->base, prop, 0);
127 &exynos_plane_funcs, formats, ARRAY_SIZE(formats),
128 false);
129} 228}
130 229
131int exynos_plane_set_zpos_ioctl(struct drm_device *dev, void *data, 230struct drm_plane *exynos_plane_init(struct drm_device *dev,
132 struct drm_file *file_priv) 231 unsigned int possible_crtcs, bool priv)
133{ 232{
134 struct drm_exynos_plane_set_zpos *zpos_req = data;
135 struct drm_mode_object *obj;
136 struct drm_plane *plane;
137 struct exynos_plane *exynos_plane; 233 struct exynos_plane *exynos_plane;
138 int ret = 0; 234 int err;
139 235
140 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 236 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
141 237
142 if (!drm_core_check_feature(dev, DRIVER_MODESET)) 238 exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL);
143 return -EINVAL; 239 if (!exynos_plane) {
144 240 DRM_ERROR("failed to allocate plane\n");
145 if (zpos_req->zpos < 0 || zpos_req->zpos >= MAX_PLANE) { 241 return NULL;
146 if (zpos_req->zpos != DEFAULT_ZPOS) {
147 DRM_ERROR("zpos not within limits\n");
148 return -EINVAL;
149 }
150 } 242 }
151 243
152 mutex_lock(&dev->mode_config.mutex); 244 err = drm_plane_init(dev, &exynos_plane->base, possible_crtcs,
153 245 &exynos_plane_funcs, formats, ARRAY_SIZE(formats),
154 obj = drm_mode_object_find(dev, zpos_req->plane_id, 246 priv);
155 DRM_MODE_OBJECT_PLANE); 247 if (err) {
156 if (!obj) { 248 DRM_ERROR("failed to initialize plane\n");
157 DRM_DEBUG_KMS("Unknown plane ID %d\n", 249 kfree(exynos_plane);
158 zpos_req->plane_id); 250 return NULL;
159 ret = -EINVAL;
160 goto out;
161 } 251 }
162 252
163 plane = obj_to_plane(obj); 253 if (priv)
164 exynos_plane = container_of(plane, struct exynos_plane, base); 254 exynos_plane->overlay.zpos = DEFAULT_ZPOS;
165 255 else
166 exynos_plane->overlay.zpos = zpos_req->zpos; 256 exynos_plane_attach_zpos_property(&exynos_plane->base);
167 257
168out: 258 return &exynos_plane->base;
169 mutex_unlock(&dev->mode_config.mutex);
170 return ret;
171} 259}
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.h b/drivers/gpu/drm/exynos/exynos_drm_plane.h
index 16b71f8217e7..88312458580d 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.h
@@ -9,6 +9,12 @@
9 * 9 *
10 */ 10 */
11 11
12int exynos_plane_init(struct drm_device *dev, unsigned int nr); 12int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc,
13int exynos_plane_set_zpos_ioctl(struct drm_device *dev, void *data, 13 struct drm_framebuffer *fb, int crtc_x, int crtc_y,
14 struct drm_file *file_priv); 14 unsigned int crtc_w, unsigned int crtc_h,
15 uint32_t src_x, uint32_t src_y,
16 uint32_t src_w, uint32_t src_h);
17void exynos_plane_commit(struct drm_plane *plane);
18void exynos_plane_dpms(struct drm_plane *plane, int mode);
19struct drm_plane *exynos_plane_init(struct drm_device *dev,
20 unsigned int possible_crtcs, bool priv);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index 7b9c153dceb6..bb1550c4dd57 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -85,8 +85,6 @@ static const char fake_edid_info[] = {
85 0x00, 0x00, 0x00, 0x06 85 0x00, 0x00, 0x00, 0x06
86}; 86};
87 87
88static void vidi_fake_vblank_handler(struct work_struct *work);
89
90static bool vidi_display_is_connected(struct device *dev) 88static bool vidi_display_is_connected(struct device *dev)
91{ 89{
92 struct vidi_context *ctx = get_vidi_context(dev); 90 struct vidi_context *ctx = get_vidi_context(dev);
@@ -531,6 +529,16 @@ static int vidi_store_connection(struct device *dev,
531 if (ctx->connected > 1) 529 if (ctx->connected > 1)
532 return -EINVAL; 530 return -EINVAL;
533 531
532 /* use fake edid data for test. */
533 if (!ctx->raw_edid)
534 ctx->raw_edid = (struct edid *)fake_edid_info;
535
536 /* if raw_edid isn't same as fake data then it can't be tested. */
537 if (ctx->raw_edid != (struct edid *)fake_edid_info) {
538 DRM_DEBUG_KMS("edid data is not fake data.\n");
539 return -EINVAL;
540 }
541
534 DRM_DEBUG_KMS("requested connection.\n"); 542 DRM_DEBUG_KMS("requested connection.\n");
535 543
536 drm_helper_hpd_irq_event(ctx->subdrv.drm_dev); 544 drm_helper_hpd_irq_event(ctx->subdrv.drm_dev);
@@ -549,6 +557,8 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
549 struct exynos_drm_manager *manager; 557 struct exynos_drm_manager *manager;
550 struct exynos_drm_display_ops *display_ops; 558 struct exynos_drm_display_ops *display_ops;
551 struct drm_exynos_vidi_connection *vidi = data; 559 struct drm_exynos_vidi_connection *vidi = data;
560 struct edid *raw_edid;
561 int edid_len;
552 562
553 DRM_DEBUG_KMS("%s\n", __FILE__); 563 DRM_DEBUG_KMS("%s\n", __FILE__);
554 564
@@ -557,11 +567,6 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
557 return -EINVAL; 567 return -EINVAL;
558 } 568 }
559 569
560 if (!vidi->edid) {
561 DRM_DEBUG_KMS("edid data is null.\n");
562 return -EINVAL;
563 }
564
565 if (vidi->connection > 1) { 570 if (vidi->connection > 1) {
566 DRM_DEBUG_KMS("connection should be 0 or 1.\n"); 571 DRM_DEBUG_KMS("connection should be 0 or 1.\n");
567 return -EINVAL; 572 return -EINVAL;
@@ -588,8 +593,30 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
588 return -EINVAL; 593 return -EINVAL;
589 } 594 }
590 595
591 if (vidi->connection) 596 if (vidi->connection) {
592 ctx->raw_edid = (struct edid *)vidi->edid; 597 if (!vidi->edid) {
598 DRM_DEBUG_KMS("edid data is null.\n");
599 return -EINVAL;
600 }
601 raw_edid = (struct edid *)(uint32_t)vidi->edid;
602 edid_len = (1 + raw_edid->extensions) * EDID_LENGTH;
603 ctx->raw_edid = kzalloc(edid_len, GFP_KERNEL);
604 if (!ctx->raw_edid) {
605 DRM_DEBUG_KMS("failed to allocate raw_edid.\n");
606 return -ENOMEM;
607 }
608 memcpy(ctx->raw_edid, raw_edid, edid_len);
609 } else {
610 /*
611 * with connection = 0, free raw_edid
612 * only if raw edid data isn't same as fake data.
613 */
614 if (ctx->raw_edid && ctx->raw_edid !=
615 (struct edid *)fake_edid_info) {
616 kfree(ctx->raw_edid);
617 ctx->raw_edid = NULL;
618 }
619 }
593 620
594 ctx->connected = vidi->connection; 621 ctx->connected = vidi->connection;
595 drm_helper_hpd_irq_event(ctx->subdrv.drm_dev); 622 drm_helper_hpd_irq_event(ctx->subdrv.drm_dev);
@@ -614,9 +641,6 @@ static int __devinit vidi_probe(struct platform_device *pdev)
614 641
615 INIT_WORK(&ctx->work, vidi_fake_vblank_handler); 642 INIT_WORK(&ctx->work, vidi_fake_vblank_handler);
616 643
617 /* for test */
618 ctx->raw_edid = (struct edid *)fake_edid_info;
619
620 subdrv = &ctx->subdrv; 644 subdrv = &ctx->subdrv;
621 subdrv->dev = dev; 645 subdrv->dev = dev;
622 subdrv->manager = &vidi_manager; 646 subdrv->manager = &vidi_manager;
@@ -644,6 +668,11 @@ static int __devexit vidi_remove(struct platform_device *pdev)
644 668
645 exynos_drm_subdrv_unregister(&ctx->subdrv); 669 exynos_drm_subdrv_unregister(&ctx->subdrv);
646 670
671 if (ctx->raw_edid != (struct edid *)fake_edid_info) {
672 kfree(ctx->raw_edid);
673 ctx->raw_edid = NULL;
674 }
675
647 kfree(ctx); 676 kfree(ctx);
648 677
649 return 0; 678 return 0;
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 066bde3f19c4..409e2ec1207c 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -63,7 +63,6 @@ struct hdmi_context {
63 bool dvi_mode; 63 bool dvi_mode;
64 struct mutex hdmi_mutex; 64 struct mutex hdmi_mutex;
65 65
66 struct resource *regs_res;
67 void __iomem *regs; 66 void __iomem *regs;
68 unsigned int external_irq; 67 unsigned int external_irq;
69 unsigned int internal_irq; 68 unsigned int internal_irq;
@@ -2280,16 +2279,17 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
2280 return -EINVAL; 2279 return -EINVAL;
2281 } 2280 }
2282 2281
2283 drm_hdmi_ctx = kzalloc(sizeof(*drm_hdmi_ctx), GFP_KERNEL); 2282 drm_hdmi_ctx = devm_kzalloc(&pdev->dev, sizeof(*drm_hdmi_ctx),
2283 GFP_KERNEL);
2284 if (!drm_hdmi_ctx) { 2284 if (!drm_hdmi_ctx) {
2285 DRM_ERROR("failed to allocate common hdmi context.\n"); 2285 DRM_ERROR("failed to allocate common hdmi context.\n");
2286 return -ENOMEM; 2286 return -ENOMEM;
2287 } 2287 }
2288 2288
2289 hdata = kzalloc(sizeof(struct hdmi_context), GFP_KERNEL); 2289 hdata = devm_kzalloc(&pdev->dev, sizeof(struct hdmi_context),
2290 GFP_KERNEL);
2290 if (!hdata) { 2291 if (!hdata) {
2291 DRM_ERROR("out of memory\n"); 2292 DRM_ERROR("out of memory\n");
2292 kfree(drm_hdmi_ctx);
2293 return -ENOMEM; 2293 return -ENOMEM;
2294 } 2294 }
2295 2295
@@ -2318,26 +2318,18 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
2318 goto err_resource; 2318 goto err_resource;
2319 } 2319 }
2320 2320
2321 hdata->regs_res = request_mem_region(res->start, resource_size(res), 2321 hdata->regs = devm_request_and_ioremap(&pdev->dev, res);
2322 dev_name(dev));
2323 if (!hdata->regs_res) {
2324 DRM_ERROR("failed to claim register region\n");
2325 ret = -ENOENT;
2326 goto err_resource;
2327 }
2328
2329 hdata->regs = ioremap(res->start, resource_size(res));
2330 if (!hdata->regs) { 2322 if (!hdata->regs) {
2331 DRM_ERROR("failed to map registers\n"); 2323 DRM_ERROR("failed to map registers\n");
2332 ret = -ENXIO; 2324 ret = -ENXIO;
2333 goto err_req_region; 2325 goto err_resource;
2334 } 2326 }
2335 2327
2336 /* DDC i2c driver */ 2328 /* DDC i2c driver */
2337 if (i2c_add_driver(&ddc_driver)) { 2329 if (i2c_add_driver(&ddc_driver)) {
2338 DRM_ERROR("failed to register ddc i2c driver\n"); 2330 DRM_ERROR("failed to register ddc i2c driver\n");
2339 ret = -ENOENT; 2331 ret = -ENOENT;
2340 goto err_iomap; 2332 goto err_resource;
2341 } 2333 }
2342 2334
2343 hdata->ddc_port = hdmi_ddc; 2335 hdata->ddc_port = hdmi_ddc;
@@ -2398,16 +2390,9 @@ err_hdmiphy:
2398 i2c_del_driver(&hdmiphy_driver); 2390 i2c_del_driver(&hdmiphy_driver);
2399err_ddc: 2391err_ddc:
2400 i2c_del_driver(&ddc_driver); 2392 i2c_del_driver(&ddc_driver);
2401err_iomap:
2402 iounmap(hdata->regs);
2403err_req_region:
2404 release_mem_region(hdata->regs_res->start,
2405 resource_size(hdata->regs_res));
2406err_resource: 2393err_resource:
2407 hdmi_resources_cleanup(hdata); 2394 hdmi_resources_cleanup(hdata);
2408err_data: 2395err_data:
2409 kfree(hdata);
2410 kfree(drm_hdmi_ctx);
2411 return ret; 2396 return ret;
2412} 2397}
2413 2398
@@ -2425,18 +2410,11 @@ static int __devexit hdmi_remove(struct platform_device *pdev)
2425 2410
2426 hdmi_resources_cleanup(hdata); 2411 hdmi_resources_cleanup(hdata);
2427 2412
2428 iounmap(hdata->regs);
2429
2430 release_mem_region(hdata->regs_res->start,
2431 resource_size(hdata->regs_res));
2432
2433 /* hdmiphy i2c driver */ 2413 /* hdmiphy i2c driver */
2434 i2c_del_driver(&hdmiphy_driver); 2414 i2c_del_driver(&hdmiphy_driver);
2435 /* DDC i2c driver */ 2415 /* DDC i2c driver */
2436 i2c_del_driver(&ddc_driver); 2416 i2c_del_driver(&ddc_driver);
2437 2417
2438 kfree(hdata);
2439
2440 return 0; 2418 return 0;
2441} 2419}
2442 2420
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index e2147a2ddcec..30fcc12f81dd 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -956,7 +956,8 @@ static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx,
956 956
957 clk_set_parent(mixer_res->sclk_mixer, mixer_res->sclk_hdmi); 957 clk_set_parent(mixer_res->sclk_mixer, mixer_res->sclk_hdmi);
958 958
959 mixer_res->mixer_regs = ioremap(res->start, resource_size(res)); 959 mixer_res->mixer_regs = devm_ioremap(&pdev->dev, res->start,
960 resource_size(res));
960 if (mixer_res->mixer_regs == NULL) { 961 if (mixer_res->mixer_regs == NULL) {
961 dev_err(dev, "register mapping failed.\n"); 962 dev_err(dev, "register mapping failed.\n");
962 ret = -ENXIO; 963 ret = -ENXIO;
@@ -967,38 +968,34 @@ static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx,
967 if (res == NULL) { 968 if (res == NULL) {
968 dev_err(dev, "get memory resource failed.\n"); 969 dev_err(dev, "get memory resource failed.\n");
969 ret = -ENXIO; 970 ret = -ENXIO;
970 goto fail_mixer_regs; 971 goto fail;
971 } 972 }
972 973
973 mixer_res->vp_regs = ioremap(res->start, resource_size(res)); 974 mixer_res->vp_regs = devm_ioremap(&pdev->dev, res->start,
975 resource_size(res));
974 if (mixer_res->vp_regs == NULL) { 976 if (mixer_res->vp_regs == NULL) {
975 dev_err(dev, "register mapping failed.\n"); 977 dev_err(dev, "register mapping failed.\n");
976 ret = -ENXIO; 978 ret = -ENXIO;
977 goto fail_mixer_regs; 979 goto fail;
978 } 980 }
979 981
980 res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq"); 982 res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "irq");
981 if (res == NULL) { 983 if (res == NULL) {
982 dev_err(dev, "get interrupt resource failed.\n"); 984 dev_err(dev, "get interrupt resource failed.\n");
983 ret = -ENXIO; 985 ret = -ENXIO;
984 goto fail_vp_regs; 986 goto fail;
985 } 987 }
986 988
987 ret = request_irq(res->start, mixer_irq_handler, 0, "drm_mixer", ctx); 989 ret = devm_request_irq(&pdev->dev, res->start, mixer_irq_handler,
990 0, "drm_mixer", ctx);
988 if (ret) { 991 if (ret) {
989 dev_err(dev, "request interrupt failed.\n"); 992 dev_err(dev, "request interrupt failed.\n");
990 goto fail_vp_regs; 993 goto fail;
991 } 994 }
992 mixer_res->irq = res->start; 995 mixer_res->irq = res->start;
993 996
994 return 0; 997 return 0;
995 998
996fail_vp_regs:
997 iounmap(mixer_res->vp_regs);
998
999fail_mixer_regs:
1000 iounmap(mixer_res->mixer_regs);
1001
1002fail: 999fail:
1003 if (!IS_ERR_OR_NULL(mixer_res->sclk_dac)) 1000 if (!IS_ERR_OR_NULL(mixer_res->sclk_dac))
1004 clk_put(mixer_res->sclk_dac); 1001 clk_put(mixer_res->sclk_dac);
@@ -1013,16 +1010,6 @@ fail:
1013 return ret; 1010 return ret;
1014} 1011}
1015 1012
1016static void mixer_resources_cleanup(struct mixer_context *ctx)
1017{
1018 struct mixer_resources *res = &ctx->mixer_res;
1019
1020 free_irq(res->irq, ctx);
1021
1022 iounmap(res->vp_regs);
1023 iounmap(res->mixer_regs);
1024}
1025
1026static int __devinit mixer_probe(struct platform_device *pdev) 1013static int __devinit mixer_probe(struct platform_device *pdev)
1027{ 1014{
1028 struct device *dev = &pdev->dev; 1015 struct device *dev = &pdev->dev;
@@ -1032,16 +1019,16 @@ static int __devinit mixer_probe(struct platform_device *pdev)
1032 1019
1033 dev_info(dev, "probe start\n"); 1020 dev_info(dev, "probe start\n");
1034 1021
1035 drm_hdmi_ctx = kzalloc(sizeof(*drm_hdmi_ctx), GFP_KERNEL); 1022 drm_hdmi_ctx = devm_kzalloc(&pdev->dev, sizeof(*drm_hdmi_ctx),
1023 GFP_KERNEL);
1036 if (!drm_hdmi_ctx) { 1024 if (!drm_hdmi_ctx) {
1037 DRM_ERROR("failed to allocate common hdmi context.\n"); 1025 DRM_ERROR("failed to allocate common hdmi context.\n");
1038 return -ENOMEM; 1026 return -ENOMEM;
1039 } 1027 }
1040 1028
1041 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 1029 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
1042 if (!ctx) { 1030 if (!ctx) {
1043 DRM_ERROR("failed to alloc mixer context.\n"); 1031 DRM_ERROR("failed to alloc mixer context.\n");
1044 kfree(drm_hdmi_ctx);
1045 return -ENOMEM; 1032 return -ENOMEM;
1046 } 1033 }
1047 1034
@@ -1072,17 +1059,10 @@ fail:
1072 1059
1073static int mixer_remove(struct platform_device *pdev) 1060static int mixer_remove(struct platform_device *pdev)
1074{ 1061{
1075 struct device *dev = &pdev->dev; 1062 dev_info(&pdev->dev, "remove successful\n");
1076 struct exynos_drm_hdmi_context *drm_hdmi_ctx =
1077 platform_get_drvdata(pdev);
1078 struct mixer_context *ctx = drm_hdmi_ctx->ctx;
1079
1080 dev_info(dev, "remove successful\n");
1081 1063
1082 pm_runtime_disable(&pdev->dev); 1064 pm_runtime_disable(&pdev->dev);
1083 1065
1084 mixer_resources_cleanup(ctx);
1085
1086 return 0; 1066 return 0;
1087} 1067}
1088 1068
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 563c02904ddf..23ab3c496b05 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -927,6 +927,8 @@ static int acpi_power_meter_remove(struct acpi_device *device, int type)
927 return 0; 927 return 0;
928} 928}
929 929
930#ifdef CONFIG_PM_SLEEP
931
930static int acpi_power_meter_resume(struct device *dev) 932static int acpi_power_meter_resume(struct device *dev)
931{ 933{
932 struct acpi_power_meter_resource *resource; 934 struct acpi_power_meter_resource *resource;
@@ -944,6 +946,8 @@ static int acpi_power_meter_resume(struct device *dev)
944 return 0; 946 return 0;
945} 947}
946 948
949#endif /* CONFIG_PM_SLEEP */
950
947static SIMPLE_DEV_PM_OPS(acpi_power_meter_pm, NULL, acpi_power_meter_resume); 951static SIMPLE_DEV_PM_OPS(acpi_power_meter_pm, NULL, acpi_power_meter_resume);
948 952
949static struct acpi_driver acpi_power_meter_driver = { 953static struct acpi_driver acpi_power_meter_driver = {
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 4d937a18fadb..282708860517 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -55,9 +55,9 @@
55 55
56/* wait up to 32 ms for a status change. */ 56/* wait up to 32 ms for a status change. */
57#define APPLESMC_MIN_WAIT 0x0010 57#define APPLESMC_MIN_WAIT 0x0010
58#define APPLESMC_RETRY_WAIT 0x0100
58#define APPLESMC_MAX_WAIT 0x8000 59#define APPLESMC_MAX_WAIT 0x8000
59 60
60#define APPLESMC_STATUS_MASK 0x0f
61#define APPLESMC_READ_CMD 0x10 61#define APPLESMC_READ_CMD 0x10
62#define APPLESMC_WRITE_CMD 0x11 62#define APPLESMC_WRITE_CMD 0x11
63#define APPLESMC_GET_KEY_BY_INDEX_CMD 0x12 63#define APPLESMC_GET_KEY_BY_INDEX_CMD 0x12
@@ -162,51 +162,68 @@ static unsigned int key_at_index;
162static struct workqueue_struct *applesmc_led_wq; 162static struct workqueue_struct *applesmc_led_wq;
163 163
164/* 164/*
165 * __wait_status - Wait up to 32ms for the status port to get a certain value 165 * wait_read - Wait for a byte to appear on SMC port. Callers must
166 * (masked with 0x0f), returning zero if the value is obtained. Callers must
167 * hold applesmc_lock. 166 * hold applesmc_lock.
168 */ 167 */
169static int __wait_status(u8 val) 168static int wait_read(void)
170{ 169{
170 u8 status;
171 int us; 171 int us;
172
173 val = val & APPLESMC_STATUS_MASK;
174
175 for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) { 172 for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
176 udelay(us); 173 udelay(us);
177 if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val) 174 status = inb(APPLESMC_CMD_PORT);
175 /* read: wait for smc to settle */
176 if (status & 0x01)
178 return 0; 177 return 0;
179 } 178 }
180 179
180 pr_warn("wait_read() fail: 0x%02x\n", status);
181 return -EIO; 181 return -EIO;
182} 182}
183 183
184/* 184/*
185 * special treatment of command port - on newer macbooks, it seems necessary 185 * send_byte - Write to SMC port, retrying when necessary. Callers
186 * to resend the command byte before polling the status again. Callers must 186 * must hold applesmc_lock.
187 * hold applesmc_lock.
188 */ 187 */
189static int send_command(u8 cmd) 188static int send_byte(u8 cmd, u16 port)
190{ 189{
190 u8 status;
191 int us; 191 int us;
192
193 outb(cmd, port);
192 for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) { 194 for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
193 outb(cmd, APPLESMC_CMD_PORT);
194 udelay(us); 195 udelay(us);
195 if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == 0x0c) 196 status = inb(APPLESMC_CMD_PORT);
197 /* write: wait for smc to settle */
198 if (status & 0x02)
199 continue;
200 /* ready: cmd accepted, return */
201 if (status & 0x04)
196 return 0; 202 return 0;
203 /* timeout: give up */
204 if (us << 1 == APPLESMC_MAX_WAIT)
205 break;
206 /* busy: long wait and resend */
207 udelay(APPLESMC_RETRY_WAIT);
208 outb(cmd, port);
197 } 209 }
210
211 pr_warn("send_byte(0x%02x, 0x%04x) fail: 0x%02x\n", cmd, port, status);
198 return -EIO; 212 return -EIO;
199} 213}
200 214
215static int send_command(u8 cmd)
216{
217 return send_byte(cmd, APPLESMC_CMD_PORT);
218}
219
201static int send_argument(const char *key) 220static int send_argument(const char *key)
202{ 221{
203 int i; 222 int i;
204 223
205 for (i = 0; i < 4; i++) { 224 for (i = 0; i < 4; i++)
206 outb(key[i], APPLESMC_DATA_PORT); 225 if (send_byte(key[i], APPLESMC_DATA_PORT))
207 if (__wait_status(0x04))
208 return -EIO; 226 return -EIO;
209 }
210 return 0; 227 return 0;
211} 228}
212 229
@@ -219,11 +236,14 @@ static int read_smc(u8 cmd, const char *key, u8 *buffer, u8 len)
219 return -EIO; 236 return -EIO;
220 } 237 }
221 238
222 outb(len, APPLESMC_DATA_PORT); 239 if (send_byte(len, APPLESMC_DATA_PORT)) {
240 pr_warn("%.4s: read len fail\n", key);
241 return -EIO;
242 }
223 243
224 for (i = 0; i < len; i++) { 244 for (i = 0; i < len; i++) {
225 if (__wait_status(0x05)) { 245 if (wait_read()) {
226 pr_warn("%.4s: read data fail\n", key); 246 pr_warn("%.4s: read data[%d] fail\n", key, i);
227 return -EIO; 247 return -EIO;
228 } 248 }
229 buffer[i] = inb(APPLESMC_DATA_PORT); 249 buffer[i] = inb(APPLESMC_DATA_PORT);
@@ -241,14 +261,16 @@ static int write_smc(u8 cmd, const char *key, const u8 *buffer, u8 len)
241 return -EIO; 261 return -EIO;
242 } 262 }
243 263
244 outb(len, APPLESMC_DATA_PORT); 264 if (send_byte(len, APPLESMC_DATA_PORT)) {
265 pr_warn("%.4s: write len fail\n", key);
266 return -EIO;
267 }
245 268
246 for (i = 0; i < len; i++) { 269 for (i = 0; i < len; i++) {
247 if (__wait_status(0x04)) { 270 if (send_byte(buffer[i], APPLESMC_DATA_PORT)) {
248 pr_warn("%s: write data fail\n", key); 271 pr_warn("%s: write data fail\n", key);
249 return -EIO; 272 return -EIO;
250 } 273 }
251 outb(buffer[i], APPLESMC_DATA_PORT);
252 } 274 }
253 275
254 return 0; 276 return 0;
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 637c51c11b44..faa16f80db9c 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -793,7 +793,7 @@ static struct notifier_block coretemp_cpu_notifier __refdata = {
793 .notifier_call = coretemp_cpu_callback, 793 .notifier_call = coretemp_cpu_callback,
794}; 794};
795 795
796static const struct x86_cpu_id coretemp_ids[] = { 796static const struct x86_cpu_id __initconst coretemp_ids[] = {
797 { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_DTHERM }, 797 { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_DTHERM },
798 {} 798 {}
799}; 799};
diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c
index e72ba5d2a824..e21e43c13156 100644
--- a/drivers/hwmon/jc42.c
+++ b/drivers/hwmon/jc42.c
@@ -57,7 +57,7 @@ static const unsigned short normal_i2c[] = {
57#define JC42_CFG_EVENT_LOCK (1 << 7) 57#define JC42_CFG_EVENT_LOCK (1 << 7)
58#define JC42_CFG_SHUTDOWN (1 << 8) 58#define JC42_CFG_SHUTDOWN (1 << 8)
59#define JC42_CFG_HYST_SHIFT 9 59#define JC42_CFG_HYST_SHIFT 9
60#define JC42_CFG_HYST_MASK 0x03 60#define JC42_CFG_HYST_MASK (0x03 << 9)
61 61
62/* Capabilities */ 62/* Capabilities */
63#define JC42_CAP_RANGE (1 << 2) 63#define JC42_CAP_RANGE (1 << 2)
@@ -287,8 +287,8 @@ static ssize_t show_temp_crit_hyst(struct device *dev,
287 return PTR_ERR(data); 287 return PTR_ERR(data);
288 288
289 temp = jc42_temp_from_reg(data->temp_crit); 289 temp = jc42_temp_from_reg(data->temp_crit);
290 hyst = jc42_hysteresis[(data->config >> JC42_CFG_HYST_SHIFT) 290 hyst = jc42_hysteresis[(data->config & JC42_CFG_HYST_MASK)
291 & JC42_CFG_HYST_MASK]; 291 >> JC42_CFG_HYST_SHIFT];
292 return sprintf(buf, "%d\n", temp - hyst); 292 return sprintf(buf, "%d\n", temp - hyst);
293} 293}
294 294
@@ -302,8 +302,8 @@ static ssize_t show_temp_max_hyst(struct device *dev,
302 return PTR_ERR(data); 302 return PTR_ERR(data);
303 303
304 temp = jc42_temp_from_reg(data->temp_max); 304 temp = jc42_temp_from_reg(data->temp_max);
305 hyst = jc42_hysteresis[(data->config >> JC42_CFG_HYST_SHIFT) 305 hyst = jc42_hysteresis[(data->config & JC42_CFG_HYST_MASK)
306 & JC42_CFG_HYST_MASK]; 306 >> JC42_CFG_HYST_SHIFT];
307 return sprintf(buf, "%d\n", temp - hyst); 307 return sprintf(buf, "%d\n", temp - hyst);
308} 308}
309 309
@@ -362,8 +362,7 @@ static ssize_t set_temp_crit_hyst(struct device *dev,
362 } 362 }
363 363
364 mutex_lock(&data->update_lock); 364 mutex_lock(&data->update_lock);
365 data->config = (data->config 365 data->config = (data->config & ~JC42_CFG_HYST_MASK)
366 & ~(JC42_CFG_HYST_MASK << JC42_CFG_HYST_SHIFT))
367 | (hyst << JC42_CFG_HYST_SHIFT); 366 | (hyst << JC42_CFG_HYST_SHIFT);
368 err = i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, 367 err = i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG,
369 data->config); 368 data->config);
@@ -535,9 +534,16 @@ static int jc42_remove(struct i2c_client *client)
535 struct jc42_data *data = i2c_get_clientdata(client); 534 struct jc42_data *data = i2c_get_clientdata(client);
536 hwmon_device_unregister(data->hwmon_dev); 535 hwmon_device_unregister(data->hwmon_dev);
537 sysfs_remove_group(&client->dev.kobj, &jc42_group); 536 sysfs_remove_group(&client->dev.kobj, &jc42_group);
538 if (data->config != data->orig_config) 537
539 i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, 538 /* Restore original configuration except hysteresis */
540 data->orig_config); 539 if ((data->config & ~JC42_CFG_HYST_MASK) !=
540 (data->orig_config & ~JC42_CFG_HYST_MASK)) {
541 int config;
542
543 config = (data->orig_config & ~JC42_CFG_HYST_MASK)
544 | (data->config & JC42_CFG_HYST_MASK);
545 i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, config);
546 }
541 return 0; 547 return 0;
542} 548}
543 549
diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
index 8689664ef03c..ee4ebc198a94 100644
--- a/drivers/hwmon/via-cputemp.c
+++ b/drivers/hwmon/via-cputemp.c
@@ -309,7 +309,7 @@ static struct notifier_block via_cputemp_cpu_notifier __refdata = {
309 .notifier_call = via_cputemp_cpu_callback, 309 .notifier_call = via_cputemp_cpu_callback,
310}; 310};
311 311
312static const struct x86_cpu_id cputemp_ids[] = { 312static const struct x86_cpu_id __initconst cputemp_ids[] = {
313 { X86_VENDOR_CENTAUR, 6, 0xa, }, /* C7 A */ 313 { X86_VENDOR_CENTAUR, 6, 0xa, }, /* C7 A */
314 { X86_VENDOR_CENTAUR, 6, 0xd, }, /* C7 D */ 314 { X86_VENDOR_CENTAUR, 6, 0xd, }, /* C7 D */
315 { X86_VENDOR_CENTAUR, 6, 0xf, }, /* Nano */ 315 { X86_VENDOR_CENTAUR, 6, 0xf, }, /* Nano */
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c
index ee139a598814..f44c83549fe5 100644
--- a/drivers/i2c/busses/i2c-octeon.c
+++ b/drivers/i2c/busses/i2c-octeon.c
@@ -2,7 +2,7 @@
2 * (C) Copyright 2009-2010 2 * (C) Copyright 2009-2010
3 * Nokia Siemens Networks, michael.lawnick.ext@nsn.com 3 * Nokia Siemens Networks, michael.lawnick.ext@nsn.com
4 * 4 *
5 * Portions Copyright (C) 2010 Cavium Networks, Inc. 5 * Portions Copyright (C) 2010, 2011 Cavium Networks, Inc.
6 * 6 *
7 * This is a driver for the i2c adapter in Cavium Networks' OCTEON processors. 7 * This is a driver for the i2c adapter in Cavium Networks' OCTEON processors.
8 * 8 *
@@ -11,17 +11,18 @@
11 * warranty of any kind, whether express or implied. 11 * warranty of any kind, whether express or implied.
12 */ 12 */
13 13
14#include <linux/platform_device.h>
15#include <linux/interrupt.h>
14#include <linux/kernel.h> 16#include <linux/kernel.h>
15#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/of_i2c.h>
19#include <linux/delay.h>
16#include <linux/sched.h> 20#include <linux/sched.h>
17#include <linux/slab.h> 21#include <linux/slab.h>
18#include <linux/init.h> 22#include <linux/init.h>
19
20#include <linux/io.h>
21#include <linux/i2c.h> 23#include <linux/i2c.h>
22#include <linux/interrupt.h> 24#include <linux/io.h>
23#include <linux/delay.h> 25#include <linux/of.h>
24#include <linux/platform_device.h>
25 26
26#include <asm/octeon/octeon.h> 27#include <asm/octeon/octeon.h>
27 28
@@ -65,7 +66,7 @@ struct octeon_i2c {
65 wait_queue_head_t queue; 66 wait_queue_head_t queue;
66 struct i2c_adapter adap; 67 struct i2c_adapter adap;
67 int irq; 68 int irq;
68 int twsi_freq; 69 u32 twsi_freq;
69 int sys_freq; 70 int sys_freq;
70 resource_size_t twsi_phys; 71 resource_size_t twsi_phys;
71 void __iomem *twsi_base; 72 void __iomem *twsi_base;
@@ -121,10 +122,8 @@ static u8 octeon_i2c_read_sw(struct octeon_i2c *i2c, u64 eop_reg)
121 */ 122 */
122static void octeon_i2c_write_int(struct octeon_i2c *i2c, u64 data) 123static void octeon_i2c_write_int(struct octeon_i2c *i2c, u64 data)
123{ 124{
124 u64 tmp;
125
126 __raw_writeq(data, i2c->twsi_base + TWSI_INT); 125 __raw_writeq(data, i2c->twsi_base + TWSI_INT);
127 tmp = __raw_readq(i2c->twsi_base + TWSI_INT); 126 __raw_readq(i2c->twsi_base + TWSI_INT);
128} 127}
129 128
130/** 129/**
@@ -515,7 +514,6 @@ static int __devinit octeon_i2c_probe(struct platform_device *pdev)
515{ 514{
516 int irq, result = 0; 515 int irq, result = 0;
517 struct octeon_i2c *i2c; 516 struct octeon_i2c *i2c;
518 struct octeon_i2c_data *i2c_data;
519 struct resource *res_mem; 517 struct resource *res_mem;
520 518
521 /* All adaptors have an irq. */ 519 /* All adaptors have an irq. */
@@ -523,86 +521,90 @@ static int __devinit octeon_i2c_probe(struct platform_device *pdev)
523 if (irq < 0) 521 if (irq < 0)
524 return irq; 522 return irq;
525 523
526 i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); 524 i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL);
527 if (!i2c) { 525 if (!i2c) {
528 dev_err(&pdev->dev, "kzalloc failed\n"); 526 dev_err(&pdev->dev, "kzalloc failed\n");
529 result = -ENOMEM; 527 result = -ENOMEM;
530 goto out; 528 goto out;
531 } 529 }
532 i2c->dev = &pdev->dev; 530 i2c->dev = &pdev->dev;
533 i2c_data = pdev->dev.platform_data;
534 531
535 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 532 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
536 533
537 if (res_mem == NULL) { 534 if (res_mem == NULL) {
538 dev_err(i2c->dev, "found no memory resource\n"); 535 dev_err(i2c->dev, "found no memory resource\n");
539 result = -ENXIO; 536 result = -ENXIO;
540 goto fail_region; 537 goto out;
541 } 538 }
539 i2c->twsi_phys = res_mem->start;
540 i2c->regsize = resource_size(res_mem);
542 541
543 if (i2c_data == NULL) { 542 /*
544 dev_err(i2c->dev, "no I2C frequency data\n"); 543 * "clock-rate" is a legacy binding, the official binding is
544 * "clock-frequency". Try the official one first and then
545 * fall back if it doesn't exist.
546 */
547 if (of_property_read_u32(pdev->dev.of_node,
548 "clock-frequency", &i2c->twsi_freq) &&
549 of_property_read_u32(pdev->dev.of_node,
550 "clock-rate", &i2c->twsi_freq)) {
551 dev_err(i2c->dev,
552 "no I2C 'clock-rate' or 'clock-frequency' property\n");
545 result = -ENXIO; 553 result = -ENXIO;
546 goto fail_region; 554 goto out;
547 } 555 }
548 556
549 i2c->twsi_phys = res_mem->start; 557 i2c->sys_freq = octeon_get_io_clock_rate();
550 i2c->regsize = resource_size(res_mem);
551 i2c->twsi_freq = i2c_data->i2c_freq;
552 i2c->sys_freq = i2c_data->sys_freq;
553 558
554 if (!request_mem_region(i2c->twsi_phys, i2c->regsize, res_mem->name)) { 559 if (!devm_request_mem_region(&pdev->dev, i2c->twsi_phys, i2c->regsize,
560 res_mem->name)) {
555 dev_err(i2c->dev, "request_mem_region failed\n"); 561 dev_err(i2c->dev, "request_mem_region failed\n");
556 goto fail_region; 562 goto out;
557 } 563 }
558 i2c->twsi_base = ioremap(i2c->twsi_phys, i2c->regsize); 564 i2c->twsi_base = devm_ioremap(&pdev->dev, i2c->twsi_phys, i2c->regsize);
559 565
560 init_waitqueue_head(&i2c->queue); 566 init_waitqueue_head(&i2c->queue);
561 567
562 i2c->irq = irq; 568 i2c->irq = irq;
563 569
564 result = request_irq(i2c->irq, octeon_i2c_isr, 0, DRV_NAME, i2c); 570 result = devm_request_irq(&pdev->dev, i2c->irq,
571 octeon_i2c_isr, 0, DRV_NAME, i2c);
565 if (result < 0) { 572 if (result < 0) {
566 dev_err(i2c->dev, "failed to attach interrupt\n"); 573 dev_err(i2c->dev, "failed to attach interrupt\n");
567 goto fail_irq; 574 goto out;
568 } 575 }
569 576
570 result = octeon_i2c_initlowlevel(i2c); 577 result = octeon_i2c_initlowlevel(i2c);
571 if (result) { 578 if (result) {
572 dev_err(i2c->dev, "init low level failed\n"); 579 dev_err(i2c->dev, "init low level failed\n");
573 goto fail_add; 580 goto out;
574 } 581 }
575 582
576 result = octeon_i2c_setclock(i2c); 583 result = octeon_i2c_setclock(i2c);
577 if (result) { 584 if (result) {
578 dev_err(i2c->dev, "clock init failed\n"); 585 dev_err(i2c->dev, "clock init failed\n");
579 goto fail_add; 586 goto out;
580 } 587 }
581 588
582 i2c->adap = octeon_i2c_ops; 589 i2c->adap = octeon_i2c_ops;
583 i2c->adap.dev.parent = &pdev->dev; 590 i2c->adap.dev.parent = &pdev->dev;
584 i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0; 591 i2c->adap.dev.of_node = pdev->dev.of_node;
585 i2c_set_adapdata(&i2c->adap, i2c); 592 i2c_set_adapdata(&i2c->adap, i2c);
586 platform_set_drvdata(pdev, i2c); 593 platform_set_drvdata(pdev, i2c);
587 594
588 result = i2c_add_numbered_adapter(&i2c->adap); 595 result = i2c_add_adapter(&i2c->adap);
589 if (result < 0) { 596 if (result < 0) {
590 dev_err(i2c->dev, "failed to add adapter\n"); 597 dev_err(i2c->dev, "failed to add adapter\n");
591 goto fail_add; 598 goto fail_add;
592 } 599 }
593
594 dev_info(i2c->dev, "version %s\n", DRV_VERSION); 600 dev_info(i2c->dev, "version %s\n", DRV_VERSION);
595 601
596 return result; 602 of_i2c_register_devices(&i2c->adap);
603
604 return 0;
597 605
598fail_add: 606fail_add:
599 platform_set_drvdata(pdev, NULL); 607 platform_set_drvdata(pdev, NULL);
600 free_irq(i2c->irq, i2c);
601fail_irq:
602 iounmap(i2c->twsi_base);
603 release_mem_region(i2c->twsi_phys, i2c->regsize);
604fail_region:
605 kfree(i2c);
606out: 608out:
607 return result; 609 return result;
608}; 610};
@@ -613,19 +615,24 @@ static int __devexit octeon_i2c_remove(struct platform_device *pdev)
613 615
614 i2c_del_adapter(&i2c->adap); 616 i2c_del_adapter(&i2c->adap);
615 platform_set_drvdata(pdev, NULL); 617 platform_set_drvdata(pdev, NULL);
616 free_irq(i2c->irq, i2c);
617 iounmap(i2c->twsi_base);
618 release_mem_region(i2c->twsi_phys, i2c->regsize);
619 kfree(i2c);
620 return 0; 618 return 0;
621}; 619};
622 620
621static struct of_device_id octeon_i2c_match[] = {
622 {
623 .compatible = "cavium,octeon-3860-twsi",
624 },
625 {},
626};
627MODULE_DEVICE_TABLE(of, octeon_i2c_match);
628
623static struct platform_driver octeon_i2c_driver = { 629static struct platform_driver octeon_i2c_driver = {
624 .probe = octeon_i2c_probe, 630 .probe = octeon_i2c_probe,
625 .remove = __devexit_p(octeon_i2c_remove), 631 .remove = __devexit_p(octeon_i2c_remove),
626 .driver = { 632 .driver = {
627 .owner = THIS_MODULE, 633 .owner = THIS_MODULE,
628 .name = DRV_NAME, 634 .name = DRV_NAME,
635 .of_match_table = octeon_i2c_match,
629 }, 636 },
630}; 637};
631 638
@@ -635,4 +642,3 @@ MODULE_AUTHOR("Michael Lawnick <michael.lawnick.ext@nsn.com>");
635MODULE_DESCRIPTION("I2C-Bus adapter for Cavium OCTEON processors"); 642MODULE_DESCRIPTION("I2C-Bus adapter for Cavium OCTEON processors");
636MODULE_LICENSE("GPL"); 643MODULE_LICENSE("GPL");
637MODULE_VERSION(DRV_VERSION); 644MODULE_VERSION(DRV_VERSION);
638MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/drivers/input/misc/88pm80x_onkey.c b/drivers/input/misc/88pm80x_onkey.c
new file mode 100644
index 000000000000..7f26e7b6c228
--- /dev/null
+++ b/drivers/input/misc/88pm80x_onkey.c
@@ -0,0 +1,168 @@
1/*
2 * Marvell 88PM80x ONKEY driver
3 *
4 * Copyright (C) 2012 Marvell International Ltd.
5 * Haojian Zhuang <haojian.zhuang@marvell.com>
6 * Qiao Zhou <zhouqiao@marvell.com>
7 *
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file "COPYING" in the main directory of this
10 * archive for more details.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <linux/kernel.h>
23#include <linux/module.h>
24#include <linux/input.h>
25#include <linux/mfd/88pm80x.h>
26#include <linux/regmap.h>
27#include <linux/slab.h>
28
29#define PM800_LONG_ONKEY_EN (1 << 0)
30#define PM800_LONG_KEY_DELAY (8) /* 1 .. 16 seconds */
31#define PM800_LONKEY_PRESS_TIME ((PM800_LONG_KEY_DELAY-1) << 4)
32#define PM800_LONKEY_PRESS_TIME_MASK (0xF0)
33#define PM800_SW_PDOWN (1 << 5)
34
35struct pm80x_onkey_info {
36 struct input_dev *idev;
37 struct pm80x_chip *pm80x;
38 struct regmap *map;
39 int irq;
40};
41
42/* 88PM80x gives us an interrupt when ONKEY is held */
43static irqreturn_t pm80x_onkey_handler(int irq, void *data)
44{
45 struct pm80x_onkey_info *info = data;
46 int ret = 0;
47 unsigned int val;
48
49 ret = regmap_read(info->map, PM800_STATUS_1, &val);
50 if (ret < 0) {
51 dev_err(info->idev->dev.parent, "failed to read status: %d\n", ret);
52 return IRQ_NONE;
53 }
54 val &= PM800_ONKEY_STS1;
55
56 input_report_key(info->idev, KEY_POWER, val);
57 input_sync(info->idev);
58
59 return IRQ_HANDLED;
60}
61
62static SIMPLE_DEV_PM_OPS(pm80x_onkey_pm_ops, pm80x_dev_suspend,
63 pm80x_dev_resume);
64
65static int __devinit pm80x_onkey_probe(struct platform_device *pdev)
66{
67
68 struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
69 struct pm80x_onkey_info *info;
70 int err;
71
72 info = kzalloc(sizeof(struct pm80x_onkey_info), GFP_KERNEL);
73 if (!info)
74 return -ENOMEM;
75
76 info->pm80x = chip;
77
78 info->irq = platform_get_irq(pdev, 0);
79 if (info->irq < 0) {
80 dev_err(&pdev->dev, "No IRQ resource!\n");
81 err = -EINVAL;
82 goto out;
83 }
84
85 info->map = info->pm80x->regmap;
86 if (!info->map) {
87 dev_err(&pdev->dev, "no regmap!\n");
88 err = -EINVAL;
89 goto out;
90 }
91
92 info->idev = input_allocate_device();
93 if (!info->idev) {
94 dev_err(&pdev->dev, "Failed to allocate input dev\n");
95 err = -ENOMEM;
96 goto out;
97 }
98
99 info->idev->name = "88pm80x_on";
100 info->idev->phys = "88pm80x_on/input0";
101 info->idev->id.bustype = BUS_I2C;
102 info->idev->dev.parent = &pdev->dev;
103 info->idev->evbit[0] = BIT_MASK(EV_KEY);
104 __set_bit(KEY_POWER, info->idev->keybit);
105
106 err = pm80x_request_irq(info->pm80x, info->irq, pm80x_onkey_handler,
107 IRQF_ONESHOT, "onkey", info);
108 if (err < 0) {
109 dev_err(&pdev->dev, "Failed to request IRQ: #%d: %d\n",
110 info->irq, err);
111 goto out_reg;
112 }
113
114 err = input_register_device(info->idev);
115 if (err) {
116 dev_err(&pdev->dev, "Can't register input device: %d\n", err);
117 goto out_irq;
118 }
119
120 platform_set_drvdata(pdev, info);
121
122 /* Enable long onkey detection */
123 regmap_update_bits(info->map, PM800_RTC_MISC4, PM800_LONG_ONKEY_EN,
124 PM800_LONG_ONKEY_EN);
125 /* Set 8-second interval */
126 regmap_update_bits(info->map, PM800_RTC_MISC3,
127 PM800_LONKEY_PRESS_TIME_MASK,
128 PM800_LONKEY_PRESS_TIME);
129
130 device_init_wakeup(&pdev->dev, 1);
131 return 0;
132
133out_irq:
134 pm80x_free_irq(info->pm80x, info->irq, info);
135out_reg:
136 input_free_device(info->idev);
137out:
138 kfree(info);
139 return err;
140}
141
142static int __devexit pm80x_onkey_remove(struct platform_device *pdev)
143{
144 struct pm80x_onkey_info *info = platform_get_drvdata(pdev);
145
146 device_init_wakeup(&pdev->dev, 0);
147 pm80x_free_irq(info->pm80x, info->irq, info);
148 input_unregister_device(info->idev);
149 kfree(info);
150 return 0;
151}
152
153static struct platform_driver pm80x_onkey_driver = {
154 .driver = {
155 .name = "88pm80x-onkey",
156 .owner = THIS_MODULE,
157 .pm = &pm80x_onkey_pm_ops,
158 },
159 .probe = pm80x_onkey_probe,
160 .remove = __devexit_p(pm80x_onkey_remove),
161};
162
163module_platform_driver(pm80x_onkey_driver);
164
165MODULE_LICENSE("GPL");
166MODULE_DESCRIPTION("Marvell 88PM80x ONKEY driver");
167MODULE_AUTHOR("Qiao Zhou <zhouqiao@marvell.com>");
168MODULE_ALIAS("platform:88pm80x-onkey");
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7faf4a7fcaa9..7c0f1ecfdd7a 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -22,6 +22,16 @@ config INPUT_88PM860X_ONKEY
22 To compile this driver as a module, choose M here: the module 22 To compile this driver as a module, choose M here: the module
23 will be called 88pm860x_onkey. 23 will be called 88pm860x_onkey.
24 24
25config INPUT_88PM80X_ONKEY
26 tristate "88PM80x ONKEY support"
27 depends on MFD_88PM800
28 help
29 Support the ONKEY of Marvell 88PM80x PMICs as an input device
30 reporting power button status.
31
32 To compile this driver as a module, choose M here: the module
33 will be called 88pm80x_onkey.
34
25config INPUT_AB8500_PONKEY 35config INPUT_AB8500_PONKEY
26 tristate "AB8500 Pon (PowerOn) Key" 36 tristate "AB8500 Pon (PowerOn) Key"
27 depends on AB8500_CORE 37 depends on AB8500_CORE
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index f55cdf4916fa..83fe6f5b77d1 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -5,6 +5,7 @@
5# Each configuration option enables a list of files. 5# Each configuration option enables a list of files.
6 6
7obj-$(CONFIG_INPUT_88PM860X_ONKEY) += 88pm860x_onkey.o 7obj-$(CONFIG_INPUT_88PM860X_ONKEY) += 88pm860x_onkey.o
8obj-$(CONFIG_INPUT_88PM80X_ONKEY) += 88pm80x_onkey.o
8obj-$(CONFIG_INPUT_AB8500_PONKEY) += ab8500-ponkey.o 9obj-$(CONFIG_INPUT_AB8500_PONKEY) += ab8500-ponkey.o
9obj-$(CONFIG_INPUT_AD714X) += ad714x.o 10obj-$(CONFIG_INPUT_AD714X) += ad714x.o
10obj-$(CONFIG_INPUT_AD714X_I2C) += ad714x-i2c.o 11obj-$(CONFIG_INPUT_AD714X_I2C) += ad714x-i2c.o
diff --git a/drivers/input/misc/ab8500-ponkey.c b/drivers/input/misc/ab8500-ponkey.c
index 84ec691c05aa..f06231b7cab1 100644
--- a/drivers/input/misc/ab8500-ponkey.c
+++ b/drivers/input/misc/ab8500-ponkey.c
@@ -74,8 +74,8 @@ static int __devinit ab8500_ponkey_probe(struct platform_device *pdev)
74 74
75 ponkey->idev = input; 75 ponkey->idev = input;
76 ponkey->ab8500 = ab8500; 76 ponkey->ab8500 = ab8500;
77 ponkey->irq_dbf = irq_dbf; 77 ponkey->irq_dbf = ab8500_irq_get_virq(ab8500, irq_dbf);
78 ponkey->irq_dbr = irq_dbr; 78 ponkey->irq_dbr = ab8500_irq_get_virq(ab8500, irq_dbr);
79 79
80 input->name = "AB8500 POn(PowerOn) Key"; 80 input->name = "AB8500 POn(PowerOn) Key";
81 input->dev.parent = &pdev->dev; 81 input->dev.parent = &pdev->dev;
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index d5b390f75c9a..14eaecea2b70 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -40,11 +40,27 @@
40 * Note that newer firmware allows querying device for maximum useable 40 * Note that newer firmware allows querying device for maximum useable
41 * coordinates. 41 * coordinates.
42 */ 42 */
43#define XMIN 0
44#define XMAX 6143
45#define YMIN 0
46#define YMAX 6143
43#define XMIN_NOMINAL 1472 47#define XMIN_NOMINAL 1472
44#define XMAX_NOMINAL 5472 48#define XMAX_NOMINAL 5472
45#define YMIN_NOMINAL 1408 49#define YMIN_NOMINAL 1408
46#define YMAX_NOMINAL 4448 50#define YMAX_NOMINAL 4448
47 51
52/* Size in bits of absolute position values reported by the hardware */
53#define ABS_POS_BITS 13
54
55/*
56 * Any position values from the hardware above the following limits are
57 * treated as "wrapped around negative" values that have been truncated to
58 * the 13-bit reporting range of the hardware. These are just reasonable
59 * guesses and can be adjusted if hardware is found that operates outside
60 * of these parameters.
61 */
62#define X_MAX_POSITIVE (((1 << ABS_POS_BITS) + XMAX) / 2)
63#define Y_MAX_POSITIVE (((1 << ABS_POS_BITS) + YMAX) / 2)
48 64
49/***************************************************************************** 65/*****************************************************************************
50 * Stuff we need even when we do not want native Synaptics support 66 * Stuff we need even when we do not want native Synaptics support
@@ -588,6 +604,12 @@ static int synaptics_parse_hw_state(const unsigned char buf[],
588 hw->right = (buf[0] & 0x02) ? 1 : 0; 604 hw->right = (buf[0] & 0x02) ? 1 : 0;
589 } 605 }
590 606
607 /* Convert wrap-around values to negative */
608 if (hw->x > X_MAX_POSITIVE)
609 hw->x -= 1 << ABS_POS_BITS;
610 if (hw->y > Y_MAX_POSITIVE)
611 hw->y -= 1 << ABS_POS_BITS;
612
591 return 0; 613 return 0;
592} 614}
593 615
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 6533f44be5bd..002041975de9 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -464,7 +464,7 @@ static void wacom_intuos_general(struct wacom_wac *wacom)
464 t = (data[6] << 2) | ((data[7] >> 6) & 3); 464 t = (data[6] << 2) | ((data[7] >> 6) & 3);
465 if ((features->type >= INTUOS4S && features->type <= INTUOS4L) || 465 if ((features->type >= INTUOS4S && features->type <= INTUOS4L) ||
466 (features->type >= INTUOS5S && features->type <= INTUOS5L) || 466 (features->type >= INTUOS5S && features->type <= INTUOS5L) ||
467 features->type == WACOM_21UX2 || features->type == WACOM_24HD) { 467 (features->type >= WACOM_21UX2 && features->type <= WACOM_24HD)) {
468 t = (t << 1) | (data[1] & 1); 468 t = (t << 1) | (data[1] & 1);
469 } 469 }
470 input_report_abs(input, ABS_PRESSURE, t); 470 input_report_abs(input, ABS_PRESSURE, t);
@@ -614,7 +614,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
614 input_report_abs(input, ABS_MISC, 0); 614 input_report_abs(input, ABS_MISC, 0);
615 } 615 }
616 } else { 616 } else {
617 if (features->type == WACOM_21UX2) { 617 if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
618 input_report_key(input, BTN_0, (data[5] & 0x01)); 618 input_report_key(input, BTN_0, (data[5] & 0x01));
619 input_report_key(input, BTN_1, (data[6] & 0x01)); 619 input_report_key(input, BTN_1, (data[6] & 0x01));
620 input_report_key(input, BTN_2, (data[6] & 0x02)); 620 input_report_key(input, BTN_2, (data[6] & 0x02));
@@ -633,6 +633,12 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
633 input_report_key(input, BTN_Z, (data[8] & 0x20)); 633 input_report_key(input, BTN_Z, (data[8] & 0x20));
634 input_report_key(input, BTN_BASE, (data[8] & 0x40)); 634 input_report_key(input, BTN_BASE, (data[8] & 0x40));
635 input_report_key(input, BTN_BASE2, (data[8] & 0x80)); 635 input_report_key(input, BTN_BASE2, (data[8] & 0x80));
636
637 if (features->type == WACOM_22HD) {
638 input_report_key(input, KEY_PROG1, data[9] & 0x01);
639 input_report_key(input, KEY_PROG2, data[9] & 0x02);
640 input_report_key(input, KEY_PROG3, data[9] & 0x04);
641 }
636 } else { 642 } else {
637 input_report_key(input, BTN_0, (data[5] & 0x01)); 643 input_report_key(input, BTN_0, (data[5] & 0x01));
638 input_report_key(input, BTN_1, (data[5] & 0x02)); 644 input_report_key(input, BTN_1, (data[5] & 0x02));
@@ -1231,6 +1237,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
1231 case CINTIQ: 1237 case CINTIQ:
1232 case WACOM_BEE: 1238 case WACOM_BEE:
1233 case WACOM_21UX2: 1239 case WACOM_21UX2:
1240 case WACOM_22HD:
1234 case WACOM_24HD: 1241 case WACOM_24HD:
1235 sync = wacom_intuos_irq(wacom_wac); 1242 sync = wacom_intuos_irq(wacom_wac);
1236 break; 1243 break;
@@ -1432,6 +1439,12 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
1432 wacom_setup_cintiq(wacom_wac); 1439 wacom_setup_cintiq(wacom_wac);
1433 break; 1440 break;
1434 1441
1442 case WACOM_22HD:
1443 __set_bit(KEY_PROG1, input_dev->keybit);
1444 __set_bit(KEY_PROG2, input_dev->keybit);
1445 __set_bit(KEY_PROG3, input_dev->keybit);
1446 /* fall through */
1447
1435 case WACOM_21UX2: 1448 case WACOM_21UX2:
1436 __set_bit(BTN_A, input_dev->keybit); 1449 __set_bit(BTN_A, input_dev->keybit);
1437 __set_bit(BTN_B, input_dev->keybit); 1450 __set_bit(BTN_B, input_dev->keybit);
@@ -1858,6 +1871,9 @@ static const struct wacom_features wacom_features_0xF0 =
1858static const struct wacom_features wacom_features_0xCC = 1871static const struct wacom_features wacom_features_0xCC =
1859 { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047, 1872 { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047,
1860 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 1873 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1874static const struct wacom_features wacom_features_0xFA =
1875 { "Wacom Cintiq 22HD", WACOM_PKGLEN_INTUOS, 95840, 54260, 2047,
1876 63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1861static const struct wacom_features wacom_features_0x90 = 1877static const struct wacom_features wacom_features_0x90 =
1862 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 1878 { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
1863 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1879 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -2075,6 +2091,7 @@ const struct usb_device_id wacom_ids[] = {
2075 { USB_DEVICE_WACOM(0xEF) }, 2091 { USB_DEVICE_WACOM(0xEF) },
2076 { USB_DEVICE_WACOM(0x47) }, 2092 { USB_DEVICE_WACOM(0x47) },
2077 { USB_DEVICE_WACOM(0xF4) }, 2093 { USB_DEVICE_WACOM(0xF4) },
2094 { USB_DEVICE_WACOM(0xFA) },
2078 { USB_DEVICE_LENOVO(0x6004) }, 2095 { USB_DEVICE_LENOVO(0x6004) },
2079 { } 2096 { }
2080}; 2097};
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index bd5d37b28714..96c185cc301e 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -73,8 +73,9 @@ enum {
73 INTUOS5S, 73 INTUOS5S,
74 INTUOS5, 74 INTUOS5,
75 INTUOS5L, 75 INTUOS5L,
76 WACOM_24HD,
77 WACOM_21UX2, 76 WACOM_21UX2,
77 WACOM_22HD,
78 WACOM_24HD,
78 CINTIQ, 79 CINTIQ,
79 WACOM_BEE, 80 WACOM_BEE,
80 WACOM_MO, 81 WACOM_MO,
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 73bd2f6b82ec..1ba232cbc09d 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -472,6 +472,19 @@ config TOUCHSCREEN_PENMOUNT
472 To compile this driver as a module, choose M here: the 472 To compile this driver as a module, choose M here: the
473 module will be called penmount. 473 module will be called penmount.
474 474
475config TOUCHSCREEN_EDT_FT5X06
476 tristate "EDT FocalTech FT5x06 I2C Touchscreen support"
477 depends on I2C
478 help
479 Say Y here if you have an EDT "Polytouch" touchscreen based
480 on the FocalTech FT5x06 family of controllers connected to
481 your system.
482
483 If unsure, say N.
484
485 To compile this driver as a module, choose M here: the
486 module will be called edt-ft5x06.
487
475config TOUCHSCREEN_MIGOR 488config TOUCHSCREEN_MIGOR
476 tristate "Renesas MIGO-R touchscreen" 489 tristate "Renesas MIGO-R touchscreen"
477 depends on SH_MIGOR && I2C 490 depends on SH_MIGOR && I2C
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 5920c60f999d..178eb128d90f 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_TOUCHSCREEN_CYTTSP_SPI) += cyttsp_spi.o
24obj-$(CONFIG_TOUCHSCREEN_DA9034) += da9034-ts.o 24obj-$(CONFIG_TOUCHSCREEN_DA9034) += da9034-ts.o
25obj-$(CONFIG_TOUCHSCREEN_DA9052) += da9052_tsi.o 25obj-$(CONFIG_TOUCHSCREEN_DA9052) += da9052_tsi.o
26obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o 26obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o
27obj-$(CONFIG_TOUCHSCREEN_EDT_FT5X06) += edt-ft5x06.o
27obj-$(CONFIG_TOUCHSCREEN_HAMPSHIRE) += hampshire.o 28obj-$(CONFIG_TOUCHSCREEN_HAMPSHIRE) += hampshire.o
28obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o 29obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o
29obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o 30obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
new file mode 100644
index 000000000000..9afc777a40a7
--- /dev/null
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -0,0 +1,898 @@
1/*
2 * Copyright (C) 2012 Simon Budig, <simon.budig@kernelconcepts.de>
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18/*
19 * This is a driver for the EDT "Polytouch" family of touch controllers
20 * based on the FocalTech FT5x06 line of chips.
21 *
22 * Development of this driver has been sponsored by Glyn:
23 * http://www.glyn.com/Products/Displays
24 */
25
26#include <linux/module.h>
27#include <linux/ratelimit.h>
28#include <linux/interrupt.h>
29#include <linux/input.h>
30#include <linux/i2c.h>
31#include <linux/uaccess.h>
32#include <linux/delay.h>
33#include <linux/debugfs.h>
34#include <linux/slab.h>
35#include <linux/gpio.h>
36#include <linux/input/mt.h>
37#include <linux/input/edt-ft5x06.h>
38
39#define MAX_SUPPORT_POINTS 5
40
41#define WORK_REGISTER_THRESHOLD 0x00
42#define WORK_REGISTER_REPORT_RATE 0x08
43#define WORK_REGISTER_GAIN 0x30
44#define WORK_REGISTER_OFFSET 0x31
45#define WORK_REGISTER_NUM_X 0x33
46#define WORK_REGISTER_NUM_Y 0x34
47
48#define WORK_REGISTER_OPMODE 0x3c
49#define FACTORY_REGISTER_OPMODE 0x01
50
51#define TOUCH_EVENT_DOWN 0x00
52#define TOUCH_EVENT_UP 0x01
53#define TOUCH_EVENT_ON 0x02
54#define TOUCH_EVENT_RESERVED 0x03
55
56#define EDT_NAME_LEN 23
57#define EDT_SWITCH_MODE_RETRIES 10
58#define EDT_SWITCH_MODE_DELAY 5 /* msec */
59#define EDT_RAW_DATA_RETRIES 100
60#define EDT_RAW_DATA_DELAY 1 /* msec */
61
62struct edt_ft5x06_ts_data {
63 struct i2c_client *client;
64 struct input_dev *input;
65 u16 num_x;
66 u16 num_y;
67
68#if defined(CONFIG_DEBUG_FS)
69 struct dentry *debug_dir;
70 u8 *raw_buffer;
71 size_t raw_bufsize;
72#endif
73
74 struct mutex mutex;
75 bool factory_mode;
76 int threshold;
77 int gain;
78 int offset;
79 int report_rate;
80
81 char name[EDT_NAME_LEN];
82};
83
84static int edt_ft5x06_ts_readwrite(struct i2c_client *client,
85 u16 wr_len, u8 *wr_buf,
86 u16 rd_len, u8 *rd_buf)
87{
88 struct i2c_msg wrmsg[2];
89 int i = 0;
90 int ret;
91
92 if (wr_len) {
93 wrmsg[i].addr = client->addr;
94 wrmsg[i].flags = 0;
95 wrmsg[i].len = wr_len;
96 wrmsg[i].buf = wr_buf;
97 i++;
98 }
99 if (rd_len) {
100 wrmsg[i].addr = client->addr;
101 wrmsg[i].flags = I2C_M_RD;
102 wrmsg[i].len = rd_len;
103 wrmsg[i].buf = rd_buf;
104 i++;
105 }
106
107 ret = i2c_transfer(client->adapter, wrmsg, i);
108 if (ret < 0)
109 return ret;
110 if (ret != i)
111 return -EIO;
112
113 return 0;
114}
115
116static bool edt_ft5x06_ts_check_crc(struct edt_ft5x06_ts_data *tsdata,
117 u8 *buf, int buflen)
118{
119 int i;
120 u8 crc = 0;
121
122 for (i = 0; i < buflen - 1; i++)
123 crc ^= buf[i];
124
125 if (crc != buf[buflen-1]) {
126 dev_err_ratelimited(&tsdata->client->dev,
127 "crc error: 0x%02x expected, got 0x%02x\n",
128 crc, buf[buflen-1]);
129 return false;
130 }
131
132 return true;
133}
134
135static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
136{
137 struct edt_ft5x06_ts_data *tsdata = dev_id;
138 struct device *dev = &tsdata->client->dev;
139 u8 cmd = 0xf9;
140 u8 rdbuf[26];
141 int i, type, x, y, id;
142 int error;
143
144 memset(rdbuf, 0, sizeof(rdbuf));
145
146 error = edt_ft5x06_ts_readwrite(tsdata->client,
147 sizeof(cmd), &cmd,
148 sizeof(rdbuf), rdbuf);
149 if (error) {
150 dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n",
151 error);
152 goto out;
153 }
154
155 if (rdbuf[0] != 0xaa || rdbuf[1] != 0xaa || rdbuf[2] != 26) {
156 dev_err_ratelimited(dev, "Unexpected header: %02x%02x%02x!\n",
157 rdbuf[0], rdbuf[1], rdbuf[2]);
158 goto out;
159 }
160
161 if (!edt_ft5x06_ts_check_crc(tsdata, rdbuf, 26))
162 goto out;
163
164 for (i = 0; i < MAX_SUPPORT_POINTS; i++) {
165 u8 *buf = &rdbuf[i * 4 + 5];
166 bool down;
167
168 type = buf[0] >> 6;
169 /* ignore Reserved events */
170 if (type == TOUCH_EVENT_RESERVED)
171 continue;
172
173 x = ((buf[0] << 8) | buf[1]) & 0x0fff;
174 y = ((buf[2] << 8) | buf[3]) & 0x0fff;
175 id = (buf[2] >> 4) & 0x0f;
176 down = (type != TOUCH_EVENT_UP);
177
178 input_mt_slot(tsdata->input, id);
179 input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, down);
180
181 if (!down)
182 continue;
183
184 input_report_abs(tsdata->input, ABS_MT_POSITION_X, x);
185 input_report_abs(tsdata->input, ABS_MT_POSITION_Y, y);
186 }
187
188 input_mt_report_pointer_emulation(tsdata->input, true);
189 input_sync(tsdata->input);
190
191out:
192 return IRQ_HANDLED;
193}
194
195static int edt_ft5x06_register_write(struct edt_ft5x06_ts_data *tsdata,
196 u8 addr, u8 value)
197{
198 u8 wrbuf[4];
199
200 wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc;
201 wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f;
202 wrbuf[2] = value;
203 wrbuf[3] = wrbuf[0] ^ wrbuf[1] ^ wrbuf[2];
204
205 return edt_ft5x06_ts_readwrite(tsdata->client, 4, wrbuf, 0, NULL);
206}
207
208static int edt_ft5x06_register_read(struct edt_ft5x06_ts_data *tsdata,
209 u8 addr)
210{
211 u8 wrbuf[2], rdbuf[2];
212 int error;
213
214 wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc;
215 wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f;
216 wrbuf[1] |= tsdata->factory_mode ? 0x80 : 0x40;
217
218 error = edt_ft5x06_ts_readwrite(tsdata->client, 2, wrbuf, 2, rdbuf);
219 if (error)
220 return error;
221
222 if ((wrbuf[0] ^ wrbuf[1] ^ rdbuf[0]) != rdbuf[1]) {
223 dev_err(&tsdata->client->dev,
224 "crc error: 0x%02x expected, got 0x%02x\n",
225 wrbuf[0] ^ wrbuf[1] ^ rdbuf[0], rdbuf[1]);
226 return -EIO;
227 }
228
229 return rdbuf[0];
230}
231
232struct edt_ft5x06_attribute {
233 struct device_attribute dattr;
234 size_t field_offset;
235 u8 limit_low;
236 u8 limit_high;
237 u8 addr;
238};
239
240#define EDT_ATTR(_field, _mode, _addr, _limit_low, _limit_high) \
241 struct edt_ft5x06_attribute edt_ft5x06_attr_##_field = { \
242 .dattr = __ATTR(_field, _mode, \
243 edt_ft5x06_setting_show, \
244 edt_ft5x06_setting_store), \
245 .field_offset = \
246 offsetof(struct edt_ft5x06_ts_data, _field), \
247 .limit_low = _limit_low, \
248 .limit_high = _limit_high, \
249 .addr = _addr, \
250 }
251
252static ssize_t edt_ft5x06_setting_show(struct device *dev,
253 struct device_attribute *dattr,
254 char *buf)
255{
256 struct i2c_client *client = to_i2c_client(dev);
257 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
258 struct edt_ft5x06_attribute *attr =
259 container_of(dattr, struct edt_ft5x06_attribute, dattr);
260 u8 *field = (u8 *)((char *)tsdata + attr->field_offset);
261 int val;
262 size_t count = 0;
263 int error = 0;
264
265 mutex_lock(&tsdata->mutex);
266
267 if (tsdata->factory_mode) {
268 error = -EIO;
269 goto out;
270 }
271
272 val = edt_ft5x06_register_read(tsdata, attr->addr);
273 if (val < 0) {
274 error = val;
275 dev_err(&tsdata->client->dev,
276 "Failed to fetch attribute %s, error %d\n",
277 dattr->attr.name, error);
278 goto out;
279 }
280
281 if (val != *field) {
282 dev_warn(&tsdata->client->dev,
283 "%s: read (%d) and stored value (%d) differ\n",
284 dattr->attr.name, val, *field);
285 *field = val;
286 }
287
288 count = scnprintf(buf, PAGE_SIZE, "%d\n", val);
289out:
290 mutex_unlock(&tsdata->mutex);
291 return error ?: count;
292}
293
294static ssize_t edt_ft5x06_setting_store(struct device *dev,
295 struct device_attribute *dattr,
296 const char *buf, size_t count)
297{
298 struct i2c_client *client = to_i2c_client(dev);
299 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
300 struct edt_ft5x06_attribute *attr =
301 container_of(dattr, struct edt_ft5x06_attribute, dattr);
302 u8 *field = (u8 *)((char *)tsdata + attr->field_offset);
303 unsigned int val;
304 int error;
305
306 mutex_lock(&tsdata->mutex);
307
308 if (tsdata->factory_mode) {
309 error = -EIO;
310 goto out;
311 }
312
313 error = kstrtouint(buf, 0, &val);
314 if (error)
315 goto out;
316
317 if (val < attr->limit_low || val > attr->limit_high) {
318 error = -ERANGE;
319 goto out;
320 }
321
322 error = edt_ft5x06_register_write(tsdata, attr->addr, val);
323 if (error) {
324 dev_err(&tsdata->client->dev,
325 "Failed to update attribute %s, error: %d\n",
326 dattr->attr.name, error);
327 goto out;
328 }
329
330 *field = val;
331
332out:
333 mutex_unlock(&tsdata->mutex);
334 return error ?: count;
335}
336
337static EDT_ATTR(gain, S_IWUSR | S_IRUGO, WORK_REGISTER_GAIN, 0, 31);
338static EDT_ATTR(offset, S_IWUSR | S_IRUGO, WORK_REGISTER_OFFSET, 0, 31);
339static EDT_ATTR(threshold, S_IWUSR | S_IRUGO,
340 WORK_REGISTER_THRESHOLD, 20, 80);
341static EDT_ATTR(report_rate, S_IWUSR | S_IRUGO,
342 WORK_REGISTER_REPORT_RATE, 3, 14);
343
344static struct attribute *edt_ft5x06_attrs[] = {
345 &edt_ft5x06_attr_gain.dattr.attr,
346 &edt_ft5x06_attr_offset.dattr.attr,
347 &edt_ft5x06_attr_threshold.dattr.attr,
348 &edt_ft5x06_attr_report_rate.dattr.attr,
349 NULL
350};
351
352static const struct attribute_group edt_ft5x06_attr_group = {
353 .attrs = edt_ft5x06_attrs,
354};
355
356#ifdef CONFIG_DEBUG_FS
357static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata)
358{
359 struct i2c_client *client = tsdata->client;
360 int retries = EDT_SWITCH_MODE_RETRIES;
361 int ret;
362 int error;
363
364 disable_irq(client->irq);
365
366 if (!tsdata->raw_buffer) {
367 tsdata->raw_bufsize = tsdata->num_x * tsdata->num_y *
368 sizeof(u16);
369 tsdata->raw_buffer = kzalloc(tsdata->raw_bufsize, GFP_KERNEL);
370 if (!tsdata->raw_buffer) {
371 error = -ENOMEM;
372 goto err_out;
373 }
374 }
375
376 /* mode register is 0x3c when in the work mode */
377 error = edt_ft5x06_register_write(tsdata, WORK_REGISTER_OPMODE, 0x03);
378 if (error) {
379 dev_err(&client->dev,
380 "failed to switch to factory mode, error %d\n", error);
381 goto err_out;
382 }
383
384 tsdata->factory_mode = true;
385 do {
386 mdelay(EDT_SWITCH_MODE_DELAY);
387 /* mode register is 0x01 when in factory mode */
388 ret = edt_ft5x06_register_read(tsdata, FACTORY_REGISTER_OPMODE);
389 if (ret == 0x03)
390 break;
391 } while (--retries > 0);
392
393 if (retries == 0) {
394 dev_err(&client->dev, "not in factory mode after %dms.\n",
395 EDT_SWITCH_MODE_RETRIES * EDT_SWITCH_MODE_DELAY);
396 error = -EIO;
397 goto err_out;
398 }
399
400 return 0;
401
402err_out:
403 kfree(tsdata->raw_buffer);
404 tsdata->raw_buffer = NULL;
405 tsdata->factory_mode = false;
406 enable_irq(client->irq);
407
408 return error;
409}
410
411static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata)
412{
413 struct i2c_client *client = tsdata->client;
414 int retries = EDT_SWITCH_MODE_RETRIES;
415 int ret;
416 int error;
417
418 /* mode register is 0x01 when in the factory mode */
419 error = edt_ft5x06_register_write(tsdata, FACTORY_REGISTER_OPMODE, 0x1);
420 if (error) {
421 dev_err(&client->dev,
422 "failed to switch to work mode, error: %d\n", error);
423 return error;
424 }
425
426 tsdata->factory_mode = false;
427
428 do {
429 mdelay(EDT_SWITCH_MODE_DELAY);
430 /* mode register is 0x01 when in factory mode */
431 ret = edt_ft5x06_register_read(tsdata, WORK_REGISTER_OPMODE);
432 if (ret == 0x01)
433 break;
434 } while (--retries > 0);
435
436 if (retries == 0) {
437 dev_err(&client->dev, "not in work mode after %dms.\n",
438 EDT_SWITCH_MODE_RETRIES * EDT_SWITCH_MODE_DELAY);
439 tsdata->factory_mode = true;
440 return -EIO;
441 }
442
443 if (tsdata->raw_buffer)
444 kfree(tsdata->raw_buffer);
445 tsdata->raw_buffer = NULL;
446
447 /* restore parameters */
448 edt_ft5x06_register_write(tsdata, WORK_REGISTER_THRESHOLD,
449 tsdata->threshold);
450 edt_ft5x06_register_write(tsdata, WORK_REGISTER_GAIN,
451 tsdata->gain);
452 edt_ft5x06_register_write(tsdata, WORK_REGISTER_OFFSET,
453 tsdata->offset);
454 edt_ft5x06_register_write(tsdata, WORK_REGISTER_REPORT_RATE,
455 tsdata->report_rate);
456
457 enable_irq(client->irq);
458
459 return 0;
460}
461
462static int edt_ft5x06_debugfs_mode_get(void *data, u64 *mode)
463{
464 struct edt_ft5x06_ts_data *tsdata = data;
465
466 *mode = tsdata->factory_mode;
467
468 return 0;
469};
470
471static int edt_ft5x06_debugfs_mode_set(void *data, u64 mode)
472{
473 struct edt_ft5x06_ts_data *tsdata = data;
474 int retval = 0;
475
476 if (mode > 1)
477 return -ERANGE;
478
479 mutex_lock(&tsdata->mutex);
480
481 if (mode != tsdata->factory_mode) {
482 retval = mode ? edt_ft5x06_factory_mode(tsdata) :
483 edt_ft5x06_work_mode(tsdata);
484 }
485
486 mutex_unlock(&tsdata->mutex);
487
488 return retval;
489};
490
491DEFINE_SIMPLE_ATTRIBUTE(debugfs_mode_fops, edt_ft5x06_debugfs_mode_get,
492 edt_ft5x06_debugfs_mode_set, "%llu\n");
493
494static int edt_ft5x06_debugfs_raw_data_open(struct inode *inode,
495 struct file *file)
496{
497 file->private_data = inode->i_private;
498
499 return 0;
500}
501
502static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file,
503 char __user *buf, size_t count, loff_t *off)
504{
505 struct edt_ft5x06_ts_data *tsdata = file->private_data;
506 struct i2c_client *client = tsdata->client;
507 int retries = EDT_RAW_DATA_RETRIES;
508 int val, i, error;
509 size_t read = 0;
510 int colbytes;
511 char wrbuf[3];
512 u8 *rdbuf;
513
514 if (*off < 0 || *off >= tsdata->raw_bufsize)
515 return 0;
516
517 mutex_lock(&tsdata->mutex);
518
519 if (!tsdata->factory_mode || !tsdata->raw_buffer) {
520 error = -EIO;
521 goto out;
522 }
523
524 error = edt_ft5x06_register_write(tsdata, 0x08, 0x01);
525 if (error) {
526 dev_dbg(&client->dev,
527 "failed to write 0x08 register, error %d\n", error);
528 goto out;
529 }
530
531 do {
532 msleep(EDT_RAW_DATA_DELAY);
533 val = edt_ft5x06_register_read(tsdata, 0x08);
534 if (val < 1)
535 break;
536 } while (--retries > 0);
537
538 if (val < 0) {
539 error = val;
540 dev_dbg(&client->dev,
541 "failed to read 0x08 register, error %d\n", error);
542 goto out;
543 }
544
545 if (retries == 0) {
546 dev_dbg(&client->dev,
547 "timed out waiting for register to settle\n");
548 error = -ETIMEDOUT;
549 goto out;
550 }
551
552 rdbuf = tsdata->raw_buffer;
553 colbytes = tsdata->num_y * sizeof(u16);
554
555 wrbuf[0] = 0xf5;
556 wrbuf[1] = 0x0e;
557 for (i = 0; i < tsdata->num_x; i++) {
558 wrbuf[2] = i; /* column index */
559 error = edt_ft5x06_ts_readwrite(tsdata->client,
560 sizeof(wrbuf), wrbuf,
561 colbytes, rdbuf);
562 if (error)
563 goto out;
564
565 rdbuf += colbytes;
566 }
567
568 read = min_t(size_t, count, tsdata->raw_bufsize - *off);
569 error = copy_to_user(buf, tsdata->raw_buffer + *off, read);
570 if (!error)
571 *off += read;
572out:
573 mutex_unlock(&tsdata->mutex);
574 return error ?: read;
575};
576
577
578static const struct file_operations debugfs_raw_data_fops = {
579 .open = edt_ft5x06_debugfs_raw_data_open,
580 .read = edt_ft5x06_debugfs_raw_data_read,
581};
582
583static void __devinit
584edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata,
585 const char *debugfs_name)
586{
587 tsdata->debug_dir = debugfs_create_dir(debugfs_name, NULL);
588 if (!tsdata->debug_dir)
589 return;
590
591 debugfs_create_u16("num_x", S_IRUSR, tsdata->debug_dir, &tsdata->num_x);
592 debugfs_create_u16("num_y", S_IRUSR, tsdata->debug_dir, &tsdata->num_y);
593
594 debugfs_create_file("mode", S_IRUSR | S_IWUSR,
595 tsdata->debug_dir, tsdata, &debugfs_mode_fops);
596 debugfs_create_file("raw_data", S_IRUSR,
597 tsdata->debug_dir, tsdata, &debugfs_raw_data_fops);
598}
599
600static void __devexit
601edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
602{
603 if (tsdata->debug_dir)
604 debugfs_remove_recursive(tsdata->debug_dir);
605}
606
607#else
608
609static inline void
610edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata,
611 const char *debugfs_name)
612{
613}
614
615static inline void
616edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata)
617{
618}
619
620#endif /* CONFIG_DEBUGFS */
621
622
623
624static int __devinit edt_ft5x06_ts_reset(struct i2c_client *client,
625 int reset_pin)
626{
627 int error;
628
629 if (gpio_is_valid(reset_pin)) {
630 /* this pulls reset down, enabling the low active reset */
631 error = gpio_request_one(reset_pin, GPIOF_OUT_INIT_LOW,
632 "edt-ft5x06 reset");
633 if (error) {
634 dev_err(&client->dev,
635 "Failed to request GPIO %d as reset pin, error %d\n",
636 reset_pin, error);
637 return error;
638 }
639
640 mdelay(50);
641 gpio_set_value(reset_pin, 1);
642 mdelay(100);
643 }
644
645 return 0;
646}
647
648static int __devinit edt_ft5x06_ts_identify(struct i2c_client *client,
649 char *model_name,
650 char *fw_version)
651{
652 u8 rdbuf[EDT_NAME_LEN];
653 char *p;
654 int error;
655
656 error = edt_ft5x06_ts_readwrite(client, 1, "\xbb",
657 EDT_NAME_LEN - 1, rdbuf);
658 if (error)
659 return error;
660
661 /* remove last '$' end marker */
662 rdbuf[EDT_NAME_LEN - 1] = '\0';
663 if (rdbuf[EDT_NAME_LEN - 2] == '$')
664 rdbuf[EDT_NAME_LEN - 2] = '\0';
665
666 /* look for Model/Version separator */
667 p = strchr(rdbuf, '*');
668 if (p)
669 *p++ = '\0';
670
671 strlcpy(model_name, rdbuf + 1, EDT_NAME_LEN);
672 strlcpy(fw_version, p ? p : "", EDT_NAME_LEN);
673
674 return 0;
675}
676
677#define EDT_ATTR_CHECKSET(name, reg) \
678 if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \
679 pdata->name <= edt_ft5x06_attr_##name.limit_high) \
680 edt_ft5x06_register_write(tsdata, reg, pdata->name)
681
682static void __devinit
683edt_ft5x06_ts_get_defaults(struct edt_ft5x06_ts_data *tsdata,
684 const struct edt_ft5x06_platform_data *pdata)
685{
686 if (!pdata->use_parameters)
687 return;
688
689 /* pick up defaults from the platform data */
690 EDT_ATTR_CHECKSET(threshold, WORK_REGISTER_THRESHOLD);
691 EDT_ATTR_CHECKSET(gain, WORK_REGISTER_GAIN);
692 EDT_ATTR_CHECKSET(offset, WORK_REGISTER_OFFSET);
693 EDT_ATTR_CHECKSET(report_rate, WORK_REGISTER_REPORT_RATE);
694}
695
696static void __devinit
697edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata)
698{
699 tsdata->threshold = edt_ft5x06_register_read(tsdata,
700 WORK_REGISTER_THRESHOLD);
701 tsdata->gain = edt_ft5x06_register_read(tsdata, WORK_REGISTER_GAIN);
702 tsdata->offset = edt_ft5x06_register_read(tsdata, WORK_REGISTER_OFFSET);
703 tsdata->report_rate = edt_ft5x06_register_read(tsdata,
704 WORK_REGISTER_REPORT_RATE);
705 tsdata->num_x = edt_ft5x06_register_read(tsdata, WORK_REGISTER_NUM_X);
706 tsdata->num_y = edt_ft5x06_register_read(tsdata, WORK_REGISTER_NUM_Y);
707}
708
709static int __devinit edt_ft5x06_ts_probe(struct i2c_client *client,
710 const struct i2c_device_id *id)
711{
712 const struct edt_ft5x06_platform_data *pdata =
713 client->dev.platform_data;
714 struct edt_ft5x06_ts_data *tsdata;
715 struct input_dev *input;
716 int error;
717 char fw_version[EDT_NAME_LEN];
718
719 dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n");
720
721 if (!pdata) {
722 dev_err(&client->dev, "no platform data?\n");
723 return -EINVAL;
724 }
725
726 error = edt_ft5x06_ts_reset(client, pdata->reset_pin);
727 if (error)
728 return error;
729
730 if (gpio_is_valid(pdata->irq_pin)) {
731 error = gpio_request_one(pdata->irq_pin,
732 GPIOF_IN, "edt-ft5x06 irq");
733 if (error) {
734 dev_err(&client->dev,
735 "Failed to request GPIO %d, error %d\n",
736 pdata->irq_pin, error);
737 return error;
738 }
739 }
740
741 tsdata = kzalloc(sizeof(*tsdata), GFP_KERNEL);
742 input = input_allocate_device();
743 if (!tsdata || !input) {
744 dev_err(&client->dev, "failed to allocate driver data.\n");
745 error = -ENOMEM;
746 goto err_free_mem;
747 }
748
749 mutex_init(&tsdata->mutex);
750 tsdata->client = client;
751 tsdata->input = input;
752 tsdata->factory_mode = false;
753
754 error = edt_ft5x06_ts_identify(client, tsdata->name, fw_version);
755 if (error) {
756 dev_err(&client->dev, "touchscreen probe failed\n");
757 goto err_free_mem;
758 }
759
760 edt_ft5x06_ts_get_defaults(tsdata, pdata);
761 edt_ft5x06_ts_get_parameters(tsdata);
762
763 dev_dbg(&client->dev,
764 "Model \"%s\", Rev. \"%s\", %dx%d sensors\n",
765 tsdata->name, fw_version, tsdata->num_x, tsdata->num_y);
766
767 input->name = tsdata->name;
768 input->id.bustype = BUS_I2C;
769 input->dev.parent = &client->dev;
770
771 __set_bit(EV_SYN, input->evbit);
772 __set_bit(EV_KEY, input->evbit);
773 __set_bit(EV_ABS, input->evbit);
774 __set_bit(BTN_TOUCH, input->keybit);
775 input_set_abs_params(input, ABS_X, 0, tsdata->num_x * 64 - 1, 0, 0);
776 input_set_abs_params(input, ABS_Y, 0, tsdata->num_y * 64 - 1, 0, 0);
777 input_set_abs_params(input, ABS_MT_POSITION_X,
778 0, tsdata->num_x * 64 - 1, 0, 0);
779 input_set_abs_params(input, ABS_MT_POSITION_Y,
780 0, tsdata->num_y * 64 - 1, 0, 0);
781 error = input_mt_init_slots(input, MAX_SUPPORT_POINTS);
782 if (error) {
783 dev_err(&client->dev, "Unable to init MT slots.\n");
784 goto err_free_mem;
785 }
786
787 input_set_drvdata(input, tsdata);
788 i2c_set_clientdata(client, tsdata);
789
790 error = request_threaded_irq(client->irq, NULL, edt_ft5x06_ts_isr,
791 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
792 client->name, tsdata);
793 if (error) {
794 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
795 goto err_free_mem;
796 }
797
798 error = sysfs_create_group(&client->dev.kobj, &edt_ft5x06_attr_group);
799 if (error)
800 goto err_free_irq;
801
802 error = input_register_device(input);
803 if (error)
804 goto err_remove_attrs;
805
806 edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev));
807 device_init_wakeup(&client->dev, 1);
808
809 dev_dbg(&client->dev,
810 "EDT FT5x06 initialized: IRQ pin %d, Reset pin %d.\n",
811 pdata->irq_pin, pdata->reset_pin);
812
813 return 0;
814
815err_remove_attrs:
816 sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
817err_free_irq:
818 free_irq(client->irq, tsdata);
819err_free_mem:
820 input_free_device(input);
821 kfree(tsdata);
822
823 if (gpio_is_valid(pdata->irq_pin))
824 gpio_free(pdata->irq_pin);
825
826 return error;
827}
828
829static int __devexit edt_ft5x06_ts_remove(struct i2c_client *client)
830{
831 const struct edt_ft5x06_platform_data *pdata =
832 dev_get_platdata(&client->dev);
833 struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
834
835 edt_ft5x06_ts_teardown_debugfs(tsdata);
836 sysfs_remove_group(&client->dev.kobj, &edt_ft5x06_attr_group);
837
838 free_irq(client->irq, tsdata);
839 input_unregister_device(tsdata->input);
840
841 if (gpio_is_valid(pdata->irq_pin))
842 gpio_free(pdata->irq_pin);
843 if (gpio_is_valid(pdata->reset_pin))
844 gpio_free(pdata->reset_pin);
845
846 kfree(tsdata->raw_buffer);
847 kfree(tsdata);
848
849 return 0;
850}
851
852#ifdef CONFIG_PM_SLEEP
853static int edt_ft5x06_ts_suspend(struct device *dev)
854{
855 struct i2c_client *client = to_i2c_client(dev);
856
857 if (device_may_wakeup(dev))
858 enable_irq_wake(client->irq);
859
860 return 0;
861}
862
863static int edt_ft5x06_ts_resume(struct device *dev)
864{
865 struct i2c_client *client = to_i2c_client(dev);
866
867 if (device_may_wakeup(dev))
868 disable_irq_wake(client->irq);
869
870 return 0;
871}
872#endif
873
874static SIMPLE_DEV_PM_OPS(edt_ft5x06_ts_pm_ops,
875 edt_ft5x06_ts_suspend, edt_ft5x06_ts_resume);
876
877static const struct i2c_device_id edt_ft5x06_ts_id[] = {
878 { "edt-ft5x06", 0 },
879 { }
880};
881MODULE_DEVICE_TABLE(i2c, edt_ft5x06_ts_id);
882
883static struct i2c_driver edt_ft5x06_ts_driver = {
884 .driver = {
885 .owner = THIS_MODULE,
886 .name = "edt_ft5x06",
887 .pm = &edt_ft5x06_ts_pm_ops,
888 },
889 .id_table = edt_ft5x06_ts_id,
890 .probe = edt_ft5x06_ts_probe,
891 .remove = __devexit_p(edt_ft5x06_ts_remove),
892};
893
894module_i2c_driver(edt_ft5x06_ts_driver);
895
896MODULE_AUTHOR("Simon Budig <simon.budig@kernelconcepts.de>");
897MODULE_DESCRIPTION("EDT FT5x06 I2C Touchscreen Driver");
898MODULE_LICENSE("GPL");
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index 10f122a3a856..1eee45b69b71 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -260,15 +260,6 @@ config DM_DEBUG_BLOCK_STACK_TRACING
260 260
261 If unsure, say N. 261 If unsure, say N.
262 262
263config DM_DEBUG_SPACE_MAPS
264 boolean "Extra validation for thin provisioning space maps"
265 depends on DM_THIN_PROVISIONING
266 ---help---
267 Enable this for messages that may help debug problems with the
268 space maps used by thin provisioning.
269
270 If unsure, say N.
271
272config DM_MIRROR 263config DM_MIRROR
273 tristate "Mirror target" 264 tristate "Mirror target"
274 depends on BLK_DEV_DM 265 depends on BLK_DEV_DM
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 3f06df59fd82..664743d6a6cd 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -42,21 +42,21 @@ struct convert_context {
42 unsigned int offset_out; 42 unsigned int offset_out;
43 unsigned int idx_in; 43 unsigned int idx_in;
44 unsigned int idx_out; 44 unsigned int idx_out;
45 sector_t sector; 45 sector_t cc_sector;
46 atomic_t pending; 46 atomic_t cc_pending;
47}; 47};
48 48
49/* 49/*
50 * per bio private data 50 * per bio private data
51 */ 51 */
52struct dm_crypt_io { 52struct dm_crypt_io {
53 struct dm_target *target; 53 struct crypt_config *cc;
54 struct bio *base_bio; 54 struct bio *base_bio;
55 struct work_struct work; 55 struct work_struct work;
56 56
57 struct convert_context ctx; 57 struct convert_context ctx;
58 58
59 atomic_t pending; 59 atomic_t io_pending;
60 int error; 60 int error;
61 sector_t sector; 61 sector_t sector;
62 struct dm_crypt_io *base_io; 62 struct dm_crypt_io *base_io;
@@ -109,9 +109,6 @@ enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID };
109 */ 109 */
110struct crypt_cpu { 110struct crypt_cpu {
111 struct ablkcipher_request *req; 111 struct ablkcipher_request *req;
112 /* ESSIV: struct crypto_cipher *essiv_tfm */
113 void *iv_private;
114 struct crypto_ablkcipher *tfms[0];
115}; 112};
116 113
117/* 114/*
@@ -151,6 +148,10 @@ struct crypt_config {
151 * per_cpu_ptr() only. 148 * per_cpu_ptr() only.
152 */ 149 */
153 struct crypt_cpu __percpu *cpu; 150 struct crypt_cpu __percpu *cpu;
151
152 /* ESSIV: struct crypto_cipher *essiv_tfm */
153 void *iv_private;
154 struct crypto_ablkcipher **tfms;
154 unsigned tfms_count; 155 unsigned tfms_count;
155 156
156 /* 157 /*
@@ -193,7 +194,7 @@ static struct crypt_cpu *this_crypt_config(struct crypt_config *cc)
193 */ 194 */
194static struct crypto_ablkcipher *any_tfm(struct crypt_config *cc) 195static struct crypto_ablkcipher *any_tfm(struct crypt_config *cc)
195{ 196{
196 return __this_cpu_ptr(cc->cpu)->tfms[0]; 197 return cc->tfms[0];
197} 198}
198 199
199/* 200/*
@@ -258,7 +259,7 @@ static int crypt_iv_essiv_init(struct crypt_config *cc)
258 struct hash_desc desc; 259 struct hash_desc desc;
259 struct scatterlist sg; 260 struct scatterlist sg;
260 struct crypto_cipher *essiv_tfm; 261 struct crypto_cipher *essiv_tfm;
261 int err, cpu; 262 int err;
262 263
263 sg_init_one(&sg, cc->key, cc->key_size); 264 sg_init_one(&sg, cc->key, cc->key_size);
264 desc.tfm = essiv->hash_tfm; 265 desc.tfm = essiv->hash_tfm;
@@ -268,14 +269,12 @@ static int crypt_iv_essiv_init(struct crypt_config *cc)
268 if (err) 269 if (err)
269 return err; 270 return err;
270 271
271 for_each_possible_cpu(cpu) { 272 essiv_tfm = cc->iv_private;
272 essiv_tfm = per_cpu_ptr(cc->cpu, cpu)->iv_private,
273 273
274 err = crypto_cipher_setkey(essiv_tfm, essiv->salt, 274 err = crypto_cipher_setkey(essiv_tfm, essiv->salt,
275 crypto_hash_digestsize(essiv->hash_tfm)); 275 crypto_hash_digestsize(essiv->hash_tfm));
276 if (err) 276 if (err)
277 return err; 277 return err;
278 }
279 278
280 return 0; 279 return 0;
281} 280}
@@ -286,16 +285,14 @@ static int crypt_iv_essiv_wipe(struct crypt_config *cc)
286 struct iv_essiv_private *essiv = &cc->iv_gen_private.essiv; 285 struct iv_essiv_private *essiv = &cc->iv_gen_private.essiv;
287 unsigned salt_size = crypto_hash_digestsize(essiv->hash_tfm); 286 unsigned salt_size = crypto_hash_digestsize(essiv->hash_tfm);
288 struct crypto_cipher *essiv_tfm; 287 struct crypto_cipher *essiv_tfm;
289 int cpu, r, err = 0; 288 int r, err = 0;
290 289
291 memset(essiv->salt, 0, salt_size); 290 memset(essiv->salt, 0, salt_size);
292 291
293 for_each_possible_cpu(cpu) { 292 essiv_tfm = cc->iv_private;
294 essiv_tfm = per_cpu_ptr(cc->cpu, cpu)->iv_private; 293 r = crypto_cipher_setkey(essiv_tfm, essiv->salt, salt_size);
295 r = crypto_cipher_setkey(essiv_tfm, essiv->salt, salt_size); 294 if (r)
296 if (r) 295 err = r;
297 err = r;
298 }
299 296
300 return err; 297 return err;
301} 298}
@@ -335,8 +332,6 @@ static struct crypto_cipher *setup_essiv_cpu(struct crypt_config *cc,
335 332
336static void crypt_iv_essiv_dtr(struct crypt_config *cc) 333static void crypt_iv_essiv_dtr(struct crypt_config *cc)
337{ 334{
338 int cpu;
339 struct crypt_cpu *cpu_cc;
340 struct crypto_cipher *essiv_tfm; 335 struct crypto_cipher *essiv_tfm;
341 struct iv_essiv_private *essiv = &cc->iv_gen_private.essiv; 336 struct iv_essiv_private *essiv = &cc->iv_gen_private.essiv;
342 337
@@ -346,15 +341,12 @@ static void crypt_iv_essiv_dtr(struct crypt_config *cc)
346 kzfree(essiv->salt); 341 kzfree(essiv->salt);
347 essiv->salt = NULL; 342 essiv->salt = NULL;
348 343
349 for_each_possible_cpu(cpu) { 344 essiv_tfm = cc->iv_private;
350 cpu_cc = per_cpu_ptr(cc->cpu, cpu);
351 essiv_tfm = cpu_cc->iv_private;
352 345
353 if (essiv_tfm) 346 if (essiv_tfm)
354 crypto_free_cipher(essiv_tfm); 347 crypto_free_cipher(essiv_tfm);
355 348
356 cpu_cc->iv_private = NULL; 349 cc->iv_private = NULL;
357 }
358} 350}
359 351
360static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, 352static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
@@ -363,7 +355,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
363 struct crypto_cipher *essiv_tfm = NULL; 355 struct crypto_cipher *essiv_tfm = NULL;
364 struct crypto_hash *hash_tfm = NULL; 356 struct crypto_hash *hash_tfm = NULL;
365 u8 *salt = NULL; 357 u8 *salt = NULL;
366 int err, cpu; 358 int err;
367 359
368 if (!opts) { 360 if (!opts) {
369 ti->error = "Digest algorithm missing for ESSIV mode"; 361 ti->error = "Digest algorithm missing for ESSIV mode";
@@ -388,15 +380,13 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
388 cc->iv_gen_private.essiv.salt = salt; 380 cc->iv_gen_private.essiv.salt = salt;
389 cc->iv_gen_private.essiv.hash_tfm = hash_tfm; 381 cc->iv_gen_private.essiv.hash_tfm = hash_tfm;
390 382
391 for_each_possible_cpu(cpu) { 383 essiv_tfm = setup_essiv_cpu(cc, ti, salt,
392 essiv_tfm = setup_essiv_cpu(cc, ti, salt, 384 crypto_hash_digestsize(hash_tfm));
393 crypto_hash_digestsize(hash_tfm)); 385 if (IS_ERR(essiv_tfm)) {
394 if (IS_ERR(essiv_tfm)) { 386 crypt_iv_essiv_dtr(cc);
395 crypt_iv_essiv_dtr(cc); 387 return PTR_ERR(essiv_tfm);
396 return PTR_ERR(essiv_tfm);
397 }
398 per_cpu_ptr(cc->cpu, cpu)->iv_private = essiv_tfm;
399 } 388 }
389 cc->iv_private = essiv_tfm;
400 390
401 return 0; 391 return 0;
402 392
@@ -410,7 +400,7 @@ bad:
410static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, 400static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv,
411 struct dm_crypt_request *dmreq) 401 struct dm_crypt_request *dmreq)
412{ 402{
413 struct crypto_cipher *essiv_tfm = this_crypt_config(cc)->iv_private; 403 struct crypto_cipher *essiv_tfm = cc->iv_private;
414 404
415 memset(iv, 0, cc->iv_size); 405 memset(iv, 0, cc->iv_size);
416 *(__le64 *)iv = cpu_to_le64(dmreq->iv_sector); 406 *(__le64 *)iv = cpu_to_le64(dmreq->iv_sector);
@@ -664,7 +654,7 @@ static void crypt_convert_init(struct crypt_config *cc,
664 ctx->offset_out = 0; 654 ctx->offset_out = 0;
665 ctx->idx_in = bio_in ? bio_in->bi_idx : 0; 655 ctx->idx_in = bio_in ? bio_in->bi_idx : 0;
666 ctx->idx_out = bio_out ? bio_out->bi_idx : 0; 656 ctx->idx_out = bio_out ? bio_out->bi_idx : 0;
667 ctx->sector = sector + cc->iv_offset; 657 ctx->cc_sector = sector + cc->iv_offset;
668 init_completion(&ctx->restart); 658 init_completion(&ctx->restart);
669} 659}
670 660
@@ -695,12 +685,12 @@ static int crypt_convert_block(struct crypt_config *cc,
695 struct bio_vec *bv_out = bio_iovec_idx(ctx->bio_out, ctx->idx_out); 685 struct bio_vec *bv_out = bio_iovec_idx(ctx->bio_out, ctx->idx_out);
696 struct dm_crypt_request *dmreq; 686 struct dm_crypt_request *dmreq;
697 u8 *iv; 687 u8 *iv;
698 int r = 0; 688 int r;
699 689
700 dmreq = dmreq_of_req(cc, req); 690 dmreq = dmreq_of_req(cc, req);
701 iv = iv_of_dmreq(cc, dmreq); 691 iv = iv_of_dmreq(cc, dmreq);
702 692
703 dmreq->iv_sector = ctx->sector; 693 dmreq->iv_sector = ctx->cc_sector;
704 dmreq->ctx = ctx; 694 dmreq->ctx = ctx;
705 sg_init_table(&dmreq->sg_in, 1); 695 sg_init_table(&dmreq->sg_in, 1);
706 sg_set_page(&dmreq->sg_in, bv_in->bv_page, 1 << SECTOR_SHIFT, 696 sg_set_page(&dmreq->sg_in, bv_in->bv_page, 1 << SECTOR_SHIFT,
@@ -749,12 +739,12 @@ static void crypt_alloc_req(struct crypt_config *cc,
749 struct convert_context *ctx) 739 struct convert_context *ctx)
750{ 740{
751 struct crypt_cpu *this_cc = this_crypt_config(cc); 741 struct crypt_cpu *this_cc = this_crypt_config(cc);
752 unsigned key_index = ctx->sector & (cc->tfms_count - 1); 742 unsigned key_index = ctx->cc_sector & (cc->tfms_count - 1);
753 743
754 if (!this_cc->req) 744 if (!this_cc->req)
755 this_cc->req = mempool_alloc(cc->req_pool, GFP_NOIO); 745 this_cc->req = mempool_alloc(cc->req_pool, GFP_NOIO);
756 746
757 ablkcipher_request_set_tfm(this_cc->req, this_cc->tfms[key_index]); 747 ablkcipher_request_set_tfm(this_cc->req, cc->tfms[key_index]);
758 ablkcipher_request_set_callback(this_cc->req, 748 ablkcipher_request_set_callback(this_cc->req,
759 CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, 749 CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP,
760 kcryptd_async_done, dmreq_of_req(cc, this_cc->req)); 750 kcryptd_async_done, dmreq_of_req(cc, this_cc->req));
@@ -769,14 +759,14 @@ static int crypt_convert(struct crypt_config *cc,
769 struct crypt_cpu *this_cc = this_crypt_config(cc); 759 struct crypt_cpu *this_cc = this_crypt_config(cc);
770 int r; 760 int r;
771 761
772 atomic_set(&ctx->pending, 1); 762 atomic_set(&ctx->cc_pending, 1);
773 763
774 while(ctx->idx_in < ctx->bio_in->bi_vcnt && 764 while(ctx->idx_in < ctx->bio_in->bi_vcnt &&
775 ctx->idx_out < ctx->bio_out->bi_vcnt) { 765 ctx->idx_out < ctx->bio_out->bi_vcnt) {
776 766
777 crypt_alloc_req(cc, ctx); 767 crypt_alloc_req(cc, ctx);
778 768
779 atomic_inc(&ctx->pending); 769 atomic_inc(&ctx->cc_pending);
780 770
781 r = crypt_convert_block(cc, ctx, this_cc->req); 771 r = crypt_convert_block(cc, ctx, this_cc->req);
782 772
@@ -788,19 +778,19 @@ static int crypt_convert(struct crypt_config *cc,
788 /* fall through*/ 778 /* fall through*/
789 case -EINPROGRESS: 779 case -EINPROGRESS:
790 this_cc->req = NULL; 780 this_cc->req = NULL;
791 ctx->sector++; 781 ctx->cc_sector++;
792 continue; 782 continue;
793 783
794 /* sync */ 784 /* sync */
795 case 0: 785 case 0:
796 atomic_dec(&ctx->pending); 786 atomic_dec(&ctx->cc_pending);
797 ctx->sector++; 787 ctx->cc_sector++;
798 cond_resched(); 788 cond_resched();
799 continue; 789 continue;
800 790
801 /* error */ 791 /* error */
802 default: 792 default:
803 atomic_dec(&ctx->pending); 793 atomic_dec(&ctx->cc_pending);
804 return r; 794 return r;
805 } 795 }
806 } 796 }
@@ -811,7 +801,7 @@ static int crypt_convert(struct crypt_config *cc,
811static void dm_crypt_bio_destructor(struct bio *bio) 801static void dm_crypt_bio_destructor(struct bio *bio)
812{ 802{
813 struct dm_crypt_io *io = bio->bi_private; 803 struct dm_crypt_io *io = bio->bi_private;
814 struct crypt_config *cc = io->target->private; 804 struct crypt_config *cc = io->cc;
815 805
816 bio_free(bio, cc->bs); 806 bio_free(bio, cc->bs);
817} 807}
@@ -825,7 +815,7 @@ static void dm_crypt_bio_destructor(struct bio *bio)
825static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size, 815static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size,
826 unsigned *out_of_pages) 816 unsigned *out_of_pages)
827{ 817{
828 struct crypt_config *cc = io->target->private; 818 struct crypt_config *cc = io->cc;
829 struct bio *clone; 819 struct bio *clone;
830 unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 820 unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
831 gfp_t gfp_mask = GFP_NOIO | __GFP_HIGHMEM; 821 gfp_t gfp_mask = GFP_NOIO | __GFP_HIGHMEM;
@@ -884,26 +874,25 @@ static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone)
884 } 874 }
885} 875}
886 876
887static struct dm_crypt_io *crypt_io_alloc(struct dm_target *ti, 877static struct dm_crypt_io *crypt_io_alloc(struct crypt_config *cc,
888 struct bio *bio, sector_t sector) 878 struct bio *bio, sector_t sector)
889{ 879{
890 struct crypt_config *cc = ti->private;
891 struct dm_crypt_io *io; 880 struct dm_crypt_io *io;
892 881
893 io = mempool_alloc(cc->io_pool, GFP_NOIO); 882 io = mempool_alloc(cc->io_pool, GFP_NOIO);
894 io->target = ti; 883 io->cc = cc;
895 io->base_bio = bio; 884 io->base_bio = bio;
896 io->sector = sector; 885 io->sector = sector;
897 io->error = 0; 886 io->error = 0;
898 io->base_io = NULL; 887 io->base_io = NULL;
899 atomic_set(&io->pending, 0); 888 atomic_set(&io->io_pending, 0);
900 889
901 return io; 890 return io;
902} 891}
903 892
904static void crypt_inc_pending(struct dm_crypt_io *io) 893static void crypt_inc_pending(struct dm_crypt_io *io)
905{ 894{
906 atomic_inc(&io->pending); 895 atomic_inc(&io->io_pending);
907} 896}
908 897
909/* 898/*
@@ -913,12 +902,12 @@ static void crypt_inc_pending(struct dm_crypt_io *io)
913 */ 902 */
914static void crypt_dec_pending(struct dm_crypt_io *io) 903static void crypt_dec_pending(struct dm_crypt_io *io)
915{ 904{
916 struct crypt_config *cc = io->target->private; 905 struct crypt_config *cc = io->cc;
917 struct bio *base_bio = io->base_bio; 906 struct bio *base_bio = io->base_bio;
918 struct dm_crypt_io *base_io = io->base_io; 907 struct dm_crypt_io *base_io = io->base_io;
919 int error = io->error; 908 int error = io->error;
920 909
921 if (!atomic_dec_and_test(&io->pending)) 910 if (!atomic_dec_and_test(&io->io_pending))
922 return; 911 return;
923 912
924 mempool_free(io, cc->io_pool); 913 mempool_free(io, cc->io_pool);
@@ -952,7 +941,7 @@ static void crypt_dec_pending(struct dm_crypt_io *io)
952static void crypt_endio(struct bio *clone, int error) 941static void crypt_endio(struct bio *clone, int error)
953{ 942{
954 struct dm_crypt_io *io = clone->bi_private; 943 struct dm_crypt_io *io = clone->bi_private;
955 struct crypt_config *cc = io->target->private; 944 struct crypt_config *cc = io->cc;
956 unsigned rw = bio_data_dir(clone); 945 unsigned rw = bio_data_dir(clone);
957 946
958 if (unlikely(!bio_flagged(clone, BIO_UPTODATE) && !error)) 947 if (unlikely(!bio_flagged(clone, BIO_UPTODATE) && !error))
@@ -979,7 +968,7 @@ static void crypt_endio(struct bio *clone, int error)
979 968
980static void clone_init(struct dm_crypt_io *io, struct bio *clone) 969static void clone_init(struct dm_crypt_io *io, struct bio *clone)
981{ 970{
982 struct crypt_config *cc = io->target->private; 971 struct crypt_config *cc = io->cc;
983 972
984 clone->bi_private = io; 973 clone->bi_private = io;
985 clone->bi_end_io = crypt_endio; 974 clone->bi_end_io = crypt_endio;
@@ -990,7 +979,7 @@ static void clone_init(struct dm_crypt_io *io, struct bio *clone)
990 979
991static int kcryptd_io_read(struct dm_crypt_io *io, gfp_t gfp) 980static int kcryptd_io_read(struct dm_crypt_io *io, gfp_t gfp)
992{ 981{
993 struct crypt_config *cc = io->target->private; 982 struct crypt_config *cc = io->cc;
994 struct bio *base_bio = io->base_bio; 983 struct bio *base_bio = io->base_bio;
995 struct bio *clone; 984 struct bio *clone;
996 985
@@ -1038,7 +1027,7 @@ static void kcryptd_io(struct work_struct *work)
1038 1027
1039static void kcryptd_queue_io(struct dm_crypt_io *io) 1028static void kcryptd_queue_io(struct dm_crypt_io *io)
1040{ 1029{
1041 struct crypt_config *cc = io->target->private; 1030 struct crypt_config *cc = io->cc;
1042 1031
1043 INIT_WORK(&io->work, kcryptd_io); 1032 INIT_WORK(&io->work, kcryptd_io);
1044 queue_work(cc->io_queue, &io->work); 1033 queue_work(cc->io_queue, &io->work);
@@ -1047,7 +1036,7 @@ static void kcryptd_queue_io(struct dm_crypt_io *io)
1047static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io, int async) 1036static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io, int async)
1048{ 1037{
1049 struct bio *clone = io->ctx.bio_out; 1038 struct bio *clone = io->ctx.bio_out;
1050 struct crypt_config *cc = io->target->private; 1039 struct crypt_config *cc = io->cc;
1051 1040
1052 if (unlikely(io->error < 0)) { 1041 if (unlikely(io->error < 0)) {
1053 crypt_free_buffer_pages(cc, clone); 1042 crypt_free_buffer_pages(cc, clone);
@@ -1069,7 +1058,7 @@ static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io, int async)
1069 1058
1070static void kcryptd_crypt_write_convert(struct dm_crypt_io *io) 1059static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
1071{ 1060{
1072 struct crypt_config *cc = io->target->private; 1061 struct crypt_config *cc = io->cc;
1073 struct bio *clone; 1062 struct bio *clone;
1074 struct dm_crypt_io *new_io; 1063 struct dm_crypt_io *new_io;
1075 int crypt_finished; 1064 int crypt_finished;
@@ -1107,7 +1096,7 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
1107 if (r < 0) 1096 if (r < 0)
1108 io->error = -EIO; 1097 io->error = -EIO;
1109 1098
1110 crypt_finished = atomic_dec_and_test(&io->ctx.pending); 1099 crypt_finished = atomic_dec_and_test(&io->ctx.cc_pending);
1111 1100
1112 /* Encryption was already finished, submit io now */ 1101 /* Encryption was already finished, submit io now */
1113 if (crypt_finished) { 1102 if (crypt_finished) {
@@ -1135,7 +1124,7 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
1135 * between fragments, so switch to a new dm_crypt_io structure. 1124 * between fragments, so switch to a new dm_crypt_io structure.
1136 */ 1125 */
1137 if (unlikely(!crypt_finished && remaining)) { 1126 if (unlikely(!crypt_finished && remaining)) {
1138 new_io = crypt_io_alloc(io->target, io->base_bio, 1127 new_io = crypt_io_alloc(io->cc, io->base_bio,
1139 sector); 1128 sector);
1140 crypt_inc_pending(new_io); 1129 crypt_inc_pending(new_io);
1141 crypt_convert_init(cc, &new_io->ctx, NULL, 1130 crypt_convert_init(cc, &new_io->ctx, NULL,
@@ -1169,7 +1158,7 @@ static void kcryptd_crypt_read_done(struct dm_crypt_io *io)
1169 1158
1170static void kcryptd_crypt_read_convert(struct dm_crypt_io *io) 1159static void kcryptd_crypt_read_convert(struct dm_crypt_io *io)
1171{ 1160{
1172 struct crypt_config *cc = io->target->private; 1161 struct crypt_config *cc = io->cc;
1173 int r = 0; 1162 int r = 0;
1174 1163
1175 crypt_inc_pending(io); 1164 crypt_inc_pending(io);
@@ -1181,7 +1170,7 @@ static void kcryptd_crypt_read_convert(struct dm_crypt_io *io)
1181 if (r < 0) 1170 if (r < 0)
1182 io->error = -EIO; 1171 io->error = -EIO;
1183 1172
1184 if (atomic_dec_and_test(&io->ctx.pending)) 1173 if (atomic_dec_and_test(&io->ctx.cc_pending))
1185 kcryptd_crypt_read_done(io); 1174 kcryptd_crypt_read_done(io);
1186 1175
1187 crypt_dec_pending(io); 1176 crypt_dec_pending(io);
@@ -1193,7 +1182,7 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
1193 struct dm_crypt_request *dmreq = async_req->data; 1182 struct dm_crypt_request *dmreq = async_req->data;
1194 struct convert_context *ctx = dmreq->ctx; 1183 struct convert_context *ctx = dmreq->ctx;
1195 struct dm_crypt_io *io = container_of(ctx, struct dm_crypt_io, ctx); 1184 struct dm_crypt_io *io = container_of(ctx, struct dm_crypt_io, ctx);
1196 struct crypt_config *cc = io->target->private; 1185 struct crypt_config *cc = io->cc;
1197 1186
1198 if (error == -EINPROGRESS) { 1187 if (error == -EINPROGRESS) {
1199 complete(&ctx->restart); 1188 complete(&ctx->restart);
@@ -1208,7 +1197,7 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
1208 1197
1209 mempool_free(req_of_dmreq(cc, dmreq), cc->req_pool); 1198 mempool_free(req_of_dmreq(cc, dmreq), cc->req_pool);
1210 1199
1211 if (!atomic_dec_and_test(&ctx->pending)) 1200 if (!atomic_dec_and_test(&ctx->cc_pending))
1212 return; 1201 return;
1213 1202
1214 if (bio_data_dir(io->base_bio) == READ) 1203 if (bio_data_dir(io->base_bio) == READ)
@@ -1229,7 +1218,7 @@ static void kcryptd_crypt(struct work_struct *work)
1229 1218
1230static void kcryptd_queue_crypt(struct dm_crypt_io *io) 1219static void kcryptd_queue_crypt(struct dm_crypt_io *io)
1231{ 1220{
1232 struct crypt_config *cc = io->target->private; 1221 struct crypt_config *cc = io->cc;
1233 1222
1234 INIT_WORK(&io->work, kcryptd_crypt); 1223 INIT_WORK(&io->work, kcryptd_crypt);
1235 queue_work(cc->crypt_queue, &io->work); 1224 queue_work(cc->crypt_queue, &io->work);
@@ -1241,7 +1230,6 @@ static void kcryptd_queue_crypt(struct dm_crypt_io *io)
1241static int crypt_decode_key(u8 *key, char *hex, unsigned int size) 1230static int crypt_decode_key(u8 *key, char *hex, unsigned int size)
1242{ 1231{
1243 char buffer[3]; 1232 char buffer[3];
1244 char *endp;
1245 unsigned int i; 1233 unsigned int i;
1246 1234
1247 buffer[2] = '\0'; 1235 buffer[2] = '\0';
@@ -1250,9 +1238,7 @@ static int crypt_decode_key(u8 *key, char *hex, unsigned int size)
1250 buffer[0] = *hex++; 1238 buffer[0] = *hex++;
1251 buffer[1] = *hex++; 1239 buffer[1] = *hex++;
1252 1240
1253 key[i] = (u8)simple_strtoul(buffer, &endp, 16); 1241 if (kstrtou8(buffer, 16, &key[i]))
1254
1255 if (endp != &buffer[2])
1256 return -EINVAL; 1242 return -EINVAL;
1257 } 1243 }
1258 1244
@@ -1276,29 +1262,38 @@ static void crypt_encode_key(char *hex, u8 *key, unsigned int size)
1276 } 1262 }
1277} 1263}
1278 1264
1279static void crypt_free_tfms(struct crypt_config *cc, int cpu) 1265static void crypt_free_tfms(struct crypt_config *cc)
1280{ 1266{
1281 struct crypt_cpu *cpu_cc = per_cpu_ptr(cc->cpu, cpu);
1282 unsigned i; 1267 unsigned i;
1283 1268
1269 if (!cc->tfms)
1270 return;
1271
1284 for (i = 0; i < cc->tfms_count; i++) 1272 for (i = 0; i < cc->tfms_count; i++)
1285 if (cpu_cc->tfms[i] && !IS_ERR(cpu_cc->tfms[i])) { 1273 if (cc->tfms[i] && !IS_ERR(cc->tfms[i])) {
1286 crypto_free_ablkcipher(cpu_cc->tfms[i]); 1274 crypto_free_ablkcipher(cc->tfms[i]);
1287 cpu_cc->tfms[i] = NULL; 1275 cc->tfms[i] = NULL;
1288 } 1276 }
1277
1278 kfree(cc->tfms);
1279 cc->tfms = NULL;
1289} 1280}
1290 1281
1291static int crypt_alloc_tfms(struct crypt_config *cc, int cpu, char *ciphermode) 1282static int crypt_alloc_tfms(struct crypt_config *cc, char *ciphermode)
1292{ 1283{
1293 struct crypt_cpu *cpu_cc = per_cpu_ptr(cc->cpu, cpu);
1294 unsigned i; 1284 unsigned i;
1295 int err; 1285 int err;
1296 1286
1287 cc->tfms = kmalloc(cc->tfms_count * sizeof(struct crypto_ablkcipher *),
1288 GFP_KERNEL);
1289 if (!cc->tfms)
1290 return -ENOMEM;
1291
1297 for (i = 0; i < cc->tfms_count; i++) { 1292 for (i = 0; i < cc->tfms_count; i++) {
1298 cpu_cc->tfms[i] = crypto_alloc_ablkcipher(ciphermode, 0, 0); 1293 cc->tfms[i] = crypto_alloc_ablkcipher(ciphermode, 0, 0);
1299 if (IS_ERR(cpu_cc->tfms[i])) { 1294 if (IS_ERR(cc->tfms[i])) {
1300 err = PTR_ERR(cpu_cc->tfms[i]); 1295 err = PTR_ERR(cc->tfms[i]);
1301 crypt_free_tfms(cc, cpu); 1296 crypt_free_tfms(cc);
1302 return err; 1297 return err;
1303 } 1298 }
1304 } 1299 }
@@ -1309,15 +1304,14 @@ static int crypt_alloc_tfms(struct crypt_config *cc, int cpu, char *ciphermode)
1309static int crypt_setkey_allcpus(struct crypt_config *cc) 1304static int crypt_setkey_allcpus(struct crypt_config *cc)
1310{ 1305{
1311 unsigned subkey_size = cc->key_size >> ilog2(cc->tfms_count); 1306 unsigned subkey_size = cc->key_size >> ilog2(cc->tfms_count);
1312 int cpu, err = 0, i, r; 1307 int err = 0, i, r;
1313 1308
1314 for_each_possible_cpu(cpu) { 1309 for (i = 0; i < cc->tfms_count; i++) {
1315 for (i = 0; i < cc->tfms_count; i++) { 1310 r = crypto_ablkcipher_setkey(cc->tfms[i],
1316 r = crypto_ablkcipher_setkey(per_cpu_ptr(cc->cpu, cpu)->tfms[i], 1311 cc->key + (i * subkey_size),
1317 cc->key + (i * subkey_size), subkey_size); 1312 subkey_size);
1318 if (r) 1313 if (r)
1319 err = r; 1314 err = r;
1320 }
1321 } 1315 }
1322 1316
1323 return err; 1317 return err;
@@ -1379,9 +1373,10 @@ static void crypt_dtr(struct dm_target *ti)
1379 cpu_cc = per_cpu_ptr(cc->cpu, cpu); 1373 cpu_cc = per_cpu_ptr(cc->cpu, cpu);
1380 if (cpu_cc->req) 1374 if (cpu_cc->req)
1381 mempool_free(cpu_cc->req, cc->req_pool); 1375 mempool_free(cpu_cc->req, cc->req_pool);
1382 crypt_free_tfms(cc, cpu);
1383 } 1376 }
1384 1377
1378 crypt_free_tfms(cc);
1379
1385 if (cc->bs) 1380 if (cc->bs)
1386 bioset_free(cc->bs); 1381 bioset_free(cc->bs);
1387 1382
@@ -1414,7 +1409,7 @@ static int crypt_ctr_cipher(struct dm_target *ti,
1414 struct crypt_config *cc = ti->private; 1409 struct crypt_config *cc = ti->private;
1415 char *tmp, *cipher, *chainmode, *ivmode, *ivopts, *keycount; 1410 char *tmp, *cipher, *chainmode, *ivmode, *ivopts, *keycount;
1416 char *cipher_api = NULL; 1411 char *cipher_api = NULL;
1417 int cpu, ret = -EINVAL; 1412 int ret = -EINVAL;
1418 char dummy; 1413 char dummy;
1419 1414
1420 /* Convert to crypto api definition? */ 1415 /* Convert to crypto api definition? */
@@ -1455,8 +1450,7 @@ static int crypt_ctr_cipher(struct dm_target *ti,
1455 if (tmp) 1450 if (tmp)
1456 DMWARN("Ignoring unexpected additional cipher options"); 1451 DMWARN("Ignoring unexpected additional cipher options");
1457 1452
1458 cc->cpu = __alloc_percpu(sizeof(*(cc->cpu)) + 1453 cc->cpu = __alloc_percpu(sizeof(*(cc->cpu)),
1459 cc->tfms_count * sizeof(*(cc->cpu->tfms)),
1460 __alignof__(struct crypt_cpu)); 1454 __alignof__(struct crypt_cpu));
1461 if (!cc->cpu) { 1455 if (!cc->cpu) {
1462 ti->error = "Cannot allocate per cpu state"; 1456 ti->error = "Cannot allocate per cpu state";
@@ -1489,12 +1483,10 @@ static int crypt_ctr_cipher(struct dm_target *ti,
1489 } 1483 }
1490 1484
1491 /* Allocate cipher */ 1485 /* Allocate cipher */
1492 for_each_possible_cpu(cpu) { 1486 ret = crypt_alloc_tfms(cc, cipher_api);
1493 ret = crypt_alloc_tfms(cc, cpu, cipher_api); 1487 if (ret < 0) {
1494 if (ret < 0) { 1488 ti->error = "Error allocating crypto tfm";
1495 ti->error = "Error allocating crypto tfm"; 1489 goto bad;
1496 goto bad;
1497 }
1498 } 1490 }
1499 1491
1500 /* Initialize and set key */ 1492 /* Initialize and set key */
@@ -1702,7 +1694,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1702 } 1694 }
1703 1695
1704 ti->num_flush_requests = 1; 1696 ti->num_flush_requests = 1;
1705 ti->discard_zeroes_data_unsupported = 1; 1697 ti->discard_zeroes_data_unsupported = true;
1706 1698
1707 return 0; 1699 return 0;
1708 1700
@@ -1715,7 +1707,7 @@ static int crypt_map(struct dm_target *ti, struct bio *bio,
1715 union map_info *map_context) 1707 union map_info *map_context)
1716{ 1708{
1717 struct dm_crypt_io *io; 1709 struct dm_crypt_io *io;
1718 struct crypt_config *cc; 1710 struct crypt_config *cc = ti->private;
1719 1711
1720 /* 1712 /*
1721 * If bio is REQ_FLUSH or REQ_DISCARD, just bypass crypt queues. 1713 * If bio is REQ_FLUSH or REQ_DISCARD, just bypass crypt queues.
@@ -1723,14 +1715,13 @@ static int crypt_map(struct dm_target *ti, struct bio *bio,
1723 * - for REQ_DISCARD caller must use flush if IO ordering matters 1715 * - for REQ_DISCARD caller must use flush if IO ordering matters
1724 */ 1716 */
1725 if (unlikely(bio->bi_rw & (REQ_FLUSH | REQ_DISCARD))) { 1717 if (unlikely(bio->bi_rw & (REQ_FLUSH | REQ_DISCARD))) {
1726 cc = ti->private;
1727 bio->bi_bdev = cc->dev->bdev; 1718 bio->bi_bdev = cc->dev->bdev;
1728 if (bio_sectors(bio)) 1719 if (bio_sectors(bio))
1729 bio->bi_sector = cc->start + dm_target_offset(ti, bio->bi_sector); 1720 bio->bi_sector = cc->start + dm_target_offset(ti, bio->bi_sector);
1730 return DM_MAPIO_REMAPPED; 1721 return DM_MAPIO_REMAPPED;
1731 } 1722 }
1732 1723
1733 io = crypt_io_alloc(ti, bio, dm_target_offset(ti, bio->bi_sector)); 1724 io = crypt_io_alloc(cc, bio, dm_target_offset(ti, bio->bi_sector));
1734 1725
1735 if (bio_data_dir(io->base_bio) == READ) { 1726 if (bio_data_dir(io->base_bio) == READ) {
1736 if (kcryptd_io_read(io, GFP_NOWAIT)) 1727 if (kcryptd_io_read(io, GFP_NOWAIT))
@@ -1742,7 +1733,7 @@ static int crypt_map(struct dm_target *ti, struct bio *bio,
1742} 1733}
1743 1734
1744static int crypt_status(struct dm_target *ti, status_type_t type, 1735static int crypt_status(struct dm_target *ti, status_type_t type,
1745 char *result, unsigned int maxlen) 1736 unsigned status_flags, char *result, unsigned maxlen)
1746{ 1737{
1747 struct crypt_config *cc = ti->private; 1738 struct crypt_config *cc = ti->private;
1748 unsigned int sz = 0; 1739 unsigned int sz = 0;
diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c
index 2dc22dddb2ae..f53846f9ab50 100644
--- a/drivers/md/dm-delay.c
+++ b/drivers/md/dm-delay.c
@@ -295,7 +295,7 @@ static int delay_map(struct dm_target *ti, struct bio *bio,
295} 295}
296 296
297static int delay_status(struct dm_target *ti, status_type_t type, 297static int delay_status(struct dm_target *ti, status_type_t type,
298 char *result, unsigned maxlen) 298 unsigned status_flags, char *result, unsigned maxlen)
299{ 299{
300 struct delay_c *dc = ti->private; 300 struct delay_c *dc = ti->private;
301 int sz = 0; 301 int sz = 0;
diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index aa70f7d43a1a..ebaa4f803eec 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -142,24 +142,19 @@ EXPORT_SYMBOL(dm_exception_store_type_unregister);
142static int set_chunk_size(struct dm_exception_store *store, 142static int set_chunk_size(struct dm_exception_store *store,
143 const char *chunk_size_arg, char **error) 143 const char *chunk_size_arg, char **error)
144{ 144{
145 unsigned long chunk_size_ulong; 145 unsigned chunk_size;
146 char *value;
147 146
148 chunk_size_ulong = simple_strtoul(chunk_size_arg, &value, 10); 147 if (kstrtouint(chunk_size_arg, 10, &chunk_size)) {
149 if (*chunk_size_arg == '\0' || *value != '\0' ||
150 chunk_size_ulong > UINT_MAX) {
151 *error = "Invalid chunk size"; 148 *error = "Invalid chunk size";
152 return -EINVAL; 149 return -EINVAL;
153 } 150 }
154 151
155 if (!chunk_size_ulong) { 152 if (!chunk_size) {
156 store->chunk_size = store->chunk_mask = store->chunk_shift = 0; 153 store->chunk_size = store->chunk_mask = store->chunk_shift = 0;
157 return 0; 154 return 0;
158 } 155 }
159 156
160 return dm_exception_store_set_chunk_size(store, 157 return dm_exception_store_set_chunk_size(store, chunk_size, error);
161 (unsigned) chunk_size_ulong,
162 error);
163} 158}
164 159
165int dm_exception_store_set_chunk_size(struct dm_exception_store *store, 160int dm_exception_store_set_chunk_size(struct dm_exception_store *store,
diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
index ac49c01f1a44..cc15543a6ad7 100644
--- a/drivers/md/dm-flakey.c
+++ b/drivers/md/dm-flakey.c
@@ -333,7 +333,7 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio,
333} 333}
334 334
335static int flakey_status(struct dm_target *ti, status_type_t type, 335static int flakey_status(struct dm_target *ti, status_type_t type,
336 char *result, unsigned int maxlen) 336 unsigned status_flags, char *result, unsigned maxlen)
337{ 337{
338 unsigned sz = 0; 338 unsigned sz = 0;
339 struct flakey_c *fc = ti->private; 339 struct flakey_c *fc = ti->private;
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index a1a3e6df17b8..afd95986d099 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1054,6 +1054,7 @@ static void retrieve_status(struct dm_table *table,
1054 char *outbuf, *outptr; 1054 char *outbuf, *outptr;
1055 status_type_t type; 1055 status_type_t type;
1056 size_t remaining, len, used = 0; 1056 size_t remaining, len, used = 0;
1057 unsigned status_flags = 0;
1057 1058
1058 outptr = outbuf = get_result_buffer(param, param_size, &len); 1059 outptr = outbuf = get_result_buffer(param, param_size, &len);
1059 1060
@@ -1090,7 +1091,9 @@ static void retrieve_status(struct dm_table *table,
1090 1091
1091 /* Get the status/table string from the target driver */ 1092 /* Get the status/table string from the target driver */
1092 if (ti->type->status) { 1093 if (ti->type->status) {
1093 if (ti->type->status(ti, type, outptr, remaining)) { 1094 if (param->flags & DM_NOFLUSH_FLAG)
1095 status_flags |= DM_STATUS_NOFLUSH_FLAG;
1096 if (ti->type->status(ti, type, status_flags, outptr, remaining)) {
1094 param->flags |= DM_BUFFER_FULL_FLAG; 1097 param->flags |= DM_BUFFER_FULL_FLAG;
1095 break; 1098 break;
1096 } 1099 }
diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c
index 3639eeab6042..1bf19a93eef0 100644
--- a/drivers/md/dm-linear.c
+++ b/drivers/md/dm-linear.c
@@ -96,7 +96,7 @@ static int linear_map(struct dm_target *ti, struct bio *bio,
96} 96}
97 97
98static int linear_status(struct dm_target *ti, status_type_t type, 98static int linear_status(struct dm_target *ti, status_type_t type,
99 char *result, unsigned int maxlen) 99 unsigned status_flags, char *result, unsigned maxlen)
100{ 100{
101 struct linear_c *lc = (struct linear_c *) ti->private; 101 struct linear_c *lc = (struct linear_c *) ti->private;
102 102
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 638dae048b4f..d8abb90a6c2f 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -85,6 +85,7 @@ struct multipath {
85 unsigned queue_io:1; /* Must we queue all I/O? */ 85 unsigned queue_io:1; /* Must we queue all I/O? */
86 unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */ 86 unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */
87 unsigned saved_queue_if_no_path:1; /* Saved state during suspension */ 87 unsigned saved_queue_if_no_path:1; /* Saved state during suspension */
88 unsigned retain_attached_hw_handler:1; /* If there's already a hw_handler present, don't change it. */
88 89
89 unsigned pg_init_retries; /* Number of times to retry pg_init */ 90 unsigned pg_init_retries; /* Number of times to retry pg_init */
90 unsigned pg_init_count; /* Number of times pg_init called */ 91 unsigned pg_init_count; /* Number of times pg_init called */
@@ -568,6 +569,8 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
568 int r; 569 int r;
569 struct pgpath *p; 570 struct pgpath *p;
570 struct multipath *m = ti->private; 571 struct multipath *m = ti->private;
572 struct request_queue *q = NULL;
573 const char *attached_handler_name;
571 574
572 /* we need at least a path arg */ 575 /* we need at least a path arg */
573 if (as->argc < 1) { 576 if (as->argc < 1) {
@@ -586,13 +589,37 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
586 goto bad; 589 goto bad;
587 } 590 }
588 591
589 if (m->hw_handler_name) { 592 if (m->retain_attached_hw_handler || m->hw_handler_name)
590 struct request_queue *q = bdev_get_queue(p->path.dev->bdev); 593 q = bdev_get_queue(p->path.dev->bdev);
594
595 if (m->retain_attached_hw_handler) {
596 attached_handler_name = scsi_dh_attached_handler_name(q, GFP_KERNEL);
597 if (attached_handler_name) {
598 /*
599 * Reset hw_handler_name to match the attached handler
600 * and clear any hw_handler_params associated with the
601 * ignored handler.
602 *
603 * NB. This modifies the table line to show the actual
604 * handler instead of the original table passed in.
605 */
606 kfree(m->hw_handler_name);
607 m->hw_handler_name = attached_handler_name;
608
609 kfree(m->hw_handler_params);
610 m->hw_handler_params = NULL;
611 }
612 }
591 613
614 if (m->hw_handler_name) {
615 /*
616 * Increments scsi_dh reference, even when using an
617 * already-attached handler.
618 */
592 r = scsi_dh_attach(q, m->hw_handler_name); 619 r = scsi_dh_attach(q, m->hw_handler_name);
593 if (r == -EBUSY) { 620 if (r == -EBUSY) {
594 /* 621 /*
595 * Already attached to different hw_handler, 622 * Already attached to different hw_handler:
596 * try to reattach with correct one. 623 * try to reattach with correct one.
597 */ 624 */
598 scsi_dh_detach(q); 625 scsi_dh_detach(q);
@@ -760,7 +787,7 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)
760 const char *arg_name; 787 const char *arg_name;
761 788
762 static struct dm_arg _args[] = { 789 static struct dm_arg _args[] = {
763 {0, 5, "invalid number of feature args"}, 790 {0, 6, "invalid number of feature args"},
764 {1, 50, "pg_init_retries must be between 1 and 50"}, 791 {1, 50, "pg_init_retries must be between 1 and 50"},
765 {0, 60000, "pg_init_delay_msecs must be between 0 and 60000"}, 792 {0, 60000, "pg_init_delay_msecs must be between 0 and 60000"},
766 }; 793 };
@@ -781,6 +808,11 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)
781 continue; 808 continue;
782 } 809 }
783 810
811 if (!strcasecmp(arg_name, "retain_attached_hw_handler")) {
812 m->retain_attached_hw_handler = 1;
813 continue;
814 }
815
784 if (!strcasecmp(arg_name, "pg_init_retries") && 816 if (!strcasecmp(arg_name, "pg_init_retries") &&
785 (argc >= 1)) { 817 (argc >= 1)) {
786 r = dm_read_arg(_args + 1, as, &m->pg_init_retries, &ti->error); 818 r = dm_read_arg(_args + 1, as, &m->pg_init_retries, &ti->error);
@@ -1346,7 +1378,7 @@ static void multipath_resume(struct dm_target *ti)
1346 * num_paths num_selector_args [path_dev [selector_args]* ]+ ]+ 1378 * num_paths num_selector_args [path_dev [selector_args]* ]+ ]+
1347 */ 1379 */
1348static int multipath_status(struct dm_target *ti, status_type_t type, 1380static int multipath_status(struct dm_target *ti, status_type_t type,
1349 char *result, unsigned int maxlen) 1381 unsigned status_flags, char *result, unsigned maxlen)
1350{ 1382{
1351 int sz = 0; 1383 int sz = 0;
1352 unsigned long flags; 1384 unsigned long flags;
@@ -1364,13 +1396,16 @@ static int multipath_status(struct dm_target *ti, status_type_t type,
1364 else { 1396 else {
1365 DMEMIT("%u ", m->queue_if_no_path + 1397 DMEMIT("%u ", m->queue_if_no_path +
1366 (m->pg_init_retries > 0) * 2 + 1398 (m->pg_init_retries > 0) * 2 +
1367 (m->pg_init_delay_msecs != DM_PG_INIT_DELAY_DEFAULT) * 2); 1399 (m->pg_init_delay_msecs != DM_PG_INIT_DELAY_DEFAULT) * 2 +
1400 m->retain_attached_hw_handler);
1368 if (m->queue_if_no_path) 1401 if (m->queue_if_no_path)
1369 DMEMIT("queue_if_no_path "); 1402 DMEMIT("queue_if_no_path ");
1370 if (m->pg_init_retries) 1403 if (m->pg_init_retries)
1371 DMEMIT("pg_init_retries %u ", m->pg_init_retries); 1404 DMEMIT("pg_init_retries %u ", m->pg_init_retries);
1372 if (m->pg_init_delay_msecs != DM_PG_INIT_DELAY_DEFAULT) 1405 if (m->pg_init_delay_msecs != DM_PG_INIT_DELAY_DEFAULT)
1373 DMEMIT("pg_init_delay_msecs %u ", m->pg_init_delay_msecs); 1406 DMEMIT("pg_init_delay_msecs %u ", m->pg_init_delay_msecs);
1407 if (m->retain_attached_hw_handler)
1408 DMEMIT("retain_attached_hw_handler ");
1374 } 1409 }
1375 1410
1376 if (!m->hw_handler_name || type == STATUSTYPE_INFO) 1411 if (!m->hw_handler_name || type == STATUSTYPE_INFO)
@@ -1656,7 +1691,7 @@ out:
1656 *---------------------------------------------------------------*/ 1691 *---------------------------------------------------------------*/
1657static struct target_type multipath_target = { 1692static struct target_type multipath_target = {
1658 .name = "multipath", 1693 .name = "multipath",
1659 .version = {1, 4, 0}, 1694 .version = {1, 5, 0},
1660 .module = THIS_MODULE, 1695 .module = THIS_MODULE,
1661 .ctr = multipath_ctr, 1696 .ctr = multipath_ctr,
1662 .dtr = multipath_dtr, 1697 .dtr = multipath_dtr,
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 017c34d78d61..f2f29c526544 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -101,20 +101,12 @@ static struct raid_set *context_alloc(struct dm_target *ti, struct raid_type *ra
101{ 101{
102 unsigned i; 102 unsigned i;
103 struct raid_set *rs; 103 struct raid_set *rs;
104 sector_t sectors_per_dev;
105 104
106 if (raid_devs <= raid_type->parity_devs) { 105 if (raid_devs <= raid_type->parity_devs) {
107 ti->error = "Insufficient number of devices"; 106 ti->error = "Insufficient number of devices";
108 return ERR_PTR(-EINVAL); 107 return ERR_PTR(-EINVAL);
109 } 108 }
110 109
111 sectors_per_dev = ti->len;
112 if ((raid_type->level > 1) &&
113 sector_div(sectors_per_dev, (raid_devs - raid_type->parity_devs))) {
114 ti->error = "Target length not divisible by number of data devices";
115 return ERR_PTR(-EINVAL);
116 }
117
118 rs = kzalloc(sizeof(*rs) + raid_devs * sizeof(rs->dev[0]), GFP_KERNEL); 110 rs = kzalloc(sizeof(*rs) + raid_devs * sizeof(rs->dev[0]), GFP_KERNEL);
119 if (!rs) { 111 if (!rs) {
120 ti->error = "Cannot allocate raid context"; 112 ti->error = "Cannot allocate raid context";
@@ -128,7 +120,6 @@ static struct raid_set *context_alloc(struct dm_target *ti, struct raid_type *ra
128 rs->md.raid_disks = raid_devs; 120 rs->md.raid_disks = raid_devs;
129 rs->md.level = raid_type->level; 121 rs->md.level = raid_type->level;
130 rs->md.new_level = rs->md.level; 122 rs->md.new_level = rs->md.level;
131 rs->md.dev_sectors = sectors_per_dev;
132 rs->md.layout = raid_type->algorithm; 123 rs->md.layout = raid_type->algorithm;
133 rs->md.new_layout = rs->md.layout; 124 rs->md.new_layout = rs->md.layout;
134 rs->md.delta_disks = 0; 125 rs->md.delta_disks = 0;
@@ -143,6 +134,7 @@ static struct raid_set *context_alloc(struct dm_target *ti, struct raid_type *ra
143 * rs->md.external 134 * rs->md.external
144 * rs->md.chunk_sectors 135 * rs->md.chunk_sectors
145 * rs->md.new_chunk_sectors 136 * rs->md.new_chunk_sectors
137 * rs->md.dev_sectors
146 */ 138 */
147 139
148 return rs; 140 return rs;
@@ -353,6 +345,8 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
353{ 345{
354 unsigned i, rebuild_cnt = 0; 346 unsigned i, rebuild_cnt = 0;
355 unsigned long value, region_size = 0; 347 unsigned long value, region_size = 0;
348 sector_t sectors_per_dev = rs->ti->len;
349 sector_t max_io_len;
356 char *key; 350 char *key;
357 351
358 /* 352 /*
@@ -429,13 +423,28 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
429 423
430 if (!strcasecmp(key, "rebuild")) { 424 if (!strcasecmp(key, "rebuild")) {
431 rebuild_cnt++; 425 rebuild_cnt++;
432 if (((rs->raid_type->level != 1) && 426
433 (rebuild_cnt > rs->raid_type->parity_devs)) || 427 switch (rs->raid_type->level) {
434 ((rs->raid_type->level == 1) && 428 case 1:
435 (rebuild_cnt > (rs->md.raid_disks - 1)))) { 429 if (rebuild_cnt >= rs->md.raid_disks) {
436 rs->ti->error = "Too many rebuild devices specified for given RAID type"; 430 rs->ti->error = "Too many rebuild devices specified";
431 return -EINVAL;
432 }
433 break;
434 case 4:
435 case 5:
436 case 6:
437 if (rebuild_cnt > rs->raid_type->parity_devs) {
438 rs->ti->error = "Too many rebuild devices specified for given RAID type";
439 return -EINVAL;
440 }
441 break;
442 default:
443 DMERR("The rebuild parameter is not supported for %s", rs->raid_type->name);
444 rs->ti->error = "Rebuild not supported for this RAID type";
437 return -EINVAL; 445 return -EINVAL;
438 } 446 }
447
439 if (value > rs->md.raid_disks) { 448 if (value > rs->md.raid_disks) {
440 rs->ti->error = "Invalid rebuild index given"; 449 rs->ti->error = "Invalid rebuild index given";
441 return -EINVAL; 450 return -EINVAL;
@@ -522,14 +531,19 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
522 return -EINVAL; 531 return -EINVAL;
523 532
524 if (rs->md.chunk_sectors) 533 if (rs->md.chunk_sectors)
525 rs->ti->split_io = rs->md.chunk_sectors; 534 max_io_len = rs->md.chunk_sectors;
526 else 535 else
527 rs->ti->split_io = region_size; 536 max_io_len = region_size;
528 537
529 if (rs->md.chunk_sectors) 538 if (dm_set_target_max_io_len(rs->ti, max_io_len))
530 rs->ti->split_io = rs->md.chunk_sectors; 539 return -EINVAL;
531 else 540
532 rs->ti->split_io = region_size; 541 if ((rs->raid_type->level > 1) &&
542 sector_div(sectors_per_dev, (rs->md.raid_disks - rs->raid_type->parity_devs))) {
543 rs->ti->error = "Target length not divisible by number of data devices";
544 return -EINVAL;
545 }
546 rs->md.dev_sectors = sectors_per_dev;
533 547
534 /* Assume there are no metadata devices until the drives are parsed */ 548 /* Assume there are no metadata devices until the drives are parsed */
535 rs->md.persistent = 0; 549 rs->md.persistent = 0;
@@ -1067,7 +1081,7 @@ static int raid_map(struct dm_target *ti, struct bio *bio, union map_info *map_c
1067} 1081}
1068 1082
1069static int raid_status(struct dm_target *ti, status_type_t type, 1083static int raid_status(struct dm_target *ti, status_type_t type,
1070 char *result, unsigned maxlen) 1084 unsigned status_flags, char *result, unsigned maxlen)
1071{ 1085{
1072 struct raid_set *rs = ti->private; 1086 struct raid_set *rs = ti->private;
1073 unsigned raid_param_cnt = 1; /* at least 1 for chunksize */ 1087 unsigned raid_param_cnt = 1; /* at least 1 for chunksize */
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index b58b7a33914a..bc5ddba8045b 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -1081,10 +1081,14 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1081 } 1081 }
1082 1082
1083 ti->private = ms; 1083 ti->private = ms;
1084 ti->split_io = dm_rh_get_region_size(ms->rh); 1084
1085 r = dm_set_target_max_io_len(ti, dm_rh_get_region_size(ms->rh));
1086 if (r)
1087 goto err_free_context;
1088
1085 ti->num_flush_requests = 1; 1089 ti->num_flush_requests = 1;
1086 ti->num_discard_requests = 1; 1090 ti->num_discard_requests = 1;
1087 ti->discard_zeroes_data_unsupported = 1; 1091 ti->discard_zeroes_data_unsupported = true;
1088 1092
1089 ms->kmirrord_wq = alloc_workqueue("kmirrord", 1093 ms->kmirrord_wq = alloc_workqueue("kmirrord",
1090 WQ_NON_REENTRANT | WQ_MEM_RECLAIM, 0); 1094 WQ_NON_REENTRANT | WQ_MEM_RECLAIM, 0);
@@ -1363,7 +1367,7 @@ static char device_status_char(struct mirror *m)
1363 1367
1364 1368
1365static int mirror_status(struct dm_target *ti, status_type_t type, 1369static int mirror_status(struct dm_target *ti, status_type_t type,
1366 char *result, unsigned int maxlen) 1370 unsigned status_flags, char *result, unsigned maxlen)
1367{ 1371{
1368 unsigned int m, sz = 0; 1372 unsigned int m, sz = 0;
1369 struct mirror_set *ms = (struct mirror_set *) ti->private; 1373 struct mirror_set *ms = (struct mirror_set *) ti->private;
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 6f758870fc19..a143921feaf6 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -691,7 +691,7 @@ static int dm_add_exception(void *context, chunk_t old, chunk_t new)
691 * Return a minimum chunk size of all snapshots that have the specified origin. 691 * Return a minimum chunk size of all snapshots that have the specified origin.
692 * Return zero if the origin has no snapshots. 692 * Return zero if the origin has no snapshots.
693 */ 693 */
694static sector_t __minimum_chunk_size(struct origin *o) 694static uint32_t __minimum_chunk_size(struct origin *o)
695{ 695{
696 struct dm_snapshot *snap; 696 struct dm_snapshot *snap;
697 unsigned chunk_size = 0; 697 unsigned chunk_size = 0;
@@ -701,7 +701,7 @@ static sector_t __minimum_chunk_size(struct origin *o)
701 chunk_size = min_not_zero(chunk_size, 701 chunk_size = min_not_zero(chunk_size,
702 snap->store->chunk_size); 702 snap->store->chunk_size);
703 703
704 return chunk_size; 704 return (uint32_t) chunk_size;
705} 705}
706 706
707/* 707/*
@@ -1172,7 +1172,10 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1172 ti->error = "Chunk size not set"; 1172 ti->error = "Chunk size not set";
1173 goto bad_read_metadata; 1173 goto bad_read_metadata;
1174 } 1174 }
1175 ti->split_io = s->store->chunk_size; 1175
1176 r = dm_set_target_max_io_len(ti, s->store->chunk_size);
1177 if (r)
1178 goto bad_read_metadata;
1176 1179
1177 return 0; 1180 return 0;
1178 1181
@@ -1239,7 +1242,7 @@ static void __handover_exceptions(struct dm_snapshot *snap_src,
1239 snap_dest->store->snap = snap_dest; 1242 snap_dest->store->snap = snap_dest;
1240 snap_src->store->snap = snap_src; 1243 snap_src->store->snap = snap_src;
1241 1244
1242 snap_dest->ti->split_io = snap_dest->store->chunk_size; 1245 snap_dest->ti->max_io_len = snap_dest->store->chunk_size;
1243 snap_dest->valid = snap_src->valid; 1246 snap_dest->valid = snap_src->valid;
1244 1247
1245 /* 1248 /*
@@ -1817,9 +1820,9 @@ static void snapshot_resume(struct dm_target *ti)
1817 up_write(&s->lock); 1820 up_write(&s->lock);
1818} 1821}
1819 1822
1820static sector_t get_origin_minimum_chunksize(struct block_device *bdev) 1823static uint32_t get_origin_minimum_chunksize(struct block_device *bdev)
1821{ 1824{
1822 sector_t min_chunksize; 1825 uint32_t min_chunksize;
1823 1826
1824 down_read(&_origins_lock); 1827 down_read(&_origins_lock);
1825 min_chunksize = __minimum_chunk_size(__lookup_origin(bdev)); 1828 min_chunksize = __minimum_chunk_size(__lookup_origin(bdev));
@@ -1838,15 +1841,15 @@ static void snapshot_merge_resume(struct dm_target *ti)
1838 snapshot_resume(ti); 1841 snapshot_resume(ti);
1839 1842
1840 /* 1843 /*
1841 * snapshot-merge acts as an origin, so set ti->split_io 1844 * snapshot-merge acts as an origin, so set ti->max_io_len
1842 */ 1845 */
1843 ti->split_io = get_origin_minimum_chunksize(s->origin->bdev); 1846 ti->max_io_len = get_origin_minimum_chunksize(s->origin->bdev);
1844 1847
1845 start_merge(s); 1848 start_merge(s);
1846} 1849}
1847 1850
1848static int snapshot_status(struct dm_target *ti, status_type_t type, 1851static int snapshot_status(struct dm_target *ti, status_type_t type,
1849 char *result, unsigned int maxlen) 1852 unsigned status_flags, char *result, unsigned maxlen)
1850{ 1853{
1851 unsigned sz = 0; 1854 unsigned sz = 0;
1852 struct dm_snapshot *snap = ti->private; 1855 struct dm_snapshot *snap = ti->private;
@@ -2073,12 +2076,12 @@ static int origin_write_extent(struct dm_snapshot *merging_snap,
2073 struct origin *o; 2076 struct origin *o;
2074 2077
2075 /* 2078 /*
2076 * The origin's __minimum_chunk_size() got stored in split_io 2079 * The origin's __minimum_chunk_size() got stored in max_io_len
2077 * by snapshot_merge_resume(). 2080 * by snapshot_merge_resume().
2078 */ 2081 */
2079 down_read(&_origins_lock); 2082 down_read(&_origins_lock);
2080 o = __lookup_origin(merging_snap->origin->bdev); 2083 o = __lookup_origin(merging_snap->origin->bdev);
2081 for (n = 0; n < size; n += merging_snap->ti->split_io) 2084 for (n = 0; n < size; n += merging_snap->ti->max_io_len)
2082 if (__origin_write(&o->snapshots, sector + n, NULL) == 2085 if (__origin_write(&o->snapshots, sector + n, NULL) ==
2083 DM_MAPIO_SUBMITTED) 2086 DM_MAPIO_SUBMITTED)
2084 must_wait = 1; 2087 must_wait = 1;
@@ -2138,18 +2141,18 @@ static int origin_map(struct dm_target *ti, struct bio *bio,
2138} 2141}
2139 2142
2140/* 2143/*
2141 * Set the target "split_io" field to the minimum of all the snapshots' 2144 * Set the target "max_io_len" field to the minimum of all the snapshots'
2142 * chunk sizes. 2145 * chunk sizes.
2143 */ 2146 */
2144static void origin_resume(struct dm_target *ti) 2147static void origin_resume(struct dm_target *ti)
2145{ 2148{
2146 struct dm_dev *dev = ti->private; 2149 struct dm_dev *dev = ti->private;
2147 2150
2148 ti->split_io = get_origin_minimum_chunksize(dev->bdev); 2151 ti->max_io_len = get_origin_minimum_chunksize(dev->bdev);
2149} 2152}
2150 2153
2151static int origin_status(struct dm_target *ti, status_type_t type, char *result, 2154static int origin_status(struct dm_target *ti, status_type_t type,
2152 unsigned int maxlen) 2155 unsigned status_flags, char *result, unsigned maxlen)
2153{ 2156{
2154 struct dm_dev *dev = ti->private; 2157 struct dm_dev *dev = ti->private;
2155 2158
@@ -2176,7 +2179,6 @@ static int origin_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
2176 return max_size; 2179 return max_size;
2177 2180
2178 bvm->bi_bdev = dev->bdev; 2181 bvm->bi_bdev = dev->bdev;
2179 bvm->bi_sector = bvm->bi_sector;
2180 2182
2181 return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 2183 return min(max_size, q->merge_bvec_fn(q, bvm, biovec));
2182} 2184}
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index 35c94ff24ad5..a087bf2a8d66 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -26,14 +26,12 @@ struct stripe {
26struct stripe_c { 26struct stripe_c {
27 uint32_t stripes; 27 uint32_t stripes;
28 int stripes_shift; 28 int stripes_shift;
29 sector_t stripes_mask;
30 29
31 /* The size of this target / num. stripes */ 30 /* The size of this target / num. stripes */
32 sector_t stripe_width; 31 sector_t stripe_width;
33 32
34 /* stripe chunk size */ 33 uint32_t chunk_size;
35 uint32_t chunk_shift; 34 int chunk_size_shift;
36 sector_t chunk_mask;
37 35
38 /* Needed for handling events */ 36 /* Needed for handling events */
39 struct dm_target *ti; 37 struct dm_target *ti;
@@ -91,7 +89,7 @@ static int get_stripe(struct dm_target *ti, struct stripe_c *sc,
91 89
92/* 90/*
93 * Construct a striped mapping. 91 * Construct a striped mapping.
94 * <number of stripes> <chunk size (2^^n)> [<dev_path> <offset>]+ 92 * <number of stripes> <chunk size> [<dev_path> <offset>]+
95 */ 93 */
96static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv) 94static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
97{ 95{
@@ -99,7 +97,6 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
99 sector_t width; 97 sector_t width;
100 uint32_t stripes; 98 uint32_t stripes;
101 uint32_t chunk_size; 99 uint32_t chunk_size;
102 char *end;
103 int r; 100 int r;
104 unsigned int i; 101 unsigned int i;
105 102
@@ -108,34 +105,23 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
108 return -EINVAL; 105 return -EINVAL;
109 } 106 }
110 107
111 stripes = simple_strtoul(argv[0], &end, 10); 108 if (kstrtouint(argv[0], 10, &stripes) || !stripes) {
112 if (!stripes || *end) {
113 ti->error = "Invalid stripe count"; 109 ti->error = "Invalid stripe count";
114 return -EINVAL; 110 return -EINVAL;
115 } 111 }
116 112
117 chunk_size = simple_strtoul(argv[1], &end, 10); 113 if (kstrtouint(argv[1], 10, &chunk_size) || !chunk_size) {
118 if (*end) {
119 ti->error = "Invalid chunk_size"; 114 ti->error = "Invalid chunk_size";
120 return -EINVAL; 115 return -EINVAL;
121 } 116 }
122 117
123 /* 118 width = ti->len;
124 * chunk_size is a power of two 119 if (sector_div(width, chunk_size)) {
125 */
126 if (!is_power_of_2(chunk_size) ||
127 (chunk_size < (PAGE_SIZE >> SECTOR_SHIFT))) {
128 ti->error = "Invalid chunk size";
129 return -EINVAL;
130 }
131
132 if (ti->len & (chunk_size - 1)) {
133 ti->error = "Target length not divisible by " 120 ti->error = "Target length not divisible by "
134 "chunk size"; 121 "chunk size";
135 return -EINVAL; 122 return -EINVAL;
136 } 123 }
137 124
138 width = ti->len;
139 if (sector_div(width, stripes)) { 125 if (sector_div(width, stripes)) {
140 ti->error = "Target length not divisible by " 126 ti->error = "Target length not divisible by "
141 "number of stripes"; 127 "number of stripes";
@@ -167,17 +153,21 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
167 153
168 if (stripes & (stripes - 1)) 154 if (stripes & (stripes - 1))
169 sc->stripes_shift = -1; 155 sc->stripes_shift = -1;
170 else { 156 else
171 sc->stripes_shift = ffs(stripes) - 1; 157 sc->stripes_shift = __ffs(stripes);
172 sc->stripes_mask = ((sector_t) stripes) - 1; 158
173 } 159 r = dm_set_target_max_io_len(ti, chunk_size);
160 if (r)
161 return r;
174 162
175 ti->split_io = chunk_size;
176 ti->num_flush_requests = stripes; 163 ti->num_flush_requests = stripes;
177 ti->num_discard_requests = stripes; 164 ti->num_discard_requests = stripes;
178 165
179 sc->chunk_shift = ffs(chunk_size) - 1; 166 sc->chunk_size = chunk_size;
180 sc->chunk_mask = ((sector_t) chunk_size) - 1; 167 if (chunk_size & (chunk_size - 1))
168 sc->chunk_size_shift = -1;
169 else
170 sc->chunk_size_shift = __ffs(chunk_size);
181 171
182 /* 172 /*
183 * Get the stripe destinations. 173 * Get the stripe destinations.
@@ -216,17 +206,29 @@ static void stripe_dtr(struct dm_target *ti)
216static void stripe_map_sector(struct stripe_c *sc, sector_t sector, 206static void stripe_map_sector(struct stripe_c *sc, sector_t sector,
217 uint32_t *stripe, sector_t *result) 207 uint32_t *stripe, sector_t *result)
218{ 208{
219 sector_t offset = dm_target_offset(sc->ti, sector); 209 sector_t chunk = dm_target_offset(sc->ti, sector);
220 sector_t chunk = offset >> sc->chunk_shift; 210 sector_t chunk_offset;
211
212 if (sc->chunk_size_shift < 0)
213 chunk_offset = sector_div(chunk, sc->chunk_size);
214 else {
215 chunk_offset = chunk & (sc->chunk_size - 1);
216 chunk >>= sc->chunk_size_shift;
217 }
221 218
222 if (sc->stripes_shift < 0) 219 if (sc->stripes_shift < 0)
223 *stripe = sector_div(chunk, sc->stripes); 220 *stripe = sector_div(chunk, sc->stripes);
224 else { 221 else {
225 *stripe = chunk & sc->stripes_mask; 222 *stripe = chunk & (sc->stripes - 1);
226 chunk >>= sc->stripes_shift; 223 chunk >>= sc->stripes_shift;
227 } 224 }
228 225
229 *result = (chunk << sc->chunk_shift) | (offset & sc->chunk_mask); 226 if (sc->chunk_size_shift < 0)
227 chunk *= sc->chunk_size;
228 else
229 chunk <<= sc->chunk_size_shift;
230
231 *result = chunk + chunk_offset;
230} 232}
231 233
232static void stripe_map_range_sector(struct stripe_c *sc, sector_t sector, 234static void stripe_map_range_sector(struct stripe_c *sc, sector_t sector,
@@ -237,9 +239,16 @@ static void stripe_map_range_sector(struct stripe_c *sc, sector_t sector,
237 stripe_map_sector(sc, sector, &stripe, result); 239 stripe_map_sector(sc, sector, &stripe, result);
238 if (stripe == target_stripe) 240 if (stripe == target_stripe)
239 return; 241 return;
240 *result &= ~sc->chunk_mask; /* round down */ 242
243 /* round down */
244 sector = *result;
245 if (sc->chunk_size_shift < 0)
246 *result -= sector_div(sector, sc->chunk_size);
247 else
248 *result = sector & ~(sector_t)(sc->chunk_size - 1);
249
241 if (target_stripe < stripe) 250 if (target_stripe < stripe)
242 *result += sc->chunk_mask + 1; /* next chunk */ 251 *result += sc->chunk_size; /* next chunk */
243} 252}
244 253
245static int stripe_map_discard(struct stripe_c *sc, struct bio *bio, 254static int stripe_map_discard(struct stripe_c *sc, struct bio *bio,
@@ -302,8 +311,8 @@ static int stripe_map(struct dm_target *ti, struct bio *bio,
302 * 311 *
303 */ 312 */
304 313
305static int stripe_status(struct dm_target *ti, 314static int stripe_status(struct dm_target *ti, status_type_t type,
306 status_type_t type, char *result, unsigned int maxlen) 315 unsigned status_flags, char *result, unsigned maxlen)
307{ 316{
308 struct stripe_c *sc = (struct stripe_c *) ti->private; 317 struct stripe_c *sc = (struct stripe_c *) ti->private;
309 char buffer[sc->stripes + 1]; 318 char buffer[sc->stripes + 1];
@@ -324,7 +333,7 @@ static int stripe_status(struct dm_target *ti,
324 333
325 case STATUSTYPE_TABLE: 334 case STATUSTYPE_TABLE:
326 DMEMIT("%d %llu", sc->stripes, 335 DMEMIT("%d %llu", sc->stripes,
327 (unsigned long long)sc->chunk_mask + 1); 336 (unsigned long long)sc->chunk_size);
328 for (i = 0; i < sc->stripes; i++) 337 for (i = 0; i < sc->stripes; i++)
329 DMEMIT(" %s %llu", sc->stripe[i].dev->name, 338 DMEMIT(" %s %llu", sc->stripe[i].dev->name,
330 (unsigned long long)sc->stripe[i].physical_start); 339 (unsigned long long)sc->stripe[i].physical_start);
@@ -391,7 +400,7 @@ static void stripe_io_hints(struct dm_target *ti,
391 struct queue_limits *limits) 400 struct queue_limits *limits)
392{ 401{
393 struct stripe_c *sc = ti->private; 402 struct stripe_c *sc = ti->private;
394 unsigned chunk_size = (sc->chunk_mask + 1) << 9; 403 unsigned chunk_size = sc->chunk_size << SECTOR_SHIFT;
395 404
396 blk_limits_io_min(limits, chunk_size); 405 blk_limits_io_min(limits, chunk_size);
397 blk_limits_io_opt(limits, chunk_size * sc->stripes); 406 blk_limits_io_opt(limits, chunk_size * sc->stripes);
@@ -419,7 +428,7 @@ static int stripe_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
419 428
420static struct target_type stripe_target = { 429static struct target_type stripe_target = {
421 .name = "striped", 430 .name = "striped",
422 .version = {1, 4, 0}, 431 .version = {1, 5, 0},
423 .module = THIS_MODULE, 432 .module = THIS_MODULE,
424 .ctr = stripe_ctr, 433 .ctr = stripe_ctr,
425 .dtr = stripe_dtr, 434 .dtr = stripe_dtr,
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 2e227fbf1622..f90069029aae 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1319,6 +1319,9 @@ static bool dm_table_supports_flush(struct dm_table *t, unsigned flush)
1319 if (!ti->num_flush_requests) 1319 if (!ti->num_flush_requests)
1320 continue; 1320 continue;
1321 1321
1322 if (ti->flush_supported)
1323 return 1;
1324
1322 if (ti->type->iterate_devices && 1325 if (ti->type->iterate_devices &&
1323 ti->type->iterate_devices(ti, device_flush_capable, &flush)) 1326 ti->type->iterate_devices(ti, device_flush_capable, &flush))
1324 return 1; 1327 return 1;
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index 3e2907f0bc46..693e149e9727 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2011 Red Hat, Inc. 2 * Copyright (C) 2011-2012 Red Hat, Inc.
3 * 3 *
4 * This file is released under the GPL. 4 * This file is released under the GPL.
5 */ 5 */
@@ -80,6 +80,12 @@
80#define THIN_METADATA_CACHE_SIZE 64 80#define THIN_METADATA_CACHE_SIZE 64
81#define SECTOR_TO_BLOCK_SHIFT 3 81#define SECTOR_TO_BLOCK_SHIFT 3
82 82
83/*
84 * 3 for btree insert +
85 * 2 for btree lookup used within space map
86 */
87#define THIN_MAX_CONCURRENT_LOCKS 5
88
83/* This should be plenty */ 89/* This should be plenty */
84#define SPACE_MAP_ROOT_SIZE 128 90#define SPACE_MAP_ROOT_SIZE 128
85 91
@@ -172,13 +178,20 @@ struct dm_pool_metadata {
172 178
173 struct rw_semaphore root_lock; 179 struct rw_semaphore root_lock;
174 uint32_t time; 180 uint32_t time;
175 int need_commit;
176 dm_block_t root; 181 dm_block_t root;
177 dm_block_t details_root; 182 dm_block_t details_root;
178 struct list_head thin_devices; 183 struct list_head thin_devices;
179 uint64_t trans_id; 184 uint64_t trans_id;
180 unsigned long flags; 185 unsigned long flags;
181 sector_t data_block_size; 186 sector_t data_block_size;
187 bool read_only:1;
188
189 /*
190 * Set if a transaction has to be aborted but the attempt to roll back
191 * to the previous (good) transaction failed. The only pool metadata
192 * operation possible in this state is the closing of the device.
193 */
194 bool fail_io:1;
182}; 195};
183 196
184struct dm_thin_device { 197struct dm_thin_device {
@@ -187,7 +200,8 @@ struct dm_thin_device {
187 dm_thin_id id; 200 dm_thin_id id;
188 201
189 int open_count; 202 int open_count;
190 int changed; 203 bool changed:1;
204 bool aborted_with_changes:1;
191 uint64_t mapped_blocks; 205 uint64_t mapped_blocks;
192 uint64_t transaction_id; 206 uint64_t transaction_id;
193 uint32_t creation_time; 207 uint32_t creation_time;
@@ -338,7 +352,21 @@ static int subtree_equal(void *context, void *value1_le, void *value2_le)
338 352
339/*----------------------------------------------------------------*/ 353/*----------------------------------------------------------------*/
340 354
341static int superblock_all_zeroes(struct dm_block_manager *bm, int *result) 355static int superblock_lock_zero(struct dm_pool_metadata *pmd,
356 struct dm_block **sblock)
357{
358 return dm_bm_write_lock_zero(pmd->bm, THIN_SUPERBLOCK_LOCATION,
359 &sb_validator, sblock);
360}
361
362static int superblock_lock(struct dm_pool_metadata *pmd,
363 struct dm_block **sblock)
364{
365 return dm_bm_write_lock(pmd->bm, THIN_SUPERBLOCK_LOCATION,
366 &sb_validator, sblock);
367}
368
369static int __superblock_all_zeroes(struct dm_block_manager *bm, int *result)
342{ 370{
343 int r; 371 int r;
344 unsigned i; 372 unsigned i;
@@ -365,72 +393,9 @@ static int superblock_all_zeroes(struct dm_block_manager *bm, int *result)
365 return dm_bm_unlock(b); 393 return dm_bm_unlock(b);
366} 394}
367 395
368static int init_pmd(struct dm_pool_metadata *pmd, 396static void __setup_btree_details(struct dm_pool_metadata *pmd)
369 struct dm_block_manager *bm,
370 dm_block_t nr_blocks, int create)
371{ 397{
372 int r; 398 pmd->info.tm = pmd->tm;
373 struct dm_space_map *sm, *data_sm;
374 struct dm_transaction_manager *tm;
375 struct dm_block *sblock;
376
377 if (create) {
378 r = dm_tm_create_with_sm(bm, THIN_SUPERBLOCK_LOCATION,
379 &sb_validator, &tm, &sm, &sblock);
380 if (r < 0) {
381 DMERR("tm_create_with_sm failed");
382 return r;
383 }
384
385 data_sm = dm_sm_disk_create(tm, nr_blocks);
386 if (IS_ERR(data_sm)) {
387 DMERR("sm_disk_create failed");
388 dm_tm_unlock(tm, sblock);
389 r = PTR_ERR(data_sm);
390 goto bad;
391 }
392 } else {
393 struct thin_disk_superblock *disk_super = NULL;
394 size_t space_map_root_offset =
395 offsetof(struct thin_disk_superblock, metadata_space_map_root);
396
397 r = dm_tm_open_with_sm(bm, THIN_SUPERBLOCK_LOCATION,
398 &sb_validator, space_map_root_offset,
399 SPACE_MAP_ROOT_SIZE, &tm, &sm, &sblock);
400 if (r < 0) {
401 DMERR("tm_open_with_sm failed");
402 return r;
403 }
404
405 disk_super = dm_block_data(sblock);
406 data_sm = dm_sm_disk_open(tm, disk_super->data_space_map_root,
407 sizeof(disk_super->data_space_map_root));
408 if (IS_ERR(data_sm)) {
409 DMERR("sm_disk_open failed");
410 r = PTR_ERR(data_sm);
411 goto bad;
412 }
413 }
414
415
416 r = dm_tm_unlock(tm, sblock);
417 if (r < 0) {
418 DMERR("couldn't unlock superblock");
419 goto bad_data_sm;
420 }
421
422 pmd->bm = bm;
423 pmd->metadata_sm = sm;
424 pmd->data_sm = data_sm;
425 pmd->tm = tm;
426 pmd->nb_tm = dm_tm_create_non_blocking_clone(tm);
427 if (!pmd->nb_tm) {
428 DMERR("could not create clone tm");
429 r = -ENOMEM;
430 goto bad_data_sm;
431 }
432
433 pmd->info.tm = tm;
434 pmd->info.levels = 2; 399 pmd->info.levels = 2;
435 pmd->info.value_type.context = pmd->data_sm; 400 pmd->info.value_type.context = pmd->data_sm;
436 pmd->info.value_type.size = sizeof(__le64); 401 pmd->info.value_type.size = sizeof(__le64);
@@ -441,7 +406,7 @@ static int init_pmd(struct dm_pool_metadata *pmd,
441 memcpy(&pmd->nb_info, &pmd->info, sizeof(pmd->nb_info)); 406 memcpy(&pmd->nb_info, &pmd->info, sizeof(pmd->nb_info));
442 pmd->nb_info.tm = pmd->nb_tm; 407 pmd->nb_info.tm = pmd->nb_tm;
443 408
444 pmd->tl_info.tm = tm; 409 pmd->tl_info.tm = pmd->tm;
445 pmd->tl_info.levels = 1; 410 pmd->tl_info.levels = 1;
446 pmd->tl_info.value_type.context = &pmd->info; 411 pmd->tl_info.value_type.context = &pmd->info;
447 pmd->tl_info.value_type.size = sizeof(__le64); 412 pmd->tl_info.value_type.size = sizeof(__le64);
@@ -449,7 +414,7 @@ static int init_pmd(struct dm_pool_metadata *pmd,
449 pmd->tl_info.value_type.dec = subtree_dec; 414 pmd->tl_info.value_type.dec = subtree_dec;
450 pmd->tl_info.value_type.equal = subtree_equal; 415 pmd->tl_info.value_type.equal = subtree_equal;
451 416
452 pmd->bl_info.tm = tm; 417 pmd->bl_info.tm = pmd->tm;
453 pmd->bl_info.levels = 1; 418 pmd->bl_info.levels = 1;
454 pmd->bl_info.value_type.context = pmd->data_sm; 419 pmd->bl_info.value_type.context = pmd->data_sm;
455 pmd->bl_info.value_type.size = sizeof(__le64); 420 pmd->bl_info.value_type.size = sizeof(__le64);
@@ -457,48 +422,266 @@ static int init_pmd(struct dm_pool_metadata *pmd,
457 pmd->bl_info.value_type.dec = data_block_dec; 422 pmd->bl_info.value_type.dec = data_block_dec;
458 pmd->bl_info.value_type.equal = data_block_equal; 423 pmd->bl_info.value_type.equal = data_block_equal;
459 424
460 pmd->details_info.tm = tm; 425 pmd->details_info.tm = pmd->tm;
461 pmd->details_info.levels = 1; 426 pmd->details_info.levels = 1;
462 pmd->details_info.value_type.context = NULL; 427 pmd->details_info.value_type.context = NULL;
463 pmd->details_info.value_type.size = sizeof(struct disk_device_details); 428 pmd->details_info.value_type.size = sizeof(struct disk_device_details);
464 pmd->details_info.value_type.inc = NULL; 429 pmd->details_info.value_type.inc = NULL;
465 pmd->details_info.value_type.dec = NULL; 430 pmd->details_info.value_type.dec = NULL;
466 pmd->details_info.value_type.equal = NULL; 431 pmd->details_info.value_type.equal = NULL;
432}
467 433
468 pmd->root = 0; 434static int __write_initial_superblock(struct dm_pool_metadata *pmd)
435{
436 int r;
437 struct dm_block *sblock;
438 size_t metadata_len, data_len;
439 struct thin_disk_superblock *disk_super;
440 sector_t bdev_size = i_size_read(pmd->bdev->bd_inode) >> SECTOR_SHIFT;
469 441
470 init_rwsem(&pmd->root_lock); 442 if (bdev_size > THIN_METADATA_MAX_SECTORS)
471 pmd->time = 0; 443 bdev_size = THIN_METADATA_MAX_SECTORS;
472 pmd->need_commit = 0; 444
473 pmd->details_root = 0; 445 r = dm_sm_root_size(pmd->metadata_sm, &metadata_len);
474 pmd->trans_id = 0; 446 if (r < 0)
475 pmd->flags = 0; 447 return r;
476 INIT_LIST_HEAD(&pmd->thin_devices); 448
449 r = dm_sm_root_size(pmd->data_sm, &data_len);
450 if (r < 0)
451 return r;
452
453 r = dm_sm_commit(pmd->data_sm);
454 if (r < 0)
455 return r;
456
457 r = dm_tm_pre_commit(pmd->tm);
458 if (r < 0)
459 return r;
460
461 r = superblock_lock_zero(pmd, &sblock);
462 if (r)
463 return r;
464
465 disk_super = dm_block_data(sblock);
466 disk_super->flags = 0;
467 memset(disk_super->uuid, 0, sizeof(disk_super->uuid));
468 disk_super->magic = cpu_to_le64(THIN_SUPERBLOCK_MAGIC);
469 disk_super->version = cpu_to_le32(THIN_VERSION);
470 disk_super->time = 0;
471 disk_super->trans_id = 0;
472 disk_super->held_root = 0;
473
474 r = dm_sm_copy_root(pmd->metadata_sm, &disk_super->metadata_space_map_root,
475 metadata_len);
476 if (r < 0)
477 goto bad_locked;
478
479 r = dm_sm_copy_root(pmd->data_sm, &disk_super->data_space_map_root,
480 data_len);
481 if (r < 0)
482 goto bad_locked;
483
484 disk_super->data_mapping_root = cpu_to_le64(pmd->root);
485 disk_super->device_details_root = cpu_to_le64(pmd->details_root);
486 disk_super->metadata_block_size = cpu_to_le32(THIN_METADATA_BLOCK_SIZE >> SECTOR_SHIFT);
487 disk_super->metadata_nr_blocks = cpu_to_le64(bdev_size >> SECTOR_TO_BLOCK_SHIFT);
488 disk_super->data_block_size = cpu_to_le32(pmd->data_block_size);
489
490 return dm_tm_commit(pmd->tm, sblock);
491
492bad_locked:
493 dm_bm_unlock(sblock);
494 return r;
495}
496
497static int __format_metadata(struct dm_pool_metadata *pmd)
498{
499 int r;
500
501 r = dm_tm_create_with_sm(pmd->bm, THIN_SUPERBLOCK_LOCATION,
502 &pmd->tm, &pmd->metadata_sm);
503 if (r < 0) {
504 DMERR("tm_create_with_sm failed");
505 return r;
506 }
507
508 pmd->data_sm = dm_sm_disk_create(pmd->tm, 0);
509 if (IS_ERR(pmd->data_sm)) {
510 DMERR("sm_disk_create failed");
511 r = PTR_ERR(pmd->data_sm);
512 goto bad_cleanup_tm;
513 }
514
515 pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm);
516 if (!pmd->nb_tm) {
517 DMERR("could not create non-blocking clone tm");
518 r = -ENOMEM;
519 goto bad_cleanup_data_sm;
520 }
521
522 __setup_btree_details(pmd);
523
524 r = dm_btree_empty(&pmd->info, &pmd->root);
525 if (r < 0)
526 goto bad_cleanup_nb_tm;
527
528 r = dm_btree_empty(&pmd->details_info, &pmd->details_root);
529 if (r < 0) {
530 DMERR("couldn't create devices root");
531 goto bad_cleanup_nb_tm;
532 }
533
534 r = __write_initial_superblock(pmd);
535 if (r)
536 goto bad_cleanup_nb_tm;
477 537
478 return 0; 538 return 0;
479 539
480bad_data_sm: 540bad_cleanup_nb_tm:
481 dm_sm_destroy(data_sm); 541 dm_tm_destroy(pmd->nb_tm);
482bad: 542bad_cleanup_data_sm:
483 dm_tm_destroy(tm); 543 dm_sm_destroy(pmd->data_sm);
484 dm_sm_destroy(sm); 544bad_cleanup_tm:
545 dm_tm_destroy(pmd->tm);
546 dm_sm_destroy(pmd->metadata_sm);
547
548 return r;
549}
550
551static int __check_incompat_features(struct thin_disk_superblock *disk_super,
552 struct dm_pool_metadata *pmd)
553{
554 uint32_t features;
555
556 features = le32_to_cpu(disk_super->incompat_flags) & ~THIN_FEATURE_INCOMPAT_SUPP;
557 if (features) {
558 DMERR("could not access metadata due to unsupported optional features (%lx).",
559 (unsigned long)features);
560 return -EINVAL;
561 }
562
563 /*
564 * Check for read-only metadata to skip the following RDWR checks.
565 */
566 if (get_disk_ro(pmd->bdev->bd_disk))
567 return 0;
568
569 features = le32_to_cpu(disk_super->compat_ro_flags) & ~THIN_FEATURE_COMPAT_RO_SUPP;
570 if (features) {
571 DMERR("could not access metadata RDWR due to unsupported optional features (%lx).",
572 (unsigned long)features);
573 return -EINVAL;
574 }
575
576 return 0;
577}
578
579static int __open_metadata(struct dm_pool_metadata *pmd)
580{
581 int r;
582 struct dm_block *sblock;
583 struct thin_disk_superblock *disk_super;
584
585 r = dm_bm_read_lock(pmd->bm, THIN_SUPERBLOCK_LOCATION,
586 &sb_validator, &sblock);
587 if (r < 0) {
588 DMERR("couldn't read superblock");
589 return r;
590 }
591
592 disk_super = dm_block_data(sblock);
593
594 r = __check_incompat_features(disk_super, pmd);
595 if (r < 0)
596 goto bad_unlock_sblock;
597
598 r = dm_tm_open_with_sm(pmd->bm, THIN_SUPERBLOCK_LOCATION,
599 disk_super->metadata_space_map_root,
600 sizeof(disk_super->metadata_space_map_root),
601 &pmd->tm, &pmd->metadata_sm);
602 if (r < 0) {
603 DMERR("tm_open_with_sm failed");
604 goto bad_unlock_sblock;
605 }
606
607 pmd->data_sm = dm_sm_disk_open(pmd->tm, disk_super->data_space_map_root,
608 sizeof(disk_super->data_space_map_root));
609 if (IS_ERR(pmd->data_sm)) {
610 DMERR("sm_disk_open failed");
611 r = PTR_ERR(pmd->data_sm);
612 goto bad_cleanup_tm;
613 }
614
615 pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm);
616 if (!pmd->nb_tm) {
617 DMERR("could not create non-blocking clone tm");
618 r = -ENOMEM;
619 goto bad_cleanup_data_sm;
620 }
621
622 __setup_btree_details(pmd);
623 return dm_bm_unlock(sblock);
624
625bad_cleanup_data_sm:
626 dm_sm_destroy(pmd->data_sm);
627bad_cleanup_tm:
628 dm_tm_destroy(pmd->tm);
629 dm_sm_destroy(pmd->metadata_sm);
630bad_unlock_sblock:
631 dm_bm_unlock(sblock);
632
633 return r;
634}
635
636static int __open_or_format_metadata(struct dm_pool_metadata *pmd, bool format_device)
637{
638 int r, unformatted;
639
640 r = __superblock_all_zeroes(pmd->bm, &unformatted);
641 if (r)
642 return r;
643
644 if (unformatted)
645 return format_device ? __format_metadata(pmd) : -EPERM;
646
647 return __open_metadata(pmd);
648}
649
650static int __create_persistent_data_objects(struct dm_pool_metadata *pmd, bool format_device)
651{
652 int r;
653
654 pmd->bm = dm_block_manager_create(pmd->bdev, THIN_METADATA_BLOCK_SIZE,
655 THIN_METADATA_CACHE_SIZE,
656 THIN_MAX_CONCURRENT_LOCKS);
657 if (IS_ERR(pmd->bm)) {
658 DMERR("could not create block manager");
659 return PTR_ERR(pmd->bm);
660 }
661
662 r = __open_or_format_metadata(pmd, format_device);
663 if (r)
664 dm_block_manager_destroy(pmd->bm);
485 665
486 return r; 666 return r;
487} 667}
488 668
669static void __destroy_persistent_data_objects(struct dm_pool_metadata *pmd)
670{
671 dm_sm_destroy(pmd->data_sm);
672 dm_sm_destroy(pmd->metadata_sm);
673 dm_tm_destroy(pmd->nb_tm);
674 dm_tm_destroy(pmd->tm);
675 dm_block_manager_destroy(pmd->bm);
676}
677
489static int __begin_transaction(struct dm_pool_metadata *pmd) 678static int __begin_transaction(struct dm_pool_metadata *pmd)
490{ 679{
491 int r; 680 int r;
492 u32 features;
493 struct thin_disk_superblock *disk_super; 681 struct thin_disk_superblock *disk_super;
494 struct dm_block *sblock; 682 struct dm_block *sblock;
495 683
496 /* 684 /*
497 * __maybe_commit_transaction() resets these
498 */
499 WARN_ON(pmd->need_commit);
500
501 /*
502 * We re-read the superblock every time. Shouldn't need to do this 685 * We re-read the superblock every time. Shouldn't need to do this
503 * really. 686 * really.
504 */ 687 */
@@ -515,32 +698,8 @@ static int __begin_transaction(struct dm_pool_metadata *pmd)
515 pmd->flags = le32_to_cpu(disk_super->flags); 698 pmd->flags = le32_to_cpu(disk_super->flags);
516 pmd->data_block_size = le32_to_cpu(disk_super->data_block_size); 699 pmd->data_block_size = le32_to_cpu(disk_super->data_block_size);
517 700
518 features = le32_to_cpu(disk_super->incompat_flags) & ~THIN_FEATURE_INCOMPAT_SUPP;
519 if (features) {
520 DMERR("could not access metadata due to "
521 "unsupported optional features (%lx).",
522 (unsigned long)features);
523 r = -EINVAL;
524 goto out;
525 }
526
527 /*
528 * Check for read-only metadata to skip the following RDWR checks.
529 */
530 if (get_disk_ro(pmd->bdev->bd_disk))
531 goto out;
532
533 features = le32_to_cpu(disk_super->compat_ro_flags) & ~THIN_FEATURE_COMPAT_RO_SUPP;
534 if (features) {
535 DMERR("could not access metadata RDWR due to "
536 "unsupported optional features (%lx).",
537 (unsigned long)features);
538 r = -EINVAL;
539 }
540
541out:
542 dm_bm_unlock(sblock); 701 dm_bm_unlock(sblock);
543 return r; 702 return 0;
544} 703}
545 704
546static int __write_changed_details(struct dm_pool_metadata *pmd) 705static int __write_changed_details(struct dm_pool_metadata *pmd)
@@ -573,8 +732,6 @@ static int __write_changed_details(struct dm_pool_metadata *pmd)
573 list_del(&td->list); 732 list_del(&td->list);
574 kfree(td); 733 kfree(td);
575 } 734 }
576
577 pmd->need_commit = 1;
578 } 735 }
579 736
580 return 0; 737 return 0;
@@ -582,9 +739,6 @@ static int __write_changed_details(struct dm_pool_metadata *pmd)
582 739
583static int __commit_transaction(struct dm_pool_metadata *pmd) 740static int __commit_transaction(struct dm_pool_metadata *pmd)
584{ 741{
585 /*
586 * FIXME: Associated pool should be made read-only on failure.
587 */
588 int r; 742 int r;
589 size_t metadata_len, data_len; 743 size_t metadata_len, data_len;
590 struct thin_disk_superblock *disk_super; 744 struct thin_disk_superblock *disk_super;
@@ -597,31 +751,27 @@ static int __commit_transaction(struct dm_pool_metadata *pmd)
597 751
598 r = __write_changed_details(pmd); 752 r = __write_changed_details(pmd);
599 if (r < 0) 753 if (r < 0)
600 goto out; 754 return r;
601
602 if (!pmd->need_commit)
603 goto out;
604 755
605 r = dm_sm_commit(pmd->data_sm); 756 r = dm_sm_commit(pmd->data_sm);
606 if (r < 0) 757 if (r < 0)
607 goto out; 758 return r;
608 759
609 r = dm_tm_pre_commit(pmd->tm); 760 r = dm_tm_pre_commit(pmd->tm);
610 if (r < 0) 761 if (r < 0)
611 goto out; 762 return r;
612 763
613 r = dm_sm_root_size(pmd->metadata_sm, &metadata_len); 764 r = dm_sm_root_size(pmd->metadata_sm, &metadata_len);
614 if (r < 0) 765 if (r < 0)
615 goto out; 766 return r;
616 767
617 r = dm_sm_root_size(pmd->data_sm, &data_len); 768 r = dm_sm_root_size(pmd->data_sm, &data_len);
618 if (r < 0) 769 if (r < 0)
619 goto out; 770 return r;
620 771
621 r = dm_bm_write_lock(pmd->bm, THIN_SUPERBLOCK_LOCATION, 772 r = superblock_lock(pmd, &sblock);
622 &sb_validator, &sblock);
623 if (r) 773 if (r)
624 goto out; 774 return r;
625 775
626 disk_super = dm_block_data(sblock); 776 disk_super = dm_block_data(sblock);
627 disk_super->time = cpu_to_le32(pmd->time); 777 disk_super->time = cpu_to_le32(pmd->time);
@@ -640,12 +790,7 @@ static int __commit_transaction(struct dm_pool_metadata *pmd)
640 if (r < 0) 790 if (r < 0)
641 goto out_locked; 791 goto out_locked;
642 792
643 r = dm_tm_commit(pmd->tm, sblock); 793 return dm_tm_commit(pmd->tm, sblock);
644 if (!r)
645 pmd->need_commit = 0;
646
647out:
648 return r;
649 794
650out_locked: 795out_locked:
651 dm_bm_unlock(sblock); 796 dm_bm_unlock(sblock);
@@ -653,15 +798,11 @@ out_locked:
653} 798}
654 799
655struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev, 800struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
656 sector_t data_block_size) 801 sector_t data_block_size,
802 bool format_device)
657{ 803{
658 int r; 804 int r;
659 struct thin_disk_superblock *disk_super;
660 struct dm_pool_metadata *pmd; 805 struct dm_pool_metadata *pmd;
661 sector_t bdev_size = i_size_read(bdev->bd_inode) >> SECTOR_SHIFT;
662 struct dm_block_manager *bm;
663 int create;
664 struct dm_block *sblock;
665 806
666 pmd = kmalloc(sizeof(*pmd), GFP_KERNEL); 807 pmd = kmalloc(sizeof(*pmd), GFP_KERNEL);
667 if (!pmd) { 808 if (!pmd) {
@@ -669,90 +810,28 @@ struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
669 return ERR_PTR(-ENOMEM); 810 return ERR_PTR(-ENOMEM);
670 } 811 }
671 812
672 /* 813 init_rwsem(&pmd->root_lock);
673 * Max hex locks: 814 pmd->time = 0;
674 * 3 for btree insert + 815 INIT_LIST_HEAD(&pmd->thin_devices);
675 * 2 for btree lookup used within space map 816 pmd->read_only = false;
676 */ 817 pmd->fail_io = false;
677 bm = dm_block_manager_create(bdev, THIN_METADATA_BLOCK_SIZE, 818 pmd->bdev = bdev;
678 THIN_METADATA_CACHE_SIZE, 5); 819 pmd->data_block_size = data_block_size;
679 if (!bm) {
680 DMERR("could not create block manager");
681 kfree(pmd);
682 return ERR_PTR(-ENOMEM);
683 }
684
685 r = superblock_all_zeroes(bm, &create);
686 if (r) {
687 dm_block_manager_destroy(bm);
688 kfree(pmd);
689 return ERR_PTR(r);
690 }
691
692 820
693 r = init_pmd(pmd, bm, 0, create); 821 r = __create_persistent_data_objects(pmd, format_device);
694 if (r) { 822 if (r) {
695 dm_block_manager_destroy(bm);
696 kfree(pmd); 823 kfree(pmd);
697 return ERR_PTR(r); 824 return ERR_PTR(r);
698 } 825 }
699 pmd->bdev = bdev;
700
701 if (!create) {
702 r = __begin_transaction(pmd);
703 if (r < 0)
704 goto bad;
705 return pmd;
706 }
707
708 /*
709 * Create.
710 */
711 r = dm_bm_write_lock(pmd->bm, THIN_SUPERBLOCK_LOCATION,
712 &sb_validator, &sblock);
713 if (r)
714 goto bad;
715
716 if (bdev_size > THIN_METADATA_MAX_SECTORS)
717 bdev_size = THIN_METADATA_MAX_SECTORS;
718
719 disk_super = dm_block_data(sblock);
720 disk_super->magic = cpu_to_le64(THIN_SUPERBLOCK_MAGIC);
721 disk_super->version = cpu_to_le32(THIN_VERSION);
722 disk_super->time = 0;
723 disk_super->metadata_block_size = cpu_to_le32(THIN_METADATA_BLOCK_SIZE >> SECTOR_SHIFT);
724 disk_super->metadata_nr_blocks = cpu_to_le64(bdev_size >> SECTOR_TO_BLOCK_SHIFT);
725 disk_super->data_block_size = cpu_to_le32(data_block_size);
726
727 r = dm_bm_unlock(sblock);
728 if (r < 0)
729 goto bad;
730
731 r = dm_btree_empty(&pmd->info, &pmd->root);
732 if (r < 0)
733 goto bad;
734
735 r = dm_btree_empty(&pmd->details_info, &pmd->details_root);
736 if (r < 0) {
737 DMERR("couldn't create devices root");
738 goto bad;
739 }
740 826
741 pmd->flags = 0; 827 r = __begin_transaction(pmd);
742 pmd->need_commit = 1;
743 r = dm_pool_commit_metadata(pmd);
744 if (r < 0) { 828 if (r < 0) {
745 DMERR("%s: dm_pool_commit_metadata() failed, error = %d", 829 if (dm_pool_metadata_close(pmd) < 0)
746 __func__, r); 830 DMWARN("%s: dm_pool_metadata_close() failed.", __func__);
747 goto bad; 831 return ERR_PTR(r);
748 } 832 }
749 833
750 return pmd; 834 return pmd;
751
752bad:
753 if (dm_pool_metadata_close(pmd) < 0)
754 DMWARN("%s: dm_pool_metadata_close() failed.", __func__);
755 return ERR_PTR(r);
756} 835}
757 836
758int dm_pool_metadata_close(struct dm_pool_metadata *pmd) 837int dm_pool_metadata_close(struct dm_pool_metadata *pmd)
@@ -778,18 +857,17 @@ int dm_pool_metadata_close(struct dm_pool_metadata *pmd)
778 return -EBUSY; 857 return -EBUSY;
779 } 858 }
780 859
781 r = __commit_transaction(pmd); 860 if (!pmd->read_only && !pmd->fail_io) {
782 if (r < 0) 861 r = __commit_transaction(pmd);
783 DMWARN("%s: __commit_transaction() failed, error = %d", 862 if (r < 0)
784 __func__, r); 863 DMWARN("%s: __commit_transaction() failed, error = %d",
864 __func__, r);
865 }
785 866
786 dm_tm_destroy(pmd->tm); 867 if (!pmd->fail_io)
787 dm_tm_destroy(pmd->nb_tm); 868 __destroy_persistent_data_objects(pmd);
788 dm_block_manager_destroy(pmd->bm);
789 dm_sm_destroy(pmd->metadata_sm);
790 dm_sm_destroy(pmd->data_sm);
791 kfree(pmd);
792 869
870 kfree(pmd);
793 return 0; 871 return 0;
794} 872}
795 873
@@ -850,6 +928,7 @@ static int __open_device(struct dm_pool_metadata *pmd,
850 (*td)->id = dev; 928 (*td)->id = dev;
851 (*td)->open_count = 1; 929 (*td)->open_count = 1;
852 (*td)->changed = changed; 930 (*td)->changed = changed;
931 (*td)->aborted_with_changes = false;
853 (*td)->mapped_blocks = le64_to_cpu(details_le.mapped_blocks); 932 (*td)->mapped_blocks = le64_to_cpu(details_le.mapped_blocks);
854 (*td)->transaction_id = le64_to_cpu(details_le.transaction_id); 933 (*td)->transaction_id = le64_to_cpu(details_le.transaction_id);
855 (*td)->creation_time = le32_to_cpu(details_le.creation_time); 934 (*td)->creation_time = le32_to_cpu(details_le.creation_time);
@@ -911,10 +990,11 @@ static int __create_thin(struct dm_pool_metadata *pmd,
911 990
912int dm_pool_create_thin(struct dm_pool_metadata *pmd, dm_thin_id dev) 991int dm_pool_create_thin(struct dm_pool_metadata *pmd, dm_thin_id dev)
913{ 992{
914 int r; 993 int r = -EINVAL;
915 994
916 down_write(&pmd->root_lock); 995 down_write(&pmd->root_lock);
917 r = __create_thin(pmd, dev); 996 if (!pmd->fail_io)
997 r = __create_thin(pmd, dev);
918 up_write(&pmd->root_lock); 998 up_write(&pmd->root_lock);
919 999
920 return r; 1000 return r;
@@ -1001,10 +1081,11 @@ int dm_pool_create_snap(struct dm_pool_metadata *pmd,
1001 dm_thin_id dev, 1081 dm_thin_id dev,
1002 dm_thin_id origin) 1082 dm_thin_id origin)
1003{ 1083{
1004 int r; 1084 int r = -EINVAL;
1005 1085
1006 down_write(&pmd->root_lock); 1086 down_write(&pmd->root_lock);
1007 r = __create_snap(pmd, dev, origin); 1087 if (!pmd->fail_io)
1088 r = __create_snap(pmd, dev, origin);
1008 up_write(&pmd->root_lock); 1089 up_write(&pmd->root_lock);
1009 1090
1010 return r; 1091 return r;
@@ -1037,18 +1118,17 @@ static int __delete_device(struct dm_pool_metadata *pmd, dm_thin_id dev)
1037 if (r) 1118 if (r)
1038 return r; 1119 return r;
1039 1120
1040 pmd->need_commit = 1;
1041
1042 return 0; 1121 return 0;
1043} 1122}
1044 1123
1045int dm_pool_delete_thin_device(struct dm_pool_metadata *pmd, 1124int dm_pool_delete_thin_device(struct dm_pool_metadata *pmd,
1046 dm_thin_id dev) 1125 dm_thin_id dev)
1047{ 1126{
1048 int r; 1127 int r = -EINVAL;
1049 1128
1050 down_write(&pmd->root_lock); 1129 down_write(&pmd->root_lock);
1051 r = __delete_device(pmd, dev); 1130 if (!pmd->fail_io)
1131 r = __delete_device(pmd, dev);
1052 up_write(&pmd->root_lock); 1132 up_write(&pmd->root_lock);
1053 1133
1054 return r; 1134 return r;
@@ -1058,28 +1138,40 @@ int dm_pool_set_metadata_transaction_id(struct dm_pool_metadata *pmd,
1058 uint64_t current_id, 1138 uint64_t current_id,
1059 uint64_t new_id) 1139 uint64_t new_id)
1060{ 1140{
1141 int r = -EINVAL;
1142
1061 down_write(&pmd->root_lock); 1143 down_write(&pmd->root_lock);
1144
1145 if (pmd->fail_io)
1146 goto out;
1147
1062 if (pmd->trans_id != current_id) { 1148 if (pmd->trans_id != current_id) {
1063 up_write(&pmd->root_lock);
1064 DMERR("mismatched transaction id"); 1149 DMERR("mismatched transaction id");
1065 return -EINVAL; 1150 goto out;
1066 } 1151 }
1067 1152
1068 pmd->trans_id = new_id; 1153 pmd->trans_id = new_id;
1069 pmd->need_commit = 1; 1154 r = 0;
1155
1156out:
1070 up_write(&pmd->root_lock); 1157 up_write(&pmd->root_lock);
1071 1158
1072 return 0; 1159 return r;
1073} 1160}
1074 1161
1075int dm_pool_get_metadata_transaction_id(struct dm_pool_metadata *pmd, 1162int dm_pool_get_metadata_transaction_id(struct dm_pool_metadata *pmd,
1076 uint64_t *result) 1163 uint64_t *result)
1077{ 1164{
1165 int r = -EINVAL;
1166
1078 down_read(&pmd->root_lock); 1167 down_read(&pmd->root_lock);
1079 *result = pmd->trans_id; 1168 if (!pmd->fail_io) {
1169 *result = pmd->trans_id;
1170 r = 0;
1171 }
1080 up_read(&pmd->root_lock); 1172 up_read(&pmd->root_lock);
1081 1173
1082 return 0; 1174 return r;
1083} 1175}
1084 1176
1085static int __reserve_metadata_snap(struct dm_pool_metadata *pmd) 1177static int __reserve_metadata_snap(struct dm_pool_metadata *pmd)
@@ -1108,8 +1200,6 @@ static int __reserve_metadata_snap(struct dm_pool_metadata *pmd)
1108 1200
1109 dm_tm_dec(pmd->tm, held_root); 1201 dm_tm_dec(pmd->tm, held_root);
1110 dm_tm_unlock(pmd->tm, copy); 1202 dm_tm_unlock(pmd->tm, copy);
1111 pmd->need_commit = 1;
1112
1113 return -EBUSY; 1203 return -EBUSY;
1114 } 1204 }
1115 1205
@@ -1131,29 +1221,25 @@ static int __reserve_metadata_snap(struct dm_pool_metadata *pmd)
1131 /* 1221 /*
1132 * Write the held root into the superblock. 1222 * Write the held root into the superblock.
1133 */ 1223 */
1134 r = dm_bm_write_lock(pmd->bm, THIN_SUPERBLOCK_LOCATION, 1224 r = superblock_lock(pmd, &sblock);
1135 &sb_validator, &sblock);
1136 if (r) { 1225 if (r) {
1137 dm_tm_dec(pmd->tm, held_root); 1226 dm_tm_dec(pmd->tm, held_root);
1138 pmd->need_commit = 1;
1139 return r; 1227 return r;
1140 } 1228 }
1141 1229
1142 disk_super = dm_block_data(sblock); 1230 disk_super = dm_block_data(sblock);
1143 disk_super->held_root = cpu_to_le64(held_root); 1231 disk_super->held_root = cpu_to_le64(held_root);
1144 dm_bm_unlock(sblock); 1232 dm_bm_unlock(sblock);
1145
1146 pmd->need_commit = 1;
1147
1148 return 0; 1233 return 0;
1149} 1234}
1150 1235
1151int dm_pool_reserve_metadata_snap(struct dm_pool_metadata *pmd) 1236int dm_pool_reserve_metadata_snap(struct dm_pool_metadata *pmd)
1152{ 1237{
1153 int r; 1238 int r = -EINVAL;
1154 1239
1155 down_write(&pmd->root_lock); 1240 down_write(&pmd->root_lock);
1156 r = __reserve_metadata_snap(pmd); 1241 if (!pmd->fail_io)
1242 r = __reserve_metadata_snap(pmd);
1157 up_write(&pmd->root_lock); 1243 up_write(&pmd->root_lock);
1158 1244
1159 return r; 1245 return r;
@@ -1166,15 +1252,13 @@ static int __release_metadata_snap(struct dm_pool_metadata *pmd)
1166 struct dm_block *sblock, *copy; 1252 struct dm_block *sblock, *copy;
1167 dm_block_t held_root; 1253 dm_block_t held_root;
1168 1254
1169 r = dm_bm_write_lock(pmd->bm, THIN_SUPERBLOCK_LOCATION, 1255 r = superblock_lock(pmd, &sblock);
1170 &sb_validator, &sblock);
1171 if (r) 1256 if (r)
1172 return r; 1257 return r;
1173 1258
1174 disk_super = dm_block_data(sblock); 1259 disk_super = dm_block_data(sblock);
1175 held_root = le64_to_cpu(disk_super->held_root); 1260 held_root = le64_to_cpu(disk_super->held_root);
1176 disk_super->held_root = cpu_to_le64(0); 1261 disk_super->held_root = cpu_to_le64(0);
1177 pmd->need_commit = 1;
1178 1262
1179 dm_bm_unlock(sblock); 1263 dm_bm_unlock(sblock);
1180 1264
@@ -1197,10 +1281,11 @@ static int __release_metadata_snap(struct dm_pool_metadata *pmd)
1197 1281
1198int dm_pool_release_metadata_snap(struct dm_pool_metadata *pmd) 1282int dm_pool_release_metadata_snap(struct dm_pool_metadata *pmd)
1199{ 1283{
1200 int r; 1284 int r = -EINVAL;
1201 1285
1202 down_write(&pmd->root_lock); 1286 down_write(&pmd->root_lock);
1203 r = __release_metadata_snap(pmd); 1287 if (!pmd->fail_io)
1288 r = __release_metadata_snap(pmd);
1204 up_write(&pmd->root_lock); 1289 up_write(&pmd->root_lock);
1205 1290
1206 return r; 1291 return r;
@@ -1227,10 +1312,11 @@ static int __get_metadata_snap(struct dm_pool_metadata *pmd,
1227int dm_pool_get_metadata_snap(struct dm_pool_metadata *pmd, 1312int dm_pool_get_metadata_snap(struct dm_pool_metadata *pmd,
1228 dm_block_t *result) 1313 dm_block_t *result)
1229{ 1314{
1230 int r; 1315 int r = -EINVAL;
1231 1316
1232 down_read(&pmd->root_lock); 1317 down_read(&pmd->root_lock);
1233 r = __get_metadata_snap(pmd, result); 1318 if (!pmd->fail_io)
1319 r = __get_metadata_snap(pmd, result);
1234 up_read(&pmd->root_lock); 1320 up_read(&pmd->root_lock);
1235 1321
1236 return r; 1322 return r;
@@ -1239,10 +1325,11 @@ int dm_pool_get_metadata_snap(struct dm_pool_metadata *pmd,
1239int dm_pool_open_thin_device(struct dm_pool_metadata *pmd, dm_thin_id dev, 1325int dm_pool_open_thin_device(struct dm_pool_metadata *pmd, dm_thin_id dev,
1240 struct dm_thin_device **td) 1326 struct dm_thin_device **td)
1241{ 1327{
1242 int r; 1328 int r = -EINVAL;
1243 1329
1244 down_write(&pmd->root_lock); 1330 down_write(&pmd->root_lock);
1245 r = __open_device(pmd, dev, 0, td); 1331 if (!pmd->fail_io)
1332 r = __open_device(pmd, dev, 0, td);
1246 up_write(&pmd->root_lock); 1333 up_write(&pmd->root_lock);
1247 1334
1248 return r; 1335 return r;
@@ -1262,7 +1349,7 @@ dm_thin_id dm_thin_dev_id(struct dm_thin_device *td)
1262 return td->id; 1349 return td->id;
1263} 1350}
1264 1351
1265static int __snapshotted_since(struct dm_thin_device *td, uint32_t time) 1352static bool __snapshotted_since(struct dm_thin_device *td, uint32_t time)
1266{ 1353{
1267 return td->snapshotted_time > time; 1354 return td->snapshotted_time > time;
1268} 1355}
@@ -1270,28 +1357,31 @@ static int __snapshotted_since(struct dm_thin_device *td, uint32_t time)
1270int dm_thin_find_block(struct dm_thin_device *td, dm_block_t block, 1357int dm_thin_find_block(struct dm_thin_device *td, dm_block_t block,
1271 int can_block, struct dm_thin_lookup_result *result) 1358 int can_block, struct dm_thin_lookup_result *result)
1272{ 1359{
1273 int r; 1360 int r = -EINVAL;
1274 uint64_t block_time = 0; 1361 uint64_t block_time = 0;
1275 __le64 value; 1362 __le64 value;
1276 struct dm_pool_metadata *pmd = td->pmd; 1363 struct dm_pool_metadata *pmd = td->pmd;
1277 dm_block_t keys[2] = { td->id, block }; 1364 dm_block_t keys[2] = { td->id, block };
1365 struct dm_btree_info *info;
1278 1366
1279 if (can_block) { 1367 if (can_block) {
1280 down_read(&pmd->root_lock); 1368 down_read(&pmd->root_lock);
1281 r = dm_btree_lookup(&pmd->info, pmd->root, keys, &value); 1369 info = &pmd->info;
1282 if (!r) 1370 } else if (down_read_trylock(&pmd->root_lock))
1283 block_time = le64_to_cpu(value); 1371 info = &pmd->nb_info;
1284 up_read(&pmd->root_lock); 1372 else
1285
1286 } else if (down_read_trylock(&pmd->root_lock)) {
1287 r = dm_btree_lookup(&pmd->nb_info, pmd->root, keys, &value);
1288 if (!r)
1289 block_time = le64_to_cpu(value);
1290 up_read(&pmd->root_lock);
1291
1292 } else
1293 return -EWOULDBLOCK; 1373 return -EWOULDBLOCK;
1294 1374
1375 if (pmd->fail_io)
1376 goto out;
1377
1378 r = dm_btree_lookup(info, pmd->root, keys, &value);
1379 if (!r)
1380 block_time = le64_to_cpu(value);
1381
1382out:
1383 up_read(&pmd->root_lock);
1384
1295 if (!r) { 1385 if (!r) {
1296 dm_block_t exception_block; 1386 dm_block_t exception_block;
1297 uint32_t exception_time; 1387 uint32_t exception_time;
@@ -1312,7 +1402,6 @@ static int __insert(struct dm_thin_device *td, dm_block_t block,
1312 struct dm_pool_metadata *pmd = td->pmd; 1402 struct dm_pool_metadata *pmd = td->pmd;
1313 dm_block_t keys[2] = { td->id, block }; 1403 dm_block_t keys[2] = { td->id, block };
1314 1404
1315 pmd->need_commit = 1;
1316 value = cpu_to_le64(pack_block_time(data_block, pmd->time)); 1405 value = cpu_to_le64(pack_block_time(data_block, pmd->time));
1317 __dm_bless_for_disk(&value); 1406 __dm_bless_for_disk(&value);
1318 1407
@@ -1321,10 +1410,9 @@ static int __insert(struct dm_thin_device *td, dm_block_t block,
1321 if (r) 1410 if (r)
1322 return r; 1411 return r;
1323 1412
1324 if (inserted) { 1413 td->changed = 1;
1414 if (inserted)
1325 td->mapped_blocks++; 1415 td->mapped_blocks++;
1326 td->changed = 1;
1327 }
1328 1416
1329 return 0; 1417 return 0;
1330} 1418}
@@ -1332,10 +1420,11 @@ static int __insert(struct dm_thin_device *td, dm_block_t block,
1332int dm_thin_insert_block(struct dm_thin_device *td, dm_block_t block, 1420int dm_thin_insert_block(struct dm_thin_device *td, dm_block_t block,
1333 dm_block_t data_block) 1421 dm_block_t data_block)
1334{ 1422{
1335 int r; 1423 int r = -EINVAL;
1336 1424
1337 down_write(&td->pmd->root_lock); 1425 down_write(&td->pmd->root_lock);
1338 r = __insert(td, block, data_block); 1426 if (!td->pmd->fail_io)
1427 r = __insert(td, block, data_block);
1339 up_write(&td->pmd->root_lock); 1428 up_write(&td->pmd->root_lock);
1340 1429
1341 return r; 1430 return r;
@@ -1353,31 +1442,51 @@ static int __remove(struct dm_thin_device *td, dm_block_t block)
1353 1442
1354 td->mapped_blocks--; 1443 td->mapped_blocks--;
1355 td->changed = 1; 1444 td->changed = 1;
1356 pmd->need_commit = 1;
1357 1445
1358 return 0; 1446 return 0;
1359} 1447}
1360 1448
1361int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block) 1449int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block)
1362{ 1450{
1363 int r; 1451 int r = -EINVAL;
1364 1452
1365 down_write(&td->pmd->root_lock); 1453 down_write(&td->pmd->root_lock);
1366 r = __remove(td, block); 1454 if (!td->pmd->fail_io)
1455 r = __remove(td, block);
1367 up_write(&td->pmd->root_lock); 1456 up_write(&td->pmd->root_lock);
1368 1457
1369 return r; 1458 return r;
1370} 1459}
1371 1460
1372int dm_pool_alloc_data_block(struct dm_pool_metadata *pmd, dm_block_t *result) 1461bool dm_thin_changed_this_transaction(struct dm_thin_device *td)
1373{ 1462{
1374 int r; 1463 int r;
1375 1464
1376 down_write(&pmd->root_lock); 1465 down_read(&td->pmd->root_lock);
1466 r = td->changed;
1467 up_read(&td->pmd->root_lock);
1377 1468
1378 r = dm_sm_new_block(pmd->data_sm, result); 1469 return r;
1379 pmd->need_commit = 1; 1470}
1471
1472bool dm_thin_aborted_changes(struct dm_thin_device *td)
1473{
1474 bool r;
1380 1475
1476 down_read(&td->pmd->root_lock);
1477 r = td->aborted_with_changes;
1478 up_read(&td->pmd->root_lock);
1479
1480 return r;
1481}
1482
1483int dm_pool_alloc_data_block(struct dm_pool_metadata *pmd, dm_block_t *result)
1484{
1485 int r = -EINVAL;
1486
1487 down_write(&pmd->root_lock);
1488 if (!pmd->fail_io)
1489 r = dm_sm_new_block(pmd->data_sm, result);
1381 up_write(&pmd->root_lock); 1490 up_write(&pmd->root_lock);
1382 1491
1383 return r; 1492 return r;
@@ -1385,9 +1494,11 @@ int dm_pool_alloc_data_block(struct dm_pool_metadata *pmd, dm_block_t *result)
1385 1494
1386int dm_pool_commit_metadata(struct dm_pool_metadata *pmd) 1495int dm_pool_commit_metadata(struct dm_pool_metadata *pmd)
1387{ 1496{
1388 int r; 1497 int r = -EINVAL;
1389 1498
1390 down_write(&pmd->root_lock); 1499 down_write(&pmd->root_lock);
1500 if (pmd->fail_io)
1501 goto out;
1391 1502
1392 r = __commit_transaction(pmd); 1503 r = __commit_transaction(pmd);
1393 if (r <= 0) 1504 if (r <= 0)
@@ -1402,12 +1513,41 @@ out:
1402 return r; 1513 return r;
1403} 1514}
1404 1515
1516static void __set_abort_with_changes_flags(struct dm_pool_metadata *pmd)
1517{
1518 struct dm_thin_device *td;
1519
1520 list_for_each_entry(td, &pmd->thin_devices, list)
1521 td->aborted_with_changes = td->changed;
1522}
1523
1524int dm_pool_abort_metadata(struct dm_pool_metadata *pmd)
1525{
1526 int r = -EINVAL;
1527
1528 down_write(&pmd->root_lock);
1529 if (pmd->fail_io)
1530 goto out;
1531
1532 __set_abort_with_changes_flags(pmd);
1533 __destroy_persistent_data_objects(pmd);
1534 r = __create_persistent_data_objects(pmd, false);
1535 if (r)
1536 pmd->fail_io = true;
1537
1538out:
1539 up_write(&pmd->root_lock);
1540
1541 return r;
1542}
1543
1405int dm_pool_get_free_block_count(struct dm_pool_metadata *pmd, dm_block_t *result) 1544int dm_pool_get_free_block_count(struct dm_pool_metadata *pmd, dm_block_t *result)
1406{ 1545{
1407 int r; 1546 int r = -EINVAL;
1408 1547
1409 down_read(&pmd->root_lock); 1548 down_read(&pmd->root_lock);
1410 r = dm_sm_get_nr_free(pmd->data_sm, result); 1549 if (!pmd->fail_io)
1550 r = dm_sm_get_nr_free(pmd->data_sm, result);
1411 up_read(&pmd->root_lock); 1551 up_read(&pmd->root_lock);
1412 1552
1413 return r; 1553 return r;
@@ -1416,10 +1556,11 @@ int dm_pool_get_free_block_count(struct dm_pool_metadata *pmd, dm_block_t *resul
1416int dm_pool_get_free_metadata_block_count(struct dm_pool_metadata *pmd, 1556int dm_pool_get_free_metadata_block_count(struct dm_pool_metadata *pmd,
1417 dm_block_t *result) 1557 dm_block_t *result)
1418{ 1558{
1419 int r; 1559 int r = -EINVAL;
1420 1560
1421 down_read(&pmd->root_lock); 1561 down_read(&pmd->root_lock);
1422 r = dm_sm_get_nr_free(pmd->metadata_sm, result); 1562 if (!pmd->fail_io)
1563 r = dm_sm_get_nr_free(pmd->metadata_sm, result);
1423 up_read(&pmd->root_lock); 1564 up_read(&pmd->root_lock);
1424 1565
1425 return r; 1566 return r;
@@ -1428,10 +1569,11 @@ int dm_pool_get_free_metadata_block_count(struct dm_pool_metadata *pmd,
1428int dm_pool_get_metadata_dev_size(struct dm_pool_metadata *pmd, 1569int dm_pool_get_metadata_dev_size(struct dm_pool_metadata *pmd,
1429 dm_block_t *result) 1570 dm_block_t *result)
1430{ 1571{
1431 int r; 1572 int r = -EINVAL;
1432 1573
1433 down_read(&pmd->root_lock); 1574 down_read(&pmd->root_lock);
1434 r = dm_sm_get_nr_blocks(pmd->metadata_sm, result); 1575 if (!pmd->fail_io)
1576 r = dm_sm_get_nr_blocks(pmd->metadata_sm, result);
1435 up_read(&pmd->root_lock); 1577 up_read(&pmd->root_lock);
1436 1578
1437 return r; 1579 return r;
@@ -1448,10 +1590,11 @@ int dm_pool_get_data_block_size(struct dm_pool_metadata *pmd, sector_t *result)
1448 1590
1449int dm_pool_get_data_dev_size(struct dm_pool_metadata *pmd, dm_block_t *result) 1591int dm_pool_get_data_dev_size(struct dm_pool_metadata *pmd, dm_block_t *result)
1450{ 1592{
1451 int r; 1593 int r = -EINVAL;
1452 1594
1453 down_read(&pmd->root_lock); 1595 down_read(&pmd->root_lock);
1454 r = dm_sm_get_nr_blocks(pmd->data_sm, result); 1596 if (!pmd->fail_io)
1597 r = dm_sm_get_nr_blocks(pmd->data_sm, result);
1455 up_read(&pmd->root_lock); 1598 up_read(&pmd->root_lock);
1456 1599
1457 return r; 1600 return r;
@@ -1459,13 +1602,17 @@ int dm_pool_get_data_dev_size(struct dm_pool_metadata *pmd, dm_block_t *result)
1459 1602
1460int dm_thin_get_mapped_count(struct dm_thin_device *td, dm_block_t *result) 1603int dm_thin_get_mapped_count(struct dm_thin_device *td, dm_block_t *result)
1461{ 1604{
1605 int r = -EINVAL;
1462 struct dm_pool_metadata *pmd = td->pmd; 1606 struct dm_pool_metadata *pmd = td->pmd;
1463 1607
1464 down_read(&pmd->root_lock); 1608 down_read(&pmd->root_lock);
1465 *result = td->mapped_blocks; 1609 if (!pmd->fail_io) {
1610 *result = td->mapped_blocks;
1611 r = 0;
1612 }
1466 up_read(&pmd->root_lock); 1613 up_read(&pmd->root_lock);
1467 1614
1468 return 0; 1615 return r;
1469} 1616}
1470 1617
1471static int __highest_block(struct dm_thin_device *td, dm_block_t *result) 1618static int __highest_block(struct dm_thin_device *td, dm_block_t *result)
@@ -1487,11 +1634,12 @@ static int __highest_block(struct dm_thin_device *td, dm_block_t *result)
1487int dm_thin_get_highest_mapped_block(struct dm_thin_device *td, 1634int dm_thin_get_highest_mapped_block(struct dm_thin_device *td,
1488 dm_block_t *result) 1635 dm_block_t *result)
1489{ 1636{
1490 int r; 1637 int r = -EINVAL;
1491 struct dm_pool_metadata *pmd = td->pmd; 1638 struct dm_pool_metadata *pmd = td->pmd;
1492 1639
1493 down_read(&pmd->root_lock); 1640 down_read(&pmd->root_lock);
1494 r = __highest_block(td, result); 1641 if (!pmd->fail_io)
1642 r = __highest_block(td, result);
1495 up_read(&pmd->root_lock); 1643 up_read(&pmd->root_lock);
1496 1644
1497 return r; 1645 return r;
@@ -1514,20 +1662,25 @@ static int __resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_count)
1514 return -EINVAL; 1662 return -EINVAL;
1515 } 1663 }
1516 1664
1517 r = dm_sm_extend(pmd->data_sm, new_count - old_count); 1665 return dm_sm_extend(pmd->data_sm, new_count - old_count);
1518 if (!r)
1519 pmd->need_commit = 1;
1520
1521 return r;
1522} 1666}
1523 1667
1524int dm_pool_resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_count) 1668int dm_pool_resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_count)
1525{ 1669{
1526 int r; 1670 int r = -EINVAL;
1527 1671
1528 down_write(&pmd->root_lock); 1672 down_write(&pmd->root_lock);
1529 r = __resize_data_dev(pmd, new_count); 1673 if (!pmd->fail_io)
1674 r = __resize_data_dev(pmd, new_count);
1530 up_write(&pmd->root_lock); 1675 up_write(&pmd->root_lock);
1531 1676
1532 return r; 1677 return r;
1533} 1678}
1679
1680void dm_pool_metadata_read_only(struct dm_pool_metadata *pmd)
1681{
1682 down_write(&pmd->root_lock);
1683 pmd->read_only = true;
1684 dm_bm_set_read_only(pmd->bm);
1685 up_write(&pmd->root_lock);
1686}
diff --git a/drivers/md/dm-thin-metadata.h b/drivers/md/dm-thin-metadata.h
index b88918ccdaf6..0cecc3702885 100644
--- a/drivers/md/dm-thin-metadata.h
+++ b/drivers/md/dm-thin-metadata.h
@@ -38,7 +38,8 @@ typedef uint64_t dm_thin_id;
38 * Reopens or creates a new, empty metadata volume. 38 * Reopens or creates a new, empty metadata volume.
39 */ 39 */
40struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev, 40struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
41 sector_t data_block_size); 41 sector_t data_block_size,
42 bool format_device);
42 43
43int dm_pool_metadata_close(struct dm_pool_metadata *pmd); 44int dm_pool_metadata_close(struct dm_pool_metadata *pmd);
44 45
@@ -79,6 +80,16 @@ int dm_pool_delete_thin_device(struct dm_pool_metadata *pmd,
79int dm_pool_commit_metadata(struct dm_pool_metadata *pmd); 80int dm_pool_commit_metadata(struct dm_pool_metadata *pmd);
80 81
81/* 82/*
83 * Discards all uncommitted changes. Rereads the superblock, rolling back
84 * to the last good transaction. Thin devices remain open.
85 * dm_thin_aborted_changes() tells you if they had uncommitted changes.
86 *
87 * If this call fails it's only useful to call dm_pool_metadata_close().
88 * All other methods will fail with -EINVAL.
89 */
90int dm_pool_abort_metadata(struct dm_pool_metadata *pmd);
91
92/*
82 * Set/get userspace transaction id. 93 * Set/get userspace transaction id.
83 */ 94 */
84int dm_pool_set_metadata_transaction_id(struct dm_pool_metadata *pmd, 95int dm_pool_set_metadata_transaction_id(struct dm_pool_metadata *pmd,
@@ -119,7 +130,7 @@ dm_thin_id dm_thin_dev_id(struct dm_thin_device *td);
119 130
120struct dm_thin_lookup_result { 131struct dm_thin_lookup_result {
121 dm_block_t block; 132 dm_block_t block;
122 int shared; 133 unsigned shared:1;
123}; 134};
124 135
125/* 136/*
@@ -147,6 +158,10 @@ int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block);
147/* 158/*
148 * Queries. 159 * Queries.
149 */ 160 */
161bool dm_thin_changed_this_transaction(struct dm_thin_device *td);
162
163bool dm_thin_aborted_changes(struct dm_thin_device *td);
164
150int dm_thin_get_highest_mapped_block(struct dm_thin_device *td, 165int dm_thin_get_highest_mapped_block(struct dm_thin_device *td,
151 dm_block_t *highest_mapped); 166 dm_block_t *highest_mapped);
152 167
@@ -171,6 +186,12 @@ int dm_pool_get_data_dev_size(struct dm_pool_metadata *pmd, dm_block_t *result);
171 */ 186 */
172int dm_pool_resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_size); 187int dm_pool_resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_size);
173 188
189/*
190 * Flicks the underlying block manager into read only mode, so you know
191 * that nothing is changing.
192 */
193void dm_pool_metadata_read_only(struct dm_pool_metadata *pmd);
194
174/*----------------------------------------------------------------*/ 195/*----------------------------------------------------------------*/
175 196
176#endif 197#endif
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 68694da0d21d..af1fc3b2c2ad 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -1,10 +1,11 @@
1/* 1/*
2 * Copyright (C) 2011 Red Hat UK. 2 * Copyright (C) 2011-2012 Red Hat UK.
3 * 3 *
4 * This file is released under the GPL. 4 * This file is released under the GPL.
5 */ 5 */
6 6
7#include "dm-thin-metadata.h" 7#include "dm-thin-metadata.h"
8#include "dm.h"
8 9
9#include <linux/device-mapper.h> 10#include <linux/device-mapper.h>
10#include <linux/dm-io.h> 11#include <linux/dm-io.h>
@@ -19,7 +20,7 @@
19/* 20/*
20 * Tunable constants 21 * Tunable constants
21 */ 22 */
22#define ENDIO_HOOK_POOL_SIZE 10240 23#define ENDIO_HOOK_POOL_SIZE 1024
23#define DEFERRED_SET_SIZE 64 24#define DEFERRED_SET_SIZE 64
24#define MAPPING_POOL_SIZE 1024 25#define MAPPING_POOL_SIZE 1024
25#define PRISON_CELLS 1024 26#define PRISON_CELLS 1024
@@ -496,12 +497,27 @@ static void build_virtual_key(struct dm_thin_device *td, dm_block_t b,
496 */ 497 */
497struct dm_thin_new_mapping; 498struct dm_thin_new_mapping;
498 499
500/*
501 * The pool runs in 3 modes. Ordered in degraded order for comparisons.
502 */
503enum pool_mode {
504 PM_WRITE, /* metadata may be changed */
505 PM_READ_ONLY, /* metadata may not be changed */
506 PM_FAIL, /* all I/O fails */
507};
508
499struct pool_features { 509struct pool_features {
510 enum pool_mode mode;
511
500 unsigned zero_new_blocks:1; 512 unsigned zero_new_blocks:1;
501 unsigned discard_enabled:1; 513 unsigned discard_enabled:1;
502 unsigned discard_passdown:1; 514 unsigned discard_passdown:1;
503}; 515};
504 516
517struct thin_c;
518typedef void (*process_bio_fn)(struct thin_c *tc, struct bio *bio);
519typedef void (*process_mapping_fn)(struct dm_thin_new_mapping *m);
520
505struct pool { 521struct pool {
506 struct list_head list; 522 struct list_head list;
507 struct dm_target *ti; /* Only set if a pool target is bound */ 523 struct dm_target *ti; /* Only set if a pool target is bound */
@@ -510,10 +526,9 @@ struct pool {
510 struct block_device *md_dev; 526 struct block_device *md_dev;
511 struct dm_pool_metadata *pmd; 527 struct dm_pool_metadata *pmd;
512 528
513 uint32_t sectors_per_block;
514 unsigned block_shift;
515 dm_block_t offset_mask;
516 dm_block_t low_water_blocks; 529 dm_block_t low_water_blocks;
530 uint32_t sectors_per_block;
531 int sectors_per_block_shift;
517 532
518 struct pool_features pf; 533 struct pool_features pf;
519 unsigned low_water_triggered:1; /* A dm event has been sent */ 534 unsigned low_water_triggered:1; /* A dm event has been sent */
@@ -526,8 +541,8 @@ struct pool {
526 struct work_struct worker; 541 struct work_struct worker;
527 struct delayed_work waker; 542 struct delayed_work waker;
528 543
529 unsigned ref_count;
530 unsigned long last_commit_jiffies; 544 unsigned long last_commit_jiffies;
545 unsigned ref_count;
531 546
532 spinlock_t lock; 547 spinlock_t lock;
533 struct bio_list deferred_bios; 548 struct bio_list deferred_bios;
@@ -543,8 +558,17 @@ struct pool {
543 struct dm_thin_new_mapping *next_mapping; 558 struct dm_thin_new_mapping *next_mapping;
544 mempool_t *mapping_pool; 559 mempool_t *mapping_pool;
545 mempool_t *endio_hook_pool; 560 mempool_t *endio_hook_pool;
561
562 process_bio_fn process_bio;
563 process_bio_fn process_discard;
564
565 process_mapping_fn process_prepared_mapping;
566 process_mapping_fn process_prepared_discard;
546}; 567};
547 568
569static enum pool_mode get_pool_mode(struct pool *pool);
570static void set_pool_mode(struct pool *pool, enum pool_mode mode);
571
548/* 572/*
549 * Target context for a pool. 573 * Target context for a pool.
550 */ 574 */
@@ -679,16 +703,28 @@ static void requeue_io(struct thin_c *tc)
679 703
680static dm_block_t get_bio_block(struct thin_c *tc, struct bio *bio) 704static dm_block_t get_bio_block(struct thin_c *tc, struct bio *bio)
681{ 705{
682 return bio->bi_sector >> tc->pool->block_shift; 706 sector_t block_nr = bio->bi_sector;
707
708 if (tc->pool->sectors_per_block_shift < 0)
709 (void) sector_div(block_nr, tc->pool->sectors_per_block);
710 else
711 block_nr >>= tc->pool->sectors_per_block_shift;
712
713 return block_nr;
683} 714}
684 715
685static void remap(struct thin_c *tc, struct bio *bio, dm_block_t block) 716static void remap(struct thin_c *tc, struct bio *bio, dm_block_t block)
686{ 717{
687 struct pool *pool = tc->pool; 718 struct pool *pool = tc->pool;
719 sector_t bi_sector = bio->bi_sector;
688 720
689 bio->bi_bdev = tc->pool_dev->bdev; 721 bio->bi_bdev = tc->pool_dev->bdev;
690 bio->bi_sector = (block << pool->block_shift) + 722 if (tc->pool->sectors_per_block_shift < 0)
691 (bio->bi_sector & pool->offset_mask); 723 bio->bi_sector = (block * pool->sectors_per_block) +
724 sector_div(bi_sector, pool->sectors_per_block);
725 else
726 bio->bi_sector = (block << pool->sectors_per_block_shift) |
727 (bi_sector & (pool->sectors_per_block - 1));
692} 728}
693 729
694static void remap_to_origin(struct thin_c *tc, struct bio *bio) 730static void remap_to_origin(struct thin_c *tc, struct bio *bio)
@@ -696,21 +732,39 @@ static void remap_to_origin(struct thin_c *tc, struct bio *bio)
696 bio->bi_bdev = tc->origin_dev->bdev; 732 bio->bi_bdev = tc->origin_dev->bdev;
697} 733}
698 734
735static int bio_triggers_commit(struct thin_c *tc, struct bio *bio)
736{
737 return (bio->bi_rw & (REQ_FLUSH | REQ_FUA)) &&
738 dm_thin_changed_this_transaction(tc->td);
739}
740
699static void issue(struct thin_c *tc, struct bio *bio) 741static void issue(struct thin_c *tc, struct bio *bio)
700{ 742{
701 struct pool *pool = tc->pool; 743 struct pool *pool = tc->pool;
702 unsigned long flags; 744 unsigned long flags;
703 745
746 if (!bio_triggers_commit(tc, bio)) {
747 generic_make_request(bio);
748 return;
749 }
750
704 /* 751 /*
705 * Batch together any FUA/FLUSH bios we find and then issue 752 * Complete bio with an error if earlier I/O caused changes to
706 * a single commit for them in process_deferred_bios(). 753 * the metadata that can't be committed e.g, due to I/O errors
754 * on the metadata device.
707 */ 755 */
708 if (bio->bi_rw & (REQ_FLUSH | REQ_FUA)) { 756 if (dm_thin_aborted_changes(tc->td)) {
709 spin_lock_irqsave(&pool->lock, flags); 757 bio_io_error(bio);
710 bio_list_add(&pool->deferred_flush_bios, bio); 758 return;
711 spin_unlock_irqrestore(&pool->lock, flags); 759 }
712 } else 760
713 generic_make_request(bio); 761 /*
762 * Batch together any bios that trigger commits and then issue a
763 * single commit for them in process_deferred_bios().
764 */
765 spin_lock_irqsave(&pool->lock, flags);
766 bio_list_add(&pool->deferred_flush_bios, bio);
767 spin_unlock_irqrestore(&pool->lock, flags);
714} 768}
715 769
716static void remap_to_origin_and_issue(struct thin_c *tc, struct bio *bio) 770static void remap_to_origin_and_issue(struct thin_c *tc, struct bio *bio)
@@ -847,6 +901,14 @@ static void cell_defer_except(struct thin_c *tc, struct dm_bio_prison_cell *cell
847 wake_worker(pool); 901 wake_worker(pool);
848} 902}
849 903
904static void process_prepared_mapping_fail(struct dm_thin_new_mapping *m)
905{
906 if (m->bio)
907 m->bio->bi_end_io = m->saved_bi_end_io;
908 cell_error(m->cell);
909 list_del(&m->list);
910 mempool_free(m, m->tc->pool->mapping_pool);
911}
850static void process_prepared_mapping(struct dm_thin_new_mapping *m) 912static void process_prepared_mapping(struct dm_thin_new_mapping *m)
851{ 913{
852 struct thin_c *tc = m->tc; 914 struct thin_c *tc = m->tc;
@@ -859,7 +921,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m)
859 921
860 if (m->err) { 922 if (m->err) {
861 cell_error(m->cell); 923 cell_error(m->cell);
862 return; 924 goto out;
863 } 925 }
864 926
865 /* 927 /*
@@ -871,7 +933,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m)
871 if (r) { 933 if (r) {
872 DMERR("dm_thin_insert_block() failed"); 934 DMERR("dm_thin_insert_block() failed");
873 cell_error(m->cell); 935 cell_error(m->cell);
874 return; 936 goto out;
875 } 937 }
876 938
877 /* 939 /*
@@ -886,22 +948,25 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m)
886 } else 948 } else
887 cell_defer(tc, m->cell, m->data_block); 949 cell_defer(tc, m->cell, m->data_block);
888 950
951out:
889 list_del(&m->list); 952 list_del(&m->list);
890 mempool_free(m, tc->pool->mapping_pool); 953 mempool_free(m, tc->pool->mapping_pool);
891} 954}
892 955
893static void process_prepared_discard(struct dm_thin_new_mapping *m) 956static void process_prepared_discard_fail(struct dm_thin_new_mapping *m)
894{ 957{
895 int r;
896 struct thin_c *tc = m->tc; 958 struct thin_c *tc = m->tc;
897 959
898 r = dm_thin_remove_block(tc->td, m->virt_block); 960 bio_io_error(m->bio);
899 if (r) 961 cell_defer_except(tc, m->cell);
900 DMERR("dm_thin_remove_block() failed"); 962 cell_defer_except(tc, m->cell2);
963 mempool_free(m, tc->pool->mapping_pool);
964}
965
966static void process_prepared_discard_passdown(struct dm_thin_new_mapping *m)
967{
968 struct thin_c *tc = m->tc;
901 969
902 /*
903 * Pass the discard down to the underlying device?
904 */
905 if (m->pass_discard) 970 if (m->pass_discard)
906 remap_and_issue(tc, m->bio, m->data_block); 971 remap_and_issue(tc, m->bio, m->data_block);
907 else 972 else
@@ -912,8 +977,20 @@ static void process_prepared_discard(struct dm_thin_new_mapping *m)
912 mempool_free(m, tc->pool->mapping_pool); 977 mempool_free(m, tc->pool->mapping_pool);
913} 978}
914 979
980static void process_prepared_discard(struct dm_thin_new_mapping *m)
981{
982 int r;
983 struct thin_c *tc = m->tc;
984
985 r = dm_thin_remove_block(tc->td, m->virt_block);
986 if (r)
987 DMERR("dm_thin_remove_block() failed");
988
989 process_prepared_discard_passdown(m);
990}
991
915static void process_prepared(struct pool *pool, struct list_head *head, 992static void process_prepared(struct pool *pool, struct list_head *head,
916 void (*fn)(struct dm_thin_new_mapping *)) 993 process_mapping_fn *fn)
917{ 994{
918 unsigned long flags; 995 unsigned long flags;
919 struct list_head maps; 996 struct list_head maps;
@@ -925,7 +1002,7 @@ static void process_prepared(struct pool *pool, struct list_head *head,
925 spin_unlock_irqrestore(&pool->lock, flags); 1002 spin_unlock_irqrestore(&pool->lock, flags);
926 1003
927 list_for_each_entry_safe(m, tmp, &maps, list) 1004 list_for_each_entry_safe(m, tmp, &maps, list)
928 fn(m); 1005 (*fn)(m);
929} 1006}
930 1007
931/* 1008/*
@@ -933,9 +1010,7 @@ static void process_prepared(struct pool *pool, struct list_head *head,
933 */ 1010 */
934static int io_overlaps_block(struct pool *pool, struct bio *bio) 1011static int io_overlaps_block(struct pool *pool, struct bio *bio)
935{ 1012{
936 return !(bio->bi_sector & pool->offset_mask) && 1013 return bio->bi_size == (pool->sectors_per_block << SECTOR_SHIFT);
937 (bio->bi_size == (pool->sectors_per_block << SECTOR_SHIFT));
938
939} 1014}
940 1015
941static int io_overwrites_block(struct pool *pool, struct bio *bio) 1016static int io_overwrites_block(struct pool *pool, struct bio *bio)
@@ -1093,6 +1168,35 @@ static void schedule_zero(struct thin_c *tc, dm_block_t virt_block,
1093 } 1168 }
1094} 1169}
1095 1170
1171static int commit(struct pool *pool)
1172{
1173 int r;
1174
1175 r = dm_pool_commit_metadata(pool->pmd);
1176 if (r)
1177 DMERR("commit failed, error = %d", r);
1178
1179 return r;
1180}
1181
1182/*
1183 * A non-zero return indicates read_only or fail_io mode.
1184 * Many callers don't care about the return value.
1185 */
1186static int commit_or_fallback(struct pool *pool)
1187{
1188 int r;
1189
1190 if (get_pool_mode(pool) != PM_WRITE)
1191 return -EINVAL;
1192
1193 r = commit(pool);
1194 if (r)
1195 set_pool_mode(pool, PM_READ_ONLY);
1196
1197 return r;
1198}
1199
1096static int alloc_data_block(struct thin_c *tc, dm_block_t *result) 1200static int alloc_data_block(struct thin_c *tc, dm_block_t *result)
1097{ 1201{
1098 int r; 1202 int r;
@@ -1121,12 +1225,7 @@ static int alloc_data_block(struct thin_c *tc, dm_block_t *result)
1121 * Try to commit to see if that will free up some 1225 * Try to commit to see if that will free up some
1122 * more space. 1226 * more space.
1123 */ 1227 */
1124 r = dm_pool_commit_metadata(pool->pmd); 1228 (void) commit_or_fallback(pool);
1125 if (r) {
1126 DMERR("%s: dm_pool_commit_metadata() failed, error = %d",
1127 __func__, r);
1128 return r;
1129 }
1130 1229
1131 r = dm_pool_get_free_block_count(pool->pmd, &free_blocks); 1230 r = dm_pool_get_free_block_count(pool->pmd, &free_blocks);
1132 if (r) 1231 if (r)
@@ -1218,7 +1317,7 @@ static void process_discard(struct thin_c *tc, struct bio *bio)
1218 */ 1317 */
1219 m = get_next_mapping(pool); 1318 m = get_next_mapping(pool);
1220 m->tc = tc; 1319 m->tc = tc;
1221 m->pass_discard = (!lookup_result.shared) & pool->pf.discard_passdown; 1320 m->pass_discard = (!lookup_result.shared) && pool->pf.discard_passdown;
1222 m->virt_block = block; 1321 m->virt_block = block;
1223 m->data_block = lookup_result.block; 1322 m->data_block = lookup_result.block;
1224 m->cell = cell; 1323 m->cell = cell;
@@ -1234,15 +1333,10 @@ static void process_discard(struct thin_c *tc, struct bio *bio)
1234 } 1333 }
1235 } else { 1334 } else {
1236 /* 1335 /*
1237 * This path is hit if people are ignoring 1336 * The DM core makes sure that the discard doesn't span
1238 * limits->discard_granularity. It ignores any 1337 * a block boundary. So we submit the discard of a
1239 * part of the discard that is in a subsequent 1338 * partial block appropriately.
1240 * block.
1241 */ 1339 */
1242 sector_t offset = bio->bi_sector - (block << pool->block_shift);
1243 unsigned remaining = (pool->sectors_per_block - offset) << 9;
1244 bio->bi_size = min(bio->bi_size, remaining);
1245
1246 cell_release_singleton(cell, bio); 1340 cell_release_singleton(cell, bio);
1247 cell_release_singleton(cell2, bio); 1341 cell_release_singleton(cell2, bio);
1248 if ((!lookup_result.shared) && pool->pf.discard_passdown) 1342 if ((!lookup_result.shared) && pool->pf.discard_passdown)
@@ -1310,7 +1404,7 @@ static void process_shared_bio(struct thin_c *tc, struct bio *bio,
1310 if (bio_detain(pool->prison, &key, bio, &cell)) 1404 if (bio_detain(pool->prison, &key, bio, &cell))
1311 return; 1405 return;
1312 1406
1313 if (bio_data_dir(bio) == WRITE) 1407 if (bio_data_dir(bio) == WRITE && bio->bi_size)
1314 break_sharing(tc, bio, block, &key, lookup_result, cell); 1408 break_sharing(tc, bio, block, &key, lookup_result, cell);
1315 else { 1409 else {
1316 struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr; 1410 struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr;
@@ -1362,6 +1456,7 @@ static void provision_block(struct thin_c *tc, struct bio *bio, dm_block_t block
1362 1456
1363 default: 1457 default:
1364 DMERR("%s: alloc_data_block() failed, error = %d", __func__, r); 1458 DMERR("%s: alloc_data_block() failed, error = %d", __func__, r);
1459 set_pool_mode(tc->pool, PM_READ_ONLY);
1365 cell_error(cell); 1460 cell_error(cell);
1366 break; 1461 break;
1367 } 1462 }
@@ -1419,6 +1514,49 @@ static void process_bio(struct thin_c *tc, struct bio *bio)
1419 } 1514 }
1420} 1515}
1421 1516
1517static void process_bio_read_only(struct thin_c *tc, struct bio *bio)
1518{
1519 int r;
1520 int rw = bio_data_dir(bio);
1521 dm_block_t block = get_bio_block(tc, bio);
1522 struct dm_thin_lookup_result lookup_result;
1523
1524 r = dm_thin_find_block(tc->td, block, 1, &lookup_result);
1525 switch (r) {
1526 case 0:
1527 if (lookup_result.shared && (rw == WRITE) && bio->bi_size)
1528 bio_io_error(bio);
1529 else
1530 remap_and_issue(tc, bio, lookup_result.block);
1531 break;
1532
1533 case -ENODATA:
1534 if (rw != READ) {
1535 bio_io_error(bio);
1536 break;
1537 }
1538
1539 if (tc->origin_dev) {
1540 remap_to_origin_and_issue(tc, bio);
1541 break;
1542 }
1543
1544 zero_fill_bio(bio);
1545 bio_endio(bio, 0);
1546 break;
1547
1548 default:
1549 DMERR("dm_thin_find_block() failed, error = %d", r);
1550 bio_io_error(bio);
1551 break;
1552 }
1553}
1554
1555static void process_bio_fail(struct thin_c *tc, struct bio *bio)
1556{
1557 bio_io_error(bio);
1558}
1559
1422static int need_commit_due_to_time(struct pool *pool) 1560static int need_commit_due_to_time(struct pool *pool)
1423{ 1561{
1424 return jiffies < pool->last_commit_jiffies || 1562 return jiffies < pool->last_commit_jiffies ||
@@ -1430,7 +1568,6 @@ static void process_deferred_bios(struct pool *pool)
1430 unsigned long flags; 1568 unsigned long flags;
1431 struct bio *bio; 1569 struct bio *bio;
1432 struct bio_list bios; 1570 struct bio_list bios;
1433 int r;
1434 1571
1435 bio_list_init(&bios); 1572 bio_list_init(&bios);
1436 1573
@@ -1457,9 +1594,9 @@ static void process_deferred_bios(struct pool *pool)
1457 } 1594 }
1458 1595
1459 if (bio->bi_rw & REQ_DISCARD) 1596 if (bio->bi_rw & REQ_DISCARD)
1460 process_discard(tc, bio); 1597 pool->process_discard(tc, bio);
1461 else 1598 else
1462 process_bio(tc, bio); 1599 pool->process_bio(tc, bio);
1463 } 1600 }
1464 1601
1465 /* 1602 /*
@@ -1475,10 +1612,7 @@ static void process_deferred_bios(struct pool *pool)
1475 if (bio_list_empty(&bios) && !need_commit_due_to_time(pool)) 1612 if (bio_list_empty(&bios) && !need_commit_due_to_time(pool))
1476 return; 1613 return;
1477 1614
1478 r = dm_pool_commit_metadata(pool->pmd); 1615 if (commit_or_fallback(pool)) {
1479 if (r) {
1480 DMERR("%s: dm_pool_commit_metadata() failed, error = %d",
1481 __func__, r);
1482 while ((bio = bio_list_pop(&bios))) 1616 while ((bio = bio_list_pop(&bios)))
1483 bio_io_error(bio); 1617 bio_io_error(bio);
1484 return; 1618 return;
@@ -1493,8 +1627,8 @@ static void do_worker(struct work_struct *ws)
1493{ 1627{
1494 struct pool *pool = container_of(ws, struct pool, worker); 1628 struct pool *pool = container_of(ws, struct pool, worker);
1495 1629
1496 process_prepared(pool, &pool->prepared_mappings, process_prepared_mapping); 1630 process_prepared(pool, &pool->prepared_mappings, &pool->process_prepared_mapping);
1497 process_prepared(pool, &pool->prepared_discards, process_prepared_discard); 1631 process_prepared(pool, &pool->prepared_discards, &pool->process_prepared_discard);
1498 process_deferred_bios(pool); 1632 process_deferred_bios(pool);
1499} 1633}
1500 1634
@@ -1511,6 +1645,52 @@ static void do_waker(struct work_struct *ws)
1511 1645
1512/*----------------------------------------------------------------*/ 1646/*----------------------------------------------------------------*/
1513 1647
1648static enum pool_mode get_pool_mode(struct pool *pool)
1649{
1650 return pool->pf.mode;
1651}
1652
1653static void set_pool_mode(struct pool *pool, enum pool_mode mode)
1654{
1655 int r;
1656
1657 pool->pf.mode = mode;
1658
1659 switch (mode) {
1660 case PM_FAIL:
1661 DMERR("switching pool to failure mode");
1662 pool->process_bio = process_bio_fail;
1663 pool->process_discard = process_bio_fail;
1664 pool->process_prepared_mapping = process_prepared_mapping_fail;
1665 pool->process_prepared_discard = process_prepared_discard_fail;
1666 break;
1667
1668 case PM_READ_ONLY:
1669 DMERR("switching pool to read-only mode");
1670 r = dm_pool_abort_metadata(pool->pmd);
1671 if (r) {
1672 DMERR("aborting transaction failed");
1673 set_pool_mode(pool, PM_FAIL);
1674 } else {
1675 dm_pool_metadata_read_only(pool->pmd);
1676 pool->process_bio = process_bio_read_only;
1677 pool->process_discard = process_discard;
1678 pool->process_prepared_mapping = process_prepared_mapping_fail;
1679 pool->process_prepared_discard = process_prepared_discard_passdown;
1680 }
1681 break;
1682
1683 case PM_WRITE:
1684 pool->process_bio = process_bio;
1685 pool->process_discard = process_discard;
1686 pool->process_prepared_mapping = process_prepared_mapping;
1687 pool->process_prepared_discard = process_prepared_discard;
1688 break;
1689 }
1690}
1691
1692/*----------------------------------------------------------------*/
1693
1514/* 1694/*
1515 * Mapping functions. 1695 * Mapping functions.
1516 */ 1696 */
@@ -1556,6 +1736,12 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio,
1556 struct dm_thin_lookup_result result; 1736 struct dm_thin_lookup_result result;
1557 1737
1558 map_context->ptr = thin_hook_bio(tc, bio); 1738 map_context->ptr = thin_hook_bio(tc, bio);
1739
1740 if (get_pool_mode(tc->pool) == PM_FAIL) {
1741 bio_io_error(bio);
1742 return DM_MAPIO_SUBMITTED;
1743 }
1744
1559 if (bio->bi_rw & (REQ_DISCARD | REQ_FLUSH | REQ_FUA)) { 1745 if (bio->bi_rw & (REQ_DISCARD | REQ_FLUSH | REQ_FUA)) {
1560 thin_defer_bio(tc, bio); 1746 thin_defer_bio(tc, bio);
1561 return DM_MAPIO_SUBMITTED; 1747 return DM_MAPIO_SUBMITTED;
@@ -1592,14 +1778,35 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio,
1592 break; 1778 break;
1593 1779
1594 case -ENODATA: 1780 case -ENODATA:
1781 if (get_pool_mode(tc->pool) == PM_READ_ONLY) {
1782 /*
1783 * This block isn't provisioned, and we have no way
1784 * of doing so. Just error it.
1785 */
1786 bio_io_error(bio);
1787 r = DM_MAPIO_SUBMITTED;
1788 break;
1789 }
1790 /* fall through */
1791
1792 case -EWOULDBLOCK:
1595 /* 1793 /*
1596 * In future, the failed dm_thin_find_block above could 1794 * In future, the failed dm_thin_find_block above could
1597 * provide the hint to load the metadata into cache. 1795 * provide the hint to load the metadata into cache.
1598 */ 1796 */
1599 case -EWOULDBLOCK:
1600 thin_defer_bio(tc, bio); 1797 thin_defer_bio(tc, bio);
1601 r = DM_MAPIO_SUBMITTED; 1798 r = DM_MAPIO_SUBMITTED;
1602 break; 1799 break;
1800
1801 default:
1802 /*
1803 * Must always call bio_io_error on failure.
1804 * dm_thin_find_block can fail with -EINVAL if the
1805 * pool is switched to fail-io mode.
1806 */
1807 bio_io_error(bio);
1808 r = DM_MAPIO_SUBMITTED;
1809 break;
1603 } 1810 }
1604 1811
1605 return r; 1812 return r;
@@ -1636,15 +1843,26 @@ static int bind_control_target(struct pool *pool, struct dm_target *ti)
1636{ 1843{
1637 struct pool_c *pt = ti->private; 1844 struct pool_c *pt = ti->private;
1638 1845
1846 /*
1847 * We want to make sure that degraded pools are never upgraded.
1848 */
1849 enum pool_mode old_mode = pool->pf.mode;
1850 enum pool_mode new_mode = pt->pf.mode;
1851
1852 if (old_mode > new_mode)
1853 new_mode = old_mode;
1854
1639 pool->ti = ti; 1855 pool->ti = ti;
1640 pool->low_water_blocks = pt->low_water_blocks; 1856 pool->low_water_blocks = pt->low_water_blocks;
1641 pool->pf = pt->pf; 1857 pool->pf = pt->pf;
1858 set_pool_mode(pool, new_mode);
1642 1859
1643 /* 1860 /*
1644 * If discard_passdown was enabled verify that the data device 1861 * If discard_passdown was enabled verify that the data device
1645 * supports discards. Disable discard_passdown if not; otherwise 1862 * supports discards. Disable discard_passdown if not; otherwise
1646 * -EOPNOTSUPP will be returned. 1863 * -EOPNOTSUPP will be returned.
1647 */ 1864 */
1865 /* FIXME: pull this out into a sep fn. */
1648 if (pt->pf.discard_passdown) { 1866 if (pt->pf.discard_passdown) {
1649 struct request_queue *q = bdev_get_queue(pt->data_dev->bdev); 1867 struct request_queue *q = bdev_get_queue(pt->data_dev->bdev);
1650 if (!q || !blk_queue_discard(q)) { 1868 if (!q || !blk_queue_discard(q)) {
@@ -1670,6 +1888,7 @@ static void unbind_control_target(struct pool *pool, struct dm_target *ti)
1670/* Initialize pool features. */ 1888/* Initialize pool features. */
1671static void pool_features_init(struct pool_features *pf) 1889static void pool_features_init(struct pool_features *pf)
1672{ 1890{
1891 pf->mode = PM_WRITE;
1673 pf->zero_new_blocks = 1; 1892 pf->zero_new_blocks = 1;
1674 pf->discard_enabled = 1; 1893 pf->discard_enabled = 1;
1675 pf->discard_passdown = 1; 1894 pf->discard_passdown = 1;
@@ -1700,14 +1919,16 @@ static struct kmem_cache *_endio_hook_cache;
1700 1919
1701static struct pool *pool_create(struct mapped_device *pool_md, 1920static struct pool *pool_create(struct mapped_device *pool_md,
1702 struct block_device *metadata_dev, 1921 struct block_device *metadata_dev,
1703 unsigned long block_size, char **error) 1922 unsigned long block_size,
1923 int read_only, char **error)
1704{ 1924{
1705 int r; 1925 int r;
1706 void *err_p; 1926 void *err_p;
1707 struct pool *pool; 1927 struct pool *pool;
1708 struct dm_pool_metadata *pmd; 1928 struct dm_pool_metadata *pmd;
1929 bool format_device = read_only ? false : true;
1709 1930
1710 pmd = dm_pool_metadata_open(metadata_dev, block_size); 1931 pmd = dm_pool_metadata_open(metadata_dev, block_size, format_device);
1711 if (IS_ERR(pmd)) { 1932 if (IS_ERR(pmd)) {
1712 *error = "Error creating metadata object"; 1933 *error = "Error creating metadata object";
1713 return (struct pool *)pmd; 1934 return (struct pool *)pmd;
@@ -1722,8 +1943,10 @@ static struct pool *pool_create(struct mapped_device *pool_md,
1722 1943
1723 pool->pmd = pmd; 1944 pool->pmd = pmd;
1724 pool->sectors_per_block = block_size; 1945 pool->sectors_per_block = block_size;
1725 pool->block_shift = ffs(block_size) - 1; 1946 if (block_size & (block_size - 1))
1726 pool->offset_mask = block_size - 1; 1947 pool->sectors_per_block_shift = -1;
1948 else
1949 pool->sectors_per_block_shift = __ffs(block_size);
1727 pool->low_water_blocks = 0; 1950 pool->low_water_blocks = 0;
1728 pool_features_init(&pool->pf); 1951 pool_features_init(&pool->pf);
1729 pool->prison = prison_create(PRISON_CELLS); 1952 pool->prison = prison_create(PRISON_CELLS);
@@ -1822,25 +2045,29 @@ static void __pool_dec(struct pool *pool)
1822 2045
1823static struct pool *__pool_find(struct mapped_device *pool_md, 2046static struct pool *__pool_find(struct mapped_device *pool_md,
1824 struct block_device *metadata_dev, 2047 struct block_device *metadata_dev,
1825 unsigned long block_size, char **error, 2048 unsigned long block_size, int read_only,
1826 int *created) 2049 char **error, int *created)
1827{ 2050{
1828 struct pool *pool = __pool_table_lookup_metadata_dev(metadata_dev); 2051 struct pool *pool = __pool_table_lookup_metadata_dev(metadata_dev);
1829 2052
1830 if (pool) { 2053 if (pool) {
1831 if (pool->pool_md != pool_md) 2054 if (pool->pool_md != pool_md) {
2055 *error = "metadata device already in use by a pool";
1832 return ERR_PTR(-EBUSY); 2056 return ERR_PTR(-EBUSY);
2057 }
1833 __pool_inc(pool); 2058 __pool_inc(pool);
1834 2059
1835 } else { 2060 } else {
1836 pool = __pool_table_lookup(pool_md); 2061 pool = __pool_table_lookup(pool_md);
1837 if (pool) { 2062 if (pool) {
1838 if (pool->md_dev != metadata_dev) 2063 if (pool->md_dev != metadata_dev) {
2064 *error = "different pool cannot replace a pool";
1839 return ERR_PTR(-EINVAL); 2065 return ERR_PTR(-EINVAL);
2066 }
1840 __pool_inc(pool); 2067 __pool_inc(pool);
1841 2068
1842 } else { 2069 } else {
1843 pool = pool_create(pool_md, metadata_dev, block_size, error); 2070 pool = pool_create(pool_md, metadata_dev, block_size, read_only, error);
1844 *created = 1; 2071 *created = 1;
1845 } 2072 }
1846 } 2073 }
@@ -1891,19 +2118,23 @@ static int parse_pool_features(struct dm_arg_set *as, struct pool_features *pf,
1891 arg_name = dm_shift_arg(as); 2118 arg_name = dm_shift_arg(as);
1892 argc--; 2119 argc--;
1893 2120
1894 if (!strcasecmp(arg_name, "skip_block_zeroing")) { 2121 if (!strcasecmp(arg_name, "skip_block_zeroing"))
1895 pf->zero_new_blocks = 0; 2122 pf->zero_new_blocks = 0;
1896 continue; 2123
1897 } else if (!strcasecmp(arg_name, "ignore_discard")) { 2124 else if (!strcasecmp(arg_name, "ignore_discard"))
1898 pf->discard_enabled = 0; 2125 pf->discard_enabled = 0;
1899 continue; 2126
1900 } else if (!strcasecmp(arg_name, "no_discard_passdown")) { 2127 else if (!strcasecmp(arg_name, "no_discard_passdown"))
1901 pf->discard_passdown = 0; 2128 pf->discard_passdown = 0;
1902 continue;
1903 }
1904 2129
1905 ti->error = "Unrecognised pool feature requested"; 2130 else if (!strcasecmp(arg_name, "read_only"))
1906 r = -EINVAL; 2131 pf->mode = PM_READ_ONLY;
2132
2133 else {
2134 ti->error = "Unrecognised pool feature requested";
2135 r = -EINVAL;
2136 break;
2137 }
1907 } 2138 }
1908 2139
1909 return r; 2140 return r;
@@ -1967,7 +2198,7 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
1967 if (kstrtoul(argv[2], 10, &block_size) || !block_size || 2198 if (kstrtoul(argv[2], 10, &block_size) || !block_size ||
1968 block_size < DATA_DEV_BLOCK_SIZE_MIN_SECTORS || 2199 block_size < DATA_DEV_BLOCK_SIZE_MIN_SECTORS ||
1969 block_size > DATA_DEV_BLOCK_SIZE_MAX_SECTORS || 2200 block_size > DATA_DEV_BLOCK_SIZE_MAX_SECTORS ||
1970 !is_power_of_2(block_size)) { 2201 block_size & (DATA_DEV_BLOCK_SIZE_MIN_SECTORS - 1)) {
1971 ti->error = "Invalid block size"; 2202 ti->error = "Invalid block size";
1972 r = -EINVAL; 2203 r = -EINVAL;
1973 goto out; 2204 goto out;
@@ -1996,7 +2227,7 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
1996 } 2227 }
1997 2228
1998 pool = __pool_find(dm_table_get_md(ti->table), metadata_dev->bdev, 2229 pool = __pool_find(dm_table_get_md(ti->table), metadata_dev->bdev,
1999 block_size, &ti->error, &pool_created); 2230 block_size, pf.mode == PM_READ_ONLY, &ti->error, &pool_created);
2000 if (IS_ERR(pool)) { 2231 if (IS_ERR(pool)) {
2001 r = PTR_ERR(pool); 2232 r = PTR_ERR(pool);
2002 goto out_free_pt; 2233 goto out_free_pt;
@@ -2014,6 +2245,15 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
2014 goto out_flags_changed; 2245 goto out_flags_changed;
2015 } 2246 }
2016 2247
2248 /*
2249 * The block layer requires discard_granularity to be a power of 2.
2250 */
2251 if (pf.discard_enabled && !is_power_of_2(block_size)) {
2252 ti->error = "Discard support must be disabled when the block size is not a power of 2";
2253 r = -EINVAL;
2254 goto out_flags_changed;
2255 }
2256
2017 pt->pool = pool; 2257 pt->pool = pool;
2018 pt->ti = ti; 2258 pt->ti = ti;
2019 pt->metadata_dev = metadata_dev; 2259 pt->metadata_dev = metadata_dev;
@@ -2033,7 +2273,7 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
2033 * stacking of discard limits (this keeps the pool and 2273 * stacking of discard limits (this keeps the pool and
2034 * thin devices' discard limits consistent). 2274 * thin devices' discard limits consistent).
2035 */ 2275 */
2036 ti->discards_supported = 1; 2276 ti->discards_supported = true;
2037 } 2277 }
2038 ti->private = pt; 2278 ti->private = pt;
2039 2279
@@ -2093,7 +2333,8 @@ static int pool_preresume(struct dm_target *ti)
2093 int r; 2333 int r;
2094 struct pool_c *pt = ti->private; 2334 struct pool_c *pt = ti->private;
2095 struct pool *pool = pt->pool; 2335 struct pool *pool = pt->pool;
2096 dm_block_t data_size, sb_data_size; 2336 sector_t data_size = ti->len;
2337 dm_block_t sb_data_size;
2097 2338
2098 /* 2339 /*
2099 * Take control of the pool object. 2340 * Take control of the pool object.
@@ -2102,7 +2343,8 @@ static int pool_preresume(struct dm_target *ti)
2102 if (r) 2343 if (r)
2103 return r; 2344 return r;
2104 2345
2105 data_size = ti->len >> pool->block_shift; 2346 (void) sector_div(data_size, pool->sectors_per_block);
2347
2106 r = dm_pool_get_data_dev_size(pool->pmd, &sb_data_size); 2348 r = dm_pool_get_data_dev_size(pool->pmd, &sb_data_size);
2107 if (r) { 2349 if (r) {
2108 DMERR("failed to retrieve data device size"); 2350 DMERR("failed to retrieve data device size");
@@ -2111,22 +2353,19 @@ static int pool_preresume(struct dm_target *ti)
2111 2353
2112 if (data_size < sb_data_size) { 2354 if (data_size < sb_data_size) {
2113 DMERR("pool target too small, is %llu blocks (expected %llu)", 2355 DMERR("pool target too small, is %llu blocks (expected %llu)",
2114 data_size, sb_data_size); 2356 (unsigned long long)data_size, sb_data_size);
2115 return -EINVAL; 2357 return -EINVAL;
2116 2358
2117 } else if (data_size > sb_data_size) { 2359 } else if (data_size > sb_data_size) {
2118 r = dm_pool_resize_data_dev(pool->pmd, data_size); 2360 r = dm_pool_resize_data_dev(pool->pmd, data_size);
2119 if (r) { 2361 if (r) {
2120 DMERR("failed to resize data device"); 2362 DMERR("failed to resize data device");
2363 /* FIXME Stricter than necessary: Rollback transaction instead here */
2364 set_pool_mode(pool, PM_READ_ONLY);
2121 return r; 2365 return r;
2122 } 2366 }
2123 2367
2124 r = dm_pool_commit_metadata(pool->pmd); 2368 (void) commit_or_fallback(pool);
2125 if (r) {
2126 DMERR("%s: dm_pool_commit_metadata() failed, error = %d",
2127 __func__, r);
2128 return r;
2129 }
2130 } 2369 }
2131 2370
2132 return 0; 2371 return 0;
@@ -2149,19 +2388,12 @@ static void pool_resume(struct dm_target *ti)
2149 2388
2150static void pool_postsuspend(struct dm_target *ti) 2389static void pool_postsuspend(struct dm_target *ti)
2151{ 2390{
2152 int r;
2153 struct pool_c *pt = ti->private; 2391 struct pool_c *pt = ti->private;
2154 struct pool *pool = pt->pool; 2392 struct pool *pool = pt->pool;
2155 2393
2156 cancel_delayed_work(&pool->waker); 2394 cancel_delayed_work(&pool->waker);
2157 flush_workqueue(pool->wq); 2395 flush_workqueue(pool->wq);
2158 2396 (void) commit_or_fallback(pool);
2159 r = dm_pool_commit_metadata(pool->pmd);
2160 if (r < 0) {
2161 DMERR("%s: dm_pool_commit_metadata() failed, error = %d",
2162 __func__, r);
2163 /* FIXME: invalidate device? error the next FUA or FLUSH bio ?*/
2164 }
2165} 2397}
2166 2398
2167static int check_arg_count(unsigned argc, unsigned args_required) 2399static int check_arg_count(unsigned argc, unsigned args_required)
@@ -2295,12 +2527,7 @@ static int process_reserve_metadata_snap_mesg(unsigned argc, char **argv, struct
2295 if (r) 2527 if (r)
2296 return r; 2528 return r;
2297 2529
2298 r = dm_pool_commit_metadata(pool->pmd); 2530 (void) commit_or_fallback(pool);
2299 if (r) {
2300 DMERR("%s: dm_pool_commit_metadata() failed, error = %d",
2301 __func__, r);
2302 return r;
2303 }
2304 2531
2305 r = dm_pool_reserve_metadata_snap(pool->pmd); 2532 r = dm_pool_reserve_metadata_snap(pool->pmd);
2306 if (r) 2533 if (r)
@@ -2361,25 +2588,41 @@ static int pool_message(struct dm_target *ti, unsigned argc, char **argv)
2361 else 2588 else
2362 DMWARN("Unrecognised thin pool target message received: %s", argv[0]); 2589 DMWARN("Unrecognised thin pool target message received: %s", argv[0]);
2363 2590
2364 if (!r) { 2591 if (!r)
2365 r = dm_pool_commit_metadata(pool->pmd); 2592 (void) commit_or_fallback(pool);
2366 if (r)
2367 DMERR("%s message: dm_pool_commit_metadata() failed, error = %d",
2368 argv[0], r);
2369 }
2370 2593
2371 return r; 2594 return r;
2372} 2595}
2373 2596
2597static void emit_flags(struct pool_features *pf, char *result,
2598 unsigned sz, unsigned maxlen)
2599{
2600 unsigned count = !pf->zero_new_blocks + !pf->discard_enabled +
2601 !pf->discard_passdown + (pf->mode == PM_READ_ONLY);
2602 DMEMIT("%u ", count);
2603
2604 if (!pf->zero_new_blocks)
2605 DMEMIT("skip_block_zeroing ");
2606
2607 if (!pf->discard_enabled)
2608 DMEMIT("ignore_discard ");
2609
2610 if (!pf->discard_passdown)
2611 DMEMIT("no_discard_passdown ");
2612
2613 if (pf->mode == PM_READ_ONLY)
2614 DMEMIT("read_only ");
2615}
2616
2374/* 2617/*
2375 * Status line is: 2618 * Status line is:
2376 * <transaction id> <used metadata sectors>/<total metadata sectors> 2619 * <transaction id> <used metadata sectors>/<total metadata sectors>
2377 * <used data sectors>/<total data sectors> <held metadata root> 2620 * <used data sectors>/<total data sectors> <held metadata root>
2378 */ 2621 */
2379static int pool_status(struct dm_target *ti, status_type_t type, 2622static int pool_status(struct dm_target *ti, status_type_t type,
2380 char *result, unsigned maxlen) 2623 unsigned status_flags, char *result, unsigned maxlen)
2381{ 2624{
2382 int r, count; 2625 int r;
2383 unsigned sz = 0; 2626 unsigned sz = 0;
2384 uint64_t transaction_id; 2627 uint64_t transaction_id;
2385 dm_block_t nr_free_blocks_data; 2628 dm_block_t nr_free_blocks_data;
@@ -2394,6 +2637,15 @@ static int pool_status(struct dm_target *ti, status_type_t type,
2394 2637
2395 switch (type) { 2638 switch (type) {
2396 case STATUSTYPE_INFO: 2639 case STATUSTYPE_INFO:
2640 if (get_pool_mode(pool) == PM_FAIL) {
2641 DMEMIT("Fail");
2642 break;
2643 }
2644
2645 /* Commit to ensure statistics aren't out-of-date */
2646 if (!(status_flags & DM_STATUS_NOFLUSH_FLAG) && !dm_suspended(ti))
2647 (void) commit_or_fallback(pool);
2648
2397 r = dm_pool_get_metadata_transaction_id(pool->pmd, 2649 r = dm_pool_get_metadata_transaction_id(pool->pmd,
2398 &transaction_id); 2650 &transaction_id);
2399 if (r) 2651 if (r)
@@ -2429,9 +2681,19 @@ static int pool_status(struct dm_target *ti, status_type_t type,
2429 (unsigned long long)nr_blocks_data); 2681 (unsigned long long)nr_blocks_data);
2430 2682
2431 if (held_root) 2683 if (held_root)
2432 DMEMIT("%llu", held_root); 2684 DMEMIT("%llu ", held_root);
2685 else
2686 DMEMIT("- ");
2687
2688 if (pool->pf.mode == PM_READ_ONLY)
2689 DMEMIT("ro ");
2690 else
2691 DMEMIT("rw ");
2692
2693 if (pool->pf.discard_enabled && pool->pf.discard_passdown)
2694 DMEMIT("discard_passdown");
2433 else 2695 else
2434 DMEMIT("-"); 2696 DMEMIT("no_discard_passdown");
2435 2697
2436 break; 2698 break;
2437 2699
@@ -2441,20 +2703,7 @@ static int pool_status(struct dm_target *ti, status_type_t type,
2441 format_dev_t(buf2, pt->data_dev->bdev->bd_dev), 2703 format_dev_t(buf2, pt->data_dev->bdev->bd_dev),
2442 (unsigned long)pool->sectors_per_block, 2704 (unsigned long)pool->sectors_per_block,
2443 (unsigned long long)pt->low_water_blocks); 2705 (unsigned long long)pt->low_water_blocks);
2444 2706 emit_flags(&pt->pf, result, sz, maxlen);
2445 count = !pool->pf.zero_new_blocks + !pool->pf.discard_enabled +
2446 !pt->pf.discard_passdown;
2447 DMEMIT("%u ", count);
2448
2449 if (!pool->pf.zero_new_blocks)
2450 DMEMIT("skip_block_zeroing ");
2451
2452 if (!pool->pf.discard_enabled)
2453 DMEMIT("ignore_discard ");
2454
2455 if (!pt->pf.discard_passdown)
2456 DMEMIT("no_discard_passdown ");
2457
2458 break; 2707 break;
2459 } 2708 }
2460 2709
@@ -2492,7 +2741,8 @@ static void set_discard_limits(struct pool *pool, struct queue_limits *limits)
2492 2741
2493 /* 2742 /*
2494 * This is just a hint, and not enforced. We have to cope with 2743 * This is just a hint, and not enforced. We have to cope with
2495 * bios that overlap 2 blocks. 2744 * bios that cover a block partially. A discard that spans a block
2745 * boundary is not sent to this target.
2496 */ 2746 */
2497 limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT; 2747 limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
2498 limits->discard_zeroes_data = pool->pf.zero_new_blocks; 2748 limits->discard_zeroes_data = pool->pf.zero_new_blocks;
@@ -2513,7 +2763,7 @@ static struct target_type pool_target = {
2513 .name = "thin-pool", 2763 .name = "thin-pool",
2514 .features = DM_TARGET_SINGLETON | DM_TARGET_ALWAYS_WRITEABLE | 2764 .features = DM_TARGET_SINGLETON | DM_TARGET_ALWAYS_WRITEABLE |
2515 DM_TARGET_IMMUTABLE, 2765 DM_TARGET_IMMUTABLE,
2516 .version = {1, 2, 0}, 2766 .version = {1, 3, 0},
2517 .module = THIS_MODULE, 2767 .module = THIS_MODULE,
2518 .ctr = pool_ctr, 2768 .ctr = pool_ctr,
2519 .dtr = pool_dtr, 2769 .dtr = pool_dtr,
@@ -2618,20 +2868,31 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
2618 } 2868 }
2619 __pool_inc(tc->pool); 2869 __pool_inc(tc->pool);
2620 2870
2871 if (get_pool_mode(tc->pool) == PM_FAIL) {
2872 ti->error = "Couldn't open thin device, Pool is in fail mode";
2873 goto bad_thin_open;
2874 }
2875
2621 r = dm_pool_open_thin_device(tc->pool->pmd, tc->dev_id, &tc->td); 2876 r = dm_pool_open_thin_device(tc->pool->pmd, tc->dev_id, &tc->td);
2622 if (r) { 2877 if (r) {
2623 ti->error = "Couldn't open thin internal device"; 2878 ti->error = "Couldn't open thin internal device";
2624 goto bad_thin_open; 2879 goto bad_thin_open;
2625 } 2880 }
2626 2881
2627 ti->split_io = tc->pool->sectors_per_block; 2882 r = dm_set_target_max_io_len(ti, tc->pool->sectors_per_block);
2883 if (r)
2884 goto bad_thin_open;
2885
2628 ti->num_flush_requests = 1; 2886 ti->num_flush_requests = 1;
2887 ti->flush_supported = true;
2629 2888
2630 /* In case the pool supports discards, pass them on. */ 2889 /* In case the pool supports discards, pass them on. */
2631 if (tc->pool->pf.discard_enabled) { 2890 if (tc->pool->pf.discard_enabled) {
2632 ti->discards_supported = 1; 2891 ti->discards_supported = true;
2633 ti->num_discard_requests = 1; 2892 ti->num_discard_requests = 1;
2634 ti->discard_zeroes_data_unsupported = 1; 2893 ti->discard_zeroes_data_unsupported = true;
2894 /* Discard requests must be split on a block boundary */
2895 ti->split_discard_requests = true;
2635 } 2896 }
2636 2897
2637 dm_put(pool_md); 2898 dm_put(pool_md);
@@ -2712,7 +2973,7 @@ static void thin_postsuspend(struct dm_target *ti)
2712 * <nr mapped sectors> <highest mapped sector> 2973 * <nr mapped sectors> <highest mapped sector>
2713 */ 2974 */
2714static int thin_status(struct dm_target *ti, status_type_t type, 2975static int thin_status(struct dm_target *ti, status_type_t type,
2715 char *result, unsigned maxlen) 2976 unsigned status_flags, char *result, unsigned maxlen)
2716{ 2977{
2717 int r; 2978 int r;
2718 ssize_t sz = 0; 2979 ssize_t sz = 0;
@@ -2720,6 +2981,11 @@ static int thin_status(struct dm_target *ti, status_type_t type,
2720 char buf[BDEVNAME_SIZE]; 2981 char buf[BDEVNAME_SIZE];
2721 struct thin_c *tc = ti->private; 2982 struct thin_c *tc = ti->private;
2722 2983
2984 if (get_pool_mode(tc->pool) == PM_FAIL) {
2985 DMEMIT("Fail");
2986 return 0;
2987 }
2988
2723 if (!tc->td) 2989 if (!tc->td)
2724 DMEMIT("-"); 2990 DMEMIT("-");
2725 else { 2991 else {
@@ -2757,19 +3023,21 @@ static int thin_status(struct dm_target *ti, status_type_t type,
2757static int thin_iterate_devices(struct dm_target *ti, 3023static int thin_iterate_devices(struct dm_target *ti,
2758 iterate_devices_callout_fn fn, void *data) 3024 iterate_devices_callout_fn fn, void *data)
2759{ 3025{
2760 dm_block_t blocks; 3026 sector_t blocks;
2761 struct thin_c *tc = ti->private; 3027 struct thin_c *tc = ti->private;
3028 struct pool *pool = tc->pool;
2762 3029
2763 /* 3030 /*
2764 * We can't call dm_pool_get_data_dev_size() since that blocks. So 3031 * We can't call dm_pool_get_data_dev_size() since that blocks. So
2765 * we follow a more convoluted path through to the pool's target. 3032 * we follow a more convoluted path through to the pool's target.
2766 */ 3033 */
2767 if (!tc->pool->ti) 3034 if (!pool->ti)
2768 return 0; /* nothing is bound */ 3035 return 0; /* nothing is bound */
2769 3036
2770 blocks = tc->pool->ti->len >> tc->pool->block_shift; 3037 blocks = pool->ti->len;
3038 (void) sector_div(blocks, pool->sectors_per_block);
2771 if (blocks) 3039 if (blocks)
2772 return fn(ti, tc->pool_dev, 0, tc->pool->sectors_per_block * blocks, data); 3040 return fn(ti, tc->pool_dev, 0, pool->sectors_per_block * blocks, data);
2773 3041
2774 return 0; 3042 return 0;
2775} 3043}
@@ -2786,7 +3054,7 @@ static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits)
2786 3054
2787static struct target_type thin_target = { 3055static struct target_type thin_target = {
2788 .name = "thin", 3056 .name = "thin",
2789 .version = {1, 1, 0}, 3057 .version = {1, 3, 0},
2790 .module = THIS_MODULE, 3058 .module = THIS_MODULE,
2791 .ctr = thin_ctr, 3059 .ctr = thin_ctr,
2792 .dtr = thin_dtr, 3060 .dtr = thin_dtr,
diff --git a/drivers/md/dm-verity.c b/drivers/md/dm-verity.c
index fa365d39b612..254d19268ad2 100644
--- a/drivers/md/dm-verity.c
+++ b/drivers/md/dm-verity.c
@@ -515,7 +515,7 @@ static int verity_map(struct dm_target *ti, struct bio *bio,
515 * Status: V (valid) or C (corruption found) 515 * Status: V (valid) or C (corruption found)
516 */ 516 */
517static int verity_status(struct dm_target *ti, status_type_t type, 517static int verity_status(struct dm_target *ti, status_type_t type,
518 char *result, unsigned maxlen) 518 unsigned status_flags, char *result, unsigned maxlen)
519{ 519{
520 struct dm_verity *v = ti->private; 520 struct dm_verity *v = ti->private;
521 unsigned sz = 0; 521 unsigned sz = 0;
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index e24143cc2040..4e09b6ff5b49 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -968,22 +968,41 @@ static sector_t max_io_len_target_boundary(sector_t sector, struct dm_target *ti
968static sector_t max_io_len(sector_t sector, struct dm_target *ti) 968static sector_t max_io_len(sector_t sector, struct dm_target *ti)
969{ 969{
970 sector_t len = max_io_len_target_boundary(sector, ti); 970 sector_t len = max_io_len_target_boundary(sector, ti);
971 sector_t offset, max_len;
971 972
972 /* 973 /*
973 * Does the target need to split even further ? 974 * Does the target need to split even further?
974 */ 975 */
975 if (ti->split_io) { 976 if (ti->max_io_len) {
976 sector_t boundary; 977 offset = dm_target_offset(ti, sector);
977 sector_t offset = dm_target_offset(ti, sector); 978 if (unlikely(ti->max_io_len & (ti->max_io_len - 1)))
978 boundary = ((offset + ti->split_io) & ~(ti->split_io - 1)) 979 max_len = sector_div(offset, ti->max_io_len);
979 - offset; 980 else
980 if (len > boundary) 981 max_len = offset & (ti->max_io_len - 1);
981 len = boundary; 982 max_len = ti->max_io_len - max_len;
983
984 if (len > max_len)
985 len = max_len;
982 } 986 }
983 987
984 return len; 988 return len;
985} 989}
986 990
991int dm_set_target_max_io_len(struct dm_target *ti, sector_t len)
992{
993 if (len > UINT_MAX) {
994 DMERR("Specified maximum size of target IO (%llu) exceeds limit (%u)",
995 (unsigned long long)len, UINT_MAX);
996 ti->error = "Maximum size of target IO is too large";
997 return -EINVAL;
998 }
999
1000 ti->max_io_len = (uint32_t) len;
1001
1002 return 0;
1003}
1004EXPORT_SYMBOL_GPL(dm_set_target_max_io_len);
1005
987static void __map_bio(struct dm_target *ti, struct bio *clone, 1006static void __map_bio(struct dm_target *ti, struct bio *clone,
988 struct dm_target_io *tio) 1007 struct dm_target_io *tio)
989{ 1008{
@@ -1196,7 +1215,10 @@ static int __clone_and_map_discard(struct clone_info *ci)
1196 if (!ti->num_discard_requests) 1215 if (!ti->num_discard_requests)
1197 return -EOPNOTSUPP; 1216 return -EOPNOTSUPP;
1198 1217
1199 len = min(ci->sector_count, max_io_len_target_boundary(ci->sector, ti)); 1218 if (!ti->split_discard_requests)
1219 len = min(ci->sector_count, max_io_len_target_boundary(ci->sector, ti));
1220 else
1221 len = min(ci->sector_count, max_io_len(ci->sector, ti));
1200 1222
1201 __issue_target_requests(ci, ti, ti->num_discard_requests, len); 1223 __issue_target_requests(ci, ti, ti->num_discard_requests, len);
1202 1224
diff --git a/drivers/md/dm.h b/drivers/md/dm.h
index b7dacd59d8d7..52eef493d266 100644
--- a/drivers/md/dm.h
+++ b/drivers/md/dm.h
@@ -23,6 +23,11 @@
23#define DM_SUSPEND_NOFLUSH_FLAG (1 << 1) 23#define DM_SUSPEND_NOFLUSH_FLAG (1 << 1)
24 24
25/* 25/*
26 * Status feature flags
27 */
28#define DM_STATUS_NOFLUSH_FLAG (1 << 0)
29
30/*
26 * Type of table and mapped_device's mempool 31 * Type of table and mapped_device's mempool
27 */ 32 */
28#define DM_TYPE_NONE 0 33#define DM_TYPE_NONE 0
diff --git a/drivers/md/persistent-data/Makefile b/drivers/md/persistent-data/Makefile
index cfa95f662230..d8e7cb767c1e 100644
--- a/drivers/md/persistent-data/Makefile
+++ b/drivers/md/persistent-data/Makefile
@@ -1,7 +1,6 @@
1obj-$(CONFIG_DM_PERSISTENT_DATA) += dm-persistent-data.o 1obj-$(CONFIG_DM_PERSISTENT_DATA) += dm-persistent-data.o
2dm-persistent-data-objs := \ 2dm-persistent-data-objs := \
3 dm-block-manager.o \ 3 dm-block-manager.o \
4 dm-space-map-checker.o \
5 dm-space-map-common.o \ 4 dm-space-map-common.o \
6 dm-space-map-disk.o \ 5 dm-space-map-disk.o \
7 dm-space-map-metadata.o \ 6 dm-space-map-metadata.o \
diff --git a/drivers/md/persistent-data/dm-block-manager.c b/drivers/md/persistent-data/dm-block-manager.c
index 0317ecdc6e53..5ba277768d99 100644
--- a/drivers/md/persistent-data/dm-block-manager.c
+++ b/drivers/md/persistent-data/dm-block-manager.c
@@ -325,11 +325,6 @@ static struct dm_buffer *to_buffer(struct dm_block *b)
325 return (struct dm_buffer *) b; 325 return (struct dm_buffer *) b;
326} 326}
327 327
328static struct dm_bufio_client *to_bufio(struct dm_block_manager *bm)
329{
330 return (struct dm_bufio_client *) bm;
331}
332
333dm_block_t dm_block_location(struct dm_block *b) 328dm_block_t dm_block_location(struct dm_block *b)
334{ 329{
335 return dm_bufio_get_block_number(to_buffer(b)); 330 return dm_bufio_get_block_number(to_buffer(b));
@@ -367,34 +362,60 @@ static void dm_block_manager_write_callback(struct dm_buffer *buf)
367/*---------------------------------------------------------------- 362/*----------------------------------------------------------------
368 * Public interface 363 * Public interface
369 *--------------------------------------------------------------*/ 364 *--------------------------------------------------------------*/
365struct dm_block_manager {
366 struct dm_bufio_client *bufio;
367 bool read_only:1;
368};
369
370struct dm_block_manager *dm_block_manager_create(struct block_device *bdev, 370struct dm_block_manager *dm_block_manager_create(struct block_device *bdev,
371 unsigned block_size, 371 unsigned block_size,
372 unsigned cache_size, 372 unsigned cache_size,
373 unsigned max_held_per_thread) 373 unsigned max_held_per_thread)
374{ 374{
375 return (struct dm_block_manager *) 375 int r;
376 dm_bufio_client_create(bdev, block_size, max_held_per_thread, 376 struct dm_block_manager *bm;
377 sizeof(struct buffer_aux), 377
378 dm_block_manager_alloc_callback, 378 bm = kmalloc(sizeof(*bm), GFP_KERNEL);
379 dm_block_manager_write_callback); 379 if (!bm) {
380 r = -ENOMEM;
381 goto bad;
382 }
383
384 bm->bufio = dm_bufio_client_create(bdev, block_size, max_held_per_thread,
385 sizeof(struct buffer_aux),
386 dm_block_manager_alloc_callback,
387 dm_block_manager_write_callback);
388 if (IS_ERR(bm->bufio)) {
389 r = PTR_ERR(bm->bufio);
390 kfree(bm);
391 goto bad;
392 }
393
394 bm->read_only = false;
395
396 return bm;
397
398bad:
399 return ERR_PTR(r);
380} 400}
381EXPORT_SYMBOL_GPL(dm_block_manager_create); 401EXPORT_SYMBOL_GPL(dm_block_manager_create);
382 402
383void dm_block_manager_destroy(struct dm_block_manager *bm) 403void dm_block_manager_destroy(struct dm_block_manager *bm)
384{ 404{
385 return dm_bufio_client_destroy(to_bufio(bm)); 405 dm_bufio_client_destroy(bm->bufio);
406 kfree(bm);
386} 407}
387EXPORT_SYMBOL_GPL(dm_block_manager_destroy); 408EXPORT_SYMBOL_GPL(dm_block_manager_destroy);
388 409
389unsigned dm_bm_block_size(struct dm_block_manager *bm) 410unsigned dm_bm_block_size(struct dm_block_manager *bm)
390{ 411{
391 return dm_bufio_get_block_size(to_bufio(bm)); 412 return dm_bufio_get_block_size(bm->bufio);
392} 413}
393EXPORT_SYMBOL_GPL(dm_bm_block_size); 414EXPORT_SYMBOL_GPL(dm_bm_block_size);
394 415
395dm_block_t dm_bm_nr_blocks(struct dm_block_manager *bm) 416dm_block_t dm_bm_nr_blocks(struct dm_block_manager *bm)
396{ 417{
397 return dm_bufio_get_device_size(to_bufio(bm)); 418 return dm_bufio_get_device_size(bm->bufio);
398} 419}
399 420
400static int dm_bm_validate_buffer(struct dm_block_manager *bm, 421static int dm_bm_validate_buffer(struct dm_block_manager *bm,
@@ -406,7 +427,7 @@ static int dm_bm_validate_buffer(struct dm_block_manager *bm,
406 int r; 427 int r;
407 if (!v) 428 if (!v)
408 return 0; 429 return 0;
409 r = v->check(v, (struct dm_block *) buf, dm_bufio_get_block_size(to_bufio(bm))); 430 r = v->check(v, (struct dm_block *) buf, dm_bufio_get_block_size(bm->bufio));
410 if (unlikely(r)) 431 if (unlikely(r))
411 return r; 432 return r;
412 aux->validator = v; 433 aux->validator = v;
@@ -430,7 +451,7 @@ int dm_bm_read_lock(struct dm_block_manager *bm, dm_block_t b,
430 void *p; 451 void *p;
431 int r; 452 int r;
432 453
433 p = dm_bufio_read(to_bufio(bm), b, (struct dm_buffer **) result); 454 p = dm_bufio_read(bm->bufio, b, (struct dm_buffer **) result);
434 if (unlikely(IS_ERR(p))) 455 if (unlikely(IS_ERR(p)))
435 return PTR_ERR(p); 456 return PTR_ERR(p);
436 457
@@ -463,7 +484,10 @@ int dm_bm_write_lock(struct dm_block_manager *bm,
463 void *p; 484 void *p;
464 int r; 485 int r;
465 486
466 p = dm_bufio_read(to_bufio(bm), b, (struct dm_buffer **) result); 487 if (bm->read_only)
488 return -EPERM;
489
490 p = dm_bufio_read(bm->bufio, b, (struct dm_buffer **) result);
467 if (unlikely(IS_ERR(p))) 491 if (unlikely(IS_ERR(p)))
468 return PTR_ERR(p); 492 return PTR_ERR(p);
469 493
@@ -496,7 +520,7 @@ int dm_bm_read_try_lock(struct dm_block_manager *bm,
496 void *p; 520 void *p;
497 int r; 521 int r;
498 522
499 p = dm_bufio_get(to_bufio(bm), b, (struct dm_buffer **) result); 523 p = dm_bufio_get(bm->bufio, b, (struct dm_buffer **) result);
500 if (unlikely(IS_ERR(p))) 524 if (unlikely(IS_ERR(p)))
501 return PTR_ERR(p); 525 return PTR_ERR(p);
502 if (unlikely(!p)) 526 if (unlikely(!p))
@@ -529,7 +553,10 @@ int dm_bm_write_lock_zero(struct dm_block_manager *bm,
529 struct buffer_aux *aux; 553 struct buffer_aux *aux;
530 void *p; 554 void *p;
531 555
532 p = dm_bufio_new(to_bufio(bm), b, (struct dm_buffer **) result); 556 if (bm->read_only)
557 return -EPERM;
558
559 p = dm_bufio_new(bm->bufio, b, (struct dm_buffer **) result);
533 if (unlikely(IS_ERR(p))) 560 if (unlikely(IS_ERR(p)))
534 return PTR_ERR(p); 561 return PTR_ERR(p);
535 562
@@ -547,6 +574,7 @@ int dm_bm_write_lock_zero(struct dm_block_manager *bm,
547 574
548 return 0; 575 return 0;
549} 576}
577EXPORT_SYMBOL_GPL(dm_bm_write_lock_zero);
550 578
551int dm_bm_unlock(struct dm_block *b) 579int dm_bm_unlock(struct dm_block *b)
552{ 580{
@@ -565,45 +593,30 @@ int dm_bm_unlock(struct dm_block *b)
565} 593}
566EXPORT_SYMBOL_GPL(dm_bm_unlock); 594EXPORT_SYMBOL_GPL(dm_bm_unlock);
567 595
568int dm_bm_unlock_move(struct dm_block *b, dm_block_t n)
569{
570 struct buffer_aux *aux;
571
572 aux = dm_bufio_get_aux_data(to_buffer(b));
573
574 if (aux->write_locked) {
575 dm_bufio_mark_buffer_dirty(to_buffer(b));
576 bl_up_write(&aux->lock);
577 } else
578 bl_up_read(&aux->lock);
579
580 dm_bufio_release_move(to_buffer(b), n);
581 return 0;
582}
583
584int dm_bm_flush_and_unlock(struct dm_block_manager *bm, 596int dm_bm_flush_and_unlock(struct dm_block_manager *bm,
585 struct dm_block *superblock) 597 struct dm_block *superblock)
586{ 598{
587 int r; 599 int r;
588 600
589 r = dm_bufio_write_dirty_buffers(to_bufio(bm)); 601 if (bm->read_only)
590 if (unlikely(r)) 602 return -EPERM;
591 return r; 603
592 r = dm_bufio_issue_flush(to_bufio(bm)); 604 r = dm_bufio_write_dirty_buffers(bm->bufio);
593 if (unlikely(r)) 605 if (unlikely(r)) {
606 dm_bm_unlock(superblock);
594 return r; 607 return r;
608 }
595 609
596 dm_bm_unlock(superblock); 610 dm_bm_unlock(superblock);
597 611
598 r = dm_bufio_write_dirty_buffers(to_bufio(bm)); 612 return dm_bufio_write_dirty_buffers(bm->bufio);
599 if (unlikely(r)) 613}
600 return r;
601 r = dm_bufio_issue_flush(to_bufio(bm));
602 if (unlikely(r))
603 return r;
604 614
605 return 0; 615void dm_bm_set_read_only(struct dm_block_manager *bm)
616{
617 bm->read_only = true;
606} 618}
619EXPORT_SYMBOL_GPL(dm_bm_set_read_only);
607 620
608u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor) 621u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor)
609{ 622{
diff --git a/drivers/md/persistent-data/dm-block-manager.h b/drivers/md/persistent-data/dm-block-manager.h
index 924833d2dfa6..be5bff61be28 100644
--- a/drivers/md/persistent-data/dm-block-manager.h
+++ b/drivers/md/persistent-data/dm-block-manager.h
@@ -97,14 +97,6 @@ int dm_bm_write_lock_zero(struct dm_block_manager *bm, dm_block_t b,
97int dm_bm_unlock(struct dm_block *b); 97int dm_bm_unlock(struct dm_block *b);
98 98
99/* 99/*
100 * An optimisation; we often want to copy a block's contents to a new
101 * block. eg, as part of the shadowing operation. It's far better for
102 * bufio to do this move behind the scenes than hold 2 locks and memcpy the
103 * data.
104 */
105int dm_bm_unlock_move(struct dm_block *b, dm_block_t n);
106
107/*
108 * It's a common idiom to have a superblock that should be committed last. 100 * It's a common idiom to have a superblock that should be committed last.
109 * 101 *
110 * @superblock should be write-locked on entry. It will be unlocked during 102 * @superblock should be write-locked on entry. It will be unlocked during
@@ -116,6 +108,19 @@ int dm_bm_unlock_move(struct dm_block *b, dm_block_t n);
116int dm_bm_flush_and_unlock(struct dm_block_manager *bm, 108int dm_bm_flush_and_unlock(struct dm_block_manager *bm,
117 struct dm_block *superblock); 109 struct dm_block *superblock);
118 110
111/*
112 * Switches the bm to a read only mode. Once read-only mode
113 * has been entered the following functions will return -EPERM.
114 *
115 * dm_bm_write_lock
116 * dm_bm_write_lock_zero
117 * dm_bm_flush_and_unlock
118 *
119 * Additionally you should not use dm_bm_unlock_move, however no error will
120 * be returned if you do.
121 */
122void dm_bm_set_read_only(struct dm_block_manager *bm);
123
119u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor); 124u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor);
120 125
121/*----------------------------------------------------------------*/ 126/*----------------------------------------------------------------*/
diff --git a/drivers/md/persistent-data/dm-space-map-checker.c b/drivers/md/persistent-data/dm-space-map-checker.c
deleted file mode 100644
index fc90c11620ad..000000000000
--- a/drivers/md/persistent-data/dm-space-map-checker.c
+++ /dev/null
@@ -1,446 +0,0 @@
1/*
2 * Copyright (C) 2011 Red Hat, Inc.
3 *
4 * This file is released under the GPL.
5 */
6
7#include "dm-space-map-checker.h"
8
9#include <linux/device-mapper.h>
10#include <linux/export.h>
11#include <linux/vmalloc.h>
12
13#ifdef CONFIG_DM_DEBUG_SPACE_MAPS
14
15#define DM_MSG_PREFIX "space map checker"
16
17/*----------------------------------------------------------------*/
18
19struct count_array {
20 dm_block_t nr;
21 dm_block_t nr_free;
22
23 uint32_t *counts;
24};
25
26static int ca_get_count(struct count_array *ca, dm_block_t b, uint32_t *count)
27{
28 if (b >= ca->nr)
29 return -EINVAL;
30
31 *count = ca->counts[b];
32 return 0;
33}
34
35static int ca_count_more_than_one(struct count_array *ca, dm_block_t b, int *r)
36{
37 if (b >= ca->nr)
38 return -EINVAL;
39
40 *r = ca->counts[b] > 1;
41 return 0;
42}
43
44static int ca_set_count(struct count_array *ca, dm_block_t b, uint32_t count)
45{
46 uint32_t old_count;
47
48 if (b >= ca->nr)
49 return -EINVAL;
50
51 old_count = ca->counts[b];
52
53 if (!count && old_count)
54 ca->nr_free++;
55
56 else if (count && !old_count)
57 ca->nr_free--;
58
59 ca->counts[b] = count;
60 return 0;
61}
62
63static int ca_inc_block(struct count_array *ca, dm_block_t b)
64{
65 if (b >= ca->nr)
66 return -EINVAL;
67
68 ca_set_count(ca, b, ca->counts[b] + 1);
69 return 0;
70}
71
72static int ca_dec_block(struct count_array *ca, dm_block_t b)
73{
74 if (b >= ca->nr)
75 return -EINVAL;
76
77 BUG_ON(ca->counts[b] == 0);
78 ca_set_count(ca, b, ca->counts[b] - 1);
79 return 0;
80}
81
82static int ca_create(struct count_array *ca, struct dm_space_map *sm)
83{
84 int r;
85 dm_block_t nr_blocks;
86
87 r = dm_sm_get_nr_blocks(sm, &nr_blocks);
88 if (r)
89 return r;
90
91 ca->nr = nr_blocks;
92 ca->nr_free = nr_blocks;
93
94 if (!nr_blocks)
95 ca->counts = NULL;
96 else {
97 ca->counts = vzalloc(sizeof(*ca->counts) * nr_blocks);
98 if (!ca->counts)
99 return -ENOMEM;
100 }
101
102 return 0;
103}
104
105static void ca_destroy(struct count_array *ca)
106{
107 vfree(ca->counts);
108}
109
110static int ca_load(struct count_array *ca, struct dm_space_map *sm)
111{
112 int r;
113 uint32_t count;
114 dm_block_t nr_blocks, i;
115
116 r = dm_sm_get_nr_blocks(sm, &nr_blocks);
117 if (r)
118 return r;
119
120 BUG_ON(ca->nr != nr_blocks);
121
122 DMWARN("Loading debug space map from disk. This may take some time");
123 for (i = 0; i < nr_blocks; i++) {
124 r = dm_sm_get_count(sm, i, &count);
125 if (r) {
126 DMERR("load failed");
127 return r;
128 }
129
130 ca_set_count(ca, i, count);
131 }
132 DMWARN("Load complete");
133
134 return 0;
135}
136
137static int ca_extend(struct count_array *ca, dm_block_t extra_blocks)
138{
139 dm_block_t nr_blocks = ca->nr + extra_blocks;
140 uint32_t *counts = vzalloc(sizeof(*counts) * nr_blocks);
141 if (!counts)
142 return -ENOMEM;
143
144 if (ca->counts) {
145 memcpy(counts, ca->counts, sizeof(*counts) * ca->nr);
146 ca_destroy(ca);
147 }
148 ca->nr = nr_blocks;
149 ca->nr_free += extra_blocks;
150 ca->counts = counts;
151 return 0;
152}
153
154static int ca_commit(struct count_array *old, struct count_array *new)
155{
156 if (old->nr != new->nr) {
157 BUG_ON(old->nr > new->nr);
158 ca_extend(old, new->nr - old->nr);
159 }
160
161 BUG_ON(old->nr != new->nr);
162 old->nr_free = new->nr_free;
163 memcpy(old->counts, new->counts, sizeof(*old->counts) * old->nr);
164 return 0;
165}
166
167/*----------------------------------------------------------------*/
168
169struct sm_checker {
170 struct dm_space_map sm;
171
172 struct count_array old_counts;
173 struct count_array counts;
174
175 struct dm_space_map *real_sm;
176};
177
178static void sm_checker_destroy(struct dm_space_map *sm)
179{
180 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
181
182 dm_sm_destroy(smc->real_sm);
183 ca_destroy(&smc->old_counts);
184 ca_destroy(&smc->counts);
185 kfree(smc);
186}
187
188static int sm_checker_get_nr_blocks(struct dm_space_map *sm, dm_block_t *count)
189{
190 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
191 int r = dm_sm_get_nr_blocks(smc->real_sm, count);
192 if (!r)
193 BUG_ON(smc->old_counts.nr != *count);
194 return r;
195}
196
197static int sm_checker_get_nr_free(struct dm_space_map *sm, dm_block_t *count)
198{
199 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
200 int r = dm_sm_get_nr_free(smc->real_sm, count);
201 if (!r) {
202 /*
203 * Slow, but we know it's correct.
204 */
205 dm_block_t b, n = 0;
206 for (b = 0; b < smc->old_counts.nr; b++)
207 if (smc->old_counts.counts[b] == 0 &&
208 smc->counts.counts[b] == 0)
209 n++;
210
211 if (n != *count)
212 DMERR("free block counts differ, checker %u, sm-disk:%u",
213 (unsigned) n, (unsigned) *count);
214 }
215 return r;
216}
217
218static int sm_checker_new_block(struct dm_space_map *sm, dm_block_t *b)
219{
220 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
221 int r = dm_sm_new_block(smc->real_sm, b);
222
223 if (!r) {
224 BUG_ON(*b >= smc->old_counts.nr);
225 BUG_ON(smc->old_counts.counts[*b] != 0);
226 BUG_ON(*b >= smc->counts.nr);
227 BUG_ON(smc->counts.counts[*b] != 0);
228 ca_set_count(&smc->counts, *b, 1);
229 }
230
231 return r;
232}
233
234static int sm_checker_inc_block(struct dm_space_map *sm, dm_block_t b)
235{
236 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
237 int r = dm_sm_inc_block(smc->real_sm, b);
238 int r2 = ca_inc_block(&smc->counts, b);
239 BUG_ON(r != r2);
240 return r;
241}
242
243static int sm_checker_dec_block(struct dm_space_map *sm, dm_block_t b)
244{
245 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
246 int r = dm_sm_dec_block(smc->real_sm, b);
247 int r2 = ca_dec_block(&smc->counts, b);
248 BUG_ON(r != r2);
249 return r;
250}
251
252static int sm_checker_get_count(struct dm_space_map *sm, dm_block_t b, uint32_t *result)
253{
254 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
255 uint32_t result2 = 0;
256 int r = dm_sm_get_count(smc->real_sm, b, result);
257 int r2 = ca_get_count(&smc->counts, b, &result2);
258
259 BUG_ON(r != r2);
260 if (!r)
261 BUG_ON(*result != result2);
262 return r;
263}
264
265static int sm_checker_count_more_than_one(struct dm_space_map *sm, dm_block_t b, int *result)
266{
267 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
268 int result2 = 0;
269 int r = dm_sm_count_is_more_than_one(smc->real_sm, b, result);
270 int r2 = ca_count_more_than_one(&smc->counts, b, &result2);
271
272 BUG_ON(r != r2);
273 if (!r)
274 BUG_ON(!(*result) && result2);
275 return r;
276}
277
278static int sm_checker_set_count(struct dm_space_map *sm, dm_block_t b, uint32_t count)
279{
280 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
281 uint32_t old_rc;
282 int r = dm_sm_set_count(smc->real_sm, b, count);
283 int r2;
284
285 BUG_ON(b >= smc->counts.nr);
286 old_rc = smc->counts.counts[b];
287 r2 = ca_set_count(&smc->counts, b, count);
288 BUG_ON(r != r2);
289
290 return r;
291}
292
293static int sm_checker_commit(struct dm_space_map *sm)
294{
295 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
296 int r;
297
298 r = dm_sm_commit(smc->real_sm);
299 if (r)
300 return r;
301
302 r = ca_commit(&smc->old_counts, &smc->counts);
303 if (r)
304 return r;
305
306 return 0;
307}
308
309static int sm_checker_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
310{
311 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
312 int r = dm_sm_extend(smc->real_sm, extra_blocks);
313 if (r)
314 return r;
315
316 return ca_extend(&smc->counts, extra_blocks);
317}
318
319static int sm_checker_root_size(struct dm_space_map *sm, size_t *result)
320{
321 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
322 return dm_sm_root_size(smc->real_sm, result);
323}
324
325static int sm_checker_copy_root(struct dm_space_map *sm, void *copy_to_here_le, size_t len)
326{
327 struct sm_checker *smc = container_of(sm, struct sm_checker, sm);
328 return dm_sm_copy_root(smc->real_sm, copy_to_here_le, len);
329}
330
331/*----------------------------------------------------------------*/
332
333static struct dm_space_map ops_ = {
334 .destroy = sm_checker_destroy,
335 .get_nr_blocks = sm_checker_get_nr_blocks,
336 .get_nr_free = sm_checker_get_nr_free,
337 .inc_block = sm_checker_inc_block,
338 .dec_block = sm_checker_dec_block,
339 .new_block = sm_checker_new_block,
340 .get_count = sm_checker_get_count,
341 .count_is_more_than_one = sm_checker_count_more_than_one,
342 .set_count = sm_checker_set_count,
343 .commit = sm_checker_commit,
344 .extend = sm_checker_extend,
345 .root_size = sm_checker_root_size,
346 .copy_root = sm_checker_copy_root
347};
348
349struct dm_space_map *dm_sm_checker_create(struct dm_space_map *sm)
350{
351 int r;
352 struct sm_checker *smc;
353
354 if (IS_ERR_OR_NULL(sm))
355 return ERR_PTR(-EINVAL);
356
357 smc = kmalloc(sizeof(*smc), GFP_KERNEL);
358 if (!smc)
359 return ERR_PTR(-ENOMEM);
360
361 memcpy(&smc->sm, &ops_, sizeof(smc->sm));
362 r = ca_create(&smc->old_counts, sm);
363 if (r) {
364 kfree(smc);
365 return ERR_PTR(r);
366 }
367
368 r = ca_create(&smc->counts, sm);
369 if (r) {
370 ca_destroy(&smc->old_counts);
371 kfree(smc);
372 return ERR_PTR(r);
373 }
374
375 smc->real_sm = sm;
376
377 r = ca_load(&smc->counts, sm);
378 if (r) {
379 ca_destroy(&smc->counts);
380 ca_destroy(&smc->old_counts);
381 kfree(smc);
382 return ERR_PTR(r);
383 }
384
385 r = ca_commit(&smc->old_counts, &smc->counts);
386 if (r) {
387 ca_destroy(&smc->counts);
388 ca_destroy(&smc->old_counts);
389 kfree(smc);
390 return ERR_PTR(r);
391 }
392
393 return &smc->sm;
394}
395EXPORT_SYMBOL_GPL(dm_sm_checker_create);
396
397struct dm_space_map *dm_sm_checker_create_fresh(struct dm_space_map *sm)
398{
399 int r;
400 struct sm_checker *smc;
401
402 if (IS_ERR_OR_NULL(sm))
403 return ERR_PTR(-EINVAL);
404
405 smc = kmalloc(sizeof(*smc), GFP_KERNEL);
406 if (!smc)
407 return ERR_PTR(-ENOMEM);
408
409 memcpy(&smc->sm, &ops_, sizeof(smc->sm));
410 r = ca_create(&smc->old_counts, sm);
411 if (r) {
412 kfree(smc);
413 return ERR_PTR(r);
414 }
415
416 r = ca_create(&smc->counts, sm);
417 if (r) {
418 ca_destroy(&smc->old_counts);
419 kfree(smc);
420 return ERR_PTR(r);
421 }
422
423 smc->real_sm = sm;
424 return &smc->sm;
425}
426EXPORT_SYMBOL_GPL(dm_sm_checker_create_fresh);
427
428/*----------------------------------------------------------------*/
429
430#else
431
432struct dm_space_map *dm_sm_checker_create(struct dm_space_map *sm)
433{
434 return sm;
435}
436EXPORT_SYMBOL_GPL(dm_sm_checker_create);
437
438struct dm_space_map *dm_sm_checker_create_fresh(struct dm_space_map *sm)
439{
440 return sm;
441}
442EXPORT_SYMBOL_GPL(dm_sm_checker_create_fresh);
443
444/*----------------------------------------------------------------*/
445
446#endif
diff --git a/drivers/md/persistent-data/dm-space-map-checker.h b/drivers/md/persistent-data/dm-space-map-checker.h
deleted file mode 100644
index 444dccf6688c..000000000000
--- a/drivers/md/persistent-data/dm-space-map-checker.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * Copyright (C) 2011 Red Hat, Inc.
3 *
4 * This file is released under the GPL.
5 */
6
7#ifndef SNAPSHOTS_SPACE_MAP_CHECKER_H
8#define SNAPSHOTS_SPACE_MAP_CHECKER_H
9
10#include "dm-space-map.h"
11
12/*----------------------------------------------------------------*/
13
14/*
15 * This space map wraps a real on-disk space map, and verifies all of its
16 * operations. It uses a lot of memory, so only use if you have a specific
17 * problem that you're debugging.
18 *
19 * Ownership of @sm passes.
20 */
21struct dm_space_map *dm_sm_checker_create(struct dm_space_map *sm);
22struct dm_space_map *dm_sm_checker_create_fresh(struct dm_space_map *sm);
23
24/*----------------------------------------------------------------*/
25
26#endif
diff --git a/drivers/md/persistent-data/dm-space-map-common.c b/drivers/md/persistent-data/dm-space-map-common.c
index ff3beed6ad2d..d77602d63c83 100644
--- a/drivers/md/persistent-data/dm-space-map-common.c
+++ b/drivers/md/persistent-data/dm-space-map-common.c
@@ -224,6 +224,7 @@ static int sm_ll_init(struct ll_disk *ll, struct dm_transaction_manager *tm)
224 ll->nr_blocks = 0; 224 ll->nr_blocks = 0;
225 ll->bitmap_root = 0; 225 ll->bitmap_root = 0;
226 ll->ref_count_root = 0; 226 ll->ref_count_root = 0;
227 ll->bitmap_index_changed = false;
227 228
228 return 0; 229 return 0;
229} 230}
@@ -476,7 +477,15 @@ int sm_ll_dec(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev)
476 477
477int sm_ll_commit(struct ll_disk *ll) 478int sm_ll_commit(struct ll_disk *ll)
478{ 479{
479 return ll->commit(ll); 480 int r = 0;
481
482 if (ll->bitmap_index_changed) {
483 r = ll->commit(ll);
484 if (!r)
485 ll->bitmap_index_changed = false;
486 }
487
488 return r;
480} 489}
481 490
482/*----------------------------------------------------------------*/ 491/*----------------------------------------------------------------*/
@@ -491,6 +500,7 @@ static int metadata_ll_load_ie(struct ll_disk *ll, dm_block_t index,
491static int metadata_ll_save_ie(struct ll_disk *ll, dm_block_t index, 500static int metadata_ll_save_ie(struct ll_disk *ll, dm_block_t index,
492 struct disk_index_entry *ie) 501 struct disk_index_entry *ie)
493{ 502{
503 ll->bitmap_index_changed = true;
494 memcpy(ll->mi_le.index + index, ie, sizeof(*ie)); 504 memcpy(ll->mi_le.index + index, ie, sizeof(*ie));
495 return 0; 505 return 0;
496} 506}
diff --git a/drivers/md/persistent-data/dm-space-map-common.h b/drivers/md/persistent-data/dm-space-map-common.h
index 8f220821a9a9..b3078d5eda0c 100644
--- a/drivers/md/persistent-data/dm-space-map-common.h
+++ b/drivers/md/persistent-data/dm-space-map-common.h
@@ -78,6 +78,7 @@ struct ll_disk {
78 open_index_fn open_index; 78 open_index_fn open_index;
79 max_index_entries_fn max_entries; 79 max_index_entries_fn max_entries;
80 commit_fn commit; 80 commit_fn commit;
81 bool bitmap_index_changed:1;
81}; 82};
82 83
83struct disk_sm_root { 84struct disk_sm_root {
diff --git a/drivers/md/persistent-data/dm-space-map-disk.c b/drivers/md/persistent-data/dm-space-map-disk.c
index 3d0ed5332883..f6d29e614ab7 100644
--- a/drivers/md/persistent-data/dm-space-map-disk.c
+++ b/drivers/md/persistent-data/dm-space-map-disk.c
@@ -4,7 +4,6 @@
4 * This file is released under the GPL. 4 * This file is released under the GPL.
5 */ 5 */
6 6
7#include "dm-space-map-checker.h"
8#include "dm-space-map-common.h" 7#include "dm-space-map-common.h"
9#include "dm-space-map-disk.h" 8#include "dm-space-map-disk.h"
10#include "dm-space-map.h" 9#include "dm-space-map.h"
@@ -252,9 +251,8 @@ static struct dm_space_map ops = {
252 .copy_root = sm_disk_copy_root 251 .copy_root = sm_disk_copy_root
253}; 252};
254 253
255static struct dm_space_map *dm_sm_disk_create_real( 254struct dm_space_map *dm_sm_disk_create(struct dm_transaction_manager *tm,
256 struct dm_transaction_manager *tm, 255 dm_block_t nr_blocks)
257 dm_block_t nr_blocks)
258{ 256{
259 int r; 257 int r;
260 struct sm_disk *smd; 258 struct sm_disk *smd;
@@ -285,27 +283,10 @@ bad:
285 kfree(smd); 283 kfree(smd);
286 return ERR_PTR(r); 284 return ERR_PTR(r);
287} 285}
288
289struct dm_space_map *dm_sm_disk_create(struct dm_transaction_manager *tm,
290 dm_block_t nr_blocks)
291{
292 struct dm_space_map *sm = dm_sm_disk_create_real(tm, nr_blocks);
293 struct dm_space_map *smc;
294
295 if (IS_ERR_OR_NULL(sm))
296 return sm;
297
298 smc = dm_sm_checker_create_fresh(sm);
299 if (IS_ERR(smc))
300 dm_sm_destroy(sm);
301
302 return smc;
303}
304EXPORT_SYMBOL_GPL(dm_sm_disk_create); 286EXPORT_SYMBOL_GPL(dm_sm_disk_create);
305 287
306static struct dm_space_map *dm_sm_disk_open_real( 288struct dm_space_map *dm_sm_disk_open(struct dm_transaction_manager *tm,
307 struct dm_transaction_manager *tm, 289 void *root_le, size_t len)
308 void *root_le, size_t len)
309{ 290{
310 int r; 291 int r;
311 struct sm_disk *smd; 292 struct sm_disk *smd;
@@ -332,13 +313,6 @@ bad:
332 kfree(smd); 313 kfree(smd);
333 return ERR_PTR(r); 314 return ERR_PTR(r);
334} 315}
335
336struct dm_space_map *dm_sm_disk_open(struct dm_transaction_manager *tm,
337 void *root_le, size_t len)
338{
339 return dm_sm_checker_create(
340 dm_sm_disk_open_real(tm, root_le, len));
341}
342EXPORT_SYMBOL_GPL(dm_sm_disk_open); 316EXPORT_SYMBOL_GPL(dm_sm_disk_open);
343 317
344/*----------------------------------------------------------------*/ 318/*----------------------------------------------------------------*/
diff --git a/drivers/md/persistent-data/dm-transaction-manager.c b/drivers/md/persistent-data/dm-transaction-manager.c
index e5604b32d91f..d247a35da3c6 100644
--- a/drivers/md/persistent-data/dm-transaction-manager.c
+++ b/drivers/md/persistent-data/dm-transaction-manager.c
@@ -5,7 +5,6 @@
5 */ 5 */
6#include "dm-transaction-manager.h" 6#include "dm-transaction-manager.h"
7#include "dm-space-map.h" 7#include "dm-space-map.h"
8#include "dm-space-map-checker.h"
9#include "dm-space-map-disk.h" 8#include "dm-space-map-disk.h"
10#include "dm-space-map-metadata.h" 9#include "dm-space-map-metadata.h"
11#include "dm-persistent-data-internal.h" 10#include "dm-persistent-data-internal.h"
@@ -220,13 +219,24 @@ static int __shadow_block(struct dm_transaction_manager *tm, dm_block_t orig,
220 if (r < 0) 219 if (r < 0)
221 return r; 220 return r;
222 221
223 r = dm_bm_unlock_move(orig_block, new); 222 /*
224 if (r < 0) { 223 * It would be tempting to use dm_bm_unlock_move here, but some
224 * code, such as the space maps, keeps using the old data structures
225 * secure in the knowledge they won't be changed until the next
226 * transaction. Using unlock_move would force a synchronous read
227 * since the old block would no longer be in the cache.
228 */
229 r = dm_bm_write_lock_zero(tm->bm, new, v, result);
230 if (r) {
225 dm_bm_unlock(orig_block); 231 dm_bm_unlock(orig_block);
226 return r; 232 return r;
227 } 233 }
228 234
229 return dm_bm_write_lock(tm->bm, new, v, result); 235 memcpy(dm_block_data(*result), dm_block_data(orig_block),
236 dm_bm_block_size(tm->bm));
237
238 dm_bm_unlock(orig_block);
239 return r;
230} 240}
231 241
232int dm_tm_shadow_block(struct dm_transaction_manager *tm, dm_block_t orig, 242int dm_tm_shadow_block(struct dm_transaction_manager *tm, dm_block_t orig,
@@ -311,98 +321,61 @@ struct dm_block_manager *dm_tm_get_bm(struct dm_transaction_manager *tm)
311 321
312static int dm_tm_create_internal(struct dm_block_manager *bm, 322static int dm_tm_create_internal(struct dm_block_manager *bm,
313 dm_block_t sb_location, 323 dm_block_t sb_location,
314 struct dm_block_validator *sb_validator,
315 size_t root_offset, size_t root_max_len,
316 struct dm_transaction_manager **tm, 324 struct dm_transaction_manager **tm,
317 struct dm_space_map **sm, 325 struct dm_space_map **sm,
318 struct dm_block **sblock, 326 int create,
319 int create) 327 void *sm_root, size_t sm_len)
320{ 328{
321 int r; 329 int r;
322 struct dm_space_map *inner;
323 330
324 inner = dm_sm_metadata_init(); 331 *sm = dm_sm_metadata_init();
325 if (IS_ERR(inner)) 332 if (IS_ERR(*sm))
326 return PTR_ERR(inner); 333 return PTR_ERR(*sm);
327 334
328 *tm = dm_tm_create(bm, inner); 335 *tm = dm_tm_create(bm, *sm);
329 if (IS_ERR(*tm)) { 336 if (IS_ERR(*tm)) {
330 dm_sm_destroy(inner); 337 dm_sm_destroy(*sm);
331 return PTR_ERR(*tm); 338 return PTR_ERR(*tm);
332 } 339 }
333 340
334 if (create) { 341 if (create) {
335 r = dm_bm_write_lock_zero(dm_tm_get_bm(*tm), sb_location, 342 r = dm_sm_metadata_create(*sm, *tm, dm_bm_nr_blocks(bm),
336 sb_validator, sblock);
337 if (r < 0) {
338 DMERR("couldn't lock superblock");
339 goto bad1;
340 }
341
342 r = dm_sm_metadata_create(inner, *tm, dm_bm_nr_blocks(bm),
343 sb_location); 343 sb_location);
344 if (r) { 344 if (r) {
345 DMERR("couldn't create metadata space map"); 345 DMERR("couldn't create metadata space map");
346 goto bad2; 346 goto bad;
347 }
348
349 *sm = dm_sm_checker_create(inner);
350 if (IS_ERR(*sm)) {
351 r = PTR_ERR(*sm);
352 goto bad2;
353 } 347 }
354 348
355 } else { 349 } else {
356 r = dm_bm_write_lock(dm_tm_get_bm(*tm), sb_location, 350 r = dm_sm_metadata_open(*sm, *tm, sm_root, sm_len);
357 sb_validator, sblock);
358 if (r < 0) {
359 DMERR("couldn't lock superblock");
360 goto bad1;
361 }
362
363 r = dm_sm_metadata_open(inner, *tm,
364 dm_block_data(*sblock) + root_offset,
365 root_max_len);
366 if (r) { 351 if (r) {
367 DMERR("couldn't open metadata space map"); 352 DMERR("couldn't open metadata space map");
368 goto bad2; 353 goto bad;
369 }
370
371 *sm = dm_sm_checker_create(inner);
372 if (IS_ERR(*sm)) {
373 r = PTR_ERR(*sm);
374 goto bad2;
375 } 354 }
376 } 355 }
377 356
378 return 0; 357 return 0;
379 358
380bad2: 359bad:
381 dm_tm_unlock(*tm, *sblock);
382bad1:
383 dm_tm_destroy(*tm); 360 dm_tm_destroy(*tm);
384 dm_sm_destroy(inner); 361 dm_sm_destroy(*sm);
385 return r; 362 return r;
386} 363}
387 364
388int dm_tm_create_with_sm(struct dm_block_manager *bm, dm_block_t sb_location, 365int dm_tm_create_with_sm(struct dm_block_manager *bm, dm_block_t sb_location,
389 struct dm_block_validator *sb_validator,
390 struct dm_transaction_manager **tm, 366 struct dm_transaction_manager **tm,
391 struct dm_space_map **sm, struct dm_block **sblock) 367 struct dm_space_map **sm)
392{ 368{
393 return dm_tm_create_internal(bm, sb_location, sb_validator, 369 return dm_tm_create_internal(bm, sb_location, tm, sm, 1, NULL, 0);
394 0, 0, tm, sm, sblock, 1);
395} 370}
396EXPORT_SYMBOL_GPL(dm_tm_create_with_sm); 371EXPORT_SYMBOL_GPL(dm_tm_create_with_sm);
397 372
398int dm_tm_open_with_sm(struct dm_block_manager *bm, dm_block_t sb_location, 373int dm_tm_open_with_sm(struct dm_block_manager *bm, dm_block_t sb_location,
399 struct dm_block_validator *sb_validator, 374 void *sm_root, size_t root_len,
400 size_t root_offset, size_t root_max_len,
401 struct dm_transaction_manager **tm, 375 struct dm_transaction_manager **tm,
402 struct dm_space_map **sm, struct dm_block **sblock) 376 struct dm_space_map **sm)
403{ 377{
404 return dm_tm_create_internal(bm, sb_location, sb_validator, root_offset, 378 return dm_tm_create_internal(bm, sb_location, tm, sm, 0, sm_root, root_len);
405 root_max_len, tm, sm, sblock, 0);
406} 379}
407EXPORT_SYMBOL_GPL(dm_tm_open_with_sm); 380EXPORT_SYMBOL_GPL(dm_tm_open_with_sm);
408 381
diff --git a/drivers/md/persistent-data/dm-transaction-manager.h b/drivers/md/persistent-data/dm-transaction-manager.h
index 6da784871db4..b5b139076ca5 100644
--- a/drivers/md/persistent-data/dm-transaction-manager.h
+++ b/drivers/md/persistent-data/dm-transaction-manager.h
@@ -115,16 +115,17 @@ struct dm_block_manager *dm_tm_get_bm(struct dm_transaction_manager *tm);
115 * 115 *
116 * Returns a tm that has an open transaction to write the new disk sm. 116 * Returns a tm that has an open transaction to write the new disk sm.
117 * Caller should store the new sm root and commit. 117 * Caller should store the new sm root and commit.
118 *
119 * The superblock location is passed so the metadata space map knows it
120 * shouldn't be used.
118 */ 121 */
119int dm_tm_create_with_sm(struct dm_block_manager *bm, dm_block_t sb_location, 122int dm_tm_create_with_sm(struct dm_block_manager *bm, dm_block_t sb_location,
120 struct dm_block_validator *sb_validator,
121 struct dm_transaction_manager **tm, 123 struct dm_transaction_manager **tm,
122 struct dm_space_map **sm, struct dm_block **sblock); 124 struct dm_space_map **sm);
123 125
124int dm_tm_open_with_sm(struct dm_block_manager *bm, dm_block_t sb_location, 126int dm_tm_open_with_sm(struct dm_block_manager *bm, dm_block_t sb_location,
125 struct dm_block_validator *sb_validator, 127 void *sm_root, size_t root_len,
126 size_t root_offset, size_t root_max_len,
127 struct dm_transaction_manager **tm, 128 struct dm_transaction_manager **tm,
128 struct dm_space_map **sm, struct dm_block **sblock); 129 struct dm_space_map **sm);
129 130
130#endif /* _LINUX_DM_TRANSACTION_MANAGER_H */ 131#endif /* _LINUX_DM_TRANSACTION_MANAGER_H */
diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c
new file mode 100644
index 000000000000..b67a3018b136
--- /dev/null
+++ b/drivers/mfd/88pm800.c
@@ -0,0 +1,596 @@
1/*
2 * Base driver for Marvell 88PM800
3 *
4 * Copyright (C) 2012 Marvell International Ltd.
5 * Haojian Zhuang <haojian.zhuang@marvell.com>
6 * Joseph(Yossi) Hanin <yhanin@marvell.com>
7 * Qiao Zhou <zhouqiao@marvell.com>
8 *
9 * This file is subject to the terms and conditions of the GNU General
10 * Public License. See the file "COPYING" in the main directory of this
11 * archive for more details.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/i2c.h>
26#include <linux/mfd/core.h>
27#include <linux/mfd/88pm80x.h>
28#include <linux/slab.h>
29
30#define PM800_CHIP_ID (0x00)
31
32/* Interrupt Registers */
33#define PM800_INT_STATUS1 (0x05)
34#define PM800_ONKEY_INT_STS1 (1 << 0)
35#define PM800_EXTON_INT_STS1 (1 << 1)
36#define PM800_CHG_INT_STS1 (1 << 2)
37#define PM800_BAT_INT_STS1 (1 << 3)
38#define PM800_RTC_INT_STS1 (1 << 4)
39#define PM800_CLASSD_OC_INT_STS1 (1 << 5)
40
41#define PM800_INT_STATUS2 (0x06)
42#define PM800_VBAT_INT_STS2 (1 << 0)
43#define PM800_VSYS_INT_STS2 (1 << 1)
44#define PM800_VCHG_INT_STS2 (1 << 2)
45#define PM800_TINT_INT_STS2 (1 << 3)
46#define PM800_GPADC0_INT_STS2 (1 << 4)
47#define PM800_TBAT_INT_STS2 (1 << 5)
48#define PM800_GPADC2_INT_STS2 (1 << 6)
49#define PM800_GPADC3_INT_STS2 (1 << 7)
50
51#define PM800_INT_STATUS3 (0x07)
52
53#define PM800_INT_STATUS4 (0x08)
54#define PM800_GPIO0_INT_STS4 (1 << 0)
55#define PM800_GPIO1_INT_STS4 (1 << 1)
56#define PM800_GPIO2_INT_STS4 (1 << 2)
57#define PM800_GPIO3_INT_STS4 (1 << 3)
58#define PM800_GPIO4_INT_STS4 (1 << 4)
59
60#define PM800_INT_ENA_1 (0x09)
61#define PM800_ONKEY_INT_ENA1 (1 << 0)
62#define PM800_EXTON_INT_ENA1 (1 << 1)
63#define PM800_CHG_INT_ENA1 (1 << 2)
64#define PM800_BAT_INT_ENA1 (1 << 3)
65#define PM800_RTC_INT_ENA1 (1 << 4)
66#define PM800_CLASSD_OC_INT_ENA1 (1 << 5)
67
68#define PM800_INT_ENA_2 (0x0A)
69#define PM800_VBAT_INT_ENA2 (1 << 0)
70#define PM800_VSYS_INT_ENA2 (1 << 1)
71#define PM800_VCHG_INT_ENA2 (1 << 2)
72#define PM800_TINT_INT_ENA2 (1 << 3)
73
74#define PM800_INT_ENA_3 (0x0B)
75#define PM800_GPADC0_INT_ENA3 (1 << 0)
76#define PM800_GPADC1_INT_ENA3 (1 << 1)
77#define PM800_GPADC2_INT_ENA3 (1 << 2)
78#define PM800_GPADC3_INT_ENA3 (1 << 3)
79#define PM800_GPADC4_INT_ENA3 (1 << 4)
80
81#define PM800_INT_ENA_4 (0x0C)
82#define PM800_GPIO0_INT_ENA4 (1 << 0)
83#define PM800_GPIO1_INT_ENA4 (1 << 1)
84#define PM800_GPIO2_INT_ENA4 (1 << 2)
85#define PM800_GPIO3_INT_ENA4 (1 << 3)
86#define PM800_GPIO4_INT_ENA4 (1 << 4)
87
88/* number of INT_ENA & INT_STATUS regs */
89#define PM800_INT_REG_NUM (4)
90
91/* Interrupt Number in 88PM800 */
92enum {
93 PM800_IRQ_ONKEY, /*EN1b0 *//*0 */
94 PM800_IRQ_EXTON, /*EN1b1 */
95 PM800_IRQ_CHG, /*EN1b2 */
96 PM800_IRQ_BAT, /*EN1b3 */
97 PM800_IRQ_RTC, /*EN1b4 */
98 PM800_IRQ_CLASSD, /*EN1b5 *//*5 */
99 PM800_IRQ_VBAT, /*EN2b0 */
100 PM800_IRQ_VSYS, /*EN2b1 */
101 PM800_IRQ_VCHG, /*EN2b2 */
102 PM800_IRQ_TINT, /*EN2b3 */
103 PM800_IRQ_GPADC0, /*EN3b0 *//*10 */
104 PM800_IRQ_GPADC1, /*EN3b1 */
105 PM800_IRQ_GPADC2, /*EN3b2 */
106 PM800_IRQ_GPADC3, /*EN3b3 */
107 PM800_IRQ_GPADC4, /*EN3b4 */
108 PM800_IRQ_GPIO0, /*EN4b0 *//*15 */
109 PM800_IRQ_GPIO1, /*EN4b1 */
110 PM800_IRQ_GPIO2, /*EN4b2 */
111 PM800_IRQ_GPIO3, /*EN4b3 */
112 PM800_IRQ_GPIO4, /*EN4b4 *//*19 */
113 PM800_MAX_IRQ,
114};
115
116enum {
117 /* Procida */
118 PM800_CHIP_A0 = 0x60,
119 PM800_CHIP_A1 = 0x61,
120 PM800_CHIP_B0 = 0x62,
121 PM800_CHIP_C0 = 0x63,
122 PM800_CHIP_END = PM800_CHIP_C0,
123
124 /* Make sure to update this to the last stepping */
125 PM8XXX_CHIP_END = PM800_CHIP_END
126};
127
128static const struct i2c_device_id pm80x_id_table[] = {
129 {"88PM800", CHIP_PM800},
130 {} /* NULL terminated */
131};
132MODULE_DEVICE_TABLE(i2c, pm80x_id_table);
133
134static struct resource rtc_resources[] = {
135 {
136 .name = "88pm80x-rtc",
137 .start = PM800_IRQ_RTC,
138 .end = PM800_IRQ_RTC,
139 .flags = IORESOURCE_IRQ,
140 },
141};
142
143static struct mfd_cell rtc_devs[] = {
144 {
145 .name = "88pm80x-rtc",
146 .num_resources = ARRAY_SIZE(rtc_resources),
147 .resources = &rtc_resources[0],
148 .id = -1,
149 },
150};
151
152static struct resource onkey_resources[] = {
153 {
154 .name = "88pm80x-onkey",
155 .start = PM800_IRQ_ONKEY,
156 .end = PM800_IRQ_ONKEY,
157 .flags = IORESOURCE_IRQ,
158 },
159};
160
161static struct mfd_cell onkey_devs[] = {
162 {
163 .name = "88pm80x-onkey",
164 .num_resources = 1,
165 .resources = &onkey_resources[0],
166 .id = -1,
167 },
168};
169
170static const struct regmap_irq pm800_irqs[] = {
171 /* INT0 */
172 [PM800_IRQ_ONKEY] = {
173 .mask = PM800_ONKEY_INT_ENA1,
174 },
175 [PM800_IRQ_EXTON] = {
176 .mask = PM800_EXTON_INT_ENA1,
177 },
178 [PM800_IRQ_CHG] = {
179 .mask = PM800_CHG_INT_ENA1,
180 },
181 [PM800_IRQ_BAT] = {
182 .mask = PM800_BAT_INT_ENA1,
183 },
184 [PM800_IRQ_RTC] = {
185 .mask = PM800_RTC_INT_ENA1,
186 },
187 [PM800_IRQ_CLASSD] = {
188 .mask = PM800_CLASSD_OC_INT_ENA1,
189 },
190 /* INT1 */
191 [PM800_IRQ_VBAT] = {
192 .reg_offset = 1,
193 .mask = PM800_VBAT_INT_ENA2,
194 },
195 [PM800_IRQ_VSYS] = {
196 .reg_offset = 1,
197 .mask = PM800_VSYS_INT_ENA2,
198 },
199 [PM800_IRQ_VCHG] = {
200 .reg_offset = 1,
201 .mask = PM800_VCHG_INT_ENA2,
202 },
203 [PM800_IRQ_TINT] = {
204 .reg_offset = 1,
205 .mask = PM800_TINT_INT_ENA2,
206 },
207 /* INT2 */
208 [PM800_IRQ_GPADC0] = {
209 .reg_offset = 2,
210 .mask = PM800_GPADC0_INT_ENA3,
211 },
212 [PM800_IRQ_GPADC1] = {
213 .reg_offset = 2,
214 .mask = PM800_GPADC1_INT_ENA3,
215 },
216 [PM800_IRQ_GPADC2] = {
217 .reg_offset = 2,
218 .mask = PM800_GPADC2_INT_ENA3,
219 },
220 [PM800_IRQ_GPADC3] = {
221 .reg_offset = 2,
222 .mask = PM800_GPADC3_INT_ENA3,
223 },
224 [PM800_IRQ_GPADC4] = {
225 .reg_offset = 2,
226 .mask = PM800_GPADC4_INT_ENA3,
227 },
228 /* INT3 */
229 [PM800_IRQ_GPIO0] = {
230 .reg_offset = 3,
231 .mask = PM800_GPIO0_INT_ENA4,
232 },
233 [PM800_IRQ_GPIO1] = {
234 .reg_offset = 3,
235 .mask = PM800_GPIO1_INT_ENA4,
236 },
237 [PM800_IRQ_GPIO2] = {
238 .reg_offset = 3,
239 .mask = PM800_GPIO2_INT_ENA4,
240 },
241 [PM800_IRQ_GPIO3] = {
242 .reg_offset = 3,
243 .mask = PM800_GPIO3_INT_ENA4,
244 },
245 [PM800_IRQ_GPIO4] = {
246 .reg_offset = 3,
247 .mask = PM800_GPIO4_INT_ENA4,
248 },
249};
250
251static int __devinit device_gpadc_init(struct pm80x_chip *chip,
252 struct pm80x_platform_data *pdata)
253{
254 struct pm80x_subchip *subchip = chip->subchip;
255 struct regmap *map = subchip->regmap_gpadc;
256 int data = 0, mask = 0, ret = 0;
257
258 if (!map) {
259 dev_warn(chip->dev,
260 "Warning: gpadc regmap is not available!\n");
261 return -EINVAL;
262 }
263 /*
264 * initialize GPADC without activating it turn on GPADC
265 * measurments
266 */
267 ret = regmap_update_bits(map,
268 PM800_GPADC_MISC_CONFIG2,
269 PM800_GPADC_MISC_GPFSM_EN,
270 PM800_GPADC_MISC_GPFSM_EN);
271 if (ret < 0)
272 goto out;
273 /*
274 * This function configures the ADC as requires for
275 * CP implementation.CP does not "own" the ADC configuration
276 * registers and relies on AP.
277 * Reason: enable automatic ADC measurements needed
278 * for CP to get VBAT and RF temperature readings.
279 */
280 ret = regmap_update_bits(map, PM800_GPADC_MEAS_EN1,
281 PM800_MEAS_EN1_VBAT, PM800_MEAS_EN1_VBAT);
282 if (ret < 0)
283 goto out;
284 ret = regmap_update_bits(map, PM800_GPADC_MEAS_EN2,
285 (PM800_MEAS_EN2_RFTMP | PM800_MEAS_GP0_EN),
286 (PM800_MEAS_EN2_RFTMP | PM800_MEAS_GP0_EN));
287 if (ret < 0)
288 goto out;
289
290 /*
291 * the defult of PM800 is GPADC operates at 100Ks/s rate
292 * and Number of GPADC slots with active current bias prior
293 * to GPADC sampling = 1 slot for all GPADCs set for
294 * Temprature mesurmants
295 */
296 mask = (PM800_GPADC_GP_BIAS_EN0 | PM800_GPADC_GP_BIAS_EN1 |
297 PM800_GPADC_GP_BIAS_EN2 | PM800_GPADC_GP_BIAS_EN3);
298
299 if (pdata && (pdata->batt_det == 0))
300 data = (PM800_GPADC_GP_BIAS_EN0 | PM800_GPADC_GP_BIAS_EN1 |
301 PM800_GPADC_GP_BIAS_EN2 | PM800_GPADC_GP_BIAS_EN3);
302 else
303 data = (PM800_GPADC_GP_BIAS_EN0 | PM800_GPADC_GP_BIAS_EN2 |
304 PM800_GPADC_GP_BIAS_EN3);
305
306 ret = regmap_update_bits(map, PM800_GP_BIAS_ENA1, mask, data);
307 if (ret < 0)
308 goto out;
309
310 dev_info(chip->dev, "pm800 device_gpadc_init: Done\n");
311 return 0;
312
313out:
314 dev_info(chip->dev, "pm800 device_gpadc_init: Failed!\n");
315 return ret;
316}
317
318static int __devinit device_irq_init_800(struct pm80x_chip *chip)
319{
320 struct regmap *map = chip->regmap;
321 unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
322 int data, mask, ret = -EINVAL;
323
324 if (!map || !chip->irq) {
325 dev_err(chip->dev, "incorrect parameters\n");
326 return -EINVAL;
327 }
328
329 /*
330 * irq_mode defines the way of clearing interrupt. it's read-clear by
331 * default.
332 */
333 mask =
334 PM800_WAKEUP2_INV_INT | PM800_WAKEUP2_INT_CLEAR |
335 PM800_WAKEUP2_INT_MASK;
336
337 data = PM800_WAKEUP2_INT_CLEAR;
338 ret = regmap_update_bits(map, PM800_WAKEUP2, mask, data);
339
340 if (ret < 0)
341 goto out;
342
343 ret =
344 regmap_add_irq_chip(chip->regmap, chip->irq, flags, -1,
345 chip->regmap_irq_chip, &chip->irq_data);
346
347out:
348 return ret;
349}
350
351static void device_irq_exit_800(struct pm80x_chip *chip)
352{
353 regmap_del_irq_chip(chip->irq, chip->irq_data);
354}
355
356static struct regmap_irq_chip pm800_irq_chip = {
357 .name = "88pm800",
358 .irqs = pm800_irqs,
359 .num_irqs = ARRAY_SIZE(pm800_irqs),
360
361 .num_regs = 4,
362 .status_base = PM800_INT_STATUS1,
363 .mask_base = PM800_INT_ENA_1,
364 .ack_base = PM800_INT_STATUS1,
365};
366
367static int pm800_pages_init(struct pm80x_chip *chip)
368{
369 struct pm80x_subchip *subchip;
370 struct i2c_client *client = chip->client;
371
372 subchip = chip->subchip;
373 /* PM800 block power: i2c addr 0x31 */
374 if (subchip->power_page_addr) {
375 subchip->power_page =
376 i2c_new_dummy(client->adapter, subchip->power_page_addr);
377 subchip->regmap_power =
378 devm_regmap_init_i2c(subchip->power_page,
379 &pm80x_regmap_config);
380 i2c_set_clientdata(subchip->power_page, chip);
381 } else
382 dev_info(chip->dev,
383 "PM800 block power 0x31: No power_page_addr\n");
384
385 /* PM800 block GPADC: i2c addr 0x32 */
386 if (subchip->gpadc_page_addr) {
387 subchip->gpadc_page = i2c_new_dummy(client->adapter,
388 subchip->gpadc_page_addr);
389 subchip->regmap_gpadc =
390 devm_regmap_init_i2c(subchip->gpadc_page,
391 &pm80x_regmap_config);
392 i2c_set_clientdata(subchip->gpadc_page, chip);
393 } else
394 dev_info(chip->dev,
395 "PM800 block GPADC 0x32: No gpadc_page_addr\n");
396
397 return 0;
398}
399
400static void pm800_pages_exit(struct pm80x_chip *chip)
401{
402 struct pm80x_subchip *subchip;
403
404 regmap_exit(chip->regmap);
405 i2c_unregister_device(chip->client);
406
407 subchip = chip->subchip;
408 if (subchip->power_page) {
409 regmap_exit(subchip->regmap_power);
410 i2c_unregister_device(subchip->power_page);
411 }
412 if (subchip->gpadc_page) {
413 regmap_exit(subchip->regmap_gpadc);
414 i2c_unregister_device(subchip->gpadc_page);
415 }
416}
417
418static int __devinit device_800_init(struct pm80x_chip *chip,
419 struct pm80x_platform_data *pdata)
420{
421 int ret, pmic_id;
422 unsigned int val;
423
424 ret = regmap_read(chip->regmap, PM800_CHIP_ID, &val);
425 if (ret < 0) {
426 dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret);
427 goto out;
428 }
429
430 pmic_id = val & PM80X_VERSION_MASK;
431
432 if ((pmic_id >= PM800_CHIP_A0) && (pmic_id <= PM800_CHIP_END)) {
433 chip->version = val;
434 dev_info(chip->dev,
435 "88PM80x:Marvell 88PM800 (ID:0x%x) detected\n", val);
436 } else {
437 dev_err(chip->dev,
438 "Failed to detect Marvell 88PM800:ChipID[0x%x]\n", val);
439 ret = -EINVAL;
440 goto out;
441 }
442
443 /*
444 * alarm wake up bit will be clear in device_irq_init(),
445 * read before that
446 */
447 ret = regmap_read(chip->regmap, PM800_RTC_CONTROL, &val);
448 if (ret < 0) {
449 dev_err(chip->dev, "Failed to read RTC register: %d\n", ret);
450 goto out;
451 }
452 if (val & PM800_ALARM_WAKEUP) {
453 if (pdata && pdata->rtc)
454 pdata->rtc->rtc_wakeup = 1;
455 }
456
457 ret = device_gpadc_init(chip, pdata);
458 if (ret < 0) {
459 dev_err(chip->dev, "[%s]Failed to init gpadc\n", __func__);
460 goto out;
461 }
462
463 chip->regmap_irq_chip = &pm800_irq_chip;
464
465 ret = device_irq_init_800(chip);
466 if (ret < 0) {
467 dev_err(chip->dev, "[%s]Failed to init pm800 irq\n", __func__);
468 goto out;
469 }
470
471 ret =
472 mfd_add_devices(chip->dev, 0, &onkey_devs[0],
473 ARRAY_SIZE(onkey_devs), &onkey_resources[0], 0);
474 if (ret < 0) {
475 dev_err(chip->dev, "Failed to add onkey subdev\n");
476 goto out_dev;
477 } else
478 dev_info(chip->dev, "[%s]:Added mfd onkey_devs\n", __func__);
479
480 if (pdata && pdata->rtc) {
481 rtc_devs[0].platform_data = pdata->rtc;
482 rtc_devs[0].pdata_size = sizeof(struct pm80x_rtc_pdata);
483 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
484 ARRAY_SIZE(rtc_devs), NULL, 0);
485 if (ret < 0) {
486 dev_err(chip->dev, "Failed to add rtc subdev\n");
487 goto out_dev;
488 } else
489 dev_info(chip->dev,
490 "[%s]:Added mfd rtc_devs\n", __func__);
491 }
492
493 return 0;
494out_dev:
495 mfd_remove_devices(chip->dev);
496 device_irq_exit_800(chip);
497out:
498 return ret;
499}
500
501static int __devinit pm800_probe(struct i2c_client *client,
502 const struct i2c_device_id *id)
503{
504 int ret = 0;
505 struct pm80x_chip *chip;
506 struct pm80x_platform_data *pdata = client->dev.platform_data;
507 struct pm80x_subchip *subchip;
508
509 ret = pm80x_init(client, id);
510 if (ret) {
511 dev_err(&client->dev, "pm800_init fail\n");
512 goto out_init;
513 }
514
515 chip = i2c_get_clientdata(client);
516
517 /* init subchip for PM800 */
518 subchip =
519 devm_kzalloc(&client->dev, sizeof(struct pm80x_subchip),
520 GFP_KERNEL);
521 if (!subchip) {
522 ret = -ENOMEM;
523 goto err_subchip_alloc;
524 }
525
526 subchip->power_page_addr = pdata->power_page_addr;
527 subchip->gpadc_page_addr = pdata->gpadc_page_addr;
528 chip->subchip = subchip;
529
530 ret = device_800_init(chip, pdata);
531 if (ret) {
532 dev_err(chip->dev, "%s id 0x%x failed!\n", __func__, chip->id);
533 goto err_800_init;
534 }
535
536 ret = pm800_pages_init(chip);
537 if (ret) {
538 dev_err(&client->dev, "pm800_pages_init failed!\n");
539 goto err_page_init;
540 }
541
542 if (pdata->plat_config)
543 pdata->plat_config(chip, pdata);
544
545err_page_init:
546 mfd_remove_devices(chip->dev);
547 device_irq_exit_800(chip);
548err_800_init:
549 devm_kfree(&client->dev, subchip);
550err_subchip_alloc:
551 pm80x_deinit(client);
552out_init:
553 return ret;
554}
555
556static int __devexit pm800_remove(struct i2c_client *client)
557{
558 struct pm80x_chip *chip = i2c_get_clientdata(client);
559
560 mfd_remove_devices(chip->dev);
561 device_irq_exit_800(chip);
562
563 pm800_pages_exit(chip);
564 devm_kfree(&client->dev, chip->subchip);
565
566 pm80x_deinit(client);
567
568 return 0;
569}
570
571static struct i2c_driver pm800_driver = {
572 .driver = {
573 .name = "88PM80X",
574 .owner = THIS_MODULE,
575 .pm = &pm80x_pm_ops,
576 },
577 .probe = pm800_probe,
578 .remove = __devexit_p(pm800_remove),
579 .id_table = pm80x_id_table,
580};
581
582static int __init pm800_i2c_init(void)
583{
584 return i2c_add_driver(&pm800_driver);
585}
586subsys_initcall(pm800_i2c_init);
587
588static void __exit pm800_i2c_exit(void)
589{
590 i2c_del_driver(&pm800_driver);
591}
592module_exit(pm800_i2c_exit);
593
594MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM800");
595MODULE_AUTHOR("Qiao Zhou <zhouqiao@marvell.com>");
596MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/88pm805.c b/drivers/mfd/88pm805.c
new file mode 100644
index 000000000000..6146583589f6
--- /dev/null
+++ b/drivers/mfd/88pm805.c
@@ -0,0 +1,301 @@
1/*
2 * Base driver for Marvell 88PM805
3 *
4 * Copyright (C) 2012 Marvell International Ltd.
5 * Haojian Zhuang <haojian.zhuang@marvell.com>
6 * Joseph(Yossi) Hanin <yhanin@marvell.com>
7 * Qiao Zhou <zhouqiao@marvell.com>
8 *
9 * This file is subject to the terms and conditions of the GNU General
10 * Public License. See the file "COPYING" in the main directory of this
11 * archive for more details.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/i2c.h>
26#include <linux/irq.h>
27#include <linux/mfd/core.h>
28#include <linux/mfd/88pm80x.h>
29#include <linux/slab.h>
30#include <linux/delay.h>
31
32#define PM805_CHIP_ID (0x00)
33
34static const struct i2c_device_id pm80x_id_table[] = {
35 {"88PM805", CHIP_PM805},
36 {} /* NULL terminated */
37};
38MODULE_DEVICE_TABLE(i2c, pm80x_id_table);
39
40/* Interrupt Number in 88PM805 */
41enum {
42 PM805_IRQ_LDO_OFF, /*0 */
43 PM805_IRQ_SRC_DPLL_LOCK, /*1 */
44 PM805_IRQ_CLIP_FAULT,
45 PM805_IRQ_MIC_CONFLICT,
46 PM805_IRQ_HP2_SHRT,
47 PM805_IRQ_HP1_SHRT, /*5 */
48 PM805_IRQ_FINE_PLL_FAULT,
49 PM805_IRQ_RAW_PLL_FAULT,
50 PM805_IRQ_VOLP_BTN_DET,
51 PM805_IRQ_VOLM_BTN_DET,
52 PM805_IRQ_SHRT_BTN_DET, /*10 */
53 PM805_IRQ_MIC_DET, /*11 */
54
55 PM805_MAX_IRQ,
56};
57
58static struct resource codec_resources[] = {
59 {
60 /* Headset microphone insertion or removal */
61 .name = "micin",
62 .start = PM805_IRQ_MIC_DET,
63 .end = PM805_IRQ_MIC_DET,
64 .flags = IORESOURCE_IRQ,
65 },
66 {
67 /* Audio short HP1 */
68 .name = "audio-short1",
69 .start = PM805_IRQ_HP1_SHRT,
70 .end = PM805_IRQ_HP1_SHRT,
71 .flags = IORESOURCE_IRQ,
72 },
73 {
74 /* Audio short HP2 */
75 .name = "audio-short2",
76 .start = PM805_IRQ_HP2_SHRT,
77 .end = PM805_IRQ_HP2_SHRT,
78 .flags = IORESOURCE_IRQ,
79 },
80};
81
82static struct mfd_cell codec_devs[] = {
83 {
84 .name = "88pm80x-codec",
85 .num_resources = ARRAY_SIZE(codec_resources),
86 .resources = &codec_resources[0],
87 .id = -1,
88 },
89};
90
91static struct regmap_irq pm805_irqs[] = {
92 /* INT0 */
93 [PM805_IRQ_LDO_OFF] = {
94 .mask = PM805_INT1_HP1_SHRT,
95 },
96 [PM805_IRQ_SRC_DPLL_LOCK] = {
97 .mask = PM805_INT1_HP2_SHRT,
98 },
99 [PM805_IRQ_CLIP_FAULT] = {
100 .mask = PM805_INT1_MIC_CONFLICT,
101 },
102 [PM805_IRQ_MIC_CONFLICT] = {
103 .mask = PM805_INT1_CLIP_FAULT,
104 },
105 [PM805_IRQ_HP2_SHRT] = {
106 .mask = PM805_INT1_LDO_OFF,
107 },
108 [PM805_IRQ_HP1_SHRT] = {
109 .mask = PM805_INT1_SRC_DPLL_LOCK,
110 },
111 /* INT1 */
112 [PM805_IRQ_FINE_PLL_FAULT] = {
113 .reg_offset = 1,
114 .mask = PM805_INT2_MIC_DET,
115 },
116 [PM805_IRQ_RAW_PLL_FAULT] = {
117 .reg_offset = 1,
118 .mask = PM805_INT2_SHRT_BTN_DET,
119 },
120 [PM805_IRQ_VOLP_BTN_DET] = {
121 .reg_offset = 1,
122 .mask = PM805_INT2_VOLM_BTN_DET,
123 },
124 [PM805_IRQ_VOLM_BTN_DET] = {
125 .reg_offset = 1,
126 .mask = PM805_INT2_VOLP_BTN_DET,
127 },
128 [PM805_IRQ_SHRT_BTN_DET] = {
129 .reg_offset = 1,
130 .mask = PM805_INT2_RAW_PLL_FAULT,
131 },
132 [PM805_IRQ_MIC_DET] = {
133 .reg_offset = 1,
134 .mask = PM805_INT2_FINE_PLL_FAULT,
135 },
136};
137
138static int __devinit device_irq_init_805(struct pm80x_chip *chip)
139{
140 struct regmap *map = chip->regmap;
141 unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
142 int data, mask, ret = -EINVAL;
143
144 if (!map || !chip->irq) {
145 dev_err(chip->dev, "incorrect parameters\n");
146 return -EINVAL;
147 }
148
149 /*
150 * irq_mode defines the way of clearing interrupt. it's read-clear by
151 * default.
152 */
153 mask =
154 PM805_STATUS0_INT_CLEAR | PM805_STATUS0_INV_INT |
155 PM800_STATUS0_INT_MASK;
156
157 data = PM805_STATUS0_INT_CLEAR;
158 ret = regmap_update_bits(map, PM805_INT_STATUS0, mask, data);
159 /*
160 * PM805_INT_STATUS is under 32K clock domain, so need to
161 * add proper delay before the next I2C register access.
162 */
163 msleep(1);
164
165 if (ret < 0)
166 goto out;
167
168 ret =
169 regmap_add_irq_chip(chip->regmap, chip->irq, flags, -1,
170 chip->regmap_irq_chip, &chip->irq_data);
171
172out:
173 return ret;
174}
175
176static void device_irq_exit_805(struct pm80x_chip *chip)
177{
178 regmap_del_irq_chip(chip->irq, chip->irq_data);
179}
180
181static struct regmap_irq_chip pm805_irq_chip = {
182 .name = "88pm805",
183 .irqs = pm805_irqs,
184 .num_irqs = ARRAY_SIZE(pm805_irqs),
185
186 .num_regs = 2,
187 .status_base = PM805_INT_STATUS1,
188 .mask_base = PM805_INT_MASK1,
189 .ack_base = PM805_INT_STATUS1,
190};
191
192static int __devinit device_805_init(struct pm80x_chip *chip)
193{
194 int ret = 0;
195 unsigned int val;
196 struct regmap *map = chip->regmap;
197
198 if (!map) {
199 dev_err(chip->dev, "regmap is invalid\n");
200 return -EINVAL;
201 }
202
203 ret = regmap_read(map, PM805_CHIP_ID, &val);
204 if (ret < 0) {
205 dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret);
206 goto out_irq_init;
207 }
208 chip->version = val;
209
210 chip->regmap_irq_chip = &pm805_irq_chip;
211
212 ret = device_irq_init_805(chip);
213 if (ret < 0) {
214 dev_err(chip->dev, "Failed to init pm805 irq!\n");
215 goto out_irq_init;
216 }
217
218 ret = mfd_add_devices(chip->dev, 0, &codec_devs[0],
219 ARRAY_SIZE(codec_devs), &codec_resources[0], 0);
220 if (ret < 0) {
221 dev_err(chip->dev, "Failed to add codec subdev\n");
222 goto out_codec;
223 } else
224 dev_info(chip->dev, "[%s]:Added mfd codec_devs\n", __func__);
225
226 return 0;
227
228out_codec:
229 device_irq_exit_805(chip);
230out_irq_init:
231 return ret;
232}
233
234static int __devinit pm805_probe(struct i2c_client *client,
235 const struct i2c_device_id *id)
236{
237 int ret = 0;
238 struct pm80x_chip *chip;
239 struct pm80x_platform_data *pdata = client->dev.platform_data;
240
241 ret = pm80x_init(client, id);
242 if (ret) {
243 dev_err(&client->dev, "pm805_init fail!\n");
244 goto out_init;
245 }
246
247 chip = i2c_get_clientdata(client);
248
249 ret = device_805_init(chip);
250 if (ret) {
251 dev_err(chip->dev, "%s id 0x%x failed!\n", __func__, chip->id);
252 goto err_805_init;
253 }
254
255 if (pdata->plat_config)
256 pdata->plat_config(chip, pdata);
257
258err_805_init:
259 pm80x_deinit(client);
260out_init:
261 return ret;
262}
263
264static int __devexit pm805_remove(struct i2c_client *client)
265{
266 struct pm80x_chip *chip = i2c_get_clientdata(client);
267
268 mfd_remove_devices(chip->dev);
269 device_irq_exit_805(chip);
270
271 pm80x_deinit(client);
272
273 return 0;
274}
275
276static struct i2c_driver pm805_driver = {
277 .driver = {
278 .name = "88PM80X",
279 .owner = THIS_MODULE,
280 .pm = &pm80x_pm_ops,
281 },
282 .probe = pm805_probe,
283 .remove = __devexit_p(pm805_remove),
284 .id_table = pm80x_id_table,
285};
286
287static int __init pm805_i2c_init(void)
288{
289 return i2c_add_driver(&pm805_driver);
290}
291subsys_initcall(pm805_i2c_init);
292
293static void __exit pm805_i2c_exit(void)
294{
295 i2c_del_driver(&pm805_driver);
296}
297module_exit(pm805_i2c_exit);
298
299MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM805");
300MODULE_AUTHOR("Qiao Zhou <zhouqiao@marvell.com>");
301MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/88pm80x.c b/drivers/mfd/88pm80x.c
new file mode 100644
index 000000000000..cd0bf527d764
--- /dev/null
+++ b/drivers/mfd/88pm80x.c
@@ -0,0 +1,145 @@
1/*
2 * I2C driver for Marvell 88PM80x
3 *
4 * Copyright (C) 2012 Marvell International Ltd.
5 * Haojian Zhuang <haojian.zhuang@marvell.com>
6 * Joseph(Yossi) Hanin <yhanin@marvell.com>
7 * Qiao Zhou <zhouqiao@marvell.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/i2c.h>
16#include <linux/mfd/88pm80x.h>
17#include <linux/slab.h>
18#include <linux/uaccess.h>
19#include <linux/err.h>
20
21/*
22 * workaround: some registers needed by pm805 are defined in pm800, so
23 * need to use this global variable to maintain the relation between
24 * pm800 and pm805. would remove it after HW chip fixes the issue.
25 */
26static struct pm80x_chip *g_pm80x_chip;
27
28const struct regmap_config pm80x_regmap_config = {
29 .reg_bits = 8,
30 .val_bits = 8,
31};
32EXPORT_SYMBOL_GPL(pm80x_regmap_config);
33
34int __devinit pm80x_init(struct i2c_client *client,
35 const struct i2c_device_id *id)
36{
37 struct pm80x_chip *chip;
38 struct regmap *map;
39 int ret = 0;
40
41 chip =
42 devm_kzalloc(&client->dev, sizeof(struct pm80x_chip), GFP_KERNEL);
43 if (!chip)
44 return -ENOMEM;
45
46 map = devm_regmap_init_i2c(client, &pm80x_regmap_config);
47 if (IS_ERR(map)) {
48 ret = PTR_ERR(map);
49 dev_err(&client->dev, "Failed to allocate register map: %d\n",
50 ret);
51 goto err_regmap_init;
52 }
53
54 chip->id = id->driver_data;
55 if (chip->id < CHIP_PM800 || chip->id > CHIP_PM805) {
56 ret = -EINVAL;
57 goto err_chip_id;
58 }
59
60 chip->client = client;
61 chip->regmap = map;
62
63 chip->irq = client->irq;
64
65 chip->dev = &client->dev;
66 dev_set_drvdata(chip->dev, chip);
67 i2c_set_clientdata(chip->client, chip);
68
69 device_init_wakeup(&client->dev, 1);
70
71 /*
72 * workaround: set g_pm80x_chip to the first probed chip. if the
73 * second chip is probed, just point to the companion to each
74 * other so that pm805 can access those specific register. would
75 * remove it after HW chip fixes the issue.
76 */
77 if (!g_pm80x_chip)
78 g_pm80x_chip = chip;
79 else {
80 chip->companion = g_pm80x_chip->client;
81 g_pm80x_chip->companion = chip->client;
82 }
83
84 return 0;
85
86err_chip_id:
87 regmap_exit(map);
88err_regmap_init:
89 devm_kfree(&client->dev, chip);
90 return ret;
91}
92EXPORT_SYMBOL_GPL(pm80x_init);
93
94int pm80x_deinit(struct i2c_client *client)
95{
96 struct pm80x_chip *chip = i2c_get_clientdata(client);
97
98 /*
99 * workaround: clear the dependency between pm800 and pm805.
100 * would remove it after HW chip fixes the issue.
101 */
102 if (g_pm80x_chip->companion)
103 g_pm80x_chip->companion = NULL;
104 else
105 g_pm80x_chip = NULL;
106
107 regmap_exit(chip->regmap);
108 devm_kfree(&client->dev, chip);
109
110 return 0;
111}
112EXPORT_SYMBOL_GPL(pm80x_deinit);
113
114#ifdef CONFIG_PM_SLEEP
115static int pm80x_suspend(struct device *dev)
116{
117 struct i2c_client *client = container_of(dev, struct i2c_client, dev);
118 struct pm80x_chip *chip = i2c_get_clientdata(client);
119
120 if (chip && chip->wu_flag)
121 if (device_may_wakeup(chip->dev))
122 enable_irq_wake(chip->irq);
123
124 return 0;
125}
126
127static int pm80x_resume(struct device *dev)
128{
129 struct i2c_client *client = container_of(dev, struct i2c_client, dev);
130 struct pm80x_chip *chip = i2c_get_clientdata(client);
131
132 if (chip && chip->wu_flag)
133 if (device_may_wakeup(chip->dev))
134 disable_irq_wake(chip->irq);
135
136 return 0;
137}
138#endif
139
140SIMPLE_DEV_PM_OPS(pm80x_pm_ops, pm80x_suspend, pm80x_resume);
141EXPORT_SYMBOL_GPL(pm80x_pm_ops);
142
143MODULE_DESCRIPTION("I2C Driver for Marvell 88PM80x");
144MODULE_AUTHOR("Qiao Zhou <zhouqiao@marvell.com>");
145MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index 87bd5ba38d5b..d09918cf1b15 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -90,6 +90,10 @@ static struct resource charger_resources[] __devinitdata = {
90 {PM8607_IRQ_VCHG, PM8607_IRQ_VCHG, "vchg voltage", IORESOURCE_IRQ,}, 90 {PM8607_IRQ_VCHG, PM8607_IRQ_VCHG, "vchg voltage", IORESOURCE_IRQ,},
91}; 91};
92 92
93static struct resource preg_resources[] __devinitdata = {
94 {PM8606_ID_PREG, PM8606_ID_PREG, "preg", IORESOURCE_IO,},
95};
96
93static struct resource rtc_resources[] __devinitdata = { 97static struct resource rtc_resources[] __devinitdata = {
94 {PM8607_IRQ_RTC, PM8607_IRQ_RTC, "rtc", IORESOURCE_IRQ,}, 98 {PM8607_IRQ_RTC, PM8607_IRQ_RTC, "rtc", IORESOURCE_IRQ,},
95}; 99};
@@ -142,9 +146,19 @@ static struct mfd_cell codec_devs[] = {
142 {"88pm860x-codec", -1,}, 146 {"88pm860x-codec", -1,},
143}; 147};
144 148
149static struct regulator_consumer_supply preg_supply[] = {
150 REGULATOR_SUPPLY("preg", "charger-manager"),
151};
152
153static struct regulator_init_data preg_init_data = {
154 .num_consumer_supplies = ARRAY_SIZE(preg_supply),
155 .consumer_supplies = &preg_supply[0],
156};
157
145static struct mfd_cell power_devs[] = { 158static struct mfd_cell power_devs[] = {
146 {"88pm860x-battery", -1,}, 159 {"88pm860x-battery", -1,},
147 {"88pm860x-charger", -1,}, 160 {"88pm860x-charger", -1,},
161 {"88pm860x-preg", -1,},
148}; 162};
149 163
150static struct mfd_cell rtc_devs[] = { 164static struct mfd_cell rtc_devs[] = {
@@ -768,6 +782,15 @@ static void __devinit device_power_init(struct pm860x_chip *chip,
768 &charger_resources[0], chip->irq_base); 782 &charger_resources[0], chip->irq_base);
769 if (ret < 0) 783 if (ret < 0)
770 dev_err(chip->dev, "Failed to add charger subdev\n"); 784 dev_err(chip->dev, "Failed to add charger subdev\n");
785
786 power_devs[2].platform_data = &preg_init_data;
787 power_devs[2].pdata_size = sizeof(struct regulator_init_data);
788 power_devs[2].num_resources = ARRAY_SIZE(preg_resources);
789 power_devs[2].resources = &preg_resources[0],
790 ret = mfd_add_devices(chip->dev, 0, &power_devs[2], 1,
791 &preg_resources[0], chip->irq_base);
792 if (ret < 0)
793 dev_err(chip->dev, "Failed to add preg subdev\n");
771} 794}
772 795
773static void __devinit device_onkey_init(struct pm860x_chip *chip, 796static void __devinit device_onkey_init(struct pm860x_chip *chip,
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 92144ed1ad46..d1facef28a60 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -7,6 +7,7 @@ menu "Multifunction device drivers"
7 7
8config MFD_CORE 8config MFD_CORE
9 tristate 9 tristate
10 select IRQ_DOMAIN
10 default n 11 default n
11 12
12config MFD_88PM860X 13config MFD_88PM860X
@@ -20,6 +21,30 @@ config MFD_88PM860X
20 select individual components like voltage regulators, RTC and 21 select individual components like voltage regulators, RTC and
21 battery-charger under the corresponding menus. 22 battery-charger under the corresponding menus.
22 23
24config MFD_88PM800
25 tristate "Support Marvell 88PM800"
26 depends on I2C=y && GENERIC_HARDIRQS
27 select REGMAP_I2C
28 select REGMAP_IRQ
29 select MFD_CORE
30 help
31 This supports for Marvell 88PM800 Power Management IC.
32 This includes the I2C driver and the core APIs _only_, you have to
33 select individual components like voltage regulators, RTC and
34 battery-charger under the corresponding menus.
35
36config MFD_88PM805
37 tristate "Support Marvell 88PM805"
38 depends on I2C=y && GENERIC_HARDIRQS
39 select REGMAP_I2C
40 select REGMAP_IRQ
41 select MFD_CORE
42 help
43 This supports for Marvell 88PM805 Power Management IC. This includes
44 the I2C driver and the core APIs _only_, you have to select individual
45 components like codec device, headset/Mic device under the
46 corresponding menus.
47
23config MFD_SM501 48config MFD_SM501
24 tristate "Support for Silicon Motion SM501" 49 tristate "Support for Silicon Motion SM501"
25 ---help--- 50 ---help---
@@ -173,8 +198,9 @@ config MFD_TPS65217
173 198
174config MFD_TPS6586X 199config MFD_TPS6586X
175 bool "TPS6586x Power Management chips" 200 bool "TPS6586x Power Management chips"
176 depends on I2C=y && GPIOLIB && GENERIC_HARDIRQS 201 depends on I2C=y && GENERIC_HARDIRQS
177 select MFD_CORE 202 select MFD_CORE
203 select REGMAP_I2C
178 depends on REGULATOR 204 depends on REGULATOR
179 help 205 help
180 If you say yes here you get support for the TPS6586X series of 206 If you say yes here you get support for the TPS6586X series of
@@ -276,6 +302,7 @@ config TWL6030_PWM
276 tristate "TWL6030 PWM (Pulse Width Modulator) Support" 302 tristate "TWL6030 PWM (Pulse Width Modulator) Support"
277 depends on TWL4030_CORE 303 depends on TWL4030_CORE
278 select HAVE_PWM 304 select HAVE_PWM
305 depends on !PWM
279 default n 306 default n
280 help 307 help
281 Say yes here if you want support for TWL6030 PWM. 308 Say yes here if you want support for TWL6030 PWM.
@@ -423,6 +450,19 @@ config PMIC_ADP5520
423 individual components like LCD backlight, LEDs, GPIOs and Kepad 450 individual components like LCD backlight, LEDs, GPIOs and Kepad
424 under the corresponding menus. 451 under the corresponding menus.
425 452
453config MFD_MAX77686
454 bool "Maxim Semiconductor MAX77686 PMIC Support"
455 depends on I2C=y && GENERIC_HARDIRQS
456 select MFD_CORE
457 select REGMAP_I2C
458 select IRQ_DOMAIN
459 help
460 Say yes here to support for Maxim Semiconductor MAX77686.
461 This is a Power Management IC with RTC on chip.
462 This driver provides common support for accessing the device;
463 additional drivers must be enabled in order to use the functionality
464 of the device.
465
426config MFD_MAX77693 466config MFD_MAX77693
427 bool "Maxim Semiconductor MAX77693 PMIC Support" 467 bool "Maxim Semiconductor MAX77693 PMIC Support"
428 depends on I2C=y && GENERIC_HARDIRQS 468 depends on I2C=y && GENERIC_HARDIRQS
@@ -450,6 +490,7 @@ config MFD_MAX8997
450 bool "Maxim Semiconductor MAX8997/8966 PMIC Support" 490 bool "Maxim Semiconductor MAX8997/8966 PMIC Support"
451 depends on I2C=y && GENERIC_HARDIRQS 491 depends on I2C=y && GENERIC_HARDIRQS
452 select MFD_CORE 492 select MFD_CORE
493 select IRQ_DOMAIN
453 help 494 help
454 Say yes here to support for Maxim Semiconductor MAX8997/8966. 495 Say yes here to support for Maxim Semiconductor MAX8997/8966.
455 This is a Power Management IC with RTC, Flash, Fuel Gauge, Haptic, 496 This is a Power Management IC with RTC, Flash, Fuel Gauge, Haptic,
@@ -469,17 +510,56 @@ config MFD_MAX8998
469 additional drivers must be enabled in order to use the functionality 510 additional drivers must be enabled in order to use the functionality
470 of the device. 511 of the device.
471 512
472config MFD_S5M_CORE 513config MFD_SEC_CORE
473 bool "SAMSUNG S5M Series Support" 514 bool "SAMSUNG Electronics PMIC Series Support"
474 depends on I2C=y && GENERIC_HARDIRQS 515 depends on I2C=y && GENERIC_HARDIRQS
475 select MFD_CORE 516 select MFD_CORE
476 select REGMAP_I2C 517 select REGMAP_I2C
518 select REGMAP_IRQ
477 help 519 help
478 Support for the Samsung Electronics S5M MFD series. 520 Support for the Samsung Electronics MFD series.
479 This driver provides common support for accessing the device, 521 This driver provides common support for accessing the device,
480 additional drivers must be enabled in order to use the functionality 522 additional drivers must be enabled in order to use the functionality
481 of the device 523 of the device
482 524
525config MFD_ARIZONA
526 select REGMAP
527 select REGMAP_IRQ
528 select MFD_CORE
529 bool
530
531config MFD_ARIZONA_I2C
532 tristate "Support Wolfson Microelectronics Arizona platform with I2C"
533 select MFD_ARIZONA
534 select MFD_CORE
535 select REGMAP_I2C
536 depends on I2C
537 help
538 Support for the Wolfson Microelectronics Arizona platform audio SoC
539 core functionality controlled via I2C.
540
541config MFD_ARIZONA_SPI
542 tristate "Support Wolfson Microelectronics Arizona platform with SPI"
543 select MFD_ARIZONA
544 select MFD_CORE
545 select REGMAP_SPI
546 depends on SPI_MASTER
547 help
548 Support for the Wolfson Microelectronics Arizona platform audio SoC
549 core functionality controlled via I2C.
550
551config MFD_WM5102
552 bool "Support Wolfson Microelectronics WM5102"
553 depends on MFD_ARIZONA
554 help
555 Support for Wolfson Microelectronics WM5102 low power audio SoC
556
557config MFD_WM5110
558 bool "Support Wolfson Microelectronics WM5110"
559 depends on MFD_ARIZONA
560 help
561 Support for Wolfson Microelectronics WM5110 low power audio SoC
562
483config MFD_WM8400 563config MFD_WM8400
484 bool "Support Wolfson Microelectronics WM8400" 564 bool "Support Wolfson Microelectronics WM8400"
485 select MFD_CORE 565 select MFD_CORE
@@ -697,6 +777,7 @@ config AB8500_CORE
697 bool "ST-Ericsson AB8500 Mixed Signal Power Management chip" 777 bool "ST-Ericsson AB8500 Mixed Signal Power Management chip"
698 depends on GENERIC_HARDIRQS && ABX500_CORE && MFD_DB8500_PRCMU 778 depends on GENERIC_HARDIRQS && ABX500_CORE && MFD_DB8500_PRCMU
699 select MFD_CORE 779 select MFD_CORE
780 select IRQ_DOMAIN
700 help 781 help
701 Select this option to enable access to AB8500 power management 782 Select this option to enable access to AB8500 power management
702 chip. This connects to U8500 either on the SSP/SPI bus (deprecated 783 chip. This connects to U8500 either on the SSP/SPI bus (deprecated
@@ -704,16 +785,6 @@ config AB8500_CORE
704 the irq_chip parts for handling the Mixed Signal chip events. 785 the irq_chip parts for handling the Mixed Signal chip events.
705 This chip embeds various other multimedia funtionalities as well. 786 This chip embeds various other multimedia funtionalities as well.
706 787
707config AB8500_I2C_CORE
708 bool "AB8500 register access via PRCMU I2C"
709 depends on AB8500_CORE && MFD_DB8500_PRCMU
710 default y
711 help
712 This enables register access to the AB8500 chip via PRCMU I2C.
713 The AB8500 chip can be accessed via SPI or I2C. On DB8500 hardware
714 the I2C bus is connected to the Power Reset
715 and Mangagement Unit, PRCMU.
716
717config AB8500_DEBUG 788config AB8500_DEBUG
718 bool "Enable debug info via debugfs" 789 bool "Enable debug info via debugfs"
719 depends on AB8500_CORE && DEBUG_FS 790 depends on AB8500_CORE && DEBUG_FS
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 75f6ed68a4b9..79dd22d1dc3d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -4,6 +4,8 @@
4 4
588pm860x-objs := 88pm860x-core.o 88pm860x-i2c.o 588pm860x-objs := 88pm860x-core.o 88pm860x-i2c.o
6obj-$(CONFIG_MFD_88PM860X) += 88pm860x.o 6obj-$(CONFIG_MFD_88PM860X) += 88pm860x.o
7obj-$(CONFIG_MFD_88PM800) += 88pm800.o 88pm80x.o
8obj-$(CONFIG_MFD_88PM805) += 88pm805.o 88pm80x.o
7obj-$(CONFIG_MFD_SM501) += sm501.o 9obj-$(CONFIG_MFD_SM501) += sm501.o
8obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o 10obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o
9 11
@@ -24,6 +26,16 @@ obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o tmio_core.o
24obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o tmio_core.o 26obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o tmio_core.o
25obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o tmio_core.o 27obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o tmio_core.o
26 28
29obj-$(CONFIG_MFD_ARIZONA) += arizona-core.o
30obj-$(CONFIG_MFD_ARIZONA) += arizona-irq.o
31obj-$(CONFIG_MFD_ARIZONA_I2C) += arizona-i2c.o
32obj-$(CONFIG_MFD_ARIZONA_SPI) += arizona-spi.o
33ifneq ($(CONFIG_MFD_WM5102),n)
34obj-$(CONFIG_MFD_ARIZONA) += wm5102-tables.o
35endif
36ifneq ($(CONFIG_MFD_WM5110),n)
37obj-$(CONFIG_MFD_ARIZONA) += wm5110-tables.o
38endif
27obj-$(CONFIG_MFD_WM8400) += wm8400-core.o 39obj-$(CONFIG_MFD_WM8400) += wm8400-core.o
28wm831x-objs := wm831x-core.o wm831x-irq.o wm831x-otp.o 40wm831x-objs := wm831x-core.o wm831x-irq.o wm831x-otp.o
29wm831x-objs += wm831x-auxadc.o 41wm831x-objs += wm831x-auxadc.o
@@ -78,6 +90,7 @@ obj-$(CONFIG_PMIC_DA9052) += da9052-core.o
78obj-$(CONFIG_MFD_DA9052_SPI) += da9052-spi.o 90obj-$(CONFIG_MFD_DA9052_SPI) += da9052-spi.o
79obj-$(CONFIG_MFD_DA9052_I2C) += da9052-i2c.o 91obj-$(CONFIG_MFD_DA9052_I2C) += da9052-i2c.o
80 92
93obj-$(CONFIG_MFD_MAX77686) += max77686.o max77686-irq.o
81obj-$(CONFIG_MFD_MAX77693) += max77693.o max77693-irq.o 94obj-$(CONFIG_MFD_MAX77693) += max77693.o max77693-irq.o
82max8925-objs := max8925-core.o max8925-i2c.o 95max8925-objs := max8925-core.o max8925-i2c.o
83obj-$(CONFIG_MFD_MAX8925) += max8925.o 96obj-$(CONFIG_MFD_MAX8925) += max8925.o
@@ -116,6 +129,6 @@ obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
116obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o 129obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o
117obj-$(CONFIG_MFD_PALMAS) += palmas.o 130obj-$(CONFIG_MFD_PALMAS) += palmas.o
118obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o 131obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o
119obj-$(CONFIG_MFD_S5M_CORE) += s5m-core.o s5m-irq.o 132obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o
120obj-$(CONFIG_MFD_ANATOP) += anatop-mfd.o 133obj-$(CONFIG_MFD_ANATOP) += anatop-mfd.o
121obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o 134obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index 1efad20fb175..4276aab4f196 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -867,7 +867,7 @@ static int __devinit ab3100_probe(struct i2c_client *client,
867 int err; 867 int err;
868 int i; 868 int i;
869 869
870 ab3100 = kzalloc(sizeof(struct ab3100), GFP_KERNEL); 870 ab3100 = devm_kzalloc(&client->dev, sizeof(struct ab3100), GFP_KERNEL);
871 if (!ab3100) { 871 if (!ab3100) {
872 dev_err(&client->dev, "could not allocate AB3100 device\n"); 872 dev_err(&client->dev, "could not allocate AB3100 device\n");
873 return -ENOMEM; 873 return -ENOMEM;
@@ -921,7 +921,7 @@ static int __devinit ab3100_probe(struct i2c_client *client,
921 921
922 /* Attach a second dummy i2c_client to the test register address */ 922 /* Attach a second dummy i2c_client to the test register address */
923 ab3100->testreg_client = i2c_new_dummy(client->adapter, 923 ab3100->testreg_client = i2c_new_dummy(client->adapter,
924 client->addr + 1); 924 client->addr + 1);
925 if (!ab3100->testreg_client) { 925 if (!ab3100->testreg_client) {
926 err = -ENOMEM; 926 err = -ENOMEM;
927 goto exit_no_testreg_client; 927 goto exit_no_testreg_client;
@@ -931,13 +931,13 @@ static int __devinit ab3100_probe(struct i2c_client *client,
931 if (err) 931 if (err)
932 goto exit_no_setup; 932 goto exit_no_setup;
933 933
934 err = request_threaded_irq(client->irq, NULL, ab3100_irq_handler, 934 err = devm_request_threaded_irq(&client->dev,
935 IRQF_ONESHOT, "ab3100-core", ab3100); 935 client->irq, NULL, ab3100_irq_handler,
936 /* This real unpredictable IRQ is of course sampled for entropy */ 936 IRQF_ONESHOT, "ab3100-core", ab3100);
937 rand_initialize_irq(client->irq);
938
939 if (err) 937 if (err)
940 goto exit_no_irq; 938 goto exit_no_irq;
939 /* This real unpredictable IRQ is of course sampled for entropy */
940 rand_initialize_irq(client->irq);
941 941
942 err = abx500_register_ops(&client->dev, &ab3100_ops); 942 err = abx500_register_ops(&client->dev, &ab3100_ops);
943 if (err) 943 if (err)
@@ -962,7 +962,6 @@ static int __devinit ab3100_probe(struct i2c_client *client,
962 i2c_unregister_device(ab3100->testreg_client); 962 i2c_unregister_device(ab3100->testreg_client);
963 exit_no_testreg_client: 963 exit_no_testreg_client:
964 exit_no_detect: 964 exit_no_detect:
965 kfree(ab3100);
966 return err; 965 return err;
967} 966}
968 967
@@ -972,16 +971,8 @@ static int __devexit ab3100_remove(struct i2c_client *client)
972 971
973 /* Unregister subdevices */ 972 /* Unregister subdevices */
974 mfd_remove_devices(&client->dev); 973 mfd_remove_devices(&client->dev);
975
976 ab3100_remove_debugfs(); 974 ab3100_remove_debugfs();
977 i2c_unregister_device(ab3100->testreg_client); 975 i2c_unregister_device(ab3100->testreg_client);
978
979 /*
980 * At this point, all subscribers should have unregistered
981 * their notifiers so deactivate IRQ
982 */
983 free_irq(client->irq, ab3100);
984 kfree(ab3100);
985 return 0; 976 return 0;
986} 977}
987 978
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index dac0e2998603..626b4ecaf647 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -11,6 +11,7 @@
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/irqdomain.h>
14#include <linux/delay.h> 15#include <linux/delay.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include <linux/module.h> 17#include <linux/module.h>
@@ -140,7 +141,7 @@ static const char ab8500_version_str[][7] = {
140 [AB8500_VERSION_AB8540] = "AB8540", 141 [AB8500_VERSION_AB8540] = "AB8540",
141}; 142};
142 143
143static int ab8500_i2c_write(struct ab8500 *ab8500, u16 addr, u8 data) 144static int ab8500_prcmu_write(struct ab8500 *ab8500, u16 addr, u8 data)
144{ 145{
145 int ret; 146 int ret;
146 147
@@ -150,7 +151,7 @@ static int ab8500_i2c_write(struct ab8500 *ab8500, u16 addr, u8 data)
150 return ret; 151 return ret;
151} 152}
152 153
153static int ab8500_i2c_write_masked(struct ab8500 *ab8500, u16 addr, u8 mask, 154static int ab8500_prcmu_write_masked(struct ab8500 *ab8500, u16 addr, u8 mask,
154 u8 data) 155 u8 data)
155{ 156{
156 int ret; 157 int ret;
@@ -162,7 +163,7 @@ static int ab8500_i2c_write_masked(struct ab8500 *ab8500, u16 addr, u8 mask,
162 return ret; 163 return ret;
163} 164}
164 165
165static int ab8500_i2c_read(struct ab8500 *ab8500, u16 addr) 166static int ab8500_prcmu_read(struct ab8500 *ab8500, u16 addr)
166{ 167{
167 int ret; 168 int ret;
168 u8 data; 169 u8 data;
@@ -361,7 +362,7 @@ static void ab8500_irq_sync_unlock(struct irq_data *data)
361static void ab8500_irq_mask(struct irq_data *data) 362static void ab8500_irq_mask(struct irq_data *data)
362{ 363{
363 struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); 364 struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data);
364 int offset = data->irq - ab8500->irq_base; 365 int offset = data->hwirq;
365 int index = offset / 8; 366 int index = offset / 8;
366 int mask = 1 << (offset % 8); 367 int mask = 1 << (offset % 8);
367 368
@@ -371,7 +372,7 @@ static void ab8500_irq_mask(struct irq_data *data)
371static void ab8500_irq_unmask(struct irq_data *data) 372static void ab8500_irq_unmask(struct irq_data *data)
372{ 373{
373 struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data); 374 struct ab8500 *ab8500 = irq_data_get_irq_chip_data(data);
374 int offset = data->irq - ab8500->irq_base; 375 int offset = data->hwirq;
375 int index = offset / 8; 376 int index = offset / 8;
376 int mask = 1 << (offset % 8); 377 int mask = 1 << (offset % 8);
377 378
@@ -510,38 +511,51 @@ static irqreturn_t ab8500_irq(int irq, void *dev)
510 return IRQ_HANDLED; 511 return IRQ_HANDLED;
511} 512}
512 513
513static int ab8500_irq_init(struct ab8500 *ab8500) 514/**
515 * ab8500_irq_get_virq(): Map an interrupt on a chip to a virtual IRQ
516 *
517 * @ab8500: ab8500_irq controller to operate on.
518 * @irq: index of the interrupt requested in the chip IRQs
519 *
520 * Useful for drivers to request their own IRQs.
521 */
522int ab8500_irq_get_virq(struct ab8500 *ab8500, int irq)
514{ 523{
515 int base = ab8500->irq_base; 524 if (!ab8500)
516 int irq; 525 return -EINVAL;
517 int num_irqs;
518 526
519 if (is_ab9540(ab8500)) 527 return irq_create_mapping(ab8500->domain, irq);
520 num_irqs = AB9540_NR_IRQS; 528}
521 else if (is_ab8505(ab8500)) 529EXPORT_SYMBOL_GPL(ab8500_irq_get_virq);
522 num_irqs = AB8505_NR_IRQS; 530
523 else 531static int ab8500_irq_map(struct irq_domain *d, unsigned int virq,
524 num_irqs = AB8500_NR_IRQS; 532 irq_hw_number_t hwirq)
533{
534 struct ab8500 *ab8500 = d->host_data;
525 535
526 for (irq = base; irq < base + num_irqs; irq++) { 536 if (!ab8500)
527 irq_set_chip_data(irq, ab8500); 537 return -EINVAL;
528 irq_set_chip_and_handler(irq, &ab8500_irq_chip, 538
529 handle_simple_irq); 539 irq_set_chip_data(virq, ab8500);
530 irq_set_nested_thread(irq, 1); 540 irq_set_chip_and_handler(virq, &ab8500_irq_chip,
541 handle_simple_irq);
542 irq_set_nested_thread(virq, 1);
531#ifdef CONFIG_ARM 543#ifdef CONFIG_ARM
532 set_irq_flags(irq, IRQF_VALID); 544 set_irq_flags(virq, IRQF_VALID);
533#else 545#else
534 irq_set_noprobe(irq); 546 irq_set_noprobe(virq);
535#endif 547#endif
536 }
537 548
538 return 0; 549 return 0;
539} 550}
540 551
541static void ab8500_irq_remove(struct ab8500 *ab8500) 552static struct irq_domain_ops ab8500_irq_ops = {
553 .map = ab8500_irq_map,
554 .xlate = irq_domain_xlate_twocell,
555};
556
557static int ab8500_irq_init(struct ab8500 *ab8500, struct device_node *np)
542{ 558{
543 int base = ab8500->irq_base;
544 int irq;
545 int num_irqs; 559 int num_irqs;
546 560
547 if (is_ab9540(ab8500)) 561 if (is_ab9540(ab8500))
@@ -551,13 +565,22 @@ static void ab8500_irq_remove(struct ab8500 *ab8500)
551 else 565 else
552 num_irqs = AB8500_NR_IRQS; 566 num_irqs = AB8500_NR_IRQS;
553 567
554 for (irq = base; irq < base + num_irqs; irq++) { 568 if (ab8500->irq_base) {
555#ifdef CONFIG_ARM 569 ab8500->domain = irq_domain_add_legacy(
556 set_irq_flags(irq, 0); 570 NULL, num_irqs, ab8500->irq_base,
557#endif 571 0, &ab8500_irq_ops, ab8500);
558 irq_set_chip_and_handler(irq, NULL, NULL); 572 }
559 irq_set_chip_data(irq, NULL); 573 else {
574 ab8500->domain = irq_domain_add_linear(
575 np, num_irqs, &ab8500_irq_ops, ab8500);
576 }
577
578 if (!ab8500->domain) {
579 dev_err(ab8500->dev, "Failed to create irqdomain\n");
580 return -ENOSYS;
560 } 581 }
582
583 return 0;
561} 584}
562 585
563int ab8500_suspend(struct ab8500 *ab8500) 586int ab8500_suspend(struct ab8500 *ab8500)
@@ -947,54 +970,69 @@ static struct mfd_cell __devinitdata abx500_common_devs[] = {
947#ifdef CONFIG_DEBUG_FS 970#ifdef CONFIG_DEBUG_FS
948 { 971 {
949 .name = "ab8500-debug", 972 .name = "ab8500-debug",
973 .of_compatible = "stericsson,ab8500-debug",
950 .num_resources = ARRAY_SIZE(ab8500_debug_resources), 974 .num_resources = ARRAY_SIZE(ab8500_debug_resources),
951 .resources = ab8500_debug_resources, 975 .resources = ab8500_debug_resources,
952 }, 976 },
953#endif 977#endif
954 { 978 {
955 .name = "ab8500-sysctrl", 979 .name = "ab8500-sysctrl",
980 .of_compatible = "stericsson,ab8500-sysctrl",
956 }, 981 },
957 { 982 {
958 .name = "ab8500-regulator", 983 .name = "ab8500-regulator",
984 .of_compatible = "stericsson,ab8500-regulator",
959 }, 985 },
960 { 986 {
961 .name = "ab8500-gpadc", 987 .name = "ab8500-gpadc",
988 .of_compatible = "stericsson,ab8500-gpadc",
962 .num_resources = ARRAY_SIZE(ab8500_gpadc_resources), 989 .num_resources = ARRAY_SIZE(ab8500_gpadc_resources),
963 .resources = ab8500_gpadc_resources, 990 .resources = ab8500_gpadc_resources,
964 }, 991 },
965 { 992 {
966 .name = "ab8500-rtc", 993 .name = "ab8500-rtc",
994 .of_compatible = "stericsson,ab8500-rtc",
967 .num_resources = ARRAY_SIZE(ab8500_rtc_resources), 995 .num_resources = ARRAY_SIZE(ab8500_rtc_resources),
968 .resources = ab8500_rtc_resources, 996 .resources = ab8500_rtc_resources,
969 }, 997 },
970 { 998 {
971 .name = "ab8500-acc-det", 999 .name = "ab8500-acc-det",
1000 .of_compatible = "stericsson,ab8500-acc-det",
972 .num_resources = ARRAY_SIZE(ab8500_av_acc_detect_resources), 1001 .num_resources = ARRAY_SIZE(ab8500_av_acc_detect_resources),
973 .resources = ab8500_av_acc_detect_resources, 1002 .resources = ab8500_av_acc_detect_resources,
974 }, 1003 },
975 { 1004 {
976 .name = "ab8500-poweron-key", 1005 .name = "ab8500-poweron-key",
1006 .of_compatible = "stericsson,ab8500-poweron-key",
977 .num_resources = ARRAY_SIZE(ab8500_poweronkey_db_resources), 1007 .num_resources = ARRAY_SIZE(ab8500_poweronkey_db_resources),
978 .resources = ab8500_poweronkey_db_resources, 1008 .resources = ab8500_poweronkey_db_resources,
979 }, 1009 },
980 { 1010 {
981 .name = "ab8500-pwm", 1011 .name = "ab8500-pwm",
1012 .of_compatible = "stericsson,ab8500-pwm",
982 .id = 1, 1013 .id = 1,
983 }, 1014 },
984 { 1015 {
985 .name = "ab8500-pwm", 1016 .name = "ab8500-pwm",
1017 .of_compatible = "stericsson,ab8500-pwm",
986 .id = 2, 1018 .id = 2,
987 }, 1019 },
988 { 1020 {
989 .name = "ab8500-pwm", 1021 .name = "ab8500-pwm",
1022 .of_compatible = "stericsson,ab8500-pwm",
990 .id = 3, 1023 .id = 3,
991 }, 1024 },
992 { .name = "ab8500-leds", }, 1025 {
1026 .name = "ab8500-leds",
1027 .of_compatible = "stericsson,ab8500-leds",
1028 },
993 { 1029 {
994 .name = "ab8500-denc", 1030 .name = "ab8500-denc",
1031 .of_compatible = "stericsson,ab8500-denc",
995 }, 1032 },
996 { 1033 {
997 .name = "ab8500-temp", 1034 .name = "ab8500-temp",
1035 .of_compatible = "stericsson,ab8500-temp",
998 .num_resources = ARRAY_SIZE(ab8500_temp_resources), 1036 .num_resources = ARRAY_SIZE(ab8500_temp_resources),
999 .resources = ab8500_temp_resources, 1037 .resources = ab8500_temp_resources,
1000 }, 1038 },
@@ -1026,11 +1064,13 @@ static struct mfd_cell __devinitdata ab8500_bm_devs[] = {
1026static struct mfd_cell __devinitdata ab8500_devs[] = { 1064static struct mfd_cell __devinitdata ab8500_devs[] = {
1027 { 1065 {
1028 .name = "ab8500-gpio", 1066 .name = "ab8500-gpio",
1067 .of_compatible = "stericsson,ab8500-gpio",
1029 .num_resources = ARRAY_SIZE(ab8500_gpio_resources), 1068 .num_resources = ARRAY_SIZE(ab8500_gpio_resources),
1030 .resources = ab8500_gpio_resources, 1069 .resources = ab8500_gpio_resources,
1031 }, 1070 },
1032 { 1071 {
1033 .name = "ab8500-usb", 1072 .name = "ab8500-usb",
1073 .of_compatible = "stericsson,ab8500-usb",
1034 .num_resources = ARRAY_SIZE(ab8500_usb_resources), 1074 .num_resources = ARRAY_SIZE(ab8500_usb_resources),
1035 .resources = ab8500_usb_resources, 1075 .resources = ab8500_usb_resources,
1036 }, 1076 },
@@ -1207,16 +1247,17 @@ static struct attribute_group ab9540_attr_group = {
1207 .attrs = ab9540_sysfs_entries, 1247 .attrs = ab9540_sysfs_entries,
1208}; 1248};
1209 1249
1210static const struct of_device_id ab8500_match[] = {
1211 {
1212 .compatible = "stericsson,ab8500",
1213 .data = (void *)AB8500_VERSION_AB8500,
1214 },
1215 {},
1216};
1217
1218static int __devinit ab8500_probe(struct platform_device *pdev) 1250static int __devinit ab8500_probe(struct platform_device *pdev)
1219{ 1251{
1252 static char *switch_off_status[] = {
1253 "Swoff bit programming",
1254 "Thermal protection activation",
1255 "Vbat lower then BattOk falling threshold",
1256 "Watchdog expired",
1257 "Non presence of 32kHz clock",
1258 "Battery level lower than power on reset threshold",
1259 "Power on key 1 pressed longer than 10 seconds",
1260 "DB8500 thermal shutdown"};
1220 struct ab8500_platform_data *plat = dev_get_platdata(&pdev->dev); 1261 struct ab8500_platform_data *plat = dev_get_platdata(&pdev->dev);
1221 const struct platform_device_id *platid = platform_get_device_id(pdev); 1262 const struct platform_device_id *platid = platform_get_device_id(pdev);
1222 enum ab8500_version version = AB8500_VERSION_UNDEFINED; 1263 enum ab8500_version version = AB8500_VERSION_UNDEFINED;
@@ -1233,14 +1274,6 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
1233 1274
1234 if (plat) 1275 if (plat)
1235 ab8500->irq_base = plat->irq_base; 1276 ab8500->irq_base = plat->irq_base;
1236 else if (np)
1237 ret = of_property_read_u32(np, "stericsson,irq-base", &ab8500->irq_base);
1238
1239 if (!ab8500->irq_base) {
1240 dev_info(&pdev->dev, "couldn't find irq-base\n");
1241 ret = -EINVAL;
1242 goto out_free_ab8500;
1243 }
1244 1277
1245 ab8500->dev = &pdev->dev; 1278 ab8500->dev = &pdev->dev;
1246 1279
@@ -1252,9 +1285,9 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
1252 1285
1253 ab8500->irq = resource->start; 1286 ab8500->irq = resource->start;
1254 1287
1255 ab8500->read = ab8500_i2c_read; 1288 ab8500->read = ab8500_prcmu_read;
1256 ab8500->write = ab8500_i2c_write; 1289 ab8500->write = ab8500_prcmu_write;
1257 ab8500->write_masked = ab8500_i2c_write_masked; 1290 ab8500->write_masked = ab8500_prcmu_write_masked;
1258 1291
1259 mutex_init(&ab8500->lock); 1292 mutex_init(&ab8500->lock);
1260 mutex_init(&ab8500->irq_lock); 1293 mutex_init(&ab8500->irq_lock);
@@ -1264,9 +1297,6 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
1264 1297
1265 if (platid) 1298 if (platid)
1266 version = platid->driver_data; 1299 version = platid->driver_data;
1267 else if (np)
1268 version = (unsigned int)
1269 of_match_device(ab8500_match, &pdev->dev)->data;
1270 1300
1271 if (version != AB8500_VERSION_UNDEFINED) 1301 if (version != AB8500_VERSION_UNDEFINED)
1272 ab8500->version = version; 1302 ab8500->version = version;
@@ -1323,7 +1353,20 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
1323 AB8500_SWITCH_OFF_STATUS, &value); 1353 AB8500_SWITCH_OFF_STATUS, &value);
1324 if (ret < 0) 1354 if (ret < 0)
1325 return ret; 1355 return ret;
1326 dev_info(ab8500->dev, "switch off status: %#x", value); 1356 dev_info(ab8500->dev, "switch off cause(s) (%#x): ", value);
1357
1358 if (value) {
1359 for (i = 0; i < ARRAY_SIZE(switch_off_status); i++) {
1360 if (value & 1)
1361 printk(KERN_CONT " \"%s\"",
1362 switch_off_status[i]);
1363 value = value >> 1;
1364
1365 }
1366 printk(KERN_CONT "\n");
1367 } else {
1368 printk(KERN_CONT " None\n");
1369 }
1327 1370
1328 if (plat && plat->init) 1371 if (plat && plat->init)
1329 plat->init(ab8500); 1372 plat->init(ab8500);
@@ -1352,53 +1395,50 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
1352 for (i = 0; i < ab8500->mask_size; i++) 1395 for (i = 0; i < ab8500->mask_size; i++)
1353 ab8500->mask[i] = ab8500->oldmask[i] = 0xff; 1396 ab8500->mask[i] = ab8500->oldmask[i] = 0xff;
1354 1397
1355 if (ab8500->irq_base) { 1398 ret = ab8500_irq_init(ab8500, np);
1356 ret = ab8500_irq_init(ab8500); 1399 if (ret)
1357 if (ret) 1400 goto out_freeoldmask;
1358 goto out_freeoldmask;
1359 1401
1360 /* Activate this feature only in ab9540 */ 1402 /* Activate this feature only in ab9540 */
1361 /* till tests are done on ab8500 1p2 or later*/ 1403 /* till tests are done on ab8500 1p2 or later*/
1362 if (is_ab9540(ab8500)) 1404 if (is_ab9540(ab8500)) {
1363 ret = request_threaded_irq(ab8500->irq, NULL, 1405 ret = request_threaded_irq(ab8500->irq, NULL,
1364 ab8500_hierarchical_irq, 1406 ab8500_hierarchical_irq,
1365 IRQF_ONESHOT | IRQF_NO_SUSPEND, 1407 IRQF_ONESHOT | IRQF_NO_SUSPEND,
1366 "ab8500", ab8500); 1408 "ab8500", ab8500);
1367 else 1409 }
1368 ret = request_threaded_irq(ab8500->irq, NULL, 1410 else {
1411 ret = request_threaded_irq(ab8500->irq, NULL,
1369 ab8500_irq, 1412 ab8500_irq,
1370 IRQF_ONESHOT | IRQF_NO_SUSPEND, 1413 IRQF_ONESHOT | IRQF_NO_SUSPEND,
1371 "ab8500", ab8500); 1414 "ab8500", ab8500);
1372 if (ret) 1415 if (ret)
1373 goto out_removeirq; 1416 goto out_freeoldmask;
1374 } 1417 }
1375 1418
1376 if (!np) { 1419 ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs,
1377 ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs, 1420 ARRAY_SIZE(abx500_common_devs), NULL,
1378 ARRAY_SIZE(abx500_common_devs), NULL, 1421 ab8500->irq_base);
1379 ab8500->irq_base); 1422 if (ret)
1423 goto out_freeirq;
1380 1424
1381 if (ret) 1425 if (is_ab9540(ab8500))
1382 goto out_freeirq; 1426 ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs,
1383 1427 ARRAY_SIZE(ab9540_devs), NULL,
1384 if (is_ab9540(ab8500)) 1428 ab8500->irq_base);
1385 ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, 1429 else
1386 ARRAY_SIZE(ab9540_devs), NULL, 1430 ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs,
1387 ab8500->irq_base); 1431 ARRAY_SIZE(ab8500_devs), NULL,
1388 else 1432 ab8500->irq_base);
1389 ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, 1433 if (ret)
1390 ARRAY_SIZE(ab8500_devs), NULL, 1434 goto out_freeirq;
1391 ab8500->irq_base);
1392 if (ret)
1393 goto out_freeirq;
1394 1435
1395 if (is_ab9540(ab8500) || is_ab8505(ab8500)) 1436 if (is_ab9540(ab8500) || is_ab8505(ab8500))
1396 ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs, 1437 ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs,
1397 ARRAY_SIZE(ab9540_ab8505_devs), NULL, 1438 ARRAY_SIZE(ab9540_ab8505_devs), NULL,
1398 ab8500->irq_base); 1439 ab8500->irq_base);
1399 if (ret) 1440 if (ret)
1400 goto out_freeirq; 1441 goto out_freeirq;
1401 }
1402 1442
1403 if (!no_bm) { 1443 if (!no_bm) {
1404 /* Add battery management devices */ 1444 /* Add battery management devices */
@@ -1417,15 +1457,11 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
1417 &ab8500_attr_group); 1457 &ab8500_attr_group);
1418 if (ret) 1458 if (ret)
1419 dev_err(ab8500->dev, "error creating sysfs entries\n"); 1459 dev_err(ab8500->dev, "error creating sysfs entries\n");
1420 else 1460
1421 return ret; 1461 return ret;
1422 1462
1423out_freeirq: 1463out_freeirq:
1424 if (ab8500->irq_base) 1464 free_irq(ab8500->irq, ab8500);
1425 free_irq(ab8500->irq, ab8500);
1426out_removeirq:
1427 if (ab8500->irq_base)
1428 ab8500_irq_remove(ab8500);
1429out_freeoldmask: 1465out_freeoldmask:
1430 kfree(ab8500->oldmask); 1466 kfree(ab8500->oldmask);
1431out_freemask: 1467out_freemask:
@@ -1444,11 +1480,10 @@ static int __devexit ab8500_remove(struct platform_device *pdev)
1444 sysfs_remove_group(&ab8500->dev->kobj, &ab9540_attr_group); 1480 sysfs_remove_group(&ab8500->dev->kobj, &ab9540_attr_group);
1445 else 1481 else
1446 sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group); 1482 sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group);
1483
1447 mfd_remove_devices(ab8500->dev); 1484 mfd_remove_devices(ab8500->dev);
1448 if (ab8500->irq_base) { 1485 free_irq(ab8500->irq, ab8500);
1449 free_irq(ab8500->irq, ab8500); 1486
1450 ab8500_irq_remove(ab8500);
1451 }
1452 kfree(ab8500->oldmask); 1487 kfree(ab8500->oldmask);
1453 kfree(ab8500->mask); 1488 kfree(ab8500->mask);
1454 kfree(ab8500); 1489 kfree(ab8500);
@@ -1468,7 +1503,6 @@ static struct platform_driver ab8500_core_driver = {
1468 .driver = { 1503 .driver = {
1469 .name = "ab8500-core", 1504 .name = "ab8500-core",
1470 .owner = THIS_MODULE, 1505 .owner = THIS_MODULE,
1471 .of_match_table = ab8500_match,
1472 }, 1506 },
1473 .probe = ab8500_probe, 1507 .probe = ab8500_probe,
1474 .remove = __devexit_p(ab8500_remove), 1508 .remove = __devexit_p(ab8500_remove),
@@ -1484,7 +1518,7 @@ static void __exit ab8500_core_exit(void)
1484{ 1518{
1485 platform_driver_unregister(&ab8500_core_driver); 1519 platform_driver_unregister(&ab8500_core_driver);
1486} 1520}
1487arch_initcall(ab8500_core_init); 1521core_initcall(ab8500_core_init);
1488module_exit(ab8500_core_exit); 1522module_exit(ab8500_core_exit);
1489 1523
1490MODULE_AUTHOR("Mattias Wallin, Srinidhi Kasagar, Rabin Vincent"); 1524MODULE_AUTHOR("Mattias Wallin, Srinidhi Kasagar, Rabin Vincent");
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 50c4c89ab220..c4cb806978ac 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -31,12 +31,12 @@ struct ab8500_reg_range {
31}; 31};
32 32
33/** 33/**
34 * struct ab8500_i2c_ranges 34 * struct ab8500_prcmu_ranges
35 * @num_ranges: the number of ranges in the list 35 * @num_ranges: the number of ranges in the list
36 * @bankid: bank identifier 36 * @bankid: bank identifier
37 * @range: the list of register ranges 37 * @range: the list of register ranges
38 */ 38 */
39struct ab8500_i2c_ranges { 39struct ab8500_prcmu_ranges {
40 u8 num_ranges; 40 u8 num_ranges;
41 u8 bankid; 41 u8 bankid;
42 const struct ab8500_reg_range *range; 42 const struct ab8500_reg_range *range;
@@ -47,7 +47,7 @@ struct ab8500_i2c_ranges {
47 47
48#define AB8500_REV_REG 0x80 48#define AB8500_REV_REG 0x80
49 49
50static struct ab8500_i2c_ranges debug_ranges[AB8500_NUM_BANKS] = { 50static struct ab8500_prcmu_ranges debug_ranges[AB8500_NUM_BANKS] = {
51 [0x0] = { 51 [0x0] = {
52 .num_ranges = 0, 52 .num_ranges = 0,
53 .range = 0, 53 .range = 0,
@@ -608,16 +608,10 @@ static int __devexit ab8500_debug_remove(struct platform_device *plf)
608 return 0; 608 return 0;
609} 609}
610 610
611static const struct of_device_id ab8500_debug_match[] = {
612 { .compatible = "stericsson,ab8500-debug", },
613 {}
614};
615
616static struct platform_driver ab8500_debug_driver = { 611static struct platform_driver ab8500_debug_driver = {
617 .driver = { 612 .driver = {
618 .name = "ab8500-debug", 613 .name = "ab8500-debug",
619 .owner = THIS_MODULE, 614 .owner = THIS_MODULE,
620 .of_match_table = ab8500_debug_match,
621 }, 615 },
622 .probe = ab8500_debug_probe, 616 .probe = ab8500_debug_probe,
623 .remove = __devexit_p(ab8500_debug_remove) 617 .remove = __devexit_p(ab8500_debug_remove)
diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c
index b86fd8e1ec3f..866f95960b4b 100644
--- a/drivers/mfd/ab8500-gpadc.c
+++ b/drivers/mfd/ab8500-gpadc.c
@@ -599,7 +599,8 @@ static int __devinit ab8500_gpadc_probe(struct platform_device *pdev)
599 /* Register interrupt - SwAdcComplete */ 599 /* Register interrupt - SwAdcComplete */
600 ret = request_threaded_irq(gpadc->irq, NULL, 600 ret = request_threaded_irq(gpadc->irq, NULL,
601 ab8500_bm_gpswadcconvend_handler, 601 ab8500_bm_gpswadcconvend_handler,
602 IRQF_NO_SUSPEND | IRQF_SHARED, "ab8500-gpadc", gpadc); 602 IRQF_ONESHOT | IRQF_NO_SUSPEND | IRQF_SHARED,
603 "ab8500-gpadc", gpadc);
603 if (ret < 0) { 604 if (ret < 0) {
604 dev_err(gpadc->dev, "Failed to register interrupt, irq: %d\n", 605 dev_err(gpadc->dev, "Failed to register interrupt, irq: %d\n",
605 gpadc->irq); 606 gpadc->irq);
@@ -648,18 +649,12 @@ static int __devexit ab8500_gpadc_remove(struct platform_device *pdev)
648 return 0; 649 return 0;
649} 650}
650 651
651static const struct of_device_id ab8500_gpadc_match[] = {
652 { .compatible = "stericsson,ab8500-gpadc", },
653 {}
654};
655
656static struct platform_driver ab8500_gpadc_driver = { 652static struct platform_driver ab8500_gpadc_driver = {
657 .probe = ab8500_gpadc_probe, 653 .probe = ab8500_gpadc_probe,
658 .remove = __devexit_p(ab8500_gpadc_remove), 654 .remove = __devexit_p(ab8500_gpadc_remove),
659 .driver = { 655 .driver = {
660 .name = "ab8500-gpadc", 656 .name = "ab8500-gpadc",
661 .owner = THIS_MODULE, 657 .owner = THIS_MODULE,
662 .of_match_table = ab8500_gpadc_match,
663 }, 658 },
664}; 659};
665 660
diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
index 5a3e51ccf258..c28d4eb1eff0 100644
--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -61,16 +61,10 @@ static int __devexit ab8500_sysctrl_remove(struct platform_device *pdev)
61 return 0; 61 return 0;
62} 62}
63 63
64static const struct of_device_id ab8500_sysctrl_match[] = {
65 { .compatible = "stericsson,ab8500-sysctrl", },
66 {}
67};
68
69static struct platform_driver ab8500_sysctrl_driver = { 64static struct platform_driver ab8500_sysctrl_driver = {
70 .driver = { 65 .driver = {
71 .name = "ab8500-sysctrl", 66 .name = "ab8500-sysctrl",
72 .owner = THIS_MODULE, 67 .owner = THIS_MODULE,
73 .of_match_table = ab8500_sysctrl_match,
74 }, 68 },
75 .probe = ab8500_sysctrl_probe, 69 .probe = ab8500_sysctrl_probe,
76 .remove = __devexit_p(ab8500_sysctrl_remove), 70 .remove = __devexit_p(ab8500_sysctrl_remove),
diff --git a/drivers/mfd/adp5520.c b/drivers/mfd/adp5520.c
index 8d816cce8322..ea8b9475731d 100644
--- a/drivers/mfd/adp5520.c
+++ b/drivers/mfd/adp5520.c
@@ -320,7 +320,7 @@ static int __devexit adp5520_remove(struct i2c_client *client)
320 return 0; 320 return 0;
321} 321}
322 322
323#ifdef CONFIG_PM 323#ifdef CONFIG_PM_SLEEP
324static int adp5520_suspend(struct device *dev) 324static int adp5520_suspend(struct device *dev)
325{ 325{
326 struct i2c_client *client = to_i2c_client(dev); 326 struct i2c_client *client = to_i2c_client(dev);
diff --git a/drivers/mfd/anatop-mfd.c b/drivers/mfd/anatop-mfd.c
index 6da06341f6c9..5576e07576de 100644
--- a/drivers/mfd/anatop-mfd.c
+++ b/drivers/mfd/anatop-mfd.c
@@ -83,7 +83,7 @@ static int __devinit of_anatop_probe(struct platform_device *pdev)
83 drvdata->ioreg = ioreg; 83 drvdata->ioreg = ioreg;
84 spin_lock_init(&drvdata->reglock); 84 spin_lock_init(&drvdata->reglock);
85 platform_set_drvdata(pdev, drvdata); 85 platform_set_drvdata(pdev, drvdata);
86 of_platform_populate(np, of_anatop_match, NULL, dev); 86 of_platform_populate(np, NULL, NULL, dev);
87 87
88 return 0; 88 return 0;
89} 89}
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
new file mode 100644
index 000000000000..c7983e862549
--- /dev/null
+++ b/drivers/mfd/arizona-core.c
@@ -0,0 +1,566 @@
1/*
2 * Arizona core driver
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/delay.h>
14#include <linux/err.h>
15#include <linux/gpio.h>
16#include <linux/interrupt.h>
17#include <linux/mfd/core.h>
18#include <linux/module.h>
19#include <linux/pm_runtime.h>
20#include <linux/regmap.h>
21#include <linux/regulator/consumer.h>
22#include <linux/slab.h>
23
24#include <linux/mfd/arizona/core.h>
25#include <linux/mfd/arizona/registers.h>
26
27#include "arizona.h"
28
29static const char *wm5102_core_supplies[] = {
30 "AVDD",
31 "DBVDD1",
32};
33
34int arizona_clk32k_enable(struct arizona *arizona)
35{
36 int ret = 0;
37
38 mutex_lock(&arizona->clk_lock);
39
40 arizona->clk32k_ref++;
41
42 if (arizona->clk32k_ref == 1)
43 ret = regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1,
44 ARIZONA_CLK_32K_ENA,
45 ARIZONA_CLK_32K_ENA);
46
47 if (ret != 0)
48 arizona->clk32k_ref--;
49
50 mutex_unlock(&arizona->clk_lock);
51
52 return ret;
53}
54EXPORT_SYMBOL_GPL(arizona_clk32k_enable);
55
56int arizona_clk32k_disable(struct arizona *arizona)
57{
58 int ret = 0;
59
60 mutex_lock(&arizona->clk_lock);
61
62 BUG_ON(arizona->clk32k_ref <= 0);
63
64 arizona->clk32k_ref--;
65
66 if (arizona->clk32k_ref == 0)
67 regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1,
68 ARIZONA_CLK_32K_ENA, 0);
69
70 mutex_unlock(&arizona->clk_lock);
71
72 return ret;
73}
74EXPORT_SYMBOL_GPL(arizona_clk32k_disable);
75
76static irqreturn_t arizona_clkgen_err(int irq, void *data)
77{
78 struct arizona *arizona = data;
79
80 dev_err(arizona->dev, "CLKGEN error\n");
81
82 return IRQ_HANDLED;
83}
84
85static irqreturn_t arizona_underclocked(int irq, void *data)
86{
87 struct arizona *arizona = data;
88 unsigned int val;
89 int ret;
90
91 ret = regmap_read(arizona->regmap, ARIZONA_INTERRUPT_RAW_STATUS_8,
92 &val);
93 if (ret != 0) {
94 dev_err(arizona->dev, "Failed to read underclock status: %d\n",
95 ret);
96 return IRQ_NONE;
97 }
98
99 if (val & ARIZONA_AIF3_UNDERCLOCKED_STS)
100 dev_err(arizona->dev, "AIF3 underclocked\n");
101 if (val & ARIZONA_AIF3_UNDERCLOCKED_STS)
102 dev_err(arizona->dev, "AIF3 underclocked\n");
103 if (val & ARIZONA_AIF2_UNDERCLOCKED_STS)
104 dev_err(arizona->dev, "AIF1 underclocked\n");
105 if (val & ARIZONA_ISRC2_UNDERCLOCKED_STS)
106 dev_err(arizona->dev, "ISRC2 underclocked\n");
107 if (val & ARIZONA_ISRC1_UNDERCLOCKED_STS)
108 dev_err(arizona->dev, "ISRC1 underclocked\n");
109 if (val & ARIZONA_FX_UNDERCLOCKED_STS)
110 dev_err(arizona->dev, "FX underclocked\n");
111 if (val & ARIZONA_ASRC_UNDERCLOCKED_STS)
112 dev_err(arizona->dev, "ASRC underclocked\n");
113 if (val & ARIZONA_DAC_UNDERCLOCKED_STS)
114 dev_err(arizona->dev, "DAC underclocked\n");
115 if (val & ARIZONA_ADC_UNDERCLOCKED_STS)
116 dev_err(arizona->dev, "ADC underclocked\n");
117 if (val & ARIZONA_MIXER_UNDERCLOCKED_STS)
118 dev_err(arizona->dev, "Mixer underclocked\n");
119
120 return IRQ_HANDLED;
121}
122
123static irqreturn_t arizona_overclocked(int irq, void *data)
124{
125 struct arizona *arizona = data;
126 unsigned int val[2];
127 int ret;
128
129 ret = regmap_bulk_read(arizona->regmap, ARIZONA_INTERRUPT_RAW_STATUS_6,
130 &val[0], 2);
131 if (ret != 0) {
132 dev_err(arizona->dev, "Failed to read overclock status: %d\n",
133 ret);
134 return IRQ_NONE;
135 }
136
137 if (val[0] & ARIZONA_PWM_OVERCLOCKED_STS)
138 dev_err(arizona->dev, "PWM overclocked\n");
139 if (val[0] & ARIZONA_FX_CORE_OVERCLOCKED_STS)
140 dev_err(arizona->dev, "FX core overclocked\n");
141 if (val[0] & ARIZONA_DAC_SYS_OVERCLOCKED_STS)
142 dev_err(arizona->dev, "DAC SYS overclocked\n");
143 if (val[0] & ARIZONA_DAC_WARP_OVERCLOCKED_STS)
144 dev_err(arizona->dev, "DAC WARP overclocked\n");
145 if (val[0] & ARIZONA_ADC_OVERCLOCKED_STS)
146 dev_err(arizona->dev, "ADC overclocked\n");
147 if (val[0] & ARIZONA_MIXER_OVERCLOCKED_STS)
148 dev_err(arizona->dev, "Mixer overclocked\n");
149 if (val[0] & ARIZONA_AIF3_SYNC_OVERCLOCKED_STS)
150 dev_err(arizona->dev, "AIF3 overclocked\n");
151 if (val[0] & ARIZONA_AIF2_SYNC_OVERCLOCKED_STS)
152 dev_err(arizona->dev, "AIF2 overclocked\n");
153 if (val[0] & ARIZONA_AIF1_SYNC_OVERCLOCKED_STS)
154 dev_err(arizona->dev, "AIF1 overclocked\n");
155 if (val[0] & ARIZONA_PAD_CTRL_OVERCLOCKED_STS)
156 dev_err(arizona->dev, "Pad control overclocked\n");
157
158 if (val[1] & ARIZONA_SLIMBUS_SUBSYS_OVERCLOCKED_STS)
159 dev_err(arizona->dev, "Slimbus subsystem overclocked\n");
160 if (val[1] & ARIZONA_SLIMBUS_ASYNC_OVERCLOCKED_STS)
161 dev_err(arizona->dev, "Slimbus async overclocked\n");
162 if (val[1] & ARIZONA_SLIMBUS_SYNC_OVERCLOCKED_STS)
163 dev_err(arizona->dev, "Slimbus sync overclocked\n");
164 if (val[1] & ARIZONA_ASRC_ASYNC_SYS_OVERCLOCKED_STS)
165 dev_err(arizona->dev, "ASRC async system overclocked\n");
166 if (val[1] & ARIZONA_ASRC_ASYNC_WARP_OVERCLOCKED_STS)
167 dev_err(arizona->dev, "ASRC async WARP overclocked\n");
168 if (val[1] & ARIZONA_ASRC_SYNC_SYS_OVERCLOCKED_STS)
169 dev_err(arizona->dev, "ASRC sync system overclocked\n");
170 if (val[1] & ARIZONA_ASRC_SYNC_WARP_OVERCLOCKED_STS)
171 dev_err(arizona->dev, "ASRC sync WARP overclocked\n");
172 if (val[1] & ARIZONA_ADSP2_1_OVERCLOCKED_STS)
173 dev_err(arizona->dev, "DSP1 overclocked\n");
174 if (val[1] & ARIZONA_ISRC2_OVERCLOCKED_STS)
175 dev_err(arizona->dev, "ISRC2 overclocked\n");
176 if (val[1] & ARIZONA_ISRC1_OVERCLOCKED_STS)
177 dev_err(arizona->dev, "ISRC1 overclocked\n");
178
179 return IRQ_HANDLED;
180}
181
182static int arizona_wait_for_boot(struct arizona *arizona)
183{
184 unsigned int reg;
185 int ret, i;
186
187 /*
188 * We can't use an interrupt as we need to runtime resume to do so,
189 * we won't race with the interrupt handler as it'll be blocked on
190 * runtime resume.
191 */
192 for (i = 0; i < 5; i++) {
193 msleep(1);
194
195 ret = regmap_read(arizona->regmap,
196 ARIZONA_INTERRUPT_RAW_STATUS_5, &reg);
197 if (ret != 0) {
198 dev_err(arizona->dev, "Failed to read boot state: %d\n",
199 ret);
200 continue;
201 }
202
203 if (reg & ARIZONA_BOOT_DONE_STS)
204 break;
205 }
206
207 if (reg & ARIZONA_BOOT_DONE_STS) {
208 regmap_write(arizona->regmap, ARIZONA_INTERRUPT_STATUS_5,
209 ARIZONA_BOOT_DONE_STS);
210 } else {
211 dev_err(arizona->dev, "Device boot timed out: %x\n", reg);
212 return -ETIMEDOUT;
213 }
214
215 pm_runtime_mark_last_busy(arizona->dev);
216
217 return 0;
218}
219
220#ifdef CONFIG_PM_RUNTIME
221static int arizona_runtime_resume(struct device *dev)
222{
223 struct arizona *arizona = dev_get_drvdata(dev);
224 int ret;
225
226 dev_dbg(arizona->dev, "Leaving AoD mode\n");
227
228 ret = regulator_enable(arizona->dcvdd);
229 if (ret != 0) {
230 dev_err(arizona->dev, "Failed to enable DCVDD: %d\n", ret);
231 return ret;
232 }
233
234 regcache_cache_only(arizona->regmap, false);
235
236 ret = arizona_wait_for_boot(arizona);
237 if (ret != 0) {
238 regulator_disable(arizona->dcvdd);
239 return ret;
240 }
241
242 regcache_sync(arizona->regmap);
243
244 return 0;
245}
246
247static int arizona_runtime_suspend(struct device *dev)
248{
249 struct arizona *arizona = dev_get_drvdata(dev);
250
251 dev_dbg(arizona->dev, "Entering AoD mode\n");
252
253 regulator_disable(arizona->dcvdd);
254 regcache_cache_only(arizona->regmap, true);
255 regcache_mark_dirty(arizona->regmap);
256
257 return 0;
258}
259#endif
260
261const struct dev_pm_ops arizona_pm_ops = {
262 SET_RUNTIME_PM_OPS(arizona_runtime_suspend,
263 arizona_runtime_resume,
264 NULL)
265};
266EXPORT_SYMBOL_GPL(arizona_pm_ops);
267
268static struct mfd_cell early_devs[] = {
269 { .name = "arizona-ldo1" },
270};
271
272static struct mfd_cell wm5102_devs[] = {
273 { .name = "arizona-extcon" },
274 { .name = "arizona-gpio" },
275 { .name = "arizona-micsupp" },
276 { .name = "arizona-pwm" },
277 { .name = "wm5102-codec" },
278};
279
280static struct mfd_cell wm5110_devs[] = {
281 { .name = "arizona-extcon" },
282 { .name = "arizona-gpio" },
283 { .name = "arizona-micsupp" },
284 { .name = "arizona-pwm" },
285 { .name = "wm5110-codec" },
286};
287
288int __devinit arizona_dev_init(struct arizona *arizona)
289{
290 struct device *dev = arizona->dev;
291 const char *type_name;
292 unsigned int reg, val;
293 int ret, i;
294
295 dev_set_drvdata(arizona->dev, arizona);
296 mutex_init(&arizona->clk_lock);
297
298 if (dev_get_platdata(arizona->dev))
299 memcpy(&arizona->pdata, dev_get_platdata(arizona->dev),
300 sizeof(arizona->pdata));
301
302 regcache_cache_only(arizona->regmap, true);
303
304 switch (arizona->type) {
305 case WM5102:
306 case WM5110:
307 for (i = 0; i < ARRAY_SIZE(wm5102_core_supplies); i++)
308 arizona->core_supplies[i].supply
309 = wm5102_core_supplies[i];
310 arizona->num_core_supplies = ARRAY_SIZE(wm5102_core_supplies);
311 break;
312 default:
313 dev_err(arizona->dev, "Unknown device type %d\n",
314 arizona->type);
315 return -EINVAL;
316 }
317
318 ret = mfd_add_devices(arizona->dev, -1, early_devs,
319 ARRAY_SIZE(early_devs), NULL, 0);
320 if (ret != 0) {
321 dev_err(dev, "Failed to add early children: %d\n", ret);
322 return ret;
323 }
324
325 ret = devm_regulator_bulk_get(dev, arizona->num_core_supplies,
326 arizona->core_supplies);
327 if (ret != 0) {
328 dev_err(dev, "Failed to request core supplies: %d\n",
329 ret);
330 goto err_early;
331 }
332
333 arizona->dcvdd = devm_regulator_get(arizona->dev, "DCVDD");
334 if (IS_ERR(arizona->dcvdd)) {
335 ret = PTR_ERR(arizona->dcvdd);
336 dev_err(dev, "Failed to request DCVDD: %d\n", ret);
337 goto err_early;
338 }
339
340 ret = regulator_bulk_enable(arizona->num_core_supplies,
341 arizona->core_supplies);
342 if (ret != 0) {
343 dev_err(dev, "Failed to enable core supplies: %d\n",
344 ret);
345 goto err_early;
346 }
347
348 ret = regulator_enable(arizona->dcvdd);
349 if (ret != 0) {
350 dev_err(dev, "Failed to enable DCVDD: %d\n", ret);
351 goto err_enable;
352 }
353
354 if (arizona->pdata.reset) {
355 /* Start out with /RESET low to put the chip into reset */
356 ret = gpio_request_one(arizona->pdata.reset,
357 GPIOF_DIR_OUT | GPIOF_INIT_LOW,
358 "arizona /RESET");
359 if (ret != 0) {
360 dev_err(dev, "Failed to request /RESET: %d\n", ret);
361 goto err_dcvdd;
362 }
363
364 gpio_set_value_cansleep(arizona->pdata.reset, 1);
365 }
366
367 regcache_cache_only(arizona->regmap, false);
368
369 ret = regmap_read(arizona->regmap, ARIZONA_SOFTWARE_RESET, &reg);
370 if (ret != 0) {
371 dev_err(dev, "Failed to read ID register: %d\n", ret);
372 goto err_reset;
373 }
374
375 ret = regmap_read(arizona->regmap, ARIZONA_DEVICE_REVISION,
376 &arizona->rev);
377 if (ret != 0) {
378 dev_err(dev, "Failed to read revision register: %d\n", ret);
379 goto err_reset;
380 }
381 arizona->rev &= ARIZONA_DEVICE_REVISION_MASK;
382
383 switch (reg) {
384#ifdef CONFIG_MFD_WM5102
385 case 0x5102:
386 type_name = "WM5102";
387 if (arizona->type != WM5102) {
388 dev_err(arizona->dev, "WM5102 registered as %d\n",
389 arizona->type);
390 arizona->type = WM5102;
391 }
392 ret = wm5102_patch(arizona);
393 break;
394#endif
395#ifdef CONFIG_MFD_WM5110
396 case 0x5110:
397 type_name = "WM5110";
398 if (arizona->type != WM5110) {
399 dev_err(arizona->dev, "WM5110 registered as %d\n",
400 arizona->type);
401 arizona->type = WM5110;
402 }
403 ret = wm5110_patch(arizona);
404 break;
405#endif
406 default:
407 dev_err(arizona->dev, "Unknown device ID %x\n", reg);
408 goto err_reset;
409 }
410
411 dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A');
412
413 if (ret != 0)
414 dev_err(arizona->dev, "Failed to apply patch: %d\n", ret);
415
416 /* If we have a /RESET GPIO we'll already be reset */
417 if (!arizona->pdata.reset) {
418 ret = regmap_write(arizona->regmap, ARIZONA_SOFTWARE_RESET, 0);
419 if (ret != 0) {
420 dev_err(dev, "Failed to reset device: %d\n", ret);
421 goto err_reset;
422 }
423 }
424
425 ret = arizona_wait_for_boot(arizona);
426 if (ret != 0) {
427 dev_err(arizona->dev, "Device failed initial boot: %d\n", ret);
428 goto err_reset;
429 }
430
431 for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) {
432 if (!arizona->pdata.gpio_defaults[i])
433 continue;
434
435 regmap_write(arizona->regmap, ARIZONA_GPIO1_CTRL + i,
436 arizona->pdata.gpio_defaults[i]);
437 }
438
439 pm_runtime_set_autosuspend_delay(arizona->dev, 100);
440 pm_runtime_use_autosuspend(arizona->dev);
441 pm_runtime_enable(arizona->dev);
442
443 /* Chip default */
444 if (!arizona->pdata.clk32k_src)
445 arizona->pdata.clk32k_src = ARIZONA_32KZ_MCLK2;
446
447 switch (arizona->pdata.clk32k_src) {
448 case ARIZONA_32KZ_MCLK1:
449 case ARIZONA_32KZ_MCLK2:
450 regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1,
451 ARIZONA_CLK_32K_SRC_MASK,
452 arizona->pdata.clk32k_src - 1);
453 break;
454 case ARIZONA_32KZ_NONE:
455 regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1,
456 ARIZONA_CLK_32K_SRC_MASK, 2);
457 break;
458 default:
459 dev_err(arizona->dev, "Invalid 32kHz clock source: %d\n",
460 arizona->pdata.clk32k_src);
461 ret = -EINVAL;
462 goto err_reset;
463 }
464
465 for (i = 0; i < ARIZONA_MAX_INPUT; i++) {
466 /* Default for both is 0 so noop with defaults */
467 val = arizona->pdata.dmic_ref[i]
468 << ARIZONA_IN1_DMIC_SUP_SHIFT;
469 val |= arizona->pdata.inmode[i] << ARIZONA_IN1_MODE_SHIFT;
470
471 regmap_update_bits(arizona->regmap,
472 ARIZONA_IN1L_CONTROL + (i * 8),
473 ARIZONA_IN1_DMIC_SUP_MASK |
474 ARIZONA_IN1_MODE_MASK, val);
475 }
476
477 for (i = 0; i < ARIZONA_MAX_OUTPUT; i++) {
478 /* Default is 0 so noop with defaults */
479 if (arizona->pdata.out_mono[i])
480 val = ARIZONA_OUT1_MONO;
481 else
482 val = 0;
483
484 regmap_update_bits(arizona->regmap,
485 ARIZONA_OUTPUT_PATH_CONFIG_1L + (i * 8),
486 ARIZONA_OUT1_MONO, val);
487 }
488
489 for (i = 0; i < ARIZONA_MAX_PDM_SPK; i++) {
490 if (arizona->pdata.spk_mute[i])
491 regmap_update_bits(arizona->regmap,
492 ARIZONA_PDM_SPK1_CTRL_1 + (i * 2),
493 ARIZONA_SPK1_MUTE_ENDIAN_MASK |
494 ARIZONA_SPK1_MUTE_SEQ1_MASK,
495 arizona->pdata.spk_mute[i]);
496
497 if (arizona->pdata.spk_fmt[i])
498 regmap_update_bits(arizona->regmap,
499 ARIZONA_PDM_SPK1_CTRL_2 + (i * 2),
500 ARIZONA_SPK1_FMT_MASK,
501 arizona->pdata.spk_fmt[i]);
502 }
503
504 /* Set up for interrupts */
505 ret = arizona_irq_init(arizona);
506 if (ret != 0)
507 goto err_reset;
508
509 arizona_request_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, "CLKGEN error",
510 arizona_clkgen_err, arizona);
511 arizona_request_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, "Overclocked",
512 arizona_overclocked, arizona);
513 arizona_request_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, "Underclocked",
514 arizona_underclocked, arizona);
515
516 switch (arizona->type) {
517 case WM5102:
518 ret = mfd_add_devices(arizona->dev, -1, wm5102_devs,
519 ARRAY_SIZE(wm5102_devs), NULL, 0);
520 break;
521 case WM5110:
522 ret = mfd_add_devices(arizona->dev, -1, wm5110_devs,
523 ARRAY_SIZE(wm5102_devs), NULL, 0);
524 break;
525 }
526
527 if (ret != 0) {
528 dev_err(arizona->dev, "Failed to add subdevices: %d\n", ret);
529 goto err_irq;
530 }
531
532#ifdef CONFIG_PM_RUNTIME
533 regulator_disable(arizona->dcvdd);
534#endif
535
536 return 0;
537
538err_irq:
539 arizona_irq_exit(arizona);
540err_reset:
541 if (arizona->pdata.reset) {
542 gpio_set_value_cansleep(arizona->pdata.reset, 1);
543 gpio_free(arizona->pdata.reset);
544 }
545err_dcvdd:
546 regulator_disable(arizona->dcvdd);
547err_enable:
548 regulator_bulk_disable(arizona->num_core_supplies,
549 arizona->core_supplies);
550err_early:
551 mfd_remove_devices(dev);
552 return ret;
553}
554EXPORT_SYMBOL_GPL(arizona_dev_init);
555
556int __devexit arizona_dev_exit(struct arizona *arizona)
557{
558 mfd_remove_devices(arizona->dev);
559 arizona_free_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, arizona);
560 arizona_free_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, arizona);
561 arizona_free_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, arizona);
562 pm_runtime_disable(arizona->dev);
563 arizona_irq_exit(arizona);
564 return 0;
565}
566EXPORT_SYMBOL_GPL(arizona_dev_exit);
diff --git a/drivers/mfd/arizona-i2c.c b/drivers/mfd/arizona-i2c.c
new file mode 100644
index 000000000000..570c4b438086
--- /dev/null
+++ b/drivers/mfd/arizona-i2c.c
@@ -0,0 +1,97 @@
1/*
2 * Arizona-i2c.c -- Arizona I2C bus interface
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/err.h>
14#include <linux/i2c.h>
15#include <linux/module.h>
16#include <linux/pm_runtime.h>
17#include <linux/regmap.h>
18#include <linux/regulator/consumer.h>
19#include <linux/slab.h>
20
21#include <linux/mfd/arizona/core.h>
22
23#include "arizona.h"
24
25static __devinit int arizona_i2c_probe(struct i2c_client *i2c,
26 const struct i2c_device_id *id)
27{
28 struct arizona *arizona;
29 const struct regmap_config *regmap_config;
30 int ret;
31
32 switch (id->driver_data) {
33#ifdef CONFIG_MFD_WM5102
34 case WM5102:
35 regmap_config = &wm5102_i2c_regmap;
36 break;
37#endif
38#ifdef CONFIG_MFD_WM5110
39 case WM5110:
40 regmap_config = &wm5110_i2c_regmap;
41 break;
42#endif
43 default:
44 dev_err(&i2c->dev, "Unknown device type %ld\n",
45 id->driver_data);
46 return -EINVAL;
47 }
48
49 arizona = devm_kzalloc(&i2c->dev, sizeof(*arizona), GFP_KERNEL);
50 if (arizona == NULL)
51 return -ENOMEM;
52
53 arizona->regmap = devm_regmap_init_i2c(i2c, regmap_config);
54 if (IS_ERR(arizona->regmap)) {
55 ret = PTR_ERR(arizona->regmap);
56 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
57 ret);
58 return ret;
59 }
60
61 arizona->type = id->driver_data;
62 arizona->dev = &i2c->dev;
63 arizona->irq = i2c->irq;
64
65 return arizona_dev_init(arizona);
66}
67
68static int __devexit arizona_i2c_remove(struct i2c_client *i2c)
69{
70 struct arizona *arizona = dev_get_drvdata(&i2c->dev);
71 arizona_dev_exit(arizona);
72 return 0;
73}
74
75static const struct i2c_device_id arizona_i2c_id[] = {
76 { "wm5102", WM5102 },
77 { "wm5110", WM5110 },
78 { }
79};
80MODULE_DEVICE_TABLE(i2c, arizona_i2c_id);
81
82static struct i2c_driver arizona_i2c_driver = {
83 .driver = {
84 .name = "arizona",
85 .owner = THIS_MODULE,
86 .pm = &arizona_pm_ops,
87 },
88 .probe = arizona_i2c_probe,
89 .remove = __devexit_p(arizona_i2c_remove),
90 .id_table = arizona_i2c_id,
91};
92
93module_i2c_driver(arizona_i2c_driver);
94
95MODULE_DESCRIPTION("Arizona I2C bus interface");
96MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
97MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/arizona-irq.c b/drivers/mfd/arizona-irq.c
new file mode 100644
index 000000000000..98ac345f468e
--- /dev/null
+++ b/drivers/mfd/arizona-irq.c
@@ -0,0 +1,275 @@
1/*
2 * Arizona interrupt support
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/delay.h>
14#include <linux/gpio.h>
15#include <linux/interrupt.h>
16#include <linux/irq.h>
17#include <linux/irqdomain.h>
18#include <linux/module.h>
19#include <linux/pm_runtime.h>
20#include <linux/regmap.h>
21#include <linux/regulator/consumer.h>
22#include <linux/slab.h>
23
24#include <linux/mfd/arizona/core.h>
25#include <linux/mfd/arizona/registers.h>
26
27#include "arizona.h"
28
29static int arizona_map_irq(struct arizona *arizona, int irq)
30{
31 int ret;
32
33 ret = regmap_irq_get_virq(arizona->aod_irq_chip, irq);
34 if (ret < 0)
35 ret = regmap_irq_get_virq(arizona->irq_chip, irq);
36
37 return ret;
38}
39
40int arizona_request_irq(struct arizona *arizona, int irq, char *name,
41 irq_handler_t handler, void *data)
42{
43 irq = arizona_map_irq(arizona, irq);
44 if (irq < 0)
45 return irq;
46
47 return request_threaded_irq(irq, NULL, handler, IRQF_ONESHOT,
48 name, data);
49}
50EXPORT_SYMBOL_GPL(arizona_request_irq);
51
52void arizona_free_irq(struct arizona *arizona, int irq, void *data)
53{
54 irq = arizona_map_irq(arizona, irq);
55 if (irq < 0)
56 return;
57
58 free_irq(irq, data);
59}
60EXPORT_SYMBOL_GPL(arizona_free_irq);
61
62int arizona_set_irq_wake(struct arizona *arizona, int irq, int on)
63{
64 irq = arizona_map_irq(arizona, irq);
65 if (irq < 0)
66 return irq;
67
68 return irq_set_irq_wake(irq, on);
69}
70EXPORT_SYMBOL_GPL(arizona_set_irq_wake);
71
72static irqreturn_t arizona_boot_done(int irq, void *data)
73{
74 struct arizona *arizona = data;
75
76 dev_dbg(arizona->dev, "Boot done\n");
77
78 return IRQ_HANDLED;
79}
80
81static irqreturn_t arizona_ctrlif_err(int irq, void *data)
82{
83 struct arizona *arizona = data;
84
85 /*
86 * For pretty much all potential sources a register cache sync
87 * won't help, we've just got a software bug somewhere.
88 */
89 dev_err(arizona->dev, "Control interface error\n");
90
91 return IRQ_HANDLED;
92}
93
94static irqreturn_t arizona_irq_thread(int irq, void *data)
95{
96 struct arizona *arizona = data;
97 int i, ret;
98
99 ret = pm_runtime_get_sync(arizona->dev);
100 if (ret < 0) {
101 dev_err(arizona->dev, "Failed to resume device: %d\n", ret);
102 return IRQ_NONE;
103 }
104
105 /* Check both domains */
106 for (i = 0; i < 2; i++)
107 handle_nested_irq(irq_find_mapping(arizona->virq, i));
108
109 pm_runtime_mark_last_busy(arizona->dev);
110 pm_runtime_put_autosuspend(arizona->dev);
111
112 return IRQ_HANDLED;
113}
114
115static void arizona_irq_enable(struct irq_data *data)
116{
117}
118
119static void arizona_irq_disable(struct irq_data *data)
120{
121}
122
123static struct irq_chip arizona_irq_chip = {
124 .name = "arizona",
125 .irq_disable = arizona_irq_disable,
126 .irq_enable = arizona_irq_enable,
127};
128
129static int arizona_irq_map(struct irq_domain *h, unsigned int virq,
130 irq_hw_number_t hw)
131{
132 struct regmap_irq_chip_data *data = h->host_data;
133
134 irq_set_chip_data(virq, data);
135 irq_set_chip_and_handler(virq, &arizona_irq_chip, handle_edge_irq);
136 irq_set_nested_thread(virq, 1);
137
138 /* ARM needs us to explicitly flag the IRQ as valid
139 * and will set them noprobe when we do so. */
140#ifdef CONFIG_ARM
141 set_irq_flags(virq, IRQF_VALID);
142#else
143 irq_set_noprobe(virq);
144#endif
145
146 return 0;
147}
148
149static struct irq_domain_ops arizona_domain_ops = {
150 .map = arizona_irq_map,
151 .xlate = irq_domain_xlate_twocell,
152};
153
154int arizona_irq_init(struct arizona *arizona)
155{
156 int flags = IRQF_ONESHOT;
157 int ret, i;
158 const struct regmap_irq_chip *aod, *irq;
159
160 switch (arizona->type) {
161#ifdef CONFIG_MFD_WM5102
162 case WM5102:
163 aod = &wm5102_aod;
164 irq = &wm5102_irq;
165 break;
166#endif
167#ifdef CONFIG_MFD_WM5110
168 case WM5110:
169 aod = &wm5110_aod;
170 irq = &wm5110_irq;
171 break;
172#endif
173 default:
174 BUG_ON("Unknown Arizona class device" == NULL);
175 return -EINVAL;
176 }
177
178 if (arizona->pdata.irq_active_high) {
179 ret = regmap_update_bits(arizona->regmap, ARIZONA_IRQ_CTRL_1,
180 ARIZONA_IRQ_POL, 0);
181 if (ret != 0) {
182 dev_err(arizona->dev, "Couldn't set IRQ polarity: %d\n",
183 ret);
184 goto err;
185 }
186
187 flags |= IRQF_TRIGGER_HIGH;
188 } else {
189 flags |= IRQF_TRIGGER_LOW;
190 }
191
192 /* Allocate a virtual IRQ domain to distribute to the regmap domains */
193 arizona->virq = irq_domain_add_linear(NULL, 2, &arizona_domain_ops,
194 arizona);
195 if (!arizona->virq) {
196 ret = -EINVAL;
197 goto err;
198 }
199
200 ret = regmap_add_irq_chip(arizona->regmap,
201 irq_create_mapping(arizona->virq, 0),
202 IRQF_ONESHOT, -1, aod,
203 &arizona->aod_irq_chip);
204 if (ret != 0) {
205 dev_err(arizona->dev, "Failed to add AOD IRQs: %d\n", ret);
206 goto err_domain;
207 }
208
209 ret = regmap_add_irq_chip(arizona->regmap,
210 irq_create_mapping(arizona->virq, 1),
211 IRQF_ONESHOT, -1, irq,
212 &arizona->irq_chip);
213 if (ret != 0) {
214 dev_err(arizona->dev, "Failed to add AOD IRQs: %d\n", ret);
215 goto err_aod;
216 }
217
218 /* Make sure the boot done IRQ is unmasked for resumes */
219 i = arizona_map_irq(arizona, ARIZONA_IRQ_BOOT_DONE);
220 ret = request_threaded_irq(i, NULL, arizona_boot_done, IRQF_ONESHOT,
221 "Boot done", arizona);
222 if (ret != 0) {
223 dev_err(arizona->dev, "Failed to request boot done %d: %d\n",
224 arizona->irq, ret);
225 goto err_boot_done;
226 }
227
228 /* Handle control interface errors in the core */
229 i = arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR);
230 ret = request_threaded_irq(i, NULL, arizona_ctrlif_err, IRQF_ONESHOT,
231 "Control interface error", arizona);
232 if (ret != 0) {
233 dev_err(arizona->dev, "Failed to request boot done %d: %d\n",
234 arizona->irq, ret);
235 goto err_ctrlif;
236 }
237
238 ret = request_threaded_irq(arizona->irq, NULL, arizona_irq_thread,
239 flags, "arizona", arizona);
240
241 if (ret != 0) {
242 dev_err(arizona->dev, "Failed to request IRQ %d: %d\n",
243 arizona->irq, ret);
244 goto err_main_irq;
245 }
246
247 return 0;
248
249err_main_irq:
250 free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR), arizona);
251err_ctrlif:
252 free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_BOOT_DONE), arizona);
253err_boot_done:
254 regmap_del_irq_chip(irq_create_mapping(arizona->virq, 1),
255 arizona->irq_chip);
256err_aod:
257 regmap_del_irq_chip(irq_create_mapping(arizona->virq, 0),
258 arizona->aod_irq_chip);
259err_domain:
260err:
261 return ret;
262}
263
264int arizona_irq_exit(struct arizona *arizona)
265{
266 free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR), arizona);
267 free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_BOOT_DONE), arizona);
268 regmap_del_irq_chip(irq_create_mapping(arizona->virq, 1),
269 arizona->irq_chip);
270 regmap_del_irq_chip(irq_create_mapping(arizona->virq, 0),
271 arizona->aod_irq_chip);
272 free_irq(arizona->irq, arizona);
273
274 return 0;
275}
diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c
new file mode 100644
index 000000000000..df2e5a8bee28
--- /dev/null
+++ b/drivers/mfd/arizona-spi.c
@@ -0,0 +1,97 @@
1/*
2 * arizona-spi.c -- Arizona SPI bus interface
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/err.h>
14#include <linux/module.h>
15#include <linux/pm_runtime.h>
16#include <linux/regmap.h>
17#include <linux/regulator/consumer.h>
18#include <linux/slab.h>
19#include <linux/spi/spi.h>
20
21#include <linux/mfd/arizona/core.h>
22
23#include "arizona.h"
24
25static int __devinit arizona_spi_probe(struct spi_device *spi)
26{
27 const struct spi_device_id *id = spi_get_device_id(spi);
28 struct arizona *arizona;
29 const struct regmap_config *regmap_config;
30 int ret;
31
32 switch (id->driver_data) {
33#ifdef CONFIG_MFD_WM5102
34 case WM5102:
35 regmap_config = &wm5102_spi_regmap;
36 break;
37#endif
38#ifdef CONFIG_MFD_WM5110
39 case WM5110:
40 regmap_config = &wm5110_spi_regmap;
41 break;
42#endif
43 default:
44 dev_err(&spi->dev, "Unknown device type %ld\n",
45 id->driver_data);
46 return -EINVAL;
47 }
48
49 arizona = devm_kzalloc(&spi->dev, sizeof(*arizona), GFP_KERNEL);
50 if (arizona == NULL)
51 return -ENOMEM;
52
53 arizona->regmap = devm_regmap_init_spi(spi, regmap_config);
54 if (IS_ERR(arizona->regmap)) {
55 ret = PTR_ERR(arizona->regmap);
56 dev_err(&spi->dev, "Failed to allocate register map: %d\n",
57 ret);
58 return ret;
59 }
60
61 arizona->type = id->driver_data;
62 arizona->dev = &spi->dev;
63 arizona->irq = spi->irq;
64
65 return arizona_dev_init(arizona);
66}
67
68static int __devexit arizona_spi_remove(struct spi_device *spi)
69{
70 struct arizona *arizona = dev_get_drvdata(&spi->dev);
71 arizona_dev_exit(arizona);
72 return 0;
73}
74
75static const struct spi_device_id arizona_spi_ids[] = {
76 { "wm5102", WM5102 },
77 { "wm5110", WM5110 },
78 { },
79};
80MODULE_DEVICE_TABLE(spi, arizona_spi_ids);
81
82static struct spi_driver arizona_spi_driver = {
83 .driver = {
84 .name = "arizona",
85 .owner = THIS_MODULE,
86 .pm = &arizona_pm_ops,
87 },
88 .probe = arizona_spi_probe,
89 .remove = __devexit_p(arizona_spi_remove),
90 .id_table = arizona_spi_ids,
91};
92
93module_spi_driver(arizona_spi_driver);
94
95MODULE_DESCRIPTION("Arizona SPI bus interface");
96MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
97MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/arizona.h b/drivers/mfd/arizona.h
new file mode 100644
index 000000000000..9798ae5da67b
--- /dev/null
+++ b/drivers/mfd/arizona.h
@@ -0,0 +1,40 @@
1/*
2 * wm5102.h -- WM5102 MFD internals
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef _WM5102_H
14#define _WM5102_H
15
16#include <linux/regmap.h>
17#include <linux/pm.h>
18
19struct wm_arizona;
20
21extern const struct regmap_config wm5102_i2c_regmap;
22extern const struct regmap_config wm5102_spi_regmap;
23
24extern const struct regmap_config wm5110_i2c_regmap;
25extern const struct regmap_config wm5110_spi_regmap;
26
27extern const struct dev_pm_ops arizona_pm_ops;
28
29extern const struct regmap_irq_chip wm5102_aod;
30extern const struct regmap_irq_chip wm5102_irq;
31
32extern const struct regmap_irq_chip wm5110_aod;
33extern const struct regmap_irq_chip wm5110_irq;
34
35int arizona_dev_init(struct arizona *arizona);
36int arizona_dev_exit(struct arizona *arizona);
37int arizona_irq_init(struct arizona *arizona);
38int arizona_irq_exit(struct arizona *arizona);
39
40#endif
diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c
index 1f1313c90573..2544910e1fd6 100644
--- a/drivers/mfd/da9052-core.c
+++ b/drivers/mfd/da9052-core.c
@@ -772,7 +772,6 @@ EXPORT_SYMBOL_GPL(da9052_regmap_config);
772int __devinit da9052_device_init(struct da9052 *da9052, u8 chip_id) 772int __devinit da9052_device_init(struct da9052 *da9052, u8 chip_id)
773{ 773{
774 struct da9052_pdata *pdata = da9052->dev->platform_data; 774 struct da9052_pdata *pdata = da9052->dev->platform_data;
775 struct irq_desc *desc;
776 int ret; 775 int ret;
777 776
778 mutex_init(&da9052->auxadc_lock); 777 mutex_init(&da9052->auxadc_lock);
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
index 50e83dc5dc49..7040a0081130 100644
--- a/drivers/mfd/db8500-prcmu.c
+++ b/drivers/mfd/db8500-prcmu.c
@@ -28,6 +28,7 @@
28#include <linux/uaccess.h> 28#include <linux/uaccess.h>
29#include <linux/mfd/core.h> 29#include <linux/mfd/core.h>
30#include <linux/mfd/dbx500-prcmu.h> 30#include <linux/mfd/dbx500-prcmu.h>
31#include <linux/mfd/abx500/ab8500.h>
31#include <linux/regulator/db8500-prcmu.h> 32#include <linux/regulator/db8500-prcmu.h>
32#include <linux/regulator/machine.h> 33#include <linux/regulator/machine.h>
33#include <asm/hardware/gic.h> 34#include <asm/hardware/gic.h>
@@ -2269,10 +2270,10 @@ int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
2269/** 2270/**
2270 * prcmu_ac_wake_req - should be called whenever ARM wants to wakeup Modem 2271 * prcmu_ac_wake_req - should be called whenever ARM wants to wakeup Modem
2271 */ 2272 */
2272void prcmu_ac_wake_req(void) 2273int prcmu_ac_wake_req(void)
2273{ 2274{
2274 u32 val; 2275 u32 val;
2275 u32 status; 2276 int ret = 0;
2276 2277
2277 mutex_lock(&mb0_transfer.ac_wake_lock); 2278 mutex_lock(&mb0_transfer.ac_wake_lock);
2278 2279
@@ -2282,39 +2283,32 @@ void prcmu_ac_wake_req(void)
2282 2283
2283 atomic_set(&ac_wake_req_state, 1); 2284 atomic_set(&ac_wake_req_state, 1);
2284 2285
2285retry: 2286 /*
2286 writel((val | PRCM_HOSTACCESS_REQ_HOSTACCESS_REQ), PRCM_HOSTACCESS_REQ); 2287 * Force Modem Wake-up before hostaccess_req ping-pong.
2288 * It prevents Modem to enter in Sleep while acking the hostaccess
2289 * request. The 31us delay has been calculated by HWI.
2290 */
2291 val |= PRCM_HOSTACCESS_REQ_WAKE_REQ;
2292 writel(val, PRCM_HOSTACCESS_REQ);
2293
2294 udelay(31);
2295
2296 val |= PRCM_HOSTACCESS_REQ_HOSTACCESS_REQ;
2297 writel(val, PRCM_HOSTACCESS_REQ);
2287 2298
2288 if (!wait_for_completion_timeout(&mb0_transfer.ac_wake_work, 2299 if (!wait_for_completion_timeout(&mb0_transfer.ac_wake_work,
2289 msecs_to_jiffies(5000))) { 2300 msecs_to_jiffies(5000))) {
2301#if defined(CONFIG_DBX500_PRCMU_DEBUG)
2302 db8500_prcmu_debug_dump(__func__, true, true);
2303#endif
2290 pr_crit("prcmu: %s timed out (5 s) waiting for a reply.\n", 2304 pr_crit("prcmu: %s timed out (5 s) waiting for a reply.\n",
2291 __func__); 2305 __func__);
2292 goto unlock_and_return; 2306 ret = -EFAULT;
2293 }
2294
2295 /*
2296 * The modem can generate an AC_WAKE_ACK, and then still go to sleep.
2297 * As a workaround, we wait, and then check that the modem is indeed
2298 * awake (in terms of the value of the PRCM_MOD_AWAKE_STATUS
2299 * register, which may not be the whole truth).
2300 */
2301 udelay(400);
2302 status = (readl(PRCM_MOD_AWAKE_STATUS) & BITS(0, 2));
2303 if (status != (PRCM_MOD_AWAKE_STATUS_PRCM_MOD_AAPD_AWAKE |
2304 PRCM_MOD_AWAKE_STATUS_PRCM_MOD_COREPD_AWAKE)) {
2305 pr_err("prcmu: %s received ack, but modem not awake (0x%X).\n",
2306 __func__, status);
2307 udelay(1200);
2308 writel(val, PRCM_HOSTACCESS_REQ);
2309 if (wait_for_completion_timeout(&mb0_transfer.ac_wake_work,
2310 msecs_to_jiffies(5000)))
2311 goto retry;
2312 pr_crit("prcmu: %s timed out (5 s) waiting for AC_SLEEP_ACK.\n",
2313 __func__);
2314 } 2307 }
2315 2308
2316unlock_and_return: 2309unlock_and_return:
2317 mutex_unlock(&mb0_transfer.ac_wake_lock); 2310 mutex_unlock(&mb0_transfer.ac_wake_lock);
2311 return ret;
2318} 2312}
2319 2313
2320/** 2314/**
@@ -2945,14 +2939,31 @@ static struct regulator_init_data db8500_regulators[DB8500_NUM_REGULATORS] = {
2945 }, 2939 },
2946}; 2940};
2947 2941
2942static struct resource ab8500_resources[] = {
2943 [0] = {
2944 .start = IRQ_DB8500_AB8500,
2945 .end = IRQ_DB8500_AB8500,
2946 .flags = IORESOURCE_IRQ
2947 }
2948};
2949
2948static struct mfd_cell db8500_prcmu_devs[] = { 2950static struct mfd_cell db8500_prcmu_devs[] = {
2949 { 2951 {
2950 .name = "db8500-prcmu-regulators", 2952 .name = "db8500-prcmu-regulators",
2953 .of_compatible = "stericsson,db8500-prcmu-regulator",
2951 .platform_data = &db8500_regulators, 2954 .platform_data = &db8500_regulators,
2952 .pdata_size = sizeof(db8500_regulators), 2955 .pdata_size = sizeof(db8500_regulators),
2953 }, 2956 },
2954 { 2957 {
2955 .name = "cpufreq-u8500", 2958 .name = "cpufreq-u8500",
2959 .of_compatible = "stericsson,cpufreq-u8500",
2960 },
2961 {
2962 .name = "ab8500-core",
2963 .of_compatible = "stericsson,ab8500",
2964 .num_resources = ARRAY_SIZE(ab8500_resources),
2965 .resources = ab8500_resources,
2966 .id = AB8500_VERSION_AB8500,
2956 }, 2967 },
2957}; 2968};
2958 2969
@@ -2962,8 +2973,9 @@ static struct mfd_cell db8500_prcmu_devs[] = {
2962 */ 2973 */
2963static int __devinit db8500_prcmu_probe(struct platform_device *pdev) 2974static int __devinit db8500_prcmu_probe(struct platform_device *pdev)
2964{ 2975{
2976 struct ab8500_platform_data *ab8500_platdata = pdev->dev.platform_data;
2965 struct device_node *np = pdev->dev.of_node; 2977 struct device_node *np = pdev->dev.of_node;
2966 int irq = 0, err = 0; 2978 int irq = 0, err = 0, i;
2967 2979
2968 if (ux500_is_svp()) 2980 if (ux500_is_svp())
2969 return -ENODEV; 2981 return -ENODEV;
@@ -2987,16 +2999,21 @@ static int __devinit db8500_prcmu_probe(struct platform_device *pdev)
2987 goto no_irq_return; 2999 goto no_irq_return;
2988 } 3000 }
2989 3001
3002 for (i = 0; i < ARRAY_SIZE(db8500_prcmu_devs); i++) {
3003 if (!strcmp(db8500_prcmu_devs[i].name, "ab8500-core")) {
3004 db8500_prcmu_devs[i].platform_data = ab8500_platdata;
3005 db8500_prcmu_devs[i].pdata_size = sizeof(struct ab8500_platform_data);
3006 }
3007 }
3008
2990 if (cpu_is_u8500v20_or_later()) 3009 if (cpu_is_u8500v20_or_later())
2991 prcmu_config_esram0_deep_sleep(ESRAM0_DEEP_SLEEP_STATE_RET); 3010 prcmu_config_esram0_deep_sleep(ESRAM0_DEEP_SLEEP_STATE_RET);
2992 3011
2993 if (!np) { 3012 err = mfd_add_devices(&pdev->dev, 0, db8500_prcmu_devs,
2994 err = mfd_add_devices(&pdev->dev, 0, db8500_prcmu_devs, 3013 ARRAY_SIZE(db8500_prcmu_devs), NULL, 0);
2995 ARRAY_SIZE(db8500_prcmu_devs), NULL, 0); 3014 if (err) {
2996 if (err) { 3015 pr_err("prcmu: Failed to add subdevices\n");
2997 pr_err("prcmu: Failed to add subdevices\n"); 3016 return err;
2998 return err;
2999 }
3000 } 3017 }
3001 3018
3002 pr_info("DB8500 PRCMU initialized\n"); 3019 pr_info("DB8500 PRCMU initialized\n");
@@ -3004,11 +3021,16 @@ static int __devinit db8500_prcmu_probe(struct platform_device *pdev)
3004no_irq_return: 3021no_irq_return:
3005 return err; 3022 return err;
3006} 3023}
3024static const struct of_device_id db8500_prcmu_match[] = {
3025 { .compatible = "stericsson,db8500-prcmu"},
3026 { },
3027};
3007 3028
3008static struct platform_driver db8500_prcmu_driver = { 3029static struct platform_driver db8500_prcmu_driver = {
3009 .driver = { 3030 .driver = {
3010 .name = "db8500-prcmu", 3031 .name = "db8500-prcmu",
3011 .owner = THIS_MODULE, 3032 .owner = THIS_MODULE,
3033 .of_match_table = db8500_prcmu_match,
3012 }, 3034 },
3013 .probe = db8500_prcmu_probe, 3035 .probe = db8500_prcmu_probe,
3014}; 3036};
@@ -3018,7 +3040,7 @@ static int __init db8500_prcmu_init(void)
3018 return platform_driver_register(&db8500_prcmu_driver); 3040 return platform_driver_register(&db8500_prcmu_driver);
3019} 3041}
3020 3042
3021arch_initcall(db8500_prcmu_init); 3043core_initcall(db8500_prcmu_init);
3022 3044
3023MODULE_AUTHOR("Mattias Nilsson <mattias.i.nilsson@stericsson.com>"); 3045MODULE_AUTHOR("Mattias Nilsson <mattias.i.nilsson@stericsson.com>");
3024MODULE_DESCRIPTION("DB8500 PRCM Unit driver"); 3046MODULE_DESCRIPTION("DB8500 PRCM Unit driver");
diff --git a/drivers/mfd/dbx500-prcmu-regs.h b/drivers/mfd/dbx500-prcmu-regs.h
index 3a0bf91d7780..23108a6e3167 100644
--- a/drivers/mfd/dbx500-prcmu-regs.h
+++ b/drivers/mfd/dbx500-prcmu-regs.h
@@ -106,6 +106,7 @@
106 106
107#define PRCM_HOSTACCESS_REQ (_PRCMU_BASE + 0x334) 107#define PRCM_HOSTACCESS_REQ (_PRCMU_BASE + 0x334)
108#define PRCM_HOSTACCESS_REQ_HOSTACCESS_REQ 0x1 108#define PRCM_HOSTACCESS_REQ_HOSTACCESS_REQ 0x1
109#define PRCM_HOSTACCESS_REQ_WAKE_REQ BIT(16)
109#define ARM_WAKEUP_MODEM 0x1 110#define ARM_WAKEUP_MODEM 0x1
110 111
111#define PRCM_ARM_IT1_CLR (_PRCMU_BASE + 0x48C) 112#define PRCM_ARM_IT1_CLR (_PRCMU_BASE + 0x48C)
diff --git a/drivers/mfd/max77686-irq.c b/drivers/mfd/max77686-irq.c
new file mode 100644
index 000000000000..cdc3280e2ec7
--- /dev/null
+++ b/drivers/mfd/max77686-irq.c
@@ -0,0 +1,319 @@
1/*
2 * max77686-irq.c - Interrupt controller support for MAX77686
3 *
4 * Copyright (C) 2012 Samsung Electronics Co.Ltd
5 * Chiwoong Byun <woong.byun@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * This driver is based on max8997-irq.c
22 */
23
24#include <linux/err.h>
25#include <linux/irq.h>
26#include <linux/interrupt.h>
27#include <linux/gpio.h>
28#include <linux/mfd/max77686.h>
29#include <linux/mfd/max77686-private.h>
30#include <linux/irqdomain.h>
31#include <linux/regmap.h>
32
33enum {
34 MAX77686_DEBUG_IRQ_INFO = 1 << 0,
35 MAX77686_DEBUG_IRQ_MASK = 1 << 1,
36 MAX77686_DEBUG_IRQ_INT = 1 << 2,
37};
38
39static int debug_mask = 0;
40module_param(debug_mask, int, 0);
41MODULE_PARM_DESC(debug_mask, "Set debug_mask : 0x0=off 0x1=IRQ_INFO 0x2=IRQ_MASK 0x4=IRQ_INI)");
42
43static const u8 max77686_mask_reg[] = {
44 [PMIC_INT1] = MAX77686_REG_INT1MSK,
45 [PMIC_INT2] = MAX77686_REG_INT2MSK,
46 [RTC_INT] = MAX77686_RTC_INTM,
47};
48
49static struct regmap *max77686_get_regmap(struct max77686_dev *max77686,
50 enum max77686_irq_source src)
51{
52 switch (src) {
53 case PMIC_INT1 ... PMIC_INT2:
54 return max77686->regmap;
55 case RTC_INT:
56 return max77686->rtc_regmap;
57 default:
58 return ERR_PTR(-EINVAL);
59 }
60}
61
62struct max77686_irq_data {
63 int mask;
64 enum max77686_irq_source group;
65};
66
67#define DECLARE_IRQ(idx, _group, _mask) \
68 [(idx)] = { .group = (_group), .mask = (_mask) }
69static const struct max77686_irq_data max77686_irqs[] = {
70 DECLARE_IRQ(MAX77686_PMICIRQ_PWRONF, PMIC_INT1, 1 << 0),
71 DECLARE_IRQ(MAX77686_PMICIRQ_PWRONR, PMIC_INT1, 1 << 1),
72 DECLARE_IRQ(MAX77686_PMICIRQ_JIGONBF, PMIC_INT1, 1 << 2),
73 DECLARE_IRQ(MAX77686_PMICIRQ_JIGONBR, PMIC_INT1, 1 << 3),
74 DECLARE_IRQ(MAX77686_PMICIRQ_ACOKBF, PMIC_INT1, 1 << 4),
75 DECLARE_IRQ(MAX77686_PMICIRQ_ACOKBR, PMIC_INT1, 1 << 5),
76 DECLARE_IRQ(MAX77686_PMICIRQ_ONKEY1S, PMIC_INT1, 1 << 6),
77 DECLARE_IRQ(MAX77686_PMICIRQ_MRSTB, PMIC_INT1, 1 << 7),
78 DECLARE_IRQ(MAX77686_PMICIRQ_140C, PMIC_INT2, 1 << 0),
79 DECLARE_IRQ(MAX77686_PMICIRQ_120C, PMIC_INT2, 1 << 1),
80 DECLARE_IRQ(MAX77686_RTCIRQ_RTC60S, RTC_INT, 1 << 0),
81 DECLARE_IRQ(MAX77686_RTCIRQ_RTCA1, RTC_INT, 1 << 1),
82 DECLARE_IRQ(MAX77686_RTCIRQ_RTCA2, RTC_INT, 1 << 2),
83 DECLARE_IRQ(MAX77686_RTCIRQ_SMPL, RTC_INT, 1 << 3),
84 DECLARE_IRQ(MAX77686_RTCIRQ_RTC1S, RTC_INT, 1 << 4),
85 DECLARE_IRQ(MAX77686_RTCIRQ_WTSR, RTC_INT, 1 << 5),
86};
87
88static void max77686_irq_lock(struct irq_data *data)
89{
90 struct max77686_dev *max77686 = irq_get_chip_data(data->irq);
91
92 if (debug_mask & MAX77686_DEBUG_IRQ_MASK)
93 pr_info("%s\n", __func__);
94
95 mutex_lock(&max77686->irqlock);
96}
97
98static void max77686_irq_sync_unlock(struct irq_data *data)
99{
100 struct max77686_dev *max77686 = irq_get_chip_data(data->irq);
101 int i;
102
103 for (i = 0; i < MAX77686_IRQ_GROUP_NR; i++) {
104 u8 mask_reg = max77686_mask_reg[i];
105 struct regmap *map = max77686_get_regmap(max77686, i);
106
107 if (debug_mask & MAX77686_DEBUG_IRQ_MASK)
108 pr_debug("%s: mask_reg[%d]=0x%x, cur=0x%x\n",
109 __func__, i, mask_reg, max77686->irq_masks_cur[i]);
110
111 if (mask_reg == MAX77686_REG_INVALID ||
112 IS_ERR_OR_NULL(map))
113 continue;
114
115 max77686->irq_masks_cache[i] = max77686->irq_masks_cur[i];
116
117 regmap_write(map, max77686_mask_reg[i],
118 max77686->irq_masks_cur[i]);
119 }
120
121 mutex_unlock(&max77686->irqlock);
122}
123
124static const inline struct max77686_irq_data *to_max77686_irq(int irq)
125{
126 struct irq_data *data = irq_get_irq_data(irq);
127 return &max77686_irqs[data->hwirq];
128}
129
130static void max77686_irq_mask(struct irq_data *data)
131{
132 struct max77686_dev *max77686 = irq_get_chip_data(data->irq);
133 const struct max77686_irq_data *irq_data = to_max77686_irq(data->irq);
134
135 max77686->irq_masks_cur[irq_data->group] |= irq_data->mask;
136
137 if (debug_mask & MAX77686_DEBUG_IRQ_MASK)
138 pr_info("%s: group=%d, cur=0x%x\n",
139 __func__, irq_data->group,
140 max77686->irq_masks_cur[irq_data->group]);
141}
142
143static void max77686_irq_unmask(struct irq_data *data)
144{
145 struct max77686_dev *max77686 = irq_get_chip_data(data->irq);
146 const struct max77686_irq_data *irq_data = to_max77686_irq(data->irq);
147
148 max77686->irq_masks_cur[irq_data->group] &= ~irq_data->mask;
149
150 if (debug_mask & MAX77686_DEBUG_IRQ_MASK)
151 pr_info("%s: group=%d, cur=0x%x\n",
152 __func__, irq_data->group,
153 max77686->irq_masks_cur[irq_data->group]);
154}
155
156static struct irq_chip max77686_irq_chip = {
157 .name = "max77686",
158 .irq_bus_lock = max77686_irq_lock,
159 .irq_bus_sync_unlock = max77686_irq_sync_unlock,
160 .irq_mask = max77686_irq_mask,
161 .irq_unmask = max77686_irq_unmask,
162};
163
164static irqreturn_t max77686_irq_thread(int irq, void *data)
165{
166 struct max77686_dev *max77686 = data;
167 unsigned int irq_reg[MAX77686_IRQ_GROUP_NR] = {};
168 unsigned int irq_src;
169 int ret;
170 int i, cur_irq;
171
172 ret = regmap_read(max77686->regmap, MAX77686_REG_INTSRC, &irq_src);
173 if (ret < 0) {
174 dev_err(max77686->dev, "Failed to read interrupt source: %d\n",
175 ret);
176 return IRQ_NONE;
177 }
178
179 if (debug_mask & MAX77686_DEBUG_IRQ_INT)
180 pr_info("%s: irq_src=0x%x\n", __func__, irq_src);
181
182 if (irq_src == MAX77686_IRQSRC_PMIC) {
183 ret = regmap_bulk_read(max77686->regmap,
184 MAX77686_REG_INT1, irq_reg, 2);
185 if (ret < 0) {
186 dev_err(max77686->dev, "Failed to read interrupt source: %d\n",
187 ret);
188 return IRQ_NONE;
189 }
190
191 if (debug_mask & MAX77686_DEBUG_IRQ_INT)
192 pr_info("%s: int1=0x%x, int2=0x%x\n", __func__,
193 irq_reg[PMIC_INT1], irq_reg[PMIC_INT2]);
194 }
195
196 if (irq_src & MAX77686_IRQSRC_RTC) {
197 ret = regmap_read(max77686->rtc_regmap,
198 MAX77686_RTC_INT, &irq_reg[RTC_INT]);
199 if (ret < 0) {
200 dev_err(max77686->dev, "Failed to read interrupt source: %d\n",
201 ret);
202 return IRQ_NONE;
203 }
204
205 if (debug_mask & MAX77686_DEBUG_IRQ_INT)
206 pr_info("%s: rtc int=0x%x\n", __func__,
207 irq_reg[RTC_INT]);
208
209 }
210
211 for (i = 0; i < MAX77686_IRQ_GROUP_NR; i++)
212 irq_reg[i] &= ~max77686->irq_masks_cur[i];
213
214 for (i = 0; i < MAX77686_IRQ_NR; i++) {
215 if (irq_reg[max77686_irqs[i].group] & max77686_irqs[i].mask) {
216 cur_irq = irq_find_mapping(max77686->irq_domain, i);
217 if (cur_irq)
218 handle_nested_irq(cur_irq);
219 }
220 }
221
222 return IRQ_HANDLED;
223}
224
225static int max77686_irq_domain_map(struct irq_domain *d, unsigned int irq,
226 irq_hw_number_t hw)
227{
228 struct max77686_dev *max77686 = d->host_data;
229
230 irq_set_chip_data(irq, max77686);
231 irq_set_chip_and_handler(irq, &max77686_irq_chip, handle_edge_irq);
232 irq_set_nested_thread(irq, 1);
233#ifdef CONFIG_ARM
234 set_irq_flags(irq, IRQF_VALID);
235#else
236 irq_set_noprobe(irq);
237#endif
238 return 0;
239}
240
241static struct irq_domain_ops max77686_irq_domain_ops = {
242 .map = max77686_irq_domain_map,
243};
244
245int max77686_irq_init(struct max77686_dev *max77686)
246{
247 struct irq_domain *domain;
248 int i;
249 int ret;
250 int val;
251 struct regmap *map;
252
253 mutex_init(&max77686->irqlock);
254
255 if (max77686->irq_gpio && !max77686->irq) {
256 max77686->irq = gpio_to_irq(max77686->irq_gpio);
257
258 if (debug_mask & MAX77686_DEBUG_IRQ_INT) {
259 ret = gpio_request(max77686->irq_gpio, "pmic_irq");
260 if (ret < 0) {
261 dev_err(max77686->dev,
262 "Failed to request gpio %d with ret:"
263 "%d\n", max77686->irq_gpio, ret);
264 return IRQ_NONE;
265 }
266
267 gpio_direction_input(max77686->irq_gpio);
268 val = gpio_get_value(max77686->irq_gpio);
269 gpio_free(max77686->irq_gpio);
270 pr_info("%s: gpio_irq=%x\n", __func__, val);
271 }
272 }
273
274 if (!max77686->irq) {
275 dev_err(max77686->dev, "irq is not specified\n");
276 return -ENODEV;
277 }
278
279 /* Mask individual interrupt sources */
280 for (i = 0; i < MAX77686_IRQ_GROUP_NR; i++) {
281 max77686->irq_masks_cur[i] = 0xff;
282 max77686->irq_masks_cache[i] = 0xff;
283 map = max77686_get_regmap(max77686, i);
284
285 if (IS_ERR_OR_NULL(map))
286 continue;
287 if (max77686_mask_reg[i] == MAX77686_REG_INVALID)
288 continue;
289
290 regmap_write(map, max77686_mask_reg[i], 0xff);
291 }
292 domain = irq_domain_add_linear(NULL, MAX77686_IRQ_NR,
293 &max77686_irq_domain_ops, max77686);
294 if (!domain) {
295 dev_err(max77686->dev, "could not create irq domain\n");
296 return -ENODEV;
297 }
298 max77686->irq_domain = domain;
299
300 ret = request_threaded_irq(max77686->irq, NULL, max77686_irq_thread,
301 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
302 "max77686-irq", max77686);
303
304 if (ret)
305 dev_err(max77686->dev, "Failed to request IRQ %d: %d\n",
306 max77686->irq, ret);
307
308
309 if (debug_mask & MAX77686_DEBUG_IRQ_INFO)
310 pr_info("%s-\n", __func__);
311
312 return 0;
313}
314
315void max77686_irq_exit(struct max77686_dev *max77686)
316{
317 if (max77686->irq)
318 free_irq(max77686->irq, max77686);
319}
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
new file mode 100644
index 000000000000..c03e12b51924
--- /dev/null
+++ b/drivers/mfd/max77686.c
@@ -0,0 +1,187 @@
1/*
2 * max77686.c - mfd core driver for the Maxim 77686
3 *
4 * Copyright (C) 2012 Samsung Electronics
5 * Chiwoong Byun <woong.byun@smasung.com>
6 * Jonghwa Lee <jonghwa3.lee@samsung.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * This driver is based on max8997.c
23 */
24
25#include <linux/export.h>
26#include <linux/slab.h>
27#include <linux/i2c.h>
28#include <linux/pm_runtime.h>
29#include <linux/module.h>
30#include <linux/mfd/core.h>
31#include <linux/mfd/max77686.h>
32#include <linux/mfd/max77686-private.h>
33#include <linux/err.h>
34
35#define I2C_ADDR_RTC (0x0C >> 1)
36
37static struct mfd_cell max77686_devs[] = {
38 { .name = "max77686-pmic", },
39 { .name = "max77686-rtc", },
40};
41
42static struct regmap_config max77686_regmap_config = {
43 .reg_bits = 8,
44 .val_bits = 8,
45};
46
47#ifdef CONFIG_OF
48static struct of_device_id __devinitdata max77686_pmic_dt_match[] = {
49 {.compatible = "maxim,max77686", .data = 0},
50 {},
51};
52
53static struct max77686_platform_data *max77686_i2c_parse_dt_pdata(struct device
54 *dev)
55{
56 struct max77686_platform_data *pd;
57
58 pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
59 if (!pd) {
60 dev_err(dev, "could not allocate memory for pdata\n");
61 return NULL;
62 }
63
64 dev->platform_data = pd;
65 return pd;
66}
67#else
68static struct max77686_platform_data *max77686_i2c_parse_dt_pdata(struct device
69 *dev)
70{
71 return 0;
72}
73#endif
74
75static int max77686_i2c_probe(struct i2c_client *i2c,
76 const struct i2c_device_id *id)
77{
78 struct max77686_dev *max77686 = NULL;
79 struct max77686_platform_data *pdata = i2c->dev.platform_data;
80 unsigned int data;
81 int ret = 0;
82
83 if (i2c->dev.of_node)
84 pdata = max77686_i2c_parse_dt_pdata(&i2c->dev);
85
86 if (!pdata) {
87 ret = -EIO;
88 dev_err(&i2c->dev, "No platform data found.\n");
89 goto err;
90 }
91
92 max77686 = kzalloc(sizeof(struct max77686_dev), GFP_KERNEL);
93 if (max77686 == NULL)
94 return -ENOMEM;
95
96 max77686->regmap = regmap_init_i2c(i2c, &max77686_regmap_config);
97 if (IS_ERR(max77686->regmap)) {
98 ret = PTR_ERR(max77686->regmap);
99 dev_err(max77686->dev, "Failed to allocate register map: %d\n",
100 ret);
101 kfree(max77686);
102 return ret;
103 }
104
105 i2c_set_clientdata(i2c, max77686);
106 max77686->dev = &i2c->dev;
107 max77686->i2c = i2c;
108 max77686->type = id->driver_data;
109
110 max77686->wakeup = pdata->wakeup;
111 max77686->irq_gpio = pdata->irq_gpio;
112 max77686->irq = i2c->irq;
113
114 if (regmap_read(max77686->regmap,
115 MAX77686_REG_DEVICE_ID, &data) < 0) {
116 dev_err(max77686->dev,
117 "device not found on this channel (this is not an error)\n");
118 ret = -ENODEV;
119 goto err;
120 } else
121 dev_info(max77686->dev, "device found\n");
122
123 max77686->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC);
124 i2c_set_clientdata(max77686->rtc, max77686);
125
126 max77686_irq_init(max77686);
127
128 ret = mfd_add_devices(max77686->dev, -1, max77686_devs,
129 ARRAY_SIZE(max77686_devs), NULL, 0);
130
131 if (ret < 0)
132 goto err_mfd;
133
134 return ret;
135
136err_mfd:
137 mfd_remove_devices(max77686->dev);
138 i2c_unregister_device(max77686->rtc);
139err:
140 kfree(max77686);
141 return ret;
142}
143
144static int max77686_i2c_remove(struct i2c_client *i2c)
145{
146 struct max77686_dev *max77686 = i2c_get_clientdata(i2c);
147
148 mfd_remove_devices(max77686->dev);
149 i2c_unregister_device(max77686->rtc);
150 kfree(max77686);
151
152 return 0;
153}
154
155static const struct i2c_device_id max77686_i2c_id[] = {
156 { "max77686", TYPE_MAX77686 },
157 { }
158};
159MODULE_DEVICE_TABLE(i2c, max77686_i2c_id);
160
161static struct i2c_driver max77686_i2c_driver = {
162 .driver = {
163 .name = "max77686",
164 .owner = THIS_MODULE,
165 .of_match_table = of_match_ptr(max77686_pmic_dt_match),
166 },
167 .probe = max77686_i2c_probe,
168 .remove = max77686_i2c_remove,
169 .id_table = max77686_i2c_id,
170};
171
172static int __init max77686_i2c_init(void)
173{
174 return i2c_add_driver(&max77686_i2c_driver);
175}
176/* init early so consumer devices can complete system boot */
177subsys_initcall(max77686_i2c_init);
178
179static void __exit max77686_i2c_exit(void)
180{
181 i2c_del_driver(&max77686_i2c_driver);
182}
183module_exit(max77686_i2c_exit);
184
185MODULE_DESCRIPTION("MAXIM 77686 multi-function core driver");
186MODULE_AUTHOR("Chiwoong Byun <woong.byun@samsung.com>");
187MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
index e9e4278722f3..a1811cb50ec7 100644
--- a/drivers/mfd/max77693.c
+++ b/drivers/mfd/max77693.c
@@ -138,8 +138,6 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
138 138
139 max77693->wakeup = pdata->wakeup; 139 max77693->wakeup = pdata->wakeup;
140 140
141 mutex_init(&max77693->iolock);
142
143 if (max77693_read_reg(max77693->regmap, 141 if (max77693_read_reg(max77693->regmap,
144 MAX77693_PMIC_REG_PMIC_ID2, &reg_data) < 0) { 142 MAX77693_PMIC_REG_PMIC_ID2, &reg_data) < 0) {
145 dev_err(max77693->dev, "device not found on this channel\n"); 143 dev_err(max77693->dev, "device not found on this channel\n");
@@ -156,7 +154,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
156 154
157 ret = max77693_irq_init(max77693); 155 ret = max77693_irq_init(max77693);
158 if (ret < 0) 156 if (ret < 0)
159 goto err_mfd; 157 goto err_irq;
160 158
161 pm_runtime_set_active(max77693->dev); 159 pm_runtime_set_active(max77693->dev);
162 160
@@ -170,11 +168,11 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
170 return ret; 168 return ret;
171 169
172err_mfd: 170err_mfd:
171 max77693_irq_exit(max77693);
172err_irq:
173 i2c_unregister_device(max77693->muic); 173 i2c_unregister_device(max77693->muic);
174 i2c_unregister_device(max77693->haptic); 174 i2c_unregister_device(max77693->haptic);
175err_regmap: 175err_regmap:
176 kfree(max77693);
177
178 return ret; 176 return ret;
179} 177}
180 178
@@ -183,6 +181,7 @@ static int max77693_i2c_remove(struct i2c_client *i2c)
183 struct max77693_dev *max77693 = i2c_get_clientdata(i2c); 181 struct max77693_dev *max77693 = i2c_get_clientdata(i2c);
184 182
185 mfd_remove_devices(max77693->dev); 183 mfd_remove_devices(max77693->dev);
184 max77693_irq_exit(max77693);
186 i2c_unregister_device(max77693->muic); 185 i2c_unregister_device(max77693->muic);
187 i2c_unregister_device(max77693->haptic); 186 i2c_unregister_device(max77693->haptic);
188 187
@@ -215,7 +214,7 @@ static int max77693_resume(struct device *dev)
215 return max77693_irq_resume(max77693); 214 return max77693_irq_resume(max77693);
216} 215}
217 216
218const struct dev_pm_ops max77693_pm = { 217static const struct dev_pm_ops max77693_pm = {
219 .suspend = max77693_suspend, 218 .suspend = max77693_suspend,
220 .resume = max77693_resume, 219 .resume = max77693_resume,
221}; 220};
diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c
index ca881efedf75..825a7f06d9ba 100644
--- a/drivers/mfd/max8925-core.c
+++ b/drivers/mfd/max8925-core.c
@@ -75,9 +75,9 @@ static struct mfd_cell power_devs[] = {
75static struct resource rtc_resources[] = { 75static struct resource rtc_resources[] = {
76 { 76 {
77 .name = "max8925-rtc", 77 .name = "max8925-rtc",
78 .start = MAX8925_RTC_IRQ, 78 .start = MAX8925_IRQ_RTC_ALARM0,
79 .end = MAX8925_RTC_IRQ_MASK, 79 .end = MAX8925_IRQ_RTC_ALARM0,
80 .flags = IORESOURCE_IO, 80 .flags = IORESOURCE_IRQ,
81 }, 81 },
82}; 82};
83 83
@@ -598,7 +598,7 @@ int __devinit max8925_device_init(struct max8925_chip *chip,
598 598
599 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0], 599 ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
600 ARRAY_SIZE(rtc_devs), 600 ARRAY_SIZE(rtc_devs),
601 &rtc_resources[0], 0); 601 &rtc_resources[0], chip->irq_base);
602 if (ret < 0) { 602 if (ret < 0) {
603 dev_err(chip->dev, "Failed to add rtc subdev\n"); 603 dev_err(chip->dev, "Failed to add rtc subdev\n");
604 goto out; 604 goto out;
diff --git a/drivers/mfd/max8997-irq.c b/drivers/mfd/max8997-irq.c
index 09274cf7c33b..43fa61413e93 100644
--- a/drivers/mfd/max8997-irq.c
+++ b/drivers/mfd/max8997-irq.c
@@ -142,7 +142,8 @@ static void max8997_irq_sync_unlock(struct irq_data *data)
142static const inline struct max8997_irq_data * 142static const inline struct max8997_irq_data *
143irq_to_max8997_irq(struct max8997_dev *max8997, int irq) 143irq_to_max8997_irq(struct max8997_dev *max8997, int irq)
144{ 144{
145 return &max8997_irqs[irq - max8997->irq_base]; 145 struct irq_data *data = irq_get_irq_data(irq);
146 return &max8997_irqs[data->hwirq];
146} 147}
147 148
148static void max8997_irq_mask(struct irq_data *data) 149static void max8997_irq_mask(struct irq_data *data)
@@ -182,7 +183,7 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
182 u8 irq_reg[MAX8997_IRQ_GROUP_NR] = {}; 183 u8 irq_reg[MAX8997_IRQ_GROUP_NR] = {};
183 u8 irq_src; 184 u8 irq_src;
184 int ret; 185 int ret;
185 int i; 186 int i, cur_irq;
186 187
187 ret = max8997_read_reg(max8997->i2c, MAX8997_REG_INTSRC, &irq_src); 188 ret = max8997_read_reg(max8997->i2c, MAX8997_REG_INTSRC, &irq_src);
188 if (ret < 0) { 189 if (ret < 0) {
@@ -269,8 +270,11 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
269 270
270 /* Report */ 271 /* Report */
271 for (i = 0; i < MAX8997_IRQ_NR; i++) { 272 for (i = 0; i < MAX8997_IRQ_NR; i++) {
272 if (irq_reg[max8997_irqs[i].group] & max8997_irqs[i].mask) 273 if (irq_reg[max8997_irqs[i].group] & max8997_irqs[i].mask) {
273 handle_nested_irq(max8997->irq_base + i); 274 cur_irq = irq_find_mapping(max8997->irq_domain, i);
275 if (cur_irq)
276 handle_nested_irq(cur_irq);
277 }
274 } 278 }
275 279
276 return IRQ_HANDLED; 280 return IRQ_HANDLED;
@@ -278,26 +282,40 @@ static irqreturn_t max8997_irq_thread(int irq, void *data)
278 282
279int max8997_irq_resume(struct max8997_dev *max8997) 283int max8997_irq_resume(struct max8997_dev *max8997)
280{ 284{
281 if (max8997->irq && max8997->irq_base) 285 if (max8997->irq && max8997->irq_domain)
282 max8997_irq_thread(max8997->irq_base, max8997); 286 max8997_irq_thread(0, max8997);
287 return 0;
288}
289
290static int max8997_irq_domain_map(struct irq_domain *d, unsigned int irq,
291 irq_hw_number_t hw)
292{
293 struct max8997_dev *max8997 = d->host_data;
294
295 irq_set_chip_data(irq, max8997);
296 irq_set_chip_and_handler(irq, &max8997_irq_chip, handle_edge_irq);
297 irq_set_nested_thread(irq, 1);
298#ifdef CONFIG_ARM
299 set_irq_flags(irq, IRQF_VALID);
300#else
301 irq_set_noprobe(irq);
302#endif
283 return 0; 303 return 0;
284} 304}
285 305
306static struct irq_domain_ops max8997_irq_domain_ops = {
307 .map = max8997_irq_domain_map,
308};
309
286int max8997_irq_init(struct max8997_dev *max8997) 310int max8997_irq_init(struct max8997_dev *max8997)
287{ 311{
312 struct irq_domain *domain;
288 int i; 313 int i;
289 int cur_irq;
290 int ret; 314 int ret;
291 u8 val; 315 u8 val;
292 316
293 if (!max8997->irq) { 317 if (!max8997->irq) {
294 dev_warn(max8997->dev, "No interrupt specified.\n"); 318 dev_warn(max8997->dev, "No interrupt specified.\n");
295 max8997->irq_base = 0;
296 return 0;
297 }
298
299 if (!max8997->irq_base) {
300 dev_err(max8997->dev, "No interrupt base specified.\n");
301 return 0; 319 return 0;
302 } 320 }
303 321
@@ -327,19 +345,13 @@ int max8997_irq_init(struct max8997_dev *max8997)
327 true : false; 345 true : false;
328 } 346 }
329 347
330 /* Register with genirq */ 348 domain = irq_domain_add_linear(NULL, MAX8997_IRQ_NR,
331 for (i = 0; i < MAX8997_IRQ_NR; i++) { 349 &max8997_irq_domain_ops, max8997);
332 cur_irq = i + max8997->irq_base; 350 if (!domain) {
333 irq_set_chip_data(cur_irq, max8997); 351 dev_err(max8997->dev, "could not create irq domain\n");
334 irq_set_chip_and_handler(cur_irq, &max8997_irq_chip, 352 return -ENODEV;
335 handle_edge_irq);
336 irq_set_nested_thread(cur_irq, 1);
337#ifdef CONFIG_ARM
338 set_irq_flags(cur_irq, IRQF_VALID);
339#else
340 irq_set_noprobe(cur_irq);
341#endif
342 } 353 }
354 max8997->irq_domain = domain;
343 355
344 ret = request_threaded_irq(max8997->irq, NULL, max8997_irq_thread, 356 ret = request_threaded_irq(max8997->irq, NULL, max8997_irq_thread,
345 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 357 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index cb83a7ab53e7..10b629c245b6 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -143,7 +143,6 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
143 if (!pdata) 143 if (!pdata)
144 goto err; 144 goto err;
145 145
146 max8997->irq_base = pdata->irq_base;
147 max8997->ono = pdata->ono; 146 max8997->ono = pdata->ono;
148 147
149 mutex_init(&max8997->iolock); 148 mutex_init(&max8997->iolock);
@@ -206,7 +205,7 @@ static const struct i2c_device_id max8997_i2c_id[] = {
206}; 205};
207MODULE_DEVICE_TABLE(i2c, max8998_i2c_id); 206MODULE_DEVICE_TABLE(i2c, max8998_i2c_id);
208 207
209u8 max8997_dumpaddr_pmic[] = { 208static u8 max8997_dumpaddr_pmic[] = {
210 MAX8997_REG_INT1MSK, 209 MAX8997_REG_INT1MSK,
211 MAX8997_REG_INT2MSK, 210 MAX8997_REG_INT2MSK,
212 MAX8997_REG_INT3MSK, 211 MAX8997_REG_INT3MSK,
@@ -331,7 +330,7 @@ u8 max8997_dumpaddr_pmic[] = {
331 MAX8997_REG_DVSOKTIMER5, 330 MAX8997_REG_DVSOKTIMER5,
332}; 331};
333 332
334u8 max8997_dumpaddr_muic[] = { 333static u8 max8997_dumpaddr_muic[] = {
335 MAX8997_MUIC_REG_INTMASK1, 334 MAX8997_MUIC_REG_INTMASK1,
336 MAX8997_MUIC_REG_INTMASK2, 335 MAX8997_MUIC_REG_INTMASK2,
337 MAX8997_MUIC_REG_INTMASK3, 336 MAX8997_MUIC_REG_INTMASK3,
@@ -341,7 +340,7 @@ u8 max8997_dumpaddr_muic[] = {
341 MAX8997_MUIC_REG_CONTROL3, 340 MAX8997_MUIC_REG_CONTROL3,
342}; 341};
343 342
344u8 max8997_dumpaddr_haptic[] = { 343static u8 max8997_dumpaddr_haptic[] = {
345 MAX8997_HAPTIC_REG_CONF1, 344 MAX8997_HAPTIC_REG_CONF1,
346 MAX8997_HAPTIC_REG_CONF2, 345 MAX8997_HAPTIC_REG_CONF2,
347 MAX8997_HAPTIC_REG_DRVCONF, 346 MAX8997_HAPTIC_REG_DRVCONF,
@@ -423,7 +422,7 @@ static int max8997_resume(struct device *dev)
423 return max8997_irq_resume(max8997); 422 return max8997_irq_resume(max8997);
424} 423}
425 424
426const struct dev_pm_ops max8997_pm = { 425static const struct dev_pm_ops max8997_pm = {
427 .suspend = max8997_suspend, 426 .suspend = max8997_suspend,
428 .resume = max8997_resume, 427 .resume = max8997_resume,
429 .freeze = max8997_freeze, 428 .freeze = max8997_freeze,
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index f0ea3b8b3e4a..b801dc72f041 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -723,10 +723,6 @@ void mc13xxx_common_cleanup(struct mc13xxx *mc13xxx)
723 free_irq(mc13xxx->irq, mc13xxx); 723 free_irq(mc13xxx->irq, mc13xxx);
724 724
725 mfd_remove_devices(mc13xxx->dev); 725 mfd_remove_devices(mc13xxx->dev);
726
727 regmap_exit(mc13xxx->regmap);
728
729 kfree(mc13xxx);
730} 726}
731EXPORT_SYMBOL_GPL(mc13xxx_common_cleanup); 727EXPORT_SYMBOL_GPL(mc13xxx_common_cleanup);
732 728
diff --git a/drivers/mfd/mc13xxx-i2c.c b/drivers/mfd/mc13xxx-i2c.c
index d22501dad6a6..9d18dde3cd2a 100644
--- a/drivers/mfd/mc13xxx-i2c.c
+++ b/drivers/mfd/mc13xxx-i2c.c
@@ -53,17 +53,11 @@ static struct regmap_config mc13xxx_regmap_i2c_config = {
53static int mc13xxx_i2c_probe(struct i2c_client *client, 53static int mc13xxx_i2c_probe(struct i2c_client *client,
54 const struct i2c_device_id *id) 54 const struct i2c_device_id *id)
55{ 55{
56 const struct of_device_id *of_id;
57 struct i2c_driver *idrv = to_i2c_driver(client->dev.driver);
58 struct mc13xxx *mc13xxx; 56 struct mc13xxx *mc13xxx;
59 struct mc13xxx_platform_data *pdata = dev_get_platdata(&client->dev); 57 struct mc13xxx_platform_data *pdata = dev_get_platdata(&client->dev);
60 int ret; 58 int ret;
61 59
62 of_id = of_match_device(mc13xxx_dt_ids, &client->dev); 60 mc13xxx = devm_kzalloc(&client->dev, sizeof(*mc13xxx), GFP_KERNEL);
63 if (of_id)
64 idrv->id_table = (const struct i2c_device_id*) of_id->data;
65
66 mc13xxx = kzalloc(sizeof(*mc13xxx), GFP_KERNEL);
67 if (!mc13xxx) 61 if (!mc13xxx)
68 return -ENOMEM; 62 return -ENOMEM;
69 63
@@ -72,13 +66,13 @@ static int mc13xxx_i2c_probe(struct i2c_client *client,
72 mc13xxx->dev = &client->dev; 66 mc13xxx->dev = &client->dev;
73 mutex_init(&mc13xxx->lock); 67 mutex_init(&mc13xxx->lock);
74 68
75 mc13xxx->regmap = regmap_init_i2c(client, &mc13xxx_regmap_i2c_config); 69 mc13xxx->regmap = devm_regmap_init_i2c(client,
70 &mc13xxx_regmap_i2c_config);
76 if (IS_ERR(mc13xxx->regmap)) { 71 if (IS_ERR(mc13xxx->regmap)) {
77 ret = PTR_ERR(mc13xxx->regmap); 72 ret = PTR_ERR(mc13xxx->regmap);
78 dev_err(mc13xxx->dev, "Failed to initialize register map: %d\n", 73 dev_err(mc13xxx->dev, "Failed to initialize register map: %d\n",
79 ret); 74 ret);
80 dev_set_drvdata(&client->dev, NULL); 75 dev_set_drvdata(&client->dev, NULL);
81 kfree(mc13xxx);
82 return ret; 76 return ret;
83 } 77 }
84 78
diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c
index 03df422feb76..0bdb43a0aff0 100644
--- a/drivers/mfd/mc13xxx-spi.c
+++ b/drivers/mfd/mc13xxx-spi.c
@@ -119,17 +119,11 @@ static struct regmap_bus regmap_mc13xxx_bus = {
119 119
120static int mc13xxx_spi_probe(struct spi_device *spi) 120static int mc13xxx_spi_probe(struct spi_device *spi)
121{ 121{
122 const struct of_device_id *of_id;
123 struct spi_driver *sdrv = to_spi_driver(spi->dev.driver);
124 struct mc13xxx *mc13xxx; 122 struct mc13xxx *mc13xxx;
125 struct mc13xxx_platform_data *pdata = dev_get_platdata(&spi->dev); 123 struct mc13xxx_platform_data *pdata = dev_get_platdata(&spi->dev);
126 int ret; 124 int ret;
127 125
128 of_id = of_match_device(mc13xxx_dt_ids, &spi->dev); 126 mc13xxx = devm_kzalloc(&spi->dev, sizeof(*mc13xxx), GFP_KERNEL);
129 if (of_id)
130 sdrv->id_table = &mc13xxx_device_id[(enum mc13xxx_id) of_id->data];
131
132 mc13xxx = kzalloc(sizeof(*mc13xxx), GFP_KERNEL);
133 if (!mc13xxx) 127 if (!mc13xxx)
134 return -ENOMEM; 128 return -ENOMEM;
135 129
@@ -139,15 +133,14 @@ static int mc13xxx_spi_probe(struct spi_device *spi)
139 mc13xxx->dev = &spi->dev; 133 mc13xxx->dev = &spi->dev;
140 mutex_init(&mc13xxx->lock); 134 mutex_init(&mc13xxx->lock);
141 135
142 mc13xxx->regmap = regmap_init(&spi->dev, &regmap_mc13xxx_bus, &spi->dev, 136 mc13xxx->regmap = devm_regmap_init(&spi->dev, &regmap_mc13xxx_bus,
143 &mc13xxx_regmap_spi_config); 137 &spi->dev,
144 138 &mc13xxx_regmap_spi_config);
145 if (IS_ERR(mc13xxx->regmap)) { 139 if (IS_ERR(mc13xxx->regmap)) {
146 ret = PTR_ERR(mc13xxx->regmap); 140 ret = PTR_ERR(mc13xxx->regmap);
147 dev_err(mc13xxx->dev, "Failed to initialize register map: %d\n", 141 dev_err(mc13xxx->dev, "Failed to initialize register map: %d\n",
148 ret); 142 ret);
149 dev_set_drvdata(&spi->dev, NULL); 143 dev_set_drvdata(&spi->dev, NULL);
150 kfree(mc13xxx);
151 return ret; 144 return ret;
152 } 145 }
153 146
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index ffc3d48676ae..0c3a01cde2f7 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -18,6 +18,8 @@
18#include <linux/pm_runtime.h> 18#include <linux/pm_runtime.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/irqdomain.h>
22#include <linux/of.h>
21 23
22int mfd_cell_enable(struct platform_device *pdev) 24int mfd_cell_enable(struct platform_device *pdev)
23{ 25{
@@ -76,6 +78,8 @@ static int mfd_add_device(struct device *parent, int id,
76{ 78{
77 struct resource *res; 79 struct resource *res;
78 struct platform_device *pdev; 80 struct platform_device *pdev;
81 struct device_node *np = NULL;
82 struct irq_domain *domain = NULL;
79 int ret = -ENOMEM; 83 int ret = -ENOMEM;
80 int r; 84 int r;
81 85
@@ -89,6 +93,16 @@ static int mfd_add_device(struct device *parent, int id,
89 93
90 pdev->dev.parent = parent; 94 pdev->dev.parent = parent;
91 95
96 if (parent->of_node && cell->of_compatible) {
97 for_each_child_of_node(parent->of_node, np) {
98 if (of_device_is_compatible(np, cell->of_compatible)) {
99 pdev->dev.of_node = np;
100 domain = irq_find_host(parent->of_node);
101 break;
102 }
103 }
104 }
105
92 if (cell->pdata_size) { 106 if (cell->pdata_size) {
93 ret = platform_device_add_data(pdev, 107 ret = platform_device_add_data(pdev,
94 cell->platform_data, cell->pdata_size); 108 cell->platform_data, cell->pdata_size);
@@ -112,10 +126,18 @@ static int mfd_add_device(struct device *parent, int id,
112 res[r].end = mem_base->start + 126 res[r].end = mem_base->start +
113 cell->resources[r].end; 127 cell->resources[r].end;
114 } else if (cell->resources[r].flags & IORESOURCE_IRQ) { 128 } else if (cell->resources[r].flags & IORESOURCE_IRQ) {
115 res[r].start = irq_base + 129 if (domain) {
116 cell->resources[r].start; 130 /* Unable to create mappings for IRQ ranges. */
117 res[r].end = irq_base + 131 WARN_ON(cell->resources[r].start !=
118 cell->resources[r].end; 132 cell->resources[r].end);
133 res[r].start = res[r].end = irq_create_mapping(
134 domain, cell->resources[r].start);
135 } else {
136 res[r].start = irq_base +
137 cell->resources[r].start;
138 res[r].end = irq_base +
139 cell->resources[r].end;
140 }
119 } else { 141 } else {
120 res[r].parent = cell->resources[r].parent; 142 res[r].parent = cell->resources[r].parent;
121 res[r].start = cell->resources[r].start; 143 res[r].start = cell->resources[r].start;
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index 29c122bf28ea..45ce1fb5a549 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -253,8 +253,13 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
253 } 253 }
254 254
255 pdev->dev.parent = pcf->dev; 255 pdev->dev.parent = pcf->dev;
256 platform_device_add_data(pdev, &pdata->reg_init_data[i], 256 if (platform_device_add_data(pdev, &pdata->reg_init_data[i],
257 sizeof(pdata->reg_init_data[i])); 257 sizeof(pdata->reg_init_data[i])) < 0) {
258 platform_device_put(pdev);
259 dev_err(pcf->dev, "Out of memory for regulator parameters %d\n",
260 i);
261 continue;
262 }
258 pcf->regulator_pdev[i] = pdev; 263 pcf->regulator_pdev[i] = pdev;
259 264
260 platform_device_add(pdev); 265 platform_device_add(pdev);
diff --git a/drivers/mfd/s5m-core.c b/drivers/mfd/s5m-core.c
deleted file mode 100644
index dd170307e60e..000000000000
--- a/drivers/mfd/s5m-core.c
+++ /dev/null
@@ -1,206 +0,0 @@
1/*
2 * s5m87xx.c
3 *
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd
5 * http://www.samsung.com
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/init.h>
17#include <linux/err.h>
18#include <linux/slab.h>
19#include <linux/i2c.h>
20#include <linux/interrupt.h>
21#include <linux/pm_runtime.h>
22#include <linux/mutex.h>
23#include <linux/mfd/core.h>
24#include <linux/mfd/s5m87xx/s5m-core.h>
25#include <linux/mfd/s5m87xx/s5m-pmic.h>
26#include <linux/mfd/s5m87xx/s5m-rtc.h>
27#include <linux/regmap.h>
28
29static struct mfd_cell s5m8751_devs[] = {
30 {
31 .name = "s5m8751-pmic",
32 }, {
33 .name = "s5m-charger",
34 }, {
35 .name = "s5m8751-codec",
36 },
37};
38
39static struct mfd_cell s5m8763_devs[] = {
40 {
41 .name = "s5m8763-pmic",
42 }, {
43 .name = "s5m-rtc",
44 }, {
45 .name = "s5m-charger",
46 },
47};
48
49static struct mfd_cell s5m8767_devs[] = {
50 {
51 .name = "s5m8767-pmic",
52 }, {
53 .name = "s5m-rtc",
54 },
55};
56
57int s5m_reg_read(struct s5m87xx_dev *s5m87xx, u8 reg, void *dest)
58{
59 return regmap_read(s5m87xx->regmap, reg, dest);
60}
61EXPORT_SYMBOL_GPL(s5m_reg_read);
62
63int s5m_bulk_read(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf)
64{
65 return regmap_bulk_read(s5m87xx->regmap, reg, buf, count);
66}
67EXPORT_SYMBOL_GPL(s5m_bulk_read);
68
69int s5m_reg_write(struct s5m87xx_dev *s5m87xx, u8 reg, u8 value)
70{
71 return regmap_write(s5m87xx->regmap, reg, value);
72}
73EXPORT_SYMBOL_GPL(s5m_reg_write);
74
75int s5m_bulk_write(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf)
76{
77 return regmap_raw_write(s5m87xx->regmap, reg, buf, count);
78}
79EXPORT_SYMBOL_GPL(s5m_bulk_write);
80
81int s5m_reg_update(struct s5m87xx_dev *s5m87xx, u8 reg, u8 val, u8 mask)
82{
83 return regmap_update_bits(s5m87xx->regmap, reg, mask, val);
84}
85EXPORT_SYMBOL_GPL(s5m_reg_update);
86
87static struct regmap_config s5m_regmap_config = {
88 .reg_bits = 8,
89 .val_bits = 8,
90};
91
92static int s5m87xx_i2c_probe(struct i2c_client *i2c,
93 const struct i2c_device_id *id)
94{
95 struct s5m_platform_data *pdata = i2c->dev.platform_data;
96 struct s5m87xx_dev *s5m87xx;
97 int ret;
98
99 s5m87xx = devm_kzalloc(&i2c->dev, sizeof(struct s5m87xx_dev),
100 GFP_KERNEL);
101 if (s5m87xx == NULL)
102 return -ENOMEM;
103
104 i2c_set_clientdata(i2c, s5m87xx);
105 s5m87xx->dev = &i2c->dev;
106 s5m87xx->i2c = i2c;
107 s5m87xx->irq = i2c->irq;
108 s5m87xx->type = id->driver_data;
109
110 if (pdata) {
111 s5m87xx->device_type = pdata->device_type;
112 s5m87xx->ono = pdata->ono;
113 s5m87xx->irq_base = pdata->irq_base;
114 s5m87xx->wakeup = pdata->wakeup;
115 }
116
117 s5m87xx->regmap = devm_regmap_init_i2c(i2c, &s5m_regmap_config);
118 if (IS_ERR(s5m87xx->regmap)) {
119 ret = PTR_ERR(s5m87xx->regmap);
120 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
121 ret);
122 return ret;
123 }
124
125 s5m87xx->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
126 i2c_set_clientdata(s5m87xx->rtc, s5m87xx);
127
128 if (pdata && pdata->cfg_pmic_irq)
129 pdata->cfg_pmic_irq();
130
131 s5m_irq_init(s5m87xx);
132
133 pm_runtime_set_active(s5m87xx->dev);
134
135 switch (s5m87xx->device_type) {
136 case S5M8751X:
137 ret = mfd_add_devices(s5m87xx->dev, -1, s5m8751_devs,
138 ARRAY_SIZE(s5m8751_devs), NULL, 0);
139 break;
140 case S5M8763X:
141 ret = mfd_add_devices(s5m87xx->dev, -1, s5m8763_devs,
142 ARRAY_SIZE(s5m8763_devs), NULL, 0);
143 break;
144 case S5M8767X:
145 ret = mfd_add_devices(s5m87xx->dev, -1, s5m8767_devs,
146 ARRAY_SIZE(s5m8767_devs), NULL, 0);
147 break;
148 default:
149 /* If this happens the probe function is problem */
150 BUG();
151 }
152
153 if (ret < 0)
154 goto err;
155
156 return ret;
157
158err:
159 mfd_remove_devices(s5m87xx->dev);
160 s5m_irq_exit(s5m87xx);
161 i2c_unregister_device(s5m87xx->rtc);
162 return ret;
163}
164
165static int s5m87xx_i2c_remove(struct i2c_client *i2c)
166{
167 struct s5m87xx_dev *s5m87xx = i2c_get_clientdata(i2c);
168
169 mfd_remove_devices(s5m87xx->dev);
170 s5m_irq_exit(s5m87xx);
171 i2c_unregister_device(s5m87xx->rtc);
172 return 0;
173}
174
175static const struct i2c_device_id s5m87xx_i2c_id[] = {
176 { "s5m87xx", 0 },
177 { }
178};
179MODULE_DEVICE_TABLE(i2c, s5m87xx_i2c_id);
180
181static struct i2c_driver s5m87xx_i2c_driver = {
182 .driver = {
183 .name = "s5m87xx",
184 .owner = THIS_MODULE,
185 },
186 .probe = s5m87xx_i2c_probe,
187 .remove = s5m87xx_i2c_remove,
188 .id_table = s5m87xx_i2c_id,
189};
190
191static int __init s5m87xx_i2c_init(void)
192{
193 return i2c_add_driver(&s5m87xx_i2c_driver);
194}
195
196subsys_initcall(s5m87xx_i2c_init);
197
198static void __exit s5m87xx_i2c_exit(void)
199{
200 i2c_del_driver(&s5m87xx_i2c_driver);
201}
202module_exit(s5m87xx_i2c_exit);
203
204MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>");
205MODULE_DESCRIPTION("Core support for the S5M MFD");
206MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/s5m-irq.c b/drivers/mfd/s5m-irq.c
deleted file mode 100644
index 0236676085cf..000000000000
--- a/drivers/mfd/s5m-irq.c
+++ /dev/null
@@ -1,495 +0,0 @@
1/*
2 * s5m-irq.c
3 *
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd
5 * http://www.samsung.com
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#include <linux/device.h>
15#include <linux/interrupt.h>
16#include <linux/irq.h>
17#include <linux/mfd/s5m87xx/s5m-core.h>
18
19struct s5m_irq_data {
20 int reg;
21 int mask;
22};
23
24static struct s5m_irq_data s5m8767_irqs[] = {
25 [S5M8767_IRQ_PWRR] = {
26 .reg = 1,
27 .mask = S5M8767_IRQ_PWRR_MASK,
28 },
29 [S5M8767_IRQ_PWRF] = {
30 .reg = 1,
31 .mask = S5M8767_IRQ_PWRF_MASK,
32 },
33 [S5M8767_IRQ_PWR1S] = {
34 .reg = 1,
35 .mask = S5M8767_IRQ_PWR1S_MASK,
36 },
37 [S5M8767_IRQ_JIGR] = {
38 .reg = 1,
39 .mask = S5M8767_IRQ_JIGR_MASK,
40 },
41 [S5M8767_IRQ_JIGF] = {
42 .reg = 1,
43 .mask = S5M8767_IRQ_JIGF_MASK,
44 },
45 [S5M8767_IRQ_LOWBAT2] = {
46 .reg = 1,
47 .mask = S5M8767_IRQ_LOWBAT2_MASK,
48 },
49 [S5M8767_IRQ_LOWBAT1] = {
50 .reg = 1,
51 .mask = S5M8767_IRQ_LOWBAT1_MASK,
52 },
53 [S5M8767_IRQ_MRB] = {
54 .reg = 2,
55 .mask = S5M8767_IRQ_MRB_MASK,
56 },
57 [S5M8767_IRQ_DVSOK2] = {
58 .reg = 2,
59 .mask = S5M8767_IRQ_DVSOK2_MASK,
60 },
61 [S5M8767_IRQ_DVSOK3] = {
62 .reg = 2,
63 .mask = S5M8767_IRQ_DVSOK3_MASK,
64 },
65 [S5M8767_IRQ_DVSOK4] = {
66 .reg = 2,
67 .mask = S5M8767_IRQ_DVSOK4_MASK,
68 },
69 [S5M8767_IRQ_RTC60S] = {
70 .reg = 3,
71 .mask = S5M8767_IRQ_RTC60S_MASK,
72 },
73 [S5M8767_IRQ_RTCA1] = {
74 .reg = 3,
75 .mask = S5M8767_IRQ_RTCA1_MASK,
76 },
77 [S5M8767_IRQ_RTCA2] = {
78 .reg = 3,
79 .mask = S5M8767_IRQ_RTCA2_MASK,
80 },
81 [S5M8767_IRQ_SMPL] = {
82 .reg = 3,
83 .mask = S5M8767_IRQ_SMPL_MASK,
84 },
85 [S5M8767_IRQ_RTC1S] = {
86 .reg = 3,
87 .mask = S5M8767_IRQ_RTC1S_MASK,
88 },
89 [S5M8767_IRQ_WTSR] = {
90 .reg = 3,
91 .mask = S5M8767_IRQ_WTSR_MASK,
92 },
93};
94
95static struct s5m_irq_data s5m8763_irqs[] = {
96 [S5M8763_IRQ_DCINF] = {
97 .reg = 1,
98 .mask = S5M8763_IRQ_DCINF_MASK,
99 },
100 [S5M8763_IRQ_DCINR] = {
101 .reg = 1,
102 .mask = S5M8763_IRQ_DCINR_MASK,
103 },
104 [S5M8763_IRQ_JIGF] = {
105 .reg = 1,
106 .mask = S5M8763_IRQ_JIGF_MASK,
107 },
108 [S5M8763_IRQ_JIGR] = {
109 .reg = 1,
110 .mask = S5M8763_IRQ_JIGR_MASK,
111 },
112 [S5M8763_IRQ_PWRONF] = {
113 .reg = 1,
114 .mask = S5M8763_IRQ_PWRONF_MASK,
115 },
116 [S5M8763_IRQ_PWRONR] = {
117 .reg = 1,
118 .mask = S5M8763_IRQ_PWRONR_MASK,
119 },
120 [S5M8763_IRQ_WTSREVNT] = {
121 .reg = 2,
122 .mask = S5M8763_IRQ_WTSREVNT_MASK,
123 },
124 [S5M8763_IRQ_SMPLEVNT] = {
125 .reg = 2,
126 .mask = S5M8763_IRQ_SMPLEVNT_MASK,
127 },
128 [S5M8763_IRQ_ALARM1] = {
129 .reg = 2,
130 .mask = S5M8763_IRQ_ALARM1_MASK,
131 },
132 [S5M8763_IRQ_ALARM0] = {
133 .reg = 2,
134 .mask = S5M8763_IRQ_ALARM0_MASK,
135 },
136 [S5M8763_IRQ_ONKEY1S] = {
137 .reg = 3,
138 .mask = S5M8763_IRQ_ONKEY1S_MASK,
139 },
140 [S5M8763_IRQ_TOPOFFR] = {
141 .reg = 3,
142 .mask = S5M8763_IRQ_TOPOFFR_MASK,
143 },
144 [S5M8763_IRQ_DCINOVPR] = {
145 .reg = 3,
146 .mask = S5M8763_IRQ_DCINOVPR_MASK,
147 },
148 [S5M8763_IRQ_CHGRSTF] = {
149 .reg = 3,
150 .mask = S5M8763_IRQ_CHGRSTF_MASK,
151 },
152 [S5M8763_IRQ_DONER] = {
153 .reg = 3,
154 .mask = S5M8763_IRQ_DONER_MASK,
155 },
156 [S5M8763_IRQ_CHGFAULT] = {
157 .reg = 3,
158 .mask = S5M8763_IRQ_CHGFAULT_MASK,
159 },
160 [S5M8763_IRQ_LOBAT1] = {
161 .reg = 4,
162 .mask = S5M8763_IRQ_LOBAT1_MASK,
163 },
164 [S5M8763_IRQ_LOBAT2] = {
165 .reg = 4,
166 .mask = S5M8763_IRQ_LOBAT2_MASK,
167 },
168};
169
170static inline struct s5m_irq_data *
171irq_to_s5m8767_irq(struct s5m87xx_dev *s5m87xx, int irq)
172{
173 return &s5m8767_irqs[irq - s5m87xx->irq_base];
174}
175
176static void s5m8767_irq_lock(struct irq_data *data)
177{
178 struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data);
179
180 mutex_lock(&s5m87xx->irqlock);
181}
182
183static void s5m8767_irq_sync_unlock(struct irq_data *data)
184{
185 struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data);
186 int i;
187
188 for (i = 0; i < ARRAY_SIZE(s5m87xx->irq_masks_cur); i++) {
189 if (s5m87xx->irq_masks_cur[i] != s5m87xx->irq_masks_cache[i]) {
190 s5m87xx->irq_masks_cache[i] = s5m87xx->irq_masks_cur[i];
191 s5m_reg_write(s5m87xx, S5M8767_REG_INT1M + i,
192 s5m87xx->irq_masks_cur[i]);
193 }
194 }
195
196 mutex_unlock(&s5m87xx->irqlock);
197}
198
199static void s5m8767_irq_unmask(struct irq_data *data)
200{
201 struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data);
202 struct s5m_irq_data *irq_data = irq_to_s5m8767_irq(s5m87xx,
203 data->irq);
204
205 s5m87xx->irq_masks_cur[irq_data->reg - 1] &= ~irq_data->mask;
206}
207
208static void s5m8767_irq_mask(struct irq_data *data)
209{
210 struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data);
211 struct s5m_irq_data *irq_data = irq_to_s5m8767_irq(s5m87xx,
212 data->irq);
213
214 s5m87xx->irq_masks_cur[irq_data->reg - 1] |= irq_data->mask;
215}
216
217static struct irq_chip s5m8767_irq_chip = {
218 .name = "s5m8767",
219 .irq_bus_lock = s5m8767_irq_lock,
220 .irq_bus_sync_unlock = s5m8767_irq_sync_unlock,
221 .irq_mask = s5m8767_irq_mask,
222 .irq_unmask = s5m8767_irq_unmask,
223};
224
225static inline struct s5m_irq_data *
226irq_to_s5m8763_irq(struct s5m87xx_dev *s5m87xx, int irq)
227{
228 return &s5m8763_irqs[irq - s5m87xx->irq_base];
229}
230
231static void s5m8763_irq_lock(struct irq_data *data)
232{
233 struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data);
234
235 mutex_lock(&s5m87xx->irqlock);
236}
237
238static void s5m8763_irq_sync_unlock(struct irq_data *data)
239{
240 struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data);
241 int i;
242
243 for (i = 0; i < ARRAY_SIZE(s5m87xx->irq_masks_cur); i++) {
244 if (s5m87xx->irq_masks_cur[i] != s5m87xx->irq_masks_cache[i]) {
245 s5m87xx->irq_masks_cache[i] = s5m87xx->irq_masks_cur[i];
246 s5m_reg_write(s5m87xx, S5M8763_REG_IRQM1 + i,
247 s5m87xx->irq_masks_cur[i]);
248 }
249 }
250
251 mutex_unlock(&s5m87xx->irqlock);
252}
253
254static void s5m8763_irq_unmask(struct irq_data *data)
255{
256 struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data);
257 struct s5m_irq_data *irq_data = irq_to_s5m8763_irq(s5m87xx,
258 data->irq);
259
260 s5m87xx->irq_masks_cur[irq_data->reg - 1] &= ~irq_data->mask;
261}
262
263static void s5m8763_irq_mask(struct irq_data *data)
264{
265 struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data);
266 struct s5m_irq_data *irq_data = irq_to_s5m8763_irq(s5m87xx,
267 data->irq);
268
269 s5m87xx->irq_masks_cur[irq_data->reg - 1] |= irq_data->mask;
270}
271
272static struct irq_chip s5m8763_irq_chip = {
273 .name = "s5m8763",
274 .irq_bus_lock = s5m8763_irq_lock,
275 .irq_bus_sync_unlock = s5m8763_irq_sync_unlock,
276 .irq_mask = s5m8763_irq_mask,
277 .irq_unmask = s5m8763_irq_unmask,
278};
279
280
281static irqreturn_t s5m8767_irq_thread(int irq, void *data)
282{
283 struct s5m87xx_dev *s5m87xx = data;
284 u8 irq_reg[NUM_IRQ_REGS-1];
285 int ret;
286 int i;
287
288
289 ret = s5m_bulk_read(s5m87xx, S5M8767_REG_INT1,
290 NUM_IRQ_REGS - 1, irq_reg);
291 if (ret < 0) {
292 dev_err(s5m87xx->dev, "Failed to read interrupt register: %d\n",
293 ret);
294 return IRQ_NONE;
295 }
296
297 for (i = 0; i < NUM_IRQ_REGS - 1; i++)
298 irq_reg[i] &= ~s5m87xx->irq_masks_cur[i];
299
300 for (i = 0; i < S5M8767_IRQ_NR; i++) {
301 if (irq_reg[s5m8767_irqs[i].reg - 1] & s5m8767_irqs[i].mask)
302 handle_nested_irq(s5m87xx->irq_base + i);
303 }
304
305 return IRQ_HANDLED;
306}
307
308static irqreturn_t s5m8763_irq_thread(int irq, void *data)
309{
310 struct s5m87xx_dev *s5m87xx = data;
311 u8 irq_reg[NUM_IRQ_REGS];
312 int ret;
313 int i;
314
315 ret = s5m_bulk_read(s5m87xx, S5M8763_REG_IRQ1,
316 NUM_IRQ_REGS, irq_reg);
317 if (ret < 0) {
318 dev_err(s5m87xx->dev, "Failed to read interrupt register: %d\n",
319 ret);
320 return IRQ_NONE;
321 }
322
323 for (i = 0; i < NUM_IRQ_REGS; i++)
324 irq_reg[i] &= ~s5m87xx->irq_masks_cur[i];
325
326 for (i = 0; i < S5M8763_IRQ_NR; i++) {
327 if (irq_reg[s5m8763_irqs[i].reg - 1] & s5m8763_irqs[i].mask)
328 handle_nested_irq(s5m87xx->irq_base + i);
329 }
330
331 return IRQ_HANDLED;
332}
333
334int s5m_irq_resume(struct s5m87xx_dev *s5m87xx)
335{
336 if (s5m87xx->irq && s5m87xx->irq_base){
337 switch (s5m87xx->device_type) {
338 case S5M8763X:
339 s5m8763_irq_thread(s5m87xx->irq_base, s5m87xx);
340 break;
341 case S5M8767X:
342 s5m8767_irq_thread(s5m87xx->irq_base, s5m87xx);
343 break;
344 default:
345 dev_err(s5m87xx->dev,
346 "Unknown device type %d\n",
347 s5m87xx->device_type);
348 return -EINVAL;
349
350 }
351 }
352 return 0;
353}
354
355int s5m_irq_init(struct s5m87xx_dev *s5m87xx)
356{
357 int i;
358 int cur_irq;
359 int ret = 0;
360 int type = s5m87xx->device_type;
361
362 if (!s5m87xx->irq) {
363 dev_warn(s5m87xx->dev,
364 "No interrupt specified, no interrupts\n");
365 s5m87xx->irq_base = 0;
366 return 0;
367 }
368
369 if (!s5m87xx->irq_base) {
370 dev_err(s5m87xx->dev,
371 "No interrupt base specified, no interrupts\n");
372 return 0;
373 }
374
375 mutex_init(&s5m87xx->irqlock);
376
377 switch (type) {
378 case S5M8763X:
379 for (i = 0; i < NUM_IRQ_REGS; i++) {
380 s5m87xx->irq_masks_cur[i] = 0xff;
381 s5m87xx->irq_masks_cache[i] = 0xff;
382 s5m_reg_write(s5m87xx, S5M8763_REG_IRQM1 + i,
383 0xff);
384 }
385
386 s5m_reg_write(s5m87xx, S5M8763_REG_STATUSM1, 0xff);
387 s5m_reg_write(s5m87xx, S5M8763_REG_STATUSM2, 0xff);
388
389 for (i = 0; i < S5M8763_IRQ_NR; i++) {
390 cur_irq = i + s5m87xx->irq_base;
391 irq_set_chip_data(cur_irq, s5m87xx);
392 irq_set_chip_and_handler(cur_irq, &s5m8763_irq_chip,
393 handle_edge_irq);
394 irq_set_nested_thread(cur_irq, 1);
395#ifdef CONFIG_ARM
396 set_irq_flags(cur_irq, IRQF_VALID);
397#else
398 irq_set_noprobe(cur_irq);
399#endif
400 }
401
402 ret = request_threaded_irq(s5m87xx->irq, NULL,
403 s5m8763_irq_thread,
404 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
405 "s5m87xx-irq", s5m87xx);
406 if (ret) {
407 dev_err(s5m87xx->dev, "Failed to request IRQ %d: %d\n",
408 s5m87xx->irq, ret);
409 return ret;
410 }
411 break;
412 case S5M8767X:
413 for (i = 0; i < NUM_IRQ_REGS - 1; i++) {
414 s5m87xx->irq_masks_cur[i] = 0xff;
415 s5m87xx->irq_masks_cache[i] = 0xff;
416 s5m_reg_write(s5m87xx, S5M8767_REG_INT1M + i,
417 0xff);
418 }
419 for (i = 0; i < S5M8767_IRQ_NR; i++) {
420 cur_irq = i + s5m87xx->irq_base;
421 irq_set_chip_data(cur_irq, s5m87xx);
422 if (ret) {
423 dev_err(s5m87xx->dev,
424 "Failed to irq_set_chip_data %d: %d\n",
425 s5m87xx->irq, ret);
426 return ret;
427 }
428
429 irq_set_chip_and_handler(cur_irq, &s5m8767_irq_chip,
430 handle_edge_irq);
431 irq_set_nested_thread(cur_irq, 1);
432#ifdef CONFIG_ARM
433 set_irq_flags(cur_irq, IRQF_VALID);
434#else
435 irq_set_noprobe(cur_irq);
436#endif
437 }
438
439 ret = request_threaded_irq(s5m87xx->irq, NULL,
440 s5m8767_irq_thread,
441 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
442 "s5m87xx-irq", s5m87xx);
443 if (ret) {
444 dev_err(s5m87xx->dev, "Failed to request IRQ %d: %d\n",
445 s5m87xx->irq, ret);
446 return ret;
447 }
448 break;
449 default:
450 dev_err(s5m87xx->dev,
451 "Unknown device type %d\n", s5m87xx->device_type);
452 return -EINVAL;
453 }
454
455 if (!s5m87xx->ono)
456 return 0;
457
458 switch (type) {
459 case S5M8763X:
460 ret = request_threaded_irq(s5m87xx->ono, NULL,
461 s5m8763_irq_thread,
462 IRQF_TRIGGER_FALLING |
463 IRQF_TRIGGER_RISING |
464 IRQF_ONESHOT, "s5m87xx-ono",
465 s5m87xx);
466 break;
467 case S5M8767X:
468 ret = request_threaded_irq(s5m87xx->ono, NULL,
469 s5m8767_irq_thread,
470 IRQF_TRIGGER_FALLING |
471 IRQF_TRIGGER_RISING |
472 IRQF_ONESHOT, "s5m87xx-ono", s5m87xx);
473 break;
474 default:
475 ret = -EINVAL;
476 break;
477 }
478
479 if (ret) {
480 dev_err(s5m87xx->dev, "Failed to request IRQ %d: %d\n",
481 s5m87xx->ono, ret);
482 return ret;
483 }
484
485 return 0;
486}
487
488void s5m_irq_exit(struct s5m87xx_dev *s5m87xx)
489{
490 if (s5m87xx->ono)
491 free_irq(s5m87xx->ono, s5m87xx);
492
493 if (s5m87xx->irq)
494 free_irq(s5m87xx->irq, s5m87xx);
495}
diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
new file mode 100644
index 000000000000..2988efde11eb
--- /dev/null
+++ b/drivers/mfd/sec-core.c
@@ -0,0 +1,216 @@
1/*
2 * sec-core.c
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd
5 * http://www.samsung.com
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/init.h>
17#include <linux/err.h>
18#include <linux/slab.h>
19#include <linux/i2c.h>
20#include <linux/interrupt.h>
21#include <linux/pm_runtime.h>
22#include <linux/mutex.h>
23#include <linux/mfd/core.h>
24#include <linux/mfd/samsung/core.h>
25#include <linux/mfd/samsung/irq.h>
26#include <linux/mfd/samsung/rtc.h>
27#include <linux/regmap.h>
28
29static struct mfd_cell s5m8751_devs[] = {
30 {
31 .name = "s5m8751-pmic",
32 }, {
33 .name = "s5m-charger",
34 }, {
35 .name = "s5m8751-codec",
36 },
37};
38
39static struct mfd_cell s5m8763_devs[] = {
40 {
41 .name = "s5m8763-pmic",
42 }, {
43 .name = "s5m-rtc",
44 }, {
45 .name = "s5m-charger",
46 },
47};
48
49static struct mfd_cell s5m8767_devs[] = {
50 {
51 .name = "s5m8767-pmic",
52 }, {
53 .name = "s5m-rtc",
54 },
55};
56
57static struct mfd_cell s2mps11_devs[] = {
58 {
59 .name = "s2mps11-pmic",
60 },
61};
62
63int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest)
64{
65 return regmap_read(sec_pmic->regmap, reg, dest);
66}
67EXPORT_SYMBOL_GPL(sec_reg_read);
68
69int sec_bulk_read(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf)
70{
71 return regmap_bulk_read(sec_pmic->regmap, reg, buf, count);
72}
73EXPORT_SYMBOL_GPL(sec_bulk_read);
74
75int sec_reg_write(struct sec_pmic_dev *sec_pmic, u8 reg, u8 value)
76{
77 return regmap_write(sec_pmic->regmap, reg, value);
78}
79EXPORT_SYMBOL_GPL(sec_reg_write);
80
81int sec_bulk_write(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf)
82{
83 return regmap_raw_write(sec_pmic->regmap, reg, buf, count);
84}
85EXPORT_SYMBOL_GPL(sec_bulk_write);
86
87int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask)
88{
89 return regmap_update_bits(sec_pmic->regmap, reg, mask, val);
90}
91EXPORT_SYMBOL_GPL(sec_reg_update);
92
93static struct regmap_config sec_regmap_config = {
94 .reg_bits = 8,
95 .val_bits = 8,
96};
97
98static int sec_pmic_probe(struct i2c_client *i2c,
99 const struct i2c_device_id *id)
100{
101 struct sec_platform_data *pdata = i2c->dev.platform_data;
102 struct sec_pmic_dev *sec_pmic;
103 int ret;
104
105 sec_pmic = devm_kzalloc(&i2c->dev, sizeof(struct sec_pmic_dev),
106 GFP_KERNEL);
107 if (sec_pmic == NULL)
108 return -ENOMEM;
109
110 i2c_set_clientdata(i2c, sec_pmic);
111 sec_pmic->dev = &i2c->dev;
112 sec_pmic->i2c = i2c;
113 sec_pmic->irq = i2c->irq;
114 sec_pmic->type = id->driver_data;
115
116 if (pdata) {
117 sec_pmic->device_type = pdata->device_type;
118 sec_pmic->ono = pdata->ono;
119 sec_pmic->irq_base = pdata->irq_base;
120 sec_pmic->wakeup = pdata->wakeup;
121 }
122
123 sec_pmic->regmap = devm_regmap_init_i2c(i2c, &sec_regmap_config);
124 if (IS_ERR(sec_pmic->regmap)) {
125 ret = PTR_ERR(sec_pmic->regmap);
126 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
127 ret);
128 return ret;
129 }
130
131 sec_pmic->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
132 i2c_set_clientdata(sec_pmic->rtc, sec_pmic);
133
134 if (pdata && pdata->cfg_pmic_irq)
135 pdata->cfg_pmic_irq();
136
137 sec_irq_init(sec_pmic);
138
139 pm_runtime_set_active(sec_pmic->dev);
140
141 switch (sec_pmic->device_type) {
142 case S5M8751X:
143 ret = mfd_add_devices(sec_pmic->dev, -1, s5m8751_devs,
144 ARRAY_SIZE(s5m8751_devs), NULL, 0);
145 break;
146 case S5M8763X:
147 ret = mfd_add_devices(sec_pmic->dev, -1, s5m8763_devs,
148 ARRAY_SIZE(s5m8763_devs), NULL, 0);
149 break;
150 case S5M8767X:
151 ret = mfd_add_devices(sec_pmic->dev, -1, s5m8767_devs,
152 ARRAY_SIZE(s5m8767_devs), NULL, 0);
153 break;
154 case S2MPS11X:
155 ret = mfd_add_devices(sec_pmic->dev, -1, s2mps11_devs,
156 ARRAY_SIZE(s2mps11_devs), NULL, 0);
157 break;
158 default:
159 /* If this happens the probe function is problem */
160 BUG();
161 }
162
163 if (ret < 0)
164 goto err;
165
166 return ret;
167
168err:
169 mfd_remove_devices(sec_pmic->dev);
170 sec_irq_exit(sec_pmic);
171 i2c_unregister_device(sec_pmic->rtc);
172 return ret;
173}
174
175static int sec_pmic_remove(struct i2c_client *i2c)
176{
177 struct sec_pmic_dev *sec_pmic = i2c_get_clientdata(i2c);
178
179 mfd_remove_devices(sec_pmic->dev);
180 sec_irq_exit(sec_pmic);
181 i2c_unregister_device(sec_pmic->rtc);
182 return 0;
183}
184
185static const struct i2c_device_id sec_pmic_id[] = {
186 { "sec_pmic", 0 },
187 { }
188};
189MODULE_DEVICE_TABLE(i2c, sec_pmic_id);
190
191static struct i2c_driver sec_pmic_driver = {
192 .driver = {
193 .name = "sec_pmic",
194 .owner = THIS_MODULE,
195 },
196 .probe = sec_pmic_probe,
197 .remove = sec_pmic_remove,
198 .id_table = sec_pmic_id,
199};
200
201static int __init sec_pmic_init(void)
202{
203 return i2c_add_driver(&sec_pmic_driver);
204}
205
206subsys_initcall(sec_pmic_init);
207
208static void __exit sec_pmic_exit(void)
209{
210 i2c_del_driver(&sec_pmic_driver);
211}
212module_exit(sec_pmic_exit);
213
214MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>");
215MODULE_DESCRIPTION("Core support for the S5M MFD");
216MODULE_LICENSE("GPL");
diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c
new file mode 100644
index 000000000000..c901fa50fea1
--- /dev/null
+++ b/drivers/mfd/sec-irq.c
@@ -0,0 +1,317 @@
1/*
2 * sec-irq.c
3 *
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd
5 * http://www.samsung.com
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#include <linux/device.h>
15#include <linux/interrupt.h>
16#include <linux/irq.h>
17#include <linux/regmap.h>
18
19#include <linux/mfd/samsung/core.h>
20#include <linux/mfd/samsung/irq.h>
21#include <linux/mfd/samsung/s2mps11.h>
22#include <linux/mfd/samsung/s5m8763.h>
23#include <linux/mfd/samsung/s5m8767.h>
24
25static struct regmap_irq s2mps11_irqs[] = {
26 [S2MPS11_IRQ_PWRONF] = {
27 .reg_offset = 1,
28 .mask = S2MPS11_IRQ_PWRONF_MASK,
29 },
30 [S2MPS11_IRQ_PWRONR] = {
31 .reg_offset = 1,
32 .mask = S2MPS11_IRQ_PWRONR_MASK,
33 },
34 [S2MPS11_IRQ_JIGONBF] = {
35 .reg_offset = 1,
36 .mask = S2MPS11_IRQ_JIGONBF_MASK,
37 },
38 [S2MPS11_IRQ_JIGONBR] = {
39 .reg_offset = 1,
40 .mask = S2MPS11_IRQ_JIGONBR_MASK,
41 },
42 [S2MPS11_IRQ_ACOKBF] = {
43 .reg_offset = 1,
44 .mask = S2MPS11_IRQ_ACOKBF_MASK,
45 },
46 [S2MPS11_IRQ_ACOKBR] = {
47 .reg_offset = 1,
48 .mask = S2MPS11_IRQ_ACOKBR_MASK,
49 },
50 [S2MPS11_IRQ_PWRON1S] = {
51 .reg_offset = 1,
52 .mask = S2MPS11_IRQ_PWRON1S_MASK,
53 },
54 [S2MPS11_IRQ_MRB] = {
55 .reg_offset = 1,
56 .mask = S2MPS11_IRQ_MRB_MASK,
57 },
58 [S2MPS11_IRQ_RTC60S] = {
59 .reg_offset = 2,
60 .mask = S2MPS11_IRQ_RTC60S_MASK,
61 },
62 [S2MPS11_IRQ_RTCA1] = {
63 .reg_offset = 2,
64 .mask = S2MPS11_IRQ_RTCA1_MASK,
65 },
66 [S2MPS11_IRQ_RTCA2] = {
67 .reg_offset = 2,
68 .mask = S2MPS11_IRQ_RTCA2_MASK,
69 },
70 [S2MPS11_IRQ_SMPL] = {
71 .reg_offset = 2,
72 .mask = S2MPS11_IRQ_SMPL_MASK,
73 },
74 [S2MPS11_IRQ_RTC1S] = {
75 .reg_offset = 2,
76 .mask = S2MPS11_IRQ_RTC1S_MASK,
77 },
78 [S2MPS11_IRQ_WTSR] = {
79 .reg_offset = 2,
80 .mask = S2MPS11_IRQ_WTSR_MASK,
81 },
82 [S2MPS11_IRQ_INT120C] = {
83 .reg_offset = 3,
84 .mask = S2MPS11_IRQ_INT120C_MASK,
85 },
86 [S2MPS11_IRQ_INT140C] = {
87 .reg_offset = 3,
88 .mask = S2MPS11_IRQ_INT140C_MASK,
89 },
90};
91
92
93static struct regmap_irq s5m8767_irqs[] = {
94 [S5M8767_IRQ_PWRR] = {
95 .reg_offset = 1,
96 .mask = S5M8767_IRQ_PWRR_MASK,
97 },
98 [S5M8767_IRQ_PWRF] = {
99 .reg_offset = 1,
100 .mask = S5M8767_IRQ_PWRF_MASK,
101 },
102 [S5M8767_IRQ_PWR1S] = {
103 .reg_offset = 1,
104 .mask = S5M8767_IRQ_PWR1S_MASK,
105 },
106 [S5M8767_IRQ_JIGR] = {
107 .reg_offset = 1,
108 .mask = S5M8767_IRQ_JIGR_MASK,
109 },
110 [S5M8767_IRQ_JIGF] = {
111 .reg_offset = 1,
112 .mask = S5M8767_IRQ_JIGF_MASK,
113 },
114 [S5M8767_IRQ_LOWBAT2] = {
115 .reg_offset = 1,
116 .mask = S5M8767_IRQ_LOWBAT2_MASK,
117 },
118 [S5M8767_IRQ_LOWBAT1] = {
119 .reg_offset = 1,
120 .mask = S5M8767_IRQ_LOWBAT1_MASK,
121 },
122 [S5M8767_IRQ_MRB] = {
123 .reg_offset = 2,
124 .mask = S5M8767_IRQ_MRB_MASK,
125 },
126 [S5M8767_IRQ_DVSOK2] = {
127 .reg_offset = 2,
128 .mask = S5M8767_IRQ_DVSOK2_MASK,
129 },
130 [S5M8767_IRQ_DVSOK3] = {
131 .reg_offset = 2,
132 .mask = S5M8767_IRQ_DVSOK3_MASK,
133 },
134 [S5M8767_IRQ_DVSOK4] = {
135 .reg_offset = 2,
136 .mask = S5M8767_IRQ_DVSOK4_MASK,
137 },
138 [S5M8767_IRQ_RTC60S] = {
139 .reg_offset = 3,
140 .mask = S5M8767_IRQ_RTC60S_MASK,
141 },
142 [S5M8767_IRQ_RTCA1] = {
143 .reg_offset = 3,
144 .mask = S5M8767_IRQ_RTCA1_MASK,
145 },
146 [S5M8767_IRQ_RTCA2] = {
147 .reg_offset = 3,
148 .mask = S5M8767_IRQ_RTCA2_MASK,
149 },
150 [S5M8767_IRQ_SMPL] = {
151 .reg_offset = 3,
152 .mask = S5M8767_IRQ_SMPL_MASK,
153 },
154 [S5M8767_IRQ_RTC1S] = {
155 .reg_offset = 3,
156 .mask = S5M8767_IRQ_RTC1S_MASK,
157 },
158 [S5M8767_IRQ_WTSR] = {
159 .reg_offset = 3,
160 .mask = S5M8767_IRQ_WTSR_MASK,
161 },
162};
163
164static struct regmap_irq s5m8763_irqs[] = {
165 [S5M8763_IRQ_DCINF] = {
166 .reg_offset = 1,
167 .mask = S5M8763_IRQ_DCINF_MASK,
168 },
169 [S5M8763_IRQ_DCINR] = {
170 .reg_offset = 1,
171 .mask = S5M8763_IRQ_DCINR_MASK,
172 },
173 [S5M8763_IRQ_JIGF] = {
174 .reg_offset = 1,
175 .mask = S5M8763_IRQ_JIGF_MASK,
176 },
177 [S5M8763_IRQ_JIGR] = {
178 .reg_offset = 1,
179 .mask = S5M8763_IRQ_JIGR_MASK,
180 },
181 [S5M8763_IRQ_PWRONF] = {
182 .reg_offset = 1,
183 .mask = S5M8763_IRQ_PWRONF_MASK,
184 },
185 [S5M8763_IRQ_PWRONR] = {
186 .reg_offset = 1,
187 .mask = S5M8763_IRQ_PWRONR_MASK,
188 },
189 [S5M8763_IRQ_WTSREVNT] = {
190 .reg_offset = 2,
191 .mask = S5M8763_IRQ_WTSREVNT_MASK,
192 },
193 [S5M8763_IRQ_SMPLEVNT] = {
194 .reg_offset = 2,
195 .mask = S5M8763_IRQ_SMPLEVNT_MASK,
196 },
197 [S5M8763_IRQ_ALARM1] = {
198 .reg_offset = 2,
199 .mask = S5M8763_IRQ_ALARM1_MASK,
200 },
201 [S5M8763_IRQ_ALARM0] = {
202 .reg_offset = 2,
203 .mask = S5M8763_IRQ_ALARM0_MASK,
204 },
205 [S5M8763_IRQ_ONKEY1S] = {
206 .reg_offset = 3,
207 .mask = S5M8763_IRQ_ONKEY1S_MASK,
208 },
209 [S5M8763_IRQ_TOPOFFR] = {
210 .reg_offset = 3,
211 .mask = S5M8763_IRQ_TOPOFFR_MASK,
212 },
213 [S5M8763_IRQ_DCINOVPR] = {
214 .reg_offset = 3,
215 .mask = S5M8763_IRQ_DCINOVPR_MASK,
216 },
217 [S5M8763_IRQ_CHGRSTF] = {
218 .reg_offset = 3,
219 .mask = S5M8763_IRQ_CHGRSTF_MASK,
220 },
221 [S5M8763_IRQ_DONER] = {
222 .reg_offset = 3,
223 .mask = S5M8763_IRQ_DONER_MASK,
224 },
225 [S5M8763_IRQ_CHGFAULT] = {
226 .reg_offset = 3,
227 .mask = S5M8763_IRQ_CHGFAULT_MASK,
228 },
229 [S5M8763_IRQ_LOBAT1] = {
230 .reg_offset = 4,
231 .mask = S5M8763_IRQ_LOBAT1_MASK,
232 },
233 [S5M8763_IRQ_LOBAT2] = {
234 .reg_offset = 4,
235 .mask = S5M8763_IRQ_LOBAT2_MASK,
236 },
237};
238
239static struct regmap_irq_chip s2mps11_irq_chip = {
240 .name = "s2mps11",
241 .irqs = s2mps11_irqs,
242 .num_irqs = ARRAY_SIZE(s2mps11_irqs),
243 .num_regs = 3,
244 .status_base = S2MPS11_REG_INT1,
245 .mask_base = S2MPS11_REG_INT1M,
246 .ack_base = S2MPS11_REG_INT1,
247};
248
249static struct regmap_irq_chip s5m8767_irq_chip = {
250 .name = "s5m8767",
251 .irqs = s5m8767_irqs,
252 .num_irqs = ARRAY_SIZE(s5m8767_irqs),
253 .num_regs = 3,
254 .status_base = S5M8767_REG_INT1,
255 .mask_base = S5M8767_REG_INT1M,
256 .ack_base = S5M8767_REG_INT1,
257};
258
259static struct regmap_irq_chip s5m8763_irq_chip = {
260 .name = "s5m8763",
261 .irqs = s5m8763_irqs,
262 .num_irqs = ARRAY_SIZE(s5m8763_irqs),
263 .num_regs = 4,
264 .status_base = S5M8763_REG_IRQ1,
265 .mask_base = S5M8763_REG_IRQM1,
266 .ack_base = S5M8763_REG_IRQ1,
267};
268
269int sec_irq_init(struct sec_pmic_dev *sec_pmic)
270{
271 int ret = 0;
272 int type = sec_pmic->device_type;
273
274 if (!sec_pmic->irq) {
275 dev_warn(sec_pmic->dev,
276 "No interrupt specified, no interrupts\n");
277 sec_pmic->irq_base = 0;
278 return 0;
279 }
280
281 switch (type) {
282 case S5M8763X:
283 ret = regmap_add_irq_chip(sec_pmic->regmap, sec_pmic->irq,
284 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
285 sec_pmic->irq_base, &s5m8763_irq_chip,
286 &sec_pmic->irq_data);
287 break;
288 case S5M8767X:
289 ret = regmap_add_irq_chip(sec_pmic->regmap, sec_pmic->irq,
290 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
291 sec_pmic->irq_base, &s5m8767_irq_chip,
292 &sec_pmic->irq_data);
293 break;
294 case S2MPS11X:
295 ret = regmap_add_irq_chip(sec_pmic->regmap, sec_pmic->irq,
296 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
297 sec_pmic->irq_base, &s2mps11_irq_chip,
298 &sec_pmic->irq_data);
299 break;
300 default:
301 dev_err(sec_pmic->dev, "Unknown device type %d\n",
302 sec_pmic->device_type);
303 return -EINVAL;
304 }
305
306 if (ret != 0) {
307 dev_err(sec_pmic->dev, "Failed to register IRQ chip: %d\n", ret);
308 return ret;
309 }
310
311 return 0;
312}
313
314void sec_irq_exit(struct sec_pmic_dev *sec_pmic)
315{
316 regmap_del_irq_chip(sec_pmic->irq, sec_pmic->irq_data);
317}
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
index de979742c6fc..048bf0532a09 100644
--- a/drivers/mfd/tc3589x.c
+++ b/drivers/mfd/tc3589x.c
@@ -357,7 +357,7 @@ static int __devexit tc3589x_remove(struct i2c_client *client)
357 return 0; 357 return 0;
358} 358}
359 359
360#ifdef CONFIG_PM 360#ifdef CONFIG_PM_SLEEP
361static int tc3589x_suspend(struct device *dev) 361static int tc3589x_suspend(struct device *dev)
362{ 362{
363 struct tc3589x *tc3589x = dev_get_drvdata(dev); 363 struct tc3589x *tc3589x = dev_get_drvdata(dev);
@@ -385,11 +385,10 @@ static int tc3589x_resume(struct device *dev)
385 385
386 return ret; 386 return ret;
387} 387}
388
389static const SIMPLE_DEV_PM_OPS(tc3589x_dev_pm_ops, tc3589x_suspend,
390 tc3589x_resume);
391#endif 388#endif
392 389
390static SIMPLE_DEV_PM_OPS(tc3589x_dev_pm_ops, tc3589x_suspend, tc3589x_resume);
391
393static const struct i2c_device_id tc3589x_id[] = { 392static const struct i2c_device_id tc3589x_id[] = {
394 { "tc3589x", 24 }, 393 { "tc3589x", 24 },
395 { } 394 { }
@@ -399,9 +398,7 @@ MODULE_DEVICE_TABLE(i2c, tc3589x_id);
399static struct i2c_driver tc3589x_driver = { 398static struct i2c_driver tc3589x_driver = {
400 .driver.name = "tc3589x", 399 .driver.name = "tc3589x",
401 .driver.owner = THIS_MODULE, 400 .driver.owner = THIS_MODULE,
402#ifdef CONFIG_PM
403 .driver.pm = &tc3589x_dev_pm_ops, 401 .driver.pm = &tc3589x_dev_pm_ops,
404#endif
405 .probe = tc3589x_probe, 402 .probe = tc3589x_probe,
406 .remove = __devexit_p(tc3589x_remove), 403 .remove = __devexit_p(tc3589x_remove),
407 .id_table = tc3589x_id, 404 .id_table = tc3589x_id,
diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c
index 396b9d1b6bd6..80e24f4b47bf 100644
--- a/drivers/mfd/tps65090.c
+++ b/drivers/mfd/tps65090.c
@@ -71,10 +71,10 @@ static const struct tps65090_irq_data tps65090_irqs[] = {
71 71
72static struct mfd_cell tps65090s[] = { 72static struct mfd_cell tps65090s[] = {
73 { 73 {
74 .name = "tps65910-pmic", 74 .name = "tps65090-pmic",
75 }, 75 },
76 { 76 {
77 .name = "tps65910-regulator", 77 .name = "tps65090-regulator",
78 }, 78 },
79}; 79};
80 80
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index c84b5506d5fb..353c34812120 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -21,17 +21,14 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/gpio.h> 24#include <linux/err.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/regmap.h>
26#include <linux/regulator/of_regulator.h> 27#include <linux/regulator/of_regulator.h>
27 28
28#include <linux/mfd/core.h> 29#include <linux/mfd/core.h>
29#include <linux/mfd/tps6586x.h> 30#include <linux/mfd/tps6586x.h>
30 31
31/* GPIO control registers */
32#define TPS6586X_GPIOSET1 0x5d
33#define TPS6586X_GPIOSET2 0x5e
34
35/* interrupt control registers */ 32/* interrupt control registers */
36#define TPS6586X_INT_ACK1 0xb5 33#define TPS6586X_INT_ACK1 0xb5
37#define TPS6586X_INT_ACK2 0xb6 34#define TPS6586X_INT_ACK2 0xb6
@@ -48,6 +45,9 @@
48/* device id */ 45/* device id */
49#define TPS6586X_VERSIONCRC 0xcd 46#define TPS6586X_VERSIONCRC 0xcd
50 47
48/* Maximum register */
49#define TPS6586X_MAX_REGISTER (TPS6586X_VERSIONCRC + 1)
50
51struct tps6586x_irq_data { 51struct tps6586x_irq_data {
52 u8 mask_reg; 52 u8 mask_reg;
53 u8 mask_mask; 53 u8 mask_mask;
@@ -89,226 +89,96 @@ static const struct tps6586x_irq_data tps6586x_irqs[] = {
89 [TPS6586X_INT_RTC_ALM2] = TPS6586X_IRQ(TPS6586X_INT_MASK4, 1 << 1), 89 [TPS6586X_INT_RTC_ALM2] = TPS6586X_IRQ(TPS6586X_INT_MASK4, 1 << 1),
90}; 90};
91 91
92static struct mfd_cell tps6586x_cell[] = {
93 {
94 .name = "tps6586x-gpio",
95 },
96 {
97 .name = "tps6586x-rtc",
98 },
99 {
100 .name = "tps6586x-onkey",
101 },
102};
103
92struct tps6586x { 104struct tps6586x {
93 struct mutex lock;
94 struct device *dev; 105 struct device *dev;
95 struct i2c_client *client; 106 struct i2c_client *client;
107 struct regmap *regmap;
96 108
97 struct gpio_chip gpio;
98 struct irq_chip irq_chip; 109 struct irq_chip irq_chip;
99 struct mutex irq_lock; 110 struct mutex irq_lock;
100 int irq_base; 111 int irq_base;
101 u32 irq_en; 112 u32 irq_en;
102 u8 mask_cache[5];
103 u8 mask_reg[5]; 113 u8 mask_reg[5];
104}; 114};
105 115
106static inline int __tps6586x_read(struct i2c_client *client, 116static inline struct tps6586x *dev_to_tps6586x(struct device *dev)
107 int reg, uint8_t *val)
108{
109 int ret;
110
111 ret = i2c_smbus_read_byte_data(client, reg);
112 if (ret < 0) {
113 dev_err(&client->dev, "failed reading at 0x%02x\n", reg);
114 return ret;
115 }
116
117 *val = (uint8_t)ret;
118
119 return 0;
120}
121
122static inline int __tps6586x_reads(struct i2c_client *client, int reg,
123 int len, uint8_t *val)
124{
125 int ret;
126
127 ret = i2c_smbus_read_i2c_block_data(client, reg, len, val);
128 if (ret < 0) {
129 dev_err(&client->dev, "failed reading from 0x%02x\n", reg);
130 return ret;
131 }
132
133 return 0;
134}
135
136static inline int __tps6586x_write(struct i2c_client *client,
137 int reg, uint8_t val)
138{ 117{
139 int ret; 118 return i2c_get_clientdata(to_i2c_client(dev));
140
141 ret = i2c_smbus_write_byte_data(client, reg, val);
142 if (ret < 0) {
143 dev_err(&client->dev, "failed writing 0x%02x to 0x%02x\n",
144 val, reg);
145 return ret;
146 }
147
148 return 0;
149}
150
151static inline int __tps6586x_writes(struct i2c_client *client, int reg,
152 int len, uint8_t *val)
153{
154 int ret, i;
155
156 for (i = 0; i < len; i++) {
157 ret = __tps6586x_write(client, reg + i, *(val + i));
158 if (ret < 0)
159 return ret;
160 }
161
162 return 0;
163} 119}
164 120
165int tps6586x_write(struct device *dev, int reg, uint8_t val) 121int tps6586x_write(struct device *dev, int reg, uint8_t val)
166{ 122{
167 return __tps6586x_write(to_i2c_client(dev), reg, val); 123 struct tps6586x *tps6586x = dev_to_tps6586x(dev);
124
125 return regmap_write(tps6586x->regmap, reg, val);
168} 126}
169EXPORT_SYMBOL_GPL(tps6586x_write); 127EXPORT_SYMBOL_GPL(tps6586x_write);
170 128
171int tps6586x_writes(struct device *dev, int reg, int len, uint8_t *val) 129int tps6586x_writes(struct device *dev, int reg, int len, uint8_t *val)
172{ 130{
173 return __tps6586x_writes(to_i2c_client(dev), reg, len, val); 131 struct tps6586x *tps6586x = dev_to_tps6586x(dev);
132
133 return regmap_bulk_write(tps6586x->regmap, reg, val, len);
174} 134}
175EXPORT_SYMBOL_GPL(tps6586x_writes); 135EXPORT_SYMBOL_GPL(tps6586x_writes);
176 136
177int tps6586x_read(struct device *dev, int reg, uint8_t *val) 137int tps6586x_read(struct device *dev, int reg, uint8_t *val)
178{ 138{
179 return __tps6586x_read(to_i2c_client(dev), reg, val); 139 struct tps6586x *tps6586x = dev_to_tps6586x(dev);
140 unsigned int rval;
141 int ret;
142
143 ret = regmap_read(tps6586x->regmap, reg, &rval);
144 if (!ret)
145 *val = rval;
146 return ret;
180} 147}
181EXPORT_SYMBOL_GPL(tps6586x_read); 148EXPORT_SYMBOL_GPL(tps6586x_read);
182 149
183int tps6586x_reads(struct device *dev, int reg, int len, uint8_t *val) 150int tps6586x_reads(struct device *dev, int reg, int len, uint8_t *val)
184{ 151{
185 return __tps6586x_reads(to_i2c_client(dev), reg, len, val); 152 struct tps6586x *tps6586x = dev_to_tps6586x(dev);
153
154 return regmap_bulk_read(tps6586x->regmap, reg, val, len);
186} 155}
187EXPORT_SYMBOL_GPL(tps6586x_reads); 156EXPORT_SYMBOL_GPL(tps6586x_reads);
188 157
189int tps6586x_set_bits(struct device *dev, int reg, uint8_t bit_mask) 158int tps6586x_set_bits(struct device *dev, int reg, uint8_t bit_mask)
190{ 159{
191 struct tps6586x *tps6586x = dev_get_drvdata(dev); 160 struct tps6586x *tps6586x = dev_to_tps6586x(dev);
192 uint8_t reg_val;
193 int ret = 0;
194
195 mutex_lock(&tps6586x->lock);
196 161
197 ret = __tps6586x_read(to_i2c_client(dev), reg, &reg_val); 162 return regmap_update_bits(tps6586x->regmap, reg, bit_mask, bit_mask);
198 if (ret)
199 goto out;
200
201 if ((reg_val & bit_mask) != bit_mask) {
202 reg_val |= bit_mask;
203 ret = __tps6586x_write(to_i2c_client(dev), reg, reg_val);
204 }
205out:
206 mutex_unlock(&tps6586x->lock);
207 return ret;
208} 163}
209EXPORT_SYMBOL_GPL(tps6586x_set_bits); 164EXPORT_SYMBOL_GPL(tps6586x_set_bits);
210 165
211int tps6586x_clr_bits(struct device *dev, int reg, uint8_t bit_mask) 166int tps6586x_clr_bits(struct device *dev, int reg, uint8_t bit_mask)
212{ 167{
213 struct tps6586x *tps6586x = dev_get_drvdata(dev); 168 struct tps6586x *tps6586x = dev_to_tps6586x(dev);
214 uint8_t reg_val;
215 int ret = 0;
216
217 mutex_lock(&tps6586x->lock);
218 169
219 ret = __tps6586x_read(to_i2c_client(dev), reg, &reg_val); 170 return regmap_update_bits(tps6586x->regmap, reg, bit_mask, 0);
220 if (ret)
221 goto out;
222
223 if (reg_val & bit_mask) {
224 reg_val &= ~bit_mask;
225 ret = __tps6586x_write(to_i2c_client(dev), reg, reg_val);
226 }
227out:
228 mutex_unlock(&tps6586x->lock);
229 return ret;
230} 171}
231EXPORT_SYMBOL_GPL(tps6586x_clr_bits); 172EXPORT_SYMBOL_GPL(tps6586x_clr_bits);
232 173
233int tps6586x_update(struct device *dev, int reg, uint8_t val, uint8_t mask) 174int tps6586x_update(struct device *dev, int reg, uint8_t val, uint8_t mask)
234{ 175{
235 struct tps6586x *tps6586x = dev_get_drvdata(dev); 176 struct tps6586x *tps6586x = dev_to_tps6586x(dev);
236 uint8_t reg_val;
237 int ret = 0;
238
239 mutex_lock(&tps6586x->lock);
240 177
241 ret = __tps6586x_read(tps6586x->client, reg, &reg_val); 178 return regmap_update_bits(tps6586x->regmap, reg, mask, val);
242 if (ret)
243 goto out;
244
245 if ((reg_val & mask) != val) {
246 reg_val = (reg_val & ~mask) | val;
247 ret = __tps6586x_write(tps6586x->client, reg, reg_val);
248 }
249out:
250 mutex_unlock(&tps6586x->lock);
251 return ret;
252} 179}
253EXPORT_SYMBOL_GPL(tps6586x_update); 180EXPORT_SYMBOL_GPL(tps6586x_update);
254 181
255static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset)
256{
257 struct tps6586x *tps6586x = container_of(gc, struct tps6586x, gpio);
258 uint8_t val;
259 int ret;
260
261 ret = __tps6586x_read(tps6586x->client, TPS6586X_GPIOSET2, &val);
262 if (ret)
263 return ret;
264
265 return !!(val & (1 << offset));
266}
267
268
269static void tps6586x_gpio_set(struct gpio_chip *chip, unsigned offset,
270 int value)
271{
272 struct tps6586x *tps6586x = container_of(chip, struct tps6586x, gpio);
273
274 tps6586x_update(tps6586x->dev, TPS6586X_GPIOSET2,
275 value << offset, 1 << offset);
276}
277
278static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset,
279 int value)
280{
281 struct tps6586x *tps6586x = container_of(gc, struct tps6586x, gpio);
282 uint8_t val, mask;
283
284 tps6586x_gpio_set(gc, offset, value);
285
286 val = 0x1 << (offset * 2);
287 mask = 0x3 << (offset * 2);
288
289 return tps6586x_update(tps6586x->dev, TPS6586X_GPIOSET1, val, mask);
290}
291
292static int tps6586x_gpio_init(struct tps6586x *tps6586x, int gpio_base)
293{
294 if (!gpio_base)
295 return 0;
296
297 tps6586x->gpio.owner = THIS_MODULE;
298 tps6586x->gpio.label = tps6586x->client->name;
299 tps6586x->gpio.dev = tps6586x->dev;
300 tps6586x->gpio.base = gpio_base;
301 tps6586x->gpio.ngpio = 4;
302 tps6586x->gpio.can_sleep = 1;
303
304 /* FIXME: add handling of GPIOs as dedicated inputs */
305 tps6586x->gpio.direction_output = tps6586x_gpio_output;
306 tps6586x->gpio.set = tps6586x_gpio_set;
307 tps6586x->gpio.get = tps6586x_gpio_get;
308
309 return gpiochip_add(&tps6586x->gpio);
310}
311
312static int __remove_subdev(struct device *dev, void *unused) 182static int __remove_subdev(struct device *dev, void *unused)
313{ 183{
314 platform_device_unregister(to_platform_device(dev)); 184 platform_device_unregister(to_platform_device(dev));
@@ -354,12 +224,11 @@ static void tps6586x_irq_sync_unlock(struct irq_data *data)
354 int i; 224 int i;
355 225
356 for (i = 0; i < ARRAY_SIZE(tps6586x->mask_reg); i++) { 226 for (i = 0; i < ARRAY_SIZE(tps6586x->mask_reg); i++) {
357 if (tps6586x->mask_reg[i] != tps6586x->mask_cache[i]) { 227 int ret;
358 if (!WARN_ON(tps6586x_write(tps6586x->dev, 228 ret = tps6586x_write(tps6586x->dev,
359 TPS6586X_INT_MASK1 + i, 229 TPS6586X_INT_MASK1 + i,
360 tps6586x->mask_reg[i]))) 230 tps6586x->mask_reg[i]);
361 tps6586x->mask_cache[i] = tps6586x->mask_reg[i]; 231 WARN_ON(ret);
362 }
363 } 232 }
364 233
365 mutex_unlock(&tps6586x->irq_lock); 234 mutex_unlock(&tps6586x->irq_lock);
@@ -406,7 +275,6 @@ static int __devinit tps6586x_irq_init(struct tps6586x *tps6586x, int irq,
406 275
407 mutex_init(&tps6586x->irq_lock); 276 mutex_init(&tps6586x->irq_lock);
408 for (i = 0; i < 5; i++) { 277 for (i = 0; i < 5; i++) {
409 tps6586x->mask_cache[i] = 0xff;
410 tps6586x->mask_reg[i] = 0xff; 278 tps6586x->mask_reg[i] = 0xff;
411 tps6586x_write(tps6586x->dev, TPS6586X_INT_MASK1 + i, 0xff); 279 tps6586x_write(tps6586x->dev, TPS6586X_INT_MASK1 + i, 0xff);
412 } 280 }
@@ -556,6 +424,23 @@ static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clien
556} 424}
557#endif 425#endif
558 426
427static bool is_volatile_reg(struct device *dev, unsigned int reg)
428{
429 /* Cache all interrupt mask register */
430 if ((reg >= TPS6586X_INT_MASK1) && (reg <= TPS6586X_INT_MASK5))
431 return false;
432
433 return true;
434}
435
436static const struct regmap_config tps6586x_regmap_config = {
437 .reg_bits = 8,
438 .val_bits = 8,
439 .max_register = TPS6586X_MAX_REGISTER - 1,
440 .volatile_reg = is_volatile_reg,
441 .cache_type = REGCACHE_RBTREE,
442};
443
559static int __devinit tps6586x_i2c_probe(struct i2c_client *client, 444static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
560 const struct i2c_device_id *id) 445 const struct i2c_device_id *id)
561{ 446{
@@ -579,29 +464,39 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
579 464
580 dev_info(&client->dev, "VERSIONCRC is %02x\n", ret); 465 dev_info(&client->dev, "VERSIONCRC is %02x\n", ret);
581 466
582 tps6586x = kzalloc(sizeof(struct tps6586x), GFP_KERNEL); 467 tps6586x = devm_kzalloc(&client->dev, sizeof(*tps6586x), GFP_KERNEL);
583 if (tps6586x == NULL) 468 if (tps6586x == NULL) {
469 dev_err(&client->dev, "memory for tps6586x alloc failed\n");
584 return -ENOMEM; 470 return -ENOMEM;
471 }
585 472
586 tps6586x->client = client; 473 tps6586x->client = client;
587 tps6586x->dev = &client->dev; 474 tps6586x->dev = &client->dev;
588 i2c_set_clientdata(client, tps6586x); 475 i2c_set_clientdata(client, tps6586x);
589 476
590 mutex_init(&tps6586x->lock); 477 tps6586x->regmap = devm_regmap_init_i2c(client,
478 &tps6586x_regmap_config);
479 if (IS_ERR(tps6586x->regmap)) {
480 ret = PTR_ERR(tps6586x->regmap);
481 dev_err(&client->dev, "regmap init failed: %d\n", ret);
482 return ret;
483 }
484
591 485
592 if (client->irq) { 486 if (client->irq) {
593 ret = tps6586x_irq_init(tps6586x, client->irq, 487 ret = tps6586x_irq_init(tps6586x, client->irq,
594 pdata->irq_base); 488 pdata->irq_base);
595 if (ret) { 489 if (ret) {
596 dev_err(&client->dev, "IRQ init failed: %d\n", ret); 490 dev_err(&client->dev, "IRQ init failed: %d\n", ret);
597 goto err_irq_init; 491 return ret;
598 } 492 }
599 } 493 }
600 494
601 ret = tps6586x_gpio_init(tps6586x, pdata->gpio_base); 495 ret = mfd_add_devices(tps6586x->dev, -1,
602 if (ret) { 496 tps6586x_cell, ARRAY_SIZE(tps6586x_cell), NULL, 0);
603 dev_err(&client->dev, "GPIO registration failed: %d\n", ret); 497 if (ret < 0) {
604 goto err_gpio_init; 498 dev_err(&client->dev, "mfd_add_devices failed: %d\n", ret);
499 goto err_mfd_add;
605 } 500 }
606 501
607 ret = tps6586x_add_subdevs(tps6586x, pdata); 502 ret = tps6586x_add_subdevs(tps6586x, pdata);
@@ -613,38 +508,21 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
613 return 0; 508 return 0;
614 509
615err_add_devs: 510err_add_devs:
616 if (pdata->gpio_base) { 511 mfd_remove_devices(tps6586x->dev);
617 ret = gpiochip_remove(&tps6586x->gpio); 512err_mfd_add:
618 if (ret)
619 dev_err(&client->dev, "Can't remove gpio chip: %d\n",
620 ret);
621 }
622err_gpio_init:
623 if (client->irq) 513 if (client->irq)
624 free_irq(client->irq, tps6586x); 514 free_irq(client->irq, tps6586x);
625err_irq_init:
626 kfree(tps6586x);
627 return ret; 515 return ret;
628} 516}
629 517
630static int __devexit tps6586x_i2c_remove(struct i2c_client *client) 518static int __devexit tps6586x_i2c_remove(struct i2c_client *client)
631{ 519{
632 struct tps6586x *tps6586x = i2c_get_clientdata(client); 520 struct tps6586x *tps6586x = i2c_get_clientdata(client);
633 struct tps6586x_platform_data *pdata = client->dev.platform_data;
634 int ret;
635 521
522 tps6586x_remove_subdevs(tps6586x);
523 mfd_remove_devices(tps6586x->dev);
636 if (client->irq) 524 if (client->irq)
637 free_irq(client->irq, tps6586x); 525 free_irq(client->irq, tps6586x);
638
639 if (pdata->gpio_base) {
640 ret = gpiochip_remove(&tps6586x->gpio);
641 if (ret)
642 dev_err(&client->dev, "Can't remove gpio chip: %d\n",
643 ret);
644 }
645
646 tps6586x_remove_subdevs(tps6586x);
647 kfree(tps6586x);
648 return 0; 526 return 0;
649} 527}
650 528
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index be9e07b77325..1c563792c777 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -68,6 +68,24 @@ static const struct regmap_config tps65910_regmap_config = {
68 .cache_type = REGCACHE_RBTREE, 68 .cache_type = REGCACHE_RBTREE,
69}; 69};
70 70
71static int __devinit tps65910_ck32k_init(struct tps65910 *tps65910,
72 struct tps65910_board *pmic_pdata)
73{
74 int ret;
75
76 if (!pmic_pdata->en_ck32k_xtal)
77 return 0;
78
79 ret = tps65910_reg_clear_bits(tps65910, TPS65910_DEVCTRL,
80 DEVCTRL_CK32K_CTRL_MASK);
81 if (ret < 0) {
82 dev_err(tps65910->dev, "clear ck32k_ctrl failed: %d\n", ret);
83 return ret;
84 }
85
86 return 0;
87}
88
71static int __devinit tps65910_sleepinit(struct tps65910 *tps65910, 89static int __devinit tps65910_sleepinit(struct tps65910 *tps65910,
72 struct tps65910_board *pmic_pdata) 90 struct tps65910_board *pmic_pdata)
73{ 91{
@@ -175,6 +193,9 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
175 else if (*chip_id == TPS65911) 193 else if (*chip_id == TPS65911)
176 dev_warn(&client->dev, "VMBCH2-Threshold not specified"); 194 dev_warn(&client->dev, "VMBCH2-Threshold not specified");
177 195
196 prop = of_property_read_bool(np, "ti,en-ck32k-xtal");
197 board_info->en_ck32k_xtal = prop;
198
178 board_info->irq = client->irq; 199 board_info->irq = client->irq;
179 board_info->irq_base = -1; 200 board_info->irq_base = -1;
180 201
@@ -243,7 +264,7 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c,
243 init_data->irq_base = pmic_plat_data->irq_base; 264 init_data->irq_base = pmic_plat_data->irq_base;
244 265
245 tps65910_irq_init(tps65910, init_data->irq, init_data); 266 tps65910_irq_init(tps65910, init_data->irq, init_data);
246 267 tps65910_ck32k_init(tps65910, pmic_plat_data);
247 tps65910_sleepinit(tps65910, pmic_plat_data); 268 tps65910_sleepinit(tps65910, pmic_plat_data);
248 269
249 return ret; 270 return ret;
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 6fc90befa79e..b012efd29e01 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -568,7 +568,6 @@ add_numbered_child(unsigned chip, const char *name, int num,
568 goto err; 568 goto err;
569 } 569 }
570 570
571 device_init_wakeup(&pdev->dev, can_wakeup);
572 pdev->dev.parent = &twl->client->dev; 571 pdev->dev.parent = &twl->client->dev;
573 572
574 if (pdata) { 573 if (pdata) {
@@ -593,6 +592,8 @@ add_numbered_child(unsigned chip, const char *name, int num,
593 } 592 }
594 593
595 status = platform_device_add(pdev); 594 status = platform_device_add(pdev);
595 if (status == 0)
596 device_init_wakeup(&pdev->dev, can_wakeup);
596 597
597err: 598err:
598 if (status < 0) { 599 if (status < 0) {
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 4ded9e7aa246..b0fad0ffca56 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -64,19 +64,15 @@ int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
64 int ret; 64 int ret;
65 unsigned int val; 65 unsigned int val;
66 66
67 mutex_lock(&twl6040->io_mutex);
68 /* Vibra control registers from cache */ 67 /* Vibra control registers from cache */
69 if (unlikely(reg == TWL6040_REG_VIBCTLL || 68 if (unlikely(reg == TWL6040_REG_VIBCTLL ||
70 reg == TWL6040_REG_VIBCTLR)) { 69 reg == TWL6040_REG_VIBCTLR)) {
71 val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)]; 70 val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)];
72 } else { 71 } else {
73 ret = regmap_read(twl6040->regmap, reg, &val); 72 ret = regmap_read(twl6040->regmap, reg, &val);
74 if (ret < 0) { 73 if (ret < 0)
75 mutex_unlock(&twl6040->io_mutex);
76 return ret; 74 return ret;
77 }
78 } 75 }
79 mutex_unlock(&twl6040->io_mutex);
80 76
81 return val; 77 return val;
82} 78}
@@ -86,12 +82,10 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val)
86{ 82{
87 int ret; 83 int ret;
88 84
89 mutex_lock(&twl6040->io_mutex);
90 ret = regmap_write(twl6040->regmap, reg, val); 85 ret = regmap_write(twl6040->regmap, reg, val);
91 /* Cache the vibra control registers */ 86 /* Cache the vibra control registers */
92 if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR) 87 if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR)
93 twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val; 88 twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val;
94 mutex_unlock(&twl6040->io_mutex);
95 89
96 return ret; 90 return ret;
97} 91}
@@ -99,23 +93,13 @@ EXPORT_SYMBOL(twl6040_reg_write);
99 93
100int twl6040_set_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask) 94int twl6040_set_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask)
101{ 95{
102 int ret; 96 return regmap_update_bits(twl6040->regmap, reg, mask, mask);
103
104 mutex_lock(&twl6040->io_mutex);
105 ret = regmap_update_bits(twl6040->regmap, reg, mask, mask);
106 mutex_unlock(&twl6040->io_mutex);
107 return ret;
108} 97}
109EXPORT_SYMBOL(twl6040_set_bits); 98EXPORT_SYMBOL(twl6040_set_bits);
110 99
111int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask) 100int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask)
112{ 101{
113 int ret; 102 return regmap_update_bits(twl6040->regmap, reg, mask, 0);
114
115 mutex_lock(&twl6040->io_mutex);
116 ret = regmap_update_bits(twl6040->regmap, reg, mask, 0);
117 mutex_unlock(&twl6040->io_mutex);
118 return ret;
119} 103}
120EXPORT_SYMBOL(twl6040_clear_bits); 104EXPORT_SYMBOL(twl6040_clear_bits);
121 105
@@ -573,7 +557,6 @@ static int __devinit twl6040_probe(struct i2c_client *client,
573 twl6040->irq = client->irq; 557 twl6040->irq = client->irq;
574 558
575 mutex_init(&twl6040->mutex); 559 mutex_init(&twl6040->mutex);
576 mutex_init(&twl6040->io_mutex);
577 init_completion(&twl6040->ready); 560 init_completion(&twl6040->ready);
578 561
579 twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV); 562 twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV);
@@ -696,6 +679,7 @@ static int __devexit twl6040_remove(struct i2c_client *client)
696 679
697static const struct i2c_device_id twl6040_i2c_id[] = { 680static const struct i2c_device_id twl6040_i2c_id[] = {
698 { "twl6040", 0, }, 681 { "twl6040", 0, },
682 { "twl6041", 0, },
699 { }, 683 { },
700}; 684};
701MODULE_DEVICE_TABLE(i2c, twl6040_i2c_id); 685MODULE_DEVICE_TABLE(i2c, twl6040_i2c_id);
diff --git a/drivers/mfd/wm5102-tables.c b/drivers/mfd/wm5102-tables.c
new file mode 100644
index 000000000000..01b9255ed631
--- /dev/null
+++ b/drivers/mfd/wm5102-tables.c
@@ -0,0 +1,2399 @@
1/*
2 * wm5102-tables.c -- WM5102 data tables
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14
15#include <linux/mfd/arizona/core.h>
16#include <linux/mfd/arizona/registers.h>
17
18#include "arizona.h"
19
20#define WM5102_NUM_AOD_ISR 2
21#define WM5102_NUM_ISR 5
22
23static const struct reg_default wm5102_reva_patch[] = {
24 { 0x80, 0x0003 },
25 { 0x221, 0x0090 },
26 { 0x211, 0x0014 },
27 { 0x212, 0x0000 },
28 { 0x214, 0x000C },
29 { 0x171, 0x0002 },
30 { 0x171, 0x0000 },
31 { 0x461, 0x8000 },
32 { 0x463, 0x50F0 },
33 { 0x465, 0x4820 },
34 { 0x467, 0x4040 },
35 { 0x469, 0x3940 },
36 { 0x46B, 0x3310 },
37 { 0x46D, 0x2D80 },
38 { 0x46F, 0x2890 },
39 { 0x471, 0x1990 },
40 { 0x473, 0x1450 },
41 { 0x475, 0x1020 },
42 { 0x477, 0x0CD0 },
43 { 0x479, 0x0A30 },
44 { 0x47B, 0x0810 },
45 { 0x47D, 0x0510 },
46 { 0x500, 0x000D },
47 { 0x507, 0x1820 },
48 { 0x508, 0x1820 },
49 { 0x540, 0x000D },
50 { 0x547, 0x1820 },
51 { 0x548, 0x1820 },
52 { 0x580, 0x000D },
53 { 0x587, 0x1820 },
54 { 0x588, 0x1820 },
55 { 0x101, 0x8140 },
56 { 0x3000, 0x2225 },
57 { 0x3001, 0x3a03 },
58 { 0x3002, 0x0225 },
59 { 0x3003, 0x0801 },
60 { 0x3004, 0x6249 },
61 { 0x3005, 0x0c04 },
62 { 0x3006, 0x0225 },
63 { 0x3007, 0x5901 },
64 { 0x3008, 0xe249 },
65 { 0x3009, 0x030d },
66 { 0x300a, 0x0249 },
67 { 0x300b, 0x2c01 },
68 { 0x300c, 0xe249 },
69 { 0x300d, 0x4342 },
70 { 0x300e, 0xe249 },
71 { 0x300f, 0x73c0 },
72 { 0x3010, 0x4249 },
73 { 0x3011, 0x0c00 },
74 { 0x3012, 0x0225 },
75 { 0x3013, 0x1f01 },
76 { 0x3014, 0x0225 },
77 { 0x3015, 0x1e01 },
78 { 0x3016, 0x0225 },
79 { 0x3017, 0xfa00 },
80 { 0x3018, 0x0000 },
81 { 0x3019, 0xf000 },
82 { 0x301a, 0x0000 },
83 { 0x301b, 0xf000 },
84 { 0x301c, 0x0000 },
85 { 0x301d, 0xf000 },
86 { 0x301e, 0x0000 },
87 { 0x301f, 0xf000 },
88 { 0x3020, 0x0000 },
89 { 0x3021, 0xf000 },
90 { 0x3022, 0x0000 },
91 { 0x3023, 0xf000 },
92 { 0x3024, 0x0000 },
93 { 0x3025, 0xf000 },
94 { 0x3026, 0x0000 },
95 { 0x3027, 0xf000 },
96 { 0x3028, 0x0000 },
97 { 0x3029, 0xf000 },
98 { 0x302a, 0x0000 },
99 { 0x302b, 0xf000 },
100 { 0x302c, 0x0000 },
101 { 0x302d, 0xf000 },
102 { 0x302e, 0x0000 },
103 { 0x302f, 0xf000 },
104 { 0x3030, 0x0225 },
105 { 0x3031, 0x1a01 },
106 { 0x3032, 0x0225 },
107 { 0x3033, 0x1e00 },
108 { 0x3034, 0x0225 },
109 { 0x3035, 0x1f00 },
110 { 0x3036, 0x6225 },
111 { 0x3037, 0xf800 },
112 { 0x3038, 0x0000 },
113 { 0x3039, 0xf000 },
114 { 0x303a, 0x0000 },
115 { 0x303b, 0xf000 },
116 { 0x303c, 0x0000 },
117 { 0x303d, 0xf000 },
118 { 0x303e, 0x0000 },
119 { 0x303f, 0xf000 },
120 { 0x3040, 0x2226 },
121 { 0x3041, 0x3a03 },
122 { 0x3042, 0x0226 },
123 { 0x3043, 0x0801 },
124 { 0x3044, 0x6249 },
125 { 0x3045, 0x0c06 },
126 { 0x3046, 0x0226 },
127 { 0x3047, 0x5901 },
128 { 0x3048, 0xe249 },
129 { 0x3049, 0x030d },
130 { 0x304a, 0x0249 },
131 { 0x304b, 0x2c01 },
132 { 0x304c, 0xe249 },
133 { 0x304d, 0x4342 },
134 { 0x304e, 0xe249 },
135 { 0x304f, 0x73c0 },
136 { 0x3050, 0x4249 },
137 { 0x3051, 0x0c00 },
138 { 0x3052, 0x0226 },
139 { 0x3053, 0x1f01 },
140 { 0x3054, 0x0226 },
141 { 0x3055, 0x1e01 },
142 { 0x3056, 0x0226 },
143 { 0x3057, 0xfa00 },
144 { 0x3058, 0x0000 },
145 { 0x3059, 0xf000 },
146 { 0x305a, 0x0000 },
147 { 0x305b, 0xf000 },
148 { 0x305c, 0x0000 },
149 { 0x305d, 0xf000 },
150 { 0x305e, 0x0000 },
151 { 0x305f, 0xf000 },
152 { 0x3060, 0x0000 },
153 { 0x3061, 0xf000 },
154 { 0x3062, 0x0000 },
155 { 0x3063, 0xf000 },
156 { 0x3064, 0x0000 },
157 { 0x3065, 0xf000 },
158 { 0x3066, 0x0000 },
159 { 0x3067, 0xf000 },
160 { 0x3068, 0x0000 },
161 { 0x3069, 0xf000 },
162 { 0x306a, 0x0000 },
163 { 0x306b, 0xf000 },
164 { 0x306c, 0x0000 },
165 { 0x306d, 0xf000 },
166 { 0x306e, 0x0000 },
167 { 0x306f, 0xf000 },
168 { 0x3070, 0x0226 },
169 { 0x3071, 0x1a01 },
170 { 0x3072, 0x0226 },
171 { 0x3073, 0x1e00 },
172 { 0x3074, 0x0226 },
173 { 0x3075, 0x1f00 },
174 { 0x3076, 0x6226 },
175 { 0x3077, 0xf800 },
176 { 0x3078, 0x0000 },
177 { 0x3079, 0xf000 },
178 { 0x307a, 0x0000 },
179 { 0x307b, 0xf000 },
180 { 0x307c, 0x0000 },
181 { 0x307d, 0xf000 },
182 { 0x307e, 0x0000 },
183 { 0x307f, 0xf000 },
184 { 0x3080, 0x2227 },
185 { 0x3081, 0x3a03 },
186 { 0x3082, 0x0227 },
187 { 0x3083, 0x0801 },
188 { 0x3084, 0x6255 },
189 { 0x3085, 0x0c04 },
190 { 0x3086, 0x0227 },
191 { 0x3087, 0x5901 },
192 { 0x3088, 0xe255 },
193 { 0x3089, 0x030d },
194 { 0x308a, 0x0255 },
195 { 0x308b, 0x2c01 },
196 { 0x308c, 0xe255 },
197 { 0x308d, 0x4342 },
198 { 0x308e, 0xe255 },
199 { 0x308f, 0x73c0 },
200 { 0x3090, 0x4255 },
201 { 0x3091, 0x0c00 },
202 { 0x3092, 0x0227 },
203 { 0x3093, 0x1f01 },
204 { 0x3094, 0x0227 },
205 { 0x3095, 0x1e01 },
206 { 0x3096, 0x0227 },
207 { 0x3097, 0xfa00 },
208 { 0x3098, 0x0000 },
209 { 0x3099, 0xf000 },
210 { 0x309a, 0x0000 },
211 { 0x309b, 0xf000 },
212 { 0x309c, 0x0000 },
213 { 0x309d, 0xf000 },
214 { 0x309e, 0x0000 },
215 { 0x309f, 0xf000 },
216 { 0x30a0, 0x0000 },
217 { 0x30a1, 0xf000 },
218 { 0x30a2, 0x0000 },
219 { 0x30a3, 0xf000 },
220 { 0x30a4, 0x0000 },
221 { 0x30a5, 0xf000 },
222 { 0x30a6, 0x0000 },
223 { 0x30a7, 0xf000 },
224 { 0x30a8, 0x0000 },
225 { 0x30a9, 0xf000 },
226 { 0x30aa, 0x0000 },
227 { 0x30ab, 0xf000 },
228 { 0x30ac, 0x0000 },
229 { 0x30ad, 0xf000 },
230 { 0x30ae, 0x0000 },
231 { 0x30af, 0xf000 },
232 { 0x30b0, 0x0227 },
233 { 0x30b1, 0x1a01 },
234 { 0x30b2, 0x0227 },
235 { 0x30b3, 0x1e00 },
236 { 0x30b4, 0x0227 },
237 { 0x30b5, 0x1f00 },
238 { 0x30b6, 0x6227 },
239 { 0x30b7, 0xf800 },
240 { 0x30b8, 0x0000 },
241 { 0x30b9, 0xf000 },
242 { 0x30ba, 0x0000 },
243 { 0x30bb, 0xf000 },
244 { 0x30bc, 0x0000 },
245 { 0x30bd, 0xf000 },
246 { 0x30be, 0x0000 },
247 { 0x30bf, 0xf000 },
248 { 0x30c0, 0x2228 },
249 { 0x30c1, 0x3a03 },
250 { 0x30c2, 0x0228 },
251 { 0x30c3, 0x0801 },
252 { 0x30c4, 0x6255 },
253 { 0x30c5, 0x0c06 },
254 { 0x30c6, 0x0228 },
255 { 0x30c7, 0x5901 },
256 { 0x30c8, 0xe255 },
257 { 0x30c9, 0x030d },
258 { 0x30ca, 0x0255 },
259 { 0x30cb, 0x2c01 },
260 { 0x30cc, 0xe255 },
261 { 0x30cd, 0x4342 },
262 { 0x30ce, 0xe255 },
263 { 0x30cf, 0x73c0 },
264 { 0x30d0, 0x4255 },
265 { 0x30d1, 0x0c00 },
266 { 0x30d2, 0x0228 },
267 { 0x30d3, 0x1f01 },
268 { 0x30d4, 0x0228 },
269 { 0x30d5, 0x1e01 },
270 { 0x30d6, 0x0228 },
271 { 0x30d7, 0xfa00 },
272 { 0x30d8, 0x0000 },
273 { 0x30d9, 0xf000 },
274 { 0x30da, 0x0000 },
275 { 0x30db, 0xf000 },
276 { 0x30dc, 0x0000 },
277 { 0x30dd, 0xf000 },
278 { 0x30de, 0x0000 },
279 { 0x30df, 0xf000 },
280 { 0x30e0, 0x0000 },
281 { 0x30e1, 0xf000 },
282 { 0x30e2, 0x0000 },
283 { 0x30e3, 0xf000 },
284 { 0x30e4, 0x0000 },
285 { 0x30e5, 0xf000 },
286 { 0x30e6, 0x0000 },
287 { 0x30e7, 0xf000 },
288 { 0x30e8, 0x0000 },
289 { 0x30e9, 0xf000 },
290 { 0x30ea, 0x0000 },
291 { 0x30eb, 0xf000 },
292 { 0x30ec, 0x0000 },
293 { 0x30ed, 0xf000 },
294 { 0x30ee, 0x0000 },
295 { 0x30ef, 0xf000 },
296 { 0x30f0, 0x0228 },
297 { 0x30f1, 0x1a01 },
298 { 0x30f2, 0x0228 },
299 { 0x30f3, 0x1e00 },
300 { 0x30f4, 0x0228 },
301 { 0x30f5, 0x1f00 },
302 { 0x30f6, 0x6228 },
303 { 0x30f7, 0xf800 },
304 { 0x30f8, 0x0000 },
305 { 0x30f9, 0xf000 },
306 { 0x30fa, 0x0000 },
307 { 0x30fb, 0xf000 },
308 { 0x30fc, 0x0000 },
309 { 0x30fd, 0xf000 },
310 { 0x30fe, 0x0000 },
311 { 0x30ff, 0xf000 },
312 { 0x3100, 0x222b },
313 { 0x3101, 0x3a03 },
314 { 0x3102, 0x222b },
315 { 0x3103, 0x5803 },
316 { 0x3104, 0xe26f },
317 { 0x3105, 0x030d },
318 { 0x3106, 0x626f },
319 { 0x3107, 0x2c01 },
320 { 0x3108, 0xe26f },
321 { 0x3109, 0x4342 },
322 { 0x310a, 0xe26f },
323 { 0x310b, 0x73c0 },
324 { 0x310c, 0x026f },
325 { 0x310d, 0x0c00 },
326 { 0x310e, 0x022b },
327 { 0x310f, 0x1f01 },
328 { 0x3110, 0x022b },
329 { 0x3111, 0x1e01 },
330 { 0x3112, 0x022b },
331 { 0x3113, 0xfa00 },
332 { 0x3114, 0x0000 },
333 { 0x3115, 0xf000 },
334 { 0x3116, 0x0000 },
335 { 0x3117, 0xf000 },
336 { 0x3118, 0x0000 },
337 { 0x3119, 0xf000 },
338 { 0x311a, 0x0000 },
339 { 0x311b, 0xf000 },
340 { 0x311c, 0x0000 },
341 { 0x311d, 0xf000 },
342 { 0x311e, 0x0000 },
343 { 0x311f, 0xf000 },
344 { 0x3120, 0x022b },
345 { 0x3121, 0x0a01 },
346 { 0x3122, 0x022b },
347 { 0x3123, 0x1e00 },
348 { 0x3124, 0x022b },
349 { 0x3125, 0x1f00 },
350 { 0x3126, 0x622b },
351 { 0x3127, 0xf800 },
352 { 0x3128, 0x0000 },
353 { 0x3129, 0xf000 },
354 { 0x312a, 0x0000 },
355 { 0x312b, 0xf000 },
356 { 0x312c, 0x0000 },
357 { 0x312d, 0xf000 },
358 { 0x312e, 0x0000 },
359 { 0x312f, 0xf000 },
360 { 0x3130, 0x0000 },
361 { 0x3131, 0xf000 },
362 { 0x3132, 0x0000 },
363 { 0x3133, 0xf000 },
364 { 0x3134, 0x0000 },
365 { 0x3135, 0xf000 },
366 { 0x3136, 0x0000 },
367 { 0x3137, 0xf000 },
368 { 0x3138, 0x0000 },
369 { 0x3139, 0xf000 },
370 { 0x313a, 0x0000 },
371 { 0x313b, 0xf000 },
372 { 0x313c, 0x0000 },
373 { 0x313d, 0xf000 },
374 { 0x313e, 0x0000 },
375 { 0x313f, 0xf000 },
376 { 0x3140, 0x0000 },
377 { 0x3141, 0xf000 },
378 { 0x3142, 0x0000 },
379 { 0x3143, 0xf000 },
380 { 0x3144, 0x0000 },
381 { 0x3145, 0xf000 },
382 { 0x3146, 0x0000 },
383 { 0x3147, 0xf000 },
384 { 0x3148, 0x0000 },
385 { 0x3149, 0xf000 },
386 { 0x314a, 0x0000 },
387 { 0x314b, 0xf000 },
388 { 0x314c, 0x0000 },
389 { 0x314d, 0xf000 },
390 { 0x314e, 0x0000 },
391 { 0x314f, 0xf000 },
392 { 0x3150, 0x0000 },
393 { 0x3151, 0xf000 },
394 { 0x3152, 0x0000 },
395 { 0x3153, 0xf000 },
396 { 0x3154, 0x0000 },
397 { 0x3155, 0xf000 },
398 { 0x3156, 0x0000 },
399 { 0x3157, 0xf000 },
400 { 0x3158, 0x0000 },
401 { 0x3159, 0xf000 },
402 { 0x315a, 0x0000 },
403 { 0x315b, 0xf000 },
404 { 0x315c, 0x0000 },
405 { 0x315d, 0xf000 },
406 { 0x315e, 0x0000 },
407 { 0x315f, 0xf000 },
408 { 0x3160, 0x0000 },
409 { 0x3161, 0xf000 },
410 { 0x3162, 0x0000 },
411 { 0x3163, 0xf000 },
412 { 0x3164, 0x0000 },
413 { 0x3165, 0xf000 },
414 { 0x3166, 0x0000 },
415 { 0x3167, 0xf000 },
416 { 0x3168, 0x0000 },
417 { 0x3169, 0xf000 },
418 { 0x316a, 0x0000 },
419 { 0x316b, 0xf000 },
420 { 0x316c, 0x0000 },
421 { 0x316d, 0xf000 },
422 { 0x316e, 0x0000 },
423 { 0x316f, 0xf000 },
424 { 0x3170, 0x0000 },
425 { 0x3171, 0xf000 },
426 { 0x3172, 0x0000 },
427 { 0x3173, 0xf000 },
428 { 0x3174, 0x0000 },
429 { 0x3175, 0xf000 },
430 { 0x3176, 0x0000 },
431 { 0x3177, 0xf000 },
432 { 0x3178, 0x0000 },
433 { 0x3179, 0xf000 },
434 { 0x317a, 0x0000 },
435 { 0x317b, 0xf000 },
436 { 0x317c, 0x0000 },
437 { 0x317d, 0xf000 },
438 { 0x317e, 0x0000 },
439 { 0x317f, 0xf000 },
440 { 0x3180, 0x2001 },
441 { 0x3181, 0xf101 },
442 { 0x3182, 0x0000 },
443 { 0x3183, 0xf000 },
444 { 0x3184, 0x0000 },
445 { 0x3185, 0xf000 },
446 { 0x3186, 0x0000 },
447 { 0x3187, 0xf000 },
448 { 0x3188, 0x0000 },
449 { 0x3189, 0xf000 },
450 { 0x318a, 0x0000 },
451 { 0x318b, 0xf000 },
452 { 0x318c, 0x0000 },
453 { 0x318d, 0xf000 },
454 { 0x318e, 0x0000 },
455 { 0x318f, 0xf000 },
456 { 0x3190, 0x0000 },
457 { 0x3191, 0xf000 },
458 { 0x3192, 0x0000 },
459 { 0x3193, 0xf000 },
460 { 0x3194, 0x0000 },
461 { 0x3195, 0xf000 },
462 { 0x3196, 0x0000 },
463 { 0x3197, 0xf000 },
464 { 0x3198, 0x0000 },
465 { 0x3199, 0xf000 },
466 { 0x319a, 0x0000 },
467 { 0x319b, 0xf000 },
468 { 0x319c, 0x0000 },
469 { 0x319d, 0xf000 },
470 { 0x319e, 0x0000 },
471 { 0x319f, 0xf000 },
472 { 0x31a0, 0x0000 },
473 { 0x31a1, 0xf000 },
474 { 0x31a2, 0x0000 },
475 { 0x31a3, 0xf000 },
476 { 0x31a4, 0x0000 },
477 { 0x31a5, 0xf000 },
478 { 0x31a6, 0x0000 },
479 { 0x31a7, 0xf000 },
480 { 0x31a8, 0x0000 },
481 { 0x31a9, 0xf000 },
482 { 0x31aa, 0x0000 },
483 { 0x31ab, 0xf000 },
484 { 0x31ac, 0x0000 },
485 { 0x31ad, 0xf000 },
486 { 0x31ae, 0x0000 },
487 { 0x31af, 0xf000 },
488 { 0x31b0, 0x0000 },
489 { 0x31b1, 0xf000 },
490 { 0x31b2, 0x0000 },
491 { 0x31b3, 0xf000 },
492 { 0x31b4, 0x0000 },
493 { 0x31b5, 0xf000 },
494 { 0x31b6, 0x0000 },
495 { 0x31b7, 0xf000 },
496 { 0x31b8, 0x0000 },
497 { 0x31b9, 0xf000 },
498 { 0x31ba, 0x0000 },
499 { 0x31bb, 0xf000 },
500 { 0x31bc, 0x0000 },
501 { 0x31bd, 0xf000 },
502 { 0x31be, 0x0000 },
503 { 0x31bf, 0xf000 },
504 { 0x31c0, 0x0000 },
505 { 0x31c1, 0xf000 },
506 { 0x31c2, 0x0000 },
507 { 0x31c3, 0xf000 },
508 { 0x31c4, 0x0000 },
509 { 0x31c5, 0xf000 },
510 { 0x31c6, 0x0000 },
511 { 0x31c7, 0xf000 },
512 { 0x31c8, 0x0000 },
513 { 0x31c9, 0xf000 },
514 { 0x31ca, 0x0000 },
515 { 0x31cb, 0xf000 },
516 { 0x31cc, 0x0000 },
517 { 0x31cd, 0xf000 },
518 { 0x31ce, 0x0000 },
519 { 0x31cf, 0xf000 },
520 { 0x31d0, 0x0000 },
521 { 0x31d1, 0xf000 },
522 { 0x31d2, 0x0000 },
523 { 0x31d3, 0xf000 },
524 { 0x31d4, 0x0000 },
525 { 0x31d5, 0xf000 },
526 { 0x31d6, 0x0000 },
527 { 0x31d7, 0xf000 },
528 { 0x31d8, 0x0000 },
529 { 0x31d9, 0xf000 },
530 { 0x31da, 0x0000 },
531 { 0x31db, 0xf000 },
532 { 0x31dc, 0x0000 },
533 { 0x31dd, 0xf000 },
534 { 0x31de, 0x0000 },
535 { 0x31df, 0xf000 },
536 { 0x31e0, 0x0000 },
537 { 0x31e1, 0xf000 },
538 { 0x31e2, 0x0000 },
539 { 0x31e3, 0xf000 },
540 { 0x31e4, 0x0000 },
541 { 0x31e5, 0xf000 },
542 { 0x31e6, 0x0000 },
543 { 0x31e7, 0xf000 },
544 { 0x31e8, 0x0000 },
545 { 0x31e9, 0xf000 },
546 { 0x31ea, 0x0000 },
547 { 0x31eb, 0xf000 },
548 { 0x31ec, 0x0000 },
549 { 0x31ed, 0xf000 },
550 { 0x31ee, 0x0000 },
551 { 0x31ef, 0xf000 },
552 { 0x31f0, 0x0000 },
553 { 0x31f1, 0xf000 },
554 { 0x31f2, 0x0000 },
555 { 0x31f3, 0xf000 },
556 { 0x31f4, 0x0000 },
557 { 0x31f5, 0xf000 },
558 { 0x31f6, 0x0000 },
559 { 0x31f7, 0xf000 },
560 { 0x31f8, 0x0000 },
561 { 0x31f9, 0xf000 },
562 { 0x31fa, 0x0000 },
563 { 0x31fb, 0xf000 },
564 { 0x31fc, 0x0000 },
565 { 0x31fd, 0xf000 },
566 { 0x31fe, 0x0000 },
567 { 0x31ff, 0xf000 },
568 { 0x024d, 0xff50 },
569 { 0x0252, 0xff50 },
570 { 0x0259, 0x0112 },
571 { 0x025e, 0x0112 },
572 { 0x101, 0x0304 },
573 { 0x80, 0x0000 },
574};
575
576/* We use a function so we can use ARRAY_SIZE() */
577int wm5102_patch(struct arizona *arizona)
578{
579 switch (arizona->rev) {
580 case 0:
581 return regmap_register_patch(arizona->regmap,
582 wm5102_reva_patch,
583 ARRAY_SIZE(wm5102_reva_patch));
584 default:
585 return 0;
586 }
587}
588
589static const struct regmap_irq wm5102_aod_irqs[ARIZONA_NUM_IRQ] = {
590 [ARIZONA_IRQ_GP5_FALL] = { .mask = ARIZONA_GP5_FALL_EINT1 },
591 [ARIZONA_IRQ_GP5_RISE] = { .mask = ARIZONA_GP5_RISE_EINT1 },
592 [ARIZONA_IRQ_JD_FALL] = { .mask = ARIZONA_JD1_FALL_EINT1 },
593 [ARIZONA_IRQ_JD_RISE] = { .mask = ARIZONA_JD1_RISE_EINT1 },
594};
595
596const struct regmap_irq_chip wm5102_aod = {
597 .name = "wm5102 AOD",
598 .status_base = ARIZONA_AOD_IRQ1,
599 .mask_base = ARIZONA_AOD_IRQ_MASK_IRQ1,
600 .ack_base = ARIZONA_AOD_IRQ1,
601 .wake_base = ARIZONA_WAKE_CONTROL,
602 .num_regs = 1,
603 .irqs = wm5102_aod_irqs,
604 .num_irqs = ARRAY_SIZE(wm5102_aod_irqs),
605};
606
607static const struct regmap_irq wm5102_irqs[ARIZONA_NUM_IRQ] = {
608 [ARIZONA_IRQ_GP4] = { .reg_offset = 0, .mask = ARIZONA_GP4_EINT1 },
609 [ARIZONA_IRQ_GP3] = { .reg_offset = 0, .mask = ARIZONA_GP3_EINT1 },
610 [ARIZONA_IRQ_GP2] = { .reg_offset = 0, .mask = ARIZONA_GP2_EINT1 },
611 [ARIZONA_IRQ_GP1] = { .reg_offset = 0, .mask = ARIZONA_GP1_EINT1 },
612
613 [ARIZONA_IRQ_DSP1_RAM_RDY] = {
614 .reg_offset = 1, .mask = ARIZONA_DSP1_RAM_RDY_EINT1
615 },
616 [ARIZONA_IRQ_DSP_IRQ2] = {
617 .reg_offset = 1, .mask = ARIZONA_DSP_IRQ2_EINT1
618 },
619 [ARIZONA_IRQ_DSP_IRQ1] = {
620 .reg_offset = 1, .mask = ARIZONA_DSP_IRQ1_EINT1
621 },
622
623 [ARIZONA_IRQ_SPK_SHUTDOWN_WARN] = {
624 .reg_offset = 2, .mask = ARIZONA_SPK_SHUTDOWN_WARN_EINT1
625 },
626 [ARIZONA_IRQ_SPK_SHUTDOWN] = {
627 .reg_offset = 2, .mask = ARIZONA_SPK_SHUTDOWN_EINT1
628 },
629 [ARIZONA_IRQ_HPDET] = {
630 .reg_offset = 2, .mask = ARIZONA_HPDET_EINT1
631 },
632 [ARIZONA_IRQ_MICDET] = {
633 .reg_offset = 2, .mask = ARIZONA_MICDET_EINT1
634 },
635 [ARIZONA_IRQ_WSEQ_DONE] = {
636 .reg_offset = 2, .mask = ARIZONA_WSEQ_DONE_EINT1
637 },
638 [ARIZONA_IRQ_DRC2_SIG_DET] = {
639 .reg_offset = 2, .mask = ARIZONA_DRC2_SIG_DET_EINT1
640 },
641 [ARIZONA_IRQ_DRC1_SIG_DET] = {
642 .reg_offset = 2, .mask = ARIZONA_DRC1_SIG_DET_EINT1
643 },
644 [ARIZONA_IRQ_ASRC2_LOCK] = {
645 .reg_offset = 2, .mask = ARIZONA_ASRC2_LOCK_EINT1
646 },
647 [ARIZONA_IRQ_ASRC1_LOCK] = {
648 .reg_offset = 2, .mask = ARIZONA_ASRC1_LOCK_EINT1
649 },
650 [ARIZONA_IRQ_UNDERCLOCKED] = {
651 .reg_offset = 2, .mask = ARIZONA_UNDERCLOCKED_EINT1
652 },
653 [ARIZONA_IRQ_OVERCLOCKED] = {
654 .reg_offset = 2, .mask = ARIZONA_OVERCLOCKED_EINT1
655 },
656 [ARIZONA_IRQ_FLL2_LOCK] = {
657 .reg_offset = 2, .mask = ARIZONA_FLL2_LOCK_EINT1
658 },
659 [ARIZONA_IRQ_FLL1_LOCK] = {
660 .reg_offset = 2, .mask = ARIZONA_FLL1_LOCK_EINT1
661 },
662 [ARIZONA_IRQ_CLKGEN_ERR] = {
663 .reg_offset = 2, .mask = ARIZONA_CLKGEN_ERR_EINT1
664 },
665 [ARIZONA_IRQ_CLKGEN_ERR_ASYNC] = {
666 .reg_offset = 2, .mask = ARIZONA_CLKGEN_ERR_ASYNC_EINT1
667 },
668
669 [ARIZONA_IRQ_ASRC_CFG_ERR] = {
670 .reg_offset = 3, .mask = ARIZONA_ASRC_CFG_ERR_EINT1
671 },
672 [ARIZONA_IRQ_AIF3_ERR] = {
673 .reg_offset = 3, .mask = ARIZONA_AIF3_ERR_EINT1
674 },
675 [ARIZONA_IRQ_AIF2_ERR] = {
676 .reg_offset = 3, .mask = ARIZONA_AIF2_ERR_EINT1
677 },
678 [ARIZONA_IRQ_AIF1_ERR] = {
679 .reg_offset = 3, .mask = ARIZONA_AIF1_ERR_EINT1
680 },
681 [ARIZONA_IRQ_CTRLIF_ERR] = {
682 .reg_offset = 3, .mask = ARIZONA_CTRLIF_ERR_EINT1
683 },
684 [ARIZONA_IRQ_MIXER_DROPPED_SAMPLES] = {
685 .reg_offset = 3, .mask = ARIZONA_MIXER_DROPPED_SAMPLE_EINT1
686 },
687 [ARIZONA_IRQ_ASYNC_CLK_ENA_LOW] = {
688 .reg_offset = 3, .mask = ARIZONA_ASYNC_CLK_ENA_LOW_EINT1
689 },
690 [ARIZONA_IRQ_SYSCLK_ENA_LOW] = {
691 .reg_offset = 3, .mask = ARIZONA_SYSCLK_ENA_LOW_EINT1
692 },
693 [ARIZONA_IRQ_ISRC1_CFG_ERR] = {
694 .reg_offset = 3, .mask = ARIZONA_ISRC1_CFG_ERR_EINT1
695 },
696 [ARIZONA_IRQ_ISRC2_CFG_ERR] = {
697 .reg_offset = 3, .mask = ARIZONA_ISRC2_CFG_ERR_EINT1
698 },
699
700 [ARIZONA_IRQ_BOOT_DONE] = {
701 .reg_offset = 4, .mask = ARIZONA_BOOT_DONE_EINT1
702 },
703 [ARIZONA_IRQ_DCS_DAC_DONE] = {
704 .reg_offset = 4, .mask = ARIZONA_DCS_DAC_DONE_EINT1
705 },
706 [ARIZONA_IRQ_DCS_HP_DONE] = {
707 .reg_offset = 4, .mask = ARIZONA_DCS_HP_DONE_EINT1
708 },
709 [ARIZONA_IRQ_FLL2_CLOCK_OK] = {
710 .reg_offset = 4, .mask = ARIZONA_FLL2_CLOCK_OK_EINT1
711 },
712 [ARIZONA_IRQ_FLL1_CLOCK_OK] = {
713 .reg_offset = 4, .mask = ARIZONA_FLL1_CLOCK_OK_EINT1
714 },
715};
716
717const struct regmap_irq_chip wm5102_irq = {
718 .name = "wm5102 IRQ",
719 .status_base = ARIZONA_INTERRUPT_STATUS_1,
720 .mask_base = ARIZONA_INTERRUPT_STATUS_1_MASK,
721 .ack_base = ARIZONA_INTERRUPT_STATUS_1,
722 .num_regs = 5,
723 .irqs = wm5102_irqs,
724 .num_irqs = ARRAY_SIZE(wm5102_irqs),
725};
726
727static const struct reg_default wm5102_reg_default[] = {
728 { 0x00000008, 0x0019 }, /* R8 - Ctrl IF SPI CFG 1 */
729 { 0x00000009, 0x0001 }, /* R9 - Ctrl IF I2C1 CFG 1 */
730 { 0x0000000D, 0x0000 }, /* R13 - Ctrl IF Status 1 */
731 { 0x00000016, 0x0000 }, /* R22 - Write Sequencer Ctrl 0 */
732 { 0x00000017, 0x0000 }, /* R23 - Write Sequencer Ctrl 1 */
733 { 0x00000018, 0x0000 }, /* R24 - Write Sequencer Ctrl 2 */
734 { 0x0000001A, 0x0000 }, /* R26 - Write Sequencer PROM */
735 { 0x00000020, 0x0000 }, /* R32 - Tone Generator 1 */
736 { 0x00000021, 0x1000 }, /* R33 - Tone Generator 2 */
737 { 0x00000022, 0x0000 }, /* R34 - Tone Generator 3 */
738 { 0x00000023, 0x1000 }, /* R35 - Tone Generator 4 */
739 { 0x00000024, 0x0000 }, /* R36 - Tone Generator 5 */
740 { 0x00000030, 0x0000 }, /* R48 - PWM Drive 1 */
741 { 0x00000031, 0x0100 }, /* R49 - PWM Drive 2 */
742 { 0x00000032, 0x0100 }, /* R50 - PWM Drive 3 */
743 { 0x00000040, 0x0000 }, /* R64 - Wake control */
744 { 0x00000041, 0x0000 }, /* R65 - Sequence control */
745 { 0x00000061, 0x01FF }, /* R97 - Sample Rate Sequence Select 1 */
746 { 0x00000062, 0x01FF }, /* R98 - Sample Rate Sequence Select 2 */
747 { 0x00000063, 0x01FF }, /* R99 - Sample Rate Sequence Select 3 */
748 { 0x00000064, 0x01FF }, /* R100 - Sample Rate Sequence Select 4 */
749 { 0x00000068, 0x01FF }, /* R104 - Always On Triggers Sequence Select 1 */
750 { 0x00000069, 0x01FF }, /* R105 - Always On Triggers Sequence Select 2 */
751 { 0x0000006A, 0x01FF }, /* R106 - Always On Triggers Sequence Select 3 */
752 { 0x0000006B, 0x01FF }, /* R107 - Always On Triggers Sequence Select 4 */
753 { 0x0000006C, 0x01FF }, /* R108 - Always On Triggers Sequence Select 5 */
754 { 0x0000006D, 0x01FF }, /* R109 - Always On Triggers Sequence Select 6 */
755 { 0x00000070, 0x0000 }, /* R112 - Comfort Noise Generator */
756 { 0x00000090, 0x0000 }, /* R144 - Haptics Control 1 */
757 { 0x00000091, 0x7FFF }, /* R145 - Haptics Control 2 */
758 { 0x00000092, 0x0000 }, /* R146 - Haptics phase 1 intensity */
759 { 0x00000093, 0x0000 }, /* R147 - Haptics phase 1 duration */
760 { 0x00000094, 0x0000 }, /* R148 - Haptics phase 2 intensity */
761 { 0x00000095, 0x0000 }, /* R149 - Haptics phase 2 duration */
762 { 0x00000096, 0x0000 }, /* R150 - Haptics phase 3 intensity */
763 { 0x00000097, 0x0000 }, /* R151 - Haptics phase 3 duration */
764 { 0x00000100, 0x0001 }, /* R256 - Clock 32k 1 */
765 { 0x00000101, 0x0304 }, /* R257 - System Clock 1 */
766 { 0x00000102, 0x0011 }, /* R258 - Sample rate 1 */
767 { 0x00000103, 0x0011 }, /* R259 - Sample rate 2 */
768 { 0x00000104, 0x0011 }, /* R260 - Sample rate 3 */
769 { 0x00000112, 0x0305 }, /* R274 - Async clock 1 */
770 { 0x00000113, 0x0011 }, /* R275 - Async sample rate 1 */
771 { 0x00000149, 0x0000 }, /* R329 - Output system clock */
772 { 0x0000014A, 0x0000 }, /* R330 - Output async clock */
773 { 0x00000152, 0x0000 }, /* R338 - Rate Estimator 1 */
774 { 0x00000153, 0x0000 }, /* R339 - Rate Estimator 2 */
775 { 0x00000154, 0x0000 }, /* R340 - Rate Estimator 3 */
776 { 0x00000155, 0x0000 }, /* R341 - Rate Estimator 4 */
777 { 0x00000156, 0x0000 }, /* R342 - Rate Estimator 5 */
778 { 0x00000171, 0x0000 }, /* R369 - FLL1 Control 1 */
779 { 0x00000172, 0x0008 }, /* R370 - FLL1 Control 2 */
780 { 0x00000173, 0x0018 }, /* R371 - FLL1 Control 3 */
781 { 0x00000174, 0x007D }, /* R372 - FLL1 Control 4 */
782 { 0x00000175, 0x0004 }, /* R373 - FLL1 Control 5 */
783 { 0x00000176, 0x0000 }, /* R374 - FLL1 Control 6 */
784 { 0x00000177, 0x0181 }, /* R375 - FLL1 Loop Filter Test 1 */
785 { 0x00000181, 0x0000 }, /* R385 - FLL1 Synchroniser 1 */
786 { 0x00000182, 0x0000 }, /* R386 - FLL1 Synchroniser 2 */
787 { 0x00000183, 0x0000 }, /* R387 - FLL1 Synchroniser 3 */
788 { 0x00000184, 0x0000 }, /* R388 - FLL1 Synchroniser 4 */
789 { 0x00000185, 0x0000 }, /* R389 - FLL1 Synchroniser 5 */
790 { 0x00000186, 0x0000 }, /* R390 - FLL1 Synchroniser 6 */
791 { 0x00000189, 0x0000 }, /* R393 - FLL1 Spread Spectrum */
792 { 0x0000018A, 0x0004 }, /* R394 - FLL1 GPIO Clock */
793 { 0x00000191, 0x0000 }, /* R401 - FLL2 Control 1 */
794 { 0x00000192, 0x0008 }, /* R402 - FLL2 Control 2 */
795 { 0x00000193, 0x0018 }, /* R403 - FLL2 Control 3 */
796 { 0x00000194, 0x007D }, /* R404 - FLL2 Control 4 */
797 { 0x00000195, 0x0004 }, /* R405 - FLL2 Control 5 */
798 { 0x00000196, 0x0000 }, /* R406 - FLL2 Control 6 */
799 { 0x00000197, 0x0000 }, /* R407 - FLL2 Loop Filter Test 1 */
800 { 0x000001A1, 0x0000 }, /* R417 - FLL2 Synchroniser 1 */
801 { 0x000001A2, 0x0000 }, /* R418 - FLL2 Synchroniser 2 */
802 { 0x000001A3, 0x0000 }, /* R419 - FLL2 Synchroniser 3 */
803 { 0x000001A4, 0x0000 }, /* R420 - FLL2 Synchroniser 4 */
804 { 0x000001A5, 0x0000 }, /* R421 - FLL2 Synchroniser 5 */
805 { 0x000001A6, 0x0000 }, /* R422 - FLL2 Synchroniser 6 */
806 { 0x000001A9, 0x0000 }, /* R425 - FLL2 Spread Spectrum */
807 { 0x000001AA, 0x0004 }, /* R426 - FLL2 GPIO Clock */
808 { 0x00000200, 0x0006 }, /* R512 - Mic Charge Pump 1 */
809 { 0x00000210, 0x00D4 }, /* R528 - LDO1 Control 1 */
810 { 0x00000213, 0x0344 }, /* R531 - LDO2 Control 1 */
811 { 0x00000218, 0x01A6 }, /* R536 - Mic Bias Ctrl 1 */
812 { 0x00000219, 0x01A6 }, /* R537 - Mic Bias Ctrl 2 */
813 { 0x0000021A, 0x01A6 }, /* R538 - Mic Bias Ctrl 3 */
814 { 0x00000293, 0x0000 }, /* R659 - Accessory Detect Mode 1 */
815 { 0x0000029B, 0x0020 }, /* R667 - Headphone Detect 1 */
816 { 0x000002A3, 0x1102 }, /* R675 - Mic Detect 1 */
817 { 0x000002A4, 0x009F }, /* R676 - Mic Detect 2 */
818 { 0x000002A5, 0x0000 }, /* R677 - Mic Detect 3 */
819 { 0x000002C3, 0x0000 }, /* R707 - Mic noise mix control 1 */
820 { 0x000002CB, 0x0000 }, /* R715 - Isolation control */
821 { 0x000002D3, 0x0000 }, /* R723 - Jack detect analogue */
822 { 0x00000300, 0x0000 }, /* R768 - Input Enables */
823 { 0x00000308, 0x0000 }, /* R776 - Input Rate */
824 { 0x00000309, 0x0022 }, /* R777 - Input Volume Ramp */
825 { 0x00000310, 0x2080 }, /* R784 - IN1L Control */
826 { 0x00000311, 0x0180 }, /* R785 - ADC Digital Volume 1L */
827 { 0x00000312, 0x0000 }, /* R786 - DMIC1L Control */
828 { 0x00000314, 0x0080 }, /* R788 - IN1R Control */
829 { 0x00000315, 0x0180 }, /* R789 - ADC Digital Volume 1R */
830 { 0x00000316, 0x0000 }, /* R790 - DMIC1R Control */
831 { 0x00000318, 0x2080 }, /* R792 - IN2L Control */
832 { 0x00000319, 0x0180 }, /* R793 - ADC Digital Volume 2L */
833 { 0x0000031A, 0x0000 }, /* R794 - DMIC2L Control */
834 { 0x0000031C, 0x0080 }, /* R796 - IN2R Control */
835 { 0x0000031D, 0x0180 }, /* R797 - ADC Digital Volume 2R */
836 { 0x0000031E, 0x0000 }, /* R798 - DMIC2R Control */
837 { 0x00000320, 0x2080 }, /* R800 - IN3L Control */
838 { 0x00000321, 0x0180 }, /* R801 - ADC Digital Volume 3L */
839 { 0x00000322, 0x0000 }, /* R802 - DMIC3L Control */
840 { 0x00000324, 0x0080 }, /* R804 - IN3R Control */
841 { 0x00000325, 0x0180 }, /* R805 - ADC Digital Volume 3R */
842 { 0x00000326, 0x0000 }, /* R806 - DMIC3R Control */
843 { 0x00000400, 0x0000 }, /* R1024 - Output Enables 1 */
844 { 0x00000408, 0x0000 }, /* R1032 - Output Rate 1 */
845 { 0x00000409, 0x0022 }, /* R1033 - Output Volume Ramp */
846 { 0x00000410, 0x0080 }, /* R1040 - Output Path Config 1L */
847 { 0x00000411, 0x0180 }, /* R1041 - DAC Digital Volume 1L */
848 { 0x00000412, 0x0080 }, /* R1042 - DAC Volume Limit 1L */
849 { 0x00000413, 0x0001 }, /* R1043 - Noise Gate Select 1L */
850 { 0x00000414, 0x0080 }, /* R1044 - Output Path Config 1R */
851 { 0x00000415, 0x0180 }, /* R1045 - DAC Digital Volume 1R */
852 { 0x00000416, 0x0080 }, /* R1046 - DAC Volume Limit 1R */
853 { 0x00000417, 0x0002 }, /* R1047 - Noise Gate Select 1R */
854 { 0x00000418, 0x0080 }, /* R1048 - Output Path Config 2L */
855 { 0x00000419, 0x0180 }, /* R1049 - DAC Digital Volume 2L */
856 { 0x0000041A, 0x0080 }, /* R1050 - DAC Volume Limit 2L */
857 { 0x0000041B, 0x0004 }, /* R1051 - Noise Gate Select 2L */
858 { 0x0000041C, 0x0080 }, /* R1052 - Output Path Config 2R */
859 { 0x0000041D, 0x0180 }, /* R1053 - DAC Digital Volume 2R */
860 { 0x0000041E, 0x0080 }, /* R1054 - DAC Volume Limit 2R */
861 { 0x0000041F, 0x0008 }, /* R1055 - Noise Gate Select 2R */
862 { 0x00000420, 0x0080 }, /* R1056 - Output Path Config 3L */
863 { 0x00000421, 0x0180 }, /* R1057 - DAC Digital Volume 3L */
864 { 0x00000422, 0x0080 }, /* R1058 - DAC Volume Limit 3L */
865 { 0x00000423, 0x0010 }, /* R1059 - Noise Gate Select 3L */
866 { 0x00000424, 0x0080 }, /* R1060 - Output Path Config 3R */
867 { 0x00000425, 0x0180 }, /* R1061 - DAC Digital Volume 3R */
868 { 0x00000426, 0x0080 }, /* R1062 - DAC Volume Limit 3R */
869 { 0x00000428, 0x0000 }, /* R1064 - Output Path Config 4L */
870 { 0x00000429, 0x0180 }, /* R1065 - DAC Digital Volume 4L */
871 { 0x0000042A, 0x0080 }, /* R1066 - Out Volume 4L */
872 { 0x0000042B, 0x0040 }, /* R1067 - Noise Gate Select 4L */
873 { 0x0000042C, 0x0000 }, /* R1068 - Output Path Config 4R */
874 { 0x0000042D, 0x0180 }, /* R1069 - DAC Digital Volume 4R */
875 { 0x0000042E, 0x0080 }, /* R1070 - Out Volume 4R */
876 { 0x0000042F, 0x0080 }, /* R1071 - Noise Gate Select 4R */
877 { 0x00000430, 0x0000 }, /* R1072 - Output Path Config 5L */
878 { 0x00000431, 0x0180 }, /* R1073 - DAC Digital Volume 5L */
879 { 0x00000432, 0x0080 }, /* R1074 - DAC Volume Limit 5L */
880 { 0x00000433, 0x0100 }, /* R1075 - Noise Gate Select 5L */
881 { 0x00000434, 0x0000 }, /* R1076 - Output Path Config 5R */
882 { 0x00000435, 0x0180 }, /* R1077 - DAC Digital Volume 5R */
883 { 0x00000436, 0x0080 }, /* R1078 - DAC Volume Limit 5R */
884 { 0x00000437, 0x0200 }, /* R1079 - Noise Gate Select 5R */
885 { 0x00000450, 0x0000 }, /* R1104 - DAC AEC Control 1 */
886 { 0x00000458, 0x0001 }, /* R1112 - Noise Gate Control */
887 { 0x00000490, 0x0069 }, /* R1168 - PDM SPK1 CTRL 1 */
888 { 0x00000491, 0x0000 }, /* R1169 - PDM SPK1 CTRL 2 */
889 { 0x000004DC, 0x0000 }, /* R1244 - DAC comp 1 */
890 { 0x000004DD, 0x0000 }, /* R1245 - DAC comp 2 */
891 { 0x000004DE, 0x0000 }, /* R1246 - DAC comp 3 */
892 { 0x000004DF, 0x0000 }, /* R1247 - DAC comp 4 */
893 { 0x00000500, 0x000C }, /* R1280 - AIF1 BCLK Ctrl */
894 { 0x00000501, 0x0008 }, /* R1281 - AIF1 Tx Pin Ctrl */
895 { 0x00000502, 0x0000 }, /* R1282 - AIF1 Rx Pin Ctrl */
896 { 0x00000503, 0x0000 }, /* R1283 - AIF1 Rate Ctrl */
897 { 0x00000504, 0x0000 }, /* R1284 - AIF1 Format */
898 { 0x00000505, 0x0040 }, /* R1285 - AIF1 Tx BCLK Rate */
899 { 0x00000506, 0x0040 }, /* R1286 - AIF1 Rx BCLK Rate */
900 { 0x00000507, 0x1818 }, /* R1287 - AIF1 Frame Ctrl 1 */
901 { 0x00000508, 0x1818 }, /* R1288 - AIF1 Frame Ctrl 2 */
902 { 0x00000509, 0x0000 }, /* R1289 - AIF1 Frame Ctrl 3 */
903 { 0x0000050A, 0x0001 }, /* R1290 - AIF1 Frame Ctrl 4 */
904 { 0x0000050B, 0x0002 }, /* R1291 - AIF1 Frame Ctrl 5 */
905 { 0x0000050C, 0x0003 }, /* R1292 - AIF1 Frame Ctrl 6 */
906 { 0x0000050D, 0x0004 }, /* R1293 - AIF1 Frame Ctrl 7 */
907 { 0x0000050E, 0x0005 }, /* R1294 - AIF1 Frame Ctrl 8 */
908 { 0x0000050F, 0x0006 }, /* R1295 - AIF1 Frame Ctrl 9 */
909 { 0x00000510, 0x0007 }, /* R1296 - AIF1 Frame Ctrl 10 */
910 { 0x00000511, 0x0000 }, /* R1297 - AIF1 Frame Ctrl 11 */
911 { 0x00000512, 0x0001 }, /* R1298 - AIF1 Frame Ctrl 12 */
912 { 0x00000513, 0x0002 }, /* R1299 - AIF1 Frame Ctrl 13 */
913 { 0x00000514, 0x0003 }, /* R1300 - AIF1 Frame Ctrl 14 */
914 { 0x00000515, 0x0004 }, /* R1301 - AIF1 Frame Ctrl 15 */
915 { 0x00000516, 0x0005 }, /* R1302 - AIF1 Frame Ctrl 16 */
916 { 0x00000517, 0x0006 }, /* R1303 - AIF1 Frame Ctrl 17 */
917 { 0x00000518, 0x0007 }, /* R1304 - AIF1 Frame Ctrl 18 */
918 { 0x00000519, 0x0000 }, /* R1305 - AIF1 Tx Enables */
919 { 0x0000051A, 0x0000 }, /* R1306 - AIF1 Rx Enables */
920 { 0x0000051B, 0x0000 }, /* R1307 - AIF1 Force Write */
921 { 0x00000540, 0x000C }, /* R1344 - AIF2 BCLK Ctrl */
922 { 0x00000541, 0x0008 }, /* R1345 - AIF2 Tx Pin Ctrl */
923 { 0x00000542, 0x0000 }, /* R1346 - AIF2 Rx Pin Ctrl */
924 { 0x00000543, 0x0000 }, /* R1347 - AIF2 Rate Ctrl */
925 { 0x00000544, 0x0000 }, /* R1348 - AIF2 Format */
926 { 0x00000545, 0x0040 }, /* R1349 - AIF2 Tx BCLK Rate */
927 { 0x00000546, 0x0040 }, /* R1350 - AIF2 Rx BCLK Rate */
928 { 0x00000547, 0x1818 }, /* R1351 - AIF2 Frame Ctrl 1 */
929 { 0x00000548, 0x1818 }, /* R1352 - AIF2 Frame Ctrl 2 */
930 { 0x00000549, 0x0000 }, /* R1353 - AIF2 Frame Ctrl 3 */
931 { 0x0000054A, 0x0001 }, /* R1354 - AIF2 Frame Ctrl 4 */
932 { 0x00000551, 0x0000 }, /* R1361 - AIF2 Frame Ctrl 11 */
933 { 0x00000552, 0x0001 }, /* R1362 - AIF2 Frame Ctrl 12 */
934 { 0x00000559, 0x0000 }, /* R1369 - AIF2 Tx Enables */
935 { 0x0000055A, 0x0000 }, /* R1370 - AIF2 Rx Enables */
936 { 0x0000055B, 0x0000 }, /* R1371 - AIF2 Force Write */
937 { 0x00000580, 0x000C }, /* R1408 - AIF3 BCLK Ctrl */
938 { 0x00000581, 0x0008 }, /* R1409 - AIF3 Tx Pin Ctrl */
939 { 0x00000582, 0x0000 }, /* R1410 - AIF3 Rx Pin Ctrl */
940 { 0x00000583, 0x0000 }, /* R1411 - AIF3 Rate Ctrl */
941 { 0x00000584, 0x0000 }, /* R1412 - AIF3 Format */
942 { 0x00000585, 0x0040 }, /* R1413 - AIF3 Tx BCLK Rate */
943 { 0x00000586, 0x0040 }, /* R1414 - AIF3 Rx BCLK Rate */
944 { 0x00000587, 0x1818 }, /* R1415 - AIF3 Frame Ctrl 1 */
945 { 0x00000588, 0x1818 }, /* R1416 - AIF3 Frame Ctrl 2 */
946 { 0x00000589, 0x0000 }, /* R1417 - AIF3 Frame Ctrl 3 */
947 { 0x0000058A, 0x0001 }, /* R1418 - AIF3 Frame Ctrl 4 */
948 { 0x00000591, 0x0000 }, /* R1425 - AIF3 Frame Ctrl 11 */
949 { 0x00000592, 0x0001 }, /* R1426 - AIF3 Frame Ctrl 12 */
950 { 0x00000599, 0x0000 }, /* R1433 - AIF3 Tx Enables */
951 { 0x0000059A, 0x0000 }, /* R1434 - AIF3 Rx Enables */
952 { 0x0000059B, 0x0000 }, /* R1435 - AIF3 Force Write */
953 { 0x000005E3, 0x0004 }, /* R1507 - SLIMbus Framer Ref Gear */
954 { 0x000005E5, 0x0000 }, /* R1509 - SLIMbus Rates 1 */
955 { 0x000005E6, 0x0000 }, /* R1510 - SLIMbus Rates 2 */
956 { 0x000005E7, 0x0000 }, /* R1511 - SLIMbus Rates 3 */
957 { 0x000005E8, 0x0000 }, /* R1512 - SLIMbus Rates 4 */
958 { 0x000005E9, 0x0000 }, /* R1513 - SLIMbus Rates 5 */
959 { 0x000005EA, 0x0000 }, /* R1514 - SLIMbus Rates 6 */
960 { 0x000005EB, 0x0000 }, /* R1515 - SLIMbus Rates 7 */
961 { 0x000005EC, 0x0000 }, /* R1516 - SLIMbus Rates 8 */
962 { 0x000005F5, 0x0000 }, /* R1525 - SLIMbus RX Channel Enable */
963 { 0x000005F6, 0x0000 }, /* R1526 - SLIMbus TX Channel Enable */
964 { 0x00000640, 0x0000 }, /* R1600 - PWM1MIX Input 1 Source */
965 { 0x00000641, 0x0080 }, /* R1601 - PWM1MIX Input 1 Volume */
966 { 0x00000642, 0x0000 }, /* R1602 - PWM1MIX Input 2 Source */
967 { 0x00000643, 0x0080 }, /* R1603 - PWM1MIX Input 2 Volume */
968 { 0x00000644, 0x0000 }, /* R1604 - PWM1MIX Input 3 Source */
969 { 0x00000645, 0x0080 }, /* R1605 - PWM1MIX Input 3 Volume */
970 { 0x00000646, 0x0000 }, /* R1606 - PWM1MIX Input 4 Source */
971 { 0x00000647, 0x0080 }, /* R1607 - PWM1MIX Input 4 Volume */
972 { 0x00000648, 0x0000 }, /* R1608 - PWM2MIX Input 1 Source */
973 { 0x00000649, 0x0080 }, /* R1609 - PWM2MIX Input 1 Volume */
974 { 0x0000064A, 0x0000 }, /* R1610 - PWM2MIX Input 2 Source */
975 { 0x0000064B, 0x0080 }, /* R1611 - PWM2MIX Input 2 Volume */
976 { 0x0000064C, 0x0000 }, /* R1612 - PWM2MIX Input 3 Source */
977 { 0x0000064D, 0x0080 }, /* R1613 - PWM2MIX Input 3 Volume */
978 { 0x0000064E, 0x0000 }, /* R1614 - PWM2MIX Input 4 Source */
979 { 0x0000064F, 0x0080 }, /* R1615 - PWM2MIX Input 4 Volume */
980 { 0x00000660, 0x0000 }, /* R1632 - MICMIX Input 1 Source */
981 { 0x00000661, 0x0080 }, /* R1633 - MICMIX Input 1 Volume */
982 { 0x00000662, 0x0000 }, /* R1634 - MICMIX Input 2 Source */
983 { 0x00000663, 0x0080 }, /* R1635 - MICMIX Input 2 Volume */
984 { 0x00000664, 0x0000 }, /* R1636 - MICMIX Input 3 Source */
985 { 0x00000665, 0x0080 }, /* R1637 - MICMIX Input 3 Volume */
986 { 0x00000666, 0x0000 }, /* R1638 - MICMIX Input 4 Source */
987 { 0x00000667, 0x0080 }, /* R1639 - MICMIX Input 4 Volume */
988 { 0x00000668, 0x0000 }, /* R1640 - NOISEMIX Input 1 Source */
989 { 0x00000669, 0x0080 }, /* R1641 - NOISEMIX Input 1 Volume */
990 { 0x0000066A, 0x0000 }, /* R1642 - NOISEMIX Input 2 Source */
991 { 0x0000066B, 0x0080 }, /* R1643 - NOISEMIX Input 2 Volume */
992 { 0x0000066C, 0x0000 }, /* R1644 - NOISEMIX Input 3 Source */
993 { 0x0000066D, 0x0080 }, /* R1645 - NOISEMIX Input 3 Volume */
994 { 0x0000066E, 0x0000 }, /* R1646 - NOISEMIX Input 4 Source */
995 { 0x0000066F, 0x0080 }, /* R1647 - NOISEMIX Input 4 Volume */
996 { 0x00000680, 0x0000 }, /* R1664 - OUT1LMIX Input 1 Source */
997 { 0x00000681, 0x0080 }, /* R1665 - OUT1LMIX Input 1 Volume */
998 { 0x00000682, 0x0000 }, /* R1666 - OUT1LMIX Input 2 Source */
999 { 0x00000683, 0x0080 }, /* R1667 - OUT1LMIX Input 2 Volume */
1000 { 0x00000684, 0x0000 }, /* R1668 - OUT1LMIX Input 3 Source */
1001 { 0x00000685, 0x0080 }, /* R1669 - OUT1LMIX Input 3 Volume */
1002 { 0x00000686, 0x0000 }, /* R1670 - OUT1LMIX Input 4 Source */
1003 { 0x00000687, 0x0080 }, /* R1671 - OUT1LMIX Input 4 Volume */
1004 { 0x00000688, 0x0000 }, /* R1672 - OUT1RMIX Input 1 Source */
1005 { 0x00000689, 0x0080 }, /* R1673 - OUT1RMIX Input 1 Volume */
1006 { 0x0000068A, 0x0000 }, /* R1674 - OUT1RMIX Input 2 Source */
1007 { 0x0000068B, 0x0080 }, /* R1675 - OUT1RMIX Input 2 Volume */
1008 { 0x0000068C, 0x0000 }, /* R1676 - OUT1RMIX Input 3 Source */
1009 { 0x0000068D, 0x0080 }, /* R1677 - OUT1RMIX Input 3 Volume */
1010 { 0x0000068E, 0x0000 }, /* R1678 - OUT1RMIX Input 4 Source */
1011 { 0x0000068F, 0x0080 }, /* R1679 - OUT1RMIX Input 4 Volume */
1012 { 0x00000690, 0x0000 }, /* R1680 - OUT2LMIX Input 1 Source */
1013 { 0x00000691, 0x0080 }, /* R1681 - OUT2LMIX Input 1 Volume */
1014 { 0x00000692, 0x0000 }, /* R1682 - OUT2LMIX Input 2 Source */
1015 { 0x00000693, 0x0080 }, /* R1683 - OUT2LMIX Input 2 Volume */
1016 { 0x00000694, 0x0000 }, /* R1684 - OUT2LMIX Input 3 Source */
1017 { 0x00000695, 0x0080 }, /* R1685 - OUT2LMIX Input 3 Volume */
1018 { 0x00000696, 0x0000 }, /* R1686 - OUT2LMIX Input 4 Source */
1019 { 0x00000697, 0x0080 }, /* R1687 - OUT2LMIX Input 4 Volume */
1020 { 0x00000698, 0x0000 }, /* R1688 - OUT2RMIX Input 1 Source */
1021 { 0x00000699, 0x0080 }, /* R1689 - OUT2RMIX Input 1 Volume */
1022 { 0x0000069A, 0x0000 }, /* R1690 - OUT2RMIX Input 2 Source */
1023 { 0x0000069B, 0x0080 }, /* R1691 - OUT2RMIX Input 2 Volume */
1024 { 0x0000069C, 0x0000 }, /* R1692 - OUT2RMIX Input 3 Source */
1025 { 0x0000069D, 0x0080 }, /* R1693 - OUT2RMIX Input 3 Volume */
1026 { 0x0000069E, 0x0000 }, /* R1694 - OUT2RMIX Input 4 Source */
1027 { 0x0000069F, 0x0080 }, /* R1695 - OUT2RMIX Input 4 Volume */
1028 { 0x000006A0, 0x0000 }, /* R1696 - OUT3LMIX Input 1 Source */
1029 { 0x000006A1, 0x0080 }, /* R1697 - OUT3LMIX Input 1 Volume */
1030 { 0x000006A2, 0x0000 }, /* R1698 - OUT3LMIX Input 2 Source */
1031 { 0x000006A3, 0x0080 }, /* R1699 - OUT3LMIX Input 2 Volume */
1032 { 0x000006A4, 0x0000 }, /* R1700 - OUT3LMIX Input 3 Source */
1033 { 0x000006A5, 0x0080 }, /* R1701 - OUT3LMIX Input 3 Volume */
1034 { 0x000006A6, 0x0000 }, /* R1702 - OUT3LMIX Input 4 Source */
1035 { 0x000006A7, 0x0080 }, /* R1703 - OUT3LMIX Input 4 Volume */
1036 { 0x000006B0, 0x0000 }, /* R1712 - OUT4LMIX Input 1 Source */
1037 { 0x000006B1, 0x0080 }, /* R1713 - OUT4LMIX Input 1 Volume */
1038 { 0x000006B2, 0x0000 }, /* R1714 - OUT4LMIX Input 2 Source */
1039 { 0x000006B3, 0x0080 }, /* R1715 - OUT4LMIX Input 2 Volume */
1040 { 0x000006B4, 0x0000 }, /* R1716 - OUT4LMIX Input 3 Source */
1041 { 0x000006B5, 0x0080 }, /* R1717 - OUT4LMIX Input 3 Volume */
1042 { 0x000006B6, 0x0000 }, /* R1718 - OUT4LMIX Input 4 Source */
1043 { 0x000006B7, 0x0080 }, /* R1719 - OUT4LMIX Input 4 Volume */
1044 { 0x000006B8, 0x0000 }, /* R1720 - OUT4RMIX Input 1 Source */
1045 { 0x000006B9, 0x0080 }, /* R1721 - OUT4RMIX Input 1 Volume */
1046 { 0x000006BA, 0x0000 }, /* R1722 - OUT4RMIX Input 2 Source */
1047 { 0x000006BB, 0x0080 }, /* R1723 - OUT4RMIX Input 2 Volume */
1048 { 0x000006BC, 0x0000 }, /* R1724 - OUT4RMIX Input 3 Source */
1049 { 0x000006BD, 0x0080 }, /* R1725 - OUT4RMIX Input 3 Volume */
1050 { 0x000006BE, 0x0000 }, /* R1726 - OUT4RMIX Input 4 Source */
1051 { 0x000006BF, 0x0080 }, /* R1727 - OUT4RMIX Input 4 Volume */
1052 { 0x000006C0, 0x0000 }, /* R1728 - OUT5LMIX Input 1 Source */
1053 { 0x000006C1, 0x0080 }, /* R1729 - OUT5LMIX Input 1 Volume */
1054 { 0x000006C2, 0x0000 }, /* R1730 - OUT5LMIX Input 2 Source */
1055 { 0x000006C3, 0x0080 }, /* R1731 - OUT5LMIX Input 2 Volume */
1056 { 0x000006C4, 0x0000 }, /* R1732 - OUT5LMIX Input 3 Source */
1057 { 0x000006C5, 0x0080 }, /* R1733 - OUT5LMIX Input 3 Volume */
1058 { 0x000006C6, 0x0000 }, /* R1734 - OUT5LMIX Input 4 Source */
1059 { 0x000006C7, 0x0080 }, /* R1735 - OUT5LMIX Input 4 Volume */
1060 { 0x000006C8, 0x0000 }, /* R1736 - OUT5RMIX Input 1 Source */
1061 { 0x000006C9, 0x0080 }, /* R1737 - OUT5RMIX Input 1 Volume */
1062 { 0x000006CA, 0x0000 }, /* R1738 - OUT5RMIX Input 2 Source */
1063 { 0x000006CB, 0x0080 }, /* R1739 - OUT5RMIX Input 2 Volume */
1064 { 0x000006CC, 0x0000 }, /* R1740 - OUT5RMIX Input 3 Source */
1065 { 0x000006CD, 0x0080 }, /* R1741 - OUT5RMIX Input 3 Volume */
1066 { 0x000006CE, 0x0000 }, /* R1742 - OUT5RMIX Input 4 Source */
1067 { 0x000006CF, 0x0080 }, /* R1743 - OUT5RMIX Input 4 Volume */
1068 { 0x00000700, 0x0000 }, /* R1792 - AIF1TX1MIX Input 1 Source */
1069 { 0x00000701, 0x0080 }, /* R1793 - AIF1TX1MIX Input 1 Volume */
1070 { 0x00000702, 0x0000 }, /* R1794 - AIF1TX1MIX Input 2 Source */
1071 { 0x00000703, 0x0080 }, /* R1795 - AIF1TX1MIX Input 2 Volume */
1072 { 0x00000704, 0x0000 }, /* R1796 - AIF1TX1MIX Input 3 Source */
1073 { 0x00000705, 0x0080 }, /* R1797 - AIF1TX1MIX Input 3 Volume */
1074 { 0x00000706, 0x0000 }, /* R1798 - AIF1TX1MIX Input 4 Source */
1075 { 0x00000707, 0x0080 }, /* R1799 - AIF1TX1MIX Input 4 Volume */
1076 { 0x00000708, 0x0000 }, /* R1800 - AIF1TX2MIX Input 1 Source */
1077 { 0x00000709, 0x0080 }, /* R1801 - AIF1TX2MIX Input 1 Volume */
1078 { 0x0000070A, 0x0000 }, /* R1802 - AIF1TX2MIX Input 2 Source */
1079 { 0x0000070B, 0x0080 }, /* R1803 - AIF1TX2MIX Input 2 Volume */
1080 { 0x0000070C, 0x0000 }, /* R1804 - AIF1TX2MIX Input 3 Source */
1081 { 0x0000070D, 0x0080 }, /* R1805 - AIF1TX2MIX Input 3 Volume */
1082 { 0x0000070E, 0x0000 }, /* R1806 - AIF1TX2MIX Input 4 Source */
1083 { 0x0000070F, 0x0080 }, /* R1807 - AIF1TX2MIX Input 4 Volume */
1084 { 0x00000710, 0x0000 }, /* R1808 - AIF1TX3MIX Input 1 Source */
1085 { 0x00000711, 0x0080 }, /* R1809 - AIF1TX3MIX Input 1 Volume */
1086 { 0x00000712, 0x0000 }, /* R1810 - AIF1TX3MIX Input 2 Source */
1087 { 0x00000713, 0x0080 }, /* R1811 - AIF1TX3MIX Input 2 Volume */
1088 { 0x00000714, 0x0000 }, /* R1812 - AIF1TX3MIX Input 3 Source */
1089 { 0x00000715, 0x0080 }, /* R1813 - AIF1TX3MIX Input 3 Volume */
1090 { 0x00000716, 0x0000 }, /* R1814 - AIF1TX3MIX Input 4 Source */
1091 { 0x00000717, 0x0080 }, /* R1815 - AIF1TX3MIX Input 4 Volume */
1092 { 0x00000718, 0x0000 }, /* R1816 - AIF1TX4MIX Input 1 Source */
1093 { 0x00000719, 0x0080 }, /* R1817 - AIF1TX4MIX Input 1 Volume */
1094 { 0x0000071A, 0x0000 }, /* R1818 - AIF1TX4MIX Input 2 Source */
1095 { 0x0000071B, 0x0080 }, /* R1819 - AIF1TX4MIX Input 2 Volume */
1096 { 0x0000071C, 0x0000 }, /* R1820 - AIF1TX4MIX Input 3 Source */
1097 { 0x0000071D, 0x0080 }, /* R1821 - AIF1TX4MIX Input 3 Volume */
1098 { 0x0000071E, 0x0000 }, /* R1822 - AIF1TX4MIX Input 4 Source */
1099 { 0x0000071F, 0x0080 }, /* R1823 - AIF1TX4MIX Input 4 Volume */
1100 { 0x00000720, 0x0000 }, /* R1824 - AIF1TX5MIX Input 1 Source */
1101 { 0x00000721, 0x0080 }, /* R1825 - AIF1TX5MIX Input 1 Volume */
1102 { 0x00000722, 0x0000 }, /* R1826 - AIF1TX5MIX Input 2 Source */
1103 { 0x00000723, 0x0080 }, /* R1827 - AIF1TX5MIX Input 2 Volume */
1104 { 0x00000724, 0x0000 }, /* R1828 - AIF1TX5MIX Input 3 Source */
1105 { 0x00000725, 0x0080 }, /* R1829 - AIF1TX5MIX Input 3 Volume */
1106 { 0x00000726, 0x0000 }, /* R1830 - AIF1TX5MIX Input 4 Source */
1107 { 0x00000727, 0x0080 }, /* R1831 - AIF1TX5MIX Input 4 Volume */
1108 { 0x00000728, 0x0000 }, /* R1832 - AIF1TX6MIX Input 1 Source */
1109 { 0x00000729, 0x0080 }, /* R1833 - AIF1TX6MIX Input 1 Volume */
1110 { 0x0000072A, 0x0000 }, /* R1834 - AIF1TX6MIX Input 2 Source */
1111 { 0x0000072B, 0x0080 }, /* R1835 - AIF1TX6MIX Input 2 Volume */
1112 { 0x0000072C, 0x0000 }, /* R1836 - AIF1TX6MIX Input 3 Source */
1113 { 0x0000072D, 0x0080 }, /* R1837 - AIF1TX6MIX Input 3 Volume */
1114 { 0x0000072E, 0x0000 }, /* R1838 - AIF1TX6MIX Input 4 Source */
1115 { 0x0000072F, 0x0080 }, /* R1839 - AIF1TX6MIX Input 4 Volume */
1116 { 0x00000730, 0x0000 }, /* R1840 - AIF1TX7MIX Input 1 Source */
1117 { 0x00000731, 0x0080 }, /* R1841 - AIF1TX7MIX Input 1 Volume */
1118 { 0x00000732, 0x0000 }, /* R1842 - AIF1TX7MIX Input 2 Source */
1119 { 0x00000733, 0x0080 }, /* R1843 - AIF1TX7MIX Input 2 Volume */
1120 { 0x00000734, 0x0000 }, /* R1844 - AIF1TX7MIX Input 3 Source */
1121 { 0x00000735, 0x0080 }, /* R1845 - AIF1TX7MIX Input 3 Volume */
1122 { 0x00000736, 0x0000 }, /* R1846 - AIF1TX7MIX Input 4 Source */
1123 { 0x00000737, 0x0080 }, /* R1847 - AIF1TX7MIX Input 4 Volume */
1124 { 0x00000738, 0x0000 }, /* R1848 - AIF1TX8MIX Input 1 Source */
1125 { 0x00000739, 0x0080 }, /* R1849 - AIF1TX8MIX Input 1 Volume */
1126 { 0x0000073A, 0x0000 }, /* R1850 - AIF1TX8MIX Input 2 Source */
1127 { 0x0000073B, 0x0080 }, /* R1851 - AIF1TX8MIX Input 2 Volume */
1128 { 0x0000073C, 0x0000 }, /* R1852 - AIF1TX8MIX Input 3 Source */
1129 { 0x0000073D, 0x0080 }, /* R1853 - AIF1TX8MIX Input 3 Volume */
1130 { 0x0000073E, 0x0000 }, /* R1854 - AIF1TX8MIX Input 4 Source */
1131 { 0x0000073F, 0x0080 }, /* R1855 - AIF1TX8MIX Input 4 Volume */
1132 { 0x00000740, 0x0000 }, /* R1856 - AIF2TX1MIX Input 1 Source */
1133 { 0x00000741, 0x0080 }, /* R1857 - AIF2TX1MIX Input 1 Volume */
1134 { 0x00000742, 0x0000 }, /* R1858 - AIF2TX1MIX Input 2 Source */
1135 { 0x00000743, 0x0080 }, /* R1859 - AIF2TX1MIX Input 2 Volume */
1136 { 0x00000744, 0x0000 }, /* R1860 - AIF2TX1MIX Input 3 Source */
1137 { 0x00000745, 0x0080 }, /* R1861 - AIF2TX1MIX Input 3 Volume */
1138 { 0x00000746, 0x0000 }, /* R1862 - AIF2TX1MIX Input 4 Source */
1139 { 0x00000747, 0x0080 }, /* R1863 - AIF2TX1MIX Input 4 Volume */
1140 { 0x00000748, 0x0000 }, /* R1864 - AIF2TX2MIX Input 1 Source */
1141 { 0x00000749, 0x0080 }, /* R1865 - AIF2TX2MIX Input 1 Volume */
1142 { 0x0000074A, 0x0000 }, /* R1866 - AIF2TX2MIX Input 2 Source */
1143 { 0x0000074B, 0x0080 }, /* R1867 - AIF2TX2MIX Input 2 Volume */
1144 { 0x0000074C, 0x0000 }, /* R1868 - AIF2TX2MIX Input 3 Source */
1145 { 0x0000074D, 0x0080 }, /* R1869 - AIF2TX2MIX Input 3 Volume */
1146 { 0x0000074E, 0x0000 }, /* R1870 - AIF2TX2MIX Input 4 Source */
1147 { 0x0000074F, 0x0080 }, /* R1871 - AIF2TX2MIX Input 4 Volume */
1148 { 0x00000780, 0x0000 }, /* R1920 - AIF3TX1MIX Input 1 Source */
1149 { 0x00000781, 0x0080 }, /* R1921 - AIF3TX1MIX Input 1 Volume */
1150 { 0x00000782, 0x0000 }, /* R1922 - AIF3TX1MIX Input 2 Source */
1151 { 0x00000783, 0x0080 }, /* R1923 - AIF3TX1MIX Input 2 Volume */
1152 { 0x00000784, 0x0000 }, /* R1924 - AIF3TX1MIX Input 3 Source */
1153 { 0x00000785, 0x0080 }, /* R1925 - AIF3TX1MIX Input 3 Volume */
1154 { 0x00000786, 0x0000 }, /* R1926 - AIF3TX1MIX Input 4 Source */
1155 { 0x00000787, 0x0080 }, /* R1927 - AIF3TX1MIX Input 4 Volume */
1156 { 0x00000788, 0x0000 }, /* R1928 - AIF3TX2MIX Input 1 Source */
1157 { 0x00000789, 0x0080 }, /* R1929 - AIF3TX2MIX Input 1 Volume */
1158 { 0x0000078A, 0x0000 }, /* R1930 - AIF3TX2MIX Input 2 Source */
1159 { 0x0000078B, 0x0080 }, /* R1931 - AIF3TX2MIX Input 2 Volume */
1160 { 0x0000078C, 0x0000 }, /* R1932 - AIF3TX2MIX Input 3 Source */
1161 { 0x0000078D, 0x0080 }, /* R1933 - AIF3TX2MIX Input 3 Volume */
1162 { 0x0000078E, 0x0000 }, /* R1934 - AIF3TX2MIX Input 4 Source */
1163 { 0x0000078F, 0x0080 }, /* R1935 - AIF3TX2MIX Input 4 Volume */
1164 { 0x000007C0, 0x0000 }, /* R1984 - SLIMTX1MIX Input 1 Source */
1165 { 0x000007C1, 0x0080 }, /* R1985 - SLIMTX1MIX Input 1 Volume */
1166 { 0x000007C2, 0x0000 }, /* R1986 - SLIMTX1MIX Input 2 Source */
1167 { 0x000007C3, 0x0080 }, /* R1987 - SLIMTX1MIX Input 2 Volume */
1168 { 0x000007C4, 0x0000 }, /* R1988 - SLIMTX1MIX Input 3 Source */
1169 { 0x000007C5, 0x0080 }, /* R1989 - SLIMTX1MIX Input 3 Volume */
1170 { 0x000007C6, 0x0000 }, /* R1990 - SLIMTX1MIX Input 4 Source */
1171 { 0x000007C7, 0x0080 }, /* R1991 - SLIMTX1MIX Input 4 Volume */
1172 { 0x000007C8, 0x0000 }, /* R1992 - SLIMTX2MIX Input 1 Source */
1173 { 0x000007C9, 0x0080 }, /* R1993 - SLIMTX2MIX Input 1 Volume */
1174 { 0x000007CA, 0x0000 }, /* R1994 - SLIMTX2MIX Input 2 Source */
1175 { 0x000007CB, 0x0080 }, /* R1995 - SLIMTX2MIX Input 2 Volume */
1176 { 0x000007CC, 0x0000 }, /* R1996 - SLIMTX2MIX Input 3 Source */
1177 { 0x000007CD, 0x0080 }, /* R1997 - SLIMTX2MIX Input 3 Volume */
1178 { 0x000007CE, 0x0000 }, /* R1998 - SLIMTX2MIX Input 4 Source */
1179 { 0x000007CF, 0x0080 }, /* R1999 - SLIMTX2MIX Input 4 Volume */
1180 { 0x000007D0, 0x0000 }, /* R2000 - SLIMTX3MIX Input 1 Source */
1181 { 0x000007D1, 0x0080 }, /* R2001 - SLIMTX3MIX Input 1 Volume */
1182 { 0x000007D2, 0x0000 }, /* R2002 - SLIMTX3MIX Input 2 Source */
1183 { 0x000007D3, 0x0080 }, /* R2003 - SLIMTX3MIX Input 2 Volume */
1184 { 0x000007D4, 0x0000 }, /* R2004 - SLIMTX3MIX Input 3 Source */
1185 { 0x000007D5, 0x0080 }, /* R2005 - SLIMTX3MIX Input 3 Volume */
1186 { 0x000007D6, 0x0000 }, /* R2006 - SLIMTX3MIX Input 4 Source */
1187 { 0x000007D7, 0x0080 }, /* R2007 - SLIMTX3MIX Input 4 Volume */
1188 { 0x000007D8, 0x0000 }, /* R2008 - SLIMTX4MIX Input 1 Source */
1189 { 0x000007D9, 0x0080 }, /* R2009 - SLIMTX4MIX Input 1 Volume */
1190 { 0x000007DA, 0x0000 }, /* R2010 - SLIMTX4MIX Input 2 Source */
1191 { 0x000007DB, 0x0080 }, /* R2011 - SLIMTX4MIX Input 2 Volume */
1192 { 0x000007DC, 0x0000 }, /* R2012 - SLIMTX4MIX Input 3 Source */
1193 { 0x000007DD, 0x0080 }, /* R2013 - SLIMTX4MIX Input 3 Volume */
1194 { 0x000007DE, 0x0000 }, /* R2014 - SLIMTX4MIX Input 4 Source */
1195 { 0x000007DF, 0x0080 }, /* R2015 - SLIMTX4MIX Input 4 Volume */
1196 { 0x000007E0, 0x0000 }, /* R2016 - SLIMTX5MIX Input 1 Source */
1197 { 0x000007E1, 0x0080 }, /* R2017 - SLIMTX5MIX Input 1 Volume */
1198 { 0x000007E2, 0x0000 }, /* R2018 - SLIMTX5MIX Input 2 Source */
1199 { 0x000007E3, 0x0080 }, /* R2019 - SLIMTX5MIX Input 2 Volume */
1200 { 0x000007E4, 0x0000 }, /* R2020 - SLIMTX5MIX Input 3 Source */
1201 { 0x000007E5, 0x0080 }, /* R2021 - SLIMTX5MIX Input 3 Volume */
1202 { 0x000007E6, 0x0000 }, /* R2022 - SLIMTX5MIX Input 4 Source */
1203 { 0x000007E7, 0x0080 }, /* R2023 - SLIMTX5MIX Input 4 Volume */
1204 { 0x000007E8, 0x0000 }, /* R2024 - SLIMTX6MIX Input 1 Source */
1205 { 0x000007E9, 0x0080 }, /* R2025 - SLIMTX6MIX Input 1 Volume */
1206 { 0x000007EA, 0x0000 }, /* R2026 - SLIMTX6MIX Input 2 Source */
1207 { 0x000007EB, 0x0080 }, /* R2027 - SLIMTX6MIX Input 2 Volume */
1208 { 0x000007EC, 0x0000 }, /* R2028 - SLIMTX6MIX Input 3 Source */
1209 { 0x000007ED, 0x0080 }, /* R2029 - SLIMTX6MIX Input 3 Volume */
1210 { 0x000007EE, 0x0000 }, /* R2030 - SLIMTX6MIX Input 4 Source */
1211 { 0x000007EF, 0x0080 }, /* R2031 - SLIMTX6MIX Input 4 Volume */
1212 { 0x000007F0, 0x0000 }, /* R2032 - SLIMTX7MIX Input 1 Source */
1213 { 0x000007F1, 0x0080 }, /* R2033 - SLIMTX7MIX Input 1 Volume */
1214 { 0x000007F2, 0x0000 }, /* R2034 - SLIMTX7MIX Input 2 Source */
1215 { 0x000007F3, 0x0080 }, /* R2035 - SLIMTX7MIX Input 2 Volume */
1216 { 0x000007F4, 0x0000 }, /* R2036 - SLIMTX7MIX Input 3 Source */
1217 { 0x000007F5, 0x0080 }, /* R2037 - SLIMTX7MIX Input 3 Volume */
1218 { 0x000007F6, 0x0000 }, /* R2038 - SLIMTX7MIX Input 4 Source */
1219 { 0x000007F7, 0x0080 }, /* R2039 - SLIMTX7MIX Input 4 Volume */
1220 { 0x000007F8, 0x0000 }, /* R2040 - SLIMTX8MIX Input 1 Source */
1221 { 0x000007F9, 0x0080 }, /* R2041 - SLIMTX8MIX Input 1 Volume */
1222 { 0x000007FA, 0x0000 }, /* R2042 - SLIMTX8MIX Input 2 Source */
1223 { 0x000007FB, 0x0080 }, /* R2043 - SLIMTX8MIX Input 2 Volume */
1224 { 0x000007FC, 0x0000 }, /* R2044 - SLIMTX8MIX Input 3 Source */
1225 { 0x000007FD, 0x0080 }, /* R2045 - SLIMTX8MIX Input 3 Volume */
1226 { 0x000007FE, 0x0000 }, /* R2046 - SLIMTX8MIX Input 4 Source */
1227 { 0x000007FF, 0x0080 }, /* R2047 - SLIMTX8MIX Input 4 Volume */
1228 { 0x00000880, 0x0000 }, /* R2176 - EQ1MIX Input 1 Source */
1229 { 0x00000881, 0x0080 }, /* R2177 - EQ1MIX Input 1 Volume */
1230 { 0x00000882, 0x0000 }, /* R2178 - EQ1MIX Input 2 Source */
1231 { 0x00000883, 0x0080 }, /* R2179 - EQ1MIX Input 2 Volume */
1232 { 0x00000884, 0x0000 }, /* R2180 - EQ1MIX Input 3 Source */
1233 { 0x00000885, 0x0080 }, /* R2181 - EQ1MIX Input 3 Volume */
1234 { 0x00000886, 0x0000 }, /* R2182 - EQ1MIX Input 4 Source */
1235 { 0x00000887, 0x0080 }, /* R2183 - EQ1MIX Input 4 Volume */
1236 { 0x00000888, 0x0000 }, /* R2184 - EQ2MIX Input 1 Source */
1237 { 0x00000889, 0x0080 }, /* R2185 - EQ2MIX Input 1 Volume */
1238 { 0x0000088A, 0x0000 }, /* R2186 - EQ2MIX Input 2 Source */
1239 { 0x0000088B, 0x0080 }, /* R2187 - EQ2MIX Input 2 Volume */
1240 { 0x0000088C, 0x0000 }, /* R2188 - EQ2MIX Input 3 Source */
1241 { 0x0000088D, 0x0080 }, /* R2189 - EQ2MIX Input 3 Volume */
1242 { 0x0000088E, 0x0000 }, /* R2190 - EQ2MIX Input 4 Source */
1243 { 0x0000088F, 0x0080 }, /* R2191 - EQ2MIX Input 4 Volume */
1244 { 0x00000890, 0x0000 }, /* R2192 - EQ3MIX Input 1 Source */
1245 { 0x00000891, 0x0080 }, /* R2193 - EQ3MIX Input 1 Volume */
1246 { 0x00000892, 0x0000 }, /* R2194 - EQ3MIX Input 2 Source */
1247 { 0x00000893, 0x0080 }, /* R2195 - EQ3MIX Input 2 Volume */
1248 { 0x00000894, 0x0000 }, /* R2196 - EQ3MIX Input 3 Source */
1249 { 0x00000895, 0x0080 }, /* R2197 - EQ3MIX Input 3 Volume */
1250 { 0x00000896, 0x0000 }, /* R2198 - EQ3MIX Input 4 Source */
1251 { 0x00000897, 0x0080 }, /* R2199 - EQ3MIX Input 4 Volume */
1252 { 0x00000898, 0x0000 }, /* R2200 - EQ4MIX Input 1 Source */
1253 { 0x00000899, 0x0080 }, /* R2201 - EQ4MIX Input 1 Volume */
1254 { 0x0000089A, 0x0000 }, /* R2202 - EQ4MIX Input 2 Source */
1255 { 0x0000089B, 0x0080 }, /* R2203 - EQ4MIX Input 2 Volume */
1256 { 0x0000089C, 0x0000 }, /* R2204 - EQ4MIX Input 3 Source */
1257 { 0x0000089D, 0x0080 }, /* R2205 - EQ4MIX Input 3 Volume */
1258 { 0x0000089E, 0x0000 }, /* R2206 - EQ4MIX Input 4 Source */
1259 { 0x0000089F, 0x0080 }, /* R2207 - EQ4MIX Input 4 Volume */
1260 { 0x000008C0, 0x0000 }, /* R2240 - DRC1LMIX Input 1 Source */
1261 { 0x000008C1, 0x0080 }, /* R2241 - DRC1LMIX Input 1 Volume */
1262 { 0x000008C2, 0x0000 }, /* R2242 - DRC1LMIX Input 2 Source */
1263 { 0x000008C3, 0x0080 }, /* R2243 - DRC1LMIX Input 2 Volume */
1264 { 0x000008C4, 0x0000 }, /* R2244 - DRC1LMIX Input 3 Source */
1265 { 0x000008C5, 0x0080 }, /* R2245 - DRC1LMIX Input 3 Volume */
1266 { 0x000008C6, 0x0000 }, /* R2246 - DRC1LMIX Input 4 Source */
1267 { 0x000008C7, 0x0080 }, /* R2247 - DRC1LMIX Input 4 Volume */
1268 { 0x000008C8, 0x0000 }, /* R2248 - DRC1RMIX Input 1 Source */
1269 { 0x000008C9, 0x0080 }, /* R2249 - DRC1RMIX Input 1 Volume */
1270 { 0x000008CA, 0x0000 }, /* R2250 - DRC1RMIX Input 2 Source */
1271 { 0x000008CB, 0x0080 }, /* R2251 - DRC1RMIX Input 2 Volume */
1272 { 0x000008CC, 0x0000 }, /* R2252 - DRC1RMIX Input 3 Source */
1273 { 0x000008CD, 0x0080 }, /* R2253 - DRC1RMIX Input 3 Volume */
1274 { 0x000008CE, 0x0000 }, /* R2254 - DRC1RMIX Input 4 Source */
1275 { 0x000008CF, 0x0080 }, /* R2255 - DRC1RMIX Input 4 Volume */
1276 { 0x000008D0, 0x0000 }, /* R2256 - DRC2LMIX Input 1 Source */
1277 { 0x000008D1, 0x0080 }, /* R2257 - DRC2LMIX Input 1 Volume */
1278 { 0x000008D2, 0x0000 }, /* R2258 - DRC2LMIX Input 2 Source */
1279 { 0x000008D3, 0x0080 }, /* R2259 - DRC2LMIX Input 2 Volume */
1280 { 0x000008D4, 0x0000 }, /* R2260 - DRC2LMIX Input 3 Source */
1281 { 0x000008D5, 0x0080 }, /* R2261 - DRC2LMIX Input 3 Volume */
1282 { 0x000008D6, 0x0000 }, /* R2262 - DRC2LMIX Input 4 Source */
1283 { 0x000008D7, 0x0080 }, /* R2263 - DRC2LMIX Input 4 Volume */
1284 { 0x000008D8, 0x0000 }, /* R2264 - DRC2RMIX Input 1 Source */
1285 { 0x000008D9, 0x0080 }, /* R2265 - DRC2RMIX Input 1 Volume */
1286 { 0x000008DA, 0x0000 }, /* R2266 - DRC2RMIX Input 2 Source */
1287 { 0x000008DB, 0x0080 }, /* R2267 - DRC2RMIX Input 2 Volume */
1288 { 0x000008DC, 0x0000 }, /* R2268 - DRC2RMIX Input 3 Source */
1289 { 0x000008DD, 0x0080 }, /* R2269 - DRC2RMIX Input 3 Volume */
1290 { 0x000008DE, 0x0000 }, /* R2270 - DRC2RMIX Input 4 Source */
1291 { 0x000008DF, 0x0080 }, /* R2271 - DRC2RMIX Input 4 Volume */
1292 { 0x00000900, 0x0000 }, /* R2304 - HPLP1MIX Input 1 Source */
1293 { 0x00000901, 0x0080 }, /* R2305 - HPLP1MIX Input 1 Volume */
1294 { 0x00000902, 0x0000 }, /* R2306 - HPLP1MIX Input 2 Source */
1295 { 0x00000903, 0x0080 }, /* R2307 - HPLP1MIX Input 2 Volume */
1296 { 0x00000904, 0x0000 }, /* R2308 - HPLP1MIX Input 3 Source */
1297 { 0x00000905, 0x0080 }, /* R2309 - HPLP1MIX Input 3 Volume */
1298 { 0x00000906, 0x0000 }, /* R2310 - HPLP1MIX Input 4 Source */
1299 { 0x00000907, 0x0080 }, /* R2311 - HPLP1MIX Input 4 Volume */
1300 { 0x00000908, 0x0000 }, /* R2312 - HPLP2MIX Input 1 Source */
1301 { 0x00000909, 0x0080 }, /* R2313 - HPLP2MIX Input 1 Volume */
1302 { 0x0000090A, 0x0000 }, /* R2314 - HPLP2MIX Input 2 Source */
1303 { 0x0000090B, 0x0080 }, /* R2315 - HPLP2MIX Input 2 Volume */
1304 { 0x0000090C, 0x0000 }, /* R2316 - HPLP2MIX Input 3 Source */
1305 { 0x0000090D, 0x0080 }, /* R2317 - HPLP2MIX Input 3 Volume */
1306 { 0x0000090E, 0x0000 }, /* R2318 - HPLP2MIX Input 4 Source */
1307 { 0x0000090F, 0x0080 }, /* R2319 - HPLP2MIX Input 4 Volume */
1308 { 0x00000910, 0x0000 }, /* R2320 - HPLP3MIX Input 1 Source */
1309 { 0x00000911, 0x0080 }, /* R2321 - HPLP3MIX Input 1 Volume */
1310 { 0x00000912, 0x0000 }, /* R2322 - HPLP3MIX Input 2 Source */
1311 { 0x00000913, 0x0080 }, /* R2323 - HPLP3MIX Input 2 Volume */
1312 { 0x00000914, 0x0000 }, /* R2324 - HPLP3MIX Input 3 Source */
1313 { 0x00000915, 0x0080 }, /* R2325 - HPLP3MIX Input 3 Volume */
1314 { 0x00000916, 0x0000 }, /* R2326 - HPLP3MIX Input 4 Source */
1315 { 0x00000917, 0x0080 }, /* R2327 - HPLP3MIX Input 4 Volume */
1316 { 0x00000918, 0x0000 }, /* R2328 - HPLP4MIX Input 1 Source */
1317 { 0x00000919, 0x0080 }, /* R2329 - HPLP4MIX Input 1 Volume */
1318 { 0x0000091A, 0x0000 }, /* R2330 - HPLP4MIX Input 2 Source */
1319 { 0x0000091B, 0x0080 }, /* R2331 - HPLP4MIX Input 2 Volume */
1320 { 0x0000091C, 0x0000 }, /* R2332 - HPLP4MIX Input 3 Source */
1321 { 0x0000091D, 0x0080 }, /* R2333 - HPLP4MIX Input 3 Volume */
1322 { 0x0000091E, 0x0000 }, /* R2334 - HPLP4MIX Input 4 Source */
1323 { 0x0000091F, 0x0080 }, /* R2335 - HPLP4MIX Input 4 Volume */
1324 { 0x00000940, 0x0000 }, /* R2368 - DSP1LMIX Input 1 Source */
1325 { 0x00000941, 0x0080 }, /* R2369 - DSP1LMIX Input 1 Volume */
1326 { 0x00000942, 0x0000 }, /* R2370 - DSP1LMIX Input 2 Source */
1327 { 0x00000943, 0x0080 }, /* R2371 - DSP1LMIX Input 2 Volume */
1328 { 0x00000944, 0x0000 }, /* R2372 - DSP1LMIX Input 3 Source */
1329 { 0x00000945, 0x0080 }, /* R2373 - DSP1LMIX Input 3 Volume */
1330 { 0x00000946, 0x0000 }, /* R2374 - DSP1LMIX Input 4 Source */
1331 { 0x00000947, 0x0080 }, /* R2375 - DSP1LMIX Input 4 Volume */
1332 { 0x00000948, 0x0000 }, /* R2376 - DSP1RMIX Input 1 Source */
1333 { 0x00000949, 0x0080 }, /* R2377 - DSP1RMIX Input 1 Volume */
1334 { 0x0000094A, 0x0000 }, /* R2378 - DSP1RMIX Input 2 Source */
1335 { 0x0000094B, 0x0080 }, /* R2379 - DSP1RMIX Input 2 Volume */
1336 { 0x0000094C, 0x0000 }, /* R2380 - DSP1RMIX Input 3 Source */
1337 { 0x0000094D, 0x0080 }, /* R2381 - DSP1RMIX Input 3 Volume */
1338 { 0x0000094E, 0x0000 }, /* R2382 - DSP1RMIX Input 4 Source */
1339 { 0x0000094F, 0x0080 }, /* R2383 - DSP1RMIX Input 4 Volume */
1340 { 0x00000950, 0x0000 }, /* R2384 - DSP1AUX1MIX Input 1 Source */
1341 { 0x00000958, 0x0000 }, /* R2392 - DSP1AUX2MIX Input 1 Source */
1342 { 0x00000960, 0x0000 }, /* R2400 - DSP1AUX3MIX Input 1 Source */
1343 { 0x00000968, 0x0000 }, /* R2408 - DSP1AUX4MIX Input 1 Source */
1344 { 0x00000970, 0x0000 }, /* R2416 - DSP1AUX5MIX Input 1 Source */
1345 { 0x00000978, 0x0000 }, /* R2424 - DSP1AUX6MIX Input 1 Source */
1346 { 0x00000A80, 0x0000 }, /* R2688 - ASRC1LMIX Input 1 Source */
1347 { 0x00000A88, 0x0000 }, /* R2696 - ASRC1RMIX Input 1 Source */
1348 { 0x00000A90, 0x0000 }, /* R2704 - ASRC2LMIX Input 1 Source */
1349 { 0x00000A98, 0x0000 }, /* R2712 - ASRC2RMIX Input 1 Source */
1350 { 0x00000B00, 0x0000 }, /* R2816 - ISRC1DEC1MIX Input 1 Source */
1351 { 0x00000B08, 0x0000 }, /* R2824 - ISRC1DEC2MIX Input 1 Source */
1352 { 0x00000B20, 0x0000 }, /* R2848 - ISRC1INT1MIX Input 1 Source */
1353 { 0x00000B28, 0x0000 }, /* R2856 - ISRC1INT2MIX Input 1 Source */
1354 { 0x00000B40, 0x0000 }, /* R2880 - ISRC2DEC1MIX Input 1 Source */
1355 { 0x00000B48, 0x0000 }, /* R2888 - ISRC2DEC2MIX Input 1 Source */
1356 { 0x00000B60, 0x0000 }, /* R2912 - ISRC2INT1MIX Input 1 Source */
1357 { 0x00000B68, 0x0000 }, /* R2920 - ISRC2INT2MIX Input 1 Source */
1358 { 0x00000C00, 0xA101 }, /* R3072 - GPIO1 CTRL */
1359 { 0x00000C01, 0xA101 }, /* R3073 - GPIO2 CTRL */
1360 { 0x00000C02, 0xA101 }, /* R3074 - GPIO3 CTRL */
1361 { 0x00000C03, 0xA101 }, /* R3075 - GPIO4 CTRL */
1362 { 0x00000C04, 0xA101 }, /* R3076 - GPIO5 CTRL */
1363 { 0x00000C0F, 0x0400 }, /* R3087 - IRQ CTRL 1 */
1364 { 0x00000C10, 0x1000 }, /* R3088 - GPIO Debounce Config */
1365 { 0x00000C20, 0x8002 }, /* R3104 - Misc Pad Ctrl 1 */
1366 { 0x00000C21, 0x8001 }, /* R3105 - Misc Pad Ctrl 2 */
1367 { 0x00000C22, 0x0000 }, /* R3106 - Misc Pad Ctrl 3 */
1368 { 0x00000C23, 0x0000 }, /* R3107 - Misc Pad Ctrl 4 */
1369 { 0x00000C24, 0x0000 }, /* R3108 - Misc Pad Ctrl 5 */
1370 { 0x00000C25, 0x0000 }, /* R3109 - Misc Pad Ctrl 6 */
1371 { 0x00000D08, 0xFFFF }, /* R3336 - Interrupt Status 1 Mask */
1372 { 0x00000D09, 0xFFFF }, /* R3337 - Interrupt Status 2 Mask */
1373 { 0x00000D0A, 0xFFFF }, /* R3338 - Interrupt Status 3 Mask */
1374 { 0x00000D0B, 0xFFFF }, /* R3339 - Interrupt Status 4 Mask */
1375 { 0x00000D0C, 0xFEFF }, /* R3340 - Interrupt Status 5 Mask */
1376 { 0x00000D0F, 0x0000 }, /* R3343 - Interrupt Control */
1377 { 0x00000D18, 0xFFFF }, /* R3352 - IRQ2 Status 1 Mask */
1378 { 0x00000D19, 0xFFFF }, /* R3353 - IRQ2 Status 2 Mask */
1379 { 0x00000D1A, 0xFFFF }, /* R3354 - IRQ2 Status 3 Mask */
1380 { 0x00000D1B, 0xFFFF }, /* R3355 - IRQ2 Status 4 Mask */
1381 { 0x00000D1C, 0xFFFF }, /* R3356 - IRQ2 Status 5 Mask */
1382 { 0x00000D1F, 0x0000 }, /* R3359 - IRQ2 Control */
1383 { 0x00000D41, 0x0000 }, /* R3393 - ADSP2 IRQ0 */
1384 { 0x00000D53, 0xFFFF }, /* R3411 - AOD IRQ Mask IRQ1 */
1385 { 0x00000D54, 0xFFFF }, /* R3412 - AOD IRQ Mask IRQ2 */
1386 { 0x00000D56, 0x0000 }, /* R3414 - Jack detect debounce */
1387 { 0x00000E00, 0x0000 }, /* R3584 - FX_Ctrl1 */
1388 { 0x00000E01, 0x0000 }, /* R3585 - FX_Ctrl2 */
1389 { 0x00000E10, 0x6318 }, /* R3600 - EQ1_1 */
1390 { 0x00000E11, 0x6300 }, /* R3601 - EQ1_2 */
1391 { 0x00000E12, 0x0FC8 }, /* R3602 - EQ1_3 */
1392 { 0x00000E13, 0x03FE }, /* R3603 - EQ1_4 */
1393 { 0x00000E14, 0x00E0 }, /* R3604 - EQ1_5 */
1394 { 0x00000E15, 0x1EC4 }, /* R3605 - EQ1_6 */
1395 { 0x00000E16, 0xF136 }, /* R3606 - EQ1_7 */
1396 { 0x00000E17, 0x0409 }, /* R3607 - EQ1_8 */
1397 { 0x00000E18, 0x04CC }, /* R3608 - EQ1_9 */
1398 { 0x00000E19, 0x1C9B }, /* R3609 - EQ1_10 */
1399 { 0x00000E1A, 0xF337 }, /* R3610 - EQ1_11 */
1400 { 0x00000E1B, 0x040B }, /* R3611 - EQ1_12 */
1401 { 0x00000E1C, 0x0CBB }, /* R3612 - EQ1_13 */
1402 { 0x00000E1D, 0x16F8 }, /* R3613 - EQ1_14 */
1403 { 0x00000E1E, 0xF7D9 }, /* R3614 - EQ1_15 */
1404 { 0x00000E1F, 0x040A }, /* R3615 - EQ1_16 */
1405 { 0x00000E20, 0x1F14 }, /* R3616 - EQ1_17 */
1406 { 0x00000E21, 0x058C }, /* R3617 - EQ1_18 */
1407 { 0x00000E22, 0x0563 }, /* R3618 - EQ1_19 */
1408 { 0x00000E23, 0x4000 }, /* R3619 - EQ1_20 */
1409 { 0x00000E24, 0x0B75 }, /* R3620 - EQ1_21 */
1410 { 0x00000E26, 0x6318 }, /* R3622 - EQ2_1 */
1411 { 0x00000E27, 0x6300 }, /* R3623 - EQ2_2 */
1412 { 0x00000E28, 0x0FC8 }, /* R3624 - EQ2_3 */
1413 { 0x00000E29, 0x03FE }, /* R3625 - EQ2_4 */
1414 { 0x00000E2A, 0x00E0 }, /* R3626 - EQ2_5 */
1415 { 0x00000E2B, 0x1EC4 }, /* R3627 - EQ2_6 */
1416 { 0x00000E2C, 0xF136 }, /* R3628 - EQ2_7 */
1417 { 0x00000E2D, 0x0409 }, /* R3629 - EQ2_8 */
1418 { 0x00000E2E, 0x04CC }, /* R3630 - EQ2_9 */
1419 { 0x00000E2F, 0x1C9B }, /* R3631 - EQ2_10 */
1420 { 0x00000E30, 0xF337 }, /* R3632 - EQ2_11 */
1421 { 0x00000E31, 0x040B }, /* R3633 - EQ2_12 */
1422 { 0x00000E32, 0x0CBB }, /* R3634 - EQ2_13 */
1423 { 0x00000E33, 0x16F8 }, /* R3635 - EQ2_14 */
1424 { 0x00000E34, 0xF7D9 }, /* R3636 - EQ2_15 */
1425 { 0x00000E35, 0x040A }, /* R3637 - EQ2_16 */
1426 { 0x00000E36, 0x1F14 }, /* R3638 - EQ2_17 */
1427 { 0x00000E37, 0x058C }, /* R3639 - EQ2_18 */
1428 { 0x00000E38, 0x0563 }, /* R3640 - EQ2_19 */
1429 { 0x00000E39, 0x4000 }, /* R3641 - EQ2_20 */
1430 { 0x00000E3A, 0x0B75 }, /* R3642 - EQ2_21 */
1431 { 0x00000E3C, 0x6318 }, /* R3644 - EQ3_1 */
1432 { 0x00000E3D, 0x6300 }, /* R3645 - EQ3_2 */
1433 { 0x00000E3E, 0x0FC8 }, /* R3646 - EQ3_3 */
1434 { 0x00000E3F, 0x03FE }, /* R3647 - EQ3_4 */
1435 { 0x00000E40, 0x00E0 }, /* R3648 - EQ3_5 */
1436 { 0x00000E41, 0x1EC4 }, /* R3649 - EQ3_6 */
1437 { 0x00000E42, 0xF136 }, /* R3650 - EQ3_7 */
1438 { 0x00000E43, 0x0409 }, /* R3651 - EQ3_8 */
1439 { 0x00000E44, 0x04CC }, /* R3652 - EQ3_9 */
1440 { 0x00000E45, 0x1C9B }, /* R3653 - EQ3_10 */
1441 { 0x00000E46, 0xF337 }, /* R3654 - EQ3_11 */
1442 { 0x00000E47, 0x040B }, /* R3655 - EQ3_12 */
1443 { 0x00000E48, 0x0CBB }, /* R3656 - EQ3_13 */
1444 { 0x00000E49, 0x16F8 }, /* R3657 - EQ3_14 */
1445 { 0x00000E4A, 0xF7D9 }, /* R3658 - EQ3_15 */
1446 { 0x00000E4B, 0x040A }, /* R3659 - EQ3_16 */
1447 { 0x00000E4C, 0x1F14 }, /* R3660 - EQ3_17 */
1448 { 0x00000E4D, 0x058C }, /* R3661 - EQ3_18 */
1449 { 0x00000E4E, 0x0563 }, /* R3662 - EQ3_19 */
1450 { 0x00000E4F, 0x4000 }, /* R3663 - EQ3_20 */
1451 { 0x00000E50, 0x0B75 }, /* R3664 - EQ3_21 */
1452 { 0x00000E52, 0x6318 }, /* R3666 - EQ4_1 */
1453 { 0x00000E53, 0x6300 }, /* R3667 - EQ4_2 */
1454 { 0x00000E54, 0x0FC8 }, /* R3668 - EQ4_3 */
1455 { 0x00000E55, 0x03FE }, /* R3669 - EQ4_4 */
1456 { 0x00000E56, 0x00E0 }, /* R3670 - EQ4_5 */
1457 { 0x00000E57, 0x1EC4 }, /* R3671 - EQ4_6 */
1458 { 0x00000E58, 0xF136 }, /* R3672 - EQ4_7 */
1459 { 0x00000E59, 0x0409 }, /* R3673 - EQ4_8 */
1460 { 0x00000E5A, 0x04CC }, /* R3674 - EQ4_9 */
1461 { 0x00000E5B, 0x1C9B }, /* R3675 - EQ4_10 */
1462 { 0x00000E5C, 0xF337 }, /* R3676 - EQ4_11 */
1463 { 0x00000E5D, 0x040B }, /* R3677 - EQ4_12 */
1464 { 0x00000E5E, 0x0CBB }, /* R3678 - EQ4_13 */
1465 { 0x00000E5F, 0x16F8 }, /* R3679 - EQ4_14 */
1466 { 0x00000E60, 0xF7D9 }, /* R3680 - EQ4_15 */
1467 { 0x00000E61, 0x040A }, /* R3681 - EQ4_16 */
1468 { 0x00000E62, 0x1F14 }, /* R3682 - EQ4_17 */
1469 { 0x00000E63, 0x058C }, /* R3683 - EQ4_18 */
1470 { 0x00000E64, 0x0563 }, /* R3684 - EQ4_19 */
1471 { 0x00000E65, 0x4000 }, /* R3685 - EQ4_20 */
1472 { 0x00000E66, 0x0B75 }, /* R3686 - EQ4_21 */
1473 { 0x00000E80, 0x0018 }, /* R3712 - DRC1 ctrl1 */
1474 { 0x00000E81, 0x0933 }, /* R3713 - DRC1 ctrl2 */
1475 { 0x00000E82, 0x0018 }, /* R3714 - DRC1 ctrl3 */
1476 { 0x00000E83, 0x0000 }, /* R3715 - DRC1 ctrl4 */
1477 { 0x00000E84, 0x0000 }, /* R3716 - DRC1 ctrl5 */
1478 { 0x00000E89, 0x0018 }, /* R3721 - DRC2 ctrl1 */
1479 { 0x00000E8A, 0x0933 }, /* R3722 - DRC2 ctrl2 */
1480 { 0x00000E8B, 0x0018 }, /* R3723 - DRC2 ctrl3 */
1481 { 0x00000E8C, 0x0000 }, /* R3724 - DRC2 ctrl4 */
1482 { 0x00000E8D, 0x0000 }, /* R3725 - DRC2 ctrl5 */
1483 { 0x00000EC0, 0x0000 }, /* R3776 - HPLPF1_1 */
1484 { 0x00000EC1, 0x0000 }, /* R3777 - HPLPF1_2 */
1485 { 0x00000EC4, 0x0000 }, /* R3780 - HPLPF2_1 */
1486 { 0x00000EC5, 0x0000 }, /* R3781 - HPLPF2_2 */
1487 { 0x00000EC8, 0x0000 }, /* R3784 - HPLPF3_1 */
1488 { 0x00000EC9, 0x0000 }, /* R3785 - HPLPF3_2 */
1489 { 0x00000ECC, 0x0000 }, /* R3788 - HPLPF4_1 */
1490 { 0x00000ECD, 0x0000 }, /* R3789 - HPLPF4_2 */
1491 { 0x00000EE0, 0x0000 }, /* R3808 - ASRC_ENABLE */
1492 { 0x00000EE2, 0x0000 }, /* R3810 - ASRC_RATE1 */
1493 { 0x00000EE3, 0x4000 }, /* R3811 - ASRC_RATE2 */
1494 { 0x00000EF0, 0x0000 }, /* R3824 - ISRC 1 CTRL 1 */
1495 { 0x00000EF1, 0x0000 }, /* R3825 - ISRC 1 CTRL 2 */
1496 { 0x00000EF2, 0x0000 }, /* R3826 - ISRC 1 CTRL 3 */
1497 { 0x00000EF3, 0x0000 }, /* R3827 - ISRC 2 CTRL 1 */
1498 { 0x00000EF4, 0x0000 }, /* R3828 - ISRC 2 CTRL 2 */
1499 { 0x00000EF5, 0x0000 }, /* R3829 - ISRC 2 CTRL 3 */
1500 { 0x00000EF6, 0x0000 }, /* R3830 - ISRC 3 CTRL 1 */
1501 { 0x00000EF7, 0x0000 }, /* R3831 - ISRC 3 CTRL 2 */
1502 { 0x00000EF8, 0x0000 }, /* R3832 - ISRC 3 CTRL 3 */
1503 { 0x00001100, 0x0010 }, /* R4352 - DSP1 Control 1 */
1504 { 0x00001101, 0x0000 }, /* R4353 - DSP1 Clocking 1 */
1505};
1506
1507static bool wm5102_readable_register(struct device *dev, unsigned int reg)
1508{
1509 switch (reg) {
1510 case ARIZONA_SOFTWARE_RESET:
1511 case ARIZONA_DEVICE_REVISION:
1512 case ARIZONA_CTRL_IF_SPI_CFG_1:
1513 case ARIZONA_CTRL_IF_I2C1_CFG_1:
1514 case ARIZONA_CTRL_IF_STATUS_1:
1515 case ARIZONA_WRITE_SEQUENCER_CTRL_0:
1516 case ARIZONA_WRITE_SEQUENCER_CTRL_1:
1517 case ARIZONA_WRITE_SEQUENCER_CTRL_2:
1518 case ARIZONA_WRITE_SEQUENCER_PROM:
1519 case ARIZONA_TONE_GENERATOR_1:
1520 case ARIZONA_TONE_GENERATOR_2:
1521 case ARIZONA_TONE_GENERATOR_3:
1522 case ARIZONA_TONE_GENERATOR_4:
1523 case ARIZONA_TONE_GENERATOR_5:
1524 case ARIZONA_PWM_DRIVE_1:
1525 case ARIZONA_PWM_DRIVE_2:
1526 case ARIZONA_PWM_DRIVE_3:
1527 case ARIZONA_WAKE_CONTROL:
1528 case ARIZONA_SEQUENCE_CONTROL:
1529 case ARIZONA_SAMPLE_RATE_SEQUENCE_SELECT_1:
1530 case ARIZONA_SAMPLE_RATE_SEQUENCE_SELECT_2:
1531 case ARIZONA_SAMPLE_RATE_SEQUENCE_SELECT_3:
1532 case ARIZONA_SAMPLE_RATE_SEQUENCE_SELECT_4:
1533 case ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_1:
1534 case ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_2:
1535 case ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_3:
1536 case ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_4:
1537 case ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_5:
1538 case ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_6:
1539 case ARIZONA_COMFORT_NOISE_GENERATOR:
1540 case ARIZONA_HAPTICS_CONTROL_1:
1541 case ARIZONA_HAPTICS_CONTROL_2:
1542 case ARIZONA_HAPTICS_PHASE_1_INTENSITY:
1543 case ARIZONA_HAPTICS_PHASE_1_DURATION:
1544 case ARIZONA_HAPTICS_PHASE_2_INTENSITY:
1545 case ARIZONA_HAPTICS_PHASE_2_DURATION:
1546 case ARIZONA_HAPTICS_PHASE_3_INTENSITY:
1547 case ARIZONA_HAPTICS_PHASE_3_DURATION:
1548 case ARIZONA_HAPTICS_STATUS:
1549 case ARIZONA_CLOCK_32K_1:
1550 case ARIZONA_SYSTEM_CLOCK_1:
1551 case ARIZONA_SAMPLE_RATE_1:
1552 case ARIZONA_SAMPLE_RATE_2:
1553 case ARIZONA_SAMPLE_RATE_3:
1554 case ARIZONA_SAMPLE_RATE_1_STATUS:
1555 case ARIZONA_SAMPLE_RATE_2_STATUS:
1556 case ARIZONA_SAMPLE_RATE_3_STATUS:
1557 case ARIZONA_ASYNC_CLOCK_1:
1558 case ARIZONA_ASYNC_SAMPLE_RATE_1:
1559 case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS:
1560 case ARIZONA_OUTPUT_SYSTEM_CLOCK:
1561 case ARIZONA_OUTPUT_ASYNC_CLOCK:
1562 case ARIZONA_RATE_ESTIMATOR_1:
1563 case ARIZONA_RATE_ESTIMATOR_2:
1564 case ARIZONA_RATE_ESTIMATOR_3:
1565 case ARIZONA_RATE_ESTIMATOR_4:
1566 case ARIZONA_RATE_ESTIMATOR_5:
1567 case ARIZONA_FLL1_CONTROL_1:
1568 case ARIZONA_FLL1_CONTROL_2:
1569 case ARIZONA_FLL1_CONTROL_3:
1570 case ARIZONA_FLL1_CONTROL_4:
1571 case ARIZONA_FLL1_CONTROL_5:
1572 case ARIZONA_FLL1_CONTROL_6:
1573 case ARIZONA_FLL1_LOOP_FILTER_TEST_1:
1574 case ARIZONA_FLL1_SYNCHRONISER_1:
1575 case ARIZONA_FLL1_SYNCHRONISER_2:
1576 case ARIZONA_FLL1_SYNCHRONISER_3:
1577 case ARIZONA_FLL1_SYNCHRONISER_4:
1578 case ARIZONA_FLL1_SYNCHRONISER_5:
1579 case ARIZONA_FLL1_SYNCHRONISER_6:
1580 case ARIZONA_FLL1_SPREAD_SPECTRUM:
1581 case ARIZONA_FLL1_GPIO_CLOCK:
1582 case ARIZONA_FLL2_CONTROL_1:
1583 case ARIZONA_FLL2_CONTROL_2:
1584 case ARIZONA_FLL2_CONTROL_3:
1585 case ARIZONA_FLL2_CONTROL_4:
1586 case ARIZONA_FLL2_CONTROL_5:
1587 case ARIZONA_FLL2_CONTROL_6:
1588 case ARIZONA_FLL2_LOOP_FILTER_TEST_1:
1589 case ARIZONA_FLL2_SYNCHRONISER_1:
1590 case ARIZONA_FLL2_SYNCHRONISER_2:
1591 case ARIZONA_FLL2_SYNCHRONISER_3:
1592 case ARIZONA_FLL2_SYNCHRONISER_4:
1593 case ARIZONA_FLL2_SYNCHRONISER_5:
1594 case ARIZONA_FLL2_SYNCHRONISER_6:
1595 case ARIZONA_FLL2_SPREAD_SPECTRUM:
1596 case ARIZONA_FLL2_GPIO_CLOCK:
1597 case ARIZONA_MIC_CHARGE_PUMP_1:
1598 case ARIZONA_LDO1_CONTROL_1:
1599 case ARIZONA_LDO2_CONTROL_1:
1600 case ARIZONA_MIC_BIAS_CTRL_1:
1601 case ARIZONA_MIC_BIAS_CTRL_2:
1602 case ARIZONA_MIC_BIAS_CTRL_3:
1603 case ARIZONA_ACCESSORY_DETECT_MODE_1:
1604 case ARIZONA_HEADPHONE_DETECT_1:
1605 case ARIZONA_HEADPHONE_DETECT_2:
1606 case ARIZONA_MIC_DETECT_1:
1607 case ARIZONA_MIC_DETECT_2:
1608 case ARIZONA_MIC_DETECT_3:
1609 case ARIZONA_MIC_NOISE_MIX_CONTROL_1:
1610 case ARIZONA_ISOLATION_CONTROL:
1611 case ARIZONA_JACK_DETECT_ANALOGUE:
1612 case ARIZONA_INPUT_ENABLES:
1613 case ARIZONA_INPUT_RATE:
1614 case ARIZONA_INPUT_VOLUME_RAMP:
1615 case ARIZONA_IN1L_CONTROL:
1616 case ARIZONA_ADC_DIGITAL_VOLUME_1L:
1617 case ARIZONA_DMIC1L_CONTROL:
1618 case ARIZONA_IN1R_CONTROL:
1619 case ARIZONA_ADC_DIGITAL_VOLUME_1R:
1620 case ARIZONA_DMIC1R_CONTROL:
1621 case ARIZONA_IN2L_CONTROL:
1622 case ARIZONA_ADC_DIGITAL_VOLUME_2L:
1623 case ARIZONA_DMIC2L_CONTROL:
1624 case ARIZONA_IN2R_CONTROL:
1625 case ARIZONA_ADC_DIGITAL_VOLUME_2R:
1626 case ARIZONA_DMIC2R_CONTROL:
1627 case ARIZONA_IN3L_CONTROL:
1628 case ARIZONA_ADC_DIGITAL_VOLUME_3L:
1629 case ARIZONA_DMIC3L_CONTROL:
1630 case ARIZONA_IN3R_CONTROL:
1631 case ARIZONA_ADC_DIGITAL_VOLUME_3R:
1632 case ARIZONA_DMIC3R_CONTROL:
1633 case ARIZONA_OUTPUT_ENABLES_1:
1634 case ARIZONA_OUTPUT_STATUS_1:
1635 case ARIZONA_OUTPUT_RATE_1:
1636 case ARIZONA_OUTPUT_VOLUME_RAMP:
1637 case ARIZONA_OUTPUT_PATH_CONFIG_1L:
1638 case ARIZONA_DAC_DIGITAL_VOLUME_1L:
1639 case ARIZONA_DAC_VOLUME_LIMIT_1L:
1640 case ARIZONA_NOISE_GATE_SELECT_1L:
1641 case ARIZONA_OUTPUT_PATH_CONFIG_1R:
1642 case ARIZONA_DAC_DIGITAL_VOLUME_1R:
1643 case ARIZONA_DAC_VOLUME_LIMIT_1R:
1644 case ARIZONA_NOISE_GATE_SELECT_1R:
1645 case ARIZONA_OUTPUT_PATH_CONFIG_2L:
1646 case ARIZONA_DAC_DIGITAL_VOLUME_2L:
1647 case ARIZONA_DAC_VOLUME_LIMIT_2L:
1648 case ARIZONA_NOISE_GATE_SELECT_2L:
1649 case ARIZONA_OUTPUT_PATH_CONFIG_2R:
1650 case ARIZONA_DAC_DIGITAL_VOLUME_2R:
1651 case ARIZONA_DAC_VOLUME_LIMIT_2R:
1652 case ARIZONA_NOISE_GATE_SELECT_2R:
1653 case ARIZONA_OUTPUT_PATH_CONFIG_3L:
1654 case ARIZONA_DAC_DIGITAL_VOLUME_3L:
1655 case ARIZONA_DAC_VOLUME_LIMIT_3L:
1656 case ARIZONA_NOISE_GATE_SELECT_3L:
1657 case ARIZONA_OUTPUT_PATH_CONFIG_3R:
1658 case ARIZONA_DAC_DIGITAL_VOLUME_3R:
1659 case ARIZONA_DAC_VOLUME_LIMIT_3R:
1660 case ARIZONA_OUTPUT_PATH_CONFIG_4L:
1661 case ARIZONA_DAC_DIGITAL_VOLUME_4L:
1662 case ARIZONA_OUT_VOLUME_4L:
1663 case ARIZONA_NOISE_GATE_SELECT_4L:
1664 case ARIZONA_OUTPUT_PATH_CONFIG_4R:
1665 case ARIZONA_DAC_DIGITAL_VOLUME_4R:
1666 case ARIZONA_OUT_VOLUME_4R:
1667 case ARIZONA_NOISE_GATE_SELECT_4R:
1668 case ARIZONA_OUTPUT_PATH_CONFIG_5L:
1669 case ARIZONA_DAC_DIGITAL_VOLUME_5L:
1670 case ARIZONA_DAC_VOLUME_LIMIT_5L:
1671 case ARIZONA_NOISE_GATE_SELECT_5L:
1672 case ARIZONA_OUTPUT_PATH_CONFIG_5R:
1673 case ARIZONA_DAC_DIGITAL_VOLUME_5R:
1674 case ARIZONA_DAC_VOLUME_LIMIT_5R:
1675 case ARIZONA_NOISE_GATE_SELECT_5R:
1676 case ARIZONA_DAC_AEC_CONTROL_1:
1677 case ARIZONA_NOISE_GATE_CONTROL:
1678 case ARIZONA_PDM_SPK1_CTRL_1:
1679 case ARIZONA_PDM_SPK1_CTRL_2:
1680 case ARIZONA_DAC_COMP_1:
1681 case ARIZONA_DAC_COMP_2:
1682 case ARIZONA_DAC_COMP_3:
1683 case ARIZONA_DAC_COMP_4:
1684 case ARIZONA_AIF1_BCLK_CTRL:
1685 case ARIZONA_AIF1_TX_PIN_CTRL:
1686 case ARIZONA_AIF1_RX_PIN_CTRL:
1687 case ARIZONA_AIF1_RATE_CTRL:
1688 case ARIZONA_AIF1_FORMAT:
1689 case ARIZONA_AIF1_TX_BCLK_RATE:
1690 case ARIZONA_AIF1_RX_BCLK_RATE:
1691 case ARIZONA_AIF1_FRAME_CTRL_1:
1692 case ARIZONA_AIF1_FRAME_CTRL_2:
1693 case ARIZONA_AIF1_FRAME_CTRL_3:
1694 case ARIZONA_AIF1_FRAME_CTRL_4:
1695 case ARIZONA_AIF1_FRAME_CTRL_5:
1696 case ARIZONA_AIF1_FRAME_CTRL_6:
1697 case ARIZONA_AIF1_FRAME_CTRL_7:
1698 case ARIZONA_AIF1_FRAME_CTRL_8:
1699 case ARIZONA_AIF1_FRAME_CTRL_9:
1700 case ARIZONA_AIF1_FRAME_CTRL_10:
1701 case ARIZONA_AIF1_FRAME_CTRL_11:
1702 case ARIZONA_AIF1_FRAME_CTRL_12:
1703 case ARIZONA_AIF1_FRAME_CTRL_13:
1704 case ARIZONA_AIF1_FRAME_CTRL_14:
1705 case ARIZONA_AIF1_FRAME_CTRL_15:
1706 case ARIZONA_AIF1_FRAME_CTRL_16:
1707 case ARIZONA_AIF1_FRAME_CTRL_17:
1708 case ARIZONA_AIF1_FRAME_CTRL_18:
1709 case ARIZONA_AIF1_TX_ENABLES:
1710 case ARIZONA_AIF1_RX_ENABLES:
1711 case ARIZONA_AIF1_FORCE_WRITE:
1712 case ARIZONA_AIF2_BCLK_CTRL:
1713 case ARIZONA_AIF2_TX_PIN_CTRL:
1714 case ARIZONA_AIF2_RX_PIN_CTRL:
1715 case ARIZONA_AIF2_RATE_CTRL:
1716 case ARIZONA_AIF2_FORMAT:
1717 case ARIZONA_AIF2_TX_BCLK_RATE:
1718 case ARIZONA_AIF2_RX_BCLK_RATE:
1719 case ARIZONA_AIF2_FRAME_CTRL_1:
1720 case ARIZONA_AIF2_FRAME_CTRL_2:
1721 case ARIZONA_AIF2_FRAME_CTRL_3:
1722 case ARIZONA_AIF2_FRAME_CTRL_4:
1723 case ARIZONA_AIF2_FRAME_CTRL_11:
1724 case ARIZONA_AIF2_FRAME_CTRL_12:
1725 case ARIZONA_AIF2_TX_ENABLES:
1726 case ARIZONA_AIF2_RX_ENABLES:
1727 case ARIZONA_AIF2_FORCE_WRITE:
1728 case ARIZONA_AIF3_BCLK_CTRL:
1729 case ARIZONA_AIF3_TX_PIN_CTRL:
1730 case ARIZONA_AIF3_RX_PIN_CTRL:
1731 case ARIZONA_AIF3_RATE_CTRL:
1732 case ARIZONA_AIF3_FORMAT:
1733 case ARIZONA_AIF3_TX_BCLK_RATE:
1734 case ARIZONA_AIF3_RX_BCLK_RATE:
1735 case ARIZONA_AIF3_FRAME_CTRL_1:
1736 case ARIZONA_AIF3_FRAME_CTRL_2:
1737 case ARIZONA_AIF3_FRAME_CTRL_3:
1738 case ARIZONA_AIF3_FRAME_CTRL_4:
1739 case ARIZONA_AIF3_FRAME_CTRL_11:
1740 case ARIZONA_AIF3_FRAME_CTRL_12:
1741 case ARIZONA_AIF3_TX_ENABLES:
1742 case ARIZONA_AIF3_RX_ENABLES:
1743 case ARIZONA_AIF3_FORCE_WRITE:
1744 case ARIZONA_SLIMBUS_FRAMER_REF_GEAR:
1745 case ARIZONA_SLIMBUS_RATES_1:
1746 case ARIZONA_SLIMBUS_RATES_2:
1747 case ARIZONA_SLIMBUS_RATES_3:
1748 case ARIZONA_SLIMBUS_RATES_4:
1749 case ARIZONA_SLIMBUS_RATES_5:
1750 case ARIZONA_SLIMBUS_RATES_6:
1751 case ARIZONA_SLIMBUS_RATES_7:
1752 case ARIZONA_SLIMBUS_RATES_8:
1753 case ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE:
1754 case ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE:
1755 case ARIZONA_SLIMBUS_RX_PORT_STATUS:
1756 case ARIZONA_SLIMBUS_TX_PORT_STATUS:
1757 case ARIZONA_PWM1MIX_INPUT_1_SOURCE:
1758 case ARIZONA_PWM1MIX_INPUT_1_VOLUME:
1759 case ARIZONA_PWM1MIX_INPUT_2_SOURCE:
1760 case ARIZONA_PWM1MIX_INPUT_2_VOLUME:
1761 case ARIZONA_PWM1MIX_INPUT_3_SOURCE:
1762 case ARIZONA_PWM1MIX_INPUT_3_VOLUME:
1763 case ARIZONA_PWM1MIX_INPUT_4_SOURCE:
1764 case ARIZONA_PWM1MIX_INPUT_4_VOLUME:
1765 case ARIZONA_PWM2MIX_INPUT_1_SOURCE:
1766 case ARIZONA_PWM2MIX_INPUT_1_VOLUME:
1767 case ARIZONA_PWM2MIX_INPUT_2_SOURCE:
1768 case ARIZONA_PWM2MIX_INPUT_2_VOLUME:
1769 case ARIZONA_PWM2MIX_INPUT_3_SOURCE:
1770 case ARIZONA_PWM2MIX_INPUT_3_VOLUME:
1771 case ARIZONA_PWM2MIX_INPUT_4_SOURCE:
1772 case ARIZONA_PWM2MIX_INPUT_4_VOLUME:
1773 case ARIZONA_MICMIX_INPUT_1_SOURCE:
1774 case ARIZONA_MICMIX_INPUT_1_VOLUME:
1775 case ARIZONA_MICMIX_INPUT_2_SOURCE:
1776 case ARIZONA_MICMIX_INPUT_2_VOLUME:
1777 case ARIZONA_MICMIX_INPUT_3_SOURCE:
1778 case ARIZONA_MICMIX_INPUT_3_VOLUME:
1779 case ARIZONA_MICMIX_INPUT_4_SOURCE:
1780 case ARIZONA_MICMIX_INPUT_4_VOLUME:
1781 case ARIZONA_NOISEMIX_INPUT_1_SOURCE:
1782 case ARIZONA_NOISEMIX_INPUT_1_VOLUME:
1783 case ARIZONA_NOISEMIX_INPUT_2_SOURCE:
1784 case ARIZONA_NOISEMIX_INPUT_2_VOLUME:
1785 case ARIZONA_NOISEMIX_INPUT_3_SOURCE:
1786 case ARIZONA_NOISEMIX_INPUT_3_VOLUME:
1787 case ARIZONA_NOISEMIX_INPUT_4_SOURCE:
1788 case ARIZONA_NOISEMIX_INPUT_4_VOLUME:
1789 case ARIZONA_OUT1LMIX_INPUT_1_SOURCE:
1790 case ARIZONA_OUT1LMIX_INPUT_1_VOLUME:
1791 case ARIZONA_OUT1LMIX_INPUT_2_SOURCE:
1792 case ARIZONA_OUT1LMIX_INPUT_2_VOLUME:
1793 case ARIZONA_OUT1LMIX_INPUT_3_SOURCE:
1794 case ARIZONA_OUT1LMIX_INPUT_3_VOLUME:
1795 case ARIZONA_OUT1LMIX_INPUT_4_SOURCE:
1796 case ARIZONA_OUT1LMIX_INPUT_4_VOLUME:
1797 case ARIZONA_OUT1RMIX_INPUT_1_SOURCE:
1798 case ARIZONA_OUT1RMIX_INPUT_1_VOLUME:
1799 case ARIZONA_OUT1RMIX_INPUT_2_SOURCE:
1800 case ARIZONA_OUT1RMIX_INPUT_2_VOLUME:
1801 case ARIZONA_OUT1RMIX_INPUT_3_SOURCE:
1802 case ARIZONA_OUT1RMIX_INPUT_3_VOLUME:
1803 case ARIZONA_OUT1RMIX_INPUT_4_SOURCE:
1804 case ARIZONA_OUT1RMIX_INPUT_4_VOLUME:
1805 case ARIZONA_OUT2LMIX_INPUT_1_SOURCE:
1806 case ARIZONA_OUT2LMIX_INPUT_1_VOLUME:
1807 case ARIZONA_OUT2LMIX_INPUT_2_SOURCE:
1808 case ARIZONA_OUT2LMIX_INPUT_2_VOLUME:
1809 case ARIZONA_OUT2LMIX_INPUT_3_SOURCE:
1810 case ARIZONA_OUT2LMIX_INPUT_3_VOLUME:
1811 case ARIZONA_OUT2LMIX_INPUT_4_SOURCE:
1812 case ARIZONA_OUT2LMIX_INPUT_4_VOLUME:
1813 case ARIZONA_OUT2RMIX_INPUT_1_SOURCE:
1814 case ARIZONA_OUT2RMIX_INPUT_1_VOLUME:
1815 case ARIZONA_OUT2RMIX_INPUT_2_SOURCE:
1816 case ARIZONA_OUT2RMIX_INPUT_2_VOLUME:
1817 case ARIZONA_OUT2RMIX_INPUT_3_SOURCE:
1818 case ARIZONA_OUT2RMIX_INPUT_3_VOLUME:
1819 case ARIZONA_OUT2RMIX_INPUT_4_SOURCE:
1820 case ARIZONA_OUT2RMIX_INPUT_4_VOLUME:
1821 case ARIZONA_OUT3LMIX_INPUT_1_SOURCE:
1822 case ARIZONA_OUT3LMIX_INPUT_1_VOLUME:
1823 case ARIZONA_OUT3LMIX_INPUT_2_SOURCE:
1824 case ARIZONA_OUT3LMIX_INPUT_2_VOLUME:
1825 case ARIZONA_OUT3LMIX_INPUT_3_SOURCE:
1826 case ARIZONA_OUT3LMIX_INPUT_3_VOLUME:
1827 case ARIZONA_OUT3LMIX_INPUT_4_SOURCE:
1828 case ARIZONA_OUT3LMIX_INPUT_4_VOLUME:
1829 case ARIZONA_OUT4LMIX_INPUT_1_SOURCE:
1830 case ARIZONA_OUT4LMIX_INPUT_1_VOLUME:
1831 case ARIZONA_OUT4LMIX_INPUT_2_SOURCE:
1832 case ARIZONA_OUT4LMIX_INPUT_2_VOLUME:
1833 case ARIZONA_OUT4LMIX_INPUT_3_SOURCE:
1834 case ARIZONA_OUT4LMIX_INPUT_3_VOLUME:
1835 case ARIZONA_OUT4LMIX_INPUT_4_SOURCE:
1836 case ARIZONA_OUT4LMIX_INPUT_4_VOLUME:
1837 case ARIZONA_OUT4RMIX_INPUT_1_SOURCE:
1838 case ARIZONA_OUT4RMIX_INPUT_1_VOLUME:
1839 case ARIZONA_OUT4RMIX_INPUT_2_SOURCE:
1840 case ARIZONA_OUT4RMIX_INPUT_2_VOLUME:
1841 case ARIZONA_OUT4RMIX_INPUT_3_SOURCE:
1842 case ARIZONA_OUT4RMIX_INPUT_3_VOLUME:
1843 case ARIZONA_OUT4RMIX_INPUT_4_SOURCE:
1844 case ARIZONA_OUT4RMIX_INPUT_4_VOLUME:
1845 case ARIZONA_OUT5LMIX_INPUT_1_SOURCE:
1846 case ARIZONA_OUT5LMIX_INPUT_1_VOLUME:
1847 case ARIZONA_OUT5LMIX_INPUT_2_SOURCE:
1848 case ARIZONA_OUT5LMIX_INPUT_2_VOLUME:
1849 case ARIZONA_OUT5LMIX_INPUT_3_SOURCE:
1850 case ARIZONA_OUT5LMIX_INPUT_3_VOLUME:
1851 case ARIZONA_OUT5LMIX_INPUT_4_SOURCE:
1852 case ARIZONA_OUT5LMIX_INPUT_4_VOLUME:
1853 case ARIZONA_OUT5RMIX_INPUT_1_SOURCE:
1854 case ARIZONA_OUT5RMIX_INPUT_1_VOLUME:
1855 case ARIZONA_OUT5RMIX_INPUT_2_SOURCE:
1856 case ARIZONA_OUT5RMIX_INPUT_2_VOLUME:
1857 case ARIZONA_OUT5RMIX_INPUT_3_SOURCE:
1858 case ARIZONA_OUT5RMIX_INPUT_3_VOLUME:
1859 case ARIZONA_OUT5RMIX_INPUT_4_SOURCE:
1860 case ARIZONA_OUT5RMIX_INPUT_4_VOLUME:
1861 case ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE:
1862 case ARIZONA_AIF1TX1MIX_INPUT_1_VOLUME:
1863 case ARIZONA_AIF1TX1MIX_INPUT_2_SOURCE:
1864 case ARIZONA_AIF1TX1MIX_INPUT_2_VOLUME:
1865 case ARIZONA_AIF1TX1MIX_INPUT_3_SOURCE:
1866 case ARIZONA_AIF1TX1MIX_INPUT_3_VOLUME:
1867 case ARIZONA_AIF1TX1MIX_INPUT_4_SOURCE:
1868 case ARIZONA_AIF1TX1MIX_INPUT_4_VOLUME:
1869 case ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE:
1870 case ARIZONA_AIF1TX2MIX_INPUT_1_VOLUME:
1871 case ARIZONA_AIF1TX2MIX_INPUT_2_SOURCE:
1872 case ARIZONA_AIF1TX2MIX_INPUT_2_VOLUME:
1873 case ARIZONA_AIF1TX2MIX_INPUT_3_SOURCE:
1874 case ARIZONA_AIF1TX2MIX_INPUT_3_VOLUME:
1875 case ARIZONA_AIF1TX2MIX_INPUT_4_SOURCE:
1876 case ARIZONA_AIF1TX2MIX_INPUT_4_VOLUME:
1877 case ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE:
1878 case ARIZONA_AIF1TX3MIX_INPUT_1_VOLUME:
1879 case ARIZONA_AIF1TX3MIX_INPUT_2_SOURCE:
1880 case ARIZONA_AIF1TX3MIX_INPUT_2_VOLUME:
1881 case ARIZONA_AIF1TX3MIX_INPUT_3_SOURCE:
1882 case ARIZONA_AIF1TX3MIX_INPUT_3_VOLUME:
1883 case ARIZONA_AIF1TX3MIX_INPUT_4_SOURCE:
1884 case ARIZONA_AIF1TX3MIX_INPUT_4_VOLUME:
1885 case ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE:
1886 case ARIZONA_AIF1TX4MIX_INPUT_1_VOLUME:
1887 case ARIZONA_AIF1TX4MIX_INPUT_2_SOURCE:
1888 case ARIZONA_AIF1TX4MIX_INPUT_2_VOLUME:
1889 case ARIZONA_AIF1TX4MIX_INPUT_3_SOURCE:
1890 case ARIZONA_AIF1TX4MIX_INPUT_3_VOLUME:
1891 case ARIZONA_AIF1TX4MIX_INPUT_4_SOURCE:
1892 case ARIZONA_AIF1TX4MIX_INPUT_4_VOLUME:
1893 case ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE:
1894 case ARIZONA_AIF1TX5MIX_INPUT_1_VOLUME:
1895 case ARIZONA_AIF1TX5MIX_INPUT_2_SOURCE:
1896 case ARIZONA_AIF1TX5MIX_INPUT_2_VOLUME:
1897 case ARIZONA_AIF1TX5MIX_INPUT_3_SOURCE:
1898 case ARIZONA_AIF1TX5MIX_INPUT_3_VOLUME:
1899 case ARIZONA_AIF1TX5MIX_INPUT_4_SOURCE:
1900 case ARIZONA_AIF1TX5MIX_INPUT_4_VOLUME:
1901 case ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE:
1902 case ARIZONA_AIF1TX6MIX_INPUT_1_VOLUME:
1903 case ARIZONA_AIF1TX6MIX_INPUT_2_SOURCE:
1904 case ARIZONA_AIF1TX6MIX_INPUT_2_VOLUME:
1905 case ARIZONA_AIF1TX6MIX_INPUT_3_SOURCE:
1906 case ARIZONA_AIF1TX6MIX_INPUT_3_VOLUME:
1907 case ARIZONA_AIF1TX6MIX_INPUT_4_SOURCE:
1908 case ARIZONA_AIF1TX6MIX_INPUT_4_VOLUME:
1909 case ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE:
1910 case ARIZONA_AIF1TX7MIX_INPUT_1_VOLUME:
1911 case ARIZONA_AIF1TX7MIX_INPUT_2_SOURCE:
1912 case ARIZONA_AIF1TX7MIX_INPUT_2_VOLUME:
1913 case ARIZONA_AIF1TX7MIX_INPUT_3_SOURCE:
1914 case ARIZONA_AIF1TX7MIX_INPUT_3_VOLUME:
1915 case ARIZONA_AIF1TX7MIX_INPUT_4_SOURCE:
1916 case ARIZONA_AIF1TX7MIX_INPUT_4_VOLUME:
1917 case ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE:
1918 case ARIZONA_AIF1TX8MIX_INPUT_1_VOLUME:
1919 case ARIZONA_AIF1TX8MIX_INPUT_2_SOURCE:
1920 case ARIZONA_AIF1TX8MIX_INPUT_2_VOLUME:
1921 case ARIZONA_AIF1TX8MIX_INPUT_3_SOURCE:
1922 case ARIZONA_AIF1TX8MIX_INPUT_3_VOLUME:
1923 case ARIZONA_AIF1TX8MIX_INPUT_4_SOURCE:
1924 case ARIZONA_AIF1TX8MIX_INPUT_4_VOLUME:
1925 case ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE:
1926 case ARIZONA_AIF2TX1MIX_INPUT_1_VOLUME:
1927 case ARIZONA_AIF2TX1MIX_INPUT_2_SOURCE:
1928 case ARIZONA_AIF2TX1MIX_INPUT_2_VOLUME:
1929 case ARIZONA_AIF2TX1MIX_INPUT_3_SOURCE:
1930 case ARIZONA_AIF2TX1MIX_INPUT_3_VOLUME:
1931 case ARIZONA_AIF2TX1MIX_INPUT_4_SOURCE:
1932 case ARIZONA_AIF2TX1MIX_INPUT_4_VOLUME:
1933 case ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE:
1934 case ARIZONA_AIF2TX2MIX_INPUT_1_VOLUME:
1935 case ARIZONA_AIF2TX2MIX_INPUT_2_SOURCE:
1936 case ARIZONA_AIF2TX2MIX_INPUT_2_VOLUME:
1937 case ARIZONA_AIF2TX2MIX_INPUT_3_SOURCE:
1938 case ARIZONA_AIF2TX2MIX_INPUT_3_VOLUME:
1939 case ARIZONA_AIF2TX2MIX_INPUT_4_SOURCE:
1940 case ARIZONA_AIF2TX2MIX_INPUT_4_VOLUME:
1941 case ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE:
1942 case ARIZONA_AIF3TX1MIX_INPUT_1_VOLUME:
1943 case ARIZONA_AIF3TX1MIX_INPUT_2_SOURCE:
1944 case ARIZONA_AIF3TX1MIX_INPUT_2_VOLUME:
1945 case ARIZONA_AIF3TX1MIX_INPUT_3_SOURCE:
1946 case ARIZONA_AIF3TX1MIX_INPUT_3_VOLUME:
1947 case ARIZONA_AIF3TX1MIX_INPUT_4_SOURCE:
1948 case ARIZONA_AIF3TX1MIX_INPUT_4_VOLUME:
1949 case ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE:
1950 case ARIZONA_AIF3TX2MIX_INPUT_1_VOLUME:
1951 case ARIZONA_AIF3TX2MIX_INPUT_2_SOURCE:
1952 case ARIZONA_AIF3TX2MIX_INPUT_2_VOLUME:
1953 case ARIZONA_AIF3TX2MIX_INPUT_3_SOURCE:
1954 case ARIZONA_AIF3TX2MIX_INPUT_3_VOLUME:
1955 case ARIZONA_AIF3TX2MIX_INPUT_4_SOURCE:
1956 case ARIZONA_AIF3TX2MIX_INPUT_4_VOLUME:
1957 case ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE:
1958 case ARIZONA_SLIMTX1MIX_INPUT_1_VOLUME:
1959 case ARIZONA_SLIMTX1MIX_INPUT_2_SOURCE:
1960 case ARIZONA_SLIMTX1MIX_INPUT_2_VOLUME:
1961 case ARIZONA_SLIMTX1MIX_INPUT_3_SOURCE:
1962 case ARIZONA_SLIMTX1MIX_INPUT_3_VOLUME:
1963 case ARIZONA_SLIMTX1MIX_INPUT_4_SOURCE:
1964 case ARIZONA_SLIMTX1MIX_INPUT_4_VOLUME:
1965 case ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE:
1966 case ARIZONA_SLIMTX2MIX_INPUT_1_VOLUME:
1967 case ARIZONA_SLIMTX2MIX_INPUT_2_SOURCE:
1968 case ARIZONA_SLIMTX2MIX_INPUT_2_VOLUME:
1969 case ARIZONA_SLIMTX2MIX_INPUT_3_SOURCE:
1970 case ARIZONA_SLIMTX2MIX_INPUT_3_VOLUME:
1971 case ARIZONA_SLIMTX2MIX_INPUT_4_SOURCE:
1972 case ARIZONA_SLIMTX2MIX_INPUT_4_VOLUME:
1973 case ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE:
1974 case ARIZONA_SLIMTX3MIX_INPUT_1_VOLUME:
1975 case ARIZONA_SLIMTX3MIX_INPUT_2_SOURCE:
1976 case ARIZONA_SLIMTX3MIX_INPUT_2_VOLUME:
1977 case ARIZONA_SLIMTX3MIX_INPUT_3_SOURCE:
1978 case ARIZONA_SLIMTX3MIX_INPUT_3_VOLUME:
1979 case ARIZONA_SLIMTX3MIX_INPUT_4_SOURCE:
1980 case ARIZONA_SLIMTX3MIX_INPUT_4_VOLUME:
1981 case ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE:
1982 case ARIZONA_SLIMTX4MIX_INPUT_1_VOLUME:
1983 case ARIZONA_SLIMTX4MIX_INPUT_2_SOURCE:
1984 case ARIZONA_SLIMTX4MIX_INPUT_2_VOLUME:
1985 case ARIZONA_SLIMTX4MIX_INPUT_3_SOURCE:
1986 case ARIZONA_SLIMTX4MIX_INPUT_3_VOLUME:
1987 case ARIZONA_SLIMTX4MIX_INPUT_4_SOURCE:
1988 case ARIZONA_SLIMTX4MIX_INPUT_4_VOLUME:
1989 case ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE:
1990 case ARIZONA_SLIMTX5MIX_INPUT_1_VOLUME:
1991 case ARIZONA_SLIMTX5MIX_INPUT_2_SOURCE:
1992 case ARIZONA_SLIMTX5MIX_INPUT_2_VOLUME:
1993 case ARIZONA_SLIMTX5MIX_INPUT_3_SOURCE:
1994 case ARIZONA_SLIMTX5MIX_INPUT_3_VOLUME:
1995 case ARIZONA_SLIMTX5MIX_INPUT_4_SOURCE:
1996 case ARIZONA_SLIMTX5MIX_INPUT_4_VOLUME:
1997 case ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE:
1998 case ARIZONA_SLIMTX6MIX_INPUT_1_VOLUME:
1999 case ARIZONA_SLIMTX6MIX_INPUT_2_SOURCE:
2000 case ARIZONA_SLIMTX6MIX_INPUT_2_VOLUME:
2001 case ARIZONA_SLIMTX6MIX_INPUT_3_SOURCE:
2002 case ARIZONA_SLIMTX6MIX_INPUT_3_VOLUME:
2003 case ARIZONA_SLIMTX6MIX_INPUT_4_SOURCE:
2004 case ARIZONA_SLIMTX6MIX_INPUT_4_VOLUME:
2005 case ARIZONA_SLIMTX7MIX_INPUT_1_SOURCE:
2006 case ARIZONA_SLIMTX7MIX_INPUT_1_VOLUME:
2007 case ARIZONA_SLIMTX7MIX_INPUT_2_SOURCE:
2008 case ARIZONA_SLIMTX7MIX_INPUT_2_VOLUME:
2009 case ARIZONA_SLIMTX7MIX_INPUT_3_SOURCE:
2010 case ARIZONA_SLIMTX7MIX_INPUT_3_VOLUME:
2011 case ARIZONA_SLIMTX7MIX_INPUT_4_SOURCE:
2012 case ARIZONA_SLIMTX7MIX_INPUT_4_VOLUME:
2013 case ARIZONA_SLIMTX8MIX_INPUT_1_SOURCE:
2014 case ARIZONA_SLIMTX8MIX_INPUT_1_VOLUME:
2015 case ARIZONA_SLIMTX8MIX_INPUT_2_SOURCE:
2016 case ARIZONA_SLIMTX8MIX_INPUT_2_VOLUME:
2017 case ARIZONA_SLIMTX8MIX_INPUT_3_SOURCE:
2018 case ARIZONA_SLIMTX8MIX_INPUT_3_VOLUME:
2019 case ARIZONA_SLIMTX8MIX_INPUT_4_SOURCE:
2020 case ARIZONA_SLIMTX8MIX_INPUT_4_VOLUME:
2021 case ARIZONA_EQ1MIX_INPUT_1_SOURCE:
2022 case ARIZONA_EQ1MIX_INPUT_1_VOLUME:
2023 case ARIZONA_EQ1MIX_INPUT_2_SOURCE:
2024 case ARIZONA_EQ1MIX_INPUT_2_VOLUME:
2025 case ARIZONA_EQ1MIX_INPUT_3_SOURCE:
2026 case ARIZONA_EQ1MIX_INPUT_3_VOLUME:
2027 case ARIZONA_EQ1MIX_INPUT_4_SOURCE:
2028 case ARIZONA_EQ1MIX_INPUT_4_VOLUME:
2029 case ARIZONA_EQ2MIX_INPUT_1_SOURCE:
2030 case ARIZONA_EQ2MIX_INPUT_1_VOLUME:
2031 case ARIZONA_EQ2MIX_INPUT_2_SOURCE:
2032 case ARIZONA_EQ2MIX_INPUT_2_VOLUME:
2033 case ARIZONA_EQ2MIX_INPUT_3_SOURCE:
2034 case ARIZONA_EQ2MIX_INPUT_3_VOLUME:
2035 case ARIZONA_EQ2MIX_INPUT_4_SOURCE:
2036 case ARIZONA_EQ2MIX_INPUT_4_VOLUME:
2037 case ARIZONA_EQ3MIX_INPUT_1_SOURCE:
2038 case ARIZONA_EQ3MIX_INPUT_1_VOLUME:
2039 case ARIZONA_EQ3MIX_INPUT_2_SOURCE:
2040 case ARIZONA_EQ3MIX_INPUT_2_VOLUME:
2041 case ARIZONA_EQ3MIX_INPUT_3_SOURCE:
2042 case ARIZONA_EQ3MIX_INPUT_3_VOLUME:
2043 case ARIZONA_EQ3MIX_INPUT_4_SOURCE:
2044 case ARIZONA_EQ3MIX_INPUT_4_VOLUME:
2045 case ARIZONA_EQ4MIX_INPUT_1_SOURCE:
2046 case ARIZONA_EQ4MIX_INPUT_1_VOLUME:
2047 case ARIZONA_EQ4MIX_INPUT_2_SOURCE:
2048 case ARIZONA_EQ4MIX_INPUT_2_VOLUME:
2049 case ARIZONA_EQ4MIX_INPUT_3_SOURCE:
2050 case ARIZONA_EQ4MIX_INPUT_3_VOLUME:
2051 case ARIZONA_EQ4MIX_INPUT_4_SOURCE:
2052 case ARIZONA_EQ4MIX_INPUT_4_VOLUME:
2053 case ARIZONA_DRC1LMIX_INPUT_1_SOURCE:
2054 case ARIZONA_DRC1LMIX_INPUT_1_VOLUME:
2055 case ARIZONA_DRC1LMIX_INPUT_2_SOURCE:
2056 case ARIZONA_DRC1LMIX_INPUT_2_VOLUME:
2057 case ARIZONA_DRC1LMIX_INPUT_3_SOURCE:
2058 case ARIZONA_DRC1LMIX_INPUT_3_VOLUME:
2059 case ARIZONA_DRC1LMIX_INPUT_4_SOURCE:
2060 case ARIZONA_DRC1LMIX_INPUT_4_VOLUME:
2061 case ARIZONA_DRC1RMIX_INPUT_1_SOURCE:
2062 case ARIZONA_DRC1RMIX_INPUT_1_VOLUME:
2063 case ARIZONA_DRC1RMIX_INPUT_2_SOURCE:
2064 case ARIZONA_DRC1RMIX_INPUT_2_VOLUME:
2065 case ARIZONA_DRC1RMIX_INPUT_3_SOURCE:
2066 case ARIZONA_DRC1RMIX_INPUT_3_VOLUME:
2067 case ARIZONA_DRC1RMIX_INPUT_4_SOURCE:
2068 case ARIZONA_DRC1RMIX_INPUT_4_VOLUME:
2069 case ARIZONA_DRC2LMIX_INPUT_1_SOURCE:
2070 case ARIZONA_DRC2LMIX_INPUT_1_VOLUME:
2071 case ARIZONA_DRC2LMIX_INPUT_2_SOURCE:
2072 case ARIZONA_DRC2LMIX_INPUT_2_VOLUME:
2073 case ARIZONA_DRC2LMIX_INPUT_3_SOURCE:
2074 case ARIZONA_DRC2LMIX_INPUT_3_VOLUME:
2075 case ARIZONA_DRC2LMIX_INPUT_4_SOURCE:
2076 case ARIZONA_DRC2LMIX_INPUT_4_VOLUME:
2077 case ARIZONA_DRC2RMIX_INPUT_1_SOURCE:
2078 case ARIZONA_DRC2RMIX_INPUT_1_VOLUME:
2079 case ARIZONA_DRC2RMIX_INPUT_2_SOURCE:
2080 case ARIZONA_DRC2RMIX_INPUT_2_VOLUME:
2081 case ARIZONA_DRC2RMIX_INPUT_3_SOURCE:
2082 case ARIZONA_DRC2RMIX_INPUT_3_VOLUME:
2083 case ARIZONA_DRC2RMIX_INPUT_4_SOURCE:
2084 case ARIZONA_DRC2RMIX_INPUT_4_VOLUME:
2085 case ARIZONA_HPLP1MIX_INPUT_1_SOURCE:
2086 case ARIZONA_HPLP1MIX_INPUT_1_VOLUME:
2087 case ARIZONA_HPLP1MIX_INPUT_2_SOURCE:
2088 case ARIZONA_HPLP1MIX_INPUT_2_VOLUME:
2089 case ARIZONA_HPLP1MIX_INPUT_3_SOURCE:
2090 case ARIZONA_HPLP1MIX_INPUT_3_VOLUME:
2091 case ARIZONA_HPLP1MIX_INPUT_4_SOURCE:
2092 case ARIZONA_HPLP1MIX_INPUT_4_VOLUME:
2093 case ARIZONA_HPLP2MIX_INPUT_1_SOURCE:
2094 case ARIZONA_HPLP2MIX_INPUT_1_VOLUME:
2095 case ARIZONA_HPLP2MIX_INPUT_2_SOURCE:
2096 case ARIZONA_HPLP2MIX_INPUT_2_VOLUME:
2097 case ARIZONA_HPLP2MIX_INPUT_3_SOURCE:
2098 case ARIZONA_HPLP2MIX_INPUT_3_VOLUME:
2099 case ARIZONA_HPLP2MIX_INPUT_4_SOURCE:
2100 case ARIZONA_HPLP2MIX_INPUT_4_VOLUME:
2101 case ARIZONA_HPLP3MIX_INPUT_1_SOURCE:
2102 case ARIZONA_HPLP3MIX_INPUT_1_VOLUME:
2103 case ARIZONA_HPLP3MIX_INPUT_2_SOURCE:
2104 case ARIZONA_HPLP3MIX_INPUT_2_VOLUME:
2105 case ARIZONA_HPLP3MIX_INPUT_3_SOURCE:
2106 case ARIZONA_HPLP3MIX_INPUT_3_VOLUME:
2107 case ARIZONA_HPLP3MIX_INPUT_4_SOURCE:
2108 case ARIZONA_HPLP3MIX_INPUT_4_VOLUME:
2109 case ARIZONA_HPLP4MIX_INPUT_1_SOURCE:
2110 case ARIZONA_HPLP4MIX_INPUT_1_VOLUME:
2111 case ARIZONA_HPLP4MIX_INPUT_2_SOURCE:
2112 case ARIZONA_HPLP4MIX_INPUT_2_VOLUME:
2113 case ARIZONA_HPLP4MIX_INPUT_3_SOURCE:
2114 case ARIZONA_HPLP4MIX_INPUT_3_VOLUME:
2115 case ARIZONA_HPLP4MIX_INPUT_4_SOURCE:
2116 case ARIZONA_HPLP4MIX_INPUT_4_VOLUME:
2117 case ARIZONA_DSP1LMIX_INPUT_1_SOURCE:
2118 case ARIZONA_DSP1LMIX_INPUT_1_VOLUME:
2119 case ARIZONA_DSP1LMIX_INPUT_2_SOURCE:
2120 case ARIZONA_DSP1LMIX_INPUT_2_VOLUME:
2121 case ARIZONA_DSP1LMIX_INPUT_3_SOURCE:
2122 case ARIZONA_DSP1LMIX_INPUT_3_VOLUME:
2123 case ARIZONA_DSP1LMIX_INPUT_4_SOURCE:
2124 case ARIZONA_DSP1LMIX_INPUT_4_VOLUME:
2125 case ARIZONA_DSP1RMIX_INPUT_1_SOURCE:
2126 case ARIZONA_DSP1RMIX_INPUT_1_VOLUME:
2127 case ARIZONA_DSP1RMIX_INPUT_2_SOURCE:
2128 case ARIZONA_DSP1RMIX_INPUT_2_VOLUME:
2129 case ARIZONA_DSP1RMIX_INPUT_3_SOURCE:
2130 case ARIZONA_DSP1RMIX_INPUT_3_VOLUME:
2131 case ARIZONA_DSP1RMIX_INPUT_4_SOURCE:
2132 case ARIZONA_DSP1RMIX_INPUT_4_VOLUME:
2133 case ARIZONA_DSP1AUX1MIX_INPUT_1_SOURCE:
2134 case ARIZONA_DSP1AUX2MIX_INPUT_1_SOURCE:
2135 case ARIZONA_DSP1AUX3MIX_INPUT_1_SOURCE:
2136 case ARIZONA_DSP1AUX4MIX_INPUT_1_SOURCE:
2137 case ARIZONA_DSP1AUX5MIX_INPUT_1_SOURCE:
2138 case ARIZONA_DSP1AUX6MIX_INPUT_1_SOURCE:
2139 case ARIZONA_ASRC1LMIX_INPUT_1_SOURCE:
2140 case ARIZONA_ASRC1RMIX_INPUT_1_SOURCE:
2141 case ARIZONA_ASRC2LMIX_INPUT_1_SOURCE:
2142 case ARIZONA_ASRC2RMIX_INPUT_1_SOURCE:
2143 case ARIZONA_ISRC1DEC1MIX_INPUT_1_SOURCE:
2144 case ARIZONA_ISRC1DEC2MIX_INPUT_1_SOURCE:
2145 case ARIZONA_ISRC1INT1MIX_INPUT_1_SOURCE:
2146 case ARIZONA_ISRC1INT2MIX_INPUT_1_SOURCE:
2147 case ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE:
2148 case ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE:
2149 case ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE:
2150 case ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE:
2151 case ARIZONA_GPIO1_CTRL:
2152 case ARIZONA_GPIO2_CTRL:
2153 case ARIZONA_GPIO3_CTRL:
2154 case ARIZONA_GPIO4_CTRL:
2155 case ARIZONA_GPIO5_CTRL:
2156 case ARIZONA_IRQ_CTRL_1:
2157 case ARIZONA_GPIO_DEBOUNCE_CONFIG:
2158 case ARIZONA_MISC_PAD_CTRL_1:
2159 case ARIZONA_MISC_PAD_CTRL_2:
2160 case ARIZONA_MISC_PAD_CTRL_3:
2161 case ARIZONA_MISC_PAD_CTRL_4:
2162 case ARIZONA_MISC_PAD_CTRL_5:
2163 case ARIZONA_MISC_PAD_CTRL_6:
2164 case ARIZONA_INTERRUPT_STATUS_1:
2165 case ARIZONA_INTERRUPT_STATUS_2:
2166 case ARIZONA_INTERRUPT_STATUS_3:
2167 case ARIZONA_INTERRUPT_STATUS_4:
2168 case ARIZONA_INTERRUPT_STATUS_5:
2169 case ARIZONA_INTERRUPT_STATUS_1_MASK:
2170 case ARIZONA_INTERRUPT_STATUS_2_MASK:
2171 case ARIZONA_INTERRUPT_STATUS_3_MASK:
2172 case ARIZONA_INTERRUPT_STATUS_4_MASK:
2173 case ARIZONA_INTERRUPT_STATUS_5_MASK:
2174 case ARIZONA_INTERRUPT_CONTROL:
2175 case ARIZONA_IRQ2_STATUS_1:
2176 case ARIZONA_IRQ2_STATUS_2:
2177 case ARIZONA_IRQ2_STATUS_3:
2178 case ARIZONA_IRQ2_STATUS_4:
2179 case ARIZONA_IRQ2_STATUS_5:
2180 case ARIZONA_IRQ2_STATUS_1_MASK:
2181 case ARIZONA_IRQ2_STATUS_2_MASK:
2182 case ARIZONA_IRQ2_STATUS_3_MASK:
2183 case ARIZONA_IRQ2_STATUS_4_MASK:
2184 case ARIZONA_IRQ2_STATUS_5_MASK:
2185 case ARIZONA_IRQ2_CONTROL:
2186 case ARIZONA_INTERRUPT_RAW_STATUS_2:
2187 case ARIZONA_INTERRUPT_RAW_STATUS_3:
2188 case ARIZONA_INTERRUPT_RAW_STATUS_4:
2189 case ARIZONA_INTERRUPT_RAW_STATUS_5:
2190 case ARIZONA_INTERRUPT_RAW_STATUS_6:
2191 case ARIZONA_INTERRUPT_RAW_STATUS_7:
2192 case ARIZONA_INTERRUPT_RAW_STATUS_8:
2193 case ARIZONA_IRQ_PIN_STATUS:
2194 case ARIZONA_ADSP2_IRQ0:
2195 case ARIZONA_AOD_WKUP_AND_TRIG:
2196 case ARIZONA_AOD_IRQ1:
2197 case ARIZONA_AOD_IRQ2:
2198 case ARIZONA_AOD_IRQ_MASK_IRQ1:
2199 case ARIZONA_AOD_IRQ_MASK_IRQ2:
2200 case ARIZONA_AOD_IRQ_RAW_STATUS:
2201 case ARIZONA_JACK_DETECT_DEBOUNCE:
2202 case ARIZONA_FX_CTRL1:
2203 case ARIZONA_FX_CTRL2:
2204 case ARIZONA_EQ1_1:
2205 case ARIZONA_EQ1_2:
2206 case ARIZONA_EQ1_3:
2207 case ARIZONA_EQ1_4:
2208 case ARIZONA_EQ1_5:
2209 case ARIZONA_EQ1_6:
2210 case ARIZONA_EQ1_7:
2211 case ARIZONA_EQ1_8:
2212 case ARIZONA_EQ1_9:
2213 case ARIZONA_EQ1_10:
2214 case ARIZONA_EQ1_11:
2215 case ARIZONA_EQ1_12:
2216 case ARIZONA_EQ1_13:
2217 case ARIZONA_EQ1_14:
2218 case ARIZONA_EQ1_15:
2219 case ARIZONA_EQ1_16:
2220 case ARIZONA_EQ1_17:
2221 case ARIZONA_EQ1_18:
2222 case ARIZONA_EQ1_19:
2223 case ARIZONA_EQ1_20:
2224 case ARIZONA_EQ1_21:
2225 case ARIZONA_EQ2_1:
2226 case ARIZONA_EQ2_2:
2227 case ARIZONA_EQ2_3:
2228 case ARIZONA_EQ2_4:
2229 case ARIZONA_EQ2_5:
2230 case ARIZONA_EQ2_6:
2231 case ARIZONA_EQ2_7:
2232 case ARIZONA_EQ2_8:
2233 case ARIZONA_EQ2_9:
2234 case ARIZONA_EQ2_10:
2235 case ARIZONA_EQ2_11:
2236 case ARIZONA_EQ2_12:
2237 case ARIZONA_EQ2_13:
2238 case ARIZONA_EQ2_14:
2239 case ARIZONA_EQ2_15:
2240 case ARIZONA_EQ2_16:
2241 case ARIZONA_EQ2_17:
2242 case ARIZONA_EQ2_18:
2243 case ARIZONA_EQ2_19:
2244 case ARIZONA_EQ2_20:
2245 case ARIZONA_EQ2_21:
2246 case ARIZONA_EQ3_1:
2247 case ARIZONA_EQ3_2:
2248 case ARIZONA_EQ3_3:
2249 case ARIZONA_EQ3_4:
2250 case ARIZONA_EQ3_5:
2251 case ARIZONA_EQ3_6:
2252 case ARIZONA_EQ3_7:
2253 case ARIZONA_EQ3_8:
2254 case ARIZONA_EQ3_9:
2255 case ARIZONA_EQ3_10:
2256 case ARIZONA_EQ3_11:
2257 case ARIZONA_EQ3_12:
2258 case ARIZONA_EQ3_13:
2259 case ARIZONA_EQ3_14:
2260 case ARIZONA_EQ3_15:
2261 case ARIZONA_EQ3_16:
2262 case ARIZONA_EQ3_17:
2263 case ARIZONA_EQ3_18:
2264 case ARIZONA_EQ3_19:
2265 case ARIZONA_EQ3_20:
2266 case ARIZONA_EQ3_21:
2267 case ARIZONA_EQ4_1:
2268 case ARIZONA_EQ4_2:
2269 case ARIZONA_EQ4_3:
2270 case ARIZONA_EQ4_4:
2271 case ARIZONA_EQ4_5:
2272 case ARIZONA_EQ4_6:
2273 case ARIZONA_EQ4_7:
2274 case ARIZONA_EQ4_8:
2275 case ARIZONA_EQ4_9:
2276 case ARIZONA_EQ4_10:
2277 case ARIZONA_EQ4_11:
2278 case ARIZONA_EQ4_12:
2279 case ARIZONA_EQ4_13:
2280 case ARIZONA_EQ4_14:
2281 case ARIZONA_EQ4_15:
2282 case ARIZONA_EQ4_16:
2283 case ARIZONA_EQ4_17:
2284 case ARIZONA_EQ4_18:
2285 case ARIZONA_EQ4_19:
2286 case ARIZONA_EQ4_20:
2287 case ARIZONA_EQ4_21:
2288 case ARIZONA_DRC1_CTRL1:
2289 case ARIZONA_DRC1_CTRL2:
2290 case ARIZONA_DRC1_CTRL3:
2291 case ARIZONA_DRC1_CTRL4:
2292 case ARIZONA_DRC1_CTRL5:
2293 case ARIZONA_DRC2_CTRL1:
2294 case ARIZONA_DRC2_CTRL2:
2295 case ARIZONA_DRC2_CTRL3:
2296 case ARIZONA_DRC2_CTRL4:
2297 case ARIZONA_DRC2_CTRL5:
2298 case ARIZONA_HPLPF1_1:
2299 case ARIZONA_HPLPF1_2:
2300 case ARIZONA_HPLPF2_1:
2301 case ARIZONA_HPLPF2_2:
2302 case ARIZONA_HPLPF3_1:
2303 case ARIZONA_HPLPF3_2:
2304 case ARIZONA_HPLPF4_1:
2305 case ARIZONA_HPLPF4_2:
2306 case ARIZONA_ASRC_ENABLE:
2307 case ARIZONA_ASRC_RATE1:
2308 case ARIZONA_ASRC_RATE2:
2309 case ARIZONA_ISRC_1_CTRL_1:
2310 case ARIZONA_ISRC_1_CTRL_2:
2311 case ARIZONA_ISRC_1_CTRL_3:
2312 case ARIZONA_ISRC_2_CTRL_1:
2313 case ARIZONA_ISRC_2_CTRL_2:
2314 case ARIZONA_ISRC_2_CTRL_3:
2315 case ARIZONA_ISRC_3_CTRL_1:
2316 case ARIZONA_ISRC_3_CTRL_2:
2317 case ARIZONA_ISRC_3_CTRL_3:
2318 case ARIZONA_DSP1_CONTROL_1:
2319 case ARIZONA_DSP1_CLOCKING_1:
2320 case ARIZONA_DSP1_STATUS_1:
2321 case ARIZONA_DSP1_STATUS_2:
2322 return true;
2323 default:
2324 return false;
2325 }
2326}
2327
2328static bool wm5102_volatile_register(struct device *dev, unsigned int reg)
2329{
2330 switch (reg) {
2331 case ARIZONA_SOFTWARE_RESET:
2332 case ARIZONA_DEVICE_REVISION:
2333 case ARIZONA_OUTPUT_STATUS_1:
2334 case ARIZONA_SAMPLE_RATE_1_STATUS:
2335 case ARIZONA_SAMPLE_RATE_2_STATUS:
2336 case ARIZONA_SAMPLE_RATE_3_STATUS:
2337 case ARIZONA_HAPTICS_STATUS:
2338 case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS:
2339 case ARIZONA_FX_CTRL2:
2340 case ARIZONA_INTERRUPT_STATUS_1:
2341 case ARIZONA_INTERRUPT_STATUS_2:
2342 case ARIZONA_INTERRUPT_STATUS_3:
2343 case ARIZONA_INTERRUPT_STATUS_4:
2344 case ARIZONA_INTERRUPT_STATUS_5:
2345 case ARIZONA_IRQ2_STATUS_1:
2346 case ARIZONA_IRQ2_STATUS_2:
2347 case ARIZONA_IRQ2_STATUS_3:
2348 case ARIZONA_IRQ2_STATUS_4:
2349 case ARIZONA_IRQ2_STATUS_5:
2350 case ARIZONA_INTERRUPT_RAW_STATUS_2:
2351 case ARIZONA_INTERRUPT_RAW_STATUS_3:
2352 case ARIZONA_INTERRUPT_RAW_STATUS_4:
2353 case ARIZONA_INTERRUPT_RAW_STATUS_5:
2354 case ARIZONA_INTERRUPT_RAW_STATUS_6:
2355 case ARIZONA_INTERRUPT_RAW_STATUS_7:
2356 case ARIZONA_INTERRUPT_RAW_STATUS_8:
2357 case ARIZONA_IRQ_PIN_STATUS:
2358 case ARIZONA_AOD_WKUP_AND_TRIG:
2359 case ARIZONA_AOD_IRQ1:
2360 case ARIZONA_AOD_IRQ2:
2361 case ARIZONA_AOD_IRQ_RAW_STATUS:
2362 case ARIZONA_DSP1_STATUS_1:
2363 case ARIZONA_DSP1_STATUS_2:
2364 case ARIZONA_HEADPHONE_DETECT_2:
2365 case ARIZONA_MIC_DETECT_3:
2366 return true;
2367 default:
2368 return false;
2369 }
2370}
2371
2372const struct regmap_config wm5102_spi_regmap = {
2373 .reg_bits = 32,
2374 .pad_bits = 16,
2375 .val_bits = 16,
2376
2377 .max_register = ARIZONA_DSP1_STATUS_2,
2378 .readable_reg = wm5102_readable_register,
2379 .volatile_reg = wm5102_volatile_register,
2380
2381 .cache_type = REGCACHE_RBTREE,
2382 .reg_defaults = wm5102_reg_default,
2383 .num_reg_defaults = ARRAY_SIZE(wm5102_reg_default),
2384};
2385EXPORT_SYMBOL_GPL(wm5102_spi_regmap);
2386
2387const struct regmap_config wm5102_i2c_regmap = {
2388 .reg_bits = 32,
2389 .val_bits = 16,
2390
2391 .max_register = ARIZONA_DSP1_STATUS_2,
2392 .readable_reg = wm5102_readable_register,
2393 .volatile_reg = wm5102_volatile_register,
2394
2395 .cache_type = REGCACHE_RBTREE,
2396 .reg_defaults = wm5102_reg_default,
2397 .num_reg_defaults = ARRAY_SIZE(wm5102_reg_default),
2398};
2399EXPORT_SYMBOL_GPL(wm5102_i2c_regmap);
diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c
new file mode 100644
index 000000000000..bd8782c8896b
--- /dev/null
+++ b/drivers/mfd/wm5110-tables.c
@@ -0,0 +1,2281 @@
1/*
2 * wm5110-tables.c -- WM5110 data tables
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14
15#include <linux/mfd/arizona/core.h>
16#include <linux/mfd/arizona/registers.h>
17
18#include "arizona.h"
19
20#define WM5110_NUM_AOD_ISR 2
21#define WM5110_NUM_ISR 5
22
23static const struct reg_default wm5110_reva_patch[] = {
24 { 0x80, 0x3 },
25 { 0x44, 0x20 },
26 { 0x45, 0x40 },
27 { 0x46, 0x60 },
28 { 0x47, 0x80 },
29 { 0x48, 0xa0 },
30 { 0x51, 0x13 },
31 { 0x52, 0x33 },
32 { 0x53, 0x53 },
33 { 0x54, 0x73 },
34 { 0x55, 0x75 },
35 { 0x56, 0xb3 },
36 { 0x2ef, 0x124 },
37 { 0x2ef, 0x124 },
38 { 0x2f0, 0x124 },
39 { 0x2f0, 0x124 },
40 { 0x2f1, 0x124 },
41 { 0x2f1, 0x124 },
42 { 0x2f2, 0x124 },
43 { 0x2f2, 0x124 },
44 { 0x2f3, 0x124 },
45 { 0x2f3, 0x124 },
46 { 0x2f4, 0x124 },
47 { 0x2f4, 0x124 },
48 { 0x2eb, 0x60 },
49 { 0x2ec, 0x60 },
50 { 0x2ed, 0x60 },
51 { 0xc30, 0x3e3e },
52 { 0xc30, 0x3e3e },
53 { 0xc31, 0x3e },
54 { 0xc32, 0x3e3e },
55 { 0xc32, 0x3e3e },
56 { 0xc33, 0x3e3e },
57 { 0xc33, 0x3e3e },
58 { 0xc34, 0x3e3e },
59 { 0xc34, 0x3e3e },
60 { 0xc35, 0x3e3e },
61 { 0xc35, 0x3e3e },
62 { 0xc36, 0x3e3e },
63 { 0xc36, 0x3e3e },
64 { 0xc37, 0x3e3e },
65 { 0xc37, 0x3e3e },
66 { 0xc38, 0x3e3e },
67 { 0xc38, 0x3e3e },
68 { 0xc30, 0x3e3e },
69 { 0xc30, 0x3e3e },
70 { 0xc39, 0x3e3e },
71 { 0xc39, 0x3e3e },
72 { 0xc3a, 0x3e3e },
73 { 0xc3a, 0x3e3e },
74 { 0xc3b, 0x3e3e },
75 { 0xc3b, 0x3e3e },
76 { 0xc3c, 0x3e },
77 { 0x201, 0x18a5 },
78 { 0x201, 0x18a5 },
79 { 0x201, 0x18a5 },
80 { 0x202, 0x4100 },
81 { 0x460, 0xc00 },
82 { 0x461, 0x8000 },
83 { 0x462, 0xc01 },
84 { 0x463, 0x50f0 },
85 { 0x464, 0xc01 },
86 { 0x465, 0x4820 },
87 { 0x466, 0xc01 },
88 { 0x466, 0xc01 },
89 { 0x467, 0x4040 },
90 { 0x468, 0xc01 },
91 { 0x468, 0xc01 },
92 { 0x469, 0x3940 },
93 { 0x46a, 0xc01 },
94 { 0x46a, 0xc01 },
95 { 0x46a, 0xc01 },
96 { 0x46b, 0x3310 },
97 { 0x46c, 0x801 },
98 { 0x46c, 0x801 },
99 { 0x46d, 0x2d80 },
100 { 0x46e, 0x801 },
101 { 0x46e, 0x801 },
102 { 0x46f, 0x2890 },
103 { 0x470, 0x801 },
104 { 0x470, 0x801 },
105 { 0x471, 0x1990 },
106 { 0x472, 0x801 },
107 { 0x472, 0x801 },
108 { 0x473, 0x1450 },
109 { 0x474, 0x801 },
110 { 0x474, 0x801 },
111 { 0x474, 0x801 },
112 { 0x475, 0x1020 },
113 { 0x476, 0x801 },
114 { 0x476, 0x801 },
115 { 0x476, 0x801 },
116 { 0x477, 0xcd0 },
117 { 0x478, 0x806 },
118 { 0x478, 0x806 },
119 { 0x479, 0xa30 },
120 { 0x47a, 0x806 },
121 { 0x47a, 0x806 },
122 { 0x47b, 0x810 },
123 { 0x47c, 0x80e },
124 { 0x47c, 0x80e },
125 { 0x47d, 0x510 },
126 { 0x47e, 0x81f },
127 { 0x47e, 0x81f },
128 { 0x2DB, 0x0A00 },
129 { 0x2DD, 0x0023 },
130 { 0x2DF, 0x0102 },
131 { 0x80, 0x0 },
132 { 0xC20, 0x0002 },
133 { 0x209, 0x002A },
134};
135
136/* We use a function so we can use ARRAY_SIZE() */
137int wm5110_patch(struct arizona *arizona)
138{
139 switch (arizona->rev) {
140 case 0:
141 case 1:
142 return regmap_register_patch(arizona->regmap,
143 wm5110_reva_patch,
144 ARRAY_SIZE(wm5110_reva_patch));
145 default:
146 return 0;
147 }
148}
149EXPORT_SYMBOL_GPL(wm5110_patch);
150
151static const struct regmap_irq wm5110_aod_irqs[ARIZONA_NUM_IRQ] = {
152 [ARIZONA_IRQ_GP5_FALL] = { .mask = ARIZONA_GP5_FALL_EINT1 },
153 [ARIZONA_IRQ_GP5_RISE] = { .mask = ARIZONA_GP5_RISE_EINT1 },
154 [ARIZONA_IRQ_JD_FALL] = { .mask = ARIZONA_JD1_FALL_EINT1 },
155 [ARIZONA_IRQ_JD_RISE] = { .mask = ARIZONA_JD1_RISE_EINT1 },
156};
157
158const struct regmap_irq_chip wm5110_aod = {
159 .name = "wm5110 AOD",
160 .status_base = ARIZONA_AOD_IRQ1,
161 .mask_base = ARIZONA_AOD_IRQ_MASK_IRQ1,
162 .ack_base = ARIZONA_AOD_IRQ1,
163 .wake_base = ARIZONA_WAKE_CONTROL,
164 .num_regs = 1,
165 .irqs = wm5110_aod_irqs,
166 .num_irqs = ARRAY_SIZE(wm5110_aod_irqs),
167};
168EXPORT_SYMBOL_GPL(wm5110_aod);
169
170static const struct regmap_irq wm5110_irqs[ARIZONA_NUM_IRQ] = {
171 [ARIZONA_IRQ_GP4] = { .reg_offset = 0, .mask = ARIZONA_GP4_EINT1 },
172 [ARIZONA_IRQ_GP3] = { .reg_offset = 0, .mask = ARIZONA_GP3_EINT1 },
173 [ARIZONA_IRQ_GP2] = { .reg_offset = 0, .mask = ARIZONA_GP2_EINT1 },
174 [ARIZONA_IRQ_GP1] = { .reg_offset = 0, .mask = ARIZONA_GP1_EINT1 },
175
176 [ARIZONA_IRQ_DSP4_RAM_RDY] = {
177 .reg_offset = 1, .mask = ARIZONA_DSP4_RAM_RDY_EINT1
178 },
179 [ARIZONA_IRQ_DSP3_RAM_RDY] = {
180 .reg_offset = 1, .mask = ARIZONA_DSP3_RAM_RDY_EINT1
181 },
182 [ARIZONA_IRQ_DSP2_RAM_RDY] = {
183 .reg_offset = 1, .mask = ARIZONA_DSP2_RAM_RDY_EINT1
184 },
185 [ARIZONA_IRQ_DSP1_RAM_RDY] = {
186 .reg_offset = 1, .mask = ARIZONA_DSP1_RAM_RDY_EINT1
187 },
188 [ARIZONA_IRQ_DSP_IRQ8] = {
189 .reg_offset = 1, .mask = ARIZONA_DSP_IRQ8_EINT1
190 },
191 [ARIZONA_IRQ_DSP_IRQ7] = {
192 .reg_offset = 1, .mask = ARIZONA_DSP_IRQ7_EINT1
193 },
194 [ARIZONA_IRQ_DSP_IRQ6] = {
195 .reg_offset = 1, .mask = ARIZONA_DSP_IRQ6_EINT1
196 },
197 [ARIZONA_IRQ_DSP_IRQ5] = {
198 .reg_offset = 1, .mask = ARIZONA_DSP_IRQ5_EINT1
199 },
200 [ARIZONA_IRQ_DSP_IRQ4] = {
201 .reg_offset = 1, .mask = ARIZONA_DSP_IRQ4_EINT1
202 },
203 [ARIZONA_IRQ_DSP_IRQ3] = {
204 .reg_offset = 1, .mask = ARIZONA_DSP_IRQ3_EINT1
205 },
206 [ARIZONA_IRQ_DSP_IRQ2] = {
207 .reg_offset = 1, .mask = ARIZONA_DSP_IRQ2_EINT1
208 },
209 [ARIZONA_IRQ_DSP_IRQ1] = {
210 .reg_offset = 1, .mask = ARIZONA_DSP_IRQ1_EINT1
211 },
212
213 [ARIZONA_IRQ_SPK_SHUTDOWN_WARN] = {
214 .reg_offset = 2, .mask = ARIZONA_SPK_SHUTDOWN_WARN_EINT1
215 },
216 [ARIZONA_IRQ_SPK_SHUTDOWN] = {
217 .reg_offset = 2, .mask = ARIZONA_SPK_SHUTDOWN_EINT1
218 },
219 [ARIZONA_IRQ_HPDET] = {
220 .reg_offset = 2, .mask = ARIZONA_HPDET_EINT1
221 },
222 [ARIZONA_IRQ_MICDET] = {
223 .reg_offset = 2, .mask = ARIZONA_MICDET_EINT1
224 },
225 [ARIZONA_IRQ_WSEQ_DONE] = {
226 .reg_offset = 2, .mask = ARIZONA_WSEQ_DONE_EINT1
227 },
228 [ARIZONA_IRQ_DRC2_SIG_DET] = {
229 .reg_offset = 2, .mask = ARIZONA_DRC2_SIG_DET_EINT1
230 },
231 [ARIZONA_IRQ_DRC1_SIG_DET] = {
232 .reg_offset = 2, .mask = ARIZONA_DRC1_SIG_DET_EINT1
233 },
234 [ARIZONA_IRQ_ASRC2_LOCK] = {
235 .reg_offset = 2, .mask = ARIZONA_ASRC2_LOCK_EINT1
236 },
237 [ARIZONA_IRQ_ASRC1_LOCK] = {
238 .reg_offset = 2, .mask = ARIZONA_ASRC1_LOCK_EINT1
239 },
240 [ARIZONA_IRQ_UNDERCLOCKED] = {
241 .reg_offset = 2, .mask = ARIZONA_UNDERCLOCKED_EINT1
242 },
243 [ARIZONA_IRQ_OVERCLOCKED] = {
244 .reg_offset = 2, .mask = ARIZONA_OVERCLOCKED_EINT1
245 },
246 [ARIZONA_IRQ_FLL2_LOCK] = {
247 .reg_offset = 2, .mask = ARIZONA_FLL2_LOCK_EINT1
248 },
249 [ARIZONA_IRQ_FLL1_LOCK] = {
250 .reg_offset = 2, .mask = ARIZONA_FLL1_LOCK_EINT1
251 },
252 [ARIZONA_IRQ_CLKGEN_ERR] = {
253 .reg_offset = 2, .mask = ARIZONA_CLKGEN_ERR_EINT1
254 },
255 [ARIZONA_IRQ_CLKGEN_ERR_ASYNC] = {
256 .reg_offset = 2, .mask = ARIZONA_CLKGEN_ERR_ASYNC_EINT1
257 },
258
259 [ARIZONA_IRQ_ASRC_CFG_ERR] = {
260 .reg_offset = 3, .mask = ARIZONA_ASRC_CFG_ERR_EINT1
261 },
262 [ARIZONA_IRQ_AIF3_ERR] = {
263 .reg_offset = 3, .mask = ARIZONA_AIF3_ERR_EINT1
264 },
265 [ARIZONA_IRQ_AIF2_ERR] = {
266 .reg_offset = 3, .mask = ARIZONA_AIF2_ERR_EINT1
267 },
268 [ARIZONA_IRQ_AIF1_ERR] = {
269 .reg_offset = 3, .mask = ARIZONA_AIF1_ERR_EINT1
270 },
271 [ARIZONA_IRQ_CTRLIF_ERR] = {
272 .reg_offset = 3, .mask = ARIZONA_CTRLIF_ERR_EINT1
273 },
274 [ARIZONA_IRQ_MIXER_DROPPED_SAMPLES] = {
275 .reg_offset = 3, .mask = ARIZONA_MIXER_DROPPED_SAMPLE_EINT1
276 },
277 [ARIZONA_IRQ_ASYNC_CLK_ENA_LOW] = {
278 .reg_offset = 3, .mask = ARIZONA_ASYNC_CLK_ENA_LOW_EINT1
279 },
280 [ARIZONA_IRQ_SYSCLK_ENA_LOW] = {
281 .reg_offset = 3, .mask = ARIZONA_SYSCLK_ENA_LOW_EINT1
282 },
283 [ARIZONA_IRQ_ISRC1_CFG_ERR] = {
284 .reg_offset = 3, .mask = ARIZONA_ISRC1_CFG_ERR_EINT1
285 },
286 [ARIZONA_IRQ_ISRC2_CFG_ERR] = {
287 .reg_offset = 3, .mask = ARIZONA_ISRC2_CFG_ERR_EINT1
288 },
289
290 [ARIZONA_IRQ_BOOT_DONE] = {
291 .reg_offset = 4, .mask = ARIZONA_BOOT_DONE_EINT1
292 },
293 [ARIZONA_IRQ_DCS_DAC_DONE] = {
294 .reg_offset = 4, .mask = ARIZONA_DCS_DAC_DONE_EINT1
295 },
296 [ARIZONA_IRQ_DCS_HP_DONE] = {
297 .reg_offset = 4, .mask = ARIZONA_DCS_HP_DONE_EINT1
298 },
299 [ARIZONA_IRQ_FLL2_CLOCK_OK] = {
300 .reg_offset = 4, .mask = ARIZONA_FLL2_CLOCK_OK_EINT1
301 },
302 [ARIZONA_IRQ_FLL1_CLOCK_OK] = {
303 .reg_offset = 4, .mask = ARIZONA_FLL1_CLOCK_OK_EINT1
304 },
305};
306
307const struct regmap_irq_chip wm5110_irq = {
308 .name = "wm5110 IRQ",
309 .status_base = ARIZONA_INTERRUPT_STATUS_1,
310 .mask_base = ARIZONA_INTERRUPT_STATUS_1_MASK,
311 .ack_base = ARIZONA_INTERRUPT_STATUS_1,
312 .num_regs = 5,
313 .irqs = wm5110_irqs,
314 .num_irqs = ARRAY_SIZE(wm5110_irqs),
315};
316EXPORT_SYMBOL_GPL(wm5110_irq);
317
318static const struct reg_default wm5110_reg_default[] = {
319 { 0x00000008, 0x0019 }, /* R8 - Ctrl IF SPI CFG 1 */
320 { 0x00000009, 0x0001 }, /* R9 - Ctrl IF I2C1 CFG 1 */
321 { 0x0000000A, 0x0001 }, /* R10 - Ctrl IF I2C2 CFG 1 */
322 { 0x0000000B, 0x0036 }, /* R11 - Ctrl IF I2C1 CFG 2 */
323 { 0x0000000C, 0x0036 }, /* R12 - Ctrl IF I2C2 CFG 2 */
324 { 0x00000016, 0x0000 }, /* R22 - Write Sequencer Ctrl 0 */
325 { 0x00000017, 0x0000 }, /* R23 - Write Sequencer Ctrl 1 */
326 { 0x00000018, 0x0000 }, /* R24 - Write Sequencer Ctrl 2 */
327 { 0x00000020, 0x0000 }, /* R32 - Tone Generator 1 */
328 { 0x00000021, 0x1000 }, /* R33 - Tone Generator 2 */
329 { 0x00000022, 0x0000 }, /* R34 - Tone Generator 3 */
330 { 0x00000023, 0x1000 }, /* R35 - Tone Generator 4 */
331 { 0x00000024, 0x0000 }, /* R36 - Tone Generator 5 */
332 { 0x00000030, 0x0000 }, /* R48 - PWM Drive 1 */
333 { 0x00000031, 0x0100 }, /* R49 - PWM Drive 2 */
334 { 0x00000032, 0x0100 }, /* R50 - PWM Drive 3 */
335 { 0x00000040, 0x0000 }, /* R64 - Wake control */
336 { 0x00000041, 0x0000 }, /* R65 - Sequence control */
337 { 0x00000061, 0x01FF }, /* R97 - Sample Rate Sequence Select 1 */
338 { 0x00000062, 0x01FF }, /* R98 - Sample Rate Sequence Select 2 */
339 { 0x00000063, 0x01FF }, /* R99 - Sample Rate Sequence Select 3 */
340 { 0x00000064, 0x01FF }, /* R100 - Sample Rate Sequence Select 4 */
341 { 0x00000068, 0x01FF }, /* R104 - Always On Triggers Sequence Select 1 */
342 { 0x00000069, 0x01FF }, /* R105 - Always On Triggers Sequence Select 2 */
343 { 0x0000006A, 0x01FF }, /* R106 - Always On Triggers Sequence Select 3 */
344 { 0x0000006B, 0x01FF }, /* R107 - Always On Triggers Sequence Select 4 */
345 { 0x00000070, 0x0000 }, /* R112 - Comfort Noise Generator */
346 { 0x00000090, 0x0000 }, /* R144 - Haptics Control 1 */
347 { 0x00000091, 0x7FFF }, /* R145 - Haptics Control 2 */
348 { 0x00000092, 0x0000 }, /* R146 - Haptics phase 1 intensity */
349 { 0x00000093, 0x0000 }, /* R147 - Haptics phase 1 duration */
350 { 0x00000094, 0x0000 }, /* R148 - Haptics phase 2 intensity */
351 { 0x00000095, 0x0000 }, /* R149 - Haptics phase 2 duration */
352 { 0x00000096, 0x0000 }, /* R150 - Haptics phase 3 intensity */
353 { 0x00000097, 0x0000 }, /* R151 - Haptics phase 3 duration */
354 { 0x00000100, 0x0001 }, /* R256 - Clock 32k 1 */
355 { 0x00000101, 0x0504 }, /* R257 - System Clock 1 */
356 { 0x00000102, 0x0011 }, /* R258 - Sample rate 1 */
357 { 0x00000103, 0x0011 }, /* R259 - Sample rate 2 */
358 { 0x00000104, 0x0011 }, /* R260 - Sample rate 3 */
359 { 0x00000112, 0x0305 }, /* R274 - Async clock 1 */
360 { 0x00000113, 0x0011 }, /* R275 - Async sample rate 1 */
361 { 0x00000149, 0x0000 }, /* R329 - Output system clock */
362 { 0x0000014A, 0x0000 }, /* R330 - Output async clock */
363 { 0x00000152, 0x0000 }, /* R338 - Rate Estimator 1 */
364 { 0x00000153, 0x0000 }, /* R339 - Rate Estimator 2 */
365 { 0x00000154, 0x0000 }, /* R340 - Rate Estimator 3 */
366 { 0x00000155, 0x0000 }, /* R341 - Rate Estimator 4 */
367 { 0x00000156, 0x0000 }, /* R342 - Rate Estimator 5 */
368 { 0x00000171, 0x0000 }, /* R369 - FLL1 Control 1 */
369 { 0x00000172, 0x0008 }, /* R370 - FLL1 Control 2 */
370 { 0x00000173, 0x0018 }, /* R371 - FLL1 Control 3 */
371 { 0x00000174, 0x007D }, /* R372 - FLL1 Control 4 */
372 { 0x00000175, 0x0006 }, /* R373 - FLL1 Control 5 */
373 { 0x00000176, 0x0000 }, /* R374 - FLL1 Control 6 */
374 { 0x00000177, 0x0281 }, /* R375 - FLL1 Loop Filter Test 1 */
375 { 0x00000178, 0x0000 }, /* R376 - FLL1 NCO Test 0 */
376 { 0x00000181, 0x0000 }, /* R385 - FLL1 Synchroniser 1 */
377 { 0x00000182, 0x0000 }, /* R386 - FLL1 Synchroniser 2 */
378 { 0x00000183, 0x0000 }, /* R387 - FLL1 Synchroniser 3 */
379 { 0x00000184, 0x0000 }, /* R388 - FLL1 Synchroniser 4 */
380 { 0x00000185, 0x0000 }, /* R389 - FLL1 Synchroniser 5 */
381 { 0x00000186, 0x0000 }, /* R390 - FLL1 Synchroniser 6 */
382 { 0x00000189, 0x0000 }, /* R393 - FLL1 Spread Spectrum */
383 { 0x0000018A, 0x0004 }, /* R394 - FLL1 GPIO Clock */
384 { 0x00000191, 0x0000 }, /* R401 - FLL2 Control 1 */
385 { 0x00000192, 0x0008 }, /* R402 - FLL2 Control 2 */
386 { 0x00000193, 0x0018 }, /* R403 - FLL2 Control 3 */
387 { 0x00000194, 0x007D }, /* R404 - FLL2 Control 4 */
388 { 0x00000195, 0x000C }, /* R405 - FLL2 Control 5 */
389 { 0x00000196, 0x0000 }, /* R406 - FLL2 Control 6 */
390 { 0x00000197, 0x0000 }, /* R407 - FLL2 Loop Filter Test 1 */
391 { 0x00000198, 0x0000 }, /* R408 - FLL2 NCO Test 0 */
392 { 0x000001A1, 0x0000 }, /* R417 - FLL2 Synchroniser 1 */
393 { 0x000001A2, 0x0000 }, /* R418 - FLL2 Synchroniser 2 */
394 { 0x000001A3, 0x0000 }, /* R419 - FLL2 Synchroniser 3 */
395 { 0x000001A4, 0x0000 }, /* R420 - FLL2 Synchroniser 4 */
396 { 0x000001A5, 0x0000 }, /* R421 - FLL2 Synchroniser 5 */
397 { 0x000001A6, 0x0000 }, /* R422 - FLL2 Synchroniser 6 */
398 { 0x000001A9, 0x0000 }, /* R425 - FLL2 Spread Spectrum */
399 { 0x000001AA, 0x0004 }, /* R426 - FLL2 GPIO Clock */
400 { 0x00000200, 0x0006 }, /* R512 - Mic Charge Pump 1 */
401 { 0x00000210, 0x0184 }, /* R528 - LDO1 Control 1 */
402 { 0x00000213, 0x0344 }, /* R531 - LDO2 Control 1 */
403 { 0x00000218, 0x01A6 }, /* R536 - Mic Bias Ctrl 1 */
404 { 0x00000219, 0x01A6 }, /* R537 - Mic Bias Ctrl 2 */
405 { 0x0000021A, 0x01A6 }, /* R538 - Mic Bias Ctrl 3 */
406 { 0x00000293, 0x0000 }, /* R659 - Accessory Detect Mode 1 */
407 { 0x0000029B, 0x0020 }, /* R667 - Headphone Detect 1 */
408 { 0x0000029C, 0x0000 }, /* R668 - Headphone Detect 2 */
409 { 0x000002A3, 0x1102 }, /* R675 - Mic Detect 1 */
410 { 0x000002A4, 0x009F }, /* R676 - Mic Detect 2 */
411 { 0x000002C3, 0x0000 }, /* R707 - Mic noise mix control 1 */
412 { 0x000002D3, 0x0000 }, /* R723 - Jack detect analogue */
413 { 0x00000300, 0x0000 }, /* R768 - Input Enables */
414 { 0x00000308, 0x0000 }, /* R776 - Input Rate */
415 { 0x00000309, 0x0022 }, /* R777 - Input Volume Ramp */
416 { 0x00000310, 0x2080 }, /* R784 - IN1L Control */
417 { 0x00000311, 0x0180 }, /* R785 - ADC Digital Volume 1L */
418 { 0x00000312, 0x0000 }, /* R786 - DMIC1L Control */
419 { 0x00000314, 0x0080 }, /* R788 - IN1R Control */
420 { 0x00000315, 0x0180 }, /* R789 - ADC Digital Volume 1R */
421 { 0x00000316, 0x0000 }, /* R790 - DMIC1R Control */
422 { 0x00000318, 0x2080 }, /* R792 - IN2L Control */
423 { 0x00000319, 0x0180 }, /* R793 - ADC Digital Volume 2L */
424 { 0x0000031A, 0x0000 }, /* R794 - DMIC2L Control */
425 { 0x0000031C, 0x0080 }, /* R796 - IN2R Control */
426 { 0x0000031D, 0x0180 }, /* R797 - ADC Digital Volume 2R */
427 { 0x0000031E, 0x0000 }, /* R798 - DMIC2R Control */
428 { 0x00000320, 0x2080 }, /* R800 - IN3L Control */
429 { 0x00000321, 0x0180 }, /* R801 - ADC Digital Volume 3L */
430 { 0x00000322, 0x0000 }, /* R802 - DMIC3L Control */
431 { 0x00000324, 0x0080 }, /* R804 - IN3R Control */
432 { 0x00000325, 0x0180 }, /* R805 - ADC Digital Volume 3R */
433 { 0x00000326, 0x0000 }, /* R806 - DMIC3R Control */
434 { 0x00000328, 0x2000 }, /* R808 - IN4L Control */
435 { 0x00000329, 0x0180 }, /* R809 - ADC Digital Volume 4L */
436 { 0x0000032A, 0x0000 }, /* R810 - DMIC4L Control */
437 { 0x0000032D, 0x0180 }, /* R813 - ADC Digital Volume 4R */
438 { 0x0000032E, 0x0000 }, /* R814 - DMIC4R Control */
439 { 0x00000400, 0x0000 }, /* R1024 - Output Enables 1 */
440 { 0x00000408, 0x0000 }, /* R1032 - Output Rate 1 */
441 { 0x00000409, 0x0022 }, /* R1033 - Output Volume Ramp */
442 { 0x00000410, 0x0080 }, /* R1040 - Output Path Config 1L */
443 { 0x00000411, 0x0180 }, /* R1041 - DAC Digital Volume 1L */
444 { 0x00000412, 0x0080 }, /* R1042 - DAC Volume Limit 1L */
445 { 0x00000413, 0x0001 }, /* R1043 - Noise Gate Select 1L */
446 { 0x00000414, 0x0080 }, /* R1044 - Output Path Config 1R */
447 { 0x00000415, 0x0180 }, /* R1045 - DAC Digital Volume 1R */
448 { 0x00000416, 0x0080 }, /* R1046 - DAC Volume Limit 1R */
449 { 0x00000417, 0x0002 }, /* R1047 - Noise Gate Select 1R */
450 { 0x00000418, 0x0080 }, /* R1048 - Output Path Config 2L */
451 { 0x00000419, 0x0180 }, /* R1049 - DAC Digital Volume 2L */
452 { 0x0000041A, 0x0080 }, /* R1050 - DAC Volume Limit 2L */
453 { 0x0000041B, 0x0004 }, /* R1051 - Noise Gate Select 2L */
454 { 0x0000041C, 0x0080 }, /* R1052 - Output Path Config 2R */
455 { 0x0000041D, 0x0180 }, /* R1053 - DAC Digital Volume 2R */
456 { 0x0000041E, 0x0080 }, /* R1054 - DAC Volume Limit 2R */
457 { 0x0000041F, 0x0008 }, /* R1055 - Noise Gate Select 2R */
458 { 0x00000420, 0x0080 }, /* R1056 - Output Path Config 3L */
459 { 0x00000421, 0x0180 }, /* R1057 - DAC Digital Volume 3L */
460 { 0x00000422, 0x0080 }, /* R1058 - DAC Volume Limit 3L */
461 { 0x00000423, 0x0010 }, /* R1059 - Noise Gate Select 3L */
462 { 0x00000424, 0x0080 }, /* R1060 - Output Path Config 3R */
463 { 0x00000425, 0x0180 }, /* R1061 - DAC Digital Volume 3R */
464 { 0x00000426, 0x0080 }, /* R1062 - DAC Volume Limit 3R */
465 { 0x00000427, 0x0020 }, /* R1063 - Noise Gate Select 3R */
466 { 0x00000428, 0x0000 }, /* R1064 - Output Path Config 4L */
467 { 0x00000429, 0x0180 }, /* R1065 - DAC Digital Volume 4L */
468 { 0x0000042A, 0x0080 }, /* R1066 - Out Volume 4L */
469 { 0x0000042B, 0x0040 }, /* R1067 - Noise Gate Select 4L */
470 { 0x0000042C, 0x0000 }, /* R1068 - Output Path Config 4R */
471 { 0x0000042D, 0x0180 }, /* R1069 - DAC Digital Volume 4R */
472 { 0x0000042E, 0x0080 }, /* R1070 - Out Volume 4R */
473 { 0x0000042F, 0x0080 }, /* R1071 - Noise Gate Select 4R */
474 { 0x00000430, 0x0000 }, /* R1072 - Output Path Config 5L */
475 { 0x00000431, 0x0180 }, /* R1073 - DAC Digital Volume 5L */
476 { 0x00000432, 0x0080 }, /* R1074 - DAC Volume Limit 5L */
477 { 0x00000433, 0x0100 }, /* R1075 - Noise Gate Select 5L */
478 { 0x00000434, 0x0000 }, /* R1076 - Output Path Config 5R */
479 { 0x00000435, 0x0180 }, /* R1077 - DAC Digital Volume 5R */
480 { 0x00000436, 0x0080 }, /* R1078 - DAC Volume Limit 5R */
481 { 0x00000437, 0x0200 }, /* R1079 - Noise Gate Select 5R */
482 { 0x00000438, 0x0000 }, /* R1080 - Output Path Config 6L */
483 { 0x00000439, 0x0180 }, /* R1081 - DAC Digital Volume 6L */
484 { 0x0000043A, 0x0080 }, /* R1082 - DAC Volume Limit 6L */
485 { 0x0000043B, 0x0400 }, /* R1083 - Noise Gate Select 6L */
486 { 0x0000043C, 0x0000 }, /* R1084 - Output Path Config 6R */
487 { 0x0000043D, 0x0180 }, /* R1085 - DAC Digital Volume 6R */
488 { 0x0000043E, 0x0080 }, /* R1086 - DAC Volume Limit 6R */
489 { 0x0000043F, 0x0800 }, /* R1087 - Noise Gate Select 6R */
490 { 0x00000450, 0x0000 }, /* R1104 - DAC AEC Control 1 */
491 { 0x00000458, 0x0001 }, /* R1112 - Noise Gate Control */
492 { 0x00000480, 0x0040 }, /* R1152 - Class W ANC Threshold 1 */
493 { 0x00000481, 0x0040 }, /* R1153 - Class W ANC Threshold 2 */
494 { 0x00000490, 0x0069 }, /* R1168 - PDM SPK1 CTRL 1 */
495 { 0x00000491, 0x0000 }, /* R1169 - PDM SPK1 CTRL 2 */
496 { 0x00000492, 0x0069 }, /* R1170 - PDM SPK2 CTRL 1 */
497 { 0x00000493, 0x0000 }, /* R1171 - PDM SPK2 CTRL 2 */
498 { 0x00000500, 0x000C }, /* R1280 - AIF1 BCLK Ctrl */
499 { 0x00000501, 0x0008 }, /* R1281 - AIF1 Tx Pin Ctrl */
500 { 0x00000502, 0x0000 }, /* R1282 - AIF1 Rx Pin Ctrl */
501 { 0x00000503, 0x0000 }, /* R1283 - AIF1 Rate Ctrl */
502 { 0x00000504, 0x0000 }, /* R1284 - AIF1 Format */
503 { 0x00000505, 0x0040 }, /* R1285 - AIF1 Tx BCLK Rate */
504 { 0x00000506, 0x0040 }, /* R1286 - AIF1 Rx BCLK Rate */
505 { 0x00000507, 0x1818 }, /* R1287 - AIF1 Frame Ctrl 1 */
506 { 0x00000508, 0x1818 }, /* R1288 - AIF1 Frame Ctrl 2 */
507 { 0x00000509, 0x0000 }, /* R1289 - AIF1 Frame Ctrl 3 */
508 { 0x0000050A, 0x0001 }, /* R1290 - AIF1 Frame Ctrl 4 */
509 { 0x0000050B, 0x0002 }, /* R1291 - AIF1 Frame Ctrl 5 */
510 { 0x0000050C, 0x0003 }, /* R1292 - AIF1 Frame Ctrl 6 */
511 { 0x0000050D, 0x0004 }, /* R1293 - AIF1 Frame Ctrl 7 */
512 { 0x0000050E, 0x0005 }, /* R1294 - AIF1 Frame Ctrl 8 */
513 { 0x0000050F, 0x0006 }, /* R1295 - AIF1 Frame Ctrl 9 */
514 { 0x00000510, 0x0007 }, /* R1296 - AIF1 Frame Ctrl 10 */
515 { 0x00000511, 0x0000 }, /* R1297 - AIF1 Frame Ctrl 11 */
516 { 0x00000512, 0x0001 }, /* R1298 - AIF1 Frame Ctrl 12 */
517 { 0x00000513, 0x0002 }, /* R1299 - AIF1 Frame Ctrl 13 */
518 { 0x00000514, 0x0003 }, /* R1300 - AIF1 Frame Ctrl 14 */
519 { 0x00000515, 0x0004 }, /* R1301 - AIF1 Frame Ctrl 15 */
520 { 0x00000516, 0x0005 }, /* R1302 - AIF1 Frame Ctrl 16 */
521 { 0x00000517, 0x0006 }, /* R1303 - AIF1 Frame Ctrl 17 */
522 { 0x00000518, 0x0007 }, /* R1304 - AIF1 Frame Ctrl 18 */
523 { 0x00000519, 0x0000 }, /* R1305 - AIF1 Tx Enables */
524 { 0x0000051A, 0x0000 }, /* R1306 - AIF1 Rx Enables */
525 { 0x00000540, 0x000C }, /* R1344 - AIF2 BCLK Ctrl */
526 { 0x00000541, 0x0008 }, /* R1345 - AIF2 Tx Pin Ctrl */
527 { 0x00000542, 0x0000 }, /* R1346 - AIF2 Rx Pin Ctrl */
528 { 0x00000543, 0x0000 }, /* R1347 - AIF2 Rate Ctrl */
529 { 0x00000544, 0x0000 }, /* R1348 - AIF2 Format */
530 { 0x00000545, 0x0040 }, /* R1349 - AIF2 Tx BCLK Rate */
531 { 0x00000546, 0x0040 }, /* R1350 - AIF2 Rx BCLK Rate */
532 { 0x00000547, 0x1818 }, /* R1351 - AIF2 Frame Ctrl 1 */
533 { 0x00000548, 0x1818 }, /* R1352 - AIF2 Frame Ctrl 2 */
534 { 0x00000549, 0x0000 }, /* R1353 - AIF2 Frame Ctrl 3 */
535 { 0x0000054A, 0x0001 }, /* R1354 - AIF2 Frame Ctrl 4 */
536 { 0x00000551, 0x0000 }, /* R1361 - AIF2 Frame Ctrl 11 */
537 { 0x00000552, 0x0001 }, /* R1362 - AIF2 Frame Ctrl 12 */
538 { 0x00000559, 0x0000 }, /* R1369 - AIF2 Tx Enables */
539 { 0x0000055A, 0x0000 }, /* R1370 - AIF2 Rx Enables */
540 { 0x00000580, 0x000C }, /* R1408 - AIF3 BCLK Ctrl */
541 { 0x00000581, 0x0008 }, /* R1409 - AIF3 Tx Pin Ctrl */
542 { 0x00000582, 0x0000 }, /* R1410 - AIF3 Rx Pin Ctrl */
543 { 0x00000583, 0x0000 }, /* R1411 - AIF3 Rate Ctrl */
544 { 0x00000584, 0x0000 }, /* R1412 - AIF3 Format */
545 { 0x00000585, 0x0040 }, /* R1413 - AIF3 Tx BCLK Rate */
546 { 0x00000586, 0x0040 }, /* R1414 - AIF3 Rx BCLK Rate */
547 { 0x00000587, 0x1818 }, /* R1415 - AIF3 Frame Ctrl 1 */
548 { 0x00000588, 0x1818 }, /* R1416 - AIF3 Frame Ctrl 2 */
549 { 0x00000589, 0x0000 }, /* R1417 - AIF3 Frame Ctrl 3 */
550 { 0x0000058A, 0x0001 }, /* R1418 - AIF3 Frame Ctrl 4 */
551 { 0x00000591, 0x0000 }, /* R1425 - AIF3 Frame Ctrl 11 */
552 { 0x00000592, 0x0001 }, /* R1426 - AIF3 Frame Ctrl 12 */
553 { 0x00000599, 0x0000 }, /* R1433 - AIF3 Tx Enables */
554 { 0x0000059A, 0x0000 }, /* R1434 - AIF3 Rx Enables */
555 { 0x000005E3, 0x0004 }, /* R1507 - SLIMbus Framer Ref Gear */
556 { 0x000005E5, 0x0000 }, /* R1509 - SLIMbus Rates 1 */
557 { 0x000005E6, 0x0000 }, /* R1510 - SLIMbus Rates 2 */
558 { 0x000005E7, 0x0000 }, /* R1511 - SLIMbus Rates 3 */
559 { 0x000005E8, 0x0000 }, /* R1512 - SLIMbus Rates 4 */
560 { 0x000005E9, 0x0000 }, /* R1513 - SLIMbus Rates 5 */
561 { 0x000005EA, 0x0000 }, /* R1514 - SLIMbus Rates 6 */
562 { 0x000005EB, 0x0000 }, /* R1515 - SLIMbus Rates 7 */
563 { 0x000005EC, 0x0000 }, /* R1516 - SLIMbus Rates 8 */
564 { 0x000005F5, 0x0000 }, /* R1525 - SLIMbus RX Channel Enable */
565 { 0x000005F6, 0x0000 }, /* R1526 - SLIMbus TX Channel Enable */
566 { 0x00000640, 0x0000 }, /* R1600 - PWM1MIX Input 1 Source */
567 { 0x00000641, 0x0080 }, /* R1601 - PWM1MIX Input 1 Volume */
568 { 0x00000642, 0x0000 }, /* R1602 - PWM1MIX Input 2 Source */
569 { 0x00000643, 0x0080 }, /* R1603 - PWM1MIX Input 2 Volume */
570 { 0x00000644, 0x0000 }, /* R1604 - PWM1MIX Input 3 Source */
571 { 0x00000645, 0x0080 }, /* R1605 - PWM1MIX Input 3 Volume */
572 { 0x00000646, 0x0000 }, /* R1606 - PWM1MIX Input 4 Source */
573 { 0x00000647, 0x0080 }, /* R1607 - PWM1MIX Input 4 Volume */
574 { 0x00000648, 0x0000 }, /* R1608 - PWM2MIX Input 1 Source */
575 { 0x00000649, 0x0080 }, /* R1609 - PWM2MIX Input 1 Volume */
576 { 0x0000064A, 0x0000 }, /* R1610 - PWM2MIX Input 2 Source */
577 { 0x0000064B, 0x0080 }, /* R1611 - PWM2MIX Input 2 Volume */
578 { 0x0000064C, 0x0000 }, /* R1612 - PWM2MIX Input 3 Source */
579 { 0x0000064D, 0x0080 }, /* R1613 - PWM2MIX Input 3 Volume */
580 { 0x0000064E, 0x0000 }, /* R1614 - PWM2MIX Input 4 Source */
581 { 0x0000064F, 0x0080 }, /* R1615 - PWM2MIX Input 4 Volume */
582 { 0x00000660, 0x0000 }, /* R1632 - MICMIX Input 1 Source */
583 { 0x00000661, 0x0080 }, /* R1633 - MICMIX Input 1 Volume */
584 { 0x00000662, 0x0000 }, /* R1634 - MICMIX Input 2 Source */
585 { 0x00000663, 0x0080 }, /* R1635 - MICMIX Input 2 Volume */
586 { 0x00000664, 0x0000 }, /* R1636 - MICMIX Input 3 Source */
587 { 0x00000665, 0x0080 }, /* R1637 - MICMIX Input 3 Volume */
588 { 0x00000666, 0x0000 }, /* R1638 - MICMIX Input 4 Source */
589 { 0x00000667, 0x0080 }, /* R1639 - MICMIX Input 4 Volume */
590 { 0x00000668, 0x0000 }, /* R1640 - NOISEMIX Input 1 Source */
591 { 0x00000669, 0x0080 }, /* R1641 - NOISEMIX Input 1 Volume */
592 { 0x0000066A, 0x0000 }, /* R1642 - NOISEMIX Input 2 Source */
593 { 0x0000066B, 0x0080 }, /* R1643 - NOISEMIX Input 2 Volume */
594 { 0x0000066C, 0x0000 }, /* R1644 - NOISEMIX Input 3 Source */
595 { 0x0000066D, 0x0080 }, /* R1645 - NOISEMIX Input 3 Volume */
596 { 0x0000066E, 0x0000 }, /* R1646 - NOISEMIX Input 4 Source */
597 { 0x0000066F, 0x0080 }, /* R1647 - NOISEMIX Input 4 Volume */
598 { 0x00000680, 0x0000 }, /* R1664 - OUT1LMIX Input 1 Source */
599 { 0x00000681, 0x0080 }, /* R1665 - OUT1LMIX Input 1 Volume */
600 { 0x00000682, 0x0000 }, /* R1666 - OUT1LMIX Input 2 Source */
601 { 0x00000683, 0x0080 }, /* R1667 - OUT1LMIX Input 2 Volume */
602 { 0x00000684, 0x0000 }, /* R1668 - OUT1LMIX Input 3 Source */
603 { 0x00000685, 0x0080 }, /* R1669 - OUT1LMIX Input 3 Volume */
604 { 0x00000686, 0x0000 }, /* R1670 - OUT1LMIX Input 4 Source */
605 { 0x00000687, 0x0080 }, /* R1671 - OUT1LMIX Input 4 Volume */
606 { 0x00000688, 0x0000 }, /* R1672 - OUT1RMIX Input 1 Source */
607 { 0x00000689, 0x0080 }, /* R1673 - OUT1RMIX Input 1 Volume */
608 { 0x0000068A, 0x0000 }, /* R1674 - OUT1RMIX Input 2 Source */
609 { 0x0000068B, 0x0080 }, /* R1675 - OUT1RMIX Input 2 Volume */
610 { 0x0000068C, 0x0000 }, /* R1676 - OUT1RMIX Input 3 Source */
611 { 0x0000068D, 0x0080 }, /* R1677 - OUT1RMIX Input 3 Volume */
612 { 0x0000068E, 0x0000 }, /* R1678 - OUT1RMIX Input 4 Source */
613 { 0x0000068F, 0x0080 }, /* R1679 - OUT1RMIX Input 4 Volume */
614 { 0x00000690, 0x0000 }, /* R1680 - OUT2LMIX Input 1 Source */
615 { 0x00000691, 0x0080 }, /* R1681 - OUT2LMIX Input 1 Volume */
616 { 0x00000692, 0x0000 }, /* R1682 - OUT2LMIX Input 2 Source */
617 { 0x00000693, 0x0080 }, /* R1683 - OUT2LMIX Input 2 Volume */
618 { 0x00000694, 0x0000 }, /* R1684 - OUT2LMIX Input 3 Source */
619 { 0x00000695, 0x0080 }, /* R1685 - OUT2LMIX Input 3 Volume */
620 { 0x00000696, 0x0000 }, /* R1686 - OUT2LMIX Input 4 Source */
621 { 0x00000697, 0x0080 }, /* R1687 - OUT2LMIX Input 4 Volume */
622 { 0x00000698, 0x0000 }, /* R1688 - OUT2RMIX Input 1 Source */
623 { 0x00000699, 0x0080 }, /* R1689 - OUT2RMIX Input 1 Volume */
624 { 0x0000069A, 0x0000 }, /* R1690 - OUT2RMIX Input 2 Source */
625 { 0x0000069B, 0x0080 }, /* R1691 - OUT2RMIX Input 2 Volume */
626 { 0x0000069C, 0x0000 }, /* R1692 - OUT2RMIX Input 3 Source */
627 { 0x0000069D, 0x0080 }, /* R1693 - OUT2RMIX Input 3 Volume */
628 { 0x0000069E, 0x0000 }, /* R1694 - OUT2RMIX Input 4 Source */
629 { 0x0000069F, 0x0080 }, /* R1695 - OUT2RMIX Input 4 Volume */
630 { 0x000006A0, 0x0000 }, /* R1696 - OUT3LMIX Input 1 Source */
631 { 0x000006A1, 0x0080 }, /* R1697 - OUT3LMIX Input 1 Volume */
632 { 0x000006A2, 0x0000 }, /* R1698 - OUT3LMIX Input 2 Source */
633 { 0x000006A3, 0x0080 }, /* R1699 - OUT3LMIX Input 2 Volume */
634 { 0x000006A4, 0x0000 }, /* R1700 - OUT3LMIX Input 3 Source */
635 { 0x000006A5, 0x0080 }, /* R1701 - OUT3LMIX Input 3 Volume */
636 { 0x000006A6, 0x0000 }, /* R1702 - OUT3LMIX Input 4 Source */
637 { 0x000006A7, 0x0080 }, /* R1703 - OUT3LMIX Input 4 Volume */
638 { 0x000006A8, 0x0000 }, /* R1704 - OUT3RMIX Input 1 Source */
639 { 0x000006A9, 0x0080 }, /* R1705 - OUT3RMIX Input 1 Volume */
640 { 0x000006AA, 0x0000 }, /* R1706 - OUT3RMIX Input 2 Source */
641 { 0x000006AB, 0x0080 }, /* R1707 - OUT3RMIX Input 2 Volume */
642 { 0x000006AC, 0x0000 }, /* R1708 - OUT3RMIX Input 3 Source */
643 { 0x000006AD, 0x0080 }, /* R1709 - OUT3RMIX Input 3 Volume */
644 { 0x000006AE, 0x0000 }, /* R1710 - OUT3RMIX Input 4 Source */
645 { 0x000006AF, 0x0080 }, /* R1711 - OUT3RMIX Input 4 Volume */
646 { 0x000006B0, 0x0000 }, /* R1712 - OUT4LMIX Input 1 Source */
647 { 0x000006B1, 0x0080 }, /* R1713 - OUT4LMIX Input 1 Volume */
648 { 0x000006B2, 0x0000 }, /* R1714 - OUT4LMIX Input 2 Source */
649 { 0x000006B3, 0x0080 }, /* R1715 - OUT4LMIX Input 2 Volume */
650 { 0x000006B4, 0x0000 }, /* R1716 - OUT4LMIX Input 3 Source */
651 { 0x000006B5, 0x0080 }, /* R1717 - OUT4LMIX Input 3 Volume */
652 { 0x000006B6, 0x0000 }, /* R1718 - OUT4LMIX Input 4 Source */
653 { 0x000006B7, 0x0080 }, /* R1719 - OUT4LMIX Input 4 Volume */
654 { 0x000006B8, 0x0000 }, /* R1720 - OUT4RMIX Input 1 Source */
655 { 0x000006B9, 0x0080 }, /* R1721 - OUT4RMIX Input 1 Volume */
656 { 0x000006BA, 0x0000 }, /* R1722 - OUT4RMIX Input 2 Source */
657 { 0x000006BB, 0x0080 }, /* R1723 - OUT4RMIX Input 2 Volume */
658 { 0x000006BC, 0x0000 }, /* R1724 - OUT4RMIX Input 3 Source */
659 { 0x000006BD, 0x0080 }, /* R1725 - OUT4RMIX Input 3 Volume */
660 { 0x000006BE, 0x0000 }, /* R1726 - OUT4RMIX Input 4 Source */
661 { 0x000006BF, 0x0080 }, /* R1727 - OUT4RMIX Input 4 Volume */
662 { 0x000006C0, 0x0000 }, /* R1728 - OUT5LMIX Input 1 Source */
663 { 0x000006C1, 0x0080 }, /* R1729 - OUT5LMIX Input 1 Volume */
664 { 0x000006C2, 0x0000 }, /* R1730 - OUT5LMIX Input 2 Source */
665 { 0x000006C3, 0x0080 }, /* R1731 - OUT5LMIX Input 2 Volume */
666 { 0x000006C4, 0x0000 }, /* R1732 - OUT5LMIX Input 3 Source */
667 { 0x000006C5, 0x0080 }, /* R1733 - OUT5LMIX Input 3 Volume */
668 { 0x000006C6, 0x0000 }, /* R1734 - OUT5LMIX Input 4 Source */
669 { 0x000006C7, 0x0080 }, /* R1735 - OUT5LMIX Input 4 Volume */
670 { 0x000006C8, 0x0000 }, /* R1736 - OUT5RMIX Input 1 Source */
671 { 0x000006C9, 0x0080 }, /* R1737 - OUT5RMIX Input 1 Volume */
672 { 0x000006CA, 0x0000 }, /* R1738 - OUT5RMIX Input 2 Source */
673 { 0x000006CB, 0x0080 }, /* R1739 - OUT5RMIX Input 2 Volume */
674 { 0x000006CC, 0x0000 }, /* R1740 - OUT5RMIX Input 3 Source */
675 { 0x000006CD, 0x0080 }, /* R1741 - OUT5RMIX Input 3 Volume */
676 { 0x000006CE, 0x0000 }, /* R1742 - OUT5RMIX Input 4 Source */
677 { 0x000006CF, 0x0080 }, /* R1743 - OUT5RMIX Input 4 Volume */
678 { 0x000006D0, 0x0000 }, /* R1744 - OUT6LMIX Input 1 Source */
679 { 0x000006D1, 0x0080 }, /* R1745 - OUT6LMIX Input 1 Volume */
680 { 0x000006D2, 0x0000 }, /* R1746 - OUT6LMIX Input 2 Source */
681 { 0x000006D3, 0x0080 }, /* R1747 - OUT6LMIX Input 2 Volume */
682 { 0x000006D4, 0x0000 }, /* R1748 - OUT6LMIX Input 3 Source */
683 { 0x000006D5, 0x0080 }, /* R1749 - OUT6LMIX Input 3 Volume */
684 { 0x000006D6, 0x0000 }, /* R1750 - OUT6LMIX Input 4 Source */
685 { 0x000006D7, 0x0080 }, /* R1751 - OUT6LMIX Input 4 Volume */
686 { 0x000006D8, 0x0000 }, /* R1752 - OUT6RMIX Input 1 Source */
687 { 0x000006D9, 0x0080 }, /* R1753 - OUT6RMIX Input 1 Volume */
688 { 0x000006DA, 0x0000 }, /* R1754 - OUT6RMIX Input 2 Source */
689 { 0x000006DB, 0x0080 }, /* R1755 - OUT6RMIX Input 2 Volume */
690 { 0x000006DC, 0x0000 }, /* R1756 - OUT6RMIX Input 3 Source */
691 { 0x000006DD, 0x0080 }, /* R1757 - OUT6RMIX Input 3 Volume */
692 { 0x000006DE, 0x0000 }, /* R1758 - OUT6RMIX Input 4 Source */
693 { 0x000006DF, 0x0080 }, /* R1759 - OUT6RMIX Input 4 Volume */
694 { 0x00000700, 0x0000 }, /* R1792 - AIF1TX1MIX Input 1 Source */
695 { 0x00000701, 0x0080 }, /* R1793 - AIF1TX1MIX Input 1 Volume */
696 { 0x00000702, 0x0000 }, /* R1794 - AIF1TX1MIX Input 2 Source */
697 { 0x00000703, 0x0080 }, /* R1795 - AIF1TX1MIX Input 2 Volume */
698 { 0x00000704, 0x0000 }, /* R1796 - AIF1TX1MIX Input 3 Source */
699 { 0x00000705, 0x0080 }, /* R1797 - AIF1TX1MIX Input 3 Volume */
700 { 0x00000706, 0x0000 }, /* R1798 - AIF1TX1MIX Input 4 Source */
701 { 0x00000707, 0x0080 }, /* R1799 - AIF1TX1MIX Input 4 Volume */
702 { 0x00000708, 0x0000 }, /* R1800 - AIF1TX2MIX Input 1 Source */
703 { 0x00000709, 0x0080 }, /* R1801 - AIF1TX2MIX Input 1 Volume */
704 { 0x0000070A, 0x0000 }, /* R1802 - AIF1TX2MIX Input 2 Source */
705 { 0x0000070B, 0x0080 }, /* R1803 - AIF1TX2MIX Input 2 Volume */
706 { 0x0000070C, 0x0000 }, /* R1804 - AIF1TX2MIX Input 3 Source */
707 { 0x0000070D, 0x0080 }, /* R1805 - AIF1TX2MIX Input 3 Volume */
708 { 0x0000070E, 0x0000 }, /* R1806 - AIF1TX2MIX Input 4 Source */
709 { 0x0000070F, 0x0080 }, /* R1807 - AIF1TX2MIX Input 4 Volume */
710 { 0x00000710, 0x0000 }, /* R1808 - AIF1TX3MIX Input 1 Source */
711 { 0x00000711, 0x0080 }, /* R1809 - AIF1TX3MIX Input 1 Volume */
712 { 0x00000712, 0x0000 }, /* R1810 - AIF1TX3MIX Input 2 Source */
713 { 0x00000713, 0x0080 }, /* R1811 - AIF1TX3MIX Input 2 Volume */
714 { 0x00000714, 0x0000 }, /* R1812 - AIF1TX3MIX Input 3 Source */
715 { 0x00000715, 0x0080 }, /* R1813 - AIF1TX3MIX Input 3 Volume */
716 { 0x00000716, 0x0000 }, /* R1814 - AIF1TX3MIX Input 4 Source */
717 { 0x00000717, 0x0080 }, /* R1815 - AIF1TX3MIX Input 4 Volume */
718 { 0x00000718, 0x0000 }, /* R1816 - AIF1TX4MIX Input 1 Source */
719 { 0x00000719, 0x0080 }, /* R1817 - AIF1TX4MIX Input 1 Volume */
720 { 0x0000071A, 0x0000 }, /* R1818 - AIF1TX4MIX Input 2 Source */
721 { 0x0000071B, 0x0080 }, /* R1819 - AIF1TX4MIX Input 2 Volume */
722 { 0x0000071C, 0x0000 }, /* R1820 - AIF1TX4MIX Input 3 Source */
723 { 0x0000071D, 0x0080 }, /* R1821 - AIF1TX4MIX Input 3 Volume */
724 { 0x0000071E, 0x0000 }, /* R1822 - AIF1TX4MIX Input 4 Source */
725 { 0x0000071F, 0x0080 }, /* R1823 - AIF1TX4MIX Input 4 Volume */
726 { 0x00000720, 0x0000 }, /* R1824 - AIF1TX5MIX Input 1 Source */
727 { 0x00000721, 0x0080 }, /* R1825 - AIF1TX5MIX Input 1 Volume */
728 { 0x00000722, 0x0000 }, /* R1826 - AIF1TX5MIX Input 2 Source */
729 { 0x00000723, 0x0080 }, /* R1827 - AIF1TX5MIX Input 2 Volume */
730 { 0x00000724, 0x0000 }, /* R1828 - AIF1TX5MIX Input 3 Source */
731 { 0x00000725, 0x0080 }, /* R1829 - AIF1TX5MIX Input 3 Volume */
732 { 0x00000726, 0x0000 }, /* R1830 - AIF1TX5MIX Input 4 Source */
733 { 0x00000727, 0x0080 }, /* R1831 - AIF1TX5MIX Input 4 Volume */
734 { 0x00000728, 0x0000 }, /* R1832 - AIF1TX6MIX Input 1 Source */
735 { 0x00000729, 0x0080 }, /* R1833 - AIF1TX6MIX Input 1 Volume */
736 { 0x0000072A, 0x0000 }, /* R1834 - AIF1TX6MIX Input 2 Source */
737 { 0x0000072B, 0x0080 }, /* R1835 - AIF1TX6MIX Input 2 Volume */
738 { 0x0000072C, 0x0000 }, /* R1836 - AIF1TX6MIX Input 3 Source */
739 { 0x0000072D, 0x0080 }, /* R1837 - AIF1TX6MIX Input 3 Volume */
740 { 0x0000072E, 0x0000 }, /* R1838 - AIF1TX6MIX Input 4 Source */
741 { 0x0000072F, 0x0080 }, /* R1839 - AIF1TX6MIX Input 4 Volume */
742 { 0x00000730, 0x0000 }, /* R1840 - AIF1TX7MIX Input 1 Source */
743 { 0x00000731, 0x0080 }, /* R1841 - AIF1TX7MIX Input 1 Volume */
744 { 0x00000732, 0x0000 }, /* R1842 - AIF1TX7MIX Input 2 Source */
745 { 0x00000733, 0x0080 }, /* R1843 - AIF1TX7MIX Input 2 Volume */
746 { 0x00000734, 0x0000 }, /* R1844 - AIF1TX7MIX Input 3 Source */
747 { 0x00000735, 0x0080 }, /* R1845 - AIF1TX7MIX Input 3 Volume */
748 { 0x00000736, 0x0000 }, /* R1846 - AIF1TX7MIX Input 4 Source */
749 { 0x00000737, 0x0080 }, /* R1847 - AIF1TX7MIX Input 4 Volume */
750 { 0x00000738, 0x0000 }, /* R1848 - AIF1TX8MIX Input 1 Source */
751 { 0x00000739, 0x0080 }, /* R1849 - AIF1TX8MIX Input 1 Volume */
752 { 0x0000073A, 0x0000 }, /* R1850 - AIF1TX8MIX Input 2 Source */
753 { 0x0000073B, 0x0080 }, /* R1851 - AIF1TX8MIX Input 2 Volume */
754 { 0x0000073C, 0x0000 }, /* R1852 - AIF1TX8MIX Input 3 Source */
755 { 0x0000073D, 0x0080 }, /* R1853 - AIF1TX8MIX Input 3 Volume */
756 { 0x0000073E, 0x0000 }, /* R1854 - AIF1TX8MIX Input 4 Source */
757 { 0x0000073F, 0x0080 }, /* R1855 - AIF1TX8MIX Input 4 Volume */
758 { 0x00000740, 0x0000 }, /* R1856 - AIF2TX1MIX Input 1 Source */
759 { 0x00000741, 0x0080 }, /* R1857 - AIF2TX1MIX Input 1 Volume */
760 { 0x00000742, 0x0000 }, /* R1858 - AIF2TX1MIX Input 2 Source */
761 { 0x00000743, 0x0080 }, /* R1859 - AIF2TX1MIX Input 2 Volume */
762 { 0x00000744, 0x0000 }, /* R1860 - AIF2TX1MIX Input 3 Source */
763 { 0x00000745, 0x0080 }, /* R1861 - AIF2TX1MIX Input 3 Volume */
764 { 0x00000746, 0x0000 }, /* R1862 - AIF2TX1MIX Input 4 Source */
765 { 0x00000747, 0x0080 }, /* R1863 - AIF2TX1MIX Input 4 Volume */
766 { 0x00000748, 0x0000 }, /* R1864 - AIF2TX2MIX Input 1 Source */
767 { 0x00000749, 0x0080 }, /* R1865 - AIF2TX2MIX Input 1 Volume */
768 { 0x0000074A, 0x0000 }, /* R1866 - AIF2TX2MIX Input 2 Source */
769 { 0x0000074B, 0x0080 }, /* R1867 - AIF2TX2MIX Input 2 Volume */
770 { 0x0000074C, 0x0000 }, /* R1868 - AIF2TX2MIX Input 3 Source */
771 { 0x0000074D, 0x0080 }, /* R1869 - AIF2TX2MIX Input 3 Volume */
772 { 0x0000074E, 0x0000 }, /* R1870 - AIF2TX2MIX Input 4 Source */
773 { 0x0000074F, 0x0080 }, /* R1871 - AIF2TX2MIX Input 4 Volume */
774 { 0x00000780, 0x0000 }, /* R1920 - AIF3TX1MIX Input 1 Source */
775 { 0x00000781, 0x0080 }, /* R1921 - AIF3TX1MIX Input 1 Volume */
776 { 0x00000782, 0x0000 }, /* R1922 - AIF3TX1MIX Input 2 Source */
777 { 0x00000783, 0x0080 }, /* R1923 - AIF3TX1MIX Input 2 Volume */
778 { 0x00000784, 0x0000 }, /* R1924 - AIF3TX1MIX Input 3 Source */
779 { 0x00000785, 0x0080 }, /* R1925 - AIF3TX1MIX Input 3 Volume */
780 { 0x00000786, 0x0000 }, /* R1926 - AIF3TX1MIX Input 4 Source */
781 { 0x00000787, 0x0080 }, /* R1927 - AIF3TX1MIX Input 4 Volume */
782 { 0x00000788, 0x0000 }, /* R1928 - AIF3TX2MIX Input 1 Source */
783 { 0x00000789, 0x0080 }, /* R1929 - AIF3TX2MIX Input 1 Volume */
784 { 0x0000078A, 0x0000 }, /* R1930 - AIF3TX2MIX Input 2 Source */
785 { 0x0000078B, 0x0080 }, /* R1931 - AIF3TX2MIX Input 2 Volume */
786 { 0x0000078C, 0x0000 }, /* R1932 - AIF3TX2MIX Input 3 Source */
787 { 0x0000078D, 0x0080 }, /* R1933 - AIF3TX2MIX Input 3 Volume */
788 { 0x0000078E, 0x0000 }, /* R1934 - AIF3TX2MIX Input 4 Source */
789 { 0x0000078F, 0x0080 }, /* R1935 - AIF3TX2MIX Input 4 Volume */
790 { 0x000007C0, 0x0000 }, /* R1984 - SLIMTX1MIX Input 1 Source */
791 { 0x000007C1, 0x0080 }, /* R1985 - SLIMTX1MIX Input 1 Volume */
792 { 0x000007C2, 0x0000 }, /* R1986 - SLIMTX1MIX Input 2 Source */
793 { 0x000007C3, 0x0080 }, /* R1987 - SLIMTX1MIX Input 2 Volume */
794 { 0x000007C4, 0x0000 }, /* R1988 - SLIMTX1MIX Input 3 Source */
795 { 0x000007C5, 0x0080 }, /* R1989 - SLIMTX1MIX Input 3 Volume */
796 { 0x000007C6, 0x0000 }, /* R1990 - SLIMTX1MIX Input 4 Source */
797 { 0x000007C7, 0x0080 }, /* R1991 - SLIMTX1MIX Input 4 Volume */
798 { 0x000007C8, 0x0000 }, /* R1992 - SLIMTX2MIX Input 1 Source */
799 { 0x000007C9, 0x0080 }, /* R1993 - SLIMTX2MIX Input 1 Volume */
800 { 0x000007CA, 0x0000 }, /* R1994 - SLIMTX2MIX Input 2 Source */
801 { 0x000007CB, 0x0080 }, /* R1995 - SLIMTX2MIX Input 2 Volume */
802 { 0x000007CC, 0x0000 }, /* R1996 - SLIMTX2MIX Input 3 Source */
803 { 0x000007CD, 0x0080 }, /* R1997 - SLIMTX2MIX Input 3 Volume */
804 { 0x000007CE, 0x0000 }, /* R1998 - SLIMTX2MIX Input 4 Source */
805 { 0x000007CF, 0x0080 }, /* R1999 - SLIMTX2MIX Input 4 Volume */
806 { 0x000007D0, 0x0000 }, /* R2000 - SLIMTX3MIX Input 1 Source */
807 { 0x000007D1, 0x0080 }, /* R2001 - SLIMTX3MIX Input 1 Volume */
808 { 0x000007D2, 0x0000 }, /* R2002 - SLIMTX3MIX Input 2 Source */
809 { 0x000007D3, 0x0080 }, /* R2003 - SLIMTX3MIX Input 2 Volume */
810 { 0x000007D4, 0x0000 }, /* R2004 - SLIMTX3MIX Input 3 Source */
811 { 0x000007D5, 0x0080 }, /* R2005 - SLIMTX3MIX Input 3 Volume */
812 { 0x000007D6, 0x0000 }, /* R2006 - SLIMTX3MIX Input 4 Source */
813 { 0x000007D7, 0x0080 }, /* R2007 - SLIMTX3MIX Input 4 Volume */
814 { 0x000007D8, 0x0000 }, /* R2008 - SLIMTX4MIX Input 1 Source */
815 { 0x000007D9, 0x0080 }, /* R2009 - SLIMTX4MIX Input 1 Volume */
816 { 0x000007DA, 0x0000 }, /* R2010 - SLIMTX4MIX Input 2 Source */
817 { 0x000007DB, 0x0080 }, /* R2011 - SLIMTX4MIX Input 2 Volume */
818 { 0x000007DC, 0x0000 }, /* R2012 - SLIMTX4MIX Input 3 Source */
819 { 0x000007DD, 0x0080 }, /* R2013 - SLIMTX4MIX Input 3 Volume */
820 { 0x000007DE, 0x0000 }, /* R2014 - SLIMTX4MIX Input 4 Source */
821 { 0x000007DF, 0x0080 }, /* R2015 - SLIMTX4MIX Input 4 Volume */
822 { 0x000007E0, 0x0000 }, /* R2016 - SLIMTX5MIX Input 1 Source */
823 { 0x000007E1, 0x0080 }, /* R2017 - SLIMTX5MIX Input 1 Volume */
824 { 0x000007E2, 0x0000 }, /* R2018 - SLIMTX5MIX Input 2 Source */
825 { 0x000007E3, 0x0080 }, /* R2019 - SLIMTX5MIX Input 2 Volume */
826 { 0x000007E4, 0x0000 }, /* R2020 - SLIMTX5MIX Input 3 Source */
827 { 0x000007E5, 0x0080 }, /* R2021 - SLIMTX5MIX Input 3 Volume */
828 { 0x000007E6, 0x0000 }, /* R2022 - SLIMTX5MIX Input 4 Source */
829 { 0x000007E7, 0x0080 }, /* R2023 - SLIMTX5MIX Input 4 Volume */
830 { 0x000007E8, 0x0000 }, /* R2024 - SLIMTX6MIX Input 1 Source */
831 { 0x000007E9, 0x0080 }, /* R2025 - SLIMTX6MIX Input 1 Volume */
832 { 0x000007EA, 0x0000 }, /* R2026 - SLIMTX6MIX Input 2 Source */
833 { 0x000007EB, 0x0080 }, /* R2027 - SLIMTX6MIX Input 2 Volume */
834 { 0x000007EC, 0x0000 }, /* R2028 - SLIMTX6MIX Input 3 Source */
835 { 0x000007ED, 0x0080 }, /* R2029 - SLIMTX6MIX Input 3 Volume */
836 { 0x000007EE, 0x0000 }, /* R2030 - SLIMTX6MIX Input 4 Source */
837 { 0x000007EF, 0x0080 }, /* R2031 - SLIMTX6MIX Input 4 Volume */
838 { 0x000007F0, 0x0000 }, /* R2032 - SLIMTX7MIX Input 1 Source */
839 { 0x000007F1, 0x0080 }, /* R2033 - SLIMTX7MIX Input 1 Volume */
840 { 0x000007F2, 0x0000 }, /* R2034 - SLIMTX7MIX Input 2 Source */
841 { 0x000007F3, 0x0080 }, /* R2035 - SLIMTX7MIX Input 2 Volume */
842 { 0x000007F4, 0x0000 }, /* R2036 - SLIMTX7MIX Input 3 Source */
843 { 0x000007F5, 0x0080 }, /* R2037 - SLIMTX7MIX Input 3 Volume */
844 { 0x000007F6, 0x0000 }, /* R2038 - SLIMTX7MIX Input 4 Source */
845 { 0x000007F7, 0x0080 }, /* R2039 - SLIMTX7MIX Input 4 Volume */
846 { 0x000007F8, 0x0000 }, /* R2040 - SLIMTX8MIX Input 1 Source */
847 { 0x000007F9, 0x0080 }, /* R2041 - SLIMTX8MIX Input 1 Volume */
848 { 0x000007FA, 0x0000 }, /* R2042 - SLIMTX8MIX Input 2 Source */
849 { 0x000007FB, 0x0080 }, /* R2043 - SLIMTX8MIX Input 2 Volume */
850 { 0x000007FC, 0x0000 }, /* R2044 - SLIMTX8MIX Input 3 Source */
851 { 0x000007FD, 0x0080 }, /* R2045 - SLIMTX8MIX Input 3 Volume */
852 { 0x000007FE, 0x0000 }, /* R2046 - SLIMTX8MIX Input 4 Source */
853 { 0x000007FF, 0x0080 }, /* R2047 - SLIMTX8MIX Input 4 Volume */
854 { 0x00000880, 0x0000 }, /* R2176 - EQ1MIX Input 1 Source */
855 { 0x00000881, 0x0080 }, /* R2177 - EQ1MIX Input 1 Volume */
856 { 0x00000882, 0x0000 }, /* R2178 - EQ1MIX Input 2 Source */
857 { 0x00000883, 0x0080 }, /* R2179 - EQ1MIX Input 2 Volume */
858 { 0x00000884, 0x0000 }, /* R2180 - EQ1MIX Input 3 Source */
859 { 0x00000885, 0x0080 }, /* R2181 - EQ1MIX Input 3 Volume */
860 { 0x00000886, 0x0000 }, /* R2182 - EQ1MIX Input 4 Source */
861 { 0x00000887, 0x0080 }, /* R2183 - EQ1MIX Input 4 Volume */
862 { 0x00000888, 0x0000 }, /* R2184 - EQ2MIX Input 1 Source */
863 { 0x00000889, 0x0080 }, /* R2185 - EQ2MIX Input 1 Volume */
864 { 0x0000088A, 0x0000 }, /* R2186 - EQ2MIX Input 2 Source */
865 { 0x0000088B, 0x0080 }, /* R2187 - EQ2MIX Input 2 Volume */
866 { 0x0000088C, 0x0000 }, /* R2188 - EQ2MIX Input 3 Source */
867 { 0x0000088D, 0x0080 }, /* R2189 - EQ2MIX Input 3 Volume */
868 { 0x0000088E, 0x0000 }, /* R2190 - EQ2MIX Input 4 Source */
869 { 0x0000088F, 0x0080 }, /* R2191 - EQ2MIX Input 4 Volume */
870 { 0x00000890, 0x0000 }, /* R2192 - EQ3MIX Input 1 Source */
871 { 0x00000891, 0x0080 }, /* R2193 - EQ3MIX Input 1 Volume */
872 { 0x00000892, 0x0000 }, /* R2194 - EQ3MIX Input 2 Source */
873 { 0x00000893, 0x0080 }, /* R2195 - EQ3MIX Input 2 Volume */
874 { 0x00000894, 0x0000 }, /* R2196 - EQ3MIX Input 3 Source */
875 { 0x00000895, 0x0080 }, /* R2197 - EQ3MIX Input 3 Volume */
876 { 0x00000896, 0x0000 }, /* R2198 - EQ3MIX Input 4 Source */
877 { 0x00000897, 0x0080 }, /* R2199 - EQ3MIX Input 4 Volume */
878 { 0x00000898, 0x0000 }, /* R2200 - EQ4MIX Input 1 Source */
879 { 0x00000899, 0x0080 }, /* R2201 - EQ4MIX Input 1 Volume */
880 { 0x0000089A, 0x0000 }, /* R2202 - EQ4MIX Input 2 Source */
881 { 0x0000089B, 0x0080 }, /* R2203 - EQ4MIX Input 2 Volume */
882 { 0x0000089C, 0x0000 }, /* R2204 - EQ4MIX Input 3 Source */
883 { 0x0000089D, 0x0080 }, /* R2205 - EQ4MIX Input 3 Volume */
884 { 0x0000089E, 0x0000 }, /* R2206 - EQ4MIX Input 4 Source */
885 { 0x0000089F, 0x0080 }, /* R2207 - EQ4MIX Input 4 Volume */
886 { 0x000008C0, 0x0000 }, /* R2240 - DRC1LMIX Input 1 Source */
887 { 0x000008C1, 0x0080 }, /* R2241 - DRC1LMIX Input 1 Volume */
888 { 0x000008C2, 0x0000 }, /* R2242 - DRC1LMIX Input 2 Source */
889 { 0x000008C3, 0x0080 }, /* R2243 - DRC1LMIX Input 2 Volume */
890 { 0x000008C4, 0x0000 }, /* R2244 - DRC1LMIX Input 3 Source */
891 { 0x000008C5, 0x0080 }, /* R2245 - DRC1LMIX Input 3 Volume */
892 { 0x000008C6, 0x0000 }, /* R2246 - DRC1LMIX Input 4 Source */
893 { 0x000008C7, 0x0080 }, /* R2247 - DRC1LMIX Input 4 Volume */
894 { 0x000008C8, 0x0000 }, /* R2248 - DRC1RMIX Input 1 Source */
895 { 0x000008C9, 0x0080 }, /* R2249 - DRC1RMIX Input 1 Volume */
896 { 0x000008CA, 0x0000 }, /* R2250 - DRC1RMIX Input 2 Source */
897 { 0x000008CB, 0x0080 }, /* R2251 - DRC1RMIX Input 2 Volume */
898 { 0x000008CC, 0x0000 }, /* R2252 - DRC1RMIX Input 3 Source */
899 { 0x000008CD, 0x0080 }, /* R2253 - DRC1RMIX Input 3 Volume */
900 { 0x000008CE, 0x0000 }, /* R2254 - DRC1RMIX Input 4 Source */
901 { 0x000008CF, 0x0080 }, /* R2255 - DRC1RMIX Input 4 Volume */
902 { 0x000008D0, 0x0000 }, /* R2256 - DRC2LMIX Input 1 Source */
903 { 0x000008D1, 0x0080 }, /* R2257 - DRC2LMIX Input 1 Volume */
904 { 0x000008D2, 0x0000 }, /* R2258 - DRC2LMIX Input 2 Source */
905 { 0x000008D3, 0x0080 }, /* R2259 - DRC2LMIX Input 2 Volume */
906 { 0x000008D4, 0x0000 }, /* R2260 - DRC2LMIX Input 3 Source */
907 { 0x000008D5, 0x0080 }, /* R2261 - DRC2LMIX Input 3 Volume */
908 { 0x000008D6, 0x0000 }, /* R2262 - DRC2LMIX Input 4 Source */
909 { 0x000008D7, 0x0080 }, /* R2263 - DRC2LMIX Input 4 Volume */
910 { 0x000008D8, 0x0000 }, /* R2264 - DRC2RMIX Input 1 Source */
911 { 0x000008D9, 0x0080 }, /* R2265 - DRC2RMIX Input 1 Volume */
912 { 0x000008DA, 0x0000 }, /* R2266 - DRC2RMIX Input 2 Source */
913 { 0x000008DB, 0x0080 }, /* R2267 - DRC2RMIX Input 2 Volume */
914 { 0x000008DC, 0x0000 }, /* R2268 - DRC2RMIX Input 3 Source */
915 { 0x000008DD, 0x0080 }, /* R2269 - DRC2RMIX Input 3 Volume */
916 { 0x000008DE, 0x0000 }, /* R2270 - DRC2RMIX Input 4 Source */
917 { 0x000008DF, 0x0080 }, /* R2271 - DRC2RMIX Input 4 Volume */
918 { 0x00000900, 0x0000 }, /* R2304 - HPLP1MIX Input 1 Source */
919 { 0x00000901, 0x0080 }, /* R2305 - HPLP1MIX Input 1 Volume */
920 { 0x00000902, 0x0000 }, /* R2306 - HPLP1MIX Input 2 Source */
921 { 0x00000903, 0x0080 }, /* R2307 - HPLP1MIX Input 2 Volume */
922 { 0x00000904, 0x0000 }, /* R2308 - HPLP1MIX Input 3 Source */
923 { 0x00000905, 0x0080 }, /* R2309 - HPLP1MIX Input 3 Volume */
924 { 0x00000906, 0x0000 }, /* R2310 - HPLP1MIX Input 4 Source */
925 { 0x00000907, 0x0080 }, /* R2311 - HPLP1MIX Input 4 Volume */
926 { 0x00000908, 0x0000 }, /* R2312 - HPLP2MIX Input 1 Source */
927 { 0x00000909, 0x0080 }, /* R2313 - HPLP2MIX Input 1 Volume */
928 { 0x0000090A, 0x0000 }, /* R2314 - HPLP2MIX Input 2 Source */
929 { 0x0000090B, 0x0080 }, /* R2315 - HPLP2MIX Input 2 Volume */
930 { 0x0000090C, 0x0000 }, /* R2316 - HPLP2MIX Input 3 Source */
931 { 0x0000090D, 0x0080 }, /* R2317 - HPLP2MIX Input 3 Volume */
932 { 0x0000090E, 0x0000 }, /* R2318 - HPLP2MIX Input 4 Source */
933 { 0x0000090F, 0x0080 }, /* R2319 - HPLP2MIX Input 4 Volume */
934 { 0x00000910, 0x0000 }, /* R2320 - HPLP3MIX Input 1 Source */
935 { 0x00000911, 0x0080 }, /* R2321 - HPLP3MIX Input 1 Volume */
936 { 0x00000912, 0x0000 }, /* R2322 - HPLP3MIX Input 2 Source */
937 { 0x00000913, 0x0080 }, /* R2323 - HPLP3MIX Input 2 Volume */
938 { 0x00000914, 0x0000 }, /* R2324 - HPLP3MIX Input 3 Source */
939 { 0x00000915, 0x0080 }, /* R2325 - HPLP3MIX Input 3 Volume */
940 { 0x00000916, 0x0000 }, /* R2326 - HPLP3MIX Input 4 Source */
941 { 0x00000917, 0x0080 }, /* R2327 - HPLP3MIX Input 4 Volume */
942 { 0x00000918, 0x0000 }, /* R2328 - HPLP4MIX Input 1 Source */
943 { 0x00000919, 0x0080 }, /* R2329 - HPLP4MIX Input 1 Volume */
944 { 0x0000091A, 0x0000 }, /* R2330 - HPLP4MIX Input 2 Source */
945 { 0x0000091B, 0x0080 }, /* R2331 - HPLP4MIX Input 2 Volume */
946 { 0x0000091C, 0x0000 }, /* R2332 - HPLP4MIX Input 3 Source */
947 { 0x0000091D, 0x0080 }, /* R2333 - HPLP4MIX Input 3 Volume */
948 { 0x0000091E, 0x0000 }, /* R2334 - HPLP4MIX Input 4 Source */
949 { 0x0000091F, 0x0080 }, /* R2335 - HPLP4MIX Input 4 Volume */
950 { 0x00000940, 0x0000 }, /* R2368 - DSP1LMIX Input 1 Source */
951 { 0x00000941, 0x0080 }, /* R2369 - DSP1LMIX Input 1 Volume */
952 { 0x00000942, 0x0000 }, /* R2370 - DSP1LMIX Input 2 Source */
953 { 0x00000943, 0x0080 }, /* R2371 - DSP1LMIX Input 2 Volume */
954 { 0x00000944, 0x0000 }, /* R2372 - DSP1LMIX Input 3 Source */
955 { 0x00000945, 0x0080 }, /* R2373 - DSP1LMIX Input 3 Volume */
956 { 0x00000946, 0x0000 }, /* R2374 - DSP1LMIX Input 4 Source */
957 { 0x00000947, 0x0080 }, /* R2375 - DSP1LMIX Input 4 Volume */
958 { 0x00000948, 0x0000 }, /* R2376 - DSP1RMIX Input 1 Source */
959 { 0x00000949, 0x0080 }, /* R2377 - DSP1RMIX Input 1 Volume */
960 { 0x0000094A, 0x0000 }, /* R2378 - DSP1RMIX Input 2 Source */
961 { 0x0000094B, 0x0080 }, /* R2379 - DSP1RMIX Input 2 Volume */
962 { 0x0000094C, 0x0000 }, /* R2380 - DSP1RMIX Input 3 Source */
963 { 0x0000094D, 0x0080 }, /* R2381 - DSP1RMIX Input 3 Volume */
964 { 0x0000094E, 0x0000 }, /* R2382 - DSP1RMIX Input 4 Source */
965 { 0x0000094F, 0x0080 }, /* R2383 - DSP1RMIX Input 4 Volume */
966 { 0x00000950, 0x0000 }, /* R2384 - DSP1AUX1MIX Input 1 Source */
967 { 0x00000958, 0x0000 }, /* R2392 - DSP1AUX2MIX Input 1 Source */
968 { 0x00000960, 0x0000 }, /* R2400 - DSP1AUX3MIX Input 1 Source */
969 { 0x00000968, 0x0000 }, /* R2408 - DSP1AUX4MIX Input 1 Source */
970 { 0x00000970, 0x0000 }, /* R2416 - DSP1AUX5MIX Input 1 Source */
971 { 0x00000978, 0x0000 }, /* R2424 - DSP1AUX6MIX Input 1 Source */
972 { 0x00000980, 0x0000 }, /* R2432 - DSP2LMIX Input 1 Source */
973 { 0x00000981, 0x0080 }, /* R2433 - DSP2LMIX Input 1 Volume */
974 { 0x00000982, 0x0000 }, /* R2434 - DSP2LMIX Input 2 Source */
975 { 0x00000983, 0x0080 }, /* R2435 - DSP2LMIX Input 2 Volume */
976 { 0x00000984, 0x0000 }, /* R2436 - DSP2LMIX Input 3 Source */
977 { 0x00000985, 0x0080 }, /* R2437 - DSP2LMIX Input 3 Volume */
978 { 0x00000986, 0x0000 }, /* R2438 - DSP2LMIX Input 4 Source */
979 { 0x00000987, 0x0080 }, /* R2439 - DSP2LMIX Input 4 Volume */
980 { 0x00000988, 0x0000 }, /* R2440 - DSP2RMIX Input 1 Source */
981 { 0x00000989, 0x0080 }, /* R2441 - DSP2RMIX Input 1 Volume */
982 { 0x0000098A, 0x0000 }, /* R2442 - DSP2RMIX Input 2 Source */
983 { 0x0000098B, 0x0080 }, /* R2443 - DSP2RMIX Input 2 Volume */
984 { 0x0000098C, 0x0000 }, /* R2444 - DSP2RMIX Input 3 Source */
985 { 0x0000098D, 0x0080 }, /* R2445 - DSP2RMIX Input 3 Volume */
986 { 0x0000098E, 0x0000 }, /* R2446 - DSP2RMIX Input 4 Source */
987 { 0x0000098F, 0x0080 }, /* R2447 - DSP2RMIX Input 4 Volume */
988 { 0x00000990, 0x0000 }, /* R2448 - DSP2AUX1MIX Input 1 Source */
989 { 0x00000998, 0x0000 }, /* R2456 - DSP2AUX2MIX Input 1 Source */
990 { 0x000009A0, 0x0000 }, /* R2464 - DSP2AUX3MIX Input 1 Source */
991 { 0x000009A8, 0x0000 }, /* R2472 - DSP2AUX4MIX Input 1 Source */
992 { 0x000009B0, 0x0000 }, /* R2480 - DSP2AUX5MIX Input 1 Source */
993 { 0x000009B8, 0x0000 }, /* R2488 - DSP2AUX6MIX Input 1 Source */
994 { 0x000009C0, 0x0000 }, /* R2496 - DSP3LMIX Input 1 Source */
995 { 0x000009C1, 0x0080 }, /* R2497 - DSP3LMIX Input 1 Volume */
996 { 0x000009C2, 0x0000 }, /* R2498 - DSP3LMIX Input 2 Source */
997 { 0x000009C3, 0x0080 }, /* R2499 - DSP3LMIX Input 2 Volume */
998 { 0x000009C4, 0x0000 }, /* R2500 - DSP3LMIX Input 3 Source */
999 { 0x000009C5, 0x0080 }, /* R2501 - DSP3LMIX Input 3 Volume */
1000 { 0x000009C6, 0x0000 }, /* R2502 - DSP3LMIX Input 4 Source */
1001 { 0x000009C7, 0x0080 }, /* R2503 - DSP3LMIX Input 4 Volume */
1002 { 0x000009C8, 0x0000 }, /* R2504 - DSP3RMIX Input 1 Source */
1003 { 0x000009C9, 0x0080 }, /* R2505 - DSP3RMIX Input 1 Volume */
1004 { 0x000009CA, 0x0000 }, /* R2506 - DSP3RMIX Input 2 Source */
1005 { 0x000009CB, 0x0080 }, /* R2507 - DSP3RMIX Input 2 Volume */
1006 { 0x000009CC, 0x0000 }, /* R2508 - DSP3RMIX Input 3 Source */
1007 { 0x000009CD, 0x0080 }, /* R2509 - DSP3RMIX Input 3 Volume */
1008 { 0x000009CE, 0x0000 }, /* R2510 - DSP3RMIX Input 4 Source */
1009 { 0x000009CF, 0x0080 }, /* R2511 - DSP3RMIX Input 4 Volume */
1010 { 0x000009D0, 0x0000 }, /* R2512 - DSP3AUX1MIX Input 1 Source */
1011 { 0x000009D8, 0x0000 }, /* R2520 - DSP3AUX2MIX Input 1 Source */
1012 { 0x000009E0, 0x0000 }, /* R2528 - DSP3AUX3MIX Input 1 Source */
1013 { 0x000009E8, 0x0000 }, /* R2536 - DSP3AUX4MIX Input 1 Source */
1014 { 0x000009F0, 0x0000 }, /* R2544 - DSP3AUX5MIX Input 1 Source */
1015 { 0x000009F8, 0x0000 }, /* R2552 - DSP3AUX6MIX Input 1 Source */
1016 { 0x00000A00, 0x0000 }, /* R2560 - DSP4LMIX Input 1 Source */
1017 { 0x00000A01, 0x0080 }, /* R2561 - DSP4LMIX Input 1 Volume */
1018 { 0x00000A02, 0x0000 }, /* R2562 - DSP4LMIX Input 2 Source */
1019 { 0x00000A03, 0x0080 }, /* R2563 - DSP4LMIX Input 2 Volume */
1020 { 0x00000A04, 0x0000 }, /* R2564 - DSP4LMIX Input 3 Source */
1021 { 0x00000A05, 0x0080 }, /* R2565 - DSP4LMIX Input 3 Volume */
1022 { 0x00000A06, 0x0000 }, /* R2566 - DSP4LMIX Input 4 Source */
1023 { 0x00000A07, 0x0080 }, /* R2567 - DSP4LMIX Input 4 Volume */
1024 { 0x00000A08, 0x0000 }, /* R2568 - DSP4RMIX Input 1 Source */
1025 { 0x00000A09, 0x0080 }, /* R2569 - DSP4RMIX Input 1 Volume */
1026 { 0x00000A0A, 0x0000 }, /* R2570 - DSP4RMIX Input 2 Source */
1027 { 0x00000A0B, 0x0080 }, /* R2571 - DSP4RMIX Input 2 Volume */
1028 { 0x00000A0C, 0x0000 }, /* R2572 - DSP4RMIX Input 3 Source */
1029 { 0x00000A0D, 0x0080 }, /* R2573 - DSP4RMIX Input 3 Volume */
1030 { 0x00000A0E, 0x0000 }, /* R2574 - DSP4RMIX Input 4 Source */
1031 { 0x00000A0F, 0x0080 }, /* R2575 - DSP4RMIX Input 4 Volume */
1032 { 0x00000A10, 0x0000 }, /* R2576 - DSP4AUX1MIX Input 1 Source */
1033 { 0x00000A18, 0x0000 }, /* R2584 - DSP4AUX2MIX Input 1 Source */
1034 { 0x00000A20, 0x0000 }, /* R2592 - DSP4AUX3MIX Input 1 Source */
1035 { 0x00000A28, 0x0000 }, /* R2600 - DSP4AUX4MIX Input 1 Source */
1036 { 0x00000A30, 0x0000 }, /* R2608 - DSP4AUX5MIX Input 1 Source */
1037 { 0x00000A38, 0x0000 }, /* R2616 - DSP4AUX6MIX Input 1 Source */
1038 { 0x00000A80, 0x0000 }, /* R2688 - ASRC1LMIX Input 1 Source */
1039 { 0x00000A88, 0x0000 }, /* R2696 - ASRC1RMIX Input 1 Source */
1040 { 0x00000A90, 0x0000 }, /* R2704 - ASRC2LMIX Input 1 Source */
1041 { 0x00000A98, 0x0000 }, /* R2712 - ASRC2RMIX Input 1 Source */
1042 { 0x00000B00, 0x0000 }, /* R2816 - ISRC1DEC1MIX Input 1 Source */
1043 { 0x00000B08, 0x0000 }, /* R2824 - ISRC1DEC2MIX Input 1 Source */
1044 { 0x00000B10, 0x0000 }, /* R2832 - ISRC1DEC3MIX Input 1 Source */
1045 { 0x00000B18, 0x0000 }, /* R2840 - ISRC1DEC4MIX Input 1 Source */
1046 { 0x00000B20, 0x0000 }, /* R2848 - ISRC1INT1MIX Input 1 Source */
1047 { 0x00000B28, 0x0000 }, /* R2856 - ISRC1INT2MIX Input 1 Source */
1048 { 0x00000B30, 0x0000 }, /* R2864 - ISRC1INT3MIX Input 1 Source */
1049 { 0x00000B38, 0x0000 }, /* R2872 - ISRC1INT4MIX Input 1 Source */
1050 { 0x00000B40, 0x0000 }, /* R2880 - ISRC2DEC1MIX Input 1 Source */
1051 { 0x00000B48, 0x0000 }, /* R2888 - ISRC2DEC2MIX Input 1 Source */
1052 { 0x00000B50, 0x0000 }, /* R2896 - ISRC2DEC3MIX Input 1 Source */
1053 { 0x00000B58, 0x0000 }, /* R2904 - ISRC2DEC4MIX Input 1 Source */
1054 { 0x00000B60, 0x0000 }, /* R2912 - ISRC2INT1MIX Input 1 Source */
1055 { 0x00000B68, 0x0000 }, /* R2920 - ISRC2INT2MIX Input 1 Source */
1056 { 0x00000B70, 0x0000 }, /* R2928 - ISRC2INT3MIX Input 1 Source */
1057 { 0x00000B78, 0x0000 }, /* R2936 - ISRC2INT4MIX Input 1 Source */
1058 { 0x00000B80, 0x0000 }, /* R2944 - ISRC3DEC1MIX Input 1 Source */
1059 { 0x00000B88, 0x0000 }, /* R2952 - ISRC3DEC2MIX Input 1 Source */
1060 { 0x00000B90, 0x0000 }, /* R2960 - ISRC3DEC3MIX Input 1 Source */
1061 { 0x00000B98, 0x0000 }, /* R2968 - ISRC3DEC4MIX Input 1 Source */
1062 { 0x00000BA0, 0x0000 }, /* R2976 - ISRC3INT1MIX Input 1 Source */
1063 { 0x00000BA8, 0x0000 }, /* R2984 - ISRC3INT2MIX Input 1 Source */
1064 { 0x00000BB0, 0x0000 }, /* R2992 - ISRC3INT3MIX Input 1 Source */
1065 { 0x00000BB8, 0x0000 }, /* R3000 - ISRC3INT4MIX Input 1 Source */
1066 { 0x00000C00, 0xA101 }, /* R3072 - GPIO1 CTRL */
1067 { 0x00000C01, 0xA101 }, /* R3073 - GPIO2 CTRL */
1068 { 0x00000C02, 0xA101 }, /* R3074 - GPIO3 CTRL */
1069 { 0x00000C03, 0xA101 }, /* R3075 - GPIO4 CTRL */
1070 { 0x00000C04, 0xA101 }, /* R3076 - GPIO5 CTRL */
1071 { 0x00000C0F, 0x0400 }, /* R3087 - IRQ CTRL 1 */
1072 { 0x00000C10, 0x1000 }, /* R3088 - GPIO Debounce Config */
1073 { 0x00000C20, 0x8002 }, /* R3104 - Misc Pad Ctrl 1 */
1074 { 0x00000C21, 0x8001 }, /* R3105 - Misc Pad Ctrl 2 */
1075 { 0x00000C22, 0x0000 }, /* R3106 - Misc Pad Ctrl 3 */
1076 { 0x00000C23, 0x0000 }, /* R3107 - Misc Pad Ctrl 4 */
1077 { 0x00000C24, 0x0000 }, /* R3108 - Misc Pad Ctrl 5 */
1078 { 0x00000C25, 0x0000 }, /* R3109 - Misc Pad Ctrl 6 */
1079 { 0x00000C30, 0x8282 }, /* R3120 - Misc Pad Ctrl 7 */
1080 { 0x00000C31, 0x0082 }, /* R3121 - Misc Pad Ctrl 8 */
1081 { 0x00000C32, 0x8282 }, /* R3122 - Misc Pad Ctrl 9 */
1082 { 0x00000C33, 0x8282 }, /* R3123 - Misc Pad Ctrl 10 */
1083 { 0x00000C34, 0x8282 }, /* R3124 - Misc Pad Ctrl 11 */
1084 { 0x00000C35, 0x8282 }, /* R3125 - Misc Pad Ctrl 12 */
1085 { 0x00000C36, 0x8282 }, /* R3126 - Misc Pad Ctrl 13 */
1086 { 0x00000C37, 0x8282 }, /* R3127 - Misc Pad Ctrl 14 */
1087 { 0x00000C38, 0x8282 }, /* R3128 - Misc Pad Ctrl 15 */
1088 { 0x00000C39, 0x8282 }, /* R3129 - Misc Pad Ctrl 16 */
1089 { 0x00000C3A, 0x8282 }, /* R3130 - Misc Pad Ctrl 17 */
1090 { 0x00000C3B, 0x8282 }, /* R3131 - Misc Pad Ctrl 18 */
1091 { 0x00000D08, 0xFFFF }, /* R3336 - Interrupt Status 1 Mask */
1092 { 0x00000D09, 0xFFFF }, /* R3337 - Interrupt Status 2 Mask */
1093 { 0x00000D0A, 0xFFFF }, /* R3338 - Interrupt Status 3 Mask */
1094 { 0x00000D0B, 0xFFFF }, /* R3339 - Interrupt Status 4 Mask */
1095 { 0x00000D0C, 0xFEFF }, /* R3340 - Interrupt Status 5 Mask */
1096 { 0x00000D0F, 0x0000 }, /* R3343 - Interrupt Control */
1097 { 0x00000D18, 0xFFFF }, /* R3352 - IRQ2 Status 1 Mask */
1098 { 0x00000D19, 0xFFFF }, /* R3353 - IRQ2 Status 2 Mask */
1099 { 0x00000D1A, 0xFFFF }, /* R3354 - IRQ2 Status 3 Mask */
1100 { 0x00000D1B, 0xFFFF }, /* R3355 - IRQ2 Status 4 Mask */
1101 { 0x00000D1C, 0xFFFF }, /* R3356 - IRQ2 Status 5 Mask */
1102 { 0x00000D1F, 0x0000 }, /* R3359 - IRQ2 Control */
1103 { 0x00000D50, 0x0000 }, /* R3408 - AOD wkup and trig */
1104 { 0x00000D53, 0xFFFF }, /* R3411 - AOD IRQ Mask IRQ1 */
1105 { 0x00000D54, 0xFFFF }, /* R3412 - AOD IRQ Mask IRQ2 */
1106 { 0x00000D56, 0x0000 }, /* R3414 - Jack detect debounce */
1107 { 0x00000E00, 0x0000 }, /* R3584 - FX_Ctrl1 */
1108 { 0x00000E01, 0x0000 }, /* R3585 - FX_Ctrl2 */
1109 { 0x00000E10, 0x6318 }, /* R3600 - EQ1_1 */
1110 { 0x00000E11, 0x6300 }, /* R3601 - EQ1_2 */
1111 { 0x00000E12, 0x0FC8 }, /* R3602 - EQ1_3 */
1112 { 0x00000E13, 0x03FE }, /* R3603 - EQ1_4 */
1113 { 0x00000E14, 0x00E0 }, /* R3604 - EQ1_5 */
1114 { 0x00000E15, 0x1EC4 }, /* R3605 - EQ1_6 */
1115 { 0x00000E16, 0xF136 }, /* R3606 - EQ1_7 */
1116 { 0x00000E17, 0x0409 }, /* R3607 - EQ1_8 */
1117 { 0x00000E18, 0x04CC }, /* R3608 - EQ1_9 */
1118 { 0x00000E19, 0x1C9B }, /* R3609 - EQ1_10 */
1119 { 0x00000E1A, 0xF337 }, /* R3610 - EQ1_11 */
1120 { 0x00000E1B, 0x040B }, /* R3611 - EQ1_12 */
1121 { 0x00000E1C, 0x0CBB }, /* R3612 - EQ1_13 */
1122 { 0x00000E1D, 0x16F8 }, /* R3613 - EQ1_14 */
1123 { 0x00000E1E, 0xF7D9 }, /* R3614 - EQ1_15 */
1124 { 0x00000E1F, 0x040A }, /* R3615 - EQ1_16 */
1125 { 0x00000E20, 0x1F14 }, /* R3616 - EQ1_17 */
1126 { 0x00000E21, 0x058C }, /* R3617 - EQ1_18 */
1127 { 0x00000E22, 0x0563 }, /* R3618 - EQ1_19 */
1128 { 0x00000E23, 0x4000 }, /* R3619 - EQ1_20 */
1129 { 0x00000E24, 0x0B75 }, /* R3620 - EQ1_21 */
1130 { 0x00000E26, 0x6318 }, /* R3622 - EQ2_1 */
1131 { 0x00000E27, 0x6300 }, /* R3623 - EQ2_2 */
1132 { 0x00000E28, 0x0FC8 }, /* R3624 - EQ2_3 */
1133 { 0x00000E29, 0x03FE }, /* R3625 - EQ2_4 */
1134 { 0x00000E2A, 0x00E0 }, /* R3626 - EQ2_5 */
1135 { 0x00000E2B, 0x1EC4 }, /* R3627 - EQ2_6 */
1136 { 0x00000E2C, 0xF136 }, /* R3628 - EQ2_7 */
1137 { 0x00000E2D, 0x0409 }, /* R3629 - EQ2_8 */
1138 { 0x00000E2E, 0x04CC }, /* R3630 - EQ2_9 */
1139 { 0x00000E2F, 0x1C9B }, /* R3631 - EQ2_10 */
1140 { 0x00000E30, 0xF337 }, /* R3632 - EQ2_11 */
1141 { 0x00000E31, 0x040B }, /* R3633 - EQ2_12 */
1142 { 0x00000E32, 0x0CBB }, /* R3634 - EQ2_13 */
1143 { 0x00000E33, 0x16F8 }, /* R3635 - EQ2_14 */
1144 { 0x00000E34, 0xF7D9 }, /* R3636 - EQ2_15 */
1145 { 0x00000E35, 0x040A }, /* R3637 - EQ2_16 */
1146 { 0x00000E36, 0x1F14 }, /* R3638 - EQ2_17 */
1147 { 0x00000E37, 0x058C }, /* R3639 - EQ2_18 */
1148 { 0x00000E38, 0x0563 }, /* R3640 - EQ2_19 */
1149 { 0x00000E39, 0x4000 }, /* R3641 - EQ2_20 */
1150 { 0x00000E3A, 0x0B75 }, /* R3642 - EQ2_21 */
1151 { 0x00000E3C, 0x6318 }, /* R3644 - EQ3_1 */
1152 { 0x00000E3D, 0x6300 }, /* R3645 - EQ3_2 */
1153 { 0x00000E3E, 0x0FC8 }, /* R3646 - EQ3_3 */
1154 { 0x00000E3F, 0x03FE }, /* R3647 - EQ3_4 */
1155 { 0x00000E40, 0x00E0 }, /* R3648 - EQ3_5 */
1156 { 0x00000E41, 0x1EC4 }, /* R3649 - EQ3_6 */
1157 { 0x00000E42, 0xF136 }, /* R3650 - EQ3_7 */
1158 { 0x00000E43, 0x0409 }, /* R3651 - EQ3_8 */
1159 { 0x00000E44, 0x04CC }, /* R3652 - EQ3_9 */
1160 { 0x00000E45, 0x1C9B }, /* R3653 - EQ3_10 */
1161 { 0x00000E46, 0xF337 }, /* R3654 - EQ3_11 */
1162 { 0x00000E47, 0x040B }, /* R3655 - EQ3_12 */
1163 { 0x00000E48, 0x0CBB }, /* R3656 - EQ3_13 */
1164 { 0x00000E49, 0x16F8 }, /* R3657 - EQ3_14 */
1165 { 0x00000E4A, 0xF7D9 }, /* R3658 - EQ3_15 */
1166 { 0x00000E4B, 0x040A }, /* R3659 - EQ3_16 */
1167 { 0x00000E4C, 0x1F14 }, /* R3660 - EQ3_17 */
1168 { 0x00000E4D, 0x058C }, /* R3661 - EQ3_18 */
1169 { 0x00000E4E, 0x0563 }, /* R3662 - EQ3_19 */
1170 { 0x00000E4F, 0x4000 }, /* R3663 - EQ3_20 */
1171 { 0x00000E50, 0x0B75 }, /* R3664 - EQ3_21 */
1172 { 0x00000E52, 0x6318 }, /* R3666 - EQ4_1 */
1173 { 0x00000E53, 0x6300 }, /* R3667 - EQ4_2 */
1174 { 0x00000E54, 0x0FC8 }, /* R3668 - EQ4_3 */
1175 { 0x00000E55, 0x03FE }, /* R3669 - EQ4_4 */
1176 { 0x00000E56, 0x00E0 }, /* R3670 - EQ4_5 */
1177 { 0x00000E57, 0x1EC4 }, /* R3671 - EQ4_6 */
1178 { 0x00000E58, 0xF136 }, /* R3672 - EQ4_7 */
1179 { 0x00000E59, 0x0409 }, /* R3673 - EQ4_8 */
1180 { 0x00000E5A, 0x04CC }, /* R3674 - EQ4_9 */
1181 { 0x00000E5B, 0x1C9B }, /* R3675 - EQ4_10 */
1182 { 0x00000E5C, 0xF337 }, /* R3676 - EQ4_11 */
1183 { 0x00000E5D, 0x040B }, /* R3677 - EQ4_12 */
1184 { 0x00000E5E, 0x0CBB }, /* R3678 - EQ4_13 */
1185 { 0x00000E5F, 0x16F8 }, /* R3679 - EQ4_14 */
1186 { 0x00000E60, 0xF7D9 }, /* R3680 - EQ4_15 */
1187 { 0x00000E61, 0x040A }, /* R3681 - EQ4_16 */
1188 { 0x00000E62, 0x1F14 }, /* R3682 - EQ4_17 */
1189 { 0x00000E63, 0x058C }, /* R3683 - EQ4_18 */
1190 { 0x00000E64, 0x0563 }, /* R3684 - EQ4_19 */
1191 { 0x00000E65, 0x4000 }, /* R3685 - EQ4_20 */
1192 { 0x00000E66, 0x0B75 }, /* R3686 - EQ4_21 */
1193 { 0x00000E80, 0x0018 }, /* R3712 - DRC1 ctrl1 */
1194 { 0x00000E81, 0x0933 }, /* R3713 - DRC1 ctrl2 */
1195 { 0x00000E82, 0x0018 }, /* R3714 - DRC1 ctrl3 */
1196 { 0x00000E83, 0x0000 }, /* R3715 - DRC1 ctrl4 */
1197 { 0x00000E84, 0x0000 }, /* R3716 - DRC1 ctrl5 */
1198 { 0x00000E89, 0x0018 }, /* R3721 - DRC2 ctrl1 */
1199 { 0x00000E8A, 0x0933 }, /* R3722 - DRC2 ctrl2 */
1200 { 0x00000E8B, 0x0018 }, /* R3723 - DRC2 ctrl3 */
1201 { 0x00000E8C, 0x0000 }, /* R3724 - DRC2 ctrl4 */
1202 { 0x00000E8D, 0x0000 }, /* R3725 - DRC2 ctrl5 */
1203 { 0x00000EC0, 0x0000 }, /* R3776 - HPLPF1_1 */
1204 { 0x00000EC1, 0x0000 }, /* R3777 - HPLPF1_2 */
1205 { 0x00000EC4, 0x0000 }, /* R3780 - HPLPF2_1 */
1206 { 0x00000EC5, 0x0000 }, /* R3781 - HPLPF2_2 */
1207 { 0x00000EC8, 0x0000 }, /* R3784 - HPLPF3_1 */
1208 { 0x00000EC9, 0x0000 }, /* R3785 - HPLPF3_2 */
1209 { 0x00000ECC, 0x0000 }, /* R3788 - HPLPF4_1 */
1210 { 0x00000ECD, 0x0000 }, /* R3789 - HPLPF4_2 */
1211 { 0x00000EE0, 0x0000 }, /* R3808 - ASRC_ENABLE */
1212 { 0x00000EE2, 0x0000 }, /* R3810 - ASRC_RATE1 */
1213 { 0x00000EF0, 0x0000 }, /* R3824 - ISRC 1 CTRL 1 */
1214 { 0x00000EF1, 0x0000 }, /* R3825 - ISRC 1 CTRL 2 */
1215 { 0x00000EF2, 0x0000 }, /* R3826 - ISRC 1 CTRL 3 */
1216 { 0x00000EF3, 0x0000 }, /* R3827 - ISRC 2 CTRL 1 */
1217 { 0x00000EF4, 0x0000 }, /* R3828 - ISRC 2 CTRL 2 */
1218 { 0x00000EF5, 0x0000 }, /* R3829 - ISRC 2 CTRL 3 */
1219 { 0x00000EF6, 0x0000 }, /* R3830 - ISRC 3 CTRL 1 */
1220 { 0x00000EF7, 0x0000 }, /* R3831 - ISRC 3 CTRL 2 */
1221 { 0x00000EF8, 0x0000 }, /* R3832 - ISRC 3 CTRL 3 */
1222 { 0x00000F00, 0x0000 }, /* R3840 - Clock Control */
1223 { 0x00000F01, 0x0000 }, /* R3841 - ANC_SRC */
1224 { 0x00001100, 0x0010 }, /* R4352 - DSP1 Control 1 */
1225 { 0x00001101, 0x0000 }, /* R4353 - DSP1 Clocking 1 */
1226 { 0x00001200, 0x0010 }, /* R4608 - DSP2 Control 1 */
1227 { 0x00001201, 0x0000 }, /* R4609 - DSP2 Clocking 1 */
1228 { 0x00001300, 0x0010 }, /* R4864 - DSP3 Control 1 */
1229 { 0x00001301, 0x0000 }, /* R4865 - DSP3 Clocking 1 */
1230 { 0x00001400, 0x0010 }, /* R5120 - DSP4 Control 1 */
1231 { 0x00001401, 0x0000 }, /* R5121 - DSP4 Clocking 1 */
1232 { 0x00001404, 0x0000 }, /* R5124 - DSP4 Status 1 */
1233};
1234
1235static bool wm5110_readable_register(struct device *dev, unsigned int reg)
1236{
1237 switch (reg) {
1238 case ARIZONA_SOFTWARE_RESET:
1239 case ARIZONA_DEVICE_REVISION:
1240 case ARIZONA_CTRL_IF_SPI_CFG_1:
1241 case ARIZONA_CTRL_IF_I2C1_CFG_1:
1242 case ARIZONA_CTRL_IF_I2C2_CFG_1:
1243 case ARIZONA_CTRL_IF_I2C1_CFG_2:
1244 case ARIZONA_CTRL_IF_I2C2_CFG_2:
1245 case ARIZONA_WRITE_SEQUENCER_CTRL_0:
1246 case ARIZONA_WRITE_SEQUENCER_CTRL_1:
1247 case ARIZONA_WRITE_SEQUENCER_CTRL_2:
1248 case ARIZONA_TONE_GENERATOR_1:
1249 case ARIZONA_TONE_GENERATOR_2:
1250 case ARIZONA_TONE_GENERATOR_3:
1251 case ARIZONA_TONE_GENERATOR_4:
1252 case ARIZONA_TONE_GENERATOR_5:
1253 case ARIZONA_PWM_DRIVE_1:
1254 case ARIZONA_PWM_DRIVE_2:
1255 case ARIZONA_PWM_DRIVE_3:
1256 case ARIZONA_WAKE_CONTROL:
1257 case ARIZONA_SEQUENCE_CONTROL:
1258 case ARIZONA_SAMPLE_RATE_SEQUENCE_SELECT_1:
1259 case ARIZONA_SAMPLE_RATE_SEQUENCE_SELECT_2:
1260 case ARIZONA_SAMPLE_RATE_SEQUENCE_SELECT_3:
1261 case ARIZONA_SAMPLE_RATE_SEQUENCE_SELECT_4:
1262 case ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_1:
1263 case ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_2:
1264 case ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_3:
1265 case ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_4:
1266 case ARIZONA_COMFORT_NOISE_GENERATOR:
1267 case ARIZONA_HAPTICS_CONTROL_1:
1268 case ARIZONA_HAPTICS_CONTROL_2:
1269 case ARIZONA_HAPTICS_PHASE_1_INTENSITY:
1270 case ARIZONA_HAPTICS_PHASE_1_DURATION:
1271 case ARIZONA_HAPTICS_PHASE_2_INTENSITY:
1272 case ARIZONA_HAPTICS_PHASE_2_DURATION:
1273 case ARIZONA_HAPTICS_PHASE_3_INTENSITY:
1274 case ARIZONA_HAPTICS_PHASE_3_DURATION:
1275 case ARIZONA_HAPTICS_STATUS:
1276 case ARIZONA_CLOCK_32K_1:
1277 case ARIZONA_SYSTEM_CLOCK_1:
1278 case ARIZONA_SAMPLE_RATE_1:
1279 case ARIZONA_SAMPLE_RATE_2:
1280 case ARIZONA_SAMPLE_RATE_3:
1281 case ARIZONA_SAMPLE_RATE_1_STATUS:
1282 case ARIZONA_SAMPLE_RATE_2_STATUS:
1283 case ARIZONA_SAMPLE_RATE_3_STATUS:
1284 case ARIZONA_ASYNC_CLOCK_1:
1285 case ARIZONA_ASYNC_SAMPLE_RATE_1:
1286 case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS:
1287 case ARIZONA_OUTPUT_SYSTEM_CLOCK:
1288 case ARIZONA_OUTPUT_ASYNC_CLOCK:
1289 case ARIZONA_RATE_ESTIMATOR_1:
1290 case ARIZONA_RATE_ESTIMATOR_2:
1291 case ARIZONA_RATE_ESTIMATOR_3:
1292 case ARIZONA_RATE_ESTIMATOR_4:
1293 case ARIZONA_RATE_ESTIMATOR_5:
1294 case ARIZONA_FLL1_CONTROL_1:
1295 case ARIZONA_FLL1_CONTROL_2:
1296 case ARIZONA_FLL1_CONTROL_3:
1297 case ARIZONA_FLL1_CONTROL_4:
1298 case ARIZONA_FLL1_CONTROL_5:
1299 case ARIZONA_FLL1_CONTROL_6:
1300 case ARIZONA_FLL1_LOOP_FILTER_TEST_1:
1301 case ARIZONA_FLL1_NCO_TEST_0:
1302 case ARIZONA_FLL1_SYNCHRONISER_1:
1303 case ARIZONA_FLL1_SYNCHRONISER_2:
1304 case ARIZONA_FLL1_SYNCHRONISER_3:
1305 case ARIZONA_FLL1_SYNCHRONISER_4:
1306 case ARIZONA_FLL1_SYNCHRONISER_5:
1307 case ARIZONA_FLL1_SYNCHRONISER_6:
1308 case ARIZONA_FLL1_SPREAD_SPECTRUM:
1309 case ARIZONA_FLL1_GPIO_CLOCK:
1310 case ARIZONA_FLL2_CONTROL_1:
1311 case ARIZONA_FLL2_CONTROL_2:
1312 case ARIZONA_FLL2_CONTROL_3:
1313 case ARIZONA_FLL2_CONTROL_4:
1314 case ARIZONA_FLL2_CONTROL_5:
1315 case ARIZONA_FLL2_CONTROL_6:
1316 case ARIZONA_FLL2_LOOP_FILTER_TEST_1:
1317 case ARIZONA_FLL2_NCO_TEST_0:
1318 case ARIZONA_FLL2_SYNCHRONISER_1:
1319 case ARIZONA_FLL2_SYNCHRONISER_2:
1320 case ARIZONA_FLL2_SYNCHRONISER_3:
1321 case ARIZONA_FLL2_SYNCHRONISER_4:
1322 case ARIZONA_FLL2_SYNCHRONISER_5:
1323 case ARIZONA_FLL2_SYNCHRONISER_6:
1324 case ARIZONA_FLL2_SPREAD_SPECTRUM:
1325 case ARIZONA_FLL2_GPIO_CLOCK:
1326 case ARIZONA_MIC_CHARGE_PUMP_1:
1327 case ARIZONA_LDO1_CONTROL_1:
1328 case ARIZONA_LDO2_CONTROL_1:
1329 case ARIZONA_MIC_BIAS_CTRL_1:
1330 case ARIZONA_MIC_BIAS_CTRL_2:
1331 case ARIZONA_MIC_BIAS_CTRL_3:
1332 case ARIZONA_ACCESSORY_DETECT_MODE_1:
1333 case ARIZONA_HEADPHONE_DETECT_1:
1334 case ARIZONA_HEADPHONE_DETECT_2:
1335 case ARIZONA_MIC_DETECT_1:
1336 case ARIZONA_MIC_DETECT_2:
1337 case ARIZONA_MIC_DETECT_3:
1338 case ARIZONA_MIC_NOISE_MIX_CONTROL_1:
1339 case ARIZONA_JACK_DETECT_ANALOGUE:
1340 case ARIZONA_INPUT_ENABLES:
1341 case ARIZONA_INPUT_ENABLES_STATUS:
1342 case ARIZONA_INPUT_RATE:
1343 case ARIZONA_INPUT_VOLUME_RAMP:
1344 case ARIZONA_IN1L_CONTROL:
1345 case ARIZONA_ADC_DIGITAL_VOLUME_1L:
1346 case ARIZONA_DMIC1L_CONTROL:
1347 case ARIZONA_IN1R_CONTROL:
1348 case ARIZONA_ADC_DIGITAL_VOLUME_1R:
1349 case ARIZONA_DMIC1R_CONTROL:
1350 case ARIZONA_IN2L_CONTROL:
1351 case ARIZONA_ADC_DIGITAL_VOLUME_2L:
1352 case ARIZONA_DMIC2L_CONTROL:
1353 case ARIZONA_IN2R_CONTROL:
1354 case ARIZONA_ADC_DIGITAL_VOLUME_2R:
1355 case ARIZONA_DMIC2R_CONTROL:
1356 case ARIZONA_IN3L_CONTROL:
1357 case ARIZONA_ADC_DIGITAL_VOLUME_3L:
1358 case ARIZONA_DMIC3L_CONTROL:
1359 case ARIZONA_IN3R_CONTROL:
1360 case ARIZONA_ADC_DIGITAL_VOLUME_3R:
1361 case ARIZONA_DMIC3R_CONTROL:
1362 case ARIZONA_IN4L_CONTROL:
1363 case ARIZONA_ADC_DIGITAL_VOLUME_4L:
1364 case ARIZONA_DMIC4L_CONTROL:
1365 case ARIZONA_ADC_DIGITAL_VOLUME_4R:
1366 case ARIZONA_DMIC4R_CONTROL:
1367 case ARIZONA_OUTPUT_ENABLES_1:
1368 case ARIZONA_OUTPUT_STATUS_1:
1369 case ARIZONA_RAW_OUTPUT_STATUS_1:
1370 case ARIZONA_OUTPUT_RATE_1:
1371 case ARIZONA_OUTPUT_VOLUME_RAMP:
1372 case ARIZONA_OUTPUT_PATH_CONFIG_1L:
1373 case ARIZONA_DAC_DIGITAL_VOLUME_1L:
1374 case ARIZONA_DAC_VOLUME_LIMIT_1L:
1375 case ARIZONA_NOISE_GATE_SELECT_1L:
1376 case ARIZONA_OUTPUT_PATH_CONFIG_1R:
1377 case ARIZONA_DAC_DIGITAL_VOLUME_1R:
1378 case ARIZONA_DAC_VOLUME_LIMIT_1R:
1379 case ARIZONA_NOISE_GATE_SELECT_1R:
1380 case ARIZONA_OUTPUT_PATH_CONFIG_2L:
1381 case ARIZONA_DAC_DIGITAL_VOLUME_2L:
1382 case ARIZONA_DAC_VOLUME_LIMIT_2L:
1383 case ARIZONA_NOISE_GATE_SELECT_2L:
1384 case ARIZONA_OUTPUT_PATH_CONFIG_2R:
1385 case ARIZONA_DAC_DIGITAL_VOLUME_2R:
1386 case ARIZONA_DAC_VOLUME_LIMIT_2R:
1387 case ARIZONA_NOISE_GATE_SELECT_2R:
1388 case ARIZONA_OUTPUT_PATH_CONFIG_3L:
1389 case ARIZONA_DAC_DIGITAL_VOLUME_3L:
1390 case ARIZONA_DAC_VOLUME_LIMIT_3L:
1391 case ARIZONA_NOISE_GATE_SELECT_3L:
1392 case ARIZONA_OUTPUT_PATH_CONFIG_3R:
1393 case ARIZONA_DAC_DIGITAL_VOLUME_3R:
1394 case ARIZONA_DAC_VOLUME_LIMIT_3R:
1395 case ARIZONA_NOISE_GATE_SELECT_3R:
1396 case ARIZONA_OUTPUT_PATH_CONFIG_4L:
1397 case ARIZONA_DAC_DIGITAL_VOLUME_4L:
1398 case ARIZONA_OUT_VOLUME_4L:
1399 case ARIZONA_NOISE_GATE_SELECT_4L:
1400 case ARIZONA_OUTPUT_PATH_CONFIG_4R:
1401 case ARIZONA_DAC_DIGITAL_VOLUME_4R:
1402 case ARIZONA_OUT_VOLUME_4R:
1403 case ARIZONA_NOISE_GATE_SELECT_4R:
1404 case ARIZONA_OUTPUT_PATH_CONFIG_5L:
1405 case ARIZONA_DAC_DIGITAL_VOLUME_5L:
1406 case ARIZONA_DAC_VOLUME_LIMIT_5L:
1407 case ARIZONA_NOISE_GATE_SELECT_5L:
1408 case ARIZONA_OUTPUT_PATH_CONFIG_5R:
1409 case ARIZONA_DAC_DIGITAL_VOLUME_5R:
1410 case ARIZONA_DAC_VOLUME_LIMIT_5R:
1411 case ARIZONA_NOISE_GATE_SELECT_5R:
1412 case ARIZONA_OUTPUT_PATH_CONFIG_6L:
1413 case ARIZONA_DAC_DIGITAL_VOLUME_6L:
1414 case ARIZONA_DAC_VOLUME_LIMIT_6L:
1415 case ARIZONA_NOISE_GATE_SELECT_6L:
1416 case ARIZONA_OUTPUT_PATH_CONFIG_6R:
1417 case ARIZONA_DAC_DIGITAL_VOLUME_6R:
1418 case ARIZONA_DAC_VOLUME_LIMIT_6R:
1419 case ARIZONA_NOISE_GATE_SELECT_6R:
1420 case ARIZONA_DAC_AEC_CONTROL_1:
1421 case ARIZONA_NOISE_GATE_CONTROL:
1422 case ARIZONA_PDM_SPK1_CTRL_1:
1423 case ARIZONA_PDM_SPK1_CTRL_2:
1424 case ARIZONA_PDM_SPK2_CTRL_1:
1425 case ARIZONA_PDM_SPK2_CTRL_2:
1426 case ARIZONA_AIF1_BCLK_CTRL:
1427 case ARIZONA_AIF1_TX_PIN_CTRL:
1428 case ARIZONA_AIF1_RX_PIN_CTRL:
1429 case ARIZONA_AIF1_RATE_CTRL:
1430 case ARIZONA_AIF1_FORMAT:
1431 case ARIZONA_AIF1_TX_BCLK_RATE:
1432 case ARIZONA_AIF1_RX_BCLK_RATE:
1433 case ARIZONA_AIF1_FRAME_CTRL_1:
1434 case ARIZONA_AIF1_FRAME_CTRL_2:
1435 case ARIZONA_AIF1_FRAME_CTRL_3:
1436 case ARIZONA_AIF1_FRAME_CTRL_4:
1437 case ARIZONA_AIF1_FRAME_CTRL_5:
1438 case ARIZONA_AIF1_FRAME_CTRL_6:
1439 case ARIZONA_AIF1_FRAME_CTRL_7:
1440 case ARIZONA_AIF1_FRAME_CTRL_8:
1441 case ARIZONA_AIF1_FRAME_CTRL_9:
1442 case ARIZONA_AIF1_FRAME_CTRL_10:
1443 case ARIZONA_AIF1_FRAME_CTRL_11:
1444 case ARIZONA_AIF1_FRAME_CTRL_12:
1445 case ARIZONA_AIF1_FRAME_CTRL_13:
1446 case ARIZONA_AIF1_FRAME_CTRL_14:
1447 case ARIZONA_AIF1_FRAME_CTRL_15:
1448 case ARIZONA_AIF1_FRAME_CTRL_16:
1449 case ARIZONA_AIF1_FRAME_CTRL_17:
1450 case ARIZONA_AIF1_FRAME_CTRL_18:
1451 case ARIZONA_AIF1_TX_ENABLES:
1452 case ARIZONA_AIF1_RX_ENABLES:
1453 case ARIZONA_AIF2_BCLK_CTRL:
1454 case ARIZONA_AIF2_TX_PIN_CTRL:
1455 case ARIZONA_AIF2_RX_PIN_CTRL:
1456 case ARIZONA_AIF2_RATE_CTRL:
1457 case ARIZONA_AIF2_FORMAT:
1458 case ARIZONA_AIF2_TX_BCLK_RATE:
1459 case ARIZONA_AIF2_RX_BCLK_RATE:
1460 case ARIZONA_AIF2_FRAME_CTRL_1:
1461 case ARIZONA_AIF2_FRAME_CTRL_2:
1462 case ARIZONA_AIF2_FRAME_CTRL_3:
1463 case ARIZONA_AIF2_FRAME_CTRL_4:
1464 case ARIZONA_AIF2_FRAME_CTRL_11:
1465 case ARIZONA_AIF2_FRAME_CTRL_12:
1466 case ARIZONA_AIF2_TX_ENABLES:
1467 case ARIZONA_AIF2_RX_ENABLES:
1468 case ARIZONA_AIF3_BCLK_CTRL:
1469 case ARIZONA_AIF3_TX_PIN_CTRL:
1470 case ARIZONA_AIF3_RX_PIN_CTRL:
1471 case ARIZONA_AIF3_RATE_CTRL:
1472 case ARIZONA_AIF3_FORMAT:
1473 case ARIZONA_AIF3_TX_BCLK_RATE:
1474 case ARIZONA_AIF3_RX_BCLK_RATE:
1475 case ARIZONA_AIF3_FRAME_CTRL_1:
1476 case ARIZONA_AIF3_FRAME_CTRL_2:
1477 case ARIZONA_AIF3_FRAME_CTRL_3:
1478 case ARIZONA_AIF3_FRAME_CTRL_4:
1479 case ARIZONA_AIF3_FRAME_CTRL_11:
1480 case ARIZONA_AIF3_FRAME_CTRL_12:
1481 case ARIZONA_AIF3_TX_ENABLES:
1482 case ARIZONA_AIF3_RX_ENABLES:
1483 case ARIZONA_SLIMBUS_FRAMER_REF_GEAR:
1484 case ARIZONA_SLIMBUS_RATES_1:
1485 case ARIZONA_SLIMBUS_RATES_2:
1486 case ARIZONA_SLIMBUS_RATES_3:
1487 case ARIZONA_SLIMBUS_RATES_4:
1488 case ARIZONA_SLIMBUS_RATES_5:
1489 case ARIZONA_SLIMBUS_RATES_6:
1490 case ARIZONA_SLIMBUS_RATES_7:
1491 case ARIZONA_SLIMBUS_RATES_8:
1492 case ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE:
1493 case ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE:
1494 case ARIZONA_SLIMBUS_RX_PORT_STATUS:
1495 case ARIZONA_SLIMBUS_TX_PORT_STATUS:
1496 case ARIZONA_PWM1MIX_INPUT_1_SOURCE:
1497 case ARIZONA_PWM1MIX_INPUT_1_VOLUME:
1498 case ARIZONA_PWM1MIX_INPUT_2_SOURCE:
1499 case ARIZONA_PWM1MIX_INPUT_2_VOLUME:
1500 case ARIZONA_PWM1MIX_INPUT_3_SOURCE:
1501 case ARIZONA_PWM1MIX_INPUT_3_VOLUME:
1502 case ARIZONA_PWM1MIX_INPUT_4_SOURCE:
1503 case ARIZONA_PWM1MIX_INPUT_4_VOLUME:
1504 case ARIZONA_PWM2MIX_INPUT_1_SOURCE:
1505 case ARIZONA_PWM2MIX_INPUT_1_VOLUME:
1506 case ARIZONA_PWM2MIX_INPUT_2_SOURCE:
1507 case ARIZONA_PWM2MIX_INPUT_2_VOLUME:
1508 case ARIZONA_PWM2MIX_INPUT_3_SOURCE:
1509 case ARIZONA_PWM2MIX_INPUT_3_VOLUME:
1510 case ARIZONA_PWM2MIX_INPUT_4_SOURCE:
1511 case ARIZONA_PWM2MIX_INPUT_4_VOLUME:
1512 case ARIZONA_MICMIX_INPUT_1_SOURCE:
1513 case ARIZONA_MICMIX_INPUT_1_VOLUME:
1514 case ARIZONA_MICMIX_INPUT_2_SOURCE:
1515 case ARIZONA_MICMIX_INPUT_2_VOLUME:
1516 case ARIZONA_MICMIX_INPUT_3_SOURCE:
1517 case ARIZONA_MICMIX_INPUT_3_VOLUME:
1518 case ARIZONA_MICMIX_INPUT_4_SOURCE:
1519 case ARIZONA_MICMIX_INPUT_4_VOLUME:
1520 case ARIZONA_NOISEMIX_INPUT_1_SOURCE:
1521 case ARIZONA_NOISEMIX_INPUT_1_VOLUME:
1522 case ARIZONA_NOISEMIX_INPUT_2_SOURCE:
1523 case ARIZONA_NOISEMIX_INPUT_2_VOLUME:
1524 case ARIZONA_NOISEMIX_INPUT_3_SOURCE:
1525 case ARIZONA_NOISEMIX_INPUT_3_VOLUME:
1526 case ARIZONA_NOISEMIX_INPUT_4_SOURCE:
1527 case ARIZONA_NOISEMIX_INPUT_4_VOLUME:
1528 case ARIZONA_OUT1LMIX_INPUT_1_SOURCE:
1529 case ARIZONA_OUT1LMIX_INPUT_1_VOLUME:
1530 case ARIZONA_OUT1LMIX_INPUT_2_SOURCE:
1531 case ARIZONA_OUT1LMIX_INPUT_2_VOLUME:
1532 case ARIZONA_OUT1LMIX_INPUT_3_SOURCE:
1533 case ARIZONA_OUT1LMIX_INPUT_3_VOLUME:
1534 case ARIZONA_OUT1LMIX_INPUT_4_SOURCE:
1535 case ARIZONA_OUT1LMIX_INPUT_4_VOLUME:
1536 case ARIZONA_OUT1RMIX_INPUT_1_SOURCE:
1537 case ARIZONA_OUT1RMIX_INPUT_1_VOLUME:
1538 case ARIZONA_OUT1RMIX_INPUT_2_SOURCE:
1539 case ARIZONA_OUT1RMIX_INPUT_2_VOLUME:
1540 case ARIZONA_OUT1RMIX_INPUT_3_SOURCE:
1541 case ARIZONA_OUT1RMIX_INPUT_3_VOLUME:
1542 case ARIZONA_OUT1RMIX_INPUT_4_SOURCE:
1543 case ARIZONA_OUT1RMIX_INPUT_4_VOLUME:
1544 case ARIZONA_OUT2LMIX_INPUT_1_SOURCE:
1545 case ARIZONA_OUT2LMIX_INPUT_1_VOLUME:
1546 case ARIZONA_OUT2LMIX_INPUT_2_SOURCE:
1547 case ARIZONA_OUT2LMIX_INPUT_2_VOLUME:
1548 case ARIZONA_OUT2LMIX_INPUT_3_SOURCE:
1549 case ARIZONA_OUT2LMIX_INPUT_3_VOLUME:
1550 case ARIZONA_OUT2LMIX_INPUT_4_SOURCE:
1551 case ARIZONA_OUT2LMIX_INPUT_4_VOLUME:
1552 case ARIZONA_OUT2RMIX_INPUT_1_SOURCE:
1553 case ARIZONA_OUT2RMIX_INPUT_1_VOLUME:
1554 case ARIZONA_OUT2RMIX_INPUT_2_SOURCE:
1555 case ARIZONA_OUT2RMIX_INPUT_2_VOLUME:
1556 case ARIZONA_OUT2RMIX_INPUT_3_SOURCE:
1557 case ARIZONA_OUT2RMIX_INPUT_3_VOLUME:
1558 case ARIZONA_OUT2RMIX_INPUT_4_SOURCE:
1559 case ARIZONA_OUT2RMIX_INPUT_4_VOLUME:
1560 case ARIZONA_OUT3LMIX_INPUT_1_SOURCE:
1561 case ARIZONA_OUT3LMIX_INPUT_1_VOLUME:
1562 case ARIZONA_OUT3LMIX_INPUT_2_SOURCE:
1563 case ARIZONA_OUT3LMIX_INPUT_2_VOLUME:
1564 case ARIZONA_OUT3LMIX_INPUT_3_SOURCE:
1565 case ARIZONA_OUT3LMIX_INPUT_3_VOLUME:
1566 case ARIZONA_OUT3LMIX_INPUT_4_SOURCE:
1567 case ARIZONA_OUT3LMIX_INPUT_4_VOLUME:
1568 case ARIZONA_OUT3RMIX_INPUT_1_SOURCE:
1569 case ARIZONA_OUT3RMIX_INPUT_1_VOLUME:
1570 case ARIZONA_OUT3RMIX_INPUT_2_SOURCE:
1571 case ARIZONA_OUT3RMIX_INPUT_2_VOLUME:
1572 case ARIZONA_OUT3RMIX_INPUT_3_SOURCE:
1573 case ARIZONA_OUT3RMIX_INPUT_3_VOLUME:
1574 case ARIZONA_OUT3RMIX_INPUT_4_SOURCE:
1575 case ARIZONA_OUT3RMIX_INPUT_4_VOLUME:
1576 case ARIZONA_OUT4LMIX_INPUT_1_SOURCE:
1577 case ARIZONA_OUT4LMIX_INPUT_1_VOLUME:
1578 case ARIZONA_OUT4LMIX_INPUT_2_SOURCE:
1579 case ARIZONA_OUT4LMIX_INPUT_2_VOLUME:
1580 case ARIZONA_OUT4LMIX_INPUT_3_SOURCE:
1581 case ARIZONA_OUT4LMIX_INPUT_3_VOLUME:
1582 case ARIZONA_OUT4LMIX_INPUT_4_SOURCE:
1583 case ARIZONA_OUT4LMIX_INPUT_4_VOLUME:
1584 case ARIZONA_OUT4RMIX_INPUT_1_SOURCE:
1585 case ARIZONA_OUT4RMIX_INPUT_1_VOLUME:
1586 case ARIZONA_OUT4RMIX_INPUT_2_SOURCE:
1587 case ARIZONA_OUT4RMIX_INPUT_2_VOLUME:
1588 case ARIZONA_OUT4RMIX_INPUT_3_SOURCE:
1589 case ARIZONA_OUT4RMIX_INPUT_3_VOLUME:
1590 case ARIZONA_OUT4RMIX_INPUT_4_SOURCE:
1591 case ARIZONA_OUT4RMIX_INPUT_4_VOLUME:
1592 case ARIZONA_OUT5LMIX_INPUT_1_SOURCE:
1593 case ARIZONA_OUT5LMIX_INPUT_1_VOLUME:
1594 case ARIZONA_OUT5LMIX_INPUT_2_SOURCE:
1595 case ARIZONA_OUT5LMIX_INPUT_2_VOLUME:
1596 case ARIZONA_OUT5LMIX_INPUT_3_SOURCE:
1597 case ARIZONA_OUT5LMIX_INPUT_3_VOLUME:
1598 case ARIZONA_OUT5LMIX_INPUT_4_SOURCE:
1599 case ARIZONA_OUT5LMIX_INPUT_4_VOLUME:
1600 case ARIZONA_OUT5RMIX_INPUT_1_SOURCE:
1601 case ARIZONA_OUT5RMIX_INPUT_1_VOLUME:
1602 case ARIZONA_OUT5RMIX_INPUT_2_SOURCE:
1603 case ARIZONA_OUT5RMIX_INPUT_2_VOLUME:
1604 case ARIZONA_OUT5RMIX_INPUT_3_SOURCE:
1605 case ARIZONA_OUT5RMIX_INPUT_3_VOLUME:
1606 case ARIZONA_OUT5RMIX_INPUT_4_SOURCE:
1607 case ARIZONA_OUT5RMIX_INPUT_4_VOLUME:
1608 case ARIZONA_OUT6LMIX_INPUT_1_SOURCE:
1609 case ARIZONA_OUT6LMIX_INPUT_1_VOLUME:
1610 case ARIZONA_OUT6LMIX_INPUT_2_SOURCE:
1611 case ARIZONA_OUT6LMIX_INPUT_2_VOLUME:
1612 case ARIZONA_OUT6LMIX_INPUT_3_SOURCE:
1613 case ARIZONA_OUT6LMIX_INPUT_3_VOLUME:
1614 case ARIZONA_OUT6LMIX_INPUT_4_SOURCE:
1615 case ARIZONA_OUT6LMIX_INPUT_4_VOLUME:
1616 case ARIZONA_OUT6RMIX_INPUT_1_SOURCE:
1617 case ARIZONA_OUT6RMIX_INPUT_1_VOLUME:
1618 case ARIZONA_OUT6RMIX_INPUT_2_SOURCE:
1619 case ARIZONA_OUT6RMIX_INPUT_2_VOLUME:
1620 case ARIZONA_OUT6RMIX_INPUT_3_SOURCE:
1621 case ARIZONA_OUT6RMIX_INPUT_3_VOLUME:
1622 case ARIZONA_OUT6RMIX_INPUT_4_SOURCE:
1623 case ARIZONA_OUT6RMIX_INPUT_4_VOLUME:
1624 case ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE:
1625 case ARIZONA_AIF1TX1MIX_INPUT_1_VOLUME:
1626 case ARIZONA_AIF1TX1MIX_INPUT_2_SOURCE:
1627 case ARIZONA_AIF1TX1MIX_INPUT_2_VOLUME:
1628 case ARIZONA_AIF1TX1MIX_INPUT_3_SOURCE:
1629 case ARIZONA_AIF1TX1MIX_INPUT_3_VOLUME:
1630 case ARIZONA_AIF1TX1MIX_INPUT_4_SOURCE:
1631 case ARIZONA_AIF1TX1MIX_INPUT_4_VOLUME:
1632 case ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE:
1633 case ARIZONA_AIF1TX2MIX_INPUT_1_VOLUME:
1634 case ARIZONA_AIF1TX2MIX_INPUT_2_SOURCE:
1635 case ARIZONA_AIF1TX2MIX_INPUT_2_VOLUME:
1636 case ARIZONA_AIF1TX2MIX_INPUT_3_SOURCE:
1637 case ARIZONA_AIF1TX2MIX_INPUT_3_VOLUME:
1638 case ARIZONA_AIF1TX2MIX_INPUT_4_SOURCE:
1639 case ARIZONA_AIF1TX2MIX_INPUT_4_VOLUME:
1640 case ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE:
1641 case ARIZONA_AIF1TX3MIX_INPUT_1_VOLUME:
1642 case ARIZONA_AIF1TX3MIX_INPUT_2_SOURCE:
1643 case ARIZONA_AIF1TX3MIX_INPUT_2_VOLUME:
1644 case ARIZONA_AIF1TX3MIX_INPUT_3_SOURCE:
1645 case ARIZONA_AIF1TX3MIX_INPUT_3_VOLUME:
1646 case ARIZONA_AIF1TX3MIX_INPUT_4_SOURCE:
1647 case ARIZONA_AIF1TX3MIX_INPUT_4_VOLUME:
1648 case ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE:
1649 case ARIZONA_AIF1TX4MIX_INPUT_1_VOLUME:
1650 case ARIZONA_AIF1TX4MIX_INPUT_2_SOURCE:
1651 case ARIZONA_AIF1TX4MIX_INPUT_2_VOLUME:
1652 case ARIZONA_AIF1TX4MIX_INPUT_3_SOURCE:
1653 case ARIZONA_AIF1TX4MIX_INPUT_3_VOLUME:
1654 case ARIZONA_AIF1TX4MIX_INPUT_4_SOURCE:
1655 case ARIZONA_AIF1TX4MIX_INPUT_4_VOLUME:
1656 case ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE:
1657 case ARIZONA_AIF1TX5MIX_INPUT_1_VOLUME:
1658 case ARIZONA_AIF1TX5MIX_INPUT_2_SOURCE:
1659 case ARIZONA_AIF1TX5MIX_INPUT_2_VOLUME:
1660 case ARIZONA_AIF1TX5MIX_INPUT_3_SOURCE:
1661 case ARIZONA_AIF1TX5MIX_INPUT_3_VOLUME:
1662 case ARIZONA_AIF1TX5MIX_INPUT_4_SOURCE:
1663 case ARIZONA_AIF1TX5MIX_INPUT_4_VOLUME:
1664 case ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE:
1665 case ARIZONA_AIF1TX6MIX_INPUT_1_VOLUME:
1666 case ARIZONA_AIF1TX6MIX_INPUT_2_SOURCE:
1667 case ARIZONA_AIF1TX6MIX_INPUT_2_VOLUME:
1668 case ARIZONA_AIF1TX6MIX_INPUT_3_SOURCE:
1669 case ARIZONA_AIF1TX6MIX_INPUT_3_VOLUME:
1670 case ARIZONA_AIF1TX6MIX_INPUT_4_SOURCE:
1671 case ARIZONA_AIF1TX6MIX_INPUT_4_VOLUME:
1672 case ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE:
1673 case ARIZONA_AIF1TX7MIX_INPUT_1_VOLUME:
1674 case ARIZONA_AIF1TX7MIX_INPUT_2_SOURCE:
1675 case ARIZONA_AIF1TX7MIX_INPUT_2_VOLUME:
1676 case ARIZONA_AIF1TX7MIX_INPUT_3_SOURCE:
1677 case ARIZONA_AIF1TX7MIX_INPUT_3_VOLUME:
1678 case ARIZONA_AIF1TX7MIX_INPUT_4_SOURCE:
1679 case ARIZONA_AIF1TX7MIX_INPUT_4_VOLUME:
1680 case ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE:
1681 case ARIZONA_AIF1TX8MIX_INPUT_1_VOLUME:
1682 case ARIZONA_AIF1TX8MIX_INPUT_2_SOURCE:
1683 case ARIZONA_AIF1TX8MIX_INPUT_2_VOLUME:
1684 case ARIZONA_AIF1TX8MIX_INPUT_3_SOURCE:
1685 case ARIZONA_AIF1TX8MIX_INPUT_3_VOLUME:
1686 case ARIZONA_AIF1TX8MIX_INPUT_4_SOURCE:
1687 case ARIZONA_AIF1TX8MIX_INPUT_4_VOLUME:
1688 case ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE:
1689 case ARIZONA_AIF2TX1MIX_INPUT_1_VOLUME:
1690 case ARIZONA_AIF2TX1MIX_INPUT_2_SOURCE:
1691 case ARIZONA_AIF2TX1MIX_INPUT_2_VOLUME:
1692 case ARIZONA_AIF2TX1MIX_INPUT_3_SOURCE:
1693 case ARIZONA_AIF2TX1MIX_INPUT_3_VOLUME:
1694 case ARIZONA_AIF2TX1MIX_INPUT_4_SOURCE:
1695 case ARIZONA_AIF2TX1MIX_INPUT_4_VOLUME:
1696 case ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE:
1697 case ARIZONA_AIF2TX2MIX_INPUT_1_VOLUME:
1698 case ARIZONA_AIF2TX2MIX_INPUT_2_SOURCE:
1699 case ARIZONA_AIF2TX2MIX_INPUT_2_VOLUME:
1700 case ARIZONA_AIF2TX2MIX_INPUT_3_SOURCE:
1701 case ARIZONA_AIF2TX2MIX_INPUT_3_VOLUME:
1702 case ARIZONA_AIF2TX2MIX_INPUT_4_SOURCE:
1703 case ARIZONA_AIF2TX2MIX_INPUT_4_VOLUME:
1704 case ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE:
1705 case ARIZONA_AIF3TX1MIX_INPUT_1_VOLUME:
1706 case ARIZONA_AIF3TX1MIX_INPUT_2_SOURCE:
1707 case ARIZONA_AIF3TX1MIX_INPUT_2_VOLUME:
1708 case ARIZONA_AIF3TX1MIX_INPUT_3_SOURCE:
1709 case ARIZONA_AIF3TX1MIX_INPUT_3_VOLUME:
1710 case ARIZONA_AIF3TX1MIX_INPUT_4_SOURCE:
1711 case ARIZONA_AIF3TX1MIX_INPUT_4_VOLUME:
1712 case ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE:
1713 case ARIZONA_AIF3TX2MIX_INPUT_1_VOLUME:
1714 case ARIZONA_AIF3TX2MIX_INPUT_2_SOURCE:
1715 case ARIZONA_AIF3TX2MIX_INPUT_2_VOLUME:
1716 case ARIZONA_AIF3TX2MIX_INPUT_3_SOURCE:
1717 case ARIZONA_AIF3TX2MIX_INPUT_3_VOLUME:
1718 case ARIZONA_AIF3TX2MIX_INPUT_4_SOURCE:
1719 case ARIZONA_AIF3TX2MIX_INPUT_4_VOLUME:
1720 case ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE:
1721 case ARIZONA_SLIMTX1MIX_INPUT_1_VOLUME:
1722 case ARIZONA_SLIMTX1MIX_INPUT_2_SOURCE:
1723 case ARIZONA_SLIMTX1MIX_INPUT_2_VOLUME:
1724 case ARIZONA_SLIMTX1MIX_INPUT_3_SOURCE:
1725 case ARIZONA_SLIMTX1MIX_INPUT_3_VOLUME:
1726 case ARIZONA_SLIMTX1MIX_INPUT_4_SOURCE:
1727 case ARIZONA_SLIMTX1MIX_INPUT_4_VOLUME:
1728 case ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE:
1729 case ARIZONA_SLIMTX2MIX_INPUT_1_VOLUME:
1730 case ARIZONA_SLIMTX2MIX_INPUT_2_SOURCE:
1731 case ARIZONA_SLIMTX2MIX_INPUT_2_VOLUME:
1732 case ARIZONA_SLIMTX2MIX_INPUT_3_SOURCE:
1733 case ARIZONA_SLIMTX2MIX_INPUT_3_VOLUME:
1734 case ARIZONA_SLIMTX2MIX_INPUT_4_SOURCE:
1735 case ARIZONA_SLIMTX2MIX_INPUT_4_VOLUME:
1736 case ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE:
1737 case ARIZONA_SLIMTX3MIX_INPUT_1_VOLUME:
1738 case ARIZONA_SLIMTX3MIX_INPUT_2_SOURCE:
1739 case ARIZONA_SLIMTX3MIX_INPUT_2_VOLUME:
1740 case ARIZONA_SLIMTX3MIX_INPUT_3_SOURCE:
1741 case ARIZONA_SLIMTX3MIX_INPUT_3_VOLUME:
1742 case ARIZONA_SLIMTX3MIX_INPUT_4_SOURCE:
1743 case ARIZONA_SLIMTX3MIX_INPUT_4_VOLUME:
1744 case ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE:
1745 case ARIZONA_SLIMTX4MIX_INPUT_1_VOLUME:
1746 case ARIZONA_SLIMTX4MIX_INPUT_2_SOURCE:
1747 case ARIZONA_SLIMTX4MIX_INPUT_2_VOLUME:
1748 case ARIZONA_SLIMTX4MIX_INPUT_3_SOURCE:
1749 case ARIZONA_SLIMTX4MIX_INPUT_3_VOLUME:
1750 case ARIZONA_SLIMTX4MIX_INPUT_4_SOURCE:
1751 case ARIZONA_SLIMTX4MIX_INPUT_4_VOLUME:
1752 case ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE:
1753 case ARIZONA_SLIMTX5MIX_INPUT_1_VOLUME:
1754 case ARIZONA_SLIMTX5MIX_INPUT_2_SOURCE:
1755 case ARIZONA_SLIMTX5MIX_INPUT_2_VOLUME:
1756 case ARIZONA_SLIMTX5MIX_INPUT_3_SOURCE:
1757 case ARIZONA_SLIMTX5MIX_INPUT_3_VOLUME:
1758 case ARIZONA_SLIMTX5MIX_INPUT_4_SOURCE:
1759 case ARIZONA_SLIMTX5MIX_INPUT_4_VOLUME:
1760 case ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE:
1761 case ARIZONA_SLIMTX6MIX_INPUT_1_VOLUME:
1762 case ARIZONA_SLIMTX6MIX_INPUT_2_SOURCE:
1763 case ARIZONA_SLIMTX6MIX_INPUT_2_VOLUME:
1764 case ARIZONA_SLIMTX6MIX_INPUT_3_SOURCE:
1765 case ARIZONA_SLIMTX6MIX_INPUT_3_VOLUME:
1766 case ARIZONA_SLIMTX6MIX_INPUT_4_SOURCE:
1767 case ARIZONA_SLIMTX6MIX_INPUT_4_VOLUME:
1768 case ARIZONA_SLIMTX7MIX_INPUT_1_SOURCE:
1769 case ARIZONA_SLIMTX7MIX_INPUT_1_VOLUME:
1770 case ARIZONA_SLIMTX7MIX_INPUT_2_SOURCE:
1771 case ARIZONA_SLIMTX7MIX_INPUT_2_VOLUME:
1772 case ARIZONA_SLIMTX7MIX_INPUT_3_SOURCE:
1773 case ARIZONA_SLIMTX7MIX_INPUT_3_VOLUME:
1774 case ARIZONA_SLIMTX7MIX_INPUT_4_SOURCE:
1775 case ARIZONA_SLIMTX7MIX_INPUT_4_VOLUME:
1776 case ARIZONA_SLIMTX8MIX_INPUT_1_SOURCE:
1777 case ARIZONA_SLIMTX8MIX_INPUT_1_VOLUME:
1778 case ARIZONA_SLIMTX8MIX_INPUT_2_SOURCE:
1779 case ARIZONA_SLIMTX8MIX_INPUT_2_VOLUME:
1780 case ARIZONA_SLIMTX8MIX_INPUT_3_SOURCE:
1781 case ARIZONA_SLIMTX8MIX_INPUT_3_VOLUME:
1782 case ARIZONA_SLIMTX8MIX_INPUT_4_SOURCE:
1783 case ARIZONA_SLIMTX8MIX_INPUT_4_VOLUME:
1784 case ARIZONA_EQ1MIX_INPUT_1_SOURCE:
1785 case ARIZONA_EQ1MIX_INPUT_1_VOLUME:
1786 case ARIZONA_EQ1MIX_INPUT_2_SOURCE:
1787 case ARIZONA_EQ1MIX_INPUT_2_VOLUME:
1788 case ARIZONA_EQ1MIX_INPUT_3_SOURCE:
1789 case ARIZONA_EQ1MIX_INPUT_3_VOLUME:
1790 case ARIZONA_EQ1MIX_INPUT_4_SOURCE:
1791 case ARIZONA_EQ1MIX_INPUT_4_VOLUME:
1792 case ARIZONA_EQ2MIX_INPUT_1_SOURCE:
1793 case ARIZONA_EQ2MIX_INPUT_1_VOLUME:
1794 case ARIZONA_EQ2MIX_INPUT_2_SOURCE:
1795 case ARIZONA_EQ2MIX_INPUT_2_VOLUME:
1796 case ARIZONA_EQ2MIX_INPUT_3_SOURCE:
1797 case ARIZONA_EQ2MIX_INPUT_3_VOLUME:
1798 case ARIZONA_EQ2MIX_INPUT_4_SOURCE:
1799 case ARIZONA_EQ2MIX_INPUT_4_VOLUME:
1800 case ARIZONA_EQ3MIX_INPUT_1_SOURCE:
1801 case ARIZONA_EQ3MIX_INPUT_1_VOLUME:
1802 case ARIZONA_EQ3MIX_INPUT_2_SOURCE:
1803 case ARIZONA_EQ3MIX_INPUT_2_VOLUME:
1804 case ARIZONA_EQ3MIX_INPUT_3_SOURCE:
1805 case ARIZONA_EQ3MIX_INPUT_3_VOLUME:
1806 case ARIZONA_EQ3MIX_INPUT_4_SOURCE:
1807 case ARIZONA_EQ3MIX_INPUT_4_VOLUME:
1808 case ARIZONA_EQ4MIX_INPUT_1_SOURCE:
1809 case ARIZONA_EQ4MIX_INPUT_1_VOLUME:
1810 case ARIZONA_EQ4MIX_INPUT_2_SOURCE:
1811 case ARIZONA_EQ4MIX_INPUT_2_VOLUME:
1812 case ARIZONA_EQ4MIX_INPUT_3_SOURCE:
1813 case ARIZONA_EQ4MIX_INPUT_3_VOLUME:
1814 case ARIZONA_EQ4MIX_INPUT_4_SOURCE:
1815 case ARIZONA_EQ4MIX_INPUT_4_VOLUME:
1816 case ARIZONA_DRC1LMIX_INPUT_1_SOURCE:
1817 case ARIZONA_DRC1LMIX_INPUT_1_VOLUME:
1818 case ARIZONA_DRC1LMIX_INPUT_2_SOURCE:
1819 case ARIZONA_DRC1LMIX_INPUT_2_VOLUME:
1820 case ARIZONA_DRC1LMIX_INPUT_3_SOURCE:
1821 case ARIZONA_DRC1LMIX_INPUT_3_VOLUME:
1822 case ARIZONA_DRC1LMIX_INPUT_4_SOURCE:
1823 case ARIZONA_DRC1LMIX_INPUT_4_VOLUME:
1824 case ARIZONA_DRC1RMIX_INPUT_1_SOURCE:
1825 case ARIZONA_DRC1RMIX_INPUT_1_VOLUME:
1826 case ARIZONA_DRC1RMIX_INPUT_2_SOURCE:
1827 case ARIZONA_DRC1RMIX_INPUT_2_VOLUME:
1828 case ARIZONA_DRC1RMIX_INPUT_3_SOURCE:
1829 case ARIZONA_DRC1RMIX_INPUT_3_VOLUME:
1830 case ARIZONA_DRC1RMIX_INPUT_4_SOURCE:
1831 case ARIZONA_DRC1RMIX_INPUT_4_VOLUME:
1832 case ARIZONA_DRC2LMIX_INPUT_1_SOURCE:
1833 case ARIZONA_DRC2LMIX_INPUT_1_VOLUME:
1834 case ARIZONA_DRC2LMIX_INPUT_2_SOURCE:
1835 case ARIZONA_DRC2LMIX_INPUT_2_VOLUME:
1836 case ARIZONA_DRC2LMIX_INPUT_3_SOURCE:
1837 case ARIZONA_DRC2LMIX_INPUT_3_VOLUME:
1838 case ARIZONA_DRC2LMIX_INPUT_4_SOURCE:
1839 case ARIZONA_DRC2LMIX_INPUT_4_VOLUME:
1840 case ARIZONA_DRC2RMIX_INPUT_1_SOURCE:
1841 case ARIZONA_DRC2RMIX_INPUT_1_VOLUME:
1842 case ARIZONA_DRC2RMIX_INPUT_2_SOURCE:
1843 case ARIZONA_DRC2RMIX_INPUT_2_VOLUME:
1844 case ARIZONA_DRC2RMIX_INPUT_3_SOURCE:
1845 case ARIZONA_DRC2RMIX_INPUT_3_VOLUME:
1846 case ARIZONA_DRC2RMIX_INPUT_4_SOURCE:
1847 case ARIZONA_DRC2RMIX_INPUT_4_VOLUME:
1848 case ARIZONA_HPLP1MIX_INPUT_1_SOURCE:
1849 case ARIZONA_HPLP1MIX_INPUT_1_VOLUME:
1850 case ARIZONA_HPLP1MIX_INPUT_2_SOURCE:
1851 case ARIZONA_HPLP1MIX_INPUT_2_VOLUME:
1852 case ARIZONA_HPLP1MIX_INPUT_3_SOURCE:
1853 case ARIZONA_HPLP1MIX_INPUT_3_VOLUME:
1854 case ARIZONA_HPLP1MIX_INPUT_4_SOURCE:
1855 case ARIZONA_HPLP1MIX_INPUT_4_VOLUME:
1856 case ARIZONA_HPLP2MIX_INPUT_1_SOURCE:
1857 case ARIZONA_HPLP2MIX_INPUT_1_VOLUME:
1858 case ARIZONA_HPLP2MIX_INPUT_2_SOURCE:
1859 case ARIZONA_HPLP2MIX_INPUT_2_VOLUME:
1860 case ARIZONA_HPLP2MIX_INPUT_3_SOURCE:
1861 case ARIZONA_HPLP2MIX_INPUT_3_VOLUME:
1862 case ARIZONA_HPLP2MIX_INPUT_4_SOURCE:
1863 case ARIZONA_HPLP2MIX_INPUT_4_VOLUME:
1864 case ARIZONA_HPLP3MIX_INPUT_1_SOURCE:
1865 case ARIZONA_HPLP3MIX_INPUT_1_VOLUME:
1866 case ARIZONA_HPLP3MIX_INPUT_2_SOURCE:
1867 case ARIZONA_HPLP3MIX_INPUT_2_VOLUME:
1868 case ARIZONA_HPLP3MIX_INPUT_3_SOURCE:
1869 case ARIZONA_HPLP3MIX_INPUT_3_VOLUME:
1870 case ARIZONA_HPLP3MIX_INPUT_4_SOURCE:
1871 case ARIZONA_HPLP3MIX_INPUT_4_VOLUME:
1872 case ARIZONA_HPLP4MIX_INPUT_1_SOURCE:
1873 case ARIZONA_HPLP4MIX_INPUT_1_VOLUME:
1874 case ARIZONA_HPLP4MIX_INPUT_2_SOURCE:
1875 case ARIZONA_HPLP4MIX_INPUT_2_VOLUME:
1876 case ARIZONA_HPLP4MIX_INPUT_3_SOURCE:
1877 case ARIZONA_HPLP4MIX_INPUT_3_VOLUME:
1878 case ARIZONA_HPLP4MIX_INPUT_4_SOURCE:
1879 case ARIZONA_HPLP4MIX_INPUT_4_VOLUME:
1880 case ARIZONA_DSP1LMIX_INPUT_1_SOURCE:
1881 case ARIZONA_DSP1LMIX_INPUT_1_VOLUME:
1882 case ARIZONA_DSP1LMIX_INPUT_2_SOURCE:
1883 case ARIZONA_DSP1LMIX_INPUT_2_VOLUME:
1884 case ARIZONA_DSP1LMIX_INPUT_3_SOURCE:
1885 case ARIZONA_DSP1LMIX_INPUT_3_VOLUME:
1886 case ARIZONA_DSP1LMIX_INPUT_4_SOURCE:
1887 case ARIZONA_DSP1LMIX_INPUT_4_VOLUME:
1888 case ARIZONA_DSP1RMIX_INPUT_1_SOURCE:
1889 case ARIZONA_DSP1RMIX_INPUT_1_VOLUME:
1890 case ARIZONA_DSP1RMIX_INPUT_2_SOURCE:
1891 case ARIZONA_DSP1RMIX_INPUT_2_VOLUME:
1892 case ARIZONA_DSP1RMIX_INPUT_3_SOURCE:
1893 case ARIZONA_DSP1RMIX_INPUT_3_VOLUME:
1894 case ARIZONA_DSP1RMIX_INPUT_4_SOURCE:
1895 case ARIZONA_DSP1RMIX_INPUT_4_VOLUME:
1896 case ARIZONA_DSP1AUX1MIX_INPUT_1_SOURCE:
1897 case ARIZONA_DSP1AUX2MIX_INPUT_1_SOURCE:
1898 case ARIZONA_DSP1AUX3MIX_INPUT_1_SOURCE:
1899 case ARIZONA_DSP1AUX4MIX_INPUT_1_SOURCE:
1900 case ARIZONA_DSP1AUX5MIX_INPUT_1_SOURCE:
1901 case ARIZONA_DSP1AUX6MIX_INPUT_1_SOURCE:
1902 case ARIZONA_DSP2LMIX_INPUT_1_SOURCE:
1903 case ARIZONA_DSP2LMIX_INPUT_1_VOLUME:
1904 case ARIZONA_DSP2LMIX_INPUT_2_SOURCE:
1905 case ARIZONA_DSP2LMIX_INPUT_2_VOLUME:
1906 case ARIZONA_DSP2LMIX_INPUT_3_SOURCE:
1907 case ARIZONA_DSP2LMIX_INPUT_3_VOLUME:
1908 case ARIZONA_DSP2LMIX_INPUT_4_SOURCE:
1909 case ARIZONA_DSP2LMIX_INPUT_4_VOLUME:
1910 case ARIZONA_DSP2RMIX_INPUT_1_SOURCE:
1911 case ARIZONA_DSP2RMIX_INPUT_1_VOLUME:
1912 case ARIZONA_DSP2RMIX_INPUT_2_SOURCE:
1913 case ARIZONA_DSP2RMIX_INPUT_2_VOLUME:
1914 case ARIZONA_DSP2RMIX_INPUT_3_SOURCE:
1915 case ARIZONA_DSP2RMIX_INPUT_3_VOLUME:
1916 case ARIZONA_DSP2RMIX_INPUT_4_SOURCE:
1917 case ARIZONA_DSP2RMIX_INPUT_4_VOLUME:
1918 case ARIZONA_DSP2AUX1MIX_INPUT_1_SOURCE:
1919 case ARIZONA_DSP2AUX2MIX_INPUT_1_SOURCE:
1920 case ARIZONA_DSP2AUX3MIX_INPUT_1_SOURCE:
1921 case ARIZONA_DSP2AUX4MIX_INPUT_1_SOURCE:
1922 case ARIZONA_DSP2AUX5MIX_INPUT_1_SOURCE:
1923 case ARIZONA_DSP2AUX6MIX_INPUT_1_SOURCE:
1924 case ARIZONA_DSP3LMIX_INPUT_1_SOURCE:
1925 case ARIZONA_DSP3LMIX_INPUT_1_VOLUME:
1926 case ARIZONA_DSP3LMIX_INPUT_2_SOURCE:
1927 case ARIZONA_DSP3LMIX_INPUT_2_VOLUME:
1928 case ARIZONA_DSP3LMIX_INPUT_3_SOURCE:
1929 case ARIZONA_DSP3LMIX_INPUT_3_VOLUME:
1930 case ARIZONA_DSP3LMIX_INPUT_4_SOURCE:
1931 case ARIZONA_DSP3LMIX_INPUT_4_VOLUME:
1932 case ARIZONA_DSP3RMIX_INPUT_1_SOURCE:
1933 case ARIZONA_DSP3RMIX_INPUT_1_VOLUME:
1934 case ARIZONA_DSP3RMIX_INPUT_2_SOURCE:
1935 case ARIZONA_DSP3RMIX_INPUT_2_VOLUME:
1936 case ARIZONA_DSP3RMIX_INPUT_3_SOURCE:
1937 case ARIZONA_DSP3RMIX_INPUT_3_VOLUME:
1938 case ARIZONA_DSP3RMIX_INPUT_4_SOURCE:
1939 case ARIZONA_DSP3RMIX_INPUT_4_VOLUME:
1940 case ARIZONA_DSP3AUX1MIX_INPUT_1_SOURCE:
1941 case ARIZONA_DSP3AUX2MIX_INPUT_1_SOURCE:
1942 case ARIZONA_DSP3AUX3MIX_INPUT_1_SOURCE:
1943 case ARIZONA_DSP3AUX4MIX_INPUT_1_SOURCE:
1944 case ARIZONA_DSP3AUX5MIX_INPUT_1_SOURCE:
1945 case ARIZONA_DSP3AUX6MIX_INPUT_1_SOURCE:
1946 case ARIZONA_DSP4LMIX_INPUT_1_SOURCE:
1947 case ARIZONA_DSP4LMIX_INPUT_1_VOLUME:
1948 case ARIZONA_DSP4LMIX_INPUT_2_SOURCE:
1949 case ARIZONA_DSP4LMIX_INPUT_2_VOLUME:
1950 case ARIZONA_DSP4LMIX_INPUT_3_SOURCE:
1951 case ARIZONA_DSP4LMIX_INPUT_3_VOLUME:
1952 case ARIZONA_DSP4LMIX_INPUT_4_SOURCE:
1953 case ARIZONA_DSP4LMIX_INPUT_4_VOLUME:
1954 case ARIZONA_DSP4RMIX_INPUT_1_SOURCE:
1955 case ARIZONA_DSP4RMIX_INPUT_1_VOLUME:
1956 case ARIZONA_DSP4RMIX_INPUT_2_SOURCE:
1957 case ARIZONA_DSP4RMIX_INPUT_2_VOLUME:
1958 case ARIZONA_DSP4RMIX_INPUT_3_SOURCE:
1959 case ARIZONA_DSP4RMIX_INPUT_3_VOLUME:
1960 case ARIZONA_DSP4RMIX_INPUT_4_SOURCE:
1961 case ARIZONA_DSP4RMIX_INPUT_4_VOLUME:
1962 case ARIZONA_DSP4AUX1MIX_INPUT_1_SOURCE:
1963 case ARIZONA_DSP4AUX2MIX_INPUT_1_SOURCE:
1964 case ARIZONA_DSP4AUX3MIX_INPUT_1_SOURCE:
1965 case ARIZONA_DSP4AUX4MIX_INPUT_1_SOURCE:
1966 case ARIZONA_DSP4AUX5MIX_INPUT_1_SOURCE:
1967 case ARIZONA_DSP4AUX6MIX_INPUT_1_SOURCE:
1968 case ARIZONA_ASRC1LMIX_INPUT_1_SOURCE:
1969 case ARIZONA_ASRC1RMIX_INPUT_1_SOURCE:
1970 case ARIZONA_ASRC2LMIX_INPUT_1_SOURCE:
1971 case ARIZONA_ASRC2RMIX_INPUT_1_SOURCE:
1972 case ARIZONA_ISRC1DEC1MIX_INPUT_1_SOURCE:
1973 case ARIZONA_ISRC1DEC2MIX_INPUT_1_SOURCE:
1974 case ARIZONA_ISRC1DEC3MIX_INPUT_1_SOURCE:
1975 case ARIZONA_ISRC1DEC4MIX_INPUT_1_SOURCE:
1976 case ARIZONA_ISRC1INT1MIX_INPUT_1_SOURCE:
1977 case ARIZONA_ISRC1INT2MIX_INPUT_1_SOURCE:
1978 case ARIZONA_ISRC1INT3MIX_INPUT_1_SOURCE:
1979 case ARIZONA_ISRC1INT4MIX_INPUT_1_SOURCE:
1980 case ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE:
1981 case ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE:
1982 case ARIZONA_ISRC2DEC3MIX_INPUT_1_SOURCE:
1983 case ARIZONA_ISRC2DEC4MIX_INPUT_1_SOURCE:
1984 case ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE:
1985 case ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE:
1986 case ARIZONA_ISRC2INT3MIX_INPUT_1_SOURCE:
1987 case ARIZONA_ISRC2INT4MIX_INPUT_1_SOURCE:
1988 case ARIZONA_ISRC3DEC1MIX_INPUT_1_SOURCE:
1989 case ARIZONA_ISRC3DEC2MIX_INPUT_1_SOURCE:
1990 case ARIZONA_ISRC3DEC3MIX_INPUT_1_SOURCE:
1991 case ARIZONA_ISRC3DEC4MIX_INPUT_1_SOURCE:
1992 case ARIZONA_ISRC3INT1MIX_INPUT_1_SOURCE:
1993 case ARIZONA_ISRC3INT2MIX_INPUT_1_SOURCE:
1994 case ARIZONA_ISRC3INT3MIX_INPUT_1_SOURCE:
1995 case ARIZONA_ISRC3INT4MIX_INPUT_1_SOURCE:
1996 case ARIZONA_GPIO1_CTRL:
1997 case ARIZONA_GPIO2_CTRL:
1998 case ARIZONA_GPIO3_CTRL:
1999 case ARIZONA_GPIO4_CTRL:
2000 case ARIZONA_GPIO5_CTRL:
2001 case ARIZONA_IRQ_CTRL_1:
2002 case ARIZONA_GPIO_DEBOUNCE_CONFIG:
2003 case ARIZONA_MISC_PAD_CTRL_1:
2004 case ARIZONA_MISC_PAD_CTRL_2:
2005 case ARIZONA_MISC_PAD_CTRL_3:
2006 case ARIZONA_MISC_PAD_CTRL_4:
2007 case ARIZONA_MISC_PAD_CTRL_5:
2008 case ARIZONA_MISC_PAD_CTRL_6:
2009 case ARIZONA_MISC_PAD_CTRL_7:
2010 case ARIZONA_MISC_PAD_CTRL_8:
2011 case ARIZONA_MISC_PAD_CTRL_9:
2012 case ARIZONA_MISC_PAD_CTRL_10:
2013 case ARIZONA_MISC_PAD_CTRL_11:
2014 case ARIZONA_MISC_PAD_CTRL_12:
2015 case ARIZONA_MISC_PAD_CTRL_13:
2016 case ARIZONA_MISC_PAD_CTRL_14:
2017 case ARIZONA_MISC_PAD_CTRL_15:
2018 case ARIZONA_MISC_PAD_CTRL_16:
2019 case ARIZONA_MISC_PAD_CTRL_17:
2020 case ARIZONA_MISC_PAD_CTRL_18:
2021 case ARIZONA_INTERRUPT_STATUS_1:
2022 case ARIZONA_INTERRUPT_STATUS_2:
2023 case ARIZONA_INTERRUPT_STATUS_3:
2024 case ARIZONA_INTERRUPT_STATUS_4:
2025 case ARIZONA_INTERRUPT_STATUS_5:
2026 case ARIZONA_INTERRUPT_STATUS_1_MASK:
2027 case ARIZONA_INTERRUPT_STATUS_2_MASK:
2028 case ARIZONA_INTERRUPT_STATUS_3_MASK:
2029 case ARIZONA_INTERRUPT_STATUS_4_MASK:
2030 case ARIZONA_INTERRUPT_STATUS_5_MASK:
2031 case ARIZONA_INTERRUPT_CONTROL:
2032 case ARIZONA_IRQ2_STATUS_1:
2033 case ARIZONA_IRQ2_STATUS_2:
2034 case ARIZONA_IRQ2_STATUS_3:
2035 case ARIZONA_IRQ2_STATUS_4:
2036 case ARIZONA_IRQ2_STATUS_5:
2037 case ARIZONA_IRQ2_STATUS_1_MASK:
2038 case ARIZONA_IRQ2_STATUS_2_MASK:
2039 case ARIZONA_IRQ2_STATUS_3_MASK:
2040 case ARIZONA_IRQ2_STATUS_4_MASK:
2041 case ARIZONA_IRQ2_STATUS_5_MASK:
2042 case ARIZONA_IRQ2_CONTROL:
2043 case ARIZONA_INTERRUPT_RAW_STATUS_2:
2044 case ARIZONA_INTERRUPT_RAW_STATUS_3:
2045 case ARIZONA_INTERRUPT_RAW_STATUS_4:
2046 case ARIZONA_INTERRUPT_RAW_STATUS_5:
2047 case ARIZONA_INTERRUPT_RAW_STATUS_6:
2048 case ARIZONA_INTERRUPT_RAW_STATUS_7:
2049 case ARIZONA_INTERRUPT_RAW_STATUS_8:
2050 case ARIZONA_IRQ_PIN_STATUS:
2051 case ARIZONA_AOD_WKUP_AND_TRIG:
2052 case ARIZONA_AOD_IRQ1:
2053 case ARIZONA_AOD_IRQ2:
2054 case ARIZONA_AOD_IRQ_MASK_IRQ1:
2055 case ARIZONA_AOD_IRQ_MASK_IRQ2:
2056 case ARIZONA_AOD_IRQ_RAW_STATUS:
2057 case ARIZONA_JACK_DETECT_DEBOUNCE:
2058 case ARIZONA_FX_CTRL1:
2059 case ARIZONA_FX_CTRL2:
2060 case ARIZONA_EQ1_1:
2061 case ARIZONA_EQ1_2:
2062 case ARIZONA_EQ1_3:
2063 case ARIZONA_EQ1_4:
2064 case ARIZONA_EQ1_5:
2065 case ARIZONA_EQ1_6:
2066 case ARIZONA_EQ1_7:
2067 case ARIZONA_EQ1_8:
2068 case ARIZONA_EQ1_9:
2069 case ARIZONA_EQ1_10:
2070 case ARIZONA_EQ1_11:
2071 case ARIZONA_EQ1_12:
2072 case ARIZONA_EQ1_13:
2073 case ARIZONA_EQ1_14:
2074 case ARIZONA_EQ1_15:
2075 case ARIZONA_EQ1_16:
2076 case ARIZONA_EQ1_17:
2077 case ARIZONA_EQ1_18:
2078 case ARIZONA_EQ1_19:
2079 case ARIZONA_EQ1_20:
2080 case ARIZONA_EQ1_21:
2081 case ARIZONA_EQ2_1:
2082 case ARIZONA_EQ2_2:
2083 case ARIZONA_EQ2_3:
2084 case ARIZONA_EQ2_4:
2085 case ARIZONA_EQ2_5:
2086 case ARIZONA_EQ2_6:
2087 case ARIZONA_EQ2_7:
2088 case ARIZONA_EQ2_8:
2089 case ARIZONA_EQ2_9:
2090 case ARIZONA_EQ2_10:
2091 case ARIZONA_EQ2_11:
2092 case ARIZONA_EQ2_12:
2093 case ARIZONA_EQ2_13:
2094 case ARIZONA_EQ2_14:
2095 case ARIZONA_EQ2_15:
2096 case ARIZONA_EQ2_16:
2097 case ARIZONA_EQ2_17:
2098 case ARIZONA_EQ2_18:
2099 case ARIZONA_EQ2_19:
2100 case ARIZONA_EQ2_20:
2101 case ARIZONA_EQ2_21:
2102 case ARIZONA_EQ3_1:
2103 case ARIZONA_EQ3_2:
2104 case ARIZONA_EQ3_3:
2105 case ARIZONA_EQ3_4:
2106 case ARIZONA_EQ3_5:
2107 case ARIZONA_EQ3_6:
2108 case ARIZONA_EQ3_7:
2109 case ARIZONA_EQ3_8:
2110 case ARIZONA_EQ3_9:
2111 case ARIZONA_EQ3_10:
2112 case ARIZONA_EQ3_11:
2113 case ARIZONA_EQ3_12:
2114 case ARIZONA_EQ3_13:
2115 case ARIZONA_EQ3_14:
2116 case ARIZONA_EQ3_15:
2117 case ARIZONA_EQ3_16:
2118 case ARIZONA_EQ3_17:
2119 case ARIZONA_EQ3_18:
2120 case ARIZONA_EQ3_19:
2121 case ARIZONA_EQ3_20:
2122 case ARIZONA_EQ3_21:
2123 case ARIZONA_EQ4_1:
2124 case ARIZONA_EQ4_2:
2125 case ARIZONA_EQ4_3:
2126 case ARIZONA_EQ4_4:
2127 case ARIZONA_EQ4_5:
2128 case ARIZONA_EQ4_6:
2129 case ARIZONA_EQ4_7:
2130 case ARIZONA_EQ4_8:
2131 case ARIZONA_EQ4_9:
2132 case ARIZONA_EQ4_10:
2133 case ARIZONA_EQ4_11:
2134 case ARIZONA_EQ4_12:
2135 case ARIZONA_EQ4_13:
2136 case ARIZONA_EQ4_14:
2137 case ARIZONA_EQ4_15:
2138 case ARIZONA_EQ4_16:
2139 case ARIZONA_EQ4_17:
2140 case ARIZONA_EQ4_18:
2141 case ARIZONA_EQ4_19:
2142 case ARIZONA_EQ4_20:
2143 case ARIZONA_EQ4_21:
2144 case ARIZONA_DRC1_CTRL1:
2145 case ARIZONA_DRC1_CTRL2:
2146 case ARIZONA_DRC1_CTRL3:
2147 case ARIZONA_DRC1_CTRL4:
2148 case ARIZONA_DRC1_CTRL5:
2149 case ARIZONA_DRC2_CTRL1:
2150 case ARIZONA_DRC2_CTRL2:
2151 case ARIZONA_DRC2_CTRL3:
2152 case ARIZONA_DRC2_CTRL4:
2153 case ARIZONA_DRC2_CTRL5:
2154 case ARIZONA_HPLPF1_1:
2155 case ARIZONA_HPLPF1_2:
2156 case ARIZONA_HPLPF2_1:
2157 case ARIZONA_HPLPF2_2:
2158 case ARIZONA_HPLPF3_1:
2159 case ARIZONA_HPLPF3_2:
2160 case ARIZONA_HPLPF4_1:
2161 case ARIZONA_HPLPF4_2:
2162 case ARIZONA_ASRC_ENABLE:
2163 case ARIZONA_ASRC_STATUS:
2164 case ARIZONA_ASRC_RATE1:
2165 case ARIZONA_ISRC_1_CTRL_1:
2166 case ARIZONA_ISRC_1_CTRL_2:
2167 case ARIZONA_ISRC_1_CTRL_3:
2168 case ARIZONA_ISRC_2_CTRL_1:
2169 case ARIZONA_ISRC_2_CTRL_2:
2170 case ARIZONA_ISRC_2_CTRL_3:
2171 case ARIZONA_ISRC_3_CTRL_1:
2172 case ARIZONA_ISRC_3_CTRL_2:
2173 case ARIZONA_ISRC_3_CTRL_3:
2174 case ARIZONA_CLOCK_CONTROL:
2175 case ARIZONA_ANC_SRC:
2176 case ARIZONA_DSP_STATUS:
2177 case ARIZONA_DSP1_CONTROL_1:
2178 case ARIZONA_DSP1_CLOCKING_1:
2179 case ARIZONA_DSP1_STATUS_1:
2180 case ARIZONA_DSP1_STATUS_2:
2181 case ARIZONA_DSP2_CONTROL_1:
2182 case ARIZONA_DSP2_CLOCKING_1:
2183 case ARIZONA_DSP2_STATUS_1:
2184 case ARIZONA_DSP2_STATUS_2:
2185 case ARIZONA_DSP3_CONTROL_1:
2186 case ARIZONA_DSP3_CLOCKING_1:
2187 case ARIZONA_DSP3_STATUS_1:
2188 case ARIZONA_DSP3_STATUS_2:
2189 case ARIZONA_DSP4_CONTROL_1:
2190 case ARIZONA_DSP4_CLOCKING_1:
2191 case ARIZONA_DSP4_STATUS_1:
2192 case ARIZONA_DSP4_STATUS_2:
2193 return true;
2194 default:
2195 return false;
2196 }
2197}
2198
2199static bool wm5110_volatile_register(struct device *dev, unsigned int reg)
2200{
2201 switch (reg) {
2202 case ARIZONA_SOFTWARE_RESET:
2203 case ARIZONA_DEVICE_REVISION:
2204 case ARIZONA_HAPTICS_STATUS:
2205 case ARIZONA_SAMPLE_RATE_1_STATUS:
2206 case ARIZONA_SAMPLE_RATE_2_STATUS:
2207 case ARIZONA_SAMPLE_RATE_3_STATUS:
2208 case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS:
2209 case ARIZONA_MIC_DETECT_3:
2210 case ARIZONA_HEADPHONE_DETECT_2:
2211 case ARIZONA_INPUT_ENABLES_STATUS:
2212 case ARIZONA_OUTPUT_STATUS_1:
2213 case ARIZONA_RAW_OUTPUT_STATUS_1:
2214 case ARIZONA_SLIMBUS_RX_PORT_STATUS:
2215 case ARIZONA_SLIMBUS_TX_PORT_STATUS:
2216 case ARIZONA_INTERRUPT_STATUS_1:
2217 case ARIZONA_INTERRUPT_STATUS_2:
2218 case ARIZONA_INTERRUPT_STATUS_3:
2219 case ARIZONA_INTERRUPT_STATUS_4:
2220 case ARIZONA_INTERRUPT_STATUS_5:
2221 case ARIZONA_IRQ2_STATUS_1:
2222 case ARIZONA_IRQ2_STATUS_2:
2223 case ARIZONA_IRQ2_STATUS_3:
2224 case ARIZONA_IRQ2_STATUS_4:
2225 case ARIZONA_IRQ2_STATUS_5:
2226 case ARIZONA_INTERRUPT_RAW_STATUS_2:
2227 case ARIZONA_INTERRUPT_RAW_STATUS_3:
2228 case ARIZONA_INTERRUPT_RAW_STATUS_4:
2229 case ARIZONA_INTERRUPT_RAW_STATUS_5:
2230 case ARIZONA_INTERRUPT_RAW_STATUS_6:
2231 case ARIZONA_INTERRUPT_RAW_STATUS_7:
2232 case ARIZONA_INTERRUPT_RAW_STATUS_8:
2233 case ARIZONA_IRQ_PIN_STATUS:
2234 case ARIZONA_AOD_IRQ1:
2235 case ARIZONA_AOD_IRQ2:
2236 case ARIZONA_ASRC_STATUS:
2237 case ARIZONA_DSP_STATUS:
2238 case ARIZONA_DSP1_CONTROL_1:
2239 case ARIZONA_DSP1_CLOCKING_1:
2240 case ARIZONA_DSP1_STATUS_1:
2241 case ARIZONA_DSP1_STATUS_2:
2242 case ARIZONA_DSP2_STATUS_1:
2243 case ARIZONA_DSP2_STATUS_2:
2244 case ARIZONA_DSP3_STATUS_1:
2245 case ARIZONA_DSP3_STATUS_2:
2246 case ARIZONA_DSP4_STATUS_1:
2247 case ARIZONA_DSP4_STATUS_2:
2248 return true;
2249 default:
2250 return false;
2251 }
2252}
2253
2254const struct regmap_config wm5110_spi_regmap = {
2255 .reg_bits = 32,
2256 .pad_bits = 16,
2257 .val_bits = 16,
2258
2259 .max_register = ARIZONA_DSP1_STATUS_2,
2260 .readable_reg = wm5110_readable_register,
2261 .volatile_reg = wm5110_volatile_register,
2262
2263 .cache_type = REGCACHE_RBTREE,
2264 .reg_defaults = wm5110_reg_default,
2265 .num_reg_defaults = ARRAY_SIZE(wm5110_reg_default),
2266};
2267EXPORT_SYMBOL_GPL(wm5110_spi_regmap);
2268
2269const struct regmap_config wm5110_i2c_regmap = {
2270 .reg_bits = 32,
2271 .val_bits = 16,
2272
2273 .max_register = ARIZONA_DSP1_STATUS_2,
2274 .readable_reg = wm5110_readable_register,
2275 .volatile_reg = wm5110_volatile_register,
2276
2277 .cache_type = REGCACHE_RBTREE,
2278 .reg_defaults = wm5110_reg_default,
2279 .num_reg_defaults = ARRAY_SIZE(wm5110_reg_default),
2280};
2281EXPORT_SYMBOL_GPL(wm5110_i2c_regmap);
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index 8a9b11ca076a..7c1ae24605d9 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -32,9 +32,6 @@
32#include <linux/mfd/wm8350/supply.h> 32#include <linux/mfd/wm8350/supply.h>
33#include <linux/mfd/wm8350/wdt.h> 33#include <linux/mfd/wm8350/wdt.h>
34 34
35#define WM8350_UNLOCK_KEY 0x0013
36#define WM8350_LOCK_KEY 0x0000
37
38#define WM8350_CLOCK_CONTROL_1 0x28 35#define WM8350_CLOCK_CONTROL_1 0x28
39#define WM8350_AIF_TEST 0x74 36#define WM8350_AIF_TEST 0x74
40 37
@@ -63,181 +60,32 @@
63/* 60/*
64 * WM8350 Device IO 61 * WM8350 Device IO
65 */ 62 */
66static DEFINE_MUTEX(io_mutex);
67static DEFINE_MUTEX(reg_lock_mutex); 63static DEFINE_MUTEX(reg_lock_mutex);
68 64
69/* Perform a physical read from the device.
70 */
71static int wm8350_phys_read(struct wm8350 *wm8350, u8 reg, int num_regs,
72 u16 *dest)
73{
74 int i, ret;
75 int bytes = num_regs * 2;
76
77 dev_dbg(wm8350->dev, "volatile read\n");
78 ret = regmap_raw_read(wm8350->regmap, reg, dest, bytes);
79
80 for (i = reg; i < reg + num_regs; i++) {
81 /* Cache is CPU endian */
82 dest[i - reg] = be16_to_cpu(dest[i - reg]);
83
84 /* Mask out non-readable bits */
85 dest[i - reg] &= wm8350_reg_io_map[i].readable;
86 }
87
88 dump(num_regs, dest);
89
90 return ret;
91}
92
93static int wm8350_read(struct wm8350 *wm8350, u8 reg, int num_regs, u16 *dest)
94{
95 int i;
96 int end = reg + num_regs;
97 int ret = 0;
98 int bytes = num_regs * 2;
99
100 if ((reg + num_regs - 1) > WM8350_MAX_REGISTER) {
101 dev_err(wm8350->dev, "invalid reg %x\n",
102 reg + num_regs - 1);
103 return -EINVAL;
104 }
105
106 dev_dbg(wm8350->dev,
107 "%s R%d(0x%2.2x) %d regs\n", __func__, reg, reg, num_regs);
108
109#if WM8350_BUS_DEBUG
110 /* we can _safely_ read any register, but warn if read not supported */
111 for (i = reg; i < end; i++) {
112 if (!wm8350_reg_io_map[i].readable)
113 dev_warn(wm8350->dev,
114 "reg R%d is not readable\n", i);
115 }
116#endif
117
118 /* if any volatile registers are required, then read back all */
119 for (i = reg; i < end; i++)
120 if (wm8350_reg_io_map[i].vol)
121 return wm8350_phys_read(wm8350, reg, num_regs, dest);
122
123 /* no volatiles, then cache is good */
124 dev_dbg(wm8350->dev, "cache read\n");
125 memcpy(dest, &wm8350->reg_cache[reg], bytes);
126 dump(num_regs, dest);
127 return ret;
128}
129
130static inline int is_reg_locked(struct wm8350 *wm8350, u8 reg)
131{
132 if (reg == WM8350_SECURITY ||
133 wm8350->reg_cache[WM8350_SECURITY] == WM8350_UNLOCK_KEY)
134 return 0;
135
136 if ((reg >= WM8350_GPIO_FUNCTION_SELECT_1 &&
137 reg <= WM8350_GPIO_FUNCTION_SELECT_4) ||
138 (reg >= WM8350_BATTERY_CHARGER_CONTROL_1 &&
139 reg <= WM8350_BATTERY_CHARGER_CONTROL_3))
140 return 1;
141 return 0;
142}
143
144static int wm8350_write(struct wm8350 *wm8350, u8 reg, int num_regs, u16 *src)
145{
146 int i;
147 int end = reg + num_regs;
148 int bytes = num_regs * 2;
149
150 if ((reg + num_regs - 1) > WM8350_MAX_REGISTER) {
151 dev_err(wm8350->dev, "invalid reg %x\n",
152 reg + num_regs - 1);
153 return -EINVAL;
154 }
155
156 /* it's generally not a good idea to write to RO or locked registers */
157 for (i = reg; i < end; i++) {
158 if (!wm8350_reg_io_map[i].writable) {
159 dev_err(wm8350->dev,
160 "attempted write to read only reg R%d\n", i);
161 return -EINVAL;
162 }
163
164 if (is_reg_locked(wm8350, i)) {
165 dev_err(wm8350->dev,
166 "attempted write to locked reg R%d\n", i);
167 return -EINVAL;
168 }
169
170 src[i - reg] &= wm8350_reg_io_map[i].writable;
171
172 wm8350->reg_cache[i] =
173 (wm8350->reg_cache[i] & ~wm8350_reg_io_map[i].writable)
174 | src[i - reg];
175
176 src[i - reg] = cpu_to_be16(src[i - reg]);
177 }
178
179 /* Actually write it out */
180 return regmap_raw_write(wm8350->regmap, reg, src, bytes);
181}
182
183/* 65/*
184 * Safe read, modify, write methods 66 * Safe read, modify, write methods
185 */ 67 */
186int wm8350_clear_bits(struct wm8350 *wm8350, u16 reg, u16 mask) 68int wm8350_clear_bits(struct wm8350 *wm8350, u16 reg, u16 mask)
187{ 69{
188 u16 data; 70 return regmap_update_bits(wm8350->regmap, reg, mask, 0);
189 int err;
190
191 mutex_lock(&io_mutex);
192 err = wm8350_read(wm8350, reg, 1, &data);
193 if (err) {
194 dev_err(wm8350->dev, "read from reg R%d failed\n", reg);
195 goto out;
196 }
197
198 data &= ~mask;
199 err = wm8350_write(wm8350, reg, 1, &data);
200 if (err)
201 dev_err(wm8350->dev, "write to reg R%d failed\n", reg);
202out:
203 mutex_unlock(&io_mutex);
204 return err;
205} 71}
206EXPORT_SYMBOL_GPL(wm8350_clear_bits); 72EXPORT_SYMBOL_GPL(wm8350_clear_bits);
207 73
208int wm8350_set_bits(struct wm8350 *wm8350, u16 reg, u16 mask) 74int wm8350_set_bits(struct wm8350 *wm8350, u16 reg, u16 mask)
209{ 75{
210 u16 data; 76 return regmap_update_bits(wm8350->regmap, reg, mask, mask);
211 int err;
212
213 mutex_lock(&io_mutex);
214 err = wm8350_read(wm8350, reg, 1, &data);
215 if (err) {
216 dev_err(wm8350->dev, "read from reg R%d failed\n", reg);
217 goto out;
218 }
219
220 data |= mask;
221 err = wm8350_write(wm8350, reg, 1, &data);
222 if (err)
223 dev_err(wm8350->dev, "write to reg R%d failed\n", reg);
224out:
225 mutex_unlock(&io_mutex);
226 return err;
227} 77}
228EXPORT_SYMBOL_GPL(wm8350_set_bits); 78EXPORT_SYMBOL_GPL(wm8350_set_bits);
229 79
230u16 wm8350_reg_read(struct wm8350 *wm8350, int reg) 80u16 wm8350_reg_read(struct wm8350 *wm8350, int reg)
231{ 81{
232 u16 data; 82 unsigned int data;
233 int err; 83 int err;
234 84
235 mutex_lock(&io_mutex); 85 err = regmap_read(wm8350->regmap, reg, &data);
236 err = wm8350_read(wm8350, reg, 1, &data);
237 if (err) 86 if (err)
238 dev_err(wm8350->dev, "read from reg R%d failed\n", reg); 87 dev_err(wm8350->dev, "read from reg R%d failed\n", reg);
239 88
240 mutex_unlock(&io_mutex);
241 return data; 89 return data;
242} 90}
243EXPORT_SYMBOL_GPL(wm8350_reg_read); 91EXPORT_SYMBOL_GPL(wm8350_reg_read);
@@ -245,13 +93,11 @@ EXPORT_SYMBOL_GPL(wm8350_reg_read);
245int wm8350_reg_write(struct wm8350 *wm8350, int reg, u16 val) 93int wm8350_reg_write(struct wm8350 *wm8350, int reg, u16 val)
246{ 94{
247 int ret; 95 int ret;
248 u16 data = val;
249 96
250 mutex_lock(&io_mutex); 97 ret = regmap_write(wm8350->regmap, reg, val);
251 ret = wm8350_write(wm8350, reg, 1, &data); 98
252 if (ret) 99 if (ret)
253 dev_err(wm8350->dev, "write to reg R%d failed\n", reg); 100 dev_err(wm8350->dev, "write to reg R%d failed\n", reg);
254 mutex_unlock(&io_mutex);
255 return ret; 101 return ret;
256} 102}
257EXPORT_SYMBOL_GPL(wm8350_reg_write); 103EXPORT_SYMBOL_GPL(wm8350_reg_write);
@@ -261,12 +107,11 @@ int wm8350_block_read(struct wm8350 *wm8350, int start_reg, int regs,
261{ 107{
262 int err = 0; 108 int err = 0;
263 109
264 mutex_lock(&io_mutex); 110 err = regmap_bulk_read(wm8350->regmap, start_reg, dest, regs);
265 err = wm8350_read(wm8350, start_reg, regs, dest);
266 if (err) 111 if (err)
267 dev_err(wm8350->dev, "block read starting from R%d failed\n", 112 dev_err(wm8350->dev, "block read starting from R%d failed\n",
268 start_reg); 113 start_reg);
269 mutex_unlock(&io_mutex); 114
270 return err; 115 return err;
271} 116}
272EXPORT_SYMBOL_GPL(wm8350_block_read); 117EXPORT_SYMBOL_GPL(wm8350_block_read);
@@ -276,12 +121,11 @@ int wm8350_block_write(struct wm8350 *wm8350, int start_reg, int regs,
276{ 121{
277 int ret = 0; 122 int ret = 0;
278 123
279 mutex_lock(&io_mutex); 124 ret = regmap_bulk_write(wm8350->regmap, start_reg, src, regs);
280 ret = wm8350_write(wm8350, start_reg, regs, src);
281 if (ret) 125 if (ret)
282 dev_err(wm8350->dev, "block write starting at R%d failed\n", 126 dev_err(wm8350->dev, "block write starting at R%d failed\n",
283 start_reg); 127 start_reg);
284 mutex_unlock(&io_mutex); 128
285 return ret; 129 return ret;
286} 130}
287EXPORT_SYMBOL_GPL(wm8350_block_write); 131EXPORT_SYMBOL_GPL(wm8350_block_write);
@@ -295,15 +139,20 @@ EXPORT_SYMBOL_GPL(wm8350_block_write);
295 */ 139 */
296int wm8350_reg_lock(struct wm8350 *wm8350) 140int wm8350_reg_lock(struct wm8350 *wm8350)
297{ 141{
298 u16 key = WM8350_LOCK_KEY;
299 int ret; 142 int ret;
300 143
144 mutex_lock(&reg_lock_mutex);
145
301 ldbg(__func__); 146 ldbg(__func__);
302 mutex_lock(&io_mutex); 147
303 ret = wm8350_write(wm8350, WM8350_SECURITY, 1, &key); 148 ret = wm8350_reg_write(wm8350, WM8350_SECURITY, WM8350_LOCK_KEY);
304 if (ret) 149 if (ret)
305 dev_err(wm8350->dev, "lock failed\n"); 150 dev_err(wm8350->dev, "lock failed\n");
306 mutex_unlock(&io_mutex); 151
152 wm8350->unlocked = false;
153
154 mutex_unlock(&reg_lock_mutex);
155
307 return ret; 156 return ret;
308} 157}
309EXPORT_SYMBOL_GPL(wm8350_reg_lock); 158EXPORT_SYMBOL_GPL(wm8350_reg_lock);
@@ -319,15 +168,20 @@ EXPORT_SYMBOL_GPL(wm8350_reg_lock);
319 */ 168 */
320int wm8350_reg_unlock(struct wm8350 *wm8350) 169int wm8350_reg_unlock(struct wm8350 *wm8350)
321{ 170{
322 u16 key = WM8350_UNLOCK_KEY;
323 int ret; 171 int ret;
324 172
173 mutex_lock(&reg_lock_mutex);
174
325 ldbg(__func__); 175 ldbg(__func__);
326 mutex_lock(&io_mutex); 176
327 ret = wm8350_write(wm8350, WM8350_SECURITY, 1, &key); 177 ret = wm8350_reg_write(wm8350, WM8350_SECURITY, WM8350_UNLOCK_KEY);
328 if (ret) 178 if (ret)
329 dev_err(wm8350->dev, "unlock failed\n"); 179 dev_err(wm8350->dev, "unlock failed\n");
330 mutex_unlock(&io_mutex); 180
181 wm8350->unlocked = true;
182
183 mutex_unlock(&reg_lock_mutex);
184
331 return ret; 185 return ret;
332} 186}
333EXPORT_SYMBOL_GPL(wm8350_reg_unlock); 187EXPORT_SYMBOL_GPL(wm8350_reg_unlock);
@@ -395,146 +249,6 @@ static irqreturn_t wm8350_auxadc_irq(int irq, void *irq_data)
395} 249}
396 250
397/* 251/*
398 * Cache is always host endian.
399 */
400static int wm8350_create_cache(struct wm8350 *wm8350, int type, int mode)
401{
402 int i, ret = 0;
403 u16 value;
404 const u16 *reg_map;
405
406 switch (type) {
407 case 0:
408 switch (mode) {
409#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_0
410 case 0:
411 reg_map = wm8350_mode0_defaults;
412 break;
413#endif
414#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_1
415 case 1:
416 reg_map = wm8350_mode1_defaults;
417 break;
418#endif
419#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_2
420 case 2:
421 reg_map = wm8350_mode2_defaults;
422 break;
423#endif
424#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_3
425 case 3:
426 reg_map = wm8350_mode3_defaults;
427 break;
428#endif
429 default:
430 dev_err(wm8350->dev,
431 "WM8350 configuration mode %d not supported\n",
432 mode);
433 return -EINVAL;
434 }
435 break;
436
437 case 1:
438 switch (mode) {
439#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_0
440 case 0:
441 reg_map = wm8351_mode0_defaults;
442 break;
443#endif
444#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_1
445 case 1:
446 reg_map = wm8351_mode1_defaults;
447 break;
448#endif
449#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_2
450 case 2:
451 reg_map = wm8351_mode2_defaults;
452 break;
453#endif
454#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_3
455 case 3:
456 reg_map = wm8351_mode3_defaults;
457 break;
458#endif
459 default:
460 dev_err(wm8350->dev,
461 "WM8351 configuration mode %d not supported\n",
462 mode);
463 return -EINVAL;
464 }
465 break;
466
467 case 2:
468 switch (mode) {
469#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_0
470 case 0:
471 reg_map = wm8352_mode0_defaults;
472 break;
473#endif
474#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_1
475 case 1:
476 reg_map = wm8352_mode1_defaults;
477 break;
478#endif
479#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_2
480 case 2:
481 reg_map = wm8352_mode2_defaults;
482 break;
483#endif
484#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_3
485 case 3:
486 reg_map = wm8352_mode3_defaults;
487 break;
488#endif
489 default:
490 dev_err(wm8350->dev,
491 "WM8352 configuration mode %d not supported\n",
492 mode);
493 return -EINVAL;
494 }
495 break;
496
497 default:
498 dev_err(wm8350->dev,
499 "WM835x configuration mode %d not supported\n",
500 mode);
501 return -EINVAL;
502 }
503
504 wm8350->reg_cache =
505 kmalloc(sizeof(u16) * (WM8350_MAX_REGISTER + 1), GFP_KERNEL);
506 if (wm8350->reg_cache == NULL)
507 return -ENOMEM;
508
509 /* Read the initial cache state back from the device - this is
510 * a PMIC so the device many not be in a virgin state and we
511 * can't rely on the silicon values.
512 */
513 ret = regmap_raw_read(wm8350->regmap, 0, wm8350->reg_cache,
514 sizeof(u16) * (WM8350_MAX_REGISTER + 1));
515 if (ret < 0) {
516 dev_err(wm8350->dev,
517 "failed to read initial cache values\n");
518 goto out;
519 }
520
521 /* Mask out uncacheable/unreadable bits and the audio. */
522 for (i = 0; i < WM8350_MAX_REGISTER; i++) {
523 if (wm8350_reg_io_map[i].readable &&
524 (i < WM8350_CLOCK_CONTROL_1 || i > WM8350_AIF_TEST)) {
525 value = be16_to_cpu(wm8350->reg_cache[i]);
526 value &= wm8350_reg_io_map[i].readable;
527 wm8350->reg_cache[i] = value;
528 } else
529 wm8350->reg_cache[i] = reg_map[i];
530 }
531
532out:
533 kfree(wm8350->reg_cache);
534 return ret;
535}
536
537/*
538 * Register a client device. This is non-fatal since there is no need to 252 * Register a client device. This is non-fatal since there is no need to
539 * fail the entire device init due to a single platform device failing. 253 * fail the entire device init due to a single platform device failing.
540 */ 254 */
@@ -681,18 +395,12 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
681 goto err; 395 goto err;
682 } 396 }
683 397
684 ret = wm8350_create_cache(wm8350, mask_rev, mode);
685 if (ret < 0) {
686 dev_err(wm8350->dev, "Failed to create register cache\n");
687 return ret;
688 }
689
690 mutex_init(&wm8350->auxadc_mutex); 398 mutex_init(&wm8350->auxadc_mutex);
691 init_completion(&wm8350->auxadc_done); 399 init_completion(&wm8350->auxadc_done);
692 400
693 ret = wm8350_irq_init(wm8350, irq, pdata); 401 ret = wm8350_irq_init(wm8350, irq, pdata);
694 if (ret < 0) 402 if (ret < 0)
695 goto err_free; 403 goto err;
696 404
697 if (wm8350->irq_base) { 405 if (wm8350->irq_base) {
698 ret = request_threaded_irq(wm8350->irq_base + 406 ret = request_threaded_irq(wm8350->irq_base +
@@ -730,8 +438,6 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
730 438
731err_irq: 439err_irq:
732 wm8350_irq_exit(wm8350); 440 wm8350_irq_exit(wm8350);
733err_free:
734 kfree(wm8350->reg_cache);
735err: 441err:
736 return ret; 442 return ret;
737} 443}
@@ -758,8 +464,6 @@ void wm8350_device_exit(struct wm8350 *wm8350)
758 free_irq(wm8350->irq_base + WM8350_IRQ_AUXADC_DATARDY, wm8350); 464 free_irq(wm8350->irq_base + WM8350_IRQ_AUXADC_DATARDY, wm8350);
759 465
760 wm8350_irq_exit(wm8350); 466 wm8350_irq_exit(wm8350);
761
762 kfree(wm8350->reg_cache);
763} 467}
764EXPORT_SYMBOL_GPL(wm8350_device_exit); 468EXPORT_SYMBOL_GPL(wm8350_device_exit);
765 469
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c
index a68aceb4e48c..2e57101c8d3d 100644
--- a/drivers/mfd/wm8350-i2c.c
+++ b/drivers/mfd/wm8350-i2c.c
@@ -23,11 +23,6 @@
23#include <linux/regmap.h> 23#include <linux/regmap.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25 25
26static const struct regmap_config wm8350_regmap = {
27 .reg_bits = 8,
28 .val_bits = 16,
29};
30
31static int wm8350_i2c_probe(struct i2c_client *i2c, 26static int wm8350_i2c_probe(struct i2c_client *i2c,
32 const struct i2c_device_id *id) 27 const struct i2c_device_id *id)
33{ 28{
diff --git a/drivers/mfd/wm8350-irq.c b/drivers/mfd/wm8350-irq.c
index 9fd01bf63c51..624ff90501cd 100644
--- a/drivers/mfd/wm8350-irq.c
+++ b/drivers/mfd/wm8350-irq.c
@@ -432,11 +432,9 @@ static void wm8350_irq_sync_unlock(struct irq_data *data)
432 for (i = 0; i < ARRAY_SIZE(wm8350->irq_masks); i++) { 432 for (i = 0; i < ARRAY_SIZE(wm8350->irq_masks); i++) {
433 /* If there's been a change in the mask write it back 433 /* If there's been a change in the mask write it back
434 * to the hardware. */ 434 * to the hardware. */
435 if (wm8350->irq_masks[i] != 435 WARN_ON(regmap_update_bits(wm8350->regmap,
436 wm8350->reg_cache[WM8350_INT_STATUS_1_MASK + i]) 436 WM8350_INT_STATUS_1_MASK + i,
437 WARN_ON(wm8350_reg_write(wm8350, 437 0xffff, wm8350->irq_masks[i]));
438 WM8350_INT_STATUS_1_MASK + i,
439 wm8350->irq_masks[i]));
440 } 438 }
441 439
442 mutex_unlock(&wm8350->irq_lock); 440 mutex_unlock(&wm8350->irq_lock);
diff --git a/drivers/mfd/wm8350-regmap.c b/drivers/mfd/wm8350-regmap.c
index e965139e5cd5..9efc64750fb6 100644
--- a/drivers/mfd/wm8350-regmap.c
+++ b/drivers/mfd/wm8350-regmap.c
@@ -14,3170 +14,18 @@
14 14
15#include <linux/mfd/wm8350/core.h> 15#include <linux/mfd/wm8350/core.h>
16 16
17#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_0
18
19#undef WM8350_HAVE_CONFIG_MODE
20#define WM8350_HAVE_CONFIG_MODE
21
22const u16 wm8350_mode0_defaults[] = {
23 0x17FF, /* R0 - Reset/ID */
24 0x1000, /* R1 - ID */
25 0x0000, /* R2 */
26 0x1002, /* R3 - System Control 1 */
27 0x0004, /* R4 - System Control 2 */
28 0x0000, /* R5 - System Hibernate */
29 0x8A00, /* R6 - Interface Control */
30 0x0000, /* R7 */
31 0x8000, /* R8 - Power mgmt (1) */
32 0x0000, /* R9 - Power mgmt (2) */
33 0x0000, /* R10 - Power mgmt (3) */
34 0x2000, /* R11 - Power mgmt (4) */
35 0x0E00, /* R12 - Power mgmt (5) */
36 0x0000, /* R13 - Power mgmt (6) */
37 0x0000, /* R14 - Power mgmt (7) */
38 0x0000, /* R15 */
39 0x0000, /* R16 - RTC Seconds/Minutes */
40 0x0100, /* R17 - RTC Hours/Day */
41 0x0101, /* R18 - RTC Date/Month */
42 0x1400, /* R19 - RTC Year */
43 0x0000, /* R20 - Alarm Seconds/Minutes */
44 0x0000, /* R21 - Alarm Hours/Day */
45 0x0000, /* R22 - Alarm Date/Month */
46 0x0320, /* R23 - RTC Time Control */
47 0x0000, /* R24 - System Interrupts */
48 0x0000, /* R25 - Interrupt Status 1 */
49 0x0000, /* R26 - Interrupt Status 2 */
50 0x0000, /* R27 - Power Up Interrupt Status */
51 0x0000, /* R28 - Under Voltage Interrupt status */
52 0x0000, /* R29 - Over Current Interrupt status */
53 0x0000, /* R30 - GPIO Interrupt Status */
54 0x0000, /* R31 - Comparator Interrupt Status */
55 0x3FFF, /* R32 - System Interrupts Mask */
56 0x0000, /* R33 - Interrupt Status 1 Mask */
57 0x0000, /* R34 - Interrupt Status 2 Mask */
58 0x0000, /* R35 - Power Up Interrupt Status Mask */
59 0x0000, /* R36 - Under Voltage Interrupt status Mask */
60 0x0000, /* R37 - Over Current Interrupt status Mask */
61 0x0000, /* R38 - GPIO Interrupt Status Mask */
62 0x0000, /* R39 - Comparator Interrupt Status Mask */
63 0x0040, /* R40 - Clock Control 1 */
64 0x0000, /* R41 - Clock Control 2 */
65 0x3B00, /* R42 - FLL Control 1 */
66 0x7086, /* R43 - FLL Control 2 */
67 0xC226, /* R44 - FLL Control 3 */
68 0x0000, /* R45 - FLL Control 4 */
69 0x0000, /* R46 */
70 0x0000, /* R47 */
71 0x0000, /* R48 - DAC Control */
72 0x0000, /* R49 */
73 0x00C0, /* R50 - DAC Digital Volume L */
74 0x00C0, /* R51 - DAC Digital Volume R */
75 0x0000, /* R52 */
76 0x0040, /* R53 - DAC LR Rate */
77 0x0000, /* R54 - DAC Clock Control */
78 0x0000, /* R55 */
79 0x0000, /* R56 */
80 0x0000, /* R57 */
81 0x4000, /* R58 - DAC Mute */
82 0x0000, /* R59 - DAC Mute Volume */
83 0x0000, /* R60 - DAC Side */
84 0x0000, /* R61 */
85 0x0000, /* R62 */
86 0x0000, /* R63 */
87 0x8000, /* R64 - ADC Control */
88 0x0000, /* R65 */
89 0x00C0, /* R66 - ADC Digital Volume L */
90 0x00C0, /* R67 - ADC Digital Volume R */
91 0x0000, /* R68 - ADC Divider */
92 0x0000, /* R69 */
93 0x0040, /* R70 - ADC LR Rate */
94 0x0000, /* R71 */
95 0x0303, /* R72 - Input Control */
96 0x0000, /* R73 - IN3 Input Control */
97 0x0000, /* R74 - Mic Bias Control */
98 0x0000, /* R75 */
99 0x0000, /* R76 - Output Control */
100 0x0000, /* R77 - Jack Detect */
101 0x0000, /* R78 - Anti Pop Control */
102 0x0000, /* R79 */
103 0x0040, /* R80 - Left Input Volume */
104 0x0040, /* R81 - Right Input Volume */
105 0x0000, /* R82 */
106 0x0000, /* R83 */
107 0x0000, /* R84 */
108 0x0000, /* R85 */
109 0x0000, /* R86 */
110 0x0000, /* R87 */
111 0x0800, /* R88 - Left Mixer Control */
112 0x1000, /* R89 - Right Mixer Control */
113 0x0000, /* R90 */
114 0x0000, /* R91 */
115 0x0000, /* R92 - OUT3 Mixer Control */
116 0x0000, /* R93 - OUT4 Mixer Control */
117 0x0000, /* R94 */
118 0x0000, /* R95 */
119 0x0000, /* R96 - Output Left Mixer Volume */
120 0x0000, /* R97 - Output Right Mixer Volume */
121 0x0000, /* R98 - Input Mixer Volume L */
122 0x0000, /* R99 - Input Mixer Volume R */
123 0x0000, /* R100 - Input Mixer Volume */
124 0x0000, /* R101 */
125 0x0000, /* R102 */
126 0x0000, /* R103 */
127 0x00E4, /* R104 - LOUT1 Volume */
128 0x00E4, /* R105 - ROUT1 Volume */
129 0x00E4, /* R106 - LOUT2 Volume */
130 0x02E4, /* R107 - ROUT2 Volume */
131 0x0000, /* R108 */
132 0x0000, /* R109 */
133 0x0000, /* R110 */
134 0x0000, /* R111 - BEEP Volume */
135 0x0A00, /* R112 - AI Formating */
136 0x0000, /* R113 - ADC DAC COMP */
137 0x0020, /* R114 - AI ADC Control */
138 0x0020, /* R115 - AI DAC Control */
139 0x0000, /* R116 - AIF Test */
140 0x0000, /* R117 */
141 0x0000, /* R118 */
142 0x0000, /* R119 */
143 0x0000, /* R120 */
144 0x0000, /* R121 */
145 0x0000, /* R122 */
146 0x0000, /* R123 */
147 0x0000, /* R124 */
148 0x0000, /* R125 */
149 0x0000, /* R126 */
150 0x0000, /* R127 */
151 0x1FFF, /* R128 - GPIO Debounce */
152 0x0000, /* R129 - GPIO Pin pull up Control */
153 0x03FC, /* R130 - GPIO Pull down Control */
154 0x0000, /* R131 - GPIO Interrupt Mode */
155 0x0000, /* R132 */
156 0x0000, /* R133 - GPIO Control */
157 0x0FFC, /* R134 - GPIO Configuration (i/o) */
158 0x0FFC, /* R135 - GPIO Pin Polarity / Type */
159 0x0000, /* R136 */
160 0x0000, /* R137 */
161 0x0000, /* R138 */
162 0x0000, /* R139 */
163 0x0013, /* R140 - GPIO Function Select 1 */
164 0x0000, /* R141 - GPIO Function Select 2 */
165 0x0000, /* R142 - GPIO Function Select 3 */
166 0x0003, /* R143 - GPIO Function Select 4 */
167 0x0000, /* R144 - Digitiser Control (1) */
168 0x0002, /* R145 - Digitiser Control (2) */
169 0x0000, /* R146 */
170 0x0000, /* R147 */
171 0x0000, /* R148 */
172 0x0000, /* R149 */
173 0x0000, /* R150 */
174 0x0000, /* R151 */
175 0x7000, /* R152 - AUX1 Readback */
176 0x7000, /* R153 - AUX2 Readback */
177 0x7000, /* R154 - AUX3 Readback */
178 0x7000, /* R155 - AUX4 Readback */
179 0x0000, /* R156 - USB Voltage Readback */
180 0x0000, /* R157 - LINE Voltage Readback */
181 0x0000, /* R158 - BATT Voltage Readback */
182 0x0000, /* R159 - Chip Temp Readback */
183 0x0000, /* R160 */
184 0x0000, /* R161 */
185 0x0000, /* R162 */
186 0x0000, /* R163 - Generic Comparator Control */
187 0x0000, /* R164 - Generic comparator 1 */
188 0x0000, /* R165 - Generic comparator 2 */
189 0x0000, /* R166 - Generic comparator 3 */
190 0x0000, /* R167 - Generic comparator 4 */
191 0xA00F, /* R168 - Battery Charger Control 1 */
192 0x0B06, /* R169 - Battery Charger Control 2 */
193 0x0000, /* R170 - Battery Charger Control 3 */
194 0x0000, /* R171 */
195 0x0000, /* R172 - Current Sink Driver A */
196 0x0000, /* R173 - CSA Flash control */
197 0x0000, /* R174 - Current Sink Driver B */
198 0x0000, /* R175 - CSB Flash control */
199 0x0000, /* R176 - DCDC/LDO requested */
200 0x002D, /* R177 - DCDC Active options */
201 0x0000, /* R178 - DCDC Sleep options */
202 0x0025, /* R179 - Power-check comparator */
203 0x000E, /* R180 - DCDC1 Control */
204 0x0000, /* R181 - DCDC1 Timeouts */
205 0x1006, /* R182 - DCDC1 Low Power */
206 0x0018, /* R183 - DCDC2 Control */
207 0x0000, /* R184 - DCDC2 Timeouts */
208 0x0000, /* R185 */
209 0x0000, /* R186 - DCDC3 Control */
210 0x0000, /* R187 - DCDC3 Timeouts */
211 0x0006, /* R188 - DCDC3 Low Power */
212 0x0000, /* R189 - DCDC4 Control */
213 0x0000, /* R190 - DCDC4 Timeouts */
214 0x0006, /* R191 - DCDC4 Low Power */
215 0x0008, /* R192 - DCDC5 Control */
216 0x0000, /* R193 - DCDC5 Timeouts */
217 0x0000, /* R194 */
218 0x0000, /* R195 - DCDC6 Control */
219 0x0000, /* R196 - DCDC6 Timeouts */
220 0x0006, /* R197 - DCDC6 Low Power */
221 0x0000, /* R198 */
222 0x0003, /* R199 - Limit Switch Control */
223 0x001C, /* R200 - LDO1 Control */
224 0x0000, /* R201 - LDO1 Timeouts */
225 0x001C, /* R202 - LDO1 Low Power */
226 0x001B, /* R203 - LDO2 Control */
227 0x0000, /* R204 - LDO2 Timeouts */
228 0x001C, /* R205 - LDO2 Low Power */
229 0x001B, /* R206 - LDO3 Control */
230 0x0000, /* R207 - LDO3 Timeouts */
231 0x001C, /* R208 - LDO3 Low Power */
232 0x001B, /* R209 - LDO4 Control */
233 0x0000, /* R210 - LDO4 Timeouts */
234 0x001C, /* R211 - LDO4 Low Power */
235 0x0000, /* R212 */
236 0x0000, /* R213 */
237 0x0000, /* R214 */
238 0x0000, /* R215 - VCC_FAULT Masks */
239 0x001F, /* R216 - Main Bandgap Control */
240 0x0000, /* R217 - OSC Control */
241 0x9000, /* R218 - RTC Tick Control */
242 0x0000, /* R219 */
243 0x4000, /* R220 - RAM BIST 1 */
244 0x0000, /* R221 */
245 0x0000, /* R222 */
246 0x0000, /* R223 */
247 0x0000, /* R224 */
248 0x0000, /* R225 - DCDC/LDO status */
249 0x0000, /* R226 */
250 0x0000, /* R227 */
251 0x0000, /* R228 */
252 0x0000, /* R229 */
253 0xE000, /* R230 - GPIO Pin Status */
254 0x0000, /* R231 */
255 0x0000, /* R232 */
256 0x0000, /* R233 */
257 0x0000, /* R234 */
258 0x0000, /* R235 */
259 0x0000, /* R236 */
260 0x0000, /* R237 */
261 0x0000, /* R238 */
262 0x0000, /* R239 */
263 0x0000, /* R240 */
264 0x0000, /* R241 */
265 0x0000, /* R242 */
266 0x0000, /* R243 */
267 0x0000, /* R244 */
268 0x0000, /* R245 */
269 0x0000, /* R246 */
270 0x0000, /* R247 */
271 0x0000, /* R248 */
272 0x0000, /* R249 */
273 0x0000, /* R250 */
274 0x0000, /* R251 */
275 0x0000, /* R252 */
276 0x0000, /* R253 */
277 0x0000, /* R254 */
278 0x0000, /* R255 */
279};
280#endif
281
282#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_1
283
284#undef WM8350_HAVE_CONFIG_MODE
285#define WM8350_HAVE_CONFIG_MODE
286
287const u16 wm8350_mode1_defaults[] = {
288 0x17FF, /* R0 - Reset/ID */
289 0x1000, /* R1 - ID */
290 0x0000, /* R2 */
291 0x1002, /* R3 - System Control 1 */
292 0x0014, /* R4 - System Control 2 */
293 0x0000, /* R5 - System Hibernate */
294 0x8A00, /* R6 - Interface Control */
295 0x0000, /* R7 */
296 0x8000, /* R8 - Power mgmt (1) */
297 0x0000, /* R9 - Power mgmt (2) */
298 0x0000, /* R10 - Power mgmt (3) */
299 0x2000, /* R11 - Power mgmt (4) */
300 0x0E00, /* R12 - Power mgmt (5) */
301 0x0000, /* R13 - Power mgmt (6) */
302 0x0000, /* R14 - Power mgmt (7) */
303 0x0000, /* R15 */
304 0x0000, /* R16 - RTC Seconds/Minutes */
305 0x0100, /* R17 - RTC Hours/Day */
306 0x0101, /* R18 - RTC Date/Month */
307 0x1400, /* R19 - RTC Year */
308 0x0000, /* R20 - Alarm Seconds/Minutes */
309 0x0000, /* R21 - Alarm Hours/Day */
310 0x0000, /* R22 - Alarm Date/Month */
311 0x0320, /* R23 - RTC Time Control */
312 0x0000, /* R24 - System Interrupts */
313 0x0000, /* R25 - Interrupt Status 1 */
314 0x0000, /* R26 - Interrupt Status 2 */
315 0x0000, /* R27 - Power Up Interrupt Status */
316 0x0000, /* R28 - Under Voltage Interrupt status */
317 0x0000, /* R29 - Over Current Interrupt status */
318 0x0000, /* R30 - GPIO Interrupt Status */
319 0x0000, /* R31 - Comparator Interrupt Status */
320 0x3FFF, /* R32 - System Interrupts Mask */
321 0x0000, /* R33 - Interrupt Status 1 Mask */
322 0x0000, /* R34 - Interrupt Status 2 Mask */
323 0x0000, /* R35 - Power Up Interrupt Status Mask */
324 0x0000, /* R36 - Under Voltage Interrupt status Mask */
325 0x0000, /* R37 - Over Current Interrupt status Mask */
326 0x0000, /* R38 - GPIO Interrupt Status Mask */
327 0x0000, /* R39 - Comparator Interrupt Status Mask */
328 0x0040, /* R40 - Clock Control 1 */
329 0x0000, /* R41 - Clock Control 2 */
330 0x3B00, /* R42 - FLL Control 1 */
331 0x7086, /* R43 - FLL Control 2 */
332 0xC226, /* R44 - FLL Control 3 */
333 0x0000, /* R45 - FLL Control 4 */
334 0x0000, /* R46 */
335 0x0000, /* R47 */
336 0x0000, /* R48 - DAC Control */
337 0x0000, /* R49 */
338 0x00C0, /* R50 - DAC Digital Volume L */
339 0x00C0, /* R51 - DAC Digital Volume R */
340 0x0000, /* R52 */
341 0x0040, /* R53 - DAC LR Rate */
342 0x0000, /* R54 - DAC Clock Control */
343 0x0000, /* R55 */
344 0x0000, /* R56 */
345 0x0000, /* R57 */
346 0x4000, /* R58 - DAC Mute */
347 0x0000, /* R59 - DAC Mute Volume */
348 0x0000, /* R60 - DAC Side */
349 0x0000, /* R61 */
350 0x0000, /* R62 */
351 0x0000, /* R63 */
352 0x8000, /* R64 - ADC Control */
353 0x0000, /* R65 */
354 0x00C0, /* R66 - ADC Digital Volume L */
355 0x00C0, /* R67 - ADC Digital Volume R */
356 0x0000, /* R68 - ADC Divider */
357 0x0000, /* R69 */
358 0x0040, /* R70 - ADC LR Rate */
359 0x0000, /* R71 */
360 0x0303, /* R72 - Input Control */
361 0x0000, /* R73 - IN3 Input Control */
362 0x0000, /* R74 - Mic Bias Control */
363 0x0000, /* R75 */
364 0x0000, /* R76 - Output Control */
365 0x0000, /* R77 - Jack Detect */
366 0x0000, /* R78 - Anti Pop Control */
367 0x0000, /* R79 */
368 0x0040, /* R80 - Left Input Volume */
369 0x0040, /* R81 - Right Input Volume */
370 0x0000, /* R82 */
371 0x0000, /* R83 */
372 0x0000, /* R84 */
373 0x0000, /* R85 */
374 0x0000, /* R86 */
375 0x0000, /* R87 */
376 0x0800, /* R88 - Left Mixer Control */
377 0x1000, /* R89 - Right Mixer Control */
378 0x0000, /* R90 */
379 0x0000, /* R91 */
380 0x0000, /* R92 - OUT3 Mixer Control */
381 0x0000, /* R93 - OUT4 Mixer Control */
382 0x0000, /* R94 */
383 0x0000, /* R95 */
384 0x0000, /* R96 - Output Left Mixer Volume */
385 0x0000, /* R97 - Output Right Mixer Volume */
386 0x0000, /* R98 - Input Mixer Volume L */
387 0x0000, /* R99 - Input Mixer Volume R */
388 0x0000, /* R100 - Input Mixer Volume */
389 0x0000, /* R101 */
390 0x0000, /* R102 */
391 0x0000, /* R103 */
392 0x00E4, /* R104 - LOUT1 Volume */
393 0x00E4, /* R105 - ROUT1 Volume */
394 0x00E4, /* R106 - LOUT2 Volume */
395 0x02E4, /* R107 - ROUT2 Volume */
396 0x0000, /* R108 */
397 0x0000, /* R109 */
398 0x0000, /* R110 */
399 0x0000, /* R111 - BEEP Volume */
400 0x0A00, /* R112 - AI Formating */
401 0x0000, /* R113 - ADC DAC COMP */
402 0x0020, /* R114 - AI ADC Control */
403 0x0020, /* R115 - AI DAC Control */
404 0x0000, /* R116 - AIF Test */
405 0x0000, /* R117 */
406 0x0000, /* R118 */
407 0x0000, /* R119 */
408 0x0000, /* R120 */
409 0x0000, /* R121 */
410 0x0000, /* R122 */
411 0x0000, /* R123 */
412 0x0000, /* R124 */
413 0x0000, /* R125 */
414 0x0000, /* R126 */
415 0x0000, /* R127 */
416 0x1FFF, /* R128 - GPIO Debounce */
417 0x0000, /* R129 - GPIO Pin pull up Control */
418 0x03FC, /* R130 - GPIO Pull down Control */
419 0x0000, /* R131 - GPIO Interrupt Mode */
420 0x0000, /* R132 */
421 0x0000, /* R133 - GPIO Control */
422 0x00FB, /* R134 - GPIO Configuration (i/o) */
423 0x04FE, /* R135 - GPIO Pin Polarity / Type */
424 0x0000, /* R136 */
425 0x0000, /* R137 */
426 0x0000, /* R138 */
427 0x0000, /* R139 */
428 0x0312, /* R140 - GPIO Function Select 1 */
429 0x1003, /* R141 - GPIO Function Select 2 */
430 0x1331, /* R142 - GPIO Function Select 3 */
431 0x0003, /* R143 - GPIO Function Select 4 */
432 0x0000, /* R144 - Digitiser Control (1) */
433 0x0002, /* R145 - Digitiser Control (2) */
434 0x0000, /* R146 */
435 0x0000, /* R147 */
436 0x0000, /* R148 */
437 0x0000, /* R149 */
438 0x0000, /* R150 */
439 0x0000, /* R151 */
440 0x7000, /* R152 - AUX1 Readback */
441 0x7000, /* R153 - AUX2 Readback */
442 0x7000, /* R154 - AUX3 Readback */
443 0x7000, /* R155 - AUX4 Readback */
444 0x0000, /* R156 - USB Voltage Readback */
445 0x0000, /* R157 - LINE Voltage Readback */
446 0x0000, /* R158 - BATT Voltage Readback */
447 0x0000, /* R159 - Chip Temp Readback */
448 0x0000, /* R160 */
449 0x0000, /* R161 */
450 0x0000, /* R162 */
451 0x0000, /* R163 - Generic Comparator Control */
452 0x0000, /* R164 - Generic comparator 1 */
453 0x0000, /* R165 - Generic comparator 2 */
454 0x0000, /* R166 - Generic comparator 3 */
455 0x0000, /* R167 - Generic comparator 4 */
456 0xA00F, /* R168 - Battery Charger Control 1 */
457 0x0B06, /* R169 - Battery Charger Control 2 */
458 0x0000, /* R170 - Battery Charger Control 3 */
459 0x0000, /* R171 */
460 0x0000, /* R172 - Current Sink Driver A */
461 0x0000, /* R173 - CSA Flash control */
462 0x0000, /* R174 - Current Sink Driver B */
463 0x0000, /* R175 - CSB Flash control */
464 0x0000, /* R176 - DCDC/LDO requested */
465 0x002D, /* R177 - DCDC Active options */
466 0x0000, /* R178 - DCDC Sleep options */
467 0x0025, /* R179 - Power-check comparator */
468 0x0062, /* R180 - DCDC1 Control */
469 0x0400, /* R181 - DCDC1 Timeouts */
470 0x1006, /* R182 - DCDC1 Low Power */
471 0x0018, /* R183 - DCDC2 Control */
472 0x0000, /* R184 - DCDC2 Timeouts */
473 0x0000, /* R185 */
474 0x0026, /* R186 - DCDC3 Control */
475 0x0400, /* R187 - DCDC3 Timeouts */
476 0x0006, /* R188 - DCDC3 Low Power */
477 0x0062, /* R189 - DCDC4 Control */
478 0x0400, /* R190 - DCDC4 Timeouts */
479 0x0006, /* R191 - DCDC4 Low Power */
480 0x0008, /* R192 - DCDC5 Control */
481 0x0000, /* R193 - DCDC5 Timeouts */
482 0x0000, /* R194 */
483 0x0026, /* R195 - DCDC6 Control */
484 0x0800, /* R196 - DCDC6 Timeouts */
485 0x0006, /* R197 - DCDC6 Low Power */
486 0x0000, /* R198 */
487 0x0003, /* R199 - Limit Switch Control */
488 0x0006, /* R200 - LDO1 Control */
489 0x0400, /* R201 - LDO1 Timeouts */
490 0x001C, /* R202 - LDO1 Low Power */
491 0x0006, /* R203 - LDO2 Control */
492 0x0400, /* R204 - LDO2 Timeouts */
493 0x001C, /* R205 - LDO2 Low Power */
494 0x001B, /* R206 - LDO3 Control */
495 0x0000, /* R207 - LDO3 Timeouts */
496 0x001C, /* R208 - LDO3 Low Power */
497 0x001B, /* R209 - LDO4 Control */
498 0x0000, /* R210 - LDO4 Timeouts */
499 0x001C, /* R211 - LDO4 Low Power */
500 0x0000, /* R212 */
501 0x0000, /* R213 */
502 0x0000, /* R214 */
503 0x0000, /* R215 - VCC_FAULT Masks */
504 0x001F, /* R216 - Main Bandgap Control */
505 0x0000, /* R217 - OSC Control */
506 0x9000, /* R218 - RTC Tick Control */
507 0x0000, /* R219 */
508 0x4000, /* R220 - RAM BIST 1 */
509 0x0000, /* R221 */
510 0x0000, /* R222 */
511 0x0000, /* R223 */
512 0x0000, /* R224 */
513 0x0000, /* R225 - DCDC/LDO status */
514 0x0000, /* R226 */
515 0x0000, /* R227 */
516 0x0000, /* R228 */
517 0x0000, /* R229 */
518 0xE000, /* R230 - GPIO Pin Status */
519 0x0000, /* R231 */
520 0x0000, /* R232 */
521 0x0000, /* R233 */
522 0x0000, /* R234 */
523 0x0000, /* R235 */
524 0x0000, /* R236 */
525 0x0000, /* R237 */
526 0x0000, /* R238 */
527 0x0000, /* R239 */
528 0x0000, /* R240 */
529 0x0000, /* R241 */
530 0x0000, /* R242 */
531 0x0000, /* R243 */
532 0x0000, /* R244 */
533 0x0000, /* R245 */
534 0x0000, /* R246 */
535 0x0000, /* R247 */
536 0x0000, /* R248 */
537 0x0000, /* R249 */
538 0x0000, /* R250 */
539 0x0000, /* R251 */
540 0x0000, /* R252 */
541 0x0000, /* R253 */
542 0x0000, /* R254 */
543 0x0000, /* R255 */
544};
545#endif
546
547#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_2
548
549#undef WM8350_HAVE_CONFIG_MODE
550#define WM8350_HAVE_CONFIG_MODE
551
552const u16 wm8350_mode2_defaults[] = {
553 0x17FF, /* R0 - Reset/ID */
554 0x1000, /* R1 - ID */
555 0x0000, /* R2 */
556 0x1002, /* R3 - System Control 1 */
557 0x0014, /* R4 - System Control 2 */
558 0x0000, /* R5 - System Hibernate */
559 0x8A00, /* R6 - Interface Control */
560 0x0000, /* R7 */
561 0x8000, /* R8 - Power mgmt (1) */
562 0x0000, /* R9 - Power mgmt (2) */
563 0x0000, /* R10 - Power mgmt (3) */
564 0x2000, /* R11 - Power mgmt (4) */
565 0x0E00, /* R12 - Power mgmt (5) */
566 0x0000, /* R13 - Power mgmt (6) */
567 0x0000, /* R14 - Power mgmt (7) */
568 0x0000, /* R15 */
569 0x0000, /* R16 - RTC Seconds/Minutes */
570 0x0100, /* R17 - RTC Hours/Day */
571 0x0101, /* R18 - RTC Date/Month */
572 0x1400, /* R19 - RTC Year */
573 0x0000, /* R20 - Alarm Seconds/Minutes */
574 0x0000, /* R21 - Alarm Hours/Day */
575 0x0000, /* R22 - Alarm Date/Month */
576 0x0320, /* R23 - RTC Time Control */
577 0x0000, /* R24 - System Interrupts */
578 0x0000, /* R25 - Interrupt Status 1 */
579 0x0000, /* R26 - Interrupt Status 2 */
580 0x0000, /* R27 - Power Up Interrupt Status */
581 0x0000, /* R28 - Under Voltage Interrupt status */
582 0x0000, /* R29 - Over Current Interrupt status */
583 0x0000, /* R30 - GPIO Interrupt Status */
584 0x0000, /* R31 - Comparator Interrupt Status */
585 0x3FFF, /* R32 - System Interrupts Mask */
586 0x0000, /* R33 - Interrupt Status 1 Mask */
587 0x0000, /* R34 - Interrupt Status 2 Mask */
588 0x0000, /* R35 - Power Up Interrupt Status Mask */
589 0x0000, /* R36 - Under Voltage Interrupt status Mask */
590 0x0000, /* R37 - Over Current Interrupt status Mask */
591 0x0000, /* R38 - GPIO Interrupt Status Mask */
592 0x0000, /* R39 - Comparator Interrupt Status Mask */
593 0x0040, /* R40 - Clock Control 1 */
594 0x0000, /* R41 - Clock Control 2 */
595 0x3B00, /* R42 - FLL Control 1 */
596 0x7086, /* R43 - FLL Control 2 */
597 0xC226, /* R44 - FLL Control 3 */
598 0x0000, /* R45 - FLL Control 4 */
599 0x0000, /* R46 */
600 0x0000, /* R47 */
601 0x0000, /* R48 - DAC Control */
602 0x0000, /* R49 */
603 0x00C0, /* R50 - DAC Digital Volume L */
604 0x00C0, /* R51 - DAC Digital Volume R */
605 0x0000, /* R52 */
606 0x0040, /* R53 - DAC LR Rate */
607 0x0000, /* R54 - DAC Clock Control */
608 0x0000, /* R55 */
609 0x0000, /* R56 */
610 0x0000, /* R57 */
611 0x4000, /* R58 - DAC Mute */
612 0x0000, /* R59 - DAC Mute Volume */
613 0x0000, /* R60 - DAC Side */
614 0x0000, /* R61 */
615 0x0000, /* R62 */
616 0x0000, /* R63 */
617 0x8000, /* R64 - ADC Control */
618 0x0000, /* R65 */
619 0x00C0, /* R66 - ADC Digital Volume L */
620 0x00C0, /* R67 - ADC Digital Volume R */
621 0x0000, /* R68 - ADC Divider */
622 0x0000, /* R69 */
623 0x0040, /* R70 - ADC LR Rate */
624 0x0000, /* R71 */
625 0x0303, /* R72 - Input Control */
626 0x0000, /* R73 - IN3 Input Control */
627 0x0000, /* R74 - Mic Bias Control */
628 0x0000, /* R75 */
629 0x0000, /* R76 - Output Control */
630 0x0000, /* R77 - Jack Detect */
631 0x0000, /* R78 - Anti Pop Control */
632 0x0000, /* R79 */
633 0x0040, /* R80 - Left Input Volume */
634 0x0040, /* R81 - Right Input Volume */
635 0x0000, /* R82 */
636 0x0000, /* R83 */
637 0x0000, /* R84 */
638 0x0000, /* R85 */
639 0x0000, /* R86 */
640 0x0000, /* R87 */
641 0x0800, /* R88 - Left Mixer Control */
642 0x1000, /* R89 - Right Mixer Control */
643 0x0000, /* R90 */
644 0x0000, /* R91 */
645 0x0000, /* R92 - OUT3 Mixer Control */
646 0x0000, /* R93 - OUT4 Mixer Control */
647 0x0000, /* R94 */
648 0x0000, /* R95 */
649 0x0000, /* R96 - Output Left Mixer Volume */
650 0x0000, /* R97 - Output Right Mixer Volume */
651 0x0000, /* R98 - Input Mixer Volume L */
652 0x0000, /* R99 - Input Mixer Volume R */
653 0x0000, /* R100 - Input Mixer Volume */
654 0x0000, /* R101 */
655 0x0000, /* R102 */
656 0x0000, /* R103 */
657 0x00E4, /* R104 - LOUT1 Volume */
658 0x00E4, /* R105 - ROUT1 Volume */
659 0x00E4, /* R106 - LOUT2 Volume */
660 0x02E4, /* R107 - ROUT2 Volume */
661 0x0000, /* R108 */
662 0x0000, /* R109 */
663 0x0000, /* R110 */
664 0x0000, /* R111 - BEEP Volume */
665 0x0A00, /* R112 - AI Formating */
666 0x0000, /* R113 - ADC DAC COMP */
667 0x0020, /* R114 - AI ADC Control */
668 0x0020, /* R115 - AI DAC Control */
669 0x0000, /* R116 - AIF Test */
670 0x0000, /* R117 */
671 0x0000, /* R118 */
672 0x0000, /* R119 */
673 0x0000, /* R120 */
674 0x0000, /* R121 */
675 0x0000, /* R122 */
676 0x0000, /* R123 */
677 0x0000, /* R124 */
678 0x0000, /* R125 */
679 0x0000, /* R126 */
680 0x0000, /* R127 */
681 0x1FFF, /* R128 - GPIO Debounce */
682 0x0000, /* R129 - GPIO Pin pull up Control */
683 0x03FC, /* R130 - GPIO Pull down Control */
684 0x0000, /* R131 - GPIO Interrupt Mode */
685 0x0000, /* R132 */
686 0x0000, /* R133 - GPIO Control */
687 0x08FB, /* R134 - GPIO Configuration (i/o) */
688 0x0CFE, /* R135 - GPIO Pin Polarity / Type */
689 0x0000, /* R136 */
690 0x0000, /* R137 */
691 0x0000, /* R138 */
692 0x0000, /* R139 */
693 0x0312, /* R140 - GPIO Function Select 1 */
694 0x0003, /* R141 - GPIO Function Select 2 */
695 0x2331, /* R142 - GPIO Function Select 3 */
696 0x0003, /* R143 - GPIO Function Select 4 */
697 0x0000, /* R144 - Digitiser Control (1) */
698 0x0002, /* R145 - Digitiser Control (2) */
699 0x0000, /* R146 */
700 0x0000, /* R147 */
701 0x0000, /* R148 */
702 0x0000, /* R149 */
703 0x0000, /* R150 */
704 0x0000, /* R151 */
705 0x7000, /* R152 - AUX1 Readback */
706 0x7000, /* R153 - AUX2 Readback */
707 0x7000, /* R154 - AUX3 Readback */
708 0x7000, /* R155 - AUX4 Readback */
709 0x0000, /* R156 - USB Voltage Readback */
710 0x0000, /* R157 - LINE Voltage Readback */
711 0x0000, /* R158 - BATT Voltage Readback */
712 0x0000, /* R159 - Chip Temp Readback */
713 0x0000, /* R160 */
714 0x0000, /* R161 */
715 0x0000, /* R162 */
716 0x0000, /* R163 - Generic Comparator Control */
717 0x0000, /* R164 - Generic comparator 1 */
718 0x0000, /* R165 - Generic comparator 2 */
719 0x0000, /* R166 - Generic comparator 3 */
720 0x0000, /* R167 - Generic comparator 4 */
721 0xA00F, /* R168 - Battery Charger Control 1 */
722 0x0B06, /* R169 - Battery Charger Control 2 */
723 0x0000, /* R170 - Battery Charger Control 3 */
724 0x0000, /* R171 */
725 0x0000, /* R172 - Current Sink Driver A */
726 0x0000, /* R173 - CSA Flash control */
727 0x0000, /* R174 - Current Sink Driver B */
728 0x0000, /* R175 - CSB Flash control */
729 0x0000, /* R176 - DCDC/LDO requested */
730 0x002D, /* R177 - DCDC Active options */
731 0x0000, /* R178 - DCDC Sleep options */
732 0x0025, /* R179 - Power-check comparator */
733 0x000E, /* R180 - DCDC1 Control */
734 0x0400, /* R181 - DCDC1 Timeouts */
735 0x1006, /* R182 - DCDC1 Low Power */
736 0x0018, /* R183 - DCDC2 Control */
737 0x0000, /* R184 - DCDC2 Timeouts */
738 0x0000, /* R185 */
739 0x002E, /* R186 - DCDC3 Control */
740 0x0800, /* R187 - DCDC3 Timeouts */
741 0x0006, /* R188 - DCDC3 Low Power */
742 0x000E, /* R189 - DCDC4 Control */
743 0x0800, /* R190 - DCDC4 Timeouts */
744 0x0006, /* R191 - DCDC4 Low Power */
745 0x0008, /* R192 - DCDC5 Control */
746 0x0000, /* R193 - DCDC5 Timeouts */
747 0x0000, /* R194 */
748 0x0026, /* R195 - DCDC6 Control */
749 0x0C00, /* R196 - DCDC6 Timeouts */
750 0x0006, /* R197 - DCDC6 Low Power */
751 0x0000, /* R198 */
752 0x0003, /* R199 - Limit Switch Control */
753 0x001A, /* R200 - LDO1 Control */
754 0x0800, /* R201 - LDO1 Timeouts */
755 0x001C, /* R202 - LDO1 Low Power */
756 0x0010, /* R203 - LDO2 Control */
757 0x0800, /* R204 - LDO2 Timeouts */
758 0x001C, /* R205 - LDO2 Low Power */
759 0x000A, /* R206 - LDO3 Control */
760 0x0C00, /* R207 - LDO3 Timeouts */
761 0x001C, /* R208 - LDO3 Low Power */
762 0x001A, /* R209 - LDO4 Control */
763 0x0800, /* R210 - LDO4 Timeouts */
764 0x001C, /* R211 - LDO4 Low Power */
765 0x0000, /* R212 */
766 0x0000, /* R213 */
767 0x0000, /* R214 */
768 0x0000, /* R215 - VCC_FAULT Masks */
769 0x001F, /* R216 - Main Bandgap Control */
770 0x0000, /* R217 - OSC Control */
771 0x9000, /* R218 - RTC Tick Control */
772 0x0000, /* R219 */
773 0x4000, /* R220 - RAM BIST 1 */
774 0x0000, /* R221 */
775 0x0000, /* R222 */
776 0x0000, /* R223 */
777 0x0000, /* R224 */
778 0x0000, /* R225 - DCDC/LDO status */
779 0x0000, /* R226 */
780 0x0000, /* R227 */
781 0x0000, /* R228 */
782 0x0000, /* R229 */
783 0xE000, /* R230 - GPIO Pin Status */
784 0x0000, /* R231 */
785 0x0000, /* R232 */
786 0x0000, /* R233 */
787 0x0000, /* R234 */
788 0x0000, /* R235 */
789 0x0000, /* R236 */
790 0x0000, /* R237 */
791 0x0000, /* R238 */
792 0x0000, /* R239 */
793 0x0000, /* R240 */
794 0x0000, /* R241 */
795 0x0000, /* R242 */
796 0x0000, /* R243 */
797 0x0000, /* R244 */
798 0x0000, /* R245 */
799 0x0000, /* R246 */
800 0x0000, /* R247 */
801 0x0000, /* R248 */
802 0x0000, /* R249 */
803 0x0000, /* R250 */
804 0x0000, /* R251 */
805 0x0000, /* R252 */
806 0x0000, /* R253 */
807 0x0000, /* R254 */
808 0x0000, /* R255 */
809};
810#endif
811
812#ifdef CONFIG_MFD_WM8350_CONFIG_MODE_3
813
814#undef WM8350_HAVE_CONFIG_MODE
815#define WM8350_HAVE_CONFIG_MODE
816
817const u16 wm8350_mode3_defaults[] = {
818 0x17FF, /* R0 - Reset/ID */
819 0x1000, /* R1 - ID */
820 0x0000, /* R2 */
821 0x1000, /* R3 - System Control 1 */
822 0x0004, /* R4 - System Control 2 */
823 0x0000, /* R5 - System Hibernate */
824 0x8A00, /* R6 - Interface Control */
825 0x0000, /* R7 */
826 0x8000, /* R8 - Power mgmt (1) */
827 0x0000, /* R9 - Power mgmt (2) */
828 0x0000, /* R10 - Power mgmt (3) */
829 0x2000, /* R11 - Power mgmt (4) */
830 0x0E00, /* R12 - Power mgmt (5) */
831 0x0000, /* R13 - Power mgmt (6) */
832 0x0000, /* R14 - Power mgmt (7) */
833 0x0000, /* R15 */
834 0x0000, /* R16 - RTC Seconds/Minutes */
835 0x0100, /* R17 - RTC Hours/Day */
836 0x0101, /* R18 - RTC Date/Month */
837 0x1400, /* R19 - RTC Year */
838 0x0000, /* R20 - Alarm Seconds/Minutes */
839 0x0000, /* R21 - Alarm Hours/Day */
840 0x0000, /* R22 - Alarm Date/Month */
841 0x0320, /* R23 - RTC Time Control */
842 0x0000, /* R24 - System Interrupts */
843 0x0000, /* R25 - Interrupt Status 1 */
844 0x0000, /* R26 - Interrupt Status 2 */
845 0x0000, /* R27 - Power Up Interrupt Status */
846 0x0000, /* R28 - Under Voltage Interrupt status */
847 0x0000, /* R29 - Over Current Interrupt status */
848 0x0000, /* R30 - GPIO Interrupt Status */
849 0x0000, /* R31 - Comparator Interrupt Status */
850 0x3FFF, /* R32 - System Interrupts Mask */
851 0x0000, /* R33 - Interrupt Status 1 Mask */
852 0x0000, /* R34 - Interrupt Status 2 Mask */
853 0x0000, /* R35 - Power Up Interrupt Status Mask */
854 0x0000, /* R36 - Under Voltage Interrupt status Mask */
855 0x0000, /* R37 - Over Current Interrupt status Mask */
856 0x0000, /* R38 - GPIO Interrupt Status Mask */
857 0x0000, /* R39 - Comparator Interrupt Status Mask */
858 0x0040, /* R40 - Clock Control 1 */
859 0x0000, /* R41 - Clock Control 2 */
860 0x3B00, /* R42 - FLL Control 1 */
861 0x7086, /* R43 - FLL Control 2 */
862 0xC226, /* R44 - FLL Control 3 */
863 0x0000, /* R45 - FLL Control 4 */
864 0x0000, /* R46 */
865 0x0000, /* R47 */
866 0x0000, /* R48 - DAC Control */
867 0x0000, /* R49 */
868 0x00C0, /* R50 - DAC Digital Volume L */
869 0x00C0, /* R51 - DAC Digital Volume R */
870 0x0000, /* R52 */
871 0x0040, /* R53 - DAC LR Rate */
872 0x0000, /* R54 - DAC Clock Control */
873 0x0000, /* R55 */
874 0x0000, /* R56 */
875 0x0000, /* R57 */
876 0x4000, /* R58 - DAC Mute */
877 0x0000, /* R59 - DAC Mute Volume */
878 0x0000, /* R60 - DAC Side */
879 0x0000, /* R61 */
880 0x0000, /* R62 */
881 0x0000, /* R63 */
882 0x8000, /* R64 - ADC Control */
883 0x0000, /* R65 */
884 0x00C0, /* R66 - ADC Digital Volume L */
885 0x00C0, /* R67 - ADC Digital Volume R */
886 0x0000, /* R68 - ADC Divider */
887 0x0000, /* R69 */
888 0x0040, /* R70 - ADC LR Rate */
889 0x0000, /* R71 */
890 0x0303, /* R72 - Input Control */
891 0x0000, /* R73 - IN3 Input Control */
892 0x0000, /* R74 - Mic Bias Control */
893 0x0000, /* R75 */
894 0x0000, /* R76 - Output Control */
895 0x0000, /* R77 - Jack Detect */
896 0x0000, /* R78 - Anti Pop Control */
897 0x0000, /* R79 */
898 0x0040, /* R80 - Left Input Volume */
899 0x0040, /* R81 - Right Input Volume */
900 0x0000, /* R82 */
901 0x0000, /* R83 */
902 0x0000, /* R84 */
903 0x0000, /* R85 */
904 0x0000, /* R86 */
905 0x0000, /* R87 */
906 0x0800, /* R88 - Left Mixer Control */
907 0x1000, /* R89 - Right Mixer Control */
908 0x0000, /* R90 */
909 0x0000, /* R91 */
910 0x0000, /* R92 - OUT3 Mixer Control */
911 0x0000, /* R93 - OUT4 Mixer Control */
912 0x0000, /* R94 */
913 0x0000, /* R95 */
914 0x0000, /* R96 - Output Left Mixer Volume */
915 0x0000, /* R97 - Output Right Mixer Volume */
916 0x0000, /* R98 - Input Mixer Volume L */
917 0x0000, /* R99 - Input Mixer Volume R */
918 0x0000, /* R100 - Input Mixer Volume */
919 0x0000, /* R101 */
920 0x0000, /* R102 */
921 0x0000, /* R103 */
922 0x00E4, /* R104 - LOUT1 Volume */
923 0x00E4, /* R105 - ROUT1 Volume */
924 0x00E4, /* R106 - LOUT2 Volume */
925 0x02E4, /* R107 - ROUT2 Volume */
926 0x0000, /* R108 */
927 0x0000, /* R109 */
928 0x0000, /* R110 */
929 0x0000, /* R111 - BEEP Volume */
930 0x0A00, /* R112 - AI Formating */
931 0x0000, /* R113 - ADC DAC COMP */
932 0x0020, /* R114 - AI ADC Control */
933 0x0020, /* R115 - AI DAC Control */
934 0x0000, /* R116 - AIF Test */
935 0x0000, /* R117 */
936 0x0000, /* R118 */
937 0x0000, /* R119 */
938 0x0000, /* R120 */
939 0x0000, /* R121 */
940 0x0000, /* R122 */
941 0x0000, /* R123 */
942 0x0000, /* R124 */
943 0x0000, /* R125 */
944 0x0000, /* R126 */
945 0x0000, /* R127 */
946 0x1FFF, /* R128 - GPIO Debounce */
947 0x0000, /* R129 - GPIO Pin pull up Control */
948 0x03FC, /* R130 - GPIO Pull down Control */
949 0x0000, /* R131 - GPIO Interrupt Mode */
950 0x0000, /* R132 */
951 0x0000, /* R133 - GPIO Control */
952 0x0A7B, /* R134 - GPIO Configuration (i/o) */
953 0x06FE, /* R135 - GPIO Pin Polarity / Type */
954 0x0000, /* R136 */
955 0x0000, /* R137 */
956 0x0000, /* R138 */
957 0x0000, /* R139 */
958 0x1312, /* R140 - GPIO Function Select 1 */
959 0x1030, /* R141 - GPIO Function Select 2 */
960 0x2231, /* R142 - GPIO Function Select 3 */
961 0x0003, /* R143 - GPIO Function Select 4 */
962 0x0000, /* R144 - Digitiser Control (1) */
963 0x0002, /* R145 - Digitiser Control (2) */
964 0x0000, /* R146 */
965 0x0000, /* R147 */
966 0x0000, /* R148 */
967 0x0000, /* R149 */
968 0x0000, /* R150 */
969 0x0000, /* R151 */
970 0x7000, /* R152 - AUX1 Readback */
971 0x7000, /* R153 - AUX2 Readback */
972 0x7000, /* R154 - AUX3 Readback */
973 0x7000, /* R155 - AUX4 Readback */
974 0x0000, /* R156 - USB Voltage Readback */
975 0x0000, /* R157 - LINE Voltage Readback */
976 0x0000, /* R158 - BATT Voltage Readback */
977 0x0000, /* R159 - Chip Temp Readback */
978 0x0000, /* R160 */
979 0x0000, /* R161 */
980 0x0000, /* R162 */
981 0x0000, /* R163 - Generic Comparator Control */
982 0x0000, /* R164 - Generic comparator 1 */
983 0x0000, /* R165 - Generic comparator 2 */
984 0x0000, /* R166 - Generic comparator 3 */
985 0x0000, /* R167 - Generic comparator 4 */
986 0xA00F, /* R168 - Battery Charger Control 1 */
987 0x0B06, /* R169 - Battery Charger Control 2 */
988 0x0000, /* R170 - Battery Charger Control 3 */
989 0x0000, /* R171 */
990 0x0000, /* R172 - Current Sink Driver A */
991 0x0000, /* R173 - CSA Flash control */
992 0x0000, /* R174 - Current Sink Driver B */
993 0x0000, /* R175 - CSB Flash control */
994 0x0000, /* R176 - DCDC/LDO requested */
995 0x002D, /* R177 - DCDC Active options */
996 0x0000, /* R178 - DCDC Sleep options */
997 0x0025, /* R179 - Power-check comparator */
998 0x000E, /* R180 - DCDC1 Control */
999 0x0400, /* R181 - DCDC1 Timeouts */
1000 0x1006, /* R182 - DCDC1 Low Power */
1001 0x0018, /* R183 - DCDC2 Control */
1002 0x0000, /* R184 - DCDC2 Timeouts */
1003 0x0000, /* R185 */
1004 0x000E, /* R186 - DCDC3 Control */
1005 0x0400, /* R187 - DCDC3 Timeouts */
1006 0x0006, /* R188 - DCDC3 Low Power */
1007 0x0026, /* R189 - DCDC4 Control */
1008 0x0400, /* R190 - DCDC4 Timeouts */
1009 0x0006, /* R191 - DCDC4 Low Power */
1010 0x0008, /* R192 - DCDC5 Control */
1011 0x0000, /* R193 - DCDC5 Timeouts */
1012 0x0000, /* R194 */
1013 0x0026, /* R195 - DCDC6 Control */
1014 0x0400, /* R196 - DCDC6 Timeouts */
1015 0x0006, /* R197 - DCDC6 Low Power */
1016 0x0000, /* R198 */
1017 0x0003, /* R199 - Limit Switch Control */
1018 0x001C, /* R200 - LDO1 Control */
1019 0x0000, /* R201 - LDO1 Timeouts */
1020 0x001C, /* R202 - LDO1 Low Power */
1021 0x001C, /* R203 - LDO2 Control */
1022 0x0400, /* R204 - LDO2 Timeouts */
1023 0x001C, /* R205 - LDO2 Low Power */
1024 0x001C, /* R206 - LDO3 Control */
1025 0x0400, /* R207 - LDO3 Timeouts */
1026 0x001C, /* R208 - LDO3 Low Power */
1027 0x001F, /* R209 - LDO4 Control */
1028 0x0400, /* R210 - LDO4 Timeouts */
1029 0x001C, /* R211 - LDO4 Low Power */
1030 0x0000, /* R212 */
1031 0x0000, /* R213 */
1032 0x0000, /* R214 */
1033 0x0000, /* R215 - VCC_FAULT Masks */
1034 0x001F, /* R216 - Main Bandgap Control */
1035 0x0000, /* R217 - OSC Control */
1036 0x9000, /* R218 - RTC Tick Control */
1037 0x0000, /* R219 */
1038 0x4000, /* R220 - RAM BIST 1 */
1039 0x0000, /* R221 */
1040 0x0000, /* R222 */
1041 0x0000, /* R223 */
1042 0x0000, /* R224 */
1043 0x0000, /* R225 - DCDC/LDO status */
1044 0x0000, /* R226 */
1045 0x0000, /* R227 */
1046 0x0000, /* R228 */
1047 0x0000, /* R229 */
1048 0xE000, /* R230 - GPIO Pin Status */
1049 0x0000, /* R231 */
1050 0x0000, /* R232 */
1051 0x0000, /* R233 */
1052 0x0000, /* R234 */
1053 0x0000, /* R235 */
1054 0x0000, /* R236 */
1055 0x0000, /* R237 */
1056 0x0000, /* R238 */
1057 0x0000, /* R239 */
1058 0x0000, /* R240 */
1059 0x0000, /* R241 */
1060 0x0000, /* R242 */
1061 0x0000, /* R243 */
1062 0x0000, /* R244 */
1063 0x0000, /* R245 */
1064 0x0000, /* R246 */
1065 0x0000, /* R247 */
1066 0x0000, /* R248 */
1067 0x0000, /* R249 */
1068 0x0000, /* R250 */
1069 0x0000, /* R251 */
1070 0x0000, /* R252 */
1071 0x0000, /* R253 */
1072 0x0000, /* R254 */
1073 0x0000, /* R255 */
1074};
1075#endif
1076
1077#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_0
1078
1079#undef WM8350_HAVE_CONFIG_MODE
1080#define WM8350_HAVE_CONFIG_MODE
1081
1082const u16 wm8351_mode0_defaults[] = {
1083 0x6143, /* R0 - Reset/ID */
1084 0x0000, /* R1 - ID */
1085 0x0001, /* R2 - Revision */
1086 0x1C02, /* R3 - System Control 1 */
1087 0x0004, /* R4 - System Control 2 */
1088 0x0000, /* R5 - System Hibernate */
1089 0x8A00, /* R6 - Interface Control */
1090 0x0000, /* R7 */
1091 0x8000, /* R8 - Power mgmt (1) */
1092 0x0000, /* R9 - Power mgmt (2) */
1093 0x0000, /* R10 - Power mgmt (3) */
1094 0x2000, /* R11 - Power mgmt (4) */
1095 0x0E00, /* R12 - Power mgmt (5) */
1096 0x0000, /* R13 - Power mgmt (6) */
1097 0x0000, /* R14 - Power mgmt (7) */
1098 0x0000, /* R15 */
1099 0x0000, /* R16 - RTC Seconds/Minutes */
1100 0x0100, /* R17 - RTC Hours/Day */
1101 0x0101, /* R18 - RTC Date/Month */
1102 0x1400, /* R19 - RTC Year */
1103 0x0000, /* R20 - Alarm Seconds/Minutes */
1104 0x0000, /* R21 - Alarm Hours/Day */
1105 0x0000, /* R22 - Alarm Date/Month */
1106 0x0320, /* R23 - RTC Time Control */
1107 0x0000, /* R24 - System Interrupts */
1108 0x0000, /* R25 - Interrupt Status 1 */
1109 0x0000, /* R26 - Interrupt Status 2 */
1110 0x0000, /* R27 */
1111 0x0000, /* R28 - Under Voltage Interrupt status */
1112 0x0000, /* R29 - Over Current Interrupt status */
1113 0x0000, /* R30 - GPIO Interrupt Status */
1114 0x0000, /* R31 - Comparator Interrupt Status */
1115 0x3FFF, /* R32 - System Interrupts Mask */
1116 0x0000, /* R33 - Interrupt Status 1 Mask */
1117 0x0000, /* R34 - Interrupt Status 2 Mask */
1118 0x0000, /* R35 */
1119 0x0000, /* R36 - Under Voltage Interrupt status Mask */
1120 0x0000, /* R37 - Over Current Interrupt status Mask */
1121 0x0000, /* R38 - GPIO Interrupt Status Mask */
1122 0x0000, /* R39 - Comparator Interrupt Status Mask */
1123 0x0040, /* R40 - Clock Control 1 */
1124 0x0000, /* R41 - Clock Control 2 */
1125 0x3A00, /* R42 - FLL Control 1 */
1126 0x7086, /* R43 - FLL Control 2 */
1127 0xC226, /* R44 - FLL Control 3 */
1128 0x0000, /* R45 - FLL Control 4 */
1129 0x0000, /* R46 */
1130 0x0000, /* R47 */
1131 0x0000, /* R48 - DAC Control */
1132 0x0000, /* R49 */
1133 0x00C0, /* R50 - DAC Digital Volume L */
1134 0x00C0, /* R51 - DAC Digital Volume R */
1135 0x0000, /* R52 */
1136 0x0040, /* R53 - DAC LR Rate */
1137 0x0000, /* R54 - DAC Clock Control */
1138 0x0000, /* R55 */
1139 0x0000, /* R56 */
1140 0x0000, /* R57 */
1141 0x4000, /* R58 - DAC Mute */
1142 0x0000, /* R59 - DAC Mute Volume */
1143 0x0000, /* R60 - DAC Side */
1144 0x0000, /* R61 */
1145 0x0000, /* R62 */
1146 0x0000, /* R63 */
1147 0x8000, /* R64 - ADC Control */
1148 0x0000, /* R65 */
1149 0x00C0, /* R66 - ADC Digital Volume L */
1150 0x00C0, /* R67 - ADC Digital Volume R */
1151 0x0000, /* R68 - ADC Divider */
1152 0x0000, /* R69 */
1153 0x0040, /* R70 - ADC LR Rate */
1154 0x0000, /* R71 */
1155 0x0303, /* R72 - Input Control */
1156 0x0000, /* R73 - IN3 Input Control */
1157 0x0000, /* R74 - Mic Bias Control */
1158 0x0000, /* R75 */
1159 0x0000, /* R76 - Output Control */
1160 0x0000, /* R77 - Jack Detect */
1161 0x0000, /* R78 - Anti Pop Control */
1162 0x0000, /* R79 */
1163 0x0040, /* R80 - Left Input Volume */
1164 0x0040, /* R81 - Right Input Volume */
1165 0x0000, /* R82 */
1166 0x0000, /* R83 */
1167 0x0000, /* R84 */
1168 0x0000, /* R85 */
1169 0x0000, /* R86 */
1170 0x0000, /* R87 */
1171 0x0800, /* R88 - Left Mixer Control */
1172 0x1000, /* R89 - Right Mixer Control */
1173 0x0000, /* R90 */
1174 0x0000, /* R91 */
1175 0x0000, /* R92 - OUT3 Mixer Control */
1176 0x0000, /* R93 - OUT4 Mixer Control */
1177 0x0000, /* R94 */
1178 0x0000, /* R95 */
1179 0x0000, /* R96 - Output Left Mixer Volume */
1180 0x0000, /* R97 - Output Right Mixer Volume */
1181 0x0000, /* R98 - Input Mixer Volume L */
1182 0x0000, /* R99 - Input Mixer Volume R */
1183 0x0000, /* R100 - Input Mixer Volume */
1184 0x0000, /* R101 */
1185 0x0000, /* R102 */
1186 0x0000, /* R103 */
1187 0x00E4, /* R104 - OUT1L Volume */
1188 0x00E4, /* R105 - OUT1R Volume */
1189 0x00E4, /* R106 - OUT2L Volume */
1190 0x02E4, /* R107 - OUT2R Volume */
1191 0x0000, /* R108 */
1192 0x0000, /* R109 */
1193 0x0000, /* R110 */
1194 0x0000, /* R111 - BEEP Volume */
1195 0x0A00, /* R112 - AI Formating */
1196 0x0000, /* R113 - ADC DAC COMP */
1197 0x0020, /* R114 - AI ADC Control */
1198 0x0020, /* R115 - AI DAC Control */
1199 0x0000, /* R116 */
1200 0x0000, /* R117 */
1201 0x0000, /* R118 */
1202 0x0000, /* R119 */
1203 0x0000, /* R120 */
1204 0x0000, /* R121 */
1205 0x0000, /* R122 */
1206 0x0000, /* R123 */
1207 0x0000, /* R124 */
1208 0x0000, /* R125 */
1209 0x0000, /* R126 */
1210 0x0000, /* R127 */
1211 0x1FFF, /* R128 - GPIO Debounce */
1212 0x0000, /* R129 - GPIO Pin pull up Control */
1213 0x0000, /* R130 - GPIO Pull down Control */
1214 0x0000, /* R131 - GPIO Interrupt Mode */
1215 0x0000, /* R132 */
1216 0x0000, /* R133 - GPIO Control */
1217 0x0FFC, /* R134 - GPIO Configuration (i/o) */
1218 0x0FFC, /* R135 - GPIO Pin Polarity / Type */
1219 0x0000, /* R136 */
1220 0x0000, /* R137 */
1221 0x0000, /* R138 */
1222 0x0000, /* R139 */
1223 0x0013, /* R140 - GPIO Function Select 1 */
1224 0x0000, /* R141 - GPIO Function Select 2 */
1225 0x0000, /* R142 - GPIO Function Select 3 */
1226 0x0003, /* R143 - GPIO Function Select 4 */
1227 0x0000, /* R144 - Digitiser Control (1) */
1228 0x0002, /* R145 - Digitiser Control (2) */
1229 0x0000, /* R146 */
1230 0x0000, /* R147 */
1231 0x0000, /* R148 */
1232 0x0000, /* R149 */
1233 0x0000, /* R150 */
1234 0x0000, /* R151 */
1235 0x7000, /* R152 - AUX1 Readback */
1236 0x7000, /* R153 - AUX2 Readback */
1237 0x7000, /* R154 - AUX3 Readback */
1238 0x7000, /* R155 - AUX4 Readback */
1239 0x0000, /* R156 - USB Voltage Readback */
1240 0x0000, /* R157 - LINE Voltage Readback */
1241 0x0000, /* R158 - BATT Voltage Readback */
1242 0x0000, /* R159 - Chip Temp Readback */
1243 0x0000, /* R160 */
1244 0x0000, /* R161 */
1245 0x0000, /* R162 */
1246 0x0000, /* R163 - Generic Comparator Control */
1247 0x0000, /* R164 - Generic comparator 1 */
1248 0x0000, /* R165 - Generic comparator 2 */
1249 0x0000, /* R166 - Generic comparator 3 */
1250 0x0000, /* R167 - Generic comparator 4 */
1251 0xA00F, /* R168 - Battery Charger Control 1 */
1252 0x0B06, /* R169 - Battery Charger Control 2 */
1253 0x0000, /* R170 - Battery Charger Control 3 */
1254 0x0000, /* R171 */
1255 0x0000, /* R172 - Current Sink Driver A */
1256 0x0000, /* R173 - CSA Flash control */
1257 0x0000, /* R174 */
1258 0x0000, /* R175 */
1259 0x0000, /* R176 - DCDC/LDO requested */
1260 0x032D, /* R177 - DCDC Active options */
1261 0x0000, /* R178 - DCDC Sleep options */
1262 0x0025, /* R179 - Power-check comparator */
1263 0x000E, /* R180 - DCDC1 Control */
1264 0x0000, /* R181 - DCDC1 Timeouts */
1265 0x1006, /* R182 - DCDC1 Low Power */
1266 0x0018, /* R183 - DCDC2 Control */
1267 0x0000, /* R184 - DCDC2 Timeouts */
1268 0x0000, /* R185 */
1269 0x0000, /* R186 - DCDC3 Control */
1270 0x0000, /* R187 - DCDC3 Timeouts */
1271 0x0006, /* R188 - DCDC3 Low Power */
1272 0x0000, /* R189 - DCDC4 Control */
1273 0x0000, /* R190 - DCDC4 Timeouts */
1274 0x0006, /* R191 - DCDC4 Low Power */
1275 0x0008, /* R192 */
1276 0x0000, /* R193 */
1277 0x0000, /* R194 */
1278 0x0000, /* R195 */
1279 0x0000, /* R196 */
1280 0x0006, /* R197 */
1281 0x0000, /* R198 */
1282 0x0003, /* R199 - Limit Switch Control */
1283 0x001C, /* R200 - LDO1 Control */
1284 0x0000, /* R201 - LDO1 Timeouts */
1285 0x001C, /* R202 - LDO1 Low Power */
1286 0x001B, /* R203 - LDO2 Control */
1287 0x0000, /* R204 - LDO2 Timeouts */
1288 0x001C, /* R205 - LDO2 Low Power */
1289 0x001B, /* R206 - LDO3 Control */
1290 0x0000, /* R207 - LDO3 Timeouts */
1291 0x001C, /* R208 - LDO3 Low Power */
1292 0x001B, /* R209 - LDO4 Control */
1293 0x0000, /* R210 - LDO4 Timeouts */
1294 0x001C, /* R211 - LDO4 Low Power */
1295 0x0000, /* R212 */
1296 0x0000, /* R213 */
1297 0x0000, /* R214 */
1298 0x0000, /* R215 - VCC_FAULT Masks */
1299 0x001F, /* R216 - Main Bandgap Control */
1300 0x0000, /* R217 - OSC Control */
1301 0x9000, /* R218 - RTC Tick Control */
1302 0x0000, /* R219 - Security1 */
1303 0x4000, /* R220 */
1304 0x0000, /* R221 */
1305 0x0000, /* R222 */
1306 0x0000, /* R223 */
1307 0x0000, /* R224 - Signal overrides */
1308 0x0000, /* R225 - DCDC/LDO status */
1309 0x0000, /* R226 - Charger Overides/status */
1310 0x0000, /* R227 - misc overrides */
1311 0x0000, /* R228 - Supply overrides/status 1 */
1312 0x0000, /* R229 - Supply overrides/status 2 */
1313 0xE000, /* R230 - GPIO Pin Status */
1314 0x0000, /* R231 - comparotor overrides */
1315 0x0000, /* R232 */
1316 0x0000, /* R233 - State Machine status */
1317 0x1200, /* R234 - FLL Test 1 */
1318 0x0000, /* R235 */
1319 0x8000, /* R236 */
1320 0x0000, /* R237 */
1321 0x0000, /* R238 */
1322 0x0000, /* R239 */
1323 0x0003, /* R240 */
1324 0x0000, /* R241 */
1325 0x0000, /* R242 */
1326 0x0004, /* R243 */
1327 0x0300, /* R244 */
1328 0x0000, /* R245 */
1329 0x0200, /* R246 */
1330 0x0000, /* R247 */
1331 0x1000, /* R248 - DCDC1 Test Controls */
1332 0x1000, /* R249 */
1333 0x1000, /* R250 - DCDC3 Test Controls */
1334 0x1000, /* R251 - DCDC4 Test Controls */
1335};
1336#endif
1337
1338#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_1
1339
1340#undef WM8350_HAVE_CONFIG_MODE
1341#define WM8350_HAVE_CONFIG_MODE
1342
1343const u16 wm8351_mode1_defaults[] = {
1344 0x6143, /* R0 - Reset/ID */
1345 0x0000, /* R1 - ID */
1346 0x0001, /* R2 - Revision */
1347 0x1C02, /* R3 - System Control 1 */
1348 0x0204, /* R4 - System Control 2 */
1349 0x0000, /* R5 - System Hibernate */
1350 0x8A00, /* R6 - Interface Control */
1351 0x0000, /* R7 */
1352 0x8000, /* R8 - Power mgmt (1) */
1353 0x0000, /* R9 - Power mgmt (2) */
1354 0x0000, /* R10 - Power mgmt (3) */
1355 0x2000, /* R11 - Power mgmt (4) */
1356 0x0E00, /* R12 - Power mgmt (5) */
1357 0x0000, /* R13 - Power mgmt (6) */
1358 0x0000, /* R14 - Power mgmt (7) */
1359 0x0000, /* R15 */
1360 0x0000, /* R16 - RTC Seconds/Minutes */
1361 0x0100, /* R17 - RTC Hours/Day */
1362 0x0101, /* R18 - RTC Date/Month */
1363 0x1400, /* R19 - RTC Year */
1364 0x0000, /* R20 - Alarm Seconds/Minutes */
1365 0x0000, /* R21 - Alarm Hours/Day */
1366 0x0000, /* R22 - Alarm Date/Month */
1367 0x0320, /* R23 - RTC Time Control */
1368 0x0000, /* R24 - System Interrupts */
1369 0x0000, /* R25 - Interrupt Status 1 */
1370 0x0000, /* R26 - Interrupt Status 2 */
1371 0x0000, /* R27 */
1372 0x0000, /* R28 - Under Voltage Interrupt status */
1373 0x0000, /* R29 - Over Current Interrupt status */
1374 0x0000, /* R30 - GPIO Interrupt Status */
1375 0x0000, /* R31 - Comparator Interrupt Status */
1376 0x3FFF, /* R32 - System Interrupts Mask */
1377 0x0000, /* R33 - Interrupt Status 1 Mask */
1378 0x0000, /* R34 - Interrupt Status 2 Mask */
1379 0x0000, /* R35 */
1380 0x0000, /* R36 - Under Voltage Interrupt status Mask */
1381 0x0000, /* R37 - Over Current Interrupt status Mask */
1382 0x0000, /* R38 - GPIO Interrupt Status Mask */
1383 0x0000, /* R39 - Comparator Interrupt Status Mask */
1384 0x0040, /* R40 - Clock Control 1 */
1385 0x0000, /* R41 - Clock Control 2 */
1386 0x3A00, /* R42 - FLL Control 1 */
1387 0x7086, /* R43 - FLL Control 2 */
1388 0xC226, /* R44 - FLL Control 3 */
1389 0x0000, /* R45 - FLL Control 4 */
1390 0x0000, /* R46 */
1391 0x0000, /* R47 */
1392 0x0000, /* R48 - DAC Control */
1393 0x0000, /* R49 */
1394 0x00C0, /* R50 - DAC Digital Volume L */
1395 0x00C0, /* R51 - DAC Digital Volume R */
1396 0x0000, /* R52 */
1397 0x0040, /* R53 - DAC LR Rate */
1398 0x0000, /* R54 - DAC Clock Control */
1399 0x0000, /* R55 */
1400 0x0000, /* R56 */
1401 0x0000, /* R57 */
1402 0x4000, /* R58 - DAC Mute */
1403 0x0000, /* R59 - DAC Mute Volume */
1404 0x0000, /* R60 - DAC Side */
1405 0x0000, /* R61 */
1406 0x0000, /* R62 */
1407 0x0000, /* R63 */
1408 0x8000, /* R64 - ADC Control */
1409 0x0000, /* R65 */
1410 0x00C0, /* R66 - ADC Digital Volume L */
1411 0x00C0, /* R67 - ADC Digital Volume R */
1412 0x0000, /* R68 - ADC Divider */
1413 0x0000, /* R69 */
1414 0x0040, /* R70 - ADC LR Rate */
1415 0x0000, /* R71 */
1416 0x0303, /* R72 - Input Control */
1417 0x0000, /* R73 - IN3 Input Control */
1418 0x0000, /* R74 - Mic Bias Control */
1419 0x0000, /* R75 */
1420 0x0000, /* R76 - Output Control */
1421 0x0000, /* R77 - Jack Detect */
1422 0x0000, /* R78 - Anti Pop Control */
1423 0x0000, /* R79 */
1424 0x0040, /* R80 - Left Input Volume */
1425 0x0040, /* R81 - Right Input Volume */
1426 0x0000, /* R82 */
1427 0x0000, /* R83 */
1428 0x0000, /* R84 */
1429 0x0000, /* R85 */
1430 0x0000, /* R86 */
1431 0x0000, /* R87 */
1432 0x0800, /* R88 - Left Mixer Control */
1433 0x1000, /* R89 - Right Mixer Control */
1434 0x0000, /* R90 */
1435 0x0000, /* R91 */
1436 0x0000, /* R92 - OUT3 Mixer Control */
1437 0x0000, /* R93 - OUT4 Mixer Control */
1438 0x0000, /* R94 */
1439 0x0000, /* R95 */
1440 0x0000, /* R96 - Output Left Mixer Volume */
1441 0x0000, /* R97 - Output Right Mixer Volume */
1442 0x0000, /* R98 - Input Mixer Volume L */
1443 0x0000, /* R99 - Input Mixer Volume R */
1444 0x0000, /* R100 - Input Mixer Volume */
1445 0x0000, /* R101 */
1446 0x0000, /* R102 */
1447 0x0000, /* R103 */
1448 0x00E4, /* R104 - OUT1L Volume */
1449 0x00E4, /* R105 - OUT1R Volume */
1450 0x00E4, /* R106 - OUT2L Volume */
1451 0x02E4, /* R107 - OUT2R Volume */
1452 0x0000, /* R108 */
1453 0x0000, /* R109 */
1454 0x0000, /* R110 */
1455 0x0000, /* R111 - BEEP Volume */
1456 0x0A00, /* R112 - AI Formating */
1457 0x0000, /* R113 - ADC DAC COMP */
1458 0x0020, /* R114 - AI ADC Control */
1459 0x0020, /* R115 - AI DAC Control */
1460 0x0000, /* R116 */
1461 0x0000, /* R117 */
1462 0x0000, /* R118 */
1463 0x0000, /* R119 */
1464 0x0000, /* R120 */
1465 0x0000, /* R121 */
1466 0x0000, /* R122 */
1467 0x0000, /* R123 */
1468 0x0000, /* R124 */
1469 0x0000, /* R125 */
1470 0x0000, /* R126 */
1471 0x0000, /* R127 */
1472 0x1FFF, /* R128 - GPIO Debounce */
1473 0x0000, /* R129 - GPIO Pin pull up Control */
1474 0x0000, /* R130 - GPIO Pull down Control */
1475 0x0000, /* R131 - GPIO Interrupt Mode */
1476 0x0000, /* R132 */
1477 0x0000, /* R133 - GPIO Control */
1478 0x0CFB, /* R134 - GPIO Configuration (i/o) */
1479 0x0C1F, /* R135 - GPIO Pin Polarity / Type */
1480 0x0000, /* R136 */
1481 0x0000, /* R137 */
1482 0x0000, /* R138 */
1483 0x0000, /* R139 */
1484 0x0300, /* R140 - GPIO Function Select 1 */
1485 0x1110, /* R141 - GPIO Function Select 2 */
1486 0x0013, /* R142 - GPIO Function Select 3 */
1487 0x0003, /* R143 - GPIO Function Select 4 */
1488 0x0000, /* R144 - Digitiser Control (1) */
1489 0x0002, /* R145 - Digitiser Control (2) */
1490 0x0000, /* R146 */
1491 0x0000, /* R147 */
1492 0x0000, /* R148 */
1493 0x0000, /* R149 */
1494 0x0000, /* R150 */
1495 0x0000, /* R151 */
1496 0x7000, /* R152 - AUX1 Readback */
1497 0x7000, /* R153 - AUX2 Readback */
1498 0x7000, /* R154 - AUX3 Readback */
1499 0x7000, /* R155 - AUX4 Readback */
1500 0x0000, /* R156 - USB Voltage Readback */
1501 0x0000, /* R157 - LINE Voltage Readback */
1502 0x0000, /* R158 - BATT Voltage Readback */
1503 0x0000, /* R159 - Chip Temp Readback */
1504 0x0000, /* R160 */
1505 0x0000, /* R161 */
1506 0x0000, /* R162 */
1507 0x0000, /* R163 - Generic Comparator Control */
1508 0x0000, /* R164 - Generic comparator 1 */
1509 0x0000, /* R165 - Generic comparator 2 */
1510 0x0000, /* R166 - Generic comparator 3 */
1511 0x0000, /* R167 - Generic comparator 4 */
1512 0xA00F, /* R168 - Battery Charger Control 1 */
1513 0x0B06, /* R169 - Battery Charger Control 2 */
1514 0x0000, /* R170 - Battery Charger Control 3 */
1515 0x0000, /* R171 */
1516 0x0000, /* R172 - Current Sink Driver A */
1517 0x0000, /* R173 - CSA Flash control */
1518 0x0000, /* R174 */
1519 0x0000, /* R175 */
1520 0x0000, /* R176 - DCDC/LDO requested */
1521 0x032D, /* R177 - DCDC Active options */
1522 0x0000, /* R178 - DCDC Sleep options */
1523 0x0025, /* R179 - Power-check comparator */
1524 0x000E, /* R180 - DCDC1 Control */
1525 0x0C00, /* R181 - DCDC1 Timeouts */
1526 0x1006, /* R182 - DCDC1 Low Power */
1527 0x0018, /* R183 - DCDC2 Control */
1528 0x0000, /* R184 - DCDC2 Timeouts */
1529 0x0000, /* R185 */
1530 0x0026, /* R186 - DCDC3 Control */
1531 0x0400, /* R187 - DCDC3 Timeouts */
1532 0x0006, /* R188 - DCDC3 Low Power */
1533 0x0062, /* R189 - DCDC4 Control */
1534 0x0800, /* R190 - DCDC4 Timeouts */
1535 0x0006, /* R191 - DCDC4 Low Power */
1536 0x0008, /* R192 */
1537 0x0000, /* R193 */
1538 0x0000, /* R194 */
1539 0x000A, /* R195 */
1540 0x1000, /* R196 */
1541 0x0006, /* R197 */
1542 0x0000, /* R198 */
1543 0x0003, /* R199 - Limit Switch Control */
1544 0x0006, /* R200 - LDO1 Control */
1545 0x0000, /* R201 - LDO1 Timeouts */
1546 0x001C, /* R202 - LDO1 Low Power */
1547 0x0010, /* R203 - LDO2 Control */
1548 0x0C00, /* R204 - LDO2 Timeouts */
1549 0x001C, /* R205 - LDO2 Low Power */
1550 0x001F, /* R206 - LDO3 Control */
1551 0x0800, /* R207 - LDO3 Timeouts */
1552 0x001C, /* R208 - LDO3 Low Power */
1553 0x000A, /* R209 - LDO4 Control */
1554 0x0800, /* R210 - LDO4 Timeouts */
1555 0x001C, /* R211 - LDO4 Low Power */
1556 0x0000, /* R212 */
1557 0x0000, /* R213 */
1558 0x0000, /* R214 */
1559 0x0000, /* R215 - VCC_FAULT Masks */
1560 0x001F, /* R216 - Main Bandgap Control */
1561 0x0000, /* R217 - OSC Control */
1562 0x9000, /* R218 - RTC Tick Control */
1563 0x0000, /* R219 - Security1 */
1564 0x4000, /* R220 */
1565 0x0000, /* R221 */
1566 0x0000, /* R222 */
1567 0x0000, /* R223 */
1568 0x0000, /* R224 - Signal overrides */
1569 0x0000, /* R225 - DCDC/LDO status */
1570 0x0000, /* R226 - Charger Overides/status */
1571 0x0000, /* R227 - misc overrides */
1572 0x0000, /* R228 - Supply overrides/status 1 */
1573 0x0000, /* R229 - Supply overrides/status 2 */
1574 0xE000, /* R230 - GPIO Pin Status */
1575 0x0000, /* R231 - comparotor overrides */
1576 0x0000, /* R232 */
1577 0x0000, /* R233 - State Machine status */
1578 0x1200, /* R234 - FLL Test 1 */
1579 0x0000, /* R235 */
1580 0x8000, /* R236 */
1581 0x0000, /* R237 */
1582 0x0000, /* R238 */
1583 0x0000, /* R239 */
1584 0x0003, /* R240 */
1585 0x0000, /* R241 */
1586 0x0000, /* R242 */
1587 0x0004, /* R243 */
1588 0x0300, /* R244 */
1589 0x0000, /* R245 */
1590 0x0200, /* R246 */
1591 0x1000, /* R247 */
1592 0x1000, /* R248 - DCDC1 Test Controls */
1593 0x1000, /* R249 */
1594 0x1000, /* R250 - DCDC3 Test Controls */
1595 0x1000, /* R251 - DCDC4 Test Controls */
1596};
1597#endif
1598
1599#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_2
1600
1601#undef WM8350_HAVE_CONFIG_MODE
1602#define WM8350_HAVE_CONFIG_MODE
1603
1604const u16 wm8351_mode2_defaults[] = {
1605 0x6143, /* R0 - Reset/ID */
1606 0x0000, /* R1 - ID */
1607 0x0001, /* R2 - Revision */
1608 0x1C02, /* R3 - System Control 1 */
1609 0x0214, /* R4 - System Control 2 */
1610 0x0000, /* R5 - System Hibernate */
1611 0x8A00, /* R6 - Interface Control */
1612 0x0000, /* R7 */
1613 0x8000, /* R8 - Power mgmt (1) */
1614 0x0000, /* R9 - Power mgmt (2) */
1615 0x0000, /* R10 - Power mgmt (3) */
1616 0x2000, /* R11 - Power mgmt (4) */
1617 0x0E00, /* R12 - Power mgmt (5) */
1618 0x0000, /* R13 - Power mgmt (6) */
1619 0x0000, /* R14 - Power mgmt (7) */
1620 0x0000, /* R15 */
1621 0x0000, /* R16 - RTC Seconds/Minutes */
1622 0x0100, /* R17 - RTC Hours/Day */
1623 0x0101, /* R18 - RTC Date/Month */
1624 0x1400, /* R19 - RTC Year */
1625 0x0000, /* R20 - Alarm Seconds/Minutes */
1626 0x0000, /* R21 - Alarm Hours/Day */
1627 0x0000, /* R22 - Alarm Date/Month */
1628 0x0320, /* R23 - RTC Time Control */
1629 0x0000, /* R24 - System Interrupts */
1630 0x0000, /* R25 - Interrupt Status 1 */
1631 0x0000, /* R26 - Interrupt Status 2 */
1632 0x0000, /* R27 */
1633 0x0000, /* R28 - Under Voltage Interrupt status */
1634 0x0000, /* R29 - Over Current Interrupt status */
1635 0x0000, /* R30 - GPIO Interrupt Status */
1636 0x0000, /* R31 - Comparator Interrupt Status */
1637 0x3FFF, /* R32 - System Interrupts Mask */
1638 0x0000, /* R33 - Interrupt Status 1 Mask */
1639 0x0000, /* R34 - Interrupt Status 2 Mask */
1640 0x0000, /* R35 */
1641 0x0000, /* R36 - Under Voltage Interrupt status Mask */
1642 0x0000, /* R37 - Over Current Interrupt status Mask */
1643 0x0000, /* R38 - GPIO Interrupt Status Mask */
1644 0x0000, /* R39 - Comparator Interrupt Status Mask */
1645 0x0040, /* R40 - Clock Control 1 */
1646 0x0000, /* R41 - Clock Control 2 */
1647 0x3A00, /* R42 - FLL Control 1 */
1648 0x7086, /* R43 - FLL Control 2 */
1649 0xC226, /* R44 - FLL Control 3 */
1650 0x0000, /* R45 - FLL Control 4 */
1651 0x0000, /* R46 */
1652 0x0000, /* R47 */
1653 0x0000, /* R48 - DAC Control */
1654 0x0000, /* R49 */
1655 0x00C0, /* R50 - DAC Digital Volume L */
1656 0x00C0, /* R51 - DAC Digital Volume R */
1657 0x0000, /* R52 */
1658 0x0040, /* R53 - DAC LR Rate */
1659 0x0000, /* R54 - DAC Clock Control */
1660 0x0000, /* R55 */
1661 0x0000, /* R56 */
1662 0x0000, /* R57 */
1663 0x4000, /* R58 - DAC Mute */
1664 0x0000, /* R59 - DAC Mute Volume */
1665 0x0000, /* R60 - DAC Side */
1666 0x0000, /* R61 */
1667 0x0000, /* R62 */
1668 0x0000, /* R63 */
1669 0x8000, /* R64 - ADC Control */
1670 0x0000, /* R65 */
1671 0x00C0, /* R66 - ADC Digital Volume L */
1672 0x00C0, /* R67 - ADC Digital Volume R */
1673 0x0000, /* R68 - ADC Divider */
1674 0x0000, /* R69 */
1675 0x0040, /* R70 - ADC LR Rate */
1676 0x0000, /* R71 */
1677 0x0303, /* R72 - Input Control */
1678 0x0000, /* R73 - IN3 Input Control */
1679 0x0000, /* R74 - Mic Bias Control */
1680 0x0000, /* R75 */
1681 0x0000, /* R76 - Output Control */
1682 0x0000, /* R77 - Jack Detect */
1683 0x0000, /* R78 - Anti Pop Control */
1684 0x0000, /* R79 */
1685 0x0040, /* R80 - Left Input Volume */
1686 0x0040, /* R81 - Right Input Volume */
1687 0x0000, /* R82 */
1688 0x0000, /* R83 */
1689 0x0000, /* R84 */
1690 0x0000, /* R85 */
1691 0x0000, /* R86 */
1692 0x0000, /* R87 */
1693 0x0800, /* R88 - Left Mixer Control */
1694 0x1000, /* R89 - Right Mixer Control */
1695 0x0000, /* R90 */
1696 0x0000, /* R91 */
1697 0x0000, /* R92 - OUT3 Mixer Control */
1698 0x0000, /* R93 - OUT4 Mixer Control */
1699 0x0000, /* R94 */
1700 0x0000, /* R95 */
1701 0x0000, /* R96 - Output Left Mixer Volume */
1702 0x0000, /* R97 - Output Right Mixer Volume */
1703 0x0000, /* R98 - Input Mixer Volume L */
1704 0x0000, /* R99 - Input Mixer Volume R */
1705 0x0000, /* R100 - Input Mixer Volume */
1706 0x0000, /* R101 */
1707 0x0000, /* R102 */
1708 0x0000, /* R103 */
1709 0x00E4, /* R104 - OUT1L Volume */
1710 0x00E4, /* R105 - OUT1R Volume */
1711 0x00E4, /* R106 - OUT2L Volume */
1712 0x02E4, /* R107 - OUT2R Volume */
1713 0x0000, /* R108 */
1714 0x0000, /* R109 */
1715 0x0000, /* R110 */
1716 0x0000, /* R111 - BEEP Volume */
1717 0x0A00, /* R112 - AI Formating */
1718 0x0000, /* R113 - ADC DAC COMP */
1719 0x0020, /* R114 - AI ADC Control */
1720 0x0020, /* R115 - AI DAC Control */
1721 0x0000, /* R116 */
1722 0x0000, /* R117 */
1723 0x0000, /* R118 */
1724 0x0000, /* R119 */
1725 0x0000, /* R120 */
1726 0x0000, /* R121 */
1727 0x0000, /* R122 */
1728 0x0000, /* R123 */
1729 0x0000, /* R124 */
1730 0x0000, /* R125 */
1731 0x0000, /* R126 */
1732 0x0000, /* R127 */
1733 0x1FFF, /* R128 - GPIO Debounce */
1734 0x0000, /* R129 - GPIO Pin pull up Control */
1735 0x0110, /* R130 - GPIO Pull down Control */
1736 0x0000, /* R131 - GPIO Interrupt Mode */
1737 0x0000, /* R132 */
1738 0x0000, /* R133 - GPIO Control */
1739 0x09FA, /* R134 - GPIO Configuration (i/o) */
1740 0x0DF6, /* R135 - GPIO Pin Polarity / Type */
1741 0x0000, /* R136 */
1742 0x0000, /* R137 */
1743 0x0000, /* R138 */
1744 0x0000, /* R139 */
1745 0x1310, /* R140 - GPIO Function Select 1 */
1746 0x0003, /* R141 - GPIO Function Select 2 */
1747 0x2000, /* R142 - GPIO Function Select 3 */
1748 0x0000, /* R143 - GPIO Function Select 4 */
1749 0x0000, /* R144 - Digitiser Control (1) */
1750 0x0002, /* R145 - Digitiser Control (2) */
1751 0x0000, /* R146 */
1752 0x0000, /* R147 */
1753 0x0000, /* R148 */
1754 0x0000, /* R149 */
1755 0x0000, /* R150 */
1756 0x0000, /* R151 */
1757 0x7000, /* R152 - AUX1 Readback */
1758 0x7000, /* R153 - AUX2 Readback */
1759 0x7000, /* R154 - AUX3 Readback */
1760 0x7000, /* R155 - AUX4 Readback */
1761 0x0000, /* R156 - USB Voltage Readback */
1762 0x0000, /* R157 - LINE Voltage Readback */
1763 0x0000, /* R158 - BATT Voltage Readback */
1764 0x0000, /* R159 - Chip Temp Readback */
1765 0x0000, /* R160 */
1766 0x0000, /* R161 */
1767 0x0000, /* R162 */
1768 0x0000, /* R163 - Generic Comparator Control */
1769 0x0000, /* R164 - Generic comparator 1 */
1770 0x0000, /* R165 - Generic comparator 2 */
1771 0x0000, /* R166 - Generic comparator 3 */
1772 0x0000, /* R167 - Generic comparator 4 */
1773 0xA00F, /* R168 - Battery Charger Control 1 */
1774 0x0B06, /* R169 - Battery Charger Control 2 */
1775 0x0000, /* R170 - Battery Charger Control 3 */
1776 0x0000, /* R171 */
1777 0x0000, /* R172 - Current Sink Driver A */
1778 0x0000, /* R173 - CSA Flash control */
1779 0x0000, /* R174 */
1780 0x0000, /* R175 */
1781 0x0000, /* R176 - DCDC/LDO requested */
1782 0x032D, /* R177 - DCDC Active options */
1783 0x0000, /* R178 - DCDC Sleep options */
1784 0x0025, /* R179 - Power-check comparator */
1785 0x001A, /* R180 - DCDC1 Control */
1786 0x0800, /* R181 - DCDC1 Timeouts */
1787 0x1006, /* R182 - DCDC1 Low Power */
1788 0x0018, /* R183 - DCDC2 Control */
1789 0x0000, /* R184 - DCDC2 Timeouts */
1790 0x0000, /* R185 */
1791 0x0056, /* R186 - DCDC3 Control */
1792 0x0400, /* R187 - DCDC3 Timeouts */
1793 0x0006, /* R188 - DCDC3 Low Power */
1794 0x0026, /* R189 - DCDC4 Control */
1795 0x0C00, /* R190 - DCDC4 Timeouts */
1796 0x0006, /* R191 - DCDC4 Low Power */
1797 0x0008, /* R192 */
1798 0x0000, /* R193 */
1799 0x0000, /* R194 */
1800 0x0026, /* R195 */
1801 0x0C00, /* R196 */
1802 0x0006, /* R197 */
1803 0x0000, /* R198 */
1804 0x0003, /* R199 - Limit Switch Control */
1805 0x001C, /* R200 - LDO1 Control */
1806 0x0400, /* R201 - LDO1 Timeouts */
1807 0x001C, /* R202 - LDO1 Low Power */
1808 0x0010, /* R203 - LDO2 Control */
1809 0x0C00, /* R204 - LDO2 Timeouts */
1810 0x001C, /* R205 - LDO2 Low Power */
1811 0x0015, /* R206 - LDO3 Control */
1812 0x0000, /* R207 - LDO3 Timeouts */
1813 0x001C, /* R208 - LDO3 Low Power */
1814 0x001A, /* R209 - LDO4 Control */
1815 0x0000, /* R210 - LDO4 Timeouts */
1816 0x001C, /* R211 - LDO4 Low Power */
1817 0x0000, /* R212 */
1818 0x0000, /* R213 */
1819 0x0000, /* R214 */
1820 0x0000, /* R215 - VCC_FAULT Masks */
1821 0x001F, /* R216 - Main Bandgap Control */
1822 0x0000, /* R217 - OSC Control */
1823 0x9000, /* R218 - RTC Tick Control */
1824 0x0000, /* R219 - Security1 */
1825 0x4000, /* R220 */
1826 0x0000, /* R221 */
1827 0x0000, /* R222 */
1828 0x0000, /* R223 */
1829 0x0000, /* R224 - Signal overrides */
1830 0x0000, /* R225 - DCDC/LDO status */
1831 0x0000, /* R226 - Charger Overides/status */
1832 0x0000, /* R227 - misc overrides */
1833 0x0000, /* R228 - Supply overrides/status 1 */
1834 0x0000, /* R229 - Supply overrides/status 2 */
1835 0xE000, /* R230 - GPIO Pin Status */
1836 0x0000, /* R231 - comparotor overrides */
1837 0x0000, /* R232 */
1838 0x0000, /* R233 - State Machine status */
1839 0x1200, /* R234 - FLL Test 1 */
1840 0x0000, /* R235 */
1841 0x8000, /* R236 */
1842 0x0000, /* R237 */
1843 0x0000, /* R238 */
1844 0x0000, /* R239 */
1845 0x0003, /* R240 */
1846 0x0000, /* R241 */
1847 0x0000, /* R242 */
1848 0x0004, /* R243 */
1849 0x0300, /* R244 */
1850 0x0000, /* R245 */
1851 0x0200, /* R246 */
1852 0x0000, /* R247 */
1853 0x1000, /* R248 - DCDC1 Test Controls */
1854 0x1000, /* R249 */
1855 0x1000, /* R250 - DCDC3 Test Controls */
1856 0x1000, /* R251 - DCDC4 Test Controls */
1857};
1858#endif
1859
1860#ifdef CONFIG_MFD_WM8351_CONFIG_MODE_3
1861
1862#undef WM8350_HAVE_CONFIG_MODE
1863#define WM8350_HAVE_CONFIG_MODE
1864
1865const u16 wm8351_mode3_defaults[] = {
1866 0x6143, /* R0 - Reset/ID */
1867 0x0000, /* R1 - ID */
1868 0x0001, /* R2 - Revision */
1869 0x1C02, /* R3 - System Control 1 */
1870 0x0204, /* R4 - System Control 2 */
1871 0x0000, /* R5 - System Hibernate */
1872 0x8A00, /* R6 - Interface Control */
1873 0x0000, /* R7 */
1874 0x8000, /* R8 - Power mgmt (1) */
1875 0x0000, /* R9 - Power mgmt (2) */
1876 0x0000, /* R10 - Power mgmt (3) */
1877 0x2000, /* R11 - Power mgmt (4) */
1878 0x0E00, /* R12 - Power mgmt (5) */
1879 0x0000, /* R13 - Power mgmt (6) */
1880 0x0000, /* R14 - Power mgmt (7) */
1881 0x0000, /* R15 */
1882 0x0000, /* R16 - RTC Seconds/Minutes */
1883 0x0100, /* R17 - RTC Hours/Day */
1884 0x0101, /* R18 - RTC Date/Month */
1885 0x1400, /* R19 - RTC Year */
1886 0x0000, /* R20 - Alarm Seconds/Minutes */
1887 0x0000, /* R21 - Alarm Hours/Day */
1888 0x0000, /* R22 - Alarm Date/Month */
1889 0x0320, /* R23 - RTC Time Control */
1890 0x0000, /* R24 - System Interrupts */
1891 0x0000, /* R25 - Interrupt Status 1 */
1892 0x0000, /* R26 - Interrupt Status 2 */
1893 0x0000, /* R27 */
1894 0x0000, /* R28 - Under Voltage Interrupt status */
1895 0x0000, /* R29 - Over Current Interrupt status */
1896 0x0000, /* R30 - GPIO Interrupt Status */
1897 0x0000, /* R31 - Comparator Interrupt Status */
1898 0x3FFF, /* R32 - System Interrupts Mask */
1899 0x0000, /* R33 - Interrupt Status 1 Mask */
1900 0x0000, /* R34 - Interrupt Status 2 Mask */
1901 0x0000, /* R35 */
1902 0x0000, /* R36 - Under Voltage Interrupt status Mask */
1903 0x0000, /* R37 - Over Current Interrupt status Mask */
1904 0x0000, /* R38 - GPIO Interrupt Status Mask */
1905 0x0000, /* R39 - Comparator Interrupt Status Mask */
1906 0x0040, /* R40 - Clock Control 1 */
1907 0x0000, /* R41 - Clock Control 2 */
1908 0x3A00, /* R42 - FLL Control 1 */
1909 0x7086, /* R43 - FLL Control 2 */
1910 0xC226, /* R44 - FLL Control 3 */
1911 0x0000, /* R45 - FLL Control 4 */
1912 0x0000, /* R46 */
1913 0x0000, /* R47 */
1914 0x0000, /* R48 - DAC Control */
1915 0x0000, /* R49 */
1916 0x00C0, /* R50 - DAC Digital Volume L */
1917 0x00C0, /* R51 - DAC Digital Volume R */
1918 0x0000, /* R52 */
1919 0x0040, /* R53 - DAC LR Rate */
1920 0x0000, /* R54 - DAC Clock Control */
1921 0x0000, /* R55 */
1922 0x0000, /* R56 */
1923 0x0000, /* R57 */
1924 0x4000, /* R58 - DAC Mute */
1925 0x0000, /* R59 - DAC Mute Volume */
1926 0x0000, /* R60 - DAC Side */
1927 0x0000, /* R61 */
1928 0x0000, /* R62 */
1929 0x0000, /* R63 */
1930 0x8000, /* R64 - ADC Control */
1931 0x0000, /* R65 */
1932 0x00C0, /* R66 - ADC Digital Volume L */
1933 0x00C0, /* R67 - ADC Digital Volume R */
1934 0x0000, /* R68 - ADC Divider */
1935 0x0000, /* R69 */
1936 0x0040, /* R70 - ADC LR Rate */
1937 0x0000, /* R71 */
1938 0x0303, /* R72 - Input Control */
1939 0x0000, /* R73 - IN3 Input Control */
1940 0x0000, /* R74 - Mic Bias Control */
1941 0x0000, /* R75 */
1942 0x0000, /* R76 - Output Control */
1943 0x0000, /* R77 - Jack Detect */
1944 0x0000, /* R78 - Anti Pop Control */
1945 0x0000, /* R79 */
1946 0x0040, /* R80 - Left Input Volume */
1947 0x0040, /* R81 - Right Input Volume */
1948 0x0000, /* R82 */
1949 0x0000, /* R83 */
1950 0x0000, /* R84 */
1951 0x0000, /* R85 */
1952 0x0000, /* R86 */
1953 0x0000, /* R87 */
1954 0x0800, /* R88 - Left Mixer Control */
1955 0x1000, /* R89 - Right Mixer Control */
1956 0x0000, /* R90 */
1957 0x0000, /* R91 */
1958 0x0000, /* R92 - OUT3 Mixer Control */
1959 0x0000, /* R93 - OUT4 Mixer Control */
1960 0x0000, /* R94 */
1961 0x0000, /* R95 */
1962 0x0000, /* R96 - Output Left Mixer Volume */
1963 0x0000, /* R97 - Output Right Mixer Volume */
1964 0x0000, /* R98 - Input Mixer Volume L */
1965 0x0000, /* R99 - Input Mixer Volume R */
1966 0x0000, /* R100 - Input Mixer Volume */
1967 0x0000, /* R101 */
1968 0x0000, /* R102 */
1969 0x0000, /* R103 */
1970 0x00E4, /* R104 - OUT1L Volume */
1971 0x00E4, /* R105 - OUT1R Volume */
1972 0x00E4, /* R106 - OUT2L Volume */
1973 0x02E4, /* R107 - OUT2R Volume */
1974 0x0000, /* R108 */
1975 0x0000, /* R109 */
1976 0x0000, /* R110 */
1977 0x0000, /* R111 - BEEP Volume */
1978 0x0A00, /* R112 - AI Formating */
1979 0x0000, /* R113 - ADC DAC COMP */
1980 0x0020, /* R114 - AI ADC Control */
1981 0x0020, /* R115 - AI DAC Control */
1982 0x0000, /* R116 */
1983 0x0000, /* R117 */
1984 0x0000, /* R118 */
1985 0x0000, /* R119 */
1986 0x0000, /* R120 */
1987 0x0000, /* R121 */
1988 0x0000, /* R122 */
1989 0x0000, /* R123 */
1990 0x0000, /* R124 */
1991 0x0000, /* R125 */
1992 0x0000, /* R126 */
1993 0x0000, /* R127 */
1994 0x1FFF, /* R128 - GPIO Debounce */
1995 0x0010, /* R129 - GPIO Pin pull up Control */
1996 0x0000, /* R130 - GPIO Pull down Control */
1997 0x0000, /* R131 - GPIO Interrupt Mode */
1998 0x0000, /* R132 */
1999 0x0000, /* R133 - GPIO Control */
2000 0x0BFB, /* R134 - GPIO Configuration (i/o) */
2001 0x0FFD, /* R135 - GPIO Pin Polarity / Type */
2002 0x0000, /* R136 */
2003 0x0000, /* R137 */
2004 0x0000, /* R138 */
2005 0x0000, /* R139 */
2006 0x0310, /* R140 - GPIO Function Select 1 */
2007 0x0001, /* R141 - GPIO Function Select 2 */
2008 0x2300, /* R142 - GPIO Function Select 3 */
2009 0x0003, /* R143 - GPIO Function Select 4 */
2010 0x0000, /* R144 - Digitiser Control (1) */
2011 0x0002, /* R145 - Digitiser Control (2) */
2012 0x0000, /* R146 */
2013 0x0000, /* R147 */
2014 0x0000, /* R148 */
2015 0x0000, /* R149 */
2016 0x0000, /* R150 */
2017 0x0000, /* R151 */
2018 0x7000, /* R152 - AUX1 Readback */
2019 0x7000, /* R153 - AUX2 Readback */
2020 0x7000, /* R154 - AUX3 Readback */
2021 0x7000, /* R155 - AUX4 Readback */
2022 0x0000, /* R156 - USB Voltage Readback */
2023 0x0000, /* R157 - LINE Voltage Readback */
2024 0x0000, /* R158 - BATT Voltage Readback */
2025 0x0000, /* R159 - Chip Temp Readback */
2026 0x0000, /* R160 */
2027 0x0000, /* R161 */
2028 0x0000, /* R162 */
2029 0x0000, /* R163 - Generic Comparator Control */
2030 0x0000, /* R164 - Generic comparator 1 */
2031 0x0000, /* R165 - Generic comparator 2 */
2032 0x0000, /* R166 - Generic comparator 3 */
2033 0x0000, /* R167 - Generic comparator 4 */
2034 0xA00F, /* R168 - Battery Charger Control 1 */
2035 0x0B06, /* R169 - Battery Charger Control 2 */
2036 0x0000, /* R170 - Battery Charger Control 3 */
2037 0x0000, /* R171 */
2038 0x0000, /* R172 - Current Sink Driver A */
2039 0x0000, /* R173 - CSA Flash control */
2040 0x0000, /* R174 */
2041 0x0000, /* R175 */
2042 0x0000, /* R176 - DCDC/LDO requested */
2043 0x032D, /* R177 - DCDC Active options */
2044 0x0000, /* R178 - DCDC Sleep options */
2045 0x0025, /* R179 - Power-check comparator */
2046 0x000E, /* R180 - DCDC1 Control */
2047 0x0400, /* R181 - DCDC1 Timeouts */
2048 0x1006, /* R182 - DCDC1 Low Power */
2049 0x0018, /* R183 - DCDC2 Control */
2050 0x0000, /* R184 - DCDC2 Timeouts */
2051 0x0000, /* R185 */
2052 0x0026, /* R186 - DCDC3 Control */
2053 0x0800, /* R187 - DCDC3 Timeouts */
2054 0x0006, /* R188 - DCDC3 Low Power */
2055 0x0062, /* R189 - DCDC4 Control */
2056 0x1400, /* R190 - DCDC4 Timeouts */
2057 0x0006, /* R191 - DCDC4 Low Power */
2058 0x0008, /* R192 */
2059 0x0000, /* R193 */
2060 0x0000, /* R194 */
2061 0x0026, /* R195 */
2062 0x0400, /* R196 */
2063 0x0006, /* R197 */
2064 0x0000, /* R198 */
2065 0x0003, /* R199 - Limit Switch Control */
2066 0x0006, /* R200 - LDO1 Control */
2067 0x0C00, /* R201 - LDO1 Timeouts */
2068 0x001C, /* R202 - LDO1 Low Power */
2069 0x0016, /* R203 - LDO2 Control */
2070 0x0000, /* R204 - LDO2 Timeouts */
2071 0x001C, /* R205 - LDO2 Low Power */
2072 0x0019, /* R206 - LDO3 Control */
2073 0x0000, /* R207 - LDO3 Timeouts */
2074 0x001C, /* R208 - LDO3 Low Power */
2075 0x001A, /* R209 - LDO4 Control */
2076 0x1000, /* R210 - LDO4 Timeouts */
2077 0x001C, /* R211 - LDO4 Low Power */
2078 0x0000, /* R212 */
2079 0x0000, /* R213 */
2080 0x0000, /* R214 */
2081 0x0000, /* R215 - VCC_FAULT Masks */
2082 0x001F, /* R216 - Main Bandgap Control */
2083 0x0000, /* R217 - OSC Control */
2084 0x9000, /* R218 - RTC Tick Control */
2085 0x0000, /* R219 - Security1 */
2086 0x4000, /* R220 */
2087 0x0000, /* R221 */
2088 0x0000, /* R222 */
2089 0x0000, /* R223 */
2090 0x0000, /* R224 - Signal overrides */
2091 0x0000, /* R225 - DCDC/LDO status */
2092 0x0000, /* R226 - Charger Overides/status */
2093 0x0000, /* R227 - misc overrides */
2094 0x0000, /* R228 - Supply overrides/status 1 */
2095 0x0000, /* R229 - Supply overrides/status 2 */
2096 0xE000, /* R230 - GPIO Pin Status */
2097 0x0000, /* R231 - comparotor overrides */
2098 0x0000, /* R232 */
2099 0x0000, /* R233 - State Machine status */
2100 0x1200, /* R234 - FLL Test 1 */
2101 0x0000, /* R235 */
2102 0x8000, /* R236 */
2103 0x0000, /* R237 */
2104 0x0000, /* R238 */
2105 0x0000, /* R239 */
2106 0x0003, /* R240 */
2107 0x0000, /* R241 */
2108 0x0000, /* R242 */
2109 0x0004, /* R243 */
2110 0x0300, /* R244 */
2111 0x0000, /* R245 */
2112 0x0200, /* R246 */
2113 0x0000, /* R247 */
2114 0x1000, /* R248 - DCDC1 Test Controls */
2115 0x1000, /* R249 */
2116 0x1000, /* R250 - DCDC3 Test Controls */
2117 0x1000, /* R251 - DCDC4 Test Controls */
2118};
2119#endif
2120
2121#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_0
2122
2123#undef WM8350_HAVE_CONFIG_MODE
2124#define WM8350_HAVE_CONFIG_MODE
2125
2126const u16 wm8352_mode0_defaults[] = {
2127 0x6143, /* R0 - Reset/ID */
2128 0x0000, /* R1 - ID */
2129 0x0002, /* R2 - Revision */
2130 0x1C02, /* R3 - System Control 1 */
2131 0x0004, /* R4 - System Control 2 */
2132 0x0000, /* R5 - System Hibernate */
2133 0x8A00, /* R6 - Interface Control */
2134 0x0000, /* R7 */
2135 0x8000, /* R8 - Power mgmt (1) */
2136 0x0000, /* R9 - Power mgmt (2) */
2137 0x0000, /* R10 - Power mgmt (3) */
2138 0x2000, /* R11 - Power mgmt (4) */
2139 0x0E00, /* R12 - Power mgmt (5) */
2140 0x0000, /* R13 - Power mgmt (6) */
2141 0x0000, /* R14 - Power mgmt (7) */
2142 0x0000, /* R15 */
2143 0x0000, /* R16 - RTC Seconds/Minutes */
2144 0x0100, /* R17 - RTC Hours/Day */
2145 0x0101, /* R18 - RTC Date/Month */
2146 0x1400, /* R19 - RTC Year */
2147 0x0000, /* R20 - Alarm Seconds/Minutes */
2148 0x0000, /* R21 - Alarm Hours/Day */
2149 0x0000, /* R22 - Alarm Date/Month */
2150 0x0320, /* R23 - RTC Time Control */
2151 0x0000, /* R24 - System Interrupts */
2152 0x0000, /* R25 - Interrupt Status 1 */
2153 0x0000, /* R26 - Interrupt Status 2 */
2154 0x0000, /* R27 */
2155 0x0000, /* R28 - Under Voltage Interrupt status */
2156 0x0000, /* R29 - Over Current Interrupt status */
2157 0x0000, /* R30 - GPIO Interrupt Status */
2158 0x0000, /* R31 - Comparator Interrupt Status */
2159 0x3FFF, /* R32 - System Interrupts Mask */
2160 0x0000, /* R33 - Interrupt Status 1 Mask */
2161 0x0000, /* R34 - Interrupt Status 2 Mask */
2162 0x0000, /* R35 */
2163 0x0000, /* R36 - Under Voltage Interrupt status Mask */
2164 0x0000, /* R37 - Over Current Interrupt status Mask */
2165 0x0000, /* R38 - GPIO Interrupt Status Mask */
2166 0x0000, /* R39 - Comparator Interrupt Status Mask */
2167 0x0040, /* R40 - Clock Control 1 */
2168 0x0000, /* R41 - Clock Control 2 */
2169 0x3A00, /* R42 - FLL Control 1 */
2170 0x7086, /* R43 - FLL Control 2 */
2171 0xC226, /* R44 - FLL Control 3 */
2172 0x0000, /* R45 - FLL Control 4 */
2173 0x0000, /* R46 */
2174 0x0000, /* R47 */
2175 0x0000, /* R48 - DAC Control */
2176 0x0000, /* R49 */
2177 0x00C0, /* R50 - DAC Digital Volume L */
2178 0x00C0, /* R51 - DAC Digital Volume R */
2179 0x0000, /* R52 */
2180 0x0040, /* R53 - DAC LR Rate */
2181 0x0000, /* R54 - DAC Clock Control */
2182 0x0000, /* R55 */
2183 0x0000, /* R56 */
2184 0x0000, /* R57 */
2185 0x4000, /* R58 - DAC Mute */
2186 0x0000, /* R59 - DAC Mute Volume */
2187 0x0000, /* R60 - DAC Side */
2188 0x0000, /* R61 */
2189 0x0000, /* R62 */
2190 0x0000, /* R63 */
2191 0x8000, /* R64 - ADC Control */
2192 0x0000, /* R65 */
2193 0x00C0, /* R66 - ADC Digital Volume L */
2194 0x00C0, /* R67 - ADC Digital Volume R */
2195 0x0000, /* R68 - ADC Divider */
2196 0x0000, /* R69 */
2197 0x0040, /* R70 - ADC LR Rate */
2198 0x0000, /* R71 */
2199 0x0303, /* R72 - Input Control */
2200 0x0000, /* R73 - IN3 Input Control */
2201 0x0000, /* R74 - Mic Bias Control */
2202 0x0000, /* R75 */
2203 0x0000, /* R76 - Output Control */
2204 0x0000, /* R77 - Jack Detect */
2205 0x0000, /* R78 - Anti Pop Control */
2206 0x0000, /* R79 */
2207 0x0040, /* R80 - Left Input Volume */
2208 0x0040, /* R81 - Right Input Volume */
2209 0x0000, /* R82 */
2210 0x0000, /* R83 */
2211 0x0000, /* R84 */
2212 0x0000, /* R85 */
2213 0x0000, /* R86 */
2214 0x0000, /* R87 */
2215 0x0800, /* R88 - Left Mixer Control */
2216 0x1000, /* R89 - Right Mixer Control */
2217 0x0000, /* R90 */
2218 0x0000, /* R91 */
2219 0x0000, /* R92 - OUT3 Mixer Control */
2220 0x0000, /* R93 - OUT4 Mixer Control */
2221 0x0000, /* R94 */
2222 0x0000, /* R95 */
2223 0x0000, /* R96 - Output Left Mixer Volume */
2224 0x0000, /* R97 - Output Right Mixer Volume */
2225 0x0000, /* R98 - Input Mixer Volume L */
2226 0x0000, /* R99 - Input Mixer Volume R */
2227 0x0000, /* R100 - Input Mixer Volume */
2228 0x0000, /* R101 */
2229 0x0000, /* R102 */
2230 0x0000, /* R103 */
2231 0x00E4, /* R104 - OUT1L Volume */
2232 0x00E4, /* R105 - OUT1R Volume */
2233 0x00E4, /* R106 - OUT2L Volume */
2234 0x02E4, /* R107 - OUT2R Volume */
2235 0x0000, /* R108 */
2236 0x0000, /* R109 */
2237 0x0000, /* R110 */
2238 0x0000, /* R111 - BEEP Volume */
2239 0x0A00, /* R112 - AI Formating */
2240 0x0000, /* R113 - ADC DAC COMP */
2241 0x0020, /* R114 - AI ADC Control */
2242 0x0020, /* R115 - AI DAC Control */
2243 0x0000, /* R116 */
2244 0x0000, /* R117 */
2245 0x0000, /* R118 */
2246 0x0000, /* R119 */
2247 0x0000, /* R120 */
2248 0x0000, /* R121 */
2249 0x0000, /* R122 */
2250 0x0000, /* R123 */
2251 0x0000, /* R124 */
2252 0x0000, /* R125 */
2253 0x0000, /* R126 */
2254 0x0000, /* R127 */
2255 0x1FFF, /* R128 - GPIO Debounce */
2256 0x0000, /* R129 - GPIO Pin pull up Control */
2257 0x0000, /* R130 - GPIO Pull down Control */
2258 0x0000, /* R131 - GPIO Interrupt Mode */
2259 0x0000, /* R132 */
2260 0x0000, /* R133 - GPIO Control */
2261 0x0FFC, /* R134 - GPIO Configuration (i/o) */
2262 0x0FFC, /* R135 - GPIO Pin Polarity / Type */
2263 0x0000, /* R136 */
2264 0x0000, /* R137 */
2265 0x0000, /* R138 */
2266 0x0000, /* R139 */
2267 0x0013, /* R140 - GPIO Function Select 1 */
2268 0x0000, /* R141 - GPIO Function Select 2 */
2269 0x0000, /* R142 - GPIO Function Select 3 */
2270 0x0003, /* R143 - GPIO Function Select 4 */
2271 0x0000, /* R144 - Digitiser Control (1) */
2272 0x0002, /* R145 - Digitiser Control (2) */
2273 0x0000, /* R146 */
2274 0x0000, /* R147 */
2275 0x0000, /* R148 */
2276 0x0000, /* R149 */
2277 0x0000, /* R150 */
2278 0x0000, /* R151 */
2279 0x7000, /* R152 - AUX1 Readback */
2280 0x7000, /* R153 - AUX2 Readback */
2281 0x7000, /* R154 - AUX3 Readback */
2282 0x7000, /* R155 - AUX4 Readback */
2283 0x0000, /* R156 - USB Voltage Readback */
2284 0x0000, /* R157 - LINE Voltage Readback */
2285 0x0000, /* R158 - BATT Voltage Readback */
2286 0x0000, /* R159 - Chip Temp Readback */
2287 0x0000, /* R160 */
2288 0x0000, /* R161 */
2289 0x0000, /* R162 */
2290 0x0000, /* R163 - Generic Comparator Control */
2291 0x0000, /* R164 - Generic comparator 1 */
2292 0x0000, /* R165 - Generic comparator 2 */
2293 0x0000, /* R166 - Generic comparator 3 */
2294 0x0000, /* R167 - Generic comparator 4 */
2295 0xA00F, /* R168 - Battery Charger Control 1 */
2296 0x0B06, /* R169 - Battery Charger Control 2 */
2297 0x0000, /* R170 - Battery Charger Control 3 */
2298 0x0000, /* R171 */
2299 0x0000, /* R172 - Current Sink Driver A */
2300 0x0000, /* R173 - CSA Flash control */
2301 0x0000, /* R174 - Current Sink Driver B */
2302 0x0000, /* R175 - CSB Flash control */
2303 0x0000, /* R176 - DCDC/LDO requested */
2304 0x032D, /* R177 - DCDC Active options */
2305 0x0000, /* R178 - DCDC Sleep options */
2306 0x0025, /* R179 - Power-check comparator */
2307 0x000E, /* R180 - DCDC1 Control */
2308 0x0000, /* R181 - DCDC1 Timeouts */
2309 0x1006, /* R182 - DCDC1 Low Power */
2310 0x0018, /* R183 - DCDC2 Control */
2311 0x0000, /* R184 - DCDC2 Timeouts */
2312 0x0000, /* R185 */
2313 0x0000, /* R186 - DCDC3 Control */
2314 0x0000, /* R187 - DCDC3 Timeouts */
2315 0x0006, /* R188 - DCDC3 Low Power */
2316 0x0000, /* R189 - DCDC4 Control */
2317 0x0000, /* R190 - DCDC4 Timeouts */
2318 0x0006, /* R191 - DCDC4 Low Power */
2319 0x0008, /* R192 - DCDC5 Control */
2320 0x0000, /* R193 - DCDC5 Timeouts */
2321 0x0000, /* R194 */
2322 0x0000, /* R195 - DCDC6 Control */
2323 0x0000, /* R196 - DCDC6 Timeouts */
2324 0x0006, /* R197 - DCDC6 Low Power */
2325 0x0000, /* R198 */
2326 0x0003, /* R199 - Limit Switch Control */
2327 0x001C, /* R200 - LDO1 Control */
2328 0x0000, /* R201 - LDO1 Timeouts */
2329 0x001C, /* R202 - LDO1 Low Power */
2330 0x001B, /* R203 - LDO2 Control */
2331 0x0000, /* R204 - LDO2 Timeouts */
2332 0x001C, /* R205 - LDO2 Low Power */
2333 0x001B, /* R206 - LDO3 Control */
2334 0x0000, /* R207 - LDO3 Timeouts */
2335 0x001C, /* R208 - LDO3 Low Power */
2336 0x001B, /* R209 - LDO4 Control */
2337 0x0000, /* R210 - LDO4 Timeouts */
2338 0x001C, /* R211 - LDO4 Low Power */
2339 0x0000, /* R212 */
2340 0x0000, /* R213 */
2341 0x0000, /* R214 */
2342 0x0000, /* R215 - VCC_FAULT Masks */
2343 0x001F, /* R216 - Main Bandgap Control */
2344 0x0000, /* R217 - OSC Control */
2345 0x9000, /* R218 - RTC Tick Control */
2346 0x0000, /* R219 - Security1 */
2347 0x4000, /* R220 */
2348 0x0000, /* R221 */
2349 0x0000, /* R222 */
2350 0x0000, /* R223 */
2351 0x0000, /* R224 - Signal overrides */
2352 0x0000, /* R225 - DCDC/LDO status */
2353 0x0000, /* R226 - Charger Overides/status */
2354 0x0000, /* R227 - misc overrides */
2355 0x0000, /* R228 - Supply overrides/status 1 */
2356 0x0000, /* R229 - Supply overrides/status 2 */
2357 0xE000, /* R230 - GPIO Pin Status */
2358 0x0000, /* R231 - comparotor overrides */
2359 0x0000, /* R232 */
2360 0x0000, /* R233 - State Machine status */
2361 0x1200, /* R234 */
2362 0x0000, /* R235 */
2363 0x8000, /* R236 */
2364 0x0000, /* R237 */
2365 0x0000, /* R238 */
2366 0x0000, /* R239 */
2367 0x0003, /* R240 */
2368 0x0000, /* R241 */
2369 0x0000, /* R242 */
2370 0x0004, /* R243 */
2371 0x0300, /* R244 */
2372 0x0000, /* R245 */
2373 0x0200, /* R246 */
2374 0x0000, /* R247 */
2375 0x1000, /* R248 - DCDC1 Test Controls */
2376 0x5000, /* R249 */
2377 0x1000, /* R250 - DCDC3 Test Controls */
2378 0x1000, /* R251 - DCDC4 Test Controls */
2379 0x5100, /* R252 */
2380 0x1000, /* R253 - DCDC6 Test Controls */
2381};
2382#endif
2383
2384#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_1
2385
2386#undef WM8350_HAVE_CONFIG_MODE
2387#define WM8350_HAVE_CONFIG_MODE
2388
2389const u16 wm8352_mode1_defaults[] = {
2390 0x6143, /* R0 - Reset/ID */
2391 0x0000, /* R1 - ID */
2392 0x0002, /* R2 - Revision */
2393 0x1C02, /* R3 - System Control 1 */
2394 0x0204, /* R4 - System Control 2 */
2395 0x0000, /* R5 - System Hibernate */
2396 0x8A00, /* R6 - Interface Control */
2397 0x0000, /* R7 */
2398 0x8000, /* R8 - Power mgmt (1) */
2399 0x0000, /* R9 - Power mgmt (2) */
2400 0x0000, /* R10 - Power mgmt (3) */
2401 0x2000, /* R11 - Power mgmt (4) */
2402 0x0E00, /* R12 - Power mgmt (5) */
2403 0x0000, /* R13 - Power mgmt (6) */
2404 0x0000, /* R14 - Power mgmt (7) */
2405 0x0000, /* R15 */
2406 0x0000, /* R16 - RTC Seconds/Minutes */
2407 0x0100, /* R17 - RTC Hours/Day */
2408 0x0101, /* R18 - RTC Date/Month */
2409 0x1400, /* R19 - RTC Year */
2410 0x0000, /* R20 - Alarm Seconds/Minutes */
2411 0x0000, /* R21 - Alarm Hours/Day */
2412 0x0000, /* R22 - Alarm Date/Month */
2413 0x0320, /* R23 - RTC Time Control */
2414 0x0000, /* R24 - System Interrupts */
2415 0x0000, /* R25 - Interrupt Status 1 */
2416 0x0000, /* R26 - Interrupt Status 2 */
2417 0x0000, /* R27 */
2418 0x0000, /* R28 - Under Voltage Interrupt status */
2419 0x0000, /* R29 - Over Current Interrupt status */
2420 0x0000, /* R30 - GPIO Interrupt Status */
2421 0x0000, /* R31 - Comparator Interrupt Status */
2422 0x3FFF, /* R32 - System Interrupts Mask */
2423 0x0000, /* R33 - Interrupt Status 1 Mask */
2424 0x0000, /* R34 - Interrupt Status 2 Mask */
2425 0x0000, /* R35 */
2426 0x0000, /* R36 - Under Voltage Interrupt status Mask */
2427 0x0000, /* R37 - Over Current Interrupt status Mask */
2428 0x0000, /* R38 - GPIO Interrupt Status Mask */
2429 0x0000, /* R39 - Comparator Interrupt Status Mask */
2430 0x0040, /* R40 - Clock Control 1 */
2431 0x0000, /* R41 - Clock Control 2 */
2432 0x3A00, /* R42 - FLL Control 1 */
2433 0x7086, /* R43 - FLL Control 2 */
2434 0xC226, /* R44 - FLL Control 3 */
2435 0x0000, /* R45 - FLL Control 4 */
2436 0x0000, /* R46 */
2437 0x0000, /* R47 */
2438 0x0000, /* R48 - DAC Control */
2439 0x0000, /* R49 */
2440 0x00C0, /* R50 - DAC Digital Volume L */
2441 0x00C0, /* R51 - DAC Digital Volume R */
2442 0x0000, /* R52 */
2443 0x0040, /* R53 - DAC LR Rate */
2444 0x0000, /* R54 - DAC Clock Control */
2445 0x0000, /* R55 */
2446 0x0000, /* R56 */
2447 0x0000, /* R57 */
2448 0x4000, /* R58 - DAC Mute */
2449 0x0000, /* R59 - DAC Mute Volume */
2450 0x0000, /* R60 - DAC Side */
2451 0x0000, /* R61 */
2452 0x0000, /* R62 */
2453 0x0000, /* R63 */
2454 0x8000, /* R64 - ADC Control */
2455 0x0000, /* R65 */
2456 0x00C0, /* R66 - ADC Digital Volume L */
2457 0x00C0, /* R67 - ADC Digital Volume R */
2458 0x0000, /* R68 - ADC Divider */
2459 0x0000, /* R69 */
2460 0x0040, /* R70 - ADC LR Rate */
2461 0x0000, /* R71 */
2462 0x0303, /* R72 - Input Control */
2463 0x0000, /* R73 - IN3 Input Control */
2464 0x0000, /* R74 - Mic Bias Control */
2465 0x0000, /* R75 */
2466 0x0000, /* R76 - Output Control */
2467 0x0000, /* R77 - Jack Detect */
2468 0x0000, /* R78 - Anti Pop Control */
2469 0x0000, /* R79 */
2470 0x0040, /* R80 - Left Input Volume */
2471 0x0040, /* R81 - Right Input Volume */
2472 0x0000, /* R82 */
2473 0x0000, /* R83 */
2474 0x0000, /* R84 */
2475 0x0000, /* R85 */
2476 0x0000, /* R86 */
2477 0x0000, /* R87 */
2478 0x0800, /* R88 - Left Mixer Control */
2479 0x1000, /* R89 - Right Mixer Control */
2480 0x0000, /* R90 */
2481 0x0000, /* R91 */
2482 0x0000, /* R92 - OUT3 Mixer Control */
2483 0x0000, /* R93 - OUT4 Mixer Control */
2484 0x0000, /* R94 */
2485 0x0000, /* R95 */
2486 0x0000, /* R96 - Output Left Mixer Volume */
2487 0x0000, /* R97 - Output Right Mixer Volume */
2488 0x0000, /* R98 - Input Mixer Volume L */
2489 0x0000, /* R99 - Input Mixer Volume R */
2490 0x0000, /* R100 - Input Mixer Volume */
2491 0x0000, /* R101 */
2492 0x0000, /* R102 */
2493 0x0000, /* R103 */
2494 0x00E4, /* R104 - OUT1L Volume */
2495 0x00E4, /* R105 - OUT1R Volume */
2496 0x00E4, /* R106 - OUT2L Volume */
2497 0x02E4, /* R107 - OUT2R Volume */
2498 0x0000, /* R108 */
2499 0x0000, /* R109 */
2500 0x0000, /* R110 */
2501 0x0000, /* R111 - BEEP Volume */
2502 0x0A00, /* R112 - AI Formating */
2503 0x0000, /* R113 - ADC DAC COMP */
2504 0x0020, /* R114 - AI ADC Control */
2505 0x0020, /* R115 - AI DAC Control */
2506 0x0000, /* R116 */
2507 0x0000, /* R117 */
2508 0x0000, /* R118 */
2509 0x0000, /* R119 */
2510 0x0000, /* R120 */
2511 0x0000, /* R121 */
2512 0x0000, /* R122 */
2513 0x0000, /* R123 */
2514 0x0000, /* R124 */
2515 0x0000, /* R125 */
2516 0x0000, /* R126 */
2517 0x0000, /* R127 */
2518 0x1FFF, /* R128 - GPIO Debounce */
2519 0x0000, /* R129 - GPIO Pin pull up Control */
2520 0x0000, /* R130 - GPIO Pull down Control */
2521 0x0000, /* R131 - GPIO Interrupt Mode */
2522 0x0000, /* R132 */
2523 0x0000, /* R133 - GPIO Control */
2524 0x0BFB, /* R134 - GPIO Configuration (i/o) */
2525 0x0FFF, /* R135 - GPIO Pin Polarity / Type */
2526 0x0000, /* R136 */
2527 0x0000, /* R137 */
2528 0x0000, /* R138 */
2529 0x0000, /* R139 */
2530 0x0300, /* R140 - GPIO Function Select 1 */
2531 0x0000, /* R141 - GPIO Function Select 2 */
2532 0x2300, /* R142 - GPIO Function Select 3 */
2533 0x0003, /* R143 - GPIO Function Select 4 */
2534 0x0000, /* R144 - Digitiser Control (1) */
2535 0x0002, /* R145 - Digitiser Control (2) */
2536 0x0000, /* R146 */
2537 0x0000, /* R147 */
2538 0x0000, /* R148 */
2539 0x0000, /* R149 */
2540 0x0000, /* R150 */
2541 0x0000, /* R151 */
2542 0x7000, /* R152 - AUX1 Readback */
2543 0x7000, /* R153 - AUX2 Readback */
2544 0x7000, /* R154 - AUX3 Readback */
2545 0x7000, /* R155 - AUX4 Readback */
2546 0x0000, /* R156 - USB Voltage Readback */
2547 0x0000, /* R157 - LINE Voltage Readback */
2548 0x0000, /* R158 - BATT Voltage Readback */
2549 0x0000, /* R159 - Chip Temp Readback */
2550 0x0000, /* R160 */
2551 0x0000, /* R161 */
2552 0x0000, /* R162 */
2553 0x0000, /* R163 - Generic Comparator Control */
2554 0x0000, /* R164 - Generic comparator 1 */
2555 0x0000, /* R165 - Generic comparator 2 */
2556 0x0000, /* R166 - Generic comparator 3 */
2557 0x0000, /* R167 - Generic comparator 4 */
2558 0xA00F, /* R168 - Battery Charger Control 1 */
2559 0x0B06, /* R169 - Battery Charger Control 2 */
2560 0x0000, /* R170 - Battery Charger Control 3 */
2561 0x0000, /* R171 */
2562 0x0000, /* R172 - Current Sink Driver A */
2563 0x0000, /* R173 - CSA Flash control */
2564 0x0000, /* R174 - Current Sink Driver B */
2565 0x0000, /* R175 - CSB Flash control */
2566 0x0000, /* R176 - DCDC/LDO requested */
2567 0x032D, /* R177 - DCDC Active options */
2568 0x0000, /* R178 - DCDC Sleep options */
2569 0x0025, /* R179 - Power-check comparator */
2570 0x0062, /* R180 - DCDC1 Control */
2571 0x0400, /* R181 - DCDC1 Timeouts */
2572 0x1006, /* R182 - DCDC1 Low Power */
2573 0x0018, /* R183 - DCDC2 Control */
2574 0x0000, /* R184 - DCDC2 Timeouts */
2575 0x0000, /* R185 */
2576 0x0006, /* R186 - DCDC3 Control */
2577 0x0800, /* R187 - DCDC3 Timeouts */
2578 0x0006, /* R188 - DCDC3 Low Power */
2579 0x0006, /* R189 - DCDC4 Control */
2580 0x0C00, /* R190 - DCDC4 Timeouts */
2581 0x0006, /* R191 - DCDC4 Low Power */
2582 0x0008, /* R192 - DCDC5 Control */
2583 0x0000, /* R193 - DCDC5 Timeouts */
2584 0x0000, /* R194 */
2585 0x0026, /* R195 - DCDC6 Control */
2586 0x1000, /* R196 - DCDC6 Timeouts */
2587 0x0006, /* R197 - DCDC6 Low Power */
2588 0x0000, /* R198 */
2589 0x0003, /* R199 - Limit Switch Control */
2590 0x0002, /* R200 - LDO1 Control */
2591 0x0000, /* R201 - LDO1 Timeouts */
2592 0x001C, /* R202 - LDO1 Low Power */
2593 0x001A, /* R203 - LDO2 Control */
2594 0x0000, /* R204 - LDO2 Timeouts */
2595 0x001C, /* R205 - LDO2 Low Power */
2596 0x001F, /* R206 - LDO3 Control */
2597 0x0000, /* R207 - LDO3 Timeouts */
2598 0x001C, /* R208 - LDO3 Low Power */
2599 0x001F, /* R209 - LDO4 Control */
2600 0x0000, /* R210 - LDO4 Timeouts */
2601 0x001C, /* R211 - LDO4 Low Power */
2602 0x0000, /* R212 */
2603 0x0000, /* R213 */
2604 0x0000, /* R214 */
2605 0x0000, /* R215 - VCC_FAULT Masks */
2606 0x001F, /* R216 - Main Bandgap Control */
2607 0x0000, /* R217 - OSC Control */
2608 0x9000, /* R218 - RTC Tick Control */
2609 0x0000, /* R219 - Security1 */
2610 0x4000, /* R220 */
2611 0x0000, /* R221 */
2612 0x0000, /* R222 */
2613 0x0000, /* R223 */
2614 0x0000, /* R224 - Signal overrides */
2615 0x0000, /* R225 - DCDC/LDO status */
2616 0x0000, /* R226 - Charger Overides/status */
2617 0x0000, /* R227 - misc overrides */
2618 0x0000, /* R228 - Supply overrides/status 1 */
2619 0x0000, /* R229 - Supply overrides/status 2 */
2620 0xE000, /* R230 - GPIO Pin Status */
2621 0x0000, /* R231 - comparotor overrides */
2622 0x0000, /* R232 */
2623 0x0000, /* R233 - State Machine status */
2624 0x1200, /* R234 */
2625 0x0000, /* R235 */
2626 0x8000, /* R236 */
2627 0x0000, /* R237 */
2628 0x0000, /* R238 */
2629 0x0000, /* R239 */
2630 0x0003, /* R240 */
2631 0x0000, /* R241 */
2632 0x0000, /* R242 */
2633 0x0004, /* R243 */
2634 0x0300, /* R244 */
2635 0x0000, /* R245 */
2636 0x0200, /* R246 */
2637 0x0000, /* R247 */
2638 0x1000, /* R248 - DCDC1 Test Controls */
2639 0x5000, /* R249 */
2640 0x1000, /* R250 - DCDC3 Test Controls */
2641 0x1000, /* R251 - DCDC4 Test Controls */
2642 0x5100, /* R252 */
2643 0x1000, /* R253 - DCDC6 Test Controls */
2644};
2645#endif
2646
2647#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_2
2648
2649#undef WM8350_HAVE_CONFIG_MODE
2650#define WM8350_HAVE_CONFIG_MODE
2651
2652const u16 wm8352_mode2_defaults[] = {
2653 0x6143, /* R0 - Reset/ID */
2654 0x0000, /* R1 - ID */
2655 0x0002, /* R2 - Revision */
2656 0x1C02, /* R3 - System Control 1 */
2657 0x0204, /* R4 - System Control 2 */
2658 0x0000, /* R5 - System Hibernate */
2659 0x8A00, /* R6 - Interface Control */
2660 0x0000, /* R7 */
2661 0x8000, /* R8 - Power mgmt (1) */
2662 0x0000, /* R9 - Power mgmt (2) */
2663 0x0000, /* R10 - Power mgmt (3) */
2664 0x2000, /* R11 - Power mgmt (4) */
2665 0x0E00, /* R12 - Power mgmt (5) */
2666 0x0000, /* R13 - Power mgmt (6) */
2667 0x0000, /* R14 - Power mgmt (7) */
2668 0x0000, /* R15 */
2669 0x0000, /* R16 - RTC Seconds/Minutes */
2670 0x0100, /* R17 - RTC Hours/Day */
2671 0x0101, /* R18 - RTC Date/Month */
2672 0x1400, /* R19 - RTC Year */
2673 0x0000, /* R20 - Alarm Seconds/Minutes */
2674 0x0000, /* R21 - Alarm Hours/Day */
2675 0x0000, /* R22 - Alarm Date/Month */
2676 0x0320, /* R23 - RTC Time Control */
2677 0x0000, /* R24 - System Interrupts */
2678 0x0000, /* R25 - Interrupt Status 1 */
2679 0x0000, /* R26 - Interrupt Status 2 */
2680 0x0000, /* R27 */
2681 0x0000, /* R28 - Under Voltage Interrupt status */
2682 0x0000, /* R29 - Over Current Interrupt status */
2683 0x0000, /* R30 - GPIO Interrupt Status */
2684 0x0000, /* R31 - Comparator Interrupt Status */
2685 0x3FFF, /* R32 - System Interrupts Mask */
2686 0x0000, /* R33 - Interrupt Status 1 Mask */
2687 0x0000, /* R34 - Interrupt Status 2 Mask */
2688 0x0000, /* R35 */
2689 0x0000, /* R36 - Under Voltage Interrupt status Mask */
2690 0x0000, /* R37 - Over Current Interrupt status Mask */
2691 0x0000, /* R38 - GPIO Interrupt Status Mask */
2692 0x0000, /* R39 - Comparator Interrupt Status Mask */
2693 0x0040, /* R40 - Clock Control 1 */
2694 0x0000, /* R41 - Clock Control 2 */
2695 0x3A00, /* R42 - FLL Control 1 */
2696 0x7086, /* R43 - FLL Control 2 */
2697 0xC226, /* R44 - FLL Control 3 */
2698 0x0000, /* R45 - FLL Control 4 */
2699 0x0000, /* R46 */
2700 0x0000, /* R47 */
2701 0x0000, /* R48 - DAC Control */
2702 0x0000, /* R49 */
2703 0x00C0, /* R50 - DAC Digital Volume L */
2704 0x00C0, /* R51 - DAC Digital Volume R */
2705 0x0000, /* R52 */
2706 0x0040, /* R53 - DAC LR Rate */
2707 0x0000, /* R54 - DAC Clock Control */
2708 0x0000, /* R55 */
2709 0x0000, /* R56 */
2710 0x0000, /* R57 */
2711 0x4000, /* R58 - DAC Mute */
2712 0x0000, /* R59 - DAC Mute Volume */
2713 0x0000, /* R60 - DAC Side */
2714 0x0000, /* R61 */
2715 0x0000, /* R62 */
2716 0x0000, /* R63 */
2717 0x8000, /* R64 - ADC Control */
2718 0x0000, /* R65 */
2719 0x00C0, /* R66 - ADC Digital Volume L */
2720 0x00C0, /* R67 - ADC Digital Volume R */
2721 0x0000, /* R68 - ADC Divider */
2722 0x0000, /* R69 */
2723 0x0040, /* R70 - ADC LR Rate */
2724 0x0000, /* R71 */
2725 0x0303, /* R72 - Input Control */
2726 0x0000, /* R73 - IN3 Input Control */
2727 0x0000, /* R74 - Mic Bias Control */
2728 0x0000, /* R75 */
2729 0x0000, /* R76 - Output Control */
2730 0x0000, /* R77 - Jack Detect */
2731 0x0000, /* R78 - Anti Pop Control */
2732 0x0000, /* R79 */
2733 0x0040, /* R80 - Left Input Volume */
2734 0x0040, /* R81 - Right Input Volume */
2735 0x0000, /* R82 */
2736 0x0000, /* R83 */
2737 0x0000, /* R84 */
2738 0x0000, /* R85 */
2739 0x0000, /* R86 */
2740 0x0000, /* R87 */
2741 0x0800, /* R88 - Left Mixer Control */
2742 0x1000, /* R89 - Right Mixer Control */
2743 0x0000, /* R90 */
2744 0x0000, /* R91 */
2745 0x0000, /* R92 - OUT3 Mixer Control */
2746 0x0000, /* R93 - OUT4 Mixer Control */
2747 0x0000, /* R94 */
2748 0x0000, /* R95 */
2749 0x0000, /* R96 - Output Left Mixer Volume */
2750 0x0000, /* R97 - Output Right Mixer Volume */
2751 0x0000, /* R98 - Input Mixer Volume L */
2752 0x0000, /* R99 - Input Mixer Volume R */
2753 0x0000, /* R100 - Input Mixer Volume */
2754 0x0000, /* R101 */
2755 0x0000, /* R102 */
2756 0x0000, /* R103 */
2757 0x00E4, /* R104 - OUT1L Volume */
2758 0x00E4, /* R105 - OUT1R Volume */
2759 0x00E4, /* R106 - OUT2L Volume */
2760 0x02E4, /* R107 - OUT2R Volume */
2761 0x0000, /* R108 */
2762 0x0000, /* R109 */
2763 0x0000, /* R110 */
2764 0x0000, /* R111 - BEEP Volume */
2765 0x0A00, /* R112 - AI Formating */
2766 0x0000, /* R113 - ADC DAC COMP */
2767 0x0020, /* R114 - AI ADC Control */
2768 0x0020, /* R115 - AI DAC Control */
2769 0x0000, /* R116 */
2770 0x0000, /* R117 */
2771 0x0000, /* R118 */
2772 0x0000, /* R119 */
2773 0x0000, /* R120 */
2774 0x0000, /* R121 */
2775 0x0000, /* R122 */
2776 0x0000, /* R123 */
2777 0x0000, /* R124 */
2778 0x0000, /* R125 */
2779 0x0000, /* R126 */
2780 0x0000, /* R127 */
2781 0x1FFF, /* R128 - GPIO Debounce */
2782 0x0000, /* R129 - GPIO Pin pull up Control */
2783 0x0110, /* R130 - GPIO Pull down Control */
2784 0x0000, /* R131 - GPIO Interrupt Mode */
2785 0x0000, /* R132 */
2786 0x0000, /* R133 - GPIO Control */
2787 0x09DA, /* R134 - GPIO Configuration (i/o) */
2788 0x0DD6, /* R135 - GPIO Pin Polarity / Type */
2789 0x0000, /* R136 */
2790 0x0000, /* R137 */
2791 0x0000, /* R138 */
2792 0x0000, /* R139 */
2793 0x1310, /* R140 - GPIO Function Select 1 */
2794 0x0033, /* R141 - GPIO Function Select 2 */
2795 0x2000, /* R142 - GPIO Function Select 3 */
2796 0x0000, /* R143 - GPIO Function Select 4 */
2797 0x0000, /* R144 - Digitiser Control (1) */
2798 0x0002, /* R145 - Digitiser Control (2) */
2799 0x0000, /* R146 */
2800 0x0000, /* R147 */
2801 0x0000, /* R148 */
2802 0x0000, /* R149 */
2803 0x0000, /* R150 */
2804 0x0000, /* R151 */
2805 0x7000, /* R152 - AUX1 Readback */
2806 0x7000, /* R153 - AUX2 Readback */
2807 0x7000, /* R154 - AUX3 Readback */
2808 0x7000, /* R155 - AUX4 Readback */
2809 0x0000, /* R156 - USB Voltage Readback */
2810 0x0000, /* R157 - LINE Voltage Readback */
2811 0x0000, /* R158 - BATT Voltage Readback */
2812 0x0000, /* R159 - Chip Temp Readback */
2813 0x0000, /* R160 */
2814 0x0000, /* R161 */
2815 0x0000, /* R162 */
2816 0x0000, /* R163 - Generic Comparator Control */
2817 0x0000, /* R164 - Generic comparator 1 */
2818 0x0000, /* R165 - Generic comparator 2 */
2819 0x0000, /* R166 - Generic comparator 3 */
2820 0x0000, /* R167 - Generic comparator 4 */
2821 0xA00F, /* R168 - Battery Charger Control 1 */
2822 0x0B06, /* R169 - Battery Charger Control 2 */
2823 0x0000, /* R170 - Battery Charger Control 3 */
2824 0x0000, /* R171 */
2825 0x0000, /* R172 - Current Sink Driver A */
2826 0x0000, /* R173 - CSA Flash control */
2827 0x0000, /* R174 - Current Sink Driver B */
2828 0x0000, /* R175 - CSB Flash control */
2829 0x0000, /* R176 - DCDC/LDO requested */
2830 0x032D, /* R177 - DCDC Active options */
2831 0x0000, /* R178 - DCDC Sleep options */
2832 0x0025, /* R179 - Power-check comparator */
2833 0x000E, /* R180 - DCDC1 Control */
2834 0x0800, /* R181 - DCDC1 Timeouts */
2835 0x1006, /* R182 - DCDC1 Low Power */
2836 0x0018, /* R183 - DCDC2 Control */
2837 0x0000, /* R184 - DCDC2 Timeouts */
2838 0x0000, /* R185 */
2839 0x0056, /* R186 - DCDC3 Control */
2840 0x1800, /* R187 - DCDC3 Timeouts */
2841 0x0006, /* R188 - DCDC3 Low Power */
2842 0x000E, /* R189 - DCDC4 Control */
2843 0x1000, /* R190 - DCDC4 Timeouts */
2844 0x0006, /* R191 - DCDC4 Low Power */
2845 0x0008, /* R192 - DCDC5 Control */
2846 0x0000, /* R193 - DCDC5 Timeouts */
2847 0x0000, /* R194 */
2848 0x0026, /* R195 - DCDC6 Control */
2849 0x0C00, /* R196 - DCDC6 Timeouts */
2850 0x0006, /* R197 - DCDC6 Low Power */
2851 0x0000, /* R198 */
2852 0x0003, /* R199 - Limit Switch Control */
2853 0x001C, /* R200 - LDO1 Control */
2854 0x0000, /* R201 - LDO1 Timeouts */
2855 0x001C, /* R202 - LDO1 Low Power */
2856 0x0006, /* R203 - LDO2 Control */
2857 0x0400, /* R204 - LDO2 Timeouts */
2858 0x001C, /* R205 - LDO2 Low Power */
2859 0x001C, /* R206 - LDO3 Control */
2860 0x1400, /* R207 - LDO3 Timeouts */
2861 0x001C, /* R208 - LDO3 Low Power */
2862 0x001A, /* R209 - LDO4 Control */
2863 0x0000, /* R210 - LDO4 Timeouts */
2864 0x001C, /* R211 - LDO4 Low Power */
2865 0x0000, /* R212 */
2866 0x0000, /* R213 */
2867 0x0000, /* R214 */
2868 0x0000, /* R215 - VCC_FAULT Masks */
2869 0x001F, /* R216 - Main Bandgap Control */
2870 0x0000, /* R217 - OSC Control */
2871 0x9000, /* R218 - RTC Tick Control */
2872 0x0000, /* R219 - Security1 */
2873 0x4000, /* R220 */
2874 0x0000, /* R221 */
2875 0x0000, /* R222 */
2876 0x0000, /* R223 */
2877 0x0000, /* R224 - Signal overrides */
2878 0x0000, /* R225 - DCDC/LDO status */
2879 0x0000, /* R226 - Charger Overides/status */
2880 0x0000, /* R227 - misc overrides */
2881 0x0000, /* R228 - Supply overrides/status 1 */
2882 0x0000, /* R229 - Supply overrides/status 2 */
2883 0xE000, /* R230 - GPIO Pin Status */
2884 0x0000, /* R231 - comparotor overrides */
2885 0x0000, /* R232 */
2886 0x0000, /* R233 - State Machine status */
2887 0x1200, /* R234 */
2888 0x0000, /* R235 */
2889 0x8000, /* R236 */
2890 0x0000, /* R237 */
2891 0x0000, /* R238 */
2892 0x0000, /* R239 */
2893 0x0003, /* R240 */
2894 0x0000, /* R241 */
2895 0x0000, /* R242 */
2896 0x0004, /* R243 */
2897 0x0300, /* R244 */
2898 0x0000, /* R245 */
2899 0x0200, /* R246 */
2900 0x0000, /* R247 */
2901 0x1000, /* R248 - DCDC1 Test Controls */
2902 0x5000, /* R249 */
2903 0x1000, /* R250 - DCDC3 Test Controls */
2904 0x1000, /* R251 - DCDC4 Test Controls */
2905 0x5100, /* R252 */
2906 0x1000, /* R253 - DCDC6 Test Controls */
2907};
2908#endif
2909
2910#ifdef CONFIG_MFD_WM8352_CONFIG_MODE_3
2911
2912#undef WM8350_HAVE_CONFIG_MODE
2913#define WM8350_HAVE_CONFIG_MODE
2914
2915const u16 wm8352_mode3_defaults[] = {
2916 0x6143, /* R0 - Reset/ID */
2917 0x0000, /* R1 - ID */
2918 0x0002, /* R2 - Revision */
2919 0x1C02, /* R3 - System Control 1 */
2920 0x0204, /* R4 - System Control 2 */
2921 0x0000, /* R5 - System Hibernate */
2922 0x8A00, /* R6 - Interface Control */
2923 0x0000, /* R7 */
2924 0x8000, /* R8 - Power mgmt (1) */
2925 0x0000, /* R9 - Power mgmt (2) */
2926 0x0000, /* R10 - Power mgmt (3) */
2927 0x2000, /* R11 - Power mgmt (4) */
2928 0x0E00, /* R12 - Power mgmt (5) */
2929 0x0000, /* R13 - Power mgmt (6) */
2930 0x0000, /* R14 - Power mgmt (7) */
2931 0x0000, /* R15 */
2932 0x0000, /* R16 - RTC Seconds/Minutes */
2933 0x0100, /* R17 - RTC Hours/Day */
2934 0x0101, /* R18 - RTC Date/Month */
2935 0x1400, /* R19 - RTC Year */
2936 0x0000, /* R20 - Alarm Seconds/Minutes */
2937 0x0000, /* R21 - Alarm Hours/Day */
2938 0x0000, /* R22 - Alarm Date/Month */
2939 0x0320, /* R23 - RTC Time Control */
2940 0x0000, /* R24 - System Interrupts */
2941 0x0000, /* R25 - Interrupt Status 1 */
2942 0x0000, /* R26 - Interrupt Status 2 */
2943 0x0000, /* R27 */
2944 0x0000, /* R28 - Under Voltage Interrupt status */
2945 0x0000, /* R29 - Over Current Interrupt status */
2946 0x0000, /* R30 - GPIO Interrupt Status */
2947 0x0000, /* R31 - Comparator Interrupt Status */
2948 0x3FFF, /* R32 - System Interrupts Mask */
2949 0x0000, /* R33 - Interrupt Status 1 Mask */
2950 0x0000, /* R34 - Interrupt Status 2 Mask */
2951 0x0000, /* R35 */
2952 0x0000, /* R36 - Under Voltage Interrupt status Mask */
2953 0x0000, /* R37 - Over Current Interrupt status Mask */
2954 0x0000, /* R38 - GPIO Interrupt Status Mask */
2955 0x0000, /* R39 - Comparator Interrupt Status Mask */
2956 0x0040, /* R40 - Clock Control 1 */
2957 0x0000, /* R41 - Clock Control 2 */
2958 0x3A00, /* R42 - FLL Control 1 */
2959 0x7086, /* R43 - FLL Control 2 */
2960 0xC226, /* R44 - FLL Control 3 */
2961 0x0000, /* R45 - FLL Control 4 */
2962 0x0000, /* R46 */
2963 0x0000, /* R47 */
2964 0x0000, /* R48 - DAC Control */
2965 0x0000, /* R49 */
2966 0x00C0, /* R50 - DAC Digital Volume L */
2967 0x00C0, /* R51 - DAC Digital Volume R */
2968 0x0000, /* R52 */
2969 0x0040, /* R53 - DAC LR Rate */
2970 0x0000, /* R54 - DAC Clock Control */
2971 0x0000, /* R55 */
2972 0x0000, /* R56 */
2973 0x0000, /* R57 */
2974 0x4000, /* R58 - DAC Mute */
2975 0x0000, /* R59 - DAC Mute Volume */
2976 0x0000, /* R60 - DAC Side */
2977 0x0000, /* R61 */
2978 0x0000, /* R62 */
2979 0x0000, /* R63 */
2980 0x8000, /* R64 - ADC Control */
2981 0x0000, /* R65 */
2982 0x00C0, /* R66 - ADC Digital Volume L */
2983 0x00C0, /* R67 - ADC Digital Volume R */
2984 0x0000, /* R68 - ADC Divider */
2985 0x0000, /* R69 */
2986 0x0040, /* R70 - ADC LR Rate */
2987 0x0000, /* R71 */
2988 0x0303, /* R72 - Input Control */
2989 0x0000, /* R73 - IN3 Input Control */
2990 0x0000, /* R74 - Mic Bias Control */
2991 0x0000, /* R75 */
2992 0x0000, /* R76 - Output Control */
2993 0x0000, /* R77 - Jack Detect */
2994 0x0000, /* R78 - Anti Pop Control */
2995 0x0000, /* R79 */
2996 0x0040, /* R80 - Left Input Volume */
2997 0x0040, /* R81 - Right Input Volume */
2998 0x0000, /* R82 */
2999 0x0000, /* R83 */
3000 0x0000, /* R84 */
3001 0x0000, /* R85 */
3002 0x0000, /* R86 */
3003 0x0000, /* R87 */
3004 0x0800, /* R88 - Left Mixer Control */
3005 0x1000, /* R89 - Right Mixer Control */
3006 0x0000, /* R90 */
3007 0x0000, /* R91 */
3008 0x0000, /* R92 - OUT3 Mixer Control */
3009 0x0000, /* R93 - OUT4 Mixer Control */
3010 0x0000, /* R94 */
3011 0x0000, /* R95 */
3012 0x0000, /* R96 - Output Left Mixer Volume */
3013 0x0000, /* R97 - Output Right Mixer Volume */
3014 0x0000, /* R98 - Input Mixer Volume L */
3015 0x0000, /* R99 - Input Mixer Volume R */
3016 0x0000, /* R100 - Input Mixer Volume */
3017 0x0000, /* R101 */
3018 0x0000, /* R102 */
3019 0x0000, /* R103 */
3020 0x00E4, /* R104 - OUT1L Volume */
3021 0x00E4, /* R105 - OUT1R Volume */
3022 0x00E4, /* R106 - OUT2L Volume */
3023 0x02E4, /* R107 - OUT2R Volume */
3024 0x0000, /* R108 */
3025 0x0000, /* R109 */
3026 0x0000, /* R110 */
3027 0x0000, /* R111 - BEEP Volume */
3028 0x0A00, /* R112 - AI Formating */
3029 0x0000, /* R113 - ADC DAC COMP */
3030 0x0020, /* R114 - AI ADC Control */
3031 0x0020, /* R115 - AI DAC Control */
3032 0x0000, /* R116 */
3033 0x0000, /* R117 */
3034 0x0000, /* R118 */
3035 0x0000, /* R119 */
3036 0x0000, /* R120 */
3037 0x0000, /* R121 */
3038 0x0000, /* R122 */
3039 0x0000, /* R123 */
3040 0x0000, /* R124 */
3041 0x0000, /* R125 */
3042 0x0000, /* R126 */
3043 0x0000, /* R127 */
3044 0x1FFF, /* R128 - GPIO Debounce */
3045 0x0010, /* R129 - GPIO Pin pull up Control */
3046 0x0000, /* R130 - GPIO Pull down Control */
3047 0x0000, /* R131 - GPIO Interrupt Mode */
3048 0x0000, /* R132 */
3049 0x0000, /* R133 - GPIO Control */
3050 0x0BFB, /* R134 - GPIO Configuration (i/o) */
3051 0x0FFD, /* R135 - GPIO Pin Polarity / Type */
3052 0x0000, /* R136 */
3053 0x0000, /* R137 */
3054 0x0000, /* R138 */
3055 0x0000, /* R139 */
3056 0x0310, /* R140 - GPIO Function Select 1 */
3057 0x0001, /* R141 - GPIO Function Select 2 */
3058 0x2300, /* R142 - GPIO Function Select 3 */
3059 0x0003, /* R143 - GPIO Function Select 4 */
3060 0x0000, /* R144 - Digitiser Control (1) */
3061 0x0002, /* R145 - Digitiser Control (2) */
3062 0x0000, /* R146 */
3063 0x0000, /* R147 */
3064 0x0000, /* R148 */
3065 0x0000, /* R149 */
3066 0x0000, /* R150 */
3067 0x0000, /* R151 */
3068 0x7000, /* R152 - AUX1 Readback */
3069 0x7000, /* R153 - AUX2 Readback */
3070 0x7000, /* R154 - AUX3 Readback */
3071 0x7000, /* R155 - AUX4 Readback */
3072 0x0000, /* R156 - USB Voltage Readback */
3073 0x0000, /* R157 - LINE Voltage Readback */
3074 0x0000, /* R158 - BATT Voltage Readback */
3075 0x0000, /* R159 - Chip Temp Readback */
3076 0x0000, /* R160 */
3077 0x0000, /* R161 */
3078 0x0000, /* R162 */
3079 0x0000, /* R163 - Generic Comparator Control */
3080 0x0000, /* R164 - Generic comparator 1 */
3081 0x0000, /* R165 - Generic comparator 2 */
3082 0x0000, /* R166 - Generic comparator 3 */
3083 0x0000, /* R167 - Generic comparator 4 */
3084 0xA00F, /* R168 - Battery Charger Control 1 */
3085 0x0B06, /* R169 - Battery Charger Control 2 */
3086 0x0000, /* R170 - Battery Charger Control 3 */
3087 0x0000, /* R171 */
3088 0x0000, /* R172 - Current Sink Driver A */
3089 0x0000, /* R173 - CSA Flash control */
3090 0x0000, /* R174 - Current Sink Driver B */
3091 0x0000, /* R175 - CSB Flash control */
3092 0x0000, /* R176 - DCDC/LDO requested */
3093 0x032D, /* R177 - DCDC Active options */
3094 0x0000, /* R178 - DCDC Sleep options */
3095 0x0025, /* R179 - Power-check comparator */
3096 0x0006, /* R180 - DCDC1 Control */
3097 0x0400, /* R181 - DCDC1 Timeouts */
3098 0x1006, /* R182 - DCDC1 Low Power */
3099 0x0018, /* R183 - DCDC2 Control */
3100 0x0000, /* R184 - DCDC2 Timeouts */
3101 0x0000, /* R185 */
3102 0x0050, /* R186 - DCDC3 Control */
3103 0x0C00, /* R187 - DCDC3 Timeouts */
3104 0x0006, /* R188 - DCDC3 Low Power */
3105 0x000E, /* R189 - DCDC4 Control */
3106 0x0400, /* R190 - DCDC4 Timeouts */
3107 0x0006, /* R191 - DCDC4 Low Power */
3108 0x0008, /* R192 - DCDC5 Control */
3109 0x0000, /* R193 - DCDC5 Timeouts */
3110 0x0000, /* R194 */
3111 0x0029, /* R195 - DCDC6 Control */
3112 0x0800, /* R196 - DCDC6 Timeouts */
3113 0x0006, /* R197 - DCDC6 Low Power */
3114 0x0000, /* R198 */
3115 0x0003, /* R199 - Limit Switch Control */
3116 0x001D, /* R200 - LDO1 Control */
3117 0x1000, /* R201 - LDO1 Timeouts */
3118 0x001C, /* R202 - LDO1 Low Power */
3119 0x0017, /* R203 - LDO2 Control */
3120 0x1000, /* R204 - LDO2 Timeouts */
3121 0x001C, /* R205 - LDO2 Low Power */
3122 0x0006, /* R206 - LDO3 Control */
3123 0x1000, /* R207 - LDO3 Timeouts */
3124 0x001C, /* R208 - LDO3 Low Power */
3125 0x0010, /* R209 - LDO4 Control */
3126 0x1000, /* R210 - LDO4 Timeouts */
3127 0x001C, /* R211 - LDO4 Low Power */
3128 0x0000, /* R212 */
3129 0x0000, /* R213 */
3130 0x0000, /* R214 */
3131 0x0000, /* R215 - VCC_FAULT Masks */
3132 0x001F, /* R216 - Main Bandgap Control */
3133 0x0000, /* R217 - OSC Control */
3134 0x9000, /* R218 - RTC Tick Control */
3135 0x0000, /* R219 - Security1 */
3136 0x4000, /* R220 */
3137 0x0000, /* R221 */
3138 0x0000, /* R222 */
3139 0x0000, /* R223 */
3140 0x0000, /* R224 - Signal overrides */
3141 0x0000, /* R225 - DCDC/LDO status */
3142 0x0000, /* R226 - Charger Overides/status */
3143 0x0000, /* R227 - misc overrides */
3144 0x0000, /* R228 - Supply overrides/status 1 */
3145 0x0000, /* R229 - Supply overrides/status 2 */
3146 0xE000, /* R230 - GPIO Pin Status */
3147 0x0000, /* R231 - comparotor overrides */
3148 0x0000, /* R232 */
3149 0x0000, /* R233 - State Machine status */
3150 0x1200, /* R234 */
3151 0x0000, /* R235 */
3152 0x8000, /* R236 */
3153 0x0000, /* R237 */
3154 0x0000, /* R238 */
3155 0x0000, /* R239 */
3156 0x0003, /* R240 */
3157 0x0000, /* R241 */
3158 0x0000, /* R242 */
3159 0x0004, /* R243 */
3160 0x0300, /* R244 */
3161 0x0000, /* R245 */
3162 0x0200, /* R246 */
3163 0x0000, /* R247 */
3164 0x1000, /* R248 - DCDC1 Test Controls */
3165 0x5000, /* R249 */
3166 0x1000, /* R250 - DCDC3 Test Controls */
3167 0x1000, /* R251 - DCDC4 Test Controls */
3168 0x5100, /* R252 */
3169 0x1000, /* R253 - DCDC6 Test Controls */
3170};
3171#endif
3172
3173/* 17/*
3174 * Access masks. 18 * Access masks.
3175 */ 19 */
3176 20
3177const struct wm8350_reg_access wm8350_reg_io_map[] = { 21static const struct wm8350_reg_access {
22 u16 readable; /* Mask of readable bits */
23 u16 writable; /* Mask of writable bits */
24 u16 vol; /* Mask of volatile bits */
25} wm8350_reg_io_map[] = {
3178 /* read write volatile */ 26 /* read write volatile */
3179 { 0xFFFF, 0xFFFF, 0xFFFF }, /* R0 - Reset/ID */ 27 { 0xFFFF, 0xFFFF, 0x0000 }, /* R0 - Reset/ID */
3180 { 0x7CFF, 0x0C00, 0x7FFF }, /* R1 - ID */ 28 { 0x7CFF, 0x0C00, 0x0000 }, /* R1 - ID */
3181 { 0x007F, 0x0000, 0x0000 }, /* R2 - ROM Mask ID */ 29 { 0x007F, 0x0000, 0x0000 }, /* R2 - ROM Mask ID */
3182 { 0xBE3B, 0xBE3B, 0x8000 }, /* R3 - System Control 1 */ 30 { 0xBE3B, 0xBE3B, 0x8000 }, /* R3 - System Control 1 */
3183 { 0xFEF7, 0xFEF7, 0xF800 }, /* R4 - System Control 2 */ 31 { 0xFEF7, 0xFEF7, 0xF800 }, /* R4 - System Control 2 */
@@ -3433,3 +281,59 @@ const struct wm8350_reg_access wm8350_reg_io_map[] = {
3433 { 0x0000, 0x0000, 0x0000 }, /* R254 */ 281 { 0x0000, 0x0000, 0x0000 }, /* R254 */
3434 { 0x0000, 0x0000, 0x0000 }, /* R255 */ 282 { 0x0000, 0x0000, 0x0000 }, /* R255 */
3435}; 283};
284
285static bool wm8350_readable(struct device *dev, unsigned int reg)
286{
287 return wm8350_reg_io_map[reg].readable;
288}
289
290static bool wm8350_writeable(struct device *dev, unsigned int reg)
291{
292 struct wm8350 *wm8350 = dev_get_drvdata(dev);
293
294 if (!wm8350->unlocked) {
295 if ((reg >= WM8350_GPIO_FUNCTION_SELECT_1 &&
296 reg <= WM8350_GPIO_FUNCTION_SELECT_4) ||
297 (reg >= WM8350_BATTERY_CHARGER_CONTROL_1 &&
298 reg <= WM8350_BATTERY_CHARGER_CONTROL_3))
299 return false;
300 }
301
302 return wm8350_reg_io_map[reg].writable;
303}
304
305static bool wm8350_volatile(struct device *dev, unsigned int reg)
306{
307 return wm8350_reg_io_map[reg].vol;
308}
309
310static bool wm8350_precious(struct device *dev, unsigned int reg)
311{
312 switch (reg) {
313 case WM8350_SYSTEM_INTERRUPTS:
314 case WM8350_INT_STATUS_1:
315 case WM8350_INT_STATUS_2:
316 case WM8350_POWER_UP_INT_STATUS:
317 case WM8350_UNDER_VOLTAGE_INT_STATUS:
318 case WM8350_OVER_CURRENT_INT_STATUS:
319 case WM8350_GPIO_INT_STATUS:
320 case WM8350_COMPARATOR_INT_STATUS:
321 return true;
322
323 default:
324 return false;
325 }
326}
327
328const struct regmap_config wm8350_regmap = {
329 .reg_bits = 8,
330 .val_bits = 16,
331
332 .cache_type = REGCACHE_RBTREE,
333
334 .max_register = WM8350_MAX_REGISTER,
335 .readable_reg = wm8350_readable,
336 .writeable_reg = wm8350_writeable,
337 .volatile_reg = wm8350_volatile,
338 .precious_reg = wm8350_precious,
339};
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index 1e321d349777..eec74aa55fdf 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -283,9 +283,24 @@ static int wm8994_suspend(struct device *dev)
283 wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET, 283 wm8994_reg_write(wm8994, WM8994_SOFTWARE_RESET,
284 wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET)); 284 wm8994_reg_read(wm8994, WM8994_SOFTWARE_RESET));
285 285
286 regcache_cache_only(wm8994->regmap, true);
287 regcache_mark_dirty(wm8994->regmap); 286 regcache_mark_dirty(wm8994->regmap);
288 287
288 /* Restore GPIO registers to prevent problems with mismatched
289 * pin configurations.
290 */
291 ret = regcache_sync_region(wm8994->regmap, WM8994_GPIO_1,
292 WM8994_GPIO_11);
293 if (ret != 0)
294 dev_err(dev, "Failed to restore GPIO registers: %d\n", ret);
295
296 /* In case one of the GPIOs is used as a wake input. */
297 ret = regcache_sync_region(wm8994->regmap,
298 WM8994_INTERRUPT_STATUS_1_MASK,
299 WM8994_INTERRUPT_STATUS_1_MASK);
300 if (ret != 0)
301 dev_err(dev, "Failed to restore interrupt mask: %d\n", ret);
302
303 regcache_cache_only(wm8994->regmap, true);
289 wm8994->suspended = true; 304 wm8994->suspended = true;
290 305
291 ret = regulator_bulk_disable(wm8994->num_supplies, 306 ret = regulator_bulk_disable(wm8994->num_supplies,
diff --git a/drivers/mfd/wm8994-irq.c b/drivers/mfd/wm8994-irq.c
index f1837f669755..0aac4aff17a5 100644
--- a/drivers/mfd/wm8994-irq.c
+++ b/drivers/mfd/wm8994-irq.c
@@ -21,6 +21,7 @@
21#include <linux/regmap.h> 21#include <linux/regmap.h>
22 22
23#include <linux/mfd/wm8994/core.h> 23#include <linux/mfd/wm8994/core.h>
24#include <linux/mfd/wm8994/pdata.h>
24#include <linux/mfd/wm8994/registers.h> 25#include <linux/mfd/wm8994/registers.h>
25 26
26#include <linux/delay.h> 27#include <linux/delay.h>
@@ -139,6 +140,8 @@ static struct regmap_irq_chip wm8994_irq_chip = {
139int wm8994_irq_init(struct wm8994 *wm8994) 140int wm8994_irq_init(struct wm8994 *wm8994)
140{ 141{
141 int ret; 142 int ret;
143 unsigned long irqflags;
144 struct wm8994_pdata *pdata = wm8994->dev->platform_data;
142 145
143 if (!wm8994->irq) { 146 if (!wm8994->irq) {
144 dev_warn(wm8994->dev, 147 dev_warn(wm8994->dev,
@@ -147,8 +150,13 @@ int wm8994_irq_init(struct wm8994 *wm8994)
147 return 0; 150 return 0;
148 } 151 }
149 152
153 /* select user or default irq flags */
154 irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT;
155 if (pdata->irq_flags)
156 irqflags = pdata->irq_flags;
157
150 ret = regmap_add_irq_chip(wm8994->regmap, wm8994->irq, 158 ret = regmap_add_irq_chip(wm8994->regmap, wm8994->irq,
151 IRQF_TRIGGER_HIGH | IRQF_ONESHOT, 159 irqflags,
152 wm8994->irq_base, &wm8994_irq_chip, 160 wm8994->irq_base, &wm8994_irq_chip,
153 &wm8994->irq_data); 161 &wm8994->irq_data);
154 if (ret != 0) { 162 if (ret != 0) {
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 154f3ef07631..98a442da892a 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -64,6 +64,7 @@ config AB8500_PWM
64 bool "AB8500 PWM support" 64 bool "AB8500 PWM support"
65 depends on AB8500_CORE && ARCH_U8500 65 depends on AB8500_CORE && ARCH_U8500
66 select HAVE_PWM 66 select HAVE_PWM
67 depends on !PWM
67 help 68 help
68 This driver exports functions to enable/disble/config/free Pulse 69 This driver exports functions to enable/disble/config/free Pulse
69 Width Modulation in the Analog Baseband Chip AB8500. 70 Width Modulation in the Analog Baseband Chip AB8500.
diff --git a/drivers/misc/ab8500-pwm.c b/drivers/misc/ab8500-pwm.c
index 042a8fe4efaa..d7a9aa14e5d5 100644
--- a/drivers/misc/ab8500-pwm.c
+++ b/drivers/misc/ab8500-pwm.c
@@ -142,16 +142,10 @@ static int __devexit ab8500_pwm_remove(struct platform_device *pdev)
142 return 0; 142 return 0;
143} 143}
144 144
145static const struct of_device_id ab8500_pwm_match[] = {
146 { .compatible = "stericsson,ab8500-pwm", },
147 {}
148};
149
150static struct platform_driver ab8500_pwm_driver = { 145static struct platform_driver ab8500_pwm_driver = {
151 .driver = { 146 .driver = {
152 .name = "ab8500-pwm", 147 .name = "ab8500-pwm",
153 .owner = THIS_MODULE, 148 .owner = THIS_MODULE,
154 .of_match_table = ab8500_pwm_match,
155 }, 149 },
156 .probe = ab8500_pwm_probe, 150 .probe = ab8500_pwm_probe,
157 .remove = __devexit_p(ab8500_pwm_remove), 151 .remove = __devexit_p(ab8500_pwm_remove),
diff --git a/drivers/mtd/nand/jz4740_nand.c b/drivers/mtd/nand/jz4740_nand.c
index a6fa884ae49b..100b6775e175 100644
--- a/drivers/mtd/nand/jz4740_nand.c
+++ b/drivers/mtd/nand/jz4740_nand.c
@@ -52,9 +52,10 @@
52 52
53#define JZ_NAND_CTRL_ENABLE_CHIP(x) BIT((x) << 1) 53#define JZ_NAND_CTRL_ENABLE_CHIP(x) BIT((x) << 1)
54#define JZ_NAND_CTRL_ASSERT_CHIP(x) BIT(((x) << 1) + 1) 54#define JZ_NAND_CTRL_ASSERT_CHIP(x) BIT(((x) << 1) + 1)
55#define JZ_NAND_CTRL_ASSERT_CHIP_MASK 0xaa
55 56
56#define JZ_NAND_MEM_ADDR_OFFSET 0x10000
57#define JZ_NAND_MEM_CMD_OFFSET 0x08000 57#define JZ_NAND_MEM_CMD_OFFSET 0x08000
58#define JZ_NAND_MEM_ADDR_OFFSET 0x10000
58 59
59struct jz_nand { 60struct jz_nand {
60 struct mtd_info mtd; 61 struct mtd_info mtd;
@@ -62,8 +63,11 @@ struct jz_nand {
62 void __iomem *base; 63 void __iomem *base;
63 struct resource *mem; 64 struct resource *mem;
64 65
65 void __iomem *bank_base; 66 unsigned char banks[JZ_NAND_NUM_BANKS];
66 struct resource *bank_mem; 67 void __iomem *bank_base[JZ_NAND_NUM_BANKS];
68 struct resource *bank_mem[JZ_NAND_NUM_BANKS];
69
70 int selected_bank;
67 71
68 struct jz_nand_platform_data *pdata; 72 struct jz_nand_platform_data *pdata;
69 bool is_reading; 73 bool is_reading;
@@ -74,26 +78,50 @@ static inline struct jz_nand *mtd_to_jz_nand(struct mtd_info *mtd)
74 return container_of(mtd, struct jz_nand, mtd); 78 return container_of(mtd, struct jz_nand, mtd);
75} 79}
76 80
81static void jz_nand_select_chip(struct mtd_info *mtd, int chipnr)
82{
83 struct jz_nand *nand = mtd_to_jz_nand(mtd);
84 struct nand_chip *chip = mtd->priv;
85 uint32_t ctrl;
86 int banknr;
87
88 ctrl = readl(nand->base + JZ_REG_NAND_CTRL);
89 ctrl &= ~JZ_NAND_CTRL_ASSERT_CHIP_MASK;
90
91 if (chipnr == -1) {
92 banknr = -1;
93 } else {
94 banknr = nand->banks[chipnr] - 1;
95 chip->IO_ADDR_R = nand->bank_base[banknr];
96 chip->IO_ADDR_W = nand->bank_base[banknr];
97 }
98 writel(ctrl, nand->base + JZ_REG_NAND_CTRL);
99
100 nand->selected_bank = banknr;
101}
102
77static void jz_nand_cmd_ctrl(struct mtd_info *mtd, int dat, unsigned int ctrl) 103static void jz_nand_cmd_ctrl(struct mtd_info *mtd, int dat, unsigned int ctrl)
78{ 104{
79 struct jz_nand *nand = mtd_to_jz_nand(mtd); 105 struct jz_nand *nand = mtd_to_jz_nand(mtd);
80 struct nand_chip *chip = mtd->priv; 106 struct nand_chip *chip = mtd->priv;
81 uint32_t reg; 107 uint32_t reg;
108 void __iomem *bank_base = nand->bank_base[nand->selected_bank];
109
110 BUG_ON(nand->selected_bank < 0);
82 111
83 if (ctrl & NAND_CTRL_CHANGE) { 112 if (ctrl & NAND_CTRL_CHANGE) {
84 BUG_ON((ctrl & NAND_ALE) && (ctrl & NAND_CLE)); 113 BUG_ON((ctrl & NAND_ALE) && (ctrl & NAND_CLE));
85 if (ctrl & NAND_ALE) 114 if (ctrl & NAND_ALE)
86 chip->IO_ADDR_W = nand->bank_base + JZ_NAND_MEM_ADDR_OFFSET; 115 bank_base += JZ_NAND_MEM_ADDR_OFFSET;
87 else if (ctrl & NAND_CLE) 116 else if (ctrl & NAND_CLE)
88 chip->IO_ADDR_W = nand->bank_base + JZ_NAND_MEM_CMD_OFFSET; 117 bank_base += JZ_NAND_MEM_CMD_OFFSET;
89 else 118 chip->IO_ADDR_W = bank_base;
90 chip->IO_ADDR_W = nand->bank_base;
91 119
92 reg = readl(nand->base + JZ_REG_NAND_CTRL); 120 reg = readl(nand->base + JZ_REG_NAND_CTRL);
93 if (ctrl & NAND_NCE) 121 if (ctrl & NAND_NCE)
94 reg |= JZ_NAND_CTRL_ASSERT_CHIP(0); 122 reg |= JZ_NAND_CTRL_ASSERT_CHIP(nand->selected_bank);
95 else 123 else
96 reg &= ~JZ_NAND_CTRL_ASSERT_CHIP(0); 124 reg &= ~JZ_NAND_CTRL_ASSERT_CHIP(nand->selected_bank);
97 writel(reg, nand->base + JZ_REG_NAND_CTRL); 125 writel(reg, nand->base + JZ_REG_NAND_CTRL);
98 } 126 }
99 if (dat != NAND_CMD_NONE) 127 if (dat != NAND_CMD_NONE)
@@ -252,7 +280,7 @@ static int jz_nand_correct_ecc_rs(struct mtd_info *mtd, uint8_t *dat,
252} 280}
253 281
254static int jz_nand_ioremap_resource(struct platform_device *pdev, 282static int jz_nand_ioremap_resource(struct platform_device *pdev,
255 const char *name, struct resource **res, void __iomem **base) 283 const char *name, struct resource **res, void *__iomem *base)
256{ 284{
257 int ret; 285 int ret;
258 286
@@ -288,6 +316,90 @@ err:
288 return ret; 316 return ret;
289} 317}
290 318
319static inline void jz_nand_iounmap_resource(struct resource *res, void __iomem *base)
320{
321 iounmap(base);
322 release_mem_region(res->start, resource_size(res));
323}
324
325static int __devinit jz_nand_detect_bank(struct platform_device *pdev, struct jz_nand *nand, unsigned char bank, size_t chipnr, uint8_t *nand_maf_id, uint8_t *nand_dev_id) {
326 int ret;
327 int gpio;
328 char gpio_name[9];
329 char res_name[6];
330 uint32_t ctrl;
331 struct mtd_info *mtd = &nand->mtd;
332 struct nand_chip *chip = &nand->chip;
333
334 /* Request GPIO port. */
335 gpio = JZ_GPIO_MEM_CS0 + bank - 1;
336 sprintf(gpio_name, "NAND CS%d", bank);
337 ret = gpio_request(gpio, gpio_name);
338 if (ret) {
339 dev_warn(&pdev->dev,
340 "Failed to request %s gpio %d: %d\n",
341 gpio_name, gpio, ret);
342 goto notfound_gpio;
343 }
344
345 /* Request I/O resource. */
346 sprintf(res_name, "bank%d", bank);
347 ret = jz_nand_ioremap_resource(pdev, res_name,
348 &nand->bank_mem[bank - 1],
349 &nand->bank_base[bank - 1]);
350 if (ret)
351 goto notfound_resource;
352
353 /* Enable chip in bank. */
354 jz_gpio_set_function(gpio, JZ_GPIO_FUNC_MEM_CS0);
355 ctrl = readl(nand->base + JZ_REG_NAND_CTRL);
356 ctrl |= JZ_NAND_CTRL_ENABLE_CHIP(bank - 1);
357 writel(ctrl, nand->base + JZ_REG_NAND_CTRL);
358
359 if (chipnr == 0) {
360 /* Detect first chip. */
361 ret = nand_scan_ident(mtd, 1, NULL);
362 if (ret)
363 goto notfound_id;
364
365 /* Retrieve the IDs from the first chip. */
366 chip->select_chip(mtd, 0);
367 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
368 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
369 *nand_maf_id = chip->read_byte(mtd);
370 *nand_dev_id = chip->read_byte(mtd);
371 } else {
372 /* Detect additional chip. */
373 chip->select_chip(mtd, chipnr);
374 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
375 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
376 if (*nand_maf_id != chip->read_byte(mtd)
377 || *nand_dev_id != chip->read_byte(mtd)) {
378 ret = -ENODEV;
379 goto notfound_id;
380 }
381
382 /* Update size of the MTD. */
383 chip->numchips++;
384 mtd->size += chip->chipsize;
385 }
386
387 dev_info(&pdev->dev, "Found chip %i on bank %i\n", chipnr, bank);
388 return 0;
389
390notfound_id:
391 dev_info(&pdev->dev, "No chip found on bank %i\n", bank);
392 ctrl &= ~(JZ_NAND_CTRL_ENABLE_CHIP(bank - 1));
393 writel(ctrl, nand->base + JZ_REG_NAND_CTRL);
394 jz_gpio_set_function(gpio, JZ_GPIO_FUNC_NONE);
395 jz_nand_iounmap_resource(nand->bank_mem[bank - 1],
396 nand->bank_base[bank - 1]);
397notfound_resource:
398 gpio_free(gpio);
399notfound_gpio:
400 return ret;
401}
402
291static int __devinit jz_nand_probe(struct platform_device *pdev) 403static int __devinit jz_nand_probe(struct platform_device *pdev)
292{ 404{
293 int ret; 405 int ret;
@@ -295,6 +407,8 @@ static int __devinit jz_nand_probe(struct platform_device *pdev)
295 struct nand_chip *chip; 407 struct nand_chip *chip;
296 struct mtd_info *mtd; 408 struct mtd_info *mtd;
297 struct jz_nand_platform_data *pdata = pdev->dev.platform_data; 409 struct jz_nand_platform_data *pdata = pdev->dev.platform_data;
410 size_t chipnr, bank_idx;
411 uint8_t nand_maf_id = 0, nand_dev_id = 0;
298 412
299 nand = kzalloc(sizeof(*nand), GFP_KERNEL); 413 nand = kzalloc(sizeof(*nand), GFP_KERNEL);
300 if (!nand) { 414 if (!nand) {
@@ -305,10 +419,6 @@ static int __devinit jz_nand_probe(struct platform_device *pdev)
305 ret = jz_nand_ioremap_resource(pdev, "mmio", &nand->mem, &nand->base); 419 ret = jz_nand_ioremap_resource(pdev, "mmio", &nand->mem, &nand->base);
306 if (ret) 420 if (ret)
307 goto err_free; 421 goto err_free;
308 ret = jz_nand_ioremap_resource(pdev, "bank", &nand->bank_mem,
309 &nand->bank_base);
310 if (ret)
311 goto err_iounmap_mmio;
312 422
313 if (pdata && gpio_is_valid(pdata->busy_gpio)) { 423 if (pdata && gpio_is_valid(pdata->busy_gpio)) {
314 ret = gpio_request(pdata->busy_gpio, "NAND busy pin"); 424 ret = gpio_request(pdata->busy_gpio, "NAND busy pin");
@@ -316,7 +426,7 @@ static int __devinit jz_nand_probe(struct platform_device *pdev)
316 dev_err(&pdev->dev, 426 dev_err(&pdev->dev,
317 "Failed to request busy gpio %d: %d\n", 427 "Failed to request busy gpio %d: %d\n",
318 pdata->busy_gpio, ret); 428 pdata->busy_gpio, ret);
319 goto err_iounmap_mem; 429 goto err_iounmap_mmio;
320 } 430 }
321 } 431 }
322 432
@@ -339,22 +449,51 @@ static int __devinit jz_nand_probe(struct platform_device *pdev)
339 449
340 chip->chip_delay = 50; 450 chip->chip_delay = 50;
341 chip->cmd_ctrl = jz_nand_cmd_ctrl; 451 chip->cmd_ctrl = jz_nand_cmd_ctrl;
452 chip->select_chip = jz_nand_select_chip;
342 453
343 if (pdata && gpio_is_valid(pdata->busy_gpio)) 454 if (pdata && gpio_is_valid(pdata->busy_gpio))
344 chip->dev_ready = jz_nand_dev_ready; 455 chip->dev_ready = jz_nand_dev_ready;
345 456
346 chip->IO_ADDR_R = nand->bank_base;
347 chip->IO_ADDR_W = nand->bank_base;
348
349 nand->pdata = pdata; 457 nand->pdata = pdata;
350 platform_set_drvdata(pdev, nand); 458 platform_set_drvdata(pdev, nand);
351 459
352 writel(JZ_NAND_CTRL_ENABLE_CHIP(0), nand->base + JZ_REG_NAND_CTRL); 460 /* We are going to autodetect NAND chips in the banks specified in the
353 461 * platform data. Although nand_scan_ident() can detect multiple chips,
354 ret = nand_scan_ident(mtd, 1, NULL); 462 * it requires those chips to be numbered consecuitively, which is not
355 if (ret) { 463 * always the case for external memory banks. And a fixed chip-to-bank
356 dev_err(&pdev->dev, "Failed to scan nand\n"); 464 * mapping is not practical either, since for example Dingoo units
357 goto err_gpio_free; 465 * produced at different times have NAND chips in different banks.
466 */
467 chipnr = 0;
468 for (bank_idx = 0; bank_idx < JZ_NAND_NUM_BANKS; bank_idx++) {
469 unsigned char bank;
470
471 /* If there is no platform data, look for NAND in bank 1,
472 * which is the most likely bank since it is the only one
473 * that can be booted from.
474 */
475 bank = pdata ? pdata->banks[bank_idx] : bank_idx ^ 1;
476 if (bank == 0)
477 break;
478 if (bank > JZ_NAND_NUM_BANKS) {
479 dev_warn(&pdev->dev,
480 "Skipping non-existing bank: %d\n", bank);
481 continue;
482 }
483 /* The detection routine will directly or indirectly call
484 * jz_nand_select_chip(), so nand->banks has to contain the
485 * bank we're checking.
486 */
487 nand->banks[chipnr] = bank;
488 if (jz_nand_detect_bank(pdev, nand, bank, chipnr,
489 &nand_maf_id, &nand_dev_id) == 0)
490 chipnr++;
491 else
492 nand->banks[chipnr] = 0;
493 }
494 if (chipnr == 0) {
495 dev_err(&pdev->dev, "No NAND chips found\n");
496 goto err_gpio_busy;
358 } 497 }
359 498
360 if (pdata && pdata->ident_callback) { 499 if (pdata && pdata->ident_callback) {
@@ -364,8 +503,8 @@ static int __devinit jz_nand_probe(struct platform_device *pdev)
364 503
365 ret = nand_scan_tail(mtd); 504 ret = nand_scan_tail(mtd);
366 if (ret) { 505 if (ret) {
367 dev_err(&pdev->dev, "Failed to scan nand\n"); 506 dev_err(&pdev->dev, "Failed to scan NAND\n");
368 goto err_gpio_free; 507 goto err_unclaim_banks;
369 } 508 }
370 509
371 ret = mtd_device_parse_register(mtd, NULL, NULL, 510 ret = mtd_device_parse_register(mtd, NULL, NULL,
@@ -382,14 +521,21 @@ static int __devinit jz_nand_probe(struct platform_device *pdev)
382 return 0; 521 return 0;
383 522
384err_nand_release: 523err_nand_release:
385 nand_release(&nand->mtd); 524 nand_release(mtd);
386err_gpio_free: 525err_unclaim_banks:
526 while (chipnr--) {
527 unsigned char bank = nand->banks[chipnr];
528 gpio_free(JZ_GPIO_MEM_CS0 + bank - 1);
529 jz_nand_iounmap_resource(nand->bank_mem[bank - 1],
530 nand->bank_base[bank - 1]);
531 }
532 writel(0, nand->base + JZ_REG_NAND_CTRL);
533err_gpio_busy:
534 if (pdata && gpio_is_valid(pdata->busy_gpio))
535 gpio_free(pdata->busy_gpio);
387 platform_set_drvdata(pdev, NULL); 536 platform_set_drvdata(pdev, NULL);
388 gpio_free(pdata->busy_gpio);
389err_iounmap_mem:
390 iounmap(nand->bank_base);
391err_iounmap_mmio: 537err_iounmap_mmio:
392 iounmap(nand->base); 538 jz_nand_iounmap_resource(nand->mem, nand->base);
393err_free: 539err_free:
394 kfree(nand); 540 kfree(nand);
395 return ret; 541 return ret;
@@ -398,16 +544,26 @@ err_free:
398static int __devexit jz_nand_remove(struct platform_device *pdev) 544static int __devexit jz_nand_remove(struct platform_device *pdev)
399{ 545{
400 struct jz_nand *nand = platform_get_drvdata(pdev); 546 struct jz_nand *nand = platform_get_drvdata(pdev);
547 struct jz_nand_platform_data *pdata = pdev->dev.platform_data;
548 size_t i;
401 549
402 nand_release(&nand->mtd); 550 nand_release(&nand->mtd);
403 551
404 /* Deassert and disable all chips */ 552 /* Deassert and disable all chips */
405 writel(0, nand->base + JZ_REG_NAND_CTRL); 553 writel(0, nand->base + JZ_REG_NAND_CTRL);
406 554
407 iounmap(nand->bank_base); 555 for (i = 0; i < JZ_NAND_NUM_BANKS; ++i) {
408 release_mem_region(nand->bank_mem->start, resource_size(nand->bank_mem)); 556 unsigned char bank = nand->banks[i];
409 iounmap(nand->base); 557 if (bank != 0) {
410 release_mem_region(nand->mem->start, resource_size(nand->mem)); 558 jz_nand_iounmap_resource(nand->bank_mem[bank - 1],
559 nand->bank_base[bank - 1]);
560 gpio_free(JZ_GPIO_MEM_CS0 + bank - 1);
561 }
562 }
563 if (pdata && gpio_is_valid(pdata->busy_gpio))
564 gpio_free(pdata->busy_gpio);
565
566 jz_nand_iounmap_resource(nand->mem, nand->base);
411 567
412 platform_set_drvdata(pdev, NULL); 568 platform_set_drvdata(pdev, NULL);
413 kfree(nand); 569 kfree(nand);
diff --git a/drivers/net/ethernet/octeon/octeon_mgmt.c b/drivers/net/ethernet/octeon/octeon_mgmt.c
index cd827ff4a021..c42bbb16cdae 100644
--- a/drivers/net/ethernet/octeon/octeon_mgmt.c
+++ b/drivers/net/ethernet/octeon/octeon_mgmt.c
@@ -6,19 +6,21 @@
6 * Copyright (C) 2009 Cavium Networks 6 * Copyright (C) 2009 Cavium Networks
7 */ 7 */
8 8
9#include <linux/capability.h> 9#include <linux/platform_device.h>
10#include <linux/dma-mapping.h> 10#include <linux/dma-mapping.h>
11#include <linux/init.h> 11#include <linux/etherdevice.h>
12#include <linux/module.h> 12#include <linux/capability.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/platform_device.h>
15#include <linux/netdevice.h> 14#include <linux/netdevice.h>
16#include <linux/etherdevice.h> 15#include <linux/spinlock.h>
17#include <linux/if.h>
18#include <linux/if_vlan.h> 16#include <linux/if_vlan.h>
17#include <linux/of_mdio.h>
18#include <linux/module.h>
19#include <linux/of_net.h>
20#include <linux/init.h>
19#include <linux/slab.h> 21#include <linux/slab.h>
20#include <linux/phy.h> 22#include <linux/phy.h>
21#include <linux/spinlock.h> 23#include <linux/io.h>
22 24
23#include <asm/octeon/octeon.h> 25#include <asm/octeon/octeon.h>
24#include <asm/octeon/cvmx-mixx-defs.h> 26#include <asm/octeon/cvmx-mixx-defs.h>
@@ -58,8 +60,56 @@ union mgmt_port_ring_entry {
58 } s; 60 } s;
59}; 61};
60 62
63#define MIX_ORING1 0x0
64#define MIX_ORING2 0x8
65#define MIX_IRING1 0x10
66#define MIX_IRING2 0x18
67#define MIX_CTL 0x20
68#define MIX_IRHWM 0x28
69#define MIX_IRCNT 0x30
70#define MIX_ORHWM 0x38
71#define MIX_ORCNT 0x40
72#define MIX_ISR 0x48
73#define MIX_INTENA 0x50
74#define MIX_REMCNT 0x58
75#define MIX_BIST 0x78
76
77#define AGL_GMX_PRT_CFG 0x10
78#define AGL_GMX_RX_FRM_CTL 0x18
79#define AGL_GMX_RX_FRM_MAX 0x30
80#define AGL_GMX_RX_JABBER 0x38
81#define AGL_GMX_RX_STATS_CTL 0x50
82
83#define AGL_GMX_RX_STATS_PKTS_DRP 0xb0
84#define AGL_GMX_RX_STATS_OCTS_DRP 0xb8
85#define AGL_GMX_RX_STATS_PKTS_BAD 0xc0
86
87#define AGL_GMX_RX_ADR_CTL 0x100
88#define AGL_GMX_RX_ADR_CAM_EN 0x108
89#define AGL_GMX_RX_ADR_CAM0 0x180
90#define AGL_GMX_RX_ADR_CAM1 0x188
91#define AGL_GMX_RX_ADR_CAM2 0x190
92#define AGL_GMX_RX_ADR_CAM3 0x198
93#define AGL_GMX_RX_ADR_CAM4 0x1a0
94#define AGL_GMX_RX_ADR_CAM5 0x1a8
95
96#define AGL_GMX_TX_STATS_CTL 0x268
97#define AGL_GMX_TX_CTL 0x270
98#define AGL_GMX_TX_STAT0 0x280
99#define AGL_GMX_TX_STAT1 0x288
100#define AGL_GMX_TX_STAT2 0x290
101#define AGL_GMX_TX_STAT3 0x298
102#define AGL_GMX_TX_STAT4 0x2a0
103#define AGL_GMX_TX_STAT5 0x2a8
104#define AGL_GMX_TX_STAT6 0x2b0
105#define AGL_GMX_TX_STAT7 0x2b8
106#define AGL_GMX_TX_STAT8 0x2c0
107#define AGL_GMX_TX_STAT9 0x2c8
108
61struct octeon_mgmt { 109struct octeon_mgmt {
62 struct net_device *netdev; 110 struct net_device *netdev;
111 u64 mix;
112 u64 agl;
63 int port; 113 int port;
64 int irq; 114 int irq;
65 u64 *tx_ring; 115 u64 *tx_ring;
@@ -85,31 +135,34 @@ struct octeon_mgmt {
85 struct napi_struct napi; 135 struct napi_struct napi;
86 struct tasklet_struct tx_clean_tasklet; 136 struct tasklet_struct tx_clean_tasklet;
87 struct phy_device *phydev; 137 struct phy_device *phydev;
138 struct device_node *phy_np;
139 resource_size_t mix_phys;
140 resource_size_t mix_size;
141 resource_size_t agl_phys;
142 resource_size_t agl_size;
88}; 143};
89 144
90static void octeon_mgmt_set_rx_irq(struct octeon_mgmt *p, int enable) 145static void octeon_mgmt_set_rx_irq(struct octeon_mgmt *p, int enable)
91{ 146{
92 int port = p->port;
93 union cvmx_mixx_intena mix_intena; 147 union cvmx_mixx_intena mix_intena;
94 unsigned long flags; 148 unsigned long flags;
95 149
96 spin_lock_irqsave(&p->lock, flags); 150 spin_lock_irqsave(&p->lock, flags);
97 mix_intena.u64 = cvmx_read_csr(CVMX_MIXX_INTENA(port)); 151 mix_intena.u64 = cvmx_read_csr(p->mix + MIX_INTENA);
98 mix_intena.s.ithena = enable ? 1 : 0; 152 mix_intena.s.ithena = enable ? 1 : 0;
99 cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64); 153 cvmx_write_csr(p->mix + MIX_INTENA, mix_intena.u64);
100 spin_unlock_irqrestore(&p->lock, flags); 154 spin_unlock_irqrestore(&p->lock, flags);
101} 155}
102 156
103static void octeon_mgmt_set_tx_irq(struct octeon_mgmt *p, int enable) 157static void octeon_mgmt_set_tx_irq(struct octeon_mgmt *p, int enable)
104{ 158{
105 int port = p->port;
106 union cvmx_mixx_intena mix_intena; 159 union cvmx_mixx_intena mix_intena;
107 unsigned long flags; 160 unsigned long flags;
108 161
109 spin_lock_irqsave(&p->lock, flags); 162 spin_lock_irqsave(&p->lock, flags);
110 mix_intena.u64 = cvmx_read_csr(CVMX_MIXX_INTENA(port)); 163 mix_intena.u64 = cvmx_read_csr(p->mix + MIX_INTENA);
111 mix_intena.s.othena = enable ? 1 : 0; 164 mix_intena.s.othena = enable ? 1 : 0;
112 cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64); 165 cvmx_write_csr(p->mix + MIX_INTENA, mix_intena.u64);
113 spin_unlock_irqrestore(&p->lock, flags); 166 spin_unlock_irqrestore(&p->lock, flags);
114} 167}
115 168
@@ -146,7 +199,6 @@ static unsigned int ring_size_to_bytes(unsigned int ring_size)
146static void octeon_mgmt_rx_fill_ring(struct net_device *netdev) 199static void octeon_mgmt_rx_fill_ring(struct net_device *netdev)
147{ 200{
148 struct octeon_mgmt *p = netdev_priv(netdev); 201 struct octeon_mgmt *p = netdev_priv(netdev);
149 int port = p->port;
150 202
151 while (p->rx_current_fill < ring_max_fill(OCTEON_MGMT_RX_RING_SIZE)) { 203 while (p->rx_current_fill < ring_max_fill(OCTEON_MGMT_RX_RING_SIZE)) {
152 unsigned int size; 204 unsigned int size;
@@ -177,24 +229,23 @@ static void octeon_mgmt_rx_fill_ring(struct net_device *netdev)
177 (p->rx_next_fill + 1) % OCTEON_MGMT_RX_RING_SIZE; 229 (p->rx_next_fill + 1) % OCTEON_MGMT_RX_RING_SIZE;
178 p->rx_current_fill++; 230 p->rx_current_fill++;
179 /* Ring the bell. */ 231 /* Ring the bell. */
180 cvmx_write_csr(CVMX_MIXX_IRING2(port), 1); 232 cvmx_write_csr(p->mix + MIX_IRING2, 1);
181 } 233 }
182} 234}
183 235
184static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p) 236static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
185{ 237{
186 int port = p->port;
187 union cvmx_mixx_orcnt mix_orcnt; 238 union cvmx_mixx_orcnt mix_orcnt;
188 union mgmt_port_ring_entry re; 239 union mgmt_port_ring_entry re;
189 struct sk_buff *skb; 240 struct sk_buff *skb;
190 int cleaned = 0; 241 int cleaned = 0;
191 unsigned long flags; 242 unsigned long flags;
192 243
193 mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port)); 244 mix_orcnt.u64 = cvmx_read_csr(p->mix + MIX_ORCNT);
194 while (mix_orcnt.s.orcnt) { 245 while (mix_orcnt.s.orcnt) {
195 spin_lock_irqsave(&p->tx_list.lock, flags); 246 spin_lock_irqsave(&p->tx_list.lock, flags);
196 247
197 mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port)); 248 mix_orcnt.u64 = cvmx_read_csr(p->mix + MIX_ORCNT);
198 249
199 if (mix_orcnt.s.orcnt == 0) { 250 if (mix_orcnt.s.orcnt == 0) {
200 spin_unlock_irqrestore(&p->tx_list.lock, flags); 251 spin_unlock_irqrestore(&p->tx_list.lock, flags);
@@ -214,7 +265,7 @@ static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
214 mix_orcnt.s.orcnt = 1; 265 mix_orcnt.s.orcnt = 1;
215 266
216 /* Acknowledge to hardware that we have the buffer. */ 267 /* Acknowledge to hardware that we have the buffer. */
217 cvmx_write_csr(CVMX_MIXX_ORCNT(port), mix_orcnt.u64); 268 cvmx_write_csr(p->mix + MIX_ORCNT, mix_orcnt.u64);
218 p->tx_current_fill--; 269 p->tx_current_fill--;
219 270
220 spin_unlock_irqrestore(&p->tx_list.lock, flags); 271 spin_unlock_irqrestore(&p->tx_list.lock, flags);
@@ -224,7 +275,7 @@ static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
224 dev_kfree_skb_any(skb); 275 dev_kfree_skb_any(skb);
225 cleaned++; 276 cleaned++;
226 277
227 mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port)); 278 mix_orcnt.u64 = cvmx_read_csr(p->mix + MIX_ORCNT);
228 } 279 }
229 280
230 if (cleaned && netif_queue_stopped(p->netdev)) 281 if (cleaned && netif_queue_stopped(p->netdev))
@@ -241,13 +292,12 @@ static void octeon_mgmt_clean_tx_tasklet(unsigned long arg)
241static void octeon_mgmt_update_rx_stats(struct net_device *netdev) 292static void octeon_mgmt_update_rx_stats(struct net_device *netdev)
242{ 293{
243 struct octeon_mgmt *p = netdev_priv(netdev); 294 struct octeon_mgmt *p = netdev_priv(netdev);
244 int port = p->port;
245 unsigned long flags; 295 unsigned long flags;
246 u64 drop, bad; 296 u64 drop, bad;
247 297
248 /* These reads also clear the count registers. */ 298 /* These reads also clear the count registers. */
249 drop = cvmx_read_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(port)); 299 drop = cvmx_read_csr(p->agl + AGL_GMX_RX_STATS_PKTS_DRP);
250 bad = cvmx_read_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(port)); 300 bad = cvmx_read_csr(p->agl + AGL_GMX_RX_STATS_PKTS_BAD);
251 301
252 if (drop || bad) { 302 if (drop || bad) {
253 /* Do an atomic update. */ 303 /* Do an atomic update. */
@@ -261,15 +311,14 @@ static void octeon_mgmt_update_rx_stats(struct net_device *netdev)
261static void octeon_mgmt_update_tx_stats(struct net_device *netdev) 311static void octeon_mgmt_update_tx_stats(struct net_device *netdev)
262{ 312{
263 struct octeon_mgmt *p = netdev_priv(netdev); 313 struct octeon_mgmt *p = netdev_priv(netdev);
264 int port = p->port;
265 unsigned long flags; 314 unsigned long flags;
266 315
267 union cvmx_agl_gmx_txx_stat0 s0; 316 union cvmx_agl_gmx_txx_stat0 s0;
268 union cvmx_agl_gmx_txx_stat1 s1; 317 union cvmx_agl_gmx_txx_stat1 s1;
269 318
270 /* These reads also clear the count registers. */ 319 /* These reads also clear the count registers. */
271 s0.u64 = cvmx_read_csr(CVMX_AGL_GMX_TXX_STAT0(port)); 320 s0.u64 = cvmx_read_csr(p->agl + AGL_GMX_TX_STAT0);
272 s1.u64 = cvmx_read_csr(CVMX_AGL_GMX_TXX_STAT1(port)); 321 s1.u64 = cvmx_read_csr(p->agl + AGL_GMX_TX_STAT1);
273 322
274 if (s0.s.xsdef || s0.s.xscol || s1.s.scol || s1.s.mcol) { 323 if (s0.s.xsdef || s0.s.xscol || s1.s.scol || s1.s.mcol) {
275 /* Do an atomic update. */ 324 /* Do an atomic update. */
@@ -308,7 +357,6 @@ static u64 octeon_mgmt_dequeue_rx_buffer(struct octeon_mgmt *p,
308 357
309static int octeon_mgmt_receive_one(struct octeon_mgmt *p) 358static int octeon_mgmt_receive_one(struct octeon_mgmt *p)
310{ 359{
311 int port = p->port;
312 struct net_device *netdev = p->netdev; 360 struct net_device *netdev = p->netdev;
313 union cvmx_mixx_ircnt mix_ircnt; 361 union cvmx_mixx_ircnt mix_ircnt;
314 union mgmt_port_ring_entry re; 362 union mgmt_port_ring_entry re;
@@ -381,18 +429,17 @@ done:
381 /* Tell the hardware we processed a packet. */ 429 /* Tell the hardware we processed a packet. */
382 mix_ircnt.u64 = 0; 430 mix_ircnt.u64 = 0;
383 mix_ircnt.s.ircnt = 1; 431 mix_ircnt.s.ircnt = 1;
384 cvmx_write_csr(CVMX_MIXX_IRCNT(port), mix_ircnt.u64); 432 cvmx_write_csr(p->mix + MIX_IRCNT, mix_ircnt.u64);
385 return rc; 433 return rc;
386} 434}
387 435
388static int octeon_mgmt_receive_packets(struct octeon_mgmt *p, int budget) 436static int octeon_mgmt_receive_packets(struct octeon_mgmt *p, int budget)
389{ 437{
390 int port = p->port;
391 unsigned int work_done = 0; 438 unsigned int work_done = 0;
392 union cvmx_mixx_ircnt mix_ircnt; 439 union cvmx_mixx_ircnt mix_ircnt;
393 int rc; 440 int rc;
394 441
395 mix_ircnt.u64 = cvmx_read_csr(CVMX_MIXX_IRCNT(port)); 442 mix_ircnt.u64 = cvmx_read_csr(p->mix + MIX_IRCNT);
396 while (work_done < budget && mix_ircnt.s.ircnt) { 443 while (work_done < budget && mix_ircnt.s.ircnt) {
397 444
398 rc = octeon_mgmt_receive_one(p); 445 rc = octeon_mgmt_receive_one(p);
@@ -400,7 +447,7 @@ static int octeon_mgmt_receive_packets(struct octeon_mgmt *p, int budget)
400 work_done++; 447 work_done++;
401 448
402 /* Check for more packets. */ 449 /* Check for more packets. */
403 mix_ircnt.u64 = cvmx_read_csr(CVMX_MIXX_IRCNT(port)); 450 mix_ircnt.u64 = cvmx_read_csr(p->mix + MIX_IRCNT);
404 } 451 }
405 452
406 octeon_mgmt_rx_fill_ring(p->netdev); 453 octeon_mgmt_rx_fill_ring(p->netdev);
@@ -434,16 +481,16 @@ static void octeon_mgmt_reset_hw(struct octeon_mgmt *p)
434 union cvmx_agl_gmx_bist agl_gmx_bist; 481 union cvmx_agl_gmx_bist agl_gmx_bist;
435 482
436 mix_ctl.u64 = 0; 483 mix_ctl.u64 = 0;
437 cvmx_write_csr(CVMX_MIXX_CTL(p->port), mix_ctl.u64); 484 cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
438 do { 485 do {
439 mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(p->port)); 486 mix_ctl.u64 = cvmx_read_csr(p->mix + MIX_CTL);
440 } while (mix_ctl.s.busy); 487 } while (mix_ctl.s.busy);
441 mix_ctl.s.reset = 1; 488 mix_ctl.s.reset = 1;
442 cvmx_write_csr(CVMX_MIXX_CTL(p->port), mix_ctl.u64); 489 cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
443 cvmx_read_csr(CVMX_MIXX_CTL(p->port)); 490 cvmx_read_csr(p->mix + MIX_CTL);
444 cvmx_wait(64); 491 cvmx_wait(64);
445 492
446 mix_bist.u64 = cvmx_read_csr(CVMX_MIXX_BIST(p->port)); 493 mix_bist.u64 = cvmx_read_csr(p->mix + MIX_BIST);
447 if (mix_bist.u64) 494 if (mix_bist.u64)
448 dev_warn(p->dev, "MIX failed BIST (0x%016llx)\n", 495 dev_warn(p->dev, "MIX failed BIST (0x%016llx)\n",
449 (unsigned long long)mix_bist.u64); 496 (unsigned long long)mix_bist.u64);
@@ -474,7 +521,6 @@ static void octeon_mgmt_cam_state_add(struct octeon_mgmt_cam_state *cs,
474static void octeon_mgmt_set_rx_filtering(struct net_device *netdev) 521static void octeon_mgmt_set_rx_filtering(struct net_device *netdev)
475{ 522{
476 struct octeon_mgmt *p = netdev_priv(netdev); 523 struct octeon_mgmt *p = netdev_priv(netdev);
477 int port = p->port;
478 union cvmx_agl_gmx_rxx_adr_ctl adr_ctl; 524 union cvmx_agl_gmx_rxx_adr_ctl adr_ctl;
479 union cvmx_agl_gmx_prtx_cfg agl_gmx_prtx; 525 union cvmx_agl_gmx_prtx_cfg agl_gmx_prtx;
480 unsigned long flags; 526 unsigned long flags;
@@ -520,29 +566,29 @@ static void octeon_mgmt_set_rx_filtering(struct net_device *netdev)
520 spin_lock_irqsave(&p->lock, flags); 566 spin_lock_irqsave(&p->lock, flags);
521 567
522 /* Disable packet I/O. */ 568 /* Disable packet I/O. */
523 agl_gmx_prtx.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port)); 569 agl_gmx_prtx.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
524 prev_packet_enable = agl_gmx_prtx.s.en; 570 prev_packet_enable = agl_gmx_prtx.s.en;
525 agl_gmx_prtx.s.en = 0; 571 agl_gmx_prtx.s.en = 0;
526 cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), agl_gmx_prtx.u64); 572 cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, agl_gmx_prtx.u64);
527 573
528 adr_ctl.u64 = 0; 574 adr_ctl.u64 = 0;
529 adr_ctl.s.cam_mode = cam_mode; 575 adr_ctl.s.cam_mode = cam_mode;
530 adr_ctl.s.mcst = multicast_mode; 576 adr_ctl.s.mcst = multicast_mode;
531 adr_ctl.s.bcst = 1; /* Allow broadcast */ 577 adr_ctl.s.bcst = 1; /* Allow broadcast */
532 578
533 cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CTL(port), adr_ctl.u64); 579 cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CTL, adr_ctl.u64);
534 580
535 cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM0(port), cam_state.cam[0]); 581 cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM0, cam_state.cam[0]);
536 cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM1(port), cam_state.cam[1]); 582 cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM1, cam_state.cam[1]);
537 cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM2(port), cam_state.cam[2]); 583 cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM2, cam_state.cam[2]);
538 cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM3(port), cam_state.cam[3]); 584 cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM3, cam_state.cam[3]);
539 cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM4(port), cam_state.cam[4]); 585 cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM4, cam_state.cam[4]);
540 cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM5(port), cam_state.cam[5]); 586 cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM5, cam_state.cam[5]);
541 cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM_EN(port), cam_state.cam_mask); 587 cvmx_write_csr(p->agl + AGL_GMX_RX_ADR_CAM_EN, cam_state.cam_mask);
542 588
543 /* Restore packet I/O. */ 589 /* Restore packet I/O. */
544 agl_gmx_prtx.s.en = prev_packet_enable; 590 agl_gmx_prtx.s.en = prev_packet_enable;
545 cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), agl_gmx_prtx.u64); 591 cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, agl_gmx_prtx.u64);
546 592
547 spin_unlock_irqrestore(&p->lock, flags); 593 spin_unlock_irqrestore(&p->lock, flags);
548} 594}
@@ -564,7 +610,6 @@ static int octeon_mgmt_set_mac_address(struct net_device *netdev, void *addr)
564static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu) 610static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
565{ 611{
566 struct octeon_mgmt *p = netdev_priv(netdev); 612 struct octeon_mgmt *p = netdev_priv(netdev);
567 int port = p->port;
568 int size_without_fcs = new_mtu + OCTEON_MGMT_RX_HEADROOM; 613 int size_without_fcs = new_mtu + OCTEON_MGMT_RX_HEADROOM;
569 614
570 /* 615 /*
@@ -580,8 +625,8 @@ static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
580 625
581 netdev->mtu = new_mtu; 626 netdev->mtu = new_mtu;
582 627
583 cvmx_write_csr(CVMX_AGL_GMX_RXX_FRM_MAX(port), size_without_fcs); 628 cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_MAX, size_without_fcs);
584 cvmx_write_csr(CVMX_AGL_GMX_RXX_JABBER(port), 629 cvmx_write_csr(p->agl + AGL_GMX_RX_JABBER,
585 (size_without_fcs + 7) & 0xfff8); 630 (size_without_fcs + 7) & 0xfff8);
586 631
587 return 0; 632 return 0;
@@ -591,14 +636,13 @@ static irqreturn_t octeon_mgmt_interrupt(int cpl, void *dev_id)
591{ 636{
592 struct net_device *netdev = dev_id; 637 struct net_device *netdev = dev_id;
593 struct octeon_mgmt *p = netdev_priv(netdev); 638 struct octeon_mgmt *p = netdev_priv(netdev);
594 int port = p->port;
595 union cvmx_mixx_isr mixx_isr; 639 union cvmx_mixx_isr mixx_isr;
596 640
597 mixx_isr.u64 = cvmx_read_csr(CVMX_MIXX_ISR(port)); 641 mixx_isr.u64 = cvmx_read_csr(p->mix + MIX_ISR);
598 642
599 /* Clear any pending interrupts */ 643 /* Clear any pending interrupts */
600 cvmx_write_csr(CVMX_MIXX_ISR(port), mixx_isr.u64); 644 cvmx_write_csr(p->mix + MIX_ISR, mixx_isr.u64);
601 cvmx_read_csr(CVMX_MIXX_ISR(port)); 645 cvmx_read_csr(p->mix + MIX_ISR);
602 646
603 if (mixx_isr.s.irthresh) { 647 if (mixx_isr.s.irthresh) {
604 octeon_mgmt_disable_rx_irq(p); 648 octeon_mgmt_disable_rx_irq(p);
@@ -629,7 +673,6 @@ static int octeon_mgmt_ioctl(struct net_device *netdev,
629static void octeon_mgmt_adjust_link(struct net_device *netdev) 673static void octeon_mgmt_adjust_link(struct net_device *netdev)
630{ 674{
631 struct octeon_mgmt *p = netdev_priv(netdev); 675 struct octeon_mgmt *p = netdev_priv(netdev);
632 int port = p->port;
633 union cvmx_agl_gmx_prtx_cfg prtx_cfg; 676 union cvmx_agl_gmx_prtx_cfg prtx_cfg;
634 unsigned long flags; 677 unsigned long flags;
635 int link_changed = 0; 678 int link_changed = 0;
@@ -640,11 +683,9 @@ static void octeon_mgmt_adjust_link(struct net_device *netdev)
640 link_changed = 1; 683 link_changed = 1;
641 if (p->last_duplex != p->phydev->duplex) { 684 if (p->last_duplex != p->phydev->duplex) {
642 p->last_duplex = p->phydev->duplex; 685 p->last_duplex = p->phydev->duplex;
643 prtx_cfg.u64 = 686 prtx_cfg.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
644 cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
645 prtx_cfg.s.duplex = p->phydev->duplex; 687 prtx_cfg.s.duplex = p->phydev->duplex;
646 cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), 688 cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, prtx_cfg.u64);
647 prtx_cfg.u64);
648 } 689 }
649 } else { 690 } else {
650 if (p->last_link) 691 if (p->last_link)
@@ -670,18 +711,16 @@ static void octeon_mgmt_adjust_link(struct net_device *netdev)
670static int octeon_mgmt_init_phy(struct net_device *netdev) 711static int octeon_mgmt_init_phy(struct net_device *netdev)
671{ 712{
672 struct octeon_mgmt *p = netdev_priv(netdev); 713 struct octeon_mgmt *p = netdev_priv(netdev);
673 char phy_id[MII_BUS_ID_SIZE + 3];
674 714
675 if (octeon_is_simulation()) { 715 if (octeon_is_simulation() || p->phy_np == NULL) {
676 /* No PHYs in the simulator. */ 716 /* No PHYs in the simulator. */
677 netif_carrier_on(netdev); 717 netif_carrier_on(netdev);
678 return 0; 718 return 0;
679 } 719 }
680 720
681 snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, "mdio-octeon-0", p->port); 721 p->phydev = of_phy_connect(netdev, p->phy_np,
682 722 octeon_mgmt_adjust_link, 0,
683 p->phydev = phy_connect(netdev, phy_id, octeon_mgmt_adjust_link, 0, 723 PHY_INTERFACE_MODE_MII);
684 PHY_INTERFACE_MODE_MII);
685 724
686 if (IS_ERR(p->phydev)) { 725 if (IS_ERR(p->phydev)) {
687 p->phydev = NULL; 726 p->phydev = NULL;
@@ -737,14 +776,14 @@ static int octeon_mgmt_open(struct net_device *netdev)
737 776
738 octeon_mgmt_reset_hw(p); 777 octeon_mgmt_reset_hw(p);
739 778
740 mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(port)); 779 mix_ctl.u64 = cvmx_read_csr(p->mix + MIX_CTL);
741 780
742 /* Bring it out of reset if needed. */ 781 /* Bring it out of reset if needed. */
743 if (mix_ctl.s.reset) { 782 if (mix_ctl.s.reset) {
744 mix_ctl.s.reset = 0; 783 mix_ctl.s.reset = 0;
745 cvmx_write_csr(CVMX_MIXX_CTL(port), mix_ctl.u64); 784 cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
746 do { 785 do {
747 mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(port)); 786 mix_ctl.u64 = cvmx_read_csr(p->mix + MIX_CTL);
748 } while (mix_ctl.s.reset); 787 } while (mix_ctl.s.reset);
749 } 788 }
750 789
@@ -755,17 +794,17 @@ static int octeon_mgmt_open(struct net_device *netdev)
755 oring1.u64 = 0; 794 oring1.u64 = 0;
756 oring1.s.obase = p->tx_ring_handle >> 3; 795 oring1.s.obase = p->tx_ring_handle >> 3;
757 oring1.s.osize = OCTEON_MGMT_TX_RING_SIZE; 796 oring1.s.osize = OCTEON_MGMT_TX_RING_SIZE;
758 cvmx_write_csr(CVMX_MIXX_ORING1(port), oring1.u64); 797 cvmx_write_csr(p->mix + MIX_ORING1, oring1.u64);
759 798
760 iring1.u64 = 0; 799 iring1.u64 = 0;
761 iring1.s.ibase = p->rx_ring_handle >> 3; 800 iring1.s.ibase = p->rx_ring_handle >> 3;
762 iring1.s.isize = OCTEON_MGMT_RX_RING_SIZE; 801 iring1.s.isize = OCTEON_MGMT_RX_RING_SIZE;
763 cvmx_write_csr(CVMX_MIXX_IRING1(port), iring1.u64); 802 cvmx_write_csr(p->mix + MIX_IRING1, iring1.u64);
764 803
765 /* Disable packet I/O. */ 804 /* Disable packet I/O. */
766 prtx_cfg.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port)); 805 prtx_cfg.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
767 prtx_cfg.s.en = 0; 806 prtx_cfg.s.en = 0;
768 cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), prtx_cfg.u64); 807 cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, prtx_cfg.u64);
769 808
770 memcpy(sa.sa_data, netdev->dev_addr, ETH_ALEN); 809 memcpy(sa.sa_data, netdev->dev_addr, ETH_ALEN);
771 octeon_mgmt_set_mac_address(netdev, &sa); 810 octeon_mgmt_set_mac_address(netdev, &sa);
@@ -782,7 +821,7 @@ static int octeon_mgmt_open(struct net_device *netdev)
782 mix_ctl.s.nbtarb = 0; /* Arbitration mode */ 821 mix_ctl.s.nbtarb = 0; /* Arbitration mode */
783 /* MII CB-request FIFO programmable high watermark */ 822 /* MII CB-request FIFO programmable high watermark */
784 mix_ctl.s.mrq_hwm = 1; 823 mix_ctl.s.mrq_hwm = 1;
785 cvmx_write_csr(CVMX_MIXX_CTL(port), mix_ctl.u64); 824 cvmx_write_csr(p->mix + MIX_CTL, mix_ctl.u64);
786 825
787 if (OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X) 826 if (OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X)
788 || OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X)) { 827 || OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X)) {
@@ -809,16 +848,16 @@ static int octeon_mgmt_open(struct net_device *netdev)
809 848
810 /* Clear statistics. */ 849 /* Clear statistics. */
811 /* Clear on read. */ 850 /* Clear on read. */
812 cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_CTL(port), 1); 851 cvmx_write_csr(p->agl + AGL_GMX_RX_STATS_CTL, 1);
813 cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(port), 0); 852 cvmx_write_csr(p->agl + AGL_GMX_RX_STATS_PKTS_DRP, 0);
814 cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(port), 0); 853 cvmx_write_csr(p->agl + AGL_GMX_RX_STATS_PKTS_BAD, 0);
815 854
816 cvmx_write_csr(CVMX_AGL_GMX_TXX_STATS_CTL(port), 1); 855 cvmx_write_csr(p->agl + AGL_GMX_TX_STATS_CTL, 1);
817 cvmx_write_csr(CVMX_AGL_GMX_TXX_STAT0(port), 0); 856 cvmx_write_csr(p->agl + AGL_GMX_TX_STAT0, 0);
818 cvmx_write_csr(CVMX_AGL_GMX_TXX_STAT1(port), 0); 857 cvmx_write_csr(p->agl + AGL_GMX_TX_STAT1, 0);
819 858
820 /* Clear any pending interrupts */ 859 /* Clear any pending interrupts */
821 cvmx_write_csr(CVMX_MIXX_ISR(port), cvmx_read_csr(CVMX_MIXX_ISR(port))); 860 cvmx_write_csr(p->mix + MIX_ISR, cvmx_read_csr(p->mix + MIX_ISR));
822 861
823 if (request_irq(p->irq, octeon_mgmt_interrupt, 0, netdev->name, 862 if (request_irq(p->irq, octeon_mgmt_interrupt, 0, netdev->name,
824 netdev)) { 863 netdev)) {
@@ -829,18 +868,18 @@ static int octeon_mgmt_open(struct net_device *netdev)
829 /* Interrupt every single RX packet */ 868 /* Interrupt every single RX packet */
830 mix_irhwm.u64 = 0; 869 mix_irhwm.u64 = 0;
831 mix_irhwm.s.irhwm = 0; 870 mix_irhwm.s.irhwm = 0;
832 cvmx_write_csr(CVMX_MIXX_IRHWM(port), mix_irhwm.u64); 871 cvmx_write_csr(p->mix + MIX_IRHWM, mix_irhwm.u64);
833 872
834 /* Interrupt when we have 1 or more packets to clean. */ 873 /* Interrupt when we have 1 or more packets to clean. */
835 mix_orhwm.u64 = 0; 874 mix_orhwm.u64 = 0;
836 mix_orhwm.s.orhwm = 1; 875 mix_orhwm.s.orhwm = 1;
837 cvmx_write_csr(CVMX_MIXX_ORHWM(port), mix_orhwm.u64); 876 cvmx_write_csr(p->mix + MIX_ORHWM, mix_orhwm.u64);
838 877
839 /* Enable receive and transmit interrupts */ 878 /* Enable receive and transmit interrupts */
840 mix_intena.u64 = 0; 879 mix_intena.u64 = 0;
841 mix_intena.s.ithena = 1; 880 mix_intena.s.ithena = 1;
842 mix_intena.s.othena = 1; 881 mix_intena.s.othena = 1;
843 cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64); 882 cvmx_write_csr(p->mix + MIX_INTENA, mix_intena.u64);
844 883
845 884
846 /* Enable packet I/O. */ 885 /* Enable packet I/O. */
@@ -871,7 +910,7 @@ static int octeon_mgmt_open(struct net_device *netdev)
871 * frame. GMX checks that the PREAMBLE is sent correctly. 910 * frame. GMX checks that the PREAMBLE is sent correctly.
872 */ 911 */
873 rxx_frm_ctl.s.pre_chk = 1; 912 rxx_frm_ctl.s.pre_chk = 1;
874 cvmx_write_csr(CVMX_AGL_GMX_RXX_FRM_CTL(port), rxx_frm_ctl.u64); 913 cvmx_write_csr(p->agl + AGL_GMX_RX_FRM_CTL, rxx_frm_ctl.u64);
875 914
876 /* Enable the AGL block */ 915 /* Enable the AGL block */
877 agl_gmx_inf_mode.u64 = 0; 916 agl_gmx_inf_mode.u64 = 0;
@@ -879,13 +918,13 @@ static int octeon_mgmt_open(struct net_device *netdev)
879 cvmx_write_csr(CVMX_AGL_GMX_INF_MODE, agl_gmx_inf_mode.u64); 918 cvmx_write_csr(CVMX_AGL_GMX_INF_MODE, agl_gmx_inf_mode.u64);
880 919
881 /* Configure the port duplex and enables */ 920 /* Configure the port duplex and enables */
882 prtx_cfg.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port)); 921 prtx_cfg.u64 = cvmx_read_csr(p->agl + AGL_GMX_PRT_CFG);
883 prtx_cfg.s.tx_en = 1; 922 prtx_cfg.s.tx_en = 1;
884 prtx_cfg.s.rx_en = 1; 923 prtx_cfg.s.rx_en = 1;
885 prtx_cfg.s.en = 1; 924 prtx_cfg.s.en = 1;
886 p->last_duplex = 1; 925 p->last_duplex = 1;
887 prtx_cfg.s.duplex = p->last_duplex; 926 prtx_cfg.s.duplex = p->last_duplex;
888 cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), prtx_cfg.u64); 927 cvmx_write_csr(p->agl + AGL_GMX_PRT_CFG, prtx_cfg.u64);
889 928
890 p->last_link = 0; 929 p->last_link = 0;
891 netif_carrier_off(netdev); 930 netif_carrier_off(netdev);
@@ -949,7 +988,6 @@ static int octeon_mgmt_stop(struct net_device *netdev)
949static int octeon_mgmt_xmit(struct sk_buff *skb, struct net_device *netdev) 988static int octeon_mgmt_xmit(struct sk_buff *skb, struct net_device *netdev)
950{ 989{
951 struct octeon_mgmt *p = netdev_priv(netdev); 990 struct octeon_mgmt *p = netdev_priv(netdev);
952 int port = p->port;
953 union mgmt_port_ring_entry re; 991 union mgmt_port_ring_entry re;
954 unsigned long flags; 992 unsigned long flags;
955 int rv = NETDEV_TX_BUSY; 993 int rv = NETDEV_TX_BUSY;
@@ -993,7 +1031,7 @@ static int octeon_mgmt_xmit(struct sk_buff *skb, struct net_device *netdev)
993 netdev->stats.tx_bytes += skb->len; 1031 netdev->stats.tx_bytes += skb->len;
994 1032
995 /* Ring the bell. */ 1033 /* Ring the bell. */
996 cvmx_write_csr(CVMX_MIXX_ORING2(port), 1); 1034 cvmx_write_csr(p->mix + MIX_ORING2, 1);
997 1035
998 rv = NETDEV_TX_OK; 1036 rv = NETDEV_TX_OK;
999out: 1037out:
@@ -1071,10 +1109,14 @@ static const struct net_device_ops octeon_mgmt_ops = {
1071 1109
1072static int __devinit octeon_mgmt_probe(struct platform_device *pdev) 1110static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
1073{ 1111{
1074 struct resource *res_irq;
1075 struct net_device *netdev; 1112 struct net_device *netdev;
1076 struct octeon_mgmt *p; 1113 struct octeon_mgmt *p;
1077 int i; 1114 const __be32 *data;
1115 const u8 *mac;
1116 struct resource *res_mix;
1117 struct resource *res_agl;
1118 int len;
1119 int result;
1078 1120
1079 netdev = alloc_etherdev(sizeof(struct octeon_mgmt)); 1121 netdev = alloc_etherdev(sizeof(struct octeon_mgmt));
1080 if (netdev == NULL) 1122 if (netdev == NULL)
@@ -1088,14 +1130,63 @@ static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
1088 p->netdev = netdev; 1130 p->netdev = netdev;
1089 p->dev = &pdev->dev; 1131 p->dev = &pdev->dev;
1090 1132
1091 p->port = pdev->id; 1133 data = of_get_property(pdev->dev.of_node, "cell-index", &len);
1134 if (data && len == sizeof(*data)) {
1135 p->port = be32_to_cpup(data);
1136 } else {
1137 dev_err(&pdev->dev, "no 'cell-index' property\n");
1138 result = -ENXIO;
1139 goto err;
1140 }
1141
1092 snprintf(netdev->name, IFNAMSIZ, "mgmt%d", p->port); 1142 snprintf(netdev->name, IFNAMSIZ, "mgmt%d", p->port);
1093 1143
1094 res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1144 result = platform_get_irq(pdev, 0);
1095 if (!res_irq) 1145 if (result < 0)
1146 goto err;
1147
1148 p->irq = result;
1149
1150 res_mix = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1151 if (res_mix == NULL) {
1152 dev_err(&pdev->dev, "no 'reg' resource\n");
1153 result = -ENXIO;
1154 goto err;
1155 }
1156
1157 res_agl = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1158 if (res_agl == NULL) {
1159 dev_err(&pdev->dev, "no 'reg' resource\n");
1160 result = -ENXIO;
1161 goto err;
1162 }
1163
1164 p->mix_phys = res_mix->start;
1165 p->mix_size = resource_size(res_mix);
1166 p->agl_phys = res_agl->start;
1167 p->agl_size = resource_size(res_agl);
1168
1169
1170 if (!devm_request_mem_region(&pdev->dev, p->mix_phys, p->mix_size,
1171 res_mix->name)) {
1172 dev_err(&pdev->dev, "request_mem_region (%s) failed\n",
1173 res_mix->name);
1174 result = -ENXIO;
1175 goto err;
1176 }
1177
1178 if (!devm_request_mem_region(&pdev->dev, p->agl_phys, p->agl_size,
1179 res_agl->name)) {
1180 result = -ENXIO;
1181 dev_err(&pdev->dev, "request_mem_region (%s) failed\n",
1182 res_agl->name);
1096 goto err; 1183 goto err;
1184 }
1185
1186
1187 p->mix = (u64)devm_ioremap(&pdev->dev, p->mix_phys, p->mix_size);
1188 p->agl = (u64)devm_ioremap(&pdev->dev, p->agl_phys, p->agl_size);
1097 1189
1098 p->irq = res_irq->start;
1099 spin_lock_init(&p->lock); 1190 spin_lock_init(&p->lock);
1100 1191
1101 skb_queue_head_init(&p->tx_list); 1192 skb_queue_head_init(&p->tx_list);
@@ -1108,24 +1199,26 @@ static int __devinit octeon_mgmt_probe(struct platform_device *pdev)
1108 netdev->netdev_ops = &octeon_mgmt_ops; 1199 netdev->netdev_ops = &octeon_mgmt_ops;
1109 netdev->ethtool_ops = &octeon_mgmt_ethtool_ops; 1200 netdev->ethtool_ops = &octeon_mgmt_ethtool_ops;
1110 1201
1111 /* The mgmt ports get the first N MACs. */ 1202 mac = of_get_mac_address(pdev->dev.of_node);
1112 for (i = 0; i < 6; i++) 1203
1113 netdev->dev_addr[i] = octeon_bootinfo->mac_addr_base[i]; 1204 if (mac)
1114 netdev->dev_addr[5] += p->port; 1205 memcpy(netdev->dev_addr, mac, 6);
1115 1206
1116 if (p->port >= octeon_bootinfo->mac_addr_count) 1207 p->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
1117 dev_err(&pdev->dev,
1118 "Error %s: Using MAC outside of the assigned range: %pM\n",
1119 netdev->name, netdev->dev_addr);
1120 1208
1121 if (register_netdev(netdev)) 1209 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(64);
1210 pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
1211
1212 result = register_netdev(netdev);
1213 if (result)
1122 goto err; 1214 goto err;
1123 1215
1124 dev_info(&pdev->dev, "Version " DRV_VERSION "\n"); 1216 dev_info(&pdev->dev, "Version " DRV_VERSION "\n");
1125 return 0; 1217 return 0;
1218
1126err: 1219err:
1127 free_netdev(netdev); 1220 free_netdev(netdev);
1128 return -ENOENT; 1221 return result;
1129} 1222}
1130 1223
1131static int __devexit octeon_mgmt_remove(struct platform_device *pdev) 1224static int __devexit octeon_mgmt_remove(struct platform_device *pdev)
@@ -1137,10 +1230,19 @@ static int __devexit octeon_mgmt_remove(struct platform_device *pdev)
1137 return 0; 1230 return 0;
1138} 1231}
1139 1232
1233static struct of_device_id octeon_mgmt_match[] = {
1234 {
1235 .compatible = "cavium,octeon-5750-mix",
1236 },
1237 {},
1238};
1239MODULE_DEVICE_TABLE(of, octeon_mgmt_match);
1240
1140static struct platform_driver octeon_mgmt_driver = { 1241static struct platform_driver octeon_mgmt_driver = {
1141 .driver = { 1242 .driver = {
1142 .name = "octeon_mgmt", 1243 .name = "octeon_mgmt",
1143 .owner = THIS_MODULE, 1244 .owner = THIS_MODULE,
1245 .of_match_table = octeon_mgmt_match,
1144 }, 1246 },
1145 .probe = octeon_mgmt_probe, 1247 .probe = octeon_mgmt_probe,
1146 .remove = __devexit_p(octeon_mgmt_remove), 1248 .remove = __devexit_p(octeon_mgmt_remove),
diff --git a/drivers/net/phy/mdio-octeon.c b/drivers/net/phy/mdio-octeon.c
index 826d961f39f7..d4015aa663e6 100644
--- a/drivers/net/phy/mdio-octeon.c
+++ b/drivers/net/phy/mdio-octeon.c
@@ -3,14 +3,17 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2009 Cavium Networks 6 * Copyright (C) 2009,2011 Cavium, Inc.
7 */ 7 */
8 8
9#include <linux/gfp.h>
10#include <linux/init.h>
11#include <linux/module.h>
12#include <linux/platform_device.h> 9#include <linux/platform_device.h>
10#include <linux/of_mdio.h>
11#include <linux/delay.h>
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/gfp.h>
13#include <linux/phy.h> 15#include <linux/phy.h>
16#include <linux/io.h>
14 17
15#include <asm/octeon/octeon.h> 18#include <asm/octeon/octeon.h>
16#include <asm/octeon/cvmx-smix-defs.h> 19#include <asm/octeon/cvmx-smix-defs.h>
@@ -18,9 +21,17 @@
18#define DRV_VERSION "1.0" 21#define DRV_VERSION "1.0"
19#define DRV_DESCRIPTION "Cavium Networks Octeon SMI/MDIO driver" 22#define DRV_DESCRIPTION "Cavium Networks Octeon SMI/MDIO driver"
20 23
24#define SMI_CMD 0x0
25#define SMI_WR_DAT 0x8
26#define SMI_RD_DAT 0x10
27#define SMI_CLK 0x18
28#define SMI_EN 0x20
29
21struct octeon_mdiobus { 30struct octeon_mdiobus {
22 struct mii_bus *mii_bus; 31 struct mii_bus *mii_bus;
23 int unit; 32 u64 register_base;
33 resource_size_t mdio_phys;
34 resource_size_t regsize;
24 int phy_irq[PHY_MAX_ADDR]; 35 int phy_irq[PHY_MAX_ADDR];
25}; 36};
26 37
@@ -35,15 +46,15 @@ static int octeon_mdiobus_read(struct mii_bus *bus, int phy_id, int regnum)
35 smi_cmd.s.phy_op = 1; /* MDIO_CLAUSE_22_READ */ 46 smi_cmd.s.phy_op = 1; /* MDIO_CLAUSE_22_READ */
36 smi_cmd.s.phy_adr = phy_id; 47 smi_cmd.s.phy_adr = phy_id;
37 smi_cmd.s.reg_adr = regnum; 48 smi_cmd.s.reg_adr = regnum;
38 cvmx_write_csr(CVMX_SMIX_CMD(p->unit), smi_cmd.u64); 49 cvmx_write_csr(p->register_base + SMI_CMD, smi_cmd.u64);
39 50
40 do { 51 do {
41 /* 52 /*
42 * Wait 1000 clocks so we don't saturate the RSL bus 53 * Wait 1000 clocks so we don't saturate the RSL bus
43 * doing reads. 54 * doing reads.
44 */ 55 */
45 cvmx_wait(1000); 56 __delay(1000);
46 smi_rd.u64 = cvmx_read_csr(CVMX_SMIX_RD_DAT(p->unit)); 57 smi_rd.u64 = cvmx_read_csr(p->register_base + SMI_RD_DAT);
47 } while (smi_rd.s.pending && --timeout); 58 } while (smi_rd.s.pending && --timeout);
48 59
49 if (smi_rd.s.val) 60 if (smi_rd.s.val)
@@ -62,21 +73,21 @@ static int octeon_mdiobus_write(struct mii_bus *bus, int phy_id,
62 73
63 smi_wr.u64 = 0; 74 smi_wr.u64 = 0;
64 smi_wr.s.dat = val; 75 smi_wr.s.dat = val;
65 cvmx_write_csr(CVMX_SMIX_WR_DAT(p->unit), smi_wr.u64); 76 cvmx_write_csr(p->register_base + SMI_WR_DAT, smi_wr.u64);
66 77
67 smi_cmd.u64 = 0; 78 smi_cmd.u64 = 0;
68 smi_cmd.s.phy_op = 0; /* MDIO_CLAUSE_22_WRITE */ 79 smi_cmd.s.phy_op = 0; /* MDIO_CLAUSE_22_WRITE */
69 smi_cmd.s.phy_adr = phy_id; 80 smi_cmd.s.phy_adr = phy_id;
70 smi_cmd.s.reg_adr = regnum; 81 smi_cmd.s.reg_adr = regnum;
71 cvmx_write_csr(CVMX_SMIX_CMD(p->unit), smi_cmd.u64); 82 cvmx_write_csr(p->register_base + SMI_CMD, smi_cmd.u64);
72 83
73 do { 84 do {
74 /* 85 /*
75 * Wait 1000 clocks so we don't saturate the RSL bus 86 * Wait 1000 clocks so we don't saturate the RSL bus
76 * doing reads. 87 * doing reads.
77 */ 88 */
78 cvmx_wait(1000); 89 __delay(1000);
79 smi_wr.u64 = cvmx_read_csr(CVMX_SMIX_WR_DAT(p->unit)); 90 smi_wr.u64 = cvmx_read_csr(p->register_base + SMI_WR_DAT);
80 } while (smi_wr.s.pending && --timeout); 91 } while (smi_wr.s.pending && --timeout);
81 92
82 if (timeout <= 0) 93 if (timeout <= 0)
@@ -88,38 +99,44 @@ static int octeon_mdiobus_write(struct mii_bus *bus, int phy_id,
88static int __devinit octeon_mdiobus_probe(struct platform_device *pdev) 99static int __devinit octeon_mdiobus_probe(struct platform_device *pdev)
89{ 100{
90 struct octeon_mdiobus *bus; 101 struct octeon_mdiobus *bus;
102 struct resource *res_mem;
91 union cvmx_smix_en smi_en; 103 union cvmx_smix_en smi_en;
92 int i;
93 int err = -ENOENT; 104 int err = -ENOENT;
94 105
95 bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); 106 bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL);
96 if (!bus) 107 if (!bus)
97 return -ENOMEM; 108 return -ENOMEM;
98 109
99 /* The platform_device id is our unit number. */ 110 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
100 bus->unit = pdev->id; 111
112 if (res_mem == NULL) {
113 dev_err(&pdev->dev, "found no memory resource\n");
114 err = -ENXIO;
115 goto fail;
116 }
117 bus->mdio_phys = res_mem->start;
118 bus->regsize = resource_size(res_mem);
119 if (!devm_request_mem_region(&pdev->dev, bus->mdio_phys, bus->regsize,
120 res_mem->name)) {
121 dev_err(&pdev->dev, "request_mem_region failed\n");
122 goto fail;
123 }
124 bus->register_base =
125 (u64)devm_ioremap(&pdev->dev, bus->mdio_phys, bus->regsize);
101 126
102 bus->mii_bus = mdiobus_alloc(); 127 bus->mii_bus = mdiobus_alloc();
103 128
104 if (!bus->mii_bus) 129 if (!bus->mii_bus)
105 goto err; 130 goto fail;
106 131
107 smi_en.u64 = 0; 132 smi_en.u64 = 0;
108 smi_en.s.en = 1; 133 smi_en.s.en = 1;
109 cvmx_write_csr(CVMX_SMIX_EN(bus->unit), smi_en.u64); 134 cvmx_write_csr(bus->register_base + SMI_EN, smi_en.u64);
110
111 /*
112 * Standard Octeon evaluation boards don't support phy
113 * interrupts, we need to poll.
114 */
115 for (i = 0; i < PHY_MAX_ADDR; i++)
116 bus->phy_irq[i] = PHY_POLL;
117 135
118 bus->mii_bus->priv = bus; 136 bus->mii_bus->priv = bus;
119 bus->mii_bus->irq = bus->phy_irq; 137 bus->mii_bus->irq = bus->phy_irq;
120 bus->mii_bus->name = "mdio-octeon"; 138 bus->mii_bus->name = "mdio-octeon";
121 snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", 139 snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%llx", bus->register_base);
122 bus->mii_bus->name, bus->unit);
123 bus->mii_bus->parent = &pdev->dev; 140 bus->mii_bus->parent = &pdev->dev;
124 141
125 bus->mii_bus->read = octeon_mdiobus_read; 142 bus->mii_bus->read = octeon_mdiobus_read;
@@ -127,20 +144,18 @@ static int __devinit octeon_mdiobus_probe(struct platform_device *pdev)
127 144
128 dev_set_drvdata(&pdev->dev, bus); 145 dev_set_drvdata(&pdev->dev, bus);
129 146
130 err = mdiobus_register(bus->mii_bus); 147 err = of_mdiobus_register(bus->mii_bus, pdev->dev.of_node);
131 if (err) 148 if (err)
132 goto err_register; 149 goto fail_register;
133 150
134 dev_info(&pdev->dev, "Version " DRV_VERSION "\n"); 151 dev_info(&pdev->dev, "Version " DRV_VERSION "\n");
135 152
136 return 0; 153 return 0;
137err_register: 154fail_register:
138 mdiobus_free(bus->mii_bus); 155 mdiobus_free(bus->mii_bus);
139 156fail:
140err:
141 devm_kfree(&pdev->dev, bus);
142 smi_en.u64 = 0; 157 smi_en.u64 = 0;
143 cvmx_write_csr(CVMX_SMIX_EN(bus->unit), smi_en.u64); 158 cvmx_write_csr(bus->register_base + SMI_EN, smi_en.u64);
144 return err; 159 return err;
145} 160}
146 161
@@ -154,14 +169,23 @@ static int __devexit octeon_mdiobus_remove(struct platform_device *pdev)
154 mdiobus_unregister(bus->mii_bus); 169 mdiobus_unregister(bus->mii_bus);
155 mdiobus_free(bus->mii_bus); 170 mdiobus_free(bus->mii_bus);
156 smi_en.u64 = 0; 171 smi_en.u64 = 0;
157 cvmx_write_csr(CVMX_SMIX_EN(bus->unit), smi_en.u64); 172 cvmx_write_csr(bus->register_base + SMI_EN, smi_en.u64);
158 return 0; 173 return 0;
159} 174}
160 175
176static struct of_device_id octeon_mdiobus_match[] = {
177 {
178 .compatible = "cavium,octeon-3860-mdio",
179 },
180 {},
181};
182MODULE_DEVICE_TABLE(of, octeon_mdiobus_match);
183
161static struct platform_driver octeon_mdiobus_driver = { 184static struct platform_driver octeon_mdiobus_driver = {
162 .driver = { 185 .driver = {
163 .name = "mdio-octeon", 186 .name = "mdio-octeon",
164 .owner = THIS_MODULE, 187 .owner = THIS_MODULE,
188 .of_match_table = octeon_mdiobus_match,
165 }, 189 },
166 .probe = octeon_mdiobus_probe, 190 .probe = octeon_mdiobus_probe,
167 .remove = __devexit_p(octeon_mdiobus_remove), 191 .remove = __devexit_p(octeon_mdiobus_remove),
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index c8f40c9c0428..3782e1cd3697 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -95,6 +95,7 @@ MODULE_ALIAS("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026");
95 95
96enum acer_wmi_event_ids { 96enum acer_wmi_event_ids {
97 WMID_HOTKEY_EVENT = 0x1, 97 WMID_HOTKEY_EVENT = 0x1,
98 WMID_ACCEL_EVENT = 0x5,
98}; 99};
99 100
100static const struct key_entry acer_wmi_keymap[] = { 101static const struct key_entry acer_wmi_keymap[] = {
@@ -130,6 +131,7 @@ static const struct key_entry acer_wmi_keymap[] = {
130}; 131};
131 132
132static struct input_dev *acer_wmi_input_dev; 133static struct input_dev *acer_wmi_input_dev;
134static struct input_dev *acer_wmi_accel_dev;
133 135
134struct event_return_value { 136struct event_return_value {
135 u8 function; 137 u8 function;
@@ -200,6 +202,7 @@ struct hotkey_function_type_aa {
200#define ACER_CAP_BLUETOOTH (1<<2) 202#define ACER_CAP_BLUETOOTH (1<<2)
201#define ACER_CAP_BRIGHTNESS (1<<3) 203#define ACER_CAP_BRIGHTNESS (1<<3)
202#define ACER_CAP_THREEG (1<<4) 204#define ACER_CAP_THREEG (1<<4)
205#define ACER_CAP_ACCEL (1<<5)
203#define ACER_CAP_ANY (0xFFFFFFFF) 206#define ACER_CAP_ANY (0xFFFFFFFF)
204 207
205/* 208/*
@@ -1399,6 +1402,60 @@ static void acer_backlight_exit(void)
1399} 1402}
1400 1403
1401/* 1404/*
1405 * Accelerometer device
1406 */
1407static acpi_handle gsensor_handle;
1408
1409static int acer_gsensor_init(void)
1410{
1411 acpi_status status;
1412 struct acpi_buffer output;
1413 union acpi_object out_obj;
1414
1415 output.length = sizeof(out_obj);
1416 output.pointer = &out_obj;
1417 status = acpi_evaluate_object(gsensor_handle, "_INI", NULL, &output);
1418 if (ACPI_FAILURE(status))
1419 return -1;
1420
1421 return 0;
1422}
1423
1424static int acer_gsensor_open(struct input_dev *input)
1425{
1426 return acer_gsensor_init();
1427}
1428
1429static int acer_gsensor_event(void)
1430{
1431 acpi_status status;
1432 struct acpi_buffer output;
1433 union acpi_object out_obj[5];
1434
1435 if (!has_cap(ACER_CAP_ACCEL))
1436 return -1;
1437
1438 output.length = sizeof(out_obj);
1439 output.pointer = out_obj;
1440
1441 status = acpi_evaluate_object(gsensor_handle, "RDVL", NULL, &output);
1442 if (ACPI_FAILURE(status))
1443 return -1;
1444
1445 if (out_obj->package.count != 4)
1446 return -1;
1447
1448 input_report_abs(acer_wmi_accel_dev, ABS_X,
1449 (s16)out_obj->package.elements[0].integer.value);
1450 input_report_abs(acer_wmi_accel_dev, ABS_Y,
1451 (s16)out_obj->package.elements[1].integer.value);
1452 input_report_abs(acer_wmi_accel_dev, ABS_Z,
1453 (s16)out_obj->package.elements[2].integer.value);
1454 input_sync(acer_wmi_accel_dev);
1455 return 0;
1456}
1457
1458/*
1402 * Rfkill devices 1459 * Rfkill devices
1403 */ 1460 */
1404static void acer_rfkill_update(struct work_struct *ignored); 1461static void acer_rfkill_update(struct work_struct *ignored);
@@ -1673,6 +1730,9 @@ static void acer_wmi_notify(u32 value, void *context)
1673 1, true); 1730 1, true);
1674 } 1731 }
1675 break; 1732 break;
1733 case WMID_ACCEL_EVENT:
1734 acer_gsensor_event();
1735 break;
1676 default: 1736 default:
1677 pr_warn("Unknown function number - %d - %d\n", 1737 pr_warn("Unknown function number - %d - %d\n",
1678 return_value.function, return_value.key_num); 1738 return_value.function, return_value.key_num);
@@ -1758,6 +1818,73 @@ static int acer_wmi_enable_lm(void)
1758 return status; 1818 return status;
1759} 1819}
1760 1820
1821static acpi_status __init acer_wmi_get_handle_cb(acpi_handle ah, u32 level,
1822 void *ctx, void **retval)
1823{
1824 *(acpi_handle *)retval = ah;
1825 return AE_OK;
1826}
1827
1828static int __init acer_wmi_get_handle(const char *name, const char *prop,
1829 acpi_handle *ah)
1830{
1831 acpi_status status;
1832 acpi_handle handle;
1833
1834 BUG_ON(!name || !ah);
1835
1836 handle = NULL;
1837 status = acpi_get_devices(prop, acer_wmi_get_handle_cb,
1838 (void *)name, &handle);
1839
1840 if (ACPI_SUCCESS(status)) {
1841 *ah = handle;
1842 return 0;
1843 } else {
1844 return -ENODEV;
1845 }
1846}
1847
1848static int __init acer_wmi_accel_setup(void)
1849{
1850 int err;
1851
1852 err = acer_wmi_get_handle("SENR", "BST0001", &gsensor_handle);
1853 if (err)
1854 return err;
1855
1856 interface->capability |= ACER_CAP_ACCEL;
1857
1858 acer_wmi_accel_dev = input_allocate_device();
1859 if (!acer_wmi_accel_dev)
1860 return -ENOMEM;
1861
1862 acer_wmi_accel_dev->open = acer_gsensor_open;
1863
1864 acer_wmi_accel_dev->name = "Acer BMA150 accelerometer";
1865 acer_wmi_accel_dev->phys = "wmi/input1";
1866 acer_wmi_accel_dev->id.bustype = BUS_HOST;
1867 acer_wmi_accel_dev->evbit[0] = BIT_MASK(EV_ABS);
1868 input_set_abs_params(acer_wmi_accel_dev, ABS_X, -16384, 16384, 0, 0);
1869 input_set_abs_params(acer_wmi_accel_dev, ABS_Y, -16384, 16384, 0, 0);
1870 input_set_abs_params(acer_wmi_accel_dev, ABS_Z, -16384, 16384, 0, 0);
1871
1872 err = input_register_device(acer_wmi_accel_dev);
1873 if (err)
1874 goto err_free_dev;
1875
1876 return 0;
1877
1878err_free_dev:
1879 input_free_device(acer_wmi_accel_dev);
1880 return err;
1881}
1882
1883static void acer_wmi_accel_destroy(void)
1884{
1885 input_unregister_device(acer_wmi_accel_dev);
1886}
1887
1761static int __init acer_wmi_input_setup(void) 1888static int __init acer_wmi_input_setup(void)
1762{ 1889{
1763 acpi_status status; 1890 acpi_status status;
@@ -1912,6 +2039,9 @@ static int acer_resume(struct device *dev)
1912 if (has_cap(ACER_CAP_BRIGHTNESS)) 2039 if (has_cap(ACER_CAP_BRIGHTNESS))
1913 set_u32(data->brightness, ACER_CAP_BRIGHTNESS); 2040 set_u32(data->brightness, ACER_CAP_BRIGHTNESS);
1914 2041
2042 if (has_cap(ACER_CAP_ACCEL))
2043 acer_gsensor_init();
2044
1915 return 0; 2045 return 0;
1916} 2046}
1917 2047
@@ -2060,14 +2190,16 @@ static int __init acer_wmi_init(void)
2060 2190
2061 set_quirks(); 2191 set_quirks();
2062 2192
2193 if (dmi_check_system(video_vendor_dmi_table))
2194 acpi_video_dmi_promote_vendor();
2063 if (acpi_video_backlight_support()) { 2195 if (acpi_video_backlight_support()) {
2064 if (dmi_check_system(video_vendor_dmi_table)) { 2196 interface->capability &= ~ACER_CAP_BRIGHTNESS;
2065 acpi_video_unregister(); 2197 pr_info("Brightness must be controlled by acpi video driver\n");
2066 } else { 2198 } else {
2067 interface->capability &= ~ACER_CAP_BRIGHTNESS; 2199#ifdef CONFIG_ACPI_VIDEO
2068 pr_info("Brightness must be controlled by " 2200 pr_info("Disabling ACPI video driver\n");
2069 "acpi video driver\n"); 2201 acpi_video_unregister();
2070 } 2202#endif
2071 } 2203 }
2072 2204
2073 if (wmi_has_guid(WMID_GUID3)) { 2205 if (wmi_has_guid(WMID_GUID3)) {
@@ -2090,6 +2222,8 @@ static int __init acer_wmi_init(void)
2090 return err; 2222 return err;
2091 } 2223 }
2092 2224
2225 acer_wmi_accel_setup();
2226
2093 err = platform_driver_register(&acer_platform_driver); 2227 err = platform_driver_register(&acer_platform_driver);
2094 if (err) { 2228 if (err) {
2095 pr_err("Unable to register platform driver\n"); 2229 pr_err("Unable to register platform driver\n");
@@ -2133,6 +2267,8 @@ error_device_alloc:
2133error_platform_register: 2267error_platform_register:
2134 if (wmi_has_guid(ACERWMID_EVENT_GUID)) 2268 if (wmi_has_guid(ACERWMID_EVENT_GUID))
2135 acer_wmi_input_destroy(); 2269 acer_wmi_input_destroy();
2270 if (has_cap(ACER_CAP_ACCEL))
2271 acer_wmi_accel_destroy();
2136 2272
2137 return err; 2273 return err;
2138} 2274}
@@ -2142,6 +2278,9 @@ static void __exit acer_wmi_exit(void)
2142 if (wmi_has_guid(ACERWMID_EVENT_GUID)) 2278 if (wmi_has_guid(ACERWMID_EVENT_GUID))
2143 acer_wmi_input_destroy(); 2279 acer_wmi_input_destroy();
2144 2280
2281 if (has_cap(ACER_CAP_ACCEL))
2282 acer_wmi_accel_destroy();
2283
2145 remove_sysfs(acer_platform_device); 2284 remove_sysfs(acer_platform_device);
2146 remove_debugfs(); 2285 remove_debugfs();
2147 platform_device_unregister(acer_platform_device); 2286 platform_device_unregister(acer_platform_device);
diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
index 694a15a56230..905fa01ac8df 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -193,7 +193,10 @@ static int __devinit gmux_probe(struct pnp_dev *pnp,
193 * backlight control and supports more levels than other options. 193 * backlight control and supports more levels than other options.
194 * Disable the other backlight choices. 194 * Disable the other backlight choices.
195 */ 195 */
196 acpi_video_dmi_promote_vendor();
197#ifdef CONFIG_ACPI_VIDEO
196 acpi_video_unregister(); 198 acpi_video_unregister();
199#endif
197 apple_bl_unregister(); 200 apple_bl_unregister();
198 201
199 return 0; 202 return 0;
@@ -213,7 +216,10 @@ static void __devexit gmux_remove(struct pnp_dev *pnp)
213 release_region(gmux_data->iostart, gmux_data->iolen); 216 release_region(gmux_data->iostart, gmux_data->iolen);
214 kfree(gmux_data); 217 kfree(gmux_data);
215 218
219 acpi_video_dmi_demote_vendor();
220#ifdef CONFIG_ACPI_VIDEO
216 acpi_video_register(); 221 acpi_video_register();
222#endif
217 apple_bl_register(); 223 apple_bl_register();
218} 224}
219 225
diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
index 99a30b513137..6b0ebdeae916 100644
--- a/drivers/platform/x86/asus-nb-wmi.c
+++ b/drivers/platform/x86/asus-nb-wmi.c
@@ -26,6 +26,7 @@
26#include <linux/input.h> 26#include <linux/input.h>
27#include <linux/input/sparse-keymap.h> 27#include <linux/input/sparse-keymap.h>
28#include <linux/fb.h> 28#include <linux/fb.h>
29#include <linux/dmi.h>
29 30
30#include "asus-wmi.h" 31#include "asus-wmi.h"
31 32
@@ -48,18 +49,115 @@ MODULE_ALIAS("wmi:"ASUS_NB_WMI_EVENT_GUID);
48 * 1 | Hardware | Software 49 * 1 | Hardware | Software
49 * 4 | Software | Software 50 * 4 | Software | Software
50 */ 51 */
51static uint wapf; 52static int wapf = -1;
52module_param(wapf, uint, 0444); 53module_param(wapf, uint, 0444);
53MODULE_PARM_DESC(wapf, "WAPF value"); 54MODULE_PARM_DESC(wapf, "WAPF value");
54 55
56static struct quirk_entry *quirks;
57
55static struct quirk_entry quirk_asus_unknown = { 58static struct quirk_entry quirk_asus_unknown = {
59 .wapf = 0,
60};
61
62static struct quirk_entry quirk_asus_x401u = {
63 .wapf = 4,
64};
65
66static int dmi_matched(const struct dmi_system_id *dmi)
67{
68 quirks = dmi->driver_data;
69 return 1;
70}
71
72static struct dmi_system_id asus_quirks[] = {
73 {
74 .callback = dmi_matched,
75 .ident = "ASUSTeK COMPUTER INC. X401U",
76 .matches = {
77 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
78 DMI_MATCH(DMI_PRODUCT_NAME, "X401U"),
79 },
80 .driver_data = &quirk_asus_x401u,
81 },
82 {
83 .callback = dmi_matched,
84 .ident = "ASUSTeK COMPUTER INC. X401A1",
85 .matches = {
86 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
87 DMI_MATCH(DMI_PRODUCT_NAME, "X401A1"),
88 },
89 .driver_data = &quirk_asus_x401u,
90 },
91 {
92 .callback = dmi_matched,
93 .ident = "ASUSTeK COMPUTER INC. X501U",
94 .matches = {
95 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
96 DMI_MATCH(DMI_PRODUCT_NAME, "X501U"),
97 },
98 .driver_data = &quirk_asus_x401u,
99 },
100 {
101 .callback = dmi_matched,
102 .ident = "ASUSTeK COMPUTER INC. X501A1",
103 .matches = {
104 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
105 DMI_MATCH(DMI_PRODUCT_NAME, "X501A1"),
106 },
107 .driver_data = &quirk_asus_x401u,
108 },
109 {
110 .callback = dmi_matched,
111 .ident = "ASUSTeK COMPUTER INC. X55A",
112 .matches = {
113 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
114 DMI_MATCH(DMI_PRODUCT_NAME, "X55A"),
115 },
116 .driver_data = &quirk_asus_x401u,
117 },
118 {
119 .callback = dmi_matched,
120 .ident = "ASUSTeK COMPUTER INC. X55C",
121 .matches = {
122 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
123 DMI_MATCH(DMI_PRODUCT_NAME, "X55C"),
124 },
125 .driver_data = &quirk_asus_x401u,
126 },
127 {
128 .callback = dmi_matched,
129 .ident = "ASUSTeK COMPUTER INC. X55U",
130 .matches = {
131 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
132 DMI_MATCH(DMI_PRODUCT_NAME, "X55U"),
133 },
134 .driver_data = &quirk_asus_x401u,
135 },
136 {
137 .callback = dmi_matched,
138 .ident = "ASUSTeK COMPUTER INC. X55VD",
139 .matches = {
140 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
141 DMI_MATCH(DMI_PRODUCT_NAME, "X55VD"),
142 },
143 .driver_data = &quirk_asus_x401u,
144 },
145 {},
56}; 146};
57 147
58static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver) 148static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
59{ 149{
60 driver->quirks = &quirk_asus_unknown; 150 quirks = &quirk_asus_unknown;
61 driver->quirks->wapf = wapf; 151 dmi_check_system(asus_quirks);
152
153 driver->quirks = quirks;
62 driver->panel_power = FB_BLANK_UNBLANK; 154 driver->panel_power = FB_BLANK_UNBLANK;
155
156 /* overwrite the wapf setting if the wapf paramater is specified */
157 if (wapf != -1)
158 quirks->wapf = wapf;
159 else
160 wapf = quirks->wapf;
63} 161}
64 162
65static const struct key_entry asus_nb_wmi_keymap[] = { 163static const struct key_entry asus_nb_wmi_keymap[] = {
@@ -94,6 +192,10 @@ static const struct key_entry asus_nb_wmi_keymap[] = {
94 { KE_KEY, 0x8A, { KEY_PROG1 } }, 192 { KE_KEY, 0x8A, { KEY_PROG1 } },
95 { KE_KEY, 0x95, { KEY_MEDIA } }, 193 { KE_KEY, 0x95, { KEY_MEDIA } },
96 { KE_KEY, 0x99, { KEY_PHONE } }, 194 { KE_KEY, 0x99, { KEY_PHONE } },
195 { KE_KEY, 0xA0, { KEY_SWITCHVIDEOMODE } }, /* SDSP HDMI only */
196 { KE_KEY, 0xA1, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + HDMI */
197 { KE_KEY, 0xA2, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + HDMI */
198 { KE_KEY, 0xA3, { KEY_SWITCHVIDEOMODE } }, /* SDSP TV + HDMI */
97 { KE_KEY, 0xb5, { KEY_CALC } }, 199 { KE_KEY, 0xb5, { KEY_CALC } },
98 { KE_KEY, 0xc4, { KEY_KBDILLUMUP } }, 200 { KE_KEY, 0xc4, { KEY_KBDILLUMUP } },
99 { KE_KEY, 0xc5, { KEY_KBDILLUMDOWN } }, 201 { KE_KEY, 0xc5, { KEY_KBDILLUMDOWN } },
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 77aadde5281c..c7a36f6b0580 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -47,6 +47,9 @@
47#include <linux/thermal.h> 47#include <linux/thermal.h>
48#include <acpi/acpi_bus.h> 48#include <acpi/acpi_bus.h>
49#include <acpi/acpi_drivers.h> 49#include <acpi/acpi_drivers.h>
50#ifdef CONFIG_ACPI_VIDEO
51#include <acpi/video.h>
52#endif
50 53
51#include "asus-wmi.h" 54#include "asus-wmi.h"
52 55
@@ -136,6 +139,9 @@ MODULE_LICENSE("GPL");
136/* Power */ 139/* Power */
137#define ASUS_WMI_DEVID_PROCESSOR_STATE 0x00120012 140#define ASUS_WMI_DEVID_PROCESSOR_STATE 0x00120012
138 141
142/* Deep S3 / Resume on LID open */
143#define ASUS_WMI_DEVID_LID_RESUME 0x00120031
144
139/* DSTS masks */ 145/* DSTS masks */
140#define ASUS_WMI_DSTS_STATUS_BIT 0x00000001 146#define ASUS_WMI_DSTS_STATUS_BIT 0x00000001
141#define ASUS_WMI_DSTS_UNKNOWN_BIT 0x00000002 147#define ASUS_WMI_DSTS_UNKNOWN_BIT 0x00000002
@@ -1365,6 +1371,7 @@ static ssize_t show_sys_wmi(struct asus_wmi *asus, int devid, char *buf)
1365ASUS_WMI_CREATE_DEVICE_ATTR(touchpad, 0644, ASUS_WMI_DEVID_TOUCHPAD); 1371ASUS_WMI_CREATE_DEVICE_ATTR(touchpad, 0644, ASUS_WMI_DEVID_TOUCHPAD);
1366ASUS_WMI_CREATE_DEVICE_ATTR(camera, 0644, ASUS_WMI_DEVID_CAMERA); 1372ASUS_WMI_CREATE_DEVICE_ATTR(camera, 0644, ASUS_WMI_DEVID_CAMERA);
1367ASUS_WMI_CREATE_DEVICE_ATTR(cardr, 0644, ASUS_WMI_DEVID_CARDREADER); 1373ASUS_WMI_CREATE_DEVICE_ATTR(cardr, 0644, ASUS_WMI_DEVID_CARDREADER);
1374ASUS_WMI_CREATE_DEVICE_ATTR(lid_resume, 0644, ASUS_WMI_DEVID_LID_RESUME);
1368 1375
1369static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr, 1376static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr,
1370 const char *buf, size_t count) 1377 const char *buf, size_t count)
@@ -1390,6 +1397,7 @@ static struct attribute *platform_attributes[] = {
1390 &dev_attr_camera.attr, 1397 &dev_attr_camera.attr,
1391 &dev_attr_cardr.attr, 1398 &dev_attr_cardr.attr,
1392 &dev_attr_touchpad.attr, 1399 &dev_attr_touchpad.attr,
1400 &dev_attr_lid_resume.attr,
1393 NULL 1401 NULL
1394}; 1402};
1395 1403
@@ -1408,6 +1416,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
1408 devid = ASUS_WMI_DEVID_CARDREADER; 1416 devid = ASUS_WMI_DEVID_CARDREADER;
1409 else if (attr == &dev_attr_touchpad.attr) 1417 else if (attr == &dev_attr_touchpad.attr)
1410 devid = ASUS_WMI_DEVID_TOUCHPAD; 1418 devid = ASUS_WMI_DEVID_TOUCHPAD;
1419 else if (attr == &dev_attr_lid_resume.attr)
1420 devid = ASUS_WMI_DEVID_LID_RESUME;
1411 1421
1412 if (devid != -1) 1422 if (devid != -1)
1413 ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0); 1423 ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
@@ -1467,14 +1477,9 @@ static int asus_wmi_platform_init(struct asus_wmi *asus)
1467 */ 1477 */
1468 if (!asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS, 0, 0, NULL)) 1478 if (!asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS, 0, 0, NULL))
1469 asus->dsts_id = ASUS_WMI_METHODID_DSTS; 1479 asus->dsts_id = ASUS_WMI_METHODID_DSTS;
1470 else if (!asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS2, 0, 0, NULL)) 1480 else
1471 asus->dsts_id = ASUS_WMI_METHODID_DSTS2; 1481 asus->dsts_id = ASUS_WMI_METHODID_DSTS2;
1472 1482
1473 if (!asus->dsts_id) {
1474 pr_err("Can't find DSTS");
1475 return -ENODEV;
1476 }
1477
1478 /* CWAP allow to define the behavior of the Fn+F2 key, 1483 /* CWAP allow to define the behavior of the Fn+F2 key,
1479 * this method doesn't seems to be present on Eee PCs */ 1484 * this method doesn't seems to be present on Eee PCs */
1480 if (asus->driver->quirks->wapf >= 0) 1485 if (asus->driver->quirks->wapf >= 0)
@@ -1681,7 +1686,13 @@ static int asus_wmi_add(struct platform_device *pdev)
1681 if (err) 1686 if (err)
1682 goto fail_rfkill; 1687 goto fail_rfkill;
1683 1688
1689 if (asus->driver->quirks->wmi_backlight_power)
1690 acpi_video_dmi_promote_vendor();
1684 if (!acpi_video_backlight_support()) { 1691 if (!acpi_video_backlight_support()) {
1692#ifdef CONFIG_ACPI_VIDEO
1693 pr_info("Disabling ACPI video driver\n");
1694 acpi_video_unregister();
1695#endif
1685 err = asus_wmi_backlight_init(asus); 1696 err = asus_wmi_backlight_init(asus);
1686 if (err && err != -ENODEV) 1697 if (err && err != -ENODEV)
1687 goto fail_backlight; 1698 goto fail_backlight;
diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h
index d43b66742004..9c1da8b81bea 100644
--- a/drivers/platform/x86/asus-wmi.h
+++ b/drivers/platform/x86/asus-wmi.h
@@ -39,6 +39,7 @@ struct quirk_entry {
39 bool hotplug_wireless; 39 bool hotplug_wireless;
40 bool scalar_panel_brightness; 40 bool scalar_panel_brightness;
41 bool store_backlight_power; 41 bool store_backlight_power;
42 bool wmi_backlight_power;
42 int wapf; 43 int wapf;
43}; 44};
44 45
diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index e2230a2b2f8e..2ca7dd1ab3e4 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -31,15 +31,21 @@ MODULE_LICENSE("GPL");
31 31
32struct cmpc_accel { 32struct cmpc_accel {
33 int sensitivity; 33 int sensitivity;
34 int g_select;
35 int inputdev_state;
34}; 36};
35 37
36#define CMPC_ACCEL_SENSITIVITY_DEFAULT 5 38#define CMPC_ACCEL_DEV_STATE_CLOSED 0
39#define CMPC_ACCEL_DEV_STATE_OPEN 1
37 40
41#define CMPC_ACCEL_SENSITIVITY_DEFAULT 5
42#define CMPC_ACCEL_G_SELECT_DEFAULT 0
38 43
39#define CMPC_ACCEL_HID "ACCE0000" 44#define CMPC_ACCEL_HID "ACCE0000"
45#define CMPC_ACCEL_HID_V4 "ACCE0001"
40#define CMPC_TABLET_HID "TBLT0000" 46#define CMPC_TABLET_HID "TBLT0000"
41#define CMPC_IPML_HID "IPML200" 47#define CMPC_IPML_HID "IPML200"
42#define CMPC_KEYS_HID "FnBT0000" 48#define CMPC_KEYS_HID "FNBT0000"
43 49
44/* 50/*
45 * Generic input device code. 51 * Generic input device code.
@@ -76,7 +82,391 @@ static int cmpc_remove_acpi_notify_device(struct acpi_device *acpi)
76} 82}
77 83
78/* 84/*
79 * Accelerometer code. 85 * Accelerometer code for Classmate V4
86 */
87static acpi_status cmpc_start_accel_v4(acpi_handle handle)
88{
89 union acpi_object param[4];
90 struct acpi_object_list input;
91 acpi_status status;
92
93 param[0].type = ACPI_TYPE_INTEGER;
94 param[0].integer.value = 0x3;
95 param[1].type = ACPI_TYPE_INTEGER;
96 param[1].integer.value = 0;
97 param[2].type = ACPI_TYPE_INTEGER;
98 param[2].integer.value = 0;
99 param[3].type = ACPI_TYPE_INTEGER;
100 param[3].integer.value = 0;
101 input.count = 4;
102 input.pointer = param;
103 status = acpi_evaluate_object(handle, "ACMD", &input, NULL);
104 return status;
105}
106
107static acpi_status cmpc_stop_accel_v4(acpi_handle handle)
108{
109 union acpi_object param[4];
110 struct acpi_object_list input;
111 acpi_status status;
112
113 param[0].type = ACPI_TYPE_INTEGER;
114 param[0].integer.value = 0x4;
115 param[1].type = ACPI_TYPE_INTEGER;
116 param[1].integer.value = 0;
117 param[2].type = ACPI_TYPE_INTEGER;
118 param[2].integer.value = 0;
119 param[3].type = ACPI_TYPE_INTEGER;
120 param[3].integer.value = 0;
121 input.count = 4;
122 input.pointer = param;
123 status = acpi_evaluate_object(handle, "ACMD", &input, NULL);
124 return status;
125}
126
127static acpi_status cmpc_accel_set_sensitivity_v4(acpi_handle handle, int val)
128{
129 union acpi_object param[4];
130 struct acpi_object_list input;
131
132 param[0].type = ACPI_TYPE_INTEGER;
133 param[0].integer.value = 0x02;
134 param[1].type = ACPI_TYPE_INTEGER;
135 param[1].integer.value = val;
136 param[2].type = ACPI_TYPE_INTEGER;
137 param[2].integer.value = 0;
138 param[3].type = ACPI_TYPE_INTEGER;
139 param[3].integer.value = 0;
140 input.count = 4;
141 input.pointer = param;
142 return acpi_evaluate_object(handle, "ACMD", &input, NULL);
143}
144
145static acpi_status cmpc_accel_set_g_select_v4(acpi_handle handle, int val)
146{
147 union acpi_object param[4];
148 struct acpi_object_list input;
149
150 param[0].type = ACPI_TYPE_INTEGER;
151 param[0].integer.value = 0x05;
152 param[1].type = ACPI_TYPE_INTEGER;
153 param[1].integer.value = val;
154 param[2].type = ACPI_TYPE_INTEGER;
155 param[2].integer.value = 0;
156 param[3].type = ACPI_TYPE_INTEGER;
157 param[3].integer.value = 0;
158 input.count = 4;
159 input.pointer = param;
160 return acpi_evaluate_object(handle, "ACMD", &input, NULL);
161}
162
163static acpi_status cmpc_get_accel_v4(acpi_handle handle,
164 int16_t *x,
165 int16_t *y,
166 int16_t *z)
167{
168 union acpi_object param[4];
169 struct acpi_object_list input;
170 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
171 int16_t *locs;
172 acpi_status status;
173
174 param[0].type = ACPI_TYPE_INTEGER;
175 param[0].integer.value = 0x01;
176 param[1].type = ACPI_TYPE_INTEGER;
177 param[1].integer.value = 0;
178 param[2].type = ACPI_TYPE_INTEGER;
179 param[2].integer.value = 0;
180 param[3].type = ACPI_TYPE_INTEGER;
181 param[3].integer.value = 0;
182 input.count = 4;
183 input.pointer = param;
184 status = acpi_evaluate_object(handle, "ACMD", &input, &output);
185 if (ACPI_SUCCESS(status)) {
186 union acpi_object *obj;
187 obj = output.pointer;
188 locs = (int16_t *) obj->buffer.pointer;
189 *x = locs[0];
190 *y = locs[1];
191 *z = locs[2];
192 kfree(output.pointer);
193 }
194 return status;
195}
196
197static void cmpc_accel_handler_v4(struct acpi_device *dev, u32 event)
198{
199 if (event == 0x81) {
200 int16_t x, y, z;
201 acpi_status status;
202
203 status = cmpc_get_accel_v4(dev->handle, &x, &y, &z);
204 if (ACPI_SUCCESS(status)) {
205 struct input_dev *inputdev = dev_get_drvdata(&dev->dev);
206
207 input_report_abs(inputdev, ABS_X, x);
208 input_report_abs(inputdev, ABS_Y, y);
209 input_report_abs(inputdev, ABS_Z, z);
210 input_sync(inputdev);
211 }
212 }
213}
214
215static ssize_t cmpc_accel_sensitivity_show_v4(struct device *dev,
216 struct device_attribute *attr,
217 char *buf)
218{
219 struct acpi_device *acpi;
220 struct input_dev *inputdev;
221 struct cmpc_accel *accel;
222
223 acpi = to_acpi_device(dev);
224 inputdev = dev_get_drvdata(&acpi->dev);
225 accel = dev_get_drvdata(&inputdev->dev);
226
227 return sprintf(buf, "%d\n", accel->sensitivity);
228}
229
230static ssize_t cmpc_accel_sensitivity_store_v4(struct device *dev,
231 struct device_attribute *attr,
232 const char *buf, size_t count)
233{
234 struct acpi_device *acpi;
235 struct input_dev *inputdev;
236 struct cmpc_accel *accel;
237 unsigned long sensitivity;
238 int r;
239
240 acpi = to_acpi_device(dev);
241 inputdev = dev_get_drvdata(&acpi->dev);
242 accel = dev_get_drvdata(&inputdev->dev);
243
244 r = kstrtoul(buf, 0, &sensitivity);
245 if (r)
246 return r;
247
248 /* sensitivity must be between 1 and 127 */
249 if (sensitivity < 1 || sensitivity > 127)
250 return -EINVAL;
251
252 accel->sensitivity = sensitivity;
253 cmpc_accel_set_sensitivity_v4(acpi->handle, sensitivity);
254
255 return strnlen(buf, count);
256}
257
258static struct device_attribute cmpc_accel_sensitivity_attr_v4 = {
259 .attr = { .name = "sensitivity", .mode = 0660 },
260 .show = cmpc_accel_sensitivity_show_v4,
261 .store = cmpc_accel_sensitivity_store_v4
262};
263
264static ssize_t cmpc_accel_g_select_show_v4(struct device *dev,
265 struct device_attribute *attr,
266 char *buf)
267{
268 struct acpi_device *acpi;
269 struct input_dev *inputdev;
270 struct cmpc_accel *accel;
271
272 acpi = to_acpi_device(dev);
273 inputdev = dev_get_drvdata(&acpi->dev);
274 accel = dev_get_drvdata(&inputdev->dev);
275
276 return sprintf(buf, "%d\n", accel->g_select);
277}
278
279static ssize_t cmpc_accel_g_select_store_v4(struct device *dev,
280 struct device_attribute *attr,
281 const char *buf, size_t count)
282{
283 struct acpi_device *acpi;
284 struct input_dev *inputdev;
285 struct cmpc_accel *accel;
286 unsigned long g_select;
287 int r;
288
289 acpi = to_acpi_device(dev);
290 inputdev = dev_get_drvdata(&acpi->dev);
291 accel = dev_get_drvdata(&inputdev->dev);
292
293 r = kstrtoul(buf, 0, &g_select);
294 if (r)
295 return r;
296
297 /* 0 means 1.5g, 1 means 6g, everything else is wrong */
298 if (g_select != 0 && g_select != 1)
299 return -EINVAL;
300
301 accel->g_select = g_select;
302 cmpc_accel_set_g_select_v4(acpi->handle, g_select);
303
304 return strnlen(buf, count);
305}
306
307static struct device_attribute cmpc_accel_g_select_attr_v4 = {
308 .attr = { .name = "g_select", .mode = 0660 },
309 .show = cmpc_accel_g_select_show_v4,
310 .store = cmpc_accel_g_select_store_v4
311};
312
313static int cmpc_accel_open_v4(struct input_dev *input)
314{
315 struct acpi_device *acpi;
316 struct cmpc_accel *accel;
317
318 acpi = to_acpi_device(input->dev.parent);
319 accel = dev_get_drvdata(&input->dev);
320
321 cmpc_accel_set_sensitivity_v4(acpi->handle, accel->sensitivity);
322 cmpc_accel_set_g_select_v4(acpi->handle, accel->g_select);
323
324 if (ACPI_SUCCESS(cmpc_start_accel_v4(acpi->handle))) {
325 accel->inputdev_state = CMPC_ACCEL_DEV_STATE_OPEN;
326 return 0;
327 }
328 return -EIO;
329}
330
331static void cmpc_accel_close_v4(struct input_dev *input)
332{
333 struct acpi_device *acpi;
334 struct cmpc_accel *accel;
335
336 acpi = to_acpi_device(input->dev.parent);
337 accel = dev_get_drvdata(&input->dev);
338
339 cmpc_stop_accel_v4(acpi->handle);
340 accel->inputdev_state = CMPC_ACCEL_DEV_STATE_CLOSED;
341}
342
343static void cmpc_accel_idev_init_v4(struct input_dev *inputdev)
344{
345 set_bit(EV_ABS, inputdev->evbit);
346 input_set_abs_params(inputdev, ABS_X, -255, 255, 16, 0);
347 input_set_abs_params(inputdev, ABS_Y, -255, 255, 16, 0);
348 input_set_abs_params(inputdev, ABS_Z, -255, 255, 16, 0);
349 inputdev->open = cmpc_accel_open_v4;
350 inputdev->close = cmpc_accel_close_v4;
351}
352
353static int cmpc_accel_suspend_v4(struct device *dev)
354{
355 struct input_dev *inputdev;
356 struct cmpc_accel *accel;
357
358 inputdev = dev_get_drvdata(dev);
359 accel = dev_get_drvdata(&inputdev->dev);
360
361 if (accel->inputdev_state == CMPC_ACCEL_DEV_STATE_OPEN)
362 return cmpc_stop_accel_v4(to_acpi_device(dev)->handle);
363
364 return 0;
365}
366
367static int cmpc_accel_resume_v4(struct device *dev)
368{
369 struct input_dev *inputdev;
370 struct cmpc_accel *accel;
371
372 inputdev = dev_get_drvdata(dev);
373 accel = dev_get_drvdata(&inputdev->dev);
374
375 if (accel->inputdev_state == CMPC_ACCEL_DEV_STATE_OPEN) {
376 cmpc_accel_set_sensitivity_v4(to_acpi_device(dev)->handle,
377 accel->sensitivity);
378 cmpc_accel_set_g_select_v4(to_acpi_device(dev)->handle,
379 accel->g_select);
380
381 if (ACPI_FAILURE(cmpc_start_accel_v4(to_acpi_device(dev)->handle)))
382 return -EIO;
383 }
384
385 return 0;
386}
387
388static int cmpc_accel_add_v4(struct acpi_device *acpi)
389{
390 int error;
391 struct input_dev *inputdev;
392 struct cmpc_accel *accel;
393
394 accel = kmalloc(sizeof(*accel), GFP_KERNEL);
395 if (!accel)
396 return -ENOMEM;
397
398 accel->inputdev_state = CMPC_ACCEL_DEV_STATE_CLOSED;
399
400 accel->sensitivity = CMPC_ACCEL_SENSITIVITY_DEFAULT;
401 cmpc_accel_set_sensitivity_v4(acpi->handle, accel->sensitivity);
402
403 error = device_create_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
404 if (error)
405 goto failed_sensitivity;
406
407 accel->g_select = CMPC_ACCEL_G_SELECT_DEFAULT;
408 cmpc_accel_set_g_select_v4(acpi->handle, accel->g_select);
409
410 error = device_create_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
411 if (error)
412 goto failed_g_select;
413
414 error = cmpc_add_acpi_notify_device(acpi, "cmpc_accel_v4",
415 cmpc_accel_idev_init_v4);
416 if (error)
417 goto failed_input;
418
419 inputdev = dev_get_drvdata(&acpi->dev);
420 dev_set_drvdata(&inputdev->dev, accel);
421
422 return 0;
423
424failed_input:
425 device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
426failed_g_select:
427 device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
428failed_sensitivity:
429 kfree(accel);
430 return error;
431}
432
433static int cmpc_accel_remove_v4(struct acpi_device *acpi, int type)
434{
435 struct input_dev *inputdev;
436 struct cmpc_accel *accel;
437
438 inputdev = dev_get_drvdata(&acpi->dev);
439 accel = dev_get_drvdata(&inputdev->dev);
440
441 device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
442 device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
443 return cmpc_remove_acpi_notify_device(acpi);
444}
445
446static SIMPLE_DEV_PM_OPS(cmpc_accel_pm, cmpc_accel_suspend_v4,
447 cmpc_accel_resume_v4);
448
449static const struct acpi_device_id cmpc_accel_device_ids_v4[] = {
450 {CMPC_ACCEL_HID_V4, 0},
451 {"", 0}
452};
453
454static struct acpi_driver cmpc_accel_acpi_driver_v4 = {
455 .owner = THIS_MODULE,
456 .name = "cmpc_accel_v4",
457 .class = "cmpc_accel_v4",
458 .ids = cmpc_accel_device_ids_v4,
459 .ops = {
460 .add = cmpc_accel_add_v4,
461 .remove = cmpc_accel_remove_v4,
462 .notify = cmpc_accel_handler_v4,
463 },
464 .drv.pm = &cmpc_accel_pm,
465};
466
467
468/*
469 * Accelerometer code for Classmate versions prior to V4
80 */ 470 */
81static acpi_status cmpc_start_accel(acpi_handle handle) 471static acpi_status cmpc_start_accel(acpi_handle handle)
82{ 472{
@@ -726,8 +1116,15 @@ static int cmpc_init(void)
726 if (r) 1116 if (r)
727 goto failed_accel; 1117 goto failed_accel;
728 1118
1119 r = acpi_bus_register_driver(&cmpc_accel_acpi_driver_v4);
1120 if (r)
1121 goto failed_accel_v4;
1122
729 return r; 1123 return r;
730 1124
1125failed_accel_v4:
1126 acpi_bus_unregister_driver(&cmpc_accel_acpi_driver);
1127
731failed_accel: 1128failed_accel:
732 acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver); 1129 acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver);
733 1130
@@ -743,6 +1140,7 @@ failed_keys:
743 1140
744static void cmpc_exit(void) 1141static void cmpc_exit(void)
745{ 1142{
1143 acpi_bus_unregister_driver(&cmpc_accel_acpi_driver_v4);
746 acpi_bus_unregister_driver(&cmpc_accel_acpi_driver); 1144 acpi_bus_unregister_driver(&cmpc_accel_acpi_driver);
747 acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver); 1145 acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver);
748 acpi_bus_unregister_driver(&cmpc_ipml_acpi_driver); 1146 acpi_bus_unregister_driver(&cmpc_ipml_acpi_driver);
@@ -754,6 +1152,7 @@ module_exit(cmpc_exit);
754 1152
755static const struct acpi_device_id cmpc_device_ids[] = { 1153static const struct acpi_device_id cmpc_device_ids[] = {
756 {CMPC_ACCEL_HID, 0}, 1154 {CMPC_ACCEL_HID, 0},
1155 {CMPC_ACCEL_HID_V4, 0},
757 {CMPC_TABLET_HID, 0}, 1156 {CMPC_TABLET_HID, 0},
758 {CMPC_IPML_HID, 0}, 1157 {CMPC_IPML_HID, 0},
759 {CMPC_KEYS_HID, 0}, 1158 {CMPC_KEYS_HID, 0},
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 5f78aac9b163..4e96e8c0b60f 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -206,6 +206,60 @@ static struct dmi_system_id __devinitdata dell_quirks[] = {
206 }, 206 },
207 .driver_data = &quirk_dell_vostro_v130, 207 .driver_data = &quirk_dell_vostro_v130,
208 }, 208 },
209 {
210 .callback = dmi_matched,
211 .ident = "Dell Inspiron 5420",
212 .matches = {
213 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
214 DMI_MATCH(DMI_PRODUCT_NAME, "Isnpiron 5420"),
215 },
216 .driver_data = &quirk_dell_vostro_v130,
217 },
218 {
219 .callback = dmi_matched,
220 .ident = "Dell Inspiron 5520",
221 .matches = {
222 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
223 DMI_MATCH(DMI_PRODUCT_NAME, "Isnpiron 5520"),
224 },
225 .driver_data = &quirk_dell_vostro_v130,
226 },
227 {
228 .callback = dmi_matched,
229 .ident = "Dell Inspiron 5720",
230 .matches = {
231 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
232 DMI_MATCH(DMI_PRODUCT_NAME, "Isnpiron 5720"),
233 },
234 .driver_data = &quirk_dell_vostro_v130,
235 },
236 {
237 .callback = dmi_matched,
238 .ident = "Dell Inspiron 7420",
239 .matches = {
240 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
241 DMI_MATCH(DMI_PRODUCT_NAME, "Isnpiron 7420"),
242 },
243 .driver_data = &quirk_dell_vostro_v130,
244 },
245 {
246 .callback = dmi_matched,
247 .ident = "Dell Inspiron 7520",
248 .matches = {
249 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
250 DMI_MATCH(DMI_PRODUCT_NAME, "Isnpiron 7520"),
251 },
252 .driver_data = &quirk_dell_vostro_v130,
253 },
254 {
255 .callback = dmi_matched,
256 .ident = "Dell Inspiron 7720",
257 .matches = {
258 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
259 DMI_MATCH(DMI_PRODUCT_NAME, "Isnpiron 7720"),
260 },
261 .driver_data = &quirk_dell_vostro_v130,
262 },
209 { } 263 { }
210}; 264};
211 265
diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c
index 656761380342..5838332ea5bd 100644
--- a/drivers/platform/x86/eeepc-wmi.c
+++ b/drivers/platform/x86/eeepc-wmi.c
@@ -79,7 +79,7 @@ static const struct key_entry eeepc_wmi_keymap[] = {
79 { KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */ 79 { KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */
80 { KE_KEY, HOME_PRESS, { KEY_CONFIG } }, /* Home/Express gate key */ 80 { KE_KEY, HOME_PRESS, { KEY_CONFIG } }, /* Home/Express gate key */
81 { KE_KEY, 0xe8, { KEY_SCREENLOCK } }, 81 { KE_KEY, 0xe8, { KEY_SCREENLOCK } },
82 { KE_KEY, 0xe9, { KEY_BRIGHTNESS_ZERO } }, 82 { KE_KEY, 0xe9, { KEY_DISPLAYTOGGLE } },
83 { KE_KEY, 0xeb, { KEY_CAMERA_ZOOMOUT } }, 83 { KE_KEY, 0xeb, { KEY_CAMERA_ZOOMOUT } },
84 { KE_KEY, 0xec, { KEY_CAMERA_UP } }, 84 { KE_KEY, 0xec, { KEY_CAMERA_UP } },
85 { KE_KEY, 0xed, { KEY_CAMERA_DOWN } }, 85 { KE_KEY, 0xed, { KEY_CAMERA_DOWN } },
@@ -107,6 +107,11 @@ static struct quirk_entry quirk_asus_et2012_type3 = {
107 .store_backlight_power = true, 107 .store_backlight_power = true,
108}; 108};
109 109
110static struct quirk_entry quirk_asus_x101ch = {
111 /* We need this when ACPI function doesn't do this well */
112 .wmi_backlight_power = true,
113};
114
110static struct quirk_entry *quirks; 115static struct quirk_entry *quirks;
111 116
112static void et2012_quirks(void) 117static void et2012_quirks(void)
@@ -157,6 +162,24 @@ static struct dmi_system_id asus_quirks[] = {
157 }, 162 },
158 .driver_data = &quirk_asus_unknown, 163 .driver_data = &quirk_asus_unknown,
159 }, 164 },
165 {
166 .callback = dmi_matched,
167 .ident = "ASUSTeK Computer INC. X101CH",
168 .matches = {
169 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
170 DMI_MATCH(DMI_PRODUCT_NAME, "X101CH"),
171 },
172 .driver_data = &quirk_asus_x101ch,
173 },
174 {
175 .callback = dmi_matched,
176 .ident = "ASUSTeK Computer INC. 1015CX",
177 .matches = {
178 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
179 DMI_MATCH(DMI_PRODUCT_NAME, "1015CX"),
180 },
181 .driver_data = &quirk_asus_x101ch,
182 },
160 {}, 183 {},
161}; 184};
162 185
diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
index e2a34b42ddc1..c1ca7bcebb66 100644
--- a/drivers/platform/x86/samsung-laptop.c
+++ b/drivers/platform/x86/samsung-laptop.c
@@ -26,7 +26,7 @@
26#include <linux/seq_file.h> 26#include <linux/seq_file.h>
27#include <linux/debugfs.h> 27#include <linux/debugfs.h>
28#include <linux/ctype.h> 28#include <linux/ctype.h>
29#if (defined CONFIG_ACPI_VIDEO || defined CONFIG_ACPI_VIDEO_MODULE) 29#ifdef CONFIG_ACPI_VIDEO
30#include <acpi/video.h> 30#include <acpi/video.h>
31#endif 31#endif
32 32
@@ -1465,6 +1465,15 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
1465 DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */ 1465 DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */
1466 }, 1466 },
1467 }, 1467 },
1468 /* DMI ids for laptops with bad Chassis Type */
1469 {
1470 .ident = "R40/R41",
1471 .matches = {
1472 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1473 DMI_MATCH(DMI_PRODUCT_NAME, "R40/R41"),
1474 DMI_MATCH(DMI_BOARD_NAME, "R40/R41"),
1475 },
1476 },
1468 /* Specific DMI ids for laptop with quirks */ 1477 /* Specific DMI ids for laptop with quirks */
1469 { 1478 {
1470 .callback = samsung_dmi_matched, 1479 .callback = samsung_dmi_matched,
@@ -1506,6 +1515,16 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
1506 }, 1515 },
1507 .driver_data = &samsung_broken_acpi_video, 1516 .driver_data = &samsung_broken_acpi_video,
1508 }, 1517 },
1518 {
1519 .callback = samsung_dmi_matched,
1520 .ident = "X360",
1521 .matches = {
1522 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1523 DMI_MATCH(DMI_PRODUCT_NAME, "X360"),
1524 DMI_MATCH(DMI_BOARD_NAME, "X360"),
1525 },
1526 .driver_data = &samsung_broken_acpi_video,
1527 },
1509 { }, 1528 { },
1510}; 1529};
1511MODULE_DEVICE_TABLE(dmi, samsung_dmi_table); 1530MODULE_DEVICE_TABLE(dmi, samsung_dmi_table);
@@ -1530,15 +1549,18 @@ static int __init samsung_init(void)
1530 samsung->quirks = quirks; 1549 samsung->quirks = quirks;
1531 1550
1532 1551
1533#if (defined CONFIG_ACPI_VIDEO || defined CONFIG_ACPI_VIDEO_MODULE) 1552#ifdef CONFIG_ACPI
1553 if (samsung->quirks->broken_acpi_video)
1554 acpi_video_dmi_promote_vendor();
1555
1534 /* Don't handle backlight here if the acpi video already handle it */ 1556 /* Don't handle backlight here if the acpi video already handle it */
1535 if (acpi_video_backlight_support()) { 1557 if (acpi_video_backlight_support()) {
1536 if (samsung->quirks->broken_acpi_video) { 1558 samsung->handle_backlight = false;
1537 pr_info("Disabling ACPI video driver\n"); 1559 } else if (samsung->quirks->broken_acpi_video) {
1538 acpi_video_unregister(); 1560 pr_info("Disabling ACPI video driver\n");
1539 } else { 1561#ifdef CONFIG_ACPI_VIDEO
1540 samsung->handle_backlight = false; 1562 acpi_video_unregister();
1541 } 1563#endif
1542 } 1564 }
1543#endif 1565#endif
1544 1566
@@ -1552,8 +1574,7 @@ static int __init samsung_init(void)
1552 1574
1553#ifdef CONFIG_ACPI 1575#ifdef CONFIG_ACPI
1554 /* Only log that if we are really on a sabi platform */ 1576 /* Only log that if we are really on a sabi platform */
1555 if (acpi_video_backlight_support() && 1577 if (acpi_video_backlight_support())
1556 !samsung->quirks->broken_acpi_video)
1557 pr_info("Backlight controlled by ACPI video driver\n"); 1578 pr_info("Backlight controlled by ACPI video driver\n");
1558#endif 1579#endif
1559 1580
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index d5fd4a1193f8..e7f73287636c 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -3015,8 +3015,6 @@ static void hotkey_exit(void)
3015 if (hotkey_dev_attributes) 3015 if (hotkey_dev_attributes)
3016 delete_attr_set(hotkey_dev_attributes, &tpacpi_pdev->dev.kobj); 3016 delete_attr_set(hotkey_dev_attributes, &tpacpi_pdev->dev.kobj);
3017 3017
3018 kfree(hotkey_keycode_map);
3019
3020 dbg_printk(TPACPI_DBG_EXIT | TPACPI_DBG_HKEY, 3018 dbg_printk(TPACPI_DBG_EXIT | TPACPI_DBG_HKEY,
3021 "restoring original HKEY status and mask\n"); 3019 "restoring original HKEY status and mask\n");
3022 /* yes, there is a bitwise or below, we want the 3020 /* yes, there is a bitwise or below, we want the
@@ -5217,6 +5215,7 @@ static void led_exit(void)
5217 led_classdev_unregister(&tpacpi_leds[i].led_classdev); 5215 led_classdev_unregister(&tpacpi_leds[i].led_classdev);
5218 } 5216 }
5219 5217
5218 flush_workqueue(tpacpi_wq);
5220 kfree(tpacpi_leds); 5219 kfree(tpacpi_leds);
5221} 5220}
5222 5221
@@ -8936,6 +8935,7 @@ static void thinkpad_acpi_module_exit(void)
8936 input_unregister_device(tpacpi_inputdev); 8935 input_unregister_device(tpacpi_inputdev);
8937 else 8936 else
8938 input_free_device(tpacpi_inputdev); 8937 input_free_device(tpacpi_inputdev);
8938 kfree(hotkey_keycode_map);
8939 } 8939 }
8940 8940
8941 if (tpacpi_hwmon) 8941 if (tpacpi_hwmon)
@@ -8969,6 +8969,7 @@ static void thinkpad_acpi_module_exit(void)
8969 kfree(thinkpad_id.bios_version_str); 8969 kfree(thinkpad_id.bios_version_str);
8970 kfree(thinkpad_id.ec_version_str); 8970 kfree(thinkpad_id.ec_version_str);
8971 kfree(thinkpad_id.model_str); 8971 kfree(thinkpad_id.model_str);
8972 kfree(thinkpad_id.nummodel_str);
8972} 8973}
8973 8974
8974 8975
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
new file mode 100644
index 000000000000..8fc3808d7a3e
--- /dev/null
+++ b/drivers/pwm/Kconfig
@@ -0,0 +1,108 @@
1menuconfig PWM
2 bool "PWM Support"
3 depends on !MACH_JZ4740 && !PUV3_PWM
4 help
5 This enables PWM support through the generic PWM framework.
6 You only need to enable this, if you also want to enable
7 one or more of the PWM drivers below.
8
9 If unsure, say N.
10
11if PWM
12
13config PWM_BFIN
14 tristate "Blackfin PWM support"
15 depends on BFIN_GPTIMERS
16 help
17 Generic PWM framework driver for Blackfin.
18
19 To compile this driver as a module, choose M here: the module
20 will be called pwm-bfin.
21
22config PWM_IMX
23 tristate "i.MX pwm support"
24 depends on ARCH_MXC
25 help
26 Generic PWM framework driver for i.MX.
27
28 To compile this driver as a module, choose M here: the module
29 will be called pwm-imx.
30
31config PWM_LPC32XX
32 tristate "LPC32XX PWM support"
33 depends on ARCH_LPC32XX
34 help
35 Generic PWM framework driver for LPC32XX. The LPC32XX SOC has two
36 PWM controllers.
37
38 To compile this driver as a module, choose M here: the module
39 will be called pwm-lpc32xx.
40
41config PWM_MXS
42 tristate "Freescale MXS PWM support"
43 depends on ARCH_MXS && OF
44 select STMP_DEVICE
45 help
46 Generic PWM framework driver for Freescale MXS.
47
48 To compile this driver as a module, choose M here: the module
49 will be called pwm-mxs.
50
51config PWM_PXA
52 tristate "PXA PWM support"
53 depends on ARCH_PXA
54 help
55 Generic PWM framework driver for PXA.
56
57 To compile this driver as a module, choose M here: the module
58 will be called pwm-pxa.
59
60config PWM_SAMSUNG
61 tristate "Samsung pwm support"
62 depends on PLAT_SAMSUNG
63 help
64 Generic PWM framework driver for Samsung.
65
66 To compile this driver as a module, choose M here: the module
67 will be called pwm-samsung.
68
69config PWM_TEGRA
70 tristate "NVIDIA Tegra PWM support"
71 depends on ARCH_TEGRA
72 help
73 Generic PWM framework driver for the PWFM controller found on NVIDIA
74 Tegra SoCs.
75
76 To compile this driver as a module, choose M here: the module
77 will be called pwm-tegra.
78
79config PWM_TIECAP
80 tristate "ECAP PWM support"
81 depends on SOC_AM33XX
82 help
83 PWM driver support for the ECAP APWM controller found on AM33XX
84 TI SOC
85
86 To compile this driver as a module, choose M here: the module
87 will be called pwm-tiecap.
88
89config PWM_TIEHRPWM
90 tristate "EHRPWM PWM support"
91 depends on SOC_AM33XX
92 help
93 PWM driver support for the EHRPWM controller found on AM33XX
94 TI SOC
95
96 To compile this driver as a module, choose M here: the module
97 will be called pwm-tiehrpwm.
98
99config PWM_VT8500
100 tristate "vt8500 pwm support"
101 depends on ARCH_VT8500
102 help
103 Generic PWM framework driver for vt8500.
104
105 To compile this driver as a module, choose M here: the module
106 will be called pwm-vt8500.
107
108endif
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
new file mode 100644
index 000000000000..e4b2c898964d
--- /dev/null
+++ b/drivers/pwm/Makefile
@@ -0,0 +1,11 @@
1obj-$(CONFIG_PWM) += core.o
2obj-$(CONFIG_PWM_BFIN) += pwm-bfin.o
3obj-$(CONFIG_PWM_IMX) += pwm-imx.o
4obj-$(CONFIG_PWM_LPC32XX) += pwm-lpc32xx.o
5obj-$(CONFIG_PWM_MXS) += pwm-mxs.o
6obj-$(CONFIG_PWM_PXA) += pwm-pxa.o
7obj-$(CONFIG_PWM_SAMSUNG) += pwm-samsung.o
8obj-$(CONFIG_PWM_TEGRA) += pwm-tegra.o
9obj-$(CONFIG_PWM_TIECAP) += pwm-tiecap.o
10obj-$(CONFIG_PWM_TIEHRPWM) += pwm-tiehrpwm.o
11obj-$(CONFIG_PWM_VT8500) += pwm-vt8500.o
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
new file mode 100644
index 000000000000..ecb76909e946
--- /dev/null
+++ b/drivers/pwm/core.c
@@ -0,0 +1,713 @@
1/*
2 * Generic pwmlib implementation
3 *
4 * Copyright (C) 2011 Sascha Hauer <s.hauer@pengutronix.de>
5 * Copyright (C) 2011-2012 Avionic Design GmbH
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <linux/module.h>
23#include <linux/pwm.h>
24#include <linux/radix-tree.h>
25#include <linux/list.h>
26#include <linux/mutex.h>
27#include <linux/err.h>
28#include <linux/slab.h>
29#include <linux/device.h>
30#include <linux/debugfs.h>
31#include <linux/seq_file.h>
32
33#define MAX_PWMS 1024
34
35static DEFINE_MUTEX(pwm_lookup_lock);
36static LIST_HEAD(pwm_lookup_list);
37static DEFINE_MUTEX(pwm_lock);
38static LIST_HEAD(pwm_chips);
39static DECLARE_BITMAP(allocated_pwms, MAX_PWMS);
40static RADIX_TREE(pwm_tree, GFP_KERNEL);
41
42static struct pwm_device *pwm_to_device(unsigned int pwm)
43{
44 return radix_tree_lookup(&pwm_tree, pwm);
45}
46
47static int alloc_pwms(int pwm, unsigned int count)
48{
49 unsigned int from = 0;
50 unsigned int start;
51
52 if (pwm >= MAX_PWMS)
53 return -EINVAL;
54
55 if (pwm >= 0)
56 from = pwm;
57
58 start = bitmap_find_next_zero_area(allocated_pwms, MAX_PWMS, from,
59 count, 0);
60
61 if (pwm >= 0 && start != pwm)
62 return -EEXIST;
63
64 if (start + count > MAX_PWMS)
65 return -ENOSPC;
66
67 return start;
68}
69
70static void free_pwms(struct pwm_chip *chip)
71{
72 unsigned int i;
73
74 for (i = 0; i < chip->npwm; i++) {
75 struct pwm_device *pwm = &chip->pwms[i];
76 radix_tree_delete(&pwm_tree, pwm->pwm);
77 }
78
79 bitmap_clear(allocated_pwms, chip->base, chip->npwm);
80
81 kfree(chip->pwms);
82 chip->pwms = NULL;
83}
84
85static struct pwm_chip *pwmchip_find_by_name(const char *name)
86{
87 struct pwm_chip *chip;
88
89 if (!name)
90 return NULL;
91
92 mutex_lock(&pwm_lock);
93
94 list_for_each_entry(chip, &pwm_chips, list) {
95 const char *chip_name = dev_name(chip->dev);
96
97 if (chip_name && strcmp(chip_name, name) == 0) {
98 mutex_unlock(&pwm_lock);
99 return chip;
100 }
101 }
102
103 mutex_unlock(&pwm_lock);
104
105 return NULL;
106}
107
108static int pwm_device_request(struct pwm_device *pwm, const char *label)
109{
110 int err;
111
112 if (test_bit(PWMF_REQUESTED, &pwm->flags))
113 return -EBUSY;
114
115 if (!try_module_get(pwm->chip->ops->owner))
116 return -ENODEV;
117
118 if (pwm->chip->ops->request) {
119 err = pwm->chip->ops->request(pwm->chip, pwm);
120 if (err) {
121 module_put(pwm->chip->ops->owner);
122 return err;
123 }
124 }
125
126 set_bit(PWMF_REQUESTED, &pwm->flags);
127 pwm->label = label;
128
129 return 0;
130}
131
132static struct pwm_device *of_pwm_simple_xlate(struct pwm_chip *pc,
133 const struct of_phandle_args *args)
134{
135 struct pwm_device *pwm;
136
137 if (pc->of_pwm_n_cells < 2)
138 return ERR_PTR(-EINVAL);
139
140 if (args->args[0] >= pc->npwm)
141 return ERR_PTR(-EINVAL);
142
143 pwm = pwm_request_from_chip(pc, args->args[0], NULL);
144 if (IS_ERR(pwm))
145 return pwm;
146
147 pwm_set_period(pwm, args->args[1]);
148
149 return pwm;
150}
151
152void of_pwmchip_add(struct pwm_chip *chip)
153{
154 if (!chip->dev || !chip->dev->of_node)
155 return;
156
157 if (!chip->of_xlate) {
158 chip->of_xlate = of_pwm_simple_xlate;
159 chip->of_pwm_n_cells = 2;
160 }
161
162 of_node_get(chip->dev->of_node);
163}
164
165void of_pwmchip_remove(struct pwm_chip *chip)
166{
167 if (chip->dev && chip->dev->of_node)
168 of_node_put(chip->dev->of_node);
169}
170
171/**
172 * pwm_set_chip_data() - set private chip data for a PWM
173 * @pwm: PWM device
174 * @data: pointer to chip-specific data
175 */
176int pwm_set_chip_data(struct pwm_device *pwm, void *data)
177{
178 if (!pwm)
179 return -EINVAL;
180
181 pwm->chip_data = data;
182
183 return 0;
184}
185
186/**
187 * pwm_get_chip_data() - get private chip data for a PWM
188 * @pwm: PWM device
189 */
190void *pwm_get_chip_data(struct pwm_device *pwm)
191{
192 return pwm ? pwm->chip_data : NULL;
193}
194
195/**
196 * pwmchip_add() - register a new PWM chip
197 * @chip: the PWM chip to add
198 *
199 * Register a new PWM chip. If chip->base < 0 then a dynamically assigned base
200 * will be used.
201 */
202int pwmchip_add(struct pwm_chip *chip)
203{
204 struct pwm_device *pwm;
205 unsigned int i;
206 int ret;
207
208 if (!chip || !chip->dev || !chip->ops || !chip->ops->config ||
209 !chip->ops->enable || !chip->ops->disable)
210 return -EINVAL;
211
212 mutex_lock(&pwm_lock);
213
214 ret = alloc_pwms(chip->base, chip->npwm);
215 if (ret < 0)
216 goto out;
217
218 chip->pwms = kzalloc(chip->npwm * sizeof(*pwm), GFP_KERNEL);
219 if (!chip->pwms) {
220 ret = -ENOMEM;
221 goto out;
222 }
223
224 chip->base = ret;
225
226 for (i = 0; i < chip->npwm; i++) {
227 pwm = &chip->pwms[i];
228
229 pwm->chip = chip;
230 pwm->pwm = chip->base + i;
231 pwm->hwpwm = i;
232
233 radix_tree_insert(&pwm_tree, pwm->pwm, pwm);
234 }
235
236 bitmap_set(allocated_pwms, chip->base, chip->npwm);
237
238 INIT_LIST_HEAD(&chip->list);
239 list_add(&chip->list, &pwm_chips);
240
241 ret = 0;
242
243 if (IS_ENABLED(CONFIG_OF))
244 of_pwmchip_add(chip);
245
246out:
247 mutex_unlock(&pwm_lock);
248 return ret;
249}
250EXPORT_SYMBOL_GPL(pwmchip_add);
251
252/**
253 * pwmchip_remove() - remove a PWM chip
254 * @chip: the PWM chip to remove
255 *
256 * Removes a PWM chip. This function may return busy if the PWM chip provides
257 * a PWM device that is still requested.
258 */
259int pwmchip_remove(struct pwm_chip *chip)
260{
261 unsigned int i;
262 int ret = 0;
263
264 mutex_lock(&pwm_lock);
265
266 for (i = 0; i < chip->npwm; i++) {
267 struct pwm_device *pwm = &chip->pwms[i];
268
269 if (test_bit(PWMF_REQUESTED, &pwm->flags)) {
270 ret = -EBUSY;
271 goto out;
272 }
273 }
274
275 list_del_init(&chip->list);
276
277 if (IS_ENABLED(CONFIG_OF))
278 of_pwmchip_remove(chip);
279
280 free_pwms(chip);
281
282out:
283 mutex_unlock(&pwm_lock);
284 return ret;
285}
286EXPORT_SYMBOL_GPL(pwmchip_remove);
287
288/**
289 * pwm_request() - request a PWM device
290 * @pwm_id: global PWM device index
291 * @label: PWM device label
292 *
293 * This function is deprecated, use pwm_get() instead.
294 */
295struct pwm_device *pwm_request(int pwm, const char *label)
296{
297 struct pwm_device *dev;
298 int err;
299
300 if (pwm < 0 || pwm >= MAX_PWMS)
301 return ERR_PTR(-EINVAL);
302
303 mutex_lock(&pwm_lock);
304
305 dev = pwm_to_device(pwm);
306 if (!dev) {
307 dev = ERR_PTR(-EPROBE_DEFER);
308 goto out;
309 }
310
311 err = pwm_device_request(dev, label);
312 if (err < 0)
313 dev = ERR_PTR(err);
314
315out:
316 mutex_unlock(&pwm_lock);
317
318 return dev;
319}
320EXPORT_SYMBOL_GPL(pwm_request);
321
322/**
323 * pwm_request_from_chip() - request a PWM device relative to a PWM chip
324 * @chip: PWM chip
325 * @index: per-chip index of the PWM to request
326 * @label: a literal description string of this PWM
327 *
328 * Returns the PWM at the given index of the given PWM chip. A negative error
329 * code is returned if the index is not valid for the specified PWM chip or
330 * if the PWM device cannot be requested.
331 */
332struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
333 unsigned int index,
334 const char *label)
335{
336 struct pwm_device *pwm;
337 int err;
338
339 if (!chip || index >= chip->npwm)
340 return ERR_PTR(-EINVAL);
341
342 mutex_lock(&pwm_lock);
343 pwm = &chip->pwms[index];
344
345 err = pwm_device_request(pwm, label);
346 if (err < 0)
347 pwm = ERR_PTR(err);
348
349 mutex_unlock(&pwm_lock);
350 return pwm;
351}
352EXPORT_SYMBOL_GPL(pwm_request_from_chip);
353
354/**
355 * pwm_free() - free a PWM device
356 * @pwm: PWM device
357 *
358 * This function is deprecated, use pwm_put() instead.
359 */
360void pwm_free(struct pwm_device *pwm)
361{
362 pwm_put(pwm);
363}
364EXPORT_SYMBOL_GPL(pwm_free);
365
366/**
367 * pwm_config() - change a PWM device configuration
368 * @pwm: PWM device
369 * @duty_ns: "on" time (in nanoseconds)
370 * @period_ns: duration (in nanoseconds) of one cycle
371 */
372int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
373{
374 if (!pwm || period_ns == 0 || duty_ns > period_ns)
375 return -EINVAL;
376
377 return pwm->chip->ops->config(pwm->chip, pwm, duty_ns, period_ns);
378}
379EXPORT_SYMBOL_GPL(pwm_config);
380
381/**
382 * pwm_enable() - start a PWM output toggling
383 * @pwm: PWM device
384 */
385int pwm_enable(struct pwm_device *pwm)
386{
387 if (pwm && !test_and_set_bit(PWMF_ENABLED, &pwm->flags))
388 return pwm->chip->ops->enable(pwm->chip, pwm);
389
390 return pwm ? 0 : -EINVAL;
391}
392EXPORT_SYMBOL_GPL(pwm_enable);
393
394/**
395 * pwm_disable() - stop a PWM output toggling
396 * @pwm: PWM device
397 */
398void pwm_disable(struct pwm_device *pwm)
399{
400 if (pwm && test_and_clear_bit(PWMF_ENABLED, &pwm->flags))
401 pwm->chip->ops->disable(pwm->chip, pwm);
402}
403EXPORT_SYMBOL_GPL(pwm_disable);
404
405static struct pwm_chip *of_node_to_pwmchip(struct device_node *np)
406{
407 struct pwm_chip *chip;
408
409 mutex_lock(&pwm_lock);
410
411 list_for_each_entry(chip, &pwm_chips, list)
412 if (chip->dev && chip->dev->of_node == np) {
413 mutex_unlock(&pwm_lock);
414 return chip;
415 }
416
417 mutex_unlock(&pwm_lock);
418
419 return ERR_PTR(-EPROBE_DEFER);
420}
421
422/**
423 * of_pwm_request() - request a PWM via the PWM framework
424 * @np: device node to get the PWM from
425 * @con_id: consumer name
426 *
427 * Returns the PWM device parsed from the phandle and index specified in the
428 * "pwms" property of a device tree node or a negative error-code on failure.
429 * Values parsed from the device tree are stored in the returned PWM device
430 * object.
431 *
432 * If con_id is NULL, the first PWM device listed in the "pwms" property will
433 * be requested. Otherwise the "pwm-names" property is used to do a reverse
434 * lookup of the PWM index. This also means that the "pwm-names" property
435 * becomes mandatory for devices that look up the PWM device via the con_id
436 * parameter.
437 */
438static struct pwm_device *of_pwm_request(struct device_node *np,
439 const char *con_id)
440{
441 struct pwm_device *pwm = NULL;
442 struct of_phandle_args args;
443 struct pwm_chip *pc;
444 int index = 0;
445 int err;
446
447 if (con_id) {
448 index = of_property_match_string(np, "pwm-names", con_id);
449 if (index < 0)
450 return ERR_PTR(index);
451 }
452
453 err = of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
454 &args);
455 if (err) {
456 pr_debug("%s(): can't parse \"pwms\" property\n", __func__);
457 return ERR_PTR(err);
458 }
459
460 pc = of_node_to_pwmchip(args.np);
461 if (IS_ERR(pc)) {
462 pr_debug("%s(): PWM chip not found\n", __func__);
463 pwm = ERR_CAST(pc);
464 goto put;
465 }
466
467 if (args.args_count != pc->of_pwm_n_cells) {
468 pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
469 args.np->full_name);
470 pwm = ERR_PTR(-EINVAL);
471 goto put;
472 }
473
474 pwm = pc->of_xlate(pc, &args);
475 if (IS_ERR(pwm))
476 goto put;
477
478 /*
479 * If a consumer name was not given, try to look it up from the
480 * "pwm-names" property if it exists. Otherwise use the name of
481 * the user device node.
482 */
483 if (!con_id) {
484 err = of_property_read_string_index(np, "pwm-names", index,
485 &con_id);
486 if (err < 0)
487 con_id = np->name;
488 }
489
490 pwm->label = con_id;
491
492put:
493 of_node_put(args.np);
494
495 return pwm;
496}
497
498/**
499 * pwm_add_table() - register PWM device consumers
500 * @table: array of consumers to register
501 * @num: number of consumers in table
502 */
503void __init pwm_add_table(struct pwm_lookup *table, size_t num)
504{
505 mutex_lock(&pwm_lookup_lock);
506
507 while (num--) {
508 list_add_tail(&table->list, &pwm_lookup_list);
509 table++;
510 }
511
512 mutex_unlock(&pwm_lookup_lock);
513}
514
515/**
516 * pwm_get() - look up and request a PWM device
517 * @dev: device for PWM consumer
518 * @con_id: consumer name
519 *
520 * Lookup is first attempted using DT. If the device was not instantiated from
521 * a device tree, a PWM chip and a relative index is looked up via a table
522 * supplied by board setup code (see pwm_add_table()).
523 *
524 * Once a PWM chip has been found the specified PWM device will be requested
525 * and is ready to be used.
526 */
527struct pwm_device *pwm_get(struct device *dev, const char *con_id)
528{
529 struct pwm_device *pwm = ERR_PTR(-EPROBE_DEFER);
530 const char *dev_id = dev ? dev_name(dev): NULL;
531 struct pwm_chip *chip = NULL;
532 unsigned int index = 0;
533 unsigned int best = 0;
534 struct pwm_lookup *p;
535 unsigned int match;
536
537 /* look up via DT first */
538 if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node)
539 return of_pwm_request(dev->of_node, con_id);
540
541 /*
542 * We look up the provider in the static table typically provided by
543 * board setup code. We first try to lookup the consumer device by
544 * name. If the consumer device was passed in as NULL or if no match
545 * was found, we try to find the consumer by directly looking it up
546 * by name.
547 *
548 * If a match is found, the provider PWM chip is looked up by name
549 * and a PWM device is requested using the PWM device per-chip index.
550 *
551 * The lookup algorithm was shamelessly taken from the clock
552 * framework:
553 *
554 * We do slightly fuzzy matching here:
555 * An entry with a NULL ID is assumed to be a wildcard.
556 * If an entry has a device ID, it must match
557 * If an entry has a connection ID, it must match
558 * Then we take the most specific entry - with the following order
559 * of precedence: dev+con > dev only > con only.
560 */
561 mutex_lock(&pwm_lookup_lock);
562
563 list_for_each_entry(p, &pwm_lookup_list, list) {
564 match = 0;
565
566 if (p->dev_id) {
567 if (!dev_id || strcmp(p->dev_id, dev_id))
568 continue;
569
570 match += 2;
571 }
572
573 if (p->con_id) {
574 if (!con_id || strcmp(p->con_id, con_id))
575 continue;
576
577 match += 1;
578 }
579
580 if (match > best) {
581 chip = pwmchip_find_by_name(p->provider);
582 index = p->index;
583
584 if (match != 3)
585 best = match;
586 else
587 break;
588 }
589 }
590
591 if (chip)
592 pwm = pwm_request_from_chip(chip, index, con_id ?: dev_id);
593
594 mutex_unlock(&pwm_lookup_lock);
595
596 return pwm;
597}
598EXPORT_SYMBOL_GPL(pwm_get);
599
600/**
601 * pwm_put() - release a PWM device
602 * @pwm: PWM device
603 */
604void pwm_put(struct pwm_device *pwm)
605{
606 if (!pwm)
607 return;
608
609 mutex_lock(&pwm_lock);
610
611 if (!test_and_clear_bit(PWMF_REQUESTED, &pwm->flags)) {
612 pr_warning("PWM device already freed\n");
613 goto out;
614 }
615
616 if (pwm->chip->ops->free)
617 pwm->chip->ops->free(pwm->chip, pwm);
618
619 pwm->label = NULL;
620
621 module_put(pwm->chip->ops->owner);
622out:
623 mutex_unlock(&pwm_lock);
624}
625EXPORT_SYMBOL_GPL(pwm_put);
626
627#ifdef CONFIG_DEBUG_FS
628static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
629{
630 unsigned int i;
631
632 for (i = 0; i < chip->npwm; i++) {
633 struct pwm_device *pwm = &chip->pwms[i];
634
635 seq_printf(s, " pwm-%-3d (%-20.20s):", i, pwm->label);
636
637 if (test_bit(PWMF_REQUESTED, &pwm->flags))
638 seq_printf(s, " requested");
639
640 if (test_bit(PWMF_ENABLED, &pwm->flags))
641 seq_printf(s, " enabled");
642
643 seq_printf(s, "\n");
644 }
645}
646
647static void *pwm_seq_start(struct seq_file *s, loff_t *pos)
648{
649 mutex_lock(&pwm_lock);
650 s->private = "";
651
652 return seq_list_start(&pwm_chips, *pos);
653}
654
655static void *pwm_seq_next(struct seq_file *s, void *v, loff_t *pos)
656{
657 s->private = "\n";
658
659 return seq_list_next(v, &pwm_chips, pos);
660}
661
662static void pwm_seq_stop(struct seq_file *s, void *v)
663{
664 mutex_unlock(&pwm_lock);
665}
666
667static int pwm_seq_show(struct seq_file *s, void *v)
668{
669 struct pwm_chip *chip = list_entry(v, struct pwm_chip, list);
670
671 seq_printf(s, "%s%s/%s, %d PWM device%s\n", (char *)s->private,
672 chip->dev->bus ? chip->dev->bus->name : "no-bus",
673 dev_name(chip->dev), chip->npwm,
674 (chip->npwm != 1) ? "s" : "");
675
676 if (chip->ops->dbg_show)
677 chip->ops->dbg_show(chip, s);
678 else
679 pwm_dbg_show(chip, s);
680
681 return 0;
682}
683
684static const struct seq_operations pwm_seq_ops = {
685 .start = pwm_seq_start,
686 .next = pwm_seq_next,
687 .stop = pwm_seq_stop,
688 .show = pwm_seq_show,
689};
690
691static int pwm_seq_open(struct inode *inode, struct file *file)
692{
693 return seq_open(file, &pwm_seq_ops);
694}
695
696static const struct file_operations pwm_debugfs_ops = {
697 .owner = THIS_MODULE,
698 .open = pwm_seq_open,
699 .read = seq_read,
700 .llseek = seq_lseek,
701 .release = seq_release,
702};
703
704static int __init pwm_debugfs_init(void)
705{
706 debugfs_create_file("pwm", S_IFREG | S_IRUGO, NULL, NULL,
707 &pwm_debugfs_ops);
708
709 return 0;
710}
711
712subsys_initcall(pwm_debugfs_init);
713#endif /* CONFIG_DEBUG_FS */
diff --git a/drivers/pwm/pwm-bfin.c b/drivers/pwm/pwm-bfin.c
new file mode 100644
index 000000000000..d53c4e7941ef
--- /dev/null
+++ b/drivers/pwm/pwm-bfin.c
@@ -0,0 +1,162 @@
1/*
2 * Blackfin Pulse Width Modulation (PWM) core
3 *
4 * Copyright (c) 2011 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <linux/module.h>
10#include <linux/platform_device.h>
11#include <linux/pwm.h>
12#include <linux/slab.h>
13
14#include <asm/gptimers.h>
15#include <asm/portmux.h>
16
17struct bfin_pwm_chip {
18 struct pwm_chip chip;
19};
20
21struct bfin_pwm {
22 unsigned short pin;
23};
24
25static const unsigned short pwm_to_gptimer_per[] = {
26 P_TMR0, P_TMR1, P_TMR2, P_TMR3, P_TMR4, P_TMR5,
27 P_TMR6, P_TMR7, P_TMR8, P_TMR9, P_TMR10, P_TMR11,
28};
29
30static int bfin_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
31{
32 struct bfin_pwm *priv;
33 int ret;
34
35 if (pwm->hwpwm >= ARRAY_SIZE(pwm_to_gptimer_per))
36 return -EINVAL;
37
38 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
39 if (!priv)
40 return -ENOMEM;
41
42 priv->pin = pwm_to_gptimer_per[pwm->hwpwm];
43
44 ret = peripheral_request(priv->pin, NULL);
45 if (ret) {
46 kfree(priv);
47 return ret;
48 }
49
50 pwm_set_chip_data(pwm, priv);
51
52 return 0;
53}
54
55static void bfin_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
56{
57 struct bfin_pwm *priv = pwm_get_chip_data(pwm);
58
59 if (priv) {
60 peripheral_free(priv->pin);
61 kfree(priv);
62 }
63}
64
65static int bfin_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
66 int duty_ns, int period_ns)
67{
68 struct bfin_pwm *priv = pwm_get_chip_data(pwm);
69 unsigned long period, duty;
70 unsigned long long val;
71
72 if (duty_ns < 0 || duty_ns > period_ns)
73 return -EINVAL;
74
75 val = (unsigned long long)get_sclk() * period_ns;
76 do_div(val, NSEC_PER_SEC);
77 period = val;
78
79 val = (unsigned long long)period * duty_ns;
80 do_div(val, period_ns);
81 duty = period - val;
82
83 if (duty >= period)
84 duty = period - 1;
85
86 set_gptimer_config(priv->pin, TIMER_MODE_PWM | TIMER_PERIOD_CNT);
87 set_gptimer_pwidth(priv->pin, duty);
88 set_gptimer_period(priv->pin, period);
89
90 return 0;
91}
92
93static int bfin_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
94{
95 struct bfin_pwm *priv = pwm_get_chip_data(pwm);
96
97 enable_gptimer(priv->pin);
98
99 return 0;
100}
101
102static void bfin_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
103{
104 struct bfin_pwm *priv = pwm_get_chip_data(pwm);
105
106 disable_gptimer(priv->pin);
107}
108
109static struct pwm_ops bfin_pwm_ops = {
110 .request = bfin_pwm_request,
111 .free = bfin_pwm_free,
112 .config = bfin_pwm_config,
113 .enable = bfin_pwm_enable,
114 .disable = bfin_pwm_disable,
115 .owner = THIS_MODULE,
116};
117
118static int bfin_pwm_probe(struct platform_device *pdev)
119{
120 struct bfin_pwm_chip *pwm;
121 int ret;
122
123 pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
124 if (!pwm) {
125 dev_err(&pdev->dev, "failed to allocate memory\n");
126 return -ENOMEM;
127 }
128
129 platform_set_drvdata(pdev, pwm);
130
131 pwm->chip.dev = &pdev->dev;
132 pwm->chip.ops = &bfin_pwm_ops;
133 pwm->chip.base = -1;
134 pwm->chip.npwm = 12;
135
136 ret = pwmchip_add(&pwm->chip);
137 if (ret < 0) {
138 dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
139 return ret;
140 }
141
142 return 0;
143}
144
145static int __devexit bfin_pwm_remove(struct platform_device *pdev)
146{
147 struct bfin_pwm_chip *pwm = platform_get_drvdata(pdev);
148
149 return pwmchip_remove(&pwm->chip);
150}
151
152static struct platform_driver bfin_pwm_driver = {
153 .driver = {
154 .name = "bfin-pwm",
155 },
156 .probe = bfin_pwm_probe,
157 .remove = __devexit_p(bfin_pwm_remove),
158};
159
160module_platform_driver(bfin_pwm_driver);
161
162MODULE_LICENSE("GPL");
diff --git a/arch/arm/plat-mxc/pwm.c b/drivers/pwm/pwm-imx.c
index c0cab2270dd1..2a0b35333972 100644
--- a/arch/arm/plat-mxc/pwm.c
+++ b/drivers/pwm/pwm-imx.c
@@ -39,33 +39,28 @@
39#define MX3_PWMCR_CLKSRC_IPG (1 << 16) 39#define MX3_PWMCR_CLKSRC_IPG (1 << 16)
40#define MX3_PWMCR_EN (1 << 0) 40#define MX3_PWMCR_EN (1 << 0)
41 41
42 42struct imx_chip {
43
44struct pwm_device {
45 struct list_head node;
46 struct platform_device *pdev;
47
48 const char *label;
49 struct clk *clk; 43 struct clk *clk;
50 44
51 int clk_enabled; 45 int clk_enabled;
52 void __iomem *mmio_base; 46 void __iomem *mmio_base;
53 47
54 unsigned int use_count; 48 struct pwm_chip chip;
55 unsigned int pwm_id;
56}; 49};
57 50
58int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns) 51#define to_imx_chip(chip) container_of(chip, struct imx_chip, chip)
52
53static int imx_pwm_config(struct pwm_chip *chip,
54 struct pwm_device *pwm, int duty_ns, int period_ns)
59{ 55{
60 if (pwm == NULL || period_ns == 0 || duty_ns > period_ns) 56 struct imx_chip *imx = to_imx_chip(chip);
61 return -EINVAL;
62 57
63 if (!(cpu_is_mx1() || cpu_is_mx21())) { 58 if (!(cpu_is_mx1() || cpu_is_mx21())) {
64 unsigned long long c; 59 unsigned long long c;
65 unsigned long period_cycles, duty_cycles, prescale; 60 unsigned long period_cycles, duty_cycles, prescale;
66 u32 cr; 61 u32 cr;
67 62
68 c = clk_get_rate(pwm->clk); 63 c = clk_get_rate(imx->clk);
69 c = c * period_ns; 64 c = c * period_ns;
70 do_div(c, 1000000000); 65 do_div(c, 1000000000);
71 period_cycles = c; 66 period_cycles = c;
@@ -86,8 +81,8 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
86 else 81 else
87 period_cycles = 0; 82 period_cycles = 0;
88 83
89 writel(duty_cycles, pwm->mmio_base + MX3_PWMSAR); 84 writel(duty_cycles, imx->mmio_base + MX3_PWMSAR);
90 writel(period_cycles, pwm->mmio_base + MX3_PWMPR); 85 writel(period_cycles, imx->mmio_base + MX3_PWMPR);
91 86
92 cr = MX3_PWMCR_PRESCALER(prescale) | 87 cr = MX3_PWMCR_PRESCALER(prescale) |
93 MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN | 88 MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN |
@@ -98,7 +93,7 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
98 else 93 else
99 cr |= MX3_PWMCR_CLKSRC_IPG_HIGH; 94 cr |= MX3_PWMCR_CLKSRC_IPG_HIGH;
100 95
101 writel(cr, pwm->mmio_base + MX3_PWMCR); 96 writel(cr, imx->mmio_base + MX3_PWMCR);
102 } else if (cpu_is_mx1() || cpu_is_mx21()) { 97 } else if (cpu_is_mx1() || cpu_is_mx21()) {
103 /* The PWM subsystem allows for exact frequencies. However, 98 /* The PWM subsystem allows for exact frequencies. However,
104 * I cannot connect a scope on my device to the PWM line and 99 * I cannot connect a scope on my device to the PWM line and
@@ -116,191 +111,120 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
116 * both the prescaler (/1 .. /128) and then by CLKSEL 111 * both the prescaler (/1 .. /128) and then by CLKSEL
117 * (/2 .. /16). 112 * (/2 .. /16).
118 */ 113 */
119 u32 max = readl(pwm->mmio_base + MX1_PWMP); 114 u32 max = readl(imx->mmio_base + MX1_PWMP);
120 u32 p = max * duty_ns / period_ns; 115 u32 p = max * duty_ns / period_ns;
121 writel(max - p, pwm->mmio_base + MX1_PWMS); 116 writel(max - p, imx->mmio_base + MX1_PWMS);
122 } else { 117 } else {
123 BUG(); 118 BUG();
124 } 119 }
125 120
126 return 0; 121 return 0;
127} 122}
128EXPORT_SYMBOL(pwm_config);
129 123
130int pwm_enable(struct pwm_device *pwm) 124static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
131{ 125{
126 struct imx_chip *imx = to_imx_chip(chip);
132 int rc = 0; 127 int rc = 0;
133 128
134 if (!pwm->clk_enabled) { 129 if (!imx->clk_enabled) {
135 rc = clk_prepare_enable(pwm->clk); 130 rc = clk_prepare_enable(imx->clk);
136 if (!rc) 131 if (!rc)
137 pwm->clk_enabled = 1; 132 imx->clk_enabled = 1;
138 } 133 }
139 return rc; 134 return rc;
140} 135}
141EXPORT_SYMBOL(pwm_enable);
142 136
143void pwm_disable(struct pwm_device *pwm) 137static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
144{ 138{
145 writel(0, pwm->mmio_base + MX3_PWMCR); 139 struct imx_chip *imx = to_imx_chip(chip);
146 140
147 if (pwm->clk_enabled) { 141 writel(0, imx->mmio_base + MX3_PWMCR);
148 clk_disable_unprepare(pwm->clk);
149 pwm->clk_enabled = 0;
150 }
151}
152EXPORT_SYMBOL(pwm_disable);
153 142
154static DEFINE_MUTEX(pwm_lock); 143 if (imx->clk_enabled) {
155static LIST_HEAD(pwm_list); 144 clk_disable_unprepare(imx->clk);
156 145 imx->clk_enabled = 0;
157struct pwm_device *pwm_request(int pwm_id, const char *label)
158{
159 struct pwm_device *pwm;
160 int found = 0;
161
162 mutex_lock(&pwm_lock);
163
164 list_for_each_entry(pwm, &pwm_list, node) {
165 if (pwm->pwm_id == pwm_id) {
166 found = 1;
167 break;
168 }
169 } 146 }
170
171 if (found) {
172 if (pwm->use_count == 0) {
173 pwm->use_count++;
174 pwm->label = label;
175 } else
176 pwm = ERR_PTR(-EBUSY);
177 } else
178 pwm = ERR_PTR(-ENOENT);
179
180 mutex_unlock(&pwm_lock);
181 return pwm;
182} 147}
183EXPORT_SYMBOL(pwm_request);
184 148
185void pwm_free(struct pwm_device *pwm) 149static struct pwm_ops imx_pwm_ops = {
186{ 150 .enable = imx_pwm_enable,
187 mutex_lock(&pwm_lock); 151 .disable = imx_pwm_disable,
188 152 .config = imx_pwm_config,
189 if (pwm->use_count) { 153 .owner = THIS_MODULE,
190 pwm->use_count--; 154};
191 pwm->label = NULL;
192 } else
193 pr_warning("PWM device already freed\n");
194
195 mutex_unlock(&pwm_lock);
196}
197EXPORT_SYMBOL(pwm_free);
198 155
199static int __devinit mxc_pwm_probe(struct platform_device *pdev) 156static int __devinit imx_pwm_probe(struct platform_device *pdev)
200{ 157{
201 struct pwm_device *pwm; 158 struct imx_chip *imx;
202 struct resource *r; 159 struct resource *r;
203 int ret = 0; 160 int ret = 0;
204 161
205 pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL); 162 imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL);
206 if (pwm == NULL) { 163 if (imx == NULL) {
207 dev_err(&pdev->dev, "failed to allocate memory\n"); 164 dev_err(&pdev->dev, "failed to allocate memory\n");
208 return -ENOMEM; 165 return -ENOMEM;
209 } 166 }
210 167
211 pwm->clk = clk_get(&pdev->dev, "pwm"); 168 imx->clk = devm_clk_get(&pdev->dev, "pwm");
212 169
213 if (IS_ERR(pwm->clk)) { 170 if (IS_ERR(imx->clk))
214 ret = PTR_ERR(pwm->clk); 171 return PTR_ERR(imx->clk);
215 goto err_free;
216 }
217 172
218 pwm->clk_enabled = 0; 173 imx->chip.ops = &imx_pwm_ops;
174 imx->chip.dev = &pdev->dev;
175 imx->chip.base = -1;
176 imx->chip.npwm = 1;
219 177
220 pwm->use_count = 0; 178 imx->clk_enabled = 0;
221 pwm->pwm_id = pdev->id;
222 pwm->pdev = pdev;
223 179
224 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 180 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
225 if (r == NULL) { 181 if (r == NULL) {
226 dev_err(&pdev->dev, "no memory resource defined\n"); 182 dev_err(&pdev->dev, "no memory resource defined\n");
227 ret = -ENODEV; 183 return -ENODEV;
228 goto err_free_clk;
229 }
230
231 r = request_mem_region(r->start, resource_size(r), pdev->name);
232 if (r == NULL) {
233 dev_err(&pdev->dev, "failed to request memory resource\n");
234 ret = -EBUSY;
235 goto err_free_clk;
236 } 184 }
237 185
238 pwm->mmio_base = ioremap(r->start, resource_size(r)); 186 imx->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
239 if (pwm->mmio_base == NULL) { 187 if (imx->mmio_base == NULL)
240 dev_err(&pdev->dev, "failed to ioremap() registers\n"); 188 return -EADDRNOTAVAIL;
241 ret = -ENODEV;
242 goto err_free_mem;
243 }
244 189
245 mutex_lock(&pwm_lock); 190 ret = pwmchip_add(&imx->chip);
246 list_add_tail(&pwm->node, &pwm_list); 191 if (ret < 0)
247 mutex_unlock(&pwm_lock); 192 return ret;
248 193
249 platform_set_drvdata(pdev, pwm); 194 platform_set_drvdata(pdev, imx);
250 return 0; 195 return 0;
251
252err_free_mem:
253 release_mem_region(r->start, resource_size(r));
254err_free_clk:
255 clk_put(pwm->clk);
256err_free:
257 kfree(pwm);
258 return ret;
259} 196}
260 197
261static int __devexit mxc_pwm_remove(struct platform_device *pdev) 198static int __devexit imx_pwm_remove(struct platform_device *pdev)
262{ 199{
263 struct pwm_device *pwm; 200 struct imx_chip *imx;
264 struct resource *r;
265 201
266 pwm = platform_get_drvdata(pdev); 202 imx = platform_get_drvdata(pdev);
267 if (pwm == NULL) 203 if (imx == NULL)
268 return -ENODEV; 204 return -ENODEV;
269 205
270 mutex_lock(&pwm_lock); 206 return pwmchip_remove(&imx->chip);
271 list_del(&pwm->node);
272 mutex_unlock(&pwm_lock);
273
274 iounmap(pwm->mmio_base);
275
276 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
277 release_mem_region(r->start, resource_size(r));
278
279 clk_put(pwm->clk);
280
281 kfree(pwm);
282 return 0;
283} 207}
284 208
285static struct platform_driver mxc_pwm_driver = { 209static struct platform_driver imx_pwm_driver = {
286 .driver = { 210 .driver = {
287 .name = "mxc_pwm", 211 .name = "mxc_pwm",
288 }, 212 },
289 .probe = mxc_pwm_probe, 213 .probe = imx_pwm_probe,
290 .remove = __devexit_p(mxc_pwm_remove), 214 .remove = __devexit_p(imx_pwm_remove),
291}; 215};
292 216
293static int __init mxc_pwm_init(void) 217static int __init imx_pwm_init(void)
294{ 218{
295 return platform_driver_register(&mxc_pwm_driver); 219 return platform_driver_register(&imx_pwm_driver);
296} 220}
297arch_initcall(mxc_pwm_init); 221arch_initcall(imx_pwm_init);
298 222
299static void __exit mxc_pwm_exit(void) 223static void __exit imx_pwm_exit(void)
300{ 224{
301 platform_driver_unregister(&mxc_pwm_driver); 225 platform_driver_unregister(&imx_pwm_driver);
302} 226}
303module_exit(mxc_pwm_exit); 227module_exit(imx_pwm_exit);
304 228
305MODULE_LICENSE("GPL v2"); 229MODULE_LICENSE("GPL v2");
306MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); 230MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
diff --git a/drivers/pwm/pwm-lpc32xx.c b/drivers/pwm/pwm-lpc32xx.c
new file mode 100644
index 000000000000..adb87f0c1633
--- /dev/null
+++ b/drivers/pwm/pwm-lpc32xx.c
@@ -0,0 +1,148 @@
1/*
2 * Copyright 2012 Alexandre Pereira da Silva <aletes.xgr@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2.
7 *
8 */
9
10#include <linux/clk.h>
11#include <linux/err.h>
12#include <linux/io.h>
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/of.h>
16#include <linux/of_address.h>
17#include <linux/platform_device.h>
18#include <linux/pwm.h>
19#include <linux/slab.h>
20
21struct lpc32xx_pwm_chip {
22 struct pwm_chip chip;
23 struct clk *clk;
24 void __iomem *base;
25};
26
27#define PWM_ENABLE (1 << 31)
28#define PWM_RELOADV(x) (((x) & 0xFF) << 8)
29#define PWM_DUTY(x) ((x) & 0xFF)
30
31#define to_lpc32xx_pwm_chip(_chip) \
32 container_of(_chip, struct lpc32xx_pwm_chip, chip)
33
34static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
35 int duty_ns, int period_ns)
36{
37 struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip);
38 unsigned long long c;
39 int period_cycles, duty_cycles;
40
41 c = clk_get_rate(lpc32xx->clk) / 256;
42 c = c * period_ns;
43 do_div(c, NSEC_PER_SEC);
44
45 /* Handle high and low extremes */
46 if (c == 0)
47 c = 1;
48 if (c > 255)
49 c = 0; /* 0 set division by 256 */
50 period_cycles = c;
51
52 c = 256 * duty_ns;
53 do_div(c, period_ns);
54 duty_cycles = c;
55
56 writel(PWM_ENABLE | PWM_RELOADV(period_cycles) | PWM_DUTY(duty_cycles),
57 lpc32xx->base + (pwm->hwpwm << 2));
58
59 return 0;
60}
61
62static int lpc32xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
63{
64 struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip);
65
66 return clk_enable(lpc32xx->clk);
67}
68
69static void lpc32xx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
70{
71 struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip);
72
73 writel(0, lpc32xx->base + (pwm->hwpwm << 2));
74 clk_disable(lpc32xx->clk);
75}
76
77static const struct pwm_ops lpc32xx_pwm_ops = {
78 .config = lpc32xx_pwm_config,
79 .enable = lpc32xx_pwm_enable,
80 .disable = lpc32xx_pwm_disable,
81 .owner = THIS_MODULE,
82};
83
84static int lpc32xx_pwm_probe(struct platform_device *pdev)
85{
86 struct lpc32xx_pwm_chip *lpc32xx;
87 struct resource *res;
88 int ret;
89
90 lpc32xx = devm_kzalloc(&pdev->dev, sizeof(*lpc32xx), GFP_KERNEL);
91 if (!lpc32xx)
92 return -ENOMEM;
93
94 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
95 if (!res)
96 return -EINVAL;
97
98 lpc32xx->base = devm_request_and_ioremap(&pdev->dev, res);
99 if (!lpc32xx->base)
100 return -EADDRNOTAVAIL;
101
102 lpc32xx->clk = devm_clk_get(&pdev->dev, NULL);
103 if (IS_ERR(lpc32xx->clk))
104 return PTR_ERR(lpc32xx->clk);
105
106 lpc32xx->chip.dev = &pdev->dev;
107 lpc32xx->chip.ops = &lpc32xx_pwm_ops;
108 lpc32xx->chip.npwm = 2;
109
110 ret = pwmchip_add(&lpc32xx->chip);
111 if (ret < 0) {
112 dev_err(&pdev->dev, "failed to add PWM chip, error %d\n", ret);
113 return ret;
114 }
115
116 platform_set_drvdata(pdev, lpc32xx);
117
118 return 0;
119}
120
121static int __devexit lpc32xx_pwm_remove(struct platform_device *pdev)
122{
123 struct lpc32xx_pwm_chip *lpc32xx = platform_get_drvdata(pdev);
124
125 clk_disable(lpc32xx->clk);
126 return pwmchip_remove(&lpc32xx->chip);
127}
128
129static struct of_device_id lpc32xx_pwm_dt_ids[] = {
130 { .compatible = "nxp,lpc3220-pwm", },
131 { /* sentinel */ }
132};
133MODULE_DEVICE_TABLE(of, lpc32xx_pwm_dt_ids);
134
135static struct platform_driver lpc32xx_pwm_driver = {
136 .driver = {
137 .name = "lpc32xx-pwm",
138 .of_match_table = of_match_ptr(lpc32xx_pwm_dt_ids),
139 },
140 .probe = lpc32xx_pwm_probe,
141 .remove = __devexit_p(lpc32xx_pwm_remove),
142};
143module_platform_driver(lpc32xx_pwm_driver);
144
145MODULE_ALIAS("platform:lpc32xx-pwm");
146MODULE_AUTHOR("Alexandre Pereira da Silva <aletes.xgr@gmail.com>");
147MODULE_DESCRIPTION("LPC32XX PWM Driver");
148MODULE_LICENSE("GPL v2");
diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c
new file mode 100644
index 000000000000..e5852646f082
--- /dev/null
+++ b/drivers/pwm/pwm-mxs.c
@@ -0,0 +1,203 @@
1/*
2 * Copyright 2012 Freescale Semiconductor, Inc.
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */
11
12#include <linux/clk.h>
13#include <linux/err.h>
14#include <linux/io.h>
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/of.h>
18#include <linux/of_address.h>
19#include <linux/pinctrl/consumer.h>
20#include <linux/platform_device.h>
21#include <linux/pwm.h>
22#include <linux/slab.h>
23#include <linux/stmp_device.h>
24
25#define SET 0x4
26#define CLR 0x8
27#define TOG 0xc
28
29#define PWM_CTRL 0x0
30#define PWM_ACTIVE0 0x10
31#define PWM_PERIOD0 0x20
32#define PERIOD_PERIOD(p) ((p) & 0xffff)
33#define PERIOD_PERIOD_MAX 0x10000
34#define PERIOD_ACTIVE_HIGH (3 << 16)
35#define PERIOD_INACTIVE_LOW (2 << 18)
36#define PERIOD_CDIV(div) (((div) & 0x7) << 20)
37#define PERIOD_CDIV_MAX 8
38
39struct mxs_pwm_chip {
40 struct pwm_chip chip;
41 struct device *dev;
42 struct clk *clk;
43 void __iomem *base;
44};
45
46#define to_mxs_pwm_chip(_chip) container_of(_chip, struct mxs_pwm_chip, chip)
47
48static int mxs_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
49 int duty_ns, int period_ns)
50{
51 struct mxs_pwm_chip *mxs = to_mxs_pwm_chip(chip);
52 int ret, div = 0;
53 unsigned int period_cycles, duty_cycles;
54 unsigned long rate;
55 unsigned long long c;
56
57 rate = clk_get_rate(mxs->clk);
58 while (1) {
59 c = rate / (1 << div);
60 c = c * period_ns;
61 do_div(c, 1000000000);
62 if (c < PERIOD_PERIOD_MAX)
63 break;
64 div++;
65 if (div > PERIOD_CDIV_MAX)
66 return -EINVAL;
67 }
68
69 period_cycles = c;
70 c *= duty_ns;
71 do_div(c, period_ns);
72 duty_cycles = c;
73
74 /*
75 * If the PWM channel is disabled, make sure to turn on the clock
76 * before writing the register. Otherwise, keep it enabled.
77 */
78 if (!test_bit(PWMF_ENABLED, &pwm->flags)) {
79 ret = clk_prepare_enable(mxs->clk);
80 if (ret)
81 return ret;
82 }
83
84 writel(duty_cycles << 16,
85 mxs->base + PWM_ACTIVE0 + pwm->hwpwm * 0x20);
86 writel(PERIOD_PERIOD(period_cycles) | PERIOD_ACTIVE_HIGH |
87 PERIOD_INACTIVE_LOW | PERIOD_CDIV(div),
88 mxs->base + PWM_PERIOD0 + pwm->hwpwm * 0x20);
89
90 /*
91 * If the PWM is not enabled, turn the clock off again to save power.
92 */
93 if (!test_bit(PWMF_ENABLED, &pwm->flags))
94 clk_disable_unprepare(mxs->clk);
95
96 return 0;
97}
98
99static int mxs_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
100{
101 struct mxs_pwm_chip *mxs = to_mxs_pwm_chip(chip);
102 int ret;
103
104 ret = clk_prepare_enable(mxs->clk);
105 if (ret)
106 return ret;
107
108 writel(1 << pwm->hwpwm, mxs->base + PWM_CTRL + SET);
109
110 return 0;
111}
112
113static void mxs_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
114{
115 struct mxs_pwm_chip *mxs = to_mxs_pwm_chip(chip);
116
117 writel(1 << pwm->hwpwm, mxs->base + PWM_CTRL + CLR);
118
119 clk_disable_unprepare(mxs->clk);
120}
121
122static const struct pwm_ops mxs_pwm_ops = {
123 .config = mxs_pwm_config,
124 .enable = mxs_pwm_enable,
125 .disable = mxs_pwm_disable,
126 .owner = THIS_MODULE,
127};
128
129static int mxs_pwm_probe(struct platform_device *pdev)
130{
131 struct device_node *np = pdev->dev.of_node;
132 struct mxs_pwm_chip *mxs;
133 struct resource *res;
134 struct pinctrl *pinctrl;
135 int ret;
136
137 mxs = devm_kzalloc(&pdev->dev, sizeof(*mxs), GFP_KERNEL);
138 if (!mxs)
139 return -ENOMEM;
140
141 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
142 mxs->base = devm_request_and_ioremap(&pdev->dev, res);
143 if (!mxs->base)
144 return -EADDRNOTAVAIL;
145
146 pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
147 if (IS_ERR(pinctrl))
148 return PTR_ERR(pinctrl);
149
150 mxs->clk = devm_clk_get(&pdev->dev, NULL);
151 if (IS_ERR(mxs->clk))
152 return PTR_ERR(mxs->clk);
153
154 mxs->chip.dev = &pdev->dev;
155 mxs->chip.ops = &mxs_pwm_ops;
156 mxs->chip.base = -1;
157 ret = of_property_read_u32(np, "fsl,pwm-number", &mxs->chip.npwm);
158 if (ret < 0) {
159 dev_err(&pdev->dev, "failed to get pwm number: %d\n", ret);
160 return ret;
161 }
162
163 ret = pwmchip_add(&mxs->chip);
164 if (ret < 0) {
165 dev_err(&pdev->dev, "failed to add pwm chip %d\n", ret);
166 return ret;
167 }
168
169 mxs->dev = &pdev->dev;
170 platform_set_drvdata(pdev, mxs);
171
172 stmp_reset_block(mxs->base);
173
174 return 0;
175}
176
177static int __devexit mxs_pwm_remove(struct platform_device *pdev)
178{
179 struct mxs_pwm_chip *mxs = platform_get_drvdata(pdev);
180
181 return pwmchip_remove(&mxs->chip);
182}
183
184static struct of_device_id mxs_pwm_dt_ids[] = {
185 { .compatible = "fsl,imx23-pwm", },
186 { /* sentinel */ }
187};
188MODULE_DEVICE_TABLE(of, mxs_pwm_dt_ids);
189
190static struct platform_driver mxs_pwm_driver = {
191 .driver = {
192 .name = "mxs-pwm",
193 .of_match_table = of_match_ptr(mxs_pwm_dt_ids),
194 },
195 .probe = mxs_pwm_probe,
196 .remove = __devexit_p(mxs_pwm_remove),
197};
198module_platform_driver(mxs_pwm_driver);
199
200MODULE_ALIAS("platform:mxs-pwm");
201MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>");
202MODULE_DESCRIPTION("Freescale MXS PWM Driver");
203MODULE_LICENSE("GPL v2");
diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
new file mode 100644
index 000000000000..bd5867a1c700
--- /dev/null
+++ b/drivers/pwm/pwm-pxa.c
@@ -0,0 +1,218 @@
1/*
2 * drivers/pwm/pwm-pxa.c
3 *
4 * simple driver for PWM (Pulse Width Modulator) controller
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * 2008-02-13 initial version
11 * eric miao <eric.miao@marvell.com>
12 */
13
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/platform_device.h>
17#include <linux/slab.h>
18#include <linux/err.h>
19#include <linux/clk.h>
20#include <linux/io.h>
21#include <linux/pwm.h>
22
23#include <asm/div64.h>
24
25#define HAS_SECONDARY_PWM 0x10
26#define PWM_ID_BASE(d) ((d) & 0xf)
27
28static const struct platform_device_id pwm_id_table[] = {
29 /* PWM has_secondary_pwm? */
30 { "pxa25x-pwm", 0 },
31 { "pxa27x-pwm", 0 | HAS_SECONDARY_PWM },
32 { "pxa168-pwm", 1 },
33 { "pxa910-pwm", 1 },
34 { },
35};
36MODULE_DEVICE_TABLE(platform, pwm_id_table);
37
38/* PWM registers and bits definitions */
39#define PWMCR (0x00)
40#define PWMDCR (0x04)
41#define PWMPCR (0x08)
42
43#define PWMCR_SD (1 << 6)
44#define PWMDCR_FD (1 << 10)
45
46struct pxa_pwm_chip {
47 struct pwm_chip chip;
48 struct device *dev;
49
50 struct clk *clk;
51 int clk_enabled;
52 void __iomem *mmio_base;
53};
54
55static inline struct pxa_pwm_chip *to_pxa_pwm_chip(struct pwm_chip *chip)
56{
57 return container_of(chip, struct pxa_pwm_chip, chip);
58}
59
60/*
61 * period_ns = 10^9 * (PRESCALE + 1) * (PV + 1) / PWM_CLK_RATE
62 * duty_ns = 10^9 * (PRESCALE + 1) * DC / PWM_CLK_RATE
63 */
64static int pxa_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
65 int duty_ns, int period_ns)
66{
67 struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip);
68 unsigned long long c;
69 unsigned long period_cycles, prescale, pv, dc;
70 unsigned long offset;
71 int rc;
72
73 if (period_ns == 0 || duty_ns > period_ns)
74 return -EINVAL;
75
76 offset = pwm->hwpwm ? 0x10 : 0;
77
78 c = clk_get_rate(pc->clk);
79 c = c * period_ns;
80 do_div(c, 1000000000);
81 period_cycles = c;
82
83 if (period_cycles < 1)
84 period_cycles = 1;
85 prescale = (period_cycles - 1) / 1024;
86 pv = period_cycles / (prescale + 1) - 1;
87
88 if (prescale > 63)
89 return -EINVAL;
90
91 if (duty_ns == period_ns)
92 dc = PWMDCR_FD;
93 else
94 dc = (pv + 1) * duty_ns / period_ns;
95
96 /* NOTE: the clock to PWM has to be enabled first
97 * before writing to the registers
98 */
99 rc = clk_prepare_enable(pc->clk);
100 if (rc < 0)
101 return rc;
102
103 writel(prescale, pc->mmio_base + offset + PWMCR);
104 writel(dc, pc->mmio_base + offset + PWMDCR);
105 writel(pv, pc->mmio_base + offset + PWMPCR);
106
107 clk_disable_unprepare(pc->clk);
108 return 0;
109}
110
111static int pxa_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
112{
113 struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip);
114 int rc = 0;
115
116 if (!pc->clk_enabled) {
117 rc = clk_prepare_enable(pc->clk);
118 if (!rc)
119 pc->clk_enabled++;
120 }
121 return rc;
122}
123
124static void pxa_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
125{
126 struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip);
127
128 if (pc->clk_enabled) {
129 clk_disable_unprepare(pc->clk);
130 pc->clk_enabled--;
131 }
132}
133
134static struct pwm_ops pxa_pwm_ops = {
135 .config = pxa_pwm_config,
136 .enable = pxa_pwm_enable,
137 .disable = pxa_pwm_disable,
138 .owner = THIS_MODULE,
139};
140
141static int __devinit pwm_probe(struct platform_device *pdev)
142{
143 const struct platform_device_id *id = platform_get_device_id(pdev);
144 struct pxa_pwm_chip *pwm;
145 struct resource *r;
146 int ret = 0;
147
148 pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
149 if (pwm == NULL) {
150 dev_err(&pdev->dev, "failed to allocate memory\n");
151 return -ENOMEM;
152 }
153
154 pwm->clk = devm_clk_get(&pdev->dev, NULL);
155 if (IS_ERR(pwm->clk))
156 return PTR_ERR(pwm->clk);
157
158 pwm->clk_enabled = 0;
159
160 pwm->chip.dev = &pdev->dev;
161 pwm->chip.ops = &pxa_pwm_ops;
162 pwm->chip.base = -1;
163 pwm->chip.npwm = (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1;
164
165 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
166 if (r == NULL) {
167 dev_err(&pdev->dev, "no memory resource defined\n");
168 return -ENODEV;
169 }
170
171 pwm->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
172 if (pwm->mmio_base == NULL)
173 return -EADDRNOTAVAIL;
174
175 ret = pwmchip_add(&pwm->chip);
176 if (ret < 0) {
177 dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
178 return ret;
179 }
180
181 platform_set_drvdata(pdev, pwm);
182 return 0;
183}
184
185static int __devexit pwm_remove(struct platform_device *pdev)
186{
187 struct pxa_pwm_chip *chip;
188
189 chip = platform_get_drvdata(pdev);
190 if (chip == NULL)
191 return -ENODEV;
192
193 return pwmchip_remove(&chip->chip);
194}
195
196static struct platform_driver pwm_driver = {
197 .driver = {
198 .name = "pxa25x-pwm",
199 .owner = THIS_MODULE,
200 },
201 .probe = pwm_probe,
202 .remove = __devexit_p(pwm_remove),
203 .id_table = pwm_id_table,
204};
205
206static int __init pwm_init(void)
207{
208 return platform_driver_register(&pwm_driver);
209}
210arch_initcall(pwm_init);
211
212static void __exit pwm_exit(void)
213{
214 platform_driver_unregister(&pwm_driver);
215}
216module_exit(pwm_exit);
217
218MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/plat-samsung/pwm.c b/drivers/pwm/pwm-samsung.c
index d3583050fb05..d10386528c9c 100644
--- a/arch/arm/plat-samsung/pwm.c
+++ b/drivers/pwm/pwm-samsung.c
@@ -1,4 +1,4 @@
1/* arch/arm/plat-s3c/pwm.c 1/* drivers/pwm/pwm-samsung.c
2 * 2 *
3 * Copyright (c) 2007 Ben Dooks 3 * Copyright (c) 2007 Ben Dooks
4 * Copyright (c) 2008 Simtec Electronics 4 * Copyright (c) 2008 Simtec Electronics
@@ -11,6 +11,8 @@
11 * the Free Software Foundation; either version 2 of the License. 11 * the Free Software Foundation; either version 2 of the License.
12*/ 12*/
13 13
14#define pr_fmt(fmt) "pwm-samsung: " fmt
15
14#include <linux/export.h> 16#include <linux/export.h>
15#include <linux/kernel.h> 17#include <linux/kernel.h>
16#include <linux/platform_device.h> 18#include <linux/platform_device.h>
@@ -24,8 +26,7 @@
24 26
25#include <plat/regs-timer.h> 27#include <plat/regs-timer.h>
26 28
27struct pwm_device { 29struct s3c_chip {
28 struct list_head list;
29 struct platform_device *pdev; 30 struct platform_device *pdev;
30 31
31 struct clk *clk_div; 32 struct clk *clk_div;
@@ -36,81 +37,36 @@ struct pwm_device {
36 unsigned int duty_ns; 37 unsigned int duty_ns;
37 38
38 unsigned char tcon_base; 39 unsigned char tcon_base;
39 unsigned char use_count;
40 unsigned char pwm_id; 40 unsigned char pwm_id;
41 struct pwm_chip chip;
41}; 42};
42 43
44#define to_s3c_chip(chip) container_of(chip, struct s3c_chip, chip)
45
43#define pwm_dbg(_pwm, msg...) dev_dbg(&(_pwm)->pdev->dev, msg) 46#define pwm_dbg(_pwm, msg...) dev_dbg(&(_pwm)->pdev->dev, msg)
44 47
45static struct clk *clk_scaler[2]; 48static struct clk *clk_scaler[2];
46 49
47static inline int pwm_is_tdiv(struct pwm_device *pwm) 50static inline int pwm_is_tdiv(struct s3c_chip *chip)
48{
49 return clk_get_parent(pwm->clk) == pwm->clk_div;
50}
51
52static DEFINE_MUTEX(pwm_lock);
53static LIST_HEAD(pwm_list);
54
55struct pwm_device *pwm_request(int pwm_id, const char *label)
56{
57 struct pwm_device *pwm;
58 int found = 0;
59
60 mutex_lock(&pwm_lock);
61
62 list_for_each_entry(pwm, &pwm_list, list) {
63 if (pwm->pwm_id == pwm_id) {
64 found = 1;
65 break;
66 }
67 }
68
69 if (found) {
70 if (pwm->use_count == 0) {
71 pwm->use_count = 1;
72 pwm->label = label;
73 } else
74 pwm = ERR_PTR(-EBUSY);
75 } else
76 pwm = ERR_PTR(-ENOENT);
77
78 mutex_unlock(&pwm_lock);
79 return pwm;
80}
81
82EXPORT_SYMBOL(pwm_request);
83
84
85void pwm_free(struct pwm_device *pwm)
86{ 51{
87 mutex_lock(&pwm_lock); 52 return clk_get_parent(chip->clk) == chip->clk_div;
88
89 if (pwm->use_count) {
90 pwm->use_count--;
91 pwm->label = NULL;
92 } else
93 printk(KERN_ERR "PWM%d device already freed\n", pwm->pwm_id);
94
95 mutex_unlock(&pwm_lock);
96} 53}
97 54
98EXPORT_SYMBOL(pwm_free);
99
100#define pwm_tcon_start(pwm) (1 << (pwm->tcon_base + 0)) 55#define pwm_tcon_start(pwm) (1 << (pwm->tcon_base + 0))
101#define pwm_tcon_invert(pwm) (1 << (pwm->tcon_base + 2)) 56#define pwm_tcon_invert(pwm) (1 << (pwm->tcon_base + 2))
102#define pwm_tcon_autoreload(pwm) (1 << (pwm->tcon_base + 3)) 57#define pwm_tcon_autoreload(pwm) (1 << (pwm->tcon_base + 3))
103#define pwm_tcon_manulupdate(pwm) (1 << (pwm->tcon_base + 1)) 58#define pwm_tcon_manulupdate(pwm) (1 << (pwm->tcon_base + 1))
104 59
105int pwm_enable(struct pwm_device *pwm) 60static int s3c_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
106{ 61{
62 struct s3c_chip *s3c = to_s3c_chip(chip);
107 unsigned long flags; 63 unsigned long flags;
108 unsigned long tcon; 64 unsigned long tcon;
109 65
110 local_irq_save(flags); 66 local_irq_save(flags);
111 67
112 tcon = __raw_readl(S3C2410_TCON); 68 tcon = __raw_readl(S3C2410_TCON);
113 tcon |= pwm_tcon_start(pwm); 69 tcon |= pwm_tcon_start(s3c);
114 __raw_writel(tcon, S3C2410_TCON); 70 __raw_writel(tcon, S3C2410_TCON);
115 71
116 local_irq_restore(flags); 72 local_irq_restore(flags);
@@ -118,31 +74,28 @@ int pwm_enable(struct pwm_device *pwm)
118 return 0; 74 return 0;
119} 75}
120 76
121EXPORT_SYMBOL(pwm_enable); 77static void s3c_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
122
123void pwm_disable(struct pwm_device *pwm)
124{ 78{
79 struct s3c_chip *s3c = to_s3c_chip(chip);
125 unsigned long flags; 80 unsigned long flags;
126 unsigned long tcon; 81 unsigned long tcon;
127 82
128 local_irq_save(flags); 83 local_irq_save(flags);
129 84
130 tcon = __raw_readl(S3C2410_TCON); 85 tcon = __raw_readl(S3C2410_TCON);
131 tcon &= ~pwm_tcon_start(pwm); 86 tcon &= ~pwm_tcon_start(s3c);
132 __raw_writel(tcon, S3C2410_TCON); 87 __raw_writel(tcon, S3C2410_TCON);
133 88
134 local_irq_restore(flags); 89 local_irq_restore(flags);
135} 90}
136 91
137EXPORT_SYMBOL(pwm_disable); 92static unsigned long pwm_calc_tin(struct s3c_chip *s3c, unsigned long freq)
138
139static unsigned long pwm_calc_tin(struct pwm_device *pwm, unsigned long freq)
140{ 93{
141 unsigned long tin_parent_rate; 94 unsigned long tin_parent_rate;
142 unsigned int div; 95 unsigned int div;
143 96
144 tin_parent_rate = clk_get_rate(clk_get_parent(pwm->clk_div)); 97 tin_parent_rate = clk_get_rate(clk_get_parent(s3c->clk_div));
145 pwm_dbg(pwm, "tin parent at %lu\n", tin_parent_rate); 98 pwm_dbg(s3c, "tin parent at %lu\n", tin_parent_rate);
146 99
147 for (div = 2; div <= 16; div *= 2) { 100 for (div = 2; div <= 16; div *= 2) {
148 if ((tin_parent_rate / (div << 16)) < freq) 101 if ((tin_parent_rate / (div << 16)) < freq)
@@ -154,8 +107,10 @@ static unsigned long pwm_calc_tin(struct pwm_device *pwm, unsigned long freq)
154 107
155#define NS_IN_HZ (1000000000UL) 108#define NS_IN_HZ (1000000000UL)
156 109
157int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns) 110static int s3c_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
111 int duty_ns, int period_ns)
158{ 112{
113 struct s3c_chip *s3c = to_s3c_chip(chip);
159 unsigned long tin_rate; 114 unsigned long tin_rate;
160 unsigned long tin_ns; 115 unsigned long tin_ns;
161 unsigned long period; 116 unsigned long period;
@@ -174,38 +129,38 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
174 if (duty_ns > period_ns) 129 if (duty_ns > period_ns)
175 return -EINVAL; 130 return -EINVAL;
176 131
177 if (period_ns == pwm->period_ns && 132 if (period_ns == s3c->period_ns &&
178 duty_ns == pwm->duty_ns) 133 duty_ns == s3c->duty_ns)
179 return 0; 134 return 0;
180 135
181 /* The TCMP and TCNT can be read without a lock, they're not 136 /* The TCMP and TCNT can be read without a lock, they're not
182 * shared between the timers. */ 137 * shared between the timers. */
183 138
184 tcmp = __raw_readl(S3C2410_TCMPB(pwm->pwm_id)); 139 tcmp = __raw_readl(S3C2410_TCMPB(s3c->pwm_id));
185 tcnt = __raw_readl(S3C2410_TCNTB(pwm->pwm_id)); 140 tcnt = __raw_readl(S3C2410_TCNTB(s3c->pwm_id));
186 141
187 period = NS_IN_HZ / period_ns; 142 period = NS_IN_HZ / period_ns;
188 143
189 pwm_dbg(pwm, "duty_ns=%d, period_ns=%d (%lu)\n", 144 pwm_dbg(s3c, "duty_ns=%d, period_ns=%d (%lu)\n",
190 duty_ns, period_ns, period); 145 duty_ns, period_ns, period);
191 146
192 /* Check to see if we are changing the clock rate of the PWM */ 147 /* Check to see if we are changing the clock rate of the PWM */
193 148
194 if (pwm->period_ns != period_ns) { 149 if (s3c->period_ns != period_ns) {
195 if (pwm_is_tdiv(pwm)) { 150 if (pwm_is_tdiv(s3c)) {
196 tin_rate = pwm_calc_tin(pwm, period); 151 tin_rate = pwm_calc_tin(s3c, period);
197 clk_set_rate(pwm->clk_div, tin_rate); 152 clk_set_rate(s3c->clk_div, tin_rate);
198 } else 153 } else
199 tin_rate = clk_get_rate(pwm->clk); 154 tin_rate = clk_get_rate(s3c->clk);
200 155
201 pwm->period_ns = period_ns; 156 s3c->period_ns = period_ns;
202 157
203 pwm_dbg(pwm, "tin_rate=%lu\n", tin_rate); 158 pwm_dbg(s3c, "tin_rate=%lu\n", tin_rate);
204 159
205 tin_ns = NS_IN_HZ / tin_rate; 160 tin_ns = NS_IN_HZ / tin_rate;
206 tcnt = period_ns / tin_ns; 161 tcnt = period_ns / tin_ns;
207 } else 162 } else
208 tin_ns = NS_IN_HZ / clk_get_rate(pwm->clk); 163 tin_ns = NS_IN_HZ / clk_get_rate(s3c->clk);
209 164
210 /* Note, counters count down */ 165 /* Note, counters count down */
211 166
@@ -216,7 +171,7 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
216 if (tcmp == tcnt) 171 if (tcmp == tcnt)
217 tcmp--; 172 tcmp--;
218 173
219 pwm_dbg(pwm, "tin_ns=%lu, tcmp=%ld/%lu\n", tin_ns, tcmp, tcnt); 174 pwm_dbg(s3c, "tin_ns=%lu, tcmp=%ld/%lu\n", tin_ns, tcmp, tcnt);
220 175
221 if (tcmp < 0) 176 if (tcmp < 0)
222 tcmp = 0; 177 tcmp = 0;
@@ -225,15 +180,15 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
225 180
226 local_irq_save(flags); 181 local_irq_save(flags);
227 182
228 __raw_writel(tcmp, S3C2410_TCMPB(pwm->pwm_id)); 183 __raw_writel(tcmp, S3C2410_TCMPB(s3c->pwm_id));
229 __raw_writel(tcnt, S3C2410_TCNTB(pwm->pwm_id)); 184 __raw_writel(tcnt, S3C2410_TCNTB(s3c->pwm_id));
230 185
231 tcon = __raw_readl(S3C2410_TCON); 186 tcon = __raw_readl(S3C2410_TCON);
232 tcon |= pwm_tcon_manulupdate(pwm); 187 tcon |= pwm_tcon_manulupdate(s3c);
233 tcon |= pwm_tcon_autoreload(pwm); 188 tcon |= pwm_tcon_autoreload(s3c);
234 __raw_writel(tcon, S3C2410_TCON); 189 __raw_writel(tcon, S3C2410_TCON);
235 190
236 tcon &= ~pwm_tcon_manulupdate(pwm); 191 tcon &= ~pwm_tcon_manulupdate(s3c);
237 __raw_writel(tcon, S3C2410_TCON); 192 __raw_writel(tcon, S3C2410_TCON);
238 193
239 local_irq_restore(flags); 194 local_irq_restore(flags);
@@ -241,24 +196,17 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
241 return 0; 196 return 0;
242} 197}
243 198
244EXPORT_SYMBOL(pwm_config); 199static struct pwm_ops s3c_pwm_ops = {
245 200 .enable = s3c_pwm_enable,
246static int pwm_register(struct pwm_device *pwm) 201 .disable = s3c_pwm_disable,
247{ 202 .config = s3c_pwm_config,
248 pwm->duty_ns = -1; 203 .owner = THIS_MODULE,
249 pwm->period_ns = -1; 204};
250
251 mutex_lock(&pwm_lock);
252 list_add_tail(&pwm->list, &pwm_list);
253 mutex_unlock(&pwm_lock);
254
255 return 0;
256}
257 205
258static int s3c_pwm_probe(struct platform_device *pdev) 206static int s3c_pwm_probe(struct platform_device *pdev)
259{ 207{
260 struct device *dev = &pdev->dev; 208 struct device *dev = &pdev->dev;
261 struct pwm_device *pwm; 209 struct s3c_chip *s3c;
262 unsigned long flags; 210 unsigned long flags;
263 unsigned long tcon; 211 unsigned long tcon;
264 unsigned int id = pdev->id; 212 unsigned int id = pdev->id;
@@ -269,83 +217,75 @@ static int s3c_pwm_probe(struct platform_device *pdev)
269 return -ENXIO; 217 return -ENXIO;
270 } 218 }
271 219
272 pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL); 220 s3c = devm_kzalloc(&pdev->dev, sizeof(*s3c), GFP_KERNEL);
273 if (pwm == NULL) { 221 if (s3c == NULL) {
274 dev_err(dev, "failed to allocate pwm_device\n"); 222 dev_err(dev, "failed to allocate pwm_device\n");
275 return -ENOMEM; 223 return -ENOMEM;
276 } 224 }
277 225
278 pwm->pdev = pdev;
279 pwm->pwm_id = id;
280
281 /* calculate base of control bits in TCON */ 226 /* calculate base of control bits in TCON */
282 pwm->tcon_base = id == 0 ? 0 : (id * 4) + 4; 227 s3c->tcon_base = id == 0 ? 0 : (id * 4) + 4;
228 s3c->chip.ops = &s3c_pwm_ops;
229 s3c->chip.base = -1;
230 s3c->chip.npwm = 1;
283 231
284 pwm->clk = clk_get(dev, "pwm-tin"); 232 s3c->clk = devm_clk_get(dev, "pwm-tin");
285 if (IS_ERR(pwm->clk)) { 233 if (IS_ERR(s3c->clk)) {
286 dev_err(dev, "failed to get pwm tin clk\n"); 234 dev_err(dev, "failed to get pwm tin clk\n");
287 ret = PTR_ERR(pwm->clk); 235 return PTR_ERR(s3c->clk);
288 goto err_alloc;
289 } 236 }
290 237
291 pwm->clk_div = clk_get(dev, "pwm-tdiv"); 238 s3c->clk_div = devm_clk_get(dev, "pwm-tdiv");
292 if (IS_ERR(pwm->clk_div)) { 239 if (IS_ERR(s3c->clk_div)) {
293 dev_err(dev, "failed to get pwm tdiv clk\n"); 240 dev_err(dev, "failed to get pwm tdiv clk\n");
294 ret = PTR_ERR(pwm->clk_div); 241 return PTR_ERR(s3c->clk_div);
295 goto err_clk_tin;
296 } 242 }
297 243
298 clk_enable(pwm->clk); 244 clk_enable(s3c->clk);
299 clk_enable(pwm->clk_div); 245 clk_enable(s3c->clk_div);
300 246
301 local_irq_save(flags); 247 local_irq_save(flags);
302 248
303 tcon = __raw_readl(S3C2410_TCON); 249 tcon = __raw_readl(S3C2410_TCON);
304 tcon |= pwm_tcon_invert(pwm); 250 tcon |= pwm_tcon_invert(s3c);
305 __raw_writel(tcon, S3C2410_TCON); 251 __raw_writel(tcon, S3C2410_TCON);
306 252
307 local_irq_restore(flags); 253 local_irq_restore(flags);
308 254
309 255 ret = pwmchip_add(&s3c->chip);
310 ret = pwm_register(pwm); 256 if (ret < 0) {
311 if (ret) {
312 dev_err(dev, "failed to register pwm\n"); 257 dev_err(dev, "failed to register pwm\n");
313 goto err_clk_tdiv; 258 goto err_clk_tdiv;
314 } 259 }
315 260
316 pwm_dbg(pwm, "config bits %02x\n", 261 pwm_dbg(s3c, "config bits %02x\n",
317 (__raw_readl(S3C2410_TCON) >> pwm->tcon_base) & 0x0f); 262 (__raw_readl(S3C2410_TCON) >> s3c->tcon_base) & 0x0f);
318 263
319 dev_info(dev, "tin at %lu, tdiv at %lu, tin=%sclk, base %d\n", 264 dev_info(dev, "tin at %lu, tdiv at %lu, tin=%sclk, base %d\n",
320 clk_get_rate(pwm->clk), 265 clk_get_rate(s3c->clk),
321 clk_get_rate(pwm->clk_div), 266 clk_get_rate(s3c->clk_div),
322 pwm_is_tdiv(pwm) ? "div" : "ext", pwm->tcon_base); 267 pwm_is_tdiv(s3c) ? "div" : "ext", s3c->tcon_base);
323 268
324 platform_set_drvdata(pdev, pwm); 269 platform_set_drvdata(pdev, s3c);
325 return 0; 270 return 0;
326 271
327 err_clk_tdiv: 272 err_clk_tdiv:
328 clk_disable(pwm->clk_div); 273 clk_disable(s3c->clk_div);
329 clk_disable(pwm->clk); 274 clk_disable(s3c->clk);
330 clk_put(pwm->clk_div);
331
332 err_clk_tin:
333 clk_put(pwm->clk);
334
335 err_alloc:
336 kfree(pwm);
337 return ret; 275 return ret;
338} 276}
339 277
340static int __devexit s3c_pwm_remove(struct platform_device *pdev) 278static int __devexit s3c_pwm_remove(struct platform_device *pdev)
341{ 279{
342 struct pwm_device *pwm = platform_get_drvdata(pdev); 280 struct s3c_chip *s3c = platform_get_drvdata(pdev);
281 int err;
282
283 err = pwmchip_remove(&s3c->chip);
284 if (err < 0)
285 return err;
343 286
344 clk_disable(pwm->clk_div); 287 clk_disable(s3c->clk_div);
345 clk_disable(pwm->clk); 288 clk_disable(s3c->clk);
346 clk_put(pwm->clk_div);
347 clk_put(pwm->clk);
348 kfree(pwm);
349 289
350 return 0; 290 return 0;
351} 291}
@@ -353,26 +293,26 @@ static int __devexit s3c_pwm_remove(struct platform_device *pdev)
353#ifdef CONFIG_PM 293#ifdef CONFIG_PM
354static int s3c_pwm_suspend(struct platform_device *pdev, pm_message_t state) 294static int s3c_pwm_suspend(struct platform_device *pdev, pm_message_t state)
355{ 295{
356 struct pwm_device *pwm = platform_get_drvdata(pdev); 296 struct s3c_chip *s3c = platform_get_drvdata(pdev);
357 297
358 /* No one preserve these values during suspend so reset them 298 /* No one preserve these values during suspend so reset them
359 * Otherwise driver leaves PWM unconfigured if same values 299 * Otherwise driver leaves PWM unconfigured if same values
360 * passed to pwm_config 300 * passed to pwm_config
361 */ 301 */
362 pwm->period_ns = 0; 302 s3c->period_ns = 0;
363 pwm->duty_ns = 0; 303 s3c->duty_ns = 0;
364 304
365 return 0; 305 return 0;
366} 306}
367 307
368static int s3c_pwm_resume(struct platform_device *pdev) 308static int s3c_pwm_resume(struct platform_device *pdev)
369{ 309{
370 struct pwm_device *pwm = platform_get_drvdata(pdev); 310 struct s3c_chip *s3c = platform_get_drvdata(pdev);
371 unsigned long tcon; 311 unsigned long tcon;
372 312
373 /* Restore invertion */ 313 /* Restore invertion */
374 tcon = __raw_readl(S3C2410_TCON); 314 tcon = __raw_readl(S3C2410_TCON);
375 tcon |= pwm_tcon_invert(pwm); 315 tcon |= pwm_tcon_invert(s3c);
376 __raw_writel(tcon, S3C2410_TCON); 316 __raw_writel(tcon, S3C2410_TCON);
377 317
378 return 0; 318 return 0;
@@ -402,13 +342,13 @@ static int __init pwm_init(void)
402 clk_scaler[1] = clk_get(NULL, "pwm-scaler1"); 342 clk_scaler[1] = clk_get(NULL, "pwm-scaler1");
403 343
404 if (IS_ERR(clk_scaler[0]) || IS_ERR(clk_scaler[1])) { 344 if (IS_ERR(clk_scaler[0]) || IS_ERR(clk_scaler[1])) {
405 printk(KERN_ERR "%s: failed to get scaler clocks\n", __func__); 345 pr_err("failed to get scaler clocks\n");
406 return -EINVAL; 346 return -EINVAL;
407 } 347 }
408 348
409 ret = platform_driver_register(&s3c_pwm_driver); 349 ret = platform_driver_register(&s3c_pwm_driver);
410 if (ret) 350 if (ret)
411 printk(KERN_ERR "%s: failed to add pwm driver\n", __func__); 351 pr_err("failed to add pwm driver\n");
412 352
413 return ret; 353 return ret;
414} 354}
diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
new file mode 100644
index 000000000000..02ce18d5e49a
--- /dev/null
+++ b/drivers/pwm/pwm-tegra.c
@@ -0,0 +1,261 @@
1/*
2 * drivers/pwm/pwm-tegra.c
3 *
4 * Tegra pulse-width-modulation controller driver
5 *
6 * Copyright (c) 2010, NVIDIA Corporation.
7 * Based on arch/arm/plat-mxc/pwm.c by Sascha Hauer <s.hauer@pengutronix.de>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 */
23
24#include <linux/clk.h>
25#include <linux/err.h>
26#include <linux/io.h>
27#include <linux/module.h>
28#include <linux/of.h>
29#include <linux/pwm.h>
30#include <linux/platform_device.h>
31#include <linux/slab.h>
32
33#define PWM_ENABLE (1 << 31)
34#define PWM_DUTY_WIDTH 8
35#define PWM_DUTY_SHIFT 16
36#define PWM_SCALE_WIDTH 13
37#define PWM_SCALE_SHIFT 0
38
39#define NUM_PWM 4
40
41struct tegra_pwm_chip {
42 struct pwm_chip chip;
43 struct device *dev;
44
45 struct clk *clk;
46
47 void __iomem *mmio_base;
48};
49
50static inline struct tegra_pwm_chip *to_tegra_pwm_chip(struct pwm_chip *chip)
51{
52 return container_of(chip, struct tegra_pwm_chip, chip);
53}
54
55static inline u32 pwm_readl(struct tegra_pwm_chip *chip, unsigned int num)
56{
57 return readl(chip->mmio_base + (num << 4));
58}
59
60static inline void pwm_writel(struct tegra_pwm_chip *chip, unsigned int num,
61 unsigned long val)
62{
63 writel(val, chip->mmio_base + (num << 4));
64}
65
66static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
67 int duty_ns, int period_ns)
68{
69 struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip);
70 unsigned long long c;
71 unsigned long rate, hz;
72 u32 val = 0;
73 int err;
74
75 /*
76 * Convert from duty_ns / period_ns to a fixed number of duty ticks
77 * per (1 << PWM_DUTY_WIDTH) cycles and make sure to round to the
78 * nearest integer during division.
79 */
80 c = duty_ns * ((1 << PWM_DUTY_WIDTH) - 1) + period_ns / 2;
81 do_div(c, period_ns);
82
83 val = (u32)c << PWM_DUTY_SHIFT;
84
85 /*
86 * Compute the prescaler value for which (1 << PWM_DUTY_WIDTH)
87 * cycles at the PWM clock rate will take period_ns nanoseconds.
88 */
89 rate = clk_get_rate(pc->clk) >> PWM_DUTY_WIDTH;
90 hz = 1000000000ul / period_ns;
91
92 rate = (rate + (hz / 2)) / hz;
93
94 /*
95 * Since the actual PWM divider is the register's frequency divider
96 * field minus 1, we need to decrement to get the correct value to
97 * write to the register.
98 */
99 if (rate > 0)
100 rate--;
101
102 /*
103 * Make sure that the rate will fit in the register's frequency
104 * divider field.
105 */
106 if (rate >> PWM_SCALE_WIDTH)
107 return -EINVAL;
108
109 val |= rate << PWM_SCALE_SHIFT;
110
111 /*
112 * If the PWM channel is disabled, make sure to turn on the clock
113 * before writing the register. Otherwise, keep it enabled.
114 */
115 if (!test_bit(PWMF_ENABLED, &pwm->flags)) {
116 err = clk_prepare_enable(pc->clk);
117 if (err < 0)
118 return err;
119 } else
120 val |= PWM_ENABLE;
121
122 pwm_writel(pc, pwm->hwpwm, val);
123
124 /*
125 * If the PWM is not enabled, turn the clock off again to save power.
126 */
127 if (!test_bit(PWMF_ENABLED, &pwm->flags))
128 clk_disable_unprepare(pc->clk);
129
130 return 0;
131}
132
133static int tegra_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
134{
135 struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip);
136 int rc = 0;
137 u32 val;
138
139 rc = clk_prepare_enable(pc->clk);
140 if (rc < 0)
141 return rc;
142
143 val = pwm_readl(pc, pwm->hwpwm);
144 val |= PWM_ENABLE;
145 pwm_writel(pc, pwm->hwpwm, val);
146
147 return 0;
148}
149
150static void tegra_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
151{
152 struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip);
153 u32 val;
154
155 val = pwm_readl(pc, pwm->hwpwm);
156 val &= ~PWM_ENABLE;
157 pwm_writel(pc, pwm->hwpwm, val);
158
159 clk_disable_unprepare(pc->clk);
160}
161
162static const struct pwm_ops tegra_pwm_ops = {
163 .config = tegra_pwm_config,
164 .enable = tegra_pwm_enable,
165 .disable = tegra_pwm_disable,
166 .owner = THIS_MODULE,
167};
168
169static int tegra_pwm_probe(struct platform_device *pdev)
170{
171 struct tegra_pwm_chip *pwm;
172 struct resource *r;
173 int ret;
174
175 pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
176 if (!pwm) {
177 dev_err(&pdev->dev, "failed to allocate memory\n");
178 return -ENOMEM;
179 }
180
181 pwm->dev = &pdev->dev;
182
183 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
184 if (!r) {
185 dev_err(&pdev->dev, "no memory resources defined\n");
186 return -ENODEV;
187 }
188
189 pwm->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
190 if (!pwm->mmio_base) {
191 dev_err(&pdev->dev, "failed to ioremap() region\n");
192 return -EADDRNOTAVAIL;
193 }
194
195 platform_set_drvdata(pdev, pwm);
196
197 pwm->clk = devm_clk_get(&pdev->dev, NULL);
198 if (IS_ERR(pwm->clk))
199 return PTR_ERR(pwm->clk);
200
201 pwm->chip.dev = &pdev->dev;
202 pwm->chip.ops = &tegra_pwm_ops;
203 pwm->chip.base = -1;
204 pwm->chip.npwm = NUM_PWM;
205
206 ret = pwmchip_add(&pwm->chip);
207 if (ret < 0) {
208 dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
209 return ret;
210 }
211
212 return 0;
213}
214
215static int __devexit tegra_pwm_remove(struct platform_device *pdev)
216{
217 struct tegra_pwm_chip *pc = platform_get_drvdata(pdev);
218 int i;
219
220 if (WARN_ON(!pc))
221 return -ENODEV;
222
223 for (i = 0; i < NUM_PWM; i++) {
224 struct pwm_device *pwm = &pc->chip.pwms[i];
225
226 if (!test_bit(PWMF_ENABLED, &pwm->flags))
227 if (clk_prepare_enable(pc->clk) < 0)
228 continue;
229
230 pwm_writel(pc, i, 0);
231
232 clk_disable_unprepare(pc->clk);
233 }
234
235 return pwmchip_remove(&pc->chip);
236}
237
238#ifdef CONFIG_OF
239static struct of_device_id tegra_pwm_of_match[] = {
240 { .compatible = "nvidia,tegra20-pwm" },
241 { .compatible = "nvidia,tegra30-pwm" },
242 { }
243};
244
245MODULE_DEVICE_TABLE(of, tegra_pwm_of_match);
246#endif
247
248static struct platform_driver tegra_pwm_driver = {
249 .driver = {
250 .name = "tegra-pwm",
251 .of_match_table = of_match_ptr(tegra_pwm_of_match),
252 },
253 .probe = tegra_pwm_probe,
254 .remove = __devexit_p(tegra_pwm_remove),
255};
256
257module_platform_driver(tegra_pwm_driver);
258
259MODULE_LICENSE("GPL");
260MODULE_AUTHOR("NVIDIA Corporation");
261MODULE_ALIAS("platform:tegra-pwm");
diff --git a/drivers/pwm/pwm-tiecap.c b/drivers/pwm/pwm-tiecap.c
new file mode 100644
index 000000000000..3c2ad284ee3e
--- /dev/null
+++ b/drivers/pwm/pwm-tiecap.c
@@ -0,0 +1,232 @@
1/*
2 * ECAP PWM driver
3 *
4 * Copyright (C) 2012 Texas Instruments, Inc. - http://www.ti.com/
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#include <linux/module.h>
22#include <linux/platform_device.h>
23#include <linux/io.h>
24#include <linux/err.h>
25#include <linux/clk.h>
26#include <linux/pm_runtime.h>
27#include <linux/pwm.h>
28
29/* ECAP registers and bits definitions */
30#define CAP1 0x08
31#define CAP2 0x0C
32#define CAP3 0x10
33#define CAP4 0x14
34#define ECCTL2 0x2A
35#define ECCTL2_APWM_MODE BIT(9)
36#define ECCTL2_SYNC_SEL_DISA (BIT(7) | BIT(6))
37#define ECCTL2_TSCTR_FREERUN BIT(4)
38
39struct ecap_pwm_chip {
40 struct pwm_chip chip;
41 unsigned int clk_rate;
42 void __iomem *mmio_base;
43};
44
45static inline struct ecap_pwm_chip *to_ecap_pwm_chip(struct pwm_chip *chip)
46{
47 return container_of(chip, struct ecap_pwm_chip, chip);
48}
49
50/*
51 * period_ns = 10^9 * period_cycles / PWM_CLK_RATE
52 * duty_ns = 10^9 * duty_cycles / PWM_CLK_RATE
53 */
54static int ecap_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
55 int duty_ns, int period_ns)
56{
57 struct ecap_pwm_chip *pc = to_ecap_pwm_chip(chip);
58 unsigned long long c;
59 unsigned long period_cycles, duty_cycles;
60 unsigned int reg_val;
61
62 if (period_ns < 0 || duty_ns < 0 || period_ns > NSEC_PER_SEC)
63 return -ERANGE;
64
65 c = pc->clk_rate;
66 c = c * period_ns;
67 do_div(c, NSEC_PER_SEC);
68 period_cycles = (unsigned long)c;
69
70 if (period_cycles < 1) {
71 period_cycles = 1;
72 duty_cycles = 1;
73 } else {
74 c = pc->clk_rate;
75 c = c * duty_ns;
76 do_div(c, NSEC_PER_SEC);
77 duty_cycles = (unsigned long)c;
78 }
79
80 pm_runtime_get_sync(pc->chip.dev);
81
82 reg_val = readw(pc->mmio_base + ECCTL2);
83
84 /* Configure APWM mode & disable sync option */
85 reg_val |= ECCTL2_APWM_MODE | ECCTL2_SYNC_SEL_DISA;
86
87 writew(reg_val, pc->mmio_base + ECCTL2);
88
89 if (!test_bit(PWMF_ENABLED, &pwm->flags)) {
90 /* Update active registers if not running */
91 writel(duty_cycles, pc->mmio_base + CAP2);
92 writel(period_cycles, pc->mmio_base + CAP1);
93 } else {
94 /*
95 * Update shadow registers to configure period and
96 * compare values. This helps current PWM period to
97 * complete on reconfiguring
98 */
99 writel(duty_cycles, pc->mmio_base + CAP4);
100 writel(period_cycles, pc->mmio_base + CAP3);
101 }
102
103 pm_runtime_put_sync(pc->chip.dev);
104 return 0;
105}
106
107static int ecap_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
108{
109 struct ecap_pwm_chip *pc = to_ecap_pwm_chip(chip);
110 unsigned int reg_val;
111
112 /* Leave clock enabled on enabling PWM */
113 pm_runtime_get_sync(pc->chip.dev);
114
115 /*
116 * Enable 'Free run Time stamp counter mode' to start counter
117 * and 'APWM mode' to enable APWM output
118 */
119 reg_val = readw(pc->mmio_base + ECCTL2);
120 reg_val |= ECCTL2_TSCTR_FREERUN | ECCTL2_APWM_MODE;
121 writew(reg_val, pc->mmio_base + ECCTL2);
122 return 0;
123}
124
125static void ecap_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
126{
127 struct ecap_pwm_chip *pc = to_ecap_pwm_chip(chip);
128 unsigned int reg_val;
129
130 /*
131 * Disable 'Free run Time stamp counter mode' to stop counter
132 * and 'APWM mode' to put APWM output to low
133 */
134 reg_val = readw(pc->mmio_base + ECCTL2);
135 reg_val &= ~(ECCTL2_TSCTR_FREERUN | ECCTL2_APWM_MODE);
136 writew(reg_val, pc->mmio_base + ECCTL2);
137
138 /* Disable clock on PWM disable */
139 pm_runtime_put_sync(pc->chip.dev);
140}
141
142static void ecap_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
143{
144 if (test_bit(PWMF_ENABLED, &pwm->flags)) {
145 dev_warn(chip->dev, "Removing PWM device without disabling\n");
146 pm_runtime_put_sync(chip->dev);
147 }
148}
149
150static const struct pwm_ops ecap_pwm_ops = {
151 .free = ecap_pwm_free,
152 .config = ecap_pwm_config,
153 .enable = ecap_pwm_enable,
154 .disable = ecap_pwm_disable,
155 .owner = THIS_MODULE,
156};
157
158static int __devinit ecap_pwm_probe(struct platform_device *pdev)
159{
160 int ret;
161 struct resource *r;
162 struct clk *clk;
163 struct ecap_pwm_chip *pc;
164
165 pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
166 if (!pc) {
167 dev_err(&pdev->dev, "failed to allocate memory\n");
168 return -ENOMEM;
169 }
170
171 clk = devm_clk_get(&pdev->dev, "fck");
172 if (IS_ERR(clk)) {
173 dev_err(&pdev->dev, "failed to get clock\n");
174 return PTR_ERR(clk);
175 }
176
177 pc->clk_rate = clk_get_rate(clk);
178 if (!pc->clk_rate) {
179 dev_err(&pdev->dev, "failed to get clock rate\n");
180 return -EINVAL;
181 }
182
183 pc->chip.dev = &pdev->dev;
184 pc->chip.ops = &ecap_pwm_ops;
185 pc->chip.base = -1;
186 pc->chip.npwm = 1;
187
188 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
189 if (!r) {
190 dev_err(&pdev->dev, "no memory resource defined\n");
191 return -ENODEV;
192 }
193
194 pc->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
195 if (!pc->mmio_base) {
196 dev_err(&pdev->dev, "failed to ioremap() registers\n");
197 return -EADDRNOTAVAIL;
198 }
199
200 ret = pwmchip_add(&pc->chip);
201 if (ret < 0) {
202 dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
203 return ret;
204 }
205
206 pm_runtime_enable(&pdev->dev);
207 platform_set_drvdata(pdev, pc);
208 return 0;
209}
210
211static int __devexit ecap_pwm_remove(struct platform_device *pdev)
212{
213 struct ecap_pwm_chip *pc = platform_get_drvdata(pdev);
214
215 pm_runtime_put_sync(&pdev->dev);
216 pm_runtime_disable(&pdev->dev);
217 return pwmchip_remove(&pc->chip);
218}
219
220static struct platform_driver ecap_pwm_driver = {
221 .driver = {
222 .name = "ecap",
223 },
224 .probe = ecap_pwm_probe,
225 .remove = __devexit_p(ecap_pwm_remove),
226};
227
228module_platform_driver(ecap_pwm_driver);
229
230MODULE_DESCRIPTION("ECAP PWM driver");
231MODULE_AUTHOR("Texas Instruments");
232MODULE_LICENSE("GPL");
diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
new file mode 100644
index 000000000000..010d232cb0c8
--- /dev/null
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -0,0 +1,411 @@
1/*
2 * EHRPWM PWM driver
3 *
4 * Copyright (C) 2012 Texas Instruments, Inc. - http://www.ti.com/
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#include <linux/module.h>
22#include <linux/platform_device.h>
23#include <linux/pwm.h>
24#include <linux/io.h>
25#include <linux/err.h>
26#include <linux/clk.h>
27#include <linux/pm_runtime.h>
28
29/* EHRPWM registers and bits definitions */
30
31/* Time base module registers */
32#define TBCTL 0x00
33#define TBPRD 0x0A
34
35#define TBCTL_RUN_MASK (BIT(15) | BIT(14))
36#define TBCTL_STOP_NEXT 0
37#define TBCTL_STOP_ON_CYCLE BIT(14)
38#define TBCTL_FREE_RUN (BIT(15) | BIT(14))
39#define TBCTL_PRDLD_MASK BIT(3)
40#define TBCTL_PRDLD_SHDW 0
41#define TBCTL_PRDLD_IMDT BIT(3)
42#define TBCTL_CLKDIV_MASK (BIT(12) | BIT(11) | BIT(10) | BIT(9) | \
43 BIT(8) | BIT(7))
44#define TBCTL_CTRMODE_MASK (BIT(1) | BIT(0))
45#define TBCTL_CTRMODE_UP 0
46#define TBCTL_CTRMODE_DOWN BIT(0)
47#define TBCTL_CTRMODE_UPDOWN BIT(1)
48#define TBCTL_CTRMODE_FREEZE (BIT(1) | BIT(0))
49
50#define TBCTL_HSPCLKDIV_SHIFT 7
51#define TBCTL_CLKDIV_SHIFT 10
52
53#define CLKDIV_MAX 7
54#define HSPCLKDIV_MAX 7
55#define PERIOD_MAX 0xFFFF
56
57/* compare module registers */
58#define CMPA 0x12
59#define CMPB 0x14
60
61/* Action qualifier module registers */
62#define AQCTLA 0x16
63#define AQCTLB 0x18
64#define AQSFRC 0x1A
65#define AQCSFRC 0x1C
66
67#define AQCTL_CBU_MASK (BIT(9) | BIT(8))
68#define AQCTL_CBU_FRCLOW BIT(8)
69#define AQCTL_CBU_FRCHIGH BIT(9)
70#define AQCTL_CBU_FRCTOGGLE (BIT(9) | BIT(8))
71#define AQCTL_CAU_MASK (BIT(5) | BIT(4))
72#define AQCTL_CAU_FRCLOW BIT(4)
73#define AQCTL_CAU_FRCHIGH BIT(5)
74#define AQCTL_CAU_FRCTOGGLE (BIT(5) | BIT(4))
75#define AQCTL_PRD_MASK (BIT(3) | BIT(2))
76#define AQCTL_PRD_FRCLOW BIT(2)
77#define AQCTL_PRD_FRCHIGH BIT(3)
78#define AQCTL_PRD_FRCTOGGLE (BIT(3) | BIT(2))
79#define AQCTL_ZRO_MASK (BIT(1) | BIT(0))
80#define AQCTL_ZRO_FRCLOW BIT(0)
81#define AQCTL_ZRO_FRCHIGH BIT(1)
82#define AQCTL_ZRO_FRCTOGGLE (BIT(1) | BIT(0))
83
84#define AQSFRC_RLDCSF_MASK (BIT(7) | BIT(6))
85#define AQSFRC_RLDCSF_ZRO 0
86#define AQSFRC_RLDCSF_PRD BIT(6)
87#define AQSFRC_RLDCSF_ZROPRD BIT(7)
88#define AQSFRC_RLDCSF_IMDT (BIT(7) | BIT(6))
89
90#define AQCSFRC_CSFB_MASK (BIT(3) | BIT(2))
91#define AQCSFRC_CSFB_FRCDIS 0
92#define AQCSFRC_CSFB_FRCLOW BIT(2)
93#define AQCSFRC_CSFB_FRCHIGH BIT(3)
94#define AQCSFRC_CSFB_DISSWFRC (BIT(3) | BIT(2))
95#define AQCSFRC_CSFA_MASK (BIT(1) | BIT(0))
96#define AQCSFRC_CSFA_FRCDIS 0
97#define AQCSFRC_CSFA_FRCLOW BIT(0)
98#define AQCSFRC_CSFA_FRCHIGH BIT(1)
99#define AQCSFRC_CSFA_DISSWFRC (BIT(1) | BIT(0))
100
101#define NUM_PWM_CHANNEL 2 /* EHRPWM channels */
102
103struct ehrpwm_pwm_chip {
104 struct pwm_chip chip;
105 unsigned int clk_rate;
106 void __iomem *mmio_base;
107};
108
109static inline struct ehrpwm_pwm_chip *to_ehrpwm_pwm_chip(struct pwm_chip *chip)
110{
111 return container_of(chip, struct ehrpwm_pwm_chip, chip);
112}
113
114static void ehrpwm_write(void *base, int offset, unsigned int val)
115{
116 writew(val & 0xFFFF, base + offset);
117}
118
119static void ehrpwm_modify(void *base, int offset,
120 unsigned short mask, unsigned short val)
121{
122 unsigned short regval;
123
124 regval = readw(base + offset);
125 regval &= ~mask;
126 regval |= val & mask;
127 writew(regval, base + offset);
128}
129
130/**
131 * set_prescale_div - Set up the prescaler divider function
132 * @rqst_prescaler: prescaler value min
133 * @prescale_div: prescaler value set
134 * @tb_clk_div: Time Base Control prescaler bits
135 */
136static int set_prescale_div(unsigned long rqst_prescaler,
137 unsigned short *prescale_div, unsigned short *tb_clk_div)
138{
139 unsigned int clkdiv, hspclkdiv;
140
141 for (clkdiv = 0; clkdiv <= CLKDIV_MAX; clkdiv++) {
142 for (hspclkdiv = 0; hspclkdiv <= HSPCLKDIV_MAX; hspclkdiv++) {
143
144 /*
145 * calculations for prescaler value :
146 * prescale_div = HSPCLKDIVIDER * CLKDIVIDER.
147 * HSPCLKDIVIDER = 2 ** hspclkdiv
148 * CLKDIVIDER = (1), if clkdiv == 0 *OR*
149 * (2 * clkdiv), if clkdiv != 0
150 *
151 * Configure prescale_div value such that period
152 * register value is less than 65535.
153 */
154
155 *prescale_div = (1 << clkdiv) *
156 (hspclkdiv ? (hspclkdiv * 2) : 1);
157 if (*prescale_div > rqst_prescaler) {
158 *tb_clk_div = (clkdiv << TBCTL_CLKDIV_SHIFT) |
159 (hspclkdiv << TBCTL_HSPCLKDIV_SHIFT);
160 return 0;
161 }
162 }
163 }
164 return 1;
165}
166
167static void configure_chans(struct ehrpwm_pwm_chip *pc, int chan,
168 unsigned long duty_cycles)
169{
170 int cmp_reg, aqctl_reg;
171 unsigned short aqctl_val, aqctl_mask;
172
173 /*
174 * Channels can be configured from action qualifier module.
175 * Channel 0 configured with compare A register and for
176 * up-counter mode.
177 * Channel 1 configured with compare B register and for
178 * up-counter mode.
179 */
180 if (chan == 1) {
181 aqctl_reg = AQCTLB;
182 cmp_reg = CMPB;
183 /* Configure PWM Low from compare B value */
184 aqctl_val = AQCTL_CBU_FRCLOW;
185 aqctl_mask = AQCTL_CBU_MASK;
186 } else {
187 cmp_reg = CMPA;
188 aqctl_reg = AQCTLA;
189 /* Configure PWM Low from compare A value*/
190 aqctl_val = AQCTL_CAU_FRCLOW;
191 aqctl_mask = AQCTL_CAU_MASK;
192 }
193
194 /* Configure PWM High from period value and zero value */
195 aqctl_val |= AQCTL_PRD_FRCHIGH | AQCTL_ZRO_FRCHIGH;
196 aqctl_mask |= AQCTL_PRD_MASK | AQCTL_ZRO_MASK;
197 ehrpwm_modify(pc->mmio_base, aqctl_reg, aqctl_mask, aqctl_val);
198
199 ehrpwm_write(pc->mmio_base, cmp_reg, duty_cycles);
200}
201
202/*
203 * period_ns = 10^9 * (ps_divval * period_cycles) / PWM_CLK_RATE
204 * duty_ns = 10^9 * (ps_divval * duty_cycles) / PWM_CLK_RATE
205 */
206static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
207 int duty_ns, int period_ns)
208{
209 struct ehrpwm_pwm_chip *pc = to_ehrpwm_pwm_chip(chip);
210 unsigned long long c;
211 unsigned long period_cycles, duty_cycles;
212 unsigned short ps_divval, tb_divval;
213
214 if (period_ns < 0 || duty_ns < 0 || period_ns > NSEC_PER_SEC)
215 return -ERANGE;
216
217 c = pc->clk_rate;
218 c = c * period_ns;
219 do_div(c, NSEC_PER_SEC);
220 period_cycles = (unsigned long)c;
221
222 if (period_cycles < 1) {
223 period_cycles = 1;
224 duty_cycles = 1;
225 } else {
226 c = pc->clk_rate;
227 c = c * duty_ns;
228 do_div(c, NSEC_PER_SEC);
229 duty_cycles = (unsigned long)c;
230 }
231
232 /* Configure clock prescaler to support Low frequency PWM wave */
233 if (set_prescale_div(period_cycles/PERIOD_MAX, &ps_divval,
234 &tb_divval)) {
235 dev_err(chip->dev, "Unsupported values\n");
236 return -EINVAL;
237 }
238
239 pm_runtime_get_sync(chip->dev);
240
241 /* Update clock prescaler values */
242 ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_CLKDIV_MASK, tb_divval);
243
244 /* Update period & duty cycle with presacler division */
245 period_cycles = period_cycles / ps_divval;
246 duty_cycles = duty_cycles / ps_divval;
247
248 /* Configure shadow loading on Period register */
249 ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_PRDLD_MASK, TBCTL_PRDLD_SHDW);
250
251 ehrpwm_write(pc->mmio_base, TBPRD, period_cycles);
252
253 /* Configure ehrpwm counter for up-count mode */
254 ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_CTRMODE_MASK,
255 TBCTL_CTRMODE_UP);
256
257 /* Configure the channel for duty cycle */
258 configure_chans(pc, pwm->hwpwm, duty_cycles);
259 pm_runtime_put_sync(chip->dev);
260 return 0;
261}
262
263static int ehrpwm_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
264{
265 struct ehrpwm_pwm_chip *pc = to_ehrpwm_pwm_chip(chip);
266 unsigned short aqcsfrc_val, aqcsfrc_mask;
267
268 /* Leave clock enabled on enabling PWM */
269 pm_runtime_get_sync(chip->dev);
270
271 /* Disabling Action Qualifier on PWM output */
272 if (pwm->hwpwm) {
273 aqcsfrc_val = AQCSFRC_CSFB_FRCDIS;
274 aqcsfrc_mask = AQCSFRC_CSFB_MASK;
275 } else {
276 aqcsfrc_val = AQCSFRC_CSFA_FRCDIS;
277 aqcsfrc_mask = AQCSFRC_CSFA_MASK;
278 }
279
280 /* Changes to shadow mode */
281 ehrpwm_modify(pc->mmio_base, AQSFRC, AQSFRC_RLDCSF_MASK,
282 AQSFRC_RLDCSF_ZRO);
283
284 ehrpwm_modify(pc->mmio_base, AQCSFRC, aqcsfrc_mask, aqcsfrc_val);
285
286 /* Enable time counter for free_run */
287 ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_RUN_MASK, TBCTL_FREE_RUN);
288 return 0;
289}
290
291static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
292{
293 struct ehrpwm_pwm_chip *pc = to_ehrpwm_pwm_chip(chip);
294 unsigned short aqcsfrc_val, aqcsfrc_mask;
295
296 /* Action Qualifier puts PWM output low forcefully */
297 if (pwm->hwpwm) {
298 aqcsfrc_val = AQCSFRC_CSFB_FRCLOW;
299 aqcsfrc_mask = AQCSFRC_CSFB_MASK;
300 } else {
301 aqcsfrc_val = AQCSFRC_CSFA_FRCLOW;
302 aqcsfrc_mask = AQCSFRC_CSFA_MASK;
303 }
304
305 /*
306 * Changes to immediate action on Action Qualifier. This puts
307 * Action Qualifier control on PWM output from next TBCLK
308 */
309 ehrpwm_modify(pc->mmio_base, AQSFRC, AQSFRC_RLDCSF_MASK,
310 AQSFRC_RLDCSF_IMDT);
311
312 ehrpwm_modify(pc->mmio_base, AQCSFRC, aqcsfrc_mask, aqcsfrc_val);
313
314 /* Stop Time base counter */
315 ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_RUN_MASK, TBCTL_STOP_NEXT);
316
317 /* Disable clock on PWM disable */
318 pm_runtime_put_sync(chip->dev);
319}
320
321static void ehrpwm_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
322{
323 if (test_bit(PWMF_ENABLED, &pwm->flags)) {
324 dev_warn(chip->dev, "Removing PWM device without disabling\n");
325 pm_runtime_put_sync(chip->dev);
326 }
327}
328
329static const struct pwm_ops ehrpwm_pwm_ops = {
330 .free = ehrpwm_pwm_free,
331 .config = ehrpwm_pwm_config,
332 .enable = ehrpwm_pwm_enable,
333 .disable = ehrpwm_pwm_disable,
334 .owner = THIS_MODULE,
335};
336
337static int __devinit ehrpwm_pwm_probe(struct platform_device *pdev)
338{
339 int ret;
340 struct resource *r;
341 struct clk *clk;
342 struct ehrpwm_pwm_chip *pc;
343
344 pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
345 if (!pc) {
346 dev_err(&pdev->dev, "failed to allocate memory\n");
347 return -ENOMEM;
348 }
349
350 clk = devm_clk_get(&pdev->dev, "fck");
351 if (IS_ERR(clk)) {
352 dev_err(&pdev->dev, "failed to get clock\n");
353 return PTR_ERR(clk);
354 }
355
356 pc->clk_rate = clk_get_rate(clk);
357 if (!pc->clk_rate) {
358 dev_err(&pdev->dev, "failed to get clock rate\n");
359 return -EINVAL;
360 }
361
362 pc->chip.dev = &pdev->dev;
363 pc->chip.ops = &ehrpwm_pwm_ops;
364 pc->chip.base = -1;
365 pc->chip.npwm = NUM_PWM_CHANNEL;
366
367 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
368 if (!r) {
369 dev_err(&pdev->dev, "no memory resource defined\n");
370 return -ENODEV;
371 }
372
373 pc->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
374 if (!pc->mmio_base) {
375 dev_err(&pdev->dev, "failed to ioremap() registers\n");
376 return -EADDRNOTAVAIL;
377 }
378
379 ret = pwmchip_add(&pc->chip);
380 if (ret < 0) {
381 dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
382 return ret;
383 }
384
385 pm_runtime_enable(&pdev->dev);
386 platform_set_drvdata(pdev, pc);
387 return 0;
388}
389
390static int __devexit ehrpwm_pwm_remove(struct platform_device *pdev)
391{
392 struct ehrpwm_pwm_chip *pc = platform_get_drvdata(pdev);
393
394 pm_runtime_put_sync(&pdev->dev);
395 pm_runtime_disable(&pdev->dev);
396 return pwmchip_remove(&pc->chip);
397}
398
399static struct platform_driver ehrpwm_pwm_driver = {
400 .driver = {
401 .name = "ehrpwm",
402 },
403 .probe = ehrpwm_pwm_probe,
404 .remove = __devexit_p(ehrpwm_pwm_remove),
405};
406
407module_platform_driver(ehrpwm_pwm_driver);
408
409MODULE_DESCRIPTION("EHRPWM PWM driver");
410MODULE_AUTHOR("Texas Instruments");
411MODULE_LICENSE("GPL");
diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c
new file mode 100644
index 000000000000..548021439f0c
--- /dev/null
+++ b/drivers/pwm/pwm-vt8500.c
@@ -0,0 +1,177 @@
1/*
2 * drivers/pwm/pwm-vt8500.c
3 *
4 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/platform_device.h>
19#include <linux/slab.h>
20#include <linux/err.h>
21#include <linux/io.h>
22#include <linux/pwm.h>
23#include <linux/delay.h>
24
25#include <asm/div64.h>
26
27#define VT8500_NR_PWMS 4
28
29struct vt8500_chip {
30 struct pwm_chip chip;
31 void __iomem *base;
32};
33
34#define to_vt8500_chip(chip) container_of(chip, struct vt8500_chip, chip)
35
36#define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
37static inline void pwm_busy_wait(void __iomem *reg, u8 bitmask)
38{
39 int loops = msecs_to_loops(10);
40 while ((readb(reg) & bitmask) && --loops)
41 cpu_relax();
42
43 if (unlikely(!loops))
44 pr_warning("Waiting for status bits 0x%x to clear timed out\n",
45 bitmask);
46}
47
48static int vt8500_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
49 int duty_ns, int period_ns)
50{
51 struct vt8500_chip *vt8500 = to_vt8500_chip(chip);
52 unsigned long long c;
53 unsigned long period_cycles, prescale, pv, dc;
54
55 c = 25000000/2; /* wild guess --- need to implement clocks */
56 c = c * period_ns;
57 do_div(c, 1000000000);
58 period_cycles = c;
59
60 if (period_cycles < 1)
61 period_cycles = 1;
62 prescale = (period_cycles - 1) / 4096;
63 pv = period_cycles / (prescale + 1) - 1;
64 if (pv > 4095)
65 pv = 4095;
66
67 if (prescale > 1023)
68 return -EINVAL;
69
70 c = (unsigned long long)pv * duty_ns;
71 do_div(c, period_ns);
72 dc = c;
73
74 pwm_busy_wait(vt8500->base + 0x40 + pwm->hwpwm, (1 << 1));
75 writel(prescale, vt8500->base + 0x4 + (pwm->hwpwm << 4));
76
77 pwm_busy_wait(vt8500->base + 0x40 + pwm->hwpwm, (1 << 2));
78 writel(pv, vt8500->base + 0x8 + (pwm->hwpwm << 4));
79
80 pwm_busy_wait(vt8500->base + 0x40 + pwm->hwpwm, (1 << 3));
81 writel(dc, vt8500->base + 0xc + (pwm->hwpwm << 4));
82
83 return 0;
84}
85
86static int vt8500_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
87{
88 struct vt8500_chip *vt8500 = to_vt8500_chip(chip);
89
90 pwm_busy_wait(vt8500->base + 0x40 + pwm->hwpwm, (1 << 0));
91 writel(5, vt8500->base + (pwm->hwpwm << 4));
92 return 0;
93}
94
95static void vt8500_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
96{
97 struct vt8500_chip *vt8500 = to_vt8500_chip(chip);
98
99 pwm_busy_wait(vt8500->base + 0x40 + pwm->hwpwm, (1 << 0));
100 writel(0, vt8500->base + (pwm->hwpwm << 4));
101}
102
103static struct pwm_ops vt8500_pwm_ops = {
104 .enable = vt8500_pwm_enable,
105 .disable = vt8500_pwm_disable,
106 .config = vt8500_pwm_config,
107 .owner = THIS_MODULE,
108};
109
110static int __devinit pwm_probe(struct platform_device *pdev)
111{
112 struct vt8500_chip *chip;
113 struct resource *r;
114 int ret;
115
116 chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
117 if (chip == NULL) {
118 dev_err(&pdev->dev, "failed to allocate memory\n");
119 return -ENOMEM;
120 }
121
122 chip->chip.dev = &pdev->dev;
123 chip->chip.ops = &vt8500_pwm_ops;
124 chip->chip.base = -1;
125 chip->chip.npwm = VT8500_NR_PWMS;
126
127 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
128 if (r == NULL) {
129 dev_err(&pdev->dev, "no memory resource defined\n");
130 return -ENODEV;
131 }
132
133 chip->base = devm_request_and_ioremap(&pdev->dev, r);
134 if (chip->base == NULL)
135 return -EADDRNOTAVAIL;
136
137 ret = pwmchip_add(&chip->chip);
138 if (ret < 0)
139 return ret;
140
141 platform_set_drvdata(pdev, chip);
142 return ret;
143}
144
145static int __devexit pwm_remove(struct platform_device *pdev)
146{
147 struct vt8500_chip *chip;
148
149 chip = platform_get_drvdata(pdev);
150 if (chip == NULL)
151 return -ENODEV;
152
153 return pwmchip_remove(&chip->chip);
154}
155
156static struct platform_driver pwm_driver = {
157 .driver = {
158 .name = "vt8500-pwm",
159 .owner = THIS_MODULE,
160 },
161 .probe = pwm_probe,
162 .remove = __devexit_p(pwm_remove),
163};
164
165static int __init pwm_init(void)
166{
167 return platform_driver_register(&pwm_driver);
168}
169arch_initcall(pwm_init);
170
171static void __exit pwm_exit(void)
172{
173 platform_driver_unregister(&pwm_driver);
174}
175module_exit(pwm_exit);
176
177MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index f34c3be6c9fe..4e932cc695e9 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -272,7 +272,7 @@ config REGULATOR_S2MPS11
272 272
273config REGULATOR_S5M8767 273config REGULATOR_S5M8767
274 tristate "Samsung S5M8767A voltage regulator" 274 tristate "Samsung S5M8767A voltage regulator"
275 depends on MFD_S5M_CORE 275 depends on MFD_SEC_CORE
276 help 276 help
277 This driver supports a Samsung S5M8767A voltage output regulator 277 This driver supports a Samsung S5M8767A voltage output regulator
278 via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and 278 via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 13d424fc1c14..10f2f4d4d190 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -848,18 +848,12 @@ static __devexit int ab8500_regulator_remove(struct platform_device *pdev)
848 return 0; 848 return 0;
849} 849}
850 850
851static const struct of_device_id ab8500_regulator_match[] = {
852 { .compatible = "stericsson,ab8500-regulator", },
853 {}
854};
855
856static struct platform_driver ab8500_regulator_driver = { 851static struct platform_driver ab8500_regulator_driver = {
857 .probe = ab8500_regulator_probe, 852 .probe = ab8500_regulator_probe,
858 .remove = __devexit_p(ab8500_regulator_remove), 853 .remove = __devexit_p(ab8500_regulator_remove),
859 .driver = { 854 .driver = {
860 .name = "ab8500-regulator", 855 .name = "ab8500-regulator",
861 .owner = THIS_MODULE, 856 .owner = THIS_MODULE,
862 .of_match_table = ab8500_regulator_match,
863 }, 857 },
864}; 858};
865 859
diff --git a/drivers/regulator/db8500-prcmu.c b/drivers/regulator/db8500-prcmu.c
index 9dbb491b6efa..359f8d18fc3f 100644
--- a/drivers/regulator/db8500-prcmu.c
+++ b/drivers/regulator/db8500-prcmu.c
@@ -547,16 +547,10 @@ static int __exit db8500_regulator_remove(struct platform_device *pdev)
547 return 0; 547 return 0;
548} 548}
549 549
550static const struct of_device_id db8500_prcmu_regulator_match[] = {
551 { .compatible = "stericsson,db8500-prcmu-regulator", },
552 {}
553};
554
555static struct platform_driver db8500_regulator_driver = { 550static struct platform_driver db8500_regulator_driver = {
556 .driver = { 551 .driver = {
557 .name = "db8500-prcmu-regulators", 552 .name = "db8500-prcmu-regulators",
558 .owner = THIS_MODULE, 553 .owner = THIS_MODULE,
559 .of_match_table = db8500_prcmu_regulator_match,
560 }, 554 },
561 .probe = db8500_regulator_probe, 555 .probe = db8500_regulator_probe,
562 .remove = __exit_p(db8500_regulator_remove), 556 .remove = __exit_p(db8500_regulator_remove),
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 102287fa7ecb..5a0d18a7aa2a 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -19,15 +19,15 @@
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/regulator/driver.h> 20#include <linux/regulator/driver.h>
21#include <linux/regulator/machine.h> 21#include <linux/regulator/machine.h>
22#include <linux/mfd/s5m87xx/s5m-core.h> 22#include <linux/mfd/samsung/core.h>
23#include <linux/mfd/s5m87xx/s5m-pmic.h> 23#include <linux/mfd/samsung/s5m8767.h>
24 24
25struct s5m8767_info { 25struct s5m8767_info {
26 struct device *dev; 26 struct device *dev;
27 struct s5m87xx_dev *iodev; 27 struct sec_pmic_dev *iodev;
28 int num_regulators; 28 int num_regulators;
29 struct regulator_dev **rdev; 29 struct regulator_dev **rdev;
30 struct s5m_opmode_data *opmode; 30 struct sec_opmode_data *opmode;
31 31
32 int ramp_delay; 32 int ramp_delay;
33 bool buck2_ramp; 33 bool buck2_ramp;
@@ -45,43 +45,43 @@ struct s5m8767_info {
45 int buck_gpioindex; 45 int buck_gpioindex;
46}; 46};
47 47
48struct s5m_voltage_desc { 48struct sec_voltage_desc {
49 int max; 49 int max;
50 int min; 50 int min;
51 int step; 51 int step;
52}; 52};
53 53
54static const struct s5m_voltage_desc buck_voltage_val1 = { 54static const struct sec_voltage_desc buck_voltage_val1 = {
55 .max = 2225000, 55 .max = 2225000,
56 .min = 650000, 56 .min = 650000,
57 .step = 6250, 57 .step = 6250,
58}; 58};
59 59
60static const struct s5m_voltage_desc buck_voltage_val2 = { 60static const struct sec_voltage_desc buck_voltage_val2 = {
61 .max = 1600000, 61 .max = 1600000,
62 .min = 600000, 62 .min = 600000,
63 .step = 6250, 63 .step = 6250,
64}; 64};
65 65
66static const struct s5m_voltage_desc buck_voltage_val3 = { 66static const struct sec_voltage_desc buck_voltage_val3 = {
67 .max = 3000000, 67 .max = 3000000,
68 .min = 750000, 68 .min = 750000,
69 .step = 12500, 69 .step = 12500,
70}; 70};
71 71
72static const struct s5m_voltage_desc ldo_voltage_val1 = { 72static const struct sec_voltage_desc ldo_voltage_val1 = {
73 .max = 3950000, 73 .max = 3950000,
74 .min = 800000, 74 .min = 800000,
75 .step = 50000, 75 .step = 50000,
76}; 76};
77 77
78static const struct s5m_voltage_desc ldo_voltage_val2 = { 78static const struct sec_voltage_desc ldo_voltage_val2 = {
79 .max = 2375000, 79 .max = 2375000,
80 .min = 800000, 80 .min = 800000,
81 .step = 25000, 81 .step = 25000,
82}; 82};
83 83
84static const struct s5m_voltage_desc *reg_voltage_map[] = { 84static const struct sec_voltage_desc *reg_voltage_map[] = {
85 [S5M8767_LDO1] = &ldo_voltage_val2, 85 [S5M8767_LDO1] = &ldo_voltage_val2,
86 [S5M8767_LDO2] = &ldo_voltage_val2, 86 [S5M8767_LDO2] = &ldo_voltage_val2,
87 [S5M8767_LDO3] = &ldo_voltage_val1, 87 [S5M8767_LDO3] = &ldo_voltage_val1,
@@ -213,7 +213,7 @@ static int s5m8767_reg_is_enabled(struct regulator_dev *rdev)
213 else if (ret) 213 else if (ret)
214 return ret; 214 return ret;
215 215
216 ret = s5m_reg_read(s5m8767->iodev, reg, &val); 216 ret = sec_reg_read(s5m8767->iodev, reg, &val);
217 if (ret) 217 if (ret)
218 return ret; 218 return ret;
219 219
@@ -230,7 +230,7 @@ static int s5m8767_reg_enable(struct regulator_dev *rdev)
230 if (ret) 230 if (ret)
231 return ret; 231 return ret;
232 232
233 return s5m_reg_update(s5m8767->iodev, reg, enable_ctrl, mask); 233 return sec_reg_update(s5m8767->iodev, reg, enable_ctrl, mask);
234} 234}
235 235
236static int s5m8767_reg_disable(struct regulator_dev *rdev) 236static int s5m8767_reg_disable(struct regulator_dev *rdev)
@@ -243,7 +243,7 @@ static int s5m8767_reg_disable(struct regulator_dev *rdev)
243 if (ret) 243 if (ret)
244 return ret; 244 return ret;
245 245
246 return s5m_reg_update(s5m8767->iodev, reg, ~mask, mask); 246 return sec_reg_update(s5m8767->iodev, reg, ~mask, mask);
247} 247}
248 248
249static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg) 249static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg)
@@ -305,7 +305,7 @@ static int s5m8767_get_voltage_sel(struct regulator_dev *rdev)
305 305
306 mask = (reg_id < S5M8767_BUCK1) ? 0x3f : 0xff; 306 mask = (reg_id < S5M8767_BUCK1) ? 0x3f : 0xff;
307 307
308 ret = s5m_reg_read(s5m8767->iodev, reg, &val); 308 ret = sec_reg_read(s5m8767->iodev, reg, &val);
309 if (ret) 309 if (ret)
310 return ret; 310 return ret;
311 311
@@ -315,7 +315,7 @@ static int s5m8767_get_voltage_sel(struct regulator_dev *rdev)
315} 315}
316 316
317static int s5m8767_convert_voltage_to_sel( 317static int s5m8767_convert_voltage_to_sel(
318 const struct s5m_voltage_desc *desc, 318 const struct sec_voltage_desc *desc,
319 int min_vol, int max_vol) 319 int min_vol, int max_vol)
320{ 320{
321 int selector = 0; 321 int selector = 0;
@@ -407,7 +407,7 @@ static int s5m8767_set_voltage_sel(struct regulator_dev *rdev,
407 if (ret) 407 if (ret)
408 return ret; 408 return ret;
409 409
410 return s5m_reg_update(s5m8767->iodev, reg, selector, mask); 410 return sec_reg_update(s5m8767->iodev, reg, selector, mask);
411 } 411 }
412} 412}
413 413
@@ -416,7 +416,7 @@ static int s5m8767_set_voltage_time_sel(struct regulator_dev *rdev,
416 unsigned int new_sel) 416 unsigned int new_sel)
417{ 417{
418 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); 418 struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
419 const struct s5m_voltage_desc *desc; 419 const struct sec_voltage_desc *desc;
420 int reg_id = rdev_get_id(rdev); 420 int reg_id = rdev_get_id(rdev);
421 421
422 desc = reg_voltage_map[reg_id]; 422 desc = reg_voltage_map[reg_id];
@@ -501,8 +501,8 @@ static struct regulator_desc regulators[] = {
501 501
502static __devinit int s5m8767_pmic_probe(struct platform_device *pdev) 502static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
503{ 503{
504 struct s5m87xx_dev *iodev = dev_get_drvdata(pdev->dev.parent); 504 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
505 struct s5m_platform_data *pdata = dev_get_platdata(iodev->dev); 505 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev);
506 struct regulator_config config = { }; 506 struct regulator_config config = { };
507 struct regulator_dev **rdev; 507 struct regulator_dev **rdev;
508 struct s5m8767_info *s5m8767; 508 struct s5m8767_info *s5m8767;
@@ -671,13 +671,13 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
671 671
672 if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || 672 if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs ||
673 pdata->buck4_gpiodvs) { 673 pdata->buck4_gpiodvs) {
674 s5m_reg_update(s5m8767->iodev, S5M8767_REG_BUCK2CTRL, 674 sec_reg_update(s5m8767->iodev, S5M8767_REG_BUCK2CTRL,
675 (pdata->buck2_gpiodvs) ? (1 << 1) : (0 << 1), 675 (pdata->buck2_gpiodvs) ? (1 << 1) : (0 << 1),
676 1 << 1); 676 1 << 1);
677 s5m_reg_update(s5m8767->iodev, S5M8767_REG_BUCK3CTRL, 677 sec_reg_update(s5m8767->iodev, S5M8767_REG_BUCK3CTRL,
678 (pdata->buck3_gpiodvs) ? (1 << 1) : (0 << 1), 678 (pdata->buck3_gpiodvs) ? (1 << 1) : (0 << 1),
679 1 << 1); 679 1 << 1);
680 s5m_reg_update(s5m8767->iodev, S5M8767_REG_BUCK4CTRL, 680 sec_reg_update(s5m8767->iodev, S5M8767_REG_BUCK4CTRL,
681 (pdata->buck4_gpiodvs) ? (1 << 1) : (0 << 1), 681 (pdata->buck4_gpiodvs) ? (1 << 1) : (0 << 1),
682 1 << 1); 682 1 << 1);
683 } 683 }
@@ -685,61 +685,61 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev)
685 /* Initialize GPIO DVS registers */ 685 /* Initialize GPIO DVS registers */
686 for (i = 0; i < 8; i++) { 686 for (i = 0; i < 8; i++) {
687 if (s5m8767->buck2_gpiodvs) { 687 if (s5m8767->buck2_gpiodvs) {
688 s5m_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS1 + i, 688 sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS1 + i,
689 s5m8767->buck2_vol[i]); 689 s5m8767->buck2_vol[i]);
690 } 690 }
691 691
692 if (s5m8767->buck3_gpiodvs) { 692 if (s5m8767->buck3_gpiodvs) {
693 s5m_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS1 + i, 693 sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS1 + i,
694 s5m8767->buck3_vol[i]); 694 s5m8767->buck3_vol[i]);
695 } 695 }
696 696
697 if (s5m8767->buck4_gpiodvs) { 697 if (s5m8767->buck4_gpiodvs) {
698 s5m_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS1 + i, 698 sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS1 + i,
699 s5m8767->buck4_vol[i]); 699 s5m8767->buck4_vol[i]);
700 } 700 }
701 } 701 }
702 702
703 if (s5m8767->buck2_ramp) 703 if (s5m8767->buck2_ramp)
704 s5m_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x08, 0x08); 704 sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x08, 0x08);
705 705
706 if (s5m8767->buck3_ramp) 706 if (s5m8767->buck3_ramp)
707 s5m_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x04, 0x04); 707 sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x04, 0x04);
708 708
709 if (s5m8767->buck4_ramp) 709 if (s5m8767->buck4_ramp)
710 s5m_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x02, 0x02); 710 sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x02, 0x02);
711 711
712 if (s5m8767->buck2_ramp || s5m8767->buck3_ramp 712 if (s5m8767->buck2_ramp || s5m8767->buck3_ramp
713 || s5m8767->buck4_ramp) { 713 || s5m8767->buck4_ramp) {
714 switch (s5m8767->ramp_delay) { 714 switch (s5m8767->ramp_delay) {
715 case 5: 715 case 5:
716 s5m_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 716 sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
717 0x40, 0xf0); 717 0x40, 0xf0);
718 break; 718 break;
719 case 10: 719 case 10:
720 s5m_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 720 sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
721 0x90, 0xf0); 721 0x90, 0xf0);
722 break; 722 break;
723 case 25: 723 case 25:
724 s5m_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 724 sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
725 0xd0, 0xf0); 725 0xd0, 0xf0);
726 break; 726 break;
727 case 50: 727 case 50:
728 s5m_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 728 sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
729 0xe0, 0xf0); 729 0xe0, 0xf0);
730 break; 730 break;
731 case 100: 731 case 100:
732 s5m_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 732 sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
733 0xf0, 0xf0); 733 0xf0, 0xf0);
734 break; 734 break;
735 default: 735 default:
736 s5m_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 736 sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP,
737 0x90, 0xf0); 737 0x90, 0xf0);
738 } 738 }
739 } 739 }
740 740
741 for (i = 0; i < pdata->num_regulators; i++) { 741 for (i = 0; i < pdata->num_regulators; i++) {
742 const struct s5m_voltage_desc *desc; 742 const struct sec_voltage_desc *desc;
743 int id = pdata->regulators[i].id; 743 int id = pdata->regulators[i].id;
744 744
745 desc = reg_voltage_map[id]; 745 desc = reg_voltage_map[id];
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 668da5922d9e..fabc99a75c65 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -135,6 +135,16 @@ config RTC_DRV_88PM860X
135 This driver can also be built as a module. If so, the module 135 This driver can also be built as a module. If so, the module
136 will be called rtc-88pm860x. 136 will be called rtc-88pm860x.
137 137
138config RTC_DRV_88PM80X
139 tristate "Marvell 88PM80x"
140 depends on RTC_CLASS && I2C && MFD_88PM800
141 help
142 If you say yes here you get support for RTC function in Marvell
143 88PM80x chips.
144
145 This driver can also be built as a module. If so, the module
146 will be called rtc-88pm80x.
147
138config RTC_DRV_DS1307 148config RTC_DRV_DS1307
139 tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025" 149 tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025"
140 help 150 help
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 2973921c30d8..0d5b2b66f90d 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -16,6 +16,7 @@ rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o
16# Keep the list ordered. 16# Keep the list ordered.
17 17
18obj-$(CONFIG_RTC_DRV_88PM860X) += rtc-88pm860x.o 18obj-$(CONFIG_RTC_DRV_88PM860X) += rtc-88pm860x.o
19obj-$(CONFIG_RTC_DRV_88PM80X) += rtc-88pm80x.o
19obj-$(CONFIG_RTC_DRV_AB3100) += rtc-ab3100.o 20obj-$(CONFIG_RTC_DRV_AB3100) += rtc-ab3100.o
20obj-$(CONFIG_RTC_DRV_AB8500) += rtc-ab8500.o 21obj-$(CONFIG_RTC_DRV_AB8500) += rtc-ab8500.o
21obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o 22obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o
diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c
new file mode 100644
index 000000000000..a2f956d90de0
--- /dev/null
+++ b/drivers/rtc/rtc-88pm80x.c
@@ -0,0 +1,371 @@
1/*
2 * Real Time Clock driver for Marvell 88PM80x PMIC
3 *
4 * Copyright (c) 2012 Marvell International Ltd.
5 * Wenzeng Chen<wzch@marvell.com>
6 * Qiao Zhou <zhouqiao@marvell.com>
7 *
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file "COPYING" in the main directory of this
10 * archive for more details.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <linux/kernel.h>
23#include <linux/module.h>
24#include <linux/slab.h>
25#include <linux/regmap.h>
26#include <linux/mfd/core.h>
27#include <linux/mfd/88pm80x.h>
28#include <linux/rtc.h>
29
30#define PM800_RTC_COUNTER1 (0xD1)
31#define PM800_RTC_COUNTER2 (0xD2)
32#define PM800_RTC_COUNTER3 (0xD3)
33#define PM800_RTC_COUNTER4 (0xD4)
34#define PM800_RTC_EXPIRE1_1 (0xD5)
35#define PM800_RTC_EXPIRE1_2 (0xD6)
36#define PM800_RTC_EXPIRE1_3 (0xD7)
37#define PM800_RTC_EXPIRE1_4 (0xD8)
38#define PM800_RTC_TRIM1 (0xD9)
39#define PM800_RTC_TRIM2 (0xDA)
40#define PM800_RTC_TRIM3 (0xDB)
41#define PM800_RTC_TRIM4 (0xDC)
42#define PM800_RTC_EXPIRE2_1 (0xDD)
43#define PM800_RTC_EXPIRE2_2 (0xDE)
44#define PM800_RTC_EXPIRE2_3 (0xDF)
45#define PM800_RTC_EXPIRE2_4 (0xE0)
46
47#define PM800_POWER_DOWN_LOG1 (0xE5)
48#define PM800_POWER_DOWN_LOG2 (0xE6)
49
50struct pm80x_rtc_info {
51 struct pm80x_chip *chip;
52 struct regmap *map;
53 struct rtc_device *rtc_dev;
54 struct device *dev;
55 struct delayed_work calib_work;
56
57 int irq;
58 int vrtc;
59};
60
61static irqreturn_t rtc_update_handler(int irq, void *data)
62{
63 struct pm80x_rtc_info *info = (struct pm80x_rtc_info *)data;
64 int mask;
65
66 mask = PM800_ALARM | PM800_ALARM_WAKEUP;
67 regmap_update_bits(info->map, PM800_RTC_CONTROL, mask | PM800_ALARM1_EN,
68 mask);
69 rtc_update_irq(info->rtc_dev, 1, RTC_AF);
70 return IRQ_HANDLED;
71}
72
73static int pm80x_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
74{
75 struct pm80x_rtc_info *info = dev_get_drvdata(dev);
76
77 if (enabled)
78 regmap_update_bits(info->map, PM800_RTC_CONTROL,
79 PM800_ALARM1_EN, PM800_ALARM1_EN);
80 else
81 regmap_update_bits(info->map, PM800_RTC_CONTROL,
82 PM800_ALARM1_EN, 0);
83 return 0;
84}
85
86/*
87 * Calculate the next alarm time given the requested alarm time mask
88 * and the current time.
89 */
90static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
91 struct rtc_time *alrm)
92{
93 unsigned long next_time;
94 unsigned long now_time;
95
96 next->tm_year = now->tm_year;
97 next->tm_mon = now->tm_mon;
98 next->tm_mday = now->tm_mday;
99 next->tm_hour = alrm->tm_hour;
100 next->tm_min = alrm->tm_min;
101 next->tm_sec = alrm->tm_sec;
102
103 rtc_tm_to_time(now, &now_time);
104 rtc_tm_to_time(next, &next_time);
105
106 if (next_time < now_time) {
107 /* Advance one day */
108 next_time += 60 * 60 * 24;
109 rtc_time_to_tm(next_time, next);
110 }
111}
112
113static int pm80x_rtc_read_time(struct device *dev, struct rtc_time *tm)
114{
115 struct pm80x_rtc_info *info = dev_get_drvdata(dev);
116 unsigned char buf[4];
117 unsigned long ticks, base, data;
118 regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4);
119 base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
120 dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]);
121
122 /* load 32-bit read-only counter */
123 regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4);
124 data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
125 ticks = base + data;
126 dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
127 base, data, ticks);
128 rtc_time_to_tm(ticks, tm);
129 return 0;
130}
131
132static int pm80x_rtc_set_time(struct device *dev, struct rtc_time *tm)
133{
134 struct pm80x_rtc_info *info = dev_get_drvdata(dev);
135 unsigned char buf[4];
136 unsigned long ticks, base, data;
137 if ((tm->tm_year < 70) || (tm->tm_year > 138)) {
138 dev_dbg(info->dev,
139 "Set time %d out of range. Please set time between 1970 to 2038.\n",
140 1900 + tm->tm_year);
141 return -EINVAL;
142 }
143 rtc_tm_to_time(tm, &ticks);
144
145 /* load 32-bit read-only counter */
146 regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4);
147 data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
148 base = ticks - data;
149 dev_dbg(info->dev, "set base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
150 base, data, ticks);
151 buf[0] = base & 0xFF;
152 buf[1] = (base >> 8) & 0xFF;
153 buf[2] = (base >> 16) & 0xFF;
154 buf[3] = (base >> 24) & 0xFF;
155 regmap_raw_write(info->map, PM800_RTC_EXPIRE2_1, buf, 4);
156
157 return 0;
158}
159
160static int pm80x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
161{
162 struct pm80x_rtc_info *info = dev_get_drvdata(dev);
163 unsigned char buf[4];
164 unsigned long ticks, base, data;
165 int ret;
166
167 regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4);
168 base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
169 dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]);
170
171 regmap_raw_read(info->map, PM800_RTC_EXPIRE1_1, buf, 4);
172 data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
173 ticks = base + data;
174 dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
175 base, data, ticks);
176
177 rtc_time_to_tm(ticks, &alrm->time);
178 regmap_read(info->map, PM800_RTC_CONTROL, &ret);
179 alrm->enabled = (ret & PM800_ALARM1_EN) ? 1 : 0;
180 alrm->pending = (ret & (PM800_ALARM | PM800_ALARM_WAKEUP)) ? 1 : 0;
181 return 0;
182}
183
184static int pm80x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
185{
186 struct pm80x_rtc_info *info = dev_get_drvdata(dev);
187 struct rtc_time now_tm, alarm_tm;
188 unsigned long ticks, base, data;
189 unsigned char buf[4];
190 int mask;
191
192 regmap_update_bits(info->map, PM800_RTC_CONTROL, PM800_ALARM1_EN, 0);
193
194 regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4);
195 base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
196 dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]);
197
198 /* load 32-bit read-only counter */
199 regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4);
200 data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
201 ticks = base + data;
202 dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n",
203 base, data, ticks);
204
205 rtc_time_to_tm(ticks, &now_tm);
206 dev_dbg(info->dev, "%s, now time : %lu\n", __func__, ticks);
207 rtc_next_alarm_time(&alarm_tm, &now_tm, &alrm->time);
208 /* get new ticks for alarm in 24 hours */
209 rtc_tm_to_time(&alarm_tm, &ticks);
210 dev_dbg(info->dev, "%s, alarm time: %lu\n", __func__, ticks);
211 data = ticks - base;
212
213 buf[0] = data & 0xff;
214 buf[1] = (data >> 8) & 0xff;
215 buf[2] = (data >> 16) & 0xff;
216 buf[3] = (data >> 24) & 0xff;
217 regmap_raw_write(info->map, PM800_RTC_EXPIRE1_1, buf, 4);
218 if (alrm->enabled) {
219 mask = PM800_ALARM | PM800_ALARM_WAKEUP | PM800_ALARM1_EN;
220 regmap_update_bits(info->map, PM800_RTC_CONTROL, mask, mask);
221 } else {
222 mask = PM800_ALARM | PM800_ALARM_WAKEUP | PM800_ALARM1_EN;
223 regmap_update_bits(info->map, PM800_RTC_CONTROL, mask,
224 PM800_ALARM | PM800_ALARM_WAKEUP);
225 }
226 return 0;
227}
228
229static const struct rtc_class_ops pm80x_rtc_ops = {
230 .read_time = pm80x_rtc_read_time,
231 .set_time = pm80x_rtc_set_time,
232 .read_alarm = pm80x_rtc_read_alarm,
233 .set_alarm = pm80x_rtc_set_alarm,
234 .alarm_irq_enable = pm80x_rtc_alarm_irq_enable,
235};
236
237#ifdef CONFIG_PM
238static int pm80x_rtc_suspend(struct device *dev)
239{
240 return pm80x_dev_suspend(dev);
241}
242
243static int pm80x_rtc_resume(struct device *dev)
244{
245 return pm80x_dev_resume(dev);
246}
247#endif
248
249static SIMPLE_DEV_PM_OPS(pm80x_rtc_pm_ops, pm80x_rtc_suspend, pm80x_rtc_resume);
250
251static int __devinit pm80x_rtc_probe(struct platform_device *pdev)
252{
253 struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
254 struct pm80x_platform_data *pm80x_pdata;
255 struct pm80x_rtc_pdata *pdata = NULL;
256 struct pm80x_rtc_info *info;
257 struct rtc_time tm;
258 unsigned long ticks = 0;
259 int ret;
260
261 pdata = pdev->dev.platform_data;
262 if (pdata == NULL)
263 dev_warn(&pdev->dev, "No platform data!\n");
264
265 info =
266 devm_kzalloc(&pdev->dev, sizeof(struct pm80x_rtc_info), GFP_KERNEL);
267 if (!info)
268 return -ENOMEM;
269 info->irq = platform_get_irq(pdev, 0);
270 if (info->irq < 0) {
271 dev_err(&pdev->dev, "No IRQ resource!\n");
272 ret = -EINVAL;
273 goto out;
274 }
275
276 info->chip = chip;
277 info->map = chip->regmap;
278 if (!info->map) {
279 dev_err(&pdev->dev, "no regmap!\n");
280 ret = -EINVAL;
281 goto out;
282 }
283
284 info->dev = &pdev->dev;
285 dev_set_drvdata(&pdev->dev, info);
286
287 ret = pm80x_request_irq(chip, info->irq, rtc_update_handler,
288 IRQF_ONESHOT, "rtc", info);
289 if (ret < 0) {
290 dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
291 info->irq, ret);
292 goto out;
293 }
294
295 ret = pm80x_rtc_read_time(&pdev->dev, &tm);
296 if (ret < 0) {
297 dev_err(&pdev->dev, "Failed to read initial time.\n");
298 goto out_rtc;
299 }
300 if ((tm.tm_year < 70) || (tm.tm_year > 138)) {
301 tm.tm_year = 70;
302 tm.tm_mon = 0;
303 tm.tm_mday = 1;
304 tm.tm_hour = 0;
305 tm.tm_min = 0;
306 tm.tm_sec = 0;
307 ret = pm80x_rtc_set_time(&pdev->dev, &tm);
308 if (ret < 0) {
309 dev_err(&pdev->dev, "Failed to set initial time.\n");
310 goto out_rtc;
311 }
312 }
313 rtc_tm_to_time(&tm, &ticks);
314
315 info->rtc_dev = rtc_device_register("88pm80x-rtc", &pdev->dev,
316 &pm80x_rtc_ops, THIS_MODULE);
317 ret = PTR_ERR(info->rtc_dev);
318 if (IS_ERR(info->rtc_dev)) {
319 dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret);
320 goto out_rtc;
321 }
322 /*
323 * enable internal XO instead of internal 3.25MHz clock since it can
324 * free running in PMIC power-down state.
325 */
326 regmap_update_bits(info->map, PM800_RTC_CONTROL, PM800_RTC1_USE_XO,
327 PM800_RTC1_USE_XO);
328
329 if (pdev->dev.parent->platform_data) {
330 pm80x_pdata = pdev->dev.parent->platform_data;
331 pdata = pm80x_pdata->rtc;
332 if (pdata)
333 info->rtc_dev->dev.platform_data = &pdata->rtc_wakeup;
334 }
335
336 device_init_wakeup(&pdev->dev, 1);
337
338 return 0;
339out_rtc:
340 pm80x_free_irq(chip, info->irq, info);
341out:
342 devm_kfree(&pdev->dev, info);
343 return ret;
344}
345
346static int __devexit pm80x_rtc_remove(struct platform_device *pdev)
347{
348 struct pm80x_rtc_info *info = platform_get_drvdata(pdev);
349 platform_set_drvdata(pdev, NULL);
350 rtc_device_unregister(info->rtc_dev);
351 pm80x_free_irq(info->chip, info->irq, info);
352 devm_kfree(&pdev->dev, info);
353 return 0;
354}
355
356static struct platform_driver pm80x_rtc_driver = {
357 .driver = {
358 .name = "88pm80x-rtc",
359 .owner = THIS_MODULE,
360 .pm = &pm80x_rtc_pm_ops,
361 },
362 .probe = pm80x_rtc_probe,
363 .remove = __devexit_p(pm80x_rtc_remove),
364};
365
366module_platform_driver(pm80x_rtc_driver);
367
368MODULE_LICENSE("GPL");
369MODULE_DESCRIPTION("Marvell 88PM80x RTC driver");
370MODULE_AUTHOR("Qiao Zhou <zhouqiao@marvell.com>");
371MODULE_ALIAS("platform:88pm80x-rtc");
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c
index 1459055a83aa..34e4349611db 100644
--- a/drivers/rtc/rtc-max8925.c
+++ b/drivers/rtc/rtc-max8925.c
@@ -69,6 +69,7 @@ struct max8925_rtc_info {
69 struct max8925_chip *chip; 69 struct max8925_chip *chip;
70 struct i2c_client *rtc; 70 struct i2c_client *rtc;
71 struct device *dev; 71 struct device *dev;
72 int irq;
72}; 73};
73 74
74static irqreturn_t rtc_update_handler(int irq, void *data) 75static irqreturn_t rtc_update_handler(int irq, void *data)
@@ -250,7 +251,7 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev)
250{ 251{
251 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); 252 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
252 struct max8925_rtc_info *info; 253 struct max8925_rtc_info *info;
253 int irq, ret; 254 int ret;
254 255
255 info = kzalloc(sizeof(struct max8925_rtc_info), GFP_KERNEL); 256 info = kzalloc(sizeof(struct max8925_rtc_info), GFP_KERNEL);
256 if (!info) 257 if (!info)
@@ -258,13 +259,13 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev)
258 info->chip = chip; 259 info->chip = chip;
259 info->rtc = chip->rtc; 260 info->rtc = chip->rtc;
260 info->dev = &pdev->dev; 261 info->dev = &pdev->dev;
261 irq = chip->irq_base + MAX8925_IRQ_RTC_ALARM0; 262 info->irq = platform_get_irq(pdev, 0);
262 263
263 ret = request_threaded_irq(irq, NULL, rtc_update_handler, 264 ret = request_threaded_irq(info->irq, NULL, rtc_update_handler,
264 IRQF_ONESHOT, "rtc-alarm0", info); 265 IRQF_ONESHOT, "rtc-alarm0", info);
265 if (ret < 0) { 266 if (ret < 0) {
266 dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", 267 dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
267 irq, ret); 268 info->irq, ret);
268 goto out_irq; 269 goto out_irq;
269 } 270 }
270 271
@@ -285,7 +286,7 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev)
285 return 0; 286 return 0;
286out_rtc: 287out_rtc:
287 platform_set_drvdata(pdev, NULL); 288 platform_set_drvdata(pdev, NULL);
288 free_irq(chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info); 289 free_irq(info->irq, info);
289out_irq: 290out_irq:
290 kfree(info); 291 kfree(info);
291 return ret; 292 return ret;
@@ -296,7 +297,7 @@ static int __devexit max8925_rtc_remove(struct platform_device *pdev)
296 struct max8925_rtc_info *info = platform_get_drvdata(pdev); 297 struct max8925_rtc_info *info = platform_get_drvdata(pdev);
297 298
298 if (info) { 299 if (info) {
299 free_irq(info->chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info); 300 free_irq(info->irq, info);
300 rtc_device_unregister(info->rtc_dev); 301 rtc_device_unregister(info->rtc_dev);
301 kfree(info); 302 kfree(info);
302 } 303 }
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 4cde4fb0cd6c..5f84b5563c2d 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -144,6 +144,15 @@ config SPI_EP93XX
144 This enables using the Cirrus EP93xx SPI controller in master 144 This enables using the Cirrus EP93xx SPI controller in master
145 mode. 145 mode.
146 146
147config SPI_FALCON
148 tristate "Falcon SPI controller support"
149 depends on SOC_FALCON
150 help
151 The external bus unit (EBU) found on the FALC-ON SoC has SPI
152 emulation that is designed for serial flash access. This driver
153 has only been tested with m25p80 type chips. The hardware has no
154 support for other types of SPI peripherals.
155
147config SPI_GPIO 156config SPI_GPIO
148 tristate "GPIO-based bitbanging SPI Master" 157 tristate "GPIO-based bitbanging SPI Master"
149 depends on GENERIC_GPIO 158 depends on GENERIC_GPIO
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 273f50d1127a..3920dcf4c740 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_SPI_DW_MMIO) += spi-dw-mmio.o
26obj-$(CONFIG_SPI_DW_PCI) += spi-dw-midpci.o 26obj-$(CONFIG_SPI_DW_PCI) += spi-dw-midpci.o
27spi-dw-midpci-objs := spi-dw-pci.o spi-dw-mid.o 27spi-dw-midpci-objs := spi-dw-pci.o spi-dw-mid.o
28obj-$(CONFIG_SPI_EP93XX) += spi-ep93xx.o 28obj-$(CONFIG_SPI_EP93XX) += spi-ep93xx.o
29obj-$(CONFIG_SPI_FALCON) += spi-falcon.o
29obj-$(CONFIG_SPI_FSL_LIB) += spi-fsl-lib.o 30obj-$(CONFIG_SPI_FSL_LIB) += spi-fsl-lib.o
30obj-$(CONFIG_SPI_FSL_ESPI) += spi-fsl-espi.o 31obj-$(CONFIG_SPI_FSL_ESPI) += spi-fsl-espi.o
31obj-$(CONFIG_SPI_FSL_SPI) += spi-fsl-spi.o 32obj-$(CONFIG_SPI_FSL_SPI) += spi-fsl-spi.o
diff --git a/drivers/spi/spi-falcon.c b/drivers/spi/spi-falcon.c
new file mode 100644
index 000000000000..8f6aa735a24c
--- /dev/null
+++ b/drivers/spi/spi-falcon.c
@@ -0,0 +1,469 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License version 2 as published
4 * by the Free Software Foundation.
5 *
6 * Copyright (C) 2012 Thomas Langer <thomas.langer@lantiq.com>
7 */
8
9#include <linux/module.h>
10#include <linux/device.h>
11#include <linux/platform_device.h>
12#include <linux/spi/spi.h>
13#include <linux/delay.h>
14#include <linux/workqueue.h>
15#include <linux/of.h>
16#include <linux/of_platform.h>
17
18#include <lantiq_soc.h>
19
20#define DRV_NAME "sflash-falcon"
21
22#define FALCON_SPI_XFER_BEGIN (1 << 0)
23#define FALCON_SPI_XFER_END (1 << 1)
24
25/* Bus Read Configuration Register0 */
26#define BUSRCON0 0x00000010
27/* Bus Write Configuration Register0 */
28#define BUSWCON0 0x00000018
29/* Serial Flash Configuration Register */
30#define SFCON 0x00000080
31/* Serial Flash Time Register */
32#define SFTIME 0x00000084
33/* Serial Flash Status Register */
34#define SFSTAT 0x00000088
35/* Serial Flash Command Register */
36#define SFCMD 0x0000008C
37/* Serial Flash Address Register */
38#define SFADDR 0x00000090
39/* Serial Flash Data Register */
40#define SFDATA 0x00000094
41/* Serial Flash I/O Control Register */
42#define SFIO 0x00000098
43/* EBU Clock Control Register */
44#define EBUCC 0x000000C4
45
46/* Dummy Phase Length */
47#define SFCMD_DUMLEN_OFFSET 16
48#define SFCMD_DUMLEN_MASK 0x000F0000
49/* Chip Select */
50#define SFCMD_CS_OFFSET 24
51#define SFCMD_CS_MASK 0x07000000
52/* field offset */
53#define SFCMD_ALEN_OFFSET 20
54#define SFCMD_ALEN_MASK 0x00700000
55/* SCK Rise-edge Position */
56#define SFTIME_SCKR_POS_OFFSET 8
57#define SFTIME_SCKR_POS_MASK 0x00000F00
58/* SCK Period */
59#define SFTIME_SCK_PER_OFFSET 0
60#define SFTIME_SCK_PER_MASK 0x0000000F
61/* SCK Fall-edge Position */
62#define SFTIME_SCKF_POS_OFFSET 12
63#define SFTIME_SCKF_POS_MASK 0x0000F000
64/* Device Size */
65#define SFCON_DEV_SIZE_A23_0 0x03000000
66#define SFCON_DEV_SIZE_MASK 0x0F000000
67/* Read Data Position */
68#define SFTIME_RD_POS_MASK 0x000F0000
69/* Data Output */
70#define SFIO_UNUSED_WD_MASK 0x0000000F
71/* Command Opcode mask */
72#define SFCMD_OPC_MASK 0x000000FF
73/* dlen bytes of data to write */
74#define SFCMD_DIR_WRITE 0x00000100
75/* Data Length offset */
76#define SFCMD_DLEN_OFFSET 9
77/* Command Error */
78#define SFSTAT_CMD_ERR 0x20000000
79/* Access Command Pending */
80#define SFSTAT_CMD_PEND 0x00400000
81/* Frequency set to 100MHz. */
82#define EBUCC_EBUDIV_SELF100 0x00000001
83/* Serial Flash */
84#define BUSRCON0_AGEN_SERIAL_FLASH 0xF0000000
85/* 8-bit multiplexed */
86#define BUSRCON0_PORTW_8_BIT_MUX 0x00000000
87/* Serial Flash */
88#define BUSWCON0_AGEN_SERIAL_FLASH 0xF0000000
89/* Chip Select after opcode */
90#define SFCMD_KEEP_CS_KEEP_SELECTED 0x00008000
91
92#define CLOCK_100M 100000000
93#define CLOCK_50M 50000000
94
95struct falcon_sflash {
96 u32 sfcmd; /* for caching of opcode, direction, ... */
97 struct spi_master *master;
98};
99
100int falcon_sflash_xfer(struct spi_device *spi, struct spi_transfer *t,
101 unsigned long flags)
102{
103 struct device *dev = &spi->dev;
104 struct falcon_sflash *priv = spi_master_get_devdata(spi->master);
105 const u8 *txp = t->tx_buf;
106 u8 *rxp = t->rx_buf;
107 unsigned int bytelen = ((8 * t->len + 7) / 8);
108 unsigned int len, alen, dumlen;
109 u32 val;
110 enum {
111 state_init,
112 state_command_prepare,
113 state_write,
114 state_read,
115 state_disable_cs,
116 state_end
117 } state = state_init;
118
119 do {
120 switch (state) {
121 case state_init: /* detect phase of upper layer sequence */
122 {
123 /* initial write ? */
124 if (flags & FALCON_SPI_XFER_BEGIN) {
125 if (!txp) {
126 dev_err(dev,
127 "BEGIN without tx data!\n");
128 return -ENODATA;
129 }
130 /*
131 * Prepare the parts of the sfcmd register,
132 * which should not change during a sequence!
133 * Only exception are the length fields,
134 * especially alen and dumlen.
135 */
136
137 priv->sfcmd = ((spi->chip_select
138 << SFCMD_CS_OFFSET)
139 & SFCMD_CS_MASK);
140 priv->sfcmd |= SFCMD_KEEP_CS_KEEP_SELECTED;
141 priv->sfcmd |= *txp;
142 txp++;
143 bytelen--;
144 if (bytelen) {
145 /*
146 * more data:
147 * maybe address and/or dummy
148 */
149 state = state_command_prepare;
150 break;
151 } else {
152 dev_dbg(dev, "write cmd %02X\n",
153 priv->sfcmd & SFCMD_OPC_MASK);
154 }
155 }
156 /* continued write ? */
157 if (txp && bytelen) {
158 state = state_write;
159 break;
160 }
161 /* read data? */
162 if (rxp && bytelen) {
163 state = state_read;
164 break;
165 }
166 /* end of sequence? */
167 if (flags & FALCON_SPI_XFER_END)
168 state = state_disable_cs;
169 else
170 state = state_end;
171 break;
172 }
173 /* collect tx data for address and dummy phase */
174 case state_command_prepare:
175 {
176 /* txp is valid, already checked */
177 val = 0;
178 alen = 0;
179 dumlen = 0;
180 while (bytelen > 0) {
181 if (alen < 3) {
182 val = (val << 8) | (*txp++);
183 alen++;
184 } else if ((dumlen < 15) && (*txp == 0)) {
185 /*
186 * assume dummy bytes are set to 0
187 * from upper layer
188 */
189 dumlen++;
190 txp++;
191 } else {
192 break;
193 }
194 bytelen--;
195 }
196 priv->sfcmd &= ~(SFCMD_ALEN_MASK | SFCMD_DUMLEN_MASK);
197 priv->sfcmd |= (alen << SFCMD_ALEN_OFFSET) |
198 (dumlen << SFCMD_DUMLEN_OFFSET);
199 if (alen > 0)
200 ltq_ebu_w32(val, SFADDR);
201
202 dev_dbg(dev, "wr %02X, alen=%d (addr=%06X) dlen=%d\n",
203 priv->sfcmd & SFCMD_OPC_MASK,
204 alen, val, dumlen);
205
206 if (bytelen > 0) {
207 /* continue with write */
208 state = state_write;
209 } else if (flags & FALCON_SPI_XFER_END) {
210 /* end of sequence? */
211 state = state_disable_cs;
212 } else {
213 /*
214 * go to end and expect another
215 * call (read or write)
216 */
217 state = state_end;
218 }
219 break;
220 }
221 case state_write:
222 {
223 /* txp still valid */
224 priv->sfcmd |= SFCMD_DIR_WRITE;
225 len = 0;
226 val = 0;
227 do {
228 if (bytelen--)
229 val |= (*txp++) << (8 * len++);
230 if ((flags & FALCON_SPI_XFER_END)
231 && (bytelen == 0)) {
232 priv->sfcmd &=
233 ~SFCMD_KEEP_CS_KEEP_SELECTED;
234 }
235 if ((len == 4) || (bytelen == 0)) {
236 ltq_ebu_w32(val, SFDATA);
237 ltq_ebu_w32(priv->sfcmd
238 | (len<<SFCMD_DLEN_OFFSET),
239 SFCMD);
240 len = 0;
241 val = 0;
242 priv->sfcmd &= ~(SFCMD_ALEN_MASK
243 | SFCMD_DUMLEN_MASK);
244 }
245 } while (bytelen);
246 state = state_end;
247 break;
248 }
249 case state_read:
250 {
251 /* read data */
252 priv->sfcmd &= ~SFCMD_DIR_WRITE;
253 do {
254 if ((flags & FALCON_SPI_XFER_END)
255 && (bytelen <= 4)) {
256 priv->sfcmd &=
257 ~SFCMD_KEEP_CS_KEEP_SELECTED;
258 }
259 len = (bytelen > 4) ? 4 : bytelen;
260 bytelen -= len;
261 ltq_ebu_w32(priv->sfcmd
262 | (len << SFCMD_DLEN_OFFSET), SFCMD);
263 priv->sfcmd &= ~(SFCMD_ALEN_MASK
264 | SFCMD_DUMLEN_MASK);
265 do {
266 val = ltq_ebu_r32(SFSTAT);
267 if (val & SFSTAT_CMD_ERR) {
268 /* reset error status */
269 dev_err(dev, "SFSTAT: CMD_ERR");
270 dev_err(dev, " (%x)\n", val);
271 ltq_ebu_w32(SFSTAT_CMD_ERR,
272 SFSTAT);
273 return -EBADE;
274 }
275 } while (val & SFSTAT_CMD_PEND);
276 val = ltq_ebu_r32(SFDATA);
277 do {
278 *rxp = (val & 0xFF);
279 rxp++;
280 val >>= 8;
281 len--;
282 } while (len);
283 } while (bytelen);
284 state = state_end;
285 break;
286 }
287 case state_disable_cs:
288 {
289 priv->sfcmd &= ~SFCMD_KEEP_CS_KEEP_SELECTED;
290 ltq_ebu_w32(priv->sfcmd | (0 << SFCMD_DLEN_OFFSET),
291 SFCMD);
292 val = ltq_ebu_r32(SFSTAT);
293 if (val & SFSTAT_CMD_ERR) {
294 /* reset error status */
295 dev_err(dev, "SFSTAT: CMD_ERR (%x)\n", val);
296 ltq_ebu_w32(SFSTAT_CMD_ERR, SFSTAT);
297 return -EBADE;
298 }
299 state = state_end;
300 break;
301 }
302 case state_end:
303 break;
304 }
305 } while (state != state_end);
306
307 return 0;
308}
309
310static int falcon_sflash_setup(struct spi_device *spi)
311{
312 unsigned int i;
313 unsigned long flags;
314
315 if (spi->chip_select > 0)
316 return -ENODEV;
317
318 spin_lock_irqsave(&ebu_lock, flags);
319
320 if (spi->max_speed_hz >= CLOCK_100M) {
321 /* set EBU clock to 100 MHz */
322 ltq_sys1_w32_mask(0, EBUCC_EBUDIV_SELF100, EBUCC);
323 i = 1; /* divider */
324 } else {
325 /* set EBU clock to 50 MHz */
326 ltq_sys1_w32_mask(EBUCC_EBUDIV_SELF100, 0, EBUCC);
327
328 /* search for suitable divider */
329 for (i = 1; i < 7; i++) {
330 if (CLOCK_50M / i <= spi->max_speed_hz)
331 break;
332 }
333 }
334
335 /* setup period of serial clock */
336 ltq_ebu_w32_mask(SFTIME_SCKF_POS_MASK
337 | SFTIME_SCKR_POS_MASK
338 | SFTIME_SCK_PER_MASK,
339 (i << SFTIME_SCKR_POS_OFFSET)
340 | (i << (SFTIME_SCK_PER_OFFSET + 1)),
341 SFTIME);
342
343 /*
344 * set some bits of unused_wd, to not trigger HOLD/WP
345 * signals on non QUAD flashes
346 */
347 ltq_ebu_w32((SFIO_UNUSED_WD_MASK & (0x8 | 0x4)), SFIO);
348
349 ltq_ebu_w32(BUSRCON0_AGEN_SERIAL_FLASH | BUSRCON0_PORTW_8_BIT_MUX,
350 BUSRCON0);
351 ltq_ebu_w32(BUSWCON0_AGEN_SERIAL_FLASH, BUSWCON0);
352 /* set address wrap around to maximum for 24-bit addresses */
353 ltq_ebu_w32_mask(SFCON_DEV_SIZE_MASK, SFCON_DEV_SIZE_A23_0, SFCON);
354
355 spin_unlock_irqrestore(&ebu_lock, flags);
356
357 return 0;
358}
359
360static int falcon_sflash_prepare_xfer(struct spi_master *master)
361{
362 return 0;
363}
364
365static int falcon_sflash_unprepare_xfer(struct spi_master *master)
366{
367 return 0;
368}
369
370static int falcon_sflash_xfer_one(struct spi_master *master,
371 struct spi_message *m)
372{
373 struct falcon_sflash *priv = spi_master_get_devdata(master);
374 struct spi_transfer *t;
375 unsigned long spi_flags;
376 unsigned long flags;
377 int ret = 0;
378
379 priv->sfcmd = 0;
380 m->actual_length = 0;
381
382 spi_flags = FALCON_SPI_XFER_BEGIN;
383 list_for_each_entry(t, &m->transfers, transfer_list) {
384 if (list_is_last(&t->transfer_list, &m->transfers))
385 spi_flags |= FALCON_SPI_XFER_END;
386
387 spin_lock_irqsave(&ebu_lock, flags);
388 ret = falcon_sflash_xfer(m->spi, t, spi_flags);
389 spin_unlock_irqrestore(&ebu_lock, flags);
390
391 if (ret)
392 break;
393
394 m->actual_length += t->len;
395
396 WARN_ON(t->delay_usecs || t->cs_change);
397 spi_flags = 0;
398 }
399
400 m->status = ret;
401 m->complete(m->context);
402
403 return 0;
404}
405
406static int __devinit falcon_sflash_probe(struct platform_device *pdev)
407{
408 struct falcon_sflash *priv;
409 struct spi_master *master;
410 int ret;
411
412 if (ltq_boot_select() != BS_SPI) {
413 dev_err(&pdev->dev, "invalid bootstrap options\n");
414 return -ENODEV;
415 }
416
417 master = spi_alloc_master(&pdev->dev, sizeof(*priv));
418 if (!master)
419 return -ENOMEM;
420
421 priv = spi_master_get_devdata(master);
422 priv->master = master;
423
424 master->mode_bits = SPI_MODE_3;
425 master->num_chipselect = 1;
426 master->bus_num = -1;
427 master->setup = falcon_sflash_setup;
428 master->prepare_transfer_hardware = falcon_sflash_prepare_xfer;
429 master->transfer_one_message = falcon_sflash_xfer_one;
430 master->unprepare_transfer_hardware = falcon_sflash_unprepare_xfer;
431 master->dev.of_node = pdev->dev.of_node;
432
433 platform_set_drvdata(pdev, priv);
434
435 ret = spi_register_master(master);
436 if (ret)
437 spi_master_put(master);
438 return ret;
439}
440
441static int __devexit falcon_sflash_remove(struct platform_device *pdev)
442{
443 struct falcon_sflash *priv = platform_get_drvdata(pdev);
444
445 spi_unregister_master(priv->master);
446
447 return 0;
448}
449
450static const struct of_device_id falcon_sflash_match[] = {
451 { .compatible = "lantiq,sflash-falcon" },
452 {},
453};
454MODULE_DEVICE_TABLE(of, falcon_sflash_match);
455
456static struct platform_driver falcon_sflash_driver = {
457 .probe = falcon_sflash_probe,
458 .remove = __devexit_p(falcon_sflash_remove),
459 .driver = {
460 .name = DRV_NAME,
461 .owner = THIS_MODULE,
462 .of_match_table = falcon_sflash_match,
463 }
464};
465
466module_platform_driver(falcon_sflash_driver);
467
468MODULE_LICENSE("GPL");
469MODULE_DESCRIPTION("Lantiq Falcon SPI/SFLASH controller driver");
diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c
index e31949c9c87e..f15b31b37ca5 100644
--- a/drivers/staging/octeon/ethernet-mdio.c
+++ b/drivers/staging/octeon/ethernet-mdio.c
@@ -28,6 +28,7 @@
28#include <linux/ethtool.h> 28#include <linux/ethtool.h>
29#include <linux/phy.h> 29#include <linux/phy.h>
30#include <linux/ratelimit.h> 30#include <linux/ratelimit.h>
31#include <linux/of_mdio.h>
31 32
32#include <net/dst.h> 33#include <net/dst.h>
33 34
@@ -161,22 +162,23 @@ static void cvm_oct_adjust_link(struct net_device *dev)
161int cvm_oct_phy_setup_device(struct net_device *dev) 162int cvm_oct_phy_setup_device(struct net_device *dev)
162{ 163{
163 struct octeon_ethernet *priv = netdev_priv(dev); 164 struct octeon_ethernet *priv = netdev_priv(dev);
165 struct device_node *phy_node;
164 166
165 int phy_addr = cvmx_helper_board_get_mii_address(priv->port); 167 if (!priv->of_node)
166 if (phy_addr != -1) { 168 return 0;
167 char phy_id[MII_BUS_ID_SIZE + 3];
168 169
169 snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, "mdio-octeon-0", phy_addr); 170 phy_node = of_parse_phandle(priv->of_node, "phy-handle", 0);
171 if (!phy_node)
172 return 0;
170 173
171 priv->phydev = phy_connect(dev, phy_id, cvm_oct_adjust_link, 0, 174 priv->phydev = of_phy_connect(dev, phy_node, cvm_oct_adjust_link, 0,
172 PHY_INTERFACE_MODE_GMII); 175 PHY_INTERFACE_MODE_GMII);
176
177 if (priv->phydev == NULL)
178 return -ENODEV;
179
180 priv->last_link = 0;
181 phy_start_aneg(priv->phydev);
173 182
174 if (IS_ERR(priv->phydev)) {
175 priv->phydev = NULL;
176 return -1;
177 }
178 priv->last_link = 0;
179 phy_start_aneg(priv->phydev);
180 }
181 return 0; 183 return 0;
182} 184}
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index 18f7a790f73d..683bedc74dde 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -24,6 +24,7 @@
24 * This file may also be available under a different license from Cavium. 24 * This file may also be available under a different license from Cavium.
25 * Contact Cavium Networks for more information 25 * Contact Cavium Networks for more information
26**********************************************************************/ 26**********************************************************************/
27#include <linux/platform_device.h>
27#include <linux/kernel.h> 28#include <linux/kernel.h>
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/module.h> 30#include <linux/module.h>
@@ -32,6 +33,7 @@
32#include <linux/phy.h> 33#include <linux/phy.h>
33#include <linux/slab.h> 34#include <linux/slab.h>
34#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/of_net.h>
35 37
36#include <net/dst.h> 38#include <net/dst.h>
37 39
@@ -113,15 +115,6 @@ int rx_napi_weight = 32;
113module_param(rx_napi_weight, int, 0444); 115module_param(rx_napi_weight, int, 0444);
114MODULE_PARM_DESC(rx_napi_weight, "The NAPI WEIGHT parameter."); 116MODULE_PARM_DESC(rx_napi_weight, "The NAPI WEIGHT parameter.");
115 117
116/*
117 * The offset from mac_addr_base that should be used for the next port
118 * that is configured. By convention, if any mgmt ports exist on the
119 * chip, they get the first mac addresses, The ports controlled by
120 * this driver are numbered sequencially following any mgmt addresses
121 * that may exist.
122 */
123static unsigned int cvm_oct_mac_addr_offset;
124
125/** 118/**
126 * cvm_oct_poll_queue - Workqueue for polling operations. 119 * cvm_oct_poll_queue - Workqueue for polling operations.
127 */ 120 */
@@ -176,7 +169,7 @@ static void cvm_oct_periodic_worker(struct work_struct *work)
176 queue_delayed_work(cvm_oct_poll_queue, &priv->port_periodic_work, HZ); 169 queue_delayed_work(cvm_oct_poll_queue, &priv->port_periodic_work, HZ);
177 } 170 }
178 171
179static __init void cvm_oct_configure_common_hw(void) 172static __devinit void cvm_oct_configure_common_hw(void)
180{ 173{
181 /* Setup the FPA */ 174 /* Setup the FPA */
182 cvmx_fpa_enable(); 175 cvmx_fpa_enable();
@@ -396,23 +389,21 @@ static void cvm_oct_common_set_multicast_list(struct net_device *dev)
396 389
397 * Returns Zero on success 390 * Returns Zero on success
398 */ 391 */
399static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr) 392static int cvm_oct_set_mac_filter(struct net_device *dev)
400{ 393{
401 struct octeon_ethernet *priv = netdev_priv(dev); 394 struct octeon_ethernet *priv = netdev_priv(dev);
402 union cvmx_gmxx_prtx_cfg gmx_cfg; 395 union cvmx_gmxx_prtx_cfg gmx_cfg;
403 int interface = INTERFACE(priv->port); 396 int interface = INTERFACE(priv->port);
404 int index = INDEX(priv->port); 397 int index = INDEX(priv->port);
405 398
406 memcpy(dev->dev_addr, addr + 2, 6);
407
408 if ((interface < 2) 399 if ((interface < 2)
409 && (cvmx_helper_interface_get_mode(interface) != 400 && (cvmx_helper_interface_get_mode(interface) !=
410 CVMX_HELPER_INTERFACE_MODE_SPI)) { 401 CVMX_HELPER_INTERFACE_MODE_SPI)) {
411 int i; 402 int i;
412 uint8_t *ptr = addr; 403 uint8_t *ptr = dev->dev_addr;
413 uint64_t mac = 0; 404 uint64_t mac = 0;
414 for (i = 0; i < 6; i++) 405 for (i = 0; i < 6; i++)
415 mac = (mac << 8) | (uint64_t) (ptr[i + 2]); 406 mac = (mac << 8) | (uint64_t)ptr[i];
416 407
417 gmx_cfg.u64 = 408 gmx_cfg.u64 =
418 cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface)); 409 cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
@@ -421,17 +412,17 @@ static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr)
421 412
422 cvmx_write_csr(CVMX_GMXX_SMACX(index, interface), mac); 413 cvmx_write_csr(CVMX_GMXX_SMACX(index, interface), mac);
423 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM0(index, interface), 414 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM0(index, interface),
424 ptr[2]); 415 ptr[0]);
425 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM1(index, interface), 416 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM1(index, interface),
426 ptr[3]); 417 ptr[1]);
427 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM2(index, interface), 418 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM2(index, interface),
428 ptr[4]); 419 ptr[2]);
429 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM3(index, interface), 420 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM3(index, interface),
430 ptr[5]); 421 ptr[3]);
431 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM4(index, interface), 422 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM4(index, interface),
432 ptr[6]); 423 ptr[4]);
433 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM5(index, interface), 424 cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM5(index, interface),
434 ptr[7]); 425 ptr[5]);
435 cvm_oct_common_set_multicast_list(dev); 426 cvm_oct_common_set_multicast_list(dev);
436 cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), 427 cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface),
437 gmx_cfg.u64); 428 gmx_cfg.u64);
@@ -439,6 +430,15 @@ static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr)
439 return 0; 430 return 0;
440} 431}
441 432
433static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr)
434{
435 int r = eth_mac_addr(dev, addr);
436
437 if (r)
438 return r;
439 return cvm_oct_set_mac_filter(dev);
440}
441
442/** 442/**
443 * cvm_oct_common_init - per network device initialization 443 * cvm_oct_common_init - per network device initialization
444 * @dev: Device to initialize 444 * @dev: Device to initialize
@@ -448,26 +448,17 @@ static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr)
448int cvm_oct_common_init(struct net_device *dev) 448int cvm_oct_common_init(struct net_device *dev)
449{ 449{
450 struct octeon_ethernet *priv = netdev_priv(dev); 450 struct octeon_ethernet *priv = netdev_priv(dev);
451 struct sockaddr sa; 451 const u8 *mac = NULL;
452 u64 mac = ((u64)(octeon_bootinfo->mac_addr_base[0] & 0xff) << 40) | 452
453 ((u64)(octeon_bootinfo->mac_addr_base[1] & 0xff) << 32) | 453 if (priv->of_node)
454 ((u64)(octeon_bootinfo->mac_addr_base[2] & 0xff) << 24) | 454 mac = of_get_mac_address(priv->of_node);
455 ((u64)(octeon_bootinfo->mac_addr_base[3] & 0xff) << 16) | 455
456 ((u64)(octeon_bootinfo->mac_addr_base[4] & 0xff) << 8) | 456 if (mac && is_valid_ether_addr(mac)) {
457 (u64)(octeon_bootinfo->mac_addr_base[5] & 0xff); 457 memcpy(dev->dev_addr, mac, ETH_ALEN);
458 458 dev->addr_assign_type &= ~NET_ADDR_RANDOM;
459 mac += cvm_oct_mac_addr_offset; 459 } else {
460 sa.sa_data[0] = (mac >> 40) & 0xff; 460 eth_hw_addr_random(dev);
461 sa.sa_data[1] = (mac >> 32) & 0xff; 461 }
462 sa.sa_data[2] = (mac >> 24) & 0xff;
463 sa.sa_data[3] = (mac >> 16) & 0xff;
464 sa.sa_data[4] = (mac >> 8) & 0xff;
465 sa.sa_data[5] = mac & 0xff;
466
467 if (cvm_oct_mac_addr_offset >= octeon_bootinfo->mac_addr_count)
468 printk(KERN_DEBUG "%s: Using MAC outside of the assigned range:"
469 " %pM\n", dev->name, sa.sa_data);
470 cvm_oct_mac_addr_offset++;
471 462
472 /* 463 /*
473 * Force the interface to use the POW send if always_use_pow 464 * Force the interface to use the POW send if always_use_pow
@@ -488,7 +479,7 @@ int cvm_oct_common_init(struct net_device *dev)
488 SET_ETHTOOL_OPS(dev, &cvm_oct_ethtool_ops); 479 SET_ETHTOOL_OPS(dev, &cvm_oct_ethtool_ops);
489 480
490 cvm_oct_phy_setup_device(dev); 481 cvm_oct_phy_setup_device(dev);
491 dev->netdev_ops->ndo_set_mac_address(dev, &sa); 482 cvm_oct_set_mac_filter(dev);
492 dev->netdev_ops->ndo_change_mtu(dev, dev->mtu); 483 dev->netdev_ops->ndo_change_mtu(dev, dev->mtu);
493 484
494 /* 485 /*
@@ -595,22 +586,55 @@ static const struct net_device_ops cvm_oct_pow_netdev_ops = {
595 586
596extern void octeon_mdiobus_force_mod_depencency(void); 587extern void octeon_mdiobus_force_mod_depencency(void);
597 588
598static int __init cvm_oct_init_module(void) 589static struct device_node * __devinit cvm_oct_of_get_child(const struct device_node *parent,
590 int reg_val)
591{
592 struct device_node *node = NULL;
593 int size;
594 const __be32 *addr;
595
596 for (;;) {
597 node = of_get_next_child(parent, node);
598 if (!node)
599 break;
600 addr = of_get_property(node, "reg", &size);
601 if (addr && (be32_to_cpu(*addr) == reg_val))
602 break;
603 }
604 return node;
605}
606
607static struct device_node * __devinit cvm_oct_node_for_port(struct device_node *pip,
608 int interface, int port)
609{
610 struct device_node *ni, *np;
611
612 ni = cvm_oct_of_get_child(pip, interface);
613 if (!ni)
614 return NULL;
615
616 np = cvm_oct_of_get_child(ni, port);
617 of_node_put(ni);
618
619 return np;
620}
621
622static int __devinit cvm_oct_probe(struct platform_device *pdev)
599{ 623{
600 int num_interfaces; 624 int num_interfaces;
601 int interface; 625 int interface;
602 int fau = FAU_NUM_PACKET_BUFFERS_TO_FREE; 626 int fau = FAU_NUM_PACKET_BUFFERS_TO_FREE;
603 int qos; 627 int qos;
628 struct device_node *pip;
604 629
605 octeon_mdiobus_force_mod_depencency(); 630 octeon_mdiobus_force_mod_depencency();
606 pr_notice("cavium-ethernet %s\n", OCTEON_ETHERNET_VERSION); 631 pr_notice("cavium-ethernet %s\n", OCTEON_ETHERNET_VERSION);
607 632
608 if (OCTEON_IS_MODEL(OCTEON_CN52XX)) 633 pip = pdev->dev.of_node;
609 cvm_oct_mac_addr_offset = 2; /* First two are the mgmt ports. */ 634 if (!pip) {
610 else if (OCTEON_IS_MODEL(OCTEON_CN56XX)) 635 pr_err("Error: No 'pip' in /aliases\n");
611 cvm_oct_mac_addr_offset = 1; /* First one is the mgmt port. */ 636 return -EINVAL;
612 else 637 }
613 cvm_oct_mac_addr_offset = 0;
614 638
615 cvm_oct_poll_queue = create_singlethread_workqueue("octeon-ethernet"); 639 cvm_oct_poll_queue = create_singlethread_workqueue("octeon-ethernet");
616 if (cvm_oct_poll_queue == NULL) { 640 if (cvm_oct_poll_queue == NULL) {
@@ -689,10 +713,11 @@ static int __init cvm_oct_init_module(void)
689 cvmx_helper_interface_get_mode(interface); 713 cvmx_helper_interface_get_mode(interface);
690 int num_ports = cvmx_helper_ports_on_interface(interface); 714 int num_ports = cvmx_helper_ports_on_interface(interface);
691 int port; 715 int port;
716 int port_index;
692 717
693 for (port = cvmx_helper_get_ipd_port(interface, 0); 718 for (port_index = 0, port = cvmx_helper_get_ipd_port(interface, 0);
694 port < cvmx_helper_get_ipd_port(interface, num_ports); 719 port < cvmx_helper_get_ipd_port(interface, num_ports);
695 port++) { 720 port_index++, port++) {
696 struct octeon_ethernet *priv; 721 struct octeon_ethernet *priv;
697 struct net_device *dev = 722 struct net_device *dev =
698 alloc_etherdev(sizeof(struct octeon_ethernet)); 723 alloc_etherdev(sizeof(struct octeon_ethernet));
@@ -703,6 +728,7 @@ static int __init cvm_oct_init_module(void)
703 728
704 /* Initialize the device private structure. */ 729 /* Initialize the device private structure. */
705 priv = netdev_priv(dev); 730 priv = netdev_priv(dev);
731 priv->of_node = cvm_oct_node_for_port(pip, interface, port_index);
706 732
707 INIT_DELAYED_WORK(&priv->port_periodic_work, 733 INIT_DELAYED_WORK(&priv->port_periodic_work,
708 cvm_oct_periodic_worker); 734 cvm_oct_periodic_worker);
@@ -787,7 +813,7 @@ static int __init cvm_oct_init_module(void)
787 return 0; 813 return 0;
788} 814}
789 815
790static void __exit cvm_oct_cleanup_module(void) 816static int __devexit cvm_oct_remove(struct platform_device *pdev)
791{ 817{
792 int port; 818 int port;
793 819
@@ -835,10 +861,29 @@ static void __exit cvm_oct_cleanup_module(void)
835 if (CVMX_FPA_OUTPUT_BUFFER_POOL != CVMX_FPA_PACKET_POOL) 861 if (CVMX_FPA_OUTPUT_BUFFER_POOL != CVMX_FPA_PACKET_POOL)
836 cvm_oct_mem_empty_fpa(CVMX_FPA_OUTPUT_BUFFER_POOL, 862 cvm_oct_mem_empty_fpa(CVMX_FPA_OUTPUT_BUFFER_POOL,
837 CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE, 128); 863 CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE, 128);
864 return 0;
838} 865}
839 866
867static struct of_device_id cvm_oct_match[] = {
868 {
869 .compatible = "cavium,octeon-3860-pip",
870 },
871 {},
872};
873MODULE_DEVICE_TABLE(of, cvm_oct_match);
874
875static struct platform_driver cvm_oct_driver = {
876 .probe = cvm_oct_probe,
877 .remove = __devexit_p(cvm_oct_remove),
878 .driver = {
879 .owner = THIS_MODULE,
880 .name = KBUILD_MODNAME,
881 .of_match_table = cvm_oct_match,
882 },
883};
884
885module_platform_driver(cvm_oct_driver);
886
840MODULE_LICENSE("GPL"); 887MODULE_LICENSE("GPL");
841MODULE_AUTHOR("Cavium Networks <support@caviumnetworks.com>"); 888MODULE_AUTHOR("Cavium Networks <support@caviumnetworks.com>");
842MODULE_DESCRIPTION("Cavium Networks Octeon ethernet driver."); 889MODULE_DESCRIPTION("Cavium Networks Octeon ethernet driver.");
843module_init(cvm_oct_init_module);
844module_exit(cvm_oct_cleanup_module);
diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h
index d58192563552..9360e22e0739 100644
--- a/drivers/staging/octeon/octeon-ethernet.h
+++ b/drivers/staging/octeon/octeon-ethernet.h
@@ -31,6 +31,8 @@
31#ifndef OCTEON_ETHERNET_H 31#ifndef OCTEON_ETHERNET_H
32#define OCTEON_ETHERNET_H 32#define OCTEON_ETHERNET_H
33 33
34#include <linux/of.h>
35
34/** 36/**
35 * This is the definition of the Ethernet driver's private 37 * This is the definition of the Ethernet driver's private
36 * driver state stored in netdev_priv(dev). 38 * driver state stored in netdev_priv(dev).
@@ -59,6 +61,7 @@ struct octeon_ethernet {
59 void (*poll) (struct net_device *dev); 61 void (*poll) (struct net_device *dev);
60 struct delayed_work port_periodic_work; 62 struct delayed_work port_periodic_work;
61 struct work_struct port_work; /* may be unused. */ 63 struct work_struct port_work; /* may be unused. */
64 struct device_node *of_node;
62}; 65};
63 66
64int cvm_oct_free_work(void *work_queue_entry); 67int cvm_oct_free_work(void *work_queue_entry);
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index ec21f4a4a056..bb55eb4a7d48 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -152,14 +152,14 @@ static int omap_ehci_init(struct usb_hcd *hcd)
152 struct ehci_hcd_omap_platform_data *pdata; 152 struct ehci_hcd_omap_platform_data *pdata;
153 153
154 pdata = hcd->self.controller->platform_data; 154 pdata = hcd->self.controller->platform_data;
155
156 /* Hold PHYs in reset while initializing EHCI controller */
155 if (pdata->phy_reset) { 157 if (pdata->phy_reset) {
156 if (gpio_is_valid(pdata->reset_gpio_port[0])) 158 if (gpio_is_valid(pdata->reset_gpio_port[0]))
157 gpio_request_one(pdata->reset_gpio_port[0], 159 gpio_set_value_cansleep(pdata->reset_gpio_port[0], 0);
158 GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
159 160
160 if (gpio_is_valid(pdata->reset_gpio_port[1])) 161 if (gpio_is_valid(pdata->reset_gpio_port[1]))
161 gpio_request_one(pdata->reset_gpio_port[1], 162 gpio_set_value_cansleep(pdata->reset_gpio_port[1], 0);
162 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
163 163
164 /* Hold the PHY in RESET for enough time till DIR is high */ 164 /* Hold the PHY in RESET for enough time till DIR is high */
165 udelay(10); 165 udelay(10);
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 2979292650d6..cf282763a8dc 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -245,7 +245,7 @@ config BACKLIGHT_CARILLO_RANCH
245 245
246config BACKLIGHT_PWM 246config BACKLIGHT_PWM
247 tristate "Generic PWM based Backlight Driver" 247 tristate "Generic PWM based Backlight Driver"
248 depends on HAVE_PWM 248 depends on PWM
249 help 249 help
250 If you have a LCD backlight adjustable by PWM, say Y to enable 250 If you have a LCD backlight adjustable by PWM, say Y to enable
251 this driver. 251 this driver.
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 342b7d7cbb63..995f0164c9b0 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -26,11 +26,13 @@ struct pwm_bl_data {
26 struct device *dev; 26 struct device *dev;
27 unsigned int period; 27 unsigned int period;
28 unsigned int lth_brightness; 28 unsigned int lth_brightness;
29 unsigned int *levels;
29 int (*notify)(struct device *, 30 int (*notify)(struct device *,
30 int brightness); 31 int brightness);
31 void (*notify_after)(struct device *, 32 void (*notify_after)(struct device *,
32 int brightness); 33 int brightness);
33 int (*check_fb)(struct device *, struct fb_info *); 34 int (*check_fb)(struct device *, struct fb_info *);
35 void (*exit)(struct device *);
34}; 36};
35 37
36static int pwm_backlight_update_status(struct backlight_device *bl) 38static int pwm_backlight_update_status(struct backlight_device *bl)
@@ -52,9 +54,18 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
52 pwm_config(pb->pwm, 0, pb->period); 54 pwm_config(pb->pwm, 0, pb->period);
53 pwm_disable(pb->pwm); 55 pwm_disable(pb->pwm);
54 } else { 56 } else {
55 brightness = pb->lth_brightness + 57 int duty_cycle;
56 (brightness * (pb->period - pb->lth_brightness) / max); 58
57 pwm_config(pb->pwm, brightness, pb->period); 59 if (pb->levels) {
60 duty_cycle = pb->levels[brightness];
61 max = pb->levels[max];
62 } else {
63 duty_cycle = brightness;
64 }
65
66 duty_cycle = pb->lth_brightness +
67 (duty_cycle * (pb->period - pb->lth_brightness) / max);
68 pwm_config(pb->pwm, duty_cycle, pb->period);
58 pwm_enable(pb->pwm); 69 pwm_enable(pb->pwm);
59 } 70 }
60 71
@@ -83,17 +94,98 @@ static const struct backlight_ops pwm_backlight_ops = {
83 .check_fb = pwm_backlight_check_fb, 94 .check_fb = pwm_backlight_check_fb,
84}; 95};
85 96
97#ifdef CONFIG_OF
98static int pwm_backlight_parse_dt(struct device *dev,
99 struct platform_pwm_backlight_data *data)
100{
101 struct device_node *node = dev->of_node;
102 struct property *prop;
103 int length;
104 u32 value;
105 int ret;
106
107 if (!node)
108 return -ENODEV;
109
110 memset(data, 0, sizeof(*data));
111
112 /* determine the number of brightness levels */
113 prop = of_find_property(node, "brightness-levels", &length);
114 if (!prop)
115 return -EINVAL;
116
117 data->max_brightness = length / sizeof(u32);
118
119 /* read brightness levels from DT property */
120 if (data->max_brightness > 0) {
121 size_t size = sizeof(*data->levels) * data->max_brightness;
122
123 data->levels = devm_kzalloc(dev, size, GFP_KERNEL);
124 if (!data->levels)
125 return -ENOMEM;
126
127 ret = of_property_read_u32_array(node, "brightness-levels",
128 data->levels,
129 data->max_brightness);
130 if (ret < 0)
131 return ret;
132
133 ret = of_property_read_u32(node, "default-brightness-level",
134 &value);
135 if (ret < 0)
136 return ret;
137
138 if (value >= data->max_brightness) {
139 dev_warn(dev, "invalid default brightness level: %u, using %u\n",
140 value, data->max_brightness - 1);
141 value = data->max_brightness - 1;
142 }
143
144 data->dft_brightness = value;
145 data->max_brightness--;
146 }
147
148 /*
149 * TODO: Most users of this driver use a number of GPIOs to control
150 * backlight power. Support for specifying these needs to be
151 * added.
152 */
153
154 return 0;
155}
156
157static struct of_device_id pwm_backlight_of_match[] = {
158 { .compatible = "pwm-backlight" },
159 { }
160};
161
162MODULE_DEVICE_TABLE(of, pwm_backlight_of_match);
163#else
164static int pwm_backlight_parse_dt(struct device *dev,
165 struct platform_pwm_backlight_data *data)
166{
167 return -ENODEV;
168}
169#endif
170
86static int pwm_backlight_probe(struct platform_device *pdev) 171static int pwm_backlight_probe(struct platform_device *pdev)
87{ 172{
88 struct backlight_properties props;
89 struct platform_pwm_backlight_data *data = pdev->dev.platform_data; 173 struct platform_pwm_backlight_data *data = pdev->dev.platform_data;
174 struct platform_pwm_backlight_data defdata;
175 struct backlight_properties props;
90 struct backlight_device *bl; 176 struct backlight_device *bl;
91 struct pwm_bl_data *pb; 177 struct pwm_bl_data *pb;
178 unsigned int max;
92 int ret; 179 int ret;
93 180
94 if (!data) { 181 if (!data) {
95 dev_err(&pdev->dev, "failed to find platform data\n"); 182 ret = pwm_backlight_parse_dt(&pdev->dev, &defdata);
96 return -EINVAL; 183 if (ret < 0) {
184 dev_err(&pdev->dev, "failed to find platform data\n");
185 return ret;
186 }
187
188 data = &defdata;
97 } 189 }
98 190
99 if (data->init) { 191 if (data->init) {
@@ -109,21 +201,42 @@ static int pwm_backlight_probe(struct platform_device *pdev)
109 goto err_alloc; 201 goto err_alloc;
110 } 202 }
111 203
112 pb->period = data->pwm_period_ns; 204 if (data->levels) {
205 max = data->levels[data->max_brightness];
206 pb->levels = data->levels;
207 } else
208 max = data->max_brightness;
209
113 pb->notify = data->notify; 210 pb->notify = data->notify;
114 pb->notify_after = data->notify_after; 211 pb->notify_after = data->notify_after;
115 pb->check_fb = data->check_fb; 212 pb->check_fb = data->check_fb;
116 pb->lth_brightness = data->lth_brightness * 213 pb->exit = data->exit;
117 (data->pwm_period_ns / data->max_brightness);
118 pb->dev = &pdev->dev; 214 pb->dev = &pdev->dev;
119 215
120 pb->pwm = pwm_request(data->pwm_id, "backlight"); 216 pb->pwm = pwm_get(&pdev->dev, NULL);
121 if (IS_ERR(pb->pwm)) { 217 if (IS_ERR(pb->pwm)) {
122 dev_err(&pdev->dev, "unable to request PWM for backlight\n"); 218 dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n");
123 ret = PTR_ERR(pb->pwm); 219
124 goto err_alloc; 220 pb->pwm = pwm_request(data->pwm_id, "pwm-backlight");
125 } else 221 if (IS_ERR(pb->pwm)) {
126 dev_dbg(&pdev->dev, "got pwm for backlight\n"); 222 dev_err(&pdev->dev, "unable to request legacy PWM\n");
223 ret = PTR_ERR(pb->pwm);
224 goto err_alloc;
225 }
226 }
227
228 dev_dbg(&pdev->dev, "got pwm for backlight\n");
229
230 /*
231 * The DT case will set the pwm_period_ns field to 0 and store the
232 * period, parsed from the DT, in the PWM device. For the non-DT case,
233 * set the period from platform data.
234 */
235 if (data->pwm_period_ns > 0)
236 pwm_set_period(pb->pwm, data->pwm_period_ns);
237
238 pb->period = pwm_get_period(pb->pwm);
239 pb->lth_brightness = data->lth_brightness * (pb->period / max);
127 240
128 memset(&props, 0, sizeof(struct backlight_properties)); 241 memset(&props, 0, sizeof(struct backlight_properties));
129 props.type = BACKLIGHT_RAW; 242 props.type = BACKLIGHT_RAW;
@@ -143,7 +256,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
143 return 0; 256 return 0;
144 257
145err_bl: 258err_bl:
146 pwm_free(pb->pwm); 259 pwm_put(pb->pwm);
147err_alloc: 260err_alloc:
148 if (data->exit) 261 if (data->exit)
149 data->exit(&pdev->dev); 262 data->exit(&pdev->dev);
@@ -152,16 +265,15 @@ err_alloc:
152 265
153static int pwm_backlight_remove(struct platform_device *pdev) 266static int pwm_backlight_remove(struct platform_device *pdev)
154{ 267{
155 struct platform_pwm_backlight_data *data = pdev->dev.platform_data;
156 struct backlight_device *bl = platform_get_drvdata(pdev); 268 struct backlight_device *bl = platform_get_drvdata(pdev);
157 struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev); 269 struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev);
158 270
159 backlight_device_unregister(bl); 271 backlight_device_unregister(bl);
160 pwm_config(pb->pwm, 0, pb->period); 272 pwm_config(pb->pwm, 0, pb->period);
161 pwm_disable(pb->pwm); 273 pwm_disable(pb->pwm);
162 pwm_free(pb->pwm); 274 pwm_put(pb->pwm);
163 if (data->exit) 275 if (pb->exit)
164 data->exit(&pdev->dev); 276 pb->exit(&pdev->dev);
165 return 0; 277 return 0;
166} 278}
167 279
@@ -195,11 +307,12 @@ static SIMPLE_DEV_PM_OPS(pwm_backlight_pm_ops, pwm_backlight_suspend,
195 307
196static struct platform_driver pwm_backlight_driver = { 308static struct platform_driver pwm_backlight_driver = {
197 .driver = { 309 .driver = {
198 .name = "pwm-backlight", 310 .name = "pwm-backlight",
199 .owner = THIS_MODULE, 311 .owner = THIS_MODULE,
200#ifdef CONFIG_PM 312#ifdef CONFIG_PM
201 .pm = &pwm_backlight_pm_ops, 313 .pm = &pwm_backlight_pm_ops,
202#endif 314#endif
315 .of_match_table = of_match_ptr(pwm_backlight_of_match),
203 }, 316 },
204 .probe = pwm_backlight_probe, 317 .probe = pwm_backlight_probe,
205 .remove = pwm_backlight_remove, 318 .remove = pwm_backlight_remove,
diff --git a/fs/xfs/xfs_alloc_btree.h b/fs/xfs/xfs_alloc_btree.h
index a6caa0022c9b..359fb86ed876 100644
--- a/fs/xfs/xfs_alloc_btree.h
+++ b/fs/xfs/xfs_alloc_btree.h
@@ -51,20 +51,6 @@ typedef struct xfs_alloc_rec_incore {
51typedef __be32 xfs_alloc_ptr_t; 51typedef __be32 xfs_alloc_ptr_t;
52 52
53/* 53/*
54 * Minimum and maximum blocksize and sectorsize.
55 * The blocksize upper limit is pretty much arbitrary.
56 * The sectorsize upper limit is due to sizeof(sb_sectsize).
57 */
58#define XFS_MIN_BLOCKSIZE_LOG 9 /* i.e. 512 bytes */
59#define XFS_MAX_BLOCKSIZE_LOG 16 /* i.e. 65536 bytes */
60#define XFS_MIN_BLOCKSIZE (1 << XFS_MIN_BLOCKSIZE_LOG)
61#define XFS_MAX_BLOCKSIZE (1 << XFS_MAX_BLOCKSIZE_LOG)
62#define XFS_MIN_SECTORSIZE_LOG 9 /* i.e. 512 bytes */
63#define XFS_MAX_SECTORSIZE_LOG 15 /* i.e. 32768 bytes */
64#define XFS_MIN_SECTORSIZE (1 << XFS_MIN_SECTORSIZE_LOG)
65#define XFS_MAX_SECTORSIZE (1 << XFS_MAX_SECTORSIZE_LOG)
66
67/*
68 * Block numbers in the AG: 54 * Block numbers in the AG:
69 * SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3. 55 * SB is sector 0, AGF is sector 1, AGI is sector 2, AGFL is sector 3.
70 */ 56 */
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 8dad722c0041..15052ff916ec 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -179,7 +179,7 @@ xfs_finish_ioend(
179 if (atomic_dec_and_test(&ioend->io_remaining)) { 179 if (atomic_dec_and_test(&ioend->io_remaining)) {
180 struct xfs_mount *mp = XFS_I(ioend->io_inode)->i_mount; 180 struct xfs_mount *mp = XFS_I(ioend->io_inode)->i_mount;
181 181
182 if (ioend->io_type == IO_UNWRITTEN) 182 if (ioend->io_type == XFS_IO_UNWRITTEN)
183 queue_work(mp->m_unwritten_workqueue, &ioend->io_work); 183 queue_work(mp->m_unwritten_workqueue, &ioend->io_work);
184 else if (ioend->io_append_trans) 184 else if (ioend->io_append_trans)
185 queue_work(mp->m_data_workqueue, &ioend->io_work); 185 queue_work(mp->m_data_workqueue, &ioend->io_work);
@@ -210,7 +210,7 @@ xfs_end_io(
210 * For unwritten extents we need to issue transactions to convert a 210 * For unwritten extents we need to issue transactions to convert a
211 * range to normal written extens after the data I/O has finished. 211 * range to normal written extens after the data I/O has finished.
212 */ 212 */
213 if (ioend->io_type == IO_UNWRITTEN) { 213 if (ioend->io_type == XFS_IO_UNWRITTEN) {
214 /* 214 /*
215 * For buffered I/O we never preallocate a transaction when 215 * For buffered I/O we never preallocate a transaction when
216 * doing the unwritten extent conversion, but for direct I/O 216 * doing the unwritten extent conversion, but for direct I/O
@@ -312,7 +312,7 @@ xfs_map_blocks(
312 if (XFS_FORCED_SHUTDOWN(mp)) 312 if (XFS_FORCED_SHUTDOWN(mp))
313 return -XFS_ERROR(EIO); 313 return -XFS_ERROR(EIO);
314 314
315 if (type == IO_UNWRITTEN) 315 if (type == XFS_IO_UNWRITTEN)
316 bmapi_flags |= XFS_BMAPI_IGSTATE; 316 bmapi_flags |= XFS_BMAPI_IGSTATE;
317 317
318 if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) { 318 if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) {
@@ -323,10 +323,10 @@ xfs_map_blocks(
323 323
324 ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE || 324 ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
325 (ip->i_df.if_flags & XFS_IFEXTENTS)); 325 (ip->i_df.if_flags & XFS_IFEXTENTS));
326 ASSERT(offset <= mp->m_maxioffset); 326 ASSERT(offset <= mp->m_super->s_maxbytes);
327 327
328 if (offset + count > mp->m_maxioffset) 328 if (offset + count > mp->m_super->s_maxbytes)
329 count = mp->m_maxioffset - offset; 329 count = mp->m_super->s_maxbytes - offset;
330 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count); 330 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count);
331 offset_fsb = XFS_B_TO_FSBT(mp, offset); 331 offset_fsb = XFS_B_TO_FSBT(mp, offset);
332 error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, 332 error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb,
@@ -336,7 +336,7 @@ xfs_map_blocks(
336 if (error) 336 if (error)
337 return -XFS_ERROR(error); 337 return -XFS_ERROR(error);
338 338
339 if (type == IO_DELALLOC && 339 if (type == XFS_IO_DELALLOC &&
340 (!nimaps || isnullstartblock(imap->br_startblock))) { 340 (!nimaps || isnullstartblock(imap->br_startblock))) {
341 error = xfs_iomap_write_allocate(ip, offset, count, imap); 341 error = xfs_iomap_write_allocate(ip, offset, count, imap);
342 if (!error) 342 if (!error)
@@ -345,7 +345,7 @@ xfs_map_blocks(
345 } 345 }
346 346
347#ifdef DEBUG 347#ifdef DEBUG
348 if (type == IO_UNWRITTEN) { 348 if (type == XFS_IO_UNWRITTEN) {
349 ASSERT(nimaps); 349 ASSERT(nimaps);
350 ASSERT(imap->br_startblock != HOLESTARTBLOCK); 350 ASSERT(imap->br_startblock != HOLESTARTBLOCK);
351 ASSERT(imap->br_startblock != DELAYSTARTBLOCK); 351 ASSERT(imap->br_startblock != DELAYSTARTBLOCK);
@@ -634,11 +634,11 @@ xfs_check_page_type(
634 bh = head = page_buffers(page); 634 bh = head = page_buffers(page);
635 do { 635 do {
636 if (buffer_unwritten(bh)) 636 if (buffer_unwritten(bh))
637 acceptable += (type == IO_UNWRITTEN); 637 acceptable += (type == XFS_IO_UNWRITTEN);
638 else if (buffer_delay(bh)) 638 else if (buffer_delay(bh))
639 acceptable += (type == IO_DELALLOC); 639 acceptable += (type == XFS_IO_DELALLOC);
640 else if (buffer_dirty(bh) && buffer_mapped(bh)) 640 else if (buffer_dirty(bh) && buffer_mapped(bh))
641 acceptable += (type == IO_OVERWRITE); 641 acceptable += (type == XFS_IO_OVERWRITE);
642 else 642 else
643 break; 643 break;
644 } while ((bh = bh->b_this_page) != head); 644 } while ((bh = bh->b_this_page) != head);
@@ -721,11 +721,11 @@ xfs_convert_page(
721 if (buffer_unwritten(bh) || buffer_delay(bh) || 721 if (buffer_unwritten(bh) || buffer_delay(bh) ||
722 buffer_mapped(bh)) { 722 buffer_mapped(bh)) {
723 if (buffer_unwritten(bh)) 723 if (buffer_unwritten(bh))
724 type = IO_UNWRITTEN; 724 type = XFS_IO_UNWRITTEN;
725 else if (buffer_delay(bh)) 725 else if (buffer_delay(bh))
726 type = IO_DELALLOC; 726 type = XFS_IO_DELALLOC;
727 else 727 else
728 type = IO_OVERWRITE; 728 type = XFS_IO_OVERWRITE;
729 729
730 if (!xfs_imap_valid(inode, imap, offset)) { 730 if (!xfs_imap_valid(inode, imap, offset)) {
731 done = 1; 731 done = 1;
@@ -733,7 +733,7 @@ xfs_convert_page(
733 } 733 }
734 734
735 lock_buffer(bh); 735 lock_buffer(bh);
736 if (type != IO_OVERWRITE) 736 if (type != XFS_IO_OVERWRITE)
737 xfs_map_at_offset(inode, bh, imap, offset); 737 xfs_map_at_offset(inode, bh, imap, offset);
738 xfs_add_to_ioend(inode, bh, offset, type, 738 xfs_add_to_ioend(inode, bh, offset, type,
739 ioendp, done); 739 ioendp, done);
@@ -831,7 +831,7 @@ xfs_aops_discard_page(
831 struct buffer_head *bh, *head; 831 struct buffer_head *bh, *head;
832 loff_t offset = page_offset(page); 832 loff_t offset = page_offset(page);
833 833
834 if (!xfs_check_page_type(page, IO_DELALLOC)) 834 if (!xfs_check_page_type(page, XFS_IO_DELALLOC))
835 goto out_invalidate; 835 goto out_invalidate;
836 836
837 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) 837 if (XFS_FORCED_SHUTDOWN(ip->i_mount))
@@ -927,11 +927,26 @@ xfs_vm_writepage(
927 end_index = offset >> PAGE_CACHE_SHIFT; 927 end_index = offset >> PAGE_CACHE_SHIFT;
928 last_index = (offset - 1) >> PAGE_CACHE_SHIFT; 928 last_index = (offset - 1) >> PAGE_CACHE_SHIFT;
929 if (page->index >= end_index) { 929 if (page->index >= end_index) {
930 if ((page->index >= end_index + 1) || 930 unsigned offset_into_page = offset & (PAGE_CACHE_SIZE - 1);
931 !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) { 931
932 /*
933 * Just skip the page if it is fully outside i_size, e.g. due
934 * to a truncate operation that is in progress.
935 */
936 if (page->index >= end_index + 1 || offset_into_page == 0) {
932 unlock_page(page); 937 unlock_page(page);
933 return 0; 938 return 0;
934 } 939 }
940
941 /*
942 * The page straddles i_size. It must be zeroed out on each
943 * and every writepage invocation because it may be mmapped.
944 * "A file is mapped in multiples of the page size. For a file
945 * that is not a multiple of the page size, the remaining
946 * memory is zeroed when mapped, and writes to that region are
947 * not written out to the file."
948 */
949 zero_user_segment(page, offset_into_page, PAGE_CACHE_SIZE);
935 } 950 }
936 951
937 end_offset = min_t(unsigned long long, 952 end_offset = min_t(unsigned long long,
@@ -941,7 +956,7 @@ xfs_vm_writepage(
941 956
942 bh = head = page_buffers(page); 957 bh = head = page_buffers(page);
943 offset = page_offset(page); 958 offset = page_offset(page);
944 type = IO_OVERWRITE; 959 type = XFS_IO_OVERWRITE;
945 960
946 if (wbc->sync_mode == WB_SYNC_NONE) 961 if (wbc->sync_mode == WB_SYNC_NONE)
947 nonblocking = 1; 962 nonblocking = 1;
@@ -966,18 +981,18 @@ xfs_vm_writepage(
966 } 981 }
967 982
968 if (buffer_unwritten(bh)) { 983 if (buffer_unwritten(bh)) {
969 if (type != IO_UNWRITTEN) { 984 if (type != XFS_IO_UNWRITTEN) {
970 type = IO_UNWRITTEN; 985 type = XFS_IO_UNWRITTEN;
971 imap_valid = 0; 986 imap_valid = 0;
972 } 987 }
973 } else if (buffer_delay(bh)) { 988 } else if (buffer_delay(bh)) {
974 if (type != IO_DELALLOC) { 989 if (type != XFS_IO_DELALLOC) {
975 type = IO_DELALLOC; 990 type = XFS_IO_DELALLOC;
976 imap_valid = 0; 991 imap_valid = 0;
977 } 992 }
978 } else if (buffer_uptodate(bh)) { 993 } else if (buffer_uptodate(bh)) {
979 if (type != IO_OVERWRITE) { 994 if (type != XFS_IO_OVERWRITE) {
980 type = IO_OVERWRITE; 995 type = XFS_IO_OVERWRITE;
981 imap_valid = 0; 996 imap_valid = 0;
982 } 997 }
983 } else { 998 } else {
@@ -1013,7 +1028,7 @@ xfs_vm_writepage(
1013 } 1028 }
1014 if (imap_valid) { 1029 if (imap_valid) {
1015 lock_buffer(bh); 1030 lock_buffer(bh);
1016 if (type != IO_OVERWRITE) 1031 if (type != XFS_IO_OVERWRITE)
1017 xfs_map_at_offset(inode, bh, &imap, offset); 1032 xfs_map_at_offset(inode, bh, &imap, offset);
1018 xfs_add_to_ioend(inode, bh, offset, type, &ioend, 1033 xfs_add_to_ioend(inode, bh, offset, type, &ioend,
1019 new_ioend); 1034 new_ioend);
@@ -1054,7 +1069,7 @@ xfs_vm_writepage(
1054 * Reserve log space if we might write beyond the on-disk 1069 * Reserve log space if we might write beyond the on-disk
1055 * inode size. 1070 * inode size.
1056 */ 1071 */
1057 if (ioend->io_type != IO_UNWRITTEN && 1072 if (ioend->io_type != XFS_IO_UNWRITTEN &&
1058 xfs_ioend_is_append(ioend)) { 1073 xfs_ioend_is_append(ioend)) {
1059 err = xfs_setfilesize_trans_alloc(ioend); 1074 err = xfs_setfilesize_trans_alloc(ioend);
1060 if (err) 1075 if (err)
@@ -1162,9 +1177,9 @@ __xfs_get_blocks(
1162 lockmode = xfs_ilock_map_shared(ip); 1177 lockmode = xfs_ilock_map_shared(ip);
1163 } 1178 }
1164 1179
1165 ASSERT(offset <= mp->m_maxioffset); 1180 ASSERT(offset <= mp->m_super->s_maxbytes);
1166 if (offset + size > mp->m_maxioffset) 1181 if (offset + size > mp->m_super->s_maxbytes)
1167 size = mp->m_maxioffset - offset; 1182 size = mp->m_super->s_maxbytes - offset;
1168 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + size); 1183 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + size);
1169 offset_fsb = XFS_B_TO_FSBT(mp, offset); 1184 offset_fsb = XFS_B_TO_FSBT(mp, offset);
1170 1185
@@ -1351,7 +1366,7 @@ xfs_end_io_direct_write(
1351 ioend->io_iocb = iocb; 1366 ioend->io_iocb = iocb;
1352 ioend->io_result = ret; 1367 ioend->io_result = ret;
1353 if (private && size > 0) 1368 if (private && size > 0)
1354 ioend->io_type = IO_UNWRITTEN; 1369 ioend->io_type = XFS_IO_UNWRITTEN;
1355 1370
1356 if (is_async) { 1371 if (is_async) {
1357 ioend->io_isasync = 1; 1372 ioend->io_isasync = 1;
@@ -1383,7 +1398,7 @@ xfs_vm_direct_IO(
1383 * and converts at least on unwritten extent we will cancel 1398 * and converts at least on unwritten extent we will cancel
1384 * the still clean transaction after the I/O has finished. 1399 * the still clean transaction after the I/O has finished.
1385 */ 1400 */
1386 iocb->private = ioend = xfs_alloc_ioend(inode, IO_DIRECT); 1401 iocb->private = ioend = xfs_alloc_ioend(inode, XFS_IO_DIRECT);
1387 if (offset + size > XFS_I(inode)->i_d.di_size) { 1402 if (offset + size > XFS_I(inode)->i_d.di_size) {
1388 ret = xfs_setfilesize_trans_alloc(ioend); 1403 ret = xfs_setfilesize_trans_alloc(ioend);
1389 if (ret) 1404 if (ret)
diff --git a/fs/xfs/xfs_aops.h b/fs/xfs/xfs_aops.h
index 84eafbcb0d9d..c325abb8d61a 100644
--- a/fs/xfs/xfs_aops.h
+++ b/fs/xfs/xfs_aops.h
@@ -24,17 +24,17 @@ extern mempool_t *xfs_ioend_pool;
24 * Types of I/O for bmap clustering and I/O completion tracking. 24 * Types of I/O for bmap clustering and I/O completion tracking.
25 */ 25 */
26enum { 26enum {
27 IO_DIRECT = 0, /* special case for direct I/O ioends */ 27 XFS_IO_DIRECT = 0, /* special case for direct I/O ioends */
28 IO_DELALLOC, /* mapping covers delalloc region */ 28 XFS_IO_DELALLOC, /* covers delalloc region */
29 IO_UNWRITTEN, /* mapping covers allocated but uninitialized data */ 29 XFS_IO_UNWRITTEN, /* covers allocated but uninitialized data */
30 IO_OVERWRITE, /* mapping covers already allocated extent */ 30 XFS_IO_OVERWRITE, /* covers already allocated extent */
31}; 31};
32 32
33#define XFS_IO_TYPES \ 33#define XFS_IO_TYPES \
34 { 0, "" }, \ 34 { 0, "" }, \
35 { IO_DELALLOC, "delalloc" }, \ 35 { XFS_IO_DELALLOC, "delalloc" }, \
36 { IO_UNWRITTEN, "unwritten" }, \ 36 { XFS_IO_UNWRITTEN, "unwritten" }, \
37 { IO_OVERWRITE, "overwrite" } 37 { XFS_IO_OVERWRITE, "overwrite" }
38 38
39/* 39/*
40 * xfs_ioend struct manages large extent writes for XFS. 40 * xfs_ioend struct manages large extent writes for XFS.
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index a17ff01b5adf..0ca1f0be62d2 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -893,7 +893,7 @@ STATIC int
893xfs_attr_leaf_addname(xfs_da_args_t *args) 893xfs_attr_leaf_addname(xfs_da_args_t *args)
894{ 894{
895 xfs_inode_t *dp; 895 xfs_inode_t *dp;
896 xfs_dabuf_t *bp; 896 struct xfs_buf *bp;
897 int retval, error, committed, forkoff; 897 int retval, error, committed, forkoff;
898 898
899 trace_xfs_attr_leaf_addname(args); 899 trace_xfs_attr_leaf_addname(args);
@@ -915,11 +915,11 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
915 */ 915 */
916 retval = xfs_attr_leaf_lookup_int(bp, args); 916 retval = xfs_attr_leaf_lookup_int(bp, args);
917 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { 917 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
918 xfs_da_brelse(args->trans, bp); 918 xfs_trans_brelse(args->trans, bp);
919 return(retval); 919 return(retval);
920 } else if (retval == EEXIST) { 920 } else if (retval == EEXIST) {
921 if (args->flags & ATTR_CREATE) { /* pure create op */ 921 if (args->flags & ATTR_CREATE) { /* pure create op */
922 xfs_da_brelse(args->trans, bp); 922 xfs_trans_brelse(args->trans, bp);
923 return(retval); 923 return(retval);
924 } 924 }
925 925
@@ -937,7 +937,6 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
937 * if required. 937 * if required.
938 */ 938 */
939 retval = xfs_attr_leaf_add(bp, args); 939 retval = xfs_attr_leaf_add(bp, args);
940 xfs_da_buf_done(bp);
941 if (retval == ENOSPC) { 940 if (retval == ENOSPC) {
942 /* 941 /*
943 * Promote the attribute list to the Btree format, then 942 * Promote the attribute list to the Btree format, then
@@ -1065,8 +1064,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
1065 */ 1064 */
1066 if (committed) 1065 if (committed)
1067 xfs_trans_ijoin(args->trans, dp, 0); 1066 xfs_trans_ijoin(args->trans, dp, 0);
1068 } else 1067 }
1069 xfs_da_buf_done(bp);
1070 1068
1071 /* 1069 /*
1072 * Commit the remove and start the next trans in series. 1070 * Commit the remove and start the next trans in series.
@@ -1092,7 +1090,7 @@ STATIC int
1092xfs_attr_leaf_removename(xfs_da_args_t *args) 1090xfs_attr_leaf_removename(xfs_da_args_t *args)
1093{ 1091{
1094 xfs_inode_t *dp; 1092 xfs_inode_t *dp;
1095 xfs_dabuf_t *bp; 1093 struct xfs_buf *bp;
1096 int error, committed, forkoff; 1094 int error, committed, forkoff;
1097 1095
1098 trace_xfs_attr_leaf_removename(args); 1096 trace_xfs_attr_leaf_removename(args);
@@ -1111,7 +1109,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
1111 ASSERT(bp != NULL); 1109 ASSERT(bp != NULL);
1112 error = xfs_attr_leaf_lookup_int(bp, args); 1110 error = xfs_attr_leaf_lookup_int(bp, args);
1113 if (error == ENOATTR) { 1111 if (error == ENOATTR) {
1114 xfs_da_brelse(args->trans, bp); 1112 xfs_trans_brelse(args->trans, bp);
1115 return(error); 1113 return(error);
1116 } 1114 }
1117 1115
@@ -1141,8 +1139,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
1141 */ 1139 */
1142 if (committed) 1140 if (committed)
1143 xfs_trans_ijoin(args->trans, dp, 0); 1141 xfs_trans_ijoin(args->trans, dp, 0);
1144 } else 1142 }
1145 xfs_da_buf_done(bp);
1146 return(0); 1143 return(0);
1147} 1144}
1148 1145
@@ -1155,7 +1152,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
1155STATIC int 1152STATIC int
1156xfs_attr_leaf_get(xfs_da_args_t *args) 1153xfs_attr_leaf_get(xfs_da_args_t *args)
1157{ 1154{
1158 xfs_dabuf_t *bp; 1155 struct xfs_buf *bp;
1159 int error; 1156 int error;
1160 1157
1161 args->blkno = 0; 1158 args->blkno = 0;
@@ -1167,11 +1164,11 @@ xfs_attr_leaf_get(xfs_da_args_t *args)
1167 1164
1168 error = xfs_attr_leaf_lookup_int(bp, args); 1165 error = xfs_attr_leaf_lookup_int(bp, args);
1169 if (error != EEXIST) { 1166 if (error != EEXIST) {
1170 xfs_da_brelse(args->trans, bp); 1167 xfs_trans_brelse(args->trans, bp);
1171 return(error); 1168 return(error);
1172 } 1169 }
1173 error = xfs_attr_leaf_getvalue(bp, args); 1170 error = xfs_attr_leaf_getvalue(bp, args);
1174 xfs_da_brelse(args->trans, bp); 1171 xfs_trans_brelse(args->trans, bp);
1175 if (!error && (args->rmtblkno > 0) && !(args->flags & ATTR_KERNOVAL)) { 1172 if (!error && (args->rmtblkno > 0) && !(args->flags & ATTR_KERNOVAL)) {
1176 error = xfs_attr_rmtval_get(args); 1173 error = xfs_attr_rmtval_get(args);
1177 } 1174 }
@@ -1186,23 +1183,23 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
1186{ 1183{
1187 xfs_attr_leafblock_t *leaf; 1184 xfs_attr_leafblock_t *leaf;
1188 int error; 1185 int error;
1189 xfs_dabuf_t *bp; 1186 struct xfs_buf *bp;
1190 1187
1191 context->cursor->blkno = 0; 1188 context->cursor->blkno = 0;
1192 error = xfs_da_read_buf(NULL, context->dp, 0, -1, &bp, XFS_ATTR_FORK); 1189 error = xfs_da_read_buf(NULL, context->dp, 0, -1, &bp, XFS_ATTR_FORK);
1193 if (error) 1190 if (error)
1194 return XFS_ERROR(error); 1191 return XFS_ERROR(error);
1195 ASSERT(bp != NULL); 1192 ASSERT(bp != NULL);
1196 leaf = bp->data; 1193 leaf = bp->b_addr;
1197 if (unlikely(leaf->hdr.info.magic != cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) { 1194 if (unlikely(leaf->hdr.info.magic != cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) {
1198 XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW, 1195 XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW,
1199 context->dp->i_mount, leaf); 1196 context->dp->i_mount, leaf);
1200 xfs_da_brelse(NULL, bp); 1197 xfs_trans_brelse(NULL, bp);
1201 return XFS_ERROR(EFSCORRUPTED); 1198 return XFS_ERROR(EFSCORRUPTED);
1202 } 1199 }
1203 1200
1204 error = xfs_attr_leaf_list_int(bp, context); 1201 error = xfs_attr_leaf_list_int(bp, context);
1205 xfs_da_brelse(NULL, bp); 1202 xfs_trans_brelse(NULL, bp);
1206 return XFS_ERROR(error); 1203 return XFS_ERROR(error);
1207} 1204}
1208 1205
@@ -1489,7 +1486,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1489 xfs_da_state_t *state; 1486 xfs_da_state_t *state;
1490 xfs_da_state_blk_t *blk; 1487 xfs_da_state_blk_t *blk;
1491 xfs_inode_t *dp; 1488 xfs_inode_t *dp;
1492 xfs_dabuf_t *bp; 1489 struct xfs_buf *bp;
1493 int retval, error, committed, forkoff; 1490 int retval, error, committed, forkoff;
1494 1491
1495 trace_xfs_attr_node_removename(args); 1492 trace_xfs_attr_node_removename(args);
@@ -1601,14 +1598,13 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1601 */ 1598 */
1602 ASSERT(state->path.active == 1); 1599 ASSERT(state->path.active == 1);
1603 ASSERT(state->path.blk[0].bp); 1600 ASSERT(state->path.blk[0].bp);
1604 xfs_da_buf_done(state->path.blk[0].bp);
1605 state->path.blk[0].bp = NULL; 1601 state->path.blk[0].bp = NULL;
1606 1602
1607 error = xfs_da_read_buf(args->trans, args->dp, 0, -1, &bp, 1603 error = xfs_da_read_buf(args->trans, args->dp, 0, -1, &bp,
1608 XFS_ATTR_FORK); 1604 XFS_ATTR_FORK);
1609 if (error) 1605 if (error)
1610 goto out; 1606 goto out;
1611 ASSERT((((xfs_attr_leafblock_t *)bp->data)->hdr.info.magic) == 1607 ASSERT((((xfs_attr_leafblock_t *)bp->b_addr)->hdr.info.magic) ==
1612 cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1608 cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1613 1609
1614 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { 1610 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
@@ -1635,7 +1631,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1635 if (committed) 1631 if (committed)
1636 xfs_trans_ijoin(args->trans, dp, 0); 1632 xfs_trans_ijoin(args->trans, dp, 0);
1637 } else 1633 } else
1638 xfs_da_brelse(args->trans, bp); 1634 xfs_trans_brelse(args->trans, bp);
1639 } 1635 }
1640 error = 0; 1636 error = 0;
1641 1637
@@ -1665,8 +1661,7 @@ xfs_attr_fillstate(xfs_da_state_t *state)
1665 ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH)); 1661 ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
1666 for (blk = path->blk, level = 0; level < path->active; blk++, level++) { 1662 for (blk = path->blk, level = 0; level < path->active; blk++, level++) {
1667 if (blk->bp) { 1663 if (blk->bp) {
1668 blk->disk_blkno = xfs_da_blkno(blk->bp); 1664 blk->disk_blkno = XFS_BUF_ADDR(blk->bp);
1669 xfs_da_buf_done(blk->bp);
1670 blk->bp = NULL; 1665 blk->bp = NULL;
1671 } else { 1666 } else {
1672 blk->disk_blkno = 0; 1667 blk->disk_blkno = 0;
@@ -1681,8 +1676,7 @@ xfs_attr_fillstate(xfs_da_state_t *state)
1681 ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH)); 1676 ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
1682 for (blk = path->blk, level = 0; level < path->active; blk++, level++) { 1677 for (blk = path->blk, level = 0; level < path->active; blk++, level++) {
1683 if (blk->bp) { 1678 if (blk->bp) {
1684 blk->disk_blkno = xfs_da_blkno(blk->bp); 1679 blk->disk_blkno = XFS_BUF_ADDR(blk->bp);
1685 xfs_da_buf_done(blk->bp);
1686 blk->bp = NULL; 1680 blk->bp = NULL;
1687 } else { 1681 } else {
1688 blk->disk_blkno = 0; 1682 blk->disk_blkno = 0;
@@ -1792,7 +1786,7 @@ xfs_attr_node_get(xfs_da_args_t *args)
1792 * If not in a transaction, we have to release all the buffers. 1786 * If not in a transaction, we have to release all the buffers.
1793 */ 1787 */
1794 for (i = 0; i < state->path.active; i++) { 1788 for (i = 0; i < state->path.active; i++) {
1795 xfs_da_brelse(args->trans, state->path.blk[i].bp); 1789 xfs_trans_brelse(args->trans, state->path.blk[i].bp);
1796 state->path.blk[i].bp = NULL; 1790 state->path.blk[i].bp = NULL;
1797 } 1791 }
1798 1792
@@ -1808,7 +1802,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1808 xfs_da_intnode_t *node; 1802 xfs_da_intnode_t *node;
1809 xfs_da_node_entry_t *btree; 1803 xfs_da_node_entry_t *btree;
1810 int error, i; 1804 int error, i;
1811 xfs_dabuf_t *bp; 1805 struct xfs_buf *bp;
1812 1806
1813 cursor = context->cursor; 1807 cursor = context->cursor;
1814 cursor->initted = 1; 1808 cursor->initted = 1;
@@ -1825,30 +1819,30 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1825 if ((error != 0) && (error != EFSCORRUPTED)) 1819 if ((error != 0) && (error != EFSCORRUPTED))
1826 return(error); 1820 return(error);
1827 if (bp) { 1821 if (bp) {
1828 node = bp->data; 1822 node = bp->b_addr;
1829 switch (be16_to_cpu(node->hdr.info.magic)) { 1823 switch (be16_to_cpu(node->hdr.info.magic)) {
1830 case XFS_DA_NODE_MAGIC: 1824 case XFS_DA_NODE_MAGIC:
1831 trace_xfs_attr_list_wrong_blk(context); 1825 trace_xfs_attr_list_wrong_blk(context);
1832 xfs_da_brelse(NULL, bp); 1826 xfs_trans_brelse(NULL, bp);
1833 bp = NULL; 1827 bp = NULL;
1834 break; 1828 break;
1835 case XFS_ATTR_LEAF_MAGIC: 1829 case XFS_ATTR_LEAF_MAGIC:
1836 leaf = bp->data; 1830 leaf = bp->b_addr;
1837 if (cursor->hashval > be32_to_cpu(leaf->entries[ 1831 if (cursor->hashval > be32_to_cpu(leaf->entries[
1838 be16_to_cpu(leaf->hdr.count)-1].hashval)) { 1832 be16_to_cpu(leaf->hdr.count)-1].hashval)) {
1839 trace_xfs_attr_list_wrong_blk(context); 1833 trace_xfs_attr_list_wrong_blk(context);
1840 xfs_da_brelse(NULL, bp); 1834 xfs_trans_brelse(NULL, bp);
1841 bp = NULL; 1835 bp = NULL;
1842 } else if (cursor->hashval <= 1836 } else if (cursor->hashval <=
1843 be32_to_cpu(leaf->entries[0].hashval)) { 1837 be32_to_cpu(leaf->entries[0].hashval)) {
1844 trace_xfs_attr_list_wrong_blk(context); 1838 trace_xfs_attr_list_wrong_blk(context);
1845 xfs_da_brelse(NULL, bp); 1839 xfs_trans_brelse(NULL, bp);
1846 bp = NULL; 1840 bp = NULL;
1847 } 1841 }
1848 break; 1842 break;
1849 default: 1843 default:
1850 trace_xfs_attr_list_wrong_blk(context); 1844 trace_xfs_attr_list_wrong_blk(context);
1851 xfs_da_brelse(NULL, bp); 1845 xfs_trans_brelse(NULL, bp);
1852 bp = NULL; 1846 bp = NULL;
1853 } 1847 }
1854 } 1848 }
@@ -1873,7 +1867,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1873 context->dp->i_mount); 1867 context->dp->i_mount);
1874 return(XFS_ERROR(EFSCORRUPTED)); 1868 return(XFS_ERROR(EFSCORRUPTED));
1875 } 1869 }
1876 node = bp->data; 1870 node = bp->b_addr;
1877 if (node->hdr.info.magic == 1871 if (node->hdr.info.magic ==
1878 cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) 1872 cpu_to_be16(XFS_ATTR_LEAF_MAGIC))
1879 break; 1873 break;
@@ -1883,7 +1877,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1883 XFS_ERRLEVEL_LOW, 1877 XFS_ERRLEVEL_LOW,
1884 context->dp->i_mount, 1878 context->dp->i_mount,
1885 node); 1879 node);
1886 xfs_da_brelse(NULL, bp); 1880 xfs_trans_brelse(NULL, bp);
1887 return(XFS_ERROR(EFSCORRUPTED)); 1881 return(XFS_ERROR(EFSCORRUPTED));
1888 } 1882 }
1889 btree = node->btree; 1883 btree = node->btree;
@@ -1898,10 +1892,10 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1898 } 1892 }
1899 } 1893 }
1900 if (i == be16_to_cpu(node->hdr.count)) { 1894 if (i == be16_to_cpu(node->hdr.count)) {
1901 xfs_da_brelse(NULL, bp); 1895 xfs_trans_brelse(NULL, bp);
1902 return(0); 1896 return(0);
1903 } 1897 }
1904 xfs_da_brelse(NULL, bp); 1898 xfs_trans_brelse(NULL, bp);
1905 } 1899 }
1906 } 1900 }
1907 ASSERT(bp != NULL); 1901 ASSERT(bp != NULL);
@@ -1912,24 +1906,24 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1912 * adding the information. 1906 * adding the information.
1913 */ 1907 */
1914 for (;;) { 1908 for (;;) {
1915 leaf = bp->data; 1909 leaf = bp->b_addr;
1916 if (unlikely(leaf->hdr.info.magic != 1910 if (unlikely(leaf->hdr.info.magic !=
1917 cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) { 1911 cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) {
1918 XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)", 1912 XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)",
1919 XFS_ERRLEVEL_LOW, 1913 XFS_ERRLEVEL_LOW,
1920 context->dp->i_mount, leaf); 1914 context->dp->i_mount, leaf);
1921 xfs_da_brelse(NULL, bp); 1915 xfs_trans_brelse(NULL, bp);
1922 return(XFS_ERROR(EFSCORRUPTED)); 1916 return(XFS_ERROR(EFSCORRUPTED));
1923 } 1917 }
1924 error = xfs_attr_leaf_list_int(bp, context); 1918 error = xfs_attr_leaf_list_int(bp, context);
1925 if (error) { 1919 if (error) {
1926 xfs_da_brelse(NULL, bp); 1920 xfs_trans_brelse(NULL, bp);
1927 return error; 1921 return error;
1928 } 1922 }
1929 if (context->seen_enough || leaf->hdr.info.forw == 0) 1923 if (context->seen_enough || leaf->hdr.info.forw == 0)
1930 break; 1924 break;
1931 cursor->blkno = be32_to_cpu(leaf->hdr.info.forw); 1925 cursor->blkno = be32_to_cpu(leaf->hdr.info.forw);
1932 xfs_da_brelse(NULL, bp); 1926 xfs_trans_brelse(NULL, bp);
1933 error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1, 1927 error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
1934 &bp, XFS_ATTR_FORK); 1928 &bp, XFS_ATTR_FORK);
1935 if (error) 1929 if (error)
@@ -1941,7 +1935,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1941 return(XFS_ERROR(EFSCORRUPTED)); 1935 return(XFS_ERROR(EFSCORRUPTED));
1942 } 1936 }
1943 } 1937 }
1944 xfs_da_brelse(NULL, bp); 1938 xfs_trans_brelse(NULL, bp);
1945 return(0); 1939 return(0);
1946} 1940}
1947 1941
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 7d89d800f517..d330111ca738 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -54,10 +54,10 @@
54 * Routines used for growing the Btree. 54 * Routines used for growing the Btree.
55 */ 55 */
56STATIC int xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t which_block, 56STATIC int xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t which_block,
57 xfs_dabuf_t **bpp); 57 struct xfs_buf **bpp);
58STATIC int xfs_attr_leaf_add_work(xfs_dabuf_t *leaf_buffer, xfs_da_args_t *args, 58STATIC int xfs_attr_leaf_add_work(struct xfs_buf *leaf_buffer,
59 int freemap_index); 59 xfs_da_args_t *args, int freemap_index);
60STATIC void xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *leaf_buffer); 60STATIC void xfs_attr_leaf_compact(xfs_trans_t *tp, struct xfs_buf *leaf_buffer);
61STATIC void xfs_attr_leaf_rebalance(xfs_da_state_t *state, 61STATIC void xfs_attr_leaf_rebalance(xfs_da_state_t *state,
62 xfs_da_state_blk_t *blk1, 62 xfs_da_state_blk_t *blk1,
63 xfs_da_state_blk_t *blk2); 63 xfs_da_state_blk_t *blk2);
@@ -71,9 +71,9 @@ STATIC int xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
71 * Routines used for shrinking the Btree. 71 * Routines used for shrinking the Btree.
72 */ 72 */
73STATIC int xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, 73STATIC int xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp,
74 xfs_dabuf_t *bp, int level); 74 struct xfs_buf *bp, int level);
75STATIC int xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, 75STATIC int xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp,
76 xfs_dabuf_t *bp); 76 struct xfs_buf *bp);
77STATIC int xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp, 77STATIC int xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp,
78 xfs_dablk_t blkno, int blkcnt); 78 xfs_dablk_t blkno, int blkcnt);
79 79
@@ -480,7 +480,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
480 char *tmpbuffer; 480 char *tmpbuffer;
481 int error, i, size; 481 int error, i, size;
482 xfs_dablk_t blkno; 482 xfs_dablk_t blkno;
483 xfs_dabuf_t *bp; 483 struct xfs_buf *bp;
484 xfs_ifork_t *ifp; 484 xfs_ifork_t *ifp;
485 485
486 trace_xfs_attr_sf_to_leaf(args); 486 trace_xfs_attr_sf_to_leaf(args);
@@ -550,8 +550,6 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
550 error = 0; 550 error = 0;
551 551
552out: 552out:
553 if(bp)
554 xfs_da_buf_done(bp);
555 kmem_free(tmpbuffer); 553 kmem_free(tmpbuffer);
556 return(error); 554 return(error);
557} 555}
@@ -737,14 +735,16 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
737 * a shortform attribute list. 735 * a shortform attribute list.
738 */ 736 */
739int 737int
740xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp) 738xfs_attr_shortform_allfit(
739 struct xfs_buf *bp,
740 struct xfs_inode *dp)
741{ 741{
742 xfs_attr_leafblock_t *leaf; 742 xfs_attr_leafblock_t *leaf;
743 xfs_attr_leaf_entry_t *entry; 743 xfs_attr_leaf_entry_t *entry;
744 xfs_attr_leaf_name_local_t *name_loc; 744 xfs_attr_leaf_name_local_t *name_loc;
745 int bytes, i; 745 int bytes, i;
746 746
747 leaf = bp->data; 747 leaf = bp->b_addr;
748 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 748 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
749 749
750 entry = &leaf->entries[0]; 750 entry = &leaf->entries[0];
@@ -774,7 +774,10 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
774 * Convert a leaf attribute list to shortform attribute list 774 * Convert a leaf attribute list to shortform attribute list
775 */ 775 */
776int 776int
777xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) 777xfs_attr_leaf_to_shortform(
778 struct xfs_buf *bp,
779 xfs_da_args_t *args,
780 int forkoff)
778{ 781{
779 xfs_attr_leafblock_t *leaf; 782 xfs_attr_leafblock_t *leaf;
780 xfs_attr_leaf_entry_t *entry; 783 xfs_attr_leaf_entry_t *entry;
@@ -791,10 +794,10 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
791 ASSERT(tmpbuffer != NULL); 794 ASSERT(tmpbuffer != NULL);
792 795
793 ASSERT(bp != NULL); 796 ASSERT(bp != NULL);
794 memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); 797 memcpy(tmpbuffer, bp->b_addr, XFS_LBSIZE(dp->i_mount));
795 leaf = (xfs_attr_leafblock_t *)tmpbuffer; 798 leaf = (xfs_attr_leafblock_t *)tmpbuffer;
796 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 799 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
797 memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); 800 memset(bp->b_addr, 0, XFS_LBSIZE(dp->i_mount));
798 801
799 /* 802 /*
800 * Clean out the prior contents of the attribute list. 803 * Clean out the prior contents of the attribute list.
@@ -855,7 +858,7 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
855 xfs_attr_leafblock_t *leaf; 858 xfs_attr_leafblock_t *leaf;
856 xfs_da_intnode_t *node; 859 xfs_da_intnode_t *node;
857 xfs_inode_t *dp; 860 xfs_inode_t *dp;
858 xfs_dabuf_t *bp1, *bp2; 861 struct xfs_buf *bp1, *bp2;
859 xfs_dablk_t blkno; 862 xfs_dablk_t blkno;
860 int error; 863 int error;
861 864
@@ -877,10 +880,9 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
877 if (error) 880 if (error)
878 goto out; 881 goto out;
879 ASSERT(bp2 != NULL); 882 ASSERT(bp2 != NULL);
880 memcpy(bp2->data, bp1->data, XFS_LBSIZE(dp->i_mount)); 883 memcpy(bp2->b_addr, bp1->b_addr, XFS_LBSIZE(dp->i_mount));
881 xfs_da_buf_done(bp1);
882 bp1 = NULL; 884 bp1 = NULL;
883 xfs_da_log_buf(args->trans, bp2, 0, XFS_LBSIZE(dp->i_mount) - 1); 885 xfs_trans_log_buf(args->trans, bp2, 0, XFS_LBSIZE(dp->i_mount) - 1);
884 886
885 /* 887 /*
886 * Set up the new root node. 888 * Set up the new root node.
@@ -888,21 +890,17 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
888 error = xfs_da_node_create(args, 0, 1, &bp1, XFS_ATTR_FORK); 890 error = xfs_da_node_create(args, 0, 1, &bp1, XFS_ATTR_FORK);
889 if (error) 891 if (error)
890 goto out; 892 goto out;
891 node = bp1->data; 893 node = bp1->b_addr;
892 leaf = bp2->data; 894 leaf = bp2->b_addr;
893 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 895 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
894 /* both on-disk, don't endian-flip twice */ 896 /* both on-disk, don't endian-flip twice */
895 node->btree[0].hashval = 897 node->btree[0].hashval =
896 leaf->entries[be16_to_cpu(leaf->hdr.count)-1 ].hashval; 898 leaf->entries[be16_to_cpu(leaf->hdr.count)-1 ].hashval;
897 node->btree[0].before = cpu_to_be32(blkno); 899 node->btree[0].before = cpu_to_be32(blkno);
898 node->hdr.count = cpu_to_be16(1); 900 node->hdr.count = cpu_to_be16(1);
899 xfs_da_log_buf(args->trans, bp1, 0, XFS_LBSIZE(dp->i_mount) - 1); 901 xfs_trans_log_buf(args->trans, bp1, 0, XFS_LBSIZE(dp->i_mount) - 1);
900 error = 0; 902 error = 0;
901out: 903out:
902 if (bp1)
903 xfs_da_buf_done(bp1);
904 if (bp2)
905 xfs_da_buf_done(bp2);
906 return(error); 904 return(error);
907} 905}
908 906
@@ -916,12 +914,15 @@ out:
916 * or a leaf in a node attribute list. 914 * or a leaf in a node attribute list.
917 */ 915 */
918STATIC int 916STATIC int
919xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) 917xfs_attr_leaf_create(
918 xfs_da_args_t *args,
919 xfs_dablk_t blkno,
920 struct xfs_buf **bpp)
920{ 921{
921 xfs_attr_leafblock_t *leaf; 922 xfs_attr_leafblock_t *leaf;
922 xfs_attr_leaf_hdr_t *hdr; 923 xfs_attr_leaf_hdr_t *hdr;
923 xfs_inode_t *dp; 924 xfs_inode_t *dp;
924 xfs_dabuf_t *bp; 925 struct xfs_buf *bp;
925 int error; 926 int error;
926 927
927 trace_xfs_attr_leaf_create(args); 928 trace_xfs_attr_leaf_create(args);
@@ -933,7 +934,7 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
933 if (error) 934 if (error)
934 return(error); 935 return(error);
935 ASSERT(bp != NULL); 936 ASSERT(bp != NULL);
936 leaf = bp->data; 937 leaf = bp->b_addr;
937 memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); 938 memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount));
938 hdr = &leaf->hdr; 939 hdr = &leaf->hdr;
939 hdr->info.magic = cpu_to_be16(XFS_ATTR_LEAF_MAGIC); 940 hdr->info.magic = cpu_to_be16(XFS_ATTR_LEAF_MAGIC);
@@ -947,7 +948,7 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
947 hdr->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr->firstused) - 948 hdr->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr->firstused) -
948 sizeof(xfs_attr_leaf_hdr_t)); 949 sizeof(xfs_attr_leaf_hdr_t));
949 950
950 xfs_da_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1); 951 xfs_trans_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1);
951 952
952 *bpp = bp; 953 *bpp = bp;
953 return(0); 954 return(0);
@@ -1014,7 +1015,9 @@ xfs_attr_leaf_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
1014 * Add a name to the leaf attribute list structure. 1015 * Add a name to the leaf attribute list structure.
1015 */ 1016 */
1016int 1017int
1017xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) 1018xfs_attr_leaf_add(
1019 struct xfs_buf *bp,
1020 struct xfs_da_args *args)
1018{ 1021{
1019 xfs_attr_leafblock_t *leaf; 1022 xfs_attr_leafblock_t *leaf;
1020 xfs_attr_leaf_hdr_t *hdr; 1023 xfs_attr_leaf_hdr_t *hdr;
@@ -1023,7 +1026,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
1023 1026
1024 trace_xfs_attr_leaf_add(args); 1027 trace_xfs_attr_leaf_add(args);
1025 1028
1026 leaf = bp->data; 1029 leaf = bp->b_addr;
1027 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1030 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1028 ASSERT((args->index >= 0) 1031 ASSERT((args->index >= 0)
1029 && (args->index <= be16_to_cpu(leaf->hdr.count))); 1032 && (args->index <= be16_to_cpu(leaf->hdr.count)));
@@ -1085,7 +1088,10 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
1085 * Add a name to a leaf attribute list structure. 1088 * Add a name to a leaf attribute list structure.
1086 */ 1089 */
1087STATIC int 1090STATIC int
1088xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) 1091xfs_attr_leaf_add_work(
1092 struct xfs_buf *bp,
1093 xfs_da_args_t *args,
1094 int mapindex)
1089{ 1095{
1090 xfs_attr_leafblock_t *leaf; 1096 xfs_attr_leafblock_t *leaf;
1091 xfs_attr_leaf_hdr_t *hdr; 1097 xfs_attr_leaf_hdr_t *hdr;
@@ -1096,7 +1102,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1096 xfs_mount_t *mp; 1102 xfs_mount_t *mp;
1097 int tmp, i; 1103 int tmp, i;
1098 1104
1099 leaf = bp->data; 1105 leaf = bp->b_addr;
1100 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1106 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1101 hdr = &leaf->hdr; 1107 hdr = &leaf->hdr;
1102 ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE)); 1108 ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE));
@@ -1110,7 +1116,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1110 tmp = be16_to_cpu(hdr->count) - args->index; 1116 tmp = be16_to_cpu(hdr->count) - args->index;
1111 tmp *= sizeof(xfs_attr_leaf_entry_t); 1117 tmp *= sizeof(xfs_attr_leaf_entry_t);
1112 memmove((char *)(entry+1), (char *)entry, tmp); 1118 memmove((char *)(entry+1), (char *)entry, tmp);
1113 xfs_da_log_buf(args->trans, bp, 1119 xfs_trans_log_buf(args->trans, bp,
1114 XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); 1120 XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry)));
1115 } 1121 }
1116 be16_add_cpu(&hdr->count, 1); 1122 be16_add_cpu(&hdr->count, 1);
@@ -1142,7 +1148,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1142 args->index2++; 1148 args->index2++;
1143 } 1149 }
1144 } 1150 }
1145 xfs_da_log_buf(args->trans, bp, 1151 xfs_trans_log_buf(args->trans, bp,
1146 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); 1152 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry)));
1147 ASSERT((args->index == 0) || 1153 ASSERT((args->index == 0) ||
1148 (be32_to_cpu(entry->hashval) >= be32_to_cpu((entry-1)->hashval))); 1154 (be32_to_cpu(entry->hashval) >= be32_to_cpu((entry-1)->hashval)));
@@ -1174,7 +1180,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1174 args->rmtblkno = 1; 1180 args->rmtblkno = 1;
1175 args->rmtblkcnt = XFS_B_TO_FSB(mp, args->valuelen); 1181 args->rmtblkcnt = XFS_B_TO_FSB(mp, args->valuelen);
1176 } 1182 }
1177 xfs_da_log_buf(args->trans, bp, 1183 xfs_trans_log_buf(args->trans, bp,
1178 XFS_DA_LOGRANGE(leaf, xfs_attr_leaf_name(leaf, args->index), 1184 XFS_DA_LOGRANGE(leaf, xfs_attr_leaf_name(leaf, args->index),
1179 xfs_attr_leaf_entsize(leaf, args->index))); 1185 xfs_attr_leaf_entsize(leaf, args->index)));
1180 1186
@@ -1198,7 +1204,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1198 } 1204 }
1199 } 1205 }
1200 be16_add_cpu(&hdr->usedbytes, xfs_attr_leaf_entsize(leaf, args->index)); 1206 be16_add_cpu(&hdr->usedbytes, xfs_attr_leaf_entsize(leaf, args->index));
1201 xfs_da_log_buf(args->trans, bp, 1207 xfs_trans_log_buf(args->trans, bp,
1202 XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr))); 1208 XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr)));
1203 return(0); 1209 return(0);
1204} 1210}
@@ -1207,7 +1213,9 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1207 * Garbage collect a leaf attribute list block by copying it to a new buffer. 1213 * Garbage collect a leaf attribute list block by copying it to a new buffer.
1208 */ 1214 */
1209STATIC void 1215STATIC void
1210xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp) 1216xfs_attr_leaf_compact(
1217 struct xfs_trans *trans,
1218 struct xfs_buf *bp)
1211{ 1219{
1212 xfs_attr_leafblock_t *leaf_s, *leaf_d; 1220 xfs_attr_leafblock_t *leaf_s, *leaf_d;
1213 xfs_attr_leaf_hdr_t *hdr_s, *hdr_d; 1221 xfs_attr_leaf_hdr_t *hdr_s, *hdr_d;
@@ -1217,14 +1225,14 @@ xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp)
1217 mp = trans->t_mountp; 1225 mp = trans->t_mountp;
1218 tmpbuffer = kmem_alloc(XFS_LBSIZE(mp), KM_SLEEP); 1226 tmpbuffer = kmem_alloc(XFS_LBSIZE(mp), KM_SLEEP);
1219 ASSERT(tmpbuffer != NULL); 1227 ASSERT(tmpbuffer != NULL);
1220 memcpy(tmpbuffer, bp->data, XFS_LBSIZE(mp)); 1228 memcpy(tmpbuffer, bp->b_addr, XFS_LBSIZE(mp));
1221 memset(bp->data, 0, XFS_LBSIZE(mp)); 1229 memset(bp->b_addr, 0, XFS_LBSIZE(mp));
1222 1230
1223 /* 1231 /*
1224 * Copy basic information 1232 * Copy basic information
1225 */ 1233 */
1226 leaf_s = (xfs_attr_leafblock_t *)tmpbuffer; 1234 leaf_s = (xfs_attr_leafblock_t *)tmpbuffer;
1227 leaf_d = bp->data; 1235 leaf_d = bp->b_addr;
1228 hdr_s = &leaf_s->hdr; 1236 hdr_s = &leaf_s->hdr;
1229 hdr_d = &leaf_d->hdr; 1237 hdr_d = &leaf_d->hdr;
1230 hdr_d->info = hdr_s->info; /* struct copy */ 1238 hdr_d->info = hdr_s->info; /* struct copy */
@@ -1247,7 +1255,7 @@ xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp)
1247 */ 1255 */
1248 xfs_attr_leaf_moveents(leaf_s, 0, leaf_d, 0, 1256 xfs_attr_leaf_moveents(leaf_s, 0, leaf_d, 0,
1249 be16_to_cpu(hdr_s->count), mp); 1257 be16_to_cpu(hdr_s->count), mp);
1250 xfs_da_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1); 1258 xfs_trans_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1);
1251 1259
1252 kmem_free(tmpbuffer); 1260 kmem_free(tmpbuffer);
1253} 1261}
@@ -1279,8 +1287,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1279 */ 1287 */
1280 ASSERT(blk1->magic == XFS_ATTR_LEAF_MAGIC); 1288 ASSERT(blk1->magic == XFS_ATTR_LEAF_MAGIC);
1281 ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC); 1289 ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC);
1282 leaf1 = blk1->bp->data; 1290 leaf1 = blk1->bp->b_addr;
1283 leaf2 = blk2->bp->data; 1291 leaf2 = blk2->bp->b_addr;
1284 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1292 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1285 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1293 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1286 args = state->args; 1294 args = state->args;
@@ -1298,8 +1306,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1298 tmp_blk = blk1; 1306 tmp_blk = blk1;
1299 blk1 = blk2; 1307 blk1 = blk2;
1300 blk2 = tmp_blk; 1308 blk2 = tmp_blk;
1301 leaf1 = blk1->bp->data; 1309 leaf1 = blk1->bp->b_addr;
1302 leaf2 = blk2->bp->data; 1310 leaf2 = blk2->bp->b_addr;
1303 swap = 1; 1311 swap = 1;
1304 } 1312 }
1305 hdr1 = &leaf1->hdr; 1313 hdr1 = &leaf1->hdr;
@@ -1346,8 +1354,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1346 xfs_attr_leaf_moveents(leaf1, be16_to_cpu(hdr1->count) - count, 1354 xfs_attr_leaf_moveents(leaf1, be16_to_cpu(hdr1->count) - count,
1347 leaf2, 0, count, state->mp); 1355 leaf2, 0, count, state->mp);
1348 1356
1349 xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); 1357 xfs_trans_log_buf(args->trans, blk1->bp, 0, state->blocksize-1);
1350 xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); 1358 xfs_trans_log_buf(args->trans, blk2->bp, 0, state->blocksize-1);
1351 } else if (count > be16_to_cpu(hdr1->count)) { 1359 } else if (count > be16_to_cpu(hdr1->count)) {
1352 /* 1360 /*
1353 * I assert that since all callers pass in an empty 1361 * I assert that since all callers pass in an empty
@@ -1378,8 +1386,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1378 xfs_attr_leaf_moveents(leaf2, 0, leaf1, 1386 xfs_attr_leaf_moveents(leaf2, 0, leaf1,
1379 be16_to_cpu(hdr1->count), count, state->mp); 1387 be16_to_cpu(hdr1->count), count, state->mp);
1380 1388
1381 xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); 1389 xfs_trans_log_buf(args->trans, blk1->bp, 0, state->blocksize-1);
1382 xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); 1390 xfs_trans_log_buf(args->trans, blk2->bp, 0, state->blocksize-1);
1383 } 1391 }
1384 1392
1385 /* 1393 /*
@@ -1448,8 +1456,8 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
1448 /* 1456 /*
1449 * Set up environment. 1457 * Set up environment.
1450 */ 1458 */
1451 leaf1 = blk1->bp->data; 1459 leaf1 = blk1->bp->b_addr;
1452 leaf2 = blk2->bp->data; 1460 leaf2 = blk2->bp->b_addr;
1453 hdr1 = &leaf1->hdr; 1461 hdr1 = &leaf1->hdr;
1454 hdr2 = &leaf2->hdr; 1462 hdr2 = &leaf2->hdr;
1455 foundit = 0; 1463 foundit = 0;
@@ -1551,7 +1559,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
1551 xfs_da_blkinfo_t *info; 1559 xfs_da_blkinfo_t *info;
1552 int count, bytes, forward, error, retval, i; 1560 int count, bytes, forward, error, retval, i;
1553 xfs_dablk_t blkno; 1561 xfs_dablk_t blkno;
1554 xfs_dabuf_t *bp; 1562 struct xfs_buf *bp;
1555 1563
1556 /* 1564 /*
1557 * Check for the degenerate case of the block being over 50% full. 1565 * Check for the degenerate case of the block being over 50% full.
@@ -1559,7 +1567,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
1559 * to coalesce with a sibling. 1567 * to coalesce with a sibling.
1560 */ 1568 */
1561 blk = &state->path.blk[ state->path.active-1 ]; 1569 blk = &state->path.blk[ state->path.active-1 ];
1562 info = blk->bp->data; 1570 info = blk->bp->b_addr;
1563 ASSERT(info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1571 ASSERT(info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1564 leaf = (xfs_attr_leafblock_t *)info; 1572 leaf = (xfs_attr_leafblock_t *)info;
1565 count = be16_to_cpu(leaf->hdr.count); 1573 count = be16_to_cpu(leaf->hdr.count);
@@ -1622,13 +1630,13 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
1622 count = be16_to_cpu(leaf->hdr.count); 1630 count = be16_to_cpu(leaf->hdr.count);
1623 bytes = state->blocksize - (state->blocksize>>2); 1631 bytes = state->blocksize - (state->blocksize>>2);
1624 bytes -= be16_to_cpu(leaf->hdr.usedbytes); 1632 bytes -= be16_to_cpu(leaf->hdr.usedbytes);
1625 leaf = bp->data; 1633 leaf = bp->b_addr;
1626 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1634 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1627 count += be16_to_cpu(leaf->hdr.count); 1635 count += be16_to_cpu(leaf->hdr.count);
1628 bytes -= be16_to_cpu(leaf->hdr.usedbytes); 1636 bytes -= be16_to_cpu(leaf->hdr.usedbytes);
1629 bytes -= count * sizeof(xfs_attr_leaf_entry_t); 1637 bytes -= count * sizeof(xfs_attr_leaf_entry_t);
1630 bytes -= sizeof(xfs_attr_leaf_hdr_t); 1638 bytes -= sizeof(xfs_attr_leaf_hdr_t);
1631 xfs_da_brelse(state->args->trans, bp); 1639 xfs_trans_brelse(state->args->trans, bp);
1632 if (bytes >= 0) 1640 if (bytes >= 0)
1633 break; /* fits with at least 25% to spare */ 1641 break; /* fits with at least 25% to spare */
1634 } 1642 }
@@ -1666,7 +1674,9 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
1666 * If two leaves are 37% full, when combined they will leave 25% free. 1674 * If two leaves are 37% full, when combined they will leave 25% free.
1667 */ 1675 */
1668int 1676int
1669xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) 1677xfs_attr_leaf_remove(
1678 struct xfs_buf *bp,
1679 xfs_da_args_t *args)
1670{ 1680{
1671 xfs_attr_leafblock_t *leaf; 1681 xfs_attr_leafblock_t *leaf;
1672 xfs_attr_leaf_hdr_t *hdr; 1682 xfs_attr_leaf_hdr_t *hdr;
@@ -1676,7 +1686,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1676 int tablesize, tmp, i; 1686 int tablesize, tmp, i;
1677 xfs_mount_t *mp; 1687 xfs_mount_t *mp;
1678 1688
1679 leaf = bp->data; 1689 leaf = bp->b_addr;
1680 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1690 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1681 hdr = &leaf->hdr; 1691 hdr = &leaf->hdr;
1682 mp = args->trans->t_mountp; 1692 mp = args->trans->t_mountp;
@@ -1769,7 +1779,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1769 */ 1779 */
1770 memset(xfs_attr_leaf_name(leaf, args->index), 0, entsize); 1780 memset(xfs_attr_leaf_name(leaf, args->index), 0, entsize);
1771 be16_add_cpu(&hdr->usedbytes, -entsize); 1781 be16_add_cpu(&hdr->usedbytes, -entsize);
1772 xfs_da_log_buf(args->trans, bp, 1782 xfs_trans_log_buf(args->trans, bp,
1773 XFS_DA_LOGRANGE(leaf, xfs_attr_leaf_name(leaf, args->index), 1783 XFS_DA_LOGRANGE(leaf, xfs_attr_leaf_name(leaf, args->index),
1774 entsize)); 1784 entsize));
1775 1785
@@ -1777,7 +1787,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1777 * sizeof(xfs_attr_leaf_entry_t); 1787 * sizeof(xfs_attr_leaf_entry_t);
1778 memmove((char *)entry, (char *)(entry+1), tmp); 1788 memmove((char *)entry, (char *)(entry+1), tmp);
1779 be16_add_cpu(&hdr->count, -1); 1789 be16_add_cpu(&hdr->count, -1);
1780 xfs_da_log_buf(args->trans, bp, 1790 xfs_trans_log_buf(args->trans, bp,
1781 XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); 1791 XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry)));
1782 entry = &leaf->entries[be16_to_cpu(hdr->count)]; 1792 entry = &leaf->entries[be16_to_cpu(hdr->count)];
1783 memset((char *)entry, 0, sizeof(xfs_attr_leaf_entry_t)); 1793 memset((char *)entry, 0, sizeof(xfs_attr_leaf_entry_t));
@@ -1807,7 +1817,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1807 } else { 1817 } else {
1808 hdr->holes = 1; /* mark as needing compaction */ 1818 hdr->holes = 1; /* mark as needing compaction */
1809 } 1819 }
1810 xfs_da_log_buf(args->trans, bp, 1820 xfs_trans_log_buf(args->trans, bp,
1811 XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr))); 1821 XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr)));
1812 1822
1813 /* 1823 /*
@@ -1840,8 +1850,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1840 mp = state->mp; 1850 mp = state->mp;
1841 ASSERT(drop_blk->magic == XFS_ATTR_LEAF_MAGIC); 1851 ASSERT(drop_blk->magic == XFS_ATTR_LEAF_MAGIC);
1842 ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC); 1852 ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC);
1843 drop_leaf = drop_blk->bp->data; 1853 drop_leaf = drop_blk->bp->b_addr;
1844 save_leaf = save_blk->bp->data; 1854 save_leaf = save_blk->bp->b_addr;
1845 ASSERT(drop_leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1855 ASSERT(drop_leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1846 ASSERT(save_leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1856 ASSERT(save_leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1847 drop_hdr = &drop_leaf->hdr; 1857 drop_hdr = &drop_leaf->hdr;
@@ -1906,7 +1916,7 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1906 kmem_free(tmpbuffer); 1916 kmem_free(tmpbuffer);
1907 } 1917 }
1908 1918
1909 xfs_da_log_buf(state->args->trans, save_blk->bp, 0, 1919 xfs_trans_log_buf(state->args->trans, save_blk->bp, 0,
1910 state->blocksize - 1); 1920 state->blocksize - 1);
1911 1921
1912 /* 1922 /*
@@ -1934,7 +1944,9 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1934 * Don't change the args->value unless we find the attribute. 1944 * Don't change the args->value unless we find the attribute.
1935 */ 1945 */
1936int 1946int
1937xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) 1947xfs_attr_leaf_lookup_int(
1948 struct xfs_buf *bp,
1949 xfs_da_args_t *args)
1938{ 1950{
1939 xfs_attr_leafblock_t *leaf; 1951 xfs_attr_leafblock_t *leaf;
1940 xfs_attr_leaf_entry_t *entry; 1952 xfs_attr_leaf_entry_t *entry;
@@ -1945,7 +1957,7 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
1945 1957
1946 trace_xfs_attr_leaf_lookup(args); 1958 trace_xfs_attr_leaf_lookup(args);
1947 1959
1948 leaf = bp->data; 1960 leaf = bp->b_addr;
1949 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1961 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1950 ASSERT(be16_to_cpu(leaf->hdr.count) 1962 ASSERT(be16_to_cpu(leaf->hdr.count)
1951 < (XFS_LBSIZE(args->dp->i_mount)/8)); 1963 < (XFS_LBSIZE(args->dp->i_mount)/8));
@@ -2041,7 +2053,9 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
2041 * list structure. 2053 * list structure.
2042 */ 2054 */
2043int 2055int
2044xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args) 2056xfs_attr_leaf_getvalue(
2057 struct xfs_buf *bp,
2058 xfs_da_args_t *args)
2045{ 2059{
2046 int valuelen; 2060 int valuelen;
2047 xfs_attr_leafblock_t *leaf; 2061 xfs_attr_leafblock_t *leaf;
@@ -2049,7 +2063,7 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args)
2049 xfs_attr_leaf_name_local_t *name_loc; 2063 xfs_attr_leaf_name_local_t *name_loc;
2050 xfs_attr_leaf_name_remote_t *name_rmt; 2064 xfs_attr_leaf_name_remote_t *name_rmt;
2051 2065
2052 leaf = bp->data; 2066 leaf = bp->b_addr;
2053 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2067 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2054 ASSERT(be16_to_cpu(leaf->hdr.count) 2068 ASSERT(be16_to_cpu(leaf->hdr.count)
2055 < (XFS_LBSIZE(args->dp->i_mount)/8)); 2069 < (XFS_LBSIZE(args->dp->i_mount)/8));
@@ -2247,12 +2261,14 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
2247 * Return 0 unless leaf2 should go before leaf1. 2261 * Return 0 unless leaf2 should go before leaf1.
2248 */ 2262 */
2249int 2263int
2250xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) 2264xfs_attr_leaf_order(
2265 struct xfs_buf *leaf1_bp,
2266 struct xfs_buf *leaf2_bp)
2251{ 2267{
2252 xfs_attr_leafblock_t *leaf1, *leaf2; 2268 xfs_attr_leafblock_t *leaf1, *leaf2;
2253 2269
2254 leaf1 = leaf1_bp->data; 2270 leaf1 = leaf1_bp->b_addr;
2255 leaf2 = leaf2_bp->data; 2271 leaf2 = leaf2_bp->b_addr;
2256 ASSERT((leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) && 2272 ASSERT((leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) &&
2257 (leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC))); 2273 (leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)));
2258 if ((be16_to_cpu(leaf1->hdr.count) > 0) && 2274 if ((be16_to_cpu(leaf1->hdr.count) > 0) &&
@@ -2272,11 +2288,13 @@ xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp)
2272 * Pick up the last hashvalue from a leaf block. 2288 * Pick up the last hashvalue from a leaf block.
2273 */ 2289 */
2274xfs_dahash_t 2290xfs_dahash_t
2275xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count) 2291xfs_attr_leaf_lasthash(
2292 struct xfs_buf *bp,
2293 int *count)
2276{ 2294{
2277 xfs_attr_leafblock_t *leaf; 2295 xfs_attr_leafblock_t *leaf;
2278 2296
2279 leaf = bp->data; 2297 leaf = bp->b_addr;
2280 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2298 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2281 if (count) 2299 if (count)
2282 *count = be16_to_cpu(leaf->hdr.count); 2300 *count = be16_to_cpu(leaf->hdr.count);
@@ -2337,7 +2355,9 @@ xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, int *local)
2337 * Copy out attribute list entries for attr_list(), for leaf attribute lists. 2355 * Copy out attribute list entries for attr_list(), for leaf attribute lists.
2338 */ 2356 */
2339int 2357int
2340xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) 2358xfs_attr_leaf_list_int(
2359 struct xfs_buf *bp,
2360 xfs_attr_list_context_t *context)
2341{ 2361{
2342 attrlist_cursor_kern_t *cursor; 2362 attrlist_cursor_kern_t *cursor;
2343 xfs_attr_leafblock_t *leaf; 2363 xfs_attr_leafblock_t *leaf;
@@ -2345,7 +2365,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
2345 int retval, i; 2365 int retval, i;
2346 2366
2347 ASSERT(bp != NULL); 2367 ASSERT(bp != NULL);
2348 leaf = bp->data; 2368 leaf = bp->b_addr;
2349 cursor = context->cursor; 2369 cursor = context->cursor;
2350 cursor->initted = 1; 2370 cursor->initted = 1;
2351 2371
@@ -2463,7 +2483,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
2463 xfs_attr_leafblock_t *leaf; 2483 xfs_attr_leafblock_t *leaf;
2464 xfs_attr_leaf_entry_t *entry; 2484 xfs_attr_leaf_entry_t *entry;
2465 xfs_attr_leaf_name_remote_t *name_rmt; 2485 xfs_attr_leaf_name_remote_t *name_rmt;
2466 xfs_dabuf_t *bp; 2486 struct xfs_buf *bp;
2467 int error; 2487 int error;
2468#ifdef DEBUG 2488#ifdef DEBUG
2469 xfs_attr_leaf_name_local_t *name_loc; 2489 xfs_attr_leaf_name_local_t *name_loc;
@@ -2482,7 +2502,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
2482 } 2502 }
2483 ASSERT(bp != NULL); 2503 ASSERT(bp != NULL);
2484 2504
2485 leaf = bp->data; 2505 leaf = bp->b_addr;
2486 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2506 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2487 ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); 2507 ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
2488 ASSERT(args->index >= 0); 2508 ASSERT(args->index >= 0);
@@ -2505,7 +2525,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
2505#endif /* DEBUG */ 2525#endif /* DEBUG */
2506 2526
2507 entry->flags &= ~XFS_ATTR_INCOMPLETE; 2527 entry->flags &= ~XFS_ATTR_INCOMPLETE;
2508 xfs_da_log_buf(args->trans, bp, 2528 xfs_trans_log_buf(args->trans, bp,
2509 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); 2529 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry)));
2510 2530
2511 if (args->rmtblkno) { 2531 if (args->rmtblkno) {
@@ -2513,10 +2533,9 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
2513 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index); 2533 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
2514 name_rmt->valueblk = cpu_to_be32(args->rmtblkno); 2534 name_rmt->valueblk = cpu_to_be32(args->rmtblkno);
2515 name_rmt->valuelen = cpu_to_be32(args->valuelen); 2535 name_rmt->valuelen = cpu_to_be32(args->valuelen);
2516 xfs_da_log_buf(args->trans, bp, 2536 xfs_trans_log_buf(args->trans, bp,
2517 XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); 2537 XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt)));
2518 } 2538 }
2519 xfs_da_buf_done(bp);
2520 2539
2521 /* 2540 /*
2522 * Commit the flag value change and start the next trans in series. 2541 * Commit the flag value change and start the next trans in series.
@@ -2533,7 +2552,7 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
2533 xfs_attr_leafblock_t *leaf; 2552 xfs_attr_leafblock_t *leaf;
2534 xfs_attr_leaf_entry_t *entry; 2553 xfs_attr_leaf_entry_t *entry;
2535 xfs_attr_leaf_name_remote_t *name_rmt; 2554 xfs_attr_leaf_name_remote_t *name_rmt;
2536 xfs_dabuf_t *bp; 2555 struct xfs_buf *bp;
2537 int error; 2556 int error;
2538 2557
2539 trace_xfs_attr_leaf_setflag(args); 2558 trace_xfs_attr_leaf_setflag(args);
@@ -2548,7 +2567,7 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
2548 } 2567 }
2549 ASSERT(bp != NULL); 2568 ASSERT(bp != NULL);
2550 2569
2551 leaf = bp->data; 2570 leaf = bp->b_addr;
2552 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2571 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2553 ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); 2572 ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
2554 ASSERT(args->index >= 0); 2573 ASSERT(args->index >= 0);
@@ -2556,16 +2575,15 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
2556 2575
2557 ASSERT((entry->flags & XFS_ATTR_INCOMPLETE) == 0); 2576 ASSERT((entry->flags & XFS_ATTR_INCOMPLETE) == 0);
2558 entry->flags |= XFS_ATTR_INCOMPLETE; 2577 entry->flags |= XFS_ATTR_INCOMPLETE;
2559 xfs_da_log_buf(args->trans, bp, 2578 xfs_trans_log_buf(args->trans, bp,
2560 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); 2579 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry)));
2561 if ((entry->flags & XFS_ATTR_LOCAL) == 0) { 2580 if ((entry->flags & XFS_ATTR_LOCAL) == 0) {
2562 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index); 2581 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
2563 name_rmt->valueblk = 0; 2582 name_rmt->valueblk = 0;
2564 name_rmt->valuelen = 0; 2583 name_rmt->valuelen = 0;
2565 xfs_da_log_buf(args->trans, bp, 2584 xfs_trans_log_buf(args->trans, bp,
2566 XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); 2585 XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt)));
2567 } 2586 }
2568 xfs_da_buf_done(bp);
2569 2587
2570 /* 2588 /*
2571 * Commit the flag value change and start the next trans in series. 2589 * Commit the flag value change and start the next trans in series.
@@ -2586,7 +2604,7 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
2586 xfs_attr_leafblock_t *leaf1, *leaf2; 2604 xfs_attr_leafblock_t *leaf1, *leaf2;
2587 xfs_attr_leaf_entry_t *entry1, *entry2; 2605 xfs_attr_leaf_entry_t *entry1, *entry2;
2588 xfs_attr_leaf_name_remote_t *name_rmt; 2606 xfs_attr_leaf_name_remote_t *name_rmt;
2589 xfs_dabuf_t *bp1, *bp2; 2607 struct xfs_buf *bp1, *bp2;
2590 int error; 2608 int error;
2591#ifdef DEBUG 2609#ifdef DEBUG
2592 xfs_attr_leaf_name_local_t *name_loc; 2610 xfs_attr_leaf_name_local_t *name_loc;
@@ -2620,13 +2638,13 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
2620 bp2 = bp1; 2638 bp2 = bp1;
2621 } 2639 }
2622 2640
2623 leaf1 = bp1->data; 2641 leaf1 = bp1->b_addr;
2624 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2642 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2625 ASSERT(args->index < be16_to_cpu(leaf1->hdr.count)); 2643 ASSERT(args->index < be16_to_cpu(leaf1->hdr.count));
2626 ASSERT(args->index >= 0); 2644 ASSERT(args->index >= 0);
2627 entry1 = &leaf1->entries[ args->index ]; 2645 entry1 = &leaf1->entries[ args->index ];
2628 2646
2629 leaf2 = bp2->data; 2647 leaf2 = bp2->b_addr;
2630 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2648 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2631 ASSERT(args->index2 < be16_to_cpu(leaf2->hdr.count)); 2649 ASSERT(args->index2 < be16_to_cpu(leaf2->hdr.count));
2632 ASSERT(args->index2 >= 0); 2650 ASSERT(args->index2 >= 0);
@@ -2660,30 +2678,27 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
2660 ASSERT((entry2->flags & XFS_ATTR_INCOMPLETE) == 0); 2678 ASSERT((entry2->flags & XFS_ATTR_INCOMPLETE) == 0);
2661 2679
2662 entry1->flags &= ~XFS_ATTR_INCOMPLETE; 2680 entry1->flags &= ~XFS_ATTR_INCOMPLETE;
2663 xfs_da_log_buf(args->trans, bp1, 2681 xfs_trans_log_buf(args->trans, bp1,
2664 XFS_DA_LOGRANGE(leaf1, entry1, sizeof(*entry1))); 2682 XFS_DA_LOGRANGE(leaf1, entry1, sizeof(*entry1)));
2665 if (args->rmtblkno) { 2683 if (args->rmtblkno) {
2666 ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0); 2684 ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0);
2667 name_rmt = xfs_attr_leaf_name_remote(leaf1, args->index); 2685 name_rmt = xfs_attr_leaf_name_remote(leaf1, args->index);
2668 name_rmt->valueblk = cpu_to_be32(args->rmtblkno); 2686 name_rmt->valueblk = cpu_to_be32(args->rmtblkno);
2669 name_rmt->valuelen = cpu_to_be32(args->valuelen); 2687 name_rmt->valuelen = cpu_to_be32(args->valuelen);
2670 xfs_da_log_buf(args->trans, bp1, 2688 xfs_trans_log_buf(args->trans, bp1,
2671 XFS_DA_LOGRANGE(leaf1, name_rmt, sizeof(*name_rmt))); 2689 XFS_DA_LOGRANGE(leaf1, name_rmt, sizeof(*name_rmt)));
2672 } 2690 }
2673 2691
2674 entry2->flags |= XFS_ATTR_INCOMPLETE; 2692 entry2->flags |= XFS_ATTR_INCOMPLETE;
2675 xfs_da_log_buf(args->trans, bp2, 2693 xfs_trans_log_buf(args->trans, bp2,
2676 XFS_DA_LOGRANGE(leaf2, entry2, sizeof(*entry2))); 2694 XFS_DA_LOGRANGE(leaf2, entry2, sizeof(*entry2)));
2677 if ((entry2->flags & XFS_ATTR_LOCAL) == 0) { 2695 if ((entry2->flags & XFS_ATTR_LOCAL) == 0) {
2678 name_rmt = xfs_attr_leaf_name_remote(leaf2, args->index2); 2696 name_rmt = xfs_attr_leaf_name_remote(leaf2, args->index2);
2679 name_rmt->valueblk = 0; 2697 name_rmt->valueblk = 0;
2680 name_rmt->valuelen = 0; 2698 name_rmt->valuelen = 0;
2681 xfs_da_log_buf(args->trans, bp2, 2699 xfs_trans_log_buf(args->trans, bp2,
2682 XFS_DA_LOGRANGE(leaf2, name_rmt, sizeof(*name_rmt))); 2700 XFS_DA_LOGRANGE(leaf2, name_rmt, sizeof(*name_rmt)));
2683 } 2701 }
2684 xfs_da_buf_done(bp1);
2685 if (bp1 != bp2)
2686 xfs_da_buf_done(bp2);
2687 2702
2688 /* 2703 /*
2689 * Commit the flag value change and start the next trans in series. 2704 * Commit the flag value change and start the next trans in series.
@@ -2706,7 +2721,7 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
2706{ 2721{
2707 xfs_da_blkinfo_t *info; 2722 xfs_da_blkinfo_t *info;
2708 xfs_daddr_t blkno; 2723 xfs_daddr_t blkno;
2709 xfs_dabuf_t *bp; 2724 struct xfs_buf *bp;
2710 int error; 2725 int error;
2711 2726
2712 /* 2727 /*
@@ -2718,20 +2733,20 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
2718 error = xfs_da_read_buf(*trans, dp, 0, -1, &bp, XFS_ATTR_FORK); 2733 error = xfs_da_read_buf(*trans, dp, 0, -1, &bp, XFS_ATTR_FORK);
2719 if (error) 2734 if (error)
2720 return(error); 2735 return(error);
2721 blkno = xfs_da_blkno(bp); 2736 blkno = XFS_BUF_ADDR(bp);
2722 2737
2723 /* 2738 /*
2724 * Invalidate the tree, even if the "tree" is only a single leaf block. 2739 * Invalidate the tree, even if the "tree" is only a single leaf block.
2725 * This is a depth-first traversal! 2740 * This is a depth-first traversal!
2726 */ 2741 */
2727 info = bp->data; 2742 info = bp->b_addr;
2728 if (info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) { 2743 if (info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) {
2729 error = xfs_attr_node_inactive(trans, dp, bp, 1); 2744 error = xfs_attr_node_inactive(trans, dp, bp, 1);
2730 } else if (info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) { 2745 } else if (info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) {
2731 error = xfs_attr_leaf_inactive(trans, dp, bp); 2746 error = xfs_attr_leaf_inactive(trans, dp, bp);
2732 } else { 2747 } else {
2733 error = XFS_ERROR(EIO); 2748 error = XFS_ERROR(EIO);
2734 xfs_da_brelse(*trans, bp); 2749 xfs_trans_brelse(*trans, bp);
2735 } 2750 }
2736 if (error) 2751 if (error)
2737 return(error); 2752 return(error);
@@ -2742,7 +2757,7 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
2742 error = xfs_da_get_buf(*trans, dp, 0, blkno, &bp, XFS_ATTR_FORK); 2757 error = xfs_da_get_buf(*trans, dp, 0, blkno, &bp, XFS_ATTR_FORK);
2743 if (error) 2758 if (error)
2744 return(error); 2759 return(error);
2745 xfs_da_binval(*trans, bp); /* remove from cache */ 2760 xfs_trans_binval(*trans, bp); /* remove from cache */
2746 /* 2761 /*
2747 * Commit the invalidate and start the next transaction. 2762 * Commit the invalidate and start the next transaction.
2748 */ 2763 */
@@ -2756,34 +2771,37 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
2756 * We're doing a depth-first traversal in order to invalidate everything. 2771 * We're doing a depth-first traversal in order to invalidate everything.
2757 */ 2772 */
2758STATIC int 2773STATIC int
2759xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, 2774xfs_attr_node_inactive(
2760 int level) 2775 struct xfs_trans **trans,
2776 struct xfs_inode *dp,
2777 struct xfs_buf *bp,
2778 int level)
2761{ 2779{
2762 xfs_da_blkinfo_t *info; 2780 xfs_da_blkinfo_t *info;
2763 xfs_da_intnode_t *node; 2781 xfs_da_intnode_t *node;
2764 xfs_dablk_t child_fsb; 2782 xfs_dablk_t child_fsb;
2765 xfs_daddr_t parent_blkno, child_blkno; 2783 xfs_daddr_t parent_blkno, child_blkno;
2766 int error, count, i; 2784 int error, count, i;
2767 xfs_dabuf_t *child_bp; 2785 struct xfs_buf *child_bp;
2768 2786
2769 /* 2787 /*
2770 * Since this code is recursive (gasp!) we must protect ourselves. 2788 * Since this code is recursive (gasp!) we must protect ourselves.
2771 */ 2789 */
2772 if (level > XFS_DA_NODE_MAXDEPTH) { 2790 if (level > XFS_DA_NODE_MAXDEPTH) {
2773 xfs_da_brelse(*trans, bp); /* no locks for later trans */ 2791 xfs_trans_brelse(*trans, bp); /* no locks for later trans */
2774 return(XFS_ERROR(EIO)); 2792 return(XFS_ERROR(EIO));
2775 } 2793 }
2776 2794
2777 node = bp->data; 2795 node = bp->b_addr;
2778 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 2796 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
2779 parent_blkno = xfs_da_blkno(bp); /* save for re-read later */ 2797 parent_blkno = XFS_BUF_ADDR(bp); /* save for re-read later */
2780 count = be16_to_cpu(node->hdr.count); 2798 count = be16_to_cpu(node->hdr.count);
2781 if (!count) { 2799 if (!count) {
2782 xfs_da_brelse(*trans, bp); 2800 xfs_trans_brelse(*trans, bp);
2783 return(0); 2801 return(0);
2784 } 2802 }
2785 child_fsb = be32_to_cpu(node->btree[0].before); 2803 child_fsb = be32_to_cpu(node->btree[0].before);
2786 xfs_da_brelse(*trans, bp); /* no locks for later trans */ 2804 xfs_trans_brelse(*trans, bp); /* no locks for later trans */
2787 2805
2788 /* 2806 /*
2789 * If this is the node level just above the leaves, simply loop 2807 * If this is the node level just above the leaves, simply loop
@@ -2803,12 +2821,12 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2803 return(error); 2821 return(error);
2804 if (child_bp) { 2822 if (child_bp) {
2805 /* save for re-read later */ 2823 /* save for re-read later */
2806 child_blkno = xfs_da_blkno(child_bp); 2824 child_blkno = XFS_BUF_ADDR(child_bp);
2807 2825
2808 /* 2826 /*
2809 * Invalidate the subtree, however we have to. 2827 * Invalidate the subtree, however we have to.
2810 */ 2828 */
2811 info = child_bp->data; 2829 info = child_bp->b_addr;
2812 if (info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) { 2830 if (info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) {
2813 error = xfs_attr_node_inactive(trans, dp, 2831 error = xfs_attr_node_inactive(trans, dp,
2814 child_bp, level+1); 2832 child_bp, level+1);
@@ -2817,7 +2835,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2817 child_bp); 2835 child_bp);
2818 } else { 2836 } else {
2819 error = XFS_ERROR(EIO); 2837 error = XFS_ERROR(EIO);
2820 xfs_da_brelse(*trans, child_bp); 2838 xfs_trans_brelse(*trans, child_bp);
2821 } 2839 }
2822 if (error) 2840 if (error)
2823 return(error); 2841 return(error);
@@ -2830,7 +2848,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2830 &child_bp, XFS_ATTR_FORK); 2848 &child_bp, XFS_ATTR_FORK);
2831 if (error) 2849 if (error)
2832 return(error); 2850 return(error);
2833 xfs_da_binval(*trans, child_bp); 2851 xfs_trans_binval(*trans, child_bp);
2834 } 2852 }
2835 2853
2836 /* 2854 /*
@@ -2843,7 +2861,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2843 if (error) 2861 if (error)
2844 return(error); 2862 return(error);
2845 child_fsb = be32_to_cpu(node->btree[i+1].before); 2863 child_fsb = be32_to_cpu(node->btree[i+1].before);
2846 xfs_da_brelse(*trans, bp); 2864 xfs_trans_brelse(*trans, bp);
2847 } 2865 }
2848 /* 2866 /*
2849 * Atomically commit the whole invalidate stuff. 2867 * Atomically commit the whole invalidate stuff.
@@ -2863,7 +2881,10 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2863 * caught holding something that the logging code wants to flush to disk. 2881 * caught holding something that the logging code wants to flush to disk.
2864 */ 2882 */
2865STATIC int 2883STATIC int
2866xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) 2884xfs_attr_leaf_inactive(
2885 struct xfs_trans **trans,
2886 struct xfs_inode *dp,
2887 struct xfs_buf *bp)
2867{ 2888{
2868 xfs_attr_leafblock_t *leaf; 2889 xfs_attr_leafblock_t *leaf;
2869 xfs_attr_leaf_entry_t *entry; 2890 xfs_attr_leaf_entry_t *entry;
@@ -2871,7 +2892,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
2871 xfs_attr_inactive_list_t *list, *lp; 2892 xfs_attr_inactive_list_t *list, *lp;
2872 int error, count, size, tmp, i; 2893 int error, count, size, tmp, i;
2873 2894
2874 leaf = bp->data; 2895 leaf = bp->b_addr;
2875 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2896 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2876 2897
2877 /* 2898 /*
@@ -2892,7 +2913,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
2892 * If there are no "remote" values, we're done. 2913 * If there are no "remote" values, we're done.
2893 */ 2914 */
2894 if (count == 0) { 2915 if (count == 0) {
2895 xfs_da_brelse(*trans, bp); 2916 xfs_trans_brelse(*trans, bp);
2896 return(0); 2917 return(0);
2897 } 2918 }
2898 2919
@@ -2919,7 +2940,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
2919 } 2940 }
2920 } 2941 }
2921 } 2942 }
2922 xfs_da_brelse(*trans, bp); /* unlock for trans. in freextent() */ 2943 xfs_trans_brelse(*trans, bp); /* unlock for trans. in freextent() */
2923 2944
2924 /* 2945 /*
2925 * Invalidate each of the "remote" value extents. 2946 * Invalidate each of the "remote" value extents.
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h
index 9c7d22fdcf4d..dea17722945e 100644
--- a/fs/xfs/xfs_attr_leaf.h
+++ b/fs/xfs/xfs_attr_leaf.h
@@ -31,7 +31,6 @@
31struct attrlist; 31struct attrlist;
32struct attrlist_cursor_kern; 32struct attrlist_cursor_kern;
33struct xfs_attr_list_context; 33struct xfs_attr_list_context;
34struct xfs_dabuf;
35struct xfs_da_args; 34struct xfs_da_args;
36struct xfs_da_state; 35struct xfs_da_state;
37struct xfs_da_state_blk; 36struct xfs_da_state_blk;
@@ -215,7 +214,7 @@ int xfs_attr_shortform_getvalue(struct xfs_da_args *args);
215int xfs_attr_shortform_to_leaf(struct xfs_da_args *args); 214int xfs_attr_shortform_to_leaf(struct xfs_da_args *args);
216int xfs_attr_shortform_remove(struct xfs_da_args *args); 215int xfs_attr_shortform_remove(struct xfs_da_args *args);
217int xfs_attr_shortform_list(struct xfs_attr_list_context *context); 216int xfs_attr_shortform_list(struct xfs_attr_list_context *context);
218int xfs_attr_shortform_allfit(struct xfs_dabuf *bp, struct xfs_inode *dp); 217int xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp);
219int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes); 218int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes);
220 219
221 220
@@ -223,7 +222,7 @@ int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes);
223 * Internal routines when attribute fork size == XFS_LBSIZE(mp). 222 * Internal routines when attribute fork size == XFS_LBSIZE(mp).
224 */ 223 */
225int xfs_attr_leaf_to_node(struct xfs_da_args *args); 224int xfs_attr_leaf_to_node(struct xfs_da_args *args);
226int xfs_attr_leaf_to_shortform(struct xfs_dabuf *bp, 225int xfs_attr_leaf_to_shortform(struct xfs_buf *bp,
227 struct xfs_da_args *args, int forkoff); 226 struct xfs_da_args *args, int forkoff);
228int xfs_attr_leaf_clearflag(struct xfs_da_args *args); 227int xfs_attr_leaf_clearflag(struct xfs_da_args *args);
229int xfs_attr_leaf_setflag(struct xfs_da_args *args); 228int xfs_attr_leaf_setflag(struct xfs_da_args *args);
@@ -235,14 +234,14 @@ int xfs_attr_leaf_flipflags(xfs_da_args_t *args);
235int xfs_attr_leaf_split(struct xfs_da_state *state, 234int xfs_attr_leaf_split(struct xfs_da_state *state,
236 struct xfs_da_state_blk *oldblk, 235 struct xfs_da_state_blk *oldblk,
237 struct xfs_da_state_blk *newblk); 236 struct xfs_da_state_blk *newblk);
238int xfs_attr_leaf_lookup_int(struct xfs_dabuf *leaf, 237int xfs_attr_leaf_lookup_int(struct xfs_buf *leaf,
239 struct xfs_da_args *args); 238 struct xfs_da_args *args);
240int xfs_attr_leaf_getvalue(struct xfs_dabuf *bp, struct xfs_da_args *args); 239int xfs_attr_leaf_getvalue(struct xfs_buf *bp, struct xfs_da_args *args);
241int xfs_attr_leaf_add(struct xfs_dabuf *leaf_buffer, 240int xfs_attr_leaf_add(struct xfs_buf *leaf_buffer,
242 struct xfs_da_args *args); 241 struct xfs_da_args *args);
243int xfs_attr_leaf_remove(struct xfs_dabuf *leaf_buffer, 242int xfs_attr_leaf_remove(struct xfs_buf *leaf_buffer,
244 struct xfs_da_args *args); 243 struct xfs_da_args *args);
245int xfs_attr_leaf_list_int(struct xfs_dabuf *bp, 244int xfs_attr_leaf_list_int(struct xfs_buf *bp,
246 struct xfs_attr_list_context *context); 245 struct xfs_attr_list_context *context);
247 246
248/* 247/*
@@ -257,9 +256,9 @@ int xfs_attr_root_inactive(struct xfs_trans **trans, struct xfs_inode *dp);
257/* 256/*
258 * Utility routines. 257 * Utility routines.
259 */ 258 */
260xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_dabuf *bp, int *count); 259xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_buf *bp, int *count);
261int xfs_attr_leaf_order(struct xfs_dabuf *leaf1_bp, 260int xfs_attr_leaf_order(struct xfs_buf *leaf1_bp,
262 struct xfs_dabuf *leaf2_bp); 261 struct xfs_buf *leaf2_bp);
263int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, 262int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize,
264 int *local); 263 int *local);
265#endif /* __XFS_ATTR_LEAF_H__ */ 264#endif /* __XFS_ATTR_LEAF_H__ */
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 58b815ec8c91..848ffa77707b 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -5517,7 +5517,7 @@ xfs_getbmap(
5517 if (xfs_get_extsz_hint(ip) || 5517 if (xfs_get_extsz_hint(ip) ||
5518 ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){ 5518 ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC|XFS_DIFLAG_APPEND)){
5519 prealloced = 1; 5519 prealloced = 1;
5520 fixlen = XFS_MAXIOFFSET(mp); 5520 fixlen = mp->m_super->s_maxbytes;
5521 } else { 5521 } else {
5522 prealloced = 0; 5522 prealloced = 0;
5523 fixlen = XFS_ISIZE(ip); 5523 fixlen = XFS_ISIZE(ip);
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 269b35c084da..d7a9dd735e1e 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -164,14 +164,49 @@ xfs_buf_stale(
164 ASSERT(atomic_read(&bp->b_hold) >= 1); 164 ASSERT(atomic_read(&bp->b_hold) >= 1);
165} 165}
166 166
167static int
168xfs_buf_get_maps(
169 struct xfs_buf *bp,
170 int map_count)
171{
172 ASSERT(bp->b_maps == NULL);
173 bp->b_map_count = map_count;
174
175 if (map_count == 1) {
176 bp->b_maps = &bp->b_map;
177 return 0;
178 }
179
180 bp->b_maps = kmem_zalloc(map_count * sizeof(struct xfs_buf_map),
181 KM_NOFS);
182 if (!bp->b_maps)
183 return ENOMEM;
184 return 0;
185}
186
187/*
188 * Frees b_pages if it was allocated.
189 */
190static void
191xfs_buf_free_maps(
192 struct xfs_buf *bp)
193{
194 if (bp->b_maps != &bp->b_map) {
195 kmem_free(bp->b_maps);
196 bp->b_maps = NULL;
197 }
198}
199
167struct xfs_buf * 200struct xfs_buf *
168xfs_buf_alloc( 201_xfs_buf_alloc(
169 struct xfs_buftarg *target, 202 struct xfs_buftarg *target,
170 xfs_daddr_t blkno, 203 struct xfs_buf_map *map,
171 size_t numblks, 204 int nmaps,
172 xfs_buf_flags_t flags) 205 xfs_buf_flags_t flags)
173{ 206{
174 struct xfs_buf *bp; 207 struct xfs_buf *bp;
208 int error;
209 int i;
175 210
176 bp = kmem_zone_zalloc(xfs_buf_zone, KM_NOFS); 211 bp = kmem_zone_zalloc(xfs_buf_zone, KM_NOFS);
177 if (unlikely(!bp)) 212 if (unlikely(!bp))
@@ -192,16 +227,28 @@ xfs_buf_alloc(
192 sema_init(&bp->b_sema, 0); /* held, no waiters */ 227 sema_init(&bp->b_sema, 0); /* held, no waiters */
193 XB_SET_OWNER(bp); 228 XB_SET_OWNER(bp);
194 bp->b_target = target; 229 bp->b_target = target;
230 bp->b_flags = flags;
195 231
196 /* 232 /*
197 * Set length and io_length to the same value initially. 233 * Set length and io_length to the same value initially.
198 * I/O routines should use io_length, which will be the same in 234 * I/O routines should use io_length, which will be the same in
199 * most cases but may be reset (e.g. XFS recovery). 235 * most cases but may be reset (e.g. XFS recovery).
200 */ 236 */
201 bp->b_length = numblks; 237 error = xfs_buf_get_maps(bp, nmaps);
202 bp->b_io_length = numblks; 238 if (error) {
203 bp->b_flags = flags; 239 kmem_zone_free(xfs_buf_zone, bp);
204 bp->b_bn = blkno; 240 return NULL;
241 }
242
243 bp->b_bn = map[0].bm_bn;
244 bp->b_length = 0;
245 for (i = 0; i < nmaps; i++) {
246 bp->b_maps[i].bm_bn = map[i].bm_bn;
247 bp->b_maps[i].bm_len = map[i].bm_len;
248 bp->b_length += map[i].bm_len;
249 }
250 bp->b_io_length = bp->b_length;
251
205 atomic_set(&bp->b_pin_count, 0); 252 atomic_set(&bp->b_pin_count, 0);
206 init_waitqueue_head(&bp->b_waiters); 253 init_waitqueue_head(&bp->b_waiters);
207 254
@@ -280,6 +327,7 @@ xfs_buf_free(
280 } else if (bp->b_flags & _XBF_KMEM) 327 } else if (bp->b_flags & _XBF_KMEM)
281 kmem_free(bp->b_addr); 328 kmem_free(bp->b_addr);
282 _xfs_buf_free_pages(bp); 329 _xfs_buf_free_pages(bp);
330 xfs_buf_free_maps(bp);
283 kmem_zone_free(xfs_buf_zone, bp); 331 kmem_zone_free(xfs_buf_zone, bp);
284} 332}
285 333
@@ -327,8 +375,9 @@ xfs_buf_allocate_memory(
327 } 375 }
328 376
329use_alloc_page: 377use_alloc_page:
330 start = BBTOB(bp->b_bn) >> PAGE_SHIFT; 378 start = BBTOB(bp->b_map.bm_bn) >> PAGE_SHIFT;
331 end = (BBTOB(bp->b_bn + bp->b_length) + PAGE_SIZE - 1) >> PAGE_SHIFT; 379 end = (BBTOB(bp->b_map.bm_bn + bp->b_length) + PAGE_SIZE - 1)
380 >> PAGE_SHIFT;
332 page_count = end - start; 381 page_count = end - start;
333 error = _xfs_buf_get_pages(bp, page_count, flags); 382 error = _xfs_buf_get_pages(bp, page_count, flags);
334 if (unlikely(error)) 383 if (unlikely(error))
@@ -425,8 +474,8 @@ _xfs_buf_map_pages(
425xfs_buf_t * 474xfs_buf_t *
426_xfs_buf_find( 475_xfs_buf_find(
427 struct xfs_buftarg *btp, 476 struct xfs_buftarg *btp,
428 xfs_daddr_t blkno, 477 struct xfs_buf_map *map,
429 size_t numblks, 478 int nmaps,
430 xfs_buf_flags_t flags, 479 xfs_buf_flags_t flags,
431 xfs_buf_t *new_bp) 480 xfs_buf_t *new_bp)
432{ 481{
@@ -435,7 +484,12 @@ _xfs_buf_find(
435 struct rb_node **rbp; 484 struct rb_node **rbp;
436 struct rb_node *parent; 485 struct rb_node *parent;
437 xfs_buf_t *bp; 486 xfs_buf_t *bp;
487 xfs_daddr_t blkno = map[0].bm_bn;
488 int numblks = 0;
489 int i;
438 490
491 for (i = 0; i < nmaps; i++)
492 numblks += map[i].bm_len;
439 numbytes = BBTOB(numblks); 493 numbytes = BBTOB(numblks);
440 494
441 /* Check for IOs smaller than the sector size / not sector aligned */ 495 /* Check for IOs smaller than the sector size / not sector aligned */
@@ -527,31 +581,31 @@ found:
527 * more hits than misses. 581 * more hits than misses.
528 */ 582 */
529struct xfs_buf * 583struct xfs_buf *
530xfs_buf_get( 584xfs_buf_get_map(
531 xfs_buftarg_t *target, 585 struct xfs_buftarg *target,
532 xfs_daddr_t blkno, 586 struct xfs_buf_map *map,
533 size_t numblks, 587 int nmaps,
534 xfs_buf_flags_t flags) 588 xfs_buf_flags_t flags)
535{ 589{
536 struct xfs_buf *bp; 590 struct xfs_buf *bp;
537 struct xfs_buf *new_bp; 591 struct xfs_buf *new_bp;
538 int error = 0; 592 int error = 0;
539 593
540 bp = _xfs_buf_find(target, blkno, numblks, flags, NULL); 594 bp = _xfs_buf_find(target, map, nmaps, flags, NULL);
541 if (likely(bp)) 595 if (likely(bp))
542 goto found; 596 goto found;
543 597
544 new_bp = xfs_buf_alloc(target, blkno, numblks, flags); 598 new_bp = _xfs_buf_alloc(target, map, nmaps, flags);
545 if (unlikely(!new_bp)) 599 if (unlikely(!new_bp))
546 return NULL; 600 return NULL;
547 601
548 error = xfs_buf_allocate_memory(new_bp, flags); 602 error = xfs_buf_allocate_memory(new_bp, flags);
549 if (error) { 603 if (error) {
550 kmem_zone_free(xfs_buf_zone, new_bp); 604 xfs_buf_free(new_bp);
551 return NULL; 605 return NULL;
552 } 606 }
553 607
554 bp = _xfs_buf_find(target, blkno, numblks, flags, new_bp); 608 bp = _xfs_buf_find(target, map, nmaps, flags, new_bp);
555 if (!bp) { 609 if (!bp) {
556 xfs_buf_free(new_bp); 610 xfs_buf_free(new_bp);
557 return NULL; 611 return NULL;
@@ -560,8 +614,6 @@ xfs_buf_get(
560 if (bp != new_bp) 614 if (bp != new_bp)
561 xfs_buf_free(new_bp); 615 xfs_buf_free(new_bp);
562 616
563 bp->b_io_length = bp->b_length;
564
565found: 617found:
566 if (!bp->b_addr) { 618 if (!bp->b_addr) {
567 error = _xfs_buf_map_pages(bp, flags); 619 error = _xfs_buf_map_pages(bp, flags);
@@ -584,7 +636,7 @@ _xfs_buf_read(
584 xfs_buf_flags_t flags) 636 xfs_buf_flags_t flags)
585{ 637{
586 ASSERT(!(flags & XBF_WRITE)); 638 ASSERT(!(flags & XBF_WRITE));
587 ASSERT(bp->b_bn != XFS_BUF_DADDR_NULL); 639 ASSERT(bp->b_map.bm_bn != XFS_BUF_DADDR_NULL);
588 640
589 bp->b_flags &= ~(XBF_WRITE | XBF_ASYNC | XBF_READ_AHEAD); 641 bp->b_flags &= ~(XBF_WRITE | XBF_ASYNC | XBF_READ_AHEAD);
590 bp->b_flags |= flags & (XBF_READ | XBF_ASYNC | XBF_READ_AHEAD); 642 bp->b_flags |= flags & (XBF_READ | XBF_ASYNC | XBF_READ_AHEAD);
@@ -596,17 +648,17 @@ _xfs_buf_read(
596} 648}
597 649
598xfs_buf_t * 650xfs_buf_t *
599xfs_buf_read( 651xfs_buf_read_map(
600 xfs_buftarg_t *target, 652 struct xfs_buftarg *target,
601 xfs_daddr_t blkno, 653 struct xfs_buf_map *map,
602 size_t numblks, 654 int nmaps,
603 xfs_buf_flags_t flags) 655 xfs_buf_flags_t flags)
604{ 656{
605 xfs_buf_t *bp; 657 struct xfs_buf *bp;
606 658
607 flags |= XBF_READ; 659 flags |= XBF_READ;
608 660
609 bp = xfs_buf_get(target, blkno, numblks, flags); 661 bp = xfs_buf_get_map(target, map, nmaps, flags);
610 if (bp) { 662 if (bp) {
611 trace_xfs_buf_read(bp, flags, _RET_IP_); 663 trace_xfs_buf_read(bp, flags, _RET_IP_);
612 664
@@ -634,15 +686,15 @@ xfs_buf_read(
634 * safe manner. 686 * safe manner.
635 */ 687 */
636void 688void
637xfs_buf_readahead( 689xfs_buf_readahead_map(
638 xfs_buftarg_t *target, 690 struct xfs_buftarg *target,
639 xfs_daddr_t blkno, 691 struct xfs_buf_map *map,
640 size_t numblks) 692 int nmaps)
641{ 693{
642 if (bdi_read_congested(target->bt_bdi)) 694 if (bdi_read_congested(target->bt_bdi))
643 return; 695 return;
644 696
645 xfs_buf_read(target, blkno, numblks, 697 xfs_buf_read_map(target, map, nmaps,
646 XBF_TRYLOCK|XBF_ASYNC|XBF_READ_AHEAD); 698 XBF_TRYLOCK|XBF_ASYNC|XBF_READ_AHEAD);
647} 699}
648 700
@@ -665,8 +717,10 @@ xfs_buf_read_uncached(
665 return NULL; 717 return NULL;
666 718
667 /* set up the buffer for a read IO */ 719 /* set up the buffer for a read IO */
668 XFS_BUF_SET_ADDR(bp, daddr); 720 ASSERT(bp->b_map_count == 1);
669 XFS_BUF_READ(bp); 721 bp->b_bn = daddr;
722 bp->b_maps[0].bm_bn = daddr;
723 bp->b_flags |= XBF_READ;
670 724
671 xfsbdstrat(target->bt_mount, bp); 725 xfsbdstrat(target->bt_mount, bp);
672 error = xfs_buf_iowait(bp); 726 error = xfs_buf_iowait(bp);
@@ -694,7 +748,11 @@ xfs_buf_set_empty(
694 bp->b_addr = NULL; 748 bp->b_addr = NULL;
695 bp->b_length = numblks; 749 bp->b_length = numblks;
696 bp->b_io_length = numblks; 750 bp->b_io_length = numblks;
751
752 ASSERT(bp->b_map_count == 1);
697 bp->b_bn = XFS_BUF_DADDR_NULL; 753 bp->b_bn = XFS_BUF_DADDR_NULL;
754 bp->b_maps[0].bm_bn = XFS_BUF_DADDR_NULL;
755 bp->b_maps[0].bm_len = bp->b_length;
698} 756}
699 757
700static inline struct page * 758static inline struct page *
@@ -758,9 +816,10 @@ xfs_buf_get_uncached(
758{ 816{
759 unsigned long page_count; 817 unsigned long page_count;
760 int error, i; 818 int error, i;
761 xfs_buf_t *bp; 819 struct xfs_buf *bp;
820 DEFINE_SINGLE_BUF_MAP(map, XFS_BUF_DADDR_NULL, numblks);
762 821
763 bp = xfs_buf_alloc(target, XFS_BUF_DADDR_NULL, numblks, 0); 822 bp = _xfs_buf_alloc(target, &map, 1, 0);
764 if (unlikely(bp == NULL)) 823 if (unlikely(bp == NULL))
765 goto fail; 824 goto fail;
766 825
@@ -791,6 +850,7 @@ xfs_buf_get_uncached(
791 __free_page(bp->b_pages[i]); 850 __free_page(bp->b_pages[i]);
792 _xfs_buf_free_pages(bp); 851 _xfs_buf_free_pages(bp);
793 fail_free_buf: 852 fail_free_buf:
853 xfs_buf_free_maps(bp);
794 kmem_zone_free(xfs_buf_zone, bp); 854 kmem_zone_free(xfs_buf_zone, bp);
795 fail: 855 fail:
796 return NULL; 856 return NULL;
@@ -1144,36 +1204,39 @@ xfs_buf_bio_end_io(
1144 bio_put(bio); 1204 bio_put(bio);
1145} 1205}
1146 1206
1147STATIC void 1207static void
1148_xfs_buf_ioapply( 1208xfs_buf_ioapply_map(
1149 xfs_buf_t *bp) 1209 struct xfs_buf *bp,
1210 int map,
1211 int *buf_offset,
1212 int *count,
1213 int rw)
1150{ 1214{
1151 int rw, map_i, total_nr_pages, nr_pages; 1215 int page_index;
1152 struct bio *bio; 1216 int total_nr_pages = bp->b_page_count;
1153 int offset = bp->b_offset; 1217 int nr_pages;
1154 int size = BBTOB(bp->b_io_length); 1218 struct bio *bio;
1155 sector_t sector = bp->b_bn; 1219 sector_t sector = bp->b_maps[map].bm_bn;
1220 int size;
1221 int offset;
1156 1222
1157 total_nr_pages = bp->b_page_count; 1223 total_nr_pages = bp->b_page_count;
1158 map_i = 0;
1159 1224
1160 if (bp->b_flags & XBF_WRITE) { 1225 /* skip the pages in the buffer before the start offset */
1161 if (bp->b_flags & XBF_SYNCIO) 1226 page_index = 0;
1162 rw = WRITE_SYNC; 1227 offset = *buf_offset;
1163 else 1228 while (offset >= PAGE_SIZE) {
1164 rw = WRITE; 1229 page_index++;
1165 if (bp->b_flags & XBF_FUA) 1230 offset -= PAGE_SIZE;
1166 rw |= REQ_FUA;
1167 if (bp->b_flags & XBF_FLUSH)
1168 rw |= REQ_FLUSH;
1169 } else if (bp->b_flags & XBF_READ_AHEAD) {
1170 rw = READA;
1171 } else {
1172 rw = READ;
1173 } 1231 }
1174 1232
1175 /* we only use the buffer cache for meta-data */ 1233 /*
1176 rw |= REQ_META; 1234 * Limit the IO size to the length of the current vector, and update the
1235 * remaining IO count for the next time around.
1236 */
1237 size = min_t(int, BBTOB(bp->b_maps[map].bm_len), *count);
1238 *count -= size;
1239 *buf_offset += size;
1177 1240
1178next_chunk: 1241next_chunk:
1179 atomic_inc(&bp->b_io_remaining); 1242 atomic_inc(&bp->b_io_remaining);
@@ -1188,13 +1251,14 @@ next_chunk:
1188 bio->bi_private = bp; 1251 bio->bi_private = bp;
1189 1252
1190 1253
1191 for (; size && nr_pages; nr_pages--, map_i++) { 1254 for (; size && nr_pages; nr_pages--, page_index++) {
1192 int rbytes, nbytes = PAGE_SIZE - offset; 1255 int rbytes, nbytes = PAGE_SIZE - offset;
1193 1256
1194 if (nbytes > size) 1257 if (nbytes > size)
1195 nbytes = size; 1258 nbytes = size;
1196 1259
1197 rbytes = bio_add_page(bio, bp->b_pages[map_i], nbytes, offset); 1260 rbytes = bio_add_page(bio, bp->b_pages[page_index], nbytes,
1261 offset);
1198 if (rbytes < nbytes) 1262 if (rbytes < nbytes)
1199 break; 1263 break;
1200 1264
@@ -1216,6 +1280,54 @@ next_chunk:
1216 xfs_buf_ioerror(bp, EIO); 1280 xfs_buf_ioerror(bp, EIO);
1217 bio_put(bio); 1281 bio_put(bio);
1218 } 1282 }
1283
1284}
1285
1286STATIC void
1287_xfs_buf_ioapply(
1288 struct xfs_buf *bp)
1289{
1290 struct blk_plug plug;
1291 int rw;
1292 int offset;
1293 int size;
1294 int i;
1295
1296 if (bp->b_flags & XBF_WRITE) {
1297 if (bp->b_flags & XBF_SYNCIO)
1298 rw = WRITE_SYNC;
1299 else
1300 rw = WRITE;
1301 if (bp->b_flags & XBF_FUA)
1302 rw |= REQ_FUA;
1303 if (bp->b_flags & XBF_FLUSH)
1304 rw |= REQ_FLUSH;
1305 } else if (bp->b_flags & XBF_READ_AHEAD) {
1306 rw = READA;
1307 } else {
1308 rw = READ;
1309 }
1310
1311 /* we only use the buffer cache for meta-data */
1312 rw |= REQ_META;
1313
1314 /*
1315 * Walk all the vectors issuing IO on them. Set up the initial offset
1316 * into the buffer and the desired IO size before we start -
1317 * _xfs_buf_ioapply_vec() will modify them appropriately for each
1318 * subsequent call.
1319 */
1320 offset = bp->b_offset;
1321 size = BBTOB(bp->b_io_length);
1322 blk_start_plug(&plug);
1323 for (i = 0; i < bp->b_map_count; i++) {
1324 xfs_buf_ioapply_map(bp, i, &offset, &size, rw);
1325 if (bp->b_error)
1326 break;
1327 if (size <= 0)
1328 break; /* all done */
1329 }
1330 blk_finish_plug(&plug);
1219} 1331}
1220 1332
1221void 1333void
@@ -1557,7 +1669,7 @@ xfs_buf_cmp(
1557 struct xfs_buf *bp = container_of(b, struct xfs_buf, b_list); 1669 struct xfs_buf *bp = container_of(b, struct xfs_buf, b_list);
1558 xfs_daddr_t diff; 1670 xfs_daddr_t diff;
1559 1671
1560 diff = ap->b_bn - bp->b_bn; 1672 diff = ap->b_map.bm_bn - bp->b_map.bm_bn;
1561 if (diff < 0) 1673 if (diff < 0)
1562 return -1; 1674 return -1;
1563 if (diff > 0) 1675 if (diff > 0)
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 79344c48008e..d03b73b9604e 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -58,6 +58,7 @@ typedef enum {
58#define _XBF_PAGES (1 << 20)/* backed by refcounted pages */ 58#define _XBF_PAGES (1 << 20)/* backed by refcounted pages */
59#define _XBF_KMEM (1 << 21)/* backed by heap memory */ 59#define _XBF_KMEM (1 << 21)/* backed by heap memory */
60#define _XBF_DELWRI_Q (1 << 22)/* buffer on a delwri queue */ 60#define _XBF_DELWRI_Q (1 << 22)/* buffer on a delwri queue */
61#define _XBF_COMPOUND (1 << 23)/* compound buffer */
61 62
62typedef unsigned int xfs_buf_flags_t; 63typedef unsigned int xfs_buf_flags_t;
63 64
@@ -75,7 +76,8 @@ typedef unsigned int xfs_buf_flags_t;
75 { XBF_UNMAPPED, "UNMAPPED" }, /* ditto */\ 76 { XBF_UNMAPPED, "UNMAPPED" }, /* ditto */\
76 { _XBF_PAGES, "PAGES" }, \ 77 { _XBF_PAGES, "PAGES" }, \
77 { _XBF_KMEM, "KMEM" }, \ 78 { _XBF_KMEM, "KMEM" }, \
78 { _XBF_DELWRI_Q, "DELWRI_Q" } 79 { _XBF_DELWRI_Q, "DELWRI_Q" }, \
80 { _XBF_COMPOUND, "COMPOUND" }
79 81
80typedef struct xfs_buftarg { 82typedef struct xfs_buftarg {
81 dev_t bt_dev; 83 dev_t bt_dev;
@@ -98,6 +100,14 @@ typedef void (*xfs_buf_iodone_t)(struct xfs_buf *);
98 100
99#define XB_PAGES 2 101#define XB_PAGES 2
100 102
103struct xfs_buf_map {
104 xfs_daddr_t bm_bn; /* block number for I/O */
105 int bm_len; /* size of I/O */
106};
107
108#define DEFINE_SINGLE_BUF_MAP(map, blkno, numblk) \
109 struct xfs_buf_map (map) = { .bm_bn = (blkno), .bm_len = (numblk) };
110
101typedef struct xfs_buf { 111typedef struct xfs_buf {
102 /* 112 /*
103 * first cacheline holds all the fields needed for an uncontended cache 113 * first cacheline holds all the fields needed for an uncontended cache
@@ -107,7 +117,7 @@ typedef struct xfs_buf {
107 * fast-path on locking. 117 * fast-path on locking.
108 */ 118 */
109 struct rb_node b_rbnode; /* rbtree node */ 119 struct rb_node b_rbnode; /* rbtree node */
110 xfs_daddr_t b_bn; /* block number for I/O */ 120 xfs_daddr_t b_bn; /* block number of buffer */
111 int b_length; /* size of buffer in BBs */ 121 int b_length; /* size of buffer in BBs */
112 atomic_t b_hold; /* reference count */ 122 atomic_t b_hold; /* reference count */
113 atomic_t b_lru_ref; /* lru reclaim ref count */ 123 atomic_t b_lru_ref; /* lru reclaim ref count */
@@ -127,12 +137,16 @@ typedef struct xfs_buf {
127 struct xfs_trans *b_transp; 137 struct xfs_trans *b_transp;
128 struct page **b_pages; /* array of page pointers */ 138 struct page **b_pages; /* array of page pointers */
129 struct page *b_page_array[XB_PAGES]; /* inline pages */ 139 struct page *b_page_array[XB_PAGES]; /* inline pages */
140 struct xfs_buf_map *b_maps; /* compound buffer map */
141 struct xfs_buf_map b_map; /* inline compound buffer map */
142 int b_map_count;
130 int b_io_length; /* IO size in BBs */ 143 int b_io_length; /* IO size in BBs */
131 atomic_t b_pin_count; /* pin count */ 144 atomic_t b_pin_count; /* pin count */
132 atomic_t b_io_remaining; /* #outstanding I/O requests */ 145 atomic_t b_io_remaining; /* #outstanding I/O requests */
133 unsigned int b_page_count; /* size of page array */ 146 unsigned int b_page_count; /* size of page array */
134 unsigned int b_offset; /* page offset in first page */ 147 unsigned int b_offset; /* page offset in first page */
135 unsigned short b_error; /* error code on I/O */ 148 unsigned short b_error; /* error code on I/O */
149
136#ifdef XFS_BUF_LOCK_TRACKING 150#ifdef XFS_BUF_LOCK_TRACKING
137 int b_last_holder; 151 int b_last_holder;
138#endif 152#endif
@@ -140,22 +154,78 @@ typedef struct xfs_buf {
140 154
141 155
142/* Finding and Reading Buffers */ 156/* Finding and Reading Buffers */
143struct xfs_buf *_xfs_buf_find(struct xfs_buftarg *target, xfs_daddr_t blkno, 157struct xfs_buf *_xfs_buf_find(struct xfs_buftarg *target,
144 size_t numblks, xfs_buf_flags_t flags, 158 struct xfs_buf_map *map, int nmaps,
145 struct xfs_buf *new_bp); 159 xfs_buf_flags_t flags, struct xfs_buf *new_bp);
146#define xfs_incore(buftarg,blkno,len,lockit) \ 160
147 _xfs_buf_find(buftarg, blkno ,len, lockit, NULL) 161static inline struct xfs_buf *
148 162xfs_incore(
149struct xfs_buf *xfs_buf_get(struct xfs_buftarg *target, xfs_daddr_t blkno, 163 struct xfs_buftarg *target,
150 size_t numblks, xfs_buf_flags_t flags); 164 xfs_daddr_t blkno,
151struct xfs_buf *xfs_buf_read(struct xfs_buftarg *target, xfs_daddr_t blkno, 165 size_t numblks,
152 size_t numblks, xfs_buf_flags_t flags); 166 xfs_buf_flags_t flags)
153void xfs_buf_readahead(struct xfs_buftarg *target, xfs_daddr_t blkno, 167{
154 size_t numblks); 168 DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
169 return _xfs_buf_find(target, &map, 1, flags, NULL);
170}
171
172struct xfs_buf *_xfs_buf_alloc(struct xfs_buftarg *target,
173 struct xfs_buf_map *map, int nmaps,
174 xfs_buf_flags_t flags);
175
176static inline struct xfs_buf *
177xfs_buf_alloc(
178 struct xfs_buftarg *target,
179 xfs_daddr_t blkno,
180 size_t numblks,
181 xfs_buf_flags_t flags)
182{
183 DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
184 return _xfs_buf_alloc(target, &map, 1, flags);
185}
186
187struct xfs_buf *xfs_buf_get_map(struct xfs_buftarg *target,
188 struct xfs_buf_map *map, int nmaps,
189 xfs_buf_flags_t flags);
190struct xfs_buf *xfs_buf_read_map(struct xfs_buftarg *target,
191 struct xfs_buf_map *map, int nmaps,
192 xfs_buf_flags_t flags);
193void xfs_buf_readahead_map(struct xfs_buftarg *target,
194 struct xfs_buf_map *map, int nmaps);
195
196static inline struct xfs_buf *
197xfs_buf_get(
198 struct xfs_buftarg *target,
199 xfs_daddr_t blkno,
200 size_t numblks,
201 xfs_buf_flags_t flags)
202{
203 DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
204 return xfs_buf_get_map(target, &map, 1, flags);
205}
206
207static inline struct xfs_buf *
208xfs_buf_read(
209 struct xfs_buftarg *target,
210 xfs_daddr_t blkno,
211 size_t numblks,
212 xfs_buf_flags_t flags)
213{
214 DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
215 return xfs_buf_read_map(target, &map, 1, flags);
216}
217
218static inline void
219xfs_buf_readahead(
220 struct xfs_buftarg *target,
221 xfs_daddr_t blkno,
222 size_t numblks)
223{
224 DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
225 return xfs_buf_readahead_map(target, &map, 1);
226}
155 227
156struct xfs_buf *xfs_buf_get_empty(struct xfs_buftarg *target, size_t numblks); 228struct xfs_buf *xfs_buf_get_empty(struct xfs_buftarg *target, size_t numblks);
157struct xfs_buf *xfs_buf_alloc(struct xfs_buftarg *target, xfs_daddr_t blkno,
158 size_t numblks, xfs_buf_flags_t flags);
159void xfs_buf_set_empty(struct xfs_buf *bp, size_t numblks); 229void xfs_buf_set_empty(struct xfs_buf *bp, size_t numblks);
160int xfs_buf_associate_memory(struct xfs_buf *bp, void *mem, size_t length); 230int xfs_buf_associate_memory(struct xfs_buf *bp, void *mem, size_t length);
161 231
@@ -232,8 +302,18 @@ void xfs_buf_stale(struct xfs_buf *bp);
232#define XFS_BUF_UNWRITE(bp) ((bp)->b_flags &= ~XBF_WRITE) 302#define XFS_BUF_UNWRITE(bp) ((bp)->b_flags &= ~XBF_WRITE)
233#define XFS_BUF_ISWRITE(bp) ((bp)->b_flags & XBF_WRITE) 303#define XFS_BUF_ISWRITE(bp) ((bp)->b_flags & XBF_WRITE)
234 304
235#define XFS_BUF_ADDR(bp) ((bp)->b_bn) 305/*
236#define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_bn = (xfs_daddr_t)(bno)) 306 * These macros use the IO block map rather than b_bn. b_bn is now really
307 * just for the buffer cache index for cached buffers. As IO does not use b_bn
308 * anymore, uncached buffers do not use b_bn at all and hence must modify the IO
309 * map directly. Uncached buffers are not allowed to be discontiguous, so this
310 * is safe to do.
311 *
312 * In future, uncached buffers will pass the block number directly to the io
313 * request function and hence these macros will go away at that point.
314 */
315#define XFS_BUF_ADDR(bp) ((bp)->b_map.bm_bn)
316#define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_map.bm_bn = (xfs_daddr_t)(bno))
237 317
238static inline void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref) 318static inline void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref)
239{ 319{
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index d9e451115f98..a8d0ed911196 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -153,33 +153,25 @@ STATIC void xfs_buf_do_callbacks(struct xfs_buf *bp);
153 * If the XFS_BLI_STALE flag has been set, then log nothing. 153 * If the XFS_BLI_STALE flag has been set, then log nothing.
154 */ 154 */
155STATIC uint 155STATIC uint
156xfs_buf_item_size( 156xfs_buf_item_size_segment(
157 struct xfs_log_item *lip) 157 struct xfs_buf_log_item *bip,
158 struct xfs_buf_log_format *blfp)
158{ 159{
159 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
160 struct xfs_buf *bp = bip->bli_buf; 160 struct xfs_buf *bp = bip->bli_buf;
161 uint nvecs; 161 uint nvecs;
162 int next_bit; 162 int next_bit;
163 int last_bit; 163 int last_bit;
164 164
165 ASSERT(atomic_read(&bip->bli_refcount) > 0); 165 last_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0);
166 if (bip->bli_flags & XFS_BLI_STALE) { 166 if (last_bit == -1)
167 /* 167 return 0;
168 * The buffer is stale, so all we need to log 168
169 * is the buf log format structure with the 169 /*
170 * cancel flag in it. 170 * initial count for a dirty buffer is 2 vectors - the format structure
171 */ 171 * and the first dirty region.
172 trace_xfs_buf_item_size_stale(bip); 172 */
173 ASSERT(bip->bli_format.blf_flags & XFS_BLF_CANCEL); 173 nvecs = 2;
174 return 1;
175 }
176 174
177 ASSERT(bip->bli_flags & XFS_BLI_LOGGED);
178 nvecs = 1;
179 last_bit = xfs_next_bit(bip->bli_format.blf_data_map,
180 bip->bli_format.blf_map_size, 0);
181 ASSERT(last_bit != -1);
182 nvecs++;
183 while (last_bit != -1) { 175 while (last_bit != -1) {
184 /* 176 /*
185 * This takes the bit number to start looking from and 177 * This takes the bit number to start looking from and
@@ -187,16 +179,15 @@ xfs_buf_item_size(
187 * if there are no more bits set or the start bit is 179 * if there are no more bits set or the start bit is
188 * beyond the end of the bitmap. 180 * beyond the end of the bitmap.
189 */ 181 */
190 next_bit = xfs_next_bit(bip->bli_format.blf_data_map, 182 next_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size,
191 bip->bli_format.blf_map_size, 183 last_bit + 1);
192 last_bit + 1);
193 /* 184 /*
194 * If we run out of bits, leave the loop, 185 * If we run out of bits, leave the loop,
195 * else if we find a new set of bits bump the number of vecs, 186 * else if we find a new set of bits bump the number of vecs,
196 * else keep scanning the current set of bits. 187 * else keep scanning the current set of bits.
197 */ 188 */
198 if (next_bit == -1) { 189 if (next_bit == -1) {
199 last_bit = -1; 190 break;
200 } else if (next_bit != last_bit + 1) { 191 } else if (next_bit != last_bit + 1) {
201 last_bit = next_bit; 192 last_bit = next_bit;
202 nvecs++; 193 nvecs++;
@@ -210,22 +201,73 @@ xfs_buf_item_size(
210 } 201 }
211 } 202 }
212 203
213 trace_xfs_buf_item_size(bip);
214 return nvecs; 204 return nvecs;
215} 205}
216 206
217/* 207/*
218 * This is called to fill in the vector of log iovecs for the 208 * This returns the number of log iovecs needed to log the given buf log item.
219 * given log buf item. It fills the first entry with a buf log 209 *
220 * format structure, and the rest point to contiguous chunks 210 * It calculates this as 1 iovec for the buf log format structure and 1 for each
221 * within the buffer. 211 * stretch of non-contiguous chunks to be logged. Contiguous chunks are logged
212 * in a single iovec.
213 *
214 * Discontiguous buffers need a format structure per region that that is being
215 * logged. This makes the changes in the buffer appear to log recovery as though
216 * they came from separate buffers, just like would occur if multiple buffers
217 * were used instead of a single discontiguous buffer. This enables
218 * discontiguous buffers to be in-memory constructs, completely transparent to
219 * what ends up on disk.
220 *
221 * If the XFS_BLI_STALE flag has been set, then log nothing but the buf log
222 * format structures.
222 */ 223 */
223STATIC void 224STATIC uint
224xfs_buf_item_format( 225xfs_buf_item_size(
225 struct xfs_log_item *lip, 226 struct xfs_log_item *lip)
226 struct xfs_log_iovec *vecp)
227{ 227{
228 struct xfs_buf_log_item *bip = BUF_ITEM(lip); 228 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
229 uint nvecs;
230 int i;
231
232 ASSERT(atomic_read(&bip->bli_refcount) > 0);
233 if (bip->bli_flags & XFS_BLI_STALE) {
234 /*
235 * The buffer is stale, so all we need to log
236 * is the buf log format structure with the
237 * cancel flag in it.
238 */
239 trace_xfs_buf_item_size_stale(bip);
240 ASSERT(bip->bli_format.blf_flags & XFS_BLF_CANCEL);
241 return bip->bli_format_count;
242 }
243
244 ASSERT(bip->bli_flags & XFS_BLI_LOGGED);
245
246 /*
247 * the vector count is based on the number of buffer vectors we have
248 * dirty bits in. This will only be greater than one when we have a
249 * compound buffer with more than one segment dirty. Hence for compound
250 * buffers we need to track which segment the dirty bits correspond to,
251 * and when we move from one segment to the next increment the vector
252 * count for the extra buf log format structure that will need to be
253 * written.
254 */
255 nvecs = 0;
256 for (i = 0; i < bip->bli_format_count; i++) {
257 nvecs += xfs_buf_item_size_segment(bip, &bip->bli_formats[i]);
258 }
259
260 trace_xfs_buf_item_size(bip);
261 return nvecs;
262}
263
264static struct xfs_log_iovec *
265xfs_buf_item_format_segment(
266 struct xfs_buf_log_item *bip,
267 struct xfs_log_iovec *vecp,
268 uint offset,
269 struct xfs_buf_log_format *blfp)
270{
229 struct xfs_buf *bp = bip->bli_buf; 271 struct xfs_buf *bp = bip->bli_buf;
230 uint base_size; 272 uint base_size;
231 uint nvecs; 273 uint nvecs;
@@ -235,40 +277,22 @@ xfs_buf_item_format(
235 uint nbits; 277 uint nbits;
236 uint buffer_offset; 278 uint buffer_offset;
237 279
238 ASSERT(atomic_read(&bip->bli_refcount) > 0); 280 /* copy the flags across from the base format item */
239 ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || 281 blfp->blf_flags = bip->bli_format.blf_flags;
240 (bip->bli_flags & XFS_BLI_STALE));
241 282
242 /* 283 /*
243 * The size of the base structure is the size of the 284 * Base size is the actual size of the ondisk structure - it reflects
244 * declared structure plus the space for the extra words 285 * the actual size of the dirty bitmap rather than the size of the in
245 * of the bitmap. We subtract one from the map size, because 286 * memory structure.
246 * the first element of the bitmap is accounted for in the
247 * size of the base structure.
248 */ 287 */
249 base_size = 288 base_size = offsetof(struct xfs_buf_log_format, blf_data_map) +
250 (uint)(sizeof(xfs_buf_log_format_t) + 289 (blfp->blf_map_size * sizeof(blfp->blf_data_map[0]));
251 ((bip->bli_format.blf_map_size - 1) * sizeof(uint))); 290 vecp->i_addr = blfp;
252 vecp->i_addr = &bip->bli_format;
253 vecp->i_len = base_size; 291 vecp->i_len = base_size;
254 vecp->i_type = XLOG_REG_TYPE_BFORMAT; 292 vecp->i_type = XLOG_REG_TYPE_BFORMAT;
255 vecp++; 293 vecp++;
256 nvecs = 1; 294 nvecs = 1;
257 295
258 /*
259 * If it is an inode buffer, transfer the in-memory state to the
260 * format flags and clear the in-memory state. We do not transfer
261 * this state if the inode buffer allocation has not yet been committed
262 * to the log as setting the XFS_BLI_INODE_BUF flag will prevent
263 * correct replay of the inode allocation.
264 */
265 if (bip->bli_flags & XFS_BLI_INODE_BUF) {
266 if (!((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) &&
267 xfs_log_item_in_current_chkpt(lip)))
268 bip->bli_format.blf_flags |= XFS_BLF_INODE_BUF;
269 bip->bli_flags &= ~XFS_BLI_INODE_BUF;
270 }
271
272 if (bip->bli_flags & XFS_BLI_STALE) { 296 if (bip->bli_flags & XFS_BLI_STALE) {
273 /* 297 /*
274 * The buffer is stale, so all we need to log 298 * The buffer is stale, so all we need to log
@@ -276,16 +300,15 @@ xfs_buf_item_format(
276 * cancel flag in it. 300 * cancel flag in it.
277 */ 301 */
278 trace_xfs_buf_item_format_stale(bip); 302 trace_xfs_buf_item_format_stale(bip);
279 ASSERT(bip->bli_format.blf_flags & XFS_BLF_CANCEL); 303 ASSERT(blfp->blf_flags & XFS_BLF_CANCEL);
280 bip->bli_format.blf_size = nvecs; 304 blfp->blf_size = nvecs;
281 return; 305 return vecp;
282 } 306 }
283 307
284 /* 308 /*
285 * Fill in an iovec for each set of contiguous chunks. 309 * Fill in an iovec for each set of contiguous chunks.
286 */ 310 */
287 first_bit = xfs_next_bit(bip->bli_format.blf_data_map, 311 first_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0);
288 bip->bli_format.blf_map_size, 0);
289 ASSERT(first_bit != -1); 312 ASSERT(first_bit != -1);
290 last_bit = first_bit; 313 last_bit = first_bit;
291 nbits = 1; 314 nbits = 1;
@@ -296,9 +319,8 @@ xfs_buf_item_format(
296 * if there are no more bits set or the start bit is 319 * if there are no more bits set or the start bit is
297 * beyond the end of the bitmap. 320 * beyond the end of the bitmap.
298 */ 321 */
299 next_bit = xfs_next_bit(bip->bli_format.blf_data_map, 322 next_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size,
300 bip->bli_format.blf_map_size, 323 (uint)last_bit + 1);
301 (uint)last_bit + 1);
302 /* 324 /*
303 * If we run out of bits fill in the last iovec and get 325 * If we run out of bits fill in the last iovec and get
304 * out of the loop. 326 * out of the loop.
@@ -309,14 +331,14 @@ xfs_buf_item_format(
309 * keep counting and scanning. 331 * keep counting and scanning.
310 */ 332 */
311 if (next_bit == -1) { 333 if (next_bit == -1) {
312 buffer_offset = first_bit * XFS_BLF_CHUNK; 334 buffer_offset = offset + first_bit * XFS_BLF_CHUNK;
313 vecp->i_addr = xfs_buf_offset(bp, buffer_offset); 335 vecp->i_addr = xfs_buf_offset(bp, buffer_offset);
314 vecp->i_len = nbits * XFS_BLF_CHUNK; 336 vecp->i_len = nbits * XFS_BLF_CHUNK;
315 vecp->i_type = XLOG_REG_TYPE_BCHUNK; 337 vecp->i_type = XLOG_REG_TYPE_BCHUNK;
316 nvecs++; 338 nvecs++;
317 break; 339 break;
318 } else if (next_bit != last_bit + 1) { 340 } else if (next_bit != last_bit + 1) {
319 buffer_offset = first_bit * XFS_BLF_CHUNK; 341 buffer_offset = offset + first_bit * XFS_BLF_CHUNK;
320 vecp->i_addr = xfs_buf_offset(bp, buffer_offset); 342 vecp->i_addr = xfs_buf_offset(bp, buffer_offset);
321 vecp->i_len = nbits * XFS_BLF_CHUNK; 343 vecp->i_len = nbits * XFS_BLF_CHUNK;
322 vecp->i_type = XLOG_REG_TYPE_BCHUNK; 344 vecp->i_type = XLOG_REG_TYPE_BCHUNK;
@@ -325,14 +347,17 @@ xfs_buf_item_format(
325 first_bit = next_bit; 347 first_bit = next_bit;
326 last_bit = next_bit; 348 last_bit = next_bit;
327 nbits = 1; 349 nbits = 1;
328 } else if (xfs_buf_offset(bp, next_bit << XFS_BLF_SHIFT) != 350 } else if (xfs_buf_offset(bp, offset +
329 (xfs_buf_offset(bp, last_bit << XFS_BLF_SHIFT) + 351 (next_bit << XFS_BLF_SHIFT)) !=
352 (xfs_buf_offset(bp, offset +
353 (last_bit << XFS_BLF_SHIFT)) +
330 XFS_BLF_CHUNK)) { 354 XFS_BLF_CHUNK)) {
331 buffer_offset = first_bit * XFS_BLF_CHUNK; 355 buffer_offset = offset + first_bit * XFS_BLF_CHUNK;
332 vecp->i_addr = xfs_buf_offset(bp, buffer_offset); 356 vecp->i_addr = xfs_buf_offset(bp, buffer_offset);
333 vecp->i_len = nbits * XFS_BLF_CHUNK; 357 vecp->i_len = nbits * XFS_BLF_CHUNK;
334 vecp->i_type = XLOG_REG_TYPE_BCHUNK; 358 vecp->i_type = XLOG_REG_TYPE_BCHUNK;
335/* You would think we need to bump the nvecs here too, but we do not 359/*
360 * You would think we need to bump the nvecs here too, but we do not
336 * this number is used by recovery, and it gets confused by the boundary 361 * this number is used by recovery, and it gets confused by the boundary
337 * split here 362 * split here
338 * nvecs++; 363 * nvecs++;
@@ -347,6 +372,48 @@ xfs_buf_item_format(
347 } 372 }
348 } 373 }
349 bip->bli_format.blf_size = nvecs; 374 bip->bli_format.blf_size = nvecs;
375 return vecp;
376}
377
378/*
379 * This is called to fill in the vector of log iovecs for the
380 * given log buf item. It fills the first entry with a buf log
381 * format structure, and the rest point to contiguous chunks
382 * within the buffer.
383 */
384STATIC void
385xfs_buf_item_format(
386 struct xfs_log_item *lip,
387 struct xfs_log_iovec *vecp)
388{
389 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
390 struct xfs_buf *bp = bip->bli_buf;
391 uint offset = 0;
392 int i;
393
394 ASSERT(atomic_read(&bip->bli_refcount) > 0);
395 ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
396 (bip->bli_flags & XFS_BLI_STALE));
397
398 /*
399 * If it is an inode buffer, transfer the in-memory state to the
400 * format flags and clear the in-memory state. We do not transfer
401 * this state if the inode buffer allocation has not yet been committed
402 * to the log as setting the XFS_BLI_INODE_BUF flag will prevent
403 * correct replay of the inode allocation.
404 */
405 if (bip->bli_flags & XFS_BLI_INODE_BUF) {
406 if (!((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) &&
407 xfs_log_item_in_current_chkpt(lip)))
408 bip->bli_format.blf_flags |= XFS_BLF_INODE_BUF;
409 bip->bli_flags &= ~XFS_BLI_INODE_BUF;
410 }
411
412 for (i = 0; i < bip->bli_format_count; i++) {
413 vecp = xfs_buf_item_format_segment(bip, vecp, offset,
414 &bip->bli_formats[i]);
415 offset += bp->b_maps[i].bm_len;
416 }
350 417
351 /* 418 /*
352 * Check to make sure everything is consistent. 419 * Check to make sure everything is consistent.
@@ -622,6 +689,35 @@ static const struct xfs_item_ops xfs_buf_item_ops = {
622 .iop_committing = xfs_buf_item_committing 689 .iop_committing = xfs_buf_item_committing
623}; 690};
624 691
692STATIC int
693xfs_buf_item_get_format(
694 struct xfs_buf_log_item *bip,
695 int count)
696{
697 ASSERT(bip->bli_formats == NULL);
698 bip->bli_format_count = count;
699
700 if (count == 1) {
701 bip->bli_formats = &bip->bli_format;
702 return 0;
703 }
704
705 bip->bli_formats = kmem_zalloc(count * sizeof(struct xfs_buf_log_format),
706 KM_SLEEP);
707 if (!bip->bli_formats)
708 return ENOMEM;
709 return 0;
710}
711
712STATIC void
713xfs_buf_item_free_format(
714 struct xfs_buf_log_item *bip)
715{
716 if (bip->bli_formats != &bip->bli_format) {
717 kmem_free(bip->bli_formats);
718 bip->bli_formats = NULL;
719 }
720}
625 721
626/* 722/*
627 * Allocate a new buf log item to go with the given buffer. 723 * Allocate a new buf log item to go with the given buffer.
@@ -639,6 +735,8 @@ xfs_buf_item_init(
639 xfs_buf_log_item_t *bip; 735 xfs_buf_log_item_t *bip;
640 int chunks; 736 int chunks;
641 int map_size; 737 int map_size;
738 int error;
739 int i;
642 740
643 /* 741 /*
644 * Check to see if there is already a buf log item for 742 * Check to see if there is already a buf log item for
@@ -650,25 +748,33 @@ xfs_buf_item_init(
650 if (lip != NULL && lip->li_type == XFS_LI_BUF) 748 if (lip != NULL && lip->li_type == XFS_LI_BUF)
651 return; 749 return;
652 750
653 /* 751 bip = kmem_zone_zalloc(xfs_buf_item_zone, KM_SLEEP);
654 * chunks is the number of XFS_BLF_CHUNK size pieces
655 * the buffer can be divided into. Make sure not to
656 * truncate any pieces. map_size is the size of the
657 * bitmap needed to describe the chunks of the buffer.
658 */
659 chunks = (int)((BBTOB(bp->b_length) + (XFS_BLF_CHUNK - 1)) >>
660 XFS_BLF_SHIFT);
661 map_size = (int)((chunks + NBWORD) >> BIT_TO_WORD_SHIFT);
662
663 bip = (xfs_buf_log_item_t*)kmem_zone_zalloc(xfs_buf_item_zone,
664 KM_SLEEP);
665 xfs_log_item_init(mp, &bip->bli_item, XFS_LI_BUF, &xfs_buf_item_ops); 752 xfs_log_item_init(mp, &bip->bli_item, XFS_LI_BUF, &xfs_buf_item_ops);
666 bip->bli_buf = bp; 753 bip->bli_buf = bp;
667 xfs_buf_hold(bp); 754 xfs_buf_hold(bp);
668 bip->bli_format.blf_type = XFS_LI_BUF; 755
669 bip->bli_format.blf_blkno = (__int64_t)XFS_BUF_ADDR(bp); 756 /*
670 bip->bli_format.blf_len = (ushort)bp->b_length; 757 * chunks is the number of XFS_BLF_CHUNK size pieces the buffer
671 bip->bli_format.blf_map_size = map_size; 758 * can be divided into. Make sure not to truncate any pieces.
759 * map_size is the size of the bitmap needed to describe the
760 * chunks of the buffer.
761 *
762 * Discontiguous buffer support follows the layout of the underlying
763 * buffer. This makes the implementation as simple as possible.
764 */
765 error = xfs_buf_item_get_format(bip, bp->b_map_count);
766 ASSERT(error == 0);
767
768 for (i = 0; i < bip->bli_format_count; i++) {
769 chunks = DIV_ROUND_UP(BBTOB(bp->b_maps[i].bm_len),
770 XFS_BLF_CHUNK);
771 map_size = DIV_ROUND_UP(chunks, NBWORD);
772
773 bip->bli_formats[i].blf_type = XFS_LI_BUF;
774 bip->bli_formats[i].blf_blkno = bp->b_maps[i].bm_bn;
775 bip->bli_formats[i].blf_len = bp->b_maps[i].bm_len;
776 bip->bli_formats[i].blf_map_size = map_size;
777 }
672 778
673#ifdef XFS_TRANS_DEBUG 779#ifdef XFS_TRANS_DEBUG
674 /* 780 /*
@@ -699,10 +805,11 @@ xfs_buf_item_init(
699 * item's bitmap. 805 * item's bitmap.
700 */ 806 */
701void 807void
702xfs_buf_item_log( 808xfs_buf_item_log_segment(
703 xfs_buf_log_item_t *bip, 809 struct xfs_buf_log_item *bip,
704 uint first, 810 uint first,
705 uint last) 811 uint last,
812 uint *map)
706{ 813{
707 uint first_bit; 814 uint first_bit;
708 uint last_bit; 815 uint last_bit;
@@ -715,12 +822,6 @@ xfs_buf_item_log(
715 uint mask; 822 uint mask;
716 823
717 /* 824 /*
718 * Mark the item as having some dirty data for
719 * quick reference in xfs_buf_item_dirty.
720 */
721 bip->bli_flags |= XFS_BLI_DIRTY;
722
723 /*
724 * Convert byte offsets to bit numbers. 825 * Convert byte offsets to bit numbers.
725 */ 826 */
726 first_bit = first >> XFS_BLF_SHIFT; 827 first_bit = first >> XFS_BLF_SHIFT;
@@ -736,7 +837,7 @@ xfs_buf_item_log(
736 * to set a bit in. 837 * to set a bit in.
737 */ 838 */
738 word_num = first_bit >> BIT_TO_WORD_SHIFT; 839 word_num = first_bit >> BIT_TO_WORD_SHIFT;
739 wordp = &(bip->bli_format.blf_data_map[word_num]); 840 wordp = &map[word_num];
740 841
741 /* 842 /*
742 * Calculate the starting bit in the first word. 843 * Calculate the starting bit in the first word.
@@ -783,6 +884,51 @@ xfs_buf_item_log(
783 xfs_buf_item_log_debug(bip, first, last); 884 xfs_buf_item_log_debug(bip, first, last);
784} 885}
785 886
887/*
888 * Mark bytes first through last inclusive as dirty in the buf
889 * item's bitmap.
890 */
891void
892xfs_buf_item_log(
893 xfs_buf_log_item_t *bip,
894 uint first,
895 uint last)
896{
897 int i;
898 uint start;
899 uint end;
900 struct xfs_buf *bp = bip->bli_buf;
901
902 /*
903 * Mark the item as having some dirty data for
904 * quick reference in xfs_buf_item_dirty.
905 */
906 bip->bli_flags |= XFS_BLI_DIRTY;
907
908 /*
909 * walk each buffer segment and mark them dirty appropriately.
910 */
911 start = 0;
912 for (i = 0; i < bip->bli_format_count; i++) {
913 if (start > last)
914 break;
915 end = start + BBTOB(bp->b_maps[i].bm_len);
916 if (first > end) {
917 start += BBTOB(bp->b_maps[i].bm_len);
918 continue;
919 }
920 if (first < start)
921 first = start;
922 if (end > last)
923 end = last;
924
925 xfs_buf_item_log_segment(bip, first, end,
926 &bip->bli_formats[i].blf_data_map[0]);
927
928 start += bp->b_maps[i].bm_len;
929 }
930}
931
786 932
787/* 933/*
788 * Return 1 if the buffer has some data that has been logged (at any 934 * Return 1 if the buffer has some data that has been logged (at any
@@ -804,6 +950,7 @@ xfs_buf_item_free(
804 kmem_free(bip->bli_logged); 950 kmem_free(bip->bli_logged);
805#endif /* XFS_TRANS_DEBUG */ 951#endif /* XFS_TRANS_DEBUG */
806 952
953 xfs_buf_item_free_format(bip);
807 kmem_zone_free(xfs_buf_item_zone, bip); 954 kmem_zone_free(xfs_buf_item_zone, bip);
808} 955}
809 956
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
index b6ecd2061e7c..6850f49f4af3 100644
--- a/fs/xfs/xfs_buf_item.h
+++ b/fs/xfs/xfs_buf_item.h
@@ -21,23 +21,6 @@
21extern kmem_zone_t *xfs_buf_item_zone; 21extern kmem_zone_t *xfs_buf_item_zone;
22 22
23/* 23/*
24 * This is the structure used to lay out a buf log item in the
25 * log. The data map describes which 128 byte chunks of the buffer
26 * have been logged.
27 * For 6.2 and beyond, this is XFS_LI_BUF. We use this to log everything.
28 */
29typedef struct xfs_buf_log_format {
30 unsigned short blf_type; /* buf log item type indicator */
31 unsigned short blf_size; /* size of this item */
32 ushort blf_flags; /* misc state */
33 ushort blf_len; /* number of blocks in this buf */
34 __int64_t blf_blkno; /* starting blkno of this buf */
35 unsigned int blf_map_size; /* size of data bitmap in words */
36 unsigned int blf_data_map[1];/* variable size bitmap of */
37 /* regions of buffer in this item */
38} xfs_buf_log_format_t;
39
40/*
41 * This flag indicates that the buffer contains on disk inodes 24 * This flag indicates that the buffer contains on disk inodes
42 * and requires special recovery handling. 25 * and requires special recovery handling.
43 */ 26 */
@@ -61,6 +44,23 @@ typedef struct xfs_buf_log_format {
61#define NBWORD (NBBY * sizeof(unsigned int)) 44#define NBWORD (NBBY * sizeof(unsigned int))
62 45
63/* 46/*
47 * This is the structure used to lay out a buf log item in the
48 * log. The data map describes which 128 byte chunks of the buffer
49 * have been logged.
50 */
51#define XFS_BLF_DATAMAP_SIZE ((XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK) / NBWORD)
52
53typedef struct xfs_buf_log_format {
54 unsigned short blf_type; /* buf log item type indicator */
55 unsigned short blf_size; /* size of this item */
56 ushort blf_flags; /* misc state */
57 ushort blf_len; /* number of blocks in this buf */
58 __int64_t blf_blkno; /* starting blkno of this buf */
59 unsigned int blf_map_size; /* used size of data bitmap in words */
60 unsigned int blf_data_map[XFS_BLF_DATAMAP_SIZE]; /* dirty bitmap */
61} xfs_buf_log_format_t;
62
63/*
64 * buf log item flags 64 * buf log item flags
65 */ 65 */
66#define XFS_BLI_HOLD 0x01 66#define XFS_BLI_HOLD 0x01
@@ -102,7 +102,9 @@ typedef struct xfs_buf_log_item {
102 char *bli_orig; /* original buffer copy */ 102 char *bli_orig; /* original buffer copy */
103 char *bli_logged; /* bytes logged (bitmap) */ 103 char *bli_logged; /* bytes logged (bitmap) */
104#endif 104#endif
105 xfs_buf_log_format_t bli_format; /* in-log header */ 105 int bli_format_count; /* count of headers */
106 struct xfs_buf_log_format *bli_formats; /* array of in-log header ptrs */
107 struct xfs_buf_log_format bli_format; /* embedded in-log header */
106} xfs_buf_log_item_t; 108} xfs_buf_log_item_t;
107 109
108void xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *); 110void xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 015b946c5808..7bfb7dd334fc 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -83,9 +83,9 @@ STATIC void xfs_da_node_unbalance(xfs_da_state_t *state,
83/* 83/*
84 * Utility routines. 84 * Utility routines.
85 */ 85 */
86STATIC uint xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count); 86STATIC uint xfs_da_node_lasthash(struct xfs_buf *bp, int *count);
87STATIC int xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp); 87STATIC int xfs_da_node_order(struct xfs_buf *node1_bp,
88STATIC xfs_dabuf_t *xfs_da_buf_make(int nbuf, xfs_buf_t **bps); 88 struct xfs_buf *node2_bp);
89STATIC int xfs_da_blk_unlink(xfs_da_state_t *state, 89STATIC int xfs_da_blk_unlink(xfs_da_state_t *state,
90 xfs_da_state_blk_t *drop_blk, 90 xfs_da_state_blk_t *drop_blk,
91 xfs_da_state_blk_t *save_blk); 91 xfs_da_state_blk_t *save_blk);
@@ -100,10 +100,10 @@ STATIC void xfs_da_state_kill_altpath(xfs_da_state_t *state);
100 */ 100 */
101int 101int
102xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level, 102xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
103 xfs_dabuf_t **bpp, int whichfork) 103 struct xfs_buf **bpp, int whichfork)
104{ 104{
105 xfs_da_intnode_t *node; 105 xfs_da_intnode_t *node;
106 xfs_dabuf_t *bp; 106 struct xfs_buf *bp;
107 int error; 107 int error;
108 xfs_trans_t *tp; 108 xfs_trans_t *tp;
109 109
@@ -114,7 +114,7 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
114 if (error) 114 if (error)
115 return(error); 115 return(error);
116 ASSERT(bp != NULL); 116 ASSERT(bp != NULL);
117 node = bp->data; 117 node = bp->b_addr;
118 node->hdr.info.forw = 0; 118 node->hdr.info.forw = 0;
119 node->hdr.info.back = 0; 119 node->hdr.info.back = 0;
120 node->hdr.info.magic = cpu_to_be16(XFS_DA_NODE_MAGIC); 120 node->hdr.info.magic = cpu_to_be16(XFS_DA_NODE_MAGIC);
@@ -122,7 +122,7 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
122 node->hdr.count = 0; 122 node->hdr.count = 0;
123 node->hdr.level = cpu_to_be16(level); 123 node->hdr.level = cpu_to_be16(level);
124 124
125 xfs_da_log_buf(tp, bp, 125 xfs_trans_log_buf(tp, bp,
126 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); 126 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
127 127
128 *bpp = bp; 128 *bpp = bp;
@@ -138,7 +138,7 @@ xfs_da_split(xfs_da_state_t *state)
138{ 138{
139 xfs_da_state_blk_t *oldblk, *newblk, *addblk; 139 xfs_da_state_blk_t *oldblk, *newblk, *addblk;
140 xfs_da_intnode_t *node; 140 xfs_da_intnode_t *node;
141 xfs_dabuf_t *bp; 141 struct xfs_buf *bp;
142 int max, action, error, i; 142 int max, action, error, i;
143 143
144 trace_xfs_da_split(state->args); 144 trace_xfs_da_split(state->args);
@@ -203,7 +203,6 @@ xfs_da_split(xfs_da_state_t *state)
203 case XFS_DA_NODE_MAGIC: 203 case XFS_DA_NODE_MAGIC:
204 error = xfs_da_node_split(state, oldblk, newblk, addblk, 204 error = xfs_da_node_split(state, oldblk, newblk, addblk,
205 max - i, &action); 205 max - i, &action);
206 xfs_da_buf_done(addblk->bp);
207 addblk->bp = NULL; 206 addblk->bp = NULL;
208 if (error) 207 if (error)
209 return(error); /* GROT: dir is inconsistent */ 208 return(error); /* GROT: dir is inconsistent */
@@ -221,13 +220,6 @@ xfs_da_split(xfs_da_state_t *state)
221 * Update the btree to show the new hashval for this child. 220 * Update the btree to show the new hashval for this child.
222 */ 221 */
223 xfs_da_fixhashpath(state, &state->path); 222 xfs_da_fixhashpath(state, &state->path);
224 /*
225 * If we won't need this block again, it's getting dropped
226 * from the active path by the loop control, so we need
227 * to mark it done now.
228 */
229 if (i > 0 || !addblk)
230 xfs_da_buf_done(oldblk->bp);
231 } 223 }
232 if (!addblk) 224 if (!addblk)
233 return(0); 225 return(0);
@@ -239,8 +231,6 @@ xfs_da_split(xfs_da_state_t *state)
239 oldblk = &state->path.blk[0]; 231 oldblk = &state->path.blk[0];
240 error = xfs_da_root_split(state, oldblk, addblk); 232 error = xfs_da_root_split(state, oldblk, addblk);
241 if (error) { 233 if (error) {
242 xfs_da_buf_done(oldblk->bp);
243 xfs_da_buf_done(addblk->bp);
244 addblk->bp = NULL; 234 addblk->bp = NULL;
245 return(error); /* GROT: dir is inconsistent */ 235 return(error); /* GROT: dir is inconsistent */
246 } 236 }
@@ -252,7 +242,7 @@ xfs_da_split(xfs_da_state_t *state)
252 * and the original block 0 could be at any position in the list. 242 * and the original block 0 could be at any position in the list.
253 */ 243 */
254 244
255 node = oldblk->bp->data; 245 node = oldblk->bp->b_addr;
256 if (node->hdr.info.forw) { 246 if (node->hdr.info.forw) {
257 if (be32_to_cpu(node->hdr.info.forw) == addblk->blkno) { 247 if (be32_to_cpu(node->hdr.info.forw) == addblk->blkno) {
258 bp = addblk->bp; 248 bp = addblk->bp;
@@ -260,13 +250,13 @@ xfs_da_split(xfs_da_state_t *state)
260 ASSERT(state->extravalid); 250 ASSERT(state->extravalid);
261 bp = state->extrablk.bp; 251 bp = state->extrablk.bp;
262 } 252 }
263 node = bp->data; 253 node = bp->b_addr;
264 node->hdr.info.back = cpu_to_be32(oldblk->blkno); 254 node->hdr.info.back = cpu_to_be32(oldblk->blkno);
265 xfs_da_log_buf(state->args->trans, bp, 255 xfs_trans_log_buf(state->args->trans, bp,
266 XFS_DA_LOGRANGE(node, &node->hdr.info, 256 XFS_DA_LOGRANGE(node, &node->hdr.info,
267 sizeof(node->hdr.info))); 257 sizeof(node->hdr.info)));
268 } 258 }
269 node = oldblk->bp->data; 259 node = oldblk->bp->b_addr;
270 if (node->hdr.info.back) { 260 if (node->hdr.info.back) {
271 if (be32_to_cpu(node->hdr.info.back) == addblk->blkno) { 261 if (be32_to_cpu(node->hdr.info.back) == addblk->blkno) {
272 bp = addblk->bp; 262 bp = addblk->bp;
@@ -274,14 +264,12 @@ xfs_da_split(xfs_da_state_t *state)
274 ASSERT(state->extravalid); 264 ASSERT(state->extravalid);
275 bp = state->extrablk.bp; 265 bp = state->extrablk.bp;
276 } 266 }
277 node = bp->data; 267 node = bp->b_addr;
278 node->hdr.info.forw = cpu_to_be32(oldblk->blkno); 268 node->hdr.info.forw = cpu_to_be32(oldblk->blkno);
279 xfs_da_log_buf(state->args->trans, bp, 269 xfs_trans_log_buf(state->args->trans, bp,
280 XFS_DA_LOGRANGE(node, &node->hdr.info, 270 XFS_DA_LOGRANGE(node, &node->hdr.info,
281 sizeof(node->hdr.info))); 271 sizeof(node->hdr.info)));
282 } 272 }
283 xfs_da_buf_done(oldblk->bp);
284 xfs_da_buf_done(addblk->bp);
285 addblk->bp = NULL; 273 addblk->bp = NULL;
286 return(0); 274 return(0);
287} 275}
@@ -298,7 +286,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
298 xfs_da_intnode_t *node, *oldroot; 286 xfs_da_intnode_t *node, *oldroot;
299 xfs_da_args_t *args; 287 xfs_da_args_t *args;
300 xfs_dablk_t blkno; 288 xfs_dablk_t blkno;
301 xfs_dabuf_t *bp; 289 struct xfs_buf *bp;
302 int error, size; 290 int error, size;
303 xfs_inode_t *dp; 291 xfs_inode_t *dp;
304 xfs_trans_t *tp; 292 xfs_trans_t *tp;
@@ -323,8 +311,8 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
323 if (error) 311 if (error)
324 return(error); 312 return(error);
325 ASSERT(bp != NULL); 313 ASSERT(bp != NULL);
326 node = bp->data; 314 node = bp->b_addr;
327 oldroot = blk1->bp->data; 315 oldroot = blk1->bp->b_addr;
328 if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) { 316 if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) {
329 size = (int)((char *)&oldroot->btree[be16_to_cpu(oldroot->hdr.count)] - 317 size = (int)((char *)&oldroot->btree[be16_to_cpu(oldroot->hdr.count)] -
330 (char *)oldroot); 318 (char *)oldroot);
@@ -335,8 +323,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
335 (char *)leaf); 323 (char *)leaf);
336 } 324 }
337 memcpy(node, oldroot, size); 325 memcpy(node, oldroot, size);
338 xfs_da_log_buf(tp, bp, 0, size - 1); 326 xfs_trans_log_buf(tp, bp, 0, size - 1);
339 xfs_da_buf_done(blk1->bp);
340 blk1->bp = bp; 327 blk1->bp = bp;
341 blk1->blkno = blkno; 328 blk1->blkno = blkno;
342 329
@@ -348,7 +335,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
348 be16_to_cpu(node->hdr.level) + 1, &bp, args->whichfork); 335 be16_to_cpu(node->hdr.level) + 1, &bp, args->whichfork);
349 if (error) 336 if (error)
350 return(error); 337 return(error);
351 node = bp->data; 338 node = bp->b_addr;
352 node->btree[0].hashval = cpu_to_be32(blk1->hashval); 339 node->btree[0].hashval = cpu_to_be32(blk1->hashval);
353 node->btree[0].before = cpu_to_be32(blk1->blkno); 340 node->btree[0].before = cpu_to_be32(blk1->blkno);
354 node->btree[1].hashval = cpu_to_be32(blk2->hashval); 341 node->btree[1].hashval = cpu_to_be32(blk2->hashval);
@@ -365,10 +352,9 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
365#endif 352#endif
366 353
367 /* Header is already logged by xfs_da_node_create */ 354 /* Header is already logged by xfs_da_node_create */
368 xfs_da_log_buf(tp, bp, 355 xfs_trans_log_buf(tp, bp,
369 XFS_DA_LOGRANGE(node, node->btree, 356 XFS_DA_LOGRANGE(node, node->btree,
370 sizeof(xfs_da_node_entry_t) * 2)); 357 sizeof(xfs_da_node_entry_t) * 2));
371 xfs_da_buf_done(bp);
372 358
373 return(0); 359 return(0);
374} 360}
@@ -389,7 +375,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
389 375
390 trace_xfs_da_node_split(state->args); 376 trace_xfs_da_node_split(state->args);
391 377
392 node = oldblk->bp->data; 378 node = oldblk->bp->b_addr;
393 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 379 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
394 380
395 /* 381 /*
@@ -436,7 +422,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
436 * 422 *
437 * If we had double-split op below us, then add the extra block too. 423 * If we had double-split op below us, then add the extra block too.
438 */ 424 */
439 node = oldblk->bp->data; 425 node = oldblk->bp->b_addr;
440 if (oldblk->index <= be16_to_cpu(node->hdr.count)) { 426 if (oldblk->index <= be16_to_cpu(node->hdr.count)) {
441 oldblk->index++; 427 oldblk->index++;
442 xfs_da_node_add(state, oldblk, addblk); 428 xfs_da_node_add(state, oldblk, addblk);
@@ -477,8 +463,8 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
477 463
478 trace_xfs_da_node_rebalance(state->args); 464 trace_xfs_da_node_rebalance(state->args);
479 465
480 node1 = blk1->bp->data; 466 node1 = blk1->bp->b_addr;
481 node2 = blk2->bp->data; 467 node2 = blk2->bp->b_addr;
482 /* 468 /*
483 * Figure out how many entries need to move, and in which direction. 469 * Figure out how many entries need to move, and in which direction.
484 * Swap the nodes around if that makes it simpler. 470 * Swap the nodes around if that makes it simpler.
@@ -532,7 +518,7 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
532 btree_d = &node1->btree[be16_to_cpu(node1->hdr.count)]; 518 btree_d = &node1->btree[be16_to_cpu(node1->hdr.count)];
533 memcpy(btree_d, btree_s, tmp); 519 memcpy(btree_d, btree_s, tmp);
534 be16_add_cpu(&node1->hdr.count, count); 520 be16_add_cpu(&node1->hdr.count, count);
535 xfs_da_log_buf(tp, blk1->bp, 521 xfs_trans_log_buf(tp, blk1->bp,
536 XFS_DA_LOGRANGE(node1, btree_d, tmp)); 522 XFS_DA_LOGRANGE(node1, btree_d, tmp));
537 523
538 /* 524 /*
@@ -549,9 +535,9 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
549 /* 535 /*
550 * Log header of node 1 and all current bits of node 2. 536 * Log header of node 1 and all current bits of node 2.
551 */ 537 */
552 xfs_da_log_buf(tp, blk1->bp, 538 xfs_trans_log_buf(tp, blk1->bp,
553 XFS_DA_LOGRANGE(node1, &node1->hdr, sizeof(node1->hdr))); 539 XFS_DA_LOGRANGE(node1, &node1->hdr, sizeof(node1->hdr)));
554 xfs_da_log_buf(tp, blk2->bp, 540 xfs_trans_log_buf(tp, blk2->bp,
555 XFS_DA_LOGRANGE(node2, &node2->hdr, 541 XFS_DA_LOGRANGE(node2, &node2->hdr,
556 sizeof(node2->hdr) + 542 sizeof(node2->hdr) +
557 sizeof(node2->btree[0]) * be16_to_cpu(node2->hdr.count))); 543 sizeof(node2->btree[0]) * be16_to_cpu(node2->hdr.count)));
@@ -560,8 +546,8 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
560 * Record the last hashval from each block for upward propagation. 546 * Record the last hashval from each block for upward propagation.
561 * (note: don't use the swapped node pointers) 547 * (note: don't use the swapped node pointers)
562 */ 548 */
563 node1 = blk1->bp->data; 549 node1 = blk1->bp->b_addr;
564 node2 = blk2->bp->data; 550 node2 = blk2->bp->b_addr;
565 blk1->hashval = be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval); 551 blk1->hashval = be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval);
566 blk2->hashval = be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval); 552 blk2->hashval = be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval);
567 553
@@ -587,7 +573,7 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
587 573
588 trace_xfs_da_node_add(state->args); 574 trace_xfs_da_node_add(state->args);
589 575
590 node = oldblk->bp->data; 576 node = oldblk->bp->b_addr;
591 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 577 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
592 ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count))); 578 ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count)));
593 ASSERT(newblk->blkno != 0); 579 ASSERT(newblk->blkno != 0);
@@ -606,10 +592,10 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
606 } 592 }
607 btree->hashval = cpu_to_be32(newblk->hashval); 593 btree->hashval = cpu_to_be32(newblk->hashval);
608 btree->before = cpu_to_be32(newblk->blkno); 594 btree->before = cpu_to_be32(newblk->blkno);
609 xfs_da_log_buf(state->args->trans, oldblk->bp, 595 xfs_trans_log_buf(state->args->trans, oldblk->bp,
610 XFS_DA_LOGRANGE(node, btree, tmp + sizeof(*btree))); 596 XFS_DA_LOGRANGE(node, btree, tmp + sizeof(*btree)));
611 be16_add_cpu(&node->hdr.count, 1); 597 be16_add_cpu(&node->hdr.count, 1);
612 xfs_da_log_buf(state->args->trans, oldblk->bp, 598 xfs_trans_log_buf(state->args->trans, oldblk->bp,
613 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); 599 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
614 600
615 /* 601 /*
@@ -735,7 +721,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
735 xfs_da_intnode_t *oldroot; 721 xfs_da_intnode_t *oldroot;
736 xfs_da_args_t *args; 722 xfs_da_args_t *args;
737 xfs_dablk_t child; 723 xfs_dablk_t child;
738 xfs_dabuf_t *bp; 724 struct xfs_buf *bp;
739 int error; 725 int error;
740 726
741 trace_xfs_da_root_join(state->args); 727 trace_xfs_da_root_join(state->args);
@@ -743,7 +729,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
743 args = state->args; 729 args = state->args;
744 ASSERT(args != NULL); 730 ASSERT(args != NULL);
745 ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC); 731 ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC);
746 oldroot = root_blk->bp->data; 732 oldroot = root_blk->bp->b_addr;
747 ASSERT(oldroot->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 733 ASSERT(oldroot->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
748 ASSERT(!oldroot->hdr.info.forw); 734 ASSERT(!oldroot->hdr.info.forw);
749 ASSERT(!oldroot->hdr.info.back); 735 ASSERT(!oldroot->hdr.info.back);
@@ -765,11 +751,11 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
765 if (error) 751 if (error)
766 return(error); 752 return(error);
767 ASSERT(bp != NULL); 753 ASSERT(bp != NULL);
768 xfs_da_blkinfo_onlychild_validate(bp->data, 754 xfs_da_blkinfo_onlychild_validate(bp->b_addr,
769 be16_to_cpu(oldroot->hdr.level)); 755 be16_to_cpu(oldroot->hdr.level));
770 756
771 memcpy(root_blk->bp->data, bp->data, state->blocksize); 757 memcpy(root_blk->bp->b_addr, bp->b_addr, state->blocksize);
772 xfs_da_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1); 758 xfs_trans_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1);
773 error = xfs_da_shrink_inode(args, child, bp); 759 error = xfs_da_shrink_inode(args, child, bp);
774 return(error); 760 return(error);
775} 761}
@@ -791,7 +777,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
791 xfs_da_blkinfo_t *info; 777 xfs_da_blkinfo_t *info;
792 int count, forward, error, retval, i; 778 int count, forward, error, retval, i;
793 xfs_dablk_t blkno; 779 xfs_dablk_t blkno;
794 xfs_dabuf_t *bp; 780 struct xfs_buf *bp;
795 781
796 /* 782 /*
797 * Check for the degenerate case of the block being over 50% full. 783 * Check for the degenerate case of the block being over 50% full.
@@ -799,7 +785,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
799 * to coalesce with a sibling. 785 * to coalesce with a sibling.
800 */ 786 */
801 blk = &state->path.blk[ state->path.active-1 ]; 787 blk = &state->path.blk[ state->path.active-1 ];
802 info = blk->bp->data; 788 info = blk->bp->b_addr;
803 ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 789 ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
804 node = (xfs_da_intnode_t *)info; 790 node = (xfs_da_intnode_t *)info;
805 count = be16_to_cpu(node->hdr.count); 791 count = be16_to_cpu(node->hdr.count);
@@ -859,10 +845,10 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
859 count = state->node_ents; 845 count = state->node_ents;
860 count -= state->node_ents >> 2; 846 count -= state->node_ents >> 2;
861 count -= be16_to_cpu(node->hdr.count); 847 count -= be16_to_cpu(node->hdr.count);
862 node = bp->data; 848 node = bp->b_addr;
863 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 849 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
864 count -= be16_to_cpu(node->hdr.count); 850 count -= be16_to_cpu(node->hdr.count);
865 xfs_da_brelse(state->args->trans, bp); 851 xfs_trans_brelse(state->args->trans, bp);
866 if (count >= 0) 852 if (count >= 0)
867 break; /* fits with at least 25% to spare */ 853 break; /* fits with at least 25% to spare */
868 } 854 }
@@ -934,14 +920,14 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path)
934 break; 920 break;
935 } 921 }
936 for (blk--, level--; level >= 0; blk--, level--) { 922 for (blk--, level--; level >= 0; blk--, level--) {
937 node = blk->bp->data; 923 node = blk->bp->b_addr;
938 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 924 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
939 btree = &node->btree[ blk->index ]; 925 btree = &node->btree[ blk->index ];
940 if (be32_to_cpu(btree->hashval) == lasthash) 926 if (be32_to_cpu(btree->hashval) == lasthash)
941 break; 927 break;
942 blk->hashval = lasthash; 928 blk->hashval = lasthash;
943 btree->hashval = cpu_to_be32(lasthash); 929 btree->hashval = cpu_to_be32(lasthash);
944 xfs_da_log_buf(state->args->trans, blk->bp, 930 xfs_trans_log_buf(state->args->trans, blk->bp,
945 XFS_DA_LOGRANGE(node, btree, sizeof(*btree))); 931 XFS_DA_LOGRANGE(node, btree, sizeof(*btree)));
946 932
947 lasthash = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval); 933 lasthash = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
@@ -960,7 +946,7 @@ xfs_da_node_remove(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk)
960 946
961 trace_xfs_da_node_remove(state->args); 947 trace_xfs_da_node_remove(state->args);
962 948
963 node = drop_blk->bp->data; 949 node = drop_blk->bp->b_addr;
964 ASSERT(drop_blk->index < be16_to_cpu(node->hdr.count)); 950 ASSERT(drop_blk->index < be16_to_cpu(node->hdr.count));
965 ASSERT(drop_blk->index >= 0); 951 ASSERT(drop_blk->index >= 0);
966 952
@@ -972,15 +958,15 @@ xfs_da_node_remove(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk)
972 tmp = be16_to_cpu(node->hdr.count) - drop_blk->index - 1; 958 tmp = be16_to_cpu(node->hdr.count) - drop_blk->index - 1;
973 tmp *= (uint)sizeof(xfs_da_node_entry_t); 959 tmp *= (uint)sizeof(xfs_da_node_entry_t);
974 memmove(btree, btree + 1, tmp); 960 memmove(btree, btree + 1, tmp);
975 xfs_da_log_buf(state->args->trans, drop_blk->bp, 961 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
976 XFS_DA_LOGRANGE(node, btree, tmp)); 962 XFS_DA_LOGRANGE(node, btree, tmp));
977 btree = &node->btree[be16_to_cpu(node->hdr.count)-1]; 963 btree = &node->btree[be16_to_cpu(node->hdr.count)-1];
978 } 964 }
979 memset((char *)btree, 0, sizeof(xfs_da_node_entry_t)); 965 memset((char *)btree, 0, sizeof(xfs_da_node_entry_t));
980 xfs_da_log_buf(state->args->trans, drop_blk->bp, 966 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
981 XFS_DA_LOGRANGE(node, btree, sizeof(*btree))); 967 XFS_DA_LOGRANGE(node, btree, sizeof(*btree)));
982 be16_add_cpu(&node->hdr.count, -1); 968 be16_add_cpu(&node->hdr.count, -1);
983 xfs_da_log_buf(state->args->trans, drop_blk->bp, 969 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
984 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); 970 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
985 971
986 /* 972 /*
@@ -1005,8 +991,8 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1005 991
1006 trace_xfs_da_node_unbalance(state->args); 992 trace_xfs_da_node_unbalance(state->args);
1007 993
1008 drop_node = drop_blk->bp->data; 994 drop_node = drop_blk->bp->b_addr;
1009 save_node = save_blk->bp->data; 995 save_node = save_blk->bp->b_addr;
1010 ASSERT(drop_node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 996 ASSERT(drop_node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
1011 ASSERT(save_node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 997 ASSERT(save_node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
1012 tp = state->args->trans; 998 tp = state->args->trans;
@@ -1023,13 +1009,13 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1023 tmp = be16_to_cpu(save_node->hdr.count) * (uint)sizeof(xfs_da_node_entry_t); 1009 tmp = be16_to_cpu(save_node->hdr.count) * (uint)sizeof(xfs_da_node_entry_t);
1024 memmove(btree, &save_node->btree[0], tmp); 1010 memmove(btree, &save_node->btree[0], tmp);
1025 btree = &save_node->btree[0]; 1011 btree = &save_node->btree[0];
1026 xfs_da_log_buf(tp, save_blk->bp, 1012 xfs_trans_log_buf(tp, save_blk->bp,
1027 XFS_DA_LOGRANGE(save_node, btree, 1013 XFS_DA_LOGRANGE(save_node, btree,
1028 (be16_to_cpu(save_node->hdr.count) + be16_to_cpu(drop_node->hdr.count)) * 1014 (be16_to_cpu(save_node->hdr.count) + be16_to_cpu(drop_node->hdr.count)) *
1029 sizeof(xfs_da_node_entry_t))); 1015 sizeof(xfs_da_node_entry_t)));
1030 } else { 1016 } else {
1031 btree = &save_node->btree[be16_to_cpu(save_node->hdr.count)]; 1017 btree = &save_node->btree[be16_to_cpu(save_node->hdr.count)];
1032 xfs_da_log_buf(tp, save_blk->bp, 1018 xfs_trans_log_buf(tp, save_blk->bp,
1033 XFS_DA_LOGRANGE(save_node, btree, 1019 XFS_DA_LOGRANGE(save_node, btree,
1034 be16_to_cpu(drop_node->hdr.count) * 1020 be16_to_cpu(drop_node->hdr.count) *
1035 sizeof(xfs_da_node_entry_t))); 1021 sizeof(xfs_da_node_entry_t)));
@@ -1042,7 +1028,7 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1042 memcpy(btree, &drop_node->btree[0], tmp); 1028 memcpy(btree, &drop_node->btree[0], tmp);
1043 be16_add_cpu(&save_node->hdr.count, be16_to_cpu(drop_node->hdr.count)); 1029 be16_add_cpu(&save_node->hdr.count, be16_to_cpu(drop_node->hdr.count));
1044 1030
1045 xfs_da_log_buf(tp, save_blk->bp, 1031 xfs_trans_log_buf(tp, save_blk->bp,
1046 XFS_DA_LOGRANGE(save_node, &save_node->hdr, 1032 XFS_DA_LOGRANGE(save_node, &save_node->hdr,
1047 sizeof(save_node->hdr))); 1033 sizeof(save_node->hdr)));
1048 1034
@@ -1100,7 +1086,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
1100 state->path.active--; 1086 state->path.active--;
1101 return(error); 1087 return(error);
1102 } 1088 }
1103 curr = blk->bp->data; 1089 curr = blk->bp->b_addr;
1104 blk->magic = be16_to_cpu(curr->magic); 1090 blk->magic = be16_to_cpu(curr->magic);
1105 ASSERT(blk->magic == XFS_DA_NODE_MAGIC || 1091 ASSERT(blk->magic == XFS_DA_NODE_MAGIC ||
1106 blk->magic == XFS_DIR2_LEAFN_MAGIC || 1092 blk->magic == XFS_DIR2_LEAFN_MAGIC ||
@@ -1110,7 +1096,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
1110 * Search an intermediate node for a match. 1096 * Search an intermediate node for a match.
1111 */ 1097 */
1112 if (blk->magic == XFS_DA_NODE_MAGIC) { 1098 if (blk->magic == XFS_DA_NODE_MAGIC) {
1113 node = blk->bp->data; 1099 node = blk->bp->b_addr;
1114 max = be16_to_cpu(node->hdr.count); 1100 max = be16_to_cpu(node->hdr.count);
1115 blk->hashval = be32_to_cpu(node->btree[max-1].hashval); 1101 blk->hashval = be32_to_cpu(node->btree[max-1].hashval);
1116 1102
@@ -1216,15 +1202,15 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1216 xfs_da_blkinfo_t *old_info, *new_info, *tmp_info; 1202 xfs_da_blkinfo_t *old_info, *new_info, *tmp_info;
1217 xfs_da_args_t *args; 1203 xfs_da_args_t *args;
1218 int before=0, error; 1204 int before=0, error;
1219 xfs_dabuf_t *bp; 1205 struct xfs_buf *bp;
1220 1206
1221 /* 1207 /*
1222 * Set up environment. 1208 * Set up environment.
1223 */ 1209 */
1224 args = state->args; 1210 args = state->args;
1225 ASSERT(args != NULL); 1211 ASSERT(args != NULL);
1226 old_info = old_blk->bp->data; 1212 old_info = old_blk->bp->b_addr;
1227 new_info = new_blk->bp->data; 1213 new_info = new_blk->bp->b_addr;
1228 ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC || 1214 ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC ||
1229 old_blk->magic == XFS_DIR2_LEAFN_MAGIC || 1215 old_blk->magic == XFS_DIR2_LEAFN_MAGIC ||
1230 old_blk->magic == XFS_ATTR_LEAF_MAGIC); 1216 old_blk->magic == XFS_ATTR_LEAF_MAGIC);
@@ -1261,12 +1247,11 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1261 if (error) 1247 if (error)
1262 return(error); 1248 return(error);
1263 ASSERT(bp != NULL); 1249 ASSERT(bp != NULL);
1264 tmp_info = bp->data; 1250 tmp_info = bp->b_addr;
1265 ASSERT(be16_to_cpu(tmp_info->magic) == be16_to_cpu(old_info->magic)); 1251 ASSERT(be16_to_cpu(tmp_info->magic) == be16_to_cpu(old_info->magic));
1266 ASSERT(be32_to_cpu(tmp_info->forw) == old_blk->blkno); 1252 ASSERT(be32_to_cpu(tmp_info->forw) == old_blk->blkno);
1267 tmp_info->forw = cpu_to_be32(new_blk->blkno); 1253 tmp_info->forw = cpu_to_be32(new_blk->blkno);
1268 xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); 1254 xfs_trans_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1);
1269 xfs_da_buf_done(bp);
1270 } 1255 }
1271 old_info->back = cpu_to_be32(new_blk->blkno); 1256 old_info->back = cpu_to_be32(new_blk->blkno);
1272 } else { 1257 } else {
@@ -1283,18 +1268,17 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1283 if (error) 1268 if (error)
1284 return(error); 1269 return(error);
1285 ASSERT(bp != NULL); 1270 ASSERT(bp != NULL);
1286 tmp_info = bp->data; 1271 tmp_info = bp->b_addr;
1287 ASSERT(tmp_info->magic == old_info->magic); 1272 ASSERT(tmp_info->magic == old_info->magic);
1288 ASSERT(be32_to_cpu(tmp_info->back) == old_blk->blkno); 1273 ASSERT(be32_to_cpu(tmp_info->back) == old_blk->blkno);
1289 tmp_info->back = cpu_to_be32(new_blk->blkno); 1274 tmp_info->back = cpu_to_be32(new_blk->blkno);
1290 xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); 1275 xfs_trans_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1);
1291 xfs_da_buf_done(bp);
1292 } 1276 }
1293 old_info->forw = cpu_to_be32(new_blk->blkno); 1277 old_info->forw = cpu_to_be32(new_blk->blkno);
1294 } 1278 }
1295 1279
1296 xfs_da_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1); 1280 xfs_trans_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1);
1297 xfs_da_log_buf(args->trans, new_blk->bp, 0, sizeof(*tmp_info) - 1); 1281 xfs_trans_log_buf(args->trans, new_blk->bp, 0, sizeof(*tmp_info) - 1);
1298 return(0); 1282 return(0);
1299} 1283}
1300 1284
@@ -1302,12 +1286,14 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1302 * Compare two intermediate nodes for "order". 1286 * Compare two intermediate nodes for "order".
1303 */ 1287 */
1304STATIC int 1288STATIC int
1305xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp) 1289xfs_da_node_order(
1290 struct xfs_buf *node1_bp,
1291 struct xfs_buf *node2_bp)
1306{ 1292{
1307 xfs_da_intnode_t *node1, *node2; 1293 xfs_da_intnode_t *node1, *node2;
1308 1294
1309 node1 = node1_bp->data; 1295 node1 = node1_bp->b_addr;
1310 node2 = node2_bp->data; 1296 node2 = node2_bp->b_addr;
1311 ASSERT(node1->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC) && 1297 ASSERT(node1->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC) &&
1312 node2->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 1298 node2->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
1313 if ((be16_to_cpu(node1->hdr.count) > 0) && (be16_to_cpu(node2->hdr.count) > 0) && 1299 if ((be16_to_cpu(node1->hdr.count) > 0) && (be16_to_cpu(node2->hdr.count) > 0) &&
@@ -1324,11 +1310,13 @@ xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp)
1324 * Pick up the last hashvalue from an intermediate node. 1310 * Pick up the last hashvalue from an intermediate node.
1325 */ 1311 */
1326STATIC uint 1312STATIC uint
1327xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count) 1313xfs_da_node_lasthash(
1314 struct xfs_buf *bp,
1315 int *count)
1328{ 1316{
1329 xfs_da_intnode_t *node; 1317 xfs_da_intnode_t *node;
1330 1318
1331 node = bp->data; 1319 node = bp->b_addr;
1332 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 1320 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
1333 if (count) 1321 if (count)
1334 *count = be16_to_cpu(node->hdr.count); 1322 *count = be16_to_cpu(node->hdr.count);
@@ -1346,7 +1334,7 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1346{ 1334{
1347 xfs_da_blkinfo_t *drop_info, *save_info, *tmp_info; 1335 xfs_da_blkinfo_t *drop_info, *save_info, *tmp_info;
1348 xfs_da_args_t *args; 1336 xfs_da_args_t *args;
1349 xfs_dabuf_t *bp; 1337 struct xfs_buf *bp;
1350 int error; 1338 int error;
1351 1339
1352 /* 1340 /*
@@ -1354,8 +1342,8 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1354 */ 1342 */
1355 args = state->args; 1343 args = state->args;
1356 ASSERT(args != NULL); 1344 ASSERT(args != NULL);
1357 save_info = save_blk->bp->data; 1345 save_info = save_blk->bp->b_addr;
1358 drop_info = drop_blk->bp->data; 1346 drop_info = drop_blk->bp->b_addr;
1359 ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC || 1347 ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC ||
1360 save_blk->magic == XFS_DIR2_LEAFN_MAGIC || 1348 save_blk->magic == XFS_DIR2_LEAFN_MAGIC ||
1361 save_blk->magic == XFS_ATTR_LEAF_MAGIC); 1349 save_blk->magic == XFS_ATTR_LEAF_MAGIC);
@@ -1380,13 +1368,12 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1380 if (error) 1368 if (error)
1381 return(error); 1369 return(error);
1382 ASSERT(bp != NULL); 1370 ASSERT(bp != NULL);
1383 tmp_info = bp->data; 1371 tmp_info = bp->b_addr;
1384 ASSERT(tmp_info->magic == save_info->magic); 1372 ASSERT(tmp_info->magic == save_info->magic);
1385 ASSERT(be32_to_cpu(tmp_info->forw) == drop_blk->blkno); 1373 ASSERT(be32_to_cpu(tmp_info->forw) == drop_blk->blkno);
1386 tmp_info->forw = cpu_to_be32(save_blk->blkno); 1374 tmp_info->forw = cpu_to_be32(save_blk->blkno);
1387 xfs_da_log_buf(args->trans, bp, 0, 1375 xfs_trans_log_buf(args->trans, bp, 0,
1388 sizeof(*tmp_info) - 1); 1376 sizeof(*tmp_info) - 1);
1389 xfs_da_buf_done(bp);
1390 } 1377 }
1391 } else { 1378 } else {
1392 trace_xfs_da_unlink_forward(args); 1379 trace_xfs_da_unlink_forward(args);
@@ -1398,17 +1385,16 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1398 if (error) 1385 if (error)
1399 return(error); 1386 return(error);
1400 ASSERT(bp != NULL); 1387 ASSERT(bp != NULL);
1401 tmp_info = bp->data; 1388 tmp_info = bp->b_addr;
1402 ASSERT(tmp_info->magic == save_info->magic); 1389 ASSERT(tmp_info->magic == save_info->magic);
1403 ASSERT(be32_to_cpu(tmp_info->back) == drop_blk->blkno); 1390 ASSERT(be32_to_cpu(tmp_info->back) == drop_blk->blkno);
1404 tmp_info->back = cpu_to_be32(save_blk->blkno); 1391 tmp_info->back = cpu_to_be32(save_blk->blkno);
1405 xfs_da_log_buf(args->trans, bp, 0, 1392 xfs_trans_log_buf(args->trans, bp, 0,
1406 sizeof(*tmp_info) - 1); 1393 sizeof(*tmp_info) - 1);
1407 xfs_da_buf_done(bp);
1408 } 1394 }
1409 } 1395 }
1410 1396
1411 xfs_da_log_buf(args->trans, save_blk->bp, 0, sizeof(*save_info) - 1); 1397 xfs_trans_log_buf(args->trans, save_blk->bp, 0, sizeof(*save_info) - 1);
1412 return(0); 1398 return(0);
1413} 1399}
1414 1400
@@ -1443,7 +1429,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1443 level = (path->active-1) - 1; /* skip bottom layer in path */ 1429 level = (path->active-1) - 1; /* skip bottom layer in path */
1444 for (blk = &path->blk[level]; level >= 0; blk--, level--) { 1430 for (blk = &path->blk[level]; level >= 0; blk--, level--) {
1445 ASSERT(blk->bp != NULL); 1431 ASSERT(blk->bp != NULL);
1446 node = blk->bp->data; 1432 node = blk->bp->b_addr;
1447 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 1433 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
1448 if (forward && (blk->index < be16_to_cpu(node->hdr.count)-1)) { 1434 if (forward && (blk->index < be16_to_cpu(node->hdr.count)-1)) {
1449 blk->index++; 1435 blk->index++;
@@ -1471,7 +1457,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1471 * (if it's dirty, trans won't actually let go) 1457 * (if it's dirty, trans won't actually let go)
1472 */ 1458 */
1473 if (release) 1459 if (release)
1474 xfs_da_brelse(args->trans, blk->bp); 1460 xfs_trans_brelse(args->trans, blk->bp);
1475 1461
1476 /* 1462 /*
1477 * Read the next child block. 1463 * Read the next child block.
@@ -1482,7 +1468,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1482 if (error) 1468 if (error)
1483 return(error); 1469 return(error);
1484 ASSERT(blk->bp != NULL); 1470 ASSERT(blk->bp != NULL);
1485 info = blk->bp->data; 1471 info = blk->bp->b_addr;
1486 ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC) || 1472 ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC) ||
1487 info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || 1473 info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
1488 info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1474 info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
@@ -1702,11 +1688,13 @@ xfs_da_grow_inode(
1702 * a bmap btree split to do that. 1688 * a bmap btree split to do that.
1703 */ 1689 */
1704STATIC int 1690STATIC int
1705xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, 1691xfs_da_swap_lastblock(
1706 xfs_dabuf_t **dead_bufp) 1692 xfs_da_args_t *args,
1693 xfs_dablk_t *dead_blknop,
1694 struct xfs_buf **dead_bufp)
1707{ 1695{
1708 xfs_dablk_t dead_blkno, last_blkno, sib_blkno, par_blkno; 1696 xfs_dablk_t dead_blkno, last_blkno, sib_blkno, par_blkno;
1709 xfs_dabuf_t *dead_buf, *last_buf, *sib_buf, *par_buf; 1697 struct xfs_buf *dead_buf, *last_buf, *sib_buf, *par_buf;
1710 xfs_fileoff_t lastoff; 1698 xfs_fileoff_t lastoff;
1711 xfs_inode_t *ip; 1699 xfs_inode_t *ip;
1712 xfs_trans_t *tp; 1700 xfs_trans_t *tp;
@@ -1744,9 +1732,9 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1744 /* 1732 /*
1745 * Copy the last block into the dead buffer and log it. 1733 * Copy the last block into the dead buffer and log it.
1746 */ 1734 */
1747 memcpy(dead_buf->data, last_buf->data, mp->m_dirblksize); 1735 memcpy(dead_buf->b_addr, last_buf->b_addr, mp->m_dirblksize);
1748 xfs_da_log_buf(tp, dead_buf, 0, mp->m_dirblksize - 1); 1736 xfs_trans_log_buf(tp, dead_buf, 0, mp->m_dirblksize - 1);
1749 dead_info = dead_buf->data; 1737 dead_info = dead_buf->b_addr;
1750 /* 1738 /*
1751 * Get values from the moved block. 1739 * Get values from the moved block.
1752 */ 1740 */
@@ -1767,7 +1755,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1767 if ((sib_blkno = be32_to_cpu(dead_info->back))) { 1755 if ((sib_blkno = be32_to_cpu(dead_info->back))) {
1768 if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) 1756 if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w)))
1769 goto done; 1757 goto done;
1770 sib_info = sib_buf->data; 1758 sib_info = sib_buf->b_addr;
1771 if (unlikely( 1759 if (unlikely(
1772 be32_to_cpu(sib_info->forw) != last_blkno || 1760 be32_to_cpu(sib_info->forw) != last_blkno ||
1773 sib_info->magic != dead_info->magic)) { 1761 sib_info->magic != dead_info->magic)) {
@@ -1777,10 +1765,9 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1777 goto done; 1765 goto done;
1778 } 1766 }
1779 sib_info->forw = cpu_to_be32(dead_blkno); 1767 sib_info->forw = cpu_to_be32(dead_blkno);
1780 xfs_da_log_buf(tp, sib_buf, 1768 xfs_trans_log_buf(tp, sib_buf,
1781 XFS_DA_LOGRANGE(sib_info, &sib_info->forw, 1769 XFS_DA_LOGRANGE(sib_info, &sib_info->forw,
1782 sizeof(sib_info->forw))); 1770 sizeof(sib_info->forw)));
1783 xfs_da_buf_done(sib_buf);
1784 sib_buf = NULL; 1771 sib_buf = NULL;
1785 } 1772 }
1786 /* 1773 /*
@@ -1789,7 +1776,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1789 if ((sib_blkno = be32_to_cpu(dead_info->forw))) { 1776 if ((sib_blkno = be32_to_cpu(dead_info->forw))) {
1790 if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) 1777 if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w)))
1791 goto done; 1778 goto done;
1792 sib_info = sib_buf->data; 1779 sib_info = sib_buf->b_addr;
1793 if (unlikely( 1780 if (unlikely(
1794 be32_to_cpu(sib_info->back) != last_blkno || 1781 be32_to_cpu(sib_info->back) != last_blkno ||
1795 sib_info->magic != dead_info->magic)) { 1782 sib_info->magic != dead_info->magic)) {
@@ -1799,10 +1786,9 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1799 goto done; 1786 goto done;
1800 } 1787 }
1801 sib_info->back = cpu_to_be32(dead_blkno); 1788 sib_info->back = cpu_to_be32(dead_blkno);
1802 xfs_da_log_buf(tp, sib_buf, 1789 xfs_trans_log_buf(tp, sib_buf,
1803 XFS_DA_LOGRANGE(sib_info, &sib_info->back, 1790 XFS_DA_LOGRANGE(sib_info, &sib_info->back,
1804 sizeof(sib_info->back))); 1791 sizeof(sib_info->back)));
1805 xfs_da_buf_done(sib_buf);
1806 sib_buf = NULL; 1792 sib_buf = NULL;
1807 } 1793 }
1808 par_blkno = mp->m_dirleafblk; 1794 par_blkno = mp->m_dirleafblk;
@@ -1813,7 +1799,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1813 for (;;) { 1799 for (;;) {
1814 if ((error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w))) 1800 if ((error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w)))
1815 goto done; 1801 goto done;
1816 par_node = par_buf->data; 1802 par_node = par_buf->b_addr;
1817 if (unlikely(par_node->hdr.info.magic != 1803 if (unlikely(par_node->hdr.info.magic !=
1818 cpu_to_be16(XFS_DA_NODE_MAGIC) || 1804 cpu_to_be16(XFS_DA_NODE_MAGIC) ||
1819 (level >= 0 && level != be16_to_cpu(par_node->hdr.level) + 1))) { 1805 (level >= 0 && level != be16_to_cpu(par_node->hdr.level) + 1))) {
@@ -1837,7 +1823,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1837 par_blkno = be32_to_cpu(par_node->btree[entno].before); 1823 par_blkno = be32_to_cpu(par_node->btree[entno].before);
1838 if (level == dead_level + 1) 1824 if (level == dead_level + 1)
1839 break; 1825 break;
1840 xfs_da_brelse(tp, par_buf); 1826 xfs_trans_brelse(tp, par_buf);
1841 par_buf = NULL; 1827 par_buf = NULL;
1842 } 1828 }
1843 /* 1829 /*
@@ -1853,7 +1839,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1853 if (entno < be16_to_cpu(par_node->hdr.count)) 1839 if (entno < be16_to_cpu(par_node->hdr.count))
1854 break; 1840 break;
1855 par_blkno = be32_to_cpu(par_node->hdr.info.forw); 1841 par_blkno = be32_to_cpu(par_node->hdr.info.forw);
1856 xfs_da_brelse(tp, par_buf); 1842 xfs_trans_brelse(tp, par_buf);
1857 par_buf = NULL; 1843 par_buf = NULL;
1858 if (unlikely(par_blkno == 0)) { 1844 if (unlikely(par_blkno == 0)) {
1859 XFS_ERROR_REPORT("xfs_da_swap_lastblock(6)", 1845 XFS_ERROR_REPORT("xfs_da_swap_lastblock(6)",
@@ -1863,7 +1849,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1863 } 1849 }
1864 if ((error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w))) 1850 if ((error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w)))
1865 goto done; 1851 goto done;
1866 par_node = par_buf->data; 1852 par_node = par_buf->b_addr;
1867 if (unlikely( 1853 if (unlikely(
1868 be16_to_cpu(par_node->hdr.level) != level || 1854 be16_to_cpu(par_node->hdr.level) != level ||
1869 par_node->hdr.info.magic != cpu_to_be16(XFS_DA_NODE_MAGIC))) { 1855 par_node->hdr.info.magic != cpu_to_be16(XFS_DA_NODE_MAGIC))) {
@@ -1878,20 +1864,18 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1878 * Update the parent entry pointing to the moved block. 1864 * Update the parent entry pointing to the moved block.
1879 */ 1865 */
1880 par_node->btree[entno].before = cpu_to_be32(dead_blkno); 1866 par_node->btree[entno].before = cpu_to_be32(dead_blkno);
1881 xfs_da_log_buf(tp, par_buf, 1867 xfs_trans_log_buf(tp, par_buf,
1882 XFS_DA_LOGRANGE(par_node, &par_node->btree[entno].before, 1868 XFS_DA_LOGRANGE(par_node, &par_node->btree[entno].before,
1883 sizeof(par_node->btree[entno].before))); 1869 sizeof(par_node->btree[entno].before)));
1884 xfs_da_buf_done(par_buf);
1885 xfs_da_buf_done(dead_buf);
1886 *dead_blknop = last_blkno; 1870 *dead_blknop = last_blkno;
1887 *dead_bufp = last_buf; 1871 *dead_bufp = last_buf;
1888 return 0; 1872 return 0;
1889done: 1873done:
1890 if (par_buf) 1874 if (par_buf)
1891 xfs_da_brelse(tp, par_buf); 1875 xfs_trans_brelse(tp, par_buf);
1892 if (sib_buf) 1876 if (sib_buf)
1893 xfs_da_brelse(tp, sib_buf); 1877 xfs_trans_brelse(tp, sib_buf);
1894 xfs_da_brelse(tp, last_buf); 1878 xfs_trans_brelse(tp, last_buf);
1895 return error; 1879 return error;
1896} 1880}
1897 1881
@@ -1899,8 +1883,10 @@ done:
1899 * Remove a btree block from a directory or attribute. 1883 * Remove a btree block from a directory or attribute.
1900 */ 1884 */
1901int 1885int
1902xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, 1886xfs_da_shrink_inode(
1903 xfs_dabuf_t *dead_buf) 1887 xfs_da_args_t *args,
1888 xfs_dablk_t dead_blkno,
1889 struct xfs_buf *dead_buf)
1904{ 1890{
1905 xfs_inode_t *dp; 1891 xfs_inode_t *dp;
1906 int done, error, w, count; 1892 int done, error, w, count;
@@ -1935,7 +1921,7 @@ xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
1935 break; 1921 break;
1936 } 1922 }
1937 } 1923 }
1938 xfs_da_binval(tp, dead_buf); 1924 xfs_trans_binval(tp, dead_buf);
1939 return error; 1925 return error;
1940} 1926}
1941 1927
@@ -1967,35 +1953,75 @@ xfs_da_map_covers_blocks(
1967} 1953}
1968 1954
1969/* 1955/*
1970 * Make a dabuf. 1956 * Convert a struct xfs_bmbt_irec to a struct xfs_buf_map.
1971 * Used for get_buf, read_buf, read_bufr, and reada_buf. 1957 *
1958 * For the single map case, it is assumed that the caller has provided a pointer
1959 * to a valid xfs_buf_map. For the multiple map case, this function will
1960 * allocate the xfs_buf_map to hold all the maps and replace the caller's single
1961 * map pointer with the allocated map.
1972 */ 1962 */
1973STATIC int 1963static int
1974xfs_da_do_buf( 1964xfs_buf_map_from_irec(
1975 xfs_trans_t *trans, 1965 struct xfs_mount *mp,
1976 xfs_inode_t *dp, 1966 struct xfs_buf_map **mapp,
1977 xfs_dablk_t bno, 1967 unsigned int *nmaps,
1978 xfs_daddr_t *mappedbnop, 1968 struct xfs_bmbt_irec *irecs,
1979 xfs_dabuf_t **bpp, 1969 unsigned int nirecs)
1980 int whichfork,
1981 int caller)
1982{ 1970{
1983 xfs_buf_t *bp = NULL; 1971 struct xfs_buf_map *map;
1984 xfs_buf_t **bplist; 1972 int i;
1985 int error=0; 1973
1986 int i; 1974 ASSERT(*nmaps == 1);
1987 xfs_bmbt_irec_t map; 1975 ASSERT(nirecs >= 1);
1988 xfs_bmbt_irec_t *mapp; 1976
1989 xfs_daddr_t mappedbno; 1977 if (nirecs > 1) {
1990 xfs_mount_t *mp; 1978 map = kmem_zalloc(nirecs * sizeof(struct xfs_buf_map), KM_SLEEP);
1991 int nbplist=0; 1979 if (!map)
1992 int nfsb; 1980 return ENOMEM;
1993 int nmap; 1981 *mapp = map;
1994 xfs_dabuf_t *rbp; 1982 }
1983
1984 *nmaps = nirecs;
1985 map = *mapp;
1986 for (i = 0; i < *nmaps; i++) {
1987 ASSERT(irecs[i].br_startblock != DELAYSTARTBLOCK &&
1988 irecs[i].br_startblock != HOLESTARTBLOCK);
1989 map[i].bm_bn = XFS_FSB_TO_DADDR(mp, irecs[i].br_startblock);
1990 map[i].bm_len = XFS_FSB_TO_BB(mp, irecs[i].br_blockcount);
1991 }
1992 return 0;
1993}
1994
1995/*
1996 * Map the block we are given ready for reading. There are three possible return
1997 * values:
1998 * -1 - will be returned if we land in a hole and mappedbno == -2 so the
1999 * caller knows not to execute a subsequent read.
2000 * 0 - if we mapped the block successfully
2001 * >0 - positive error number if there was an error.
2002 */
2003static int
2004xfs_dabuf_map(
2005 struct xfs_trans *trans,
2006 struct xfs_inode *dp,
2007 xfs_dablk_t bno,
2008 xfs_daddr_t mappedbno,
2009 int whichfork,
2010 struct xfs_buf_map **map,
2011 int *nmaps)
2012{
2013 struct xfs_mount *mp = dp->i_mount;
2014 int nfsb;
2015 int error = 0;
2016 struct xfs_bmbt_irec irec;
2017 struct xfs_bmbt_irec *irecs = &irec;
2018 int nirecs;
2019
2020 ASSERT(map && *map);
2021 ASSERT(*nmaps == 1);
1995 2022
1996 mp = dp->i_mount;
1997 nfsb = (whichfork == XFS_DATA_FORK) ? mp->m_dirblkfsbs : 1; 2023 nfsb = (whichfork == XFS_DATA_FORK) ? mp->m_dirblkfsbs : 1;
1998 mappedbno = *mappedbnop; 2024
1999 /* 2025 /*
2000 * Caller doesn't have a mapping. -2 means don't complain 2026 * Caller doesn't have a mapping. -2 means don't complain
2001 * if we land in a hole. 2027 * if we land in a hole.
@@ -2004,112 +2030,150 @@ xfs_da_do_buf(
2004 /* 2030 /*
2005 * Optimize the one-block case. 2031 * Optimize the one-block case.
2006 */ 2032 */
2007 if (nfsb == 1) 2033 if (nfsb != 1)
2008 mapp = &map; 2034 irecs = kmem_zalloc(sizeof(irec) * nfsb, KM_SLEEP);
2009 else
2010 mapp = kmem_alloc(sizeof(*mapp) * nfsb, KM_SLEEP);
2011 2035
2012 nmap = nfsb; 2036 nirecs = nfsb;
2013 error = xfs_bmapi_read(dp, (xfs_fileoff_t)bno, nfsb, mapp, 2037 error = xfs_bmapi_read(dp, (xfs_fileoff_t)bno, nfsb, irecs,
2014 &nmap, xfs_bmapi_aflag(whichfork)); 2038 &nirecs, xfs_bmapi_aflag(whichfork));
2015 if (error) 2039 if (error)
2016 goto exit0; 2040 goto out;
2017 } else { 2041 } else {
2018 map.br_startblock = XFS_DADDR_TO_FSB(mp, mappedbno); 2042 irecs->br_startblock = XFS_DADDR_TO_FSB(mp, mappedbno);
2019 map.br_startoff = (xfs_fileoff_t)bno; 2043 irecs->br_startoff = (xfs_fileoff_t)bno;
2020 map.br_blockcount = nfsb; 2044 irecs->br_blockcount = nfsb;
2021 mapp = &map; 2045 irecs->br_state = 0;
2022 nmap = 1; 2046 nirecs = 1;
2023 } 2047 }
2024 if (!xfs_da_map_covers_blocks(nmap, mapp, bno, nfsb)) { 2048
2025 error = mappedbno == -2 ? 0 : XFS_ERROR(EFSCORRUPTED); 2049 if (!xfs_da_map_covers_blocks(nirecs, irecs, bno, nfsb)) {
2050 error = mappedbno == -2 ? -1 : XFS_ERROR(EFSCORRUPTED);
2026 if (unlikely(error == EFSCORRUPTED)) { 2051 if (unlikely(error == EFSCORRUPTED)) {
2027 if (xfs_error_level >= XFS_ERRLEVEL_LOW) { 2052 if (xfs_error_level >= XFS_ERRLEVEL_LOW) {
2053 int i;
2028 xfs_alert(mp, "%s: bno %lld dir: inode %lld", 2054 xfs_alert(mp, "%s: bno %lld dir: inode %lld",
2029 __func__, (long long)bno, 2055 __func__, (long long)bno,
2030 (long long)dp->i_ino); 2056 (long long)dp->i_ino);
2031 for (i = 0; i < nmap; i++) { 2057 for (i = 0; i < *nmaps; i++) {
2032 xfs_alert(mp, 2058 xfs_alert(mp,
2033"[%02d] br_startoff %lld br_startblock %lld br_blockcount %lld br_state %d", 2059"[%02d] br_startoff %lld br_startblock %lld br_blockcount %lld br_state %d",
2034 i, 2060 i,
2035 (long long)mapp[i].br_startoff, 2061 (long long)irecs[i].br_startoff,
2036 (long long)mapp[i].br_startblock, 2062 (long long)irecs[i].br_startblock,
2037 (long long)mapp[i].br_blockcount, 2063 (long long)irecs[i].br_blockcount,
2038 mapp[i].br_state); 2064 irecs[i].br_state);
2039 } 2065 }
2040 } 2066 }
2041 XFS_ERROR_REPORT("xfs_da_do_buf(1)", 2067 XFS_ERROR_REPORT("xfs_da_do_buf(1)",
2042 XFS_ERRLEVEL_LOW, mp); 2068 XFS_ERRLEVEL_LOW, mp);
2043 } 2069 }
2044 goto exit0; 2070 goto out;
2045 } 2071 }
2046 if (caller != 3 && nmap > 1) { 2072 error = xfs_buf_map_from_irec(mp, map, nmaps, irecs, nirecs);
2047 bplist = kmem_alloc(sizeof(*bplist) * nmap, KM_SLEEP); 2073out:
2048 nbplist = 0; 2074 if (irecs != &irec)
2049 } else 2075 kmem_free(irecs);
2050 bplist = NULL; 2076 return error;
2051 /* 2077}
2052 * Turn the mapping(s) into buffer(s). 2078
2053 */ 2079/*
2054 for (i = 0; i < nmap; i++) { 2080 * Get a buffer for the dir/attr block.
2055 int nmapped; 2081 */
2056 2082int
2057 mappedbno = XFS_FSB_TO_DADDR(mp, mapp[i].br_startblock); 2083xfs_da_get_buf(
2058 if (i == 0) 2084 struct xfs_trans *trans,
2059 *mappedbnop = mappedbno; 2085 struct xfs_inode *dp,
2060 nmapped = (int)XFS_FSB_TO_BB(mp, mapp[i].br_blockcount); 2086 xfs_dablk_t bno,
2061 switch (caller) { 2087 xfs_daddr_t mappedbno,
2062 case 0: 2088 struct xfs_buf **bpp,
2063 bp = xfs_trans_get_buf(trans, mp->m_ddev_targp, 2089 int whichfork)
2064 mappedbno, nmapped, 0); 2090{
2065 error = bp ? bp->b_error : XFS_ERROR(EIO); 2091 struct xfs_buf *bp;
2066 break; 2092 struct xfs_buf_map map;
2067 case 1: 2093 struct xfs_buf_map *mapp;
2068 case 2: 2094 int nmap;
2069 bp = NULL; 2095 int error;
2070 error = xfs_trans_read_buf(mp, trans, mp->m_ddev_targp, 2096
2071 mappedbno, nmapped, 0, &bp); 2097 *bpp = NULL;
2072 break; 2098 mapp = &map;
2073 case 3: 2099 nmap = 1;
2074 xfs_buf_readahead(mp->m_ddev_targp, mappedbno, nmapped); 2100 error = xfs_dabuf_map(trans, dp, bno, mappedbno, whichfork,
2101 &mapp, &nmap);
2102 if (error) {
2103 /* mapping a hole is not an error, but we don't continue */
2104 if (error == -1)
2075 error = 0; 2105 error = 0;
2076 bp = NULL; 2106 goto out_free;
2077 break;
2078 }
2079 if (error) {
2080 if (bp)
2081 xfs_trans_brelse(trans, bp);
2082 goto exit1;
2083 }
2084 if (!bp)
2085 continue;
2086 if (caller == 1) {
2087 if (whichfork == XFS_ATTR_FORK)
2088 xfs_buf_set_ref(bp, XFS_ATTR_BTREE_REF);
2089 else
2090 xfs_buf_set_ref(bp, XFS_DIR_BTREE_REF);
2091 }
2092 if (bplist) {
2093 bplist[nbplist++] = bp;
2094 }
2095 } 2107 }
2096 /* 2108
2097 * Build a dabuf structure. 2109 bp = xfs_trans_get_buf_map(trans, dp->i_mount->m_ddev_targp,
2098 */ 2110 mapp, nmap, 0);
2099 if (bplist) { 2111 error = bp ? bp->b_error : XFS_ERROR(EIO);
2100 rbp = xfs_da_buf_make(nbplist, bplist); 2112 if (error) {
2101 } else if (bp) 2113 xfs_trans_brelse(trans, bp);
2102 rbp = xfs_da_buf_make(1, &bp); 2114 goto out_free;
2115 }
2116
2117 *bpp = bp;
2118
2119out_free:
2120 if (mapp != &map)
2121 kmem_free(mapp);
2122
2123 return error;
2124}
2125
2126/*
2127 * Get a buffer for the dir/attr block, fill in the contents.
2128 */
2129int
2130xfs_da_read_buf(
2131 struct xfs_trans *trans,
2132 struct xfs_inode *dp,
2133 xfs_dablk_t bno,
2134 xfs_daddr_t mappedbno,
2135 struct xfs_buf **bpp,
2136 int whichfork)
2137{
2138 struct xfs_buf *bp;
2139 struct xfs_buf_map map;
2140 struct xfs_buf_map *mapp;
2141 int nmap;
2142 int error;
2143
2144 *bpp = NULL;
2145 mapp = &map;
2146 nmap = 1;
2147 error = xfs_dabuf_map(trans, dp, bno, mappedbno, whichfork,
2148 &mapp, &nmap);
2149 if (error) {
2150 /* mapping a hole is not an error, but we don't continue */
2151 if (error == -1)
2152 error = 0;
2153 goto out_free;
2154 }
2155
2156 error = xfs_trans_read_buf_map(dp->i_mount, trans,
2157 dp->i_mount->m_ddev_targp,
2158 mapp, nmap, 0, &bp);
2159 if (error)
2160 goto out_free;
2161
2162 if (whichfork == XFS_ATTR_FORK)
2163 xfs_buf_set_ref(bp, XFS_ATTR_BTREE_REF);
2103 else 2164 else
2104 rbp = NULL; 2165 xfs_buf_set_ref(bp, XFS_DIR_BTREE_REF);
2166
2105 /* 2167 /*
2106 * For read_buf, check the magic number. 2168 * This verification code will be moved to a CRC verification callback
2169 * function so just leave it here unchanged until then.
2107 */ 2170 */
2108 if (caller == 1) { 2171 {
2109 xfs_dir2_data_hdr_t *hdr = rbp->data; 2172 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
2110 xfs_dir2_free_t *free = rbp->data; 2173 xfs_dir2_free_t *free = bp->b_addr;
2111 xfs_da_blkinfo_t *info = rbp->data; 2174 xfs_da_blkinfo_t *info = bp->b_addr;
2112 uint magic, magic1; 2175 uint magic, magic1;
2176 struct xfs_mount *mp = dp->i_mount;
2113 2177
2114 magic = be16_to_cpu(info->magic); 2178 magic = be16_to_cpu(info->magic);
2115 magic1 = be32_to_cpu(hdr->magic); 2179 magic1 = be32_to_cpu(hdr->magic);
@@ -2123,66 +2187,20 @@ xfs_da_do_buf(
2123 (free->hdr.magic != cpu_to_be32(XFS_DIR2_FREE_MAGIC)), 2187 (free->hdr.magic != cpu_to_be32(XFS_DIR2_FREE_MAGIC)),
2124 mp, XFS_ERRTAG_DA_READ_BUF, 2188 mp, XFS_ERRTAG_DA_READ_BUF,
2125 XFS_RANDOM_DA_READ_BUF))) { 2189 XFS_RANDOM_DA_READ_BUF))) {
2126 trace_xfs_da_btree_corrupt(rbp->bps[0], _RET_IP_); 2190 trace_xfs_da_btree_corrupt(bp, _RET_IP_);
2127 XFS_CORRUPTION_ERROR("xfs_da_do_buf(2)", 2191 XFS_CORRUPTION_ERROR("xfs_da_do_buf(2)",
2128 XFS_ERRLEVEL_LOW, mp, info); 2192 XFS_ERRLEVEL_LOW, mp, info);
2129 error = XFS_ERROR(EFSCORRUPTED); 2193 error = XFS_ERROR(EFSCORRUPTED);
2130 xfs_da_brelse(trans, rbp); 2194 xfs_trans_brelse(trans, bp);
2131 nbplist = 0; 2195 goto out_free;
2132 goto exit1;
2133 } 2196 }
2134 } 2197 }
2135 if (bplist) { 2198 *bpp = bp;
2136 kmem_free(bplist); 2199out_free:
2137 }
2138 if (mapp != &map) {
2139 kmem_free(mapp);
2140 }
2141 if (bpp)
2142 *bpp = rbp;
2143 return 0;
2144exit1:
2145 if (bplist) {
2146 for (i = 0; i < nbplist; i++)
2147 xfs_trans_brelse(trans, bplist[i]);
2148 kmem_free(bplist);
2149 }
2150exit0:
2151 if (mapp != &map) 2200 if (mapp != &map)
2152 kmem_free(mapp); 2201 kmem_free(mapp);
2153 if (bpp)
2154 *bpp = NULL;
2155 return error;
2156}
2157
2158/*
2159 * Get a buffer for the dir/attr block.
2160 */
2161int
2162xfs_da_get_buf(
2163 xfs_trans_t *trans,
2164 xfs_inode_t *dp,
2165 xfs_dablk_t bno,
2166 xfs_daddr_t mappedbno,
2167 xfs_dabuf_t **bpp,
2168 int whichfork)
2169{
2170 return xfs_da_do_buf(trans, dp, bno, &mappedbno, bpp, whichfork, 0);
2171}
2172 2202
2173/* 2203 return error;
2174 * Get a buffer for the dir/attr block, fill in the contents.
2175 */
2176int
2177xfs_da_read_buf(
2178 xfs_trans_t *trans,
2179 xfs_inode_t *dp,
2180 xfs_dablk_t bno,
2181 xfs_daddr_t mappedbno,
2182 xfs_dabuf_t **bpp,
2183 int whichfork)
2184{
2185 return xfs_da_do_buf(trans, dp, bno, &mappedbno, bpp, whichfork, 1);
2186} 2204}
2187 2205
2188/* 2206/*
@@ -2190,22 +2208,41 @@ xfs_da_read_buf(
2190 */ 2208 */
2191xfs_daddr_t 2209xfs_daddr_t
2192xfs_da_reada_buf( 2210xfs_da_reada_buf(
2193 xfs_trans_t *trans, 2211 struct xfs_trans *trans,
2194 xfs_inode_t *dp, 2212 struct xfs_inode *dp,
2195 xfs_dablk_t bno, 2213 xfs_dablk_t bno,
2196 int whichfork) 2214 int whichfork)
2197{ 2215{
2198 xfs_daddr_t rval; 2216 xfs_daddr_t mappedbno = -1;
2217 struct xfs_buf_map map;
2218 struct xfs_buf_map *mapp;
2219 int nmap;
2220 int error;
2221
2222 mapp = &map;
2223 nmap = 1;
2224 error = xfs_dabuf_map(trans, dp, bno, -1, whichfork,
2225 &mapp, &nmap);
2226 if (error) {
2227 /* mapping a hole is not an error, but we don't continue */
2228 if (error == -1)
2229 error = 0;
2230 goto out_free;
2231 }
2199 2232
2200 rval = -1; 2233 mappedbno = mapp[0].bm_bn;
2201 if (xfs_da_do_buf(trans, dp, bno, &rval, NULL, whichfork, 3)) 2234 xfs_buf_readahead_map(dp->i_mount->m_ddev_targp, mapp, nmap);
2235
2236out_free:
2237 if (mapp != &map)
2238 kmem_free(mapp);
2239
2240 if (error)
2202 return -1; 2241 return -1;
2203 else 2242 return mappedbno;
2204 return rval;
2205} 2243}
2206 2244
2207kmem_zone_t *xfs_da_state_zone; /* anchor for state struct zone */ 2245kmem_zone_t *xfs_da_state_zone; /* anchor for state struct zone */
2208kmem_zone_t *xfs_dabuf_zone; /* dabuf zone */
2209 2246
2210/* 2247/*
2211 * Allocate a dir-state structure. 2248 * Allocate a dir-state structure.
@@ -2225,13 +2262,8 @@ xfs_da_state_kill_altpath(xfs_da_state_t *state)
2225{ 2262{
2226 int i; 2263 int i;
2227 2264
2228 for (i = 0; i < state->altpath.active; i++) { 2265 for (i = 0; i < state->altpath.active; i++)
2229 if (state->altpath.blk[i].bp) { 2266 state->altpath.blk[i].bp = NULL;
2230 if (state->altpath.blk[i].bp != state->path.blk[i].bp)
2231 xfs_da_buf_done(state->altpath.blk[i].bp);
2232 state->altpath.blk[i].bp = NULL;
2233 }
2234 }
2235 state->altpath.active = 0; 2267 state->altpath.active = 0;
2236} 2268}
2237 2269
@@ -2241,204 +2273,9 @@ xfs_da_state_kill_altpath(xfs_da_state_t *state)
2241void 2273void
2242xfs_da_state_free(xfs_da_state_t *state) 2274xfs_da_state_free(xfs_da_state_t *state)
2243{ 2275{
2244 int i;
2245
2246 xfs_da_state_kill_altpath(state); 2276 xfs_da_state_kill_altpath(state);
2247 for (i = 0; i < state->path.active; i++) {
2248 if (state->path.blk[i].bp)
2249 xfs_da_buf_done(state->path.blk[i].bp);
2250 }
2251 if (state->extravalid && state->extrablk.bp)
2252 xfs_da_buf_done(state->extrablk.bp);
2253#ifdef DEBUG 2277#ifdef DEBUG
2254 memset((char *)state, 0, sizeof(*state)); 2278 memset((char *)state, 0, sizeof(*state));
2255#endif /* DEBUG */ 2279#endif /* DEBUG */
2256 kmem_zone_free(xfs_da_state_zone, state); 2280 kmem_zone_free(xfs_da_state_zone, state);
2257} 2281}
2258
2259/*
2260 * Create a dabuf.
2261 */
2262/* ARGSUSED */
2263STATIC xfs_dabuf_t *
2264xfs_da_buf_make(int nbuf, xfs_buf_t **bps)
2265{
2266 xfs_buf_t *bp;
2267 xfs_dabuf_t *dabuf;
2268 int i;
2269 int off;
2270
2271 if (nbuf == 1)
2272 dabuf = kmem_zone_alloc(xfs_dabuf_zone, KM_NOFS);
2273 else
2274 dabuf = kmem_alloc(XFS_DA_BUF_SIZE(nbuf), KM_NOFS);
2275 dabuf->dirty = 0;
2276 if (nbuf == 1) {
2277 dabuf->nbuf = 1;
2278 bp = bps[0];
2279 dabuf->bbcount = bp->b_length;
2280 dabuf->data = bp->b_addr;
2281 dabuf->bps[0] = bp;
2282 } else {
2283 dabuf->nbuf = nbuf;
2284 for (i = 0, dabuf->bbcount = 0; i < nbuf; i++) {
2285 dabuf->bps[i] = bp = bps[i];
2286 dabuf->bbcount += bp->b_length;
2287 }
2288 dabuf->data = kmem_alloc(BBTOB(dabuf->bbcount), KM_SLEEP);
2289 for (i = off = 0; i < nbuf; i++, off += BBTOB(bp->b_length)) {
2290 bp = bps[i];
2291 memcpy((char *)dabuf->data + off, bp->b_addr,
2292 BBTOB(bp->b_length));
2293 }
2294 }
2295 return dabuf;
2296}
2297
2298/*
2299 * Un-dirty a dabuf.
2300 */
2301STATIC void
2302xfs_da_buf_clean(xfs_dabuf_t *dabuf)
2303{
2304 xfs_buf_t *bp;
2305 int i;
2306 int off;
2307
2308 if (dabuf->dirty) {
2309 ASSERT(dabuf->nbuf > 1);
2310 dabuf->dirty = 0;
2311 for (i = off = 0; i < dabuf->nbuf;
2312 i++, off += BBTOB(bp->b_length)) {
2313 bp = dabuf->bps[i];
2314 memcpy(bp->b_addr, dabuf->data + off,
2315 BBTOB(bp->b_length));
2316 }
2317 }
2318}
2319
2320/*
2321 * Release a dabuf.
2322 */
2323void
2324xfs_da_buf_done(xfs_dabuf_t *dabuf)
2325{
2326 ASSERT(dabuf);
2327 ASSERT(dabuf->nbuf && dabuf->data && dabuf->bbcount && dabuf->bps[0]);
2328 if (dabuf->dirty)
2329 xfs_da_buf_clean(dabuf);
2330 if (dabuf->nbuf > 1) {
2331 kmem_free(dabuf->data);
2332 kmem_free(dabuf);
2333 } else {
2334 kmem_zone_free(xfs_dabuf_zone, dabuf);
2335 }
2336}
2337
2338/*
2339 * Log transaction from a dabuf.
2340 */
2341void
2342xfs_da_log_buf(xfs_trans_t *tp, xfs_dabuf_t *dabuf, uint first, uint last)
2343{
2344 xfs_buf_t *bp;
2345 uint f;
2346 int i;
2347 uint l;
2348 int off;
2349
2350 ASSERT(dabuf->nbuf && dabuf->data && dabuf->bbcount && dabuf->bps[0]);
2351 if (dabuf->nbuf == 1) {
2352 ASSERT(dabuf->data == dabuf->bps[0]->b_addr);
2353 xfs_trans_log_buf(tp, dabuf->bps[0], first, last);
2354 return;
2355 }
2356 dabuf->dirty = 1;
2357 ASSERT(first <= last);
2358 for (i = off = 0; i < dabuf->nbuf; i++, off += BBTOB(bp->b_length)) {
2359 bp = dabuf->bps[i];
2360 f = off;
2361 l = f + BBTOB(bp->b_length) - 1;
2362 if (f < first)
2363 f = first;
2364 if (l > last)
2365 l = last;
2366 if (f <= l)
2367 xfs_trans_log_buf(tp, bp, f - off, l - off);
2368 /*
2369 * B_DONE is set by xfs_trans_log buf.
2370 * If we don't set it on a new buffer (get not read)
2371 * then if we don't put anything in the buffer it won't
2372 * be set, and at commit it it released into the cache,
2373 * and then a read will fail.
2374 */
2375 else if (!(XFS_BUF_ISDONE(bp)))
2376 XFS_BUF_DONE(bp);
2377 }
2378 ASSERT(last < off);
2379}
2380
2381/*
2382 * Release dabuf from a transaction.
2383 * Have to free up the dabuf before the buffers are released,
2384 * since the synchronization on the dabuf is really the lock on the buffer.
2385 */
2386void
2387xfs_da_brelse(xfs_trans_t *tp, xfs_dabuf_t *dabuf)
2388{
2389 xfs_buf_t *bp;
2390 xfs_buf_t **bplist;
2391 int i;
2392 int nbuf;
2393
2394 ASSERT(dabuf->nbuf && dabuf->data && dabuf->bbcount && dabuf->bps[0]);
2395 if ((nbuf = dabuf->nbuf) == 1) {
2396 bplist = &bp;
2397 bp = dabuf->bps[0];
2398 } else {
2399 bplist = kmem_alloc(nbuf * sizeof(*bplist), KM_SLEEP);
2400 memcpy(bplist, dabuf->bps, nbuf * sizeof(*bplist));
2401 }
2402 xfs_da_buf_done(dabuf);
2403 for (i = 0; i < nbuf; i++)
2404 xfs_trans_brelse(tp, bplist[i]);
2405 if (bplist != &bp)
2406 kmem_free(bplist);
2407}
2408
2409/*
2410 * Invalidate dabuf from a transaction.
2411 */
2412void
2413xfs_da_binval(xfs_trans_t *tp, xfs_dabuf_t *dabuf)
2414{
2415 xfs_buf_t *bp;
2416 xfs_buf_t **bplist;
2417 int i;
2418 int nbuf;
2419
2420 ASSERT(dabuf->nbuf && dabuf->data && dabuf->bbcount && dabuf->bps[0]);
2421 if ((nbuf = dabuf->nbuf) == 1) {
2422 bplist = &bp;
2423 bp = dabuf->bps[0];
2424 } else {
2425 bplist = kmem_alloc(nbuf * sizeof(*bplist), KM_SLEEP);
2426 memcpy(bplist, dabuf->bps, nbuf * sizeof(*bplist));
2427 }
2428 xfs_da_buf_done(dabuf);
2429 for (i = 0; i < nbuf; i++)
2430 xfs_trans_binval(tp, bplist[i]);
2431 if (bplist != &bp)
2432 kmem_free(bplist);
2433}
2434
2435/*
2436 * Get the first daddr from a dabuf.
2437 */
2438xfs_daddr_t
2439xfs_da_blkno(xfs_dabuf_t *dabuf)
2440{
2441 ASSERT(dabuf->nbuf);
2442 ASSERT(dabuf->data);
2443 return XFS_BUF_ADDR(dabuf->bps[0]);
2444}
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h
index dbf7c074ae73..132adafb041e 100644
--- a/fs/xfs/xfs_da_btree.h
+++ b/fs/xfs/xfs_da_btree.h
@@ -32,7 +32,7 @@ struct zone;
32/* 32/*
33 * This structure is common to both leaf nodes and non-leaf nodes in the Btree. 33 * This structure is common to both leaf nodes and non-leaf nodes in the Btree.
34 * 34 *
35 * Is is used to manage a doubly linked list of all blocks at the same 35 * It is used to manage a doubly linked list of all blocks at the same
36 * level in the Btree, and to identify which type of block this is. 36 * level in the Btree, and to identify which type of block this is.
37 */ 37 */
38#define XFS_DA_NODE_MAGIC 0xfebe /* magic number: non-leaf blocks */ 38#define XFS_DA_NODE_MAGIC 0xfebe /* magic number: non-leaf blocks */
@@ -133,24 +133,6 @@ typedef struct xfs_da_args {
133 { XFS_DA_OP_CILOOKUP, "CILOOKUP" } 133 { XFS_DA_OP_CILOOKUP, "CILOOKUP" }
134 134
135/* 135/*
136 * Structure to describe buffer(s) for a block.
137 * This is needed in the directory version 2 format case, when
138 * multiple non-contiguous fsblocks might be needed to cover one
139 * logical directory block.
140 * If the buffer count is 1 then the data pointer points to the
141 * same place as the b_addr field for the buffer, else to kmem_alloced memory.
142 */
143typedef struct xfs_dabuf {
144 int nbuf; /* number of buffer pointers present */
145 short dirty; /* data needs to be copied back */
146 short bbcount; /* how large is data in bbs */
147 void *data; /* pointer for buffers' data */
148 struct xfs_buf *bps[1]; /* actually nbuf of these */
149} xfs_dabuf_t;
150#define XFS_DA_BUF_SIZE(n) \
151 (sizeof(xfs_dabuf_t) + sizeof(struct xfs_buf *) * ((n) - 1))
152
153/*
154 * Storage for holding state during Btree searches and split/join ops. 136 * Storage for holding state during Btree searches and split/join ops.
155 * 137 *
156 * Only need space for 5 intermediate nodes. With a minimum of 62-way 138 * Only need space for 5 intermediate nodes. With a minimum of 62-way
@@ -158,7 +140,7 @@ typedef struct xfs_dabuf {
158 * which is slightly more than enough. 140 * which is slightly more than enough.
159 */ 141 */
160typedef struct xfs_da_state_blk { 142typedef struct xfs_da_state_blk {
161 xfs_dabuf_t *bp; /* buffer containing block */ 143 struct xfs_buf *bp; /* buffer containing block */
162 xfs_dablk_t blkno; /* filesystem blkno of buffer */ 144 xfs_dablk_t blkno; /* filesystem blkno of buffer */
163 xfs_daddr_t disk_blkno; /* on-disk blkno (in BBs) of buffer */ 145 xfs_daddr_t disk_blkno; /* on-disk blkno (in BBs) of buffer */
164 int index; /* relevant index into block */ 146 int index; /* relevant index into block */
@@ -211,7 +193,7 @@ struct xfs_nameops {
211 * Routines used for growing the Btree. 193 * Routines used for growing the Btree.
212 */ 194 */
213int xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level, 195int xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
214 xfs_dabuf_t **bpp, int whichfork); 196 struct xfs_buf **bpp, int whichfork);
215int xfs_da_split(xfs_da_state_t *state); 197int xfs_da_split(xfs_da_state_t *state);
216 198
217/* 199/*
@@ -241,14 +223,14 @@ int xfs_da_grow_inode_int(struct xfs_da_args *args, xfs_fileoff_t *bno,
241 int count); 223 int count);
242int xfs_da_get_buf(struct xfs_trans *trans, struct xfs_inode *dp, 224int xfs_da_get_buf(struct xfs_trans *trans, struct xfs_inode *dp,
243 xfs_dablk_t bno, xfs_daddr_t mappedbno, 225 xfs_dablk_t bno, xfs_daddr_t mappedbno,
244 xfs_dabuf_t **bp, int whichfork); 226 struct xfs_buf **bp, int whichfork);
245int xfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp, 227int xfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp,
246 xfs_dablk_t bno, xfs_daddr_t mappedbno, 228 xfs_dablk_t bno, xfs_daddr_t mappedbno,
247 xfs_dabuf_t **bpp, int whichfork); 229 struct xfs_buf **bpp, int whichfork);
248xfs_daddr_t xfs_da_reada_buf(struct xfs_trans *trans, struct xfs_inode *dp, 230xfs_daddr_t xfs_da_reada_buf(struct xfs_trans *trans, struct xfs_inode *dp,
249 xfs_dablk_t bno, int whichfork); 231 xfs_dablk_t bno, int whichfork);
250int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, 232int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
251 xfs_dabuf_t *dead_buf); 233 struct xfs_buf *dead_buf);
252 234
253uint xfs_da_hashname(const __uint8_t *name_string, int name_length); 235uint xfs_da_hashname(const __uint8_t *name_string, int name_length);
254enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args, 236enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,
@@ -258,15 +240,7 @@ enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,
258xfs_da_state_t *xfs_da_state_alloc(void); 240xfs_da_state_t *xfs_da_state_alloc(void);
259void xfs_da_state_free(xfs_da_state_t *state); 241void xfs_da_state_free(xfs_da_state_t *state);
260 242
261void xfs_da_buf_done(xfs_dabuf_t *dabuf);
262void xfs_da_log_buf(struct xfs_trans *tp, xfs_dabuf_t *dabuf, uint first,
263 uint last);
264void xfs_da_brelse(struct xfs_trans *tp, xfs_dabuf_t *dabuf);
265void xfs_da_binval(struct xfs_trans *tp, xfs_dabuf_t *dabuf);
266xfs_daddr_t xfs_da_blkno(xfs_dabuf_t *dabuf);
267
268extern struct kmem_zone *xfs_da_state_zone; 243extern struct kmem_zone *xfs_da_state_zone;
269extern struct kmem_zone *xfs_dabuf_zone;
270extern const struct xfs_nameops xfs_default_nameops; 244extern const struct xfs_nameops xfs_default_nameops;
271 245
272#endif /* __XFS_DA_BTREE_H__ */ 246#endif /* __XFS_DA_BTREE_H__ */
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h
index a3721633abc8..1d9643b3dce6 100644
--- a/fs/xfs/xfs_dinode.h
+++ b/fs/xfs/xfs_dinode.h
@@ -33,7 +33,7 @@ typedef struct xfs_timestamp {
33 * variable size the leftover area split into a data and an attribute fork. 33 * variable size the leftover area split into a data and an attribute fork.
34 * The format of the data and attribute fork depends on the format of the 34 * The format of the data and attribute fork depends on the format of the
35 * inode as indicated by di_format and di_aformat. To access the data and 35 * inode as indicated by di_format and di_aformat. To access the data and
36 * attribute use the XFS_DFORK_PTR, XFS_DFORK_DPTR, and XFS_DFORK_PTR macros 36 * attribute use the XFS_DFORK_DPTR, XFS_DFORK_APTR, and XFS_DFORK_PTR macros
37 * below. 37 * below.
38 * 38 *
39 * There is a very similar struct icdinode in xfs_inode which matches the 39 * There is a very similar struct icdinode in xfs_inode which matches the
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index 67a250c36d41..b26a50f9921d 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -592,7 +592,7 @@ int
592xfs_dir2_shrink_inode( 592xfs_dir2_shrink_inode(
593 xfs_da_args_t *args, 593 xfs_da_args_t *args,
594 xfs_dir2_db_t db, 594 xfs_dir2_db_t db,
595 xfs_dabuf_t *bp) 595 struct xfs_buf *bp)
596{ 596{
597 xfs_fileoff_t bno; /* directory file offset */ 597 xfs_fileoff_t bno; /* directory file offset */
598 xfs_dablk_t da; /* directory file offset */ 598 xfs_dablk_t da; /* directory file offset */
@@ -634,7 +634,7 @@ xfs_dir2_shrink_inode(
634 /* 634 /*
635 * Invalidate the buffer from the transaction. 635 * Invalidate the buffer from the transaction.
636 */ 636 */
637 xfs_da_binval(tp, bp); 637 xfs_trans_binval(tp, bp);
638 /* 638 /*
639 * If it's not a data block, we're done. 639 * If it's not a data block, we're done.
640 */ 640 */
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index 586732f2d80d..e93ca8f054f4 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -37,10 +37,10 @@
37/* 37/*
38 * Local function prototypes. 38 * Local function prototypes.
39 */ 39 */
40static void xfs_dir2_block_log_leaf(xfs_trans_t *tp, xfs_dabuf_t *bp, int first, 40static void xfs_dir2_block_log_leaf(xfs_trans_t *tp, struct xfs_buf *bp,
41 int last); 41 int first, int last);
42static void xfs_dir2_block_log_tail(xfs_trans_t *tp, xfs_dabuf_t *bp); 42static void xfs_dir2_block_log_tail(xfs_trans_t *tp, struct xfs_buf *bp);
43static int xfs_dir2_block_lookup_int(xfs_da_args_t *args, xfs_dabuf_t **bpp, 43static int xfs_dir2_block_lookup_int(xfs_da_args_t *args, struct xfs_buf **bpp,
44 int *entno); 44 int *entno);
45static int xfs_dir2_block_sort(const void *a, const void *b); 45static int xfs_dir2_block_sort(const void *a, const void *b);
46 46
@@ -66,7 +66,7 @@ xfs_dir2_block_addname(
66 xfs_dir2_data_free_t *bf; /* bestfree table in block */ 66 xfs_dir2_data_free_t *bf; /* bestfree table in block */
67 xfs_dir2_data_hdr_t *hdr; /* block header */ 67 xfs_dir2_data_hdr_t *hdr; /* block header */
68 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ 68 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
69 xfs_dabuf_t *bp; /* buffer for block */ 69 struct xfs_buf *bp; /* buffer for block */
70 xfs_dir2_block_tail_t *btp; /* block tail */ 70 xfs_dir2_block_tail_t *btp; /* block tail */
71 int compact; /* need to compact leaf ents */ 71 int compact; /* need to compact leaf ents */
72 xfs_dir2_data_entry_t *dep; /* block data entry */ 72 xfs_dir2_data_entry_t *dep; /* block data entry */
@@ -102,14 +102,14 @@ xfs_dir2_block_addname(
102 return error; 102 return error;
103 } 103 }
104 ASSERT(bp != NULL); 104 ASSERT(bp != NULL);
105 hdr = bp->data; 105 hdr = bp->b_addr;
106 /* 106 /*
107 * Check the magic number, corrupted if wrong. 107 * Check the magic number, corrupted if wrong.
108 */ 108 */
109 if (unlikely(hdr->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC))) { 109 if (unlikely(hdr->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC))) {
110 XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", 110 XFS_CORRUPTION_ERROR("xfs_dir2_block_addname",
111 XFS_ERRLEVEL_LOW, mp, hdr); 111 XFS_ERRLEVEL_LOW, mp, hdr);
112 xfs_da_brelse(tp, bp); 112 xfs_trans_brelse(tp, bp);
113 return XFS_ERROR(EFSCORRUPTED); 113 return XFS_ERROR(EFSCORRUPTED);
114 } 114 }
115 len = xfs_dir2_data_entsize(args->namelen); 115 len = xfs_dir2_data_entsize(args->namelen);
@@ -212,7 +212,7 @@ xfs_dir2_block_addname(
212 * If this isn't a real add, we're done with the buffer. 212 * If this isn't a real add, we're done with the buffer.
213 */ 213 */
214 if (args->op_flags & XFS_DA_OP_JUSTCHECK) 214 if (args->op_flags & XFS_DA_OP_JUSTCHECK)
215 xfs_da_brelse(tp, bp); 215 xfs_trans_brelse(tp, bp);
216 /* 216 /*
217 * If we don't have space for the new entry & leaf ... 217 * If we don't have space for the new entry & leaf ...
218 */ 218 */
@@ -228,7 +228,6 @@ xfs_dir2_block_addname(
228 * Then add the new entry in that format. 228 * Then add the new entry in that format.
229 */ 229 */
230 error = xfs_dir2_block_to_leaf(args, bp); 230 error = xfs_dir2_block_to_leaf(args, bp);
231 xfs_da_buf_done(bp);
232 if (error) 231 if (error)
233 return error; 232 return error;
234 return xfs_dir2_leaf_addname(args); 233 return xfs_dir2_leaf_addname(args);
@@ -422,7 +421,6 @@ xfs_dir2_block_addname(
422 xfs_dir2_block_log_tail(tp, bp); 421 xfs_dir2_block_log_tail(tp, bp);
423 xfs_dir2_data_log_entry(tp, bp, dep); 422 xfs_dir2_data_log_entry(tp, bp, dep);
424 xfs_dir2_data_check(dp, bp); 423 xfs_dir2_data_check(dp, bp);
425 xfs_da_buf_done(bp);
426 return 0; 424 return 0;
427} 425}
428 426
@@ -437,7 +435,7 @@ xfs_dir2_block_getdents(
437 filldir_t filldir) 435 filldir_t filldir)
438{ 436{
439 xfs_dir2_data_hdr_t *hdr; /* block header */ 437 xfs_dir2_data_hdr_t *hdr; /* block header */
440 xfs_dabuf_t *bp; /* buffer for block */ 438 struct xfs_buf *bp; /* buffer for block */
441 xfs_dir2_block_tail_t *btp; /* block tail */ 439 xfs_dir2_block_tail_t *btp; /* block tail */
442 xfs_dir2_data_entry_t *dep; /* block data entry */ 440 xfs_dir2_data_entry_t *dep; /* block data entry */
443 xfs_dir2_data_unused_t *dup; /* block unused entry */ 441 xfs_dir2_data_unused_t *dup; /* block unused entry */
@@ -469,7 +467,7 @@ xfs_dir2_block_getdents(
469 * We'll skip entries before this. 467 * We'll skip entries before this.
470 */ 468 */
471 wantoff = xfs_dir2_dataptr_to_off(mp, *offset); 469 wantoff = xfs_dir2_dataptr_to_off(mp, *offset);
472 hdr = bp->data; 470 hdr = bp->b_addr;
473 xfs_dir2_data_check(dp, bp); 471 xfs_dir2_data_check(dp, bp);
474 /* 472 /*
475 * Set up values for the loop. 473 * Set up values for the loop.
@@ -514,7 +512,7 @@ xfs_dir2_block_getdents(
514 cook & 0x7fffffff, be64_to_cpu(dep->inumber), 512 cook & 0x7fffffff, be64_to_cpu(dep->inumber),
515 DT_UNKNOWN)) { 513 DT_UNKNOWN)) {
516 *offset = cook & 0x7fffffff; 514 *offset = cook & 0x7fffffff;
517 xfs_da_brelse(NULL, bp); 515 xfs_trans_brelse(NULL, bp);
518 return 0; 516 return 0;
519 } 517 }
520 } 518 }
@@ -525,7 +523,7 @@ xfs_dir2_block_getdents(
525 */ 523 */
526 *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & 524 *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) &
527 0x7fffffff; 525 0x7fffffff;
528 xfs_da_brelse(NULL, bp); 526 xfs_trans_brelse(NULL, bp);
529 return 0; 527 return 0;
530} 528}
531 529
@@ -535,17 +533,17 @@ xfs_dir2_block_getdents(
535static void 533static void
536xfs_dir2_block_log_leaf( 534xfs_dir2_block_log_leaf(
537 xfs_trans_t *tp, /* transaction structure */ 535 xfs_trans_t *tp, /* transaction structure */
538 xfs_dabuf_t *bp, /* block buffer */ 536 struct xfs_buf *bp, /* block buffer */
539 int first, /* index of first logged leaf */ 537 int first, /* index of first logged leaf */
540 int last) /* index of last logged leaf */ 538 int last) /* index of last logged leaf */
541{ 539{
542 xfs_dir2_data_hdr_t *hdr = bp->data; 540 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
543 xfs_dir2_leaf_entry_t *blp; 541 xfs_dir2_leaf_entry_t *blp;
544 xfs_dir2_block_tail_t *btp; 542 xfs_dir2_block_tail_t *btp;
545 543
546 btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr); 544 btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr);
547 blp = xfs_dir2_block_leaf_p(btp); 545 blp = xfs_dir2_block_leaf_p(btp);
548 xfs_da_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)hdr), 546 xfs_trans_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)hdr),
549 (uint)((char *)&blp[last + 1] - (char *)hdr - 1)); 547 (uint)((char *)&blp[last + 1] - (char *)hdr - 1));
550} 548}
551 549
@@ -555,13 +553,13 @@ xfs_dir2_block_log_leaf(
555static void 553static void
556xfs_dir2_block_log_tail( 554xfs_dir2_block_log_tail(
557 xfs_trans_t *tp, /* transaction structure */ 555 xfs_trans_t *tp, /* transaction structure */
558 xfs_dabuf_t *bp) /* block buffer */ 556 struct xfs_buf *bp) /* block buffer */
559{ 557{
560 xfs_dir2_data_hdr_t *hdr = bp->data; 558 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
561 xfs_dir2_block_tail_t *btp; 559 xfs_dir2_block_tail_t *btp;
562 560
563 btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr); 561 btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr);
564 xfs_da_log_buf(tp, bp, (uint)((char *)btp - (char *)hdr), 562 xfs_trans_log_buf(tp, bp, (uint)((char *)btp - (char *)hdr),
565 (uint)((char *)(btp + 1) - (char *)hdr - 1)); 563 (uint)((char *)(btp + 1) - (char *)hdr - 1));
566} 564}
567 565
@@ -575,7 +573,7 @@ xfs_dir2_block_lookup(
575{ 573{
576 xfs_dir2_data_hdr_t *hdr; /* block header */ 574 xfs_dir2_data_hdr_t *hdr; /* block header */
577 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ 575 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
578 xfs_dabuf_t *bp; /* block buffer */ 576 struct xfs_buf *bp; /* block buffer */
579 xfs_dir2_block_tail_t *btp; /* block tail */ 577 xfs_dir2_block_tail_t *btp; /* block tail */
580 xfs_dir2_data_entry_t *dep; /* block data entry */ 578 xfs_dir2_data_entry_t *dep; /* block data entry */
581 xfs_inode_t *dp; /* incore inode */ 579 xfs_inode_t *dp; /* incore inode */
@@ -593,7 +591,7 @@ xfs_dir2_block_lookup(
593 return error; 591 return error;
594 dp = args->dp; 592 dp = args->dp;
595 mp = dp->i_mount; 593 mp = dp->i_mount;
596 hdr = bp->data; 594 hdr = bp->b_addr;
597 xfs_dir2_data_check(dp, bp); 595 xfs_dir2_data_check(dp, bp);
598 btp = xfs_dir2_block_tail_p(mp, hdr); 596 btp = xfs_dir2_block_tail_p(mp, hdr);
599 blp = xfs_dir2_block_leaf_p(btp); 597 blp = xfs_dir2_block_leaf_p(btp);
@@ -607,7 +605,7 @@ xfs_dir2_block_lookup(
607 */ 605 */
608 args->inumber = be64_to_cpu(dep->inumber); 606 args->inumber = be64_to_cpu(dep->inumber);
609 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen); 607 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen);
610 xfs_da_brelse(args->trans, bp); 608 xfs_trans_brelse(args->trans, bp);
611 return XFS_ERROR(error); 609 return XFS_ERROR(error);
612} 610}
613 611
@@ -617,13 +615,13 @@ xfs_dir2_block_lookup(
617static int /* error */ 615static int /* error */
618xfs_dir2_block_lookup_int( 616xfs_dir2_block_lookup_int(
619 xfs_da_args_t *args, /* dir lookup arguments */ 617 xfs_da_args_t *args, /* dir lookup arguments */
620 xfs_dabuf_t **bpp, /* returned block buffer */ 618 struct xfs_buf **bpp, /* returned block buffer */
621 int *entno) /* returned entry number */ 619 int *entno) /* returned entry number */
622{ 620{
623 xfs_dir2_dataptr_t addr; /* data entry address */ 621 xfs_dir2_dataptr_t addr; /* data entry address */
624 xfs_dir2_data_hdr_t *hdr; /* block header */ 622 xfs_dir2_data_hdr_t *hdr; /* block header */
625 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ 623 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
626 xfs_dabuf_t *bp; /* block buffer */ 624 struct xfs_buf *bp; /* block buffer */
627 xfs_dir2_block_tail_t *btp; /* block tail */ 625 xfs_dir2_block_tail_t *btp; /* block tail */
628 xfs_dir2_data_entry_t *dep; /* block data entry */ 626 xfs_dir2_data_entry_t *dep; /* block data entry */
629 xfs_inode_t *dp; /* incore inode */ 627 xfs_inode_t *dp; /* incore inode */
@@ -647,7 +645,7 @@ xfs_dir2_block_lookup_int(
647 return error; 645 return error;
648 } 646 }
649 ASSERT(bp != NULL); 647 ASSERT(bp != NULL);
650 hdr = bp->data; 648 hdr = bp->b_addr;
651 xfs_dir2_data_check(dp, bp); 649 xfs_dir2_data_check(dp, bp);
652 btp = xfs_dir2_block_tail_p(mp, hdr); 650 btp = xfs_dir2_block_tail_p(mp, hdr);
653 blp = xfs_dir2_block_leaf_p(btp); 651 blp = xfs_dir2_block_leaf_p(btp);
@@ -666,7 +664,7 @@ xfs_dir2_block_lookup_int(
666 high = mid - 1; 664 high = mid - 1;
667 if (low > high) { 665 if (low > high) {
668 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); 666 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
669 xfs_da_brelse(tp, bp); 667 xfs_trans_brelse(tp, bp);
670 return XFS_ERROR(ENOENT); 668 return XFS_ERROR(ENOENT);
671 } 669 }
672 } 670 }
@@ -714,7 +712,7 @@ xfs_dir2_block_lookup_int(
714 /* 712 /*
715 * No match, release the buffer and return ENOENT. 713 * No match, release the buffer and return ENOENT.
716 */ 714 */
717 xfs_da_brelse(tp, bp); 715 xfs_trans_brelse(tp, bp);
718 return XFS_ERROR(ENOENT); 716 return XFS_ERROR(ENOENT);
719} 717}
720 718
@@ -728,7 +726,7 @@ xfs_dir2_block_removename(
728{ 726{
729 xfs_dir2_data_hdr_t *hdr; /* block header */ 727 xfs_dir2_data_hdr_t *hdr; /* block header */
730 xfs_dir2_leaf_entry_t *blp; /* block leaf pointer */ 728 xfs_dir2_leaf_entry_t *blp; /* block leaf pointer */
731 xfs_dabuf_t *bp; /* block buffer */ 729 struct xfs_buf *bp; /* block buffer */
732 xfs_dir2_block_tail_t *btp; /* block tail */ 730 xfs_dir2_block_tail_t *btp; /* block tail */
733 xfs_dir2_data_entry_t *dep; /* block data entry */ 731 xfs_dir2_data_entry_t *dep; /* block data entry */
734 xfs_inode_t *dp; /* incore inode */ 732 xfs_inode_t *dp; /* incore inode */
@@ -753,7 +751,7 @@ xfs_dir2_block_removename(
753 dp = args->dp; 751 dp = args->dp;
754 tp = args->trans; 752 tp = args->trans;
755 mp = dp->i_mount; 753 mp = dp->i_mount;
756 hdr = bp->data; 754 hdr = bp->b_addr;
757 btp = xfs_dir2_block_tail_p(mp, hdr); 755 btp = xfs_dir2_block_tail_p(mp, hdr);
758 blp = xfs_dir2_block_leaf_p(btp); 756 blp = xfs_dir2_block_leaf_p(btp);
759 /* 757 /*
@@ -790,10 +788,9 @@ xfs_dir2_block_removename(
790 * See if the size as a shortform is good enough. 788 * See if the size as a shortform is good enough.
791 */ 789 */
792 size = xfs_dir2_block_sfsize(dp, hdr, &sfh); 790 size = xfs_dir2_block_sfsize(dp, hdr, &sfh);
793 if (size > XFS_IFORK_DSIZE(dp)) { 791 if (size > XFS_IFORK_DSIZE(dp))
794 xfs_da_buf_done(bp);
795 return 0; 792 return 0;
796 } 793
797 /* 794 /*
798 * If it works, do the conversion. 795 * If it works, do the conversion.
799 */ 796 */
@@ -810,7 +807,7 @@ xfs_dir2_block_replace(
810{ 807{
811 xfs_dir2_data_hdr_t *hdr; /* block header */ 808 xfs_dir2_data_hdr_t *hdr; /* block header */
812 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ 809 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
813 xfs_dabuf_t *bp; /* block buffer */ 810 struct xfs_buf *bp; /* block buffer */
814 xfs_dir2_block_tail_t *btp; /* block tail */ 811 xfs_dir2_block_tail_t *btp; /* block tail */
815 xfs_dir2_data_entry_t *dep; /* block data entry */ 812 xfs_dir2_data_entry_t *dep; /* block data entry */
816 xfs_inode_t *dp; /* incore inode */ 813 xfs_inode_t *dp; /* incore inode */
@@ -829,7 +826,7 @@ xfs_dir2_block_replace(
829 } 826 }
830 dp = args->dp; 827 dp = args->dp;
831 mp = dp->i_mount; 828 mp = dp->i_mount;
832 hdr = bp->data; 829 hdr = bp->b_addr;
833 btp = xfs_dir2_block_tail_p(mp, hdr); 830 btp = xfs_dir2_block_tail_p(mp, hdr);
834 blp = xfs_dir2_block_leaf_p(btp); 831 blp = xfs_dir2_block_leaf_p(btp);
835 /* 832 /*
@@ -844,7 +841,6 @@ xfs_dir2_block_replace(
844 dep->inumber = cpu_to_be64(args->inumber); 841 dep->inumber = cpu_to_be64(args->inumber);
845 xfs_dir2_data_log_entry(args->trans, bp, dep); 842 xfs_dir2_data_log_entry(args->trans, bp, dep);
846 xfs_dir2_data_check(dp, bp); 843 xfs_dir2_data_check(dp, bp);
847 xfs_da_buf_done(bp);
848 return 0; 844 return 0;
849} 845}
850 846
@@ -871,8 +867,8 @@ xfs_dir2_block_sort(
871int /* error */ 867int /* error */
872xfs_dir2_leaf_to_block( 868xfs_dir2_leaf_to_block(
873 xfs_da_args_t *args, /* operation arguments */ 869 xfs_da_args_t *args, /* operation arguments */
874 xfs_dabuf_t *lbp, /* leaf buffer */ 870 struct xfs_buf *lbp, /* leaf buffer */
875 xfs_dabuf_t *dbp) /* data buffer */ 871 struct xfs_buf *dbp) /* data buffer */
876{ 872{
877 __be16 *bestsp; /* leaf bests table */ 873 __be16 *bestsp; /* leaf bests table */
878 xfs_dir2_data_hdr_t *hdr; /* block header */ 874 xfs_dir2_data_hdr_t *hdr; /* block header */
@@ -898,7 +894,7 @@ xfs_dir2_leaf_to_block(
898 dp = args->dp; 894 dp = args->dp;
899 tp = args->trans; 895 tp = args->trans;
900 mp = dp->i_mount; 896 mp = dp->i_mount;
901 leaf = lbp->data; 897 leaf = lbp->b_addr;
902 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC)); 898 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
903 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 899 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
904 /* 900 /*
@@ -914,11 +910,9 @@ xfs_dir2_leaf_to_block(
914 if ((error = 910 if ((error =
915 xfs_dir2_leaf_trim_data(args, lbp, 911 xfs_dir2_leaf_trim_data(args, lbp,
916 (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1)))) 912 (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1))))
917 goto out; 913 return error;
918 } else { 914 } else
919 error = 0; 915 return 0;
920 goto out;
921 }
922 } 916 }
923 /* 917 /*
924 * Read the data block if we don't already have it, give up if it fails. 918 * Read the data block if we don't already have it, give up if it fails.
@@ -926,9 +920,9 @@ xfs_dir2_leaf_to_block(
926 if (dbp == NULL && 920 if (dbp == NULL &&
927 (error = xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &dbp, 921 (error = xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &dbp,
928 XFS_DATA_FORK))) { 922 XFS_DATA_FORK))) {
929 goto out; 923 return error;
930 } 924 }
931 hdr = dbp->data; 925 hdr = dbp->b_addr;
932 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC)); 926 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC));
933 /* 927 /*
934 * Size of the "leaf" area in the block. 928 * Size of the "leaf" area in the block.
@@ -944,10 +938,9 @@ xfs_dir2_leaf_to_block(
944 * If it's not free or is too short we can't do it. 938 * If it's not free or is too short we can't do it.
945 */ 939 */
946 if (be16_to_cpu(dup->freetag) != XFS_DIR2_DATA_FREE_TAG || 940 if (be16_to_cpu(dup->freetag) != XFS_DIR2_DATA_FREE_TAG ||
947 be16_to_cpu(dup->length) < size) { 941 be16_to_cpu(dup->length) < size)
948 error = 0; 942 return 0;
949 goto out; 943
950 }
951 /* 944 /*
952 * Start converting it to block form. 945 * Start converting it to block form.
953 */ 946 */
@@ -989,25 +982,17 @@ xfs_dir2_leaf_to_block(
989 * Pitch the old leaf block. 982 * Pitch the old leaf block.
990 */ 983 */
991 error = xfs_da_shrink_inode(args, mp->m_dirleafblk, lbp); 984 error = xfs_da_shrink_inode(args, mp->m_dirleafblk, lbp);
992 lbp = NULL; 985 if (error)
993 if (error) { 986 return error;
994 goto out; 987
995 }
996 /* 988 /*
997 * Now see if the resulting block can be shrunken to shortform. 989 * Now see if the resulting block can be shrunken to shortform.
998 */ 990 */
999 size = xfs_dir2_block_sfsize(dp, hdr, &sfh); 991 size = xfs_dir2_block_sfsize(dp, hdr, &sfh);
1000 if (size > XFS_IFORK_DSIZE(dp)) { 992 if (size > XFS_IFORK_DSIZE(dp))
1001 error = 0; 993 return 0;
1002 goto out; 994
1003 }
1004 return xfs_dir2_block_to_sf(args, dbp, size, &sfh); 995 return xfs_dir2_block_to_sf(args, dbp, size, &sfh);
1005out:
1006 if (lbp)
1007 xfs_da_buf_done(lbp);
1008 if (dbp)
1009 xfs_da_buf_done(dbp);
1010 return error;
1011} 996}
1012 997
1013/* 998/*
@@ -1020,7 +1005,7 @@ xfs_dir2_sf_to_block(
1020 xfs_dir2_db_t blkno; /* dir-relative block # (0) */ 1005 xfs_dir2_db_t blkno; /* dir-relative block # (0) */
1021 xfs_dir2_data_hdr_t *hdr; /* block header */ 1006 xfs_dir2_data_hdr_t *hdr; /* block header */
1022 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ 1007 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
1023 xfs_dabuf_t *bp; /* block buffer */ 1008 struct xfs_buf *bp; /* block buffer */
1024 xfs_dir2_block_tail_t *btp; /* block tail pointer */ 1009 xfs_dir2_block_tail_t *btp; /* block tail pointer */
1025 xfs_dir2_data_entry_t *dep; /* data entry pointer */ 1010 xfs_dir2_data_entry_t *dep; /* data entry pointer */
1026 xfs_inode_t *dp; /* incore directory inode */ 1011 xfs_inode_t *dp; /* incore directory inode */
@@ -1088,7 +1073,7 @@ xfs_dir2_sf_to_block(
1088 kmem_free(sfp); 1073 kmem_free(sfp);
1089 return error; 1074 return error;
1090 } 1075 }
1091 hdr = bp->data; 1076 hdr = bp->b_addr;
1092 hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); 1077 hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC);
1093 /* 1078 /*
1094 * Compute size of block "tail" area. 1079 * Compute size of block "tail" area.
@@ -1217,6 +1202,5 @@ xfs_dir2_sf_to_block(
1217 xfs_dir2_block_log_leaf(tp, bp, 0, be32_to_cpu(btp->count) - 1); 1202 xfs_dir2_block_log_leaf(tp, bp, 0, be32_to_cpu(btp->count) - 1);
1218 xfs_dir2_block_log_tail(tp, bp); 1203 xfs_dir2_block_log_tail(tp, bp);
1219 xfs_dir2_data_check(dp, bp); 1204 xfs_dir2_data_check(dp, bp);
1220 xfs_da_buf_done(bp);
1221 return 0; 1205 return 0;
1222} 1206}
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index 2046988e9eb2..44ffd4d6bc91 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -42,8 +42,8 @@ xfs_dir2_data_freefind(xfs_dir2_data_hdr_t *hdr, xfs_dir2_data_unused_t *dup);
42 */ 42 */
43void 43void
44xfs_dir2_data_check( 44xfs_dir2_data_check(
45 xfs_inode_t *dp, /* incore inode pointer */ 45 struct xfs_inode *dp, /* incore inode pointer */
46 xfs_dabuf_t *bp) /* data block's buffer */ 46 struct xfs_buf *bp) /* data block's buffer */
47{ 47{
48 xfs_dir2_dataptr_t addr; /* addr for leaf lookup */ 48 xfs_dir2_dataptr_t addr; /* addr for leaf lookup */
49 xfs_dir2_data_free_t *bf; /* bestfree table */ 49 xfs_dir2_data_free_t *bf; /* bestfree table */
@@ -65,7 +65,7 @@ xfs_dir2_data_check(
65 struct xfs_name name; 65 struct xfs_name name;
66 66
67 mp = dp->i_mount; 67 mp = dp->i_mount;
68 hdr = bp->data; 68 hdr = bp->b_addr;
69 bf = hdr->bestfree; 69 bf = hdr->bestfree;
70 p = (char *)(hdr + 1); 70 p = (char *)(hdr + 1);
71 71
@@ -389,9 +389,9 @@ int /* error */
389xfs_dir2_data_init( 389xfs_dir2_data_init(
390 xfs_da_args_t *args, /* directory operation args */ 390 xfs_da_args_t *args, /* directory operation args */
391 xfs_dir2_db_t blkno, /* logical dir block number */ 391 xfs_dir2_db_t blkno, /* logical dir block number */
392 xfs_dabuf_t **bpp) /* output block buffer */ 392 struct xfs_buf **bpp) /* output block buffer */
393{ 393{
394 xfs_dabuf_t *bp; /* block buffer */ 394 struct xfs_buf *bp; /* block buffer */
395 xfs_dir2_data_hdr_t *hdr; /* data block header */ 395 xfs_dir2_data_hdr_t *hdr; /* data block header */
396 xfs_inode_t *dp; /* incore directory inode */ 396 xfs_inode_t *dp; /* incore directory inode */
397 xfs_dir2_data_unused_t *dup; /* unused entry pointer */ 397 xfs_dir2_data_unused_t *dup; /* unused entry pointer */
@@ -417,7 +417,7 @@ xfs_dir2_data_init(
417 /* 417 /*
418 * Initialize the header. 418 * Initialize the header.
419 */ 419 */
420 hdr = bp->data; 420 hdr = bp->b_addr;
421 hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); 421 hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
422 hdr->bestfree[0].offset = cpu_to_be16(sizeof(*hdr)); 422 hdr->bestfree[0].offset = cpu_to_be16(sizeof(*hdr));
423 for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) { 423 for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) {
@@ -449,16 +449,16 @@ xfs_dir2_data_init(
449 */ 449 */
450void 450void
451xfs_dir2_data_log_entry( 451xfs_dir2_data_log_entry(
452 xfs_trans_t *tp, /* transaction pointer */ 452 struct xfs_trans *tp,
453 xfs_dabuf_t *bp, /* block buffer */ 453 struct xfs_buf *bp,
454 xfs_dir2_data_entry_t *dep) /* data entry pointer */ 454 xfs_dir2_data_entry_t *dep) /* data entry pointer */
455{ 455{
456 xfs_dir2_data_hdr_t *hdr = bp->data; 456 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
457 457
458 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 458 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
459 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); 459 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
460 460
461 xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)hdr), 461 xfs_trans_log_buf(tp, bp, (uint)((char *)dep - (char *)hdr),
462 (uint)((char *)(xfs_dir2_data_entry_tag_p(dep) + 1) - 462 (uint)((char *)(xfs_dir2_data_entry_tag_p(dep) + 1) -
463 (char *)hdr - 1)); 463 (char *)hdr - 1));
464} 464}
@@ -468,15 +468,15 @@ xfs_dir2_data_log_entry(
468 */ 468 */
469void 469void
470xfs_dir2_data_log_header( 470xfs_dir2_data_log_header(
471 xfs_trans_t *tp, /* transaction pointer */ 471 struct xfs_trans *tp,
472 xfs_dabuf_t *bp) /* block buffer */ 472 struct xfs_buf *bp)
473{ 473{
474 xfs_dir2_data_hdr_t *hdr = bp->data; 474 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
475 475
476 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 476 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
477 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); 477 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
478 478
479 xfs_da_log_buf(tp, bp, 0, sizeof(*hdr) - 1); 479 xfs_trans_log_buf(tp, bp, 0, sizeof(*hdr) - 1);
480} 480}
481 481
482/* 482/*
@@ -484,11 +484,11 @@ xfs_dir2_data_log_header(
484 */ 484 */
485void 485void
486xfs_dir2_data_log_unused( 486xfs_dir2_data_log_unused(
487 xfs_trans_t *tp, /* transaction pointer */ 487 struct xfs_trans *tp,
488 xfs_dabuf_t *bp, /* block buffer */ 488 struct xfs_buf *bp,
489 xfs_dir2_data_unused_t *dup) /* data unused pointer */ 489 xfs_dir2_data_unused_t *dup) /* data unused pointer */
490{ 490{
491 xfs_dir2_data_hdr_t *hdr = bp->data; 491 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
492 492
493 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 493 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
494 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); 494 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
@@ -496,13 +496,13 @@ xfs_dir2_data_log_unused(
496 /* 496 /*
497 * Log the first part of the unused entry. 497 * Log the first part of the unused entry.
498 */ 498 */
499 xfs_da_log_buf(tp, bp, (uint)((char *)dup - (char *)hdr), 499 xfs_trans_log_buf(tp, bp, (uint)((char *)dup - (char *)hdr),
500 (uint)((char *)&dup->length + sizeof(dup->length) - 500 (uint)((char *)&dup->length + sizeof(dup->length) -
501 1 - (char *)hdr)); 501 1 - (char *)hdr));
502 /* 502 /*
503 * Log the end (tag) of the unused entry. 503 * Log the end (tag) of the unused entry.
504 */ 504 */
505 xfs_da_log_buf(tp, bp, 505 xfs_trans_log_buf(tp, bp,
506 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr), 506 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr),
507 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr + 507 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr +
508 sizeof(xfs_dir2_data_off_t) - 1)); 508 sizeof(xfs_dir2_data_off_t) - 1));
@@ -514,8 +514,8 @@ xfs_dir2_data_log_unused(
514 */ 514 */
515void 515void
516xfs_dir2_data_make_free( 516xfs_dir2_data_make_free(
517 xfs_trans_t *tp, /* transaction pointer */ 517 struct xfs_trans *tp,
518 xfs_dabuf_t *bp, /* block buffer */ 518 struct xfs_buf *bp,
519 xfs_dir2_data_aoff_t offset, /* starting byte offset */ 519 xfs_dir2_data_aoff_t offset, /* starting byte offset */
520 xfs_dir2_data_aoff_t len, /* length in bytes */ 520 xfs_dir2_data_aoff_t len, /* length in bytes */
521 int *needlogp, /* out: log header */ 521 int *needlogp, /* out: log header */
@@ -531,7 +531,7 @@ xfs_dir2_data_make_free(
531 xfs_dir2_data_unused_t *prevdup; /* unused entry before us */ 531 xfs_dir2_data_unused_t *prevdup; /* unused entry before us */
532 532
533 mp = tp->t_mountp; 533 mp = tp->t_mountp;
534 hdr = bp->data; 534 hdr = bp->b_addr;
535 535
536 /* 536 /*
537 * Figure out where the end of the data area is. 537 * Figure out where the end of the data area is.
@@ -696,8 +696,8 @@ xfs_dir2_data_make_free(
696 */ 696 */
697void 697void
698xfs_dir2_data_use_free( 698xfs_dir2_data_use_free(
699 xfs_trans_t *tp, /* transaction pointer */ 699 struct xfs_trans *tp,
700 xfs_dabuf_t *bp, /* data block buffer */ 700 struct xfs_buf *bp,
701 xfs_dir2_data_unused_t *dup, /* unused entry */ 701 xfs_dir2_data_unused_t *dup, /* unused entry */
702 xfs_dir2_data_aoff_t offset, /* starting offset to use */ 702 xfs_dir2_data_aoff_t offset, /* starting offset to use */
703 xfs_dir2_data_aoff_t len, /* length to use */ 703 xfs_dir2_data_aoff_t len, /* length to use */
@@ -713,7 +713,7 @@ xfs_dir2_data_use_free(
713 xfs_dir2_data_unused_t *newdup2; /* another new unused entry */ 713 xfs_dir2_data_unused_t *newdup2; /* another new unused entry */
714 int oldlen; /* old unused entry's length */ 714 int oldlen; /* old unused entry's length */
715 715
716 hdr = bp->data; 716 hdr = bp->b_addr;
717 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 717 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
718 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); 718 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
719 ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG); 719 ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG);
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index 397ffbcbab1d..0b296253bd01 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -38,15 +38,15 @@
38 * Local function declarations. 38 * Local function declarations.
39 */ 39 */
40#ifdef DEBUG 40#ifdef DEBUG
41static void xfs_dir2_leaf_check(xfs_inode_t *dp, xfs_dabuf_t *bp); 41static void xfs_dir2_leaf_check(struct xfs_inode *dp, struct xfs_buf *bp);
42#else 42#else
43#define xfs_dir2_leaf_check(dp, bp) 43#define xfs_dir2_leaf_check(dp, bp)
44#endif 44#endif
45static int xfs_dir2_leaf_lookup_int(xfs_da_args_t *args, xfs_dabuf_t **lbpp, 45static int xfs_dir2_leaf_lookup_int(xfs_da_args_t *args, struct xfs_buf **lbpp,
46 int *indexp, xfs_dabuf_t **dbpp); 46 int *indexp, struct xfs_buf **dbpp);
47static void xfs_dir2_leaf_log_bests(struct xfs_trans *tp, struct xfs_dabuf *bp, 47static void xfs_dir2_leaf_log_bests(struct xfs_trans *tp, struct xfs_buf *bp,
48 int first, int last); 48 int first, int last);
49static void xfs_dir2_leaf_log_tail(struct xfs_trans *tp, struct xfs_dabuf *bp); 49static void xfs_dir2_leaf_log_tail(struct xfs_trans *tp, struct xfs_buf *bp);
50 50
51 51
52/* 52/*
@@ -55,7 +55,7 @@ static void xfs_dir2_leaf_log_tail(struct xfs_trans *tp, struct xfs_dabuf *bp);
55int /* error */ 55int /* error */
56xfs_dir2_block_to_leaf( 56xfs_dir2_block_to_leaf(
57 xfs_da_args_t *args, /* operation arguments */ 57 xfs_da_args_t *args, /* operation arguments */
58 xfs_dabuf_t *dbp) /* input block's buffer */ 58 struct xfs_buf *dbp) /* input block's buffer */
59{ 59{
60 __be16 *bestsp; /* leaf's bestsp entries */ 60 __be16 *bestsp; /* leaf's bestsp entries */
61 xfs_dablk_t blkno; /* leaf block's bno */ 61 xfs_dablk_t blkno; /* leaf block's bno */
@@ -64,7 +64,7 @@ xfs_dir2_block_to_leaf(
64 xfs_dir2_block_tail_t *btp; /* block's tail */ 64 xfs_dir2_block_tail_t *btp; /* block's tail */
65 xfs_inode_t *dp; /* incore directory inode */ 65 xfs_inode_t *dp; /* incore directory inode */
66 int error; /* error return code */ 66 int error; /* error return code */
67 xfs_dabuf_t *lbp; /* leaf block's buffer */ 67 struct xfs_buf *lbp; /* leaf block's buffer */
68 xfs_dir2_db_t ldb; /* leaf block's bno */ 68 xfs_dir2_db_t ldb; /* leaf block's bno */
69 xfs_dir2_leaf_t *leaf; /* leaf structure */ 69 xfs_dir2_leaf_t *leaf; /* leaf structure */
70 xfs_dir2_leaf_tail_t *ltp; /* leaf's tail */ 70 xfs_dir2_leaf_tail_t *ltp; /* leaf's tail */
@@ -95,8 +95,8 @@ xfs_dir2_block_to_leaf(
95 return error; 95 return error;
96 } 96 }
97 ASSERT(lbp != NULL); 97 ASSERT(lbp != NULL);
98 leaf = lbp->data; 98 leaf = lbp->b_addr;
99 hdr = dbp->data; 99 hdr = dbp->b_addr;
100 xfs_dir2_data_check(dp, dbp); 100 xfs_dir2_data_check(dp, dbp);
101 btp = xfs_dir2_block_tail_p(mp, hdr); 101 btp = xfs_dir2_block_tail_p(mp, hdr);
102 blp = xfs_dir2_block_leaf_p(btp); 102 blp = xfs_dir2_block_leaf_p(btp);
@@ -143,7 +143,6 @@ xfs_dir2_block_to_leaf(
143 xfs_dir2_leaf_check(dp, lbp); 143 xfs_dir2_leaf_check(dp, lbp);
144 xfs_dir2_data_check(dp, dbp); 144 xfs_dir2_data_check(dp, dbp);
145 xfs_dir2_leaf_log_bests(tp, lbp, 0, 0); 145 xfs_dir2_leaf_log_bests(tp, lbp, 0, 0);
146 xfs_da_buf_done(lbp);
147 return 0; 146 return 0;
148} 147}
149 148
@@ -282,7 +281,7 @@ xfs_dir2_leaf_addname(
282 __be16 *bestsp; /* freespace table in leaf */ 281 __be16 *bestsp; /* freespace table in leaf */
283 int compact; /* need to compact leaves */ 282 int compact; /* need to compact leaves */
284 xfs_dir2_data_hdr_t *hdr; /* data block header */ 283 xfs_dir2_data_hdr_t *hdr; /* data block header */
285 xfs_dabuf_t *dbp; /* data block buffer */ 284 struct xfs_buf *dbp; /* data block buffer */
286 xfs_dir2_data_entry_t *dep; /* data block entry */ 285 xfs_dir2_data_entry_t *dep; /* data block entry */
287 xfs_inode_t *dp; /* incore directory inode */ 286 xfs_inode_t *dp; /* incore directory inode */
288 xfs_dir2_data_unused_t *dup; /* data unused entry */ 287 xfs_dir2_data_unused_t *dup; /* data unused entry */
@@ -291,7 +290,7 @@ xfs_dir2_leaf_addname(
291 int highstale; /* index of next stale leaf */ 290 int highstale; /* index of next stale leaf */
292 int i; /* temporary, index */ 291 int i; /* temporary, index */
293 int index; /* leaf table position */ 292 int index; /* leaf table position */
294 xfs_dabuf_t *lbp; /* leaf's buffer */ 293 struct xfs_buf *lbp; /* leaf's buffer */
295 xfs_dir2_leaf_t *leaf; /* leaf structure */ 294 xfs_dir2_leaf_t *leaf; /* leaf structure */
296 int length; /* length of new entry */ 295 int length; /* length of new entry */
297 xfs_dir2_leaf_entry_t *lep; /* leaf entry table pointer */ 296 xfs_dir2_leaf_entry_t *lep; /* leaf entry table pointer */
@@ -328,7 +327,7 @@ xfs_dir2_leaf_addname(
328 * But if there are dup hash values the index is of the first of those. 327 * But if there are dup hash values the index is of the first of those.
329 */ 328 */
330 index = xfs_dir2_leaf_search_hash(args, lbp); 329 index = xfs_dir2_leaf_search_hash(args, lbp);
331 leaf = lbp->data; 330 leaf = lbp->b_addr;
332 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 331 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
333 bestsp = xfs_dir2_leaf_bests_p(ltp); 332 bestsp = xfs_dir2_leaf_bests_p(ltp);
334 length = xfs_dir2_data_entsize(args->namelen); 333 length = xfs_dir2_data_entsize(args->namelen);
@@ -402,14 +401,13 @@ xfs_dir2_leaf_addname(
402 */ 401 */
403 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || 402 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) ||
404 args->total == 0) { 403 args->total == 0) {
405 xfs_da_brelse(tp, lbp); 404 xfs_trans_brelse(tp, lbp);
406 return XFS_ERROR(ENOSPC); 405 return XFS_ERROR(ENOSPC);
407 } 406 }
408 /* 407 /*
409 * Convert to node form. 408 * Convert to node form.
410 */ 409 */
411 error = xfs_dir2_leaf_to_node(args, lbp); 410 error = xfs_dir2_leaf_to_node(args, lbp);
412 xfs_da_buf_done(lbp);
413 if (error) 411 if (error)
414 return error; 412 return error;
415 /* 413 /*
@@ -427,7 +425,7 @@ xfs_dir2_leaf_addname(
427 * a new data block. 425 * a new data block.
428 */ 426 */
429 if (args->op_flags & XFS_DA_OP_JUSTCHECK) { 427 if (args->op_flags & XFS_DA_OP_JUSTCHECK) {
430 xfs_da_brelse(tp, lbp); 428 xfs_trans_brelse(tp, lbp);
431 return use_block == -1 ? XFS_ERROR(ENOSPC) : 0; 429 return use_block == -1 ? XFS_ERROR(ENOSPC) : 0;
432 } 430 }
433 /* 431 /*
@@ -435,7 +433,7 @@ xfs_dir2_leaf_addname(
435 * changed anything. 433 * changed anything.
436 */ 434 */
437 if (args->total == 0 && use_block == -1) { 435 if (args->total == 0 && use_block == -1) {
438 xfs_da_brelse(tp, lbp); 436 xfs_trans_brelse(tp, lbp);
439 return XFS_ERROR(ENOSPC); 437 return XFS_ERROR(ENOSPC);
440 } 438 }
441 /* 439 /*
@@ -466,14 +464,14 @@ xfs_dir2_leaf_addname(
466 */ 464 */
467 if ((error = xfs_dir2_grow_inode(args, XFS_DIR2_DATA_SPACE, 465 if ((error = xfs_dir2_grow_inode(args, XFS_DIR2_DATA_SPACE,
468 &use_block))) { 466 &use_block))) {
469 xfs_da_brelse(tp, lbp); 467 xfs_trans_brelse(tp, lbp);
470 return error; 468 return error;
471 } 469 }
472 /* 470 /*
473 * Initialize the block. 471 * Initialize the block.
474 */ 472 */
475 if ((error = xfs_dir2_data_init(args, use_block, &dbp))) { 473 if ((error = xfs_dir2_data_init(args, use_block, &dbp))) {
476 xfs_da_brelse(tp, lbp); 474 xfs_trans_brelse(tp, lbp);
477 return error; 475 return error;
478 } 476 }
479 /* 477 /*
@@ -493,7 +491,7 @@ xfs_dir2_leaf_addname(
493 */ 491 */
494 else 492 else
495 xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); 493 xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block);
496 hdr = dbp->data; 494 hdr = dbp->b_addr;
497 bestsp[use_block] = hdr->bestfree[0].length; 495 bestsp[use_block] = hdr->bestfree[0].length;
498 grown = 1; 496 grown = 1;
499 } 497 }
@@ -505,10 +503,10 @@ xfs_dir2_leaf_addname(
505 if ((error = 503 if ((error =
506 xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, use_block), 504 xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, use_block),
507 -1, &dbp, XFS_DATA_FORK))) { 505 -1, &dbp, XFS_DATA_FORK))) {
508 xfs_da_brelse(tp, lbp); 506 xfs_trans_brelse(tp, lbp);
509 return error; 507 return error;
510 } 508 }
511 hdr = dbp->data; 509 hdr = dbp->b_addr;
512 grown = 0; 510 grown = 0;
513 } 511 }
514 xfs_dir2_data_check(dp, dbp); 512 xfs_dir2_data_check(dp, dbp);
@@ -570,9 +568,7 @@ xfs_dir2_leaf_addname(
570 xfs_dir2_leaf_log_header(tp, lbp); 568 xfs_dir2_leaf_log_header(tp, lbp);
571 xfs_dir2_leaf_log_ents(tp, lbp, lfloglow, lfloghigh); 569 xfs_dir2_leaf_log_ents(tp, lbp, lfloglow, lfloghigh);
572 xfs_dir2_leaf_check(dp, lbp); 570 xfs_dir2_leaf_check(dp, lbp);
573 xfs_da_buf_done(lbp);
574 xfs_dir2_data_check(dp, dbp); 571 xfs_dir2_data_check(dp, dbp);
575 xfs_da_buf_done(dbp);
576 return 0; 572 return 0;
577} 573}
578 574
@@ -583,8 +579,8 @@ xfs_dir2_leaf_addname(
583 */ 579 */
584STATIC void 580STATIC void
585xfs_dir2_leaf_check( 581xfs_dir2_leaf_check(
586 xfs_inode_t *dp, /* incore directory inode */ 582 struct xfs_inode *dp, /* incore directory inode */
587 xfs_dabuf_t *bp) /* leaf's buffer */ 583 struct xfs_buf *bp) /* leaf's buffer */
588{ 584{
589 int i; /* leaf index */ 585 int i; /* leaf index */
590 xfs_dir2_leaf_t *leaf; /* leaf structure */ 586 xfs_dir2_leaf_t *leaf; /* leaf structure */
@@ -592,7 +588,7 @@ xfs_dir2_leaf_check(
592 xfs_mount_t *mp; /* filesystem mount point */ 588 xfs_mount_t *mp; /* filesystem mount point */
593 int stale; /* count of stale leaves */ 589 int stale; /* count of stale leaves */
594 590
595 leaf = bp->data; 591 leaf = bp->b_addr;
596 mp = dp->i_mount; 592 mp = dp->i_mount;
597 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC)); 593 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
598 /* 594 /*
@@ -628,14 +624,14 @@ xfs_dir2_leaf_check(
628void 624void
629xfs_dir2_leaf_compact( 625xfs_dir2_leaf_compact(
630 xfs_da_args_t *args, /* operation arguments */ 626 xfs_da_args_t *args, /* operation arguments */
631 xfs_dabuf_t *bp) /* leaf buffer */ 627 struct xfs_buf *bp) /* leaf buffer */
632{ 628{
633 int from; /* source leaf index */ 629 int from; /* source leaf index */
634 xfs_dir2_leaf_t *leaf; /* leaf structure */ 630 xfs_dir2_leaf_t *leaf; /* leaf structure */
635 int loglow; /* first leaf entry to log */ 631 int loglow; /* first leaf entry to log */
636 int to; /* target leaf index */ 632 int to; /* target leaf index */
637 633
638 leaf = bp->data; 634 leaf = bp->b_addr;
639 if (!leaf->hdr.stale) { 635 if (!leaf->hdr.stale) {
640 return; 636 return;
641 } 637 }
@@ -677,7 +673,7 @@ xfs_dir2_leaf_compact(
677 */ 673 */
678void 674void
679xfs_dir2_leaf_compact_x1( 675xfs_dir2_leaf_compact_x1(
680 xfs_dabuf_t *bp, /* leaf buffer */ 676 struct xfs_buf *bp, /* leaf buffer */
681 int *indexp, /* insertion index */ 677 int *indexp, /* insertion index */
682 int *lowstalep, /* out: stale entry before us */ 678 int *lowstalep, /* out: stale entry before us */
683 int *highstalep, /* out: stale entry after us */ 679 int *highstalep, /* out: stale entry after us */
@@ -693,7 +689,7 @@ xfs_dir2_leaf_compact_x1(
693 int newindex=0; /* new insertion index */ 689 int newindex=0; /* new insertion index */
694 int to; /* destination copy index */ 690 int to; /* destination copy index */
695 691
696 leaf = bp->data; 692 leaf = bp->b_addr;
697 ASSERT(be16_to_cpu(leaf->hdr.stale) > 1); 693 ASSERT(be16_to_cpu(leaf->hdr.stale) > 1);
698 index = *indexp; 694 index = *indexp;
699 695
@@ -763,6 +759,218 @@ xfs_dir2_leaf_compact_x1(
763 *highstalep = highstale; 759 *highstalep = highstale;
764} 760}
765 761
762struct xfs_dir2_leaf_map_info {
763 xfs_extlen_t map_blocks; /* number of fsbs in map */
764 xfs_dablk_t map_off; /* last mapped file offset */
765 int map_size; /* total entries in *map */
766 int map_valid; /* valid entries in *map */
767 int nmap; /* mappings to ask xfs_bmapi */
768 xfs_dir2_db_t curdb; /* db for current block */
769 int ra_current; /* number of read-ahead blks */
770 int ra_index; /* *map index for read-ahead */
771 int ra_offset; /* map entry offset for ra */
772 int ra_want; /* readahead count wanted */
773 struct xfs_bmbt_irec map[]; /* map vector for blocks */
774};
775
776STATIC int
777xfs_dir2_leaf_readbuf(
778 struct xfs_inode *dp,
779 size_t bufsize,
780 struct xfs_dir2_leaf_map_info *mip,
781 xfs_dir2_off_t *curoff,
782 struct xfs_buf **bpp)
783{
784 struct xfs_mount *mp = dp->i_mount;
785 struct xfs_buf *bp = *bpp;
786 struct xfs_bmbt_irec *map = mip->map;
787 int error = 0;
788 int length;
789 int i;
790 int j;
791
792 /*
793 * If we have a buffer, we need to release it and
794 * take it out of the mapping.
795 */
796
797 if (bp) {
798 xfs_trans_brelse(NULL, bp);
799 bp = NULL;
800 mip->map_blocks -= mp->m_dirblkfsbs;
801 /*
802 * Loop to get rid of the extents for the
803 * directory block.
804 */
805 for (i = mp->m_dirblkfsbs; i > 0; ) {
806 j = min_t(int, map->br_blockcount, i);
807 map->br_blockcount -= j;
808 map->br_startblock += j;
809 map->br_startoff += j;
810 /*
811 * If mapping is done, pitch it from
812 * the table.
813 */
814 if (!map->br_blockcount && --mip->map_valid)
815 memmove(&map[0], &map[1],
816 sizeof(map[0]) * mip->map_valid);
817 i -= j;
818 }
819 }
820
821 /*
822 * Recalculate the readahead blocks wanted.
823 */
824 mip->ra_want = howmany(bufsize + mp->m_dirblksize,
825 mp->m_sb.sb_blocksize) - 1;
826 ASSERT(mip->ra_want >= 0);
827
828 /*
829 * If we don't have as many as we want, and we haven't
830 * run out of data blocks, get some more mappings.
831 */
832 if (1 + mip->ra_want > mip->map_blocks &&
833 mip->map_off < xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET)) {
834 /*
835 * Get more bmaps, fill in after the ones
836 * we already have in the table.
837 */
838 mip->nmap = mip->map_size - mip->map_valid;
839 error = xfs_bmapi_read(dp, mip->map_off,
840 xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET) -
841 mip->map_off,
842 &map[mip->map_valid], &mip->nmap, 0);
843
844 /*
845 * Don't know if we should ignore this or try to return an
846 * error. The trouble with returning errors is that readdir
847 * will just stop without actually passing the error through.
848 */
849 if (error)
850 goto out; /* XXX */
851
852 /*
853 * If we got all the mappings we asked for, set the final map
854 * offset based on the last bmap value received. Otherwise,
855 * we've reached the end.
856 */
857 if (mip->nmap == mip->map_size - mip->map_valid) {
858 i = mip->map_valid + mip->nmap - 1;
859 mip->map_off = map[i].br_startoff + map[i].br_blockcount;
860 } else
861 mip->map_off = xfs_dir2_byte_to_da(mp,
862 XFS_DIR2_LEAF_OFFSET);
863
864 /*
865 * Look for holes in the mapping, and eliminate them. Count up
866 * the valid blocks.
867 */
868 for (i = mip->map_valid; i < mip->map_valid + mip->nmap; ) {
869 if (map[i].br_startblock == HOLESTARTBLOCK) {
870 mip->nmap--;
871 length = mip->map_valid + mip->nmap - i;
872 if (length)
873 memmove(&map[i], &map[i + 1],
874 sizeof(map[i]) * length);
875 } else {
876 mip->map_blocks += map[i].br_blockcount;
877 i++;
878 }
879 }
880 mip->map_valid += mip->nmap;
881 }
882
883 /*
884 * No valid mappings, so no more data blocks.
885 */
886 if (!mip->map_valid) {
887 *curoff = xfs_dir2_da_to_byte(mp, mip->map_off);
888 goto out;
889 }
890
891 /*
892 * Read the directory block starting at the first mapping.
893 */
894 mip->curdb = xfs_dir2_da_to_db(mp, map->br_startoff);
895 error = xfs_da_read_buf(NULL, dp, map->br_startoff,
896 map->br_blockcount >= mp->m_dirblkfsbs ?
897 XFS_FSB_TO_DADDR(mp, map->br_startblock) : -1,
898 &bp, XFS_DATA_FORK);
899
900 /*
901 * Should just skip over the data block instead of giving up.
902 */
903 if (error)
904 goto out; /* XXX */
905
906 /*
907 * Adjust the current amount of read-ahead: we just read a block that
908 * was previously ra.
909 */
910 if (mip->ra_current)
911 mip->ra_current -= mp->m_dirblkfsbs;
912
913 /*
914 * Do we need more readahead?
915 */
916 for (mip->ra_index = mip->ra_offset = i = 0;
917 mip->ra_want > mip->ra_current && i < mip->map_blocks;
918 i += mp->m_dirblkfsbs) {
919 ASSERT(mip->ra_index < mip->map_valid);
920 /*
921 * Read-ahead a contiguous directory block.
922 */
923 if (i > mip->ra_current &&
924 map[mip->ra_index].br_blockcount >= mp->m_dirblkfsbs) {
925 xfs_buf_readahead(mp->m_ddev_targp,
926 XFS_FSB_TO_DADDR(mp,
927 map[mip->ra_index].br_startblock +
928 mip->ra_offset),
929 (int)BTOBB(mp->m_dirblksize));
930 mip->ra_current = i;
931 }
932
933 /*
934 * Read-ahead a non-contiguous directory block. This doesn't
935 * use our mapping, but this is a very rare case.
936 */
937 else if (i > mip->ra_current) {
938 xfs_da_reada_buf(NULL, dp,
939 map[mip->ra_index].br_startoff +
940 mip->ra_offset,
941 XFS_DATA_FORK);
942 mip->ra_current = i;
943 }
944
945 /*
946 * Advance offset through the mapping table.
947 */
948 for (j = 0; j < mp->m_dirblkfsbs; j++) {
949 /*
950 * The rest of this extent but not more than a dir
951 * block.
952 */
953 length = min_t(int, mp->m_dirblkfsbs,
954 map[mip->ra_index].br_blockcount -
955 mip->ra_offset);
956 j += length;
957 mip->ra_offset += length;
958
959 /*
960 * Advance to the next mapping if this one is used up.
961 */
962 if (mip->ra_offset == map[mip->ra_index].br_blockcount) {
963 mip->ra_offset = 0;
964 mip->ra_index++;
965 }
966 }
967 }
968
969out:
970 *bpp = bp;
971 return error;
972}
973
766/* 974/*
767 * Getdents (readdir) for leaf and node directories. 975 * Getdents (readdir) for leaf and node directories.
768 * This reads the data blocks only, so is the same for both forms. 976 * This reads the data blocks only, so is the same for both forms.
@@ -775,30 +983,18 @@ xfs_dir2_leaf_getdents(
775 xfs_off_t *offset, 983 xfs_off_t *offset,
776 filldir_t filldir) 984 filldir_t filldir)
777{ 985{
778 xfs_dabuf_t *bp; /* data block buffer */ 986 struct xfs_buf *bp = NULL; /* data block buffer */
779 int byteoff; /* offset in current block */
780 xfs_dir2_db_t curdb; /* db for current block */
781 xfs_dir2_off_t curoff; /* current overall offset */
782 xfs_dir2_data_hdr_t *hdr; /* data block header */ 987 xfs_dir2_data_hdr_t *hdr; /* data block header */
783 xfs_dir2_data_entry_t *dep; /* data entry */ 988 xfs_dir2_data_entry_t *dep; /* data entry */
784 xfs_dir2_data_unused_t *dup; /* unused entry */ 989 xfs_dir2_data_unused_t *dup; /* unused entry */
785 int error = 0; /* error return value */ 990 int error = 0; /* error return value */
786 int i; /* temporary loop index */
787 int j; /* temporary loop index */
788 int length; /* temporary length value */ 991 int length; /* temporary length value */
789 xfs_bmbt_irec_t *map; /* map vector for blocks */
790 xfs_extlen_t map_blocks; /* number of fsbs in map */
791 xfs_dablk_t map_off; /* last mapped file offset */
792 int map_size; /* total entries in *map */
793 int map_valid; /* valid entries in *map */
794 xfs_mount_t *mp; /* filesystem mount point */ 992 xfs_mount_t *mp; /* filesystem mount point */
993 int byteoff; /* offset in current block */
994 xfs_dir2_off_t curoff; /* current overall offset */
795 xfs_dir2_off_t newoff; /* new curoff after new blk */ 995 xfs_dir2_off_t newoff; /* new curoff after new blk */
796 int nmap; /* mappings to ask xfs_bmapi */
797 char *ptr = NULL; /* pointer to current data */ 996 char *ptr = NULL; /* pointer to current data */
798 int ra_current; /* number of read-ahead blks */ 997 struct xfs_dir2_leaf_map_info *map_info;
799 int ra_index; /* *map index for read-ahead */
800 int ra_offset; /* map entry offset for ra */
801 int ra_want; /* readahead count wanted */
802 998
803 /* 999 /*
804 * If the offset is at or past the largest allowed value, 1000 * If the offset is at or past the largest allowed value,
@@ -814,10 +1010,12 @@ xfs_dir2_leaf_getdents(
814 * buffer size, the directory block size, and the filesystem 1010 * buffer size, the directory block size, and the filesystem
815 * block size. 1011 * block size.
816 */ 1012 */
817 map_size = howmany(bufsize + mp->m_dirblksize, mp->m_sb.sb_blocksize); 1013 length = howmany(bufsize + mp->m_dirblksize,
818 map = kmem_alloc(map_size * sizeof(*map), KM_SLEEP); 1014 mp->m_sb.sb_blocksize);
819 map_valid = ra_index = ra_offset = ra_current = map_blocks = 0; 1015 map_info = kmem_zalloc(offsetof(struct xfs_dir2_leaf_map_info, map) +
820 bp = NULL; 1016 (length * sizeof(struct xfs_bmbt_irec)),
1017 KM_SLEEP);
1018 map_info->map_size = length;
821 1019
822 /* 1020 /*
823 * Inside the loop we keep the main offset value as a byte offset 1021 * Inside the loop we keep the main offset value as a byte offset
@@ -829,7 +1027,9 @@ xfs_dir2_leaf_getdents(
829 * Force this conversion through db so we truncate the offset 1027 * Force this conversion through db so we truncate the offset
830 * down to get the start of the data block. 1028 * down to get the start of the data block.
831 */ 1029 */
832 map_off = xfs_dir2_db_to_da(mp, xfs_dir2_byte_to_db(mp, curoff)); 1030 map_info->map_off = xfs_dir2_db_to_da(mp,
1031 xfs_dir2_byte_to_db(mp, curoff));
1032
833 /* 1033 /*
834 * Loop over directory entries until we reach the end offset. 1034 * Loop over directory entries until we reach the end offset.
835 * Get more blocks and readahead as necessary. 1035 * Get more blocks and readahead as necessary.
@@ -839,191 +1039,17 @@ xfs_dir2_leaf_getdents(
839 * If we have no buffer, or we're off the end of the 1039 * If we have no buffer, or we're off the end of the
840 * current buffer, need to get another one. 1040 * current buffer, need to get another one.
841 */ 1041 */
842 if (!bp || ptr >= (char *)bp->data + mp->m_dirblksize) { 1042 if (!bp || ptr >= (char *)bp->b_addr + mp->m_dirblksize) {
843 /*
844 * If we have a buffer, we need to release it and
845 * take it out of the mapping.
846 */
847 if (bp) {
848 xfs_da_brelse(NULL, bp);
849 bp = NULL;
850 map_blocks -= mp->m_dirblkfsbs;
851 /*
852 * Loop to get rid of the extents for the
853 * directory block.
854 */
855 for (i = mp->m_dirblkfsbs; i > 0; ) {
856 j = MIN((int)map->br_blockcount, i);
857 map->br_blockcount -= j;
858 map->br_startblock += j;
859 map->br_startoff += j;
860 /*
861 * If mapping is done, pitch it from
862 * the table.
863 */
864 if (!map->br_blockcount && --map_valid)
865 memmove(&map[0], &map[1],
866 sizeof(map[0]) *
867 map_valid);
868 i -= j;
869 }
870 }
871 /*
872 * Recalculate the readahead blocks wanted.
873 */
874 ra_want = howmany(bufsize + mp->m_dirblksize,
875 mp->m_sb.sb_blocksize) - 1;
876 ASSERT(ra_want >= 0);
877 1043
878 /* 1044 error = xfs_dir2_leaf_readbuf(dp, bufsize, map_info,
879 * If we don't have as many as we want, and we haven't 1045 &curoff, &bp);
880 * run out of data blocks, get some more mappings. 1046 if (error || !map_info->map_valid)
881 */
882 if (1 + ra_want > map_blocks &&
883 map_off <
884 xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET)) {
885 /*
886 * Get more bmaps, fill in after the ones
887 * we already have in the table.
888 */
889 nmap = map_size - map_valid;
890 error = xfs_bmapi_read(dp, map_off,
891 xfs_dir2_byte_to_da(mp,
892 XFS_DIR2_LEAF_OFFSET) - map_off,
893 &map[map_valid], &nmap, 0);
894 /*
895 * Don't know if we should ignore this or
896 * try to return an error.
897 * The trouble with returning errors
898 * is that readdir will just stop without
899 * actually passing the error through.
900 */
901 if (error)
902 break; /* XXX */
903 /*
904 * If we got all the mappings we asked for,
905 * set the final map offset based on the
906 * last bmap value received.
907 * Otherwise, we've reached the end.
908 */
909 if (nmap == map_size - map_valid)
910 map_off =
911 map[map_valid + nmap - 1].br_startoff +
912 map[map_valid + nmap - 1].br_blockcount;
913 else
914 map_off =
915 xfs_dir2_byte_to_da(mp,
916 XFS_DIR2_LEAF_OFFSET);
917 /*
918 * Look for holes in the mapping, and
919 * eliminate them. Count up the valid blocks.
920 */
921 for (i = map_valid; i < map_valid + nmap; ) {
922 if (map[i].br_startblock ==
923 HOLESTARTBLOCK) {
924 nmap--;
925 length = map_valid + nmap - i;
926 if (length)
927 memmove(&map[i],
928 &map[i + 1],
929 sizeof(map[i]) *
930 length);
931 } else {
932 map_blocks +=
933 map[i].br_blockcount;
934 i++;
935 }
936 }
937 map_valid += nmap;
938 }
939 /*
940 * No valid mappings, so no more data blocks.
941 */
942 if (!map_valid) {
943 curoff = xfs_dir2_da_to_byte(mp, map_off);
944 break; 1047 break;
945 } 1048
946 /*
947 * Read the directory block starting at the first
948 * mapping.
949 */
950 curdb = xfs_dir2_da_to_db(mp, map->br_startoff);
951 error = xfs_da_read_buf(NULL, dp, map->br_startoff,
952 map->br_blockcount >= mp->m_dirblkfsbs ?
953 XFS_FSB_TO_DADDR(mp, map->br_startblock) :
954 -1,
955 &bp, XFS_DATA_FORK);
956 /*
957 * Should just skip over the data block instead
958 * of giving up.
959 */
960 if (error)
961 break; /* XXX */
962 /*
963 * Adjust the current amount of read-ahead: we just
964 * read a block that was previously ra.
965 */
966 if (ra_current)
967 ra_current -= mp->m_dirblkfsbs;
968 /*
969 * Do we need more readahead?
970 */
971 for (ra_index = ra_offset = i = 0;
972 ra_want > ra_current && i < map_blocks;
973 i += mp->m_dirblkfsbs) {
974 ASSERT(ra_index < map_valid);
975 /*
976 * Read-ahead a contiguous directory block.
977 */
978 if (i > ra_current &&
979 map[ra_index].br_blockcount >=
980 mp->m_dirblkfsbs) {
981 xfs_buf_readahead(mp->m_ddev_targp,
982 XFS_FSB_TO_DADDR(mp,
983 map[ra_index].br_startblock +
984 ra_offset),
985 (int)BTOBB(mp->m_dirblksize));
986 ra_current = i;
987 }
988 /*
989 * Read-ahead a non-contiguous directory block.
990 * This doesn't use our mapping, but this
991 * is a very rare case.
992 */
993 else if (i > ra_current) {
994 (void)xfs_da_reada_buf(NULL, dp,
995 map[ra_index].br_startoff +
996 ra_offset, XFS_DATA_FORK);
997 ra_current = i;
998 }
999 /*
1000 * Advance offset through the mapping table.
1001 */
1002 for (j = 0; j < mp->m_dirblkfsbs; j++) {
1003 /*
1004 * The rest of this extent but not
1005 * more than a dir block.
1006 */
1007 length = MIN(mp->m_dirblkfsbs,
1008 (int)(map[ra_index].br_blockcount -
1009 ra_offset));
1010 j += length;
1011 ra_offset += length;
1012 /*
1013 * Advance to the next mapping if
1014 * this one is used up.
1015 */
1016 if (ra_offset ==
1017 map[ra_index].br_blockcount) {
1018 ra_offset = 0;
1019 ra_index++;
1020 }
1021 }
1022 }
1023 /* 1049 /*
1024 * Having done a read, we need to set a new offset. 1050 * Having done a read, we need to set a new offset.
1025 */ 1051 */
1026 newoff = xfs_dir2_db_off_to_byte(mp, curdb, 0); 1052 newoff = xfs_dir2_db_off_to_byte(mp, map_info->curdb, 0);
1027 /* 1053 /*
1028 * Start of the current block. 1054 * Start of the current block.
1029 */ 1055 */
@@ -1034,8 +1060,8 @@ xfs_dir2_leaf_getdents(
1034 */ 1060 */
1035 else if (curoff > newoff) 1061 else if (curoff > newoff)
1036 ASSERT(xfs_dir2_byte_to_db(mp, curoff) == 1062 ASSERT(xfs_dir2_byte_to_db(mp, curoff) ==
1037 curdb); 1063 map_info->curdb);
1038 hdr = bp->data; 1064 hdr = bp->b_addr;
1039 xfs_dir2_data_check(dp, bp); 1065 xfs_dir2_data_check(dp, bp);
1040 /* 1066 /*
1041 * Find our position in the block. 1067 * Find our position in the block.
@@ -1117,9 +1143,9 @@ xfs_dir2_leaf_getdents(
1117 *offset = XFS_DIR2_MAX_DATAPTR & 0x7fffffff; 1143 *offset = XFS_DIR2_MAX_DATAPTR & 0x7fffffff;
1118 else 1144 else
1119 *offset = xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff; 1145 *offset = xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff;
1120 kmem_free(map); 1146 kmem_free(map_info);
1121 if (bp) 1147 if (bp)
1122 xfs_da_brelse(NULL, bp); 1148 xfs_trans_brelse(NULL, bp);
1123 return error; 1149 return error;
1124} 1150}
1125 1151
@@ -1130,10 +1156,10 @@ int
1130xfs_dir2_leaf_init( 1156xfs_dir2_leaf_init(
1131 xfs_da_args_t *args, /* operation arguments */ 1157 xfs_da_args_t *args, /* operation arguments */
1132 xfs_dir2_db_t bno, /* directory block number */ 1158 xfs_dir2_db_t bno, /* directory block number */
1133 xfs_dabuf_t **bpp, /* out: leaf buffer */ 1159 struct xfs_buf **bpp, /* out: leaf buffer */
1134 int magic) /* magic number for block */ 1160 int magic) /* magic number for block */
1135{ 1161{
1136 xfs_dabuf_t *bp; /* leaf buffer */ 1162 struct xfs_buf *bp; /* leaf buffer */
1137 xfs_inode_t *dp; /* incore directory inode */ 1163 xfs_inode_t *dp; /* incore directory inode */
1138 int error; /* error return code */ 1164 int error; /* error return code */
1139 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1165 xfs_dir2_leaf_t *leaf; /* leaf structure */
@@ -1156,7 +1182,7 @@ xfs_dir2_leaf_init(
1156 return error; 1182 return error;
1157 } 1183 }
1158 ASSERT(bp != NULL); 1184 ASSERT(bp != NULL);
1159 leaf = bp->data; 1185 leaf = bp->b_addr;
1160 /* 1186 /*
1161 * Initialize the header. 1187 * Initialize the header.
1162 */ 1188 */
@@ -1186,7 +1212,7 @@ xfs_dir2_leaf_init(
1186static void 1212static void
1187xfs_dir2_leaf_log_bests( 1213xfs_dir2_leaf_log_bests(
1188 xfs_trans_t *tp, /* transaction pointer */ 1214 xfs_trans_t *tp, /* transaction pointer */
1189 xfs_dabuf_t *bp, /* leaf buffer */ 1215 struct xfs_buf *bp, /* leaf buffer */
1190 int first, /* first entry to log */ 1216 int first, /* first entry to log */
1191 int last) /* last entry to log */ 1217 int last) /* last entry to log */
1192{ 1218{
@@ -1195,12 +1221,12 @@ xfs_dir2_leaf_log_bests(
1195 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1221 xfs_dir2_leaf_t *leaf; /* leaf structure */
1196 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ 1222 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
1197 1223
1198 leaf = bp->data; 1224 leaf = bp->b_addr;
1199 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC)); 1225 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
1200 ltp = xfs_dir2_leaf_tail_p(tp->t_mountp, leaf); 1226 ltp = xfs_dir2_leaf_tail_p(tp->t_mountp, leaf);
1201 firstb = xfs_dir2_leaf_bests_p(ltp) + first; 1227 firstb = xfs_dir2_leaf_bests_p(ltp) + first;
1202 lastb = xfs_dir2_leaf_bests_p(ltp) + last; 1228 lastb = xfs_dir2_leaf_bests_p(ltp) + last;
1203 xfs_da_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf), 1229 xfs_trans_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf),
1204 (uint)((char *)lastb - (char *)leaf + sizeof(*lastb) - 1)); 1230 (uint)((char *)lastb - (char *)leaf + sizeof(*lastb) - 1));
1205} 1231}
1206 1232
@@ -1210,7 +1236,7 @@ xfs_dir2_leaf_log_bests(
1210void 1236void
1211xfs_dir2_leaf_log_ents( 1237xfs_dir2_leaf_log_ents(
1212 xfs_trans_t *tp, /* transaction pointer */ 1238 xfs_trans_t *tp, /* transaction pointer */
1213 xfs_dabuf_t *bp, /* leaf buffer */ 1239 struct xfs_buf *bp, /* leaf buffer */
1214 int first, /* first entry to log */ 1240 int first, /* first entry to log */
1215 int last) /* last entry to log */ 1241 int last) /* last entry to log */
1216{ 1242{
@@ -1218,12 +1244,12 @@ xfs_dir2_leaf_log_ents(
1218 xfs_dir2_leaf_entry_t *lastlep; /* pointer to last entry */ 1244 xfs_dir2_leaf_entry_t *lastlep; /* pointer to last entry */
1219 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1245 xfs_dir2_leaf_t *leaf; /* leaf structure */
1220 1246
1221 leaf = bp->data; 1247 leaf = bp->b_addr;
1222 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) || 1248 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
1223 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1249 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1224 firstlep = &leaf->ents[first]; 1250 firstlep = &leaf->ents[first];
1225 lastlep = &leaf->ents[last]; 1251 lastlep = &leaf->ents[last];
1226 xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), 1252 xfs_trans_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf),
1227 (uint)((char *)lastlep - (char *)leaf + sizeof(*lastlep) - 1)); 1253 (uint)((char *)lastlep - (char *)leaf + sizeof(*lastlep) - 1));
1228} 1254}
1229 1255
@@ -1232,15 +1258,15 @@ xfs_dir2_leaf_log_ents(
1232 */ 1258 */
1233void 1259void
1234xfs_dir2_leaf_log_header( 1260xfs_dir2_leaf_log_header(
1235 xfs_trans_t *tp, /* transaction pointer */ 1261 struct xfs_trans *tp,
1236 xfs_dabuf_t *bp) /* leaf buffer */ 1262 struct xfs_buf *bp)
1237{ 1263{
1238 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1264 xfs_dir2_leaf_t *leaf; /* leaf structure */
1239 1265
1240 leaf = bp->data; 1266 leaf = bp->b_addr;
1241 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) || 1267 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
1242 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1268 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1243 xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf), 1269 xfs_trans_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf),
1244 (uint)(sizeof(leaf->hdr) - 1)); 1270 (uint)(sizeof(leaf->hdr) - 1));
1245} 1271}
1246 1272
@@ -1249,18 +1275,18 @@ xfs_dir2_leaf_log_header(
1249 */ 1275 */
1250STATIC void 1276STATIC void
1251xfs_dir2_leaf_log_tail( 1277xfs_dir2_leaf_log_tail(
1252 xfs_trans_t *tp, /* transaction pointer */ 1278 struct xfs_trans *tp,
1253 xfs_dabuf_t *bp) /* leaf buffer */ 1279 struct xfs_buf *bp)
1254{ 1280{
1255 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1281 xfs_dir2_leaf_t *leaf; /* leaf structure */
1256 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ 1282 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
1257 xfs_mount_t *mp; /* filesystem mount point */ 1283 xfs_mount_t *mp; /* filesystem mount point */
1258 1284
1259 mp = tp->t_mountp; 1285 mp = tp->t_mountp;
1260 leaf = bp->data; 1286 leaf = bp->b_addr;
1261 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC)); 1287 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
1262 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1288 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
1263 xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), 1289 xfs_trans_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf),
1264 (uint)(mp->m_dirblksize - 1)); 1290 (uint)(mp->m_dirblksize - 1));
1265} 1291}
1266 1292
@@ -1273,12 +1299,12 @@ int
1273xfs_dir2_leaf_lookup( 1299xfs_dir2_leaf_lookup(
1274 xfs_da_args_t *args) /* operation arguments */ 1300 xfs_da_args_t *args) /* operation arguments */
1275{ 1301{
1276 xfs_dabuf_t *dbp; /* data block buffer */ 1302 struct xfs_buf *dbp; /* data block buffer */
1277 xfs_dir2_data_entry_t *dep; /* data block entry */ 1303 xfs_dir2_data_entry_t *dep; /* data block entry */
1278 xfs_inode_t *dp; /* incore directory inode */ 1304 xfs_inode_t *dp; /* incore directory inode */
1279 int error; /* error return code */ 1305 int error; /* error return code */
1280 int index; /* found entry index */ 1306 int index; /* found entry index */
1281 xfs_dabuf_t *lbp; /* leaf buffer */ 1307 struct xfs_buf *lbp; /* leaf buffer */
1282 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1308 xfs_dir2_leaf_t *leaf; /* leaf structure */
1283 xfs_dir2_leaf_entry_t *lep; /* leaf entry */ 1309 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1284 xfs_trans_t *tp; /* transaction pointer */ 1310 xfs_trans_t *tp; /* transaction pointer */
@@ -1294,7 +1320,7 @@ xfs_dir2_leaf_lookup(
1294 tp = args->trans; 1320 tp = args->trans;
1295 dp = args->dp; 1321 dp = args->dp;
1296 xfs_dir2_leaf_check(dp, lbp); 1322 xfs_dir2_leaf_check(dp, lbp);
1297 leaf = lbp->data; 1323 leaf = lbp->b_addr;
1298 /* 1324 /*
1299 * Get to the leaf entry and contained data entry address. 1325 * Get to the leaf entry and contained data entry address.
1300 */ 1326 */
@@ -1303,15 +1329,15 @@ xfs_dir2_leaf_lookup(
1303 * Point to the data entry. 1329 * Point to the data entry.
1304 */ 1330 */
1305 dep = (xfs_dir2_data_entry_t *) 1331 dep = (xfs_dir2_data_entry_t *)
1306 ((char *)dbp->data + 1332 ((char *)dbp->b_addr +
1307 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address))); 1333 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address)));
1308 /* 1334 /*
1309 * Return the found inode number & CI name if appropriate 1335 * Return the found inode number & CI name if appropriate
1310 */ 1336 */
1311 args->inumber = be64_to_cpu(dep->inumber); 1337 args->inumber = be64_to_cpu(dep->inumber);
1312 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen); 1338 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen);
1313 xfs_da_brelse(tp, dbp); 1339 xfs_trans_brelse(tp, dbp);
1314 xfs_da_brelse(tp, lbp); 1340 xfs_trans_brelse(tp, lbp);
1315 return XFS_ERROR(error); 1341 return XFS_ERROR(error);
1316} 1342}
1317 1343
@@ -1324,17 +1350,17 @@ xfs_dir2_leaf_lookup(
1324static int /* error */ 1350static int /* error */
1325xfs_dir2_leaf_lookup_int( 1351xfs_dir2_leaf_lookup_int(
1326 xfs_da_args_t *args, /* operation arguments */ 1352 xfs_da_args_t *args, /* operation arguments */
1327 xfs_dabuf_t **lbpp, /* out: leaf buffer */ 1353 struct xfs_buf **lbpp, /* out: leaf buffer */
1328 int *indexp, /* out: index in leaf block */ 1354 int *indexp, /* out: index in leaf block */
1329 xfs_dabuf_t **dbpp) /* out: data buffer */ 1355 struct xfs_buf **dbpp) /* out: data buffer */
1330{ 1356{
1331 xfs_dir2_db_t curdb = -1; /* current data block number */ 1357 xfs_dir2_db_t curdb = -1; /* current data block number */
1332 xfs_dabuf_t *dbp = NULL; /* data buffer */ 1358 struct xfs_buf *dbp = NULL; /* data buffer */
1333 xfs_dir2_data_entry_t *dep; /* data entry */ 1359 xfs_dir2_data_entry_t *dep; /* data entry */
1334 xfs_inode_t *dp; /* incore directory inode */ 1360 xfs_inode_t *dp; /* incore directory inode */
1335 int error; /* error return code */ 1361 int error; /* error return code */
1336 int index; /* index in leaf block */ 1362 int index; /* index in leaf block */
1337 xfs_dabuf_t *lbp; /* leaf buffer */ 1363 struct xfs_buf *lbp; /* leaf buffer */
1338 xfs_dir2_leaf_entry_t *lep; /* leaf entry */ 1364 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1339 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1365 xfs_dir2_leaf_t *leaf; /* leaf structure */
1340 xfs_mount_t *mp; /* filesystem mount point */ 1366 xfs_mount_t *mp; /* filesystem mount point */
@@ -1354,7 +1380,7 @@ xfs_dir2_leaf_lookup_int(
1354 if (error) 1380 if (error)
1355 return error; 1381 return error;
1356 *lbpp = lbp; 1382 *lbpp = lbp;
1357 leaf = lbp->data; 1383 leaf = lbp->b_addr;
1358 xfs_dir2_leaf_check(dp, lbp); 1384 xfs_dir2_leaf_check(dp, lbp);
1359 /* 1385 /*
1360 * Look for the first leaf entry with our hash value. 1386 * Look for the first leaf entry with our hash value.
@@ -1382,12 +1408,12 @@ xfs_dir2_leaf_lookup_int(
1382 */ 1408 */
1383 if (newdb != curdb) { 1409 if (newdb != curdb) {
1384 if (dbp) 1410 if (dbp)
1385 xfs_da_brelse(tp, dbp); 1411 xfs_trans_brelse(tp, dbp);
1386 error = xfs_da_read_buf(tp, dp, 1412 error = xfs_da_read_buf(tp, dp,
1387 xfs_dir2_db_to_da(mp, newdb), 1413 xfs_dir2_db_to_da(mp, newdb),
1388 -1, &dbp, XFS_DATA_FORK); 1414 -1, &dbp, XFS_DATA_FORK);
1389 if (error) { 1415 if (error) {
1390 xfs_da_brelse(tp, lbp); 1416 xfs_trans_brelse(tp, lbp);
1391 return error; 1417 return error;
1392 } 1418 }
1393 xfs_dir2_data_check(dp, dbp); 1419 xfs_dir2_data_check(dp, dbp);
@@ -1396,7 +1422,7 @@ xfs_dir2_leaf_lookup_int(
1396 /* 1422 /*
1397 * Point to the data entry. 1423 * Point to the data entry.
1398 */ 1424 */
1399 dep = (xfs_dir2_data_entry_t *)((char *)dbp->data + 1425 dep = (xfs_dir2_data_entry_t *)((char *)dbp->b_addr +
1400 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); 1426 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
1401 /* 1427 /*
1402 * Compare name and if it's an exact match, return the index 1428 * Compare name and if it's an exact match, return the index
@@ -1424,12 +1450,12 @@ xfs_dir2_leaf_lookup_int(
1424 if (args->cmpresult == XFS_CMP_CASE) { 1450 if (args->cmpresult == XFS_CMP_CASE) {
1425 ASSERT(cidb != -1); 1451 ASSERT(cidb != -1);
1426 if (cidb != curdb) { 1452 if (cidb != curdb) {
1427 xfs_da_brelse(tp, dbp); 1453 xfs_trans_brelse(tp, dbp);
1428 error = xfs_da_read_buf(tp, dp, 1454 error = xfs_da_read_buf(tp, dp,
1429 xfs_dir2_db_to_da(mp, cidb), 1455 xfs_dir2_db_to_da(mp, cidb),
1430 -1, &dbp, XFS_DATA_FORK); 1456 -1, &dbp, XFS_DATA_FORK);
1431 if (error) { 1457 if (error) {
1432 xfs_da_brelse(tp, lbp); 1458 xfs_trans_brelse(tp, lbp);
1433 return error; 1459 return error;
1434 } 1460 }
1435 } 1461 }
@@ -1441,8 +1467,8 @@ xfs_dir2_leaf_lookup_int(
1441 */ 1467 */
1442 ASSERT(cidb == -1); 1468 ASSERT(cidb == -1);
1443 if (dbp) 1469 if (dbp)
1444 xfs_da_brelse(tp, dbp); 1470 xfs_trans_brelse(tp, dbp);
1445 xfs_da_brelse(tp, lbp); 1471 xfs_trans_brelse(tp, lbp);
1446 return XFS_ERROR(ENOENT); 1472 return XFS_ERROR(ENOENT);
1447} 1473}
1448 1474
@@ -1456,13 +1482,13 @@ xfs_dir2_leaf_removename(
1456 __be16 *bestsp; /* leaf block best freespace */ 1482 __be16 *bestsp; /* leaf block best freespace */
1457 xfs_dir2_data_hdr_t *hdr; /* data block header */ 1483 xfs_dir2_data_hdr_t *hdr; /* data block header */
1458 xfs_dir2_db_t db; /* data block number */ 1484 xfs_dir2_db_t db; /* data block number */
1459 xfs_dabuf_t *dbp; /* data block buffer */ 1485 struct xfs_buf *dbp; /* data block buffer */
1460 xfs_dir2_data_entry_t *dep; /* data entry structure */ 1486 xfs_dir2_data_entry_t *dep; /* data entry structure */
1461 xfs_inode_t *dp; /* incore directory inode */ 1487 xfs_inode_t *dp; /* incore directory inode */
1462 int error; /* error return code */ 1488 int error; /* error return code */
1463 xfs_dir2_db_t i; /* temporary data block # */ 1489 xfs_dir2_db_t i; /* temporary data block # */
1464 int index; /* index into leaf entries */ 1490 int index; /* index into leaf entries */
1465 xfs_dabuf_t *lbp; /* leaf buffer */ 1491 struct xfs_buf *lbp; /* leaf buffer */
1466 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1492 xfs_dir2_leaf_t *leaf; /* leaf structure */
1467 xfs_dir2_leaf_entry_t *lep; /* leaf entry */ 1493 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1468 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ 1494 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
@@ -1483,8 +1509,8 @@ xfs_dir2_leaf_removename(
1483 dp = args->dp; 1509 dp = args->dp;
1484 tp = args->trans; 1510 tp = args->trans;
1485 mp = dp->i_mount; 1511 mp = dp->i_mount;
1486 leaf = lbp->data; 1512 leaf = lbp->b_addr;
1487 hdr = dbp->data; 1513 hdr = dbp->b_addr;
1488 xfs_dir2_data_check(dp, dbp); 1514 xfs_dir2_data_check(dp, dbp);
1489 /* 1515 /*
1490 * Point to the leaf entry, use that to point to the data entry. 1516 * Point to the leaf entry, use that to point to the data entry.
@@ -1541,12 +1567,9 @@ xfs_dir2_leaf_removename(
1541 * Just go on, returning success, leaving the 1567 * Just go on, returning success, leaving the
1542 * empty block in place. 1568 * empty block in place.
1543 */ 1569 */
1544 if (error == ENOSPC && args->total == 0) { 1570 if (error == ENOSPC && args->total == 0)
1545 xfs_da_buf_done(dbp);
1546 error = 0; 1571 error = 0;
1547 }
1548 xfs_dir2_leaf_check(dp, lbp); 1572 xfs_dir2_leaf_check(dp, lbp);
1549 xfs_da_buf_done(lbp);
1550 return error; 1573 return error;
1551 } 1574 }
1552 dbp = NULL; 1575 dbp = NULL;
@@ -1577,10 +1600,9 @@ xfs_dir2_leaf_removename(
1577 /* 1600 /*
1578 * If the data block was not the first one, drop it. 1601 * If the data block was not the first one, drop it.
1579 */ 1602 */
1580 else if (db != mp->m_dirdatablk && dbp != NULL) { 1603 else if (db != mp->m_dirdatablk)
1581 xfs_da_buf_done(dbp);
1582 dbp = NULL; 1604 dbp = NULL;
1583 } 1605
1584 xfs_dir2_leaf_check(dp, lbp); 1606 xfs_dir2_leaf_check(dp, lbp);
1585 /* 1607 /*
1586 * See if we can convert to block form. 1608 * See if we can convert to block form.
@@ -1595,12 +1617,12 @@ int /* error */
1595xfs_dir2_leaf_replace( 1617xfs_dir2_leaf_replace(
1596 xfs_da_args_t *args) /* operation arguments */ 1618 xfs_da_args_t *args) /* operation arguments */
1597{ 1619{
1598 xfs_dabuf_t *dbp; /* data block buffer */ 1620 struct xfs_buf *dbp; /* data block buffer */
1599 xfs_dir2_data_entry_t *dep; /* data block entry */ 1621 xfs_dir2_data_entry_t *dep; /* data block entry */
1600 xfs_inode_t *dp; /* incore directory inode */ 1622 xfs_inode_t *dp; /* incore directory inode */
1601 int error; /* error return code */ 1623 int error; /* error return code */
1602 int index; /* index of leaf entry */ 1624 int index; /* index of leaf entry */
1603 xfs_dabuf_t *lbp; /* leaf buffer */ 1625 struct xfs_buf *lbp; /* leaf buffer */
1604 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1626 xfs_dir2_leaf_t *leaf; /* leaf structure */
1605 xfs_dir2_leaf_entry_t *lep; /* leaf entry */ 1627 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1606 xfs_trans_t *tp; /* transaction pointer */ 1628 xfs_trans_t *tp; /* transaction pointer */
@@ -1614,7 +1636,7 @@ xfs_dir2_leaf_replace(
1614 return error; 1636 return error;
1615 } 1637 }
1616 dp = args->dp; 1638 dp = args->dp;
1617 leaf = lbp->data; 1639 leaf = lbp->b_addr;
1618 /* 1640 /*
1619 * Point to the leaf entry, get data address from it. 1641 * Point to the leaf entry, get data address from it.
1620 */ 1642 */
@@ -1623,7 +1645,7 @@ xfs_dir2_leaf_replace(
1623 * Point to the data entry. 1645 * Point to the data entry.
1624 */ 1646 */
1625 dep = (xfs_dir2_data_entry_t *) 1647 dep = (xfs_dir2_data_entry_t *)
1626 ((char *)dbp->data + 1648 ((char *)dbp->b_addr +
1627 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address))); 1649 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address)));
1628 ASSERT(args->inumber != be64_to_cpu(dep->inumber)); 1650 ASSERT(args->inumber != be64_to_cpu(dep->inumber));
1629 /* 1651 /*
@@ -1632,9 +1654,8 @@ xfs_dir2_leaf_replace(
1632 dep->inumber = cpu_to_be64(args->inumber); 1654 dep->inumber = cpu_to_be64(args->inumber);
1633 tp = args->trans; 1655 tp = args->trans;
1634 xfs_dir2_data_log_entry(tp, dbp, dep); 1656 xfs_dir2_data_log_entry(tp, dbp, dep);
1635 xfs_da_buf_done(dbp);
1636 xfs_dir2_leaf_check(dp, lbp); 1657 xfs_dir2_leaf_check(dp, lbp);
1637 xfs_da_brelse(tp, lbp); 1658 xfs_trans_brelse(tp, lbp);
1638 return 0; 1659 return 0;
1639} 1660}
1640 1661
@@ -1646,7 +1667,7 @@ xfs_dir2_leaf_replace(
1646int /* index value */ 1667int /* index value */
1647xfs_dir2_leaf_search_hash( 1668xfs_dir2_leaf_search_hash(
1648 xfs_da_args_t *args, /* operation arguments */ 1669 xfs_da_args_t *args, /* operation arguments */
1649 xfs_dabuf_t *lbp) /* leaf buffer */ 1670 struct xfs_buf *lbp) /* leaf buffer */
1650{ 1671{
1651 xfs_dahash_t hash=0; /* hash from this entry */ 1672 xfs_dahash_t hash=0; /* hash from this entry */
1652 xfs_dahash_t hashwant; /* hash value looking for */ 1673 xfs_dahash_t hashwant; /* hash value looking for */
@@ -1656,7 +1677,7 @@ xfs_dir2_leaf_search_hash(
1656 xfs_dir2_leaf_entry_t *lep; /* leaf entry */ 1677 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1657 int mid=0; /* current leaf index */ 1678 int mid=0; /* current leaf index */
1658 1679
1659 leaf = lbp->data; 1680 leaf = lbp->b_addr;
1660#ifndef __KERNEL__ 1681#ifndef __KERNEL__
1661 if (!leaf->hdr.count) 1682 if (!leaf->hdr.count)
1662 return 0; 1683 return 0;
@@ -1699,11 +1720,11 @@ xfs_dir2_leaf_search_hash(
1699int /* error */ 1720int /* error */
1700xfs_dir2_leaf_trim_data( 1721xfs_dir2_leaf_trim_data(
1701 xfs_da_args_t *args, /* operation arguments */ 1722 xfs_da_args_t *args, /* operation arguments */
1702 xfs_dabuf_t *lbp, /* leaf buffer */ 1723 struct xfs_buf *lbp, /* leaf buffer */
1703 xfs_dir2_db_t db) /* data block number */ 1724 xfs_dir2_db_t db) /* data block number */
1704{ 1725{
1705 __be16 *bestsp; /* leaf bests table */ 1726 __be16 *bestsp; /* leaf bests table */
1706 xfs_dabuf_t *dbp; /* data block buffer */ 1727 struct xfs_buf *dbp; /* data block buffer */
1707 xfs_inode_t *dp; /* incore directory inode */ 1728 xfs_inode_t *dp; /* incore directory inode */
1708 int error; /* error return value */ 1729 int error; /* error return value */
1709 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1730 xfs_dir2_leaf_t *leaf; /* leaf structure */
@@ -1722,12 +1743,12 @@ xfs_dir2_leaf_trim_data(
1722 return error; 1743 return error;
1723 } 1744 }
1724 1745
1725 leaf = lbp->data; 1746 leaf = lbp->b_addr;
1726 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1747 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
1727 1748
1728#ifdef DEBUG 1749#ifdef DEBUG
1729{ 1750{
1730 struct xfs_dir2_data_hdr *hdr = dbp->data; 1751 struct xfs_dir2_data_hdr *hdr = dbp->b_addr;
1731 1752
1732 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC)); 1753 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC));
1733 ASSERT(be16_to_cpu(hdr->bestfree[0].length) == 1754 ASSERT(be16_to_cpu(hdr->bestfree[0].length) ==
@@ -1741,7 +1762,7 @@ xfs_dir2_leaf_trim_data(
1741 */ 1762 */
1742 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { 1763 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
1743 ASSERT(error != ENOSPC); 1764 ASSERT(error != ENOSPC);
1744 xfs_da_brelse(tp, dbp); 1765 xfs_trans_brelse(tp, dbp);
1745 return error; 1766 return error;
1746 } 1767 }
1747 /* 1768 /*
@@ -1781,10 +1802,10 @@ xfs_dir2_node_to_leaf(
1781 xfs_da_args_t *args; /* operation arguments */ 1802 xfs_da_args_t *args; /* operation arguments */
1782 xfs_inode_t *dp; /* incore directory inode */ 1803 xfs_inode_t *dp; /* incore directory inode */
1783 int error; /* error return code */ 1804 int error; /* error return code */
1784 xfs_dabuf_t *fbp; /* buffer for freespace block */ 1805 struct xfs_buf *fbp; /* buffer for freespace block */
1785 xfs_fileoff_t fo; /* freespace file offset */ 1806 xfs_fileoff_t fo; /* freespace file offset */
1786 xfs_dir2_free_t *free; /* freespace structure */ 1807 xfs_dir2_free_t *free; /* freespace structure */
1787 xfs_dabuf_t *lbp; /* buffer for leaf block */ 1808 struct xfs_buf *lbp; /* buffer for leaf block */
1788 xfs_dir2_leaf_tail_t *ltp; /* tail of leaf structure */ 1809 xfs_dir2_leaf_tail_t *ltp; /* tail of leaf structure */
1789 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1810 xfs_dir2_leaf_t *leaf; /* leaf structure */
1790 xfs_mount_t *mp; /* filesystem mount point */ 1811 xfs_mount_t *mp; /* filesystem mount point */
@@ -1838,7 +1859,7 @@ xfs_dir2_node_to_leaf(
1838 if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + mp->m_dirblksize) 1859 if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + mp->m_dirblksize)
1839 return 0; 1860 return 0;
1840 lbp = state->path.blk[0].bp; 1861 lbp = state->path.blk[0].bp;
1841 leaf = lbp->data; 1862 leaf = lbp->b_addr;
1842 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1863 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1843 /* 1864 /*
1844 * Read the freespace block. 1865 * Read the freespace block.
@@ -1847,7 +1868,7 @@ xfs_dir2_node_to_leaf(
1847 XFS_DATA_FORK))) { 1868 XFS_DATA_FORK))) {
1848 return error; 1869 return error;
1849 } 1870 }
1850 free = fbp->data; 1871 free = fbp->b_addr;
1851 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1872 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1852 ASSERT(!free->hdr.firstdb); 1873 ASSERT(!free->hdr.firstdb);
1853 1874
@@ -1857,7 +1878,7 @@ xfs_dir2_node_to_leaf(
1857 */ 1878 */
1858 if (xfs_dir2_leaf_size(&leaf->hdr, be32_to_cpu(free->hdr.nvalid)) > 1879 if (xfs_dir2_leaf_size(&leaf->hdr, be32_to_cpu(free->hdr.nvalid)) >
1859 mp->m_dirblksize) { 1880 mp->m_dirblksize) {
1860 xfs_da_brelse(tp, fbp); 1881 xfs_trans_brelse(tp, fbp);
1861 return 0; 1882 return 0;
1862 } 1883 }
1863 1884
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index b0f26780449d..6c7052406605 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -36,20 +36,20 @@
36/* 36/*
37 * Function declarations. 37 * Function declarations.
38 */ 38 */
39static void xfs_dir2_free_log_header(xfs_trans_t *tp, xfs_dabuf_t *bp); 39static int xfs_dir2_leafn_add(struct xfs_buf *bp, xfs_da_args_t *args,
40static int xfs_dir2_leafn_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index); 40 int index);
41#ifdef DEBUG 41#ifdef DEBUG
42static void xfs_dir2_leafn_check(xfs_inode_t *dp, xfs_dabuf_t *bp); 42static void xfs_dir2_leafn_check(struct xfs_inode *dp, struct xfs_buf *bp);
43#else 43#else
44#define xfs_dir2_leafn_check(dp, bp) 44#define xfs_dir2_leafn_check(dp, bp)
45#endif 45#endif
46static void xfs_dir2_leafn_moveents(xfs_da_args_t *args, xfs_dabuf_t *bp_s, 46static void xfs_dir2_leafn_moveents(xfs_da_args_t *args, struct xfs_buf *bp_s,
47 int start_s, xfs_dabuf_t *bp_d, int start_d, 47 int start_s, struct xfs_buf *bp_d,
48 int count); 48 int start_d, int count);
49static void xfs_dir2_leafn_rebalance(xfs_da_state_t *state, 49static void xfs_dir2_leafn_rebalance(xfs_da_state_t *state,
50 xfs_da_state_blk_t *blk1, 50 xfs_da_state_blk_t *blk1,
51 xfs_da_state_blk_t *blk2); 51 xfs_da_state_blk_t *blk2);
52static int xfs_dir2_leafn_remove(xfs_da_args_t *args, xfs_dabuf_t *bp, 52static int xfs_dir2_leafn_remove(xfs_da_args_t *args, struct xfs_buf *bp,
53 int index, xfs_da_state_blk_t *dblk, 53 int index, xfs_da_state_blk_t *dblk,
54 int *rval); 54 int *rval);
55static int xfs_dir2_node_addname_int(xfs_da_args_t *args, 55static int xfs_dir2_node_addname_int(xfs_da_args_t *args,
@@ -60,16 +60,16 @@ static int xfs_dir2_node_addname_int(xfs_da_args_t *args,
60 */ 60 */
61STATIC void 61STATIC void
62xfs_dir2_free_log_bests( 62xfs_dir2_free_log_bests(
63 xfs_trans_t *tp, /* transaction pointer */ 63 struct xfs_trans *tp,
64 xfs_dabuf_t *bp, /* freespace buffer */ 64 struct xfs_buf *bp,
65 int first, /* first entry to log */ 65 int first, /* first entry to log */
66 int last) /* last entry to log */ 66 int last) /* last entry to log */
67{ 67{
68 xfs_dir2_free_t *free; /* freespace structure */ 68 xfs_dir2_free_t *free; /* freespace structure */
69 69
70 free = bp->data; 70 free = bp->b_addr;
71 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 71 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
72 xfs_da_log_buf(tp, bp, 72 xfs_trans_log_buf(tp, bp,
73 (uint)((char *)&free->bests[first] - (char *)free), 73 (uint)((char *)&free->bests[first] - (char *)free),
74 (uint)((char *)&free->bests[last] - (char *)free + 74 (uint)((char *)&free->bests[last] - (char *)free +
75 sizeof(free->bests[0]) - 1)); 75 sizeof(free->bests[0]) - 1));
@@ -80,14 +80,14 @@ xfs_dir2_free_log_bests(
80 */ 80 */
81static void 81static void
82xfs_dir2_free_log_header( 82xfs_dir2_free_log_header(
83 xfs_trans_t *tp, /* transaction pointer */ 83 struct xfs_trans *tp,
84 xfs_dabuf_t *bp) /* freespace buffer */ 84 struct xfs_buf *bp)
85{ 85{
86 xfs_dir2_free_t *free; /* freespace structure */ 86 xfs_dir2_free_t *free; /* freespace structure */
87 87
88 free = bp->data; 88 free = bp->b_addr;
89 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 89 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
90 xfs_da_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free), 90 xfs_trans_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free),
91 (uint)(sizeof(xfs_dir2_free_hdr_t) - 1)); 91 (uint)(sizeof(xfs_dir2_free_hdr_t) - 1));
92} 92}
93 93
@@ -99,11 +99,11 @@ xfs_dir2_free_log_header(
99int /* error */ 99int /* error */
100xfs_dir2_leaf_to_node( 100xfs_dir2_leaf_to_node(
101 xfs_da_args_t *args, /* operation arguments */ 101 xfs_da_args_t *args, /* operation arguments */
102 xfs_dabuf_t *lbp) /* leaf buffer */ 102 struct xfs_buf *lbp) /* leaf buffer */
103{ 103{
104 xfs_inode_t *dp; /* incore directory inode */ 104 xfs_inode_t *dp; /* incore directory inode */
105 int error; /* error return value */ 105 int error; /* error return value */
106 xfs_dabuf_t *fbp; /* freespace buffer */ 106 struct xfs_buf *fbp; /* freespace buffer */
107 xfs_dir2_db_t fdb; /* freespace block number */ 107 xfs_dir2_db_t fdb; /* freespace block number */
108 xfs_dir2_free_t *free; /* freespace structure */ 108 xfs_dir2_free_t *free; /* freespace structure */
109 __be16 *from; /* pointer to freespace entry */ 109 __be16 *from; /* pointer to freespace entry */
@@ -136,8 +136,8 @@ xfs_dir2_leaf_to_node(
136 return error; 136 return error;
137 } 137 }
138 ASSERT(fbp != NULL); 138 ASSERT(fbp != NULL);
139 free = fbp->data; 139 free = fbp->b_addr;
140 leaf = lbp->data; 140 leaf = lbp->b_addr;
141 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 141 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
142 /* 142 /*
143 * Initialize the freespace block header. 143 * Initialize the freespace block header.
@@ -164,7 +164,6 @@ xfs_dir2_leaf_to_node(
164 xfs_dir2_leaf_log_header(tp, lbp); 164 xfs_dir2_leaf_log_header(tp, lbp);
165 xfs_dir2_free_log_header(tp, fbp); 165 xfs_dir2_free_log_header(tp, fbp);
166 xfs_dir2_free_log_bests(tp, fbp, 0, be32_to_cpu(free->hdr.nvalid) - 1); 166 xfs_dir2_free_log_bests(tp, fbp, 0, be32_to_cpu(free->hdr.nvalid) - 1);
167 xfs_da_buf_done(fbp);
168 xfs_dir2_leafn_check(dp, lbp); 167 xfs_dir2_leafn_check(dp, lbp);
169 return 0; 168 return 0;
170} 169}
@@ -175,7 +174,7 @@ xfs_dir2_leaf_to_node(
175 */ 174 */
176static int /* error */ 175static int /* error */
177xfs_dir2_leafn_add( 176xfs_dir2_leafn_add(
178 xfs_dabuf_t *bp, /* leaf buffer */ 177 struct xfs_buf *bp, /* leaf buffer */
179 xfs_da_args_t *args, /* operation arguments */ 178 xfs_da_args_t *args, /* operation arguments */
180 int index) /* insertion pt for new entry */ 179 int index) /* insertion pt for new entry */
181{ 180{
@@ -195,7 +194,7 @@ xfs_dir2_leafn_add(
195 dp = args->dp; 194 dp = args->dp;
196 mp = dp->i_mount; 195 mp = dp->i_mount;
197 tp = args->trans; 196 tp = args->trans;
198 leaf = bp->data; 197 leaf = bp->b_addr;
199 198
200 /* 199 /*
201 * Quick check just to make sure we are not going to index 200 * Quick check just to make sure we are not going to index
@@ -261,15 +260,15 @@ xfs_dir2_leafn_add(
261 */ 260 */
262void 261void
263xfs_dir2_leafn_check( 262xfs_dir2_leafn_check(
264 xfs_inode_t *dp, /* incore directory inode */ 263 struct xfs_inode *dp,
265 xfs_dabuf_t *bp) /* leaf buffer */ 264 struct xfs_buf *bp)
266{ 265{
267 int i; /* leaf index */ 266 int i; /* leaf index */
268 xfs_dir2_leaf_t *leaf; /* leaf structure */ 267 xfs_dir2_leaf_t *leaf; /* leaf structure */
269 xfs_mount_t *mp; /* filesystem mount point */ 268 xfs_mount_t *mp; /* filesystem mount point */
270 int stale; /* count of stale leaves */ 269 int stale; /* count of stale leaves */
271 270
272 leaf = bp->data; 271 leaf = bp->b_addr;
273 mp = dp->i_mount; 272 mp = dp->i_mount;
274 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 273 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
275 ASSERT(be16_to_cpu(leaf->hdr.count) <= xfs_dir2_max_leaf_ents(mp)); 274 ASSERT(be16_to_cpu(leaf->hdr.count) <= xfs_dir2_max_leaf_ents(mp));
@@ -291,12 +290,12 @@ xfs_dir2_leafn_check(
291 */ 290 */
292xfs_dahash_t /* hash value */ 291xfs_dahash_t /* hash value */
293xfs_dir2_leafn_lasthash( 292xfs_dir2_leafn_lasthash(
294 xfs_dabuf_t *bp, /* leaf buffer */ 293 struct xfs_buf *bp, /* leaf buffer */
295 int *count) /* count of entries in leaf */ 294 int *count) /* count of entries in leaf */
296{ 295{
297 xfs_dir2_leaf_t *leaf; /* leaf structure */ 296 xfs_dir2_leaf_t *leaf; /* leaf structure */
298 297
299 leaf = bp->data; 298 leaf = bp->b_addr;
300 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 299 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
301 if (count) 300 if (count)
302 *count = be16_to_cpu(leaf->hdr.count); 301 *count = be16_to_cpu(leaf->hdr.count);
@@ -311,12 +310,12 @@ xfs_dir2_leafn_lasthash(
311 */ 310 */
312STATIC int 311STATIC int
313xfs_dir2_leafn_lookup_for_addname( 312xfs_dir2_leafn_lookup_for_addname(
314 xfs_dabuf_t *bp, /* leaf buffer */ 313 struct xfs_buf *bp, /* leaf buffer */
315 xfs_da_args_t *args, /* operation arguments */ 314 xfs_da_args_t *args, /* operation arguments */
316 int *indexp, /* out: leaf entry index */ 315 int *indexp, /* out: leaf entry index */
317 xfs_da_state_t *state) /* state to fill in */ 316 xfs_da_state_t *state) /* state to fill in */
318{ 317{
319 xfs_dabuf_t *curbp = NULL; /* current data/free buffer */ 318 struct xfs_buf *curbp = NULL; /* current data/free buffer */
320 xfs_dir2_db_t curdb = -1; /* current data block number */ 319 xfs_dir2_db_t curdb = -1; /* current data block number */
321 xfs_dir2_db_t curfdb = -1; /* current free block number */ 320 xfs_dir2_db_t curfdb = -1; /* current free block number */
322 xfs_inode_t *dp; /* incore directory inode */ 321 xfs_inode_t *dp; /* incore directory inode */
@@ -335,7 +334,7 @@ xfs_dir2_leafn_lookup_for_addname(
335 dp = args->dp; 334 dp = args->dp;
336 tp = args->trans; 335 tp = args->trans;
337 mp = dp->i_mount; 336 mp = dp->i_mount;
338 leaf = bp->data; 337 leaf = bp->b_addr;
339 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 338 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
340#ifdef __KERNEL__ 339#ifdef __KERNEL__
341 ASSERT(be16_to_cpu(leaf->hdr.count) > 0); 340 ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
@@ -352,7 +351,7 @@ xfs_dir2_leafn_lookup_for_addname(
352 /* If so, it's a free block buffer, get the block number. */ 351 /* If so, it's a free block buffer, get the block number. */
353 curbp = state->extrablk.bp; 352 curbp = state->extrablk.bp;
354 curfdb = state->extrablk.blkno; 353 curfdb = state->extrablk.blkno;
355 free = curbp->data; 354 free = curbp->b_addr;
356 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 355 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
357 } 356 }
358 length = xfs_dir2_data_entsize(args->namelen); 357 length = xfs_dir2_data_entsize(args->namelen);
@@ -394,7 +393,7 @@ xfs_dir2_leafn_lookup_for_addname(
394 * If we had one before, drop it. 393 * If we had one before, drop it.
395 */ 394 */
396 if (curbp) 395 if (curbp)
397 xfs_da_brelse(tp, curbp); 396 xfs_trans_brelse(tp, curbp);
398 /* 397 /*
399 * Read the free block. 398 * Read the free block.
400 */ 399 */
@@ -403,7 +402,7 @@ xfs_dir2_leafn_lookup_for_addname(
403 -1, &curbp, XFS_DATA_FORK); 402 -1, &curbp, XFS_DATA_FORK);
404 if (error) 403 if (error)
405 return error; 404 return error;
406 free = curbp->data; 405 free = curbp->b_addr;
407 ASSERT(be32_to_cpu(free->hdr.magic) == 406 ASSERT(be32_to_cpu(free->hdr.magic) ==
408 XFS_DIR2_FREE_MAGIC); 407 XFS_DIR2_FREE_MAGIC);
409 ASSERT((be32_to_cpu(free->hdr.firstdb) % 408 ASSERT((be32_to_cpu(free->hdr.firstdb) %
@@ -424,7 +423,7 @@ xfs_dir2_leafn_lookup_for_addname(
424 XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int", 423 XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int",
425 XFS_ERRLEVEL_LOW, mp); 424 XFS_ERRLEVEL_LOW, mp);
426 if (curfdb != newfdb) 425 if (curfdb != newfdb)
427 xfs_da_brelse(tp, curbp); 426 xfs_trans_brelse(tp, curbp);
428 return XFS_ERROR(EFSCORRUPTED); 427 return XFS_ERROR(EFSCORRUPTED);
429 } 428 }
430 curfdb = newfdb; 429 curfdb = newfdb;
@@ -459,12 +458,12 @@ out:
459 */ 458 */
460STATIC int 459STATIC int
461xfs_dir2_leafn_lookup_for_entry( 460xfs_dir2_leafn_lookup_for_entry(
462 xfs_dabuf_t *bp, /* leaf buffer */ 461 struct xfs_buf *bp, /* leaf buffer */
463 xfs_da_args_t *args, /* operation arguments */ 462 xfs_da_args_t *args, /* operation arguments */
464 int *indexp, /* out: leaf entry index */ 463 int *indexp, /* out: leaf entry index */
465 xfs_da_state_t *state) /* state to fill in */ 464 xfs_da_state_t *state) /* state to fill in */
466{ 465{
467 xfs_dabuf_t *curbp = NULL; /* current data/free buffer */ 466 struct xfs_buf *curbp = NULL; /* current data/free buffer */
468 xfs_dir2_db_t curdb = -1; /* current data block number */ 467 xfs_dir2_db_t curdb = -1; /* current data block number */
469 xfs_dir2_data_entry_t *dep; /* data block entry */ 468 xfs_dir2_data_entry_t *dep; /* data block entry */
470 xfs_inode_t *dp; /* incore directory inode */ 469 xfs_inode_t *dp; /* incore directory inode */
@@ -480,7 +479,7 @@ xfs_dir2_leafn_lookup_for_entry(
480 dp = args->dp; 479 dp = args->dp;
481 tp = args->trans; 480 tp = args->trans;
482 mp = dp->i_mount; 481 mp = dp->i_mount;
483 leaf = bp->data; 482 leaf = bp->b_addr;
484 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 483 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
485#ifdef __KERNEL__ 484#ifdef __KERNEL__
486 ASSERT(be16_to_cpu(leaf->hdr.count) > 0); 485 ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
@@ -525,7 +524,7 @@ xfs_dir2_leafn_lookup_for_entry(
525 */ 524 */
526 if (curbp && (args->cmpresult == XFS_CMP_DIFFERENT || 525 if (curbp && (args->cmpresult == XFS_CMP_DIFFERENT ||
527 curdb != state->extrablk.blkno)) 526 curdb != state->extrablk.blkno))
528 xfs_da_brelse(tp, curbp); 527 xfs_trans_brelse(tp, curbp);
529 /* 528 /*
530 * If needing the block that is saved with a CI match, 529 * If needing the block that is saved with a CI match,
531 * use it otherwise read in the new data block. 530 * use it otherwise read in the new data block.
@@ -547,7 +546,7 @@ xfs_dir2_leafn_lookup_for_entry(
547 /* 546 /*
548 * Point to the data entry. 547 * Point to the data entry.
549 */ 548 */
550 dep = (xfs_dir2_data_entry_t *)((char *)curbp->data + 549 dep = (xfs_dir2_data_entry_t *)((char *)curbp->b_addr +
551 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); 550 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
552 /* 551 /*
553 * Compare the entry and if it's an exact match, return 552 * Compare the entry and if it's an exact match, return
@@ -559,7 +558,7 @@ xfs_dir2_leafn_lookup_for_entry(
559 /* If there is a CI match block, drop it */ 558 /* If there is a CI match block, drop it */
560 if (args->cmpresult != XFS_CMP_DIFFERENT && 559 if (args->cmpresult != XFS_CMP_DIFFERENT &&
561 curdb != state->extrablk.blkno) 560 curdb != state->extrablk.blkno)
562 xfs_da_brelse(tp, state->extrablk.bp); 561 xfs_trans_brelse(tp, state->extrablk.bp);
563 args->cmpresult = cmp; 562 args->cmpresult = cmp;
564 args->inumber = be64_to_cpu(dep->inumber); 563 args->inumber = be64_to_cpu(dep->inumber);
565 *indexp = index; 564 *indexp = index;
@@ -567,7 +566,7 @@ xfs_dir2_leafn_lookup_for_entry(
567 state->extrablk.bp = curbp; 566 state->extrablk.bp = curbp;
568 state->extrablk.blkno = curdb; 567 state->extrablk.blkno = curdb;
569 state->extrablk.index = (int)((char *)dep - 568 state->extrablk.index = (int)((char *)dep -
570 (char *)curbp->data); 569 (char *)curbp->b_addr);
571 state->extrablk.magic = XFS_DIR2_DATA_MAGIC; 570 state->extrablk.magic = XFS_DIR2_DATA_MAGIC;
572 if (cmp == XFS_CMP_EXACT) 571 if (cmp == XFS_CMP_EXACT)
573 return XFS_ERROR(EEXIST); 572 return XFS_ERROR(EEXIST);
@@ -586,7 +585,7 @@ xfs_dir2_leafn_lookup_for_entry(
586 } else { 585 } else {
587 /* If the curbp is not the CI match block, drop it */ 586 /* If the curbp is not the CI match block, drop it */
588 if (state->extrablk.bp != curbp) 587 if (state->extrablk.bp != curbp)
589 xfs_da_brelse(tp, curbp); 588 xfs_trans_brelse(tp, curbp);
590 } 589 }
591 } else { 590 } else {
592 state->extravalid = 0; 591 state->extravalid = 0;
@@ -602,7 +601,7 @@ xfs_dir2_leafn_lookup_for_entry(
602 */ 601 */
603int 602int
604xfs_dir2_leafn_lookup_int( 603xfs_dir2_leafn_lookup_int(
605 xfs_dabuf_t *bp, /* leaf buffer */ 604 struct xfs_buf *bp, /* leaf buffer */
606 xfs_da_args_t *args, /* operation arguments */ 605 xfs_da_args_t *args, /* operation arguments */
607 int *indexp, /* out: leaf entry index */ 606 int *indexp, /* out: leaf entry index */
608 xfs_da_state_t *state) /* state to fill in */ 607 xfs_da_state_t *state) /* state to fill in */
@@ -620,9 +619,9 @@ xfs_dir2_leafn_lookup_int(
620static void 619static void
621xfs_dir2_leafn_moveents( 620xfs_dir2_leafn_moveents(
622 xfs_da_args_t *args, /* operation arguments */ 621 xfs_da_args_t *args, /* operation arguments */
623 xfs_dabuf_t *bp_s, /* source leaf buffer */ 622 struct xfs_buf *bp_s, /* source leaf buffer */
624 int start_s, /* source leaf index */ 623 int start_s, /* source leaf index */
625 xfs_dabuf_t *bp_d, /* destination leaf buffer */ 624 struct xfs_buf *bp_d, /* destination leaf buffer */
626 int start_d, /* destination leaf index */ 625 int start_d, /* destination leaf index */
627 int count) /* count of leaves to copy */ 626 int count) /* count of leaves to copy */
628{ 627{
@@ -640,8 +639,8 @@ xfs_dir2_leafn_moveents(
640 return; 639 return;
641 } 640 }
642 tp = args->trans; 641 tp = args->trans;
643 leaf_s = bp_s->data; 642 leaf_s = bp_s->b_addr;
644 leaf_d = bp_d->data; 643 leaf_d = bp_d->b_addr;
645 /* 644 /*
646 * If the destination index is not the end of the current 645 * If the destination index is not the end of the current
647 * destination leaf entries, open up a hole in the destination 646 * destination leaf entries, open up a hole in the destination
@@ -702,14 +701,14 @@ xfs_dir2_leafn_moveents(
702 */ 701 */
703int /* sort order */ 702int /* sort order */
704xfs_dir2_leafn_order( 703xfs_dir2_leafn_order(
705 xfs_dabuf_t *leaf1_bp, /* leaf1 buffer */ 704 struct xfs_buf *leaf1_bp, /* leaf1 buffer */
706 xfs_dabuf_t *leaf2_bp) /* leaf2 buffer */ 705 struct xfs_buf *leaf2_bp) /* leaf2 buffer */
707{ 706{
708 xfs_dir2_leaf_t *leaf1; /* leaf1 structure */ 707 xfs_dir2_leaf_t *leaf1; /* leaf1 structure */
709 xfs_dir2_leaf_t *leaf2; /* leaf2 structure */ 708 xfs_dir2_leaf_t *leaf2; /* leaf2 structure */
710 709
711 leaf1 = leaf1_bp->data; 710 leaf1 = leaf1_bp->b_addr;
712 leaf2 = leaf2_bp->data; 711 leaf2 = leaf2_bp->b_addr;
713 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 712 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
714 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 713 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
715 if (be16_to_cpu(leaf1->hdr.count) > 0 && 714 if (be16_to_cpu(leaf1->hdr.count) > 0 &&
@@ -757,8 +756,8 @@ xfs_dir2_leafn_rebalance(
757 blk1 = blk2; 756 blk1 = blk2;
758 blk2 = tmp; 757 blk2 = tmp;
759 } 758 }
760 leaf1 = blk1->bp->data; 759 leaf1 = blk1->bp->b_addr;
761 leaf2 = blk2->bp->data; 760 leaf2 = blk2->bp->b_addr;
762 oldsum = be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count); 761 oldsum = be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count);
763#ifdef DEBUG 762#ifdef DEBUG
764 oldstale = be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale); 763 oldstale = be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale);
@@ -834,14 +833,14 @@ xfs_dir2_leafn_rebalance(
834static int /* error */ 833static int /* error */
835xfs_dir2_leafn_remove( 834xfs_dir2_leafn_remove(
836 xfs_da_args_t *args, /* operation arguments */ 835 xfs_da_args_t *args, /* operation arguments */
837 xfs_dabuf_t *bp, /* leaf buffer */ 836 struct xfs_buf *bp, /* leaf buffer */
838 int index, /* leaf entry index */ 837 int index, /* leaf entry index */
839 xfs_da_state_blk_t *dblk, /* data block */ 838 xfs_da_state_blk_t *dblk, /* data block */
840 int *rval) /* resulting block needs join */ 839 int *rval) /* resulting block needs join */
841{ 840{
842 xfs_dir2_data_hdr_t *hdr; /* data block header */ 841 xfs_dir2_data_hdr_t *hdr; /* data block header */
843 xfs_dir2_db_t db; /* data block number */ 842 xfs_dir2_db_t db; /* data block number */
844 xfs_dabuf_t *dbp; /* data block buffer */ 843 struct xfs_buf *dbp; /* data block buffer */
845 xfs_dir2_data_entry_t *dep; /* data block entry */ 844 xfs_dir2_data_entry_t *dep; /* data block entry */
846 xfs_inode_t *dp; /* incore directory inode */ 845 xfs_inode_t *dp; /* incore directory inode */
847 xfs_dir2_leaf_t *leaf; /* leaf structure */ 846 xfs_dir2_leaf_t *leaf; /* leaf structure */
@@ -858,7 +857,7 @@ xfs_dir2_leafn_remove(
858 dp = args->dp; 857 dp = args->dp;
859 tp = args->trans; 858 tp = args->trans;
860 mp = dp->i_mount; 859 mp = dp->i_mount;
861 leaf = bp->data; 860 leaf = bp->b_addr;
862 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 861 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
863 /* 862 /*
864 * Point to the entry we're removing. 863 * Point to the entry we're removing.
@@ -884,7 +883,7 @@ xfs_dir2_leafn_remove(
884 * in the data block in case it changes. 883 * in the data block in case it changes.
885 */ 884 */
886 dbp = dblk->bp; 885 dbp = dblk->bp;
887 hdr = dbp->data; 886 hdr = dbp->b_addr;
888 dep = (xfs_dir2_data_entry_t *)((char *)hdr + off); 887 dep = (xfs_dir2_data_entry_t *)((char *)hdr + off);
889 longest = be16_to_cpu(hdr->bestfree[0].length); 888 longest = be16_to_cpu(hdr->bestfree[0].length);
890 needlog = needscan = 0; 889 needlog = needscan = 0;
@@ -905,7 +904,7 @@ xfs_dir2_leafn_remove(
905 */ 904 */
906 if (longest < be16_to_cpu(hdr->bestfree[0].length)) { 905 if (longest < be16_to_cpu(hdr->bestfree[0].length)) {
907 int error; /* error return value */ 906 int error; /* error return value */
908 xfs_dabuf_t *fbp; /* freeblock buffer */ 907 struct xfs_buf *fbp; /* freeblock buffer */
909 xfs_dir2_db_t fdb; /* freeblock block number */ 908 xfs_dir2_db_t fdb; /* freeblock block number */
910 int findex; /* index in freeblock entries */ 909 int findex; /* index in freeblock entries */
911 xfs_dir2_free_t *free; /* freeblock structure */ 910 xfs_dir2_free_t *free; /* freeblock structure */
@@ -920,7 +919,7 @@ xfs_dir2_leafn_remove(
920 -1, &fbp, XFS_DATA_FORK))) { 919 -1, &fbp, XFS_DATA_FORK))) {
921 return error; 920 return error;
922 } 921 }
923 free = fbp->data; 922 free = fbp->b_addr;
924 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 923 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
925 ASSERT(be32_to_cpu(free->hdr.firstdb) == 924 ASSERT(be32_to_cpu(free->hdr.firstdb) ==
926 xfs_dir2_free_max_bests(mp) * 925 xfs_dir2_free_max_bests(mp) *
@@ -948,9 +947,7 @@ xfs_dir2_leafn_remove(
948 * In this case just drop the buffer and some one else 947 * In this case just drop the buffer and some one else
949 * will eventually get rid of the empty block. 948 * will eventually get rid of the empty block.
950 */ 949 */
951 else if (error == ENOSPC && args->total == 0) 950 else if (!(error == ENOSPC && args->total == 0))
952 xfs_da_buf_done(dbp);
953 else
954 return error; 951 return error;
955 } 952 }
956 /* 953 /*
@@ -1018,11 +1015,6 @@ xfs_dir2_leafn_remove(
1018 */ 1015 */
1019 if (logfree) 1016 if (logfree)
1020 xfs_dir2_free_log_bests(tp, fbp, findex, findex); 1017 xfs_dir2_free_log_bests(tp, fbp, findex, findex);
1021 /*
1022 * Drop the buffer if we still have it.
1023 */
1024 if (fbp)
1025 xfs_da_buf_done(fbp);
1026 } 1018 }
1027 xfs_dir2_leafn_check(dp, bp); 1019 xfs_dir2_leafn_check(dp, bp);
1028 /* 1020 /*
@@ -1114,7 +1106,7 @@ xfs_dir2_leafn_toosmall(
1114{ 1106{
1115 xfs_da_state_blk_t *blk; /* leaf block */ 1107 xfs_da_state_blk_t *blk; /* leaf block */
1116 xfs_dablk_t blkno; /* leaf block number */ 1108 xfs_dablk_t blkno; /* leaf block number */
1117 xfs_dabuf_t *bp; /* leaf buffer */ 1109 struct xfs_buf *bp; /* leaf buffer */
1118 int bytes; /* bytes in use */ 1110 int bytes; /* bytes in use */
1119 int count; /* leaf live entry count */ 1111 int count; /* leaf live entry count */
1120 int error; /* error return value */ 1112 int error; /* error return value */
@@ -1130,7 +1122,7 @@ xfs_dir2_leafn_toosmall(
1130 * to coalesce with a sibling. 1122 * to coalesce with a sibling.
1131 */ 1123 */
1132 blk = &state->path.blk[state->path.active - 1]; 1124 blk = &state->path.blk[state->path.active - 1];
1133 info = blk->bp->data; 1125 info = blk->bp->b_addr;
1134 ASSERT(info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1126 ASSERT(info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1135 leaf = (xfs_dir2_leaf_t *)info; 1127 leaf = (xfs_dir2_leaf_t *)info;
1136 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); 1128 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
@@ -1189,7 +1181,7 @@ xfs_dir2_leafn_toosmall(
1189 leaf = (xfs_dir2_leaf_t *)info; 1181 leaf = (xfs_dir2_leaf_t *)info;
1190 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); 1182 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
1191 bytes = state->blocksize - (state->blocksize >> 2); 1183 bytes = state->blocksize - (state->blocksize >> 2);
1192 leaf = bp->data; 1184 leaf = bp->b_addr;
1193 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1185 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1194 count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); 1186 count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
1195 bytes -= count * (uint)sizeof(leaf->ents[0]); 1187 bytes -= count * (uint)sizeof(leaf->ents[0]);
@@ -1198,7 +1190,7 @@ xfs_dir2_leafn_toosmall(
1198 */ 1190 */
1199 if (bytes >= 0) 1191 if (bytes >= 0)
1200 break; 1192 break;
1201 xfs_da_brelse(state->args->trans, bp); 1193 xfs_trans_brelse(state->args->trans, bp);
1202 } 1194 }
1203 /* 1195 /*
1204 * Didn't like either block, give up. 1196 * Didn't like either block, give up.
@@ -1207,11 +1199,7 @@ xfs_dir2_leafn_toosmall(
1207 *action = 0; 1199 *action = 0;
1208 return 0; 1200 return 0;
1209 } 1201 }
1210 /* 1202
1211 * Done with the sibling leaf block here, drop the dabuf
1212 * so path_shift can get it.
1213 */
1214 xfs_da_buf_done(bp);
1215 /* 1203 /*
1216 * Make altpath point to the block we want to keep (the lower 1204 * Make altpath point to the block we want to keep (the lower
1217 * numbered block) and path point to the block we want to drop. 1205 * numbered block) and path point to the block we want to drop.
@@ -1247,8 +1235,8 @@ xfs_dir2_leafn_unbalance(
1247 args = state->args; 1235 args = state->args;
1248 ASSERT(drop_blk->magic == XFS_DIR2_LEAFN_MAGIC); 1236 ASSERT(drop_blk->magic == XFS_DIR2_LEAFN_MAGIC);
1249 ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC); 1237 ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC);
1250 drop_leaf = drop_blk->bp->data; 1238 drop_leaf = drop_blk->bp->b_addr;
1251 save_leaf = save_blk->bp->data; 1239 save_leaf = save_blk->bp->b_addr;
1252 ASSERT(drop_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1240 ASSERT(drop_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1253 ASSERT(save_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1241 ASSERT(save_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1254 /* 1242 /*
@@ -1356,13 +1344,13 @@ xfs_dir2_node_addname_int(
1356{ 1344{
1357 xfs_dir2_data_hdr_t *hdr; /* data block header */ 1345 xfs_dir2_data_hdr_t *hdr; /* data block header */
1358 xfs_dir2_db_t dbno; /* data block number */ 1346 xfs_dir2_db_t dbno; /* data block number */
1359 xfs_dabuf_t *dbp; /* data block buffer */ 1347 struct xfs_buf *dbp; /* data block buffer */
1360 xfs_dir2_data_entry_t *dep; /* data entry pointer */ 1348 xfs_dir2_data_entry_t *dep; /* data entry pointer */
1361 xfs_inode_t *dp; /* incore directory inode */ 1349 xfs_inode_t *dp; /* incore directory inode */
1362 xfs_dir2_data_unused_t *dup; /* data unused entry pointer */ 1350 xfs_dir2_data_unused_t *dup; /* data unused entry pointer */
1363 int error; /* error return value */ 1351 int error; /* error return value */
1364 xfs_dir2_db_t fbno; /* freespace block number */ 1352 xfs_dir2_db_t fbno; /* freespace block number */
1365 xfs_dabuf_t *fbp; /* freespace buffer */ 1353 struct xfs_buf *fbp; /* freespace buffer */
1366 int findex; /* freespace entry index */ 1354 int findex; /* freespace entry index */
1367 xfs_dir2_free_t *free=NULL; /* freespace block structure */ 1355 xfs_dir2_free_t *free=NULL; /* freespace block structure */
1368 xfs_dir2_db_t ifbno; /* initial freespace block no */ 1356 xfs_dir2_db_t ifbno; /* initial freespace block no */
@@ -1390,7 +1378,7 @@ xfs_dir2_node_addname_int(
1390 * Remember initial freespace block number. 1378 * Remember initial freespace block number.
1391 */ 1379 */
1392 ifbno = fblk->blkno; 1380 ifbno = fblk->blkno;
1393 free = fbp->data; 1381 free = fbp->b_addr;
1394 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1382 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1395 findex = fblk->index; 1383 findex = fblk->index;
1396 /* 1384 /*
@@ -1474,7 +1462,7 @@ xfs_dir2_node_addname_int(
1474 if (unlikely(fbp == NULL)) { 1462 if (unlikely(fbp == NULL)) {
1475 continue; 1463 continue;
1476 } 1464 }
1477 free = fbp->data; 1465 free = fbp->b_addr;
1478 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1466 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1479 findex = 0; 1467 findex = 0;
1480 } 1468 }
@@ -1492,7 +1480,7 @@ xfs_dir2_node_addname_int(
1492 /* 1480 /*
1493 * Drop the block. 1481 * Drop the block.
1494 */ 1482 */
1495 xfs_da_brelse(tp, fbp); 1483 xfs_trans_brelse(tp, fbp);
1496 fbp = NULL; 1484 fbp = NULL;
1497 if (fblk && fblk->bp) 1485 if (fblk && fblk->bp)
1498 fblk->bp = NULL; 1486 fblk->bp = NULL;
@@ -1507,36 +1495,23 @@ xfs_dir2_node_addname_int(
1507 /* 1495 /*
1508 * Not allowed to allocate, return failure. 1496 * Not allowed to allocate, return failure.
1509 */ 1497 */
1510 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || 1498 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0)
1511 args->total == 0) {
1512 /*
1513 * Drop the freespace buffer unless it came from our
1514 * caller.
1515 */
1516 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1517 xfs_da_buf_done(fbp);
1518 return XFS_ERROR(ENOSPC); 1499 return XFS_ERROR(ENOSPC);
1519 } 1500
1520 /* 1501 /*
1521 * Allocate and initialize the new data block. 1502 * Allocate and initialize the new data block.
1522 */ 1503 */
1523 if (unlikely((error = xfs_dir2_grow_inode(args, 1504 if (unlikely((error = xfs_dir2_grow_inode(args,
1524 XFS_DIR2_DATA_SPACE, 1505 XFS_DIR2_DATA_SPACE,
1525 &dbno)) || 1506 &dbno)) ||
1526 (error = xfs_dir2_data_init(args, dbno, &dbp)))) { 1507 (error = xfs_dir2_data_init(args, dbno, &dbp))))
1527 /*
1528 * Drop the freespace buffer unless it came from our
1529 * caller.
1530 */
1531 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1532 xfs_da_buf_done(fbp);
1533 return error; 1508 return error;
1534 } 1509
1535 /* 1510 /*
1536 * If (somehow) we have a freespace block, get rid of it. 1511 * If (somehow) we have a freespace block, get rid of it.
1537 */ 1512 */
1538 if (fbp) 1513 if (fbp)
1539 xfs_da_brelse(tp, fbp); 1514 xfs_trans_brelse(tp, fbp);
1540 if (fblk && fblk->bp) 1515 if (fblk && fblk->bp)
1541 fblk->bp = NULL; 1516 fblk->bp = NULL;
1542 1517
@@ -1547,10 +1522,9 @@ xfs_dir2_node_addname_int(
1547 fbno = xfs_dir2_db_to_fdb(mp, dbno); 1522 fbno = xfs_dir2_db_to_fdb(mp, dbno);
1548 if (unlikely(error = xfs_da_read_buf(tp, dp, 1523 if (unlikely(error = xfs_da_read_buf(tp, dp,
1549 xfs_dir2_db_to_da(mp, fbno), -2, &fbp, 1524 xfs_dir2_db_to_da(mp, fbno), -2, &fbp,
1550 XFS_DATA_FORK))) { 1525 XFS_DATA_FORK)))
1551 xfs_da_buf_done(dbp);
1552 return error; 1526 return error;
1553 } 1527
1554 /* 1528 /*
1555 * If there wasn't a freespace block, the read will 1529 * If there wasn't a freespace block, the read will
1556 * return a NULL fbp. Allocate and initialize a new one. 1530 * return a NULL fbp. Allocate and initialize a new one.
@@ -1598,7 +1572,7 @@ xfs_dir2_node_addname_int(
1598 * Initialize the new block to be empty, and remember 1572 * Initialize the new block to be empty, and remember
1599 * its first slot as our empty slot. 1573 * its first slot as our empty slot.
1600 */ 1574 */
1601 free = fbp->data; 1575 free = fbp->b_addr;
1602 free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC); 1576 free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC);
1603 free->hdr.firstdb = cpu_to_be32( 1577 free->hdr.firstdb = cpu_to_be32(
1604 (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) * 1578 (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) *
@@ -1606,7 +1580,7 @@ xfs_dir2_node_addname_int(
1606 free->hdr.nvalid = 0; 1580 free->hdr.nvalid = 0;
1607 free->hdr.nused = 0; 1581 free->hdr.nused = 0;
1608 } else { 1582 } else {
1609 free = fbp->data; 1583 free = fbp->b_addr;
1610 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1584 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1611 } 1585 }
1612 1586
@@ -1639,7 +1613,7 @@ xfs_dir2_node_addname_int(
1639 * We haven't allocated the data entry yet so this will 1613 * We haven't allocated the data entry yet so this will
1640 * change again. 1614 * change again.
1641 */ 1615 */
1642 hdr = dbp->data; 1616 hdr = dbp->b_addr;
1643 free->bests[findex] = hdr->bestfree[0].length; 1617 free->bests[findex] = hdr->bestfree[0].length;
1644 logfree = 1; 1618 logfree = 1;
1645 } 1619 }
@@ -1650,22 +1624,17 @@ xfs_dir2_node_addname_int(
1650 /* 1624 /*
1651 * If just checking, we succeeded. 1625 * If just checking, we succeeded.
1652 */ 1626 */
1653 if (args->op_flags & XFS_DA_OP_JUSTCHECK) { 1627 if (args->op_flags & XFS_DA_OP_JUSTCHECK)
1654 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1655 xfs_da_buf_done(fbp);
1656 return 0; 1628 return 0;
1657 } 1629
1658 /* 1630 /*
1659 * Read the data block in. 1631 * Read the data block in.
1660 */ 1632 */
1661 if (unlikely( 1633 error = xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, dbno),
1662 error = xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, dbno), 1634 -1, &dbp, XFS_DATA_FORK);
1663 -1, &dbp, XFS_DATA_FORK))) { 1635 if (error)
1664 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1665 xfs_da_buf_done(fbp);
1666 return error; 1636 return error;
1667 } 1637 hdr = dbp->b_addr;
1668 hdr = dbp->data;
1669 logfree = 0; 1638 logfree = 0;
1670 } 1639 }
1671 ASSERT(be16_to_cpu(hdr->bestfree[0].length) >= length); 1640 ASSERT(be16_to_cpu(hdr->bestfree[0].length) >= length);
@@ -1714,16 +1683,10 @@ xfs_dir2_node_addname_int(
1714 if (logfree) 1683 if (logfree)
1715 xfs_dir2_free_log_bests(tp, fbp, findex, findex); 1684 xfs_dir2_free_log_bests(tp, fbp, findex, findex);
1716 /* 1685 /*
1717 * If the caller didn't hand us the freespace block, drop it.
1718 */
1719 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1720 xfs_da_buf_done(fbp);
1721 /*
1722 * Return the data block and offset in args, then drop the data block. 1686 * Return the data block and offset in args, then drop the data block.
1723 */ 1687 */
1724 args->blkno = (xfs_dablk_t)dbno; 1688 args->blkno = (xfs_dablk_t)dbno;
1725 args->index = be16_to_cpu(*tagp); 1689 args->index = be16_to_cpu(*tagp);
1726 xfs_da_buf_done(dbp);
1727 return 0; 1690 return 0;
1728} 1691}
1729 1692
@@ -1761,22 +1724,23 @@ xfs_dir2_node_lookup(
1761 /* If a CI match, dup the actual name and return EEXIST */ 1724 /* If a CI match, dup the actual name and return EEXIST */
1762 xfs_dir2_data_entry_t *dep; 1725 xfs_dir2_data_entry_t *dep;
1763 1726
1764 dep = (xfs_dir2_data_entry_t *)((char *)state->extrablk.bp-> 1727 dep = (xfs_dir2_data_entry_t *)
1765 data + state->extrablk.index); 1728 ((char *)state->extrablk.bp->b_addr +
1729 state->extrablk.index);
1766 rval = xfs_dir_cilookup_result(args, dep->name, dep->namelen); 1730 rval = xfs_dir_cilookup_result(args, dep->name, dep->namelen);
1767 } 1731 }
1768 /* 1732 /*
1769 * Release the btree blocks and leaf block. 1733 * Release the btree blocks and leaf block.
1770 */ 1734 */
1771 for (i = 0; i < state->path.active; i++) { 1735 for (i = 0; i < state->path.active; i++) {
1772 xfs_da_brelse(args->trans, state->path.blk[i].bp); 1736 xfs_trans_brelse(args->trans, state->path.blk[i].bp);
1773 state->path.blk[i].bp = NULL; 1737 state->path.blk[i].bp = NULL;
1774 } 1738 }
1775 /* 1739 /*
1776 * Release the data block if we have it. 1740 * Release the data block if we have it.
1777 */ 1741 */
1778 if (state->extravalid && state->extrablk.bp) { 1742 if (state->extravalid && state->extrablk.bp) {
1779 xfs_da_brelse(args->trans, state->extrablk.bp); 1743 xfs_trans_brelse(args->trans, state->extrablk.bp);
1780 state->extrablk.bp = NULL; 1744 state->extrablk.bp = NULL;
1781 } 1745 }
1782 xfs_da_state_free(state); 1746 xfs_da_state_free(state);
@@ -1893,13 +1857,13 @@ xfs_dir2_node_replace(
1893 */ 1857 */
1894 blk = &state->path.blk[state->path.active - 1]; 1858 blk = &state->path.blk[state->path.active - 1];
1895 ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC); 1859 ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC);
1896 leaf = blk->bp->data; 1860 leaf = blk->bp->b_addr;
1897 lep = &leaf->ents[blk->index]; 1861 lep = &leaf->ents[blk->index];
1898 ASSERT(state->extravalid); 1862 ASSERT(state->extravalid);
1899 /* 1863 /*
1900 * Point to the data entry. 1864 * Point to the data entry.
1901 */ 1865 */
1902 hdr = state->extrablk.bp->data; 1866 hdr = state->extrablk.bp->b_addr;
1903 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC)); 1867 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC));
1904 dep = (xfs_dir2_data_entry_t *) 1868 dep = (xfs_dir2_data_entry_t *)
1905 ((char *)hdr + 1869 ((char *)hdr +
@@ -1916,14 +1880,14 @@ xfs_dir2_node_replace(
1916 * Didn't find it, and we're holding a data block. Drop it. 1880 * Didn't find it, and we're holding a data block. Drop it.
1917 */ 1881 */
1918 else if (state->extravalid) { 1882 else if (state->extravalid) {
1919 xfs_da_brelse(args->trans, state->extrablk.bp); 1883 xfs_trans_brelse(args->trans, state->extrablk.bp);
1920 state->extrablk.bp = NULL; 1884 state->extrablk.bp = NULL;
1921 } 1885 }
1922 /* 1886 /*
1923 * Release all the buffers in the cursor. 1887 * Release all the buffers in the cursor.
1924 */ 1888 */
1925 for (i = 0; i < state->path.active; i++) { 1889 for (i = 0; i < state->path.active; i++) {
1926 xfs_da_brelse(args->trans, state->path.blk[i].bp); 1890 xfs_trans_brelse(args->trans, state->path.blk[i].bp);
1927 state->path.blk[i].bp = NULL; 1891 state->path.blk[i].bp = NULL;
1928 } 1892 }
1929 xfs_da_state_free(state); 1893 xfs_da_state_free(state);
@@ -1940,7 +1904,7 @@ xfs_dir2_node_trim_free(
1940 xfs_fileoff_t fo, /* free block number */ 1904 xfs_fileoff_t fo, /* free block number */
1941 int *rvalp) /* out: did something */ 1905 int *rvalp) /* out: did something */
1942{ 1906{
1943 xfs_dabuf_t *bp; /* freespace buffer */ 1907 struct xfs_buf *bp; /* freespace buffer */
1944 xfs_inode_t *dp; /* incore directory inode */ 1908 xfs_inode_t *dp; /* incore directory inode */
1945 int error; /* error return code */ 1909 int error; /* error return code */
1946 xfs_dir2_free_t *free; /* freespace structure */ 1910 xfs_dir2_free_t *free; /* freespace structure */
@@ -1965,13 +1929,13 @@ xfs_dir2_node_trim_free(
1965 if (bp == NULL) { 1929 if (bp == NULL) {
1966 return 0; 1930 return 0;
1967 } 1931 }
1968 free = bp->data; 1932 free = bp->b_addr;
1969 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1933 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1970 /* 1934 /*
1971 * If there are used entries, there's nothing to do. 1935 * If there are used entries, there's nothing to do.
1972 */ 1936 */
1973 if (be32_to_cpu(free->hdr.nused) > 0) { 1937 if (be32_to_cpu(free->hdr.nused) > 0) {
1974 xfs_da_brelse(tp, bp); 1938 xfs_trans_brelse(tp, bp);
1975 *rvalp = 0; 1939 *rvalp = 0;
1976 return 0; 1940 return 0;
1977 } 1941 }
@@ -1987,7 +1951,7 @@ xfs_dir2_node_trim_free(
1987 * pieces. This is the last block of an extent. 1951 * pieces. This is the last block of an extent.
1988 */ 1952 */
1989 ASSERT(error != ENOSPC); 1953 ASSERT(error != ENOSPC);
1990 xfs_da_brelse(tp, bp); 1954 xfs_trans_brelse(tp, bp);
1991 return error; 1955 return error;
1992 } 1956 }
1993 /* 1957 /*
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h
index 067f403ecf8a..3523d3e15aa8 100644
--- a/fs/xfs/xfs_dir2_priv.h
+++ b/fs/xfs/xfs_dir2_priv.h
@@ -25,7 +25,7 @@ extern int xfs_dir2_isleaf(struct xfs_trans *tp, struct xfs_inode *dp, int *r);
25extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, 25extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
26 xfs_dir2_db_t *dbp); 26 xfs_dir2_db_t *dbp);
27extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db, 27extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
28 struct xfs_dabuf *bp); 28 struct xfs_buf *bp);
29extern int xfs_dir_cilookup_result(struct xfs_da_args *args, 29extern int xfs_dir_cilookup_result(struct xfs_da_args *args,
30 const unsigned char *name, int len); 30 const unsigned char *name, int len);
31 31
@@ -37,11 +37,11 @@ extern int xfs_dir2_block_lookup(struct xfs_da_args *args);
37extern int xfs_dir2_block_removename(struct xfs_da_args *args); 37extern int xfs_dir2_block_removename(struct xfs_da_args *args);
38extern int xfs_dir2_block_replace(struct xfs_da_args *args); 38extern int xfs_dir2_block_replace(struct xfs_da_args *args);
39extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args, 39extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
40 struct xfs_dabuf *lbp, struct xfs_dabuf *dbp); 40 struct xfs_buf *lbp, struct xfs_buf *dbp);
41 41
42/* xfs_dir2_data.c */ 42/* xfs_dir2_data.c */
43#ifdef DEBUG 43#ifdef DEBUG
44extern void xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_dabuf *bp); 44extern void xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
45#else 45#else
46#define xfs_dir2_data_check(dp,bp) 46#define xfs_dir2_data_check(dp,bp)
47#endif 47#endif
@@ -51,43 +51,43 @@ xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr,
51extern void xfs_dir2_data_freescan(struct xfs_mount *mp, 51extern void xfs_dir2_data_freescan(struct xfs_mount *mp,
52 struct xfs_dir2_data_hdr *hdr, int *loghead); 52 struct xfs_dir2_data_hdr *hdr, int *loghead);
53extern int xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno, 53extern int xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,
54 struct xfs_dabuf **bpp); 54 struct xfs_buf **bpp);
55extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_dabuf *bp, 55extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_buf *bp,
56 struct xfs_dir2_data_entry *dep); 56 struct xfs_dir2_data_entry *dep);
57extern void xfs_dir2_data_log_header(struct xfs_trans *tp, 57extern void xfs_dir2_data_log_header(struct xfs_trans *tp,
58 struct xfs_dabuf *bp); 58 struct xfs_buf *bp);
59extern void xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_dabuf *bp, 59extern void xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_buf *bp,
60 struct xfs_dir2_data_unused *dup); 60 struct xfs_dir2_data_unused *dup);
61extern void xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_dabuf *bp, 61extern void xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_buf *bp,
62 xfs_dir2_data_aoff_t offset, xfs_dir2_data_aoff_t len, 62 xfs_dir2_data_aoff_t offset, xfs_dir2_data_aoff_t len,
63 int *needlogp, int *needscanp); 63 int *needlogp, int *needscanp);
64extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_dabuf *bp, 64extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_buf *bp,
65 struct xfs_dir2_data_unused *dup, xfs_dir2_data_aoff_t offset, 65 struct xfs_dir2_data_unused *dup, xfs_dir2_data_aoff_t offset,
66 xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp); 66 xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);
67 67
68/* xfs_dir2_leaf.c */ 68/* xfs_dir2_leaf.c */
69extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args, 69extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
70 struct xfs_dabuf *dbp); 70 struct xfs_buf *dbp);
71extern int xfs_dir2_leaf_addname(struct xfs_da_args *args); 71extern int xfs_dir2_leaf_addname(struct xfs_da_args *args);
72extern void xfs_dir2_leaf_compact(struct xfs_da_args *args, 72extern void xfs_dir2_leaf_compact(struct xfs_da_args *args,
73 struct xfs_dabuf *bp); 73 struct xfs_buf *bp);
74extern void xfs_dir2_leaf_compact_x1(struct xfs_dabuf *bp, int *indexp, 74extern void xfs_dir2_leaf_compact_x1(struct xfs_buf *bp, int *indexp,
75 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp); 75 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp);
76extern int xfs_dir2_leaf_getdents(struct xfs_inode *dp, void *dirent, 76extern int xfs_dir2_leaf_getdents(struct xfs_inode *dp, void *dirent,
77 size_t bufsize, xfs_off_t *offset, filldir_t filldir); 77 size_t bufsize, xfs_off_t *offset, filldir_t filldir);
78extern int xfs_dir2_leaf_init(struct xfs_da_args *args, xfs_dir2_db_t bno, 78extern int xfs_dir2_leaf_init(struct xfs_da_args *args, xfs_dir2_db_t bno,
79 struct xfs_dabuf **bpp, int magic); 79 struct xfs_buf **bpp, int magic);
80extern void xfs_dir2_leaf_log_ents(struct xfs_trans *tp, struct xfs_dabuf *bp, 80extern void xfs_dir2_leaf_log_ents(struct xfs_trans *tp, struct xfs_buf *bp,
81 int first, int last); 81 int first, int last);
82extern void xfs_dir2_leaf_log_header(struct xfs_trans *tp, 82extern void xfs_dir2_leaf_log_header(struct xfs_trans *tp,
83 struct xfs_dabuf *bp); 83 struct xfs_buf *bp);
84extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args); 84extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args);
85extern int xfs_dir2_leaf_removename(struct xfs_da_args *args); 85extern int xfs_dir2_leaf_removename(struct xfs_da_args *args);
86extern int xfs_dir2_leaf_replace(struct xfs_da_args *args); 86extern int xfs_dir2_leaf_replace(struct xfs_da_args *args);
87extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args, 87extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args,
88 struct xfs_dabuf *lbp); 88 struct xfs_buf *lbp);
89extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args, 89extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args,
90 struct xfs_dabuf *lbp, xfs_dir2_db_t db); 90 struct xfs_buf *lbp, xfs_dir2_db_t db);
91extern struct xfs_dir2_leaf_entry * 91extern struct xfs_dir2_leaf_entry *
92xfs_dir2_leaf_find_entry(struct xfs_dir2_leaf *leaf, int index, int compact, 92xfs_dir2_leaf_find_entry(struct xfs_dir2_leaf *leaf, int index, int compact,
93 int lowstale, int highstale, 93 int lowstale, int highstale,
@@ -96,13 +96,13 @@ extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
96 96
97/* xfs_dir2_node.c */ 97/* xfs_dir2_node.c */
98extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args, 98extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args,
99 struct xfs_dabuf *lbp); 99 struct xfs_buf *lbp);
100extern xfs_dahash_t xfs_dir2_leafn_lasthash(struct xfs_dabuf *bp, int *count); 100extern xfs_dahash_t xfs_dir2_leafn_lasthash(struct xfs_buf *bp, int *count);
101extern int xfs_dir2_leafn_lookup_int(struct xfs_dabuf *bp, 101extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp,
102 struct xfs_da_args *args, int *indexp, 102 struct xfs_da_args *args, int *indexp,
103 struct xfs_da_state *state); 103 struct xfs_da_state *state);
104extern int xfs_dir2_leafn_order(struct xfs_dabuf *leaf1_bp, 104extern int xfs_dir2_leafn_order(struct xfs_buf *leaf1_bp,
105 struct xfs_dabuf *leaf2_bp); 105 struct xfs_buf *leaf2_bp);
106extern int xfs_dir2_leafn_split(struct xfs_da_state *state, 106extern int xfs_dir2_leafn_split(struct xfs_da_state *state,
107 struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk); 107 struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk);
108extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action); 108extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action);
@@ -122,7 +122,7 @@ extern xfs_ino_t xfs_dir2_sfe_get_ino(struct xfs_dir2_sf_hdr *sfp,
122 struct xfs_dir2_sf_entry *sfep); 122 struct xfs_dir2_sf_entry *sfep);
123extern int xfs_dir2_block_sfsize(struct xfs_inode *dp, 123extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
124 struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp); 124 struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp);
125extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_dabuf *bp, 125extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,
126 int size, xfs_dir2_sf_hdr_t *sfhp); 126 int size, xfs_dir2_sf_hdr_t *sfhp);
127extern int xfs_dir2_sf_addname(struct xfs_da_args *args); 127extern int xfs_dir2_sf_addname(struct xfs_da_args *args);
128extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino); 128extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index 19bf0c5e38f4..1b9fc3ec7e4b 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -222,7 +222,7 @@ xfs_dir2_block_sfsize(
222int /* error */ 222int /* error */
223xfs_dir2_block_to_sf( 223xfs_dir2_block_to_sf(
224 xfs_da_args_t *args, /* operation arguments */ 224 xfs_da_args_t *args, /* operation arguments */
225 xfs_dabuf_t *bp, /* block buffer */ 225 struct xfs_buf *bp,
226 int size, /* shortform directory size */ 226 int size, /* shortform directory size */
227 xfs_dir2_sf_hdr_t *sfhp) /* shortform directory hdr */ 227 xfs_dir2_sf_hdr_t *sfhp) /* shortform directory hdr */
228{ 228{
@@ -249,7 +249,7 @@ xfs_dir2_block_to_sf(
249 * and add local data. 249 * and add local data.
250 */ 250 */
251 hdr = kmem_alloc(mp->m_dirblksize, KM_SLEEP); 251 hdr = kmem_alloc(mp->m_dirblksize, KM_SLEEP);
252 memcpy(hdr, bp->data, mp->m_dirblksize); 252 memcpy(hdr, bp->b_addr, mp->m_dirblksize);
253 logflags = XFS_ILOG_CORE; 253 logflags = XFS_ILOG_CORE;
254 if ((error = xfs_dir2_shrink_inode(args, mp->m_dirdatablk, bp))) { 254 if ((error = xfs_dir2_shrink_inode(args, mp->m_dirdatablk, bp))) {
255 ASSERT(error != ENOSPC); 255 ASSERT(error != ENOSPC);
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 9f7ec15a6522..c4559c6e6f2c 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -236,7 +236,6 @@ xfs_file_aio_read(
236 ssize_t ret = 0; 236 ssize_t ret = 0;
237 int ioflags = 0; 237 int ioflags = 0;
238 xfs_fsize_t n; 238 xfs_fsize_t n;
239 unsigned long seg;
240 239
241 XFS_STATS_INC(xs_read_calls); 240 XFS_STATS_INC(xs_read_calls);
242 241
@@ -247,19 +246,9 @@ xfs_file_aio_read(
247 if (file->f_mode & FMODE_NOCMTIME) 246 if (file->f_mode & FMODE_NOCMTIME)
248 ioflags |= IO_INVIS; 247 ioflags |= IO_INVIS;
249 248
250 /* START copy & waste from filemap.c */ 249 ret = generic_segment_checks(iovp, &nr_segs, &size, VERIFY_WRITE);
251 for (seg = 0; seg < nr_segs; seg++) { 250 if (ret < 0)
252 const struct iovec *iv = &iovp[seg]; 251 return ret;
253
254 /*
255 * If any segment has a negative length, or the cumulative
256 * length ever wraps negative then return -EINVAL.
257 */
258 size += iv->iov_len;
259 if (unlikely((ssize_t)(size|iv->iov_len) < 0))
260 return XFS_ERROR(-EINVAL);
261 }
262 /* END copy & waste from filemap.c */
263 252
264 if (unlikely(ioflags & IO_ISDIRECT)) { 253 if (unlikely(ioflags & IO_ISDIRECT)) {
265 xfs_buftarg_t *target = 254 xfs_buftarg_t *target =
@@ -273,7 +262,7 @@ xfs_file_aio_read(
273 } 262 }
274 } 263 }
275 264
276 n = XFS_MAXIOFFSET(mp) - iocb->ki_pos; 265 n = mp->m_super->s_maxbytes - iocb->ki_pos;
277 if (n <= 0 || size == 0) 266 if (n <= 0 || size == 0)
278 return 0; 267 return 0;
279 268
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index 177a21a7ac49..21e37b55f7e5 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -442,14 +442,13 @@ xfs_ialloc_next_ag(
442 * Select an allocation group to look for a free inode in, based on the parent 442 * Select an allocation group to look for a free inode in, based on the parent
443 * inode and then mode. Return the allocation group buffer. 443 * inode and then mode. Return the allocation group buffer.
444 */ 444 */
445STATIC xfs_buf_t * /* allocation group buffer */ 445STATIC xfs_agnumber_t
446xfs_ialloc_ag_select( 446xfs_ialloc_ag_select(
447 xfs_trans_t *tp, /* transaction pointer */ 447 xfs_trans_t *tp, /* transaction pointer */
448 xfs_ino_t parent, /* parent directory inode number */ 448 xfs_ino_t parent, /* parent directory inode number */
449 umode_t mode, /* bits set to indicate file type */ 449 umode_t mode, /* bits set to indicate file type */
450 int okalloc) /* ok to allocate more space */ 450 int okalloc) /* ok to allocate more space */
451{ 451{
452 xfs_buf_t *agbp; /* allocation group header buffer */
453 xfs_agnumber_t agcount; /* number of ag's in the filesystem */ 452 xfs_agnumber_t agcount; /* number of ag's in the filesystem */
454 xfs_agnumber_t agno; /* current ag number */ 453 xfs_agnumber_t agno; /* current ag number */
455 int flags; /* alloc buffer locking flags */ 454 int flags; /* alloc buffer locking flags */
@@ -459,6 +458,7 @@ xfs_ialloc_ag_select(
459 int needspace; /* file mode implies space allocated */ 458 int needspace; /* file mode implies space allocated */
460 xfs_perag_t *pag; /* per allocation group data */ 459 xfs_perag_t *pag; /* per allocation group data */
461 xfs_agnumber_t pagno; /* parent (starting) ag number */ 460 xfs_agnumber_t pagno; /* parent (starting) ag number */
461 int error;
462 462
463 /* 463 /*
464 * Files of these types need at least one block if length > 0 464 * Files of these types need at least one block if length > 0
@@ -474,7 +474,9 @@ xfs_ialloc_ag_select(
474 if (pagno >= agcount) 474 if (pagno >= agcount)
475 pagno = 0; 475 pagno = 0;
476 } 476 }
477
477 ASSERT(pagno < agcount); 478 ASSERT(pagno < agcount);
479
478 /* 480 /*
479 * Loop through allocation groups, looking for one with a little 481 * Loop through allocation groups, looking for one with a little
480 * free space in it. Note we don't look for free inodes, exactly. 482 * free space in it. Note we don't look for free inodes, exactly.
@@ -486,51 +488,45 @@ xfs_ialloc_ag_select(
486 flags = XFS_ALLOC_FLAG_TRYLOCK; 488 flags = XFS_ALLOC_FLAG_TRYLOCK;
487 for (;;) { 489 for (;;) {
488 pag = xfs_perag_get(mp, agno); 490 pag = xfs_perag_get(mp, agno);
491 if (!pag->pagi_inodeok) {
492 xfs_ialloc_next_ag(mp);
493 goto nextag;
494 }
495
489 if (!pag->pagi_init) { 496 if (!pag->pagi_init) {
490 if (xfs_ialloc_read_agi(mp, tp, agno, &agbp)) { 497 error = xfs_ialloc_pagi_init(mp, tp, agno);
491 agbp = NULL; 498 if (error)
492 goto nextag; 499 goto nextag;
493 } 500 }
494 } else
495 agbp = NULL;
496 501
497 if (!pag->pagi_inodeok) { 502 if (pag->pagi_freecount) {
498 xfs_ialloc_next_ag(mp); 503 xfs_perag_put(pag);
499 goto unlock_nextag; 504 return agno;
500 } 505 }
501 506
502 /* 507 if (!okalloc)
503 * Is there enough free space for the file plus a block 508 goto nextag;
504 * of inodes (if we need to allocate some)? 509
505 */ 510 if (!pag->pagf_init) {
506 ineed = pag->pagi_freecount ? 0 : XFS_IALLOC_BLOCKS(mp); 511 error = xfs_alloc_pagf_init(mp, tp, agno, flags);
507 if (ineed && !pag->pagf_init) { 512 if (error)
508 if (agbp == NULL &&
509 xfs_ialloc_read_agi(mp, tp, agno, &agbp)) {
510 agbp = NULL;
511 goto nextag; 513 goto nextag;
512 }
513 (void)xfs_alloc_pagf_init(mp, tp, agno, flags);
514 } 514 }
515 if (!ineed || pag->pagf_init) { 515
516 if (ineed && !(longest = pag->pagf_longest)) 516 /*
517 longest = pag->pagf_flcount > 0; 517 * Is there enough free space for the file plus a block of
518 if (!ineed || 518 * inodes? (if we need to allocate some)?
519 (pag->pagf_freeblks >= needspace + ineed && 519 */
520 longest >= ineed && 520 ineed = XFS_IALLOC_BLOCKS(mp);
521 okalloc)) { 521 longest = pag->pagf_longest;
522 if (agbp == NULL && 522 if (!longest)
523 xfs_ialloc_read_agi(mp, tp, agno, &agbp)) { 523 longest = pag->pagf_flcount > 0;
524 agbp = NULL; 524
525 goto nextag; 525 if (pag->pagf_freeblks >= needspace + ineed &&
526 } 526 longest >= ineed) {
527 xfs_perag_put(pag); 527 xfs_perag_put(pag);
528 return agbp; 528 return agno;
529 }
530 } 529 }
531unlock_nextag:
532 if (agbp)
533 xfs_trans_brelse(tp, agbp);
534nextag: 530nextag:
535 xfs_perag_put(pag); 531 xfs_perag_put(pag);
536 /* 532 /*
@@ -538,13 +534,13 @@ nextag:
538 * down. 534 * down.
539 */ 535 */
540 if (XFS_FORCED_SHUTDOWN(mp)) 536 if (XFS_FORCED_SHUTDOWN(mp))
541 return NULL; 537 return NULLAGNUMBER;
542 agno++; 538 agno++;
543 if (agno >= agcount) 539 if (agno >= agcount)
544 agno = 0; 540 agno = 0;
545 if (agno == pagno) { 541 if (agno == pagno) {
546 if (flags == 0) 542 if (flags == 0)
547 return NULL; 543 return NULLAGNUMBER;
548 flags = 0; 544 flags = 0;
549 } 545 }
550 } 546 }
@@ -607,195 +603,39 @@ xfs_ialloc_get_rec(
607} 603}
608 604
609/* 605/*
610 * Visible inode allocation functions. 606 * Allocate an inode.
611 */
612/*
613 * Find a free (set) bit in the inode bitmask.
614 */
615static inline int xfs_ialloc_find_free(xfs_inofree_t *fp)
616{
617 return xfs_lowbit64(*fp);
618}
619
620/*
621 * Allocate an inode on disk.
622 * Mode is used to tell whether the new inode will need space, and whether
623 * it is a directory.
624 *
625 * The arguments IO_agbp and alloc_done are defined to work within
626 * the constraint of one allocation per transaction.
627 * xfs_dialloc() is designed to be called twice if it has to do an
628 * allocation to make more free inodes. On the first call,
629 * IO_agbp should be set to NULL. If an inode is available,
630 * i.e., xfs_dialloc() did not need to do an allocation, an inode
631 * number is returned. In this case, IO_agbp would be set to the
632 * current ag_buf and alloc_done set to false.
633 * If an allocation needed to be done, xfs_dialloc would return
634 * the current ag_buf in IO_agbp and set alloc_done to true.
635 * The caller should then commit the current transaction, allocate a new
636 * transaction, and call xfs_dialloc() again, passing in the previous
637 * value of IO_agbp. IO_agbp should be held across the transactions.
638 * Since the agbp is locked across the two calls, the second call is
639 * guaranteed to have a free inode available.
640 * 607 *
641 * Once we successfully pick an inode its number is returned and the 608 * The caller selected an AG for us, and made sure that free inodes are
642 * on-disk data structures are updated. The inode itself is not read 609 * available.
643 * in, since doing so would break ordering constraints with xfs_reclaim.
644 */ 610 */
645int 611STATIC int
646xfs_dialloc( 612xfs_dialloc_ag(
647 xfs_trans_t *tp, /* transaction pointer */ 613 struct xfs_trans *tp,
648 xfs_ino_t parent, /* parent inode (directory) */ 614 struct xfs_buf *agbp,
649 umode_t mode, /* mode bits for new inode */ 615 xfs_ino_t parent,
650 int okalloc, /* ok to allocate more space */ 616 xfs_ino_t *inop)
651 xfs_buf_t **IO_agbp, /* in/out ag header's buffer */
652 boolean_t *alloc_done, /* true if we needed to replenish
653 inode freelist */
654 xfs_ino_t *inop) /* inode number allocated */
655{ 617{
656 xfs_agnumber_t agcount; /* number of allocation groups */ 618 struct xfs_mount *mp = tp->t_mountp;
657 xfs_buf_t *agbp; /* allocation group header's buffer */ 619 struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp);
658 xfs_agnumber_t agno; /* allocation group number */ 620 xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno);
659 xfs_agi_t *agi; /* allocation group header structure */ 621 xfs_agnumber_t pagno = XFS_INO_TO_AGNO(mp, parent);
660 xfs_btree_cur_t *cur; /* inode allocation btree cursor */ 622 xfs_agino_t pagino = XFS_INO_TO_AGINO(mp, parent);
661 int error; /* error return value */ 623 struct xfs_perag *pag;
662 int i; /* result code */ 624 struct xfs_btree_cur *cur, *tcur;
663 int ialloced; /* inode allocation status */ 625 struct xfs_inobt_rec_incore rec, trec;
664 int noroom = 0; /* no space for inode blk allocation */ 626 xfs_ino_t ino;
665 xfs_ino_t ino; /* fs-relative inode to be returned */ 627 int error;
666 /* REFERENCED */ 628 int offset;
667 int j; /* result code */ 629 int i, j;
668 xfs_mount_t *mp; /* file system mount structure */
669 int offset; /* index of inode in chunk */
670 xfs_agino_t pagino; /* parent's AG relative inode # */
671 xfs_agnumber_t pagno; /* parent's AG number */
672 xfs_inobt_rec_incore_t rec; /* inode allocation record */
673 xfs_agnumber_t tagno; /* testing allocation group number */
674 xfs_btree_cur_t *tcur; /* temp cursor */
675 xfs_inobt_rec_incore_t trec; /* temp inode allocation record */
676 struct xfs_perag *pag;
677
678
679 if (*IO_agbp == NULL) {
680 /*
681 * We do not have an agbp, so select an initial allocation
682 * group for inode allocation.
683 */
684 agbp = xfs_ialloc_ag_select(tp, parent, mode, okalloc);
685 /*
686 * Couldn't find an allocation group satisfying the
687 * criteria, give up.
688 */
689 if (!agbp) {
690 *inop = NULLFSINO;
691 return 0;
692 }
693 agi = XFS_BUF_TO_AGI(agbp);
694 ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC));
695 } else {
696 /*
697 * Continue where we left off before. In this case, we
698 * know that the allocation group has free inodes.
699 */
700 agbp = *IO_agbp;
701 agi = XFS_BUF_TO_AGI(agbp);
702 ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC));
703 ASSERT(be32_to_cpu(agi->agi_freecount) > 0);
704 }
705 mp = tp->t_mountp;
706 agcount = mp->m_sb.sb_agcount;
707 agno = be32_to_cpu(agi->agi_seqno);
708 tagno = agno;
709 pagno = XFS_INO_TO_AGNO(mp, parent);
710 pagino = XFS_INO_TO_AGINO(mp, parent);
711
712 /*
713 * If we have already hit the ceiling of inode blocks then clear
714 * okalloc so we scan all available agi structures for a free
715 * inode.
716 */
717
718 if (mp->m_maxicount &&
719 mp->m_sb.sb_icount + XFS_IALLOC_INODES(mp) > mp->m_maxicount) {
720 noroom = 1;
721 okalloc = 0;
722 }
723 630
724 /*
725 * Loop until we find an allocation group that either has free inodes
726 * or in which we can allocate some inodes. Iterate through the
727 * allocation groups upward, wrapping at the end.
728 */
729 *alloc_done = B_FALSE;
730 while (!agi->agi_freecount) {
731 /*
732 * Don't do anything if we're not supposed to allocate
733 * any blocks, just go on to the next ag.
734 */
735 if (okalloc) {
736 /*
737 * Try to allocate some new inodes in the allocation
738 * group.
739 */
740 if ((error = xfs_ialloc_ag_alloc(tp, agbp, &ialloced))) {
741 xfs_trans_brelse(tp, agbp);
742 if (error == ENOSPC) {
743 *inop = NULLFSINO;
744 return 0;
745 } else
746 return error;
747 }
748 if (ialloced) {
749 /*
750 * We successfully allocated some inodes, return
751 * the current context to the caller so that it
752 * can commit the current transaction and call
753 * us again where we left off.
754 */
755 ASSERT(be32_to_cpu(agi->agi_freecount) > 0);
756 *alloc_done = B_TRUE;
757 *IO_agbp = agbp;
758 *inop = NULLFSINO;
759 return 0;
760 }
761 }
762 /*
763 * If it failed, give up on this ag.
764 */
765 xfs_trans_brelse(tp, agbp);
766 /*
767 * Go on to the next ag: get its ag header.
768 */
769nextag:
770 if (++tagno == agcount)
771 tagno = 0;
772 if (tagno == agno) {
773 *inop = NULLFSINO;
774 return noroom ? ENOSPC : 0;
775 }
776 pag = xfs_perag_get(mp, tagno);
777 if (pag->pagi_inodeok == 0) {
778 xfs_perag_put(pag);
779 goto nextag;
780 }
781 error = xfs_ialloc_read_agi(mp, tp, tagno, &agbp);
782 xfs_perag_put(pag);
783 if (error)
784 goto nextag;
785 agi = XFS_BUF_TO_AGI(agbp);
786 ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC));
787 }
788 /*
789 * Here with an allocation group that has a free inode.
790 * Reset agno since we may have chosen a new ag in the
791 * loop above.
792 */
793 agno = tagno;
794 *IO_agbp = NULL;
795 pag = xfs_perag_get(mp, agno); 631 pag = xfs_perag_get(mp, agno);
796 632
633 ASSERT(pag->pagi_init);
634 ASSERT(pag->pagi_inodeok);
635 ASSERT(pag->pagi_freecount > 0);
636
797 restart_pagno: 637 restart_pagno:
798 cur = xfs_inobt_init_cursor(mp, tp, agbp, be32_to_cpu(agi->agi_seqno)); 638 cur = xfs_inobt_init_cursor(mp, tp, agbp, agno);
799 /* 639 /*
800 * If pagino is 0 (this is the root inode allocation) use newino. 640 * If pagino is 0 (this is the root inode allocation) use newino.
801 * This must work because we've just allocated some. 641 * This must work because we've just allocated some.
@@ -995,7 +835,7 @@ newino:
995 } 835 }
996 836
997alloc_inode: 837alloc_inode:
998 offset = xfs_ialloc_find_free(&rec.ir_free); 838 offset = xfs_lowbit64(rec.ir_free);
999 ASSERT(offset >= 0); 839 ASSERT(offset >= 0);
1000 ASSERT(offset < XFS_INODES_PER_CHUNK); 840 ASSERT(offset < XFS_INODES_PER_CHUNK);
1001 ASSERT((XFS_AGINO_TO_OFFSET(mp, rec.ir_startino) % 841 ASSERT((XFS_AGINO_TO_OFFSET(mp, rec.ir_startino) %
@@ -1028,6 +868,164 @@ error0:
1028} 868}
1029 869
1030/* 870/*
871 * Allocate an inode on disk.
872 *
873 * Mode is used to tell whether the new inode will need space, and whether it
874 * is a directory.
875 *
876 * This function is designed to be called twice if it has to do an allocation
877 * to make more free inodes. On the first call, *IO_agbp should be set to NULL.
878 * If an inode is available without having to performn an allocation, an inode
879 * number is returned. In this case, *IO_agbp would be NULL. If an allocation
880 * needes to be done, xfs_dialloc would return the current AGI buffer in
881 * *IO_agbp. The caller should then commit the current transaction, allocate a
882 * new transaction, and call xfs_dialloc() again, passing in the previous value
883 * of *IO_agbp. IO_agbp should be held across the transactions. Since the AGI
884 * buffer is locked across the two calls, the second call is guaranteed to have
885 * a free inode available.
886 *
887 * Once we successfully pick an inode its number is returned and the on-disk
888 * data structures are updated. The inode itself is not read in, since doing so
889 * would break ordering constraints with xfs_reclaim.
890 */
891int
892xfs_dialloc(
893 struct xfs_trans *tp,
894 xfs_ino_t parent,
895 umode_t mode,
896 int okalloc,
897 struct xfs_buf **IO_agbp,
898 xfs_ino_t *inop)
899{
900 struct xfs_mount *mp = tp->t_mountp;
901 struct xfs_buf *agbp;
902 xfs_agnumber_t agno;
903 int error;
904 int ialloced;
905 int noroom = 0;
906 xfs_agnumber_t start_agno;
907 struct xfs_perag *pag;
908
909 if (*IO_agbp) {
910 /*
911 * If the caller passes in a pointer to the AGI buffer,
912 * continue where we left off before. In this case, we
913 * know that the allocation group has free inodes.
914 */
915 agbp = *IO_agbp;
916 goto out_alloc;
917 }
918
919 /*
920 * We do not have an agbp, so select an initial allocation
921 * group for inode allocation.
922 */
923 start_agno = xfs_ialloc_ag_select(tp, parent, mode, okalloc);
924 if (start_agno == NULLAGNUMBER) {
925 *inop = NULLFSINO;
926 return 0;
927 }
928
929 /*
930 * If we have already hit the ceiling of inode blocks then clear
931 * okalloc so we scan all available agi structures for a free
932 * inode.
933 */
934 if (mp->m_maxicount &&
935 mp->m_sb.sb_icount + XFS_IALLOC_INODES(mp) > mp->m_maxicount) {
936 noroom = 1;
937 okalloc = 0;
938 }
939
940 /*
941 * Loop until we find an allocation group that either has free inodes
942 * or in which we can allocate some inodes. Iterate through the
943 * allocation groups upward, wrapping at the end.
944 */
945 agno = start_agno;
946 for (;;) {
947 pag = xfs_perag_get(mp, agno);
948 if (!pag->pagi_inodeok) {
949 xfs_ialloc_next_ag(mp);
950 goto nextag;
951 }
952
953 if (!pag->pagi_init) {
954 error = xfs_ialloc_pagi_init(mp, tp, agno);
955 if (error)
956 goto out_error;
957 }
958
959 /*
960 * Do a first racy fast path check if this AG is usable.
961 */
962 if (!pag->pagi_freecount && !okalloc)
963 goto nextag;
964
965 error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
966 if (error)
967 goto out_error;
968
969 /*
970 * Once the AGI has been read in we have to recheck
971 * pagi_freecount with the AGI buffer lock held.
972 */
973 if (pag->pagi_freecount) {
974 xfs_perag_put(pag);
975 goto out_alloc;
976 }
977
978 if (!okalloc) {
979 xfs_trans_brelse(tp, agbp);
980 goto nextag;
981 }
982
983 error = xfs_ialloc_ag_alloc(tp, agbp, &ialloced);
984 if (error) {
985 xfs_trans_brelse(tp, agbp);
986
987 if (error != ENOSPC)
988 goto out_error;
989
990 xfs_perag_put(pag);
991 *inop = NULLFSINO;
992 return 0;
993 }
994
995 if (ialloced) {
996 /*
997 * We successfully allocated some inodes, return
998 * the current context to the caller so that it
999 * can commit the current transaction and call
1000 * us again where we left off.
1001 */
1002 ASSERT(pag->pagi_freecount > 0);
1003 xfs_perag_put(pag);
1004
1005 *IO_agbp = agbp;
1006 *inop = NULLFSINO;
1007 return 0;
1008 }
1009
1010nextag:
1011 xfs_perag_put(pag);
1012 if (++agno == mp->m_sb.sb_agcount)
1013 agno = 0;
1014 if (agno == start_agno) {
1015 *inop = NULLFSINO;
1016 return noroom ? ENOSPC : 0;
1017 }
1018 }
1019
1020out_alloc:
1021 *IO_agbp = NULL;
1022 return xfs_dialloc_ag(tp, agbp, parent, inop);
1023out_error:
1024 xfs_perag_put(pag);
1025 return XFS_ERROR(error);
1026}
1027
1028/*
1031 * Free disk inode. Carefully avoids touching the incore inode, all 1029 * Free disk inode. Carefully avoids touching the incore inode, all
1032 * manipulations incore are the caller's responsibility. 1030 * manipulations incore are the caller's responsibility.
1033 * The on-disk inode is not changed by this operation, only the 1031 * The on-disk inode is not changed by this operation, only the
diff --git a/fs/xfs/xfs_ialloc.h b/fs/xfs/xfs_ialloc.h
index 65ac57c8063c..1fd6ea4e9c91 100644
--- a/fs/xfs/xfs_ialloc.h
+++ b/fs/xfs/xfs_ialloc.h
@@ -75,8 +75,6 @@ xfs_dialloc(
75 umode_t mode, /* mode bits for new inode */ 75 umode_t mode, /* mode bits for new inode */
76 int okalloc, /* ok to allocate more space */ 76 int okalloc, /* ok to allocate more space */
77 struct xfs_buf **agbp, /* buf for a.g. inode header */ 77 struct xfs_buf **agbp, /* buf for a.g. inode header */
78 boolean_t *alloc_done, /* an allocation was done to replenish
79 the free inodes */
80 xfs_ino_t *inop); /* inode number allocated */ 78 xfs_ino_t *inop); /* inode number allocated */
81 79
82/* 80/*
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index 1bb4365e8c25..784a803383ec 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -41,17 +41,6 @@
41 41
42 42
43/* 43/*
44 * Define xfs inode iolock lockdep classes. We need to ensure that all active
45 * inodes are considered the same for lockdep purposes, including inodes that
46 * are recycled through the XFS_IRECLAIMABLE state. This is the the only way to
47 * guarantee the locks are considered the same when there are multiple lock
48 * initialisation siteѕ. Also, define a reclaimable inode class so it is
49 * obvious in lockdep reports which class the report is against.
50 */
51static struct lock_class_key xfs_iolock_active;
52struct lock_class_key xfs_iolock_reclaimable;
53
54/*
55 * Allocate and initialise an xfs_inode. 44 * Allocate and initialise an xfs_inode.
56 */ 45 */
57STATIC struct xfs_inode * 46STATIC struct xfs_inode *
@@ -80,8 +69,6 @@ xfs_inode_alloc(
80 ASSERT(ip->i_ino == 0); 69 ASSERT(ip->i_ino == 0);
81 70
82 mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino); 71 mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino);
83 lockdep_set_class_and_name(&ip->i_iolock.mr_lock,
84 &xfs_iolock_active, "xfs_iolock_active");
85 72
86 /* initialise the xfs inode */ 73 /* initialise the xfs inode */
87 ip->i_ino = ino; 74 ip->i_ino = ino;
@@ -250,8 +237,6 @@ xfs_iget_cache_hit(
250 237
251 ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock)); 238 ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock));
252 mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino); 239 mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino);
253 lockdep_set_class_and_name(&ip->i_iolock.mr_lock,
254 &xfs_iolock_active, "xfs_iolock_active");
255 240
256 spin_unlock(&ip->i_flags_lock); 241 spin_unlock(&ip->i_flags_lock);
257 spin_unlock(&pag->pag_ici_lock); 242 spin_unlock(&pag->pag_ici_lock);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index a59eea09930a..2778258fcfa2 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -132,23 +132,28 @@ xfs_inobp_check(
132#endif 132#endif
133 133
134/* 134/*
135 * Find the buffer associated with the given inode map 135 * This routine is called to map an inode to the buffer containing the on-disk
136 * We do basic validation checks on the buffer once it has been 136 * version of the inode. It returns a pointer to the buffer containing the
137 * retrieved from disk. 137 * on-disk inode in the bpp parameter, and in the dipp parameter it returns a
138 * pointer to the on-disk inode within that buffer.
139 *
140 * If a non-zero error is returned, then the contents of bpp and dipp are
141 * undefined.
138 */ 142 */
139STATIC int 143int
140xfs_imap_to_bp( 144xfs_imap_to_bp(
141 xfs_mount_t *mp, 145 struct xfs_mount *mp,
142 xfs_trans_t *tp, 146 struct xfs_trans *tp,
143 struct xfs_imap *imap, 147 struct xfs_imap *imap,
144 xfs_buf_t **bpp, 148 struct xfs_dinode **dipp,
145 uint buf_flags, 149 struct xfs_buf **bpp,
146 uint iget_flags) 150 uint buf_flags,
151 uint iget_flags)
147{ 152{
148 int error; 153 struct xfs_buf *bp;
149 int i; 154 int error;
150 int ni; 155 int i;
151 xfs_buf_t *bp; 156 int ni;
152 157
153 buf_flags |= XBF_UNMAPPED; 158 buf_flags |= XBF_UNMAPPED;
154 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno, 159 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno,
@@ -189,8 +194,8 @@ xfs_imap_to_bp(
189 xfs_trans_brelse(tp, bp); 194 xfs_trans_brelse(tp, bp);
190 return XFS_ERROR(EINVAL); 195 return XFS_ERROR(EINVAL);
191 } 196 }
192 XFS_CORRUPTION_ERROR("xfs_imap_to_bp", 197 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_HIGH,
193 XFS_ERRLEVEL_HIGH, mp, dip); 198 mp, dip);
194#ifdef DEBUG 199#ifdef DEBUG
195 xfs_emerg(mp, 200 xfs_emerg(mp,
196 "bad inode magic/vsn daddr %lld #%d (magic=%x)", 201 "bad inode magic/vsn daddr %lld #%d (magic=%x)",
@@ -204,96 +209,9 @@ xfs_imap_to_bp(
204 } 209 }
205 210
206 xfs_inobp_check(mp, bp); 211 xfs_inobp_check(mp, bp);
207 *bpp = bp;
208 return 0;
209}
210
211/*
212 * This routine is called to map an inode number within a file
213 * system to the buffer containing the on-disk version of the
214 * inode. It returns a pointer to the buffer containing the
215 * on-disk inode in the bpp parameter, and in the dip parameter
216 * it returns a pointer to the on-disk inode within that buffer.
217 *
218 * If a non-zero error is returned, then the contents of bpp and
219 * dipp are undefined.
220 *
221 * Use xfs_imap() to determine the size and location of the
222 * buffer to read from disk.
223 */
224int
225xfs_inotobp(
226 xfs_mount_t *mp,
227 xfs_trans_t *tp,
228 xfs_ino_t ino,
229 xfs_dinode_t **dipp,
230 xfs_buf_t **bpp,
231 int *offset,
232 uint imap_flags)
233{
234 struct xfs_imap imap;
235 xfs_buf_t *bp;
236 int error;
237
238 imap.im_blkno = 0;
239 error = xfs_imap(mp, tp, ino, &imap, imap_flags);
240 if (error)
241 return error;
242
243 error = xfs_imap_to_bp(mp, tp, &imap, &bp, 0, imap_flags);
244 if (error)
245 return error;
246
247 *dipp = (xfs_dinode_t *)xfs_buf_offset(bp, imap.im_boffset);
248 *bpp = bp;
249 *offset = imap.im_boffset;
250 return 0;
251}
252
253
254/*
255 * This routine is called to map an inode to the buffer containing
256 * the on-disk version of the inode. It returns a pointer to the
257 * buffer containing the on-disk inode in the bpp parameter, and in
258 * the dip parameter it returns a pointer to the on-disk inode within
259 * that buffer.
260 *
261 * If a non-zero error is returned, then the contents of bpp and
262 * dipp are undefined.
263 *
264 * The inode is expected to already been mapped to its buffer and read
265 * in once, thus we can use the mapping information stored in the inode
266 * rather than calling xfs_imap(). This allows us to avoid the overhead
267 * of looking at the inode btree for small block file systems
268 * (see xfs_imap()).
269 */
270int
271xfs_itobp(
272 xfs_mount_t *mp,
273 xfs_trans_t *tp,
274 xfs_inode_t *ip,
275 xfs_dinode_t **dipp,
276 xfs_buf_t **bpp,
277 uint buf_flags)
278{
279 xfs_buf_t *bp;
280 int error;
281
282 ASSERT(ip->i_imap.im_blkno != 0);
283
284 error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, buf_flags, 0);
285 if (error)
286 return error;
287 212
288 if (!bp) {
289 ASSERT(buf_flags & XBF_TRYLOCK);
290 ASSERT(tp == NULL);
291 *bpp = NULL;
292 return EAGAIN;
293 }
294
295 *dipp = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
296 *bpp = bp; 213 *bpp = bp;
214 *dipp = (struct xfs_dinode *)xfs_buf_offset(bp, imap->im_boffset);
297 return 0; 215 return 0;
298} 216}
299 217
@@ -796,10 +714,9 @@ xfs_iread(
796 /* 714 /*
797 * Get pointers to the on-disk inode and the buffer containing it. 715 * Get pointers to the on-disk inode and the buffer containing it.
798 */ 716 */
799 error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, 0, iget_flags); 717 error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &dip, &bp, 0, iget_flags);
800 if (error) 718 if (error)
801 return error; 719 return error;
802 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
803 720
804 /* 721 /*
805 * If we got something that isn't an inode it means someone 722 * If we got something that isn't an inode it means someone
@@ -876,7 +793,7 @@ xfs_iread(
876 /* 793 /*
877 * Use xfs_trans_brelse() to release the buffer containing the 794 * Use xfs_trans_brelse() to release the buffer containing the
878 * on-disk inode, because it was acquired with xfs_trans_read_buf() 795 * on-disk inode, because it was acquired with xfs_trans_read_buf()
879 * in xfs_itobp() above. If tp is NULL, this is just a normal 796 * in xfs_imap_to_bp() above. If tp is NULL, this is just a normal
880 * brelse(). If we're within a transaction, then xfs_trans_brelse() 797 * brelse(). If we're within a transaction, then xfs_trans_brelse()
881 * will only release the buffer if it is not dirty within the 798 * will only release the buffer if it is not dirty within the
882 * transaction. It will be OK to release the buffer in this case, 799 * transaction. It will be OK to release the buffer in this case,
@@ -970,7 +887,6 @@ xfs_ialloc(
970 prid_t prid, 887 prid_t prid,
971 int okalloc, 888 int okalloc,
972 xfs_buf_t **ialloc_context, 889 xfs_buf_t **ialloc_context,
973 boolean_t *call_again,
974 xfs_inode_t **ipp) 890 xfs_inode_t **ipp)
975{ 891{
976 xfs_ino_t ino; 892 xfs_ino_t ino;
@@ -985,10 +901,10 @@ xfs_ialloc(
985 * the on-disk inode to be allocated. 901 * the on-disk inode to be allocated.
986 */ 902 */
987 error = xfs_dialloc(tp, pip ? pip->i_ino : 0, mode, okalloc, 903 error = xfs_dialloc(tp, pip ? pip->i_ino : 0, mode, okalloc,
988 ialloc_context, call_again, &ino); 904 ialloc_context, &ino);
989 if (error) 905 if (error)
990 return error; 906 return error;
991 if (*call_again || ino == NULLFSINO) { 907 if (*ialloc_context || ino == NULLFSINO) {
992 *ipp = NULL; 908 *ipp = NULL;
993 return 0; 909 return 0;
994 } 910 }
@@ -1207,7 +1123,9 @@ xfs_itruncate_extents(
1207 int error = 0; 1123 int error = 0;
1208 int done = 0; 1124 int done = 0;
1209 1125
1210 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_IOLOCK_EXCL)); 1126 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
1127 ASSERT(!atomic_read(&VFS_I(ip)->i_count) ||
1128 xfs_isilocked(ip, XFS_IOLOCK_EXCL));
1211 ASSERT(new_size <= XFS_ISIZE(ip)); 1129 ASSERT(new_size <= XFS_ISIZE(ip));
1212 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); 1130 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES);
1213 ASSERT(ip->i_itemp != NULL); 1131 ASSERT(ip->i_itemp != NULL);
@@ -1226,7 +1144,7 @@ xfs_itruncate_extents(
1226 * then there is nothing to do. 1144 * then there is nothing to do.
1227 */ 1145 */
1228 first_unmap_block = XFS_B_TO_FSB(mp, (xfs_ufsize_t)new_size); 1146 first_unmap_block = XFS_B_TO_FSB(mp, (xfs_ufsize_t)new_size);
1229 last_block = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp)); 1147 last_block = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);
1230 if (first_unmap_block == last_block) 1148 if (first_unmap_block == last_block)
1231 return 0; 1149 return 0;
1232 1150
@@ -1355,7 +1273,8 @@ xfs_iunlink(
1355 * Here we put the head pointer into our next pointer, 1273 * Here we put the head pointer into our next pointer,
1356 * and then we fall through to point the head at us. 1274 * and then we fall through to point the head at us.
1357 */ 1275 */
1358 error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0); 1276 error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &dip, &ibp,
1277 0, 0);
1359 if (error) 1278 if (error)
1360 return error; 1279 return error;
1361 1280
@@ -1429,16 +1348,16 @@ xfs_iunlink_remove(
1429 1348
1430 if (be32_to_cpu(agi->agi_unlinked[bucket_index]) == agino) { 1349 if (be32_to_cpu(agi->agi_unlinked[bucket_index]) == agino) {
1431 /* 1350 /*
1432 * We're at the head of the list. Get the inode's 1351 * We're at the head of the list. Get the inode's on-disk
1433 * on-disk buffer to see if there is anyone after us 1352 * buffer to see if there is anyone after us on the list.
1434 * on the list. Only modify our next pointer if it 1353 * Only modify our next pointer if it is not already NULLAGINO.
1435 * is not already NULLAGINO. This saves us the overhead 1354 * This saves us the overhead of dealing with the buffer when
1436 * of dealing with the buffer when there is no need to 1355 * there is no need to change it.
1437 * change it.
1438 */ 1356 */
1439 error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0); 1357 error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &dip, &ibp,
1358 0, 0);
1440 if (error) { 1359 if (error) {
1441 xfs_warn(mp, "%s: xfs_itobp() returned error %d.", 1360 xfs_warn(mp, "%s: xfs_imap_to_bp returned error %d.",
1442 __func__, error); 1361 __func__, error);
1443 return error; 1362 return error;
1444 } 1363 }
@@ -1472,34 +1391,45 @@ xfs_iunlink_remove(
1472 next_agino = be32_to_cpu(agi->agi_unlinked[bucket_index]); 1391 next_agino = be32_to_cpu(agi->agi_unlinked[bucket_index]);
1473 last_ibp = NULL; 1392 last_ibp = NULL;
1474 while (next_agino != agino) { 1393 while (next_agino != agino) {
1475 /* 1394 struct xfs_imap imap;
1476 * If the last inode wasn't the one pointing to 1395
1477 * us, then release its buffer since we're not 1396 if (last_ibp)
1478 * going to do anything with it.
1479 */
1480 if (last_ibp != NULL) {
1481 xfs_trans_brelse(tp, last_ibp); 1397 xfs_trans_brelse(tp, last_ibp);
1482 } 1398
1399 imap.im_blkno = 0;
1483 next_ino = XFS_AGINO_TO_INO(mp, agno, next_agino); 1400 next_ino = XFS_AGINO_TO_INO(mp, agno, next_agino);
1484 error = xfs_inotobp(mp, tp, next_ino, &last_dip, 1401
1485 &last_ibp, &last_offset, 0); 1402 error = xfs_imap(mp, tp, next_ino, &imap, 0);
1403 if (error) {
1404 xfs_warn(mp,
1405 "%s: xfs_imap returned error %d.",
1406 __func__, error);
1407 return error;
1408 }
1409
1410 error = xfs_imap_to_bp(mp, tp, &imap, &last_dip,
1411 &last_ibp, 0, 0);
1486 if (error) { 1412 if (error) {
1487 xfs_warn(mp, 1413 xfs_warn(mp,
1488 "%s: xfs_inotobp() returned error %d.", 1414 "%s: xfs_imap_to_bp returned error %d.",
1489 __func__, error); 1415 __func__, error);
1490 return error; 1416 return error;
1491 } 1417 }
1418
1419 last_offset = imap.im_boffset;
1492 next_agino = be32_to_cpu(last_dip->di_next_unlinked); 1420 next_agino = be32_to_cpu(last_dip->di_next_unlinked);
1493 ASSERT(next_agino != NULLAGINO); 1421 ASSERT(next_agino != NULLAGINO);
1494 ASSERT(next_agino != 0); 1422 ASSERT(next_agino != 0);
1495 } 1423 }
1424
1496 /* 1425 /*
1497 * Now last_ibp points to the buffer previous to us on 1426 * Now last_ibp points to the buffer previous to us on the
1498 * the unlinked list. Pull us from the list. 1427 * unlinked list. Pull us from the list.
1499 */ 1428 */
1500 error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0); 1429 error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &dip, &ibp,
1430 0, 0);
1501 if (error) { 1431 if (error) {
1502 xfs_warn(mp, "%s: xfs_itobp(2) returned error %d.", 1432 xfs_warn(mp, "%s: xfs_imap_to_bp(2) returned error %d.",
1503 __func__, error); 1433 __func__, error);
1504 return error; 1434 return error;
1505 } 1435 }
@@ -1749,7 +1679,8 @@ xfs_ifree(
1749 1679
1750 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 1680 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
1751 1681
1752 error = xfs_itobp(ip->i_mount, tp, ip, &dip, &ibp, 0); 1682 error = xfs_imap_to_bp(ip->i_mount, tp, &ip->i_imap, &dip, &ibp,
1683 0, 0);
1753 if (error) 1684 if (error)
1754 return error; 1685 return error;
1755 1686
@@ -2428,7 +2359,7 @@ xfs_iflush(
2428 /* 2359 /*
2429 * For stale inodes we cannot rely on the backing buffer remaining 2360 * For stale inodes we cannot rely on the backing buffer remaining
2430 * stale in cache for the remaining life of the stale inode and so 2361 * stale in cache for the remaining life of the stale inode and so
2431 * xfs_itobp() below may give us a buffer that no longer contains 2362 * xfs_imap_to_bp() below may give us a buffer that no longer contains
2432 * inodes below. We have to check this after ensuring the inode is 2363 * inodes below. We have to check this after ensuring the inode is
2433 * unpinned so that it is safe to reclaim the stale inode after the 2364 * unpinned so that it is safe to reclaim the stale inode after the
2434 * flush call. 2365 * flush call.
@@ -2454,7 +2385,8 @@ xfs_iflush(
2454 /* 2385 /*
2455 * Get the buffer containing the on-disk inode. 2386 * Get the buffer containing the on-disk inode.
2456 */ 2387 */
2457 error = xfs_itobp(mp, NULL, ip, &dip, &bp, XBF_TRYLOCK); 2388 error = xfs_imap_to_bp(mp, NULL, &ip->i_imap, &dip, &bp, XBF_TRYLOCK,
2389 0);
2458 if (error || !bp) { 2390 if (error || !bp) {
2459 xfs_ifunlock(ip); 2391 xfs_ifunlock(ip);
2460 return error; 2392 return error;
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 1efff36a75b6..94b32f906e79 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -487,8 +487,6 @@ static inline int xfs_isiflocked(struct xfs_inode *ip)
487#define XFS_IOLOCK_DEP(flags) (((flags) & XFS_IOLOCK_DEP_MASK) >> XFS_IOLOCK_SHIFT) 487#define XFS_IOLOCK_DEP(flags) (((flags) & XFS_IOLOCK_DEP_MASK) >> XFS_IOLOCK_SHIFT)
488#define XFS_ILOCK_DEP(flags) (((flags) & XFS_ILOCK_DEP_MASK) >> XFS_ILOCK_SHIFT) 488#define XFS_ILOCK_DEP(flags) (((flags) & XFS_ILOCK_DEP_MASK) >> XFS_ILOCK_SHIFT)
489 489
490extern struct lock_class_key xfs_iolock_reclaimable;
491
492/* 490/*
493 * For multiple groups support: if S_ISGID bit is set in the parent 491 * For multiple groups support: if S_ISGID bit is set in the parent
494 * directory, group of new file is set to that of the parent, and 492 * directory, group of new file is set to that of the parent, and
@@ -517,7 +515,7 @@ void xfs_inode_free(struct xfs_inode *ip);
517 */ 515 */
518int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, umode_t, 516int xfs_ialloc(struct xfs_trans *, xfs_inode_t *, umode_t,
519 xfs_nlink_t, xfs_dev_t, prid_t, int, 517 xfs_nlink_t, xfs_dev_t, prid_t, int,
520 struct xfs_buf **, boolean_t *, xfs_inode_t **); 518 struct xfs_buf **, xfs_inode_t **);
521 519
522uint xfs_ip2xflags(struct xfs_inode *); 520uint xfs_ip2xflags(struct xfs_inode *);
523uint xfs_dic2xflags(struct xfs_dinode *); 521uint xfs_dic2xflags(struct xfs_dinode *);
@@ -557,12 +555,9 @@ do { \
557#define XFS_IGET_UNTRUSTED 0x2 555#define XFS_IGET_UNTRUSTED 0x2
558#define XFS_IGET_DONTCACHE 0x4 556#define XFS_IGET_DONTCACHE 0x4
559 557
560int xfs_inotobp(struct xfs_mount *, struct xfs_trans *, 558int xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *,
561 xfs_ino_t, struct xfs_dinode **, 559 struct xfs_imap *, struct xfs_dinode **,
562 struct xfs_buf **, int *, uint); 560 struct xfs_buf **, uint, uint);
563int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
564 struct xfs_inode *, struct xfs_dinode **,
565 struct xfs_buf **, uint);
566int xfs_iread(struct xfs_mount *, struct xfs_trans *, 561int xfs_iread(struct xfs_mount *, struct xfs_trans *,
567 struct xfs_inode *, uint); 562 struct xfs_inode *, uint);
568void xfs_dinode_to_disk(struct xfs_dinode *, 563void xfs_dinode_to_disk(struct xfs_dinode *,
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index aadfce6681ee..915edf6639f0 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -285,7 +285,7 @@ xfs_iomap_eof_want_preallocate(
285 * do any speculative allocation. 285 * do any speculative allocation.
286 */ 286 */
287 start_fsb = XFS_B_TO_FSBT(mp, ((xfs_ufsize_t)(offset + count - 1))); 287 start_fsb = XFS_B_TO_FSBT(mp, ((xfs_ufsize_t)(offset + count - 1)));
288 count_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp)); 288 count_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);
289 while (count_fsb > 0) { 289 while (count_fsb > 0) {
290 imaps = nimaps; 290 imaps = nimaps;
291 firstblock = NULLFSBLOCK; 291 firstblock = NULLFSBLOCK;
@@ -416,8 +416,8 @@ retry:
416 * Make sure preallocation does not create extents beyond the range we 416 * Make sure preallocation does not create extents beyond the range we
417 * actually support in this filesystem. 417 * actually support in this filesystem.
418 */ 418 */
419 if (last_fsb > XFS_B_TO_FSB(mp, mp->m_maxioffset)) 419 if (last_fsb > XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes))
420 last_fsb = XFS_B_TO_FSB(mp, mp->m_maxioffset); 420 last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);
421 421
422 ASSERT(last_fsb > offset_fsb); 422 ASSERT(last_fsb > offset_fsb);
423 423
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 9c4340f5c3e0..4e00cf091d2c 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -897,6 +897,47 @@ xfs_vn_setattr(
897 return -xfs_setattr_nonsize(XFS_I(dentry->d_inode), iattr, 0); 897 return -xfs_setattr_nonsize(XFS_I(dentry->d_inode), iattr, 0);
898} 898}
899 899
900STATIC int
901xfs_vn_update_time(
902 struct inode *inode,
903 struct timespec *now,
904 int flags)
905{
906 struct xfs_inode *ip = XFS_I(inode);
907 struct xfs_mount *mp = ip->i_mount;
908 struct xfs_trans *tp;
909 int error;
910
911 trace_xfs_update_time(ip);
912
913 tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS);
914 error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0);
915 if (error) {
916 xfs_trans_cancel(tp, 0);
917 return -error;
918 }
919
920 xfs_ilock(ip, XFS_ILOCK_EXCL);
921 if (flags & S_CTIME) {
922 inode->i_ctime = *now;
923 ip->i_d.di_ctime.t_sec = (__int32_t)now->tv_sec;
924 ip->i_d.di_ctime.t_nsec = (__int32_t)now->tv_nsec;
925 }
926 if (flags & S_MTIME) {
927 inode->i_mtime = *now;
928 ip->i_d.di_mtime.t_sec = (__int32_t)now->tv_sec;
929 ip->i_d.di_mtime.t_nsec = (__int32_t)now->tv_nsec;
930 }
931 if (flags & S_ATIME) {
932 inode->i_atime = *now;
933 ip->i_d.di_atime.t_sec = (__int32_t)now->tv_sec;
934 ip->i_d.di_atime.t_nsec = (__int32_t)now->tv_nsec;
935 }
936 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
937 xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP);
938 return -xfs_trans_commit(tp, 0);
939}
940
900#define XFS_FIEMAP_FLAGS (FIEMAP_FLAG_SYNC|FIEMAP_FLAG_XATTR) 941#define XFS_FIEMAP_FLAGS (FIEMAP_FLAG_SYNC|FIEMAP_FLAG_XATTR)
901 942
902/* 943/*
@@ -991,6 +1032,7 @@ static const struct inode_operations xfs_inode_operations = {
991 .removexattr = generic_removexattr, 1032 .removexattr = generic_removexattr,
992 .listxattr = xfs_vn_listxattr, 1033 .listxattr = xfs_vn_listxattr,
993 .fiemap = xfs_vn_fiemap, 1034 .fiemap = xfs_vn_fiemap,
1035 .update_time = xfs_vn_update_time,
994}; 1036};
995 1037
996static const struct inode_operations xfs_dir_inode_operations = { 1038static const struct inode_operations xfs_dir_inode_operations = {
@@ -1016,6 +1058,7 @@ static const struct inode_operations xfs_dir_inode_operations = {
1016 .getxattr = generic_getxattr, 1058 .getxattr = generic_getxattr,
1017 .removexattr = generic_removexattr, 1059 .removexattr = generic_removexattr,
1018 .listxattr = xfs_vn_listxattr, 1060 .listxattr = xfs_vn_listxattr,
1061 .update_time = xfs_vn_update_time,
1019}; 1062};
1020 1063
1021static const struct inode_operations xfs_dir_ci_inode_operations = { 1064static const struct inode_operations xfs_dir_ci_inode_operations = {
@@ -1041,6 +1084,7 @@ static const struct inode_operations xfs_dir_ci_inode_operations = {
1041 .getxattr = generic_getxattr, 1084 .getxattr = generic_getxattr,
1042 .removexattr = generic_removexattr, 1085 .removexattr = generic_removexattr,
1043 .listxattr = xfs_vn_listxattr, 1086 .listxattr = xfs_vn_listxattr,
1087 .update_time = xfs_vn_update_time,
1044}; 1088};
1045 1089
1046static const struct inode_operations xfs_symlink_inode_operations = { 1090static const struct inode_operations xfs_symlink_inode_operations = {
@@ -1054,6 +1098,7 @@ static const struct inode_operations xfs_symlink_inode_operations = {
1054 .getxattr = generic_getxattr, 1098 .getxattr = generic_getxattr,
1055 .removexattr = generic_removexattr, 1099 .removexattr = generic_removexattr,
1056 .listxattr = xfs_vn_listxattr, 1100 .listxattr = xfs_vn_listxattr,
1101 .update_time = xfs_vn_update_time,
1057}; 1102};
1058 1103
1059STATIC void 1104STATIC void
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index eff577a9b67f..01d10a66e302 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -555,7 +555,7 @@ xfs_bulkstat_single(
555 555
556 /* 556 /*
557 * note that requesting valid inode numbers which are not allocated 557 * note that requesting valid inode numbers which are not allocated
558 * to inodes will most likely cause xfs_itobp to generate warning 558 * to inodes will most likely cause xfs_imap_to_bp to generate warning
559 * messages about bad magic numbers. This is ok. The fact that 559 * messages about bad magic numbers. This is ok. The fact that
560 * the inode isn't actually an inode is handled by the 560 * the inode isn't actually an inode is handled by the
561 * error check below. Done this way to make the usual case faster 561 * error check below. Done this way to make the usual case faster
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index d90d4a388609..7f4f9370d0e7 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -45,51 +45,85 @@ xlog_commit_record(
45 struct xlog_in_core **iclog, 45 struct xlog_in_core **iclog,
46 xfs_lsn_t *commitlsnp); 46 xfs_lsn_t *commitlsnp);
47 47
48STATIC xlog_t * xlog_alloc_log(xfs_mount_t *mp, 48STATIC struct xlog *
49 xfs_buftarg_t *log_target, 49xlog_alloc_log(
50 xfs_daddr_t blk_offset, 50 struct xfs_mount *mp,
51 int num_bblks); 51 struct xfs_buftarg *log_target,
52 xfs_daddr_t blk_offset,
53 int num_bblks);
52STATIC int 54STATIC int
53xlog_space_left( 55xlog_space_left(
54 struct xlog *log, 56 struct xlog *log,
55 atomic64_t *head); 57 atomic64_t *head);
56STATIC int xlog_sync(xlog_t *log, xlog_in_core_t *iclog); 58STATIC int
57STATIC void xlog_dealloc_log(xlog_t *log); 59xlog_sync(
60 struct xlog *log,
61 struct xlog_in_core *iclog);
62STATIC void
63xlog_dealloc_log(
64 struct xlog *log);
58 65
59/* local state machine functions */ 66/* local state machine functions */
60STATIC void xlog_state_done_syncing(xlog_in_core_t *iclog, int); 67STATIC void xlog_state_done_syncing(xlog_in_core_t *iclog, int);
61STATIC void xlog_state_do_callback(xlog_t *log,int aborted, xlog_in_core_t *iclog); 68STATIC void
62STATIC int xlog_state_get_iclog_space(xlog_t *log, 69xlog_state_do_callback(
63 int len, 70 struct xlog *log,
64 xlog_in_core_t **iclog, 71 int aborted,
65 xlog_ticket_t *ticket, 72 struct xlog_in_core *iclog);
66 int *continued_write, 73STATIC int
67 int *logoffsetp); 74xlog_state_get_iclog_space(
68STATIC int xlog_state_release_iclog(xlog_t *log, 75 struct xlog *log,
69 xlog_in_core_t *iclog); 76 int len,
70STATIC void xlog_state_switch_iclogs(xlog_t *log, 77 struct xlog_in_core **iclog,
71 xlog_in_core_t *iclog, 78 struct xlog_ticket *ticket,
72 int eventual_size); 79 int *continued_write,
73STATIC void xlog_state_want_sync(xlog_t *log, xlog_in_core_t *iclog); 80 int *logoffsetp);
81STATIC int
82xlog_state_release_iclog(
83 struct xlog *log,
84 struct xlog_in_core *iclog);
85STATIC void
86xlog_state_switch_iclogs(
87 struct xlog *log,
88 struct xlog_in_core *iclog,
89 int eventual_size);
90STATIC void
91xlog_state_want_sync(
92 struct xlog *log,
93 struct xlog_in_core *iclog);
74 94
75STATIC void 95STATIC void
76xlog_grant_push_ail( 96xlog_grant_push_ail(
77 struct xlog *log, 97 struct xlog *log,
78 int need_bytes); 98 int need_bytes);
79STATIC void xlog_regrant_reserve_log_space(xlog_t *log, 99STATIC void
80 xlog_ticket_t *ticket); 100xlog_regrant_reserve_log_space(
81STATIC void xlog_ungrant_log_space(xlog_t *log, 101 struct xlog *log,
82 xlog_ticket_t *ticket); 102 struct xlog_ticket *ticket);
103STATIC void
104xlog_ungrant_log_space(
105 struct xlog *log,
106 struct xlog_ticket *ticket);
83 107
84#if defined(DEBUG) 108#if defined(DEBUG)
85STATIC void xlog_verify_dest_ptr(xlog_t *log, char *ptr); 109STATIC void
110xlog_verify_dest_ptr(
111 struct xlog *log,
112 char *ptr);
86STATIC void 113STATIC void
87xlog_verify_grant_tail( 114xlog_verify_grant_tail(
88 struct xlog *log); 115 struct xlog *log);
89STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog, 116STATIC void
90 int count, boolean_t syncing); 117xlog_verify_iclog(
91STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog, 118 struct xlog *log,
92 xfs_lsn_t tail_lsn); 119 struct xlog_in_core *iclog,
120 int count,
121 boolean_t syncing);
122STATIC void
123xlog_verify_tail_lsn(
124 struct xlog *log,
125 struct xlog_in_core *iclog,
126 xfs_lsn_t tail_lsn);
93#else 127#else
94#define xlog_verify_dest_ptr(a,b) 128#define xlog_verify_dest_ptr(a,b)
95#define xlog_verify_grant_tail(a) 129#define xlog_verify_grant_tail(a)
@@ -97,7 +131,9 @@ STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog,
97#define xlog_verify_tail_lsn(a,b,c) 131#define xlog_verify_tail_lsn(a,b,c)
98#endif 132#endif
99 133
100STATIC int xlog_iclogs_empty(xlog_t *log); 134STATIC int
135xlog_iclogs_empty(
136 struct xlog *log);
101 137
102static void 138static void
103xlog_grant_sub_space( 139xlog_grant_sub_space(
@@ -684,7 +720,7 @@ xfs_log_mount_finish(xfs_mount_t *mp)
684int 720int
685xfs_log_unmount_write(xfs_mount_t *mp) 721xfs_log_unmount_write(xfs_mount_t *mp)
686{ 722{
687 xlog_t *log = mp->m_log; 723 struct xlog *log = mp->m_log;
688 xlog_in_core_t *iclog; 724 xlog_in_core_t *iclog;
689#ifdef DEBUG 725#ifdef DEBUG
690 xlog_in_core_t *first_iclog; 726 xlog_in_core_t *first_iclog;
@@ -893,7 +929,7 @@ int
893xfs_log_need_covered(xfs_mount_t *mp) 929xfs_log_need_covered(xfs_mount_t *mp)
894{ 930{
895 int needed = 0; 931 int needed = 0;
896 xlog_t *log = mp->m_log; 932 struct xlog *log = mp->m_log;
897 933
898 if (!xfs_fs_writable(mp)) 934 if (!xfs_fs_writable(mp))
899 return 0; 935 return 0;
@@ -1024,9 +1060,9 @@ xlog_space_left(
1024void 1060void
1025xlog_iodone(xfs_buf_t *bp) 1061xlog_iodone(xfs_buf_t *bp)
1026{ 1062{
1027 xlog_in_core_t *iclog = bp->b_fspriv; 1063 struct xlog_in_core *iclog = bp->b_fspriv;
1028 xlog_t *l = iclog->ic_log; 1064 struct xlog *l = iclog->ic_log;
1029 int aborted = 0; 1065 int aborted = 0;
1030 1066
1031 /* 1067 /*
1032 * Race to shutdown the filesystem if we see an error. 1068 * Race to shutdown the filesystem if we see an error.
@@ -1067,8 +1103,9 @@ xlog_iodone(xfs_buf_t *bp)
1067 */ 1103 */
1068 1104
1069STATIC void 1105STATIC void
1070xlog_get_iclog_buffer_size(xfs_mount_t *mp, 1106xlog_get_iclog_buffer_size(
1071 xlog_t *log) 1107 struct xfs_mount *mp,
1108 struct xlog *log)
1072{ 1109{
1073 int size; 1110 int size;
1074 int xhdrs; 1111 int xhdrs;
@@ -1129,13 +1166,14 @@ done:
1129 * Its primary purpose is to fill in enough, so recovery can occur. However, 1166 * Its primary purpose is to fill in enough, so recovery can occur. However,
1130 * some other stuff may be filled in too. 1167 * some other stuff may be filled in too.
1131 */ 1168 */
1132STATIC xlog_t * 1169STATIC struct xlog *
1133xlog_alloc_log(xfs_mount_t *mp, 1170xlog_alloc_log(
1134 xfs_buftarg_t *log_target, 1171 struct xfs_mount *mp,
1135 xfs_daddr_t blk_offset, 1172 struct xfs_buftarg *log_target,
1136 int num_bblks) 1173 xfs_daddr_t blk_offset,
1174 int num_bblks)
1137{ 1175{
1138 xlog_t *log; 1176 struct xlog *log;
1139 xlog_rec_header_t *head; 1177 xlog_rec_header_t *head;
1140 xlog_in_core_t **iclogp; 1178 xlog_in_core_t **iclogp;
1141 xlog_in_core_t *iclog, *prev_iclog=NULL; 1179 xlog_in_core_t *iclog, *prev_iclog=NULL;
@@ -1144,7 +1182,7 @@ xlog_alloc_log(xfs_mount_t *mp,
1144 int error = ENOMEM; 1182 int error = ENOMEM;
1145 uint log2_size = 0; 1183 uint log2_size = 0;
1146 1184
1147 log = kmem_zalloc(sizeof(xlog_t), KM_MAYFAIL); 1185 log = kmem_zalloc(sizeof(struct xlog), KM_MAYFAIL);
1148 if (!log) { 1186 if (!log) {
1149 xfs_warn(mp, "Log allocation failed: No memory!"); 1187 xfs_warn(mp, "Log allocation failed: No memory!");
1150 goto out; 1188 goto out;
@@ -1434,8 +1472,9 @@ xlog_bdstrat(
1434 */ 1472 */
1435 1473
1436STATIC int 1474STATIC int
1437xlog_sync(xlog_t *log, 1475xlog_sync(
1438 xlog_in_core_t *iclog) 1476 struct xlog *log,
1477 struct xlog_in_core *iclog)
1439{ 1478{
1440 xfs_caddr_t dptr; /* pointer to byte sized element */ 1479 xfs_caddr_t dptr; /* pointer to byte sized element */
1441 xfs_buf_t *bp; 1480 xfs_buf_t *bp;
@@ -1584,7 +1623,8 @@ xlog_sync(xlog_t *log,
1584 * Deallocate a log structure 1623 * Deallocate a log structure
1585 */ 1624 */
1586STATIC void 1625STATIC void
1587xlog_dealloc_log(xlog_t *log) 1626xlog_dealloc_log(
1627 struct xlog *log)
1588{ 1628{
1589 xlog_in_core_t *iclog, *next_iclog; 1629 xlog_in_core_t *iclog, *next_iclog;
1590 int i; 1630 int i;
@@ -1616,10 +1656,11 @@ xlog_dealloc_log(xlog_t *log)
1616 */ 1656 */
1617/* ARGSUSED */ 1657/* ARGSUSED */
1618static inline void 1658static inline void
1619xlog_state_finish_copy(xlog_t *log, 1659xlog_state_finish_copy(
1620 xlog_in_core_t *iclog, 1660 struct xlog *log,
1621 int record_cnt, 1661 struct xlog_in_core *iclog,
1622 int copy_bytes) 1662 int record_cnt,
1663 int copy_bytes)
1623{ 1664{
1624 spin_lock(&log->l_icloglock); 1665 spin_lock(&log->l_icloglock);
1625 1666
@@ -2142,7 +2183,8 @@ xlog_write(
2142 * State Change: DIRTY -> ACTIVE 2183 * State Change: DIRTY -> ACTIVE
2143 */ 2184 */
2144STATIC void 2185STATIC void
2145xlog_state_clean_log(xlog_t *log) 2186xlog_state_clean_log(
2187 struct xlog *log)
2146{ 2188{
2147 xlog_in_core_t *iclog; 2189 xlog_in_core_t *iclog;
2148 int changed = 0; 2190 int changed = 0;
@@ -2222,7 +2264,7 @@ xlog_state_clean_log(xlog_t *log)
2222 2264
2223STATIC xfs_lsn_t 2265STATIC xfs_lsn_t
2224xlog_get_lowest_lsn( 2266xlog_get_lowest_lsn(
2225 xlog_t *log) 2267 struct xlog *log)
2226{ 2268{
2227 xlog_in_core_t *lsn_log; 2269 xlog_in_core_t *lsn_log;
2228 xfs_lsn_t lowest_lsn, lsn; 2270 xfs_lsn_t lowest_lsn, lsn;
@@ -2245,9 +2287,9 @@ xlog_get_lowest_lsn(
2245 2287
2246STATIC void 2288STATIC void
2247xlog_state_do_callback( 2289xlog_state_do_callback(
2248 xlog_t *log, 2290 struct xlog *log,
2249 int aborted, 2291 int aborted,
2250 xlog_in_core_t *ciclog) 2292 struct xlog_in_core *ciclog)
2251{ 2293{
2252 xlog_in_core_t *iclog; 2294 xlog_in_core_t *iclog;
2253 xlog_in_core_t *first_iclog; /* used to know when we've 2295 xlog_in_core_t *first_iclog; /* used to know when we've
@@ -2467,7 +2509,7 @@ xlog_state_done_syncing(
2467 xlog_in_core_t *iclog, 2509 xlog_in_core_t *iclog,
2468 int aborted) 2510 int aborted)
2469{ 2511{
2470 xlog_t *log = iclog->ic_log; 2512 struct xlog *log = iclog->ic_log;
2471 2513
2472 spin_lock(&log->l_icloglock); 2514 spin_lock(&log->l_icloglock);
2473 2515
@@ -2521,12 +2563,13 @@ xlog_state_done_syncing(
2521 * is copied. 2563 * is copied.
2522 */ 2564 */
2523STATIC int 2565STATIC int
2524xlog_state_get_iclog_space(xlog_t *log, 2566xlog_state_get_iclog_space(
2525 int len, 2567 struct xlog *log,
2526 xlog_in_core_t **iclogp, 2568 int len,
2527 xlog_ticket_t *ticket, 2569 struct xlog_in_core **iclogp,
2528 int *continued_write, 2570 struct xlog_ticket *ticket,
2529 int *logoffsetp) 2571 int *continued_write,
2572 int *logoffsetp)
2530{ 2573{
2531 int log_offset; 2574 int log_offset;
2532 xlog_rec_header_t *head; 2575 xlog_rec_header_t *head;
@@ -2631,8 +2674,9 @@ restart:
2631 * move grant reservation head forward. 2674 * move grant reservation head forward.
2632 */ 2675 */
2633STATIC void 2676STATIC void
2634xlog_regrant_reserve_log_space(xlog_t *log, 2677xlog_regrant_reserve_log_space(
2635 xlog_ticket_t *ticket) 2678 struct xlog *log,
2679 struct xlog_ticket *ticket)
2636{ 2680{
2637 trace_xfs_log_regrant_reserve_enter(log, ticket); 2681 trace_xfs_log_regrant_reserve_enter(log, ticket);
2638 2682
@@ -2677,8 +2721,9 @@ xlog_regrant_reserve_log_space(xlog_t *log,
2677 * in the current reservation field. 2721 * in the current reservation field.
2678 */ 2722 */
2679STATIC void 2723STATIC void
2680xlog_ungrant_log_space(xlog_t *log, 2724xlog_ungrant_log_space(
2681 xlog_ticket_t *ticket) 2725 struct xlog *log,
2726 struct xlog_ticket *ticket)
2682{ 2727{
2683 int bytes; 2728 int bytes;
2684 2729
@@ -2717,8 +2762,8 @@ xlog_ungrant_log_space(xlog_t *log,
2717 */ 2762 */
2718STATIC int 2763STATIC int
2719xlog_state_release_iclog( 2764xlog_state_release_iclog(
2720 xlog_t *log, 2765 struct xlog *log,
2721 xlog_in_core_t *iclog) 2766 struct xlog_in_core *iclog)
2722{ 2767{
2723 int sync = 0; /* do we sync? */ 2768 int sync = 0; /* do we sync? */
2724 2769
@@ -2768,9 +2813,10 @@ xlog_state_release_iclog(
2768 * that every data block. We have run out of space in this log record. 2813 * that every data block. We have run out of space in this log record.
2769 */ 2814 */
2770STATIC void 2815STATIC void
2771xlog_state_switch_iclogs(xlog_t *log, 2816xlog_state_switch_iclogs(
2772 xlog_in_core_t *iclog, 2817 struct xlog *log,
2773 int eventual_size) 2818 struct xlog_in_core *iclog,
2819 int eventual_size)
2774{ 2820{
2775 ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE); 2821 ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE);
2776 if (!eventual_size) 2822 if (!eventual_size)
@@ -3114,7 +3160,9 @@ xfs_log_force_lsn(
3114 * disk. 3160 * disk.
3115 */ 3161 */
3116STATIC void 3162STATIC void
3117xlog_state_want_sync(xlog_t *log, xlog_in_core_t *iclog) 3163xlog_state_want_sync(
3164 struct xlog *log,
3165 struct xlog_in_core *iclog)
3118{ 3166{
3119 assert_spin_locked(&log->l_icloglock); 3167 assert_spin_locked(&log->l_icloglock);
3120 3168
@@ -3158,7 +3206,7 @@ xfs_log_ticket_get(
3158/* 3206/*
3159 * Allocate and initialise a new log ticket. 3207 * Allocate and initialise a new log ticket.
3160 */ 3208 */
3161xlog_ticket_t * 3209struct xlog_ticket *
3162xlog_ticket_alloc( 3210xlog_ticket_alloc(
3163 struct xlog *log, 3211 struct xlog *log,
3164 int unit_bytes, 3212 int unit_bytes,
@@ -3346,9 +3394,10 @@ xlog_verify_grant_tail(
3346 3394
3347/* check if it will fit */ 3395/* check if it will fit */
3348STATIC void 3396STATIC void
3349xlog_verify_tail_lsn(xlog_t *log, 3397xlog_verify_tail_lsn(
3350 xlog_in_core_t *iclog, 3398 struct xlog *log,
3351 xfs_lsn_t tail_lsn) 3399 struct xlog_in_core *iclog,
3400 xfs_lsn_t tail_lsn)
3352{ 3401{
3353 int blocks; 3402 int blocks;
3354 3403
@@ -3385,10 +3434,11 @@ xlog_verify_tail_lsn(xlog_t *log,
3385 * the cycle numbers agree with the current cycle number. 3434 * the cycle numbers agree with the current cycle number.
3386 */ 3435 */
3387STATIC void 3436STATIC void
3388xlog_verify_iclog(xlog_t *log, 3437xlog_verify_iclog(
3389 xlog_in_core_t *iclog, 3438 struct xlog *log,
3390 int count, 3439 struct xlog_in_core *iclog,
3391 boolean_t syncing) 3440 int count,
3441 boolean_t syncing)
3392{ 3442{
3393 xlog_op_header_t *ophead; 3443 xlog_op_header_t *ophead;
3394 xlog_in_core_t *icptr; 3444 xlog_in_core_t *icptr;
@@ -3482,7 +3532,7 @@ xlog_verify_iclog(xlog_t *log,
3482 */ 3532 */
3483STATIC int 3533STATIC int
3484xlog_state_ioerror( 3534xlog_state_ioerror(
3485 xlog_t *log) 3535 struct xlog *log)
3486{ 3536{
3487 xlog_in_core_t *iclog, *ic; 3537 xlog_in_core_t *iclog, *ic;
3488 3538
@@ -3527,7 +3577,7 @@ xfs_log_force_umount(
3527 struct xfs_mount *mp, 3577 struct xfs_mount *mp,
3528 int logerror) 3578 int logerror)
3529{ 3579{
3530 xlog_t *log; 3580 struct xlog *log;
3531 int retval; 3581 int retval;
3532 3582
3533 log = mp->m_log; 3583 log = mp->m_log;
@@ -3634,7 +3684,8 @@ xfs_log_force_umount(
3634} 3684}
3635 3685
3636STATIC int 3686STATIC int
3637xlog_iclogs_empty(xlog_t *log) 3687xlog_iclogs_empty(
3688 struct xlog *log)
3638{ 3689{
3639 xlog_in_core_t *iclog; 3690 xlog_in_core_t *iclog;
3640 3691
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
index 72eba2201b14..18a801d76a42 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -487,7 +487,7 @@ struct xlog_grant_head {
487 * overflow 31 bits worth of byte offset, so using a byte number will mean 487 * overflow 31 bits worth of byte offset, so using a byte number will mean
488 * that round off problems won't occur when releasing partial reservations. 488 * that round off problems won't occur when releasing partial reservations.
489 */ 489 */
490typedef struct xlog { 490struct xlog {
491 /* The following fields don't need locking */ 491 /* The following fields don't need locking */
492 struct xfs_mount *l_mp; /* mount point */ 492 struct xfs_mount *l_mp; /* mount point */
493 struct xfs_ail *l_ailp; /* AIL log is working with */ 493 struct xfs_ail *l_ailp; /* AIL log is working with */
@@ -540,7 +540,7 @@ typedef struct xlog {
540 char *l_iclog_bak[XLOG_MAX_ICLOGS]; 540 char *l_iclog_bak[XLOG_MAX_ICLOGS];
541#endif 541#endif
542 542
543} xlog_t; 543};
544 544
545#define XLOG_BUF_CANCEL_BUCKET(log, blkno) \ 545#define XLOG_BUF_CANCEL_BUCKET(log, blkno) \
546 ((log)->l_buf_cancel_table + ((__uint64_t)blkno % XLOG_BC_TABLE_SIZE)) 546 ((log)->l_buf_cancel_table + ((__uint64_t)blkno % XLOG_BC_TABLE_SIZE))
@@ -548,9 +548,17 @@ typedef struct xlog {
548#define XLOG_FORCED_SHUTDOWN(log) ((log)->l_flags & XLOG_IO_ERROR) 548#define XLOG_FORCED_SHUTDOWN(log) ((log)->l_flags & XLOG_IO_ERROR)
549 549
550/* common routines */ 550/* common routines */
551extern int xlog_recover(xlog_t *log); 551extern int
552extern int xlog_recover_finish(xlog_t *log); 552xlog_recover(
553extern void xlog_pack_data(xlog_t *log, xlog_in_core_t *iclog, int); 553 struct xlog *log);
554extern int
555xlog_recover_finish(
556 struct xlog *log);
557extern void
558xlog_pack_data(
559 struct xlog *log,
560 struct xlog_in_core *iclog,
561 int);
554 562
555extern kmem_zone_t *xfs_log_ticket_zone; 563extern kmem_zone_t *xfs_log_ticket_zone;
556struct xlog_ticket * 564struct xlog_ticket *
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index a7be98abd6a9..5da3ace352bf 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -43,10 +43,18 @@
43#include "xfs_utils.h" 43#include "xfs_utils.h"
44#include "xfs_trace.h" 44#include "xfs_trace.h"
45 45
46STATIC int xlog_find_zeroed(xlog_t *, xfs_daddr_t *); 46STATIC int
47STATIC int xlog_clear_stale_blocks(xlog_t *, xfs_lsn_t); 47xlog_find_zeroed(
48 struct xlog *,
49 xfs_daddr_t *);
50STATIC int
51xlog_clear_stale_blocks(
52 struct xlog *,
53 xfs_lsn_t);
48#if defined(DEBUG) 54#if defined(DEBUG)
49STATIC void xlog_recover_check_summary(xlog_t *); 55STATIC void
56xlog_recover_check_summary(
57 struct xlog *);
50#else 58#else
51#define xlog_recover_check_summary(log) 59#define xlog_recover_check_summary(log)
52#endif 60#endif
@@ -74,7 +82,7 @@ struct xfs_buf_cancel {
74 82
75static inline int 83static inline int
76xlog_buf_bbcount_valid( 84xlog_buf_bbcount_valid(
77 xlog_t *log, 85 struct xlog *log,
78 int bbcount) 86 int bbcount)
79{ 87{
80 return bbcount > 0 && bbcount <= log->l_logBBsize; 88 return bbcount > 0 && bbcount <= log->l_logBBsize;
@@ -87,7 +95,7 @@ xlog_buf_bbcount_valid(
87 */ 95 */
88STATIC xfs_buf_t * 96STATIC xfs_buf_t *
89xlog_get_bp( 97xlog_get_bp(
90 xlog_t *log, 98 struct xlog *log,
91 int nbblks) 99 int nbblks)
92{ 100{
93 struct xfs_buf *bp; 101 struct xfs_buf *bp;
@@ -138,10 +146,10 @@ xlog_put_bp(
138 */ 146 */
139STATIC xfs_caddr_t 147STATIC xfs_caddr_t
140xlog_align( 148xlog_align(
141 xlog_t *log, 149 struct xlog *log,
142 xfs_daddr_t blk_no, 150 xfs_daddr_t blk_no,
143 int nbblks, 151 int nbblks,
144 xfs_buf_t *bp) 152 struct xfs_buf *bp)
145{ 153{
146 xfs_daddr_t offset = blk_no & ((xfs_daddr_t)log->l_sectBBsize - 1); 154 xfs_daddr_t offset = blk_no & ((xfs_daddr_t)log->l_sectBBsize - 1);
147 155
@@ -155,10 +163,10 @@ xlog_align(
155 */ 163 */
156STATIC int 164STATIC int
157xlog_bread_noalign( 165xlog_bread_noalign(
158 xlog_t *log, 166 struct xlog *log,
159 xfs_daddr_t blk_no, 167 xfs_daddr_t blk_no,
160 int nbblks, 168 int nbblks,
161 xfs_buf_t *bp) 169 struct xfs_buf *bp)
162{ 170{
163 int error; 171 int error;
164 172
@@ -189,10 +197,10 @@ xlog_bread_noalign(
189 197
190STATIC int 198STATIC int
191xlog_bread( 199xlog_bread(
192 xlog_t *log, 200 struct xlog *log,
193 xfs_daddr_t blk_no, 201 xfs_daddr_t blk_no,
194 int nbblks, 202 int nbblks,
195 xfs_buf_t *bp, 203 struct xfs_buf *bp,
196 xfs_caddr_t *offset) 204 xfs_caddr_t *offset)
197{ 205{
198 int error; 206 int error;
@@ -211,10 +219,10 @@ xlog_bread(
211 */ 219 */
212STATIC int 220STATIC int
213xlog_bread_offset( 221xlog_bread_offset(
214 xlog_t *log, 222 struct xlog *log,
215 xfs_daddr_t blk_no, /* block to read from */ 223 xfs_daddr_t blk_no, /* block to read from */
216 int nbblks, /* blocks to read */ 224 int nbblks, /* blocks to read */
217 xfs_buf_t *bp, 225 struct xfs_buf *bp,
218 xfs_caddr_t offset) 226 xfs_caddr_t offset)
219{ 227{
220 xfs_caddr_t orig_offset = bp->b_addr; 228 xfs_caddr_t orig_offset = bp->b_addr;
@@ -241,10 +249,10 @@ xlog_bread_offset(
241 */ 249 */
242STATIC int 250STATIC int
243xlog_bwrite( 251xlog_bwrite(
244 xlog_t *log, 252 struct xlog *log,
245 xfs_daddr_t blk_no, 253 xfs_daddr_t blk_no,
246 int nbblks, 254 int nbblks,
247 xfs_buf_t *bp) 255 struct xfs_buf *bp)
248{ 256{
249 int error; 257 int error;
250 258
@@ -378,8 +386,8 @@ xlog_recover_iodone(
378 */ 386 */
379STATIC int 387STATIC int
380xlog_find_cycle_start( 388xlog_find_cycle_start(
381 xlog_t *log, 389 struct xlog *log,
382 xfs_buf_t *bp, 390 struct xfs_buf *bp,
383 xfs_daddr_t first_blk, 391 xfs_daddr_t first_blk,
384 xfs_daddr_t *last_blk, 392 xfs_daddr_t *last_blk,
385 uint cycle) 393 uint cycle)
@@ -421,7 +429,7 @@ xlog_find_cycle_start(
421 */ 429 */
422STATIC int 430STATIC int
423xlog_find_verify_cycle( 431xlog_find_verify_cycle(
424 xlog_t *log, 432 struct xlog *log,
425 xfs_daddr_t start_blk, 433 xfs_daddr_t start_blk,
426 int nbblks, 434 int nbblks,
427 uint stop_on_cycle_no, 435 uint stop_on_cycle_no,
@@ -490,7 +498,7 @@ out:
490 */ 498 */
491STATIC int 499STATIC int
492xlog_find_verify_log_record( 500xlog_find_verify_log_record(
493 xlog_t *log, 501 struct xlog *log,
494 xfs_daddr_t start_blk, 502 xfs_daddr_t start_blk,
495 xfs_daddr_t *last_blk, 503 xfs_daddr_t *last_blk,
496 int extra_bblks) 504 int extra_bblks)
@@ -600,7 +608,7 @@ out:
600 */ 608 */
601STATIC int 609STATIC int
602xlog_find_head( 610xlog_find_head(
603 xlog_t *log, 611 struct xlog *log,
604 xfs_daddr_t *return_head_blk) 612 xfs_daddr_t *return_head_blk)
605{ 613{
606 xfs_buf_t *bp; 614 xfs_buf_t *bp;
@@ -871,7 +879,7 @@ validate_head:
871 */ 879 */
872STATIC int 880STATIC int
873xlog_find_tail( 881xlog_find_tail(
874 xlog_t *log, 882 struct xlog *log,
875 xfs_daddr_t *head_blk, 883 xfs_daddr_t *head_blk,
876 xfs_daddr_t *tail_blk) 884 xfs_daddr_t *tail_blk)
877{ 885{
@@ -1080,7 +1088,7 @@ done:
1080 */ 1088 */
1081STATIC int 1089STATIC int
1082xlog_find_zeroed( 1090xlog_find_zeroed(
1083 xlog_t *log, 1091 struct xlog *log,
1084 xfs_daddr_t *blk_no) 1092 xfs_daddr_t *blk_no)
1085{ 1093{
1086 xfs_buf_t *bp; 1094 xfs_buf_t *bp;
@@ -1183,7 +1191,7 @@ bp_err:
1183 */ 1191 */
1184STATIC void 1192STATIC void
1185xlog_add_record( 1193xlog_add_record(
1186 xlog_t *log, 1194 struct xlog *log,
1187 xfs_caddr_t buf, 1195 xfs_caddr_t buf,
1188 int cycle, 1196 int cycle,
1189 int block, 1197 int block,
@@ -1205,7 +1213,7 @@ xlog_add_record(
1205 1213
1206STATIC int 1214STATIC int
1207xlog_write_log_records( 1215xlog_write_log_records(
1208 xlog_t *log, 1216 struct xlog *log,
1209 int cycle, 1217 int cycle,
1210 int start_block, 1218 int start_block,
1211 int blocks, 1219 int blocks,
@@ -1305,7 +1313,7 @@ xlog_write_log_records(
1305 */ 1313 */
1306STATIC int 1314STATIC int
1307xlog_clear_stale_blocks( 1315xlog_clear_stale_blocks(
1308 xlog_t *log, 1316 struct xlog *log,
1309 xfs_lsn_t tail_lsn) 1317 xfs_lsn_t tail_lsn)
1310{ 1318{
1311 int tail_cycle, head_cycle; 1319 int tail_cycle, head_cycle;
@@ -2050,11 +2058,11 @@ xfs_qm_dqcheck(
2050 */ 2058 */
2051STATIC void 2059STATIC void
2052xlog_recover_do_dquot_buffer( 2060xlog_recover_do_dquot_buffer(
2053 xfs_mount_t *mp, 2061 struct xfs_mount *mp,
2054 xlog_t *log, 2062 struct xlog *log,
2055 xlog_recover_item_t *item, 2063 struct xlog_recover_item *item,
2056 xfs_buf_t *bp, 2064 struct xfs_buf *bp,
2057 xfs_buf_log_format_t *buf_f) 2065 struct xfs_buf_log_format *buf_f)
2058{ 2066{
2059 uint type; 2067 uint type;
2060 2068
@@ -2108,9 +2116,9 @@ xlog_recover_do_dquot_buffer(
2108 */ 2116 */
2109STATIC int 2117STATIC int
2110xlog_recover_buffer_pass2( 2118xlog_recover_buffer_pass2(
2111 xlog_t *log, 2119 struct xlog *log,
2112 struct list_head *buffer_list, 2120 struct list_head *buffer_list,
2113 xlog_recover_item_t *item) 2121 struct xlog_recover_item *item)
2114{ 2122{
2115 xfs_buf_log_format_t *buf_f = item->ri_buf[0].i_addr; 2123 xfs_buf_log_format_t *buf_f = item->ri_buf[0].i_addr;
2116 xfs_mount_t *mp = log->l_mp; 2124 xfs_mount_t *mp = log->l_mp;
@@ -2189,9 +2197,9 @@ xlog_recover_buffer_pass2(
2189 2197
2190STATIC int 2198STATIC int
2191xlog_recover_inode_pass2( 2199xlog_recover_inode_pass2(
2192 xlog_t *log, 2200 struct xlog *log,
2193 struct list_head *buffer_list, 2201 struct list_head *buffer_list,
2194 xlog_recover_item_t *item) 2202 struct xlog_recover_item *item)
2195{ 2203{
2196 xfs_inode_log_format_t *in_f; 2204 xfs_inode_log_format_t *in_f;
2197 xfs_mount_t *mp = log->l_mp; 2205 xfs_mount_t *mp = log->l_mp;
@@ -2452,14 +2460,14 @@ error:
2452} 2460}
2453 2461
2454/* 2462/*
2455 * Recover QUOTAOFF records. We simply make a note of it in the xlog_t 2463 * Recover QUOTAOFF records. We simply make a note of it in the xlog
2456 * structure, so that we know not to do any dquot item or dquot buffer recovery, 2464 * structure, so that we know not to do any dquot item or dquot buffer recovery,
2457 * of that type. 2465 * of that type.
2458 */ 2466 */
2459STATIC int 2467STATIC int
2460xlog_recover_quotaoff_pass1( 2468xlog_recover_quotaoff_pass1(
2461 xlog_t *log, 2469 struct xlog *log,
2462 xlog_recover_item_t *item) 2470 struct xlog_recover_item *item)
2463{ 2471{
2464 xfs_qoff_logformat_t *qoff_f = item->ri_buf[0].i_addr; 2472 xfs_qoff_logformat_t *qoff_f = item->ri_buf[0].i_addr;
2465 ASSERT(qoff_f); 2473 ASSERT(qoff_f);
@@ -2483,9 +2491,9 @@ xlog_recover_quotaoff_pass1(
2483 */ 2491 */
2484STATIC int 2492STATIC int
2485xlog_recover_dquot_pass2( 2493xlog_recover_dquot_pass2(
2486 xlog_t *log, 2494 struct xlog *log,
2487 struct list_head *buffer_list, 2495 struct list_head *buffer_list,
2488 xlog_recover_item_t *item) 2496 struct xlog_recover_item *item)
2489{ 2497{
2490 xfs_mount_t *mp = log->l_mp; 2498 xfs_mount_t *mp = log->l_mp;
2491 xfs_buf_t *bp; 2499 xfs_buf_t *bp;
@@ -2578,9 +2586,9 @@ xlog_recover_dquot_pass2(
2578 */ 2586 */
2579STATIC int 2587STATIC int
2580xlog_recover_efi_pass2( 2588xlog_recover_efi_pass2(
2581 xlog_t *log, 2589 struct xlog *log,
2582 xlog_recover_item_t *item, 2590 struct xlog_recover_item *item,
2583 xfs_lsn_t lsn) 2591 xfs_lsn_t lsn)
2584{ 2592{
2585 int error; 2593 int error;
2586 xfs_mount_t *mp = log->l_mp; 2594 xfs_mount_t *mp = log->l_mp;
@@ -2616,8 +2624,8 @@ xlog_recover_efi_pass2(
2616 */ 2624 */
2617STATIC int 2625STATIC int
2618xlog_recover_efd_pass2( 2626xlog_recover_efd_pass2(
2619 xlog_t *log, 2627 struct xlog *log,
2620 xlog_recover_item_t *item) 2628 struct xlog_recover_item *item)
2621{ 2629{
2622 xfs_efd_log_format_t *efd_formatp; 2630 xfs_efd_log_format_t *efd_formatp;
2623 xfs_efi_log_item_t *efip = NULL; 2631 xfs_efi_log_item_t *efip = NULL;
@@ -2812,9 +2820,9 @@ xlog_recover_unmount_trans(
2812 */ 2820 */
2813STATIC int 2821STATIC int
2814xlog_recover_process_data( 2822xlog_recover_process_data(
2815 xlog_t *log, 2823 struct xlog *log,
2816 struct hlist_head rhash[], 2824 struct hlist_head rhash[],
2817 xlog_rec_header_t *rhead, 2825 struct xlog_rec_header *rhead,
2818 xfs_caddr_t dp, 2826 xfs_caddr_t dp,
2819 int pass) 2827 int pass)
2820{ 2828{
@@ -2986,7 +2994,7 @@ abort_error:
2986 */ 2994 */
2987STATIC int 2995STATIC int
2988xlog_recover_process_efis( 2996xlog_recover_process_efis(
2989 xlog_t *log) 2997 struct xlog *log)
2990{ 2998{
2991 xfs_log_item_t *lip; 2999 xfs_log_item_t *lip;
2992 xfs_efi_log_item_t *efip; 3000 xfs_efi_log_item_t *efip;
@@ -3098,7 +3106,7 @@ xlog_recover_process_one_iunlink(
3098 /* 3106 /*
3099 * Get the on disk inode to find the next inode in the bucket. 3107 * Get the on disk inode to find the next inode in the bucket.
3100 */ 3108 */
3101 error = xfs_itobp(mp, NULL, ip, &dip, &ibp, 0); 3109 error = xfs_imap_to_bp(mp, NULL, &ip->i_imap, &dip, &ibp, 0, 0);
3102 if (error) 3110 if (error)
3103 goto fail_iput; 3111 goto fail_iput;
3104 3112
@@ -3147,7 +3155,7 @@ xlog_recover_process_one_iunlink(
3147 */ 3155 */
3148STATIC void 3156STATIC void
3149xlog_recover_process_iunlinks( 3157xlog_recover_process_iunlinks(
3150 xlog_t *log) 3158 struct xlog *log)
3151{ 3159{
3152 xfs_mount_t *mp; 3160 xfs_mount_t *mp;
3153 xfs_agnumber_t agno; 3161 xfs_agnumber_t agno;
@@ -3209,9 +3217,9 @@ xlog_recover_process_iunlinks(
3209#ifdef DEBUG 3217#ifdef DEBUG
3210STATIC void 3218STATIC void
3211xlog_pack_data_checksum( 3219xlog_pack_data_checksum(
3212 xlog_t *log, 3220 struct xlog *log,
3213 xlog_in_core_t *iclog, 3221 struct xlog_in_core *iclog,
3214 int size) 3222 int size)
3215{ 3223{
3216 int i; 3224 int i;
3217 __be32 *up; 3225 __be32 *up;
@@ -3234,8 +3242,8 @@ xlog_pack_data_checksum(
3234 */ 3242 */
3235void 3243void
3236xlog_pack_data( 3244xlog_pack_data(
3237 xlog_t *log, 3245 struct xlog *log,
3238 xlog_in_core_t *iclog, 3246 struct xlog_in_core *iclog,
3239 int roundoff) 3247 int roundoff)
3240{ 3248{
3241 int i, j, k; 3249 int i, j, k;
@@ -3274,9 +3282,9 @@ xlog_pack_data(
3274 3282
3275STATIC void 3283STATIC void
3276xlog_unpack_data( 3284xlog_unpack_data(
3277 xlog_rec_header_t *rhead, 3285 struct xlog_rec_header *rhead,
3278 xfs_caddr_t dp, 3286 xfs_caddr_t dp,
3279 xlog_t *log) 3287 struct xlog *log)
3280{ 3288{
3281 int i, j, k; 3289 int i, j, k;
3282 3290
@@ -3299,8 +3307,8 @@ xlog_unpack_data(
3299 3307
3300STATIC int 3308STATIC int
3301xlog_valid_rec_header( 3309xlog_valid_rec_header(
3302 xlog_t *log, 3310 struct xlog *log,
3303 xlog_rec_header_t *rhead, 3311 struct xlog_rec_header *rhead,
3304 xfs_daddr_t blkno) 3312 xfs_daddr_t blkno)
3305{ 3313{
3306 int hlen; 3314 int hlen;
@@ -3343,7 +3351,7 @@ xlog_valid_rec_header(
3343 */ 3351 */
3344STATIC int 3352STATIC int
3345xlog_do_recovery_pass( 3353xlog_do_recovery_pass(
3346 xlog_t *log, 3354 struct xlog *log,
3347 xfs_daddr_t head_blk, 3355 xfs_daddr_t head_blk,
3348 xfs_daddr_t tail_blk, 3356 xfs_daddr_t tail_blk,
3349 int pass) 3357 int pass)
@@ -3595,7 +3603,7 @@ xlog_do_recovery_pass(
3595 */ 3603 */
3596STATIC int 3604STATIC int
3597xlog_do_log_recovery( 3605xlog_do_log_recovery(
3598 xlog_t *log, 3606 struct xlog *log,
3599 xfs_daddr_t head_blk, 3607 xfs_daddr_t head_blk,
3600 xfs_daddr_t tail_blk) 3608 xfs_daddr_t tail_blk)
3601{ 3609{
@@ -3646,7 +3654,7 @@ xlog_do_log_recovery(
3646 */ 3654 */
3647STATIC int 3655STATIC int
3648xlog_do_recover( 3656xlog_do_recover(
3649 xlog_t *log, 3657 struct xlog *log,
3650 xfs_daddr_t head_blk, 3658 xfs_daddr_t head_blk,
3651 xfs_daddr_t tail_blk) 3659 xfs_daddr_t tail_blk)
3652{ 3660{
@@ -3721,7 +3729,7 @@ xlog_do_recover(
3721 */ 3729 */
3722int 3730int
3723xlog_recover( 3731xlog_recover(
3724 xlog_t *log) 3732 struct xlog *log)
3725{ 3733{
3726 xfs_daddr_t head_blk, tail_blk; 3734 xfs_daddr_t head_blk, tail_blk;
3727 int error; 3735 int error;
@@ -3767,7 +3775,7 @@ xlog_recover(
3767 */ 3775 */
3768int 3776int
3769xlog_recover_finish( 3777xlog_recover_finish(
3770 xlog_t *log) 3778 struct xlog *log)
3771{ 3779{
3772 /* 3780 /*
3773 * Now we're ready to do the transactions needed for the 3781 * Now we're ready to do the transactions needed for the
@@ -3814,7 +3822,7 @@ xlog_recover_finish(
3814 */ 3822 */
3815void 3823void
3816xlog_recover_check_summary( 3824xlog_recover_check_summary(
3817 xlog_t *log) 3825 struct xlog *log)
3818{ 3826{
3819 xfs_mount_t *mp; 3827 xfs_mount_t *mp;
3820 xfs_agf_t *agfp; 3828 xfs_agf_t *agfp;
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 536021fb3d4e..711ca51ca3d7 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1200,8 +1200,6 @@ xfs_mountfs(
1200 1200
1201 xfs_set_maxicount(mp); 1201 xfs_set_maxicount(mp);
1202 1202
1203 mp->m_maxioffset = xfs_max_file_offset(sbp->sb_blocklog);
1204
1205 error = xfs_uuid_mount(mp); 1203 error = xfs_uuid_mount(mp);
1206 if (error) 1204 if (error)
1207 goto out; 1205 goto out;
@@ -1531,6 +1529,15 @@ xfs_unmountfs(
1531 xfs_ail_push_all_sync(mp->m_ail); 1529 xfs_ail_push_all_sync(mp->m_ail);
1532 xfs_wait_buftarg(mp->m_ddev_targp); 1530 xfs_wait_buftarg(mp->m_ddev_targp);
1533 1531
1532 /*
1533 * The superblock buffer is uncached and xfsaild_push() will lock and
1534 * set the XBF_ASYNC flag on the buffer. We cannot do xfs_buf_iowait()
1535 * here but a lock on the superblock buffer will block until iodone()
1536 * has completed.
1537 */
1538 xfs_buf_lock(mp->m_sb_bp);
1539 xfs_buf_unlock(mp->m_sb_bp);
1540
1534 xfs_log_unmount_write(mp); 1541 xfs_log_unmount_write(mp);
1535 xfs_log_unmount(mp); 1542 xfs_log_unmount(mp);
1536 xfs_uuid_unmount(mp); 1543 xfs_uuid_unmount(mp);
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 90c1fc9eaea4..8724336a9a08 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -176,7 +176,6 @@ typedef struct xfs_mount {
176 uint m_qflags; /* quota status flags */ 176 uint m_qflags; /* quota status flags */
177 xfs_trans_reservations_t m_reservations;/* precomputed res values */ 177 xfs_trans_reservations_t m_reservations;/* precomputed res values */
178 __uint64_t m_maxicount; /* maximum inode count */ 178 __uint64_t m_maxicount; /* maximum inode count */
179 __uint64_t m_maxioffset; /* maximum inode offset */
180 __uint64_t m_resblks; /* total reserved blocks */ 179 __uint64_t m_resblks; /* total reserved blocks */
181 __uint64_t m_resblks_avail;/* available reserved blocks */ 180 __uint64_t m_resblks_avail;/* available reserved blocks */
182 __uint64_t m_resblks_save; /* reserved blks @ remount,ro */ 181 __uint64_t m_resblks_save; /* reserved blks @ remount,ro */
@@ -297,8 +296,6 @@ xfs_preferred_iosize(xfs_mount_t *mp)
297 PAGE_CACHE_SIZE)); 296 PAGE_CACHE_SIZE));
298} 297}
299 298
300#define XFS_MAXIOFFSET(mp) ((mp)->m_maxioffset)
301
302#define XFS_LAST_UNMOUNT_WAS_CLEAN(mp) \ 299#define XFS_LAST_UNMOUNT_WAS_CLEAN(mp) \
303 ((mp)->m_flags & XFS_MOUNT_WAS_CLEAN) 300 ((mp)->m_flags & XFS_MOUNT_WAS_CLEAN)
304#define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN) 301#define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN)
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 249db1987764..2e86fa0cfc0d 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -940,7 +940,7 @@ xfs_qm_dqiterate(
940 map = kmem_alloc(XFS_DQITER_MAP_SIZE * sizeof(*map), KM_SLEEP); 940 map = kmem_alloc(XFS_DQITER_MAP_SIZE * sizeof(*map), KM_SLEEP);
941 941
942 lblkno = 0; 942 lblkno = 0;
943 maxlblkcnt = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp)); 943 maxlblkcnt = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);
944 do { 944 do {
945 nmaps = XFS_DQITER_MAP_SIZE; 945 nmaps = XFS_DQITER_MAP_SIZE;
946 /* 946 /*
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 0d9de41a7151..bdaf4cb9f4a2 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -868,67 +868,14 @@ xfs_fs_inode_init_once(
868 "xfsino", ip->i_ino); 868 "xfsino", ip->i_ino);
869} 869}
870 870
871/*
872 * This is called by the VFS when dirtying inode metadata. This can happen
873 * for a few reasons, but we only care about timestamp updates, given that
874 * we handled the rest ourselves. In theory no other calls should happen,
875 * but for example generic_write_end() keeps dirtying the inode after
876 * updating i_size. Thus we check that the flags are exactly I_DIRTY_SYNC,
877 * and skip this call otherwise.
878 *
879 * We'll hopefull get a different method just for updating timestamps soon,
880 * at which point this hack can go away, and maybe we'll also get real
881 * error handling here.
882 */
883STATIC void
884xfs_fs_dirty_inode(
885 struct inode *inode,
886 int flags)
887{
888 struct xfs_inode *ip = XFS_I(inode);
889 struct xfs_mount *mp = ip->i_mount;
890 struct xfs_trans *tp;
891 int error;
892
893 if (flags != I_DIRTY_SYNC)
894 return;
895
896 trace_xfs_dirty_inode(ip);
897
898 tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS);
899 error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0);
900 if (error) {
901 xfs_trans_cancel(tp, 0);
902 goto trouble;
903 }
904 xfs_ilock(ip, XFS_ILOCK_EXCL);
905 /*
906 * Grab all the latest timestamps from the Linux inode.
907 */
908 ip->i_d.di_atime.t_sec = (__int32_t)inode->i_atime.tv_sec;
909 ip->i_d.di_atime.t_nsec = (__int32_t)inode->i_atime.tv_nsec;
910 ip->i_d.di_ctime.t_sec = (__int32_t)inode->i_ctime.tv_sec;
911 ip->i_d.di_ctime.t_nsec = (__int32_t)inode->i_ctime.tv_nsec;
912 ip->i_d.di_mtime.t_sec = (__int32_t)inode->i_mtime.tv_sec;
913 ip->i_d.di_mtime.t_nsec = (__int32_t)inode->i_mtime.tv_nsec;
914
915 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
916 xfs_trans_log_inode(tp, ip, XFS_ILOG_TIMESTAMP);
917 error = xfs_trans_commit(tp, 0);
918 if (error)
919 goto trouble;
920 return;
921
922trouble:
923 xfs_warn(mp, "failed to update timestamps for inode 0x%llx", ip->i_ino);
924}
925
926STATIC void 871STATIC void
927xfs_fs_evict_inode( 872xfs_fs_evict_inode(
928 struct inode *inode) 873 struct inode *inode)
929{ 874{
930 xfs_inode_t *ip = XFS_I(inode); 875 xfs_inode_t *ip = XFS_I(inode);
931 876
877 ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock));
878
932 trace_xfs_evict_inode(ip); 879 trace_xfs_evict_inode(ip);
933 880
934 truncate_inode_pages(&inode->i_data, 0); 881 truncate_inode_pages(&inode->i_data, 0);
@@ -937,22 +884,6 @@ xfs_fs_evict_inode(
937 XFS_STATS_INC(vn_remove); 884 XFS_STATS_INC(vn_remove);
938 XFS_STATS_DEC(vn_active); 885 XFS_STATS_DEC(vn_active);
939 886
940 /*
941 * The iolock is used by the file system to coordinate reads,
942 * writes, and block truncates. Up to this point the lock
943 * protected concurrent accesses by users of the inode. But
944 * from here forward we're doing some final processing of the
945 * inode because we're done with it, and although we reuse the
946 * iolock for protection it is really a distinct lock class
947 * (in the lockdep sense) from before. To keep lockdep happy
948 * (and basically indicate what we are doing), we explicitly
949 * re-init the iolock here.
950 */
951 ASSERT(!rwsem_is_locked(&ip->i_iolock.mr_lock));
952 mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", ip->i_ino);
953 lockdep_set_class_and_name(&ip->i_iolock.mr_lock,
954 &xfs_iolock_reclaimable, "xfs_iolock_reclaimable");
955
956 xfs_inactive(ip); 887 xfs_inactive(ip);
957} 888}
958 889
@@ -1436,7 +1367,6 @@ xfs_fs_free_cached_objects(
1436static const struct super_operations xfs_super_operations = { 1367static const struct super_operations xfs_super_operations = {
1437 .alloc_inode = xfs_fs_alloc_inode, 1368 .alloc_inode = xfs_fs_alloc_inode,
1438 .destroy_inode = xfs_fs_destroy_inode, 1369 .destroy_inode = xfs_fs_destroy_inode,
1439 .dirty_inode = xfs_fs_dirty_inode,
1440 .evict_inode = xfs_fs_evict_inode, 1370 .evict_inode = xfs_fs_evict_inode,
1441 .drop_inode = xfs_fs_drop_inode, 1371 .drop_inode = xfs_fs_drop_inode,
1442 .put_super = xfs_fs_put_super, 1372 .put_super = xfs_fs_put_super,
@@ -1491,13 +1421,9 @@ xfs_init_zones(void)
1491 if (!xfs_da_state_zone) 1421 if (!xfs_da_state_zone)
1492 goto out_destroy_btree_cur_zone; 1422 goto out_destroy_btree_cur_zone;
1493 1423
1494 xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf");
1495 if (!xfs_dabuf_zone)
1496 goto out_destroy_da_state_zone;
1497
1498 xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork"); 1424 xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
1499 if (!xfs_ifork_zone) 1425 if (!xfs_ifork_zone)
1500 goto out_destroy_dabuf_zone; 1426 goto out_destroy_da_state_zone;
1501 1427
1502 xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans"); 1428 xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
1503 if (!xfs_trans_zone) 1429 if (!xfs_trans_zone)
@@ -1514,9 +1440,8 @@ xfs_init_zones(void)
1514 * size possible under XFS. This wastes a little bit of memory, 1440 * size possible under XFS. This wastes a little bit of memory,
1515 * but it is much faster. 1441 * but it is much faster.
1516 */ 1442 */
1517 xfs_buf_item_zone = kmem_zone_init((sizeof(xfs_buf_log_item_t) + 1443 xfs_buf_item_zone = kmem_zone_init(sizeof(struct xfs_buf_log_item),
1518 (((XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK) / 1444 "xfs_buf_item");
1519 NBWORD) * sizeof(int))), "xfs_buf_item");
1520 if (!xfs_buf_item_zone) 1445 if (!xfs_buf_item_zone)
1521 goto out_destroy_log_item_desc_zone; 1446 goto out_destroy_log_item_desc_zone;
1522 1447
@@ -1561,8 +1486,6 @@ xfs_init_zones(void)
1561 kmem_zone_destroy(xfs_trans_zone); 1486 kmem_zone_destroy(xfs_trans_zone);
1562 out_destroy_ifork_zone: 1487 out_destroy_ifork_zone:
1563 kmem_zone_destroy(xfs_ifork_zone); 1488 kmem_zone_destroy(xfs_ifork_zone);
1564 out_destroy_dabuf_zone:
1565 kmem_zone_destroy(xfs_dabuf_zone);
1566 out_destroy_da_state_zone: 1489 out_destroy_da_state_zone:
1567 kmem_zone_destroy(xfs_da_state_zone); 1490 kmem_zone_destroy(xfs_da_state_zone);
1568 out_destroy_btree_cur_zone: 1491 out_destroy_btree_cur_zone:
@@ -1590,7 +1513,6 @@ xfs_destroy_zones(void)
1590 kmem_zone_destroy(xfs_log_item_desc_zone); 1513 kmem_zone_destroy(xfs_log_item_desc_zone);
1591 kmem_zone_destroy(xfs_trans_zone); 1514 kmem_zone_destroy(xfs_trans_zone);
1592 kmem_zone_destroy(xfs_ifork_zone); 1515 kmem_zone_destroy(xfs_ifork_zone);
1593 kmem_zone_destroy(xfs_dabuf_zone);
1594 kmem_zone_destroy(xfs_da_state_zone); 1516 kmem_zone_destroy(xfs_da_state_zone);
1595 kmem_zone_destroy(xfs_btree_cur_zone); 1517 kmem_zone_destroy(xfs_btree_cur_zone);
1596 kmem_zone_destroy(xfs_bmap_free_item_zone); 1518 kmem_zone_destroy(xfs_bmap_free_item_zone);
diff --git a/fs/xfs/xfs_sync.c b/fs/xfs/xfs_sync.c
index 1e9ee064dbb2..97304f10e78a 100644
--- a/fs/xfs/xfs_sync.c
+++ b/fs/xfs/xfs_sync.c
@@ -359,6 +359,15 @@ xfs_quiesce_attr(
359 * added an item to the AIL, thus flush it again. 359 * added an item to the AIL, thus flush it again.
360 */ 360 */
361 xfs_ail_push_all_sync(mp->m_ail); 361 xfs_ail_push_all_sync(mp->m_ail);
362
363 /*
364 * The superblock buffer is uncached and xfsaild_push() will lock and
365 * set the XBF_ASYNC flag on the buffer. We cannot do xfs_buf_iowait()
366 * here but a lock on the superblock buffer will block until iodone()
367 * has completed.
368 */
369 xfs_buf_lock(mp->m_sb_bp);
370 xfs_buf_unlock(mp->m_sb_bp);
362} 371}
363 372
364static void 373static void
@@ -712,8 +721,8 @@ restart:
712 * Note that xfs_iflush will never block on the inode buffer lock, as 721 * Note that xfs_iflush will never block on the inode buffer lock, as
713 * xfs_ifree_cluster() can lock the inode buffer before it locks the 722 * xfs_ifree_cluster() can lock the inode buffer before it locks the
714 * ip->i_lock, and we are doing the exact opposite here. As a result, 723 * ip->i_lock, and we are doing the exact opposite here. As a result,
715 * doing a blocking xfs_itobp() to get the cluster buffer would result 724 * doing a blocking xfs_imap_to_bp() to get the cluster buffer would
716 * in an ABBA deadlock with xfs_ifree_cluster(). 725 * result in an ABBA deadlock with xfs_ifree_cluster().
717 * 726 *
718 * As xfs_ifree_cluser() must gather all inodes that are active in the 727 * As xfs_ifree_cluser() must gather all inodes that are active in the
719 * cache to mark them stale, if we hit this case we don't actually want 728 * cache to mark them stale, if we hit this case we don't actually want
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index caf5dabfd553..e5795dd6013a 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -578,8 +578,8 @@ DEFINE_INODE_EVENT(xfs_ioctl_setattr);
578DEFINE_INODE_EVENT(xfs_dir_fsync); 578DEFINE_INODE_EVENT(xfs_dir_fsync);
579DEFINE_INODE_EVENT(xfs_file_fsync); 579DEFINE_INODE_EVENT(xfs_file_fsync);
580DEFINE_INODE_EVENT(xfs_destroy_inode); 580DEFINE_INODE_EVENT(xfs_destroy_inode);
581DEFINE_INODE_EVENT(xfs_dirty_inode);
582DEFINE_INODE_EVENT(xfs_evict_inode); 581DEFINE_INODE_EVENT(xfs_evict_inode);
582DEFINE_INODE_EVENT(xfs_update_time);
583 583
584DEFINE_INODE_EVENT(xfs_dquot_dqalloc); 584DEFINE_INODE_EVENT(xfs_dquot_dqalloc);
585DEFINE_INODE_EVENT(xfs_dquot_dqdetach); 585DEFINE_INODE_EVENT(xfs_dquot_dqdetach);
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 7c37b533aa8e..bc2afd52a0b7 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -448,11 +448,51 @@ xfs_trans_t *xfs_trans_dup(xfs_trans_t *);
448int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint, 448int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint,
449 uint, uint); 449 uint, uint);
450void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t); 450void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);
451struct xfs_buf *xfs_trans_get_buf(xfs_trans_t *, struct xfs_buftarg *, xfs_daddr_t, 451
452 int, uint); 452struct xfs_buf *xfs_trans_get_buf_map(struct xfs_trans *tp,
453int xfs_trans_read_buf(struct xfs_mount *, xfs_trans_t *, 453 struct xfs_buftarg *target,
454 struct xfs_buftarg *, xfs_daddr_t, int, uint, 454 struct xfs_buf_map *map, int nmaps,
455 struct xfs_buf **); 455 uint flags);
456
457static inline struct xfs_buf *
458xfs_trans_get_buf(
459 struct xfs_trans *tp,
460 struct xfs_buftarg *target,
461 xfs_daddr_t blkno,
462 int numblks,
463 uint flags)
464{
465 struct xfs_buf_map map = {
466 .bm_bn = blkno,
467 .bm_len = numblks,
468 };
469 return xfs_trans_get_buf_map(tp, target, &map, 1, flags);
470}
471
472int xfs_trans_read_buf_map(struct xfs_mount *mp,
473 struct xfs_trans *tp,
474 struct xfs_buftarg *target,
475 struct xfs_buf_map *map, int nmaps,
476 xfs_buf_flags_t flags,
477 struct xfs_buf **bpp);
478
479static inline int
480xfs_trans_read_buf(
481 struct xfs_mount *mp,
482 struct xfs_trans *tp,
483 struct xfs_buftarg *target,
484 xfs_daddr_t blkno,
485 int numblks,
486 xfs_buf_flags_t flags,
487 struct xfs_buf **bpp)
488{
489 struct xfs_buf_map map = {
490 .bm_bn = blkno,
491 .bm_len = numblks,
492 };
493 return xfs_trans_read_buf_map(mp, tp, target, &map, 1, flags, bpp);
494}
495
456struct xfs_buf *xfs_trans_getsb(xfs_trans_t *, struct xfs_mount *, int); 496struct xfs_buf *xfs_trans_getsb(xfs_trans_t *, struct xfs_mount *, int);
457 497
458void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *); 498void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *);
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index 9c514483e599..6011ee661339 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -383,6 +383,12 @@ xfsaild_push(
383 } 383 }
384 384
385 spin_lock(&ailp->xa_lock); 385 spin_lock(&ailp->xa_lock);
386
387 /* barrier matches the xa_target update in xfs_ail_push() */
388 smp_rmb();
389 target = ailp->xa_target;
390 ailp->xa_target_prev = target;
391
386 lip = xfs_trans_ail_cursor_first(ailp, &cur, ailp->xa_last_pushed_lsn); 392 lip = xfs_trans_ail_cursor_first(ailp, &cur, ailp->xa_last_pushed_lsn);
387 if (!lip) { 393 if (!lip) {
388 /* 394 /*
@@ -397,7 +403,6 @@ xfsaild_push(
397 XFS_STATS_INC(xs_push_ail); 403 XFS_STATS_INC(xs_push_ail);
398 404
399 lsn = lip->li_lsn; 405 lsn = lip->li_lsn;
400 target = ailp->xa_target;
401 while ((XFS_LSN_CMP(lip->li_lsn, target) <= 0)) { 406 while ((XFS_LSN_CMP(lip->li_lsn, target) <= 0)) {
402 int lock_result; 407 int lock_result;
403 408
@@ -527,8 +532,32 @@ xfsaild(
527 __set_current_state(TASK_KILLABLE); 532 __set_current_state(TASK_KILLABLE);
528 else 533 else
529 __set_current_state(TASK_INTERRUPTIBLE); 534 __set_current_state(TASK_INTERRUPTIBLE);
530 schedule_timeout(tout ? 535
531 msecs_to_jiffies(tout) : MAX_SCHEDULE_TIMEOUT); 536 spin_lock(&ailp->xa_lock);
537
538 /*
539 * Idle if the AIL is empty and we are not racing with a target
540 * update. We check the AIL after we set the task to a sleep
541 * state to guarantee that we either catch an xa_target update
542 * or that a wake_up resets the state to TASK_RUNNING.
543 * Otherwise, we run the risk of sleeping indefinitely.
544 *
545 * The barrier matches the xa_target update in xfs_ail_push().
546 */
547 smp_rmb();
548 if (!xfs_ail_min(ailp) &&
549 ailp->xa_target == ailp->xa_target_prev) {
550 spin_unlock(&ailp->xa_lock);
551 schedule();
552 tout = 0;
553 continue;
554 }
555 spin_unlock(&ailp->xa_lock);
556
557 if (tout)
558 schedule_timeout(msecs_to_jiffies(tout));
559
560 __set_current_state(TASK_RUNNING);
532 561
533 try_to_freeze(); 562 try_to_freeze();
534 563
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 21c5a5e3700d..6311b99c267f 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -41,20 +41,26 @@ STATIC struct xfs_buf *
41xfs_trans_buf_item_match( 41xfs_trans_buf_item_match(
42 struct xfs_trans *tp, 42 struct xfs_trans *tp,
43 struct xfs_buftarg *target, 43 struct xfs_buftarg *target,
44 xfs_daddr_t blkno, 44 struct xfs_buf_map *map,
45 int len) 45 int nmaps)
46{ 46{
47 struct xfs_log_item_desc *lidp; 47 struct xfs_log_item_desc *lidp;
48 struct xfs_buf_log_item *blip; 48 struct xfs_buf_log_item *blip;
49 int len = 0;
50 int i;
51
52 for (i = 0; i < nmaps; i++)
53 len += map[i].bm_len;
49 54
50 len = BBTOB(len);
51 list_for_each_entry(lidp, &tp->t_items, lid_trans) { 55 list_for_each_entry(lidp, &tp->t_items, lid_trans) {
52 blip = (struct xfs_buf_log_item *)lidp->lid_item; 56 blip = (struct xfs_buf_log_item *)lidp->lid_item;
53 if (blip->bli_item.li_type == XFS_LI_BUF && 57 if (blip->bli_item.li_type == XFS_LI_BUF &&
54 blip->bli_buf->b_target == target && 58 blip->bli_buf->b_target == target &&
55 XFS_BUF_ADDR(blip->bli_buf) == blkno && 59 XFS_BUF_ADDR(blip->bli_buf) == map[0].bm_bn &&
56 BBTOB(blip->bli_buf->b_length) == len) 60 blip->bli_buf->b_length == len) {
61 ASSERT(blip->bli_buf->b_map_count == nmaps);
57 return blip->bli_buf; 62 return blip->bli_buf;
63 }
58 } 64 }
59 65
60 return NULL; 66 return NULL;
@@ -128,21 +134,19 @@ xfs_trans_bjoin(
128 * If the transaction pointer is NULL, make this just a normal 134 * If the transaction pointer is NULL, make this just a normal
129 * get_buf() call. 135 * get_buf() call.
130 */ 136 */
131xfs_buf_t * 137struct xfs_buf *
132xfs_trans_get_buf(xfs_trans_t *tp, 138xfs_trans_get_buf_map(
133 xfs_buftarg_t *target_dev, 139 struct xfs_trans *tp,
134 xfs_daddr_t blkno, 140 struct xfs_buftarg *target,
135 int len, 141 struct xfs_buf_map *map,
136 uint flags) 142 int nmaps,
143 xfs_buf_flags_t flags)
137{ 144{
138 xfs_buf_t *bp; 145 xfs_buf_t *bp;
139 xfs_buf_log_item_t *bip; 146 xfs_buf_log_item_t *bip;
140 147
141 /* 148 if (!tp)
142 * Default to a normal get_buf() call if the tp is NULL. 149 return xfs_buf_get_map(target, map, nmaps, flags);
143 */
144 if (tp == NULL)
145 return xfs_buf_get(target_dev, blkno, len, flags);
146 150
147 /* 151 /*
148 * If we find the buffer in the cache with this transaction 152 * If we find the buffer in the cache with this transaction
@@ -150,7 +154,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,
150 * have it locked. In this case we just increment the lock 154 * have it locked. In this case we just increment the lock
151 * recursion count and return the buffer to the caller. 155 * recursion count and return the buffer to the caller.
152 */ 156 */
153 bp = xfs_trans_buf_item_match(tp, target_dev, blkno, len); 157 bp = xfs_trans_buf_item_match(tp, target, map, nmaps);
154 if (bp != NULL) { 158 if (bp != NULL) {
155 ASSERT(xfs_buf_islocked(bp)); 159 ASSERT(xfs_buf_islocked(bp));
156 if (XFS_FORCED_SHUTDOWN(tp->t_mountp)) { 160 if (XFS_FORCED_SHUTDOWN(tp->t_mountp)) {
@@ -167,7 +171,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,
167 return (bp); 171 return (bp);
168 } 172 }
169 173
170 bp = xfs_buf_get(target_dev, blkno, len, flags); 174 bp = xfs_buf_get_map(target, map, nmaps, flags);
171 if (bp == NULL) { 175 if (bp == NULL) {
172 return NULL; 176 return NULL;
173 } 177 }
@@ -246,26 +250,22 @@ int xfs_error_mod = 33;
246 * read_buf() call. 250 * read_buf() call.
247 */ 251 */
248int 252int
249xfs_trans_read_buf( 253xfs_trans_read_buf_map(
250 xfs_mount_t *mp, 254 struct xfs_mount *mp,
251 xfs_trans_t *tp, 255 struct xfs_trans *tp,
252 xfs_buftarg_t *target, 256 struct xfs_buftarg *target,
253 xfs_daddr_t blkno, 257 struct xfs_buf_map *map,
254 int len, 258 int nmaps,
255 uint flags, 259 xfs_buf_flags_t flags,
256 xfs_buf_t **bpp) 260 struct xfs_buf **bpp)
257{ 261{
258 xfs_buf_t *bp; 262 xfs_buf_t *bp;
259 xfs_buf_log_item_t *bip; 263 xfs_buf_log_item_t *bip;
260 int error; 264 int error;
261 265
262 *bpp = NULL; 266 *bpp = NULL;
263 267 if (!tp) {
264 /* 268 bp = xfs_buf_read_map(target, map, nmaps, flags);
265 * Default to a normal get_buf() call if the tp is NULL.
266 */
267 if (tp == NULL) {
268 bp = xfs_buf_read(target, blkno, len, flags);
269 if (!bp) 269 if (!bp)
270 return (flags & XBF_TRYLOCK) ? 270 return (flags & XBF_TRYLOCK) ?
271 EAGAIN : XFS_ERROR(ENOMEM); 271 EAGAIN : XFS_ERROR(ENOMEM);
@@ -303,7 +303,7 @@ xfs_trans_read_buf(
303 * If the buffer is not yet read in, then we read it in, increment 303 * If the buffer is not yet read in, then we read it in, increment
304 * the lock recursion count, and return it to the caller. 304 * the lock recursion count, and return it to the caller.
305 */ 305 */
306 bp = xfs_trans_buf_item_match(tp, target, blkno, len); 306 bp = xfs_trans_buf_item_match(tp, target, map, nmaps);
307 if (bp != NULL) { 307 if (bp != NULL) {
308 ASSERT(xfs_buf_islocked(bp)); 308 ASSERT(xfs_buf_islocked(bp));
309 ASSERT(bp->b_transp == tp); 309 ASSERT(bp->b_transp == tp);
@@ -349,7 +349,7 @@ xfs_trans_read_buf(
349 return 0; 349 return 0;
350 } 350 }
351 351
352 bp = xfs_buf_read(target, blkno, len, flags); 352 bp = xfs_buf_read_map(target, map, nmaps, flags);
353 if (bp == NULL) { 353 if (bp == NULL) {
354 *bpp = NULL; 354 *bpp = NULL;
355 return (flags & XBF_TRYLOCK) ? 355 return (flags & XBF_TRYLOCK) ?
diff --git a/fs/xfs/xfs_trans_priv.h b/fs/xfs/xfs_trans_priv.h
index fb62377d1cbc..53b7c9b0f8f7 100644
--- a/fs/xfs/xfs_trans_priv.h
+++ b/fs/xfs/xfs_trans_priv.h
@@ -67,6 +67,7 @@ struct xfs_ail {
67 struct task_struct *xa_task; 67 struct task_struct *xa_task;
68 struct list_head xa_ail; 68 struct list_head xa_ail;
69 xfs_lsn_t xa_target; 69 xfs_lsn_t xa_target;
70 xfs_lsn_t xa_target_prev;
70 struct list_head xa_cursors; 71 struct list_head xa_cursors;
71 spinlock_t xa_lock; 72 spinlock_t xa_lock;
72 xfs_lsn_t xa_last_pushed_lsn; 73 xfs_lsn_t xa_last_pushed_lsn;
diff --git a/fs/xfs/xfs_types.h b/fs/xfs/xfs_types.h
index 398cf681d025..7a41874f4c20 100644
--- a/fs/xfs/xfs_types.h
+++ b/fs/xfs/xfs_types.h
@@ -133,6 +133,20 @@ typedef __uint64_t xfs_filblks_t; /* number of blocks in a file */
133#define MAXAEXTNUM ((xfs_aextnum_t)0x7fff) /* signed short */ 133#define MAXAEXTNUM ((xfs_aextnum_t)0x7fff) /* signed short */
134 134
135/* 135/*
136 * Minimum and maximum blocksize and sectorsize.
137 * The blocksize upper limit is pretty much arbitrary.
138 * The sectorsize upper limit is due to sizeof(sb_sectsize).
139 */
140#define XFS_MIN_BLOCKSIZE_LOG 9 /* i.e. 512 bytes */
141#define XFS_MAX_BLOCKSIZE_LOG 16 /* i.e. 65536 bytes */
142#define XFS_MIN_BLOCKSIZE (1 << XFS_MIN_BLOCKSIZE_LOG)
143#define XFS_MAX_BLOCKSIZE (1 << XFS_MAX_BLOCKSIZE_LOG)
144#define XFS_MIN_SECTORSIZE_LOG 9 /* i.e. 512 bytes */
145#define XFS_MAX_SECTORSIZE_LOG 15 /* i.e. 32768 bytes */
146#define XFS_MIN_SECTORSIZE (1 << XFS_MIN_SECTORSIZE_LOG)
147#define XFS_MAX_SECTORSIZE (1 << XFS_MAX_SECTORSIZE_LOG)
148
149/*
136 * Min numbers of data/attr fork btree root pointers. 150 * Min numbers of data/attr fork btree root pointers.
137 */ 151 */
138#define MINDBTPTRS 3 152#define MINDBTPTRS 3
diff --git a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c
index 4e5b9ad5cb97..0025c78ac03c 100644
--- a/fs/xfs/xfs_utils.c
+++ b/fs/xfs/xfs_utils.c
@@ -65,7 +65,6 @@ xfs_dir_ialloc(
65 xfs_trans_t *ntp; 65 xfs_trans_t *ntp;
66 xfs_inode_t *ip; 66 xfs_inode_t *ip;
67 xfs_buf_t *ialloc_context = NULL; 67 xfs_buf_t *ialloc_context = NULL;
68 boolean_t call_again = B_FALSE;
69 int code; 68 int code;
70 uint log_res; 69 uint log_res;
71 uint log_count; 70 uint log_count;
@@ -91,7 +90,7 @@ xfs_dir_ialloc(
91 * the inode(s) that we've just allocated. 90 * the inode(s) that we've just allocated.
92 */ 91 */
93 code = xfs_ialloc(tp, dp, mode, nlink, rdev, prid, okalloc, 92 code = xfs_ialloc(tp, dp, mode, nlink, rdev, prid, okalloc,
94 &ialloc_context, &call_again, &ip); 93 &ialloc_context, &ip);
95 94
96 /* 95 /*
97 * Return an error if we were unable to allocate a new inode. 96 * Return an error if we were unable to allocate a new inode.
@@ -102,19 +101,18 @@ xfs_dir_ialloc(
102 *ipp = NULL; 101 *ipp = NULL;
103 return code; 102 return code;
104 } 103 }
105 if (!call_again && (ip == NULL)) { 104 if (!ialloc_context && !ip) {
106 *ipp = NULL; 105 *ipp = NULL;
107 return XFS_ERROR(ENOSPC); 106 return XFS_ERROR(ENOSPC);
108 } 107 }
109 108
110 /* 109 /*
111 * If call_again is set, then we were unable to get an 110 * If the AGI buffer is non-NULL, then we were unable to get an
112 * inode in one operation. We need to commit the current 111 * inode in one operation. We need to commit the current
113 * transaction and call xfs_ialloc() again. It is guaranteed 112 * transaction and call xfs_ialloc() again. It is guaranteed
114 * to succeed the second time. 113 * to succeed the second time.
115 */ 114 */
116 if (call_again) { 115 if (ialloc_context) {
117
118 /* 116 /*
119 * Normally, xfs_trans_commit releases all the locks. 117 * Normally, xfs_trans_commit releases all the locks.
120 * We call bhold to hang on to the ialloc_context across 118 * We call bhold to hang on to the ialloc_context across
@@ -195,7 +193,7 @@ xfs_dir_ialloc(
195 * this call should always succeed. 193 * this call should always succeed.
196 */ 194 */
197 code = xfs_ialloc(tp, dp, mode, nlink, rdev, prid, 195 code = xfs_ialloc(tp, dp, mode, nlink, rdev, prid,
198 okalloc, &ialloc_context, &call_again, &ip); 196 okalloc, &ialloc_context, &ip);
199 197
200 /* 198 /*
201 * If we get an error at this point, return to the caller 199 * If we get an error at this point, return to the caller
@@ -206,12 +204,11 @@ xfs_dir_ialloc(
206 *ipp = NULL; 204 *ipp = NULL;
207 return code; 205 return code;
208 } 206 }
209 ASSERT ((!call_again) && (ip != NULL)); 207 ASSERT(!ialloc_context && ip);
210 208
211 } else { 209 } else {
212 if (committed != NULL) { 210 if (committed != NULL)
213 *committed = 0; 211 *committed = 0;
214 }
215 } 212 }
216 213
217 *ipp = ip; 214 *ipp = ip;
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index b6a82d817a82..2a5c637344b4 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -146,11 +146,6 @@ xfs_readlink(
146} 146}
147 147
148/* 148/*
149 * Flags for xfs_free_eofblocks
150 */
151#define XFS_FREE_EOF_TRYLOCK (1<<0)
152
153/*
154 * This is called by xfs_inactive to free any blocks beyond eof 149 * This is called by xfs_inactive to free any blocks beyond eof
155 * when the link count isn't zero and by xfs_dm_punch_hole() when 150 * when the link count isn't zero and by xfs_dm_punch_hole() when
156 * punching a hole to EOF. 151 * punching a hole to EOF.
@@ -159,7 +154,7 @@ STATIC int
159xfs_free_eofblocks( 154xfs_free_eofblocks(
160 xfs_mount_t *mp, 155 xfs_mount_t *mp,
161 xfs_inode_t *ip, 156 xfs_inode_t *ip,
162 int flags) 157 bool need_iolock)
163{ 158{
164 xfs_trans_t *tp; 159 xfs_trans_t *tp;
165 int error; 160 int error;
@@ -174,7 +169,7 @@ xfs_free_eofblocks(
174 * of the file. If not, then there is nothing to do. 169 * of the file. If not, then there is nothing to do.
175 */ 170 */
176 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip)); 171 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip));
177 last_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp)); 172 last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);
178 if (last_fsb <= end_fsb) 173 if (last_fsb <= end_fsb)
179 return 0; 174 return 0;
180 map_len = last_fsb - end_fsb; 175 map_len = last_fsb - end_fsb;
@@ -201,13 +196,11 @@ xfs_free_eofblocks(
201 */ 196 */
202 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); 197 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);
203 198
204 if (flags & XFS_FREE_EOF_TRYLOCK) { 199 if (need_iolock) {
205 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) { 200 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
206 xfs_trans_cancel(tp, 0); 201 xfs_trans_cancel(tp, 0);
207 return 0; 202 return 0;
208 } 203 }
209 } else {
210 xfs_ilock(ip, XFS_IOLOCK_EXCL);
211 } 204 }
212 205
213 error = xfs_trans_reserve(tp, 0, 206 error = xfs_trans_reserve(tp, 0,
@@ -217,7 +210,8 @@ xfs_free_eofblocks(
217 if (error) { 210 if (error) {
218 ASSERT(XFS_FORCED_SHUTDOWN(mp)); 211 ASSERT(XFS_FORCED_SHUTDOWN(mp));
219 xfs_trans_cancel(tp, 0); 212 xfs_trans_cancel(tp, 0);
220 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 213 if (need_iolock)
214 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
221 return error; 215 return error;
222 } 216 }
223 217
@@ -244,7 +238,10 @@ xfs_free_eofblocks(
244 error = xfs_trans_commit(tp, 238 error = xfs_trans_commit(tp,
245 XFS_TRANS_RELEASE_LOG_RES); 239 XFS_TRANS_RELEASE_LOG_RES);
246 } 240 }
247 xfs_iunlock(ip, XFS_IOLOCK_EXCL|XFS_ILOCK_EXCL); 241
242 xfs_iunlock(ip, XFS_ILOCK_EXCL);
243 if (need_iolock)
244 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
248 } 245 }
249 return error; 246 return error;
250} 247}
@@ -282,23 +279,15 @@ xfs_inactive_symlink_rmt(
282 * free them all in one bunmapi call. 279 * free them all in one bunmapi call.
283 */ 280 */
284 ASSERT(ip->i_d.di_nextents > 0 && ip->i_d.di_nextents <= 2); 281 ASSERT(ip->i_d.di_nextents > 0 && ip->i_d.di_nextents <= 2);
285 if ((error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0, 282
286 XFS_TRANS_PERM_LOG_RES, XFS_ITRUNCATE_LOG_COUNT))) {
287 ASSERT(XFS_FORCED_SHUTDOWN(mp));
288 xfs_trans_cancel(tp, 0);
289 *tpp = NULL;
290 return error;
291 }
292 /* 283 /*
293 * Lock the inode, fix the size, and join it to the transaction. 284 * Lock the inode, fix the size, and join it to the transaction.
294 * Hold it so in the normal path, we still have it locked for 285 * Hold it so in the normal path, we still have it locked for
295 * the second transaction. In the error paths we need it 286 * the second transaction. In the error paths we need it
296 * held so the cancel won't rele it, see below. 287 * held so the cancel won't rele it, see below.
297 */ 288 */
298 xfs_ilock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL);
299 size = (int)ip->i_d.di_size; 289 size = (int)ip->i_d.di_size;
300 ip->i_d.di_size = 0; 290 ip->i_d.di_size = 0;
301 xfs_trans_ijoin(tp, ip, 0);
302 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 291 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
303 /* 292 /*
304 * Find the block(s) so we can inval and unmap them. 293 * Find the block(s) so we can inval and unmap them.
@@ -385,114 +374,14 @@ xfs_inactive_symlink_rmt(
385 ASSERT(XFS_FORCED_SHUTDOWN(mp)); 374 ASSERT(XFS_FORCED_SHUTDOWN(mp));
386 goto error0; 375 goto error0;
387 } 376 }
388 /* 377
389 * Return with the inode locked but not joined to the transaction. 378 xfs_trans_ijoin(tp, ip, 0);
390 */
391 *tpp = tp; 379 *tpp = tp;
392 return 0; 380 return 0;
393 381
394 error1: 382 error1:
395 xfs_bmap_cancel(&free_list); 383 xfs_bmap_cancel(&free_list);
396 error0: 384 error0:
397 /*
398 * Have to come here with the inode locked and either
399 * (held and in the transaction) or (not in the transaction).
400 * If the inode isn't held then cancel would iput it, but
401 * that's wrong since this is inactive and the vnode ref
402 * count is 0 already.
403 * Cancel won't do anything to the inode if held, but it still
404 * needs to be locked until the cancel is done, if it was
405 * joined to the transaction.
406 */
407 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
408 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL);
409 *tpp = NULL;
410 return error;
411
412}
413
414STATIC int
415xfs_inactive_symlink_local(
416 xfs_inode_t *ip,
417 xfs_trans_t **tpp)
418{
419 int error;
420
421 ASSERT(ip->i_d.di_size <= XFS_IFORK_DSIZE(ip));
422 /*
423 * We're freeing a symlink which fit into
424 * the inode. Just free the memory used
425 * to hold the old symlink.
426 */
427 error = xfs_trans_reserve(*tpp, 0,
428 XFS_ITRUNCATE_LOG_RES(ip->i_mount),
429 0, XFS_TRANS_PERM_LOG_RES,
430 XFS_ITRUNCATE_LOG_COUNT);
431
432 if (error) {
433 xfs_trans_cancel(*tpp, 0);
434 *tpp = NULL;
435 return error;
436 }
437 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
438
439 /*
440 * Zero length symlinks _can_ exist.
441 */
442 if (ip->i_df.if_bytes > 0) {
443 xfs_idata_realloc(ip,
444 -(ip->i_df.if_bytes),
445 XFS_DATA_FORK);
446 ASSERT(ip->i_df.if_bytes == 0);
447 }
448 return 0;
449}
450
451STATIC int
452xfs_inactive_attrs(
453 xfs_inode_t *ip,
454 xfs_trans_t **tpp)
455{
456 xfs_trans_t *tp;
457 int error;
458 xfs_mount_t *mp;
459
460 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
461 tp = *tpp;
462 mp = ip->i_mount;
463 ASSERT(ip->i_d.di_forkoff != 0);
464 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
465 xfs_iunlock(ip, XFS_ILOCK_EXCL);
466 if (error)
467 goto error_unlock;
468
469 error = xfs_attr_inactive(ip);
470 if (error)
471 goto error_unlock;
472
473 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);
474 error = xfs_trans_reserve(tp, 0,
475 XFS_IFREE_LOG_RES(mp),
476 0, XFS_TRANS_PERM_LOG_RES,
477 XFS_INACTIVE_LOG_COUNT);
478 if (error)
479 goto error_cancel;
480
481 xfs_ilock(ip, XFS_ILOCK_EXCL);
482 xfs_trans_ijoin(tp, ip, 0);
483 xfs_idestroy_fork(ip, XFS_ATTR_FORK);
484
485 ASSERT(ip->i_d.di_anextents == 0);
486
487 *tpp = tp;
488 return 0;
489
490error_cancel:
491 ASSERT(XFS_FORCED_SHUTDOWN(mp));
492 xfs_trans_cancel(tp, 0);
493error_unlock:
494 *tpp = NULL;
495 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
496 return error; 385 return error;
497} 386}
498 387
@@ -574,8 +463,7 @@ xfs_release(
574 if (xfs_iflags_test(ip, XFS_IDIRTY_RELEASE)) 463 if (xfs_iflags_test(ip, XFS_IDIRTY_RELEASE))
575 return 0; 464 return 0;
576 465
577 error = xfs_free_eofblocks(mp, ip, 466 error = xfs_free_eofblocks(mp, ip, true);
578 XFS_FREE_EOF_TRYLOCK);
579 if (error) 467 if (error)
580 return error; 468 return error;
581 469
@@ -604,7 +492,7 @@ xfs_inactive(
604 xfs_trans_t *tp; 492 xfs_trans_t *tp;
605 xfs_mount_t *mp; 493 xfs_mount_t *mp;
606 int error; 494 int error;
607 int truncate; 495 int truncate = 0;
608 496
609 /* 497 /*
610 * If the inode is already free, then there can be nothing 498 * If the inode is already free, then there can be nothing
@@ -616,17 +504,6 @@ xfs_inactive(
616 return VN_INACTIVE_CACHE; 504 return VN_INACTIVE_CACHE;
617 } 505 }
618 506
619 /*
620 * Only do a truncate if it's a regular file with
621 * some actual space in it. It's OK to look at the
622 * inode's fields without the lock because we're the
623 * only one with a reference to the inode.
624 */
625 truncate = ((ip->i_d.di_nlink == 0) &&
626 ((ip->i_d.di_size != 0) || XFS_ISIZE(ip) != 0 ||
627 (ip->i_d.di_nextents > 0) || (ip->i_delayed_blks > 0)) &&
628 S_ISREG(ip->i_d.di_mode));
629
630 mp = ip->i_mount; 507 mp = ip->i_mount;
631 508
632 error = 0; 509 error = 0;
@@ -643,99 +520,100 @@ xfs_inactive(
643 (!(ip->i_d.di_flags & 520 (!(ip->i_d.di_flags &
644 (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) || 521 (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) ||
645 ip->i_delayed_blks != 0))) { 522 ip->i_delayed_blks != 0))) {
646 error = xfs_free_eofblocks(mp, ip, 0); 523 error = xfs_free_eofblocks(mp, ip, false);
647 if (error) 524 if (error)
648 return VN_INACTIVE_CACHE; 525 return VN_INACTIVE_CACHE;
649 } 526 }
650 goto out; 527 goto out;
651 } 528 }
652 529
653 ASSERT(ip->i_d.di_nlink == 0); 530 if (S_ISREG(ip->i_d.di_mode) &&
531 (ip->i_d.di_size != 0 || XFS_ISIZE(ip) != 0 ||
532 ip->i_d.di_nextents > 0 || ip->i_delayed_blks > 0))
533 truncate = 1;
654 534
655 error = xfs_qm_dqattach(ip, 0); 535 error = xfs_qm_dqattach(ip, 0);
656 if (error) 536 if (error)
657 return VN_INACTIVE_CACHE; 537 return VN_INACTIVE_CACHE;
658 538
659 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); 539 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);
660 if (truncate) { 540 error = xfs_trans_reserve(tp, 0,
661 xfs_ilock(ip, XFS_IOLOCK_EXCL); 541 (truncate || S_ISLNK(ip->i_d.di_mode)) ?
662 542 XFS_ITRUNCATE_LOG_RES(mp) :
663 error = xfs_trans_reserve(tp, 0, 543 XFS_IFREE_LOG_RES(mp),
664 XFS_ITRUNCATE_LOG_RES(mp), 544 0,
665 0, XFS_TRANS_PERM_LOG_RES, 545 XFS_TRANS_PERM_LOG_RES,
666 XFS_ITRUNCATE_LOG_COUNT); 546 XFS_ITRUNCATE_LOG_COUNT);
667 if (error) { 547 if (error) {
668 /* Don't call itruncate_cleanup */ 548 ASSERT(XFS_FORCED_SHUTDOWN(mp));
669 ASSERT(XFS_FORCED_SHUTDOWN(mp)); 549 xfs_trans_cancel(tp, 0);
670 xfs_trans_cancel(tp, 0); 550 return VN_INACTIVE_CACHE;
671 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 551 }
672 return VN_INACTIVE_CACHE;
673 }
674 552
675 xfs_ilock(ip, XFS_ILOCK_EXCL); 553 xfs_ilock(ip, XFS_ILOCK_EXCL);
676 xfs_trans_ijoin(tp, ip, 0); 554 xfs_trans_ijoin(tp, ip, 0);
677 555
556 if (S_ISLNK(ip->i_d.di_mode)) {
557 /*
558 * Zero length symlinks _can_ exist.
559 */
560 if (ip->i_d.di_size > XFS_IFORK_DSIZE(ip)) {
561 error = xfs_inactive_symlink_rmt(ip, &tp);
562 if (error)
563 goto out_cancel;
564 } else if (ip->i_df.if_bytes > 0) {
565 xfs_idata_realloc(ip, -(ip->i_df.if_bytes),
566 XFS_DATA_FORK);
567 ASSERT(ip->i_df.if_bytes == 0);
568 }
569 } else if (truncate) {
678 ip->i_d.di_size = 0; 570 ip->i_d.di_size = 0;
679 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 571 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
680 572
681 error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0); 573 error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0);
682 if (error) { 574 if (error)
683 xfs_trans_cancel(tp, 575 goto out_cancel;
684 XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
685 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL);
686 return VN_INACTIVE_CACHE;
687 }
688 576
689 ASSERT(ip->i_d.di_nextents == 0); 577 ASSERT(ip->i_d.di_nextents == 0);
690 } else if (S_ISLNK(ip->i_d.di_mode)) { 578 }
691 579
692 /* 580 /*
693 * If we get an error while cleaning up a 581 * If there are attributes associated with the file then blow them away
694 * symlink we bail out. 582 * now. The code calls a routine that recursively deconstructs the
695 */ 583 * attribute fork. We need to just commit the current transaction
696 error = (ip->i_d.di_size > XFS_IFORK_DSIZE(ip)) ? 584 * because we can't use it for xfs_attr_inactive().
697 xfs_inactive_symlink_rmt(ip, &tp) : 585 */
698 xfs_inactive_symlink_local(ip, &tp); 586 if (ip->i_d.di_anextents > 0) {
587 ASSERT(ip->i_d.di_forkoff != 0);
699 588
700 if (error) { 589 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
701 ASSERT(tp == NULL); 590 if (error)
702 return VN_INACTIVE_CACHE; 591 goto out_unlock;
703 }
704 592
705 xfs_trans_ijoin(tp, ip, 0); 593 xfs_iunlock(ip, XFS_ILOCK_EXCL);
706 } else { 594
595 error = xfs_attr_inactive(ip);
596 if (error)
597 goto out;
598
599 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);
707 error = xfs_trans_reserve(tp, 0, 600 error = xfs_trans_reserve(tp, 0,
708 XFS_IFREE_LOG_RES(mp), 601 XFS_IFREE_LOG_RES(mp),
709 0, XFS_TRANS_PERM_LOG_RES, 602 0, XFS_TRANS_PERM_LOG_RES,
710 XFS_INACTIVE_LOG_COUNT); 603 XFS_INACTIVE_LOG_COUNT);
711 if (error) { 604 if (error) {
712 ASSERT(XFS_FORCED_SHUTDOWN(mp));
713 xfs_trans_cancel(tp, 0); 605 xfs_trans_cancel(tp, 0);
714 return VN_INACTIVE_CACHE; 606 goto out;
715 } 607 }
716 608
717 xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 609 xfs_ilock(ip, XFS_ILOCK_EXCL);
718 xfs_trans_ijoin(tp, ip, 0); 610 xfs_trans_ijoin(tp, ip, 0);
719 } 611 }
720 612
721 /* 613 if (ip->i_afp)
722 * If there are attributes associated with the file
723 * then blow them away now. The code calls a routine
724 * that recursively deconstructs the attribute fork.
725 * We need to just commit the current transaction
726 * because we can't use it for xfs_attr_inactive().
727 */
728 if (ip->i_d.di_anextents > 0) {
729 error = xfs_inactive_attrs(ip, &tp);
730 /*
731 * If we got an error, the transaction is already
732 * cancelled, and the inode is unlocked. Just get out.
733 */
734 if (error)
735 return VN_INACTIVE_CACHE;
736 } else if (ip->i_afp) {
737 xfs_idestroy_fork(ip, XFS_ATTR_FORK); 614 xfs_idestroy_fork(ip, XFS_ATTR_FORK);
738 } 615
616 ASSERT(ip->i_d.di_anextents == 0);
739 617
740 /* 618 /*
741 * Free the inode. 619 * Free the inode.
@@ -779,10 +657,13 @@ xfs_inactive(
779 * Release the dquots held by inode, if any. 657 * Release the dquots held by inode, if any.
780 */ 658 */
781 xfs_qm_dqdetach(ip); 659 xfs_qm_dqdetach(ip);
782 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 660out_unlock:
783 661 xfs_iunlock(ip, XFS_ILOCK_EXCL);
784 out: 662out:
785 return VN_INACTIVE_CACHE; 663 return VN_INACTIVE_CACHE;
664out_cancel:
665 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
666 goto out_unlock;
786} 667}
787 668
788/* 669/*
@@ -2262,10 +2143,10 @@ xfs_change_file_space(
2262 2143
2263 llen = bf->l_len > 0 ? bf->l_len - 1 : bf->l_len; 2144 llen = bf->l_len > 0 ? bf->l_len - 1 : bf->l_len;
2264 2145
2265 if ( (bf->l_start < 0) 2146 if (bf->l_start < 0 ||
2266 || (bf->l_start > XFS_MAXIOFFSET(mp)) 2147 bf->l_start > mp->m_super->s_maxbytes ||
2267 || (bf->l_start + llen < 0) 2148 bf->l_start + llen < 0 ||
2268 || (bf->l_start + llen > XFS_MAXIOFFSET(mp))) 2149 bf->l_start + llen > mp->m_super->s_maxbytes)
2269 return XFS_ERROR(EINVAL); 2150 return XFS_ERROR(EINVAL);
2270 2151
2271 bf->l_whence = 0; 2152 bf->l_whence = 0;
diff --git a/include/asm-generic/dma-coherent.h b/include/asm-generic/dma-coherent.h
index abfb2682de7f..2be8a2dbc868 100644
--- a/include/asm-generic/dma-coherent.h
+++ b/include/asm-generic/dma-coherent.h
@@ -29,6 +29,7 @@ dma_mark_declared_memory_occupied(struct device *dev,
29#else 29#else
30#define dma_alloc_from_coherent(dev, size, handle, ret) (0) 30#define dma_alloc_from_coherent(dev, size, handle, ret) (0)
31#define dma_release_from_coherent(dev, order, vaddr) (0) 31#define dma_release_from_coherent(dev, order, vaddr) (0)
32#define dma_mmap_from_coherent(dev, vma, vaddr, order, ret) (0)
32#endif 33#endif
33 34
34#endif 35#endif
diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index 2e248d8924dc..de8bf89940f8 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -176,4 +176,59 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
176#define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL) 176#define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL)
177#define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL) 177#define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL)
178 178
179extern int dma_common_mmap(struct device *dev, struct vm_area_struct *vma,
180 void *cpu_addr, dma_addr_t dma_addr, size_t size);
181
182/**
183 * dma_mmap_attrs - map a coherent DMA allocation into user space
184 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
185 * @vma: vm_area_struct describing requested user mapping
186 * @cpu_addr: kernel CPU-view address returned from dma_alloc_attrs
187 * @handle: device-view address returned from dma_alloc_attrs
188 * @size: size of memory originally requested in dma_alloc_attrs
189 * @attrs: attributes of mapping properties requested in dma_alloc_attrs
190 *
191 * Map a coherent DMA buffer previously allocated by dma_alloc_attrs
192 * into user space. The coherent DMA buffer must not be freed by the
193 * driver until the user space mapping has been released.
194 */
195static inline int
196dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, void *cpu_addr,
197 dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs)
198{
199 struct dma_map_ops *ops = get_dma_ops(dev);
200 BUG_ON(!ops);
201 if (ops->mmap)
202 return ops->mmap(dev, vma, cpu_addr, dma_addr, size, attrs);
203 return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size);
204}
205
206#define dma_mmap_coherent(d, v, c, h, s) dma_mmap_attrs(d, v, c, h, s, NULL)
207
208static inline int dma_mmap_writecombine(struct device *dev, struct vm_area_struct *vma,
209 void *cpu_addr, dma_addr_t dma_addr, size_t size)
210{
211 DEFINE_DMA_ATTRS(attrs);
212 dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
213 return dma_mmap_attrs(dev, vma, cpu_addr, dma_addr, size, &attrs);
214}
215
216int
217dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
218 void *cpu_addr, dma_addr_t dma_addr, size_t size);
219
220static inline int
221dma_get_sgtable_attrs(struct device *dev, struct sg_table *sgt, void *cpu_addr,
222 dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs)
223{
224 struct dma_map_ops *ops = get_dma_ops(dev);
225 BUG_ON(!ops);
226 if (ops->get_sgtable)
227 return ops->get_sgtable(dev, sgt, cpu_addr, dma_addr, size,
228 attrs);
229 return dma_common_get_sgtable(dev, sgt, cpu_addr, dma_addr, size);
230}
231
232#define dma_get_sgtable(d, t, v, h, s) dma_get_sgtable_attrs(d, t, v, h, s, NULL)
233
179#endif 234#endif
diff --git a/include/drm/exynos_drm.h b/include/drm/exynos_drm.h
index 68733587e700..c20b00181530 100644
--- a/include/drm/exynos_drm.h
+++ b/include/drm/exynos_drm.h
@@ -107,11 +107,6 @@ struct drm_exynos_vidi_connection {
107 uint64_t edid; 107 uint64_t edid;
108}; 108};
109 109
110struct drm_exynos_plane_set_zpos {
111 __u32 plane_id;
112 __s32 zpos;
113};
114
115/* memory type definitions. */ 110/* memory type definitions. */
116enum e_drm_exynos_gem_mem_type { 111enum e_drm_exynos_gem_mem_type {
117 /* Physically Continuous memory and used as default. */ 112 /* Physically Continuous memory and used as default. */
@@ -164,7 +159,6 @@ struct drm_exynos_g2d_exec {
164#define DRM_EXYNOS_GEM_MMAP 0x02 159#define DRM_EXYNOS_GEM_MMAP 0x02
165/* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */ 160/* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */
166#define DRM_EXYNOS_GEM_GET 0x04 161#define DRM_EXYNOS_GEM_GET 0x04
167#define DRM_EXYNOS_PLANE_SET_ZPOS 0x06
168#define DRM_EXYNOS_VIDI_CONNECTION 0x07 162#define DRM_EXYNOS_VIDI_CONNECTION 0x07
169 163
170/* G2D */ 164/* G2D */
@@ -184,9 +178,6 @@ struct drm_exynos_g2d_exec {
184#define DRM_IOCTL_EXYNOS_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \ 178#define DRM_IOCTL_EXYNOS_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \
185 DRM_EXYNOS_GEM_GET, struct drm_exynos_gem_info) 179 DRM_EXYNOS_GEM_GET, struct drm_exynos_gem_info)
186 180
187#define DRM_IOCTL_EXYNOS_PLANE_SET_ZPOS DRM_IOWR(DRM_COMMAND_BASE + \
188 DRM_EXYNOS_PLANE_SET_ZPOS, struct drm_exynos_plane_set_zpos)
189
190#define DRM_IOCTL_EXYNOS_VIDI_CONNECTION DRM_IOWR(DRM_COMMAND_BASE + \ 181#define DRM_IOCTL_EXYNOS_VIDI_CONNECTION DRM_IOWR(DRM_COMMAND_BASE + \
191 DRM_EXYNOS_VIDI_CONNECTION, struct drm_exynos_vidi_connection) 182 DRM_EXYNOS_VIDI_CONNECTION, struct drm_exynos_vidi_connection)
192 183
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index b2b4d2ad7103..3ad510b25283 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -190,6 +190,8 @@ extern bool wmi_has_guid(const char *guid);
190 190
191extern long acpi_video_get_capabilities(acpi_handle graphics_dev_handle); 191extern long acpi_video_get_capabilities(acpi_handle graphics_dev_handle);
192extern long acpi_is_video_device(struct acpi_device *device); 192extern long acpi_is_video_device(struct acpi_device *device);
193extern void acpi_video_dmi_promote_vendor(void);
194extern void acpi_video_dmi_demote_vendor(void);
193extern int acpi_video_backlight_support(void); 195extern int acpi_video_backlight_support(void);
194extern int acpi_video_display_switch_support(void); 196extern int acpi_video_display_switch_support(void);
195 197
@@ -205,6 +207,14 @@ static inline long acpi_is_video_device(struct acpi_device *device)
205 return 0; 207 return 0;
206} 208}
207 209
210static inline void acpi_video_dmi_promote_vendor(void)
211{
212}
213
214static inline void acpi_video_dmi_demote_vendor(void)
215{
216}
217
208static inline int acpi_video_backlight_support(void) 218static inline int acpi_video_backlight_support(void)
209{ 219{
210 return 0; 220 return 0;
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 98f34b886f95..38d27a10aa5d 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -66,14 +66,13 @@ typedef int (*dm_request_endio_fn) (struct dm_target *ti,
66 struct request *clone, int error, 66 struct request *clone, int error,
67 union map_info *map_context); 67 union map_info *map_context);
68 68
69typedef void (*dm_flush_fn) (struct dm_target *ti);
70typedef void (*dm_presuspend_fn) (struct dm_target *ti); 69typedef void (*dm_presuspend_fn) (struct dm_target *ti);
71typedef void (*dm_postsuspend_fn) (struct dm_target *ti); 70typedef void (*dm_postsuspend_fn) (struct dm_target *ti);
72typedef int (*dm_preresume_fn) (struct dm_target *ti); 71typedef int (*dm_preresume_fn) (struct dm_target *ti);
73typedef void (*dm_resume_fn) (struct dm_target *ti); 72typedef void (*dm_resume_fn) (struct dm_target *ti);
74 73
75typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type, 74typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type,
76 char *result, unsigned int maxlen); 75 unsigned status_flags, char *result, unsigned maxlen);
77 76
78typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv); 77typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv);
79 78
@@ -139,7 +138,6 @@ struct target_type {
139 dm_map_request_fn map_rq; 138 dm_map_request_fn map_rq;
140 dm_endio_fn end_io; 139 dm_endio_fn end_io;
141 dm_request_endio_fn rq_end_io; 140 dm_request_endio_fn rq_end_io;
142 dm_flush_fn flush;
143 dm_presuspend_fn presuspend; 141 dm_presuspend_fn presuspend;
144 dm_postsuspend_fn postsuspend; 142 dm_postsuspend_fn postsuspend;
145 dm_preresume_fn preresume; 143 dm_preresume_fn preresume;
@@ -188,8 +186,8 @@ struct dm_target {
188 sector_t begin; 186 sector_t begin;
189 sector_t len; 187 sector_t len;
190 188
191 /* Always a power of 2 */ 189 /* If non-zero, maximum size of I/O submitted to a target. */
192 sector_t split_io; 190 uint32_t max_io_len;
193 191
194 /* 192 /*
195 * A number of zero-length barrier requests that will be submitted 193 * A number of zero-length barrier requests that will be submitted
@@ -214,15 +212,27 @@ struct dm_target {
214 char *error; 212 char *error;
215 213
216 /* 214 /*
215 * Set if this target needs to receive flushes regardless of
216 * whether or not its underlying devices have support.
217 */
218 bool flush_supported:1;
219
220 /*
217 * Set if this target needs to receive discards regardless of 221 * Set if this target needs to receive discards regardless of
218 * whether or not its underlying devices have support. 222 * whether or not its underlying devices have support.
219 */ 223 */
220 unsigned discards_supported:1; 224 bool discards_supported:1;
225
226 /*
227 * Set if the target required discard request to be split
228 * on max_io_len boundary.
229 */
230 bool split_discard_requests:1;
221 231
222 /* 232 /*
223 * Set if this target does not return zeroes on discarded blocks. 233 * Set if this target does not return zeroes on discarded blocks.
224 */ 234 */
225 unsigned discard_zeroes_data_unsupported:1; 235 bool discard_zeroes_data_unsupported:1;
226}; 236};
227 237
228/* Each target can link one of these into the table */ 238/* Each target can link one of these into the table */
@@ -360,6 +370,11 @@ void dm_table_add_target_callbacks(struct dm_table *t, struct dm_target_callback
360int dm_table_complete(struct dm_table *t); 370int dm_table_complete(struct dm_table *t);
361 371
362/* 372/*
373 * Target may require that it is never sent I/O larger than len.
374 */
375int __must_check dm_set_target_max_io_len(struct dm_target *ti, sector_t len);
376
377/*
363 * Table reference counting. 378 * Table reference counting.
364 */ 379 */
365struct dm_table *dm_get_live_table(struct mapped_device *md); 380struct dm_table *dm_get_live_table(struct mapped_device *md);
diff --git a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h
index 75fd5573516e..91e3a360f611 100644
--- a/include/linux/dm-ioctl.h
+++ b/include/linux/dm-ioctl.h
@@ -267,9 +267,9 @@ enum {
267#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) 267#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
268 268
269#define DM_VERSION_MAJOR 4 269#define DM_VERSION_MAJOR 4
270#define DM_VERSION_MINOR 22 270#define DM_VERSION_MINOR 23
271#define DM_VERSION_PATCHLEVEL 0 271#define DM_VERSION_PATCHLEVEL 0
272#define DM_VERSION_EXTRA "-ioctl (2011-10-19)" 272#define DM_VERSION_EXTRA "-ioctl (2012-07-25)"
273 273
274/* Status bits */ 274/* Status bits */
275#define DM_READONLY_FLAG (1 << 0) /* In/Out */ 275#define DM_READONLY_FLAG (1 << 0) /* In/Out */
@@ -307,6 +307,8 @@ enum {
307 307
308/* 308/*
309 * Set this to suspend without flushing queued ios. 309 * Set this to suspend without flushing queued ios.
310 * Also disables flushing uncommitted changes in the thin target before
311 * generating statistics for DM_TABLE_STATUS and DM_DEV_WAIT.
310 */ 312 */
311#define DM_NOFLUSH_FLAG (1 << 11) /* In */ 313#define DM_NOFLUSH_FLAG (1 << 11) /* In */
312 314
diff --git a/include/linux/dma-attrs.h b/include/linux/dma-attrs.h
index 547ab568d3ae..f83f793223ff 100644
--- a/include/linux/dma-attrs.h
+++ b/include/linux/dma-attrs.h
@@ -15,6 +15,8 @@ enum dma_attr {
15 DMA_ATTR_WEAK_ORDERING, 15 DMA_ATTR_WEAK_ORDERING,
16 DMA_ATTR_WRITE_COMBINE, 16 DMA_ATTR_WRITE_COMBINE,
17 DMA_ATTR_NON_CONSISTENT, 17 DMA_ATTR_NON_CONSISTENT,
18 DMA_ATTR_NO_KERNEL_MAPPING,
19 DMA_ATTR_SKIP_CPU_SYNC,
18 DMA_ATTR_MAX, 20 DMA_ATTR_MAX,
19}; 21};
20 22
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index dfc099e56a66..94af41858513 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -18,6 +18,9 @@ struct dma_map_ops {
18 int (*mmap)(struct device *, struct vm_area_struct *, 18 int (*mmap)(struct device *, struct vm_area_struct *,
19 void *, dma_addr_t, size_t, struct dma_attrs *attrs); 19 void *, dma_addr_t, size_t, struct dma_attrs *attrs);
20 20
21 int (*get_sgtable)(struct device *dev, struct sg_table *sgt, void *,
22 dma_addr_t, size_t, struct dma_attrs *attrs);
23
21 dma_addr_t (*map_page)(struct device *dev, struct page *page, 24 dma_addr_t (*map_page)(struct device *dev, struct page *page,
22 unsigned long offset, size_t size, 25 unsigned long offset, size_t size,
23 enum dma_data_direction dir, 26 enum dma_data_direction dir,
diff --git a/include/linux/edac.h b/include/linux/edac.h
index 91ba3bae42ee..bab9f8473dc1 100644
--- a/include/linux/edac.h
+++ b/include/linux/edac.h
@@ -13,9 +13,11 @@
13#define _LINUX_EDAC_H_ 13#define _LINUX_EDAC_H_
14 14
15#include <linux/atomic.h> 15#include <linux/atomic.h>
16#include <linux/device.h>
16#include <linux/kobject.h> 17#include <linux/kobject.h>
17#include <linux/completion.h> 18#include <linux/completion.h>
18#include <linux/workqueue.h> 19#include <linux/workqueue.h>
20#include <linux/debugfs.h>
19 21
20struct device; 22struct device;
21 23
@@ -49,7 +51,19 @@ static inline void opstate_init(void)
49#define EDAC_MC_LABEL_LEN 31 51#define EDAC_MC_LABEL_LEN 31
50#define MC_PROC_NAME_MAX_LEN 7 52#define MC_PROC_NAME_MAX_LEN 7
51 53
52/* memory devices */ 54/**
55 * enum dev_type - describe the type of memory DRAM chips used at the stick
56 * @DEV_UNKNOWN: Can't be determined, or MC doesn't support detect it
57 * @DEV_X1: 1 bit for data
58 * @DEV_X2: 2 bits for data
59 * @DEV_X4: 4 bits for data
60 * @DEV_X8: 8 bits for data
61 * @DEV_X16: 16 bits for data
62 * @DEV_X32: 32 bits for data
63 * @DEV_X64: 64 bits for data
64 *
65 * Typical values are x4 and x8.
66 */
53enum dev_type { 67enum dev_type {
54 DEV_UNKNOWN = 0, 68 DEV_UNKNOWN = 0,
55 DEV_X1, 69 DEV_X1,
@@ -167,18 +181,30 @@ enum mem_type {
167#define MEM_FLAG_DDR3 BIT(MEM_DDR3) 181#define MEM_FLAG_DDR3 BIT(MEM_DDR3)
168#define MEM_FLAG_RDDR3 BIT(MEM_RDDR3) 182#define MEM_FLAG_RDDR3 BIT(MEM_RDDR3)
169 183
170/* chipset Error Detection and Correction capabilities and mode */ 184/**
185 * enum edac-type - Error Detection and Correction capabilities and mode
186 * @EDAC_UNKNOWN: Unknown if ECC is available
187 * @EDAC_NONE: Doesn't support ECC
188 * @EDAC_RESERVED: Reserved ECC type
189 * @EDAC_PARITY: Detects parity errors
190 * @EDAC_EC: Error Checking - no correction
191 * @EDAC_SECDED: Single bit error correction, Double detection
192 * @EDAC_S2ECD2ED: Chipkill x2 devices - do these exist?
193 * @EDAC_S4ECD4ED: Chipkill x4 devices
194 * @EDAC_S8ECD8ED: Chipkill x8 devices
195 * @EDAC_S16ECD16ED: Chipkill x16 devices
196 */
171enum edac_type { 197enum edac_type {
172 EDAC_UNKNOWN = 0, /* Unknown if ECC is available */ 198 EDAC_UNKNOWN = 0,
173 EDAC_NONE, /* Doesn't support ECC */ 199 EDAC_NONE,
174 EDAC_RESERVED, /* Reserved ECC type */ 200 EDAC_RESERVED,
175 EDAC_PARITY, /* Detects parity errors */ 201 EDAC_PARITY,
176 EDAC_EC, /* Error Checking - no correction */ 202 EDAC_EC,
177 EDAC_SECDED, /* Single bit error correction, Double detection */ 203 EDAC_SECDED,
178 EDAC_S2ECD2ED, /* Chipkill x2 devices - do these exist? */ 204 EDAC_S2ECD2ED,
179 EDAC_S4ECD4ED, /* Chipkill x4 devices */ 205 EDAC_S4ECD4ED,
180 EDAC_S8ECD8ED, /* Chipkill x8 devices */ 206 EDAC_S8ECD8ED,
181 EDAC_S16ECD16ED, /* Chipkill x16 devices */ 207 EDAC_S16ECD16ED,
182}; 208};
183 209
184#define EDAC_FLAG_UNKNOWN BIT(EDAC_UNKNOWN) 210#define EDAC_FLAG_UNKNOWN BIT(EDAC_UNKNOWN)
@@ -191,18 +217,30 @@ enum edac_type {
191#define EDAC_FLAG_S8ECD8ED BIT(EDAC_S8ECD8ED) 217#define EDAC_FLAG_S8ECD8ED BIT(EDAC_S8ECD8ED)
192#define EDAC_FLAG_S16ECD16ED BIT(EDAC_S16ECD16ED) 218#define EDAC_FLAG_S16ECD16ED BIT(EDAC_S16ECD16ED)
193 219
194/* scrubbing capabilities */ 220/**
221 * enum scrub_type - scrubbing capabilities
222 * @SCRUB_UNKNOWN Unknown if scrubber is available
223 * @SCRUB_NONE: No scrubber
224 * @SCRUB_SW_PROG: SW progressive (sequential) scrubbing
225 * @SCRUB_SW_SRC: Software scrub only errors
226 * @SCRUB_SW_PROG_SRC: Progressive software scrub from an error
227 * @SCRUB_SW_TUNABLE: Software scrub frequency is tunable
228 * @SCRUB_HW_PROG: HW progressive (sequential) scrubbing
229 * @SCRUB_HW_SRC: Hardware scrub only errors
230 * @SCRUB_HW_PROG_SRC: Progressive hardware scrub from an error
231 * SCRUB_HW_TUNABLE: Hardware scrub frequency is tunable
232 */
195enum scrub_type { 233enum scrub_type {
196 SCRUB_UNKNOWN = 0, /* Unknown if scrubber is available */ 234 SCRUB_UNKNOWN = 0,
197 SCRUB_NONE, /* No scrubber */ 235 SCRUB_NONE,
198 SCRUB_SW_PROG, /* SW progressive (sequential) scrubbing */ 236 SCRUB_SW_PROG,
199 SCRUB_SW_SRC, /* Software scrub only errors */ 237 SCRUB_SW_SRC,
200 SCRUB_SW_PROG_SRC, /* Progressive software scrub from an error */ 238 SCRUB_SW_PROG_SRC,
201 SCRUB_SW_TUNABLE, /* Software scrub frequency is tunable */ 239 SCRUB_SW_TUNABLE,
202 SCRUB_HW_PROG, /* HW progressive (sequential) scrubbing */ 240 SCRUB_HW_PROG,
203 SCRUB_HW_SRC, /* Hardware scrub only errors */ 241 SCRUB_HW_SRC,
204 SCRUB_HW_PROG_SRC, /* Progressive hardware scrub from an error */ 242 SCRUB_HW_PROG_SRC,
205 SCRUB_HW_TUNABLE /* Hardware scrub frequency is tunable */ 243 SCRUB_HW_TUNABLE
206}; 244};
207 245
208#define SCRUB_FLAG_SW_PROG BIT(SCRUB_SW_PROG) 246#define SCRUB_FLAG_SW_PROG BIT(SCRUB_SW_PROG)
@@ -374,23 +412,21 @@ struct edac_mc_layer {
374#define EDAC_MAX_LAYERS 3 412#define EDAC_MAX_LAYERS 3
375 413
376/** 414/**
377 * EDAC_DIMM_PTR - Macro responsible to find a pointer inside a pointer array 415 * EDAC_DIMM_OFF - Macro responsible to get a pointer offset inside a pointer array
378 * for the element given by [layer0,layer1,layer2] position 416 * for the element given by [layer0,layer1,layer2] position
379 * 417 *
380 * @layers: a struct edac_mc_layer array, describing how many elements 418 * @layers: a struct edac_mc_layer array, describing how many elements
381 * were allocated for each layer 419 * were allocated for each layer
382 * @var: name of the var where we want to get the pointer
383 * (like mci->dimms)
384 * @n_layers: Number of layers at the @layers array 420 * @n_layers: Number of layers at the @layers array
385 * @layer0: layer0 position 421 * @layer0: layer0 position
386 * @layer1: layer1 position. Unused if n_layers < 2 422 * @layer1: layer1 position. Unused if n_layers < 2
387 * @layer2: layer2 position. Unused if n_layers < 3 423 * @layer2: layer2 position. Unused if n_layers < 3
388 * 424 *
389 * For 1 layer, this macro returns &var[layer0] 425 * For 1 layer, this macro returns &var[layer0] - &var
390 * For 2 layers, this macro is similar to allocate a bi-dimensional array 426 * For 2 layers, this macro is similar to allocate a bi-dimensional array
391 * and to return "&var[layer0][layer1]" 427 * and to return "&var[layer0][layer1] - &var"
392 * For 3 layers, this macro is similar to allocate a tri-dimensional array 428 * For 3 layers, this macro is similar to allocate a tri-dimensional array
393 * and to return "&var[layer0][layer1][layer2]" 429 * and to return "&var[layer0][layer1][layer2] - &var"
394 * 430 *
395 * A loop could be used here to make it more generic, but, as we only have 431 * A loop could be used here to make it more generic, but, as we only have
396 * 3 layers, this is a little faster. 432 * 3 layers, this is a little faster.
@@ -398,23 +434,52 @@ struct edac_mc_layer {
398 * a NULL is returned, causing an OOPS during the memory allocation routine, 434 * a NULL is returned, causing an OOPS during the memory allocation routine,
399 * with would point to the developer that he's doing something wrong. 435 * with would point to the developer that he's doing something wrong.
400 */ 436 */
401#define EDAC_DIMM_PTR(layers, var, nlayers, layer0, layer1, layer2) ({ \ 437#define EDAC_DIMM_OFF(layers, nlayers, layer0, layer1, layer2) ({ \
402 typeof(var) __p; \ 438 int __i; \
403 if ((nlayers) == 1) \ 439 if ((nlayers) == 1) \
404 __p = &var[layer0]; \ 440 __i = layer0; \
405 else if ((nlayers) == 2) \ 441 else if ((nlayers) == 2) \
406 __p = &var[(layer1) + ((layers[1]).size * (layer0))]; \ 442 __i = (layer1) + ((layers[1]).size * (layer0)); \
407 else if ((nlayers) == 3) \ 443 else if ((nlayers) == 3) \
408 __p = &var[(layer2) + ((layers[2]).size * ((layer1) + \ 444 __i = (layer2) + ((layers[2]).size * ((layer1) + \
409 ((layers[1]).size * (layer0))))]; \ 445 ((layers[1]).size * (layer0)))); \
410 else \ 446 else \
447 __i = -EINVAL; \
448 __i; \
449})
450
451/**
452 * EDAC_DIMM_PTR - Macro responsible to get a pointer inside a pointer array
453 * for the element given by [layer0,layer1,layer2] position
454 *
455 * @layers: a struct edac_mc_layer array, describing how many elements
456 * were allocated for each layer
457 * @var: name of the var where we want to get the pointer
458 * (like mci->dimms)
459 * @n_layers: Number of layers at the @layers array
460 * @layer0: layer0 position
461 * @layer1: layer1 position. Unused if n_layers < 2
462 * @layer2: layer2 position. Unused if n_layers < 3
463 *
464 * For 1 layer, this macro returns &var[layer0]
465 * For 2 layers, this macro is similar to allocate a bi-dimensional array
466 * and to return "&var[layer0][layer1]"
467 * For 3 layers, this macro is similar to allocate a tri-dimensional array
468 * and to return "&var[layer0][layer1][layer2]"
469 */
470#define EDAC_DIMM_PTR(layers, var, nlayers, layer0, layer1, layer2) ({ \
471 typeof(*var) __p; \
472 int ___i = EDAC_DIMM_OFF(layers, nlayers, layer0, layer1, layer2); \
473 if (___i < 0) \
411 __p = NULL; \ 474 __p = NULL; \
475 else \
476 __p = (var)[___i]; \
412 __p; \ 477 __p; \
413}) 478})
414 479
415
416/* FIXME: add the proper per-location error counts */
417struct dimm_info { 480struct dimm_info {
481 struct device dev;
482
418 char label[EDAC_MC_LABEL_LEN + 1]; /* DIMM label on motherboard */ 483 char label[EDAC_MC_LABEL_LEN + 1]; /* DIMM label on motherboard */
419 484
420 /* Memory location data */ 485 /* Memory location data */
@@ -456,6 +521,8 @@ struct rank_info {
456}; 521};
457 522
458struct csrow_info { 523struct csrow_info {
524 struct device dev;
525
459 /* Used only by edac_mc_find_csrow_by_page() */ 526 /* Used only by edac_mc_find_csrow_by_page() */
460 unsigned long first_page; /* first page number in csrow */ 527 unsigned long first_page; /* first page number in csrow */
461 unsigned long last_page; /* last page number in csrow */ 528 unsigned long last_page; /* last page number in csrow */
@@ -469,44 +536,26 @@ struct csrow_info {
469 536
470 struct mem_ctl_info *mci; /* the parent */ 537 struct mem_ctl_info *mci; /* the parent */
471 538
472 struct kobject kobj; /* sysfs kobject for this csrow */
473
474 /* channel information for this csrow */ 539 /* channel information for this csrow */
475 u32 nr_channels; 540 u32 nr_channels;
476 struct rank_info *channels; 541 struct rank_info **channels;
477}; 542};
478 543
479struct mcidev_sysfs_group { 544/*
480 const char *name; /* group name */ 545 * struct errcount_attribute - used to store the several error counts
481 const struct mcidev_sysfs_attribute *mcidev_attr; /* group attributes */
482};
483
484struct mcidev_sysfs_group_kobj {
485 struct list_head list; /* list for all instances within a mc */
486
487 struct kobject kobj; /* kobj for the group */
488
489 const struct mcidev_sysfs_group *grp; /* group description table */
490 struct mem_ctl_info *mci; /* the parent */
491};
492
493/* mcidev_sysfs_attribute structure
494 * used for driver sysfs attributes and in mem_ctl_info
495 * sysfs top level entries
496 */ 546 */
497struct mcidev_sysfs_attribute { 547struct errcount_attribute_data {
498 /* It should use either attr or grp */ 548 int n_layers;
499 struct attribute attr; 549 int pos[EDAC_MAX_LAYERS];
500 const struct mcidev_sysfs_group *grp; /* Points to a group of attributes */ 550 int layer0, layer1, layer2;
501
502 /* Ops for show/store values at the attribute - not used on group */
503 ssize_t (*show)(struct mem_ctl_info *,char *);
504 ssize_t (*store)(struct mem_ctl_info *, const char *,size_t);
505}; 551};
506 552
507/* MEMORY controller information structure 553/* MEMORY controller information structure
508 */ 554 */
509struct mem_ctl_info { 555struct mem_ctl_info {
556 struct device dev;
557 struct bus_type bus;
558
510 struct list_head link; /* for global list of mem_ctl_info structs */ 559 struct list_head link; /* for global list of mem_ctl_info structs */
511 560
512 struct module *owner; /* Module owner of this control struct */ 561 struct module *owner; /* Module owner of this control struct */
@@ -548,10 +597,18 @@ struct mem_ctl_info {
548 unsigned long (*ctl_page_to_phys) (struct mem_ctl_info * mci, 597 unsigned long (*ctl_page_to_phys) (struct mem_ctl_info * mci,
549 unsigned long page); 598 unsigned long page);
550 int mc_idx; 599 int mc_idx;
551 struct csrow_info *csrows; 600 struct csrow_info **csrows;
552 unsigned nr_csrows, num_cschannel; 601 unsigned nr_csrows, num_cschannel;
553 602
554 /* Memory Controller hierarchy */ 603 /*
604 * Memory Controller hierarchy
605 *
606 * There are basically two types of memory controller: the ones that
607 * sees memory sticks ("dimms"), and the ones that sees memory ranks.
608 * All old memory controllers enumerate memories per rank, but most
609 * of the recent drivers enumerate memories per DIMM, instead.
610 * When the memory controller is per rank, mem_is_per_rank is true.
611 */
555 unsigned n_layers; 612 unsigned n_layers;
556 struct edac_mc_layer *layers; 613 struct edac_mc_layer *layers;
557 bool mem_is_per_rank; 614 bool mem_is_per_rank;
@@ -560,14 +617,14 @@ struct mem_ctl_info {
560 * DIMM info. Will eventually remove the entire csrows_info some day 617 * DIMM info. Will eventually remove the entire csrows_info some day
561 */ 618 */
562 unsigned tot_dimms; 619 unsigned tot_dimms;
563 struct dimm_info *dimms; 620 struct dimm_info **dimms;
564 621
565 /* 622 /*
566 * FIXME - what about controllers on other busses? - IDs must be 623 * FIXME - what about controllers on other busses? - IDs must be
567 * unique. dev pointer should be sufficiently unique, but 624 * unique. dev pointer should be sufficiently unique, but
568 * BUS:SLOT.FUNC numbers may not be unique. 625 * BUS:SLOT.FUNC numbers may not be unique.
569 */ 626 */
570 struct device *dev; 627 struct device *pdev;
571 const char *mod_name; 628 const char *mod_name;
572 const char *mod_ver; 629 const char *mod_ver;
573 const char *ctl_name; 630 const char *ctl_name;
@@ -586,12 +643,6 @@ struct mem_ctl_info {
586 643
587 struct completion complete; 644 struct completion complete;
588 645
589 /* edac sysfs device control */
590 struct kobject edac_mci_kobj;
591
592 /* list for all grp instances within a mc */
593 struct list_head grp_kobj_list;
594
595 /* Additional top controller level attributes, but specified 646 /* Additional top controller level attributes, but specified
596 * by the low level driver. 647 * by the low level driver.
597 * 648 *
@@ -609,6 +660,13 @@ struct mem_ctl_info {
609 660
610 /* the internal state of this controller instance */ 661 /* the internal state of this controller instance */
611 int op_state; 662 int op_state;
663
664#ifdef CONFIG_EDAC_DEBUG
665 struct dentry *debugfs;
666 u8 fake_inject_layer[EDAC_MAX_LAYERS];
667 u32 fake_inject_ue;
668 u16 fake_inject_count;
669#endif
612}; 670};
613 671
614#endif 672#endif
diff --git a/include/linux/firewire.h b/include/linux/firewire.h
index 7edcf1031718..db04ec5121cb 100644
--- a/include/linux/firewire.h
+++ b/include/linux/firewire.h
@@ -152,7 +152,7 @@ static inline void fw_card_put(struct fw_card *card)
152struct fw_attribute_group { 152struct fw_attribute_group {
153 struct attribute_group *groups[2]; 153 struct attribute_group *groups[2];
154 struct attribute_group group; 154 struct attribute_group group;
155 struct attribute *attrs[12]; 155 struct attribute *attrs[13];
156}; 156};
157 157
158enum fw_device_state { 158enum fw_device_state {
@@ -321,7 +321,7 @@ struct fw_transaction {
321 321
322struct fw_address_handler { 322struct fw_address_handler {
323 u64 offset; 323 u64 offset;
324 size_t length; 324 u64 length;
325 fw_address_callback_t address_callback; 325 fw_address_callback_t address_callback;
326 void *callback_data; 326 void *callback_data;
327 struct list_head link; 327 struct list_head link;
diff --git a/include/linux/input/edt-ft5x06.h b/include/linux/input/edt-ft5x06.h
new file mode 100644
index 000000000000..8a1e0d1a0124
--- /dev/null
+++ b/include/linux/input/edt-ft5x06.h
@@ -0,0 +1,24 @@
1#ifndef _EDT_FT5X06_H
2#define _EDT_FT5X06_H
3
4/*
5 * Copyright (c) 2012 Simon Budig, <simon.budig@kernelconcepts.de>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 */
11
12struct edt_ft5x06_platform_data {
13 int irq_pin;
14 int reset_pin;
15
16 /* startup defaults for operational parameters */
17 bool use_parameters;
18 u8 gain;
19 u8 threshold;
20 u8 offset;
21 u8 report_rate;
22};
23
24#endif /* _EDT_FT5X06_H */
diff --git a/include/linux/key-type.h b/include/linux/key-type.h
index 39e3c082c49d..f0c651cda7b0 100644
--- a/include/linux/key-type.h
+++ b/include/linux/key-type.h
@@ -13,6 +13,7 @@
13#define _LINUX_KEY_TYPE_H 13#define _LINUX_KEY_TYPE_H
14 14
15#include <linux/key.h> 15#include <linux/key.h>
16#include <linux/errno.h>
16 17
17#ifdef CONFIG_KEYS 18#ifdef CONFIG_KEYS
18 19
diff --git a/include/linux/libfdt.h b/include/linux/libfdt.h
new file mode 100644
index 000000000000..4c0306c69b4e
--- /dev/null
+++ b/include/linux/libfdt.h
@@ -0,0 +1,8 @@
1#ifndef _INCLUDE_LIBFDT_H_
2#define _INCLUDE_LIBFDT_H_
3
4#include <linux/libfdt_env.h>
5#include "../../scripts/dtc/libfdt/fdt.h"
6#include "../../scripts/dtc/libfdt/libfdt.h"
7
8#endif /* _INCLUDE_LIBFDT_H_ */
diff --git a/include/linux/libfdt_env.h b/include/linux/libfdt_env.h
new file mode 100644
index 000000000000..01508c7b8c81
--- /dev/null
+++ b/include/linux/libfdt_env.h
@@ -0,0 +1,13 @@
1#ifndef _LIBFDT_ENV_H
2#define _LIBFDT_ENV_H
3
4#include <linux/string.h>
5
6#include <asm/byteorder.h>
7
8#define fdt32_to_cpu(x) be32_to_cpu(x)
9#define cpu_to_fdt32(x) cpu_to_be32(x)
10#define fdt64_to_cpu(x) be64_to_cpu(x)
11#define cpu_to_fdt64(x) cpu_to_be64(x)
12
13#endif /* _LIBFDT_ENV_H */
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index 4aa42732e47f..95b738c7abff 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -215,7 +215,7 @@ extern struct zonelist *huge_zonelist(struct vm_area_struct *vma,
215extern bool init_nodemask_of_mempolicy(nodemask_t *mask); 215extern bool init_nodemask_of_mempolicy(nodemask_t *mask);
216extern bool mempolicy_nodemask_intersects(struct task_struct *tsk, 216extern bool mempolicy_nodemask_intersects(struct task_struct *tsk,
217 const nodemask_t *mask); 217 const nodemask_t *mask);
218extern unsigned slab_node(struct mempolicy *policy); 218extern unsigned slab_node(void);
219 219
220extern enum zone_type policy_zone; 220extern enum zone_type policy_zone;
221 221
diff --git a/include/linux/mfd/88pm80x.h b/include/linux/mfd/88pm80x.h
new file mode 100644
index 000000000000..a0ca0dca1244
--- /dev/null
+++ b/include/linux/mfd/88pm80x.h
@@ -0,0 +1,369 @@
1/*
2 * Marvell 88PM80x Interface
3 *
4 * Copyright (C) 2012 Marvell International Ltd.
5 * Qiao Zhou <zhouqiao@marvell.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef __LINUX_MFD_88PM80X_H
13#define __LINUX_MFD_88PM80X_H
14
15#include <linux/platform_device.h>
16#include <linux/interrupt.h>
17#include <linux/regmap.h>
18#include <linux/atomic.h>
19
20#define PM80X_VERSION_MASK (0xFF) /* 80X chip ID mask */
21enum {
22 CHIP_INVALID = 0,
23 CHIP_PM800,
24 CHIP_PM805,
25 CHIP_MAX,
26};
27
28enum {
29 PM800_ID_BUCK1 = 0,
30 PM800_ID_BUCK2,
31 PM800_ID_BUCK3,
32 PM800_ID_BUCK4,
33 PM800_ID_BUCK5,
34
35 PM800_ID_LDO1,
36 PM800_ID_LDO2,
37 PM800_ID_LDO3,
38 PM800_ID_LDO4,
39 PM800_ID_LDO5,
40 PM800_ID_LDO6,
41 PM800_ID_LDO7,
42 PM800_ID_LDO8,
43 PM800_ID_LDO9,
44 PM800_ID_LDO10,
45 PM800_ID_LDO11,
46 PM800_ID_LDO12,
47 PM800_ID_LDO13,
48 PM800_ID_LDO14,
49 PM800_ID_LDO15,
50 PM800_ID_LDO16,
51 PM800_ID_LDO17,
52 PM800_ID_LDO18,
53 PM800_ID_LDO19,
54
55 PM800_ID_RG_MAX,
56};
57#define PM800_MAX_REGULATOR PM800_ID_RG_MAX /* 5 Bucks, 19 LDOs */
58#define PM800_NUM_BUCK (5) /*5 Bucks */
59#define PM800_NUM_LDO (19) /*19 Bucks */
60
61/* page 0 basic: slave adder 0x60 */
62
63#define PM800_STATUS_1 (0x01)
64#define PM800_ONKEY_STS1 (1 << 0)
65#define PM800_EXTON_STS1 (1 << 1)
66#define PM800_CHG_STS1 (1 << 2)
67#define PM800_BAT_STS1 (1 << 3)
68#define PM800_VBUS_STS1 (1 << 4)
69#define PM800_LDO_PGOOD_STS1 (1 << 5)
70#define PM800_BUCK_PGOOD_STS1 (1 << 6)
71
72#define PM800_STATUS_2 (0x02)
73#define PM800_RTC_ALARM_STS2 (1 << 0)
74
75/* Wakeup Registers */
76#define PM800_WAKEUP1 (0x0D)
77
78#define PM800_WAKEUP2 (0x0E)
79#define PM800_WAKEUP2_INV_INT (1 << 0)
80#define PM800_WAKEUP2_INT_CLEAR (1 << 1)
81#define PM800_WAKEUP2_INT_MASK (1 << 2)
82
83#define PM800_POWER_UP_LOG (0x10)
84
85/* Referance and low power registers */
86#define PM800_LOW_POWER1 (0x20)
87#define PM800_LOW_POWER2 (0x21)
88#define PM800_LOW_POWER_CONFIG3 (0x22)
89#define PM800_LOW_POWER_CONFIG4 (0x23)
90
91/* GPIO register */
92#define PM800_GPIO_0_1_CNTRL (0x30)
93#define PM800_GPIO0_VAL (1 << 0)
94#define PM800_GPIO0_GPIO_MODE(x) (x << 1)
95#define PM800_GPIO1_VAL (1 << 4)
96#define PM800_GPIO1_GPIO_MODE(x) (x << 5)
97
98#define PM800_GPIO_2_3_CNTRL (0x31)
99#define PM800_GPIO2_VAL (1 << 0)
100#define PM800_GPIO2_GPIO_MODE(x) (x << 1)
101#define PM800_GPIO3_VAL (1 << 4)
102#define PM800_GPIO3_GPIO_MODE(x) (x << 5)
103#define PM800_GPIO3_MODE_MASK 0x1F
104#define PM800_GPIO3_HEADSET_MODE PM800_GPIO3_GPIO_MODE(6)
105
106#define PM800_GPIO_4_CNTRL (0x32)
107#define PM800_GPIO4_VAL (1 << 0)
108#define PM800_GPIO4_GPIO_MODE(x) (x << 1)
109
110#define PM800_HEADSET_CNTRL (0x38)
111#define PM800_HEADSET_DET_EN (1 << 7)
112#define PM800_HSDET_SLP (1 << 1)
113/* PWM register */
114#define PM800_PWM1 (0x40)
115#define PM800_PWM2 (0x41)
116#define PM800_PWM3 (0x42)
117#define PM800_PWM4 (0x43)
118
119/* RTC Registers */
120#define PM800_RTC_CONTROL (0xD0)
121#define PM800_RTC_MISC1 (0xE1)
122#define PM800_RTC_MISC2 (0xE2)
123#define PM800_RTC_MISC3 (0xE3)
124#define PM800_RTC_MISC4 (0xE4)
125#define PM800_RTC_MISC5 (0xE7)
126/* bit definitions of RTC Register 1 (0xD0) */
127#define PM800_ALARM1_EN (1 << 0)
128#define PM800_ALARM_WAKEUP (1 << 4)
129#define PM800_ALARM (1 << 5)
130#define PM800_RTC1_USE_XO (1 << 7)
131
132/* Regulator Control Registers: BUCK1,BUCK5,LDO1 have DVC */
133
134/* buck registers */
135#define PM800_SLEEP_BUCK1 (0x30)
136
137/* BUCK Sleep Mode Register 1: BUCK[1..4] */
138#define PM800_BUCK_SLP1 (0x5A)
139#define PM800_BUCK1_SLP1_SHIFT 0
140#define PM800_BUCK1_SLP1_MASK (0x3 << PM800_BUCK1_SLP1_SHIFT)
141
142/* page 2 GPADC: slave adder 0x02 */
143#define PM800_GPADC_MEAS_EN1 (0x01)
144#define PM800_MEAS_EN1_VBAT (1 << 2)
145#define PM800_GPADC_MEAS_EN2 (0x02)
146#define PM800_MEAS_EN2_RFTMP (1 << 0)
147#define PM800_MEAS_GP0_EN (1 << 2)
148#define PM800_MEAS_GP1_EN (1 << 3)
149#define PM800_MEAS_GP2_EN (1 << 4)
150#define PM800_MEAS_GP3_EN (1 << 5)
151#define PM800_MEAS_GP4_EN (1 << 6)
152
153#define PM800_GPADC_MISC_CONFIG1 (0x05)
154#define PM800_GPADC_MISC_CONFIG2 (0x06)
155#define PM800_GPADC_MISC_GPFSM_EN (1 << 0)
156#define PM800_GPADC_SLOW_MODE(x) (x << 3)
157
158#define PM800_GPADC_MISC_CONFIG3 (0x09)
159#define PM800_GPADC_MISC_CONFIG4 (0x0A)
160
161#define PM800_GPADC_PREBIAS1 (0x0F)
162#define PM800_GPADC0_GP_PREBIAS_TIME(x) (x << 0)
163#define PM800_GPADC_PREBIAS2 (0x10)
164
165#define PM800_GP_BIAS_ENA1 (0x14)
166#define PM800_GPADC_GP_BIAS_EN0 (1 << 0)
167#define PM800_GPADC_GP_BIAS_EN1 (1 << 1)
168#define PM800_GPADC_GP_BIAS_EN2 (1 << 2)
169#define PM800_GPADC_GP_BIAS_EN3 (1 << 3)
170
171#define PM800_GP_BIAS_OUT1 (0x15)
172#define PM800_BIAS_OUT_GP0 (1 << 0)
173#define PM800_BIAS_OUT_GP1 (1 << 1)
174#define PM800_BIAS_OUT_GP2 (1 << 2)
175#define PM800_BIAS_OUT_GP3 (1 << 3)
176
177#define PM800_GPADC0_LOW_TH 0x20
178#define PM800_GPADC1_LOW_TH 0x21
179#define PM800_GPADC2_LOW_TH 0x22
180#define PM800_GPADC3_LOW_TH 0x23
181#define PM800_GPADC4_LOW_TH 0x24
182
183#define PM800_GPADC0_UPP_TH 0x30
184#define PM800_GPADC1_UPP_TH 0x31
185#define PM800_GPADC2_UPP_TH 0x32
186#define PM800_GPADC3_UPP_TH 0x33
187#define PM800_GPADC4_UPP_TH 0x34
188
189#define PM800_VBBAT_MEAS1 0x40
190#define PM800_VBBAT_MEAS2 0x41
191#define PM800_VBAT_MEAS1 0x42
192#define PM800_VBAT_MEAS2 0x43
193#define PM800_VSYS_MEAS1 0x44
194#define PM800_VSYS_MEAS2 0x45
195#define PM800_VCHG_MEAS1 0x46
196#define PM800_VCHG_MEAS2 0x47
197#define PM800_TINT_MEAS1 0x50
198#define PM800_TINT_MEAS2 0x51
199#define PM800_PMOD_MEAS1 0x52
200#define PM800_PMOD_MEAS2 0x53
201
202#define PM800_GPADC0_MEAS1 0x54
203#define PM800_GPADC0_MEAS2 0x55
204#define PM800_GPADC1_MEAS1 0x56
205#define PM800_GPADC1_MEAS2 0x57
206#define PM800_GPADC2_MEAS1 0x58
207#define PM800_GPADC2_MEAS2 0x59
208#define PM800_GPADC3_MEAS1 0x5A
209#define PM800_GPADC3_MEAS2 0x5B
210#define PM800_GPADC4_MEAS1 0x5C
211#define PM800_GPADC4_MEAS2 0x5D
212
213#define PM800_GPADC4_AVG1 0xA8
214#define PM800_GPADC4_AVG2 0xA9
215
216/* 88PM805 Registers */
217#define PM805_MAIN_POWERUP (0x01)
218#define PM805_INT_STATUS0 (0x02) /* for ena/dis all interrupts */
219
220#define PM805_STATUS0_INT_CLEAR (1 << 0)
221#define PM805_STATUS0_INV_INT (1 << 1)
222#define PM800_STATUS0_INT_MASK (1 << 2)
223
224#define PM805_INT_STATUS1 (0x03)
225
226#define PM805_INT1_HP1_SHRT (1 << 0)
227#define PM805_INT1_HP2_SHRT (1 << 1)
228#define PM805_INT1_MIC_CONFLICT (1 << 2)
229#define PM805_INT1_CLIP_FAULT (1 << 3)
230#define PM805_INT1_LDO_OFF (1 << 4)
231#define PM805_INT1_SRC_DPLL_LOCK (1 << 5)
232
233#define PM805_INT_STATUS2 (0x04)
234
235#define PM805_INT2_MIC_DET (1 << 0)
236#define PM805_INT2_SHRT_BTN_DET (1 << 1)
237#define PM805_INT2_VOLM_BTN_DET (1 << 2)
238#define PM805_INT2_VOLP_BTN_DET (1 << 3)
239#define PM805_INT2_RAW_PLL_FAULT (1 << 4)
240#define PM805_INT2_FINE_PLL_FAULT (1 << 5)
241
242#define PM805_INT_MASK1 (0x05)
243#define PM805_INT_MASK2 (0x06)
244#define PM805_SHRT_BTN_DET (1 << 1)
245
246/* number of status and int reg in a row */
247#define PM805_INT_REG_NUM (2)
248
249#define PM805_MIC_DET1 (0x07)
250#define PM805_MIC_DET_EN_MIC_DET (1 << 0)
251#define PM805_MIC_DET2 (0x08)
252#define PM805_MIC_DET_STATUS1 (0x09)
253
254#define PM805_MIC_DET_STATUS3 (0x0A)
255#define PM805_AUTO_SEQ_STATUS1 (0x0B)
256#define PM805_AUTO_SEQ_STATUS2 (0x0C)
257
258#define PM805_ADC_SETTING1 (0x10)
259#define PM805_ADC_SETTING2 (0x11)
260#define PM805_ADC_SETTING3 (0x11)
261#define PM805_ADC_GAIN1 (0x12)
262#define PM805_ADC_GAIN2 (0x13)
263#define PM805_DMIC_SETTING (0x15)
264#define PM805_DWS_SETTING (0x16)
265#define PM805_MIC_CONFLICT_STS (0x17)
266
267#define PM805_PDM_SETTING1 (0x20)
268#define PM805_PDM_SETTING2 (0x21)
269#define PM805_PDM_SETTING3 (0x22)
270#define PM805_PDM_CONTROL1 (0x23)
271#define PM805_PDM_CONTROL2 (0x24)
272#define PM805_PDM_CONTROL3 (0x25)
273
274#define PM805_HEADPHONE_SETTING (0x26)
275#define PM805_HEADPHONE_GAIN_A2A (0x27)
276#define PM805_HEADPHONE_SHORT_STATE (0x28)
277#define PM805_EARPHONE_SETTING (0x29)
278#define PM805_AUTO_SEQ_SETTING (0x2A)
279
280struct pm80x_rtc_pdata {
281 int vrtc;
282 int rtc_wakeup;
283};
284
285struct pm80x_subchip {
286 struct i2c_client *power_page; /* chip client for power page */
287 struct i2c_client *gpadc_page; /* chip client for gpadc page */
288 struct regmap *regmap_power;
289 struct regmap *regmap_gpadc;
290 unsigned short power_page_addr; /* power page I2C address */
291 unsigned short gpadc_page_addr; /* gpadc page I2C address */
292};
293
294struct pm80x_chip {
295 struct pm80x_subchip *subchip;
296 struct device *dev;
297 struct i2c_client *client;
298 struct i2c_client *companion;
299 struct regmap *regmap;
300 struct regmap_irq_chip *regmap_irq_chip;
301 struct regmap_irq_chip_data *irq_data;
302 unsigned char version;
303 int id;
304 int irq;
305 int irq_mode;
306 unsigned long wu_flag;
307 spinlock_t lock;
308};
309
310struct pm80x_platform_data {
311 struct pm80x_rtc_pdata *rtc;
312 unsigned short power_page_addr; /* power page I2C address */
313 unsigned short gpadc_page_addr; /* gpadc page I2C address */
314 int irq_mode; /* Clear interrupt by read/write(0/1) */
315 int batt_det; /* enable/disable */
316 int (*plat_config)(struct pm80x_chip *chip,
317 struct pm80x_platform_data *pdata);
318};
319
320extern const struct dev_pm_ops pm80x_pm_ops;
321extern const struct regmap_config pm80x_regmap_config;
322
323static inline int pm80x_request_irq(struct pm80x_chip *pm80x, int irq,
324 irq_handler_t handler, unsigned long flags,
325 const char *name, void *data)
326{
327 if (!pm80x->irq_data)
328 return -EINVAL;
329 return request_threaded_irq(regmap_irq_get_virq(pm80x->irq_data, irq),
330 NULL, handler, flags, name, data);
331}
332
333static inline void pm80x_free_irq(struct pm80x_chip *pm80x, int irq, void *data)
334{
335 if (!pm80x->irq_data)
336 return;
337 free_irq(regmap_irq_get_virq(pm80x->irq_data, irq), data);
338}
339
340#ifdef CONFIG_PM
341static inline int pm80x_dev_suspend(struct device *dev)
342{
343 struct platform_device *pdev = to_platform_device(dev);
344 struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
345 int irq = platform_get_irq(pdev, 0);
346
347 if (device_may_wakeup(dev))
348 set_bit((1 << irq), &chip->wu_flag);
349
350 return 0;
351}
352
353static inline int pm80x_dev_resume(struct device *dev)
354{
355 struct platform_device *pdev = to_platform_device(dev);
356 struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
357 int irq = platform_get_irq(pdev, 0);
358
359 if (device_may_wakeup(dev))
360 clear_bit((1 << irq), &chip->wu_flag);
361
362 return 0;
363}
364#endif
365
366extern int pm80x_init(struct i2c_client *client,
367 const struct i2c_device_id *id) __devinit;
368extern int pm80x_deinit(struct i2c_client *client);
369#endif /* __LINUX_MFD_88PM80X_H */
diff --git a/include/linux/mfd/88pm860x.h b/include/linux/mfd/88pm860x.h
index 84d071ade1d8..7b24943779fa 100644
--- a/include/linux/mfd/88pm860x.h
+++ b/include/linux/mfd/88pm860x.h
@@ -136,6 +136,7 @@ enum {
136 PM8607_ID_LDO13, 136 PM8607_ID_LDO13,
137 PM8607_ID_LDO14, 137 PM8607_ID_LDO14,
138 PM8607_ID_LDO15, 138 PM8607_ID_LDO15,
139 PM8606_ID_PREG,
139 140
140 PM8607_ID_RG_MAX, 141 PM8607_ID_RG_MAX,
141}; 142};
diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h
index bc9b84b60ec6..3764cb6759e3 100644
--- a/include/linux/mfd/abx500/ab8500.h
+++ b/include/linux/mfd/abx500/ab8500.h
@@ -9,6 +9,7 @@
9 9
10#include <linux/atomic.h> 10#include <linux/atomic.h>
11#include <linux/mutex.h> 11#include <linux/mutex.h>
12#include <linux/irqdomain.h>
12 13
13struct device; 14struct device;
14 15
@@ -227,6 +228,7 @@ enum ab8500_version {
227 * @irq_lock: genirq bus lock 228 * @irq_lock: genirq bus lock
228 * @transfer_ongoing: 0 if no transfer ongoing 229 * @transfer_ongoing: 0 if no transfer ongoing
229 * @irq: irq line 230 * @irq: irq line
231 * @irq_domain: irq domain
230 * @version: chip version id (e.g. ab8500 or ab9540) 232 * @version: chip version id (e.g. ab8500 or ab9540)
231 * @chip_id: chip revision id 233 * @chip_id: chip revision id
232 * @write: register write 234 * @write: register write
@@ -247,6 +249,7 @@ struct ab8500 {
247 atomic_t transfer_ongoing; 249 atomic_t transfer_ongoing;
248 int irq_base; 250 int irq_base;
249 int irq; 251 int irq;
252 struct irq_domain *domain;
250 enum ab8500_version version; 253 enum ab8500_version version;
251 u8 chip_id; 254 u8 chip_id;
252 255
@@ -338,4 +341,6 @@ static inline int is_ab8500_2p0(struct ab8500 *ab)
338 return (is_ab8500(ab) && (ab->chip_id == AB8500_CUT2P0)); 341 return (is_ab8500(ab) && (ab->chip_id == AB8500_CUT2P0));
339} 342}
340 343
344int ab8500_irq_get_virq(struct ab8500 *ab8500, int irq);
345
341#endif /* MFD_AB8500_H */ 346#endif /* MFD_AB8500_H */
diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h
new file mode 100644
index 000000000000..dd231ac0bb1f
--- /dev/null
+++ b/include/linux/mfd/arizona/core.h
@@ -0,0 +1,114 @@
1/*
2 * Arizona MFD internals
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef _WM_ARIZONA_CORE_H
14#define _WM_ARIZONA_CORE_H
15
16#include <linux/interrupt.h>
17#include <linux/regmap.h>
18#include <linux/regulator/consumer.h>
19#include <linux/mfd/arizona/pdata.h>
20
21#define ARIZONA_MAX_CORE_SUPPLIES 3
22
23enum arizona_type {
24 WM5102 = 1,
25 WM5110 = 2,
26};
27
28#define ARIZONA_IRQ_GP1 0
29#define ARIZONA_IRQ_GP2 1
30#define ARIZONA_IRQ_GP3 2
31#define ARIZONA_IRQ_GP4 3
32#define ARIZONA_IRQ_GP5_FALL 4
33#define ARIZONA_IRQ_GP5_RISE 5
34#define ARIZONA_IRQ_JD_FALL 6
35#define ARIZONA_IRQ_JD_RISE 7
36#define ARIZONA_IRQ_DSP1_RAM_RDY 8
37#define ARIZONA_IRQ_DSP2_RAM_RDY 9
38#define ARIZONA_IRQ_DSP3_RAM_RDY 10
39#define ARIZONA_IRQ_DSP4_RAM_RDY 11
40#define ARIZONA_IRQ_DSP_IRQ1 12
41#define ARIZONA_IRQ_DSP_IRQ2 13
42#define ARIZONA_IRQ_DSP_IRQ3 14
43#define ARIZONA_IRQ_DSP_IRQ4 15
44#define ARIZONA_IRQ_DSP_IRQ5 16
45#define ARIZONA_IRQ_DSP_IRQ6 17
46#define ARIZONA_IRQ_DSP_IRQ7 18
47#define ARIZONA_IRQ_DSP_IRQ8 19
48#define ARIZONA_IRQ_SPK_SHUTDOWN_WARN 20
49#define ARIZONA_IRQ_SPK_SHUTDOWN 21
50#define ARIZONA_IRQ_MICDET 22
51#define ARIZONA_IRQ_HPDET 23
52#define ARIZONA_IRQ_WSEQ_DONE 24
53#define ARIZONA_IRQ_DRC2_SIG_DET 25
54#define ARIZONA_IRQ_DRC1_SIG_DET 26
55#define ARIZONA_IRQ_ASRC2_LOCK 27
56#define ARIZONA_IRQ_ASRC1_LOCK 28
57#define ARIZONA_IRQ_UNDERCLOCKED 29
58#define ARIZONA_IRQ_OVERCLOCKED 30
59#define ARIZONA_IRQ_FLL2_LOCK 31
60#define ARIZONA_IRQ_FLL1_LOCK 32
61#define ARIZONA_IRQ_CLKGEN_ERR 33
62#define ARIZONA_IRQ_CLKGEN_ERR_ASYNC 34
63#define ARIZONA_IRQ_ASRC_CFG_ERR 35
64#define ARIZONA_IRQ_AIF3_ERR 36
65#define ARIZONA_IRQ_AIF2_ERR 37
66#define ARIZONA_IRQ_AIF1_ERR 38
67#define ARIZONA_IRQ_CTRLIF_ERR 39
68#define ARIZONA_IRQ_MIXER_DROPPED_SAMPLES 40
69#define ARIZONA_IRQ_ASYNC_CLK_ENA_LOW 41
70#define ARIZONA_IRQ_SYSCLK_ENA_LOW 42
71#define ARIZONA_IRQ_ISRC1_CFG_ERR 43
72#define ARIZONA_IRQ_ISRC2_CFG_ERR 44
73#define ARIZONA_IRQ_BOOT_DONE 45
74#define ARIZONA_IRQ_DCS_DAC_DONE 46
75#define ARIZONA_IRQ_DCS_HP_DONE 47
76#define ARIZONA_IRQ_FLL2_CLOCK_OK 48
77#define ARIZONA_IRQ_FLL1_CLOCK_OK 49
78
79#define ARIZONA_NUM_IRQ 50
80
81struct arizona {
82 struct regmap *regmap;
83 struct device *dev;
84
85 enum arizona_type type;
86 unsigned int rev;
87
88 int num_core_supplies;
89 struct regulator_bulk_data core_supplies[ARIZONA_MAX_CORE_SUPPLIES];
90 struct regulator *dcvdd;
91
92 struct arizona_pdata pdata;
93
94 int irq;
95 struct irq_domain *virq;
96 struct regmap_irq_chip_data *aod_irq_chip;
97 struct regmap_irq_chip_data *irq_chip;
98
99 struct mutex clk_lock;
100 int clk32k_ref;
101};
102
103int arizona_clk32k_enable(struct arizona *arizona);
104int arizona_clk32k_disable(struct arizona *arizona);
105
106int arizona_request_irq(struct arizona *arizona, int irq, char *name,
107 irq_handler_t handler, void *data);
108void arizona_free_irq(struct arizona *arizona, int irq, void *data);
109int arizona_set_irq_wake(struct arizona *arizona, int irq, int on);
110
111int wm5102_patch(struct arizona *arizona);
112int wm5110_patch(struct arizona *arizona);
113
114#endif
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
new file mode 100644
index 000000000000..7ab442905a57
--- /dev/null
+++ b/include/linux/mfd/arizona/pdata.h
@@ -0,0 +1,119 @@
1/*
2 * Platform data for Arizona devices
3 *
4 * Copyright 2012 Wolfson Microelectronics. PLC.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef _ARIZONA_PDATA_H
12#define _ARIZONA_PDATA_H
13
14#define ARIZONA_GPN_DIR 0x8000 /* GPN_DIR */
15#define ARIZONA_GPN_DIR_MASK 0x8000 /* GPN_DIR */
16#define ARIZONA_GPN_DIR_SHIFT 15 /* GPN_DIR */
17#define ARIZONA_GPN_DIR_WIDTH 1 /* GPN_DIR */
18#define ARIZONA_GPN_PU 0x4000 /* GPN_PU */
19#define ARIZONA_GPN_PU_MASK 0x4000 /* GPN_PU */
20#define ARIZONA_GPN_PU_SHIFT 14 /* GPN_PU */
21#define ARIZONA_GPN_PU_WIDTH 1 /* GPN_PU */
22#define ARIZONA_GPN_PD 0x2000 /* GPN_PD */
23#define ARIZONA_GPN_PD_MASK 0x2000 /* GPN_PD */
24#define ARIZONA_GPN_PD_SHIFT 13 /* GPN_PD */
25#define ARIZONA_GPN_PD_WIDTH 1 /* GPN_PD */
26#define ARIZONA_GPN_LVL 0x0800 /* GPN_LVL */
27#define ARIZONA_GPN_LVL_MASK 0x0800 /* GPN_LVL */
28#define ARIZONA_GPN_LVL_SHIFT 11 /* GPN_LVL */
29#define ARIZONA_GPN_LVL_WIDTH 1 /* GPN_LVL */
30#define ARIZONA_GPN_POL 0x0400 /* GPN_POL */
31#define ARIZONA_GPN_POL_MASK 0x0400 /* GPN_POL */
32#define ARIZONA_GPN_POL_SHIFT 10 /* GPN_POL */
33#define ARIZONA_GPN_POL_WIDTH 1 /* GPN_POL */
34#define ARIZONA_GPN_OP_CFG 0x0200 /* GPN_OP_CFG */
35#define ARIZONA_GPN_OP_CFG_MASK 0x0200 /* GPN_OP_CFG */
36#define ARIZONA_GPN_OP_CFG_SHIFT 9 /* GPN_OP_CFG */
37#define ARIZONA_GPN_OP_CFG_WIDTH 1 /* GPN_OP_CFG */
38#define ARIZONA_GPN_DB 0x0100 /* GPN_DB */
39#define ARIZONA_GPN_DB_MASK 0x0100 /* GPN_DB */
40#define ARIZONA_GPN_DB_SHIFT 8 /* GPN_DB */
41#define ARIZONA_GPN_DB_WIDTH 1 /* GPN_DB */
42#define ARIZONA_GPN_FN_MASK 0x007F /* GPN_FN - [6:0] */
43#define ARIZONA_GPN_FN_SHIFT 0 /* GPN_FN - [6:0] */
44#define ARIZONA_GPN_FN_WIDTH 7 /* GPN_FN - [6:0] */
45
46#define ARIZONA_MAX_GPIO 5
47
48#define ARIZONA_32KZ_MCLK1 1
49#define ARIZONA_32KZ_MCLK2 2
50#define ARIZONA_32KZ_NONE 3
51
52#define ARIZONA_MAX_INPUT 4
53
54#define ARIZONA_DMIC_MICVDD 0
55#define ARIZONA_DMIC_MICBIAS1 1
56#define ARIZONA_DMIC_MICBIAS2 2
57#define ARIZONA_DMIC_MICBIAS3 3
58
59#define ARIZONA_INMODE_DIFF 0
60#define ARIZONA_INMODE_SE 1
61#define ARIZONA_INMODE_DMIC 2
62
63#define ARIZONA_MAX_OUTPUT 6
64
65#define ARIZONA_MAX_PDM_SPK 2
66
67struct regulator_init_data;
68
69struct arizona_micd_config {
70 unsigned int src;
71 unsigned int bias;
72 bool gpio;
73};
74
75struct arizona_pdata {
76 int reset; /** GPIO controlling /RESET, if any */
77 int ldoena; /** GPIO controlling LODENA, if any */
78
79 /** Regulator configuration for MICVDD */
80 struct regulator_init_data *micvdd;
81
82 /** Regulator configuration for LDO1 */
83 struct regulator_init_data *ldo1;
84
85 /** If a direct 32kHz clock is provided on an MCLK specify it here */
86 int clk32k_src;
87
88 bool irq_active_high; /** IRQ polarity */
89
90 /* Base GPIO */
91 int gpio_base;
92
93 /** Pin state for GPIO pins */
94 int gpio_defaults[ARIZONA_MAX_GPIO];
95
96 /** GPIO for mic detection polarity */
97 int micd_pol_gpio;
98
99 /** Headset polarity configurations */
100 struct arizona_micd_config *micd_configs;
101 int num_micd_configs;
102
103 /** Reference voltage for DMIC inputs */
104 int dmic_ref[ARIZONA_MAX_INPUT];
105
106 /** Mode of input structures */
107 int inmode[ARIZONA_MAX_INPUT];
108
109 /** Mode for outputs */
110 bool out_mono[ARIZONA_MAX_OUTPUT];
111
112 /** PDM speaker mute setting */
113 unsigned int spk_mute[ARIZONA_MAX_PDM_SPK];
114
115 /** PDM speaker format */
116 unsigned int spk_fmt[ARIZONA_MAX_PDM_SPK];
117};
118
119#endif
diff --git a/include/linux/mfd/arizona/registers.h b/include/linux/mfd/arizona/registers.h
new file mode 100644
index 000000000000..7671a287dfee
--- /dev/null
+++ b/include/linux/mfd/arizona/registers.h
@@ -0,0 +1,6594 @@
1/*
2 * ARIZONA register definitions
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef _ARIZONA_REGISTERS_H
14#define _ARIZONA_REGISTERS_H
15
16/*
17 * Register values.
18 */
19#define ARIZONA_SOFTWARE_RESET 0x00
20#define ARIZONA_DEVICE_REVISION 0x01
21#define ARIZONA_CTRL_IF_SPI_CFG_1 0x08
22#define ARIZONA_CTRL_IF_I2C1_CFG_1 0x09
23#define ARIZONA_CTRL_IF_I2C2_CFG_1 0x0A
24#define ARIZONA_CTRL_IF_I2C1_CFG_2 0x0B
25#define ARIZONA_CTRL_IF_I2C2_CFG_2 0x0C
26#define ARIZONA_CTRL_IF_STATUS_1 0x0D
27#define ARIZONA_WRITE_SEQUENCER_CTRL_0 0x16
28#define ARIZONA_WRITE_SEQUENCER_CTRL_1 0x17
29#define ARIZONA_WRITE_SEQUENCER_CTRL_2 0x18
30#define ARIZONA_WRITE_SEQUENCER_PROM 0x1A
31#define ARIZONA_TONE_GENERATOR_1 0x20
32#define ARIZONA_TONE_GENERATOR_2 0x21
33#define ARIZONA_TONE_GENERATOR_3 0x22
34#define ARIZONA_TONE_GENERATOR_4 0x23
35#define ARIZONA_TONE_GENERATOR_5 0x24
36#define ARIZONA_PWM_DRIVE_1 0x30
37#define ARIZONA_PWM_DRIVE_2 0x31
38#define ARIZONA_PWM_DRIVE_3 0x32
39#define ARIZONA_WAKE_CONTROL 0x40
40#define ARIZONA_SEQUENCE_CONTROL 0x41
41#define ARIZONA_SAMPLE_RATE_SEQUENCE_SELECT_1 0x61
42#define ARIZONA_SAMPLE_RATE_SEQUENCE_SELECT_2 0x62
43#define ARIZONA_SAMPLE_RATE_SEQUENCE_SELECT_3 0x63
44#define ARIZONA_SAMPLE_RATE_SEQUENCE_SELECT_4 0x64
45#define ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_1 0x68
46#define ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_2 0x69
47#define ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_3 0x6A
48#define ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_4 0x6B
49#define ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_5 0x6C
50#define ARIZONA_ALWAYS_ON_TRIGGERS_SEQUENCE_SELECT_6 0x6D
51#define ARIZONA_COMFORT_NOISE_GENERATOR 0x70
52#define ARIZONA_HAPTICS_CONTROL_1 0x90
53#define ARIZONA_HAPTICS_CONTROL_2 0x91
54#define ARIZONA_HAPTICS_PHASE_1_INTENSITY 0x92
55#define ARIZONA_HAPTICS_PHASE_1_DURATION 0x93
56#define ARIZONA_HAPTICS_PHASE_2_INTENSITY 0x94
57#define ARIZONA_HAPTICS_PHASE_2_DURATION 0x95
58#define ARIZONA_HAPTICS_PHASE_3_INTENSITY 0x96
59#define ARIZONA_HAPTICS_PHASE_3_DURATION 0x97
60#define ARIZONA_HAPTICS_STATUS 0x98
61#define ARIZONA_CLOCK_32K_1 0x100
62#define ARIZONA_SYSTEM_CLOCK_1 0x101
63#define ARIZONA_SAMPLE_RATE_1 0x102
64#define ARIZONA_SAMPLE_RATE_2 0x103
65#define ARIZONA_SAMPLE_RATE_3 0x104
66#define ARIZONA_SAMPLE_RATE_1_STATUS 0x10A
67#define ARIZONA_SAMPLE_RATE_2_STATUS 0x10B
68#define ARIZONA_SAMPLE_RATE_3_STATUS 0x10C
69#define ARIZONA_ASYNC_CLOCK_1 0x112
70#define ARIZONA_ASYNC_SAMPLE_RATE_1 0x113
71#define ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS 0x11B
72#define ARIZONA_OUTPUT_SYSTEM_CLOCK 0x149
73#define ARIZONA_OUTPUT_ASYNC_CLOCK 0x14A
74#define ARIZONA_RATE_ESTIMATOR_1 0x152
75#define ARIZONA_RATE_ESTIMATOR_2 0x153
76#define ARIZONA_RATE_ESTIMATOR_3 0x154
77#define ARIZONA_RATE_ESTIMATOR_4 0x155
78#define ARIZONA_RATE_ESTIMATOR_5 0x156
79#define ARIZONA_FLL1_CONTROL_1 0x171
80#define ARIZONA_FLL1_CONTROL_2 0x172
81#define ARIZONA_FLL1_CONTROL_3 0x173
82#define ARIZONA_FLL1_CONTROL_4 0x174
83#define ARIZONA_FLL1_CONTROL_5 0x175
84#define ARIZONA_FLL1_CONTROL_6 0x176
85#define ARIZONA_FLL1_LOOP_FILTER_TEST_1 0x177
86#define ARIZONA_FLL1_NCO_TEST_0 0x178
87#define ARIZONA_FLL1_SYNCHRONISER_1 0x181
88#define ARIZONA_FLL1_SYNCHRONISER_2 0x182
89#define ARIZONA_FLL1_SYNCHRONISER_3 0x183
90#define ARIZONA_FLL1_SYNCHRONISER_4 0x184
91#define ARIZONA_FLL1_SYNCHRONISER_5 0x185
92#define ARIZONA_FLL1_SYNCHRONISER_6 0x186
93#define ARIZONA_FLL1_SPREAD_SPECTRUM 0x189
94#define ARIZONA_FLL1_GPIO_CLOCK 0x18A
95#define ARIZONA_FLL2_CONTROL_1 0x191
96#define ARIZONA_FLL2_CONTROL_2 0x192
97#define ARIZONA_FLL2_CONTROL_3 0x193
98#define ARIZONA_FLL2_CONTROL_4 0x194
99#define ARIZONA_FLL2_CONTROL_5 0x195
100#define ARIZONA_FLL2_CONTROL_6 0x196
101#define ARIZONA_FLL2_LOOP_FILTER_TEST_1 0x197
102#define ARIZONA_FLL2_NCO_TEST_0 0x198
103#define ARIZONA_FLL2_SYNCHRONISER_1 0x1A1
104#define ARIZONA_FLL2_SYNCHRONISER_2 0x1A2
105#define ARIZONA_FLL2_SYNCHRONISER_3 0x1A3
106#define ARIZONA_FLL2_SYNCHRONISER_4 0x1A4
107#define ARIZONA_FLL2_SYNCHRONISER_5 0x1A5
108#define ARIZONA_FLL2_SYNCHRONISER_6 0x1A6
109#define ARIZONA_FLL2_SPREAD_SPECTRUM 0x1A9
110#define ARIZONA_FLL2_GPIO_CLOCK 0x1AA
111#define ARIZONA_MIC_CHARGE_PUMP_1 0x200
112#define ARIZONA_LDO1_CONTROL_1 0x210
113#define ARIZONA_LDO2_CONTROL_1 0x213
114#define ARIZONA_MIC_BIAS_CTRL_1 0x218
115#define ARIZONA_MIC_BIAS_CTRL_2 0x219
116#define ARIZONA_MIC_BIAS_CTRL_3 0x21A
117#define ARIZONA_ACCESSORY_DETECT_MODE_1 0x293
118#define ARIZONA_HEADPHONE_DETECT_1 0x29B
119#define ARIZONA_HEADPHONE_DETECT_2 0x29C
120#define ARIZONA_MIC_DETECT_1 0x2A3
121#define ARIZONA_MIC_DETECT_2 0x2A4
122#define ARIZONA_MIC_DETECT_3 0x2A5
123#define ARIZONA_MIC_NOISE_MIX_CONTROL_1 0x2C3
124#define ARIZONA_ISOLATION_CONTROL 0x2CB
125#define ARIZONA_JACK_DETECT_ANALOGUE 0x2D3
126#define ARIZONA_INPUT_ENABLES 0x300
127#define ARIZONA_INPUT_ENABLES_STATUS 0x301
128#define ARIZONA_INPUT_RATE 0x308
129#define ARIZONA_INPUT_VOLUME_RAMP 0x309
130#define ARIZONA_IN1L_CONTROL 0x310
131#define ARIZONA_ADC_DIGITAL_VOLUME_1L 0x311
132#define ARIZONA_DMIC1L_CONTROL 0x312
133#define ARIZONA_IN1R_CONTROL 0x314
134#define ARIZONA_ADC_DIGITAL_VOLUME_1R 0x315
135#define ARIZONA_DMIC1R_CONTROL 0x316
136#define ARIZONA_IN2L_CONTROL 0x318
137#define ARIZONA_ADC_DIGITAL_VOLUME_2L 0x319
138#define ARIZONA_DMIC2L_CONTROL 0x31A
139#define ARIZONA_IN2R_CONTROL 0x31C
140#define ARIZONA_ADC_DIGITAL_VOLUME_2R 0x31D
141#define ARIZONA_DMIC2R_CONTROL 0x31E
142#define ARIZONA_IN3L_CONTROL 0x320
143#define ARIZONA_ADC_DIGITAL_VOLUME_3L 0x321
144#define ARIZONA_DMIC3L_CONTROL 0x322
145#define ARIZONA_IN3R_CONTROL 0x324
146#define ARIZONA_ADC_DIGITAL_VOLUME_3R 0x325
147#define ARIZONA_DMIC3R_CONTROL 0x326
148#define ARIZONA_IN4L_CONTROL 0x328
149#define ARIZONA_ADC_DIGITAL_VOLUME_4L 0x329
150#define ARIZONA_DMIC4L_CONTROL 0x32A
151#define ARIZONA_ADC_DIGITAL_VOLUME_4R 0x32D
152#define ARIZONA_DMIC4R_CONTROL 0x32E
153#define ARIZONA_OUTPUT_ENABLES_1 0x400
154#define ARIZONA_OUTPUT_STATUS_1 0x401
155#define ARIZONA_RAW_OUTPUT_STATUS_1 0x406
156#define ARIZONA_OUTPUT_RATE_1 0x408
157#define ARIZONA_OUTPUT_VOLUME_RAMP 0x409
158#define ARIZONA_OUTPUT_PATH_CONFIG_1L 0x410
159#define ARIZONA_DAC_DIGITAL_VOLUME_1L 0x411
160#define ARIZONA_DAC_VOLUME_LIMIT_1L 0x412
161#define ARIZONA_NOISE_GATE_SELECT_1L 0x413
162#define ARIZONA_OUTPUT_PATH_CONFIG_1R 0x414
163#define ARIZONA_DAC_DIGITAL_VOLUME_1R 0x415
164#define ARIZONA_DAC_VOLUME_LIMIT_1R 0x416
165#define ARIZONA_NOISE_GATE_SELECT_1R 0x417
166#define ARIZONA_OUTPUT_PATH_CONFIG_2L 0x418
167#define ARIZONA_DAC_DIGITAL_VOLUME_2L 0x419
168#define ARIZONA_DAC_VOLUME_LIMIT_2L 0x41A
169#define ARIZONA_NOISE_GATE_SELECT_2L 0x41B
170#define ARIZONA_OUTPUT_PATH_CONFIG_2R 0x41C
171#define ARIZONA_DAC_DIGITAL_VOLUME_2R 0x41D
172#define ARIZONA_DAC_VOLUME_LIMIT_2R 0x41E
173#define ARIZONA_NOISE_GATE_SELECT_2R 0x41F
174#define ARIZONA_OUTPUT_PATH_CONFIG_3L 0x420
175#define ARIZONA_DAC_DIGITAL_VOLUME_3L 0x421
176#define ARIZONA_DAC_VOLUME_LIMIT_3L 0x422
177#define ARIZONA_NOISE_GATE_SELECT_3L 0x423
178#define ARIZONA_OUTPUT_PATH_CONFIG_3R 0x424
179#define ARIZONA_DAC_DIGITAL_VOLUME_3R 0x425
180#define ARIZONA_DAC_VOLUME_LIMIT_3R 0x426
181#define ARIZONA_NOISE_GATE_SELECT_3R 0x427
182#define ARIZONA_OUTPUT_PATH_CONFIG_4L 0x428
183#define ARIZONA_DAC_DIGITAL_VOLUME_4L 0x429
184#define ARIZONA_OUT_VOLUME_4L 0x42A
185#define ARIZONA_NOISE_GATE_SELECT_4L 0x42B
186#define ARIZONA_OUTPUT_PATH_CONFIG_4R 0x42C
187#define ARIZONA_DAC_DIGITAL_VOLUME_4R 0x42D
188#define ARIZONA_OUT_VOLUME_4R 0x42E
189#define ARIZONA_NOISE_GATE_SELECT_4R 0x42F
190#define ARIZONA_OUTPUT_PATH_CONFIG_5L 0x430
191#define ARIZONA_DAC_DIGITAL_VOLUME_5L 0x431
192#define ARIZONA_DAC_VOLUME_LIMIT_5L 0x432
193#define ARIZONA_NOISE_GATE_SELECT_5L 0x433
194#define ARIZONA_OUTPUT_PATH_CONFIG_5R 0x434
195#define ARIZONA_DAC_DIGITAL_VOLUME_5R 0x435
196#define ARIZONA_DAC_VOLUME_LIMIT_5R 0x436
197#define ARIZONA_NOISE_GATE_SELECT_5R 0x437
198#define ARIZONA_OUTPUT_PATH_CONFIG_6L 0x438
199#define ARIZONA_DAC_DIGITAL_VOLUME_6L 0x439
200#define ARIZONA_DAC_VOLUME_LIMIT_6L 0x43A
201#define ARIZONA_NOISE_GATE_SELECT_6L 0x43B
202#define ARIZONA_OUTPUT_PATH_CONFIG_6R 0x43C
203#define ARIZONA_DAC_DIGITAL_VOLUME_6R 0x43D
204#define ARIZONA_DAC_VOLUME_LIMIT_6R 0x43E
205#define ARIZONA_NOISE_GATE_SELECT_6R 0x43F
206#define ARIZONA_DAC_AEC_CONTROL_1 0x450
207#define ARIZONA_NOISE_GATE_CONTROL 0x458
208#define ARIZONA_PDM_SPK1_CTRL_1 0x490
209#define ARIZONA_PDM_SPK1_CTRL_2 0x491
210#define ARIZONA_PDM_SPK2_CTRL_1 0x492
211#define ARIZONA_PDM_SPK2_CTRL_2 0x493
212#define ARIZONA_DAC_COMP_1 0x4DC
213#define ARIZONA_DAC_COMP_2 0x4DD
214#define ARIZONA_DAC_COMP_3 0x4DE
215#define ARIZONA_DAC_COMP_4 0x4DF
216#define ARIZONA_AIF1_BCLK_CTRL 0x500
217#define ARIZONA_AIF1_TX_PIN_CTRL 0x501
218#define ARIZONA_AIF1_RX_PIN_CTRL 0x502
219#define ARIZONA_AIF1_RATE_CTRL 0x503
220#define ARIZONA_AIF1_FORMAT 0x504
221#define ARIZONA_AIF1_TX_BCLK_RATE 0x505
222#define ARIZONA_AIF1_RX_BCLK_RATE 0x506
223#define ARIZONA_AIF1_FRAME_CTRL_1 0x507
224#define ARIZONA_AIF1_FRAME_CTRL_2 0x508
225#define ARIZONA_AIF1_FRAME_CTRL_3 0x509
226#define ARIZONA_AIF1_FRAME_CTRL_4 0x50A
227#define ARIZONA_AIF1_FRAME_CTRL_5 0x50B
228#define ARIZONA_AIF1_FRAME_CTRL_6 0x50C
229#define ARIZONA_AIF1_FRAME_CTRL_7 0x50D
230#define ARIZONA_AIF1_FRAME_CTRL_8 0x50E
231#define ARIZONA_AIF1_FRAME_CTRL_9 0x50F
232#define ARIZONA_AIF1_FRAME_CTRL_10 0x510
233#define ARIZONA_AIF1_FRAME_CTRL_11 0x511
234#define ARIZONA_AIF1_FRAME_CTRL_12 0x512
235#define ARIZONA_AIF1_FRAME_CTRL_13 0x513
236#define ARIZONA_AIF1_FRAME_CTRL_14 0x514
237#define ARIZONA_AIF1_FRAME_CTRL_15 0x515
238#define ARIZONA_AIF1_FRAME_CTRL_16 0x516
239#define ARIZONA_AIF1_FRAME_CTRL_17 0x517
240#define ARIZONA_AIF1_FRAME_CTRL_18 0x518
241#define ARIZONA_AIF1_TX_ENABLES 0x519
242#define ARIZONA_AIF1_RX_ENABLES 0x51A
243#define ARIZONA_AIF1_FORCE_WRITE 0x51B
244#define ARIZONA_AIF2_BCLK_CTRL 0x540
245#define ARIZONA_AIF2_TX_PIN_CTRL 0x541
246#define ARIZONA_AIF2_RX_PIN_CTRL 0x542
247#define ARIZONA_AIF2_RATE_CTRL 0x543
248#define ARIZONA_AIF2_FORMAT 0x544
249#define ARIZONA_AIF2_TX_BCLK_RATE 0x545
250#define ARIZONA_AIF2_RX_BCLK_RATE 0x546
251#define ARIZONA_AIF2_FRAME_CTRL_1 0x547
252#define ARIZONA_AIF2_FRAME_CTRL_2 0x548
253#define ARIZONA_AIF2_FRAME_CTRL_3 0x549
254#define ARIZONA_AIF2_FRAME_CTRL_4 0x54A
255#define ARIZONA_AIF2_FRAME_CTRL_11 0x551
256#define ARIZONA_AIF2_FRAME_CTRL_12 0x552
257#define ARIZONA_AIF2_TX_ENABLES 0x559
258#define ARIZONA_AIF2_RX_ENABLES 0x55A
259#define ARIZONA_AIF2_FORCE_WRITE 0x55B
260#define ARIZONA_AIF3_BCLK_CTRL 0x580
261#define ARIZONA_AIF3_TX_PIN_CTRL 0x581
262#define ARIZONA_AIF3_RX_PIN_CTRL 0x582
263#define ARIZONA_AIF3_RATE_CTRL 0x583
264#define ARIZONA_AIF3_FORMAT 0x584
265#define ARIZONA_AIF3_TX_BCLK_RATE 0x585
266#define ARIZONA_AIF3_RX_BCLK_RATE 0x586
267#define ARIZONA_AIF3_FRAME_CTRL_1 0x587
268#define ARIZONA_AIF3_FRAME_CTRL_2 0x588
269#define ARIZONA_AIF3_FRAME_CTRL_3 0x589
270#define ARIZONA_AIF3_FRAME_CTRL_4 0x58A
271#define ARIZONA_AIF3_FRAME_CTRL_11 0x591
272#define ARIZONA_AIF3_FRAME_CTRL_12 0x592
273#define ARIZONA_AIF3_TX_ENABLES 0x599
274#define ARIZONA_AIF3_RX_ENABLES 0x59A
275#define ARIZONA_AIF3_FORCE_WRITE 0x59B
276#define ARIZONA_SLIMBUS_FRAMER_REF_GEAR 0x5E3
277#define ARIZONA_SLIMBUS_RATES_1 0x5E5
278#define ARIZONA_SLIMBUS_RATES_2 0x5E6
279#define ARIZONA_SLIMBUS_RATES_3 0x5E7
280#define ARIZONA_SLIMBUS_RATES_4 0x5E8
281#define ARIZONA_SLIMBUS_RATES_5 0x5E9
282#define ARIZONA_SLIMBUS_RATES_6 0x5EA
283#define ARIZONA_SLIMBUS_RATES_7 0x5EB
284#define ARIZONA_SLIMBUS_RATES_8 0x5EC
285#define ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE 0x5F5
286#define ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE 0x5F6
287#define ARIZONA_SLIMBUS_RX_PORT_STATUS 0x5F7
288#define ARIZONA_SLIMBUS_TX_PORT_STATUS 0x5F8
289#define ARIZONA_PWM1MIX_INPUT_1_SOURCE 0x640
290#define ARIZONA_PWM1MIX_INPUT_1_VOLUME 0x641
291#define ARIZONA_PWM1MIX_INPUT_2_SOURCE 0x642
292#define ARIZONA_PWM1MIX_INPUT_2_VOLUME 0x643
293#define ARIZONA_PWM1MIX_INPUT_3_SOURCE 0x644
294#define ARIZONA_PWM1MIX_INPUT_3_VOLUME 0x645
295#define ARIZONA_PWM1MIX_INPUT_4_SOURCE 0x646
296#define ARIZONA_PWM1MIX_INPUT_4_VOLUME 0x647
297#define ARIZONA_PWM2MIX_INPUT_1_SOURCE 0x648
298#define ARIZONA_PWM2MIX_INPUT_1_VOLUME 0x649
299#define ARIZONA_PWM2MIX_INPUT_2_SOURCE 0x64A
300#define ARIZONA_PWM2MIX_INPUT_2_VOLUME 0x64B
301#define ARIZONA_PWM2MIX_INPUT_3_SOURCE 0x64C
302#define ARIZONA_PWM2MIX_INPUT_3_VOLUME 0x64D
303#define ARIZONA_PWM2MIX_INPUT_4_SOURCE 0x64E
304#define ARIZONA_PWM2MIX_INPUT_4_VOLUME 0x64F
305#define ARIZONA_MICMIX_INPUT_1_SOURCE 0x660
306#define ARIZONA_MICMIX_INPUT_1_VOLUME 0x661
307#define ARIZONA_MICMIX_INPUT_2_SOURCE 0x662
308#define ARIZONA_MICMIX_INPUT_2_VOLUME 0x663
309#define ARIZONA_MICMIX_INPUT_3_SOURCE 0x664
310#define ARIZONA_MICMIX_INPUT_3_VOLUME 0x665
311#define ARIZONA_MICMIX_INPUT_4_SOURCE 0x666
312#define ARIZONA_MICMIX_INPUT_4_VOLUME 0x667
313#define ARIZONA_NOISEMIX_INPUT_1_SOURCE 0x668
314#define ARIZONA_NOISEMIX_INPUT_1_VOLUME 0x669
315#define ARIZONA_NOISEMIX_INPUT_2_SOURCE 0x66A
316#define ARIZONA_NOISEMIX_INPUT_2_VOLUME 0x66B
317#define ARIZONA_NOISEMIX_INPUT_3_SOURCE 0x66C
318#define ARIZONA_NOISEMIX_INPUT_3_VOLUME 0x66D
319#define ARIZONA_NOISEMIX_INPUT_4_SOURCE 0x66E
320#define ARIZONA_NOISEMIX_INPUT_4_VOLUME 0x66F
321#define ARIZONA_OUT1LMIX_INPUT_1_SOURCE 0x680
322#define ARIZONA_OUT1LMIX_INPUT_1_VOLUME 0x681
323#define ARIZONA_OUT1LMIX_INPUT_2_SOURCE 0x682
324#define ARIZONA_OUT1LMIX_INPUT_2_VOLUME 0x683
325#define ARIZONA_OUT1LMIX_INPUT_3_SOURCE 0x684
326#define ARIZONA_OUT1LMIX_INPUT_3_VOLUME 0x685
327#define ARIZONA_OUT1LMIX_INPUT_4_SOURCE 0x686
328#define ARIZONA_OUT1LMIX_INPUT_4_VOLUME 0x687
329#define ARIZONA_OUT1RMIX_INPUT_1_SOURCE 0x688
330#define ARIZONA_OUT1RMIX_INPUT_1_VOLUME 0x689
331#define ARIZONA_OUT1RMIX_INPUT_2_SOURCE 0x68A
332#define ARIZONA_OUT1RMIX_INPUT_2_VOLUME 0x68B
333#define ARIZONA_OUT1RMIX_INPUT_3_SOURCE 0x68C
334#define ARIZONA_OUT1RMIX_INPUT_3_VOLUME 0x68D
335#define ARIZONA_OUT1RMIX_INPUT_4_SOURCE 0x68E
336#define ARIZONA_OUT1RMIX_INPUT_4_VOLUME 0x68F
337#define ARIZONA_OUT2LMIX_INPUT_1_SOURCE 0x690
338#define ARIZONA_OUT2LMIX_INPUT_1_VOLUME 0x691
339#define ARIZONA_OUT2LMIX_INPUT_2_SOURCE 0x692
340#define ARIZONA_OUT2LMIX_INPUT_2_VOLUME 0x693
341#define ARIZONA_OUT2LMIX_INPUT_3_SOURCE 0x694
342#define ARIZONA_OUT2LMIX_INPUT_3_VOLUME 0x695
343#define ARIZONA_OUT2LMIX_INPUT_4_SOURCE 0x696
344#define ARIZONA_OUT2LMIX_INPUT_4_VOLUME 0x697
345#define ARIZONA_OUT2RMIX_INPUT_1_SOURCE 0x698
346#define ARIZONA_OUT2RMIX_INPUT_1_VOLUME 0x699
347#define ARIZONA_OUT2RMIX_INPUT_2_SOURCE 0x69A
348#define ARIZONA_OUT2RMIX_INPUT_2_VOLUME 0x69B
349#define ARIZONA_OUT2RMIX_INPUT_3_SOURCE 0x69C
350#define ARIZONA_OUT2RMIX_INPUT_3_VOLUME 0x69D
351#define ARIZONA_OUT2RMIX_INPUT_4_SOURCE 0x69E
352#define ARIZONA_OUT2RMIX_INPUT_4_VOLUME 0x69F
353#define ARIZONA_OUT3LMIX_INPUT_1_SOURCE 0x6A0
354#define ARIZONA_OUT3LMIX_INPUT_1_VOLUME 0x6A1
355#define ARIZONA_OUT3LMIX_INPUT_2_SOURCE 0x6A2
356#define ARIZONA_OUT3LMIX_INPUT_2_VOLUME 0x6A3
357#define ARIZONA_OUT3LMIX_INPUT_3_SOURCE 0x6A4
358#define ARIZONA_OUT3LMIX_INPUT_3_VOLUME 0x6A5
359#define ARIZONA_OUT3LMIX_INPUT_4_SOURCE 0x6A6
360#define ARIZONA_OUT3LMIX_INPUT_4_VOLUME 0x6A7
361#define ARIZONA_OUT3RMIX_INPUT_1_SOURCE 0x6A8
362#define ARIZONA_OUT3RMIX_INPUT_1_VOLUME 0x6A9
363#define ARIZONA_OUT3RMIX_INPUT_2_SOURCE 0x6AA
364#define ARIZONA_OUT3RMIX_INPUT_2_VOLUME 0x6AB
365#define ARIZONA_OUT3RMIX_INPUT_3_SOURCE 0x6AC
366#define ARIZONA_OUT3RMIX_INPUT_3_VOLUME 0x6AD
367#define ARIZONA_OUT3RMIX_INPUT_4_SOURCE 0x6AE
368#define ARIZONA_OUT3RMIX_INPUT_4_VOLUME 0x6AF
369#define ARIZONA_OUT4LMIX_INPUT_1_SOURCE 0x6B0
370#define ARIZONA_OUT4LMIX_INPUT_1_VOLUME 0x6B1
371#define ARIZONA_OUT4LMIX_INPUT_2_SOURCE 0x6B2
372#define ARIZONA_OUT4LMIX_INPUT_2_VOLUME 0x6B3
373#define ARIZONA_OUT4LMIX_INPUT_3_SOURCE 0x6B4
374#define ARIZONA_OUT4LMIX_INPUT_3_VOLUME 0x6B5
375#define ARIZONA_OUT4LMIX_INPUT_4_SOURCE 0x6B6
376#define ARIZONA_OUT4LMIX_INPUT_4_VOLUME 0x6B7
377#define ARIZONA_OUT4RMIX_INPUT_1_SOURCE 0x6B8
378#define ARIZONA_OUT4RMIX_INPUT_1_VOLUME 0x6B9
379#define ARIZONA_OUT4RMIX_INPUT_2_SOURCE 0x6BA
380#define ARIZONA_OUT4RMIX_INPUT_2_VOLUME 0x6BB
381#define ARIZONA_OUT4RMIX_INPUT_3_SOURCE 0x6BC
382#define ARIZONA_OUT4RMIX_INPUT_3_VOLUME 0x6BD
383#define ARIZONA_OUT4RMIX_INPUT_4_SOURCE 0x6BE
384#define ARIZONA_OUT4RMIX_INPUT_4_VOLUME 0x6BF
385#define ARIZONA_OUT5LMIX_INPUT_1_SOURCE 0x6C0
386#define ARIZONA_OUT5LMIX_INPUT_1_VOLUME 0x6C1
387#define ARIZONA_OUT5LMIX_INPUT_2_SOURCE 0x6C2
388#define ARIZONA_OUT5LMIX_INPUT_2_VOLUME 0x6C3
389#define ARIZONA_OUT5LMIX_INPUT_3_SOURCE 0x6C4
390#define ARIZONA_OUT5LMIX_INPUT_3_VOLUME 0x6C5
391#define ARIZONA_OUT5LMIX_INPUT_4_SOURCE 0x6C6
392#define ARIZONA_OUT5LMIX_INPUT_4_VOLUME 0x6C7
393#define ARIZONA_OUT5RMIX_INPUT_1_SOURCE 0x6C8
394#define ARIZONA_OUT5RMIX_INPUT_1_VOLUME 0x6C9
395#define ARIZONA_OUT5RMIX_INPUT_2_SOURCE 0x6CA
396#define ARIZONA_OUT5RMIX_INPUT_2_VOLUME 0x6CB
397#define ARIZONA_OUT5RMIX_INPUT_3_SOURCE 0x6CC
398#define ARIZONA_OUT5RMIX_INPUT_3_VOLUME 0x6CD
399#define ARIZONA_OUT5RMIX_INPUT_4_SOURCE 0x6CE
400#define ARIZONA_OUT5RMIX_INPUT_4_VOLUME 0x6CF
401#define ARIZONA_OUT6LMIX_INPUT_1_SOURCE 0x6D0
402#define ARIZONA_OUT6LMIX_INPUT_1_VOLUME 0x6D1
403#define ARIZONA_OUT6LMIX_INPUT_2_SOURCE 0x6D2
404#define ARIZONA_OUT6LMIX_INPUT_2_VOLUME 0x6D3
405#define ARIZONA_OUT6LMIX_INPUT_3_SOURCE 0x6D4
406#define ARIZONA_OUT6LMIX_INPUT_3_VOLUME 0x6D5
407#define ARIZONA_OUT6LMIX_INPUT_4_SOURCE 0x6D6
408#define ARIZONA_OUT6LMIX_INPUT_4_VOLUME 0x6D7
409#define ARIZONA_OUT6RMIX_INPUT_1_SOURCE 0x6D8
410#define ARIZONA_OUT6RMIX_INPUT_1_VOLUME 0x6D9
411#define ARIZONA_OUT6RMIX_INPUT_2_SOURCE 0x6DA
412#define ARIZONA_OUT6RMIX_INPUT_2_VOLUME 0x6DB
413#define ARIZONA_OUT6RMIX_INPUT_3_SOURCE 0x6DC
414#define ARIZONA_OUT6RMIX_INPUT_3_VOLUME 0x6DD
415#define ARIZONA_OUT6RMIX_INPUT_4_SOURCE 0x6DE
416#define ARIZONA_OUT6RMIX_INPUT_4_VOLUME 0x6DF
417#define ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE 0x700
418#define ARIZONA_AIF1TX1MIX_INPUT_1_VOLUME 0x701
419#define ARIZONA_AIF1TX1MIX_INPUT_2_SOURCE 0x702
420#define ARIZONA_AIF1TX1MIX_INPUT_2_VOLUME 0x703
421#define ARIZONA_AIF1TX1MIX_INPUT_3_SOURCE 0x704
422#define ARIZONA_AIF1TX1MIX_INPUT_3_VOLUME 0x705
423#define ARIZONA_AIF1TX1MIX_INPUT_4_SOURCE 0x706
424#define ARIZONA_AIF1TX1MIX_INPUT_4_VOLUME 0x707
425#define ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE 0x708
426#define ARIZONA_AIF1TX2MIX_INPUT_1_VOLUME 0x709
427#define ARIZONA_AIF1TX2MIX_INPUT_2_SOURCE 0x70A
428#define ARIZONA_AIF1TX2MIX_INPUT_2_VOLUME 0x70B
429#define ARIZONA_AIF1TX2MIX_INPUT_3_SOURCE 0x70C
430#define ARIZONA_AIF1TX2MIX_INPUT_3_VOLUME 0x70D
431#define ARIZONA_AIF1TX2MIX_INPUT_4_SOURCE 0x70E
432#define ARIZONA_AIF1TX2MIX_INPUT_4_VOLUME 0x70F
433#define ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE 0x710
434#define ARIZONA_AIF1TX3MIX_INPUT_1_VOLUME 0x711
435#define ARIZONA_AIF1TX3MIX_INPUT_2_SOURCE 0x712
436#define ARIZONA_AIF1TX3MIX_INPUT_2_VOLUME 0x713
437#define ARIZONA_AIF1TX3MIX_INPUT_3_SOURCE 0x714
438#define ARIZONA_AIF1TX3MIX_INPUT_3_VOLUME 0x715
439#define ARIZONA_AIF1TX3MIX_INPUT_4_SOURCE 0x716
440#define ARIZONA_AIF1TX3MIX_INPUT_4_VOLUME 0x717
441#define ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE 0x718
442#define ARIZONA_AIF1TX4MIX_INPUT_1_VOLUME 0x719
443#define ARIZONA_AIF1TX4MIX_INPUT_2_SOURCE 0x71A
444#define ARIZONA_AIF1TX4MIX_INPUT_2_VOLUME 0x71B
445#define ARIZONA_AIF1TX4MIX_INPUT_3_SOURCE 0x71C
446#define ARIZONA_AIF1TX4MIX_INPUT_3_VOLUME 0x71D
447#define ARIZONA_AIF1TX4MIX_INPUT_4_SOURCE 0x71E
448#define ARIZONA_AIF1TX4MIX_INPUT_4_VOLUME 0x71F
449#define ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE 0x720
450#define ARIZONA_AIF1TX5MIX_INPUT_1_VOLUME 0x721
451#define ARIZONA_AIF1TX5MIX_INPUT_2_SOURCE 0x722
452#define ARIZONA_AIF1TX5MIX_INPUT_2_VOLUME 0x723
453#define ARIZONA_AIF1TX5MIX_INPUT_3_SOURCE 0x724
454#define ARIZONA_AIF1TX5MIX_INPUT_3_VOLUME 0x725
455#define ARIZONA_AIF1TX5MIX_INPUT_4_SOURCE 0x726
456#define ARIZONA_AIF1TX5MIX_INPUT_4_VOLUME 0x727
457#define ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE 0x728
458#define ARIZONA_AIF1TX6MIX_INPUT_1_VOLUME 0x729
459#define ARIZONA_AIF1TX6MIX_INPUT_2_SOURCE 0x72A
460#define ARIZONA_AIF1TX6MIX_INPUT_2_VOLUME 0x72B
461#define ARIZONA_AIF1TX6MIX_INPUT_3_SOURCE 0x72C
462#define ARIZONA_AIF1TX6MIX_INPUT_3_VOLUME 0x72D
463#define ARIZONA_AIF1TX6MIX_INPUT_4_SOURCE 0x72E
464#define ARIZONA_AIF1TX6MIX_INPUT_4_VOLUME 0x72F
465#define ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE 0x730
466#define ARIZONA_AIF1TX7MIX_INPUT_1_VOLUME 0x731
467#define ARIZONA_AIF1TX7MIX_INPUT_2_SOURCE 0x732
468#define ARIZONA_AIF1TX7MIX_INPUT_2_VOLUME 0x733
469#define ARIZONA_AIF1TX7MIX_INPUT_3_SOURCE 0x734
470#define ARIZONA_AIF1TX7MIX_INPUT_3_VOLUME 0x735
471#define ARIZONA_AIF1TX7MIX_INPUT_4_SOURCE 0x736
472#define ARIZONA_AIF1TX7MIX_INPUT_4_VOLUME 0x737
473#define ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE 0x738
474#define ARIZONA_AIF1TX8MIX_INPUT_1_VOLUME 0x739
475#define ARIZONA_AIF1TX8MIX_INPUT_2_SOURCE 0x73A
476#define ARIZONA_AIF1TX8MIX_INPUT_2_VOLUME 0x73B
477#define ARIZONA_AIF1TX8MIX_INPUT_3_SOURCE 0x73C
478#define ARIZONA_AIF1TX8MIX_INPUT_3_VOLUME 0x73D
479#define ARIZONA_AIF1TX8MIX_INPUT_4_SOURCE 0x73E
480#define ARIZONA_AIF1TX8MIX_INPUT_4_VOLUME 0x73F
481#define ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE 0x740
482#define ARIZONA_AIF2TX1MIX_INPUT_1_VOLUME 0x741
483#define ARIZONA_AIF2TX1MIX_INPUT_2_SOURCE 0x742
484#define ARIZONA_AIF2TX1MIX_INPUT_2_VOLUME 0x743
485#define ARIZONA_AIF2TX1MIX_INPUT_3_SOURCE 0x744
486#define ARIZONA_AIF2TX1MIX_INPUT_3_VOLUME 0x745
487#define ARIZONA_AIF2TX1MIX_INPUT_4_SOURCE 0x746
488#define ARIZONA_AIF2TX1MIX_INPUT_4_VOLUME 0x747
489#define ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE 0x748
490#define ARIZONA_AIF2TX2MIX_INPUT_1_VOLUME 0x749
491#define ARIZONA_AIF2TX2MIX_INPUT_2_SOURCE 0x74A
492#define ARIZONA_AIF2TX2MIX_INPUT_2_VOLUME 0x74B
493#define ARIZONA_AIF2TX2MIX_INPUT_3_SOURCE 0x74C
494#define ARIZONA_AIF2TX2MIX_INPUT_3_VOLUME 0x74D
495#define ARIZONA_AIF2TX2MIX_INPUT_4_SOURCE 0x74E
496#define ARIZONA_AIF2TX2MIX_INPUT_4_VOLUME 0x74F
497#define ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE 0x780
498#define ARIZONA_AIF3TX1MIX_INPUT_1_VOLUME 0x781
499#define ARIZONA_AIF3TX1MIX_INPUT_2_SOURCE 0x782
500#define ARIZONA_AIF3TX1MIX_INPUT_2_VOLUME 0x783
501#define ARIZONA_AIF3TX1MIX_INPUT_3_SOURCE 0x784
502#define ARIZONA_AIF3TX1MIX_INPUT_3_VOLUME 0x785
503#define ARIZONA_AIF3TX1MIX_INPUT_4_SOURCE 0x786
504#define ARIZONA_AIF3TX1MIX_INPUT_4_VOLUME 0x787
505#define ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE 0x788
506#define ARIZONA_AIF3TX2MIX_INPUT_1_VOLUME 0x789
507#define ARIZONA_AIF3TX2MIX_INPUT_2_SOURCE 0x78A
508#define ARIZONA_AIF3TX2MIX_INPUT_2_VOLUME 0x78B
509#define ARIZONA_AIF3TX2MIX_INPUT_3_SOURCE 0x78C
510#define ARIZONA_AIF3TX2MIX_INPUT_3_VOLUME 0x78D
511#define ARIZONA_AIF3TX2MIX_INPUT_4_SOURCE 0x78E
512#define ARIZONA_AIF3TX2MIX_INPUT_4_VOLUME 0x78F
513#define ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE 0x7C0
514#define ARIZONA_SLIMTX1MIX_INPUT_1_VOLUME 0x7C1
515#define ARIZONA_SLIMTX1MIX_INPUT_2_SOURCE 0x7C2
516#define ARIZONA_SLIMTX1MIX_INPUT_2_VOLUME 0x7C3
517#define ARIZONA_SLIMTX1MIX_INPUT_3_SOURCE 0x7C4
518#define ARIZONA_SLIMTX1MIX_INPUT_3_VOLUME 0x7C5
519#define ARIZONA_SLIMTX1MIX_INPUT_4_SOURCE 0x7C6
520#define ARIZONA_SLIMTX1MIX_INPUT_4_VOLUME 0x7C7
521#define ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE 0x7C8
522#define ARIZONA_SLIMTX2MIX_INPUT_1_VOLUME 0x7C9
523#define ARIZONA_SLIMTX2MIX_INPUT_2_SOURCE 0x7CA
524#define ARIZONA_SLIMTX2MIX_INPUT_2_VOLUME 0x7CB
525#define ARIZONA_SLIMTX2MIX_INPUT_3_SOURCE 0x7CC
526#define ARIZONA_SLIMTX2MIX_INPUT_3_VOLUME 0x7CD
527#define ARIZONA_SLIMTX2MIX_INPUT_4_SOURCE 0x7CE
528#define ARIZONA_SLIMTX2MIX_INPUT_4_VOLUME 0x7CF
529#define ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE 0x7D0
530#define ARIZONA_SLIMTX3MIX_INPUT_1_VOLUME 0x7D1
531#define ARIZONA_SLIMTX3MIX_INPUT_2_SOURCE 0x7D2
532#define ARIZONA_SLIMTX3MIX_INPUT_2_VOLUME 0x7D3
533#define ARIZONA_SLIMTX3MIX_INPUT_3_SOURCE 0x7D4
534#define ARIZONA_SLIMTX3MIX_INPUT_3_VOLUME 0x7D5
535#define ARIZONA_SLIMTX3MIX_INPUT_4_SOURCE 0x7D6
536#define ARIZONA_SLIMTX3MIX_INPUT_4_VOLUME 0x7D7
537#define ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE 0x7D8
538#define ARIZONA_SLIMTX4MIX_INPUT_1_VOLUME 0x7D9
539#define ARIZONA_SLIMTX4MIX_INPUT_2_SOURCE 0x7DA
540#define ARIZONA_SLIMTX4MIX_INPUT_2_VOLUME 0x7DB
541#define ARIZONA_SLIMTX4MIX_INPUT_3_SOURCE 0x7DC
542#define ARIZONA_SLIMTX4MIX_INPUT_3_VOLUME 0x7DD
543#define ARIZONA_SLIMTX4MIX_INPUT_4_SOURCE 0x7DE
544#define ARIZONA_SLIMTX4MIX_INPUT_4_VOLUME 0x7DF
545#define ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE 0x7E0
546#define ARIZONA_SLIMTX5MIX_INPUT_1_VOLUME 0x7E1
547#define ARIZONA_SLIMTX5MIX_INPUT_2_SOURCE 0x7E2
548#define ARIZONA_SLIMTX5MIX_INPUT_2_VOLUME 0x7E3
549#define ARIZONA_SLIMTX5MIX_INPUT_3_SOURCE 0x7E4
550#define ARIZONA_SLIMTX5MIX_INPUT_3_VOLUME 0x7E5
551#define ARIZONA_SLIMTX5MIX_INPUT_4_SOURCE 0x7E6
552#define ARIZONA_SLIMTX5MIX_INPUT_4_VOLUME 0x7E7
553#define ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE 0x7E8
554#define ARIZONA_SLIMTX6MIX_INPUT_1_VOLUME 0x7E9
555#define ARIZONA_SLIMTX6MIX_INPUT_2_SOURCE 0x7EA
556#define ARIZONA_SLIMTX6MIX_INPUT_2_VOLUME 0x7EB
557#define ARIZONA_SLIMTX6MIX_INPUT_3_SOURCE 0x7EC
558#define ARIZONA_SLIMTX6MIX_INPUT_3_VOLUME 0x7ED
559#define ARIZONA_SLIMTX6MIX_INPUT_4_SOURCE 0x7EE
560#define ARIZONA_SLIMTX6MIX_INPUT_4_VOLUME 0x7EF
561#define ARIZONA_SLIMTX7MIX_INPUT_1_SOURCE 0x7F0
562#define ARIZONA_SLIMTX7MIX_INPUT_1_VOLUME 0x7F1
563#define ARIZONA_SLIMTX7MIX_INPUT_2_SOURCE 0x7F2
564#define ARIZONA_SLIMTX7MIX_INPUT_2_VOLUME 0x7F3
565#define ARIZONA_SLIMTX7MIX_INPUT_3_SOURCE 0x7F4
566#define ARIZONA_SLIMTX7MIX_INPUT_3_VOLUME 0x7F5
567#define ARIZONA_SLIMTX7MIX_INPUT_4_SOURCE 0x7F6
568#define ARIZONA_SLIMTX7MIX_INPUT_4_VOLUME 0x7F7
569#define ARIZONA_SLIMTX8MIX_INPUT_1_SOURCE 0x7F8
570#define ARIZONA_SLIMTX8MIX_INPUT_1_VOLUME 0x7F9
571#define ARIZONA_SLIMTX8MIX_INPUT_2_SOURCE 0x7FA
572#define ARIZONA_SLIMTX8MIX_INPUT_2_VOLUME 0x7FB
573#define ARIZONA_SLIMTX8MIX_INPUT_3_SOURCE 0x7FC
574#define ARIZONA_SLIMTX8MIX_INPUT_3_VOLUME 0x7FD
575#define ARIZONA_SLIMTX8MIX_INPUT_4_SOURCE 0x7FE
576#define ARIZONA_SLIMTX8MIX_INPUT_4_VOLUME 0x7FF
577#define ARIZONA_EQ1MIX_INPUT_1_SOURCE 0x880
578#define ARIZONA_EQ1MIX_INPUT_1_VOLUME 0x881
579#define ARIZONA_EQ1MIX_INPUT_2_SOURCE 0x882
580#define ARIZONA_EQ1MIX_INPUT_2_VOLUME 0x883
581#define ARIZONA_EQ1MIX_INPUT_3_SOURCE 0x884
582#define ARIZONA_EQ1MIX_INPUT_3_VOLUME 0x885
583#define ARIZONA_EQ1MIX_INPUT_4_SOURCE 0x886
584#define ARIZONA_EQ1MIX_INPUT_4_VOLUME 0x887
585#define ARIZONA_EQ2MIX_INPUT_1_SOURCE 0x888
586#define ARIZONA_EQ2MIX_INPUT_1_VOLUME 0x889
587#define ARIZONA_EQ2MIX_INPUT_2_SOURCE 0x88A
588#define ARIZONA_EQ2MIX_INPUT_2_VOLUME 0x88B
589#define ARIZONA_EQ2MIX_INPUT_3_SOURCE 0x88C
590#define ARIZONA_EQ2MIX_INPUT_3_VOLUME 0x88D
591#define ARIZONA_EQ2MIX_INPUT_4_SOURCE 0x88E
592#define ARIZONA_EQ2MIX_INPUT_4_VOLUME 0x88F
593#define ARIZONA_EQ3MIX_INPUT_1_SOURCE 0x890
594#define ARIZONA_EQ3MIX_INPUT_1_VOLUME 0x891
595#define ARIZONA_EQ3MIX_INPUT_2_SOURCE 0x892
596#define ARIZONA_EQ3MIX_INPUT_2_VOLUME 0x893
597#define ARIZONA_EQ3MIX_INPUT_3_SOURCE 0x894
598#define ARIZONA_EQ3MIX_INPUT_3_VOLUME 0x895
599#define ARIZONA_EQ3MIX_INPUT_4_SOURCE 0x896
600#define ARIZONA_EQ3MIX_INPUT_4_VOLUME 0x897
601#define ARIZONA_EQ4MIX_INPUT_1_SOURCE 0x898
602#define ARIZONA_EQ4MIX_INPUT_1_VOLUME 0x899
603#define ARIZONA_EQ4MIX_INPUT_2_SOURCE 0x89A
604#define ARIZONA_EQ4MIX_INPUT_2_VOLUME 0x89B
605#define ARIZONA_EQ4MIX_INPUT_3_SOURCE 0x89C
606#define ARIZONA_EQ4MIX_INPUT_3_VOLUME 0x89D
607#define ARIZONA_EQ4MIX_INPUT_4_SOURCE 0x89E
608#define ARIZONA_EQ4MIX_INPUT_4_VOLUME 0x89F
609#define ARIZONA_DRC1LMIX_INPUT_1_SOURCE 0x8C0
610#define ARIZONA_DRC1LMIX_INPUT_1_VOLUME 0x8C1
611#define ARIZONA_DRC1LMIX_INPUT_2_SOURCE 0x8C2
612#define ARIZONA_DRC1LMIX_INPUT_2_VOLUME 0x8C3
613#define ARIZONA_DRC1LMIX_INPUT_3_SOURCE 0x8C4
614#define ARIZONA_DRC1LMIX_INPUT_3_VOLUME 0x8C5
615#define ARIZONA_DRC1LMIX_INPUT_4_SOURCE 0x8C6
616#define ARIZONA_DRC1LMIX_INPUT_4_VOLUME 0x8C7
617#define ARIZONA_DRC1RMIX_INPUT_1_SOURCE 0x8C8
618#define ARIZONA_DRC1RMIX_INPUT_1_VOLUME 0x8C9
619#define ARIZONA_DRC1RMIX_INPUT_2_SOURCE 0x8CA
620#define ARIZONA_DRC1RMIX_INPUT_2_VOLUME 0x8CB
621#define ARIZONA_DRC1RMIX_INPUT_3_SOURCE 0x8CC
622#define ARIZONA_DRC1RMIX_INPUT_3_VOLUME 0x8CD
623#define ARIZONA_DRC1RMIX_INPUT_4_SOURCE 0x8CE
624#define ARIZONA_DRC1RMIX_INPUT_4_VOLUME 0x8CF
625#define ARIZONA_DRC2LMIX_INPUT_1_SOURCE 0x8D0
626#define ARIZONA_DRC2LMIX_INPUT_1_VOLUME 0x8D1
627#define ARIZONA_DRC2LMIX_INPUT_2_SOURCE 0x8D2
628#define ARIZONA_DRC2LMIX_INPUT_2_VOLUME 0x8D3
629#define ARIZONA_DRC2LMIX_INPUT_3_SOURCE 0x8D4
630#define ARIZONA_DRC2LMIX_INPUT_3_VOLUME 0x8D5
631#define ARIZONA_DRC2LMIX_INPUT_4_SOURCE 0x8D6
632#define ARIZONA_DRC2LMIX_INPUT_4_VOLUME 0x8D7
633#define ARIZONA_DRC2RMIX_INPUT_1_SOURCE 0x8D8
634#define ARIZONA_DRC2RMIX_INPUT_1_VOLUME 0x8D9
635#define ARIZONA_DRC2RMIX_INPUT_2_SOURCE 0x8DA
636#define ARIZONA_DRC2RMIX_INPUT_2_VOLUME 0x8DB
637#define ARIZONA_DRC2RMIX_INPUT_3_SOURCE 0x8DC
638#define ARIZONA_DRC2RMIX_INPUT_3_VOLUME 0x8DD
639#define ARIZONA_DRC2RMIX_INPUT_4_SOURCE 0x8DE
640#define ARIZONA_DRC2RMIX_INPUT_4_VOLUME 0x8DF
641#define ARIZONA_HPLP1MIX_INPUT_1_SOURCE 0x900
642#define ARIZONA_HPLP1MIX_INPUT_1_VOLUME 0x901
643#define ARIZONA_HPLP1MIX_INPUT_2_SOURCE 0x902
644#define ARIZONA_HPLP1MIX_INPUT_2_VOLUME 0x903
645#define ARIZONA_HPLP1MIX_INPUT_3_SOURCE 0x904
646#define ARIZONA_HPLP1MIX_INPUT_3_VOLUME 0x905
647#define ARIZONA_HPLP1MIX_INPUT_4_SOURCE 0x906
648#define ARIZONA_HPLP1MIX_INPUT_4_VOLUME 0x907
649#define ARIZONA_HPLP2MIX_INPUT_1_SOURCE 0x908
650#define ARIZONA_HPLP2MIX_INPUT_1_VOLUME 0x909
651#define ARIZONA_HPLP2MIX_INPUT_2_SOURCE 0x90A
652#define ARIZONA_HPLP2MIX_INPUT_2_VOLUME 0x90B
653#define ARIZONA_HPLP2MIX_INPUT_3_SOURCE 0x90C
654#define ARIZONA_HPLP2MIX_INPUT_3_VOLUME 0x90D
655#define ARIZONA_HPLP2MIX_INPUT_4_SOURCE 0x90E
656#define ARIZONA_HPLP2MIX_INPUT_4_VOLUME 0x90F
657#define ARIZONA_HPLP3MIX_INPUT_1_SOURCE 0x910
658#define ARIZONA_HPLP3MIX_INPUT_1_VOLUME 0x911
659#define ARIZONA_HPLP3MIX_INPUT_2_SOURCE 0x912
660#define ARIZONA_HPLP3MIX_INPUT_2_VOLUME 0x913
661#define ARIZONA_HPLP3MIX_INPUT_3_SOURCE 0x914
662#define ARIZONA_HPLP3MIX_INPUT_3_VOLUME 0x915
663#define ARIZONA_HPLP3MIX_INPUT_4_SOURCE 0x916
664#define ARIZONA_HPLP3MIX_INPUT_4_VOLUME 0x917
665#define ARIZONA_HPLP4MIX_INPUT_1_SOURCE 0x918
666#define ARIZONA_HPLP4MIX_INPUT_1_VOLUME 0x919
667#define ARIZONA_HPLP4MIX_INPUT_2_SOURCE 0x91A
668#define ARIZONA_HPLP4MIX_INPUT_2_VOLUME 0x91B
669#define ARIZONA_HPLP4MIX_INPUT_3_SOURCE 0x91C
670#define ARIZONA_HPLP4MIX_INPUT_3_VOLUME 0x91D
671#define ARIZONA_HPLP4MIX_INPUT_4_SOURCE 0x91E
672#define ARIZONA_HPLP4MIX_INPUT_4_VOLUME 0x91F
673#define ARIZONA_DSP1LMIX_INPUT_1_SOURCE 0x940
674#define ARIZONA_DSP1LMIX_INPUT_1_VOLUME 0x941
675#define ARIZONA_DSP1LMIX_INPUT_2_SOURCE 0x942
676#define ARIZONA_DSP1LMIX_INPUT_2_VOLUME 0x943
677#define ARIZONA_DSP1LMIX_INPUT_3_SOURCE 0x944
678#define ARIZONA_DSP1LMIX_INPUT_3_VOLUME 0x945
679#define ARIZONA_DSP1LMIX_INPUT_4_SOURCE 0x946
680#define ARIZONA_DSP1LMIX_INPUT_4_VOLUME 0x947
681#define ARIZONA_DSP1RMIX_INPUT_1_SOURCE 0x948
682#define ARIZONA_DSP1RMIX_INPUT_1_VOLUME 0x949
683#define ARIZONA_DSP1RMIX_INPUT_2_SOURCE 0x94A
684#define ARIZONA_DSP1RMIX_INPUT_2_VOLUME 0x94B
685#define ARIZONA_DSP1RMIX_INPUT_3_SOURCE 0x94C
686#define ARIZONA_DSP1RMIX_INPUT_3_VOLUME 0x94D
687#define ARIZONA_DSP1RMIX_INPUT_4_SOURCE 0x94E
688#define ARIZONA_DSP1RMIX_INPUT_4_VOLUME 0x94F
689#define ARIZONA_DSP1AUX1MIX_INPUT_1_SOURCE 0x950
690#define ARIZONA_DSP1AUX2MIX_INPUT_1_SOURCE 0x958
691#define ARIZONA_DSP1AUX3MIX_INPUT_1_SOURCE 0x960
692#define ARIZONA_DSP1AUX4MIX_INPUT_1_SOURCE 0x968
693#define ARIZONA_DSP1AUX5MIX_INPUT_1_SOURCE 0x970
694#define ARIZONA_DSP1AUX6MIX_INPUT_1_SOURCE 0x978
695#define ARIZONA_DSP2LMIX_INPUT_1_SOURCE 0x980
696#define ARIZONA_DSP2LMIX_INPUT_1_VOLUME 0x981
697#define ARIZONA_DSP2LMIX_INPUT_2_SOURCE 0x982
698#define ARIZONA_DSP2LMIX_INPUT_2_VOLUME 0x983
699#define ARIZONA_DSP2LMIX_INPUT_3_SOURCE 0x984
700#define ARIZONA_DSP2LMIX_INPUT_3_VOLUME 0x985
701#define ARIZONA_DSP2LMIX_INPUT_4_SOURCE 0x986
702#define ARIZONA_DSP2LMIX_INPUT_4_VOLUME 0x987
703#define ARIZONA_DSP2RMIX_INPUT_1_SOURCE 0x988
704#define ARIZONA_DSP2RMIX_INPUT_1_VOLUME 0x989
705#define ARIZONA_DSP2RMIX_INPUT_2_SOURCE 0x98A
706#define ARIZONA_DSP2RMIX_INPUT_2_VOLUME 0x98B
707#define ARIZONA_DSP2RMIX_INPUT_3_SOURCE 0x98C
708#define ARIZONA_DSP2RMIX_INPUT_3_VOLUME 0x98D
709#define ARIZONA_DSP2RMIX_INPUT_4_SOURCE 0x98E
710#define ARIZONA_DSP2RMIX_INPUT_4_VOLUME 0x98F
711#define ARIZONA_DSP2AUX1MIX_INPUT_1_SOURCE 0x990
712#define ARIZONA_DSP2AUX2MIX_INPUT_1_SOURCE 0x998
713#define ARIZONA_DSP2AUX3MIX_INPUT_1_SOURCE 0x9A0
714#define ARIZONA_DSP2AUX4MIX_INPUT_1_SOURCE 0x9A8
715#define ARIZONA_DSP2AUX5MIX_INPUT_1_SOURCE 0x9B0
716#define ARIZONA_DSP2AUX6MIX_INPUT_1_SOURCE 0x9B8
717#define ARIZONA_DSP3LMIX_INPUT_1_SOURCE 0x9C0
718#define ARIZONA_DSP3LMIX_INPUT_1_VOLUME 0x9C1
719#define ARIZONA_DSP3LMIX_INPUT_2_SOURCE 0x9C2
720#define ARIZONA_DSP3LMIX_INPUT_2_VOLUME 0x9C3
721#define ARIZONA_DSP3LMIX_INPUT_3_SOURCE 0x9C4
722#define ARIZONA_DSP3LMIX_INPUT_3_VOLUME 0x9C5
723#define ARIZONA_DSP3LMIX_INPUT_4_SOURCE 0x9C6
724#define ARIZONA_DSP3LMIX_INPUT_4_VOLUME 0x9C7
725#define ARIZONA_DSP3RMIX_INPUT_1_SOURCE 0x9C8
726#define ARIZONA_DSP3RMIX_INPUT_1_VOLUME 0x9C9
727#define ARIZONA_DSP3RMIX_INPUT_2_SOURCE 0x9CA
728#define ARIZONA_DSP3RMIX_INPUT_2_VOLUME 0x9CB
729#define ARIZONA_DSP3RMIX_INPUT_3_SOURCE 0x9CC
730#define ARIZONA_DSP3RMIX_INPUT_3_VOLUME 0x9CD
731#define ARIZONA_DSP3RMIX_INPUT_4_SOURCE 0x9CE
732#define ARIZONA_DSP3RMIX_INPUT_4_VOLUME 0x9CF
733#define ARIZONA_DSP3AUX1MIX_INPUT_1_SOURCE 0x9D0
734#define ARIZONA_DSP3AUX2MIX_INPUT_1_SOURCE 0x9D8
735#define ARIZONA_DSP3AUX3MIX_INPUT_1_SOURCE 0x9E0
736#define ARIZONA_DSP3AUX4MIX_INPUT_1_SOURCE 0x9E8
737#define ARIZONA_DSP3AUX5MIX_INPUT_1_SOURCE 0x9F0
738#define ARIZONA_DSP3AUX6MIX_INPUT_1_SOURCE 0x9F8
739#define ARIZONA_DSP4LMIX_INPUT_1_SOURCE 0xA00
740#define ARIZONA_DSP4LMIX_INPUT_1_VOLUME 0xA01
741#define ARIZONA_DSP4LMIX_INPUT_2_SOURCE 0xA02
742#define ARIZONA_DSP4LMIX_INPUT_2_VOLUME 0xA03
743#define ARIZONA_DSP4LMIX_INPUT_3_SOURCE 0xA04
744#define ARIZONA_DSP4LMIX_INPUT_3_VOLUME 0xA05
745#define ARIZONA_DSP4LMIX_INPUT_4_SOURCE 0xA06
746#define ARIZONA_DSP4LMIX_INPUT_4_VOLUME 0xA07
747#define ARIZONA_DSP4RMIX_INPUT_1_SOURCE 0xA08
748#define ARIZONA_DSP4RMIX_INPUT_1_VOLUME 0xA09
749#define ARIZONA_DSP4RMIX_INPUT_2_SOURCE 0xA0A
750#define ARIZONA_DSP4RMIX_INPUT_2_VOLUME 0xA0B
751#define ARIZONA_DSP4RMIX_INPUT_3_SOURCE 0xA0C
752#define ARIZONA_DSP4RMIX_INPUT_3_VOLUME 0xA0D
753#define ARIZONA_DSP4RMIX_INPUT_4_SOURCE 0xA0E
754#define ARIZONA_DSP4RMIX_INPUT_4_VOLUME 0xA0F
755#define ARIZONA_DSP4AUX1MIX_INPUT_1_SOURCE 0xA10
756#define ARIZONA_DSP4AUX2MIX_INPUT_1_SOURCE 0xA18
757#define ARIZONA_DSP4AUX3MIX_INPUT_1_SOURCE 0xA20
758#define ARIZONA_DSP4AUX4MIX_INPUT_1_SOURCE 0xA28
759#define ARIZONA_DSP4AUX5MIX_INPUT_1_SOURCE 0xA30
760#define ARIZONA_DSP4AUX6MIX_INPUT_1_SOURCE 0xA38
761#define ARIZONA_ASRC1LMIX_INPUT_1_SOURCE 0xA80
762#define ARIZONA_ASRC1RMIX_INPUT_1_SOURCE 0xA88
763#define ARIZONA_ASRC2LMIX_INPUT_1_SOURCE 0xA90
764#define ARIZONA_ASRC2RMIX_INPUT_1_SOURCE 0xA98
765#define ARIZONA_ISRC1DEC1MIX_INPUT_1_SOURCE 0xB00
766#define ARIZONA_ISRC1DEC2MIX_INPUT_1_SOURCE 0xB08
767#define ARIZONA_ISRC1DEC3MIX_INPUT_1_SOURCE 0xB10
768#define ARIZONA_ISRC1DEC4MIX_INPUT_1_SOURCE 0xB18
769#define ARIZONA_ISRC1INT1MIX_INPUT_1_SOURCE 0xB20
770#define ARIZONA_ISRC1INT2MIX_INPUT_1_SOURCE 0xB28
771#define ARIZONA_ISRC1INT3MIX_INPUT_1_SOURCE 0xB30
772#define ARIZONA_ISRC1INT4MIX_INPUT_1_SOURCE 0xB38
773#define ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE 0xB40
774#define ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE 0xB48
775#define ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE 0xB60
776#define ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE 0xB68
777#define ARIZONA_ISRC1INT3MIX_INPUT_1_SOURCE 0xB30
778#define ARIZONA_ISRC1INT4MIX_INPUT_1_SOURCE 0xB38
779#define ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE 0xB40
780#define ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE 0xB48
781#define ARIZONA_ISRC2DEC3MIX_INPUT_1_SOURCE 0xB50
782#define ARIZONA_ISRC2DEC4MIX_INPUT_1_SOURCE 0xB58
783#define ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE 0xB60
784#define ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE 0xB68
785#define ARIZONA_ISRC2INT3MIX_INPUT_1_SOURCE 0xB70
786#define ARIZONA_ISRC2INT4MIX_INPUT_1_SOURCE 0xB78
787#define ARIZONA_ISRC3DEC1MIX_INPUT_1_SOURCE 0xB80
788#define ARIZONA_ISRC3DEC2MIX_INPUT_1_SOURCE 0xB88
789#define ARIZONA_ISRC3DEC3MIX_INPUT_1_SOURCE 0xB90
790#define ARIZONA_ISRC3DEC4MIX_INPUT_1_SOURCE 0xB98
791#define ARIZONA_ISRC3INT1MIX_INPUT_1_SOURCE 0xBA0
792#define ARIZONA_ISRC3INT2MIX_INPUT_1_SOURCE 0xBA8
793#define ARIZONA_ISRC3INT3MIX_INPUT_1_SOURCE 0xBB0
794#define ARIZONA_ISRC3INT4MIX_INPUT_1_SOURCE 0xBB8
795#define ARIZONA_GPIO1_CTRL 0xC00
796#define ARIZONA_GPIO2_CTRL 0xC01
797#define ARIZONA_GPIO3_CTRL 0xC02
798#define ARIZONA_GPIO4_CTRL 0xC03
799#define ARIZONA_GPIO5_CTRL 0xC04
800#define ARIZONA_IRQ_CTRL_1 0xC0F
801#define ARIZONA_GPIO_DEBOUNCE_CONFIG 0xC10
802#define ARIZONA_MISC_PAD_CTRL_1 0xC20
803#define ARIZONA_MISC_PAD_CTRL_2 0xC21
804#define ARIZONA_MISC_PAD_CTRL_3 0xC22
805#define ARIZONA_MISC_PAD_CTRL_4 0xC23
806#define ARIZONA_MISC_PAD_CTRL_5 0xC24
807#define ARIZONA_MISC_PAD_CTRL_6 0xC25
808#define ARIZONA_MISC_PAD_CTRL_7 0xC30
809#define ARIZONA_MISC_PAD_CTRL_8 0xC31
810#define ARIZONA_MISC_PAD_CTRL_9 0xC32
811#define ARIZONA_MISC_PAD_CTRL_10 0xC33
812#define ARIZONA_MISC_PAD_CTRL_11 0xC34
813#define ARIZONA_MISC_PAD_CTRL_12 0xC35
814#define ARIZONA_MISC_PAD_CTRL_13 0xC36
815#define ARIZONA_MISC_PAD_CTRL_14 0xC37
816#define ARIZONA_MISC_PAD_CTRL_15 0xC38
817#define ARIZONA_MISC_PAD_CTRL_16 0xC39
818#define ARIZONA_MISC_PAD_CTRL_17 0xC3A
819#define ARIZONA_MISC_PAD_CTRL_18 0xC3B
820#define ARIZONA_INTERRUPT_STATUS_1 0xD00
821#define ARIZONA_INTERRUPT_STATUS_2 0xD01
822#define ARIZONA_INTERRUPT_STATUS_3 0xD02
823#define ARIZONA_INTERRUPT_STATUS_4 0xD03
824#define ARIZONA_INTERRUPT_STATUS_5 0xD04
825#define ARIZONA_INTERRUPT_STATUS_1_MASK 0xD08
826#define ARIZONA_INTERRUPT_STATUS_2_MASK 0xD09
827#define ARIZONA_INTERRUPT_STATUS_3_MASK 0xD0A
828#define ARIZONA_INTERRUPT_STATUS_4_MASK 0xD0B
829#define ARIZONA_INTERRUPT_STATUS_5_MASK 0xD0C
830#define ARIZONA_INTERRUPT_CONTROL 0xD0F
831#define ARIZONA_IRQ2_STATUS_1 0xD10
832#define ARIZONA_IRQ2_STATUS_2 0xD11
833#define ARIZONA_IRQ2_STATUS_3 0xD12
834#define ARIZONA_IRQ2_STATUS_4 0xD13
835#define ARIZONA_IRQ2_STATUS_5 0xD14
836#define ARIZONA_IRQ2_STATUS_1_MASK 0xD18
837#define ARIZONA_IRQ2_STATUS_2_MASK 0xD19
838#define ARIZONA_IRQ2_STATUS_3_MASK 0xD1A
839#define ARIZONA_IRQ2_STATUS_4_MASK 0xD1B
840#define ARIZONA_IRQ2_STATUS_5_MASK 0xD1C
841#define ARIZONA_IRQ2_CONTROL 0xD1F
842#define ARIZONA_INTERRUPT_RAW_STATUS_2 0xD20
843#define ARIZONA_INTERRUPT_RAW_STATUS_3 0xD21
844#define ARIZONA_INTERRUPT_RAW_STATUS_4 0xD22
845#define ARIZONA_INTERRUPT_RAW_STATUS_5 0xD23
846#define ARIZONA_INTERRUPT_RAW_STATUS_6 0xD24
847#define ARIZONA_INTERRUPT_RAW_STATUS_7 0xD25
848#define ARIZONA_INTERRUPT_RAW_STATUS_8 0xD26
849#define ARIZONA_IRQ_PIN_STATUS 0xD40
850#define ARIZONA_ADSP2_IRQ0 0xD41
851#define ARIZONA_AOD_WKUP_AND_TRIG 0xD50
852#define ARIZONA_AOD_IRQ1 0xD51
853#define ARIZONA_AOD_IRQ2 0xD52
854#define ARIZONA_AOD_IRQ_MASK_IRQ1 0xD53
855#define ARIZONA_AOD_IRQ_MASK_IRQ2 0xD54
856#define ARIZONA_AOD_IRQ_RAW_STATUS 0xD55
857#define ARIZONA_JACK_DETECT_DEBOUNCE 0xD56
858#define ARIZONA_FX_CTRL1 0xE00
859#define ARIZONA_FX_CTRL2 0xE01
860#define ARIZONA_EQ1_1 0xE10
861#define ARIZONA_EQ1_2 0xE11
862#define ARIZONA_EQ1_3 0xE12
863#define ARIZONA_EQ1_4 0xE13
864#define ARIZONA_EQ1_5 0xE14
865#define ARIZONA_EQ1_6 0xE15
866#define ARIZONA_EQ1_7 0xE16
867#define ARIZONA_EQ1_8 0xE17
868#define ARIZONA_EQ1_9 0xE18
869#define ARIZONA_EQ1_10 0xE19
870#define ARIZONA_EQ1_11 0xE1A
871#define ARIZONA_EQ1_12 0xE1B
872#define ARIZONA_EQ1_13 0xE1C
873#define ARIZONA_EQ1_14 0xE1D
874#define ARIZONA_EQ1_15 0xE1E
875#define ARIZONA_EQ1_16 0xE1F
876#define ARIZONA_EQ1_17 0xE20
877#define ARIZONA_EQ1_18 0xE21
878#define ARIZONA_EQ1_19 0xE22
879#define ARIZONA_EQ1_20 0xE23
880#define ARIZONA_EQ1_21 0xE24
881#define ARIZONA_EQ2_1 0xE26
882#define ARIZONA_EQ2_2 0xE27
883#define ARIZONA_EQ2_3 0xE28
884#define ARIZONA_EQ2_4 0xE29
885#define ARIZONA_EQ2_5 0xE2A
886#define ARIZONA_EQ2_6 0xE2B
887#define ARIZONA_EQ2_7 0xE2C
888#define ARIZONA_EQ2_8 0xE2D
889#define ARIZONA_EQ2_9 0xE2E
890#define ARIZONA_EQ2_10 0xE2F
891#define ARIZONA_EQ2_11 0xE30
892#define ARIZONA_EQ2_12 0xE31
893#define ARIZONA_EQ2_13 0xE32
894#define ARIZONA_EQ2_14 0xE33
895#define ARIZONA_EQ2_15 0xE34
896#define ARIZONA_EQ2_16 0xE35
897#define ARIZONA_EQ2_17 0xE36
898#define ARIZONA_EQ2_18 0xE37
899#define ARIZONA_EQ2_19 0xE38
900#define ARIZONA_EQ2_20 0xE39
901#define ARIZONA_EQ2_21 0xE3A
902#define ARIZONA_EQ3_1 0xE3C
903#define ARIZONA_EQ3_2 0xE3D
904#define ARIZONA_EQ3_3 0xE3E
905#define ARIZONA_EQ3_4 0xE3F
906#define ARIZONA_EQ3_5 0xE40
907#define ARIZONA_EQ3_6 0xE41
908#define ARIZONA_EQ3_7 0xE42
909#define ARIZONA_EQ3_8 0xE43
910#define ARIZONA_EQ3_9 0xE44
911#define ARIZONA_EQ3_10 0xE45
912#define ARIZONA_EQ3_11 0xE46
913#define ARIZONA_EQ3_12 0xE47
914#define ARIZONA_EQ3_13 0xE48
915#define ARIZONA_EQ3_14 0xE49
916#define ARIZONA_EQ3_15 0xE4A
917#define ARIZONA_EQ3_16 0xE4B
918#define ARIZONA_EQ3_17 0xE4C
919#define ARIZONA_EQ3_18 0xE4D
920#define ARIZONA_EQ3_19 0xE4E
921#define ARIZONA_EQ3_20 0xE4F
922#define ARIZONA_EQ3_21 0xE50
923#define ARIZONA_EQ4_1 0xE52
924#define ARIZONA_EQ4_2 0xE53
925#define ARIZONA_EQ4_3 0xE54
926#define ARIZONA_EQ4_4 0xE55
927#define ARIZONA_EQ4_5 0xE56
928#define ARIZONA_EQ4_6 0xE57
929#define ARIZONA_EQ4_7 0xE58
930#define ARIZONA_EQ4_8 0xE59
931#define ARIZONA_EQ4_9 0xE5A
932#define ARIZONA_EQ4_10 0xE5B
933#define ARIZONA_EQ4_11 0xE5C
934#define ARIZONA_EQ4_12 0xE5D
935#define ARIZONA_EQ4_13 0xE5E
936#define ARIZONA_EQ4_14 0xE5F
937#define ARIZONA_EQ4_15 0xE60
938#define ARIZONA_EQ4_16 0xE61
939#define ARIZONA_EQ4_17 0xE62
940#define ARIZONA_EQ4_18 0xE63
941#define ARIZONA_EQ4_19 0xE64
942#define ARIZONA_EQ4_20 0xE65
943#define ARIZONA_EQ4_21 0xE66
944#define ARIZONA_DRC1_CTRL1 0xE80
945#define ARIZONA_DRC1_CTRL2 0xE81
946#define ARIZONA_DRC1_CTRL3 0xE82
947#define ARIZONA_DRC1_CTRL4 0xE83
948#define ARIZONA_DRC1_CTRL5 0xE84
949#define ARIZONA_DRC2_CTRL1 0xE89
950#define ARIZONA_DRC2_CTRL2 0xE8A
951#define ARIZONA_DRC2_CTRL3 0xE8B
952#define ARIZONA_DRC2_CTRL4 0xE8C
953#define ARIZONA_DRC2_CTRL5 0xE8D
954#define ARIZONA_HPLPF1_1 0xEC0
955#define ARIZONA_HPLPF1_2 0xEC1
956#define ARIZONA_HPLPF2_1 0xEC4
957#define ARIZONA_HPLPF2_2 0xEC5
958#define ARIZONA_HPLPF3_1 0xEC8
959#define ARIZONA_HPLPF3_2 0xEC9
960#define ARIZONA_HPLPF4_1 0xECC
961#define ARIZONA_HPLPF4_2 0xECD
962#define ARIZONA_ASRC_ENABLE 0xEE0
963#define ARIZONA_ASRC_STATUS 0xEE1
964#define ARIZONA_ASRC_RATE1 0xEE2
965#define ARIZONA_ASRC_RATE2 0xEE3
966#define ARIZONA_ISRC_1_CTRL_1 0xEF0
967#define ARIZONA_ISRC_1_CTRL_2 0xEF1
968#define ARIZONA_ISRC_1_CTRL_3 0xEF2
969#define ARIZONA_ISRC_2_CTRL_1 0xEF3
970#define ARIZONA_ISRC_2_CTRL_2 0xEF4
971#define ARIZONA_ISRC_2_CTRL_3 0xEF5
972#define ARIZONA_ISRC_3_CTRL_1 0xEF6
973#define ARIZONA_ISRC_3_CTRL_2 0xEF7
974#define ARIZONA_ISRC_3_CTRL_3 0xEF8
975#define ARIZONA_CLOCK_CONTROL 0xF00
976#define ARIZONA_ANC_SRC 0xF01
977#define ARIZONA_DSP_STATUS 0xF02
978#define ARIZONA_DSP1_CONTROL_1 0x1100
979#define ARIZONA_DSP1_CLOCKING_1 0x1101
980#define ARIZONA_DSP1_STATUS_1 0x1104
981#define ARIZONA_DSP1_STATUS_2 0x1105
982#define ARIZONA_DSP2_CONTROL_1 0x1200
983#define ARIZONA_DSP2_CLOCKING_1 0x1201
984#define ARIZONA_DSP2_STATUS_1 0x1204
985#define ARIZONA_DSP2_STATUS_2 0x1205
986#define ARIZONA_DSP3_CONTROL_1 0x1300
987#define ARIZONA_DSP3_CLOCKING_1 0x1301
988#define ARIZONA_DSP3_STATUS_1 0x1304
989#define ARIZONA_DSP3_STATUS_2 0x1305
990#define ARIZONA_DSP4_CONTROL_1 0x1400
991#define ARIZONA_DSP4_CLOCKING_1 0x1401
992#define ARIZONA_DSP4_STATUS_1 0x1404
993#define ARIZONA_DSP4_STATUS_2 0x1405
994
995/*
996 * Field Definitions.
997 */
998
999/*
1000 * R0 (0x00) - software reset
1001 */
1002#define ARIZONA_SW_RST_DEV_ID1_MASK 0xFFFF /* SW_RST_DEV_ID1 - [15:0] */
1003#define ARIZONA_SW_RST_DEV_ID1_SHIFT 0 /* SW_RST_DEV_ID1 - [15:0] */
1004#define ARIZONA_SW_RST_DEV_ID1_WIDTH 16 /* SW_RST_DEV_ID1 - [15:0] */
1005
1006/*
1007 * R1 (0x01) - Device Revision
1008 */
1009#define ARIZONA_DEVICE_REVISION_MASK 0x00FF /* DEVICE_REVISION - [7:0] */
1010#define ARIZONA_DEVICE_REVISION_SHIFT 0 /* DEVICE_REVISION - [7:0] */
1011#define ARIZONA_DEVICE_REVISION_WIDTH 8 /* DEVICE_REVISION - [7:0] */
1012
1013/*
1014 * R8 (0x08) - Ctrl IF SPI CFG 1
1015 */
1016#define ARIZONA_SPI_CFG 0x0010 /* SPI_CFG */
1017#define ARIZONA_SPI_CFG_MASK 0x0010 /* SPI_CFG */
1018#define ARIZONA_SPI_CFG_SHIFT 4 /* SPI_CFG */
1019#define ARIZONA_SPI_CFG_WIDTH 1 /* SPI_CFG */
1020#define ARIZONA_SPI_4WIRE 0x0008 /* SPI_4WIRE */
1021#define ARIZONA_SPI_4WIRE_MASK 0x0008 /* SPI_4WIRE */
1022#define ARIZONA_SPI_4WIRE_SHIFT 3 /* SPI_4WIRE */
1023#define ARIZONA_SPI_4WIRE_WIDTH 1 /* SPI_4WIRE */
1024#define ARIZONA_SPI_AUTO_INC_MASK 0x0003 /* SPI_AUTO_INC - [1:0] */
1025#define ARIZONA_SPI_AUTO_INC_SHIFT 0 /* SPI_AUTO_INC - [1:0] */
1026#define ARIZONA_SPI_AUTO_INC_WIDTH 2 /* SPI_AUTO_INC - [1:0] */
1027
1028/*
1029 * R9 (0x09) - Ctrl IF I2C1 CFG 1
1030 */
1031#define ARIZONA_I2C1_AUTO_INC_MASK 0x0003 /* I2C1_AUTO_INC - [1:0] */
1032#define ARIZONA_I2C1_AUTO_INC_SHIFT 0 /* I2C1_AUTO_INC - [1:0] */
1033#define ARIZONA_I2C1_AUTO_INC_WIDTH 2 /* I2C1_AUTO_INC - [1:0] */
1034
1035/*
1036 * R13 (0x0D) - Ctrl IF Status 1
1037 */
1038#define ARIZONA_I2C1_BUSY 0x0020 /* I2C1_BUSY */
1039#define ARIZONA_I2C1_BUSY_MASK 0x0020 /* I2C1_BUSY */
1040#define ARIZONA_I2C1_BUSY_SHIFT 5 /* I2C1_BUSY */
1041#define ARIZONA_I2C1_BUSY_WIDTH 1 /* I2C1_BUSY */
1042#define ARIZONA_SPI_BUSY 0x0010 /* SPI_BUSY */
1043#define ARIZONA_SPI_BUSY_MASK 0x0010 /* SPI_BUSY */
1044#define ARIZONA_SPI_BUSY_SHIFT 4 /* SPI_BUSY */
1045#define ARIZONA_SPI_BUSY_WIDTH 1 /* SPI_BUSY */
1046
1047/*
1048 * R22 (0x16) - Write Sequencer Ctrl 0
1049 */
1050#define ARIZONA_WSEQ_ABORT 0x0800 /* WSEQ_ABORT */
1051#define ARIZONA_WSEQ_ABORT_MASK 0x0800 /* WSEQ_ABORT */
1052#define ARIZONA_WSEQ_ABORT_SHIFT 11 /* WSEQ_ABORT */
1053#define ARIZONA_WSEQ_ABORT_WIDTH 1 /* WSEQ_ABORT */
1054#define ARIZONA_WSEQ_START 0x0400 /* WSEQ_START */
1055#define ARIZONA_WSEQ_START_MASK 0x0400 /* WSEQ_START */
1056#define ARIZONA_WSEQ_START_SHIFT 10 /* WSEQ_START */
1057#define ARIZONA_WSEQ_START_WIDTH 1 /* WSEQ_START */
1058#define ARIZONA_WSEQ_ENA 0x0200 /* WSEQ_ENA */
1059#define ARIZONA_WSEQ_ENA_MASK 0x0200 /* WSEQ_ENA */
1060#define ARIZONA_WSEQ_ENA_SHIFT 9 /* WSEQ_ENA */
1061#define ARIZONA_WSEQ_ENA_WIDTH 1 /* WSEQ_ENA */
1062#define ARIZONA_WSEQ_START_INDEX_MASK 0x01FF /* WSEQ_START_INDEX - [8:0] */
1063#define ARIZONA_WSEQ_START_INDEX_SHIFT 0 /* WSEQ_START_INDEX - [8:0] */
1064#define ARIZONA_WSEQ_START_INDEX_WIDTH 9 /* WSEQ_START_INDEX - [8:0] */
1065
1066/*
1067 * R23 (0x17) - Write Sequencer Ctrl 1
1068 */
1069#define ARIZONA_WSEQ_BUSY 0x0200 /* WSEQ_BUSY */
1070#define ARIZONA_WSEQ_BUSY_MASK 0x0200 /* WSEQ_BUSY */
1071#define ARIZONA_WSEQ_BUSY_SHIFT 9 /* WSEQ_BUSY */
1072#define ARIZONA_WSEQ_BUSY_WIDTH 1 /* WSEQ_BUSY */
1073#define ARIZONA_WSEQ_CURRENT_INDEX_MASK 0x01FF /* WSEQ_CURRENT_INDEX - [8:0] */
1074#define ARIZONA_WSEQ_CURRENT_INDEX_SHIFT 0 /* WSEQ_CURRENT_INDEX - [8:0] */
1075#define ARIZONA_WSEQ_CURRENT_INDEX_WIDTH 9 /* WSEQ_CURRENT_INDEX - [8:0] */
1076
1077/*
1078 * R24 (0x18) - Write Sequencer Ctrl 2
1079 */
1080#define ARIZONA_LOAD_DEFAULTS 0x0002 /* LOAD_DEFAULTS */
1081#define ARIZONA_LOAD_DEFAULTS_MASK 0x0002 /* LOAD_DEFAULTS */
1082#define ARIZONA_LOAD_DEFAULTS_SHIFT 1 /* LOAD_DEFAULTS */
1083#define ARIZONA_LOAD_DEFAULTS_WIDTH 1 /* LOAD_DEFAULTS */
1084#define ARIZONA_WSEQ_LOAD_MEM 0x0001 /* WSEQ_LOAD_MEM */
1085#define ARIZONA_WSEQ_LOAD_MEM_MASK 0x0001 /* WSEQ_LOAD_MEM */
1086#define ARIZONA_WSEQ_LOAD_MEM_SHIFT 0 /* WSEQ_LOAD_MEM */
1087#define ARIZONA_WSEQ_LOAD_MEM_WIDTH 1 /* WSEQ_LOAD_MEM */
1088
1089/*
1090 * R26 (0x1A) - Write Sequencer PROM
1091 */
1092#define ARIZONA_WSEQ_OTP_WRITE 0x0001 /* WSEQ_OTP_WRITE */
1093#define ARIZONA_WSEQ_OTP_WRITE_MASK 0x0001 /* WSEQ_OTP_WRITE */
1094#define ARIZONA_WSEQ_OTP_WRITE_SHIFT 0 /* WSEQ_OTP_WRITE */
1095#define ARIZONA_WSEQ_OTP_WRITE_WIDTH 1 /* WSEQ_OTP_WRITE */
1096
1097/*
1098 * R32 (0x20) - Tone Generator 1
1099 */
1100#define ARIZONA_TONE_RATE_MASK 0x7800 /* TONE_RATE - [14:11] */
1101#define ARIZONA_TONE_RATE_SHIFT 11 /* TONE_RATE - [14:11] */
1102#define ARIZONA_TONE_RATE_WIDTH 4 /* TONE_RATE - [14:11] */
1103#define ARIZONA_TONE_OFFSET_MASK 0x0300 /* TONE_OFFSET - [9:8] */
1104#define ARIZONA_TONE_OFFSET_SHIFT 8 /* TONE_OFFSET - [9:8] */
1105#define ARIZONA_TONE_OFFSET_WIDTH 2 /* TONE_OFFSET - [9:8] */
1106#define ARIZONA_TONE2_OVD 0x0020 /* TONE2_OVD */
1107#define ARIZONA_TONE2_OVD_MASK 0x0020 /* TONE2_OVD */
1108#define ARIZONA_TONE2_OVD_SHIFT 5 /* TONE2_OVD */
1109#define ARIZONA_TONE2_OVD_WIDTH 1 /* TONE2_OVD */
1110#define ARIZONA_TONE1_OVD 0x0010 /* TONE1_OVD */
1111#define ARIZONA_TONE1_OVD_MASK 0x0010 /* TONE1_OVD */
1112#define ARIZONA_TONE1_OVD_SHIFT 4 /* TONE1_OVD */
1113#define ARIZONA_TONE1_OVD_WIDTH 1 /* TONE1_OVD */
1114#define ARIZONA_TONE2_ENA 0x0002 /* TONE2_ENA */
1115#define ARIZONA_TONE2_ENA_MASK 0x0002 /* TONE2_ENA */
1116#define ARIZONA_TONE2_ENA_SHIFT 1 /* TONE2_ENA */
1117#define ARIZONA_TONE2_ENA_WIDTH 1 /* TONE2_ENA */
1118#define ARIZONA_TONE1_ENA 0x0001 /* TONE1_ENA */
1119#define ARIZONA_TONE1_ENA_MASK 0x0001 /* TONE1_ENA */
1120#define ARIZONA_TONE1_ENA_SHIFT 0 /* TONE1_ENA */
1121#define ARIZONA_TONE1_ENA_WIDTH 1 /* TONE1_ENA */
1122
1123/*
1124 * R33 (0x21) - Tone Generator 2
1125 */
1126#define ARIZONA_TONE1_LVL_0_MASK 0xFFFF /* TONE1_LVL - [15:0] */
1127#define ARIZONA_TONE1_LVL_0_SHIFT 0 /* TONE1_LVL - [15:0] */
1128#define ARIZONA_TONE1_LVL_0_WIDTH 16 /* TONE1_LVL - [15:0] */
1129
1130/*
1131 * R34 (0x22) - Tone Generator 3
1132 */
1133#define ARIZONA_TONE1_LVL_MASK 0x00FF /* TONE1_LVL - [7:0] */
1134#define ARIZONA_TONE1_LVL_SHIFT 0 /* TONE1_LVL - [7:0] */
1135#define ARIZONA_TONE1_LVL_WIDTH 8 /* TONE1_LVL - [7:0] */
1136
1137/*
1138 * R35 (0x23) - Tone Generator 4
1139 */
1140#define ARIZONA_TONE2_LVL_0_MASK 0xFFFF /* TONE2_LVL - [15:0] */
1141#define ARIZONA_TONE2_LVL_0_SHIFT 0 /* TONE2_LVL - [15:0] */
1142#define ARIZONA_TONE2_LVL_0_WIDTH 16 /* TONE2_LVL - [15:0] */
1143
1144/*
1145 * R36 (0x24) - Tone Generator 5
1146 */
1147#define ARIZONA_TONE2_LVL_MASK 0x00FF /* TONE2_LVL - [7:0] */
1148#define ARIZONA_TONE2_LVL_SHIFT 0 /* TONE2_LVL - [7:0] */
1149#define ARIZONA_TONE2_LVL_WIDTH 8 /* TONE2_LVL - [7:0] */
1150
1151/*
1152 * R48 (0x30) - PWM Drive 1
1153 */
1154#define ARIZONA_PWM_RATE_MASK 0x7800 /* PWM_RATE - [14:11] */
1155#define ARIZONA_PWM_RATE_SHIFT 11 /* PWM_RATE - [14:11] */
1156#define ARIZONA_PWM_RATE_WIDTH 4 /* PWM_RATE - [14:11] */
1157#define ARIZONA_PWM_CLK_SEL_MASK 0x0700 /* PWM_CLK_SEL - [10:8] */
1158#define ARIZONA_PWM_CLK_SEL_SHIFT 8 /* PWM_CLK_SEL - [10:8] */
1159#define ARIZONA_PWM_CLK_SEL_WIDTH 3 /* PWM_CLK_SEL - [10:8] */
1160#define ARIZONA_PWM2_OVD 0x0020 /* PWM2_OVD */
1161#define ARIZONA_PWM2_OVD_MASK 0x0020 /* PWM2_OVD */
1162#define ARIZONA_PWM2_OVD_SHIFT 5 /* PWM2_OVD */
1163#define ARIZONA_PWM2_OVD_WIDTH 1 /* PWM2_OVD */
1164#define ARIZONA_PWM1_OVD 0x0010 /* PWM1_OVD */
1165#define ARIZONA_PWM1_OVD_MASK 0x0010 /* PWM1_OVD */
1166#define ARIZONA_PWM1_OVD_SHIFT 4 /* PWM1_OVD */
1167#define ARIZONA_PWM1_OVD_WIDTH 1 /* PWM1_OVD */
1168#define ARIZONA_PWM2_ENA 0x0002 /* PWM2_ENA */
1169#define ARIZONA_PWM2_ENA_MASK 0x0002 /* PWM2_ENA */
1170#define ARIZONA_PWM2_ENA_SHIFT 1 /* PWM2_ENA */
1171#define ARIZONA_PWM2_ENA_WIDTH 1 /* PWM2_ENA */
1172#define ARIZONA_PWM1_ENA 0x0001 /* PWM1_ENA */
1173#define ARIZONA_PWM1_ENA_MASK 0x0001 /* PWM1_ENA */
1174#define ARIZONA_PWM1_ENA_SHIFT 0 /* PWM1_ENA */
1175#define ARIZONA_PWM1_ENA_WIDTH 1 /* PWM1_ENA */
1176
1177/*
1178 * R49 (0x31) - PWM Drive 2
1179 */
1180#define ARIZONA_PWM1_LVL_MASK 0x03FF /* PWM1_LVL - [9:0] */
1181#define ARIZONA_PWM1_LVL_SHIFT 0 /* PWM1_LVL - [9:0] */
1182#define ARIZONA_PWM1_LVL_WIDTH 10 /* PWM1_LVL - [9:0] */
1183
1184/*
1185 * R50 (0x32) - PWM Drive 3
1186 */
1187#define ARIZONA_PWM2_LVL_MASK 0x03FF /* PWM2_LVL - [9:0] */
1188#define ARIZONA_PWM2_LVL_SHIFT 0 /* PWM2_LVL - [9:0] */
1189#define ARIZONA_PWM2_LVL_WIDTH 10 /* PWM2_LVL - [9:0] */
1190
1191/*
1192 * R64 (0x40) - Wake control
1193 */
1194#define ARIZONA_WKUP_GP5_FALL 0x0020 /* WKUP_GP5_FALL */
1195#define ARIZONA_WKUP_GP5_FALL_MASK 0x0020 /* WKUP_GP5_FALL */
1196#define ARIZONA_WKUP_GP5_FALL_SHIFT 5 /* WKUP_GP5_FALL */
1197#define ARIZONA_WKUP_GP5_FALL_WIDTH 1 /* WKUP_GP5_FALL */
1198#define ARIZONA_WKUP_GP5_RISE 0x0010 /* WKUP_GP5_RISE */
1199#define ARIZONA_WKUP_GP5_RISE_MASK 0x0010 /* WKUP_GP5_RISE */
1200#define ARIZONA_WKUP_GP5_RISE_SHIFT 4 /* WKUP_GP5_RISE */
1201#define ARIZONA_WKUP_GP5_RISE_WIDTH 1 /* WKUP_GP5_RISE */
1202#define ARIZONA_WKUP_JD1_FALL 0x0008 /* WKUP_JD1_FALL */
1203#define ARIZONA_WKUP_JD1_FALL_MASK 0x0008 /* WKUP_JD1_FALL */
1204#define ARIZONA_WKUP_JD1_FALL_SHIFT 3 /* WKUP_JD1_FALL */
1205#define ARIZONA_WKUP_JD1_FALL_WIDTH 1 /* WKUP_JD1_FALL */
1206#define ARIZONA_WKUP_JD1_RISE 0x0004 /* WKUP_JD1_RISE */
1207#define ARIZONA_WKUP_JD1_RISE_MASK 0x0004 /* WKUP_JD1_RISE */
1208#define ARIZONA_WKUP_JD1_RISE_SHIFT 2 /* WKUP_JD1_RISE */
1209#define ARIZONA_WKUP_JD1_RISE_WIDTH 1 /* WKUP_JD1_RISE */
1210#define ARIZONA_WKUP_JD2_FALL 0x0002 /* WKUP_JD2_FALL */
1211#define ARIZONA_WKUP_JD2_FALL_MASK 0x0002 /* WKUP_JD2_FALL */
1212#define ARIZONA_WKUP_JD2_FALL_SHIFT 1 /* WKUP_JD2_FALL */
1213#define ARIZONA_WKUP_JD2_FALL_WIDTH 1 /* WKUP_JD2_FALL */
1214#define ARIZONA_WKUP_JD2_RISE 0x0001 /* WKUP_JD2_RISE */
1215#define ARIZONA_WKUP_JD2_RISE_MASK 0x0001 /* WKUP_JD2_RISE */
1216#define ARIZONA_WKUP_JD2_RISE_SHIFT 0 /* WKUP_JD2_RISE */
1217#define ARIZONA_WKUP_JD2_RISE_WIDTH 1 /* WKUP_JD2_RISE */
1218
1219/*
1220 * R65 (0x41) - Sequence control
1221 */
1222#define ARIZONA_WSEQ_ENA_GP5_FALL 0x0020 /* WSEQ_ENA_GP5_FALL */
1223#define ARIZONA_WSEQ_ENA_GP5_FALL_MASK 0x0020 /* WSEQ_ENA_GP5_FALL */
1224#define ARIZONA_WSEQ_ENA_GP5_FALL_SHIFT 5 /* WSEQ_ENA_GP5_FALL */
1225#define ARIZONA_WSEQ_ENA_GP5_FALL_WIDTH 1 /* WSEQ_ENA_GP5_FALL */
1226#define ARIZONA_WSEQ_ENA_GP5_RISE 0x0010 /* WSEQ_ENA_GP5_RISE */
1227#define ARIZONA_WSEQ_ENA_GP5_RISE_MASK 0x0010 /* WSEQ_ENA_GP5_RISE */
1228#define ARIZONA_WSEQ_ENA_GP5_RISE_SHIFT 4 /* WSEQ_ENA_GP5_RISE */
1229#define ARIZONA_WSEQ_ENA_GP5_RISE_WIDTH 1 /* WSEQ_ENA_GP5_RISE */
1230#define ARIZONA_WSEQ_ENA_JD1_FALL 0x0008 /* WSEQ_ENA_JD1_FALL */
1231#define ARIZONA_WSEQ_ENA_JD1_FALL_MASK 0x0008 /* WSEQ_ENA_JD1_FALL */
1232#define ARIZONA_WSEQ_ENA_JD1_FALL_SHIFT 3 /* WSEQ_ENA_JD1_FALL */
1233#define ARIZONA_WSEQ_ENA_JD1_FALL_WIDTH 1 /* WSEQ_ENA_JD1_FALL */
1234#define ARIZONA_WSEQ_ENA_JD1_RISE 0x0004 /* WSEQ_ENA_JD1_RISE */
1235#define ARIZONA_WSEQ_ENA_JD1_RISE_MASK 0x0004 /* WSEQ_ENA_JD1_RISE */
1236#define ARIZONA_WSEQ_ENA_JD1_RISE_SHIFT 2 /* WSEQ_ENA_JD1_RISE */
1237#define ARIZONA_WSEQ_ENA_JD1_RISE_WIDTH 1 /* WSEQ_ENA_JD1_RISE */
1238#define ARIZONA_WSEQ_ENA_JD2_FALL 0x0002 /* WSEQ_ENA_JD2_FALL */
1239#define ARIZONA_WSEQ_ENA_JD2_FALL_MASK 0x0002 /* WSEQ_ENA_JD2_FALL */
1240#define ARIZONA_WSEQ_ENA_JD2_FALL_SHIFT 1 /* WSEQ_ENA_JD2_FALL */
1241#define ARIZONA_WSEQ_ENA_JD2_FALL_WIDTH 1 /* WSEQ_ENA_JD2_FALL */
1242#define ARIZONA_WSEQ_ENA_JD2_RISE 0x0001 /* WSEQ_ENA_JD2_RISE */
1243#define ARIZONA_WSEQ_ENA_JD2_RISE_MASK 0x0001 /* WSEQ_ENA_JD2_RISE */
1244#define ARIZONA_WSEQ_ENA_JD2_RISE_SHIFT 0 /* WSEQ_ENA_JD2_RISE */
1245#define ARIZONA_WSEQ_ENA_JD2_RISE_WIDTH 1 /* WSEQ_ENA_JD2_RISE */
1246
1247/*
1248 * R97 (0x61) - Sample Rate Sequence Select 1
1249 */
1250#define ARIZONA_WSEQ_SAMPLE_RATE_DETECT_A_SEQ_ADDR_MASK 0x01FF /* WSEQ_SAMPLE_RATE_DETECT_A_SEQ_ADDR - [8:0] */
1251#define ARIZONA_WSEQ_SAMPLE_RATE_DETECT_A_SEQ_ADDR_SHIFT 0 /* WSEQ_SAMPLE_RATE_DETECT_A_SEQ_ADDR - [8:0] */
1252#define ARIZONA_WSEQ_SAMPLE_RATE_DETECT_A_SEQ_ADDR_WIDTH 9 /* WSEQ_SAMPLE_RATE_DETECT_A_SEQ_ADDR - [8:0] */
1253
1254/*
1255 * R98 (0x62) - Sample Rate Sequence Select 2
1256 */
1257#define ARIZONA_WSEQ_SAMPLE_RATE_DETECT_B_SEQ_ADDR_MASK 0x01FF /* WSEQ_SAMPLE_RATE_DETECT_B_SEQ_ADDR - [8:0] */
1258#define ARIZONA_WSEQ_SAMPLE_RATE_DETECT_B_SEQ_ADDR_SHIFT 0 /* WSEQ_SAMPLE_RATE_DETECT_B_SEQ_ADDR - [8:0] */
1259#define ARIZONA_WSEQ_SAMPLE_RATE_DETECT_B_SEQ_ADDR_WIDTH 9 /* WSEQ_SAMPLE_RATE_DETECT_B_SEQ_ADDR - [8:0] */
1260
1261/*
1262 * R99 (0x63) - Sample Rate Sequence Select 3
1263 */
1264#define ARIZONA_WSEQ_SAMPLE_RATE_DETECT_C_SEQ_ADDR_MASK 0x01FF /* WSEQ_SAMPLE_RATE_DETECT_C_SEQ_ADDR - [8:0] */
1265#define ARIZONA_WSEQ_SAMPLE_RATE_DETECT_C_SEQ_ADDR_SHIFT 0 /* WSEQ_SAMPLE_RATE_DETECT_C_SEQ_ADDR - [8:0] */
1266#define ARIZONA_WSEQ_SAMPLE_RATE_DETECT_C_SEQ_ADDR_WIDTH 9 /* WSEQ_SAMPLE_RATE_DETECT_C_SEQ_ADDR - [8:0] */
1267
1268/*
1269 * R100 (0x64) - Sample Rate Sequence Select 4
1270 */
1271#define ARIZONA_WSEQ_SAMPLE_RATE_DETECT_D_SEQ_ADDR_MASK 0x01FF /* WSEQ_SAMPLE_RATE_DETECT_D_SEQ_ADDR - [8:0] */
1272#define ARIZONA_WSEQ_SAMPLE_RATE_DETECT_D_SEQ_ADDR_SHIFT 0 /* WSEQ_SAMPLE_RATE_DETECT_D_SEQ_ADDR - [8:0] */
1273#define ARIZONA_WSEQ_SAMPLE_RATE_DETECT_D_SEQ_ADDR_WIDTH 9 /* WSEQ_SAMPLE_RATE_DETECT_D_SEQ_ADDR - [8:0] */
1274
1275/*
1276 * R104 (0x68) - Always On Triggers Sequence Select 1
1277 */
1278#define ARIZONA_WSEQ_GP5_RISE_SEQ_ADDR_MASK 0x01FF /* WSEQ_GP5_RISE_SEQ_ADDR - [8:0] */
1279#define ARIZONA_WSEQ_GP5_RISE_SEQ_ADDR_SHIFT 0 /* WSEQ_GP5_RISE_SEQ_ADDR - [8:0] */
1280#define ARIZONA_WSEQ_GP5_RISE_SEQ_ADDR_WIDTH 9 /* WSEQ_GP5_RISE_SEQ_ADDR - [8:0] */
1281
1282/*
1283 * R105 (0x69) - Always On Triggers Sequence Select 2
1284 */
1285#define ARIZONA_WSEQ_GP5_FALL_SEQ_ADDR_MASK 0x01FF /* WSEQ_GP5_FALL_SEQ_ADDR - [8:0] */
1286#define ARIZONA_WSEQ_GP5_FALL_SEQ_ADDR_SHIFT 0 /* WSEQ_GP5_FALL_SEQ_ADDR - [8:0] */
1287#define ARIZONA_WSEQ_GP5_FALL_SEQ_ADDR_WIDTH 9 /* WSEQ_GP5_FALL_SEQ_ADDR - [8:0] */
1288
1289/*
1290 * R106 (0x6A) - Always On Triggers Sequence Select 3
1291 */
1292#define ARIZONA_WSEQ_JD1_RISE_SEQ_ADDR_MASK 0x01FF /* WSEQ_JD1_RISE_SEQ_ADDR - [8:0] */
1293#define ARIZONA_WSEQ_JD1_RISE_SEQ_ADDR_SHIFT 0 /* WSEQ_JD1_RISE_SEQ_ADDR - [8:0] */
1294#define ARIZONA_WSEQ_JD1_RISE_SEQ_ADDR_WIDTH 9 /* WSEQ_JD1_RISE_SEQ_ADDR - [8:0] */
1295
1296/*
1297 * R107 (0x6B) - Always On Triggers Sequence Select 4
1298 */
1299#define ARIZONA_WSEQ_JD1_FALL_SEQ_ADDR_MASK 0x01FF /* WSEQ_JD1_FALL_SEQ_ADDR - [8:0] */
1300#define ARIZONA_WSEQ_JD1_FALL_SEQ_ADDR_SHIFT 0 /* WSEQ_JD1_FALL_SEQ_ADDR - [8:0] */
1301#define ARIZONA_WSEQ_JD1_FALL_SEQ_ADDR_WIDTH 9 /* WSEQ_JD1_FALL_SEQ_ADDR - [8:0] */
1302
1303/*
1304 * R108 (0x6C) - Always On Triggers Sequence Select 5
1305 */
1306#define ARIZONA_WSEQ_JD2_RISE_SEQ_ADDR_MASK 0x01FF /* WSEQ_JD2_RISE_SEQ_ADDR - [8:0] */
1307#define ARIZONA_WSEQ_JD2_RISE_SEQ_ADDR_SHIFT 0 /* WSEQ_JD2_RISE_SEQ_ADDR - [8:0] */
1308#define ARIZONA_WSEQ_JD2_RISE_SEQ_ADDR_WIDTH 9 /* WSEQ_JD2_RISE_SEQ_ADDR - [8:0] */
1309
1310/*
1311 * R109 (0x6D) - Always On Triggers Sequence Select 6
1312 */
1313#define ARIZONA_WSEQ_JD2_FALL_SEQ_ADDR_MASK 0x01FF /* WSEQ_JD2_FALL_SEQ_ADDR - [8:0] */
1314#define ARIZONA_WSEQ_JD2_FALL_SEQ_ADDR_SHIFT 0 /* WSEQ_JD2_FALL_SEQ_ADDR - [8:0] */
1315#define ARIZONA_WSEQ_JD2_FALL_SEQ_ADDR_WIDTH 9 /* WSEQ_JD2_FALL_SEQ_ADDR - [8:0] */
1316
1317/*
1318 * R112 (0x70) - Comfort Noise Generator
1319 */
1320#define ARIZONA_NOISE_GEN_RATE_MASK 0x7800 /* NOISE_GEN_RATE - [14:11] */
1321#define ARIZONA_NOISE_GEN_RATE_SHIFT 11 /* NOISE_GEN_RATE - [14:11] */
1322#define ARIZONA_NOISE_GEN_RATE_WIDTH 4 /* NOISE_GEN_RATE - [14:11] */
1323#define ARIZONA_NOISE_GEN_ENA 0x0020 /* NOISE_GEN_ENA */
1324#define ARIZONA_NOISE_GEN_ENA_MASK 0x0020 /* NOISE_GEN_ENA */
1325#define ARIZONA_NOISE_GEN_ENA_SHIFT 5 /* NOISE_GEN_ENA */
1326#define ARIZONA_NOISE_GEN_ENA_WIDTH 1 /* NOISE_GEN_ENA */
1327#define ARIZONA_NOISE_GEN_GAIN_MASK 0x001F /* NOISE_GEN_GAIN - [4:0] */
1328#define ARIZONA_NOISE_GEN_GAIN_SHIFT 0 /* NOISE_GEN_GAIN - [4:0] */
1329#define ARIZONA_NOISE_GEN_GAIN_WIDTH 5 /* NOISE_GEN_GAIN - [4:0] */
1330
1331/*
1332 * R144 (0x90) - Haptics Control 1
1333 */
1334#define ARIZONA_HAP_RATE_MASK 0x7800 /* HAP_RATE - [14:11] */
1335#define ARIZONA_HAP_RATE_SHIFT 11 /* HAP_RATE - [14:11] */
1336#define ARIZONA_HAP_RATE_WIDTH 4 /* HAP_RATE - [14:11] */
1337#define ARIZONA_ONESHOT_TRIG 0x0010 /* ONESHOT_TRIG */
1338#define ARIZONA_ONESHOT_TRIG_MASK 0x0010 /* ONESHOT_TRIG */
1339#define ARIZONA_ONESHOT_TRIG_SHIFT 4 /* ONESHOT_TRIG */
1340#define ARIZONA_ONESHOT_TRIG_WIDTH 1 /* ONESHOT_TRIG */
1341#define ARIZONA_HAP_CTRL_MASK 0x000C /* HAP_CTRL - [3:2] */
1342#define ARIZONA_HAP_CTRL_SHIFT 2 /* HAP_CTRL - [3:2] */
1343#define ARIZONA_HAP_CTRL_WIDTH 2 /* HAP_CTRL - [3:2] */
1344#define ARIZONA_HAP_ACT 0x0002 /* HAP_ACT */
1345#define ARIZONA_HAP_ACT_MASK 0x0002 /* HAP_ACT */
1346#define ARIZONA_HAP_ACT_SHIFT 1 /* HAP_ACT */
1347#define ARIZONA_HAP_ACT_WIDTH 1 /* HAP_ACT */
1348
1349/*
1350 * R145 (0x91) - Haptics Control 2
1351 */
1352#define ARIZONA_LRA_FREQ_MASK 0x7FFF /* LRA_FREQ - [14:0] */
1353#define ARIZONA_LRA_FREQ_SHIFT 0 /* LRA_FREQ - [14:0] */
1354#define ARIZONA_LRA_FREQ_WIDTH 15 /* LRA_FREQ - [14:0] */
1355
1356/*
1357 * R146 (0x92) - Haptics phase 1 intensity
1358 */
1359#define ARIZONA_PHASE1_INTENSITY_MASK 0x00FF /* PHASE1_INTENSITY - [7:0] */
1360#define ARIZONA_PHASE1_INTENSITY_SHIFT 0 /* PHASE1_INTENSITY - [7:0] */
1361#define ARIZONA_PHASE1_INTENSITY_WIDTH 8 /* PHASE1_INTENSITY - [7:0] */
1362
1363/*
1364 * R147 (0x93) - Haptics phase 1 duration
1365 */
1366#define ARIZONA_PHASE1_DURATION_MASK 0x01FF /* PHASE1_DURATION - [8:0] */
1367#define ARIZONA_PHASE1_DURATION_SHIFT 0 /* PHASE1_DURATION - [8:0] */
1368#define ARIZONA_PHASE1_DURATION_WIDTH 9 /* PHASE1_DURATION - [8:0] */
1369
1370/*
1371 * R148 (0x94) - Haptics phase 2 intensity
1372 */
1373#define ARIZONA_PHASE2_INTENSITY_MASK 0x00FF /* PHASE2_INTENSITY - [7:0] */
1374#define ARIZONA_PHASE2_INTENSITY_SHIFT 0 /* PHASE2_INTENSITY - [7:0] */
1375#define ARIZONA_PHASE2_INTENSITY_WIDTH 8 /* PHASE2_INTENSITY - [7:0] */
1376
1377/*
1378 * R149 (0x95) - Haptics phase 2 duration
1379 */
1380#define ARIZONA_PHASE2_DURATION_MASK 0x07FF /* PHASE2_DURATION - [10:0] */
1381#define ARIZONA_PHASE2_DURATION_SHIFT 0 /* PHASE2_DURATION - [10:0] */
1382#define ARIZONA_PHASE2_DURATION_WIDTH 11 /* PHASE2_DURATION - [10:0] */
1383
1384/*
1385 * R150 (0x96) - Haptics phase 3 intensity
1386 */
1387#define ARIZONA_PHASE3_INTENSITY_MASK 0x00FF /* PHASE3_INTENSITY - [7:0] */
1388#define ARIZONA_PHASE3_INTENSITY_SHIFT 0 /* PHASE3_INTENSITY - [7:0] */
1389#define ARIZONA_PHASE3_INTENSITY_WIDTH 8 /* PHASE3_INTENSITY - [7:0] */
1390
1391/*
1392 * R151 (0x97) - Haptics phase 3 duration
1393 */
1394#define ARIZONA_PHASE3_DURATION_MASK 0x01FF /* PHASE3_DURATION - [8:0] */
1395#define ARIZONA_PHASE3_DURATION_SHIFT 0 /* PHASE3_DURATION - [8:0] */
1396#define ARIZONA_PHASE3_DURATION_WIDTH 9 /* PHASE3_DURATION - [8:0] */
1397
1398/*
1399 * R152 (0x98) - Haptics Status
1400 */
1401#define ARIZONA_ONESHOT_STS 0x0001 /* ONESHOT_STS */
1402#define ARIZONA_ONESHOT_STS_MASK 0x0001 /* ONESHOT_STS */
1403#define ARIZONA_ONESHOT_STS_SHIFT 0 /* ONESHOT_STS */
1404#define ARIZONA_ONESHOT_STS_WIDTH 1 /* ONESHOT_STS */
1405
1406/*
1407 * R256 (0x100) - Clock 32k 1
1408 */
1409#define ARIZONA_CLK_32K_ENA 0x0040 /* CLK_32K_ENA */
1410#define ARIZONA_CLK_32K_ENA_MASK 0x0040 /* CLK_32K_ENA */
1411#define ARIZONA_CLK_32K_ENA_SHIFT 6 /* CLK_32K_ENA */
1412#define ARIZONA_CLK_32K_ENA_WIDTH 1 /* CLK_32K_ENA */
1413#define ARIZONA_CLK_32K_SRC_MASK 0x0003 /* CLK_32K_SRC - [1:0] */
1414#define ARIZONA_CLK_32K_SRC_SHIFT 0 /* CLK_32K_SRC - [1:0] */
1415#define ARIZONA_CLK_32K_SRC_WIDTH 2 /* CLK_32K_SRC - [1:0] */
1416
1417/*
1418 * R257 (0x101) - System Clock 1
1419 */
1420#define ARIZONA_SYSCLK_FRAC 0x8000 /* SYSCLK_FRAC */
1421#define ARIZONA_SYSCLK_FRAC_MASK 0x8000 /* SYSCLK_FRAC */
1422#define ARIZONA_SYSCLK_FRAC_SHIFT 15 /* SYSCLK_FRAC */
1423#define ARIZONA_SYSCLK_FRAC_WIDTH 1 /* SYSCLK_FRAC */
1424#define ARIZONA_SYSCLK_FREQ_MASK 0x0700 /* SYSCLK_FREQ - [10:8] */
1425#define ARIZONA_SYSCLK_FREQ_SHIFT 8 /* SYSCLK_FREQ - [10:8] */
1426#define ARIZONA_SYSCLK_FREQ_WIDTH 3 /* SYSCLK_FREQ - [10:8] */
1427#define ARIZONA_SYSCLK_ENA 0x0040 /* SYSCLK_ENA */
1428#define ARIZONA_SYSCLK_ENA_MASK 0x0040 /* SYSCLK_ENA */
1429#define ARIZONA_SYSCLK_ENA_SHIFT 6 /* SYSCLK_ENA */
1430#define ARIZONA_SYSCLK_ENA_WIDTH 1 /* SYSCLK_ENA */
1431#define ARIZONA_SYSCLK_SRC_MASK 0x000F /* SYSCLK_SRC - [3:0] */
1432#define ARIZONA_SYSCLK_SRC_SHIFT 0 /* SYSCLK_SRC - [3:0] */
1433#define ARIZONA_SYSCLK_SRC_WIDTH 4 /* SYSCLK_SRC - [3:0] */
1434
1435/*
1436 * R258 (0x102) - Sample rate 1
1437 */
1438#define ARIZONA_SAMPLE_RATE_1_MASK 0x001F /* SAMPLE_RATE_1 - [4:0] */
1439#define ARIZONA_SAMPLE_RATE_1_SHIFT 0 /* SAMPLE_RATE_1 - [4:0] */
1440#define ARIZONA_SAMPLE_RATE_1_WIDTH 5 /* SAMPLE_RATE_1 - [4:0] */
1441
1442/*
1443 * R259 (0x103) - Sample rate 2
1444 */
1445#define ARIZONA_SAMPLE_RATE_2_MASK 0x001F /* SAMPLE_RATE_2 - [4:0] */
1446#define ARIZONA_SAMPLE_RATE_2_SHIFT 0 /* SAMPLE_RATE_2 - [4:0] */
1447#define ARIZONA_SAMPLE_RATE_2_WIDTH 5 /* SAMPLE_RATE_2 - [4:0] */
1448
1449/*
1450 * R260 (0x104) - Sample rate 3
1451 */
1452#define ARIZONA_SAMPLE_RATE_3_MASK 0x001F /* SAMPLE_RATE_3 - [4:0] */
1453#define ARIZONA_SAMPLE_RATE_3_SHIFT 0 /* SAMPLE_RATE_3 - [4:0] */
1454#define ARIZONA_SAMPLE_RATE_3_WIDTH 5 /* SAMPLE_RATE_3 - [4:0] */
1455
1456/*
1457 * R266 (0x10A) - Sample rate 1 status
1458 */
1459#define ARIZONA_SAMPLE_RATE_1_STS_MASK 0x001F /* SAMPLE_RATE_1_STS - [4:0] */
1460#define ARIZONA_SAMPLE_RATE_1_STS_SHIFT 0 /* SAMPLE_RATE_1_STS - [4:0] */
1461#define ARIZONA_SAMPLE_RATE_1_STS_WIDTH 5 /* SAMPLE_RATE_1_STS - [4:0] */
1462
1463/*
1464 * R267 (0x10B) - Sample rate 2 status
1465 */
1466#define ARIZONA_SAMPLE_RATE_2_STS_MASK 0x001F /* SAMPLE_RATE_2_STS - [4:0] */
1467#define ARIZONA_SAMPLE_RATE_2_STS_SHIFT 0 /* SAMPLE_RATE_2_STS - [4:0] */
1468#define ARIZONA_SAMPLE_RATE_2_STS_WIDTH 5 /* SAMPLE_RATE_2_STS - [4:0] */
1469
1470/*
1471 * R268 (0x10C) - Sample rate 3 status
1472 */
1473#define ARIZONA_SAMPLE_RATE_3_STS_MASK 0x001F /* SAMPLE_RATE_3_STS - [4:0] */
1474#define ARIZONA_SAMPLE_RATE_3_STS_SHIFT 0 /* SAMPLE_RATE_3_STS - [4:0] */
1475#define ARIZONA_SAMPLE_RATE_3_STS_WIDTH 5 /* SAMPLE_RATE_3_STS - [4:0] */
1476
1477/*
1478 * R274 (0x112) - Async clock 1
1479 */
1480#define ARIZONA_ASYNC_CLK_FREQ_MASK 0x0700 /* ASYNC_CLK_FREQ - [10:8] */
1481#define ARIZONA_ASYNC_CLK_FREQ_SHIFT 8 /* ASYNC_CLK_FREQ - [10:8] */
1482#define ARIZONA_ASYNC_CLK_FREQ_WIDTH 3 /* ASYNC_CLK_FREQ - [10:8] */
1483#define ARIZONA_ASYNC_CLK_ENA 0x0040 /* ASYNC_CLK_ENA */
1484#define ARIZONA_ASYNC_CLK_ENA_MASK 0x0040 /* ASYNC_CLK_ENA */
1485#define ARIZONA_ASYNC_CLK_ENA_SHIFT 6 /* ASYNC_CLK_ENA */
1486#define ARIZONA_ASYNC_CLK_ENA_WIDTH 1 /* ASYNC_CLK_ENA */
1487#define ARIZONA_ASYNC_CLK_SRC_MASK 0x000F /* ASYNC_CLK_SRC - [3:0] */
1488#define ARIZONA_ASYNC_CLK_SRC_SHIFT 0 /* ASYNC_CLK_SRC - [3:0] */
1489#define ARIZONA_ASYNC_CLK_SRC_WIDTH 4 /* ASYNC_CLK_SRC - [3:0] */
1490
1491/*
1492 * R275 (0x113) - Async sample rate 1
1493 */
1494#define ARIZONA_ASYNC_SAMPLE_RATE_MASK 0x001F /* ASYNC_SAMPLE_RATE - [4:0] */
1495#define ARIZONA_ASYNC_SAMPLE_RATE_SHIFT 0 /* ASYNC_SAMPLE_RATE - [4:0] */
1496#define ARIZONA_ASYNC_SAMPLE_RATE_WIDTH 5 /* ASYNC_SAMPLE_RATE - [4:0] */
1497
1498/*
1499 * R283 (0x11B) - Async sample rate 1 status
1500 */
1501#define ARIZONA_ASYNC_SAMPLE_RATE_STS_MASK 0x001F /* ASYNC_SAMPLE_RATE_STS - [4:0] */
1502#define ARIZONA_ASYNC_SAMPLE_RATE_STS_SHIFT 0 /* ASYNC_SAMPLE_RATE_STS - [4:0] */
1503#define ARIZONA_ASYNC_SAMPLE_RATE_STS_WIDTH 5 /* ASYNC_SAMPLE_RATE_STS - [4:0] */
1504
1505/*
1506 * R329 (0x149) - Output system clock
1507 */
1508#define ARIZONA_OPCLK_ENA 0x8000 /* OPCLK_ENA */
1509#define ARIZONA_OPCLK_ENA_MASK 0x8000 /* OPCLK_ENA */
1510#define ARIZONA_OPCLK_ENA_SHIFT 15 /* OPCLK_ENA */
1511#define ARIZONA_OPCLK_ENA_WIDTH 1 /* OPCLK_ENA */
1512#define ARIZONA_OPCLK_DIV_MASK 0x00F8 /* OPCLK_DIV - [7:3] */
1513#define ARIZONA_OPCLK_DIV_SHIFT 3 /* OPCLK_DIV - [7:3] */
1514#define ARIZONA_OPCLK_DIV_WIDTH 5 /* OPCLK_DIV - [7:3] */
1515#define ARIZONA_OPCLK_SEL_MASK 0x0007 /* OPCLK_SEL - [2:0] */
1516#define ARIZONA_OPCLK_SEL_SHIFT 0 /* OPCLK_SEL - [2:0] */
1517#define ARIZONA_OPCLK_SEL_WIDTH 3 /* OPCLK_SEL - [2:0] */
1518
1519/*
1520 * R330 (0x14A) - Output async clock
1521 */
1522#define ARIZONA_OPCLK_ASYNC_ENA 0x8000 /* OPCLK_ASYNC_ENA */
1523#define ARIZONA_OPCLK_ASYNC_ENA_MASK 0x8000 /* OPCLK_ASYNC_ENA */
1524#define ARIZONA_OPCLK_ASYNC_ENA_SHIFT 15 /* OPCLK_ASYNC_ENA */
1525#define ARIZONA_OPCLK_ASYNC_ENA_WIDTH 1 /* OPCLK_ASYNC_ENA */
1526#define ARIZONA_OPCLK_ASYNC_DIV_MASK 0x00F8 /* OPCLK_ASYNC_DIV - [7:3] */
1527#define ARIZONA_OPCLK_ASYNC_DIV_SHIFT 3 /* OPCLK_ASYNC_DIV - [7:3] */
1528#define ARIZONA_OPCLK_ASYNC_DIV_WIDTH 5 /* OPCLK_ASYNC_DIV - [7:3] */
1529#define ARIZONA_OPCLK_ASYNC_SEL_MASK 0x0007 /* OPCLK_ASYNC_SEL - [2:0] */
1530#define ARIZONA_OPCLK_ASYNC_SEL_SHIFT 0 /* OPCLK_ASYNC_SEL - [2:0] */
1531#define ARIZONA_OPCLK_ASYNC_SEL_WIDTH 3 /* OPCLK_ASYNC_SEL - [2:0] */
1532
1533/*
1534 * R338 (0x152) - Rate Estimator 1
1535 */
1536#define ARIZONA_TRIG_ON_STARTUP 0x0010 /* TRIG_ON_STARTUP */
1537#define ARIZONA_TRIG_ON_STARTUP_MASK 0x0010 /* TRIG_ON_STARTUP */
1538#define ARIZONA_TRIG_ON_STARTUP_SHIFT 4 /* TRIG_ON_STARTUP */
1539#define ARIZONA_TRIG_ON_STARTUP_WIDTH 1 /* TRIG_ON_STARTUP */
1540#define ARIZONA_LRCLK_SRC_MASK 0x000E /* LRCLK_SRC - [3:1] */
1541#define ARIZONA_LRCLK_SRC_SHIFT 1 /* LRCLK_SRC - [3:1] */
1542#define ARIZONA_LRCLK_SRC_WIDTH 3 /* LRCLK_SRC - [3:1] */
1543#define ARIZONA_RATE_EST_ENA 0x0001 /* RATE_EST_ENA */
1544#define ARIZONA_RATE_EST_ENA_MASK 0x0001 /* RATE_EST_ENA */
1545#define ARIZONA_RATE_EST_ENA_SHIFT 0 /* RATE_EST_ENA */
1546#define ARIZONA_RATE_EST_ENA_WIDTH 1 /* RATE_EST_ENA */
1547
1548/*
1549 * R339 (0x153) - Rate Estimator 2
1550 */
1551#define ARIZONA_SAMPLE_RATE_DETECT_A_MASK 0x001F /* SAMPLE_RATE_DETECT_A - [4:0] */
1552#define ARIZONA_SAMPLE_RATE_DETECT_A_SHIFT 0 /* SAMPLE_RATE_DETECT_A - [4:0] */
1553#define ARIZONA_SAMPLE_RATE_DETECT_A_WIDTH 5 /* SAMPLE_RATE_DETECT_A - [4:0] */
1554
1555/*
1556 * R340 (0x154) - Rate Estimator 3
1557 */
1558#define ARIZONA_SAMPLE_RATE_DETECT_B_MASK 0x001F /* SAMPLE_RATE_DETECT_B - [4:0] */
1559#define ARIZONA_SAMPLE_RATE_DETECT_B_SHIFT 0 /* SAMPLE_RATE_DETECT_B - [4:0] */
1560#define ARIZONA_SAMPLE_RATE_DETECT_B_WIDTH 5 /* SAMPLE_RATE_DETECT_B - [4:0] */
1561
1562/*
1563 * R341 (0x155) - Rate Estimator 4
1564 */
1565#define ARIZONA_SAMPLE_RATE_DETECT_C_MASK 0x001F /* SAMPLE_RATE_DETECT_C - [4:0] */
1566#define ARIZONA_SAMPLE_RATE_DETECT_C_SHIFT 0 /* SAMPLE_RATE_DETECT_C - [4:0] */
1567#define ARIZONA_SAMPLE_RATE_DETECT_C_WIDTH 5 /* SAMPLE_RATE_DETECT_C - [4:0] */
1568
1569/*
1570 * R342 (0x156) - Rate Estimator 5
1571 */
1572#define ARIZONA_SAMPLE_RATE_DETECT_D_MASK 0x001F /* SAMPLE_RATE_DETECT_D - [4:0] */
1573#define ARIZONA_SAMPLE_RATE_DETECT_D_SHIFT 0 /* SAMPLE_RATE_DETECT_D - [4:0] */
1574#define ARIZONA_SAMPLE_RATE_DETECT_D_WIDTH 5 /* SAMPLE_RATE_DETECT_D - [4:0] */
1575
1576/*
1577 * R369 (0x171) - FLL1 Control 1
1578 */
1579#define ARIZONA_FLL1_FREERUN 0x0002 /* FLL1_FREERUN */
1580#define ARIZONA_FLL1_FREERUN_MASK 0x0002 /* FLL1_FREERUN */
1581#define ARIZONA_FLL1_FREERUN_SHIFT 1 /* FLL1_FREERUN */
1582#define ARIZONA_FLL1_FREERUN_WIDTH 1 /* FLL1_FREERUN */
1583#define ARIZONA_FLL1_ENA 0x0001 /* FLL1_ENA */
1584#define ARIZONA_FLL1_ENA_MASK 0x0001 /* FLL1_ENA */
1585#define ARIZONA_FLL1_ENA_SHIFT 0 /* FLL1_ENA */
1586#define ARIZONA_FLL1_ENA_WIDTH 1 /* FLL1_ENA */
1587
1588/*
1589 * R370 (0x172) - FLL1 Control 2
1590 */
1591#define ARIZONA_FLL1_CTRL_UPD 0x8000 /* FLL1_CTRL_UPD */
1592#define ARIZONA_FLL1_CTRL_UPD_MASK 0x8000 /* FLL1_CTRL_UPD */
1593#define ARIZONA_FLL1_CTRL_UPD_SHIFT 15 /* FLL1_CTRL_UPD */
1594#define ARIZONA_FLL1_CTRL_UPD_WIDTH 1 /* FLL1_CTRL_UPD */
1595#define ARIZONA_FLL1_N_MASK 0x03FF /* FLL1_N - [9:0] */
1596#define ARIZONA_FLL1_N_SHIFT 0 /* FLL1_N - [9:0] */
1597#define ARIZONA_FLL1_N_WIDTH 10 /* FLL1_N - [9:0] */
1598
1599/*
1600 * R371 (0x173) - FLL1 Control 3
1601 */
1602#define ARIZONA_FLL1_THETA_MASK 0xFFFF /* FLL1_THETA - [15:0] */
1603#define ARIZONA_FLL1_THETA_SHIFT 0 /* FLL1_THETA - [15:0] */
1604#define ARIZONA_FLL1_THETA_WIDTH 16 /* FLL1_THETA - [15:0] */
1605
1606/*
1607 * R372 (0x174) - FLL1 Control 4
1608 */
1609#define ARIZONA_FLL1_LAMBDA_MASK 0xFFFF /* FLL1_LAMBDA - [15:0] */
1610#define ARIZONA_FLL1_LAMBDA_SHIFT 0 /* FLL1_LAMBDA - [15:0] */
1611#define ARIZONA_FLL1_LAMBDA_WIDTH 16 /* FLL1_LAMBDA - [15:0] */
1612
1613/*
1614 * R373 (0x175) - FLL1 Control 5
1615 */
1616#define ARIZONA_FLL1_FRATIO_MASK 0x0700 /* FLL1_FRATIO - [10:8] */
1617#define ARIZONA_FLL1_FRATIO_SHIFT 8 /* FLL1_FRATIO - [10:8] */
1618#define ARIZONA_FLL1_FRATIO_WIDTH 3 /* FLL1_FRATIO - [10:8] */
1619#define ARIZONA_FLL1_OUTDIV_MASK 0x000E /* FLL1_OUTDIV - [3:1] */
1620#define ARIZONA_FLL1_OUTDIV_SHIFT 1 /* FLL1_OUTDIV - [3:1] */
1621#define ARIZONA_FLL1_OUTDIV_WIDTH 3 /* FLL1_OUTDIV - [3:1] */
1622
1623/*
1624 * R374 (0x176) - FLL1 Control 6
1625 */
1626#define ARIZONA_FLL1_CLK_REF_DIV_MASK 0x00C0 /* FLL1_CLK_REF_DIV - [7:6] */
1627#define ARIZONA_FLL1_CLK_REF_DIV_SHIFT 6 /* FLL1_CLK_REF_DIV - [7:6] */
1628#define ARIZONA_FLL1_CLK_REF_DIV_WIDTH 2 /* FLL1_CLK_REF_DIV - [7:6] */
1629#define ARIZONA_FLL1_CLK_REF_SRC_MASK 0x000F /* FLL1_CLK_REF_SRC - [3:0] */
1630#define ARIZONA_FLL1_CLK_REF_SRC_SHIFT 0 /* FLL1_CLK_REF_SRC - [3:0] */
1631#define ARIZONA_FLL1_CLK_REF_SRC_WIDTH 4 /* FLL1_CLK_REF_SRC - [3:0] */
1632
1633/*
1634 * R375 (0x177) - FLL1 Loop Filter Test 1
1635 */
1636#define ARIZONA_FLL1_FRC_INTEG_UPD 0x8000 /* FLL1_FRC_INTEG_UPD */
1637#define ARIZONA_FLL1_FRC_INTEG_UPD_MASK 0x8000 /* FLL1_FRC_INTEG_UPD */
1638#define ARIZONA_FLL1_FRC_INTEG_UPD_SHIFT 15 /* FLL1_FRC_INTEG_UPD */
1639#define ARIZONA_FLL1_FRC_INTEG_UPD_WIDTH 1 /* FLL1_FRC_INTEG_UPD */
1640#define ARIZONA_FLL1_FRC_INTEG_VAL_MASK 0x0FFF /* FLL1_FRC_INTEG_VAL - [11:0] */
1641#define ARIZONA_FLL1_FRC_INTEG_VAL_SHIFT 0 /* FLL1_FRC_INTEG_VAL - [11:0] */
1642#define ARIZONA_FLL1_FRC_INTEG_VAL_WIDTH 12 /* FLL1_FRC_INTEG_VAL - [11:0] */
1643
1644/*
1645 * R385 (0x181) - FLL1 Synchroniser 1
1646 */
1647#define ARIZONA_FLL1_SYNC_ENA 0x0001 /* FLL1_SYNC_ENA */
1648#define ARIZONA_FLL1_SYNC_ENA_MASK 0x0001 /* FLL1_SYNC_ENA */
1649#define ARIZONA_FLL1_SYNC_ENA_SHIFT 0 /* FLL1_SYNC_ENA */
1650#define ARIZONA_FLL1_SYNC_ENA_WIDTH 1 /* FLL1_SYNC_ENA */
1651
1652/*
1653 * R386 (0x182) - FLL1 Synchroniser 2
1654 */
1655#define ARIZONA_FLL1_SYNC_N_MASK 0x03FF /* FLL1_SYNC_N - [9:0] */
1656#define ARIZONA_FLL1_SYNC_N_SHIFT 0 /* FLL1_SYNC_N - [9:0] */
1657#define ARIZONA_FLL1_SYNC_N_WIDTH 10 /* FLL1_SYNC_N - [9:0] */
1658
1659/*
1660 * R387 (0x183) - FLL1 Synchroniser 3
1661 */
1662#define ARIZONA_FLL1_SYNC_THETA_MASK 0xFFFF /* FLL1_SYNC_THETA - [15:0] */
1663#define ARIZONA_FLL1_SYNC_THETA_SHIFT 0 /* FLL1_SYNC_THETA - [15:0] */
1664#define ARIZONA_FLL1_SYNC_THETA_WIDTH 16 /* FLL1_SYNC_THETA - [15:0] */
1665
1666/*
1667 * R388 (0x184) - FLL1 Synchroniser 4
1668 */
1669#define ARIZONA_FLL1_SYNC_LAMBDA_MASK 0xFFFF /* FLL1_SYNC_LAMBDA - [15:0] */
1670#define ARIZONA_FLL1_SYNC_LAMBDA_SHIFT 0 /* FLL1_SYNC_LAMBDA - [15:0] */
1671#define ARIZONA_FLL1_SYNC_LAMBDA_WIDTH 16 /* FLL1_SYNC_LAMBDA - [15:0] */
1672
1673/*
1674 * R389 (0x185) - FLL1 Synchroniser 5
1675 */
1676#define ARIZONA_FLL1_SYNC_FRATIO_MASK 0x0700 /* FLL1_SYNC_FRATIO - [10:8] */
1677#define ARIZONA_FLL1_SYNC_FRATIO_SHIFT 8 /* FLL1_SYNC_FRATIO - [10:8] */
1678#define ARIZONA_FLL1_SYNC_FRATIO_WIDTH 3 /* FLL1_SYNC_FRATIO - [10:8] */
1679
1680/*
1681 * R390 (0x186) - FLL1 Synchroniser 6
1682 */
1683#define ARIZONA_FLL1_CLK_SYNC_DIV_MASK 0x00C0 /* FLL1_CLK_SYNC_DIV - [7:6] */
1684#define ARIZONA_FLL1_CLK_SYNC_DIV_SHIFT 6 /* FLL1_CLK_SYNC_DIV - [7:6] */
1685#define ARIZONA_FLL1_CLK_SYNC_DIV_WIDTH 2 /* FLL1_CLK_SYNC_DIV - [7:6] */
1686#define ARIZONA_FLL1_CLK_SYNC_SRC_MASK 0x000F /* FLL1_CLK_SYNC_SRC - [3:0] */
1687#define ARIZONA_FLL1_CLK_SYNC_SRC_SHIFT 0 /* FLL1_CLK_SYNC_SRC - [3:0] */
1688#define ARIZONA_FLL1_CLK_SYNC_SRC_WIDTH 4 /* FLL1_CLK_SYNC_SRC - [3:0] */
1689
1690/*
1691 * R393 (0x189) - FLL1 Spread Spectrum
1692 */
1693#define ARIZONA_FLL1_SS_AMPL_MASK 0x0030 /* FLL1_SS_AMPL - [5:4] */
1694#define ARIZONA_FLL1_SS_AMPL_SHIFT 4 /* FLL1_SS_AMPL - [5:4] */
1695#define ARIZONA_FLL1_SS_AMPL_WIDTH 2 /* FLL1_SS_AMPL - [5:4] */
1696#define ARIZONA_FLL1_SS_FREQ_MASK 0x000C /* FLL1_SS_FREQ - [3:2] */
1697#define ARIZONA_FLL1_SS_FREQ_SHIFT 2 /* FLL1_SS_FREQ - [3:2] */
1698#define ARIZONA_FLL1_SS_FREQ_WIDTH 2 /* FLL1_SS_FREQ - [3:2] */
1699#define ARIZONA_FLL1_SS_SEL_MASK 0x0003 /* FLL1_SS_SEL - [1:0] */
1700#define ARIZONA_FLL1_SS_SEL_SHIFT 0 /* FLL1_SS_SEL - [1:0] */
1701#define ARIZONA_FLL1_SS_SEL_WIDTH 2 /* FLL1_SS_SEL - [1:0] */
1702
1703/*
1704 * R394 (0x18A) - FLL1 GPIO Clock
1705 */
1706#define ARIZONA_FLL1_GPDIV_MASK 0x00FE /* FLL1_GPDIV - [7:1] */
1707#define ARIZONA_FLL1_GPDIV_SHIFT 1 /* FLL1_GPDIV - [7:1] */
1708#define ARIZONA_FLL1_GPDIV_WIDTH 7 /* FLL1_GPDIV - [7:1] */
1709#define ARIZONA_FLL1_GPDIV_ENA 0x0001 /* FLL1_GPDIV_ENA */
1710#define ARIZONA_FLL1_GPDIV_ENA_MASK 0x0001 /* FLL1_GPDIV_ENA */
1711#define ARIZONA_FLL1_GPDIV_ENA_SHIFT 0 /* FLL1_GPDIV_ENA */
1712#define ARIZONA_FLL1_GPDIV_ENA_WIDTH 1 /* FLL1_GPDIV_ENA */
1713
1714/*
1715 * R401 (0x191) - FLL2 Control 1
1716 */
1717#define ARIZONA_FLL2_FREERUN 0x0002 /* FLL2_FREERUN */
1718#define ARIZONA_FLL2_FREERUN_MASK 0x0002 /* FLL2_FREERUN */
1719#define ARIZONA_FLL2_FREERUN_SHIFT 1 /* FLL2_FREERUN */
1720#define ARIZONA_FLL2_FREERUN_WIDTH 1 /* FLL2_FREERUN */
1721#define ARIZONA_FLL2_ENA 0x0001 /* FLL2_ENA */
1722#define ARIZONA_FLL2_ENA_MASK 0x0001 /* FLL2_ENA */
1723#define ARIZONA_FLL2_ENA_SHIFT 0 /* FLL2_ENA */
1724#define ARIZONA_FLL2_ENA_WIDTH 1 /* FLL2_ENA */
1725
1726/*
1727 * R402 (0x192) - FLL2 Control 2
1728 */
1729#define ARIZONA_FLL2_CTRL_UPD 0x8000 /* FLL2_CTRL_UPD */
1730#define ARIZONA_FLL2_CTRL_UPD_MASK 0x8000 /* FLL2_CTRL_UPD */
1731#define ARIZONA_FLL2_CTRL_UPD_SHIFT 15 /* FLL2_CTRL_UPD */
1732#define ARIZONA_FLL2_CTRL_UPD_WIDTH 1 /* FLL2_CTRL_UPD */
1733#define ARIZONA_FLL2_N_MASK 0x03FF /* FLL2_N - [9:0] */
1734#define ARIZONA_FLL2_N_SHIFT 0 /* FLL2_N - [9:0] */
1735#define ARIZONA_FLL2_N_WIDTH 10 /* FLL2_N - [9:0] */
1736
1737/*
1738 * R403 (0x193) - FLL2 Control 3
1739 */
1740#define ARIZONA_FLL2_THETA_MASK 0xFFFF /* FLL2_THETA - [15:0] */
1741#define ARIZONA_FLL2_THETA_SHIFT 0 /* FLL2_THETA - [15:0] */
1742#define ARIZONA_FLL2_THETA_WIDTH 16 /* FLL2_THETA - [15:0] */
1743
1744/*
1745 * R404 (0x194) - FLL2 Control 4
1746 */
1747#define ARIZONA_FLL2_LAMBDA_MASK 0xFFFF /* FLL2_LAMBDA - [15:0] */
1748#define ARIZONA_FLL2_LAMBDA_SHIFT 0 /* FLL2_LAMBDA - [15:0] */
1749#define ARIZONA_FLL2_LAMBDA_WIDTH 16 /* FLL2_LAMBDA - [15:0] */
1750
1751/*
1752 * R405 (0x195) - FLL2 Control 5
1753 */
1754#define ARIZONA_FLL2_FRATIO_MASK 0x0700 /* FLL2_FRATIO - [10:8] */
1755#define ARIZONA_FLL2_FRATIO_SHIFT 8 /* FLL2_FRATIO - [10:8] */
1756#define ARIZONA_FLL2_FRATIO_WIDTH 3 /* FLL2_FRATIO - [10:8] */
1757#define ARIZONA_FLL2_OUTDIV_MASK 0x000E /* FLL2_OUTDIV - [3:1] */
1758#define ARIZONA_FLL2_OUTDIV_SHIFT 1 /* FLL2_OUTDIV - [3:1] */
1759#define ARIZONA_FLL2_OUTDIV_WIDTH 3 /* FLL2_OUTDIV - [3:1] */
1760
1761/*
1762 * R406 (0x196) - FLL2 Control 6
1763 */
1764#define ARIZONA_FLL2_CLK_REF_DIV_MASK 0x00C0 /* FLL2_CLK_REF_DIV - [7:6] */
1765#define ARIZONA_FLL2_CLK_REF_DIV_SHIFT 6 /* FLL2_CLK_REF_DIV - [7:6] */
1766#define ARIZONA_FLL2_CLK_REF_DIV_WIDTH 2 /* FLL2_CLK_REF_DIV - [7:6] */
1767#define ARIZONA_FLL2_CLK_REF_SRC_MASK 0x000F /* FLL2_CLK_REF_SRC - [3:0] */
1768#define ARIZONA_FLL2_CLK_REF_SRC_SHIFT 0 /* FLL2_CLK_REF_SRC - [3:0] */
1769#define ARIZONA_FLL2_CLK_REF_SRC_WIDTH 4 /* FLL2_CLK_REF_SRC - [3:0] */
1770
1771/*
1772 * R407 (0x197) - FLL2 Loop Filter Test 1
1773 */
1774#define ARIZONA_FLL2_FRC_INTEG_UPD 0x8000 /* FLL2_FRC_INTEG_UPD */
1775#define ARIZONA_FLL2_FRC_INTEG_UPD_MASK 0x8000 /* FLL2_FRC_INTEG_UPD */
1776#define ARIZONA_FLL2_FRC_INTEG_UPD_SHIFT 15 /* FLL2_FRC_INTEG_UPD */
1777#define ARIZONA_FLL2_FRC_INTEG_UPD_WIDTH 1 /* FLL2_FRC_INTEG_UPD */
1778#define ARIZONA_FLL2_FRC_INTEG_VAL_MASK 0x0FFF /* FLL2_FRC_INTEG_VAL - [11:0] */
1779#define ARIZONA_FLL2_FRC_INTEG_VAL_SHIFT 0 /* FLL2_FRC_INTEG_VAL - [11:0] */
1780#define ARIZONA_FLL2_FRC_INTEG_VAL_WIDTH 12 /* FLL2_FRC_INTEG_VAL - [11:0] */
1781
1782/*
1783 * R417 (0x1A1) - FLL2 Synchroniser 1
1784 */
1785#define ARIZONA_FLL2_SYNC_ENA 0x0001 /* FLL2_SYNC_ENA */
1786#define ARIZONA_FLL2_SYNC_ENA_MASK 0x0001 /* FLL2_SYNC_ENA */
1787#define ARIZONA_FLL2_SYNC_ENA_SHIFT 0 /* FLL2_SYNC_ENA */
1788#define ARIZONA_FLL2_SYNC_ENA_WIDTH 1 /* FLL2_SYNC_ENA */
1789
1790/*
1791 * R418 (0x1A2) - FLL2 Synchroniser 2
1792 */
1793#define ARIZONA_FLL2_SYNC_N_MASK 0x03FF /* FLL2_SYNC_N - [9:0] */
1794#define ARIZONA_FLL2_SYNC_N_SHIFT 0 /* FLL2_SYNC_N - [9:0] */
1795#define ARIZONA_FLL2_SYNC_N_WIDTH 10 /* FLL2_SYNC_N - [9:0] */
1796
1797/*
1798 * R419 (0x1A3) - FLL2 Synchroniser 3
1799 */
1800#define ARIZONA_FLL2_SYNC_THETA_MASK 0xFFFF /* FLL2_SYNC_THETA - [15:0] */
1801#define ARIZONA_FLL2_SYNC_THETA_SHIFT 0 /* FLL2_SYNC_THETA - [15:0] */
1802#define ARIZONA_FLL2_SYNC_THETA_WIDTH 16 /* FLL2_SYNC_THETA - [15:0] */
1803
1804/*
1805 * R420 (0x1A4) - FLL2 Synchroniser 4
1806 */
1807#define ARIZONA_FLL2_SYNC_LAMBDA_MASK 0xFFFF /* FLL2_SYNC_LAMBDA - [15:0] */
1808#define ARIZONA_FLL2_SYNC_LAMBDA_SHIFT 0 /* FLL2_SYNC_LAMBDA - [15:0] */
1809#define ARIZONA_FLL2_SYNC_LAMBDA_WIDTH 16 /* FLL2_SYNC_LAMBDA - [15:0] */
1810
1811/*
1812 * R421 (0x1A5) - FLL2 Synchroniser 5
1813 */
1814#define ARIZONA_FLL2_SYNC_FRATIO_MASK 0x0700 /* FLL2_SYNC_FRATIO - [10:8] */
1815#define ARIZONA_FLL2_SYNC_FRATIO_SHIFT 8 /* FLL2_SYNC_FRATIO - [10:8] */
1816#define ARIZONA_FLL2_SYNC_FRATIO_WIDTH 3 /* FLL2_SYNC_FRATIO - [10:8] */
1817
1818/*
1819 * R422 (0x1A6) - FLL2 Synchroniser 6
1820 */
1821#define ARIZONA_FLL2_CLK_SYNC_DIV_MASK 0x00C0 /* FLL2_CLK_SYNC_DIV - [7:6] */
1822#define ARIZONA_FLL2_CLK_SYNC_DIV_SHIFT 6 /* FLL2_CLK_SYNC_DIV - [7:6] */
1823#define ARIZONA_FLL2_CLK_SYNC_DIV_WIDTH 2 /* FLL2_CLK_SYNC_DIV - [7:6] */
1824#define ARIZONA_FLL2_CLK_SYNC_SRC_MASK 0x000F /* FLL2_CLK_SYNC_SRC - [3:0] */
1825#define ARIZONA_FLL2_CLK_SYNC_SRC_SHIFT 0 /* FLL2_CLK_SYNC_SRC - [3:0] */
1826#define ARIZONA_FLL2_CLK_SYNC_SRC_WIDTH 4 /* FLL2_CLK_SYNC_SRC - [3:0] */
1827
1828/*
1829 * R425 (0x1A9) - FLL2 Spread Spectrum
1830 */
1831#define ARIZONA_FLL2_SS_AMPL_MASK 0x0030 /* FLL2_SS_AMPL - [5:4] */
1832#define ARIZONA_FLL2_SS_AMPL_SHIFT 4 /* FLL2_SS_AMPL - [5:4] */
1833#define ARIZONA_FLL2_SS_AMPL_WIDTH 2 /* FLL2_SS_AMPL - [5:4] */
1834#define ARIZONA_FLL2_SS_FREQ_MASK 0x000C /* FLL2_SS_FREQ - [3:2] */
1835#define ARIZONA_FLL2_SS_FREQ_SHIFT 2 /* FLL2_SS_FREQ - [3:2] */
1836#define ARIZONA_FLL2_SS_FREQ_WIDTH 2 /* FLL2_SS_FREQ - [3:2] */
1837#define ARIZONA_FLL2_SS_SEL_MASK 0x0003 /* FLL2_SS_SEL - [1:0] */
1838#define ARIZONA_FLL2_SS_SEL_SHIFT 0 /* FLL2_SS_SEL - [1:0] */
1839#define ARIZONA_FLL2_SS_SEL_WIDTH 2 /* FLL2_SS_SEL - [1:0] */
1840
1841/*
1842 * R426 (0x1AA) - FLL2 GPIO Clock
1843 */
1844#define ARIZONA_FLL2_GPDIV_MASK 0x00FE /* FLL2_GPDIV - [7:1] */
1845#define ARIZONA_FLL2_GPDIV_SHIFT 1 /* FLL2_GPDIV - [7:1] */
1846#define ARIZONA_FLL2_GPDIV_WIDTH 7 /* FLL2_GPDIV - [7:1] */
1847#define ARIZONA_FLL2_GPDIV_ENA 0x0001 /* FLL2_GPDIV_ENA */
1848#define ARIZONA_FLL2_GPDIV_ENA_MASK 0x0001 /* FLL2_GPDIV_ENA */
1849#define ARIZONA_FLL2_GPDIV_ENA_SHIFT 0 /* FLL2_GPDIV_ENA */
1850#define ARIZONA_FLL2_GPDIV_ENA_WIDTH 1 /* FLL2_GPDIV_ENA */
1851
1852/*
1853 * R512 (0x200) - Mic Charge Pump 1
1854 */
1855#define ARIZONA_CPMIC_DISCH 0x0004 /* CPMIC_DISCH */
1856#define ARIZONA_CPMIC_DISCH_MASK 0x0004 /* CPMIC_DISCH */
1857#define ARIZONA_CPMIC_DISCH_SHIFT 2 /* CPMIC_DISCH */
1858#define ARIZONA_CPMIC_DISCH_WIDTH 1 /* CPMIC_DISCH */
1859#define ARIZONA_CPMIC_BYPASS 0x0002 /* CPMIC_BYPASS */
1860#define ARIZONA_CPMIC_BYPASS_MASK 0x0002 /* CPMIC_BYPASS */
1861#define ARIZONA_CPMIC_BYPASS_SHIFT 1 /* CPMIC_BYPASS */
1862#define ARIZONA_CPMIC_BYPASS_WIDTH 1 /* CPMIC_BYPASS */
1863#define ARIZONA_CPMIC_ENA 0x0001 /* CPMIC_ENA */
1864#define ARIZONA_CPMIC_ENA_MASK 0x0001 /* CPMIC_ENA */
1865#define ARIZONA_CPMIC_ENA_SHIFT 0 /* CPMIC_ENA */
1866#define ARIZONA_CPMIC_ENA_WIDTH 1 /* CPMIC_ENA */
1867
1868/*
1869 * R528 (0x210) - LDO1 Control 1
1870 */
1871#define ARIZONA_LDO1_VSEL_MASK 0x07E0 /* LDO1_VSEL - [10:5] */
1872#define ARIZONA_LDO1_VSEL_SHIFT 5 /* LDO1_VSEL - [10:5] */
1873#define ARIZONA_LDO1_VSEL_WIDTH 6 /* LDO1_VSEL - [10:5] */
1874#define ARIZONA_LDO1_FAST 0x0010 /* LDO1_FAST */
1875#define ARIZONA_LDO1_FAST_MASK 0x0010 /* LDO1_FAST */
1876#define ARIZONA_LDO1_FAST_SHIFT 4 /* LDO1_FAST */
1877#define ARIZONA_LDO1_FAST_WIDTH 1 /* LDO1_FAST */
1878#define ARIZONA_LDO1_DISCH 0x0004 /* LDO1_DISCH */
1879#define ARIZONA_LDO1_DISCH_MASK 0x0004 /* LDO1_DISCH */
1880#define ARIZONA_LDO1_DISCH_SHIFT 2 /* LDO1_DISCH */
1881#define ARIZONA_LDO1_DISCH_WIDTH 1 /* LDO1_DISCH */
1882#define ARIZONA_LDO1_BYPASS 0x0002 /* LDO1_BYPASS */
1883#define ARIZONA_LDO1_BYPASS_MASK 0x0002 /* LDO1_BYPASS */
1884#define ARIZONA_LDO1_BYPASS_SHIFT 1 /* LDO1_BYPASS */
1885#define ARIZONA_LDO1_BYPASS_WIDTH 1 /* LDO1_BYPASS */
1886#define ARIZONA_LDO1_ENA 0x0001 /* LDO1_ENA */
1887#define ARIZONA_LDO1_ENA_MASK 0x0001 /* LDO1_ENA */
1888#define ARIZONA_LDO1_ENA_SHIFT 0 /* LDO1_ENA */
1889#define ARIZONA_LDO1_ENA_WIDTH 1 /* LDO1_ENA */
1890
1891/*
1892 * R531 (0x213) - LDO2 Control 1
1893 */
1894#define ARIZONA_LDO2_VSEL_MASK 0x07E0 /* LDO2_VSEL - [10:5] */
1895#define ARIZONA_LDO2_VSEL_SHIFT 5 /* LDO2_VSEL - [10:5] */
1896#define ARIZONA_LDO2_VSEL_WIDTH 6 /* LDO2_VSEL - [10:5] */
1897#define ARIZONA_LDO2_FAST 0x0010 /* LDO2_FAST */
1898#define ARIZONA_LDO2_FAST_MASK 0x0010 /* LDO2_FAST */
1899#define ARIZONA_LDO2_FAST_SHIFT 4 /* LDO2_FAST */
1900#define ARIZONA_LDO2_FAST_WIDTH 1 /* LDO2_FAST */
1901#define ARIZONA_LDO2_DISCH 0x0004 /* LDO2_DISCH */
1902#define ARIZONA_LDO2_DISCH_MASK 0x0004 /* LDO2_DISCH */
1903#define ARIZONA_LDO2_DISCH_SHIFT 2 /* LDO2_DISCH */
1904#define ARIZONA_LDO2_DISCH_WIDTH 1 /* LDO2_DISCH */
1905#define ARIZONA_LDO2_BYPASS 0x0002 /* LDO2_BYPASS */
1906#define ARIZONA_LDO2_BYPASS_MASK 0x0002 /* LDO2_BYPASS */
1907#define ARIZONA_LDO2_BYPASS_SHIFT 1 /* LDO2_BYPASS */
1908#define ARIZONA_LDO2_BYPASS_WIDTH 1 /* LDO2_BYPASS */
1909#define ARIZONA_LDO2_ENA 0x0001 /* LDO2_ENA */
1910#define ARIZONA_LDO2_ENA_MASK 0x0001 /* LDO2_ENA */
1911#define ARIZONA_LDO2_ENA_SHIFT 0 /* LDO2_ENA */
1912#define ARIZONA_LDO2_ENA_WIDTH 1 /* LDO2_ENA */
1913
1914/*
1915 * R536 (0x218) - Mic Bias Ctrl 1
1916 */
1917#define ARIZONA_MICB1_EXT_CAP 0x8000 /* MICB1_EXT_CAP */
1918#define ARIZONA_MICB1_EXT_CAP_MASK 0x8000 /* MICB1_EXT_CAP */
1919#define ARIZONA_MICB1_EXT_CAP_SHIFT 15 /* MICB1_EXT_CAP */
1920#define ARIZONA_MICB1_EXT_CAP_WIDTH 1 /* MICB1_EXT_CAP */
1921#define ARIZONA_MICB1_LVL_MASK 0x01E0 /* MICB1_LVL - [8:5] */
1922#define ARIZONA_MICB1_LVL_SHIFT 5 /* MICB1_LVL - [8:5] */
1923#define ARIZONA_MICB1_LVL_WIDTH 4 /* MICB1_LVL - [8:5] */
1924#define ARIZONA_MICB1_FAST 0x0010 /* MICB1_FAST */
1925#define ARIZONA_MICB1_FAST_MASK 0x0010 /* MICB1_FAST */
1926#define ARIZONA_MICB1_FAST_SHIFT 4 /* MICB1_FAST */
1927#define ARIZONA_MICB1_FAST_WIDTH 1 /* MICB1_FAST */
1928#define ARIZONA_MICB1_RATE 0x0008 /* MICB1_RATE */
1929#define ARIZONA_MICB1_RATE_MASK 0x0008 /* MICB1_RATE */
1930#define ARIZONA_MICB1_RATE_SHIFT 3 /* MICB1_RATE */
1931#define ARIZONA_MICB1_RATE_WIDTH 1 /* MICB1_RATE */
1932#define ARIZONA_MICB1_DISCH 0x0004 /* MICB1_DISCH */
1933#define ARIZONA_MICB1_DISCH_MASK 0x0004 /* MICB1_DISCH */
1934#define ARIZONA_MICB1_DISCH_SHIFT 2 /* MICB1_DISCH */
1935#define ARIZONA_MICB1_DISCH_WIDTH 1 /* MICB1_DISCH */
1936#define ARIZONA_MICB1_BYPASS 0x0002 /* MICB1_BYPASS */
1937#define ARIZONA_MICB1_BYPASS_MASK 0x0002 /* MICB1_BYPASS */
1938#define ARIZONA_MICB1_BYPASS_SHIFT 1 /* MICB1_BYPASS */
1939#define ARIZONA_MICB1_BYPASS_WIDTH 1 /* MICB1_BYPASS */
1940#define ARIZONA_MICB1_ENA 0x0001 /* MICB1_ENA */
1941#define ARIZONA_MICB1_ENA_MASK 0x0001 /* MICB1_ENA */
1942#define ARIZONA_MICB1_ENA_SHIFT 0 /* MICB1_ENA */
1943#define ARIZONA_MICB1_ENA_WIDTH 1 /* MICB1_ENA */
1944
1945/*
1946 * R537 (0x219) - Mic Bias Ctrl 2
1947 */
1948#define ARIZONA_MICB2_EXT_CAP 0x8000 /* MICB2_EXT_CAP */
1949#define ARIZONA_MICB2_EXT_CAP_MASK 0x8000 /* MICB2_EXT_CAP */
1950#define ARIZONA_MICB2_EXT_CAP_SHIFT 15 /* MICB2_EXT_CAP */
1951#define ARIZONA_MICB2_EXT_CAP_WIDTH 1 /* MICB2_EXT_CAP */
1952#define ARIZONA_MICB2_LVL_MASK 0x01E0 /* MICB2_LVL - [8:5] */
1953#define ARIZONA_MICB2_LVL_SHIFT 5 /* MICB2_LVL - [8:5] */
1954#define ARIZONA_MICB2_LVL_WIDTH 4 /* MICB2_LVL - [8:5] */
1955#define ARIZONA_MICB2_FAST 0x0010 /* MICB2_FAST */
1956#define ARIZONA_MICB2_FAST_MASK 0x0010 /* MICB2_FAST */
1957#define ARIZONA_MICB2_FAST_SHIFT 4 /* MICB2_FAST */
1958#define ARIZONA_MICB2_FAST_WIDTH 1 /* MICB2_FAST */
1959#define ARIZONA_MICB2_RATE 0x0008 /* MICB2_RATE */
1960#define ARIZONA_MICB2_RATE_MASK 0x0008 /* MICB2_RATE */
1961#define ARIZONA_MICB2_RATE_SHIFT 3 /* MICB2_RATE */
1962#define ARIZONA_MICB2_RATE_WIDTH 1 /* MICB2_RATE */
1963#define ARIZONA_MICB2_DISCH 0x0004 /* MICB2_DISCH */
1964#define ARIZONA_MICB2_DISCH_MASK 0x0004 /* MICB2_DISCH */
1965#define ARIZONA_MICB2_DISCH_SHIFT 2 /* MICB2_DISCH */
1966#define ARIZONA_MICB2_DISCH_WIDTH 1 /* MICB2_DISCH */
1967#define ARIZONA_MICB2_BYPASS 0x0002 /* MICB2_BYPASS */
1968#define ARIZONA_MICB2_BYPASS_MASK 0x0002 /* MICB2_BYPASS */
1969#define ARIZONA_MICB2_BYPASS_SHIFT 1 /* MICB2_BYPASS */
1970#define ARIZONA_MICB2_BYPASS_WIDTH 1 /* MICB2_BYPASS */
1971#define ARIZONA_MICB2_ENA 0x0001 /* MICB2_ENA */
1972#define ARIZONA_MICB2_ENA_MASK 0x0001 /* MICB2_ENA */
1973#define ARIZONA_MICB2_ENA_SHIFT 0 /* MICB2_ENA */
1974#define ARIZONA_MICB2_ENA_WIDTH 1 /* MICB2_ENA */
1975
1976/*
1977 * R538 (0x21A) - Mic Bias Ctrl 3
1978 */
1979#define ARIZONA_MICB3_EXT_CAP 0x8000 /* MICB3_EXT_CAP */
1980#define ARIZONA_MICB3_EXT_CAP_MASK 0x8000 /* MICB3_EXT_CAP */
1981#define ARIZONA_MICB3_EXT_CAP_SHIFT 15 /* MICB3_EXT_CAP */
1982#define ARIZONA_MICB3_EXT_CAP_WIDTH 1 /* MICB3_EXT_CAP */
1983#define ARIZONA_MICB3_LVL_MASK 0x01E0 /* MICB3_LVL - [8:5] */
1984#define ARIZONA_MICB3_LVL_SHIFT 5 /* MICB3_LVL - [8:5] */
1985#define ARIZONA_MICB3_LVL_WIDTH 4 /* MICB3_LVL - [8:5] */
1986#define ARIZONA_MICB3_FAST 0x0010 /* MICB3_FAST */
1987#define ARIZONA_MICB3_FAST_MASK 0x0010 /* MICB3_FAST */
1988#define ARIZONA_MICB3_FAST_SHIFT 4 /* MICB3_FAST */
1989#define ARIZONA_MICB3_FAST_WIDTH 1 /* MICB3_FAST */
1990#define ARIZONA_MICB3_RATE 0x0008 /* MICB3_RATE */
1991#define ARIZONA_MICB3_RATE_MASK 0x0008 /* MICB3_RATE */
1992#define ARIZONA_MICB3_RATE_SHIFT 3 /* MICB3_RATE */
1993#define ARIZONA_MICB3_RATE_WIDTH 1 /* MICB3_RATE */
1994#define ARIZONA_MICB3_DISCH 0x0004 /* MICB3_DISCH */
1995#define ARIZONA_MICB3_DISCH_MASK 0x0004 /* MICB3_DISCH */
1996#define ARIZONA_MICB3_DISCH_SHIFT 2 /* MICB3_DISCH */
1997#define ARIZONA_MICB3_DISCH_WIDTH 1 /* MICB3_DISCH */
1998#define ARIZONA_MICB3_BYPASS 0x0002 /* MICB3_BYPASS */
1999#define ARIZONA_MICB3_BYPASS_MASK 0x0002 /* MICB3_BYPASS */
2000#define ARIZONA_MICB3_BYPASS_SHIFT 1 /* MICB3_BYPASS */
2001#define ARIZONA_MICB3_BYPASS_WIDTH 1 /* MICB3_BYPASS */
2002#define ARIZONA_MICB3_ENA 0x0001 /* MICB3_ENA */
2003#define ARIZONA_MICB3_ENA_MASK 0x0001 /* MICB3_ENA */
2004#define ARIZONA_MICB3_ENA_SHIFT 0 /* MICB3_ENA */
2005#define ARIZONA_MICB3_ENA_WIDTH 1 /* MICB3_ENA */
2006
2007/*
2008 * R659 (0x293) - Accessory Detect Mode 1
2009 */
2010#define ARIZONA_ACCDET_SRC 0x2000 /* ACCDET_SRC */
2011#define ARIZONA_ACCDET_SRC_MASK 0x2000 /* ACCDET_SRC */
2012#define ARIZONA_ACCDET_SRC_SHIFT 13 /* ACCDET_SRC */
2013#define ARIZONA_ACCDET_SRC_WIDTH 1 /* ACCDET_SRC */
2014#define ARIZONA_ACCDET_MODE_MASK 0x0003 /* ACCDET_MODE - [1:0] */
2015#define ARIZONA_ACCDET_MODE_SHIFT 0 /* ACCDET_MODE - [1:0] */
2016#define ARIZONA_ACCDET_MODE_WIDTH 2 /* ACCDET_MODE - [1:0] */
2017
2018/*
2019 * R667 (0x29B) - Headphone Detect 1
2020 */
2021#define ARIZONA_HP_STEP_SIZE 0x0100 /* HP_STEP_SIZE */
2022#define ARIZONA_HP_STEP_SIZE_MASK 0x0100 /* HP_STEP_SIZE */
2023#define ARIZONA_HP_STEP_SIZE_SHIFT 8 /* HP_STEP_SIZE */
2024#define ARIZONA_HP_STEP_SIZE_WIDTH 1 /* HP_STEP_SIZE */
2025#define ARIZONA_HP_HOLDTIME_MASK 0x00E0 /* HP_HOLDTIME - [7:5] */
2026#define ARIZONA_HP_HOLDTIME_SHIFT 5 /* HP_HOLDTIME - [7:5] */
2027#define ARIZONA_HP_HOLDTIME_WIDTH 3 /* HP_HOLDTIME - [7:5] */
2028#define ARIZONA_HP_CLK_DIV_MASK 0x0018 /* HP_CLK_DIV - [4:3] */
2029#define ARIZONA_HP_CLK_DIV_SHIFT 3 /* HP_CLK_DIV - [4:3] */
2030#define ARIZONA_HP_CLK_DIV_WIDTH 2 /* HP_CLK_DIV - [4:3] */
2031#define ARIZONA_HP_IDAC_STEER 0x0004 /* HP_IDAC_STEER */
2032#define ARIZONA_HP_IDAC_STEER_MASK 0x0004 /* HP_IDAC_STEER */
2033#define ARIZONA_HP_IDAC_STEER_SHIFT 2 /* HP_IDAC_STEER */
2034#define ARIZONA_HP_IDAC_STEER_WIDTH 1 /* HP_IDAC_STEER */
2035#define ARIZONA_HP_RATE 0x0002 /* HP_RATE */
2036#define ARIZONA_HP_RATE_MASK 0x0002 /* HP_RATE */
2037#define ARIZONA_HP_RATE_SHIFT 1 /* HP_RATE */
2038#define ARIZONA_HP_RATE_WIDTH 1 /* HP_RATE */
2039#define ARIZONA_HP_POLL 0x0001 /* HP_POLL */
2040#define ARIZONA_HP_POLL_MASK 0x0001 /* HP_POLL */
2041#define ARIZONA_HP_POLL_SHIFT 0 /* HP_POLL */
2042#define ARIZONA_HP_POLL_WIDTH 1 /* HP_POLL */
2043
2044/*
2045 * R668 (0x29C) - Headphone Detect 2
2046 */
2047#define ARIZONA_HP_DONE 0x0080 /* HP_DONE */
2048#define ARIZONA_HP_DONE_MASK 0x0080 /* HP_DONE */
2049#define ARIZONA_HP_DONE_SHIFT 7 /* HP_DONE */
2050#define ARIZONA_HP_DONE_WIDTH 1 /* HP_DONE */
2051#define ARIZONA_HP_LVL_MASK 0x007F /* HP_LVL - [6:0] */
2052#define ARIZONA_HP_LVL_SHIFT 0 /* HP_LVL - [6:0] */
2053#define ARIZONA_HP_LVL_WIDTH 7 /* HP_LVL - [6:0] */
2054
2055/*
2056 * R675 (0x2A3) - Mic Detect 1
2057 */
2058#define ARIZONA_MICD_BIAS_STARTTIME_MASK 0xF000 /* MICD_BIAS_STARTTIME - [15:12] */
2059#define ARIZONA_MICD_BIAS_STARTTIME_SHIFT 12 /* MICD_BIAS_STARTTIME - [15:12] */
2060#define ARIZONA_MICD_BIAS_STARTTIME_WIDTH 4 /* MICD_BIAS_STARTTIME - [15:12] */
2061#define ARIZONA_MICD_RATE_MASK 0x0F00 /* MICD_RATE - [11:8] */
2062#define ARIZONA_MICD_RATE_SHIFT 8 /* MICD_RATE - [11:8] */
2063#define ARIZONA_MICD_RATE_WIDTH 4 /* MICD_RATE - [11:8] */
2064#define ARIZONA_MICD_BIAS_SRC_MASK 0x0030 /* MICD_BIAS_SRC - [5:4] */
2065#define ARIZONA_MICD_BIAS_SRC_SHIFT 4 /* MICD_BIAS_SRC - [5:4] */
2066#define ARIZONA_MICD_BIAS_SRC_WIDTH 2 /* MICD_BIAS_SRC - [5:4] */
2067#define ARIZONA_MICD_DBTIME 0x0002 /* MICD_DBTIME */
2068#define ARIZONA_MICD_DBTIME_MASK 0x0002 /* MICD_DBTIME */
2069#define ARIZONA_MICD_DBTIME_SHIFT 1 /* MICD_DBTIME */
2070#define ARIZONA_MICD_DBTIME_WIDTH 1 /* MICD_DBTIME */
2071#define ARIZONA_MICD_ENA 0x0001 /* MICD_ENA */
2072#define ARIZONA_MICD_ENA_MASK 0x0001 /* MICD_ENA */
2073#define ARIZONA_MICD_ENA_SHIFT 0 /* MICD_ENA */
2074#define ARIZONA_MICD_ENA_WIDTH 1 /* MICD_ENA */
2075
2076/*
2077 * R676 (0x2A4) - Mic Detect 2
2078 */
2079#define ARIZONA_MICD_LVL_SEL_MASK 0x00FF /* MICD_LVL_SEL - [7:0] */
2080#define ARIZONA_MICD_LVL_SEL_SHIFT 0 /* MICD_LVL_SEL - [7:0] */
2081#define ARIZONA_MICD_LVL_SEL_WIDTH 8 /* MICD_LVL_SEL - [7:0] */
2082
2083/*
2084 * R677 (0x2A5) - Mic Detect 3
2085 */
2086#define ARIZONA_MICD_LVL_MASK 0x07FC /* MICD_LVL - [10:2] */
2087#define ARIZONA_MICD_LVL_SHIFT 2 /* MICD_LVL - [10:2] */
2088#define ARIZONA_MICD_LVL_WIDTH 9 /* MICD_LVL - [10:2] */
2089#define ARIZONA_MICD_VALID 0x0002 /* MICD_VALID */
2090#define ARIZONA_MICD_VALID_MASK 0x0002 /* MICD_VALID */
2091#define ARIZONA_MICD_VALID_SHIFT 1 /* MICD_VALID */
2092#define ARIZONA_MICD_VALID_WIDTH 1 /* MICD_VALID */
2093#define ARIZONA_MICD_STS 0x0001 /* MICD_STS */
2094#define ARIZONA_MICD_STS_MASK 0x0001 /* MICD_STS */
2095#define ARIZONA_MICD_STS_SHIFT 0 /* MICD_STS */
2096#define ARIZONA_MICD_STS_WIDTH 1 /* MICD_STS */
2097
2098/*
2099 * R707 (0x2C3) - Mic noise mix control 1
2100 */
2101#define ARIZONA_MICMUTE_RATE_MASK 0x7800 /* MICMUTE_RATE - [14:11] */
2102#define ARIZONA_MICMUTE_RATE_SHIFT 11 /* MICMUTE_RATE - [14:11] */
2103#define ARIZONA_MICMUTE_RATE_WIDTH 4 /* MICMUTE_RATE - [14:11] */
2104#define ARIZONA_MICMUTE_MIX_ENA 0x0040 /* MICMUTE_MIX_ENA */
2105#define ARIZONA_MICMUTE_MIX_ENA_MASK 0x0040 /* MICMUTE_MIX_ENA */
2106#define ARIZONA_MICMUTE_MIX_ENA_SHIFT 6 /* MICMUTE_MIX_ENA */
2107#define ARIZONA_MICMUTE_MIX_ENA_WIDTH 1 /* MICMUTE_MIX_ENA */
2108
2109/*
2110 * R715 (0x2CB) - Isolation control
2111 */
2112#define ARIZONA_ISOLATE_DCVDD1 0x0001 /* ISOLATE_DCVDD1 */
2113#define ARIZONA_ISOLATE_DCVDD1_MASK 0x0001 /* ISOLATE_DCVDD1 */
2114#define ARIZONA_ISOLATE_DCVDD1_SHIFT 0 /* ISOLATE_DCVDD1 */
2115#define ARIZONA_ISOLATE_DCVDD1_WIDTH 1 /* ISOLATE_DCVDD1 */
2116
2117/*
2118 * R723 (0x2D3) - Jack detect analogue
2119 */
2120#define ARIZONA_JD2_ENA 0x0002 /* JD2_ENA */
2121#define ARIZONA_JD2_ENA_MASK 0x0002 /* JD2_ENA */
2122#define ARIZONA_JD2_ENA_SHIFT 1 /* JD2_ENA */
2123#define ARIZONA_JD2_ENA_WIDTH 1 /* JD2_ENA */
2124#define ARIZONA_JD1_ENA 0x0001 /* JD1_ENA */
2125#define ARIZONA_JD1_ENA_MASK 0x0001 /* JD1_ENA */
2126#define ARIZONA_JD1_ENA_SHIFT 0 /* JD1_ENA */
2127#define ARIZONA_JD1_ENA_WIDTH 1 /* JD1_ENA */
2128
2129/*
2130 * R768 (0x300) - Input Enables
2131 */
2132#define ARIZONA_IN4L_ENA 0x0080 /* IN4L_ENA */
2133#define ARIZONA_IN4L_ENA_MASK 0x0080 /* IN4L_ENA */
2134#define ARIZONA_IN4L_ENA_SHIFT 7 /* IN4L_ENA */
2135#define ARIZONA_IN4L_ENA_WIDTH 1 /* IN4L_ENA */
2136#define ARIZONA_IN4R_ENA 0x0040 /* IN4R_ENA */
2137#define ARIZONA_IN4R_ENA_MASK 0x0040 /* IN4R_ENA */
2138#define ARIZONA_IN4R_ENA_SHIFT 6 /* IN4R_ENA */
2139#define ARIZONA_IN4R_ENA_WIDTH 1 /* IN4R_ENA */
2140#define ARIZONA_IN3L_ENA 0x0020 /* IN3L_ENA */
2141#define ARIZONA_IN3L_ENA_MASK 0x0020 /* IN3L_ENA */
2142#define ARIZONA_IN3L_ENA_SHIFT 5 /* IN3L_ENA */
2143#define ARIZONA_IN3L_ENA_WIDTH 1 /* IN3L_ENA */
2144#define ARIZONA_IN3R_ENA 0x0010 /* IN3R_ENA */
2145#define ARIZONA_IN3R_ENA_MASK 0x0010 /* IN3R_ENA */
2146#define ARIZONA_IN3R_ENA_SHIFT 4 /* IN3R_ENA */
2147#define ARIZONA_IN3R_ENA_WIDTH 1 /* IN3R_ENA */
2148#define ARIZONA_IN2L_ENA 0x0008 /* IN2L_ENA */
2149#define ARIZONA_IN2L_ENA_MASK 0x0008 /* IN2L_ENA */
2150#define ARIZONA_IN2L_ENA_SHIFT 3 /* IN2L_ENA */
2151#define ARIZONA_IN2L_ENA_WIDTH 1 /* IN2L_ENA */
2152#define ARIZONA_IN2R_ENA 0x0004 /* IN2R_ENA */
2153#define ARIZONA_IN2R_ENA_MASK 0x0004 /* IN2R_ENA */
2154#define ARIZONA_IN2R_ENA_SHIFT 2 /* IN2R_ENA */
2155#define ARIZONA_IN2R_ENA_WIDTH 1 /* IN2R_ENA */
2156#define ARIZONA_IN1L_ENA 0x0002 /* IN1L_ENA */
2157#define ARIZONA_IN1L_ENA_MASK 0x0002 /* IN1L_ENA */
2158#define ARIZONA_IN1L_ENA_SHIFT 1 /* IN1L_ENA */
2159#define ARIZONA_IN1L_ENA_WIDTH 1 /* IN1L_ENA */
2160#define ARIZONA_IN1R_ENA 0x0001 /* IN1R_ENA */
2161#define ARIZONA_IN1R_ENA_MASK 0x0001 /* IN1R_ENA */
2162#define ARIZONA_IN1R_ENA_SHIFT 0 /* IN1R_ENA */
2163#define ARIZONA_IN1R_ENA_WIDTH 1 /* IN1R_ENA */
2164
2165/*
2166 * R776 (0x308) - Input Rate
2167 */
2168#define ARIZONA_IN_RATE_MASK 0x7800 /* IN_RATE - [14:11] */
2169#define ARIZONA_IN_RATE_SHIFT 11 /* IN_RATE - [14:11] */
2170#define ARIZONA_IN_RATE_WIDTH 4 /* IN_RATE - [14:11] */
2171
2172/*
2173 * R777 (0x309) - Input Volume Ramp
2174 */
2175#define ARIZONA_IN_VD_RAMP_MASK 0x0070 /* IN_VD_RAMP - [6:4] */
2176#define ARIZONA_IN_VD_RAMP_SHIFT 4 /* IN_VD_RAMP - [6:4] */
2177#define ARIZONA_IN_VD_RAMP_WIDTH 3 /* IN_VD_RAMP - [6:4] */
2178#define ARIZONA_IN_VI_RAMP_MASK 0x0007 /* IN_VI_RAMP - [2:0] */
2179#define ARIZONA_IN_VI_RAMP_SHIFT 0 /* IN_VI_RAMP - [2:0] */
2180#define ARIZONA_IN_VI_RAMP_WIDTH 3 /* IN_VI_RAMP - [2:0] */
2181
2182/*
2183 * R784 (0x310) - IN1L Control
2184 */
2185#define ARIZONA_IN1_OSR_MASK 0x6000 /* IN1_OSR - [14:13] */
2186#define ARIZONA_IN1_OSR_SHIFT 13 /* IN1_OSR - [14:13] */
2187#define ARIZONA_IN1_OSR_WIDTH 2 /* IN1_OSR - [14:13] */
2188#define ARIZONA_IN1_DMIC_SUP_MASK 0x1800 /* IN1_DMIC_SUP - [12:11] */
2189#define ARIZONA_IN1_DMIC_SUP_SHIFT 11 /* IN1_DMIC_SUP - [12:11] */
2190#define ARIZONA_IN1_DMIC_SUP_WIDTH 2 /* IN1_DMIC_SUP - [12:11] */
2191#define ARIZONA_IN1_MODE_MASK 0x0600 /* IN1_MODE - [10:9] */
2192#define ARIZONA_IN1_MODE_SHIFT 9 /* IN1_MODE - [10:9] */
2193#define ARIZONA_IN1_MODE_WIDTH 2 /* IN1_MODE - [10:9] */
2194#define ARIZONA_IN1L_PGA_VOL_MASK 0x00FE /* IN1L_PGA_VOL - [7:1] */
2195#define ARIZONA_IN1L_PGA_VOL_SHIFT 1 /* IN1L_PGA_VOL - [7:1] */
2196#define ARIZONA_IN1L_PGA_VOL_WIDTH 7 /* IN1L_PGA_VOL - [7:1] */
2197
2198/*
2199 * R785 (0x311) - ADC Digital Volume 1L
2200 */
2201#define ARIZONA_IN_VU 0x0200 /* IN_VU */
2202#define ARIZONA_IN_VU_MASK 0x0200 /* IN_VU */
2203#define ARIZONA_IN_VU_SHIFT 9 /* IN_VU */
2204#define ARIZONA_IN_VU_WIDTH 1 /* IN_VU */
2205#define ARIZONA_IN1L_MUTE 0x0100 /* IN1L_MUTE */
2206#define ARIZONA_IN1L_MUTE_MASK 0x0100 /* IN1L_MUTE */
2207#define ARIZONA_IN1L_MUTE_SHIFT 8 /* IN1L_MUTE */
2208#define ARIZONA_IN1L_MUTE_WIDTH 1 /* IN1L_MUTE */
2209#define ARIZONA_IN1L_DIG_VOL_MASK 0x00FF /* IN1L_DIG_VOL - [7:0] */
2210#define ARIZONA_IN1L_DIG_VOL_SHIFT 0 /* IN1L_DIG_VOL - [7:0] */
2211#define ARIZONA_IN1L_DIG_VOL_WIDTH 8 /* IN1L_DIG_VOL - [7:0] */
2212
2213/*
2214 * R786 (0x312) - DMIC1L Control
2215 */
2216#define ARIZONA_IN1_DMICL_DLY_MASK 0x003F /* IN1_DMICL_DLY - [5:0] */
2217#define ARIZONA_IN1_DMICL_DLY_SHIFT 0 /* IN1_DMICL_DLY - [5:0] */
2218#define ARIZONA_IN1_DMICL_DLY_WIDTH 6 /* IN1_DMICL_DLY - [5:0] */
2219
2220/*
2221 * R788 (0x314) - IN1R Control
2222 */
2223#define ARIZONA_IN1R_PGA_VOL_MASK 0x00FE /* IN1R_PGA_VOL - [7:1] */
2224#define ARIZONA_IN1R_PGA_VOL_SHIFT 1 /* IN1R_PGA_VOL - [7:1] */
2225#define ARIZONA_IN1R_PGA_VOL_WIDTH 7 /* IN1R_PGA_VOL - [7:1] */
2226
2227/*
2228 * R789 (0x315) - ADC Digital Volume 1R
2229 */
2230#define ARIZONA_IN_VU 0x0200 /* IN_VU */
2231#define ARIZONA_IN_VU_MASK 0x0200 /* IN_VU */
2232#define ARIZONA_IN_VU_SHIFT 9 /* IN_VU */
2233#define ARIZONA_IN_VU_WIDTH 1 /* IN_VU */
2234#define ARIZONA_IN1R_MUTE 0x0100 /* IN1R_MUTE */
2235#define ARIZONA_IN1R_MUTE_MASK 0x0100 /* IN1R_MUTE */
2236#define ARIZONA_IN1R_MUTE_SHIFT 8 /* IN1R_MUTE */
2237#define ARIZONA_IN1R_MUTE_WIDTH 1 /* IN1R_MUTE */
2238#define ARIZONA_IN1R_DIG_VOL_MASK 0x00FF /* IN1R_DIG_VOL - [7:0] */
2239#define ARIZONA_IN1R_DIG_VOL_SHIFT 0 /* IN1R_DIG_VOL - [7:0] */
2240#define ARIZONA_IN1R_DIG_VOL_WIDTH 8 /* IN1R_DIG_VOL - [7:0] */
2241
2242/*
2243 * R790 (0x316) - DMIC1R Control
2244 */
2245#define ARIZONA_IN1_DMICR_DLY_MASK 0x003F /* IN1_DMICR_DLY - [5:0] */
2246#define ARIZONA_IN1_DMICR_DLY_SHIFT 0 /* IN1_DMICR_DLY - [5:0] */
2247#define ARIZONA_IN1_DMICR_DLY_WIDTH 6 /* IN1_DMICR_DLY - [5:0] */
2248
2249/*
2250 * R792 (0x318) - IN2L Control
2251 */
2252#define ARIZONA_IN2_OSR_MASK 0x6000 /* IN2_OSR - [14:13] */
2253#define ARIZONA_IN2_OSR_SHIFT 13 /* IN2_OSR - [14:13] */
2254#define ARIZONA_IN2_OSR_WIDTH 2 /* IN2_OSR - [14:13] */
2255#define ARIZONA_IN2_DMIC_SUP_MASK 0x1800 /* IN2_DMIC_SUP - [12:11] */
2256#define ARIZONA_IN2_DMIC_SUP_SHIFT 11 /* IN2_DMIC_SUP - [12:11] */
2257#define ARIZONA_IN2_DMIC_SUP_WIDTH 2 /* IN2_DMIC_SUP - [12:11] */
2258#define ARIZONA_IN2_MODE_MASK 0x0600 /* IN2_MODE - [10:9] */
2259#define ARIZONA_IN2_MODE_SHIFT 9 /* IN2_MODE - [10:9] */
2260#define ARIZONA_IN2_MODE_WIDTH 2 /* IN2_MODE - [10:9] */
2261#define ARIZONA_IN2L_PGA_VOL_MASK 0x00FE /* IN2L_PGA_VOL - [7:1] */
2262#define ARIZONA_IN2L_PGA_VOL_SHIFT 1 /* IN2L_PGA_VOL - [7:1] */
2263#define ARIZONA_IN2L_PGA_VOL_WIDTH 7 /* IN2L_PGA_VOL - [7:1] */
2264
2265/*
2266 * R793 (0x319) - ADC Digital Volume 2L
2267 */
2268#define ARIZONA_IN_VU 0x0200 /* IN_VU */
2269#define ARIZONA_IN_VU_MASK 0x0200 /* IN_VU */
2270#define ARIZONA_IN_VU_SHIFT 9 /* IN_VU */
2271#define ARIZONA_IN_VU_WIDTH 1 /* IN_VU */
2272#define ARIZONA_IN2L_MUTE 0x0100 /* IN2L_MUTE */
2273#define ARIZONA_IN2L_MUTE_MASK 0x0100 /* IN2L_MUTE */
2274#define ARIZONA_IN2L_MUTE_SHIFT 8 /* IN2L_MUTE */
2275#define ARIZONA_IN2L_MUTE_WIDTH 1 /* IN2L_MUTE */
2276#define ARIZONA_IN2L_DIG_VOL_MASK 0x00FF /* IN2L_DIG_VOL - [7:0] */
2277#define ARIZONA_IN2L_DIG_VOL_SHIFT 0 /* IN2L_DIG_VOL - [7:0] */
2278#define ARIZONA_IN2L_DIG_VOL_WIDTH 8 /* IN2L_DIG_VOL - [7:0] */
2279
2280/*
2281 * R794 (0x31A) - DMIC2L Control
2282 */
2283#define ARIZONA_IN2_DMICL_DLY_MASK 0x003F /* IN2_DMICL_DLY - [5:0] */
2284#define ARIZONA_IN2_DMICL_DLY_SHIFT 0 /* IN2_DMICL_DLY - [5:0] */
2285#define ARIZONA_IN2_DMICL_DLY_WIDTH 6 /* IN2_DMICL_DLY - [5:0] */
2286
2287/*
2288 * R796 (0x31C) - IN2R Control
2289 */
2290#define ARIZONA_IN2R_PGA_VOL_MASK 0x00FE /* IN2R_PGA_VOL - [7:1] */
2291#define ARIZONA_IN2R_PGA_VOL_SHIFT 1 /* IN2R_PGA_VOL - [7:1] */
2292#define ARIZONA_IN2R_PGA_VOL_WIDTH 7 /* IN2R_PGA_VOL - [7:1] */
2293
2294/*
2295 * R797 (0x31D) - ADC Digital Volume 2R
2296 */
2297#define ARIZONA_IN_VU 0x0200 /* IN_VU */
2298#define ARIZONA_IN_VU_MASK 0x0200 /* IN_VU */
2299#define ARIZONA_IN_VU_SHIFT 9 /* IN_VU */
2300#define ARIZONA_IN_VU_WIDTH 1 /* IN_VU */
2301#define ARIZONA_IN2R_MUTE 0x0100 /* IN2R_MUTE */
2302#define ARIZONA_IN2R_MUTE_MASK 0x0100 /* IN2R_MUTE */
2303#define ARIZONA_IN2R_MUTE_SHIFT 8 /* IN2R_MUTE */
2304#define ARIZONA_IN2R_MUTE_WIDTH 1 /* IN2R_MUTE */
2305#define ARIZONA_IN2R_DIG_VOL_MASK 0x00FF /* IN2R_DIG_VOL - [7:0] */
2306#define ARIZONA_IN2R_DIG_VOL_SHIFT 0 /* IN2R_DIG_VOL - [7:0] */
2307#define ARIZONA_IN2R_DIG_VOL_WIDTH 8 /* IN2R_DIG_VOL - [7:0] */
2308
2309/*
2310 * R798 (0x31E) - DMIC2R Control
2311 */
2312#define ARIZONA_IN2_DMICR_DLY_MASK 0x003F /* IN2_DMICR_DLY - [5:0] */
2313#define ARIZONA_IN2_DMICR_DLY_SHIFT 0 /* IN2_DMICR_DLY - [5:0] */
2314#define ARIZONA_IN2_DMICR_DLY_WIDTH 6 /* IN2_DMICR_DLY - [5:0] */
2315
2316/*
2317 * R800 (0x320) - IN3L Control
2318 */
2319#define ARIZONA_IN3_OSR_MASK 0x6000 /* IN3_OSR - [14:13] */
2320#define ARIZONA_IN3_OSR_SHIFT 13 /* IN3_OSR - [14:13] */
2321#define ARIZONA_IN3_OSR_WIDTH 2 /* IN3_OSR - [14:13] */
2322#define ARIZONA_IN3_DMIC_SUP_MASK 0x1800 /* IN3_DMIC_SUP - [12:11] */
2323#define ARIZONA_IN3_DMIC_SUP_SHIFT 11 /* IN3_DMIC_SUP - [12:11] */
2324#define ARIZONA_IN3_DMIC_SUP_WIDTH 2 /* IN3_DMIC_SUP - [12:11] */
2325#define ARIZONA_IN3_MODE_MASK 0x0600 /* IN3_MODE - [10:9] */
2326#define ARIZONA_IN3_MODE_SHIFT 9 /* IN3_MODE - [10:9] */
2327#define ARIZONA_IN3_MODE_WIDTH 2 /* IN3_MODE - [10:9] */
2328#define ARIZONA_IN3L_PGA_VOL_MASK 0x00FE /* IN3L_PGA_VOL - [7:1] */
2329#define ARIZONA_IN3L_PGA_VOL_SHIFT 1 /* IN3L_PGA_VOL - [7:1] */
2330#define ARIZONA_IN3L_PGA_VOL_WIDTH 7 /* IN3L_PGA_VOL - [7:1] */
2331
2332/*
2333 * R801 (0x321) - ADC Digital Volume 3L
2334 */
2335#define ARIZONA_IN_VU 0x0200 /* IN_VU */
2336#define ARIZONA_IN_VU_MASK 0x0200 /* IN_VU */
2337#define ARIZONA_IN_VU_SHIFT 9 /* IN_VU */
2338#define ARIZONA_IN_VU_WIDTH 1 /* IN_VU */
2339#define ARIZONA_IN3L_MUTE 0x0100 /* IN3L_MUTE */
2340#define ARIZONA_IN3L_MUTE_MASK 0x0100 /* IN3L_MUTE */
2341#define ARIZONA_IN3L_MUTE_SHIFT 8 /* IN3L_MUTE */
2342#define ARIZONA_IN3L_MUTE_WIDTH 1 /* IN3L_MUTE */
2343#define ARIZONA_IN3L_DIG_VOL_MASK 0x00FF /* IN3L_DIG_VOL - [7:0] */
2344#define ARIZONA_IN3L_DIG_VOL_SHIFT 0 /* IN3L_DIG_VOL - [7:0] */
2345#define ARIZONA_IN3L_DIG_VOL_WIDTH 8 /* IN3L_DIG_VOL - [7:0] */
2346
2347/*
2348 * R802 (0x322) - DMIC3L Control
2349 */
2350#define ARIZONA_IN3_DMICL_DLY_MASK 0x003F /* IN3_DMICL_DLY - [5:0] */
2351#define ARIZONA_IN3_DMICL_DLY_SHIFT 0 /* IN3_DMICL_DLY - [5:0] */
2352#define ARIZONA_IN3_DMICL_DLY_WIDTH 6 /* IN3_DMICL_DLY - [5:0] */
2353
2354/*
2355 * R804 (0x324) - IN3R Control
2356 */
2357#define ARIZONA_IN3R_PGA_VOL_MASK 0x00FE /* IN3R_PGA_VOL - [7:1] */
2358#define ARIZONA_IN3R_PGA_VOL_SHIFT 1 /* IN3R_PGA_VOL - [7:1] */
2359#define ARIZONA_IN3R_PGA_VOL_WIDTH 7 /* IN3R_PGA_VOL - [7:1] */
2360
2361/*
2362 * R805 (0x325) - ADC Digital Volume 3R
2363 */
2364#define ARIZONA_IN_VU 0x0200 /* IN_VU */
2365#define ARIZONA_IN_VU_MASK 0x0200 /* IN_VU */
2366#define ARIZONA_IN_VU_SHIFT 9 /* IN_VU */
2367#define ARIZONA_IN_VU_WIDTH 1 /* IN_VU */
2368#define ARIZONA_IN3R_MUTE 0x0100 /* IN3R_MUTE */
2369#define ARIZONA_IN3R_MUTE_MASK 0x0100 /* IN3R_MUTE */
2370#define ARIZONA_IN3R_MUTE_SHIFT 8 /* IN3R_MUTE */
2371#define ARIZONA_IN3R_MUTE_WIDTH 1 /* IN3R_MUTE */
2372#define ARIZONA_IN3R_DIG_VOL_MASK 0x00FF /* IN3R_DIG_VOL - [7:0] */
2373#define ARIZONA_IN3R_DIG_VOL_SHIFT 0 /* IN3R_DIG_VOL - [7:0] */
2374#define ARIZONA_IN3R_DIG_VOL_WIDTH 8 /* IN3R_DIG_VOL - [7:0] */
2375
2376/*
2377 * R806 (0x326) - DMIC3R Control
2378 */
2379#define ARIZONA_IN3_DMICR_DLY_MASK 0x003F /* IN3_DMICR_DLY - [5:0] */
2380#define ARIZONA_IN3_DMICR_DLY_SHIFT 0 /* IN3_DMICR_DLY - [5:0] */
2381#define ARIZONA_IN3_DMICR_DLY_WIDTH 6 /* IN3_DMICR_DLY - [5:0] */
2382
2383/*
2384 * R808 (0x328) - IN4 Control
2385 */
2386#define ARIZONA_IN4_OSR_MASK 0x6000 /* IN4_OSR - [14:13] */
2387#define ARIZONA_IN4_OSR_SHIFT 13 /* IN4_OSR - [14:13] */
2388#define ARIZONA_IN4_OSR_WIDTH 2 /* IN4_OSR - [14:13] */
2389#define ARIZONA_IN4_DMIC_SUP_MASK 0x1800 /* IN4_DMIC_SUP - [12:11] */
2390#define ARIZONA_IN4_DMIC_SUP_SHIFT 11 /* IN4_DMIC_SUP - [12:11] */
2391#define ARIZONA_IN4_DMIC_SUP_WIDTH 2 /* IN4_DMIC_SUP - [12:11] */
2392
2393/*
2394 * R809 (0x329) - ADC Digital Volume 4L
2395 */
2396#define ARIZONA_IN_VU 0x0200 /* IN_VU */
2397#define ARIZONA_IN_VU_MASK 0x0200 /* IN_VU */
2398#define ARIZONA_IN_VU_SHIFT 9 /* IN_VU */
2399#define ARIZONA_IN_VU_WIDTH 1 /* IN_VU */
2400#define ARIZONA_IN4L_MUTE 0x0100 /* IN4L_MUTE */
2401#define ARIZONA_IN4L_MUTE_MASK 0x0100 /* IN4L_MUTE */
2402#define ARIZONA_IN4L_MUTE_SHIFT 8 /* IN4L_MUTE */
2403#define ARIZONA_IN4L_MUTE_WIDTH 1 /* IN4L_MUTE */
2404#define ARIZONA_IN4L_DIG_VOL_MASK 0x00FF /* IN4L_DIG_VOL - [7:0] */
2405#define ARIZONA_IN4L_DIG_VOL_SHIFT 0 /* IN4L_DIG_VOL - [7:0] */
2406#define ARIZONA_IN4L_DIG_VOL_WIDTH 8 /* IN4L_DIG_VOL - [7:0] */
2407
2408/*
2409 * R810 (0x32A) - DMIC4L Control
2410 */
2411#define ARIZONA_IN4L_DMIC_DLY_MASK 0x003F /* IN4L_DMIC_DLY - [5:0] */
2412#define ARIZONA_IN4L_DMIC_DLY_SHIFT 0 /* IN4L_DMIC_DLY - [5:0] */
2413#define ARIZONA_IN4L_DMIC_DLY_WIDTH 6 /* IN4L_DMIC_DLY - [5:0] */
2414
2415/*
2416 * R813 (0x32D) - ADC Digital Volume 4R
2417 */
2418#define ARIZONA_IN_VU 0x0200 /* IN_VU */
2419#define ARIZONA_IN_VU_MASK 0x0200 /* IN_VU */
2420#define ARIZONA_IN_VU_SHIFT 9 /* IN_VU */
2421#define ARIZONA_IN_VU_WIDTH 1 /* IN_VU */
2422#define ARIZONA_IN4R_MUTE 0x0100 /* IN4R_MUTE */
2423#define ARIZONA_IN4R_MUTE_MASK 0x0100 /* IN4R_MUTE */
2424#define ARIZONA_IN4R_MUTE_SHIFT 8 /* IN4R_MUTE */
2425#define ARIZONA_IN4R_MUTE_WIDTH 1 /* IN4R_MUTE */
2426#define ARIZONA_IN4R_DIG_VOL_MASK 0x00FF /* IN4R_DIG_VOL - [7:0] */
2427#define ARIZONA_IN4R_DIG_VOL_SHIFT 0 /* IN4R_DIG_VOL - [7:0] */
2428#define ARIZONA_IN4R_DIG_VOL_WIDTH 8 /* IN4R_DIG_VOL - [7:0] */
2429
2430/*
2431 * R814 (0x32E) - DMIC4R Control
2432 */
2433#define ARIZONA_IN4R_DMIC_DLY_MASK 0x003F /* IN4R_DMIC_DLY - [5:0] */
2434#define ARIZONA_IN4R_DMIC_DLY_SHIFT 0 /* IN4R_DMIC_DLY - [5:0] */
2435#define ARIZONA_IN4R_DMIC_DLY_WIDTH 6 /* IN4R_DMIC_DLY - [5:0] */
2436
2437/*
2438 * R1024 (0x400) - Output Enables 1
2439 */
2440#define ARIZONA_OUT6L_ENA 0x0800 /* OUT6L_ENA */
2441#define ARIZONA_OUT6L_ENA_MASK 0x0800 /* OUT6L_ENA */
2442#define ARIZONA_OUT6L_ENA_SHIFT 11 /* OUT6L_ENA */
2443#define ARIZONA_OUT6L_ENA_WIDTH 1 /* OUT6L_ENA */
2444#define ARIZONA_OUT6R_ENA 0x0400 /* OUT6R_ENA */
2445#define ARIZONA_OUT6R_ENA_MASK 0x0400 /* OUT6R_ENA */
2446#define ARIZONA_OUT6R_ENA_SHIFT 10 /* OUT6R_ENA */
2447#define ARIZONA_OUT6R_ENA_WIDTH 1 /* OUT6R_ENA */
2448#define ARIZONA_OUT5L_ENA 0x0200 /* OUT5L_ENA */
2449#define ARIZONA_OUT5L_ENA_MASK 0x0200 /* OUT5L_ENA */
2450#define ARIZONA_OUT5L_ENA_SHIFT 9 /* OUT5L_ENA */
2451#define ARIZONA_OUT5L_ENA_WIDTH 1 /* OUT5L_ENA */
2452#define ARIZONA_OUT5R_ENA 0x0100 /* OUT5R_ENA */
2453#define ARIZONA_OUT5R_ENA_MASK 0x0100 /* OUT5R_ENA */
2454#define ARIZONA_OUT5R_ENA_SHIFT 8 /* OUT5R_ENA */
2455#define ARIZONA_OUT5R_ENA_WIDTH 1 /* OUT5R_ENA */
2456#define ARIZONA_OUT4L_ENA 0x0080 /* OUT4L_ENA */
2457#define ARIZONA_OUT4L_ENA_MASK 0x0080 /* OUT4L_ENA */
2458#define ARIZONA_OUT4L_ENA_SHIFT 7 /* OUT4L_ENA */
2459#define ARIZONA_OUT4L_ENA_WIDTH 1 /* OUT4L_ENA */
2460#define ARIZONA_OUT4R_ENA 0x0040 /* OUT4R_ENA */
2461#define ARIZONA_OUT4R_ENA_MASK 0x0040 /* OUT4R_ENA */
2462#define ARIZONA_OUT4R_ENA_SHIFT 6 /* OUT4R_ENA */
2463#define ARIZONA_OUT4R_ENA_WIDTH 1 /* OUT4R_ENA */
2464#define ARIZONA_OUT3L_ENA 0x0020 /* OUT3L_ENA */
2465#define ARIZONA_OUT3L_ENA_MASK 0x0020 /* OUT3L_ENA */
2466#define ARIZONA_OUT3L_ENA_SHIFT 5 /* OUT3L_ENA */
2467#define ARIZONA_OUT3L_ENA_WIDTH 1 /* OUT3L_ENA */
2468#define ARIZONA_OUT3R_ENA 0x0010 /* OUT3R_ENA */
2469#define ARIZONA_OUT3R_ENA_MASK 0x0010 /* OUT3R_ENA */
2470#define ARIZONA_OUT3R_ENA_SHIFT 4 /* OUT3R_ENA */
2471#define ARIZONA_OUT3R_ENA_WIDTH 1 /* OUT3R_ENA */
2472#define ARIZONA_OUT2L_ENA 0x0008 /* OUT2L_ENA */
2473#define ARIZONA_OUT2L_ENA_MASK 0x0008 /* OUT2L_ENA */
2474#define ARIZONA_OUT2L_ENA_SHIFT 3 /* OUT2L_ENA */
2475#define ARIZONA_OUT2L_ENA_WIDTH 1 /* OUT2L_ENA */
2476#define ARIZONA_OUT2R_ENA 0x0004 /* OUT2R_ENA */
2477#define ARIZONA_OUT2R_ENA_MASK 0x0004 /* OUT2R_ENA */
2478#define ARIZONA_OUT2R_ENA_SHIFT 2 /* OUT2R_ENA */
2479#define ARIZONA_OUT2R_ENA_WIDTH 1 /* OUT2R_ENA */
2480#define ARIZONA_OUT1L_ENA 0x0002 /* OUT1L_ENA */
2481#define ARIZONA_OUT1L_ENA_MASK 0x0002 /* OUT1L_ENA */
2482#define ARIZONA_OUT1L_ENA_SHIFT 1 /* OUT1L_ENA */
2483#define ARIZONA_OUT1L_ENA_WIDTH 1 /* OUT1L_ENA */
2484#define ARIZONA_OUT1R_ENA 0x0001 /* OUT1R_ENA */
2485#define ARIZONA_OUT1R_ENA_MASK 0x0001 /* OUT1R_ENA */
2486#define ARIZONA_OUT1R_ENA_SHIFT 0 /* OUT1R_ENA */
2487#define ARIZONA_OUT1R_ENA_WIDTH 1 /* OUT1R_ENA */
2488
2489/*
2490 * R1025 (0x401) - Output Status 1
2491 */
2492#define ARIZONA_OUT6L_ENA_STS 0x0800 /* OUT6L_ENA_STS */
2493#define ARIZONA_OUT6L_ENA_STS_MASK 0x0800 /* OUT6L_ENA_STS */
2494#define ARIZONA_OUT6L_ENA_STS_SHIFT 11 /* OUT6L_ENA_STS */
2495#define ARIZONA_OUT6L_ENA_STS_WIDTH 1 /* OUT6L_ENA_STS */
2496#define ARIZONA_OUT6R_ENA_STS 0x0400 /* OUT6R_ENA_STS */
2497#define ARIZONA_OUT6R_ENA_STS_MASK 0x0400 /* OUT6R_ENA_STS */
2498#define ARIZONA_OUT6R_ENA_STS_SHIFT 10 /* OUT6R_ENA_STS */
2499#define ARIZONA_OUT6R_ENA_STS_WIDTH 1 /* OUT6R_ENA_STS */
2500#define ARIZONA_OUT5L_ENA_STS 0x0200 /* OUT5L_ENA_STS */
2501#define ARIZONA_OUT5L_ENA_STS_MASK 0x0200 /* OUT5L_ENA_STS */
2502#define ARIZONA_OUT5L_ENA_STS_SHIFT 9 /* OUT5L_ENA_STS */
2503#define ARIZONA_OUT5L_ENA_STS_WIDTH 1 /* OUT5L_ENA_STS */
2504#define ARIZONA_OUT5R_ENA_STS 0x0100 /* OUT5R_ENA_STS */
2505#define ARIZONA_OUT5R_ENA_STS_MASK 0x0100 /* OUT5R_ENA_STS */
2506#define ARIZONA_OUT5R_ENA_STS_SHIFT 8 /* OUT5R_ENA_STS */
2507#define ARIZONA_OUT5R_ENA_STS_WIDTH 1 /* OUT5R_ENA_STS */
2508#define ARIZONA_OUT4L_ENA_STS 0x0080 /* OUT4L_ENA_STS */
2509#define ARIZONA_OUT4L_ENA_STS_MASK 0x0080 /* OUT4L_ENA_STS */
2510#define ARIZONA_OUT4L_ENA_STS_SHIFT 7 /* OUT4L_ENA_STS */
2511#define ARIZONA_OUT4L_ENA_STS_WIDTH 1 /* OUT4L_ENA_STS */
2512#define ARIZONA_OUT4R_ENA_STS 0x0040 /* OUT4R_ENA_STS */
2513#define ARIZONA_OUT4R_ENA_STS_MASK 0x0040 /* OUT4R_ENA_STS */
2514#define ARIZONA_OUT4R_ENA_STS_SHIFT 6 /* OUT4R_ENA_STS */
2515#define ARIZONA_OUT4R_ENA_STS_WIDTH 1 /* OUT4R_ENA_STS */
2516
2517/*
2518 * R1032 (0x408) - Output Rate 1
2519 */
2520#define ARIZONA_OUT_RATE_MASK 0x7800 /* OUT_RATE - [14:11] */
2521#define ARIZONA_OUT_RATE_SHIFT 11 /* OUT_RATE - [14:11] */
2522#define ARIZONA_OUT_RATE_WIDTH 4 /* OUT_RATE - [14:11] */
2523
2524/*
2525 * R1033 (0x409) - Output Volume Ramp
2526 */
2527#define ARIZONA_OUT_VD_RAMP_MASK 0x0070 /* OUT_VD_RAMP - [6:4] */
2528#define ARIZONA_OUT_VD_RAMP_SHIFT 4 /* OUT_VD_RAMP - [6:4] */
2529#define ARIZONA_OUT_VD_RAMP_WIDTH 3 /* OUT_VD_RAMP - [6:4] */
2530#define ARIZONA_OUT_VI_RAMP_MASK 0x0007 /* OUT_VI_RAMP - [2:0] */
2531#define ARIZONA_OUT_VI_RAMP_SHIFT 0 /* OUT_VI_RAMP - [2:0] */
2532#define ARIZONA_OUT_VI_RAMP_WIDTH 3 /* OUT_VI_RAMP - [2:0] */
2533
2534/*
2535 * R1040 (0x410) - Output Path Config 1L
2536 */
2537#define ARIZONA_OUT1_LP_MODE 0x8000 /* OUT1_LP_MODE */
2538#define ARIZONA_OUT1_LP_MODE_MASK 0x8000 /* OUT1_LP_MODE */
2539#define ARIZONA_OUT1_LP_MODE_SHIFT 15 /* OUT1_LP_MODE */
2540#define ARIZONA_OUT1_LP_MODE_WIDTH 1 /* OUT1_LP_MODE */
2541#define ARIZONA_OUT1_OSR 0x2000 /* OUT1_OSR */
2542#define ARIZONA_OUT1_OSR_MASK 0x2000 /* OUT1_OSR */
2543#define ARIZONA_OUT1_OSR_SHIFT 13 /* OUT1_OSR */
2544#define ARIZONA_OUT1_OSR_WIDTH 1 /* OUT1_OSR */
2545#define ARIZONA_OUT1_MONO 0x1000 /* OUT1_MONO */
2546#define ARIZONA_OUT1_MONO_MASK 0x1000 /* OUT1_MONO */
2547#define ARIZONA_OUT1_MONO_SHIFT 12 /* OUT1_MONO */
2548#define ARIZONA_OUT1_MONO_WIDTH 1 /* OUT1_MONO */
2549#define ARIZONA_OUT1L_ANC_SRC_MASK 0x0C00 /* OUT1L_ANC_SRC - [11:10] */
2550#define ARIZONA_OUT1L_ANC_SRC_SHIFT 10 /* OUT1L_ANC_SRC - [11:10] */
2551#define ARIZONA_OUT1L_ANC_SRC_WIDTH 2 /* OUT1L_ANC_SRC - [11:10] */
2552#define ARIZONA_OUT1L_PGA_VOL_MASK 0x00FE /* OUT1L_PGA_VOL - [7:1] */
2553#define ARIZONA_OUT1L_PGA_VOL_SHIFT 1 /* OUT1L_PGA_VOL - [7:1] */
2554#define ARIZONA_OUT1L_PGA_VOL_WIDTH 7 /* OUT1L_PGA_VOL - [7:1] */
2555
2556/*
2557 * R1041 (0x411) - DAC Digital Volume 1L
2558 */
2559#define ARIZONA_OUT_VU 0x0200 /* OUT_VU */
2560#define ARIZONA_OUT_VU_MASK 0x0200 /* OUT_VU */
2561#define ARIZONA_OUT_VU_SHIFT 9 /* OUT_VU */
2562#define ARIZONA_OUT_VU_WIDTH 1 /* OUT_VU */
2563#define ARIZONA_OUT1L_MUTE 0x0100 /* OUT1L_MUTE */
2564#define ARIZONA_OUT1L_MUTE_MASK 0x0100 /* OUT1L_MUTE */
2565#define ARIZONA_OUT1L_MUTE_SHIFT 8 /* OUT1L_MUTE */
2566#define ARIZONA_OUT1L_MUTE_WIDTH 1 /* OUT1L_MUTE */
2567#define ARIZONA_OUT1L_VOL_MASK 0x00FF /* OUT1L_VOL - [7:0] */
2568#define ARIZONA_OUT1L_VOL_SHIFT 0 /* OUT1L_VOL - [7:0] */
2569#define ARIZONA_OUT1L_VOL_WIDTH 8 /* OUT1L_VOL - [7:0] */
2570
2571/*
2572 * R1042 (0x412) - DAC Volume Limit 1L
2573 */
2574#define ARIZONA_OUT1L_VOL_LIM_MASK 0x00FF /* OUT1L_VOL_LIM - [7:0] */
2575#define ARIZONA_OUT1L_VOL_LIM_SHIFT 0 /* OUT1L_VOL_LIM - [7:0] */
2576#define ARIZONA_OUT1L_VOL_LIM_WIDTH 8 /* OUT1L_VOL_LIM - [7:0] */
2577
2578/*
2579 * R1043 (0x413) - Noise Gate Select 1L
2580 */
2581#define ARIZONA_OUT1L_NGATE_SRC_MASK 0x0FFF /* OUT1L_NGATE_SRC - [11:0] */
2582#define ARIZONA_OUT1L_NGATE_SRC_SHIFT 0 /* OUT1L_NGATE_SRC - [11:0] */
2583#define ARIZONA_OUT1L_NGATE_SRC_WIDTH 12 /* OUT1L_NGATE_SRC - [11:0] */
2584
2585/*
2586 * R1044 (0x414) - Output Path Config 1R
2587 */
2588#define ARIZONA_OUT1R_ANC_SRC_MASK 0x0C00 /* OUT1R_ANC_SRC - [11:10] */
2589#define ARIZONA_OUT1R_ANC_SRC_SHIFT 10 /* OUT1R_ANC_SRC - [11:10] */
2590#define ARIZONA_OUT1R_ANC_SRC_WIDTH 2 /* OUT1R_ANC_SRC - [11:10] */
2591#define ARIZONA_OUT1R_PGA_VOL_MASK 0x00FE /* OUT1R_PGA_VOL - [7:1] */
2592#define ARIZONA_OUT1R_PGA_VOL_SHIFT 1 /* OUT1R_PGA_VOL - [7:1] */
2593#define ARIZONA_OUT1R_PGA_VOL_WIDTH 7 /* OUT1R_PGA_VOL - [7:1] */
2594
2595/*
2596 * R1045 (0x415) - DAC Digital Volume 1R
2597 */
2598#define ARIZONA_OUT_VU 0x0200 /* OUT_VU */
2599#define ARIZONA_OUT_VU_MASK 0x0200 /* OUT_VU */
2600#define ARIZONA_OUT_VU_SHIFT 9 /* OUT_VU */
2601#define ARIZONA_OUT_VU_WIDTH 1 /* OUT_VU */
2602#define ARIZONA_OUT1R_MUTE 0x0100 /* OUT1R_MUTE */
2603#define ARIZONA_OUT1R_MUTE_MASK 0x0100 /* OUT1R_MUTE */
2604#define ARIZONA_OUT1R_MUTE_SHIFT 8 /* OUT1R_MUTE */
2605#define ARIZONA_OUT1R_MUTE_WIDTH 1 /* OUT1R_MUTE */
2606#define ARIZONA_OUT1R_VOL_MASK 0x00FF /* OUT1R_VOL - [7:0] */
2607#define ARIZONA_OUT1R_VOL_SHIFT 0 /* OUT1R_VOL - [7:0] */
2608#define ARIZONA_OUT1R_VOL_WIDTH 8 /* OUT1R_VOL - [7:0] */
2609
2610/*
2611 * R1046 (0x416) - DAC Volume Limit 1R
2612 */
2613#define ARIZONA_OUT1R_VOL_LIM_MASK 0x00FF /* OUT1R_VOL_LIM - [7:0] */
2614#define ARIZONA_OUT1R_VOL_LIM_SHIFT 0 /* OUT1R_VOL_LIM - [7:0] */
2615#define ARIZONA_OUT1R_VOL_LIM_WIDTH 8 /* OUT1R_VOL_LIM - [7:0] */
2616
2617/*
2618 * R1047 (0x417) - Noise Gate Select 1R
2619 */
2620#define ARIZONA_OUT1R_NGATE_SRC_MASK 0x0FFF /* OUT1R_NGATE_SRC - [11:0] */
2621#define ARIZONA_OUT1R_NGATE_SRC_SHIFT 0 /* OUT1R_NGATE_SRC - [11:0] */
2622#define ARIZONA_OUT1R_NGATE_SRC_WIDTH 12 /* OUT1R_NGATE_SRC - [11:0] */
2623
2624/*
2625 * R1048 (0x418) - Output Path Config 2L
2626 */
2627#define ARIZONA_OUT2_LP_MODE 0x8000 /* OUT2_LP_MODE */
2628#define ARIZONA_OUT2_LP_MODE_MASK 0x8000 /* OUT2_LP_MODE */
2629#define ARIZONA_OUT2_LP_MODE_SHIFT 15 /* OUT2_LP_MODE */
2630#define ARIZONA_OUT2_LP_MODE_WIDTH 1 /* OUT2_LP_MODE */
2631#define ARIZONA_OUT2_OSR 0x2000 /* OUT2_OSR */
2632#define ARIZONA_OUT2_OSR_MASK 0x2000 /* OUT2_OSR */
2633#define ARIZONA_OUT2_OSR_SHIFT 13 /* OUT2_OSR */
2634#define ARIZONA_OUT2_OSR_WIDTH 1 /* OUT2_OSR */
2635#define ARIZONA_OUT2_MONO 0x1000 /* OUT2_MONO */
2636#define ARIZONA_OUT2_MONO_MASK 0x1000 /* OUT2_MONO */
2637#define ARIZONA_OUT2_MONO_SHIFT 12 /* OUT2_MONO */
2638#define ARIZONA_OUT2_MONO_WIDTH 1 /* OUT2_MONO */
2639#define ARIZONA_OUT2L_ANC_SRC_MASK 0x0C00 /* OUT2L_ANC_SRC - [11:10] */
2640#define ARIZONA_OUT2L_ANC_SRC_SHIFT 10 /* OUT2L_ANC_SRC - [11:10] */
2641#define ARIZONA_OUT2L_ANC_SRC_WIDTH 2 /* OUT2L_ANC_SRC - [11:10] */
2642#define ARIZONA_OUT2L_PGA_VOL_MASK 0x00FE /* OUT2L_PGA_VOL - [7:1] */
2643#define ARIZONA_OUT2L_PGA_VOL_SHIFT 1 /* OUT2L_PGA_VOL - [7:1] */
2644#define ARIZONA_OUT2L_PGA_VOL_WIDTH 7 /* OUT2L_PGA_VOL - [7:1] */
2645
2646/*
2647 * R1049 (0x419) - DAC Digital Volume 2L
2648 */
2649#define ARIZONA_OUT_VU 0x0200 /* OUT_VU */
2650#define ARIZONA_OUT_VU_MASK 0x0200 /* OUT_VU */
2651#define ARIZONA_OUT_VU_SHIFT 9 /* OUT_VU */
2652#define ARIZONA_OUT_VU_WIDTH 1 /* OUT_VU */
2653#define ARIZONA_OUT2L_MUTE 0x0100 /* OUT2L_MUTE */
2654#define ARIZONA_OUT2L_MUTE_MASK 0x0100 /* OUT2L_MUTE */
2655#define ARIZONA_OUT2L_MUTE_SHIFT 8 /* OUT2L_MUTE */
2656#define ARIZONA_OUT2L_MUTE_WIDTH 1 /* OUT2L_MUTE */
2657#define ARIZONA_OUT2L_VOL_MASK 0x00FF /* OUT2L_VOL - [7:0] */
2658#define ARIZONA_OUT2L_VOL_SHIFT 0 /* OUT2L_VOL - [7:0] */
2659#define ARIZONA_OUT2L_VOL_WIDTH 8 /* OUT2L_VOL - [7:0] */
2660
2661/*
2662 * R1050 (0x41A) - DAC Volume Limit 2L
2663 */
2664#define ARIZONA_OUT2L_VOL_LIM_MASK 0x00FF /* OUT2L_VOL_LIM - [7:0] */
2665#define ARIZONA_OUT2L_VOL_LIM_SHIFT 0 /* OUT2L_VOL_LIM - [7:0] */
2666#define ARIZONA_OUT2L_VOL_LIM_WIDTH 8 /* OUT2L_VOL_LIM - [7:0] */
2667
2668/*
2669 * R1051 (0x41B) - Noise Gate Select 2L
2670 */
2671#define ARIZONA_OUT2L_NGATE_SRC_MASK 0x0FFF /* OUT2L_NGATE_SRC - [11:0] */
2672#define ARIZONA_OUT2L_NGATE_SRC_SHIFT 0 /* OUT2L_NGATE_SRC - [11:0] */
2673#define ARIZONA_OUT2L_NGATE_SRC_WIDTH 12 /* OUT2L_NGATE_SRC - [11:0] */
2674
2675/*
2676 * R1052 (0x41C) - Output Path Config 2R
2677 */
2678#define ARIZONA_OUT2R_ANC_SRC_MASK 0x0C00 /* OUT2R_ANC_SRC - [11:10] */
2679#define ARIZONA_OUT2R_ANC_SRC_SHIFT 10 /* OUT2R_ANC_SRC - [11:10] */
2680#define ARIZONA_OUT2R_ANC_SRC_WIDTH 2 /* OUT2R_ANC_SRC - [11:10] */
2681#define ARIZONA_OUT2R_PGA_VOL_MASK 0x00FE /* OUT2R_PGA_VOL - [7:1] */
2682#define ARIZONA_OUT2R_PGA_VOL_SHIFT 1 /* OUT2R_PGA_VOL - [7:1] */
2683#define ARIZONA_OUT2R_PGA_VOL_WIDTH 7 /* OUT2R_PGA_VOL - [7:1] */
2684
2685/*
2686 * R1053 (0x41D) - DAC Digital Volume 2R
2687 */
2688#define ARIZONA_OUT_VU 0x0200 /* OUT_VU */
2689#define ARIZONA_OUT_VU_MASK 0x0200 /* OUT_VU */
2690#define ARIZONA_OUT_VU_SHIFT 9 /* OUT_VU */
2691#define ARIZONA_OUT_VU_WIDTH 1 /* OUT_VU */
2692#define ARIZONA_OUT2R_MUTE 0x0100 /* OUT2R_MUTE */
2693#define ARIZONA_OUT2R_MUTE_MASK 0x0100 /* OUT2R_MUTE */
2694#define ARIZONA_OUT2R_MUTE_SHIFT 8 /* OUT2R_MUTE */
2695#define ARIZONA_OUT2R_MUTE_WIDTH 1 /* OUT2R_MUTE */
2696#define ARIZONA_OUT2R_VOL_MASK 0x00FF /* OUT2R_VOL - [7:0] */
2697#define ARIZONA_OUT2R_VOL_SHIFT 0 /* OUT2R_VOL - [7:0] */
2698#define ARIZONA_OUT2R_VOL_WIDTH 8 /* OUT2R_VOL - [7:0] */
2699
2700/*
2701 * R1054 (0x41E) - DAC Volume Limit 2R
2702 */
2703#define ARIZONA_OUT2R_VOL_LIM_MASK 0x00FF /* OUT2R_VOL_LIM - [7:0] */
2704#define ARIZONA_OUT2R_VOL_LIM_SHIFT 0 /* OUT2R_VOL_LIM - [7:0] */
2705#define ARIZONA_OUT2R_VOL_LIM_WIDTH 8 /* OUT2R_VOL_LIM - [7:0] */
2706
2707/*
2708 * R1055 (0x41F) - Noise Gate Select 2R
2709 */
2710#define ARIZONA_OUT2R_NGATE_SRC_MASK 0x0FFF /* OUT2R_NGATE_SRC - [11:0] */
2711#define ARIZONA_OUT2R_NGATE_SRC_SHIFT 0 /* OUT2R_NGATE_SRC - [11:0] */
2712#define ARIZONA_OUT2R_NGATE_SRC_WIDTH 12 /* OUT2R_NGATE_SRC - [11:0] */
2713
2714/*
2715 * R1056 (0x420) - Output Path Config 3L
2716 */
2717#define ARIZONA_OUT3_LP_MODE 0x8000 /* OUT3_LP_MODE */
2718#define ARIZONA_OUT3_LP_MODE_MASK 0x8000 /* OUT3_LP_MODE */
2719#define ARIZONA_OUT3_LP_MODE_SHIFT 15 /* OUT3_LP_MODE */
2720#define ARIZONA_OUT3_LP_MODE_WIDTH 1 /* OUT3_LP_MODE */
2721#define ARIZONA_OUT3_OSR 0x2000 /* OUT3_OSR */
2722#define ARIZONA_OUT3_OSR_MASK 0x2000 /* OUT3_OSR */
2723#define ARIZONA_OUT3_OSR_SHIFT 13 /* OUT3_OSR */
2724#define ARIZONA_OUT3_OSR_WIDTH 1 /* OUT3_OSR */
2725#define ARIZONA_OUT3_MONO 0x1000 /* OUT3_MONO */
2726#define ARIZONA_OUT3_MONO_MASK 0x1000 /* OUT3_MONO */
2727#define ARIZONA_OUT3_MONO_SHIFT 12 /* OUT3_MONO */
2728#define ARIZONA_OUT3_MONO_WIDTH 1 /* OUT3_MONO */
2729#define ARIZONA_OUT3L_ANC_SRC_MASK 0x0C00 /* OUT3L_ANC_SRC - [11:10] */
2730#define ARIZONA_OUT3L_ANC_SRC_SHIFT 10 /* OUT3L_ANC_SRC - [11:10] */
2731#define ARIZONA_OUT3L_ANC_SRC_WIDTH 2 /* OUT3L_ANC_SRC - [11:10] */
2732#define ARIZONA_OUT3L_PGA_VOL_MASK 0x00FE /* OUT3L_PGA_VOL - [7:1] */
2733#define ARIZONA_OUT3L_PGA_VOL_SHIFT 1 /* OUT3L_PGA_VOL - [7:1] */
2734#define ARIZONA_OUT3L_PGA_VOL_WIDTH 7 /* OUT3L_PGA_VOL - [7:1] */
2735
2736/*
2737 * R1057 (0x421) - DAC Digital Volume 3L
2738 */
2739#define ARIZONA_OUT_VU 0x0200 /* OUT_VU */
2740#define ARIZONA_OUT_VU_MASK 0x0200 /* OUT_VU */
2741#define ARIZONA_OUT_VU_SHIFT 9 /* OUT_VU */
2742#define ARIZONA_OUT_VU_WIDTH 1 /* OUT_VU */
2743#define ARIZONA_OUT3L_MUTE 0x0100 /* OUT3L_MUTE */
2744#define ARIZONA_OUT3L_MUTE_MASK 0x0100 /* OUT3L_MUTE */
2745#define ARIZONA_OUT3L_MUTE_SHIFT 8 /* OUT3L_MUTE */
2746#define ARIZONA_OUT3L_MUTE_WIDTH 1 /* OUT3L_MUTE */
2747#define ARIZONA_OUT3L_VOL_MASK 0x00FF /* OUT3L_VOL - [7:0] */
2748#define ARIZONA_OUT3L_VOL_SHIFT 0 /* OUT3L_VOL - [7:0] */
2749#define ARIZONA_OUT3L_VOL_WIDTH 8 /* OUT3L_VOL - [7:0] */
2750
2751/*
2752 * R1058 (0x422) - DAC Volume Limit 3L
2753 */
2754#define ARIZONA_OUT3L_VOL_LIM_MASK 0x00FF /* OUT3L_VOL_LIM - [7:0] */
2755#define ARIZONA_OUT3L_VOL_LIM_SHIFT 0 /* OUT3L_VOL_LIM - [7:0] */
2756#define ARIZONA_OUT3L_VOL_LIM_WIDTH 8 /* OUT3L_VOL_LIM - [7:0] */
2757
2758/*
2759 * R1059 (0x423) - Noise Gate Select 3L
2760 */
2761#define ARIZONA_OUT3_NGATE_SRC_MASK 0x0FFF /* OUT3_NGATE_SRC - [11:0] */
2762#define ARIZONA_OUT3_NGATE_SRC_SHIFT 0 /* OUT3_NGATE_SRC - [11:0] */
2763#define ARIZONA_OUT3_NGATE_SRC_WIDTH 12 /* OUT3_NGATE_SRC - [11:0] */
2764
2765/*
2766 * R1060 (0x424) - Output Path Config 3R
2767 */
2768#define ARIZONA_OUT3R_PGA_VOL_MASK 0x00FE /* OUT3R_PGA_VOL - [7:1] */
2769#define ARIZONA_OUT3R_PGA_VOL_SHIFT 1 /* OUT3R_PGA_VOL - [7:1] */
2770#define ARIZONA_OUT3R_PGA_VOL_WIDTH 7 /* OUT3R_PGA_VOL - [7:1] */
2771
2772/*
2773 * R1061 (0x425) - DAC Digital Volume 3R
2774 */
2775#define ARIZONA_OUT_VU 0x0200 /* OUT_VU */
2776#define ARIZONA_OUT_VU_MASK 0x0200 /* OUT_VU */
2777#define ARIZONA_OUT_VU_SHIFT 9 /* OUT_VU */
2778#define ARIZONA_OUT_VU_WIDTH 1 /* OUT_VU */
2779#define ARIZONA_OUT3R_MUTE 0x0100 /* OUT3R_MUTE */
2780#define ARIZONA_OUT3R_MUTE_MASK 0x0100 /* OUT3R_MUTE */
2781#define ARIZONA_OUT3R_MUTE_SHIFT 8 /* OUT3R_MUTE */
2782#define ARIZONA_OUT3R_MUTE_WIDTH 1 /* OUT3R_MUTE */
2783#define ARIZONA_OUT3R_VOL_MASK 0x00FF /* OUT3R_VOL - [7:0] */
2784#define ARIZONA_OUT3R_VOL_SHIFT 0 /* OUT3R_VOL - [7:0] */
2785#define ARIZONA_OUT3R_VOL_WIDTH 8 /* OUT3R_VOL - [7:0] */
2786
2787/*
2788 * R1062 (0x426) - DAC Volume Limit 3R
2789 */
2790#define ARIZONA_OUT3R_ANC_SRC_MASK 0x0C00 /* OUT3R_ANC_SRC - [11:10] */
2791#define ARIZONA_OUT3R_ANC_SRC_SHIFT 10 /* OUT3R_ANC_SRC - [11:10] */
2792#define ARIZONA_OUT3R_ANC_SRC_WIDTH 2 /* OUT3R_ANC_SRC - [11:10] */
2793#define ARIZONA_OUT3R_VOL_LIM_MASK 0x00FF /* OUT3R_VOL_LIM - [7:0] */
2794#define ARIZONA_OUT3R_VOL_LIM_SHIFT 0 /* OUT3R_VOL_LIM - [7:0] */
2795#define ARIZONA_OUT3R_VOL_LIM_WIDTH 8 /* OUT3R_VOL_LIM - [7:0] */
2796
2797/*
2798 * R1064 (0x428) - Output Path Config 4L
2799 */
2800#define ARIZONA_OUT4_OSR 0x2000 /* OUT4_OSR */
2801#define ARIZONA_OUT4_OSR_MASK 0x2000 /* OUT4_OSR */
2802#define ARIZONA_OUT4_OSR_SHIFT 13 /* OUT4_OSR */
2803#define ARIZONA_OUT4_OSR_WIDTH 1 /* OUT4_OSR */
2804#define ARIZONA_OUT4L_ANC_SRC_MASK 0x0C00 /* OUT4L_ANC_SRC - [11:10] */
2805#define ARIZONA_OUT4L_ANC_SRC_SHIFT 10 /* OUT4L_ANC_SRC - [11:10] */
2806#define ARIZONA_OUT4L_ANC_SRC_WIDTH 2 /* OUT4L_ANC_SRC - [11:10] */
2807
2808/*
2809 * R1065 (0x429) - DAC Digital Volume 4L
2810 */
2811#define ARIZONA_OUT_VU 0x0200 /* OUT_VU */
2812#define ARIZONA_OUT_VU_MASK 0x0200 /* OUT_VU */
2813#define ARIZONA_OUT_VU_SHIFT 9 /* OUT_VU */
2814#define ARIZONA_OUT_VU_WIDTH 1 /* OUT_VU */
2815#define ARIZONA_OUT4L_MUTE 0x0100 /* OUT4L_MUTE */
2816#define ARIZONA_OUT4L_MUTE_MASK 0x0100 /* OUT4L_MUTE */
2817#define ARIZONA_OUT4L_MUTE_SHIFT 8 /* OUT4L_MUTE */
2818#define ARIZONA_OUT4L_MUTE_WIDTH 1 /* OUT4L_MUTE */
2819#define ARIZONA_OUT4L_VOL_MASK 0x00FF /* OUT4L_VOL - [7:0] */
2820#define ARIZONA_OUT4L_VOL_SHIFT 0 /* OUT4L_VOL - [7:0] */
2821#define ARIZONA_OUT4L_VOL_WIDTH 8 /* OUT4L_VOL - [7:0] */
2822
2823/*
2824 * R1066 (0x42A) - Out Volume 4L
2825 */
2826#define ARIZONA_OUT4L_VOL_LIM_MASK 0x00FF /* OUT4L_VOL_LIM - [7:0] */
2827#define ARIZONA_OUT4L_VOL_LIM_SHIFT 0 /* OUT4L_VOL_LIM - [7:0] */
2828#define ARIZONA_OUT4L_VOL_LIM_WIDTH 8 /* OUT4L_VOL_LIM - [7:0] */
2829
2830/*
2831 * R1067 (0x42B) - Noise Gate Select 4L
2832 */
2833#define ARIZONA_OUT4L_NGATE_SRC_MASK 0x0FFF /* OUT4L_NGATE_SRC - [11:0] */
2834#define ARIZONA_OUT4L_NGATE_SRC_SHIFT 0 /* OUT4L_NGATE_SRC - [11:0] */
2835#define ARIZONA_OUT4L_NGATE_SRC_WIDTH 12 /* OUT4L_NGATE_SRC - [11:0] */
2836
2837/*
2838 * R1068 (0x42C) - Output Path Config 4R
2839 */
2840#define ARIZONA_OUT4R_ANC_SRC_MASK 0x0C00 /* OUT4R_ANC_SRC - [11:10] */
2841#define ARIZONA_OUT4R_ANC_SRC_SHIFT 10 /* OUT4R_ANC_SRC - [11:10] */
2842#define ARIZONA_OUT4R_ANC_SRC_WIDTH 2 /* OUT4R_ANC_SRC - [11:10] */
2843
2844/*
2845 * R1069 (0x42D) - DAC Digital Volume 4R
2846 */
2847#define ARIZONA_OUT_VU 0x0200 /* OUT_VU */
2848#define ARIZONA_OUT_VU_MASK 0x0200 /* OUT_VU */
2849#define ARIZONA_OUT_VU_SHIFT 9 /* OUT_VU */
2850#define ARIZONA_OUT_VU_WIDTH 1 /* OUT_VU */
2851#define ARIZONA_OUT4R_MUTE 0x0100 /* OUT4R_MUTE */
2852#define ARIZONA_OUT4R_MUTE_MASK 0x0100 /* OUT4R_MUTE */
2853#define ARIZONA_OUT4R_MUTE_SHIFT 8 /* OUT4R_MUTE */
2854#define ARIZONA_OUT4R_MUTE_WIDTH 1 /* OUT4R_MUTE */
2855#define ARIZONA_OUT4R_VOL_MASK 0x00FF /* OUT4R_VOL - [7:0] */
2856#define ARIZONA_OUT4R_VOL_SHIFT 0 /* OUT4R_VOL - [7:0] */
2857#define ARIZONA_OUT4R_VOL_WIDTH 8 /* OUT4R_VOL - [7:0] */
2858
2859/*
2860 * R1070 (0x42E) - Out Volume 4R
2861 */
2862#define ARIZONA_OUT4R_VOL_LIM_MASK 0x00FF /* OUT4R_VOL_LIM - [7:0] */
2863#define ARIZONA_OUT4R_VOL_LIM_SHIFT 0 /* OUT4R_VOL_LIM - [7:0] */
2864#define ARIZONA_OUT4R_VOL_LIM_WIDTH 8 /* OUT4R_VOL_LIM - [7:0] */
2865
2866/*
2867 * R1071 (0x42F) - Noise Gate Select 4R
2868 */
2869#define ARIZONA_OUT4R_NGATE_SRC_MASK 0x0FFF /* OUT4R_NGATE_SRC - [11:0] */
2870#define ARIZONA_OUT4R_NGATE_SRC_SHIFT 0 /* OUT4R_NGATE_SRC - [11:0] */
2871#define ARIZONA_OUT4R_NGATE_SRC_WIDTH 12 /* OUT4R_NGATE_SRC - [11:0] */
2872
2873/*
2874 * R1072 (0x430) - Output Path Config 5L
2875 */
2876#define ARIZONA_OUT5_OSR 0x2000 /* OUT5_OSR */
2877#define ARIZONA_OUT5_OSR_MASK 0x2000 /* OUT5_OSR */
2878#define ARIZONA_OUT5_OSR_SHIFT 13 /* OUT5_OSR */
2879#define ARIZONA_OUT5_OSR_WIDTH 1 /* OUT5_OSR */
2880#define ARIZONA_OUT5L_ANC_SRC_MASK 0x0C00 /* OUT5L_ANC_SRC - [11:10] */
2881#define ARIZONA_OUT5L_ANC_SRC_SHIFT 10 /* OUT5L_ANC_SRC - [11:10] */
2882#define ARIZONA_OUT5L_ANC_SRC_WIDTH 2 /* OUT5L_ANC_SRC - [11:10] */
2883
2884/*
2885 * R1073 (0x431) - DAC Digital Volume 5L
2886 */
2887#define ARIZONA_OUT_VU 0x0200 /* OUT_VU */
2888#define ARIZONA_OUT_VU_MASK 0x0200 /* OUT_VU */
2889#define ARIZONA_OUT_VU_SHIFT 9 /* OUT_VU */
2890#define ARIZONA_OUT_VU_WIDTH 1 /* OUT_VU */
2891#define ARIZONA_OUT5L_MUTE 0x0100 /* OUT5L_MUTE */
2892#define ARIZONA_OUT5L_MUTE_MASK 0x0100 /* OUT5L_MUTE */
2893#define ARIZONA_OUT5L_MUTE_SHIFT 8 /* OUT5L_MUTE */
2894#define ARIZONA_OUT5L_MUTE_WIDTH 1 /* OUT5L_MUTE */
2895#define ARIZONA_OUT5L_VOL_MASK 0x00FF /* OUT5L_VOL - [7:0] */
2896#define ARIZONA_OUT5L_VOL_SHIFT 0 /* OUT5L_VOL - [7:0] */
2897#define ARIZONA_OUT5L_VOL_WIDTH 8 /* OUT5L_VOL - [7:0] */
2898
2899/*
2900 * R1074 (0x432) - DAC Volume Limit 5L
2901 */
2902#define ARIZONA_OUT5L_VOL_LIM_MASK 0x00FF /* OUT5L_VOL_LIM - [7:0] */
2903#define ARIZONA_OUT5L_VOL_LIM_SHIFT 0 /* OUT5L_VOL_LIM - [7:0] */
2904#define ARIZONA_OUT5L_VOL_LIM_WIDTH 8 /* OUT5L_VOL_LIM - [7:0] */
2905
2906/*
2907 * R1075 (0x433) - Noise Gate Select 5L
2908 */
2909#define ARIZONA_OUT5L_NGATE_SRC_MASK 0x0FFF /* OUT5L_NGATE_SRC - [11:0] */
2910#define ARIZONA_OUT5L_NGATE_SRC_SHIFT 0 /* OUT5L_NGATE_SRC - [11:0] */
2911#define ARIZONA_OUT5L_NGATE_SRC_WIDTH 12 /* OUT5L_NGATE_SRC - [11:0] */
2912
2913/*
2914 * R1076 (0x434) - Output Path Config 5R
2915 */
2916#define ARIZONA_OUT5R_ANC_SRC_MASK 0x0C00 /* OUT5R_ANC_SRC - [11:10] */
2917#define ARIZONA_OUT5R_ANC_SRC_SHIFT 10 /* OUT5R_ANC_SRC - [11:10] */
2918#define ARIZONA_OUT5R_ANC_SRC_WIDTH 2 /* OUT5R_ANC_SRC - [11:10] */
2919
2920/*
2921 * R1077 (0x435) - DAC Digital Volume 5R
2922 */
2923#define ARIZONA_OUT_VU 0x0200 /* OUT_VU */
2924#define ARIZONA_OUT_VU_MASK 0x0200 /* OUT_VU */
2925#define ARIZONA_OUT_VU_SHIFT 9 /* OUT_VU */
2926#define ARIZONA_OUT_VU_WIDTH 1 /* OUT_VU */
2927#define ARIZONA_OUT5R_MUTE 0x0100 /* OUT5R_MUTE */
2928#define ARIZONA_OUT5R_MUTE_MASK 0x0100 /* OUT5R_MUTE */
2929#define ARIZONA_OUT5R_MUTE_SHIFT 8 /* OUT5R_MUTE */
2930#define ARIZONA_OUT5R_MUTE_WIDTH 1 /* OUT5R_MUTE */
2931#define ARIZONA_OUT5R_VOL_MASK 0x00FF /* OUT5R_VOL - [7:0] */
2932#define ARIZONA_OUT5R_VOL_SHIFT 0 /* OUT5R_VOL - [7:0] */
2933#define ARIZONA_OUT5R_VOL_WIDTH 8 /* OUT5R_VOL - [7:0] */
2934
2935/*
2936 * R1078 (0x436) - DAC Volume Limit 5R
2937 */
2938#define ARIZONA_OUT5R_VOL_LIM_MASK 0x00FF /* OUT5R_VOL_LIM - [7:0] */
2939#define ARIZONA_OUT5R_VOL_LIM_SHIFT 0 /* OUT5R_VOL_LIM - [7:0] */
2940#define ARIZONA_OUT5R_VOL_LIM_WIDTH 8 /* OUT5R_VOL_LIM - [7:0] */
2941
2942/*
2943 * R1079 (0x437) - Noise Gate Select 5R
2944 */
2945#define ARIZONA_OUT5R_NGATE_SRC_MASK 0x0FFF /* OUT5R_NGATE_SRC - [11:0] */
2946#define ARIZONA_OUT5R_NGATE_SRC_SHIFT 0 /* OUT5R_NGATE_SRC - [11:0] */
2947#define ARIZONA_OUT5R_NGATE_SRC_WIDTH 12 /* OUT5R_NGATE_SRC - [11:0] */
2948
2949/*
2950 * R1080 (0x438) - Output Path Config 6L
2951 */
2952#define ARIZONA_OUT6_OSR 0x2000 /* OUT6_OSR */
2953#define ARIZONA_OUT6_OSR_MASK 0x2000 /* OUT6_OSR */
2954#define ARIZONA_OUT6_OSR_SHIFT 13 /* OUT6_OSR */
2955#define ARIZONA_OUT6_OSR_WIDTH 1 /* OUT6_OSR */
2956#define ARIZONA_OUT6L_ANC_SRC_MASK 0x0C00 /* OUT6L_ANC_SRC - [11:10] */
2957#define ARIZONA_OUT6L_ANC_SRC_SHIFT 10 /* OUT6L_ANC_SRC - [11:10] */
2958#define ARIZONA_OUT6L_ANC_SRC_WIDTH 2 /* OUT6L_ANC_SRC - [11:10] */
2959
2960/*
2961 * R1081 (0x439) - DAC Digital Volume 6L
2962 */
2963#define ARIZONA_OUT_VU 0x0200 /* OUT_VU */
2964#define ARIZONA_OUT_VU_MASK 0x0200 /* OUT_VU */
2965#define ARIZONA_OUT_VU_SHIFT 9 /* OUT_VU */
2966#define ARIZONA_OUT_VU_WIDTH 1 /* OUT_VU */
2967#define ARIZONA_OUT6L_MUTE 0x0100 /* OUT6L_MUTE */
2968#define ARIZONA_OUT6L_MUTE_MASK 0x0100 /* OUT6L_MUTE */
2969#define ARIZONA_OUT6L_MUTE_SHIFT 8 /* OUT6L_MUTE */
2970#define ARIZONA_OUT6L_MUTE_WIDTH 1 /* OUT6L_MUTE */
2971#define ARIZONA_OUT6L_VOL_MASK 0x00FF /* OUT6L_VOL - [7:0] */
2972#define ARIZONA_OUT6L_VOL_SHIFT 0 /* OUT6L_VOL - [7:0] */
2973#define ARIZONA_OUT6L_VOL_WIDTH 8 /* OUT6L_VOL - [7:0] */
2974
2975/*
2976 * R1082 (0x43A) - DAC Volume Limit 6L
2977 */
2978#define ARIZONA_OUT6L_VOL_LIM_MASK 0x00FF /* OUT6L_VOL_LIM - [7:0] */
2979#define ARIZONA_OUT6L_VOL_LIM_SHIFT 0 /* OUT6L_VOL_LIM - [7:0] */
2980#define ARIZONA_OUT6L_VOL_LIM_WIDTH 8 /* OUT6L_VOL_LIM - [7:0] */
2981
2982/*
2983 * R1083 (0x43B) - Noise Gate Select 6L
2984 */
2985#define ARIZONA_OUT6L_NGATE_SRC_MASK 0x0FFF /* OUT6L_NGATE_SRC - [11:0] */
2986#define ARIZONA_OUT6L_NGATE_SRC_SHIFT 0 /* OUT6L_NGATE_SRC - [11:0] */
2987#define ARIZONA_OUT6L_NGATE_SRC_WIDTH 12 /* OUT6L_NGATE_SRC - [11:0] */
2988
2989/*
2990 * R1084 (0x43C) - Output Path Config 6R
2991 */
2992#define ARIZONA_OUT6R_ANC_SRC_MASK 0x0C00 /* OUT6R_ANC_SRC - [11:10] */
2993#define ARIZONA_OUT6R_ANC_SRC_SHIFT 10 /* OUT6R_ANC_SRC - [11:10] */
2994#define ARIZONA_OUT6R_ANC_SRC_WIDTH 2 /* OUT6R_ANC_SRC - [11:10] */
2995
2996/*
2997 * R1085 (0x43D) - DAC Digital Volume 6R
2998 */
2999#define ARIZONA_OUT_VU 0x0200 /* OUT_VU */
3000#define ARIZONA_OUT_VU_MASK 0x0200 /* OUT_VU */
3001#define ARIZONA_OUT_VU_SHIFT 9 /* OUT_VU */
3002#define ARIZONA_OUT_VU_WIDTH 1 /* OUT_VU */
3003#define ARIZONA_OUT6R_MUTE 0x0100 /* OUT6R_MUTE */
3004#define ARIZONA_OUT6R_MUTE_MASK 0x0100 /* OUT6R_MUTE */
3005#define ARIZONA_OUT6R_MUTE_SHIFT 8 /* OUT6R_MUTE */
3006#define ARIZONA_OUT6R_MUTE_WIDTH 1 /* OUT6R_MUTE */
3007#define ARIZONA_OUT6R_VOL_MASK 0x00FF /* OUT6R_VOL - [7:0] */
3008#define ARIZONA_OUT6R_VOL_SHIFT 0 /* OUT6R_VOL - [7:0] */
3009#define ARIZONA_OUT6R_VOL_WIDTH 8 /* OUT6R_VOL - [7:0] */
3010
3011/*
3012 * R1086 (0x43E) - DAC Volume Limit 6R
3013 */
3014#define ARIZONA_OUT6R_VOL_LIM_MASK 0x00FF /* OUT6R_VOL_LIM - [7:0] */
3015#define ARIZONA_OUT6R_VOL_LIM_SHIFT 0 /* OUT6R_VOL_LIM - [7:0] */
3016#define ARIZONA_OUT6R_VOL_LIM_WIDTH 8 /* OUT6R_VOL_LIM - [7:0] */
3017
3018/*
3019 * R1087 (0x43F) - Noise Gate Select 6R
3020 */
3021#define ARIZONA_OUT6R_NGATE_SRC_MASK 0x0FFF /* OUT6R_NGATE_SRC - [11:0] */
3022#define ARIZONA_OUT6R_NGATE_SRC_SHIFT 0 /* OUT6R_NGATE_SRC - [11:0] */
3023#define ARIZONA_OUT6R_NGATE_SRC_WIDTH 12 /* OUT6R_NGATE_SRC - [11:0] */
3024
3025/*
3026 * R1104 (0x450) - DAC AEC Control 1
3027 */
3028#define ARIZONA_AEC_LOOPBACK_SRC_MASK 0x003C /* AEC_LOOPBACK_SRC - [5:2] */
3029#define ARIZONA_AEC_LOOPBACK_SRC_SHIFT 2 /* AEC_LOOPBACK_SRC - [5:2] */
3030#define ARIZONA_AEC_LOOPBACK_SRC_WIDTH 4 /* AEC_LOOPBACK_SRC - [5:2] */
3031#define ARIZONA_AEC_ENA_STS 0x0002 /* AEC_ENA_STS */
3032#define ARIZONA_AEC_ENA_STS_MASK 0x0002 /* AEC_ENA_STS */
3033#define ARIZONA_AEC_ENA_STS_SHIFT 1 /* AEC_ENA_STS */
3034#define ARIZONA_AEC_ENA_STS_WIDTH 1 /* AEC_ENA_STS */
3035#define ARIZONA_AEC_LOOPBACK_ENA 0x0001 /* AEC_LOOPBACK_ENA */
3036#define ARIZONA_AEC_LOOPBACK_ENA_MASK 0x0001 /* AEC_LOOPBACK_ENA */
3037#define ARIZONA_AEC_LOOPBACK_ENA_SHIFT 0 /* AEC_LOOPBACK_ENA */
3038#define ARIZONA_AEC_LOOPBACK_ENA_WIDTH 1 /* AEC_LOOPBACK_ENA */
3039
3040/*
3041 * R1112 (0x458) - Noise Gate Control
3042 */
3043#define ARIZONA_NGATE_HOLD_MASK 0x0030 /* NGATE_HOLD - [5:4] */
3044#define ARIZONA_NGATE_HOLD_SHIFT 4 /* NGATE_HOLD - [5:4] */
3045#define ARIZONA_NGATE_HOLD_WIDTH 2 /* NGATE_HOLD - [5:4] */
3046#define ARIZONA_NGATE_THR_MASK 0x000E /* NGATE_THR - [3:1] */
3047#define ARIZONA_NGATE_THR_SHIFT 1 /* NGATE_THR - [3:1] */
3048#define ARIZONA_NGATE_THR_WIDTH 3 /* NGATE_THR - [3:1] */
3049#define ARIZONA_NGATE_ENA 0x0001 /* NGATE_ENA */
3050#define ARIZONA_NGATE_ENA_MASK 0x0001 /* NGATE_ENA */
3051#define ARIZONA_NGATE_ENA_SHIFT 0 /* NGATE_ENA */
3052#define ARIZONA_NGATE_ENA_WIDTH 1 /* NGATE_ENA */
3053
3054/*
3055 * R1168 (0x490) - PDM SPK1 CTRL 1
3056 */
3057#define ARIZONA_SPK1R_MUTE 0x2000 /* SPK1R_MUTE */
3058#define ARIZONA_SPK1R_MUTE_MASK 0x2000 /* SPK1R_MUTE */
3059#define ARIZONA_SPK1R_MUTE_SHIFT 13 /* SPK1R_MUTE */
3060#define ARIZONA_SPK1R_MUTE_WIDTH 1 /* SPK1R_MUTE */
3061#define ARIZONA_SPK1L_MUTE 0x1000 /* SPK1L_MUTE */
3062#define ARIZONA_SPK1L_MUTE_MASK 0x1000 /* SPK1L_MUTE */
3063#define ARIZONA_SPK1L_MUTE_SHIFT 12 /* SPK1L_MUTE */
3064#define ARIZONA_SPK1L_MUTE_WIDTH 1 /* SPK1L_MUTE */
3065#define ARIZONA_SPK1_MUTE_ENDIAN 0x0100 /* SPK1_MUTE_ENDIAN */
3066#define ARIZONA_SPK1_MUTE_ENDIAN_MASK 0x0100 /* SPK1_MUTE_ENDIAN */
3067#define ARIZONA_SPK1_MUTE_ENDIAN_SHIFT 8 /* SPK1_MUTE_ENDIAN */
3068#define ARIZONA_SPK1_MUTE_ENDIAN_WIDTH 1 /* SPK1_MUTE_ENDIAN */
3069#define ARIZONA_SPK1_MUTE_SEQ1_MASK 0x00FF /* SPK1_MUTE_SEQ1 - [7:0] */
3070#define ARIZONA_SPK1_MUTE_SEQ1_SHIFT 0 /* SPK1_MUTE_SEQ1 - [7:0] */
3071#define ARIZONA_SPK1_MUTE_SEQ1_WIDTH 8 /* SPK1_MUTE_SEQ1 - [7:0] */
3072
3073/*
3074 * R1169 (0x491) - PDM SPK1 CTRL 2
3075 */
3076#define ARIZONA_SPK1_FMT 0x0001 /* SPK1_FMT */
3077#define ARIZONA_SPK1_FMT_MASK 0x0001 /* SPK1_FMT */
3078#define ARIZONA_SPK1_FMT_SHIFT 0 /* SPK1_FMT */
3079#define ARIZONA_SPK1_FMT_WIDTH 1 /* SPK1_FMT */
3080
3081/*
3082 * R1170 (0x492) - PDM SPK2 CTRL 1
3083 */
3084#define ARIZONA_SPK2R_MUTE 0x2000 /* SPK2R_MUTE */
3085#define ARIZONA_SPK2R_MUTE_MASK 0x2000 /* SPK2R_MUTE */
3086#define ARIZONA_SPK2R_MUTE_SHIFT 13 /* SPK2R_MUTE */
3087#define ARIZONA_SPK2R_MUTE_WIDTH 1 /* SPK2R_MUTE */
3088#define ARIZONA_SPK2L_MUTE 0x1000 /* SPK2L_MUTE */
3089#define ARIZONA_SPK2L_MUTE_MASK 0x1000 /* SPK2L_MUTE */
3090#define ARIZONA_SPK2L_MUTE_SHIFT 12 /* SPK2L_MUTE */
3091#define ARIZONA_SPK2L_MUTE_WIDTH 1 /* SPK2L_MUTE */
3092#define ARIZONA_SPK2_MUTE_ENDIAN 0x0100 /* SPK2_MUTE_ENDIAN */
3093#define ARIZONA_SPK2_MUTE_ENDIAN_MASK 0x0100 /* SPK2_MUTE_ENDIAN */
3094#define ARIZONA_SPK2_MUTE_ENDIAN_SHIFT 8 /* SPK2_MUTE_ENDIAN */
3095#define ARIZONA_SPK2_MUTE_ENDIAN_WIDTH 1 /* SPK2_MUTE_ENDIAN */
3096#define ARIZONA_SPK2_MUTE_SEQ_MASK 0x00FF /* SPK2_MUTE_SEQ - [7:0] */
3097#define ARIZONA_SPK2_MUTE_SEQ_SHIFT 0 /* SPK2_MUTE_SEQ - [7:0] */
3098#define ARIZONA_SPK2_MUTE_SEQ_WIDTH 8 /* SPK2_MUTE_SEQ - [7:0] */
3099
3100/*
3101 * R1171 (0x493) - PDM SPK2 CTRL 2
3102 */
3103#define ARIZONA_SPK2_FMT 0x0001 /* SPK2_FMT */
3104#define ARIZONA_SPK2_FMT_MASK 0x0001 /* SPK2_FMT */
3105#define ARIZONA_SPK2_FMT_SHIFT 0 /* SPK2_FMT */
3106#define ARIZONA_SPK2_FMT_WIDTH 1 /* SPK2_FMT */
3107
3108/*
3109 * R1244 (0x4DC) - DAC comp 1
3110 */
3111#define ARIZONA_OUT_COMP_COEFF_MASK 0xFFFF /* OUT_COMP_COEFF - [15:0] */
3112#define ARIZONA_OUT_COMP_COEFF_SHIFT 0 /* OUT_COMP_COEFF - [15:0] */
3113#define ARIZONA_OUT_COMP_COEFF_WIDTH 16 /* OUT_COMP_COEFF - [15:0] */
3114
3115/*
3116 * R1245 (0x4DD) - DAC comp 2
3117 */
3118#define ARIZONA_OUT_COMP_COEFF_1 0x0002 /* OUT_COMP_COEFF */
3119#define ARIZONA_OUT_COMP_COEFF_1_MASK 0x0002 /* OUT_COMP_COEFF */
3120#define ARIZONA_OUT_COMP_COEFF_1_SHIFT 1 /* OUT_COMP_COEFF */
3121#define ARIZONA_OUT_COMP_COEFF_1_WIDTH 1 /* OUT_COMP_COEFF */
3122#define ARIZONA_OUT_COMP_COEFF_SEL 0x0001 /* OUT_COMP_COEFF_SEL */
3123#define ARIZONA_OUT_COMP_COEFF_SEL_MASK 0x0001 /* OUT_COMP_COEFF_SEL */
3124#define ARIZONA_OUT_COMP_COEFF_SEL_SHIFT 0 /* OUT_COMP_COEFF_SEL */
3125#define ARIZONA_OUT_COMP_COEFF_SEL_WIDTH 1 /* OUT_COMP_COEFF_SEL */
3126
3127/*
3128 * R1246 (0x4DE) - DAC comp 3
3129 */
3130#define ARIZONA_AEC_COMP_COEFF_MASK 0xFFFF /* AEC_COMP_COEFF - [15:0] */
3131#define ARIZONA_AEC_COMP_COEFF_SHIFT 0 /* AEC_COMP_COEFF - [15:0] */
3132#define ARIZONA_AEC_COMP_COEFF_WIDTH 16 /* AEC_COMP_COEFF - [15:0] */
3133
3134/*
3135 * R1247 (0x4DF) - DAC comp 4
3136 */
3137#define ARIZONA_AEC_COMP_COEFF_1 0x0002 /* AEC_COMP_COEFF */
3138#define ARIZONA_AEC_COMP_COEFF_1_MASK 0x0002 /* AEC_COMP_COEFF */
3139#define ARIZONA_AEC_COMP_COEFF_1_SHIFT 1 /* AEC_COMP_COEFF */
3140#define ARIZONA_AEC_COMP_COEFF_1_WIDTH 1 /* AEC_COMP_COEFF */
3141#define ARIZONA_AEC_COMP_COEFF_SEL 0x0001 /* AEC_COMP_COEFF_SEL */
3142#define ARIZONA_AEC_COMP_COEFF_SEL_MASK 0x0001 /* AEC_COMP_COEFF_SEL */
3143#define ARIZONA_AEC_COMP_COEFF_SEL_SHIFT 0 /* AEC_COMP_COEFF_SEL */
3144#define ARIZONA_AEC_COMP_COEFF_SEL_WIDTH 1 /* AEC_COMP_COEFF_SEL */
3145
3146/*
3147 * R1280 (0x500) - AIF1 BCLK Ctrl
3148 */
3149#define ARIZONA_AIF1_BCLK_INV 0x0080 /* AIF1_BCLK_INV */
3150#define ARIZONA_AIF1_BCLK_INV_MASK 0x0080 /* AIF1_BCLK_INV */
3151#define ARIZONA_AIF1_BCLK_INV_SHIFT 7 /* AIF1_BCLK_INV */
3152#define ARIZONA_AIF1_BCLK_INV_WIDTH 1 /* AIF1_BCLK_INV */
3153#define ARIZONA_AIF1_BCLK_FRC 0x0040 /* AIF1_BCLK_FRC */
3154#define ARIZONA_AIF1_BCLK_FRC_MASK 0x0040 /* AIF1_BCLK_FRC */
3155#define ARIZONA_AIF1_BCLK_FRC_SHIFT 6 /* AIF1_BCLK_FRC */
3156#define ARIZONA_AIF1_BCLK_FRC_WIDTH 1 /* AIF1_BCLK_FRC */
3157#define ARIZONA_AIF1_BCLK_MSTR 0x0020 /* AIF1_BCLK_MSTR */
3158#define ARIZONA_AIF1_BCLK_MSTR_MASK 0x0020 /* AIF1_BCLK_MSTR */
3159#define ARIZONA_AIF1_BCLK_MSTR_SHIFT 5 /* AIF1_BCLK_MSTR */
3160#define ARIZONA_AIF1_BCLK_MSTR_WIDTH 1 /* AIF1_BCLK_MSTR */
3161#define ARIZONA_AIF1_BCLK_FREQ_MASK 0x001F /* AIF1_BCLK_FREQ - [4:0] */
3162#define ARIZONA_AIF1_BCLK_FREQ_SHIFT 0 /* AIF1_BCLK_FREQ - [4:0] */
3163#define ARIZONA_AIF1_BCLK_FREQ_WIDTH 5 /* AIF1_BCLK_FREQ - [4:0] */
3164
3165/*
3166 * R1281 (0x501) - AIF1 Tx Pin Ctrl
3167 */
3168#define ARIZONA_AIF1TX_DAT_TRI 0x0020 /* AIF1TX_DAT_TRI */
3169#define ARIZONA_AIF1TX_DAT_TRI_MASK 0x0020 /* AIF1TX_DAT_TRI */
3170#define ARIZONA_AIF1TX_DAT_TRI_SHIFT 5 /* AIF1TX_DAT_TRI */
3171#define ARIZONA_AIF1TX_DAT_TRI_WIDTH 1 /* AIF1TX_DAT_TRI */
3172#define ARIZONA_AIF1TX_LRCLK_SRC 0x0008 /* AIF1TX_LRCLK_SRC */
3173#define ARIZONA_AIF1TX_LRCLK_SRC_MASK 0x0008 /* AIF1TX_LRCLK_SRC */
3174#define ARIZONA_AIF1TX_LRCLK_SRC_SHIFT 3 /* AIF1TX_LRCLK_SRC */
3175#define ARIZONA_AIF1TX_LRCLK_SRC_WIDTH 1 /* AIF1TX_LRCLK_SRC */
3176#define ARIZONA_AIF1TX_LRCLK_INV 0x0004 /* AIF1TX_LRCLK_INV */
3177#define ARIZONA_AIF1TX_LRCLK_INV_MASK 0x0004 /* AIF1TX_LRCLK_INV */
3178#define ARIZONA_AIF1TX_LRCLK_INV_SHIFT 2 /* AIF1TX_LRCLK_INV */
3179#define ARIZONA_AIF1TX_LRCLK_INV_WIDTH 1 /* AIF1TX_LRCLK_INV */
3180#define ARIZONA_AIF1TX_LRCLK_FRC 0x0002 /* AIF1TX_LRCLK_FRC */
3181#define ARIZONA_AIF1TX_LRCLK_FRC_MASK 0x0002 /* AIF1TX_LRCLK_FRC */
3182#define ARIZONA_AIF1TX_LRCLK_FRC_SHIFT 1 /* AIF1TX_LRCLK_FRC */
3183#define ARIZONA_AIF1TX_LRCLK_FRC_WIDTH 1 /* AIF1TX_LRCLK_FRC */
3184#define ARIZONA_AIF1TX_LRCLK_MSTR 0x0001 /* AIF1TX_LRCLK_MSTR */
3185#define ARIZONA_AIF1TX_LRCLK_MSTR_MASK 0x0001 /* AIF1TX_LRCLK_MSTR */
3186#define ARIZONA_AIF1TX_LRCLK_MSTR_SHIFT 0 /* AIF1TX_LRCLK_MSTR */
3187#define ARIZONA_AIF1TX_LRCLK_MSTR_WIDTH 1 /* AIF1TX_LRCLK_MSTR */
3188
3189/*
3190 * R1282 (0x502) - AIF1 Rx Pin Ctrl
3191 */
3192#define ARIZONA_AIF1RX_LRCLK_INV 0x0004 /* AIF1RX_LRCLK_INV */
3193#define ARIZONA_AIF1RX_LRCLK_INV_MASK 0x0004 /* AIF1RX_LRCLK_INV */
3194#define ARIZONA_AIF1RX_LRCLK_INV_SHIFT 2 /* AIF1RX_LRCLK_INV */
3195#define ARIZONA_AIF1RX_LRCLK_INV_WIDTH 1 /* AIF1RX_LRCLK_INV */
3196#define ARIZONA_AIF1RX_LRCLK_FRC 0x0002 /* AIF1RX_LRCLK_FRC */
3197#define ARIZONA_AIF1RX_LRCLK_FRC_MASK 0x0002 /* AIF1RX_LRCLK_FRC */
3198#define ARIZONA_AIF1RX_LRCLK_FRC_SHIFT 1 /* AIF1RX_LRCLK_FRC */
3199#define ARIZONA_AIF1RX_LRCLK_FRC_WIDTH 1 /* AIF1RX_LRCLK_FRC */
3200#define ARIZONA_AIF1RX_LRCLK_MSTR 0x0001 /* AIF1RX_LRCLK_MSTR */
3201#define ARIZONA_AIF1RX_LRCLK_MSTR_MASK 0x0001 /* AIF1RX_LRCLK_MSTR */
3202#define ARIZONA_AIF1RX_LRCLK_MSTR_SHIFT 0 /* AIF1RX_LRCLK_MSTR */
3203#define ARIZONA_AIF1RX_LRCLK_MSTR_WIDTH 1 /* AIF1RX_LRCLK_MSTR */
3204
3205/*
3206 * R1283 (0x503) - AIF1 Rate Ctrl
3207 */
3208#define ARIZONA_AIF1_RATE_MASK 0x7800 /* AIF1_RATE - [14:11] */
3209#define ARIZONA_AIF1_RATE_SHIFT 11 /* AIF1_RATE - [14:11] */
3210#define ARIZONA_AIF1_RATE_WIDTH 4 /* AIF1_RATE - [14:11] */
3211#define ARIZONA_AIF1_TRI 0x0040 /* AIF1_TRI */
3212#define ARIZONA_AIF1_TRI_MASK 0x0040 /* AIF1_TRI */
3213#define ARIZONA_AIF1_TRI_SHIFT 6 /* AIF1_TRI */
3214#define ARIZONA_AIF1_TRI_WIDTH 1 /* AIF1_TRI */
3215
3216/*
3217 * R1284 (0x504) - AIF1 Format
3218 */
3219#define ARIZONA_AIF1_FMT_MASK 0x0007 /* AIF1_FMT - [2:0] */
3220#define ARIZONA_AIF1_FMT_SHIFT 0 /* AIF1_FMT - [2:0] */
3221#define ARIZONA_AIF1_FMT_WIDTH 3 /* AIF1_FMT - [2:0] */
3222
3223/*
3224 * R1285 (0x505) - AIF1 Tx BCLK Rate
3225 */
3226#define ARIZONA_AIF1TX_BCPF_MASK 0x1FFF /* AIF1TX_BCPF - [12:0] */
3227#define ARIZONA_AIF1TX_BCPF_SHIFT 0 /* AIF1TX_BCPF - [12:0] */
3228#define ARIZONA_AIF1TX_BCPF_WIDTH 13 /* AIF1TX_BCPF - [12:0] */
3229
3230/*
3231 * R1286 (0x506) - AIF1 Rx BCLK Rate
3232 */
3233#define ARIZONA_AIF1RX_BCPF_MASK 0x1FFF /* AIF1RX_BCPF - [12:0] */
3234#define ARIZONA_AIF1RX_BCPF_SHIFT 0 /* AIF1RX_BCPF - [12:0] */
3235#define ARIZONA_AIF1RX_BCPF_WIDTH 13 /* AIF1RX_BCPF - [12:0] */
3236
3237/*
3238 * R1287 (0x507) - AIF1 Frame Ctrl 1
3239 */
3240#define ARIZONA_AIF1TX_WL_MASK 0x3F00 /* AIF1TX_WL - [13:8] */
3241#define ARIZONA_AIF1TX_WL_SHIFT 8 /* AIF1TX_WL - [13:8] */
3242#define ARIZONA_AIF1TX_WL_WIDTH 6 /* AIF1TX_WL - [13:8] */
3243#define ARIZONA_AIF1TX_SLOT_LEN_MASK 0x00FF /* AIF1TX_SLOT_LEN - [7:0] */
3244#define ARIZONA_AIF1TX_SLOT_LEN_SHIFT 0 /* AIF1TX_SLOT_LEN - [7:0] */
3245#define ARIZONA_AIF1TX_SLOT_LEN_WIDTH 8 /* AIF1TX_SLOT_LEN - [7:0] */
3246
3247/*
3248 * R1288 (0x508) - AIF1 Frame Ctrl 2
3249 */
3250#define ARIZONA_AIF1RX_WL_MASK 0x3F00 /* AIF1RX_WL - [13:8] */
3251#define ARIZONA_AIF1RX_WL_SHIFT 8 /* AIF1RX_WL - [13:8] */
3252#define ARIZONA_AIF1RX_WL_WIDTH 6 /* AIF1RX_WL - [13:8] */
3253#define ARIZONA_AIF1RX_SLOT_LEN_MASK 0x00FF /* AIF1RX_SLOT_LEN - [7:0] */
3254#define ARIZONA_AIF1RX_SLOT_LEN_SHIFT 0 /* AIF1RX_SLOT_LEN - [7:0] */
3255#define ARIZONA_AIF1RX_SLOT_LEN_WIDTH 8 /* AIF1RX_SLOT_LEN - [7:0] */
3256
3257/*
3258 * R1289 (0x509) - AIF1 Frame Ctrl 3
3259 */
3260#define ARIZONA_AIF1TX1_SLOT_MASK 0x003F /* AIF1TX1_SLOT - [5:0] */
3261#define ARIZONA_AIF1TX1_SLOT_SHIFT 0 /* AIF1TX1_SLOT - [5:0] */
3262#define ARIZONA_AIF1TX1_SLOT_WIDTH 6 /* AIF1TX1_SLOT - [5:0] */
3263
3264/*
3265 * R1290 (0x50A) - AIF1 Frame Ctrl 4
3266 */
3267#define ARIZONA_AIF1TX2_SLOT_MASK 0x003F /* AIF1TX2_SLOT - [5:0] */
3268#define ARIZONA_AIF1TX2_SLOT_SHIFT 0 /* AIF1TX2_SLOT - [5:0] */
3269#define ARIZONA_AIF1TX2_SLOT_WIDTH 6 /* AIF1TX2_SLOT - [5:0] */
3270
3271/*
3272 * R1291 (0x50B) - AIF1 Frame Ctrl 5
3273 */
3274#define ARIZONA_AIF1TX3_SLOT_MASK 0x003F /* AIF1TX3_SLOT - [5:0] */
3275#define ARIZONA_AIF1TX3_SLOT_SHIFT 0 /* AIF1TX3_SLOT - [5:0] */
3276#define ARIZONA_AIF1TX3_SLOT_WIDTH 6 /* AIF1TX3_SLOT - [5:0] */
3277
3278/*
3279 * R1292 (0x50C) - AIF1 Frame Ctrl 6
3280 */
3281#define ARIZONA_AIF1TX4_SLOT_MASK 0x003F /* AIF1TX4_SLOT - [5:0] */
3282#define ARIZONA_AIF1TX4_SLOT_SHIFT 0 /* AIF1TX4_SLOT - [5:0] */
3283#define ARIZONA_AIF1TX4_SLOT_WIDTH 6 /* AIF1TX4_SLOT - [5:0] */
3284
3285/*
3286 * R1293 (0x50D) - AIF1 Frame Ctrl 7
3287 */
3288#define ARIZONA_AIF1TX5_SLOT_MASK 0x003F /* AIF1TX5_SLOT - [5:0] */
3289#define ARIZONA_AIF1TX5_SLOT_SHIFT 0 /* AIF1TX5_SLOT - [5:0] */
3290#define ARIZONA_AIF1TX5_SLOT_WIDTH 6 /* AIF1TX5_SLOT - [5:0] */
3291
3292/*
3293 * R1294 (0x50E) - AIF1 Frame Ctrl 8
3294 */
3295#define ARIZONA_AIF1TX6_SLOT_MASK 0x003F /* AIF1TX6_SLOT - [5:0] */
3296#define ARIZONA_AIF1TX6_SLOT_SHIFT 0 /* AIF1TX6_SLOT - [5:0] */
3297#define ARIZONA_AIF1TX6_SLOT_WIDTH 6 /* AIF1TX6_SLOT - [5:0] */
3298
3299/*
3300 * R1295 (0x50F) - AIF1 Frame Ctrl 9
3301 */
3302#define ARIZONA_AIF1TX7_SLOT_MASK 0x003F /* AIF1TX7_SLOT - [5:0] */
3303#define ARIZONA_AIF1TX7_SLOT_SHIFT 0 /* AIF1TX7_SLOT - [5:0] */
3304#define ARIZONA_AIF1TX7_SLOT_WIDTH 6 /* AIF1TX7_SLOT - [5:0] */
3305
3306/*
3307 * R1296 (0x510) - AIF1 Frame Ctrl 10
3308 */
3309#define ARIZONA_AIF1TX8_SLOT_MASK 0x003F /* AIF1TX8_SLOT - [5:0] */
3310#define ARIZONA_AIF1TX8_SLOT_SHIFT 0 /* AIF1TX8_SLOT - [5:0] */
3311#define ARIZONA_AIF1TX8_SLOT_WIDTH 6 /* AIF1TX8_SLOT - [5:0] */
3312
3313/*
3314 * R1297 (0x511) - AIF1 Frame Ctrl 11
3315 */
3316#define ARIZONA_AIF1RX1_SLOT_MASK 0x003F /* AIF1RX1_SLOT - [5:0] */
3317#define ARIZONA_AIF1RX1_SLOT_SHIFT 0 /* AIF1RX1_SLOT - [5:0] */
3318#define ARIZONA_AIF1RX1_SLOT_WIDTH 6 /* AIF1RX1_SLOT - [5:0] */
3319
3320/*
3321 * R1298 (0x512) - AIF1 Frame Ctrl 12
3322 */
3323#define ARIZONA_AIF1RX2_SLOT_MASK 0x003F /* AIF1RX2_SLOT - [5:0] */
3324#define ARIZONA_AIF1RX2_SLOT_SHIFT 0 /* AIF1RX2_SLOT - [5:0] */
3325#define ARIZONA_AIF1RX2_SLOT_WIDTH 6 /* AIF1RX2_SLOT - [5:0] */
3326
3327/*
3328 * R1299 (0x513) - AIF1 Frame Ctrl 13
3329 */
3330#define ARIZONA_AIF1RX3_SLOT_MASK 0x003F /* AIF1RX3_SLOT - [5:0] */
3331#define ARIZONA_AIF1RX3_SLOT_SHIFT 0 /* AIF1RX3_SLOT - [5:0] */
3332#define ARIZONA_AIF1RX3_SLOT_WIDTH 6 /* AIF1RX3_SLOT - [5:0] */
3333
3334/*
3335 * R1300 (0x514) - AIF1 Frame Ctrl 14
3336 */
3337#define ARIZONA_AIF1RX4_SLOT_MASK 0x003F /* AIF1RX4_SLOT - [5:0] */
3338#define ARIZONA_AIF1RX4_SLOT_SHIFT 0 /* AIF1RX4_SLOT - [5:0] */
3339#define ARIZONA_AIF1RX4_SLOT_WIDTH 6 /* AIF1RX4_SLOT - [5:0] */
3340
3341/*
3342 * R1301 (0x515) - AIF1 Frame Ctrl 15
3343 */
3344#define ARIZONA_AIF1RX5_SLOT_MASK 0x003F /* AIF1RX5_SLOT - [5:0] */
3345#define ARIZONA_AIF1RX5_SLOT_SHIFT 0 /* AIF1RX5_SLOT - [5:0] */
3346#define ARIZONA_AIF1RX5_SLOT_WIDTH 6 /* AIF1RX5_SLOT - [5:0] */
3347
3348/*
3349 * R1302 (0x516) - AIF1 Frame Ctrl 16
3350 */
3351#define ARIZONA_AIF1RX6_SLOT_MASK 0x003F /* AIF1RX6_SLOT - [5:0] */
3352#define ARIZONA_AIF1RX6_SLOT_SHIFT 0 /* AIF1RX6_SLOT - [5:0] */
3353#define ARIZONA_AIF1RX6_SLOT_WIDTH 6 /* AIF1RX6_SLOT - [5:0] */
3354
3355/*
3356 * R1303 (0x517) - AIF1 Frame Ctrl 17
3357 */
3358#define ARIZONA_AIF1RX7_SLOT_MASK 0x003F /* AIF1RX7_SLOT - [5:0] */
3359#define ARIZONA_AIF1RX7_SLOT_SHIFT 0 /* AIF1RX7_SLOT - [5:0] */
3360#define ARIZONA_AIF1RX7_SLOT_WIDTH 6 /* AIF1RX7_SLOT - [5:0] */
3361
3362/*
3363 * R1304 (0x518) - AIF1 Frame Ctrl 18
3364 */
3365#define ARIZONA_AIF1RX8_SLOT_MASK 0x003F /* AIF1RX8_SLOT - [5:0] */
3366#define ARIZONA_AIF1RX8_SLOT_SHIFT 0 /* AIF1RX8_SLOT - [5:0] */
3367#define ARIZONA_AIF1RX8_SLOT_WIDTH 6 /* AIF1RX8_SLOT - [5:0] */
3368
3369/*
3370 * R1305 (0x519) - AIF1 Tx Enables
3371 */
3372#define ARIZONA_AIF1TX8_ENA 0x0080 /* AIF1TX8_ENA */
3373#define ARIZONA_AIF1TX8_ENA_MASK 0x0080 /* AIF1TX8_ENA */
3374#define ARIZONA_AIF1TX8_ENA_SHIFT 7 /* AIF1TX8_ENA */
3375#define ARIZONA_AIF1TX8_ENA_WIDTH 1 /* AIF1TX8_ENA */
3376#define ARIZONA_AIF1TX7_ENA 0x0040 /* AIF1TX7_ENA */
3377#define ARIZONA_AIF1TX7_ENA_MASK 0x0040 /* AIF1TX7_ENA */
3378#define ARIZONA_AIF1TX7_ENA_SHIFT 6 /* AIF1TX7_ENA */
3379#define ARIZONA_AIF1TX7_ENA_WIDTH 1 /* AIF1TX7_ENA */
3380#define ARIZONA_AIF1TX6_ENA 0x0020 /* AIF1TX6_ENA */
3381#define ARIZONA_AIF1TX6_ENA_MASK 0x0020 /* AIF1TX6_ENA */
3382#define ARIZONA_AIF1TX6_ENA_SHIFT 5 /* AIF1TX6_ENA */
3383#define ARIZONA_AIF1TX6_ENA_WIDTH 1 /* AIF1TX6_ENA */
3384#define ARIZONA_AIF1TX5_ENA 0x0010 /* AIF1TX5_ENA */
3385#define ARIZONA_AIF1TX5_ENA_MASK 0x0010 /* AIF1TX5_ENA */
3386#define ARIZONA_AIF1TX5_ENA_SHIFT 4 /* AIF1TX5_ENA */
3387#define ARIZONA_AIF1TX5_ENA_WIDTH 1 /* AIF1TX5_ENA */
3388#define ARIZONA_AIF1TX4_ENA 0x0008 /* AIF1TX4_ENA */
3389#define ARIZONA_AIF1TX4_ENA_MASK 0x0008 /* AIF1TX4_ENA */
3390#define ARIZONA_AIF1TX4_ENA_SHIFT 3 /* AIF1TX4_ENA */
3391#define ARIZONA_AIF1TX4_ENA_WIDTH 1 /* AIF1TX4_ENA */
3392#define ARIZONA_AIF1TX3_ENA 0x0004 /* AIF1TX3_ENA */
3393#define ARIZONA_AIF1TX3_ENA_MASK 0x0004 /* AIF1TX3_ENA */
3394#define ARIZONA_AIF1TX3_ENA_SHIFT 2 /* AIF1TX3_ENA */
3395#define ARIZONA_AIF1TX3_ENA_WIDTH 1 /* AIF1TX3_ENA */
3396#define ARIZONA_AIF1TX2_ENA 0x0002 /* AIF1TX2_ENA */
3397#define ARIZONA_AIF1TX2_ENA_MASK 0x0002 /* AIF1TX2_ENA */
3398#define ARIZONA_AIF1TX2_ENA_SHIFT 1 /* AIF1TX2_ENA */
3399#define ARIZONA_AIF1TX2_ENA_WIDTH 1 /* AIF1TX2_ENA */
3400#define ARIZONA_AIF1TX1_ENA 0x0001 /* AIF1TX1_ENA */
3401#define ARIZONA_AIF1TX1_ENA_MASK 0x0001 /* AIF1TX1_ENA */
3402#define ARIZONA_AIF1TX1_ENA_SHIFT 0 /* AIF1TX1_ENA */
3403#define ARIZONA_AIF1TX1_ENA_WIDTH 1 /* AIF1TX1_ENA */
3404
3405/*
3406 * R1306 (0x51A) - AIF1 Rx Enables
3407 */
3408#define ARIZONA_AIF1RX8_ENA 0x0080 /* AIF1RX8_ENA */
3409#define ARIZONA_AIF1RX8_ENA_MASK 0x0080 /* AIF1RX8_ENA */
3410#define ARIZONA_AIF1RX8_ENA_SHIFT 7 /* AIF1RX8_ENA */
3411#define ARIZONA_AIF1RX8_ENA_WIDTH 1 /* AIF1RX8_ENA */
3412#define ARIZONA_AIF1RX7_ENA 0x0040 /* AIF1RX7_ENA */
3413#define ARIZONA_AIF1RX7_ENA_MASK 0x0040 /* AIF1RX7_ENA */
3414#define ARIZONA_AIF1RX7_ENA_SHIFT 6 /* AIF1RX7_ENA */
3415#define ARIZONA_AIF1RX7_ENA_WIDTH 1 /* AIF1RX7_ENA */
3416#define ARIZONA_AIF1RX6_ENA 0x0020 /* AIF1RX6_ENA */
3417#define ARIZONA_AIF1RX6_ENA_MASK 0x0020 /* AIF1RX6_ENA */
3418#define ARIZONA_AIF1RX6_ENA_SHIFT 5 /* AIF1RX6_ENA */
3419#define ARIZONA_AIF1RX6_ENA_WIDTH 1 /* AIF1RX6_ENA */
3420#define ARIZONA_AIF1RX5_ENA 0x0010 /* AIF1RX5_ENA */
3421#define ARIZONA_AIF1RX5_ENA_MASK 0x0010 /* AIF1RX5_ENA */
3422#define ARIZONA_AIF1RX5_ENA_SHIFT 4 /* AIF1RX5_ENA */
3423#define ARIZONA_AIF1RX5_ENA_WIDTH 1 /* AIF1RX5_ENA */
3424#define ARIZONA_AIF1RX4_ENA 0x0008 /* AIF1RX4_ENA */
3425#define ARIZONA_AIF1RX4_ENA_MASK 0x0008 /* AIF1RX4_ENA */
3426#define ARIZONA_AIF1RX4_ENA_SHIFT 3 /* AIF1RX4_ENA */
3427#define ARIZONA_AIF1RX4_ENA_WIDTH 1 /* AIF1RX4_ENA */
3428#define ARIZONA_AIF1RX3_ENA 0x0004 /* AIF1RX3_ENA */
3429#define ARIZONA_AIF1RX3_ENA_MASK 0x0004 /* AIF1RX3_ENA */
3430#define ARIZONA_AIF1RX3_ENA_SHIFT 2 /* AIF1RX3_ENA */
3431#define ARIZONA_AIF1RX3_ENA_WIDTH 1 /* AIF1RX3_ENA */
3432#define ARIZONA_AIF1RX2_ENA 0x0002 /* AIF1RX2_ENA */
3433#define ARIZONA_AIF1RX2_ENA_MASK 0x0002 /* AIF1RX2_ENA */
3434#define ARIZONA_AIF1RX2_ENA_SHIFT 1 /* AIF1RX2_ENA */
3435#define ARIZONA_AIF1RX2_ENA_WIDTH 1 /* AIF1RX2_ENA */
3436#define ARIZONA_AIF1RX1_ENA 0x0001 /* AIF1RX1_ENA */
3437#define ARIZONA_AIF1RX1_ENA_MASK 0x0001 /* AIF1RX1_ENA */
3438#define ARIZONA_AIF1RX1_ENA_SHIFT 0 /* AIF1RX1_ENA */
3439#define ARIZONA_AIF1RX1_ENA_WIDTH 1 /* AIF1RX1_ENA */
3440
3441/*
3442 * R1307 (0x51B) - AIF1 Force Write
3443 */
3444#define ARIZONA_AIF1_FRC_WR 0x0001 /* AIF1_FRC_WR */
3445#define ARIZONA_AIF1_FRC_WR_MASK 0x0001 /* AIF1_FRC_WR */
3446#define ARIZONA_AIF1_FRC_WR_SHIFT 0 /* AIF1_FRC_WR */
3447#define ARIZONA_AIF1_FRC_WR_WIDTH 1 /* AIF1_FRC_WR */
3448
3449/*
3450 * R1344 (0x540) - AIF2 BCLK Ctrl
3451 */
3452#define ARIZONA_AIF2_BCLK_INV 0x0080 /* AIF2_BCLK_INV */
3453#define ARIZONA_AIF2_BCLK_INV_MASK 0x0080 /* AIF2_BCLK_INV */
3454#define ARIZONA_AIF2_BCLK_INV_SHIFT 7 /* AIF2_BCLK_INV */
3455#define ARIZONA_AIF2_BCLK_INV_WIDTH 1 /* AIF2_BCLK_INV */
3456#define ARIZONA_AIF2_BCLK_FRC 0x0040 /* AIF2_BCLK_FRC */
3457#define ARIZONA_AIF2_BCLK_FRC_MASK 0x0040 /* AIF2_BCLK_FRC */
3458#define ARIZONA_AIF2_BCLK_FRC_SHIFT 6 /* AIF2_BCLK_FRC */
3459#define ARIZONA_AIF2_BCLK_FRC_WIDTH 1 /* AIF2_BCLK_FRC */
3460#define ARIZONA_AIF2_BCLK_MSTR 0x0020 /* AIF2_BCLK_MSTR */
3461#define ARIZONA_AIF2_BCLK_MSTR_MASK 0x0020 /* AIF2_BCLK_MSTR */
3462#define ARIZONA_AIF2_BCLK_MSTR_SHIFT 5 /* AIF2_BCLK_MSTR */
3463#define ARIZONA_AIF2_BCLK_MSTR_WIDTH 1 /* AIF2_BCLK_MSTR */
3464#define ARIZONA_AIF2_BCLK_FREQ_MASK 0x001F /* AIF2_BCLK_FREQ - [4:0] */
3465#define ARIZONA_AIF2_BCLK_FREQ_SHIFT 0 /* AIF2_BCLK_FREQ - [4:0] */
3466#define ARIZONA_AIF2_BCLK_FREQ_WIDTH 5 /* AIF2_BCLK_FREQ - [4:0] */
3467
3468/*
3469 * R1345 (0x541) - AIF2 Tx Pin Ctrl
3470 */
3471#define ARIZONA_AIF2TX_DAT_TRI 0x0020 /* AIF2TX_DAT_TRI */
3472#define ARIZONA_AIF2TX_DAT_TRI_MASK 0x0020 /* AIF2TX_DAT_TRI */
3473#define ARIZONA_AIF2TX_DAT_TRI_SHIFT 5 /* AIF2TX_DAT_TRI */
3474#define ARIZONA_AIF2TX_DAT_TRI_WIDTH 1 /* AIF2TX_DAT_TRI */
3475#define ARIZONA_AIF2TX_LRCLK_SRC 0x0008 /* AIF2TX_LRCLK_SRC */
3476#define ARIZONA_AIF2TX_LRCLK_SRC_MASK 0x0008 /* AIF2TX_LRCLK_SRC */
3477#define ARIZONA_AIF2TX_LRCLK_SRC_SHIFT 3 /* AIF2TX_LRCLK_SRC */
3478#define ARIZONA_AIF2TX_LRCLK_SRC_WIDTH 1 /* AIF2TX_LRCLK_SRC */
3479#define ARIZONA_AIF2TX_LRCLK_INV 0x0004 /* AIF2TX_LRCLK_INV */
3480#define ARIZONA_AIF2TX_LRCLK_INV_MASK 0x0004 /* AIF2TX_LRCLK_INV */
3481#define ARIZONA_AIF2TX_LRCLK_INV_SHIFT 2 /* AIF2TX_LRCLK_INV */
3482#define ARIZONA_AIF2TX_LRCLK_INV_WIDTH 1 /* AIF2TX_LRCLK_INV */
3483#define ARIZONA_AIF2TX_LRCLK_FRC 0x0002 /* AIF2TX_LRCLK_FRC */
3484#define ARIZONA_AIF2TX_LRCLK_FRC_MASK 0x0002 /* AIF2TX_LRCLK_FRC */
3485#define ARIZONA_AIF2TX_LRCLK_FRC_SHIFT 1 /* AIF2TX_LRCLK_FRC */
3486#define ARIZONA_AIF2TX_LRCLK_FRC_WIDTH 1 /* AIF2TX_LRCLK_FRC */
3487#define ARIZONA_AIF2TX_LRCLK_MSTR 0x0001 /* AIF2TX_LRCLK_MSTR */
3488#define ARIZONA_AIF2TX_LRCLK_MSTR_MASK 0x0001 /* AIF2TX_LRCLK_MSTR */
3489#define ARIZONA_AIF2TX_LRCLK_MSTR_SHIFT 0 /* AIF2TX_LRCLK_MSTR */
3490#define ARIZONA_AIF2TX_LRCLK_MSTR_WIDTH 1 /* AIF2TX_LRCLK_MSTR */
3491
3492/*
3493 * R1346 (0x542) - AIF2 Rx Pin Ctrl
3494 */
3495#define ARIZONA_AIF2RX_LRCLK_INV 0x0004 /* AIF2RX_LRCLK_INV */
3496#define ARIZONA_AIF2RX_LRCLK_INV_MASK 0x0004 /* AIF2RX_LRCLK_INV */
3497#define ARIZONA_AIF2RX_LRCLK_INV_SHIFT 2 /* AIF2RX_LRCLK_INV */
3498#define ARIZONA_AIF2RX_LRCLK_INV_WIDTH 1 /* AIF2RX_LRCLK_INV */
3499#define ARIZONA_AIF2RX_LRCLK_FRC 0x0002 /* AIF2RX_LRCLK_FRC */
3500#define ARIZONA_AIF2RX_LRCLK_FRC_MASK 0x0002 /* AIF2RX_LRCLK_FRC */
3501#define ARIZONA_AIF2RX_LRCLK_FRC_SHIFT 1 /* AIF2RX_LRCLK_FRC */
3502#define ARIZONA_AIF2RX_LRCLK_FRC_WIDTH 1 /* AIF2RX_LRCLK_FRC */
3503#define ARIZONA_AIF2RX_LRCLK_MSTR 0x0001 /* AIF2RX_LRCLK_MSTR */
3504#define ARIZONA_AIF2RX_LRCLK_MSTR_MASK 0x0001 /* AIF2RX_LRCLK_MSTR */
3505#define ARIZONA_AIF2RX_LRCLK_MSTR_SHIFT 0 /* AIF2RX_LRCLK_MSTR */
3506#define ARIZONA_AIF2RX_LRCLK_MSTR_WIDTH 1 /* AIF2RX_LRCLK_MSTR */
3507
3508/*
3509 * R1347 (0x543) - AIF2 Rate Ctrl
3510 */
3511#define ARIZONA_AIF2_RATE_MASK 0x7800 /* AIF2_RATE - [14:11] */
3512#define ARIZONA_AIF2_RATE_SHIFT 11 /* AIF2_RATE - [14:11] */
3513#define ARIZONA_AIF2_RATE_WIDTH 4 /* AIF2_RATE - [14:11] */
3514#define ARIZONA_AIF2_TRI 0x0040 /* AIF2_TRI */
3515#define ARIZONA_AIF2_TRI_MASK 0x0040 /* AIF2_TRI */
3516#define ARIZONA_AIF2_TRI_SHIFT 6 /* AIF2_TRI */
3517#define ARIZONA_AIF2_TRI_WIDTH 1 /* AIF2_TRI */
3518
3519/*
3520 * R1348 (0x544) - AIF2 Format
3521 */
3522#define ARIZONA_AIF2_FMT_MASK 0x0007 /* AIF2_FMT - [2:0] */
3523#define ARIZONA_AIF2_FMT_SHIFT 0 /* AIF2_FMT - [2:0] */
3524#define ARIZONA_AIF2_FMT_WIDTH 3 /* AIF2_FMT - [2:0] */
3525
3526/*
3527 * R1349 (0x545) - AIF2 Tx BCLK Rate
3528 */
3529#define ARIZONA_AIF2TX_BCPF_MASK 0x1FFF /* AIF2TX_BCPF - [12:0] */
3530#define ARIZONA_AIF2TX_BCPF_SHIFT 0 /* AIF2TX_BCPF - [12:0] */
3531#define ARIZONA_AIF2TX_BCPF_WIDTH 13 /* AIF2TX_BCPF - [12:0] */
3532
3533/*
3534 * R1350 (0x546) - AIF2 Rx BCLK Rate
3535 */
3536#define ARIZONA_AIF2RX_BCPF_MASK 0x1FFF /* AIF2RX_BCPF - [12:0] */
3537#define ARIZONA_AIF2RX_BCPF_SHIFT 0 /* AIF2RX_BCPF - [12:0] */
3538#define ARIZONA_AIF2RX_BCPF_WIDTH 13 /* AIF2RX_BCPF - [12:0] */
3539
3540/*
3541 * R1351 (0x547) - AIF2 Frame Ctrl 1
3542 */
3543#define ARIZONA_AIF2TX_WL_MASK 0x3F00 /* AIF2TX_WL - [13:8] */
3544#define ARIZONA_AIF2TX_WL_SHIFT 8 /* AIF2TX_WL - [13:8] */
3545#define ARIZONA_AIF2TX_WL_WIDTH 6 /* AIF2TX_WL - [13:8] */
3546#define ARIZONA_AIF2TX_SLOT_LEN_MASK 0x00FF /* AIF2TX_SLOT_LEN - [7:0] */
3547#define ARIZONA_AIF2TX_SLOT_LEN_SHIFT 0 /* AIF2TX_SLOT_LEN - [7:0] */
3548#define ARIZONA_AIF2TX_SLOT_LEN_WIDTH 8 /* AIF2TX_SLOT_LEN - [7:0] */
3549
3550/*
3551 * R1352 (0x548) - AIF2 Frame Ctrl 2
3552 */
3553#define ARIZONA_AIF2RX_WL_MASK 0x3F00 /* AIF2RX_WL - [13:8] */
3554#define ARIZONA_AIF2RX_WL_SHIFT 8 /* AIF2RX_WL - [13:8] */
3555#define ARIZONA_AIF2RX_WL_WIDTH 6 /* AIF2RX_WL - [13:8] */
3556#define ARIZONA_AIF2RX_SLOT_LEN_MASK 0x00FF /* AIF2RX_SLOT_LEN - [7:0] */
3557#define ARIZONA_AIF2RX_SLOT_LEN_SHIFT 0 /* AIF2RX_SLOT_LEN - [7:0] */
3558#define ARIZONA_AIF2RX_SLOT_LEN_WIDTH 8 /* AIF2RX_SLOT_LEN - [7:0] */
3559
3560/*
3561 * R1353 (0x549) - AIF2 Frame Ctrl 3
3562 */
3563#define ARIZONA_AIF2TX1_SLOT_MASK 0x003F /* AIF2TX1_SLOT - [5:0] */
3564#define ARIZONA_AIF2TX1_SLOT_SHIFT 0 /* AIF2TX1_SLOT - [5:0] */
3565#define ARIZONA_AIF2TX1_SLOT_WIDTH 6 /* AIF2TX1_SLOT - [5:0] */
3566
3567/*
3568 * R1354 (0x54A) - AIF2 Frame Ctrl 4
3569 */
3570#define ARIZONA_AIF2TX2_SLOT_MASK 0x003F /* AIF2TX2_SLOT - [5:0] */
3571#define ARIZONA_AIF2TX2_SLOT_SHIFT 0 /* AIF2TX2_SLOT - [5:0] */
3572#define ARIZONA_AIF2TX2_SLOT_WIDTH 6 /* AIF2TX2_SLOT - [5:0] */
3573
3574/*
3575 * R1361 (0x551) - AIF2 Frame Ctrl 11
3576 */
3577#define ARIZONA_AIF2RX1_SLOT_MASK 0x003F /* AIF2RX1_SLOT - [5:0] */
3578#define ARIZONA_AIF2RX1_SLOT_SHIFT 0 /* AIF2RX1_SLOT - [5:0] */
3579#define ARIZONA_AIF2RX1_SLOT_WIDTH 6 /* AIF2RX1_SLOT - [5:0] */
3580
3581/*
3582 * R1362 (0x552) - AIF2 Frame Ctrl 12
3583 */
3584#define ARIZONA_AIF2RX2_SLOT_MASK 0x003F /* AIF2RX2_SLOT - [5:0] */
3585#define ARIZONA_AIF2RX2_SLOT_SHIFT 0 /* AIF2RX2_SLOT - [5:0] */
3586#define ARIZONA_AIF2RX2_SLOT_WIDTH 6 /* AIF2RX2_SLOT - [5:0] */
3587
3588/*
3589 * R1369 (0x559) - AIF2 Tx Enables
3590 */
3591#define ARIZONA_AIF2TX2_ENA 0x0002 /* AIF2TX2_ENA */
3592#define ARIZONA_AIF2TX2_ENA_MASK 0x0002 /* AIF2TX2_ENA */
3593#define ARIZONA_AIF2TX2_ENA_SHIFT 1 /* AIF2TX2_ENA */
3594#define ARIZONA_AIF2TX2_ENA_WIDTH 1 /* AIF2TX2_ENA */
3595#define ARIZONA_AIF2TX1_ENA 0x0001 /* AIF2TX1_ENA */
3596#define ARIZONA_AIF2TX1_ENA_MASK 0x0001 /* AIF2TX1_ENA */
3597#define ARIZONA_AIF2TX1_ENA_SHIFT 0 /* AIF2TX1_ENA */
3598#define ARIZONA_AIF2TX1_ENA_WIDTH 1 /* AIF2TX1_ENA */
3599
3600/*
3601 * R1370 (0x55A) - AIF2 Rx Enables
3602 */
3603#define ARIZONA_AIF2RX2_ENA 0x0002 /* AIF2RX2_ENA */
3604#define ARIZONA_AIF2RX2_ENA_MASK 0x0002 /* AIF2RX2_ENA */
3605#define ARIZONA_AIF2RX2_ENA_SHIFT 1 /* AIF2RX2_ENA */
3606#define ARIZONA_AIF2RX2_ENA_WIDTH 1 /* AIF2RX2_ENA */
3607#define ARIZONA_AIF2RX1_ENA 0x0001 /* AIF2RX1_ENA */
3608#define ARIZONA_AIF2RX1_ENA_MASK 0x0001 /* AIF2RX1_ENA */
3609#define ARIZONA_AIF2RX1_ENA_SHIFT 0 /* AIF2RX1_ENA */
3610#define ARIZONA_AIF2RX1_ENA_WIDTH 1 /* AIF2RX1_ENA */
3611
3612/*
3613 * R1371 (0x55B) - AIF2 Force Write
3614 */
3615#define ARIZONA_AIF2_FRC_WR 0x0001 /* AIF2_FRC_WR */
3616#define ARIZONA_AIF2_FRC_WR_MASK 0x0001 /* AIF2_FRC_WR */
3617#define ARIZONA_AIF2_FRC_WR_SHIFT 0 /* AIF2_FRC_WR */
3618#define ARIZONA_AIF2_FRC_WR_WIDTH 1 /* AIF2_FRC_WR */
3619
3620/*
3621 * R1408 (0x580) - AIF3 BCLK Ctrl
3622 */
3623#define ARIZONA_AIF3_BCLK_INV 0x0080 /* AIF3_BCLK_INV */
3624#define ARIZONA_AIF3_BCLK_INV_MASK 0x0080 /* AIF3_BCLK_INV */
3625#define ARIZONA_AIF3_BCLK_INV_SHIFT 7 /* AIF3_BCLK_INV */
3626#define ARIZONA_AIF3_BCLK_INV_WIDTH 1 /* AIF3_BCLK_INV */
3627#define ARIZONA_AIF3_BCLK_FRC 0x0040 /* AIF3_BCLK_FRC */
3628#define ARIZONA_AIF3_BCLK_FRC_MASK 0x0040 /* AIF3_BCLK_FRC */
3629#define ARIZONA_AIF3_BCLK_FRC_SHIFT 6 /* AIF3_BCLK_FRC */
3630#define ARIZONA_AIF3_BCLK_FRC_WIDTH 1 /* AIF3_BCLK_FRC */
3631#define ARIZONA_AIF3_BCLK_MSTR 0x0020 /* AIF3_BCLK_MSTR */
3632#define ARIZONA_AIF3_BCLK_MSTR_MASK 0x0020 /* AIF3_BCLK_MSTR */
3633#define ARIZONA_AIF3_BCLK_MSTR_SHIFT 5 /* AIF3_BCLK_MSTR */
3634#define ARIZONA_AIF3_BCLK_MSTR_WIDTH 1 /* AIF3_BCLK_MSTR */
3635#define ARIZONA_AIF3_BCLK_FREQ_MASK 0x001F /* AIF3_BCLK_FREQ - [4:0] */
3636#define ARIZONA_AIF3_BCLK_FREQ_SHIFT 0 /* AIF3_BCLK_FREQ - [4:0] */
3637#define ARIZONA_AIF3_BCLK_FREQ_WIDTH 5 /* AIF3_BCLK_FREQ - [4:0] */
3638
3639/*
3640 * R1409 (0x581) - AIF3 Tx Pin Ctrl
3641 */
3642#define ARIZONA_AIF3TX_DAT_TRI 0x0020 /* AIF3TX_DAT_TRI */
3643#define ARIZONA_AIF3TX_DAT_TRI_MASK 0x0020 /* AIF3TX_DAT_TRI */
3644#define ARIZONA_AIF3TX_DAT_TRI_SHIFT 5 /* AIF3TX_DAT_TRI */
3645#define ARIZONA_AIF3TX_DAT_TRI_WIDTH 1 /* AIF3TX_DAT_TRI */
3646#define ARIZONA_AIF3TX_LRCLK_SRC 0x0008 /* AIF3TX_LRCLK_SRC */
3647#define ARIZONA_AIF3TX_LRCLK_SRC_MASK 0x0008 /* AIF3TX_LRCLK_SRC */
3648#define ARIZONA_AIF3TX_LRCLK_SRC_SHIFT 3 /* AIF3TX_LRCLK_SRC */
3649#define ARIZONA_AIF3TX_LRCLK_SRC_WIDTH 1 /* AIF3TX_LRCLK_SRC */
3650#define ARIZONA_AIF3TX_LRCLK_INV 0x0004 /* AIF3TX_LRCLK_INV */
3651#define ARIZONA_AIF3TX_LRCLK_INV_MASK 0x0004 /* AIF3TX_LRCLK_INV */
3652#define ARIZONA_AIF3TX_LRCLK_INV_SHIFT 2 /* AIF3TX_LRCLK_INV */
3653#define ARIZONA_AIF3TX_LRCLK_INV_WIDTH 1 /* AIF3TX_LRCLK_INV */
3654#define ARIZONA_AIF3TX_LRCLK_FRC 0x0002 /* AIF3TX_LRCLK_FRC */
3655#define ARIZONA_AIF3TX_LRCLK_FRC_MASK 0x0002 /* AIF3TX_LRCLK_FRC */
3656#define ARIZONA_AIF3TX_LRCLK_FRC_SHIFT 1 /* AIF3TX_LRCLK_FRC */
3657#define ARIZONA_AIF3TX_LRCLK_FRC_WIDTH 1 /* AIF3TX_LRCLK_FRC */
3658#define ARIZONA_AIF3TX_LRCLK_MSTR 0x0001 /* AIF3TX_LRCLK_MSTR */
3659#define ARIZONA_AIF3TX_LRCLK_MSTR_MASK 0x0001 /* AIF3TX_LRCLK_MSTR */
3660#define ARIZONA_AIF3TX_LRCLK_MSTR_SHIFT 0 /* AIF3TX_LRCLK_MSTR */
3661#define ARIZONA_AIF3TX_LRCLK_MSTR_WIDTH 1 /* AIF3TX_LRCLK_MSTR */
3662
3663/*
3664 * R1410 (0x582) - AIF3 Rx Pin Ctrl
3665 */
3666#define ARIZONA_AIF3RX_LRCLK_INV 0x0004 /* AIF3RX_LRCLK_INV */
3667#define ARIZONA_AIF3RX_LRCLK_INV_MASK 0x0004 /* AIF3RX_LRCLK_INV */
3668#define ARIZONA_AIF3RX_LRCLK_INV_SHIFT 2 /* AIF3RX_LRCLK_INV */
3669#define ARIZONA_AIF3RX_LRCLK_INV_WIDTH 1 /* AIF3RX_LRCLK_INV */
3670#define ARIZONA_AIF3RX_LRCLK_FRC 0x0002 /* AIF3RX_LRCLK_FRC */
3671#define ARIZONA_AIF3RX_LRCLK_FRC_MASK 0x0002 /* AIF3RX_LRCLK_FRC */
3672#define ARIZONA_AIF3RX_LRCLK_FRC_SHIFT 1 /* AIF3RX_LRCLK_FRC */
3673#define ARIZONA_AIF3RX_LRCLK_FRC_WIDTH 1 /* AIF3RX_LRCLK_FRC */
3674#define ARIZONA_AIF3RX_LRCLK_MSTR 0x0001 /* AIF3RX_LRCLK_MSTR */
3675#define ARIZONA_AIF3RX_LRCLK_MSTR_MASK 0x0001 /* AIF3RX_LRCLK_MSTR */
3676#define ARIZONA_AIF3RX_LRCLK_MSTR_SHIFT 0 /* AIF3RX_LRCLK_MSTR */
3677#define ARIZONA_AIF3RX_LRCLK_MSTR_WIDTH 1 /* AIF3RX_LRCLK_MSTR */
3678
3679/*
3680 * R1411 (0x583) - AIF3 Rate Ctrl
3681 */
3682#define ARIZONA_AIF3_RATE_MASK 0x7800 /* AIF3_RATE - [14:11] */
3683#define ARIZONA_AIF3_RATE_SHIFT 11 /* AIF3_RATE - [14:11] */
3684#define ARIZONA_AIF3_RATE_WIDTH 4 /* AIF3_RATE - [14:11] */
3685#define ARIZONA_AIF3_TRI 0x0040 /* AIF3_TRI */
3686#define ARIZONA_AIF3_TRI_MASK 0x0040 /* AIF3_TRI */
3687#define ARIZONA_AIF3_TRI_SHIFT 6 /* AIF3_TRI */
3688#define ARIZONA_AIF3_TRI_WIDTH 1 /* AIF3_TRI */
3689
3690/*
3691 * R1412 (0x584) - AIF3 Format
3692 */
3693#define ARIZONA_AIF3_FMT_MASK 0x0007 /* AIF3_FMT - [2:0] */
3694#define ARIZONA_AIF3_FMT_SHIFT 0 /* AIF3_FMT - [2:0] */
3695#define ARIZONA_AIF3_FMT_WIDTH 3 /* AIF3_FMT - [2:0] */
3696
3697/*
3698 * R1413 (0x585) - AIF3 Tx BCLK Rate
3699 */
3700#define ARIZONA_AIF3TX_BCPF_MASK 0x1FFF /* AIF3TX_BCPF - [12:0] */
3701#define ARIZONA_AIF3TX_BCPF_SHIFT 0 /* AIF3TX_BCPF - [12:0] */
3702#define ARIZONA_AIF3TX_BCPF_WIDTH 13 /* AIF3TX_BCPF - [12:0] */
3703
3704/*
3705 * R1414 (0x586) - AIF3 Rx BCLK Rate
3706 */
3707#define ARIZONA_AIF3RX_BCPF_MASK 0x1FFF /* AIF3RX_BCPF - [12:0] */
3708#define ARIZONA_AIF3RX_BCPF_SHIFT 0 /* AIF3RX_BCPF - [12:0] */
3709#define ARIZONA_AIF3RX_BCPF_WIDTH 13 /* AIF3RX_BCPF - [12:0] */
3710
3711/*
3712 * R1415 (0x587) - AIF3 Frame Ctrl 1
3713 */
3714#define ARIZONA_AIF3TX_WL_MASK 0x3F00 /* AIF3TX_WL - [13:8] */
3715#define ARIZONA_AIF3TX_WL_SHIFT 8 /* AIF3TX_WL - [13:8] */
3716#define ARIZONA_AIF3TX_WL_WIDTH 6 /* AIF3TX_WL - [13:8] */
3717#define ARIZONA_AIF3TX_SLOT_LEN_MASK 0x00FF /* AIF3TX_SLOT_LEN - [7:0] */
3718#define ARIZONA_AIF3TX_SLOT_LEN_SHIFT 0 /* AIF3TX_SLOT_LEN - [7:0] */
3719#define ARIZONA_AIF3TX_SLOT_LEN_WIDTH 8 /* AIF3TX_SLOT_LEN - [7:0] */
3720
3721/*
3722 * R1416 (0x588) - AIF3 Frame Ctrl 2
3723 */
3724#define ARIZONA_AIF3RX_WL_MASK 0x3F00 /* AIF3RX_WL - [13:8] */
3725#define ARIZONA_AIF3RX_WL_SHIFT 8 /* AIF3RX_WL - [13:8] */
3726#define ARIZONA_AIF3RX_WL_WIDTH 6 /* AIF3RX_WL - [13:8] */
3727#define ARIZONA_AIF3RX_SLOT_LEN_MASK 0x00FF /* AIF3RX_SLOT_LEN - [7:0] */
3728#define ARIZONA_AIF3RX_SLOT_LEN_SHIFT 0 /* AIF3RX_SLOT_LEN - [7:0] */
3729#define ARIZONA_AIF3RX_SLOT_LEN_WIDTH 8 /* AIF3RX_SLOT_LEN - [7:0] */
3730
3731/*
3732 * R1417 (0x589) - AIF3 Frame Ctrl 3
3733 */
3734#define ARIZONA_AIF3TX1_SLOT_MASK 0x003F /* AIF3TX1_SLOT - [5:0] */
3735#define ARIZONA_AIF3TX1_SLOT_SHIFT 0 /* AIF3TX1_SLOT - [5:0] */
3736#define ARIZONA_AIF3TX1_SLOT_WIDTH 6 /* AIF3TX1_SLOT - [5:0] */
3737
3738/*
3739 * R1418 (0x58A) - AIF3 Frame Ctrl 4
3740 */
3741#define ARIZONA_AIF3TX2_SLOT_MASK 0x003F /* AIF3TX2_SLOT - [5:0] */
3742#define ARIZONA_AIF3TX2_SLOT_SHIFT 0 /* AIF3TX2_SLOT - [5:0] */
3743#define ARIZONA_AIF3TX2_SLOT_WIDTH 6 /* AIF3TX2_SLOT - [5:0] */
3744
3745/*
3746 * R1425 (0x591) - AIF3 Frame Ctrl 11
3747 */
3748#define ARIZONA_AIF3RX1_SLOT_MASK 0x003F /* AIF3RX1_SLOT - [5:0] */
3749#define ARIZONA_AIF3RX1_SLOT_SHIFT 0 /* AIF3RX1_SLOT - [5:0] */
3750#define ARIZONA_AIF3RX1_SLOT_WIDTH 6 /* AIF3RX1_SLOT - [5:0] */
3751
3752/*
3753 * R1426 (0x592) - AIF3 Frame Ctrl 12
3754 */
3755#define ARIZONA_AIF3RX2_SLOT_MASK 0x003F /* AIF3RX2_SLOT - [5:0] */
3756#define ARIZONA_AIF3RX2_SLOT_SHIFT 0 /* AIF3RX2_SLOT - [5:0] */
3757#define ARIZONA_AIF3RX2_SLOT_WIDTH 6 /* AIF3RX2_SLOT - [5:0] */
3758
3759/*
3760 * R1433 (0x599) - AIF3 Tx Enables
3761 */
3762#define ARIZONA_AIF3TX2_ENA 0x0002 /* AIF3TX2_ENA */
3763#define ARIZONA_AIF3TX2_ENA_MASK 0x0002 /* AIF3TX2_ENA */
3764#define ARIZONA_AIF3TX2_ENA_SHIFT 1 /* AIF3TX2_ENA */
3765#define ARIZONA_AIF3TX2_ENA_WIDTH 1 /* AIF3TX2_ENA */
3766#define ARIZONA_AIF3TX1_ENA 0x0001 /* AIF3TX1_ENA */
3767#define ARIZONA_AIF3TX1_ENA_MASK 0x0001 /* AIF3TX1_ENA */
3768#define ARIZONA_AIF3TX1_ENA_SHIFT 0 /* AIF3TX1_ENA */
3769#define ARIZONA_AIF3TX1_ENA_WIDTH 1 /* AIF3TX1_ENA */
3770
3771/*
3772 * R1434 (0x59A) - AIF3 Rx Enables
3773 */
3774#define ARIZONA_AIF3RX2_ENA 0x0002 /* AIF3RX2_ENA */
3775#define ARIZONA_AIF3RX2_ENA_MASK 0x0002 /* AIF3RX2_ENA */
3776#define ARIZONA_AIF3RX2_ENA_SHIFT 1 /* AIF3RX2_ENA */
3777#define ARIZONA_AIF3RX2_ENA_WIDTH 1 /* AIF3RX2_ENA */
3778#define ARIZONA_AIF3RX1_ENA 0x0001 /* AIF3RX1_ENA */
3779#define ARIZONA_AIF3RX1_ENA_MASK 0x0001 /* AIF3RX1_ENA */
3780#define ARIZONA_AIF3RX1_ENA_SHIFT 0 /* AIF3RX1_ENA */
3781#define ARIZONA_AIF3RX1_ENA_WIDTH 1 /* AIF3RX1_ENA */
3782
3783/*
3784 * R1435 (0x59B) - AIF3 Force Write
3785 */
3786#define ARIZONA_AIF3_FRC_WR 0x0001 /* AIF3_FRC_WR */
3787#define ARIZONA_AIF3_FRC_WR_MASK 0x0001 /* AIF3_FRC_WR */
3788#define ARIZONA_AIF3_FRC_WR_SHIFT 0 /* AIF3_FRC_WR */
3789#define ARIZONA_AIF3_FRC_WR_WIDTH 1 /* AIF3_FRC_WR */
3790
3791/*
3792 * R1507 (0x5E3) - SLIMbus Framer Ref Gear
3793 */
3794#define ARIZONA_SLIMCLK_SRC 0x0010 /* SLIMCLK_SRC */
3795#define ARIZONA_SLIMCLK_SRC_MASK 0x0010 /* SLIMCLK_SRC */
3796#define ARIZONA_SLIMCLK_SRC_SHIFT 4 /* SLIMCLK_SRC */
3797#define ARIZONA_SLIMCLK_SRC_WIDTH 1 /* SLIMCLK_SRC */
3798#define ARIZONA_FRAMER_REF_GEAR_MASK 0x000F /* FRAMER_REF_GEAR - [3:0] */
3799#define ARIZONA_FRAMER_REF_GEAR_SHIFT 0 /* FRAMER_REF_GEAR - [3:0] */
3800#define ARIZONA_FRAMER_REF_GEAR_WIDTH 4 /* FRAMER_REF_GEAR - [3:0] */
3801
3802/*
3803 * R1509 (0x5E5) - SLIMbus Rates 1
3804 */
3805#define ARIZONA_SLIMRX2_RATE_MASK 0x7800 /* SLIMRX2_RATE - [14:11] */
3806#define ARIZONA_SLIMRX2_RATE_SHIFT 11 /* SLIMRX2_RATE - [14:11] */
3807#define ARIZONA_SLIMRX2_RATE_WIDTH 4 /* SLIMRX2_RATE - [14:11] */
3808#define ARIZONA_SLIMRX1_RATE_MASK 0x0078 /* SLIMRX1_RATE - [6:3] */
3809#define ARIZONA_SLIMRX1_RATE_SHIFT 3 /* SLIMRX1_RATE - [6:3] */
3810#define ARIZONA_SLIMRX1_RATE_WIDTH 4 /* SLIMRX1_RATE - [6:3] */
3811
3812/*
3813 * R1510 (0x5E6) - SLIMbus Rates 2
3814 */
3815#define ARIZONA_SLIMRX4_RATE_MASK 0x7800 /* SLIMRX4_RATE - [14:11] */
3816#define ARIZONA_SLIMRX4_RATE_SHIFT 11 /* SLIMRX4_RATE - [14:11] */
3817#define ARIZONA_SLIMRX4_RATE_WIDTH 4 /* SLIMRX4_RATE - [14:11] */
3818#define ARIZONA_SLIMRX3_RATE_MASK 0x0078 /* SLIMRX3_RATE - [6:3] */
3819#define ARIZONA_SLIMRX3_RATE_SHIFT 3 /* SLIMRX3_RATE - [6:3] */
3820#define ARIZONA_SLIMRX3_RATE_WIDTH 4 /* SLIMRX3_RATE - [6:3] */
3821
3822/*
3823 * R1511 (0x5E7) - SLIMbus Rates 3
3824 */
3825#define ARIZONA_SLIMRX6_RATE_MASK 0x7800 /* SLIMRX6_RATE - [14:11] */
3826#define ARIZONA_SLIMRX6_RATE_SHIFT 11 /* SLIMRX6_RATE - [14:11] */
3827#define ARIZONA_SLIMRX6_RATE_WIDTH 4 /* SLIMRX6_RATE - [14:11] */
3828#define ARIZONA_SLIMRX5_RATE_MASK 0x0078 /* SLIMRX5_RATE - [6:3] */
3829#define ARIZONA_SLIMRX5_RATE_SHIFT 3 /* SLIMRX5_RATE - [6:3] */
3830#define ARIZONA_SLIMRX5_RATE_WIDTH 4 /* SLIMRX5_RATE - [6:3] */
3831
3832/*
3833 * R1512 (0x5E8) - SLIMbus Rates 4
3834 */
3835#define ARIZONA_SLIMRX8_RATE_MASK 0x7800 /* SLIMRX8_RATE - [14:11] */
3836#define ARIZONA_SLIMRX8_RATE_SHIFT 11 /* SLIMRX8_RATE - [14:11] */
3837#define ARIZONA_SLIMRX8_RATE_WIDTH 4 /* SLIMRX8_RATE - [14:11] */
3838#define ARIZONA_SLIMRX7_RATE_MASK 0x0078 /* SLIMRX7_RATE - [6:3] */
3839#define ARIZONA_SLIMRX7_RATE_SHIFT 3 /* SLIMRX7_RATE - [6:3] */
3840#define ARIZONA_SLIMRX7_RATE_WIDTH 4 /* SLIMRX7_RATE - [6:3] */
3841
3842/*
3843 * R1513 (0x5E9) - SLIMbus Rates 5
3844 */
3845#define ARIZONA_SLIMTX2_RATE_MASK 0x7800 /* SLIMTX2_RATE - [14:11] */
3846#define ARIZONA_SLIMTX2_RATE_SHIFT 11 /* SLIMTX2_RATE - [14:11] */
3847#define ARIZONA_SLIMTX2_RATE_WIDTH 4 /* SLIMTX2_RATE - [14:11] */
3848#define ARIZONA_SLIMTX1_RATE_MASK 0x0078 /* SLIMTX1_RATE - [6:3] */
3849#define ARIZONA_SLIMTX1_RATE_SHIFT 3 /* SLIMTX1_RATE - [6:3] */
3850#define ARIZONA_SLIMTX1_RATE_WIDTH 4 /* SLIMTX1_RATE - [6:3] */
3851
3852/*
3853 * R1514 (0x5EA) - SLIMbus Rates 6
3854 */
3855#define ARIZONA_SLIMTX4_RATE_MASK 0x7800 /* SLIMTX4_RATE - [14:11] */
3856#define ARIZONA_SLIMTX4_RATE_SHIFT 11 /* SLIMTX4_RATE - [14:11] */
3857#define ARIZONA_SLIMTX4_RATE_WIDTH 4 /* SLIMTX4_RATE - [14:11] */
3858#define ARIZONA_SLIMTX3_RATE_MASK 0x0078 /* SLIMTX3_RATE - [6:3] */
3859#define ARIZONA_SLIMTX3_RATE_SHIFT 3 /* SLIMTX3_RATE - [6:3] */
3860#define ARIZONA_SLIMTX3_RATE_WIDTH 4 /* SLIMTX3_RATE - [6:3] */
3861
3862/*
3863 * R1515 (0x5EB) - SLIMbus Rates 7
3864 */
3865#define ARIZONA_SLIMTX6_RATE_MASK 0x7800 /* SLIMTX6_RATE - [14:11] */
3866#define ARIZONA_SLIMTX6_RATE_SHIFT 11 /* SLIMTX6_RATE - [14:11] */
3867#define ARIZONA_SLIMTX6_RATE_WIDTH 4 /* SLIMTX6_RATE - [14:11] */
3868#define ARIZONA_SLIMTX5_RATE_MASK 0x0078 /* SLIMTX5_RATE - [6:3] */
3869#define ARIZONA_SLIMTX5_RATE_SHIFT 3 /* SLIMTX5_RATE - [6:3] */
3870#define ARIZONA_SLIMTX5_RATE_WIDTH 4 /* SLIMTX5_RATE - [6:3] */
3871
3872/*
3873 * R1516 (0x5EC) - SLIMbus Rates 8
3874 */
3875#define ARIZONA_SLIMTX8_RATE_MASK 0x7800 /* SLIMTX8_RATE - [14:11] */
3876#define ARIZONA_SLIMTX8_RATE_SHIFT 11 /* SLIMTX8_RATE - [14:11] */
3877#define ARIZONA_SLIMTX8_RATE_WIDTH 4 /* SLIMTX8_RATE - [14:11] */
3878#define ARIZONA_SLIMTX7_RATE_MASK 0x0078 /* SLIMTX7_RATE - [6:3] */
3879#define ARIZONA_SLIMTX7_RATE_SHIFT 3 /* SLIMTX7_RATE - [6:3] */
3880#define ARIZONA_SLIMTX7_RATE_WIDTH 4 /* SLIMTX7_RATE - [6:3] */
3881
3882/*
3883 * R1525 (0x5F5) - SLIMbus RX Channel Enable
3884 */
3885#define ARIZONA_SLIMRX8_ENA 0x0080 /* SLIMRX8_ENA */
3886#define ARIZONA_SLIMRX8_ENA_MASK 0x0080 /* SLIMRX8_ENA */
3887#define ARIZONA_SLIMRX8_ENA_SHIFT 7 /* SLIMRX8_ENA */
3888#define ARIZONA_SLIMRX8_ENA_WIDTH 1 /* SLIMRX8_ENA */
3889#define ARIZONA_SLIMRX7_ENA 0x0040 /* SLIMRX7_ENA */
3890#define ARIZONA_SLIMRX7_ENA_MASK 0x0040 /* SLIMRX7_ENA */
3891#define ARIZONA_SLIMRX7_ENA_SHIFT 6 /* SLIMRX7_ENA */
3892#define ARIZONA_SLIMRX7_ENA_WIDTH 1 /* SLIMRX7_ENA */
3893#define ARIZONA_SLIMRX6_ENA 0x0020 /* SLIMRX6_ENA */
3894#define ARIZONA_SLIMRX6_ENA_MASK 0x0020 /* SLIMRX6_ENA */
3895#define ARIZONA_SLIMRX6_ENA_SHIFT 5 /* SLIMRX6_ENA */
3896#define ARIZONA_SLIMRX6_ENA_WIDTH 1 /* SLIMRX6_ENA */
3897#define ARIZONA_SLIMRX5_ENA 0x0010 /* SLIMRX5_ENA */
3898#define ARIZONA_SLIMRX5_ENA_MASK 0x0010 /* SLIMRX5_ENA */
3899#define ARIZONA_SLIMRX5_ENA_SHIFT 4 /* SLIMRX5_ENA */
3900#define ARIZONA_SLIMRX5_ENA_WIDTH 1 /* SLIMRX5_ENA */
3901#define ARIZONA_SLIMRX4_ENA 0x0008 /* SLIMRX4_ENA */
3902#define ARIZONA_SLIMRX4_ENA_MASK 0x0008 /* SLIMRX4_ENA */
3903#define ARIZONA_SLIMRX4_ENA_SHIFT 3 /* SLIMRX4_ENA */
3904#define ARIZONA_SLIMRX4_ENA_WIDTH 1 /* SLIMRX4_ENA */
3905#define ARIZONA_SLIMRX3_ENA 0x0004 /* SLIMRX3_ENA */
3906#define ARIZONA_SLIMRX3_ENA_MASK 0x0004 /* SLIMRX3_ENA */
3907#define ARIZONA_SLIMRX3_ENA_SHIFT 2 /* SLIMRX3_ENA */
3908#define ARIZONA_SLIMRX3_ENA_WIDTH 1 /* SLIMRX3_ENA */
3909#define ARIZONA_SLIMRX2_ENA 0x0002 /* SLIMRX2_ENA */
3910#define ARIZONA_SLIMRX2_ENA_MASK 0x0002 /* SLIMRX2_ENA */
3911#define ARIZONA_SLIMRX2_ENA_SHIFT 1 /* SLIMRX2_ENA */
3912#define ARIZONA_SLIMRX2_ENA_WIDTH 1 /* SLIMRX2_ENA */
3913#define ARIZONA_SLIMRX1_ENA 0x0001 /* SLIMRX1_ENA */
3914#define ARIZONA_SLIMRX1_ENA_MASK 0x0001 /* SLIMRX1_ENA */
3915#define ARIZONA_SLIMRX1_ENA_SHIFT 0 /* SLIMRX1_ENA */
3916#define ARIZONA_SLIMRX1_ENA_WIDTH 1 /* SLIMRX1_ENA */
3917
3918/*
3919 * R1526 (0x5F6) - SLIMbus TX Channel Enable
3920 */
3921#define ARIZONA_SLIMTX8_ENA 0x0080 /* SLIMTX8_ENA */
3922#define ARIZONA_SLIMTX8_ENA_MASK 0x0080 /* SLIMTX8_ENA */
3923#define ARIZONA_SLIMTX8_ENA_SHIFT 7 /* SLIMTX8_ENA */
3924#define ARIZONA_SLIMTX8_ENA_WIDTH 1 /* SLIMTX8_ENA */
3925#define ARIZONA_SLIMTX7_ENA 0x0040 /* SLIMTX7_ENA */
3926#define ARIZONA_SLIMTX7_ENA_MASK 0x0040 /* SLIMTX7_ENA */
3927#define ARIZONA_SLIMTX7_ENA_SHIFT 6 /* SLIMTX7_ENA */
3928#define ARIZONA_SLIMTX7_ENA_WIDTH 1 /* SLIMTX7_ENA */
3929#define ARIZONA_SLIMTX6_ENA 0x0020 /* SLIMTX6_ENA */
3930#define ARIZONA_SLIMTX6_ENA_MASK 0x0020 /* SLIMTX6_ENA */
3931#define ARIZONA_SLIMTX6_ENA_SHIFT 5 /* SLIMTX6_ENA */
3932#define ARIZONA_SLIMTX6_ENA_WIDTH 1 /* SLIMTX6_ENA */
3933#define ARIZONA_SLIMTX5_ENA 0x0010 /* SLIMTX5_ENA */
3934#define ARIZONA_SLIMTX5_ENA_MASK 0x0010 /* SLIMTX5_ENA */
3935#define ARIZONA_SLIMTX5_ENA_SHIFT 4 /* SLIMTX5_ENA */
3936#define ARIZONA_SLIMTX5_ENA_WIDTH 1 /* SLIMTX5_ENA */
3937#define ARIZONA_SLIMTX4_ENA 0x0008 /* SLIMTX4_ENA */
3938#define ARIZONA_SLIMTX4_ENA_MASK 0x0008 /* SLIMTX4_ENA */
3939#define ARIZONA_SLIMTX4_ENA_SHIFT 3 /* SLIMTX4_ENA */
3940#define ARIZONA_SLIMTX4_ENA_WIDTH 1 /* SLIMTX4_ENA */
3941#define ARIZONA_SLIMTX3_ENA 0x0004 /* SLIMTX3_ENA */
3942#define ARIZONA_SLIMTX3_ENA_MASK 0x0004 /* SLIMTX3_ENA */
3943#define ARIZONA_SLIMTX3_ENA_SHIFT 2 /* SLIMTX3_ENA */
3944#define ARIZONA_SLIMTX3_ENA_WIDTH 1 /* SLIMTX3_ENA */
3945#define ARIZONA_SLIMTX2_ENA 0x0002 /* SLIMTX2_ENA */
3946#define ARIZONA_SLIMTX2_ENA_MASK 0x0002 /* SLIMTX2_ENA */
3947#define ARIZONA_SLIMTX2_ENA_SHIFT 1 /* SLIMTX2_ENA */
3948#define ARIZONA_SLIMTX2_ENA_WIDTH 1 /* SLIMTX2_ENA */
3949#define ARIZONA_SLIMTX1_ENA 0x0001 /* SLIMTX1_ENA */
3950#define ARIZONA_SLIMTX1_ENA_MASK 0x0001 /* SLIMTX1_ENA */
3951#define ARIZONA_SLIMTX1_ENA_SHIFT 0 /* SLIMTX1_ENA */
3952#define ARIZONA_SLIMTX1_ENA_WIDTH 1 /* SLIMTX1_ENA */
3953
3954/*
3955 * R1527 (0x5F7) - SLIMbus RX Port Status
3956 */
3957#define ARIZONA_SLIMRX8_PORT_STS 0x0080 /* SLIMRX8_PORT_STS */
3958#define ARIZONA_SLIMRX8_PORT_STS_MASK 0x0080 /* SLIMRX8_PORT_STS */
3959#define ARIZONA_SLIMRX8_PORT_STS_SHIFT 7 /* SLIMRX8_PORT_STS */
3960#define ARIZONA_SLIMRX8_PORT_STS_WIDTH 1 /* SLIMRX8_PORT_STS */
3961#define ARIZONA_SLIMRX7_PORT_STS 0x0040 /* SLIMRX7_PORT_STS */
3962#define ARIZONA_SLIMRX7_PORT_STS_MASK 0x0040 /* SLIMRX7_PORT_STS */
3963#define ARIZONA_SLIMRX7_PORT_STS_SHIFT 6 /* SLIMRX7_PORT_STS */
3964#define ARIZONA_SLIMRX7_PORT_STS_WIDTH 1 /* SLIMRX7_PORT_STS */
3965#define ARIZONA_SLIMRX6_PORT_STS 0x0020 /* SLIMRX6_PORT_STS */
3966#define ARIZONA_SLIMRX6_PORT_STS_MASK 0x0020 /* SLIMRX6_PORT_STS */
3967#define ARIZONA_SLIMRX6_PORT_STS_SHIFT 5 /* SLIMRX6_PORT_STS */
3968#define ARIZONA_SLIMRX6_PORT_STS_WIDTH 1 /* SLIMRX6_PORT_STS */
3969#define ARIZONA_SLIMRX5_PORT_STS 0x0010 /* SLIMRX5_PORT_STS */
3970#define ARIZONA_SLIMRX5_PORT_STS_MASK 0x0010 /* SLIMRX5_PORT_STS */
3971#define ARIZONA_SLIMRX5_PORT_STS_SHIFT 4 /* SLIMRX5_PORT_STS */
3972#define ARIZONA_SLIMRX5_PORT_STS_WIDTH 1 /* SLIMRX5_PORT_STS */
3973#define ARIZONA_SLIMRX4_PORT_STS 0x0008 /* SLIMRX4_PORT_STS */
3974#define ARIZONA_SLIMRX4_PORT_STS_MASK 0x0008 /* SLIMRX4_PORT_STS */
3975#define ARIZONA_SLIMRX4_PORT_STS_SHIFT 3 /* SLIMRX4_PORT_STS */
3976#define ARIZONA_SLIMRX4_PORT_STS_WIDTH 1 /* SLIMRX4_PORT_STS */
3977#define ARIZONA_SLIMRX3_PORT_STS 0x0004 /* SLIMRX3_PORT_STS */
3978#define ARIZONA_SLIMRX3_PORT_STS_MASK 0x0004 /* SLIMRX3_PORT_STS */
3979#define ARIZONA_SLIMRX3_PORT_STS_SHIFT 2 /* SLIMRX3_PORT_STS */
3980#define ARIZONA_SLIMRX3_PORT_STS_WIDTH 1 /* SLIMRX3_PORT_STS */
3981#define ARIZONA_SLIMRX2_PORT_STS 0x0002 /* SLIMRX2_PORT_STS */
3982#define ARIZONA_SLIMRX2_PORT_STS_MASK 0x0002 /* SLIMRX2_PORT_STS */
3983#define ARIZONA_SLIMRX2_PORT_STS_SHIFT 1 /* SLIMRX2_PORT_STS */
3984#define ARIZONA_SLIMRX2_PORT_STS_WIDTH 1 /* SLIMRX2_PORT_STS */
3985#define ARIZONA_SLIMRX1_PORT_STS 0x0001 /* SLIMRX1_PORT_STS */
3986#define ARIZONA_SLIMRX1_PORT_STS_MASK 0x0001 /* SLIMRX1_PORT_STS */
3987#define ARIZONA_SLIMRX1_PORT_STS_SHIFT 0 /* SLIMRX1_PORT_STS */
3988#define ARIZONA_SLIMRX1_PORT_STS_WIDTH 1 /* SLIMRX1_PORT_STS */
3989
3990/*
3991 * R1528 (0x5F8) - SLIMbus TX Port Status
3992 */
3993#define ARIZONA_SLIMTX8_PORT_STS 0x0080 /* SLIMTX8_PORT_STS */
3994#define ARIZONA_SLIMTX8_PORT_STS_MASK 0x0080 /* SLIMTX8_PORT_STS */
3995#define ARIZONA_SLIMTX8_PORT_STS_SHIFT 7 /* SLIMTX8_PORT_STS */
3996#define ARIZONA_SLIMTX8_PORT_STS_WIDTH 1 /* SLIMTX8_PORT_STS */
3997#define ARIZONA_SLIMTX7_PORT_STS 0x0040 /* SLIMTX7_PORT_STS */
3998#define ARIZONA_SLIMTX7_PORT_STS_MASK 0x0040 /* SLIMTX7_PORT_STS */
3999#define ARIZONA_SLIMTX7_PORT_STS_SHIFT 6 /* SLIMTX7_PORT_STS */
4000#define ARIZONA_SLIMTX7_PORT_STS_WIDTH 1 /* SLIMTX7_PORT_STS */
4001#define ARIZONA_SLIMTX6_PORT_STS 0x0020 /* SLIMTX6_PORT_STS */
4002#define ARIZONA_SLIMTX6_PORT_STS_MASK 0x0020 /* SLIMTX6_PORT_STS */
4003#define ARIZONA_SLIMTX6_PORT_STS_SHIFT 5 /* SLIMTX6_PORT_STS */
4004#define ARIZONA_SLIMTX6_PORT_STS_WIDTH 1 /* SLIMTX6_PORT_STS */
4005#define ARIZONA_SLIMTX5_PORT_STS 0x0010 /* SLIMTX5_PORT_STS */
4006#define ARIZONA_SLIMTX5_PORT_STS_MASK 0x0010 /* SLIMTX5_PORT_STS */
4007#define ARIZONA_SLIMTX5_PORT_STS_SHIFT 4 /* SLIMTX5_PORT_STS */
4008#define ARIZONA_SLIMTX5_PORT_STS_WIDTH 1 /* SLIMTX5_PORT_STS */
4009#define ARIZONA_SLIMTX4_PORT_STS 0x0008 /* SLIMTX4_PORT_STS */
4010#define ARIZONA_SLIMTX4_PORT_STS_MASK 0x0008 /* SLIMTX4_PORT_STS */
4011#define ARIZONA_SLIMTX4_PORT_STS_SHIFT 3 /* SLIMTX4_PORT_STS */
4012#define ARIZONA_SLIMTX4_PORT_STS_WIDTH 1 /* SLIMTX4_PORT_STS */
4013#define ARIZONA_SLIMTX3_PORT_STS 0x0004 /* SLIMTX3_PORT_STS */
4014#define ARIZONA_SLIMTX3_PORT_STS_MASK 0x0004 /* SLIMTX3_PORT_STS */
4015#define ARIZONA_SLIMTX3_PORT_STS_SHIFT 2 /* SLIMTX3_PORT_STS */
4016#define ARIZONA_SLIMTX3_PORT_STS_WIDTH 1 /* SLIMTX3_PORT_STS */
4017#define ARIZONA_SLIMTX2_PORT_STS 0x0002 /* SLIMTX2_PORT_STS */
4018#define ARIZONA_SLIMTX2_PORT_STS_MASK 0x0002 /* SLIMTX2_PORT_STS */
4019#define ARIZONA_SLIMTX2_PORT_STS_SHIFT 1 /* SLIMTX2_PORT_STS */
4020#define ARIZONA_SLIMTX2_PORT_STS_WIDTH 1 /* SLIMTX2_PORT_STS */
4021#define ARIZONA_SLIMTX1_PORT_STS 0x0001 /* SLIMTX1_PORT_STS */
4022#define ARIZONA_SLIMTX1_PORT_STS_MASK 0x0001 /* SLIMTX1_PORT_STS */
4023#define ARIZONA_SLIMTX1_PORT_STS_SHIFT 0 /* SLIMTX1_PORT_STS */
4024#define ARIZONA_SLIMTX1_PORT_STS_WIDTH 1 /* SLIMTX1_PORT_STS */
4025
4026/*
4027 * R3087 (0xC0F) - IRQ CTRL 1
4028 */
4029#define ARIZONA_IRQ_POL 0x0400 /* IRQ_POL */
4030#define ARIZONA_IRQ_POL_MASK 0x0400 /* IRQ_POL */
4031#define ARIZONA_IRQ_POL_SHIFT 10 /* IRQ_POL */
4032#define ARIZONA_IRQ_POL_WIDTH 1 /* IRQ_POL */
4033#define ARIZONA_IRQ_OP_CFG 0x0200 /* IRQ_OP_CFG */
4034#define ARIZONA_IRQ_OP_CFG_MASK 0x0200 /* IRQ_OP_CFG */
4035#define ARIZONA_IRQ_OP_CFG_SHIFT 9 /* IRQ_OP_CFG */
4036#define ARIZONA_IRQ_OP_CFG_WIDTH 1 /* IRQ_OP_CFG */
4037
4038/*
4039 * R3088 (0xC10) - GPIO Debounce Config
4040 */
4041#define ARIZONA_GP_DBTIME_MASK 0xF000 /* GP_DBTIME - [15:12] */
4042#define ARIZONA_GP_DBTIME_SHIFT 12 /* GP_DBTIME - [15:12] */
4043#define ARIZONA_GP_DBTIME_WIDTH 4 /* GP_DBTIME - [15:12] */
4044
4045/*
4046 * R3104 (0xC20) - Misc Pad Ctrl 1
4047 */
4048#define ARIZONA_LDO1ENA_PD 0x8000 /* LDO1ENA_PD */
4049#define ARIZONA_LDO1ENA_PD_MASK 0x8000 /* LDO1ENA_PD */
4050#define ARIZONA_LDO1ENA_PD_SHIFT 15 /* LDO1ENA_PD */
4051#define ARIZONA_LDO1ENA_PD_WIDTH 1 /* LDO1ENA_PD */
4052#define ARIZONA_MCLK2_PD 0x2000 /* MCLK2_PD */
4053#define ARIZONA_MCLK2_PD_MASK 0x2000 /* MCLK2_PD */
4054#define ARIZONA_MCLK2_PD_SHIFT 13 /* MCLK2_PD */
4055#define ARIZONA_MCLK2_PD_WIDTH 1 /* MCLK2_PD */
4056#define ARIZONA_RSTB_PU 0x0002 /* RSTB_PU */
4057#define ARIZONA_RSTB_PU_MASK 0x0002 /* RSTB_PU */
4058#define ARIZONA_RSTB_PU_SHIFT 1 /* RSTB_PU */
4059#define ARIZONA_RSTB_PU_WIDTH 1 /* RSTB_PU */
4060
4061/*
4062 * R3105 (0xC21) - Misc Pad Ctrl 2
4063 */
4064#define ARIZONA_MCLK1_PD 0x1000 /* MCLK1_PD */
4065#define ARIZONA_MCLK1_PD_MASK 0x1000 /* MCLK1_PD */
4066#define ARIZONA_MCLK1_PD_SHIFT 12 /* MCLK1_PD */
4067#define ARIZONA_MCLK1_PD_WIDTH 1 /* MCLK1_PD */
4068#define ARIZONA_MICD_PD 0x0100 /* MICD_PD */
4069#define ARIZONA_MICD_PD_MASK 0x0100 /* MICD_PD */
4070#define ARIZONA_MICD_PD_SHIFT 8 /* MICD_PD */
4071#define ARIZONA_MICD_PD_WIDTH 1 /* MICD_PD */
4072#define ARIZONA_ADDR_PD 0x0001 /* ADDR_PD */
4073#define ARIZONA_ADDR_PD_MASK 0x0001 /* ADDR_PD */
4074#define ARIZONA_ADDR_PD_SHIFT 0 /* ADDR_PD */
4075#define ARIZONA_ADDR_PD_WIDTH 1 /* ADDR_PD */
4076
4077/*
4078 * R3106 (0xC22) - Misc Pad Ctrl 3
4079 */
4080#define ARIZONA_DMICDAT4_PD 0x0008 /* DMICDAT4_PD */
4081#define ARIZONA_DMICDAT4_PD_MASK 0x0008 /* DMICDAT4_PD */
4082#define ARIZONA_DMICDAT4_PD_SHIFT 3 /* DMICDAT4_PD */
4083#define ARIZONA_DMICDAT4_PD_WIDTH 1 /* DMICDAT4_PD */
4084#define ARIZONA_DMICDAT3_PD 0x0004 /* DMICDAT3_PD */
4085#define ARIZONA_DMICDAT3_PD_MASK 0x0004 /* DMICDAT3_PD */
4086#define ARIZONA_DMICDAT3_PD_SHIFT 2 /* DMICDAT3_PD */
4087#define ARIZONA_DMICDAT3_PD_WIDTH 1 /* DMICDAT3_PD */
4088#define ARIZONA_DMICDAT2_PD 0x0002 /* DMICDAT2_PD */
4089#define ARIZONA_DMICDAT2_PD_MASK 0x0002 /* DMICDAT2_PD */
4090#define ARIZONA_DMICDAT2_PD_SHIFT 1 /* DMICDAT2_PD */
4091#define ARIZONA_DMICDAT2_PD_WIDTH 1 /* DMICDAT2_PD */
4092#define ARIZONA_DMICDAT1_PD 0x0001 /* DMICDAT1_PD */
4093#define ARIZONA_DMICDAT1_PD_MASK 0x0001 /* DMICDAT1_PD */
4094#define ARIZONA_DMICDAT1_PD_SHIFT 0 /* DMICDAT1_PD */
4095#define ARIZONA_DMICDAT1_PD_WIDTH 1 /* DMICDAT1_PD */
4096
4097/*
4098 * R3107 (0xC23) - Misc Pad Ctrl 4
4099 */
4100#define ARIZONA_AIF1RXLRCLK_PU 0x0020 /* AIF1RXLRCLK_PU */
4101#define ARIZONA_AIF1RXLRCLK_PU_MASK 0x0020 /* AIF1RXLRCLK_PU */
4102#define ARIZONA_AIF1RXLRCLK_PU_SHIFT 5 /* AIF1RXLRCLK_PU */
4103#define ARIZONA_AIF1RXLRCLK_PU_WIDTH 1 /* AIF1RXLRCLK_PU */
4104#define ARIZONA_AIF1RXLRCLK_PD 0x0010 /* AIF1RXLRCLK_PD */
4105#define ARIZONA_AIF1RXLRCLK_PD_MASK 0x0010 /* AIF1RXLRCLK_PD */
4106#define ARIZONA_AIF1RXLRCLK_PD_SHIFT 4 /* AIF1RXLRCLK_PD */
4107#define ARIZONA_AIF1RXLRCLK_PD_WIDTH 1 /* AIF1RXLRCLK_PD */
4108#define ARIZONA_AIF1BCLK_PU 0x0008 /* AIF1BCLK_PU */
4109#define ARIZONA_AIF1BCLK_PU_MASK 0x0008 /* AIF1BCLK_PU */
4110#define ARIZONA_AIF1BCLK_PU_SHIFT 3 /* AIF1BCLK_PU */
4111#define ARIZONA_AIF1BCLK_PU_WIDTH 1 /* AIF1BCLK_PU */
4112#define ARIZONA_AIF1BCLK_PD 0x0004 /* AIF1BCLK_PD */
4113#define ARIZONA_AIF1BCLK_PD_MASK 0x0004 /* AIF1BCLK_PD */
4114#define ARIZONA_AIF1BCLK_PD_SHIFT 2 /* AIF1BCLK_PD */
4115#define ARIZONA_AIF1BCLK_PD_WIDTH 1 /* AIF1BCLK_PD */
4116#define ARIZONA_AIF1RXDAT_PU 0x0002 /* AIF1RXDAT_PU */
4117#define ARIZONA_AIF1RXDAT_PU_MASK 0x0002 /* AIF1RXDAT_PU */
4118#define ARIZONA_AIF1RXDAT_PU_SHIFT 1 /* AIF1RXDAT_PU */
4119#define ARIZONA_AIF1RXDAT_PU_WIDTH 1 /* AIF1RXDAT_PU */
4120#define ARIZONA_AIF1RXDAT_PD 0x0001 /* AIF1RXDAT_PD */
4121#define ARIZONA_AIF1RXDAT_PD_MASK 0x0001 /* AIF1RXDAT_PD */
4122#define ARIZONA_AIF1RXDAT_PD_SHIFT 0 /* AIF1RXDAT_PD */
4123#define ARIZONA_AIF1RXDAT_PD_WIDTH 1 /* AIF1RXDAT_PD */
4124
4125/*
4126 * R3108 (0xC24) - Misc Pad Ctrl 5
4127 */
4128#define ARIZONA_AIF2RXLRCLK_PU 0x0020 /* AIF2RXLRCLK_PU */
4129#define ARIZONA_AIF2RXLRCLK_PU_MASK 0x0020 /* AIF2RXLRCLK_PU */
4130#define ARIZONA_AIF2RXLRCLK_PU_SHIFT 5 /* AIF2RXLRCLK_PU */
4131#define ARIZONA_AIF2RXLRCLK_PU_WIDTH 1 /* AIF2RXLRCLK_PU */
4132#define ARIZONA_AIF2RXLRCLK_PD 0x0010 /* AIF2RXLRCLK_PD */
4133#define ARIZONA_AIF2RXLRCLK_PD_MASK 0x0010 /* AIF2RXLRCLK_PD */
4134#define ARIZONA_AIF2RXLRCLK_PD_SHIFT 4 /* AIF2RXLRCLK_PD */
4135#define ARIZONA_AIF2RXLRCLK_PD_WIDTH 1 /* AIF2RXLRCLK_PD */
4136#define ARIZONA_AIF2BCLK_PU 0x0008 /* AIF2BCLK_PU */
4137#define ARIZONA_AIF2BCLK_PU_MASK 0x0008 /* AIF2BCLK_PU */
4138#define ARIZONA_AIF2BCLK_PU_SHIFT 3 /* AIF2BCLK_PU */
4139#define ARIZONA_AIF2BCLK_PU_WIDTH 1 /* AIF2BCLK_PU */
4140#define ARIZONA_AIF2BCLK_PD 0x0004 /* AIF2BCLK_PD */
4141#define ARIZONA_AIF2BCLK_PD_MASK 0x0004 /* AIF2BCLK_PD */
4142#define ARIZONA_AIF2BCLK_PD_SHIFT 2 /* AIF2BCLK_PD */
4143#define ARIZONA_AIF2BCLK_PD_WIDTH 1 /* AIF2BCLK_PD */
4144#define ARIZONA_AIF2RXDAT_PU 0x0002 /* AIF2RXDAT_PU */
4145#define ARIZONA_AIF2RXDAT_PU_MASK 0x0002 /* AIF2RXDAT_PU */
4146#define ARIZONA_AIF2RXDAT_PU_SHIFT 1 /* AIF2RXDAT_PU */
4147#define ARIZONA_AIF2RXDAT_PU_WIDTH 1 /* AIF2RXDAT_PU */
4148#define ARIZONA_AIF2RXDAT_PD 0x0001 /* AIF2RXDAT_PD */
4149#define ARIZONA_AIF2RXDAT_PD_MASK 0x0001 /* AIF2RXDAT_PD */
4150#define ARIZONA_AIF2RXDAT_PD_SHIFT 0 /* AIF2RXDAT_PD */
4151#define ARIZONA_AIF2RXDAT_PD_WIDTH 1 /* AIF2RXDAT_PD */
4152
4153/*
4154 * R3109 (0xC25) - Misc Pad Ctrl 6
4155 */
4156#define ARIZONA_AIF3RXLRCLK_PU 0x0020 /* AIF3RXLRCLK_PU */
4157#define ARIZONA_AIF3RXLRCLK_PU_MASK 0x0020 /* AIF3RXLRCLK_PU */
4158#define ARIZONA_AIF3RXLRCLK_PU_SHIFT 5 /* AIF3RXLRCLK_PU */
4159#define ARIZONA_AIF3RXLRCLK_PU_WIDTH 1 /* AIF3RXLRCLK_PU */
4160#define ARIZONA_AIF3RXLRCLK_PD 0x0010 /* AIF3RXLRCLK_PD */
4161#define ARIZONA_AIF3RXLRCLK_PD_MASK 0x0010 /* AIF3RXLRCLK_PD */
4162#define ARIZONA_AIF3RXLRCLK_PD_SHIFT 4 /* AIF3RXLRCLK_PD */
4163#define ARIZONA_AIF3RXLRCLK_PD_WIDTH 1 /* AIF3RXLRCLK_PD */
4164#define ARIZONA_AIF3BCLK_PU 0x0008 /* AIF3BCLK_PU */
4165#define ARIZONA_AIF3BCLK_PU_MASK 0x0008 /* AIF3BCLK_PU */
4166#define ARIZONA_AIF3BCLK_PU_SHIFT 3 /* AIF3BCLK_PU */
4167#define ARIZONA_AIF3BCLK_PU_WIDTH 1 /* AIF3BCLK_PU */
4168#define ARIZONA_AIF3BCLK_PD 0x0004 /* AIF3BCLK_PD */
4169#define ARIZONA_AIF3BCLK_PD_MASK 0x0004 /* AIF3BCLK_PD */
4170#define ARIZONA_AIF3BCLK_PD_SHIFT 2 /* AIF3BCLK_PD */
4171#define ARIZONA_AIF3BCLK_PD_WIDTH 1 /* AIF3BCLK_PD */
4172#define ARIZONA_AIF3RXDAT_PU 0x0002 /* AIF3RXDAT_PU */
4173#define ARIZONA_AIF3RXDAT_PU_MASK 0x0002 /* AIF3RXDAT_PU */
4174#define ARIZONA_AIF3RXDAT_PU_SHIFT 1 /* AIF3RXDAT_PU */
4175#define ARIZONA_AIF3RXDAT_PU_WIDTH 1 /* AIF3RXDAT_PU */
4176#define ARIZONA_AIF3RXDAT_PD 0x0001 /* AIF3RXDAT_PD */
4177#define ARIZONA_AIF3RXDAT_PD_MASK 0x0001 /* AIF3RXDAT_PD */
4178#define ARIZONA_AIF3RXDAT_PD_SHIFT 0 /* AIF3RXDAT_PD */
4179#define ARIZONA_AIF3RXDAT_PD_WIDTH 1 /* AIF3RXDAT_PD */
4180
4181/*
4182 * R3328 (0xD00) - Interrupt Status 1
4183 */
4184#define ARIZONA_GP4_EINT1 0x0008 /* GP4_EINT1 */
4185#define ARIZONA_GP4_EINT1_MASK 0x0008 /* GP4_EINT1 */
4186#define ARIZONA_GP4_EINT1_SHIFT 3 /* GP4_EINT1 */
4187#define ARIZONA_GP4_EINT1_WIDTH 1 /* GP4_EINT1 */
4188#define ARIZONA_GP3_EINT1 0x0004 /* GP3_EINT1 */
4189#define ARIZONA_GP3_EINT1_MASK 0x0004 /* GP3_EINT1 */
4190#define ARIZONA_GP3_EINT1_SHIFT 2 /* GP3_EINT1 */
4191#define ARIZONA_GP3_EINT1_WIDTH 1 /* GP3_EINT1 */
4192#define ARIZONA_GP2_EINT1 0x0002 /* GP2_EINT1 */
4193#define ARIZONA_GP2_EINT1_MASK 0x0002 /* GP2_EINT1 */
4194#define ARIZONA_GP2_EINT1_SHIFT 1 /* GP2_EINT1 */
4195#define ARIZONA_GP2_EINT1_WIDTH 1 /* GP2_EINT1 */
4196#define ARIZONA_GP1_EINT1 0x0001 /* GP1_EINT1 */
4197#define ARIZONA_GP1_EINT1_MASK 0x0001 /* GP1_EINT1 */
4198#define ARIZONA_GP1_EINT1_SHIFT 0 /* GP1_EINT1 */
4199#define ARIZONA_GP1_EINT1_WIDTH 1 /* GP1_EINT1 */
4200
4201/*
4202 * R3329 (0xD01) - Interrupt Status 2
4203 */
4204#define ARIZONA_DSP4_RAM_RDY_EINT1 0x0800 /* DSP4_RAM_RDY_EINT1 */
4205#define ARIZONA_DSP4_RAM_RDY_EINT1_MASK 0x0800 /* DSP4_RAM_RDY_EINT1 */
4206#define ARIZONA_DSP4_RAM_RDY_EINT1_SHIFT 11 /* DSP4_RAM_RDY_EINT1 */
4207#define ARIZONA_DSP4_RAM_RDY_EINT1_WIDTH 1 /* DSP4_RAM_RDY_EINT1 */
4208#define ARIZONA_DSP3_RAM_RDY_EINT1 0x0400 /* DSP3_RAM_RDY_EINT1 */
4209#define ARIZONA_DSP3_RAM_RDY_EINT1_MASK 0x0400 /* DSP3_RAM_RDY_EINT1 */
4210#define ARIZONA_DSP3_RAM_RDY_EINT1_SHIFT 10 /* DSP3_RAM_RDY_EINT1 */
4211#define ARIZONA_DSP3_RAM_RDY_EINT1_WIDTH 1 /* DSP3_RAM_RDY_EINT1 */
4212#define ARIZONA_DSP2_RAM_RDY_EINT1 0x0200 /* DSP2_RAM_RDY_EINT1 */
4213#define ARIZONA_DSP2_RAM_RDY_EINT1_MASK 0x0200 /* DSP2_RAM_RDY_EINT1 */
4214#define ARIZONA_DSP2_RAM_RDY_EINT1_SHIFT 9 /* DSP2_RAM_RDY_EINT1 */
4215#define ARIZONA_DSP2_RAM_RDY_EINT1_WIDTH 1 /* DSP2_RAM_RDY_EINT1 */
4216#define ARIZONA_DSP1_RAM_RDY_EINT1 0x0100 /* DSP1_RAM_RDY_EINT1 */
4217#define ARIZONA_DSP1_RAM_RDY_EINT1_MASK 0x0100 /* DSP1_RAM_RDY_EINT1 */
4218#define ARIZONA_DSP1_RAM_RDY_EINT1_SHIFT 8 /* DSP1_RAM_RDY_EINT1 */
4219#define ARIZONA_DSP1_RAM_RDY_EINT1_WIDTH 1 /* DSP1_RAM_RDY_EINT1 */
4220#define ARIZONA_DSP_IRQ8_EINT1 0x0080 /* DSP_IRQ8_EINT1 */
4221#define ARIZONA_DSP_IRQ8_EINT1_MASK 0x0080 /* DSP_IRQ8_EINT1 */
4222#define ARIZONA_DSP_IRQ8_EINT1_SHIFT 7 /* DSP_IRQ8_EINT1 */
4223#define ARIZONA_DSP_IRQ8_EINT1_WIDTH 1 /* DSP_IRQ8_EINT1 */
4224#define ARIZONA_DSP_IRQ7_EINT1 0x0040 /* DSP_IRQ7_EINT1 */
4225#define ARIZONA_DSP_IRQ7_EINT1_MASK 0x0040 /* DSP_IRQ7_EINT1 */
4226#define ARIZONA_DSP_IRQ7_EINT1_SHIFT 6 /* DSP_IRQ7_EINT1 */
4227#define ARIZONA_DSP_IRQ7_EINT1_WIDTH 1 /* DSP_IRQ7_EINT1 */
4228#define ARIZONA_DSP_IRQ6_EINT1 0x0020 /* DSP_IRQ6_EINT1 */
4229#define ARIZONA_DSP_IRQ6_EINT1_MASK 0x0020 /* DSP_IRQ6_EINT1 */
4230#define ARIZONA_DSP_IRQ6_EINT1_SHIFT 5 /* DSP_IRQ6_EINT1 */
4231#define ARIZONA_DSP_IRQ6_EINT1_WIDTH 1 /* DSP_IRQ6_EINT1 */
4232#define ARIZONA_DSP_IRQ5_EINT1 0x0010 /* DSP_IRQ5_EINT1 */
4233#define ARIZONA_DSP_IRQ5_EINT1_MASK 0x0010 /* DSP_IRQ5_EINT1 */
4234#define ARIZONA_DSP_IRQ5_EINT1_SHIFT 4 /* DSP_IRQ5_EINT1 */
4235#define ARIZONA_DSP_IRQ5_EINT1_WIDTH 1 /* DSP_IRQ5_EINT1 */
4236#define ARIZONA_DSP_IRQ4_EINT1 0x0008 /* DSP_IRQ4_EINT1 */
4237#define ARIZONA_DSP_IRQ4_EINT1_MASK 0x0008 /* DSP_IRQ4_EINT1 */
4238#define ARIZONA_DSP_IRQ4_EINT1_SHIFT 3 /* DSP_IRQ4_EINT1 */
4239#define ARIZONA_DSP_IRQ4_EINT1_WIDTH 1 /* DSP_IRQ4_EINT1 */
4240#define ARIZONA_DSP_IRQ3_EINT1 0x0004 /* DSP_IRQ3_EINT1 */
4241#define ARIZONA_DSP_IRQ3_EINT1_MASK 0x0004 /* DSP_IRQ3_EINT1 */
4242#define ARIZONA_DSP_IRQ3_EINT1_SHIFT 2 /* DSP_IRQ3_EINT1 */
4243#define ARIZONA_DSP_IRQ3_EINT1_WIDTH 1 /* DSP_IRQ3_EINT1 */
4244#define ARIZONA_DSP_IRQ2_EINT1 0x0002 /* DSP_IRQ2_EINT1 */
4245#define ARIZONA_DSP_IRQ2_EINT1_MASK 0x0002 /* DSP_IRQ2_EINT1 */
4246#define ARIZONA_DSP_IRQ2_EINT1_SHIFT 1 /* DSP_IRQ2_EINT1 */
4247#define ARIZONA_DSP_IRQ2_EINT1_WIDTH 1 /* DSP_IRQ2_EINT1 */
4248#define ARIZONA_DSP_IRQ1_EINT1 0x0001 /* DSP_IRQ1_EINT1 */
4249#define ARIZONA_DSP_IRQ1_EINT1_MASK 0x0001 /* DSP_IRQ1_EINT1 */
4250#define ARIZONA_DSP_IRQ1_EINT1_SHIFT 0 /* DSP_IRQ1_EINT1 */
4251#define ARIZONA_DSP_IRQ1_EINT1_WIDTH 1 /* DSP_IRQ1_EINT1 */
4252
4253/*
4254 * R3330 (0xD02) - Interrupt Status 3
4255 */
4256#define ARIZONA_SPK_SHUTDOWN_WARN_EINT1 0x8000 /* SPK_SHUTDOWN_WARN_EINT1 */
4257#define ARIZONA_SPK_SHUTDOWN_WARN_EINT1_MASK 0x8000 /* SPK_SHUTDOWN_WARN_EINT1 */
4258#define ARIZONA_SPK_SHUTDOWN_WARN_EINT1_SHIFT 15 /* SPK_SHUTDOWN_WARN_EINT1 */
4259#define ARIZONA_SPK_SHUTDOWN_WARN_EINT1_WIDTH 1 /* SPK_SHUTDOWN_WARN_EINT1 */
4260#define ARIZONA_SPK_SHUTDOWN_EINT1 0x4000 /* SPK_SHUTDOWN_EINT1 */
4261#define ARIZONA_SPK_SHUTDOWN_EINT1_MASK 0x4000 /* SPK_SHUTDOWN_EINT1 */
4262#define ARIZONA_SPK_SHUTDOWN_EINT1_SHIFT 14 /* SPK_SHUTDOWN_EINT1 */
4263#define ARIZONA_SPK_SHUTDOWN_EINT1_WIDTH 1 /* SPK_SHUTDOWN_EINT1 */
4264#define ARIZONA_HPDET_EINT1 0x2000 /* HPDET_EINT1 */
4265#define ARIZONA_HPDET_EINT1_MASK 0x2000 /* HPDET_EINT1 */
4266#define ARIZONA_HPDET_EINT1_SHIFT 13 /* HPDET_EINT1 */
4267#define ARIZONA_HPDET_EINT1_WIDTH 1 /* HPDET_EINT1 */
4268#define ARIZONA_MICDET_EINT1 0x1000 /* MICDET_EINT1 */
4269#define ARIZONA_MICDET_EINT1_MASK 0x1000 /* MICDET_EINT1 */
4270#define ARIZONA_MICDET_EINT1_SHIFT 12 /* MICDET_EINT1 */
4271#define ARIZONA_MICDET_EINT1_WIDTH 1 /* MICDET_EINT1 */
4272#define ARIZONA_WSEQ_DONE_EINT1 0x0800 /* WSEQ_DONE_EINT1 */
4273#define ARIZONA_WSEQ_DONE_EINT1_MASK 0x0800 /* WSEQ_DONE_EINT1 */
4274#define ARIZONA_WSEQ_DONE_EINT1_SHIFT 11 /* WSEQ_DONE_EINT1 */
4275#define ARIZONA_WSEQ_DONE_EINT1_WIDTH 1 /* WSEQ_DONE_EINT1 */
4276#define ARIZONA_DRC2_SIG_DET_EINT1 0x0400 /* DRC2_SIG_DET_EINT1 */
4277#define ARIZONA_DRC2_SIG_DET_EINT1_MASK 0x0400 /* DRC2_SIG_DET_EINT1 */
4278#define ARIZONA_DRC2_SIG_DET_EINT1_SHIFT 10 /* DRC2_SIG_DET_EINT1 */
4279#define ARIZONA_DRC2_SIG_DET_EINT1_WIDTH 1 /* DRC2_SIG_DET_EINT1 */
4280#define ARIZONA_DRC1_SIG_DET_EINT1 0x0200 /* DRC1_SIG_DET_EINT1 */
4281#define ARIZONA_DRC1_SIG_DET_EINT1_MASK 0x0200 /* DRC1_SIG_DET_EINT1 */
4282#define ARIZONA_DRC1_SIG_DET_EINT1_SHIFT 9 /* DRC1_SIG_DET_EINT1 */
4283#define ARIZONA_DRC1_SIG_DET_EINT1_WIDTH 1 /* DRC1_SIG_DET_EINT1 */
4284#define ARIZONA_ASRC2_LOCK_EINT1 0x0100 /* ASRC2_LOCK_EINT1 */
4285#define ARIZONA_ASRC2_LOCK_EINT1_MASK 0x0100 /* ASRC2_LOCK_EINT1 */
4286#define ARIZONA_ASRC2_LOCK_EINT1_SHIFT 8 /* ASRC2_LOCK_EINT1 */
4287#define ARIZONA_ASRC2_LOCK_EINT1_WIDTH 1 /* ASRC2_LOCK_EINT1 */
4288#define ARIZONA_ASRC1_LOCK_EINT1 0x0080 /* ASRC1_LOCK_EINT1 */
4289#define ARIZONA_ASRC1_LOCK_EINT1_MASK 0x0080 /* ASRC1_LOCK_EINT1 */
4290#define ARIZONA_ASRC1_LOCK_EINT1_SHIFT 7 /* ASRC1_LOCK_EINT1 */
4291#define ARIZONA_ASRC1_LOCK_EINT1_WIDTH 1 /* ASRC1_LOCK_EINT1 */
4292#define ARIZONA_UNDERCLOCKED_EINT1 0x0040 /* UNDERCLOCKED_EINT1 */
4293#define ARIZONA_UNDERCLOCKED_EINT1_MASK 0x0040 /* UNDERCLOCKED_EINT1 */
4294#define ARIZONA_UNDERCLOCKED_EINT1_SHIFT 6 /* UNDERCLOCKED_EINT1 */
4295#define ARIZONA_UNDERCLOCKED_EINT1_WIDTH 1 /* UNDERCLOCKED_EINT1 */
4296#define ARIZONA_OVERCLOCKED_EINT1 0x0020 /* OVERCLOCKED_EINT1 */
4297#define ARIZONA_OVERCLOCKED_EINT1_MASK 0x0020 /* OVERCLOCKED_EINT1 */
4298#define ARIZONA_OVERCLOCKED_EINT1_SHIFT 5 /* OVERCLOCKED_EINT1 */
4299#define ARIZONA_OVERCLOCKED_EINT1_WIDTH 1 /* OVERCLOCKED_EINT1 */
4300#define ARIZONA_FLL2_LOCK_EINT1 0x0008 /* FLL2_LOCK_EINT1 */
4301#define ARIZONA_FLL2_LOCK_EINT1_MASK 0x0008 /* FLL2_LOCK_EINT1 */
4302#define ARIZONA_FLL2_LOCK_EINT1_SHIFT 3 /* FLL2_LOCK_EINT1 */
4303#define ARIZONA_FLL2_LOCK_EINT1_WIDTH 1 /* FLL2_LOCK_EINT1 */
4304#define ARIZONA_FLL1_LOCK_EINT1 0x0004 /* FLL1_LOCK_EINT1 */
4305#define ARIZONA_FLL1_LOCK_EINT1_MASK 0x0004 /* FLL1_LOCK_EINT1 */
4306#define ARIZONA_FLL1_LOCK_EINT1_SHIFT 2 /* FLL1_LOCK_EINT1 */
4307#define ARIZONA_FLL1_LOCK_EINT1_WIDTH 1 /* FLL1_LOCK_EINT1 */
4308#define ARIZONA_CLKGEN_ERR_EINT1 0x0002 /* CLKGEN_ERR_EINT1 */
4309#define ARIZONA_CLKGEN_ERR_EINT1_MASK 0x0002 /* CLKGEN_ERR_EINT1 */
4310#define ARIZONA_CLKGEN_ERR_EINT1_SHIFT 1 /* CLKGEN_ERR_EINT1 */
4311#define ARIZONA_CLKGEN_ERR_EINT1_WIDTH 1 /* CLKGEN_ERR_EINT1 */
4312#define ARIZONA_CLKGEN_ERR_ASYNC_EINT1 0x0001 /* CLKGEN_ERR_ASYNC_EINT1 */
4313#define ARIZONA_CLKGEN_ERR_ASYNC_EINT1_MASK 0x0001 /* CLKGEN_ERR_ASYNC_EINT1 */
4314#define ARIZONA_CLKGEN_ERR_ASYNC_EINT1_SHIFT 0 /* CLKGEN_ERR_ASYNC_EINT1 */
4315#define ARIZONA_CLKGEN_ERR_ASYNC_EINT1_WIDTH 1 /* CLKGEN_ERR_ASYNC_EINT1 */
4316
4317/*
4318 * R3331 (0xD03) - Interrupt Status 4
4319 */
4320#define ARIZONA_ASRC_CFG_ERR_EINT1 0x8000 /* ASRC_CFG_ERR_EINT1 */
4321#define ARIZONA_ASRC_CFG_ERR_EINT1_MASK 0x8000 /* ASRC_CFG_ERR_EINT1 */
4322#define ARIZONA_ASRC_CFG_ERR_EINT1_SHIFT 15 /* ASRC_CFG_ERR_EINT1 */
4323#define ARIZONA_ASRC_CFG_ERR_EINT1_WIDTH 1 /* ASRC_CFG_ERR_EINT1 */
4324#define ARIZONA_AIF3_ERR_EINT1 0x4000 /* AIF3_ERR_EINT1 */
4325#define ARIZONA_AIF3_ERR_EINT1_MASK 0x4000 /* AIF3_ERR_EINT1 */
4326#define ARIZONA_AIF3_ERR_EINT1_SHIFT 14 /* AIF3_ERR_EINT1 */
4327#define ARIZONA_AIF3_ERR_EINT1_WIDTH 1 /* AIF3_ERR_EINT1 */
4328#define ARIZONA_AIF2_ERR_EINT1 0x2000 /* AIF2_ERR_EINT1 */
4329#define ARIZONA_AIF2_ERR_EINT1_MASK 0x2000 /* AIF2_ERR_EINT1 */
4330#define ARIZONA_AIF2_ERR_EINT1_SHIFT 13 /* AIF2_ERR_EINT1 */
4331#define ARIZONA_AIF2_ERR_EINT1_WIDTH 1 /* AIF2_ERR_EINT1 */
4332#define ARIZONA_AIF1_ERR_EINT1 0x1000 /* AIF1_ERR_EINT1 */
4333#define ARIZONA_AIF1_ERR_EINT1_MASK 0x1000 /* AIF1_ERR_EINT1 */
4334#define ARIZONA_AIF1_ERR_EINT1_SHIFT 12 /* AIF1_ERR_EINT1 */
4335#define ARIZONA_AIF1_ERR_EINT1_WIDTH 1 /* AIF1_ERR_EINT1 */
4336#define ARIZONA_CTRLIF_ERR_EINT1 0x0800 /* CTRLIF_ERR_EINT1 */
4337#define ARIZONA_CTRLIF_ERR_EINT1_MASK 0x0800 /* CTRLIF_ERR_EINT1 */
4338#define ARIZONA_CTRLIF_ERR_EINT1_SHIFT 11 /* CTRLIF_ERR_EINT1 */
4339#define ARIZONA_CTRLIF_ERR_EINT1_WIDTH 1 /* CTRLIF_ERR_EINT1 */
4340#define ARIZONA_MIXER_DROPPED_SAMPLE_EINT1 0x0400 /* MIXER_DROPPED_SAMPLE_EINT1 */
4341#define ARIZONA_MIXER_DROPPED_SAMPLE_EINT1_MASK 0x0400 /* MIXER_DROPPED_SAMPLE_EINT1 */
4342#define ARIZONA_MIXER_DROPPED_SAMPLE_EINT1_SHIFT 10 /* MIXER_DROPPED_SAMPLE_EINT1 */
4343#define ARIZONA_MIXER_DROPPED_SAMPLE_EINT1_WIDTH 1 /* MIXER_DROPPED_SAMPLE_EINT1 */
4344#define ARIZONA_ASYNC_CLK_ENA_LOW_EINT1 0x0200 /* ASYNC_CLK_ENA_LOW_EINT1 */
4345#define ARIZONA_ASYNC_CLK_ENA_LOW_EINT1_MASK 0x0200 /* ASYNC_CLK_ENA_LOW_EINT1 */
4346#define ARIZONA_ASYNC_CLK_ENA_LOW_EINT1_SHIFT 9 /* ASYNC_CLK_ENA_LOW_EINT1 */
4347#define ARIZONA_ASYNC_CLK_ENA_LOW_EINT1_WIDTH 1 /* ASYNC_CLK_ENA_LOW_EINT1 */
4348#define ARIZONA_SYSCLK_ENA_LOW_EINT1 0x0100 /* SYSCLK_ENA_LOW_EINT1 */
4349#define ARIZONA_SYSCLK_ENA_LOW_EINT1_MASK 0x0100 /* SYSCLK_ENA_LOW_EINT1 */
4350#define ARIZONA_SYSCLK_ENA_LOW_EINT1_SHIFT 8 /* SYSCLK_ENA_LOW_EINT1 */
4351#define ARIZONA_SYSCLK_ENA_LOW_EINT1_WIDTH 1 /* SYSCLK_ENA_LOW_EINT1 */
4352#define ARIZONA_ISRC1_CFG_ERR_EINT1 0x0080 /* ISRC1_CFG_ERR_EINT1 */
4353#define ARIZONA_ISRC1_CFG_ERR_EINT1_MASK 0x0080 /* ISRC1_CFG_ERR_EINT1 */
4354#define ARIZONA_ISRC1_CFG_ERR_EINT1_SHIFT 7 /* ISRC1_CFG_ERR_EINT1 */
4355#define ARIZONA_ISRC1_CFG_ERR_EINT1_WIDTH 1 /* ISRC1_CFG_ERR_EINT1 */
4356#define ARIZONA_ISRC2_CFG_ERR_EINT1 0x0040 /* ISRC2_CFG_ERR_EINT1 */
4357#define ARIZONA_ISRC2_CFG_ERR_EINT1_MASK 0x0040 /* ISRC2_CFG_ERR_EINT1 */
4358#define ARIZONA_ISRC2_CFG_ERR_EINT1_SHIFT 6 /* ISRC2_CFG_ERR_EINT1 */
4359#define ARIZONA_ISRC2_CFG_ERR_EINT1_WIDTH 1 /* ISRC2_CFG_ERR_EINT1 */
4360
4361/*
4362 * R3332 (0xD04) - Interrupt Status 5
4363 */
4364#define ARIZONA_BOOT_DONE_EINT1 0x0100 /* BOOT_DONE_EINT1 */
4365#define ARIZONA_BOOT_DONE_EINT1_MASK 0x0100 /* BOOT_DONE_EINT1 */
4366#define ARIZONA_BOOT_DONE_EINT1_SHIFT 8 /* BOOT_DONE_EINT1 */
4367#define ARIZONA_BOOT_DONE_EINT1_WIDTH 1 /* BOOT_DONE_EINT1 */
4368#define ARIZONA_DCS_DAC_DONE_EINT1 0x0080 /* DCS_DAC_DONE_EINT1 */
4369#define ARIZONA_DCS_DAC_DONE_EINT1_MASK 0x0080 /* DCS_DAC_DONE_EINT1 */
4370#define ARIZONA_DCS_DAC_DONE_EINT1_SHIFT 7 /* DCS_DAC_DONE_EINT1 */
4371#define ARIZONA_DCS_DAC_DONE_EINT1_WIDTH 1 /* DCS_DAC_DONE_EINT1 */
4372#define ARIZONA_DCS_HP_DONE_EINT1 0x0040 /* DCS_HP_DONE_EINT1 */
4373#define ARIZONA_DCS_HP_DONE_EINT1_MASK 0x0040 /* DCS_HP_DONE_EINT1 */
4374#define ARIZONA_DCS_HP_DONE_EINT1_SHIFT 6 /* DCS_HP_DONE_EINT1 */
4375#define ARIZONA_DCS_HP_DONE_EINT1_WIDTH 1 /* DCS_HP_DONE_EINT1 */
4376#define ARIZONA_FLL2_CLOCK_OK_EINT1 0x0002 /* FLL2_CLOCK_OK_EINT1 */
4377#define ARIZONA_FLL2_CLOCK_OK_EINT1_MASK 0x0002 /* FLL2_CLOCK_OK_EINT1 */
4378#define ARIZONA_FLL2_CLOCK_OK_EINT1_SHIFT 1 /* FLL2_CLOCK_OK_EINT1 */
4379#define ARIZONA_FLL2_CLOCK_OK_EINT1_WIDTH 1 /* FLL2_CLOCK_OK_EINT1 */
4380#define ARIZONA_FLL1_CLOCK_OK_EINT1 0x0001 /* FLL1_CLOCK_OK_EINT1 */
4381#define ARIZONA_FLL1_CLOCK_OK_EINT1_MASK 0x0001 /* FLL1_CLOCK_OK_EINT1 */
4382#define ARIZONA_FLL1_CLOCK_OK_EINT1_SHIFT 0 /* FLL1_CLOCK_OK_EINT1 */
4383#define ARIZONA_FLL1_CLOCK_OK_EINT1_WIDTH 1 /* FLL1_CLOCK_OK_EINT1 */
4384
4385/*
4386 * R3336 (0xD08) - Interrupt Status 1 Mask
4387 */
4388#define ARIZONA_IM_GP4_EINT1 0x0008 /* IM_GP4_EINT1 */
4389#define ARIZONA_IM_GP4_EINT1_MASK 0x0008 /* IM_GP4_EINT1 */
4390#define ARIZONA_IM_GP4_EINT1_SHIFT 3 /* IM_GP4_EINT1 */
4391#define ARIZONA_IM_GP4_EINT1_WIDTH 1 /* IM_GP4_EINT1 */
4392#define ARIZONA_IM_GP3_EINT1 0x0004 /* IM_GP3_EINT1 */
4393#define ARIZONA_IM_GP3_EINT1_MASK 0x0004 /* IM_GP3_EINT1 */
4394#define ARIZONA_IM_GP3_EINT1_SHIFT 2 /* IM_GP3_EINT1 */
4395#define ARIZONA_IM_GP3_EINT1_WIDTH 1 /* IM_GP3_EINT1 */
4396#define ARIZONA_IM_GP2_EINT1 0x0002 /* IM_GP2_EINT1 */
4397#define ARIZONA_IM_GP2_EINT1_MASK 0x0002 /* IM_GP2_EINT1 */
4398#define ARIZONA_IM_GP2_EINT1_SHIFT 1 /* IM_GP2_EINT1 */
4399#define ARIZONA_IM_GP2_EINT1_WIDTH 1 /* IM_GP2_EINT1 */
4400#define ARIZONA_IM_GP1_EINT1 0x0001 /* IM_GP1_EINT1 */
4401#define ARIZONA_IM_GP1_EINT1_MASK 0x0001 /* IM_GP1_EINT1 */
4402#define ARIZONA_IM_GP1_EINT1_SHIFT 0 /* IM_GP1_EINT1 */
4403#define ARIZONA_IM_GP1_EINT1_WIDTH 1 /* IM_GP1_EINT1 */
4404
4405/*
4406 * R3337 (0xD09) - Interrupt Status 2 Mask
4407 */
4408#define ARIZONA_IM_DSP1_RAM_RDY_EINT1 0x0100 /* IM_DSP1_RAM_RDY_EINT1 */
4409#define ARIZONA_IM_DSP1_RAM_RDY_EINT1_MASK 0x0100 /* IM_DSP1_RAM_RDY_EINT1 */
4410#define ARIZONA_IM_DSP1_RAM_RDY_EINT1_SHIFT 8 /* IM_DSP1_RAM_RDY_EINT1 */
4411#define ARIZONA_IM_DSP1_RAM_RDY_EINT1_WIDTH 1 /* IM_DSP1_RAM_RDY_EINT1 */
4412#define ARIZONA_IM_DSP_IRQ2_EINT1 0x0002 /* IM_DSP_IRQ2_EINT1 */
4413#define ARIZONA_IM_DSP_IRQ2_EINT1_MASK 0x0002 /* IM_DSP_IRQ2_EINT1 */
4414#define ARIZONA_IM_DSP_IRQ2_EINT1_SHIFT 1 /* IM_DSP_IRQ2_EINT1 */
4415#define ARIZONA_IM_DSP_IRQ2_EINT1_WIDTH 1 /* IM_DSP_IRQ2_EINT1 */
4416#define ARIZONA_IM_DSP_IRQ1_EINT1 0x0001 /* IM_DSP_IRQ1_EINT1 */
4417#define ARIZONA_IM_DSP_IRQ1_EINT1_MASK 0x0001 /* IM_DSP_IRQ1_EINT1 */
4418#define ARIZONA_IM_DSP_IRQ1_EINT1_SHIFT 0 /* IM_DSP_IRQ1_EINT1 */
4419#define ARIZONA_IM_DSP_IRQ1_EINT1_WIDTH 1 /* IM_DSP_IRQ1_EINT1 */
4420
4421/*
4422 * R3338 (0xD0A) - Interrupt Status 3 Mask
4423 */
4424#define ARIZONA_IM_SPK_SHUTDOWN_WARN_EINT1 0x8000 /* IM_SPK_SHUTDOWN_WARN_EINT1 */
4425#define ARIZONA_IM_SPK_SHUTDOWN_WARN_EINT1_MASK 0x8000 /* IM_SPK_SHUTDOWN_WARN_EINT1 */
4426#define ARIZONA_IM_SPK_SHUTDOWN_WARN_EINT1_SHIFT 15 /* IM_SPK_SHUTDOWN_WARN_EINT1 */
4427#define ARIZONA_IM_SPK_SHUTDOWN_WARN_EINT1_WIDTH 1 /* IM_SPK_SHUTDOWN_WARN_EINT1 */
4428#define ARIZONA_IM_SPK_SHUTDOWN_EINT1 0x4000 /* IM_SPK_SHUTDOWN_EINT1 */
4429#define ARIZONA_IM_SPK_SHUTDOWN_EINT1_MASK 0x4000 /* IM_SPK_SHUTDOWN_EINT1 */
4430#define ARIZONA_IM_SPK_SHUTDOWN_EINT1_SHIFT 14 /* IM_SPK_SHUTDOWN_EINT1 */
4431#define ARIZONA_IM_SPK_SHUTDOWN_EINT1_WIDTH 1 /* IM_SPK_SHUTDOWN_EINT1 */
4432#define ARIZONA_IM_HPDET_EINT1 0x2000 /* IM_HPDET_EINT1 */
4433#define ARIZONA_IM_HPDET_EINT1_MASK 0x2000 /* IM_HPDET_EINT1 */
4434#define ARIZONA_IM_HPDET_EINT1_SHIFT 13 /* IM_HPDET_EINT1 */
4435#define ARIZONA_IM_HPDET_EINT1_WIDTH 1 /* IM_HPDET_EINT1 */
4436#define ARIZONA_IM_MICDET_EINT1 0x1000 /* IM_MICDET_EINT1 */
4437#define ARIZONA_IM_MICDET_EINT1_MASK 0x1000 /* IM_MICDET_EINT1 */
4438#define ARIZONA_IM_MICDET_EINT1_SHIFT 12 /* IM_MICDET_EINT1 */
4439#define ARIZONA_IM_MICDET_EINT1_WIDTH 1 /* IM_MICDET_EINT1 */
4440#define ARIZONA_IM_WSEQ_DONE_EINT1 0x0800 /* IM_WSEQ_DONE_EINT1 */
4441#define ARIZONA_IM_WSEQ_DONE_EINT1_MASK 0x0800 /* IM_WSEQ_DONE_EINT1 */
4442#define ARIZONA_IM_WSEQ_DONE_EINT1_SHIFT 11 /* IM_WSEQ_DONE_EINT1 */
4443#define ARIZONA_IM_WSEQ_DONE_EINT1_WIDTH 1 /* IM_WSEQ_DONE_EINT1 */
4444#define ARIZONA_IM_DRC2_SIG_DET_EINT1 0x0400 /* IM_DRC2_SIG_DET_EINT1 */
4445#define ARIZONA_IM_DRC2_SIG_DET_EINT1_MASK 0x0400 /* IM_DRC2_SIG_DET_EINT1 */
4446#define ARIZONA_IM_DRC2_SIG_DET_EINT1_SHIFT 10 /* IM_DRC2_SIG_DET_EINT1 */
4447#define ARIZONA_IM_DRC2_SIG_DET_EINT1_WIDTH 1 /* IM_DRC2_SIG_DET_EINT1 */
4448#define ARIZONA_IM_DRC1_SIG_DET_EINT1 0x0200 /* IM_DRC1_SIG_DET_EINT1 */
4449#define ARIZONA_IM_DRC1_SIG_DET_EINT1_MASK 0x0200 /* IM_DRC1_SIG_DET_EINT1 */
4450#define ARIZONA_IM_DRC1_SIG_DET_EINT1_SHIFT 9 /* IM_DRC1_SIG_DET_EINT1 */
4451#define ARIZONA_IM_DRC1_SIG_DET_EINT1_WIDTH 1 /* IM_DRC1_SIG_DET_EINT1 */
4452#define ARIZONA_IM_ASRC2_LOCK_EINT1 0x0100 /* IM_ASRC2_LOCK_EINT1 */
4453#define ARIZONA_IM_ASRC2_LOCK_EINT1_MASK 0x0100 /* IM_ASRC2_LOCK_EINT1 */
4454#define ARIZONA_IM_ASRC2_LOCK_EINT1_SHIFT 8 /* IM_ASRC2_LOCK_EINT1 */
4455#define ARIZONA_IM_ASRC2_LOCK_EINT1_WIDTH 1 /* IM_ASRC2_LOCK_EINT1 */
4456#define ARIZONA_IM_ASRC1_LOCK_EINT1 0x0080 /* IM_ASRC1_LOCK_EINT1 */
4457#define ARIZONA_IM_ASRC1_LOCK_EINT1_MASK 0x0080 /* IM_ASRC1_LOCK_EINT1 */
4458#define ARIZONA_IM_ASRC1_LOCK_EINT1_SHIFT 7 /* IM_ASRC1_LOCK_EINT1 */
4459#define ARIZONA_IM_ASRC1_LOCK_EINT1_WIDTH 1 /* IM_ASRC1_LOCK_EINT1 */
4460#define ARIZONA_IM_UNDERCLOCKED_EINT1 0x0040 /* IM_UNDERCLOCKED_EINT1 */
4461#define ARIZONA_IM_UNDERCLOCKED_EINT1_MASK 0x0040 /* IM_UNDERCLOCKED_EINT1 */
4462#define ARIZONA_IM_UNDERCLOCKED_EINT1_SHIFT 6 /* IM_UNDERCLOCKED_EINT1 */
4463#define ARIZONA_IM_UNDERCLOCKED_EINT1_WIDTH 1 /* IM_UNDERCLOCKED_EINT1 */
4464#define ARIZONA_IM_OVERCLOCKED_EINT1 0x0020 /* IM_OVERCLOCKED_EINT1 */
4465#define ARIZONA_IM_OVERCLOCKED_EINT1_MASK 0x0020 /* IM_OVERCLOCKED_EINT1 */
4466#define ARIZONA_IM_OVERCLOCKED_EINT1_SHIFT 5 /* IM_OVERCLOCKED_EINT1 */
4467#define ARIZONA_IM_OVERCLOCKED_EINT1_WIDTH 1 /* IM_OVERCLOCKED_EINT1 */
4468#define ARIZONA_IM_FLL2_LOCK_EINT1 0x0008 /* IM_FLL2_LOCK_EINT1 */
4469#define ARIZONA_IM_FLL2_LOCK_EINT1_MASK 0x0008 /* IM_FLL2_LOCK_EINT1 */
4470#define ARIZONA_IM_FLL2_LOCK_EINT1_SHIFT 3 /* IM_FLL2_LOCK_EINT1 */
4471#define ARIZONA_IM_FLL2_LOCK_EINT1_WIDTH 1 /* IM_FLL2_LOCK_EINT1 */
4472#define ARIZONA_IM_FLL1_LOCK_EINT1 0x0004 /* IM_FLL1_LOCK_EINT1 */
4473#define ARIZONA_IM_FLL1_LOCK_EINT1_MASK 0x0004 /* IM_FLL1_LOCK_EINT1 */
4474#define ARIZONA_IM_FLL1_LOCK_EINT1_SHIFT 2 /* IM_FLL1_LOCK_EINT1 */
4475#define ARIZONA_IM_FLL1_LOCK_EINT1_WIDTH 1 /* IM_FLL1_LOCK_EINT1 */
4476#define ARIZONA_IM_CLKGEN_ERR_EINT1 0x0002 /* IM_CLKGEN_ERR_EINT1 */
4477#define ARIZONA_IM_CLKGEN_ERR_EINT1_MASK 0x0002 /* IM_CLKGEN_ERR_EINT1 */
4478#define ARIZONA_IM_CLKGEN_ERR_EINT1_SHIFT 1 /* IM_CLKGEN_ERR_EINT1 */
4479#define ARIZONA_IM_CLKGEN_ERR_EINT1_WIDTH 1 /* IM_CLKGEN_ERR_EINT1 */
4480#define ARIZONA_IM_CLKGEN_ERR_ASYNC_EINT1 0x0001 /* IM_CLKGEN_ERR_ASYNC_EINT1 */
4481#define ARIZONA_IM_CLKGEN_ERR_ASYNC_EINT1_MASK 0x0001 /* IM_CLKGEN_ERR_ASYNC_EINT1 */
4482#define ARIZONA_IM_CLKGEN_ERR_ASYNC_EINT1_SHIFT 0 /* IM_CLKGEN_ERR_ASYNC_EINT1 */
4483#define ARIZONA_IM_CLKGEN_ERR_ASYNC_EINT1_WIDTH 1 /* IM_CLKGEN_ERR_ASYNC_EINT1 */
4484
4485/*
4486 * R3339 (0xD0B) - Interrupt Status 4 Mask
4487 */
4488#define ARIZONA_IM_ASRC_CFG_ERR_EINT1 0x8000 /* IM_ASRC_CFG_ERR_EINT1 */
4489#define ARIZONA_IM_ASRC_CFG_ERR_EINT1_MASK 0x8000 /* IM_ASRC_CFG_ERR_EINT1 */
4490#define ARIZONA_IM_ASRC_CFG_ERR_EINT1_SHIFT 15 /* IM_ASRC_CFG_ERR_EINT1 */
4491#define ARIZONA_IM_ASRC_CFG_ERR_EINT1_WIDTH 1 /* IM_ASRC_CFG_ERR_EINT1 */
4492#define ARIZONA_IM_AIF3_ERR_EINT1 0x4000 /* IM_AIF3_ERR_EINT1 */
4493#define ARIZONA_IM_AIF3_ERR_EINT1_MASK 0x4000 /* IM_AIF3_ERR_EINT1 */
4494#define ARIZONA_IM_AIF3_ERR_EINT1_SHIFT 14 /* IM_AIF3_ERR_EINT1 */
4495#define ARIZONA_IM_AIF3_ERR_EINT1_WIDTH 1 /* IM_AIF3_ERR_EINT1 */
4496#define ARIZONA_IM_AIF2_ERR_EINT1 0x2000 /* IM_AIF2_ERR_EINT1 */
4497#define ARIZONA_IM_AIF2_ERR_EINT1_MASK 0x2000 /* IM_AIF2_ERR_EINT1 */
4498#define ARIZONA_IM_AIF2_ERR_EINT1_SHIFT 13 /* IM_AIF2_ERR_EINT1 */
4499#define ARIZONA_IM_AIF2_ERR_EINT1_WIDTH 1 /* IM_AIF2_ERR_EINT1 */
4500#define ARIZONA_IM_AIF1_ERR_EINT1 0x1000 /* IM_AIF1_ERR_EINT1 */
4501#define ARIZONA_IM_AIF1_ERR_EINT1_MASK 0x1000 /* IM_AIF1_ERR_EINT1 */
4502#define ARIZONA_IM_AIF1_ERR_EINT1_SHIFT 12 /* IM_AIF1_ERR_EINT1 */
4503#define ARIZONA_IM_AIF1_ERR_EINT1_WIDTH 1 /* IM_AIF1_ERR_EINT1 */
4504#define ARIZONA_IM_CTRLIF_ERR_EINT1 0x0800 /* IM_CTRLIF_ERR_EINT1 */
4505#define ARIZONA_IM_CTRLIF_ERR_EINT1_MASK 0x0800 /* IM_CTRLIF_ERR_EINT1 */
4506#define ARIZONA_IM_CTRLIF_ERR_EINT1_SHIFT 11 /* IM_CTRLIF_ERR_EINT1 */
4507#define ARIZONA_IM_CTRLIF_ERR_EINT1_WIDTH 1 /* IM_CTRLIF_ERR_EINT1 */
4508#define ARIZONA_IM_MIXER_DROPPED_SAMPLE_EINT1 0x0400 /* IM_MIXER_DROPPED_SAMPLE_EINT1 */
4509#define ARIZONA_IM_MIXER_DROPPED_SAMPLE_EINT1_MASK 0x0400 /* IM_MIXER_DROPPED_SAMPLE_EINT1 */
4510#define ARIZONA_IM_MIXER_DROPPED_SAMPLE_EINT1_SHIFT 10 /* IM_MIXER_DROPPED_SAMPLE_EINT1 */
4511#define ARIZONA_IM_MIXER_DROPPED_SAMPLE_EINT1_WIDTH 1 /* IM_MIXER_DROPPED_SAMPLE_EINT1 */
4512#define ARIZONA_IM_ASYNC_CLK_ENA_LOW_EINT1 0x0200 /* IM_ASYNC_CLK_ENA_LOW_EINT1 */
4513#define ARIZONA_IM_ASYNC_CLK_ENA_LOW_EINT1_MASK 0x0200 /* IM_ASYNC_CLK_ENA_LOW_EINT1 */
4514#define ARIZONA_IM_ASYNC_CLK_ENA_LOW_EINT1_SHIFT 9 /* IM_ASYNC_CLK_ENA_LOW_EINT1 */
4515#define ARIZONA_IM_ASYNC_CLK_ENA_LOW_EINT1_WIDTH 1 /* IM_ASYNC_CLK_ENA_LOW_EINT1 */
4516#define ARIZONA_IM_SYSCLK_ENA_LOW_EINT1 0x0100 /* IM_SYSCLK_ENA_LOW_EINT1 */
4517#define ARIZONA_IM_SYSCLK_ENA_LOW_EINT1_MASK 0x0100 /* IM_SYSCLK_ENA_LOW_EINT1 */
4518#define ARIZONA_IM_SYSCLK_ENA_LOW_EINT1_SHIFT 8 /* IM_SYSCLK_ENA_LOW_EINT1 */
4519#define ARIZONA_IM_SYSCLK_ENA_LOW_EINT1_WIDTH 1 /* IM_SYSCLK_ENA_LOW_EINT1 */
4520#define ARIZONA_IM_ISRC1_CFG_ERR_EINT1 0x0080 /* IM_ISRC1_CFG_ERR_EINT1 */
4521#define ARIZONA_IM_ISRC1_CFG_ERR_EINT1_MASK 0x0080 /* IM_ISRC1_CFG_ERR_EINT1 */
4522#define ARIZONA_IM_ISRC1_CFG_ERR_EINT1_SHIFT 7 /* IM_ISRC1_CFG_ERR_EINT1 */
4523#define ARIZONA_IM_ISRC1_CFG_ERR_EINT1_WIDTH 1 /* IM_ISRC1_CFG_ERR_EINT1 */
4524#define ARIZONA_IM_ISRC2_CFG_ERR_EINT1 0x0040 /* IM_ISRC2_CFG_ERR_EINT1 */
4525#define ARIZONA_IM_ISRC2_CFG_ERR_EINT1_MASK 0x0040 /* IM_ISRC2_CFG_ERR_EINT1 */
4526#define ARIZONA_IM_ISRC2_CFG_ERR_EINT1_SHIFT 6 /* IM_ISRC2_CFG_ERR_EINT1 */
4527#define ARIZONA_IM_ISRC2_CFG_ERR_EINT1_WIDTH 1 /* IM_ISRC2_CFG_ERR_EINT1 */
4528
4529/*
4530 * R3340 (0xD0C) - Interrupt Status 5 Mask
4531 */
4532#define ARIZONA_IM_BOOT_DONE_EINT1 0x0100 /* IM_BOOT_DONE_EINT1 */
4533#define ARIZONA_IM_BOOT_DONE_EINT1_MASK 0x0100 /* IM_BOOT_DONE_EINT1 */
4534#define ARIZONA_IM_BOOT_DONE_EINT1_SHIFT 8 /* IM_BOOT_DONE_EINT1 */
4535#define ARIZONA_IM_BOOT_DONE_EINT1_WIDTH 1 /* IM_BOOT_DONE_EINT1 */
4536#define ARIZONA_IM_DCS_DAC_DONE_EINT1 0x0080 /* IM_DCS_DAC_DONE_EINT1 */
4537#define ARIZONA_IM_DCS_DAC_DONE_EINT1_MASK 0x0080 /* IM_DCS_DAC_DONE_EINT1 */
4538#define ARIZONA_IM_DCS_DAC_DONE_EINT1_SHIFT 7 /* IM_DCS_DAC_DONE_EINT1 */
4539#define ARIZONA_IM_DCS_DAC_DONE_EINT1_WIDTH 1 /* IM_DCS_DAC_DONE_EINT1 */
4540#define ARIZONA_IM_DCS_HP_DONE_EINT1 0x0040 /* IM_DCS_HP_DONE_EINT1 */
4541#define ARIZONA_IM_DCS_HP_DONE_EINT1_MASK 0x0040 /* IM_DCS_HP_DONE_EINT1 */
4542#define ARIZONA_IM_DCS_HP_DONE_EINT1_SHIFT 6 /* IM_DCS_HP_DONE_EINT1 */
4543#define ARIZONA_IM_DCS_HP_DONE_EINT1_WIDTH 1 /* IM_DCS_HP_DONE_EINT1 */
4544#define ARIZONA_IM_FLL2_CLOCK_OK_EINT1 0x0002 /* IM_FLL2_CLOCK_OK_EINT1 */
4545#define ARIZONA_IM_FLL2_CLOCK_OK_EINT1_MASK 0x0002 /* IM_FLL2_CLOCK_OK_EINT1 */
4546#define ARIZONA_IM_FLL2_CLOCK_OK_EINT1_SHIFT 1 /* IM_FLL2_CLOCK_OK_EINT1 */
4547#define ARIZONA_IM_FLL2_CLOCK_OK_EINT1_WIDTH 1 /* IM_FLL2_CLOCK_OK_EINT1 */
4548#define ARIZONA_IM_FLL1_CLOCK_OK_EINT1 0x0001 /* IM_FLL1_CLOCK_OK_EINT1 */
4549#define ARIZONA_IM_FLL1_CLOCK_OK_EINT1_MASK 0x0001 /* IM_FLL1_CLOCK_OK_EINT1 */
4550#define ARIZONA_IM_FLL1_CLOCK_OK_EINT1_SHIFT 0 /* IM_FLL1_CLOCK_OK_EINT1 */
4551#define ARIZONA_IM_FLL1_CLOCK_OK_EINT1_WIDTH 1 /* IM_FLL1_CLOCK_OK_EINT1 */
4552
4553/*
4554 * R3343 (0xD0F) - Interrupt Control
4555 */
4556#define ARIZONA_IM_IRQ1 0x0001 /* IM_IRQ1 */
4557#define ARIZONA_IM_IRQ1_MASK 0x0001 /* IM_IRQ1 */
4558#define ARIZONA_IM_IRQ1_SHIFT 0 /* IM_IRQ1 */
4559#define ARIZONA_IM_IRQ1_WIDTH 1 /* IM_IRQ1 */
4560
4561/*
4562 * R3344 (0xD10) - IRQ2 Status 1
4563 */
4564#define ARIZONA_GP4_EINT2 0x0008 /* GP4_EINT2 */
4565#define ARIZONA_GP4_EINT2_MASK 0x0008 /* GP4_EINT2 */
4566#define ARIZONA_GP4_EINT2_SHIFT 3 /* GP4_EINT2 */
4567#define ARIZONA_GP4_EINT2_WIDTH 1 /* GP4_EINT2 */
4568#define ARIZONA_GP3_EINT2 0x0004 /* GP3_EINT2 */
4569#define ARIZONA_GP3_EINT2_MASK 0x0004 /* GP3_EINT2 */
4570#define ARIZONA_GP3_EINT2_SHIFT 2 /* GP3_EINT2 */
4571#define ARIZONA_GP3_EINT2_WIDTH 1 /* GP3_EINT2 */
4572#define ARIZONA_GP2_EINT2 0x0002 /* GP2_EINT2 */
4573#define ARIZONA_GP2_EINT2_MASK 0x0002 /* GP2_EINT2 */
4574#define ARIZONA_GP2_EINT2_SHIFT 1 /* GP2_EINT2 */
4575#define ARIZONA_GP2_EINT2_WIDTH 1 /* GP2_EINT2 */
4576#define ARIZONA_GP1_EINT2 0x0001 /* GP1_EINT2 */
4577#define ARIZONA_GP1_EINT2_MASK 0x0001 /* GP1_EINT2 */
4578#define ARIZONA_GP1_EINT2_SHIFT 0 /* GP1_EINT2 */
4579#define ARIZONA_GP1_EINT2_WIDTH 1 /* GP1_EINT2 */
4580
4581/*
4582 * R3345 (0xD11) - IRQ2 Status 2
4583 */
4584#define ARIZONA_DSP1_RAM_RDY_EINT2 0x0100 /* DSP1_RAM_RDY_EINT2 */
4585#define ARIZONA_DSP1_RAM_RDY_EINT2_MASK 0x0100 /* DSP1_RAM_RDY_EINT2 */
4586#define ARIZONA_DSP1_RAM_RDY_EINT2_SHIFT 8 /* DSP1_RAM_RDY_EINT2 */
4587#define ARIZONA_DSP1_RAM_RDY_EINT2_WIDTH 1 /* DSP1_RAM_RDY_EINT2 */
4588#define ARIZONA_DSP_IRQ2_EINT2 0x0002 /* DSP_IRQ2_EINT2 */
4589#define ARIZONA_DSP_IRQ2_EINT2_MASK 0x0002 /* DSP_IRQ2_EINT2 */
4590#define ARIZONA_DSP_IRQ2_EINT2_SHIFT 1 /* DSP_IRQ2_EINT2 */
4591#define ARIZONA_DSP_IRQ2_EINT2_WIDTH 1 /* DSP_IRQ2_EINT2 */
4592#define ARIZONA_DSP_IRQ1_EINT2 0x0001 /* DSP_IRQ1_EINT2 */
4593#define ARIZONA_DSP_IRQ1_EINT2_MASK 0x0001 /* DSP_IRQ1_EINT2 */
4594#define ARIZONA_DSP_IRQ1_EINT2_SHIFT 0 /* DSP_IRQ1_EINT2 */
4595#define ARIZONA_DSP_IRQ1_EINT2_WIDTH 1 /* DSP_IRQ1_EINT2 */
4596
4597/*
4598 * R3346 (0xD12) - IRQ2 Status 3
4599 */
4600#define ARIZONA_SPK_SHUTDOWN_WARN_EINT2 0x8000 /* SPK_SHUTDOWN_WARN_EINT2 */
4601#define ARIZONA_SPK_SHUTDOWN_WARN_EINT2_MASK 0x8000 /* SPK_SHUTDOWN_WARN_EINT2 */
4602#define ARIZONA_SPK_SHUTDOWN_WARN_EINT2_SHIFT 15 /* SPK_SHUTDOWN_WARN_EINT2 */
4603#define ARIZONA_SPK_SHUTDOWN_WARN_EINT2_WIDTH 1 /* SPK_SHUTDOWN_WARN_EINT2 */
4604#define ARIZONA_SPK_SHUTDOWN_EINT2 0x4000 /* SPK_SHUTDOWN_EINT2 */
4605#define ARIZONA_SPK_SHUTDOWN_EINT2_MASK 0x4000 /* SPK_SHUTDOWN_EINT2 */
4606#define ARIZONA_SPK_SHUTDOWN_EINT2_SHIFT 14 /* SPK_SHUTDOWN_EINT2 */
4607#define ARIZONA_SPK_SHUTDOWN_EINT2_WIDTH 1 /* SPK_SHUTDOWN_EINT2 */
4608#define ARIZONA_HPDET_EINT2 0x2000 /* HPDET_EINT2 */
4609#define ARIZONA_HPDET_EINT2_MASK 0x2000 /* HPDET_EINT2 */
4610#define ARIZONA_HPDET_EINT2_SHIFT 13 /* HPDET_EINT2 */
4611#define ARIZONA_HPDET_EINT2_WIDTH 1 /* HPDET_EINT2 */
4612#define ARIZONA_MICDET_EINT2 0x1000 /* MICDET_EINT2 */
4613#define ARIZONA_MICDET_EINT2_MASK 0x1000 /* MICDET_EINT2 */
4614#define ARIZONA_MICDET_EINT2_SHIFT 12 /* MICDET_EINT2 */
4615#define ARIZONA_MICDET_EINT2_WIDTH 1 /* MICDET_EINT2 */
4616#define ARIZONA_WSEQ_DONE_EINT2 0x0800 /* WSEQ_DONE_EINT2 */
4617#define ARIZONA_WSEQ_DONE_EINT2_MASK 0x0800 /* WSEQ_DONE_EINT2 */
4618#define ARIZONA_WSEQ_DONE_EINT2_SHIFT 11 /* WSEQ_DONE_EINT2 */
4619#define ARIZONA_WSEQ_DONE_EINT2_WIDTH 1 /* WSEQ_DONE_EINT2 */
4620#define ARIZONA_DRC2_SIG_DET_EINT2 0x0400 /* DRC2_SIG_DET_EINT2 */
4621#define ARIZONA_DRC2_SIG_DET_EINT2_MASK 0x0400 /* DRC2_SIG_DET_EINT2 */
4622#define ARIZONA_DRC2_SIG_DET_EINT2_SHIFT 10 /* DRC2_SIG_DET_EINT2 */
4623#define ARIZONA_DRC2_SIG_DET_EINT2_WIDTH 1 /* DRC2_SIG_DET_EINT2 */
4624#define ARIZONA_DRC1_SIG_DET_EINT2 0x0200 /* DRC1_SIG_DET_EINT2 */
4625#define ARIZONA_DRC1_SIG_DET_EINT2_MASK 0x0200 /* DRC1_SIG_DET_EINT2 */
4626#define ARIZONA_DRC1_SIG_DET_EINT2_SHIFT 9 /* DRC1_SIG_DET_EINT2 */
4627#define ARIZONA_DRC1_SIG_DET_EINT2_WIDTH 1 /* DRC1_SIG_DET_EINT2 */
4628#define ARIZONA_ASRC2_LOCK_EINT2 0x0100 /* ASRC2_LOCK_EINT2 */
4629#define ARIZONA_ASRC2_LOCK_EINT2_MASK 0x0100 /* ASRC2_LOCK_EINT2 */
4630#define ARIZONA_ASRC2_LOCK_EINT2_SHIFT 8 /* ASRC2_LOCK_EINT2 */
4631#define ARIZONA_ASRC2_LOCK_EINT2_WIDTH 1 /* ASRC2_LOCK_EINT2 */
4632#define ARIZONA_ASRC1_LOCK_EINT2 0x0080 /* ASRC1_LOCK_EINT2 */
4633#define ARIZONA_ASRC1_LOCK_EINT2_MASK 0x0080 /* ASRC1_LOCK_EINT2 */
4634#define ARIZONA_ASRC1_LOCK_EINT2_SHIFT 7 /* ASRC1_LOCK_EINT2 */
4635#define ARIZONA_ASRC1_LOCK_EINT2_WIDTH 1 /* ASRC1_LOCK_EINT2 */
4636#define ARIZONA_UNDERCLOCKED_EINT2 0x0040 /* UNDERCLOCKED_EINT2 */
4637#define ARIZONA_UNDERCLOCKED_EINT2_MASK 0x0040 /* UNDERCLOCKED_EINT2 */
4638#define ARIZONA_UNDERCLOCKED_EINT2_SHIFT 6 /* UNDERCLOCKED_EINT2 */
4639#define ARIZONA_UNDERCLOCKED_EINT2_WIDTH 1 /* UNDERCLOCKED_EINT2 */
4640#define ARIZONA_OVERCLOCKED_EINT2 0x0020 /* OVERCLOCKED_EINT2 */
4641#define ARIZONA_OVERCLOCKED_EINT2_MASK 0x0020 /* OVERCLOCKED_EINT2 */
4642#define ARIZONA_OVERCLOCKED_EINT2_SHIFT 5 /* OVERCLOCKED_EINT2 */
4643#define ARIZONA_OVERCLOCKED_EINT2_WIDTH 1 /* OVERCLOCKED_EINT2 */
4644#define ARIZONA_FLL2_LOCK_EINT2 0x0008 /* FLL2_LOCK_EINT2 */
4645#define ARIZONA_FLL2_LOCK_EINT2_MASK 0x0008 /* FLL2_LOCK_EINT2 */
4646#define ARIZONA_FLL2_LOCK_EINT2_SHIFT 3 /* FLL2_LOCK_EINT2 */
4647#define ARIZONA_FLL2_LOCK_EINT2_WIDTH 1 /* FLL2_LOCK_EINT2 */
4648#define ARIZONA_FLL1_LOCK_EINT2 0x0004 /* FLL1_LOCK_EINT2 */
4649#define ARIZONA_FLL1_LOCK_EINT2_MASK 0x0004 /* FLL1_LOCK_EINT2 */
4650#define ARIZONA_FLL1_LOCK_EINT2_SHIFT 2 /* FLL1_LOCK_EINT2 */
4651#define ARIZONA_FLL1_LOCK_EINT2_WIDTH 1 /* FLL1_LOCK_EINT2 */
4652#define ARIZONA_CLKGEN_ERR_EINT2 0x0002 /* CLKGEN_ERR_EINT2 */
4653#define ARIZONA_CLKGEN_ERR_EINT2_MASK 0x0002 /* CLKGEN_ERR_EINT2 */
4654#define ARIZONA_CLKGEN_ERR_EINT2_SHIFT 1 /* CLKGEN_ERR_EINT2 */
4655#define ARIZONA_CLKGEN_ERR_EINT2_WIDTH 1 /* CLKGEN_ERR_EINT2 */
4656#define ARIZONA_CLKGEN_ERR_ASYNC_EINT2 0x0001 /* CLKGEN_ERR_ASYNC_EINT2 */
4657#define ARIZONA_CLKGEN_ERR_ASYNC_EINT2_MASK 0x0001 /* CLKGEN_ERR_ASYNC_EINT2 */
4658#define ARIZONA_CLKGEN_ERR_ASYNC_EINT2_SHIFT 0 /* CLKGEN_ERR_ASYNC_EINT2 */
4659#define ARIZONA_CLKGEN_ERR_ASYNC_EINT2_WIDTH 1 /* CLKGEN_ERR_ASYNC_EINT2 */
4660
4661/*
4662 * R3347 (0xD13) - IRQ2 Status 4
4663 */
4664#define ARIZONA_ASRC_CFG_ERR_EINT2 0x8000 /* ASRC_CFG_ERR_EINT2 */
4665#define ARIZONA_ASRC_CFG_ERR_EINT2_MASK 0x8000 /* ASRC_CFG_ERR_EINT2 */
4666#define ARIZONA_ASRC_CFG_ERR_EINT2_SHIFT 15 /* ASRC_CFG_ERR_EINT2 */
4667#define ARIZONA_ASRC_CFG_ERR_EINT2_WIDTH 1 /* ASRC_CFG_ERR_EINT2 */
4668#define ARIZONA_AIF3_ERR_EINT2 0x4000 /* AIF3_ERR_EINT2 */
4669#define ARIZONA_AIF3_ERR_EINT2_MASK 0x4000 /* AIF3_ERR_EINT2 */
4670#define ARIZONA_AIF3_ERR_EINT2_SHIFT 14 /* AIF3_ERR_EINT2 */
4671#define ARIZONA_AIF3_ERR_EINT2_WIDTH 1 /* AIF3_ERR_EINT2 */
4672#define ARIZONA_AIF2_ERR_EINT2 0x2000 /* AIF2_ERR_EINT2 */
4673#define ARIZONA_AIF2_ERR_EINT2_MASK 0x2000 /* AIF2_ERR_EINT2 */
4674#define ARIZONA_AIF2_ERR_EINT2_SHIFT 13 /* AIF2_ERR_EINT2 */
4675#define ARIZONA_AIF2_ERR_EINT2_WIDTH 1 /* AIF2_ERR_EINT2 */
4676#define ARIZONA_AIF1_ERR_EINT2 0x1000 /* AIF1_ERR_EINT2 */
4677#define ARIZONA_AIF1_ERR_EINT2_MASK 0x1000 /* AIF1_ERR_EINT2 */
4678#define ARIZONA_AIF1_ERR_EINT2_SHIFT 12 /* AIF1_ERR_EINT2 */
4679#define ARIZONA_AIF1_ERR_EINT2_WIDTH 1 /* AIF1_ERR_EINT2 */
4680#define ARIZONA_CTRLIF_ERR_EINT2 0x0800 /* CTRLIF_ERR_EINT2 */
4681#define ARIZONA_CTRLIF_ERR_EINT2_MASK 0x0800 /* CTRLIF_ERR_EINT2 */
4682#define ARIZONA_CTRLIF_ERR_EINT2_SHIFT 11 /* CTRLIF_ERR_EINT2 */
4683#define ARIZONA_CTRLIF_ERR_EINT2_WIDTH 1 /* CTRLIF_ERR_EINT2 */
4684#define ARIZONA_MIXER_DROPPED_SAMPLE_EINT2 0x0400 /* MIXER_DROPPED_SAMPLE_EINT2 */
4685#define ARIZONA_MIXER_DROPPED_SAMPLE_EINT2_MASK 0x0400 /* MIXER_DROPPED_SAMPLE_EINT2 */
4686#define ARIZONA_MIXER_DROPPED_SAMPLE_EINT2_SHIFT 10 /* MIXER_DROPPED_SAMPLE_EINT2 */
4687#define ARIZONA_MIXER_DROPPED_SAMPLE_EINT2_WIDTH 1 /* MIXER_DROPPED_SAMPLE_EINT2 */
4688#define ARIZONA_ASYNC_CLK_ENA_LOW_EINT2 0x0200 /* ASYNC_CLK_ENA_LOW_EINT2 */
4689#define ARIZONA_ASYNC_CLK_ENA_LOW_EINT2_MASK 0x0200 /* ASYNC_CLK_ENA_LOW_EINT2 */
4690#define ARIZONA_ASYNC_CLK_ENA_LOW_EINT2_SHIFT 9 /* ASYNC_CLK_ENA_LOW_EINT2 */
4691#define ARIZONA_ASYNC_CLK_ENA_LOW_EINT2_WIDTH 1 /* ASYNC_CLK_ENA_LOW_EINT2 */
4692#define ARIZONA_SYSCLK_ENA_LOW_EINT2 0x0100 /* SYSCLK_ENA_LOW_EINT2 */
4693#define ARIZONA_SYSCLK_ENA_LOW_EINT2_MASK 0x0100 /* SYSCLK_ENA_LOW_EINT2 */
4694#define ARIZONA_SYSCLK_ENA_LOW_EINT2_SHIFT 8 /* SYSCLK_ENA_LOW_EINT2 */
4695#define ARIZONA_SYSCLK_ENA_LOW_EINT2_WIDTH 1 /* SYSCLK_ENA_LOW_EINT2 */
4696#define ARIZONA_ISRC1_CFG_ERR_EINT2 0x0080 /* ISRC1_CFG_ERR_EINT2 */
4697#define ARIZONA_ISRC1_CFG_ERR_EINT2_MASK 0x0080 /* ISRC1_CFG_ERR_EINT2 */
4698#define ARIZONA_ISRC1_CFG_ERR_EINT2_SHIFT 7 /* ISRC1_CFG_ERR_EINT2 */
4699#define ARIZONA_ISRC1_CFG_ERR_EINT2_WIDTH 1 /* ISRC1_CFG_ERR_EINT2 */
4700#define ARIZONA_ISRC2_CFG_ERR_EINT2 0x0040 /* ISRC2_CFG_ERR_EINT2 */
4701#define ARIZONA_ISRC2_CFG_ERR_EINT2_MASK 0x0040 /* ISRC2_CFG_ERR_EINT2 */
4702#define ARIZONA_ISRC2_CFG_ERR_EINT2_SHIFT 6 /* ISRC2_CFG_ERR_EINT2 */
4703#define ARIZONA_ISRC2_CFG_ERR_EINT2_WIDTH 1 /* ISRC2_CFG_ERR_EINT2 */
4704
4705/*
4706 * R3348 (0xD14) - IRQ2 Status 5
4707 */
4708#define ARIZONA_BOOT_DONE_EINT2 0x0100 /* BOOT_DONE_EINT2 */
4709#define ARIZONA_BOOT_DONE_EINT2_MASK 0x0100 /* BOOT_DONE_EINT2 */
4710#define ARIZONA_BOOT_DONE_EINT2_SHIFT 8 /* BOOT_DONE_EINT2 */
4711#define ARIZONA_BOOT_DONE_EINT2_WIDTH 1 /* BOOT_DONE_EINT2 */
4712#define ARIZONA_DCS_DAC_DONE_EINT2 0x0080 /* DCS_DAC_DONE_EINT2 */
4713#define ARIZONA_DCS_DAC_DONE_EINT2_MASK 0x0080 /* DCS_DAC_DONE_EINT2 */
4714#define ARIZONA_DCS_DAC_DONE_EINT2_SHIFT 7 /* DCS_DAC_DONE_EINT2 */
4715#define ARIZONA_DCS_DAC_DONE_EINT2_WIDTH 1 /* DCS_DAC_DONE_EINT2 */
4716#define ARIZONA_DCS_HP_DONE_EINT2 0x0040 /* DCS_HP_DONE_EINT2 */
4717#define ARIZONA_DCS_HP_DONE_EINT2_MASK 0x0040 /* DCS_HP_DONE_EINT2 */
4718#define ARIZONA_DCS_HP_DONE_EINT2_SHIFT 6 /* DCS_HP_DONE_EINT2 */
4719#define ARIZONA_DCS_HP_DONE_EINT2_WIDTH 1 /* DCS_HP_DONE_EINT2 */
4720#define ARIZONA_FLL2_CLOCK_OK_EINT2 0x0002 /* FLL2_CLOCK_OK_EINT2 */
4721#define ARIZONA_FLL2_CLOCK_OK_EINT2_MASK 0x0002 /* FLL2_CLOCK_OK_EINT2 */
4722#define ARIZONA_FLL2_CLOCK_OK_EINT2_SHIFT 1 /* FLL2_CLOCK_OK_EINT2 */
4723#define ARIZONA_FLL2_CLOCK_OK_EINT2_WIDTH 1 /* FLL2_CLOCK_OK_EINT2 */
4724#define ARIZONA_FLL1_CLOCK_OK_EINT2 0x0001 /* FLL1_CLOCK_OK_EINT2 */
4725#define ARIZONA_FLL1_CLOCK_OK_EINT2_MASK 0x0001 /* FLL1_CLOCK_OK_EINT2 */
4726#define ARIZONA_FLL1_CLOCK_OK_EINT2_SHIFT 0 /* FLL1_CLOCK_OK_EINT2 */
4727#define ARIZONA_FLL1_CLOCK_OK_EINT2_WIDTH 1 /* FLL1_CLOCK_OK_EINT2 */
4728
4729/*
4730 * R3352 (0xD18) - IRQ2 Status 1 Mask
4731 */
4732#define ARIZONA_IM_GP4_EINT2 0x0008 /* IM_GP4_EINT2 */
4733#define ARIZONA_IM_GP4_EINT2_MASK 0x0008 /* IM_GP4_EINT2 */
4734#define ARIZONA_IM_GP4_EINT2_SHIFT 3 /* IM_GP4_EINT2 */
4735#define ARIZONA_IM_GP4_EINT2_WIDTH 1 /* IM_GP4_EINT2 */
4736#define ARIZONA_IM_GP3_EINT2 0x0004 /* IM_GP3_EINT2 */
4737#define ARIZONA_IM_GP3_EINT2_MASK 0x0004 /* IM_GP3_EINT2 */
4738#define ARIZONA_IM_GP3_EINT2_SHIFT 2 /* IM_GP3_EINT2 */
4739#define ARIZONA_IM_GP3_EINT2_WIDTH 1 /* IM_GP3_EINT2 */
4740#define ARIZONA_IM_GP2_EINT2 0x0002 /* IM_GP2_EINT2 */
4741#define ARIZONA_IM_GP2_EINT2_MASK 0x0002 /* IM_GP2_EINT2 */
4742#define ARIZONA_IM_GP2_EINT2_SHIFT 1 /* IM_GP2_EINT2 */
4743#define ARIZONA_IM_GP2_EINT2_WIDTH 1 /* IM_GP2_EINT2 */
4744#define ARIZONA_IM_GP1_EINT2 0x0001 /* IM_GP1_EINT2 */
4745#define ARIZONA_IM_GP1_EINT2_MASK 0x0001 /* IM_GP1_EINT2 */
4746#define ARIZONA_IM_GP1_EINT2_SHIFT 0 /* IM_GP1_EINT2 */
4747#define ARIZONA_IM_GP1_EINT2_WIDTH 1 /* IM_GP1_EINT2 */
4748
4749/*
4750 * R3353 (0xD19) - IRQ2 Status 2 Mask
4751 */
4752#define ARIZONA_IM_DSP1_RAM_RDY_EINT2 0x0100 /* IM_DSP1_RAM_RDY_EINT2 */
4753#define ARIZONA_IM_DSP1_RAM_RDY_EINT2_MASK 0x0100 /* IM_DSP1_RAM_RDY_EINT2 */
4754#define ARIZONA_IM_DSP1_RAM_RDY_EINT2_SHIFT 8 /* IM_DSP1_RAM_RDY_EINT2 */
4755#define ARIZONA_IM_DSP1_RAM_RDY_EINT2_WIDTH 1 /* IM_DSP1_RAM_RDY_EINT2 */
4756#define ARIZONA_IM_DSP_IRQ2_EINT2 0x0002 /* IM_DSP_IRQ2_EINT2 */
4757#define ARIZONA_IM_DSP_IRQ2_EINT2_MASK 0x0002 /* IM_DSP_IRQ2_EINT2 */
4758#define ARIZONA_IM_DSP_IRQ2_EINT2_SHIFT 1 /* IM_DSP_IRQ2_EINT2 */
4759#define ARIZONA_IM_DSP_IRQ2_EINT2_WIDTH 1 /* IM_DSP_IRQ2_EINT2 */
4760#define ARIZONA_IM_DSP_IRQ1_EINT2 0x0001 /* IM_DSP_IRQ1_EINT2 */
4761#define ARIZONA_IM_DSP_IRQ1_EINT2_MASK 0x0001 /* IM_DSP_IRQ1_EINT2 */
4762#define ARIZONA_IM_DSP_IRQ1_EINT2_SHIFT 0 /* IM_DSP_IRQ1_EINT2 */
4763#define ARIZONA_IM_DSP_IRQ1_EINT2_WIDTH 1 /* IM_DSP_IRQ1_EINT2 */
4764
4765/*
4766 * R3354 (0xD1A) - IRQ2 Status 3 Mask
4767 */
4768#define ARIZONA_IM_SPK_SHUTDOWN_WARN_EINT2 0x8000 /* IM_SPK_SHUTDOWN_WARN_EINT2 */
4769#define ARIZONA_IM_SPK_SHUTDOWN_WARN_EINT2_MASK 0x8000 /* IM_SPK_SHUTDOWN_WARN_EINT2 */
4770#define ARIZONA_IM_SPK_SHUTDOWN_WARN_EINT2_SHIFT 15 /* IM_SPK_SHUTDOWN_WARN_EINT2 */
4771#define ARIZONA_IM_SPK_SHUTDOWN_WARN_EINT2_WIDTH 1 /* IM_SPK_SHUTDOWN_WARN_EINT2 */
4772#define ARIZONA_IM_SPK_SHUTDOWN_EINT2 0x4000 /* IM_SPK_SHUTDOWN_EINT2 */
4773#define ARIZONA_IM_SPK_SHUTDOWN_EINT2_MASK 0x4000 /* IM_SPK_SHUTDOWN_EINT2 */
4774#define ARIZONA_IM_SPK_SHUTDOWN_EINT2_SHIFT 14 /* IM_SPK_SHUTDOWN_EINT2 */
4775#define ARIZONA_IM_SPK_SHUTDOWN_EINT2_WIDTH 1 /* IM_SPK_SHUTDOWN_EINT2 */
4776#define ARIZONA_IM_HPDET_EINT2 0x2000 /* IM_HPDET_EINT2 */
4777#define ARIZONA_IM_HPDET_EINT2_MASK 0x2000 /* IM_HPDET_EINT2 */
4778#define ARIZONA_IM_HPDET_EINT2_SHIFT 13 /* IM_HPDET_EINT2 */
4779#define ARIZONA_IM_HPDET_EINT2_WIDTH 1 /* IM_HPDET_EINT2 */
4780#define ARIZONA_IM_MICDET_EINT2 0x1000 /* IM_MICDET_EINT2 */
4781#define ARIZONA_IM_MICDET_EINT2_MASK 0x1000 /* IM_MICDET_EINT2 */
4782#define ARIZONA_IM_MICDET_EINT2_SHIFT 12 /* IM_MICDET_EINT2 */
4783#define ARIZONA_IM_MICDET_EINT2_WIDTH 1 /* IM_MICDET_EINT2 */
4784#define ARIZONA_IM_WSEQ_DONE_EINT2 0x0800 /* IM_WSEQ_DONE_EINT2 */
4785#define ARIZONA_IM_WSEQ_DONE_EINT2_MASK 0x0800 /* IM_WSEQ_DONE_EINT2 */
4786#define ARIZONA_IM_WSEQ_DONE_EINT2_SHIFT 11 /* IM_WSEQ_DONE_EINT2 */
4787#define ARIZONA_IM_WSEQ_DONE_EINT2_WIDTH 1 /* IM_WSEQ_DONE_EINT2 */
4788#define ARIZONA_IM_DRC2_SIG_DET_EINT2 0x0400 /* IM_DRC2_SIG_DET_EINT2 */
4789#define ARIZONA_IM_DRC2_SIG_DET_EINT2_MASK 0x0400 /* IM_DRC2_SIG_DET_EINT2 */
4790#define ARIZONA_IM_DRC2_SIG_DET_EINT2_SHIFT 10 /* IM_DRC2_SIG_DET_EINT2 */
4791#define ARIZONA_IM_DRC2_SIG_DET_EINT2_WIDTH 1 /* IM_DRC2_SIG_DET_EINT2 */
4792#define ARIZONA_IM_DRC1_SIG_DET_EINT2 0x0200 /* IM_DRC1_SIG_DET_EINT2 */
4793#define ARIZONA_IM_DRC1_SIG_DET_EINT2_MASK 0x0200 /* IM_DRC1_SIG_DET_EINT2 */
4794#define ARIZONA_IM_DRC1_SIG_DET_EINT2_SHIFT 9 /* IM_DRC1_SIG_DET_EINT2 */
4795#define ARIZONA_IM_DRC1_SIG_DET_EINT2_WIDTH 1 /* IM_DRC1_SIG_DET_EINT2 */
4796#define ARIZONA_IM_ASRC2_LOCK_EINT2 0x0100 /* IM_ASRC2_LOCK_EINT2 */
4797#define ARIZONA_IM_ASRC2_LOCK_EINT2_MASK 0x0100 /* IM_ASRC2_LOCK_EINT2 */
4798#define ARIZONA_IM_ASRC2_LOCK_EINT2_SHIFT 8 /* IM_ASRC2_LOCK_EINT2 */
4799#define ARIZONA_IM_ASRC2_LOCK_EINT2_WIDTH 1 /* IM_ASRC2_LOCK_EINT2 */
4800#define ARIZONA_IM_ASRC1_LOCK_EINT2 0x0080 /* IM_ASRC1_LOCK_EINT2 */
4801#define ARIZONA_IM_ASRC1_LOCK_EINT2_MASK 0x0080 /* IM_ASRC1_LOCK_EINT2 */
4802#define ARIZONA_IM_ASRC1_LOCK_EINT2_SHIFT 7 /* IM_ASRC1_LOCK_EINT2 */
4803#define ARIZONA_IM_ASRC1_LOCK_EINT2_WIDTH 1 /* IM_ASRC1_LOCK_EINT2 */
4804#define ARIZONA_IM_UNDERCLOCKED_EINT2 0x0040 /* IM_UNDERCLOCKED_EINT2 */
4805#define ARIZONA_IM_UNDERCLOCKED_EINT2_MASK 0x0040 /* IM_UNDERCLOCKED_EINT2 */
4806#define ARIZONA_IM_UNDERCLOCKED_EINT2_SHIFT 6 /* IM_UNDERCLOCKED_EINT2 */
4807#define ARIZONA_IM_UNDERCLOCKED_EINT2_WIDTH 1 /* IM_UNDERCLOCKED_EINT2 */
4808#define ARIZONA_IM_OVERCLOCKED_EINT2 0x0020 /* IM_OVERCLOCKED_EINT2 */
4809#define ARIZONA_IM_OVERCLOCKED_EINT2_MASK 0x0020 /* IM_OVERCLOCKED_EINT2 */
4810#define ARIZONA_IM_OVERCLOCKED_EINT2_SHIFT 5 /* IM_OVERCLOCKED_EINT2 */
4811#define ARIZONA_IM_OVERCLOCKED_EINT2_WIDTH 1 /* IM_OVERCLOCKED_EINT2 */
4812#define ARIZONA_IM_FLL2_LOCK_EINT2 0x0008 /* IM_FLL2_LOCK_EINT2 */
4813#define ARIZONA_IM_FLL2_LOCK_EINT2_MASK 0x0008 /* IM_FLL2_LOCK_EINT2 */
4814#define ARIZONA_IM_FLL2_LOCK_EINT2_SHIFT 3 /* IM_FLL2_LOCK_EINT2 */
4815#define ARIZONA_IM_FLL2_LOCK_EINT2_WIDTH 1 /* IM_FLL2_LOCK_EINT2 */
4816#define ARIZONA_IM_FLL1_LOCK_EINT2 0x0004 /* IM_FLL1_LOCK_EINT2 */
4817#define ARIZONA_IM_FLL1_LOCK_EINT2_MASK 0x0004 /* IM_FLL1_LOCK_EINT2 */
4818#define ARIZONA_IM_FLL1_LOCK_EINT2_SHIFT 2 /* IM_FLL1_LOCK_EINT2 */
4819#define ARIZONA_IM_FLL1_LOCK_EINT2_WIDTH 1 /* IM_FLL1_LOCK_EINT2 */
4820#define ARIZONA_IM_CLKGEN_ERR_EINT2 0x0002 /* IM_CLKGEN_ERR_EINT2 */
4821#define ARIZONA_IM_CLKGEN_ERR_EINT2_MASK 0x0002 /* IM_CLKGEN_ERR_EINT2 */
4822#define ARIZONA_IM_CLKGEN_ERR_EINT2_SHIFT 1 /* IM_CLKGEN_ERR_EINT2 */
4823#define ARIZONA_IM_CLKGEN_ERR_EINT2_WIDTH 1 /* IM_CLKGEN_ERR_EINT2 */
4824#define ARIZONA_IM_CLKGEN_ERR_ASYNC_EINT2 0x0001 /* IM_CLKGEN_ERR_ASYNC_EINT2 */
4825#define ARIZONA_IM_CLKGEN_ERR_ASYNC_EINT2_MASK 0x0001 /* IM_CLKGEN_ERR_ASYNC_EINT2 */
4826#define ARIZONA_IM_CLKGEN_ERR_ASYNC_EINT2_SHIFT 0 /* IM_CLKGEN_ERR_ASYNC_EINT2 */
4827#define ARIZONA_IM_CLKGEN_ERR_ASYNC_EINT2_WIDTH 1 /* IM_CLKGEN_ERR_ASYNC_EINT2 */
4828
4829/*
4830 * R3355 (0xD1B) - IRQ2 Status 4 Mask
4831 */
4832#define ARIZONA_IM_ASRC_CFG_ERR_EINT2 0x8000 /* IM_ASRC_CFG_ERR_EINT2 */
4833#define ARIZONA_IM_ASRC_CFG_ERR_EINT2_MASK 0x8000 /* IM_ASRC_CFG_ERR_EINT2 */
4834#define ARIZONA_IM_ASRC_CFG_ERR_EINT2_SHIFT 15 /* IM_ASRC_CFG_ERR_EINT2 */
4835#define ARIZONA_IM_ASRC_CFG_ERR_EINT2_WIDTH 1 /* IM_ASRC_CFG_ERR_EINT2 */
4836#define ARIZONA_IM_AIF3_ERR_EINT2 0x4000 /* IM_AIF3_ERR_EINT2 */
4837#define ARIZONA_IM_AIF3_ERR_EINT2_MASK 0x4000 /* IM_AIF3_ERR_EINT2 */
4838#define ARIZONA_IM_AIF3_ERR_EINT2_SHIFT 14 /* IM_AIF3_ERR_EINT2 */
4839#define ARIZONA_IM_AIF3_ERR_EINT2_WIDTH 1 /* IM_AIF3_ERR_EINT2 */
4840#define ARIZONA_IM_AIF2_ERR_EINT2 0x2000 /* IM_AIF2_ERR_EINT2 */
4841#define ARIZONA_IM_AIF2_ERR_EINT2_MASK 0x2000 /* IM_AIF2_ERR_EINT2 */
4842#define ARIZONA_IM_AIF2_ERR_EINT2_SHIFT 13 /* IM_AIF2_ERR_EINT2 */
4843#define ARIZONA_IM_AIF2_ERR_EINT2_WIDTH 1 /* IM_AIF2_ERR_EINT2 */
4844#define ARIZONA_IM_AIF1_ERR_EINT2 0x1000 /* IM_AIF1_ERR_EINT2 */
4845#define ARIZONA_IM_AIF1_ERR_EINT2_MASK 0x1000 /* IM_AIF1_ERR_EINT2 */
4846#define ARIZONA_IM_AIF1_ERR_EINT2_SHIFT 12 /* IM_AIF1_ERR_EINT2 */
4847#define ARIZONA_IM_AIF1_ERR_EINT2_WIDTH 1 /* IM_AIF1_ERR_EINT2 */
4848#define ARIZONA_IM_CTRLIF_ERR_EINT2 0x0800 /* IM_CTRLIF_ERR_EINT2 */
4849#define ARIZONA_IM_CTRLIF_ERR_EINT2_MASK 0x0800 /* IM_CTRLIF_ERR_EINT2 */
4850#define ARIZONA_IM_CTRLIF_ERR_EINT2_SHIFT 11 /* IM_CTRLIF_ERR_EINT2 */
4851#define ARIZONA_IM_CTRLIF_ERR_EINT2_WIDTH 1 /* IM_CTRLIF_ERR_EINT2 */
4852#define ARIZONA_IM_MIXER_DROPPED_SAMPLE_EINT2 0x0400 /* IM_MIXER_DROPPED_SAMPLE_EINT2 */
4853#define ARIZONA_IM_MIXER_DROPPED_SAMPLE_EINT2_MASK 0x0400 /* IM_MIXER_DROPPED_SAMPLE_EINT2 */
4854#define ARIZONA_IM_MIXER_DROPPED_SAMPLE_EINT2_SHIFT 10 /* IM_MIXER_DROPPED_SAMPLE_EINT2 */
4855#define ARIZONA_IM_MIXER_DROPPED_SAMPLE_EINT2_WIDTH 1 /* IM_MIXER_DROPPED_SAMPLE_EINT2 */
4856#define ARIZONA_IM_ASYNC_CLK_ENA_LOW_EINT2 0x0200 /* IM_ASYNC_CLK_ENA_LOW_EINT2 */
4857#define ARIZONA_IM_ASYNC_CLK_ENA_LOW_EINT2_MASK 0x0200 /* IM_ASYNC_CLK_ENA_LOW_EINT2 */
4858#define ARIZONA_IM_ASYNC_CLK_ENA_LOW_EINT2_SHIFT 9 /* IM_ASYNC_CLK_ENA_LOW_EINT2 */
4859#define ARIZONA_IM_ASYNC_CLK_ENA_LOW_EINT2_WIDTH 1 /* IM_ASYNC_CLK_ENA_LOW_EINT2 */
4860#define ARIZONA_IM_SYSCLK_ENA_LOW_EINT2 0x0100 /* IM_SYSCLK_ENA_LOW_EINT2 */
4861#define ARIZONA_IM_SYSCLK_ENA_LOW_EINT2_MASK 0x0100 /* IM_SYSCLK_ENA_LOW_EINT2 */
4862#define ARIZONA_IM_SYSCLK_ENA_LOW_EINT2_SHIFT 8 /* IM_SYSCLK_ENA_LOW_EINT2 */
4863#define ARIZONA_IM_SYSCLK_ENA_LOW_EINT2_WIDTH 1 /* IM_SYSCLK_ENA_LOW_EINT2 */
4864#define ARIZONA_IM_ISRC1_CFG_ERR_EINT2 0x0080 /* IM_ISRC1_CFG_ERR_EINT2 */
4865#define ARIZONA_IM_ISRC1_CFG_ERR_EINT2_MASK 0x0080 /* IM_ISRC1_CFG_ERR_EINT2 */
4866#define ARIZONA_IM_ISRC1_CFG_ERR_EINT2_SHIFT 7 /* IM_ISRC1_CFG_ERR_EINT2 */
4867#define ARIZONA_IM_ISRC1_CFG_ERR_EINT2_WIDTH 1 /* IM_ISRC1_CFG_ERR_EINT2 */
4868#define ARIZONA_IM_ISRC2_CFG_ERR_EINT2 0x0040 /* IM_ISRC2_CFG_ERR_EINT2 */
4869#define ARIZONA_IM_ISRC2_CFG_ERR_EINT2_MASK 0x0040 /* IM_ISRC2_CFG_ERR_EINT2 */
4870#define ARIZONA_IM_ISRC2_CFG_ERR_EINT2_SHIFT 6 /* IM_ISRC2_CFG_ERR_EINT2 */
4871#define ARIZONA_IM_ISRC2_CFG_ERR_EINT2_WIDTH 1 /* IM_ISRC2_CFG_ERR_EINT2 */
4872
4873/*
4874 * R3356 (0xD1C) - IRQ2 Status 5 Mask
4875 */
4876
4877#define ARIZONA_IM_BOOT_DONE_EINT2 0x0100 /* IM_BOOT_DONE_EINT2 */
4878#define ARIZONA_IM_BOOT_DONE_EINT2_MASK 0x0100 /* IM_BOOT_DONE_EINT2 */
4879#define ARIZONA_IM_BOOT_DONE_EINT2_SHIFT 8 /* IM_BOOT_DONE_EINT2 */
4880#define ARIZONA_IM_BOOT_DONE_EINT2_WIDTH 1 /* IM_BOOT_DONE_EINT2 */
4881#define ARIZONA_IM_DCS_DAC_DONE_EINT2 0x0080 /* IM_DCS_DAC_DONE_EINT2 */
4882#define ARIZONA_IM_DCS_DAC_DONE_EINT2_MASK 0x0080 /* IM_DCS_DAC_DONE_EINT2 */
4883#define ARIZONA_IM_DCS_DAC_DONE_EINT2_SHIFT 7 /* IM_DCS_DAC_DONE_EINT2 */
4884#define ARIZONA_IM_DCS_DAC_DONE_EINT2_WIDTH 1 /* IM_DCS_DAC_DONE_EINT2 */
4885#define ARIZONA_IM_DCS_HP_DONE_EINT2 0x0040 /* IM_DCS_HP_DONE_EINT2 */
4886#define ARIZONA_IM_DCS_HP_DONE_EINT2_MASK 0x0040 /* IM_DCS_HP_DONE_EINT2 */
4887#define ARIZONA_IM_DCS_HP_DONE_EINT2_SHIFT 6 /* IM_DCS_HP_DONE_EINT2 */
4888#define ARIZONA_IM_DCS_HP_DONE_EINT2_WIDTH 1 /* IM_DCS_HP_DONE_EINT2 */
4889#define ARIZONA_IM_FLL2_CLOCK_OK_EINT2 0x0002 /* IM_FLL2_CLOCK_OK_EINT2 */
4890#define ARIZONA_IM_FLL2_CLOCK_OK_EINT2_MASK 0x0002 /* IM_FLL2_CLOCK_OK_EINT2 */
4891#define ARIZONA_IM_FLL2_CLOCK_OK_EINT2_SHIFT 1 /* IM_FLL2_CLOCK_OK_EINT2 */
4892#define ARIZONA_IM_FLL2_CLOCK_OK_EINT2_WIDTH 1 /* IM_FLL2_CLOCK_OK_EINT2 */
4893#define ARIZONA_IM_FLL1_CLOCK_OK_EINT2 0x0001 /* IM_FLL1_CLOCK_OK_EINT2 */
4894#define ARIZONA_IM_FLL1_CLOCK_OK_EINT2_MASK 0x0001 /* IM_FLL1_CLOCK_OK_EINT2 */
4895#define ARIZONA_IM_FLL1_CLOCK_OK_EINT2_SHIFT 0 /* IM_FLL1_CLOCK_OK_EINT2 */
4896#define ARIZONA_IM_FLL1_CLOCK_OK_EINT2_WIDTH 1 /* IM_FLL1_CLOCK_OK_EINT2 */
4897
4898/*
4899 * R3359 (0xD1F) - IRQ2 Control
4900 */
4901#define ARIZONA_IM_IRQ2 0x0001 /* IM_IRQ2 */
4902#define ARIZONA_IM_IRQ2_MASK 0x0001 /* IM_IRQ2 */
4903#define ARIZONA_IM_IRQ2_SHIFT 0 /* IM_IRQ2 */
4904#define ARIZONA_IM_IRQ2_WIDTH 1 /* IM_IRQ2 */
4905
4906/*
4907 * R3360 (0xD20) - Interrupt Raw Status 2
4908 */
4909#define ARIZONA_DSP1_RAM_RDY_STS 0x0100 /* DSP1_RAM_RDY_STS */
4910#define ARIZONA_DSP1_RAM_RDY_STS_MASK 0x0100 /* DSP1_RAM_RDY_STS */
4911#define ARIZONA_DSP1_RAM_RDY_STS_SHIFT 8 /* DSP1_RAM_RDY_STS */
4912#define ARIZONA_DSP1_RAM_RDY_STS_WIDTH 1 /* DSP1_RAM_RDY_STS */
4913#define ARIZONA_DSP_IRQ2_STS 0x0002 /* DSP_IRQ2_STS */
4914#define ARIZONA_DSP_IRQ2_STS_MASK 0x0002 /* DSP_IRQ2_STS */
4915#define ARIZONA_DSP_IRQ2_STS_SHIFT 1 /* DSP_IRQ2_STS */
4916#define ARIZONA_DSP_IRQ2_STS_WIDTH 1 /* DSP_IRQ2_STS */
4917#define ARIZONA_DSP_IRQ1_STS 0x0001 /* DSP_IRQ1_STS */
4918#define ARIZONA_DSP_IRQ1_STS_MASK 0x0001 /* DSP_IRQ1_STS */
4919#define ARIZONA_DSP_IRQ1_STS_SHIFT 0 /* DSP_IRQ1_STS */
4920#define ARIZONA_DSP_IRQ1_STS_WIDTH 1 /* DSP_IRQ1_STS */
4921
4922/*
4923 * R3361 (0xD21) - Interrupt Raw Status 3
4924 */
4925#define ARIZONA_SPK_SHUTDOWN_WARN_STS 0x8000 /* SPK_SHUTDOWN_WARN_STS */
4926#define ARIZONA_SPK_SHUTDOWN_WARN_STS_MASK 0x8000 /* SPK_SHUTDOWN_WARN_STS */
4927#define ARIZONA_SPK_SHUTDOWN_WARN_STS_SHIFT 15 /* SPK_SHUTDOWN_WARN_STS */
4928#define ARIZONA_SPK_SHUTDOWN_WARN_STS_WIDTH 1 /* SPK_SHUTDOWN_WARN_STS */
4929#define ARIZONA_SPK_SHUTDOWN_STS 0x4000 /* SPK_SHUTDOWN_STS */
4930#define ARIZONA_SPK_SHUTDOWN_STS_MASK 0x4000 /* SPK_SHUTDOWN_STS */
4931#define ARIZONA_SPK_SHUTDOWN_STS_SHIFT 14 /* SPK_SHUTDOWN_STS */
4932#define ARIZONA_SPK_SHUTDOWN_STS_WIDTH 1 /* SPK_SHUTDOWN_STS */
4933#define ARIZONA_HPDET_STS 0x2000 /* HPDET_STS */
4934#define ARIZONA_HPDET_STS_MASK 0x2000 /* HPDET_STS */
4935#define ARIZONA_HPDET_STS_SHIFT 13 /* HPDET_STS */
4936#define ARIZONA_HPDET_STS_WIDTH 1 /* HPDET_STS */
4937#define ARIZONA_MICDET_STS 0x1000 /* MICDET_STS */
4938#define ARIZONA_MICDET_STS_MASK 0x1000 /* MICDET_STS */
4939#define ARIZONA_MICDET_STS_SHIFT 12 /* MICDET_STS */
4940#define ARIZONA_MICDET_STS_WIDTH 1 /* MICDET_STS */
4941#define ARIZONA_WSEQ_DONE_STS 0x0800 /* WSEQ_DONE_STS */
4942#define ARIZONA_WSEQ_DONE_STS_MASK 0x0800 /* WSEQ_DONE_STS */
4943#define ARIZONA_WSEQ_DONE_STS_SHIFT 11 /* WSEQ_DONE_STS */
4944#define ARIZONA_WSEQ_DONE_STS_WIDTH 1 /* WSEQ_DONE_STS */
4945#define ARIZONA_DRC2_SIG_DET_STS 0x0400 /* DRC2_SIG_DET_STS */
4946#define ARIZONA_DRC2_SIG_DET_STS_MASK 0x0400 /* DRC2_SIG_DET_STS */
4947#define ARIZONA_DRC2_SIG_DET_STS_SHIFT 10 /* DRC2_SIG_DET_STS */
4948#define ARIZONA_DRC2_SIG_DET_STS_WIDTH 1 /* DRC2_SIG_DET_STS */
4949#define ARIZONA_DRC1_SIG_DET_STS 0x0200 /* DRC1_SIG_DET_STS */
4950#define ARIZONA_DRC1_SIG_DET_STS_MASK 0x0200 /* DRC1_SIG_DET_STS */
4951#define ARIZONA_DRC1_SIG_DET_STS_SHIFT 9 /* DRC1_SIG_DET_STS */
4952#define ARIZONA_DRC1_SIG_DET_STS_WIDTH 1 /* DRC1_SIG_DET_STS */
4953#define ARIZONA_ASRC2_LOCK_STS 0x0100 /* ASRC2_LOCK_STS */
4954#define ARIZONA_ASRC2_LOCK_STS_MASK 0x0100 /* ASRC2_LOCK_STS */
4955#define ARIZONA_ASRC2_LOCK_STS_SHIFT 8 /* ASRC2_LOCK_STS */
4956#define ARIZONA_ASRC2_LOCK_STS_WIDTH 1 /* ASRC2_LOCK_STS */
4957#define ARIZONA_ASRC1_LOCK_STS 0x0080 /* ASRC1_LOCK_STS */
4958#define ARIZONA_ASRC1_LOCK_STS_MASK 0x0080 /* ASRC1_LOCK_STS */
4959#define ARIZONA_ASRC1_LOCK_STS_SHIFT 7 /* ASRC1_LOCK_STS */
4960#define ARIZONA_ASRC1_LOCK_STS_WIDTH 1 /* ASRC1_LOCK_STS */
4961#define ARIZONA_UNDERCLOCKED_STS 0x0040 /* UNDERCLOCKED_STS */
4962#define ARIZONA_UNDERCLOCKED_STS_MASK 0x0040 /* UNDERCLOCKED_STS */
4963#define ARIZONA_UNDERCLOCKED_STS_SHIFT 6 /* UNDERCLOCKED_STS */
4964#define ARIZONA_UNDERCLOCKED_STS_WIDTH 1 /* UNDERCLOCKED_STS */
4965#define ARIZONA_OVERCLOCKED_STS 0x0020 /* OVERCLOCKED_STS */
4966#define ARIZONA_OVERCLOCKED_STS_MASK 0x0020 /* OVERCLOCKED_STS */
4967#define ARIZONA_OVERCLOCKED_STS_SHIFT 5 /* OVERCLOCKED_STS */
4968#define ARIZONA_OVERCLOCKED_STS_WIDTH 1 /* OVERCLOCKED_STS */
4969#define ARIZONA_FLL2_LOCK_STS 0x0008 /* FLL2_LOCK_STS */
4970#define ARIZONA_FLL2_LOCK_STS_MASK 0x0008 /* FLL2_LOCK_STS */
4971#define ARIZONA_FLL2_LOCK_STS_SHIFT 3 /* FLL2_LOCK_STS */
4972#define ARIZONA_FLL2_LOCK_STS_WIDTH 1 /* FLL2_LOCK_STS */
4973#define ARIZONA_FLL1_LOCK_STS 0x0004 /* FLL1_LOCK_STS */
4974#define ARIZONA_FLL1_LOCK_STS_MASK 0x0004 /* FLL1_LOCK_STS */
4975#define ARIZONA_FLL1_LOCK_STS_SHIFT 2 /* FLL1_LOCK_STS */
4976#define ARIZONA_FLL1_LOCK_STS_WIDTH 1 /* FLL1_LOCK_STS */
4977#define ARIZONA_CLKGEN_ERR_STS 0x0002 /* CLKGEN_ERR_STS */
4978#define ARIZONA_CLKGEN_ERR_STS_MASK 0x0002 /* CLKGEN_ERR_STS */
4979#define ARIZONA_CLKGEN_ERR_STS_SHIFT 1 /* CLKGEN_ERR_STS */
4980#define ARIZONA_CLKGEN_ERR_STS_WIDTH 1 /* CLKGEN_ERR_STS */
4981#define ARIZONA_CLKGEN_ERR_ASYNC_STS 0x0001 /* CLKGEN_ERR_ASYNC_STS */
4982#define ARIZONA_CLKGEN_ERR_ASYNC_STS_MASK 0x0001 /* CLKGEN_ERR_ASYNC_STS */
4983#define ARIZONA_CLKGEN_ERR_ASYNC_STS_SHIFT 0 /* CLKGEN_ERR_ASYNC_STS */
4984#define ARIZONA_CLKGEN_ERR_ASYNC_STS_WIDTH 1 /* CLKGEN_ERR_ASYNC_STS */
4985
4986/*
4987 * R3362 (0xD22) - Interrupt Raw Status 4
4988 */
4989#define ARIZONA_ASRC_CFG_ERR_STS 0x8000 /* ASRC_CFG_ERR_STS */
4990#define ARIZONA_ASRC_CFG_ERR_STS_MASK 0x8000 /* ASRC_CFG_ERR_STS */
4991#define ARIZONA_ASRC_CFG_ERR_STS_SHIFT 15 /* ASRC_CFG_ERR_STS */
4992#define ARIZONA_ASRC_CFG_ERR_STS_WIDTH 1 /* ASRC_CFG_ERR_STS */
4993#define ARIZONA_AIF3_ERR_STS 0x4000 /* AIF3_ERR_STS */
4994#define ARIZONA_AIF3_ERR_STS_MASK 0x4000 /* AIF3_ERR_STS */
4995#define ARIZONA_AIF3_ERR_STS_SHIFT 14 /* AIF3_ERR_STS */
4996#define ARIZONA_AIF3_ERR_STS_WIDTH 1 /* AIF3_ERR_STS */
4997#define ARIZONA_AIF2_ERR_STS 0x2000 /* AIF2_ERR_STS */
4998#define ARIZONA_AIF2_ERR_STS_MASK 0x2000 /* AIF2_ERR_STS */
4999#define ARIZONA_AIF2_ERR_STS_SHIFT 13 /* AIF2_ERR_STS */
5000#define ARIZONA_AIF2_ERR_STS_WIDTH 1 /* AIF2_ERR_STS */
5001#define ARIZONA_AIF1_ERR_STS 0x1000 /* AIF1_ERR_STS */
5002#define ARIZONA_AIF1_ERR_STS_MASK 0x1000 /* AIF1_ERR_STS */
5003#define ARIZONA_AIF1_ERR_STS_SHIFT 12 /* AIF1_ERR_STS */
5004#define ARIZONA_AIF1_ERR_STS_WIDTH 1 /* AIF1_ERR_STS */
5005#define ARIZONA_CTRLIF_ERR_STS 0x0800 /* CTRLIF_ERR_STS */
5006#define ARIZONA_CTRLIF_ERR_STS_MASK 0x0800 /* CTRLIF_ERR_STS */
5007#define ARIZONA_CTRLIF_ERR_STS_SHIFT 11 /* CTRLIF_ERR_STS */
5008#define ARIZONA_CTRLIF_ERR_STS_WIDTH 1 /* CTRLIF_ERR_STS */
5009#define ARIZONA_MIXER_DROPPED_SAMPLE_STS 0x0400 /* MIXER_DROPPED_SAMPLE_STS */
5010#define ARIZONA_MIXER_DROPPED_SAMPLE_STS_MASK 0x0400 /* MIXER_DROPPED_SAMPLE_STS */
5011#define ARIZONA_MIXER_DROPPED_SAMPLE_STS_SHIFT 10 /* MIXER_DROPPED_SAMPLE_STS */
5012#define ARIZONA_MIXER_DROPPED_SAMPLE_STS_WIDTH 1 /* MIXER_DROPPED_SAMPLE_STS */
5013#define ARIZONA_ASYNC_CLK_ENA_LOW_STS 0x0200 /* ASYNC_CLK_ENA_LOW_STS */
5014#define ARIZONA_ASYNC_CLK_ENA_LOW_STS_MASK 0x0200 /* ASYNC_CLK_ENA_LOW_STS */
5015#define ARIZONA_ASYNC_CLK_ENA_LOW_STS_SHIFT 9 /* ASYNC_CLK_ENA_LOW_STS */
5016#define ARIZONA_ASYNC_CLK_ENA_LOW_STS_WIDTH 1 /* ASYNC_CLK_ENA_LOW_STS */
5017#define ARIZONA_SYSCLK_ENA_LOW_STS 0x0100 /* SYSCLK_ENA_LOW_STS */
5018#define ARIZONA_SYSCLK_ENA_LOW_STS_MASK 0x0100 /* SYSCLK_ENA_LOW_STS */
5019#define ARIZONA_SYSCLK_ENA_LOW_STS_SHIFT 8 /* SYSCLK_ENA_LOW_STS */
5020#define ARIZONA_SYSCLK_ENA_LOW_STS_WIDTH 1 /* SYSCLK_ENA_LOW_STS */
5021#define ARIZONA_ISRC1_CFG_ERR_STS 0x0080 /* ISRC1_CFG_ERR_STS */
5022#define ARIZONA_ISRC1_CFG_ERR_STS_MASK 0x0080 /* ISRC1_CFG_ERR_STS */
5023#define ARIZONA_ISRC1_CFG_ERR_STS_SHIFT 7 /* ISRC1_CFG_ERR_STS */
5024#define ARIZONA_ISRC1_CFG_ERR_STS_WIDTH 1 /* ISRC1_CFG_ERR_STS */
5025#define ARIZONA_ISRC2_CFG_ERR_STS 0x0040 /* ISRC2_CFG_ERR_STS */
5026#define ARIZONA_ISRC2_CFG_ERR_STS_MASK 0x0040 /* ISRC2_CFG_ERR_STS */
5027#define ARIZONA_ISRC2_CFG_ERR_STS_SHIFT 6 /* ISRC2_CFG_ERR_STS */
5028#define ARIZONA_ISRC2_CFG_ERR_STS_WIDTH 1 /* ISRC2_CFG_ERR_STS */
5029
5030/*
5031 * R3363 (0xD23) - Interrupt Raw Status 5
5032 */
5033#define ARIZONA_BOOT_DONE_STS 0x0100 /* BOOT_DONE_STS */
5034#define ARIZONA_BOOT_DONE_STS_MASK 0x0100 /* BOOT_DONE_STS */
5035#define ARIZONA_BOOT_DONE_STS_SHIFT 8 /* BOOT_DONE_STS */
5036#define ARIZONA_BOOT_DONE_STS_WIDTH 1 /* BOOT_DONE_STS */
5037#define ARIZONA_DCS_DAC_DONE_STS 0x0080 /* DCS_DAC_DONE_STS */
5038#define ARIZONA_DCS_DAC_DONE_STS_MASK 0x0080 /* DCS_DAC_DONE_STS */
5039#define ARIZONA_DCS_DAC_DONE_STS_SHIFT 7 /* DCS_DAC_DONE_STS */
5040#define ARIZONA_DCS_DAC_DONE_STS_WIDTH 1 /* DCS_DAC_DONE_STS */
5041#define ARIZONA_DCS_HP_DONE_STS 0x0040 /* DCS_HP_DONE_STS */
5042#define ARIZONA_DCS_HP_DONE_STS_MASK 0x0040 /* DCS_HP_DONE_STS */
5043#define ARIZONA_DCS_HP_DONE_STS_SHIFT 6 /* DCS_HP_DONE_STS */
5044#define ARIZONA_DCS_HP_DONE_STS_WIDTH 1 /* DCS_HP_DONE_STS */
5045#define ARIZONA_FLL2_CLOCK_OK_STS 0x0002 /* FLL2_CLOCK_OK_STS */
5046#define ARIZONA_FLL2_CLOCK_OK_STS_MASK 0x0002 /* FLL2_CLOCK_OK_STS */
5047#define ARIZONA_FLL2_CLOCK_OK_STS_SHIFT 1 /* FLL2_CLOCK_OK_STS */
5048#define ARIZONA_FLL2_CLOCK_OK_STS_WIDTH 1 /* FLL2_CLOCK_OK_STS */
5049#define ARIZONA_FLL1_CLOCK_OK_STS 0x0001 /* FLL1_CLOCK_OK_STS */
5050#define ARIZONA_FLL1_CLOCK_OK_STS_MASK 0x0001 /* FLL1_CLOCK_OK_STS */
5051#define ARIZONA_FLL1_CLOCK_OK_STS_SHIFT 0 /* FLL1_CLOCK_OK_STS */
5052#define ARIZONA_FLL1_CLOCK_OK_STS_WIDTH 1 /* FLL1_CLOCK_OK_STS */
5053
5054/*
5055 * R3364 (0xD24) - Interrupt Raw Status 6
5056 */
5057#define ARIZONA_PWM_OVERCLOCKED_STS 0x2000 /* PWM_OVERCLOCKED_STS */
5058#define ARIZONA_PWM_OVERCLOCKED_STS_MASK 0x2000 /* PWM_OVERCLOCKED_STS */
5059#define ARIZONA_PWM_OVERCLOCKED_STS_SHIFT 13 /* PWM_OVERCLOCKED_STS */
5060#define ARIZONA_PWM_OVERCLOCKED_STS_WIDTH 1 /* PWM_OVERCLOCKED_STS */
5061#define ARIZONA_FX_CORE_OVERCLOCKED_STS 0x1000 /* FX_CORE_OVERCLOCKED_STS */
5062#define ARIZONA_FX_CORE_OVERCLOCKED_STS_MASK 0x1000 /* FX_CORE_OVERCLOCKED_STS */
5063#define ARIZONA_FX_CORE_OVERCLOCKED_STS_SHIFT 12 /* FX_CORE_OVERCLOCKED_STS */
5064#define ARIZONA_FX_CORE_OVERCLOCKED_STS_WIDTH 1 /* FX_CORE_OVERCLOCKED_STS */
5065#define ARIZONA_DAC_SYS_OVERCLOCKED_STS 0x0400 /* DAC_SYS_OVERCLOCKED_STS */
5066#define ARIZONA_DAC_SYS_OVERCLOCKED_STS_MASK 0x0400 /* DAC_SYS_OVERCLOCKED_STS */
5067#define ARIZONA_DAC_SYS_OVERCLOCKED_STS_SHIFT 10 /* DAC_SYS_OVERCLOCKED_STS */
5068#define ARIZONA_DAC_SYS_OVERCLOCKED_STS_WIDTH 1 /* DAC_SYS_OVERCLOCKED_STS */
5069#define ARIZONA_DAC_WARP_OVERCLOCKED_STS 0x0200 /* DAC_WARP_OVERCLOCKED_STS */
5070#define ARIZONA_DAC_WARP_OVERCLOCKED_STS_MASK 0x0200 /* DAC_WARP_OVERCLOCKED_STS */
5071#define ARIZONA_DAC_WARP_OVERCLOCKED_STS_SHIFT 9 /* DAC_WARP_OVERCLOCKED_STS */
5072#define ARIZONA_DAC_WARP_OVERCLOCKED_STS_WIDTH 1 /* DAC_WARP_OVERCLOCKED_STS */
5073#define ARIZONA_ADC_OVERCLOCKED_STS 0x0100 /* ADC_OVERCLOCKED_STS */
5074#define ARIZONA_ADC_OVERCLOCKED_STS_MASK 0x0100 /* ADC_OVERCLOCKED_STS */
5075#define ARIZONA_ADC_OVERCLOCKED_STS_SHIFT 8 /* ADC_OVERCLOCKED_STS */
5076#define ARIZONA_ADC_OVERCLOCKED_STS_WIDTH 1 /* ADC_OVERCLOCKED_STS */
5077#define ARIZONA_MIXER_OVERCLOCKED_STS 0x0080 /* MIXER_OVERCLOCKED_STS */
5078#define ARIZONA_MIXER_OVERCLOCKED_STS_MASK 0x0080 /* MIXER_OVERCLOCKED_STS */
5079#define ARIZONA_MIXER_OVERCLOCKED_STS_SHIFT 7 /* MIXER_OVERCLOCKED_STS */
5080#define ARIZONA_MIXER_OVERCLOCKED_STS_WIDTH 1 /* MIXER_OVERCLOCKED_STS */
5081#define ARIZONA_AIF3_ASYNC_OVERCLOCKED_STS 0x0040 /* AIF3_ASYNC_OVERCLOCKED_STS */
5082#define ARIZONA_AIF3_ASYNC_OVERCLOCKED_STS_MASK 0x0040 /* AIF3_ASYNC_OVERCLOCKED_STS */
5083#define ARIZONA_AIF3_ASYNC_OVERCLOCKED_STS_SHIFT 6 /* AIF3_ASYNC_OVERCLOCKED_STS */
5084#define ARIZONA_AIF3_ASYNC_OVERCLOCKED_STS_WIDTH 1 /* AIF3_ASYNC_OVERCLOCKED_STS */
5085#define ARIZONA_AIF2_ASYNC_OVERCLOCKED_STS 0x0020 /* AIF2_ASYNC_OVERCLOCKED_STS */
5086#define ARIZONA_AIF2_ASYNC_OVERCLOCKED_STS_MASK 0x0020 /* AIF2_ASYNC_OVERCLOCKED_STS */
5087#define ARIZONA_AIF2_ASYNC_OVERCLOCKED_STS_SHIFT 5 /* AIF2_ASYNC_OVERCLOCKED_STS */
5088#define ARIZONA_AIF2_ASYNC_OVERCLOCKED_STS_WIDTH 1 /* AIF2_ASYNC_OVERCLOCKED_STS */
5089#define ARIZONA_AIF1_ASYNC_OVERCLOCKED_STS 0x0010 /* AIF1_ASYNC_OVERCLOCKED_STS */
5090#define ARIZONA_AIF1_ASYNC_OVERCLOCKED_STS_MASK 0x0010 /* AIF1_ASYNC_OVERCLOCKED_STS */
5091#define ARIZONA_AIF1_ASYNC_OVERCLOCKED_STS_SHIFT 4 /* AIF1_ASYNC_OVERCLOCKED_STS */
5092#define ARIZONA_AIF1_ASYNC_OVERCLOCKED_STS_WIDTH 1 /* AIF1_ASYNC_OVERCLOCKED_STS */
5093#define ARIZONA_AIF3_SYNC_OVERCLOCKED_STS 0x0008 /* AIF3_SYNC_OVERCLOCKED_STS */
5094#define ARIZONA_AIF3_SYNC_OVERCLOCKED_STS_MASK 0x0008 /* AIF3_SYNC_OVERCLOCKED_STS */
5095#define ARIZONA_AIF3_SYNC_OVERCLOCKED_STS_SHIFT 3 /* AIF3_SYNC_OVERCLOCKED_STS */
5096#define ARIZONA_AIF3_SYNC_OVERCLOCKED_STS_WIDTH 1 /* AIF3_SYNC_OVERCLOCKED_STS */
5097#define ARIZONA_AIF2_SYNC_OVERCLOCKED_STS 0x0004 /* AIF2_SYNC_OVERCLOCKED_STS */
5098#define ARIZONA_AIF2_SYNC_OVERCLOCKED_STS_MASK 0x0004 /* AIF2_SYNC_OVERCLOCKED_STS */
5099#define ARIZONA_AIF2_SYNC_OVERCLOCKED_STS_SHIFT 2 /* AIF2_SYNC_OVERCLOCKED_STS */
5100#define ARIZONA_AIF2_SYNC_OVERCLOCKED_STS_WIDTH 1 /* AIF2_SYNC_OVERCLOCKED_STS */
5101#define ARIZONA_AIF1_SYNC_OVERCLOCKED_STS 0x0002 /* AIF1_SYNC_OVERCLOCKED_STS */
5102#define ARIZONA_AIF1_SYNC_OVERCLOCKED_STS_MASK 0x0002 /* AIF1_SYNC_OVERCLOCKED_STS */
5103#define ARIZONA_AIF1_SYNC_OVERCLOCKED_STS_SHIFT 1 /* AIF1_SYNC_OVERCLOCKED_STS */
5104#define ARIZONA_AIF1_SYNC_OVERCLOCKED_STS_WIDTH 1 /* AIF1_SYNC_OVERCLOCKED_STS */
5105#define ARIZONA_PAD_CTRL_OVERCLOCKED_STS 0x0001 /* PAD_CTRL_OVERCLOCKED_STS */
5106#define ARIZONA_PAD_CTRL_OVERCLOCKED_STS_MASK 0x0001 /* PAD_CTRL_OVERCLOCKED_STS */
5107#define ARIZONA_PAD_CTRL_OVERCLOCKED_STS_SHIFT 0 /* PAD_CTRL_OVERCLOCKED_STS */
5108#define ARIZONA_PAD_CTRL_OVERCLOCKED_STS_WIDTH 1 /* PAD_CTRL_OVERCLOCKED_STS */
5109
5110/*
5111 * R3365 (0xD25) - Interrupt Raw Status 7
5112 */
5113#define ARIZONA_SLIMBUS_SUBSYS_OVERCLOCKED_STS 0x8000 /* SLIMBUS_SUBSYS_OVERCLOCKED_STS */
5114#define ARIZONA_SLIMBUS_SUBSYS_OVERCLOCKED_STS_MASK 0x8000 /* SLIMBUS_SUBSYS_OVERCLOCKED_STS */
5115#define ARIZONA_SLIMBUS_SUBSYS_OVERCLOCKED_STS_SHIFT 15 /* SLIMBUS_SUBSYS_OVERCLOCKED_STS */
5116#define ARIZONA_SLIMBUS_SUBSYS_OVERCLOCKED_STS_WIDTH 1 /* SLIMBUS_SUBSYS_OVERCLOCKED_STS */
5117#define ARIZONA_SLIMBUS_ASYNC_OVERCLOCKED_STS 0x4000 /* SLIMBUS_ASYNC_OVERCLOCKED_STS */
5118#define ARIZONA_SLIMBUS_ASYNC_OVERCLOCKED_STS_MASK 0x4000 /* SLIMBUS_ASYNC_OVERCLOCKED_STS */
5119#define ARIZONA_SLIMBUS_ASYNC_OVERCLOCKED_STS_SHIFT 14 /* SLIMBUS_ASYNC_OVERCLOCKED_STS */
5120#define ARIZONA_SLIMBUS_ASYNC_OVERCLOCKED_STS_WIDTH 1 /* SLIMBUS_ASYNC_OVERCLOCKED_STS */
5121#define ARIZONA_SLIMBUS_SYNC_OVERCLOCKED_STS 0x2000 /* SLIMBUS_SYNC_OVERCLOCKED_STS */
5122#define ARIZONA_SLIMBUS_SYNC_OVERCLOCKED_STS_MASK 0x2000 /* SLIMBUS_SYNC_OVERCLOCKED_STS */
5123#define ARIZONA_SLIMBUS_SYNC_OVERCLOCKED_STS_SHIFT 13 /* SLIMBUS_SYNC_OVERCLOCKED_STS */
5124#define ARIZONA_SLIMBUS_SYNC_OVERCLOCKED_STS_WIDTH 1 /* SLIMBUS_SYNC_OVERCLOCKED_STS */
5125#define ARIZONA_ASRC_ASYNC_SYS_OVERCLOCKED_STS 0x1000 /* ASRC_ASYNC_SYS_OVERCLOCKED_STS */
5126#define ARIZONA_ASRC_ASYNC_SYS_OVERCLOCKED_STS_MASK 0x1000 /* ASRC_ASYNC_SYS_OVERCLOCKED_STS */
5127#define ARIZONA_ASRC_ASYNC_SYS_OVERCLOCKED_STS_SHIFT 12 /* ASRC_ASYNC_SYS_OVERCLOCKED_STS */
5128#define ARIZONA_ASRC_ASYNC_SYS_OVERCLOCKED_STS_WIDTH 1 /* ASRC_ASYNC_SYS_OVERCLOCKED_STS */
5129#define ARIZONA_ASRC_ASYNC_WARP_OVERCLOCKED_STS 0x0800 /* ASRC_ASYNC_WARP_OVERCLOCKED_STS */
5130#define ARIZONA_ASRC_ASYNC_WARP_OVERCLOCKED_STS_MASK 0x0800 /* ASRC_ASYNC_WARP_OVERCLOCKED_STS */
5131#define ARIZONA_ASRC_ASYNC_WARP_OVERCLOCKED_STS_SHIFT 11 /* ASRC_ASYNC_WARP_OVERCLOCKED_STS */
5132#define ARIZONA_ASRC_ASYNC_WARP_OVERCLOCKED_STS_WIDTH 1 /* ASRC_ASYNC_WARP_OVERCLOCKED_STS */
5133#define ARIZONA_ASRC_SYNC_SYS_OVERCLOCKED_STS 0x0400 /* ASRC_SYNC_SYS_OVERCLOCKED_STS */
5134#define ARIZONA_ASRC_SYNC_SYS_OVERCLOCKED_STS_MASK 0x0400 /* ASRC_SYNC_SYS_OVERCLOCKED_STS */
5135#define ARIZONA_ASRC_SYNC_SYS_OVERCLOCKED_STS_SHIFT 10 /* ASRC_SYNC_SYS_OVERCLOCKED_STS */
5136#define ARIZONA_ASRC_SYNC_SYS_OVERCLOCKED_STS_WIDTH 1 /* ASRC_SYNC_SYS_OVERCLOCKED_STS */
5137#define ARIZONA_ASRC_SYNC_WARP_OVERCLOCKED_STS 0x0200 /* ASRC_SYNC_WARP_OVERCLOCKED_STS */
5138#define ARIZONA_ASRC_SYNC_WARP_OVERCLOCKED_STS_MASK 0x0200 /* ASRC_SYNC_WARP_OVERCLOCKED_STS */
5139#define ARIZONA_ASRC_SYNC_WARP_OVERCLOCKED_STS_SHIFT 9 /* ASRC_SYNC_WARP_OVERCLOCKED_STS */
5140#define ARIZONA_ASRC_SYNC_WARP_OVERCLOCKED_STS_WIDTH 1 /* ASRC_SYNC_WARP_OVERCLOCKED_STS */
5141#define ARIZONA_ADSP2_1_OVERCLOCKED_STS 0x0008 /* ADSP2_1_OVERCLOCKED_STS */
5142#define ARIZONA_ADSP2_1_OVERCLOCKED_STS_MASK 0x0008 /* ADSP2_1_OVERCLOCKED_STS */
5143#define ARIZONA_ADSP2_1_OVERCLOCKED_STS_SHIFT 3 /* ADSP2_1_OVERCLOCKED_STS */
5144#define ARIZONA_ADSP2_1_OVERCLOCKED_STS_WIDTH 1 /* ADSP2_1_OVERCLOCKED_STS */
5145#define ARIZONA_ISRC2_OVERCLOCKED_STS 0x0002 /* ISRC2_OVERCLOCKED_STS */
5146#define ARIZONA_ISRC2_OVERCLOCKED_STS_MASK 0x0002 /* ISRC2_OVERCLOCKED_STS */
5147#define ARIZONA_ISRC2_OVERCLOCKED_STS_SHIFT 1 /* ISRC2_OVERCLOCKED_STS */
5148#define ARIZONA_ISRC2_OVERCLOCKED_STS_WIDTH 1 /* ISRC2_OVERCLOCKED_STS */
5149#define ARIZONA_ISRC1_OVERCLOCKED_STS 0x0001 /* ISRC1_OVERCLOCKED_STS */
5150#define ARIZONA_ISRC1_OVERCLOCKED_STS_MASK 0x0001 /* ISRC1_OVERCLOCKED_STS */
5151#define ARIZONA_ISRC1_OVERCLOCKED_STS_SHIFT 0 /* ISRC1_OVERCLOCKED_STS */
5152#define ARIZONA_ISRC1_OVERCLOCKED_STS_WIDTH 1 /* ISRC1_OVERCLOCKED_STS */
5153
5154/*
5155 * R3366 (0xD26) - Interrupt Raw Status 8
5156 */
5157#define ARIZONA_AIF3_UNDERCLOCKED_STS 0x0400 /* AIF3_UNDERCLOCKED_STS */
5158#define ARIZONA_AIF3_UNDERCLOCKED_STS_MASK 0x0400 /* AIF3_UNDERCLOCKED_STS */
5159#define ARIZONA_AIF3_UNDERCLOCKED_STS_SHIFT 10 /* AIF3_UNDERCLOCKED_STS */
5160#define ARIZONA_AIF3_UNDERCLOCKED_STS_WIDTH 1 /* AIF3_UNDERCLOCKED_STS */
5161#define ARIZONA_AIF2_UNDERCLOCKED_STS 0x0200 /* AIF2_UNDERCLOCKED_STS */
5162#define ARIZONA_AIF2_UNDERCLOCKED_STS_MASK 0x0200 /* AIF2_UNDERCLOCKED_STS */
5163#define ARIZONA_AIF2_UNDERCLOCKED_STS_SHIFT 9 /* AIF2_UNDERCLOCKED_STS */
5164#define ARIZONA_AIF2_UNDERCLOCKED_STS_WIDTH 1 /* AIF2_UNDERCLOCKED_STS */
5165#define ARIZONA_AIF1_UNDERCLOCKED_STS 0x0100 /* AIF1_UNDERCLOCKED_STS */
5166#define ARIZONA_AIF1_UNDERCLOCKED_STS_MASK 0x0100 /* AIF1_UNDERCLOCKED_STS */
5167#define ARIZONA_AIF1_UNDERCLOCKED_STS_SHIFT 8 /* AIF1_UNDERCLOCKED_STS */
5168#define ARIZONA_AIF1_UNDERCLOCKED_STS_WIDTH 1 /* AIF1_UNDERCLOCKED_STS */
5169#define ARIZONA_ISRC2_UNDERCLOCKED_STS 0x0040 /* ISRC2_UNDERCLOCKED_STS */
5170#define ARIZONA_ISRC2_UNDERCLOCKED_STS_MASK 0x0040 /* ISRC2_UNDERCLOCKED_STS */
5171#define ARIZONA_ISRC2_UNDERCLOCKED_STS_SHIFT 6 /* ISRC2_UNDERCLOCKED_STS */
5172#define ARIZONA_ISRC2_UNDERCLOCKED_STS_WIDTH 1 /* ISRC2_UNDERCLOCKED_STS */
5173#define ARIZONA_ISRC1_UNDERCLOCKED_STS 0x0020 /* ISRC1_UNDERCLOCKED_STS */
5174#define ARIZONA_ISRC1_UNDERCLOCKED_STS_MASK 0x0020 /* ISRC1_UNDERCLOCKED_STS */
5175#define ARIZONA_ISRC1_UNDERCLOCKED_STS_SHIFT 5 /* ISRC1_UNDERCLOCKED_STS */
5176#define ARIZONA_ISRC1_UNDERCLOCKED_STS_WIDTH 1 /* ISRC1_UNDERCLOCKED_STS */
5177#define ARIZONA_FX_UNDERCLOCKED_STS 0x0010 /* FX_UNDERCLOCKED_STS */
5178#define ARIZONA_FX_UNDERCLOCKED_STS_MASK 0x0010 /* FX_UNDERCLOCKED_STS */
5179#define ARIZONA_FX_UNDERCLOCKED_STS_SHIFT 4 /* FX_UNDERCLOCKED_STS */
5180#define ARIZONA_FX_UNDERCLOCKED_STS_WIDTH 1 /* FX_UNDERCLOCKED_STS */
5181#define ARIZONA_ASRC_UNDERCLOCKED_STS 0x0008 /* ASRC_UNDERCLOCKED_STS */
5182#define ARIZONA_ASRC_UNDERCLOCKED_STS_MASK 0x0008 /* ASRC_UNDERCLOCKED_STS */
5183#define ARIZONA_ASRC_UNDERCLOCKED_STS_SHIFT 3 /* ASRC_UNDERCLOCKED_STS */
5184#define ARIZONA_ASRC_UNDERCLOCKED_STS_WIDTH 1 /* ASRC_UNDERCLOCKED_STS */
5185#define ARIZONA_DAC_UNDERCLOCKED_STS 0x0004 /* DAC_UNDERCLOCKED_STS */
5186#define ARIZONA_DAC_UNDERCLOCKED_STS_MASK 0x0004 /* DAC_UNDERCLOCKED_STS */
5187#define ARIZONA_DAC_UNDERCLOCKED_STS_SHIFT 2 /* DAC_UNDERCLOCKED_STS */
5188#define ARIZONA_DAC_UNDERCLOCKED_STS_WIDTH 1 /* DAC_UNDERCLOCKED_STS */
5189#define ARIZONA_ADC_UNDERCLOCKED_STS 0x0002 /* ADC_UNDERCLOCKED_STS */
5190#define ARIZONA_ADC_UNDERCLOCKED_STS_MASK 0x0002 /* ADC_UNDERCLOCKED_STS */
5191#define ARIZONA_ADC_UNDERCLOCKED_STS_SHIFT 1 /* ADC_UNDERCLOCKED_STS */
5192#define ARIZONA_ADC_UNDERCLOCKED_STS_WIDTH 1 /* ADC_UNDERCLOCKED_STS */
5193#define ARIZONA_MIXER_UNDERCLOCKED_STS 0x0001 /* MIXER_UNDERCLOCKED_STS */
5194#define ARIZONA_MIXER_UNDERCLOCKED_STS_MASK 0x0001 /* MIXER_UNDERCLOCKED_STS */
5195#define ARIZONA_MIXER_UNDERCLOCKED_STS_SHIFT 0 /* MIXER_UNDERCLOCKED_STS */
5196#define ARIZONA_MIXER_UNDERCLOCKED_STS_WIDTH 1 /* MIXER_UNDERCLOCKED_STS */
5197
5198/*
5199 * R3392 (0xD40) - IRQ Pin Status
5200 */
5201#define ARIZONA_IRQ2_STS 0x0002 /* IRQ2_STS */
5202#define ARIZONA_IRQ2_STS_MASK 0x0002 /* IRQ2_STS */
5203#define ARIZONA_IRQ2_STS_SHIFT 1 /* IRQ2_STS */
5204#define ARIZONA_IRQ2_STS_WIDTH 1 /* IRQ2_STS */
5205#define ARIZONA_IRQ1_STS 0x0001 /* IRQ1_STS */
5206#define ARIZONA_IRQ1_STS_MASK 0x0001 /* IRQ1_STS */
5207#define ARIZONA_IRQ1_STS_SHIFT 0 /* IRQ1_STS */
5208#define ARIZONA_IRQ1_STS_WIDTH 1 /* IRQ1_STS */
5209
5210/*
5211 * R3393 (0xD41) - ADSP2 IRQ0
5212 */
5213#define ARIZONA_DSP_IRQ2 0x0002 /* DSP_IRQ2 */
5214#define ARIZONA_DSP_IRQ2_MASK 0x0002 /* DSP_IRQ2 */
5215#define ARIZONA_DSP_IRQ2_SHIFT 1 /* DSP_IRQ2 */
5216#define ARIZONA_DSP_IRQ2_WIDTH 1 /* DSP_IRQ2 */
5217#define ARIZONA_DSP_IRQ1 0x0001 /* DSP_IRQ1 */
5218#define ARIZONA_DSP_IRQ1_MASK 0x0001 /* DSP_IRQ1 */
5219#define ARIZONA_DSP_IRQ1_SHIFT 0 /* DSP_IRQ1 */
5220#define ARIZONA_DSP_IRQ1_WIDTH 1 /* DSP_IRQ1 */
5221
5222/*
5223 * R3408 (0xD50) - AOD wkup and trig
5224 */
5225#define ARIZONA_GP5_FALL_TRIG_STS 0x0020 /* GP5_FALL_TRIG_STS */
5226#define ARIZONA_GP5_FALL_TRIG_STS_MASK 0x0020 /* GP5_FALL_TRIG_STS */
5227#define ARIZONA_GP5_FALL_TRIG_STS_SHIFT 5 /* GP5_FALL_TRIG_STS */
5228#define ARIZONA_GP5_FALL_TRIG_STS_WIDTH 1 /* GP5_FALL_TRIG_STS */
5229#define ARIZONA_GP5_RISE_TRIG_STS 0x0010 /* GP5_RISE_TRIG_STS */
5230#define ARIZONA_GP5_RISE_TRIG_STS_MASK 0x0010 /* GP5_RISE_TRIG_STS */
5231#define ARIZONA_GP5_RISE_TRIG_STS_SHIFT 4 /* GP5_RISE_TRIG_STS */
5232#define ARIZONA_GP5_RISE_TRIG_STS_WIDTH 1 /* GP5_RISE_TRIG_STS */
5233#define ARIZONA_JD1_FALL_TRIG_STS 0x0008 /* JD1_FALL_TRIG_STS */
5234#define ARIZONA_JD1_FALL_TRIG_STS_MASK 0x0008 /* JD1_FALL_TRIG_STS */
5235#define ARIZONA_JD1_FALL_TRIG_STS_SHIFT 3 /* JD1_FALL_TRIG_STS */
5236#define ARIZONA_JD1_FALL_TRIG_STS_WIDTH 1 /* JD1_FALL_TRIG_STS */
5237#define ARIZONA_JD1_RISE_TRIG_STS 0x0004 /* JD1_RISE_TRIG_STS */
5238#define ARIZONA_JD1_RISE_TRIG_STS_MASK 0x0004 /* JD1_RISE_TRIG_STS */
5239#define ARIZONA_JD1_RISE_TRIG_STS_SHIFT 2 /* JD1_RISE_TRIG_STS */
5240#define ARIZONA_JD1_RISE_TRIG_STS_WIDTH 1 /* JD1_RISE_TRIG_STS */
5241#define ARIZONA_JD2_FALL_TRIG_STS 0x0002 /* JD2_FALL_TRIG_STS */
5242#define ARIZONA_JD2_FALL_TRIG_STS_MASK 0x0002 /* JD2_FALL_TRIG_STS */
5243#define ARIZONA_JD2_FALL_TRIG_STS_SHIFT 1 /* JD2_FALL_TRIG_STS */
5244#define ARIZONA_JD2_FALL_TRIG_STS_WIDTH 1 /* JD2_FALL_TRIG_STS */
5245#define ARIZONA_JD2_RISE_TRIG_STS 0x0001 /* JD2_RISE_TRIG_STS */
5246#define ARIZONA_JD2_RISE_TRIG_STS_MASK 0x0001 /* JD2_RISE_TRIG_STS */
5247#define ARIZONA_JD2_RISE_TRIG_STS_SHIFT 0 /* JD2_RISE_TRIG_STS */
5248#define ARIZONA_JD2_RISE_TRIG_STS_WIDTH 1 /* JD2_RISE_TRIG_STS */
5249
5250/*
5251 * R3409 (0xD51) - AOD IRQ1
5252 */
5253#define ARIZONA_GP5_FALL_EINT1 0x0020 /* GP5_FALL_EINT1 */
5254#define ARIZONA_GP5_FALL_EINT1_MASK 0x0020 /* GP5_FALL_EINT1 */
5255#define ARIZONA_GP5_FALL_EINT1_SHIFT 5 /* GP5_FALL_EINT1 */
5256#define ARIZONA_GP5_FALL_EINT1_WIDTH 1 /* GP5_FALL_EINT1 */
5257#define ARIZONA_GP5_RISE_EINT1 0x0010 /* GP5_RISE_EINT1 */
5258#define ARIZONA_GP5_RISE_EINT1_MASK 0x0010 /* GP5_RISE_EINT1 */
5259#define ARIZONA_GP5_RISE_EINT1_SHIFT 4 /* GP5_RISE_EINT1 */
5260#define ARIZONA_GP5_RISE_EINT1_WIDTH 1 /* GP5_RISE_EINT1 */
5261#define ARIZONA_JD1_FALL_EINT1 0x0008 /* JD1_FALL_EINT1 */
5262#define ARIZONA_JD1_FALL_EINT1_MASK 0x0008 /* JD1_FALL_EINT1 */
5263#define ARIZONA_JD1_FALL_EINT1_SHIFT 3 /* JD1_FALL_EINT1 */
5264#define ARIZONA_JD1_FALL_EINT1_WIDTH 1 /* JD1_FALL_EINT1 */
5265#define ARIZONA_JD1_RISE_EINT1 0x0004 /* JD1_RISE_EINT1 */
5266#define ARIZONA_JD1_RISE_EINT1_MASK 0x0004 /* JD1_RISE_EINT1 */
5267#define ARIZONA_JD1_RISE_EINT1_SHIFT 2 /* JD1_RISE_EINT1 */
5268#define ARIZONA_JD1_RISE_EINT1_WIDTH 1 /* JD1_RISE_EINT1 */
5269#define ARIZONA_JD2_FALL_EINT1 0x0002 /* JD2_FALL_EINT1 */
5270#define ARIZONA_JD2_FALL_EINT1_MASK 0x0002 /* JD2_FALL_EINT1 */
5271#define ARIZONA_JD2_FALL_EINT1_SHIFT 1 /* JD2_FALL_EINT1 */
5272#define ARIZONA_JD2_FALL_EINT1_WIDTH 1 /* JD2_FALL_EINT1 */
5273#define ARIZONA_JD2_RISE_EINT1 0x0001 /* JD2_RISE_EINT1 */
5274#define ARIZONA_JD2_RISE_EINT1_MASK 0x0001 /* JD2_RISE_EINT1 */
5275#define ARIZONA_JD2_RISE_EINT1_SHIFT 0 /* JD2_RISE_EINT1 */
5276#define ARIZONA_JD2_RISE_EINT1_WIDTH 1 /* JD2_RISE_EINT1 */
5277
5278/*
5279 * R3410 (0xD52) - AOD IRQ2
5280 */
5281#define ARIZONA_GP5_FALL_EINT2 0x0020 /* GP5_FALL_EINT2 */
5282#define ARIZONA_GP5_FALL_EINT2_MASK 0x0020 /* GP5_FALL_EINT2 */
5283#define ARIZONA_GP5_FALL_EINT2_SHIFT 5 /* GP5_FALL_EINT2 */
5284#define ARIZONA_GP5_FALL_EINT2_WIDTH 1 /* GP5_FALL_EINT2 */
5285#define ARIZONA_GP5_RISE_EINT2 0x0010 /* GP5_RISE_EINT2 */
5286#define ARIZONA_GP5_RISE_EINT2_MASK 0x0010 /* GP5_RISE_EINT2 */
5287#define ARIZONA_GP5_RISE_EINT2_SHIFT 4 /* GP5_RISE_EINT2 */
5288#define ARIZONA_GP5_RISE_EINT2_WIDTH 1 /* GP5_RISE_EINT2 */
5289#define ARIZONA_JD1_FALL_EINT2 0x0008 /* JD1_FALL_EINT2 */
5290#define ARIZONA_JD1_FALL_EINT2_MASK 0x0008 /* JD1_FALL_EINT2 */
5291#define ARIZONA_JD1_FALL_EINT2_SHIFT 3 /* JD1_FALL_EINT2 */
5292#define ARIZONA_JD1_FALL_EINT2_WIDTH 1 /* JD1_FALL_EINT2 */
5293#define ARIZONA_JD1_RISE_EINT2 0x0004 /* JD1_RISE_EINT2 */
5294#define ARIZONA_JD1_RISE_EINT2_MASK 0x0004 /* JD1_RISE_EINT2 */
5295#define ARIZONA_JD1_RISE_EINT2_SHIFT 2 /* JD1_RISE_EINT2 */
5296#define ARIZONA_JD1_RISE_EINT2_WIDTH 1 /* JD1_RISE_EINT2 */
5297#define ARIZONA_JD2_FALL_EINT2 0x0002 /* JD2_FALL_EINT2 */
5298#define ARIZONA_JD2_FALL_EINT2_MASK 0x0002 /* JD2_FALL_EINT2 */
5299#define ARIZONA_JD2_FALL_EINT2_SHIFT 1 /* JD2_FALL_EINT2 */
5300#define ARIZONA_JD2_FALL_EINT2_WIDTH 1 /* JD2_FALL_EINT2 */
5301#define ARIZONA_JD2_RISE_EINT2 0x0001 /* JD2_RISE_EINT2 */
5302#define ARIZONA_JD2_RISE_EINT2_MASK 0x0001 /* JD2_RISE_EINT2 */
5303#define ARIZONA_JD2_RISE_EINT2_SHIFT 0 /* JD2_RISE_EINT2 */
5304#define ARIZONA_JD2_RISE_EINT2_WIDTH 1 /* JD2_RISE_EINT2 */
5305
5306/*
5307 * R3411 (0xD53) - AOD IRQ Mask IRQ1
5308 */
5309#define ARIZONA_IM_GP5_FALL_EINT1 0x0020 /* IM_GP5_FALL_EINT1 */
5310#define ARIZONA_IM_GP5_FALL_EINT1_MASK 0x0020 /* IM_GP5_FALL_EINT1 */
5311#define ARIZONA_IM_GP5_FALL_EINT1_SHIFT 5 /* IM_GP5_FALL_EINT1 */
5312#define ARIZONA_IM_GP5_FALL_EINT1_WIDTH 1 /* IM_GP5_FALL_EINT1 */
5313#define ARIZONA_IM_GP5_RISE_EINT1 0x0010 /* IM_GP5_RISE_EINT1 */
5314#define ARIZONA_IM_GP5_RISE_EINT1_MASK 0x0010 /* IM_GP5_RISE_EINT1 */
5315#define ARIZONA_IM_GP5_RISE_EINT1_SHIFT 4 /* IM_GP5_RISE_EINT1 */
5316#define ARIZONA_IM_GP5_RISE_EINT1_WIDTH 1 /* IM_GP5_RISE_EINT1 */
5317#define ARIZONA_IM_JD1_FALL_EINT1 0x0008 /* IM_JD1_FALL_EINT1 */
5318#define ARIZONA_IM_JD1_FALL_EINT1_MASK 0x0008 /* IM_JD1_FALL_EINT1 */
5319#define ARIZONA_IM_JD1_FALL_EINT1_SHIFT 3 /* IM_JD1_FALL_EINT1 */
5320#define ARIZONA_IM_JD1_FALL_EINT1_WIDTH 1 /* IM_JD1_FALL_EINT1 */
5321#define ARIZONA_IM_JD1_RISE_EINT1 0x0004 /* IM_JD1_RISE_EINT1 */
5322#define ARIZONA_IM_JD1_RISE_EINT1_MASK 0x0004 /* IM_JD1_RISE_EINT1 */
5323#define ARIZONA_IM_JD1_RISE_EINT1_SHIFT 2 /* IM_JD1_RISE_EINT1 */
5324#define ARIZONA_IM_JD1_RISE_EINT1_WIDTH 1 /* IM_JD1_RISE_EINT1 */
5325#define ARIZONA_IM_JD2_FALL_EINT1 0x0002 /* IM_JD2_FALL_EINT1 */
5326#define ARIZONA_IM_JD2_FALL_EINT1_MASK 0x0002 /* IM_JD2_FALL_EINT1 */
5327#define ARIZONA_IM_JD2_FALL_EINT1_SHIFT 1 /* IM_JD2_FALL_EINT1 */
5328#define ARIZONA_IM_JD2_FALL_EINT1_WIDTH 1 /* IM_JD2_FALL_EINT1 */
5329#define ARIZONA_IM_JD2_RISE_EINT1 0x0001 /* IM_JD2_RISE_EINT1 */
5330#define ARIZONA_IM_JD2_RISE_EINT1_MASK 0x0001 /* IM_JD2_RISE_EINT1 */
5331#define ARIZONA_IM_JD2_RISE_EINT1_SHIFT 0 /* IM_JD2_RISE_EINT1 */
5332#define ARIZONA_IM_JD2_RISE_EINT1_WIDTH 1 /* IM_JD2_RISE_EINT1 */
5333
5334/*
5335 * R3412 (0xD54) - AOD IRQ Mask IRQ2
5336 */
5337#define ARIZONA_IM_GP5_FALL_EINT2 0x0020 /* IM_GP5_FALL_EINT2 */
5338#define ARIZONA_IM_GP5_FALL_EINT2_MASK 0x0020 /* IM_GP5_FALL_EINT2 */
5339#define ARIZONA_IM_GP5_FALL_EINT2_SHIFT 5 /* IM_GP5_FALL_EINT2 */
5340#define ARIZONA_IM_GP5_FALL_EINT2_WIDTH 1 /* IM_GP5_FALL_EINT2 */
5341#define ARIZONA_IM_GP5_RISE_EINT2 0x0010 /* IM_GP5_RISE_EINT2 */
5342#define ARIZONA_IM_GP5_RISE_EINT2_MASK 0x0010 /* IM_GP5_RISE_EINT2 */
5343#define ARIZONA_IM_GP5_RISE_EINT2_SHIFT 4 /* IM_GP5_RISE_EINT2 */
5344#define ARIZONA_IM_GP5_RISE_EINT2_WIDTH 1 /* IM_GP5_RISE_EINT2 */
5345#define ARIZONA_IM_JD1_FALL_EINT2 0x0008 /* IM_JD1_FALL_EINT2 */
5346#define ARIZONA_IM_JD1_FALL_EINT2_MASK 0x0008 /* IM_JD1_FALL_EINT2 */
5347#define ARIZONA_IM_JD1_FALL_EINT2_SHIFT 3 /* IM_JD1_FALL_EINT2 */
5348#define ARIZONA_IM_JD1_FALL_EINT2_WIDTH 1 /* IM_JD1_FALL_EINT2 */
5349#define ARIZONA_IM_JD1_RISE_EINT2 0x0004 /* IM_JD1_RISE_EINT2 */
5350#define ARIZONA_IM_JD1_RISE_EINT2_MASK 0x0004 /* IM_JD1_RISE_EINT2 */
5351#define ARIZONA_IM_JD1_RISE_EINT2_SHIFT 2 /* IM_JD1_RISE_EINT2 */
5352#define ARIZONA_IM_JD1_RISE_EINT2_WIDTH 1 /* IM_JD1_RISE_EINT2 */
5353#define ARIZONA_IM_JD2_FALL_EINT2 0x0002 /* IM_JD2_FALL_EINT2 */
5354#define ARIZONA_IM_JD2_FALL_EINT2_MASK 0x0002 /* IM_JD2_FALL_EINT2 */
5355#define ARIZONA_IM_JD2_FALL_EINT2_SHIFT 1 /* IM_JD2_FALL_EINT2 */
5356#define ARIZONA_IM_JD2_FALL_EINT2_WIDTH 1 /* IM_JD2_FALL_EINT2 */
5357#define ARIZONA_IM_JD2_RISE_EINT2 0x0001 /* IM_JD2_RISE_EINT2 */
5358#define ARIZONA_IM_JD2_RISE_EINT2_MASK 0x0001 /* IM_JD2_RISE_EINT2 */
5359#define ARIZONA_IM_JD2_RISE_EINT2_SHIFT 0 /* IM_JD2_RISE_EINT2 */
5360#define ARIZONA_IM_JD2_RISE_EINT2_WIDTH 1 /* IM_JD2_RISE_EINT2 */
5361
5362/*
5363 * R3413 (0xD55) - AOD IRQ Raw Status
5364 */
5365#define ARIZONA_GP5_STS 0x0004 /* GP5_STS */
5366#define ARIZONA_GP5_STS_MASK 0x0004 /* GP5_STS */
5367#define ARIZONA_GP5_STS_SHIFT 2 /* GP5_STS */
5368#define ARIZONA_GP5_STS_WIDTH 1 /* GP5_STS */
5369#define ARIZONA_JD2_STS 0x0002 /* JD2_STS */
5370#define ARIZONA_JD2_STS_MASK 0x0002 /* JD2_STS */
5371#define ARIZONA_JD2_STS_SHIFT 1 /* JD2_STS */
5372#define ARIZONA_JD2_STS_WIDTH 1 /* JD2_STS */
5373#define ARIZONA_JD1_STS 0x0001 /* JD1_STS */
5374#define ARIZONA_JD1_STS_MASK 0x0001 /* JD1_STS */
5375#define ARIZONA_JD1_STS_SHIFT 0 /* JD1_STS */
5376#define ARIZONA_JD1_STS_WIDTH 1 /* JD1_STS */
5377
5378/*
5379 * R3414 (0xD56) - Jack detect debounce
5380 */
5381#define ARIZONA_JD2_DB 0x0002 /* JD2_DB */
5382#define ARIZONA_JD2_DB_MASK 0x0002 /* JD2_DB */
5383#define ARIZONA_JD2_DB_SHIFT 1 /* JD2_DB */
5384#define ARIZONA_JD2_DB_WIDTH 1 /* JD2_DB */
5385#define ARIZONA_JD1_DB 0x0001 /* JD1_DB */
5386#define ARIZONA_JD1_DB_MASK 0x0001 /* JD1_DB */
5387#define ARIZONA_JD1_DB_SHIFT 0 /* JD1_DB */
5388#define ARIZONA_JD1_DB_WIDTH 1 /* JD1_DB */
5389
5390/*
5391 * R3584 (0xE00) - FX_Ctrl1
5392 */
5393#define ARIZONA_FX_RATE_MASK 0x7800 /* FX_RATE - [14:11] */
5394#define ARIZONA_FX_RATE_SHIFT 11 /* FX_RATE - [14:11] */
5395#define ARIZONA_FX_RATE_WIDTH 4 /* FX_RATE - [14:11] */
5396
5397/*
5398 * R3585 (0xE01) - FX_Ctrl2
5399 */
5400#define ARIZONA_FX_STS_MASK 0xFFF0 /* FX_STS - [15:4] */
5401#define ARIZONA_FX_STS_SHIFT 4 /* FX_STS - [15:4] */
5402#define ARIZONA_FX_STS_WIDTH 12 /* FX_STS - [15:4] */
5403
5404/*
5405 * R3600 (0xE10) - EQ1_1
5406 */
5407#define ARIZONA_EQ1_B1_GAIN_MASK 0xF800 /* EQ1_B1_GAIN - [15:11] */
5408#define ARIZONA_EQ1_B1_GAIN_SHIFT 11 /* EQ1_B1_GAIN - [15:11] */
5409#define ARIZONA_EQ1_B1_GAIN_WIDTH 5 /* EQ1_B1_GAIN - [15:11] */
5410#define ARIZONA_EQ1_B2_GAIN_MASK 0x07C0 /* EQ1_B2_GAIN - [10:6] */
5411#define ARIZONA_EQ1_B2_GAIN_SHIFT 6 /* EQ1_B2_GAIN - [10:6] */
5412#define ARIZONA_EQ1_B2_GAIN_WIDTH 5 /* EQ1_B2_GAIN - [10:6] */
5413#define ARIZONA_EQ1_B3_GAIN_MASK 0x003E /* EQ1_B3_GAIN - [5:1] */
5414#define ARIZONA_EQ1_B3_GAIN_SHIFT 1 /* EQ1_B3_GAIN - [5:1] */
5415#define ARIZONA_EQ1_B3_GAIN_WIDTH 5 /* EQ1_B3_GAIN - [5:1] */
5416#define ARIZONA_EQ1_ENA 0x0001 /* EQ1_ENA */
5417#define ARIZONA_EQ1_ENA_MASK 0x0001 /* EQ1_ENA */
5418#define ARIZONA_EQ1_ENA_SHIFT 0 /* EQ1_ENA */
5419#define ARIZONA_EQ1_ENA_WIDTH 1 /* EQ1_ENA */
5420
5421/*
5422 * R3601 (0xE11) - EQ1_2
5423 */
5424#define ARIZONA_EQ1_B4_GAIN_MASK 0xF800 /* EQ1_B4_GAIN - [15:11] */
5425#define ARIZONA_EQ1_B4_GAIN_SHIFT 11 /* EQ1_B4_GAIN - [15:11] */
5426#define ARIZONA_EQ1_B4_GAIN_WIDTH 5 /* EQ1_B4_GAIN - [15:11] */
5427#define ARIZONA_EQ1_B5_GAIN_MASK 0x07C0 /* EQ1_B5_GAIN - [10:6] */
5428#define ARIZONA_EQ1_B5_GAIN_SHIFT 6 /* EQ1_B5_GAIN - [10:6] */
5429#define ARIZONA_EQ1_B5_GAIN_WIDTH 5 /* EQ1_B5_GAIN - [10:6] */
5430#define ARIZONA_EQ1_B1_MODE 0x0001 /* EQ1_B1_MODE */
5431#define ARIZONA_EQ1_B1_MODE_MASK 0x0001 /* EQ1_B1_MODE */
5432#define ARIZONA_EQ1_B1_MODE_SHIFT 0 /* EQ1_B1_MODE */
5433#define ARIZONA_EQ1_B1_MODE_WIDTH 1 /* EQ1_B1_MODE */
5434
5435/*
5436 * R3602 (0xE12) - EQ1_3
5437 */
5438#define ARIZONA_EQ1_B1_A_MASK 0xFFFF /* EQ1_B1_A - [15:0] */
5439#define ARIZONA_EQ1_B1_A_SHIFT 0 /* EQ1_B1_A - [15:0] */
5440#define ARIZONA_EQ1_B1_A_WIDTH 16 /* EQ1_B1_A - [15:0] */
5441
5442/*
5443 * R3603 (0xE13) - EQ1_4
5444 */
5445#define ARIZONA_EQ1_B1_B_MASK 0xFFFF /* EQ1_B1_B - [15:0] */
5446#define ARIZONA_EQ1_B1_B_SHIFT 0 /* EQ1_B1_B - [15:0] */
5447#define ARIZONA_EQ1_B1_B_WIDTH 16 /* EQ1_B1_B - [15:0] */
5448
5449/*
5450 * R3604 (0xE14) - EQ1_5
5451 */
5452#define ARIZONA_EQ1_B1_PG_MASK 0xFFFF /* EQ1_B1_PG - [15:0] */
5453#define ARIZONA_EQ1_B1_PG_SHIFT 0 /* EQ1_B1_PG - [15:0] */
5454#define ARIZONA_EQ1_B1_PG_WIDTH 16 /* EQ1_B1_PG - [15:0] */
5455
5456/*
5457 * R3605 (0xE15) - EQ1_6
5458 */
5459#define ARIZONA_EQ1_B2_A_MASK 0xFFFF /* EQ1_B2_A - [15:0] */
5460#define ARIZONA_EQ1_B2_A_SHIFT 0 /* EQ1_B2_A - [15:0] */
5461#define ARIZONA_EQ1_B2_A_WIDTH 16 /* EQ1_B2_A - [15:0] */
5462
5463/*
5464 * R3606 (0xE16) - EQ1_7
5465 */
5466#define ARIZONA_EQ1_B2_B_MASK 0xFFFF /* EQ1_B2_B - [15:0] */
5467#define ARIZONA_EQ1_B2_B_SHIFT 0 /* EQ1_B2_B - [15:0] */
5468#define ARIZONA_EQ1_B2_B_WIDTH 16 /* EQ1_B2_B - [15:0] */
5469
5470/*
5471 * R3607 (0xE17) - EQ1_8
5472 */
5473#define ARIZONA_EQ1_B2_C_MASK 0xFFFF /* EQ1_B2_C - [15:0] */
5474#define ARIZONA_EQ1_B2_C_SHIFT 0 /* EQ1_B2_C - [15:0] */
5475#define ARIZONA_EQ1_B2_C_WIDTH 16 /* EQ1_B2_C - [15:0] */
5476
5477/*
5478 * R3608 (0xE18) - EQ1_9
5479 */
5480#define ARIZONA_EQ1_B2_PG_MASK 0xFFFF /* EQ1_B2_PG - [15:0] */
5481#define ARIZONA_EQ1_B2_PG_SHIFT 0 /* EQ1_B2_PG - [15:0] */
5482#define ARIZONA_EQ1_B2_PG_WIDTH 16 /* EQ1_B2_PG - [15:0] */
5483
5484/*
5485 * R3609 (0xE19) - EQ1_10
5486 */
5487#define ARIZONA_EQ1_B3_A_MASK 0xFFFF /* EQ1_B3_A - [15:0] */
5488#define ARIZONA_EQ1_B3_A_SHIFT 0 /* EQ1_B3_A - [15:0] */
5489#define ARIZONA_EQ1_B3_A_WIDTH 16 /* EQ1_B3_A - [15:0] */
5490
5491/*
5492 * R3610 (0xE1A) - EQ1_11
5493 */
5494#define ARIZONA_EQ1_B3_B_MASK 0xFFFF /* EQ1_B3_B - [15:0] */
5495#define ARIZONA_EQ1_B3_B_SHIFT 0 /* EQ1_B3_B - [15:0] */
5496#define ARIZONA_EQ1_B3_B_WIDTH 16 /* EQ1_B3_B - [15:0] */
5497
5498/*
5499 * R3611 (0xE1B) - EQ1_12
5500 */
5501#define ARIZONA_EQ1_B3_C_MASK 0xFFFF /* EQ1_B3_C - [15:0] */
5502#define ARIZONA_EQ1_B3_C_SHIFT 0 /* EQ1_B3_C - [15:0] */
5503#define ARIZONA_EQ1_B3_C_WIDTH 16 /* EQ1_B3_C - [15:0] */
5504
5505/*
5506 * R3612 (0xE1C) - EQ1_13
5507 */
5508#define ARIZONA_EQ1_B3_PG_MASK 0xFFFF /* EQ1_B3_PG - [15:0] */
5509#define ARIZONA_EQ1_B3_PG_SHIFT 0 /* EQ1_B3_PG - [15:0] */
5510#define ARIZONA_EQ1_B3_PG_WIDTH 16 /* EQ1_B3_PG - [15:0] */
5511
5512/*
5513 * R3613 (0xE1D) - EQ1_14
5514 */
5515#define ARIZONA_EQ1_B4_A_MASK 0xFFFF /* EQ1_B4_A - [15:0] */
5516#define ARIZONA_EQ1_B4_A_SHIFT 0 /* EQ1_B4_A - [15:0] */
5517#define ARIZONA_EQ1_B4_A_WIDTH 16 /* EQ1_B4_A - [15:0] */
5518
5519/*
5520 * R3614 (0xE1E) - EQ1_15
5521 */
5522#define ARIZONA_EQ1_B4_B_MASK 0xFFFF /* EQ1_B4_B - [15:0] */
5523#define ARIZONA_EQ1_B4_B_SHIFT 0 /* EQ1_B4_B - [15:0] */
5524#define ARIZONA_EQ1_B4_B_WIDTH 16 /* EQ1_B4_B - [15:0] */
5525
5526/*
5527 * R3615 (0xE1F) - EQ1_16
5528 */
5529#define ARIZONA_EQ1_B4_C_MASK 0xFFFF /* EQ1_B4_C - [15:0] */
5530#define ARIZONA_EQ1_B4_C_SHIFT 0 /* EQ1_B4_C - [15:0] */
5531#define ARIZONA_EQ1_B4_C_WIDTH 16 /* EQ1_B4_C - [15:0] */
5532
5533/*
5534 * R3616 (0xE20) - EQ1_17
5535 */
5536#define ARIZONA_EQ1_B4_PG_MASK 0xFFFF /* EQ1_B4_PG - [15:0] */
5537#define ARIZONA_EQ1_B4_PG_SHIFT 0 /* EQ1_B4_PG - [15:0] */
5538#define ARIZONA_EQ1_B4_PG_WIDTH 16 /* EQ1_B4_PG - [15:0] */
5539
5540/*
5541 * R3617 (0xE21) - EQ1_18
5542 */
5543#define ARIZONA_EQ1_B5_A_MASK 0xFFFF /* EQ1_B5_A - [15:0] */
5544#define ARIZONA_EQ1_B5_A_SHIFT 0 /* EQ1_B5_A - [15:0] */
5545#define ARIZONA_EQ1_B5_A_WIDTH 16 /* EQ1_B5_A - [15:0] */
5546
5547/*
5548 * R3618 (0xE22) - EQ1_19
5549 */
5550#define ARIZONA_EQ1_B5_B_MASK 0xFFFF /* EQ1_B5_B - [15:0] */
5551#define ARIZONA_EQ1_B5_B_SHIFT 0 /* EQ1_B5_B - [15:0] */
5552#define ARIZONA_EQ1_B5_B_WIDTH 16 /* EQ1_B5_B - [15:0] */
5553
5554/*
5555 * R3619 (0xE23) - EQ1_20
5556 */
5557#define ARIZONA_EQ1_B5_PG_MASK 0xFFFF /* EQ1_B5_PG - [15:0] */
5558#define ARIZONA_EQ1_B5_PG_SHIFT 0 /* EQ1_B5_PG - [15:0] */
5559#define ARIZONA_EQ1_B5_PG_WIDTH 16 /* EQ1_B5_PG - [15:0] */
5560
5561/*
5562 * R3620 (0xE24) - EQ1_21
5563 */
5564#define ARIZONA_EQ1_B1_C_MASK 0xFFFF /* EQ1_B1_C - [15:0] */
5565#define ARIZONA_EQ1_B1_C_SHIFT 0 /* EQ1_B1_C - [15:0] */
5566#define ARIZONA_EQ1_B1_C_WIDTH 16 /* EQ1_B1_C - [15:0] */
5567
5568/*
5569 * R3622 (0xE26) - EQ2_1
5570 */
5571#define ARIZONA_EQ2_B1_GAIN_MASK 0xF800 /* EQ2_B1_GAIN - [15:11] */
5572#define ARIZONA_EQ2_B1_GAIN_SHIFT 11 /* EQ2_B1_GAIN - [15:11] */
5573#define ARIZONA_EQ2_B1_GAIN_WIDTH 5 /* EQ2_B1_GAIN - [15:11] */
5574#define ARIZONA_EQ2_B2_GAIN_MASK 0x07C0 /* EQ2_B2_GAIN - [10:6] */
5575#define ARIZONA_EQ2_B2_GAIN_SHIFT 6 /* EQ2_B2_GAIN - [10:6] */
5576#define ARIZONA_EQ2_B2_GAIN_WIDTH 5 /* EQ2_B2_GAIN - [10:6] */
5577#define ARIZONA_EQ2_B3_GAIN_MASK 0x003E /* EQ2_B3_GAIN - [5:1] */
5578#define ARIZONA_EQ2_B3_GAIN_SHIFT 1 /* EQ2_B3_GAIN - [5:1] */
5579#define ARIZONA_EQ2_B3_GAIN_WIDTH 5 /* EQ2_B3_GAIN - [5:1] */
5580#define ARIZONA_EQ2_ENA 0x0001 /* EQ2_ENA */
5581#define ARIZONA_EQ2_ENA_MASK 0x0001 /* EQ2_ENA */
5582#define ARIZONA_EQ2_ENA_SHIFT 0 /* EQ2_ENA */
5583#define ARIZONA_EQ2_ENA_WIDTH 1 /* EQ2_ENA */
5584
5585/*
5586 * R3623 (0xE27) - EQ2_2
5587 */
5588#define ARIZONA_EQ2_B4_GAIN_MASK 0xF800 /* EQ2_B4_GAIN - [15:11] */
5589#define ARIZONA_EQ2_B4_GAIN_SHIFT 11 /* EQ2_B4_GAIN - [15:11] */
5590#define ARIZONA_EQ2_B4_GAIN_WIDTH 5 /* EQ2_B4_GAIN - [15:11] */
5591#define ARIZONA_EQ2_B5_GAIN_MASK 0x07C0 /* EQ2_B5_GAIN - [10:6] */
5592#define ARIZONA_EQ2_B5_GAIN_SHIFT 6 /* EQ2_B5_GAIN - [10:6] */
5593#define ARIZONA_EQ2_B5_GAIN_WIDTH 5 /* EQ2_B5_GAIN - [10:6] */
5594#define ARIZONA_EQ2_B1_MODE 0x0001 /* EQ2_B1_MODE */
5595#define ARIZONA_EQ2_B1_MODE_MASK 0x0001 /* EQ2_B1_MODE */
5596#define ARIZONA_EQ2_B1_MODE_SHIFT 0 /* EQ2_B1_MODE */
5597#define ARIZONA_EQ2_B1_MODE_WIDTH 1 /* EQ2_B1_MODE */
5598
5599/*
5600 * R3624 (0xE28) - EQ2_3
5601 */
5602#define ARIZONA_EQ2_B1_A_MASK 0xFFFF /* EQ2_B1_A - [15:0] */
5603#define ARIZONA_EQ2_B1_A_SHIFT 0 /* EQ2_B1_A - [15:0] */
5604#define ARIZONA_EQ2_B1_A_WIDTH 16 /* EQ2_B1_A - [15:0] */
5605
5606/*
5607 * R3625 (0xE29) - EQ2_4
5608 */
5609#define ARIZONA_EQ2_B1_B_MASK 0xFFFF /* EQ2_B1_B - [15:0] */
5610#define ARIZONA_EQ2_B1_B_SHIFT 0 /* EQ2_B1_B - [15:0] */
5611#define ARIZONA_EQ2_B1_B_WIDTH 16 /* EQ2_B1_B - [15:0] */
5612
5613/*
5614 * R3626 (0xE2A) - EQ2_5
5615 */
5616#define ARIZONA_EQ2_B1_PG_MASK 0xFFFF /* EQ2_B1_PG - [15:0] */
5617#define ARIZONA_EQ2_B1_PG_SHIFT 0 /* EQ2_B1_PG - [15:0] */
5618#define ARIZONA_EQ2_B1_PG_WIDTH 16 /* EQ2_B1_PG - [15:0] */
5619
5620/*
5621 * R3627 (0xE2B) - EQ2_6
5622 */
5623#define ARIZONA_EQ2_B2_A_MASK 0xFFFF /* EQ2_B2_A - [15:0] */
5624#define ARIZONA_EQ2_B2_A_SHIFT 0 /* EQ2_B2_A - [15:0] */
5625#define ARIZONA_EQ2_B2_A_WIDTH 16 /* EQ2_B2_A - [15:0] */
5626
5627/*
5628 * R3628 (0xE2C) - EQ2_7
5629 */
5630#define ARIZONA_EQ2_B2_B_MASK 0xFFFF /* EQ2_B2_B - [15:0] */
5631#define ARIZONA_EQ2_B2_B_SHIFT 0 /* EQ2_B2_B - [15:0] */
5632#define ARIZONA_EQ2_B2_B_WIDTH 16 /* EQ2_B2_B - [15:0] */
5633
5634/*
5635 * R3629 (0xE2D) - EQ2_8
5636 */
5637#define ARIZONA_EQ2_B2_C_MASK 0xFFFF /* EQ2_B2_C - [15:0] */
5638#define ARIZONA_EQ2_B2_C_SHIFT 0 /* EQ2_B2_C - [15:0] */
5639#define ARIZONA_EQ2_B2_C_WIDTH 16 /* EQ2_B2_C - [15:0] */
5640
5641/*
5642 * R3630 (0xE2E) - EQ2_9
5643 */
5644#define ARIZONA_EQ2_B2_PG_MASK 0xFFFF /* EQ2_B2_PG - [15:0] */
5645#define ARIZONA_EQ2_B2_PG_SHIFT 0 /* EQ2_B2_PG - [15:0] */
5646#define ARIZONA_EQ2_B2_PG_WIDTH 16 /* EQ2_B2_PG - [15:0] */
5647
5648/*
5649 * R3631 (0xE2F) - EQ2_10
5650 */
5651#define ARIZONA_EQ2_B3_A_MASK 0xFFFF /* EQ2_B3_A - [15:0] */
5652#define ARIZONA_EQ2_B3_A_SHIFT 0 /* EQ2_B3_A - [15:0] */
5653#define ARIZONA_EQ2_B3_A_WIDTH 16 /* EQ2_B3_A - [15:0] */
5654
5655/*
5656 * R3632 (0xE30) - EQ2_11
5657 */
5658#define ARIZONA_EQ2_B3_B_MASK 0xFFFF /* EQ2_B3_B - [15:0] */
5659#define ARIZONA_EQ2_B3_B_SHIFT 0 /* EQ2_B3_B - [15:0] */
5660#define ARIZONA_EQ2_B3_B_WIDTH 16 /* EQ2_B3_B - [15:0] */
5661
5662/*
5663 * R3633 (0xE31) - EQ2_12
5664 */
5665#define ARIZONA_EQ2_B3_C_MASK 0xFFFF /* EQ2_B3_C - [15:0] */
5666#define ARIZONA_EQ2_B3_C_SHIFT 0 /* EQ2_B3_C - [15:0] */
5667#define ARIZONA_EQ2_B3_C_WIDTH 16 /* EQ2_B3_C - [15:0] */
5668
5669/*
5670 * R3634 (0xE32) - EQ2_13
5671 */
5672#define ARIZONA_EQ2_B3_PG_MASK 0xFFFF /* EQ2_B3_PG - [15:0] */
5673#define ARIZONA_EQ2_B3_PG_SHIFT 0 /* EQ2_B3_PG - [15:0] */
5674#define ARIZONA_EQ2_B3_PG_WIDTH 16 /* EQ2_B3_PG - [15:0] */
5675
5676/*
5677 * R3635 (0xE33) - EQ2_14
5678 */
5679#define ARIZONA_EQ2_B4_A_MASK 0xFFFF /* EQ2_B4_A - [15:0] */
5680#define ARIZONA_EQ2_B4_A_SHIFT 0 /* EQ2_B4_A - [15:0] */
5681#define ARIZONA_EQ2_B4_A_WIDTH 16 /* EQ2_B4_A - [15:0] */
5682
5683/*
5684 * R3636 (0xE34) - EQ2_15
5685 */
5686#define ARIZONA_EQ2_B4_B_MASK 0xFFFF /* EQ2_B4_B - [15:0] */
5687#define ARIZONA_EQ2_B4_B_SHIFT 0 /* EQ2_B4_B - [15:0] */
5688#define ARIZONA_EQ2_B4_B_WIDTH 16 /* EQ2_B4_B - [15:0] */
5689
5690/*
5691 * R3637 (0xE35) - EQ2_16
5692 */
5693#define ARIZONA_EQ2_B4_C_MASK 0xFFFF /* EQ2_B4_C - [15:0] */
5694#define ARIZONA_EQ2_B4_C_SHIFT 0 /* EQ2_B4_C - [15:0] */
5695#define ARIZONA_EQ2_B4_C_WIDTH 16 /* EQ2_B4_C - [15:0] */
5696
5697/*
5698 * R3638 (0xE36) - EQ2_17
5699 */
5700#define ARIZONA_EQ2_B4_PG_MASK 0xFFFF /* EQ2_B4_PG - [15:0] */
5701#define ARIZONA_EQ2_B4_PG_SHIFT 0 /* EQ2_B4_PG - [15:0] */
5702#define ARIZONA_EQ2_B4_PG_WIDTH 16 /* EQ2_B4_PG - [15:0] */
5703
5704/*
5705 * R3639 (0xE37) - EQ2_18
5706 */
5707#define ARIZONA_EQ2_B5_A_MASK 0xFFFF /* EQ2_B5_A - [15:0] */
5708#define ARIZONA_EQ2_B5_A_SHIFT 0 /* EQ2_B5_A - [15:0] */
5709#define ARIZONA_EQ2_B5_A_WIDTH 16 /* EQ2_B5_A - [15:0] */
5710
5711/*
5712 * R3640 (0xE38) - EQ2_19
5713 */
5714#define ARIZONA_EQ2_B5_B_MASK 0xFFFF /* EQ2_B5_B - [15:0] */
5715#define ARIZONA_EQ2_B5_B_SHIFT 0 /* EQ2_B5_B - [15:0] */
5716#define ARIZONA_EQ2_B5_B_WIDTH 16 /* EQ2_B5_B - [15:0] */
5717
5718/*
5719 * R3641 (0xE39) - EQ2_20
5720 */
5721#define ARIZONA_EQ2_B5_PG_MASK 0xFFFF /* EQ2_B5_PG - [15:0] */
5722#define ARIZONA_EQ2_B5_PG_SHIFT 0 /* EQ2_B5_PG - [15:0] */
5723#define ARIZONA_EQ2_B5_PG_WIDTH 16 /* EQ2_B5_PG - [15:0] */
5724
5725/*
5726 * R3642 (0xE3A) - EQ2_21
5727 */
5728#define ARIZONA_EQ2_B1_C_MASK 0xFFFF /* EQ2_B1_C - [15:0] */
5729#define ARIZONA_EQ2_B1_C_SHIFT 0 /* EQ2_B1_C - [15:0] */
5730#define ARIZONA_EQ2_B1_C_WIDTH 16 /* EQ2_B1_C - [15:0] */
5731
5732/*
5733 * R3644 (0xE3C) - EQ3_1
5734 */
5735#define ARIZONA_EQ3_B1_GAIN_MASK 0xF800 /* EQ3_B1_GAIN - [15:11] */
5736#define ARIZONA_EQ3_B1_GAIN_SHIFT 11 /* EQ3_B1_GAIN - [15:11] */
5737#define ARIZONA_EQ3_B1_GAIN_WIDTH 5 /* EQ3_B1_GAIN - [15:11] */
5738#define ARIZONA_EQ3_B2_GAIN_MASK 0x07C0 /* EQ3_B2_GAIN - [10:6] */
5739#define ARIZONA_EQ3_B2_GAIN_SHIFT 6 /* EQ3_B2_GAIN - [10:6] */
5740#define ARIZONA_EQ3_B2_GAIN_WIDTH 5 /* EQ3_B2_GAIN - [10:6] */
5741#define ARIZONA_EQ3_B3_GAIN_MASK 0x003E /* EQ3_B3_GAIN - [5:1] */
5742#define ARIZONA_EQ3_B3_GAIN_SHIFT 1 /* EQ3_B3_GAIN - [5:1] */
5743#define ARIZONA_EQ3_B3_GAIN_WIDTH 5 /* EQ3_B3_GAIN - [5:1] */
5744#define ARIZONA_EQ3_ENA 0x0001 /* EQ3_ENA */
5745#define ARIZONA_EQ3_ENA_MASK 0x0001 /* EQ3_ENA */
5746#define ARIZONA_EQ3_ENA_SHIFT 0 /* EQ3_ENA */
5747#define ARIZONA_EQ3_ENA_WIDTH 1 /* EQ3_ENA */
5748
5749/*
5750 * R3645 (0xE3D) - EQ3_2
5751 */
5752#define ARIZONA_EQ3_B4_GAIN_MASK 0xF800 /* EQ3_B4_GAIN - [15:11] */
5753#define ARIZONA_EQ3_B4_GAIN_SHIFT 11 /* EQ3_B4_GAIN - [15:11] */
5754#define ARIZONA_EQ3_B4_GAIN_WIDTH 5 /* EQ3_B4_GAIN - [15:11] */
5755#define ARIZONA_EQ3_B5_GAIN_MASK 0x07C0 /* EQ3_B5_GAIN - [10:6] */
5756#define ARIZONA_EQ3_B5_GAIN_SHIFT 6 /* EQ3_B5_GAIN - [10:6] */
5757#define ARIZONA_EQ3_B5_GAIN_WIDTH 5 /* EQ3_B5_GAIN - [10:6] */
5758#define ARIZONA_EQ3_B1_MODE 0x0001 /* EQ3_B1_MODE */
5759#define ARIZONA_EQ3_B1_MODE_MASK 0x0001 /* EQ3_B1_MODE */
5760#define ARIZONA_EQ3_B1_MODE_SHIFT 0 /* EQ3_B1_MODE */
5761#define ARIZONA_EQ3_B1_MODE_WIDTH 1 /* EQ3_B1_MODE */
5762
5763/*
5764 * R3646 (0xE3E) - EQ3_3
5765 */
5766#define ARIZONA_EQ3_B1_A_MASK 0xFFFF /* EQ3_B1_A - [15:0] */
5767#define ARIZONA_EQ3_B1_A_SHIFT 0 /* EQ3_B1_A - [15:0] */
5768#define ARIZONA_EQ3_B1_A_WIDTH 16 /* EQ3_B1_A - [15:0] */
5769
5770/*
5771 * R3647 (0xE3F) - EQ3_4
5772 */
5773#define ARIZONA_EQ3_B1_B_MASK 0xFFFF /* EQ3_B1_B - [15:0] */
5774#define ARIZONA_EQ3_B1_B_SHIFT 0 /* EQ3_B1_B - [15:0] */
5775#define ARIZONA_EQ3_B1_B_WIDTH 16 /* EQ3_B1_B - [15:0] */
5776
5777/*
5778 * R3648 (0xE40) - EQ3_5
5779 */
5780#define ARIZONA_EQ3_B1_PG_MASK 0xFFFF /* EQ3_B1_PG - [15:0] */
5781#define ARIZONA_EQ3_B1_PG_SHIFT 0 /* EQ3_B1_PG - [15:0] */
5782#define ARIZONA_EQ3_B1_PG_WIDTH 16 /* EQ3_B1_PG - [15:0] */
5783
5784/*
5785 * R3649 (0xE41) - EQ3_6
5786 */
5787#define ARIZONA_EQ3_B2_A_MASK 0xFFFF /* EQ3_B2_A - [15:0] */
5788#define ARIZONA_EQ3_B2_A_SHIFT 0 /* EQ3_B2_A - [15:0] */
5789#define ARIZONA_EQ3_B2_A_WIDTH 16 /* EQ3_B2_A - [15:0] */
5790
5791/*
5792 * R3650 (0xE42) - EQ3_7
5793 */
5794#define ARIZONA_EQ3_B2_B_MASK 0xFFFF /* EQ3_B2_B - [15:0] */
5795#define ARIZONA_EQ3_B2_B_SHIFT 0 /* EQ3_B2_B - [15:0] */
5796#define ARIZONA_EQ3_B2_B_WIDTH 16 /* EQ3_B2_B - [15:0] */
5797
5798/*
5799 * R3651 (0xE43) - EQ3_8
5800 */
5801#define ARIZONA_EQ3_B2_C_MASK 0xFFFF /* EQ3_B2_C - [15:0] */
5802#define ARIZONA_EQ3_B2_C_SHIFT 0 /* EQ3_B2_C - [15:0] */
5803#define ARIZONA_EQ3_B2_C_WIDTH 16 /* EQ3_B2_C - [15:0] */
5804
5805/*
5806 * R3652 (0xE44) - EQ3_9
5807 */
5808#define ARIZONA_EQ3_B2_PG_MASK 0xFFFF /* EQ3_B2_PG - [15:0] */
5809#define ARIZONA_EQ3_B2_PG_SHIFT 0 /* EQ3_B2_PG - [15:0] */
5810#define ARIZONA_EQ3_B2_PG_WIDTH 16 /* EQ3_B2_PG - [15:0] */
5811
5812/*
5813 * R3653 (0xE45) - EQ3_10
5814 */
5815#define ARIZONA_EQ3_B3_A_MASK 0xFFFF /* EQ3_B3_A - [15:0] */
5816#define ARIZONA_EQ3_B3_A_SHIFT 0 /* EQ3_B3_A - [15:0] */
5817#define ARIZONA_EQ3_B3_A_WIDTH 16 /* EQ3_B3_A - [15:0] */
5818
5819/*
5820 * R3654 (0xE46) - EQ3_11
5821 */
5822#define ARIZONA_EQ3_B3_B_MASK 0xFFFF /* EQ3_B3_B - [15:0] */
5823#define ARIZONA_EQ3_B3_B_SHIFT 0 /* EQ3_B3_B - [15:0] */
5824#define ARIZONA_EQ3_B3_B_WIDTH 16 /* EQ3_B3_B - [15:0] */
5825
5826/*
5827 * R3655 (0xE47) - EQ3_12
5828 */
5829#define ARIZONA_EQ3_B3_C_MASK 0xFFFF /* EQ3_B3_C - [15:0] */
5830#define ARIZONA_EQ3_B3_C_SHIFT 0 /* EQ3_B3_C - [15:0] */
5831#define ARIZONA_EQ3_B3_C_WIDTH 16 /* EQ3_B3_C - [15:0] */
5832
5833/*
5834 * R3656 (0xE48) - EQ3_13
5835 */
5836#define ARIZONA_EQ3_B3_PG_MASK 0xFFFF /* EQ3_B3_PG - [15:0] */
5837#define ARIZONA_EQ3_B3_PG_SHIFT 0 /* EQ3_B3_PG - [15:0] */
5838#define ARIZONA_EQ3_B3_PG_WIDTH 16 /* EQ3_B3_PG - [15:0] */
5839
5840/*
5841 * R3657 (0xE49) - EQ3_14
5842 */
5843#define ARIZONA_EQ3_B4_A_MASK 0xFFFF /* EQ3_B4_A - [15:0] */
5844#define ARIZONA_EQ3_B4_A_SHIFT 0 /* EQ3_B4_A - [15:0] */
5845#define ARIZONA_EQ3_B4_A_WIDTH 16 /* EQ3_B4_A - [15:0] */
5846
5847/*
5848 * R3658 (0xE4A) - EQ3_15
5849 */
5850#define ARIZONA_EQ3_B4_B_MASK 0xFFFF /* EQ3_B4_B - [15:0] */
5851#define ARIZONA_EQ3_B4_B_SHIFT 0 /* EQ3_B4_B - [15:0] */
5852#define ARIZONA_EQ3_B4_B_WIDTH 16 /* EQ3_B4_B - [15:0] */
5853
5854/*
5855 * R3659 (0xE4B) - EQ3_16
5856 */
5857#define ARIZONA_EQ3_B4_C_MASK 0xFFFF /* EQ3_B4_C - [15:0] */
5858#define ARIZONA_EQ3_B4_C_SHIFT 0 /* EQ3_B4_C - [15:0] */
5859#define ARIZONA_EQ3_B4_C_WIDTH 16 /* EQ3_B4_C - [15:0] */
5860
5861/*
5862 * R3660 (0xE4C) - EQ3_17
5863 */
5864#define ARIZONA_EQ3_B4_PG_MASK 0xFFFF /* EQ3_B4_PG - [15:0] */
5865#define ARIZONA_EQ3_B4_PG_SHIFT 0 /* EQ3_B4_PG - [15:0] */
5866#define ARIZONA_EQ3_B4_PG_WIDTH 16 /* EQ3_B4_PG - [15:0] */
5867
5868/*
5869 * R3661 (0xE4D) - EQ3_18
5870 */
5871#define ARIZONA_EQ3_B5_A_MASK 0xFFFF /* EQ3_B5_A - [15:0] */
5872#define ARIZONA_EQ3_B5_A_SHIFT 0 /* EQ3_B5_A - [15:0] */
5873#define ARIZONA_EQ3_B5_A_WIDTH 16 /* EQ3_B5_A - [15:0] */
5874
5875/*
5876 * R3662 (0xE4E) - EQ3_19
5877 */
5878#define ARIZONA_EQ3_B5_B_MASK 0xFFFF /* EQ3_B5_B - [15:0] */
5879#define ARIZONA_EQ3_B5_B_SHIFT 0 /* EQ3_B5_B - [15:0] */
5880#define ARIZONA_EQ3_B5_B_WIDTH 16 /* EQ3_B5_B - [15:0] */
5881
5882/*
5883 * R3663 (0xE4F) - EQ3_20
5884 */
5885#define ARIZONA_EQ3_B5_PG_MASK 0xFFFF /* EQ3_B5_PG - [15:0] */
5886#define ARIZONA_EQ3_B5_PG_SHIFT 0 /* EQ3_B5_PG - [15:0] */
5887#define ARIZONA_EQ3_B5_PG_WIDTH 16 /* EQ3_B5_PG - [15:0] */
5888
5889/*
5890 * R3664 (0xE50) - EQ3_21
5891 */
5892#define ARIZONA_EQ3_B1_C_MASK 0xFFFF /* EQ3_B1_C - [15:0] */
5893#define ARIZONA_EQ3_B1_C_SHIFT 0 /* EQ3_B1_C - [15:0] */
5894#define ARIZONA_EQ3_B1_C_WIDTH 16 /* EQ3_B1_C - [15:0] */
5895
5896/*
5897 * R3666 (0xE52) - EQ4_1
5898 */
5899#define ARIZONA_EQ4_B1_GAIN_MASK 0xF800 /* EQ4_B1_GAIN - [15:11] */
5900#define ARIZONA_EQ4_B1_GAIN_SHIFT 11 /* EQ4_B1_GAIN - [15:11] */
5901#define ARIZONA_EQ4_B1_GAIN_WIDTH 5 /* EQ4_B1_GAIN - [15:11] */
5902#define ARIZONA_EQ4_B2_GAIN_MASK 0x07C0 /* EQ4_B2_GAIN - [10:6] */
5903#define ARIZONA_EQ4_B2_GAIN_SHIFT 6 /* EQ4_B2_GAIN - [10:6] */
5904#define ARIZONA_EQ4_B2_GAIN_WIDTH 5 /* EQ4_B2_GAIN - [10:6] */
5905#define ARIZONA_EQ4_B3_GAIN_MASK 0x003E /* EQ4_B3_GAIN - [5:1] */
5906#define ARIZONA_EQ4_B3_GAIN_SHIFT 1 /* EQ4_B3_GAIN - [5:1] */
5907#define ARIZONA_EQ4_B3_GAIN_WIDTH 5 /* EQ4_B3_GAIN - [5:1] */
5908#define ARIZONA_EQ4_ENA 0x0001 /* EQ4_ENA */
5909#define ARIZONA_EQ4_ENA_MASK 0x0001 /* EQ4_ENA */
5910#define ARIZONA_EQ4_ENA_SHIFT 0 /* EQ4_ENA */
5911#define ARIZONA_EQ4_ENA_WIDTH 1 /* EQ4_ENA */
5912
5913/*
5914 * R3667 (0xE53) - EQ4_2
5915 */
5916#define ARIZONA_EQ4_B4_GAIN_MASK 0xF800 /* EQ4_B4_GAIN - [15:11] */
5917#define ARIZONA_EQ4_B4_GAIN_SHIFT 11 /* EQ4_B4_GAIN - [15:11] */
5918#define ARIZONA_EQ4_B4_GAIN_WIDTH 5 /* EQ4_B4_GAIN - [15:11] */
5919#define ARIZONA_EQ4_B5_GAIN_MASK 0x07C0 /* EQ4_B5_GAIN - [10:6] */
5920#define ARIZONA_EQ4_B5_GAIN_SHIFT 6 /* EQ4_B5_GAIN - [10:6] */
5921#define ARIZONA_EQ4_B5_GAIN_WIDTH 5 /* EQ4_B5_GAIN - [10:6] */
5922#define ARIZONA_EQ4_B1_MODE 0x0001 /* EQ4_B1_MODE */
5923#define ARIZONA_EQ4_B1_MODE_MASK 0x0001 /* EQ4_B1_MODE */
5924#define ARIZONA_EQ4_B1_MODE_SHIFT 0 /* EQ4_B1_MODE */
5925#define ARIZONA_EQ4_B1_MODE_WIDTH 1 /* EQ4_B1_MODE */
5926
5927/*
5928 * R3668 (0xE54) - EQ4_3
5929 */
5930#define ARIZONA_EQ4_B1_A_MASK 0xFFFF /* EQ4_B1_A - [15:0] */
5931#define ARIZONA_EQ4_B1_A_SHIFT 0 /* EQ4_B1_A - [15:0] */
5932#define ARIZONA_EQ4_B1_A_WIDTH 16 /* EQ4_B1_A - [15:0] */
5933
5934/*
5935 * R3669 (0xE55) - EQ4_4
5936 */
5937#define ARIZONA_EQ4_B1_B_MASK 0xFFFF /* EQ4_B1_B - [15:0] */
5938#define ARIZONA_EQ4_B1_B_SHIFT 0 /* EQ4_B1_B - [15:0] */
5939#define ARIZONA_EQ4_B1_B_WIDTH 16 /* EQ4_B1_B - [15:0] */
5940
5941/*
5942 * R3670 (0xE56) - EQ4_5
5943 */
5944#define ARIZONA_EQ4_B1_PG_MASK 0xFFFF /* EQ4_B1_PG - [15:0] */
5945#define ARIZONA_EQ4_B1_PG_SHIFT 0 /* EQ4_B1_PG - [15:0] */
5946#define ARIZONA_EQ4_B1_PG_WIDTH 16 /* EQ4_B1_PG - [15:0] */
5947
5948/*
5949 * R3671 (0xE57) - EQ4_6
5950 */
5951#define ARIZONA_EQ4_B2_A_MASK 0xFFFF /* EQ4_B2_A - [15:0] */
5952#define ARIZONA_EQ4_B2_A_SHIFT 0 /* EQ4_B2_A - [15:0] */
5953#define ARIZONA_EQ4_B2_A_WIDTH 16 /* EQ4_B2_A - [15:0] */
5954
5955/*
5956 * R3672 (0xE58) - EQ4_7
5957 */
5958#define ARIZONA_EQ4_B2_B_MASK 0xFFFF /* EQ4_B2_B - [15:0] */
5959#define ARIZONA_EQ4_B2_B_SHIFT 0 /* EQ4_B2_B - [15:0] */
5960#define ARIZONA_EQ4_B2_B_WIDTH 16 /* EQ4_B2_B - [15:0] */
5961
5962/*
5963 * R3673 (0xE59) - EQ4_8
5964 */
5965#define ARIZONA_EQ4_B2_C_MASK 0xFFFF /* EQ4_B2_C - [15:0] */
5966#define ARIZONA_EQ4_B2_C_SHIFT 0 /* EQ4_B2_C - [15:0] */
5967#define ARIZONA_EQ4_B2_C_WIDTH 16 /* EQ4_B2_C - [15:0] */
5968
5969/*
5970 * R3674 (0xE5A) - EQ4_9
5971 */
5972#define ARIZONA_EQ4_B2_PG_MASK 0xFFFF /* EQ4_B2_PG - [15:0] */
5973#define ARIZONA_EQ4_B2_PG_SHIFT 0 /* EQ4_B2_PG - [15:0] */
5974#define ARIZONA_EQ4_B2_PG_WIDTH 16 /* EQ4_B2_PG - [15:0] */
5975
5976/*
5977 * R3675 (0xE5B) - EQ4_10
5978 */
5979#define ARIZONA_EQ4_B3_A_MASK 0xFFFF /* EQ4_B3_A - [15:0] */
5980#define ARIZONA_EQ4_B3_A_SHIFT 0 /* EQ4_B3_A - [15:0] */
5981#define ARIZONA_EQ4_B3_A_WIDTH 16 /* EQ4_B3_A - [15:0] */
5982
5983/*
5984 * R3676 (0xE5C) - EQ4_11
5985 */
5986#define ARIZONA_EQ4_B3_B_MASK 0xFFFF /* EQ4_B3_B - [15:0] */
5987#define ARIZONA_EQ4_B3_B_SHIFT 0 /* EQ4_B3_B - [15:0] */
5988#define ARIZONA_EQ4_B3_B_WIDTH 16 /* EQ4_B3_B - [15:0] */
5989
5990/*
5991 * R3677 (0xE5D) - EQ4_12
5992 */
5993#define ARIZONA_EQ4_B3_C_MASK 0xFFFF /* EQ4_B3_C - [15:0] */
5994#define ARIZONA_EQ4_B3_C_SHIFT 0 /* EQ4_B3_C - [15:0] */
5995#define ARIZONA_EQ4_B3_C_WIDTH 16 /* EQ4_B3_C - [15:0] */
5996
5997/*
5998 * R3678 (0xE5E) - EQ4_13
5999 */
6000#define ARIZONA_EQ4_B3_PG_MASK 0xFFFF /* EQ4_B3_PG - [15:0] */
6001#define ARIZONA_EQ4_B3_PG_SHIFT 0 /* EQ4_B3_PG - [15:0] */
6002#define ARIZONA_EQ4_B3_PG_WIDTH 16 /* EQ4_B3_PG - [15:0] */
6003
6004/*
6005 * R3679 (0xE5F) - EQ4_14
6006 */
6007#define ARIZONA_EQ4_B4_A_MASK 0xFFFF /* EQ4_B4_A - [15:0] */
6008#define ARIZONA_EQ4_B4_A_SHIFT 0 /* EQ4_B4_A - [15:0] */
6009#define ARIZONA_EQ4_B4_A_WIDTH 16 /* EQ4_B4_A - [15:0] */
6010
6011/*
6012 * R3680 (0xE60) - EQ4_15
6013 */
6014#define ARIZONA_EQ4_B4_B_MASK 0xFFFF /* EQ4_B4_B - [15:0] */
6015#define ARIZONA_EQ4_B4_B_SHIFT 0 /* EQ4_B4_B - [15:0] */
6016#define ARIZONA_EQ4_B4_B_WIDTH 16 /* EQ4_B4_B - [15:0] */
6017
6018/*
6019 * R3681 (0xE61) - EQ4_16
6020 */
6021#define ARIZONA_EQ4_B4_C_MASK 0xFFFF /* EQ4_B4_C - [15:0] */
6022#define ARIZONA_EQ4_B4_C_SHIFT 0 /* EQ4_B4_C - [15:0] */
6023#define ARIZONA_EQ4_B4_C_WIDTH 16 /* EQ4_B4_C - [15:0] */
6024
6025/*
6026 * R3682 (0xE62) - EQ4_17
6027 */
6028#define ARIZONA_EQ4_B4_PG_MASK 0xFFFF /* EQ4_B4_PG - [15:0] */
6029#define ARIZONA_EQ4_B4_PG_SHIFT 0 /* EQ4_B4_PG - [15:0] */
6030#define ARIZONA_EQ4_B4_PG_WIDTH 16 /* EQ4_B4_PG - [15:0] */
6031
6032/*
6033 * R3683 (0xE63) - EQ4_18
6034 */
6035#define ARIZONA_EQ4_B5_A_MASK 0xFFFF /* EQ4_B5_A - [15:0] */
6036#define ARIZONA_EQ4_B5_A_SHIFT 0 /* EQ4_B5_A - [15:0] */
6037#define ARIZONA_EQ4_B5_A_WIDTH 16 /* EQ4_B5_A - [15:0] */
6038
6039/*
6040 * R3684 (0xE64) - EQ4_19
6041 */
6042#define ARIZONA_EQ4_B5_B_MASK 0xFFFF /* EQ4_B5_B - [15:0] */
6043#define ARIZONA_EQ4_B5_B_SHIFT 0 /* EQ4_B5_B - [15:0] */
6044#define ARIZONA_EQ4_B5_B_WIDTH 16 /* EQ4_B5_B - [15:0] */
6045
6046/*
6047 * R3685 (0xE65) - EQ4_20
6048 */
6049#define ARIZONA_EQ4_B5_PG_MASK 0xFFFF /* EQ4_B5_PG - [15:0] */
6050#define ARIZONA_EQ4_B5_PG_SHIFT 0 /* EQ4_B5_PG - [15:0] */
6051#define ARIZONA_EQ4_B5_PG_WIDTH 16 /* EQ4_B5_PG - [15:0] */
6052
6053/*
6054 * R3686 (0xE66) - EQ4_21
6055 */
6056#define ARIZONA_EQ4_B1_C_MASK 0xFFFF /* EQ4_B1_C - [15:0] */
6057#define ARIZONA_EQ4_B1_C_SHIFT 0 /* EQ4_B1_C - [15:0] */
6058#define ARIZONA_EQ4_B1_C_WIDTH 16 /* EQ4_B1_C - [15:0] */
6059
6060/*
6061 * R3712 (0xE80) - DRC1 ctrl1
6062 */
6063#define ARIZONA_DRC1_SIG_DET_RMS_MASK 0xF800 /* DRC1_SIG_DET_RMS - [15:11] */
6064#define ARIZONA_DRC1_SIG_DET_RMS_SHIFT 11 /* DRC1_SIG_DET_RMS - [15:11] */
6065#define ARIZONA_DRC1_SIG_DET_RMS_WIDTH 5 /* DRC1_SIG_DET_RMS - [15:11] */
6066#define ARIZONA_DRC1_SIG_DET_PK_MASK 0x0600 /* DRC1_SIG_DET_PK - [10:9] */
6067#define ARIZONA_DRC1_SIG_DET_PK_SHIFT 9 /* DRC1_SIG_DET_PK - [10:9] */
6068#define ARIZONA_DRC1_SIG_DET_PK_WIDTH 2 /* DRC1_SIG_DET_PK - [10:9] */
6069#define ARIZONA_DRC1_NG_ENA 0x0100 /* DRC1_NG_ENA */
6070#define ARIZONA_DRC1_NG_ENA_MASK 0x0100 /* DRC1_NG_ENA */
6071#define ARIZONA_DRC1_NG_ENA_SHIFT 8 /* DRC1_NG_ENA */
6072#define ARIZONA_DRC1_NG_ENA_WIDTH 1 /* DRC1_NG_ENA */
6073#define ARIZONA_DRC1_SIG_DET_MODE 0x0080 /* DRC1_SIG_DET_MODE */
6074#define ARIZONA_DRC1_SIG_DET_MODE_MASK 0x0080 /* DRC1_SIG_DET_MODE */
6075#define ARIZONA_DRC1_SIG_DET_MODE_SHIFT 7 /* DRC1_SIG_DET_MODE */
6076#define ARIZONA_DRC1_SIG_DET_MODE_WIDTH 1 /* DRC1_SIG_DET_MODE */
6077#define ARIZONA_DRC1_SIG_DET 0x0040 /* DRC1_SIG_DET */
6078#define ARIZONA_DRC1_SIG_DET_MASK 0x0040 /* DRC1_SIG_DET */
6079#define ARIZONA_DRC1_SIG_DET_SHIFT 6 /* DRC1_SIG_DET */
6080#define ARIZONA_DRC1_SIG_DET_WIDTH 1 /* DRC1_SIG_DET */
6081#define ARIZONA_DRC1_KNEE2_OP_ENA 0x0020 /* DRC1_KNEE2_OP_ENA */
6082#define ARIZONA_DRC1_KNEE2_OP_ENA_MASK 0x0020 /* DRC1_KNEE2_OP_ENA */
6083#define ARIZONA_DRC1_KNEE2_OP_ENA_SHIFT 5 /* DRC1_KNEE2_OP_ENA */
6084#define ARIZONA_DRC1_KNEE2_OP_ENA_WIDTH 1 /* DRC1_KNEE2_OP_ENA */
6085#define ARIZONA_DRC1_QR 0x0010 /* DRC1_QR */
6086#define ARIZONA_DRC1_QR_MASK 0x0010 /* DRC1_QR */
6087#define ARIZONA_DRC1_QR_SHIFT 4 /* DRC1_QR */
6088#define ARIZONA_DRC1_QR_WIDTH 1 /* DRC1_QR */
6089#define ARIZONA_DRC1_ANTICLIP 0x0008 /* DRC1_ANTICLIP */
6090#define ARIZONA_DRC1_ANTICLIP_MASK 0x0008 /* DRC1_ANTICLIP */
6091#define ARIZONA_DRC1_ANTICLIP_SHIFT 3 /* DRC1_ANTICLIP */
6092#define ARIZONA_DRC1_ANTICLIP_WIDTH 1 /* DRC1_ANTICLIP */
6093#define ARIZONA_DRC1L_ENA 0x0002 /* DRC1L_ENA */
6094#define ARIZONA_DRC1L_ENA_MASK 0x0002 /* DRC1L_ENA */
6095#define ARIZONA_DRC1L_ENA_SHIFT 1 /* DRC1L_ENA */
6096#define ARIZONA_DRC1L_ENA_WIDTH 1 /* DRC1L_ENA */
6097#define ARIZONA_DRC1R_ENA 0x0001 /* DRC1R_ENA */
6098#define ARIZONA_DRC1R_ENA_MASK 0x0001 /* DRC1R_ENA */
6099#define ARIZONA_DRC1R_ENA_SHIFT 0 /* DRC1R_ENA */
6100#define ARIZONA_DRC1R_ENA_WIDTH 1 /* DRC1R_ENA */
6101
6102/*
6103 * R3713 (0xE81) - DRC1 ctrl2
6104 */
6105#define ARIZONA_DRC1_ATK_MASK 0x1E00 /* DRC1_ATK - [12:9] */
6106#define ARIZONA_DRC1_ATK_SHIFT 9 /* DRC1_ATK - [12:9] */
6107#define ARIZONA_DRC1_ATK_WIDTH 4 /* DRC1_ATK - [12:9] */
6108#define ARIZONA_DRC1_DCY_MASK 0x01E0 /* DRC1_DCY - [8:5] */
6109#define ARIZONA_DRC1_DCY_SHIFT 5 /* DRC1_DCY - [8:5] */
6110#define ARIZONA_DRC1_DCY_WIDTH 4 /* DRC1_DCY - [8:5] */
6111#define ARIZONA_DRC1_MINGAIN_MASK 0x001C /* DRC1_MINGAIN - [4:2] */
6112#define ARIZONA_DRC1_MINGAIN_SHIFT 2 /* DRC1_MINGAIN - [4:2] */
6113#define ARIZONA_DRC1_MINGAIN_WIDTH 3 /* DRC1_MINGAIN - [4:2] */
6114#define ARIZONA_DRC1_MAXGAIN_MASK 0x0003 /* DRC1_MAXGAIN - [1:0] */
6115#define ARIZONA_DRC1_MAXGAIN_SHIFT 0 /* DRC1_MAXGAIN - [1:0] */
6116#define ARIZONA_DRC1_MAXGAIN_WIDTH 2 /* DRC1_MAXGAIN - [1:0] */
6117
6118/*
6119 * R3714 (0xE82) - DRC1 ctrl3
6120 */
6121#define ARIZONA_DRC1_NG_MINGAIN_MASK 0xF000 /* DRC1_NG_MINGAIN - [15:12] */
6122#define ARIZONA_DRC1_NG_MINGAIN_SHIFT 12 /* DRC1_NG_MINGAIN - [15:12] */
6123#define ARIZONA_DRC1_NG_MINGAIN_WIDTH 4 /* DRC1_NG_MINGAIN - [15:12] */
6124#define ARIZONA_DRC1_NG_EXP_MASK 0x0C00 /* DRC1_NG_EXP - [11:10] */
6125#define ARIZONA_DRC1_NG_EXP_SHIFT 10 /* DRC1_NG_EXP - [11:10] */
6126#define ARIZONA_DRC1_NG_EXP_WIDTH 2 /* DRC1_NG_EXP - [11:10] */
6127#define ARIZONA_DRC1_QR_THR_MASK 0x0300 /* DRC1_QR_THR - [9:8] */
6128#define ARIZONA_DRC1_QR_THR_SHIFT 8 /* DRC1_QR_THR - [9:8] */
6129#define ARIZONA_DRC1_QR_THR_WIDTH 2 /* DRC1_QR_THR - [9:8] */
6130#define ARIZONA_DRC1_QR_DCY_MASK 0x00C0 /* DRC1_QR_DCY - [7:6] */
6131#define ARIZONA_DRC1_QR_DCY_SHIFT 6 /* DRC1_QR_DCY - [7:6] */
6132#define ARIZONA_DRC1_QR_DCY_WIDTH 2 /* DRC1_QR_DCY - [7:6] */
6133#define ARIZONA_DRC1_HI_COMP_MASK 0x0038 /* DRC1_HI_COMP - [5:3] */
6134#define ARIZONA_DRC1_HI_COMP_SHIFT 3 /* DRC1_HI_COMP - [5:3] */
6135#define ARIZONA_DRC1_HI_COMP_WIDTH 3 /* DRC1_HI_COMP - [5:3] */
6136#define ARIZONA_DRC1_LO_COMP_MASK 0x0007 /* DRC1_LO_COMP - [2:0] */
6137#define ARIZONA_DRC1_LO_COMP_SHIFT 0 /* DRC1_LO_COMP - [2:0] */
6138#define ARIZONA_DRC1_LO_COMP_WIDTH 3 /* DRC1_LO_COMP - [2:0] */
6139
6140/*
6141 * R3715 (0xE83) - DRC1 ctrl4
6142 */
6143#define ARIZONA_DRC1_KNEE_IP_MASK 0x07E0 /* DRC1_KNEE_IP - [10:5] */
6144#define ARIZONA_DRC1_KNEE_IP_SHIFT 5 /* DRC1_KNEE_IP - [10:5] */
6145#define ARIZONA_DRC1_KNEE_IP_WIDTH 6 /* DRC1_KNEE_IP - [10:5] */
6146#define ARIZONA_DRC1_KNEE_OP_MASK 0x001F /* DRC1_KNEE_OP - [4:0] */
6147#define ARIZONA_DRC1_KNEE_OP_SHIFT 0 /* DRC1_KNEE_OP - [4:0] */
6148#define ARIZONA_DRC1_KNEE_OP_WIDTH 5 /* DRC1_KNEE_OP - [4:0] */
6149
6150/*
6151 * R3716 (0xE84) - DRC1 ctrl5
6152 */
6153#define ARIZONA_DRC1_KNEE2_IP_MASK 0x03E0 /* DRC1_KNEE2_IP - [9:5] */
6154#define ARIZONA_DRC1_KNEE2_IP_SHIFT 5 /* DRC1_KNEE2_IP - [9:5] */
6155#define ARIZONA_DRC1_KNEE2_IP_WIDTH 5 /* DRC1_KNEE2_IP - [9:5] */
6156#define ARIZONA_DRC1_KNEE2_OP_MASK 0x001F /* DRC1_KNEE2_OP - [4:0] */
6157#define ARIZONA_DRC1_KNEE2_OP_SHIFT 0 /* DRC1_KNEE2_OP - [4:0] */
6158#define ARIZONA_DRC1_KNEE2_OP_WIDTH 5 /* DRC1_KNEE2_OP - [4:0] */
6159
6160/*
6161 * R3721 (0xE89) - DRC2 ctrl1
6162 */
6163#define ARIZONA_DRC2_SIG_DET_RMS_MASK 0xF800 /* DRC2_SIG_DET_RMS - [15:11] */
6164#define ARIZONA_DRC2_SIG_DET_RMS_SHIFT 11 /* DRC2_SIG_DET_RMS - [15:11] */
6165#define ARIZONA_DRC2_SIG_DET_RMS_WIDTH 5 /* DRC2_SIG_DET_RMS - [15:11] */
6166#define ARIZONA_DRC2_SIG_DET_PK_MASK 0x0600 /* DRC2_SIG_DET_PK - [10:9] */
6167#define ARIZONA_DRC2_SIG_DET_PK_SHIFT 9 /* DRC2_SIG_DET_PK - [10:9] */
6168#define ARIZONA_DRC2_SIG_DET_PK_WIDTH 2 /* DRC2_SIG_DET_PK - [10:9] */
6169#define ARIZONA_DRC2_NG_ENA 0x0100 /* DRC2_NG_ENA */
6170#define ARIZONA_DRC2_NG_ENA_MASK 0x0100 /* DRC2_NG_ENA */
6171#define ARIZONA_DRC2_NG_ENA_SHIFT 8 /* DRC2_NG_ENA */
6172#define ARIZONA_DRC2_NG_ENA_WIDTH 1 /* DRC2_NG_ENA */
6173#define ARIZONA_DRC2_SIG_DET_MODE 0x0080 /* DRC2_SIG_DET_MODE */
6174#define ARIZONA_DRC2_SIG_DET_MODE_MASK 0x0080 /* DRC2_SIG_DET_MODE */
6175#define ARIZONA_DRC2_SIG_DET_MODE_SHIFT 7 /* DRC2_SIG_DET_MODE */
6176#define ARIZONA_DRC2_SIG_DET_MODE_WIDTH 1 /* DRC2_SIG_DET_MODE */
6177#define ARIZONA_DRC2_SIG_DET 0x0040 /* DRC2_SIG_DET */
6178#define ARIZONA_DRC2_SIG_DET_MASK 0x0040 /* DRC2_SIG_DET */
6179#define ARIZONA_DRC2_SIG_DET_SHIFT 6 /* DRC2_SIG_DET */
6180#define ARIZONA_DRC2_SIG_DET_WIDTH 1 /* DRC2_SIG_DET */
6181#define ARIZONA_DRC2_KNEE2_OP_ENA 0x0020 /* DRC2_KNEE2_OP_ENA */
6182#define ARIZONA_DRC2_KNEE2_OP_ENA_MASK 0x0020 /* DRC2_KNEE2_OP_ENA */
6183#define ARIZONA_DRC2_KNEE2_OP_ENA_SHIFT 5 /* DRC2_KNEE2_OP_ENA */
6184#define ARIZONA_DRC2_KNEE2_OP_ENA_WIDTH 1 /* DRC2_KNEE2_OP_ENA */
6185#define ARIZONA_DRC2_QR 0x0010 /* DRC2_QR */
6186#define ARIZONA_DRC2_QR_MASK 0x0010 /* DRC2_QR */
6187#define ARIZONA_DRC2_QR_SHIFT 4 /* DRC2_QR */
6188#define ARIZONA_DRC2_QR_WIDTH 1 /* DRC2_QR */
6189#define ARIZONA_DRC2_ANTICLIP 0x0008 /* DRC2_ANTICLIP */
6190#define ARIZONA_DRC2_ANTICLIP_MASK 0x0008 /* DRC2_ANTICLIP */
6191#define ARIZONA_DRC2_ANTICLIP_SHIFT 3 /* DRC2_ANTICLIP */
6192#define ARIZONA_DRC2_ANTICLIP_WIDTH 1 /* DRC2_ANTICLIP */
6193#define ARIZONA_DRC2L_ENA 0x0002 /* DRC2L_ENA */
6194#define ARIZONA_DRC2L_ENA_MASK 0x0002 /* DRC2L_ENA */
6195#define ARIZONA_DRC2L_ENA_SHIFT 1 /* DRC2L_ENA */
6196#define ARIZONA_DRC2L_ENA_WIDTH 1 /* DRC2L_ENA */
6197#define ARIZONA_DRC2R_ENA 0x0001 /* DRC2R_ENA */
6198#define ARIZONA_DRC2R_ENA_MASK 0x0001 /* DRC2R_ENA */
6199#define ARIZONA_DRC2R_ENA_SHIFT 0 /* DRC2R_ENA */
6200#define ARIZONA_DRC2R_ENA_WIDTH 1 /* DRC2R_ENA */
6201
6202/*
6203 * R3722 (0xE8A) - DRC2 ctrl2
6204 */
6205#define ARIZONA_DRC2_ATK_MASK 0x1E00 /* DRC2_ATK - [12:9] */
6206#define ARIZONA_DRC2_ATK_SHIFT 9 /* DRC2_ATK - [12:9] */
6207#define ARIZONA_DRC2_ATK_WIDTH 4 /* DRC2_ATK - [12:9] */
6208#define ARIZONA_DRC2_DCY_MASK 0x01E0 /* DRC2_DCY - [8:5] */
6209#define ARIZONA_DRC2_DCY_SHIFT 5 /* DRC2_DCY - [8:5] */
6210#define ARIZONA_DRC2_DCY_WIDTH 4 /* DRC2_DCY - [8:5] */
6211#define ARIZONA_DRC2_MINGAIN_MASK 0x001C /* DRC2_MINGAIN - [4:2] */
6212#define ARIZONA_DRC2_MINGAIN_SHIFT 2 /* DRC2_MINGAIN - [4:2] */
6213#define ARIZONA_DRC2_MINGAIN_WIDTH 3 /* DRC2_MINGAIN - [4:2] */
6214#define ARIZONA_DRC2_MAXGAIN_MASK 0x0003 /* DRC2_MAXGAIN - [1:0] */
6215#define ARIZONA_DRC2_MAXGAIN_SHIFT 0 /* DRC2_MAXGAIN - [1:0] */
6216#define ARIZONA_DRC2_MAXGAIN_WIDTH 2 /* DRC2_MAXGAIN - [1:0] */
6217
6218/*
6219 * R3723 (0xE8B) - DRC2 ctrl3
6220 */
6221#define ARIZONA_DRC2_NG_MINGAIN_MASK 0xF000 /* DRC2_NG_MINGAIN - [15:12] */
6222#define ARIZONA_DRC2_NG_MINGAIN_SHIFT 12 /* DRC2_NG_MINGAIN - [15:12] */
6223#define ARIZONA_DRC2_NG_MINGAIN_WIDTH 4 /* DRC2_NG_MINGAIN - [15:12] */
6224#define ARIZONA_DRC2_NG_EXP_MASK 0x0C00 /* DRC2_NG_EXP - [11:10] */
6225#define ARIZONA_DRC2_NG_EXP_SHIFT 10 /* DRC2_NG_EXP - [11:10] */
6226#define ARIZONA_DRC2_NG_EXP_WIDTH 2 /* DRC2_NG_EXP - [11:10] */
6227#define ARIZONA_DRC2_QR_THR_MASK 0x0300 /* DRC2_QR_THR - [9:8] */
6228#define ARIZONA_DRC2_QR_THR_SHIFT 8 /* DRC2_QR_THR - [9:8] */
6229#define ARIZONA_DRC2_QR_THR_WIDTH 2 /* DRC2_QR_THR - [9:8] */
6230#define ARIZONA_DRC2_QR_DCY_MASK 0x00C0 /* DRC2_QR_DCY - [7:6] */
6231#define ARIZONA_DRC2_QR_DCY_SHIFT 6 /* DRC2_QR_DCY - [7:6] */
6232#define ARIZONA_DRC2_QR_DCY_WIDTH 2 /* DRC2_QR_DCY - [7:6] */
6233#define ARIZONA_DRC2_HI_COMP_MASK 0x0038 /* DRC2_HI_COMP - [5:3] */
6234#define ARIZONA_DRC2_HI_COMP_SHIFT 3 /* DRC2_HI_COMP - [5:3] */
6235#define ARIZONA_DRC2_HI_COMP_WIDTH 3 /* DRC2_HI_COMP - [5:3] */
6236#define ARIZONA_DRC2_LO_COMP_MASK 0x0007 /* DRC2_LO_COMP - [2:0] */
6237#define ARIZONA_DRC2_LO_COMP_SHIFT 0 /* DRC2_LO_COMP - [2:0] */
6238#define ARIZONA_DRC2_LO_COMP_WIDTH 3 /* DRC2_LO_COMP - [2:0] */
6239
6240/*
6241 * R3724 (0xE8C) - DRC2 ctrl4
6242 */
6243#define ARIZONA_DRC2_KNEE_IP_MASK 0x07E0 /* DRC2_KNEE_IP - [10:5] */
6244#define ARIZONA_DRC2_KNEE_IP_SHIFT 5 /* DRC2_KNEE_IP - [10:5] */
6245#define ARIZONA_DRC2_KNEE_IP_WIDTH 6 /* DRC2_KNEE_IP - [10:5] */
6246#define ARIZONA_DRC2_KNEE_OP_MASK 0x001F /* DRC2_KNEE_OP - [4:0] */
6247#define ARIZONA_DRC2_KNEE_OP_SHIFT 0 /* DRC2_KNEE_OP - [4:0] */
6248#define ARIZONA_DRC2_KNEE_OP_WIDTH 5 /* DRC2_KNEE_OP - [4:0] */
6249
6250/*
6251 * R3725 (0xE8D) - DRC2 ctrl5
6252 */
6253#define ARIZONA_DRC2_KNEE2_IP_MASK 0x03E0 /* DRC2_KNEE2_IP - [9:5] */
6254#define ARIZONA_DRC2_KNEE2_IP_SHIFT 5 /* DRC2_KNEE2_IP - [9:5] */
6255#define ARIZONA_DRC2_KNEE2_IP_WIDTH 5 /* DRC2_KNEE2_IP - [9:5] */
6256#define ARIZONA_DRC2_KNEE2_OP_MASK 0x001F /* DRC2_KNEE2_OP - [4:0] */
6257#define ARIZONA_DRC2_KNEE2_OP_SHIFT 0 /* DRC2_KNEE2_OP - [4:0] */
6258#define ARIZONA_DRC2_KNEE2_OP_WIDTH 5 /* DRC2_KNEE2_OP - [4:0] */
6259
6260/*
6261 * R3776 (0xEC0) - HPLPF1_1
6262 */
6263#define ARIZONA_LHPF1_MODE 0x0002 /* LHPF1_MODE */
6264#define ARIZONA_LHPF1_MODE_MASK 0x0002 /* LHPF1_MODE */
6265#define ARIZONA_LHPF1_MODE_SHIFT 1 /* LHPF1_MODE */
6266#define ARIZONA_LHPF1_MODE_WIDTH 1 /* LHPF1_MODE */
6267#define ARIZONA_LHPF1_ENA 0x0001 /* LHPF1_ENA */
6268#define ARIZONA_LHPF1_ENA_MASK 0x0001 /* LHPF1_ENA */
6269#define ARIZONA_LHPF1_ENA_SHIFT 0 /* LHPF1_ENA */
6270#define ARIZONA_LHPF1_ENA_WIDTH 1 /* LHPF1_ENA */
6271
6272/*
6273 * R3777 (0xEC1) - HPLPF1_2
6274 */
6275#define ARIZONA_LHPF1_COEFF_MASK 0xFFFF /* LHPF1_COEFF - [15:0] */
6276#define ARIZONA_LHPF1_COEFF_SHIFT 0 /* LHPF1_COEFF - [15:0] */
6277#define ARIZONA_LHPF1_COEFF_WIDTH 16 /* LHPF1_COEFF - [15:0] */
6278
6279/*
6280 * R3780 (0xEC4) - HPLPF2_1
6281 */
6282#define ARIZONA_LHPF2_MODE 0x0002 /* LHPF2_MODE */
6283#define ARIZONA_LHPF2_MODE_MASK 0x0002 /* LHPF2_MODE */
6284#define ARIZONA_LHPF2_MODE_SHIFT 1 /* LHPF2_MODE */
6285#define ARIZONA_LHPF2_MODE_WIDTH 1 /* LHPF2_MODE */
6286#define ARIZONA_LHPF2_ENA 0x0001 /* LHPF2_ENA */
6287#define ARIZONA_LHPF2_ENA_MASK 0x0001 /* LHPF2_ENA */
6288#define ARIZONA_LHPF2_ENA_SHIFT 0 /* LHPF2_ENA */
6289#define ARIZONA_LHPF2_ENA_WIDTH 1 /* LHPF2_ENA */
6290
6291/*
6292 * R3781 (0xEC5) - HPLPF2_2
6293 */
6294#define ARIZONA_LHPF2_COEFF_MASK 0xFFFF /* LHPF2_COEFF - [15:0] */
6295#define ARIZONA_LHPF2_COEFF_SHIFT 0 /* LHPF2_COEFF - [15:0] */
6296#define ARIZONA_LHPF2_COEFF_WIDTH 16 /* LHPF2_COEFF - [15:0] */
6297
6298/*
6299 * R3784 (0xEC8) - HPLPF3_1
6300 */
6301#define ARIZONA_LHPF3_MODE 0x0002 /* LHPF3_MODE */
6302#define ARIZONA_LHPF3_MODE_MASK 0x0002 /* LHPF3_MODE */
6303#define ARIZONA_LHPF3_MODE_SHIFT 1 /* LHPF3_MODE */
6304#define ARIZONA_LHPF3_MODE_WIDTH 1 /* LHPF3_MODE */
6305#define ARIZONA_LHPF3_ENA 0x0001 /* LHPF3_ENA */
6306#define ARIZONA_LHPF3_ENA_MASK 0x0001 /* LHPF3_ENA */
6307#define ARIZONA_LHPF3_ENA_SHIFT 0 /* LHPF3_ENA */
6308#define ARIZONA_LHPF3_ENA_WIDTH 1 /* LHPF3_ENA */
6309
6310/*
6311 * R3785 (0xEC9) - HPLPF3_2
6312 */
6313#define ARIZONA_LHPF3_COEFF_MASK 0xFFFF /* LHPF3_COEFF - [15:0] */
6314#define ARIZONA_LHPF3_COEFF_SHIFT 0 /* LHPF3_COEFF - [15:0] */
6315#define ARIZONA_LHPF3_COEFF_WIDTH 16 /* LHPF3_COEFF - [15:0] */
6316
6317/*
6318 * R3788 (0xECC) - HPLPF4_1
6319 */
6320#define ARIZONA_LHPF4_MODE 0x0002 /* LHPF4_MODE */
6321#define ARIZONA_LHPF4_MODE_MASK 0x0002 /* LHPF4_MODE */
6322#define ARIZONA_LHPF4_MODE_SHIFT 1 /* LHPF4_MODE */
6323#define ARIZONA_LHPF4_MODE_WIDTH 1 /* LHPF4_MODE */
6324#define ARIZONA_LHPF4_ENA 0x0001 /* LHPF4_ENA */
6325#define ARIZONA_LHPF4_ENA_MASK 0x0001 /* LHPF4_ENA */
6326#define ARIZONA_LHPF4_ENA_SHIFT 0 /* LHPF4_ENA */
6327#define ARIZONA_LHPF4_ENA_WIDTH 1 /* LHPF4_ENA */
6328
6329/*
6330 * R3789 (0xECD) - HPLPF4_2
6331 */
6332#define ARIZONA_LHPF4_COEFF_MASK 0xFFFF /* LHPF4_COEFF - [15:0] */
6333#define ARIZONA_LHPF4_COEFF_SHIFT 0 /* LHPF4_COEFF - [15:0] */
6334#define ARIZONA_LHPF4_COEFF_WIDTH 16 /* LHPF4_COEFF - [15:0] */
6335
6336/*
6337 * R3808 (0xEE0) - ASRC_ENABLE
6338 */
6339#define ARIZONA_ASRC2L_ENA 0x0008 /* ASRC2L_ENA */
6340#define ARIZONA_ASRC2L_ENA_MASK 0x0008 /* ASRC2L_ENA */
6341#define ARIZONA_ASRC2L_ENA_SHIFT 3 /* ASRC2L_ENA */
6342#define ARIZONA_ASRC2L_ENA_WIDTH 1 /* ASRC2L_ENA */
6343#define ARIZONA_ASRC2R_ENA 0x0004 /* ASRC2R_ENA */
6344#define ARIZONA_ASRC2R_ENA_MASK 0x0004 /* ASRC2R_ENA */
6345#define ARIZONA_ASRC2R_ENA_SHIFT 2 /* ASRC2R_ENA */
6346#define ARIZONA_ASRC2R_ENA_WIDTH 1 /* ASRC2R_ENA */
6347#define ARIZONA_ASRC1L_ENA 0x0002 /* ASRC1L_ENA */
6348#define ARIZONA_ASRC1L_ENA_MASK 0x0002 /* ASRC1L_ENA */
6349#define ARIZONA_ASRC1L_ENA_SHIFT 1 /* ASRC1L_ENA */
6350#define ARIZONA_ASRC1L_ENA_WIDTH 1 /* ASRC1L_ENA */
6351#define ARIZONA_ASRC1R_ENA 0x0001 /* ASRC1R_ENA */
6352#define ARIZONA_ASRC1R_ENA_MASK 0x0001 /* ASRC1R_ENA */
6353#define ARIZONA_ASRC1R_ENA_SHIFT 0 /* ASRC1R_ENA */
6354#define ARIZONA_ASRC1R_ENA_WIDTH 1 /* ASRC1R_ENA */
6355
6356/*
6357 * R3810 (0xEE2) - ASRC_RATE1
6358 */
6359#define ARIZONA_ASRC_RATE1_MASK 0x7800 /* ASRC_RATE1 - [14:11] */
6360#define ARIZONA_ASRC_RATE1_SHIFT 11 /* ASRC_RATE1 - [14:11] */
6361#define ARIZONA_ASRC_RATE1_WIDTH 4 /* ASRC_RATE1 - [14:11] */
6362
6363/*
6364 * R3811 (0xEE3) - ASRC_RATE2
6365 */
6366#define ARIZONA_ASRC_RATE2_MASK 0x7800 /* ASRC_RATE2 - [14:11] */
6367#define ARIZONA_ASRC_RATE2_SHIFT 11 /* ASRC_RATE2 - [14:11] */
6368#define ARIZONA_ASRC_RATE2_WIDTH 4 /* ASRC_RATE2 - [14:11] */
6369
6370/*
6371 * R3824 (0xEF0) - ISRC 1 CTRL 1
6372 */
6373#define ARIZONA_ISRC1_FSH_MASK 0x7800 /* ISRC1_FSH - [14:11] */
6374#define ARIZONA_ISRC1_FSH_SHIFT 11 /* ISRC1_FSH - [14:11] */
6375#define ARIZONA_ISRC1_FSH_WIDTH 4 /* ISRC1_FSH - [14:11] */
6376#define ARIZONA_ISRC1_CLK_SEL_MASK 0x0700 /* ISRC1_CLK_SEL - [10:8] */
6377#define ARIZONA_ISRC1_CLK_SEL_SHIFT 8 /* ISRC1_CLK_SEL - [10:8] */
6378#define ARIZONA_ISRC1_CLK_SEL_WIDTH 3 /* ISRC1_CLK_SEL - [10:8] */
6379
6380/*
6381 * R3825 (0xEF1) - ISRC 1 CTRL 2
6382 */
6383#define ARIZONA_ISRC1_FSL_MASK 0x7800 /* ISRC1_FSL - [14:11] */
6384#define ARIZONA_ISRC1_FSL_SHIFT 11 /* ISRC1_FSL - [14:11] */
6385#define ARIZONA_ISRC1_FSL_WIDTH 4 /* ISRC1_FSL - [14:11] */
6386
6387/*
6388 * R3826 (0xEF2) - ISRC 1 CTRL 3
6389 */
6390#define ARIZONA_ISRC1_INT0_ENA 0x8000 /* ISRC1_INT0_ENA */
6391#define ARIZONA_ISRC1_INT0_ENA_MASK 0x8000 /* ISRC1_INT0_ENA */
6392#define ARIZONA_ISRC1_INT0_ENA_SHIFT 15 /* ISRC1_INT0_ENA */
6393#define ARIZONA_ISRC1_INT0_ENA_WIDTH 1 /* ISRC1_INT0_ENA */
6394#define ARIZONA_ISRC1_INT1_ENA 0x4000 /* ISRC1_INT1_ENA */
6395#define ARIZONA_ISRC1_INT1_ENA_MASK 0x4000 /* ISRC1_INT1_ENA */
6396#define ARIZONA_ISRC1_INT1_ENA_SHIFT 14 /* ISRC1_INT1_ENA */
6397#define ARIZONA_ISRC1_INT1_ENA_WIDTH 1 /* ISRC1_INT1_ENA */
6398#define ARIZONA_ISRC1_INT2_ENA 0x2000 /* ISRC1_INT2_ENA */
6399#define ARIZONA_ISRC1_INT2_ENA_MASK 0x2000 /* ISRC1_INT2_ENA */
6400#define ARIZONA_ISRC1_INT2_ENA_SHIFT 13 /* ISRC1_INT2_ENA */
6401#define ARIZONA_ISRC1_INT2_ENA_WIDTH 1 /* ISRC1_INT2_ENA */
6402#define ARIZONA_ISRC1_INT3_ENA 0x1000 /* ISRC1_INT3_ENA */
6403#define ARIZONA_ISRC1_INT3_ENA_MASK 0x1000 /* ISRC1_INT3_ENA */
6404#define ARIZONA_ISRC1_INT3_ENA_SHIFT 12 /* ISRC1_INT3_ENA */
6405#define ARIZONA_ISRC1_INT3_ENA_WIDTH 1 /* ISRC1_INT3_ENA */
6406#define ARIZONA_ISRC1_DEC0_ENA 0x0200 /* ISRC1_DEC0_ENA */
6407#define ARIZONA_ISRC1_DEC0_ENA_MASK 0x0200 /* ISRC1_DEC0_ENA */
6408#define ARIZONA_ISRC1_DEC0_ENA_SHIFT 9 /* ISRC1_DEC0_ENA */
6409#define ARIZONA_ISRC1_DEC0_ENA_WIDTH 1 /* ISRC1_DEC0_ENA */
6410#define ARIZONA_ISRC1_DEC1_ENA 0x0100 /* ISRC1_DEC1_ENA */
6411#define ARIZONA_ISRC1_DEC1_ENA_MASK 0x0100 /* ISRC1_DEC1_ENA */
6412#define ARIZONA_ISRC1_DEC1_ENA_SHIFT 8 /* ISRC1_DEC1_ENA */
6413#define ARIZONA_ISRC1_DEC1_ENA_WIDTH 1 /* ISRC1_DEC1_ENA */
6414#define ARIZONA_ISRC1_DEC2_ENA 0x0080 /* ISRC1_DEC2_ENA */
6415#define ARIZONA_ISRC1_DEC2_ENA_MASK 0x0080 /* ISRC1_DEC2_ENA */
6416#define ARIZONA_ISRC1_DEC2_ENA_SHIFT 7 /* ISRC1_DEC2_ENA */
6417#define ARIZONA_ISRC1_DEC2_ENA_WIDTH 1 /* ISRC1_DEC2_ENA */
6418#define ARIZONA_ISRC1_DEC3_ENA 0x0040 /* ISRC1_DEC3_ENA */
6419#define ARIZONA_ISRC1_DEC3_ENA_MASK 0x0040 /* ISRC1_DEC3_ENA */
6420#define ARIZONA_ISRC1_DEC3_ENA_SHIFT 6 /* ISRC1_DEC3_ENA */
6421#define ARIZONA_ISRC1_DEC3_ENA_WIDTH 1 /* ISRC1_DEC3_ENA */
6422#define ARIZONA_ISRC1_NOTCH_ENA 0x0001 /* ISRC1_NOTCH_ENA */
6423#define ARIZONA_ISRC1_NOTCH_ENA_MASK 0x0001 /* ISRC1_NOTCH_ENA */
6424#define ARIZONA_ISRC1_NOTCH_ENA_SHIFT 0 /* ISRC1_NOTCH_ENA */
6425#define ARIZONA_ISRC1_NOTCH_ENA_WIDTH 1 /* ISRC1_NOTCH_ENA */
6426
6427/*
6428 * R3827 (0xEF3) - ISRC 2 CTRL 1
6429 */
6430#define ARIZONA_ISRC2_FSH_MASK 0x7800 /* ISRC2_FSH - [14:11] */
6431#define ARIZONA_ISRC2_FSH_SHIFT 11 /* ISRC2_FSH - [14:11] */
6432#define ARIZONA_ISRC2_FSH_WIDTH 4 /* ISRC2_FSH - [14:11] */
6433#define ARIZONA_ISRC2_CLK_SEL_MASK 0x0700 /* ISRC2_CLK_SEL - [10:8] */
6434#define ARIZONA_ISRC2_CLK_SEL_SHIFT 8 /* ISRC2_CLK_SEL - [10:8] */
6435#define ARIZONA_ISRC2_CLK_SEL_WIDTH 3 /* ISRC2_CLK_SEL - [10:8] */
6436
6437/*
6438 * R3828 (0xEF4) - ISRC 2 CTRL 2
6439 */
6440#define ARIZONA_ISRC2_FSL_MASK 0x7800 /* ISRC2_FSL - [14:11] */
6441#define ARIZONA_ISRC2_FSL_SHIFT 11 /* ISRC2_FSL - [14:11] */
6442#define ARIZONA_ISRC2_FSL_WIDTH 4 /* ISRC2_FSL - [14:11] */
6443
6444/*
6445 * R3829 (0xEF5) - ISRC 2 CTRL 3
6446 */
6447#define ARIZONA_ISRC2_INT0_ENA 0x8000 /* ISRC2_INT0_ENA */
6448#define ARIZONA_ISRC2_INT0_ENA_MASK 0x8000 /* ISRC2_INT0_ENA */
6449#define ARIZONA_ISRC2_INT0_ENA_SHIFT 15 /* ISRC2_INT0_ENA */
6450#define ARIZONA_ISRC2_INT0_ENA_WIDTH 1 /* ISRC2_INT0_ENA */
6451#define ARIZONA_ISRC2_INT1_ENA 0x4000 /* ISRC2_INT1_ENA */
6452#define ARIZONA_ISRC2_INT1_ENA_MASK 0x4000 /* ISRC2_INT1_ENA */
6453#define ARIZONA_ISRC2_INT1_ENA_SHIFT 14 /* ISRC2_INT1_ENA */
6454#define ARIZONA_ISRC2_INT1_ENA_WIDTH 1 /* ISRC2_INT1_ENA */
6455#define ARIZONA_ISRC2_INT2_ENA 0x2000 /* ISRC2_INT2_ENA */
6456#define ARIZONA_ISRC2_INT2_ENA_MASK 0x2000 /* ISRC2_INT2_ENA */
6457#define ARIZONA_ISRC2_INT2_ENA_SHIFT 13 /* ISRC2_INT2_ENA */
6458#define ARIZONA_ISRC2_INT2_ENA_WIDTH 1 /* ISRC2_INT2_ENA */
6459#define ARIZONA_ISRC2_INT3_ENA 0x1000 /* ISRC2_INT3_ENA */
6460#define ARIZONA_ISRC2_INT3_ENA_MASK 0x1000 /* ISRC2_INT3_ENA */
6461#define ARIZONA_ISRC2_INT3_ENA_SHIFT 12 /* ISRC2_INT3_ENA */
6462#define ARIZONA_ISRC2_INT3_ENA_WIDTH 1 /* ISRC2_INT3_ENA */
6463#define ARIZONA_ISRC2_DEC0_ENA 0x0200 /* ISRC2_DEC0_ENA */
6464#define ARIZONA_ISRC2_DEC0_ENA_MASK 0x0200 /* ISRC2_DEC0_ENA */
6465#define ARIZONA_ISRC2_DEC0_ENA_SHIFT 9 /* ISRC2_DEC0_ENA */
6466#define ARIZONA_ISRC2_DEC0_ENA_WIDTH 1 /* ISRC2_DEC0_ENA */
6467#define ARIZONA_ISRC2_DEC1_ENA 0x0100 /* ISRC2_DEC1_ENA */
6468#define ARIZONA_ISRC2_DEC1_ENA_MASK 0x0100 /* ISRC2_DEC1_ENA */
6469#define ARIZONA_ISRC2_DEC1_ENA_SHIFT 8 /* ISRC2_DEC1_ENA */
6470#define ARIZONA_ISRC2_DEC1_ENA_WIDTH 1 /* ISRC2_DEC1_ENA */
6471#define ARIZONA_ISRC2_DEC2_ENA 0x0080 /* ISRC2_DEC2_ENA */
6472#define ARIZONA_ISRC2_DEC2_ENA_MASK 0x0080 /* ISRC2_DEC2_ENA */
6473#define ARIZONA_ISRC2_DEC2_ENA_SHIFT 7 /* ISRC2_DEC2_ENA */
6474#define ARIZONA_ISRC2_DEC2_ENA_WIDTH 1 /* ISRC2_DEC2_ENA */
6475#define ARIZONA_ISRC2_DEC3_ENA 0x0040 /* ISRC2_DEC3_ENA */
6476#define ARIZONA_ISRC2_DEC3_ENA_MASK 0x0040 /* ISRC2_DEC3_ENA */
6477#define ARIZONA_ISRC2_DEC3_ENA_SHIFT 6 /* ISRC2_DEC3_ENA */
6478#define ARIZONA_ISRC2_DEC3_ENA_WIDTH 1 /* ISRC2_DEC3_ENA */
6479#define ARIZONA_ISRC2_NOTCH_ENA 0x0001 /* ISRC2_NOTCH_ENA */
6480#define ARIZONA_ISRC2_NOTCH_ENA_MASK 0x0001 /* ISRC2_NOTCH_ENA */
6481#define ARIZONA_ISRC2_NOTCH_ENA_SHIFT 0 /* ISRC2_NOTCH_ENA */
6482#define ARIZONA_ISRC2_NOTCH_ENA_WIDTH 1 /* ISRC2_NOTCH_ENA */
6483
6484/*
6485 * R3830 (0xEF6) - ISRC 3 CTRL 1
6486 */
6487#define ARIZONA_ISRC3_FSH_MASK 0x7800 /* ISRC3_FSH - [14:11] */
6488#define ARIZONA_ISRC3_FSH_SHIFT 11 /* ISRC3_FSH - [14:11] */
6489#define ARIZONA_ISRC3_FSH_WIDTH 4 /* ISRC3_FSH - [14:11] */
6490#define ARIZONA_ISRC3_CLK_SEL_MASK 0x0700 /* ISRC3_CLK_SEL - [10:8] */
6491#define ARIZONA_ISRC3_CLK_SEL_SHIFT 8 /* ISRC3_CLK_SEL - [10:8] */
6492#define ARIZONA_ISRC3_CLK_SEL_WIDTH 3 /* ISRC3_CLK_SEL - [10:8] */
6493
6494/*
6495 * R3831 (0xEF7) - ISRC 3 CTRL 2
6496 */
6497#define ARIZONA_ISRC3_FSL_MASK 0x7800 /* ISRC3_FSL - [14:11] */
6498#define ARIZONA_ISRC3_FSL_SHIFT 11 /* ISRC3_FSL - [14:11] */
6499#define ARIZONA_ISRC3_FSL_WIDTH 4 /* ISRC3_FSL - [14:11] */
6500
6501/*
6502 * R3832 (0xEF8) - ISRC 3 CTRL 3
6503 */
6504#define ARIZONA_ISRC3_INT0_ENA 0x8000 /* ISRC3_INT0_ENA */
6505#define ARIZONA_ISRC3_INT0_ENA_MASK 0x8000 /* ISRC3_INT0_ENA */
6506#define ARIZONA_ISRC3_INT0_ENA_SHIFT 15 /* ISRC3_INT0_ENA */
6507#define ARIZONA_ISRC3_INT0_ENA_WIDTH 1 /* ISRC3_INT0_ENA */
6508#define ARIZONA_ISRC3_INT1_ENA 0x4000 /* ISRC3_INT1_ENA */
6509#define ARIZONA_ISRC3_INT1_ENA_MASK 0x4000 /* ISRC3_INT1_ENA */
6510#define ARIZONA_ISRC3_INT1_ENA_SHIFT 14 /* ISRC3_INT1_ENA */
6511#define ARIZONA_ISRC3_INT1_ENA_WIDTH 1 /* ISRC3_INT1_ENA */
6512#define ARIZONA_ISRC3_INT2_ENA 0x2000 /* ISRC3_INT2_ENA */
6513#define ARIZONA_ISRC3_INT2_ENA_MASK 0x2000 /* ISRC3_INT2_ENA */
6514#define ARIZONA_ISRC3_INT2_ENA_SHIFT 13 /* ISRC3_INT2_ENA */
6515#define ARIZONA_ISRC3_INT2_ENA_WIDTH 1 /* ISRC3_INT2_ENA */
6516#define ARIZONA_ISRC3_INT3_ENA 0x1000 /* ISRC3_INT3_ENA */
6517#define ARIZONA_ISRC3_INT3_ENA_MASK 0x1000 /* ISRC3_INT3_ENA */
6518#define ARIZONA_ISRC3_INT3_ENA_SHIFT 12 /* ISRC3_INT3_ENA */
6519#define ARIZONA_ISRC3_INT3_ENA_WIDTH 1 /* ISRC3_INT3_ENA */
6520#define ARIZONA_ISRC3_DEC0_ENA 0x0200 /* ISRC3_DEC0_ENA */
6521#define ARIZONA_ISRC3_DEC0_ENA_MASK 0x0200 /* ISRC3_DEC0_ENA */
6522#define ARIZONA_ISRC3_DEC0_ENA_SHIFT 9 /* ISRC3_DEC0_ENA */
6523#define ARIZONA_ISRC3_DEC0_ENA_WIDTH 1 /* ISRC3_DEC0_ENA */
6524#define ARIZONA_ISRC3_DEC1_ENA 0x0100 /* ISRC3_DEC1_ENA */
6525#define ARIZONA_ISRC3_DEC1_ENA_MASK 0x0100 /* ISRC3_DEC1_ENA */
6526#define ARIZONA_ISRC3_DEC1_ENA_SHIFT 8 /* ISRC3_DEC1_ENA */
6527#define ARIZONA_ISRC3_DEC1_ENA_WIDTH 1 /* ISRC3_DEC1_ENA */
6528#define ARIZONA_ISRC3_DEC2_ENA 0x0080 /* ISRC3_DEC2_ENA */
6529#define ARIZONA_ISRC3_DEC2_ENA_MASK 0x0080 /* ISRC3_DEC2_ENA */
6530#define ARIZONA_ISRC3_DEC2_ENA_SHIFT 7 /* ISRC3_DEC2_ENA */
6531#define ARIZONA_ISRC3_DEC2_ENA_WIDTH 1 /* ISRC3_DEC2_ENA */
6532#define ARIZONA_ISRC3_DEC3_ENA 0x0040 /* ISRC3_DEC3_ENA */
6533#define ARIZONA_ISRC3_DEC3_ENA_MASK 0x0040 /* ISRC3_DEC3_ENA */
6534#define ARIZONA_ISRC3_DEC3_ENA_SHIFT 6 /* ISRC3_DEC3_ENA */
6535#define ARIZONA_ISRC3_DEC3_ENA_WIDTH 1 /* ISRC3_DEC3_ENA */
6536#define ARIZONA_ISRC3_NOTCH_ENA 0x0001 /* ISRC3_NOTCH_ENA */
6537#define ARIZONA_ISRC3_NOTCH_ENA_MASK 0x0001 /* ISRC3_NOTCH_ENA */
6538#define ARIZONA_ISRC3_NOTCH_ENA_SHIFT 0 /* ISRC3_NOTCH_ENA */
6539#define ARIZONA_ISRC3_NOTCH_ENA_WIDTH 1 /* ISRC3_NOTCH_ENA */
6540
6541/*
6542 * R4352 (0x1100) - DSP1 Control 1
6543 */
6544#define ARIZONA_DSP1_RATE_MASK 0x7800 /* DSP1_RATE - [14:11] */
6545#define ARIZONA_DSP1_RATE_SHIFT 11 /* DSP1_RATE - [14:11] */
6546#define ARIZONA_DSP1_RATE_WIDTH 4 /* DSP1_RATE - [14:11] */
6547#define ARIZONA_DSP1_MEM_ENA 0x0010 /* DSP1_MEM_ENA */
6548#define ARIZONA_DSP1_MEM_ENA_MASK 0x0010 /* DSP1_MEM_ENA */
6549#define ARIZONA_DSP1_MEM_ENA_SHIFT 4 /* DSP1_MEM_ENA */
6550#define ARIZONA_DSP1_MEM_ENA_WIDTH 1 /* DSP1_MEM_ENA */
6551#define ARIZONA_DSP1_SYS_ENA 0x0004 /* DSP1_SYS_ENA */
6552#define ARIZONA_DSP1_SYS_ENA_MASK 0x0004 /* DSP1_SYS_ENA */
6553#define ARIZONA_DSP1_SYS_ENA_SHIFT 2 /* DSP1_SYS_ENA */
6554#define ARIZONA_DSP1_SYS_ENA_WIDTH 1 /* DSP1_SYS_ENA */
6555#define ARIZONA_DSP1_CORE_ENA 0x0002 /* DSP1_CORE_ENA */
6556#define ARIZONA_DSP1_CORE_ENA_MASK 0x0002 /* DSP1_CORE_ENA */
6557#define ARIZONA_DSP1_CORE_ENA_SHIFT 1 /* DSP1_CORE_ENA */
6558#define ARIZONA_DSP1_CORE_ENA_WIDTH 1 /* DSP1_CORE_ENA */
6559#define ARIZONA_DSP1_START 0x0001 /* DSP1_START */
6560#define ARIZONA_DSP1_START_MASK 0x0001 /* DSP1_START */
6561#define ARIZONA_DSP1_START_SHIFT 0 /* DSP1_START */
6562#define ARIZONA_DSP1_START_WIDTH 1 /* DSP1_START */
6563
6564/*
6565 * R4353 (0x1101) - DSP1 Clocking 1
6566 */
6567#define ARIZONA_DSP1_CLK_SEL_MASK 0x0007 /* DSP1_CLK_SEL - [2:0] */
6568#define ARIZONA_DSP1_CLK_SEL_SHIFT 0 /* DSP1_CLK_SEL - [2:0] */
6569#define ARIZONA_DSP1_CLK_SEL_WIDTH 3 /* DSP1_CLK_SEL - [2:0] */
6570
6571/*
6572 * R4356 (0x1104) - DSP1 Status 1
6573 */
6574#define ARIZONA_DSP1_RAM_RDY 0x0001 /* DSP1_RAM_RDY */
6575#define ARIZONA_DSP1_RAM_RDY_MASK 0x0001 /* DSP1_RAM_RDY */
6576#define ARIZONA_DSP1_RAM_RDY_SHIFT 0 /* DSP1_RAM_RDY */
6577#define ARIZONA_DSP1_RAM_RDY_WIDTH 1 /* DSP1_RAM_RDY */
6578
6579/*
6580 * R4357 (0x1105) - DSP1 Status 2
6581 */
6582#define ARIZONA_DSP1_PING_FULL 0x8000 /* DSP1_PING_FULL */
6583#define ARIZONA_DSP1_PING_FULL_MASK 0x8000 /* DSP1_PING_FULL */
6584#define ARIZONA_DSP1_PING_FULL_SHIFT 15 /* DSP1_PING_FULL */
6585#define ARIZONA_DSP1_PING_FULL_WIDTH 1 /* DSP1_PING_FULL */
6586#define ARIZONA_DSP1_PONG_FULL 0x4000 /* DSP1_PONG_FULL */
6587#define ARIZONA_DSP1_PONG_FULL_MASK 0x4000 /* DSP1_PONG_FULL */
6588#define ARIZONA_DSP1_PONG_FULL_SHIFT 14 /* DSP1_PONG_FULL */
6589#define ARIZONA_DSP1_PONG_FULL_WIDTH 1 /* DSP1_PONG_FULL */
6590#define ARIZONA_DSP1_WDMA_ACTIVE_CHANNELS_MASK 0x00FF /* DSP1_WDMA_ACTIVE_CHANNELS - [7:0] */
6591#define ARIZONA_DSP1_WDMA_ACTIVE_CHANNELS_SHIFT 0 /* DSP1_WDMA_ACTIVE_CHANNELS - [7:0] */
6592#define ARIZONA_DSP1_WDMA_ACTIVE_CHANNELS_WIDTH 8 /* DSP1_WDMA_ACTIVE_CHANNELS - [7:0] */
6593
6594#endif
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
index 4e76163dd862..3a8435a8058f 100644
--- a/include/linux/mfd/core.h
+++ b/include/linux/mfd/core.h
@@ -36,6 +36,11 @@ struct mfd_cell {
36 /* platform data passed to the sub devices drivers */ 36 /* platform data passed to the sub devices drivers */
37 void *platform_data; 37 void *platform_data;
38 size_t pdata_size; 38 size_t pdata_size;
39 /*
40 * Device Tree compatible string
41 * See: Documentation/devicetree/usage-model.txt Chapter 2.2 for details
42 */
43 const char *of_compatible;
39 44
40 /* 45 /*
41 * These resources can be specified relative to the parent device. 46 * These resources can be specified relative to the parent device.
diff --git a/include/linux/mfd/db8500-prcmu.h b/include/linux/mfd/db8500-prcmu.h
index b3a43b1263fe..b82f6ee66a0b 100644
--- a/include/linux/mfd/db8500-prcmu.h
+++ b/include/linux/mfd/db8500-prcmu.h
@@ -530,7 +530,7 @@ int db8500_prcmu_stop_temp_sense(void);
530int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size); 530int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
531int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size); 531int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
532 532
533void prcmu_ac_wake_req(void); 533int prcmu_ac_wake_req(void);
534void prcmu_ac_sleep_req(void); 534void prcmu_ac_sleep_req(void);
535void db8500_prcmu_modem_reset(void); 535void db8500_prcmu_modem_reset(void);
536 536
@@ -680,7 +680,10 @@ static inline int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
680 return -ENOSYS; 680 return -ENOSYS;
681} 681}
682 682
683static inline void prcmu_ac_wake_req(void) {} 683static inline int prcmu_ac_wake_req(void)
684{
685 return 0;
686}
684 687
685static inline void prcmu_ac_sleep_req(void) {} 688static inline void prcmu_ac_sleep_req(void) {}
686 689
diff --git a/include/linux/mfd/dbx500-prcmu.h b/include/linux/mfd/dbx500-prcmu.h
index 5a13f93d8f1c..5b90e94399e1 100644
--- a/include/linux/mfd/dbx500-prcmu.h
+++ b/include/linux/mfd/dbx500-prcmu.h
@@ -345,7 +345,7 @@ static inline u16 prcmu_get_reset_code(void)
345 return db8500_prcmu_get_reset_code(); 345 return db8500_prcmu_get_reset_code();
346} 346}
347 347
348void prcmu_ac_wake_req(void); 348int prcmu_ac_wake_req(void);
349void prcmu_ac_sleep_req(void); 349void prcmu_ac_sleep_req(void);
350static inline void prcmu_modem_reset(void) 350static inline void prcmu_modem_reset(void)
351{ 351{
@@ -533,7 +533,10 @@ static inline u16 prcmu_get_reset_code(void)
533 return 0; 533 return 0;
534} 534}
535 535
536static inline void prcmu_ac_wake_req(void) {} 536static inline int prcmu_ac_wake_req(void)
537{
538 return 0;
539}
537 540
538static inline void prcmu_ac_sleep_req(void) {} 541static inline void prcmu_ac_sleep_req(void) {}
539 542
diff --git a/include/linux/mfd/max77686-private.h b/include/linux/mfd/max77686-private.h
new file mode 100644
index 000000000000..d327d4971e4f
--- /dev/null
+++ b/include/linux/mfd/max77686-private.h
@@ -0,0 +1,246 @@
1/*
2 * max77686.h - Voltage regulator driver for the Maxim 77686
3 *
4 * Copyright (C) 2012 Samsung Electrnoics
5 * Chiwoong Byun <woong.byun@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef __LINUX_MFD_MAX77686_PRIV_H
23#define __LINUX_MFD_MAX77686_PRIV_H
24
25#include <linux/i2c.h>
26#include <linux/regmap.h>
27#include <linux/module.h>
28
29#define MAX77686_REG_INVALID (0xff)
30
31enum max77686_pmic_reg {
32 MAX77686_REG_DEVICE_ID = 0x00,
33 MAX77686_REG_INTSRC = 0x01,
34 MAX77686_REG_INT1 = 0x02,
35 MAX77686_REG_INT2 = 0x03,
36
37 MAX77686_REG_INT1MSK = 0x04,
38 MAX77686_REG_INT2MSK = 0x05,
39
40 MAX77686_REG_STATUS1 = 0x06,
41 MAX77686_REG_STATUS2 = 0x07,
42
43 MAX77686_REG_PWRON = 0x08,
44 MAX77686_REG_ONOFF_DELAY = 0x09,
45 MAX77686_REG_MRSTB = 0x0A,
46 /* Reserved: 0x0B-0x0F */
47
48 MAX77686_REG_BUCK1CTRL = 0x10,
49 MAX77686_REG_BUCK1OUT = 0x11,
50 MAX77686_REG_BUCK2CTRL1 = 0x12,
51 MAX77686_REG_BUCK234FREQ = 0x13,
52 MAX77686_REG_BUCK2DVS1 = 0x14,
53 MAX77686_REG_BUCK2DVS2 = 0x15,
54 MAX77686_REG_BUCK2DVS3 = 0x16,
55 MAX77686_REG_BUCK2DVS4 = 0x17,
56 MAX77686_REG_BUCK2DVS5 = 0x18,
57 MAX77686_REG_BUCK2DVS6 = 0x19,
58 MAX77686_REG_BUCK2DVS7 = 0x1A,
59 MAX77686_REG_BUCK2DVS8 = 0x1B,
60 MAX77686_REG_BUCK3CTRL1 = 0x1C,
61 /* Reserved: 0x1D */
62 MAX77686_REG_BUCK3DVS1 = 0x1E,
63 MAX77686_REG_BUCK3DVS2 = 0x1F,
64 MAX77686_REG_BUCK3DVS3 = 0x20,
65 MAX77686_REG_BUCK3DVS4 = 0x21,
66 MAX77686_REG_BUCK3DVS5 = 0x22,
67 MAX77686_REG_BUCK3DVS6 = 0x23,
68 MAX77686_REG_BUCK3DVS7 = 0x24,
69 MAX77686_REG_BUCK3DVS8 = 0x25,
70 MAX77686_REG_BUCK4CTRL1 = 0x26,
71 /* Reserved: 0x27 */
72 MAX77686_REG_BUCK4DVS1 = 0x28,
73 MAX77686_REG_BUCK4DVS2 = 0x29,
74 MAX77686_REG_BUCK4DVS3 = 0x2A,
75 MAX77686_REG_BUCK4DVS4 = 0x2B,
76 MAX77686_REG_BUCK4DVS5 = 0x2C,
77 MAX77686_REG_BUCK4DVS6 = 0x2D,
78 MAX77686_REG_BUCK4DVS7 = 0x2E,
79 MAX77686_REG_BUCK4DVS8 = 0x2F,
80 MAX77686_REG_BUCK5CTRL = 0x30,
81 MAX77686_REG_BUCK5OUT = 0x31,
82 MAX77686_REG_BUCK6CTRL = 0x32,
83 MAX77686_REG_BUCK6OUT = 0x33,
84 MAX77686_REG_BUCK7CTRL = 0x34,
85 MAX77686_REG_BUCK7OUT = 0x35,
86 MAX77686_REG_BUCK8CTRL = 0x36,
87 MAX77686_REG_BUCK8OUT = 0x37,
88 MAX77686_REG_BUCK9CTRL = 0x38,
89 MAX77686_REG_BUCK9OUT = 0x39,
90 /* Reserved: 0x3A-0x3F */
91
92 MAX77686_REG_LDO1CTRL1 = 0x40,
93 MAX77686_REG_LDO2CTRL1 = 0x41,
94 MAX77686_REG_LDO3CTRL1 = 0x42,
95 MAX77686_REG_LDO4CTRL1 = 0x43,
96 MAX77686_REG_LDO5CTRL1 = 0x44,
97 MAX77686_REG_LDO6CTRL1 = 0x45,
98 MAX77686_REG_LDO7CTRL1 = 0x46,
99 MAX77686_REG_LDO8CTRL1 = 0x47,
100 MAX77686_REG_LDO9CTRL1 = 0x48,
101 MAX77686_REG_LDO10CTRL1 = 0x49,
102 MAX77686_REG_LDO11CTRL1 = 0x4A,
103 MAX77686_REG_LDO12CTRL1 = 0x4B,
104 MAX77686_REG_LDO13CTRL1 = 0x4C,
105 MAX77686_REG_LDO14CTRL1 = 0x4D,
106 MAX77686_REG_LDO15CTRL1 = 0x4E,
107 MAX77686_REG_LDO16CTRL1 = 0x4F,
108 MAX77686_REG_LDO17CTRL1 = 0x50,
109 MAX77686_REG_LDO18CTRL1 = 0x51,
110 MAX77686_REG_LDO19CTRL1 = 0x52,
111 MAX77686_REG_LDO20CTRL1 = 0x53,
112 MAX77686_REG_LDO21CTRL1 = 0x54,
113 MAX77686_REG_LDO22CTRL1 = 0x55,
114 MAX77686_REG_LDO23CTRL1 = 0x56,
115 MAX77686_REG_LDO24CTRL1 = 0x57,
116 MAX77686_REG_LDO25CTRL1 = 0x58,
117 MAX77686_REG_LDO26CTRL1 = 0x59,
118 /* Reserved: 0x5A-0x5F */
119 MAX77686_REG_LDO1CTRL2 = 0x60,
120 MAX77686_REG_LDO2CTRL2 = 0x61,
121 MAX77686_REG_LDO3CTRL2 = 0x62,
122 MAX77686_REG_LDO4CTRL2 = 0x63,
123 MAX77686_REG_LDO5CTRL2 = 0x64,
124 MAX77686_REG_LDO6CTRL2 = 0x65,
125 MAX77686_REG_LDO7CTRL2 = 0x66,
126 MAX77686_REG_LDO8CTRL2 = 0x67,
127 MAX77686_REG_LDO9CTRL2 = 0x68,
128 MAX77686_REG_LDO10CTRL2 = 0x69,
129 MAX77686_REG_LDO11CTRL2 = 0x6A,
130 MAX77686_REG_LDO12CTRL2 = 0x6B,
131 MAX77686_REG_LDO13CTRL2 = 0x6C,
132 MAX77686_REG_LDO14CTRL2 = 0x6D,
133 MAX77686_REG_LDO15CTRL2 = 0x6E,
134 MAX77686_REG_LDO16CTRL2 = 0x6F,
135 MAX77686_REG_LDO17CTRL2 = 0x70,
136 MAX77686_REG_LDO18CTRL2 = 0x71,
137 MAX77686_REG_LDO19CTRL2 = 0x72,
138 MAX77686_REG_LDO20CTRL2 = 0x73,
139 MAX77686_REG_LDO21CTRL2 = 0x74,
140 MAX77686_REG_LDO22CTRL2 = 0x75,
141 MAX77686_REG_LDO23CTRL2 = 0x76,
142 MAX77686_REG_LDO24CTRL2 = 0x77,
143 MAX77686_REG_LDO25CTRL2 = 0x78,
144 MAX77686_REG_LDO26CTRL2 = 0x79,
145 /* Reserved: 0x7A-0x7D */
146
147 MAX77686_REG_BBAT_CHG = 0x7E,
148 MAX77686_REG_32KHZ = 0x7F,
149
150 MAX77686_REG_PMIC_END = 0x80,
151};
152
153enum max77686_rtc_reg {
154 MAX77686_RTC_INT = 0x00,
155 MAX77686_RTC_INTM = 0x01,
156 MAX77686_RTC_CONTROLM = 0x02,
157 MAX77686_RTC_CONTROL = 0x03,
158 MAX77686_RTC_UPDATE0 = 0x04,
159 /* Reserved: 0x5 */
160 MAX77686_WTSR_SMPL_CNTL = 0x06,
161 MAX77686_RTC_SEC = 0x07,
162 MAX77686_RTC_MIN = 0x08,
163 MAX77686_RTC_HOUR = 0x09,
164 MAX77686_RTC_WEEKDAY = 0x0A,
165 MAX77686_RTC_MONTH = 0x0B,
166 MAX77686_RTC_YEAR = 0x0C,
167 MAX77686_RTC_DATE = 0x0D,
168 MAX77686_ALARM1_SEC = 0x0E,
169 MAX77686_ALARM1_MIN = 0x0F,
170 MAX77686_ALARM1_HOUR = 0x10,
171 MAX77686_ALARM1_WEEKDAY = 0x11,
172 MAX77686_ALARM1_MONTH = 0x12,
173 MAX77686_ALARM1_YEAR = 0x13,
174 MAX77686_ALARM1_DATE = 0x14,
175 MAX77686_ALARM2_SEC = 0x15,
176 MAX77686_ALARM2_MIN = 0x16,
177 MAX77686_ALARM2_HOUR = 0x17,
178 MAX77686_ALARM2_WEEKDAY = 0x18,
179 MAX77686_ALARM2_MONTH = 0x19,
180 MAX77686_ALARM2_YEAR = 0x1A,
181 MAX77686_ALARM2_DATE = 0x1B,
182};
183
184#define MAX77686_IRQSRC_PMIC (0)
185#define MAX77686_IRQSRC_RTC (1 << 0)
186
187enum max77686_irq_source {
188 PMIC_INT1 = 0,
189 PMIC_INT2,
190 RTC_INT,
191
192 MAX77686_IRQ_GROUP_NR,
193};
194
195enum max77686_irq {
196 MAX77686_PMICIRQ_PWRONF,
197 MAX77686_PMICIRQ_PWRONR,
198 MAX77686_PMICIRQ_JIGONBF,
199 MAX77686_PMICIRQ_JIGONBR,
200 MAX77686_PMICIRQ_ACOKBF,
201 MAX77686_PMICIRQ_ACOKBR,
202 MAX77686_PMICIRQ_ONKEY1S,
203 MAX77686_PMICIRQ_MRSTB,
204
205 MAX77686_PMICIRQ_140C,
206 MAX77686_PMICIRQ_120C,
207
208 MAX77686_RTCIRQ_RTC60S,
209 MAX77686_RTCIRQ_RTCA1,
210 MAX77686_RTCIRQ_RTCA2,
211 MAX77686_RTCIRQ_SMPL,
212 MAX77686_RTCIRQ_RTC1S,
213 MAX77686_RTCIRQ_WTSR,
214
215 MAX77686_IRQ_NR,
216};
217
218struct max77686_dev {
219 struct device *dev;
220 struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */
221 struct i2c_client *rtc; /* slave addr 0x0c */
222
223 int type;
224
225 struct regmap *regmap; /* regmap for mfd */
226 struct regmap *rtc_regmap; /* regmap for rtc */
227
228 struct irq_domain *irq_domain;
229
230 int irq;
231 int irq_gpio;
232 bool wakeup;
233 struct mutex irqlock;
234 int irq_masks_cur[MAX77686_IRQ_GROUP_NR];
235 int irq_masks_cache[MAX77686_IRQ_GROUP_NR];
236};
237
238enum max77686_types {
239 TYPE_MAX77686,
240};
241
242extern int max77686_irq_init(struct max77686_dev *max77686);
243extern void max77686_irq_exit(struct max77686_dev *max77686);
244extern int max77686_irq_resume(struct max77686_dev *max77686);
245
246#endif /* __LINUX_MFD_MAX77686_PRIV_H */
diff --git a/include/linux/mfd/max77686.h b/include/linux/mfd/max77686.h
new file mode 100644
index 000000000000..3d7ae4d7fd36
--- /dev/null
+++ b/include/linux/mfd/max77686.h
@@ -0,0 +1,114 @@
1/*
2 * max77686.h - Driver for the Maxim 77686
3 *
4 * Copyright (C) 2012 Samsung Electrnoics
5 * Chiwoong Byun <woong.byun@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * This driver is based on max8997.h
22 *
23 * MAX77686 has PMIC, RTC devices.
24 * The devices share the same I2C bus and included in
25 * this mfd driver.
26 */
27
28#ifndef __LINUX_MFD_MAX77686_H
29#define __LINUX_MFD_MAX77686_H
30
31#include <linux/regulator/consumer.h>
32
33/* MAX77686 regulator IDs */
34enum max77686_regulators {
35 MAX77686_LDO1 = 0,
36 MAX77686_LDO2,
37 MAX77686_LDO3,
38 MAX77686_LDO4,
39 MAX77686_LDO5,
40 MAX77686_LDO6,
41 MAX77686_LDO7,
42 MAX77686_LDO8,
43 MAX77686_LDO9,
44 MAX77686_LDO10,
45 MAX77686_LDO11,
46 MAX77686_LDO12,
47 MAX77686_LDO13,
48 MAX77686_LDO14,
49 MAX77686_LDO15,
50 MAX77686_LDO16,
51 MAX77686_LDO17,
52 MAX77686_LDO18,
53 MAX77686_LDO19,
54 MAX77686_LDO20,
55 MAX77686_LDO21,
56 MAX77686_LDO22,
57 MAX77686_LDO23,
58 MAX77686_LDO24,
59 MAX77686_LDO25,
60 MAX77686_LDO26,
61 MAX77686_BUCK1,
62 MAX77686_BUCK2,
63 MAX77686_BUCK3,
64 MAX77686_BUCK4,
65 MAX77686_BUCK5,
66 MAX77686_BUCK6,
67 MAX77686_BUCK7,
68 MAX77686_BUCK8,
69 MAX77686_BUCK9,
70
71 MAX77686_REG_MAX,
72};
73
74struct max77686_regulator_data {
75 int id;
76 struct regulator_init_data *initdata;
77};
78
79enum max77686_opmode {
80 MAX77686_OPMODE_NORMAL,
81 MAX77686_OPMODE_LP,
82 MAX77686_OPMODE_STANDBY,
83};
84
85struct max77686_opmode_data {
86 int id;
87 int mode;
88};
89
90struct max77686_platform_data {
91 /* IRQ */
92 int irq_gpio;
93 int ono;
94 int wakeup;
95
96 /* ---- PMIC ---- */
97 struct max77686_regulator_data *regulators;
98 int num_regulators;
99
100 struct max77686_opmode_data *opmode_data;
101
102 /*
103 * GPIO-DVS feature is not enabled with the current version of
104 * MAX77686 driver. Buck2/3/4_voltages[0] is used as the default
105 * voltage at probe. DVS/SELB gpios are set as OUTPUT-LOW.
106 */
107 int buck234_gpio_dvs[3]; /* GPIO of [0]DVS1, [1]DVS2, [2]DVS3 */
108 int buck234_gpio_selb[3]; /* [0]SELB2, [1]SELB3, [2]SELB4 */
109 unsigned int buck2_voltage[8]; /* buckx_voltage in uV */
110 unsigned int buck3_voltage[8];
111 unsigned int buck4_voltage[8];
112};
113
114#endif /* __LINUX_MFD_MAX77686_H */
diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h
index 68263c5fa53c..1eeae5c07915 100644
--- a/include/linux/mfd/max77693-private.h
+++ b/include/linux/mfd/max77693-private.h
@@ -190,7 +190,6 @@ struct max77693_dev {
190 struct i2c_client *i2c; /* 0xCC , PMIC, Charger, Flash LED */ 190 struct i2c_client *i2c; /* 0xCC , PMIC, Charger, Flash LED */
191 struct i2c_client *muic; /* 0x4A , MUIC */ 191 struct i2c_client *muic; /* 0x4A , MUIC */
192 struct i2c_client *haptic; /* 0x90 , Haptic */ 192 struct i2c_client *haptic; /* 0x90 , Haptic */
193 struct mutex iolock;
194 193
195 int type; 194 int type;
196 195
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
index 3f4deb62d6b0..830152cfae33 100644
--- a/include/linux/mfd/max8997-private.h
+++ b/include/linux/mfd/max8997-private.h
@@ -23,6 +23,8 @@
23#define __LINUX_MFD_MAX8997_PRIV_H 23#define __LINUX_MFD_MAX8997_PRIV_H
24 24
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/export.h>
27#include <linux/irqdomain.h>
26 28
27#define MAX8997_REG_INVALID (0xff) 29#define MAX8997_REG_INVALID (0xff)
28 30
@@ -325,7 +327,7 @@ struct max8997_dev {
325 327
326 int irq; 328 int irq;
327 int ono; 329 int ono;
328 int irq_base; 330 struct irq_domain *irq_domain;
329 struct mutex irqlock; 331 struct mutex irqlock;
330 int irq_masks_cur[MAX8997_IRQ_GROUP_NR]; 332 int irq_masks_cur[MAX8997_IRQ_GROUP_NR];
331 int irq_masks_cache[MAX8997_IRQ_GROUP_NR]; 333 int irq_masks_cache[MAX8997_IRQ_GROUP_NR];
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
index b40c08cd30bc..328d8e24b533 100644
--- a/include/linux/mfd/max8997.h
+++ b/include/linux/mfd/max8997.h
@@ -181,7 +181,6 @@ struct max8997_led_platform_data {
181 181
182struct max8997_platform_data { 182struct max8997_platform_data {
183 /* IRQ */ 183 /* IRQ */
184 int irq_base;
185 int ono; 184 int ono;
186 int wakeup; 185 int wakeup;
187 186
diff --git a/include/linux/mfd/s5m87xx/s5m-core.h b/include/linux/mfd/s5m87xx/s5m-core.h
deleted file mode 100644
index 0b2e0ed309f5..000000000000
--- a/include/linux/mfd/s5m87xx/s5m-core.h
+++ /dev/null
@@ -1,379 +0,0 @@
1/*
2 * s5m-core.h
3 *
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd
5 * http://www.samsung.com
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#ifndef __LINUX_MFD_S5M_CORE_H
15#define __LINUX_MFD_S5M_CORE_H
16
17#define NUM_IRQ_REGS 4
18
19enum s5m_device_type {
20 S5M8751X,
21 S5M8763X,
22 S5M8767X,
23};
24
25/* S5M8767 registers */
26enum s5m8767_reg {
27 S5M8767_REG_ID,
28 S5M8767_REG_INT1,
29 S5M8767_REG_INT2,
30 S5M8767_REG_INT3,
31 S5M8767_REG_INT1M,
32 S5M8767_REG_INT2M,
33 S5M8767_REG_INT3M,
34 S5M8767_REG_STATUS1,
35 S5M8767_REG_STATUS2,
36 S5M8767_REG_STATUS3,
37 S5M8767_REG_CTRL1,
38 S5M8767_REG_CTRL2,
39 S5M8767_REG_LOWBAT1,
40 S5M8767_REG_LOWBAT2,
41 S5M8767_REG_BUCHG,
42 S5M8767_REG_DVSRAMP,
43 S5M8767_REG_DVSTIMER2 = 0x10,
44 S5M8767_REG_DVSTIMER3,
45 S5M8767_REG_DVSTIMER4,
46 S5M8767_REG_LDO1,
47 S5M8767_REG_LDO2,
48 S5M8767_REG_LDO3,
49 S5M8767_REG_LDO4,
50 S5M8767_REG_LDO5,
51 S5M8767_REG_LDO6,
52 S5M8767_REG_LDO7,
53 S5M8767_REG_LDO8,
54 S5M8767_REG_LDO9,
55 S5M8767_REG_LDO10,
56 S5M8767_REG_LDO11,
57 S5M8767_REG_LDO12,
58 S5M8767_REG_LDO13,
59 S5M8767_REG_LDO14 = 0x20,
60 S5M8767_REG_LDO15,
61 S5M8767_REG_LDO16,
62 S5M8767_REG_LDO17,
63 S5M8767_REG_LDO18,
64 S5M8767_REG_LDO19,
65 S5M8767_REG_LDO20,
66 S5M8767_REG_LDO21,
67 S5M8767_REG_LDO22,
68 S5M8767_REG_LDO23,
69 S5M8767_REG_LDO24,
70 S5M8767_REG_LDO25,
71 S5M8767_REG_LDO26,
72 S5M8767_REG_LDO27,
73 S5M8767_REG_LDO28,
74 S5M8767_REG_UVLO = 0x31,
75 S5M8767_REG_BUCK1CTRL1,
76 S5M8767_REG_BUCK1CTRL2,
77 S5M8767_REG_BUCK2CTRL,
78 S5M8767_REG_BUCK2DVS1,
79 S5M8767_REG_BUCK2DVS2,
80 S5M8767_REG_BUCK2DVS3,
81 S5M8767_REG_BUCK2DVS4,
82 S5M8767_REG_BUCK2DVS5,
83 S5M8767_REG_BUCK2DVS6,
84 S5M8767_REG_BUCK2DVS7,
85 S5M8767_REG_BUCK2DVS8,
86 S5M8767_REG_BUCK3CTRL,
87 S5M8767_REG_BUCK3DVS1,
88 S5M8767_REG_BUCK3DVS2,
89 S5M8767_REG_BUCK3DVS3,
90 S5M8767_REG_BUCK3DVS4,
91 S5M8767_REG_BUCK3DVS5,
92 S5M8767_REG_BUCK3DVS6,
93 S5M8767_REG_BUCK3DVS7,
94 S5M8767_REG_BUCK3DVS8,
95 S5M8767_REG_BUCK4CTRL,
96 S5M8767_REG_BUCK4DVS1,
97 S5M8767_REG_BUCK4DVS2,
98 S5M8767_REG_BUCK4DVS3,
99 S5M8767_REG_BUCK4DVS4,
100 S5M8767_REG_BUCK4DVS5,
101 S5M8767_REG_BUCK4DVS6,
102 S5M8767_REG_BUCK4DVS7,
103 S5M8767_REG_BUCK4DVS8,
104 S5M8767_REG_BUCK5CTRL1,
105 S5M8767_REG_BUCK5CTRL2,
106 S5M8767_REG_BUCK5CTRL3,
107 S5M8767_REG_BUCK5CTRL4,
108 S5M8767_REG_BUCK5CTRL5,
109 S5M8767_REG_BUCK6CTRL1,
110 S5M8767_REG_BUCK6CTRL2,
111 S5M8767_REG_BUCK7CTRL1,
112 S5M8767_REG_BUCK7CTRL2,
113 S5M8767_REG_BUCK8CTRL1,
114 S5M8767_REG_BUCK8CTRL2,
115 S5M8767_REG_BUCK9CTRL1,
116 S5M8767_REG_BUCK9CTRL2,
117 S5M8767_REG_LDO1CTRL,
118 S5M8767_REG_LDO2_1CTRL,
119 S5M8767_REG_LDO2_2CTRL,
120 S5M8767_REG_LDO2_3CTRL,
121 S5M8767_REG_LDO2_4CTRL,
122 S5M8767_REG_LDO3CTRL,
123 S5M8767_REG_LDO4CTRL,
124 S5M8767_REG_LDO5CTRL,
125 S5M8767_REG_LDO6CTRL,
126 S5M8767_REG_LDO7CTRL,
127 S5M8767_REG_LDO8CTRL,
128 S5M8767_REG_LDO9CTRL,
129 S5M8767_REG_LDO10CTRL,
130 S5M8767_REG_LDO11CTRL,
131 S5M8767_REG_LDO12CTRL,
132 S5M8767_REG_LDO13CTRL,
133 S5M8767_REG_LDO14CTRL,
134 S5M8767_REG_LDO15CTRL,
135 S5M8767_REG_LDO16CTRL,
136 S5M8767_REG_LDO17CTRL,
137 S5M8767_REG_LDO18CTRL,
138 S5M8767_REG_LDO19CTRL,
139 S5M8767_REG_LDO20CTRL,
140 S5M8767_REG_LDO21CTRL,
141 S5M8767_REG_LDO22CTRL,
142 S5M8767_REG_LDO23CTRL,
143 S5M8767_REG_LDO24CTRL,
144 S5M8767_REG_LDO25CTRL,
145 S5M8767_REG_LDO26CTRL,
146 S5M8767_REG_LDO27CTRL,
147 S5M8767_REG_LDO28CTRL,
148};
149
150/* S5M8763 registers */
151enum s5m8763_reg {
152 S5M8763_REG_IRQ1,
153 S5M8763_REG_IRQ2,
154 S5M8763_REG_IRQ3,
155 S5M8763_REG_IRQ4,
156 S5M8763_REG_IRQM1,
157 S5M8763_REG_IRQM2,
158 S5M8763_REG_IRQM3,
159 S5M8763_REG_IRQM4,
160 S5M8763_REG_STATUS1,
161 S5M8763_REG_STATUS2,
162 S5M8763_REG_STATUSM1,
163 S5M8763_REG_STATUSM2,
164 S5M8763_REG_CHGR1,
165 S5M8763_REG_CHGR2,
166 S5M8763_REG_LDO_ACTIVE_DISCHARGE1,
167 S5M8763_REG_LDO_ACTIVE_DISCHARGE2,
168 S5M8763_REG_BUCK_ACTIVE_DISCHARGE3,
169 S5M8763_REG_ONOFF1,
170 S5M8763_REG_ONOFF2,
171 S5M8763_REG_ONOFF3,
172 S5M8763_REG_ONOFF4,
173 S5M8763_REG_BUCK1_VOLTAGE1,
174 S5M8763_REG_BUCK1_VOLTAGE2,
175 S5M8763_REG_BUCK1_VOLTAGE3,
176 S5M8763_REG_BUCK1_VOLTAGE4,
177 S5M8763_REG_BUCK2_VOLTAGE1,
178 S5M8763_REG_BUCK2_VOLTAGE2,
179 S5M8763_REG_BUCK3,
180 S5M8763_REG_BUCK4,
181 S5M8763_REG_LDO1_LDO2,
182 S5M8763_REG_LDO3,
183 S5M8763_REG_LDO4,
184 S5M8763_REG_LDO5,
185 S5M8763_REG_LDO6,
186 S5M8763_REG_LDO7,
187 S5M8763_REG_LDO7_LDO8,
188 S5M8763_REG_LDO9_LDO10,
189 S5M8763_REG_LDO11,
190 S5M8763_REG_LDO12,
191 S5M8763_REG_LDO13,
192 S5M8763_REG_LDO14,
193 S5M8763_REG_LDO15,
194 S5M8763_REG_LDO16,
195 S5M8763_REG_BKCHR,
196 S5M8763_REG_LBCNFG1,
197 S5M8763_REG_LBCNFG2,
198};
199
200enum s5m8767_irq {
201 S5M8767_IRQ_PWRR,
202 S5M8767_IRQ_PWRF,
203 S5M8767_IRQ_PWR1S,
204 S5M8767_IRQ_JIGR,
205 S5M8767_IRQ_JIGF,
206 S5M8767_IRQ_LOWBAT2,
207 S5M8767_IRQ_LOWBAT1,
208
209 S5M8767_IRQ_MRB,
210 S5M8767_IRQ_DVSOK2,
211 S5M8767_IRQ_DVSOK3,
212 S5M8767_IRQ_DVSOK4,
213
214 S5M8767_IRQ_RTC60S,
215 S5M8767_IRQ_RTCA1,
216 S5M8767_IRQ_RTCA2,
217 S5M8767_IRQ_SMPL,
218 S5M8767_IRQ_RTC1S,
219 S5M8767_IRQ_WTSR,
220
221 S5M8767_IRQ_NR,
222};
223
224#define S5M8767_IRQ_PWRR_MASK (1 << 0)
225#define S5M8767_IRQ_PWRF_MASK (1 << 1)
226#define S5M8767_IRQ_PWR1S_MASK (1 << 3)
227#define S5M8767_IRQ_JIGR_MASK (1 << 4)
228#define S5M8767_IRQ_JIGF_MASK (1 << 5)
229#define S5M8767_IRQ_LOWBAT2_MASK (1 << 6)
230#define S5M8767_IRQ_LOWBAT1_MASK (1 << 7)
231
232#define S5M8767_IRQ_MRB_MASK (1 << 2)
233#define S5M8767_IRQ_DVSOK2_MASK (1 << 3)
234#define S5M8767_IRQ_DVSOK3_MASK (1 << 4)
235#define S5M8767_IRQ_DVSOK4_MASK (1 << 5)
236
237#define S5M8767_IRQ_RTC60S_MASK (1 << 0)
238#define S5M8767_IRQ_RTCA1_MASK (1 << 1)
239#define S5M8767_IRQ_RTCA2_MASK (1 << 2)
240#define S5M8767_IRQ_SMPL_MASK (1 << 3)
241#define S5M8767_IRQ_RTC1S_MASK (1 << 4)
242#define S5M8767_IRQ_WTSR_MASK (1 << 5)
243
244enum s5m8763_irq {
245 S5M8763_IRQ_DCINF,
246 S5M8763_IRQ_DCINR,
247 S5M8763_IRQ_JIGF,
248 S5M8763_IRQ_JIGR,
249 S5M8763_IRQ_PWRONF,
250 S5M8763_IRQ_PWRONR,
251
252 S5M8763_IRQ_WTSREVNT,
253 S5M8763_IRQ_SMPLEVNT,
254 S5M8763_IRQ_ALARM1,
255 S5M8763_IRQ_ALARM0,
256
257 S5M8763_IRQ_ONKEY1S,
258 S5M8763_IRQ_TOPOFFR,
259 S5M8763_IRQ_DCINOVPR,
260 S5M8763_IRQ_CHGRSTF,
261 S5M8763_IRQ_DONER,
262 S5M8763_IRQ_CHGFAULT,
263
264 S5M8763_IRQ_LOBAT1,
265 S5M8763_IRQ_LOBAT2,
266
267 S5M8763_IRQ_NR,
268};
269
270#define S5M8763_IRQ_DCINF_MASK (1 << 2)
271#define S5M8763_IRQ_DCINR_MASK (1 << 3)
272#define S5M8763_IRQ_JIGF_MASK (1 << 4)
273#define S5M8763_IRQ_JIGR_MASK (1 << 5)
274#define S5M8763_IRQ_PWRONF_MASK (1 << 6)
275#define S5M8763_IRQ_PWRONR_MASK (1 << 7)
276
277#define S5M8763_IRQ_WTSREVNT_MASK (1 << 0)
278#define S5M8763_IRQ_SMPLEVNT_MASK (1 << 1)
279#define S5M8763_IRQ_ALARM1_MASK (1 << 2)
280#define S5M8763_IRQ_ALARM0_MASK (1 << 3)
281
282#define S5M8763_IRQ_ONKEY1S_MASK (1 << 0)
283#define S5M8763_IRQ_TOPOFFR_MASK (1 << 2)
284#define S5M8763_IRQ_DCINOVPR_MASK (1 << 3)
285#define S5M8763_IRQ_CHGRSTF_MASK (1 << 4)
286#define S5M8763_IRQ_DONER_MASK (1 << 5)
287#define S5M8763_IRQ_CHGFAULT_MASK (1 << 7)
288
289#define S5M8763_IRQ_LOBAT1_MASK (1 << 0)
290#define S5M8763_IRQ_LOBAT2_MASK (1 << 1)
291
292#define S5M8763_ENRAMP (1 << 4)
293
294/**
295 * struct s5m87xx_dev - s5m87xx master device for sub-drivers
296 * @dev: master device of the chip (can be used to access platform data)
297 * @i2c: i2c client private data for regulator
298 * @rtc: i2c client private data for rtc
299 * @iolock: mutex for serializing io access
300 * @irqlock: mutex for buslock
301 * @irq_base: base IRQ number for s5m87xx, required for IRQs
302 * @irq: generic IRQ number for s5m87xx
303 * @ono: power onoff IRQ number for s5m87xx
304 * @irq_masks_cur: currently active value
305 * @irq_masks_cache: cached hardware value
306 * @type: indicate which s5m87xx "variant" is used
307 */
308struct s5m87xx_dev {
309 struct device *dev;
310 struct regmap *regmap;
311 struct i2c_client *i2c;
312 struct i2c_client *rtc;
313 struct mutex iolock;
314 struct mutex irqlock;
315
316 int device_type;
317 int irq_base;
318 int irq;
319 int ono;
320 u8 irq_masks_cur[NUM_IRQ_REGS];
321 u8 irq_masks_cache[NUM_IRQ_REGS];
322 int type;
323 bool wakeup;
324};
325
326int s5m_irq_init(struct s5m87xx_dev *s5m87xx);
327void s5m_irq_exit(struct s5m87xx_dev *s5m87xx);
328int s5m_irq_resume(struct s5m87xx_dev *s5m87xx);
329
330extern int s5m_reg_read(struct s5m87xx_dev *s5m87xx, u8 reg, void *dest);
331extern int s5m_bulk_read(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf);
332extern int s5m_reg_write(struct s5m87xx_dev *s5m87xx, u8 reg, u8 value);
333extern int s5m_bulk_write(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf);
334extern int s5m_reg_update(struct s5m87xx_dev *s5m87xx, u8 reg, u8 val, u8 mask);
335
336struct s5m_platform_data {
337 struct s5m_regulator_data *regulators;
338 struct s5m_opmode_data *opmode;
339 int device_type;
340 int num_regulators;
341
342 int irq_base;
343 int (*cfg_pmic_irq)(void);
344
345 int ono;
346 bool wakeup;
347 bool buck_voltage_lock;
348
349 int buck_gpios[3];
350 int buck_ds[3];
351 int buck2_voltage[8];
352 bool buck2_gpiodvs;
353 int buck3_voltage[8];
354 bool buck3_gpiodvs;
355 int buck4_voltage[8];
356 bool buck4_gpiodvs;
357
358 int buck_set1;
359 int buck_set2;
360 int buck_set3;
361 int buck2_enable;
362 int buck3_enable;
363 int buck4_enable;
364 int buck_default_idx;
365 int buck2_default_idx;
366 int buck3_default_idx;
367 int buck4_default_idx;
368
369 int buck_ramp_delay;
370 bool buck2_ramp_enable;
371 bool buck3_ramp_enable;
372 bool buck4_ramp_enable;
373
374 int buck2_init;
375 int buck3_init;
376 int buck4_init;
377};
378
379#endif /* __LINUX_MFD_S5M_CORE_H */
diff --git a/include/linux/mfd/s5m87xx/s5m-pmic.h b/include/linux/mfd/s5m87xx/s5m-pmic.h
deleted file mode 100644
index 7c719f20f58a..000000000000
--- a/include/linux/mfd/s5m87xx/s5m-pmic.h
+++ /dev/null
@@ -1,129 +0,0 @@
1/* s5m87xx.h
2 *
3 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9*/
10
11#ifndef __LINUX_MFD_S5M_PMIC_H
12#define __LINUX_MFD_S5M_PMIC_H
13
14#include <linux/regulator/machine.h>
15
16/* S5M8767 regulator ids */
17enum s5m8767_regulators {
18 S5M8767_LDO1,
19 S5M8767_LDO2,
20 S5M8767_LDO3,
21 S5M8767_LDO4,
22 S5M8767_LDO5,
23 S5M8767_LDO6,
24 S5M8767_LDO7,
25 S5M8767_LDO8,
26 S5M8767_LDO9,
27 S5M8767_LDO10,
28 S5M8767_LDO11,
29 S5M8767_LDO12,
30 S5M8767_LDO13,
31 S5M8767_LDO14,
32 S5M8767_LDO15,
33 S5M8767_LDO16,
34 S5M8767_LDO17,
35 S5M8767_LDO18,
36 S5M8767_LDO19,
37 S5M8767_LDO20,
38 S5M8767_LDO21,
39 S5M8767_LDO22,
40 S5M8767_LDO23,
41 S5M8767_LDO24,
42 S5M8767_LDO25,
43 S5M8767_LDO26,
44 S5M8767_LDO27,
45 S5M8767_LDO28,
46 S5M8767_BUCK1,
47 S5M8767_BUCK2,
48 S5M8767_BUCK3,
49 S5M8767_BUCK4,
50 S5M8767_BUCK5,
51 S5M8767_BUCK6,
52 S5M8767_BUCK7,
53 S5M8767_BUCK8,
54 S5M8767_BUCK9,
55 S5M8767_AP_EN32KHZ,
56 S5M8767_CP_EN32KHZ,
57
58 S5M8767_REG_MAX,
59};
60
61#define S5M8767_ENCTRL_SHIFT 6
62
63/* S5M8763 regulator ids */
64enum s5m8763_regulators {
65 S5M8763_LDO1,
66 S5M8763_LDO2,
67 S5M8763_LDO3,
68 S5M8763_LDO4,
69 S5M8763_LDO5,
70 S5M8763_LDO6,
71 S5M8763_LDO7,
72 S5M8763_LDO8,
73 S5M8763_LDO9,
74 S5M8763_LDO10,
75 S5M8763_LDO11,
76 S5M8763_LDO12,
77 S5M8763_LDO13,
78 S5M8763_LDO14,
79 S5M8763_LDO15,
80 S5M8763_LDO16,
81 S5M8763_BUCK1,
82 S5M8763_BUCK2,
83 S5M8763_BUCK3,
84 S5M8763_BUCK4,
85 S5M8763_AP_EN32KHZ,
86 S5M8763_CP_EN32KHZ,
87 S5M8763_ENCHGVI,
88 S5M8763_ESAFEUSB1,
89 S5M8763_ESAFEUSB2,
90};
91
92/**
93 * s5m87xx_regulator_data - regulator data
94 * @id: regulator id
95 * @initdata: regulator init data (contraints, supplies, ...)
96 */
97struct s5m_regulator_data {
98 int id;
99 struct regulator_init_data *initdata;
100};
101
102/*
103 * s5m_opmode_data - regulator operation mode data
104 * @id: regulator id
105 * @mode: regulator operation mode
106 */
107struct s5m_opmode_data {
108 int id;
109 int mode;
110};
111
112/*
113 * s5m regulator operation mode
114 * S5M_OPMODE_OFF Regulator always OFF
115 * S5M_OPMODE_ON Regulator always ON
116 * S5M_OPMODE_LOWPOWER Regulator is on in low-power mode
117 * S5M_OPMODE_SUSPEND Regulator is changed by PWREN pin
118 * If PWREN is high, regulator is on
119 * If PWREN is low, regulator is off
120 */
121
122enum s5m_opmode {
123 S5M_OPMODE_OFF,
124 S5M_OPMODE_ON,
125 S5M_OPMODE_LOWPOWER,
126 S5M_OPMODE_SUSPEND,
127};
128
129#endif /* __LINUX_MFD_S5M_PMIC_H */
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
new file mode 100644
index 000000000000..b50c38f8bc48
--- /dev/null
+++ b/include/linux/mfd/samsung/core.h
@@ -0,0 +1,159 @@
1/*
2 * core.h
3 *
4 * copyright (c) 2011 Samsung Electronics Co., Ltd
5 * http://www.samsung.com
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#ifndef __LINUX_MFD_SEC_CORE_H
15#define __LINUX_MFD_SEC_CORE_H
16
17#define NUM_IRQ_REGS 4
18
19enum sec_device_type {
20 S5M8751X,
21 S5M8763X,
22 S5M8767X,
23 S2MPS11X,
24};
25
26/**
27 * struct sec_pmic_dev - s5m87xx master device for sub-drivers
28 * @dev: master device of the chip (can be used to access platform data)
29 * @i2c: i2c client private data for regulator
30 * @rtc: i2c client private data for rtc
31 * @iolock: mutex for serializing io access
32 * @irqlock: mutex for buslock
33 * @irq_base: base IRQ number for sec-pmic, required for IRQs
34 * @irq: generic IRQ number for s5m87xx
35 * @ono: power onoff IRQ number for s5m87xx
36 * @irq_masks_cur: currently active value
37 * @irq_masks_cache: cached hardware value
38 * @type: indicate which s5m87xx "variant" is used
39 */
40struct sec_pmic_dev {
41 struct device *dev;
42 struct regmap *regmap;
43 struct i2c_client *i2c;
44 struct i2c_client *rtc;
45 struct mutex iolock;
46 struct mutex irqlock;
47
48 int device_type;
49 int irq_base;
50 int irq;
51 struct regmap_irq_chip_data *irq_data;
52
53 int ono;
54 u8 irq_masks_cur[NUM_IRQ_REGS];
55 u8 irq_masks_cache[NUM_IRQ_REGS];
56 int type;
57 bool wakeup;
58};
59
60int sec_irq_init(struct sec_pmic_dev *sec_pmic);
61void sec_irq_exit(struct sec_pmic_dev *sec_pmic);
62int sec_irq_resume(struct sec_pmic_dev *sec_pmic);
63
64extern int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest);
65extern int sec_bulk_read(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf);
66extern int sec_reg_write(struct sec_pmic_dev *sec_pmic, u8 reg, u8 value);
67extern int sec_bulk_write(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf);
68extern int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask);
69
70struct sec_platform_data {
71 struct sec_regulator_data *regulators;
72 struct sec_opmode_data *opmode;
73 int device_type;
74 int num_regulators;
75
76 int irq_base;
77 int (*cfg_pmic_irq)(void);
78
79 int ono;
80 bool wakeup;
81 bool buck_voltage_lock;
82
83 int buck_gpios[3];
84 int buck_ds[3];
85 int buck2_voltage[8];
86 bool buck2_gpiodvs;
87 int buck3_voltage[8];
88 bool buck3_gpiodvs;
89 int buck4_voltage[8];
90 bool buck4_gpiodvs;
91
92 int buck_set1;
93 int buck_set2;
94 int buck_set3;
95 int buck2_enable;
96 int buck3_enable;
97 int buck4_enable;
98 int buck_default_idx;
99 int buck2_default_idx;
100 int buck3_default_idx;
101 int buck4_default_idx;
102
103 int buck_ramp_delay;
104
105 int buck2_ramp_delay;
106 int buck34_ramp_delay;
107 int buck5_ramp_delay;
108 int buck16_ramp_delay;
109 int buck7810_ramp_delay;
110 int buck9_ramp_delay;
111
112 bool buck2_ramp_enable;
113 bool buck3_ramp_enable;
114 bool buck4_ramp_enable;
115 bool buck6_ramp_enable;
116
117 int buck2_init;
118 int buck3_init;
119 int buck4_init;
120};
121
122/**
123 * sec_regulator_data - regulator data
124 * @id: regulator id
125 * @initdata: regulator init data (contraints, supplies, ...)
126 */
127struct sec_regulator_data {
128 int id;
129 struct regulator_init_data *initdata;
130};
131
132/*
133 * sec_opmode_data - regulator operation mode data
134 * @id: regulator id
135 * @mode: regulator operation mode
136 */
137struct sec_opmode_data {
138 int id;
139 int mode;
140};
141
142/*
143 * samsung regulator operation mode
144 * SEC_OPMODE_OFF Regulator always OFF
145 * SEC_OPMODE_ON Regulator always ON
146 * SEC_OPMODE_LOWPOWER Regulator is on in low-power mode
147 * SEC_OPMODE_SUSPEND Regulator is changed by PWREN pin
148 * If PWREN is high, regulator is on
149 * If PWREN is low, regulator is off
150 */
151
152enum sec_opmode {
153 SEC_OPMODE_OFF,
154 SEC_OPMODE_ON,
155 SEC_OPMODE_LOWPOWER,
156 SEC_OPMODE_SUSPEND,
157};
158
159#endif /* __LINUX_MFD_SEC_CORE_H */
diff --git a/include/linux/mfd/samsung/irq.h b/include/linux/mfd/samsung/irq.h
new file mode 100644
index 000000000000..d43b4f9e7fb2
--- /dev/null
+++ b/include/linux/mfd/samsung/irq.h
@@ -0,0 +1,152 @@
1/* irq.h
2 *
3 * Copyright (c) 2012 Samsung Electronics Co., Ltd
4 * http://www.samsung.com
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifndef __LINUX_MFD_SEC_IRQ_H
14#define __LINUX_MFD_SEC_IRQ_H
15
16enum s2mps11_irq {
17 S2MPS11_IRQ_PWRONF,
18 S2MPS11_IRQ_PWRONR,
19 S2MPS11_IRQ_JIGONBF,
20 S2MPS11_IRQ_JIGONBR,
21 S2MPS11_IRQ_ACOKBF,
22 S2MPS11_IRQ_ACOKBR,
23 S2MPS11_IRQ_PWRON1S,
24 S2MPS11_IRQ_MRB,
25
26 S2MPS11_IRQ_RTC60S,
27 S2MPS11_IRQ_RTCA1,
28 S2MPS11_IRQ_RTCA2,
29 S2MPS11_IRQ_SMPL,
30 S2MPS11_IRQ_RTC1S,
31 S2MPS11_IRQ_WTSR,
32
33 S2MPS11_IRQ_INT120C,
34 S2MPS11_IRQ_INT140C,
35
36 S2MPS11_IRQ_NR,
37};
38
39#define S2MPS11_IRQ_PWRONF_MASK (1 << 0)
40#define S2MPS11_IRQ_PWRONR_MASK (1 << 1)
41#define S2MPS11_IRQ_JIGONBF_MASK (1 << 2)
42#define S2MPS11_IRQ_JIGONBR_MASK (1 << 3)
43#define S2MPS11_IRQ_ACOKBF_MASK (1 << 4)
44#define S2MPS11_IRQ_ACOKBR_MASK (1 << 5)
45#define S2MPS11_IRQ_PWRON1S_MASK (1 << 6)
46#define S2MPS11_IRQ_MRB_MASK (1 << 7)
47
48#define S2MPS11_IRQ_RTC60S_MASK (1 << 0)
49#define S2MPS11_IRQ_RTCA1_MASK (1 << 1)
50#define S2MPS11_IRQ_RTCA2_MASK (1 << 2)
51#define S2MPS11_IRQ_SMPL_MASK (1 << 3)
52#define S2MPS11_IRQ_RTC1S_MASK (1 << 4)
53#define S2MPS11_IRQ_WTSR_MASK (1 << 5)
54
55#define S2MPS11_IRQ_INT120C_MASK (1 << 0)
56#define S2MPS11_IRQ_INT140C_MASK (1 << 1)
57
58enum s5m8767_irq {
59 S5M8767_IRQ_PWRR,
60 S5M8767_IRQ_PWRF,
61 S5M8767_IRQ_PWR1S,
62 S5M8767_IRQ_JIGR,
63 S5M8767_IRQ_JIGF,
64 S5M8767_IRQ_LOWBAT2,
65 S5M8767_IRQ_LOWBAT1,
66
67 S5M8767_IRQ_MRB,
68 S5M8767_IRQ_DVSOK2,
69 S5M8767_IRQ_DVSOK3,
70 S5M8767_IRQ_DVSOK4,
71
72 S5M8767_IRQ_RTC60S,
73 S5M8767_IRQ_RTCA1,
74 S5M8767_IRQ_RTCA2,
75 S5M8767_IRQ_SMPL,
76 S5M8767_IRQ_RTC1S,
77 S5M8767_IRQ_WTSR,
78
79 S5M8767_IRQ_NR,
80};
81
82#define S5M8767_IRQ_PWRR_MASK (1 << 0)
83#define S5M8767_IRQ_PWRF_MASK (1 << 1)
84#define S5M8767_IRQ_PWR1S_MASK (1 << 3)
85#define S5M8767_IRQ_JIGR_MASK (1 << 4)
86#define S5M8767_IRQ_JIGF_MASK (1 << 5)
87#define S5M8767_IRQ_LOWBAT2_MASK (1 << 6)
88#define S5M8767_IRQ_LOWBAT1_MASK (1 << 7)
89
90#define S5M8767_IRQ_MRB_MASK (1 << 2)
91#define S5M8767_IRQ_DVSOK2_MASK (1 << 3)
92#define S5M8767_IRQ_DVSOK3_MASK (1 << 4)
93#define S5M8767_IRQ_DVSOK4_MASK (1 << 5)
94
95#define S5M8767_IRQ_RTC60S_MASK (1 << 0)
96#define S5M8767_IRQ_RTCA1_MASK (1 << 1)
97#define S5M8767_IRQ_RTCA2_MASK (1 << 2)
98#define S5M8767_IRQ_SMPL_MASK (1 << 3)
99#define S5M8767_IRQ_RTC1S_MASK (1 << 4)
100#define S5M8767_IRQ_WTSR_MASK (1 << 5)
101
102enum s5m8763_irq {
103 S5M8763_IRQ_DCINF,
104 S5M8763_IRQ_DCINR,
105 S5M8763_IRQ_JIGF,
106 S5M8763_IRQ_JIGR,
107 S5M8763_IRQ_PWRONF,
108 S5M8763_IRQ_PWRONR,
109
110 S5M8763_IRQ_WTSREVNT,
111 S5M8763_IRQ_SMPLEVNT,
112 S5M8763_IRQ_ALARM1,
113 S5M8763_IRQ_ALARM0,
114
115 S5M8763_IRQ_ONKEY1S,
116 S5M8763_IRQ_TOPOFFR,
117 S5M8763_IRQ_DCINOVPR,
118 S5M8763_IRQ_CHGRSTF,
119 S5M8763_IRQ_DONER,
120 S5M8763_IRQ_CHGFAULT,
121
122 S5M8763_IRQ_LOBAT1,
123 S5M8763_IRQ_LOBAT2,
124
125 S5M8763_IRQ_NR,
126};
127
128#define S5M8763_IRQ_DCINF_MASK (1 << 2)
129#define S5M8763_IRQ_DCINR_MASK (1 << 3)
130#define S5M8763_IRQ_JIGF_MASK (1 << 4)
131#define S5M8763_IRQ_JIGR_MASK (1 << 5)
132#define S5M8763_IRQ_PWRONF_MASK (1 << 6)
133#define S5M8763_IRQ_PWRONR_MASK (1 << 7)
134
135#define S5M8763_IRQ_WTSREVNT_MASK (1 << 0)
136#define S5M8763_IRQ_SMPLEVNT_MASK (1 << 1)
137#define S5M8763_IRQ_ALARM1_MASK (1 << 2)
138#define S5M8763_IRQ_ALARM0_MASK (1 << 3)
139
140#define S5M8763_IRQ_ONKEY1S_MASK (1 << 0)
141#define S5M8763_IRQ_TOPOFFR_MASK (1 << 2)
142#define S5M8763_IRQ_DCINOVPR_MASK (1 << 3)
143#define S5M8763_IRQ_CHGRSTF_MASK (1 << 4)
144#define S5M8763_IRQ_DONER_MASK (1 << 5)
145#define S5M8763_IRQ_CHGFAULT_MASK (1 << 7)
146
147#define S5M8763_IRQ_LOBAT1_MASK (1 << 0)
148#define S5M8763_IRQ_LOBAT2_MASK (1 << 1)
149
150#define S5M8763_ENRAMP (1 << 4)
151
152#endif /* __LINUX_MFD_SEC_IRQ_H */
diff --git a/include/linux/mfd/s5m87xx/s5m-rtc.h b/include/linux/mfd/samsung/rtc.h
index 6ce8da264cec..71597e20cddb 100644
--- a/include/linux/mfd/s5m87xx/s5m-rtc.h
+++ b/include/linux/mfd/samsung/rtc.h
@@ -1,5 +1,4 @@
1/* 1/* rtc.h
2 * s5m-rtc.h
3 * 2 *
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd 3 * Copyright (c) 2011 Samsung Electronics Co., Ltd
5 * http://www.samsung.com 4 * http://www.samsung.com
@@ -11,39 +10,39 @@
11 * 10 *
12 */ 11 */
13 12
14#ifndef __LINUX_MFD_S5M_RTC_H 13#ifndef __LINUX_MFD_SEC_RTC_H
15#define __LINUX_MFD_S5M_RTC_H 14#define __LINUX_MFD_SEC_RTC_H
16 15
17enum s5m87xx_rtc_reg { 16enum sec_rtc_reg {
18 S5M87XX_RTC_SEC, 17 SEC_RTC_SEC,
19 S5M87XX_RTC_MIN, 18 SEC_RTC_MIN,
20 S5M87XX_RTC_HOUR, 19 SEC_RTC_HOUR,
21 S5M87XX_RTC_WEEKDAY, 20 SEC_RTC_WEEKDAY,
22 S5M87XX_RTC_DATE, 21 SEC_RTC_DATE,
23 S5M87XX_RTC_MONTH, 22 SEC_RTC_MONTH,
24 S5M87XX_RTC_YEAR1, 23 SEC_RTC_YEAR1,
25 S5M87XX_RTC_YEAR2, 24 SEC_RTC_YEAR2,
26 S5M87XX_ALARM0_SEC, 25 SEC_ALARM0_SEC,
27 S5M87XX_ALARM0_MIN, 26 SEC_ALARM0_MIN,
28 S5M87XX_ALARM0_HOUR, 27 SEC_ALARM0_HOUR,
29 S5M87XX_ALARM0_WEEKDAY, 28 SEC_ALARM0_WEEKDAY,
30 S5M87XX_ALARM0_DATE, 29 SEC_ALARM0_DATE,
31 S5M87XX_ALARM0_MONTH, 30 SEC_ALARM0_MONTH,
32 S5M87XX_ALARM0_YEAR1, 31 SEC_ALARM0_YEAR1,
33 S5M87XX_ALARM0_YEAR2, 32 SEC_ALARM0_YEAR2,
34 S5M87XX_ALARM1_SEC, 33 SEC_ALARM1_SEC,
35 S5M87XX_ALARM1_MIN, 34 SEC_ALARM1_MIN,
36 S5M87XX_ALARM1_HOUR, 35 SEC_ALARM1_HOUR,
37 S5M87XX_ALARM1_WEEKDAY, 36 SEC_ALARM1_WEEKDAY,
38 S5M87XX_ALARM1_DATE, 37 SEC_ALARM1_DATE,
39 S5M87XX_ALARM1_MONTH, 38 SEC_ALARM1_MONTH,
40 S5M87XX_ALARM1_YEAR1, 39 SEC_ALARM1_YEAR1,
41 S5M87XX_ALARM1_YEAR2, 40 SEC_ALARM1_YEAR2,
42 S5M87XX_ALARM0_CONF, 41 SEC_ALARM0_CONF,
43 S5M87XX_ALARM1_CONF, 42 SEC_ALARM1_CONF,
44 S5M87XX_RTC_STATUS, 43 SEC_RTC_STATUS,
45 S5M87XX_WTSR_SMPL_CNTL, 44 SEC_WTSR_SMPL_CNTL,
46 S5M87XX_RTC_UDR_CON, 45 SEC_RTC_UDR_CON,
47}; 46};
48 47
49#define RTC_I2C_ADDR (0x0C >> 1) 48#define RTC_I2C_ADDR (0x0C >> 1)
@@ -81,4 +80,4 @@ enum {
81 RTC_YEAR2, 80 RTC_YEAR2,
82}; 81};
83 82
84#endif /* __LINUX_MFD_S5M_RTC_H */ 83#endif /* __LINUX_MFD_SEC_RTC_H */
diff --git a/include/linux/mfd/samsung/s2mps11.h b/include/linux/mfd/samsung/s2mps11.h
new file mode 100644
index 000000000000..ad2252f239d7
--- /dev/null
+++ b/include/linux/mfd/samsung/s2mps11.h
@@ -0,0 +1,196 @@
1/*
2 * s2mps11.h
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd
5 * http://www.samsung.com
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#ifndef __LINUX_MFD_S2MPS11_H
15#define __LINUX_MFD_S2MPS11_H
16
17/* S2MPS11 registers */
18enum s2mps11_reg {
19 S2MPS11_REG_ID,
20 S2MPS11_REG_INT1,
21 S2MPS11_REG_INT2,
22 S2MPS11_REG_INT3,
23 S2MPS11_REG_INT1M,
24 S2MPS11_REG_INT2M,
25 S2MPS11_REG_INT3M,
26 S2MPS11_REG_ST1,
27 S2MPS11_REG_ST2,
28 S2MPS11_REG_OFFSRC,
29 S2MPS11_REG_PWRONSRC,
30 S2MPS11_REG_RTC_CTRL,
31 S2MPS11_REG_CTRL1,
32 S2MPS11_REG_ETC_TEST,
33 S2MPS11_REG_RSVD3,
34 S2MPS11_REG_BU_CHG,
35 S2MPS11_REG_RAMP,
36 S2MPS11_REG_RAMP_BUCK,
37 S2MPS11_REG_LDO1_8,
38 S2MPS11_REG_LDO9_16,
39 S2MPS11_REG_LDO17_24,
40 S2MPS11_REG_LDO25_32,
41 S2MPS11_REG_LDO33_38,
42 S2MPS11_REG_LDO1_8_1,
43 S2MPS11_REG_LDO9_16_1,
44 S2MPS11_REG_LDO17_24_1,
45 S2MPS11_REG_LDO25_32_1,
46 S2MPS11_REG_LDO33_38_1,
47 S2MPS11_REG_OTP_ADRL,
48 S2MPS11_REG_OTP_ADRH,
49 S2MPS11_REG_OTP_DATA,
50 S2MPS11_REG_MON1SEL,
51 S2MPS11_REG_MON2SEL,
52 S2MPS11_REG_LEE,
53 S2MPS11_REG_RSVD_NO,
54 S2MPS11_REG_UVLO,
55 S2MPS11_REG_LEE_NO,
56 S2MPS11_REG_B1CTRL1,
57 S2MPS11_REG_B1CTRL2,
58 S2MPS11_REG_B2CTRL1,
59 S2MPS11_REG_B2CTRL2,
60 S2MPS11_REG_B3CTRL1,
61 S2MPS11_REG_B3CTRL2,
62 S2MPS11_REG_B4CTRL1,
63 S2MPS11_REG_B4CTRL2,
64 S2MPS11_REG_B5CTRL1,
65 S2MPS11_REG_BUCK5_SW,
66 S2MPS11_REG_B5CTRL2,
67 S2MPS11_REG_B5CTRL3,
68 S2MPS11_REG_B5CTRL4,
69 S2MPS11_REG_B5CTRL5,
70 S2MPS11_REG_B6CTRL1,
71 S2MPS11_REG_B6CTRL2,
72 S2MPS11_REG_B7CTRL1,
73 S2MPS11_REG_B7CTRL2,
74 S2MPS11_REG_B8CTRL1,
75 S2MPS11_REG_B8CTRL2,
76 S2MPS11_REG_B9CTRL1,
77 S2MPS11_REG_B9CTRL2,
78 S2MPS11_REG_B10CTRL1,
79 S2MPS11_REG_B10CTRL2,
80 S2MPS11_REG_L1CTRL,
81 S2MPS11_REG_L2CTRL,
82 S2MPS11_REG_L3CTRL,
83 S2MPS11_REG_L4CTRL,
84 S2MPS11_REG_L5CTRL,
85 S2MPS11_REG_L6CTRL,
86 S2MPS11_REG_L7CTRL,
87 S2MPS11_REG_L8CTRL,
88 S2MPS11_REG_L9CTRL,
89 S2MPS11_REG_L10CTRL,
90 S2MPS11_REG_L11CTRL,
91 S2MPS11_REG_L12CTRL,
92 S2MPS11_REG_L13CTRL,
93 S2MPS11_REG_L14CTRL,
94 S2MPS11_REG_L15CTRL,
95 S2MPS11_REG_L16CTRL,
96 S2MPS11_REG_L17CTRL,
97 S2MPS11_REG_L18CTRL,
98 S2MPS11_REG_L19CTRL,
99 S2MPS11_REG_L20CTRL,
100 S2MPS11_REG_L21CTRL,
101 S2MPS11_REG_L22CTRL,
102 S2MPS11_REG_L23CTRL,
103 S2MPS11_REG_L24CTRL,
104 S2MPS11_REG_L25CTRL,
105 S2MPS11_REG_L26CTRL,
106 S2MPS11_REG_L27CTRL,
107 S2MPS11_REG_L28CTRL,
108 S2MPS11_REG_L29CTRL,
109 S2MPS11_REG_L30CTRL,
110 S2MPS11_REG_L31CTRL,
111 S2MPS11_REG_L32CTRL,
112 S2MPS11_REG_L33CTRL,
113 S2MPS11_REG_L34CTRL,
114 S2MPS11_REG_L35CTRL,
115 S2MPS11_REG_L36CTRL,
116 S2MPS11_REG_L37CTRL,
117 S2MPS11_REG_L38CTRL,
118};
119
120/* S2MPS11 regulator ids */
121enum s2mps11_regulators {
122 S2MPS11_LDO1,
123 S2MPS11_LDO2,
124 S2MPS11_LDO3,
125 S2MPS11_LDO4,
126 S2MPS11_LDO5,
127 S2MPS11_LDO6,
128 S2MPS11_LDO7,
129 S2MPS11_LDO8,
130 S2MPS11_LDO9,
131 S2MPS11_LDO10,
132 S2MPS11_LDO11,
133 S2MPS11_LDO12,
134 S2MPS11_LDO13,
135 S2MPS11_LDO14,
136 S2MPS11_LDO15,
137 S2MPS11_LDO16,
138 S2MPS11_LDO17,
139 S2MPS11_LDO18,
140 S2MPS11_LDO19,
141 S2MPS11_LDO20,
142 S2MPS11_LDO21,
143 S2MPS11_LDO22,
144 S2MPS11_LDO23,
145 S2MPS11_LDO24,
146 S2MPS11_LDO25,
147 S2MPS11_LDO26,
148 S2MPS11_LDO27,
149 S2MPS11_LDO28,
150 S2MPS11_LDO29,
151 S2MPS11_LDO30,
152 S2MPS11_LDO31,
153 S2MPS11_LDO32,
154 S2MPS11_LDO33,
155 S2MPS11_LDO34,
156 S2MPS11_LDO35,
157 S2MPS11_LDO36,
158 S2MPS11_LDO37,
159 S2MPS11_LDO38,
160 S2MPS11_BUCK1,
161 S2MPS11_BUCK2,
162 S2MPS11_BUCK3,
163 S2MPS11_BUCK4,
164 S2MPS11_BUCK5,
165 S2MPS11_BUCK6,
166 S2MPS11_BUCK7,
167 S2MPS11_BUCK8,
168 S2MPS11_BUCK9,
169 S2MPS11_BUCK10,
170 S2MPS11_AP_EN32KHZ,
171 S2MPS11_CP_EN32KHZ,
172 S2MPS11_BT_EN32KHZ,
173
174 S2MPS11_REG_MAX,
175};
176
177#define S2MPS11_BUCK_MIN1 600000
178#define S2MPS11_BUCK_MIN2 750000
179#define S2MPS11_BUCK_MIN3 3000000
180#define S2MPS11_LDO_MIN 800000
181#define S2MPS11_BUCK_STEP1 6250
182#define S2MPS11_BUCK_STEP2 12500
183#define S2MPS11_BUCK_STEP3 25000
184#define S2MPS11_LDO_STEP1 50000
185#define S2MPS11_LDO_STEP2 25000
186#define S2MPS11_LDO_VSEL_MASK 0x3F
187#define S2MPS11_BUCK_VSEL_MASK 0xFF
188#define S2MPS11_ENABLE_MASK (0x03 << S2MPS11_ENABLE_SHIFT)
189#define S2MPS11_ENABLE_SHIFT 0x06
190#define S2MPS11_LDO_N_VOLTAGES (S2MPS11_LDO_VSEL_MASK + 1)
191#define S2MPS11_BUCK_N_VOLTAGES (S2MPS11_BUCK_VSEL_MASK + 1)
192
193#define S2MPS11_PMIC_EN_SHIFT 6
194#define S2MPS11_REGULATOR_MAX (S2MPS11_REG_MAX - 3)
195
196#endif /* __LINUX_MFD_S2MPS11_H */
diff --git a/include/linux/mfd/samsung/s5m8763.h b/include/linux/mfd/samsung/s5m8763.h
new file mode 100644
index 000000000000..e025418e5589
--- /dev/null
+++ b/include/linux/mfd/samsung/s5m8763.h
@@ -0,0 +1,96 @@
1/* s5m8763.h
2 *
3 * Copyright (c) 2011 Samsung Electronics Co., Ltd
4 * http://www.samsung.com
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifndef __LINUX_MFD_S5M8763_H
14#define __LINUX_MFD_S5M8763_H
15
16/* S5M8763 registers */
17enum s5m8763_reg {
18 S5M8763_REG_IRQ1,
19 S5M8763_REG_IRQ2,
20 S5M8763_REG_IRQ3,
21 S5M8763_REG_IRQ4,
22 S5M8763_REG_IRQM1,
23 S5M8763_REG_IRQM2,
24 S5M8763_REG_IRQM3,
25 S5M8763_REG_IRQM4,
26 S5M8763_REG_STATUS1,
27 S5M8763_REG_STATUS2,
28 S5M8763_REG_STATUSM1,
29 S5M8763_REG_STATUSM2,
30 S5M8763_REG_CHGR1,
31 S5M8763_REG_CHGR2,
32 S5M8763_REG_LDO_ACTIVE_DISCHARGE1,
33 S5M8763_REG_LDO_ACTIVE_DISCHARGE2,
34 S5M8763_REG_BUCK_ACTIVE_DISCHARGE3,
35 S5M8763_REG_ONOFF1,
36 S5M8763_REG_ONOFF2,
37 S5M8763_REG_ONOFF3,
38 S5M8763_REG_ONOFF4,
39 S5M8763_REG_BUCK1_VOLTAGE1,
40 S5M8763_REG_BUCK1_VOLTAGE2,
41 S5M8763_REG_BUCK1_VOLTAGE3,
42 S5M8763_REG_BUCK1_VOLTAGE4,
43 S5M8763_REG_BUCK2_VOLTAGE1,
44 S5M8763_REG_BUCK2_VOLTAGE2,
45 S5M8763_REG_BUCK3,
46 S5M8763_REG_BUCK4,
47 S5M8763_REG_LDO1_LDO2,
48 S5M8763_REG_LDO3,
49 S5M8763_REG_LDO4,
50 S5M8763_REG_LDO5,
51 S5M8763_REG_LDO6,
52 S5M8763_REG_LDO7,
53 S5M8763_REG_LDO7_LDO8,
54 S5M8763_REG_LDO9_LDO10,
55 S5M8763_REG_LDO11,
56 S5M8763_REG_LDO12,
57 S5M8763_REG_LDO13,
58 S5M8763_REG_LDO14,
59 S5M8763_REG_LDO15,
60 S5M8763_REG_LDO16,
61 S5M8763_REG_BKCHR,
62 S5M8763_REG_LBCNFG1,
63 S5M8763_REG_LBCNFG2,
64};
65
66/* S5M8763 regulator ids */
67enum s5m8763_regulators {
68 S5M8763_LDO1,
69 S5M8763_LDO2,
70 S5M8763_LDO3,
71 S5M8763_LDO4,
72 S5M8763_LDO5,
73 S5M8763_LDO6,
74 S5M8763_LDO7,
75 S5M8763_LDO8,
76 S5M8763_LDO9,
77 S5M8763_LDO10,
78 S5M8763_LDO11,
79 S5M8763_LDO12,
80 S5M8763_LDO13,
81 S5M8763_LDO14,
82 S5M8763_LDO15,
83 S5M8763_LDO16,
84 S5M8763_BUCK1,
85 S5M8763_BUCK2,
86 S5M8763_BUCK3,
87 S5M8763_BUCK4,
88 S5M8763_AP_EN32KHZ,
89 S5M8763_CP_EN32KHZ,
90 S5M8763_ENCHGVI,
91 S5M8763_ESAFEUSB1,
92 S5M8763_ESAFEUSB2,
93};
94
95#define S5M8763_ENRAMP (1 << 4)
96#endif /* __LINUX_MFD_S5M8763_H */
diff --git a/include/linux/mfd/samsung/s5m8767.h b/include/linux/mfd/samsung/s5m8767.h
new file mode 100644
index 000000000000..306a95fc558c
--- /dev/null
+++ b/include/linux/mfd/samsung/s5m8767.h
@@ -0,0 +1,188 @@
1/* s5m8767.h
2 *
3 * Copyright (c) 2011 Samsung Electronics Co., Ltd
4 * http://www.samsung.com
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifndef __LINUX_MFD_S5M8767_H
14#define __LINUX_MFD_S5M8767_H
15
16/* S5M8767 registers */
17enum s5m8767_reg {
18 S5M8767_REG_ID,
19 S5M8767_REG_INT1,
20 S5M8767_REG_INT2,
21 S5M8767_REG_INT3,
22 S5M8767_REG_INT1M,
23 S5M8767_REG_INT2M,
24 S5M8767_REG_INT3M,
25 S5M8767_REG_STATUS1,
26 S5M8767_REG_STATUS2,
27 S5M8767_REG_STATUS3,
28 S5M8767_REG_CTRL1,
29 S5M8767_REG_CTRL2,
30 S5M8767_REG_LOWBAT1,
31 S5M8767_REG_LOWBAT2,
32 S5M8767_REG_BUCHG,
33 S5M8767_REG_DVSRAMP,
34 S5M8767_REG_DVSTIMER2 = 0x10,
35 S5M8767_REG_DVSTIMER3,
36 S5M8767_REG_DVSTIMER4,
37 S5M8767_REG_LDO1,
38 S5M8767_REG_LDO2,
39 S5M8767_REG_LDO3,
40 S5M8767_REG_LDO4,
41 S5M8767_REG_LDO5,
42 S5M8767_REG_LDO6,
43 S5M8767_REG_LDO7,
44 S5M8767_REG_LDO8,
45 S5M8767_REG_LDO9,
46 S5M8767_REG_LDO10,
47 S5M8767_REG_LDO11,
48 S5M8767_REG_LDO12,
49 S5M8767_REG_LDO13,
50 S5M8767_REG_LDO14 = 0x20,
51 S5M8767_REG_LDO15,
52 S5M8767_REG_LDO16,
53 S5M8767_REG_LDO17,
54 S5M8767_REG_LDO18,
55 S5M8767_REG_LDO19,
56 S5M8767_REG_LDO20,
57 S5M8767_REG_LDO21,
58 S5M8767_REG_LDO22,
59 S5M8767_REG_LDO23,
60 S5M8767_REG_LDO24,
61 S5M8767_REG_LDO25,
62 S5M8767_REG_LDO26,
63 S5M8767_REG_LDO27,
64 S5M8767_REG_LDO28,
65 S5M8767_REG_UVLO = 0x31,
66 S5M8767_REG_BUCK1CTRL1,
67 S5M8767_REG_BUCK1CTRL2,
68 S5M8767_REG_BUCK2CTRL,
69 S5M8767_REG_BUCK2DVS1,
70 S5M8767_REG_BUCK2DVS2,
71 S5M8767_REG_BUCK2DVS3,
72 S5M8767_REG_BUCK2DVS4,
73 S5M8767_REG_BUCK2DVS5,
74 S5M8767_REG_BUCK2DVS6,
75 S5M8767_REG_BUCK2DVS7,
76 S5M8767_REG_BUCK2DVS8,
77 S5M8767_REG_BUCK3CTRL,
78 S5M8767_REG_BUCK3DVS1,
79 S5M8767_REG_BUCK3DVS2,
80 S5M8767_REG_BUCK3DVS3,
81 S5M8767_REG_BUCK3DVS4,
82 S5M8767_REG_BUCK3DVS5,
83 S5M8767_REG_BUCK3DVS6,
84 S5M8767_REG_BUCK3DVS7,
85 S5M8767_REG_BUCK3DVS8,
86 S5M8767_REG_BUCK4CTRL,
87 S5M8767_REG_BUCK4DVS1,
88 S5M8767_REG_BUCK4DVS2,
89 S5M8767_REG_BUCK4DVS3,
90 S5M8767_REG_BUCK4DVS4,
91 S5M8767_REG_BUCK4DVS5,
92 S5M8767_REG_BUCK4DVS6,
93 S5M8767_REG_BUCK4DVS7,
94 S5M8767_REG_BUCK4DVS8,
95 S5M8767_REG_BUCK5CTRL1,
96 S5M8767_REG_BUCK5CTRL2,
97 S5M8767_REG_BUCK5CTRL3,
98 S5M8767_REG_BUCK5CTRL4,
99 S5M8767_REG_BUCK5CTRL5,
100 S5M8767_REG_BUCK6CTRL1,
101 S5M8767_REG_BUCK6CTRL2,
102 S5M8767_REG_BUCK7CTRL1,
103 S5M8767_REG_BUCK7CTRL2,
104 S5M8767_REG_BUCK8CTRL1,
105 S5M8767_REG_BUCK8CTRL2,
106 S5M8767_REG_BUCK9CTRL1,
107 S5M8767_REG_BUCK9CTRL2,
108 S5M8767_REG_LDO1CTRL,
109 S5M8767_REG_LDO2_1CTRL,
110 S5M8767_REG_LDO2_2CTRL,
111 S5M8767_REG_LDO2_3CTRL,
112 S5M8767_REG_LDO2_4CTRL,
113 S5M8767_REG_LDO3CTRL,
114 S5M8767_REG_LDO4CTRL,
115 S5M8767_REG_LDO5CTRL,
116 S5M8767_REG_LDO6CTRL,
117 S5M8767_REG_LDO7CTRL,
118 S5M8767_REG_LDO8CTRL,
119 S5M8767_REG_LDO9CTRL,
120 S5M8767_REG_LDO10CTRL,
121 S5M8767_REG_LDO11CTRL,
122 S5M8767_REG_LDO12CTRL,
123 S5M8767_REG_LDO13CTRL,
124 S5M8767_REG_LDO14CTRL,
125 S5M8767_REG_LDO15CTRL,
126 S5M8767_REG_LDO16CTRL,
127 S5M8767_REG_LDO17CTRL,
128 S5M8767_REG_LDO18CTRL,
129 S5M8767_REG_LDO19CTRL,
130 S5M8767_REG_LDO20CTRL,
131 S5M8767_REG_LDO21CTRL,
132 S5M8767_REG_LDO22CTRL,
133 S5M8767_REG_LDO23CTRL,
134 S5M8767_REG_LDO24CTRL,
135 S5M8767_REG_LDO25CTRL,
136 S5M8767_REG_LDO26CTRL,
137 S5M8767_REG_LDO27CTRL,
138 S5M8767_REG_LDO28CTRL,
139};
140
141/* S5M8767 regulator ids */
142enum s5m8767_regulators {
143 S5M8767_LDO1,
144 S5M8767_LDO2,
145 S5M8767_LDO3,
146 S5M8767_LDO4,
147 S5M8767_LDO5,
148 S5M8767_LDO6,
149 S5M8767_LDO7,
150 S5M8767_LDO8,
151 S5M8767_LDO9,
152 S5M8767_LDO10,
153 S5M8767_LDO11,
154 S5M8767_LDO12,
155 S5M8767_LDO13,
156 S5M8767_LDO14,
157 S5M8767_LDO15,
158 S5M8767_LDO16,
159 S5M8767_LDO17,
160 S5M8767_LDO18,
161 S5M8767_LDO19,
162 S5M8767_LDO20,
163 S5M8767_LDO21,
164 S5M8767_LDO22,
165 S5M8767_LDO23,
166 S5M8767_LDO24,
167 S5M8767_LDO25,
168 S5M8767_LDO26,
169 S5M8767_LDO27,
170 S5M8767_LDO28,
171 S5M8767_BUCK1,
172 S5M8767_BUCK2,
173 S5M8767_BUCK3,
174 S5M8767_BUCK4,
175 S5M8767_BUCK5,
176 S5M8767_BUCK6,
177 S5M8767_BUCK7,
178 S5M8767_BUCK8,
179 S5M8767_BUCK9,
180 S5M8767_AP_EN32KHZ,
181 S5M8767_CP_EN32KHZ,
182
183 S5M8767_REG_MAX,
184};
185
186#define S5M8767_ENCTRL_SHIFT 6
187
188#endif /* __LINUX_MFD_S5M8767_H */
diff --git a/include/linux/mfd/tps65910.h b/include/linux/mfd/tps65910.h
index 6c4c478e21a4..9bf8767818b4 100644
--- a/include/linux/mfd/tps65910.h
+++ b/include/linux/mfd/tps65910.h
@@ -807,6 +807,7 @@ struct tps65910_board {
807 int irq_base; 807 int irq_base;
808 int vmbch_threshold; 808 int vmbch_threshold;
809 int vmbch2_threshold; 809 int vmbch2_threshold;
810 bool en_ck32k_xtal;
810 bool en_dev_slp; 811 bool en_dev_slp;
811 struct tps65910_sleep_keepon_data *slp_keepon; 812 struct tps65910_sleep_keepon_data *slp_keepon;
812 bool en_gpio_sleep[TPS6591X_MAX_NUM_GPIO]; 813 bool en_gpio_sleep[TPS6591X_MAX_NUM_GPIO];
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index 6659487c31e7..eaad49f7c130 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -161,8 +161,9 @@
161#define TWL6040_CELLS 2 161#define TWL6040_CELLS 2
162 162
163#define TWL6040_REV_ES1_0 0x00 163#define TWL6040_REV_ES1_0 0x00
164#define TWL6040_REV_ES1_1 0x01 164#define TWL6040_REV_ES1_1 0x01 /* Rev ES1.1 and ES1.2 */
165#define TWL6040_REV_ES1_2 0x02 165#define TWL6040_REV_ES1_3 0x02
166#define TWL6041_REV_ES2_0 0x10
166 167
167#define TWL6040_IRQ_TH 0 168#define TWL6040_IRQ_TH 0
168#define TWL6040_IRQ_PLUG 1 169#define TWL6040_IRQ_PLUG 1
@@ -206,7 +207,6 @@ struct twl6040 {
206 struct regmap *regmap; 207 struct regmap *regmap;
207 struct regulator_bulk_data supplies[2]; /* supplies for vio, v2v1 */ 208 struct regulator_bulk_data supplies[2]; /* supplies for vio, v2v1 */
208 struct mutex mutex; 209 struct mutex mutex;
209 struct mutex io_mutex;
210 struct mutex irq_mutex; 210 struct mutex irq_mutex;
211 struct mfd_cell cells[TWL6040_CELLS]; 211 struct mfd_cell cells[TWL6040_CELLS];
212 struct completion ready; 212 struct completion ready;
diff --git a/include/linux/mfd/wm8350/core.h b/include/linux/mfd/wm8350/core.h
index 9192b6404a73..509481d9cf19 100644
--- a/include/linux/mfd/wm8350/core.h
+++ b/include/linux/mfd/wm8350/core.h
@@ -17,6 +17,7 @@
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/completion.h> 19#include <linux/completion.h>
20#include <linux/regmap.h>
20 21
21#include <linux/mfd/wm8350/audio.h> 22#include <linux/mfd/wm8350/audio.h>
22#include <linux/mfd/wm8350/gpio.h> 23#include <linux/mfd/wm8350/gpio.h>
@@ -66,6 +67,9 @@
66 67
67#define WM8350_MAX_REGISTER 0xFF 68#define WM8350_MAX_REGISTER 0xFF
68 69
70#define WM8350_UNLOCK_KEY 0x0013
71#define WM8350_LOCK_KEY 0x0000
72
69/* 73/*
70 * Field Definitions. 74 * Field Definitions.
71 */ 75 */
@@ -582,27 +586,9 @@
582 586
583#define WM8350_NUM_IRQ_REGS 7 587#define WM8350_NUM_IRQ_REGS 7
584 588
585struct wm8350_reg_access { 589extern const struct regmap_config wm8350_regmap;
586 u16 readable; /* Mask of readable bits */
587 u16 writable; /* Mask of writable bits */
588 u16 vol; /* Mask of volatile bits */
589};
590extern const struct wm8350_reg_access wm8350_reg_io_map[];
591extern const u16 wm8350_mode0_defaults[];
592extern const u16 wm8350_mode1_defaults[];
593extern const u16 wm8350_mode2_defaults[];
594extern const u16 wm8350_mode3_defaults[];
595extern const u16 wm8351_mode0_defaults[];
596extern const u16 wm8351_mode1_defaults[];
597extern const u16 wm8351_mode2_defaults[];
598extern const u16 wm8351_mode3_defaults[];
599extern const u16 wm8352_mode0_defaults[];
600extern const u16 wm8352_mode1_defaults[];
601extern const u16 wm8352_mode2_defaults[];
602extern const u16 wm8352_mode3_defaults[];
603 590
604struct wm8350; 591struct wm8350;
605struct regmap;
606 592
607struct wm8350_hwmon { 593struct wm8350_hwmon {
608 struct platform_device *pdev; 594 struct platform_device *pdev;
@@ -614,7 +600,7 @@ struct wm8350 {
614 600
615 /* device IO */ 601 /* device IO */
616 struct regmap *regmap; 602 struct regmap *regmap;
617 u16 *reg_cache; 603 bool unlocked;
618 604
619 struct mutex auxadc_mutex; 605 struct mutex auxadc_mutex;
620 struct completion auxadc_done; 606 struct completion auxadc_done;
diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h
index 893267bb6229..f0361c031927 100644
--- a/include/linux/mfd/wm8994/pdata.h
+++ b/include/linux/mfd/wm8994/pdata.h
@@ -141,6 +141,7 @@ struct wm8994_pdata {
141 struct wm8994_ldo_pdata ldo[WM8994_NUM_LDO]; 141 struct wm8994_ldo_pdata ldo[WM8994_NUM_LDO];
142 142
143 int irq_base; /** Base IRQ number for WM8994, required for IRQs */ 143 int irq_base; /** Base IRQ number for WM8994, required for IRQs */
144 unsigned long irq_flags; /** user irq flags */
144 145
145 int num_drc_cfgs; 146 int num_drc_cfgs;
146 struct wm8994_drc_cfg *drc_cfgs; 147 struct wm8994_drc_cfg *drc_cfgs;
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 704a626d94a0..074eb98fe15d 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -53,7 +53,7 @@ struct page {
53 struct { 53 struct {
54 union { 54 union {
55 pgoff_t index; /* Our offset within mapping. */ 55 pgoff_t index; /* Our offset within mapping. */
56 void *freelist; /* slub first free object */ 56 void *freelist; /* slub/slob first free object */
57 }; 57 };
58 58
59 union { 59 union {
@@ -91,11 +91,12 @@ struct page {
91 */ 91 */
92 atomic_t _mapcount; 92 atomic_t _mapcount;
93 93
94 struct { 94 struct { /* SLUB */
95 unsigned inuse:16; 95 unsigned inuse:16;
96 unsigned objects:15; 96 unsigned objects:15;
97 unsigned frozen:1; 97 unsigned frozen:1;
98 }; 98 };
99 int units; /* SLOB */
99 }; 100 };
100 atomic_t _count; /* Usage count, see below. */ 101 atomic_t _count; /* Usage count, see below. */
101 }; 102 };
@@ -117,6 +118,12 @@ struct page {
117 short int pobjects; 118 short int pobjects;
118#endif 119#endif
119 }; 120 };
121
122 struct list_head list; /* slobs list of pages */
123 struct { /* slab fields */
124 struct kmem_cache *slab_cache;
125 struct slab *slab_page;
126 };
120 }; 127 };
121 128
122 /* Remainder is not double word aligned */ 129 /* Remainder is not double word aligned */
diff --git a/include/linux/of.h b/include/linux/of.h
index 0e9cf9eec085..42c2a58328c1 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -386,6 +386,13 @@ static inline int of_property_read_u64(const struct device_node *np,
386 return -ENOSYS; 386 return -ENOSYS;
387} 387}
388 388
389static inline int of_property_match_string(struct device_node *np,
390 const char *propname,
391 const char *string)
392{
393 return -ENOSYS;
394}
395
389static inline struct device_node *of_parse_phandle(struct device_node *np, 396static inline struct device_node *of_parse_phandle(struct device_node *np,
390 const char *phandle_name, 397 const char *phandle_name,
391 int index) 398 int index)
@@ -393,6 +400,15 @@ static inline struct device_node *of_parse_phandle(struct device_node *np,
393 return NULL; 400 return NULL;
394} 401}
395 402
403static inline int of_parse_phandle_with_args(struct device_node *np,
404 const char *list_name,
405 const char *cells_name,
406 int index,
407 struct of_phandle_args *out_args)
408{
409 return -ENOSYS;
410}
411
396static inline int of_alias_get_id(struct device_node *np, const char *stem) 412static inline int of_alias_get_id(struct device_node *np, const char *stem)
397{ 413{
398 return -ENOSYS; 414 return -ENOSYS;
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 7c775751392c..21d076c5089e 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -1,7 +1,10 @@
1#ifndef __LINUX_PWM_H 1#ifndef __LINUX_PWM_H
2#define __LINUX_PWM_H 2#define __LINUX_PWM_H
3 3
4#include <linux/of.h>
5
4struct pwm_device; 6struct pwm_device;
7struct seq_file;
5 8
6/* 9/*
7 * pwm_request - request a PWM device 10 * pwm_request - request a PWM device
@@ -28,4 +31,118 @@ int pwm_enable(struct pwm_device *pwm);
28 */ 31 */
29void pwm_disable(struct pwm_device *pwm); 32void pwm_disable(struct pwm_device *pwm);
30 33
34#ifdef CONFIG_PWM
35struct pwm_chip;
36
37enum {
38 PWMF_REQUESTED = 1 << 0,
39 PWMF_ENABLED = 1 << 1,
40};
41
42struct pwm_device {
43 const char *label;
44 unsigned long flags;
45 unsigned int hwpwm;
46 unsigned int pwm;
47 struct pwm_chip *chip;
48 void *chip_data;
49
50 unsigned int period; /* in nanoseconds */
51};
52
53static inline void pwm_set_period(struct pwm_device *pwm, unsigned int period)
54{
55 if (pwm)
56 pwm->period = period;
57}
58
59static inline unsigned int pwm_get_period(struct pwm_device *pwm)
60{
61 return pwm ? pwm->period : 0;
62}
63
64/**
65 * struct pwm_ops - PWM controller operations
66 * @request: optional hook for requesting a PWM
67 * @free: optional hook for freeing a PWM
68 * @config: configure duty cycles and period length for this PWM
69 * @enable: enable PWM output toggling
70 * @disable: disable PWM output toggling
71 * @dbg_show: optional routine to show contents in debugfs
72 * @owner: helps prevent removal of modules exporting active PWMs
73 */
74struct pwm_ops {
75 int (*request)(struct pwm_chip *chip,
76 struct pwm_device *pwm);
77 void (*free)(struct pwm_chip *chip,
78 struct pwm_device *pwm);
79 int (*config)(struct pwm_chip *chip,
80 struct pwm_device *pwm,
81 int duty_ns, int period_ns);
82 int (*enable)(struct pwm_chip *chip,
83 struct pwm_device *pwm);
84 void (*disable)(struct pwm_chip *chip,
85 struct pwm_device *pwm);
86#ifdef CONFIG_DEBUG_FS
87 void (*dbg_show)(struct pwm_chip *chip,
88 struct seq_file *s);
89#endif
90 struct module *owner;
91};
92
93/**
94 * struct pwm_chip - abstract a PWM controller
95 * @dev: device providing the PWMs
96 * @list: list node for internal use
97 * @ops: callbacks for this PWM controller
98 * @base: number of first PWM controlled by this chip
99 * @npwm: number of PWMs controlled by this chip
100 * @pwms: array of PWM devices allocated by the framework
101 */
102struct pwm_chip {
103 struct device *dev;
104 struct list_head list;
105 const struct pwm_ops *ops;
106 int base;
107 unsigned int npwm;
108
109 struct pwm_device *pwms;
110
111 struct pwm_device * (*of_xlate)(struct pwm_chip *pc,
112 const struct of_phandle_args *args);
113 unsigned int of_pwm_n_cells;
114};
115
116int pwm_set_chip_data(struct pwm_device *pwm, void *data);
117void *pwm_get_chip_data(struct pwm_device *pwm);
118
119int pwmchip_add(struct pwm_chip *chip);
120int pwmchip_remove(struct pwm_chip *chip);
121struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
122 unsigned int index,
123 const char *label);
124
125struct pwm_device *pwm_get(struct device *dev, const char *consumer);
126void pwm_put(struct pwm_device *pwm);
127
128struct pwm_lookup {
129 struct list_head list;
130 const char *provider;
131 unsigned int index;
132 const char *dev_id;
133 const char *con_id;
134};
135
136#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id) \
137 { \
138 .provider = _provider, \
139 .index = _index, \
140 .dev_id = _dev_id, \
141 .con_id = _con_id, \
142 }
143
144void pwm_add_table(struct pwm_lookup *table, size_t num);
145
146#endif
147
31#endif /* __LINUX_PWM_H */ 148#endif /* __LINUX_PWM_H */
diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h
index 63d2df43e61a..56f4a866539a 100644
--- a/include/linux/pwm_backlight.h
+++ b/include/linux/pwm_backlight.h
@@ -12,6 +12,7 @@ struct platform_pwm_backlight_data {
12 unsigned int dft_brightness; 12 unsigned int dft_brightness;
13 unsigned int lth_brightness; 13 unsigned int lth_brightness;
14 unsigned int pwm_period_ns; 14 unsigned int pwm_period_ns;
15 unsigned int *levels;
15 int (*init)(struct device *dev); 16 int (*init)(struct device *dev);
16 int (*notify)(struct device *dev, int brightness); 17 int (*notify)(struct device *dev, int brightness);
17 void (*notify_after)(struct device *dev, int brightness); 18 void (*notify_after)(struct device *dev, int brightness);
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index ac9586dadfa5..7b600da9a635 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -214,6 +214,10 @@ void sg_free_table(struct sg_table *);
214int __sg_alloc_table(struct sg_table *, unsigned int, unsigned int, gfp_t, 214int __sg_alloc_table(struct sg_table *, unsigned int, unsigned int, gfp_t,
215 sg_alloc_fn *); 215 sg_alloc_fn *);
216int sg_alloc_table(struct sg_table *, unsigned int, gfp_t); 216int sg_alloc_table(struct sg_table *, unsigned int, gfp_t);
217int sg_alloc_table_from_pages(struct sg_table *sgt,
218 struct page **pages, unsigned int n_pages,
219 unsigned long offset, unsigned long size,
220 gfp_t gfp_mask);
217 221
218size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents, 222size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents,
219 void *buf, size_t buflen); 223 void *buf, size_t buflen);
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 67d5d94b783a..0dd2dfa7beca 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -93,6 +93,30 @@
93 (unsigned long)ZERO_SIZE_PTR) 93 (unsigned long)ZERO_SIZE_PTR)
94 94
95/* 95/*
96 * Common fields provided in kmem_cache by all slab allocators
97 * This struct is either used directly by the allocator (SLOB)
98 * or the allocator must include definitions for all fields
99 * provided in kmem_cache_common in their definition of kmem_cache.
100 *
101 * Once we can do anonymous structs (C11 standard) we could put a
102 * anonymous struct definition in these allocators so that the
103 * separate allocations in the kmem_cache structure of SLAB and
104 * SLUB is no longer needed.
105 */
106#ifdef CONFIG_SLOB
107struct kmem_cache {
108 unsigned int object_size;/* The original size of the object */
109 unsigned int size; /* The aligned/padded/added on size */
110 unsigned int align; /* Alignment as calculated */
111 unsigned long flags; /* Active flags on the slab */
112 const char *name; /* Slab name for sysfs */
113 int refcount; /* Use counter */
114 void (*ctor)(void *); /* Called on object slot creation */
115 struct list_head list; /* List of all slab caches on the system */
116};
117#endif
118
119/*
96 * struct kmem_cache related prototypes 120 * struct kmem_cache related prototypes
97 */ 121 */
98void __init kmem_cache_init(void); 122void __init kmem_cache_init(void);
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index fbd1117fdfde..0c634fa376c9 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -27,7 +27,7 @@ struct kmem_cache {
27 unsigned int limit; 27 unsigned int limit;
28 unsigned int shared; 28 unsigned int shared;
29 29
30 unsigned int buffer_size; 30 unsigned int size;
31 u32 reciprocal_buffer_size; 31 u32 reciprocal_buffer_size;
32/* 2) touched by every alloc & free from the backend */ 32/* 2) touched by every alloc & free from the backend */
33 33
@@ -39,7 +39,7 @@ struct kmem_cache {
39 unsigned int gfporder; 39 unsigned int gfporder;
40 40
41 /* force GFP flags, e.g. GFP_DMA */ 41 /* force GFP flags, e.g. GFP_DMA */
42 gfp_t gfpflags; 42 gfp_t allocflags;
43 43
44 size_t colour; /* cache colouring range */ 44 size_t colour; /* cache colouring range */
45 unsigned int colour_off; /* colour offset */ 45 unsigned int colour_off; /* colour offset */
@@ -52,7 +52,10 @@ struct kmem_cache {
52 52
53/* 4) cache creation/removal */ 53/* 4) cache creation/removal */
54 const char *name; 54 const char *name;
55 struct list_head next; 55 struct list_head list;
56 int refcount;
57 int object_size;
58 int align;
56 59
57/* 5) statistics */ 60/* 5) statistics */
58#ifdef CONFIG_DEBUG_SLAB 61#ifdef CONFIG_DEBUG_SLAB
@@ -73,12 +76,11 @@ struct kmem_cache {
73 76
74 /* 77 /*
75 * If debugging is enabled, then the allocator can add additional 78 * If debugging is enabled, then the allocator can add additional
76 * fields and/or padding to every object. buffer_size contains the total 79 * fields and/or padding to every object. size contains the total
77 * object size including these internal fields, the following two 80 * object size including these internal fields, the following two
78 * variables contain the offset to the user object and its size. 81 * variables contain the offset to the user object and its size.
79 */ 82 */
80 int obj_offset; 83 int obj_offset;
81 int obj_size;
82#endif /* CONFIG_DEBUG_SLAB */ 84#endif /* CONFIG_DEBUG_SLAB */
83 85
84/* 6) per-cpu/per-node data, touched during every alloc/free */ 86/* 6) per-cpu/per-node data, touched during every alloc/free */
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index c2f8c8bc56ed..df448adb7283 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -48,7 +48,6 @@ struct kmem_cache_cpu {
48 unsigned long tid; /* Globally unique transaction id */ 48 unsigned long tid; /* Globally unique transaction id */
49 struct page *page; /* The slab from which we are allocating */ 49 struct page *page; /* The slab from which we are allocating */
50 struct page *partial; /* Partially allocated frozen slabs */ 50 struct page *partial; /* Partially allocated frozen slabs */
51 int node; /* The node of the page (or -1 for debug) */
52#ifdef CONFIG_SLUB_STATS 51#ifdef CONFIG_SLUB_STATS
53 unsigned stat[NR_SLUB_STAT_ITEMS]; 52 unsigned stat[NR_SLUB_STAT_ITEMS];
54#endif 53#endif
@@ -83,7 +82,7 @@ struct kmem_cache {
83 unsigned long flags; 82 unsigned long flags;
84 unsigned long min_partial; 83 unsigned long min_partial;
85 int size; /* The size of an object including meta data */ 84 int size; /* The size of an object including meta data */
86 int objsize; /* The size of an object without meta data */ 85 int object_size; /* The size of an object without meta data */
87 int offset; /* Free pointer offset. */ 86 int offset; /* Free pointer offset. */
88 int cpu_partial; /* Number of per cpu partial objects to keep around */ 87 int cpu_partial; /* Number of per cpu partial objects to keep around */
89 struct kmem_cache_order_objects oo; 88 struct kmem_cache_order_objects oo;
diff --git a/include/linux/virtio_blk.h b/include/linux/virtio_blk.h
index e0edb40ca7aa..6d8e61c48563 100644
--- a/include/linux/virtio_blk.h
+++ b/include/linux/virtio_blk.h
@@ -37,8 +37,14 @@
37#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */ 37#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
38#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/ 38#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
39#define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */ 39#define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
40#define VIRTIO_BLK_F_FLUSH 9 /* Cache flush command support */ 40#define VIRTIO_BLK_F_WCE 9 /* Writeback mode enabled after reset */
41#define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */ 41#define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */
42#define VIRTIO_BLK_F_CONFIG_WCE 11 /* Writeback mode available in config */
43
44#ifndef __KERNEL__
45/* Old (deprecated) name for VIRTIO_BLK_F_WCE. */
46#define VIRTIO_BLK_F_FLUSH VIRTIO_BLK_F_WCE
47#endif
42 48
43#define VIRTIO_BLK_ID_BYTES 20 /* ID string length */ 49#define VIRTIO_BLK_ID_BYTES 20 /* ID string length */
44 50
@@ -69,6 +75,8 @@ struct virtio_blk_config {
69 /* optimal sustained I/O size in logical blocks. */ 75 /* optimal sustained I/O size in logical blocks. */
70 __u32 opt_io_size; 76 __u32 opt_io_size;
71 77
78 /* writeback mode (if VIRTIO_BLK_F_CONFIG_WCE) */
79 __u8 wce;
72} __attribute__((packed)); 80} __attribute__((packed));
73 81
74/* 82/*
diff --git a/include/linux/virtio_ids.h b/include/linux/virtio_ids.h
index 7529b854b7fd..270fb22c5811 100644
--- a/include/linux/virtio_ids.h
+++ b/include/linux/virtio_ids.h
@@ -32,7 +32,7 @@
32#define VIRTIO_ID_NET 1 /* virtio net */ 32#define VIRTIO_ID_NET 1 /* virtio net */
33#define VIRTIO_ID_BLOCK 2 /* virtio block */ 33#define VIRTIO_ID_BLOCK 2 /* virtio block */
34#define VIRTIO_ID_CONSOLE 3 /* virtio console */ 34#define VIRTIO_ID_CONSOLE 3 /* virtio console */
35#define VIRTIO_ID_RNG 4 /* virtio ring */ 35#define VIRTIO_ID_RNG 4 /* virtio rng */
36#define VIRTIO_ID_BALLOON 5 /* virtio balloon */ 36#define VIRTIO_ID_BALLOON 5 /* virtio balloon */
37#define VIRTIO_ID_RPMSG 7 /* virtio remote processor messaging */ 37#define VIRTIO_ID_RPMSG 7 /* virtio remote processor messaging */
38#define VIRTIO_ID_SCSI 8 /* virtio scsi */ 38#define VIRTIO_ID_SCSI 8 /* virtio scsi */
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index dcdfc2bda922..6071e911c7f4 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -32,7 +32,7 @@ struct vm_struct {
32 struct page **pages; 32 struct page **pages;
33 unsigned int nr_pages; 33 unsigned int nr_pages;
34 phys_addr_t phys_addr; 34 phys_addr_t phys_addr;
35 void *caller; 35 const void *caller;
36}; 36};
37 37
38/* 38/*
@@ -62,7 +62,7 @@ extern void *vmalloc_32_user(unsigned long size);
62extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot); 62extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
63extern void *__vmalloc_node_range(unsigned long size, unsigned long align, 63extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
64 unsigned long start, unsigned long end, gfp_t gfp_mask, 64 unsigned long start, unsigned long end, gfp_t gfp_mask,
65 pgprot_t prot, int node, void *caller); 65 pgprot_t prot, int node, const void *caller);
66extern void vfree(const void *addr); 66extern void vfree(const void *addr);
67 67
68extern void *vmap(struct page **pages, unsigned int count, 68extern void *vmap(struct page **pages, unsigned int count,
@@ -85,14 +85,15 @@ static inline size_t get_vm_area_size(const struct vm_struct *area)
85 85
86extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags); 86extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags);
87extern struct vm_struct *get_vm_area_caller(unsigned long size, 87extern struct vm_struct *get_vm_area_caller(unsigned long size,
88 unsigned long flags, void *caller); 88 unsigned long flags, const void *caller);
89extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags, 89extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
90 unsigned long start, unsigned long end); 90 unsigned long start, unsigned long end);
91extern struct vm_struct *__get_vm_area_caller(unsigned long size, 91extern struct vm_struct *__get_vm_area_caller(unsigned long size,
92 unsigned long flags, 92 unsigned long flags,
93 unsigned long start, unsigned long end, 93 unsigned long start, unsigned long end,
94 void *caller); 94 const void *caller);
95extern struct vm_struct *remove_vm_area(const void *addr); 95extern struct vm_struct *remove_vm_area(const void *addr);
96extern struct vm_struct *find_vm_area(const void *addr);
96 97
97extern int map_vm_area(struct vm_struct *area, pgprot_t prot, 98extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
98 struct page ***pages); 99 struct page ***pages);
diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h
new file mode 100644
index 000000000000..260470e72483
--- /dev/null
+++ b/include/ras/ras_event.h
@@ -0,0 +1,102 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM ras
3#define TRACE_INCLUDE_FILE ras_event
4
5#if !defined(_TRACE_HW_EVENT_MC_H) || defined(TRACE_HEADER_MULTI_READ)
6#define _TRACE_HW_EVENT_MC_H
7
8#include <linux/tracepoint.h>
9#include <linux/edac.h>
10#include <linux/ktime.h>
11
12/*
13 * Hardware Events Report
14 *
15 * Those events are generated when hardware detected a corrected or
16 * uncorrected event, and are meant to replace the current API to report
17 * errors defined on both EDAC and MCE subsystems.
18 *
19 * FIXME: Add events for handling memory errors originated from the
20 * MCE subsystem.
21 */
22
23/*
24 * Hardware-independent Memory Controller specific events
25 */
26
27/*
28 * Default error mechanisms for Memory Controller errors (CE and UE)
29 */
30TRACE_EVENT(mc_event,
31
32 TP_PROTO(const unsigned int err_type,
33 const char *error_msg,
34 const char *label,
35 const int error_count,
36 const u8 mc_index,
37 const s8 top_layer,
38 const s8 mid_layer,
39 const s8 low_layer,
40 unsigned long address,
41 const u8 grain_bits,
42 unsigned long syndrome,
43 const char *driver_detail),
44
45 TP_ARGS(err_type, error_msg, label, error_count, mc_index,
46 top_layer, mid_layer, low_layer, address, grain_bits,
47 syndrome, driver_detail),
48
49 TP_STRUCT__entry(
50 __field( unsigned int, error_type )
51 __string( msg, error_msg )
52 __string( label, label )
53 __field( u16, error_count )
54 __field( u8, mc_index )
55 __field( s8, top_layer )
56 __field( s8, middle_layer )
57 __field( s8, lower_layer )
58 __field( long, address )
59 __field( u8, grain_bits )
60 __field( long, syndrome )
61 __string( driver_detail, driver_detail )
62 ),
63
64 TP_fast_assign(
65 __entry->error_type = err_type;
66 __assign_str(msg, error_msg);
67 __assign_str(label, label);
68 __entry->error_count = error_count;
69 __entry->mc_index = mc_index;
70 __entry->top_layer = top_layer;
71 __entry->middle_layer = mid_layer;
72 __entry->lower_layer = low_layer;
73 __entry->address = address;
74 __entry->grain_bits = grain_bits;
75 __entry->syndrome = syndrome;
76 __assign_str(driver_detail, driver_detail);
77 ),
78
79 TP_printk("%d %s error%s:%s%s on %s (mc:%d location:%d:%d:%d address:0x%08lx grain:%d syndrome:0x%08lx%s%s)",
80 __entry->error_count,
81 (__entry->error_type == HW_EVENT_ERR_CORRECTED) ? "Corrected" :
82 ((__entry->error_type == HW_EVENT_ERR_FATAL) ?
83 "Fatal" : "Uncorrected"),
84 __entry->error_count > 1 ? "s" : "",
85 ((char *)__get_str(msg))[0] ? " " : "",
86 __get_str(msg),
87 __get_str(label),
88 __entry->mc_index,
89 __entry->top_layer,
90 __entry->middle_layer,
91 __entry->lower_layer,
92 __entry->address,
93 1 << __entry->grain_bits,
94 __entry->syndrome,
95 ((char *)__get_str(driver_detail))[0] ? " " : "",
96 __get_str(driver_detail))
97);
98
99#endif /* _TRACE_HW_EVENT_MC_H */
100
101/* This part must be outside protection */
102#include <trace/define_trace.h>
diff --git a/lib/Kconfig b/lib/Kconfig
index 72c1d4693068..bb94c1ba616a 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -390,4 +390,10 @@ config SIGNATURE
390 Digital signature verification. Currently only RSA is supported. 390 Digital signature verification. Currently only RSA is supported.
391 Implementation is done using GnuPG MPI library 391 Implementation is done using GnuPG MPI library
392 392
393#
394# libfdt files, only selected if needed.
395#
396config LIBFDT
397 bool
398
393endmenu 399endmenu
diff --git a/lib/Makefile b/lib/Makefile
index 1054de86ae82..9cb4104f47d9 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -135,6 +135,11 @@ obj-$(CONFIG_GENERIC_STRNLEN_USER) += strnlen_user.o
135 135
136obj-$(CONFIG_STMP_DEVICE) += stmp_device.o 136obj-$(CONFIG_STMP_DEVICE) += stmp_device.o
137 137
138libfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o
139$(foreach file, $(libfdt_files), \
140 $(eval CFLAGS_$(file) = -I$(src)/../scripts/dtc/libfdt))
141lib-$(CONFIG_LIBFDT) += $(libfdt_files)
142
138hostprogs-y := gen_crc32table 143hostprogs-y := gen_crc32table
139clean-files := crc32table.h 144clean-files := crc32table.h
140 145
diff --git a/lib/fdt.c b/lib/fdt.c
new file mode 100644
index 000000000000..97f20069fc37
--- /dev/null
+++ b/lib/fdt.c
@@ -0,0 +1,2 @@
1#include <linux/libfdt_env.h>
2#include "../scripts/dtc/libfdt/fdt.c"
diff --git a/lib/fdt_ro.c b/lib/fdt_ro.c
new file mode 100644
index 000000000000..f73c04ea7be4
--- /dev/null
+++ b/lib/fdt_ro.c
@@ -0,0 +1,2 @@
1#include <linux/libfdt_env.h>
2#include "../scripts/dtc/libfdt/fdt_ro.c"
diff --git a/lib/fdt_rw.c b/lib/fdt_rw.c
new file mode 100644
index 000000000000..0c1f0f4a4b13
--- /dev/null
+++ b/lib/fdt_rw.c
@@ -0,0 +1,2 @@
1#include <linux/libfdt_env.h>
2#include "../scripts/dtc/libfdt/fdt_rw.c"
diff --git a/lib/fdt_strerror.c b/lib/fdt_strerror.c
new file mode 100644
index 000000000000..8713e3ff4707
--- /dev/null
+++ b/lib/fdt_strerror.c
@@ -0,0 +1,2 @@
1#include <linux/libfdt_env.h>
2#include "../scripts/dtc/libfdt/fdt_strerror.c"
diff --git a/lib/fdt_sw.c b/lib/fdt_sw.c
new file mode 100644
index 000000000000..9ac7e50c76ce
--- /dev/null
+++ b/lib/fdt_sw.c
@@ -0,0 +1,2 @@
1#include <linux/libfdt_env.h>
2#include "../scripts/dtc/libfdt/fdt_sw.c"
diff --git a/lib/fdt_wip.c b/lib/fdt_wip.c
new file mode 100644
index 000000000000..45b3fc3d3ba1
--- /dev/null
+++ b/lib/fdt_wip.c
@@ -0,0 +1,2 @@
1#include <linux/libfdt_env.h>
2#include "../scripts/dtc/libfdt/fdt_wip.c"
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index d09bdd8b40ce..fadae774a20c 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -311,6 +311,70 @@ int sg_alloc_table(struct sg_table *table, unsigned int nents, gfp_t gfp_mask)
311EXPORT_SYMBOL(sg_alloc_table); 311EXPORT_SYMBOL(sg_alloc_table);
312 312
313/** 313/**
314 * sg_alloc_table_from_pages - Allocate and initialize an sg table from
315 * an array of pages
316 * @sgt: The sg table header to use
317 * @pages: Pointer to an array of page pointers
318 * @n_pages: Number of pages in the pages array
319 * @offset: Offset from start of the first page to the start of a buffer
320 * @size: Number of valid bytes in the buffer (after offset)
321 * @gfp_mask: GFP allocation mask
322 *
323 * Description:
324 * Allocate and initialize an sg table from a list of pages. Contiguous
325 * ranges of the pages are squashed into a single scatterlist node. A user
326 * may provide an offset at a start and a size of valid data in a buffer
327 * specified by the page array. The returned sg table is released by
328 * sg_free_table.
329 *
330 * Returns:
331 * 0 on success, negative error on failure
332 */
333int sg_alloc_table_from_pages(struct sg_table *sgt,
334 struct page **pages, unsigned int n_pages,
335 unsigned long offset, unsigned long size,
336 gfp_t gfp_mask)
337{
338 unsigned int chunks;
339 unsigned int i;
340 unsigned int cur_page;
341 int ret;
342 struct scatterlist *s;
343
344 /* compute number of contiguous chunks */
345 chunks = 1;
346 for (i = 1; i < n_pages; ++i)
347 if (page_to_pfn(pages[i]) != page_to_pfn(pages[i - 1]) + 1)
348 ++chunks;
349
350 ret = sg_alloc_table(sgt, chunks, gfp_mask);
351 if (unlikely(ret))
352 return ret;
353
354 /* merging chunks and putting them into the scatterlist */
355 cur_page = 0;
356 for_each_sg(sgt->sgl, s, sgt->orig_nents, i) {
357 unsigned long chunk_size;
358 unsigned int j;
359
360 /* look for the end of the current chunk */
361 for (j = cur_page + 1; j < n_pages; ++j)
362 if (page_to_pfn(pages[j]) !=
363 page_to_pfn(pages[j - 1]) + 1)
364 break;
365
366 chunk_size = ((j - cur_page) << PAGE_SHIFT) - offset;
367 sg_set_page(s, pages[cur_page], min(size, chunk_size), offset);
368 size -= chunk_size;
369 offset = 0;
370 cur_page = j;
371 }
372
373 return 0;
374}
375EXPORT_SYMBOL(sg_alloc_table_from_pages);
376
377/**
314 * sg_miter_start - start mapping iteration over a sg list 378 * sg_miter_start - start mapping iteration over a sg list
315 * @miter: sg mapping iter to be started 379 * @miter: sg mapping iter to be started
316 * @sgl: sg list to iterate over 380 * @sgl: sg list to iterate over
diff --git a/mm/Makefile b/mm/Makefile
index 2e2fbbefb99f..8e81fe263c94 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -16,7 +16,8 @@ obj-y := filemap.o mempool.o oom_kill.o fadvise.o \
16 readahead.o swap.o truncate.o vmscan.o shmem.o \ 16 readahead.o swap.o truncate.o vmscan.o shmem.o \
17 prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \ 17 prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \
18 page_isolation.o mm_init.o mmu_context.o percpu.o \ 18 page_isolation.o mm_init.o mmu_context.o percpu.o \
19 compaction.o $(mmu-y) 19 compaction.o slab_common.o $(mmu-y)
20
20obj-y += init-mm.o 21obj-y += init-mm.o
21 22
22ifdef CONFIG_NO_BOOTMEM 23ifdef CONFIG_NO_BOOTMEM
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 1d771e4200d2..bd92431d4c49 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1602,8 +1602,14 @@ static unsigned interleave_nodes(struct mempolicy *policy)
1602 * task can change it's policy. The system default policy requires no 1602 * task can change it's policy. The system default policy requires no
1603 * such protection. 1603 * such protection.
1604 */ 1604 */
1605unsigned slab_node(struct mempolicy *policy) 1605unsigned slab_node(void)
1606{ 1606{
1607 struct mempolicy *policy;
1608
1609 if (in_interrupt())
1610 return numa_node_id();
1611
1612 policy = current->mempolicy;
1607 if (!policy || policy->flags & MPOL_F_LOCAL) 1613 if (!policy || policy->flags & MPOL_F_LOCAL)
1608 return numa_node_id(); 1614 return numa_node_id();
1609 1615
diff --git a/mm/slab.c b/mm/slab.c
index e901a36e2520..1fcf3ac94b6c 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -68,7 +68,7 @@
68 * Further notes from the original documentation: 68 * Further notes from the original documentation:
69 * 69 *
70 * 11 April '97. Started multi-threading - markhe 70 * 11 April '97. Started multi-threading - markhe
71 * The global cache-chain is protected by the mutex 'cache_chain_mutex'. 71 * The global cache-chain is protected by the mutex 'slab_mutex'.
72 * The sem is only needed when accessing/extending the cache-chain, which 72 * The sem is only needed when accessing/extending the cache-chain, which
73 * can never happen inside an interrupt (kmem_cache_create(), 73 * can never happen inside an interrupt (kmem_cache_create(),
74 * kmem_cache_shrink() and kmem_cache_reap()). 74 * kmem_cache_shrink() and kmem_cache_reap()).
@@ -87,6 +87,7 @@
87 */ 87 */
88 88
89#include <linux/slab.h> 89#include <linux/slab.h>
90#include "slab.h"
90#include <linux/mm.h> 91#include <linux/mm.h>
91#include <linux/poison.h> 92#include <linux/poison.h>
92#include <linux/swap.h> 93#include <linux/swap.h>
@@ -424,8 +425,8 @@ static void kmem_list3_init(struct kmem_list3 *parent)
424 * cachep->obj_offset - BYTES_PER_WORD .. cachep->obj_offset - 1: 425 * cachep->obj_offset - BYTES_PER_WORD .. cachep->obj_offset - 1:
425 * redzone word. 426 * redzone word.
426 * cachep->obj_offset: The real object. 427 * cachep->obj_offset: The real object.
427 * cachep->buffer_size - 2* BYTES_PER_WORD: redzone word [BYTES_PER_WORD long] 428 * cachep->size - 2* BYTES_PER_WORD: redzone word [BYTES_PER_WORD long]
428 * cachep->buffer_size - 1* BYTES_PER_WORD: last caller address 429 * cachep->size - 1* BYTES_PER_WORD: last caller address
429 * [BYTES_PER_WORD long] 430 * [BYTES_PER_WORD long]
430 */ 431 */
431static int obj_offset(struct kmem_cache *cachep) 432static int obj_offset(struct kmem_cache *cachep)
@@ -433,11 +434,6 @@ static int obj_offset(struct kmem_cache *cachep)
433 return cachep->obj_offset; 434 return cachep->obj_offset;
434} 435}
435 436
436static int obj_size(struct kmem_cache *cachep)
437{
438 return cachep->obj_size;
439}
440
441static unsigned long long *dbg_redzone1(struct kmem_cache *cachep, void *objp) 437static unsigned long long *dbg_redzone1(struct kmem_cache *cachep, void *objp)
442{ 438{
443 BUG_ON(!(cachep->flags & SLAB_RED_ZONE)); 439 BUG_ON(!(cachep->flags & SLAB_RED_ZONE));
@@ -449,23 +445,22 @@ static unsigned long long *dbg_redzone2(struct kmem_cache *cachep, void *objp)
449{ 445{
450 BUG_ON(!(cachep->flags & SLAB_RED_ZONE)); 446 BUG_ON(!(cachep->flags & SLAB_RED_ZONE));
451 if (cachep->flags & SLAB_STORE_USER) 447 if (cachep->flags & SLAB_STORE_USER)
452 return (unsigned long long *)(objp + cachep->buffer_size - 448 return (unsigned long long *)(objp + cachep->size -
453 sizeof(unsigned long long) - 449 sizeof(unsigned long long) -
454 REDZONE_ALIGN); 450 REDZONE_ALIGN);
455 return (unsigned long long *) (objp + cachep->buffer_size - 451 return (unsigned long long *) (objp + cachep->size -
456 sizeof(unsigned long long)); 452 sizeof(unsigned long long));
457} 453}
458 454
459static void **dbg_userword(struct kmem_cache *cachep, void *objp) 455static void **dbg_userword(struct kmem_cache *cachep, void *objp)
460{ 456{
461 BUG_ON(!(cachep->flags & SLAB_STORE_USER)); 457 BUG_ON(!(cachep->flags & SLAB_STORE_USER));
462 return (void **)(objp + cachep->buffer_size - BYTES_PER_WORD); 458 return (void **)(objp + cachep->size - BYTES_PER_WORD);
463} 459}
464 460
465#else 461#else
466 462
467#define obj_offset(x) 0 463#define obj_offset(x) 0
468#define obj_size(cachep) (cachep->buffer_size)
469#define dbg_redzone1(cachep, objp) ({BUG(); (unsigned long long *)NULL;}) 464#define dbg_redzone1(cachep, objp) ({BUG(); (unsigned long long *)NULL;})
470#define dbg_redzone2(cachep, objp) ({BUG(); (unsigned long long *)NULL;}) 465#define dbg_redzone2(cachep, objp) ({BUG(); (unsigned long long *)NULL;})
471#define dbg_userword(cachep, objp) ({BUG(); (void **)NULL;}) 466#define dbg_userword(cachep, objp) ({BUG(); (void **)NULL;})
@@ -475,7 +470,7 @@ static void **dbg_userword(struct kmem_cache *cachep, void *objp)
475#ifdef CONFIG_TRACING 470#ifdef CONFIG_TRACING
476size_t slab_buffer_size(struct kmem_cache *cachep) 471size_t slab_buffer_size(struct kmem_cache *cachep)
477{ 472{
478 return cachep->buffer_size; 473 return cachep->size;
479} 474}
480EXPORT_SYMBOL(slab_buffer_size); 475EXPORT_SYMBOL(slab_buffer_size);
481#endif 476#endif
@@ -489,56 +484,37 @@ EXPORT_SYMBOL(slab_buffer_size);
489static int slab_max_order = SLAB_MAX_ORDER_LO; 484static int slab_max_order = SLAB_MAX_ORDER_LO;
490static bool slab_max_order_set __initdata; 485static bool slab_max_order_set __initdata;
491 486
492/*
493 * Functions for storing/retrieving the cachep and or slab from the page
494 * allocator. These are used to find the slab an obj belongs to. With kfree(),
495 * these are used to find the cache which an obj belongs to.
496 */
497static inline void page_set_cache(struct page *page, struct kmem_cache *cache)
498{
499 page->lru.next = (struct list_head *)cache;
500}
501
502static inline struct kmem_cache *page_get_cache(struct page *page) 487static inline struct kmem_cache *page_get_cache(struct page *page)
503{ 488{
504 page = compound_head(page); 489 page = compound_head(page);
505 BUG_ON(!PageSlab(page)); 490 BUG_ON(!PageSlab(page));
506 return (struct kmem_cache *)page->lru.next; 491 return page->slab_cache;
507}
508
509static inline void page_set_slab(struct page *page, struct slab *slab)
510{
511 page->lru.prev = (struct list_head *)slab;
512}
513
514static inline struct slab *page_get_slab(struct page *page)
515{
516 BUG_ON(!PageSlab(page));
517 return (struct slab *)page->lru.prev;
518} 492}
519 493
520static inline struct kmem_cache *virt_to_cache(const void *obj) 494static inline struct kmem_cache *virt_to_cache(const void *obj)
521{ 495{
522 struct page *page = virt_to_head_page(obj); 496 struct page *page = virt_to_head_page(obj);
523 return page_get_cache(page); 497 return page->slab_cache;
524} 498}
525 499
526static inline struct slab *virt_to_slab(const void *obj) 500static inline struct slab *virt_to_slab(const void *obj)
527{ 501{
528 struct page *page = virt_to_head_page(obj); 502 struct page *page = virt_to_head_page(obj);
529 return page_get_slab(page); 503
504 VM_BUG_ON(!PageSlab(page));
505 return page->slab_page;
530} 506}
531 507
532static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab, 508static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
533 unsigned int idx) 509 unsigned int idx)
534{ 510{
535 return slab->s_mem + cache->buffer_size * idx; 511 return slab->s_mem + cache->size * idx;
536} 512}
537 513
538/* 514/*
539 * We want to avoid an expensive divide : (offset / cache->buffer_size) 515 * We want to avoid an expensive divide : (offset / cache->size)
540 * Using the fact that buffer_size is a constant for a particular cache, 516 * Using the fact that size is a constant for a particular cache,
541 * we can replace (offset / cache->buffer_size) by 517 * we can replace (offset / cache->size) by
542 * reciprocal_divide(offset, cache->reciprocal_buffer_size) 518 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
543 */ 519 */
544static inline unsigned int obj_to_index(const struct kmem_cache *cache, 520static inline unsigned int obj_to_index(const struct kmem_cache *cache,
@@ -584,33 +560,12 @@ static struct kmem_cache cache_cache = {
584 .batchcount = 1, 560 .batchcount = 1,
585 .limit = BOOT_CPUCACHE_ENTRIES, 561 .limit = BOOT_CPUCACHE_ENTRIES,
586 .shared = 1, 562 .shared = 1,
587 .buffer_size = sizeof(struct kmem_cache), 563 .size = sizeof(struct kmem_cache),
588 .name = "kmem_cache", 564 .name = "kmem_cache",
589}; 565};
590 566
591#define BAD_ALIEN_MAGIC 0x01020304ul 567#define BAD_ALIEN_MAGIC 0x01020304ul
592 568
593/*
594 * chicken and egg problem: delay the per-cpu array allocation
595 * until the general caches are up.
596 */
597static enum {
598 NONE,
599 PARTIAL_AC,
600 PARTIAL_L3,
601 EARLY,
602 LATE,
603 FULL
604} g_cpucache_up;
605
606/*
607 * used by boot code to determine if it can use slab based allocator
608 */
609int slab_is_available(void)
610{
611 return g_cpucache_up >= EARLY;
612}
613
614#ifdef CONFIG_LOCKDEP 569#ifdef CONFIG_LOCKDEP
615 570
616/* 571/*
@@ -676,7 +631,7 @@ static void init_node_lock_keys(int q)
676{ 631{
677 struct cache_sizes *s = malloc_sizes; 632 struct cache_sizes *s = malloc_sizes;
678 633
679 if (g_cpucache_up < LATE) 634 if (slab_state < UP)
680 return; 635 return;
681 636
682 for (s = malloc_sizes; s->cs_size != ULONG_MAX; s++) { 637 for (s = malloc_sizes; s->cs_size != ULONG_MAX; s++) {
@@ -716,12 +671,6 @@ static void slab_set_debugobj_lock_classes(struct kmem_cache *cachep)
716} 671}
717#endif 672#endif
718 673
719/*
720 * Guard access to the cache-chain.
721 */
722static DEFINE_MUTEX(cache_chain_mutex);
723static struct list_head cache_chain;
724
725static DEFINE_PER_CPU(struct delayed_work, slab_reap_work); 674static DEFINE_PER_CPU(struct delayed_work, slab_reap_work);
726 675
727static inline struct array_cache *cpu_cache_get(struct kmem_cache *cachep) 676static inline struct array_cache *cpu_cache_get(struct kmem_cache *cachep)
@@ -1145,7 +1094,7 @@ static inline int cache_free_alien(struct kmem_cache *cachep, void *objp)
1145 * When hotplugging memory or a cpu, existing nodelists are not replaced if 1094 * When hotplugging memory or a cpu, existing nodelists are not replaced if
1146 * already in use. 1095 * already in use.
1147 * 1096 *
1148 * Must hold cache_chain_mutex. 1097 * Must hold slab_mutex.
1149 */ 1098 */
1150static int init_cache_nodelists_node(int node) 1099static int init_cache_nodelists_node(int node)
1151{ 1100{
@@ -1153,7 +1102,7 @@ static int init_cache_nodelists_node(int node)
1153 struct kmem_list3 *l3; 1102 struct kmem_list3 *l3;
1154 const int memsize = sizeof(struct kmem_list3); 1103 const int memsize = sizeof(struct kmem_list3);
1155 1104
1156 list_for_each_entry(cachep, &cache_chain, next) { 1105 list_for_each_entry(cachep, &slab_caches, list) {
1157 /* 1106 /*
1158 * Set up the size64 kmemlist for cpu before we can 1107 * Set up the size64 kmemlist for cpu before we can
1159 * begin anything. Make sure some other cpu on this 1108 * begin anything. Make sure some other cpu on this
@@ -1169,7 +1118,7 @@ static int init_cache_nodelists_node(int node)
1169 1118
1170 /* 1119 /*
1171 * The l3s don't come and go as CPUs come and 1120 * The l3s don't come and go as CPUs come and
1172 * go. cache_chain_mutex is sufficient 1121 * go. slab_mutex is sufficient
1173 * protection here. 1122 * protection here.
1174 */ 1123 */
1175 cachep->nodelists[node] = l3; 1124 cachep->nodelists[node] = l3;
@@ -1191,7 +1140,7 @@ static void __cpuinit cpuup_canceled(long cpu)
1191 int node = cpu_to_mem(cpu); 1140 int node = cpu_to_mem(cpu);
1192 const struct cpumask *mask = cpumask_of_node(node); 1141 const struct cpumask *mask = cpumask_of_node(node);
1193 1142
1194 list_for_each_entry(cachep, &cache_chain, next) { 1143 list_for_each_entry(cachep, &slab_caches, list) {
1195 struct array_cache *nc; 1144 struct array_cache *nc;
1196 struct array_cache *shared; 1145 struct array_cache *shared;
1197 struct array_cache **alien; 1146 struct array_cache **alien;
@@ -1241,7 +1190,7 @@ free_array_cache:
1241 * the respective cache's slabs, now we can go ahead and 1190 * the respective cache's slabs, now we can go ahead and
1242 * shrink each nodelist to its limit. 1191 * shrink each nodelist to its limit.
1243 */ 1192 */
1244 list_for_each_entry(cachep, &cache_chain, next) { 1193 list_for_each_entry(cachep, &slab_caches, list) {
1245 l3 = cachep->nodelists[node]; 1194 l3 = cachep->nodelists[node];
1246 if (!l3) 1195 if (!l3)
1247 continue; 1196 continue;
@@ -1270,7 +1219,7 @@ static int __cpuinit cpuup_prepare(long cpu)
1270 * Now we can go ahead with allocating the shared arrays and 1219 * Now we can go ahead with allocating the shared arrays and
1271 * array caches 1220 * array caches
1272 */ 1221 */
1273 list_for_each_entry(cachep, &cache_chain, next) { 1222 list_for_each_entry(cachep, &slab_caches, list) {
1274 struct array_cache *nc; 1223 struct array_cache *nc;
1275 struct array_cache *shared = NULL; 1224 struct array_cache *shared = NULL;
1276 struct array_cache **alien = NULL; 1225 struct array_cache **alien = NULL;
@@ -1338,9 +1287,9 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1338 switch (action) { 1287 switch (action) {
1339 case CPU_UP_PREPARE: 1288 case CPU_UP_PREPARE:
1340 case CPU_UP_PREPARE_FROZEN: 1289 case CPU_UP_PREPARE_FROZEN:
1341 mutex_lock(&cache_chain_mutex); 1290 mutex_lock(&slab_mutex);
1342 err = cpuup_prepare(cpu); 1291 err = cpuup_prepare(cpu);
1343 mutex_unlock(&cache_chain_mutex); 1292 mutex_unlock(&slab_mutex);
1344 break; 1293 break;
1345 case CPU_ONLINE: 1294 case CPU_ONLINE:
1346 case CPU_ONLINE_FROZEN: 1295 case CPU_ONLINE_FROZEN:
@@ -1350,7 +1299,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1350 case CPU_DOWN_PREPARE: 1299 case CPU_DOWN_PREPARE:
1351 case CPU_DOWN_PREPARE_FROZEN: 1300 case CPU_DOWN_PREPARE_FROZEN:
1352 /* 1301 /*
1353 * Shutdown cache reaper. Note that the cache_chain_mutex is 1302 * Shutdown cache reaper. Note that the slab_mutex is
1354 * held so that if cache_reap() is invoked it cannot do 1303 * held so that if cache_reap() is invoked it cannot do
1355 * anything expensive but will only modify reap_work 1304 * anything expensive but will only modify reap_work
1356 * and reschedule the timer. 1305 * and reschedule the timer.
@@ -1377,9 +1326,9 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1377#endif 1326#endif
1378 case CPU_UP_CANCELED: 1327 case CPU_UP_CANCELED:
1379 case CPU_UP_CANCELED_FROZEN: 1328 case CPU_UP_CANCELED_FROZEN:
1380 mutex_lock(&cache_chain_mutex); 1329 mutex_lock(&slab_mutex);
1381 cpuup_canceled(cpu); 1330 cpuup_canceled(cpu);
1382 mutex_unlock(&cache_chain_mutex); 1331 mutex_unlock(&slab_mutex);
1383 break; 1332 break;
1384 } 1333 }
1385 return notifier_from_errno(err); 1334 return notifier_from_errno(err);
@@ -1395,14 +1344,14 @@ static struct notifier_block __cpuinitdata cpucache_notifier = {
1395 * Returns -EBUSY if all objects cannot be drained so that the node is not 1344 * Returns -EBUSY if all objects cannot be drained so that the node is not
1396 * removed. 1345 * removed.
1397 * 1346 *
1398 * Must hold cache_chain_mutex. 1347 * Must hold slab_mutex.
1399 */ 1348 */
1400static int __meminit drain_cache_nodelists_node(int node) 1349static int __meminit drain_cache_nodelists_node(int node)
1401{ 1350{
1402 struct kmem_cache *cachep; 1351 struct kmem_cache *cachep;
1403 int ret = 0; 1352 int ret = 0;
1404 1353
1405 list_for_each_entry(cachep, &cache_chain, next) { 1354 list_for_each_entry(cachep, &slab_caches, list) {
1406 struct kmem_list3 *l3; 1355 struct kmem_list3 *l3;
1407 1356
1408 l3 = cachep->nodelists[node]; 1357 l3 = cachep->nodelists[node];
@@ -1433,14 +1382,14 @@ static int __meminit slab_memory_callback(struct notifier_block *self,
1433 1382
1434 switch (action) { 1383 switch (action) {
1435 case MEM_GOING_ONLINE: 1384 case MEM_GOING_ONLINE:
1436 mutex_lock(&cache_chain_mutex); 1385 mutex_lock(&slab_mutex);
1437 ret = init_cache_nodelists_node(nid); 1386 ret = init_cache_nodelists_node(nid);
1438 mutex_unlock(&cache_chain_mutex); 1387 mutex_unlock(&slab_mutex);
1439 break; 1388 break;
1440 case MEM_GOING_OFFLINE: 1389 case MEM_GOING_OFFLINE:
1441 mutex_lock(&cache_chain_mutex); 1390 mutex_lock(&slab_mutex);
1442 ret = drain_cache_nodelists_node(nid); 1391 ret = drain_cache_nodelists_node(nid);
1443 mutex_unlock(&cache_chain_mutex); 1392 mutex_unlock(&slab_mutex);
1444 break; 1393 break;
1445 case MEM_ONLINE: 1394 case MEM_ONLINE:
1446 case MEM_OFFLINE: 1395 case MEM_OFFLINE:
@@ -1544,8 +1493,8 @@ void __init kmem_cache_init(void)
1544 node = numa_mem_id(); 1493 node = numa_mem_id();
1545 1494
1546 /* 1) create the cache_cache */ 1495 /* 1) create the cache_cache */
1547 INIT_LIST_HEAD(&cache_chain); 1496 INIT_LIST_HEAD(&slab_caches);
1548 list_add(&cache_cache.next, &cache_chain); 1497 list_add(&cache_cache.list, &slab_caches);
1549 cache_cache.colour_off = cache_line_size(); 1498 cache_cache.colour_off = cache_line_size();
1550 cache_cache.array[smp_processor_id()] = &initarray_cache.cache; 1499 cache_cache.array[smp_processor_id()] = &initarray_cache.cache;
1551 cache_cache.nodelists[node] = &initkmem_list3[CACHE_CACHE + node]; 1500 cache_cache.nodelists[node] = &initkmem_list3[CACHE_CACHE + node];
@@ -1553,18 +1502,16 @@ void __init kmem_cache_init(void)
1553 /* 1502 /*
1554 * struct kmem_cache size depends on nr_node_ids & nr_cpu_ids 1503 * struct kmem_cache size depends on nr_node_ids & nr_cpu_ids
1555 */ 1504 */
1556 cache_cache.buffer_size = offsetof(struct kmem_cache, array[nr_cpu_ids]) + 1505 cache_cache.size = offsetof(struct kmem_cache, array[nr_cpu_ids]) +
1557 nr_node_ids * sizeof(struct kmem_list3 *); 1506 nr_node_ids * sizeof(struct kmem_list3 *);
1558#if DEBUG 1507 cache_cache.object_size = cache_cache.size;
1559 cache_cache.obj_size = cache_cache.buffer_size; 1508 cache_cache.size = ALIGN(cache_cache.size,
1560#endif
1561 cache_cache.buffer_size = ALIGN(cache_cache.buffer_size,
1562 cache_line_size()); 1509 cache_line_size());
1563 cache_cache.reciprocal_buffer_size = 1510 cache_cache.reciprocal_buffer_size =
1564 reciprocal_value(cache_cache.buffer_size); 1511 reciprocal_value(cache_cache.size);
1565 1512
1566 for (order = 0; order < MAX_ORDER; order++) { 1513 for (order = 0; order < MAX_ORDER; order++) {
1567 cache_estimate(order, cache_cache.buffer_size, 1514 cache_estimate(order, cache_cache.size,
1568 cache_line_size(), 0, &left_over, &cache_cache.num); 1515 cache_line_size(), 0, &left_over, &cache_cache.num);
1569 if (cache_cache.num) 1516 if (cache_cache.num)
1570 break; 1517 break;
@@ -1585,7 +1532,7 @@ void __init kmem_cache_init(void)
1585 * bug. 1532 * bug.
1586 */ 1533 */
1587 1534
1588 sizes[INDEX_AC].cs_cachep = kmem_cache_create(names[INDEX_AC].name, 1535 sizes[INDEX_AC].cs_cachep = __kmem_cache_create(names[INDEX_AC].name,
1589 sizes[INDEX_AC].cs_size, 1536 sizes[INDEX_AC].cs_size,
1590 ARCH_KMALLOC_MINALIGN, 1537 ARCH_KMALLOC_MINALIGN,
1591 ARCH_KMALLOC_FLAGS|SLAB_PANIC, 1538 ARCH_KMALLOC_FLAGS|SLAB_PANIC,
@@ -1593,7 +1540,7 @@ void __init kmem_cache_init(void)
1593 1540
1594 if (INDEX_AC != INDEX_L3) { 1541 if (INDEX_AC != INDEX_L3) {
1595 sizes[INDEX_L3].cs_cachep = 1542 sizes[INDEX_L3].cs_cachep =
1596 kmem_cache_create(names[INDEX_L3].name, 1543 __kmem_cache_create(names[INDEX_L3].name,
1597 sizes[INDEX_L3].cs_size, 1544 sizes[INDEX_L3].cs_size,
1598 ARCH_KMALLOC_MINALIGN, 1545 ARCH_KMALLOC_MINALIGN,
1599 ARCH_KMALLOC_FLAGS|SLAB_PANIC, 1546 ARCH_KMALLOC_FLAGS|SLAB_PANIC,
@@ -1611,14 +1558,14 @@ void __init kmem_cache_init(void)
1611 * allow tighter packing of the smaller caches. 1558 * allow tighter packing of the smaller caches.
1612 */ 1559 */
1613 if (!sizes->cs_cachep) { 1560 if (!sizes->cs_cachep) {
1614 sizes->cs_cachep = kmem_cache_create(names->name, 1561 sizes->cs_cachep = __kmem_cache_create(names->name,
1615 sizes->cs_size, 1562 sizes->cs_size,
1616 ARCH_KMALLOC_MINALIGN, 1563 ARCH_KMALLOC_MINALIGN,
1617 ARCH_KMALLOC_FLAGS|SLAB_PANIC, 1564 ARCH_KMALLOC_FLAGS|SLAB_PANIC,
1618 NULL); 1565 NULL);
1619 } 1566 }
1620#ifdef CONFIG_ZONE_DMA 1567#ifdef CONFIG_ZONE_DMA
1621 sizes->cs_dmacachep = kmem_cache_create( 1568 sizes->cs_dmacachep = __kmem_cache_create(
1622 names->name_dma, 1569 names->name_dma,
1623 sizes->cs_size, 1570 sizes->cs_size,
1624 ARCH_KMALLOC_MINALIGN, 1571 ARCH_KMALLOC_MINALIGN,
@@ -1676,27 +1623,27 @@ void __init kmem_cache_init(void)
1676 } 1623 }
1677 } 1624 }
1678 1625
1679 g_cpucache_up = EARLY; 1626 slab_state = UP;
1680} 1627}
1681 1628
1682void __init kmem_cache_init_late(void) 1629void __init kmem_cache_init_late(void)
1683{ 1630{
1684 struct kmem_cache *cachep; 1631 struct kmem_cache *cachep;
1685 1632
1686 g_cpucache_up = LATE; 1633 slab_state = UP;
1687 1634
1688 /* Annotate slab for lockdep -- annotate the malloc caches */ 1635 /* Annotate slab for lockdep -- annotate the malloc caches */
1689 init_lock_keys(); 1636 init_lock_keys();
1690 1637
1691 /* 6) resize the head arrays to their final sizes */ 1638 /* 6) resize the head arrays to their final sizes */
1692 mutex_lock(&cache_chain_mutex); 1639 mutex_lock(&slab_mutex);
1693 list_for_each_entry(cachep, &cache_chain, next) 1640 list_for_each_entry(cachep, &slab_caches, list)
1694 if (enable_cpucache(cachep, GFP_NOWAIT)) 1641 if (enable_cpucache(cachep, GFP_NOWAIT))
1695 BUG(); 1642 BUG();
1696 mutex_unlock(&cache_chain_mutex); 1643 mutex_unlock(&slab_mutex);
1697 1644
1698 /* Done! */ 1645 /* Done! */
1699 g_cpucache_up = FULL; 1646 slab_state = FULL;
1700 1647
1701 /* 1648 /*
1702 * Register a cpu startup notifier callback that initializes 1649 * Register a cpu startup notifier callback that initializes
@@ -1727,6 +1674,9 @@ static int __init cpucache_init(void)
1727 */ 1674 */
1728 for_each_online_cpu(cpu) 1675 for_each_online_cpu(cpu)
1729 start_cpu_timer(cpu); 1676 start_cpu_timer(cpu);
1677
1678 /* Done! */
1679 slab_state = FULL;
1730 return 0; 1680 return 0;
1731} 1681}
1732__initcall(cpucache_init); 1682__initcall(cpucache_init);
@@ -1743,7 +1693,7 @@ slab_out_of_memory(struct kmem_cache *cachep, gfp_t gfpflags, int nodeid)
1743 "SLAB: Unable to allocate memory on node %d (gfp=0x%x)\n", 1693 "SLAB: Unable to allocate memory on node %d (gfp=0x%x)\n",
1744 nodeid, gfpflags); 1694 nodeid, gfpflags);
1745 printk(KERN_WARNING " cache: %s, object size: %d, order: %d\n", 1695 printk(KERN_WARNING " cache: %s, object size: %d, order: %d\n",
1746 cachep->name, cachep->buffer_size, cachep->gfporder); 1696 cachep->name, cachep->size, cachep->gfporder);
1747 1697
1748 for_each_online_node(node) { 1698 for_each_online_node(node) {
1749 unsigned long active_objs = 0, num_objs = 0, free_objects = 0; 1699 unsigned long active_objs = 0, num_objs = 0, free_objects = 0;
@@ -1798,7 +1748,7 @@ static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid)
1798 flags |= __GFP_COMP; 1748 flags |= __GFP_COMP;
1799#endif 1749#endif
1800 1750
1801 flags |= cachep->gfpflags; 1751 flags |= cachep->allocflags;
1802 if (cachep->flags & SLAB_RECLAIM_ACCOUNT) 1752 if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
1803 flags |= __GFP_RECLAIMABLE; 1753 flags |= __GFP_RECLAIMABLE;
1804 1754
@@ -1874,7 +1824,7 @@ static void kmem_rcu_free(struct rcu_head *head)
1874static void store_stackinfo(struct kmem_cache *cachep, unsigned long *addr, 1824static void store_stackinfo(struct kmem_cache *cachep, unsigned long *addr,
1875 unsigned long caller) 1825 unsigned long caller)
1876{ 1826{
1877 int size = obj_size(cachep); 1827 int size = cachep->object_size;
1878 1828
1879 addr = (unsigned long *)&((char *)addr)[obj_offset(cachep)]; 1829 addr = (unsigned long *)&((char *)addr)[obj_offset(cachep)];
1880 1830
@@ -1906,7 +1856,7 @@ static void store_stackinfo(struct kmem_cache *cachep, unsigned long *addr,
1906 1856
1907static void poison_obj(struct kmem_cache *cachep, void *addr, unsigned char val) 1857static void poison_obj(struct kmem_cache *cachep, void *addr, unsigned char val)
1908{ 1858{
1909 int size = obj_size(cachep); 1859 int size = cachep->object_size;
1910 addr = &((char *)addr)[obj_offset(cachep)]; 1860 addr = &((char *)addr)[obj_offset(cachep)];
1911 1861
1912 memset(addr, val, size); 1862 memset(addr, val, size);
@@ -1966,7 +1916,7 @@ static void print_objinfo(struct kmem_cache *cachep, void *objp, int lines)
1966 printk("\n"); 1916 printk("\n");
1967 } 1917 }
1968 realobj = (char *)objp + obj_offset(cachep); 1918 realobj = (char *)objp + obj_offset(cachep);
1969 size = obj_size(cachep); 1919 size = cachep->object_size;
1970 for (i = 0; i < size && lines; i += 16, lines--) { 1920 for (i = 0; i < size && lines; i += 16, lines--) {
1971 int limit; 1921 int limit;
1972 limit = 16; 1922 limit = 16;
@@ -1983,7 +1933,7 @@ static void check_poison_obj(struct kmem_cache *cachep, void *objp)
1983 int lines = 0; 1933 int lines = 0;
1984 1934
1985 realobj = (char *)objp + obj_offset(cachep); 1935 realobj = (char *)objp + obj_offset(cachep);
1986 size = obj_size(cachep); 1936 size = cachep->object_size;
1987 1937
1988 for (i = 0; i < size; i++) { 1938 for (i = 0; i < size; i++) {
1989 char exp = POISON_FREE; 1939 char exp = POISON_FREE;
@@ -2047,10 +1997,10 @@ static void slab_destroy_debugcheck(struct kmem_cache *cachep, struct slab *slab
2047 1997
2048 if (cachep->flags & SLAB_POISON) { 1998 if (cachep->flags & SLAB_POISON) {
2049#ifdef CONFIG_DEBUG_PAGEALLOC 1999#ifdef CONFIG_DEBUG_PAGEALLOC
2050 if (cachep->buffer_size % PAGE_SIZE == 0 && 2000 if (cachep->size % PAGE_SIZE == 0 &&
2051 OFF_SLAB(cachep)) 2001 OFF_SLAB(cachep))
2052 kernel_map_pages(virt_to_page(objp), 2002 kernel_map_pages(virt_to_page(objp),
2053 cachep->buffer_size / PAGE_SIZE, 1); 2003 cachep->size / PAGE_SIZE, 1);
2054 else 2004 else
2055 check_poison_obj(cachep, objp); 2005 check_poison_obj(cachep, objp);
2056#else 2006#else
@@ -2194,10 +2144,10 @@ static size_t calculate_slab_order(struct kmem_cache *cachep,
2194 2144
2195static int __init_refok setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp) 2145static int __init_refok setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp)
2196{ 2146{
2197 if (g_cpucache_up == FULL) 2147 if (slab_state >= FULL)
2198 return enable_cpucache(cachep, gfp); 2148 return enable_cpucache(cachep, gfp);
2199 2149
2200 if (g_cpucache_up == NONE) { 2150 if (slab_state == DOWN) {
2201 /* 2151 /*
2202 * Note: the first kmem_cache_create must create the cache 2152 * Note: the first kmem_cache_create must create the cache
2203 * that's used by kmalloc(24), otherwise the creation of 2153 * that's used by kmalloc(24), otherwise the creation of
@@ -2212,16 +2162,16 @@ static int __init_refok setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp)
2212 */ 2162 */
2213 set_up_list3s(cachep, SIZE_AC); 2163 set_up_list3s(cachep, SIZE_AC);
2214 if (INDEX_AC == INDEX_L3) 2164 if (INDEX_AC == INDEX_L3)
2215 g_cpucache_up = PARTIAL_L3; 2165 slab_state = PARTIAL_L3;
2216 else 2166 else
2217 g_cpucache_up = PARTIAL_AC; 2167 slab_state = PARTIAL_ARRAYCACHE;
2218 } else { 2168 } else {
2219 cachep->array[smp_processor_id()] = 2169 cachep->array[smp_processor_id()] =
2220 kmalloc(sizeof(struct arraycache_init), gfp); 2170 kmalloc(sizeof(struct arraycache_init), gfp);
2221 2171
2222 if (g_cpucache_up == PARTIAL_AC) { 2172 if (slab_state == PARTIAL_ARRAYCACHE) {
2223 set_up_list3s(cachep, SIZE_L3); 2173 set_up_list3s(cachep, SIZE_L3);
2224 g_cpucache_up = PARTIAL_L3; 2174 slab_state = PARTIAL_L3;
2225 } else { 2175 } else {
2226 int node; 2176 int node;
2227 for_each_online_node(node) { 2177 for_each_online_node(node) {
@@ -2247,7 +2197,7 @@ static int __init_refok setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp)
2247} 2197}
2248 2198
2249/** 2199/**
2250 * kmem_cache_create - Create a cache. 2200 * __kmem_cache_create - Create a cache.
2251 * @name: A string which is used in /proc/slabinfo to identify this cache. 2201 * @name: A string which is used in /proc/slabinfo to identify this cache.
2252 * @size: The size of objects to be created in this cache. 2202 * @size: The size of objects to be created in this cache.
2253 * @align: The required alignment for the objects. 2203 * @align: The required alignment for the objects.
@@ -2274,59 +2224,14 @@ static int __init_refok setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp)
2274 * as davem. 2224 * as davem.
2275 */ 2225 */
2276struct kmem_cache * 2226struct kmem_cache *
2277kmem_cache_create (const char *name, size_t size, size_t align, 2227__kmem_cache_create (const char *name, size_t size, size_t align,
2278 unsigned long flags, void (*ctor)(void *)) 2228 unsigned long flags, void (*ctor)(void *))
2279{ 2229{
2280 size_t left_over, slab_size, ralign; 2230 size_t left_over, slab_size, ralign;
2281 struct kmem_cache *cachep = NULL, *pc; 2231 struct kmem_cache *cachep = NULL;
2282 gfp_t gfp; 2232 gfp_t gfp;
2283 2233
2284 /*
2285 * Sanity checks... these are all serious usage bugs.
2286 */
2287 if (!name || in_interrupt() || (size < BYTES_PER_WORD) ||
2288 size > KMALLOC_MAX_SIZE) {
2289 printk(KERN_ERR "%s: Early error in slab %s\n", __func__,
2290 name);
2291 BUG();
2292 }
2293
2294 /*
2295 * We use cache_chain_mutex to ensure a consistent view of
2296 * cpu_online_mask as well. Please see cpuup_callback
2297 */
2298 if (slab_is_available()) {
2299 get_online_cpus();
2300 mutex_lock(&cache_chain_mutex);
2301 }
2302
2303 list_for_each_entry(pc, &cache_chain, next) {
2304 char tmp;
2305 int res;
2306
2307 /*
2308 * This happens when the module gets unloaded and doesn't
2309 * destroy its slab cache and no-one else reuses the vmalloc
2310 * area of the module. Print a warning.
2311 */
2312 res = probe_kernel_address(pc->name, tmp);
2313 if (res) {
2314 printk(KERN_ERR
2315 "SLAB: cache with size %d has lost its name\n",
2316 pc->buffer_size);
2317 continue;
2318 }
2319
2320 if (!strcmp(pc->name, name)) {
2321 printk(KERN_ERR
2322 "kmem_cache_create: duplicate cache %s\n", name);
2323 dump_stack();
2324 goto oops;
2325 }
2326 }
2327
2328#if DEBUG 2234#if DEBUG
2329 WARN_ON(strchr(name, ' ')); /* It confuses parsers */
2330#if FORCED_DEBUG 2235#if FORCED_DEBUG
2331 /* 2236 /*
2332 * Enable redzoning and last user accounting, except for caches with 2237 * Enable redzoning and last user accounting, except for caches with
@@ -2415,11 +2320,12 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2415 /* Get cache's description obj. */ 2320 /* Get cache's description obj. */
2416 cachep = kmem_cache_zalloc(&cache_cache, gfp); 2321 cachep = kmem_cache_zalloc(&cache_cache, gfp);
2417 if (!cachep) 2322 if (!cachep)
2418 goto oops; 2323 return NULL;
2419 2324
2420 cachep->nodelists = (struct kmem_list3 **)&cachep->array[nr_cpu_ids]; 2325 cachep->nodelists = (struct kmem_list3 **)&cachep->array[nr_cpu_ids];
2326 cachep->object_size = size;
2327 cachep->align = align;
2421#if DEBUG 2328#if DEBUG
2422 cachep->obj_size = size;
2423 2329
2424 /* 2330 /*
2425 * Both debugging options require word-alignment which is calculated 2331 * Both debugging options require word-alignment which is calculated
@@ -2442,7 +2348,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2442 } 2348 }
2443#if FORCED_DEBUG && defined(CONFIG_DEBUG_PAGEALLOC) 2349#if FORCED_DEBUG && defined(CONFIG_DEBUG_PAGEALLOC)
2444 if (size >= malloc_sizes[INDEX_L3 + 1].cs_size 2350 if (size >= malloc_sizes[INDEX_L3 + 1].cs_size
2445 && cachep->obj_size > cache_line_size() && ALIGN(size, align) < PAGE_SIZE) { 2351 && cachep->object_size > cache_line_size() && ALIGN(size, align) < PAGE_SIZE) {
2446 cachep->obj_offset += PAGE_SIZE - ALIGN(size, align); 2352 cachep->obj_offset += PAGE_SIZE - ALIGN(size, align);
2447 size = PAGE_SIZE; 2353 size = PAGE_SIZE;
2448 } 2354 }
@@ -2471,8 +2377,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2471 printk(KERN_ERR 2377 printk(KERN_ERR
2472 "kmem_cache_create: couldn't create cache %s.\n", name); 2378 "kmem_cache_create: couldn't create cache %s.\n", name);
2473 kmem_cache_free(&cache_cache, cachep); 2379 kmem_cache_free(&cache_cache, cachep);
2474 cachep = NULL; 2380 return NULL;
2475 goto oops;
2476 } 2381 }
2477 slab_size = ALIGN(cachep->num * sizeof(kmem_bufctl_t) 2382 slab_size = ALIGN(cachep->num * sizeof(kmem_bufctl_t)
2478 + sizeof(struct slab), align); 2383 + sizeof(struct slab), align);
@@ -2508,10 +2413,10 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2508 cachep->colour = left_over / cachep->colour_off; 2413 cachep->colour = left_over / cachep->colour_off;
2509 cachep->slab_size = slab_size; 2414 cachep->slab_size = slab_size;
2510 cachep->flags = flags; 2415 cachep->flags = flags;
2511 cachep->gfpflags = 0; 2416 cachep->allocflags = 0;
2512 if (CONFIG_ZONE_DMA_FLAG && (flags & SLAB_CACHE_DMA)) 2417 if (CONFIG_ZONE_DMA_FLAG && (flags & SLAB_CACHE_DMA))
2513 cachep->gfpflags |= GFP_DMA; 2418 cachep->allocflags |= GFP_DMA;
2514 cachep->buffer_size = size; 2419 cachep->size = size;
2515 cachep->reciprocal_buffer_size = reciprocal_value(size); 2420 cachep->reciprocal_buffer_size = reciprocal_value(size);
2516 2421
2517 if (flags & CFLGS_OFF_SLAB) { 2422 if (flags & CFLGS_OFF_SLAB) {
@@ -2530,8 +2435,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2530 2435
2531 if (setup_cpu_cache(cachep, gfp)) { 2436 if (setup_cpu_cache(cachep, gfp)) {
2532 __kmem_cache_destroy(cachep); 2437 __kmem_cache_destroy(cachep);
2533 cachep = NULL; 2438 return NULL;
2534 goto oops;
2535 } 2439 }
2536 2440
2537 if (flags & SLAB_DEBUG_OBJECTS) { 2441 if (flags & SLAB_DEBUG_OBJECTS) {
@@ -2545,18 +2449,9 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2545 } 2449 }
2546 2450
2547 /* cache setup completed, link it into the list */ 2451 /* cache setup completed, link it into the list */
2548 list_add(&cachep->next, &cache_chain); 2452 list_add(&cachep->list, &slab_caches);
2549oops:
2550 if (!cachep && (flags & SLAB_PANIC))
2551 panic("kmem_cache_create(): failed to create slab `%s'\n",
2552 name);
2553 if (slab_is_available()) {
2554 mutex_unlock(&cache_chain_mutex);
2555 put_online_cpus();
2556 }
2557 return cachep; 2453 return cachep;
2558} 2454}
2559EXPORT_SYMBOL(kmem_cache_create);
2560 2455
2561#if DEBUG 2456#if DEBUG
2562static void check_irq_off(void) 2457static void check_irq_off(void)
@@ -2671,7 +2566,7 @@ out:
2671 return nr_freed; 2566 return nr_freed;
2672} 2567}
2673 2568
2674/* Called with cache_chain_mutex held to protect against cpu hotplug */ 2569/* Called with slab_mutex held to protect against cpu hotplug */
2675static int __cache_shrink(struct kmem_cache *cachep) 2570static int __cache_shrink(struct kmem_cache *cachep)
2676{ 2571{
2677 int ret = 0, i = 0; 2572 int ret = 0, i = 0;
@@ -2706,9 +2601,9 @@ int kmem_cache_shrink(struct kmem_cache *cachep)
2706 BUG_ON(!cachep || in_interrupt()); 2601 BUG_ON(!cachep || in_interrupt());
2707 2602
2708 get_online_cpus(); 2603 get_online_cpus();
2709 mutex_lock(&cache_chain_mutex); 2604 mutex_lock(&slab_mutex);
2710 ret = __cache_shrink(cachep); 2605 ret = __cache_shrink(cachep);
2711 mutex_unlock(&cache_chain_mutex); 2606 mutex_unlock(&slab_mutex);
2712 put_online_cpus(); 2607 put_online_cpus();
2713 return ret; 2608 return ret;
2714} 2609}
@@ -2736,15 +2631,15 @@ void kmem_cache_destroy(struct kmem_cache *cachep)
2736 2631
2737 /* Find the cache in the chain of caches. */ 2632 /* Find the cache in the chain of caches. */
2738 get_online_cpus(); 2633 get_online_cpus();
2739 mutex_lock(&cache_chain_mutex); 2634 mutex_lock(&slab_mutex);
2740 /* 2635 /*
2741 * the chain is never empty, cache_cache is never destroyed 2636 * the chain is never empty, cache_cache is never destroyed
2742 */ 2637 */
2743 list_del(&cachep->next); 2638 list_del(&cachep->list);
2744 if (__cache_shrink(cachep)) { 2639 if (__cache_shrink(cachep)) {
2745 slab_error(cachep, "Can't free all objects"); 2640 slab_error(cachep, "Can't free all objects");
2746 list_add(&cachep->next, &cache_chain); 2641 list_add(&cachep->list, &slab_caches);
2747 mutex_unlock(&cache_chain_mutex); 2642 mutex_unlock(&slab_mutex);
2748 put_online_cpus(); 2643 put_online_cpus();
2749 return; 2644 return;
2750 } 2645 }
@@ -2753,7 +2648,7 @@ void kmem_cache_destroy(struct kmem_cache *cachep)
2753 rcu_barrier(); 2648 rcu_barrier();
2754 2649
2755 __kmem_cache_destroy(cachep); 2650 __kmem_cache_destroy(cachep);
2756 mutex_unlock(&cache_chain_mutex); 2651 mutex_unlock(&slab_mutex);
2757 put_online_cpus(); 2652 put_online_cpus();
2758} 2653}
2759EXPORT_SYMBOL(kmem_cache_destroy); 2654EXPORT_SYMBOL(kmem_cache_destroy);
@@ -2840,10 +2735,10 @@ static void cache_init_objs(struct kmem_cache *cachep,
2840 slab_error(cachep, "constructor overwrote the" 2735 slab_error(cachep, "constructor overwrote the"
2841 " start of an object"); 2736 " start of an object");
2842 } 2737 }
2843 if ((cachep->buffer_size % PAGE_SIZE) == 0 && 2738 if ((cachep->size % PAGE_SIZE) == 0 &&
2844 OFF_SLAB(cachep) && cachep->flags & SLAB_POISON) 2739 OFF_SLAB(cachep) && cachep->flags & SLAB_POISON)
2845 kernel_map_pages(virt_to_page(objp), 2740 kernel_map_pages(virt_to_page(objp),
2846 cachep->buffer_size / PAGE_SIZE, 0); 2741 cachep->size / PAGE_SIZE, 0);
2847#else 2742#else
2848 if (cachep->ctor) 2743 if (cachep->ctor)
2849 cachep->ctor(objp); 2744 cachep->ctor(objp);
@@ -2857,9 +2752,9 @@ static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags)
2857{ 2752{
2858 if (CONFIG_ZONE_DMA_FLAG) { 2753 if (CONFIG_ZONE_DMA_FLAG) {
2859 if (flags & GFP_DMA) 2754 if (flags & GFP_DMA)
2860 BUG_ON(!(cachep->gfpflags & GFP_DMA)); 2755 BUG_ON(!(cachep->allocflags & GFP_DMA));
2861 else 2756 else
2862 BUG_ON(cachep->gfpflags & GFP_DMA); 2757 BUG_ON(cachep->allocflags & GFP_DMA);
2863 } 2758 }
2864} 2759}
2865 2760
@@ -2918,8 +2813,8 @@ static void slab_map_pages(struct kmem_cache *cache, struct slab *slab,
2918 nr_pages <<= cache->gfporder; 2813 nr_pages <<= cache->gfporder;
2919 2814
2920 do { 2815 do {
2921 page_set_cache(page, cache); 2816 page->slab_cache = cache;
2922 page_set_slab(page, slab); 2817 page->slab_page = slab;
2923 page++; 2818 page++;
2924 } while (--nr_pages); 2819 } while (--nr_pages);
2925} 2820}
@@ -3057,7 +2952,7 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
3057 kfree_debugcheck(objp); 2952 kfree_debugcheck(objp);
3058 page = virt_to_head_page(objp); 2953 page = virt_to_head_page(objp);
3059 2954
3060 slabp = page_get_slab(page); 2955 slabp = page->slab_page;
3061 2956
3062 if (cachep->flags & SLAB_RED_ZONE) { 2957 if (cachep->flags & SLAB_RED_ZONE) {
3063 verify_redzone_free(cachep, objp); 2958 verify_redzone_free(cachep, objp);
@@ -3077,10 +2972,10 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
3077#endif 2972#endif
3078 if (cachep->flags & SLAB_POISON) { 2973 if (cachep->flags & SLAB_POISON) {
3079#ifdef CONFIG_DEBUG_PAGEALLOC 2974#ifdef CONFIG_DEBUG_PAGEALLOC
3080 if ((cachep->buffer_size % PAGE_SIZE)==0 && OFF_SLAB(cachep)) { 2975 if ((cachep->size % PAGE_SIZE)==0 && OFF_SLAB(cachep)) {
3081 store_stackinfo(cachep, objp, (unsigned long)caller); 2976 store_stackinfo(cachep, objp, (unsigned long)caller);
3082 kernel_map_pages(virt_to_page(objp), 2977 kernel_map_pages(virt_to_page(objp),
3083 cachep->buffer_size / PAGE_SIZE, 0); 2978 cachep->size / PAGE_SIZE, 0);
3084 } else { 2979 } else {
3085 poison_obj(cachep, objp, POISON_FREE); 2980 poison_obj(cachep, objp, POISON_FREE);
3086 } 2981 }
@@ -3230,9 +3125,9 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
3230 return objp; 3125 return objp;
3231 if (cachep->flags & SLAB_POISON) { 3126 if (cachep->flags & SLAB_POISON) {
3232#ifdef CONFIG_DEBUG_PAGEALLOC 3127#ifdef CONFIG_DEBUG_PAGEALLOC
3233 if ((cachep->buffer_size % PAGE_SIZE) == 0 && OFF_SLAB(cachep)) 3128 if ((cachep->size % PAGE_SIZE) == 0 && OFF_SLAB(cachep))
3234 kernel_map_pages(virt_to_page(objp), 3129 kernel_map_pages(virt_to_page(objp),
3235 cachep->buffer_size / PAGE_SIZE, 1); 3130 cachep->size / PAGE_SIZE, 1);
3236 else 3131 else
3237 check_poison_obj(cachep, objp); 3132 check_poison_obj(cachep, objp);
3238#else 3133#else
@@ -3261,8 +3156,8 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
3261 struct slab *slabp; 3156 struct slab *slabp;
3262 unsigned objnr; 3157 unsigned objnr;
3263 3158
3264 slabp = page_get_slab(virt_to_head_page(objp)); 3159 slabp = virt_to_head_page(objp)->slab_page;
3265 objnr = (unsigned)(objp - slabp->s_mem) / cachep->buffer_size; 3160 objnr = (unsigned)(objp - slabp->s_mem) / cachep->size;
3266 slab_bufctl(slabp)[objnr] = BUFCTL_ACTIVE; 3161 slab_bufctl(slabp)[objnr] = BUFCTL_ACTIVE;
3267 } 3162 }
3268#endif 3163#endif
@@ -3285,7 +3180,7 @@ static bool slab_should_failslab(struct kmem_cache *cachep, gfp_t flags)
3285 if (cachep == &cache_cache) 3180 if (cachep == &cache_cache)
3286 return false; 3181 return false;
3287 3182
3288 return should_failslab(obj_size(cachep), flags, cachep->flags); 3183 return should_failslab(cachep->object_size, flags, cachep->flags);
3289} 3184}
3290 3185
3291static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags) 3186static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
@@ -3336,7 +3231,7 @@ static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
3336 if (cpuset_do_slab_mem_spread() && (cachep->flags & SLAB_MEM_SPREAD)) 3231 if (cpuset_do_slab_mem_spread() && (cachep->flags & SLAB_MEM_SPREAD))
3337 nid_alloc = cpuset_slab_spread_node(); 3232 nid_alloc = cpuset_slab_spread_node();
3338 else if (current->mempolicy) 3233 else if (current->mempolicy)
3339 nid_alloc = slab_node(current->mempolicy); 3234 nid_alloc = slab_node();
3340 if (nid_alloc != nid_here) 3235 if (nid_alloc != nid_here)
3341 return ____cache_alloc_node(cachep, flags, nid_alloc); 3236 return ____cache_alloc_node(cachep, flags, nid_alloc);
3342 return NULL; 3237 return NULL;
@@ -3368,7 +3263,7 @@ static void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
3368 3263
3369retry_cpuset: 3264retry_cpuset:
3370 cpuset_mems_cookie = get_mems_allowed(); 3265 cpuset_mems_cookie = get_mems_allowed();
3371 zonelist = node_zonelist(slab_node(current->mempolicy), flags); 3266 zonelist = node_zonelist(slab_node(), flags);
3372 3267
3373retry: 3268retry:
3374 /* 3269 /*
@@ -3545,14 +3440,14 @@ __cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid,
3545 out: 3440 out:
3546 local_irq_restore(save_flags); 3441 local_irq_restore(save_flags);
3547 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller); 3442 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
3548 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags, 3443 kmemleak_alloc_recursive(ptr, cachep->object_size, 1, cachep->flags,
3549 flags); 3444 flags);
3550 3445
3551 if (likely(ptr)) 3446 if (likely(ptr))
3552 kmemcheck_slab_alloc(cachep, flags, ptr, obj_size(cachep)); 3447 kmemcheck_slab_alloc(cachep, flags, ptr, cachep->object_size);
3553 3448
3554 if (unlikely((flags & __GFP_ZERO) && ptr)) 3449 if (unlikely((flags & __GFP_ZERO) && ptr))
3555 memset(ptr, 0, obj_size(cachep)); 3450 memset(ptr, 0, cachep->object_size);
3556 3451
3557 return ptr; 3452 return ptr;
3558} 3453}
@@ -3607,15 +3502,15 @@ __cache_alloc(struct kmem_cache *cachep, gfp_t flags, void *caller)
3607 objp = __do_cache_alloc(cachep, flags); 3502 objp = __do_cache_alloc(cachep, flags);
3608 local_irq_restore(save_flags); 3503 local_irq_restore(save_flags);
3609 objp = cache_alloc_debugcheck_after(cachep, flags, objp, caller); 3504 objp = cache_alloc_debugcheck_after(cachep, flags, objp, caller);
3610 kmemleak_alloc_recursive(objp, obj_size(cachep), 1, cachep->flags, 3505 kmemleak_alloc_recursive(objp, cachep->object_size, 1, cachep->flags,
3611 flags); 3506 flags);
3612 prefetchw(objp); 3507 prefetchw(objp);
3613 3508
3614 if (likely(objp)) 3509 if (likely(objp))
3615 kmemcheck_slab_alloc(cachep, flags, objp, obj_size(cachep)); 3510 kmemcheck_slab_alloc(cachep, flags, objp, cachep->object_size);
3616 3511
3617 if (unlikely((flags & __GFP_ZERO) && objp)) 3512 if (unlikely((flags & __GFP_ZERO) && objp))
3618 memset(objp, 0, obj_size(cachep)); 3513 memset(objp, 0, cachep->object_size);
3619 3514
3620 return objp; 3515 return objp;
3621} 3516}
@@ -3731,7 +3626,7 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
3731 kmemleak_free_recursive(objp, cachep->flags); 3626 kmemleak_free_recursive(objp, cachep->flags);
3732 objp = cache_free_debugcheck(cachep, objp, caller); 3627 objp = cache_free_debugcheck(cachep, objp, caller);
3733 3628
3734 kmemcheck_slab_free(cachep, objp, obj_size(cachep)); 3629 kmemcheck_slab_free(cachep, objp, cachep->object_size);
3735 3630
3736 /* 3631 /*
3737 * Skip calling cache_free_alien() when the platform is not numa. 3632 * Skip calling cache_free_alien() when the platform is not numa.
@@ -3766,7 +3661,7 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
3766 void *ret = __cache_alloc(cachep, flags, __builtin_return_address(0)); 3661 void *ret = __cache_alloc(cachep, flags, __builtin_return_address(0));
3767 3662
3768 trace_kmem_cache_alloc(_RET_IP_, ret, 3663 trace_kmem_cache_alloc(_RET_IP_, ret,
3769 obj_size(cachep), cachep->buffer_size, flags); 3664 cachep->object_size, cachep->size, flags);
3770 3665
3771 return ret; 3666 return ret;
3772} 3667}
@@ -3794,7 +3689,7 @@ void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
3794 __builtin_return_address(0)); 3689 __builtin_return_address(0));
3795 3690
3796 trace_kmem_cache_alloc_node(_RET_IP_, ret, 3691 trace_kmem_cache_alloc_node(_RET_IP_, ret,
3797 obj_size(cachep), cachep->buffer_size, 3692 cachep->object_size, cachep->size,
3798 flags, nodeid); 3693 flags, nodeid);
3799 3694
3800 return ret; 3695 return ret;
@@ -3876,7 +3771,7 @@ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,
3876 ret = __cache_alloc(cachep, flags, caller); 3771 ret = __cache_alloc(cachep, flags, caller);
3877 3772
3878 trace_kmalloc((unsigned long) caller, ret, 3773 trace_kmalloc((unsigned long) caller, ret,
3879 size, cachep->buffer_size, flags); 3774 size, cachep->size, flags);
3880 3775
3881 return ret; 3776 return ret;
3882} 3777}
@@ -3916,9 +3811,9 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp)
3916 unsigned long flags; 3811 unsigned long flags;
3917 3812
3918 local_irq_save(flags); 3813 local_irq_save(flags);
3919 debug_check_no_locks_freed(objp, obj_size(cachep)); 3814 debug_check_no_locks_freed(objp, cachep->object_size);
3920 if (!(cachep->flags & SLAB_DEBUG_OBJECTS)) 3815 if (!(cachep->flags & SLAB_DEBUG_OBJECTS))
3921 debug_check_no_obj_freed(objp, obj_size(cachep)); 3816 debug_check_no_obj_freed(objp, cachep->object_size);
3922 __cache_free(cachep, objp, __builtin_return_address(0)); 3817 __cache_free(cachep, objp, __builtin_return_address(0));
3923 local_irq_restore(flags); 3818 local_irq_restore(flags);
3924 3819
@@ -3947,8 +3842,9 @@ void kfree(const void *objp)
3947 local_irq_save(flags); 3842 local_irq_save(flags);
3948 kfree_debugcheck(objp); 3843 kfree_debugcheck(objp);
3949 c = virt_to_cache(objp); 3844 c = virt_to_cache(objp);
3950 debug_check_no_locks_freed(objp, obj_size(c)); 3845 debug_check_no_locks_freed(objp, c->object_size);
3951 debug_check_no_obj_freed(objp, obj_size(c)); 3846
3847 debug_check_no_obj_freed(objp, c->object_size);
3952 __cache_free(c, (void *)objp, __builtin_return_address(0)); 3848 __cache_free(c, (void *)objp, __builtin_return_address(0));
3953 local_irq_restore(flags); 3849 local_irq_restore(flags);
3954} 3850}
@@ -3956,7 +3852,7 @@ EXPORT_SYMBOL(kfree);
3956 3852
3957unsigned int kmem_cache_size(struct kmem_cache *cachep) 3853unsigned int kmem_cache_size(struct kmem_cache *cachep)
3958{ 3854{
3959 return obj_size(cachep); 3855 return cachep->object_size;
3960} 3856}
3961EXPORT_SYMBOL(kmem_cache_size); 3857EXPORT_SYMBOL(kmem_cache_size);
3962 3858
@@ -4030,7 +3926,7 @@ static int alloc_kmemlist(struct kmem_cache *cachep, gfp_t gfp)
4030 return 0; 3926 return 0;
4031 3927
4032fail: 3928fail:
4033 if (!cachep->next.next) { 3929 if (!cachep->list.next) {
4034 /* Cache is not active yet. Roll back what we did */ 3930 /* Cache is not active yet. Roll back what we did */
4035 node--; 3931 node--;
4036 while (node >= 0) { 3932 while (node >= 0) {
@@ -4065,7 +3961,7 @@ static void do_ccupdate_local(void *info)
4065 new->new[smp_processor_id()] = old; 3961 new->new[smp_processor_id()] = old;
4066} 3962}
4067 3963
4068/* Always called with the cache_chain_mutex held */ 3964/* Always called with the slab_mutex held */
4069static int do_tune_cpucache(struct kmem_cache *cachep, int limit, 3965static int do_tune_cpucache(struct kmem_cache *cachep, int limit,
4070 int batchcount, int shared, gfp_t gfp) 3966 int batchcount, int shared, gfp_t gfp)
4071{ 3967{
@@ -4109,7 +4005,7 @@ static int do_tune_cpucache(struct kmem_cache *cachep, int limit,
4109 return alloc_kmemlist(cachep, gfp); 4005 return alloc_kmemlist(cachep, gfp);
4110} 4006}
4111 4007
4112/* Called with cache_chain_mutex held always */ 4008/* Called with slab_mutex held always */
4113static int enable_cpucache(struct kmem_cache *cachep, gfp_t gfp) 4009static int enable_cpucache(struct kmem_cache *cachep, gfp_t gfp)
4114{ 4010{
4115 int err; 4011 int err;
@@ -4124,13 +4020,13 @@ static int enable_cpucache(struct kmem_cache *cachep, gfp_t gfp)
4124 * The numbers are guessed, we should auto-tune as described by 4020 * The numbers are guessed, we should auto-tune as described by
4125 * Bonwick. 4021 * Bonwick.
4126 */ 4022 */
4127 if (cachep->buffer_size > 131072) 4023 if (cachep->size > 131072)
4128 limit = 1; 4024 limit = 1;
4129 else if (cachep->buffer_size > PAGE_SIZE) 4025 else if (cachep->size > PAGE_SIZE)
4130 limit = 8; 4026 limit = 8;
4131 else if (cachep->buffer_size > 1024) 4027 else if (cachep->size > 1024)
4132 limit = 24; 4028 limit = 24;
4133 else if (cachep->buffer_size > 256) 4029 else if (cachep->size > 256)
4134 limit = 54; 4030 limit = 54;
4135 else 4031 else
4136 limit = 120; 4032 limit = 120;
@@ -4145,7 +4041,7 @@ static int enable_cpucache(struct kmem_cache *cachep, gfp_t gfp)
4145 * to a larger limit. Thus disabled by default. 4041 * to a larger limit. Thus disabled by default.
4146 */ 4042 */
4147 shared = 0; 4043 shared = 0;
4148 if (cachep->buffer_size <= PAGE_SIZE && num_possible_cpus() > 1) 4044 if (cachep->size <= PAGE_SIZE && num_possible_cpus() > 1)
4149 shared = 8; 4045 shared = 8;
4150 4046
4151#if DEBUG 4047#if DEBUG
@@ -4211,11 +4107,11 @@ static void cache_reap(struct work_struct *w)
4211 int node = numa_mem_id(); 4107 int node = numa_mem_id();
4212 struct delayed_work *work = to_delayed_work(w); 4108 struct delayed_work *work = to_delayed_work(w);
4213 4109
4214 if (!mutex_trylock(&cache_chain_mutex)) 4110 if (!mutex_trylock(&slab_mutex))
4215 /* Give up. Setup the next iteration. */ 4111 /* Give up. Setup the next iteration. */
4216 goto out; 4112 goto out;
4217 4113
4218 list_for_each_entry(searchp, &cache_chain, next) { 4114 list_for_each_entry(searchp, &slab_caches, list) {
4219 check_irq_on(); 4115 check_irq_on();
4220 4116
4221 /* 4117 /*
@@ -4253,7 +4149,7 @@ next:
4253 cond_resched(); 4149 cond_resched();
4254 } 4150 }
4255 check_irq_on(); 4151 check_irq_on();
4256 mutex_unlock(&cache_chain_mutex); 4152 mutex_unlock(&slab_mutex);
4257 next_reap_node(); 4153 next_reap_node();
4258out: 4154out:
4259 /* Set up the next iteration */ 4155 /* Set up the next iteration */
@@ -4289,26 +4185,26 @@ static void *s_start(struct seq_file *m, loff_t *pos)
4289{ 4185{
4290 loff_t n = *pos; 4186 loff_t n = *pos;
4291 4187
4292 mutex_lock(&cache_chain_mutex); 4188 mutex_lock(&slab_mutex);
4293 if (!n) 4189 if (!n)
4294 print_slabinfo_header(m); 4190 print_slabinfo_header(m);
4295 4191
4296 return seq_list_start(&cache_chain, *pos); 4192 return seq_list_start(&slab_caches, *pos);
4297} 4193}
4298 4194
4299static void *s_next(struct seq_file *m, void *p, loff_t *pos) 4195static void *s_next(struct seq_file *m, void *p, loff_t *pos)
4300{ 4196{
4301 return seq_list_next(p, &cache_chain, pos); 4197 return seq_list_next(p, &slab_caches, pos);
4302} 4198}
4303 4199
4304static void s_stop(struct seq_file *m, void *p) 4200static void s_stop(struct seq_file *m, void *p)
4305{ 4201{
4306 mutex_unlock(&cache_chain_mutex); 4202 mutex_unlock(&slab_mutex);
4307} 4203}
4308 4204
4309static int s_show(struct seq_file *m, void *p) 4205static int s_show(struct seq_file *m, void *p)
4310{ 4206{
4311 struct kmem_cache *cachep = list_entry(p, struct kmem_cache, next); 4207 struct kmem_cache *cachep = list_entry(p, struct kmem_cache, list);
4312 struct slab *slabp; 4208 struct slab *slabp;
4313 unsigned long active_objs; 4209 unsigned long active_objs;
4314 unsigned long num_objs; 4210 unsigned long num_objs;
@@ -4364,7 +4260,7 @@ static int s_show(struct seq_file *m, void *p)
4364 printk(KERN_ERR "slab: cache %s error: %s\n", name, error); 4260 printk(KERN_ERR "slab: cache %s error: %s\n", name, error);
4365 4261
4366 seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d", 4262 seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d",
4367 name, active_objs, num_objs, cachep->buffer_size, 4263 name, active_objs, num_objs, cachep->size,
4368 cachep->num, (1 << cachep->gfporder)); 4264 cachep->num, (1 << cachep->gfporder));
4369 seq_printf(m, " : tunables %4u %4u %4u", 4265 seq_printf(m, " : tunables %4u %4u %4u",
4370 cachep->limit, cachep->batchcount, cachep->shared); 4266 cachep->limit, cachep->batchcount, cachep->shared);
@@ -4454,9 +4350,9 @@ static ssize_t slabinfo_write(struct file *file, const char __user *buffer,
4454 return -EINVAL; 4350 return -EINVAL;
4455 4351
4456 /* Find the cache in the chain of caches. */ 4352 /* Find the cache in the chain of caches. */
4457 mutex_lock(&cache_chain_mutex); 4353 mutex_lock(&slab_mutex);
4458 res = -EINVAL; 4354 res = -EINVAL;
4459 list_for_each_entry(cachep, &cache_chain, next) { 4355 list_for_each_entry(cachep, &slab_caches, list) {
4460 if (!strcmp(cachep->name, kbuf)) { 4356 if (!strcmp(cachep->name, kbuf)) {
4461 if (limit < 1 || batchcount < 1 || 4357 if (limit < 1 || batchcount < 1 ||
4462 batchcount > limit || shared < 0) { 4358 batchcount > limit || shared < 0) {
@@ -4469,7 +4365,7 @@ static ssize_t slabinfo_write(struct file *file, const char __user *buffer,
4469 break; 4365 break;
4470 } 4366 }
4471 } 4367 }
4472 mutex_unlock(&cache_chain_mutex); 4368 mutex_unlock(&slab_mutex);
4473 if (res >= 0) 4369 if (res >= 0)
4474 res = count; 4370 res = count;
4475 return res; 4371 return res;
@@ -4492,8 +4388,8 @@ static const struct file_operations proc_slabinfo_operations = {
4492 4388
4493static void *leaks_start(struct seq_file *m, loff_t *pos) 4389static void *leaks_start(struct seq_file *m, loff_t *pos)
4494{ 4390{
4495 mutex_lock(&cache_chain_mutex); 4391 mutex_lock(&slab_mutex);
4496 return seq_list_start(&cache_chain, *pos); 4392 return seq_list_start(&slab_caches, *pos);
4497} 4393}
4498 4394
4499static inline int add_caller(unsigned long *n, unsigned long v) 4395static inline int add_caller(unsigned long *n, unsigned long v)
@@ -4532,7 +4428,7 @@ static void handle_slab(unsigned long *n, struct kmem_cache *c, struct slab *s)
4532 int i; 4428 int i;
4533 if (n[0] == n[1]) 4429 if (n[0] == n[1])
4534 return; 4430 return;
4535 for (i = 0, p = s->s_mem; i < c->num; i++, p += c->buffer_size) { 4431 for (i = 0, p = s->s_mem; i < c->num; i++, p += c->size) {
4536 if (slab_bufctl(s)[i] != BUFCTL_ACTIVE) 4432 if (slab_bufctl(s)[i] != BUFCTL_ACTIVE)
4537 continue; 4433 continue;
4538 if (!add_caller(n, (unsigned long)*dbg_userword(c, p))) 4434 if (!add_caller(n, (unsigned long)*dbg_userword(c, p)))
@@ -4558,7 +4454,7 @@ static void show_symbol(struct seq_file *m, unsigned long address)
4558 4454
4559static int leaks_show(struct seq_file *m, void *p) 4455static int leaks_show(struct seq_file *m, void *p)
4560{ 4456{
4561 struct kmem_cache *cachep = list_entry(p, struct kmem_cache, next); 4457 struct kmem_cache *cachep = list_entry(p, struct kmem_cache, list);
4562 struct slab *slabp; 4458 struct slab *slabp;
4563 struct kmem_list3 *l3; 4459 struct kmem_list3 *l3;
4564 const char *name; 4460 const char *name;
@@ -4592,17 +4488,17 @@ static int leaks_show(struct seq_file *m, void *p)
4592 name = cachep->name; 4488 name = cachep->name;
4593 if (n[0] == n[1]) { 4489 if (n[0] == n[1]) {
4594 /* Increase the buffer size */ 4490 /* Increase the buffer size */
4595 mutex_unlock(&cache_chain_mutex); 4491 mutex_unlock(&slab_mutex);
4596 m->private = kzalloc(n[0] * 4 * sizeof(unsigned long), GFP_KERNEL); 4492 m->private = kzalloc(n[0] * 4 * sizeof(unsigned long), GFP_KERNEL);
4597 if (!m->private) { 4493 if (!m->private) {
4598 /* Too bad, we are really out */ 4494 /* Too bad, we are really out */
4599 m->private = n; 4495 m->private = n;
4600 mutex_lock(&cache_chain_mutex); 4496 mutex_lock(&slab_mutex);
4601 return -ENOMEM; 4497 return -ENOMEM;
4602 } 4498 }
4603 *(unsigned long *)m->private = n[0] * 2; 4499 *(unsigned long *)m->private = n[0] * 2;
4604 kfree(n); 4500 kfree(n);
4605 mutex_lock(&cache_chain_mutex); 4501 mutex_lock(&slab_mutex);
4606 /* Now make sure this entry will be retried */ 4502 /* Now make sure this entry will be retried */
4607 m->count = m->size; 4503 m->count = m->size;
4608 return 0; 4504 return 0;
@@ -4677,6 +4573,6 @@ size_t ksize(const void *objp)
4677 if (unlikely(objp == ZERO_SIZE_PTR)) 4573 if (unlikely(objp == ZERO_SIZE_PTR))
4678 return 0; 4574 return 0;
4679 4575
4680 return obj_size(virt_to_cache(objp)); 4576 return virt_to_cache(objp)->object_size;
4681} 4577}
4682EXPORT_SYMBOL(ksize); 4578EXPORT_SYMBOL(ksize);
diff --git a/mm/slab.h b/mm/slab.h
new file mode 100644
index 000000000000..db7848caaa25
--- /dev/null
+++ b/mm/slab.h
@@ -0,0 +1,33 @@
1#ifndef MM_SLAB_H
2#define MM_SLAB_H
3/*
4 * Internal slab definitions
5 */
6
7/*
8 * State of the slab allocator.
9 *
10 * This is used to describe the states of the allocator during bootup.
11 * Allocators use this to gradually bootstrap themselves. Most allocators
12 * have the problem that the structures used for managing slab caches are
13 * allocated from slab caches themselves.
14 */
15enum slab_state {
16 DOWN, /* No slab functionality yet */
17 PARTIAL, /* SLUB: kmem_cache_node available */
18 PARTIAL_ARRAYCACHE, /* SLAB: kmalloc size for arraycache available */
19 PARTIAL_L3, /* SLAB: kmalloc size for l3 struct available */
20 UP, /* Slab caches usable but not all extras yet */
21 FULL /* Everything is working */
22};
23
24extern enum slab_state slab_state;
25
26/* The slab cache mutex protects the management structures during changes */
27extern struct mutex slab_mutex;
28extern struct list_head slab_caches;
29
30struct kmem_cache *__kmem_cache_create(const char *name, size_t size,
31 size_t align, unsigned long flags, void (*ctor)(void *));
32
33#endif
diff --git a/mm/slab_common.c b/mm/slab_common.c
new file mode 100644
index 000000000000..aa3ca5bb01b5
--- /dev/null
+++ b/mm/slab_common.c
@@ -0,0 +1,120 @@
1/*
2 * Slab allocator functions that are independent of the allocator strategy
3 *
4 * (C) 2012 Christoph Lameter <cl@linux.com>
5 */
6#include <linux/slab.h>
7
8#include <linux/mm.h>
9#include <linux/poison.h>
10#include <linux/interrupt.h>
11#include <linux/memory.h>
12#include <linux/compiler.h>
13#include <linux/module.h>
14#include <linux/cpu.h>
15#include <linux/uaccess.h>
16#include <asm/cacheflush.h>
17#include <asm/tlbflush.h>
18#include <asm/page.h>
19
20#include "slab.h"
21
22enum slab_state slab_state;
23LIST_HEAD(slab_caches);
24DEFINE_MUTEX(slab_mutex);
25
26/*
27 * kmem_cache_create - Create a cache.
28 * @name: A string which is used in /proc/slabinfo to identify this cache.
29 * @size: The size of objects to be created in this cache.
30 * @align: The required alignment for the objects.
31 * @flags: SLAB flags
32 * @ctor: A constructor for the objects.
33 *
34 * Returns a ptr to the cache on success, NULL on failure.
35 * Cannot be called within a interrupt, but can be interrupted.
36 * The @ctor is run when new pages are allocated by the cache.
37 *
38 * The flags are
39 *
40 * %SLAB_POISON - Poison the slab with a known test pattern (a5a5a5a5)
41 * to catch references to uninitialised memory.
42 *
43 * %SLAB_RED_ZONE - Insert `Red' zones around the allocated memory to check
44 * for buffer overruns.
45 *
46 * %SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware
47 * cacheline. This can be beneficial if you're counting cycles as closely
48 * as davem.
49 */
50
51struct kmem_cache *kmem_cache_create(const char *name, size_t size, size_t align,
52 unsigned long flags, void (*ctor)(void *))
53{
54 struct kmem_cache *s = NULL;
55
56#ifdef CONFIG_DEBUG_VM
57 if (!name || in_interrupt() || size < sizeof(void *) ||
58 size > KMALLOC_MAX_SIZE) {
59 printk(KERN_ERR "kmem_cache_create(%s) integrity check"
60 " failed\n", name);
61 goto out;
62 }
63#endif
64
65 get_online_cpus();
66 mutex_lock(&slab_mutex);
67
68#ifdef CONFIG_DEBUG_VM
69 list_for_each_entry(s, &slab_caches, list) {
70 char tmp;
71 int res;
72
73 /*
74 * This happens when the module gets unloaded and doesn't
75 * destroy its slab cache and no-one else reuses the vmalloc
76 * area of the module. Print a warning.
77 */
78 res = probe_kernel_address(s->name, tmp);
79 if (res) {
80 printk(KERN_ERR
81 "Slab cache with size %d has lost its name\n",
82 s->object_size);
83 continue;
84 }
85
86 if (!strcmp(s->name, name)) {
87 printk(KERN_ERR "kmem_cache_create(%s): Cache name"
88 " already exists.\n",
89 name);
90 dump_stack();
91 s = NULL;
92 goto oops;
93 }
94 }
95
96 WARN_ON(strchr(name, ' ')); /* It confuses parsers */
97#endif
98
99 s = __kmem_cache_create(name, size, align, flags, ctor);
100
101#ifdef CONFIG_DEBUG_VM
102oops:
103#endif
104 mutex_unlock(&slab_mutex);
105 put_online_cpus();
106
107#ifdef CONFIG_DEBUG_VM
108out:
109#endif
110 if (!s && (flags & SLAB_PANIC))
111 panic("kmem_cache_create: Failed to create slab '%s'\n", name);
112
113 return s;
114}
115EXPORT_SYMBOL(kmem_cache_create);
116
117int slab_is_available(void)
118{
119 return slab_state >= UP;
120}
diff --git a/mm/slob.c b/mm/slob.c
index 8105be42cad1..45d4ca79933a 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -59,6 +59,8 @@
59 59
60#include <linux/kernel.h> 60#include <linux/kernel.h>
61#include <linux/slab.h> 61#include <linux/slab.h>
62#include "slab.h"
63
62#include <linux/mm.h> 64#include <linux/mm.h>
63#include <linux/swap.h> /* struct reclaim_state */ 65#include <linux/swap.h> /* struct reclaim_state */
64#include <linux/cache.h> 66#include <linux/cache.h>
@@ -92,36 +94,6 @@ struct slob_block {
92typedef struct slob_block slob_t; 94typedef struct slob_block slob_t;
93 95
94/* 96/*
95 * We use struct page fields to manage some slob allocation aspects,
96 * however to avoid the horrible mess in include/linux/mm_types.h, we'll
97 * just define our own struct page type variant here.
98 */
99struct slob_page {
100 union {
101 struct {
102 unsigned long flags; /* mandatory */
103 atomic_t _count; /* mandatory */
104 slobidx_t units; /* free units left in page */
105 unsigned long pad[2];
106 slob_t *free; /* first free slob_t in page */
107 struct list_head list; /* linked list of free pages */
108 };
109 struct page page;
110 };
111};
112static inline void struct_slob_page_wrong_size(void)
113{ BUILD_BUG_ON(sizeof(struct slob_page) != sizeof(struct page)); }
114
115/*
116 * free_slob_page: call before a slob_page is returned to the page allocator.
117 */
118static inline void free_slob_page(struct slob_page *sp)
119{
120 reset_page_mapcount(&sp->page);
121 sp->page.mapping = NULL;
122}
123
124/*
125 * All partially free slob pages go on these lists. 97 * All partially free slob pages go on these lists.
126 */ 98 */
127#define SLOB_BREAK1 256 99#define SLOB_BREAK1 256
@@ -131,46 +103,23 @@ static LIST_HEAD(free_slob_medium);
131static LIST_HEAD(free_slob_large); 103static LIST_HEAD(free_slob_large);
132 104
133/* 105/*
134 * is_slob_page: True for all slob pages (false for bigblock pages)
135 */
136static inline int is_slob_page(struct slob_page *sp)
137{
138 return PageSlab((struct page *)sp);
139}
140
141static inline void set_slob_page(struct slob_page *sp)
142{
143 __SetPageSlab((struct page *)sp);
144}
145
146static inline void clear_slob_page(struct slob_page *sp)
147{
148 __ClearPageSlab((struct page *)sp);
149}
150
151static inline struct slob_page *slob_page(const void *addr)
152{
153 return (struct slob_page *)virt_to_page(addr);
154}
155
156/*
157 * slob_page_free: true for pages on free_slob_pages list. 106 * slob_page_free: true for pages on free_slob_pages list.
158 */ 107 */
159static inline int slob_page_free(struct slob_page *sp) 108static inline int slob_page_free(struct page *sp)
160{ 109{
161 return PageSlobFree((struct page *)sp); 110 return PageSlobFree(sp);
162} 111}
163 112
164static void set_slob_page_free(struct slob_page *sp, struct list_head *list) 113static void set_slob_page_free(struct page *sp, struct list_head *list)
165{ 114{
166 list_add(&sp->list, list); 115 list_add(&sp->list, list);
167 __SetPageSlobFree((struct page *)sp); 116 __SetPageSlobFree(sp);
168} 117}
169 118
170static inline void clear_slob_page_free(struct slob_page *sp) 119static inline void clear_slob_page_free(struct page *sp)
171{ 120{
172 list_del(&sp->list); 121 list_del(&sp->list);
173 __ClearPageSlobFree((struct page *)sp); 122 __ClearPageSlobFree(sp);
174} 123}
175 124
176#define SLOB_UNIT sizeof(slob_t) 125#define SLOB_UNIT sizeof(slob_t)
@@ -267,12 +216,12 @@ static void slob_free_pages(void *b, int order)
267/* 216/*
268 * Allocate a slob block within a given slob_page sp. 217 * Allocate a slob block within a given slob_page sp.
269 */ 218 */
270static void *slob_page_alloc(struct slob_page *sp, size_t size, int align) 219static void *slob_page_alloc(struct page *sp, size_t size, int align)
271{ 220{
272 slob_t *prev, *cur, *aligned = NULL; 221 slob_t *prev, *cur, *aligned = NULL;
273 int delta = 0, units = SLOB_UNITS(size); 222 int delta = 0, units = SLOB_UNITS(size);
274 223
275 for (prev = NULL, cur = sp->free; ; prev = cur, cur = slob_next(cur)) { 224 for (prev = NULL, cur = sp->freelist; ; prev = cur, cur = slob_next(cur)) {
276 slobidx_t avail = slob_units(cur); 225 slobidx_t avail = slob_units(cur);
277 226
278 if (align) { 227 if (align) {
@@ -296,12 +245,12 @@ static void *slob_page_alloc(struct slob_page *sp, size_t size, int align)
296 if (prev) 245 if (prev)
297 set_slob(prev, slob_units(prev), next); 246 set_slob(prev, slob_units(prev), next);
298 else 247 else
299 sp->free = next; 248 sp->freelist = next;
300 } else { /* fragment */ 249 } else { /* fragment */
301 if (prev) 250 if (prev)
302 set_slob(prev, slob_units(prev), cur + units); 251 set_slob(prev, slob_units(prev), cur + units);
303 else 252 else
304 sp->free = cur + units; 253 sp->freelist = cur + units;
305 set_slob(cur + units, avail - units, next); 254 set_slob(cur + units, avail - units, next);
306 } 255 }
307 256
@@ -320,7 +269,7 @@ static void *slob_page_alloc(struct slob_page *sp, size_t size, int align)
320 */ 269 */
321static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) 270static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
322{ 271{
323 struct slob_page *sp; 272 struct page *sp;
324 struct list_head *prev; 273 struct list_head *prev;
325 struct list_head *slob_list; 274 struct list_head *slob_list;
326 slob_t *b = NULL; 275 slob_t *b = NULL;
@@ -341,7 +290,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
341 * If there's a node specification, search for a partial 290 * If there's a node specification, search for a partial
342 * page with a matching node id in the freelist. 291 * page with a matching node id in the freelist.
343 */ 292 */
344 if (node != -1 && page_to_nid(&sp->page) != node) 293 if (node != -1 && page_to_nid(sp) != node)
345 continue; 294 continue;
346#endif 295#endif
347 /* Enough room on this page? */ 296 /* Enough room on this page? */
@@ -369,12 +318,12 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
369 b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node); 318 b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
370 if (!b) 319 if (!b)
371 return NULL; 320 return NULL;
372 sp = slob_page(b); 321 sp = virt_to_page(b);
373 set_slob_page(sp); 322 __SetPageSlab(sp);
374 323
375 spin_lock_irqsave(&slob_lock, flags); 324 spin_lock_irqsave(&slob_lock, flags);
376 sp->units = SLOB_UNITS(PAGE_SIZE); 325 sp->units = SLOB_UNITS(PAGE_SIZE);
377 sp->free = b; 326 sp->freelist = b;
378 INIT_LIST_HEAD(&sp->list); 327 INIT_LIST_HEAD(&sp->list);
379 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE)); 328 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
380 set_slob_page_free(sp, slob_list); 329 set_slob_page_free(sp, slob_list);
@@ -392,7 +341,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
392 */ 341 */
393static void slob_free(void *block, int size) 342static void slob_free(void *block, int size)
394{ 343{
395 struct slob_page *sp; 344 struct page *sp;
396 slob_t *prev, *next, *b = (slob_t *)block; 345 slob_t *prev, *next, *b = (slob_t *)block;
397 slobidx_t units; 346 slobidx_t units;
398 unsigned long flags; 347 unsigned long flags;
@@ -402,7 +351,7 @@ static void slob_free(void *block, int size)
402 return; 351 return;
403 BUG_ON(!size); 352 BUG_ON(!size);
404 353
405 sp = slob_page(block); 354 sp = virt_to_page(block);
406 units = SLOB_UNITS(size); 355 units = SLOB_UNITS(size);
407 356
408 spin_lock_irqsave(&slob_lock, flags); 357 spin_lock_irqsave(&slob_lock, flags);
@@ -412,8 +361,8 @@ static void slob_free(void *block, int size)
412 if (slob_page_free(sp)) 361 if (slob_page_free(sp))
413 clear_slob_page_free(sp); 362 clear_slob_page_free(sp);
414 spin_unlock_irqrestore(&slob_lock, flags); 363 spin_unlock_irqrestore(&slob_lock, flags);
415 clear_slob_page(sp); 364 __ClearPageSlab(sp);
416 free_slob_page(sp); 365 reset_page_mapcount(sp);
417 slob_free_pages(b, 0); 366 slob_free_pages(b, 0);
418 return; 367 return;
419 } 368 }
@@ -421,7 +370,7 @@ static void slob_free(void *block, int size)
421 if (!slob_page_free(sp)) { 370 if (!slob_page_free(sp)) {
422 /* This slob page is about to become partially free. Easy! */ 371 /* This slob page is about to become partially free. Easy! */
423 sp->units = units; 372 sp->units = units;
424 sp->free = b; 373 sp->freelist = b;
425 set_slob(b, units, 374 set_slob(b, units,
426 (void *)((unsigned long)(b + 375 (void *)((unsigned long)(b +
427 SLOB_UNITS(PAGE_SIZE)) & PAGE_MASK)); 376 SLOB_UNITS(PAGE_SIZE)) & PAGE_MASK));
@@ -441,15 +390,15 @@ static void slob_free(void *block, int size)
441 */ 390 */
442 sp->units += units; 391 sp->units += units;
443 392
444 if (b < sp->free) { 393 if (b < (slob_t *)sp->freelist) {
445 if (b + units == sp->free) { 394 if (b + units == sp->freelist) {
446 units += slob_units(sp->free); 395 units += slob_units(sp->freelist);
447 sp->free = slob_next(sp->free); 396 sp->freelist = slob_next(sp->freelist);
448 } 397 }
449 set_slob(b, units, sp->free); 398 set_slob(b, units, sp->freelist);
450 sp->free = b; 399 sp->freelist = b;
451 } else { 400 } else {
452 prev = sp->free; 401 prev = sp->freelist;
453 next = slob_next(prev); 402 next = slob_next(prev);
454 while (b > next) { 403 while (b > next) {
455 prev = next; 404 prev = next;
@@ -522,7 +471,7 @@ EXPORT_SYMBOL(__kmalloc_node);
522 471
523void kfree(const void *block) 472void kfree(const void *block)
524{ 473{
525 struct slob_page *sp; 474 struct page *sp;
526 475
527 trace_kfree(_RET_IP_, block); 476 trace_kfree(_RET_IP_, block);
528 477
@@ -530,43 +479,36 @@ void kfree(const void *block)
530 return; 479 return;
531 kmemleak_free(block); 480 kmemleak_free(block);
532 481
533 sp = slob_page(block); 482 sp = virt_to_page(block);
534 if (is_slob_page(sp)) { 483 if (PageSlab(sp)) {
535 int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN); 484 int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
536 unsigned int *m = (unsigned int *)(block - align); 485 unsigned int *m = (unsigned int *)(block - align);
537 slob_free(m, *m + align); 486 slob_free(m, *m + align);
538 } else 487 } else
539 put_page(&sp->page); 488 put_page(sp);
540} 489}
541EXPORT_SYMBOL(kfree); 490EXPORT_SYMBOL(kfree);
542 491
543/* can't use ksize for kmem_cache_alloc memory, only kmalloc */ 492/* can't use ksize for kmem_cache_alloc memory, only kmalloc */
544size_t ksize(const void *block) 493size_t ksize(const void *block)
545{ 494{
546 struct slob_page *sp; 495 struct page *sp;
547 496
548 BUG_ON(!block); 497 BUG_ON(!block);
549 if (unlikely(block == ZERO_SIZE_PTR)) 498 if (unlikely(block == ZERO_SIZE_PTR))
550 return 0; 499 return 0;
551 500
552 sp = slob_page(block); 501 sp = virt_to_page(block);
553 if (is_slob_page(sp)) { 502 if (PageSlab(sp)) {
554 int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN); 503 int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
555 unsigned int *m = (unsigned int *)(block - align); 504 unsigned int *m = (unsigned int *)(block - align);
556 return SLOB_UNITS(*m) * SLOB_UNIT; 505 return SLOB_UNITS(*m) * SLOB_UNIT;
557 } else 506 } else
558 return sp->page.private; 507 return sp->private;
559} 508}
560EXPORT_SYMBOL(ksize); 509EXPORT_SYMBOL(ksize);
561 510
562struct kmem_cache { 511struct kmem_cache *__kmem_cache_create(const char *name, size_t size,
563 unsigned int size, align;
564 unsigned long flags;
565 const char *name;
566 void (*ctor)(void *);
567};
568
569struct kmem_cache *kmem_cache_create(const char *name, size_t size,
570 size_t align, unsigned long flags, void (*ctor)(void *)) 512 size_t align, unsigned long flags, void (*ctor)(void *))
571{ 513{
572 struct kmem_cache *c; 514 struct kmem_cache *c;
@@ -589,13 +531,12 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
589 c->align = ARCH_SLAB_MINALIGN; 531 c->align = ARCH_SLAB_MINALIGN;
590 if (c->align < align) 532 if (c->align < align)
591 c->align = align; 533 c->align = align;
592 } else if (flags & SLAB_PANIC)
593 panic("Cannot create slab cache %s\n", name);
594 534
595 kmemleak_alloc(c, sizeof(struct kmem_cache), 1, GFP_KERNEL); 535 kmemleak_alloc(c, sizeof(struct kmem_cache), 1, GFP_KERNEL);
536 c->refcount = 1;
537 }
596 return c; 538 return c;
597} 539}
598EXPORT_SYMBOL(kmem_cache_create);
599 540
600void kmem_cache_destroy(struct kmem_cache *c) 541void kmem_cache_destroy(struct kmem_cache *c)
601{ 542{
@@ -678,19 +619,12 @@ int kmem_cache_shrink(struct kmem_cache *d)
678} 619}
679EXPORT_SYMBOL(kmem_cache_shrink); 620EXPORT_SYMBOL(kmem_cache_shrink);
680 621
681static unsigned int slob_ready __read_mostly;
682
683int slab_is_available(void)
684{
685 return slob_ready;
686}
687
688void __init kmem_cache_init(void) 622void __init kmem_cache_init(void)
689{ 623{
690 slob_ready = 1; 624 slab_state = UP;
691} 625}
692 626
693void __init kmem_cache_init_late(void) 627void __init kmem_cache_init_late(void)
694{ 628{
695 /* Nothing to do */ 629 slab_state = FULL;
696} 630}
diff --git a/mm/slub.c b/mm/slub.c
index 8c691fa1cf3c..e517d435e5dc 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -16,6 +16,7 @@
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/bitops.h> 17#include <linux/bitops.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include "slab.h"
19#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
20#include <linux/seq_file.h> 21#include <linux/seq_file.h>
21#include <linux/kmemcheck.h> 22#include <linux/kmemcheck.h>
@@ -35,13 +36,13 @@
35 36
36/* 37/*
37 * Lock order: 38 * Lock order:
38 * 1. slub_lock (Global Semaphore) 39 * 1. slab_mutex (Global Mutex)
39 * 2. node->list_lock 40 * 2. node->list_lock
40 * 3. slab_lock(page) (Only on some arches and for debugging) 41 * 3. slab_lock(page) (Only on some arches and for debugging)
41 * 42 *
42 * slub_lock 43 * slab_mutex
43 * 44 *
44 * The role of the slub_lock is to protect the list of all the slabs 45 * The role of the slab_mutex is to protect the list of all the slabs
45 * and to synchronize major metadata changes to slab cache structures. 46 * and to synchronize major metadata changes to slab cache structures.
46 * 47 *
47 * The slab_lock is only used for debugging and on arches that do not 48 * The slab_lock is only used for debugging and on arches that do not
@@ -182,17 +183,6 @@ static int kmem_size = sizeof(struct kmem_cache);
182static struct notifier_block slab_notifier; 183static struct notifier_block slab_notifier;
183#endif 184#endif
184 185
185static enum {
186 DOWN, /* No slab functionality available */
187 PARTIAL, /* Kmem_cache_node works */
188 UP, /* Everything works but does not show up in sysfs */
189 SYSFS /* Sysfs up */
190} slab_state = DOWN;
191
192/* A list of all slab caches on the system */
193static DECLARE_RWSEM(slub_lock);
194static LIST_HEAD(slab_caches);
195
196/* 186/*
197 * Tracking user of a slab. 187 * Tracking user of a slab.
198 */ 188 */
@@ -237,11 +227,6 @@ static inline void stat(const struct kmem_cache *s, enum stat_item si)
237 * Core slab cache functions 227 * Core slab cache functions
238 *******************************************************************/ 228 *******************************************************************/
239 229
240int slab_is_available(void)
241{
242 return slab_state >= UP;
243}
244
245static inline struct kmem_cache_node *get_node(struct kmem_cache *s, int node) 230static inline struct kmem_cache_node *get_node(struct kmem_cache *s, int node)
246{ 231{
247 return s->node[node]; 232 return s->node[node];
@@ -311,7 +296,7 @@ static inline size_t slab_ksize(const struct kmem_cache *s)
311 * and whatever may come after it. 296 * and whatever may come after it.
312 */ 297 */
313 if (s->flags & (SLAB_RED_ZONE | SLAB_POISON)) 298 if (s->flags & (SLAB_RED_ZONE | SLAB_POISON))
314 return s->objsize; 299 return s->object_size;
315 300
316#endif 301#endif
317 /* 302 /*
@@ -609,11 +594,11 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p)
609 if (p > addr + 16) 594 if (p > addr + 16)
610 print_section("Bytes b4 ", p - 16, 16); 595 print_section("Bytes b4 ", p - 16, 16);
611 596
612 print_section("Object ", p, min_t(unsigned long, s->objsize, 597 print_section("Object ", p, min_t(unsigned long, s->object_size,
613 PAGE_SIZE)); 598 PAGE_SIZE));
614 if (s->flags & SLAB_RED_ZONE) 599 if (s->flags & SLAB_RED_ZONE)
615 print_section("Redzone ", p + s->objsize, 600 print_section("Redzone ", p + s->object_size,
616 s->inuse - s->objsize); 601 s->inuse - s->object_size);
617 602
618 if (s->offset) 603 if (s->offset)
619 off = s->offset + sizeof(void *); 604 off = s->offset + sizeof(void *);
@@ -655,12 +640,12 @@ static void init_object(struct kmem_cache *s, void *object, u8 val)
655 u8 *p = object; 640 u8 *p = object;
656 641
657 if (s->flags & __OBJECT_POISON) { 642 if (s->flags & __OBJECT_POISON) {
658 memset(p, POISON_FREE, s->objsize - 1); 643 memset(p, POISON_FREE, s->object_size - 1);
659 p[s->objsize - 1] = POISON_END; 644 p[s->object_size - 1] = POISON_END;
660 } 645 }
661 646
662 if (s->flags & SLAB_RED_ZONE) 647 if (s->flags & SLAB_RED_ZONE)
663 memset(p + s->objsize, val, s->inuse - s->objsize); 648 memset(p + s->object_size, val, s->inuse - s->object_size);
664} 649}
665 650
666static void restore_bytes(struct kmem_cache *s, char *message, u8 data, 651static void restore_bytes(struct kmem_cache *s, char *message, u8 data,
@@ -705,10 +690,10 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page,
705 * Poisoning uses 0x6b (POISON_FREE) and the last byte is 690 * Poisoning uses 0x6b (POISON_FREE) and the last byte is
706 * 0xa5 (POISON_END) 691 * 0xa5 (POISON_END)
707 * 692 *
708 * object + s->objsize 693 * object + s->object_size
709 * Padding to reach word boundary. This is also used for Redzoning. 694 * Padding to reach word boundary. This is also used for Redzoning.
710 * Padding is extended by another word if Redzoning is enabled and 695 * Padding is extended by another word if Redzoning is enabled and
711 * objsize == inuse. 696 * object_size == inuse.
712 * 697 *
713 * We fill with 0xbb (RED_INACTIVE) for inactive objects and with 698 * We fill with 0xbb (RED_INACTIVE) for inactive objects and with
714 * 0xcc (RED_ACTIVE) for objects in use. 699 * 0xcc (RED_ACTIVE) for objects in use.
@@ -727,7 +712,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page,
727 * object + s->size 712 * object + s->size
728 * Nothing is used beyond s->size. 713 * Nothing is used beyond s->size.
729 * 714 *
730 * If slabcaches are merged then the objsize and inuse boundaries are mostly 715 * If slabcaches are merged then the object_size and inuse boundaries are mostly
731 * ignored. And therefore no slab options that rely on these boundaries 716 * ignored. And therefore no slab options that rely on these boundaries
732 * may be used with merged slabcaches. 717 * may be used with merged slabcaches.
733 */ 718 */
@@ -787,25 +772,25 @@ static int check_object(struct kmem_cache *s, struct page *page,
787 void *object, u8 val) 772 void *object, u8 val)
788{ 773{
789 u8 *p = object; 774 u8 *p = object;
790 u8 *endobject = object + s->objsize; 775 u8 *endobject = object + s->object_size;
791 776
792 if (s->flags & SLAB_RED_ZONE) { 777 if (s->flags & SLAB_RED_ZONE) {
793 if (!check_bytes_and_report(s, page, object, "Redzone", 778 if (!check_bytes_and_report(s, page, object, "Redzone",
794 endobject, val, s->inuse - s->objsize)) 779 endobject, val, s->inuse - s->object_size))
795 return 0; 780 return 0;
796 } else { 781 } else {
797 if ((s->flags & SLAB_POISON) && s->objsize < s->inuse) { 782 if ((s->flags & SLAB_POISON) && s->object_size < s->inuse) {
798 check_bytes_and_report(s, page, p, "Alignment padding", 783 check_bytes_and_report(s, page, p, "Alignment padding",
799 endobject, POISON_INUSE, s->inuse - s->objsize); 784 endobject, POISON_INUSE, s->inuse - s->object_size);
800 } 785 }
801 } 786 }
802 787
803 if (s->flags & SLAB_POISON) { 788 if (s->flags & SLAB_POISON) {
804 if (val != SLUB_RED_ACTIVE && (s->flags & __OBJECT_POISON) && 789 if (val != SLUB_RED_ACTIVE && (s->flags & __OBJECT_POISON) &&
805 (!check_bytes_and_report(s, page, p, "Poison", p, 790 (!check_bytes_and_report(s, page, p, "Poison", p,
806 POISON_FREE, s->objsize - 1) || 791 POISON_FREE, s->object_size - 1) ||
807 !check_bytes_and_report(s, page, p, "Poison", 792 !check_bytes_and_report(s, page, p, "Poison",
808 p + s->objsize - 1, POISON_END, 1))) 793 p + s->object_size - 1, POISON_END, 1)))
809 return 0; 794 return 0;
810 /* 795 /*
811 * check_pad_bytes cleans up on its own. 796 * check_pad_bytes cleans up on its own.
@@ -926,7 +911,7 @@ static void trace(struct kmem_cache *s, struct page *page, void *object,
926 page->freelist); 911 page->freelist);
927 912
928 if (!alloc) 913 if (!alloc)
929 print_section("Object ", (void *)object, s->objsize); 914 print_section("Object ", (void *)object, s->object_size);
930 915
931 dump_stack(); 916 dump_stack();
932 } 917 }
@@ -942,14 +927,14 @@ static inline int slab_pre_alloc_hook(struct kmem_cache *s, gfp_t flags)
942 lockdep_trace_alloc(flags); 927 lockdep_trace_alloc(flags);
943 might_sleep_if(flags & __GFP_WAIT); 928 might_sleep_if(flags & __GFP_WAIT);
944 929
945 return should_failslab(s->objsize, flags, s->flags); 930 return should_failslab(s->object_size, flags, s->flags);
946} 931}
947 932
948static inline void slab_post_alloc_hook(struct kmem_cache *s, gfp_t flags, void *object) 933static inline void slab_post_alloc_hook(struct kmem_cache *s, gfp_t flags, void *object)
949{ 934{
950 flags &= gfp_allowed_mask; 935 flags &= gfp_allowed_mask;
951 kmemcheck_slab_alloc(s, flags, object, slab_ksize(s)); 936 kmemcheck_slab_alloc(s, flags, object, slab_ksize(s));
952 kmemleak_alloc_recursive(object, s->objsize, 1, s->flags, flags); 937 kmemleak_alloc_recursive(object, s->object_size, 1, s->flags, flags);
953} 938}
954 939
955static inline void slab_free_hook(struct kmem_cache *s, void *x) 940static inline void slab_free_hook(struct kmem_cache *s, void *x)
@@ -966,13 +951,13 @@ static inline void slab_free_hook(struct kmem_cache *s, void *x)
966 unsigned long flags; 951 unsigned long flags;
967 952
968 local_irq_save(flags); 953 local_irq_save(flags);
969 kmemcheck_slab_free(s, x, s->objsize); 954 kmemcheck_slab_free(s, x, s->object_size);
970 debug_check_no_locks_freed(x, s->objsize); 955 debug_check_no_locks_freed(x, s->object_size);
971 local_irq_restore(flags); 956 local_irq_restore(flags);
972 } 957 }
973#endif 958#endif
974 if (!(s->flags & SLAB_DEBUG_OBJECTS)) 959 if (!(s->flags & SLAB_DEBUG_OBJECTS))
975 debug_check_no_obj_freed(x, s->objsize); 960 debug_check_no_obj_freed(x, s->object_size);
976} 961}
977 962
978/* 963/*
@@ -1207,7 +1192,7 @@ out:
1207 1192
1208__setup("slub_debug", setup_slub_debug); 1193__setup("slub_debug", setup_slub_debug);
1209 1194
1210static unsigned long kmem_cache_flags(unsigned long objsize, 1195static unsigned long kmem_cache_flags(unsigned long object_size,
1211 unsigned long flags, const char *name, 1196 unsigned long flags, const char *name,
1212 void (*ctor)(void *)) 1197 void (*ctor)(void *))
1213{ 1198{
@@ -1237,7 +1222,7 @@ static inline int check_object(struct kmem_cache *s, struct page *page,
1237static inline void add_full(struct kmem_cache *s, struct kmem_cache_node *n, 1222static inline void add_full(struct kmem_cache *s, struct kmem_cache_node *n,
1238 struct page *page) {} 1223 struct page *page) {}
1239static inline void remove_full(struct kmem_cache *s, struct page *page) {} 1224static inline void remove_full(struct kmem_cache *s, struct page *page) {}
1240static inline unsigned long kmem_cache_flags(unsigned long objsize, 1225static inline unsigned long kmem_cache_flags(unsigned long object_size,
1241 unsigned long flags, const char *name, 1226 unsigned long flags, const char *name,
1242 void (*ctor)(void *)) 1227 void (*ctor)(void *))
1243{ 1228{
@@ -1314,13 +1299,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
1314 stat(s, ORDER_FALLBACK); 1299 stat(s, ORDER_FALLBACK);
1315 } 1300 }
1316 1301
1317 if (flags & __GFP_WAIT) 1302 if (kmemcheck_enabled && page
1318 local_irq_disable();
1319
1320 if (!page)
1321 return NULL;
1322
1323 if (kmemcheck_enabled
1324 && !(s->flags & (SLAB_NOTRACK | DEBUG_DEFAULT_FLAGS))) { 1303 && !(s->flags & (SLAB_NOTRACK | DEBUG_DEFAULT_FLAGS))) {
1325 int pages = 1 << oo_order(oo); 1304 int pages = 1 << oo_order(oo);
1326 1305
@@ -1336,6 +1315,11 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
1336 kmemcheck_mark_unallocated_pages(page, pages); 1315 kmemcheck_mark_unallocated_pages(page, pages);
1337 } 1316 }
1338 1317
1318 if (flags & __GFP_WAIT)
1319 local_irq_disable();
1320 if (!page)
1321 return NULL;
1322
1339 page->objects = oo_objects(oo); 1323 page->objects = oo_objects(oo);
1340 mod_zone_page_state(page_zone(page), 1324 mod_zone_page_state(page_zone(page),
1341 (s->flags & SLAB_RECLAIM_ACCOUNT) ? 1325 (s->flags & SLAB_RECLAIM_ACCOUNT) ?
@@ -1490,12 +1474,12 @@ static inline void remove_partial(struct kmem_cache_node *n,
1490} 1474}
1491 1475
1492/* 1476/*
1493 * Lock slab, remove from the partial list and put the object into the 1477 * Remove slab from the partial list, freeze it and
1494 * per cpu freelist. 1478 * return the pointer to the freelist.
1495 * 1479 *
1496 * Returns a list of objects or NULL if it fails. 1480 * Returns a list of objects or NULL if it fails.
1497 * 1481 *
1498 * Must hold list_lock. 1482 * Must hold list_lock since we modify the partial list.
1499 */ 1483 */
1500static inline void *acquire_slab(struct kmem_cache *s, 1484static inline void *acquire_slab(struct kmem_cache *s,
1501 struct kmem_cache_node *n, struct page *page, 1485 struct kmem_cache_node *n, struct page *page,
@@ -1510,26 +1494,27 @@ static inline void *acquire_slab(struct kmem_cache *s,
1510 * The old freelist is the list of objects for the 1494 * The old freelist is the list of objects for the
1511 * per cpu allocation list. 1495 * per cpu allocation list.
1512 */ 1496 */
1513 do { 1497 freelist = page->freelist;
1514 freelist = page->freelist; 1498 counters = page->counters;
1515 counters = page->counters; 1499 new.counters = counters;
1516 new.counters = counters; 1500 if (mode) {
1517 if (mode) { 1501 new.inuse = page->objects;
1518 new.inuse = page->objects; 1502 new.freelist = NULL;
1519 new.freelist = NULL; 1503 } else {
1520 } else { 1504 new.freelist = freelist;
1521 new.freelist = freelist; 1505 }
1522 }
1523 1506
1524 VM_BUG_ON(new.frozen); 1507 VM_BUG_ON(new.frozen);
1525 new.frozen = 1; 1508 new.frozen = 1;
1526 1509
1527 } while (!__cmpxchg_double_slab(s, page, 1510 if (!__cmpxchg_double_slab(s, page,
1528 freelist, counters, 1511 freelist, counters,
1529 new.freelist, new.counters, 1512 new.freelist, new.counters,
1530 "lock and freeze")); 1513 "acquire_slab"))
1514 return NULL;
1531 1515
1532 remove_partial(n, page); 1516 remove_partial(n, page);
1517 WARN_ON(!freelist);
1533 return freelist; 1518 return freelist;
1534} 1519}
1535 1520
@@ -1563,7 +1548,6 @@ static void *get_partial_node(struct kmem_cache *s,
1563 1548
1564 if (!object) { 1549 if (!object) {
1565 c->page = page; 1550 c->page = page;
1566 c->node = page_to_nid(page);
1567 stat(s, ALLOC_FROM_PARTIAL); 1551 stat(s, ALLOC_FROM_PARTIAL);
1568 object = t; 1552 object = t;
1569 available = page->objects - page->inuse; 1553 available = page->objects - page->inuse;
@@ -1617,7 +1601,7 @@ static void *get_any_partial(struct kmem_cache *s, gfp_t flags,
1617 1601
1618 do { 1602 do {
1619 cpuset_mems_cookie = get_mems_allowed(); 1603 cpuset_mems_cookie = get_mems_allowed();
1620 zonelist = node_zonelist(slab_node(current->mempolicy), flags); 1604 zonelist = node_zonelist(slab_node(), flags);
1621 for_each_zone_zonelist(zone, z, zonelist, high_zoneidx) { 1605 for_each_zone_zonelist(zone, z, zonelist, high_zoneidx) {
1622 struct kmem_cache_node *n; 1606 struct kmem_cache_node *n;
1623 1607
@@ -1731,14 +1715,12 @@ void init_kmem_cache_cpus(struct kmem_cache *s)
1731/* 1715/*
1732 * Remove the cpu slab 1716 * Remove the cpu slab
1733 */ 1717 */
1734static void deactivate_slab(struct kmem_cache *s, struct kmem_cache_cpu *c) 1718static void deactivate_slab(struct kmem_cache *s, struct page *page, void *freelist)
1735{ 1719{
1736 enum slab_modes { M_NONE, M_PARTIAL, M_FULL, M_FREE }; 1720 enum slab_modes { M_NONE, M_PARTIAL, M_FULL, M_FREE };
1737 struct page *page = c->page;
1738 struct kmem_cache_node *n = get_node(s, page_to_nid(page)); 1721 struct kmem_cache_node *n = get_node(s, page_to_nid(page));
1739 int lock = 0; 1722 int lock = 0;
1740 enum slab_modes l = M_NONE, m = M_NONE; 1723 enum slab_modes l = M_NONE, m = M_NONE;
1741 void *freelist;
1742 void *nextfree; 1724 void *nextfree;
1743 int tail = DEACTIVATE_TO_HEAD; 1725 int tail = DEACTIVATE_TO_HEAD;
1744 struct page new; 1726 struct page new;
@@ -1749,11 +1731,6 @@ static void deactivate_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
1749 tail = DEACTIVATE_TO_TAIL; 1731 tail = DEACTIVATE_TO_TAIL;
1750 } 1732 }
1751 1733
1752 c->tid = next_tid(c->tid);
1753 c->page = NULL;
1754 freelist = c->freelist;
1755 c->freelist = NULL;
1756
1757 /* 1734 /*
1758 * Stage one: Free all available per cpu objects back 1735 * Stage one: Free all available per cpu objects back
1759 * to the page freelist while it is still frozen. Leave the 1736 * to the page freelist while it is still frozen. Leave the
@@ -1879,21 +1856,31 @@ redo:
1879 } 1856 }
1880} 1857}
1881 1858
1882/* Unfreeze all the cpu partial slabs */ 1859/*
1860 * Unfreeze all the cpu partial slabs.
1861 *
1862 * This function must be called with interrupt disabled.
1863 */
1883static void unfreeze_partials(struct kmem_cache *s) 1864static void unfreeze_partials(struct kmem_cache *s)
1884{ 1865{
1885 struct kmem_cache_node *n = NULL; 1866 struct kmem_cache_node *n = NULL, *n2 = NULL;
1886 struct kmem_cache_cpu *c = this_cpu_ptr(s->cpu_slab); 1867 struct kmem_cache_cpu *c = this_cpu_ptr(s->cpu_slab);
1887 struct page *page, *discard_page = NULL; 1868 struct page *page, *discard_page = NULL;
1888 1869
1889 while ((page = c->partial)) { 1870 while ((page = c->partial)) {
1890 enum slab_modes { M_PARTIAL, M_FREE };
1891 enum slab_modes l, m;
1892 struct page new; 1871 struct page new;
1893 struct page old; 1872 struct page old;
1894 1873
1895 c->partial = page->next; 1874 c->partial = page->next;
1896 l = M_FREE; 1875
1876 n2 = get_node(s, page_to_nid(page));
1877 if (n != n2) {
1878 if (n)
1879 spin_unlock(&n->list_lock);
1880
1881 n = n2;
1882 spin_lock(&n->list_lock);
1883 }
1897 1884
1898 do { 1885 do {
1899 1886
@@ -1906,43 +1893,17 @@ static void unfreeze_partials(struct kmem_cache *s)
1906 1893
1907 new.frozen = 0; 1894 new.frozen = 0;
1908 1895
1909 if (!new.inuse && (!n || n->nr_partial > s->min_partial)) 1896 } while (!__cmpxchg_double_slab(s, page,
1910 m = M_FREE;
1911 else {
1912 struct kmem_cache_node *n2 = get_node(s,
1913 page_to_nid(page));
1914
1915 m = M_PARTIAL;
1916 if (n != n2) {
1917 if (n)
1918 spin_unlock(&n->list_lock);
1919
1920 n = n2;
1921 spin_lock(&n->list_lock);
1922 }
1923 }
1924
1925 if (l != m) {
1926 if (l == M_PARTIAL) {
1927 remove_partial(n, page);
1928 stat(s, FREE_REMOVE_PARTIAL);
1929 } else {
1930 add_partial(n, page,
1931 DEACTIVATE_TO_TAIL);
1932 stat(s, FREE_ADD_PARTIAL);
1933 }
1934
1935 l = m;
1936 }
1937
1938 } while (!cmpxchg_double_slab(s, page,
1939 old.freelist, old.counters, 1897 old.freelist, old.counters,
1940 new.freelist, new.counters, 1898 new.freelist, new.counters,
1941 "unfreezing slab")); 1899 "unfreezing slab"));
1942 1900
1943 if (m == M_FREE) { 1901 if (unlikely(!new.inuse && n->nr_partial > s->min_partial)) {
1944 page->next = discard_page; 1902 page->next = discard_page;
1945 discard_page = page; 1903 discard_page = page;
1904 } else {
1905 add_partial(n, page, DEACTIVATE_TO_TAIL);
1906 stat(s, FREE_ADD_PARTIAL);
1946 } 1907 }
1947 } 1908 }
1948 1909
@@ -2011,7 +1972,11 @@ int put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
2011static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c) 1972static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
2012{ 1973{
2013 stat(s, CPUSLAB_FLUSH); 1974 stat(s, CPUSLAB_FLUSH);
2014 deactivate_slab(s, c); 1975 deactivate_slab(s, c->page, c->freelist);
1976
1977 c->tid = next_tid(c->tid);
1978 c->page = NULL;
1979 c->freelist = NULL;
2015} 1980}
2016 1981
2017/* 1982/*
@@ -2055,10 +2020,10 @@ static void flush_all(struct kmem_cache *s)
2055 * Check if the objects in a per cpu structure fit numa 2020 * Check if the objects in a per cpu structure fit numa
2056 * locality expectations. 2021 * locality expectations.
2057 */ 2022 */
2058static inline int node_match(struct kmem_cache_cpu *c, int node) 2023static inline int node_match(struct page *page, int node)
2059{ 2024{
2060#ifdef CONFIG_NUMA 2025#ifdef CONFIG_NUMA
2061 if (node != NUMA_NO_NODE && c->node != node) 2026 if (node != NUMA_NO_NODE && page_to_nid(page) != node)
2062 return 0; 2027 return 0;
2063#endif 2028#endif
2064 return 1; 2029 return 1;
@@ -2101,10 +2066,10 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid)
2101 "SLUB: Unable to allocate memory on node %d (gfp=0x%x)\n", 2066 "SLUB: Unable to allocate memory on node %d (gfp=0x%x)\n",
2102 nid, gfpflags); 2067 nid, gfpflags);
2103 printk(KERN_WARNING " cache: %s, object size: %d, buffer size: %d, " 2068 printk(KERN_WARNING " cache: %s, object size: %d, buffer size: %d, "
2104 "default order: %d, min order: %d\n", s->name, s->objsize, 2069 "default order: %d, min order: %d\n", s->name, s->object_size,
2105 s->size, oo_order(s->oo), oo_order(s->min)); 2070 s->size, oo_order(s->oo), oo_order(s->min));
2106 2071
2107 if (oo_order(s->min) > get_order(s->objsize)) 2072 if (oo_order(s->min) > get_order(s->object_size))
2108 printk(KERN_WARNING " %s debugging increased min order, use " 2073 printk(KERN_WARNING " %s debugging increased min order, use "
2109 "slub_debug=O to disable.\n", s->name); 2074 "slub_debug=O to disable.\n", s->name);
2110 2075
@@ -2130,10 +2095,16 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid)
2130static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags, 2095static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
2131 int node, struct kmem_cache_cpu **pc) 2096 int node, struct kmem_cache_cpu **pc)
2132{ 2097{
2133 void *object; 2098 void *freelist;
2134 struct kmem_cache_cpu *c; 2099 struct kmem_cache_cpu *c = *pc;
2135 struct page *page = new_slab(s, flags, node); 2100 struct page *page;
2101
2102 freelist = get_partial(s, flags, node, c);
2136 2103
2104 if (freelist)
2105 return freelist;
2106
2107 page = new_slab(s, flags, node);
2137 if (page) { 2108 if (page) {
2138 c = __this_cpu_ptr(s->cpu_slab); 2109 c = __this_cpu_ptr(s->cpu_slab);
2139 if (c->page) 2110 if (c->page)
@@ -2143,17 +2114,16 @@ static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
2143 * No other reference to the page yet so we can 2114 * No other reference to the page yet so we can
2144 * muck around with it freely without cmpxchg 2115 * muck around with it freely without cmpxchg
2145 */ 2116 */
2146 object = page->freelist; 2117 freelist = page->freelist;
2147 page->freelist = NULL; 2118 page->freelist = NULL;
2148 2119
2149 stat(s, ALLOC_SLAB); 2120 stat(s, ALLOC_SLAB);
2150 c->node = page_to_nid(page);
2151 c->page = page; 2121 c->page = page;
2152 *pc = c; 2122 *pc = c;
2153 } else 2123 } else
2154 object = NULL; 2124 freelist = NULL;
2155 2125
2156 return object; 2126 return freelist;
2157} 2127}
2158 2128
2159/* 2129/*
@@ -2163,6 +2133,8 @@ static inline void *new_slab_objects(struct kmem_cache *s, gfp_t flags,
2163 * The page is still frozen if the return value is not NULL. 2133 * The page is still frozen if the return value is not NULL.
2164 * 2134 *
2165 * If this function returns NULL then the page has been unfrozen. 2135 * If this function returns NULL then the page has been unfrozen.
2136 *
2137 * This function must be called with interrupt disabled.
2166 */ 2138 */
2167static inline void *get_freelist(struct kmem_cache *s, struct page *page) 2139static inline void *get_freelist(struct kmem_cache *s, struct page *page)
2168{ 2140{
@@ -2173,13 +2145,14 @@ static inline void *get_freelist(struct kmem_cache *s, struct page *page)
2173 do { 2145 do {
2174 freelist = page->freelist; 2146 freelist = page->freelist;
2175 counters = page->counters; 2147 counters = page->counters;
2148
2176 new.counters = counters; 2149 new.counters = counters;
2177 VM_BUG_ON(!new.frozen); 2150 VM_BUG_ON(!new.frozen);
2178 2151
2179 new.inuse = page->objects; 2152 new.inuse = page->objects;
2180 new.frozen = freelist != NULL; 2153 new.frozen = freelist != NULL;
2181 2154
2182 } while (!cmpxchg_double_slab(s, page, 2155 } while (!__cmpxchg_double_slab(s, page,
2183 freelist, counters, 2156 freelist, counters,
2184 NULL, new.counters, 2157 NULL, new.counters,
2185 "get_freelist")); 2158 "get_freelist"));
@@ -2206,7 +2179,8 @@ static inline void *get_freelist(struct kmem_cache *s, struct page *page)
2206static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, 2179static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
2207 unsigned long addr, struct kmem_cache_cpu *c) 2180 unsigned long addr, struct kmem_cache_cpu *c)
2208{ 2181{
2209 void **object; 2182 void *freelist;
2183 struct page *page;
2210 unsigned long flags; 2184 unsigned long flags;
2211 2185
2212 local_irq_save(flags); 2186 local_irq_save(flags);
@@ -2219,25 +2193,29 @@ static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
2219 c = this_cpu_ptr(s->cpu_slab); 2193 c = this_cpu_ptr(s->cpu_slab);
2220#endif 2194#endif
2221 2195
2222 if (!c->page) 2196 page = c->page;
2197 if (!page)
2223 goto new_slab; 2198 goto new_slab;
2224redo: 2199redo:
2225 if (unlikely(!node_match(c, node))) { 2200
2201 if (unlikely(!node_match(page, node))) {
2226 stat(s, ALLOC_NODE_MISMATCH); 2202 stat(s, ALLOC_NODE_MISMATCH);
2227 deactivate_slab(s, c); 2203 deactivate_slab(s, page, c->freelist);
2204 c->page = NULL;
2205 c->freelist = NULL;
2228 goto new_slab; 2206 goto new_slab;
2229 } 2207 }
2230 2208
2231 /* must check again c->freelist in case of cpu migration or IRQ */ 2209 /* must check again c->freelist in case of cpu migration or IRQ */
2232 object = c->freelist; 2210 freelist = c->freelist;
2233 if (object) 2211 if (freelist)
2234 goto load_freelist; 2212 goto load_freelist;
2235 2213
2236 stat(s, ALLOC_SLOWPATH); 2214 stat(s, ALLOC_SLOWPATH);
2237 2215
2238 object = get_freelist(s, c->page); 2216 freelist = get_freelist(s, page);
2239 2217
2240 if (!object) { 2218 if (!freelist) {
2241 c->page = NULL; 2219 c->page = NULL;
2242 stat(s, DEACTIVATE_BYPASS); 2220 stat(s, DEACTIVATE_BYPASS);
2243 goto new_slab; 2221 goto new_slab;
@@ -2246,50 +2224,50 @@ redo:
2246 stat(s, ALLOC_REFILL); 2224 stat(s, ALLOC_REFILL);
2247 2225
2248load_freelist: 2226load_freelist:
2249 c->freelist = get_freepointer(s, object); 2227 /*
2228 * freelist is pointing to the list of objects to be used.
2229 * page is pointing to the page from which the objects are obtained.
2230 * That page must be frozen for per cpu allocations to work.
2231 */
2232 VM_BUG_ON(!c->page->frozen);
2233 c->freelist = get_freepointer(s, freelist);
2250 c->tid = next_tid(c->tid); 2234 c->tid = next_tid(c->tid);
2251 local_irq_restore(flags); 2235 local_irq_restore(flags);
2252 return object; 2236 return freelist;
2253 2237
2254new_slab: 2238new_slab:
2255 2239
2256 if (c->partial) { 2240 if (c->partial) {
2257 c->page = c->partial; 2241 page = c->page = c->partial;
2258 c->partial = c->page->next; 2242 c->partial = page->next;
2259 c->node = page_to_nid(c->page);
2260 stat(s, CPU_PARTIAL_ALLOC); 2243 stat(s, CPU_PARTIAL_ALLOC);
2261 c->freelist = NULL; 2244 c->freelist = NULL;
2262 goto redo; 2245 goto redo;
2263 } 2246 }
2264 2247
2265 /* Then do expensive stuff like retrieving pages from the partial lists */ 2248 freelist = new_slab_objects(s, gfpflags, node, &c);
2266 object = get_partial(s, gfpflags, node, c);
2267 2249
2268 if (unlikely(!object)) { 2250 if (unlikely(!freelist)) {
2251 if (!(gfpflags & __GFP_NOWARN) && printk_ratelimit())
2252 slab_out_of_memory(s, gfpflags, node);
2269 2253
2270 object = new_slab_objects(s, gfpflags, node, &c); 2254 local_irq_restore(flags);
2271 2255 return NULL;
2272 if (unlikely(!object)) {
2273 if (!(gfpflags & __GFP_NOWARN) && printk_ratelimit())
2274 slab_out_of_memory(s, gfpflags, node);
2275
2276 local_irq_restore(flags);
2277 return NULL;
2278 }
2279 } 2256 }
2280 2257
2258 page = c->page;
2281 if (likely(!kmem_cache_debug(s))) 2259 if (likely(!kmem_cache_debug(s)))
2282 goto load_freelist; 2260 goto load_freelist;
2283 2261
2284 /* Only entered in the debug case */ 2262 /* Only entered in the debug case */
2285 if (!alloc_debug_processing(s, c->page, object, addr)) 2263 if (!alloc_debug_processing(s, page, freelist, addr))
2286 goto new_slab; /* Slab failed checks. Next slab needed */ 2264 goto new_slab; /* Slab failed checks. Next slab needed */
2287 2265
2288 c->freelist = get_freepointer(s, object); 2266 deactivate_slab(s, page, get_freepointer(s, freelist));
2289 deactivate_slab(s, c); 2267 c->page = NULL;
2290 c->node = NUMA_NO_NODE; 2268 c->freelist = NULL;
2291 local_irq_restore(flags); 2269 local_irq_restore(flags);
2292 return object; 2270 return freelist;
2293} 2271}
2294 2272
2295/* 2273/*
@@ -2307,6 +2285,7 @@ static __always_inline void *slab_alloc(struct kmem_cache *s,
2307{ 2285{
2308 void **object; 2286 void **object;
2309 struct kmem_cache_cpu *c; 2287 struct kmem_cache_cpu *c;
2288 struct page *page;
2310 unsigned long tid; 2289 unsigned long tid;
2311 2290
2312 if (slab_pre_alloc_hook(s, gfpflags)) 2291 if (slab_pre_alloc_hook(s, gfpflags))
@@ -2332,7 +2311,8 @@ redo:
2332 barrier(); 2311 barrier();
2333 2312
2334 object = c->freelist; 2313 object = c->freelist;
2335 if (unlikely(!object || !node_match(c, node))) 2314 page = c->page;
2315 if (unlikely(!object || !node_match(page, node)))
2336 2316
2337 object = __slab_alloc(s, gfpflags, node, addr, c); 2317 object = __slab_alloc(s, gfpflags, node, addr, c);
2338 2318
@@ -2364,7 +2344,7 @@ redo:
2364 } 2344 }
2365 2345
2366 if (unlikely(gfpflags & __GFP_ZERO) && object) 2346 if (unlikely(gfpflags & __GFP_ZERO) && object)
2367 memset(object, 0, s->objsize); 2347 memset(object, 0, s->object_size);
2368 2348
2369 slab_post_alloc_hook(s, gfpflags, object); 2349 slab_post_alloc_hook(s, gfpflags, object);
2370 2350
@@ -2375,7 +2355,7 @@ void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags)
2375{ 2355{
2376 void *ret = slab_alloc(s, gfpflags, NUMA_NO_NODE, _RET_IP_); 2356 void *ret = slab_alloc(s, gfpflags, NUMA_NO_NODE, _RET_IP_);
2377 2357
2378 trace_kmem_cache_alloc(_RET_IP_, ret, s->objsize, s->size, gfpflags); 2358 trace_kmem_cache_alloc(_RET_IP_, ret, s->object_size, s->size, gfpflags);
2379 2359
2380 return ret; 2360 return ret;
2381} 2361}
@@ -2405,7 +2385,7 @@ void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags, int node)
2405 void *ret = slab_alloc(s, gfpflags, node, _RET_IP_); 2385 void *ret = slab_alloc(s, gfpflags, node, _RET_IP_);
2406 2386
2407 trace_kmem_cache_alloc_node(_RET_IP_, ret, 2387 trace_kmem_cache_alloc_node(_RET_IP_, ret,
2408 s->objsize, s->size, gfpflags, node); 2388 s->object_size, s->size, gfpflags, node);
2409 2389
2410 return ret; 2390 return ret;
2411} 2391}
@@ -2900,7 +2880,7 @@ static void set_min_partial(struct kmem_cache *s, unsigned long min)
2900static int calculate_sizes(struct kmem_cache *s, int forced_order) 2880static int calculate_sizes(struct kmem_cache *s, int forced_order)
2901{ 2881{
2902 unsigned long flags = s->flags; 2882 unsigned long flags = s->flags;
2903 unsigned long size = s->objsize; 2883 unsigned long size = s->object_size;
2904 unsigned long align = s->align; 2884 unsigned long align = s->align;
2905 int order; 2885 int order;
2906 2886
@@ -2929,7 +2909,7 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
2929 * end of the object and the free pointer. If not then add an 2909 * end of the object and the free pointer. If not then add an
2930 * additional word to have some bytes to store Redzone information. 2910 * additional word to have some bytes to store Redzone information.
2931 */ 2911 */
2932 if ((flags & SLAB_RED_ZONE) && size == s->objsize) 2912 if ((flags & SLAB_RED_ZONE) && size == s->object_size)
2933 size += sizeof(void *); 2913 size += sizeof(void *);
2934#endif 2914#endif
2935 2915
@@ -2977,7 +2957,7 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
2977 * user specified and the dynamic determination of cache line size 2957 * user specified and the dynamic determination of cache line size
2978 * on bootup. 2958 * on bootup.
2979 */ 2959 */
2980 align = calculate_alignment(flags, align, s->objsize); 2960 align = calculate_alignment(flags, align, s->object_size);
2981 s->align = align; 2961 s->align = align;
2982 2962
2983 /* 2963 /*
@@ -3025,7 +3005,7 @@ static int kmem_cache_open(struct kmem_cache *s,
3025 memset(s, 0, kmem_size); 3005 memset(s, 0, kmem_size);
3026 s->name = name; 3006 s->name = name;
3027 s->ctor = ctor; 3007 s->ctor = ctor;
3028 s->objsize = size; 3008 s->object_size = size;
3029 s->align = align; 3009 s->align = align;
3030 s->flags = kmem_cache_flags(size, flags, name, ctor); 3010 s->flags = kmem_cache_flags(size, flags, name, ctor);
3031 s->reserved = 0; 3011 s->reserved = 0;
@@ -3040,7 +3020,7 @@ static int kmem_cache_open(struct kmem_cache *s,
3040 * Disable debugging flags that store metadata if the min slab 3020 * Disable debugging flags that store metadata if the min slab
3041 * order increased. 3021 * order increased.
3042 */ 3022 */
3043 if (get_order(s->size) > get_order(s->objsize)) { 3023 if (get_order(s->size) > get_order(s->object_size)) {
3044 s->flags &= ~DEBUG_METADATA_FLAGS; 3024 s->flags &= ~DEBUG_METADATA_FLAGS;
3045 s->offset = 0; 3025 s->offset = 0;
3046 if (!calculate_sizes(s, -1)) 3026 if (!calculate_sizes(s, -1))
@@ -3114,7 +3094,7 @@ error:
3114 */ 3094 */
3115unsigned int kmem_cache_size(struct kmem_cache *s) 3095unsigned int kmem_cache_size(struct kmem_cache *s)
3116{ 3096{
3117 return s->objsize; 3097 return s->object_size;
3118} 3098}
3119EXPORT_SYMBOL(kmem_cache_size); 3099EXPORT_SYMBOL(kmem_cache_size);
3120 3100
@@ -3192,11 +3172,11 @@ static inline int kmem_cache_close(struct kmem_cache *s)
3192 */ 3172 */
3193void kmem_cache_destroy(struct kmem_cache *s) 3173void kmem_cache_destroy(struct kmem_cache *s)
3194{ 3174{
3195 down_write(&slub_lock); 3175 mutex_lock(&slab_mutex);
3196 s->refcount--; 3176 s->refcount--;
3197 if (!s->refcount) { 3177 if (!s->refcount) {
3198 list_del(&s->list); 3178 list_del(&s->list);
3199 up_write(&slub_lock); 3179 mutex_unlock(&slab_mutex);
3200 if (kmem_cache_close(s)) { 3180 if (kmem_cache_close(s)) {
3201 printk(KERN_ERR "SLUB %s: %s called for cache that " 3181 printk(KERN_ERR "SLUB %s: %s called for cache that "
3202 "still has objects.\n", s->name, __func__); 3182 "still has objects.\n", s->name, __func__);
@@ -3206,7 +3186,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
3206 rcu_barrier(); 3186 rcu_barrier();
3207 sysfs_slab_remove(s); 3187 sysfs_slab_remove(s);
3208 } else 3188 } else
3209 up_write(&slub_lock); 3189 mutex_unlock(&slab_mutex);
3210} 3190}
3211EXPORT_SYMBOL(kmem_cache_destroy); 3191EXPORT_SYMBOL(kmem_cache_destroy);
3212 3192
@@ -3268,7 +3248,7 @@ static struct kmem_cache *__init create_kmalloc_cache(const char *name,
3268 3248
3269 /* 3249 /*
3270 * This function is called with IRQs disabled during early-boot on 3250 * This function is called with IRQs disabled during early-boot on
3271 * single CPU so there's no need to take slub_lock here. 3251 * single CPU so there's no need to take slab_mutex here.
3272 */ 3252 */
3273 if (!kmem_cache_open(s, name, size, ARCH_KMALLOC_MINALIGN, 3253 if (!kmem_cache_open(s, name, size, ARCH_KMALLOC_MINALIGN,
3274 flags, NULL)) 3254 flags, NULL))
@@ -3553,10 +3533,10 @@ static int slab_mem_going_offline_callback(void *arg)
3553{ 3533{
3554 struct kmem_cache *s; 3534 struct kmem_cache *s;
3555 3535
3556 down_read(&slub_lock); 3536 mutex_lock(&slab_mutex);
3557 list_for_each_entry(s, &slab_caches, list) 3537 list_for_each_entry(s, &slab_caches, list)
3558 kmem_cache_shrink(s); 3538 kmem_cache_shrink(s);
3559 up_read(&slub_lock); 3539 mutex_unlock(&slab_mutex);
3560 3540
3561 return 0; 3541 return 0;
3562} 3542}
@@ -3577,7 +3557,7 @@ static void slab_mem_offline_callback(void *arg)
3577 if (offline_node < 0) 3557 if (offline_node < 0)
3578 return; 3558 return;
3579 3559
3580 down_read(&slub_lock); 3560 mutex_lock(&slab_mutex);
3581 list_for_each_entry(s, &slab_caches, list) { 3561 list_for_each_entry(s, &slab_caches, list) {
3582 n = get_node(s, offline_node); 3562 n = get_node(s, offline_node);
3583 if (n) { 3563 if (n) {
@@ -3593,7 +3573,7 @@ static void slab_mem_offline_callback(void *arg)
3593 kmem_cache_free(kmem_cache_node, n); 3573 kmem_cache_free(kmem_cache_node, n);
3594 } 3574 }
3595 } 3575 }
3596 up_read(&slub_lock); 3576 mutex_unlock(&slab_mutex);
3597} 3577}
3598 3578
3599static int slab_mem_going_online_callback(void *arg) 3579static int slab_mem_going_online_callback(void *arg)
@@ -3616,7 +3596,7 @@ static int slab_mem_going_online_callback(void *arg)
3616 * allocate a kmem_cache_node structure in order to bring the node 3596 * allocate a kmem_cache_node structure in order to bring the node
3617 * online. 3597 * online.
3618 */ 3598 */
3619 down_read(&slub_lock); 3599 mutex_lock(&slab_mutex);
3620 list_for_each_entry(s, &slab_caches, list) { 3600 list_for_each_entry(s, &slab_caches, list) {
3621 /* 3601 /*
3622 * XXX: kmem_cache_alloc_node will fallback to other nodes 3602 * XXX: kmem_cache_alloc_node will fallback to other nodes
@@ -3632,7 +3612,7 @@ static int slab_mem_going_online_callback(void *arg)
3632 s->node[nid] = n; 3612 s->node[nid] = n;
3633 } 3613 }
3634out: 3614out:
3635 up_read(&slub_lock); 3615 mutex_unlock(&slab_mutex);
3636 return ret; 3616 return ret;
3637} 3617}
3638 3618
@@ -3843,11 +3823,11 @@ void __init kmem_cache_init(void)
3843 3823
3844 if (s && s->size) { 3824 if (s && s->size) {
3845 char *name = kasprintf(GFP_NOWAIT, 3825 char *name = kasprintf(GFP_NOWAIT,
3846 "dma-kmalloc-%d", s->objsize); 3826 "dma-kmalloc-%d", s->object_size);
3847 3827
3848 BUG_ON(!name); 3828 BUG_ON(!name);
3849 kmalloc_dma_caches[i] = create_kmalloc_cache(name, 3829 kmalloc_dma_caches[i] = create_kmalloc_cache(name,
3850 s->objsize, SLAB_CACHE_DMA); 3830 s->object_size, SLAB_CACHE_DMA);
3851 } 3831 }
3852 } 3832 }
3853#endif 3833#endif
@@ -3924,16 +3904,12 @@ static struct kmem_cache *find_mergeable(size_t size,
3924 return NULL; 3904 return NULL;
3925} 3905}
3926 3906
3927struct kmem_cache *kmem_cache_create(const char *name, size_t size, 3907struct kmem_cache *__kmem_cache_create(const char *name, size_t size,
3928 size_t align, unsigned long flags, void (*ctor)(void *)) 3908 size_t align, unsigned long flags, void (*ctor)(void *))
3929{ 3909{
3930 struct kmem_cache *s; 3910 struct kmem_cache *s;
3931 char *n; 3911 char *n;
3932 3912
3933 if (WARN_ON(!name))
3934 return NULL;
3935
3936 down_write(&slub_lock);
3937 s = find_mergeable(size, align, flags, name, ctor); 3913 s = find_mergeable(size, align, flags, name, ctor);
3938 if (s) { 3914 if (s) {
3939 s->refcount++; 3915 s->refcount++;
@@ -3941,49 +3917,42 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
3941 * Adjust the object sizes so that we clear 3917 * Adjust the object sizes so that we clear
3942 * the complete object on kzalloc. 3918 * the complete object on kzalloc.
3943 */ 3919 */
3944 s->objsize = max(s->objsize, (int)size); 3920 s->object_size = max(s->object_size, (int)size);
3945 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *))); 3921 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
3946 3922
3947 if (sysfs_slab_alias(s, name)) { 3923 if (sysfs_slab_alias(s, name)) {
3948 s->refcount--; 3924 s->refcount--;
3949 goto err; 3925 return NULL;
3950 } 3926 }
3951 up_write(&slub_lock);
3952 return s; 3927 return s;
3953 } 3928 }
3954 3929
3955 n = kstrdup(name, GFP_KERNEL); 3930 n = kstrdup(name, GFP_KERNEL);
3956 if (!n) 3931 if (!n)
3957 goto err; 3932 return NULL;
3958 3933
3959 s = kmalloc(kmem_size, GFP_KERNEL); 3934 s = kmalloc(kmem_size, GFP_KERNEL);
3960 if (s) { 3935 if (s) {
3961 if (kmem_cache_open(s, n, 3936 if (kmem_cache_open(s, n,
3962 size, align, flags, ctor)) { 3937 size, align, flags, ctor)) {
3938 int r;
3939
3963 list_add(&s->list, &slab_caches); 3940 list_add(&s->list, &slab_caches);
3964 up_write(&slub_lock); 3941 mutex_unlock(&slab_mutex);
3965 if (sysfs_slab_add(s)) { 3942 r = sysfs_slab_add(s);
3966 down_write(&slub_lock); 3943 mutex_lock(&slab_mutex);
3967 list_del(&s->list); 3944
3968 kfree(n); 3945 if (!r)
3969 kfree(s); 3946 return s;
3970 goto err; 3947
3971 } 3948 list_del(&s->list);
3972 return s; 3949 kmem_cache_close(s);
3973 } 3950 }
3974 kfree(s); 3951 kfree(s);
3975 } 3952 }
3976 kfree(n); 3953 kfree(n);
3977err: 3954 return NULL;
3978 up_write(&slub_lock);
3979
3980 if (flags & SLAB_PANIC)
3981 panic("Cannot create slabcache %s\n", name);
3982 else
3983 s = NULL;
3984 return s;
3985} 3955}
3986EXPORT_SYMBOL(kmem_cache_create);
3987 3956
3988#ifdef CONFIG_SMP 3957#ifdef CONFIG_SMP
3989/* 3958/*
@@ -4002,13 +3971,13 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
4002 case CPU_UP_CANCELED_FROZEN: 3971 case CPU_UP_CANCELED_FROZEN:
4003 case CPU_DEAD: 3972 case CPU_DEAD:
4004 case CPU_DEAD_FROZEN: 3973 case CPU_DEAD_FROZEN:
4005 down_read(&slub_lock); 3974 mutex_lock(&slab_mutex);
4006 list_for_each_entry(s, &slab_caches, list) { 3975 list_for_each_entry(s, &slab_caches, list) {
4007 local_irq_save(flags); 3976 local_irq_save(flags);
4008 __flush_cpu_slab(s, cpu); 3977 __flush_cpu_slab(s, cpu);
4009 local_irq_restore(flags); 3978 local_irq_restore(flags);
4010 } 3979 }
4011 up_read(&slub_lock); 3980 mutex_unlock(&slab_mutex);
4012 break; 3981 break;
4013 default: 3982 default:
4014 break; 3983 break;
@@ -4500,30 +4469,31 @@ static ssize_t show_slab_objects(struct kmem_cache *s,
4500 4469
4501 for_each_possible_cpu(cpu) { 4470 for_each_possible_cpu(cpu) {
4502 struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab, cpu); 4471 struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab, cpu);
4503 int node = ACCESS_ONCE(c->node); 4472 int node;
4504 struct page *page; 4473 struct page *page;
4505 4474
4506 if (node < 0)
4507 continue;
4508 page = ACCESS_ONCE(c->page); 4475 page = ACCESS_ONCE(c->page);
4509 if (page) { 4476 if (!page)
4510 if (flags & SO_TOTAL) 4477 continue;
4511 x = page->objects;
4512 else if (flags & SO_OBJECTS)
4513 x = page->inuse;
4514 else
4515 x = 1;
4516 4478
4517 total += x; 4479 node = page_to_nid(page);
4518 nodes[node] += x; 4480 if (flags & SO_TOTAL)
4519 } 4481 x = page->objects;
4520 page = c->partial; 4482 else if (flags & SO_OBJECTS)
4483 x = page->inuse;
4484 else
4485 x = 1;
4521 4486
4487 total += x;
4488 nodes[node] += x;
4489
4490 page = ACCESS_ONCE(c->partial);
4522 if (page) { 4491 if (page) {
4523 x = page->pobjects; 4492 x = page->pobjects;
4524 total += x; 4493 total += x;
4525 nodes[node] += x; 4494 nodes[node] += x;
4526 } 4495 }
4496
4527 per_cpu[node]++; 4497 per_cpu[node]++;
4528 } 4498 }
4529 } 4499 }
@@ -4623,7 +4593,7 @@ SLAB_ATTR_RO(align);
4623 4593
4624static ssize_t object_size_show(struct kmem_cache *s, char *buf) 4594static ssize_t object_size_show(struct kmem_cache *s, char *buf)
4625{ 4595{
4626 return sprintf(buf, "%d\n", s->objsize); 4596 return sprintf(buf, "%d\n", s->object_size);
4627} 4597}
4628SLAB_ATTR_RO(object_size); 4598SLAB_ATTR_RO(object_size);
4629 4599
@@ -5286,7 +5256,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
5286 const char *name; 5256 const char *name;
5287 int unmergeable; 5257 int unmergeable;
5288 5258
5289 if (slab_state < SYSFS) 5259 if (slab_state < FULL)
5290 /* Defer until later */ 5260 /* Defer until later */
5291 return 0; 5261 return 0;
5292 5262
@@ -5331,7 +5301,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
5331 5301
5332static void sysfs_slab_remove(struct kmem_cache *s) 5302static void sysfs_slab_remove(struct kmem_cache *s)
5333{ 5303{
5334 if (slab_state < SYSFS) 5304 if (slab_state < FULL)
5335 /* 5305 /*
5336 * Sysfs has not been setup yet so no need to remove the 5306 * Sysfs has not been setup yet so no need to remove the
5337 * cache from sysfs. 5307 * cache from sysfs.
@@ -5359,7 +5329,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
5359{ 5329{
5360 struct saved_alias *al; 5330 struct saved_alias *al;
5361 5331
5362 if (slab_state == SYSFS) { 5332 if (slab_state == FULL) {
5363 /* 5333 /*
5364 * If we have a leftover link then remove it. 5334 * If we have a leftover link then remove it.
5365 */ 5335 */
@@ -5383,16 +5353,16 @@ static int __init slab_sysfs_init(void)
5383 struct kmem_cache *s; 5353 struct kmem_cache *s;
5384 int err; 5354 int err;
5385 5355
5386 down_write(&slub_lock); 5356 mutex_lock(&slab_mutex);
5387 5357
5388 slab_kset = kset_create_and_add("slab", &slab_uevent_ops, kernel_kobj); 5358 slab_kset = kset_create_and_add("slab", &slab_uevent_ops, kernel_kobj);
5389 if (!slab_kset) { 5359 if (!slab_kset) {
5390 up_write(&slub_lock); 5360 mutex_unlock(&slab_mutex);
5391 printk(KERN_ERR "Cannot register slab subsystem.\n"); 5361 printk(KERN_ERR "Cannot register slab subsystem.\n");
5392 return -ENOSYS; 5362 return -ENOSYS;
5393 } 5363 }
5394 5364
5395 slab_state = SYSFS; 5365 slab_state = FULL;
5396 5366
5397 list_for_each_entry(s, &slab_caches, list) { 5367 list_for_each_entry(s, &slab_caches, list) {
5398 err = sysfs_slab_add(s); 5368 err = sysfs_slab_add(s);
@@ -5408,11 +5378,11 @@ static int __init slab_sysfs_init(void)
5408 err = sysfs_slab_alias(al->s, al->name); 5378 err = sysfs_slab_alias(al->s, al->name);
5409 if (err) 5379 if (err)
5410 printk(KERN_ERR "SLUB: Unable to add boot slab alias" 5380 printk(KERN_ERR "SLUB: Unable to add boot slab alias"
5411 " %s to sysfs\n", s->name); 5381 " %s to sysfs\n", al->name);
5412 kfree(al); 5382 kfree(al);
5413 } 5383 }
5414 5384
5415 up_write(&slub_lock); 5385 mutex_unlock(&slab_mutex);
5416 resiliency_test(); 5386 resiliency_test();
5417 return 0; 5387 return 0;
5418} 5388}
@@ -5427,7 +5397,7 @@ __initcall(slab_sysfs_init);
5427static void print_slabinfo_header(struct seq_file *m) 5397static void print_slabinfo_header(struct seq_file *m)
5428{ 5398{
5429 seq_puts(m, "slabinfo - version: 2.1\n"); 5399 seq_puts(m, "slabinfo - version: 2.1\n");
5430 seq_puts(m, "# name <active_objs> <num_objs> <objsize> " 5400 seq_puts(m, "# name <active_objs> <num_objs> <object_size> "
5431 "<objperslab> <pagesperslab>"); 5401 "<objperslab> <pagesperslab>");
5432 seq_puts(m, " : tunables <limit> <batchcount> <sharedfactor>"); 5402 seq_puts(m, " : tunables <limit> <batchcount> <sharedfactor>");
5433 seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>"); 5403 seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>");
@@ -5438,7 +5408,7 @@ static void *s_start(struct seq_file *m, loff_t *pos)
5438{ 5408{
5439 loff_t n = *pos; 5409 loff_t n = *pos;
5440 5410
5441 down_read(&slub_lock); 5411 mutex_lock(&slab_mutex);
5442 if (!n) 5412 if (!n)
5443 print_slabinfo_header(m); 5413 print_slabinfo_header(m);
5444 5414
@@ -5452,7 +5422,7 @@ static void *s_next(struct seq_file *m, void *p, loff_t *pos)
5452 5422
5453static void s_stop(struct seq_file *m, void *p) 5423static void s_stop(struct seq_file *m, void *p)
5454{ 5424{
5455 up_read(&slub_lock); 5425 mutex_unlock(&slab_mutex);
5456} 5426}
5457 5427
5458static int s_show(struct seq_file *m, void *p) 5428static int s_show(struct seq_file *m, void *p)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index c7ac8e1b3ac7..e03f4c7307a5 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1280,7 +1280,7 @@ DEFINE_RWLOCK(vmlist_lock);
1280struct vm_struct *vmlist; 1280struct vm_struct *vmlist;
1281 1281
1282static void setup_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va, 1282static void setup_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
1283 unsigned long flags, void *caller) 1283 unsigned long flags, const void *caller)
1284{ 1284{
1285 vm->flags = flags; 1285 vm->flags = flags;
1286 vm->addr = (void *)va->va_start; 1286 vm->addr = (void *)va->va_start;
@@ -1306,7 +1306,7 @@ static void insert_vmalloc_vmlist(struct vm_struct *vm)
1306} 1306}
1307 1307
1308static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va, 1308static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
1309 unsigned long flags, void *caller) 1309 unsigned long flags, const void *caller)
1310{ 1310{
1311 setup_vmalloc_vm(vm, va, flags, caller); 1311 setup_vmalloc_vm(vm, va, flags, caller);
1312 insert_vmalloc_vmlist(vm); 1312 insert_vmalloc_vmlist(vm);
@@ -1314,7 +1314,7 @@ static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
1314 1314
1315static struct vm_struct *__get_vm_area_node(unsigned long size, 1315static struct vm_struct *__get_vm_area_node(unsigned long size,
1316 unsigned long align, unsigned long flags, unsigned long start, 1316 unsigned long align, unsigned long flags, unsigned long start,
1317 unsigned long end, int node, gfp_t gfp_mask, void *caller) 1317 unsigned long end, int node, gfp_t gfp_mask, const void *caller)
1318{ 1318{
1319 struct vmap_area *va; 1319 struct vmap_area *va;
1320 struct vm_struct *area; 1320 struct vm_struct *area;
@@ -1375,7 +1375,7 @@ EXPORT_SYMBOL_GPL(__get_vm_area);
1375 1375
1376struct vm_struct *__get_vm_area_caller(unsigned long size, unsigned long flags, 1376struct vm_struct *__get_vm_area_caller(unsigned long size, unsigned long flags,
1377 unsigned long start, unsigned long end, 1377 unsigned long start, unsigned long end,
1378 void *caller) 1378 const void *caller)
1379{ 1379{
1380 return __get_vm_area_node(size, 1, flags, start, end, -1, GFP_KERNEL, 1380 return __get_vm_area_node(size, 1, flags, start, end, -1, GFP_KERNEL,
1381 caller); 1381 caller);
@@ -1397,13 +1397,21 @@ struct vm_struct *get_vm_area(unsigned long size, unsigned long flags)
1397} 1397}
1398 1398
1399struct vm_struct *get_vm_area_caller(unsigned long size, unsigned long flags, 1399struct vm_struct *get_vm_area_caller(unsigned long size, unsigned long flags,
1400 void *caller) 1400 const void *caller)
1401{ 1401{
1402 return __get_vm_area_node(size, 1, flags, VMALLOC_START, VMALLOC_END, 1402 return __get_vm_area_node(size, 1, flags, VMALLOC_START, VMALLOC_END,
1403 -1, GFP_KERNEL, caller); 1403 -1, GFP_KERNEL, caller);
1404} 1404}
1405 1405
1406static struct vm_struct *find_vm_area(const void *addr) 1406/**
1407 * find_vm_area - find a continuous kernel virtual area
1408 * @addr: base address
1409 *
1410 * Search for the kernel VM area starting at @addr, and return it.
1411 * It is up to the caller to do all required locking to keep the returned
1412 * pointer valid.
1413 */
1414struct vm_struct *find_vm_area(const void *addr)
1407{ 1415{
1408 struct vmap_area *va; 1416 struct vmap_area *va;
1409 1417
@@ -1568,9 +1576,9 @@ EXPORT_SYMBOL(vmap);
1568 1576
1569static void *__vmalloc_node(unsigned long size, unsigned long align, 1577static void *__vmalloc_node(unsigned long size, unsigned long align,
1570 gfp_t gfp_mask, pgprot_t prot, 1578 gfp_t gfp_mask, pgprot_t prot,
1571 int node, void *caller); 1579 int node, const void *caller);
1572static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, 1580static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1573 pgprot_t prot, int node, void *caller) 1581 pgprot_t prot, int node, const void *caller)
1574{ 1582{
1575 const int order = 0; 1583 const int order = 0;
1576 struct page **pages; 1584 struct page **pages;
@@ -1643,7 +1651,7 @@ fail:
1643 */ 1651 */
1644void *__vmalloc_node_range(unsigned long size, unsigned long align, 1652void *__vmalloc_node_range(unsigned long size, unsigned long align,
1645 unsigned long start, unsigned long end, gfp_t gfp_mask, 1653 unsigned long start, unsigned long end, gfp_t gfp_mask,
1646 pgprot_t prot, int node, void *caller) 1654 pgprot_t prot, int node, const void *caller)
1647{ 1655{
1648 struct vm_struct *area; 1656 struct vm_struct *area;
1649 void *addr; 1657 void *addr;
@@ -1699,7 +1707,7 @@ fail:
1699 */ 1707 */
1700static void *__vmalloc_node(unsigned long size, unsigned long align, 1708static void *__vmalloc_node(unsigned long size, unsigned long align,
1701 gfp_t gfp_mask, pgprot_t prot, 1709 gfp_t gfp_mask, pgprot_t prot,
1702 int node, void *caller) 1710 int node, const void *caller)
1703{ 1711{
1704 return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END, 1712 return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END,
1705 gfp_mask, prot, node, caller); 1713 gfp_mask, prot, node, caller);
diff --git a/scripts/coccinelle/iterators/use_after_iter.cocci b/scripts/coccinelle/iterators/use_after_iter.cocci
new file mode 100644
index 000000000000..06284c57a951
--- /dev/null
+++ b/scripts/coccinelle/iterators/use_after_iter.cocci
@@ -0,0 +1,147 @@
1/// If list_for_each_entry, etc complete a traversal of the list, the iterator
2/// variable ends up pointing to an address at an offset from the list head,
3/// and not a meaningful structure. Thus this value should not be used after
4/// the end of the iterator.
5//#False positives arise when there is a goto in the iterator and the
6//#reported reference is at the label of this goto. Some flag tests
7//#may also cause a report to be a false positive.
8///
9// Confidence: Moderate
10// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
11// Copyright: (C) 2012 Gilles Muller, INRIA/LIP6. GPLv2.
12// URL: http://coccinelle.lip6.fr/
13// Comments:
14// Options: -no_includes -include_headers
15
16virtual context
17virtual org
18virtual report
19
20@r exists@
21identifier c,member;
22expression E,x;
23iterator name list_for_each_entry;
24iterator name list_for_each_entry_reverse;
25iterator name list_for_each_entry_continue;
26iterator name list_for_each_entry_continue_reverse;
27iterator name list_for_each_entry_from;
28iterator name list_for_each_entry_safe;
29iterator name list_for_each_entry_safe_continue;
30iterator name list_for_each_entry_safe_from;
31iterator name list_for_each_entry_safe_reverse;
32iterator name hlist_for_each_entry;
33iterator name hlist_for_each_entry_continue;
34iterator name hlist_for_each_entry_from;
35iterator name hlist_for_each_entry_safe;
36statement S;
37position p1,p2;
38@@
39
40(
41list_for_each_entry@p1(c,...,member) { ... when != break;
42 when forall
43 when strict
44}
45|
46list_for_each_entry_reverse@p1(c,...,member) { ... when != break;
47 when forall
48 when strict
49}
50|
51list_for_each_entry_continue@p1(c,...,member) { ... when != break;
52 when forall
53 when strict
54}
55|
56list_for_each_entry_continue_reverse@p1(c,...,member) { ... when != break;
57 when forall
58 when strict
59}
60|
61list_for_each_entry_from@p1(c,...,member) { ... when != break;
62 when forall
63 when strict
64}
65|
66list_for_each_entry_safe@p1(c,...,member) { ... when != break;
67 when forall
68 when strict
69}
70|
71list_for_each_entry_safe_continue@p1(c,...,member) { ... when != break;
72 when forall
73 when strict
74}
75|
76list_for_each_entry_safe_from@p1(c,...,member) { ... when != break;
77 when forall
78 when strict
79}
80|
81list_for_each_entry_safe_reverse@p1(c,...,member) { ... when != break;
82 when forall
83 when strict
84}
85)
86...
87(
88list_for_each_entry(c,...) S
89|
90list_for_each_entry_reverse(c,...) S
91|
92list_for_each_entry_continue(c,...) S
93|
94list_for_each_entry_continue_reverse(c,...) S
95|
96list_for_each_entry_from(c,...) S
97|
98list_for_each_entry_safe(c,...) S
99|
100list_for_each_entry_safe(x,c,...) S
101|
102list_for_each_entry_safe_continue(c,...) S
103|
104list_for_each_entry_safe_continue(x,c,...) S
105|
106list_for_each_entry_safe_from(c,...) S
107|
108list_for_each_entry_safe_from(x,c,...) S
109|
110list_for_each_entry_safe_reverse(c,...) S
111|
112list_for_each_entry_safe_reverse(x,c,...) S
113|
114hlist_for_each_entry(c,...) S
115|
116hlist_for_each_entry_continue(c,...) S
117|
118hlist_for_each_entry_from(c,...) S
119|
120hlist_for_each_entry_safe(c,...) S
121|
122list_remove_head(x,c,...)
123|
124sizeof(<+...c...+>)
125|
126&c->member
127|
128c = E
129|
130*c@p2
131)
132
133@script:python depends on org@
134p1 << r.p1;
135p2 << r.p2;
136@@
137
138cocci.print_main("invalid iterator index reference",p2)
139cocci.print_secs("iterator",p1)
140
141@script:python depends on report@
142p1 << r.p1;
143p2 << r.p2;
144@@
145
146msg = "ERROR: invalid reference to the index variable of the iterator on line %s" % (p1[0].line)
147coccilib.report.print_report(p2[0], msg)
diff --git a/scripts/coccinelle/misc/irqf_oneshot.cocci b/scripts/coccinelle/misc/irqf_oneshot.cocci
new file mode 100644
index 000000000000..6cfde94be0ef
--- /dev/null
+++ b/scripts/coccinelle/misc/irqf_oneshot.cocci
@@ -0,0 +1,65 @@
1/// Make sure threaded IRQs without a primary handler are always request with
2/// IRQF_ONESHOT
3///
4//
5// Confidence: Good
6// Comments:
7// Options: --no-includes
8
9virtual patch
10virtual context
11virtual org
12virtual report
13
14@r1@
15expression irq;
16expression thread_fn;
17expression flags;
18position p;
19@@
20request_threaded_irq@p(irq, NULL, thread_fn,
21(
22flags | IRQF_ONESHOT
23|
24IRQF_ONESHOT
25)
26, ...)
27
28@depends on patch@
29expression irq;
30expression thread_fn;
31expression flags;
32position p != r1.p;
33@@
34request_threaded_irq@p(irq, NULL, thread_fn,
35(
36-0
37+IRQF_ONESHOT
38|
39-flags
40+flags | IRQF_ONESHOT
41)
42, ...)
43
44@depends on context@
45position p != r1.p;
46@@
47*request_threaded_irq@p(...)
48
49@match depends on report || org@
50expression irq;
51position p != r1.p;
52@@
53request_threaded_irq@p(irq, NULL, ...)
54
55@script:python depends on org@
56p << match.p;
57@@
58msg = "ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT"
59coccilib.org.print_todo(p[0],msg)
60
61@script:python depends on report@
62p << match.p;
63@@
64msg = "ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT"
65coccilib.report.print_report(p[0],msg)
diff --git a/scripts/config b/scripts/config
index ed6653ef9702..ee355394f4ef 100755
--- a/scripts/config
+++ b/scripts/config
@@ -1,6 +1,9 @@
1#!/bin/bash 1#!/bin/bash
2# Manipulate options in a .config file from the command line 2# Manipulate options in a .config file from the command line
3 3
4# If no prefix forced, use the default CONFIG_
5CONFIG_="${CONFIG_-CONFIG_}"
6
4usage() { 7usage() {
5 cat >&2 <<EOL 8 cat >&2 <<EOL
6Manipulate options in a .config file from the command line. 9Manipulate options in a .config file from the command line.
@@ -14,6 +17,7 @@ commands:
14 Set option to "string" 17 Set option to "string"
15 --set-val option value 18 --set-val option value
16 Set option to value 19 Set option to value
20 --undefine|-u option Undefine option
17 --state|-s option Print state of option (n,y,m,undef) 21 --state|-s option Print state of option (n,y,m,undef)
18 22
19 --enable-after|-E beforeopt option 23 --enable-after|-E beforeopt option
@@ -26,10 +30,17 @@ commands:
26 commands can be repeated multiple times 30 commands can be repeated multiple times
27 31
28options: 32options:
29 --file .config file to change (default .config) 33 --file config-file .config file to change (default .config)
34 --keep-case|-k Keep next symbols' case (dont' upper-case it)
30 35
31config doesn't check the validity of the .config file. This is done at next 36config doesn't check the validity of the .config file. This is done at next
32 make time. 37make time.
38
39By default, config will upper-case the given symbol. Use --keep-case to keep
40the case of all following symbols unchanged.
41
42config uses 'CONFIG_' as the default symbol prefix. Set the environment
43variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" config ...
33EOL 44EOL
34 exit 1 45 exit 1
35} 46}
@@ -40,11 +51,13 @@ checkarg() {
40 usage 51 usage
41 fi 52 fi
42 case "$ARG" in 53 case "$ARG" in
43 CONFIG_*) 54 ${CONFIG_}*)
44 ARG="${ARG/CONFIG_/}" 55 ARG="${ARG/${CONFIG_}/}"
45 ;; 56 ;;
46 esac 57 esac
47 ARG="`echo $ARG | tr a-z A-Z`" 58 if [ "$MUNGE_CASE" = "yes" ] ; then
59 ARG="`echo $ARG | tr a-z A-Z`"
60 fi
48} 61}
49 62
50set_var() { 63set_var() {
@@ -61,6 +74,12 @@ set_var() {
61 fi 74 fi
62} 75}
63 76
77undef_var() {
78 local name=$1
79
80 sed -ri "/^($name=|# $name is not set)/d" "$FN"
81}
82
64if [ "$1" = "--file" ]; then 83if [ "$1" = "--file" ]; then
65 FN="$2" 84 FN="$2"
66 if [ "$FN" = "" ] ; then 85 if [ "$FN" = "" ] ; then
@@ -75,10 +94,16 @@ if [ "$1" = "" ] ; then
75 usage 94 usage
76fi 95fi
77 96
97MUNGE_CASE=yes
78while [ "$1" != "" ] ; do 98while [ "$1" != "" ] ; do
79 CMD="$1" 99 CMD="$1"
80 shift 100 shift
81 case "$CMD" in 101 case "$CMD" in
102 --keep-case|-k)
103 MUNGE_CASE=no
104 shift
105 continue
106 ;;
82 --refresh) 107 --refresh)
83 ;; 108 ;;
84 --*-after) 109 --*-after)
@@ -95,55 +120,58 @@ while [ "$1" != "" ] ; do
95 esac 120 esac
96 case "$CMD" in 121 case "$CMD" in
97 --enable|-e) 122 --enable|-e)
98 set_var "CONFIG_$ARG" "CONFIG_$ARG=y" 123 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
99 ;; 124 ;;
100 125
101 --disable|-d) 126 --disable|-d)
102 set_var "CONFIG_$ARG" "# CONFIG_$ARG is not set" 127 set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
103 ;; 128 ;;
104 129
105 --module|-m) 130 --module|-m)
106 set_var "CONFIG_$ARG" "CONFIG_$ARG=m" 131 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
107 ;; 132 ;;
108 133
109 --set-str) 134 --set-str)
110 # sed swallows one level of escaping, so we need double-escaping 135 # sed swallows one level of escaping, so we need double-escaping
111 set_var "CONFIG_$ARG" "CONFIG_$ARG=\"${1//\"/\\\\\"}\"" 136 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
112 shift 137 shift
113 ;; 138 ;;
114 139
115 --set-val) 140 --set-val)
116 set_var "CONFIG_$ARG" "CONFIG_$ARG=$1" 141 set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
117 shift 142 shift
118 ;; 143 ;;
144 --undefine|-u)
145 undef_var "${CONFIG_}$ARG"
146 ;;
119 147
120 --state|-s) 148 --state|-s)
121 if grep -q "# CONFIG_$ARG is not set" $FN ; then 149 if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
122 echo n 150 echo n
123 else 151 else
124 V="$(grep "^CONFIG_$ARG=" $FN)" 152 V="$(grep "^${CONFIG_}$ARG=" $FN)"
125 if [ $? != 0 ] ; then 153 if [ $? != 0 ] ; then
126 echo undef 154 echo undef
127 else 155 else
128 V="${V/#CONFIG_$ARG=/}" 156 V="${V/#${CONFIG_}$ARG=/}"
129 V="${V/#\"/}" 157 V="${V/#\"/}"
130 V="${V/%\"/}" 158 V="${V/%\"/}"
131 V="${V/\\\"/\"}" 159 V="${V//\\\"/\"}"
132 echo "${V}" 160 echo "${V}"
133 fi 161 fi
134 fi 162 fi
135 ;; 163 ;;
136 164
137 --enable-after|-E) 165 --enable-after|-E)
138 set_var "CONFIG_$B" "CONFIG_$B=y" "CONFIG_$A" 166 set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
139 ;; 167 ;;
140 168
141 --disable-after|-D) 169 --disable-after|-D)
142 set_var "CONFIG_$B" "# CONFIG_$B is not set" "CONFIG_$A" 170 set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A"
143 ;; 171 ;;
144 172
145 --module-after|-M) 173 --module-after|-M)
146 set_var "CONFIG_$B" "CONFIG_$B=m" "CONFIG_$A" 174 set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
147 ;; 175 ;;
148 176
149 # undocumented because it ignores --file (fixme) 177 # undocumented because it ignores --file (fixme)
diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore
index ee120d441565..be603c4fef62 100644
--- a/scripts/kconfig/.gitignore
+++ b/scripts/kconfig/.gitignore
@@ -7,7 +7,6 @@ config*
7*.tab.h 7*.tab.h
8zconf.hash.c 8zconf.hash.c
9*.moc 9*.moc
10lkc_defs.h
11gconf.glade.h 10gconf.glade.h
12*.pot 11*.pot
13*.mo 12*.mo
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 79662658fb91..77d53999ffb9 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -114,7 +114,7 @@ help:
114 @echo ' alldefconfig - New config with all symbols set to default' 114 @echo ' alldefconfig - New config with all symbols set to default'
115 @echo ' randconfig - New config with random answer to all options' 115 @echo ' randconfig - New config with random answer to all options'
116 @echo ' listnewconfig - List new options' 116 @echo ' listnewconfig - List new options'
117 @echo ' oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)' 117 @echo ' oldnoconfig - Same as silentoldconfig but sets new symbols to their default value'
118 118
119# lxdialog stuff 119# lxdialog stuff
120check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh 120check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
@@ -234,12 +234,12 @@ $(obj)/.tmp_qtcheck:
234 if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \ 234 if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
235 done; \ 235 done; \
236 if [ -z "$$dir" ]; then \ 236 if [ -z "$$dir" ]; then \
237 echo "*"; \ 237 echo >&2 "*"; \
238 echo "* Unable to find any QT installation. Please make sure that"; \ 238 echo >&2 "* Unable to find any QT installation. Please make sure that"; \
239 echo "* the QT4 or QT3 development package is correctly installed and"; \ 239 echo >&2 "* the QT4 or QT3 development package is correctly installed and"; \
240 echo "* either qmake can be found or install pkg-config or set"; \ 240 echo >&2 "* either qmake can be found or install pkg-config or set"; \
241 echo "* the QTDIR environment variable to the correct location."; \ 241 echo >&2 "* the QTDIR environment variable to the correct location."; \
242 echo "*"; \ 242 echo >&2 "*"; \
243 false; \ 243 false; \
244 fi; \ 244 fi; \
245 libpath=$$dir/lib; lib=qt; osdir=""; \ 245 libpath=$$dir/lib; lib=qt; osdir=""; \
@@ -260,8 +260,8 @@ $(obj)/.tmp_qtcheck:
260 else \ 260 else \
261 cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \ 261 cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \
262 libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \ 262 libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \
263 binpath="\$$(shell pkg-config QtCore --variable=prefix)"; \ 263 moc="\$$(shell pkg-config QtCore --variable=moc_location)"; \
264 moc="$$binpath/bin/moc"; \ 264 [ -n "$$moc" ] || moc="\$$(shell pkg-config QtCore --variable=prefix)/bin/moc"; \
265 fi; \ 265 fi; \
266 echo "KC_QT_CFLAGS=$$cflags" > $@; \ 266 echo "KC_QT_CFLAGS=$$cflags" > $@; \
267 echo "KC_QT_LIBS=$$libs" >> $@; \ 267 echo "KC_QT_LIBS=$$libs" >> $@; \
@@ -279,17 +279,17 @@ $(obj)/.tmp_gtkcheck:
279 if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \ 279 if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
280 touch $@; \ 280 touch $@; \
281 else \ 281 else \
282 echo "*"; \ 282 echo >&2 "*"; \
283 echo "* GTK+ is present but version >= 2.0.0 is required."; \ 283 echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \
284 echo "*"; \ 284 echo >&2 "*"; \
285 false; \ 285 false; \
286 fi \ 286 fi \
287 else \ 287 else \
288 echo "*"; \ 288 echo >&2 "*"; \
289 echo "* Unable to find the GTK+ installation. Please make sure that"; \ 289 echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \
290 echo "* the GTK+ 2.0 development package is correctly installed..."; \ 290 echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \
291 echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \ 291 echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
292 echo "*"; \ 292 echo >&2 "*"; \
293 false; \ 293 false; \
294 fi 294 fi
295endif 295endif
@@ -298,8 +298,11 @@ $(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c
298 298
299$(obj)/qconf.o: $(obj)/qconf.moc 299$(obj)/qconf.o: $(obj)/qconf.moc
300 300
301$(obj)/%.moc: $(src)/%.h 301quiet_cmd_moc = MOC $@
302 $(KC_QT_MOC) -i $< -o $@ 302 cmd_moc = $(KC_QT_MOC) -i $< -o $@
303
304$(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck
305 $(call cmd,moc)
303 306
304# Extract gconf menu items for I18N support 307# Extract gconf menu items for I18N support
305$(obj)/gconf.glade.h: $(obj)/gconf.glade 308$(obj)/gconf.glade.h: $(obj)/gconf.glade
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 52577f052bc1..13ddf1126c2a 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -182,10 +182,66 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
182 return 0; 182 return 0;
183} 183}
184 184
185#define LINE_GROWTH 16
186static int add_byte(int c, char **lineptr, size_t slen, size_t *n)
187{
188 char *nline;
189 size_t new_size = slen + 1;
190 if (new_size > *n) {
191 new_size += LINE_GROWTH - 1;
192 new_size *= 2;
193 nline = realloc(*lineptr, new_size);
194 if (!nline)
195 return -1;
196
197 *lineptr = nline;
198 *n = new_size;
199 }
200
201 (*lineptr)[slen] = c;
202
203 return 0;
204}
205
206static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream)
207{
208 char *line = *lineptr;
209 size_t slen = 0;
210
211 for (;;) {
212 int c = getc(stream);
213
214 switch (c) {
215 case '\n':
216 if (add_byte(c, &line, slen, n) < 0)
217 goto e_out;
218 slen++;
219 /* fall through */
220 case EOF:
221 if (add_byte('\0', &line, slen, n) < 0)
222 goto e_out;
223 *lineptr = line;
224 if (slen == 0)
225 return -1;
226 return slen;
227 default:
228 if (add_byte(c, &line, slen, n) < 0)
229 goto e_out;
230 slen++;
231 }
232 }
233
234e_out:
235 line[slen-1] = '\0';
236 *lineptr = line;
237 return -1;
238}
239
185int conf_read_simple(const char *name, int def) 240int conf_read_simple(const char *name, int def)
186{ 241{
187 FILE *in = NULL; 242 FILE *in = NULL;
188 char line[1024]; 243 char *line = NULL;
244 size_t line_asize = 0;
189 char *p, *p2; 245 char *p, *p2;
190 struct symbol *sym; 246 struct symbol *sym;
191 int i, def_flags; 247 int i, def_flags;
@@ -247,7 +303,7 @@ load:
247 } 303 }
248 } 304 }
249 305
250 while (fgets(line, sizeof(line), in)) { 306 while (compat_getline(&line, &line_asize, in) != -1) {
251 conf_lineno++; 307 conf_lineno++;
252 sym = NULL; 308 sym = NULL;
253 if (line[0] == '#') { 309 if (line[0] == '#') {
@@ -335,6 +391,7 @@ setsym:
335 cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri); 391 cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
336 } 392 }
337 } 393 }
394 free(line);
338 fclose(in); 395 fclose(in);
339 396
340 if (modules_sym) 397 if (modules_sym)
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
index 82cc3a85e7f8..e3b12c010417 100644
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -4,7 +4,7 @@
4# What library to link 4# What library to link
5ldflags() 5ldflags()
6{ 6{
7 for ext in so a dylib ; do 7 for ext in so a dll.a dylib ; do
8 for lib in ncursesw ncurses curses ; do 8 for lib in ncursesw ncurses curses ; do
9 $cc -print-file-name=lib${lib}.${ext} | grep -q / 9 $cc -print-file-name=lib${lib}.${ext} | grep -q /
10 if [ $? -eq 0 ]; then 10 if [ $? -eq 0 ]; then
@@ -19,12 +19,12 @@ ldflags()
19# Where is ncurses.h? 19# Where is ncurses.h?
20ccflags() 20ccflags()
21{ 21{
22 if [ -f /usr/include/ncurses/ncurses.h ]; then 22 if [ -f /usr/include/ncursesw/curses.h ]; then
23 echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
24 elif [ -f /usr/include/ncurses/ncurses.h ]; then
23 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"' 25 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
24 elif [ -f /usr/include/ncurses/curses.h ]; then 26 elif [ -f /usr/include/ncurses/curses.h ]; then
25 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"' 27 echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
26 elif [ -f /usr/include/ncursesw/curses.h ]; then
27 echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
28 elif [ -f /usr/include/ncurses.h ]; then 28 elif [ -f /usr/include/ncurses.h ]; then
29 echo '-DCURSES_LOC="<ncurses.h>"' 29 echo '-DCURSES_LOC="<ncurses.h>"'
30 else 30 else
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c
index 154c2dd245b7..4e5de60a0c0d 100644
--- a/scripts/kconfig/lxdialog/textbox.c
+++ b/scripts/kconfig/lxdialog/textbox.c
@@ -129,6 +129,7 @@ do_resize:
129 case 'e': 129 case 'e':
130 case 'X': 130 case 'X':
131 case 'x': 131 case 'x':
132 case 'q':
132 delwin(box); 133 delwin(box);
133 delwin(dialog); 134 delwin(dialog);
134 return 0; 135 return 0;
@@ -190,6 +191,7 @@ do_resize:
190 break; 191 break;
191 case 'B': /* Previous page */ 192 case 'B': /* Previous page */
192 case 'b': 193 case 'b':
194 case 'u':
193 case KEY_PPAGE: 195 case KEY_PPAGE:
194 if (begin_reached) 196 if (begin_reached)
195 break; 197 break;
@@ -214,6 +216,7 @@ do_resize:
214 break; 216 break;
215 case KEY_NPAGE: /* Next page */ 217 case KEY_NPAGE: /* Next page */
216 case ' ': 218 case ' ':
219 case 'd':
217 if (end_reached) 220 if (end_reached)
218 break; 221 break;
219 222
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index f606738d421d..f584a281bb4c 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -105,10 +105,10 @@ static const char mconf_readme[] = N_(
105"Text Box (Help Window)\n" 105"Text Box (Help Window)\n"
106"--------\n" 106"--------\n"
107"o Use the cursor keys to scroll up/down/left/right. The VI editor\n" 107"o Use the cursor keys to scroll up/down/left/right. The VI editor\n"
108" keys h,j,k,l function here as do <SPACE BAR> and <B> for those\n" 108" keys h,j,k,l function here as do <u>, <d>, <SPACE BAR> and <B> for \n"
109" who are familiar with less and lynx.\n" 109" those who are familiar with less and lynx.\n"
110"\n" 110"\n"
111"o Press <E>, <X>, <Enter> or <Esc><Esc> to exit.\n" 111"o Press <E>, <X>, <q>, <Enter> or <Esc><Esc> to exit.\n"
112"\n" 112"\n"
113"\n" 113"\n"
114"Alternate Configuration Files\n" 114"Alternate Configuration Files\n"
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index 8c0eb65978c9..1704a8562a5d 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -83,10 +83,10 @@ static const char nconf_readme[] = N_(
83"Text Box (Help Window)\n" 83"Text Box (Help Window)\n"
84"--------\n" 84"--------\n"
85"o Use the cursor keys to scroll up/down/left/right. The VI editor\n" 85"o Use the cursor keys to scroll up/down/left/right. The VI editor\n"
86" keys h,j,k,l function here as do <SPACE BAR> for those\n" 86" keys h,j,k,l function here as do <u>, <d> and <SPACE BAR> for\n"
87" who are familiar with less and lynx.\n" 87" those who are familiar with less and lynx.\n"
88"\n" 88"\n"
89"o Press <Enter>, <F1>, <F5>, <F7> or <Esc> to exit.\n" 89"o Press <Enter>, <F1>, <F5>, <F9>, <q> or <Esc> to exit.\n"
90"\n" 90"\n"
91"\n" 91"\n"
92"Alternate Configuration Files\n" 92"Alternate Configuration Files\n"
@@ -1503,7 +1503,11 @@ int main(int ac, char **av)
1503 } 1503 }
1504 1504
1505 notimeout(stdscr, FALSE); 1505 notimeout(stdscr, FALSE);
1506#if NCURSES_REENTRANT
1507 set_escdelay(1);
1508#else
1506 ESCDELAY = 1; 1509 ESCDELAY = 1;
1510#endif
1507 1511
1508 /* set btns menu */ 1512 /* set btns menu */
1509 curses_menu = new_menu(curses_menu_items); 1513 curses_menu = new_menu(curses_menu_items);
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
index 3b18dd839668..379003c7a2b4 100644
--- a/scripts/kconfig/nconf.gui.c
+++ b/scripts/kconfig/nconf.gui.c
@@ -604,9 +604,11 @@ void show_scroll_win(WINDOW *main_window,
604 switch (res) { 604 switch (res) {
605 case KEY_NPAGE: 605 case KEY_NPAGE:
606 case ' ': 606 case ' ':
607 case 'd':
607 start_y += text_lines-2; 608 start_y += text_lines-2;
608 break; 609 break;
609 case KEY_PPAGE: 610 case KEY_PPAGE:
611 case 'u':
610 start_y -= text_lines+2; 612 start_y -= text_lines+2;
611 break; 613 break;
612 case KEY_HOME: 614 case KEY_HOME:
@@ -632,10 +634,10 @@ void show_scroll_win(WINDOW *main_window,
632 start_x++; 634 start_x++;
633 break; 635 break;
634 } 636 }
635 if (res == 10 || res == 27 || res == 'q' 637 if (res == 10 || res == 27 || res == 'q' ||
636 || res == KEY_F(F_BACK) || res == KEY_F(F_EXIT)) { 638 res == KEY_F(F_HELP) || res == KEY_F(F_BACK) ||
639 res == KEY_F(F_EXIT))
637 break; 640 break;
638 }
639 if (start_y < 0) 641 if (start_y < 0)
640 start_y = 0; 642 start_y = 0;
641 if (start_y >= total_lines-text_lines) 643 if (start_y >= total_lines-text_lines)
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index bccf07ddd0b6..2fbbbc1ddea0 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -45,6 +45,16 @@
45use strict; 45use strict;
46use Getopt::Long; 46use Getopt::Long;
47 47
48# set the environment variable LOCALMODCONFIG_DEBUG to get
49# debug output.
50my $debugprint = 0;
51$debugprint = 1 if (defined($ENV{LOCALMODCONFIG_DEBUG}));
52
53sub dprint {
54 return if (!$debugprint);
55 print STDERR @_;
56}
57
48my $config = ".config"; 58my $config = ".config";
49 59
50my $uname = `uname -r`; 60my $uname = `uname -r`;
@@ -113,6 +123,10 @@ sub find_config {
113 123
114find_config; 124find_config;
115 125
126# Read in the entire config file into config_file
127my @config_file = <CIN>;
128close CIN;
129
116# Parse options 130# Parse options
117my $localmodconfig = 0; 131my $localmodconfig = 0;
118my $localyesconfig = 0; 132my $localyesconfig = 0;
@@ -186,6 +200,7 @@ sub read_kconfig {
186 $state = "NEW"; 200 $state = "NEW";
187 $config = $2; 201 $config = $2;
188 202
203 # Add depends for 'if' nesting
189 for (my $i = 0; $i < $iflevel; $i++) { 204 for (my $i = 0; $i < $iflevel; $i++) {
190 if ($i) { 205 if ($i) {
191 $depends{$config} .= " " . $ifdeps[$i]; 206 $depends{$config} .= " " . $ifdeps[$i];
@@ -204,10 +219,11 @@ sub read_kconfig {
204 219
205 # Get the configs that select this config 220 # Get the configs that select this config
206 } elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) { 221 } elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) {
207 if (defined($selects{$1})) { 222 my $conf = $1;
208 $selects{$1} .= " " . $config; 223 if (defined($selects{$conf})) {
224 $selects{$conf} .= " " . $config;
209 } else { 225 } else {
210 $selects{$1} = $config; 226 $selects{$conf} = $config;
211 } 227 }
212 228
213 # configs without prompts must be selected 229 # configs without prompts must be selected
@@ -250,6 +266,7 @@ if ($kconfig) {
250 read_kconfig($kconfig); 266 read_kconfig($kconfig);
251} 267}
252 268
269# Makefiles can use variables to define their dependencies
253sub convert_vars { 270sub convert_vars {
254 my ($line, %vars) = @_; 271 my ($line, %vars) = @_;
255 272
@@ -293,6 +310,7 @@ foreach my $makefile (@makefiles) {
293 310
294 my $objs; 311 my $objs;
295 312
313 # Convert variables in a line (could define configs)
296 $_ = convert_vars($_, %make_vars); 314 $_ = convert_vars($_, %make_vars);
297 315
298 # collect objects after obj-$(CONFIG_FOO_BAR) 316 # collect objects after obj-$(CONFIG_FOO_BAR)
@@ -373,13 +391,15 @@ while (<LIN>) {
373close (LIN); 391close (LIN);
374 392
375# add to the configs hash all configs that are needed to enable 393# add to the configs hash all configs that are needed to enable
376# a loaded module. 394# a loaded module. This is a direct obj-${CONFIG_FOO} += bar.o
395# where we know we need bar.o so we add FOO to the list.
377my %configs; 396my %configs;
378foreach my $module (keys(%modules)) { 397foreach my $module (keys(%modules)) {
379 if (defined($objects{$module})) { 398 if (defined($objects{$module})) {
380 my @arr = @{$objects{$module}}; 399 my @arr = @{$objects{$module}};
381 foreach my $conf (@arr) { 400 foreach my $conf (@arr) {
382 $configs{$conf} = $module; 401 $configs{$conf} = $module;
402 dprint "$conf added by direct ($module)\n";
383 } 403 }
384 } else { 404 } else {
385 # Most likely, someone has a custom (binary?) module loaded. 405 # Most likely, someone has a custom (binary?) module loaded.
@@ -387,9 +407,24 @@ foreach my $module (keys(%modules)) {
387 } 407 }
388} 408}
389 409
410# Read the current config, and see what is enabled. We want to
411# ignore configs that we would not enable anyway.
412
413my %orig_configs;
390my $valid = "A-Za-z_0-9"; 414my $valid = "A-Za-z_0-9";
415
416foreach my $line (@config_file) {
417 $_ = $line;
418
419 if (/(CONFIG_[$valid]*)=(m|y)/) {
420 $orig_configs{$1} = $2;
421 }
422}
423
391my $repeat = 1; 424my $repeat = 1;
392 425
426my $depconfig;
427
393# 428#
394# Note, we do not care about operands (like: &&, ||, !) we want to add any 429# Note, we do not care about operands (like: &&, ||, !) we want to add any
395# config that is in the depend list of another config. This script does 430# config that is in the depend list of another config. This script does
@@ -398,7 +433,7 @@ my $repeat = 1;
398# to keep on. If A was on in the original config, B would not have been 433# to keep on. If A was on in the original config, B would not have been
399# and B would not be turned on by this script. 434# and B would not be turned on by this script.
400# 435#
401sub parse_config_dep_select 436sub parse_config_depends
402{ 437{
403 my ($p) = @_; 438 my ($p) = @_;
404 439
@@ -409,10 +444,16 @@ sub parse_config_dep_select
409 444
410 $p =~ s/^[^$valid]*[$valid]+//; 445 $p =~ s/^[^$valid]*[$valid]+//;
411 446
447 # We only need to process if the depend config is a module
448 if (!defined($orig_configs{$conf}) || !$orig_configs{conf} eq "m") {
449 next;
450 }
451
412 if (!defined($configs{$conf})) { 452 if (!defined($configs{$conf})) {
413 # We must make sure that this config has its 453 # We must make sure that this config has its
414 # dependencies met. 454 # dependencies met.
415 $repeat = 1; # do again 455 $repeat = 1; # do again
456 dprint "$conf selected by depend $depconfig\n";
416 $configs{$conf} = 1; 457 $configs{$conf} = 1;
417 } 458 }
418 } else { 459 } else {
@@ -421,31 +462,132 @@ sub parse_config_dep_select
421 } 462 }
422} 463}
423 464
424while ($repeat) { 465# Select is treated a bit differently than depends. We call this
425 $repeat = 0; 466# when a config has no prompt and requires another config to be
467# selected. We use to just select all configs that selected this
468# config, but found that that can balloon into enabling hundreds
469# of configs that we do not care about.
470#
471# The idea is we look at all the configs that select it. If one
472# is already in our list of configs to enable, then there's nothing
473# else to do. If there isn't, we pick the first config that was
474# enabled in the orignal config and use that.
475sub parse_config_selects
476{
477 my ($config, $p) = @_;
426 478
427 foreach my $config (keys %configs) { 479 my $next_config;
428 $config =~ s/^CONFIG_//; 480
481 while ($p =~ /[$valid]/) {
429 482
430 if (defined($depends{$config})) { 483 if ($p =~ /^[^$valid]*([$valid]+)/) {
431 # This config has dependencies. Make sure they are also included 484 my $conf = "CONFIG_" . $1;
432 parse_config_dep_select $depends{$config}; 485
486 $p =~ s/^[^$valid]*[$valid]+//;
487
488 # Make sure that this config exists in the current .config file
489 if (!defined($orig_configs{$conf})) {
490 dprint "$conf not set for $config select\n";
491 next;
492 }
493
494 # Check if something other than a module selects this config
495 if (defined($orig_configs{$conf}) && $orig_configs{$conf} ne "m") {
496 dprint "$conf (non module) selects config, we are good\n";
497 # we are good with this
498 return;
499 }
500 if (defined($configs{$conf})) {
501 dprint "$conf selects $config so we are good\n";
502 # A set config selects this config, we are good
503 return;
504 }
505 # Set this config to be selected
506 if (!defined($next_config)) {
507 $next_config = $conf;
508 }
509 } else {
510 die "this should never happen";
433 } 511 }
512 }
434 513
435 if (defined($prompts{$config}) || !defined($selects{$config})) { 514 # If no possible config selected this, then something happened.
436 next; 515 if (!defined($next_config)) {
516 print STDERR "WARNING: $config is required, but nothing in the\n";
517 print STDERR " current config selects it.\n";
518 return;
519 }
520
521 # If we are here, then we found no config that is set and
522 # selects this config. Repeat.
523 $repeat = 1;
524 # Make this config need to be selected
525 $configs{$next_config} = 1;
526 dprint "$next_config selected by select $config\n";
527}
528
529my %process_selects;
530
531# loop through all configs, select their dependencies.
532sub loop_depend {
533 $repeat = 1;
534
535 while ($repeat) {
536 $repeat = 0;
537
538 forloop:
539 foreach my $config (keys %configs) {
540
541 # If this config is not a module, we do not need to process it
542 if (defined($orig_configs{$config}) && $orig_configs{$config} ne "m") {
543 next forloop;
544 }
545
546 $config =~ s/^CONFIG_//;
547 $depconfig = $config;
548
549 if (defined($depends{$config})) {
550 # This config has dependencies. Make sure they are also included
551 parse_config_depends $depends{$config};
552 }
553
554 # If the config has no prompt, then we need to check if a config
555 # that is enabled selected it. Or if we need to enable one.
556 if (!defined($prompts{$config}) && defined($selects{$config})) {
557 $process_selects{$config} = 1;
558 }
437 } 559 }
560 }
561}
562
563sub loop_select {
564
565 foreach my $config (keys %process_selects) {
566 $config =~ s/^CONFIG_//;
567
568 dprint "Process select $config\n";
438 569
439 # config has no prompt and must be selected. 570 # config has no prompt and must be selected.
440 parse_config_dep_select $selects{$config}; 571 parse_config_selects $config, $selects{$config};
441 } 572 }
442} 573}
443 574
575while ($repeat) {
576 # Get the first set of configs and their dependencies.
577 loop_depend;
578
579 $repeat = 0;
580
581 # Now we need to see if we have to check selects;
582 loop_select;
583}
584
444my %setconfigs; 585my %setconfigs;
445 586
446# Finally, read the .config file and turn off any module enabled that 587# Finally, read the .config file and turn off any module enabled that
447# we could not find a reason to keep enabled. 588# we could not find a reason to keep enabled.
448while(<CIN>) { 589foreach my $line (@config_file) {
590 $_ = $line;
449 591
450 if (/CONFIG_IKCONFIG/) { 592 if (/CONFIG_IKCONFIG/) {
451 if (/# CONFIG_IKCONFIG is not set/) { 593 if (/# CONFIG_IKCONFIG is not set/) {
@@ -473,7 +615,6 @@ while(<CIN>) {
473 } 615 }
474 print; 616 print;
475} 617}
476close(CIN);
477 618
478# Integrity check, make sure all modules that we want enabled do 619# Integrity check, make sure all modules that we want enabled do
479# indeed have their configs set. 620# indeed have their configs set.
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index cd9c6c6bb4c9..4629038c9e5a 100644
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -210,8 +210,8 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
210 mksysmap ${kallsyms_vmlinux} .tmp_System.map 210 mksysmap ${kallsyms_vmlinux} .tmp_System.map
211 211
212 if ! cmp -s System.map .tmp_System.map; then 212 if ! cmp -s System.map .tmp_System.map; then
213 echo Inconsistent kallsyms data 213 echo >&2 Inconsistent kallsyms data
214 echo echo Try "make KALLSYMS_EXTRA_PASS=1" as a workaround 214 echo >&2 echo Try "make KALLSYMS_EXTRA_PASS=1" as a workaround
215 cleanup 215 cleanup
216 exit 1 216 exit 1
217 fi 217 fi
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index c95fdda58414..acb86507828a 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -92,7 +92,7 @@ rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir"
92mkdir -m 755 -p "$tmpdir/DEBIAN" 92mkdir -m 755 -p "$tmpdir/DEBIAN"
93mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" 93mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename"
94mkdir -m 755 -p "$fwdir/DEBIAN" 94mkdir -m 755 -p "$fwdir/DEBIAN"
95mkdir -p "$fwdir/lib" "$fwdir/usr/share/doc/$fwpackagename" 95mkdir -p "$fwdir/lib/firmware/$version/" "$fwdir/usr/share/doc/$fwpackagename"
96mkdir -m 755 -p "$libc_headers_dir/DEBIAN" 96mkdir -m 755 -p "$libc_headers_dir/DEBIAN"
97mkdir -p "$libc_headers_dir/usr/share/doc/$libc_headers_packagename" 97mkdir -p "$libc_headers_dir/usr/share/doc/$libc_headers_packagename"
98mkdir -m 755 -p "$kernel_headers_dir/DEBIAN" 98mkdir -m 755 -p "$kernel_headers_dir/DEBIAN"
@@ -243,7 +243,7 @@ EOF
243fi 243fi
244 244
245# Build header package 245# Build header package
246(cd $srctree; find . -name Makefile -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles") 246(cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
247(cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles") 247(cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
248(cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles") 248(cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
249destdir=$kernel_headers_dir/usr/src/linux-headers-$version 249destdir=$kernel_headers_dir/usr/src/linux-headers-$version
@@ -267,7 +267,8 @@ EOF
267 267
268# Do we have firmware? Move it out of the way and build it into a package. 268# Do we have firmware? Move it out of the way and build it into a package.
269if [ -e "$tmpdir/lib/firmware" ]; then 269if [ -e "$tmpdir/lib/firmware" ]; then
270 mv "$tmpdir/lib/firmware" "$fwdir/lib/" 270 mv "$tmpdir/lib/firmware"/* "$fwdir/lib/firmware/$version/"
271 rmdir "$tmpdir/lib/firmware"
271 272
272 cat <<EOF >> debian/control 273 cat <<EOF >> debian/control
273 274
diff --git a/scripts/tags.sh b/scripts/tags.sh
index cf7b12fee573..cff8faad73d1 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -153,7 +153,8 @@ exuberant()
153 --regex-c++='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \ 153 --regex-c++='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \
154 --regex-c++='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \ 154 --regex-c++='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \
155 --regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ 155 --regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \
156 --regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' 156 --regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \
157 --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
157 158
158 all_kconfigs | xargs $1 -a \ 159 all_kconfigs | xargs $1 -a \
159 --langdef=kconfig --language-force=kconfig \ 160 --langdef=kconfig --language-force=kconfig \
@@ -195,7 +196,8 @@ emacs()
195 --regex='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \ 196 --regex='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/' \
196 --regex='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \ 197 --regex='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \
197 --regex='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ 198 --regex='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \
198 --regex='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' 199 --regex='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \
200 --regex='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
199 201
200 all_kconfigs | xargs $1 -a \ 202 all_kconfigs | xargs $1 -a \
201 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' 203 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index ec43760a8a03..6c77f63c7591 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2791,11 +2791,16 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name,
2791 2791
2792 /* We strip a nul only if it is at the end, otherwise the 2792 /* We strip a nul only if it is at the end, otherwise the
2793 * context contains a nul and we should audit that */ 2793 * context contains a nul and we should audit that */
2794 str = value; 2794 if (value) {
2795 if (str[size - 1] == '\0') 2795 str = value;
2796 audit_size = size - 1; 2796 if (str[size - 1] == '\0')
2797 else 2797 audit_size = size - 1;
2798 audit_size = size; 2798 else
2799 audit_size = size;
2800 } else {
2801 str = "";
2802 audit_size = 0;
2803 }
2799 ab = audit_log_start(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR); 2804 ab = audit_log_start(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR);
2800 audit_log_format(ab, "op=setxattr invalid_context="); 2805 audit_log_format(ab, "op=setxattr invalid_context=");
2801 audit_log_n_untrustedstring(ab, value, audit_size); 2806 audit_log_n_untrustedstring(ab, value, audit_size);
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index d31e6d957c21..b1b768e4049a 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -323,11 +323,11 @@ static int smk_parse_long_rule(const char *data, struct smack_rule *rule,
323 int datalen; 323 int datalen;
324 int rc = -1; 324 int rc = -1;
325 325
326 /* 326 /* This is inefficient */
327 * This is probably inefficient, but safe.
328 */
329 datalen = strlen(data); 327 datalen = strlen(data);
330 subject = kzalloc(datalen, GFP_KERNEL); 328
329 /* Our first element can be 64 + \0 with no spaces */
330 subject = kzalloc(datalen + 1, GFP_KERNEL);
331 if (subject == NULL) 331 if (subject == NULL)
332 return -1; 332 return -1;
333 object = kzalloc(datalen, GFP_KERNEL); 333 object = kzalloc(datalen, GFP_KERNEL);
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index 0ff1e70b7770..c084c549942e 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -653,7 +653,7 @@ int twl6040_get_hs_step_size(struct snd_soc_codec *codec)
653{ 653{
654 struct twl6040 *twl6040 = codec->control_data; 654 struct twl6040 *twl6040 = codec->control_data;
655 655
656 if (twl6040_get_revid(twl6040) < TWL6040_REV_ES1_2) 656 if (twl6040_get_revid(twl6040) < TWL6040_REV_ES1_3)
657 /* For ES under ES_1.3 HS step is 2 mV */ 657 /* For ES under ES_1.3 HS step is 2 mV */
658 return 2; 658 return 2;
659 else 659 else
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 292b13ad03f5..52b7959cd513 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -52,6 +52,7 @@ my %default = (
52 "STOP_AFTER_SUCCESS" => 10, 52 "STOP_AFTER_SUCCESS" => 10,
53 "STOP_AFTER_FAILURE" => 60, 53 "STOP_AFTER_FAILURE" => 60,
54 "STOP_TEST_AFTER" => 600, 54 "STOP_TEST_AFTER" => 600,
55 "MAX_MONITOR_WAIT" => 1800,
55 56
56# required, and we will ask users if they don't have them but we keep the default 57# required, and we will ask users if they don't have them but we keep the default
57# value something that is common. 58# value something that is common.
@@ -77,6 +78,11 @@ my $output_config;
77my $test_type; 78my $test_type;
78my $build_type; 79my $build_type;
79my $build_options; 80my $build_options;
81my $final_post_ktest;
82my $pre_ktest;
83my $post_ktest;
84my $pre_test;
85my $post_test;
80my $pre_build; 86my $pre_build;
81my $post_build; 87my $post_build;
82my $pre_build_die; 88my $pre_build_die;
@@ -93,6 +99,7 @@ my $reboot_on_success;
93my $die_on_failure; 99my $die_on_failure;
94my $powercycle_after_reboot; 100my $powercycle_after_reboot;
95my $poweroff_after_halt; 101my $poweroff_after_halt;
102my $max_monitor_wait;
96my $ssh_exec; 103my $ssh_exec;
97my $scp_to_target; 104my $scp_to_target;
98my $scp_to_target_install; 105my $scp_to_target_install;
@@ -101,6 +108,7 @@ my $grub_menu;
101my $grub_number; 108my $grub_number;
102my $target; 109my $target;
103my $make; 110my $make;
111my $pre_install;
104my $post_install; 112my $post_install;
105my $no_install; 113my $no_install;
106my $noclean; 114my $noclean;
@@ -167,6 +175,7 @@ my $bisect_check;
167 175
168my $config_bisect; 176my $config_bisect;
169my $config_bisect_type; 177my $config_bisect_type;
178my $config_bisect_check;
170 179
171my $patchcheck_type; 180my $patchcheck_type;
172my $patchcheck_start; 181my $patchcheck_start;
@@ -182,6 +191,9 @@ my $newconfig = 0;
182my %entered_configs; 191my %entered_configs;
183my %config_help; 192my %config_help;
184my %variable; 193my %variable;
194
195# force_config is the list of configs that we force enabled (or disabled)
196# in a .config file. The MIN_CONFIG and ADD_CONFIG configs.
185my %force_config; 197my %force_config;
186 198
187# do not force reboots on config problems 199# do not force reboots on config problems
@@ -197,6 +209,10 @@ my %option_map = (
197 "OUTPUT_DIR" => \$outputdir, 209 "OUTPUT_DIR" => \$outputdir,
198 "BUILD_DIR" => \$builddir, 210 "BUILD_DIR" => \$builddir,
199 "TEST_TYPE" => \$test_type, 211 "TEST_TYPE" => \$test_type,
212 "PRE_KTEST" => \$pre_ktest,
213 "POST_KTEST" => \$post_ktest,
214 "PRE_TEST" => \$pre_test,
215 "POST_TEST" => \$post_test,
200 "BUILD_TYPE" => \$build_type, 216 "BUILD_TYPE" => \$build_type,
201 "BUILD_OPTIONS" => \$build_options, 217 "BUILD_OPTIONS" => \$build_options,
202 "PRE_BUILD" => \$pre_build, 218 "PRE_BUILD" => \$pre_build,
@@ -216,6 +232,7 @@ my %option_map = (
216 "ADD_CONFIG" => \$addconfig, 232 "ADD_CONFIG" => \$addconfig,
217 "REBOOT_TYPE" => \$reboot_type, 233 "REBOOT_TYPE" => \$reboot_type,
218 "GRUB_MENU" => \$grub_menu, 234 "GRUB_MENU" => \$grub_menu,
235 "PRE_INSTALL" => \$pre_install,
219 "POST_INSTALL" => \$post_install, 236 "POST_INSTALL" => \$post_install,
220 "NO_INSTALL" => \$no_install, 237 "NO_INSTALL" => \$no_install,
221 "REBOOT_SCRIPT" => \$reboot_script, 238 "REBOOT_SCRIPT" => \$reboot_script,
@@ -228,6 +245,7 @@ my %option_map = (
228 "POWER_OFF" => \$power_off, 245 "POWER_OFF" => \$power_off,
229 "POWERCYCLE_AFTER_REBOOT" => \$powercycle_after_reboot, 246 "POWERCYCLE_AFTER_REBOOT" => \$powercycle_after_reboot,
230 "POWEROFF_AFTER_HALT" => \$poweroff_after_halt, 247 "POWEROFF_AFTER_HALT" => \$poweroff_after_halt,
248 "MAX_MONITOR_WAIT" => \$max_monitor_wait,
231 "SLEEP_TIME" => \$sleep_time, 249 "SLEEP_TIME" => \$sleep_time,
232 "BISECT_SLEEP_TIME" => \$bisect_sleep_time, 250 "BISECT_SLEEP_TIME" => \$bisect_sleep_time,
233 "PATCHCHECK_SLEEP_TIME" => \$patchcheck_sleep_time, 251 "PATCHCHECK_SLEEP_TIME" => \$patchcheck_sleep_time,
@@ -272,6 +290,7 @@ my %option_map = (
272 290
273 "CONFIG_BISECT" => \$config_bisect, 291 "CONFIG_BISECT" => \$config_bisect,
274 "CONFIG_BISECT_TYPE" => \$config_bisect_type, 292 "CONFIG_BISECT_TYPE" => \$config_bisect_type,
293 "CONFIG_BISECT_CHECK" => \$config_bisect_check,
275 294
276 "PATCHCHECK_TYPE" => \$patchcheck_type, 295 "PATCHCHECK_TYPE" => \$patchcheck_type,
277 "PATCHCHECK_START" => \$patchcheck_start, 296 "PATCHCHECK_START" => \$patchcheck_start,
@@ -604,6 +623,10 @@ sub process_compare {
604 return $lval eq $rval; 623 return $lval eq $rval;
605 } elsif ($cmp eq "!=") { 624 } elsif ($cmp eq "!=") {
606 return $lval ne $rval; 625 return $lval ne $rval;
626 } elsif ($cmp eq "=~") {
627 return $lval =~ m/$rval/;
628 } elsif ($cmp eq "!~") {
629 return $lval !~ m/$rval/;
607 } 630 }
608 631
609 my $statement = "$lval $cmp $rval"; 632 my $statement = "$lval $cmp $rval";
@@ -659,7 +682,7 @@ sub process_expression {
659 } 682 }
660 } 683 }
661 684
662 if ($val =~ /(.*)(==|\!=|>=|<=|>|<)(.*)/) { 685 if ($val =~ /(.*)(==|\!=|>=|<=|>|<|=~|\!~)(.*)/) {
663 my $ret = process_compare($1, $2, $3); 686 my $ret = process_compare($1, $2, $3);
664 if ($ret < 0) { 687 if ($ret < 0) {
665 die "$name: $.: Unable to process comparison\n"; 688 die "$name: $.: Unable to process comparison\n";
@@ -1117,7 +1140,11 @@ sub reboot {
1117 } 1140 }
1118 1141
1119 if (defined($time)) { 1142 if (defined($time)) {
1120 wait_for_monitor($time, $reboot_success_line); 1143 if (wait_for_monitor($time, $reboot_success_line)) {
1144 # reboot got stuck?
1145 doprint "Reboot did not finish. Forcing power cycle\n";
1146 run_command "$power_cycle";
1147 }
1121 end_monitor; 1148 end_monitor;
1122 } 1149 }
1123} 1150}
@@ -1212,6 +1239,11 @@ sub wait_for_monitor {
1212 my $full_line = ""; 1239 my $full_line = "";
1213 my $line; 1240 my $line;
1214 my $booted = 0; 1241 my $booted = 0;
1242 my $start_time = time;
1243 my $skip_call_trace = 0;
1244 my $bug = 0;
1245 my $bug_ignored = 0;
1246 my $now;
1215 1247
1216 doprint "** Wait for monitor to settle down **\n"; 1248 doprint "** Wait for monitor to settle down **\n";
1217 1249
@@ -1227,11 +1259,39 @@ sub wait_for_monitor {
1227 $booted = 1; 1259 $booted = 1;
1228 } 1260 }
1229 1261
1262 if ($full_line =~ /\[ backtrace testing \]/) {
1263 $skip_call_trace = 1;
1264 }
1265
1266 if ($full_line =~ /call trace:/i) {
1267 if (!$bug && !$skip_call_trace) {
1268 if ($ignore_errors) {
1269 $bug_ignored = 1;
1270 } else {
1271 $bug = 1;
1272 }
1273 }
1274 }
1275
1276 if ($full_line =~ /\[ end of backtrace testing \]/) {
1277 $skip_call_trace = 0;
1278 }
1279
1280 if ($full_line =~ /Kernel panic -/) {
1281 $bug = 1;
1282 }
1283
1230 if ($line =~ /\n/) { 1284 if ($line =~ /\n/) {
1231 $full_line = ""; 1285 $full_line = "";
1232 } 1286 }
1287 $now = time;
1288 if ($now - $start_time >= $max_monitor_wait) {
1289 doprint "Exiting monitor flush due to hitting MAX_MONITOR_WAIT\n";
1290 return 1;
1291 }
1233 } 1292 }
1234 print "** Monitor flushed **\n"; 1293 print "** Monitor flushed **\n";
1294 return $bug;
1235} 1295}
1236 1296
1237sub save_logs { 1297sub save_logs {
@@ -1273,6 +1333,10 @@ sub save_logs {
1273 1333
1274sub fail { 1334sub fail {
1275 1335
1336 if (defined($post_test)) {
1337 run_command $post_test;
1338 }
1339
1276 if ($die_on_failure) { 1340 if ($die_on_failure) {
1277 dodie @_; 1341 dodie @_;
1278 } 1342 }
@@ -1656,6 +1720,12 @@ sub install {
1656 1720
1657 return if ($no_install); 1721 return if ($no_install);
1658 1722
1723 if (defined($pre_install)) {
1724 my $cp_pre_install = eval_kernel_version $pre_install;
1725 run_command "$cp_pre_install" or
1726 dodie "Failed to run pre install";
1727 }
1728
1659 my $cp_target = eval_kernel_version $target_image; 1729 my $cp_target = eval_kernel_version $target_image;
1660 1730
1661 run_scp_install "$outputdir/$build_target", "$cp_target" or 1731 run_scp_install "$outputdir/$build_target", "$cp_target" or
@@ -1814,6 +1884,7 @@ sub make_oldconfig {
1814sub load_force_config { 1884sub load_force_config {
1815 my ($config) = @_; 1885 my ($config) = @_;
1816 1886
1887 doprint "Loading force configs from $config\n";
1817 open(IN, $config) or 1888 open(IN, $config) or
1818 dodie "failed to read $config"; 1889 dodie "failed to read $config";
1819 while (<IN>) { 1890 while (<IN>) {
@@ -1937,6 +2008,10 @@ sub halt {
1937sub success { 2008sub success {
1938 my ($i) = @_; 2009 my ($i) = @_;
1939 2010
2011 if (defined($post_test)) {
2012 run_command $post_test;
2013 }
2014
1940 $successes++; 2015 $successes++;
1941 2016
1942 my $name = ""; 2017 my $name = "";
@@ -2003,6 +2078,7 @@ sub do_run_test {
2003 my $line; 2078 my $line;
2004 my $full_line; 2079 my $full_line;
2005 my $bug = 0; 2080 my $bug = 0;
2081 my $bug_ignored = 0;
2006 2082
2007 wait_for_monitor 1; 2083 wait_for_monitor 1;
2008 2084
@@ -2027,7 +2103,11 @@ sub do_run_test {
2027 doprint $line; 2103 doprint $line;
2028 2104
2029 if ($full_line =~ /call trace:/i) { 2105 if ($full_line =~ /call trace:/i) {
2030 $bug = 1; 2106 if ($ignore_errors) {
2107 $bug_ignored = 1;
2108 } else {
2109 $bug = 1;
2110 }
2031 } 2111 }
2032 2112
2033 if ($full_line =~ /Kernel panic -/) { 2113 if ($full_line =~ /Kernel panic -/) {
@@ -2040,6 +2120,10 @@ sub do_run_test {
2040 } 2120 }
2041 } while (!$child_done && !$bug); 2121 } while (!$child_done && !$bug);
2042 2122
2123 if (!$bug && $bug_ignored) {
2124 doprint "WARNING: Call Trace detected but ignored due to IGNORE_ERRORS=1\n";
2125 }
2126
2043 if ($bug) { 2127 if ($bug) {
2044 my $failure_start = time; 2128 my $failure_start = time;
2045 my $now; 2129 my $now;
@@ -2362,9 +2446,24 @@ sub bisect {
2362 success $i; 2446 success $i;
2363} 2447}
2364 2448
2449# config_ignore holds the configs that were set (or unset) for
2450# a good config and we will ignore these configs for the rest
2451# of a config bisect. These configs stay as they were.
2365my %config_ignore; 2452my %config_ignore;
2453
2454# config_set holds what all configs were set as.
2366my %config_set; 2455my %config_set;
2367 2456
2457# config_off holds the set of configs that the bad config had disabled.
2458# We need to record them and set them in the .config when running
2459# oldnoconfig, because oldnoconfig does not turn off new symbols, but
2460# instead just keeps the defaults.
2461my %config_off;
2462
2463# config_off_tmp holds a set of configs to turn off for now
2464my @config_off_tmp;
2465
2466# config_list is the set of configs that are being tested
2368my %config_list; 2467my %config_list;
2369my %null_config; 2468my %null_config;
2370 2469
@@ -2443,12 +2542,21 @@ sub create_config {
2443 } 2542 }
2444 } 2543 }
2445 2544
2545 # turn off configs to keep off
2546 foreach my $config (keys %config_off) {
2547 print OUT "# $config is not set\n";
2548 }
2549
2550 # turn off configs that should be off for now
2551 foreach my $config (@config_off_tmp) {
2552 print OUT "# $config is not set\n";
2553 }
2554
2446 foreach my $config (keys %config_ignore) { 2555 foreach my $config (keys %config_ignore) {
2447 print OUT "$config_ignore{$config}\n"; 2556 print OUT "$config_ignore{$config}\n";
2448 } 2557 }
2449 close(OUT); 2558 close(OUT);
2450 2559
2451# exit;
2452 make_oldconfig; 2560 make_oldconfig;
2453} 2561}
2454 2562
@@ -2525,6 +2633,13 @@ sub run_config_bisect {
2525 do { 2633 do {
2526 my @tophalf = @start_list[0 .. $half]; 2634 my @tophalf = @start_list[0 .. $half];
2527 2635
2636 # keep the bottom half off
2637 if ($half < $#start_list) {
2638 @config_off_tmp = @start_list[$half + 1 .. $#start_list];
2639 } else {
2640 @config_off_tmp = ();
2641 }
2642
2528 create_config @tophalf; 2643 create_config @tophalf;
2529 read_current_config \%current_config; 2644 read_current_config \%current_config;
2530 2645
@@ -2541,7 +2656,11 @@ sub run_config_bisect {
2541 if (!$found) { 2656 if (!$found) {
2542 # try the other half 2657 # try the other half
2543 doprint "Top half produced no set configs, trying bottom half\n"; 2658 doprint "Top half produced no set configs, trying bottom half\n";
2659
2660 # keep the top half off
2661 @config_off_tmp = @tophalf;
2544 @tophalf = @start_list[$half + 1 .. $#start_list]; 2662 @tophalf = @start_list[$half + 1 .. $#start_list];
2663
2545 create_config @tophalf; 2664 create_config @tophalf;
2546 read_current_config \%current_config; 2665 read_current_config \%current_config;
2547 foreach my $config (@tophalf) { 2666 foreach my $config (@tophalf) {
@@ -2679,6 +2798,10 @@ sub config_bisect {
2679 $added_configs{$2} = $1; 2798 $added_configs{$2} = $1;
2680 $config_list{$2} = $1; 2799 $config_list{$2} = $1;
2681 } 2800 }
2801 } elsif (/^# ((CONFIG\S*).*)/) {
2802 # Keep these configs disabled
2803 $config_set{$2} = $1;
2804 $config_off{$2} = $1;
2682 } 2805 }
2683 } 2806 }
2684 close(IN); 2807 close(IN);
@@ -2701,6 +2824,8 @@ sub config_bisect {
2701 my %config_test; 2824 my %config_test;
2702 my $once = 0; 2825 my $once = 0;
2703 2826
2827 @config_off_tmp = ();
2828
2704 # Sometimes kconfig does weird things. We must make sure 2829 # Sometimes kconfig does weird things. We must make sure
2705 # that the config we autocreate has everything we need 2830 # that the config we autocreate has everything we need
2706 # to test, otherwise we may miss testing configs, or 2831 # to test, otherwise we may miss testing configs, or
@@ -2719,6 +2844,18 @@ sub config_bisect {
2719 } 2844 }
2720 } 2845 }
2721 my $ret; 2846 my $ret;
2847
2848 if (defined($config_bisect_check) && $config_bisect_check) {
2849 doprint " Checking to make sure bad config with min config fails\n";
2850 create_config keys %config_list;
2851 $ret = run_config_bisect_test $config_bisect_type;
2852 if ($ret) {
2853 doprint " FAILED! Bad config with min config boots fine\n";
2854 return -1;
2855 }
2856 doprint " Bad config with min config fails as expected\n";
2857 }
2858
2722 do { 2859 do {
2723 $ret = run_config_bisect; 2860 $ret = run_config_bisect;
2724 } while (!$ret); 2861 } while (!$ret);
@@ -3510,6 +3647,8 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3510 3647
3511 $iteration = $i; 3648 $iteration = $i;
3512 3649
3650 undef %force_config;
3651
3513 my $makecmd = set_test_option("MAKE_CMD", $i); 3652 my $makecmd = set_test_option("MAKE_CMD", $i);
3514 3653
3515 # Load all the options into their mapped variable names 3654 # Load all the options into their mapped variable names
@@ -3519,6 +3658,18 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3519 3658
3520 $start_minconfig_defined = 1; 3659 $start_minconfig_defined = 1;
3521 3660
3661 # The first test may override the PRE_KTEST option
3662 if (defined($pre_ktest) && $i == 1) {
3663 doprint "\n";
3664 run_command $pre_ktest;
3665 }
3666
3667 # Any test can override the POST_KTEST option
3668 # The last test takes precedence.
3669 if (defined($post_ktest)) {
3670 $final_post_ktest = $post_ktest;
3671 }
3672
3522 if (!defined($start_minconfig)) { 3673 if (!defined($start_minconfig)) {
3523 $start_minconfig_defined = 0; 3674 $start_minconfig_defined = 0;
3524 $start_minconfig = $minconfig; 3675 $start_minconfig = $minconfig;
@@ -3573,6 +3724,10 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3573 doprint "\n\n"; 3724 doprint "\n\n";
3574 doprint "RUNNING TEST $i of $opt{NUM_TESTS} with option $test_type $run_type$installme\n\n"; 3725 doprint "RUNNING TEST $i of $opt{NUM_TESTS} with option $test_type $run_type$installme\n\n";
3575 3726
3727 if (defined($pre_test)) {
3728 run_command $pre_test;
3729 }
3730
3576 unlink $dmesg; 3731 unlink $dmesg;
3577 unlink $buildlog; 3732 unlink $buildlog;
3578 unlink $testlog; 3733 unlink $testlog;
@@ -3638,6 +3793,10 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3638 success $i; 3793 success $i;
3639} 3794}
3640 3795
3796if (defined($final_post_ktest)) {
3797 run_command $final_post_ktest;
3798}
3799
3641if ($opt{"POWEROFF_ON_SUCCESS"}) { 3800if ($opt{"POWEROFF_ON_SUCCESS"}) {
3642 halt; 3801 halt;
3643} elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot && $reboot_success) { 3802} elsif ($opt{"REBOOT_ON_SUCCESS"} && !do_not_reboot && $reboot_success) {
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index cf362b3d1ec9..de28a0a3b8fc 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -376,6 +376,24 @@
376# DEFAULTS 376# DEFAULTS
377# DEFAULTS SKIP 377# DEFAULTS SKIP
378 378
379# If you want to execute some command before the first test runs
380# you can set this option. Note, it can be set as a default option
381# or an option in the first test case. All other test cases will
382# ignore it. If both the default and first test have this option
383# set, then the first test will take precedence.
384#
385# default (undefined)
386#PRE_KTEST = ${SSH} ~/set_up_test
387
388# If you want to execute some command after all the tests have
389# completed, you can set this option. Note, it can be set as a
390# default or any test case can override it. If multiple test cases
391# set this option, then the last test case that set it will take
392# precedence
393#
394# default (undefined)
395#POST_KTEST = ${SSH} ~/dismantle_test
396
379# The default test type (default test) 397# The default test type (default test)
380# The test types may be: 398# The test types may be:
381# build - only build the kernel, do nothing else 399# build - only build the kernel, do nothing else
@@ -408,6 +426,14 @@
408# (default "") 426# (default "")
409#BUILD_OPTIONS = -j20 427#BUILD_OPTIONS = -j20
410 428
429# If you need to do some special handling before installing
430# you can add a script with this option.
431# The environment variable KERNEL_VERSION will be set to the
432# kernel version that is used.
433#
434# default (undefined)
435#PRE_INSTALL = ssh user@target rm -rf '/lib/modules/*-test*'
436
411# If you need an initrd, you can add a script or code here to install 437# If you need an initrd, you can add a script or code here to install
412# it. The environment variable KERNEL_VERSION will be set to the 438# it. The environment variable KERNEL_VERSION will be set to the
413# kernel version that is used. Remember to add the initrd line 439# kernel version that is used. Remember to add the initrd line
@@ -426,6 +452,18 @@
426# (default 0) 452# (default 0)
427#NO_INSTALL = 1 453#NO_INSTALL = 1
428 454
455# If there is a command that you want to run before the individual test
456# case executes, then you can set this option
457#
458# default (undefined)
459#PRE_TEST = ${SSH} reboot_to_special_kernel
460
461# If there is a command you want to run after the individual test case
462# completes, then you can set this option.
463#
464# default (undefined)
465#POST_TEST = cd ${BUILD_DIR}; git reset --hard
466
429# If there is a script that you require to run before the build is done 467# If there is a script that you require to run before the build is done
430# you can specify it with PRE_BUILD. 468# you can specify it with PRE_BUILD.
431# 469#
@@ -657,6 +695,14 @@
657# (default 60) 695# (default 60)
658#BISECT_SLEEP_TIME = 60 696#BISECT_SLEEP_TIME = 60
659 697
698# The max wait time (in seconds) for waiting for the console to finish.
699# If for some reason, the console is outputting content without
700# ever finishing, this will cause ktest to get stuck. This
701# option is the max time ktest will wait for the monitor (console)
702# to settle down before continuing.
703# (default 1800)
704#MAX_MONITOR_WAIT
705
660# The time in between patch checks to sleep (in seconds) 706# The time in between patch checks to sleep (in seconds)
661# (default 60) 707# (default 60)
662#PATCHCHECK_SLEEP_TIME = 60 708#PATCHCHECK_SLEEP_TIME = 60
@@ -1039,6 +1085,12 @@
1039# can specify it with CONFIG_BISECT_GOOD. Otherwise 1085# can specify it with CONFIG_BISECT_GOOD. Otherwise
1040# the MIN_CONFIG is the base. 1086# the MIN_CONFIG is the base.
1041# 1087#
1088# CONFIG_BISECT_CHECK (optional)
1089# Set this to 1 if you want to confirm that the config ktest
1090# generates (the bad config with the min config) is still bad.
1091# It may be that the min config fixes what broke the bad config
1092# and the test will not return a result.
1093#
1042# Example: 1094# Example:
1043# TEST_START 1095# TEST_START
1044# TEST_TYPE = config_bisect 1096# TEST_TYPE = config_bisect
diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c
index 164cbcf61106..808d5a9d5dcf 100644
--- a/tools/vm/slabinfo.c
+++ b/tools/vm/slabinfo.c
@@ -437,34 +437,34 @@ static void slab_stats(struct slabinfo *s)
437 printf("Fastpath %8lu %8lu %3lu %3lu\n", 437 printf("Fastpath %8lu %8lu %3lu %3lu\n",
438 s->alloc_fastpath, s->free_fastpath, 438 s->alloc_fastpath, s->free_fastpath,
439 s->alloc_fastpath * 100 / total_alloc, 439 s->alloc_fastpath * 100 / total_alloc,
440 s->free_fastpath * 100 / total_free); 440 total_free ? s->free_fastpath * 100 / total_free : 0);
441 printf("Slowpath %8lu %8lu %3lu %3lu\n", 441 printf("Slowpath %8lu %8lu %3lu %3lu\n",
442 total_alloc - s->alloc_fastpath, s->free_slowpath, 442 total_alloc - s->alloc_fastpath, s->free_slowpath,
443 (total_alloc - s->alloc_fastpath) * 100 / total_alloc, 443 (total_alloc - s->alloc_fastpath) * 100 / total_alloc,
444 s->free_slowpath * 100 / total_free); 444 total_free ? s->free_slowpath * 100 / total_free : 0);
445 printf("Page Alloc %8lu %8lu %3lu %3lu\n", 445 printf("Page Alloc %8lu %8lu %3lu %3lu\n",
446 s->alloc_slab, s->free_slab, 446 s->alloc_slab, s->free_slab,
447 s->alloc_slab * 100 / total_alloc, 447 s->alloc_slab * 100 / total_alloc,
448 s->free_slab * 100 / total_free); 448 total_free ? s->free_slab * 100 / total_free : 0);
449 printf("Add partial %8lu %8lu %3lu %3lu\n", 449 printf("Add partial %8lu %8lu %3lu %3lu\n",
450 s->deactivate_to_head + s->deactivate_to_tail, 450 s->deactivate_to_head + s->deactivate_to_tail,
451 s->free_add_partial, 451 s->free_add_partial,
452 (s->deactivate_to_head + s->deactivate_to_tail) * 100 / total_alloc, 452 (s->deactivate_to_head + s->deactivate_to_tail) * 100 / total_alloc,
453 s->free_add_partial * 100 / total_free); 453 total_free ? s->free_add_partial * 100 / total_free : 0);
454 printf("Remove partial %8lu %8lu %3lu %3lu\n", 454 printf("Remove partial %8lu %8lu %3lu %3lu\n",
455 s->alloc_from_partial, s->free_remove_partial, 455 s->alloc_from_partial, s->free_remove_partial,
456 s->alloc_from_partial * 100 / total_alloc, 456 s->alloc_from_partial * 100 / total_alloc,
457 s->free_remove_partial * 100 / total_free); 457 total_free ? s->free_remove_partial * 100 / total_free : 0);
458 458
459 printf("Cpu partial list %8lu %8lu %3lu %3lu\n", 459 printf("Cpu partial list %8lu %8lu %3lu %3lu\n",
460 s->cpu_partial_alloc, s->cpu_partial_free, 460 s->cpu_partial_alloc, s->cpu_partial_free,
461 s->cpu_partial_alloc * 100 / total_alloc, 461 s->cpu_partial_alloc * 100 / total_alloc,
462 s->cpu_partial_free * 100 / total_free); 462 total_free ? s->cpu_partial_free * 100 / total_free : 0);
463 463
464 printf("RemoteObj/SlabFrozen %8lu %8lu %3lu %3lu\n", 464 printf("RemoteObj/SlabFrozen %8lu %8lu %3lu %3lu\n",
465 s->deactivate_remote_frees, s->free_frozen, 465 s->deactivate_remote_frees, s->free_frozen,
466 s->deactivate_remote_frees * 100 / total_alloc, 466 s->deactivate_remote_frees * 100 / total_alloc,
467 s->free_frozen * 100 / total_free); 467 total_free ? s->free_frozen * 100 / total_free : 0);
468 468
469 printf("Total %8lu %8lu\n\n", total_alloc, total_free); 469 printf("Total %8lu %8lu\n\n", total_alloc, total_free);
470 470