Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-tc
authorLinus Torvalds <torvalds@woody.linux-foundation.org>
Fri, 9 Feb 2007 17:22:36 +0000 (09:22 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Fri, 9 Feb 2007 17:22:36 +0000 (09:22 -0800)
* 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-tc:
  [EISA] EISA registration with !CONFIG_EISA
  [TC] pmagb-b-fb: Convert to the driver model
  [TC] dec_esp: Driver model for the PMAZ-A
  [TC] mips: pmag-ba-fb: Convert to the driver model
  [TC] defxx: TURBOchannel support
  [TC] TURBOchannel support for the DECstation
  [TC] MIPS: TURBOchannel resources off-by-one fix
  [TC] MIPS: TURBOchannel update to the driver model

539 files changed:
Documentation/crypto/api-intro.txt
Documentation/feature-removal-schedule.txt
Documentation/sound/alsa/ALSA-Configuration.txt
Documentation/sound/alsa/DocBook/alsa-driver-api.tmpl
Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
Documentation/sound/alsa/hda_codec.txt
Documentation/sound/alsa/soc/DAI.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/clocking.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/codec.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/dapm.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/machine.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/overview.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/platform.txt [new file with mode: 0644]
Documentation/sound/alsa/soc/pops_clicks.txt [new file with mode: 0644]
MAINTAINERS
arch/avr32/boards/atstk1000/Makefile
arch/avr32/boards/atstk1000/atstk1002.c
arch/avr32/boards/atstk1000/spi.c [deleted file]
arch/avr32/kernel/cpu.c
arch/avr32/kernel/irq.c
arch/avr32/kernel/setup.c
arch/avr32/lib/libgcc.h [deleted file]
arch/avr32/lib/longlong.h [deleted file]
arch/avr32/mach-at32ap/Makefile
arch/avr32/mach-at32ap/at32ap7000.c
arch/avr32/mach-at32ap/extint.c
arch/avr32/mach-at32ap/pio.c
arch/avr32/mm/cache.c
arch/i386/kernel/hpet.c
arch/i386/kernel/io_apic.c
arch/i386/mm/pageattr.c
arch/ia64/kernel/crash.c
arch/ia64/kernel/smp.c
arch/powerpc/platforms/cell/iommu.c
arch/powerpc/platforms/celleb/pci.c
arch/powerpc/platforms/celleb/scc_epci.c
arch/powerpc/platforms/chrp/setup.c
arch/powerpc/platforms/ps3/interrupt.c
arch/powerpc/platforms/ps3/system-bus.c
arch/powerpc/xmon/spu-dis.c
arch/s390/defconfig
crypto/Kconfig
crypto/Makefile
crypto/algapi.c
crypto/api.c
crypto/blkcipher.c
crypto/camellia.c [new file with mode: 0644]
crypto/cbc.c
crypto/cipher.c
crypto/compress.c
crypto/digest.c
crypto/ecb.c
crypto/fcrypt.c [new file with mode: 0644]
crypto/hash.c
crypto/hmac.c
crypto/internal.h
crypto/lrw.c
crypto/pcbc.c [new file with mode: 0644]
crypto/tcrypt.c
crypto/tcrypt.h
crypto/xcbc.c
drivers/acpi/bay.c
drivers/ata/ahci.c
drivers/ata/sata_svw.c
drivers/char/watchdog/machzwd.c
drivers/crypto/geode-aes.c
drivers/hwmon/ams/ams-input.c
drivers/infiniband/ulp/iser/iser_initiator.c
drivers/input/touchscreen/ucb1400_ts.c
drivers/kvm/kvm_main.c
drivers/kvm/mmu.c
drivers/kvm/svm.c
drivers/kvm/vmx.c
drivers/macintosh/rack-meter.c
drivers/media/common/ir-keymaps.c
drivers/media/video/usbvision/usbvision-video.c
drivers/misc/Kconfig
drivers/misc/lkdtm.c
drivers/mmc/Kconfig
drivers/net/3c503.c
drivers/net/Kconfig
drivers/net/Makefile
drivers/net/ac3200.c
drivers/net/atl1/Makefile [new file with mode: 0644]
drivers/net/atl1/atl1.h [new file with mode: 0644]
drivers/net/atl1/atl1_ethtool.c [new file with mode: 0644]
drivers/net/atl1/atl1_hw.c [new file with mode: 0644]
drivers/net/atl1/atl1_hw.h [new file with mode: 0644]
drivers/net/atl1/atl1_main.c [new file with mode: 0644]
drivers/net/atl1/atl1_param.c [new file with mode: 0644]
drivers/net/bonding/bond_alb.c
drivers/net/bonding/bond_main.c
drivers/net/cxgb3/cxgb3_main.c
drivers/net/cxgb3/cxgb3_offload.c
drivers/net/e2100.c
drivers/net/es3210.c
drivers/net/macsonic.c
drivers/net/mv643xx_eth.c
drivers/net/r8169.c
drivers/net/s2io.c
drivers/net/s2io.h
drivers/net/slip.c
drivers/net/smc-mca.c
drivers/net/smc-ultra.c
drivers/net/smc-ultra32.c
drivers/net/spider_net.c
drivers/net/tg3.c
drivers/net/ucc_geth.c
drivers/net/ucc_geth_phy.c
drivers/net/wan/pc300too.c
drivers/net/wd.c
drivers/pcmcia/m32r_pcc.c
drivers/rtc/rtc-dev.c
drivers/s390/char/monreader.c
drivers/s390/char/vmlogrdr.c
drivers/s390/net/Kconfig
drivers/s390/net/Makefile
drivers/s390/net/iucv.c [deleted file]
drivers/s390/net/iucv.h [deleted file]
drivers/s390/net/netiucv.c
drivers/s390/net/smsgiucv.c
drivers/scsi/iscsi_tcp.c
drivers/scsi/libiscsi.c
drivers/scsi/osst.c
drivers/scsi/osst.h
drivers/serial/uartlite.c
drivers/usb/host/ehci-ps3.c
drivers/usb/host/ehci.h
drivers/usb/host/ohci-ps3.c
drivers/usb/host/ohci.h
drivers/usb/net/gl620a.c
drivers/usb/serial/cp2101.c
fs/dlm/lowcomms-tcp.c
fs/ecryptfs/crypto.c
fs/ecryptfs/ecryptfs_kernel.h
include/asm-alpha/io.h
include/asm-arm/arch-ixp4xx/io.h
include/asm-arm/io.h
include/asm-avr32/arch-at32ap/at32ap7000.h
include/asm-avr32/arch-at32ap/gpio.h [new file with mode: 0644]
include/asm-avr32/arch-at32ap/irq.h [new file with mode: 0644]
include/asm-avr32/arch-at32ap/portmux.h
include/asm-avr32/checksum.h
include/asm-avr32/dma-mapping.h
include/asm-avr32/gpio.h [new file with mode: 0644]
include/asm-avr32/irq.h
include/asm-avr32/posix_types.h
include/asm-avr32/uaccess.h
include/asm-cris/io.h
include/asm-i386/io.h
include/asm-mips/io.h
include/asm-parisc/io.h
include/asm-ppc/io.h
include/asm-x86_64/io.h
include/crypto/algapi.h
include/linux/atmarp.h
include/linux/crypto.h
include/linux/gfp.h
include/linux/i2c-id.h
include/linux/if_packet.h
include/linux/net.h
include/linux/netdevice.h
include/linux/netfilter/Kbuild
include/linux/netfilter/nf_conntrack_sane.h [new file with mode: 0644]
include/linux/netfilter/nf_conntrack_tcp.h
include/linux/netfilter/xt_TCPMSS.h [new file with mode: 0644]
include/linux/netfilter_ipv4/ip_nat.h
include/linux/netfilter_ipv4/ip_tables.h
include/linux/netfilter_ipv4/ipt_TCPMSS.h
include/linux/netfilter_ipv6/ip6_tables.h
include/linux/netfilter_ipv6/ip6t_mh.h [new file with mode: 0644]
include/linux/pagemap.h
include/linux/pci_ids.h
include/linux/pfkeyv2.h
include/linux/socket.h
include/linux/sysctl.h
include/linux/tcp.h
include/linux/wanrouter.h
include/linux/xfrm.h
include/net/inet_hashtables.h
include/net/iucv/af_iucv.h [new file with mode: 0644]
include/net/iucv/iucv.h [new file with mode: 0644]
include/net/netfilter/nf_conntrack.h
include/net/netfilter/nf_nat.h
include/net/route.h
include/net/tcp.h
include/net/x25.h
include/net/xfrm.h
include/scsi/iscsi_proto.h
include/sound/ac97_codec.h
include/sound/ad1848.h
include/sound/ak4114.h
include/sound/ak4117.h
include/sound/ak4xxx-adda.h
include/sound/control.h
include/sound/core.h
include/sound/emu10k1.h
include/sound/pcm.h
include/sound/pt2258.h [new file with mode: 0644]
include/sound/sb16_csp.h
include/sound/snd_wavefront.h
include/sound/soc-dapm.h [new file with mode: 0644]
include/sound/soc.h [new file with mode: 0644]
include/sound/typedefs.h [deleted file]
include/sound/version.h
include/sound/vx_core.h
include/sound/ymfpci.h
mm/filemap.c
net/Kconfig
net/Makefile
net/atm/common.c
net/bluetooth/hidp/hidp.h
net/bluetooth/hidp/sock.c
net/bridge/br_netfilter.c
net/bridge/br_netlink.c
net/bridge/netfilter/ebt_ip.c
net/bridge/netfilter/ebt_log.c
net/core/dev.c
net/core/dst.c
net/core/fib_rules.c
net/core/neighbour.c
net/core/rtnetlink.c
net/dccp/ccids/ccid3.c
net/dccp/ipv4.c
net/dccp/ipv6.c
net/dccp/proto.c
net/decnet/dn_dev.c
net/decnet/dn_table.c
net/ipv4/af_inet.c
net/ipv4/datagram.c
net/ipv4/devinet.c
net/ipv4/fib_semantics.c
net/ipv4/igmp.c
net/ipv4/inet_diag.c
net/ipv4/inet_hashtables.c
net/ipv4/inet_timewait_sock.c
net/ipv4/ip_gre.c
net/ipv4/ipip.c
net/ipv4/netfilter/Kconfig
net/ipv4/netfilter/Makefile
net/ipv4/netfilter/ip_conntrack_proto_tcp.c
net/ipv4/netfilter/ip_nat_core.c
net/ipv4/netfilter/ip_nat_helper.c
net/ipv4/netfilter/ip_nat_proto_tcp.c
net/ipv4/netfilter/ip_nat_proto_udp.c
net/ipv4/netfilter/ip_nat_rule.c
net/ipv4/netfilter/ip_tables.c
net/ipv4/netfilter/ipt_CLUSTERIP.c
net/ipv4/netfilter/ipt_ECN.c
net/ipv4/netfilter/ipt_LOG.c
net/ipv4/netfilter/ipt_MASQUERADE.c
net/ipv4/netfilter/ipt_NETMAP.c
net/ipv4/netfilter/ipt_REDIRECT.c
net/ipv4/netfilter/ipt_REJECT.c
net/ipv4/netfilter/ipt_SAME.c
net/ipv4/netfilter/ipt_TCPMSS.c [deleted file]
net/ipv4/netfilter/ipt_TOS.c
net/ipv4/netfilter/ipt_TTL.c
net/ipv4/netfilter/ipt_ULOG.c
net/ipv4/netfilter/ipt_addrtype.c
net/ipv4/netfilter/ipt_ah.c
net/ipv4/netfilter/ipt_ecn.c
net/ipv4/netfilter/ipt_iprange.c
net/ipv4/netfilter/ipt_owner.c
net/ipv4/netfilter/ipt_recent.c
net/ipv4/netfilter/ipt_tos.c
net/ipv4/netfilter/ipt_ttl.c
net/ipv4/netfilter/iptable_filter.c
net/ipv4/netfilter/iptable_mangle.c
net/ipv4/netfilter/iptable_raw.c
net/ipv4/netfilter/nf_nat_core.c
net/ipv4/netfilter/nf_nat_helper.c
net/ipv4/netfilter/nf_nat_proto_tcp.c
net/ipv4/netfilter/nf_nat_proto_udp.c
net/ipv4/netfilter/nf_nat_rule.c
net/ipv4/netfilter/nf_nat_standalone.c
net/ipv4/raw.c
net/ipv4/route.c
net/ipv4/tcp.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_output.c
net/ipv4/udp.c
net/ipv4/xfrm4_mode_tunnel.c
net/ipv4/xfrm4_policy.c
net/ipv4/xfrm4_state.c
net/ipv6/addrconf.c
net/ipv6/datagram.c
net/ipv6/inet6_hashtables.c
net/ipv6/ip6_tunnel.c
net/ipv6/mcast.c
net/ipv6/mip6.c
net/ipv6/netfilter/Kconfig
net/ipv6/netfilter/Makefile
net/ipv6/netfilter/ip6_tables.c
net/ipv6/netfilter/ip6t_HL.c
net/ipv6/netfilter/ip6t_LOG.c
net/ipv6/netfilter/ip6t_REJECT.c
net/ipv6/netfilter/ip6t_ah.c
net/ipv6/netfilter/ip6t_eui64.c
net/ipv6/netfilter/ip6t_frag.c
net/ipv6/netfilter/ip6t_hbh.c
net/ipv6/netfilter/ip6t_hl.c
net/ipv6/netfilter/ip6t_ipv6header.c
net/ipv6/netfilter/ip6t_mh.c [new file with mode: 0644]
net/ipv6/netfilter/ip6t_owner.c
net/ipv6/netfilter/ip6t_rt.c
net/ipv6/netfilter/ip6table_filter.c
net/ipv6/netfilter/ip6table_mangle.c
net/ipv6/netfilter/ip6table_raw.c
net/ipv6/raw.c
net/ipv6/route.c
net/ipv6/sit.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c
net/ipv6/xfrm6_mode_tunnel.c
net/ipv6/xfrm6_policy.c
net/ipv6/xfrm6_state.c
net/ipx/af_ipx.c
net/irda/irias_object.c
net/irda/irlan/irlan_common.c
net/iucv/Kconfig [new file with mode: 0644]
net/iucv/Makefile [new file with mode: 0644]
net/iucv/af_iucv.c [new file with mode: 0644]
net/iucv/iucv.c [new file with mode: 0644]
net/key/af_key.c
net/netfilter/Kconfig
net/netfilter/Makefile
net/netfilter/nf_conntrack_proto_tcp.c
net/netfilter/nf_conntrack_sane.c [new file with mode: 0644]
net/netfilter/xt_CLASSIFY.c
net/netfilter/xt_CONNMARK.c
net/netfilter/xt_CONNSECMARK.c
net/netfilter/xt_MARK.c
net/netfilter/xt_SECMARK.c
net/netfilter/xt_TCPMSS.c [new file with mode: 0644]
net/netfilter/xt_hashlimit.c
net/packet/af_packet.c
net/sched/act_ipt.c
net/sched/sch_generic.c
net/sched/sch_prio.c
net/sched/sch_sfq.c
net/socket.c
net/wanrouter/wanmain.c
net/x25/Makefile
net/x25/af_x25.c
net/x25/sysctl_net_x25.c
net/x25/x25_dev.c
net/x25/x25_forward.c [new file with mode: 0644]
net/x25/x25_proc.c
net/x25/x25_route.c
net/xfrm/Kconfig
net/xfrm/xfrm_algo.c
net/xfrm/xfrm_policy.c
net/xfrm/xfrm_state.c
net/xfrm/xfrm_user.c
sound/Kconfig
sound/Makefile
sound/ac97_bus.c
sound/aoa/aoa.h
sound/aoa/codecs/snd-aoa-codec-onyx.c
sound/aoa/core/snd-aoa-alsa.c
sound/aoa/core/snd-aoa-alsa.h
sound/aoa/core/snd-aoa-core.c
sound/aoa/fabrics/snd-aoa-fabric-layout.c
sound/aoa/soundbus/i2sbus/i2sbus-core.c
sound/aoa/soundbus/i2sbus/i2sbus-pcm.c
sound/aoa/soundbus/i2sbus/i2sbus.h
sound/arm/aaci.h
sound/core/control.c
sound/core/control_compat.c
sound/core/device.c
sound/core/hwdep.c
sound/core/init.c
sound/core/memalloc.c
sound/core/misc.c
sound/core/pcm.c
sound/core/pcm_lib.c
sound/core/pcm_memory.c
sound/core/rawmidi.c
sound/core/seq/seq_clientmgr.c
sound/core/seq/seq_device.c
sound/core/seq/seq_ports.c
sound/core/seq/seq_virmidi.c
sound/core/sound.c
sound/core/timer.c
sound/drivers/Kconfig
sound/drivers/Makefile
sound/drivers/dummy.c
sound/drivers/portman2x4.c [new file with mode: 0644]
sound/drivers/serial-u16550.c
sound/drivers/vx/vx_mixer.c
sound/i2c/Makefile
sound/i2c/other/Makefile
sound/i2c/other/ak4114.c
sound/i2c/other/ak4117.c
sound/i2c/other/ak4xxx-adda.c
sound/i2c/other/pt2258.c [new file with mode: 0644]
sound/isa/Kconfig
sound/isa/ad1816a/ad1816a_lib.c
sound/isa/ad1848/ad1848_lib.c
sound/isa/gus/gus_main.c
sound/isa/opl3sa2.c
sound/isa/sb/sb16_csp.c
sound/isa/wavefront/wavefront.c
sound/isa/wavefront/wavefront_fx.c
sound/isa/wavefront/yss225.c [new file with mode: 0644]
sound/pci/Kconfig
sound/pci/ac97/ac97_codec.c
sound/pci/ac97/ac97_patch.c
sound/pci/ac97/ac97_patch.h
sound/pci/ac97/ak4531_codec.c
sound/pci/als300.c
sound/pci/atiixp.c
sound/pci/atiixp_modem.c
sound/pci/ca0106/ca0106_main.c
sound/pci/ca0106/ca0106_mixer.c
sound/pci/cs4281.c
sound/pci/echoaudio/darla20.c
sound/pci/echoaudio/darla24.c
sound/pci/echoaudio/echo3g.c
sound/pci/echoaudio/echo3g_dsp.c
sound/pci/echoaudio/echoaudio.c
sound/pci/echoaudio/gina20.c
sound/pci/echoaudio/gina24.c
sound/pci/echoaudio/indigo.c
sound/pci/echoaudio/indigodj.c
sound/pci/echoaudio/indigoio.c
sound/pci/echoaudio/layla20.c
sound/pci/echoaudio/layla24.c
sound/pci/echoaudio/mia.c
sound/pci/echoaudio/mona.c
sound/pci/emu10k1/emu10k1_main.c
sound/pci/emu10k1/emu10k1x.c
sound/pci/emu10k1/emufx.c
sound/pci/emu10k1/emumixer.c
sound/pci/emu10k1/emupcm.c
sound/pci/emu10k1/emuproc.c
sound/pci/emu10k1/io.c
sound/pci/emu10k1/p16v.c
sound/pci/emu10k1/p17v.h
sound/pci/emu10k1/voice.c
sound/pci/ens1370.c
sound/pci/es1938.c
sound/pci/fm801.c
sound/pci/hda/Makefile
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_intel.c
sound/pci/hda/hda_local.h
sound/pci/hda/hda_patch.h
sound/pci/hda/patch_analog.c
sound/pci/hda/patch_cmedia.c
sound/pci/hda/patch_conexant.c [new file with mode: 0644]
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_sigmatel.c
sound/pci/hda/patch_via.c [new file with mode: 0644]
sound/pci/ice1712/Makefile
sound/pci/ice1712/amp.c
sound/pci/ice1712/amp.h
sound/pci/ice1712/aureon.c
sound/pci/ice1712/aureon.h
sound/pci/ice1712/delta.c
sound/pci/ice1712/delta.h
sound/pci/ice1712/ews.c
sound/pci/ice1712/ews.h
sound/pci/ice1712/hoontech.c
sound/pci/ice1712/hoontech.h
sound/pci/ice1712/ice1712.c
sound/pci/ice1712/ice1712.h
sound/pci/ice1712/ice1724.c
sound/pci/ice1712/juli.c
sound/pci/ice1712/juli.h
sound/pci/ice1712/phase.c
sound/pci/ice1712/phase.h
sound/pci/ice1712/pontis.c
sound/pci/ice1712/pontis.h
sound/pci/ice1712/prodigy192.c
sound/pci/ice1712/prodigy192.h
sound/pci/ice1712/revo.c
sound/pci/ice1712/revo.h
sound/pci/ice1712/vt1720_mobo.c
sound/pci/ice1712/vt1720_mobo.h
sound/pci/ice1712/wtm.c [new file with mode: 0644]
sound/pci/ice1712/wtm.h [new file with mode: 0644]
sound/pci/intel8x0.c
sound/pci/intel8x0m.c
sound/pci/korg1212/korg1212.c
sound/pci/maestro3.c
sound/pci/mixart/mixart_mixer.c
sound/pci/nm256/nm256.c
sound/pci/pcxhr/pcxhr_mixer.c
sound/pci/rme9652/hdsp.c
sound/pci/rme9652/hdspm.c
sound/pci/trident/trident_main.c
sound/pci/via82xx.c
sound/pci/via82xx_modem.c
sound/pci/vx222/vx222.c
sound/pci/vx222/vx222_ops.c
sound/pci/ymfpci/ymfpci_image.h
sound/pci/ymfpci/ymfpci_main.c
sound/pcmcia/vx/vxp_mixer.c
sound/pcmcia/vx/vxpocket.c
sound/soc/Kconfig [new file with mode: 0644]
sound/soc/Makefile [new file with mode: 0644]
sound/soc/at91/Kconfig [new file with mode: 0644]
sound/soc/at91/Makefile [new file with mode: 0644]
sound/soc/at91/at91-i2s.c [new file with mode: 0644]
sound/soc/at91/at91-i2s.h [new file with mode: 0644]
sound/soc/at91/at91-pcm.c [new file with mode: 0644]
sound/soc/at91/at91-pcm.h [new file with mode: 0644]
sound/soc/at91/eti_b1_wm8731.c [new file with mode: 0644]
sound/soc/codecs/Kconfig [new file with mode: 0644]
sound/soc/codecs/Makefile [new file with mode: 0644]
sound/soc/codecs/ac97.c [new file with mode: 0644]
sound/soc/codecs/ac97.h [new file with mode: 0644]
sound/soc/codecs/wm8731.c [new file with mode: 0644]
sound/soc/codecs/wm8731.h [new file with mode: 0644]
sound/soc/codecs/wm8750.c [new file with mode: 0644]
sound/soc/codecs/wm8750.h [new file with mode: 0644]
sound/soc/codecs/wm9712.c [new file with mode: 0644]
sound/soc/codecs/wm9712.h [new file with mode: 0644]
sound/soc/pxa/Kconfig [new file with mode: 0644]
sound/soc/pxa/Makefile [new file with mode: 0644]
sound/soc/pxa/corgi.c [new file with mode: 0644]
sound/soc/pxa/poodle.c [new file with mode: 0644]
sound/soc/pxa/pxa2xx-ac97.c [new file with mode: 0644]
sound/soc/pxa/pxa2xx-ac97.h [new file with mode: 0644]
sound/soc/pxa/pxa2xx-i2s.c [new file with mode: 0644]
sound/soc/pxa/pxa2xx-i2s.h [new file with mode: 0644]
sound/soc/pxa/pxa2xx-pcm.c [new file with mode: 0644]
sound/soc/pxa/pxa2xx-pcm.h [new file with mode: 0644]
sound/soc/pxa/spitz.c [new file with mode: 0644]
sound/soc/pxa/tosa.c [new file with mode: 0644]
sound/soc/soc-core.c [new file with mode: 0644]
sound/soc/soc-dapm.c [new file with mode: 0644]
sound/sparc/dbri.c
sound/usb/usbaudio.c
sound/usb/usbaudio.h
sound/usb/usbquirks.h

index 5a03a2801d676f4308566b4384b6264a9b6cebc4..e41a79aa71ce30df467342cfbccdedde71a78880 100644 (file)
@@ -193,6 +193,7 @@ Original developers of the crypto algorithms:
   Kartikey Mahendra Bhatt (CAST6)
   Jon Oberheide (ARC4)
   Jouni Malinen (Michael MIC)
+  NTT(Nippon Telegraph and Telephone Corporation) (Camellia)
 
 SHA1 algorithm contributors:
   Jean-Francois Dive
@@ -246,6 +247,9 @@ Tiger algorithm contributors:
 VIA PadLock contributors:
   Michal Ludvig
 
+Camellia algorithm contributors:
+  NTT(Nippon Telegraph and Telephone Corporation) (Camellia)
+
 Generic scatterwalk code by Adam J. Richter <adam@yggdrasil.com>
 
 Please send any credits updates or corrections to:
index 2dc5e5da8f88c69360e9f5e85b38861cd932f308..4a1d8979ed9203b58f01817306f6d62e258f2a27 100644 (file)
@@ -186,18 +186,6 @@ Who:       Greg Kroah-Hartman <gregkh@suse.de>
 
 ---------------------------
 
-What:  find_trylock_page
-When:  January 2007
-Why:   The interface no longer has any callers left in the kernel. It
-       is an odd interface (compared with other find_*_page functions), in
-       that it does not take a refcount to the page, only the page lock.
-       It should be replaced with find_get_page or find_lock_page if possible.
-       This feature removal can be reevaluated if users of the interface
-       cannot cleanly use something else.
-Who:   Nick Piggin <npiggin@suse.de>
-
----------------------------
-
 What:  Interrupt only SA_* flags
 When:  Januar 2007
 Why:   The interrupt related SA_* flags are replaced by IRQF_* to move them
index 9fef210ab50ab3914cd6e7d9c261edcb72ec489f..c30ff1bb2d1019aedfb8d96d97cd248b9e711b93 100644 (file)
@@ -242,6 +242,12 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
     ac97_clock         - AC'97 clock (default = 48000)
     ac97_quirk         - AC'97 workaround for strange hardware
                          See "AC97 Quirk Option" section below.
+    ac97_codec         - Workaround to specify which AC'97 codec 
+                         instead of probing.  If this works for you
+                         file a bug with your `lspci -vn` output.
+                         -2  -- Force probing.
+                         -1  -- Default behavior.
+                         0-2 -- Use the specified codec.
     spdif_aclink       - S/PDIF transfer over AC-link (default = 1)
 
     This module supports one card and autoprobe.
@@ -779,6 +785,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
          asus-dig      ASUS with SPDIF out
          asus-dig2     ASUS with SPDIF out (using GPIO2)
          uniwill       3-jack
+         fujitsu       Fujitsu Laptops (Pi1536)
          F1734         2-jack
          lg            LG laptop (m1 express dual)
          lg-lw         LG LW20/LW25 laptop
@@ -800,14 +807,18 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
        ALC262
          fujitsu       Fujitsu Laptop
          hp-bpc        HP xw4400/6400/8400/9400 laptops
+         hp-bpc-d7000  HP BPC D7000
          benq          Benq ED8
+         hippo         Hippo (ATI) with jack detection, Sony UX-90s
+         hippo_1       Hippo (Benq) with jack detection
          basic         fixed pin assignment w/o SPDIF
          auto          auto-config reading BIOS (default)
 
        ALC882/885
          3stack-dig    3-jack with SPDIF I/O
-         6stck-dig     6-jack digital with SPDIF I/O
+         6stack-dig    6-jack digital with SPDIF I/O
          arima         Arima W820Di1
+         macpro        MacPro support
          auto          auto-config reading BIOS (default)
 
        ALC883/888
@@ -817,6 +828,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
          3stack-6ch-dig 3-jack 6-channel with SPDIF I/O
          6stack-dig-demo  6-jack digital for Intel demo board
          acer          Acer laptops (Travelmate 3012WTMi, Aspire 5600, etc)
+         medion        Medion Laptops
+         targa-dig     Targa/MSI
+         targa-2ch-dig Targs/MSI with 2-channel
+         laptop-eapd   3-jack with SPDIF I/O and EAPD (Clevo M540JE, M550JE)
          auto          auto-config reading BIOS (default)
 
        ALC861/660
@@ -825,6 +840,16 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
          6stack-dig    6-jack with SPDIF I/O
          3stack-660    3-jack (for ALC660)
          uniwill-m31   Uniwill M31 laptop
+         toshiba       Toshiba laptop support
+         asus          Asus laptop support
+         asus-laptop   ASUS F2/F3 laptops
+         auto          auto-config reading BIOS (default)
+
+       ALC861VD/660VD
+         3stack        3-jack
+         3stack-dig    3-jack with SPDIF OUT
+         6stack-dig    6-jack with SPDIF OUT
+         3stack-660    3-jack (for ALC660VD)
          auto          auto-config reading BIOS (default)
 
        CMI9880
@@ -845,6 +870,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
          3stack        3-stack, shared surrounds
          laptop        2-channel only (FSC V2060, Samsung M50)
          laptop-eapd   2-channel with EAPD (Samsung R65, ASUS A6J)
+         ultra         2-channel with EAPD (Samsung Ultra tablet PC)
 
        AD1988
          6stack        6-jack
@@ -854,12 +880,31 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
          laptop        3-jack with hp-jack automute
          laptop-dig    ditto with SPDIF
          auto          auto-config reading BIOS (default)
+       
+       Conexant 5045
+         laptop        Laptop config 
+         test          for testing/debugging purpose, almost all controls
+                       can be adjusted.  Appearing only when compiled with
+                       $CONFIG_SND_DEBUG=y
+
+       Conexant 5047
+         laptop        Basic Laptop config 
+         laptop-hp     Laptop config for some HP models (subdevice 30A5)
+         laptop-eapd   Laptop config with EAPD support
+         test          for testing/debugging purpose, almost all controls
+                       can be adjusted.  Appearing only when compiled with
+                       $CONFIG_SND_DEBUG=y
 
        STAC9200/9205/9220/9221/9254
          ref           Reference board
          3stack        D945 3stack
          5stack        D945 5stack + SPDIF
 
+       STAC9202/9250/9251
+         ref           Reference board, base config
+         m2-2          Some Gateway MX series laptops
+         m6            Some Gateway NX series laptops
+
        STAC9227/9228/9229/927x
          ref           Reference board
          3stack        D965 3stack
@@ -974,6 +1019,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
     Module for Envy24HT (VT/ICE1724), Envy24PT (VT1720) based PCI sound cards.
                        * MidiMan M Audio Revolution 5.1
                        * MidiMan M Audio Revolution 7.1
+                       * MidiMan M Audio Audiophile 192
                        * AMP Ltd AUDIO2000
                        * TerraTec Aureon 5.1 Sky
                        * TerraTec Aureon 7.1 Space
@@ -993,7 +1039,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
 
     model       - Use the given board model, one of the following:
                  revo51, revo71, amp2000, prodigy71, prodigy71lt,
-                 prodigy192, aureon51, aureon71, universe,
+                 prodigy192, aureon51, aureon71, universe, ap192,
                  k8x800, phase22, phase28, ms300, av710
 
     This module supports multiple cards and autoprobe.
@@ -1049,6 +1095,9 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
     buggy_semaphore - Enable workaround for hardwares with buggy
                    semaphores (e.g. on some ASUS laptops)
                    (default off)
+    spdif_aclink  - Use S/PDIF over AC-link instead of direct connection
+                   from the controller chip
+                   (0 = off, 1 = on, -1 = default)
 
     This module supports one chip and autoprobe.
 
@@ -1371,6 +1420,13 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
 
     This module supports multiple cards.
 
+  Module snd-portman2x4
+  ---------------------
+
+    Module for Midiman Portman 2x4 parallel port MIDI interface
+
+    This module supports multiple cards.
+
   Module snd-powermac (on ppc only)
   ---------------------------------
 
index 1f3ae3e32d699a4943d0eba08abcaed39096451d..c4d2e3507af9187adb6a941f859fea9acff3ce61 100644 (file)
@@ -36,7 +36,7 @@
   </bookinfo>
 
   <chapter><title>Management of Cards and Devices</title>
-     <sect1><title>Card Managment</title>
+     <sect1><title>Card Management</title>
 !Esound/core/init.c
      </sect1>
      <sect1><title>Device Components</title>
@@ -59,7 +59,7 @@
      <sect1><title>PCM Format Helpers</title>
 !Esound/core/pcm_misc.c
      </sect1>
-     <sect1><title>PCM Memory Managment</title>
+     <sect1><title>PCM Memory Management</title>
 !Esound/core/pcm_memory.c
      </sect1>
   </chapter>
index ccd0a953953dcc09a52288d766bff968afff3e4b..74d3a35b59bc699ba512cccf7f9aab3105fb6cec 100644 (file)
         <informalexample>
           <programlisting>
 <![CDATA[
-  static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id,
-                                          struct pt_regs *regs)
+  static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id)
   {
           struct mychip *chip = dev_id;
           ....
        accessible via <constant>substream-&gt;runtime</constant>.
        This runtime pointer holds the various information; it holds
        the copy of hw_params and sw_params configurations, the buffer
-       pointers, mmap records, spinlocks, etc.  Almost everyhing you
+       pointers, mmap records, spinlocks, etc.  Almost everything you
        need for controlling the PCM can be found there.
        </para>
 
@@ -2340,7 +2339,7 @@ struct _snd_pcm_runtime {
 
        <para>
          When the PCM substreams can be synchronized (typically,
-       synchorinized start/stop of a playback and a capture streams),
+       synchronized start/stop of a playback and a capture streams),
        you can give <constant>SNDRV_PCM_INFO_SYNC_START</constant>,
        too.  In this case, you'll need to check the linked-list of
        PCM substreams in the trigger callback.  This will be
@@ -3062,8 +3061,7 @@ struct _snd_pcm_runtime {
            <title>Interrupt Handler Case #1</title>
             <programlisting>
 <![CDATA[
-  static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id,
-                                          struct pt_regs *regs)
+  static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id)
   {
           struct mychip *chip = dev_id;
           spin_lock(&chip->lock);
@@ -3106,8 +3104,7 @@ struct _snd_pcm_runtime {
            <title>Interrupt Handler Case #2</title>
             <programlisting>
 <![CDATA[
-  static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id,
-                                          struct pt_regs *regs)
+  static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id)
   {
           struct mychip *chip = dev_id;
           spin_lock(&chip->lock);
@@ -3247,7 +3244,7 @@ struct _snd_pcm_runtime {
         You can even define your own constraint rules.
         For example, let's suppose my_chip can manage a substream of 1 channel
         if and only if the format is S16_LE, otherwise it supports any format
-        specified in the <structname>snd_pcm_hardware</structname> stucture (or in any
+        specified in the <structname>snd_pcm_hardware</structname> structure (or in any
         other constraint_list). You can build a rule like this:
 
         <example>
@@ -3690,16 +3687,6 @@ struct _snd_pcm_runtime {
           </example>
         </para>
 
-        <para>
-          Here, the chip instance is retrieved via
-        <function>snd_kcontrol_chip()</function> macro.  This macro
-        just accesses to kcontrol-&gt;private_data. The
-        kcontrol-&gt;private_data field is 
-        given as the argument of <function>snd_ctl_new()</function>
-        (see the later subsection
-        <link linkend="control-interface-constructor"><citetitle>Constructor</citetitle></link>).
-        </para>
-
         <para>
        The <structfield>value</structfield> field is depending on
         the type of control as well as on info callback.  For example,
@@ -3780,7 +3767,7 @@ struct _snd_pcm_runtime {
         <para>
        Like <structfield>get</structfield> callback,
        when the control has more than one elements,
-       all elemehts must be evaluated in this callback, too.
+       all elements must be evaluated in this callback, too.
         </para>
       </section>
 
@@ -5541,12 +5528,12 @@ struct _snd_pcm_runtime {
   #ifdef CONFIG_PM
   static int snd_my_suspend(struct pci_dev *pci, pm_message_t state)
   {
-          .... /* do things for suspsend */
+          .... /* do things for suspend */
           return 0;
   }
   static int snd_my_resume(struct pci_dev *pci)
   {
-          .... /* do things for suspsend */
+          .... /* do things for suspend */
           return 0;
   }
   #endif
@@ -6111,7 +6098,7 @@ struct _snd_pcm_runtime {
 <!-- ****************************************************** -->
 <!-- Acknowledgments  -->
 <!-- ****************************************************** -->
-  <chapter id="acknowledments">
+  <chapter id="acknowledgments">
     <title>Acknowledgments</title>
     <para>
       I would like to thank Phil Kerr for his help for improvement and
index 0be57ed813022ae587bf55fb84afa7b735173d19..4eaae2a45534184b678108dd515d31a2636b9aab 100644 (file)
@@ -277,11 +277,11 @@ Helper Functions
 snd_hda_get_codec_name() stores the codec name on the given string.
 
 snd_hda_check_board_config() can be used to obtain the configuration
-information matching with the device.  Define the table with struct
-hda_board_config entries (zero-terminated), and pass it to the
-function.  The function checks the modelname given as a module
-parameter, and PCI subsystem IDs.  If the matching entry is found, it
-returns the config field value.
+information matching with the device.  Define the model string table
+and the table with struct snd_pci_quirk entries (zero-terminated),
+and pass it to the function.  The function checks the modelname given
+as a module parameter, and PCI subsystem IDs.  If the matching entry
+is found, it returns the config field value.
 
 snd_hda_add_new_ctls() can be used to create and add control entries.
 Pass the zero-terminated array of struct snd_kcontrol_new.  The same array
diff --git a/Documentation/sound/alsa/soc/DAI.txt b/Documentation/sound/alsa/soc/DAI.txt
new file mode 100644 (file)
index 0000000..58cbfd0
--- /dev/null
@@ -0,0 +1,56 @@
+ASoC currently supports the three main Digital Audio Interfaces (DAI) found on
+SoC controllers and portable audio CODECS today, namely AC97, I2S and PCM.
+
+
+AC97
+====
+
+  AC97 is a five wire interface commonly found on many PC sound cards. It is
+now also popular in many portable devices. This DAI has a reset line and time
+multiplexes its data on its SDATA_OUT (playback) and SDATA_IN (capture) lines.
+The bit clock (BCLK) is always driven by the CODEC (usually 12.288MHz) and the
+frame (FRAME) (usually 48kHz) is always driven by the controller. Each AC97
+frame is 21uS long and is divided into 13 time slots.
+
+The AC97 specification can be found at :-
+http://www.intel.com/design/chipsets/audio/ac97_r23.pdf
+
+
+I2S
+===
+
+ I2S is a common 4 wire DAI used in HiFi, STB and portable devices. The Tx and
+Rx lines are used for audio transmision, whilst the bit clock (BCLK) and
+left/right clock (LRC) synchronise the link. I2S is flexible in that either the
+controller or CODEC can drive (master) the BCLK and LRC clock lines. Bit clock
+usually varies depending on the sample rate and the master system clock
+(SYSCLK). LRCLK is the same as the sample rate. A few devices support separate
+ADC and DAC LRCLK's, this allows for similtanious capture and playback at
+different sample rates.
+
+I2S has several different operating modes:-
+
+ o I2S - MSB is transmitted on the falling edge of the first BCLK after LRC
+         transition.
+
+ o Left Justified - MSB is transmitted on transition of LRC.
+
+ o Right Justified - MSB is transmitted sample size BCLK's before LRC
+                     transition.
+
+PCM
+===
+
+PCM is another 4 wire interface, very similar to I2S, that can support a more
+flexible protocol. It has bit clock (BCLK) and sync (SYNC) lines that are used
+to synchronise the link whilst the Tx and Rx lines are used to transmit and
+receive the audio data. Bit clock usually varies depending on sample rate
+whilst sync runs at the sample rate. PCM also supports Time Division
+Multiplexing (TDM) in that several devices can use the bus similtaniuosly (This
+is sometimes referred to as network mode).
+
+Common PCM operating modes:-
+
+ o Mode A - MSB is transmitted on falling edge of first BCLK after FRAME/SYNC.
+
+ o Mode B - MSB is transmitted on rising edge of FRAME/SYNC.
diff --git a/Documentation/sound/alsa/soc/clocking.txt b/Documentation/sound/alsa/soc/clocking.txt
new file mode 100644 (file)
index 0000000..e93960d
--- /dev/null
@@ -0,0 +1,51 @@
+Audio Clocking
+==============
+
+This text describes the audio clocking terms in ASoC and digital audio in
+general. Note: Audio clocking can be complex !
+
+
+Master Clock
+------------
+
+Every audio subsystem is driven by a master clock (sometimes refered to as MCLK
+or SYSCLK). This audio master clock can be derived from a number of sources
+(e.g. crystal, PLL, CPU clock) and is responsible for producing the correct
+audio playback and capture sample rates.
+
+Some master clocks (e.g. PLL's and CPU based clocks) are configuarble in that
+their speed can be altered by software (depending on the system use and to save
+power). Other master clocks are fixed at at set frequency (i.e. crystals).
+
+
+DAI Clocks
+----------
+The Digital Audio Interface is usually driven by a Bit Clock (often referred to
+as BCLK). This clock is used to drive the digital audio data across the link
+between the codec and CPU.
+
+The DAI also has a frame clock to signal the start of each audio frame. This
+clock is sometimes referred to as LRC (left right clock) or FRAME. This clock
+runs at exactly the sample rate (LRC = Rate).
+
+Bit Clock can be generated as follows:-
+
+BCLK = MCLK / x
+
+ or
+
+BCLK = LRC * x
+
+ or
+
+BCLK = LRC * Channels * Word Size
+
+This relationship depends on the codec or SoC CPU in particular. In general
+it's best to configure BCLK to the lowest possible speed (depending on your
+rate, number of channels and wordsize) to save on power.
+
+It's also desireable to use the codec (if possible) to drive (or master) the
+audio clocks as it's usually gives more accurate sample rates than the CPU.
+
+
+
diff --git a/Documentation/sound/alsa/soc/codec.txt b/Documentation/sound/alsa/soc/codec.txt
new file mode 100644 (file)
index 0000000..48983c7
--- /dev/null
@@ -0,0 +1,197 @@
+ASoC Codec Driver
+=================
+
+The codec driver is generic and hardware independent code that configures the
+codec to provide audio capture and playback. It should contain no code that is
+specific to the target platform or machine. All platform and machine specific
+code should be added to the platform and machine drivers respectively.
+
+Each codec driver *must* provide the following features:-
+
+ 1) Codec DAI and PCM configuration
+ 2) Codec control IO - using I2C, 3 Wire(SPI) or both API's
+ 3) Mixers and audio controls
+ 4) Codec audio operations
+
+Optionally, codec drivers can also provide:-
+
+ 5) DAPM description.
+ 6) DAPM event handler.
+ 7) DAC Digital mute control.
+
+It's probably best to use this guide in conjuction with the existing codec
+driver code in sound/soc/codecs/
+
+ASoC Codec driver breakdown
+===========================
+
+1 - Codec DAI and PCM configuration
+-----------------------------------
+Each codec driver must have a struct snd_soc_codec_dai to define it's DAI and
+PCM's capablities and operations. This struct is exported so that it can be
+registered with the core by your machine driver.
+
+e.g.
+
+struct snd_soc_codec_dai wm8731_dai = {
+       .name = "WM8731",
+       /* playback capabilities */
+       .playback = {
+               .stream_name = "Playback",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = WM8731_RATES,
+               .formats = WM8731_FORMATS,},
+       /* capture capabilities */
+       .capture = {
+               .stream_name = "Capture",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = WM8731_RATES,
+               .formats = WM8731_FORMATS,},
+       /* pcm operations - see section 4 below */
+       .ops = {
+               .prepare = wm8731_pcm_prepare,
+               .hw_params = wm8731_hw_params,
+               .shutdown = wm8731_shutdown,
+       },
+       /* DAI operations - see DAI.txt */
+       .dai_ops = {
+               .digital_mute = wm8731_mute,
+               .set_sysclk = wm8731_set_dai_sysclk,
+               .set_fmt = wm8731_set_dai_fmt,
+       }
+};
+EXPORT_SYMBOL_GPL(wm8731_dai);
+
+
+2 - Codec control IO
+--------------------
+The codec can ususally be controlled via an I2C or SPI style interface (AC97
+combines control with data in the DAI). The codec drivers will have to provide
+functions to read and write the codec registers along with supplying a register
+cache:-
+
+       /* IO control data and register cache */
+    void *control_data; /* codec control (i2c/3wire) data */
+    void *reg_cache;
+
+Codec read/write should do any data formatting and call the hardware read write
+below to perform the IO. These functions are called by the core and alsa when
+performing DAPM or changing the mixer:-
+
+    unsigned int (*read)(struct snd_soc_codec *, unsigned int);
+    int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
+
+Codec hardware IO functions - usually points to either the I2C, SPI or AC97
+read/write:-
+
+       hw_write_t hw_write;
+       hw_read_t hw_read;
+
+
+3 - Mixers and audio controls
+-----------------------------
+All the codec mixers and audio controls can be defined using the convenience
+macros defined in soc.h.
+
+    #define SOC_SINGLE(xname, reg, shift, mask, invert)
+
+Defines a single control as follows:-
+
+  xname = Control name e.g. "Playback Volume"
+  reg = codec register
+  shift = control bit(s) offset in register
+  mask = control bit size(s) e.g. mask of 7 = 3 bits
+  invert = the control is inverted
+
+Other macros include:-
+
+    #define SOC_DOUBLE(xname, reg, shift_left, shift_right, mask, invert)
+
+A stereo control
+
+    #define SOC_DOUBLE_R(xname, reg_left, reg_right, shift, mask, invert)
+
+A stereo control spanning 2 registers
+
+    #define SOC_ENUM_SINGLE(xreg, xshift, xmask, xtexts)
+
+Defines an single enumerated control as follows:-
+
+   xreg = register
+   xshift = control bit(s) offset in register
+   xmask = control bit(s) size
+   xtexts = pointer to array of strings that describe each setting
+
+   #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts)
+
+Defines a stereo enumerated control
+
+
+4 - Codec Audio Operations
+--------------------------
+The codec driver also supports the following alsa operations:-
+
+/* SoC audio ops */
+struct snd_soc_ops {
+       int (*startup)(struct snd_pcm_substream *);
+       void (*shutdown)(struct snd_pcm_substream *);
+       int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
+       int (*hw_free)(struct snd_pcm_substream *);
+       int (*prepare)(struct snd_pcm_substream *);
+};
+
+Please refer to the alsa driver PCM documentation for details.
+http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm
+
+
+5 - DAPM description.
+---------------------
+The Dynamic Audio Power Management description describes the codec's power
+components, their relationships and registers to the ASoC core. Please read
+dapm.txt for details of building the description.
+
+Please also see the examples in other codec drivers.
+
+
+6 - DAPM event handler
+----------------------
+This function is a callback that handles codec domain PM calls and system
+domain PM calls (e.g. suspend and resume). It's used to put the codec to sleep
+when not in use.
+
+Power states:-
+
+       SNDRV_CTL_POWER_D0: /* full On */
+       /* vref/mid, clk and osc on, active */
+
+       SNDRV_CTL_POWER_D1: /* partial On */
+       SNDRV_CTL_POWER_D2: /* partial On */
+
+       SNDRV_CTL_POWER_D3hot: /* Off, with power */
+       /* everything off except vref/vmid, inactive */
+
+       SNDRV_CTL_POWER_D3cold: /* Everything Off, without power */
+
+
+7 - Codec DAC digital mute control.
+------------------------------------
+Most codecs have a digital mute before the DAC's that can be used to minimise
+any system noise.  The mute stops any digital data from entering the DAC.
+
+A callback can be created that is called by the core for each codec DAI when the
+mute is applied or freed.
+
+i.e.
+
+static int wm8974_mute(struct snd_soc_codec *codec,
+       struct snd_soc_codec_dai *dai, int mute)
+{
+       u16 mute_reg = wm8974_read_reg_cache(codec, WM8974_DAC) & 0xffbf;
+       if(mute)
+               wm8974_write(codec, WM8974_DAC, mute_reg | 0x40);
+       else
+               wm8974_write(codec, WM8974_DAC, mute_reg);
+       return 0;
+}
diff --git a/Documentation/sound/alsa/soc/dapm.txt b/Documentation/sound/alsa/soc/dapm.txt
new file mode 100644 (file)
index 0000000..c11877f
--- /dev/null
@@ -0,0 +1,297 @@
+Dynamic Audio Power Management for Portable Devices
+===================================================
+
+1. Description
+==============
+
+Dynamic Audio Power Management (DAPM) is designed to allow portable Linux devices
+to use the minimum amount of power within the audio subsystem at all times. It
+is independent of other kernel PM and as such, can easily co-exist with the
+other PM systems.
+
+DAPM is also completely transparent to all user space applications as all power
+switching is done within the ASoC core. No code changes or recompiling are
+required for user space applications. DAPM makes power switching descisions based
+upon any audio stream (capture/playback) activity and audio mixer settings
+within the device.
+
+DAPM spans the whole machine. It covers power control within the entire audio
+subsystem, this includes internal codec power blocks and machine level power
+systems.
+
+There are 4 power domains within DAPM
+
+   1. Codec domain - VREF, VMID (core codec and audio power)
+      Usually controlled at codec probe/remove and suspend/resume, although
+      can be set at stream time if power is not needed for sidetone, etc.
+
+   2. Platform/Machine domain - physically connected inputs and outputs
+      Is platform/machine and user action specific, is configured by the
+      machine driver and responds to asynchronous events e.g when HP
+      are inserted
+
+   3. Path domain - audio susbsystem signal paths
+      Automatically set when mixer and mux settings are changed by the user.
+      e.g. alsamixer, amixer.
+
+   4. Stream domain - DAC's and ADC's.
+      Enabled and disabled when stream playback/capture is started and
+      stopped respectively. e.g. aplay, arecord.
+
+All DAPM power switching descisons are made automatically by consulting an audio
+routing map of the whole machine. This map is specific to each machine and
+consists of the interconnections between every audio component (including
+internal codec components). All audio components that effect power are called
+widgets hereafter.
+
+
+2. DAPM Widgets
+===============
+
+Audio DAPM widgets fall into a number of types:-
+
+ o Mixer      - Mixes several analog signals into a single analog signal.
+ o Mux        - An analog switch that outputs only 1 of it's inputs.
+ o PGA        - A programmable gain amplifier or attenuation widget.
+ o ADC        - Analog to Digital Converter
+ o DAC        - Digital to Analog Converter
+ o Switch     - An analog switch
+ o Input      - A codec input pin
+ o Output     - A codec output pin
+ o Headphone  - Headphone (and optional Jack)
+ o Mic        - Mic (and optional Jack)
+ o Line       - Line Input/Output (and optional Jack)
+ o Speaker    - Speaker
+ o Pre        - Special PRE widget (exec before all others)
+ o Post       - Special POST widget (exec after all others)
+
+(Widgets are defined in include/sound/soc-dapm.h)
+
+Widgets are usually added in the codec driver and the machine driver. There are
+convience macros defined in soc-dapm.h that can be used to quickly build a
+list of widgets of the codecs and machines DAPM widgets.
+
+Most widgets have a name, register, shift and invert. Some widgets have extra
+parameters for stream name and kcontrols.
+
+
+2.1 Stream Domain Widgets
+-------------------------
+
+Stream Widgets relate to the stream power domain and only consist of ADC's
+(analog to digital converters) and DAC's (digital to analog converters).
+
+Stream widgets have the following format:-
+
+SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert),
+
+NOTE: the stream name must match the corresponding stream name in your codecs
+snd_soc_codec_dai.
+
+e.g. stream widgets for HiFi playback and capture
+
+SND_SOC_DAPM_DAC("HiFi DAC", "HiFi Playback", REG, 3, 1),
+SND_SOC_DAPM_ADC("HiFi ADC", "HiFi Capture", REG, 2, 1),
+
+
+2.2 Path Domain Widgets
+-----------------------
+
+Path domain widgets have a ability to control or effect the audio signal or
+audio paths within the audio subsystem. They have the following form:-
+
+SND_SOC_DAPM_PGA(name, reg, shift, invert, controls, num_controls)
+
+Any widget kcontrols can be set using the controls and num_controls members.
+
+e.g. Mixer widget (the kcontrols are declared first)
+
+/* Output Mixer */
+static const snd_kcontrol_new_t wm8731_output_mixer_controls[] = {
+SOC_DAPM_SINGLE("Line Bypass Switch", WM8731_APANA, 3, 1, 0),
+SOC_DAPM_SINGLE("Mic Sidetone Switch", WM8731_APANA, 5, 1, 0),
+SOC_DAPM_SINGLE("HiFi Playback Switch", WM8731_APANA, 4, 1, 0),
+};
+
+SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, wm8731_output_mixer_controls,
+       ARRAY_SIZE(wm8731_output_mixer_controls)),
+
+
+2.3 Platform/Machine domain Widgets
+-----------------------------------
+
+Machine widgets are different from codec widgets in that they don't have a
+codec register bit associated with them. A machine widget is assigned to each
+machine audio component (non codec) that can be independently powered. e.g.
+
+ o Speaker Amp
+ o Microphone Bias
+ o Jack connectors
+
+A machine widget can have an optional call back.
+
+e.g. Jack connector widget for an external Mic that enables Mic Bias
+when the Mic is inserted:-
+
+static int spitz_mic_bias(struct snd_soc_dapm_widget* w, int event)
+{
+       if(SND_SOC_DAPM_EVENT_ON(event))
+               set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_MIC_BIAS);
+       else
+               reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_MIC_BIAS);
+
+       return 0;
+}
+
+SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias),
+
+
+2.4 Codec Domain
+----------------
+
+The Codec power domain has no widgets and is handled by the codecs DAPM event
+handler. This handler is called when the codec powerstate is changed wrt to any
+stream event or by kernel PM events.
+
+
+2.5 Virtual Widgets
+-------------------
+
+Sometimes widgets exist in the codec or machine audio map that don't have any
+corresponding register bit for power control. In this case it's necessary to
+create a virtual widget - a widget with no control bits e.g.
+
+SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_DAPM_NOPM, 0, 0, NULL, 0),
+
+This can be used to merge to signal paths together in software.
+
+After all the widgets have been defined, they can then be added to the DAPM
+subsystem individually with a call to snd_soc_dapm_new_control().
+
+
+3. Codec Widget Interconnections
+================================
+
+Widgets are connected to each other within the codec and machine by audio
+paths (called interconnections). Each interconnection must be defined in order
+to create a map of all audio paths between widgets.
+This is easiest with a diagram of the codec (and schematic of the machine audio
+system), as it requires joining widgets together via their audio signal paths.
+
+i.e. from the WM8731 codec's output mixer (wm8731.c)
+
+The WM8731 output mixer has 3 inputs (sources)
+
+ 1. Line Bypass Input
+ 2. DAC (HiFi playback)
+ 3. Mic Sidetone Input
+
+Each input in this example has a kcontrol associated with it (defined in example
+above) and is connected to the output mixer via it's kcontrol name. We can now
+connect the destination widget (wrt audio signal) with it's source widgets.
+
+       /* output mixer */
+       {"Output Mixer", "Line Bypass Switch", "Line Input"},
+       {"Output Mixer", "HiFi Playback Switch", "DAC"},
+       {"Output Mixer", "Mic Sidetone Switch", "Mic Bias"},
+
+So we have :-
+
+       Destination Widget  <=== Path Name <=== Source Widget
+
+Or:-
+
+       Sink, Path, Source
+
+Or :-
+
+       "Output Mixer" is connected to the "DAC" via the "HiFi Playback Switch".
+
+When there is no path name connecting widgets (e.g. a direct connection) we
+pass NULL for the path name.
+
+Interconnections are created with a call to:-
+
+snd_soc_dapm_connect_input(codec, sink, path, source);
+
+Finally, snd_soc_dapm_new_widgets(codec) must be called after all widgets and
+interconnections have been registered with the core. This causes the core to
+scan the codec and machine so that the internal DAPM state matches the
+physical state of the machine.
+
+
+3.1 Machine Widget Interconnections
+-----------------------------------
+Machine widget interconnections are created in the same way as codec ones and
+directly connect the codec pins to machine level widgets.
+
+e.g. connects the speaker out codec pins to the internal speaker.
+
+       /* ext speaker connected to codec pins LOUT2, ROUT2  */
+       {"Ext Spk", NULL , "ROUT2"},
+       {"Ext Spk", NULL , "LOUT2"},
+
+This allows the DAPM to power on and off pins that are connected (and in use)
+and pins that are NC respectively.
+
+
+4 Endpoint Widgets
+===================
+An endpoint is a start or end point (widget) of an audio signal within the
+machine and includes the codec. e.g.
+
+ o Headphone Jack
+ o Internal Speaker
+ o Internal Mic
+ o Mic Jack
+ o Codec Pins
+
+When a codec pin is NC it can be marked as not used with a call to
+
+snd_soc_dapm_set_endpoint(codec, "Widget Name", 0);
+
+The last argument is 0 for inactive and 1 for active. This way the pin and its
+input widget will never be powered up and consume power.
+
+This also applies to machine widgets. e.g. if a headphone is connected to a
+jack then the jack can be marked active. If the headphone is removed, then
+the headphone jack can be marked inactive.
+
+
+5 DAPM Widget Events
+====================
+
+Some widgets can register their interest with the DAPM core in PM events.
+e.g. A Speaker with an amplifier registers a widget so the amplifier can be
+powered only when the spk is in use.
+
+/* turn speaker amplifier on/off depending on use */
+static int corgi_amp_event(struct snd_soc_dapm_widget *w, int event)
+{
+       if (SND_SOC_DAPM_EVENT_ON(event))
+               set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON);
+       else
+               reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_APM_ON);
+
+       return 0;
+}
+
+/* corgi machine dapm widgets */
+static const struct snd_soc_dapm_widget wm8731_dapm_widgets =
+       SND_SOC_DAPM_SPK("Ext Spk", corgi_amp_event);
+
+Please see soc-dapm.h for all other widgets that support events.
+
+
+5.1 Event types
+---------------
+
+The following event types are supported by event widgets.
+
+/* dapm event types */
+#define SND_SOC_DAPM_PRE_PMU   0x1     /* before widget power up */
+#define SND_SOC_DAPM_POST_PMU  0x2             /* after widget power up */
+#define SND_SOC_DAPM_PRE_PMD   0x4     /* before widget power down */
+#define SND_SOC_DAPM_POST_PMD  0x8             /* after widget power down */
+#define SND_SOC_DAPM_PRE_REG   0x10    /* before audio path setup */
+#define SND_SOC_DAPM_POST_REG  0x20    /* after audio path setup */
diff --git a/Documentation/sound/alsa/soc/machine.txt b/Documentation/sound/alsa/soc/machine.txt
new file mode 100644 (file)
index 0000000..72bd222
--- /dev/null
@@ -0,0 +1,113 @@
+ASoC Machine Driver
+===================
+
+The ASoC machine (or board) driver is the code that glues together the platform
+and codec drivers.
+
+The machine driver can contain codec and platform specific code. It registers
+the audio subsystem with the kernel as a platform device and is represented by
+the following struct:-
+
+/* SoC machine */
+struct snd_soc_machine {
+       char *name;
+
+       int (*probe)(struct platform_device *pdev);
+       int (*remove)(struct platform_device *pdev);
+
+       /* the pre and post PM functions are used to do any PM work before and
+        * after the codec and DAI's do any PM work. */
+       int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
+       int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
+       int (*resume_pre)(struct platform_device *pdev);
+       int (*resume_post)(struct platform_device *pdev);
+
+       /* machine stream operations */
+       struct snd_soc_ops *ops;
+
+       /* CPU <--> Codec DAI links  */
+       struct snd_soc_dai_link *dai_link;
+       int num_links;
+};
+
+probe()/remove()
+----------------
+probe/remove are optional. Do any machine specific probe here.
+
+
+suspend()/resume()
+------------------
+The machine driver has pre and post versions of suspend and resume to take care
+of any machine audio tasks that have to be done before or after the codec, DAI's
+and DMA is suspended and resumed. Optional.
+
+
+Machine operations
+------------------
+The machine specific audio operations can be set here. Again this is optional.
+
+
+Machine DAI Configuration
+-------------------------
+The machine DAI configuration glues all the codec and CPU DAI's together. It can
+also be used to set up the DAI system clock and for any machine related DAI
+initialisation e.g. the machine audio map can be connected to the codec audio
+map, unconnnected codec pins can be set as such. Please see corgi.c, spitz.c
+for examples.
+
+struct snd_soc_dai_link is used to set up each DAI in your machine. e.g.
+
+/* corgi digital audio interface glue - connects codec <--> CPU */
+static struct snd_soc_dai_link corgi_dai = {
+       .name = "WM8731",
+       .stream_name = "WM8731",
+       .cpu_dai = &pxa_i2s_dai,
+       .codec_dai = &wm8731_dai,
+       .init = corgi_wm8731_init,
+       .ops = &corgi_ops,
+};
+
+struct snd_soc_machine then sets up the machine with it's DAI's. e.g.
+
+/* corgi audio machine driver */
+static struct snd_soc_machine snd_soc_machine_corgi = {
+       .name = "Corgi",
+       .dai_link = &corgi_dai,
+       .num_links = 1,
+};
+
+
+Machine Audio Subsystem
+-----------------------
+
+The machine soc device glues the platform, machine and codec driver together.
+Private data can also be set here. e.g.
+
+/* corgi audio private data */
+static struct wm8731_setup_data corgi_wm8731_setup = {
+       .i2c_address = 0x1b,
+};
+
+/* corgi audio subsystem */
+static struct snd_soc_device corgi_snd_devdata = {
+       .machine = &snd_soc_machine_corgi,
+       .platform = &pxa2xx_soc_platform,
+       .codec_dev = &soc_codec_dev_wm8731,
+       .codec_data = &corgi_wm8731_setup,
+};
+
+
+Machine Power Map
+-----------------
+
+The machine driver can optionally extend the codec power map and to become an
+audio power map of the audio subsystem. This allows for automatic power up/down
+of speaker/HP amplifiers, etc. Codec pins can be connected to the machines jack
+sockets in the machine init function. See soc/pxa/spitz.c and dapm.txt for
+details.
+
+
+Machine Controls
+----------------
+
+Machine specific audio mixer controls can be added in the dai init function.
\ No newline at end of file
diff --git a/Documentation/sound/alsa/soc/overview.txt b/Documentation/sound/alsa/soc/overview.txt
new file mode 100644 (file)
index 0000000..753c5cc
--- /dev/null
@@ -0,0 +1,83 @@
+ALSA SoC Layer
+==============
+
+The overall project goal of the ALSA System on Chip (ASoC) layer is to provide
+better ALSA support for embedded system on chip procesors (e.g. pxa2xx, au1x00,
+iMX, etc) and portable audio codecs. Currently there is some support in the
+kernel for SoC audio, however it has some limitations:-
+
+  * Currently, codec drivers are often tightly coupled to the underlying SoC
+    cpu. This is not ideal and leads to code duplication i.e. Linux now has 4
+    different wm8731 drivers for 4 different SoC platforms.
+
+  * There is no standard method to signal user initiated audio events.
+    e.g. Headphone/Mic insertion, Headphone/Mic detection after an insertion
+    event. These are quite common events on portable devices and ofter require
+    machine specific code to re route audio, enable amps etc after such an event.
+
+  * Current drivers tend to power up the entire codec when playing
+    (or recording) audio. This is fine for a PC, but tends to waste a lot of
+    power on portable devices. There is also no support for saving power via
+    changing codec oversampling rates, bias currents, etc.
+
+
+ASoC Design
+===========
+
+The ASoC layer is designed to address these issues and provide the following
+features :-
+
+  * Codec independence. Allows reuse of codec drivers on other platforms
+    and machines.
+
+  * Easy I2S/PCM audio interface setup between codec and SoC. Each SoC interface
+    and codec registers it's audio interface capabilities with the core and are
+    subsequently matched and configured when the application hw params are known.
+
+  * Dynamic Audio Power Management (DAPM). DAPM automatically sets the codec to
+    it's minimum power state at all times. This includes powering up/down
+    internal power blocks depending on the internal codec audio routing and any
+    active streams.
+
+  * Pop and click reduction. Pops and clicks can be reduced by powering the
+    codec up/down in the correct sequence (including using digital mute). ASoC
+    signals the codec when to change power states.
+
+  * Machine specific controls: Allow machines to add controls to the sound card
+    e.g. volume control for speaker amp.
+
+To achieve all this, ASoC basically splits an embedded audio system into 3
+components :-
+
+  * Codec driver: The codec driver is platform independent and contains audio
+    controls, audio interface capabilities, codec dapm definition and codec IO
+    functions.
+
+  * Platform driver: The platform driver contains the audio dma engine and audio
+    interface drivers (e.g. I2S, AC97, PCM) for that platform.
+
+  * Machine driver: The machine driver handles any machine specific controls and
+    audio events. i.e. turing on an amp at start of playback.
+
+
+Documentation
+=============
+
+The documentation is spilt into the following sections:-
+
+overview.txt: This file.
+
+codec.txt: Codec driver internals.
+
+DAI.txt: Description of Digital Audio Interface standards and how to configure
+a DAI within your codec and CPU DAI drivers.
+
+dapm.txt: Dynamic Audio Power Management
+
+platform.txt: Platform audio DMA and DAI.
+
+machine.txt: Machine driver internals.
+
+pop_clicks.txt: How to minimise audio artifacts.
+
+clocking.txt: ASoC clocking for best power performance.
\ No newline at end of file
diff --git a/Documentation/sound/alsa/soc/platform.txt b/Documentation/sound/alsa/soc/platform.txt
new file mode 100644 (file)
index 0000000..e95b16d
--- /dev/null
@@ -0,0 +1,58 @@
+ASoC Platform Driver
+====================
+
+An ASoC platform driver can be divided into audio DMA and SoC DAI configuration
+and control. The platform drivers only target the SoC CPU and must have no board
+specific code.
+
+Audio DMA
+=========
+
+The platform DMA driver optionally supports the following alsa operations:-
+
+/* SoC audio ops */
+struct snd_soc_ops {
+       int (*startup)(struct snd_pcm_substream *);
+       void (*shutdown)(struct snd_pcm_substream *);
+       int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
+       int (*hw_free)(struct snd_pcm_substream *);
+       int (*prepare)(struct snd_pcm_substream *);
+       int (*trigger)(struct snd_pcm_substream *, int);
+};
+
+The platform driver exports it's DMA functionailty via struct snd_soc_platform:-
+
+struct snd_soc_platform {
+       char *name;
+
+       int (*probe)(struct platform_device *pdev);
+       int (*remove)(struct platform_device *pdev);
+       int (*suspend)(struct platform_device *pdev, struct snd_soc_cpu_dai *cpu_dai);
+       int (*resume)(struct platform_device *pdev, struct snd_soc_cpu_dai *cpu_dai);
+
+       /* pcm creation and destruction */
+       int (*pcm_new)(struct snd_card *, struct snd_soc_codec_dai *, struct snd_pcm *);
+       void (*pcm_free)(struct snd_pcm *);
+
+       /* platform stream ops */
+       struct snd_pcm_ops *pcm_ops;
+};
+
+Please refer to the alsa driver documentation for details of audio DMA.
+http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c436.htm
+
+An example DMA driver is soc/pxa/pxa2xx-pcm.c
+
+
+SoC DAI Drivers
+===============
+
+Each SoC DAI driver must provide the following features:-
+
+ 1) Digital audio interface (DAI) description
+ 2) Digital audio interface configuration
+ 3) PCM's description
+ 4) Sysclk configuration
+ 5) Suspend and resume (optional)
+
+Please see codec.txt for a description of items 1 - 4.
diff --git a/Documentation/sound/alsa/soc/pops_clicks.txt b/Documentation/sound/alsa/soc/pops_clicks.txt
new file mode 100644 (file)
index 0000000..2cf7ee5
--- /dev/null
@@ -0,0 +1,52 @@
+Audio Pops and Clicks
+=====================
+
+Pops and clicks are unwanted audio artifacts caused by the powering up and down
+of components within the audio subsystem. This is noticable on PC's when an
+audio module is either loaded or unloaded (at module load time the sound card is
+powered up and causes a popping noise on the speakers).
+
+Pops and clicks can be more frequent on portable systems with DAPM. This is
+because the components within the subsystem are being dynamically powered
+depending on the audio usage and this can subsequently cause a small pop or
+click every time a component power state is changed.
+
+
+Minimising Playback Pops and Clicks
+===================================
+
+Playback pops in portable audio subsystems cannot be completely eliminated atm,
+however future audio codec hardware will have better pop and click supression.
+Pops can be reduced within playback by powering the audio components in a
+specific order. This order is different for startup and shutdown and follows
+some basic rules:-
+
+ Startup Order :- DAC --> Mixers --> Output PGA --> Digital Unmute
+
+ Shutdown Order :- Digital Mute --> Output PGA --> Mixers --> DAC
+
+This assumes that the codec PCM output path from the DAC is via a mixer and then
+a PGA (programmable gain amplifier) before being output to the speakers.
+
+
+Minimising Capture Pops and Clicks
+==================================
+
+Capture artifacts are somewhat easier to get rid as we can delay activating the
+ADC until all the pops have occured. This follows similar power rules to
+playback in that components are powered in a sequence depending upon stream
+startup or shutdown.
+
+ Startup Order - Input PGA --> Mixers --> ADC
+
+ Shutdown Order - ADC --> Mixers --> Input PGA
+
+
+Zipper Noise
+============
+An unwanted zipper noise can occur within the audio playback or capture stream
+when a volume control is changed near its maximum gain value. The zipper noise
+is heard when the gain increase or decrease changes the mean audio signal
+amplitude too quickly. It can be minimised by enabling the zero cross setting
+for each volume control. The ZC forces the gain change to occur when the signal
+crosses the zero amplitude line.
index 3780623cc70ce9bba63834ad52b9ca17c64700d5..a6c1ebd18d0f801e685e5625ca052aa98eea7d88 100644 (file)
@@ -1114,7 +1114,7 @@ S:        Supported
 DAVICOM FAST ETHERNET (DMFE) NETWORK DRIVER
 P:     Tobias Ringstrom
 M:     tori@unhappy.mine.nu
-L:     linux-kernel@vger.kernel.org
+L:     netdev@vger.kernel.org
 S:     Maintained
 
 DOCBOOK FOR DOCUMENTATION
@@ -2361,7 +2361,7 @@ S:        Maintained
 NETWORKING [WIRELESS]
 P:     John W. Linville
 M:     linville@tuxdriver.com
-L:     netdev@vger.kernel.org
+L:     linux-wireless@vger.kernel.org
 T:     git kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git
 S:     Maintained
 
@@ -3037,6 +3037,12 @@ M:       perex@suse.cz
 L:     alsa-devel@alsa-project.org
 S:     Maintained
 
+SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT
+P:     Liam Girdwood
+M:     liam.girdwood@wolfsonmicro.com
+L:     alsa-devel@alsa-project.org
+S:     Supported
+
 SPI SUBSYSTEM
 P:     David Brownell
 M:     dbrownell@users.sourceforge.net
index df9499480530bf2640cfd2b653ae609175c6e2ea..8e0992201bb98b931d9578feeac8a05d5a9ae828 100644 (file)
@@ -1,2 +1,2 @@
-obj-y                          += setup.o spi.o flash.o
+obj-y                          += setup.o flash.o
 obj-$(CONFIG_BOARD_ATSTK1002)  += atstk1002.o
index 32b361f31c2ce443a9c8760bd80ce6eeaade8d44..d47e39f0e971925f81cba2588fa185b5829ed1a0 100644 (file)
@@ -8,17 +8,24 @@
  * published by the Free Software Foundation.
  */
 #include <linux/clk.h>
+#include <linux/device.h>
 #include <linux/etherdevice.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/string.h>
 #include <linux/types.h>
+#include <linux/spi/spi.h>
 
 #include <asm/io.h>
 #include <asm/setup.h>
+#include <asm/arch/at32ap7000.h>
 #include <asm/arch/board.h>
 #include <asm/arch/init.h>
+#include <asm/arch/portmux.h>
+
+
+#define        SW2_DEFAULT             /* MMCI and UART_A available */
 
 struct eth_addr {
        u8 addr[6];
@@ -29,6 +36,16 @@ static struct eth_addr __initdata hw_addr[2];
 static struct eth_platform_data __initdata eth_data[2];
 extern struct lcdc_platform_data atstk1000_fb0_data;
 
+static struct spi_board_info spi_board_info[] __initdata = {
+       {
+               .modalias       = "ltv350qv",
+               .controller_data = (void *)GPIO_PIN_PA(4),
+               .max_speed_hz   = 16000000,
+               .bus_num        = 0,
+               .chip_select    = 1,
+       },
+};
+
 /*
  * The next two functions should go away as the boot loader is
  * supposed to initialize the macb address registers with a valid
@@ -86,23 +103,53 @@ static void __init set_hw_addr(struct platform_device *pdev)
 
 void __init setup_board(void)
 {
-       at32_map_usart(1, 0);   /* /dev/ttyS0 */
-       at32_map_usart(2, 1);   /* /dev/ttyS1 */
-       at32_map_usart(3, 2);   /* /dev/ttyS2 */
+#ifdef SW2_DEFAULT
+       at32_map_usart(1, 0);   /* USART 1/A: /dev/ttyS0, DB9 */
+#else
+       at32_map_usart(0, 1);   /* USART 0/B: /dev/ttyS1, IRDA */
+#endif
+       /* USART 2/unused: expansion connector */
+       at32_map_usart(3, 2);   /* USART 3/C: /dev/ttyS2, DB9 */
 
        at32_setup_serial_console(0);
 }
 
 static int __init atstk1002_init(void)
 {
+       /*
+        * ATSTK1000 uses 32-bit SDRAM interface. Reserve the
+        * SDRAM-specific pins so that nobody messes with them.
+        */
+       at32_reserve_pin(GPIO_PIN_PE(0));       /* DATA[16]     */
+       at32_reserve_pin(GPIO_PIN_PE(1));       /* DATA[17]     */
+       at32_reserve_pin(GPIO_PIN_PE(2));       /* DATA[18]     */
+       at32_reserve_pin(GPIO_PIN_PE(3));       /* DATA[19]     */
+       at32_reserve_pin(GPIO_PIN_PE(4));       /* DATA[20]     */
+       at32_reserve_pin(GPIO_PIN_PE(5));       /* DATA[21]     */
+       at32_reserve_pin(GPIO_PIN_PE(6));       /* DATA[22]     */
+       at32_reserve_pin(GPIO_PIN_PE(7));       /* DATA[23]     */
+       at32_reserve_pin(GPIO_PIN_PE(8));       /* DATA[24]     */
+       at32_reserve_pin(GPIO_PIN_PE(9));       /* DATA[25]     */
+       at32_reserve_pin(GPIO_PIN_PE(10));      /* DATA[26]     */
+       at32_reserve_pin(GPIO_PIN_PE(11));      /* DATA[27]     */
+       at32_reserve_pin(GPIO_PIN_PE(12));      /* DATA[28]     */
+       at32_reserve_pin(GPIO_PIN_PE(13));      /* DATA[29]     */
+       at32_reserve_pin(GPIO_PIN_PE(14));      /* DATA[30]     */
+       at32_reserve_pin(GPIO_PIN_PE(15));      /* DATA[31]     */
+       at32_reserve_pin(GPIO_PIN_PE(26));      /* SDCS         */
+
        at32_add_system_devices();
 
+#ifdef SW2_DEFAULT
        at32_add_device_usart(0);
+#else
        at32_add_device_usart(1);
+#endif
        at32_add_device_usart(2);
 
        set_hw_addr(at32_add_device_eth(0, &eth_data[0]));
 
+       spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
        at32_add_device_spi(0);
        at32_add_device_lcdc(0, &atstk1000_fb0_data);
 
diff --git a/arch/avr32/boards/atstk1000/spi.c b/arch/avr32/boards/atstk1000/spi.c
deleted file mode 100644 (file)
index 567726c..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * ATSTK1000 SPI devices
- *
- * Copyright (C) 2005 Atmel Norway
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/device.h>
-#include <linux/spi/spi.h>
-
-static struct spi_board_info spi_board_info[] __initdata = {
-       {
-               .modalias       = "ltv350qv",
-               .max_speed_hz   = 16000000,
-               .bus_num        = 0,
-               .chip_select    = 1,
-       },
-};
-
-static int board_init_spi(void)
-{
-       spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
-       return 0;
-}
-arch_initcall(board_init_spi);
index 342452ba204927f31ff5fc2d8b829582af52f5e5..2e72fd2699dfc4aaf83d7437ddbb028be8046a46 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/sysdev.h>
 #include <linux/seq_file.h>
 #include <linux/cpu.h>
+#include <linux/module.h>
 #include <linux/percpu.h>
 #include <linux/param.h>
 #include <linux/errno.h>
index 856f3548e6648065d9d7cea8057ed1f77ba759ae..fd311248c143ce8b53ba605be192ef28a7f26784 100644 (file)
@@ -57,6 +57,7 @@ int show_interrupts(struct seq_file *p, void *v)
                seq_printf(p, "%3d: ", i);
                for_each_online_cpu(cpu)
                        seq_printf(p, "%10u ", kstat_cpu(cpu).irqs[i]);
+               seq_printf(p, " %8s", irq_desc[i].chip->name ? : "-");
                seq_printf(p, "  %s", action->name);
                for (action = action->next; action; action = action->next)
                        seq_printf(p, ", %s", action->name);
index a34211601008420f456e185b825c9ed426eb51c7..c6734aefb559992e4eef8b4eb5d25b64ce0a6d6b 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/root_dev.h>
 #include <linux/cpu.h>
+#include <linux/kernel.h>
 
 #include <asm/sections.h>
 #include <asm/processor.h>
@@ -174,8 +175,7 @@ static int __init parse_tag_mem_range(struct tag *tag,
         * Copy the data so the bootmem init code doesn't need to care
         * about it.
         */
-       if (mem_range_next_free >=
-           (sizeof(mem_range_cache) / sizeof(mem_range_cache[0])))
+       if (mem_range_next_free >= ARRAY_SIZE(mem_range_cache))
                panic("Physical memory map too complex!\n");
 
        new = &mem_range_cache[mem_range_next_free++];
diff --git a/arch/avr32/lib/libgcc.h b/arch/avr32/lib/libgcc.h
deleted file mode 100644 (file)
index 5a091b5..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Definitions for various functions 'borrowed' from gcc-3.4.3 */
-
-#define BITS_PER_UNIT  8
-
-typedef                 int QItype     __attribute__ ((mode (QI)));
-typedef unsigned int UQItype   __attribute__ ((mode (QI)));
-typedef                 int HItype     __attribute__ ((mode (HI)));
-typedef unsigned int UHItype   __attribute__ ((mode (HI)));
-typedef         int SItype     __attribute__ ((mode (SI)));
-typedef unsigned int USItype   __attribute__ ((mode (SI)));
-typedef                 int DItype     __attribute__ ((mode (DI)));
-typedef unsigned int UDItype   __attribute__ ((mode (DI)));
-typedef        float SFtype    __attribute__ ((mode (SF)));
-typedef                float DFtype    __attribute__ ((mode (DF)));
-typedef int word_type __attribute__ ((mode (__word__)));
-
-#define W_TYPE_SIZE (4 * BITS_PER_UNIT)
-#define Wtype  SItype
-#define UWtype USItype
-#define HWtype SItype
-#define UHWtype        USItype
-#define DWtype DItype
-#define UDWtype        UDItype
-#define __NW(a,b)      __ ## a ## si ## b
-#define __NDW(a,b)     __ ## a ## di ## b
-
-struct DWstruct {Wtype high, low;};
-
-typedef union
-{
-  struct DWstruct s;
-  DWtype ll;
-} DWunion;
diff --git a/arch/avr32/lib/longlong.h b/arch/avr32/lib/longlong.h
deleted file mode 100644 (file)
index cd5e369..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
-   Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000
-   Free Software Foundation, Inc.
-
-   This definition file is free software; you can redistribute it
-   and/or modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation; either
-   version 2, or (at your option) any later version.
-
-   This definition file is distributed in the hope that it will be
-   useful, but WITHOUT ANY WARRANTY; without even the implied
-   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-   See the GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
-
-/* Borrowed from gcc-3.4.3 */
-
-#define __BITS4 (W_TYPE_SIZE / 4)
-#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
-#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
-#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
-
-#define count_leading_zeros(count, x) ((count) = __builtin_clz(x))
-
-#define __udiv_qrnnd_c(q, r, n1, n0, d) \
-  do {                                                                 \
-    UWtype __d1, __d0, __q1, __q0;                                     \
-    UWtype __r1, __r0, __m;                                            \
-    __d1 = __ll_highpart (d);                                          \
-    __d0 = __ll_lowpart (d);                                           \
-                                                                       \
-    __r1 = (n1) % __d1;                                                        \
-    __q1 = (n1) / __d1;                                                        \
-    __m = (UWtype) __q1 * __d0;                                                \
-    __r1 = __r1 * __ll_B | __ll_highpart (n0);                         \
-    if (__r1 < __m)                                                    \
-      {                                                                        \
-       __q1--, __r1 += (d);                                            \
-       if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
-         if (__r1 < __m)                                               \
-           __q1--, __r1 += (d);                                        \
-      }                                                                        \
-    __r1 -= __m;                                                       \
-                                                                       \
-    __r0 = __r1 % __d1;                                                        \
-    __q0 = __r1 / __d1;                                                        \
-    __m = (UWtype) __q0 * __d0;                                                \
-    __r0 = __r0 * __ll_B | __ll_lowpart (n0);                          \
-    if (__r0 < __m)                                                    \
-      {                                                                        \
-       __q0--, __r0 += (d);                                            \
-       if (__r0 >= (d))                                                \
-         if (__r0 < __m)                                               \
-           __q0--, __r0 += (d);                                        \
-      }                                                                        \
-    __r0 -= __m;                                                       \
-                                                                       \
-    (q) = (UWtype) __q1 * __ll_B | __q0;                               \
-    (r) = __r0;                                                                \
-  } while (0)
-
-#define udiv_qrnnd __udiv_qrnnd_c
-
-#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
-  do {                                                                 \
-    UWtype __x;                                                                \
-    __x = (al) - (bl);                                                 \
-    (sh) = (ah) - (bh) - (__x > (al));                                 \
-    (sl) = __x;                                                                \
-  } while (0)
-
-#define umul_ppmm(w1, w0, u, v)                                                \
-  do {                                                                 \
-    UWtype __x0, __x1, __x2, __x3;                                     \
-    UHWtype __ul, __vl, __uh, __vh;                                    \
-                                                                       \
-    __ul = __ll_lowpart (u);                                           \
-    __uh = __ll_highpart (u);                                          \
-    __vl = __ll_lowpart (v);                                           \
-    __vh = __ll_highpart (v);                                          \
-                                                                       \
-    __x0 = (UWtype) __ul * __vl;                                       \
-    __x1 = (UWtype) __ul * __vh;                                       \
-    __x2 = (UWtype) __uh * __vl;                                       \
-    __x3 = (UWtype) __uh * __vh;                                       \
-                                                                       \
-    __x1 += __ll_highpart (__x0);/* this can't give carry */           \
-    __x1 += __x2;              /* but this indeed can */               \
-    if (__x1 < __x2)           /* did we get it? */                    \
-      __x3 += __ll_B;          /* yes, add it in the proper pos.  */   \
-                                                                       \
-    (w1) = __x3 + __ll_highpart (__x1);                                        \
-    (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0);         \
-  } while (0)
index f62eb691551010f63f6d76b2b845732b550be63a..b21bea9af8b11000ddccb6a38355f75809984d6c 100644 (file)
@@ -1,2 +1,2 @@
-obj-y                          += at32ap.o clock.o pio.o intc.o extint.o hsmc.o
+obj-y                          += at32ap.o clock.o intc.o extint.o pio.o hsmc.o
 obj-$(CONFIG_CPU_AT32AP7000)   += at32ap7000.o
index 48f4ef38c70e4a097ead99b9dc8a3ccd8195048f..c1e477ec7576850887591f9cc14c7d42128fa0b0 100644 (file)
@@ -496,9 +496,16 @@ static struct resource pio3_resource[] = {
 DEFINE_DEV(pio, 3);
 DEV_CLK(mck, pio3, pba, 13);
 
+static struct resource pio4_resource[] = {
+       PBMEM(0xffe03800),
+       IRQ(17),
+};
+DEFINE_DEV(pio, 4);
+DEV_CLK(mck, pio4, pba, 14);
+
 void __init at32_add_system_devices(void)
 {
-       system_manager.eim_first_irq = NR_INTERNAL_IRQS;
+       system_manager.eim_first_irq = EIM_IRQ_BASE;
 
        platform_device_register(&at32_sm_device);
        platform_device_register(&at32_intc0_device);
@@ -509,6 +516,7 @@ void __init at32_add_system_devices(void)
        platform_device_register(&pio1_device);
        platform_device_register(&pio2_device);
        platform_device_register(&pio3_device);
+       platform_device_register(&pio4_device);
 }
 
 /* --------------------------------------------------------------------
@@ -521,7 +529,7 @@ static struct atmel_uart_data atmel_usart0_data = {
 };
 static struct resource atmel_usart0_resource[] = {
        PBMEM(0xffe00c00),
-       IRQ(7),
+       IRQ(6),
 };
 DEFINE_DEV_DATA(atmel_usart, 0);
 DEV_CLK(usart, atmel_usart0, pba, 4);
@@ -583,7 +591,7 @@ static inline void configure_usart3_pins(void)
        select_peripheral(PB(17), PERIPH_B, 0); /* TXD  */
 }
 
-static struct platform_device *at32_usarts[4];
+static struct platform_device *__initdata at32_usarts[4];
 
 void __init at32_map_usart(unsigned int hw_id, unsigned int line)
 {
@@ -728,12 +736,19 @@ at32_add_device_eth(unsigned int id, struct eth_platform_data *data)
 /* --------------------------------------------------------------------
  *  SPI
  * -------------------------------------------------------------------- */
-static struct resource spi0_resource[] = {
+static struct resource atmel_spi0_resource[] = {
        PBMEM(0xffe00000),
        IRQ(3),
 };
-DEFINE_DEV(spi, 0);
-DEV_CLK(mck, spi0, pba, 0);
+DEFINE_DEV(atmel_spi, 0);
+DEV_CLK(spi_clk, atmel_spi0, pba, 0);
+
+static struct resource atmel_spi1_resource[] = {
+       PBMEM(0xffe00400),
+       IRQ(4),
+};
+DEFINE_DEV(atmel_spi, 1);
+DEV_CLK(spi_clk, atmel_spi1, pba, 1);
 
 struct platform_device *__init at32_add_device_spi(unsigned int id)
 {
@@ -741,13 +756,33 @@ struct platform_device *__init at32_add_device_spi(unsigned int id)
 
        switch (id) {
        case 0:
-               pdev = &spi0_device;
+               pdev = &atmel_spi0_device;
                select_peripheral(PA(0),  PERIPH_A, 0); /* MISO  */
                select_peripheral(PA(1),  PERIPH_A, 0); /* MOSI  */
                select_peripheral(PA(2),  PERIPH_A, 0); /* SCK   */
-               select_peripheral(PA(3),  PERIPH_A, 0); /* NPCS0 */
-               select_peripheral(PA(4),  PERIPH_A, 0); /* NPCS1 */
-               select_peripheral(PA(5),  PERIPH_A, 0); /* NPCS2 */
+
+               /* NPCS[2:0] */
+               at32_select_gpio(GPIO_PIN_PA(3),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               at32_select_gpio(GPIO_PIN_PA(4),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               at32_select_gpio(GPIO_PIN_PA(5),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               break;
+
+       case 1:
+               pdev = &atmel_spi1_device;
+               select_peripheral(PB(0),  PERIPH_B, 0); /* MISO  */
+               select_peripheral(PB(1),  PERIPH_B, 0); /* MOSI  */
+               select_peripheral(PB(5),  PERIPH_B, 0); /* SCK   */
+
+               /* NPCS[2:0] */
+               at32_select_gpio(GPIO_PIN_PB(2),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               at32_select_gpio(GPIO_PIN_PB(3),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+               at32_select_gpio(GPIO_PIN_PB(4),
+                                AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
                break;
 
        default:
@@ -860,6 +895,7 @@ struct clk *at32_clock_list[] = {
        &pio1_mck,
        &pio2_mck,
        &pio3_mck,
+       &pio4_mck,
        &atmel_usart0_usart,
        &atmel_usart1_usart,
        &atmel_usart2_usart,
@@ -868,7 +904,8 @@ struct clk *at32_clock_list[] = {
        &macb0_pclk,
        &macb1_hclk,
        &macb1_pclk,
-       &spi0_mck,
+       &atmel_spi0_spi_clk,
+       &atmel_spi1_spi_clk,
        &lcdc0_hclk,
        &lcdc0_pixclk,
 };
@@ -880,6 +917,7 @@ void __init at32_portmux_init(void)
        at32_init_pio(&pio1_device);
        at32_init_pio(&pio2_device);
        at32_init_pio(&pio3_device);
+       at32_init_pio(&pio4_device);
 }
 
 void __init at32_clock_init(void)
index b59272e81b9a049be31be3105d23354742d11388..4a60eccfebd240762e751a3c43bd4191cb5fe714 100644 (file)
@@ -55,20 +55,11 @@ static int eim_set_irq_type(unsigned int irq, unsigned int flow_type)
        unsigned long flags;
        int ret = 0;
 
+       flow_type &= IRQ_TYPE_SENSE_MASK;
        if (flow_type == IRQ_TYPE_NONE)
                flow_type = IRQ_TYPE_LEVEL_LOW;
 
        desc = &irq_desc[irq];
-       desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
-       desc->status |= flow_type & IRQ_TYPE_SENSE_MASK;
-
-       if (flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) {
-               desc->status |= IRQ_LEVEL;
-               set_irq_handler(irq, handle_level_irq);
-       } else {
-               set_irq_handler(irq, handle_edge_irq);
-       }
-
        spin_lock_irqsave(&sm->lock, flags);
 
        mode = sm_readl(sm, EIM_MODE);
@@ -97,9 +88,16 @@ static int eim_set_irq_type(unsigned int irq, unsigned int flow_type)
                break;
        }
 
-       sm_writel(sm, EIM_MODE, mode);
-       sm_writel(sm, EIM_EDGE, edge);
-       sm_writel(sm, EIM_LEVEL, level);
+       if (ret == 0) {
+               sm_writel(sm, EIM_MODE, mode);
+               sm_writel(sm, EIM_EDGE, edge);
+               sm_writel(sm, EIM_LEVEL, level);
+
+               if (flow_type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
+                       flow_type |= IRQ_LEVEL;
+               desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
+               desc->status |= flow_type;
+       }
 
        spin_unlock_irqrestore(&sm->lock, flags);
 
@@ -122,8 +120,6 @@ static void demux_eim_irq(unsigned int irq, struct irq_desc *desc)
        unsigned long status, pending;
        unsigned int i, ext_irq;
 
-       spin_lock(&sm->lock);
-
        status = sm_readl(sm, EIM_ISR);
        pending = status & sm_readl(sm, EIM_IMR);
 
@@ -133,10 +129,11 @@ static void demux_eim_irq(unsigned int irq, struct irq_desc *desc)
 
                ext_irq = i + sm->eim_first_irq;
                ext_desc = irq_desc + ext_irq;
-               ext_desc->handle_irq(ext_irq, ext_desc);
+               if (ext_desc->status & IRQ_LEVEL)
+                       handle_level_irq(ext_irq, ext_desc);
+               else
+                       handle_edge_irq(ext_irq, ext_desc);
        }
-
-       spin_unlock(&sm->lock);
 }
 
 static int __init eim_init(void)
@@ -168,8 +165,9 @@ static int __init eim_init(void)
        sm->eim_chip = &eim_chip;
 
        for (i = 0; i < nr_irqs; i++) {
+               /* NOTE the handler we set here is ignored by the demux */
                set_irq_chip_and_handler(sm->eim_first_irq + i, &eim_chip,
-                                        handle_edge_irq);
+                                        handle_level_irq);
                set_irq_chip_data(sm->eim_first_irq + i, sm);
        }
 
index f1280ed8ed6dcb6a7b48fd5418d3c116e3bb7794..9ba5654cde110dda279fe83498ab5a1c25d33144 100644 (file)
@@ -12,7 +12,9 @@
 #include <linux/debugfs.h>
 #include <linux/fs.h>
 #include <linux/platform_device.h>
+#include <linux/irq.h>
 
+#include <asm/gpio.h>
 #include <asm/io.h>
 
 #include <asm/arch/portmux.h>
@@ -26,7 +28,8 @@ struct pio_device {
        const struct platform_device *pdev;
        struct clk *clk;
        u32 pinmux_mask;
-       char name[32];
+       u32 gpio_mask;
+       char name[8];
 };
 
 static struct pio_device pio_dev[MAX_NR_PIO_DEVICES];
@@ -76,6 +79,9 @@ void __init at32_select_periph(unsigned int pin, unsigned int periph,
        if (!(flags & AT32_GPIOF_PULLUP))
                pio_writel(pio, PUDR, mask);
 
+       /* gpio_request NOT allowed */
+       set_bit(pin_index, &pio->gpio_mask);
+
        return;
 
 fail:
@@ -99,19 +105,52 @@ void __init at32_select_gpio(unsigned int pin, unsigned long flags)
                goto fail;
        }
 
-       pio_writel(pio, PUER, mask);
-       if (flags & AT32_GPIOF_HIGH)
-               pio_writel(pio, SODR, mask);
-       else
-               pio_writel(pio, CODR, mask);
-       if (flags & AT32_GPIOF_OUTPUT)
+       if (flags & AT32_GPIOF_OUTPUT) {
+               if (flags & AT32_GPIOF_HIGH)
+                       pio_writel(pio, SODR, mask);
+               else
+                       pio_writel(pio, CODR, mask);
+               pio_writel(pio, PUDR, mask);
                pio_writel(pio, OER, mask);
-       else
+       } else {
+               if (flags & AT32_GPIOF_PULLUP)
+                       pio_writel(pio, PUER, mask);
+               else
+                       pio_writel(pio, PUDR, mask);
+               if (flags & AT32_GPIOF_DEGLITCH)
+                       pio_writel(pio, IFER, mask);
+               else
+                       pio_writel(pio, IFDR, mask);
                pio_writel(pio, ODR, mask);
+       }
 
        pio_writel(pio, PER, mask);
-       if (!(flags & AT32_GPIOF_PULLUP))
-               pio_writel(pio, PUDR, mask);
+
+       /* gpio_request now allowed */
+       clear_bit(pin_index, &pio->gpio_mask);
+
+       return;
+
+fail:
+       dump_stack();
+}
+
+/* Reserve a pin, preventing anyone else from changing its configuration. */
+void __init at32_reserve_pin(unsigned int pin)
+{
+       struct pio_device *pio;
+       unsigned int pin_index = pin & 0x1f;
+
+       pio = gpio_to_pio(pin);
+       if (unlikely(!pio)) {
+               printk("pio: invalid pin %u\n", pin);
+               goto fail;
+       }
+
+       if (unlikely(test_and_set_bit(pin_index, &pio->pinmux_mask))) {
+               printk("%s: pin %u is busy\n", pio->name, pin_index);
+               goto fail;
+       }
 
        return;
 
@@ -119,20 +158,197 @@ fail:
        dump_stack();
 }
 
+/*--------------------------------------------------------------------------*/
+
+/* GPIO API */
+
+int gpio_request(unsigned int gpio, const char *label)
+{
+       struct pio_device *pio;
+       unsigned int pin;
+
+       pio = gpio_to_pio(gpio);
+       if (!pio)
+               return -ENODEV;
+
+       pin = gpio & 0x1f;
+       if (test_and_set_bit(pin, &pio->gpio_mask))
+               return -EBUSY;
+
+       return 0;
+}
+EXPORT_SYMBOL(gpio_request);
+
+void gpio_free(unsigned int gpio)
+{
+       struct pio_device *pio;
+       unsigned int pin;
+
+       pio = gpio_to_pio(gpio);
+       if (!pio) {
+               printk(KERN_ERR
+                      "gpio: attempted to free invalid pin %u\n", gpio);
+               return;
+       }
+
+       pin = gpio & 0x1f;
+       if (!test_and_clear_bit(pin, &pio->gpio_mask))
+               printk(KERN_ERR "gpio: freeing free or non-gpio pin %s-%u\n",
+                      pio->name, pin);
+}
+EXPORT_SYMBOL(gpio_free);
+
+int gpio_direction_input(unsigned int gpio)
+{
+       struct pio_device *pio;
+       unsigned int pin;
+
+       pio = gpio_to_pio(gpio);
+       if (!pio)
+               return -ENODEV;
+
+       pin = gpio & 0x1f;
+       pio_writel(pio, ODR, 1 << pin);
+
+       return 0;
+}
+EXPORT_SYMBOL(gpio_direction_input);
+
+int gpio_direction_output(unsigned int gpio)
+{
+       struct pio_device *pio;
+       unsigned int pin;
+
+       pio = gpio_to_pio(gpio);
+       if (!pio)
+               return -ENODEV;
+
+       pin = gpio & 0x1f;
+       pio_writel(pio, OER, 1 << pin);
+
+       return 0;
+}
+EXPORT_SYMBOL(gpio_direction_output);
+
+int gpio_get_value(unsigned int gpio)
+{
+       struct pio_device *pio = &pio_dev[gpio >> 5];
+
+       return (pio_readl(pio, PDSR) >> (gpio & 0x1f)) & 1;
+}
+EXPORT_SYMBOL(gpio_get_value);
+
+void gpio_set_value(unsigned int gpio, int value)
+{
+       struct pio_device *pio = &pio_dev[gpio >> 5];
+       u32 mask;
+
+       mask = 1 << (gpio & 0x1f);
+       if (value)
+               pio_writel(pio, SODR, mask);
+       else
+               pio_writel(pio, CODR, mask);
+}
+EXPORT_SYMBOL(gpio_set_value);
+
+/*--------------------------------------------------------------------------*/
+
+/* GPIO IRQ support */
+
+static void gpio_irq_mask(unsigned irq)
+{
+       unsigned                gpio = irq_to_gpio(irq);
+       struct pio_device       *pio = &pio_dev[gpio >> 5];
+
+       pio_writel(pio, IDR, 1 << (gpio & 0x1f));
+}
+
+static void gpio_irq_unmask(unsigned irq)
+{
+       unsigned                gpio = irq_to_gpio(irq);
+       struct pio_device       *pio = &pio_dev[gpio >> 5];
+
+       pio_writel(pio, IER, 1 << (gpio & 0x1f));
+}
+
+static int gpio_irq_type(unsigned irq, unsigned type)
+{
+       if (type != IRQ_TYPE_EDGE_BOTH && type != IRQ_TYPE_NONE)
+               return -EINVAL;
+
+       return 0;
+}
+
+static struct irq_chip gpio_irqchip = {
+       .name           = "gpio",
+       .mask           = gpio_irq_mask,
+       .unmask         = gpio_irq_unmask,
+       .set_type       = gpio_irq_type,
+};
+
+static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
+{
+       struct pio_device       *pio = get_irq_chip_data(irq);
+       unsigned                gpio_irq;
+
+       gpio_irq = (unsigned) get_irq_data(irq);
+       for (;;) {
+               u32             isr;
+               struct irq_desc *d;
+
+               /* ack pending GPIO interrupts */
+               isr = pio_readl(pio, ISR) & pio_readl(pio, IMR);
+               if (!isr)
+                       break;
+               do {
+                       int i;
+
+                       i = ffs(isr) - 1;
+                       isr &= ~(1 << i);
+
+                       i += gpio_irq;
+                       d = &irq_desc[i];
+
+                       d->handle_irq(i, d);
+               } while (isr);
+       }
+}
+
+static void __init
+gpio_irq_setup(struct pio_device *pio, int irq, int gpio_irq)
+{
+       unsigned        i;
+
+       set_irq_chip_data(irq, pio);
+       set_irq_data(irq, (void *) gpio_irq);
+
+       for (i = 0; i < 32; i++, gpio_irq++) {
+               set_irq_chip_data(gpio_irq, pio);
+               set_irq_chip_and_handler(gpio_irq, &gpio_irqchip,
+                               handle_simple_irq);
+       }
+
+       set_irq_chained_handler(irq, gpio_irq_handler);
+}
+
+/*--------------------------------------------------------------------------*/
+
 static int __init pio_probe(struct platform_device *pdev)
 {
        struct pio_device *pio = NULL;
+       int irq = platform_get_irq(pdev, 0);
+       int gpio_irq_base = GPIO_IRQ_BASE + pdev->id * 32;
 
        BUG_ON(pdev->id >= MAX_NR_PIO_DEVICES);
        pio = &pio_dev[pdev->id];
        BUG_ON(!pio->regs);
 
-       /* TODO: Interrupts */
+       gpio_irq_setup(pio, irq, gpio_irq_base);
 
        platform_set_drvdata(pdev, pio);
 
-       printk(KERN_INFO "%s: Atmel Port Multiplexer at 0x%p (irq %d)\n",
-              pio->name, pio->regs, platform_get_irq(pdev, 0));
+       printk(KERN_DEBUG "%s: base 0x%p, irq %d chains %d..%d\n",
+              pio->name, pio->regs, irq, gpio_irq_base, gpio_irq_base + 31);
 
        return 0;
 }
@@ -148,7 +364,7 @@ static int __init pio_init(void)
 {
        return platform_driver_register(&pio_driver);
 }
-subsys_initcall(pio_init);
+postcore_initcall(pio_init);
 
 void __init at32_init_pio(struct platform_device *pdev)
 {
@@ -184,6 +400,13 @@ void __init at32_init_pio(struct platform_device *pdev)
        pio->pdev = pdev;
        pio->regs = ioremap(regs->start, regs->end - regs->start + 1);
 
-       pio_writel(pio, ODR, ~0UL);
-       pio_writel(pio, PER, ~0UL);
+       /*
+        * request_gpio() is only valid for pins that have been
+        * explicitly configured as GPIO and not previously requested
+        */
+       pio->gpio_mask = ~0UL;
+
+       /* start with irqs disabled and acked */
+       pio_writel(pio, IDR, ~0UL);
+       (void) pio_readl(pio, ISR);
 }
index 450515b245a08dd0418ec65f51610048815cfcd4..fb13f72e9a0290430a45db2ff6a65dafe9c114b4 100644 (file)
 
 void invalidate_dcache_region(void *start, size_t size)
 {
-       unsigned long v, begin, end, linesz;
+       unsigned long v, begin, end, linesz, mask;
+       int flush = 0;
 
        linesz = boot_cpu_data.dcache.linesz;
+       mask = linesz - 1;
+
+       /* when first and/or last cachelines are shared, flush them
+        * instead of invalidating ... never discard valid data!
+        */
+       begin = (unsigned long)start;
+       end = begin + size - 1;
+
+       if (begin & mask) {
+               flush_dcache_line(start);
+               begin += linesz;
+               flush = 1;
+       }
+       if ((end & mask) != mask) {
+               flush_dcache_line((void *)end);
+               end -= linesz;
+               flush = 1;
+       }
 
-       //printk("invalidate dcache: %p + %u\n", start, size);
-
-       /* You asked for it, you got it */
-       begin = (unsigned long)start & ~(linesz - 1);
-       end = ((unsigned long)start + size + linesz - 1) & ~(linesz - 1);
-
-       for (v = begin; v < end; v += linesz)
+       /* remaining cachelines only need invalidation */
+       for (v = begin; v <= end; v += linesz)
                invalidate_dcache_line((void *)v);
+       if (flush)
+               flush_write_buffer();
 }
 
 void clean_dcache_region(void *start, size_t size)
index 45a8685bb60bb5e21e638cd6c0b6df95586606f2..0b29d41322a2620c50a0bdc98fa1ec314d397ac9 100644 (file)
@@ -12,7 +12,7 @@
 /* FSEC = 10^-15 NSEC = 10^-9 */
 #define FSEC_PER_NSEC  1000000
 
-static void *hpet_ptr;
+static void __iomem *hpet_ptr;
 
 static cycle_t read_hpet(void)
 {
@@ -40,8 +40,7 @@ static int __init init_hpet_clocksource(void)
                return -ENODEV;
 
        /* calculate the hpet address: */
-       hpet_base =
-               (void __iomem*)ioremap_nocache(hpet_address, HPET_MMAP_SIZE);
+       hpet_base = ioremap_nocache(hpet_address, HPET_MMAP_SIZE);
        hpet_ptr = hpet_base + HPET_COUNTER;
 
        /* calculate the frequency: */
index 5592fa6e1fa1fa8dfb1adaa7167f706f2016a6d6..ba8d302a0b728718d099f5254a8e463d45b1853d 100644 (file)
@@ -126,7 +126,7 @@ static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned i
  */
 static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value)
 {
-       volatile struct io_apic *io_apic = io_apic_base(apic);
+       volatile struct io_apic __iomem *io_apic = io_apic_base(apic);
        if (sis_apic_bug)
                writel(reg, &io_apic->index);
        writel(value, &io_apic->data);
index ad91528bdc14f0cd341a6e3be8d04f29bd9b4e52..e223b1d4981c2ee845f65d5337606862c57f0213 100644 (file)
@@ -224,7 +224,7 @@ void global_flush_tlb(void)
        list_replace_init(&df_list, &l);
        spin_unlock_irq(&cpa_lock);
        if (!cpu_has_clflush)
-               flush_map(0);
+               flush_map(NULL);
        list_for_each_entry_safe(pg, next, &l, lru) {
                if (cpu_has_clflush)
                        flush_map(page_address(pg));
index 9d92097ce96daaf5ccd2210eba88e44d53018ce6..37bb16f07fc3f2fd2b7a3ca8112f0d6a0a6af2e0 100644 (file)
@@ -52,7 +52,7 @@ extern void ia64_dump_cpu_regs(void *);
 static DEFINE_PER_CPU(struct elf_prstatus, elf_prstatus);
 
 void
-crash_save_this_cpu()
+crash_save_this_cpu(void)
 {
        void *buf;
        unsigned long cfm, sof, sol;
index f4c7f7769cf7df617bdb7cecefd5be4802bb840e..55ddd809b02d47aa72fc7b1f251c851aeffddc40 100644 (file)
@@ -221,13 +221,13 @@ send_IPI_self (int op)
 
 #ifdef CONFIG_KEXEC
 void
-kdump_smp_send_stop()
+kdump_smp_send_stop(void)
 {
        send_IPI_allbutself(IPI_KDUMP_CPU_STOP);
 }
 
 void
-kdump_smp_send_init()
+kdump_smp_send_init(void)
 {
        unsigned int cpu, self_cpu;
        self_cpu = smp_processor_id();
index b43466ba8096259222d45c51a8a6ba884c15d577..67d617b60a2344ab00a78a9b32e7fb508f1b05fc 100644 (file)
@@ -149,7 +149,8 @@ static int cbe_nr_iommus;
 static void invalidate_tce_cache(struct cbe_iommu *iommu, unsigned long *pte,
                long n_ptes)
 {
-       unsigned long *reg, val;
+       unsigned long __iomem *reg;
+       unsigned long val;
        long n;
 
        reg = iommu->xlate_regs + IOC_IOPT_CacheInvd;
@@ -592,7 +593,7 @@ static void __init cell_iommu_init_one(struct device_node *np, unsigned long off
        /* Init base fields */
        i = cbe_nr_iommus++;
        iommu = &iommus[i];
-       iommu->stab = 0;
+       iommu->stab = NULL;
        iommu->nid = nid;
        snprintf(iommu->name, sizeof(iommu->name), "iommu%d", i);
        INIT_LIST_HEAD(&iommu->windows);
index 867f83a7d0c9a82b5616f180b3f345007c8c0b3d..98de836dfed3fd4e7219e6a43130ad7bde04a1a3 100644 (file)
@@ -65,13 +65,13 @@ static inline u8 celleb_fake_config_readb(void *addr)
 
 static inline u16 celleb_fake_config_readw(void *addr)
 {
-       u16 *p = addr;
+       __le16 *p = addr;
        return le16_to_cpu(*p);
 }
 
 static inline u32 celleb_fake_config_readl(void *addr)
 {
-       u32 *p = addr;
+       __le32 *p = addr;
        return le32_to_cpu(*p);
 }
 
@@ -83,16 +83,16 @@ static inline void celleb_fake_config_writeb(u32 val, void *addr)
 
 static inline void celleb_fake_config_writew(u32 val, void *addr)
 {
-       u16 val16;
-       u16 *p = addr;
+       __le16 val16;
+       __le16 *p = addr;
        val16 = cpu_to_le16(val);
        *p = val16;
 }
 
 static inline void celleb_fake_config_writel(u32 val, void *addr)
 {
-       u32 val32;
-       u32 *p = addr;
+       __le32 val32;
+       __le32 *p = addr;
        val32 = cpu_to_le32(val);
        *p = val32;
 }
index 0edbc0c4f338e8ca916a9afc2981256ecc6a1b43..c11b39c3776a5565848a4e3c8d723cb314316579 100644 (file)
@@ -47,7 +47,7 @@
 #if 0 /* test code for epci dummy read */
 static void celleb_epci_dummy_read(struct pci_dev *dev)
 {
-       void *epci_base;
+       void __iomem *epci_base;
        struct device_node *node;
        struct pci_controller *hose;
        u32 val;
@@ -58,7 +58,7 @@ static void celleb_epci_dummy_read(struct pci_dev *dev)
        if (!hose)
                return;
 
-       epci_base = (void *)hose->cfg_addr;
+       epci_base = hose->cfg_addr;
 
        val = in_be32(epci_base + SCC_EPCI_WATRP);
        iosync();
@@ -71,18 +71,18 @@ static inline void clear_and_disable_master_abort_interrupt(
                                        struct pci_controller *hose)
 {
        void __iomem *addr;
-       addr = (void *)hose->cfg_addr + PCI_COMMAND;
+       addr = hose->cfg_addr + PCI_COMMAND;
        out_be32(addr, in_be32(addr) | (PCI_STATUS_REC_MASTER_ABORT << 16));
 }
 
 static int celleb_epci_check_abort(struct pci_controller *hose,
-                                  unsigned long addr)
+                                  void __iomem *addr)
 {
        void __iomem *reg, *epci_base;
        u32 val;
 
        iob();
-       epci_base = (void *)hose->cfg_addr;
+       epci_base = hose->cfg_addr;
 
        reg = epci_base + PCI_COMMAND;
        val = in_be32(reg);
@@ -108,23 +108,23 @@ static int celleb_epci_check_abort(struct pci_controller *hose,
        return PCIBIOS_SUCCESSFUL;
 }
 
-static unsigned long celleb_epci_make_config_addr(struct pci_controller *hose,
+static void __iomem *celleb_epci_make_config_addr(struct pci_controller *hose,
                                        unsigned int devfn, int where)
 {
-       unsigned long addr;
+       void __iomem *addr;
        struct pci_bus *bus = hose->bus;
 
        if (bus->self)
-               addr = (unsigned long)hose->cfg_data +
+               addr = hose->cfg_data +
                       (((bus->number & 0xff) << 16)
                        | ((devfn & 0xff) << 8)
                        | (where & 0xff)
                        | 0x01000000);
        else
-               addr = (unsigned long)hose->cfg_data +
+               addr = hose->cfg_data +
                       (((devfn & 0xff) << 8) | (where & 0xff));
 
-       pr_debug("EPCI: config_addr = 0x%016lx\n", addr);
+       pr_debug("EPCI: config_addr = 0x%p\n", addr);
 
        return addr;
 }
@@ -132,7 +132,7 @@ static unsigned long celleb_epci_make_config_addr(struct pci_controller *hose,
 static int celleb_epci_read_config(struct pci_bus *bus,
                        unsigned int devfn, int where, int size, u32 * val)
 {
-       unsigned long addr;
+       void __iomem *addr;
        struct device_node *node;
        struct pci_controller *hose;
 
@@ -148,17 +148,17 @@ static int celleb_epci_read_config(struct pci_bus *bus,
        if (bus->number == hose->first_busno && devfn == 0) {
                /* EPCI controller self */
 
-               addr = (unsigned long)hose->cfg_addr + where;
+               addr = hose->cfg_addr + where;
 
                switch (size) {
                case 1:
-                       *val = in_8((u8 *)addr);
+                       *val = in_8(addr);
                        break;
                case 2:
-                       *val = in_be16((u16 *)addr);
+                       *val = in_be16(addr);
                        break;
                case 4:
-                       *val = in_be32((u32 *)addr);
+                       *val = in_be32(addr);
                        break;
                default:
                        return PCIBIOS_DEVICE_NOT_FOUND;
@@ -171,13 +171,13 @@ static int celleb_epci_read_config(struct pci_bus *bus,
 
                switch (size) {
                case 1:
-                       *val = in_8((u8 *)addr);
+                       *val = in_8(addr);
                        break;
                case 2:
-                       *val = in_le16((u16 *)addr);
+                       *val = in_le16(addr);
                        break;
                case 4:
-                       *val = in_le32((u32 *)addr);
+                       *val = in_le32(addr);
                        break;
                default:
                        return PCIBIOS_DEVICE_NOT_FOUND;
@@ -188,13 +188,13 @@ static int celleb_epci_read_config(struct pci_bus *bus,
                 "addr=0x%lx, devfn=0x%x, where=0x%x, size=0x%x, val=0x%x\n",
                 addr, devfn, where, size, *val);
 
-       return celleb_epci_check_abort(hose, 0);
+       return celleb_epci_check_abort(hose, NULL);
 }
 
 static int celleb_epci_write_config(struct pci_bus *bus,
                        unsigned int devfn, int where, int size, u32 val)
 {
-       unsigned long addr;
+       void __iomem *addr;
        struct device_node *node;
        struct pci_controller *hose;
 
@@ -210,17 +210,17 @@ static int celleb_epci_write_config(struct pci_bus *bus,
        if (bus->number == hose->first_busno && devfn == 0) {
                /* EPCI controller self */
 
-               addr = (unsigned long)hose->cfg_addr + where;
+               addr = hose->cfg_addr + where;
 
                switch (size) {
                case 1:
-                       out_8((u8 *)addr, val);
+                       out_8(addr, val);
                        break;
                case 2:
-                       out_be16((u16 *)addr, val);
+                       out_be16(addr, val);
                        break;
                case 4:
-                       out_be32((u32 *)addr, val);
+                       out_be32(addr, val);
                        break;
                default:
                        return PCIBIOS_DEVICE_NOT_FOUND;
@@ -233,13 +233,13 @@ static int celleb_epci_write_config(struct pci_bus *bus,
 
                switch (size) {
                case 1:
-                       out_8((u8 *)addr, val);
+                       out_8(addr, val);
                        break;
                case 2:
-                       out_le16((u16 *)addr, val);
+                       out_le16(addr, val);
                        break;
                case 4:
-                       out_le32((u32 *)addr, val);
+                       out_le32(addr, val);
                        break;
                default:
                        return PCIBIOS_DEVICE_NOT_FOUND;
@@ -261,7 +261,7 @@ static int __devinit celleb_epci_init(struct pci_controller *hose)
        void __iomem *reg, *epci_base;
        int hwres = 0;
 
-       epci_base = (void *)hose->cfg_addr;
+       epci_base = hose->cfg_addr;
 
        /* PCI core reset(Internal bus and PCI clock) */
        reg = epci_base + SCC_EPCI_CKCTRL;
index e1f51d45598445e00d6a3fbbfe0a445cd2fd01c7..117c9a0055bd734939b3ac5269c96edeef08f9c7 100644 (file)
@@ -75,7 +75,7 @@ extern irqreturn_t xmon_irq(int, void *);
 extern unsigned long loops_per_jiffy;
 
 /* To be replaced by RTAS when available */
-static unsigned int *briq_SPOR;
+static unsigned int __iomem *briq_SPOR;
 
 #ifdef CONFIG_SMP
 extern struct smp_ops_t chrp_smp_ops;
@@ -267,7 +267,7 @@ void __init chrp_setup_arch(void)
        } else if (machine && strncmp(machine, "TotalImpact,BRIQ-1", 18) == 0) {
                _chrp_type = _CHRP_briq;
                /* Map the SPOR register on briq and change the restart hook */
-               briq_SPOR = (unsigned int *)ioremap(0xff0000e8, 4);
+               briq_SPOR = ioremap(0xff0000e8, 4);
                ppc_md.restart = briq_restart;
        } else {
                /* Let's assume it is an IBM chrp if all else fails */
index bb17283275aa7122aaa4c13d6cd7df99cba968f1..631c30095617889efa43a8af7dcde0bbfc91c998 100644 (file)
@@ -194,6 +194,7 @@ int ps3_alloc_io_irq(enum ps3_cpu_binding cpu, unsigned int interrupt_id,
 
        return result;
 }
+EXPORT_SYMBOL_GPL(ps3_alloc_io_irq);
 
 int ps3_free_io_irq(unsigned int virq)
 {
@@ -209,6 +210,7 @@ int ps3_free_io_irq(unsigned int virq)
 
        return result;
 }
+EXPORT_SYMBOL_GPL(ps3_free_io_irq);
 
 /**
  * ps3_alloc_event_irq - Allocate a virq for use with a system event.
index bce6136cbce706ac3887a1d11be0c97ba7908a57..a9f7e4a39a2ae26041e3928fbaf7c969ea3c12a8 100644 (file)
@@ -57,6 +57,7 @@ int ps3_mmio_region_create(struct ps3_mmio_region *r)
        dump_mmio_region(r);
        return result;
 }
+EXPORT_SYMBOL_GPL(ps3_mmio_region_create);
 
 int ps3_free_mmio_region(struct ps3_mmio_region *r)
 {
@@ -72,6 +73,7 @@ int ps3_free_mmio_region(struct ps3_mmio_region *r)
        r->lpar_addr = 0;
        return result;
 }
+EXPORT_SYMBOL_GPL(ps3_free_mmio_region);
 
 static int ps3_system_bus_match(struct device *_dev,
        struct device_driver *_drv)
index ee929c641bf3205a3a57b09a8e61b232bb897cfb..e5f89837c82e0edb39e77e39ccea793ca08a4736 100644 (file)
@@ -85,7 +85,7 @@ get_index_for_opcode (unsigned int insn)
   if ((index = spu_disassemble_table[opcode & 0x7ff]) != 0)
     return index;
 
-  return 0;
+  return NULL;
 }
 
 /* Print a Spu instruction.  */
index 7c621b8ef68370eb7f7dd5f023db1dd0fb87b9e6..1406400bf3ea3b18a25779227e71013ea4e4a13b 100644 (file)
@@ -179,6 +179,8 @@ CONFIG_XFRM=y
 # CONFIG_XFRM_USER is not set
 # CONFIG_XFRM_SUB_POLICY is not set
 CONFIG_NET_KEY=y
+CONFIG_IUCV=m
+CONFIG_AFIUCV=m
 CONFIG_INET=y
 CONFIG_IP_MULTICAST=y
 # CONFIG_IP_ADVANCED_ROUTER is not set
@@ -508,7 +510,6 @@ CONFIG_NET_ETHERNET=y
 #
 CONFIG_LCS=m
 CONFIG_CTC=m
-CONFIG_IUCV=m
 # CONFIG_NETIUCV is not set
 # CONFIG_SMSGIUCV is not set
 # CONFIG_CLAW is not set
index 918b4d845f935ba5dfa4be45f88134716845a7e5..086fcec44720cdd02f80b1539dac562caaea4476 100644 (file)
@@ -149,6 +149,15 @@ config CRYPTO_CBC
          CBC: Cipher Block Chaining mode
          This block cipher algorithm is required for IPSec.
 
+config CRYPTO_PCBC
+       tristate "PCBC support"
+       select CRYPTO_BLKCIPHER
+       select CRYPTO_MANAGER
+       default m
+       help
+         PCBC: Propagating Cipher Block Chaining mode
+         This block cipher algorithm is required for RxRPC.
+
 config CRYPTO_LRW
        tristate "LRW support (EXPERIMENTAL)"
        depends on EXPERIMENTAL
@@ -168,6 +177,13 @@ config CRYPTO_DES
        help
          DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3).
 
+config CRYPTO_FCRYPT
+       tristate "FCrypt cipher algorithm"
+       select CRYPTO_ALGAPI
+       select CRYPTO_BLKCIPHER
+       help
+         FCrypt algorithm used by RxRPC.
+
 config CRYPTO_BLOWFISH
        tristate "Blowfish cipher algorithm"
        select CRYPTO_ALGAPI
@@ -409,6 +425,21 @@ config CRYPTO_CRC32C
          See Castagnoli93.  This implementation uses lib/libcrc32c.
           Module will be crc32c.
 
+config CRYPTO_CAMELLIA
+       tristate "Camellia cipher algorithms"
+       depends on CRYPTO
+       select CRYPTO_ALGAPI
+       help
+         Camellia cipher algorithms module.
+
+         Camellia is a symmetric key block cipher developed jointly
+         at NTT and Mitsubishi Electric Corporation.
+
+         The Camellia specifies three key sizes: 128, 192 and 256 bits.
+
+         See also:
+         <https://info.isl.ntt.co.jp/crypt/eng/camellia/index_s.html>
+
 config CRYPTO_TEST
        tristate "Testing module"
        depends on m
index 60e3d24f61f56a28c9c2e91eb84a4cac05671366..12f93f578171daccd1bad404d8d28229bd450321 100644 (file)
@@ -27,13 +27,16 @@ obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o
 obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
 obj-$(CONFIG_CRYPTO_ECB) += ecb.o
 obj-$(CONFIG_CRYPTO_CBC) += cbc.o
+obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
 obj-$(CONFIG_CRYPTO_LRW) += lrw.o
 obj-$(CONFIG_CRYPTO_DES) += des.o
+obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
 obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o
 obj-$(CONFIG_CRYPTO_TWOFISH) += twofish.o
 obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
 obj-$(CONFIG_CRYPTO_SERPENT) += serpent.o
 obj-$(CONFIG_CRYPTO_AES) += aes.o
+obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia.o
 obj-$(CONFIG_CRYPTO_CAST5) += cast5.o
 obj-$(CONFIG_CRYPTO_CAST6) += cast6.o
 obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
index c91530021e9ce6744b1382950eb9fed3d258d119..f7d2185b2c8fbac94cf6f6736b5f1a965f224bb9 100644 (file)
@@ -377,7 +377,8 @@ void crypto_drop_spawn(struct crypto_spawn *spawn)
 }
 EXPORT_SYMBOL_GPL(crypto_drop_spawn);
 
-struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn)
+struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
+                                   u32 mask)
 {
        struct crypto_alg *alg;
        struct crypto_alg *alg2;
@@ -396,10 +397,18 @@ struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn)
                return ERR_PTR(-EAGAIN);
        }
 
-       tfm = __crypto_alloc_tfm(alg, 0);
+       tfm = ERR_PTR(-EINVAL);
+       if (unlikely((alg->cra_flags ^ type) & mask))
+               goto out_put_alg;
+
+       tfm = __crypto_alloc_tfm(alg, type, mask);
        if (IS_ERR(tfm))
-               crypto_mod_put(alg);
+               goto out_put_alg;
+
+       return tfm;
 
+out_put_alg:
+       crypto_mod_put(alg);
        return tfm;
 }
 EXPORT_SYMBOL_GPL(crypto_spawn_tfm);
index 8c446871cd5b13998294850338bb4ce93930f069..55af8bb0f0502eb7f80f3ed2c71fb21518319252 100644 (file)
@@ -212,31 +212,12 @@ struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask)
 }
 EXPORT_SYMBOL_GPL(crypto_alg_mod_lookup);
 
-static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags)
+static int crypto_init_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
 {
-       tfm->crt_flags = flags & CRYPTO_TFM_REQ_MASK;
-       flags &= ~CRYPTO_TFM_REQ_MASK;
-       
-       switch (crypto_tfm_alg_type(tfm)) {
-       case CRYPTO_ALG_TYPE_CIPHER:
-               return crypto_init_cipher_flags(tfm, flags);
-               
-       case CRYPTO_ALG_TYPE_DIGEST:
-               return crypto_init_digest_flags(tfm, flags);
-               
-       case CRYPTO_ALG_TYPE_COMPRESS:
-               return crypto_init_compress_flags(tfm, flags);
-       }
-       
-       return 0;
-}
+       const struct crypto_type *type_obj = tfm->__crt_alg->cra_type;
 
-static int crypto_init_ops(struct crypto_tfm *tfm)
-{
-       const struct crypto_type *type = tfm->__crt_alg->cra_type;
-
-       if (type)
-               return type->init(tfm);
+       if (type_obj)
+               return type_obj->init(tfm, type, mask);
 
        switch (crypto_tfm_alg_type(tfm)) {
        case CRYPTO_ALG_TYPE_CIPHER:
@@ -285,29 +266,29 @@ static void crypto_exit_ops(struct crypto_tfm *tfm)
        }
 }
 
-static unsigned int crypto_ctxsize(struct crypto_alg *alg, int flags)
+static unsigned int crypto_ctxsize(struct crypto_alg *alg, u32 type, u32 mask)
 {
-       const struct crypto_type *type = alg->cra_type;
+       const struct crypto_type *type_obj = alg->cra_type;
        unsigned int len;
 
        len = alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1);
-       if (type)
-               return len + type->ctxsize(alg);
+       if (type_obj)
+               return len + type_obj->ctxsize(alg, type, mask);
 
        switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
        default:
                BUG();
 
        case CRYPTO_ALG_TYPE_CIPHER:
-               len += crypto_cipher_ctxsize(alg, flags);
+               len += crypto_cipher_ctxsize(alg);
                break;
                
        case CRYPTO_ALG_TYPE_DIGEST:
-               len += crypto_digest_ctxsize(alg, flags);
+               len += crypto_digest_ctxsize(alg);
                break;
                
        case CRYPTO_ALG_TYPE_COMPRESS:
-               len += crypto_compress_ctxsize(alg, flags);
+               len += crypto_compress_ctxsize(alg);
                break;
        }
 
@@ -322,24 +303,21 @@ void crypto_shoot_alg(struct crypto_alg *alg)
 }
 EXPORT_SYMBOL_GPL(crypto_shoot_alg);
 
-struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 flags)
+struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
+                                     u32 mask)
 {
        struct crypto_tfm *tfm = NULL;
        unsigned int tfm_size;
        int err = -ENOMEM;
 
-       tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, flags);
+       tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, type, mask);
        tfm = kzalloc(tfm_size, GFP_KERNEL);
        if (tfm == NULL)
                goto out_err;
 
        tfm->__crt_alg = alg;
 
-       err = crypto_init_flags(tfm, flags);
-       if (err)
-               goto out_free_tfm;
-               
-       err = crypto_init_ops(tfm);
+       err = crypto_init_ops(tfm, type, mask);
        if (err)
                goto out_free_tfm;
 
@@ -362,31 +340,6 @@ out:
 }
 EXPORT_SYMBOL_GPL(__crypto_alloc_tfm);
 
-struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
-{
-       struct crypto_tfm *tfm = NULL;
-       int err;
-
-       do {
-               struct crypto_alg *alg;
-
-               alg = crypto_alg_mod_lookup(name, 0, CRYPTO_ALG_ASYNC);
-               err = PTR_ERR(alg);
-               if (IS_ERR(alg))
-                       continue;
-
-               tfm = __crypto_alloc_tfm(alg, flags);
-               err = 0;
-               if (IS_ERR(tfm)) {
-                       crypto_mod_put(alg);
-                       err = PTR_ERR(tfm);
-                       tfm = NULL;
-               }
-       } while (err == -EAGAIN && !signal_pending(current));
-
-       return tfm;
-}
-
 /*
  *     crypto_alloc_base - Locate algorithm and allocate transform
  *     @alg_name: Name of algorithm
@@ -420,7 +373,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
                        goto err;
                }
 
-               tfm = __crypto_alloc_tfm(alg, 0);
+               tfm = __crypto_alloc_tfm(alg, type, mask);
                if (!IS_ERR(tfm))
                        return tfm;
 
@@ -466,7 +419,6 @@ void crypto_free_tfm(struct crypto_tfm *tfm)
        kfree(tfm);
 }
 
-EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
 EXPORT_SYMBOL_GPL(crypto_free_tfm);
 
 int crypto_has_alg(const char *name, u32 type, u32 mask)
index 6e93004f2181ccb3f265994cf9806db528641796..b5befe8c3a96ee1a4c73b708823b76a2f9bb06bc 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <linux/crypto.h>
 #include <linux/errno.h>
+#include <linux/hardirq.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/scatterlist.h>
@@ -313,6 +314,9 @@ static int blkcipher_walk_first(struct blkcipher_desc *desc,
        struct crypto_blkcipher *tfm = desc->tfm;
        unsigned int alignmask = crypto_blkcipher_alignmask(tfm);
 
+       if (WARN_ON_ONCE(in_irq()))
+               return -EDEADLK;
+
        walk->nbytes = walk->total;
        if (unlikely(!walk->total))
                return 0;
@@ -345,7 +349,8 @@ static int setkey(struct crypto_tfm *tfm, const u8 *key,
        return cipher->setkey(tfm, key, keylen);
 }
 
-static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg)
+static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg, u32 type,
+                                            u32 mask)
 {
        struct blkcipher_alg *cipher = &alg->cra_blkcipher;
        unsigned int len = alg->cra_ctxsize;
@@ -358,7 +363,7 @@ static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg)
        return len;
 }
 
-static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm)
+static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
 {
        struct blkcipher_tfm *crt = &tfm->crt_blkcipher;
        struct blkcipher_alg *alg = &tfm->__crt_alg->cra_blkcipher;
diff --git a/crypto/camellia.c b/crypto/camellia.c
new file mode 100644 (file)
index 0000000..6877ecf
--- /dev/null
@@ -0,0 +1,1801 @@
+/*
+ * Copyright (C) 2006
+ * NTT (Nippon Telegraph and Telephone Corporation).
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+/*
+ * Algorithm Specification
+ *  http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html
+ */
+
+/*
+ *
+ * NOTE --- NOTE --- NOTE --- NOTE
+ * This implementation assumes that all memory addresses passed
+ * as parameters are four-byte aligned.
+ *
+ */
+
+#include <linux/crypto.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+
+#define CAMELLIA_MIN_KEY_SIZE        16
+#define CAMELLIA_MAX_KEY_SIZE        32
+#define CAMELLIA_BLOCK_SIZE 16
+#define CAMELLIA_TABLE_BYTE_LEN 272
+#define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
+
+typedef u32 KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
+
+
+/* key constants */
+
+#define CAMELLIA_SIGMA1L (0xA09E667FL)
+#define CAMELLIA_SIGMA1R (0x3BCC908BL)
+#define CAMELLIA_SIGMA2L (0xB67AE858L)
+#define CAMELLIA_SIGMA2R (0x4CAA73B2L)
+#define CAMELLIA_SIGMA3L (0xC6EF372FL)
+#define CAMELLIA_SIGMA3R (0xE94F82BEL)
+#define CAMELLIA_SIGMA4L (0x54FF53A5L)
+#define CAMELLIA_SIGMA4R (0xF1D36F1CL)
+#define CAMELLIA_SIGMA5L (0x10E527FAL)
+#define CAMELLIA_SIGMA5R (0xDE682D1DL)
+#define CAMELLIA_SIGMA6L (0xB05688C2L)
+#define CAMELLIA_SIGMA6R (0xB3E6C1FDL)
+
+struct camellia_ctx {
+       int key_length;
+       KEY_TABLE_TYPE key_table;
+};
+
+
+/*
+ *  macros
+ */
+
+
+# define GETU32(pt) (((u32)(pt)[0] << 24)      \
+                    ^ ((u32)(pt)[1] << 16)     \
+                    ^ ((u32)(pt)[2] <<  8)     \
+                    ^ ((u32)(pt)[3]))
+
+#define COPY4WORD(dst, src)                    \
+    do {                                       \
+       (dst)[0]=(src)[0];                      \
+       (dst)[1]=(src)[1];                      \
+       (dst)[2]=(src)[2];                      \
+       (dst)[3]=(src)[3];                      \
+    }while(0)
+
+#define SWAP4WORD(word)                                \
+    do {                                       \
+       CAMELLIA_SWAP4((word)[0]);              \
+       CAMELLIA_SWAP4((word)[1]);              \
+       CAMELLIA_SWAP4((word)[2]);              \
+       CAMELLIA_SWAP4((word)[3]);              \
+    }while(0)
+
+#define XOR4WORD(a, b)/* a = a ^ b */          \
+    do {                                       \
+       (a)[0]^=(b)[0];                         \
+       (a)[1]^=(b)[1];                         \
+       (a)[2]^=(b)[2];                         \
+       (a)[3]^=(b)[3];                         \
+    }while(0)
+
+#define XOR4WORD2(a, b, c)/* a = b ^ c */      \
+    do {                                       \
+       (a)[0]=(b)[0]^(c)[0];                   \
+       (a)[1]=(b)[1]^(c)[1];                   \
+       (a)[2]=(b)[2]^(c)[2];                   \
+       (a)[3]=(b)[3]^(c)[3];                   \
+    }while(0)
+
+#define CAMELLIA_SUBKEY_L(INDEX) (subkey[(INDEX)*2])
+#define CAMELLIA_SUBKEY_R(INDEX) (subkey[(INDEX)*2 + 1])
+
+/* rotation right shift 1byte */
+#define CAMELLIA_RR8(x) (((x) >> 8) + ((x) << 24))
+/* rotation left shift 1bit */
+#define CAMELLIA_RL1(x) (((x) << 1) + ((x) >> 31))
+/* rotation left shift 1byte */
+#define CAMELLIA_RL8(x) (((x) << 8) + ((x) >> 24))
+
+#define CAMELLIA_ROLDQ(ll, lr, rl, rr, w0, w1, bits)   \
+    do {                                               \
+       w0 = ll;                                        \
+       ll = (ll << bits) + (lr >> (32 - bits));        \
+       lr = (lr << bits) + (rl >> (32 - bits));        \
+       rl = (rl << bits) + (rr >> (32 - bits));        \
+       rr = (rr << bits) + (w0 >> (32 - bits));        \
+    } while(0)
+
+#define CAMELLIA_ROLDQo32(ll, lr, rl, rr, w0, w1, bits)        \
+    do {                                               \
+       w0 = ll;                                        \
+       w1 = lr;                                        \
+       ll = (lr << (bits - 32)) + (rl >> (64 - bits)); \
+       lr = (rl << (bits - 32)) + (rr >> (64 - bits)); \
+       rl = (rr << (bits - 32)) + (w0 >> (64 - bits)); \
+       rr = (w0 << (bits - 32)) + (w1 >> (64 - bits)); \
+    } while(0)
+
+#define CAMELLIA_SP1110(INDEX) (camellia_sp1110[(INDEX)])
+#define CAMELLIA_SP0222(INDEX) (camellia_sp0222[(INDEX)])
+#define CAMELLIA_SP3033(INDEX) (camellia_sp3033[(INDEX)])
+#define CAMELLIA_SP4404(INDEX) (camellia_sp4404[(INDEX)])
+
+#define CAMELLIA_F(xl, xr, kl, kr, yl, yr, il, ir, t0, t1)     \
+    do {                                                       \
+       il = xl ^ kl;                                           \
+       ir = xr ^ kr;                                           \
+       t0 = il >> 16;                                          \
+       t1 = ir >> 16;                                          \
+       yl = CAMELLIA_SP1110(ir & 0xff)                         \
+           ^ CAMELLIA_SP0222((t1 >> 8) & 0xff)                 \
+           ^ CAMELLIA_SP3033(t1 & 0xff)                        \
+           ^ CAMELLIA_SP4404((ir >> 8) & 0xff);                \
+       yr = CAMELLIA_SP1110((t0 >> 8) & 0xff)                  \
+           ^ CAMELLIA_SP0222(t0 & 0xff)                        \
+           ^ CAMELLIA_SP3033((il >> 8) & 0xff)                 \
+           ^ CAMELLIA_SP4404(il & 0xff);                       \
+       yl ^= yr;                                               \
+       yr = CAMELLIA_RR8(yr);                                  \
+       yr ^= yl;                                               \
+    } while(0)
+
+
+/*
+ * for speed up
+ *
+ */
+#define CAMELLIA_FLS(ll, lr, rl, rr, kll, klr, krl, krr, t0, t1, t2, t3) \
+    do {                                                               \
+       t0 = kll;                                                       \
+       t2 = krr;                                                       \
+       t0 &= ll;                                                       \
+       t2 |= rr;                                                       \
+       rl ^= t2;                                                       \
+       lr ^= CAMELLIA_RL1(t0);                                         \
+       t3 = krl;                                                       \
+       t1 = klr;                                                       \
+       t3 &= rl;                                                       \
+       t1 |= lr;                                                       \
+       ll ^= t1;                                                       \
+       rr ^= CAMELLIA_RL1(t3);                                         \
+    } while(0)
+
+#define CAMELLIA_ROUNDSM(xl, xr, kl, kr, yl, yr, il, ir, t0, t1)       \
+    do {                                                               \
+       ir =  CAMELLIA_SP1110(xr & 0xff);                               \
+       il =  CAMELLIA_SP1110((xl>>24) & 0xff);                         \
+       ir ^= CAMELLIA_SP0222((xr>>24) & 0xff);                         \
+       il ^= CAMELLIA_SP0222((xl>>16) & 0xff);                         \
+       ir ^= CAMELLIA_SP3033((xr>>16) & 0xff);                         \
+       il ^= CAMELLIA_SP3033((xl>>8) & 0xff);                          \
+       ir ^= CAMELLIA_SP4404((xr>>8) & 0xff);                          \
+       il ^= CAMELLIA_SP4404(xl & 0xff);                               \
+       il ^= kl;                                                       \
+       ir ^= il ^ kr;                                                  \
+       yl ^= ir;                                                       \
+       yr ^= CAMELLIA_RR8(il) ^ ir;                                    \
+    } while(0)
+
+/**
+ * Stuff related to the Camellia key schedule
+ */
+#define SUBL(x) subL[(x)]
+#define SUBR(x) subR[(x)]
+
+
+static const u32 camellia_sp1110[256] = {
+       0x70707000,0x82828200,0x2c2c2c00,0xececec00,
+       0xb3b3b300,0x27272700,0xc0c0c000,0xe5e5e500,
+       0xe4e4e400,0x85858500,0x57575700,0x35353500,
+       0xeaeaea00,0x0c0c0c00,0xaeaeae00,0x41414100,
+       0x23232300,0xefefef00,0x6b6b6b00,0x93939300,
+       0x45454500,0x19191900,0xa5a5a500,0x21212100,
+       0xededed00,0x0e0e0e00,0x4f4f4f00,0x4e4e4e00,
+       0x1d1d1d00,0x65656500,0x92929200,0xbdbdbd00,
+       0x86868600,0xb8b8b800,0xafafaf00,0x8f8f8f00,
+       0x7c7c7c00,0xebebeb00,0x1f1f1f00,0xcecece00,
+       0x3e3e3e00,0x30303000,0xdcdcdc00,0x5f5f5f00,
+       0x5e5e5e00,0xc5c5c500,0x0b0b0b00,0x1a1a1a00,
+       0xa6a6a600,0xe1e1e100,0x39393900,0xcacaca00,
+       0xd5d5d500,0x47474700,0x5d5d5d00,0x3d3d3d00,
+       0xd9d9d900,0x01010100,0x5a5a5a00,0xd6d6d600,
+       0x51515100,0x56565600,0x6c6c6c00,0x4d4d4d00,
+       0x8b8b8b00,0x0d0d0d00,0x9a9a9a00,0x66666600,
+       0xfbfbfb00,0xcccccc00,0xb0b0b000,0x2d2d2d00,
+       0x74747400,0x12121200,0x2b2b2b00,0x20202000,
+       0xf0f0f000,0xb1b1b100,0x84848400,0x99999900,
+       0xdfdfdf00,0x4c4c4c00,0xcbcbcb00,0xc2c2c200,
+       0x34343400,0x7e7e7e00,0x76767600,0x05050500,
+       0x6d6d6d00,0xb7b7b700,0xa9a9a900,0x31313100,
+       0xd1d1d100,0x17171700,0x04040400,0xd7d7d700,
+       0x14141400,0x58585800,0x3a3a3a00,0x61616100,
+       0xdedede00,0x1b1b1b00,0x11111100,0x1c1c1c00,
+       0x32323200,0x0f0f0f00,0x9c9c9c00,0x16161600,
+       0x53535300,0x18181800,0xf2f2f200,0x22222200,
+       0xfefefe00,0x44444400,0xcfcfcf00,0xb2b2b200,
+       0xc3c3c300,0xb5b5b500,0x7a7a7a00,0x91919100,
+       0x24242400,0x08080800,0xe8e8e800,0xa8a8a800,
+       0x60606000,0xfcfcfc00,0x69696900,0x50505000,
+       0xaaaaaa00,0xd0d0d000,0xa0a0a000,0x7d7d7d00,
+       0xa1a1a100,0x89898900,0x62626200,0x97979700,
+       0x54545400,0x5b5b5b00,0x1e1e1e00,0x95959500,
+       0xe0e0e000,0xffffff00,0x64646400,0xd2d2d200,
+       0x10101000,0xc4c4c400,0x00000000,0x48484800,
+       0xa3a3a300,0xf7f7f700,0x75757500,0xdbdbdb00,
+       0x8a8a8a00,0x03030300,0xe6e6e600,0xdadada00,
+       0x09090900,0x3f3f3f00,0xdddddd00,0x94949400,
+       0x87878700,0x5c5c5c00,0x83838300,0x02020200,
+       0xcdcdcd00,0x4a4a4a00,0x90909000,0x33333300,
+       0x73737300,0x67676700,0xf6f6f600,0xf3f3f300,
+       0x9d9d9d00,0x7f7f7f00,0xbfbfbf00,0xe2e2e200,
+       0x52525200,0x9b9b9b00,0xd8d8d800,0x26262600,
+       0xc8c8c800,0x37373700,0xc6c6c600,0x3b3b3b00,
+       0x81818100,0x96969600,0x6f6f6f00,0x4b4b4b00,
+       0x13131300,0xbebebe00,0x63636300,0x2e2e2e00,
+       0xe9e9e900,0x79797900,0xa7a7a700,0x8c8c8c00,
+       0x9f9f9f00,0x6e6e6e00,0xbcbcbc00,0x8e8e8e00,
+       0x29292900,0xf5f5f500,0xf9f9f900,0xb6b6b600,
+       0x2f2f2f00,0xfdfdfd00,0xb4b4b400,0x59595900,
+       0x78787800,0x98989800,0x06060600,0x6a6a6a00,
+       0xe7e7e700,0x46464600,0x71717100,0xbababa00,
+       0xd4d4d400,0x25252500,0xababab00,0x42424200,
+       0x88888800,0xa2a2a200,0x8d8d8d00,0xfafafa00,
+       0x72727200,0x07070700,0xb9b9b900,0x55555500,
+       0xf8f8f800,0xeeeeee00,0xacacac00,0x0a0a0a00,
+       0x36363600,0x49494900,0x2a2a2a00,0x68686800,
+       0x3c3c3c00,0x38383800,0xf1f1f100,0xa4a4a400,
+       0x40404000,0x28282800,0xd3d3d300,0x7b7b7b00,
+       0xbbbbbb00,0xc9c9c900,0x43434300,0xc1c1c100,
+       0x15151500,0xe3e3e300,0xadadad00,0xf4f4f400,
+       0x77777700,0xc7c7c700,0x80808000,0x9e9e9e00,
+};
+
+static const u32 camellia_sp0222[256] = {
+       0x00e0e0e0,0x00050505,0x00585858,0x00d9d9d9,
+       0x00676767,0x004e4e4e,0x00818181,0x00cbcbcb,
+       0x00c9c9c9,0x000b0b0b,0x00aeaeae,0x006a6a6a,
+       0x00d5d5d5,0x00181818,0x005d5d5d,0x00828282,
+       0x00464646,0x00dfdfdf,0x00d6d6d6,0x00272727,
+       0x008a8a8a,0x00323232,0x004b4b4b,0x00424242,
+       0x00dbdbdb,0x001c1c1c,0x009e9e9e,0x009c9c9c,
+       0x003a3a3a,0x00cacaca,0x00252525,0x007b7b7b,
+       0x000d0d0d,0x00717171,0x005f5f5f,0x001f1f1f,
+       0x00f8f8f8,0x00d7d7d7,0x003e3e3e,0x009d9d9d,
+       0x007c7c7c,0x00606060,0x00b9b9b9,0x00bebebe,
+       0x00bcbcbc,0x008b8b8b,0x00161616,0x00343434,
+       0x004d4d4d,0x00c3c3c3,0x00727272,0x00959595,
+       0x00ababab,0x008e8e8e,0x00bababa,0x007a7a7a,
+       0x00b3b3b3,0x00020202,0x00b4b4b4,0x00adadad,
+       0x00a2a2a2,0x00acacac,0x00d8d8d8,0x009a9a9a,
+       0x00171717,0x001a1a1a,0x00353535,0x00cccccc,
+       0x00f7f7f7,0x00999999,0x00616161,0x005a5a5a,
+       0x00e8e8e8,0x00242424,0x00565656,0x00404040,
+       0x00e1e1e1,0x00636363,0x00090909,0x00333333,
+       0x00bfbfbf,0x00989898,0x00979797,0x00858585,
+       0x00686868,0x00fcfcfc,0x00ececec,0x000a0a0a,
+       0x00dadada,0x006f6f6f,0x00535353,0x00626262,
+       0x00a3a3a3,0x002e2e2e,0x00080808,0x00afafaf,
+       0x00282828,0x00b0b0b0,0x00747474,0x00c2c2c2,
+       0x00bdbdbd,0x00363636,0x00222222,0x00383838,
+       0x00646464,0x001e1e1e,0x00393939,0x002c2c2c,
+       0x00a6a6a6,0x00303030,0x00e5e5e5,0x00444444,
+       0x00fdfdfd,0x00888888,0x009f9f9f,0x00656565,
+       0x00878787,0x006b6b6b,0x00f4f4f4,0x00232323,
+       0x00484848,0x00101010,0x00d1d1d1,0x00515151,
+       0x00c0c0c0,0x00f9f9f9,0x00d2d2d2,0x00a0a0a0,
+       0x00555555,0x00a1a1a1,0x00414141,0x00fafafa,
+       0x00434343,0x00131313,0x00c4c4c4,0x002f2f2f,
+       0x00a8a8a8,0x00b6b6b6,0x003c3c3c,0x002b2b2b,
+       0x00c1c1c1,0x00ffffff,0x00c8c8c8,0x00a5a5a5,
+       0x00202020,0x00898989,0x00000000,0x00909090,
+       0x00474747,0x00efefef,0x00eaeaea,0x00b7b7b7,
+       0x00151515,0x00060606,0x00cdcdcd,0x00b5b5b5,
+       0x00121212,0x007e7e7e,0x00bbbbbb,0x00292929,
+       0x000f0f0f,0x00b8b8b8,0x00070707,0x00040404,
+       0x009b9b9b,0x00949494,0x00212121,0x00666666,
+       0x00e6e6e6,0x00cecece,0x00ededed,0x00e7e7e7,
+       0x003b3b3b,0x00fefefe,0x007f7f7f,0x00c5c5c5,
+       0x00a4a4a4,0x00373737,0x00b1b1b1,0x004c4c4c,
+       0x00919191,0x006e6e6e,0x008d8d8d,0x00767676,
+       0x00030303,0x002d2d2d,0x00dedede,0x00969696,
+       0x00262626,0x007d7d7d,0x00c6c6c6,0x005c5c5c,
+       0x00d3d3d3,0x00f2f2f2,0x004f4f4f,0x00191919,
+       0x003f3f3f,0x00dcdcdc,0x00797979,0x001d1d1d,
+       0x00525252,0x00ebebeb,0x00f3f3f3,0x006d6d6d,
+       0x005e5e5e,0x00fbfbfb,0x00696969,0x00b2b2b2,
+       0x00f0f0f0,0x00313131,0x000c0c0c,0x00d4d4d4,
+       0x00cfcfcf,0x008c8c8c,0x00e2e2e2,0x00757575,
+       0x00a9a9a9,0x004a4a4a,0x00575757,0x00848484,
+       0x00111111,0x00454545,0x001b1b1b,0x00f5f5f5,
+       0x00e4e4e4,0x000e0e0e,0x00737373,0x00aaaaaa,
+       0x00f1f1f1,0x00dddddd,0x00595959,0x00141414,
+       0x006c6c6c,0x00929292,0x00545454,0x00d0d0d0,
+       0x00787878,0x00707070,0x00e3e3e3,0x00494949,
+       0x00808080,0x00505050,0x00a7a7a7,0x00f6f6f6,
+       0x00777777,0x00939393,0x00868686,0x00838383,
+       0x002a2a2a,0x00c7c7c7,0x005b5b5b,0x00e9e9e9,
+       0x00eeeeee,0x008f8f8f,0x00010101,0x003d3d3d,
+};
+
+static const u32 camellia_sp3033[256] = {
+       0x38003838,0x41004141,0x16001616,0x76007676,
+       0xd900d9d9,0x93009393,0x60006060,0xf200f2f2,
+       0x72007272,0xc200c2c2,0xab00abab,0x9a009a9a,
+       0x75007575,0x06000606,0x57005757,0xa000a0a0,
+       0x91009191,0xf700f7f7,0xb500b5b5,0xc900c9c9,
+       0xa200a2a2,0x8c008c8c,0xd200d2d2,0x90009090,
+       0xf600f6f6,0x07000707,0xa700a7a7,0x27002727,
+       0x8e008e8e,0xb200b2b2,0x49004949,0xde00dede,
+       0x43004343,0x5c005c5c,0xd700d7d7,0xc700c7c7,
+       0x3e003e3e,0xf500f5f5,0x8f008f8f,0x67006767,
+       0x1f001f1f,0x18001818,0x6e006e6e,0xaf00afaf,
+       0x2f002f2f,0xe200e2e2,0x85008585,0x0d000d0d,
+       0x53005353,0xf000f0f0,0x9c009c9c,0x65006565,
+       0xea00eaea,0xa300a3a3,0xae00aeae,0x9e009e9e,
+       0xec00ecec,0x80008080,0x2d002d2d,0x6b006b6b,
+       0xa800a8a8,0x2b002b2b,0x36003636,0xa600a6a6,
+       0xc500c5c5,0x86008686,0x4d004d4d,0x33003333,
+       0xfd00fdfd,0x66006666,0x58005858,0x96009696,
+       0x3a003a3a,0x09000909,0x95009595,0x10001010,
+       0x78007878,0xd800d8d8,0x42004242,0xcc00cccc,
+       0xef00efef,0x26002626,0xe500e5e5,0x61006161,
+       0x1a001a1a,0x3f003f3f,0x3b003b3b,0x82008282,
+       0xb600b6b6,0xdb00dbdb,0xd400d4d4,0x98009898,
+       0xe800e8e8,0x8b008b8b,0x02000202,0xeb00ebeb,
+       0x0a000a0a,0x2c002c2c,0x1d001d1d,0xb000b0b0,
+       0x6f006f6f,0x8d008d8d,0x88008888,0x0e000e0e,
+       0x19001919,0x87008787,0x4e004e4e,0x0b000b0b,
+       0xa900a9a9,0x0c000c0c,0x79007979,0x11001111,
+       0x7f007f7f,0x22002222,0xe700e7e7,0x59005959,
+       0xe100e1e1,0xda00dada,0x3d003d3d,0xc800c8c8,
+       0x12001212,0x04000404,0x74007474,0x54005454,
+       0x30003030,0x7e007e7e,0xb400b4b4,0x28002828,
+       0x55005555,0x68006868,0x50005050,0xbe00bebe,
+       0xd000d0d0,0xc400c4c4,0x31003131,0xcb00cbcb,
+       0x2a002a2a,0xad00adad,0x0f000f0f,0xca00caca,
+       0x70007070,0xff00ffff,0x32003232,0x69006969,
+       0x08000808,0x62006262,0x00000000,0x24002424,
+       0xd100d1d1,0xfb00fbfb,0xba00baba,0xed00eded,
+       0x45004545,0x81008181,0x73007373,0x6d006d6d,
+       0x84008484,0x9f009f9f,0xee00eeee,0x4a004a4a,
+       0xc300c3c3,0x2e002e2e,0xc100c1c1,0x01000101,
+       0xe600e6e6,0x25002525,0x48004848,0x99009999,
+       0xb900b9b9,0xb300b3b3,0x7b007b7b,0xf900f9f9,
+       0xce00cece,0xbf00bfbf,0xdf00dfdf,0x71007171,
+       0x29002929,0xcd00cdcd,0x6c006c6c,0x13001313,
+       0x64006464,0x9b009b9b,0x63006363,0x9d009d9d,
+       0xc000c0c0,0x4b004b4b,0xb700b7b7,0xa500a5a5,
+       0x89008989,0x5f005f5f,0xb100b1b1,0x17001717,
+       0xf400f4f4,0xbc00bcbc,0xd300d3d3,0x46004646,
+       0xcf00cfcf,0x37003737,0x5e005e5e,0x47004747,
+       0x94009494,0xfa00fafa,0xfc00fcfc,0x5b005b5b,
+       0x97009797,0xfe00fefe,0x5a005a5a,0xac00acac,
+       0x3c003c3c,0x4c004c4c,0x03000303,0x35003535,
+       0xf300f3f3,0x23002323,0xb800b8b8,0x5d005d5d,
+       0x6a006a6a,0x92009292,0xd500d5d5,0x21002121,
+       0x44004444,0x51005151,0xc600c6c6,0x7d007d7d,
+       0x39003939,0x83008383,0xdc00dcdc,0xaa00aaaa,
+       0x7c007c7c,0x77007777,0x56005656,0x05000505,
+       0x1b001b1b,0xa400a4a4,0x15001515,0x34003434,
+       0x1e001e1e,0x1c001c1c,0xf800f8f8,0x52005252,
+       0x20002020,0x14001414,0xe900e9e9,0xbd00bdbd,
+       0xdd00dddd,0xe400e4e4,0xa100a1a1,0xe000e0e0,
+       0x8a008a8a,0xf100f1f1,0xd600d6d6,0x7a007a7a,
+       0xbb00bbbb,0xe300e3e3,0x40004040,0x4f004f4f,
+};
+
+static const u32 camellia_sp4404[256] = {
+       0x70700070,0x2c2c002c,0xb3b300b3,0xc0c000c0,
+       0xe4e400e4,0x57570057,0xeaea00ea,0xaeae00ae,
+       0x23230023,0x6b6b006b,0x45450045,0xa5a500a5,
+       0xeded00ed,0x4f4f004f,0x1d1d001d,0x92920092,
+       0x86860086,0xafaf00af,0x7c7c007c,0x1f1f001f,
+       0x3e3e003e,0xdcdc00dc,0x5e5e005e,0x0b0b000b,
+       0xa6a600a6,0x39390039,0xd5d500d5,0x5d5d005d,
+       0xd9d900d9,0x5a5a005a,0x51510051,0x6c6c006c,
+       0x8b8b008b,0x9a9a009a,0xfbfb00fb,0xb0b000b0,
+       0x74740074,0x2b2b002b,0xf0f000f0,0x84840084,
+       0xdfdf00df,0xcbcb00cb,0x34340034,0x76760076,
+       0x6d6d006d,0xa9a900a9,0xd1d100d1,0x04040004,
+       0x14140014,0x3a3a003a,0xdede00de,0x11110011,
+       0x32320032,0x9c9c009c,0x53530053,0xf2f200f2,
+       0xfefe00fe,0xcfcf00cf,0xc3c300c3,0x7a7a007a,
+       0x24240024,0xe8e800e8,0x60600060,0x69690069,
+       0xaaaa00aa,0xa0a000a0,0xa1a100a1,0x62620062,
+       0x54540054,0x1e1e001e,0xe0e000e0,0x64640064,
+       0x10100010,0x00000000,0xa3a300a3,0x75750075,
+       0x8a8a008a,0xe6e600e6,0x09090009,0xdddd00dd,
+       0x87870087,0x83830083,0xcdcd00cd,0x90900090,
+       0x73730073,0xf6f600f6,0x9d9d009d,0xbfbf00bf,
+       0x52520052,0xd8d800d8,0xc8c800c8,0xc6c600c6,
+       0x81810081,0x6f6f006f,0x13130013,0x63630063,
+       0xe9e900e9,0xa7a700a7,0x9f9f009f,0xbcbc00bc,
+       0x29290029,0xf9f900f9,0x2f2f002f,0xb4b400b4,
+       0x78780078,0x06060006,0xe7e700e7,0x71710071,
+       0xd4d400d4,0xabab00ab,0x88880088,0x8d8d008d,
+       0x72720072,0xb9b900b9,0xf8f800f8,0xacac00ac,
+       0x36360036,0x2a2a002a,0x3c3c003c,0xf1f100f1,
+       0x40400040,0xd3d300d3,0xbbbb00bb,0x43430043,
+       0x15150015,0xadad00ad,0x77770077,0x80800080,
+       0x82820082,0xecec00ec,0x27270027,0xe5e500e5,
+       0x85850085,0x35350035,0x0c0c000c,0x41410041,
+       0xefef00ef,0x93930093,0x19190019,0x21210021,
+       0x0e0e000e,0x4e4e004e,0x65650065,0xbdbd00bd,
+       0xb8b800b8,0x8f8f008f,0xebeb00eb,0xcece00ce,
+       0x30300030,0x5f5f005f,0xc5c500c5,0x1a1a001a,
+       0xe1e100e1,0xcaca00ca,0x47470047,0x3d3d003d,
+       0x01010001,0xd6d600d6,0x56560056,0x4d4d004d,
+       0x0d0d000d,0x66660066,0xcccc00cc,0x2d2d002d,
+       0x12120012,0x20200020,0xb1b100b1,0x99990099,
+       0x4c4c004c,0xc2c200c2,0x7e7e007e,0x05050005,
+       0xb7b700b7,0x31310031,0x17170017,0xd7d700d7,
+       0x58580058,0x61610061,0x1b1b001b,0x1c1c001c,
+       0x0f0f000f,0x16160016,0x18180018,0x22220022,
+       0x44440044,0xb2b200b2,0xb5b500b5,0x91910091,
+       0x08080008,0xa8a800a8,0xfcfc00fc,0x50500050,
+       0xd0d000d0,0x7d7d007d,0x89890089,0x97970097,
+       0x5b5b005b,0x95950095,0xffff00ff,0xd2d200d2,
+       0xc4c400c4,0x48480048,0xf7f700f7,0xdbdb00db,
+       0x03030003,0xdada00da,0x3f3f003f,0x94940094,
+       0x5c5c005c,0x02020002,0x4a4a004a,0x33330033,
+       0x67670067,0xf3f300f3,0x7f7f007f,0xe2e200e2,
+       0x9b9b009b,0x26260026,0x37370037,0x3b3b003b,
+       0x96960096,0x4b4b004b,0xbebe00be,0x2e2e002e,
+       0x79790079,0x8c8c008c,0x6e6e006e,0x8e8e008e,
+       0xf5f500f5,0xb6b600b6,0xfdfd00fd,0x59590059,
+       0x98980098,0x6a6a006a,0x46460046,0xbaba00ba,
+       0x25250025,0x42420042,0xa2a200a2,0xfafa00fa,
+       0x07070007,0x55550055,0xeeee00ee,0x0a0a000a,
+       0x49490049,0x68680068,0x38380038,0xa4a400a4,
+       0x28280028,0x7b7b007b,0xc9c900c9,0xc1c100c1,
+       0xe3e300e3,0xf4f400f4,0xc7c700c7,0x9e9e009e,
+};
+
+
+
+static void camellia_setup128(const unsigned char *key, u32 *subkey)
+{
+       u32 kll, klr, krl, krr;
+       u32 il, ir, t0, t1, w0, w1;
+       u32 kw4l, kw4r, dw, tl, tr;
+       u32 subL[26];
+       u32 subR[26];
+
+       /**
+        *  k == kll || klr || krl || krr (|| is concatination)
+        */
+       kll = GETU32(key     );
+       klr = GETU32(key +  4);
+       krl = GETU32(key +  8);
+       krr = GETU32(key + 12);
+       /**
+        * generate KL dependent subkeys
+        */
+       /* kw1 */
+       SUBL(0) = kll; SUBR(0) = klr;
+       /* kw2 */
+       SUBL(1) = krl; SUBR(1) = krr;
+       /* rotation left shift 15bit */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* k3 */
+       SUBL(4) = kll; SUBR(4) = klr;
+       /* k4 */
+       SUBL(5) = krl; SUBR(5) = krr;
+       /* rotation left shift 15+30bit */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 30);
+       /* k7 */
+       SUBL(10) = kll; SUBR(10) = klr;
+       /* k8 */
+       SUBL(11) = krl; SUBR(11) = krr;
+       /* rotation left shift 15+30+15bit */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* k10 */
+       SUBL(13) = krl; SUBR(13) = krr;
+       /* rotation left shift 15+30+15+17 bit */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+       /* kl3 */
+       SUBL(16) = kll; SUBR(16) = klr;
+       /* kl4 */
+       SUBL(17) = krl; SUBR(17) = krr;
+       /* rotation left shift 15+30+15+17+17 bit */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+       /* k13 */
+       SUBL(18) = kll; SUBR(18) = klr;
+       /* k14 */
+       SUBL(19) = krl; SUBR(19) = krr;
+       /* rotation left shift 15+30+15+17+17+17 bit */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+       /* k17 */
+       SUBL(22) = kll; SUBR(22) = klr;
+       /* k18 */
+       SUBL(23) = krl; SUBR(23) = krr;
+
+       /* generate KA */
+       kll = SUBL(0); klr = SUBR(0);
+       krl = SUBL(1); krr = SUBR(1);
+       CAMELLIA_F(kll, klr,
+                  CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R,
+                  w0, w1, il, ir, t0, t1);
+       krl ^= w0; krr ^= w1;
+       CAMELLIA_F(krl, krr,
+                  CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R,
+                  kll, klr, il, ir, t0, t1);
+       /* current status == (kll, klr, w0, w1) */
+       CAMELLIA_F(kll, klr,
+                  CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R,
+                  krl, krr, il, ir, t0, t1);
+       krl ^= w0; krr ^= w1;
+       CAMELLIA_F(krl, krr,
+                  CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R,
+                  w0, w1, il, ir, t0, t1);
+       kll ^= w0; klr ^= w1;
+
+       /* generate KA dependent subkeys */
+       /* k1, k2 */
+       SUBL(2) = kll; SUBR(2) = klr;
+       SUBL(3) = krl; SUBR(3) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* k5,k6 */
+       SUBL(6) = kll; SUBR(6) = klr;
+       SUBL(7) = krl; SUBR(7) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* kl1, kl2 */
+       SUBL(8) = kll; SUBR(8) = klr;
+       SUBL(9) = krl; SUBR(9) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* k9 */
+       SUBL(12) = kll; SUBR(12) = klr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* k11, k12 */
+       SUBL(14) = kll; SUBR(14) = klr;
+       SUBL(15) = krl; SUBR(15) = krr;
+       CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 34);
+       /* k15, k16 */
+       SUBL(20) = kll; SUBR(20) = klr;
+       SUBL(21) = krl; SUBR(21) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+       /* kw3, kw4 */
+       SUBL(24) = kll; SUBR(24) = klr;
+       SUBL(25) = krl; SUBR(25) = krr;
+
+
+       /* absorb kw2 to other subkeys */
+       /* round 2 */
+       SUBL(3) ^= SUBL(1); SUBR(3) ^= SUBR(1);
+       /* round 4 */
+       SUBL(5) ^= SUBL(1); SUBR(5) ^= SUBR(1);
+       /* round 6 */
+       SUBL(7) ^= SUBL(1); SUBR(7) ^= SUBR(1);
+       SUBL(1) ^= SUBR(1) & ~SUBR(9);
+       dw = SUBL(1) & SUBL(9),
+               SUBR(1) ^= CAMELLIA_RL1(dw); /* modified for FLinv(kl2) */
+       /* round 8 */
+       SUBL(11) ^= SUBL(1); SUBR(11) ^= SUBR(1);
+       /* round 10 */
+       SUBL(13) ^= SUBL(1); SUBR(13) ^= SUBR(1);
+       /* round 12 */
+       SUBL(15) ^= SUBL(1); SUBR(15) ^= SUBR(1);
+       SUBL(1) ^= SUBR(1) & ~SUBR(17);
+       dw = SUBL(1) & SUBL(17),
+               SUBR(1) ^= CAMELLIA_RL1(dw); /* modified for FLinv(kl4) */
+       /* round 14 */
+       SUBL(19) ^= SUBL(1); SUBR(19) ^= SUBR(1);
+       /* round 16 */
+       SUBL(21) ^= SUBL(1); SUBR(21) ^= SUBR(1);
+       /* round 18 */
+       SUBL(23) ^= SUBL(1); SUBR(23) ^= SUBR(1);
+       /* kw3 */
+       SUBL(24) ^= SUBL(1); SUBR(24) ^= SUBR(1);
+
+       /* absorb kw4 to other subkeys */
+       kw4l = SUBL(25); kw4r = SUBR(25);
+       /* round 17 */
+       SUBL(22) ^= kw4l; SUBR(22) ^= kw4r;
+       /* round 15 */
+       SUBL(20) ^= kw4l; SUBR(20) ^= kw4r;
+       /* round 13 */
+       SUBL(18) ^= kw4l; SUBR(18) ^= kw4r;
+       kw4l ^= kw4r & ~SUBR(16);
+       dw = kw4l & SUBL(16),
+               kw4r ^= CAMELLIA_RL1(dw); /* modified for FL(kl3) */
+       /* round 11 */
+       SUBL(14) ^= kw4l; SUBR(14) ^= kw4r;
+       /* round 9 */
+       SUBL(12) ^= kw4l; SUBR(12) ^= kw4r;
+       /* round 7 */
+       SUBL(10) ^= kw4l; SUBR(10) ^= kw4r;
+       kw4l ^= kw4r & ~SUBR(8);
+       dw = kw4l & SUBL(8),
+               kw4r ^= CAMELLIA_RL1(dw); /* modified for FL(kl1) */
+       /* round 5 */
+       SUBL(6) ^= kw4l; SUBR(6) ^= kw4r;
+       /* round 3 */
+       SUBL(4) ^= kw4l; SUBR(4) ^= kw4r;
+       /* round 1 */
+       SUBL(2) ^= kw4l; SUBR(2) ^= kw4r;
+       /* kw1 */
+       SUBL(0) ^= kw4l; SUBR(0) ^= kw4r;
+
+
+       /* key XOR is end of F-function */
+       CAMELLIA_SUBKEY_L(0) = SUBL(0) ^ SUBL(2);/* kw1 */
+       CAMELLIA_SUBKEY_R(0) = SUBR(0) ^ SUBR(2);
+       CAMELLIA_SUBKEY_L(2) = SUBL(3);       /* round 1 */
+       CAMELLIA_SUBKEY_R(2) = SUBR(3);
+       CAMELLIA_SUBKEY_L(3) = SUBL(2) ^ SUBL(4); /* round 2 */
+       CAMELLIA_SUBKEY_R(3) = SUBR(2) ^ SUBR(4);
+       CAMELLIA_SUBKEY_L(4) = SUBL(3) ^ SUBL(5); /* round 3 */
+       CAMELLIA_SUBKEY_R(4) = SUBR(3) ^ SUBR(5);
+       CAMELLIA_SUBKEY_L(5) = SUBL(4) ^ SUBL(6); /* round 4 */
+       CAMELLIA_SUBKEY_R(5) = SUBR(4) ^ SUBR(6);
+       CAMELLIA_SUBKEY_L(6) = SUBL(5) ^ SUBL(7); /* round 5 */
+       CAMELLIA_SUBKEY_R(6) = SUBR(5) ^ SUBR(7);
+       tl = SUBL(10) ^ (SUBR(10) & ~SUBR(8));
+       dw = tl & SUBL(8),  /* FL(kl1) */
+               tr = SUBR(10) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(7) = SUBL(6) ^ tl; /* round 6 */
+       CAMELLIA_SUBKEY_R(7) = SUBR(6) ^ tr;
+       CAMELLIA_SUBKEY_L(8) = SUBL(8);       /* FL(kl1) */
+       CAMELLIA_SUBKEY_R(8) = SUBR(8);
+       CAMELLIA_SUBKEY_L(9) = SUBL(9);       /* FLinv(kl2) */
+       CAMELLIA_SUBKEY_R(9) = SUBR(9);
+       tl = SUBL(7) ^ (SUBR(7) & ~SUBR(9));
+       dw = tl & SUBL(9),  /* FLinv(kl2) */
+               tr = SUBR(7) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(10) = tl ^ SUBL(11); /* round 7 */
+       CAMELLIA_SUBKEY_R(10) = tr ^ SUBR(11);
+       CAMELLIA_SUBKEY_L(11) = SUBL(10) ^ SUBL(12); /* round 8 */
+       CAMELLIA_SUBKEY_R(11) = SUBR(10) ^ SUBR(12);
+       CAMELLIA_SUBKEY_L(12) = SUBL(11) ^ SUBL(13); /* round 9 */
+       CAMELLIA_SUBKEY_R(12) = SUBR(11) ^ SUBR(13);
+       CAMELLIA_SUBKEY_L(13) = SUBL(12) ^ SUBL(14); /* round 10 */
+       CAMELLIA_SUBKEY_R(13) = SUBR(12) ^ SUBR(14);
+       CAMELLIA_SUBKEY_L(14) = SUBL(13) ^ SUBL(15); /* round 11 */
+       CAMELLIA_SUBKEY_R(14) = SUBR(13) ^ SUBR(15);
+       tl = SUBL(18) ^ (SUBR(18) & ~SUBR(16));
+       dw = tl & SUBL(16), /* FL(kl3) */
+               tr = SUBR(18) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(15) = SUBL(14) ^ tl; /* round 12 */
+       CAMELLIA_SUBKEY_R(15) = SUBR(14) ^ tr;
+       CAMELLIA_SUBKEY_L(16) = SUBL(16);     /* FL(kl3) */
+       CAMELLIA_SUBKEY_R(16) = SUBR(16);
+       CAMELLIA_SUBKEY_L(17) = SUBL(17);     /* FLinv(kl4) */
+       CAMELLIA_SUBKEY_R(17) = SUBR(17);
+       tl = SUBL(15) ^ (SUBR(15) & ~SUBR(17));
+       dw = tl & SUBL(17), /* FLinv(kl4) */
+               tr = SUBR(15) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(18) = tl ^ SUBL(19); /* round 13 */
+       CAMELLIA_SUBKEY_R(18) = tr ^ SUBR(19);
+       CAMELLIA_SUBKEY_L(19) = SUBL(18) ^ SUBL(20); /* round 14 */
+       CAMELLIA_SUBKEY_R(19) = SUBR(18) ^ SUBR(20);
+       CAMELLIA_SUBKEY_L(20) = SUBL(19) ^ SUBL(21); /* round 15 */
+       CAMELLIA_SUBKEY_R(20) = SUBR(19) ^ SUBR(21);
+       CAMELLIA_SUBKEY_L(21) = SUBL(20) ^ SUBL(22); /* round 16 */
+       CAMELLIA_SUBKEY_R(21) = SUBR(20) ^ SUBR(22);
+       CAMELLIA_SUBKEY_L(22) = SUBL(21) ^ SUBL(23); /* round 17 */
+       CAMELLIA_SUBKEY_R(22) = SUBR(21) ^ SUBR(23);
+       CAMELLIA_SUBKEY_L(23) = SUBL(22);     /* round 18 */
+       CAMELLIA_SUBKEY_R(23) = SUBR(22);
+       CAMELLIA_SUBKEY_L(24) = SUBL(24) ^ SUBL(23); /* kw3 */
+       CAMELLIA_SUBKEY_R(24) = SUBR(24) ^ SUBR(23);
+
+       /* apply the inverse of the last half of P-function */
+       dw = CAMELLIA_SUBKEY_L(2) ^ CAMELLIA_SUBKEY_R(2),
+               dw = CAMELLIA_RL8(dw);/* round 1 */
+       CAMELLIA_SUBKEY_R(2) = CAMELLIA_SUBKEY_L(2) ^ dw,
+               CAMELLIA_SUBKEY_L(2) = dw;
+       dw = CAMELLIA_SUBKEY_L(3) ^ CAMELLIA_SUBKEY_R(3),
+               dw = CAMELLIA_RL8(dw);/* round 2 */
+       CAMELLIA_SUBKEY_R(3) = CAMELLIA_SUBKEY_L(3) ^ dw,
+               CAMELLIA_SUBKEY_L(3) = dw;
+       dw = CAMELLIA_SUBKEY_L(4) ^ CAMELLIA_SUBKEY_R(4),
+               dw = CAMELLIA_RL8(dw);/* round 3 */
+       CAMELLIA_SUBKEY_R(4) = CAMELLIA_SUBKEY_L(4) ^ dw,
+               CAMELLIA_SUBKEY_L(4) = dw;
+       dw = CAMELLIA_SUBKEY_L(5) ^ CAMELLIA_SUBKEY_R(5),
+               dw = CAMELLIA_RL8(dw);/* round 4 */
+       CAMELLIA_SUBKEY_R(5) = CAMELLIA_SUBKEY_L(5) ^ dw,
+               CAMELLIA_SUBKEY_L(5) = dw;
+       dw = CAMELLIA_SUBKEY_L(6) ^ CAMELLIA_SUBKEY_R(6),
+               dw = CAMELLIA_RL8(dw);/* round 5 */
+       CAMELLIA_SUBKEY_R(6) = CAMELLIA_SUBKEY_L(6) ^ dw,
+               CAMELLIA_SUBKEY_L(6) = dw;
+       dw = CAMELLIA_SUBKEY_L(7) ^ CAMELLIA_SUBKEY_R(7),
+               dw = CAMELLIA_RL8(dw);/* round 6 */
+       CAMELLIA_SUBKEY_R(7) = CAMELLIA_SUBKEY_L(7) ^ dw,
+               CAMELLIA_SUBKEY_L(7) = dw;
+       dw = CAMELLIA_SUBKEY_L(10) ^ CAMELLIA_SUBKEY_R(10),
+               dw = CAMELLIA_RL8(dw);/* round 7 */
+       CAMELLIA_SUBKEY_R(10) = CAMELLIA_SUBKEY_L(10) ^ dw,
+               CAMELLIA_SUBKEY_L(10) = dw;
+       dw = CAMELLIA_SUBKEY_L(11) ^ CAMELLIA_SUBKEY_R(11),
+               dw = CAMELLIA_RL8(dw);/* round 8 */
+       CAMELLIA_SUBKEY_R(11) = CAMELLIA_SUBKEY_L(11) ^ dw,
+               CAMELLIA_SUBKEY_L(11) = dw;
+       dw = CAMELLIA_SUBKEY_L(12) ^ CAMELLIA_SUBKEY_R(12),
+               dw = CAMELLIA_RL8(dw);/* round 9 */
+       CAMELLIA_SUBKEY_R(12) = CAMELLIA_SUBKEY_L(12) ^ dw,
+               CAMELLIA_SUBKEY_L(12) = dw;
+       dw = CAMELLIA_SUBKEY_L(13) ^ CAMELLIA_SUBKEY_R(13),
+               dw = CAMELLIA_RL8(dw);/* round 10 */
+       CAMELLIA_SUBKEY_R(13) = CAMELLIA_SUBKEY_L(13) ^ dw,
+               CAMELLIA_SUBKEY_L(13) = dw;
+       dw = CAMELLIA_SUBKEY_L(14) ^ CAMELLIA_SUBKEY_R(14),
+               dw = CAMELLIA_RL8(dw);/* round 11 */
+       CAMELLIA_SUBKEY_R(14) = CAMELLIA_SUBKEY_L(14) ^ dw,
+               CAMELLIA_SUBKEY_L(14) = dw;
+       dw = CAMELLIA_SUBKEY_L(15) ^ CAMELLIA_SUBKEY_R(15),
+               dw = CAMELLIA_RL8(dw);/* round 12 */
+       CAMELLIA_SUBKEY_R(15) = CAMELLIA_SUBKEY_L(15) ^ dw,
+               CAMELLIA_SUBKEY_L(15) = dw;
+       dw = CAMELLIA_SUBKEY_L(18) ^ CAMELLIA_SUBKEY_R(18),
+               dw = CAMELLIA_RL8(dw);/* round 13 */
+       CAMELLIA_SUBKEY_R(18) = CAMELLIA_SUBKEY_L(18) ^ dw,
+               CAMELLIA_SUBKEY_L(18) = dw;
+       dw = CAMELLIA_SUBKEY_L(19) ^ CAMELLIA_SUBKEY_R(19),
+               dw = CAMELLIA_RL8(dw);/* round 14 */
+       CAMELLIA_SUBKEY_R(19) = CAMELLIA_SUBKEY_L(19) ^ dw,
+               CAMELLIA_SUBKEY_L(19) = dw;
+       dw = CAMELLIA_SUBKEY_L(20) ^ CAMELLIA_SUBKEY_R(20),
+               dw = CAMELLIA_RL8(dw);/* round 15 */
+       CAMELLIA_SUBKEY_R(20) = CAMELLIA_SUBKEY_L(20) ^ dw,
+               CAMELLIA_SUBKEY_L(20) = dw;
+       dw = CAMELLIA_SUBKEY_L(21) ^ CAMELLIA_SUBKEY_R(21),
+               dw = CAMELLIA_RL8(dw);/* round 16 */
+       CAMELLIA_SUBKEY_R(21) = CAMELLIA_SUBKEY_L(21) ^ dw,
+               CAMELLIA_SUBKEY_L(21) = dw;
+       dw = CAMELLIA_SUBKEY_L(22) ^ CAMELLIA_SUBKEY_R(22),
+               dw = CAMELLIA_RL8(dw);/* round 17 */
+       CAMELLIA_SUBKEY_R(22) = CAMELLIA_SUBKEY_L(22) ^ dw,
+               CAMELLIA_SUBKEY_L(22) = dw;
+       dw = CAMELLIA_SUBKEY_L(23) ^ CAMELLIA_SUBKEY_R(23),
+               dw = CAMELLIA_RL8(dw);/* round 18 */
+       CAMELLIA_SUBKEY_R(23) = CAMELLIA_SUBKEY_L(23) ^ dw,
+               CAMELLIA_SUBKEY_L(23) = dw;
+
+       return;
+}
+
+
+static void camellia_setup256(const unsigned char *key, u32 *subkey)
+{
+       u32 kll,klr,krl,krr;           /* left half of key */
+       u32 krll,krlr,krrl,krrr;       /* right half of key */
+       u32 il, ir, t0, t1, w0, w1;    /* temporary variables */
+       u32 kw4l, kw4r, dw, tl, tr;
+       u32 subL[34];
+       u32 subR[34];
+
+       /**
+        *  key = (kll || klr || krl || krr || krll || krlr || krrl || krrr)
+        *  (|| is concatination)
+        */
+
+       kll  = GETU32(key     );
+       klr  = GETU32(key +  4);
+       krl  = GETU32(key +  8);
+       krr  = GETU32(key + 12);
+       krll = GETU32(key + 16);
+       krlr = GETU32(key + 20);
+       krrl = GETU32(key + 24);
+       krrr = GETU32(key + 28);
+
+       /* generate KL dependent subkeys */
+       /* kw1 */
+       SUBL(0) = kll; SUBR(0) = klr;
+       /* kw2 */
+       SUBL(1) = krl; SUBR(1) = krr;
+       CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 45);
+       /* k9 */
+       SUBL(12) = kll; SUBR(12) = klr;
+       /* k10 */
+       SUBL(13) = krl; SUBR(13) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* kl3 */
+       SUBL(16) = kll; SUBR(16) = klr;
+       /* kl4 */
+       SUBL(17) = krl; SUBR(17) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 17);
+       /* k17 */
+       SUBL(22) = kll; SUBR(22) = klr;
+       /* k18 */
+       SUBL(23) = krl; SUBR(23) = krr;
+       CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 34);
+       /* k23 */
+       SUBL(30) = kll; SUBR(30) = klr;
+       /* k24 */
+       SUBL(31) = krl; SUBR(31) = krr;
+
+       /* generate KR dependent subkeys */
+       CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 15);
+       /* k3 */
+       SUBL(4) = krll; SUBR(4) = krlr;
+       /* k4 */
+       SUBL(5) = krrl; SUBR(5) = krrr;
+       CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 15);
+       /* kl1 */
+       SUBL(8) = krll; SUBR(8) = krlr;
+       /* kl2 */
+       SUBL(9) = krrl; SUBR(9) = krrr;
+       CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
+       /* k13 */
+       SUBL(18) = krll; SUBR(18) = krlr;
+       /* k14 */
+       SUBL(19) = krrl; SUBR(19) = krrr;
+       CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 34);
+       /* k19 */
+       SUBL(26) = krll; SUBR(26) = krlr;
+       /* k20 */
+       SUBL(27) = krrl; SUBR(27) = krrr;
+       CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 34);
+
+       /* generate KA */
+       kll = SUBL(0) ^ krll; klr = SUBR(0) ^ krlr;
+       krl = SUBL(1) ^ krrl; krr = SUBR(1) ^ krrr;
+       CAMELLIA_F(kll, klr,
+                  CAMELLIA_SIGMA1L, CAMELLIA_SIGMA1R,
+                  w0, w1, il, ir, t0, t1);
+       krl ^= w0; krr ^= w1;
+       CAMELLIA_F(krl, krr,
+                  CAMELLIA_SIGMA2L, CAMELLIA_SIGMA2R,
+                  kll, klr, il, ir, t0, t1);
+       kll ^= krll; klr ^= krlr;
+       CAMELLIA_F(kll, klr,
+                  CAMELLIA_SIGMA3L, CAMELLIA_SIGMA3R,
+                  krl, krr, il, ir, t0, t1);
+       krl ^= w0 ^ krrl; krr ^= w1 ^ krrr;
+       CAMELLIA_F(krl, krr,
+                  CAMELLIA_SIGMA4L, CAMELLIA_SIGMA4R,
+                  w0, w1, il, ir, t0, t1);
+       kll ^= w0; klr ^= w1;
+
+       /* generate KB */
+       krll ^= kll; krlr ^= klr;
+       krrl ^= krl; krrr ^= krr;
+       CAMELLIA_F(krll, krlr,
+                  CAMELLIA_SIGMA5L, CAMELLIA_SIGMA5R,
+                  w0, w1, il, ir, t0, t1);
+       krrl ^= w0; krrr ^= w1;
+       CAMELLIA_F(krrl, krrr,
+                  CAMELLIA_SIGMA6L, CAMELLIA_SIGMA6R,
+                  w0, w1, il, ir, t0, t1);
+       krll ^= w0; krlr ^= w1;
+
+       /* generate KA dependent subkeys */
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 15);
+       /* k5 */
+       SUBL(6) = kll; SUBR(6) = klr;
+       /* k6 */
+       SUBL(7) = krl; SUBR(7) = krr;
+       CAMELLIA_ROLDQ(kll, klr, krl, krr, w0, w1, 30);
+       /* k11 */
+       SUBL(14) = kll; SUBR(14) = klr;
+       /* k12 */
+       SUBL(15) = krl; SUBR(15) = krr;
+       /* rotation left shift 32bit */
+       /* kl5 */
+       SUBL(24) = klr; SUBR(24) = krl;
+       /* kl6 */
+       SUBL(25) = krr; SUBR(25) = kll;
+       /* rotation left shift 49 from k11,k12 -> k21,k22 */
+       CAMELLIA_ROLDQo32(kll, klr, krl, krr, w0, w1, 49);
+       /* k21 */
+       SUBL(28) = kll; SUBR(28) = klr;
+       /* k22 */
+       SUBL(29) = krl; SUBR(29) = krr;
+
+       /* generate KB dependent subkeys */
+       /* k1 */
+       SUBL(2) = krll; SUBR(2) = krlr;
+       /* k2 */
+       SUBL(3) = krrl; SUBR(3) = krrr;
+       CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
+       /* k7 */
+       SUBL(10) = krll; SUBR(10) = krlr;
+       /* k8 */
+       SUBL(11) = krrl; SUBR(11) = krrr;
+       CAMELLIA_ROLDQ(krll, krlr, krrl, krrr, w0, w1, 30);
+       /* k15 */
+       SUBL(20) = krll; SUBR(20) = krlr;
+       /* k16 */
+       SUBL(21) = krrl; SUBR(21) = krrr;
+       CAMELLIA_ROLDQo32(krll, krlr, krrl, krrr, w0, w1, 51);
+       /* kw3 */
+       SUBL(32) = krll; SUBR(32) = krlr;
+       /* kw4 */
+       SUBL(33) = krrl; SUBR(33) = krrr;
+
+       /* absorb kw2 to other subkeys */
+       /* round 2 */
+       SUBL(3) ^= SUBL(1); SUBR(3) ^= SUBR(1);
+       /* round 4 */
+       SUBL(5) ^= SUBL(1); SUBR(5) ^= SUBR(1);
+       /* round 6 */
+       SUBL(7) ^= SUBL(1); SUBR(7) ^= SUBR(1);
+       SUBL(1) ^= SUBR(1) & ~SUBR(9);
+       dw = SUBL(1) & SUBL(9),
+               SUBR(1) ^= CAMELLIA_RL1(dw); /* modified for FLinv(kl2) */
+       /* round 8 */
+       SUBL(11) ^= SUBL(1); SUBR(11) ^= SUBR(1);
+       /* round 10 */
+       SUBL(13) ^= SUBL(1); SUBR(13) ^= SUBR(1);
+       /* round 12 */
+       SUBL(15) ^= SUBL(1); SUBR(15) ^= SUBR(1);
+       SUBL(1) ^= SUBR(1) & ~SUBR(17);
+       dw = SUBL(1) & SUBL(17),
+               SUBR(1) ^= CAMELLIA_RL1(dw); /* modified for FLinv(kl4) */
+       /* round 14 */
+       SUBL(19) ^= SUBL(1); SUBR(19) ^= SUBR(1);
+       /* round 16 */
+       SUBL(21) ^= SUBL(1); SUBR(21) ^= SUBR(1);
+       /* round 18 */
+       SUBL(23) ^= SUBL(1); SUBR(23) ^= SUBR(1);
+       SUBL(1) ^= SUBR(1) & ~SUBR(25);
+       dw = SUBL(1) & SUBL(25),
+               SUBR(1) ^= CAMELLIA_RL1(dw); /* modified for FLinv(kl6) */
+       /* round 20 */
+       SUBL(27) ^= SUBL(1); SUBR(27) ^= SUBR(1);
+       /* round 22 */
+       SUBL(29) ^= SUBL(1); SUBR(29) ^= SUBR(1);
+       /* round 24 */
+       SUBL(31) ^= SUBL(1); SUBR(31) ^= SUBR(1);
+       /* kw3 */
+       SUBL(32) ^= SUBL(1); SUBR(32) ^= SUBR(1);
+
+
+       /* absorb kw4 to other subkeys */
+       kw4l = SUBL(33); kw4r = SUBR(33);
+       /* round 23 */
+       SUBL(30) ^= kw4l; SUBR(30) ^= kw4r;
+       /* round 21 */
+       SUBL(28) ^= kw4l; SUBR(28) ^= kw4r;
+       /* round 19 */
+       SUBL(26) ^= kw4l; SUBR(26) ^= kw4r;
+       kw4l ^= kw4r & ~SUBR(24);
+       dw = kw4l & SUBL(24),
+               kw4r ^= CAMELLIA_RL1(dw); /* modified for FL(kl5) */
+       /* round 17 */
+       SUBL(22) ^= kw4l; SUBR(22) ^= kw4r;
+       /* round 15 */
+       SUBL(20) ^= kw4l; SUBR(20) ^= kw4r;
+       /* round 13 */
+       SUBL(18) ^= kw4l; SUBR(18) ^= kw4r;
+       kw4l ^= kw4r & ~SUBR(16);
+       dw = kw4l & SUBL(16),
+               kw4r ^= CAMELLIA_RL1(dw); /* modified for FL(kl3) */
+       /* round 11 */
+       SUBL(14) ^= kw4l; SUBR(14) ^= kw4r;
+       /* round 9 */
+       SUBL(12) ^= kw4l; SUBR(12) ^= kw4r;
+       /* round 7 */
+       SUBL(10) ^= kw4l; SUBR(10) ^= kw4r;
+       kw4l ^= kw4r & ~SUBR(8);
+       dw = kw4l & SUBL(8),
+               kw4r ^= CAMELLIA_RL1(dw); /* modified for FL(kl1) */
+       /* round 5 */
+       SUBL(6) ^= kw4l; SUBR(6) ^= kw4r;
+       /* round 3 */
+       SUBL(4) ^= kw4l; SUBR(4) ^= kw4r;
+       /* round 1 */
+       SUBL(2) ^= kw4l; SUBR(2) ^= kw4r;
+       /* kw1 */
+       SUBL(0) ^= kw4l; SUBR(0) ^= kw4r;
+
+       /* key XOR is end of F-function */
+       CAMELLIA_SUBKEY_L(0) = SUBL(0) ^ SUBL(2);/* kw1 */
+       CAMELLIA_SUBKEY_R(0) = SUBR(0) ^ SUBR(2);
+       CAMELLIA_SUBKEY_L(2) = SUBL(3);       /* round 1 */
+       CAMELLIA_SUBKEY_R(2) = SUBR(3);
+       CAMELLIA_SUBKEY_L(3) = SUBL(2) ^ SUBL(4); /* round 2 */
+       CAMELLIA_SUBKEY_R(3) = SUBR(2) ^ SUBR(4);
+       CAMELLIA_SUBKEY_L(4) = SUBL(3) ^ SUBL(5); /* round 3 */
+       CAMELLIA_SUBKEY_R(4) = SUBR(3) ^ SUBR(5);
+       CAMELLIA_SUBKEY_L(5) = SUBL(4) ^ SUBL(6); /* round 4 */
+       CAMELLIA_SUBKEY_R(5) = SUBR(4) ^ SUBR(6);
+       CAMELLIA_SUBKEY_L(6) = SUBL(5) ^ SUBL(7); /* round 5 */
+       CAMELLIA_SUBKEY_R(6) = SUBR(5) ^ SUBR(7);
+       tl = SUBL(10) ^ (SUBR(10) & ~SUBR(8));
+       dw = tl & SUBL(8),  /* FL(kl1) */
+               tr = SUBR(10) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(7) = SUBL(6) ^ tl; /* round 6 */
+       CAMELLIA_SUBKEY_R(7) = SUBR(6) ^ tr;
+       CAMELLIA_SUBKEY_L(8) = SUBL(8);       /* FL(kl1) */
+       CAMELLIA_SUBKEY_R(8) = SUBR(8);
+       CAMELLIA_SUBKEY_L(9) = SUBL(9);       /* FLinv(kl2) */
+       CAMELLIA_SUBKEY_R(9) = SUBR(9);
+       tl = SUBL(7) ^ (SUBR(7) & ~SUBR(9));
+       dw = tl & SUBL(9),  /* FLinv(kl2) */
+               tr = SUBR(7) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(10) = tl ^ SUBL(11); /* round 7 */
+       CAMELLIA_SUBKEY_R(10) = tr ^ SUBR(11);
+       CAMELLIA_SUBKEY_L(11) = SUBL(10) ^ SUBL(12); /* round 8 */
+       CAMELLIA_SUBKEY_R(11) = SUBR(10) ^ SUBR(12);
+       CAMELLIA_SUBKEY_L(12) = SUBL(11) ^ SUBL(13); /* round 9 */
+       CAMELLIA_SUBKEY_R(12) = SUBR(11) ^ SUBR(13);
+       CAMELLIA_SUBKEY_L(13) = SUBL(12) ^ SUBL(14); /* round 10 */
+       CAMELLIA_SUBKEY_R(13) = SUBR(12) ^ SUBR(14);
+       CAMELLIA_SUBKEY_L(14) = SUBL(13) ^ SUBL(15); /* round 11 */
+       CAMELLIA_SUBKEY_R(14) = SUBR(13) ^ SUBR(15);
+       tl = SUBL(18) ^ (SUBR(18) & ~SUBR(16));
+       dw = tl & SUBL(16), /* FL(kl3) */
+               tr = SUBR(18) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(15) = SUBL(14) ^ tl; /* round 12 */
+       CAMELLIA_SUBKEY_R(15) = SUBR(14) ^ tr;
+       CAMELLIA_SUBKEY_L(16) = SUBL(16);     /* FL(kl3) */
+       CAMELLIA_SUBKEY_R(16) = SUBR(16);
+       CAMELLIA_SUBKEY_L(17) = SUBL(17);     /* FLinv(kl4) */
+       CAMELLIA_SUBKEY_R(17) = SUBR(17);
+       tl = SUBL(15) ^ (SUBR(15) & ~SUBR(17));
+       dw = tl & SUBL(17), /* FLinv(kl4) */
+               tr = SUBR(15) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(18) = tl ^ SUBL(19); /* round 13 */
+       CAMELLIA_SUBKEY_R(18) = tr ^ SUBR(19);
+       CAMELLIA_SUBKEY_L(19) = SUBL(18) ^ SUBL(20); /* round 14 */
+       CAMELLIA_SUBKEY_R(19) = SUBR(18) ^ SUBR(20);
+       CAMELLIA_SUBKEY_L(20) = SUBL(19) ^ SUBL(21); /* round 15 */
+       CAMELLIA_SUBKEY_R(20) = SUBR(19) ^ SUBR(21);
+       CAMELLIA_SUBKEY_L(21) = SUBL(20) ^ SUBL(22); /* round 16 */
+       CAMELLIA_SUBKEY_R(21) = SUBR(20) ^ SUBR(22);
+       CAMELLIA_SUBKEY_L(22) = SUBL(21) ^ SUBL(23); /* round 17 */
+       CAMELLIA_SUBKEY_R(22) = SUBR(21) ^ SUBR(23);
+       tl = SUBL(26) ^ (SUBR(26)
+                        & ~SUBR(24));
+       dw = tl & SUBL(24), /* FL(kl5) */
+               tr = SUBR(26) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(23) = SUBL(22) ^ tl; /* round 18 */
+       CAMELLIA_SUBKEY_R(23) = SUBR(22) ^ tr;
+       CAMELLIA_SUBKEY_L(24) = SUBL(24);     /* FL(kl5) */
+       CAMELLIA_SUBKEY_R(24) = SUBR(24);
+       CAMELLIA_SUBKEY_L(25) = SUBL(25);     /* FLinv(kl6) */
+       CAMELLIA_SUBKEY_R(25) = SUBR(25);
+       tl = SUBL(23) ^ (SUBR(23) &
+                        ~SUBR(25));
+       dw = tl & SUBL(25), /* FLinv(kl6) */
+               tr = SUBR(23) ^ CAMELLIA_RL1(dw);
+       CAMELLIA_SUBKEY_L(26) = tl ^ SUBL(27); /* round 19 */
+       CAMELLIA_SUBKEY_R(26) = tr ^ SUBR(27);
+       CAMELLIA_SUBKEY_L(27) = SUBL(26) ^ SUBL(28); /* round 20 */
+       CAMELLIA_SUBKEY_R(27) = SUBR(26) ^ SUBR(28);
+       CAMELLIA_SUBKEY_L(28) = SUBL(27) ^ SUBL(29); /* round 21 */
+       CAMELLIA_SUBKEY_R(28) = SUBR(27) ^ SUBR(29);
+       CAMELLIA_SUBKEY_L(29) = SUBL(28) ^ SUBL(30); /* round 22 */
+       CAMELLIA_SUBKEY_R(29) = SUBR(28) ^ SUBR(30);
+       CAMELLIA_SUBKEY_L(30) = SUBL(29) ^ SUBL(31); /* round 23 */
+       CAMELLIA_SUBKEY_R(30) = SUBR(29) ^ SUBR(31);
+       CAMELLIA_SUBKEY_L(31) = SUBL(30);     /* round 24 */
+       CAMELLIA_SUBKEY_R(31) = SUBR(30);
+       CAMELLIA_SUBKEY_L(32) = SUBL(32) ^ SUBL(31); /* kw3 */
+       CAMELLIA_SUBKEY_R(32) = SUBR(32) ^ SUBR(31);
+
+       /* apply the inverse of the last half of P-function */
+       dw = CAMELLIA_SUBKEY_L(2) ^ CAMELLIA_SUBKEY_R(2),
+               dw = CAMELLIA_RL8(dw);/* round 1 */
+       CAMELLIA_SUBKEY_R(2) = CAMELLIA_SUBKEY_L(2) ^ dw,
+               CAMELLIA_SUBKEY_L(2) = dw;
+       dw = CAMELLIA_SUBKEY_L(3) ^ CAMELLIA_SUBKEY_R(3),
+               dw = CAMELLIA_RL8(dw);/* round 2 */
+       CAMELLIA_SUBKEY_R(3) = CAMELLIA_SUBKEY_L(3) ^ dw,
+               CAMELLIA_SUBKEY_L(3) = dw;
+       dw = CAMELLIA_SUBKEY_L(4) ^ CAMELLIA_SUBKEY_R(4),
+               dw = CAMELLIA_RL8(dw);/* round 3 */
+       CAMELLIA_SUBKEY_R(4) = CAMELLIA_SUBKEY_L(4) ^ dw,
+               CAMELLIA_SUBKEY_L(4) = dw;
+       dw = CAMELLIA_SUBKEY_L(5) ^ CAMELLIA_SUBKEY_R(5),
+               dw = CAMELLIA_RL8(dw);/* round 4 */
+       CAMELLIA_SUBKEY_R(5) = CAMELLIA_SUBKEY_L(5) ^ dw,
+       CAMELLIA_SUBKEY_L(5) = dw;
+       dw = CAMELLIA_SUBKEY_L(6) ^ CAMELLIA_SUBKEY_R(6),
+               dw = CAMELLIA_RL8(dw);/* round 5 */
+       CAMELLIA_SUBKEY_R(6) = CAMELLIA_SUBKEY_L(6) ^ dw,
+               CAMELLIA_SUBKEY_L(6) = dw;
+       dw = CAMELLIA_SUBKEY_L(7) ^ CAMELLIA_SUBKEY_R(7),
+               dw = CAMELLIA_RL8(dw);/* round 6 */
+       CAMELLIA_SUBKEY_R(7) = CAMELLIA_SUBKEY_L(7) ^ dw,
+               CAMELLIA_SUBKEY_L(7) = dw;
+       dw = CAMELLIA_SUBKEY_L(10) ^ CAMELLIA_SUBKEY_R(10),
+               dw = CAMELLIA_RL8(dw);/* round 7 */
+       CAMELLIA_SUBKEY_R(10) = CAMELLIA_SUBKEY_L(10) ^ dw,
+               CAMELLIA_SUBKEY_L(10) = dw;
+       dw = CAMELLIA_SUBKEY_L(11) ^ CAMELLIA_SUBKEY_R(11),
+           dw = CAMELLIA_RL8(dw);/* round 8 */
+       CAMELLIA_SUBKEY_R(11) = CAMELLIA_SUBKEY_L(11) ^ dw,
+               CAMELLIA_SUBKEY_L(11) = dw;
+       dw = CAMELLIA_SUBKEY_L(12) ^ CAMELLIA_SUBKEY_R(12),
+               dw = CAMELLIA_RL8(dw);/* round 9 */
+       CAMELLIA_SUBKEY_R(12) = CAMELLIA_SUBKEY_L(12) ^ dw,
+               CAMELLIA_SUBKEY_L(12) = dw;
+       dw = CAMELLIA_SUBKEY_L(13) ^ CAMELLIA_SUBKEY_R(13),
+               dw = CAMELLIA_RL8(dw);/* round 10 */
+       CAMELLIA_SUBKEY_R(13) = CAMELLIA_SUBKEY_L(13) ^ dw,
+               CAMELLIA_SUBKEY_L(13) = dw;
+       dw = CAMELLIA_SUBKEY_L(14) ^ CAMELLIA_SUBKEY_R(14),
+               dw = CAMELLIA_RL8(dw);/* round 11 */
+       CAMELLIA_SUBKEY_R(14) = CAMELLIA_SUBKEY_L(14) ^ dw,
+               CAMELLIA_SUBKEY_L(14) = dw;
+       dw = CAMELLIA_SUBKEY_L(15) ^ CAMELLIA_SUBKEY_R(15),
+               dw = CAMELLIA_RL8(dw);/* round 12 */
+       CAMELLIA_SUBKEY_R(15) = CAMELLIA_SUBKEY_L(15) ^ dw,
+               CAMELLIA_SUBKEY_L(15) = dw;
+       dw = CAMELLIA_SUBKEY_L(18) ^ CAMELLIA_SUBKEY_R(18),
+               dw = CAMELLIA_RL8(dw);/* round 13 */
+       CAMELLIA_SUBKEY_R(18) = CAMELLIA_SUBKEY_L(18) ^ dw,
+               CAMELLIA_SUBKEY_L(18) = dw;
+       dw = CAMELLIA_SUBKEY_L(19) ^ CAMELLIA_SUBKEY_R(19),
+               dw = CAMELLIA_RL8(dw);/* round 14 */
+       CAMELLIA_SUBKEY_R(19) = CAMELLIA_SUBKEY_L(19) ^ dw,
+               CAMELLIA_SUBKEY_L(19) = dw;
+       dw = CAMELLIA_SUBKEY_L(20) ^ CAMELLIA_SUBKEY_R(20),
+               dw = CAMELLIA_RL8(dw);/* round 15 */
+       CAMELLIA_SUBKEY_R(20) = CAMELLIA_SUBKEY_L(20) ^ dw,
+               CAMELLIA_SUBKEY_L(20) = dw;
+       dw = CAMELLIA_SUBKEY_L(21) ^ CAMELLIA_SUBKEY_R(21),
+               dw = CAMELLIA_RL8(dw);/* round 16 */
+       CAMELLIA_SUBKEY_R(21) = CAMELLIA_SUBKEY_L(21) ^ dw,
+               CAMELLIA_SUBKEY_L(21) = dw;
+       dw = CAMELLIA_SUBKEY_L(22) ^ CAMELLIA_SUBKEY_R(22),
+               dw = CAMELLIA_RL8(dw);/* round 17 */
+       CAMELLIA_SUBKEY_R(22) = CAMELLIA_SUBKEY_L(22) ^ dw,
+               CAMELLIA_SUBKEY_L(22) = dw;
+       dw = CAMELLIA_SUBKEY_L(23) ^ CAMELLIA_SUBKEY_R(23),
+               dw = CAMELLIA_RL8(dw);/* round 18 */
+       CAMELLIA_SUBKEY_R(23) = CAMELLIA_SUBKEY_L(23) ^ dw,
+               CAMELLIA_SUBKEY_L(23) = dw;
+       dw = CAMELLIA_SUBKEY_L(26) ^ CAMELLIA_SUBKEY_R(26),
+               dw = CAMELLIA_RL8(dw);/* round 19 */
+       CAMELLIA_SUBKEY_R(26) = CAMELLIA_SUBKEY_L(26) ^ dw,
+               CAMELLIA_SUBKEY_L(26) = dw;
+       dw = CAMELLIA_SUBKEY_L(27) ^ CAMELLIA_SUBKEY_R(27),
+               dw = CAMELLIA_RL8(dw);/* round 20 */
+       CAMELLIA_SUBKEY_R(27) = CAMELLIA_SUBKEY_L(27) ^ dw,
+               CAMELLIA_SUBKEY_L(27) = dw;
+       dw = CAMELLIA_SUBKEY_L(28) ^ CAMELLIA_SUBKEY_R(28),
+               dw = CAMELLIA_RL8(dw);/* round 21 */
+       CAMELLIA_SUBKEY_R(28) = CAMELLIA_SUBKEY_L(28) ^ dw,
+               CAMELLIA_SUBKEY_L(28) = dw;
+       dw = CAMELLIA_SUBKEY_L(29) ^ CAMELLIA_SUBKEY_R(29),
+               dw = CAMELLIA_RL8(dw);/* round 22 */
+       CAMELLIA_SUBKEY_R(29) = CAMELLIA_SUBKEY_L(29) ^ dw,
+               CAMELLIA_SUBKEY_L(29) = dw;
+       dw = CAMELLIA_SUBKEY_L(30) ^ CAMELLIA_SUBKEY_R(30),
+               dw = CAMELLIA_RL8(dw);/* round 23 */
+       CAMELLIA_SUBKEY_R(30) = CAMELLIA_SUBKEY_L(30) ^ dw,
+               CAMELLIA_SUBKEY_L(30) = dw;
+       dw = CAMELLIA_SUBKEY_L(31) ^ CAMELLIA_SUBKEY_R(31),
+               dw = CAMELLIA_RL8(dw);/* round 24 */
+       CAMELLIA_SUBKEY_R(31) = CAMELLIA_SUBKEY_L(31) ^ dw,
+               CAMELLIA_SUBKEY_L(31) = dw;
+
+       return;
+}
+
+static void camellia_setup192(const unsigned char *key, u32 *subkey)
+{
+       unsigned char kk[32];
+       u32 krll, krlr, krrl,krrr;
+
+       memcpy(kk, key, 24);
+       memcpy((unsigned char *)&krll, key+16,4);
+       memcpy((unsigned char *)&krlr, key+20,4);
+       krrl = ~krll;
+       krrr = ~krlr;
+       memcpy(kk+24, (unsigned char *)&krrl, 4);
+       memcpy(kk+28, (unsigned char *)&krrr, 4);
+       camellia_setup256(kk, subkey);
+       return;
+}
+
+
+/**
+ * Stuff related to camellia encryption/decryption
+ */
+static void camellia_encrypt128(const u32 *subkey, __be32 *io_text)
+{
+       u32 il,ir,t0,t1;               /* temporary valiables */
+
+       u32 io[4];
+
+       io[0] = be32_to_cpu(io_text[0]);
+       io[1] = be32_to_cpu(io_text[1]);
+       io[2] = be32_to_cpu(io_text[2]);
+       io[3] = be32_to_cpu(io_text[3]);
+
+       /* pre whitening but absorb kw2*/
+       io[0] ^= CAMELLIA_SUBKEY_L(0);
+       io[1] ^= CAMELLIA_SUBKEY_R(0);
+       /* main iteration */
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(2),CAMELLIA_SUBKEY_R(2),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(3),CAMELLIA_SUBKEY_R(3),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(4),CAMELLIA_SUBKEY_R(4),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(5),CAMELLIA_SUBKEY_R(5),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(6),CAMELLIA_SUBKEY_R(6),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(7),CAMELLIA_SUBKEY_R(7),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(8),CAMELLIA_SUBKEY_R(8),
+                    CAMELLIA_SUBKEY_L(9),CAMELLIA_SUBKEY_R(9),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(10),CAMELLIA_SUBKEY_R(10),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(11),CAMELLIA_SUBKEY_R(11),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(12),CAMELLIA_SUBKEY_R(12),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(13),CAMELLIA_SUBKEY_R(13),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(14),CAMELLIA_SUBKEY_R(14),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(15),CAMELLIA_SUBKEY_R(15),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(16),CAMELLIA_SUBKEY_R(16),
+                    CAMELLIA_SUBKEY_L(17),CAMELLIA_SUBKEY_R(17),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(18),CAMELLIA_SUBKEY_R(18),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(19),CAMELLIA_SUBKEY_R(19),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(20),CAMELLIA_SUBKEY_R(20),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(21),CAMELLIA_SUBKEY_R(21),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(22),CAMELLIA_SUBKEY_R(22),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(23),CAMELLIA_SUBKEY_R(23),
+                        io[0],io[1],il,ir,t0,t1);
+
+       /* post whitening but kw4 */
+       io[2] ^= CAMELLIA_SUBKEY_L(24);
+       io[3] ^= CAMELLIA_SUBKEY_R(24);
+
+       t0 = io[0];
+       t1 = io[1];
+       io[0] = io[2];
+       io[1] = io[3];
+       io[2] = t0;
+       io[3] = t1;
+
+       io_text[0] = cpu_to_be32(io[0]);
+       io_text[1] = cpu_to_be32(io[1]);
+       io_text[2] = cpu_to_be32(io[2]);
+       io_text[3] = cpu_to_be32(io[3]);
+
+       return;
+}
+
+static void camellia_decrypt128(const u32 *subkey, __be32 *io_text)
+{
+       u32 il,ir,t0,t1;               /* temporary valiables */
+
+       u32 io[4];
+
+       io[0] = be32_to_cpu(io_text[0]);
+       io[1] = be32_to_cpu(io_text[1]);
+       io[2] = be32_to_cpu(io_text[2]);
+       io[3] = be32_to_cpu(io_text[3]);
+
+       /* pre whitening but absorb kw2*/
+       io[0] ^= CAMELLIA_SUBKEY_L(24);
+       io[1] ^= CAMELLIA_SUBKEY_R(24);
+
+       /* main iteration */
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(23),CAMELLIA_SUBKEY_R(23),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(22),CAMELLIA_SUBKEY_R(22),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(21),CAMELLIA_SUBKEY_R(21),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(20),CAMELLIA_SUBKEY_R(20),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(19),CAMELLIA_SUBKEY_R(19),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(18),CAMELLIA_SUBKEY_R(18),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(17),CAMELLIA_SUBKEY_R(17),
+                    CAMELLIA_SUBKEY_L(16),CAMELLIA_SUBKEY_R(16),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(15),CAMELLIA_SUBKEY_R(15),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(14),CAMELLIA_SUBKEY_R(14),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(13),CAMELLIA_SUBKEY_R(13),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(12),CAMELLIA_SUBKEY_R(12),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(11),CAMELLIA_SUBKEY_R(11),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(10),CAMELLIA_SUBKEY_R(10),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(9),CAMELLIA_SUBKEY_R(9),
+                    CAMELLIA_SUBKEY_L(8),CAMELLIA_SUBKEY_R(8),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(7),CAMELLIA_SUBKEY_R(7),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(6),CAMELLIA_SUBKEY_R(6),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(5),CAMELLIA_SUBKEY_R(5),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(4),CAMELLIA_SUBKEY_R(4),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(3),CAMELLIA_SUBKEY_R(3),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(2),CAMELLIA_SUBKEY_R(2),
+                        io[0],io[1],il,ir,t0,t1);
+
+       /* post whitening but kw4 */
+       io[2] ^= CAMELLIA_SUBKEY_L(0);
+       io[3] ^= CAMELLIA_SUBKEY_R(0);
+
+       t0 = io[0];
+       t1 = io[1];
+       io[0] = io[2];
+       io[1] = io[3];
+       io[2] = t0;
+       io[3] = t1;
+
+       io_text[0] = cpu_to_be32(io[0]);
+       io_text[1] = cpu_to_be32(io[1]);
+       io_text[2] = cpu_to_be32(io[2]);
+       io_text[3] = cpu_to_be32(io[3]);
+
+       return;
+}
+
+
+/**
+ * stuff for 192 and 256bit encryption/decryption
+ */
+static void camellia_encrypt256(const u32 *subkey, __be32 *io_text)
+{
+       u32 il,ir,t0,t1;           /* temporary valiables */
+
+       u32 io[4];
+
+       io[0] = be32_to_cpu(io_text[0]);
+       io[1] = be32_to_cpu(io_text[1]);
+       io[2] = be32_to_cpu(io_text[2]);
+       io[3] = be32_to_cpu(io_text[3]);
+
+       /* pre whitening but absorb kw2*/
+       io[0] ^= CAMELLIA_SUBKEY_L(0);
+       io[1] ^= CAMELLIA_SUBKEY_R(0);
+
+       /* main iteration */
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(2),CAMELLIA_SUBKEY_R(2),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(3),CAMELLIA_SUBKEY_R(3),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(4),CAMELLIA_SUBKEY_R(4),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(5),CAMELLIA_SUBKEY_R(5),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(6),CAMELLIA_SUBKEY_R(6),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(7),CAMELLIA_SUBKEY_R(7),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(8),CAMELLIA_SUBKEY_R(8),
+                    CAMELLIA_SUBKEY_L(9),CAMELLIA_SUBKEY_R(9),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(10),CAMELLIA_SUBKEY_R(10),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(11),CAMELLIA_SUBKEY_R(11),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(12),CAMELLIA_SUBKEY_R(12),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(13),CAMELLIA_SUBKEY_R(13),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(14),CAMELLIA_SUBKEY_R(14),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(15),CAMELLIA_SUBKEY_R(15),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(16),CAMELLIA_SUBKEY_R(16),
+                    CAMELLIA_SUBKEY_L(17),CAMELLIA_SUBKEY_R(17),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(18),CAMELLIA_SUBKEY_R(18),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(19),CAMELLIA_SUBKEY_R(19),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(20),CAMELLIA_SUBKEY_R(20),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(21),CAMELLIA_SUBKEY_R(21),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(22),CAMELLIA_SUBKEY_R(22),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(23),CAMELLIA_SUBKEY_R(23),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(24),CAMELLIA_SUBKEY_R(24),
+                    CAMELLIA_SUBKEY_L(25),CAMELLIA_SUBKEY_R(25),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(26),CAMELLIA_SUBKEY_R(26),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(27),CAMELLIA_SUBKEY_R(27),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(28),CAMELLIA_SUBKEY_R(28),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(29),CAMELLIA_SUBKEY_R(29),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(30),CAMELLIA_SUBKEY_R(30),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(31),CAMELLIA_SUBKEY_R(31),
+                        io[0],io[1],il,ir,t0,t1);
+
+       /* post whitening but kw4 */
+       io[2] ^= CAMELLIA_SUBKEY_L(32);
+       io[3] ^= CAMELLIA_SUBKEY_R(32);
+
+       t0 = io[0];
+       t1 = io[1];
+       io[0] = io[2];
+       io[1] = io[3];
+       io[2] = t0;
+       io[3] = t1;
+
+       io_text[0] = cpu_to_be32(io[0]);
+       io_text[1] = cpu_to_be32(io[1]);
+       io_text[2] = cpu_to_be32(io[2]);
+       io_text[3] = cpu_to_be32(io[3]);
+
+       return;
+}
+
+
+static void camellia_decrypt256(const u32 *subkey, __be32 *io_text)
+{
+       u32 il,ir,t0,t1;           /* temporary valiables */
+
+       u32 io[4];
+
+       io[0] = be32_to_cpu(io_text[0]);
+       io[1] = be32_to_cpu(io_text[1]);
+       io[2] = be32_to_cpu(io_text[2]);
+       io[3] = be32_to_cpu(io_text[3]);
+
+       /* pre whitening but absorb kw2*/
+       io[0] ^= CAMELLIA_SUBKEY_L(32);
+       io[1] ^= CAMELLIA_SUBKEY_R(32);
+
+       /* main iteration */
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(31),CAMELLIA_SUBKEY_R(31),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(30),CAMELLIA_SUBKEY_R(30),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(29),CAMELLIA_SUBKEY_R(29),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(28),CAMELLIA_SUBKEY_R(28),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(27),CAMELLIA_SUBKEY_R(27),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(26),CAMELLIA_SUBKEY_R(26),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(25),CAMELLIA_SUBKEY_R(25),
+                    CAMELLIA_SUBKEY_L(24),CAMELLIA_SUBKEY_R(24),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(23),CAMELLIA_SUBKEY_R(23),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(22),CAMELLIA_SUBKEY_R(22),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(21),CAMELLIA_SUBKEY_R(21),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(20),CAMELLIA_SUBKEY_R(20),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(19),CAMELLIA_SUBKEY_R(19),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(18),CAMELLIA_SUBKEY_R(18),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+                    CAMELLIA_SUBKEY_L(17),CAMELLIA_SUBKEY_R(17),
+                    CAMELLIA_SUBKEY_L(16),CAMELLIA_SUBKEY_R(16),
+                    t0,t1,il,ir);
+
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(15),CAMELLIA_SUBKEY_R(15),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(14),CAMELLIA_SUBKEY_R(14),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(13),CAMELLIA_SUBKEY_R(13),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(12),CAMELLIA_SUBKEY_R(12),
+                        io[0],io[1],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[0],io[1],
+                        CAMELLIA_SUBKEY_L(11),CAMELLIA_SUBKEY_R(11),
+                        io[2],io[3],il,ir,t0,t1);
+       CAMELLIA_ROUNDSM(io[2],io[3],
+                        CAMELLIA_SUBKEY_L(10),CAMELLIA_SUBKEY_R(10),
+                        io[0],io[1],il,ir,t0,t1);
+
+       CAMELLIA_FLS(io[0],io[1],io[2],io[3],
+  &nbs