diff options
author | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2012-04-21 17:16:40 +0000 |
---|---|---|
committer | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2012-04-21 17:16:40 +0000 |
commit | 8012e885db368f7a7e83ecc7d47cd16801f88479 (patch) | |
tree | 1c86a6a6ca48c7aab684dc379a7d31e6b88b16cb | |
parent | c9ed69ae7ad7b1285f7153bf058becc381442f23 (diff) |
omap24xx: remove 2.6.38 support
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31426 3c298f89-4303-0410-b956-a3cf2f4a3e73
32 files changed, 0 insertions, 12106 deletions
diff --git a/target/linux/omap24xx/config-2.6.38 b/target/linux/omap24xx/config-2.6.38 deleted file mode 100644 index 2b4ccc6223..0000000000 --- a/target/linux/omap24xx/config-2.6.38 +++ /dev/null @@ -1,704 +0,0 @@ -# CONFIG_AD2S120X is not set -# CONFIG_AD2S1210 is not set -# CONFIG_AD2S90 is not set -# CONFIG_AD5446 is not set -# CONFIG_AD5624R_SPI is not set -# CONFIG_AD5930 is not set -# CONFIG_AD7150 is not set -# CONFIG_AD7152 is not set -# CONFIG_AD7291 is not set -# CONFIG_AD7298 is not set -# CONFIG_AD7314 is not set -# CONFIG_AD7476 is not set -# CONFIG_AD7745 is not set -# CONFIG_AD7816 is not set -# CONFIG_AD7887 is not set -# CONFIG_AD799X is not set -# CONFIG_AD9832 is not set -# CONFIG_AD9834 is not set -# CONFIG_AD9850 is not set -# CONFIG_AD9852 is not set -# CONFIG_AD9910 is not set -# CONFIG_AD9951 is not set -# CONFIG_ADE7753 is not set -# CONFIG_ADE7754 is not set -# CONFIG_ADE7758 is not set -# CONFIG_ADE7759 is not set -# CONFIG_ADE7854 is not set -# CONFIG_ADIS16060 is not set -# CONFIG_ADIS16080 is not set -# CONFIG_ADIS16130 is not set -CONFIG_ADIS16201=m -CONFIG_ADIS16203=m -CONFIG_ADIS16204=m -# CONFIG_ADIS16209 is not set -# CONFIG_ADIS16220 is not set -# CONFIG_ADIS16240 is not set -# CONFIG_ADIS16251 is not set -# CONFIG_ADIS16260 is not set -# CONFIG_ADIS16300 is not set -# CONFIG_ADIS16350 is not set -# CONFIG_ADIS16400 is not set -# CONFIG_ADT7310 is not set -# CONFIG_ADT7316 is not set -# CONFIG_ADT7410 is not set -# CONFIG_ADT75 is not set -CONFIG_ALIGNMENT_TRAP=y -CONFIG_APM_EMULATION=y -CONFIG_ARCH_HAS_CPUFREQ=y -CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y -CONFIG_ARCH_HAS_HOLES_MEMORYMODEL=y -CONFIG_ARCH_OMAP=y -# CONFIG_ARCH_OMAP1 is not set -CONFIG_ARCH_OMAP2=y -CONFIG_ARCH_OMAP2420=y -# CONFIG_ARCH_OMAP2430 is not set -CONFIG_ARCH_OMAP2PLUS=y -CONFIG_ARCH_OMAP2PLUS_TYPICAL=y -# CONFIG_ARCH_OMAP3 is not set -# CONFIG_ARCH_OMAP4 is not set -CONFIG_ARCH_OMAP_OTG=y -CONFIG_ARCH_REQUIRE_GPIOLIB=y -# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set -# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set -# CONFIG_ARCH_SUPPORTS_MSI is not set -CONFIG_ARCH_SUSPEND_POSSIBLE=y -# CONFIG_ARCH_USES_GETTIMEOFFSET is not set -CONFIG_ARM=y -CONFIG_ARM_ERRATA_411920=y -CONFIG_ARM_L1_CACHE_SHIFT=5 -CONFIG_ARM_THUMB=y -CONFIG_ARM_UNWIND=y -# CONFIG_ARPD is not set -CONFIG_ATAGS_PROC=y -# CONFIG_AUTO_IRQ_AFFINITY is not set -CONFIG_BINFMT_MISC=y -# CONFIG_BKL is not set -# CONFIG_BLK_CGROUP is not set -# CONFIG_BLK_DEV_INITRD is not set -CONFIG_BLK_DEV_LOOP=y -CONFIG_BLK_DEV_RAM=y -CONFIG_BLK_DEV_RAM_COUNT=16 -CONFIG_BLK_DEV_RAM_SIZE=4096 -CONFIG_BLK_DEV_SD=y -CONFIG_BRIDGE=m -CONFIG_BT=m -CONFIG_BT_BNEP=m -# CONFIG_BT_BNEP_MC_FILTER is not set -# CONFIG_BT_BNEP_PROTO_FILTER is not set -# CONFIG_BT_HCIH4P is not set -CONFIG_BT_HCIUART=m -# CONFIG_BT_HCIUART_BCSP is not set -CONFIG_BT_HIDP=m -CONFIG_BT_L2CAP=m -CONFIG_BT_RFCOMM=m -# CONFIG_BT_RFCOMM_TTY is not set -CONFIG_BT_SCO=m -CONFIG_CBUS=y -CONFIG_CBUS_RETU=y -CONFIG_CBUS_RETU_HEADSET=y -CONFIG_CBUS_RETU_POWERBUTTON=y -CONFIG_CBUS_RETU_WDT=y -CONFIG_CBUS_TAHVO=y -# CONFIG_CBUS_TAHVO_USB is not set -CONFIG_CC_OPTIMIZE_FOR_SIZE=y -CONFIG_CGROUPS=y -# CONFIG_CGROUP_CPUACCT is not set -# CONFIG_CGROUP_DEBUG is not set -# CONFIG_CGROUP_DEVICE is not set -# CONFIG_CGROUP_FREEZER is not set -# CONFIG_CGROUP_NS is not set -CONFIG_CGROUP_SCHED=y -CONFIG_CLKDEV_LOOKUP=y -CONFIG_CMDLINE="root=/dev/mmcblk0p1 rootfstype=ext4,ext3,ext2,squashfs,jffs2 console=tty0 console=ttyO2,115200n8 earlyprintk" -CONFIG_CMDLINE_FORCE=y -CONFIG_CONSOLE_TRANSLATIONS=y -# CONFIG_CPUSETS is not set -CONFIG_CPU_32v6=y -# CONFIG_CPU_32v6K is not set -CONFIG_CPU_ABRT_EV6=y -# CONFIG_CPU_BPREDICT_DISABLE is not set -CONFIG_CPU_CACHE_V6=y -CONFIG_CPU_CACHE_VIPT=y -CONFIG_CPU_COPY_V6=y -CONFIG_CPU_CP15=y -CONFIG_CPU_CP15_MMU=y -CONFIG_CPU_FREQ=y -# CONFIG_CPU_FREQ_DEBUG is not set -# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set -# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set -CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y -# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set -# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set -CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y -CONFIG_CPU_FREQ_GOV_ONDEMAND=y -CONFIG_CPU_FREQ_GOV_PERFORMANCE=y -CONFIG_CPU_FREQ_GOV_POWERSAVE=y -CONFIG_CPU_FREQ_GOV_USERSPACE=y -CONFIG_CPU_FREQ_STAT=y -# CONFIG_CPU_FREQ_STAT_DETAILS is not set -CONFIG_CPU_FREQ_TABLE=y -CONFIG_CPU_HAS_ASID=y -CONFIG_CPU_HAS_PMU=y -# CONFIG_CPU_ICACHE_DISABLE is not set -CONFIG_CPU_IDLE=y -CONFIG_CPU_IDLE_GOV_LADDER=y -CONFIG_CPU_IDLE_GOV_MENU=y -CONFIG_CPU_PABRT_V6=y -CONFIG_CPU_TLB_V6=y -CONFIG_CPU_USE_DOMAINS=y -CONFIG_CPU_V6=y -CONFIG_CRC16=y -CONFIG_CRC7=y -CONFIG_CRC_CCITT=y -CONFIG_CRC_ITU_T=y -CONFIG_CRYPTO_AEAD2=y -CONFIG_CRYPTO_AES=y -CONFIG_CRYPTO_ALGAPI=y -CONFIG_CRYPTO_ALGAPI2=y -CONFIG_CRYPTO_ARC4=m -CONFIG_CRYPTO_BLKCIPHER=m -CONFIG_CRYPTO_BLKCIPHER2=y -CONFIG_CRYPTO_CBC=m -CONFIG_CRYPTO_DES=m -CONFIG_CRYPTO_DEV_OMAP_AES=y -CONFIG_CRYPTO_DEV_OMAP_SHAM=y -CONFIG_CRYPTO_ECB=m -CONFIG_CRYPTO_HASH=y -CONFIG_CRYPTO_HASH2=y -CONFIG_CRYPTO_HW=y -CONFIG_CRYPTO_MANAGER=m -CONFIG_CRYPTO_MANAGER2=y -CONFIG_CRYPTO_MD5=y -CONFIG_CRYPTO_PCOMP2=y -CONFIG_CRYPTO_RNG2=y -CONFIG_CRYPTO_SHA1=y -CONFIG_CRYPTO_WORKQUEUE=y -CONFIG_DEBUG_BUGVERBOSE=y -CONFIG_DEBUG_ERRORS=y -# CONFIG_DEBUG_FS is not set -CONFIG_DEBUG_KERNEL=y -# CONFIG_DEBUG_USER is not set -CONFIG_DEFAULT_CFQ=y -CONFIG_DEFAULT_IOSCHED="cfq" -CONFIG_DEFAULT_TCP_CONG="cubic" -CONFIG_DEVKMEM=y -CONFIG_DEVTMPFS=y -CONFIG_DEVTMPFS_MOUNT=y -CONFIG_DNOTIFY=y -CONFIG_DNS_RESOLVER=y -CONFIG_DUMMY_CONSOLE=y -# CONFIG_ECRYPT_FS is not set -CONFIG_ENABLE_MUST_CHECK=y -CONFIG_EXPERT=y -CONFIG_EXPORTFS=m -CONFIG_EXT4_FS=y -CONFIG_FAIR_GROUP_SCHED=y -CONFIG_FAT_FS=y -CONFIG_FB=y -CONFIG_FB_CFB_COPYAREA=y -CONFIG_FB_CFB_FILLRECT=y -CONFIG_FB_CFB_IMAGEBLIT=y -CONFIG_FB_OMAP=y -# CONFIG_FB_OMAP_BOOTLOADER_INIT is not set -CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE=2 -CONFIG_FB_OMAP_LCDC_BLIZZARD=y -CONFIG_FB_OMAP_LCDC_EXTERNAL=y -# CONFIG_FB_OMAP_LCDC_HWA742 is not set -CONFIG_FB_OMAP_LCD_MIPID=y -# CONFIG_FB_OMAP_MANUAL_UPDATE is not set -# CONFIG_FB_SM7XX is not set -# CONFIG_FB_WMT_GE_ROPS is not set -# CONFIG_FIRMWARE_EDID is not set -CONFIG_FIRMWARE_IN_KERNEL=y -CONFIG_FONTS=y -# CONFIG_FONT_10x18 is not set -# CONFIG_FONT_6x11 is not set -# CONFIG_FONT_7x14 is not set -CONFIG_FONT_8x16=y -CONFIG_FONT_8x8=y -# CONFIG_FONT_ACORN_8x8 is not set -# CONFIG_FONT_MINI_4x6 is not set -# CONFIG_FONT_PEARL_8x8 is not set -# CONFIG_FONT_SUN12x22 is not set -# CONFIG_FONT_SUN8x16 is not set -CONFIG_FRAMEBUFFER_CONSOLE=y -# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set -# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set -CONFIG_FREEZER=y -CONFIG_FS_MBCACHE=y -CONFIG_FS_POSIX_ACL=y -CONFIG_GENERIC_ACL=y -CONFIG_GENERIC_ATOMIC64=y -CONFIG_GENERIC_CLOCKEVENTS=y -CONFIG_GENERIC_CLOCKEVENTS_BUILD=y -CONFIG_GENERIC_FIND_LAST_BIT=y -CONFIG_GENERIC_GPIO=y -# CONFIG_GENERIC_HARDIRQS_NO_DEPRECATED is not set -# CONFIG_GENERIC_PENDING_IRQ is not set -CONFIG_GPIOLIB=y -CONFIG_GPIO_SYSFS=y -# CONFIG_HAMRADIO is not set -CONFIG_HARDIRQS_SW_RESEND=y -CONFIG_HAS_DMA=y -CONFIG_HAS_IOMEM=y -CONFIG_HAS_IOPORT=y -CONFIG_HAVE_AOUT=y -CONFIG_HAVE_ARCH_KGDB=y -CONFIG_HAVE_CLK=y -CONFIG_HAVE_C_RECORDMCOUNT=y -CONFIG_HAVE_DMA_API_DEBUG=y -CONFIG_HAVE_DYNAMIC_FTRACE=y -CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y -CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y -CONFIG_HAVE_FUNCTION_TRACER=y -CONFIG_HAVE_GENERIC_DMA_COHERENT=y -CONFIG_HAVE_GENERIC_HARDIRQS=y -CONFIG_HAVE_IDE=y -CONFIG_HAVE_IRQ_WORK=y -CONFIG_HAVE_KERNEL_GZIP=y -CONFIG_HAVE_KERNEL_LZMA=y -CONFIG_HAVE_KERNEL_LZO=y -CONFIG_HAVE_LATENCYTOP_SUPPORT=y -CONFIG_HAVE_MEMBLOCK=y -CONFIG_HAVE_MTD_OTP=y -CONFIG_HAVE_OPROFILE=y -CONFIG_HAVE_PERF_EVENTS=y -CONFIG_HAVE_PROC_CPU=y -CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y -CONFIG_HAVE_SCHED_CLOCK=y -CONFIG_HAVE_SPARSE_IRQ=y -CONFIG_HID=y -CONFIG_HID_APPLE=m -CONFIG_HID_SUPPORT=y -CONFIG_HID_WACOM=m -# CONFIG_HID_WACOM_POWER_SUPPLY is not set -CONFIG_HWMON=m -# CONFIG_HWMON_DEBUG_CHIP is not set -CONFIG_HW_CONSOLE=y -CONFIG_HW_RANDOM=y -CONFIG_HW_RANDOM_OMAP=y -CONFIG_HZ=128 -CONFIG_I2C=y -CONFIG_I2C_BOARDINFO=y -CONFIG_I2C_CHARDEV=y -CONFIG_I2C_COMPAT=y -CONFIG_I2C_HELPER_AUTO=y -CONFIG_I2C_OMAP=y -CONFIG_IIO=y -# CONFIG_IIO_RING_BUFFER is not set -# CONFIG_IIO_TRIGGER is not set -CONFIG_INET6_XFRM_MODE_BEET=m -CONFIG_INET6_XFRM_MODE_TRANSPORT=m -CONFIG_INET6_XFRM_MODE_TUNNEL=m -CONFIG_INET_DIAG=y -CONFIG_INET_TCP_DIAG=y -CONFIG_INET_TUNNEL=m -# CONFIG_INLINE_READ_UNLOCK is not set -# CONFIG_INLINE_READ_UNLOCK_IRQ is not set -# CONFIG_INLINE_SPIN_UNLOCK is not set -# CONFIG_INLINE_SPIN_UNLOCK_IRQ is not set -# CONFIG_INLINE_WRITE_UNLOCK is not set -# CONFIG_INLINE_WRITE_UNLOCK_IRQ is not set -CONFIG_INOTIFY_USER=y -CONFIG_INPUT=y -# CONFIG_INPUT_APMPOWER is not set -CONFIG_INPUT_EVDEV=y -# CONFIG_INPUT_GPIO_BUTTONS is not set -CONFIG_INPUT_JOYSTICK=y -CONFIG_INPUT_KEYBOARD=y -CONFIG_INPUT_MOUSE=y -CONFIG_INPUT_MOUSEDEV=y -# CONFIG_INPUT_MOUSEDEV_PSAUX is not set -CONFIG_INPUT_MOUSEDEV_SCREEN_X=800 -CONFIG_INPUT_MOUSEDEV_SCREEN_Y=480 -CONFIG_INPUT_TABLET=y -CONFIG_INPUT_TOUCHSCREEN=y -CONFIG_IOSCHED_CFQ=y -# CONFIG_IOSCHED_DEADLINE is not set -CONFIG_IPV6=y -CONFIG_IPV6_MIP6=m -CONFIG_IPV6_PRIVACY=y -CONFIG_IPV6_ROUTER_PREF=y -CONFIG_IPV6_SIT=m -# CONFIG_IP_ADVANCED_ROUTER is not set -# CONFIG_IP_MROUTE is not set -# CONFIG_IRQ_PER_CPU is not set -CONFIG_IR_LIRC_CODEC=m -CONFIG_IR_RC5_SZ_DECODER=m -# CONFIG_ISDN is not set -# CONFIG_ISP1301_OMAP is not set -CONFIG_JBD2=y -CONFIG_JFFS2_LZO=y -CONFIG_JFFS2_ZLIB=y -# CONFIG_JOYSTICK_A3D is not set -# CONFIG_JOYSTICK_ADI is not set -# CONFIG_JOYSTICK_ANALOG is not set -# CONFIG_JOYSTICK_AS5011 is not set -# CONFIG_JOYSTICK_COBRA is not set -# CONFIG_JOYSTICK_GF2K is not set -# CONFIG_JOYSTICK_GRIP is not set -# CONFIG_JOYSTICK_GRIP_MP is not set -# CONFIG_JOYSTICK_GUILLEMOT is not set -# CONFIG_JOYSTICK_IFORCE is not set -# CONFIG_JOYSTICK_INTERACT is not set -# CONFIG_JOYSTICK_JOYDUMP is not set -# CONFIG_JOYSTICK_MAGELLAN is not set -# CONFIG_JOYSTICK_SIDEWINDER is not set -# CONFIG_JOYSTICK_SPACEBALL is not set -# CONFIG_JOYSTICK_SPACEORB is not set -# CONFIG_JOYSTICK_STINGER is not set -# CONFIG_JOYSTICK_TMDC is not set -# CONFIG_JOYSTICK_TWIDJOY is not set -# CONFIG_JOYSTICK_WARRIOR is not set -# CONFIG_JOYSTICK_XPAD is not set -# CONFIG_JOYSTICK_ZHENHUA is not set -CONFIG_KALLSYMS=y -CONFIG_KALLSYMS_ALL=y -CONFIG_KEXEC=y -# CONFIG_KEYBOARD_GPIO is not set -CONFIG_KEYBOARD_LM8323=y -# CONFIG_KEYBOARD_OMAP is not set -CONFIG_KEYS=y -# CONFIG_KEYS_DEBUG_PROC_KEYS is not set -# CONFIG_KXSD9 is not set -# CONFIG_LEDS is not set -# CONFIG_LEDS_GPIO is not set -# CONFIG_LEDS_REGULATOR is not set -CONFIG_LEDS_TRIGGER_BACKLIGHT=y -CONFIG_LEDS_TRIGGER_GPIO=y -CONFIG_LIRC=m -# CONFIG_LIS3L02DQ is not set -CONFIG_LLC=m -CONFIG_LOCKD=m -CONFIG_LOG_BUF_SHIFT=18 -CONFIG_LZO_COMPRESS=y -CONFIG_LZO_DECOMPRESS=y -CONFIG_MACH_NOKIA_N800=y -CONFIG_MACH_NOKIA_N810=y -CONFIG_MACH_NOKIA_N810_WIMAX=y -CONFIG_MACH_NOKIA_N8X0=y -CONFIG_MACH_NO_WESTBRIDGE=y -CONFIG_MACH_OMAP2_TUSB6010=y -# CONFIG_MACH_OMAP_APOLLON is not set -# CONFIG_MACH_OMAP_GENERIC is not set -# CONFIG_MACH_OMAP_H4 is not set -CONFIG_MACVLAN=m -CONFIG_MAC_PARTITION=y -# CONFIG_MAX1363 is not set -CONFIG_MEDIA_ATTACH=y -CONFIG_MEDIA_SUPPORT=m -CONFIG_MEDIA_TUNER=m -CONFIG_MEDIA_TUNER_MC44S803=m -CONFIG_MEDIA_TUNER_MT20XX=m -CONFIG_MEDIA_TUNER_SIMPLE=m -CONFIG_MEDIA_TUNER_TDA18271=m -CONFIG_MEDIA_TUNER_TDA827X=m -CONFIG_MEDIA_TUNER_TDA8290=m -CONFIG_MEDIA_TUNER_TDA9887=m -CONFIG_MEDIA_TUNER_TEA5761=m -CONFIG_MEDIA_TUNER_TEA5767=m -CONFIG_MEDIA_TUNER_XC2028=m -CONFIG_MEDIA_TUNER_XC5000=m -CONFIG_MENELAUS=y -# CONFIG_MFD_T7L66XB is not set -# CONFIG_MFD_WL1273_CORE is not set -# CONFIG_MISC_DEVICES is not set -CONFIG_MMC=y -CONFIG_MMC_BLOCK=y -CONFIG_MMC_OMAP=y -CONFIG_MMC_SDHCI=y -CONFIG_MMC_SDHCI_PLTFM=y -CONFIG_MMC_SPI=y -CONFIG_MMC_UNSAFE_RESUME=y -# CONFIG_MOUSE_BCM5974 is not set -# CONFIG_MOUSE_GPIO is not set -CONFIG_MOUSE_PS2=y -CONFIG_MOUSE_PS2_ALPS=y -# CONFIG_MOUSE_PS2_ELANTECH is not set -CONFIG_MOUSE_PS2_LOGIPS2PP=y -CONFIG_MOUSE_PS2_SYNAPTICS=y -# CONFIG_MOUSE_PS2_TOUCHKIT is not set -CONFIG_MOUSE_PS2_TRACKPOINT=y -# CONFIG_MOUSE_SERIAL is not set -# CONFIG_MOUSE_VSXXXAA is not set -CONFIG_MSDOS_FS=y -CONFIG_MTD_BLOCK2MTD=y -# CONFIG_MTD_CFI is not set -CONFIG_MTD_CMDLINE_PARTS=y -# CONFIG_MTD_COMPLEX_MAPPINGS is not set -CONFIG_MTD_ONENAND=y -# CONFIG_MTD_ONENAND_2X_PROGRAM is not set -# CONFIG_MTD_ONENAND_GENERIC is not set -CONFIG_MTD_ONENAND_OMAP2=y -CONFIG_MTD_ONENAND_OTP=y -# CONFIG_MTD_ONENAND_SIM is not set -# CONFIG_MTD_ONENAND_VERIFY_WRITE is not set -# CONFIG_MTD_ROOTFS_ROOT_DEV is not set -# CONFIG_MTD_ROOTFS_SPLIT is not set -# CONFIG_MUSB_PIO_ONLY is not set -# CONFIG_N810BM is not set -CONFIG_NAMESPACES=y -CONFIG_NEED_DMA_MAP_STATE=y -CONFIG_NEED_PER_CPU_KM=y -CONFIG_NETDEV_10000=y -# CONFIG_NET_NS is not set -# CONFIG_NET_SCHED is not set -CONFIG_NFSD=m -CONFIG_NFSD_DEPRECATED=y -CONFIG_NFSD_V2_ACL=y -CONFIG_NFSD_V3_ACL=y -CONFIG_NFSD_V4=y -CONFIG_NFS_ACL_SUPPORT=m -CONFIG_NFS_FS=m -CONFIG_NFS_USE_KERNEL_DNS=y -# CONFIG_NFS_USE_LEGACY_DNS is not set -# CONFIG_NFS_USE_NEW_IDMAPPER is not set -CONFIG_NFS_V3_ACL=y -CONFIG_NFS_V4=y -CONFIG_NFS_V4_1=y -CONFIG_NLS=y -CONFIG_NOP_USB_XCEIV=m -CONFIG_NO_HZ=y -# CONFIG_OMAP2_DSS is not set -CONFIG_OMAP_32K_TIMER=y -CONFIG_OMAP_32K_TIMER_HZ=128 -CONFIG_OMAP_BOOT_REASON=y -CONFIG_OMAP_BOOT_TAG=y -CONFIG_OMAP_COMPONENT_VERSION=y -CONFIG_OMAP_DM_TIMER=y -CONFIG_OMAP_GPIO_SWITCH=y -CONFIG_OMAP_MBOX_FWK=y -CONFIG_OMAP_MBOX_KFIFO_SIZE=256 -CONFIG_OMAP_MCBSP=y -CONFIG_OMAP_MUX=y -# CONFIG_OMAP_MUX_DEBUG is not set -CONFIG_OMAP_MUX_WARNINGS=y -CONFIG_OMAP_PACKAGE_ZAC=y -# CONFIG_OMAP_PM_NONE is not set -CONFIG_OMAP_PM_NOOP=y -CONFIG_OMAP_RESET_CLOCKS=y -# CONFIG_OMAP_WATCHDOG is not set -CONFIG_PAGEFLAGS_EXTENDED=y -CONFIG_PAGE_OFFSET=0xC0000000 -# CONFIG_PCI_SYSCALL is not set -CONFIG_PERF_USE_VMALLOC=y -CONFIG_PM=y -# CONFIG_PM_DEBUG is not set -CONFIG_PM_OPS=y -CONFIG_PM_RUNTIME=y -CONFIG_PM_SLEEP=y -CONFIG_PNFS_FILE_LAYOUT=m -CONFIG_POSIX_MQUEUE=y -CONFIG_POSIX_MQUEUE_SYSCTL=y -CONFIG_PPP=m -CONFIG_PPP_ASYNC=m -CONFIG_PPP_BSDCOMP=m -CONFIG_PPP_DEFLATE=m -CONFIG_PPP_MPPE=m -# CONFIG_PPP_MULTILINK is not set -CONFIG_PPP_SYNC_TTY=m -CONFIG_PREEMPT=y -# CONFIG_PREEMPT_NONE is not set -CONFIG_PREEMPT_RCU=y -CONFIG_PRINTK_TIME=y -CONFIG_PROC_PAGE_MONITOR=y -# CONFIG_QUOTACTL is not set -# CONFIG_RCU_BOOST is not set -CONFIG_RC_CORE=m -# CONFIG_RC_LOOPBACK is not set -CONFIG_REGULATOR=y -# CONFIG_REGULATOR_AD5398 is not set -# CONFIG_REGULATOR_DEBUG is not set -# CONFIG_REGULATOR_DUMMY is not set -# CONFIG_REGULATOR_ISL6271A is not set -# CONFIG_REGULATOR_LP3971 is not set -# CONFIG_REGULATOR_LP3972 is not set -# CONFIG_REGULATOR_MAX1586 is not set -# CONFIG_REGULATOR_MAX8649 is not set -# CONFIG_REGULATOR_MAX8660 is not set -# CONFIG_REGULATOR_MAX8952 is not set -# CONFIG_REGULATOR_TPS65023 is not set -# CONFIG_REGULATOR_TPS6507X is not set -# CONFIG_REGULATOR_TPS6524X is not set -# CONFIG_REGULATOR_USERSPACE_CONSUMER is not set -# CONFIG_RESOURCE_COUNTERS is not set -CONFIG_RPCSEC_GSS_KRB5=m -# CONFIG_RT_GROUP_SCHED is not set -CONFIG_SCHED_AUTOGROUP=y -CONFIG_SCSI=y -# CONFIG_SCSI_LOWLEVEL is not set -# CONFIG_SDIO_UART is not set -# CONFIG_SENSORS_AK8975 is not set -# CONFIG_SENSORS_HMC5843 is not set -# CONFIG_SENSORS_ISL29018 is not set -CONFIG_SENSORS_LM75=m -CONFIG_SENSORS_TSL2563=m -CONFIG_SERIAL_8250_NR_UARTS=4 -CONFIG_SERIAL_8250_RUNTIME_UARTS=4 -# CONFIG_SERIAL_IFX6X60 is not set -CONFIG_SERIAL_OMAP=y -CONFIG_SERIAL_OMAP_CONSOLE=y -CONFIG_SERIO=y -CONFIG_SERIO_LIBPS2=y -# CONFIG_SERIO_PS2MULT is not set -# CONFIG_SERIO_RAW is not set -CONFIG_SERIO_SERPORT=y -# CONFIG_SLAB is not set -CONFIG_SLHC=m -CONFIG_SLUB=y -CONFIG_SND=m -CONFIG_SND_ARM=y -# CONFIG_SND_EMU10K1_SEQ is not set -CONFIG_SND_JACK=y -CONFIG_SND_MIXER_OSS=m -CONFIG_SND_OMAP_SOC=m -CONFIG_SND_OMAP_SOC_MCBSP=m -CONFIG_SND_OMAP_SOC_N810=m -# CONFIG_SND_OPL3_LIB_SEQ is not set -# CONFIG_SND_OPL4_LIB_SEQ is not set -CONFIG_SND_PCM=m -CONFIG_SND_PCM_OSS=m -# CONFIG_SND_RAWMIDI_SEQ is not set -# CONFIG_SND_SBAWE_SEQ is not set -CONFIG_SND_SOC=m -# CONFIG_SND_SOC_ALL_CODECS is not set -CONFIG_SND_SOC_CACHE_LZO=y -CONFIG_SND_SOC_I2C_AND_SPI=m -CONFIG_SND_SOC_TLV320AIC3X=m -CONFIG_SND_SPI=y -CONFIG_SND_SUPPORT_OLD_API=y -CONFIG_SND_TIMER=m -CONFIG_SOUND=m -CONFIG_SOUND_OSS_CORE=y -CONFIG_SOUND_OSS_CORE_PRECLAIM=y -CONFIG_SPEAKUP=m -CONFIG_SPEAKUP_SYNTH_ACNTPC=m -CONFIG_SPEAKUP_SYNTH_ACNTSA=m -CONFIG_SPEAKUP_SYNTH_APOLLO=m -CONFIG_SPEAKUP_SYNTH_AUDPTR=m -CONFIG_SPEAKUP_SYNTH_BNS=m -CONFIG_SPEAKUP_SYNTH_DECEXT=m -CONFIG_SPEAKUP_SYNTH_DECPC=m -CONFIG_SPEAKUP_SYNTH_DECTLK=m -CONFIG_SPEAKUP_SYNTH_DTLK=m -CONFIG_SPEAKUP_SYNTH_DUMMY=m -CONFIG_SPEAKUP_SYNTH_KEYPC=m -CONFIG_SPEAKUP_SYNTH_LTLK=m -CONFIG_SPEAKUP_SYNTH_SOFT=m -CONFIG_SPEAKUP_SYNTH_SPKOUT=m -CONFIG_SPEAKUP_SYNTH_TXPRT=m -CONFIG_SPI=y -# CONFIG_SPI_BITBANG is not set -# CONFIG_SPI_GPIO is not set -CONFIG_SPI_MASTER=y -CONFIG_SPI_OMAP24XX=y -# CONFIG_SPI_PXA2XX_PCI is not set -CONFIG_STP=m -# CONFIG_STRIP_ASM_SYMS is not set -CONFIG_SUNRPC=m -CONFIG_SUNRPC_GSS=m -CONFIG_SUSPEND=y -CONFIG_SUSPEND_FREEZER=y -# CONFIG_SYN_COOKIES is not set -CONFIG_SYS_SUPPORTS_APM_EMULATION=y -# CONFIG_TABLET_USB_ACECAD is not set -# CONFIG_TABLET_USB_AIPTEK is not set -# CONFIG_TABLET_USB_GTCO is not set -# CONFIG_TABLET_USB_HANWANG is not set -# CONFIG_TABLET_USB_KBTAB is not set -# CONFIG_TABLET_USB_WACOM is not set -# CONFIG_TCP_CONG_ADVANCED is not set -CONFIG_TCP_CONG_CUBIC=y -CONFIG_TINY_PREEMPT_RCU=y -# CONFIG_TINY_RCU is not set -CONFIG_TMPFS_POSIX_ACL=y -# CONFIG_TOUCHSCREEN_BU21013 is not set -# CONFIG_TOUCHSCREEN_CLEARPAD_TM1217 is not set -# CONFIG_TOUCHSCREEN_DYNAPRO is not set -# CONFIG_TOUCHSCREEN_HAMPSHIRE is not set -# CONFIG_TOUCHSCREEN_ST1232 is not set -CONFIG_TOUCHSCREEN_TSC2005=y -CONFIG_TUN=m -CONFIG_UACCESS_WITH_MEMCPY=y -CONFIG_UID16=y -CONFIG_USB=m -# CONFIG_USB_ARCH_HAS_EHCI is not set -# CONFIG_USB_AUDIO is not set -# CONFIG_USB_CDC_COMPOSITE is not set -CONFIG_USB_ETH=m -# CONFIG_USB_ETH_EEM is not set -# CONFIG_USB_ETH_RNDIS is not set -# CONFIG_USB_FILE_STORAGE is not set -# CONFIG_USB_FUNCTIONFS is not set -CONFIG_USB_GADGET=m -# CONFIG_USB_GADGETFS is not set -# CONFIG_USB_GADGET_DEBUG_FILES is not set -CONFIG_USB_GADGET_DUALSPEED=y -# CONFIG_USB_GADGET_DUMMY_HCD is not set -# CONFIG_USB_GADGET_M66592 is not set -CONFIG_USB_GADGET_MUSB_HDRC=y -# CONFIG_USB_GADGET_OMAP is not set -# CONFIG_USB_GADGET_PXA_U2O is not set -# CONFIG_USB_GADGET_R8A66597 is not set -CONFIG_USB_GADGET_SELECTED=y -CONFIG_USB_GADGET_VBUS_DRAW=100 -CONFIG_USB_GSPCA=m -# CONFIG_USB_G_DBGP is not set -# CONFIG_USB_G_HID is not set -CONFIG_USB_G_NCM=m -# CONFIG_USB_G_PRINTER is not set -# CONFIG_USB_G_SERIAL is not set -# CONFIG_USB_G_WEBCAM is not set -CONFIG_USB_HID=m -# CONFIG_USB_INVENTRA_DMA is not set -# CONFIG_USB_MIDI_GADGET is not set -# CONFIG_USB_MUSB_AM35X is not set -# CONFIG_USB_MUSB_DEBUG is not set -CONFIG_USB_MUSB_HDRC=m -CONFIG_USB_MUSB_HDRC_HCD=y -# CONFIG_USB_MUSB_HOST is not set -# CONFIG_USB_MUSB_OMAP2PLUS is not set -CONFIG_USB_MUSB_OTG=y -# CONFIG_USB_MUSB_PERIPHERAL is not set -CONFIG_USB_MUSB_TUSB6010=y -CONFIG_USB_NET_CDC_NCM=m -CONFIG_USB_OTG=y -CONFIG_USB_OTG_UTILS=y -# CONFIG_USB_PWC is not set -CONFIG_USB_SERIAL=m -CONFIG_USB_SUPPORT=y -# CONFIG_USB_TI_CPPI_DMA is not set -CONFIG_USB_TUSB_OMAP_DMA=y -CONFIG_USB_USBNET=m -# CONFIG_USB_ZERO is not set -# CONFIG_USER_NS is not set -CONFIG_V4L_USB_DRIVERS=y -CONFIG_VECTORS_BASE=0xffff0000 -CONFIG_VFAT_FS=y -CONFIG_VFP=y -CONFIG_VIDEO_CAPTURE_DRIVERS=y -# CONFIG_VIDEO_CPIA2 is not set -CONFIG_VIDEO_DEV=m -CONFIG_VIDEO_IR_I2C=m -CONFIG_VIDEO_MEDIA=m -# CONFIG_VIDEO_OMAP2 is not set -# CONFIG_VIDEO_OMAP2_VOUT is not set -CONFIG_VIDEO_TCM825X=m -CONFIG_VIDEO_V4L2=m -CONFIG_VIDEO_V4L2_COMMON=m -CONFIG_VLAN_8021Q=m -CONFIG_VT=y -CONFIG_VT_CONSOLE=y -# CONFIG_VT_HW_CONSOLE_BINDING is not set -CONFIG_WATCHDOG_NOWAYOUT=y -# CONFIG_WEXT_PRIV is not set -# CONFIG_WEXT_SPY is not set -CONFIG_XZ_DEC=y -CONFIG_XZ_DEC_ARM=y -CONFIG_XZ_DEC_ARMTHUMB=y -CONFIG_XZ_DEC_BCJ=y -# CONFIG_ZBOOT_ROM is not set -CONFIG_ZBOOT_ROM_BSS=0x10200000 -CONFIG_ZBOOT_ROM_TEXT=0x10C08000 -CONFIG_ZONE_DMA_FLAG=0 diff --git a/target/linux/omap24xx/patches-2.6.38/200-omap-platform.patch b/target/linux/omap24xx/patches-2.6.38/200-omap-platform.patch deleted file mode 100644 index 1a0a3def48..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/200-omap-platform.patch +++ /dev/null @@ -1,896 +0,0 @@ ---- /dev/null -+++ b/arch/arm/plat-omap/bootreason.c -@@ -0,0 +1,79 @@ -+/* -+ * linux/arch/arm/plat-omap/bootreason.c -+ * -+ * OMAP Bootreason passing -+ * -+ * Copyright (c) 2004 Nokia -+ * -+ * Written by David Weinehall <david.weinehall@nokia.com> -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms of the GNU General Public License as published by the -+ * Free Software Foundation; either version 2 of the License, or (at your -+ * option) any later version. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ * 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., -+ * 675 Mass Ave, Cambridge, MA 02139, USA. -+ */ -+#include <linux/proc_fs.h> -+#include <linux/errno.h> -+#include <plat/board.h> -+ -+static char boot_reason[16]; -+ -+static int omap_bootreason_read_proc(char *page, char **start, off_t off, -+ int count, int *eof, void *data) -+{ -+ int len = 0; -+ -+ len += sprintf(page + len, "%s\n", boot_reason); -+ -+ *start = page + off; -+ -+ if (len > off) -+ len -= off; -+ else -+ len = 0; -+ -+ return len < count ? len : count; -+} -+ -+static int __init bootreason_init(void) -+{ -+ const struct omap_boot_reason_config *cfg; -+ int reason_valid = 0; -+ -+ cfg = omap_get_config(OMAP_TAG_BOOT_REASON, struct omap_boot_reason_config); -+ if (cfg != NULL) { -+ strncpy(boot_reason, cfg->reason_str, sizeof(cfg->reason_str)); -+ boot_reason[sizeof(cfg->reason_str)] = 0; -+ reason_valid = 1; -+ } else { -+ /* Read the boot reason from the OMAP registers */ -+ } -+ -+ if (!reason_valid) -+ return -ENOENT; -+ -+ printk(KERN_INFO "Bootup reason: %s\n", boot_reason); -+ -+ if (!create_proc_read_entry("bootreason", S_IRUGO, NULL, -+ omap_bootreason_read_proc, NULL)) -+ return -ENOMEM; -+ -+ return 0; -+} -+ -+late_initcall(bootreason_init); ---- a/arch/arm/plat-omap/common.c -+++ b/arch/arm/plat-omap/common.c -@@ -21,17 +21,89 @@ - #include <plat/vram.h> - #include <plat/dsp.h> - -+#include <asm/setup.h> -+ - - #define NO_LENGTH_CHECK 0xffffffff - - struct omap_board_config_kernel *omap_board_config; - int omap_board_config_size; - -+unsigned char omap_bootloader_tag[1024]; -+int omap_bootloader_tag_len; -+ -+/* used by omap-smp.c and board-4430sdp.c */ -+void __iomem *gic_cpu_base_addr; -+ -+#ifdef CONFIG_OMAP_BOOT_TAG -+ -+static int __init parse_tag_omap(const struct tag *tag) -+{ -+ u32 size = tag->hdr.size - (sizeof(tag->hdr) >> 2); -+ -+ size <<= 2; -+ if (size > sizeof(omap_bootloader_tag)) -+ return -1; -+ -+ memcpy(omap_bootloader_tag, tag->u.omap.data, size); -+ omap_bootloader_tag_len = size; -+ -+ return 0; -+} -+ -+__tagtable(ATAG_BOARD, parse_tag_omap); -+ -+#endif -+ - static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out) - { - struct omap_board_config_kernel *kinfo = NULL; - int i; - -+#ifdef CONFIG_OMAP_BOOT_TAG -+ struct omap_board_config_entry *info = NULL; -+ -+ if (omap_bootloader_tag_len > 4) -+ info = (struct omap_board_config_entry *) omap_bootloader_tag; -+ while (info != NULL) { -+ u8 *next; -+ -+ if (info->tag == tag) { -+ if (skip == 0) -+ break; -+ skip--; -+ } -+ -+ if ((info->len & 0x03) != 0) { -+ /* We bail out to avoid an alignment fault */ -+ printk(KERN_ERR "OMAP peripheral config: Length (%d) not word-aligned (tag %04x)\n", -+ info->len, info->tag); -+ return NULL; -+ } -+ next = (u8 *) info + sizeof(*info) + info->len; -+ if (next >= omap_bootloader_tag + omap_bootloader_tag_len) -+ info = NULL; -+ else -+ info = (struct omap_board_config_entry *) next; -+ } -+ if (info != NULL) { -+ /* Check the length as a lame attempt to check for -+ * binary inconsistency. */ -+ if (len != NO_LENGTH_CHECK) { -+ /* Word-align len */ -+ if (len & 0x03) -+ len = (len + 3) & ~0x03; -+ if (info->len != len) { -+ printk(KERN_ERR "OMAP peripheral config: Length mismatch with tag %x (want %d, got %d)\n", -+ tag, len, info->len); -+ return NULL; -+ } -+ } -+ if (len_out != NULL) -+ *len_out = info->len; -+ return info->data; -+ } -+#endif - /* Try to find the config from the board-specific structures - * in the kernel. */ - for (i = 0; i < omap_board_config_size; i++) { ---- /dev/null -+++ b/arch/arm/plat-omap/component-version.c -@@ -0,0 +1,64 @@ -+/* -+ * linux/arch/arm/plat-omap/component-version.c -+ * -+ * Copyright (C) 2005 Nokia Corporation -+ * Written by Juha Yrjölä <juha.yrjola@nokia.com> -+ * -+ * 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/init.h> -+#include <linux/module.h> -+#include <linux/err.h> -+#include <linux/proc_fs.h> -+#include <plat/board.h> -+ -+static int component_version_read_proc(char *page, char **start, off_t off, -+ int count, int *eof, void *data) -+{ -+ int len, i; -+ const struct omap_version_config *ver; -+ char *p; -+ -+ i = 0; -+ p = page; -+ while ((ver = omap_get_nr_config(OMAP_TAG_VERSION_STR, -+ struct omap_version_config, i)) != NULL) { -+ p += sprintf(p, "%-12s%s\n", ver->component, ver->version); -+ i++; -+ } -+ -+ len = (p - page) - off; -+ if (len < 0) -+ len = 0; -+ -+ *eof = (len <= count) ? 1 : 0; -+ *start = page + off; -+ -+ return len; -+} -+ -+static int __init component_version_init(void) -+{ -+ if (omap_get_config(OMAP_TAG_VERSION_STR, struct omap_version_config) == NULL) -+ return -ENODEV; -+ if (!create_proc_read_entry("component_version", S_IRUGO, NULL, -+ component_version_read_proc, NULL)) -+ return -ENOMEM; -+ -+ return 0; -+} -+ -+static void __exit component_version_exit(void) -+{ -+ remove_proc_entry("component_version", NULL); -+} -+ -+late_initcall(component_version_init); -+module_exit(component_version_exit); -+ -+MODULE_AUTHOR("Juha Yrjölä <juha.yrjola@nokia.com>"); -+MODULE_DESCRIPTION("Component version driver"); -+MODULE_LICENSE("GPL"); ---- a/arch/arm/plat-omap/Kconfig -+++ b/arch/arm/plat-omap/Kconfig -@@ -79,6 +79,38 @@ config OMAP_RESET_CLOCKS - probably do not want this option enabled until your - device drivers work properly. - -+config OMAP_BOOT_TAG -+ bool "OMAP bootloader information passing" -+ depends on ARCH_OMAP -+ default n -+ help -+ Say Y, if you have a bootloader which passes information -+ about your board and its peripheral configuration. -+ -+config OMAP_BOOT_REASON -+ bool "Support for boot reason" -+ depends on OMAP_BOOT_TAG -+ default n -+ help -+ Say Y, if you want to have a procfs entry for reading the boot -+ reason in user-space. -+ -+config OMAP_COMPONENT_VERSION -+ bool "Support for component version display" -+ depends on OMAP_BOOT_TAG && PROC_FS -+ default n -+ help -+ Say Y, if you want to have a procfs entry for reading component -+ versions (supplied by the bootloader) in user-space. -+ -+config OMAP_GPIO_SWITCH -+ bool "GPIO switch support" -+ help -+ Say Y, if you want to have support for reporting of GPIO -+ switches (e.g. cover switches) via sysfs. Your bootloader has -+ to provide information about the switches to the kernel via the -+ ATAG_BOARD mechanism if they're not defined by the board config. -+ - config OMAP_MUX - bool "OMAP multiplexing support" - depends on ARCH_OMAP ---- a/arch/arm/plat-omap/Makefile -+++ b/arch/arm/plat-omap/Makefile -@@ -23,6 +23,9 @@ obj-$(CONFIG_OMAP_IOMMU_DEBUG) += iommu- - - obj-$(CONFIG_CPU_FREQ) += cpu-omap.o - obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o -+obj-$(CONFIG_OMAP_BOOT_REASON) += bootreason.o -+obj-$(CONFIG_OMAP_COMPONENT_VERSION) += component-version.o -+obj-$(CONFIG_OMAP_GPIO_SWITCH) += gpio-switch.o - obj-$(CONFIG_OMAP_DEBUG_DEVICES) += debug-devices.o - obj-$(CONFIG_OMAP_DEBUG_LEDS) += debug-leds.o - i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o ---- a/arch/arm/include/asm/setup.h -+++ b/arch/arm/include/asm/setup.h -@@ -136,6 +136,13 @@ struct tag_acorn { - __u8 adfsdrives; - }; - -+/* TI OMAP specific information */ -+#define ATAG_BOARD 0x414f4d50 -+ -+struct tag_omap { -+ u8 data[0]; -+}; -+ - /* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */ - #define ATAG_MEMCLK 0x41000402 - -@@ -162,6 +169,11 @@ struct tag { - struct tag_acorn acorn; - - /* -+ * OMAP specific -+ */ -+ struct tag_omap omap; -+ -+ /* - * DC21285 specific - */ - struct tag_memclk memclk; ---- /dev/null -+++ b/arch/arm/plat-omap/gpio-switch.c -@@ -0,0 +1,554 @@ -+/* -+ * linux/arch/arm/plat-omap/gpio-switch.c -+ * -+ * Copyright (C) 2004-2006 Nokia Corporation -+ * Written by Juha Yrjölä <juha.yrjola@nokia.com> -+ * and Paul Mundt <paul.mundt@nokia.com> -+ * -+ * 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/sched.h> -+#include <linux/init.h> -+#include <linux/list.h> -+#include <linux/irq.h> -+#include <linux/interrupt.h> -+#include <linux/module.h> -+#include <linux/platform_device.h> -+#include <linux/timer.h> -+#include <linux/err.h> -+#include <linux/slab.h> -+#include <linux/gpio.h> -+#include <plat/hardware.h> -+#include <plat/irqs.h> -+#include <plat/mux.h> -+#include <plat/board.h> -+#include <plat/gpio-switch.h> -+ -+struct gpio_switch { -+ char name[14]; -+ u16 gpio; -+ unsigned flags:4; -+ unsigned type:4; -+ unsigned state:1; -+ unsigned both_edges:1; -+ -+ u16 debounce_rising; -+ u16 debounce_falling; -+ -+ void (* notify)(void *data, int state); -+ void *notify_data; -+ -+ struct work_struct work; -+ struct timer_list timer; -+ struct platform_device pdev; -+ -+ struct list_head node; -+}; -+ -+static LIST_HEAD(gpio_switches); -+static struct platform_device *gpio_sw_platform_dev; -+static struct platform_driver gpio_sw_driver; -+ -+static const struct omap_gpio_switch *board_gpio_sw_table; -+static int board_gpio_sw_count; -+ -+static const char *cover_str[2] = { "open", "closed" }; -+static const char *connection_str[2] = { "disconnected", "connected" }; -+static const char *activity_str[2] = { "inactive", "active" }; -+ -+/* -+ * GPIO switch state default debounce delay in ms -+ */ -+#define OMAP_GPIO_SW_DEFAULT_DEBOUNCE 10 -+ -+static const char **get_sw_str(struct gpio_switch *sw) -+{ -+ switch (sw->type) { -+ case OMAP_GPIO_SWITCH_TYPE_COVER: -+ return cover_str; -+ case OMAP_GPIO_SWITCH_TYPE_CONNECTION: -+ return connection_str; -+ case OMAP_GPIO_SWITCH_TYPE_ACTIVITY: -+ return activity_str; -+ default: -+ BUG(); -+ return NULL; -+ } -+} -+ -+static const char *get_sw_type(struct gpio_switch *sw) -+{ -+ switch (sw->type) { -+ case OMAP_GPIO_SWITCH_TYPE_COVER: -+ return "cover"; -+ case OMAP_GPIO_SWITCH_TYPE_CONNECTION: -+ return "connection"; -+ case OMAP_GPIO_SWITCH_TYPE_ACTIVITY: -+ return "activity"; -+ default: -+ BUG(); -+ return NULL; -+ } -+} -+ -+static void print_sw_state(struct gpio_switch *sw, int state) -+{ -+ const char **str; -+ -+ str = get_sw_str(sw); -+ if (str != NULL) -+ printk(KERN_INFO "%s (GPIO %d) is now %s\n", sw->name, sw->gpio, str[state]); -+} -+ -+static int gpio_sw_get_state(struct gpio_switch *sw) -+{ -+ int state; -+ -+ state = gpio_get_value(sw->gpio); -+ if (sw->flags & OMAP_GPIO_SWITCH_FLAG_INVERTED) -+ state = !state; -+ -+ return state; -+} -+ -+static ssize_t gpio_sw_state_store(struct device *dev, -+ struct device_attribute *attr, -+ const char *buf, -+ size_t count) -+{ -+ struct gpio_switch *sw = dev_get_drvdata(dev); -+ const char **str; -+ char state[16]; -+ int enable; -+ -+ if (!(sw->flags & OMAP_GPIO_SWITCH_FLAG_OUTPUT)) -+ return -EPERM; -+ -+ if (sscanf(buf, "%15s", state) != 1) -+ return -EINVAL; -+ -+ str = get_sw_str(sw); -+ if (strcmp(state, str[0]) == 0) -+ sw->state = enable = 0; -+ else if (strcmp(state, str[1]) == 0) -+ sw->state = enable = 1; -+ else -+ return -EINVAL; -+ -+ if (sw->flags & OMAP_GPIO_SWITCH_FLAG_INVERTED) -+ enable = !enable; -+ gpio_set_value(sw->gpio, enable); -+ -+ return count; -+} -+ -+static ssize_t gpio_sw_state_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct gpio_switch *sw = dev_get_drvdata(dev); -+ const char **str; -+ -+ str = get_sw_str(sw); -+ return sprintf(buf, "%s\n", str[sw->state]); -+} -+ -+static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, gpio_sw_state_show, -+ gpio_sw_state_store); -+ -+static ssize_t gpio_sw_type_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct gpio_switch *sw = dev_get_drvdata(dev); -+ -+ return sprintf(buf, "%s\n", get_sw_type(sw)); -+} -+ -+static DEVICE_ATTR(type, S_IRUGO, gpio_sw_type_show, NULL); -+ -+static ssize_t gpio_sw_direction_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct gpio_switch *sw = dev_get_drvdata(dev); -+ int is_output; -+ -+ is_output = sw->flags & OMAP_GPIO_SWITCH_FLAG_OUTPUT; -+ return sprintf(buf, "%s\n", is_output ? "output" : "input"); -+} -+ -+static DEVICE_ATTR(direction, S_IRUGO, gpio_sw_direction_show, NULL); -+ -+ -+static irqreturn_t gpio_sw_irq_handler(int irq, void *arg) -+{ -+ struct gpio_switch *sw = arg; -+ unsigned long timeout; -+ int state; -+ -+ if (!sw->both_edges) { -+ if (gpio_get_value(sw->gpio)) -+ set_irq_type(OMAP_GPIO_IRQ(sw->gpio), IRQ_TYPE_EDGE_FALLING); -+ else -+ set_irq_type(OMAP_GPIO_IRQ(sw->gpio), IRQ_TYPE_EDGE_RISING); -+ } -+ -+ state = gpio_sw_get_state(sw); -+ if (sw->state == state) -+ return IRQ_HANDLED; -+ -+ if (state) -+ timeout = sw->debounce_rising; -+ else -+ timeout = sw->debounce_falling; -+ if (!timeout) -+ schedule_work(&sw->work); -+ else -+ mod_timer(&sw->timer, jiffies + msecs_to_jiffies(timeout)); -+ -+ return IRQ_HANDLED; -+} -+ -+static void gpio_sw_timer(unsigned long arg) -+{ -+ struct gpio_switch *sw = (struct gpio_switch *) arg; -+ -+ schedule_work(&sw->work); -+} -+ -+static void gpio_sw_handler(struct work_struct *work) -+{ -+ struct gpio_switch *sw = container_of(work, struct gpio_switch, work); -+ int state; -+ -+ state = gpio_sw_get_state(sw); -+ if (sw->state == state) -+ return; -+ -+ sw->state = state; -+ if (sw->notify != NULL) -+ sw->notify(sw->notify_data, state); -+ sysfs_notify(&sw->pdev.dev.kobj, NULL, "state"); -+ print_sw_state(sw, state); -+} -+ -+static int __init can_do_both_edges(struct gpio_switch *sw) -+{ -+ if (!cpu_class_is_omap1()) -+ return 1; -+ if (OMAP_GPIO_IS_MPUIO(sw->gpio)) -+ return 0; -+ else -+ return 1; -+} -+ -+static void gpio_sw_release(struct device *dev) -+{ -+} -+ -+static int __init new_switch(struct gpio_switch *sw) -+{ -+ int r, direction, trigger; -+ -+ switch (sw->type) { -+ case OMAP_GPIO_SWITCH_TYPE_COVER: -+ case OMAP_GPIO_SWITCH_TYPE_CONNECTION: -+ case OMAP_GPIO_SWITCH_TYPE_ACTIVITY: -+ break; -+ default: -+ printk(KERN_ERR "invalid GPIO switch type: %d\n", sw->type); -+ return -EINVAL; -+ } -+ -+ sw->pdev.name = sw->name; -+ sw->pdev.id = -1; -+ -+ sw->pdev.dev.parent = &gpio_sw_platform_dev->dev; -+ sw->pdev.dev.driver = &gpio_sw_driver.driver; -+ sw->pdev.dev.release = gpio_sw_release; -+ -+ r = platform_device_register(&sw->pdev); -+ if (r) { -+ printk(KERN_ERR "gpio-switch: platform device registration " -+ "failed for %s", sw->name); -+ return r; -+ } -+ dev_set_drvdata(&sw->pdev.dev, sw); -+ -+ r = gpio_request(sw->gpio, "gpio-switch"); -+ if (r < 0) { -+ platform_device_unregister(&sw->pdev); -+ return r; -+ } -+ -+ /* input: 1, output: 0 */ -+ direction = !(sw->flags & OMAP_GPIO_SWITCH_FLAG_OUTPUT); -+ if (direction) -+ gpio_direction_input(sw->gpio); -+ else -+ gpio_direction_output(sw->gpio, 0); -+ -+ sw->state = gpio_sw_get_state(sw); -+ -+ r = 0; -+ r |= device_create_file(&sw->pdev.dev, &dev_attr_state); -+ r |= device_create_file(&sw->pdev.dev, &dev_attr_type); -+ r |= device_create_file(&sw->pdev.dev, &dev_attr_direction); -+ if (r) -+ printk(KERN_ERR "gpio-switch: attribute file creation " -+ "failed for %s\n", sw->name); -+ -+ if (!direction) -+ return 0; -+ -+ if (can_do_both_edges(sw)) { -+ trigger = IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING; -+ sw->both_edges = 1; -+ } else { -+ if (gpio_get_value(sw->gpio)) -+ trigger = IRQF_TRIGGER_FALLING; -+ else -+ trigger = IRQF_TRIGGER_RISING; -+ } -+ r = request_irq(OMAP_GPIO_IRQ(sw->gpio), gpio_sw_irq_handler, -+ IRQF_SHARED | trigger, sw->name, sw); -+ if (r < 0) { -+ printk(KERN_ERR "gpio-switch: request_irq() failed " -+ "for GPIO %d\n", sw->gpio); -+ platform_device_unregister(&sw->pdev); -+ gpio_free(sw->gpio); -+ return r; -+ } -+ -+ INIT_WORK(&sw->work, gpio_sw_handler); -+ init_timer(&sw->timer); -+ -+ sw->timer.function = gpio_sw_timer; -+ sw->timer.data = (unsigned long)sw; -+ -+ list_add(&sw->node, &gpio_switches); -+ -+ return 0; -+} -+ -+static int __init add_atag_switches(void) -+{ -+ const struct omap_gpio_switch_config *cfg; -+ struct gpio_switch *sw; -+ int i, r; -+ -+ for (i = 0; ; i++) { -+ cfg = omap_get_nr_config(OMAP_TAG_GPIO_SWITCH, -+ struct omap_gpio_switch_config, i); -+ if (cfg == NULL) -+ break; -+ sw = kzalloc(sizeof(*sw), GFP_KERNEL); -+ if (sw == NULL) { -+ printk(KERN_ERR "gpio-switch: kmalloc failed\n"); -+ return -ENOMEM; -+ } -+ strncpy(sw->name, cfg->name, sizeof(cfg->name)); -+ sw->gpio = cfg->gpio; -+ sw->flags = cfg->flags; -+ sw->type = cfg->type; -+ sw->debounce_rising = OMAP_GPIO_SW_DEFAULT_DEBOUNCE; -+ sw->debounce_falling = OMAP_GPIO_SW_DEFAULT_DEBOUNCE; -+ if ((r = new_switch(sw)) < 0) { -+ kfree(sw); -+ return r; -+ } -+ } -+ return 0; -+} -+ -+static struct gpio_switch * __init find_switch(int gpio, const char *name) -+{ -+ struct gpio_switch *sw; -+ -+ list_for_each_entry(sw, &gpio_switches, node) { -+ if ((gpio < 0 || sw->gpio != gpio) && -+ (name == NULL || strcmp(sw->name, name) != 0)) -+ continue; -+ -+ if (gpio < 0 || name == NULL) -+ goto no_check; -+ -+ if (strcmp(sw->name, name) != 0) -+ printk("gpio-switch: name mismatch for %d (%s, %s)\n", -+ gpio, name, sw->name); -+ else if (sw->gpio != gpio) -+ printk("gpio-switch: GPIO mismatch for %s (%d, %d)\n", -+ name, gpio, sw->gpio); -+no_check: -+ return sw; -+ } -+ return NULL; -+} -+ -+static int __init add_board_switches(void) -+{ -+ int i; -+ -+ for (i = 0; i < board_gpio_sw_count; i++) { -+ const struct omap_gpio_switch *cfg; -+ struct gpio_switch *sw; -+ int r; -+ -+ cfg = board_gpio_sw_table + i; -+ if (strlen(cfg->name) > sizeof(sw->name) - 1) -+ return -EINVAL; -+ /* Check whether we only update an existing switch -+ * or add a new switch. */ -+ sw = find_switch(cfg->gpio, cfg->name); -+ if (sw != NULL) { -+ sw->debounce_rising = cfg->debounce_rising; -+ sw->debounce_falling = cfg->debounce_falling; -+ sw->notify = cfg->notify; -+ sw->notify_data = cfg->notify_data; -+ continue; -+ } else { -+ if (cfg->gpio < 0 || cfg->name == NULL) { -+ printk("gpio-switch: required switch not " -+ "found (%d, %s)\n", cfg->gpio, -+ cfg->name); -+ continue; -+ } -+ } -+ sw = kzalloc(sizeof(*sw), GFP_KERNEL); -+ if (sw == NULL) { -+ printk(KERN_ERR "gpio-switch: kmalloc failed\n"); -+ return -ENOMEM; -+ } -+ strlcpy(sw->name, cfg->name, sizeof(sw->name)); -+ sw->gpio = cfg->gpio; -+ sw->flags = cfg->flags; -+ sw->type = cfg->type; -+ sw->debounce_rising = cfg->debounce_rising; -+ sw->debounce_falling = cfg->debounce_falling; -+ sw->notify = cfg->notify; -+ sw->notify_data = cfg->notify_data; -+ if ((r = new_switch(sw)) < 0) { -+ kfree(sw); -+ return r; -+ } -+ } -+ return 0; -+} -+ -+static void gpio_sw_cleanup(void) -+{ -+ struct gpio_switch *sw = NULL, *old = NULL; -+ -+ list_for_each_entry(sw, &gpio_switches, node) { -+ if (old != NULL) -+ kfree(old); -+ flush_scheduled_work(); -+ del_timer_sync(&sw->timer); -+ -+ free_irq(OMAP_GPIO_IRQ(sw->gpio), sw); -+ -+ device_remove_file(&sw->pdev.dev, &dev_attr_state); -+ device_remove_file(&sw->pdev.dev, &dev_attr_type); -+ device_remove_file(&sw->pdev.dev, &dev_attr_direction); -+ -+ platform_device_unregister(&sw->pdev); -+ gpio_free(sw->gpio); -+ old = sw; -+ } -+ kfree(old); -+} -+ -+static void __init report_initial_state(void) -+{ -+ struct gpio_switch *sw; -+ -+ list_for_each_entry(sw, &gpio_switches, node) { -+ int state; -+ -+ state = gpio_get_value(sw->gpio); -+ if (sw->flags & OMAP_GPIO_SWITCH_FLAG_INVERTED) -+ state = !state; -+ if (sw->notify != NULL) -+ sw->notify(sw->notify_data, state); -+ print_sw_state(sw, state); -+ } -+} -+ -+static int gpio_sw_remove(struct platform_device *dev) -+{ -+ return 0; -+} -+ -+static struct platform_driver gpio_sw_driver = { -+ .remove = gpio_sw_remove, -+ .driver = { -+ .name = "gpio-switch", -+ }, -+}; -+ -+void __init omap_register_gpio_switches(const struct omap_gpio_switch *tbl, -+ int count) -+{ -+ BUG_ON(board_gpio_sw_table != NULL); -+ -+ board_gpio_sw_table = tbl; -+ board_gpio_sw_count = count; -+} -+ -+static int __init gpio_sw_init(void) -+{ -+ int r; -+ -+ printk(KERN_INFO "OMAP GPIO switch handler initializing\n"); -+ -+ r = platform_driver_register(&gpio_sw_driver); -+ if (r) -+ return r; -+ -+ gpio_sw_platform_dev = platform_device_register_simple("gpio-switch", -+ -1, NULL, 0); -+ if (IS_ERR(gpio_sw_platform_dev)) { -+ r = PTR_ERR(gpio_sw_platform_dev); -+ goto err1; -+ } -+ -+ r = add_atag_switches(); -+ if (r < 0) -+ goto err2; -+ -+ r = add_board_switches(); -+ if (r < 0) -+ goto err2; -+ -+ report_initial_state(); -+ -+ return 0; -+err2: -+ gpio_sw_cleanup(); -+ platform_device_unregister(gpio_sw_platform_dev); -+err1: -+ platform_driver_unregister(&gpio_sw_driver); -+ return r; -+} -+ -+static void __exit gpio_sw_exit(void) -+{ -+ gpio_sw_cleanup(); -+ platform_device_unregister(gpio_sw_platform_dev); -+ platform_driver_unregister(&gpio_sw_driver); -+} -+ -+#ifndef MODULE -+late_initcall(gpio_sw_init); -+#else -+module_init(gpio_sw_init); -+#endif -+module_exit(gpio_sw_exit); -+ -+MODULE_AUTHOR("Juha Yrjölä <juha.yrjola@nokia.com>, Paul Mundt <paul.mundt@nokia.com"); -+MODULE_DESCRIPTION("GPIO switch driver"); -+MODULE_LICENSE("GPL"); ---- a/arch/arm/plat-omap/include/plat/board.h -+++ b/arch/arm/plat-omap/include/plat/board.h -@@ -151,6 +151,14 @@ struct omap_board_config_kernel { - const void *data; - }; - -+struct omap_gpio_switch_config { -+ char name[12]; -+ u16 gpio; -+ int flags:4; -+ int type:4; -+ int key_code:24; /* Linux key code */ -+}; -+ - extern const void *__omap_get_config(u16 tag, size_t len, int nr); - - #define omap_get_config(tag, type) \ diff --git a/target/linux/omap24xx/patches-2.6.38/300-nokia-board.patch b/target/linux/omap24xx/patches-2.6.38/300-nokia-board.patch deleted file mode 100644 index e292c21c86..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/300-nokia-board.patch +++ /dev/null @@ -1,195 +0,0 @@ ---- a/arch/arm/mach-omap2/board-n8x0.c -+++ b/arch/arm/mach-omap2/board-n8x0.c -@@ -15,8 +15,10 @@ - #include <linux/delay.h> - #include <linux/gpio.h> - #include <linux/init.h> -+#include <linux/irq.h> - #include <linux/io.h> - #include <linux/stddef.h> -+#include <linux/platform_device.h> - #include <linux/i2c.h> - #include <linux/spi/spi.h> - #include <linux/usb/musb.h> -@@ -33,6 +35,7 @@ - #include <plat/onenand.h> - #include <plat/mmc.h> - #include <plat/serial.h> -+#include <plat/cbus.h> - - #include "mux.h" - -@@ -194,6 +197,114 @@ static struct omap_onenand_platform_data - }; - #endif - -+#if defined(CONFIG_CBUS) || defined(CONFIG_CBUS_MODULE) -+ -+static struct cbus_host_platform_data n8x0_cbus_data = { -+ .clk_gpio = 66, -+ .dat_gpio = 65, -+ .sel_gpio = 64, -+}; -+ -+static struct platform_device n8x0_cbus_device = { -+ .name = "cbus", -+ .id = -1, -+ .dev = { -+ .platform_data = &n8x0_cbus_data, -+ }, -+}; -+ -+static struct resource retu_resource[] = { -+ { -+ .start = -EINVAL, /* set later */ -+ .flags = IORESOURCE_IRQ, -+ }, -+}; -+ -+static struct cbus_retu_platform_data n8x0_retu_data = { -+ .irq_base = CBUS_RETU_IRQ_BASE, -+ .irq_end = CBUS_RETU_IRQ_END, -+ .devid = CBUS_RETU_DEVICE_ID, -+}; -+ -+static struct platform_device retu_device = { -+ .name = "retu", -+ .id = -1, -+ .resource = retu_resource, -+ .num_resources = ARRAY_SIZE(retu_resource), -+ .dev = { -+ .platform_data = &n8x0_retu_data, -+ }, -+}; -+ -+static struct resource tahvo_resource[] = { -+ { -+ .start = -EINVAL, /* set later */ -+ .flags = IORESOURCE_IRQ, -+ } -+}; -+ -+static struct platform_device tahvo_device = { -+ .name = "tahvo", -+ .id = -1, -+ .resource = tahvo_resource, -+ .num_resources = ARRAY_SIZE(tahvo_resource), -+}; -+ -+static struct platform_device tahvo_usb_device = { -+ .name = "tahvo-usb", -+ .id = -1, -+}; -+ -+static void __init n8x0_cbus_init(void) -+{ -+ int ret; -+ -+ platform_device_register(&n8x0_cbus_device); -+ -+ ret = gpio_request(108, "RETU irq"); -+ if (ret < 0) { -+ pr_err("retu: Unable to reserve IRQ GPIO\n"); -+ return; -+ } -+ -+ ret = gpio_direction_input(108); -+ if (ret < 0) { -+ pr_err("retu: Unable to change gpio direction\n"); -+ gpio_free(108); -+ return; -+ } -+ -+ set_irq_type(gpio_to_irq(108), IRQ_TYPE_EDGE_RISING); -+ retu_resource[0].start = gpio_to_irq(108); -+ platform_device_register(&retu_device); -+ -+ ret = gpio_request(111, "TAHVO irq"); -+ if (ret) { -+ pr_err("tahvo: Unable to reserve IRQ GPIO\n"); -+ gpio_free(108); -+ return; -+ } -+ -+ /* Set the pin as input */ -+ ret = gpio_direction_input(111); -+ if (ret) { -+ pr_err("tahvo: Unable to change direction\n"); -+ gpio_free(108); -+ gpio_free(111); -+ return; -+ } -+ -+ tahvo_resource[0].start = gpio_to_irq(111); -+ platform_device_register(&tahvo_device); -+ platform_device_register(&tahvo_usb_device); -+} -+ -+#else -+static inline void __init n8x0_cbus_init(void) -+{ -+} -+#endif -+ - #if defined(CONFIG_MENELAUS) && \ - (defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)) - -@@ -628,11 +739,10 @@ static void __init n8x0_map_io(void) - omap242x_map_common_io(); - } - --static void __init n8x0_init_irq(void) -+static void __init n8x0_init_early(void) - { - omap2_init_common_infrastructure(); - omap2_init_common_devices(NULL, NULL); -- omap_init_irq(); - } - - #ifdef CONFIG_OMAP_MUX -@@ -686,6 +796,8 @@ static inline void board_serial_init(voi - static void __init n8x0_init_machine(void) - { - omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC); -+ n8x0_cbus_init(); -+ - /* FIXME: add n810 spi devices */ - spi_register_board_info(n800_spi_board_info, - ARRAY_SIZE(n800_spi_board_info)); -@@ -703,27 +815,30 @@ static void __init n8x0_init_machine(voi - - MACHINE_START(NOKIA_N800, "Nokia N800") - .boot_params = 0x80000100, -- .map_io = n8x0_map_io, - .reserve = omap_reserve, -- .init_irq = n8x0_init_irq, -+ .map_io = n8x0_map_io, -+ .init_early = n8x0_init_early, -+ .init_irq = omap_init_irq, - .init_machine = n8x0_init_machine, - .timer = &omap_timer, - MACHINE_END - - MACHINE_START(NOKIA_N810, "Nokia N810") - .boot_params = 0x80000100, -- .map_io = n8x0_map_io, - .reserve = omap_reserve, -- .init_irq = n8x0_init_irq, -+ .map_io = n8x0_map_io, -+ .init_early = n8x0_init_early, -+ .init_irq = omap_init_irq, - .init_machine = n8x0_init_machine, - .timer = &omap_timer, - MACHINE_END - - MACHINE_START(NOKIA_N810_WIMAX, "Nokia N810 WiMAX") - .boot_params = 0x80000100, -- .map_io = n8x0_map_io, - .reserve = omap_reserve, -- .init_irq = n8x0_init_irq, -+ .map_io = n8x0_map_io, -+ .init_early = n8x0_init_early, -+ .init_irq = omap_init_irq, - .init_machine = n8x0_init_machine, - .timer = &omap_timer, - MACHINE_END diff --git a/target/linux/omap24xx/patches-2.6.38/301-nokia-board-additional.patch b/target/linux/omap24xx/patches-2.6.38/301-nokia-board-additional.patch deleted file mode 100644 index 6c2294fee9..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/301-nokia-board-additional.patch +++ /dev/null @@ -1,537 +0,0 @@ ---- a/arch/arm/mach-omap2/board-n8x0.c -+++ b/arch/arm/mach-omap2/board-n8x0.c -@@ -23,6 +23,9 @@ - #include <linux/spi/spi.h> - #include <linux/usb/musb.h> - #include <sound/tlv320aic3x.h> -+#include <linux/input.h> -+#include <linux/i2c/lm8323.h> -+#include <linux/spi/tsc2005.h> - - #include <asm/mach/arch.h> - #include <asm/mach-types.h> -@@ -36,6 +39,7 @@ - #include <plat/mmc.h> - #include <plat/serial.h> - #include <plat/cbus.h> -+#include <plat/gpio-switch.h> - - #include "mux.h" - -@@ -43,6 +47,221 @@ static int slot1_cover_open; - static int slot2_cover_open; - static struct device *mmc_device; - -+/* We map the FN key as LALT to workaround an X keycode problem. -+ * The XKB map needs to be adjusted to support this. */ -+#define MAP_FN_AS_LEFTALT -+ -+static s16 rx44_keymap[LM8323_KEYMAP_SIZE] = { -+ [0x01] = KEY_Q, -+ [0x02] = KEY_K, -+ [0x03] = KEY_O, -+ [0x04] = KEY_P, -+ [0x05] = KEY_BACKSPACE, -+ [0x06] = KEY_A, -+ [0x07] = KEY_S, -+ [0x08] = KEY_D, -+ [0x09] = KEY_F, -+ [0x0a] = KEY_G, -+ [0x0b] = KEY_H, -+ [0x0c] = KEY_J, -+ -+ [0x11] = KEY_W, -+ [0x12] = KEY_F4, -+ [0x13] = KEY_L, -+ [0x14] = KEY_APOSTROPHE, -+ [0x16] = KEY_Z, -+ [0x17] = KEY_X, -+ [0x18] = KEY_C, -+ [0x19] = KEY_V, -+ [0x1a] = KEY_B, -+ [0x1b] = KEY_N, -+ [0x1c] = KEY_LEFTSHIFT, /* Actually, this is both shift keys */ -+ [0x1f] = KEY_F7, -+ -+ [0x21] = KEY_E, -+ [0x22] = KEY_SEMICOLON, -+ [0x23] = KEY_MINUS, -+ [0x24] = KEY_EQUAL, -+#ifdef MAP_FN_AS_LEFTALT -+ [0x2b] = KEY_LEFTALT, -+#else -+ [0x2b] = KEY_FN, -+#endif -+ [0x2c] = KEY_M, -+ [0x2f] = KEY_F8, -+ -+ [0x31] = KEY_R, -+ [0x32] = KEY_RIGHTCTRL, -+ [0x34] = KEY_SPACE, -+ [0x35] = KEY_COMMA, -+ [0x37] = KEY_UP, -+ [0x3c] = KEY_COMPOSE, -+ [0x3f] = KEY_F6, -+ -+ [0x41] = KEY_T, -+ [0x44] = KEY_DOT, -+ [0x46] = KEY_RIGHT, -+ [0x4f] = KEY_F5, -+ [0x51] = KEY_Y, -+ [0x53] = KEY_DOWN, -+ [0x55] = KEY_ENTER, -+ [0x5f] = KEY_ESC, -+ -+ [0x61] = KEY_U, -+ [0x64] = KEY_LEFT, -+ -+ [0x71] = KEY_I, -+ [0x75] = KEY_KPENTER, -+}; -+ -+static struct lm8323_platform_data lm8323_pdata = { -+ .repeat = 0, /* Repeat is handled in userspace for now. */ -+ .keymap = rx44_keymap, -+ .size_x = 8, -+ .size_y = 12, -+ .debounce_time = 12, -+ .active_time = 500, -+ -+ .name = "Internal keyboard", -+ .pwm_names[0] = "n810::keyboard", -+ .pwm_names[1] = "n810::cover", -+}; -+ -+#define OMAP_TAG_NOKIA_BT 0x4e01 -+ -+struct omap_bluetooth_config { -+ u8 chip_type; -+ u8 bt_wakeup_gpio; -+ u8 host_wakeup_gpio; -+ u8 reset_gpio; -+ u8 bt_uart; -+ u8 bd_addr[6]; -+ u8 bt_sysclk; -+}; -+ -+static struct platform_device n8x0_bt_device = { -+ .name = "hci_h4p", -+ .id = -1, -+ .num_resources = 0, -+}; -+ -+void __init n8x0_bt_init(void) -+{ -+ const struct omap_bluetooth_config *bt_config; -+ -+ bt_config = (void *) omap_get_config(OMAP_TAG_NOKIA_BT, -+ struct omap_bluetooth_config); -+ n8x0_bt_device.dev.platform_data = (void *) bt_config; -+ if (platform_device_register(&n8x0_bt_device) < 0) -+ BUG(); -+} -+ -+#define RX51_TSC2005_RESET_GPIO 94 -+#define RX51_TSC2005_IRQ_GPIO 106 -+ -+#ifdef CONFIG_TOUCHSCREEN_TSC2005 -+static struct tsc2005_platform_data tsc2005_config; -+static void rx51_tsc2005_set_reset(bool enable) -+{ -+ gpio_set_value(RX51_TSC2005_RESET_GPIO, enable); -+} -+ -+static struct omap2_mcspi_device_config tsc2005_mcspi_config = { -+ .turbo_mode = 0, -+ .single_channel = 1, -+}; -+#endif -+ -+static void __init tsc2005_set_config(void) -+{ -+ const struct omap_lcd_config *conf; -+ -+ conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config); -+ if (conf != NULL) { -+#ifdef CONFIG_TOUCHSCREEN_TSC2005 -+ if (strcmp(conf->panel_name, "lph8923") == 0) { -+ tsc2005_config.ts_x_plate_ohm = 180; -+ tsc2005_config.ts_hw_avg = 0; -+ tsc2005_config.ts_ignore_last = 0; -+ tsc2005_config.ts_touch_pressure = 1500; -+ tsc2005_config.ts_stab_time = 100; -+ tsc2005_config.ts_pressure_max = 2048; -+ tsc2005_config.ts_pressure_fudge = 2; -+ tsc2005_config.ts_x_max = 4096; -+ tsc2005_config.ts_x_fudge = 4; -+ tsc2005_config.ts_y_max = 4096; -+ tsc2005_config.ts_y_fudge = 7; -+ tsc2005_config.set_reset = rx51_tsc2005_set_reset; -+ } else if (strcmp(conf->panel_name, "ls041y3") == 0) { -+ tsc2005_config.ts_x_plate_ohm = 280; -+ tsc2005_config.ts_hw_avg = 0; -+ tsc2005_config.ts_ignore_last = 0; -+ tsc2005_config.ts_touch_pressure = 1500; -+ tsc2005_config.ts_stab_time = 1000; -+ tsc2005_config.ts_pressure_max = 2048; -+ tsc2005_config.ts_pressure_fudge = 2; -+ tsc2005_config.ts_x_max = 4096; -+ tsc2005_config.ts_x_fudge = 4; -+ tsc2005_config.ts_y_max = 4096; -+ tsc2005_config.ts_y_fudge = 7; -+ tsc2005_config.set_reset = rx51_tsc2005_set_reset; -+ } else { -+ printk(KERN_ERR "Unknown panel type, set default " -+ "touchscreen configuration\n"); -+ tsc2005_config.ts_x_plate_ohm = 200; -+ tsc2005_config.ts_stab_time = 100; -+ } -+#endif -+ } -+} -+ -+static struct omap2_mcspi_device_config mipid_mcspi_config = { -+ .turbo_mode = 0, -+ .single_channel = 1, -+}; -+ -+extern struct mipid_platform_data n8x0_mipid_platform_data; -+ -+extern void n8x0_mipid_init(void); -+extern void n8x0_blizzard_init(void); -+ -+static struct omap_gpio_switch n8x0_gpio_switches[] __initdata = { -+ { -+ .name = "headphone", -+ .gpio = -1, -+ .debounce_rising = 200, -+ .debounce_falling = 200, -+ }, { -+ .name = "cam_act", -+ .gpio = -1, -+ .debounce_rising = 200, -+ .debounce_falling = 200, -+ }, { -+ .name = "cam_turn", -+ .gpio = -1, -+ .debounce_rising = 100, -+ .debounce_falling = 100, -+ }, { -+ .name = "slide", -+ .gpio = -1, -+ .debounce_rising = 200, -+ .debounce_falling = 200, -+ }, { -+ .name = "kb_lock", -+ .gpio = -1, -+ .debounce_rising = 200, -+ .debounce_falling = 200, -+ }, -+}; -+ -+static void __init n8x0_gpio_switches_init(void) -+{ -+ /* The switches are actually registered through ATAG mechanism. -+ * This just updates the parameters (thus .gpio is -1) */ -+ omap_register_gpio_switches(n8x0_gpio_switches, -+ ARRAY_SIZE(n8x0_gpio_switches)); -+} -+ - #define TUSB6010_ASYNC_CS 1 - #define TUSB6010_SYNC_CS 4 - #define TUSB6010_GPIO_INT 58 -@@ -146,12 +365,29 @@ static struct omap2_mcspi_device_config - - static struct spi_board_info n800_spi_board_info[] __initdata = { - { -+ .modalias = "lcd_mipid", -+ .bus_num = 1, -+ .chip_select = 1, -+ .max_speed_hz = 4000000, -+ .controller_data= &mipid_mcspi_config, -+ .platform_data = &n8x0_mipid_platform_data, -+ }, -+ { - .modalias = "p54spi", - .bus_num = 2, - .chip_select = 0, - .max_speed_hz = 48000000, - .controller_data = &p54spi_mcspi_config, - }, -+ { -+ .modalias = "tsc2005", -+ .bus_num = 1, -+ .chip_select = 0, -+ .irq = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO), -+ .max_speed_hz = 6000000, -+ .controller_data = &tsc2005_mcspi_config, -+ .platform_data = &tsc2005_config, -+ }, - }; - - #if defined(CONFIG_MTD_ONENAND_OMAP2) || \ -@@ -727,6 +963,11 @@ static struct aic3x_pdata n810_aic33_dat - }; - - static struct i2c_board_info n810_i2c_board_info_2[] __initdata = { -+ { -+ I2C_BOARD_INFO("lm8323", 0x45), -+ .irq = OMAP_GPIO_IRQ(109), -+ .platform_data = &lm8323_pdata, -+ }, - { - I2C_BOARD_INFO("tlv320aic3x", 0x18), - .platform_data = &n810_aic33_data, -@@ -796,9 +1037,12 @@ static inline void board_serial_init(voi - static void __init n8x0_init_machine(void) - { - omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC); -+ n8x0_gpio_switches_init(); - n8x0_cbus_init(); -+ n8x0_bt_init(); - - /* FIXME: add n810 spi devices */ -+ tsc2005_set_config(); - spi_register_board_info(n800_spi_board_info, - ARRAY_SIZE(n800_spi_board_info)); - omap_register_i2c_bus(1, 400, n8x0_i2c_board_info_1, -@@ -808,6 +1052,8 @@ static void __init n8x0_init_machine(voi - i2c_register_board_info(2, n810_i2c_board_info_2, - ARRAY_SIZE(n810_i2c_board_info_2)); - board_serial_init(); -+ n8x0_mipid_init(); -+ n8x0_blizzard_init(); - gpmc_onenand_init(board_onenand_data); - n8x0_mmc_init(); - n8x0_usb_init(); ---- /dev/null -+++ b/arch/arm/mach-omap2/board-n8x0-lcd.c -@@ -0,0 +1,141 @@ -+/* -+ * linux/arch/arm/mach-omap2/board-n8x0.c -+ * -+ * Copyright (C) 2005-2009 Nokia Corporation -+ * Author: Juha Yrjola <juha.yrjola@nokia.com> -+ * -+ * Modified from mach-omap2/board-generic.c -+ * -+ * 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/clk.h> -+#include <linux/delay.h> -+#include <linux/gpio.h> -+#include <linux/omapfb.h> -+ -+#include <plat/lcd_mipid.h> -+#include <plat/blizzard.h> -+ -+#include <../drivers/cbus/tahvo.h> -+ -+#define N8X0_BLIZZARD_POWERDOWN_GPIO 15 -+ -+// MIPID LCD Panel -+ -+static void mipid_shutdown(struct mipid_platform_data *pdata) -+{ -+ if (pdata->nreset_gpio != -1) { -+ pr_info("shutdown LCD\n"); -+ gpio_set_value(pdata->nreset_gpio, 0); -+ msleep(120); -+ } -+} -+ -+struct mipid_platform_data n8x0_mipid_platform_data = { -+ .shutdown = mipid_shutdown, -+}; -+ -+void __init n8x0_mipid_init(void) -+{ -+ const struct omap_lcd_config *conf; -+ int err; -+ -+ conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config); -+ if (conf != NULL) { -+ n8x0_mipid_platform_data.nreset_gpio = conf->nreset_gpio; -+ n8x0_mipid_platform_data.data_lines = conf->data_lines; -+ if (conf->nreset_gpio != -1) { -+ err = gpio_request(conf->nreset_gpio, "MIPID nreset"); -+ if (err) { -+ printk(KERN_ERR "N8x0 MIPID failed to request nreset GPIO %d\n", -+ conf->nreset_gpio); -+ } else { -+ err = gpio_direction_output(conf->nreset_gpio, 1); -+ if (err) { -+ printk(KERN_ERR "N8x0 MIPID failed to set nreset GPIO %d\n", -+ conf->nreset_gpio); -+ } -+ } -+ } -+ printk(KERN_INFO "N8x0 MIPID config loaded"); -+ } -+ else -+ printk(KERN_INFO "N8x0 MIPID config not provided"); -+} -+ -+ -+// Epson Blizzard LCD Controller -+ -+static struct { -+ struct clk *sys_ck; -+} blizzard; -+ -+static int blizzard_get_clocks(void) -+{ -+ blizzard.sys_ck = clk_get(0, "osc_ck"); -+ if (IS_ERR(blizzard.sys_ck)) { -+ printk(KERN_ERR "can't get Blizzard clock\n"); -+ return PTR_ERR(blizzard.sys_ck); -+ } -+ return 0; -+} -+ -+static unsigned long blizzard_get_clock_rate(struct device *dev) -+{ -+ return clk_get_rate(blizzard.sys_ck); -+} -+ -+static void blizzard_enable_clocks(int enable) -+{ -+ if (enable) -+ clk_enable(blizzard.sys_ck); -+ else -+ clk_disable(blizzard.sys_ck); -+} -+ -+static void blizzard_power_up(struct device *dev) -+{ -+ /* Vcore to 1.475V */ -+ tahvo_set_clear_reg_bits(0x07, 0, 0xf); -+ msleep(10); -+ -+ blizzard_enable_clocks(1); -+ gpio_set_value(N8X0_BLIZZARD_POWERDOWN_GPIO, 1); -+} -+ -+static void blizzard_power_down(struct device *dev) -+{ -+ gpio_set_value(N8X0_BLIZZARD_POWERDOWN_GPIO, 0); -+ blizzard_enable_clocks(0); -+ -+ /* Vcore to 1.005V */ -+ tahvo_set_clear_reg_bits(0x07, 0xf, 0); -+} -+ -+static struct blizzard_platform_data n8x0_blizzard_data = { -+ .power_up = blizzard_power_up, -+ .power_down = blizzard_power_down, -+ .get_clock_rate = blizzard_get_clock_rate, -+ .te_connected = 1, -+}; -+ -+void __init n8x0_blizzard_init(void) -+{ -+ int r; -+ -+ r = gpio_request(N8X0_BLIZZARD_POWERDOWN_GPIO, "Blizzard pd"); -+ if (r < 0) -+ { -+ printk(KERN_ERR "Can't get N8x0 Blizzard powerdown GPIO %d\n", N8X0_BLIZZARD_POWERDOWN_GPIO); -+ return; -+ } -+ gpio_direction_output(N8X0_BLIZZARD_POWERDOWN_GPIO, 1); -+ -+ blizzard_get_clocks(); -+ omapfb_set_ctrl_platform_data(&n8x0_blizzard_data); -+ -+ printk(KERN_INFO "N8x0 Blizzard initialized"); -+} ---- a/arch/arm/mach-omap2/Makefile -+++ b/arch/arm/mach-omap2/Makefile -@@ -177,6 +177,7 @@ obj-$(CONFIG_MACH_OMAP_3430SDP) += boar - hsmmc.o \ - board-flash.o - obj-$(CONFIG_MACH_NOKIA_N8X0) += board-n8x0.o -+obj-$(CONFIG_MACH_NOKIA_N8X0) += board-n8x0-lcd.o - obj-$(CONFIG_MACH_NOKIA_RM680) += board-rm680.o \ - sdram-nokia.o \ - hsmmc.o ---- /dev/null -+++ b/arch/arm/plat-omap/include/plat/cbus.h -@@ -0,0 +1,40 @@ -+/* -+ * cbus.h - CBUS platform_data definition -+ * -+ * Copyright (C) 2004 - 2009 Nokia Corporation -+ * -+ * Written by Felipe Balbi <felipe.balbi@nokia.com> -+ * -+ * This file is subject to the terms and conditions of the GNU General -+ * Public License. See the file "COPYING" in the main directory of this -+ * archive for more details. -+ * -+ * 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 -+ */ -+ -+#ifndef __PLAT_CBUS_H -+#define __PLAT_CBUS_H -+ -+#define CBUS_RETU_DEVICE_ID 0x01 -+#define CBUS_TAHVO_DEVICE_ID 0x02 -+ -+struct cbus_host_platform_data { -+ int dat_gpio; -+ int clk_gpio; -+ int sel_gpio; -+}; -+ -+struct cbus_retu_platform_data { -+ int irq_base; -+ int irq_end; -+ int devid; -+}; -+ -+#endif /* __PLAT_CBUS_H */ ---- a/arch/arm/plat-omap/include/plat/irqs.h -+++ b/arch/arm/plat-omap/include/plat/irqs.h -@@ -411,7 +411,20 @@ - #define TWL_IRQ_END TWL6030_IRQ_END - #endif - --#define NR_IRQS TWL_IRQ_END -+/* GPMC related */ -+#define OMAP_GPMC_IRQ_BASE (TWL_IRQ_END) -+#define OMAP_GPMC_NR_IRQS 7 -+#define OMAP_GPMC_IRQ_END (OMAP_GPMC_IRQ_BASE + OMAP_GPMC_NR_IRQS) -+ -+#define CBUS_RETU_IRQ_BASE OMAP_GPMC_IRQ_END -+#ifdef CONFIG_CBUS_RETU -+#define CBUS_RETU_NR_IRQS 16 -+#else -+#define CBUS_RETU_NR_IRQS 0 -+#endif -+#define CBUS_RETU_IRQ_END (CBUS_RETU_IRQ_BASE + CBUS_RETU_NR_IRQS) -+ -+#define NR_IRQS CBUS_RETU_IRQ_END - - #define OMAP_IRQ_BIT(irq) (1 << ((irq) % 32)) - ---- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c -+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c -@@ -673,6 +673,7 @@ static struct omap_hwmod_ocp_if *omap242 - - static struct omap_hwmod omap2420_gpio1_hwmod = { - .name = "gpio1", -+ .flags = HWMOD_INIT_NO_RESET, /* Workaround: Don't reset the n810 MIPID */ - .mpu_irqs = omap242x_gpio1_irqs, - .mpu_irqs_cnt = ARRAY_SIZE(omap242x_gpio1_irqs), - .main_clk = "gpios_fck", diff --git a/target/linux/omap24xx/patches-2.6.38/310-n8x0-gpioswitch-input.patch b/target/linux/omap24xx/patches-2.6.38/310-n8x0-gpioswitch-input.patch deleted file mode 100644 index 30a169f536..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/310-n8x0-gpioswitch-input.patch +++ /dev/null @@ -1,98 +0,0 @@ ---- - arch/arm/mach-omap2/board-n8x0.c | 73 +++++++++++++++++++++++++++++++++++++++ - 1 file changed, 73 insertions(+) - ---- a/arch/arm/mach-omap2/board-n8x0.c -+++ b/arch/arm/mach-omap2/board-n8x0.c -@@ -225,6 +225,77 @@ extern struct mipid_platform_data n8x0_m - extern void n8x0_mipid_init(void); - extern void n8x0_blizzard_init(void); - -+struct gpio_switch_input_dev { -+ struct input_dev *idev; -+ unsigned int swcode; -+}; -+ -+static struct gpio_switch_input_dev *slide_input; -+static struct gpio_switch_input_dev *kblock_input; -+ -+static void n8x0_gpio_switch_input_notify(struct gpio_switch_input_dev *gdev, -+ int state) -+{ -+ if (gdev) { -+ input_report_switch(gdev->idev, gdev->swcode, state); -+ input_sync(gdev->idev); -+ } -+} -+ -+static void n8x0_slide_notify(void *data, int state) -+{ -+ n8x0_gpio_switch_input_notify(slide_input, state); -+} -+ -+static void n8x0_kb_lock_notify(void *data, int state) -+{ -+ n8x0_gpio_switch_input_notify(kblock_input, state); -+} -+ -+static struct gpio_switch_input_dev * __init gpioswitch_input_init( -+ const char *name, -+ unsigned int swcode) -+{ -+ struct gpio_switch_input_dev *gdev; -+ int err; -+ -+ gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); -+ if (!gdev) -+ goto error; -+ gdev->swcode = swcode; -+ -+ gdev->idev = input_allocate_device(); -+ if (!gdev->idev) -+ goto err_free; -+ -+ gdev->idev->evbit[0] = BIT_MASK(EV_SW); -+ gdev->idev->swbit[BIT_WORD(swcode)] = BIT_MASK(swcode); -+ gdev->idev->name = name; -+ -+ err = input_register_device(gdev->idev); -+ if (err) -+ goto err_free_idev; -+ -+ return gdev; -+ -+err_free_idev: -+ input_free_device(gdev->idev); -+err_free: -+ kfree(gdev); -+error: -+ return NULL; -+} -+ -+static int __init n8x0_gpio_switches_input_init(void) -+{ -+ slide_input = gpioswitch_input_init("slide", SW_KEYPAD_SLIDE); -+ kblock_input = gpioswitch_input_init("kb_lock", SW_LID); -+ if (WARN_ON(!slide_input || !kblock_input)) -+ return -ENODEV; -+ return 0; -+} -+late_initcall(n8x0_gpio_switches_input_init); -+ - static struct omap_gpio_switch n8x0_gpio_switches[] __initdata = { - { - .name = "headphone", -@@ -246,11 +317,13 @@ static struct omap_gpio_switch n8x0_gpio - .gpio = -1, - .debounce_rising = 200, - .debounce_falling = 200, -+ .notify = n8x0_slide_notify, - }, { - .name = "kb_lock", - .gpio = -1, - .debounce_rising = 200, - .debounce_falling = 200, -+ .notify = n8x0_kb_lock_notify, - }, - }; - diff --git a/target/linux/omap24xx/patches-2.6.38/400-bluetooth-hci_h4p.patch b/target/linux/omap24xx/patches-2.6.38/400-bluetooth-hci_h4p.patch deleted file mode 100644 index 408da4a3a0..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/400-bluetooth-hci_h4p.patch +++ /dev/null @@ -1,1946 +0,0 @@ ---- - drivers/bluetooth/Kconfig | 10 - drivers/bluetooth/Makefile | 1 - drivers/bluetooth/hci_h4p/Makefile | 7 - drivers/bluetooth/hci_h4p/core.c | 1043 ++++++++++++++++++++++++++++++++++++ - drivers/bluetooth/hci_h4p/fw-csr.c | 149 +++++ - drivers/bluetooth/hci_h4p/fw-ti.c | 90 +++ - drivers/bluetooth/hci_h4p/fw.c | 155 +++++ - drivers/bluetooth/hci_h4p/hci_h4p.h | 183 ++++++ - drivers/bluetooth/hci_h4p/sysfs.c | 84 ++ - drivers/bluetooth/hci_h4p/uart.c | 169 +++++ - 10 files changed, 1891 insertions(+) - ---- /dev/null -+++ b/drivers/bluetooth/hci_h4p/core.c -@@ -0,0 +1,1043 @@ -+/* -+ * This file is part of hci_h4p bluetooth driver -+ * -+ * Copyright (C) 2005, 2006 Nokia Corporation. -+ * -+ * Contact: Ville Tervo <ville.tervo@nokia.com> -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * version 2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -+ * 02110-1301 USA -+ * -+ */ -+ -+#include <linux/module.h> -+ -+#include <linux/kernel.h> -+#include <linux/init.h> -+#include <linux/errno.h> -+#include <linux/delay.h> -+#include <linux/spinlock.h> -+#include <linux/serial_reg.h> -+#include <linux/skbuff.h> -+#include <linux/timer.h> -+#include <linux/device.h> -+#include <linux/platform_device.h> -+#include <linux/clk.h> -+#include <linux/gpio.h> -+ -+#include <mach/hardware.h> -+#include <mach/board.h> -+#include <mach/irqs.h> -+#include <plat/serial.h> -+ -+#include <net/bluetooth/bluetooth.h> -+#include <net/bluetooth/hci_core.h> -+#include <net/bluetooth/hci.h> -+ -+#include "hci_h4p.h" -+ -+#define PM_TIMEOUT 200 -+ -+struct omap_bluetooth_config { -+ u8 chip_type; -+ u8 bt_wakeup_gpio; -+ u8 host_wakeup_gpio; -+ u8 reset_gpio; -+ u8 bt_uart; -+ u8 bd_addr[6]; -+ u8 bt_sysclk; -+}; -+ -+/* This should be used in function that cannot release clocks */ -+static void hci_h4p_set_clk(struct hci_h4p_info *info, int *clock, int enable) -+{ -+ unsigned long flags; -+ -+ spin_lock_irqsave(&info->clocks_lock, flags); -+ if (enable && !*clock) { -+ NBT_DBG_POWER("Enabling %p\n", clock); -+ clk_enable(info->uart_fclk); -+#ifdef CONFIG_ARCH_OMAP2 -+ if (cpu_is_omap24xx()) { -+ clk_enable(info->uart_iclk); -+ //omap2_block_sleep(); -+ } -+#endif -+ } -+ if (!enable && *clock) { -+ NBT_DBG_POWER("Disabling %p\n", clock); -+ clk_disable(info->uart_fclk); -+#ifdef CONFIG_ARCH_OMAP2 -+ if (cpu_is_omap24xx()) { -+ clk_disable(info->uart_iclk); -+ //omap2_allow_sleep(); -+ } -+#endif -+ } -+ -+ *clock = enable; -+ spin_unlock_irqrestore(&info->clocks_lock, flags); -+} -+ -+/* Power management functions */ -+static void hci_h4p_disable_tx(struct hci_h4p_info *info) -+{ -+ NBT_DBG_POWER("\n"); -+ -+ if (!info->pm_enabled) -+ return; -+ -+ mod_timer(&info->tx_pm_timer, jiffies + msecs_to_jiffies(PM_TIMEOUT)); -+} -+ -+static void hci_h4p_enable_tx(struct hci_h4p_info *info) -+{ -+ NBT_DBG_POWER("\n"); -+ -+ if (!info->pm_enabled) -+ return; -+ -+ del_timer_sync(&info->tx_pm_timer); -+ if (info->tx_pm_enabled) { -+ info->tx_pm_enabled = 0; -+ hci_h4p_set_clk(info, &info->tx_clocks_en, 1); -+ gpio_set_value(info->bt_wakeup_gpio, 1); -+ } -+} -+ -+static void hci_h4p_tx_pm_timer(unsigned long data) -+{ -+ struct hci_h4p_info *info; -+ -+ NBT_DBG_POWER("\n"); -+ -+ info = (struct hci_h4p_info *)data; -+ -+ if (hci_h4p_inb(info, UART_LSR) & UART_LSR_TEMT) { -+ gpio_set_value(info->bt_wakeup_gpio, 0); -+ hci_h4p_set_clk(info, &info->tx_clocks_en, 0); -+ info->tx_pm_enabled = 1; -+ } -+ else { -+ mod_timer(&info->tx_pm_timer, jiffies + msecs_to_jiffies(PM_TIMEOUT)); -+ } -+} -+ -+static void hci_h4p_disable_rx(struct hci_h4p_info *info) -+{ -+ if (!info->pm_enabled) -+ return; -+ -+ mod_timer(&info->rx_pm_timer, jiffies + msecs_to_jiffies(PM_TIMEOUT)); -+} -+ -+static void hci_h4p_enable_rx(struct hci_h4p_info *info) -+{ -+ unsigned long flags; -+ -+ if (!info->pm_enabled) -+ return; -+ -+ del_timer_sync(&info->rx_pm_timer); -+ spin_lock_irqsave(&info->lock, flags); -+ if (info->rx_pm_enabled) { -+ hci_h4p_set_clk(info, &info->rx_clocks_en, 1); -+ hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) | UART_IER_RDI); -+ __hci_h4p_set_auto_ctsrts(info, 1, UART_EFR_RTS); -+ info->rx_pm_enabled = 0; -+ } -+ spin_unlock_irqrestore(&info->lock, flags); -+} -+ -+static void hci_h4p_rx_pm_timer(unsigned long data) -+{ -+ unsigned long flags; -+ struct hci_h4p_info *info = (struct hci_h4p_info *)data; -+ -+ spin_lock_irqsave(&info->lock, flags); -+ if (!(hci_h4p_inb(info, UART_LSR) & UART_LSR_DR)) { -+ __hci_h4p_set_auto_ctsrts(info, 0, UART_EFR_RTS); -+ hci_h4p_set_rts(info, 0); -+ hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) & ~UART_IER_RDI); -+ hci_h4p_set_clk(info, &info->rx_clocks_en, 0); -+ info->rx_pm_enabled = 1; -+ } -+ else { -+ mod_timer(&info->rx_pm_timer, jiffies + msecs_to_jiffies(PM_TIMEOUT)); -+ } -+ spin_unlock_irqrestore(&info->lock, flags); -+} -+ -+/* Negotiation functions */ -+int hci_h4p_send_alive_packet(struct hci_h4p_info *info) -+{ -+ NBT_DBG("Sending alive packet\n"); -+ -+ if (!info->alive_cmd_skb) -+ return -EINVAL; -+ -+ /* Keep reference to buffer so we can reuse it */ -+ info->alive_cmd_skb = skb_get(info->alive_cmd_skb); -+ -+ skb_queue_tail(&info->txq, info->alive_cmd_skb); -+ tasklet_schedule(&info->tx_task); -+ -+ NBT_DBG("Alive packet sent\n"); -+ -+ return 0; -+} -+ -+static void hci_h4p_alive_packet(struct hci_h4p_info *info, struct sk_buff *skb) -+{ -+ NBT_DBG("Received alive packet\n"); -+ if (skb->data[1] == 0xCC) { -+ complete(&info->init_completion); -+ } -+ -+ kfree_skb(skb); -+} -+ -+static int hci_h4p_send_negotiation(struct hci_h4p_info *info, struct sk_buff *skb) -+{ -+ NBT_DBG("Sending negotiation..\n"); -+ -+ hci_h4p_change_speed(info, INIT_SPEED); -+ -+ info->init_error = 0; -+ init_completion(&info->init_completion); -+ skb_queue_tail(&info->txq, skb); -+ tasklet_schedule(&info->tx_task); -+ -+ if (!wait_for_completion_interruptible_timeout(&info->init_completion, -+ msecs_to_jiffies(1000))) -+ return -ETIMEDOUT; -+ -+ NBT_DBG("Negotiation sent\n"); -+ return info->init_error; -+} -+ -+static void hci_h4p_negotiation_packet(struct hci_h4p_info *info, -+ struct sk_buff *skb) -+{ -+ int err = 0; -+ -+ if (skb->data[1] == 0x20) { -+ /* Change to operational settings */ -+ hci_h4p_set_rts(info, 0); -+ -+ err = hci_h4p_wait_for_cts(info, 0, 100); -+ if (err < 0) -+ goto neg_ret; -+ -+ hci_h4p_change_speed(info, MAX_BAUD_RATE); -+ -+ err = hci_h4p_wait_for_cts(info, 1, 100); -+ if (err < 0) -+ goto neg_ret; -+ -+ hci_h4p_set_auto_ctsrts(info, 1, UART_EFR_CTS | UART_EFR_RTS); -+ -+ err = hci_h4p_send_alive_packet(info); -+ if (err < 0) -+ goto neg_ret; -+ } else { -+ dev_err(info->dev, "Could not negotiate hci_h4p settings\n"); -+ err = -EINVAL; -+ goto neg_ret; -+ } -+ -+ kfree_skb(skb); -+ return; -+ -+neg_ret: -+ info->init_error = err; -+ complete(&info->init_completion); -+ kfree_skb(skb); -+} -+ -+/* H4 packet handling functions */ -+static int hci_h4p_get_hdr_len(struct hci_h4p_info *info, u8 pkt_type) -+{ -+ long retval; -+ -+ switch (pkt_type) { -+ case H4_EVT_PKT: -+ retval = HCI_EVENT_HDR_SIZE; -+ break; -+ case H4_ACL_PKT: -+ retval = HCI_ACL_HDR_SIZE; -+ break; -+ case H4_SCO_PKT: -+ retval = HCI_SCO_HDR_SIZE; -+ break; -+ case H4_NEG_PKT: -+ retval = 11; -+ break; -+ case H4_ALIVE_PKT: -+ retval = 3; -+ break; -+ default: -+ dev_err(info->dev, "Unknown H4 packet type 0x%.2x\n", pkt_type); -+ retval = -1; -+ break; -+ } -+ -+ return retval; -+} -+ -+static unsigned int hci_h4p_get_data_len(struct hci_h4p_info *info, -+ struct sk_buff *skb) -+{ -+ long retval = -1; -+ struct hci_event_hdr *evt_hdr; -+ struct hci_acl_hdr *acl_hdr; -+ struct hci_sco_hdr *sco_hdr; -+ -+ switch (bt_cb(skb)->pkt_type) { -+ case H4_EVT_PKT: -+ evt_hdr = (struct hci_event_hdr *)skb->data; -+ retval = evt_hdr->plen; -+ break; -+ case H4_ACL_PKT: -+ acl_hdr = (struct hci_acl_hdr *)skb->data; -+ retval = le16_to_cpu(acl_hdr->dlen); -+ break; -+ case H4_SCO_PKT: -+ sco_hdr = (struct hci_sco_hdr *)skb->data; -+ retval = sco_hdr->dlen; -+ break; -+ case H4_NEG_PKT: -+ retval = 0; -+ break; -+ case H4_ALIVE_PKT: -+ retval = 0; -+ break; -+ } -+ -+ return retval; -+} -+ -+static inline void hci_h4p_recv_frame(struct hci_h4p_info *info, -+ struct sk_buff *skb) -+{ -+ -+ if (unlikely(!test_bit(HCI_RUNNING, &info->hdev->flags))) { -+ NBT_DBG("fw_event\n"); -+ hci_h4p_parse_fw_event(info, skb); -+ } else { -+ hci_recv_frame(skb); -+ NBT_DBG("Frame sent to upper layer\n"); -+ } -+} -+ -+static void hci_h4p_rx_tasklet(unsigned long data) -+{ -+ u8 byte; -+ unsigned long flags; -+ struct hci_h4p_info *info = (struct hci_h4p_info *)data; -+ -+ NBT_DBG("tasklet woke up\n"); -+ NBT_DBG_TRANSFER("rx_tasklet woke up\ndata "); -+ -+ while (hci_h4p_inb(info, UART_LSR) & UART_LSR_DR) { -+ byte = hci_h4p_inb(info, UART_RX); -+ if (info->garbage_bytes) { -+ info->garbage_bytes--; -+ continue; -+ } -+ if (info->rx_skb == NULL) { -+ info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC | GFP_DMA); -+ if (!info->rx_skb) { -+ dev_err(info->dev, "Can't allocate memory for new packet\n"); -+ goto finish_task; -+ } -+ info->rx_state = WAIT_FOR_PKT_TYPE; -+ info->rx_skb->dev = (void *)info->hdev; -+ } -+ info->hdev->stat.byte_rx++; -+ NBT_DBG_TRANSFER_NF("0x%.2x ", byte); -+ switch (info->rx_state) { -+ case WAIT_FOR_PKT_TYPE: -+ bt_cb(info->rx_skb)->pkt_type = byte; -+ info->rx_count = hci_h4p_get_hdr_len(info, byte); -+ if (info->rx_count < 0) { -+ info->hdev->stat.err_rx++; -+ kfree_skb(info->rx_skb); -+ info->rx_skb = NULL; -+ } else { -+ info->rx_state = WAIT_FOR_HEADER; -+ } -+ break; -+ case WAIT_FOR_HEADER: -+ info->rx_count--; -+ *skb_put(info->rx_skb, 1) = byte; -+ if (info->rx_count == 0) { -+ info->rx_count = hci_h4p_get_data_len(info, info->rx_skb); -+ if (info->rx_count > skb_tailroom(info->rx_skb)) { -+ dev_err(info->dev, "Frame is %ld bytes too long.\n", -+ info->rx_count - skb_tailroom(info->rx_skb)); -+ kfree_skb(info->rx_skb); -+ info->rx_skb = NULL; -+ info->garbage_bytes = info->rx_count - skb_tailroom(info->rx_skb); -+ break; -+ } -+ info->rx_state = WAIT_FOR_DATA; -+ -+ if (bt_cb(info->rx_skb)->pkt_type == H4_NEG_PKT) { -+ hci_h4p_negotiation_packet(info, info->rx_skb); -+ info->rx_skb = NULL; -+ info->rx_state = WAIT_FOR_PKT_TYPE; -+ goto finish_task; -+ } -+ if (bt_cb(info->rx_skb)->pkt_type == H4_ALIVE_PKT) { -+ hci_h4p_alive_packet(info, info->rx_skb); -+ info->rx_skb = NULL; -+ info->rx_state = WAIT_FOR_PKT_TYPE; -+ goto finish_task; -+ } -+ } -+ break; -+ case WAIT_FOR_DATA: -+ info->rx_count--; -+ *skb_put(info->rx_skb, 1) = byte; -+ if (info->rx_count == 0) { -+ /* H4+ devices should allways send word aligned packets */ -+ if (!(info->rx_skb->len % 2)) { -+ info->garbage_bytes++; -+ } -+ hci_h4p_recv_frame(info, info->rx_skb); -+ info->rx_skb = NULL; -+ } -+ break; -+ default: -+ WARN_ON(1); -+ break; -+ } -+ } -+ -+finish_task: -+ spin_lock_irqsave(&info->lock, flags); -+ hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) | UART_IER_RDI); -+ spin_unlock_irqrestore(&info->lock, flags); -+ -+ NBT_DBG_TRANSFER_NF("\n"); -+ NBT_DBG("rx_ended\n"); -+} -+ -+static void hci_h4p_tx_tasklet(unsigned long data) -+{ -+ unsigned int sent = 0; -+ unsigned long flags; -+ struct sk_buff *skb; -+ struct hci_h4p_info *info = (struct hci_h4p_info *)data; -+ -+ NBT_DBG("tasklet woke up\n"); -+ NBT_DBG_TRANSFER("tx_tasklet woke up\n data "); -+ -+ skb = skb_dequeue(&info->txq); -+ if (!skb) { -+ /* No data in buffer */ -+ NBT_DBG("skb ready\n"); -+ hci_h4p_disable_tx(info); -+ return; -+ } -+ -+ /* Copy data to tx fifo */ -+ while (!(hci_h4p_inb(info, UART_OMAP_SSR) & UART_OMAP_SSR_TXFULL) && -+ (sent < skb->len)) { -+ NBT_DBG_TRANSFER_NF("0x%.2x ", skb->data[sent]); -+ hci_h4p_outb(info, UART_TX, skb->data[sent]); -+ sent++; -+ } -+ -+ info->hdev->stat.byte_tx += sent; -+ NBT_DBG_TRANSFER_NF("\n"); -+ if (skb->len == sent) { -+ kfree_skb(skb); -+ } else { -+ skb_pull(skb, sent); -+ skb_queue_head(&info->txq, skb); -+ } -+ -+ spin_lock_irqsave(&info->lock, flags); -+ hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) | UART_IER_THRI); -+ spin_unlock_irqrestore(&info->lock, flags); -+} -+ -+static irqreturn_t hci_h4p_interrupt(int irq, void *data) -+{ -+ struct hci_h4p_info *info = (struct hci_h4p_info *)data; -+ u8 iir, msr; -+ int ret; -+ unsigned long flags; -+ -+ ret = IRQ_NONE; -+ -+ iir = hci_h4p_inb(info, UART_IIR); -+ if (iir & UART_IIR_NO_INT) { -+ dev_err(info->dev, "Interrupt but no reason irq 0x%.2x\n", iir); -+ return IRQ_HANDLED; -+ } -+ -+ NBT_DBG("In interrupt handler iir 0x%.2x\n", iir); -+ -+ iir &= UART_IIR_ID; -+ -+ if (iir == UART_IIR_MSI) { -+ msr = hci_h4p_inb(info, UART_MSR); -+ ret = IRQ_HANDLED; -+ } -+ if (iir == UART_IIR_RLSI) { -+ hci_h4p_inb(info, UART_RX); -+ hci_h4p_inb(info, UART_LSR); -+ ret = IRQ_HANDLED; -+ } -+ -+ if (iir == UART_IIR_RDI) { -+ spin_lock_irqsave(&info->lock, flags); -+ hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) & ~UART_IER_RDI); -+ spin_unlock_irqrestore(&info->lock, flags); -+ tasklet_schedule(&info->rx_task); -+ ret = IRQ_HANDLED; -+ } -+ -+ if (iir == UART_IIR_THRI) { -+ spin_lock_irqsave(&info->lock, flags); -+ hci_h4p_outb(info, UART_IER, hci_h4p_inb(info, UART_IER) & ~UART_IER_THRI); -+ spin_unlock_irqrestore(&info->lock, flags); -+ tasklet_schedule(&info->tx_task); -+ ret = IRQ_HANDLED; -+ } -+ -+ return ret; -+} -+ -+static irqreturn_t hci_h4p_wakeup_interrupt(int irq, void *dev_inst) -+{ -+ struct hci_h4p_info *info = dev_inst; -+ int should_wakeup; -+ struct hci_dev *hdev; -+ -+ if (!info->hdev) -+ return IRQ_HANDLED; -+ -+ hdev = info->hdev; -+ -+ if (!test_bit(HCI_RUNNING, &hdev->flags)) -+ return IRQ_HANDLED; -+ -+ should_wakeup = gpio_get_value(info->host_wakeup_gpio); -+ NBT_DBG_POWER("gpio interrupt %d\n", should_wakeup); -+ if (should_wakeup) { -+ hci_h4p_enable_rx(info); -+ } else { -+ hci_h4p_disable_rx(info); -+ } -+ -+ return IRQ_HANDLED; -+} -+ -+static int hci_h4p_reset(struct hci_h4p_info *info) -+{ -+ int err; -+ -+ hci_h4p_init_uart(info); -+ hci_h4p_set_rts(info, 0); -+ -+ gpio_set_value(info->reset_gpio, 0); -+ msleep(100); -+ gpio_set_value(info->bt_wakeup_gpio, 1); -+ gpio_set_value(info->reset_gpio, 1); -+ msleep(100); -+ -+ err = hci_h4p_wait_for_cts(info, 1, 10); -+ if (err < 0) { -+ dev_err(info->dev, "No cts from bt chip\n"); -+ return err; -+ } -+ -+ hci_h4p_set_rts(info, 1); -+ -+ return 0; -+} -+ -+/* hci callback functions */ -+static int hci_h4p_hci_flush(struct hci_dev *hdev) -+{ -+ struct hci_h4p_info *info; -+ info = hdev->driver_data; -+ -+ skb_queue_purge(&info->txq); -+ -+ return 0; -+} -+ -+static int hci_h4p_hci_open(struct hci_dev *hdev) -+{ -+ struct hci_h4p_info *info; -+ int err; -+ struct sk_buff *neg_cmd_skb; -+ struct sk_buff_head fw_queue; -+ -+ info = hdev->driver_data; -+ -+ if (test_bit(HCI_RUNNING, &hdev->flags)) -+ return 0; -+ -+ skb_queue_head_init(&fw_queue); -+ err = hci_h4p_read_fw(info, &fw_queue); -+ if (err < 0) { -+ dev_err(info->dev, "Cannot read firmware\n"); -+ return err; -+ } -+ neg_cmd_skb = skb_dequeue(&fw_queue); -+ if (!neg_cmd_skb) { -+ err = -EPROTO; -+ goto err_clean; -+ } -+ info->alive_cmd_skb = skb_dequeue(&fw_queue); -+ if (!info->alive_cmd_skb) { -+ err = -EPROTO; -+ goto err_clean; -+ } -+ -+ hci_h4p_set_clk(info, &info->tx_clocks_en, 1); -+ hci_h4p_set_clk(info, &info->rx_clocks_en, 1); -+ -+ tasklet_enable(&info->tx_task); -+ tasklet_enable(&info->rx_task); -+ info->rx_state = WAIT_FOR_PKT_TYPE; -+ info->rx_count = 0; -+ info->garbage_bytes = 0; -+ info->rx_skb = NULL; -+ info->pm_enabled = 0; -+ init_completion(&info->fw_completion); -+ -+ err = hci_h4p_reset(info); -+ if (err < 0) -+ goto err_clean; -+ -+ err = hci_h4p_send_negotiation(info, neg_cmd_skb); -+ neg_cmd_skb = NULL; -+ if (err < 0) -+ goto err_clean; -+ -+ err = hci_h4p_send_fw(info, &fw_queue); -+ if (err < 0) { -+ dev_err(info->dev, "Sending firmware failed.\n"); -+ goto err_clean; -+ } -+ -+ kfree_skb(info->alive_cmd_skb); -+ info->alive_cmd_skb = NULL; -+ info->pm_enabled = 1; -+ info->tx_pm_enabled = 1; -+ info->rx_pm_enabled = 0; -+ set_bit(HCI_RUNNING, &hdev->flags); -+ -+ NBT_DBG("hci up and running\n"); -+ return 0; -+ -+err_clean: -+ hci_h4p_hci_flush(hdev); -+ tasklet_disable(&info->tx_task); -+ tasklet_disable(&info->rx_task); -+ hci_h4p_reset_uart(info); -+ hci_h4p_set_clk(info, &info->tx_clocks_en, 0); -+ hci_h4p_set_clk(info, &info->rx_clocks_en, 0); -+ gpio_set_value(info->reset_gpio, 0); -+ gpio_set_value(info->bt_wakeup_gpio, 0); -+ skb_queue_purge(&fw_queue); -+ kfree_skb(neg_cmd_skb); -+ neg_cmd_skb = NULL; -+ kfree_skb(info->alive_cmd_skb); -+ info->alive_cmd_skb = NULL; -+ kfree_skb(info->rx_skb); -+ -+ return err; -+} -+ -+static int hci_h4p_hci_close(struct hci_dev *hdev) -+{ -+ struct hci_h4p_info *info = hdev->driver_data; -+ -+ if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) -+ return 0; -+ -+ hci_h4p_hci_flush(hdev); -+ del_timer_sync(&info->tx_pm_timer); -+ del_timer_sync(&info->rx_pm_timer); -+ tasklet_disable(&info->tx_task); -+ tasklet_disable(&info->rx_task); -+ hci_h4p_set_clk(info, &info->tx_clocks_en, 1); -+ hci_h4p_set_clk(info, &info->rx_clocks_en, 1); -+ hci_h4p_reset_uart(info); -+ hci_h4p_set_clk(info, &info->tx_clocks_en, 0); -+ hci_h4p_set_clk(info, &info->rx_clocks_en, 0); -+ gpio_set_value(info->reset_gpio, 0); -+ gpio_set_value(info->bt_wakeup_gpio, 0); -+ kfree_skb(info->rx_skb); -+ -+ return 0; -+} -+ -+static void hci_h4p_hci_destruct(struct hci_dev *hdev) -+{ -+} -+ -+static int hci_h4p_hci_send_frame(struct sk_buff *skb) -+{ -+ struct hci_h4p_info *info; -+ struct hci_dev *hdev = (struct hci_dev *)skb->dev; -+ int err = 0; -+ -+ if (!hdev) { -+ printk(KERN_WARNING "hci_h4p: Frame for unknown device\n"); -+ return -ENODEV; -+ } -+ -+ NBT_DBG("dev %p, skb %p\n", hdev, skb); -+ -+ info = hdev->driver_data; -+ -+ if (!test_bit(HCI_RUNNING, &hdev->flags)) { -+ dev_warn(info->dev, "Frame for non-running device\n"); -+ return -EIO; -+ } -+ -+ switch (bt_cb(skb)->pkt_type) { -+ case HCI_COMMAND_PKT: -+ hdev->stat.cmd_tx++; -+ break; -+ case HCI_ACLDATA_PKT: -+ hdev->stat.acl_tx++; -+ break; -+ case HCI_SCODATA_PKT: -+ hdev->stat.sco_tx++; -+ break; -+ } -+ -+ /* Push frame type to skb */ -+ *skb_push(skb, 1) = (bt_cb(skb)->pkt_type); -+ /* We should allways send word aligned data to h4+ devices */ -+ if (skb->len % 2) { -+ err = skb_pad(skb, 1); -+ } -+ if (err) -+ return err; -+ -+ hci_h4p_enable_tx(info); -+ skb_queue_tail(&info->txq, skb); -+ tasklet_schedule(&info->tx_task); -+ -+ return 0; -+} -+ -+static int hci_h4p_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) -+{ -+ return -ENOIOCTLCMD; -+} -+ -+static int hci_h4p_register_hdev(struct hci_h4p_info *info) -+{ -+ struct hci_dev *hdev; -+ -+ /* Initialize and register HCI device */ -+ -+ hdev = hci_alloc_dev(); -+ if (!hdev) { -+ dev_err(info->dev, "Can't allocate memory for device\n"); -+ return -ENOMEM; -+ } -+ info->hdev = hdev; -+ -+ hdev->dev_type = HCI_UART; -+ hdev->driver_data = info; -+ -+ hdev->open = hci_h4p_hci_open; -+ hdev->close = hci_h4p_hci_close; -+ hdev->flush = hci_h4p_hci_flush; -+ hdev->send = hci_h4p_hci_send_frame; -+ hdev->destruct = hci_h4p_hci_destruct; -+ hdev->ioctl = hci_h4p_hci_ioctl; -+ -+ hdev->owner = THIS_MODULE; -+ -+ if (hci_register_dev(hdev) < 0) { -+ dev_err(info->dev, "hci_h4p: Can't register HCI device %s.\n", hdev->name); -+ return -ENODEV; -+ } -+ -+ return 0; -+} -+ -+static int hci_h4p_probe(struct platform_device *pdev) -+{ -+ struct omap_bluetooth_config *bt_config; -+ struct hci_h4p_info *info; -+ int irq, err; -+ -+ dev_info(&pdev->dev, "Registering HCI H4P device\n"); -+ info = kzalloc(sizeof(struct hci_h4p_info), GFP_KERNEL); -+ if (!info) -+ return -ENOMEM; -+ -+ info->dev = &pdev->dev; -+ info->pm_enabled = 0; -+ info->tx_pm_enabled = 0; -+ info->rx_pm_enabled = 0; -+ info->garbage_bytes = 0; -+ info->tx_clocks_en = 0; -+ info->rx_clocks_en = 0; -+ tasklet_init(&info->tx_task, hci_h4p_tx_tasklet, (unsigned long)info); -+ tasklet_init(&info->rx_task, hci_h4p_rx_tasklet, (unsigned long)info); -+ /* hci_h4p_hci_open assumes that tasklet is disabled in startup */ -+ tasklet_disable(&info->tx_task); -+ tasklet_disable(&info->rx_task); -+ spin_lock_init(&info->lock); -+ spin_lock_init(&info->clocks_lock); -+ skb_queue_head_init(&info->txq); -+ init_timer(&info->tx_pm_timer); -+ info->tx_pm_timer.function = hci_h4p_tx_pm_timer; -+ info->tx_pm_timer.data = (unsigned long)info; -+ init_timer(&info->rx_pm_timer); -+ info->rx_pm_timer.function = hci_h4p_rx_pm_timer; -+ info->rx_pm_timer.data = (unsigned long)info; -+ -+ if (pdev->dev.platform_data == NULL) { -+ dev_err(&pdev->dev, "Could not get Bluetooth config data\n"); -+ return -ENODATA; -+ } -+ -+ bt_config = pdev->dev.platform_data; -+ info->chip_type = bt_config->chip_type; -+ info->bt_wakeup_gpio = bt_config->bt_wakeup_gpio; -+ info->host_wakeup_gpio = bt_config->host_wakeup_gpio; -+ info->reset_gpio = bt_config->reset_gpio; -+ info->bt_sysclk = bt_config->bt_sysclk; -+ -+ NBT_DBG("RESET gpio: %d\n", info->reset_gpio); -+ NBT_DBG("BTWU gpio: %d\n", info->bt_wakeup_gpio); -+ NBT_DBG("HOSTWU gpio: %d\n", info->host_wakeup_gpio); -+ NBT_DBG("Uart: %d\n", bt_config->bt_uart); -+ NBT_DBG("sysclk: %d\n", info->bt_sysclk); -+ -+ err = gpio_request(info->reset_gpio, "BT reset"); -+ if (err < 0) { -+ dev_err(&pdev->dev, "Cannot get GPIO line %d\n", -+ info->reset_gpio); -+ kfree(info); -+ goto cleanup; -+ } -+ -+ err = gpio_request(info->bt_wakeup_gpio, "BT wakeup"); -+ if (err < 0) -+ { -+ dev_err(info->dev, "Cannot get GPIO line 0x%d", -+ info->bt_wakeup_gpio); -+ gpio_free(info->reset_gpio); -+ kfree(info); -+ goto cleanup; -+ } -+ -+ err = gpio_request(info->host_wakeup_gpio, "BT host wakeup"); -+ if (err < 0) -+ { -+ dev_err(info->dev, "Cannot get GPIO line %d", -+ info->host_wakeup_gpio); -+ gpio_free(info->reset_gpio); -+ gpio_free(info->bt_wakeup_gpio); -+ kfree(info); -+ goto cleanup; -+ } -+ -+ gpio_direction_output(info->reset_gpio, 0); -+ gpio_direction_output(info->bt_wakeup_gpio, 0); -+ gpio_direction_input(info->host_wakeup_gpio); -+ -+//FIXME -+#if defined(CONFIG_ARCH_OMAP1) -+# define OMAP_UART1_BASE OMAP1_UART1_BASE -+# define OMAP_UART2_BASE OMAP1_UART2_BASE -+# define OMAP_UART3_BASE OMAP1_UART3_BASE -+#elif defined(CONFIG_ARCH_OMAP2) -+# define OMAP_UART1_BASE OMAP2_UART1_BASE -+# define OMAP_UART2_BASE OMAP2_UART2_BASE -+# define OMAP_UART3_BASE OMAP2_UART3_BASE -+#elif defined(CONFIG_ARCH_OMAP3) -+# define OMAP_UART1_BASE OMAP3_UART1_BASE -+# define OMAP_UART2_BASE OMAP3_UART2_BASE -+# define OMAP_UART3_BASE OMAP3_UART3_BASE -+#elif defined(CONFIG_ARCH_OMAP4) -+# define OMAP_UART1_BASE OMAP4_UART1_BASE -+# define OMAP_UART2_BASE OMAP4_UART2_BASE -+# define OMAP_UART3_BASE OMAP4_UART3_BASE -+#else -+# error -+#endif -+ switch (bt_config->bt_uart) { -+ case 1: -+ if (cpu_is_omap16xx()) { -+ irq = INT_UART1; -+ info->uart_fclk = clk_get(NULL, "uart1_ck"); -+ } else if (cpu_is_omap24xx()) { -+ irq = INT_24XX_UART1_IRQ; -+ info->uart_iclk = clk_get(NULL, "uart1_ick"); -+ info->uart_fclk = clk_get(NULL, "uart1_fck"); -+ } -+ /* FIXME: Use platform_get_resource for the port */ -+ info->uart_base = ioremap(OMAP_UART1_BASE, 0x16); -+ if (!info->uart_base) -+ goto cleanup; -+ break; -+ case 2: -+ if (cpu_is_omap16xx()) { -+ irq = INT_UART2; -+ info->uart_fclk = clk_get(NULL, "uart2_ck"); -+ } else { -+ irq = INT_24XX_UART2_IRQ; -+ info->uart_iclk = clk_get(NULL, "uart2_ick"); -+ info->uart_fclk = clk_get(NULL, "uart2_fck"); -+ } -+ /* FIXME: Use platform_get_resource for the port */ -+ info->uart_base = ioremap(OMAP_UART2_BASE, 0x16); -+ if (!info->uart_base) -+ goto cleanup; -+ break; -+ case 3: -+ if (cpu_is_omap16xx()) { -+ irq = INT_UART3; -+ info->uart_fclk = clk_get(NULL, "uart3_ck"); -+ } else { -+ irq = INT_24XX_UART3_IRQ; -+ info->uart_iclk = clk_get(NULL, "uart3_ick"); -+ info->uart_fclk = clk_get(NULL, "uart3_fck"); -+ } -+ /* FIXME: Use platform_get_resource for the port */ -+ info->uart_base = ioremap(OMAP_UART3_BASE, 0x16); -+ if (!info->uart_base) -+ goto cleanup; -+ break; -+ default: -+ dev_err(info->dev, "No uart defined\n"); -+ goto cleanup; -+ } -+ -+ info->irq = irq; -+ err = request_irq(irq, hci_h4p_interrupt, 0, "hci_h4p", (void *)info); -+ if (err < 0) { -+ dev_err(info->dev, "hci_h4p: unable to get IRQ %d\n", irq); -+ goto cleanup; -+ } -+ -+ err = request_irq(gpio_to_irq(info->host_wakeup_gpio), -+ hci_h4p_wakeup_interrupt, -+ IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, -+ "hci_h4p_wkup", (void *)info); -+ if (err < 0) { -+ dev_err(info->dev, "hci_h4p: unable to get wakeup IRQ %d\n", -+ gpio_to_irq(info->host_wakeup_gpio)); -+ free_irq(irq, (void *)info); -+ goto cleanup; -+ } -+ -+ hci_h4p_set_clk(info, &info->tx_clocks_en, 1); -+ hci_h4p_set_auto_ctsrts(info, 0, UART_EFR_CTS | UART_EFR_RTS); -+ err = hci_h4p_init_uart(info); -+ if (err < 0) -+ goto cleanup_irq; -+ err = hci_h4p_reset(info); -+ if (err < 0) -+ goto cleanup_irq; -+ err = hci_h4p_wait_for_cts(info, 1, 10); -+ if (err < 0) -+ goto cleanup_irq; -+ hci_h4p_set_clk(info, &info->tx_clocks_en, 0); -+ -+ platform_set_drvdata(pdev, info); -+ err = hci_h4p_sysfs_create_files(info->dev); -+ if (err < 0) -+ goto cleanup_irq; -+ -+ if (hci_h4p_register_hdev(info) < 0) { -+ dev_err(info->dev, "failed to register hci_h4p hci device\n"); -+ goto cleanup_irq; -+ } -+ gpio_set_value(info->reset_gpio, 0); -+ -+ return 0; -+ -+cleanup_irq: -+ free_irq(irq, (void *)info); -+ free_irq(gpio_to_irq(info->host_wakeup_gpio), (void *)info); -+cleanup: -+ gpio_set_value(info->reset_gpio, 0); -+ gpio_free(info->reset_gpio); -+ gpio_free(info->bt_wakeup_gpio); -+ gpio_free(info->host_wakeup_gpio); -+ kfree(info); -+ -+ return err; -+ -+} -+ -+static int hci_h4p_remove(struct platform_device *dev) -+{ -+ struct hci_h4p_info *info; -+ -+ info = platform_get_drvdata(dev); -+ -+ hci_h4p_hci_close(info->hdev); -+ free_irq(gpio_to_irq(info->host_wakeup_gpio), (void *) info); -+ hci_free_dev(info->hdev); -+ gpio_free(info->reset_gpio); -+ gpio_free(info->bt_wakeup_gpio); -+ gpio_free(info->host_wakeup_gpio); -+ free_irq(info->irq, (void *) info); -+ kfree(info); -+ -+ return 0; -+} -+ -+static struct platform_driver hci_h4p_driver = { -+ .probe = hci_h4p_probe, -+ .remove = hci_h4p_remove, -+ .driver = { -+ .name = "hci_h4p", -+ }, -+}; -+ -+static int __init hci_h4p_init(void) -+{ -+ int err = 0; -+ -+ /* Register the driver with LDM */ -+ err = platform_driver_register(&hci_h4p_driver); -+ if (err < 0) -+ printk(KERN_WARNING "failed to register hci_h4p driver\n"); -+ -+ return err; -+} -+ -+static void __exit hci_h4p_exit(void) -+{ -+ platform_driver_unregister(&hci_h4p_driver); -+} -+ -+module_init(hci_h4p_init); -+module_exit(hci_h4p_exit); -+ -+MODULE_DESCRIPTION("h4 driver with nokia extensions"); -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("Ville Tervo"); ---- /dev/null -+++ b/drivers/bluetooth/hci_h4p/fw.c -@@ -0,0 +1,155 @@ -+/* -+ * This file is part of hci_h4p bluetooth driver -+ * -+ * Copyright (C) 2005, 2006 Nokia Corporation. -+ * -+ * Contact: Ville Tervo <ville.tervo@nokia.com> -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * version 2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -+ * 02110-1301 USA -+ * -+ */ -+ -+#include <linux/skbuff.h> -+#include <linux/firmware.h> -+#include <linux/clk.h> -+ -+#include <net/bluetooth/bluetooth.h> -+ -+#include "hci_h4p.h" -+ -+#define BT_CHIP_TI 2 -+#define BT_CHIP_CSR 1 -+ -+static int fw_pos; -+ -+/* Firmware handling */ -+static int hci_h4p_open_firmware(struct hci_h4p_info *info, -+ const struct firmware **fw_entry) -+{ -+ int err; -+ -+ fw_pos = 0; -+ NBT_DBG_FW("Opening %d firmware\n", info->chip_type); -+ switch (info->chip_type) { -+ case BT_CHIP_TI: -+ err = request_firmware(fw_entry, "brf6150fw.bin", info->dev); -+ break; -+ case BT_CHIP_CSR: -+ err = request_firmware(fw_entry, "bc4fw.bin", info->dev); -+ break; -+ default: -+ dev_err(info->dev, "Invalid chip type\n"); -+ *fw_entry = NULL; -+ err = -EINVAL; -+ } -+ -+ return err; -+} -+ -+static void hci_h4p_close_firmware(const struct firmware *fw_entry) -+{ -+ release_firmware(fw_entry); -+} -+ -+/* Read fw. Return length of the command. If no more commands in -+ * fw 0 is returned. In error case return value is negative. -+ */ -+static int hci_h4p_read_fw_cmd(struct hci_h4p_info *info, struct sk_buff **skb, -+ const struct firmware *fw_entry, int how) -+{ -+ unsigned int cmd_len; -+ -+ if (fw_pos >= fw_entry->size) { -+ return 0; -+ } -+ -+ cmd_len = fw_entry->data[fw_pos++]; -+ if (!cmd_len) -+ return 0; -+ -+ if (fw_pos + cmd_len > fw_entry->size) { -+ dev_err(info->dev, "Corrupted firmware image\n"); -+ return -EMSGSIZE; -+ } -+ -+ *skb = bt_skb_alloc(cmd_len, how); -+ if (!*skb) { -+ dev_err(info->dev, "Cannot reserve memory for buffer\n"); -+ return -ENOMEM; -+ } -+ memcpy(skb_put(*skb, cmd_len), &fw_entry->data[fw_pos], cmd_len); -+ -+ fw_pos += cmd_len; -+ -+ return (*skb)->len; -+} -+ -+int hci_h4p_read_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue) -+{ -+ const struct firmware *fw_entry = NULL; -+ struct sk_buff *skb = NULL; -+ int err; -+ -+ err = hci_h4p_open_firmware(info, &fw_entry); -+ if (err < 0 || !fw_entry) -+ goto err_clean; -+ -+ while ((err = hci_h4p_read_fw_cmd(info, &skb, fw_entry, GFP_KERNEL))) { -+ if (err < 0 || !skb) -+ goto err_clean; -+ -+ skb_queue_tail(fw_queue, skb); -+ } -+ -+err_clean: -+ hci_h4p_close_firmware(fw_entry); -+ return err; -+} -+ -+int hci_h4p_send_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue) -+{ -+ int err; -+ -+ switch(info->chip_type) { -+ case BT_CHIP_CSR: -+ err = hci_h4p_bc4_send_fw(info, fw_queue); -+ break; -+ case BT_CHIP_TI: -+ err = hci_h4p_brf6150_send_fw(info, fw_queue); -+ break; -+ default: -+ dev_err(info->dev, "Don't know how to send firmware\n"); -+ err = -EINVAL; -+ } -+ -+ return err; -+} -+ -+void hci_h4p_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb) -+{ -+ switch (info->chip_type) { -+ case BT_CHIP_CSR: -+ hci_h4p_bc4_parse_fw_event(info, skb); -+ break; -+ case BT_CHIP_TI: -+ hci_h4p_brf6150_parse_fw_event(info, skb); -+ break; -+ default: -+ dev_err(info->dev, "Don't know how to parse fw event\n"); -+ info->fw_error = -EINVAL; -+ } -+ -+ return; -+} ---- /dev/null -+++ b/drivers/bluetooth/hci_h4p/fw-csr.c -@@ -0,0 +1,149 @@ -+/* -+ * This file is part of hci_h4p bluetooth driver -+ * -+ * Copyright (C) 2005, 2006 Nokia Corporation. -+ * -+ * Contact: Ville Tervo <ville.tervo@nokia.com> -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * version 2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -+ * 02110-1301 USA -+ * -+ */ -+ -+#include <linux/skbuff.h> -+#include <linux/delay.h> -+#include <linux/serial_reg.h> -+ -+#include "hci_h4p.h" -+ -+void hci_h4p_bc4_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb) -+{ -+ /* Check if this is fw packet */ -+ if (skb->data[0] != 0xff) { -+ hci_recv_frame(skb); -+ return; -+ } -+ -+ if (skb->data[11] || skb->data[12]) { -+ dev_err(info->dev, "Firmware sending command failed\n"); -+ info->fw_error = -EPROTO; -+ } -+ -+ kfree_skb(skb); -+ complete(&info->fw_completion); -+} -+ -+int hci_h4p_bc4_send_fw(struct hci_h4p_info *info, -+ struct sk_buff_head *fw_queue) -+{ -+ struct sk_buff *skb; -+ unsigned int offset; -+ int retries, count, i; -+ -+ info->fw_error = 0; -+ -+ NBT_DBG_FW("Sending firmware\n"); -+ skb = skb_dequeue(fw_queue); -+ -+ if (!skb) -+ return -ENOMSG; -+ -+ info->bdaddr[0] = 0x00; -+ info->bdaddr[1] = 0x1D; -+ info->bdaddr[2] = 0x6E; -+ info->bdaddr[3] = 0xD4; -+ info->bdaddr[4] = 0xF0; -+ info->bdaddr[5] = 0x37; -+ -+ /* Check if this is bd_address packet */ -+ if (skb->data[15] == 0x01 && skb->data[16] == 0x00) { -+ dev_info(info->dev, "bd_address packet found\n"); -+ offset = 21; -+ skb->data[offset + 1] = 0x00; -+ skb->data[offset + 5] = 0x00; -+ skb->data[offset + 7] = info->bdaddr[0]; -+ skb->data[offset + 6] = info->bdaddr[1]; -+ skb->data[offset + 4] = info->bdaddr[2]; -+ skb->data[offset + 0] = info->bdaddr[3]; -+ skb->data[offset + 3] = info->bdaddr[4]; -+ skb->data[offset + 2] = info->bdaddr[5]; -+ } -+ -+ for (i = 0; i < 6; i++) { -+ if (info->bdaddr[i] != 0x00) -+ break; -+ } -+ -+ /* if (i > 5) { -+ dev_info(info->dev, "Valid bluetooth address not found.\n"); -+ kfree_skb(skb); -+ return -ENODEV; -+ } */ -+ -+ for (count = 1; ; count++) { -+ NBT_DBG_FW("Sending firmware command %d\n", count); -+ init_completion(&info->fw_completion); -+ skb_queue_tail(&info->txq, skb); -+ tasklet_schedule(&info->tx_task); -+ -+ skb = skb_dequeue(fw_queue); -+ if (!skb) -+ break; -+ -+ if (!wait_for_completion_timeout(&info->fw_completion, -+ msecs_to_jiffies(1000))) { -+ dev_err(info->dev, "No reply to fw command\n"); -+ return -ETIMEDOUT; -+ } -+ -+ if (info->fw_error) { -+ dev_err(info->dev, "FW error\n"); -+ return -EPROTO; -+ } -+ }; -+ -+ /* Wait for chip warm reset */ -+ retries = 100; -+ while ((!skb_queue_empty(&info->txq) || -+ !(hci_h4p_inb(info, UART_LSR) & UART_LSR_TEMT)) && -+ retries--) { -+ msleep(10); -+ } -+ if (!retries) { -+ dev_err(info->dev, "Transmitter not empty\n"); -+ return -ETIMEDOUT; -+ } -+ -+ hci_h4p_change_speed(info, BC4_MAX_BAUD_RATE); -+ -+ if (hci_h4p_wait_for_cts(info, 1, 100)) { -+ dev_err(info->dev, "cts didn't go down after final speed change\n"); -+ return -ETIMEDOUT; -+ } -+ -+ retries = 100; -+ do { -+ init_completion(&info->init_completion); -+ hci_h4p_send_alive_packet(info); -+ retries--; -+ } while (!wait_for_completion_timeout(&info->init_completion, 100) && -+ retries > 0); -+ -+ if (!retries) { -+ dev_err(info->dev, "No alive reply after speed change\n"); -+ return -ETIMEDOUT; -+ } -+ -+ return 0; -+} ---- /dev/null -+++ b/drivers/bluetooth/hci_h4p/fw-ti.c -@@ -0,0 +1,90 @@ -+/* -+ * This file is part of hci_h4p bluetooth driver -+ * -+ * Copyright (C) 2005, 2006 Nokia Corporation. -+ * -+ * Contact: Ville Tervo <ville.tervo@nokia.com> -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * version 2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -+ * 02110-1301 USA -+ * -+ */ -+ -+#include <linux/skbuff.h> -+ -+#include "hci_h4p.h" -+ -+void hci_h4p_brf6150_parse_fw_event(struct hci_h4p_info *info, -+ struct sk_buff *skb) -+{ -+ struct hci_fw_event *ev; -+ int err = 0; -+ -+ if (bt_cb(skb)->pkt_type != H4_EVT_PKT) { -+ dev_err(info->dev, "Got non event fw packet.\n"); -+ err = -EPROTO; -+ goto ret; -+ } -+ -+ ev = (struct hci_fw_event *)skb->data; -+ if (ev->hev.evt != HCI_EV_CMD_COMPLETE) { -+ dev_err(info->dev, "Got non cmd complete fw event\n"); -+ err = -EPROTO; -+ goto ret; -+ } -+ -+ if (ev->status != 0) { -+ dev_err(info->dev, "Got error status from fw command\n"); -+ err = -EPROTO; -+ goto ret; -+ } -+ -+ret: -+ info->fw_error = err; -+ complete(&info->fw_completion); -+} -+ -+int hci_h4p_brf6150_send_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue) -+{ -+ struct sk_buff *skb; -+ int err = 0; -+ -+ info->fw_error = 0; -+ -+ while ((skb = skb_dequeue(fw_queue)) != NULL) { -+ /* We should allways send word aligned data to h4+ devices */ -+ if (skb->len % 2) { -+ err = skb_pad(skb, 1); -+ } -+ if (err) -+ return err; -+ -+ init_completion(&info->fw_completion); -+ skb_queue_tail(&info->txq, skb); -+ tasklet_schedule(&info->tx_task); -+ -+ if (!wait_for_completion_timeout(&info->fw_completion, HZ)) { -+ dev_err(info->dev, "Timeout while sending brf6150 fw\n"); -+ return -ETIMEDOUT; -+ } -+ -+ if (info->fw_error) { -+ dev_err(info->dev, "There was fw_error while sending bfr6150 fw\n"); -+ return -EPROTO; -+ } -+ } -+ NBT_DBG_FW("Firmware sent\n"); -+ -+ return 0; -+} ---- /dev/null -+++ b/drivers/bluetooth/hci_h4p/hci_h4p.h -@@ -0,0 +1,183 @@ -+/* -+ * This file is part of hci_h4p bluetooth driver -+ * -+ * Copyright (C) 2005, 2006 Nokia Corporation. -+ * -+ * Contact: Ville Tervo <ville.tervo@nokia.com> -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * version 2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -+ * 02110-1301 USA -+ * -+ */ -+ -+#include <mach/board.h> -+ -+#include <net/bluetooth/bluetooth.h> -+#include <net/bluetooth/hci_core.h> -+#include <net/bluetooth/hci.h> -+ -+#ifndef __DRIVERS_BLUETOOTH_HCI_H4P_H -+#define __DRIVERS_BLUETOOTH_HCI_H4P_H -+ -+#define UART_SYSC_OMAP_RESET 0x03 -+#define UART_SYSS_RESETDONE 0x01 -+#define UART_OMAP_SCR_EMPTY_THR 0x08 -+#define UART_OMAP_SCR_WAKEUP 0x10 -+#define UART_OMAP_SSR_WAKEUP 0x02 -+#define UART_OMAP_SSR_TXFULL 0x01 -+ -+#if 0 -+#define NBT_DBG(fmt, arg...) printk("%s: " fmt "" , __FUNCTION__ , ## arg) -+#else -+#define NBT_DBG(...) -+#endif -+ -+#if 0 -+#define NBT_DBG_FW(fmt, arg...) printk("%s: " fmt "" , __FUNCTION__ , ## arg) -+#else -+#define NBT_DBG_FW(...) -+#endif -+ -+#if 0 -+#define NBT_DBG_POWER(fmt, arg...) printk("%s: " fmt "" , __FUNCTION__ , ## arg) -+#else -+#define NBT_DBG_POWER(...) -+#endif -+ -+#if 0 -+#define NBT_DBG_TRANSFER(fmt, arg...) printk("%s: " fmt "" , __FUNCTION__ , ## arg) -+#else -+#define NBT_DBG_TRANSFER(...) -+#endif -+ -+#if 0 -+#define NBT_DBG_TRANSFER_NF(fmt, arg...) printk(fmt "" , ## arg) -+#else -+#define NBT_DBG_TRANSFER_NF(...) -+#endif -+ -+#if 0 -+#define NBT_DBG_DMA(fmt, arg...) printk("%s: " fmt "" , __FUNCTION__ , ## arg) -+#else -+#define NBT_DBG_DMA(...) -+#endif -+ -+struct hci_h4p_info { -+ struct hci_dev *hdev; -+ spinlock_t lock; -+ -+ void __iomem *uart_base; -+ unsigned long uart_phys_base; -+ int irq; -+ struct device *dev; -+ u8 bdaddr[6]; -+ u8 chip_type; -+ u8 bt_wakeup_gpio; -+ u8 host_wakeup_gpio; -+ u8 reset_gpio; -+ u8 bt_sysclk; -+ -+ -+ struct sk_buff_head fw_queue; -+ struct sk_buff *alive_cmd_skb; -+ struct completion init_completion; -+ struct completion fw_completion; -+ int fw_error; -+ int init_error; -+ -+ struct sk_buff_head txq; -+ struct tasklet_struct tx_task; -+ -+ struct sk_buff *rx_skb; -+ long rx_count; -+ unsigned long rx_state; -+ unsigned long garbage_bytes; -+ struct tasklet_struct rx_task; -+ -+ int pm_enabled; -+ int tx_pm_enabled; -+ int rx_pm_enabled; -+ struct timer_list tx_pm_timer; -+ struct timer_list rx_pm_timer; -+ -+ int tx_clocks_en; -+ int rx_clocks_en; -+ spinlock_t clocks_lock; -+ struct clk *uart_iclk; -+ struct clk *uart_fclk; -+}; -+ -+#define MAX_BAUD_RATE 921600 -+#define BC4_MAX_BAUD_RATE 3692300 -+#define UART_CLOCK 48000000 -+#define BT_INIT_DIVIDER 320 -+#define BT_BAUDRATE_DIVIDER 384000000 -+#define BT_SYSCLK_DIV 1000 -+#define INIT_SPEED 120000 -+ -+#define H4_TYPE_SIZE 1 -+ -+/* H4+ packet types */ -+#define H4_CMD_PKT 0x01 -+#define H4_ACL_PKT 0x02 -+#define H4_SCO_PKT 0x03 -+#define H4_EVT_PKT 0x04 -+#define H4_NEG_PKT 0x06 -+#define H4_ALIVE_PKT 0x07 -+ -+/* TX states */ -+#define WAIT_FOR_PKT_TYPE 1 -+#define WAIT_FOR_HEADER 2 -+#define WAIT_FOR_DATA 3 -+ -+struct hci_fw_event { -+ struct hci_event_hdr hev; -+ struct hci_ev_cmd_complete cmd; -+ u8 status; -+} __attribute__ ((packed)); -+ -+struct hci_bc4_set_bdaddr { -+ u8 type; -+ struct hci_command_hdr cmd_hdr; -+} __attribute__ ((packed)); -+ -+int hci_h4p_send_alive_packet(struct hci_h4p_info *info); -+ -+void hci_h4p_bc4_parse_fw_event(struct hci_h4p_info *info, -+ struct sk_buff *skb); -+int hci_h4p_bc4_send_fw(struct hci_h4p_info *info, -+ struct sk_buff_head *fw_queue); -+ -+void hci_h4p_brf6150_parse_fw_event(struct hci_h4p_info *info, -+ struct sk_buff *skb); -+int hci_h4p_brf6150_send_fw(struct hci_h4p_info *info, -+ struct sk_buff_head *fw_queue); -+ -+int hci_h4p_read_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue); -+int hci_h4p_send_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue); -+void hci_h4p_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb); -+ -+int hci_h4p_sysfs_create_files(struct device *dev); -+ -+void hci_h4p_outb(struct hci_h4p_info *info, unsigned int offset, u8 val); -+u8 hci_h4p_inb(struct hci_h4p_info *info, unsigned int offset); -+void hci_h4p_set_rts(struct hci_h4p_info *info, int active); -+int hci_h4p_wait_for_cts(struct hci_h4p_info *info, int active, int timeout_ms); -+void __hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which); -+void hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which); -+void hci_h4p_change_speed(struct hci_h4p_info *info, unsigned long speed); -+int hci_h4p_reset_uart(struct hci_h4p_info *info); -+int hci_h4p_init_uart(struct hci_h4p_info *info); -+ -+#endif /* __DRIVERS_BLUETOOTH_HCI_H4P_H */ ---- /dev/null -+++ b/drivers/bluetooth/hci_h4p/Makefile -@@ -0,0 +1,7 @@ -+# -+# Makefile for the Linux Bluetooth HCI device drivers. -+# -+ -+obj-$(CONFIG_BT_HCIH4P) += hci_h4p.o -+ -+hci_h4p-objs := core.o fw.o uart.o sysfs.o fw-ti.o fw-csr.o ---- /dev/null -+++ b/drivers/bluetooth/hci_h4p/sysfs.c -@@ -0,0 +1,84 @@ -+/* -+ * This file is part of hci_h4p bluetooth driver -+ * -+ * Copyright (C) 2005, 2006 Nokia Corporation. -+ * -+ * Contact: Ville Tervo <ville.tervo@nokia.com> -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * version 2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -+ * 02110-1301 USA -+ * -+ */ -+ -+#include <linux/kernel.h> -+#include <linux/init.h> -+#include <linux/device.h> -+#include <linux/platform_device.h> -+ -+#include "hci_h4p.h" -+ -+#ifdef CONFIG_SYSFS -+ -+static ssize_t hci_h4p_store_bdaddr(struct device *dev, struct device_attribute *attr, -+ const char *buf, size_t count) -+{ -+ struct hci_h4p_info *info = (struct hci_h4p_info*)dev_get_drvdata(dev); -+ unsigned int bdaddr[6]; -+ int ret, i; -+ -+ dev_info(info->dev, "HCI_H4P_STORE_BDADDR called\n"); -+ -+ ret = sscanf(buf, "%2x:%2x:%2x:%2x:%2x:%2x\n", -+ &bdaddr[0], &bdaddr[1], &bdaddr[2], -+ &bdaddr[3], &bdaddr[4], &bdaddr[5]); -+ -+ if (ret != 6) { -+ dev_info(info->dev, "bdaddr isn't found\n"); -+ return -EINVAL; -+ } -+ -+ //for (i = 0; i < 6; i++) -+ //info->bdaddr[i] = bdaddr[i] & 0xff; -+ -+ info->bdaddr[0] = 0x00; -+ info->bdaddr[1] = 0x1D; -+ info->bdaddr[2] = 0x6E; -+ info->bdaddr[3] = 0xD4; -+ info->bdaddr[4] = 0xF0; -+ info->bdaddr[5] = 0x37; -+ -+ return count; -+} -+ -+static ssize_t hci_h4p_show_bdaddr(struct device *dev, struct device_attribute *attr, -+ char *buf) -+{ -+ struct hci_h4p_info *info = (struct hci_h4p_info*)dev_get_drvdata(dev); -+ -+ return sprintf(buf, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", -+ info->bdaddr[0], -+ info->bdaddr[1], -+ info->bdaddr[2], -+ info->bdaddr[3], -+ info->bdaddr[4], -+ info->bdaddr[5]); -+} -+ -+static DEVICE_ATTR(bdaddr, S_IRUGO | S_IWUSR, hci_h4p_show_bdaddr, hci_h4p_store_bdaddr); -+int hci_h4p_sysfs_create_files(struct device *dev) -+{ -+ return device_create_file(dev, &dev_attr_bdaddr); -+} -+ -+#endif ---- /dev/null -+++ b/drivers/bluetooth/hci_h4p/uart.c -@@ -0,0 +1,169 @@ -+/* -+ * This file is part of hci_h4p bluetooth driver -+ * -+ * Copyright (C) 2005, 2006 Nokia Corporation. -+ * -+ * Contact: Ville Tervo <ville.tervo@nokia.com> -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * version 2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, but -+ * WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -+ * 02110-1301 USA -+ * -+ */ -+ -+#include <linux/serial_reg.h> -+#include <linux/delay.h> -+#include <linux/clk.h> -+ -+#include <asm/io.h> -+ -+#include "hci_h4p.h" -+ -+inline void hci_h4p_outb(struct hci_h4p_info *info, unsigned int offset, u8 val) -+{ -+ offset <<= 2; -+ __raw_writeb(val, info->uart_base + offset); -+ //outb(val, info->uart_base + (offset << 2)); -+} -+ -+inline u8 hci_h4p_inb(struct hci_h4p_info *info, unsigned int offset) -+{ -+ offset <<= 2; -+ return (u8)__raw_readb(info->uart_base + offset); -+ //return (unsigned int)__raw_readb(up->membase + offset); -+ //return inb(info->uart_base + (offset << 2)); -+} -+ -+void hci_h4p_set_rts(struct hci_h4p_info *info, int active) -+{ -+ u8 b; -+ -+ b = hci_h4p_inb(info, UART_MCR); -+ if (active) -+ b |= UART_MCR_RTS; -+ else -+ b &= ~UART_MCR_RTS; -+ hci_h4p_outb(info, UART_MCR, b); -+} -+ -+int hci_h4p_wait_for_cts(struct hci_h4p_info *info, int active, -+ int timeout_ms) -+{ -+ int okay; -+ unsigned long timeout; -+ -+ okay = 0; -+ timeout = jiffies + msecs_to_jiffies(timeout_ms); -+ for (;;) { -+ int state; -+ -+ state = hci_h4p_inb(info, UART_MSR) & UART_MSR_CTS; -+ if (active) { -+ if (state) -+ return 0; -+ } else { -+ if (!state) -+ return 0; -+ } -+ if (time_after(jiffies, timeout)) -+ return -ETIMEDOUT; -+ } -+} -+ -+void __hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which) -+{ -+ u8 lcr, b; -+ -+ lcr = hci_h4p_inb(info, UART_LCR); -+ hci_h4p_outb(info, UART_LCR, 0xbf); -+ b = hci_h4p_inb(info, UART_EFR); -+ if (on) -+ b |= which; -+ else -+ b &= ~which; -+ hci_h4p_outb(info, UART_EFR, b); -+ hci_h4p_outb(info, UART_LCR, lcr); -+} -+ -+void hci_h4p_set_auto_ctsrts(struct hci_h4p_info *info, int on, u8 which) -+{ -+ unsigned long flags; -+ -+ spin_lock_irqsave(&info->lock, flags); -+ __hci_h4p_set_auto_ctsrts(info, on, which); -+ spin_unlock_irqrestore(&info->lock, flags); -+} -+ -+void hci_h4p_change_speed(struct hci_h4p_info *info, unsigned long speed) -+{ -+ unsigned int divisor; -+ u8 lcr, mdr1; -+ -+ NBT_DBG("Setting speed %lu\n", speed); -+ -+ if (speed >= 460800) { -+ divisor = UART_CLOCK / 13 / speed; -+ mdr1 = 3; -+ } else { -+ divisor = UART_CLOCK / 16 / speed; -+ mdr1 = 0; -+ } -+ -+ hci_h4p_outb(info, UART_OMAP_MDR1, 7); /* Make sure UART mode is disabled */ -+ lcr = hci_h4p_inb(info, UART_LCR); -+ hci_h4p_outb(info, UART_LCR, UART_LCR_DLAB); /* Set DLAB */ -+ hci_h4p_outb(info, UART_DLL, divisor & 0xff); /* Set speed */ -+ hci_h4p_outb(info, UART_DLM, divisor >> 8); -+ hci_h4p_outb(info, UART_LCR, lcr); -+ hci_h4p_outb(info, UART_OMAP_MDR1, mdr1); /* Make sure UART mode is enabled */ -+} -+ -+int hci_h4p_reset_uart(struct hci_h4p_info *info) -+{ -+ int count = 0; -+ -+ /* Reset the UART */ -+ hci_h4p_outb(info, UART_OMAP_SYSC, UART_SYSC_OMAP_RESET); -+ while (!(hci_h4p_inb(info, UART_OMAP_SYSS) & UART_SYSS_RESETDONE)) { -+ if (count++ > 20000) { -+ dev_err(info->dev, "hci_h4p: UART reset timeout\n"); -+ return -ENODEV; -+ } -+ udelay(1); -+ } -+ -+ return 0; -+} -+ -+int hci_h4p_init_uart(struct hci_h4p_info *info) -+{ -+ int err; -+ -+ err = hci_h4p_reset_uart(info); -+ if (err < 0) -+ return err; -+ -+ /* Enable and setup FIFO */ -+ hci_h4p_outb(info, UART_LCR, UART_LCR_WLEN8); -+ hci_h4p_outb(info, UART_OMAP_MDR1, 0x00); /* Make sure UART mode is enabled */ -+ hci_h4p_outb(info, UART_OMAP_SCR, 0x80); -+ hci_h4p_outb(info, UART_EFR, UART_EFR_ECB); -+ hci_h4p_outb(info, UART_MCR, UART_MCR_TCRTLR); -+ hci_h4p_outb(info, UART_TI752_TLR, 0x1f); -+ hci_h4p_outb(info, UART_TI752_TCR, 0xef); -+ hci_h4p_outb(info, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | -+ UART_FCR_CLEAR_XMIT | UART_FCR_R_TRIG_00); -+ hci_h4p_outb(info, UART_IER, UART_IER_RDI); -+ -+ return 0; -+} ---- a/drivers/bluetooth/Kconfig -+++ b/drivers/bluetooth/Kconfig -@@ -173,6 +173,16 @@ config BT_HCIBTUART - Say Y here to compile support for HCI UART devices into the - kernel or say M to compile it as module (btuart_cs). - -+config BT_HCIH4P -+ tristate "HCI driver with H4 Nokia extensions" -+ depends on BT && ARCH_OMAP -+ help -+ Bluetooth HCI driver with H4 extensions. This driver provides -+ support for H4+ Bluetooth chip with vendor-specific H4 extensions. -+ -+ Say Y here to compile support for h4 extended devices into the kernel -+ or say M to compile it as module (hci_h4p). -+ - config BT_HCIVHCI - tristate "HCI VHCI (Virtual HCI device) driver" - help ---- a/drivers/bluetooth/Makefile -+++ b/drivers/bluetooth/Makefile -@@ -11,6 +11,7 @@ obj-$(CONFIG_BT_HCIDTL1) += dtl1_cs.o - obj-$(CONFIG_BT_HCIBT3C) += bt3c_cs.o - obj-$(CONFIG_BT_HCIBLUECARD) += bluecard_cs.o - obj-$(CONFIG_BT_HCIBTUART) += btuart_cs.o -+obj-$(CONFIG_BT_HCIH4P) += hci_h4p/ - - obj-$(CONFIG_BT_HCIBTUSB) += btusb.o - obj-$(CONFIG_BT_HCIBTSDIO) += btsdio.o diff --git a/target/linux/omap24xx/patches-2.6.38/410-hci-h4p-fixes.patch b/target/linux/omap24xx/patches-2.6.38/410-hci-h4p-fixes.patch deleted file mode 100644 index 6741511a88..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/410-hci-h4p-fixes.patch +++ /dev/null @@ -1,46 +0,0 @@ ---- a/drivers/bluetooth/hci_h4p/core.c -+++ b/drivers/bluetooth/hci_h4p/core.c -@@ -36,9 +36,9 @@ - #include <linux/clk.h> - #include <linux/gpio.h> - --#include <mach/hardware.h> --#include <mach/board.h> --#include <mach/irqs.h> -+#include <plat/hardware.h> -+#include <plat/board.h> -+#include <plat/irqs.h> - #include <plat/serial.h> - - #include <net/bluetooth/bluetooth.h> ---- a/drivers/bluetooth/hci_h4p/hci_h4p.h -+++ b/drivers/bluetooth/hci_h4p/hci_h4p.h -@@ -21,7 +21,7 @@ - * - */ - --#include <mach/board.h> -+#include <plat/board.h> - - #include <net/bluetooth/bluetooth.h> - #include <net/bluetooth/hci_core.h> ---- a/drivers/bluetooth/hci_h4p/sysfs.c -+++ b/drivers/bluetooth/hci_h4p/sysfs.c -@@ -48,15 +48,8 @@ static ssize_t hci_h4p_store_bdaddr(stru - return -EINVAL; - } - -- //for (i = 0; i < 6; i++) -- //info->bdaddr[i] = bdaddr[i] & 0xff; -- -- info->bdaddr[0] = 0x00; -- info->bdaddr[1] = 0x1D; -- info->bdaddr[2] = 0x6E; -- info->bdaddr[3] = 0xD4; -- info->bdaddr[4] = 0xF0; -- info->bdaddr[5] = 0x37; -+ for (i = 0; i < 6; i++) -+ info->bdaddr[i] = bdaddr[i] & 0xff; - - return count; - } diff --git a/target/linux/omap24xx/patches-2.6.38/420-hci-h4p-interrupt-workaround.patch b/target/linux/omap24xx/patches-2.6.38/420-hci-h4p-interrupt-workaround.patch deleted file mode 100644 index 829de435cb..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/420-hci-h4p-interrupt-workaround.patch +++ /dev/null @@ -1,54 +0,0 @@ ---- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c -+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c -@@ -362,7 +362,7 @@ static struct omap_hwmod_class uart_clas - /* UART1 */ - - static struct omap_hwmod_irq_info uart1_mpu_irqs[] = { -- { .irq = INT_24XX_UART1_IRQ, }, -+ { .irq = 0, }, - }; - - static struct omap_hwmod_dma_info uart1_sdma_reqs[] = { ---- a/arch/arm/mach-omap2/serial.c -+++ b/arch/arm/mach-omap2/serial.c -@@ -546,10 +546,12 @@ static void omap_uart_idle_init(struct o - uart->padconf = 0; - } - -- uart->irqflags |= IRQF_SHARED; -- ret = request_threaded_irq(uart->irq, NULL, omap_uart_interrupt, -- IRQF_SHARED, "serial idle", (void *)uart); -- WARN_ON(ret); -+ if (uart->irq) { -+ uart->irqflags |= IRQF_SHARED; -+ ret = request_threaded_irq(uart->irq, NULL, omap_uart_interrupt, -+ IRQF_SHARED, "serial idle", (void *)uart); -+ WARN_ON(ret); -+ } - } - - void omap_uart_enable_irqs(int enable) -@@ -560,14 +562,17 @@ void omap_uart_enable_irqs(int enable) - list_for_each_entry(uart, &uart_list, node) { - if (enable) { - pm_runtime_put_sync(&uart->pdev->dev); -- ret = request_threaded_irq(uart->irq, NULL, -- omap_uart_interrupt, -- IRQF_SHARED, -- "serial idle", -- (void *)uart); -+ if (uart->irq) { -+ ret = request_threaded_irq(uart->irq, NULL, -+ omap_uart_interrupt, -+ IRQF_SHARED, -+ "serial idle", -+ (void *)uart); -+ } - } else { - pm_runtime_get_noresume(&uart->pdev->dev); -- free_irq(uart->irq, (void *)uart); -+ if (uart->irq) -+ free_irq(uart->irq, (void *)uart); - } - } - } diff --git a/target/linux/omap24xx/patches-2.6.38/500-cbus.patch b/target/linux/omap24xx/patches-2.6.38/500-cbus.patch deleted file mode 100644 index 3810de77f7..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/500-cbus.patch +++ /dev/null @@ -1,3533 +0,0 @@ ---- - arch/arm/Kconfig | 4 - drivers/Makefile | 2 - drivers/cbus/Kconfig | 89 ++++ - drivers/cbus/Makefile | 14 - drivers/cbus/cbus.c | 309 ++++++++++++++++ - drivers/cbus/cbus.h | 36 + - drivers/cbus/retu-headset.c | 356 ++++++++++++++++++ - drivers/cbus/retu-pwrbutton.c | 118 ++++++ - drivers/cbus/retu-rtc.c | 477 ++++++++++++++++++++++++ - drivers/cbus/retu-user.c | 424 ++++++++++++++++++++++ - drivers/cbus/retu-wdt.c | 387 ++++++++++++++++++++ - drivers/cbus/retu.c | 468 ++++++++++++++++++++++++ - drivers/cbus/retu.h | 77 ++++ - drivers/cbus/tahvo-usb.c | 788 +++++++++++++++++++++++++++++++++++++++++ - drivers/cbus/tahvo-user.c | 406 +++++++++++++++++++++ - drivers/cbus/tahvo.c | 443 +++++++++++++++++++++++ - drivers/cbus/tahvo.h | 61 +++ - drivers/cbus/user_retu_tahvo.h | 75 +++ - 18 files changed, 4533 insertions(+), 1 deletion(-) - ---- /dev/null -+++ b/drivers/cbus/cbus.c -@@ -0,0 +1,332 @@ -+/* -+ * drivers/cbus/cbus.c -+ * -+ * Support functions for CBUS serial protocol -+ * -+ * Copyright (C) 2004-2010 Nokia Corporation -+ * Contact: Felipe Balbi <felipe.balbi@nokia.com> -+ * -+ * Written by Juha Yrjölä <juha.yrjola@nokia.com>, -+ * David Weinehall <david.weinehall@nokia.com>, and -+ * Mikko Ylinen <mikko.k.ylinen@nokia.com> -+ * -+ * Several updates and cleanups by Felipe Balbi <felipe.balbi@nokia.com> -+ * -+ * This file is subject to the terms and conditions of the GNU General -+ * Public License. See the file "COPYING" in the main directory of this -+ * archive for more details. -+ * -+ * 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 -+ */ -+ -+#include <linux/device.h> -+#include <linux/init.h> -+#include <linux/kernel.h> -+#include <linux/slab.h> -+#include <linux/spinlock.h> -+#include <linux/gpio.h> -+#include <linux/platform_device.h> -+ -+#include <plat/cbus.h> -+ -+#include "cbus.h" -+ -+#define CBUS_XFER_READ 1 -+#define CBUS_XFER_WRITE 0 -+ -+struct cbus_host { -+ /* host lock */ -+ spinlock_t lock; -+ -+ struct device *dev; -+ -+ int clk_gpio; -+ int dat_gpio; -+ int sel_gpio; -+}; -+ -+static struct cbus_host *cbus_host; -+ -+/** -+ * cbus_send_bit - sends one bit over the bus -+ * @host: the host we're using -+ * @bit: one bit of information to send -+ * @input: whether to set data pin as input after sending -+ */ -+static int cbus_send_bit(struct cbus_host *host, unsigned bit, -+ unsigned input) -+{ -+ int ret = 0; -+ -+ gpio_set_value(host->dat_gpio, bit ? 1 : 0); -+ gpio_set_value(host->clk_gpio, 1); -+ -+ /* The data bit is read on the rising edge of CLK */ -+ if (input) -+ ret = gpio_direction_input(host->dat_gpio); -+ -+ gpio_set_value(host->clk_gpio, 0); -+ -+ return ret; -+} -+ -+/** -+ * cbus_send_data - sends @len amount of data over the bus -+ * @host: the host we're using -+ * @data: the data to send -+ * @len: size of the transfer -+ * @input: whether to set data pin as input after sending -+ */ -+static int cbus_send_data(struct cbus_host *host, unsigned data, unsigned len, -+ unsigned input) -+{ -+ int ret = 0; -+ int i; -+ -+ for (i = len; i > 0; i--) { -+ ret = cbus_send_bit(host, data & (1 << (i - 1)), -+ input && (i == 1)); -+ if (ret < 0) -+ goto out; -+ } -+ -+out: -+ return ret; -+} -+ -+/** -+ * cbus_receive_bit - receives one bit from the bus -+ * @host: the host we're using -+ */ -+static int cbus_receive_bit(struct cbus_host *host) -+{ -+ int ret; -+ -+ gpio_set_value(host->clk_gpio, 1); -+ ret = gpio_get_value(host->dat_gpio); -+ if (ret < 0) -+ goto out; -+ gpio_set_value(host->clk_gpio, 0); -+ -+out: -+ return ret; -+} -+ -+/** -+ * cbus_receive_data - receives @len data from the bus -+ * @host: the host we're using -+ * @len: the length of data to receive -+ */ -+static int cbus_receive_data(struct cbus_host *host, unsigned len) -+{ -+ int ret = 0; -+ int i; -+ -+ for (i = 16; i > 0; i--) { -+ int bit = cbus_receive_bit(host); -+ -+ if (bit < 0) -+ goto out; -+ -+ if (bit) -+ ret |= 1 << (i - 1); -+ } -+ -+out: -+ return ret; -+} -+ -+/** -+ * cbus_transfer - transfers data over the bus -+ * @host: the host we're using -+ * @rw: read/write flag -+ * @dev: device address -+ * @reg: register address -+ * @data: if @rw == 0 data to send otherwise 0 -+ */ -+static int cbus_transfer(struct cbus_host *host, unsigned rw, unsigned dev, -+ unsigned reg, unsigned data) -+{ -+ unsigned long flags; -+ int input = 0; -+ int ret = 0; -+ -+ /* We don't want interrupts disturbing our transfer */ -+ spin_lock_irqsave(&host->lock, flags); -+ -+ /* Reset state and start of transfer, SEL stays down during transfer */ -+ gpio_set_value(host->sel_gpio, 0); -+ -+ /* Set the DAT pin to output */ -+ gpio_direction_output(host->dat_gpio, 1); -+ -+ /* Send the device address */ -+ ret = cbus_send_data(host, dev, 3, 0); -+ if (ret < 0) { -+ dev_dbg(host->dev, "failed sending device addr\n"); -+ goto out; -+ } -+ -+ /* Send the rw flag */ -+ ret = cbus_send_bit(host, rw, 0); -+ if (ret < 0) { -+ dev_dbg(host->dev, "failed sending read/write flag\n"); -+ goto out; -+ } -+ -+ /* Send the register address */ -+ if (rw) -+ input = true; -+ -+ ret = cbus_send_data(host, reg, 5, input); -+ if (ret < 0) { -+ dev_dbg(host->dev, "failed sending register addr\n"); -+ goto out; -+ } -+ -+ if (!rw) { -+ ret = cbus_send_data(host, data, 16, 0); -+ if (ret < 0) { -+ dev_dbg(host->dev, "failed sending data\n"); -+ goto out; -+ } -+ } else { -+ gpio_set_value(host->clk_gpio, 1); -+ -+ ret = cbus_receive_data(host, 16); -+ if (ret < 0) { -+ dev_dbg(host->dev, "failed receiving data\n"); -+ goto out; -+ } -+ } -+ -+ /* Indicate end of transfer, SEL goes up until next transfer */ -+ gpio_set_value(host->sel_gpio, 1); -+ gpio_set_value(host->clk_gpio, 1); -+ gpio_set_value(host->clk_gpio, 0); -+ -+out: -+ spin_unlock_irqrestore(&host->lock, flags); -+ -+ return ret; -+} -+ -+/** -+ * cbus_read_reg - reads a given register from the device -+ * @dev: device address -+ * @reg: register address -+ */ -+int cbus_read_reg(unsigned dev, unsigned reg) -+{ -+ return cbus_transfer(cbus_host, CBUS_XFER_READ, dev, reg, 0); -+} -+EXPORT_SYMBOL(cbus_read_reg); -+ -+/** -+ * cbus_write_reg - writes to a given register of the device -+ * @dev: device address -+ * @reg: register address -+ * @val: data to be written to @reg -+ */ -+int cbus_write_reg(unsigned dev, unsigned reg, unsigned val) -+{ -+ return cbus_transfer(cbus_host, CBUS_XFER_WRITE, dev, reg, val); -+} -+EXPORT_SYMBOL(cbus_write_reg); -+ -+static int __init cbus_bus_probe(struct platform_device *pdev) -+{ -+ struct cbus_host *chost; -+ struct cbus_host_platform_data *pdata = pdev->dev.platform_data; -+ int ret; -+ -+ chost = kzalloc(sizeof(*chost), GFP_KERNEL); -+ if (chost == NULL) -+ return -ENOMEM; -+ -+ spin_lock_init(&chost->lock); -+ -+ chost->clk_gpio = pdata->clk_gpio; -+ chost->dat_gpio = pdata->dat_gpio; -+ chost->sel_gpio = pdata->sel_gpio; -+ chost->dev = &pdev->dev; -+ -+ ret = gpio_request(chost->clk_gpio, "CBUS clk"); -+ if (ret < 0) -+ goto exit1; -+ -+ ret = gpio_request(chost->dat_gpio, "CBUS data"); -+ if (ret < 0) -+ goto exit2; -+ -+ ret = gpio_request(chost->sel_gpio, "CBUS sel"); -+ if (ret < 0) -+ goto exit3; -+ -+ gpio_direction_output(chost->clk_gpio, 0); -+ gpio_direction_input(chost->dat_gpio); -+ gpio_direction_output(chost->sel_gpio, 1); -+ -+ gpio_set_value(chost->clk_gpio, 1); -+ gpio_set_value(chost->clk_gpio, 0); -+ -+ platform_set_drvdata(pdev, chost); -+ -+ cbus_host = chost; -+ -+ return 0; -+exit3: -+ gpio_free(chost->dat_gpio); -+exit2: -+ gpio_free(chost->clk_gpio); -+exit1: -+ kfree(chost); -+ -+ return ret; -+} -+ -+static void __exit cbus_bus_remove(struct platform_device *pdev) -+{ -+ struct cbus_host *chost = platform_get_drvdata(pdev); -+ -+ gpio_free(chost->sel_gpio); -+ gpio_free(chost->dat_gpio); -+ gpio_free(chost->clk_gpio); -+ -+ kfree(chost); -+ cbus_host = NULL; -+} -+ -+static struct platform_driver cbus_driver = { -+ .remove = __exit_p(cbus_bus_remove), -+ .driver = { -+ .name = "cbus", -+ }, -+}; -+ -+static int __init cbus_bus_init(void) -+{ -+ return platform_driver_probe(&cbus_driver, cbus_bus_probe); -+} -+subsys_initcall(cbus_bus_init); -+ -+static void __exit cbus_bus_exit(void) -+{ -+ platform_driver_unregister(&cbus_driver); -+} -+module_exit(cbus_bus_exit); -+ -+MODULE_DESCRIPTION("CBUS serial protocol"); -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("Juha Yrjölä"); -+MODULE_AUTHOR("David Weinehall"); -+MODULE_AUTHOR("Mikko Ylinen"); -+MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>"); -+ ---- /dev/null -+++ b/drivers/cbus/cbus.h -@@ -0,0 +1,29 @@ -+/* -+ * drivers/cbus/cbus.h -+ * -+ * Copyright (C) 2004, 2005 Nokia Corporation -+ * -+ * Written by Juha Yrjölä <juha.yrjola@nokia.com> and -+ * David Weinehall <david.weinehall@nokia.com> -+ * -+ * This file is subject to the terms and conditions of the GNU General -+ * Public License. See the file "COPYING" in the main directory of this -+ * archive for more details. -+ * -+ * 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 -+ */ -+ -+#ifndef __DRIVERS_CBUS_CBUS_H -+#define __DRIVERS_CBUS_CBUS_H -+ -+extern int cbus_read_reg(unsigned dev, unsigned reg); -+extern int cbus_write_reg(unsigned dev, unsigned reg, unsigned val); -+ -+#endif /* __DRIVERS_CBUS_CBUS_H */ ---- /dev/null -+++ b/drivers/cbus/Kconfig -@@ -0,0 +1,75 @@ -+# -+# CBUS device configuration -+# -+ -+menu "CBUS support" -+ -+config CBUS -+ depends on ARCH_OMAP -+ bool "CBUS support on OMAP" -+ ---help--- -+ CBUS is a proprietary serial protocol by Nokia. It is mainly -+ used for accessing Energy Management auxiliary chips. -+ -+ If you want CBUS support, you should say Y here. -+ -+config CBUS_TAHVO -+ depends on CBUS -+ bool "Support for Tahvo" -+ ---help--- -+ Tahvo is a mixed signal ASIC with some system features -+ -+ If you want Tahvo support, you should say Y here. -+ -+config CBUS_TAHVO_USB -+ depends on CBUS_TAHVO && USB -+ tristate "Support for Tahvo USB transceiver" -+ ---help--- -+ If you want Tahvo support for USB transceiver, say Y or M here. -+ -+config CBUS_TAHVO_USB_HOST_BY_DEFAULT -+ depends on CBUS_TAHVO_USB && USB_OTG -+ boolean "Device in USB host mode by default" -+ ---help--- -+ Say Y here, if you want the device to enter USB host mode -+ by default on bootup. -+ -+config CBUS_RETU -+ depends on CBUS -+ bool "Support for Retu" -+ ---help--- -+ Retu is a mixed signal ASIC with some system features -+ -+ If you want Retu support, you should say Y here. -+ -+config CBUS_RETU_POWERBUTTON -+ depends on CBUS_RETU -+ bool "Support for Retu power button" -+ ---help--- -+ The power button on Nokia 770 is connected to the Retu ASIC. -+ -+ If you want support for the Retu power button, you should say Y here. -+ -+config CBUS_RETU_RTC -+ depends on CBUS_RETU && RTC_CLASS -+ tristate "Support for Retu pseudo-RTC" -+ ---help--- -+ Say Y here if you want support for the device that alleges to be an -+ RTC in Retu. This will expose a sysfs interface for it. -+ -+config CBUS_RETU_WDT -+ depends on CBUS_RETU && SYSFS && WATCHDOG -+ tristate "Support for Retu watchdog timer" -+ ---help--- -+ Say Y here if you want support for the watchdog in Retu. This will -+ expose a sysfs interface to grok it. -+ -+config CBUS_RETU_HEADSET -+ depends on CBUS_RETU && SYSFS -+ tristate "Support for headset detection with Retu/Vilma" -+ ---help--- -+ Say Y here if you want support detecting a headset that's connected -+ to Retu/Vilma. Detection state and events are exposed through -+ sysfs. -+ -+endmenu ---- /dev/null -+++ b/drivers/cbus/Makefile -@@ -0,0 +1,13 @@ -+# -+# Makefile for CBUS. -+# -+ -+obj-$(CONFIG_CBUS) += cbus.o -+obj-$(CONFIG_CBUS_TAHVO) += tahvo.o -+obj-$(CONFIG_CBUS_RETU) += retu.o -+obj-$(CONFIG_CBUS_TAHVO_USB) += tahvo-usb.o -+ -+obj-$(CONFIG_CBUS_RETU_POWERBUTTON) += retu-pwrbutton.o -+obj-$(CONFIG_CBUS_RETU_RTC) += retu-rtc.o -+obj-$(CONFIG_CBUS_RETU_WDT) += retu-wdt.o -+obj-$(CONFIG_CBUS_RETU_HEADSET) += retu-headset.o ---- /dev/null -+++ b/drivers/cbus/retu.c -@@ -0,0 +1,544 @@ -+/** -+ * drivers/cbus/retu.c -+ * -+ * Support functions for Retu ASIC -+ * -+ * Copyright (C) 2004, 2005 Nokia Corporation -+ * -+ * Written by Juha Yrjölä <juha.yrjola@nokia.com>, -+ * David Weinehall <david.weinehall@nokia.com>, and -+ * Mikko Ylinen <mikko.k.ylinen@nokia.com> -+ * -+ * This file is subject to the terms and conditions of the GNU General -+ * Public License. See the file "COPYING" in the main directory of this -+ * archive for more details. -+ * -+ * 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 -+ */ -+ -+#include <linux/module.h> -+#include <linux/init.h> -+ -+#include <linux/slab.h> -+#include <linux/kernel.h> -+#include <linux/errno.h> -+#include <linux/device.h> -+#include <linux/miscdevice.h> -+#include <linux/poll.h> -+#include <linux/fs.h> -+#include <linux/mutex.h> -+#include <linux/irq.h> -+#include <linux/interrupt.h> -+#include <linux/platform_device.h> -+#include <linux/gpio.h> -+ -+#include <asm/uaccess.h> -+#include <asm/mach-types.h> -+ -+#include <plat/mux.h> -+#include <plat/board.h> -+#include <plat/cbus.h> -+ -+#include "cbus.h" -+#include "retu.h" -+ -+struct retu { -+ /* Device lock */ -+ struct mutex mutex; -+ struct device *dev; -+ -+ int devid; -+ -+ int irq_base; -+ int irq_end; -+ -+ int irq; -+ -+ int ack; -+ bool ack_pending; -+ -+ int mask; -+ bool mask_pending; -+ -+ bool is_vilma; -+}; -+ -+static struct retu *the_retu; -+ -+/** -+ * __retu_read_reg - Read a value from a register in Retu -+ * @retu: pointer to retu structure -+ * @reg: the register address to read from -+ */ -+static int __retu_read_reg(struct retu *retu, unsigned reg) -+{ -+ return cbus_read_reg(retu->devid, reg); -+} -+ -+/** -+ * __retu_write_reg - Writes a value to a register in Retu -+ * @retu: pointer to retu structure -+ * @reg: the register address to write to -+ * @val: the value to write to the register -+ */ -+static void __retu_write_reg(struct retu *retu, unsigned reg, u16 val) -+{ -+ cbus_write_reg(retu->devid, reg, val); -+} -+ -+/** -+ * retu_read_reg - Read a value from a register in Retu -+ * @child: device pointer for the calling child -+ * @reg: the register to read from -+ * -+ * This function returns the contents of the specified register -+ */ -+int retu_read_reg(struct device *child, unsigned reg) -+{ -+ struct retu *retu = dev_get_drvdata(child->parent); -+ -+ return __retu_read_reg(retu, reg); -+} -+EXPORT_SYMBOL_GPL(retu_read_reg); -+ -+/** -+ * retu_write_reg - Write a value to a register in Retu -+ * @child: the pointer to our calling child -+ * @reg: the register to write to -+ * @val: the value to write to the register -+ * -+ * This function writes a value to the specified register -+ */ -+void retu_write_reg(struct device *child, unsigned reg, u16 val) -+{ -+ struct retu *retu = dev_get_drvdata(child->parent); -+ -+ __retu_write_reg(retu, reg, val); -+} -+EXPORT_SYMBOL_GPL(retu_write_reg); -+ -+/** -+ * retu_set_clear_reg_bits - helper function to read/set/clear bits -+ * @child: device pointer to calling child -+ * @reg: the register address -+ * @set: mask for setting bits -+ * @clear: mask for clearing bits -+ */ -+void retu_set_clear_reg_bits(struct device *child, unsigned reg, u16 set, -+ u16 clear) -+{ -+ struct retu *retu = dev_get_drvdata(child->parent); -+ u16 w; -+ -+ mutex_lock(&retu->mutex); -+ w = __retu_read_reg(retu, reg); -+ w &= ~clear; -+ w |= set; -+ __retu_write_reg(retu, reg, w); -+ mutex_unlock(&retu->mutex); -+} -+EXPORT_SYMBOL_GPL(retu_set_clear_reg_bits); -+ -+#define ADC_MAX_CHAN_NUMBER 13 -+ -+/** -+ * retu_read_adc - Reads AD conversion result -+ * @child: device pointer to calling child -+ * @channel: the ADC channel to read from -+ */ -+int retu_read_adc(struct device *child, int channel) -+{ -+ struct retu *retu = dev_get_drvdata(child->parent); -+ int res; -+ -+ if (!retu) -+ return -ENODEV; -+ -+ if (channel < 0 || channel > ADC_MAX_CHAN_NUMBER) -+ return -EINVAL; -+ -+ mutex_lock(&retu->mutex); -+ -+ if ((channel == 8) && retu->is_vilma) { -+ int scr = __retu_read_reg(retu, RETU_REG_ADCSCR); -+ int ch = (__retu_read_reg(retu, RETU_REG_ADCR) >> 10) & 0xf; -+ if (((scr & 0xff) != 0) && (ch != 8)) -+ __retu_write_reg(retu, RETU_REG_ADCSCR, (scr & ~0xff)); -+ } -+ -+ /* Select the channel and read result */ -+ __retu_write_reg(retu, RETU_REG_ADCR, channel << 10); -+ res = __retu_read_reg(retu, RETU_REG_ADCR) & 0x3ff; -+ -+ if (retu->is_vilma) -+ __retu_write_reg(retu, RETU_REG_ADCR, (1 << 13)); -+ -+ /* Unlock retu */ -+ mutex_unlock(&retu->mutex); -+ -+ return res; -+} -+EXPORT_SYMBOL_GPL(retu_read_adc); -+ -+static irqreturn_t retu_irq_handler(int irq, void *_retu) -+{ -+ struct retu *retu = _retu; -+ -+ int i; -+ -+ u16 idr; -+ u16 imr; -+ -+ idr = __retu_read_reg(retu, RETU_REG_IDR); -+ imr = __retu_read_reg(retu, RETU_REG_IMR); -+ idr &= ~imr; -+ -+ if (!idr) { -+ dev_vdbg(retu->dev, "No IRQ, spurious?\n"); -+ return IRQ_NONE; -+ } -+ -+ for (i = 0; idr != 0; i++, idr >>= 1) { -+ if (!(idr & 1)) -+ continue; -+ -+ handle_nested_irq(i); -+ } -+ -+ return IRQ_HANDLED; -+} -+ -+/* -------------------------------------------------------------------------- */ -+ -+static void retu_irq_mask(struct irq_data *data) -+{ -+ struct retu *retu = irq_data_get_irq_chip_data(data); -+ int irq = data->irq; -+ -+ retu->mask |= (1 << (irq - retu->irq_base)); -+ retu->mask_pending = true; -+} -+ -+static void retu_irq_unmask(struct irq_data *data) -+{ -+ struct retu *retu = irq_data_get_irq_chip_data(data); -+ int irq = data->irq; -+ -+ retu->mask &= ~(1 << (irq - retu->irq_base)); -+ retu->mask_pending = true; -+ -+} -+ -+static void retu_irq_ack(struct irq_data *data) -+{ -+ struct retu *retu = irq_data_get_irq_chip_data(data); -+ int irq = data->irq; -+ -+ retu->ack |= (1 << (irq - retu->irq_base)); -+ retu->ack_pending = true; -+} -+ -+static void retu_bus_lock(struct irq_data *data) -+{ -+ struct retu *retu = irq_data_get_irq_chip_data(data); -+ -+ mutex_lock(&retu->mutex); -+} -+ -+static void retu_bus_sync_unlock(struct irq_data *data) -+{ -+ struct retu *retu = irq_data_get_irq_chip_data(data); -+ -+ if (retu->mask_pending) { -+ __retu_write_reg(retu, RETU_REG_IMR, retu->mask); -+ retu->mask_pending = false; -+ } -+ -+ if (retu->ack_pending) { -+ __retu_write_reg(retu, RETU_REG_IDR, retu->ack); -+ retu->ack_pending = false; -+ } -+ -+ mutex_unlock(&retu->mutex); -+} -+ -+static struct irq_chip retu_irq_chip = { -+ .name = "retu", -+ .irq_bus_lock = retu_bus_lock, -+ .irq_bus_sync_unlock = retu_bus_sync_unlock, -+ .irq_mask = retu_irq_mask, -+ .irq_unmask = retu_irq_unmask, -+ .irq_ack = retu_irq_ack, -+}; -+ -+static inline void retu_irq_setup(int irq) -+{ -+#ifdef CONFIG_ARM -+ set_irq_flags(irq, IRQF_VALID); -+#else -+ set_irq_noprobe(irq); -+#endif -+} -+ -+static void retu_irq_init(struct retu *retu) -+{ -+ int base = retu->irq_base; -+ int end = retu->irq_end; -+ int irq; -+ -+ for (irq = base; irq < end; irq++) { -+ set_irq_chip_data(irq, retu); -+ set_irq_chip_and_handler(irq, &retu_irq_chip, -+ handle_simple_irq); -+ set_irq_nested_thread(irq, 1); -+ retu_irq_setup(irq); -+ } -+} -+ -+static void retu_irq_exit(struct retu *retu) -+{ -+ int base = retu->irq_base; -+ int end = retu->irq_end; -+ int irq; -+ -+ for (irq = base; irq < end; irq++) { -+#ifdef CONFIG_ARM -+ set_irq_flags(irq, 0); -+#endif -+ set_irq_chip_and_handler(irq, NULL, NULL); -+ set_irq_chip_data(irq, NULL); -+ } -+} -+ -+/* -------------------------------------------------------------------------- */ -+ -+/** -+ * retu_power_off - Shut down power to system -+ * -+ * This function puts the system in power off state -+ */ -+static void retu_power_off(void) -+{ -+ struct retu *retu = the_retu; -+ unsigned reg; -+ -+ reg = __retu_read_reg(retu, RETU_REG_CC1); -+ -+ /* Ignore power button state */ -+ __retu_write_reg(retu, RETU_REG_CC1, reg | 2); -+ /* Expire watchdog immediately */ -+ __retu_write_reg(retu, RETU_REG_WATCHDOG, 0); -+ /* Wait for poweroff*/ -+ for (;;); -+} -+ -+static struct resource generic_resources[] = { -+ { -+ .start = -EINVAL, /* fixed later */ -+ .flags = IORESOURCE_IRQ, -+ }, -+ { -+ .start = -EINVAL, /* fixed later */ -+ .flags = IORESOURCE_IRQ, -+ }, -+}; -+ -+/** -+ * retu_allocate_child - Allocates one Retu child -+ * @name: name of new child -+ * @parent: parent device for this child -+ */ -+static struct device *retu_allocate_child(char *name, struct device *parent, -+ int irq_base, int irq1, int irq2, int num) -+{ -+ struct platform_device *pdev; -+ int status; -+ -+ pdev = platform_device_alloc(name, -1); -+ if (!pdev) { -+ dev_dbg(parent, "can't allocate %s\n", name); -+ goto err; -+ } -+ -+ pdev->dev.parent = parent; -+ -+ if (num) { -+ generic_resources[0].start = irq_base + irq1; -+ generic_resources[1].start = irq_base + irq2; -+ -+ status = platform_device_add_resources(pdev, -+ generic_resources, num); -+ if (status < 0) { -+ dev_dbg(parent, "can't add resources to %s\n", name); -+ goto err; -+ } -+ } -+ -+ status = platform_device_add(pdev); -+ if (status < 0) { -+ dev_dbg(parent, "can't add %s\n", name); -+ goto err; -+ } -+ -+ return &pdev->dev; -+ -+err: -+ platform_device_put(pdev); -+ -+ return NULL; -+} -+ -+/** -+ * retu_allocate_children - Allocates Retu's children -+ */ -+static int retu_allocate_children(struct device *parent, int irq_base) -+{ -+ struct device *child; -+ -+ child = retu_allocate_child("retu-pwrbutton", parent, irq_base, -+ RETU_INT_PWR, -1, 1); -+ if (!child) -+ return -ENOMEM; -+ -+ child = retu_allocate_child("retu-headset", parent, irq_base, -+ RETU_INT_HOOK, -1, 1); -+ if (!child) -+ return -ENOMEM; -+ -+ child = retu_allocate_child("retu-rtc", parent, irq_base, -+ RETU_INT_RTCS, RETU_INT_RTCA, 2); -+ if (!child) -+ return -ENOMEM; -+ -+ child = retu_allocate_child("retu-wdt", parent, -1, -1, -1, 0); -+ if (!child) -+ return -ENOMEM; -+ -+ return 0; -+} -+ -+/** -+ * retu_probe - Probe for Retu ASIC -+ * @dev: the Retu device -+ * -+ * Probe for the Retu ASIC and allocate memory -+ * for its device-struct if found -+ */ -+static int __init retu_probe(struct platform_device *pdev) -+{ -+ struct retu *retu; -+ struct cbus_retu_platform_data *pdata = pdev->dev.platform_data; -+ -+ int ret = -ENOMEM; -+ int rev; -+ -+ retu = kzalloc(sizeof(*retu), GFP_KERNEL); -+ if (!retu) { -+ dev_err(&pdev->dev, "not enough memory\n"); -+ goto err0; -+ } -+ -+ platform_set_drvdata(pdev, retu); -+ -+ retu->irq = platform_get_irq(pdev, 0); -+ retu->irq_base = pdata->irq_base; -+ retu->irq_end = pdata->irq_end; -+ retu->devid = pdata->devid; -+ the_retu = retu; -+ -+ mutex_init(&retu->mutex); -+ -+ retu_irq_init(retu); -+ -+ rev = __retu_read_reg(retu, RETU_REG_ASICR) & 0xff; -+ if (rev & (1 << 7)) -+ retu->is_vilma = true; -+ -+ dev_info(&pdev->dev, "%s v%d.%d found\n", -+ retu->is_vilma ? "Vilma" : "Retu", -+ (rev >> 4) & 0x07, rev & 0x0f); -+ -+ /* Mask all RETU interrupts */ -+ __retu_write_reg(retu, RETU_REG_IMR, 0xffff); -+ -+ ret = request_threaded_irq(retu->irq, NULL, retu_irq_handler, 0, -+ "retu", retu); -+ if (ret < 0) { -+ dev_err(&pdev->dev, "Unable to register IRQ handler\n"); -+ goto err1; -+ } -+ -+ set_irq_wake(retu->irq, 1); -+ -+ /* Register power off function */ -+ pm_power_off = retu_power_off; -+ -+ ret = retu_allocate_children(&pdev->dev, retu->irq_base); -+ if (ret < 0) { -+ dev_err(&pdev->dev, "Unable to allocate Retu children\n"); -+ goto err2; -+ } -+ -+ return 0; -+ -+err2: -+ pm_power_off = NULL; -+ __retu_write_reg(retu, RETU_REG_IMR, 0xffff); -+ free_irq(retu->irq, retu); -+ -+err1: -+ kfree(retu); -+ the_retu = NULL; -+ -+err0: -+ return ret; -+} -+ -+static int __exit retu_remove(struct platform_device *pdev) -+{ -+ struct retu *retu = platform_get_drvdata(pdev); -+ -+ pm_power_off = NULL; -+ the_retu = NULL; -+ -+ /* Mask all RETU interrupts */ -+ __retu_write_reg(retu, RETU_REG_IMR, 0xffff); -+ -+ free_irq(retu->irq, retu); -+ retu_irq_exit(retu); -+ kfree(retu); -+ -+ return 0; -+} -+ -+static struct platform_driver retu_driver = { -+ .remove = __exit_p(retu_remove), -+ .driver = { -+ .name = "retu", -+ }, -+}; -+ -+static int __init retu_init(void) -+{ -+ return platform_driver_probe(&retu_driver, retu_probe); -+} -+subsys_initcall(retu_init); -+ -+static void __exit retu_exit(void) -+{ -+ platform_driver_unregister(&retu_driver); -+} -+module_exit(retu_exit); -+ -+MODULE_DESCRIPTION("Retu ASIC control"); -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("Juha Yrjölä"); -+MODULE_AUTHOR("David Weinehall"); -+MODULE_AUTHOR("Mikko Ylinen"); ---- /dev/null -+++ b/drivers/cbus/retu.h -@@ -0,0 +1,66 @@ -+/** -+ * drivers/cbus/retu.h -+ * -+ * Copyright (C) 2004, 2005 Nokia Corporation -+ * -+ * Written by Juha Yrjölä <juha.yrjola@nokia.com> and -+ * David Weinehall <david.weinehall@nokia.com> -+ * -+ * This file is subject to the terms and conditions of the GNU General -+ * Public License. See the file "COPYING" in the main directory of this -+ * archive for more details. -+ * -+ * 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 -+ */ -+ -+#ifndef __DRIVERS_CBUS_RETU_H -+#define __DRIVERS_CBUS_RETU_H -+ -+#include <linux/types.h> -+ -+/* Registers */ -+#define RETU_REG_ASICR 0x00 /* ASIC ID & revision */ -+#define RETU_REG_IDR 0x01 /* Interrupt ID */ -+#define RETU_REG_IMR 0x02 /* Interrupt mask */ -+#define RETU_REG_RTCDSR 0x03 /* RTC seconds register */ -+#define RETU_REG_RTCHMR 0x04 /* RTC hours and minutes register */ -+#define RETU_REG_RTCHMAR 0x05 /* RTC hours and minutes alarm and time set register */ -+#define RETU_REG_RTCCALR 0x06 /* RTC calibration register */ -+#define RETU_REG_ADCR 0x08 /* ADC result */ -+#define RETU_REG_ADCSCR 0x09 /* ADC sample ctrl */ -+#define RETU_REG_CC1 0x0d /* Common control register 1 */ -+#define RETU_REG_CC2 0x0e /* Common control register 2 */ -+#define RETU_REG_CTRL_CLR 0x0f /* Regulator clear register */ -+#define RETU_REG_CTRL_SET 0x10 /* Regulator set register */ -+#define RETU_REG_STATUS 0x16 /* Status register */ -+#define RETU_REG_WATCHDOG 0x17 /* Watchdog register */ -+#define RETU_REG_AUDTXR 0x18 /* Audio Codec Tx register */ -+#define RETU_REG_MAX 0x1f -+ -+/* Interrupt sources */ -+#define RETU_INT_PWR 0 -+#define RETU_INT_CHAR 1 -+#define RETU_INT_RTCS 2 -+#define RETU_INT_RTCM 3 -+#define RETU_INT_RTCD 4 -+#define RETU_INT_RTCA 5 -+#define RETU_INT_HOOK 6 -+#define RETU_INT_HEAD 7 -+#define RETU_INT_ADCS 8 -+ -+#define MAX_RETU_IRQ_HANDLERS 16 -+ -+int retu_read_reg(struct device *child, unsigned reg); -+void retu_write_reg(struct device *child, unsigned reg, u16 val); -+void retu_set_clear_reg_bits(struct device *child, unsigned reg, u16 set, -+ u16 clear); -+int retu_read_adc(struct device *child, int channel); -+ -+#endif /* __DRIVERS_CBUS_RETU_H */ ---- /dev/null -+++ b/drivers/cbus/retu-headset.c -@@ -0,0 +1,359 @@ -+/** -+ * Retu/Vilma headset detection -+ * -+ * Copyright (C) 2006 Nokia Corporation -+ * -+ * Written by Juha Yrjölä -+ * -+ * This file is subject to the terms and conditions of the GNU General -+ * Public License. See the file "COPYING" in the main directory of this -+ * archive for more details. -+ * -+ * 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 -+ */ -+ -+#include <linux/module.h> -+#include <linux/init.h> -+#include <linux/kernel.h> -+#include <linux/irq.h> -+#include <linux/interrupt.h> -+#include <linux/slab.h> -+#include <linux/delay.h> -+#include <linux/input.h> -+#include <linux/platform_device.h> -+ -+#include "retu.h" -+ -+#define RETU_ADC_CHANNEL_HOOKDET 0x05 -+ -+#define RETU_HEADSET_KEY KEY_PHONE -+ -+struct retu_headset { -+ spinlock_t lock; -+ struct mutex mutex; -+ struct device *dev; -+ struct input_dev *idev; -+ unsigned bias_enabled; -+ unsigned detection_enabled; -+ unsigned pressed; -+ struct timer_list enable_timer; -+ struct timer_list detect_timer; -+ int irq; -+}; -+ -+static void retu_headset_set_bias(struct retu_headset *hs, int enable) -+{ -+ if (enable) { -+ retu_set_clear_reg_bits(hs->dev, RETU_REG_AUDTXR, -+ (1 << 0) | (1 << 1), 0); -+ msleep(2); -+ retu_set_clear_reg_bits(hs->dev, RETU_REG_AUDTXR, -+ 1 << 3, 0); -+ } else { -+ retu_set_clear_reg_bits(hs->dev, RETU_REG_AUDTXR, 0, -+ (1 << 0) | (1 << 1) | (1 << 3)); -+ } -+} -+ -+static void retu_headset_enable(struct retu_headset *hs) -+{ -+ mutex_lock(&hs->mutex); -+ if (!hs->bias_enabled) { -+ hs->bias_enabled = 1; -+ retu_headset_set_bias(hs, 1); -+ } -+ mutex_unlock(&hs->mutex); -+} -+ -+static void retu_headset_disable(struct retu_headset *hs) -+{ -+ mutex_lock(&hs->mutex); -+ if (hs->bias_enabled) { -+ hs->bias_enabled = 0; -+ retu_headset_set_bias(hs, 0); -+ } -+ mutex_unlock(&hs->mutex); -+} -+ -+static void retu_headset_det_enable(struct retu_headset *hs) -+{ -+ mutex_lock(&hs->mutex); -+ if (!hs->detection_enabled) { -+ hs->detection_enabled = 1; -+ retu_set_clear_reg_bits(hs->dev, RETU_REG_CC1, -+ (1 << 10) | (1 << 8), 0); -+ } -+ mutex_unlock(&hs->mutex); -+} -+ -+static void retu_headset_det_disable(struct retu_headset *hs) -+{ -+ unsigned long flags; -+ -+ mutex_lock(&hs->mutex); -+ if (hs->detection_enabled) { -+ hs->detection_enabled = 0; -+ del_timer_sync(&hs->enable_timer); -+ del_timer_sync(&hs->detect_timer); -+ spin_lock_irqsave(&hs->lock, flags); -+ if (hs->pressed) -+ input_report_key(hs->idev, RETU_HEADSET_KEY, 0); -+ spin_unlock_irqrestore(&hs->lock, flags); -+ retu_set_clear_reg_bits(hs->dev, RETU_REG_CC1, 0, -+ (1 << 10) | (1 << 8)); -+ } -+ mutex_unlock(&hs->mutex); -+} -+ -+static ssize_t retu_headset_hookdet_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ int val; -+ -+ val = retu_read_adc(dev, RETU_ADC_CHANNEL_HOOKDET); -+ return sprintf(buf, "%d\n", val); -+} -+ -+static DEVICE_ATTR(hookdet, S_IRUGO, retu_headset_hookdet_show, NULL); -+ -+static ssize_t retu_headset_enable_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct retu_headset *hs = dev_get_drvdata(dev); -+ -+ return sprintf(buf, "%u\n", hs->bias_enabled); -+} -+ -+static ssize_t retu_headset_enable_store(struct device *dev, -+ struct device_attribute *attr, -+ const char *buf, size_t count) -+{ -+ struct retu_headset *hs = dev_get_drvdata(dev); -+ int enable; -+ -+ if (sscanf(buf, "%u", &enable) != 1) -+ return -EINVAL; -+ if (enable) -+ retu_headset_enable(hs); -+ else -+ retu_headset_disable(hs); -+ return count; -+} -+ -+static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR | S_IWGRP, -+ retu_headset_enable_show, retu_headset_enable_store); -+ -+static ssize_t retu_headset_enable_det_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct retu_headset *hs = dev_get_drvdata(dev); -+ -+ return sprintf(buf, "%u\n", hs->detection_enabled); -+} -+ -+static ssize_t retu_headset_enable_det_store(struct device *dev, -+ struct device_attribute *attr, -+ const char *buf, size_t count) -+{ -+ struct retu_headset *hs = dev_get_drvdata(dev); -+ int enable; -+ -+ if (sscanf(buf, "%u", &enable) != 1) -+ return -EINVAL; -+ if (enable) -+ retu_headset_det_enable(hs); -+ else -+ retu_headset_det_disable(hs); -+ return count; -+} -+ -+static DEVICE_ATTR(enable_det, S_IRUGO | S_IWUSR | S_IWGRP, -+ retu_headset_enable_det_show, -+ retu_headset_enable_det_store); -+ -+static irqreturn_t retu_headset_hook_interrupt(int irq, void *_hs) -+{ -+ struct retu_headset *hs = _hs; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&hs->lock, flags); -+ if (!hs->pressed) { -+ /* Headset button was just pressed down. */ -+ hs->pressed = 1; -+ input_report_key(hs->idev, RETU_HEADSET_KEY, 1); -+ } -+ spin_unlock_irqrestore(&hs->lock, flags); -+ retu_set_clear_reg_bits(hs->dev, RETU_REG_CC1, 0, -+ (1 << 10) | (1 << 8)); -+ mod_timer(&hs->enable_timer, jiffies + msecs_to_jiffies(50)); -+ -+ return IRQ_HANDLED; -+} -+ -+static void retu_headset_enable_timer(unsigned long arg) -+{ -+ struct retu_headset *hs = (struct retu_headset *) arg; -+ -+ retu_set_clear_reg_bits(hs->dev, RETU_REG_CC1, -+ (1 << 10) | (1 << 8), 0); -+ mod_timer(&hs->detect_timer, jiffies + msecs_to_jiffies(350)); -+} -+ -+static void retu_headset_detect_timer(unsigned long arg) -+{ -+ struct retu_headset *hs = (struct retu_headset *) arg; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&hs->lock, flags); -+ if (hs->pressed) { -+ hs->pressed = 0; -+ input_report_key(hs->idev, RETU_HEADSET_KEY, 0); -+ } -+ spin_unlock_irqrestore(&hs->lock, flags); -+} -+ -+static int __init retu_headset_probe(struct platform_device *pdev) -+{ -+ struct retu_headset *hs; -+ int irq; -+ int r; -+ -+ hs = kzalloc(sizeof(*hs), GFP_KERNEL); -+ if (hs == NULL) -+ return -ENOMEM; -+ -+ hs->dev = &pdev->dev; -+ -+ hs->idev = input_allocate_device(); -+ if (hs->idev == NULL) { -+ r = -ENOMEM; -+ goto err1; -+ } -+ hs->idev->name = "retu-headset"; -+ hs->idev->dev.parent = &pdev->dev; -+ set_bit(EV_KEY, hs->idev->evbit); -+ set_bit(RETU_HEADSET_KEY, hs->idev->keybit); -+ r = input_register_device(hs->idev); -+ if (r < 0) -+ goto err2; -+ -+ r = device_create_file(&pdev->dev, &dev_attr_hookdet); -+ if (r < 0) -+ goto err3; -+ r = device_create_file(&pdev->dev, &dev_attr_enable); -+ if (r < 0) -+ goto err4; -+ r = device_create_file(&pdev->dev, &dev_attr_enable_det); -+ if (r < 0) -+ goto err5; -+ platform_set_drvdata(pdev, hs); -+ -+ spin_lock_init(&hs->lock); -+ mutex_init(&hs->mutex); -+ setup_timer(&hs->enable_timer, retu_headset_enable_timer, -+ (unsigned long) hs); -+ setup_timer(&hs->detect_timer, retu_headset_detect_timer, -+ (unsigned long) hs); -+ -+ irq = platform_get_irq(pdev, 0); -+ hs->irq = irq; -+ -+ r = request_threaded_irq(irq, NULL, retu_headset_hook_interrupt, 0, -+ "hookdet", hs); -+ if (r != 0) { -+ dev_err(&pdev->dev, "hookdet IRQ not available\n"); -+ goto err6; -+ } -+ -+ return 0; -+err6: -+ device_remove_file(&pdev->dev, &dev_attr_enable_det); -+err5: -+ device_remove_file(&pdev->dev, &dev_attr_enable); -+err4: -+ device_remove_file(&pdev->dev, &dev_attr_hookdet); -+err3: -+ input_unregister_device(hs->idev); -+err2: -+ input_free_device(hs->idev); -+err1: -+ kfree(hs); -+ return r; -+} -+ -+static int retu_headset_remove(struct platform_device *pdev) -+{ -+ struct retu_headset *hs = platform_get_drvdata(pdev); -+ -+ device_remove_file(&pdev->dev, &dev_attr_hookdet); -+ device_remove_file(&pdev->dev, &dev_attr_enable); -+ device_remove_file(&pdev->dev, &dev_attr_enable_det); -+ retu_headset_disable(hs); -+ retu_headset_det_disable(hs); -+ free_irq(hs->irq, hs); -+ input_unregister_device(hs->idev); -+ input_free_device(hs->idev); -+ -+ return 0; -+} -+ -+static int retu_headset_suspend(struct platform_device *pdev, -+ pm_message_t mesg) -+{ -+ struct retu_headset *hs = platform_get_drvdata(pdev); -+ -+ mutex_lock(&hs->mutex); -+ if (hs->bias_enabled) -+ retu_headset_set_bias(hs, 0); -+ mutex_unlock(&hs->mutex); -+ -+ return 0; -+} -+ -+static int retu_headset_resume(struct platform_device *pdev) -+{ -+ struct retu_headset *hs = platform_get_drvdata(pdev); -+ -+ mutex_lock(&hs->mutex); -+ if (hs->bias_enabled) -+ retu_headset_set_bias(hs, 1); -+ mutex_unlock(&hs->mutex); -+ -+ return 0; -+} -+ -+static struct platform_driver retu_headset_driver = { -+ .remove = retu_headset_remove, -+ .suspend = retu_headset_suspend, -+ .resume = retu_headset_resume, -+ .driver = { -+ .name = "retu-headset", -+ }, -+}; -+ -+static int __init retu_headset_init(void) -+{ -+ return platform_driver_probe(&retu_headset_driver, retu_headset_probe); -+} -+ -+static void __exit retu_headset_exit(void) -+{ -+ platform_driver_unregister(&retu_headset_driver); -+} -+ -+module_init(retu_headset_init); -+module_exit(retu_headset_exit); -+ -+MODULE_DESCRIPTION("Retu/Vilma headset detection"); -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("Juha Yrjölä"); ---- /dev/null -+++ b/drivers/cbus/retu-pwrbutton.c -@@ -0,0 +1,165 @@ -+/** -+ * drivers/cbus/retu-pwrbutton.c -+ * -+ * Driver for sending retu power button event to input-layer -+ * -+ * Copyright (C) 2004-2010 Nokia Corporation -+ * -+ * Written by -+ * Ari Saastamoinen <ari.saastamoinen@elektrobit.com> -+ * Juha Yrjola <juha.yrjola@solidboot.com> -+ * -+ * Contact: Felipe Balbi <felipe.balbi@nokia.com> -+ * -+ * This file is subject to the terms and conditions of the GNU General -+ * Public License. See the file "COPYING" in the main directory of this -+ * archive for more details. -+ * -+ * 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 -+ */ -+ -+#include <linux/module.h> -+#include <linux/init.h> -+#include <linux/kernel.h> -+#include <linux/errno.h> -+#include <linux/input.h> -+#include <linux/jiffies.h> -+#include <linux/bitops.h> -+#include <linux/irq.h> -+#include <linux/interrupt.h> -+#include <linux/platform_device.h> -+#include <linux/slab.h> -+ -+#include "retu.h" -+ -+#define RETU_STATUS_PWRONX (1 << 5) -+ -+#define PWRBTN_DELAY 20 -+#define PWRBTN_UP 0 -+#define PWRBTN_PRESSED 1 -+ -+struct retu_pwrbutton { -+ struct input_dev *idev; -+ struct device *dev; -+ -+ int state; -+ int irq; -+}; -+ -+static irqreturn_t retubutton_irq(int irq, void *_pwr) -+{ -+ struct retu_pwrbutton *pwr = _pwr; -+ int state; -+ -+ if (retu_read_reg(pwr->dev, RETU_REG_STATUS) & RETU_STATUS_PWRONX) -+ state = PWRBTN_UP; -+ else -+ state = PWRBTN_PRESSED; -+ -+ if (pwr->state != state) { -+ input_report_key(pwr->idev, KEY_POWER, state); -+ input_sync(pwr->idev); -+ pwr->state = state; -+ } -+ -+ return IRQ_HANDLED; -+} -+ -+static int __init retubutton_probe(struct platform_device *pdev) -+{ -+ struct retu_pwrbutton *pwr; -+ int ret = 0; -+ -+ pwr = kzalloc(sizeof(*pwr), GFP_KERNEL); -+ if (!pwr) { -+ dev_err(&pdev->dev, "not enough memory\n"); -+ ret = -ENOMEM; -+ goto err0; -+ } -+ -+ pwr->dev = &pdev->dev; -+ pwr->irq = platform_get_irq(pdev, 0); -+ platform_set_drvdata(pdev, pwr); -+ -+ ret = request_threaded_irq(pwr->irq, NULL, retubutton_irq, 0, -+ "retu-pwrbutton", pwr); -+ if (ret < 0) { -+ dev_err(&pdev->dev, "Cannot allocate irq\n"); -+ goto err1; -+ } -+ -+ pwr->idev = input_allocate_device(); -+ if (!pwr->idev) { -+ dev_err(&pdev->dev, "can't allocate input device\n"); -+ ret = -ENOMEM; -+ goto err2; -+ } -+ -+ pwr->idev->evbit[0] = BIT_MASK(EV_KEY); -+ pwr->idev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER); -+ pwr->idev->name = "retu-pwrbutton"; -+ -+ ret = input_register_device(pwr->idev); -+ if (ret < 0) { -+ dev_err(&pdev->dev, "failed to register input device\n"); -+ goto err3; -+ } -+ -+ return 0; -+ -+err3: -+ input_free_device(pwr->idev); -+ -+err2: -+ free_irq(pwr->irq, pwr); -+ -+err1: -+ kfree(pwr); -+ -+err0: -+ return ret; -+} -+ -+static int __exit retubutton_remove(struct platform_device *pdev) -+{ -+ struct retu_pwrbutton *pwr = platform_get_drvdata(pdev); -+ -+ free_irq(pwr->irq, pwr); -+ input_unregister_device(pwr->idev); -+ input_free_device(pwr->idev); -+ kfree(pwr); -+ -+ return 0; -+} -+ -+static struct platform_driver retu_pwrbutton_driver = { -+ .remove = __exit_p(retubutton_remove), -+ .driver = { -+ .name = "retu-pwrbutton", -+ }, -+}; -+ -+static int __init retubutton_init(void) -+{ -+ return platform_driver_probe(&retu_pwrbutton_driver, retubutton_probe); -+} -+module_init(retubutton_init); -+ -+static void __exit retubutton_exit(void) -+{ -+ platform_driver_unregister(&retu_pwrbutton_driver); -+} -+module_exit(retubutton_exit); -+ -+MODULE_DESCRIPTION("Retu Power Button"); -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("Ari Saastamoinen"); -+MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>"); -+ ---- /dev/null -+++ b/drivers/cbus/retu-rtc.c -@@ -0,0 +1,287 @@ -+/** -+ * drivers/cbus/retu-rtc.c -+ * -+ * Support for Retu RTC -+ * -+ * Copyright (C) 2004, 2005 Nokia Corporation -+ * -+ * Written by Paul Mundt <paul.mundt@nokia.com> and -+ * Igor Stoppa <igor.stoppa@nokia.com> -+ * -+ * The Retu RTC is essentially a partial read-only RTC that gives us Retu's -+ * idea of what time actually is. It's left as a userspace excercise to map -+ * this back to time in the real world and ensure that calibration settings -+ * are sane to compensate for any horrible drift (on account of not being able -+ * to set the clock to anything). -+ * -+ * Days are semi-writeable. Namely, Retu will only track 255 days for us -+ * consecutively, after which the counter is explicitly stuck at 255 until -+ * someone comes along and clears it with a write. In the event that no one -+ * comes along and clears it, we no longer have any idea what day it is. -+ * -+ * This file is subject to the terms and conditions of the GNU General -+ * Public License. See the file "COPYING" in the main directory of this -+ * archive for more details. -+ * -+ * 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 -+ */ -+ -+#include <linux/device.h> -+#include <linux/init.h> -+#include <linux/kernel.h> -+#include <linux/slab.h> -+#include <linux/module.h> -+#include <linux/platform_device.h> -+#include <linux/mutex.h> -+#include <linux/rtc.h> -+ -+#include "cbus.h" -+#include "retu.h" -+ -+struct retu_rtc { -+ /* device lock */ -+ struct mutex mutex; -+ struct device *dev; -+ struct rtc_device *rtc; -+ -+ u16 alarm_expired; -+ int irq_rtcs; -+ int irq_rtca; -+}; -+ -+static void retu_rtc_do_reset(struct retu_rtc *rtc) -+{ -+ u16 ccr1; -+ -+ ccr1 = retu_read_reg(rtc->dev, RETU_REG_CC1); -+ /* RTC in reset */ -+ retu_write_reg(rtc->dev, RETU_REG_CC1, ccr1 | 0x0001); -+ /* RTC in normal operating mode */ -+ retu_write_reg(rtc->dev, RETU_REG_CC1, ccr1 & ~0x0001); -+ -+ /* Disable alarm and RTC WD */ -+ retu_write_reg(rtc->dev, RETU_REG_RTCHMAR, 0x7f3f); -+ /* Set Calibration register to default value */ -+ retu_write_reg(rtc->dev, RETU_REG_RTCCALR, 0x00c0); -+ -+ rtc->alarm_expired = 0; -+} -+ -+static irqreturn_t retu_rtc_interrupt(int irq, void *_rtc) -+{ -+ struct retu_rtc *rtc = _rtc; -+ -+ mutex_lock(&rtc->mutex); -+ rtc->alarm_expired = 1; -+ retu_write_reg(rtc->dev, RETU_REG_RTCHMAR, (24 << 8) | 60); -+ mutex_unlock(&rtc->mutex); -+ -+ return IRQ_HANDLED; -+} -+ -+static int retu_rtc_init_irq(struct retu_rtc *rtc) -+{ -+ int irq; -+ int ret; -+ -+ irq = platform_get_irq(to_platform_device(rtc->dev), 0); -+ rtc->irq_rtcs = irq; -+ -+ irq = platform_get_irq(to_platform_device(rtc->dev), 1); -+ rtc->irq_rtca = irq; -+ -+ ret = request_threaded_irq(rtc->irq_rtcs, NULL, retu_rtc_interrupt, -+ 0, "RTCS", rtc); -+ if (ret != 0) -+ return ret; -+ -+ ret = request_threaded_irq(rtc->irq_rtca, NULL, retu_rtc_interrupt, -+ 0, "RTCA", rtc); -+ if (ret != 0) { -+ free_irq(rtc->irq_rtcs, rtc); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static int retu_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) -+{ -+ struct retu_rtc *rtc = dev_get_drvdata(dev); -+ u16 chmar; -+ -+ mutex_lock(&rtc->mutex); -+ -+ chmar = ((alm->time.tm_hour & 0x1f) << 8) | (alm->time.tm_min & 0x3f); -+ retu_write_reg(rtc->dev, RETU_REG_RTCHMAR, chmar); -+ -+ mutex_unlock(&rtc->mutex); -+ -+ return 0; -+} -+ -+static int retu_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) -+{ -+ struct retu_rtc *rtc = dev_get_drvdata(dev); -+ u16 chmar; -+ -+ mutex_lock(&rtc->mutex); -+ -+ chmar = retu_read_reg(rtc->dev, RETU_REG_RTCHMAR); -+ -+ alm->time.tm_hour = (chmar >> 8) & 0x1f; -+ alm->time.tm_min = chmar & 0x3f; -+ alm->enabled = !!rtc->alarm_expired; -+ -+ mutex_unlock(&rtc->mutex); -+ -+ return 0; -+} -+ -+static int retu_rtc_set_time(struct device *dev, struct rtc_time *tm) -+{ -+ struct retu_rtc *rtc = dev_get_drvdata(dev); -+ u16 dsr; -+ u16 hmr; -+ -+ dsr = ((tm->tm_mday & 0xff) << 8) | (tm->tm_hour & 0xff); -+ hmr = ((tm->tm_min & 0xff) << 8) | (tm->tm_sec & 0xff); -+ -+ mutex_lock(&rtc->mutex); -+ -+ retu_write_reg(rtc->dev, RETU_REG_RTCDSR, dsr); -+ retu_write_reg(rtc->dev, RETU_REG_RTCHMR, hmr); -+ -+ mutex_unlock(&rtc->mutex); -+ -+ return 0; -+} -+ -+static int retu_rtc_read_time(struct device *dev, struct rtc_time *tm) -+{ -+ struct retu_rtc *rtc = dev_get_drvdata(dev); -+ u16 dsr; -+ u16 hmr; -+ -+ /* -+ * DSR holds days and hours -+ * HMR hols minutes and seconds -+ * -+ * both are 16 bit registers with 8-bit for each field. -+ */ -+ -+ mutex_lock(&rtc->mutex); -+ -+ dsr = retu_read_reg(rtc->dev, RETU_REG_RTCDSR); -+ hmr = retu_read_reg(rtc->dev, RETU_REG_RTCHMR); -+ -+ tm->tm_sec = hmr & 0xff; -+ tm->tm_min = hmr >> 8; -+ tm->tm_hour = dsr & 0xff; -+ tm->tm_mday = dsr >> 8; -+ -+ mutex_unlock(&rtc->mutex); -+ -+ return 0; -+} -+ -+static struct rtc_class_ops retu_rtc_ops = { -+ .read_time = retu_rtc_read_time, -+ .set_time = retu_rtc_set_time, -+ .read_alarm = retu_rtc_read_alarm, -+ .set_alarm = retu_rtc_set_alarm, -+}; -+ -+static int __init retu_rtc_probe(struct platform_device *pdev) -+{ -+ struct retu_rtc *rtc; -+ int r; -+ -+ rtc = kzalloc(sizeof(*rtc), GFP_KERNEL); -+ if (!rtc) { -+ dev_err(&pdev->dev, "not enough memory\n"); -+ r = -ENOMEM; -+ goto err0; -+ } -+ -+ rtc->dev = &pdev->dev; -+ platform_set_drvdata(pdev, rtc); -+ mutex_init(&rtc->mutex); -+ -+ rtc->alarm_expired = retu_read_reg(rtc->dev, RETU_REG_IDR) & -+ (0x1 << RETU_INT_RTCA); -+ -+ r = retu_rtc_init_irq(rtc); -+ if (r < 0) { -+ dev_err(&pdev->dev, "failed to request retu irq\n"); -+ goto err1; -+ } -+ -+ /* If the calibration register is zero, we've probably lost power */ -+ if (!(retu_read_reg(rtc->dev, RETU_REG_RTCCALR) & 0x00ff)) -+ retu_rtc_do_reset(rtc); -+ -+ rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, & -+ retu_rtc_ops, THIS_MODULE); -+ if (IS_ERR(rtc->rtc)) { -+ dev_err(&pdev->dev, "can't register RTC device\n"); -+ goto err2; -+ } -+ -+ return 0; -+ -+err2: -+ free_irq(rtc->irq_rtcs, rtc); -+ free_irq(rtc->irq_rtca, rtc); -+ -+err1: -+ kfree(rtc); -+ -+err0: -+ return r; -+} -+ -+static int __devexit retu_rtc_remove(struct platform_device *pdev) -+{ -+ struct retu_rtc *rtc = platform_get_drvdata(pdev); -+ -+ free_irq(rtc->irq_rtcs, rtc); -+ free_irq(rtc->irq_rtca, rtc); -+ rtc_device_unregister(rtc->rtc); -+ kfree(rtc); -+ -+ return 0; -+} -+ -+static struct platform_driver retu_rtc_driver = { -+ .remove = __exit_p(retu_rtc_remove), -+ .driver = { -+ .name = "retu-rtc", -+ }, -+}; -+ -+static int __init retu_rtc_init(void) -+{ -+ return platform_driver_probe(&retu_rtc_driver, retu_rtc_probe); -+} -+module_init(retu_rtc_init); -+ -+static void __exit retu_rtc_exit(void) -+{ -+ platform_driver_unregister(&retu_rtc_driver); -+} -+module_exit(retu_rtc_exit); -+ -+MODULE_DESCRIPTION("Retu RTC"); -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("Paul Mundt"); -+MODULE_AUTHOR("Igor Stoppa"); -+MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>"); -+ ---- /dev/null -+++ b/drivers/cbus/retu-wdt.c -@@ -0,0 +1,358 @@ -+/** -+ * drivers/cbus/retu-wdt.c -+ * -+ * Driver for Retu watchdog -+ * -+ * Copyright (C) 2004, 2005 Nokia Corporation -+ * -+ * Written by Amit Kucheria <amit.kucheria@nokia.com> -+ * -+ * This file is subject to the terms and conditions of the GNU General -+ * Public License. See the file "COPYING" in the main directory of this -+ * archive for more details. -+ * -+ * 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 -+ */ -+ -+#include <linux/kernel.h> -+#include <linux/slab.h> -+#include <linux/module.h> -+#include <linux/device.h> -+#include <linux/init.h> -+#include <linux/fs.h> -+#include <linux/io.h> -+#include <linux/platform_device.h> -+ -+#include <linux/completion.h> -+#include <linux/errno.h> -+#include <linux/moduleparam.h> -+#include <linux/miscdevice.h> -+#include <linux/watchdog.h> -+ -+#include <asm/uaccess.h> -+ -+#include <plat/prcm.h> -+ -+#include "cbus.h" -+#include "retu.h" -+ -+/* Watchdog timeout in seconds */ -+#define RETU_WDT_MIN_TIMER 0 -+#define RETU_WDT_DEFAULT_TIMER 32 -+#define RETU_WDT_MAX_TIMER 63 -+ -+static DEFINE_MUTEX(retu_wdt_mutex); -+ -+/* Current period of watchdog */ -+static unsigned int period_val = RETU_WDT_DEFAULT_TIMER; -+static int counter_param = RETU_WDT_MAX_TIMER; -+ -+struct retu_wdt_dev { -+ struct device *dev; -+ int users; -+ struct miscdevice retu_wdt_miscdev; -+ struct timer_list ping_timer; -+}; -+ -+static struct retu_wdt_dev *retu_wdt; -+ -+static void retu_wdt_set_ping_timer(unsigned long enable); -+ -+static int _retu_modify_counter(unsigned int new) -+{ -+ if (retu_wdt) -+ retu_write_reg(retu_wdt->dev, RETU_REG_WATCHDOG, (u16)new); -+ -+ return 0; -+} -+ -+static int retu_modify_counter(unsigned int new) -+{ -+ if (new < RETU_WDT_MIN_TIMER || new > RETU_WDT_MAX_TIMER) -+ return -EINVAL; -+ -+ mutex_lock(&retu_wdt_mutex); -+ period_val = new; -+ _retu_modify_counter(period_val); -+ mutex_unlock(&retu_wdt_mutex); -+ -+ return 0; -+} -+ -+static ssize_t retu_wdt_period_show(struct device *dev, -+ struct device_attribute *attr, char *buf) -+{ -+ /* Show current max counter */ -+ return sprintf(buf, "%u\n", (u16)period_val); -+} -+ -+/* -+ * Note: This inteface is non-standard and likely to disappear! -+ * Use /dev/watchdog instead, that's the standard. -+ */ -+static ssize_t retu_wdt_period_store(struct device *dev, -+ struct device_attribute *attr, -+ const char *buf, size_t count) -+{ -+ unsigned int new_period; -+ int ret; -+ -+#ifdef CONFIG_WATCHDOG_NOWAYOUT -+ retu_wdt_set_ping_timer(0); -+#endif -+ -+ if (sscanf(buf, "%u", &new_period) != 1) { -+ printk(KERN_ALERT "retu_wdt_period_store: Invalid input\n"); -+ return -EINVAL; -+ } -+ -+ ret = retu_modify_counter(new_period); -+ if (ret < 0) -+ return ret; -+ -+ return strnlen(buf, count); -+} -+ -+static ssize_t retu_wdt_counter_show(struct device *dev, -+ struct device_attribute *attr, char *buf) -+{ -+ u16 counter; -+ -+ /* Show current value in watchdog counter */ -+ counter = retu_read_reg(dev, RETU_REG_WATCHDOG); -+ -+ /* Only the 5 LSB are important */ -+ return snprintf(buf, PAGE_SIZE, "%u\n", (counter & 0x3F)); -+} -+ -+static DEVICE_ATTR(period, S_IRUGO | S_IWUSR, retu_wdt_period_show, \ -+ retu_wdt_period_store); -+static DEVICE_ATTR(counter, S_IRUGO, retu_wdt_counter_show, NULL); -+ -+/*----------------------------------------------------------------------------*/ -+ -+/* -+ * Since retu watchdog cannot be disabled in hardware, we must kick it -+ * with a timer until userspace watchdog software takes over. Do this -+ * unless /dev/watchdog is open or CONFIG_WATCHDOG_NOWAYOUT is set. -+ */ -+static void retu_wdt_set_ping_timer(unsigned long enable) -+{ -+ _retu_modify_counter(RETU_WDT_MAX_TIMER); -+ if (enable) -+ mod_timer(&retu_wdt->ping_timer, -+ jiffies + RETU_WDT_DEFAULT_TIMER * HZ); -+ else -+ del_timer_sync(&retu_wdt->ping_timer); -+} -+ -+static int retu_wdt_open(struct inode *inode, struct file *file) -+{ -+ if (test_and_set_bit(1, (unsigned long *)&(retu_wdt->users))) -+ return -EBUSY; -+ -+ file->private_data = (void *)retu_wdt; -+ retu_wdt_set_ping_timer(0); -+ -+ return nonseekable_open(inode, file); -+} -+ -+static int retu_wdt_release(struct inode *inode, struct file *file) -+{ -+ struct retu_wdt_dev *wdev = file->private_data; -+ -+#ifndef CONFIG_WATCHDOG_NOWAYOUT -+ retu_wdt_set_ping_timer(1); -+#endif -+ wdev->users = 0; -+ -+ return 0; -+} -+ -+static ssize_t retu_wdt_write(struct file *file, const char __user *data, -+ size_t len, loff_t *ppos) -+{ -+ if (len) -+ retu_modify_counter(RETU_WDT_MAX_TIMER); -+ -+ return len; -+} -+ -+static long retu_wdt_ioctl(struct file *file, unsigned int cmd, -+ unsigned long arg) -+{ -+ int new_margin; -+ -+ static struct watchdog_info ident = { -+ .identity = "Retu Watchdog", -+ .options = WDIOF_SETTIMEOUT, -+ .firmware_version = 0, -+ }; -+ -+ switch (cmd) { -+ default: -+ return -ENOTTY; -+ case WDIOC_GETSUPPORT: -+ return copy_to_user((struct watchdog_info __user *)arg, &ident, -+ sizeof(ident)); -+ case WDIOC_GETSTATUS: -+ return put_user(0, (int __user *)arg); -+ case WDIOC_GETBOOTSTATUS: -+ if (cpu_is_omap16xx()) -+ return put_user(omap_readw(ARM_SYSST), -+ (int __user *)arg); -+ if (cpu_is_omap24xx()) -+ return put_user(omap_prcm_get_reset_sources(), -+ (int __user *)arg); -+ case WDIOC_KEEPALIVE: -+ retu_modify_counter(RETU_WDT_MAX_TIMER); -+ break; -+ case WDIOC_SETTIMEOUT: -+ if (get_user(new_margin, (int __user *)arg)) -+ return -EFAULT; -+ retu_modify_counter(new_margin); -+ /* Fall through */ -+ case WDIOC_GETTIMEOUT: -+ return put_user(period_val, (int __user *)arg); -+ } -+ -+ return 0; -+} -+ -+/* Start kicking retu watchdog until user space starts doing the kicking */ -+static int __devinit retu_wdt_ping(void) -+{ -+#ifdef CONFIG_WATCHDOG_NOWAYOUT -+ retu_modify_counter(RETU_WDT_MAX_TIMER); -+#else -+ retu_wdt_set_ping_timer(1); -+#endif -+ -+ return 0; -+} -+ -+static const struct file_operations retu_wdt_fops = { -+ .owner = THIS_MODULE, -+ .write = retu_wdt_write, -+ .unlocked_ioctl = retu_wdt_ioctl, -+ .open = retu_wdt_open, -+ .release = retu_wdt_release, -+}; -+ -+/*----------------------------------------------------------------------------*/ -+ -+static int __init retu_wdt_probe(struct platform_device *pdev) -+{ -+ struct retu_wdt_dev *wdev; -+ int ret; -+ -+ wdev = kzalloc(sizeof(struct retu_wdt_dev), GFP_KERNEL); -+ if (!wdev) -+ return -ENOMEM; -+ -+ wdev->dev = &pdev->dev; -+ wdev->users = 0; -+ -+ ret = device_create_file(&pdev->dev, &dev_attr_period); -+ if (ret) { -+ dev_err(&pdev->dev, "Error creating sysfs period\n"); -+ goto free1; -+ } -+ -+ ret = device_create_file(&pdev->dev, &dev_attr_counter); -+ if (ret) { -+ dev_err(&pdev->dev, "Error creating sysfs counter\n"); -+ goto free2; -+ } -+ -+ platform_set_drvdata(pdev, wdev); -+ retu_wdt = wdev; -+ wdev->retu_wdt_miscdev.parent = &pdev->dev; -+ wdev->retu_wdt_miscdev.minor = WATCHDOG_MINOR; -+ wdev->retu_wdt_miscdev.name = "watchdog"; -+ wdev->retu_wdt_miscdev.fops = &retu_wdt_fops; -+ -+ ret = misc_register(&(wdev->retu_wdt_miscdev)); -+ if (ret) -+ goto free3; -+ -+ setup_timer(&wdev->ping_timer, retu_wdt_set_ping_timer, 1); -+ -+ /* passed as module parameter? */ -+ ret = retu_modify_counter(counter_param); -+ if (ret == -EINVAL) { -+ ret = retu_modify_counter(RETU_WDT_DEFAULT_TIMER); -+ dev_dbg(&pdev->dev, "Initializing to default value\n"); -+ } -+ -+ /* Kick the watchdog for kernel booting to finish */ -+ retu_modify_counter(RETU_WDT_MAX_TIMER); -+ -+ ret = retu_wdt_ping(); -+ if (ret < 0) { -+ dev_err(&pdev->dev, "Failed to ping\n"); -+ goto free4; -+ } -+ -+ return 0; -+ -+free4: -+ misc_deregister(&wdev->retu_wdt_miscdev); -+ -+free3: -+ device_remove_file(&pdev->dev, &dev_attr_counter); -+ -+free2: -+ device_remove_file(&pdev->dev, &dev_attr_period); -+ -+free1: -+ kfree(wdev); -+ -+ return ret; -+} -+ -+static int __devexit retu_wdt_remove(struct platform_device *pdev) -+{ -+ struct retu_wdt_dev *wdev; -+ -+ wdev = platform_get_drvdata(pdev); -+ misc_deregister(&wdev->retu_wdt_miscdev); -+ device_remove_file(&pdev->dev, &dev_attr_period); -+ device_remove_file(&pdev->dev, &dev_attr_counter); -+ kfree(wdev); -+ -+ return 0; -+} -+ -+static struct platform_driver retu_wdt_driver = { -+ .remove = __exit_p(retu_wdt_remove), -+ .driver = { -+ .name = "retu-wdt", -+ }, -+}; -+ -+static int __init retu_wdt_init(void) -+{ -+ return platform_driver_probe(&retu_wdt_driver, retu_wdt_probe); -+} -+ -+static void __exit retu_wdt_exit(void) -+{ -+ platform_driver_unregister(&retu_wdt_driver); -+} -+ -+module_init(retu_wdt_init); -+module_exit(retu_wdt_exit); -+module_param(counter_param, int, 0); -+ -+MODULE_DESCRIPTION("Retu WatchDog"); -+MODULE_AUTHOR("Amit Kucheria"); -+MODULE_LICENSE("GPL"); -+ ---- /dev/null -+++ b/drivers/cbus/tahvo.c -@@ -0,0 +1,391 @@ -+/** -+ * drivers/cbus/tahvo.c -+ * -+ * Support functions for Tahvo ASIC -+ * -+ * Copyright (C) 2004, 2005 Nokia Corporation -+ * -+ * Written by Juha Yrjölä <juha.yrjola@nokia.com>, -+ * David Weinehall <david.weinehall@nokia.com>, and -+ * Mikko Ylinen <mikko.k.ylinen@nokia.com> -+ * -+ * This file is subject to the terms and conditions of the GNU General -+ * Public License. See the file "COPYING" in the main directory of this -+ * archive for more details. -+ * -+ * 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 -+ */ -+ -+#include <linux/module.h> -+#include <linux/init.h> -+ -+#include <linux/kernel.h> -+#include <linux/errno.h> -+#include <linux/device.h> -+#include <linux/miscdevice.h> -+#include <linux/poll.h> -+#include <linux/fs.h> -+#include <linux/irq.h> -+#include <linux/interrupt.h> -+#include <linux/platform_device.h> -+#include <linux/gpio.h> -+ -+#include <asm/uaccess.h> -+#include <asm/mach-types.h> -+ -+#include <plat/mux.h> -+#include <plat/board.h> -+ -+#include "cbus.h" -+#include "tahvo.h" -+ -+#define TAHVO_ID 0x02 -+#define PFX "tahvo: " -+ -+static int tahvo_initialized; -+static int tahvo_is_betty; -+ -+static struct tasklet_struct tahvo_tasklet; -+spinlock_t tahvo_lock = SPIN_LOCK_UNLOCKED; -+ -+struct tahvo_irq_handler_desc { -+ int (*func)(unsigned long); -+ unsigned long arg; -+ char name[8]; -+}; -+ -+static struct tahvo_irq_handler_desc tahvo_irq_handlers[MAX_TAHVO_IRQ_HANDLERS]; -+ -+int tahvo_get_status(void) -+{ -+ return tahvo_initialized; -+} -+EXPORT_SYMBOL(tahvo_get_status); -+ -+/** -+ * tahvo_read_reg - Read a value from a register in Tahvo -+ * @reg: the register to read from -+ * -+ * This function returns the contents of the specified register -+ */ -+int tahvo_read_reg(unsigned reg) -+{ -+ BUG_ON(!tahvo_initialized); -+ return cbus_read_reg(TAHVO_ID, reg); -+} -+EXPORT_SYMBOL(tahvo_read_reg); -+ -+/** -+ * tahvo_write_reg - Write a value to a register in Tahvo -+ * @reg: the register to write to -+ * @reg: the value to write to the register -+ * -+ * This function writes a value to the specified register -+ */ -+void tahvo_write_reg(unsigned reg, u16 val) -+{ -+ BUG_ON(!tahvo_initialized); -+ cbus_write_reg(TAHVO_ID, reg, val); -+} -+EXPORT_SYMBOL(tahvo_write_reg); -+ -+/** -+ * tahvo_set_clear_reg_bits - set and clear register bits atomically -+ * @reg: the register to write to -+ * @bits: the bits to set -+ * -+ * This function sets and clears the specified Tahvo register bits atomically -+ */ -+void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear) -+{ -+ unsigned long flags; -+ u16 w; -+ -+ spin_lock_irqsave(&tahvo_lock, flags); -+ w = tahvo_read_reg(reg); -+ w &= ~clear; -+ w |= set; -+ tahvo_write_reg(reg, w); -+ spin_unlock_irqrestore(&tahvo_lock, flags); -+} -+ -+/* -+ * Disable given TAHVO interrupt -+ */ -+void tahvo_disable_irq(int id) -+{ -+ unsigned long flags; -+ u16 mask; -+ -+ spin_lock_irqsave(&tahvo_lock, flags); -+ mask = tahvo_read_reg(TAHVO_REG_IMR); -+ mask |= 1 << id; -+ tahvo_write_reg(TAHVO_REG_IMR, mask); -+ spin_unlock_irqrestore(&tahvo_lock, flags); -+} -+EXPORT_SYMBOL(tahvo_disable_irq); -+ -+/* -+ * Enable given TAHVO interrupt -+ */ -+void tahvo_enable_irq(int id) -+{ -+ unsigned long flags; -+ u16 mask; -+ -+ spin_lock_irqsave(&tahvo_lock, flags); -+ mask = tahvo_read_reg(TAHVO_REG_IMR); -+ mask &= ~(1 << id); -+ tahvo_write_reg(TAHVO_REG_IMR, mask); -+ spin_unlock_irqrestore(&tahvo_lock, flags); -+} -+EXPORT_SYMBOL(tahvo_enable_irq); -+ -+/* -+ * Acknowledge given TAHVO interrupt -+ */ -+void tahvo_ack_irq(int id) -+{ -+ tahvo_write_reg(TAHVO_REG_IDR, 1 << id); -+} -+EXPORT_SYMBOL(tahvo_ack_irq); -+ -+static int tahvo_7bit_backlight; -+ -+int tahvo_get_backlight_level(void) -+{ -+ int mask; -+ -+ if (tahvo_7bit_backlight) -+ mask = 0x7f; -+ else -+ mask = 0x0f; -+ return tahvo_read_reg(TAHVO_REG_LEDPWMR) & mask; -+} -+EXPORT_SYMBOL(tahvo_get_backlight_level); -+ -+int tahvo_get_max_backlight_level(void) -+{ -+ if (tahvo_7bit_backlight) -+ return 0x7f; -+ else -+ return 0x0f; -+} -+EXPORT_SYMBOL(tahvo_get_max_backlight_level); -+ -+void tahvo_set_backlight_level(int level) -+{ -+ int max_level; -+ -+ max_level = tahvo_get_max_backlight_level(); -+ if (level > max_level) -+ level = max_level; -+ tahvo_write_reg(TAHVO_REG_LEDPWMR, level); -+} -+EXPORT_SYMBOL(tahvo_set_backlight_level); -+ -+/* -+ * TAHVO interrupt handler. Only schedules the tasklet. -+ */ -+static irqreturn_t tahvo_irq_handler(int irq, void *dev_id) -+{ -+ tasklet_schedule(&tahvo_tasklet); -+ return IRQ_HANDLED; -+} -+ -+/* -+ * Tasklet handler -+ */ -+static void tahvo_tasklet_handler(unsigned long data) -+{ -+ struct tahvo_irq_handler_desc *hnd; -+ u16 id; -+ u16 im; -+ int i; -+ -+ for (;;) { -+ id = tahvo_read_reg(TAHVO_REG_IDR); -+ im = ~tahvo_read_reg(TAHVO_REG_IMR); -+ id &= im; -+ -+ if (!id) -+ break; -+ -+ for (i = 0; id != 0; i++, id >>= 1) { -+ if (!(id & 1)) -+ continue; -+ hnd = &tahvo_irq_handlers[i]; -+ if (hnd->func == NULL) { -+ /* Spurious tahvo interrupt - just ack it */ -+ printk(KERN_INFO "Spurious Tahvo interrupt " -+ "(id %d)\n", i); -+ tahvo_disable_irq(i); -+ tahvo_ack_irq(i); -+ continue; -+ } -+ hnd->func(hnd->arg); -+ /* -+ * Don't acknowledge the interrupt here -+ * It must be done explicitly -+ */ -+ } -+ } -+} -+ -+/* -+ * Register the handler for a given TAHVO interrupt source. -+ */ -+int tahvo_request_irq(int id, void *irq_handler, unsigned long arg, char *name) -+{ -+ struct tahvo_irq_handler_desc *hnd; -+ -+ if (irq_handler == NULL || id >= MAX_TAHVO_IRQ_HANDLERS || -+ name == NULL) { -+ printk(KERN_ERR PFX "Invalid arguments to %s\n", -+ __FUNCTION__); -+ return -EINVAL; -+ } -+ hnd = &tahvo_irq_handlers[id]; -+ if (hnd->func != NULL) { -+ printk(KERN_ERR PFX "IRQ %d already reserved\n", id); -+ return -EBUSY; -+ } -+ printk(KERN_INFO PFX "Registering interrupt %d for device %s\n", -+ id, name); -+ hnd->func = irq_handler; -+ hnd->arg = arg; -+ strlcpy(hnd->name, name, sizeof(hnd->name)); -+ -+ tahvo_ack_irq(id); -+ tahvo_enable_irq(id); -+ -+ return 0; -+} -+EXPORT_SYMBOL(tahvo_request_irq); -+ -+/* -+ * Unregister the handler for a given TAHVO interrupt source. -+ */ -+void tahvo_free_irq(int id) -+{ -+ struct tahvo_irq_handler_desc *hnd; -+ -+ if (id >= MAX_TAHVO_IRQ_HANDLERS) { -+ printk(KERN_ERR PFX "Invalid argument to %s\n", -+ __FUNCTION__); -+ return; -+ } -+ hnd = &tahvo_irq_handlers[id]; -+ if (hnd->func == NULL) { -+ printk(KERN_ERR PFX "IRQ %d already freed\n", id); -+ return; -+ } -+ -+ tahvo_disable_irq(id); -+ hnd->func = NULL; -+} -+EXPORT_SYMBOL(tahvo_free_irq); -+ -+/** -+ * tahvo_probe - Probe for Tahvo ASIC -+ * @dev: the Tahvo device -+ * -+ * Probe for the Tahvo ASIC and allocate memory -+ * for its device-struct if found -+ */ -+static int __init tahvo_probe(struct platform_device *pdev) -+{ -+ int rev, id, ret; -+ int irq; -+ -+ /* Prepare tasklet */ -+ tasklet_init(&tahvo_tasklet, tahvo_tasklet_handler, 0); -+ -+ tahvo_initialized = 1; -+ -+ rev = tahvo_read_reg(TAHVO_REG_ASICR); -+ -+ id = (rev >> 8) & 0xff; -+ if (id == 0x03) { -+ if ((rev & 0xff) >= 0x50) -+ tahvo_7bit_backlight = 1; -+ } else if (id == 0x0b) { -+ tahvo_is_betty = 1; -+ tahvo_7bit_backlight = 1; -+ } else { -+ dev_err(&pdev->dev, "Tahvo/Betty chip not found"); -+ return -ENODEV; -+ } -+ -+ dev_err(&pdev->dev, "%s v%d.%d found\n", tahvo_is_betty ? "Betty" : "Tahvo", -+ (rev >> 4) & 0x0f, rev & 0x0f); -+ -+ irq = platform_get_irq(pdev, 0); -+ -+ /* Mask all TAHVO interrupts */ -+ tahvo_write_reg(TAHVO_REG_IMR, 0xffff); -+ -+ ret = request_irq(irq, tahvo_irq_handler, IRQF_TRIGGER_RISING, -+ "tahvo", 0); -+ if (ret < 0) { -+ dev_err(&pdev->dev, "Unable to register IRQ handler\n"); -+ return ret; -+ } -+ return 0; -+} -+ -+static int __exit tahvo_remove(struct platform_device *pdev) -+{ -+ int irq; -+ -+ irq = platform_get_irq(pdev, 0); -+ -+ /* Mask all TAHVO interrupts */ -+ tahvo_write_reg(TAHVO_REG_IMR, 0xffff); -+ free_irq(irq, 0); -+ tasklet_kill(&tahvo_tasklet); -+ -+ return 0; -+} -+ -+static struct platform_driver tahvo_driver = { -+ .remove = __exit_p(tahvo_remove), -+ .driver = { -+ .name = "tahvo", -+ }, -+}; -+ -+/** -+ * tahvo_init - initialise Tahvo driver -+ * -+ * Initialise the Tahvo driver and return 0 if everything worked ok -+ */ -+static int __init tahvo_init(void) -+{ -+ return platform_driver_probe(&tahvo_driver, tahvo_probe); -+} -+ -+/* -+ * Cleanup -+ */ -+static void __exit tahvo_exit(void) -+{ -+ platform_driver_unregister(&tahvo_driver); -+} -+ -+subsys_initcall(tahvo_init); -+module_exit(tahvo_exit); -+ -+MODULE_DESCRIPTION("Tahvo ASIC control"); -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("Juha Yrjölä"); -+MODULE_AUTHOR("David Weinehall"); -+MODULE_AUTHOR("Mikko Ylinen"); -+ ---- /dev/null -+++ b/drivers/cbus/tahvo.h -@@ -0,0 +1,57 @@ -+/* -+ * drivers/cbus/tahvo.h -+ * -+ * Copyright (C) 2004, 2005 Nokia Corporation -+ * -+ * Written by Juha Yrjölä <juha.yrjola@nokia.com> and -+ * David Weinehall <david.weinehall@nokia.com> -+ * -+ * This file is subject to the terms and conditions of the GNU General -+ * Public License. See the file "COPYING" in the main directory of this -+ * archive for more details. -+ * -+ * 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 -+ */ -+ -+#ifndef __DRIVERS_CBUS_TAHVO_H -+#define __DRIVERS_CBUS_TAHVO_H -+ -+#include <linux/types.h> -+ -+/* Registers */ -+#define TAHVO_REG_ASICR 0x00 /* ASIC ID & revision */ -+#define TAHVO_REG_IDR 0x01 /* Interrupt ID */ -+#define TAHVO_REG_IDSR 0x02 /* Interrupt status */ -+#define TAHVO_REG_IMR 0x03 /* Interrupt mask */ -+#define TAHVO_REG_LEDPWMR 0x05 /* LED PWM */ -+#define TAHVO_REG_USBR 0x06 /* USB control */ -+#define TAHVO_REG_MAX 0x0d -+ -+/* Interrupt sources */ -+#define TAHVO_INT_VBUSON 0 -+ -+#define MAX_TAHVO_IRQ_HANDLERS 8 -+ -+int tahvo_get_status(void); -+int tahvo_read_reg(unsigned reg); -+void tahvo_write_reg(unsigned reg, u16 val); -+void tahvo_set_clear_reg_bits(unsigned reg, u16 set, u16 clear); -+int tahvo_request_irq(int id, void *irq_handler, unsigned long arg, char *name); -+void tahvo_free_irq(int id); -+void tahvo_enable_irq(int id); -+void tahvo_disable_irq(int id); -+void tahvo_ack_irq(int id); -+int tahvo_get_backlight_level(void); -+int tahvo_get_max_backlight_level(void); -+void tahvo_set_backlight_level(int level); -+ -+extern spinlock_t tahvo_lock; -+ -+#endif /* __DRIVERS_CBUS_TAHVO_H */ ---- /dev/null -+++ b/drivers/cbus/tahvo-usb.c -@@ -0,0 +1,773 @@ -+/** -+ * drivers/cbus/tahvo-usb.c -+ * -+ * Tahvo USB transeiver -+ * -+ * Copyright (C) 2005-2006 Nokia Corporation -+ * -+ * Parts copied from drivers/i2c/chips/isp1301_omap.c -+ * Copyright (C) 2004 Texas Instruments -+ * Copyright (C) 2004 David Brownell -+ * -+ * Written by Juha Yrjölä <juha.yrjola@nokia.com>, -+ * Tony Lindgren <tony@atomide.com>, and -+ * Timo Teräs <timo.teras@nokia.com> -+ * -+ * This file is subject to the terms and conditions of the GNU General -+ * Public License. See the file "COPYING" in the main directory of this -+ * archive for more details. -+ * -+ * 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 -+ */ -+ -+#include <linux/kernel.h> -+#include <linux/module.h> -+#include <linux/init.h> -+#include <linux/slab.h> -+#include <linux/io.h> -+#include <linux/interrupt.h> -+#include <linux/platform_device.h> -+#include <linux/usb/ch9.h> -+#include <linux/usb/gadget.h> -+#include <linux/usb.h> -+#include <linux/usb/otg.h> -+#include <linux/i2c.h> -+#include <linux/workqueue.h> -+#include <linux/kobject.h> -+#include <linux/clk.h> -+#include <linux/mutex.h> -+ -+#include <asm/irq.h> -+#include <plat/usb.h> -+ -+#include "cbus.h" -+#include "tahvo.h" -+ -+#define DRIVER_NAME "tahvo-usb" -+ -+#define USBR_SLAVE_CONTROL (1 << 8) -+#define USBR_VPPVIO_SW (1 << 7) -+#define USBR_SPEED (1 << 6) -+#define USBR_REGOUT (1 << 5) -+#define USBR_MASTER_SW2 (1 << 4) -+#define USBR_MASTER_SW1 (1 << 3) -+#define USBR_SLAVE_SW (1 << 2) -+#define USBR_NSUSPEND (1 << 1) -+#define USBR_SEMODE (1 << 0) -+ -+/* bits in OTG_CTRL */ -+ -+/* Bits that are controlled by OMAP OTG and are read-only */ -+#define OTG_CTRL_OMAP_MASK (OTG_PULLDOWN|OTG_PULLUP|OTG_DRV_VBUS|\ -+ OTG_PD_VBUS|OTG_PU_VBUS|OTG_PU_ID) -+/* Bits that are controlled by transceiver */ -+#define OTG_CTRL_XCVR_MASK (OTG_ASESSVLD|OTG_BSESSEND|\ -+ OTG_BSESSVLD|OTG_VBUSVLD|OTG_ID) -+/* Bits that are controlled by system */ -+#define OTG_CTRL_SYS_MASK (OTG_A_BUSREQ|OTG_A_SETB_HNPEN|OTG_B_BUSREQ|\ -+ OTG_B_HNPEN|OTG_BUSDROP) -+ -+#if defined(CONFIG_USB_OHCI_HCD) && !defined(CONFIG_USB_OTG) -+#error tahvo-otg.c does not work with OCHI yet! -+#endif -+ -+#define TAHVO_MODE_HOST 0 -+#define TAHVO_MODE_PERIPHERAL 1 -+ -+#ifdef CONFIG_USB_OTG -+#define TAHVO_MODE(tu) (tu)->tahvo_mode -+#elif defined(CONFIG_USB_GADGET_OMAP) -+#define TAHVO_MODE(tu) TAHVO_MODE_PERIPHERAL -+#else -+#define TAHVO_MODE(tu) TAHVO_MODE_HOST -+#endif -+ -+struct tahvo_usb { -+ struct platform_device *pt_dev; -+ struct otg_transceiver otg; -+ int vbus_state; -+ struct work_struct irq_work; -+ struct mutex serialize; -+#ifdef CONFIG_USB_OTG -+ int tahvo_mode; -+#endif -+}; -+static struct platform_device tahvo_usb_device; -+ -+/* -+ * --------------------------------------------------------------------------- -+ * OTG related functions -+ * -+ * These shoud be separated into omap-otg.c driver module, as they are used -+ * by various transceivers. These functions are needed in the UDC-only case -+ * as well. These functions are copied from GPL isp1301_omap.c -+ * --------------------------------------------------------------------------- -+ */ -+static struct platform_device *tahvo_otg_dev; -+ -+static irqreturn_t omap_otg_irq(int irq, void *arg) -+{ -+ struct platform_device *otg_dev = arg; -+ struct tahvo_usb *tu = platform_get_drvdata(otg_dev); -+ u16 otg_irq; -+ -+ otg_irq = omap_readw(OTG_IRQ_SRC); -+ if (otg_irq & OPRT_CHG) { -+ omap_writew(OPRT_CHG, OTG_IRQ_SRC); -+ } else if (otg_irq & B_SRP_TMROUT) { -+ omap_writew(B_SRP_TMROUT, OTG_IRQ_SRC); -+ } else if (otg_irq & B_HNP_FAIL) { -+ omap_writew(B_HNP_FAIL, OTG_IRQ_SRC); -+ } else if (otg_irq & A_SRP_DETECT) { -+ omap_writew(A_SRP_DETECT, OTG_IRQ_SRC); -+ } else if (otg_irq & A_REQ_TMROUT) { -+ omap_writew(A_REQ_TMROUT, OTG_IRQ_SRC); -+ } else if (otg_irq & A_VBUS_ERR) { -+ omap_writew(A_VBUS_ERR, OTG_IRQ_SRC); -+ } else if (otg_irq & DRIVER_SWITCH) { -+#ifdef CONFIG_USB_OTG -+ if ((!(omap_readl(OTG_CTRL) & OTG_DRIVER_SEL)) && -+ tu->otg.host && tu->otg.state == OTG_STATE_A_HOST) { -+ /* role is host */ -+ usb_bus_start_enum(tu->otg.host, -+ tu->otg.host->otg_port); -+ } -+#endif -+ omap_writew(DRIVER_SWITCH, OTG_IRQ_SRC); -+ } else -+ return IRQ_NONE; -+ -+ return IRQ_HANDLED; -+ -+} -+ -+static int tahvo_otg_init(void) -+{ -+ u32 l; -+ -+#ifdef CONFIG_USB_OTG -+ if (!tahvo_otg_dev) { -+ printk("tahvo-usb: no tahvo_otg_dev\n"); -+ return -ENODEV; -+ } -+#endif -+ -+ l = omap_readl(OTG_SYSCON_1); -+ l &= ~OTG_IDLE_EN; -+ omap_writel(l, OTG_SYSCON_1); -+ udelay(100); -+ -+ /* some of these values are board-specific... */ -+ l = omap_readl(OTG_SYSCON_2); -+ l |= OTG_EN -+ /* for B-device: */ -+ | SRP_GPDATA /* 9msec Bdev D+ pulse */ -+ | SRP_GPDVBUS /* discharge after VBUS pulse */ -+ // | (3 << 24) /* 2msec VBUS pulse */ -+ /* for A-device: */ -+ | (0 << 20) /* 200ms nominal A_WAIT_VRISE timer */ -+ | SRP_DPW /* detect 167+ns SRP pulses */ -+ | SRP_DATA | SRP_VBUS; /* accept both kinds of SRP pulse */ -+ omap_writel(l, OTG_SYSCON_2); -+ -+ omap_writew(DRIVER_SWITCH | OPRT_CHG -+ | B_SRP_TMROUT | B_HNP_FAIL -+ | A_VBUS_ERR | A_SRP_DETECT | A_REQ_TMROUT, -+ OTG_IRQ_EN); -+ l = omap_readl(OTG_SYSCON_2); -+ l |= OTG_EN; -+ omap_writel(l, OTG_SYSCON_2); -+ -+ return 0; -+} -+ -+static int __init omap_otg_probe(struct platform_device *pdev) -+{ -+ int ret; -+ -+ tahvo_otg_dev = pdev; -+ ret = tahvo_otg_init(); -+ if (ret != 0) { -+ printk(KERN_ERR "tahvo-usb: tahvo_otg_init failed\n"); -+ return ret; -+ } -+ -+ return request_irq(tahvo_otg_dev->resource[1].start, -+ omap_otg_irq, IRQF_DISABLED, DRIVER_NAME, -+ &tahvo_usb_device); -+} -+ -+static int __exit omap_otg_remove(struct platform_device *pdev) -+{ -+ free_irq(tahvo_otg_dev->resource[1].start, &tahvo_usb_device); -+ tahvo_otg_dev = NULL; -+ -+ return 0; -+} -+ -+struct platform_driver omap_otg_driver = { -+ .driver = { -+ .name = "omap_otg", -+ }, -+ .remove = __exit_p(omap_otg_remove), -+}; -+ -+/* -+ * --------------------------------------------------------------------------- -+ * Tahvo related functions -+ * These are Nokia proprietary code, except for the OTG register settings, -+ * which are copied from isp1301.c -+ * --------------------------------------------------------------------------- -+ */ -+static ssize_t vbus_state_show(struct device *device, -+ struct device_attribute *attr, char *buf) -+{ -+ struct tahvo_usb *tu = dev_get_drvdata(device); -+ return sprintf(buf, "%d\n", tu->vbus_state); -+} -+static DEVICE_ATTR(vbus_state, 0444, vbus_state_show, NULL); -+ -+int vbus_active = 0; -+ -+#if 0 -+ -+static int host_suspend(struct tahvo_usb *tu) -+{ -+ struct device *dev; -+ -+ if (!tu->otg.host) -+ return -ENODEV; -+ -+ /* Currently ASSUMES only the OTG port matters; -+ * other ports could be active... -+ */ -+ dev = tu->otg.host->controller; -+ return dev->driver->suspend(dev, PMSG_SUSPEND); -+} -+ -+static int host_resume(struct tahvo_usb *tu) -+{ -+ struct device *dev; -+ -+ if (!tu->otg.host) -+ return -ENODEV; -+ -+ dev = tu->otg.host->controller; -+ return dev->driver->resume(dev); -+} -+ -+#else -+ -+static int host_suspend(struct tahvo_usb *tu) -+{ -+ return 0; -+} -+ -+static int host_resume(struct tahvo_usb *tu) -+{ -+ return 0; -+} -+ -+#endif -+ -+static void check_vbus_state(struct tahvo_usb *tu) -+{ -+ int reg, prev_state; -+ -+ reg = tahvo_read_reg(TAHVO_REG_IDSR); -+ if (reg & 0x01) { -+ u32 l; -+ -+ vbus_active = 1; -+ switch (tu->otg.state) { -+ case OTG_STATE_B_IDLE: -+ /* Enable the gadget driver */ -+ if (tu->otg.gadget) -+ usb_gadget_vbus_connect(tu->otg.gadget); -+ /* Set B-session valid and not B-sessio ended to indicate -+ * Vbus to be ok. */ -+ l = omap_readl(OTG_CTRL); -+ l &= ~OTG_BSESSEND; -+ l |= OTG_BSESSVLD; -+ omap_writel(l, OTG_CTRL); -+ -+ tu->otg.state = OTG_STATE_B_PERIPHERAL; -+ break; -+ case OTG_STATE_A_IDLE: -+ /* Session is now valid assuming the USB hub is driving Vbus */ -+ tu->otg.state = OTG_STATE_A_HOST; -+ host_resume(tu); -+ break; -+ default: -+ break; -+ } -+ printk("USB cable connected\n"); -+ } else { -+ switch (tu->otg.state) { -+ case OTG_STATE_B_PERIPHERAL: -+ if (tu->otg.gadget) -+ usb_gadget_vbus_disconnect(tu->otg.gadget); -+ tu->otg.state = OTG_STATE_B_IDLE; -+ break; -+ case OTG_STATE_A_HOST: -+ tu->otg.state = OTG_STATE_A_IDLE; -+ break; -+ default: -+ break; -+ } -+ printk("USB cable disconnected\n"); -+ vbus_active = 0; -+ } -+ -+ prev_state = tu->vbus_state; -+ tu->vbus_state = reg & 0x01; -+ if (prev_state != tu->vbus_state) -+ sysfs_notify(&tu->pt_dev->dev.kobj, NULL, "vbus_state"); -+} -+ -+static void tahvo_usb_become_host(struct tahvo_usb *tu) -+{ -+ u32 l; -+ -+ /* Clear system and transceiver controlled bits -+ * also mark the A-session is always valid */ -+ tahvo_otg_init(); -+ -+ l = omap_readl(OTG_CTRL); -+ l &= ~(OTG_CTRL_XCVR_MASK | OTG_CTRL_SYS_MASK); -+ l |= OTG_ASESSVLD; -+ omap_writel(l, OTG_CTRL); -+ -+ /* Power up the transceiver in USB host mode */ -+ tahvo_write_reg(TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND | -+ USBR_MASTER_SW2 | USBR_MASTER_SW1); -+ tu->otg.state = OTG_STATE_A_IDLE; -+ -+ check_vbus_state(tu); -+} -+ -+static void tahvo_usb_stop_host(struct tahvo_usb *tu) -+{ -+ host_suspend(tu); -+ tu->otg.state = OTG_STATE_A_IDLE; -+} -+ -+static void tahvo_usb_become_peripheral(struct tahvo_usb *tu) -+{ -+ u32 l; -+ -+ /* Clear system and transceiver controlled bits -+ * and enable ID to mark peripheral mode and -+ * BSESSEND to mark no Vbus */ -+ tahvo_otg_init(); -+ l = omap_readl(OTG_CTRL); -+ l &= ~(OTG_CTRL_XCVR_MASK | OTG_CTRL_SYS_MASK | OTG_BSESSVLD); -+ l |= OTG_ID | OTG_BSESSEND; -+ omap_writel(l, OTG_CTRL); -+ -+ /* Power up transceiver and set it in USB perhiperal mode */ -+ tahvo_write_reg(TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | USBR_NSUSPEND | USBR_SLAVE_SW); -+ tu->otg.state = OTG_STATE_B_IDLE; -+ -+ check_vbus_state(tu); -+} -+ -+static void tahvo_usb_stop_peripheral(struct tahvo_usb *tu) -+{ -+ u32 l; -+ -+ l = omap_readl(OTG_CTRL); -+ l &= ~OTG_BSESSVLD; -+ l |= OTG_BSESSEND; -+ omap_writel(l, OTG_CTRL); -+ -+ if (tu->otg.gadget) -+ usb_gadget_vbus_disconnect(tu->otg.gadget); -+ tu->otg.state = OTG_STATE_B_IDLE; -+ -+} -+ -+static void tahvo_usb_power_off(struct tahvo_usb *tu) -+{ -+ u32 l; -+ int id; -+ -+ /* Disable gadget controller if any */ -+ if (tu->otg.gadget) -+ usb_gadget_vbus_disconnect(tu->otg.gadget); -+ -+ host_suspend(tu); -+ -+ /* Disable OTG and interrupts */ -+ if (TAHVO_MODE(tu) == TAHVO_MODE_PERIPHERAL) -+ id = OTG_ID; -+ else -+ id = 0; -+ l = omap_readl(OTG_CTRL); -+ l &= ~(OTG_CTRL_XCVR_MASK | OTG_CTRL_SYS_MASK | OTG_BSESSVLD); -+ l |= id | OTG_BSESSEND; -+ omap_writel(l, OTG_CTRL); -+ omap_writew(0, OTG_IRQ_EN); -+ -+ l = omap_readl(OTG_SYSCON_2); -+ l &= ~OTG_EN; -+ omap_writel(l, OTG_SYSCON_2); -+ -+ l = omap_readl(OTG_SYSCON_1); -+ l |= OTG_IDLE_EN; -+ omap_writel(l, OTG_SYSCON_1); -+ -+ /* Power off transceiver */ -+ tahvo_write_reg(TAHVO_REG_USBR, 0); -+ tu->otg.state = OTG_STATE_UNDEFINED; -+} -+ -+ -+static int tahvo_usb_set_power(struct otg_transceiver *dev, unsigned mA) -+{ -+ struct tahvo_usb *tu = container_of(dev, struct tahvo_usb, otg); -+ -+ dev_dbg(&tu->pt_dev->dev, "set_power %d mA\n", mA); -+ -+ if (dev->state == OTG_STATE_B_PERIPHERAL) { -+ /* REVISIT: Can Tahvo charge battery from VBUS? */ -+ } -+ return 0; -+} -+ -+static int tahvo_usb_set_suspend(struct otg_transceiver *dev, int suspend) -+{ -+ struct tahvo_usb *tu = container_of(dev, struct tahvo_usb, otg); -+ u16 w; -+ -+ dev_dbg(&tu->pt_dev->dev, "set_suspend\n"); -+ -+ w = tahvo_read_reg(TAHVO_REG_USBR); -+ if (suspend) -+ w &= ~USBR_NSUSPEND; -+ else -+ w |= USBR_NSUSPEND; -+ tahvo_write_reg(TAHVO_REG_USBR, w); -+ -+ return 0; -+} -+ -+static int tahvo_usb_start_srp(struct otg_transceiver *dev) -+{ -+ struct tahvo_usb *tu = container_of(dev, struct tahvo_usb, otg); -+ u32 otg_ctrl; -+ -+ dev_dbg(&tu->pt_dev->dev, "start_srp\n"); -+ -+ if (!dev || tu->otg.state != OTG_STATE_B_IDLE) -+ return -ENODEV; -+ -+ otg_ctrl = omap_readl(OTG_CTRL); -+ if (!(otg_ctrl & OTG_BSESSEND)) -+ return -EINVAL; -+ -+ otg_ctrl |= OTG_B_BUSREQ; -+ otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_SYS_MASK; -+ omap_writel(otg_ctrl, OTG_CTRL); -+ tu->otg.state = OTG_STATE_B_SRP_INIT; -+ -+ return 0; -+} -+ -+static int tahvo_usb_start_hnp(struct otg_transceiver *otg) -+{ -+ struct tahvo_usb *tu = container_of(otg, struct tahvo_usb, otg); -+ -+ dev_dbg(&tu->pt_dev->dev, "start_hnp\n"); -+#ifdef CONFIG_USB_OTG -+ /* REVISIT: Add this for OTG */ -+#endif -+ return -EINVAL; -+} -+ -+static int tahvo_usb_set_host(struct otg_transceiver *otg, struct usb_bus *host) -+{ -+ struct tahvo_usb *tu = container_of(otg, struct tahvo_usb, otg); -+ u32 l; -+ -+ dev_dbg(&tu->pt_dev->dev, "set_host %p\n", host); -+ -+ if (otg == NULL) -+ return -ENODEV; -+ -+#if defined(CONFIG_USB_OTG) || !defined(CONFIG_USB_GADGET_OMAP) -+ -+ mutex_lock(&tu->serialize); -+ -+ if (host == NULL) { -+ if (TAHVO_MODE(tu) == TAHVO_MODE_HOST) -+ tahvo_usb_power_off(tu); -+ tu->otg.host = NULL; -+ mutex_unlock(&tu->serialize); -+ return 0; -+ } -+ -+ l = omap_readl(OTG_SYSCON_1); -+ l &= ~(OTG_IDLE_EN | HST_IDLE_EN | DEV_IDLE_EN); -+ omap_writel(l, OTG_SYSCON_1); -+ -+ if (TAHVO_MODE(tu) == TAHVO_MODE_HOST) { -+ tu->otg.host = NULL; -+ tahvo_usb_become_host(tu); -+ } else -+ host_suspend(tu); -+ -+ tu->otg.host = host; -+ -+ mutex_unlock(&tu->serialize); -+#else -+ /* No host mode configured, so do not allow host controlled to be set */ -+ return -EINVAL; -+#endif -+ -+ return 0; -+} -+ -+static int tahvo_usb_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) -+{ -+ struct tahvo_usb *tu = container_of(otg, struct tahvo_usb, otg); -+ -+ dev_dbg(&tu->pt_dev->dev, "set_peripheral %p\n", gadget); -+ -+ if (!otg) -+ return -ENODEV; -+ -+#if defined(CONFIG_USB_OTG) || defined(CONFIG_USB_GADGET_OMAP) -+ -+ mutex_lock(&tu->serialize); -+ -+ if (!gadget) { -+ if (TAHVO_MODE(tu) == TAHVO_MODE_PERIPHERAL) -+ tahvo_usb_power_off(tu); -+ tu->otg.gadget = NULL; -+ mutex_unlock(&tu->serialize); -+ return 0; -+ } -+ -+ tu->otg.gadget = gadget; -+ if (TAHVO_MODE(tu) == TAHVO_MODE_PERIPHERAL) -+ tahvo_usb_become_peripheral(tu); -+ -+ mutex_unlock(&tu->serialize); -+#else -+ /* No gadget mode configured, so do not allow host controlled to be set */ -+ return -EINVAL; -+#endif -+ -+ return 0; -+} -+ -+static void tahvo_usb_irq_work(struct work_struct *work) -+{ -+ struct tahvo_usb *tu = container_of(work, struct tahvo_usb, irq_work); -+ -+ mutex_lock(&tu->serialize); -+ check_vbus_state(tu); -+ mutex_unlock(&tu->serialize); -+} -+ -+static void tahvo_usb_vbus_interrupt(unsigned long arg) -+{ -+ struct tahvo_usb *tu = (struct tahvo_usb *) arg; -+ -+ tahvo_ack_irq(TAHVO_INT_VBUSON); -+ /* Seems we need this to acknowledge the interrupt */ -+ tahvo_read_reg(TAHVO_REG_IDSR); -+ schedule_work(&tu->irq_work); -+} -+ -+#ifdef CONFIG_USB_OTG -+static ssize_t otg_mode_show(struct device *device, -+ struct device_attribute *attr, char *buf) -+{ -+ struct tahvo_usb *tu = dev_get_drvdata(device); -+ switch (tu->tahvo_mode) { -+ case TAHVO_MODE_HOST: -+ return sprintf(buf, "host\n"); -+ case TAHVO_MODE_PERIPHERAL: -+ return sprintf(buf, "peripheral\n"); -+ } -+ return sprintf(buf, "unknown\n"); -+} -+ -+static ssize_t otg_mode_store(struct device *device, -+ struct device_attribute *attr, -+ const char *buf, size_t count) -+{ -+ struct tahvo_usb *tu = dev_get_drvdata(device); -+ int r; -+ -+ r = strlen(buf); -+ mutex_lock(&tu->serialize); -+ if (strncmp(buf, "host", 4) == 0) { -+ if (tu->tahvo_mode == TAHVO_MODE_PERIPHERAL) -+ tahvo_usb_stop_peripheral(tu); -+ tu->tahvo_mode = TAHVO_MODE_HOST; -+ if (tu->otg.host) { -+ printk(KERN_INFO "Selected HOST mode: host controller present.\n"); -+ tahvo_usb_become_host(tu); -+ } else { -+ printk(KERN_INFO "Selected HOST mode: no host controller, powering off.\n"); -+ tahvo_usb_power_off(tu); -+ } -+ } else if (strncmp(buf, "peripheral", 10) == 0) { -+ if (tu->tahvo_mode == TAHVO_MODE_HOST) -+ tahvo_usb_stop_host(tu); -+ tu->tahvo_mode = TAHVO_MODE_PERIPHERAL; -+ if (tu->otg.gadget) { -+ printk(KERN_INFO "Selected PERIPHERAL mode: gadget driver present.\n"); -+ tahvo_usb_become_peripheral(tu); -+ } else { -+ printk(KERN_INFO "Selected PERIPHERAL mode: no gadget driver, powering off.\n"); -+ tahvo_usb_power_off(tu); -+ } -+ } else -+ r = -EINVAL; -+ -+ mutex_unlock(&tu->serialize); -+ return r; -+} -+ -+static DEVICE_ATTR(otg_mode, 0644, otg_mode_show, otg_mode_store); -+#endif -+ -+static int __init tahvo_usb_probe(struct platform_device *pdev) -+{ -+ struct tahvo_usb *tu; -+ struct device *dev = &pdev->dev; -+ int ret; -+ -+ ret = tahvo_get_status(); -+ if (!ret) -+ return -ENODEV; -+ -+ dev_dbg(dev, "probe\n"); -+ -+ /* Create driver data */ -+ tu = kzalloc(sizeof(*tu), GFP_KERNEL); -+ if (!tu) -+ return -ENOMEM; -+ -+ tu->pt_dev = container_of(dev, struct platform_device, dev); -+#ifdef CONFIG_USB_OTG -+ /* Default mode */ -+#ifdef CONFIG_CBUS_TAHVO_USB_HOST_BY_DEFAULT -+ tu->tahvo_mode = TAHVO_MODE_HOST; -+#else -+ tu->tahvo_mode = TAHVO_MODE_PERIPHERAL; -+#endif -+#endif -+ -+ INIT_WORK(&tu->irq_work, tahvo_usb_irq_work); -+ mutex_init(&tu->serialize); -+ -+ /* Set initial state, so that we generate kevents only on -+ * state changes */ -+ tu->vbus_state = tahvo_read_reg(TAHVO_REG_IDSR) & 0x01; -+ -+ /* We cannot enable interrupt until omap_udc is initialized */ -+ ret = tahvo_request_irq(TAHVO_INT_VBUSON, tahvo_usb_vbus_interrupt, -+ (unsigned long) tu, "vbus_interrupt"); -+ if (ret != 0) { -+ kfree(tu); -+ printk(KERN_ERR "Could not register Tahvo interrupt for VBUS\n"); -+ return ret; -+ } -+ -+ /* Attributes */ -+ ret = device_create_file(dev, &dev_attr_vbus_state); -+#ifdef CONFIG_USB_OTG -+ ret |= device_create_file(dev, &dev_attr_otg_mode); -+#endif -+ if (ret) -+ printk(KERN_ERR "attribute creation failed: %d\n", ret); -+ -+ /* Create OTG interface */ -+ tahvo_usb_power_off(tu); -+ tu->otg.state = OTG_STATE_UNDEFINED; -+ tu->otg.label = DRIVER_NAME; -+ tu->otg.set_host = tahvo_usb_set_host; -+ tu->otg.set_peripheral = tahvo_usb_set_peripheral; -+ tu->otg.set_power = tahvo_usb_set_power; -+ tu->otg.set_suspend = tahvo_usb_set_suspend; -+ tu->otg.start_srp = tahvo_usb_start_srp; -+ tu->otg.start_hnp = tahvo_usb_start_hnp; -+ -+ ret = otg_set_transceiver(&tu->otg); -+ if (ret < 0) { -+ printk(KERN_ERR "Cannot register USB transceiver\n"); -+ kfree(tu); -+ tahvo_free_irq(TAHVO_INT_VBUSON); -+ return ret; -+ } -+ -+ dev_set_drvdata(dev, tu); -+ -+ /* Act upon current vbus state once at startup. A vbus state irq may or -+ * may not be generated in addition to this. */ -+ schedule_work(&tu->irq_work); -+ return 0; -+} -+ -+static int __exit tahvo_usb_remove(struct platform_device *pdev) -+{ -+ dev_dbg(&pdev->dev, "remove\n"); -+ -+ tahvo_free_irq(TAHVO_INT_VBUSON); -+ flush_scheduled_work(); -+ otg_set_transceiver(0); -+ device_remove_file(&pdev->dev, &dev_attr_vbus_state); -+#ifdef CONFIG_USB_OTG -+ device_remove_file(&pdev->dev, &dev_attr_otg_mode); -+#endif -+ return 0; -+} -+ -+static struct platform_driver tahvo_usb_driver = { -+ .driver = { -+ .name = "tahvo-usb", -+ }, -+ .remove = __exit_p(tahvo_usb_remove), -+}; -+ -+static int __init tahvo_usb_init(void) -+{ -+ int ret = 0; -+ -+ ret = platform_driver_probe(&tahvo_usb_driver, tahvo_usb_probe); -+ if (ret) -+ return ret; -+ -+ ret = platform_driver_probe(&omap_otg_driver, omap_otg_probe); -+ if (ret) { -+ platform_driver_unregister(&tahvo_usb_driver); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+subsys_initcall(tahvo_usb_init); -+ -+static void __exit tahvo_usb_exit(void) -+{ -+ platform_driver_unregister(&omap_otg_driver); -+ platform_driver_unregister(&tahvo_usb_driver); -+} -+module_exit(tahvo_usb_exit); -+ -+MODULE_DESCRIPTION("Tahvo USB OTG Transceiver Driver"); -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("Juha Yrjölä, Tony Lindgren, and Timo Teräs"); ---- a/drivers/Makefile -+++ b/drivers/Makefile -@@ -74,7 +74,7 @@ obj-$(CONFIG_GAMEPORT) += input/gamepor - obj-$(CONFIG_INPUT) += input/ - obj-$(CONFIG_I2O) += message/ - obj-$(CONFIG_RTC_LIB) += rtc/ --obj-y += i2c/ media/ -+obj-y += i2c/ media/ cbus/ - obj-$(CONFIG_PPS) += pps/ - obj-$(CONFIG_W1) += w1/ - obj-$(CONFIG_POWER_SUPPLY) += power/ ---- a/arch/arm/Kconfig -+++ b/arch/arm/Kconfig -@@ -1930,6 +1930,10 @@ source "net/Kconfig" - - source "drivers/Kconfig" - -+if ARCH_OMAP -+source "drivers/cbus/Kconfig" -+endif -+ - source "fs/Kconfig" - - source "arch/arm/Kconfig.debug" diff --git a/target/linux/omap24xx/patches-2.6.38/501-cbus-retu-irq-nr-fix.patch b/target/linux/omap24xx/patches-2.6.38/501-cbus-retu-irq-nr-fix.patch deleted file mode 100644 index 478bcc83d7..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/501-cbus-retu-irq-nr-fix.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/drivers/cbus/retu.c -+++ b/drivers/cbus/retu.c -@@ -205,7 +205,7 @@ static irqreturn_t retu_irq_handler(int - return IRQ_NONE; - } - -- for (i = 0; idr != 0; i++, idr >>= 1) { -+ for (i = retu->irq_base; idr != 0; i++, idr >>= 1) { - if (!(idr & 1)) - continue; - diff --git a/target/linux/omap24xx/patches-2.6.38/505-cbus-retu-write-lock.patch b/target/linux/omap24xx/patches-2.6.38/505-cbus-retu-write-lock.patch deleted file mode 100644 index 1e18dc2198..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/505-cbus-retu-write-lock.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/drivers/cbus/retu.c -+++ b/drivers/cbus/retu.c -@@ -120,7 +120,9 @@ void retu_write_reg(struct device *child - { - struct retu *retu = dev_get_drvdata(child->parent); - -+ mutex_lock(&retu->mutex); - __retu_write_reg(retu, reg, val); -+ mutex_unlock(&retu->mutex); - } - EXPORT_SYMBOL_GPL(retu_write_reg); - diff --git a/target/linux/omap24xx/patches-2.6.38/506-cbus-retu-irq-handler-locking.patch b/target/linux/omap24xx/patches-2.6.38/506-cbus-retu-irq-handler-locking.patch deleted file mode 100644 index 7729327a0d..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/506-cbus-retu-irq-handler-locking.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/drivers/cbus/retu.c -+++ b/drivers/cbus/retu.c -@@ -198,10 +198,12 @@ static irqreturn_t retu_irq_handler(int - u16 idr; - u16 imr; - -+ mutex_lock(&retu->mutex); - idr = __retu_read_reg(retu, RETU_REG_IDR); - imr = __retu_read_reg(retu, RETU_REG_IMR); -- idr &= ~imr; -+ mutex_unlock(&retu->mutex); - -+ idr &= ~imr; - if (!idr) { - dev_vdbg(retu->dev, "No IRQ, spurious?\n"); - return IRQ_NONE; diff --git a/target/linux/omap24xx/patches-2.6.38/510-cbus-retu-defines.patch b/target/linux/omap24xx/patches-2.6.38/510-cbus-retu-defines.patch deleted file mode 100644 index 4bfe2bfea7..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/510-cbus-retu-defines.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/drivers/cbus/retu.h -+++ b/drivers/cbus/retu.h -@@ -40,6 +40,8 @@ - #define RETU_REG_CTRL_CLR 0x0f /* Regulator clear register */ - #define RETU_REG_CTRL_SET 0x10 /* Regulator set register */ - #define RETU_REG_STATUS 0x16 /* Status register */ -+#define RETU_REG_STATUS_BATAVAIL 0x0100 /* Battery available */ -+#define RETU_REG_STATUS_CHGPLUG 0x1000 /* Charger is plugged in */ - #define RETU_REG_WATCHDOG 0x17 /* Watchdog register */ - #define RETU_REG_AUDTXR 0x18 /* Audio Codec Tx register */ - #define RETU_REG_MAX 0x1f -@@ -57,6 +59,23 @@ - - #define MAX_RETU_IRQ_HANDLERS 16 - -+/* ADC channels */ -+#define RETU_ADC_GND 0x00 /* Ground */ -+#define RETU_ADC_BSI 0x01 /* Battery Size Indicator */ -+#define RETU_ADC_BATTEMP 0x02 /* Battery temperature */ -+#define RETU_ADC_CHGVOLT 0x03 /* Charger voltage */ -+#define RETU_ADC_HEADSET 0x04 /* Headset detection */ -+#define RETU_ADC_HOOKDET 0x05 /* Hook detection */ -+#define RETU_ADC_RFGP 0x06 /* RF GP */ -+#define RETU_ADC_WBTX 0x07 /* Wideband Tx detection */ -+#define RETU_ADC_BATTVOLT 0x08 /* Battery voltage measurement */ -+#define RETU_ADC_GND2 0x09 /* Ground */ -+#define RETU_ADC_LIGHTSENS 0x0A /* Light sensor */ -+#define RETU_ADC_LIGHTTEMP 0x0B /* Light sensor temperature */ -+#define RETU_ADC_BKUPVOLT 0x0C /* Backup battery voltage */ -+#define RETU_ADC_TEMP 0x0D /* RETU temperature */ -+ -+ - int retu_read_reg(struct device *child, unsigned reg); - void retu_write_reg(struct device *child, unsigned reg, u16 val); - void retu_set_clear_reg_bits(struct device *child, unsigned reg, u16 set, diff --git a/target/linux/omap24xx/patches-2.6.38/520-cbus-tahvo-defines.patch b/target/linux/omap24xx/patches-2.6.38/520-cbus-tahvo-defines.patch deleted file mode 100644 index 9d1837a771..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/520-cbus-tahvo-defines.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/drivers/cbus/tahvo.h -+++ b/drivers/cbus/tahvo.h -@@ -30,12 +30,23 @@ - #define TAHVO_REG_IDR 0x01 /* Interrupt ID */ - #define TAHVO_REG_IDSR 0x02 /* Interrupt status */ - #define TAHVO_REG_IMR 0x03 /* Interrupt mask */ -+#define TAHVO_REG_CHGCURR 0x04 /* Charge current control PWM (8-bit) */ - #define TAHVO_REG_LEDPWMR 0x05 /* LED PWM */ - #define TAHVO_REG_USBR 0x06 /* USB control */ -+#define TAHVO_REG_CHGCTL 0x08 /* Charge control register */ -+#define TAHVO_REG_CHGCTL_EN 0x0001 /* Global charge enable */ -+#define TAHVO_REG_CHGCTL_PWMOVR 0x0004 /* PWM override. Force charge PWM to 0%/100% duty cycle. */ -+#define TAHVO_REG_CHGCTL_PWMOVRZERO 0x0008 /* If set, PWM override is 0% (If unset -> 100%) */ -+#define TAHVO_REG_CHGCTL_CURMEAS 0x0040 /* Enable battery current measurement. */ -+#define TAHVO_REG_CHGCTL_CURTIMRST 0x0080 /* Current measure timer reset. */ -+#define TAHVO_REG_BATCURRTIMER 0x0c /* Battery current measure timer (8-bit) */ -+#define TAHVO_REG_BATCURR 0x0d /* Battery (dis)charge current (signed 16-bit) */ -+ - #define TAHVO_REG_MAX 0x0d - - /* Interrupt sources */ - #define TAHVO_INT_VBUSON 0 -+#define TAHVO_INT_BATCURR 7 /* Battery current measure timer */ - - #define MAX_TAHVO_IRQ_HANDLERS 8 - diff --git a/target/linux/omap24xx/patches-2.6.38/530-cbus-retu-wdt-preemptible.patch b/target/linux/omap24xx/patches-2.6.38/530-cbus-retu-wdt-preemptible.patch deleted file mode 100644 index 96c1f6c120..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/530-cbus-retu-wdt-preemptible.patch +++ /dev/null @@ -1,125 +0,0 @@ ---- a/drivers/cbus/retu-wdt.c -+++ b/drivers/cbus/retu-wdt.c -@@ -58,13 +58,11 @@ struct retu_wdt_dev { - struct device *dev; - int users; - struct miscdevice retu_wdt_miscdev; -- struct timer_list ping_timer; -+ struct delayed_work ping_work; - }; - - static struct retu_wdt_dev *retu_wdt; - --static void retu_wdt_set_ping_timer(unsigned long enable); -- - static int _retu_modify_counter(unsigned int new) - { - if (retu_wdt) -@@ -86,6 +84,31 @@ static int retu_modify_counter(unsigned - return 0; - } - -+/* -+ * Since retu watchdog cannot be disabled in hardware, we must kick it -+ * with a timer until userspace watchdog software takes over. Do this -+ * unless /dev/watchdog is open or CONFIG_WATCHDOG_NOWAYOUT is set. -+ */ -+static void retu_wdt_ping_enable(struct retu_wdt_dev *wdev) -+{ -+ _retu_modify_counter(RETU_WDT_MAX_TIMER); -+ schedule_delayed_work(&wdev->ping_work, -+ round_jiffies_relative(RETU_WDT_DEFAULT_TIMER * HZ)); -+} -+ -+static void retu_wdt_ping_disable(struct retu_wdt_dev *wdev) -+{ -+ _retu_modify_counter(RETU_WDT_MAX_TIMER); -+ cancel_delayed_work_sync(&wdev->ping_work); -+} -+ -+static void retu_wdt_ping_work(struct work_struct *work) -+{ -+ struct retu_wdt_dev *wdev = container_of(to_delayed_work(work), -+ struct retu_wdt_dev, ping_work); -+ retu_wdt_ping_enable(wdev); -+} -+ - static ssize_t retu_wdt_period_show(struct device *dev, - struct device_attribute *attr, char *buf) - { -@@ -105,7 +128,7 @@ static ssize_t retu_wdt_period_store(str - int ret; - - #ifdef CONFIG_WATCHDOG_NOWAYOUT -- retu_wdt_set_ping_timer(0); -+ retu_wdt_ping_disable(retu_wdt); - #endif - - if (sscanf(buf, "%u", &new_period) != 1) { -@@ -136,30 +159,13 @@ static DEVICE_ATTR(period, S_IRUGO | S_I - retu_wdt_period_store); - static DEVICE_ATTR(counter, S_IRUGO, retu_wdt_counter_show, NULL); - --/*----------------------------------------------------------------------------*/ -- --/* -- * Since retu watchdog cannot be disabled in hardware, we must kick it -- * with a timer until userspace watchdog software takes over. Do this -- * unless /dev/watchdog is open or CONFIG_WATCHDOG_NOWAYOUT is set. -- */ --static void retu_wdt_set_ping_timer(unsigned long enable) --{ -- _retu_modify_counter(RETU_WDT_MAX_TIMER); -- if (enable) -- mod_timer(&retu_wdt->ping_timer, -- jiffies + RETU_WDT_DEFAULT_TIMER * HZ); -- else -- del_timer_sync(&retu_wdt->ping_timer); --} -- - static int retu_wdt_open(struct inode *inode, struct file *file) - { - if (test_and_set_bit(1, (unsigned long *)&(retu_wdt->users))) - return -EBUSY; - - file->private_data = (void *)retu_wdt; -- retu_wdt_set_ping_timer(0); -+ retu_wdt_ping_disable(retu_wdt); - - return nonseekable_open(inode, file); - } -@@ -169,7 +175,7 @@ static int retu_wdt_release(struct inode - struct retu_wdt_dev *wdev = file->private_data; - - #ifndef CONFIG_WATCHDOG_NOWAYOUT -- retu_wdt_set_ping_timer(1); -+ retu_wdt_ping_enable(retu_wdt); - #endif - wdev->users = 0; - -@@ -232,7 +238,7 @@ static int __devinit retu_wdt_ping(void) - #ifdef CONFIG_WATCHDOG_NOWAYOUT - retu_modify_counter(RETU_WDT_MAX_TIMER); - #else -- retu_wdt_set_ping_timer(1); -+ retu_wdt_ping_enable(retu_wdt); - #endif - - return 0; -@@ -283,7 +289,7 @@ static int __init retu_wdt_probe(struct - if (ret) - goto free3; - -- setup_timer(&wdev->ping_timer, retu_wdt_set_ping_timer, 1); -+ INIT_DELAYED_WORK(&wdev->ping_work, retu_wdt_ping_work); - - /* passed as module parameter? */ - ret = retu_modify_counter(counter_param); -@@ -326,6 +332,7 @@ static int __devexit retu_wdt_remove(str - misc_deregister(&wdev->retu_wdt_miscdev); - device_remove_file(&pdev->dev, &dev_attr_period); - device_remove_file(&pdev->dev, &dev_attr_counter); -+ cancel_delayed_work_sync(&wdev->ping_work); - kfree(wdev); - - return 0; diff --git a/target/linux/omap24xx/patches-2.6.38/531-cbus-retu-wdt-fix-bitfield.patch b/target/linux/omap24xx/patches-2.6.38/531-cbus-retu-wdt-fix-bitfield.patch deleted file mode 100644 index c06cedeea1..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/531-cbus-retu-wdt-fix-bitfield.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- a/drivers/cbus/retu-wdt.c -+++ b/drivers/cbus/retu-wdt.c -@@ -56,7 +56,7 @@ static int counter_param = RETU_WDT_MAX_ - - struct retu_wdt_dev { - struct device *dev; -- int users; -+ unsigned long users; - struct miscdevice retu_wdt_miscdev; - struct delayed_work ping_work; - }; -@@ -161,7 +161,7 @@ static DEVICE_ATTR(counter, S_IRUGO, ret - - static int retu_wdt_open(struct inode *inode, struct file *file) - { -- if (test_and_set_bit(1, (unsigned long *)&(retu_wdt->users))) -+ if (test_and_set_bit(0, &retu_wdt->users)) - return -EBUSY; - - file->private_data = (void *)retu_wdt; -@@ -177,7 +177,7 @@ static int retu_wdt_release(struct inode - #ifndef CONFIG_WATCHDOG_NOWAYOUT - retu_wdt_ping_enable(retu_wdt); - #endif -- wdev->users = 0; -+ clear_bit(0, &retu_wdt->users); - - return 0; - } -@@ -264,7 +264,6 @@ static int __init retu_wdt_probe(struct - return -ENOMEM; - - wdev->dev = &pdev->dev; -- wdev->users = 0; - - ret = device_create_file(&pdev->dev, &dev_attr_period); - if (ret) { diff --git a/target/linux/omap24xx/patches-2.6.38/534-cbus-retu-wdt-remove-unused-interfaces.patch b/target/linux/omap24xx/patches-2.6.38/534-cbus-retu-wdt-remove-unused-interfaces.patch deleted file mode 100644 index 7ce813093a..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/534-cbus-retu-wdt-remove-unused-interfaces.patch +++ /dev/null @@ -1,180 +0,0 @@ ---- a/drivers/cbus/retu-wdt.c -+++ b/drivers/cbus/retu-wdt.c -@@ -52,7 +52,6 @@ static DEFINE_MUTEX(retu_wdt_mutex); - - /* Current period of watchdog */ - static unsigned int period_val = RETU_WDT_DEFAULT_TIMER; --static int counter_param = RETU_WDT_MAX_TIMER; - - struct retu_wdt_dev { - struct device *dev; -@@ -109,56 +108,6 @@ static void retu_wdt_ping_work(struct wo - retu_wdt_ping_enable(wdev); - } - --static ssize_t retu_wdt_period_show(struct device *dev, -- struct device_attribute *attr, char *buf) --{ -- /* Show current max counter */ -- return sprintf(buf, "%u\n", (u16)period_val); --} -- --/* -- * Note: This inteface is non-standard and likely to disappear! -- * Use /dev/watchdog instead, that's the standard. -- */ --static ssize_t retu_wdt_period_store(struct device *dev, -- struct device_attribute *attr, -- const char *buf, size_t count) --{ -- unsigned int new_period; -- int ret; -- --#ifdef CONFIG_WATCHDOG_NOWAYOUT -- retu_wdt_ping_disable(retu_wdt); --#endif -- -- if (sscanf(buf, "%u", &new_period) != 1) { -- printk(KERN_ALERT "retu_wdt_period_store: Invalid input\n"); -- return -EINVAL; -- } -- -- ret = retu_modify_counter(new_period); -- if (ret < 0) -- return ret; -- -- return strnlen(buf, count); --} -- --static ssize_t retu_wdt_counter_show(struct device *dev, -- struct device_attribute *attr, char *buf) --{ -- u16 counter; -- -- /* Show current value in watchdog counter */ -- counter = retu_read_reg(dev, RETU_REG_WATCHDOG); -- -- /* Only the 5 LSB are important */ -- return snprintf(buf, PAGE_SIZE, "%u\n", (counter & 0x3F)); --} -- --static DEVICE_ATTR(period, S_IRUGO | S_IWUSR, retu_wdt_period_show, \ -- retu_wdt_period_store); --static DEVICE_ATTR(counter, S_IRUGO, retu_wdt_counter_show, NULL); -- - static int retu_wdt_open(struct inode *inode, struct file *file) - { - if (test_and_set_bit(0, &retu_wdt->users)) -@@ -232,18 +181,6 @@ static long retu_wdt_ioctl(struct file * - return 0; - } - --/* Start kicking retu watchdog until user space starts doing the kicking */ --static int __devinit retu_wdt_ping(void) --{ --#ifdef CONFIG_WATCHDOG_NOWAYOUT -- retu_modify_counter(RETU_WDT_MAX_TIMER); --#else -- retu_wdt_ping_enable(retu_wdt); --#endif -- -- return 0; --} -- - static const struct file_operations retu_wdt_fops = { - .owner = THIS_MODULE, - .write = retu_wdt_write, -@@ -252,8 +189,6 @@ static const struct file_operations retu - .release = retu_wdt_release, - }; - --/*----------------------------------------------------------------------------*/ -- - static int __init retu_wdt_probe(struct platform_device *pdev) - { - struct retu_wdt_dev *wdev; -@@ -265,18 +200,6 @@ static int __init retu_wdt_probe(struct - - wdev->dev = &pdev->dev; - -- ret = device_create_file(&pdev->dev, &dev_attr_period); -- if (ret) { -- dev_err(&pdev->dev, "Error creating sysfs period\n"); -- goto free1; -- } -- -- ret = device_create_file(&pdev->dev, &dev_attr_counter); -- if (ret) { -- dev_err(&pdev->dev, "Error creating sysfs counter\n"); -- goto free2; -- } -- - platform_set_drvdata(pdev, wdev); - retu_wdt = wdev; - wdev->retu_wdt_miscdev.parent = &pdev->dev; -@@ -286,38 +209,21 @@ static int __init retu_wdt_probe(struct - - ret = misc_register(&(wdev->retu_wdt_miscdev)); - if (ret) -- goto free3; -+ goto err_free_wdev; - - INIT_DELAYED_WORK(&wdev->ping_work, retu_wdt_ping_work); - -- /* passed as module parameter? */ -- ret = retu_modify_counter(counter_param); -- if (ret == -EINVAL) { -- ret = retu_modify_counter(RETU_WDT_DEFAULT_TIMER); -- dev_dbg(&pdev->dev, "Initializing to default value\n"); -- } -- -- /* Kick the watchdog for kernel booting to finish */ -+ /* Kick the watchdog for kernel booting to finish. -+ * If nowayout is not set, we start the ping work. */ -+#ifdef CONFIG_WATCHDOG_NOWAYOUT - retu_modify_counter(RETU_WDT_MAX_TIMER); -- -- ret = retu_wdt_ping(); -- if (ret < 0) { -- dev_err(&pdev->dev, "Failed to ping\n"); -- goto free4; -- } -+#else -+ retu_wdt_ping_enable(retu_wdt); -+#endif - - return 0; - --free4: -- misc_deregister(&wdev->retu_wdt_miscdev); -- --free3: -- device_remove_file(&pdev->dev, &dev_attr_counter); -- --free2: -- device_remove_file(&pdev->dev, &dev_attr_period); -- --free1: -+err_free_wdev: - kfree(wdev); - - return ret; -@@ -329,8 +235,6 @@ static int __devexit retu_wdt_remove(str - - wdev = platform_get_drvdata(pdev); - misc_deregister(&wdev->retu_wdt_miscdev); -- device_remove_file(&pdev->dev, &dev_attr_period); -- device_remove_file(&pdev->dev, &dev_attr_counter); - cancel_delayed_work_sync(&wdev->ping_work); - kfree(wdev); - -@@ -356,9 +260,7 @@ static void __exit retu_wdt_exit(void) - - module_init(retu_wdt_init); - module_exit(retu_wdt_exit); --module_param(counter_param, int, 0); - - MODULE_DESCRIPTION("Retu WatchDog"); - MODULE_AUTHOR("Amit Kucheria"); - MODULE_LICENSE("GPL"); -- diff --git a/target/linux/omap24xx/patches-2.6.38/535-cbus-retu-wdt-cleanup.patch b/target/linux/omap24xx/patches-2.6.38/535-cbus-retu-wdt-cleanup.patch deleted file mode 100644 index 05bcc918a2..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/535-cbus-retu-wdt-cleanup.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/drivers/cbus/retu-wdt.c -+++ b/drivers/cbus/retu-wdt.c -@@ -124,9 +124,9 @@ static int retu_wdt_release(struct inode - struct retu_wdt_dev *wdev = file->private_data; - - #ifndef CONFIG_WATCHDOG_NOWAYOUT -- retu_wdt_ping_enable(retu_wdt); -+ retu_wdt_ping_enable(wdev); - #endif -- clear_bit(0, &retu_wdt->users); -+ clear_bit(0, &wdev->users); - - return 0; - } diff --git a/target/linux/omap24xx/patches-2.6.38/540-cbus-retu-wdt-remove-static-variables.patch b/target/linux/omap24xx/patches-2.6.38/540-cbus-retu-wdt-remove-static-variables.patch deleted file mode 100644 index 482b6d77ac..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/540-cbus-retu-wdt-remove-static-variables.patch +++ /dev/null @@ -1,189 +0,0 @@ ---- a/drivers/cbus/retu-wdt.c -+++ b/drivers/cbus/retu-wdt.c -@@ -7,6 +7,8 @@ - * - * Written by Amit Kucheria <amit.kucheria@nokia.com> - * -+ * Cleanups by Michael Buesch <mb@bu3sch.de> (C) 2011 -+ * - * This file is subject to the terms and conditions of the GNU General - * Public License. See the file "COPYING" in the main directory of this - * archive for more details. -@@ -48,37 +50,31 @@ - #define RETU_WDT_DEFAULT_TIMER 32 - #define RETU_WDT_MAX_TIMER 63 - --static DEFINE_MUTEX(retu_wdt_mutex); -- --/* Current period of watchdog */ --static unsigned int period_val = RETU_WDT_DEFAULT_TIMER; -- - struct retu_wdt_dev { - struct device *dev; -+ unsigned int period_val; /* Current period of watchdog */ - unsigned long users; -- struct miscdevice retu_wdt_miscdev; -+ struct miscdevice miscdev; - struct delayed_work ping_work; -+ struct mutex mutex; - }; - --static struct retu_wdt_dev *retu_wdt; - --static int _retu_modify_counter(unsigned int new) -+static inline void _retu_modify_counter(struct retu_wdt_dev *wdev, -+ unsigned int new) - { -- if (retu_wdt) -- retu_write_reg(retu_wdt->dev, RETU_REG_WATCHDOG, (u16)new); -- -- return 0; -+ retu_write_reg(wdev->dev, RETU_REG_WATCHDOG, (u16)new); - } - --static int retu_modify_counter(unsigned int new) -+static int retu_modify_counter(struct retu_wdt_dev *wdev, unsigned int new) - { - if (new < RETU_WDT_MIN_TIMER || new > RETU_WDT_MAX_TIMER) - return -EINVAL; - -- mutex_lock(&retu_wdt_mutex); -- period_val = new; -- _retu_modify_counter(period_val); -- mutex_unlock(&retu_wdt_mutex); -+ mutex_lock(&wdev->mutex); -+ wdev->period_val = new; -+ _retu_modify_counter(wdev, wdev->period_val); -+ mutex_unlock(&wdev->mutex); - - return 0; - } -@@ -90,14 +86,14 @@ static int retu_modify_counter(unsigned - */ - static void retu_wdt_ping_enable(struct retu_wdt_dev *wdev) - { -- _retu_modify_counter(RETU_WDT_MAX_TIMER); -+ _retu_modify_counter(wdev, RETU_WDT_MAX_TIMER); - schedule_delayed_work(&wdev->ping_work, - round_jiffies_relative(RETU_WDT_DEFAULT_TIMER * HZ)); - } - - static void retu_wdt_ping_disable(struct retu_wdt_dev *wdev) - { -- _retu_modify_counter(RETU_WDT_MAX_TIMER); -+ _retu_modify_counter(wdev, RETU_WDT_MAX_TIMER); - cancel_delayed_work_sync(&wdev->ping_work); - } - -@@ -110,18 +106,21 @@ static void retu_wdt_ping_work(struct wo - - static int retu_wdt_open(struct inode *inode, struct file *file) - { -- if (test_and_set_bit(0, &retu_wdt->users)) -+ struct miscdevice *mdev = file->private_data; -+ struct retu_wdt_dev *wdev = container_of(mdev, struct retu_wdt_dev, miscdev); -+ -+ if (test_and_set_bit(0, &wdev->users)) - return -EBUSY; - -- file->private_data = (void *)retu_wdt; -- retu_wdt_ping_disable(retu_wdt); -+ retu_wdt_ping_disable(wdev); - - return nonseekable_open(inode, file); - } - - static int retu_wdt_release(struct inode *inode, struct file *file) - { -- struct retu_wdt_dev *wdev = file->private_data; -+ struct miscdevice *mdev = file->private_data; -+ struct retu_wdt_dev *wdev = container_of(mdev, struct retu_wdt_dev, miscdev); - - #ifndef CONFIG_WATCHDOG_NOWAYOUT - retu_wdt_ping_enable(wdev); -@@ -134,8 +133,11 @@ static int retu_wdt_release(struct inode - static ssize_t retu_wdt_write(struct file *file, const char __user *data, - size_t len, loff_t *ppos) - { -+ struct miscdevice *mdev = file->private_data; -+ struct retu_wdt_dev *wdev = container_of(mdev, struct retu_wdt_dev, miscdev); -+ - if (len) -- retu_modify_counter(RETU_WDT_MAX_TIMER); -+ retu_modify_counter(wdev, RETU_WDT_MAX_TIMER); - - return len; - } -@@ -143,6 +145,8 @@ static ssize_t retu_wdt_write(struct fil - static long retu_wdt_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) - { -+ struct miscdevice *mdev = file->private_data; -+ struct retu_wdt_dev *wdev = container_of(mdev, struct retu_wdt_dev, miscdev); - int new_margin; - - static struct watchdog_info ident = { -@@ -167,15 +171,15 @@ static long retu_wdt_ioctl(struct file * - return put_user(omap_prcm_get_reset_sources(), - (int __user *)arg); - case WDIOC_KEEPALIVE: -- retu_modify_counter(RETU_WDT_MAX_TIMER); -+ retu_modify_counter(wdev, RETU_WDT_MAX_TIMER); - break; - case WDIOC_SETTIMEOUT: - if (get_user(new_margin, (int __user *)arg)) - return -EFAULT; -- retu_modify_counter(new_margin); -+ retu_modify_counter(wdev, new_margin); - /* Fall through */ - case WDIOC_GETTIMEOUT: -- return put_user(period_val, (int __user *)arg); -+ return put_user(wdev->period_val, (int __user *)arg); - } - - return 0; -@@ -199,15 +203,17 @@ static int __init retu_wdt_probe(struct - return -ENOMEM; - - wdev->dev = &pdev->dev; -+ wdev->period_val = RETU_WDT_DEFAULT_TIMER; -+ mutex_init(&wdev->mutex); - - platform_set_drvdata(pdev, wdev); -- retu_wdt = wdev; -- wdev->retu_wdt_miscdev.parent = &pdev->dev; -- wdev->retu_wdt_miscdev.minor = WATCHDOG_MINOR; -- wdev->retu_wdt_miscdev.name = "watchdog"; -- wdev->retu_wdt_miscdev.fops = &retu_wdt_fops; - -- ret = misc_register(&(wdev->retu_wdt_miscdev)); -+ wdev->miscdev.parent = &pdev->dev; -+ wdev->miscdev.minor = WATCHDOG_MINOR; -+ wdev->miscdev.name = "watchdog"; -+ wdev->miscdev.fops = &retu_wdt_fops; -+ -+ ret = misc_register(&wdev->miscdev); - if (ret) - goto err_free_wdev; - -@@ -216,9 +222,9 @@ static int __init retu_wdt_probe(struct - /* Kick the watchdog for kernel booting to finish. - * If nowayout is not set, we start the ping work. */ - #ifdef CONFIG_WATCHDOG_NOWAYOUT -- retu_modify_counter(RETU_WDT_MAX_TIMER); -+ retu_modify_counter(wdev, RETU_WDT_MAX_TIMER); - #else -- retu_wdt_ping_enable(retu_wdt); -+ retu_wdt_ping_enable(wdev); - #endif - - return 0; -@@ -234,7 +240,7 @@ static int __devexit retu_wdt_remove(str - struct retu_wdt_dev *wdev; - - wdev = platform_get_drvdata(pdev); -- misc_deregister(&wdev->retu_wdt_miscdev); -+ misc_deregister(&wdev->miscdev); - cancel_delayed_work_sync(&wdev->ping_work); - kfree(wdev); - diff --git a/target/linux/omap24xx/patches-2.6.38/545-cbus-retu-wdt-constify-info-struct.patch b/target/linux/omap24xx/patches-2.6.38/545-cbus-retu-wdt-constify-info-struct.patch deleted file mode 100644 index d07ad5f899..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/545-cbus-retu-wdt-constify-info-struct.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/drivers/cbus/retu-wdt.c -+++ b/drivers/cbus/retu-wdt.c -@@ -149,7 +149,7 @@ static long retu_wdt_ioctl(struct file * - struct retu_wdt_dev *wdev = container_of(mdev, struct retu_wdt_dev, miscdev); - int new_margin; - -- static struct watchdog_info ident = { -+ static const struct watchdog_info ident = { - .identity = "Retu Watchdog", - .options = WDIOF_SETTIMEOUT, - .firmware_version = 0, diff --git a/target/linux/omap24xx/patches-2.6.38/590-cbus-tahvo-usb-ptr-fix.patch b/target/linux/omap24xx/patches-2.6.38/590-cbus-tahvo-usb-ptr-fix.patch deleted file mode 100644 index aa6200b7f1..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/590-cbus-tahvo-usb-ptr-fix.patch +++ /dev/null @@ -1,69 +0,0 @@ ---- a/drivers/cbus/tahvo-usb.c -+++ b/drivers/cbus/tahvo-usb.c -@@ -99,7 +99,7 @@ struct tahvo_usb { - int tahvo_mode; - #endif - }; --static struct platform_device tahvo_usb_device; -+static struct tahvo_usb *tahvo_usb_device; - - /* - * --------------------------------------------------------------------------- -@@ -114,8 +114,7 @@ static struct platform_device *tahvo_otg - - static irqreturn_t omap_otg_irq(int irq, void *arg) - { -- struct platform_device *otg_dev = arg; -- struct tahvo_usb *tu = platform_get_drvdata(otg_dev); -+ struct tahvo_usb *tu = arg; - u16 otg_irq; - - otg_irq = omap_readw(OTG_IRQ_SRC); -@@ -201,12 +200,12 @@ static int __init omap_otg_probe(struct - - return request_irq(tahvo_otg_dev->resource[1].start, - omap_otg_irq, IRQF_DISABLED, DRIVER_NAME, -- &tahvo_usb_device); -+ tahvo_usb_device); - } - - static int __exit omap_otg_remove(struct platform_device *pdev) - { -- free_irq(tahvo_otg_dev->resource[1].start, &tahvo_usb_device); -+ free_irq(tahvo_otg_dev->resource[1].start, tahvo_usb_device); - tahvo_otg_dev = NULL; - - return 0; -@@ -659,6 +658,7 @@ static int __init tahvo_usb_probe(struct - tu = kzalloc(sizeof(*tu), GFP_KERNEL); - if (!tu) - return -ENOMEM; -+ tahvo_usb_device = tu; - - tu->pt_dev = container_of(dev, struct platform_device, dev); - #ifdef CONFIG_USB_OTG -@@ -682,6 +682,7 @@ static int __init tahvo_usb_probe(struct - (unsigned long) tu, "vbus_interrupt"); - if (ret != 0) { - kfree(tu); -+ tahvo_usb_device = NULL; - printk(KERN_ERR "Could not register Tahvo interrupt for VBUS\n"); - return ret; - } -@@ -708,6 +709,7 @@ static int __init tahvo_usb_probe(struct - ret = otg_set_transceiver(&tu->otg); - if (ret < 0) { - printk(KERN_ERR "Cannot register USB transceiver\n"); -+ tahvo_usb_device = NULL; - kfree(tu); - tahvo_free_irq(TAHVO_INT_VBUSON); - return ret; -@@ -732,6 +734,8 @@ static int __exit tahvo_usb_remove(struc - #ifdef CONFIG_USB_OTG - device_remove_file(&pdev->dev, &dev_attr_otg_mode); - #endif -+ tahvo_usb_device = NULL; -+ - return 0; - } - diff --git a/target/linux/omap24xx/patches-2.6.38/595-cbus-tahvo-usb-leak.patch b/target/linux/omap24xx/patches-2.6.38/595-cbus-tahvo-usb-leak.patch deleted file mode 100644 index 2fd4276acb..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/595-cbus-tahvo-usb-leak.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/drivers/cbus/tahvo-usb.c -+++ b/drivers/cbus/tahvo-usb.c -@@ -725,6 +725,8 @@ static int __init tahvo_usb_probe(struct - - static int __exit tahvo_usb_remove(struct platform_device *pdev) - { -+ struct tahvo_usb *tu = platform_get_drvdata(pdev); -+ - dev_dbg(&pdev->dev, "remove\n"); - - tahvo_free_irq(TAHVO_INT_VBUSON); -@@ -734,6 +736,8 @@ static int __exit tahvo_usb_remove(struc - #ifdef CONFIG_USB_OTG - device_remove_file(&pdev->dev, &dev_attr_otg_mode); - #endif -+ -+ kfree(tu); - tahvo_usb_device = NULL; - - return 0; diff --git a/target/linux/omap24xx/patches-2.6.38/596-cbus-tahvo-usb-clk.patch b/target/linux/omap24xx/patches-2.6.38/596-cbus-tahvo-usb-clk.patch deleted file mode 100644 index 2c88dfc288..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/596-cbus-tahvo-usb-clk.patch +++ /dev/null @@ -1,76 +0,0 @@ ---- a/drivers/cbus/tahvo-usb.c -+++ b/drivers/cbus/tahvo-usb.c -@@ -98,6 +98,7 @@ struct tahvo_usb { - #ifdef CONFIG_USB_OTG - int tahvo_mode; - #endif -+ struct clk *ick; - }; - static struct tahvo_usb *tahvo_usb_device; - -@@ -673,6 +674,14 @@ static int __init tahvo_usb_probe(struct - INIT_WORK(&tu->irq_work, tahvo_usb_irq_work); - mutex_init(&tu->serialize); - -+ tu->ick = clk_get(NULL, "usb_l4_ick"); -+ if (IS_ERR(tu->ick)) { -+ dev_err(dev, "Failed to get usb_l4_ick\n"); -+ ret = PTR_ERR(tu->ick); -+ goto err_free_tu; -+ } -+ clk_enable(tu->ick); -+ - /* Set initial state, so that we generate kevents only on - * state changes */ - tu->vbus_state = tahvo_read_reg(TAHVO_REG_IDSR) & 0x01; -@@ -681,10 +690,8 @@ static int __init tahvo_usb_probe(struct - ret = tahvo_request_irq(TAHVO_INT_VBUSON, tahvo_usb_vbus_interrupt, - (unsigned long) tu, "vbus_interrupt"); - if (ret != 0) { -- kfree(tu); -- tahvo_usb_device = NULL; - printk(KERN_ERR "Could not register Tahvo interrupt for VBUS\n"); -- return ret; -+ goto err_release_clk; - } - - /* Attributes */ -@@ -709,10 +716,7 @@ static int __init tahvo_usb_probe(struct - ret = otg_set_transceiver(&tu->otg); - if (ret < 0) { - printk(KERN_ERR "Cannot register USB transceiver\n"); -- tahvo_usb_device = NULL; -- kfree(tu); -- tahvo_free_irq(TAHVO_INT_VBUSON); -- return ret; -+ goto err_free_irq; - } - - dev_set_drvdata(dev, tu); -@@ -721,6 +725,17 @@ static int __init tahvo_usb_probe(struct - * may not be generated in addition to this. */ - schedule_work(&tu->irq_work); - return 0; -+ -+err_free_irq: -+ tahvo_free_irq(TAHVO_INT_VBUSON); -+err_release_clk: -+ clk_disable(tu->ick); -+ clk_put(tu->ick); -+err_free_tu: -+ kfree(tu); -+ tahvo_usb_device = NULL; -+ -+ return ret; - } - - static int __exit tahvo_usb_remove(struct platform_device *pdev) -@@ -736,6 +751,8 @@ static int __exit tahvo_usb_remove(struc - #ifdef CONFIG_USB_OTG - device_remove_file(&pdev->dev, &dev_attr_otg_mode); - #endif -+ clk_disable(tu->ick); -+ clk_put(tu->ick); - - kfree(tu); - tahvo_usb_device = NULL; diff --git a/target/linux/omap24xx/patches-2.6.38/597-cbus-tahvo-usb-platform.patch b/target/linux/omap24xx/patches-2.6.38/597-cbus-tahvo-usb-platform.patch deleted file mode 100644 index acc3ba34e0..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/597-cbus-tahvo-usb-platform.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/arch/arm/mach-omap2/board-n8x0.c -+++ b/arch/arm/mach-omap2/board-n8x0.c -@@ -40,6 +40,7 @@ - #include <plat/serial.h> - #include <plat/cbus.h> - #include <plat/gpio-switch.h> -+#include <plat/usb.h> - - #include "mux.h" - -@@ -395,6 +396,14 @@ static struct musb_hdrc_platform_data tu - .config = &musb_config, - }; - -+static struct omap_usb_config n8x0_omap_usb_config __initdata = { -+ .otg = 1, -+ .register_host = 1, -+ .register_dev = 1, -+ .hmc_mode = 16, -+ .pins[0] = 6, -+}; -+ - static void __init n8x0_usb_init(void) - { - int ret = 0; -@@ -417,6 +426,8 @@ static void __init n8x0_usb_init(void) - if (ret != 0) - goto err; - -+ omap2_usbfs_init(&n8x0_omap_usb_config); -+ - printk(announce); - - return; diff --git a/target/linux/omap24xx/patches-2.6.38/600-tsc2005.patch b/target/linux/omap24xx/patches-2.6.38/600-tsc2005.patch deleted file mode 100644 index 4fed8030b3..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/600-tsc2005.patch +++ /dev/null @@ -1,1031 +0,0 @@ ---- - drivers/input/touchscreen/Kconfig | 11 - drivers/input/touchscreen/Makefile | 1 - drivers/input/touchscreen/tsc2005.c | 958 ++++++++++++++++++++++++++++++++++++ - include/linux/spi/tsc2005.h | 30 + - 4 files changed, 1000 insertions(+) - ---- a/drivers/input/touchscreen/Kconfig -+++ b/drivers/input/touchscreen/Kconfig -@@ -629,6 +629,17 @@ config TOUCHSCREEN_TOUCHIT213 - To compile this driver as a module, choose M here: the - module will be called touchit213. - -+config TOUCHSCREEN_TSC2005 -+ tristate "TSC2005 based touchscreens" -+ depends on SPI_MASTER -+ help -+ Say Y here if you have a TSC2005 based touchscreen. -+ -+ If unsure, say N. -+ -+ To compile this driver as a module, choose M here: the -+ module will be called tsc2005. -+ - config TOUCHSCREEN_TSC2007 - tristate "TSC2007 based touchscreens" - depends on I2C ---- a/drivers/input/touchscreen/Makefile -+++ b/drivers/input/touchscreen/Makefile -@@ -45,6 +45,7 @@ obj-$(CONFIG_TOUCHSCREEN_TNETV107X) += t - obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o - obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o - obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o -+obj-$(CONFIG_TOUCHSCREEN_TSC2005) += tsc2005.o - obj-$(CONFIG_TOUCHSCREEN_TSC2007) += tsc2007.o - obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o - obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o ---- /dev/null -+++ b/drivers/input/touchscreen/tsc2005.c -@@ -0,0 +1,958 @@ -+/* -+ * TSC2005 touchscreen driver -+ * -+ * Copyright (C) 2006-2008 Nokia Corporation -+ * -+ * Author: Lauri Leukkunen <lauri.leukkunen@nokia.com> -+ * based on TSC2301 driver by Klaus K. Pedersen <klaus.k.pedersen@nokia.com> -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ * -+ */ -+ -+#include <linux/kernel.h> -+#include <linux/module.h> -+#include <linux/input.h> -+#include <linux/interrupt.h> -+#include <linux/delay.h> -+#include <linux/spi/spi.h> -+ -+#include <linux/spi/tsc2005.h> -+ -+/** -+ * The touchscreen interface operates as follows: -+ * -+ * Initialize: -+ * Request access to GPIO103 (DAV) -+ * tsc2005_ts_irq_handler will trigger when DAV line goes down -+ * -+ * 1) Pen is pressed against touchscreeen -+ * 2) TSC2005 performs AD conversion -+ * 3) After the conversion is done TSC2005 drives DAV line down -+ * 4) GPIO IRQ is received and tsc2005_ts_irq_handler is called -+ * 5) tsc2005_ts_irq_handler queues up an spi transfer to fetch -+ * the x, y, z1, z2 values -+ * 6) tsc2005_ts_rx() reports coordinates to input layer and -+ * sets up tsc2005_ts_timer() to be called after TSC2005_TS_SCAN_TIME -+ * 7) When the penup_timer expires, there have not been DAV interrupts -+ * during the last 20ms which means the pen has been lifted. -+ */ -+ -+#define TSC2005_VDD_LOWER_27 -+ -+#ifdef TSC2005_VDD_LOWER_27 -+#define TSC2005_HZ (10000000) -+#else -+#define TSC2005_HZ (25000000) -+#endif -+ -+#define TSC2005_CMD (0x80) -+#define TSC2005_REG (0x00) -+ -+#define TSC2005_CMD_STOP (1) -+#define TSC2005_CMD_10BIT (0 << 2) -+#define TSC2005_CMD_12BIT (1 << 2) -+ -+#define TSC2005_CMD_SCAN_XYZZ (0 << 3) -+#define TSC2005_CMD_SCAN_XY (1 << 3) -+#define TSC2005_CMD_SCAN_X (2 << 3) -+#define TSC2005_CMD_SCAN_Y (3 << 3) -+#define TSC2005_CMD_SCAN_ZZ (4 << 3) -+#define TSC2005_CMD_AUX_SINGLE (5 << 3) -+#define TSC2005_CMD_TEMP1 (6 << 3) -+#define TSC2005_CMD_TEMP2 (7 << 3) -+#define TSC2005_CMD_AUX_CONT (8 << 3) -+#define TSC2005_CMD_TEST_X_CONN (9 << 3) -+#define TSC2005_CMD_TEST_Y_CONN (10 << 3) -+#define TSC2005_CMD_TEST_SHORT (11 << 3) -+/* command 12 reserved, according to 2008-03 erratum */ -+#define TSC2005_CMD_DRIVE_XX (13 << 3) -+#define TSC2005_CMD_DRIVE_YY (14 << 3) -+#define TSC2005_CMD_DRIVE_YX (15 << 3) -+ -+#define TSC2005_REG_X (0 << 3) -+#define TSC2005_REG_Y (1 << 3) -+#define TSC2005_REG_Z1 (2 << 3) -+#define TSC2005_REG_Z2 (3 << 3) -+#define TSC2005_REG_AUX (4 << 3) -+#define TSC2005_REG_TEMP1 (5 << 3) -+#define TSC2005_REG_TEMP2 (6 << 3) -+#define TSC2005_REG_STATUS (7 << 3) -+#define TSC2005_REG_AUX_HIGH (8 << 3) -+#define TSC2005_REG_AUX_LOW (9 << 3) -+#define TSC2005_REG_TEMP_HIGH (10 << 3) -+#define TSC2005_REG_TEMP_LOW (11 << 3) -+#define TSC2005_REG_CFR0 (12 << 3) -+#define TSC2005_REG_CFR1 (13 << 3) -+#define TSC2005_REG_CFR2 (14 << 3) -+#define TSC2005_REG_FUNCTION (15 << 3) -+ -+#define TSC2005_REG_PND0 (1 << 1) -+#define TSC2005_REG_READ (0x01) -+#define TSC2005_REG_WRITE (0x00) -+ -+ -+#define TSC2005_CFR0_LONGSAMPLING (1) -+#define TSC2005_CFR0_DETECTINWAIT (1 << 1) -+#define TSC2005_CFR0_SENSETIME_32US (0) -+#define TSC2005_CFR0_SENSETIME_96US (1 << 2) -+#define TSC2005_CFR0_SENSETIME_544US (1 << 3) -+#define TSC2005_CFR0_SENSETIME_2080US (1 << 4) -+#define TSC2005_CFR0_SENSETIME_2656US (0x001C) -+#define TSC2005_CFR0_PRECHARGE_20US (0x0000) -+#define TSC2005_CFR0_PRECHARGE_84US (0x0020) -+#define TSC2005_CFR0_PRECHARGE_276US (0x0040) -+#define TSC2005_CFR0_PRECHARGE_1044US (0x0080) -+#define TSC2005_CFR0_PRECHARGE_1364US (0x00E0) -+#define TSC2005_CFR0_STABTIME_0US (0x0000) -+#define TSC2005_CFR0_STABTIME_100US (0x0100) -+#define TSC2005_CFR0_STABTIME_500US (0x0200) -+#define TSC2005_CFR0_STABTIME_1MS (0x0300) -+#define TSC2005_CFR0_STABTIME_5MS (0x0400) -+#define TSC2005_CFR0_STABTIME_100MS (0x0700) -+#define TSC2005_CFR0_CLOCK_4MHZ (0x0000) -+#define TSC2005_CFR0_CLOCK_2MHZ (0x0800) -+#define TSC2005_CFR0_CLOCK_1MHZ (0x1000) -+#define TSC2005_CFR0_RESOLUTION12 (0x2000) -+#define TSC2005_CFR0_STATUS (0x4000) -+#define TSC2005_CFR0_PENMODE (0x8000) -+ -+#define TSC2005_CFR0_INITVALUE (TSC2005_CFR0_STABTIME_1MS | \ -+ TSC2005_CFR0_CLOCK_1MHZ | \ -+ TSC2005_CFR0_RESOLUTION12 | \ -+ TSC2005_CFR0_PRECHARGE_276US | \ -+ TSC2005_CFR0_PENMODE) -+ -+/* Bits common to both read and write of config register 0 */ -+#define TSC2005_CFR0_RW_MASK 0x3fff -+ -+#define TSC2005_CFR1_BATCHDELAY_0MS (0x0000) -+#define TSC2005_CFR1_BATCHDELAY_1MS (0x0001) -+#define TSC2005_CFR1_BATCHDELAY_2MS (0x0002) -+#define TSC2005_CFR1_BATCHDELAY_4MS (0x0003) -+#define TSC2005_CFR1_BATCHDELAY_10MS (0x0004) -+#define TSC2005_CFR1_BATCHDELAY_20MS (0x0005) -+#define TSC2005_CFR1_BATCHDELAY_40MS (0x0006) -+#define TSC2005_CFR1_BATCHDELAY_100MS (0x0007) -+ -+#define TSC2005_CFR1_INITVALUE (TSC2005_CFR1_BATCHDELAY_4MS) -+ -+#define TSC2005_CFR2_MAVE_TEMP (0x0001) -+#define TSC2005_CFR2_MAVE_AUX (0x0002) -+#define TSC2005_CFR2_MAVE_Z (0x0004) -+#define TSC2005_CFR2_MAVE_Y (0x0008) -+#define TSC2005_CFR2_MAVE_X (0x0010) -+#define TSC2005_CFR2_AVG_1 (0x0000) -+#define TSC2005_CFR2_AVG_3 (0x0400) -+#define TSC2005_CFR2_AVG_7 (0x0800) -+#define TSC2005_CFR2_MEDIUM_1 (0x0000) -+#define TSC2005_CFR2_MEDIUM_3 (0x1000) -+#define TSC2005_CFR2_MEDIUM_7 (0x2000) -+#define TSC2005_CFR2_MEDIUM_15 (0x3000) -+ -+#define TSC2005_CFR2_IRQ_MASK (0xC000) -+#define TSC2005_CFR2_IRQ_DAV (0x4000) -+#define TSC2005_CFR2_IRQ_PEN (0x8000) -+#define TSC2005_CFR2_IRQ_PENDAV (0x0000) -+ -+#define TSC2005_CFR2_INITVALUE (TSC2005_CFR2_IRQ_PENDAV | \ -+ TSC2005_CFR2_MAVE_X | \ -+ TSC2005_CFR2_MAVE_Y | \ -+ TSC2005_CFR2_MAVE_Z | \ -+ TSC2005_CFR2_MEDIUM_15 | \ -+ TSC2005_CFR2_AVG_7) -+ -+#define MAX_12BIT ((1 << 12) - 1) -+#define TS_SAMPLES 4 -+#define TSC2005_TS_PENUP_TIME 40 -+ -+static const u32 tsc2005_read_reg[] = { -+ (TSC2005_REG | TSC2005_REG_X | TSC2005_REG_READ) << 16, -+ (TSC2005_REG | TSC2005_REG_Y | TSC2005_REG_READ) << 16, -+ (TSC2005_REG | TSC2005_REG_Z1 | TSC2005_REG_READ) << 16, -+ (TSC2005_REG | TSC2005_REG_Z2 | TSC2005_REG_READ) << 16, -+}; -+#define NUM_READ_REGS (sizeof(tsc2005_read_reg)/sizeof(tsc2005_read_reg[0])) -+ -+struct tsc2005 { -+ struct spi_device *spi; -+ -+ struct input_dev *idev; -+ char phys[32]; -+ struct timer_list penup_timer; -+ -+ /* ESD recovery via a hardware reset if the tsc2005 -+ * doesn't respond after a configurable period (in ms) of -+ * IRQ/SPI inactivity. If esd_timeout is 0, timer and work -+ * fields are used. -+ */ -+ u32 esd_timeout; -+ struct timer_list esd_timer; -+ struct work_struct esd_work; -+ -+ spinlock_t lock; -+ struct mutex mutex; -+ -+ struct spi_message read_msg; -+ struct spi_transfer read_xfer[NUM_READ_REGS]; -+ u32 data[NUM_READ_REGS]; -+ -+ /* previously reported x,y,p (if pen_down) */ -+ int out_x; -+ int out_y; -+ int out_p; -+ /* fudge parameters - changes must exceed one of these. */ -+ int fudge_x; -+ int fudge_y; -+ int fudge_p; -+ /* raw copy of previous x,y,z */ -+ int in_x; -+ int in_y; -+ int in_z1; -+ int in_z2; -+ /* average accumulators for each component */ -+ int sample_cnt; -+ int avg_x; -+ int avg_y; -+ int avg_z1; -+ int avg_z2; -+ /* configuration */ -+ int x_plate_ohm; -+ int hw_avg_max; -+ int stab_time; -+ int p_max; -+ int touch_pressure; -+ /* status */ -+ u8 sample_sent; -+ u8 pen_down; -+ u8 disabled; -+ u8 disable_depth; -+ u8 spi_pending; -+ -+ void (*set_reset)(bool enable); -+}; -+ -+static void tsc2005_cmd(struct tsc2005 *ts, u8 cmd) -+{ -+ u8 data = TSC2005_CMD | TSC2005_CMD_12BIT | cmd; -+ struct spi_message msg; -+ struct spi_transfer xfer = { 0 }; -+ -+ xfer.tx_buf = &data; -+ xfer.rx_buf = NULL; -+ xfer.len = 1; -+ xfer.bits_per_word = 8; -+ -+ spi_message_init(&msg); -+ spi_message_add_tail(&xfer, &msg); -+ spi_sync(ts->spi, &msg); -+} -+ -+static void tsc2005_write(struct tsc2005 *ts, u8 reg, u16 value) -+{ -+ u32 tx; -+ struct spi_message msg; -+ struct spi_transfer xfer = { 0 }; -+ -+ tx = (TSC2005_REG | reg | TSC2005_REG_PND0 | -+ TSC2005_REG_WRITE) << 16; -+ tx |= value; -+ -+ xfer.tx_buf = &tx; -+ xfer.rx_buf = NULL; -+ xfer.len = 4; -+ xfer.bits_per_word = 24; -+ -+ spi_message_init(&msg); -+ spi_message_add_tail(&xfer, &msg); -+ spi_sync(ts->spi, &msg); -+} -+ -+static void tsc2005_read(struct tsc2005 *ts, u8 reg, u16 *value) -+{ -+ u32 tx; -+ u32 rx = 0; -+ struct spi_message msg; -+ struct spi_transfer xfer = { 0 }; -+ -+ tx = (TSC2005_REG | reg | TSC2005_REG_READ) << 16; -+ -+ xfer.tx_buf = &tx; -+ xfer.rx_buf = ℞ -+ xfer.len = 4; -+ xfer.bits_per_word = 24; -+ -+ spi_message_init(&msg); -+ spi_message_add_tail(&xfer, &msg); -+ spi_sync(ts->spi, &msg); -+ *value = rx; -+} -+ -+static void tsc2005_ts_update_pen_state(struct tsc2005 *ts, -+ int x, int y, int pressure) -+{ -+ if (pressure) { -+ input_report_abs(ts->idev, ABS_X, x); -+ input_report_abs(ts->idev, ABS_Y, y); -+ input_report_abs(ts->idev, ABS_PRESSURE, pressure); -+ if (!ts->pen_down) { -+ input_report_key(ts->idev, BTN_TOUCH, 1); -+ ts->pen_down = 1; -+ } -+ } else { -+ input_report_abs(ts->idev, ABS_PRESSURE, 0); -+ if (ts->pen_down) { -+ input_report_key(ts->idev, BTN_TOUCH, 0); -+ ts->pen_down = 0; -+ } -+ } -+ -+ input_sync(ts->idev); -+} -+ -+/* -+ * This function is called by the SPI framework after the coordinates -+ * have been read from TSC2005 -+ */ -+static void tsc2005_ts_rx(void *arg) -+{ -+ struct tsc2005 *ts = arg; -+ unsigned long flags; -+ int inside_rect, pressure_limit; -+ int x, y, z1, z2, pressure; -+ -+ spin_lock_irqsave(&ts->lock, flags); -+ -+ if (ts->disable_depth) { -+ ts->spi_pending = 0; -+ goto out; -+ } -+ -+ x = ts->data[0]; -+ y = ts->data[1]; -+ z1 = ts->data[2]; -+ z2 = ts->data[3]; -+ -+ /* validate pressure and position */ -+ if (x > MAX_12BIT || y > MAX_12BIT) -+ goto out; -+ -+ /* skip coords if the pressure-components are out of range */ -+ if (z1 < 100 || z2 > MAX_12BIT || z1 >= z2) -+ goto out; -+ -+ /* skip point if this is a pen down with the exact same values as -+ * the value before pen-up - that implies SPI fed us stale data -+ */ -+ if (!ts->pen_down && -+ ts->in_x == x && -+ ts->in_y == y && -+ ts->in_z1 == z1 && -+ ts->in_z2 == z2) -+ goto out; -+ -+ /* At this point we are happy we have a valid and useful reading. -+ * Remember it for later comparisons. We may now begin downsampling -+ */ -+ ts->in_x = x; -+ ts->in_y = y; -+ ts->in_z1 = z1; -+ ts->in_z2 = z2; -+ -+ /* don't run average on the "pen down" event */ -+ if (ts->sample_sent) { -+ ts->avg_x += x; -+ ts->avg_y += y; -+ ts->avg_z1 += z1; -+ ts->avg_z2 += z2; -+ -+ if (++ts->sample_cnt < TS_SAMPLES) -+ goto out; -+ -+ x = ts->avg_x / TS_SAMPLES; -+ y = ts->avg_y / TS_SAMPLES; -+ z1 = ts->avg_z1 / TS_SAMPLES; -+ z2 = ts->avg_z2 / TS_SAMPLES; -+ } -+ -+ ts->sample_cnt = 0; -+ ts->avg_x = 0; -+ ts->avg_y = 0; -+ ts->avg_z1 = 0; -+ ts->avg_z2 = 0; -+ -+ pressure = x * (z2 - z1) / z1; -+ pressure = pressure * ts->x_plate_ohm / 4096; -+ -+ pressure_limit = ts->sample_sent ? ts->p_max : ts->touch_pressure; -+ if (pressure > pressure_limit) -+ goto out; -+ -+ /* Discard the event if it still is within the previous rect - -+ * unless the pressure is clearly harder, but then use previous -+ * x,y position. If any coordinate deviates enough, fudging -+ * of all three will still take place in the input layer. -+ */ -+ inside_rect = (ts->sample_sent && -+ x > (int)ts->out_x - ts->fudge_x && -+ x < (int)ts->out_x + ts->fudge_x && -+ y > (int)ts->out_y - ts->fudge_y && -+ y < (int)ts->out_y + ts->fudge_y); -+ if (inside_rect) -+ x = ts->out_x, y = ts->out_y; -+ -+ if (!inside_rect || pressure < (ts->out_p - ts->fudge_p)) { -+ tsc2005_ts_update_pen_state(ts, x, y, pressure); -+ ts->sample_sent = 1; -+ ts->out_x = x; -+ ts->out_y = y; -+ ts->out_p = pressure; -+ } -+out: -+ if (ts->spi_pending > 1) { -+ /* One or more interrupts (sometimes several dozens) -+ * occured while waiting for the SPI read - get -+ * another read going. -+ */ -+ ts->spi_pending = 1; -+ if (spi_async(ts->spi, &ts->read_msg)) { -+ dev_err(&ts->spi->dev, "ts: spi_async() failed"); -+ ts->spi_pending = 0; -+ } -+ } else -+ ts->spi_pending = 0; -+ -+ /* kick pen up timer - to make sure it expires again(!) */ -+ if (ts->sample_sent) { -+ mod_timer(&ts->penup_timer, -+ jiffies + msecs_to_jiffies(TSC2005_TS_PENUP_TIME)); -+ /* Also kick the watchdog, as we still think we're alive */ -+ if (ts->esd_timeout && ts->disable_depth == 0) { -+ unsigned long wdj = msecs_to_jiffies(ts->esd_timeout); -+ mod_timer(&ts->esd_timer, round_jiffies(jiffies+wdj)); -+ } -+ } -+ spin_unlock_irqrestore(&ts->lock, flags); -+} -+ -+/* This penup timer is very forgiving of delayed SPI reads. The -+ * (ESD) watchdog will rescue us if spi_pending remains set, unless -+ * we are enterring the disabled state. In that case we must just -+ * handle the pen up, and let disabling complete. -+ */ -+static void tsc2005_ts_penup_timer_handler(unsigned long data) -+{ -+ struct tsc2005 *ts = (struct tsc2005 *)data; -+ if ((!ts->spi_pending || ts->disable_depth) && -+ ts->sample_sent) { -+ tsc2005_ts_update_pen_state(ts, 0, 0, 0); -+ ts->sample_sent = 0; -+ } -+} -+ -+/* -+ * This interrupt is called when pen is down and coordinates are -+ * available. That is indicated by a either: -+ * a) a rising edge on PINTDAV or (PENDAV mode) -+ * b) a falling edge on DAV line (DAV mode) -+ * depending on the setting of the IRQ bits in the CFR2 setting above. -+ */ -+static irqreturn_t tsc2005_ts_irq_handler(int irq, void *dev_id) -+{ -+ struct tsc2005 *ts = dev_id; -+ if (ts->disable_depth) -+ goto out; -+ -+ if (!ts->spi_pending) { -+ if (spi_async(ts->spi, &ts->read_msg)) { -+ dev_err(&ts->spi->dev, "ts: spi_async() failed"); -+ goto out; -+ } -+ } -+ /* By shifting in 1s we can never wrap */ -+ ts->spi_pending = (ts->spi_pending<<1)+1; -+ -+ /* Kick pen up timer only if it's not been started yet. Strictly, -+ * it isn't even necessary to start it at all here, but doing so -+ * keeps an equivalence between pen state and timer state. -+ * The SPI read loop will keep pushing it into the future. -+ * If it times out with an SPI pending, it's ignored anyway. -+ */ -+ if (!timer_pending(&ts->penup_timer)) { -+ unsigned long pu = msecs_to_jiffies(TSC2005_TS_PENUP_TIME); -+ ts->penup_timer.expires = jiffies + pu; -+ add_timer(&ts->penup_timer); -+ } -+out: -+ return IRQ_HANDLED; -+} -+ -+static void tsc2005_ts_setup_spi_xfer(struct tsc2005 *ts) -+{ -+ struct spi_message *m = &ts->read_msg; -+ struct spi_transfer *x = &ts->read_xfer[0]; -+ int i; -+ -+ spi_message_init(m); -+ -+ for (i = 0; i < NUM_READ_REGS; i++, x++) { -+ x->tx_buf = &tsc2005_read_reg[i]; -+ x->rx_buf = &ts->data[i]; -+ x->len = 4; -+ x->bits_per_word = 24; -+ x->cs_change = i < (NUM_READ_REGS - 1); -+ spi_message_add_tail(x, m); -+ } -+ -+ m->complete = tsc2005_ts_rx; -+ m->context = ts; -+} -+ -+static ssize_t tsc2005_ts_pen_down_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct tsc2005 *ts = dev_get_drvdata(dev); -+ -+ return sprintf(buf, "%u\n", ts->pen_down); -+} -+ -+static DEVICE_ATTR(pen_down, S_IRUGO, tsc2005_ts_pen_down_show, NULL); -+ -+static int tsc2005_configure(struct tsc2005 *ts, int flags) -+{ -+ tsc2005_write(ts, TSC2005_REG_CFR0, TSC2005_CFR0_INITVALUE); -+ tsc2005_write(ts, TSC2005_REG_CFR1, TSC2005_CFR1_INITVALUE); -+ tsc2005_write(ts, TSC2005_REG_CFR2, TSC2005_CFR2_INITVALUE); -+ tsc2005_cmd(ts, flags); -+ -+ return 0; -+} -+ -+static void tsc2005_start_scan(struct tsc2005 *ts) -+{ -+ tsc2005_configure(ts, TSC2005_CMD_SCAN_XYZZ); -+} -+ -+static void tsc2005_stop_scan(struct tsc2005 *ts) -+{ -+ tsc2005_cmd(ts, TSC2005_CMD_STOP); -+} -+ -+/* Must be called with mutex held */ -+static void tsc2005_disable(struct tsc2005 *ts) -+{ -+ if (ts->disable_depth++ != 0) -+ return; -+ -+ disable_irq(ts->spi->irq); -+ if (ts->esd_timeout) -+ del_timer(&ts->esd_timer); -+ -+ /* wait until penup timer expire normally */ -+ do { -+ msleep(4); -+ } while (ts->sample_sent); -+ -+ tsc2005_stop_scan(ts); -+} -+ -+static void tsc2005_enable(struct tsc2005 *ts) -+{ -+ if (ts->disable_depth != 1) -+ goto out; -+ -+ if (ts->esd_timeout) { -+ unsigned long wdj = msecs_to_jiffies(ts->esd_timeout); -+ ts->esd_timer.expires = round_jiffies(jiffies+wdj); -+ add_timer(&ts->esd_timer); -+ } -+ tsc2005_start_scan(ts); -+ enable_irq(ts->spi->irq); -+out: -+ --ts->disable_depth; -+} -+ -+static ssize_t tsc2005_disable_show(struct device *dev, -+ struct device_attribute *attr, char *buf) -+{ -+ struct tsc2005 *ts = dev_get_drvdata(dev); -+ -+ return sprintf(buf, "%u\n", ts->disabled); -+} -+ -+static ssize_t tsc2005_disable_store(struct device *dev, -+ struct device_attribute *attr, -+ const char *buf, size_t count) -+{ -+ struct tsc2005 *ts = dev_get_drvdata(dev); -+ unsigned long res; -+ int i; -+ -+ if (strict_strtoul(buf, 10, &res) < 0) -+ return -EINVAL; -+ i = res ? 1 : 0; -+ -+ mutex_lock(&ts->mutex); -+ if (i == ts->disabled) -+ goto out; -+ ts->disabled = i; -+ -+ if (i) -+ tsc2005_disable(ts); -+ else -+ tsc2005_enable(ts); -+out: -+ mutex_unlock(&ts->mutex); -+ return count; -+} -+ -+static DEVICE_ATTR(disable_ts, 0664, tsc2005_disable_show, -+ tsc2005_disable_store); -+ -+static ssize_t tsc2005_ctrl_selftest_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ u16 temp_high_orig, temp_high_test, temp_high; -+ unsigned int result = 1; -+ struct tsc2005 *ts = dev_get_drvdata(dev); -+ -+ if (!ts->set_reset) { -+ dev_warn(&ts->spi->dev, -+ "unable to selftest: reset not configured\n"); -+ result = 0; -+ goto out; -+ } -+ -+ mutex_lock(&ts->mutex); -+ tsc2005_disable(ts); -+ -+ /* Test ctrl communications via temp high / low registers */ -+ tsc2005_read(ts, TSC2005_REG_TEMP_HIGH, &temp_high_orig); -+ -+ temp_high_test = (temp_high_orig - 1) & 0x0FFF; -+ -+ tsc2005_write(ts, TSC2005_REG_TEMP_HIGH, temp_high_test); -+ -+ tsc2005_read(ts, TSC2005_REG_TEMP_HIGH, &temp_high); -+ -+ if (temp_high != temp_high_test) { -+ result = 0; -+ dev_warn(dev, "selftest failed: %d != %d\n", -+ temp_high, temp_high_test); -+ } -+ -+ /* HW Reset */ -+ ts->set_reset(0); -+ msleep(1); /* only 10us required */ -+ ts->set_reset(1); -+ -+ tsc2005_enable(ts); -+ -+ /* Test that reset really happened */ -+ tsc2005_read(ts, TSC2005_REG_TEMP_HIGH, &temp_high); -+ -+ if (temp_high != temp_high_orig) { -+ result = 0; -+ dev_warn(dev, "selftest failed after reset: " -+ "%d != %d\n", -+ temp_high, temp_high_orig); -+ } -+ -+ mutex_unlock(&ts->mutex); -+ -+out: -+ return sprintf(buf, "%u\n", result); -+} -+ -+static DEVICE_ATTR(ts_ctrl_selftest, S_IRUGO, tsc2005_ctrl_selftest_show, NULL); -+ -+static void tsc2005_esd_timer_handler(unsigned long data) -+{ -+ struct tsc2005 *ts = (struct tsc2005 *)data; -+ if (!ts->disable_depth) -+ schedule_work(&ts->esd_work); -+} -+ -+static void tsc2005_rst_handler(struct work_struct *work) -+{ -+ u16 reg_val; -+ struct tsc2005 *ts = container_of(work, struct tsc2005, esd_work); -+ unsigned long wdj; -+ -+ mutex_lock(&ts->mutex); -+ -+ /* If we are disabled, or the a touch has been detected, -+ * then ignore this timeout. The enable will restart the -+ * watchdog, as it restarts scanning -+ */ -+ if (ts->disable_depth) -+ goto out; -+ -+ /* If we cannot read our known value from configuration register 0 -+ * then reset the controller as if from power-up and start -+ * scanning again. Always re-arm the watchdog. -+ */ -+ tsc2005_read(ts, TSC2005_REG_CFR0, ®_val); -+ if ((reg_val ^ TSC2005_CFR0_INITVALUE) & TSC2005_CFR0_RW_MASK) { -+ dev_info(&ts->spi->dev, "TSC not responding, resetting.\n"); -+ /* If this timer kicked in, the penup timer, if ever active -+ * at all, must have expired ages ago, so no need to del it. -+ */ -+ ts->set_reset(0); -+ if (ts->sample_sent) { -+ tsc2005_ts_update_pen_state(ts, 0, 0, 0); -+ ts->sample_sent = 0; -+ } -+ ts->spi_pending = 0; -+ msleep(1); /* only 10us required */ -+ ts->set_reset(1); -+ tsc2005_start_scan(ts); -+ } -+ wdj = msecs_to_jiffies(ts->esd_timeout); -+ mod_timer(&ts->esd_timer, round_jiffies(jiffies+wdj)); -+ -+out: -+ mutex_unlock(&ts->mutex); -+} -+ -+static int __devinit tsc2005_ts_init(struct tsc2005 *ts, -+ struct tsc2005_platform_data *pdata) -+{ -+ struct input_dev *idev; -+ int r; -+ int x_max, y_max; -+ -+ init_timer(&ts->penup_timer); -+ setup_timer(&ts->penup_timer, tsc2005_ts_penup_timer_handler, -+ (unsigned long)ts); -+ -+ spin_lock_init(&ts->lock); -+ mutex_init(&ts->mutex); -+ -+ ts->x_plate_ohm = pdata->ts_x_plate_ohm ? : 280; -+ ts->hw_avg_max = pdata->ts_hw_avg; -+ ts->stab_time = pdata->ts_stab_time; -+ x_max = pdata->ts_x_max ? : 4096; -+ ts->fudge_x = pdata->ts_x_fudge ? : 4; -+ y_max = pdata->ts_y_max ? : 4096; -+ ts->fudge_y = pdata->ts_y_fudge ? : 8; -+ ts->p_max = pdata->ts_pressure_max ? : MAX_12BIT; -+ ts->touch_pressure = pdata->ts_touch_pressure ? : ts->p_max; -+ ts->fudge_p = pdata->ts_pressure_fudge ? : 2; -+ -+ ts->set_reset = pdata->set_reset; -+ -+ idev = input_allocate_device(); -+ if (idev == NULL) { -+ r = -ENOMEM; -+ goto err1; -+ } -+ -+ idev->name = "TSC2005 touchscreen"; -+ snprintf(ts->phys, sizeof(ts->phys), "%s/input-ts", -+ dev_name(&ts->spi->dev)); -+ idev->phys = ts->phys; -+ -+ idev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); -+ idev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); -+ idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); -+ ts->idev = idev; -+ -+ tsc2005_ts_setup_spi_xfer(ts); -+ -+ input_set_abs_params(idev, ABS_X, 0, x_max, ts->fudge_x, 0); -+ input_set_abs_params(idev, ABS_Y, 0, y_max, ts->fudge_y, 0); -+ input_set_abs_params(idev, ABS_PRESSURE, 0, ts->p_max, ts->fudge_p, 0); -+ -+ tsc2005_start_scan(ts); -+ -+ r = request_irq(ts->spi->irq, tsc2005_ts_irq_handler, -+ (((TSC2005_CFR2_INITVALUE & TSC2005_CFR2_IRQ_MASK) == -+ TSC2005_CFR2_IRQ_PENDAV) -+ ? IRQF_TRIGGER_RISING -+ : IRQF_TRIGGER_FALLING) | -+ IRQF_DISABLED, "tsc2005", ts); -+ if (r < 0) { -+ dev_err(&ts->spi->dev, "unable to get DAV IRQ"); -+ goto err2; -+ } -+ -+ set_irq_wake(ts->spi->irq, 1); -+ -+ r = input_register_device(idev); -+ if (r < 0) { -+ dev_err(&ts->spi->dev, "can't register touchscreen device\n"); -+ goto err3; -+ } -+ -+ /* We can tolerate these failing */ -+ r = device_create_file(&ts->spi->dev, &dev_attr_ts_ctrl_selftest); -+ if (r < 0) -+ dev_warn(&ts->spi->dev, "can't create sysfs file for %s: %d\n", -+ dev_attr_ts_ctrl_selftest.attr.name, r); -+ -+ r = device_create_file(&ts->spi->dev, &dev_attr_pen_down); -+ if (r < 0) -+ dev_warn(&ts->spi->dev, "can't create sysfs file for %s: %d\n", -+ dev_attr_pen_down.attr.name, r); -+ -+ r = device_create_file(&ts->spi->dev, &dev_attr_disable_ts); -+ if (r < 0) -+ dev_warn(&ts->spi->dev, "can't create sysfs file for %s: %d\n", -+ dev_attr_disable_ts.attr.name, r); -+ -+ /* Finally, configure and start the optional EDD watchdog. */ -+ ts->esd_timeout = pdata->esd_timeout; -+ if (ts->esd_timeout && ts->set_reset) { -+ unsigned long wdj; -+ setup_timer(&ts->esd_timer, tsc2005_esd_timer_handler, -+ (unsigned long)ts); -+ INIT_WORK(&ts->esd_work, tsc2005_rst_handler); -+ wdj = msecs_to_jiffies(ts->esd_timeout); -+ ts->esd_timer.expires = round_jiffies(jiffies+wdj); -+ add_timer(&ts->esd_timer); -+ } -+ -+ return 0; -+err3: -+ free_irq(ts->spi->irq, ts); -+err2: -+ tsc2005_stop_scan(ts); -+ input_free_device(idev); -+err1: -+ return r; -+} -+ -+static int __devinit tsc2005_probe(struct spi_device *spi) -+{ -+ struct tsc2005 *ts; -+ struct tsc2005_platform_data *pdata = spi->dev.platform_data; -+ int r; -+ -+ if (spi->irq < 0) { -+ dev_dbg(&spi->dev, "no irq?\n"); -+ return -ENODEV; -+ } -+ if (!pdata) { -+ dev_dbg(&spi->dev, "no platform data?\n"); -+ return -ENODEV; -+ } -+ -+ ts = kzalloc(sizeof(*ts), GFP_KERNEL); -+ if (ts == NULL) -+ return -ENOMEM; -+ -+ dev_set_drvdata(&spi->dev, ts); -+ ts->spi = spi; -+ spi->dev.power.power_state = PMSG_ON; -+ -+ spi->mode = SPI_MODE_0; -+ spi->bits_per_word = 8; -+ /* The max speed might've been defined by the board-specific -+ * struct */ -+ if (!spi->max_speed_hz) -+ spi->max_speed_hz = TSC2005_HZ; -+ -+ spi_setup(spi); -+ -+ r = tsc2005_ts_init(ts, pdata); -+ if (r) -+ goto err1; -+ -+ return 0; -+ -+err1: -+ kfree(ts); -+ return r; -+} -+ -+static int __devexit tsc2005_remove(struct spi_device *spi) -+{ -+ struct tsc2005 *ts = dev_get_drvdata(&spi->dev); -+ -+ mutex_lock(&ts->mutex); -+ tsc2005_disable(ts); -+ mutex_unlock(&ts->mutex); -+ -+ device_remove_file(&ts->spi->dev, &dev_attr_disable_ts); -+ device_remove_file(&ts->spi->dev, &dev_attr_pen_down); -+ device_remove_file(&ts->spi->dev, &dev_attr_ts_ctrl_selftest); -+ -+ free_irq(ts->spi->irq, ts); -+ input_unregister_device(ts->idev); -+ -+ if (ts->esd_timeout) -+ del_timer(&ts->esd_timer); -+ kfree(ts); -+ -+ return 0; -+} -+ -+#ifdef CONFIG_PM -+static int tsc2005_suspend(struct spi_device *spi, pm_message_t mesg) -+{ -+ struct tsc2005 *ts = dev_get_drvdata(&spi->dev); -+ -+ mutex_lock(&ts->mutex); -+ tsc2005_disable(ts); -+ mutex_unlock(&ts->mutex); -+ -+ return 0; -+} -+ -+static int tsc2005_resume(struct spi_device *spi) -+{ -+ struct tsc2005 *ts = dev_get_drvdata(&spi->dev); -+ -+ mutex_lock(&ts->mutex); -+ tsc2005_enable(ts); -+ mutex_unlock(&ts->mutex); -+ -+ return 0; -+} -+#endif -+ -+static struct spi_driver tsc2005_driver = { -+ .driver = { -+ .name = "tsc2005", -+ .owner = THIS_MODULE, -+ }, -+#ifdef CONFIG_PM -+ .suspend = tsc2005_suspend, -+ .resume = tsc2005_resume, -+#endif -+ .probe = tsc2005_probe, -+ .remove = __devexit_p(tsc2005_remove), -+}; -+ -+static int __init tsc2005_init(void) -+{ -+ printk(KERN_INFO "TSC2005 driver initializing\n"); -+ -+ return spi_register_driver(&tsc2005_driver); -+} -+module_init(tsc2005_init); -+ -+static void __exit tsc2005_exit(void) -+{ -+ spi_unregister_driver(&tsc2005_driver); -+} -+module_exit(tsc2005_exit); -+ -+MODULE_AUTHOR("Lauri Leukkunen <lauri.leukkunen@nokia.com>"); -+MODULE_LICENSE("GPL"); -+MODULE_ALIAS("platform:tsc2005"); ---- /dev/null -+++ b/include/linux/spi/tsc2005.h -@@ -0,0 +1,30 @@ -+#ifndef _LINUX_SPI_TSC2005_H -+#define _LINUX_SPI_TSC2005_H -+ -+#include <linux/types.h> -+ -+struct tsc2005_platform_data { -+ u16 ts_x_plate_ohm; -+ u32 ts_stab_time; /* voltage settling time */ -+ u8 ts_hw_avg; /* HW assiseted averaging. Can be -+ 0, 4, 8, 16 samples per reading */ -+ u32 ts_touch_pressure; /* Pressure limit until we report a -+ touch event. After that we switch -+ to ts_max_pressure. */ -+ u32 ts_pressure_max;/* Samples with bigger pressure value will -+ be ignored, since the corresponding X, Y -+ values are unreliable */ -+ u32 ts_pressure_fudge; -+ u32 ts_x_max; -+ u32 ts_x_fudge; -+ u32 ts_y_max; -+ u32 ts_y_fudge; -+ -+ u32 esd_timeout; /* msec of inactivity before we check */ -+ -+ unsigned ts_ignore_last:1; -+ -+ void (*set_reset)(bool enable); -+}; -+ -+#endif diff --git a/target/linux/omap24xx/patches-2.6.38/710-evdev-events-without-grab.patch b/target/linux/omap24xx/patches-2.6.38/710-evdev-events-without-grab.patch deleted file mode 100644 index fa81278042..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/710-evdev-events-without-grab.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- - drivers/input/evdev.c | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - ---- a/drivers/input/evdev.c -+++ b/drivers/input/evdev.c -@@ -78,7 +78,7 @@ static void evdev_event(struct input_han - unsigned int type, unsigned int code, int value) - { - struct evdev *evdev = handle->private; -- struct evdev_client *client; -+ struct evdev_client *client, *c; - struct input_event event; - - do_gettimeofday(&event.time); -@@ -89,9 +89,13 @@ static void evdev_event(struct input_han - rcu_read_lock(); - - client = rcu_dereference(evdev->grab); -- if (client) -+ if (client) { - evdev_pass_event(client, &event); -- else -+ /* Also pass events to clients that did not grab the device. */ -+ list_for_each_entry_rcu(c, &evdev->client_list, node) -+ if (c != client) -+ evdev_pass_event(c, &event); -+ } else - list_for_each_entry_rcu(client, &evdev->client_list, node) - evdev_pass_event(client, &event); - diff --git a/target/linux/omap24xx/patches-2.6.38/810-mmc-fixes.patch b/target/linux/omap24xx/patches-2.6.38/810-mmc-fixes.patch deleted file mode 100644 index 854a1305e4..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/810-mmc-fixes.patch +++ /dev/null @@ -1,49 +0,0 @@ ---- a/drivers/mmc/host/omap.c -+++ b/drivers/mmc/host/omap.c -@@ -1456,6 +1456,7 @@ static int __init mmc_omap_probe(struct - host->dma_ch = -1; - - host->irq = irq; -+ host->reg_shift = (cpu_is_omap7xx() ? 1 : 2); - host->phys_base = host->mem_res->start; - host->virt_base = ioremap(res->start, res->end - res->start + 1); - if (!host->virt_base) -@@ -1495,7 +1496,9 @@ static int __init mmc_omap_probe(struct - } - } - -- host->reg_shift = (cpu_is_omap7xx() ? 1 : 2); -+ /* Make sure the detect workqueue was run at least once. */ -+ printk(KERN_INFO "OMAP-mmc: waiting for cards...\n"); -+ mmc_flush_scheduled_work(); - - return 0; - ---- a/drivers/mmc/core/core.c -+++ b/drivers/mmc/core/core.c -@@ -75,12 +75,13 @@ static int mmc_schedule_delayed_work(str - } - - /* -- * Internal function. Flush all scheduled work from the MMC work queue. -+ * Flush all scheduled work from the MMC work queue. - */ --static void mmc_flush_scheduled_work(void) -+void mmc_flush_scheduled_work(void) - { - flush_workqueue(workqueue); - } -+EXPORT_SYMBOL(mmc_flush_scheduled_work); - - /** - * mmc_request_done - finish processing an MMC request ---- a/include/linux/mmc/host.h -+++ b/include/linux/mmc/host.h -@@ -325,5 +325,7 @@ static inline int mmc_card_is_powered_re - return host->pm_flags & MMC_PM_KEEP_POWER; - } - -+void mmc_flush_scheduled_work(void); -+ - #endif - diff --git a/target/linux/omap24xx/patches-2.6.38/811-mmc-null-ptr-fix.patch b/target/linux/omap24xx/patches-2.6.38/811-mmc-null-ptr-fix.patch deleted file mode 100644 index 16b9ca6fe2..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/811-mmc-null-ptr-fix.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/drivers/mmc/host/omap.c -+++ b/drivers/mmc/host/omap.c -@@ -832,7 +832,7 @@ static irqreturn_t mmc_omap_irq(int irq, - return IRQ_HANDLED; - } - -- if (end_command) -+ if (end_command && host->cmd) - mmc_omap_cmd_done(host, host->cmd); - if (host->data != NULL) { - if (transfer_error) diff --git a/target/linux/omap24xx/patches-2.6.38/820-backlight-fixes.patch b/target/linux/omap24xx/patches-2.6.38/820-backlight-fixes.patch deleted file mode 100644 index 20cb61d5cf..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/820-backlight-fixes.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- - arch/arm/mach-omap2/board-n8x0-lcd.c | 18 ++++++++++++++++++ - 1 file changed, 18 insertions(+) - ---- a/arch/arm/mach-omap2/board-n8x0-lcd.c -+++ b/arch/arm/mach-omap2/board-n8x0-lcd.c -@@ -34,8 +34,26 @@ static void mipid_shutdown(struct mipid_ - } - } - -+static int n8x0_get_backlight_level(struct mipid_platform_data *pdata) -+{ -+ return tahvo_get_backlight_level(); -+} -+ -+static int n8x0_get_max_backlight_level(struct mipid_platform_data *pdata) -+{ -+ return tahvo_get_max_backlight_level(); -+} -+ -+static void n8x0_set_backlight_level(struct mipid_platform_data *pdata, int level) -+{ -+ tahvo_set_backlight_level(level); -+} -+ - struct mipid_platform_data n8x0_mipid_platform_data = { - .shutdown = mipid_shutdown, -+ .get_bklight_level = n8x0_get_backlight_level, -+ .set_bklight_level = n8x0_set_backlight_level, -+ .get_bklight_max = n8x0_get_max_backlight_level, - }; - - void __init n8x0_mipid_init(void) diff --git a/target/linux/omap24xx/patches-2.6.38/830-omap2-serial-fixes.patch b/target/linux/omap24xx/patches-2.6.38/830-omap2-serial-fixes.patch deleted file mode 100644 index cf2e9ac25c..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/830-omap2-serial-fixes.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/arch/arm/mach-omap2/serial.c -+++ b/arch/arm/mach-omap2/serial.c -@@ -660,6 +660,8 @@ static void serial_out_override(struct u - } - #endif - -+static struct omap_uart_state statebuf[4]; -+ - void __init omap_serial_early_init(void) - { - int i = 0; -@@ -675,9 +677,9 @@ void __init omap_serial_early_init(void) - if (!oh) - break; - -- uart = kzalloc(sizeof(struct omap_uart_state), GFP_KERNEL); -- if (WARN_ON(!uart)) -+ if (WARN_ON(i >= ARRAY_SIZE(statebuf))) - return; -+ uart = &statebuf[i]; - - uart->oh = oh; - uart->num = i++; diff --git a/target/linux/omap24xx/patches-2.6.38/850-musb-tusb-modular-fixes.patch b/target/linux/omap24xx/patches-2.6.38/850-musb-tusb-modular-fixes.patch deleted file mode 100644 index 111a499227..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/850-musb-tusb-modular-fixes.patch +++ /dev/null @@ -1,137 +0,0 @@ ---- a/drivers/Makefile -+++ b/drivers/Makefile -@@ -66,7 +66,7 @@ obj-$(CONFIG_TC) += tc/ - obj-$(CONFIG_UWB) += uwb/ - obj-$(CONFIG_USB_OTG_UTILS) += usb/otg/ - obj-$(CONFIG_USB) += usb/ --obj-$(CONFIG_USB_MUSB_HDRC) += usb/musb/ -+obj-y += usb/musb/ - obj-$(CONFIG_PCI) += usb/ - obj-$(CONFIG_USB_GADGET) += usb/gadget/ - obj-$(CONFIG_SERIO) += input/serio/ ---- a/drivers/usb/musb/Kconfig -+++ b/drivers/usb/musb/Kconfig -@@ -46,7 +46,7 @@ config USB_MUSB_DA8XX - depends on ARCH_DAVINCI_DA8XX - - config USB_MUSB_TUSB6010 -- bool "TUSB6010" -+ tristate "TUSB6010" - depends on ARCH_OMAP - - config USB_MUSB_OMAP2PLUS ---- a/drivers/usb/musb/tusb6010.c -+++ b/drivers/usb/musb/tusb6010.c -@@ -55,6 +55,7 @@ u8 tusb_get_revision(struct musb *musb) - - return rev; - } -+EXPORT_SYMBOL(tusb_get_revision); - - static int tusb_print_revision(struct musb *musb) - { -@@ -218,6 +219,7 @@ void musb_write_fifo(struct musb_hw_ep * - if (len > 0) - tusb_fifo_write_unaligned(fifo, buf, len); - } -+EXPORT_SYMBOL(musb_write_fifo); - - void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *buf) - { -@@ -264,6 +266,7 @@ void musb_read_fifo(struct musb_hw_ep *h - if (len > 0) - tusb_fifo_read_unaligned(fifo, buf, len); - } -+EXPORT_SYMBOL(musb_read_fifo); - - static struct musb *the_musb; - -@@ -1259,18 +1262,16 @@ static struct platform_driver tusb_drive - }, - }; - --MODULE_DESCRIPTION("TUSB6010 MUSB Glue Layer"); --MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); --MODULE_LICENSE("GPL v2"); -+//MODULE_DESCRIPTION("TUSB6010 MUSB Glue Layer"); -+//MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); -+//MODULE_LICENSE("GPL v2"); - --static int __init tusb_init(void) -+int musb_hdrc_glue_init(void) - { - return platform_driver_probe(&tusb_driver, tusb_probe); - } --subsys_initcall(tusb_init); - --static void __exit tusb_exit(void) -+void musb_hdrc_glue_exit(void) - { - platform_driver_unregister(&tusb_driver); - } --module_exit(tusb_exit); ---- a/drivers/usb/musb/Makefile -+++ b/drivers/usb/musb/Makefile -@@ -13,13 +13,13 @@ musb_hdrc-$(CONFIG_USB_MUSB_HDRC_HCD) + - musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o - - # Hardware Glue Layer --obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o --obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o --obj-$(CONFIG_USB_MUSB_TUSB6010) += tusb6010.o --obj-$(CONFIG_USB_MUSB_DAVINCI) += davinci.o --obj-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o --obj-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o --obj-$(CONFIG_USB_MUSB_UX500) += ux500.o -+musb_hdrc-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o -+musb_hdrc-$(CONFIG_USB_MUSB_AM35X) += am35x.o -+musb_hdrc-$(CONFIG_USB_MUSB_TUSB6010) += tusb6010.o -+musb_hdrc-$(CONFIG_USB_MUSB_DAVINCI) += davinci.o -+musb_hdrc-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o -+musb_hdrc-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o -+musb_hdrc-$(CONFIG_USB_MUSB_UX500) += ux500.o - - # the kconfig must guarantee that only one of the - # possible I/O schemes will be enabled at a time ... ---- a/drivers/usb/musb/musb_core.c -+++ b/drivers/usb/musb/musb_core.c -@@ -2427,8 +2427,13 @@ static struct platform_driver musb_drive - - /*-------------------------------------------------------------------------*/ - -+extern int musb_hdrc_glue_init(void); -+extern void musb_hdrc_glue_exit(void); -+ - static int __init musb_init(void) - { -+ int err; -+ - #ifdef CONFIG_USB_MUSB_HDRC_HCD - if (usb_disabled()) - return 0; -@@ -2456,7 +2461,17 @@ static int __init musb_init(void) - #endif - ", debug=%d\n", - musb_driver_name, musb_debug); -- return platform_driver_probe(&musb_driver, musb_probe); -+ -+ err = musb_hdrc_glue_init(); -+ if (err) -+ return err; -+ err = platform_driver_probe(&musb_driver, musb_probe); -+ if (err) { -+ musb_hdrc_glue_exit(); -+ return err; -+ } -+ -+ return 0; - } - - /* make us init after usbcore and i2c (transceivers, regulators, etc) -@@ -2467,5 +2482,6 @@ fs_initcall(musb_init); - static void __exit musb_cleanup(void) - { - platform_driver_unregister(&musb_driver); -+ musb_hdrc_glue_exit(); - } - module_exit(musb_cleanup); diff --git a/target/linux/omap24xx/patches-2.6.38/900-n810-battery-management.patch b/target/linux/omap24xx/patches-2.6.38/900-n810-battery-management.patch deleted file mode 100644 index beef0b60b1..0000000000 --- a/target/linux/omap24xx/patches-2.6.38/900-n810-battery-management.patch +++ /dev/null @@ -1,1927 +0,0 @@ ---- a/drivers/cbus/Kconfig -+++ b/drivers/cbus/Kconfig -@@ -72,4 +72,12 @@ config CBUS_RETU_HEADSET - to Retu/Vilma. Detection state and events are exposed through - sysfs. - -+config N810BM -+ depends on CBUS_RETU && CBUS_TAHVO -+ tristate "Nokia n810 battery management" -+ ---help--- -+ Nokia n810 device battery management. -+ -+ If unsure, say N. -+ - endmenu ---- a/drivers/cbus/Makefile -+++ b/drivers/cbus/Makefile -@@ -11,3 +11,6 @@ obj-$(CONFIG_CBUS_RETU_POWERBUTTON) += r - obj-$(CONFIG_CBUS_RETU_RTC) += retu-rtc.o - obj-$(CONFIG_CBUS_RETU_WDT) += retu-wdt.o - obj-$(CONFIG_CBUS_RETU_HEADSET) += retu-headset.o -+n810bm-y += n810bm_main.o -+n810bm-y += lipocharge.o -+obj-$(CONFIG_N810BM) += n810bm.o ---- /dev/null -+++ b/drivers/cbus/n810bm_main.c -@@ -0,0 +1,1586 @@ -+/* -+ * Nokia n810 battery management -+ * -+ * WARNING: This driver is based on unconfirmed documentation. -+ * It is possibly dangerous to use this software. -+ * Use this software at your own risk! -+ * -+ * Copyright (c) 2010-2011 Michael Buesch <mb@bu3sch.de> -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version 2 -+ * of the License, or (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ */ -+ -+#define DEBUG -+ -+#include <linux/module.h> -+#include <linux/device.h> -+#include <linux/platform_device.h> -+#include <linux/slab.h> -+#include <linux/mutex.h> -+#include <linux/timer.h> -+#include <linux/firmware.h> -+#include <linux/bitops.h> -+#include <linux/workqueue.h> -+#include <linux/delay.h> -+ -+#include "cbus.h" -+#include "retu.h" -+#include "tahvo.h" -+#include "lipocharge.h" -+ -+ -+#define N810BM_PMM_BLOCK_FILENAME "n810-cal-bme-pmm.fw" -+#define N810BM_PMM_BLOCK_SIZE 0x600 -+#define N810BM_PMM_GROUP_SIZE 0x200 -+#define N810BM_PMM_ELEM_SIZE 0x10 -+ -+#define N810BM_CHECK_INTERVAL (HZ * 2) -+#define N810BM_MIN_VOLTAGE_THRES 3200 /* Absolute minimum voltage threshold */ -+ -+ -+/* RETU_ADC_BSI -+ * The battery size indicator ADC measures the resistance between -+ * the battery BSI pin and ground. This is used to detect the battery -+ * capacity, as the BSI resistor is related to capacity. -+ * -+ * Manually measured lookup table. -+ * Hard to measure, thus not very accurate. -+ * -+ * Resistance | ADC value -+ * ======================== -+ * 120k | 0x3AC -+ * 110k | 0x37C -+ * 100k | 0x351 -+ * 90k | 0x329 -+ */ -+ -+/* RETU_ADC_BATTVOLT -+ * Manually measured lookup table. -+ * Hard to measure, thus not very accurate. -+ * -+ * Voltage | ADC value -+ * ===================== -+ * 2.80V | 0x037 -+ * 2.90V | 0x05E -+ * 3.00V | 0x090 -+ * 3.10V | 0x0A4 -+ * 3.20V | 0x0CC -+ * 3.30V | 0x0EF -+ * 3.40V | 0x115 -+ * 3.50V | 0x136 -+ * 3.60V | 0x15C -+ * 3.70V | 0x187 -+ * 3.80V | 0x1A5 -+ * 3.90V | 0x1C9 -+ * 4.00V | 0x1ED -+ * 4.10V | 0x212 -+ * 4.20V | 0x236 -+ */ -+ -+ -+/* PMM block ADC IDs */ -+enum n810bm_pmm_adc_id { -+ N810BM_PMM_ADC_BATVOLT = 0x01, /* Battery voltage */ -+ N810BM_PMM_ADC_CHGVOLT = 0x02, /* Charger voltage */ -+ N810BM_PMM_ADC_GND2 = 0x03, /* Ground 0V */ -+ N810BM_PMM_ADC_BSI = 0x04, /* Battery size indicator */ -+ N810BM_PMM_ADC_BATTEMP = 0x05, /* Battery temperature */ -+ N810BM_PMM_ADC_HEADSET = 0x06, /* Headset detection */ -+ N810BM_PMM_ADC_HOOKDET = 0x07, /* Hook detection */ -+ N810BM_PMM_ADC_LIGHTSENS = 0x08, /* Light sensor */ -+ N810BM_PMM_ADC_BATCURR = 0x0E, /* Battery current */ -+ N810BM_PMM_ADC_BKUPVOLT = 0x13, /* Backup battery voltage */ -+ N810BM_PMM_ADC_LIGHTTEMP = 0x14, /* Light sensor temperature */ -+ N810BM_PMM_ADC_RFGP = 0x15, /* RF GP */ -+ N810BM_PMM_ADC_WBTX = 0x16, /* Wideband TX detection */ -+ N810BM_PMM_ADC_RETUTEMP = 0x17, /* RETU chip temperature */ -+ N810BM_PMM_ADC_0xFE = 0xFE, -+}; -+ -+struct n810bm_adc_calib { -+ enum n810bm_pmm_adc_id id; -+ u8 flags; -+ u8 adc_groupnr; -+ u32 field1; -+ u32 field2; -+ u16 field3; -+ u16 field4; -+}; -+ -+struct n810bm_calib { -+ struct n810bm_adc_calib adc[25]; -+}; -+ -+enum n810bm_capacity { -+ N810BM_CAP_UNKNOWN = -1, -+ N810BM_CAP_NONE = 0, -+ N810BM_CAP_1500MAH = 1500, /* 1500 mAh battery */ -+}; -+ -+enum n810bm_notify_flags { -+ N810BM_NOTIFY_charger_present, -+ N810BM_NOTIFY_charger_state, -+ N810BM_NOTIFY_charger_pwm, -+}; -+ -+struct n810bm { -+ bool battery_present; /* A battery is inserted */ -+ bool charger_present; /* The charger is connected */ -+ enum n810bm_capacity capacity; /* The capacity of the inserted battery (if any) */ -+ -+ bool charger_enabled; /* Want to charge? */ -+ struct lipocharge charger; /* Charger subsystem */ -+ unsigned int active_current_pwm; /* Active value of TAHVO_REG_CHGCURR */ -+ int current_measure_enabled; /* Current measure enable refcount */ -+ -+ struct platform_device *pdev; -+ struct n810bm_calib calib; /* Calibration data */ -+ -+ bool verbose_charge_log; /* Verbose charge logging */ -+ -+ unsigned long notify_flags; -+ struct work_struct notify_work; -+ struct work_struct currmeas_irq_work; -+ struct delayed_work periodic_check_work; -+ -+ bool initialized; /* The hardware was initialized */ -+ struct mutex mutex; -+}; -+ -+static void n810bm_notify_charger_present(struct n810bm *bm); -+static void n810bm_notify_charger_state(struct n810bm *bm); -+static void n810bm_notify_charger_pwm(struct n810bm *bm); -+ -+ -+static struct platform_device *n810bm_retu_device; -+static struct platform_device *n810bm_tahvo_device; -+ -+ -+static inline struct n810bm * device_to_n810bm(struct device *dev) -+{ -+ struct platform_device *pdev = to_platform_device(dev); -+ struct n810bm *bm = platform_get_drvdata(pdev); -+ -+ return bm; -+} -+ -+static inline bool n810bm_known_battery_present(struct n810bm *bm) -+{ -+ return bm->battery_present && -+ bm->capacity != N810BM_CAP_UNKNOWN && -+ bm->capacity != N810BM_CAP_NONE; -+} -+ -+static NORET_TYPE void n810bm_emergency(struct n810bm *bm, const char *message) ATTRIB_NORET; -+static void n810bm_emergency(struct n810bm *bm, const char *message) -+{ -+ printk(KERN_EMERG "n810 battery management fatal fault: %s\n", message); -+ cbus_emergency(); -+} -+ -+static u16 tahvo_read(struct n810bm *bm, unsigned int reg) -+{ -+ return tahvo_read_reg(reg); -+} -+ -+static void tahvo_maskset(struct n810bm *bm, unsigned int reg, u16 mask, u16 set) -+{ -+ tahvo_set_clear_reg_bits(reg, set, mask); -+} -+ -+static inline void tahvo_write(struct n810bm *bm, unsigned int reg, u16 value) -+{ -+ unsigned long flags; -+ -+ spin_lock_irqsave(&tahvo_lock, flags); -+ tahvo_write_reg(reg, value); -+ spin_unlock_irqrestore(&tahvo_lock, flags); -+} -+ -+static inline void tahvo_set(struct n810bm *bm, unsigned int reg, u16 mask) -+{ -+ tahvo_set_clear_reg_bits(reg, mask, mask); -+} -+ -+static inline void tahvo_clear(struct n810bm *bm, unsigned int reg, u16 mask) -+{ -+ tahvo_set_clear_reg_bits(reg, 0, mask); -+} -+ -+static u16 retu_read(struct n810bm *bm, unsigned int reg) -+{ -+ return retu_read_reg(&n810bm_retu_device->dev, reg); -+} -+ -+static void retu_maskset(struct n810bm *bm, unsigned int reg, u16 mask, u16 set) -+{ -+ retu_set_clear_reg_bits(&n810bm_retu_device->dev, reg, set, mask); -+} -+ -+static inline void retu_write(struct n810bm *bm, unsigned int reg, u16 value) -+{ -+ retu_write_reg(&n810bm_retu_device->dev, reg, value); -+} -+ -+static int retu_adc_average(struct n810bm *bm, unsigned int chan, -+ unsigned int nr_passes) -+{ -+ unsigned int i, value = 0; -+ int ret; -+ -+ if (WARN_ON(!nr_passes)) -+ return 0; -+ for (i = 0; i < nr_passes; i++) { -+ ret = retu_read_adc(&n810bm_retu_device->dev, chan); -+ if (ret < 0) -+ return ret; -+ value += ret; -+ } -+ value /= nr_passes; -+ -+ return value; -+} -+ -+static struct n810bm_adc_calib * n810bm_get_adc_calib(struct n810bm *bm, -+ enum n810bm_pmm_adc_id id) -+{ -+ unsigned int index = 0; -+ struct n810bm_adc_calib *cal; -+ -+ if (id != N810BM_PMM_ADC_0xFE) -+ index = (unsigned int)id + 1; -+ if (index >= ARRAY_SIZE(bm->calib.adc)) -+ return NULL; -+ -+ cal = &bm->calib.adc[index]; -+ WARN_ON(cal->id && cal->id != id); -+ -+ return cal; -+} -+ -+static int pmm_record_get(struct n810bm *bm, -+ const struct firmware *pmm_block, -+ void *buffer, size_t length, -+ unsigned int group, unsigned int element, unsigned int offset) -+{ -+ const u8 *pmm_area = pmm_block->data; -+ u8 active_group_mask; -+ -+ if (pmm_block->size != N810BM_PMM_BLOCK_SIZE) -+ return -EINVAL; -+ if (group >= N810BM_PMM_BLOCK_SIZE / N810BM_PMM_GROUP_SIZE) -+ return -EINVAL; -+ if (element >= N810BM_PMM_GROUP_SIZE / N810BM_PMM_ELEM_SIZE) -+ return -EINVAL; -+ if (offset >= N810BM_PMM_ELEM_SIZE || length > N810BM_PMM_ELEM_SIZE || -+ length + offset > N810BM_PMM_ELEM_SIZE) -+ return -EINVAL; -+ -+ active_group_mask = pmm_area[16]; -+ if (!(active_group_mask & (1 << group))) { -+ dev_dbg(&bm->pdev->dev, "pwm_record_get: Requested group %u, " -+ "but group is not active", group); -+ return -ENOENT; -+ } -+ -+ memcpy(buffer, -+ pmm_area + group * N810BM_PMM_GROUP_SIZE -+ + element * N810BM_PMM_ELEM_SIZE -+ + offset, -+ length); -+ -+ return 0; -+} -+ -+/* PMM block group 1 element */ -+struct group1_element { -+ u8 id; -+ u8 flags; -+ u8 adc_groupnr; -+ u8 _padding; -+ __le32 field1; -+ __le32 field2; -+} __packed; -+ -+static int extract_group1_elem(struct n810bm *bm, -+ const struct firmware *pmm_block, -+ const enum n810bm_pmm_adc_id *pmm_adc_ids, size_t nr_pmm_adc_ids, -+ u32 field1_mask, u32 field2_mask) -+{ -+ struct group1_element elem; -+ int err; -+ unsigned int i, element_nr; -+ struct n810bm_adc_calib *adc_calib; -+ -+ for (i = 0; i < nr_pmm_adc_ids; i++) { -+ element_nr = (unsigned int)(pmm_adc_ids[i]) + 3; -+ -+ err = pmm_record_get(bm, pmm_block, &elem, sizeof(elem), -+ 1, element_nr, 0); -+ if (err) -+ continue; -+ adc_calib = n810bm_get_adc_calib(bm, elem.id); -+ if (!adc_calib) { -+ dev_err(&bm->pdev->dev, "extract_group1_elem: " -+ "Could not get calib element for 0x%02X", -+ elem.id); -+ return -EINVAL; -+ } -+ -+ if (adc_calib->flags == elem.flags) { -+ adc_calib->field1 = le32_to_cpu(elem.field1) & field1_mask; -+ adc_calib->field2 = le32_to_cpu(elem.field2) & field2_mask; -+ } else { -+ dev_dbg(&bm->pdev->dev, "extract_group1_elem: " -+ "Not extracting fields due to flags mismatch: " -+ "0x%02X vs 0x%02X", -+ adc_calib->flags, elem.flags); -+ } -+ } -+ -+ return 0; -+} -+ -+static int n810bm_parse_pmm_group1(struct n810bm *bm, -+ const struct firmware *pmm_block) -+{ -+ struct n810bm_adc_calib *adc_calib; -+ struct group1_element elem; -+ int err; -+ -+ static const enum n810bm_pmm_adc_id pmm_adc_ids_1[] = { -+ N810BM_PMM_ADC_BATVOLT, -+ N810BM_PMM_ADC_CHGVOLT, -+ N810BM_PMM_ADC_BKUPVOLT, -+ N810BM_PMM_ADC_BATCURR, -+ }; -+ static const enum n810bm_pmm_adc_id pmm_adc_ids_2[] = { -+ N810BM_PMM_ADC_BSI, -+ }; -+ static const enum n810bm_pmm_adc_id pmm_adc_ids_3[] = { -+ N810BM_PMM_ADC_BATTEMP, -+ }; -+ -+ /* Parse element 2 */ -+ err = pmm_record_get(bm, pmm_block, &elem, sizeof(elem), -+ 1, 2, 0); -+ if (err) { -+ dev_err(&bm->pdev->dev, -+ "PMM: Failed to get group 1 / element 2"); -+ return err; -+ } -+ if (elem.id == N810BM_PMM_ADC_0xFE && elem.flags == 0x05) { -+ adc_calib = n810bm_get_adc_calib(bm, elem.id); -+ if (!adc_calib) { -+ dev_err(&bm->pdev->dev, -+ "calib extract: Failed to get 0xFE calib"); -+ return -EINVAL; -+ } -+ adc_calib->id = elem.id; -+ adc_calib->flags = elem.flags; -+ adc_calib->field1 = le32_to_cpu(elem.field1); -+ adc_calib->field2 = le32_to_cpu(elem.field2); -+ } -+ -+ err = extract_group1_elem(bm, pmm_block, -+ pmm_adc_ids_1, ARRAY_SIZE(pmm_adc_ids_1), -+ 0xFFFFFFFF, 0xFFFFFFFF); -+ if (err) -+ return err; -+ err = extract_group1_elem(bm, pmm_block, -+ pmm_adc_ids_2, ARRAY_SIZE(pmm_adc_ids_2), -+ 0xFFFFFFFF, 0); -+ if (err) -+ return err; -+ err = extract_group1_elem(bm, pmm_block, -+ pmm_adc_ids_3, ARRAY_SIZE(pmm_adc_ids_3), -+ 0xFFFFFFFF, 0x0000FFFF); -+ if (err) -+ return err; -+ -+ return 0; -+} -+ -+static int n810bm_parse_pmm_group2(struct n810bm *bm, -+ const struct firmware *pmm_block) -+{ -+ dev_err(&bm->pdev->dev, "TODO: CAL BME PMM group 2 parser not implemented, yet"); -+ return -EOPNOTSUPP; -+} -+ -+static void n810bm_adc_calib_set_defaults(struct n810bm *bm) -+{ -+ struct n810bm_adc_calib *adc_calib; -+ unsigned int i; -+ -+ static const struct n810bm_adc_calib defaults[] = { -+ /* ADC group-nr 0 */ -+ { -+ .id = N810BM_PMM_ADC_HEADSET, -+ .flags = 0x00, -+ .adc_groupnr = 0, -+ }, { -+ .id = N810BM_PMM_ADC_HOOKDET, -+ .flags = 0x00, -+ .adc_groupnr = 0, -+ }, { -+ .id = N810BM_PMM_ADC_RFGP, -+ .flags = 0x00, -+ .adc_groupnr = 0, -+ }, { -+ .id = N810BM_PMM_ADC_LIGHTSENS, -+ .flags = 0x00, -+ .adc_groupnr = 0, -+ }, { -+ .id = N810BM_PMM_ADC_WBTX, -+ .flags = 0x00, -+ .adc_groupnr = 0, -+ }, { -+ .id = N810BM_PMM_ADC_RETUTEMP, -+ .flags = 0x00, -+ .adc_groupnr = 0, -+ }, { -+ .id = N810BM_PMM_ADC_GND2, -+ .flags = 0x00, -+ .adc_groupnr = 0, -+ }, -+ /* ADC group-nr 1 */ -+ { -+ .id = N810BM_PMM_ADC_0xFE, -+ .flags = 0x05, -+ .adc_groupnr = 1, -+ .field1 = (u32)-2, -+ .field2 = 13189, -+ }, { -+ .id = N810BM_PMM_ADC_BATVOLT, -+ .flags = 0x01, -+ .adc_groupnr = 1, -+ .field1 = 2527, -+ .field2 = 21373, -+ }, { -+ .id = N810BM_PMM_ADC_CHGVOLT, -+ .flags = 0x01, -+ .adc_groupnr = 1, -+ .field1 = 0, -+ .field2 = 129848, -+ }, { -+ .id = N810BM_PMM_ADC_BKUPVOLT, -+ .flags = 0x01, -+ .adc_groupnr = 1, -+ .field1 = 0, -+ .field2 = 20000, -+ }, { -+ .id = N810BM_PMM_ADC_BATCURR, -+ .flags = 0x06, -+ .adc_groupnr = 1, -+ .field1 = 0, -+ .field2 = 9660, -+ }, -+ /* ADC group-nr 2 */ -+ { -+ .id = N810BM_PMM_ADC_BSI, -+ .flags = 0x02, -+ .adc_groupnr = 2, -+ .field1 = 1169, -+ .field2 = 0, -+ }, -+ /* ADC group-nr 3 */ -+ { -+ .id = N810BM_PMM_ADC_BATTEMP, -+ .flags = 0x03, -+ .adc_groupnr = 3, -+ .field1 = 265423000, -+ .field2 = 298, -+ }, -+ /* ADC group-nr 4 */ -+ { -+ .id = N810BM_PMM_ADC_LIGHTTEMP, -+ .flags = 0x04, -+ .adc_groupnr = 4, -+ .field1 = 19533778, -+ .field2 = 308019670, -+ .field3 = 4700, -+ .field4 = 2500, -+ }, -+ }; -+ -+ /* Clear the array */ -+ memset(&bm->calib.adc, 0, sizeof(bm->calib.adc)); -+ for (i = 0; i < ARRAY_SIZE(bm->calib.adc); i++) -+ bm->calib.adc[i].flags = 0xFF; -+ -+ /* Copy the defaults */ -+ for (i = 0; i < ARRAY_SIZE(defaults); i++) { -+ adc_calib = n810bm_get_adc_calib(bm, defaults[i].id); -+ if (WARN_ON(!adc_calib)) -+ continue; -+ *adc_calib = defaults[i]; -+ } -+} -+ -+static int n810bm_parse_pmm_block(struct n810bm *bm, -+ const struct firmware *pmm_block) -+{ -+ u8 byte; -+ int err; -+ unsigned int i, count; -+ struct n810bm_adc_calib *adc_calib; -+ -+ /* Initialize to defaults */ -+ n810bm_adc_calib_set_defaults(bm); -+ -+ /* Parse the PMM data */ -+ err = pmm_record_get(bm, pmm_block, &byte, sizeof(byte), -+ 1, 0, 0); /* group 1 / element 0 */ -+ err |= (byte != 0x01); -+ err |= pmm_record_get(bm, pmm_block, &byte, sizeof(byte), -+ 1, 1, 0); /* group 1 / element 1 */ -+ err |= (byte != 0x01); -+ if (err) -+ err = n810bm_parse_pmm_group2(bm, pmm_block); -+ else -+ err = n810bm_parse_pmm_group1(bm, pmm_block); -+ if (err) -+ return err; -+ -+ /* Sanity checks */ -+ for (i = 0, count = 0; i < ARRAY_SIZE(bm->calib.adc); i++) { -+ adc_calib = &bm->calib.adc[i]; -+ if (adc_calib->flags == 0xFF) -+ continue; -+ switch (adc_calib->id) { -+ case N810BM_PMM_ADC_BATVOLT: -+ if (adc_calib->field1 < 2400 || -+ adc_calib->field1 > 2700) -+ goto value_check_fail; -+ if (adc_calib->field2 < 20000 || -+ adc_calib->field2 > 23000) -+ goto value_check_fail; -+ count++; -+ break; -+ case N810BM_PMM_ADC_BSI: -+ if (adc_calib->field1 < 1100 || -+ adc_calib->field1 > 1300) -+ goto value_check_fail; -+ count++; -+ break; -+ case N810BM_PMM_ADC_BATCURR: -+ if (adc_calib->field2 < 7000 || -+ adc_calib->field2 > 12000) -+ goto value_check_fail; -+ count++; -+ break; -+ case N810BM_PMM_ADC_0xFE: -+ if ((s32)adc_calib->field1 > 14 || -+ (s32)adc_calib->field1 < -14) -+ goto value_check_fail; -+ if (adc_calib->field2 < 13000 || -+ adc_calib->field2 > 13350) -+ goto value_check_fail; -+ count++; -+ break; -+ case N810BM_PMM_ADC_CHGVOLT: -+ case N810BM_PMM_ADC_BATTEMP: -+ case N810BM_PMM_ADC_BKUPVOLT: -+ count++; -+ break; -+ case N810BM_PMM_ADC_GND2: -+ case N810BM_PMM_ADC_HOOKDET: -+ case N810BM_PMM_ADC_LIGHTSENS: -+ case N810BM_PMM_ADC_HEADSET: -+ case N810BM_PMM_ADC_LIGHTTEMP: -+ case N810BM_PMM_ADC_RFGP: -+ case N810BM_PMM_ADC_WBTX: -+ case N810BM_PMM_ADC_RETUTEMP: -+ break; -+ } -+ dev_dbg(&bm->pdev->dev, -+ "ADC 0x%02X calib: 0x%02X 0x%02X 0x%08X 0x%08X 0x%04X 0x%04X", -+ adc_calib->id, adc_calib->flags, adc_calib->adc_groupnr, -+ adc_calib->field1, adc_calib->field2, -+ adc_calib->field3, adc_calib->field4); -+ } -+ if (count != 7) { -+ dev_err(&bm->pdev->dev, "PMM sanity check: Did not find " -+ "all required values (count=%u)", count); -+ goto check_fail; -+ } -+ -+ return 0; -+ -+value_check_fail: -+ dev_err(&bm->pdev->dev, "PMM image sanity check failed " -+ "(id=%02X, field1=%08X, field2=%08X)", -+ adc_calib->id, adc_calib->field1, adc_calib->field2); -+check_fail: -+ return -EILSEQ; -+} -+ -+/* Set the current measure timer that triggers on Tahvo IRQ 7 -+ * An interval of zero disables the timer. */ -+static void n810bm_set_current_measure_timer(struct n810bm *bm, -+ u16 millisec_interval) -+{ -+ u16 value = millisec_interval; -+ -+ if (value <= 0xF905) { -+ value = ((u64)0x10624DD3 * (u64)(value + 0xF9)) >> 32; -+ value /= 16; -+ } else -+ value = 0xFF; -+ -+ tahvo_write(bm, TAHVO_REG_BATCURRTIMER, value & 0xFF); -+ -+ tahvo_set(bm, TAHVO_REG_CHGCTL, -+ TAHVO_REG_CHGCTL_CURTIMRST); -+ tahvo_clear(bm, TAHVO_REG_CHGCTL, -+ TAHVO_REG_CHGCTL_CURTIMRST); -+ -+ if (millisec_interval) -+ tahvo_enable_irq(TAHVO_INT_BATCURR); -+ else -+ tahvo_disable_irq(TAHVO_INT_BATCURR); -+ -+ //TODO also do a software timer for safety. -+} -+ -+static void n810bm_enable_current_measure(struct n810bm *bm) -+{ -+ WARN_ON(bm->current_measure_enabled < 0); -+ if (!bm->current_measure_enabled) { -+ /* Enable the current measurement circuitry */ -+ tahvo_set(bm, TAHVO_REG_CHGCTL, -+ TAHVO_REG_CHGCTL_CURMEAS); -+ dev_dbg(&bm->pdev->dev, -+ "Current measurement circuitry enabled"); -+ } -+ bm->current_measure_enabled++; -+} -+ -+static void n810bm_disable_current_measure(struct n810bm *bm) -+{ -+ bm->current_measure_enabled--; -+ WARN_ON(bm->current_measure_enabled < 0); -+ if (!bm->current_measure_enabled) { -+ /* Disable the current measurement circuitry */ -+ tahvo_clear(bm, TAHVO_REG_CHGCTL, -+ TAHVO_REG_CHGCTL_CURMEAS); -+ dev_dbg(&bm->pdev->dev, -+ "Current measurement circuitry disabled"); -+ } -+} -+ -+/* Measure the actual battery current. Returns a signed value in mA. -+ * Does only work, if current measurement was enabled. */ -+static int n810bm_measure_batt_current(struct n810bm *bm) -+{ -+ u16 retval; -+ int adc = 0, ma, i; -+ -+ if (WARN_ON(bm->current_measure_enabled <= 0)) -+ return 0; -+ for (i = 0; i < 3; i++) { -+ retval = tahvo_read(bm, TAHVO_REG_BATCURR); -+ adc += (s16)retval; /* Value is signed */ -+ } -+ adc /= 3; -+ -+ //TODO convert to mA -+ ma = adc; -+ -+ return ma; -+} -+ -+/* Requires bm->mutex locked */ -+static int n810bm_measure_batt_current_async(struct n810bm *bm) -+{ -+ int ma; -+ bool charging = lipocharge_is_charging(&bm->charger); -+ -+ n810bm_enable_current_measure(bm); -+ if (!charging) -+ WARN_ON(bm->active_current_pwm != 0); -+ tahvo_maskset(bm, TAHVO_REG_CHGCTL, -+ TAHVO_REG_CHGCTL_EN | -+ TAHVO_REG_CHGCTL_PWMOVR | -+ TAHVO_REG_CHGCTL_PWMOVRZERO, -+ TAHVO_REG_CHGCTL_EN | -+ TAHVO_REG_CHGCTL_PWMOVR | -+ (charging ? 0 : TAHVO_REG_CHGCTL_PWMOVRZERO)); -+ ma = n810bm_measure_batt_current(bm); -+ tahvo_maskset(bm, TAHVO_REG_CHGCTL, -+ TAHVO_REG_CHGCTL_EN | -+ TAHVO_REG_CHGCTL_PWMOVR | -+ TAHVO_REG_CHGCTL_PWMOVRZERO, -+ (charging ? TAHVO_REG_CHGCTL_EN : 0)); -+ n810bm_disable_current_measure(bm); -+ -+ return ma; -+} -+ -+static int adc_sanity_check(struct n810bm *bm, unsigned int channel) -+{ -+ int value; -+ -+ value = retu_read_adc(&n810bm_retu_device->dev, channel); -+ if (value < 0) { -+ dev_err(&bm->pdev->dev, "Failed to read GND ADC channel %u", -+ channel); -+ return -EIO; -+ } -+ dev_dbg(&bm->pdev->dev, -+ "GND ADC channel %u sanity check got value: %d", -+ channel, value); -+ if (value > 5) { -+ n810bm_emergency(bm, "GND ADC sanity check failed"); -+ return -EIO; -+ } -+ -+ return 0; -+} -+ -+static int n810bm_check_adc_sanity(struct n810bm *bm) -+{ -+ int err; -+ -+ /* Discard one conversion */ -+ retu_write(bm, RETU_REG_ADCSCR, 0); -+ retu_read_adc(&n810bm_retu_device->dev, RETU_ADC_GND2); -+ -+ err = adc_sanity_check(bm, RETU_ADC_GND2); -+ if (err) -+ return err; -+ -+ return 0; -+} -+ -+/* Measure the battery voltage. Returns the value in mV (or negative value on error). */ -+static int n810bm_measure_batt_voltage(struct n810bm *bm) -+{ -+ int adc; -+ unsigned int mv; -+ const unsigned int scale = 1000; -+ -+ adc = retu_adc_average(bm, RETU_ADC_BATTVOLT, 5); -+ if (adc < 0) -+ return adc; -+ if (adc <= 0x37) -+ return 2800; -+ mv = 2800 + ((adc - 0x37) * (((4200 - 2800) * scale) / (0x236 - 0x37))) / scale; -+ -+ //TODO compensate for power consumption -+ //TODO honor calibration values -+ -+ return mv; -+} -+ -+/* Measure the charger voltage. Returns the value in mV (or negative value on error). */ -+static int n810bm_measure_charger_voltage(struct n810bm *bm) -+{ -+ int adc; -+ unsigned int mv; -+ -+ adc = retu_adc_average(bm, RETU_ADC_CHGVOLT, 5); -+ if (adc < 0) -+ return adc; -+ //TODO convert to mV -+ mv = adc; -+ -+ return mv; -+} -+ -+/* Measure backup battery voltage. Returns the value in mV (or negative value on error). */ -+static int n810bm_measure_backup_batt_voltage(struct n810bm *bm) -+{ -+ int adc; -+ unsigned int mv; -+ -+ adc = retu_adc_average(bm, RETU_ADC_BKUPVOLT, 3); -+ if (adc < 0) -+ return adc; -+ //TODO convert to mV -+ mv = adc; -+ -+ return mv; -+} -+ -+/* Measure the battery temperature. Returns the value in K (or negative value on error). */ -+static int n810bm_measure_batt_temp(struct n810bm *bm) -+{ -+ int adc; -+ unsigned int k; -+ -+ adc = retu_adc_average(bm, RETU_ADC_BATTEMP, 3); -+ if (adc < 0) -+ return adc; -+ //TODO convert to K -+ k = adc; -+ -+ return k; -+} -+ -+/* Read the battery capacity via BSI pin. */ -+static enum n810bm_capacity n810bm_read_batt_capacity(struct n810bm *bm) -+{ -+ int adc; -+ const unsigned int hyst = 20; -+ -+ adc = retu_adc_average(bm, RETU_ADC_BSI, 5); -+ if (adc < 0) { -+ dev_err(&bm->pdev->dev, "Failed to read BSI ADC"); -+ return N810BM_CAP_UNKNOWN; -+ } -+ -+ if (adc >= 0x3B5 - hyst && adc <= 0x3B5 + hyst) -+ return N810BM_CAP_1500MAH; -+ -+ dev_err(&bm->pdev->dev, "Capacity indicator 0x%X unknown", adc); -+ -+ return N810BM_CAP_UNKNOWN; -+} -+ -+/* Convert a battery voltage (in mV) to percentage. */ -+static unsigned int n810bm_mvolt2percent(unsigned int mv) -+{ -+ const unsigned int minv = 3700; -+ const unsigned int maxv = 4150; -+ unsigned int percent; -+ -+ mv = clamp(mv, minv, maxv); -+ percent = (mv - minv) * 100 / (maxv - minv); -+ -+ return percent; -+} -+ -+static void n810bm_start_charge(struct n810bm *bm) -+{ -+ int err; -+ -+ WARN_ON(!bm->battery_present); -+ WARN_ON(!bm->charger_present); -+ -+ /* Set PWM to zero */ -+ bm->active_current_pwm = 0; -+ tahvo_write(bm, TAHVO_REG_CHGCURR, bm->active_current_pwm); -+ -+ /* Charge global enable */ -+ tahvo_maskset(bm, TAHVO_REG_CHGCTL, -+ TAHVO_REG_CHGCTL_EN | -+ TAHVO_REG_CHGCTL_PWMOVR | -+ TAHVO_REG_CHGCTL_PWMOVRZERO, -+ TAHVO_REG_CHGCTL_EN); -+ -+ WARN_ON((int)bm->capacity <= 0); -+ bm->charger.capacity = bm->capacity; -+ err = lipocharge_start(&bm->charger); -+ WARN_ON(err); -+ -+ /* Initialize current measurement circuitry */ -+ n810bm_enable_current_measure(bm); -+ n810bm_set_current_measure_timer(bm, 250); -+ -+ dev_info(&bm->pdev->dev, "Charging battery"); -+ n810bm_notify_charger_state(bm); -+ n810bm_notify_charger_pwm(bm); -+} -+ -+static void n810bm_stop_charge(struct n810bm *bm) -+{ -+ if (lipocharge_is_charging(&bm->charger)) { -+ n810bm_set_current_measure_timer(bm, 0); -+ n810bm_disable_current_measure(bm); -+ } -+ lipocharge_stop(&bm->charger); -+ -+ /* Set PWM to zero */ -+ bm->active_current_pwm = 0; -+ tahvo_write(bm, TAHVO_REG_CHGCURR, bm->active_current_pwm); -+ -+ /* Charge global disable */ -+ tahvo_maskset(bm, TAHVO_REG_CHGCTL, -+ TAHVO_REG_CHGCTL_EN | -+ TAHVO_REG_CHGCTL_PWMOVR | -+ TAHVO_REG_CHGCTL_PWMOVRZERO, -+ 0); -+ -+ dev_info(&bm->pdev->dev, "Not charging battery"); -+ n810bm_notify_charger_state(bm); -+ n810bm_notify_charger_pwm(bm); -+} -+ -+/* Periodic check */ -+static void n810bm_periodic_check_work(struct work_struct *work) -+{ -+ struct n810bm *bm = container_of(to_delayed_work(work), -+ struct n810bm, periodic_check_work); -+ u16 status; -+ bool battery_was_present, charger_was_present; -+ int mv; -+ -+ mutex_lock(&bm->mutex); -+ -+ status = retu_read(bm, RETU_REG_STATUS); -+ battery_was_present = bm->battery_present; -+ charger_was_present = bm->charger_present; -+ bm->battery_present = !!(status & RETU_REG_STATUS_BATAVAIL); -+ bm->charger_present = !!(status & RETU_REG_STATUS_CHGPLUG); -+ -+ if (bm->battery_present != battery_was_present) { -+ /* Battery state changed */ -+ if (bm->battery_present) { -+ bm->capacity = n810bm_read_batt_capacity(bm); -+ if (bm->capacity == N810BM_CAP_UNKNOWN) { -+ dev_err(&bm->pdev->dev, "Unknown battery detected"); -+ } else { -+ dev_info(&bm->pdev->dev, "Detected %u mAh battery", -+ (unsigned int)bm->capacity); -+ } -+ } else { -+ bm->capacity = N810BM_CAP_NONE; -+ dev_info(&bm->pdev->dev, "The main battery was removed"); -+ //TODO disable charging -+ } -+ } -+ -+ if (bm->charger_present != charger_was_present) { -+ /* Charger state changed */ -+ dev_info(&bm->pdev->dev, "The charger was %s", -+ bm->charger_present ? "plugged in" : "removed"); -+ n810bm_notify_charger_present(bm); -+ } -+ -+ if ((bm->battery_present && !bm->charger_present) || -+ !n810bm_known_battery_present(bm)){ -+ /* We're draining the battery */ -+ mv = n810bm_measure_batt_voltage(bm); -+ if (mv < 0) { -+ n810bm_emergency(bm, -+ "check: Failed to measure voltage"); -+ } -+ if (mv < N810BM_MIN_VOLTAGE_THRES) { -+ n810bm_emergency(bm, -+ "check: Minimum voltage threshold reached"); -+ } -+ } -+ -+ if (bm->charger_present && n810bm_known_battery_present(bm)) { -+ /* Known battery and charger are connected */ -+ if (bm->charger_enabled) { -+ /* Charger is enabled */ -+ if (!lipocharge_is_charging(&bm->charger)) { -+ //TODO start charging, if battery is below some threshold -+ n810bm_start_charge(bm); -+ } -+ } -+ } -+ -+ if (lipocharge_is_charging(&bm->charger) && !bm->charger_present) { -+ /* Charger was unplugged. */ -+ n810bm_stop_charge(bm); -+ } -+ -+ mutex_unlock(&bm->mutex); -+ schedule_delayed_work(&bm->periodic_check_work, -+ round_jiffies_relative(N810BM_CHECK_INTERVAL)); -+} -+ -+/*XXX -+static void n810bm_adc_irq_handler(unsigned long data) -+{ -+ struct n810bm *bm = (struct n810bm *)data; -+ -+ retu_ack_irq(RETU_INT_ADCS); -+ //TODO -+dev_info(&bm->pdev->dev, "ADC interrupt triggered\n"); -+} -+*/ -+ -+static void n810bm_tahvo_current_measure_work(struct work_struct *work) -+{ -+ struct n810bm *bm = container_of(work, struct n810bm, currmeas_irq_work); -+ int res, ma, mv, temp; -+ -+ mutex_lock(&bm->mutex); -+ if (!lipocharge_is_charging(&bm->charger)) -+ goto out_unlock; -+ -+ tahvo_maskset(bm, TAHVO_REG_CHGCTL, -+ TAHVO_REG_CHGCTL_PWMOVR | -+ TAHVO_REG_CHGCTL_PWMOVRZERO, -+ TAHVO_REG_CHGCTL_PWMOVR); -+ ma = n810bm_measure_batt_current(bm); -+ tahvo_maskset(bm, TAHVO_REG_CHGCTL, -+ TAHVO_REG_CHGCTL_PWMOVR | -+ TAHVO_REG_CHGCTL_PWMOVRZERO, -+ TAHVO_REG_CHGCTL_PWMOVR | -+ TAHVO_REG_CHGCTL_PWMOVRZERO); -+ msleep(10); -+ mv = n810bm_measure_batt_voltage(bm); -+ tahvo_maskset(bm, TAHVO_REG_CHGCTL, -+ TAHVO_REG_CHGCTL_PWMOVR | -+ TAHVO_REG_CHGCTL_PWMOVRZERO, -+ 0); -+ temp = n810bm_measure_batt_temp(bm); -+ if (WARN_ON(mv < 0)) -+ goto out_unlock; -+ if (WARN_ON(temp < 0)) -+ goto out_unlock; -+ -+ if (bm->verbose_charge_log) { -+ dev_info(&bm->pdev->dev, -+ "Battery charge state: %d mV, %d mA (%s)", -+ mv, ma, -+ (ma <= 0) ? "discharging" : "charging"); -+ } -+ res = lipocharge_update_state(&bm->charger, mv, ma, temp); -+ if (res) { -+ if (res > 0) -+ dev_info(&bm->pdev->dev, "Battery fully charged"); -+ n810bm_stop_charge(bm); -+ } -+out_unlock: -+ mutex_unlock(&bm->mutex); -+} -+ -+static void n810bm_tahvo_current_measure_irq_handler(unsigned long data) -+{ -+ struct n810bm *bm = (struct n810bm *)data; -+ -+ tahvo_ack_irq(TAHVO_INT_BATCURR); -+ schedule_work(&bm->currmeas_irq_work); -+} -+ -+#define DEFINE_ATTR_NOTIFY(attr_name) \ -+ void n810bm_notify_##attr_name(struct n810bm *bm) \ -+ { \ -+ set_bit(N810BM_NOTIFY_##attr_name, &bm->notify_flags); \ -+ wmb(); \ -+ schedule_work(&bm->notify_work); \ -+ } -+ -+#define DEFINE_SHOW_INT_FUNC(name, member) \ -+ static ssize_t n810bm_attr_##name##_show(struct device *dev, \ -+ struct device_attribute *attr, \ -+ char *buf) \ -+ { \ -+ struct n810bm *bm = device_to_n810bm(dev); \ -+ ssize_t count; \ -+ \ -+ mutex_lock(&bm->mutex); \ -+ count = snprintf(buf, PAGE_SIZE, "%d\n", (int)(bm->member)); \ -+ mutex_unlock(&bm->mutex); \ -+ \ -+ return count; \ -+ } -+ -+#define DEFINE_STORE_INT_FUNC(name, member) \ -+ static ssize_t n810bm_attr_##name##_store(struct device *dev, \ -+ struct device_attribute *attr,\ -+ const char *buf, size_t count)\ -+ { \ -+ struct n810bm *bm = device_to_n810bm(dev); \ -+ long val; \ -+ int err; \ -+ \ -+ mutex_lock(&bm->mutex); \ -+ err = strict_strtol(buf, 0, &val); \ -+ if (!err) \ -+ bm->member = (typeof(bm->member))val; \ -+ mutex_unlock(&bm->mutex); \ -+ \ -+ return err ? err : count; \ -+ } -+ -+#define DEFINE_ATTR_SHOW_INT(name, member) \ -+ DEFINE_SHOW_INT_FUNC(name, member) \ -+ static DEVICE_ATTR(name, S_IRUGO, \ -+ n810bm_attr_##name##_show, NULL); -+ -+#define DEFINE_ATTR_SHOW_STORE_INT(name, member) \ -+ DEFINE_SHOW_INT_FUNC(name, member) \ -+ DEFINE_STORE_INT_FUNC(name, member) \ -+ static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, \ -+ n810bm_attr_##name##_show, \ -+ n810bm_attr_##name##_store); -+ -+DEFINE_ATTR_SHOW_INT(battery_present, battery_present); -+DEFINE_ATTR_SHOW_INT(charger_present, charger_present); -+static DEFINE_ATTR_NOTIFY(charger_present); -+DEFINE_ATTR_SHOW_INT(charger_state, charger.state); -+static DEFINE_ATTR_NOTIFY(charger_state); -+DEFINE_ATTR_SHOW_INT(charger_pwm, active_current_pwm); -+static DEFINE_ATTR_NOTIFY(charger_pwm); -+DEFINE_ATTR_SHOW_STORE_INT(charger_enable, charger_enabled); -+DEFINE_ATTR_SHOW_STORE_INT(charger_verbose, verbose_charge_log); -+ -+static ssize_t n810bm_attr_battery_level_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct n810bm *bm = device_to_n810bm(dev); -+ ssize_t count = -ENODEV; -+ int millivolt; -+ -+ mutex_lock(&bm->mutex); -+ if (!bm->battery_present || lipocharge_is_charging(&bm->charger)) -+ millivolt = 0; -+ else -+ millivolt = n810bm_measure_batt_voltage(bm); -+ if (millivolt >= 0) { -+ count = snprintf(buf, PAGE_SIZE, "%u\n", -+ n810bm_mvolt2percent(millivolt)); -+ } -+ mutex_unlock(&bm->mutex); -+ -+ return count; -+} -+static DEVICE_ATTR(battery_level, S_IRUGO, -+ n810bm_attr_battery_level_show, NULL); -+ -+static ssize_t n810bm_attr_battery_capacity_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct n810bm *bm = device_to_n810bm(dev); -+ ssize_t count; -+ int capacity = 0; -+ -+ mutex_lock(&bm->mutex); -+ if (n810bm_known_battery_present(bm)) -+ capacity = (int)bm->capacity; -+ count = snprintf(buf, PAGE_SIZE, "%d\n", capacity); -+ mutex_unlock(&bm->mutex); -+ -+ return count; -+} -+static DEVICE_ATTR(battery_capacity, S_IRUGO, -+ n810bm_attr_battery_capacity_show, NULL); -+ -+static ssize_t n810bm_attr_battery_temp_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct n810bm *bm = device_to_n810bm(dev); -+ ssize_t count = -ENODEV; -+ int k; -+ -+ mutex_lock(&bm->mutex); -+ k = n810bm_measure_batt_temp(bm); -+ if (k >= 0) -+ count = snprintf(buf, PAGE_SIZE, "%d\n", k); -+ mutex_unlock(&bm->mutex); -+ -+ return count; -+} -+static DEVICE_ATTR(battery_temp, S_IRUGO, -+ n810bm_attr_battery_temp_show, NULL); -+ -+static ssize_t n810bm_attr_charger_voltage_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct n810bm *bm = device_to_n810bm(dev); -+ ssize_t count = -ENODEV; -+ int mv = 0; -+ -+ mutex_lock(&bm->mutex); -+ if (bm->charger_present) -+ mv = n810bm_measure_charger_voltage(bm); -+ if (mv >= 0) -+ count = snprintf(buf, PAGE_SIZE, "%d\n", mv); -+ mutex_unlock(&bm->mutex); -+ -+ return count; -+} -+static DEVICE_ATTR(charger_voltage, S_IRUGO, -+ n810bm_attr_charger_voltage_show, NULL); -+ -+static ssize_t n810bm_attr_backup_battery_voltage_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct n810bm *bm = device_to_n810bm(dev); -+ ssize_t count = -ENODEV; -+ int mv; -+ -+ mutex_lock(&bm->mutex); -+ mv = n810bm_measure_backup_batt_voltage(bm); -+ if (mv >= 0) -+ count = snprintf(buf, PAGE_SIZE, "%d\n", mv); -+ mutex_unlock(&bm->mutex); -+ -+ return count; -+} -+static DEVICE_ATTR(backup_battery_voltage, S_IRUGO, -+ n810bm_attr_backup_battery_voltage_show, NULL); -+ -+static ssize_t n810bm_attr_battery_current_show(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct n810bm *bm = device_to_n810bm(dev); -+ ssize_t count = -ENODEV; -+ int ma = 0; -+ -+ mutex_lock(&bm->mutex); -+ if (bm->battery_present) -+ ma = n810bm_measure_batt_current_async(bm); -+ count = snprintf(buf, PAGE_SIZE, "%d\n", ma); -+ mutex_unlock(&bm->mutex); -+ -+ return count; -+} -+static DEVICE_ATTR(battery_current, S_IRUGO, -+ n810bm_attr_battery_current_show, NULL); -+ -+static const struct device_attribute *n810bm_attrs[] = { -+ &dev_attr_battery_present, -+ &dev_attr_battery_level, -+ &dev_attr_battery_current, -+ &dev_attr_battery_capacity, -+ &dev_attr_battery_temp, -+ &dev_attr_backup_battery_voltage, -+ &dev_attr_charger_present, -+ &dev_attr_charger_state, -+ &dev_attr_charger_verbose, -+ &dev_attr_charger_voltage, -+ &dev_attr_charger_enable, -+ &dev_attr_charger_pwm, -+}; -+ -+static void n810bm_notify_work(struct work_struct *work) -+{ -+ struct n810bm *bm = container_of(work, struct n810bm, notify_work); -+ unsigned long notify_flags; -+ -+ notify_flags = xchg(&bm->notify_flags, 0); -+ mb(); -+ -+#define do_notify(attr_name) \ -+ do { \ -+ if (notify_flags & (1 << N810BM_NOTIFY_##attr_name)) { \ -+ sysfs_notify(&bm->pdev->dev.kobj, NULL, \ -+ dev_attr_##attr_name.attr.name); \ -+ } \ -+ } while (0) -+ -+ do_notify(charger_present); -+ do_notify(charger_state); -+ do_notify(charger_pwm); -+} -+ -+static int n810bm_charger_set_current_pwm(struct lipocharge *c, -+ unsigned int duty_cycle) -+{ -+ struct n810bm *bm = container_of(c, struct n810bm, charger); -+ int err = -EINVAL; -+ -+ WARN_ON(!mutex_is_locked(&bm->mutex)); -+ if (WARN_ON(duty_cycle > 0xFF)) -+ goto out; -+ if (WARN_ON(!bm->charger_enabled)) -+ goto out; -+ if (WARN_ON(!bm->battery_present || !bm->charger_present)) -+ goto out; -+ -+ if (duty_cycle != bm->active_current_pwm) { -+ bm->active_current_pwm = duty_cycle; -+ tahvo_write(bm, TAHVO_REG_CHGCURR, duty_cycle); -+ n810bm_notify_charger_pwm(bm); -+ } -+ -+ err = 0; -+out: -+ -+ return err; -+} -+ -+static void n810bm_charger_emergency(struct lipocharge *c) -+{ -+ struct n810bm *bm = container_of(c, struct n810bm, charger); -+ -+ n810bm_emergency(bm, "Battery charger fault"); -+} -+ -+static void n810bm_hw_exit(struct n810bm *bm) -+{ -+ n810bm_stop_charge(bm); -+ retu_write(bm, RETU_REG_ADCSCR, 0); -+} -+ -+static int n810bm_hw_init(struct n810bm *bm) -+{ -+ int err; -+ -+ err = n810bm_check_adc_sanity(bm); -+ if (err) -+ return err; -+ -+ n810bm_stop_charge(bm); -+ -+ return 0; -+} -+ -+static void n810bm_cancel_and_flush_work(struct n810bm *bm) -+{ -+ cancel_delayed_work_sync(&bm->periodic_check_work); -+ cancel_work_sync(&bm->notify_work); -+ cancel_work_sync(&bm->currmeas_irq_work); -+ flush_scheduled_work(); -+} -+ -+static int n810bm_device_init(struct n810bm *bm) -+{ -+ int attr_index; -+ int err; -+ -+ bm->charger.rate = LIPORATE_p6C; -+ bm->charger.top_voltage = 4100; -+ bm->charger.duty_cycle_max = 0xFF; -+ bm->charger.set_current_pwm = n810bm_charger_set_current_pwm; -+ bm->charger.emergency = n810bm_charger_emergency; -+ lipocharge_init(&bm->charger, &bm->pdev->dev); -+ -+ err = n810bm_hw_init(bm); -+ if (err) -+ goto error; -+ for (attr_index = 0; attr_index < ARRAY_SIZE(n810bm_attrs); attr_index++) { -+ err = device_create_file(&bm->pdev->dev, n810bm_attrs[attr_index]); -+ if (err) -+ goto err_unwind_attrs; -+ } -+/*XXX -+ err = retu_request_irq(RETU_INT_ADCS, -+ n810bm_adc_irq_handler, -+ (unsigned long)bm, "n810bm"); -+ if (err) -+ goto err_unwind_attrs; -+*/ -+ err = tahvo_request_irq(TAHVO_INT_BATCURR, -+ n810bm_tahvo_current_measure_irq_handler, -+ (unsigned long)bm, "n810bm"); -+ if (err) -+ goto err_free_retu_irq; -+ tahvo_disable_irq(TAHVO_INT_BATCURR); -+ -+ schedule_delayed_work(&bm->periodic_check_work, -+ round_jiffies_relative(N810BM_CHECK_INTERVAL)); -+ -+ bm->initialized = 1; -+ dev_info(&bm->pdev->dev, "Battery management initialized"); -+ -+ return 0; -+ -+err_free_retu_irq: -+//XXX retu_free_irq(RETU_INT_ADCS); -+err_unwind_attrs: -+ for (attr_index--; attr_index >= 0; attr_index--) -+ device_remove_file(&bm->pdev->dev, n810bm_attrs[attr_index]); -+/*err_exit:*/ -+ n810bm_hw_exit(bm); -+error: -+ n810bm_cancel_and_flush_work(bm); -+ -+ return err; -+} -+ -+static void n810bm_device_exit(struct n810bm *bm) -+{ -+ int i; -+ -+ if (!bm->initialized) -+ return; -+ -+ lipocharge_exit(&bm->charger); -+ tahvo_free_irq(TAHVO_INT_BATCURR); -+//XXX retu_free_irq(RETU_INT_ADCS); -+ for (i = 0; i < ARRAY_SIZE(n810bm_attrs); i++) -+ device_remove_file(&bm->pdev->dev, n810bm_attrs[i]); -+ -+ n810bm_cancel_and_flush_work(bm); -+ -+ n810bm_hw_exit(bm); -+ -+ bm->initialized = 0; -+} -+ -+static void n810bm_pmm_block_found(const struct firmware *fw, void *context) -+{ -+ struct n810bm *bm = context; -+ int err; -+ -+ if (!fw) { -+ dev_err(&bm->pdev->dev, -+ "CAL PMM block image file not found"); -+ goto err_release; -+ } -+ if (fw->size != N810BM_PMM_BLOCK_SIZE || -+ memcmp(fw->data, "BME-PMM-BLOCK01", 15) != 0) { -+ dev_err(&bm->pdev->dev, -+ "CAL PMM block image file has an invalid format"); -+ goto err_release; -+ } -+ -+ err = n810bm_parse_pmm_block(bm, fw); -+ if (err) -+ goto err_release; -+ release_firmware(fw); -+ -+ err = n810bm_device_init(bm); -+ if (err) { -+ dev_err(&bm->pdev->dev, -+ "Failed to initialized battery management (%d)", err); -+ goto error; -+ } -+ -+ return; -+err_release: -+ release_firmware(fw); -+error: -+ return; -+} -+ -+static int __devinit n810bm_probe(void) -+{ -+ struct n810bm *bm; -+ int err; -+ -+ if (!n810bm_retu_device || !n810bm_tahvo_device) -+ return 0; -+ -+ bm = kzalloc(sizeof(*bm), GFP_KERNEL); -+ if (!bm) -+ return -ENOMEM; -+ bm->pdev = n810bm_retu_device; -+ platform_set_drvdata(n810bm_retu_device, bm); -+ platform_set_drvdata(n810bm_tahvo_device, bm); -+ mutex_init(&bm->mutex); -+ INIT_DELAYED_WORK(&bm->periodic_check_work, n810bm_periodic_check_work); -+ INIT_WORK(&bm->notify_work, n810bm_notify_work); -+ INIT_WORK(&bm->currmeas_irq_work, n810bm_tahvo_current_measure_work); -+ -+ dev_info(&bm->pdev->dev, "Requesting CAL BME PMM block firmware file " -+ N810BM_PMM_BLOCK_FILENAME); -+ err = request_firmware_nowait(THIS_MODULE, 1, -+ N810BM_PMM_BLOCK_FILENAME, -+ &bm->pdev->dev, GFP_KERNEL, -+ bm, n810bm_pmm_block_found); -+ if (err) { -+ dev_err(&bm->pdev->dev, -+ "Failed to request CAL PMM block image file (%d)", err); -+ goto err_free; -+ } -+ -+ return 0; -+ -+err_free: -+ kfree(bm); -+ -+ return err; -+} -+ -+static void __devexit n810bm_remove(void) -+{ -+ struct n810bm *bm; -+ -+ if (!n810bm_retu_device || !n810bm_tahvo_device) -+ return; -+ bm = platform_get_drvdata(n810bm_retu_device); -+ -+ n810bm_device_exit(bm); -+ -+ kfree(bm); -+ platform_set_drvdata(n810bm_retu_device, NULL); -+ platform_set_drvdata(n810bm_tahvo_device, NULL); -+} -+ -+static int __devinit n810bm_retu_probe(struct platform_device *pdev) -+{ -+ n810bm_retu_device = pdev; -+ return n810bm_probe(); -+} -+ -+static int __devexit n810bm_retu_remove(struct platform_device *pdev) -+{ -+ n810bm_remove(); -+ n810bm_retu_device = NULL; -+ return 0; -+} -+ -+static int __devinit n810bm_tahvo_probe(struct platform_device *pdev) -+{ -+ n810bm_tahvo_device = pdev; -+ return n810bm_probe(); -+} -+ -+static int __devexit n810bm_tahvo_remove(struct platform_device *pdev) -+{ -+ n810bm_remove(); -+ n810bm_tahvo_device = NULL; -+ return 0; -+} -+ -+static struct platform_driver n810bm_retu_driver = { -+ .remove = __devexit_p(n810bm_retu_remove), -+ .driver = { -+ .name = "retu-n810bm", -+ } -+}; -+ -+static struct platform_driver n810bm_tahvo_driver = { -+ .remove = __devexit_p(n810bm_tahvo_remove), -+ .driver = { -+ .name = "tahvo-n810bm", -+ } -+}; -+ -+/* FIXME: for now alloc the device here... */ -+static struct platform_device n810bm_tahvo_dev = { -+ .name = "tahvo-n810bm", -+ .id = -1, -+}; -+ -+static int __init n810bm_modinit(void) -+{ -+ int err; -+ -+ //FIXME -+ err = platform_device_register(&n810bm_tahvo_dev); -+ if (err) -+ return err; -+ -+ err = platform_driver_probe(&n810bm_retu_driver, n810bm_retu_probe); -+ if (err) -+ return err; -+ err = platform_driver_probe(&n810bm_tahvo_driver, n810bm_tahvo_probe); -+ if (err) { -+ platform_driver_unregister(&n810bm_retu_driver); -+ return err; -+ } -+ -+ return 0; -+} -+module_init(n810bm_modinit); -+ -+static void __exit n810bm_modexit(void) -+{ -+ //FIXME -+ platform_device_unregister(&n810bm_tahvo_dev); -+ -+ platform_driver_unregister(&n810bm_tahvo_driver); -+ platform_driver_unregister(&n810bm_retu_driver); -+} -+module_exit(n810bm_modexit); -+ -+MODULE_DESCRIPTION("Nokia n810 battery management"); -+MODULE_FIRMWARE(N810BM_PMM_BLOCK_FILENAME); -+MODULE_LICENSE("GPL"); -+MODULE_AUTHOR("Michael Buesch"); ---- /dev/null -+++ b/drivers/cbus/lipocharge.c -@@ -0,0 +1,183 @@ -+/* -+ * Generic LIPO battery charger -+ * -+ * Copyright (c) 2010-2011 Michael Buesch <mb@bu3sch.de> -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version 2 -+ * of the License, or (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ */ -+ -+#define DEBUG -+ -+#include "lipocharge.h" -+ -+#include <linux/slab.h> -+ -+ -+/* Hysteresis constants */ -+#define CURRENT_HYST 30 /* mA */ -+#define VOLTAGE_HYST 10 /* mV */ -+ -+/* Threshold constants */ -+#define FINISH_CURRENT_PERCENT 3 -+ -+ -+/* Returns the requested first-stage charge current in mA */ -+static inline unsigned int get_stage1_charge_current(struct lipocharge *c) -+{ -+ /* current = (capacity * C) */ -+ return c->capacity * c->rate / 1000; -+} -+ -+void lipocharge_init(struct lipocharge *c, struct device *dev) -+{ -+ c->dev = dev; -+ c->state = LIPO_IDLE; -+} -+ -+void lipocharge_exit(struct lipocharge *c) -+{ -+ c->state = LIPO_IDLE; -+} -+ -+int lipocharge_start(struct lipocharge *c) -+{ -+ int err; -+ -+ if (c->state != LIPO_IDLE) -+ return -EBUSY; -+ if (!c->set_current_pwm || !c->emergency) -+ return -EINVAL; -+ if (!c->top_voltage || c->top_voltage > 4200) -+ return -EINVAL; -+ -+ c->active_duty_cycle = 0; -+ err = c->set_current_pwm(c, c->active_duty_cycle); -+ if (err) -+ return err; -+ c->state = LIPO_FIRST_STAGE; -+ -+ return 0; -+} -+ -+void lipocharge_stop(struct lipocharge *c) -+{ -+ if (c->state == LIPO_IDLE) -+ return; -+ c->state = LIPO_IDLE; -+} -+ -+static int lipocharge_increase_current(struct lipocharge *c, -+ unsigned int inc_permille) -+{ -+ int old_pwm, new_pwm; -+ -+ if (c->active_duty_cycle >= c->duty_cycle_max) -+ return 0; -+ -+ old_pwm = c->active_duty_cycle; -+ new_pwm = old_pwm + (c->duty_cycle_max * inc_permille / 1000); -+ new_pwm = min(new_pwm, (int)c->duty_cycle_max); -+ c->active_duty_cycle = new_pwm; -+ -+ dev_dbg(c->dev, "lipo: Increasing duty_cycle by " -+ "%u permille (0x%02X -> 0x%02X)", -+ inc_permille, old_pwm, new_pwm); -+ -+ return c->set_current_pwm(c, c->active_duty_cycle); -+} -+ -+static int lipocharge_decrease_current(struct lipocharge *c, -+ unsigned int dec_permille) -+{ -+ int old_pwm, new_pwm; -+ -+ if (c->active_duty_cycle <= 0) -+ return 0; -+ -+ old_pwm = c->active_duty_cycle; -+ new_pwm = old_pwm - (c->duty_cycle_max * dec_permille / 1000); -+ new_pwm = max(0, new_pwm); -+ c->active_duty_cycle = new_pwm; -+ -+ dev_dbg(c->dev, "lipo: Decreasing duty_cycle by " -+ "%u permille (0x%02X -> 0x%02X)", -+ dec_permille, old_pwm, new_pwm); -+ -+ return c->set_current_pwm(c, c->active_duty_cycle); -+} -+ -+/** lipocharge_update_state - Update the charge state -+ * @c: The context. -+ * @voltage_mV: The measured battery voltage. -+ * @current_mA: The measured charge current. -+ * negative -> drain. -+ * positive -> charge. -+ * @temp_K: Battery temperature in K. -+ * -+ * Returns 0 on success, -1 on error. -+ * Returns 1, if the charging process is finished. -+ */ -+int lipocharge_update_state(struct lipocharge *c, -+ unsigned int voltage_mV, -+ int current_mA, -+ unsigned int temp_K) -+{ -+ int requested_current, current_diff; -+ int err; -+ unsigned int permille; -+ -+ //TODO temp -+ -+restart: -+ switch (c->state) { -+ case LIPO_IDLE: -+ dev_err(c->dev, "%s: called while idle", __func__); -+ return -EINVAL; -+ case LIPO_FIRST_STAGE: /* Constant current */ -+//printk("GOT %u %d %u\n", voltage_mV, current_mA, temp_K); -+ if (voltage_mV >= c->top_voltage) { -+ /* Float voltage reached. -+ * Switch charger mode to "constant current" */ -+ c->state = LIPO_SECOND_STAGE; -+ dev_dbg(c->dev, "Switched to second charging stage."); -+ goto restart; -+ } -+ /* Float voltage not reached, yet. -+ * Try to get the requested constant current. */ -+ requested_current = get_stage1_charge_current(c); -+ if (current_mA < 0) -+ current_mA = 0; -+ current_diff = requested_current - current_mA; -+ if (abs(requested_current - current_mA) > CURRENT_HYST) { -+ if (current_diff > 0) { -+ /* Increase current */ -+ permille = current_diff * 1000 / requested_current; -+ permille /= 2; -+ err = lipocharge_increase_current(c, permille); -+ if (err) -+ return err; -+ } else { -+ /* Decrease current */ -+ permille = (-current_diff) * 1000 / requested_current; -+ permille /= 2; -+ err = lipocharge_decrease_current(c, permille); -+ if (err) -+ return err; -+ } -+ } -+ break; -+ case LIPO_SECOND_STAGE: /* Constant voltage */ -+ //TODO -+ break; -+ } -+ -+ return 0; -+} ---- /dev/null -+++ b/drivers/cbus/lipocharge.h -@@ -0,0 +1,60 @@ -+#ifndef LIPOCHARGE_H_ -+#define LIPOCHARGE_H_ -+ -+#include <linux/types.h> -+#include <linux/device.h> -+ -+ -+#define LIPORATE(a,b) (((a) * 1000) + ((b) * 100)) -+#define LIPORATE_p6C LIPORATE(0,6) /* 0.6C */ -+ -+enum lipocharge_state { -+ LIPO_IDLE = 0, /* Not charging */ -+ LIPO_FIRST_STAGE, /* Charging: constant current */ -+ LIPO_SECOND_STAGE, /* Charging: constant voltage */ -+}; -+ -+/** struct lipocharge - A generic LIPO charger -+ * -+ * @capacity: Battery capacity in mAh. -+ * @rate: Charge rate. -+ * @top_voltage: Fully charged voltage, in mV. -+ * @duty_cycle_max: Max value for duty_cycle. -+ * -+ * @set_charge_current: Set the charge current PWM duty cycle. -+ * @emergency: Something went wrong. Force shutdown. -+ */ -+struct lipocharge { -+ unsigned int capacity; -+ unsigned int rate; -+ unsigned int top_voltage; -+ unsigned int duty_cycle_max; -+ -+ int (*set_current_pwm)(struct lipocharge *c, unsigned int duty_cycle); -+ void (*emergency)(struct lipocharge *c); -+ -+ /* internal */ -+ struct device *dev; -+ enum lipocharge_state state; -+ unsigned int active_duty_cycle; -+ -+ //TODO implement timer to cut power after maximum charge time. -+}; -+ -+void lipocharge_init(struct lipocharge *c, struct device *dev); -+void lipocharge_exit(struct lipocharge *c); -+ -+int lipocharge_start(struct lipocharge *c); -+void lipocharge_stop(struct lipocharge *c); -+ -+int lipocharge_update_state(struct lipocharge *c, -+ unsigned int voltage_mV, -+ int current_mA, -+ unsigned int temp_K); -+ -+static inline bool lipocharge_is_charging(struct lipocharge *c) -+{ -+ return (c->state != LIPO_IDLE); -+} -+ -+#endif /* LIPOCHARGE_H_ */ ---- a/drivers/cbus/cbus.c -+++ b/drivers/cbus/cbus.c -@@ -35,6 +35,7 @@ - #include <linux/platform_device.h> - - #include <plat/cbus.h> -+#include <linux/reboot.h> - - #include "cbus.h" - -@@ -323,6 +324,13 @@ static void __exit cbus_bus_exit(void) - } - module_exit(cbus_bus_exit); - -+void cbus_emergency(void) -+{ -+ machine_power_off(); -+ panic("cbus: Failed to halt machine in emergency state\n"); -+} -+EXPORT_SYMBOL(cbus_emergency); -+ - MODULE_DESCRIPTION("CBUS serial protocol"); - MODULE_LICENSE("GPL"); - MODULE_AUTHOR("Juha Yrjölä"); ---- a/drivers/cbus/cbus.h -+++ b/drivers/cbus/cbus.h -@@ -26,4 +26,6 @@ - extern int cbus_read_reg(unsigned dev, unsigned reg); - extern int cbus_write_reg(unsigned dev, unsigned reg, unsigned val); - -+NORET_TYPE void cbus_emergency(void) ATTRIB_NORET; -+ - #endif /* __DRIVERS_CBUS_CBUS_H */ ---- a/drivers/cbus/retu.c -+++ b/drivers/cbus/retu.c -@@ -425,6 +425,11 @@ static int retu_allocate_children(struct - if (!child) - return -ENOMEM; - -+ child = retu_allocate_child("retu-n810bm", parent, irq_base, -+ RETU_INT_ADCS, -1, 1); -+ if (!child) -+ return -ENOMEM; -+ - return 0; - } - ---- a/drivers/cbus/tahvo.c -+++ b/drivers/cbus/tahvo.c -@@ -54,6 +54,7 @@ static int tahvo_is_betty; - - static struct tasklet_struct tahvo_tasklet; - spinlock_t tahvo_lock = SPIN_LOCK_UNLOCKED; -+EXPORT_SYMBOL(tahvo_lock); - - struct tahvo_irq_handler_desc { - int (*func)(unsigned long); -@@ -115,6 +116,7 @@ void tahvo_set_clear_reg_bits(unsigned r - tahvo_write_reg(reg, w); - spin_unlock_irqrestore(&tahvo_lock, flags); - } -+EXPORT_SYMBOL(tahvo_set_clear_reg_bits); - - /* - * Disable given TAHVO interrupt |